From bbcc9fa0afe4f8a36e8777e14f7b016090605306 Mon Sep 17 00:00:00 2001 From: Guennadi Liakhovetski Date: Thu, 18 Apr 2013 18:35:39 -0300 Subject: [PATCH 0001/1048] [media] mt9p031: Power down the sensor if no supported device has been detected The mt9p031 driver first accesses the I2C device in its .registered() method. While doing that it first powers the device up, but if probing fails, it doesn't power the chip back down. This patch fixes that bug. Signed-off-by: Guennadi Liakhovetski Signed-off-by: Laurent Pinchart Signed-off-by: Mauro Carvalho Chehab --- drivers/media/i2c/mt9p031.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/media/i2c/mt9p031.c b/drivers/media/i2c/mt9p031.c index 28cf95b37285..8de84c0a48dc 100644 --- a/drivers/media/i2c/mt9p031.c +++ b/drivers/media/i2c/mt9p031.c @@ -849,18 +849,18 @@ static int mt9p031_registered(struct v4l2_subdev *subdev) /* Read out the chip version register */ data = mt9p031_read(client, MT9P031_CHIP_VERSION); + mt9p031_power_off(mt9p031); + if (data != MT9P031_CHIP_VERSION_VALUE) { dev_err(&client->dev, "MT9P031 not detected, wrong version " "0x%04x\n", data); return -ENODEV; } - mt9p031_power_off(mt9p031); - dev_info(&client->dev, "MT9P031 detected at address 0x%02x\n", client->addr); - return ret; + return 0; } static int mt9p031_open(struct v4l2_subdev *subdev, struct v4l2_subdev_fh *fh) From 2660a22b55ae9a01c1e1117e9d514427834704bc Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Thu, 2 May 2013 07:57:51 -0300 Subject: [PATCH 0002/1048] [media] mt9p031: Use gpio_is_valid() Replace the manual validity checks for the reset GPIO with the gpio_is_valid() function. Signed-off-by: Laurent Pinchart Reviewed-by: Sylwester Nawrocki Acked-by: Lad, Prabhakar Signed-off-by: Mauro Carvalho Chehab --- drivers/media/i2c/mt9p031.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/media/i2c/mt9p031.c b/drivers/media/i2c/mt9p031.c index 8de84c0a48dc..bf49899945f8 100644 --- a/drivers/media/i2c/mt9p031.c +++ b/drivers/media/i2c/mt9p031.c @@ -272,7 +272,7 @@ static inline int mt9p031_pll_disable(struct mt9p031 *mt9p031) static int mt9p031_power_on(struct mt9p031 *mt9p031) { /* Ensure RESET_BAR is low */ - if (mt9p031->reset != -1) { + if (gpio_is_valid(mt9p031->reset)) { gpio_set_value(mt9p031->reset, 0); usleep_range(1000, 2000); } @@ -287,7 +287,7 @@ static int mt9p031_power_on(struct mt9p031 *mt9p031) clk_prepare_enable(mt9p031->clk); /* Now RESET_BAR must be high */ - if (mt9p031->reset != -1) { + if (gpio_is_valid(mt9p031->reset)) { gpio_set_value(mt9p031->reset, 1); usleep_range(1000, 2000); } @@ -297,7 +297,7 @@ static int mt9p031_power_on(struct mt9p031 *mt9p031) static void mt9p031_power_off(struct mt9p031 *mt9p031) { - if (mt9p031->reset != -1) { + if (gpio_is_valid(mt9p031->reset)) { gpio_set_value(mt9p031->reset, 0); usleep_range(1000, 2000); } @@ -1031,7 +1031,7 @@ static int mt9p031_probe(struct i2c_client *client, mt9p031->format.field = V4L2_FIELD_NONE; mt9p031->format.colorspace = V4L2_COLORSPACE_SRGB; - if (pdata->reset != -1) { + if (gpio_is_valid(pdata->reset)) { ret = devm_gpio_request_one(&client->dev, pdata->reset, GPIOF_OUT_INIT_LOW, "mt9p031_rst"); if (ret < 0) From 9462550f66dfbbb2eb0961af2c9d2c3e000d9239 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Thu, 2 May 2013 08:34:30 -0300 Subject: [PATCH 0003/1048] [media] mt9v032: Free control handler in cleanup paths The control handler must be freed in the probe error path and in the remove handler. Signed-off-by: Laurent Pinchart Signed-off-by: Mauro Carvalho Chehab --- drivers/media/i2c/mt9v032.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/media/i2c/mt9v032.c b/drivers/media/i2c/mt9v032.c index 3f356cb28256..24ea6fd3ee81 100644 --- a/drivers/media/i2c/mt9v032.c +++ b/drivers/media/i2c/mt9v032.c @@ -830,8 +830,11 @@ static int mt9v032_probe(struct i2c_client *client, mt9v032->pad.flags = MEDIA_PAD_FL_SOURCE; ret = media_entity_init(&mt9v032->subdev.entity, 1, &mt9v032->pad, 0); - if (ret < 0) + + if (ret < 0) { + v4l2_ctrl_handler_free(&mt9v032->ctrls); kfree(mt9v032); + } return ret; } @@ -841,9 +844,11 @@ static int mt9v032_remove(struct i2c_client *client) struct v4l2_subdev *subdev = i2c_get_clientdata(client); struct mt9v032 *mt9v032 = to_mt9v032(subdev); + v4l2_ctrl_handler_free(&mt9v032->ctrls); v4l2_device_unregister_subdev(subdev); media_entity_cleanup(&subdev->entity); kfree(mt9v032); + return 0; } From c7e3cc3ca1ff2fe1aeffd2ba642548d79f9a73dc Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Thu, 2 May 2013 10:09:07 -0300 Subject: [PATCH 0004/1048] [media] tvp514x: Fix double free The tvp514x data structure is allocated using devm_kzalloc(). Freeing it explictly would result in a double free. Fix it. Signed-off-by: Laurent Pinchart Acked-by: Lad, Prabhakar Signed-off-by: Mauro Carvalho Chehab --- drivers/media/i2c/tvp514x.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/media/i2c/tvp514x.c b/drivers/media/i2c/tvp514x.c index ab8f3fee7e94..7438e015d879 100644 --- a/drivers/media/i2c/tvp514x.c +++ b/drivers/media/i2c/tvp514x.c @@ -1120,7 +1120,6 @@ tvp514x_probe(struct i2c_client *client, const struct i2c_device_id *id) if (ret < 0) { v4l2_err(sd, "%s decoder driver failed to register !!\n", sd->name); - kfree(decoder); return ret; } #endif From 95323361e5313733a54771c5059f5b352adbf32c Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Thu, 2 May 2013 11:11:50 -0300 Subject: [PATCH 0005/1048] [media] media: i2c: Convert to gpio_request_one() Replace gpio_request() with gpio_request_one() and remove the associated gpio_direction_output() calls. Signed-off-by: Laurent Pinchart Acked-by: Sylwester Nawrocki Signed-off-by: Mauro Carvalho Chehab --- drivers/media/i2c/adv7183.c | 14 +++++++------- drivers/media/i2c/m5mols/m5mols_core.c | 6 ++++-- drivers/media/i2c/noon010pc30.c | 8 ++++---- drivers/media/i2c/vs6624.c | 3 +-- 4 files changed, 16 insertions(+), 15 deletions(-) diff --git a/drivers/media/i2c/adv7183.c b/drivers/media/i2c/adv7183.c index 56a1fa4af0fe..2bc032894bae 100644 --- a/drivers/media/i2c/adv7183.c +++ b/drivers/media/i2c/adv7183.c @@ -474,9 +474,9 @@ static int adv7183_s_stream(struct v4l2_subdev *sd, int enable) struct adv7183 *decoder = to_adv7183(sd); if (enable) - gpio_direction_output(decoder->oe_pin, 0); + gpio_set_value(decoder->oe_pin, 0); else - gpio_direction_output(decoder->oe_pin, 1); + gpio_set_value(decoder->oe_pin, 1); udelay(1); return 0; } @@ -580,13 +580,15 @@ static int adv7183_probe(struct i2c_client *client, decoder->reset_pin = pin_array[0]; decoder->oe_pin = pin_array[1]; - if (gpio_request(decoder->reset_pin, "ADV7183 Reset")) { + if (gpio_request_one(decoder->reset_pin, GPIOF_OUT_INIT_LOW, + "ADV7183 Reset")) { v4l_err(client, "failed to request GPIO %d\n", decoder->reset_pin); ret = -EBUSY; goto err_free_decoder; } - if (gpio_request(decoder->oe_pin, "ADV7183 Output Enable")) { + if (gpio_request_one(decoder->oe_pin, GPIOF_OUT_INIT_HIGH, + "ADV7183 Output Enable")) { v4l_err(client, "failed to request GPIO %d\n", decoder->oe_pin); ret = -EBUSY; goto err_free_reset; @@ -619,12 +621,10 @@ static int adv7183_probe(struct i2c_client *client, decoder->input = ADV7183_COMPOSITE4; decoder->output = ADV7183_8BIT_OUT; - gpio_direction_output(decoder->oe_pin, 1); /* reset chip */ - gpio_direction_output(decoder->reset_pin, 0); /* reset pulse width at least 5ms */ mdelay(10); - gpio_direction_output(decoder->reset_pin, 1); + gpio_set_value(decoder->reset_pin, 1); /* wait 5ms before any further i2c writes are performed */ mdelay(5); diff --git a/drivers/media/i2c/m5mols/m5mols_core.c b/drivers/media/i2c/m5mols/m5mols_core.c index 0b899cb6cda1..f0b870c06376 100644 --- a/drivers/media/i2c/m5mols/m5mols_core.c +++ b/drivers/media/i2c/m5mols/m5mols_core.c @@ -930,6 +930,7 @@ static int m5mols_probe(struct i2c_client *client, const struct i2c_device_id *id) { const struct m5mols_platform_data *pdata = client->dev.platform_data; + unsigned long gpio_flags; struct m5mols_info *info; struct v4l2_subdev *sd; int ret; @@ -956,12 +957,13 @@ static int m5mols_probe(struct i2c_client *client, info->pdata = pdata; info->set_power = pdata->set_power; - ret = gpio_request(pdata->gpio_reset, "M5MOLS_NRST"); + gpio_flags = pdata->reset_polarity + ? GPIOF_OUT_INIT_HIGH : GPIOF_OUT_INIT_LOW; + ret = gpio_request_one(pdata->gpio_reset, gpio_flags, "M5MOLS_NRST"); if (ret) { dev_err(&client->dev, "Failed to request gpio: %d\n", ret); goto out_free; } - gpio_direction_output(pdata->gpio_reset, pdata->reset_polarity); ret = regulator_bulk_get(&client->dev, ARRAY_SIZE(supplies), supplies); if (ret) { diff --git a/drivers/media/i2c/noon010pc30.c b/drivers/media/i2c/noon010pc30.c index 8554b47f993a..a115842ab996 100644 --- a/drivers/media/i2c/noon010pc30.c +++ b/drivers/media/i2c/noon010pc30.c @@ -746,24 +746,24 @@ static int noon010_probe(struct i2c_client *client, info->curr_win = &noon010_sizes[0]; if (gpio_is_valid(pdata->gpio_nreset)) { - ret = gpio_request(pdata->gpio_nreset, "NOON010PC30 NRST"); + ret = gpio_request_one(pdata->gpio_nreset, GPIOF_OUT_INIT_LOW, + "NOON010PC30 NRST"); if (ret) { dev_err(&client->dev, "GPIO request error: %d\n", ret); goto np_err; } info->gpio_nreset = pdata->gpio_nreset; - gpio_direction_output(info->gpio_nreset, 0); gpio_export(info->gpio_nreset, 0); } if (gpio_is_valid(pdata->gpio_nstby)) { - ret = gpio_request(pdata->gpio_nstby, "NOON010PC30 NSTBY"); + ret = gpio_request_one(pdata->gpio_nstby, GPIOF_OUT_INIT_LOW, + "NOON010PC30 NSTBY"); if (ret) { dev_err(&client->dev, "GPIO request error: %d\n", ret); goto np_gpio_err; } info->gpio_nstby = pdata->gpio_nstby; - gpio_direction_output(info->gpio_nstby, 0); gpio_export(info->gpio_nstby, 0); } diff --git a/drivers/media/i2c/vs6624.c b/drivers/media/i2c/vs6624.c index f366fad6269e..6b8c0b7aa488 100644 --- a/drivers/media/i2c/vs6624.c +++ b/drivers/media/i2c/vs6624.c @@ -805,12 +805,11 @@ static int vs6624_probe(struct i2c_client *client, if (ce == NULL) return -EINVAL; - ret = gpio_request(*ce, "VS6624 Chip Enable"); + ret = gpio_request_one(*ce, GPIOF_OUT_INIT_HIGH, "VS6624 Chip Enable"); if (ret) { v4l_err(client, "failed to request GPIO %d\n", *ce); return ret; } - gpio_direction_output(*ce, 1); /* wait 100ms before any further i2c writes are performed */ mdelay(100); From c02b211df6fc54e51ee554c27a6736a11255a764 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Thu, 2 May 2013 08:29:43 -0300 Subject: [PATCH 0006/1048] [media] media: i2c: Convert to devm_kzalloc() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Using the managed function the kfree() calls can be removed from the probe error path and the remove handler. Signed-off-by: Laurent Pinchart Acked-by: Sylwester Nawrocki Acked-by: Lad, Prabhakar Acked-by: Andy Shevchenko Reviewed-by: Benoît Thébaudeau Signed-off-by: Mauro Carvalho Chehab --- drivers/media/i2c/ad9389b.c | 8 ++------ drivers/media/i2c/adp1653.c | 5 ++--- drivers/media/i2c/adv7170.c | 3 +-- drivers/media/i2c/adv7175.c | 3 +-- drivers/media/i2c/adv7180.c | 4 +--- drivers/media/i2c/adv7183.c | 8 ++------ drivers/media/i2c/adv7393.c | 8 ++------ drivers/media/i2c/adv7604.c | 11 +++-------- drivers/media/i2c/ak881x.c | 4 +--- drivers/media/i2c/as3645a.c | 7 ++----- drivers/media/i2c/bt819.c | 4 +--- drivers/media/i2c/bt856.c | 3 +-- drivers/media/i2c/bt866.c | 3 +-- drivers/media/i2c/cs5345.c | 4 +--- drivers/media/i2c/cs53l32a.c | 4 +--- drivers/media/i2c/cx25840/cx25840-core.c | 4 +--- drivers/media/i2c/cx25840/cx25840-ir.c | 7 ++----- drivers/media/i2c/ir-kbd-i2c.c | 10 +++------- drivers/media/i2c/ks0127.c | 3 +-- drivers/media/i2c/m52790.c | 3 +-- drivers/media/i2c/m5mols/m5mols_core.c | 8 +++----- drivers/media/i2c/msp3400-driver.c | 5 +---- drivers/media/i2c/mt9m032.c | 4 +--- drivers/media/i2c/mt9t001.c | 4 +--- drivers/media/i2c/mt9v011.c | 6 ++---- drivers/media/i2c/mt9v032.c | 7 ++----- drivers/media/i2c/noon010pc30.c | 5 ++--- drivers/media/i2c/ov7640.c | 5 ++--- drivers/media/i2c/ov7670.c | 5 +---- drivers/media/i2c/saa6588.c | 10 +++------- drivers/media/i2c/saa7110.c | 4 +--- drivers/media/i2c/saa7115.c | 4 +--- drivers/media/i2c/saa7127.c | 4 +--- drivers/media/i2c/saa717x.c | 5 +---- drivers/media/i2c/saa7185.c | 3 +-- drivers/media/i2c/saa7191.c | 4 +--- drivers/media/i2c/sony-btf-mpx.c | 3 +-- drivers/media/i2c/sr030pc30.c | 4 +--- drivers/media/i2c/tda7432.c | 4 +--- drivers/media/i2c/tda9840.c | 3 +-- drivers/media/i2c/tea6415c.c | 3 +-- drivers/media/i2c/tea6420.c | 3 +-- drivers/media/i2c/tlv320aic23b.c | 4 +--- drivers/media/i2c/tvaudio.c | 5 +---- drivers/media/i2c/tvp5150.c | 14 ++++---------- drivers/media/i2c/tw2804.c | 5 +---- drivers/media/i2c/tw9903.c | 5 +---- drivers/media/i2c/tw9906.c | 5 +---- drivers/media/i2c/uda1342.c | 3 +-- drivers/media/i2c/upd64031a.c | 3 +-- drivers/media/i2c/upd64083.c | 3 +-- drivers/media/i2c/vp27smpx.c | 3 +-- drivers/media/i2c/vpx3220.c | 5 ++--- drivers/media/i2c/vs6624.c | 9 ++------- drivers/media/i2c/wm8739.c | 4 +--- drivers/media/i2c/wm8775.c | 4 +--- 56 files changed, 79 insertions(+), 202 deletions(-) diff --git a/drivers/media/i2c/ad9389b.c b/drivers/media/i2c/ad9389b.c index 58344b6c3a55..15043554cc8b 100644 --- a/drivers/media/i2c/ad9389b.c +++ b/drivers/media/i2c/ad9389b.c @@ -1188,15 +1188,14 @@ static int ad9389b_probe(struct i2c_client *client, const struct i2c_device_id * v4l_dbg(1, debug, client, "detecting ad9389b client on address 0x%x\n", client->addr << 1); - state = kzalloc(sizeof(struct ad9389b_state), GFP_KERNEL); + state = devm_kzalloc(&client->dev, sizeof(*state), GFP_KERNEL); if (!state) return -ENOMEM; /* Platform data */ if (pdata == NULL) { v4l_err(client, "No platform data!\n"); - err = -ENODEV; - goto err_free; + return -ENODEV; } memcpy(&state->pdata, pdata, sizeof(state->pdata)); @@ -1276,8 +1275,6 @@ err_entity: media_entity_cleanup(&sd->entity); err_hdl: v4l2_ctrl_handler_free(&state->hdl); -err_free: - kfree(state); return err; } @@ -1302,7 +1299,6 @@ static int ad9389b_remove(struct i2c_client *client) v4l2_device_unregister_subdev(sd); media_entity_cleanup(&sd->entity); v4l2_ctrl_handler_free(sd->ctrl_handler); - kfree(get_ad9389b_state(sd)); return 0; } diff --git a/drivers/media/i2c/adp1653.c b/drivers/media/i2c/adp1653.c index ef75abe5984c..873fe1949e98 100644 --- a/drivers/media/i2c/adp1653.c +++ b/drivers/media/i2c/adp1653.c @@ -417,7 +417,7 @@ static int adp1653_probe(struct i2c_client *client, if (client->dev.platform_data == NULL) return -ENODEV; - flash = kzalloc(sizeof(*flash), GFP_KERNEL); + flash = devm_kzalloc(&client->dev, sizeof(*flash), GFP_KERNEL); if (flash == NULL) return -ENOMEM; @@ -443,7 +443,6 @@ static int adp1653_probe(struct i2c_client *client, free_and_quit: v4l2_ctrl_handler_free(&flash->ctrls); - kfree(flash); return ret; } @@ -455,7 +454,7 @@ static int adp1653_remove(struct i2c_client *client) v4l2_device_unregister_subdev(&flash->subdev); v4l2_ctrl_handler_free(&flash->ctrls); media_entity_cleanup(&flash->subdev.entity); - kfree(flash); + return 0; } diff --git a/drivers/media/i2c/adv7170.c b/drivers/media/i2c/adv7170.c index 6bc01fb98ff8..d07689d44354 100644 --- a/drivers/media/i2c/adv7170.c +++ b/drivers/media/i2c/adv7170.c @@ -359,7 +359,7 @@ static int adv7170_probe(struct i2c_client *client, v4l_info(client, "chip found @ 0x%x (%s)\n", client->addr << 1, client->adapter->name); - encoder = kzalloc(sizeof(struct adv7170), GFP_KERNEL); + encoder = devm_kzalloc(&client->dev, sizeof(*encoder), GFP_KERNEL); if (encoder == NULL) return -ENOMEM; sd = &encoder->sd; @@ -384,7 +384,6 @@ static int adv7170_remove(struct i2c_client *client) struct v4l2_subdev *sd = i2c_get_clientdata(client); v4l2_device_unregister_subdev(sd); - kfree(to_adv7170(sd)); return 0; } diff --git a/drivers/media/i2c/adv7175.c b/drivers/media/i2c/adv7175.c index c7640fab5730..eaefa50b8d28 100644 --- a/drivers/media/i2c/adv7175.c +++ b/drivers/media/i2c/adv7175.c @@ -409,7 +409,7 @@ static int adv7175_probe(struct i2c_client *client, v4l_info(client, "chip found @ 0x%x (%s)\n", client->addr << 1, client->adapter->name); - encoder = kzalloc(sizeof(struct adv7175), GFP_KERNEL); + encoder = devm_kzalloc(&client->dev, sizeof(*encoder), GFP_KERNEL); if (encoder == NULL) return -ENOMEM; sd = &encoder->sd; @@ -434,7 +434,6 @@ static int adv7175_remove(struct i2c_client *client) struct v4l2_subdev *sd = i2c_get_clientdata(client); v4l2_device_unregister_subdev(sd); - kfree(to_adv7175(sd)); return 0; } diff --git a/drivers/media/i2c/adv7180.c b/drivers/media/i2c/adv7180.c index afd561ab190d..3d1456780318 100644 --- a/drivers/media/i2c/adv7180.c +++ b/drivers/media/i2c/adv7180.c @@ -555,7 +555,7 @@ static int adv7180_probe(struct i2c_client *client, v4l_info(client, "chip found @ 0x%02x (%s)\n", client->addr, client->adapter->name); - state = kzalloc(sizeof(struct adv7180_state), GFP_KERNEL); + state = devm_kzalloc(&client->dev, sizeof(*state), GFP_KERNEL); if (state == NULL) { ret = -ENOMEM; goto err; @@ -582,7 +582,6 @@ err_free_ctrl: err_unreg_subdev: mutex_destroy(&state->mutex); v4l2_device_unregister_subdev(sd); - kfree(state); err: printk(KERN_ERR KBUILD_MODNAME ": Failed to probe: %d\n", ret); return ret; @@ -607,7 +606,6 @@ static int adv7180_remove(struct i2c_client *client) mutex_destroy(&state->mutex); v4l2_device_unregister_subdev(sd); - kfree(to_state(sd)); return 0; } diff --git a/drivers/media/i2c/adv7183.c b/drivers/media/i2c/adv7183.c index 2bc032894bae..56904174abc3 100644 --- a/drivers/media/i2c/adv7183.c +++ b/drivers/media/i2c/adv7183.c @@ -573,7 +573,7 @@ static int adv7183_probe(struct i2c_client *client, if (pin_array == NULL) return -EINVAL; - decoder = kzalloc(sizeof(struct adv7183), GFP_KERNEL); + decoder = devm_kzalloc(&client->dev, sizeof(*decoder), GFP_KERNEL); if (decoder == NULL) return -ENOMEM; @@ -583,8 +583,7 @@ static int adv7183_probe(struct i2c_client *client, if (gpio_request_one(decoder->reset_pin, GPIOF_OUT_INIT_LOW, "ADV7183 Reset")) { v4l_err(client, "failed to request GPIO %d\n", decoder->reset_pin); - ret = -EBUSY; - goto err_free_decoder; + return -EBUSY; } if (gpio_request_one(decoder->oe_pin, GPIOF_OUT_INIT_HIGH, @@ -646,8 +645,6 @@ err_free_oe: gpio_free(decoder->oe_pin); err_free_reset: gpio_free(decoder->reset_pin); -err_free_decoder: - kfree(decoder); return ret; } @@ -660,7 +657,6 @@ static int adv7183_remove(struct i2c_client *client) v4l2_ctrl_handler_free(sd->ctrl_handler); gpio_free(decoder->oe_pin); gpio_free(decoder->reset_pin); - kfree(decoder); return 0; } diff --git a/drivers/media/i2c/adv7393.c b/drivers/media/i2c/adv7393.c index 3dc6098c7267..ec505098598a 100644 --- a/drivers/media/i2c/adv7393.c +++ b/drivers/media/i2c/adv7393.c @@ -410,7 +410,7 @@ static int adv7393_probe(struct i2c_client *client, v4l_info(client, "chip found @ 0x%x (%s)\n", client->addr << 1, client->adapter->name); - state = kzalloc(sizeof(struct adv7393_state), GFP_KERNEL); + state = devm_kzalloc(&client->dev, sizeof(*state), GFP_KERNEL); if (state == NULL) return -ENOMEM; @@ -444,16 +444,13 @@ static int adv7393_probe(struct i2c_client *client, int err = state->hdl.error; v4l2_ctrl_handler_free(&state->hdl); - kfree(state); return err; } v4l2_ctrl_handler_setup(&state->hdl); err = adv7393_initialize(&state->sd); - if (err) { + if (err) v4l2_ctrl_handler_free(&state->hdl); - kfree(state); - } return err; } @@ -464,7 +461,6 @@ static int adv7393_remove(struct i2c_client *client) v4l2_device_unregister_subdev(sd); v4l2_ctrl_handler_free(&state->hdl); - kfree(state); return 0; } diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c index 31a63c9324fe..4cdcfc96aa56 100644 --- a/drivers/media/i2c/adv7604.c +++ b/drivers/media/i2c/adv7604.c @@ -1968,7 +1968,7 @@ static int adv7604_probe(struct i2c_client *client, v4l_dbg(1, debug, client, "detecting adv7604 client on address 0x%x\n", client->addr << 1); - state = kzalloc(sizeof(struct adv7604_state), GFP_KERNEL); + state = devm_kzalloc(&client->dev, sizeof(*state), GFP_KERNEL); if (!state) { v4l_err(client, "Could not allocate adv7604_state memory!\n"); return -ENOMEM; @@ -1977,8 +1977,7 @@ static int adv7604_probe(struct i2c_client *client, /* platform data */ if (!pdata) { v4l_err(client, "No platform data!\n"); - err = -ENODEV; - goto err_state; + return -ENODEV; } memcpy(&state->pdata, pdata, sizeof(state->pdata)); @@ -1991,8 +1990,7 @@ static int adv7604_probe(struct i2c_client *client, if (adv_smbus_read_byte_data_check(client, 0xfb, false) != 0x68) { v4l2_info(sd, "not an adv7604 on address 0x%x\n", client->addr << 1); - err = -ENODEV; - goto err_state; + return -ENODEV; } /* control handlers */ @@ -2093,8 +2091,6 @@ err_i2c: adv7604_unregister_clients(state); err_hdl: v4l2_ctrl_handler_free(hdl); -err_state: - kfree(state); return err; } @@ -2111,7 +2107,6 @@ static int adv7604_remove(struct i2c_client *client) media_entity_cleanup(&sd->entity); adv7604_unregister_clients(to_state(sd)); v4l2_ctrl_handler_free(sd->ctrl_handler); - kfree(to_state(sd)); return 0; } diff --git a/drivers/media/i2c/ak881x.c b/drivers/media/i2c/ak881x.c index fd47465e4f6a..b918c3f29cbe 100644 --- a/drivers/media/i2c/ak881x.c +++ b/drivers/media/i2c/ak881x.c @@ -264,7 +264,7 @@ static int ak881x_probe(struct i2c_client *client, return -EIO; } - ak881x = kzalloc(sizeof(struct ak881x), GFP_KERNEL); + ak881x = devm_kzalloc(&client->dev, sizeof(*ak881x), GFP_KERNEL); if (!ak881x) return -ENOMEM; @@ -282,7 +282,6 @@ static int ak881x_probe(struct i2c_client *client, default: dev_err(&client->dev, "No ak881x chip detected, register read %x\n", data); - kfree(ak881x); return -ENODEV; } @@ -331,7 +330,6 @@ static int ak881x_remove(struct i2c_client *client) struct ak881x *ak881x = to_ak881x(client); v4l2_device_unregister_subdev(&ak881x->subdev); - kfree(ak881x); return 0; } diff --git a/drivers/media/i2c/as3645a.c b/drivers/media/i2c/as3645a.c index 58d523f2648f..301084b07887 100644 --- a/drivers/media/i2c/as3645a.c +++ b/drivers/media/i2c/as3645a.c @@ -813,7 +813,7 @@ static int as3645a_probe(struct i2c_client *client, if (client->dev.platform_data == NULL) return -ENODEV; - flash = kzalloc(sizeof(*flash), GFP_KERNEL); + flash = devm_kzalloc(&client->dev, sizeof(*flash), GFP_KERNEL); if (flash == NULL) return -ENOMEM; @@ -838,10 +838,8 @@ static int as3645a_probe(struct i2c_client *client, flash->led_mode = V4L2_FLASH_LED_MODE_NONE; done: - if (ret < 0) { + if (ret < 0) v4l2_ctrl_handler_free(&flash->ctrls); - kfree(flash); - } return ret; } @@ -855,7 +853,6 @@ static int as3645a_remove(struct i2c_client *client) v4l2_ctrl_handler_free(&flash->ctrls); media_entity_cleanup(&flash->subdev.entity); mutex_destroy(&flash->power_lock); - kfree(flash); return 0; } diff --git a/drivers/media/i2c/bt819.c b/drivers/media/i2c/bt819.c index 377bf05b1efd..ee9ed67e7910 100644 --- a/drivers/media/i2c/bt819.c +++ b/drivers/media/i2c/bt819.c @@ -425,7 +425,7 @@ static int bt819_probe(struct i2c_client *client, if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) return -ENODEV; - decoder = kzalloc(sizeof(struct bt819), GFP_KERNEL); + decoder = devm_kzalloc(&client->dev, sizeof(*decoder), GFP_KERNEL); if (decoder == NULL) return -ENOMEM; sd = &decoder->sd; @@ -476,7 +476,6 @@ static int bt819_probe(struct i2c_client *client, int err = decoder->hdl.error; v4l2_ctrl_handler_free(&decoder->hdl); - kfree(decoder); return err; } v4l2_ctrl_handler_setup(&decoder->hdl); @@ -490,7 +489,6 @@ static int bt819_remove(struct i2c_client *client) v4l2_device_unregister_subdev(sd); v4l2_ctrl_handler_free(&decoder->hdl); - kfree(decoder); return 0; } diff --git a/drivers/media/i2c/bt856.c b/drivers/media/i2c/bt856.c index 7e5bd365c239..7e5011163b62 100644 --- a/drivers/media/i2c/bt856.c +++ b/drivers/media/i2c/bt856.c @@ -216,7 +216,7 @@ static int bt856_probe(struct i2c_client *client, v4l_info(client, "chip found @ 0x%x (%s)\n", client->addr << 1, client->adapter->name); - encoder = kzalloc(sizeof(struct bt856), GFP_KERNEL); + encoder = devm_kzalloc(&client->dev, sizeof(*encoder), GFP_KERNEL); if (encoder == NULL) return -ENOMEM; sd = &encoder->sd; @@ -250,7 +250,6 @@ static int bt856_remove(struct i2c_client *client) struct v4l2_subdev *sd = i2c_get_clientdata(client); v4l2_device_unregister_subdev(sd); - kfree(to_bt856(sd)); return 0; } diff --git a/drivers/media/i2c/bt866.c b/drivers/media/i2c/bt866.c index 905320b67a1c..9355b924b471 100644 --- a/drivers/media/i2c/bt866.c +++ b/drivers/media/i2c/bt866.c @@ -207,7 +207,7 @@ static int bt866_probe(struct i2c_client *client, v4l_info(client, "chip found @ 0x%x (%s)\n", client->addr << 1, client->adapter->name); - encoder = kzalloc(sizeof(*encoder), GFP_KERNEL); + encoder = devm_kzalloc(&client->dev, sizeof(*encoder), GFP_KERNEL); if (encoder == NULL) return -ENOMEM; sd = &encoder->sd; @@ -220,7 +220,6 @@ static int bt866_remove(struct i2c_client *client) struct v4l2_subdev *sd = i2c_get_clientdata(client); v4l2_device_unregister_subdev(sd); - kfree(to_bt866(sd)); return 0; } diff --git a/drivers/media/i2c/cs5345.c b/drivers/media/i2c/cs5345.c index 1d2f7c8512b5..841b9c49dcfa 100644 --- a/drivers/media/i2c/cs5345.c +++ b/drivers/media/i2c/cs5345.c @@ -190,7 +190,7 @@ static int cs5345_probe(struct i2c_client *client, v4l_info(client, "chip found @ 0x%x (%s)\n", client->addr << 1, client->adapter->name); - state = kzalloc(sizeof(struct cs5345_state), GFP_KERNEL); + state = devm_kzalloc(&client->dev, sizeof(*state), GFP_KERNEL); if (state == NULL) return -ENOMEM; sd = &state->sd; @@ -206,7 +206,6 @@ static int cs5345_probe(struct i2c_client *client, int err = state->hdl.error; v4l2_ctrl_handler_free(&state->hdl); - kfree(state); return err; } /* set volume/mute */ @@ -227,7 +226,6 @@ static int cs5345_remove(struct i2c_client *client) v4l2_device_unregister_subdev(sd); v4l2_ctrl_handler_free(&state->hdl); - kfree(state); return 0; } diff --git a/drivers/media/i2c/cs53l32a.c b/drivers/media/i2c/cs53l32a.c index b293912206eb..1082fb775ab2 100644 --- a/drivers/media/i2c/cs53l32a.c +++ b/drivers/media/i2c/cs53l32a.c @@ -175,7 +175,7 @@ static int cs53l32a_probe(struct i2c_client *client, v4l_info(client, "chip found @ 0x%x (%s)\n", client->addr << 1, client->adapter->name); - state = kzalloc(sizeof(struct cs53l32a_state), GFP_KERNEL); + state = devm_kzalloc(&client->dev, sizeof(*state), GFP_KERNEL); if (state == NULL) return -ENOMEM; sd = &state->sd; @@ -197,7 +197,6 @@ static int cs53l32a_probe(struct i2c_client *client, int err = state->hdl.error; v4l2_ctrl_handler_free(&state->hdl); - kfree(state); return err; } @@ -228,7 +227,6 @@ static int cs53l32a_remove(struct i2c_client *client) v4l2_device_unregister_subdev(sd); v4l2_ctrl_handler_free(&state->hdl); - kfree(state); return 0; } diff --git a/drivers/media/i2c/cx25840/cx25840-core.c b/drivers/media/i2c/cx25840/cx25840-core.c index 12fb9b2eb887..bdfec4c768fe 100644 --- a/drivers/media/i2c/cx25840/cx25840-core.c +++ b/drivers/media/i2c/cx25840/cx25840-core.c @@ -5190,7 +5190,7 @@ static int cx25840_probe(struct i2c_client *client, return -ENODEV; } - state = kzalloc(sizeof(struct cx25840_state), GFP_KERNEL); + state = devm_kzalloc(&client->dev, sizeof(*state), GFP_KERNEL); if (state == NULL) return -ENOMEM; @@ -5292,7 +5292,6 @@ static int cx25840_probe(struct i2c_client *client, int err = state->hdl.error; v4l2_ctrl_handler_free(&state->hdl); - kfree(state); return err; } if (!is_cx2583x(state)) @@ -5317,7 +5316,6 @@ static int cx25840_remove(struct i2c_client *client) cx25840_ir_remove(sd); v4l2_device_unregister_subdev(sd); v4l2_ctrl_handler_free(&state->hdl); - kfree(state); return 0; } diff --git a/drivers/media/i2c/cx25840/cx25840-ir.c b/drivers/media/i2c/cx25840/cx25840-ir.c index 9ae977b5983a..e6588ee5bdb0 100644 --- a/drivers/media/i2c/cx25840/cx25840-ir.c +++ b/drivers/media/i2c/cx25840/cx25840-ir.c @@ -1230,16 +1230,14 @@ int cx25840_ir_probe(struct v4l2_subdev *sd) if (!(is_cx23885(state) || is_cx23887(state))) return 0; - ir_state = kzalloc(sizeof(struct cx25840_ir_state), GFP_KERNEL); + ir_state = devm_kzalloc(&state->c->dev, sizeof(*ir_state), GFP_KERNEL); if (ir_state == NULL) return -ENOMEM; spin_lock_init(&ir_state->rx_kfifo_lock); if (kfifo_alloc(&ir_state->rx_kfifo, - CX25840_IR_RX_KFIFO_SIZE, GFP_KERNEL)) { - kfree(ir_state); + CX25840_IR_RX_KFIFO_SIZE, GFP_KERNEL)) return -ENOMEM; - } ir_state->c = state->c; state->ir_state = ir_state; @@ -1273,7 +1271,6 @@ int cx25840_ir_remove(struct v4l2_subdev *sd) cx25840_ir_tx_shutdown(sd); kfifo_free(&ir_state->rx_kfifo); - kfree(ir_state); state->ir_state = NULL; return 0; } diff --git a/drivers/media/i2c/ir-kbd-i2c.c b/drivers/media/i2c/ir-kbd-i2c.c index 8e2f79cb045e..82bf5679da30 100644 --- a/drivers/media/i2c/ir-kbd-i2c.c +++ b/drivers/media/i2c/ir-kbd-i2c.c @@ -295,7 +295,7 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id) unsigned short addr = client->addr; int err; - ir = kzalloc(sizeof(struct IR_i2c), GFP_KERNEL); + ir = devm_kzalloc(&client->dev, sizeof(*ir), GFP_KERNEL); if (!ir) return -ENOMEM; @@ -398,10 +398,8 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id) * internally */ rc = rc_allocate_device(); - if (!rc) { - err = -ENOMEM; - goto err_out_free; - } + if (!rc) + return -ENOMEM; } ir->rc = rc; @@ -454,7 +452,6 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id) err_out_free: /* Only frees rc if it were allocated internally */ rc_free_device(rc); - kfree(ir); return err; } @@ -470,7 +467,6 @@ static int ir_remove(struct i2c_client *client) rc_unregister_device(ir->rc); /* free memory */ - kfree(ir); return 0; } diff --git a/drivers/media/i2c/ks0127.c b/drivers/media/i2c/ks0127.c index 04a6efa37cc3..c7227763240e 100644 --- a/drivers/media/i2c/ks0127.c +++ b/drivers/media/i2c/ks0127.c @@ -685,7 +685,7 @@ static int ks0127_probe(struct i2c_client *client, const struct i2c_device_id *i client->addr == (I2C_KS0127_ADDON >> 1) ? "addon" : "on-board", client->addr << 1, client->adapter->name); - ks = kzalloc(sizeof(*ks), GFP_KERNEL); + ks = devm_kzalloc(&client->dev, sizeof(*ks), GFP_KERNEL); if (ks == NULL) return -ENOMEM; sd = &ks->sd; @@ -708,7 +708,6 @@ static int ks0127_remove(struct i2c_client *client) v4l2_device_unregister_subdev(sd); ks0127_write(sd, KS_OFMTA, 0x20); /* tristate */ ks0127_write(sd, KS_CMDA, 0x2c | 0x80); /* power down */ - kfree(to_ks0127(sd)); return 0; } diff --git a/drivers/media/i2c/m52790.c b/drivers/media/i2c/m52790.c index 39f50fd2b8d2..0d153f3b1a5b 100644 --- a/drivers/media/i2c/m52790.c +++ b/drivers/media/i2c/m52790.c @@ -174,7 +174,7 @@ static int m52790_probe(struct i2c_client *client, v4l_info(client, "chip found @ 0x%x (%s)\n", client->addr << 1, client->adapter->name); - state = kzalloc(sizeof(struct m52790_state), GFP_KERNEL); + state = devm_kzalloc(&client->dev, sizeof(*state), GFP_KERNEL); if (state == NULL) return -ENOMEM; @@ -191,7 +191,6 @@ static int m52790_remove(struct i2c_client *client) struct v4l2_subdev *sd = i2c_get_clientdata(client); v4l2_device_unregister_subdev(sd); - kfree(to_state(sd)); return 0; } diff --git a/drivers/media/i2c/m5mols/m5mols_core.c b/drivers/media/i2c/m5mols/m5mols_core.c index f0b870c06376..08ff082242c3 100644 --- a/drivers/media/i2c/m5mols/m5mols_core.c +++ b/drivers/media/i2c/m5mols/m5mols_core.c @@ -950,7 +950,7 @@ static int m5mols_probe(struct i2c_client *client, return -EINVAL; } - info = kzalloc(sizeof(struct m5mols_info), GFP_KERNEL); + info = devm_kzalloc(&client->dev, sizeof(*info), GFP_KERNEL); if (!info) return -ENOMEM; @@ -962,7 +962,7 @@ static int m5mols_probe(struct i2c_client *client, ret = gpio_request_one(pdata->gpio_reset, gpio_flags, "M5MOLS_NRST"); if (ret) { dev_err(&client->dev, "Failed to request gpio: %d\n", ret); - goto out_free; + return ret; } ret = regulator_bulk_get(&client->dev, ARRAY_SIZE(supplies), supplies); @@ -1015,8 +1015,6 @@ out_reg: regulator_bulk_free(ARRAY_SIZE(supplies), supplies); out_gpio: gpio_free(pdata->gpio_reset); -out_free: - kfree(info); return ret; } @@ -1032,7 +1030,7 @@ static int m5mols_remove(struct i2c_client *client) regulator_bulk_free(ARRAY_SIZE(supplies), supplies); gpio_free(info->pdata->gpio_reset); media_entity_cleanup(&sd->entity); - kfree(info); + return 0; } diff --git a/drivers/media/i2c/msp3400-driver.c b/drivers/media/i2c/msp3400-driver.c index 54a9dd394f45..ae92c20790e3 100644 --- a/drivers/media/i2c/msp3400-driver.c +++ b/drivers/media/i2c/msp3400-driver.c @@ -707,7 +707,7 @@ static int msp_probe(struct i2c_client *client, const struct i2c_device_id *id) return -ENODEV; } - state = kzalloc(sizeof(*state), GFP_KERNEL); + state = devm_kzalloc(&client->dev, sizeof(*state), GFP_KERNEL); if (!state) return -ENOMEM; @@ -732,7 +732,6 @@ static int msp_probe(struct i2c_client *client, const struct i2c_device_id *id) if (state->rev1 == -1 || (state->rev1 == 0 && state->rev2 == 0)) { v4l_dbg(1, msp_debug, client, "not an msp3400 (cannot read chip version)\n"); - kfree(state); return -ENODEV; } @@ -827,7 +826,6 @@ static int msp_probe(struct i2c_client *client, const struct i2c_device_id *id) int err = hdl->error; v4l2_ctrl_handler_free(hdl); - kfree(state); return err; } @@ -889,7 +887,6 @@ static int msp_remove(struct i2c_client *client) msp_reset(client); v4l2_ctrl_handler_free(&state->hdl); - kfree(state); return 0; } diff --git a/drivers/media/i2c/mt9m032.c b/drivers/media/i2c/mt9m032.c index 8edb3d8f7b90..cca704e02f79 100644 --- a/drivers/media/i2c/mt9m032.c +++ b/drivers/media/i2c/mt9m032.c @@ -730,7 +730,7 @@ static int mt9m032_probe(struct i2c_client *client, if (!client->dev.platform_data) return -ENODEV; - sensor = kzalloc(sizeof(*sensor), GFP_KERNEL); + sensor = devm_kzalloc(&client->dev, sizeof(*sensor), GFP_KERNEL); if (sensor == NULL) return -ENOMEM; @@ -860,7 +860,6 @@ error_ctrl: v4l2_ctrl_handler_free(&sensor->ctrls); error_sensor: mutex_destroy(&sensor->lock); - kfree(sensor); return ret; } @@ -873,7 +872,6 @@ static int mt9m032_remove(struct i2c_client *client) v4l2_ctrl_handler_free(&sensor->ctrls); media_entity_cleanup(&subdev->entity); mutex_destroy(&sensor->lock); - kfree(sensor); return 0; } diff --git a/drivers/media/i2c/mt9t001.c b/drivers/media/i2c/mt9t001.c index 2e189d8b71bb..796463466ef0 100644 --- a/drivers/media/i2c/mt9t001.c +++ b/drivers/media/i2c/mt9t001.c @@ -740,7 +740,7 @@ static int mt9t001_probe(struct i2c_client *client, if (ret < 0) return ret; - mt9t001 = kzalloc(sizeof(*mt9t001), GFP_KERNEL); + mt9t001 = devm_kzalloc(&client->dev, sizeof(*mt9t001), GFP_KERNEL); if (!mt9t001) return -ENOMEM; @@ -801,7 +801,6 @@ done: if (ret < 0) { v4l2_ctrl_handler_free(&mt9t001->ctrls); media_entity_cleanup(&mt9t001->subdev.entity); - kfree(mt9t001); } return ret; @@ -815,7 +814,6 @@ static int mt9t001_remove(struct i2c_client *client) v4l2_ctrl_handler_free(&mt9t001->ctrls); v4l2_device_unregister_subdev(subdev); media_entity_cleanup(&subdev->entity); - kfree(mt9t001); return 0; } diff --git a/drivers/media/i2c/mt9v011.c b/drivers/media/i2c/mt9v011.c index 3f415fd12de3..c64c9d9e253d 100644 --- a/drivers/media/i2c/mt9v011.c +++ b/drivers/media/i2c/mt9v011.c @@ -526,7 +526,7 @@ static int mt9v011_probe(struct i2c_client *c, I2C_FUNC_SMBUS_READ_BYTE | I2C_FUNC_SMBUS_WRITE_BYTE_DATA)) return -EIO; - core = kzalloc(sizeof(struct mt9v011), GFP_KERNEL); + core = devm_kzalloc(&c->dev, sizeof(struct mt9v011), GFP_KERNEL); if (!core) return -ENOMEM; @@ -539,7 +539,6 @@ static int mt9v011_probe(struct i2c_client *c, (version != MT9V011_REV_B_VERSION)) { v4l2_info(sd, "*** unknown micron chip detected (0x%04x).\n", version); - kfree(core); return -EINVAL; } @@ -562,7 +561,6 @@ static int mt9v011_probe(struct i2c_client *c, v4l2_err(sd, "control initialization error %d\n", ret); v4l2_ctrl_handler_free(&core->ctrls); - kfree(core); return ret; } core->sd.ctrl_handler = &core->ctrls; @@ -598,7 +596,7 @@ static int mt9v011_remove(struct i2c_client *c) v4l2_device_unregister_subdev(sd); v4l2_ctrl_handler_free(&core->ctrls); - kfree(to_mt9v011(sd)); + return 0; } diff --git a/drivers/media/i2c/mt9v032.c b/drivers/media/i2c/mt9v032.c index 24ea6fd3ee81..60c6f6739560 100644 --- a/drivers/media/i2c/mt9v032.c +++ b/drivers/media/i2c/mt9v032.c @@ -744,7 +744,7 @@ static int mt9v032_probe(struct i2c_client *client, return -EIO; } - mt9v032 = kzalloc(sizeof(*mt9v032), GFP_KERNEL); + mt9v032 = devm_kzalloc(&client->dev, sizeof(*mt9v032), GFP_KERNEL); if (!mt9v032) return -ENOMEM; @@ -831,10 +831,8 @@ static int mt9v032_probe(struct i2c_client *client, mt9v032->pad.flags = MEDIA_PAD_FL_SOURCE; ret = media_entity_init(&mt9v032->subdev.entity, 1, &mt9v032->pad, 0); - if (ret < 0) { + if (ret < 0) v4l2_ctrl_handler_free(&mt9v032->ctrls); - kfree(mt9v032); - } return ret; } @@ -847,7 +845,6 @@ static int mt9v032_remove(struct i2c_client *client) v4l2_ctrl_handler_free(&mt9v032->ctrls); v4l2_device_unregister_subdev(subdev); media_entity_cleanup(&subdev->entity); - kfree(mt9v032); return 0; } diff --git a/drivers/media/i2c/noon010pc30.c b/drivers/media/i2c/noon010pc30.c index a115842ab996..d205522e598e 100644 --- a/drivers/media/i2c/noon010pc30.c +++ b/drivers/media/i2c/noon010pc30.c @@ -712,7 +712,7 @@ static int noon010_probe(struct i2c_client *client, return -EIO; } - info = kzalloc(sizeof(*info), GFP_KERNEL); + info = devm_kzalloc(&client->dev, sizeof(*info), GFP_KERNEL); if (!info) return -ENOMEM; @@ -796,7 +796,6 @@ np_gpio_err: np_err: v4l2_ctrl_handler_free(&info->hdl); v4l2_device_unregister_subdev(sd); - kfree(info); return ret; } @@ -817,7 +816,7 @@ static int noon010_remove(struct i2c_client *client) gpio_free(info->gpio_nstby); media_entity_cleanup(&sd->entity); - kfree(info); + return 0; } diff --git a/drivers/media/i2c/ov7640.c b/drivers/media/i2c/ov7640.c index b0cc927e8b19..5e117abaa2eb 100644 --- a/drivers/media/i2c/ov7640.c +++ b/drivers/media/i2c/ov7640.c @@ -59,7 +59,7 @@ static int ov7640_probe(struct i2c_client *client, if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) return -ENODEV; - sd = kzalloc(sizeof(struct v4l2_subdev), GFP_KERNEL); + sd = devm_kzalloc(&client->dev, sizeof(*sd), GFP_KERNEL); if (sd == NULL) return -ENOMEM; v4l2_i2c_subdev_init(sd, client, &ov7640_ops); @@ -71,7 +71,6 @@ static int ov7640_probe(struct i2c_client *client, if (write_regs(client, initial_registers) < 0) { v4l_err(client, "error initializing OV7640\n"); - kfree(sd); return -ENODEV; } @@ -84,7 +83,7 @@ static int ov7640_remove(struct i2c_client *client) struct v4l2_subdev *sd = i2c_get_clientdata(client); v4l2_device_unregister_subdev(sd); - kfree(sd); + return 0; } diff --git a/drivers/media/i2c/ov7670.c b/drivers/media/i2c/ov7670.c index 617ad3fff4aa..d71602f4fb43 100644 --- a/drivers/media/i2c/ov7670.c +++ b/drivers/media/i2c/ov7670.c @@ -1552,7 +1552,7 @@ static int ov7670_probe(struct i2c_client *client, struct ov7670_info *info; int ret; - info = kzalloc(sizeof(struct ov7670_info), GFP_KERNEL); + info = devm_kzalloc(&client->dev, sizeof(*info), GFP_KERNEL); if (info == NULL) return -ENOMEM; sd = &info->sd; @@ -1590,7 +1590,6 @@ static int ov7670_probe(struct i2c_client *client, v4l_dbg(1, debug, client, "chip found @ 0x%x (%s) is not an ov7670 chip.\n", client->addr << 1, client->adapter->name); - kfree(info); return ret; } v4l_info(client, "chip found @ 0x%02x (%s)\n", @@ -1635,7 +1634,6 @@ static int ov7670_probe(struct i2c_client *client, int err = info->hdl.error; v4l2_ctrl_handler_free(&info->hdl); - kfree(info); return err; } /* @@ -1659,7 +1657,6 @@ static int ov7670_remove(struct i2c_client *client) v4l2_device_unregister_subdev(sd); v4l2_ctrl_handler_free(&info->hdl); - kfree(info); return 0; } diff --git a/drivers/media/i2c/saa6588.c b/drivers/media/i2c/saa6588.c index b4e1ccbd87ec..729e78d94222 100644 --- a/drivers/media/i2c/saa6588.c +++ b/drivers/media/i2c/saa6588.c @@ -478,17 +478,15 @@ static int saa6588_probe(struct i2c_client *client, v4l_info(client, "saa6588 found @ 0x%x (%s)\n", client->addr << 1, client->adapter->name); - s = kzalloc(sizeof(*s), GFP_KERNEL); + s = devm_kzalloc(&client->dev, sizeof(*s), GFP_KERNEL); if (s == NULL) return -ENOMEM; s->buf_size = bufblocks * 3; - s->buffer = kmalloc(s->buf_size, GFP_KERNEL); - if (s->buffer == NULL) { - kfree(s); + s->buffer = devm_kzalloc(&client->dev, s->buf_size, GFP_KERNEL); + if (s->buffer == NULL) return -ENOMEM; - } sd = &s->sd; v4l2_i2c_subdev_init(sd, client, &saa6588_ops); spin_lock_init(&s->lock); @@ -516,8 +514,6 @@ static int saa6588_remove(struct i2c_client *client) cancel_delayed_work_sync(&s->work); - kfree(s->buffer); - kfree(s); return 0; } diff --git a/drivers/media/i2c/saa7110.c b/drivers/media/i2c/saa7110.c index 51cd4c8f0520..e4026aa93f42 100644 --- a/drivers/media/i2c/saa7110.c +++ b/drivers/media/i2c/saa7110.c @@ -406,7 +406,7 @@ static int saa7110_probe(struct i2c_client *client, v4l_info(client, "chip found @ 0x%x (%s)\n", client->addr << 1, client->adapter->name); - decoder = kzalloc(sizeof(struct saa7110), GFP_KERNEL); + decoder = devm_kzalloc(&client->dev, sizeof(*decoder), GFP_KERNEL); if (!decoder) return -ENOMEM; sd = &decoder->sd; @@ -428,7 +428,6 @@ static int saa7110_probe(struct i2c_client *client, int err = decoder->hdl.error; v4l2_ctrl_handler_free(&decoder->hdl); - kfree(decoder); return err; } v4l2_ctrl_handler_setup(&decoder->hdl); @@ -469,7 +468,6 @@ static int saa7110_remove(struct i2c_client *client) v4l2_device_unregister_subdev(sd); v4l2_ctrl_handler_free(&decoder->hdl); - kfree(decoder); return 0; } diff --git a/drivers/media/i2c/saa7115.c b/drivers/media/i2c/saa7115.c index 52c717d977c9..eecb92df5d96 100644 --- a/drivers/media/i2c/saa7115.c +++ b/drivers/media/i2c/saa7115.c @@ -1614,7 +1614,7 @@ static int saa711x_probe(struct i2c_client *client, v4l_info(client, "saa711%c found (%s) @ 0x%x (%s)\n", chip_id, name, client->addr << 1, client->adapter->name); - state = kzalloc(sizeof(struct saa711x_state), GFP_KERNEL); + state = devm_kzalloc(&client->dev, sizeof(*state), GFP_KERNEL); if (state == NULL) return -ENOMEM; sd = &state->sd; @@ -1640,7 +1640,6 @@ static int saa711x_probe(struct i2c_client *client, int err = hdl->error; v4l2_ctrl_handler_free(hdl); - kfree(state); return err; } v4l2_ctrl_auto_cluster(2, &state->agc, 0, true); @@ -1712,7 +1711,6 @@ static int saa711x_remove(struct i2c_client *client) v4l2_device_unregister_subdev(sd); v4l2_ctrl_handler_free(sd->ctrl_handler); - kfree(to_state(sd)); return 0; } diff --git a/drivers/media/i2c/saa7127.c b/drivers/media/i2c/saa7127.c index 8a47ac10927f..9882c83c1c93 100644 --- a/drivers/media/i2c/saa7127.c +++ b/drivers/media/i2c/saa7127.c @@ -752,7 +752,7 @@ static int saa7127_probe(struct i2c_client *client, v4l_dbg(1, debug, client, "detecting saa7127 client on address 0x%x\n", client->addr << 1); - state = kzalloc(sizeof(struct saa7127_state), GFP_KERNEL); + state = devm_kzalloc(&client->dev, sizeof(*state), GFP_KERNEL); if (state == NULL) return -ENOMEM; @@ -767,7 +767,6 @@ static int saa7127_probe(struct i2c_client *client, if ((saa7127_read(sd, 0) & 0xe4) != 0 || (saa7127_read(sd, 0x29) & 0x3f) != 0x1d) { v4l2_dbg(1, debug, sd, "saa7127 not found\n"); - kfree(state); return -ENODEV; } @@ -823,7 +822,6 @@ static int saa7127_remove(struct i2c_client *client) v4l2_device_unregister_subdev(sd); /* Turn off TV output */ saa7127_set_video_enable(sd, 0); - kfree(to_state(sd)); return 0; } diff --git a/drivers/media/i2c/saa717x.c b/drivers/media/i2c/saa717x.c index cf3a0aa7e45e..71328109642e 100644 --- a/drivers/media/i2c/saa717x.c +++ b/drivers/media/i2c/saa717x.c @@ -1262,7 +1262,7 @@ static int saa717x_probe(struct i2c_client *client, if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) return -EIO; - decoder = kzalloc(sizeof(struct saa717x_state), GFP_KERNEL); + decoder = devm_kzalloc(&client->dev, sizeof(*decoder), GFP_KERNEL); if (decoder == NULL) return -ENOMEM; @@ -1276,7 +1276,6 @@ static int saa717x_probe(struct i2c_client *client, id = saa717x_read(sd, 0x5a0); if (id != 0xc2 && id != 0x32 && id != 0xf2 && id != 0x6c) { v4l2_dbg(1, debug, sd, "saa717x not found (id=%02x)\n", id); - kfree(decoder); return -ENODEV; } if (id == 0xc2) @@ -1316,7 +1315,6 @@ static int saa717x_probe(struct i2c_client *client, int err = hdl->error; v4l2_ctrl_handler_free(hdl); - kfree(decoder); return err; } @@ -1353,7 +1351,6 @@ static int saa717x_remove(struct i2c_client *client) v4l2_device_unregister_subdev(sd); v4l2_ctrl_handler_free(sd->ctrl_handler); - kfree(to_state(sd)); return 0; } diff --git a/drivers/media/i2c/saa7185.c b/drivers/media/i2c/saa7185.c index 2c6b65c76e2b..e95a0edc7f3e 100644 --- a/drivers/media/i2c/saa7185.c +++ b/drivers/media/i2c/saa7185.c @@ -326,7 +326,7 @@ static int saa7185_probe(struct i2c_client *client, v4l_info(client, "chip found @ 0x%x (%s)\n", client->addr << 1, client->adapter->name); - encoder = kzalloc(sizeof(struct saa7185), GFP_KERNEL); + encoder = devm_kzalloc(&client->dev, sizeof(*encoder), GFP_KERNEL); if (encoder == NULL) return -ENOMEM; encoder->norm = V4L2_STD_NTSC; @@ -352,7 +352,6 @@ static int saa7185_remove(struct i2c_client *client) v4l2_device_unregister_subdev(sd); /* SW: output off is active */ saa7185_write(sd, 0x61, (encoder->reg[0x61]) | 0x40); - kfree(encoder); return 0; } diff --git a/drivers/media/i2c/saa7191.c b/drivers/media/i2c/saa7191.c index d7d1670e0ca3..84f7899a4044 100644 --- a/drivers/media/i2c/saa7191.c +++ b/drivers/media/i2c/saa7191.c @@ -605,7 +605,7 @@ static int saa7191_probe(struct i2c_client *client, v4l_info(client, "chip found @ 0x%x (%s)\n", client->addr << 1, client->adapter->name); - decoder = kzalloc(sizeof(*decoder), GFP_KERNEL); + decoder = devm_kzalloc(&client->dev, sizeof(*decoder), GFP_KERNEL); if (!decoder) return -ENOMEM; @@ -615,7 +615,6 @@ static int saa7191_probe(struct i2c_client *client, err = saa7191_write_block(sd, sizeof(initseq), initseq); if (err) { printk(KERN_ERR "SAA7191 initialization failed\n"); - kfree(decoder); return err; } @@ -636,7 +635,6 @@ static int saa7191_remove(struct i2c_client *client) struct v4l2_subdev *sd = i2c_get_clientdata(client); v4l2_device_unregister_subdev(sd); - kfree(to_saa7191(sd)); return 0; } diff --git a/drivers/media/i2c/sony-btf-mpx.c b/drivers/media/i2c/sony-btf-mpx.c index 38cbea98764c..efa306165618 100644 --- a/drivers/media/i2c/sony-btf-mpx.c +++ b/drivers/media/i2c/sony-btf-mpx.c @@ -355,7 +355,7 @@ static int sony_btf_mpx_probe(struct i2c_client *client, v4l_info(client, "chip found @ 0x%x (%s)\n", client->addr << 1, client->adapter->name); - t = kzalloc(sizeof(struct sony_btf_mpx), GFP_KERNEL); + t = devm_kzalloc(&client->dev, sizeof(*t), GFP_KERNEL); if (t == NULL) return -ENOMEM; @@ -374,7 +374,6 @@ static int sony_btf_mpx_remove(struct i2c_client *client) struct v4l2_subdev *sd = i2c_get_clientdata(client); v4l2_device_unregister_subdev(sd); - kfree(to_state(sd)); return 0; } diff --git a/drivers/media/i2c/sr030pc30.c b/drivers/media/i2c/sr030pc30.c index e9d95bda2ab1..4c5a9ee60c3e 100644 --- a/drivers/media/i2c/sr030pc30.c +++ b/drivers/media/i2c/sr030pc30.c @@ -820,7 +820,7 @@ static int sr030pc30_probe(struct i2c_client *client, if (ret) return ret; - info = kzalloc(sizeof(*info), GFP_KERNEL); + info = devm_kzalloc(&client->dev, sizeof(*info), GFP_KERNEL); if (!info) return -ENOMEM; @@ -841,10 +841,8 @@ static int sr030pc30_probe(struct i2c_client *client, static int sr030pc30_remove(struct i2c_client *client) { struct v4l2_subdev *sd = i2c_get_clientdata(client); - struct sr030pc30_info *info = to_sr030pc30(sd); v4l2_device_unregister_subdev(sd); - kfree(info); return 0; } diff --git a/drivers/media/i2c/tda7432.c b/drivers/media/i2c/tda7432.c index 28b5121881f5..72af644fa051 100644 --- a/drivers/media/i2c/tda7432.c +++ b/drivers/media/i2c/tda7432.c @@ -359,7 +359,7 @@ static int tda7432_probe(struct i2c_client *client, v4l_info(client, "chip found @ 0x%02x (%s)\n", client->addr << 1, client->adapter->name); - t = kzalloc(sizeof(*t), GFP_KERNEL); + t = devm_kzalloc(&client->dev, sizeof(*t), GFP_KERNEL); if (!t) return -ENOMEM; sd = &t->sd; @@ -380,7 +380,6 @@ static int tda7432_probe(struct i2c_client *client, int err = t->hdl.error; v4l2_ctrl_handler_free(&t->hdl); - kfree(t); return err; } v4l2_ctrl_cluster(2, &t->bass); @@ -406,7 +405,6 @@ static int tda7432_remove(struct i2c_client *client) tda7432_set(sd); v4l2_device_unregister_subdev(sd); v4l2_ctrl_handler_free(&t->hdl); - kfree(t); return 0; } diff --git a/drivers/media/i2c/tda9840.c b/drivers/media/i2c/tda9840.c index 01441e35d88b..3f1266246ca3 100644 --- a/drivers/media/i2c/tda9840.c +++ b/drivers/media/i2c/tda9840.c @@ -184,7 +184,7 @@ static int tda9840_probe(struct i2c_client *client, v4l_info(client, "chip found @ 0x%x (%s)\n", client->addr << 1, client->adapter->name); - sd = kzalloc(sizeof(struct v4l2_subdev), GFP_KERNEL); + sd = devm_kzalloc(&client->dev, sizeof(*sd), GFP_KERNEL); if (sd == NULL) return -ENOMEM; v4l2_i2c_subdev_init(sd, client, &tda9840_ops); @@ -201,7 +201,6 @@ static int tda9840_remove(struct i2c_client *client) struct v4l2_subdev *sd = i2c_get_clientdata(client); v4l2_device_unregister_subdev(sd); - kfree(sd); return 0; } diff --git a/drivers/media/i2c/tea6415c.c b/drivers/media/i2c/tea6415c.c index 3d5b06a5c308..52ebc384e453 100644 --- a/drivers/media/i2c/tea6415c.c +++ b/drivers/media/i2c/tea6415c.c @@ -152,7 +152,7 @@ static int tea6415c_probe(struct i2c_client *client, v4l_info(client, "chip found @ 0x%x (%s)\n", client->addr << 1, client->adapter->name); - sd = kzalloc(sizeof(struct v4l2_subdev), GFP_KERNEL); + sd = devm_kzalloc(&client->dev, sizeof(*sd), GFP_KERNEL); if (sd == NULL) return -ENOMEM; v4l2_i2c_subdev_init(sd, client, &tea6415c_ops); @@ -164,7 +164,6 @@ static int tea6415c_remove(struct i2c_client *client) struct v4l2_subdev *sd = i2c_get_clientdata(client); v4l2_device_unregister_subdev(sd); - kfree(sd); return 0; } diff --git a/drivers/media/i2c/tea6420.c b/drivers/media/i2c/tea6420.c index 38757217a074..1f869742e3fe 100644 --- a/drivers/media/i2c/tea6420.c +++ b/drivers/media/i2c/tea6420.c @@ -125,7 +125,7 @@ static int tea6420_probe(struct i2c_client *client, v4l_info(client, "chip found @ 0x%x (%s)\n", client->addr << 1, client->adapter->name); - sd = kzalloc(sizeof(struct v4l2_subdev), GFP_KERNEL); + sd = devm_kzalloc(&client->dev, sizeof(*sd), GFP_KERNEL); if (sd == NULL) return -ENOMEM; v4l2_i2c_subdev_init(sd, client, &tea6420_ops); @@ -146,7 +146,6 @@ static int tea6420_remove(struct i2c_client *client) struct v4l2_subdev *sd = i2c_get_clientdata(client); v4l2_device_unregister_subdev(sd); - kfree(sd); return 0; } diff --git a/drivers/media/i2c/tlv320aic23b.c b/drivers/media/i2c/tlv320aic23b.c index 809a75a558ee..ef87f7b09ea2 100644 --- a/drivers/media/i2c/tlv320aic23b.c +++ b/drivers/media/i2c/tlv320aic23b.c @@ -162,7 +162,7 @@ static int tlv320aic23b_probe(struct i2c_client *client, v4l_info(client, "chip found @ 0x%x (%s)\n", client->addr << 1, client->adapter->name); - state = kzalloc(sizeof(struct tlv320aic23b_state), GFP_KERNEL); + state = devm_kzalloc(&client->dev, sizeof(*state), GFP_KERNEL); if (state == NULL) return -ENOMEM; sd = &state->sd; @@ -191,7 +191,6 @@ static int tlv320aic23b_probe(struct i2c_client *client, int err = state->hdl.error; v4l2_ctrl_handler_free(&state->hdl); - kfree(state); return err; } v4l2_ctrl_handler_setup(&state->hdl); @@ -205,7 +204,6 @@ static int tlv320aic23b_remove(struct i2c_client *client) v4l2_device_unregister_subdev(sd); v4l2_ctrl_handler_free(&state->hdl); - kfree(state); return 0; } diff --git a/drivers/media/i2c/tvaudio.c b/drivers/media/i2c/tvaudio.c index b72a59d3216a..fc69e9c27343 100644 --- a/drivers/media/i2c/tvaudio.c +++ b/drivers/media/i2c/tvaudio.c @@ -1910,7 +1910,7 @@ static int tvaudio_probe(struct i2c_client *client, const struct i2c_device_id * printk("\n"); } - chip = kzalloc(sizeof(*chip), GFP_KERNEL); + chip = devm_kzalloc(&client->dev, sizeof(*chip), GFP_KERNEL); if (!chip) return -ENOMEM; sd = &chip->sd; @@ -1930,7 +1930,6 @@ static int tvaudio_probe(struct i2c_client *client, const struct i2c_device_id * } if (desc->name == NULL) { v4l2_dbg(1, debug, sd, "no matching chip description found\n"); - kfree(chip); return -EIO; } v4l2_info(sd, "%s found @ 0x%x (%s)\n", desc->name, client->addr<<1, client->adapter->name); @@ -2001,7 +2000,6 @@ static int tvaudio_probe(struct i2c_client *client, const struct i2c_device_id * int err = chip->hdl.error; v4l2_ctrl_handler_free(&chip->hdl); - kfree(chip); return err; } /* set controls to the default values */ @@ -2043,7 +2041,6 @@ static int tvaudio_remove(struct i2c_client *client) v4l2_device_unregister_subdev(sd); v4l2_ctrl_handler_free(&chip->hdl); - kfree(chip); return 0; } diff --git a/drivers/media/i2c/tvp5150.c b/drivers/media/i2c/tvp5150.c index 485159a3c0b7..de9db3bf1ebd 100644 --- a/drivers/media/i2c/tvp5150.c +++ b/drivers/media/i2c/tvp5150.c @@ -1152,10 +1152,9 @@ static int tvp5150_probe(struct i2c_client *c, I2C_FUNC_SMBUS_READ_BYTE | I2C_FUNC_SMBUS_WRITE_BYTE_DATA)) return -EIO; - core = kzalloc(sizeof(struct tvp5150), GFP_KERNEL); - if (!core) { + core = devm_kzalloc(&c->dev, sizeof(*core), GFP_KERNEL); + if (!core) return -ENOMEM; - } sd = &core->sd; v4l2_i2c_subdev_init(sd, c, &tvp5150_ops); @@ -1166,7 +1165,7 @@ static int tvp5150_probe(struct i2c_client *c, for (i = 0; i < 4; i++) { res = tvp5150_read(sd, TVP5150_MSB_DEV_ID + i); if (res < 0) - goto free_core; + return res; tvp5150_id[i] = res; } @@ -1209,7 +1208,7 @@ static int tvp5150_probe(struct i2c_client *c, if (core->hdl.error) { res = core->hdl.error; v4l2_ctrl_handler_free(&core->hdl); - goto free_core; + return res; } v4l2_ctrl_handler_setup(&core->hdl); @@ -1225,10 +1224,6 @@ static int tvp5150_probe(struct i2c_client *c, if (debug > 1) tvp5150_log_status(sd); return 0; - -free_core: - kfree(core); - return res; } static int tvp5150_remove(struct i2c_client *c) @@ -1242,7 +1237,6 @@ static int tvp5150_remove(struct i2c_client *c) v4l2_device_unregister_subdev(sd); v4l2_ctrl_handler_free(&decoder->hdl); - kfree(to_tvp5150(sd)); return 0; } diff --git a/drivers/media/i2c/tw2804.c b/drivers/media/i2c/tw2804.c index c5dc2c3bf2d7..41a5c9b31006 100644 --- a/drivers/media/i2c/tw2804.c +++ b/drivers/media/i2c/tw2804.c @@ -368,8 +368,7 @@ static int tw2804_probe(struct i2c_client *client, if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) return -ENODEV; - state = kzalloc(sizeof(struct tw2804), GFP_KERNEL); - + state = devm_kzalloc(&client->dev, sizeof(*state), GFP_KERNEL); if (state == NULL) return -ENOMEM; sd = &state->sd; @@ -410,7 +409,6 @@ static int tw2804_probe(struct i2c_client *client, err = state->hdl.error; if (err) { v4l2_ctrl_handler_free(&state->hdl); - kfree(state); return err; } @@ -427,7 +425,6 @@ static int tw2804_remove(struct i2c_client *client) v4l2_device_unregister_subdev(sd); v4l2_ctrl_handler_free(&state->hdl); - kfree(state); return 0; } diff --git a/drivers/media/i2c/tw9903.c b/drivers/media/i2c/tw9903.c index 87880b19d8c3..285b759a5f7f 100644 --- a/drivers/media/i2c/tw9903.c +++ b/drivers/media/i2c/tw9903.c @@ -215,7 +215,7 @@ static int tw9903_probe(struct i2c_client *client, v4l_info(client, "chip found @ 0x%02x (%s)\n", client->addr << 1, client->adapter->name); - dec = kzalloc(sizeof(struct tw9903), GFP_KERNEL); + dec = devm_kzalloc(&client->dev, sizeof(*dec), GFP_KERNEL); if (dec == NULL) return -ENOMEM; sd = &dec->sd; @@ -233,7 +233,6 @@ static int tw9903_probe(struct i2c_client *client, int err = hdl->error; v4l2_ctrl_handler_free(hdl); - kfree(dec); return err; } @@ -242,7 +241,6 @@ static int tw9903_probe(struct i2c_client *client, if (write_regs(sd, initial_registers) < 0) { v4l2_err(client, "error initializing TW9903\n"); - kfree(dec); return -EINVAL; } @@ -255,7 +253,6 @@ static int tw9903_remove(struct i2c_client *client) v4l2_device_unregister_subdev(sd); v4l2_ctrl_handler_free(&to_state(sd)->hdl); - kfree(to_state(sd)); return 0; } diff --git a/drivers/media/i2c/tw9906.c b/drivers/media/i2c/tw9906.c index accd79e5a7fd..f6bef25bd9ce 100644 --- a/drivers/media/i2c/tw9906.c +++ b/drivers/media/i2c/tw9906.c @@ -183,7 +183,7 @@ static int tw9906_probe(struct i2c_client *client, v4l_info(client, "chip found @ 0x%02x (%s)\n", client->addr << 1, client->adapter->name); - dec = kzalloc(sizeof(struct tw9906), GFP_KERNEL); + dec = devm_kzalloc(&client->dev, sizeof(*dec), GFP_KERNEL); if (dec == NULL) return -ENOMEM; sd = &dec->sd; @@ -201,7 +201,6 @@ static int tw9906_probe(struct i2c_client *client, int err = hdl->error; v4l2_ctrl_handler_free(hdl); - kfree(dec); return err; } @@ -210,7 +209,6 @@ static int tw9906_probe(struct i2c_client *client, if (write_regs(sd, initial_registers) < 0) { v4l2_err(client, "error initializing TW9906\n"); - kfree(dec); return -EINVAL; } @@ -223,7 +221,6 @@ static int tw9906_remove(struct i2c_client *client) v4l2_device_unregister_subdev(sd); v4l2_ctrl_handler_free(&to_state(sd)->hdl); - kfree(to_state(sd)); return 0; } diff --git a/drivers/media/i2c/uda1342.c b/drivers/media/i2c/uda1342.c index 3af408556d27..081786d176d0 100644 --- a/drivers/media/i2c/uda1342.c +++ b/drivers/media/i2c/uda1342.c @@ -69,7 +69,7 @@ static int uda1342_probe(struct i2c_client *client, dev_dbg(&client->dev, "initializing UDA1342 at address %d on %s\n", client->addr, adapter->name); - sd = kzalloc(sizeof(struct v4l2_subdev), GFP_KERNEL); + sd = devm_kzalloc(&client->dev, sizeof(*sd), GFP_KERNEL); if (sd == NULL) return -ENOMEM; @@ -89,7 +89,6 @@ static int uda1342_remove(struct i2c_client *client) struct v4l2_subdev *sd = i2c_get_clientdata(client); v4l2_device_unregister_subdev(sd); - kfree(sd); return 0; } diff --git a/drivers/media/i2c/upd64031a.c b/drivers/media/i2c/upd64031a.c index f0a09214c519..4283fc5f39ef 100644 --- a/drivers/media/i2c/upd64031a.c +++ b/drivers/media/i2c/upd64031a.c @@ -230,7 +230,7 @@ static int upd64031a_probe(struct i2c_client *client, v4l_info(client, "chip found @ 0x%x (%s)\n", client->addr << 1, client->adapter->name); - state = kzalloc(sizeof(struct upd64031a_state), GFP_KERNEL); + state = devm_kzalloc(&client->dev, sizeof(*state), GFP_KERNEL); if (state == NULL) return -ENOMEM; sd = &state->sd; @@ -249,7 +249,6 @@ static int upd64031a_remove(struct i2c_client *client) struct v4l2_subdev *sd = i2c_get_clientdata(client); v4l2_device_unregister_subdev(sd); - kfree(to_state(sd)); return 0; } diff --git a/drivers/media/i2c/upd64083.c b/drivers/media/i2c/upd64083.c index 343e0215f74c..b2ac56ca22e6 100644 --- a/drivers/media/i2c/upd64083.c +++ b/drivers/media/i2c/upd64083.c @@ -202,7 +202,7 @@ static int upd64083_probe(struct i2c_client *client, v4l_info(client, "chip found @ 0x%x (%s)\n", client->addr << 1, client->adapter->name); - state = kzalloc(sizeof(struct upd64083_state), GFP_KERNEL); + state = devm_kzalloc(&client->dev, sizeof(*state), GFP_KERNEL); if (state == NULL) return -ENOMEM; sd = &state->sd; @@ -221,7 +221,6 @@ static int upd64083_remove(struct i2c_client *client) struct v4l2_subdev *sd = i2c_get_clientdata(client); v4l2_device_unregister_subdev(sd); - kfree(to_state(sd)); return 0; } diff --git a/drivers/media/i2c/vp27smpx.c b/drivers/media/i2c/vp27smpx.c index e71f139695af..208a095d7bcc 100644 --- a/drivers/media/i2c/vp27smpx.c +++ b/drivers/media/i2c/vp27smpx.c @@ -169,7 +169,7 @@ static int vp27smpx_probe(struct i2c_client *client, v4l_info(client, "chip found @ 0x%x (%s)\n", client->addr << 1, client->adapter->name); - state = kzalloc(sizeof(struct vp27smpx_state), GFP_KERNEL); + state = devm_kzalloc(&client->dev, sizeof(*state), GFP_KERNEL); if (state == NULL) return -ENOMEM; sd = &state->sd; @@ -186,7 +186,6 @@ static int vp27smpx_remove(struct i2c_client *client) struct v4l2_subdev *sd = i2c_get_clientdata(client); v4l2_device_unregister_subdev(sd); - kfree(to_state(sd)); return 0; } diff --git a/drivers/media/i2c/vpx3220.c b/drivers/media/i2c/vpx3220.c index 2f67b4c5c823..f02e74b9b1ac 100644 --- a/drivers/media/i2c/vpx3220.c +++ b/drivers/media/i2c/vpx3220.c @@ -499,7 +499,7 @@ static int vpx3220_probe(struct i2c_client *client, I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA)) return -ENODEV; - decoder = kzalloc(sizeof(struct vpx3220), GFP_KERNEL); + decoder = devm_kzalloc(&client->dev, sizeof(*decoder), GFP_KERNEL); if (decoder == NULL) return -ENOMEM; sd = &decoder->sd; @@ -521,7 +521,6 @@ static int vpx3220_probe(struct i2c_client *client, int err = decoder->hdl.error; v4l2_ctrl_handler_free(&decoder->hdl); - kfree(decoder); return err; } v4l2_ctrl_handler_setup(&decoder->hdl); @@ -566,7 +565,7 @@ static int vpx3220_remove(struct i2c_client *client) v4l2_device_unregister_subdev(sd); v4l2_ctrl_handler_free(&decoder->hdl); - kfree(decoder); + return 0; } diff --git a/drivers/media/i2c/vs6624.c b/drivers/media/i2c/vs6624.c index 6b8c0b7aa488..94e284908f39 100644 --- a/drivers/media/i2c/vs6624.c +++ b/drivers/media/i2c/vs6624.c @@ -813,11 +813,9 @@ static int vs6624_probe(struct i2c_client *client, /* wait 100ms before any further i2c writes are performed */ mdelay(100); - sensor = kzalloc(sizeof(*sensor), GFP_KERNEL); - if (sensor == NULL) { - gpio_free(*ce); + sensor = devm_kzalloc(&client->dev, sizeof(*sensor), GFP_KERNEL); + if (sensor == NULL) return -ENOMEM; - } sd = &sensor->sd; v4l2_i2c_subdev_init(sd, client, &vs6624_ops); @@ -865,7 +863,6 @@ static int vs6624_probe(struct i2c_client *client, int err = hdl->error; v4l2_ctrl_handler_free(hdl); - kfree(sensor); gpio_free(*ce); return err; } @@ -874,7 +871,6 @@ static int vs6624_probe(struct i2c_client *client, ret = v4l2_ctrl_handler_setup(hdl); if (ret) { v4l2_ctrl_handler_free(hdl); - kfree(sensor); gpio_free(*ce); } return ret; @@ -888,7 +884,6 @@ static int vs6624_remove(struct i2c_client *client) v4l2_device_unregister_subdev(sd); v4l2_ctrl_handler_free(sd->ctrl_handler); gpio_free(sensor->ce_pin); - kfree(sensor); return 0; } diff --git a/drivers/media/i2c/wm8739.c b/drivers/media/i2c/wm8739.c index 3bb99e93febe..ac3faa7bab2d 100644 --- a/drivers/media/i2c/wm8739.c +++ b/drivers/media/i2c/wm8739.c @@ -220,7 +220,7 @@ static int wm8739_probe(struct i2c_client *client, v4l_info(client, "chip found @ 0x%x (%s)\n", client->addr << 1, client->adapter->name); - state = kzalloc(sizeof(struct wm8739_state), GFP_KERNEL); + state = devm_kzalloc(&client->dev, sizeof(*state), GFP_KERNEL); if (state == NULL) return -ENOMEM; sd = &state->sd; @@ -237,7 +237,6 @@ static int wm8739_probe(struct i2c_client *client, int err = state->hdl.error; v4l2_ctrl_handler_free(&state->hdl); - kfree(state); return err; } v4l2_ctrl_cluster(3, &state->volume); @@ -271,7 +270,6 @@ static int wm8739_remove(struct i2c_client *client) v4l2_device_unregister_subdev(sd); v4l2_ctrl_handler_free(&state->hdl); - kfree(to_state(sd)); return 0; } diff --git a/drivers/media/i2c/wm8775.c b/drivers/media/i2c/wm8775.c index 27c27b4ae238..75ded82d513f 100644 --- a/drivers/media/i2c/wm8775.c +++ b/drivers/media/i2c/wm8775.c @@ -241,7 +241,7 @@ static int wm8775_probe(struct i2c_client *client, v4l_info(client, "chip found @ 0x%02x (%s)\n", client->addr << 1, client->adapter->name); - state = kzalloc(sizeof(struct wm8775_state), GFP_KERNEL); + state = devm_kzalloc(&client->dev, sizeof(*state), GFP_KERNEL); if (state == NULL) return -ENOMEM; sd = &state->sd; @@ -261,7 +261,6 @@ static int wm8775_probe(struct i2c_client *client, err = state->hdl.error; if (err) { v4l2_ctrl_handler_free(&state->hdl); - kfree(state); return err; } @@ -319,7 +318,6 @@ static int wm8775_remove(struct i2c_client *client) v4l2_device_unregister_subdev(sd); v4l2_ctrl_handler_free(&state->hdl); - kfree(state); return 0; } From b015ba29ca09b0e3750b4de365d3baf9c5b11450 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Thu, 2 May 2013 08:29:43 -0300 Subject: [PATCH 0007/1048] [media] media: i2c: Convert to devm_gpio_request_one() Using the managed function the gpio_free() calls can be removed from the probe error path and the remove handler. Signed-off-by: Laurent Pinchart Acked-by: Sylwester Nawrocki Signed-off-by: Mauro Carvalho Chehab --- drivers/media/i2c/adv7183.c | 24 ++++++++--------------- drivers/media/i2c/m5mols/m5mols_core.c | 9 +++------ drivers/media/i2c/noon010pc30.c | 27 ++++++++------------------ drivers/media/i2c/smiapp/smiapp-core.c | 18 +++++------------ drivers/media/i2c/vs6624.c | 10 +++------- 5 files changed, 27 insertions(+), 61 deletions(-) diff --git a/drivers/media/i2c/adv7183.c b/drivers/media/i2c/adv7183.c index 56904174abc3..42b2dec4ca3a 100644 --- a/drivers/media/i2c/adv7183.c +++ b/drivers/media/i2c/adv7183.c @@ -580,17 +580,17 @@ static int adv7183_probe(struct i2c_client *client, decoder->reset_pin = pin_array[0]; decoder->oe_pin = pin_array[1]; - if (gpio_request_one(decoder->reset_pin, GPIOF_OUT_INIT_LOW, - "ADV7183 Reset")) { + if (devm_gpio_request_one(&client->dev, decoder->reset_pin, + GPIOF_OUT_INIT_LOW, "ADV7183 Reset")) { v4l_err(client, "failed to request GPIO %d\n", decoder->reset_pin); return -EBUSY; } - if (gpio_request_one(decoder->oe_pin, GPIOF_OUT_INIT_HIGH, - "ADV7183 Output Enable")) { + if (devm_gpio_request_one(&client->dev, decoder->oe_pin, + GPIOF_OUT_INIT_HIGH, + "ADV7183 Output Enable")) { v4l_err(client, "failed to request GPIO %d\n", decoder->oe_pin); - ret = -EBUSY; - goto err_free_reset; + return -EBUSY; } sd = &decoder->sd; @@ -612,7 +612,7 @@ static int adv7183_probe(struct i2c_client *client, ret = hdl->error; v4l2_ctrl_handler_free(hdl); - goto err_free_oe; + return ret; } /* v4l2 doesn't support an autodetect standard, pick PAL as default */ @@ -637,26 +637,18 @@ static int adv7183_probe(struct i2c_client *client, ret = v4l2_ctrl_handler_setup(hdl); if (ret) { v4l2_ctrl_handler_free(hdl); - goto err_free_oe; + return ret; } return 0; -err_free_oe: - gpio_free(decoder->oe_pin); -err_free_reset: - gpio_free(decoder->reset_pin); - return ret; } static int adv7183_remove(struct i2c_client *client) { struct v4l2_subdev *sd = i2c_get_clientdata(client); - struct adv7183 *decoder = to_adv7183(sd); v4l2_device_unregister_subdev(sd); v4l2_ctrl_handler_free(sd->ctrl_handler); - gpio_free(decoder->oe_pin); - gpio_free(decoder->reset_pin); return 0; } diff --git a/drivers/media/i2c/m5mols/m5mols_core.c b/drivers/media/i2c/m5mols/m5mols_core.c index 08ff082242c3..f870d5057e3d 100644 --- a/drivers/media/i2c/m5mols/m5mols_core.c +++ b/drivers/media/i2c/m5mols/m5mols_core.c @@ -959,7 +959,8 @@ static int m5mols_probe(struct i2c_client *client, gpio_flags = pdata->reset_polarity ? GPIOF_OUT_INIT_HIGH : GPIOF_OUT_INIT_LOW; - ret = gpio_request_one(pdata->gpio_reset, gpio_flags, "M5MOLS_NRST"); + ret = devm_gpio_request_one(&client->dev, pdata->gpio_reset, gpio_flags, + "M5MOLS_NRST"); if (ret) { dev_err(&client->dev, "Failed to request gpio: %d\n", ret); return ret; @@ -968,7 +969,7 @@ static int m5mols_probe(struct i2c_client *client, ret = regulator_bulk_get(&client->dev, ARRAY_SIZE(supplies), supplies); if (ret) { dev_err(&client->dev, "Failed to get regulators: %d\n", ret); - goto out_gpio; + return ret; } sd = &info->sd; @@ -1013,22 +1014,18 @@ out_me: media_entity_cleanup(&sd->entity); out_reg: regulator_bulk_free(ARRAY_SIZE(supplies), supplies); -out_gpio: - gpio_free(pdata->gpio_reset); return ret; } static int m5mols_remove(struct i2c_client *client) { struct v4l2_subdev *sd = i2c_get_clientdata(client); - struct m5mols_info *info = to_m5mols(sd); v4l2_device_unregister_subdev(sd); v4l2_ctrl_handler_free(sd->ctrl_handler); free_irq(client->irq, sd); regulator_bulk_free(ARRAY_SIZE(supplies), supplies); - gpio_free(info->pdata->gpio_reset); media_entity_cleanup(&sd->entity); return 0; diff --git a/drivers/media/i2c/noon010pc30.c b/drivers/media/i2c/noon010pc30.c index d205522e598e..6f81b99ddd1c 100644 --- a/drivers/media/i2c/noon010pc30.c +++ b/drivers/media/i2c/noon010pc30.c @@ -746,8 +746,9 @@ static int noon010_probe(struct i2c_client *client, info->curr_win = &noon010_sizes[0]; if (gpio_is_valid(pdata->gpio_nreset)) { - ret = gpio_request_one(pdata->gpio_nreset, GPIOF_OUT_INIT_LOW, - "NOON010PC30 NRST"); + ret = devm_gpio_request_one(&client->dev, pdata->gpio_nreset, + GPIOF_OUT_INIT_LOW, + "NOON010PC30 NRST"); if (ret) { dev_err(&client->dev, "GPIO request error: %d\n", ret); goto np_err; @@ -757,11 +758,12 @@ static int noon010_probe(struct i2c_client *client, } if (gpio_is_valid(pdata->gpio_nstby)) { - ret = gpio_request_one(pdata->gpio_nstby, GPIOF_OUT_INIT_LOW, - "NOON010PC30 NSTBY"); + ret = devm_gpio_request_one(&client->dev, pdata->gpio_nstby, + GPIOF_OUT_INIT_LOW, + "NOON010PC30 NSTBY"); if (ret) { dev_err(&client->dev, "GPIO request error: %d\n", ret); - goto np_gpio_err; + goto np_err; } info->gpio_nstby = pdata->gpio_nstby; gpio_export(info->gpio_nstby, 0); @@ -773,7 +775,7 @@ static int noon010_probe(struct i2c_client *client, ret = regulator_bulk_get(&client->dev, NOON010_NUM_SUPPLIES, info->supply); if (ret) - goto np_reg_err; + goto np_err; info->pad.flags = MEDIA_PAD_FL_SOURCE; sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR; @@ -787,12 +789,6 @@ static int noon010_probe(struct i2c_client *client, np_me_err: regulator_bulk_free(NOON010_NUM_SUPPLIES, info->supply); -np_reg_err: - if (gpio_is_valid(info->gpio_nstby)) - gpio_free(info->gpio_nstby); -np_gpio_err: - if (gpio_is_valid(info->gpio_nreset)) - gpio_free(info->gpio_nreset); np_err: v4l2_ctrl_handler_free(&info->hdl); v4l2_device_unregister_subdev(sd); @@ -808,13 +804,6 @@ static int noon010_remove(struct i2c_client *client) v4l2_ctrl_handler_free(&info->hdl); regulator_bulk_free(NOON010_NUM_SUPPLIES, info->supply); - - if (gpio_is_valid(info->gpio_nreset)) - gpio_free(info->gpio_nreset); - - if (gpio_is_valid(info->gpio_nstby)) - gpio_free(info->gpio_nstby); - media_entity_cleanup(&sd->entity); return 0; diff --git a/drivers/media/i2c/smiapp/smiapp-core.c b/drivers/media/i2c/smiapp/smiapp-core.c index cae4f4683851..c38545419045 100644 --- a/drivers/media/i2c/smiapp/smiapp-core.c +++ b/drivers/media/i2c/smiapp/smiapp-core.c @@ -2383,8 +2383,9 @@ static int smiapp_registered(struct v4l2_subdev *subdev) } if (sensor->platform_data->xshutdown != SMIAPP_NO_XSHUTDOWN) { - if (gpio_request_one(sensor->platform_data->xshutdown, 0, - "SMIA++ xshutdown") != 0) { + if (devm_gpio_request_one(&client->dev, + sensor->platform_data->xshutdown, 0, + "SMIA++ xshutdown") != 0) { dev_err(&client->dev, "unable to acquire reset gpio %d\n", sensor->platform_data->xshutdown); @@ -2393,10 +2394,8 @@ static int smiapp_registered(struct v4l2_subdev *subdev) } rval = smiapp_power_on(sensor); - if (rval) { - rval = -ENODEV; - goto out_smiapp_power_on; - } + if (rval) + return -ENODEV; rval = smiapp_identify_module(subdev); if (rval) { @@ -2656,11 +2655,6 @@ out_ident_release: out_power_off: smiapp_power_off(sensor); - -out_smiapp_power_on: - if (sensor->platform_data->xshutdown != SMIAPP_NO_XSHUTDOWN) - gpio_free(sensor->platform_data->xshutdown); - return rval; } @@ -2858,8 +2852,6 @@ static int smiapp_remove(struct i2c_client *client) v4l2_device_unregister_subdev(&sensor->ssds[i].sd); } smiapp_free_controls(sensor); - if (sensor->platform_data->xshutdown != SMIAPP_NO_XSHUTDOWN) - gpio_free(sensor->platform_data->xshutdown); return 0; } diff --git a/drivers/media/i2c/vs6624.c b/drivers/media/i2c/vs6624.c index 94e284908f39..7b55b3ddd80f 100644 --- a/drivers/media/i2c/vs6624.c +++ b/drivers/media/i2c/vs6624.c @@ -805,7 +805,8 @@ static int vs6624_probe(struct i2c_client *client, if (ce == NULL) return -EINVAL; - ret = gpio_request_one(*ce, GPIOF_OUT_INIT_HIGH, "VS6624 Chip Enable"); + ret = devm_gpio_request_one(&client->dev, *ce, GPIOF_OUT_INIT_HIGH, + "VS6624 Chip Enable"); if (ret) { v4l_err(client, "failed to request GPIO %d\n", *ce); return ret; @@ -863,27 +864,22 @@ static int vs6624_probe(struct i2c_client *client, int err = hdl->error; v4l2_ctrl_handler_free(hdl); - gpio_free(*ce); return err; } /* initialize the hardware to the default control values */ ret = v4l2_ctrl_handler_setup(hdl); - if (ret) { + if (ret) v4l2_ctrl_handler_free(hdl); - gpio_free(*ce); - } return ret; } static int vs6624_remove(struct i2c_client *client) { struct v4l2_subdev *sd = i2c_get_clientdata(client); - struct vs6624 *sensor = to_vs6624(sd); v4l2_device_unregister_subdev(sd); v4l2_ctrl_handler_free(sd->ctrl_handler); - gpio_free(sensor->ce_pin); return 0; } From 07e0e5b287421fcc4f4dbe2c0c8bfbc02e23a51e Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Thu, 2 May 2013 08:29:43 -0300 Subject: [PATCH 0008/1048] [media] media: i2c: Convert to devm_regulator_bulk_get() Using the managed function the regulator_bulk_put() calls can be removed from the probe error path and the remove handler. Signed-off-by: Laurent Pinchart Acked-by: Sylwester Nawrocki Signed-off-by: Mauro Carvalho Chehab --- drivers/media/i2c/m5mols/m5mols_core.c | 8 +++----- drivers/media/i2c/noon010pc30.c | 8 ++------ 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/drivers/media/i2c/m5mols/m5mols_core.c b/drivers/media/i2c/m5mols/m5mols_core.c index f870d5057e3d..11f6f871c372 100644 --- a/drivers/media/i2c/m5mols/m5mols_core.c +++ b/drivers/media/i2c/m5mols/m5mols_core.c @@ -966,7 +966,8 @@ static int m5mols_probe(struct i2c_client *client, return ret; } - ret = regulator_bulk_get(&client->dev, ARRAY_SIZE(supplies), supplies); + ret = devm_regulator_bulk_get(&client->dev, ARRAY_SIZE(supplies), + supplies); if (ret) { dev_err(&client->dev, "Failed to get regulators: %d\n", ret); return ret; @@ -981,7 +982,7 @@ static int m5mols_probe(struct i2c_client *client, info->pad.flags = MEDIA_PAD_FL_SOURCE; ret = media_entity_init(&sd->entity, 1, &info->pad, 0); if (ret < 0) - goto out_reg; + return ret; sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR; init_waitqueue_head(&info->irq_waitq); @@ -1012,8 +1013,6 @@ out_irq: free_irq(client->irq, sd); out_me: media_entity_cleanup(&sd->entity); -out_reg: - regulator_bulk_free(ARRAY_SIZE(supplies), supplies); return ret; } @@ -1025,7 +1024,6 @@ static int m5mols_remove(struct i2c_client *client) v4l2_ctrl_handler_free(sd->ctrl_handler); free_irq(client->irq, sd); - regulator_bulk_free(ARRAY_SIZE(supplies), supplies); media_entity_cleanup(&sd->entity); return 0; diff --git a/drivers/media/i2c/noon010pc30.c b/drivers/media/i2c/noon010pc30.c index 6f81b99ddd1c..2284b02102db 100644 --- a/drivers/media/i2c/noon010pc30.c +++ b/drivers/media/i2c/noon010pc30.c @@ -772,7 +772,7 @@ static int noon010_probe(struct i2c_client *client, for (i = 0; i < NOON010_NUM_SUPPLIES; i++) info->supply[i].supply = noon010_supply_name[i]; - ret = regulator_bulk_get(&client->dev, NOON010_NUM_SUPPLIES, + ret = devm_regulator_bulk_get(&client->dev, NOON010_NUM_SUPPLIES, info->supply); if (ret) goto np_err; @@ -781,14 +781,12 @@ static int noon010_probe(struct i2c_client *client, sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR; ret = media_entity_init(&sd->entity, 1, &info->pad, 0); if (ret < 0) - goto np_me_err; + goto np_err; ret = noon010_detect(client, info); if (!ret) return 0; -np_me_err: - regulator_bulk_free(NOON010_NUM_SUPPLIES, info->supply); np_err: v4l2_ctrl_handler_free(&info->hdl); v4l2_device_unregister_subdev(sd); @@ -802,8 +800,6 @@ static int noon010_remove(struct i2c_client *client) v4l2_device_unregister_subdev(sd); v4l2_ctrl_handler_free(&info->hdl); - - regulator_bulk_free(NOON010_NUM_SUPPLIES, info->supply); media_entity_cleanup(&sd->entity); return 0; From 736db646b676e20542a98a95968ef806b25b794b Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Thu, 2 May 2013 08:29:43 -0300 Subject: [PATCH 0009/1048] [media] m5mols: Convert to devm_request_irq() Using the managed function the free_irq() calls can be removed from the probe error path and the remove handler. Signed-off-by: Laurent Pinchart Acked-by: Sylwester Nawrocki Signed-off-by: Mauro Carvalho Chehab --- drivers/media/i2c/m5mols/m5mols_core.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/drivers/media/i2c/m5mols/m5mols_core.c b/drivers/media/i2c/m5mols/m5mols_core.c index 11f6f871c372..8d870b7b43ff 100644 --- a/drivers/media/i2c/m5mols/m5mols_core.c +++ b/drivers/media/i2c/m5mols/m5mols_core.c @@ -988,11 +988,11 @@ static int m5mols_probe(struct i2c_client *client, init_waitqueue_head(&info->irq_waitq); mutex_init(&info->lock); - ret = request_irq(client->irq, m5mols_irq_handler, - IRQF_TRIGGER_RISING, MODULE_NAME, sd); + ret = devm_request_irq(&client->dev, client->irq, m5mols_irq_handler, + IRQF_TRIGGER_RISING, MODULE_NAME, sd); if (ret) { dev_err(&client->dev, "Interrupt request failed: %d\n", ret); - goto out_me; + goto error; } info->res_type = M5MOLS_RESTYPE_MONITOR; info->ffmt[0] = m5mols_default_ffmt[0]; @@ -1000,7 +1000,7 @@ static int m5mols_probe(struct i2c_client *client, ret = m5mols_sensor_power(info, true); if (ret) - goto out_irq; + goto error; ret = m5mols_fw_start(sd); if (!ret) @@ -1009,9 +1009,7 @@ static int m5mols_probe(struct i2c_client *client, ret = m5mols_sensor_power(info, false); if (!ret) return 0; -out_irq: - free_irq(client->irq, sd); -out_me: +error: media_entity_cleanup(&sd->entity); return ret; } @@ -1022,8 +1020,6 @@ static int m5mols_remove(struct i2c_client *client) v4l2_device_unregister_subdev(sd); v4l2_ctrl_handler_free(sd->ctrl_handler); - free_irq(client->irq, sd); - media_entity_cleanup(&sd->entity); return 0; From 598d8d1e4c0bd21a992c52fe0adc69e0b3117a41 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Thu, 2 May 2013 08:29:43 -0300 Subject: [PATCH 0010/1048] [media] s5c73m3: Convert to devm_gpio_request_one() Use the devm_gpio_request_one() managed function to simplify cleanup code paths. Signed-off-by: Laurent Pinchart Acked-by: Sylwester Nawrocki Signed-off-by: Mauro Carvalho Chehab --- drivers/media/i2c/s5c73m3/s5c73m3-core.c | 79 +++++++++--------------- 1 file changed, 28 insertions(+), 51 deletions(-) diff --git a/drivers/media/i2c/s5c73m3/s5c73m3-core.c b/drivers/media/i2c/s5c73m3/s5c73m3-core.c index cb52438e53ac..d3e867a7a565 100644 --- a/drivers/media/i2c/s5c73m3/s5c73m3-core.c +++ b/drivers/media/i2c/s5c73m3/s5c73m3-core.c @@ -1511,59 +1511,40 @@ static const struct v4l2_subdev_ops oif_subdev_ops = { .video = &s5c73m3_oif_video_ops, }; -static int s5c73m3_configure_gpio(int nr, int val, const char *name) -{ - unsigned long flags = val ? GPIOF_OUT_INIT_HIGH : GPIOF_OUT_INIT_LOW; - int ret; - - if (!gpio_is_valid(nr)) - return 0; - ret = gpio_request_one(nr, flags, name); - if (!ret) - gpio_export(nr, 0); - return ret; -} - -static int s5c73m3_free_gpios(struct s5c73m3 *state) -{ - int i; - - for (i = 0; i < ARRAY_SIZE(state->gpio); i++) { - if (!gpio_is_valid(state->gpio[i].gpio)) - continue; - gpio_free(state->gpio[i].gpio); - state->gpio[i].gpio = -EINVAL; - } - return 0; -} - static int s5c73m3_configure_gpios(struct s5c73m3 *state, const struct s5c73m3_platform_data *pdata) { - const struct s5c73m3_gpio *gpio = &pdata->gpio_stby; + struct device *dev = &state->i2c_client->dev; + const struct s5c73m3_gpio *gpio; + unsigned long flags; int ret; state->gpio[STBY].gpio = -EINVAL; state->gpio[RST].gpio = -EINVAL; - ret = s5c73m3_configure_gpio(gpio->gpio, gpio->level, "S5C73M3_STBY"); - if (ret) { - s5c73m3_free_gpios(state); - return ret; + gpio = &pdata->gpio_stby; + if (gpio_is_valid(gpio->gpio)) { + flags = (gpio->level ? GPIOF_OUT_INIT_HIGH : GPIOF_OUT_INIT_LOW) + | GPIOF_EXPORT; + ret = devm_gpio_request_one(dev, gpio->gpio, flags, + "S5C73M3_STBY"); + if (ret < 0) + return ret; + + state->gpio[STBY] = *gpio; } - state->gpio[STBY] = *gpio; - if (gpio_is_valid(gpio->gpio)) - gpio_set_value(gpio->gpio, 0); gpio = &pdata->gpio_reset; - ret = s5c73m3_configure_gpio(gpio->gpio, gpio->level, "S5C73M3_RST"); - if (ret) { - s5c73m3_free_gpios(state); - return ret; + if (gpio_is_valid(gpio->gpio)) { + flags = (gpio->level ? GPIOF_OUT_INIT_HIGH : GPIOF_OUT_INIT_LOW) + | GPIOF_EXPORT; + ret = devm_gpio_request_one(dev, gpio->gpio, flags, + "S5C73M3_RST"); + if (ret < 0) + return ret; + + state->gpio[RST] = *gpio; } - state->gpio[RST] = *gpio; - if (gpio_is_valid(gpio->gpio)) - gpio_set_value(gpio->gpio, 0); return 0; } @@ -1626,10 +1607,11 @@ static int s5c73m3_probe(struct i2c_client *client, state->mclk_frequency = pdata->mclk_frequency; state->bus_type = pdata->bus_type; + state->i2c_client = client; ret = s5c73m3_configure_gpios(state, pdata); if (ret) - goto out_err1; + goto out_err; for (i = 0; i < S5C73M3_MAX_SUPPLIES; i++) state->supplies[i].supply = s5c73m3_supply_names[i]; @@ -1638,12 +1620,12 @@ static int s5c73m3_probe(struct i2c_client *client, state->supplies); if (ret) { dev_err(dev, "failed to get regulators\n"); - goto out_err2; + goto out_err; } ret = s5c73m3_init_controls(state); if (ret) - goto out_err2; + goto out_err; state->sensor_pix_size[RES_ISP] = &s5c73m3_isp_resolutions[1]; state->sensor_pix_size[RES_JPEG] = &s5c73m3_jpeg_resolutions[1]; @@ -1659,16 +1641,12 @@ static int s5c73m3_probe(struct i2c_client *client, ret = s5c73m3_register_spi_driver(state); if (ret < 0) - goto out_err2; - - state->i2c_client = client; + goto out_err; v4l2_info(sd, "%s: completed succesfully\n", __func__); return 0; -out_err2: - s5c73m3_free_gpios(state); -out_err1: +out_err: media_entity_cleanup(&sd->entity); return ret; } @@ -1688,7 +1666,6 @@ static int s5c73m3_remove(struct i2c_client *client) media_entity_cleanup(&sensor_sd->entity); s5c73m3_unregister_spi_driver(state); - s5c73m3_free_gpios(state); return 0; } From 31857e54fa5a6e39d2d24dc912135bb0d26a6db9 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Thu, 2 May 2013 08:29:43 -0300 Subject: [PATCH 0011/1048] [media] s5k6aa: Convert to devm_gpio_request_one() Use the devm_gpio_request_one() managed function to simplify cleanup code paths. Signed-off-by: Laurent Pinchart Acked-by: Sylwester Nawrocki Signed-off-by: Mauro Carvalho Chehab --- drivers/media/i2c/s5k6aa.c | 73 ++++++++++++++------------------------ 1 file changed, 26 insertions(+), 47 deletions(-) diff --git a/drivers/media/i2c/s5k6aa.c b/drivers/media/i2c/s5k6aa.c index bdf5e3db31d1..789c02a6ca1a 100644 --- a/drivers/media/i2c/s5k6aa.c +++ b/drivers/media/i2c/s5k6aa.c @@ -1491,58 +1491,41 @@ static const struct v4l2_subdev_ops s5k6aa_subdev_ops = { /* * GPIO setup */ -static int s5k6aa_configure_gpio(int nr, int val, const char *name) -{ - unsigned long flags = val ? GPIOF_OUT_INIT_HIGH : GPIOF_OUT_INIT_LOW; - int ret; - - if (!gpio_is_valid(nr)) - return 0; - ret = gpio_request_one(nr, flags, name); - if (!ret) - gpio_export(nr, 0); - return ret; -} - -static void s5k6aa_free_gpios(struct s5k6aa *s5k6aa) -{ - int i; - - for (i = 0; i < ARRAY_SIZE(s5k6aa->gpio); i++) { - if (!gpio_is_valid(s5k6aa->gpio[i].gpio)) - continue; - gpio_free(s5k6aa->gpio[i].gpio); - s5k6aa->gpio[i].gpio = -EINVAL; - } -} static int s5k6aa_configure_gpios(struct s5k6aa *s5k6aa, const struct s5k6aa_platform_data *pdata) { - const struct s5k6aa_gpio *gpio = &pdata->gpio_stby; + struct i2c_client *client = v4l2_get_subdevdata(&s5k6aa->sd); + const struct s5k6aa_gpio *gpio; + unsigned long flags; int ret; s5k6aa->gpio[STBY].gpio = -EINVAL; s5k6aa->gpio[RST].gpio = -EINVAL; - ret = s5k6aa_configure_gpio(gpio->gpio, gpio->level, "S5K6AA_STBY"); - if (ret) { - s5k6aa_free_gpios(s5k6aa); - return ret; + gpio = &pdata->gpio_stby; + if (gpio_is_valid(gpio->gpio)) { + flags = (gpio->level ? GPIOF_OUT_INIT_HIGH : GPIOF_OUT_INIT_LOW) + | GPIOF_EXPORT; + ret = devm_gpio_request_one(&client->dev, gpio->gpio, flags, + "S5K6AA_STBY"); + if (ret < 0) + return ret; + + s5k6aa->gpio[STBY] = *gpio; } - s5k6aa->gpio[STBY] = *gpio; - if (gpio_is_valid(gpio->gpio)) - gpio_set_value(gpio->gpio, 0); gpio = &pdata->gpio_reset; - ret = s5k6aa_configure_gpio(gpio->gpio, gpio->level, "S5K6AA_RST"); - if (ret) { - s5k6aa_free_gpios(s5k6aa); - return ret; + if (gpio_is_valid(gpio->gpio)) { + flags = (gpio->level ? GPIOF_OUT_INIT_HIGH : GPIOF_OUT_INIT_LOW) + | GPIOF_EXPORT; + ret = devm_gpio_request_one(&client->dev, gpio->gpio, flags, + "S5K6AA_RST"); + if (ret < 0) + return ret; + + s5k6aa->gpio[RST] = *gpio; } - s5k6aa->gpio[RST] = *gpio; - if (gpio_is_valid(gpio->gpio)) - gpio_set_value(gpio->gpio, 0); return 0; } @@ -1593,7 +1576,7 @@ static int s5k6aa_probe(struct i2c_client *client, ret = s5k6aa_configure_gpios(s5k6aa, pdata); if (ret) - goto out_err2; + goto out_err; for (i = 0; i < S5K6AA_NUM_SUPPLIES; i++) s5k6aa->supplies[i].supply = s5k6aa_supply_names[i]; @@ -1602,12 +1585,12 @@ static int s5k6aa_probe(struct i2c_client *client, s5k6aa->supplies); if (ret) { dev_err(&client->dev, "Failed to get regulators\n"); - goto out_err3; + goto out_err; } ret = s5k6aa_initialize_ctrls(s5k6aa); if (ret) - goto out_err3; + goto out_err; s5k6aa_presets_data_init(s5k6aa); @@ -1618,9 +1601,7 @@ static int s5k6aa_probe(struct i2c_client *client, return 0; -out_err3: - s5k6aa_free_gpios(s5k6aa); -out_err2: +out_err: media_entity_cleanup(&s5k6aa->sd.entity); return ret; } @@ -1628,12 +1609,10 @@ out_err2: static int s5k6aa_remove(struct i2c_client *client) { struct v4l2_subdev *sd = i2c_get_clientdata(client); - struct s5k6aa *s5k6aa = to_s5k6aa(sd); v4l2_device_unregister_subdev(sd); v4l2_ctrl_handler_free(sd->ctrl_handler); media_entity_cleanup(&sd->entity); - s5k6aa_free_gpios(s5k6aa); return 0; } From 835ab0121adb24ff27729bd3743f1477af00c435 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Fri, 12 Apr 2013 09:30:29 -0300 Subject: [PATCH 0012/1048] [media] bttv: Add Adlink MPG24 entry to the bttv cardlist Add a proper card entry for this device, rather than abusing entries that are not-quite-right. Regards, Hans Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- Documentation/video4linux/CARDLIST.bttv | 1 + drivers/media/pci/bt8xx/bttv-cards.c | 22 +++++++++++++++++----- drivers/media/pci/bt8xx/bttv.h | 1 + 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/Documentation/video4linux/CARDLIST.bttv b/Documentation/video4linux/CARDLIST.bttv index 581f666a76cf..407ab4660dce 100644 --- a/Documentation/video4linux/CARDLIST.bttv +++ b/Documentation/video4linux/CARDLIST.bttv @@ -160,3 +160,4 @@ 159 -> ProVideo PV183 [1830:1540,1831:1540,1832:1540,1833:1540,1834:1540,1835:1540,1836:1540,1837:1540] 160 -> Tongwei Video Technology TD-3116 [f200:3116] 161 -> Aposonic W-DVR [0279:0228] +162 -> Adlink MPG24 diff --git a/drivers/media/pci/bt8xx/bttv-cards.c b/drivers/media/pci/bt8xx/bttv-cards.c index b7dc921e1b91..8d327ff60e37 100644 --- a/drivers/media/pci/bt8xx/bttv-cards.c +++ b/drivers/media/pci/bt8xx/bttv-cards.c @@ -2705,7 +2705,7 @@ struct tvcard bttv_tvcards[] = { .has_radio = 1, .has_remote = 1, }, - [BTTV_BOARD_VD012] = { + [BTTV_BOARD_VD012] = { /* D.Heer@Phytec.de */ .name = "PHYTEC VD-012 (bt878)", .video_inputs = 4, @@ -2718,7 +2718,7 @@ struct tvcard bttv_tvcards[] = { .tuner_type = TUNER_ABSENT, .tuner_addr = ADDR_UNSET, }, - [BTTV_BOARD_VD012_X1] = { + [BTTV_BOARD_VD012_X1] = { /* D.Heer@Phytec.de */ .name = "PHYTEC VD-012-X1 (bt878)", .video_inputs = 4, @@ -2731,7 +2731,7 @@ struct tvcard bttv_tvcards[] = { .tuner_type = TUNER_ABSENT, .tuner_addr = ADDR_UNSET, }, - [BTTV_BOARD_VD012_X2] = { + [BTTV_BOARD_VD012_X2] = { /* D.Heer@Phytec.de */ .name = "PHYTEC VD-012-X2 (bt878)", .video_inputs = 4, @@ -2744,7 +2744,7 @@ struct tvcard bttv_tvcards[] = { .tuner_type = TUNER_ABSENT, .tuner_addr = ADDR_UNSET, }, - [BTTV_BOARD_GEOVISION_GV800S] = { + [BTTV_BOARD_GEOVISION_GV800S] = { /* Bruno Christo * * GeoVision GV-800(S) has 4 Conexant Fusion 878A: @@ -2771,7 +2771,7 @@ struct tvcard bttv_tvcards[] = { .no_tda7432 = 1, .muxsel_hook = gv800s_muxsel, }, - [BTTV_BOARD_GEOVISION_GV800S_SL] = { + [BTTV_BOARD_GEOVISION_GV800S_SL] = { /* Bruno Christo * * GeoVision GV-800(S) has 4 Conexant Fusion 878A: @@ -2808,6 +2808,7 @@ struct tvcard bttv_tvcards[] = { .tuner_type = TUNER_ABSENT, .tuner_addr = ADDR_UNSET, }, + /* ---- card 0xa0---------------------------------- */ [BTTV_BOARD_TVT_TD3116] = { .name = "Tongwei Video Technology TD-3116", .video_inputs = 16, @@ -2825,6 +2826,17 @@ struct tvcard bttv_tvcards[] = { .muxsel = MUXSEL(2, 3, 1, 0), .tuner_type = TUNER_ABSENT, }, + [BTTV_BOARD_ADLINK_MPG24] = { + /* Adlink MPG24 */ + .name = "Adlink MPG24", + .video_inputs = 1, + /* .audio_inputs= 1, */ + .svhs = NO_SVHS, + .muxsel = MUXSEL(2, 2, 2, 2), + .tuner_type = UNSET, + .tuner_addr = ADDR_UNSET, + .pll = PLL_28, + }, }; diff --git a/drivers/media/pci/bt8xx/bttv.h b/drivers/media/pci/bt8xx/bttv.h index 6139ce26dc2c..f01c9d4c7ec1 100644 --- a/drivers/media/pci/bt8xx/bttv.h +++ b/drivers/media/pci/bt8xx/bttv.h @@ -185,6 +185,7 @@ #define BTTV_BOARD_PV183 0x9f #define BTTV_BOARD_TVT_TD3116 0xa0 #define BTTV_BOARD_APOSONIC_WDVR 0xa1 +#define BTTV_BOARD_ADLINK_MPG24 0xa2 /* more card-specific defines */ #define PT2254_L_CHANNEL 0x10 From 968bd2e7ca25d630edc0d8e145ab8225af6d585b Mon Sep 17 00:00:00 2001 From: Scott Jiang Date: Fri, 12 Apr 2013 19:52:57 -0300 Subject: [PATCH 0013/1048] [media] blackfin: add display support in ppi driver Signed-off-by: Scott Jiang Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/blackfin/ppi.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/media/platform/blackfin/ppi.c b/drivers/media/platform/blackfin/ppi.c index 01b5b501347e..15e9c2bac2b1 100644 --- a/drivers/media/platform/blackfin/ppi.c +++ b/drivers/media/platform/blackfin/ppi.c @@ -266,6 +266,18 @@ static int ppi_set_params(struct ppi_if *ppi, struct ppi_params *params) bfin_write32(®->vcnt, params->height); if (params->int_mask) bfin_write32(®->imsk, params->int_mask & 0xFF); + if (ppi->ppi_control & PORT_DIR) { + u32 hsync_width, vsync_width, vsync_period; + + hsync_width = params->hsync + * params->bpp / params->dlen; + vsync_width = params->vsync * samples_per_line; + vsync_period = samples_per_line * params->frame; + bfin_write32(®->fs1_wlhb, hsync_width); + bfin_write32(®->fs1_paspl, samples_per_line); + bfin_write32(®->fs2_wlvb, vsync_width); + bfin_write32(®->fs2_palpf, vsync_period); + } break; } default: From ead156c427295f8dfad7d4f954122501ca32ab65 Mon Sep 17 00:00:00 2001 From: Scott Jiang Date: Fri, 12 Apr 2013 19:52:59 -0300 Subject: [PATCH 0014/1048] [media] bfin_capture: add query_dv_timings/enum_dv_timings support More dv_timings ioctl ops are introduced in video core. Add query_dv_timings/enum_dv_timings accordingly. Signed-off-by: Scott Jiang Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- .../media/platform/blackfin/bfin_capture.c | 28 ++++++++++++++----- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/drivers/media/platform/blackfin/bfin_capture.c b/drivers/media/platform/blackfin/bfin_capture.c index 0e55b087076f..03530bc6bdd1 100644 --- a/drivers/media/platform/blackfin/bfin_capture.c +++ b/drivers/media/platform/blackfin/bfin_capture.c @@ -649,18 +649,30 @@ static int bcap_s_std(struct file *file, void *priv, v4l2_std_id std) return 0; } +static int bcap_enum_dv_timings(struct file *file, void *priv, + struct v4l2_enum_dv_timings *timings) +{ + struct bcap_device *bcap_dev = video_drvdata(file); + + return v4l2_subdev_call(bcap_dev->sd, video, + enum_dv_timings, timings); +} + +static int bcap_query_dv_timings(struct file *file, void *priv, + struct v4l2_dv_timings *timings) +{ + struct bcap_device *bcap_dev = video_drvdata(file); + + return v4l2_subdev_call(bcap_dev->sd, video, + query_dv_timings, timings); +} + static int bcap_g_dv_timings(struct file *file, void *priv, struct v4l2_dv_timings *timings) { struct bcap_device *bcap_dev = video_drvdata(file); - int ret; - ret = v4l2_subdev_call(bcap_dev->sd, video, - g_dv_timings, timings); - if (ret < 0) - return ret; - - bcap_dev->dv_timings = *timings; + *timings = bcap_dev->dv_timings; return 0; } @@ -921,6 +933,8 @@ static const struct v4l2_ioctl_ops bcap_ioctl_ops = { .vidioc_g_std = bcap_g_std, .vidioc_s_dv_timings = bcap_s_dv_timings, .vidioc_g_dv_timings = bcap_g_dv_timings, + .vidioc_query_dv_timings = bcap_query_dv_timings, + .vidioc_enum_dv_timings = bcap_enum_dv_timings, .vidioc_reqbufs = bcap_reqbufs, .vidioc_querybuf = bcap_querybuf, .vidioc_qbuf = bcap_qbuf, From cc1088dc0b92723c5e2e4cb5098dfa84a39afaed Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Sat, 13 Apr 2013 05:25:59 -0300 Subject: [PATCH 0015/1048] [media] media:adv7180: Use dev_pm_ops Use dev_pm_ops instead of the deprecated legacy suspend/resume callbacks. Signed-off-by: Lars-Peter Clausen Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/i2c/adv7180.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/drivers/media/i2c/adv7180.c b/drivers/media/i2c/adv7180.c index 3d1456780318..04ee1d4a4b93 100644 --- a/drivers/media/i2c/adv7180.c +++ b/drivers/media/i2c/adv7180.c @@ -614,9 +614,10 @@ static const struct i2c_device_id adv7180_id[] = { {}, }; -#ifdef CONFIG_PM -static int adv7180_suspend(struct i2c_client *client, pm_message_t state) +#ifdef CONFIG_PM_SLEEP +static int adv7180_suspend(struct device *dev) { + struct i2c_client *client = to_i2c_client(dev); int ret; ret = i2c_smbus_write_byte_data(client, ADV7180_PWR_MAN_REG, @@ -626,8 +627,9 @@ static int adv7180_suspend(struct i2c_client *client, pm_message_t state) return 0; } -static int adv7180_resume(struct i2c_client *client) +static int adv7180_resume(struct device *dev) { + struct i2c_client *client = to_i2c_client(dev); struct v4l2_subdev *sd = i2c_get_clientdata(client); struct adv7180_state *state = to_state(sd); int ret; @@ -641,6 +643,12 @@ static int adv7180_resume(struct i2c_client *client) return ret; return 0; } + +static SIMPLE_DEV_PM_OPS(adv7180_pm_ops, adv7180_suspend, adv7180_resume); +#define ADV7180_PM_OPS (&adv7180_pm_ops) + +#else +#define ADV7180_PM_OPS NULL #endif MODULE_DEVICE_TABLE(i2c, adv7180_id); @@ -649,13 +657,10 @@ static struct i2c_driver adv7180_driver = { .driver = { .owner = THIS_MODULE, .name = KBUILD_MODNAME, + .pm = ADV7180_PM_OPS, }, .probe = adv7180_probe, .remove = adv7180_remove, -#ifdef CONFIG_PM - .suspend = adv7180_suspend, - .resume = adv7180_resume, -#endif .id_table = adv7180_id, }; From ec7c15b58f34015df182e909fbb80674211daf54 Mon Sep 17 00:00:00 2001 From: Ondrej Zary Date: Sun, 14 Apr 2013 12:39:09 -0300 Subject: [PATCH 0016/1048] [media] bttv: Add noname Bt848 capture card with 14MHz xtal Add support for noname Bt848 capture-only card (3x composite, 1x S-VHS) with 14MHz crystal: http://www.rainbow-software.org/images/hardware/bt848_.jpg 14MHz PLL was not supported by bttv driver until now. [mchehab@redhat.com: CodingStyle fixes] Signed-off-by: Ondrej Zary Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/pci/bt8xx/bttv-cards.c | 20 +++++++++++++++++++- drivers/media/pci/bt8xx/bttv.h | 2 ++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/drivers/media/pci/bt8xx/bttv-cards.c b/drivers/media/pci/bt8xx/bttv-cards.c index 8d327ff60e37..2ba62f113522 100644 --- a/drivers/media/pci/bt8xx/bttv-cards.c +++ b/drivers/media/pci/bt8xx/bttv-cards.c @@ -131,7 +131,7 @@ MODULE_PARM_DESC(vsfx,"set VSFX pci config bit " "[yet another chipset flaw workaround]"); MODULE_PARM_DESC(latency,"pci latency timer"); MODULE_PARM_DESC(card,"specify TV/grabber card model, see CARDLIST file for a list"); -MODULE_PARM_DESC(pll,"specify installed crystal (0=none, 28=28 MHz, 35=35 MHz)"); +MODULE_PARM_DESC(pll, "specify installed crystal (0=none, 28=28 MHz, 35=35 MHz, 14=14 MHz)"); MODULE_PARM_DESC(tuner,"specify installed tuner type"); MODULE_PARM_DESC(autoload, "obsolete option, please do not use anymore"); MODULE_PARM_DESC(audiodev, "specify audio device:\n" @@ -2837,6 +2837,14 @@ struct tvcard bttv_tvcards[] = { .tuner_addr = ADDR_UNSET, .pll = PLL_28, }, + [BTTV_BOARD_BT848_CAP_14] = { + .name = "Bt848 Capture 14MHz", + .video_inputs = 4, + .svhs = 2, + .muxsel = MUXSEL(2, 3, 1, 0), + .pll = PLL_14, + .tuner_type = TUNER_ABSENT, + }, }; @@ -3402,6 +3410,10 @@ void bttv_init_card2(struct bttv *btv) btv->pll.pll_ifreq=35468950; btv->pll.pll_crystal=BT848_IFORM_XT1; } + if (PLL_14 == bttv_tvcards[btv->c.type].pll) { + btv->pll.pll_ifreq = 14318181; + btv->pll.pll_crystal = BT848_IFORM_XT0; + } /* insmod options can override */ switch (pll[btv->c.nr]) { case 0: /* none */ @@ -3421,6 +3433,12 @@ void bttv_init_card2(struct bttv *btv) btv->pll.pll_ofreq = 0; btv->pll.pll_crystal = BT848_IFORM_XT1; break; + case 3: /* 14 MHz */ + case 14: + btv->pll.pll_ifreq = 14318181; + btv->pll.pll_ofreq = 0; + btv->pll.pll_crystal = BT848_IFORM_XT0; + break; } } btv->pll.pll_current = -1; diff --git a/drivers/media/pci/bt8xx/bttv.h b/drivers/media/pci/bt8xx/bttv.h index f01c9d4c7ec1..9d09e303f1dd 100644 --- a/drivers/media/pci/bt8xx/bttv.h +++ b/drivers/media/pci/bt8xx/bttv.h @@ -186,6 +186,7 @@ #define BTTV_BOARD_TVT_TD3116 0xa0 #define BTTV_BOARD_APOSONIC_WDVR 0xa1 #define BTTV_BOARD_ADLINK_MPG24 0xa2 +#define BTTV_BOARD_BT848_CAP_14 0xa3 /* more card-specific defines */ #define PT2254_L_CHANNEL 0x10 @@ -233,6 +234,7 @@ struct tvcard { #define PLL_NONE 0 #define PLL_28 1 #define PLL_35 2 +#define PLL_14 3 /* i2c audio flags */ unsigned int no_msp34xx:1; From ba9948fb9c3bd220b4766f19aff82c2776a7eb4c Mon Sep 17 00:00:00 2001 From: Ondrej Zary Date: Sun, 14 Apr 2013 17:26:21 -0300 Subject: [PATCH 0017/1048] [media] bttv: Add CyberVision CV06 Add CyberVision CV06 4-camera card (from CyberVision SV card kit): http://www.cybervision.com.tw/products-swcard_kits-sv.html There are some interesting things on the card but they're not supported: 4 LEDs, a connector with 4 IN and 4 OUT pins, RESET IN and RESET OUT connectors, a relay and CyberVision CV8088-SV16 chip Signed-off-by: Ondrej Zary Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/pci/bt8xx/bttv-cards.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/media/pci/bt8xx/bttv-cards.c b/drivers/media/pci/bt8xx/bttv-cards.c index 2ba62f113522..e564aac0aa30 100644 --- a/drivers/media/pci/bt8xx/bttv-cards.c +++ b/drivers/media/pci/bt8xx/bttv-cards.c @@ -2845,6 +2845,16 @@ struct tvcard bttv_tvcards[] = { .pll = PLL_14, .tuner_type = TUNER_ABSENT, }, + [BTTV_BOARD_CYBERVISION_CV06] = { + .name = "CyberVision CV06 (SV)", + .video_inputs = 4, + /* .audio_inputs= 0, */ + .svhs = NO_SVHS, + .muxsel = MUXSEL(2, 3, 1, 0), + .pll = PLL_28, + .tuner_type = TUNER_ABSENT, + .tuner_addr = ADDR_UNSET, + }, }; From adf6271281a811dbcf2cb090b2a99a8520f7852b Mon Sep 17 00:00:00 2001 From: Ismael Luceno Date: Thu, 18 Apr 2013 08:16:08 -0300 Subject: [PATCH 0018/1048] [media] videodev2.h: Make V4L2_PIX_FMT_MPEG4 comment more specific about its usage Signed-off-by: Ismael Luceno Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- include/uapi/linux/videodev2.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h index f40b41c7e108..16c3cf71eb94 100644 --- a/include/uapi/linux/videodev2.h +++ b/include/uapi/linux/videodev2.h @@ -395,7 +395,7 @@ struct v4l2_pix_format { #define V4L2_PIX_FMT_H263 v4l2_fourcc('H', '2', '6', '3') /* H263 */ #define V4L2_PIX_FMT_MPEG1 v4l2_fourcc('M', 'P', 'G', '1') /* MPEG-1 ES */ #define V4L2_PIX_FMT_MPEG2 v4l2_fourcc('M', 'P', 'G', '2') /* MPEG-2 ES */ -#define V4L2_PIX_FMT_MPEG4 v4l2_fourcc('M', 'P', 'G', '4') /* MPEG-4 ES */ +#define V4L2_PIX_FMT_MPEG4 v4l2_fourcc('M', 'P', 'G', '4') /* MPEG-4 part 2 ES */ #define V4L2_PIX_FMT_XVID v4l2_fourcc('X', 'V', 'I', 'D') /* Xvid */ #define V4L2_PIX_FMT_VC1_ANNEX_G v4l2_fourcc('V', 'C', '1', 'G') /* SMPTE 421M Annex G compliant stream */ #define V4L2_PIX_FMT_VC1_ANNEX_L v4l2_fourcc('V', 'C', '1', 'L') /* SMPTE 421M Annex L compliant stream */ From 012eef7001d4e0bede7122f34a4a6cc13a83c28e Mon Sep 17 00:00:00 2001 From: "Lad, Prabhakar" Date: Fri, 19 Apr 2013 05:53:29 -0300 Subject: [PATCH 0019/1048] [media] media: davinci: vpif: remove unwanted header file inclusion this patch removes unwanted header file inclusion and sorts header alphabetically. Signed-off-by: Lad, Prabhakar Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/davinci/vpif_capture.c | 29 ++++++------------- drivers/media/platform/davinci/vpif_capture.h | 5 +--- drivers/media/platform/davinci/vpif_display.c | 23 ++------------- drivers/media/platform/davinci/vpif_display.h | 5 +--- 4 files changed, 14 insertions(+), 48 deletions(-) diff --git a/drivers/media/platform/davinci/vpif_capture.c b/drivers/media/platform/davinci/vpif_capture.c index 5f98df1fc8a0..a1b42b037678 100644 --- a/drivers/media/platform/davinci/vpif_capture.c +++ b/drivers/media/platform/davinci/vpif_capture.c @@ -18,28 +18,17 @@ * TODO : add support for VBI & HBI data service * add static buffer allocation */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "vpif_capture.h" +#include +#include +#include +#include + +#include +#include + #include "vpif.h" +#include "vpif_capture.h" MODULE_DESCRIPTION("TI DaVinci VPIF Capture driver"); MODULE_LICENSE("GPL"); diff --git a/drivers/media/platform/davinci/vpif_capture.h b/drivers/media/platform/davinci/vpif_capture.h index 3d3c1e5cd5d4..0ebb31260369 100644 --- a/drivers/media/platform/davinci/vpif_capture.h +++ b/drivers/media/platform/davinci/vpif_capture.h @@ -22,11 +22,8 @@ #ifdef __KERNEL__ /* Header files */ -#include -#include -#include #include -#include +#include #include "vpif.h" diff --git a/drivers/media/platform/davinci/vpif_display.c b/drivers/media/platform/davinci/vpif_display.c index 1b3fb5ca2ad4..d8330567dd57 100644 --- a/drivers/media/platform/davinci/vpif_display.c +++ b/drivers/media/platform/davinci/vpif_display.c @@ -14,33 +14,16 @@ * GNU General Public License for more details. */ -#include -#include -#include -#include -#include -#include #include -#include -#include -#include -#include -#include -#include +#include #include -#include #include -#include -#include - -#include -#include -#include #include +#include -#include "vpif_display.h" #include "vpif.h" +#include "vpif_display.h" MODULE_DESCRIPTION("TI DaVinci VPIF Display driver"); MODULE_LICENSE("GPL"); diff --git a/drivers/media/platform/davinci/vpif_display.h b/drivers/media/platform/davinci/vpif_display.h index a5a18f74395c..5d87fc86e580 100644 --- a/drivers/media/platform/davinci/vpif_display.h +++ b/drivers/media/platform/davinci/vpif_display.h @@ -17,11 +17,8 @@ #define DAVINCIHD_DISPLAY_H /* Header files */ -#include -#include -#include #include -#include +#include #include "vpif.h" From c8f089c9203e0061ecd27030518e7d06fea0edd8 Mon Sep 17 00:00:00 2001 From: "Lad, Prabhakar" Date: Fri, 19 Apr 2013 05:53:30 -0300 Subject: [PATCH 0020/1048] [media] media: davinci: vpif_display: move displaying of error to approppraite place this patch moves the displaying out error case "VPIF IRQ request failed\n" when there is actual request_irq() fail. Signed-off-by: Lad, Prabhakar Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/davinci/vpif_display.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/platform/davinci/vpif_display.c b/drivers/media/platform/davinci/vpif_display.c index d8330567dd57..7b1736842690 100644 --- a/drivers/media/platform/davinci/vpif_display.c +++ b/drivers/media/platform/davinci/vpif_display.c @@ -1725,6 +1725,7 @@ static __init int vpif_probe(struct platform_device *pdev) for (j = 0; j < i; j++) free_irq(j, (void *) (&vpif_obj.dev[res_idx]->channel_id)); + vpif_err("VPIF IRQ request failed\n"); goto vpif_int_err; } } @@ -1878,7 +1879,6 @@ vpif_sd_error: } vpif_int_err: v4l2_device_unregister(&vpif_obj.v4l2_dev); - vpif_err("VPIF IRQ request failed\n"); for (i = 0; i < res_idx; i++) { res = platform_get_resource(pdev, IORESOURCE_IRQ, i); for (j = res->start; j <= res->end; j++) From 05ff7240b0aa1794cebd8b0ecb846ed629fb5da3 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Sat, 20 Apr 2013 08:57:41 -0300 Subject: [PATCH 0021/1048] [media] CARDLIST.bttv: add new cards Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- Documentation/video4linux/CARDLIST.bttv | 2 ++ drivers/media/pci/bt8xx/bttv.h | 1 + 2 files changed, 3 insertions(+) diff --git a/Documentation/video4linux/CARDLIST.bttv b/Documentation/video4linux/CARDLIST.bttv index 407ab4660dce..f14475011fea 100644 --- a/Documentation/video4linux/CARDLIST.bttv +++ b/Documentation/video4linux/CARDLIST.bttv @@ -161,3 +161,5 @@ 160 -> Tongwei Video Technology TD-3116 [f200:3116] 161 -> Aposonic W-DVR [0279:0228] 162 -> Adlink MPG24 +163 -> Bt848 Capture 14MHz +164 -> CyberVision CV06 (SV) diff --git a/drivers/media/pci/bt8xx/bttv.h b/drivers/media/pci/bt8xx/bttv.h index 9d09e303f1dd..df578efe03c9 100644 --- a/drivers/media/pci/bt8xx/bttv.h +++ b/drivers/media/pci/bt8xx/bttv.h @@ -187,6 +187,7 @@ #define BTTV_BOARD_APOSONIC_WDVR 0xa1 #define BTTV_BOARD_ADLINK_MPG24 0xa2 #define BTTV_BOARD_BT848_CAP_14 0xa3 +#define BTTV_BOARD_CYBERVISION_CV06 0xa4 /* more card-specific defines */ #define PT2254_L_CHANNEL 0x10 From 60bc53d5f7a2b5117fe665c6db1f03ec389f4ae6 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Tue, 21 May 2013 08:16:19 -0300 Subject: [PATCH 0022/1048] [media] update saa7134 and tuner cardlists Those are automatically updated using the cardlist script. Signed-off-by: Mauro Carvalho Chehab --- Documentation/video4linux/CARDLIST.saa7134 | 1 + Documentation/video4linux/CARDLIST.tuner | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Documentation/video4linux/CARDLIST.saa7134 b/Documentation/video4linux/CARDLIST.saa7134 index b3ad68309109..8df17d063499 100644 --- a/Documentation/video4linux/CARDLIST.saa7134 +++ b/Documentation/video4linux/CARDLIST.saa7134 @@ -190,3 +190,4 @@ 189 -> Kworld PC150-U [17de:a134] 190 -> Asus My Cinema PS3-100 [1043:48cd] 191 -> Hawell HW-9004V1 +192 -> AverMedia AverTV Satellite Hybrid+FM A706 [1461:2055] diff --git a/Documentation/video4linux/CARDLIST.tuner b/Documentation/video4linux/CARDLIST.tuner index 5b83a3ff15c2..ac8862184962 100644 --- a/Documentation/video4linux/CARDLIST.tuner +++ b/Documentation/video4linux/CARDLIST.tuner @@ -86,6 +86,6 @@ tuner=85 - Philips FQ1236 MK5 tuner=86 - Tena TNF5337 MFD tuner=87 - Xceive 4000 tuner tuner=88 - Xceive 5000C tuner -tuner=89 - Sony PAL+SECAM (BTF-PG472Z) -tuner=90 - Sony NTSC-M-JP (BTF-PK467Z) -tuner=91 - Sony NTSC-M (BTF-PB463Z) +tuner=89 - Sony BTF-PG472Z PAL/SECAM +tuner=90 - Sony BTF-PK467Z NTSC-M-JP +tuner=91 - Sony BTF-PB463Z NTSC-M From 3020bea57fdb950bc6121a51d1e8e7b0a82c2827 Mon Sep 17 00:00:00 2001 From: Jakob Haufe Date: Sat, 13 Apr 2013 11:03:36 -0300 Subject: [PATCH 0023/1048] [media] rc: Add rc-delock-61959 This adds the keytable for the remote that comes with the Delock 61959. NEC protocol with address 0x866b. Signed-off-by: Jakob Haufe Reviewed-by: Antti Palosaari Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/rc/keymaps/Makefile | 1 + drivers/media/rc/keymaps/rc-delock-61959.c | 83 ++++++++++++++++++++++ include/media/rc-map.h | 1 + 3 files changed, 85 insertions(+) create mode 100644 drivers/media/rc/keymaps/rc-delock-61959.c diff --git a/drivers/media/rc/keymaps/Makefile b/drivers/media/rc/keymaps/Makefile index 5ab94ea4bc28..b1cde8c0422b 100644 --- a/drivers/media/rc/keymaps/Makefile +++ b/drivers/media/rc/keymaps/Makefile @@ -20,6 +20,7 @@ obj-$(CONFIG_RC_MAP) += rc-adstech-dvb-t-pci.o \ rc-budget-ci-old.o \ rc-cinergy-1400.o \ rc-cinergy.o \ + rc-delock-61959.o \ rc-dib0700-nec.o \ rc-dib0700-rc5.o \ rc-digitalnow-tinytwin.o \ diff --git a/drivers/media/rc/keymaps/rc-delock-61959.c b/drivers/media/rc/keymaps/rc-delock-61959.c new file mode 100644 index 000000000000..01bed864f09d --- /dev/null +++ b/drivers/media/rc/keymaps/rc-delock-61959.c @@ -0,0 +1,83 @@ +/* rc-delock-61959.c - Keytable for Delock + * + * Copyright (c) 2013 by Jakob Haufe + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + */ + +#include +#include + +/* + * Keytable for remote provided with Delock 61959 + */ +static struct rc_map_table delock_61959[] = { + { 0x866b16, KEY_POWER2 }, /* Power */ + { 0x866b0c, KEY_POWER }, /* Shut Down */ + + { 0x866b00, KEY_1}, + { 0x866b01, KEY_2}, + { 0x866b02, KEY_3}, + { 0x866b03, KEY_4}, + { 0x866b04, KEY_5}, + { 0x866b05, KEY_6}, + { 0x866b06, KEY_7}, + { 0x866b07, KEY_8}, + { 0x866b08, KEY_9}, + { 0x866b14, KEY_0}, + + { 0x866b0a, KEY_ZOOM}, /* Full Screen */ + { 0x866b10, KEY_CAMERA}, /* Photo */ + { 0x866b0e, KEY_CHANNEL}, /* circular arrow / Recall */ + { 0x866b13, KEY_ESC}, /* Back */ + + { 0x866b20, KEY_UP}, + { 0x866b21, KEY_DOWN}, + { 0x866b42, KEY_LEFT}, + { 0x866b43, KEY_RIGHT}, + { 0x866b0b, KEY_OK}, + + { 0x866b11, KEY_CHANNELUP}, + { 0x866b1b, KEY_CHANNELDOWN}, + + { 0x866b12, KEY_VOLUMEUP}, + { 0x866b48, KEY_VOLUMEDOWN}, + { 0x866b44, KEY_MUTE}, + + { 0x866b1a, KEY_RECORD}, + { 0x866b41, KEY_PLAY}, + { 0x866b40, KEY_STOP}, + { 0x866b19, KEY_PAUSE}, + { 0x866b1c, KEY_FASTFORWARD}, /* >> / FWD */ + { 0x866b1e, KEY_REWIND}, /* << / REW */ + +}; + +static struct rc_map_list delock_61959_map = { + .map = { + .scan = delock_61959, + .size = ARRAY_SIZE(delock_61959), + .rc_type = RC_TYPE_NEC, + .name = RC_MAP_DELOCK_61959, + } +}; + +static int __init init_rc_map_delock_61959(void) +{ + return rc_map_register(&delock_61959_map); +} + +static void __exit exit_rc_map_delock_61959(void) +{ + rc_map_unregister(&delock_61959_map); +} + +module_init(init_rc_map_delock_61959) +module_exit(exit_rc_map_delock_61959) + +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("Jakob Haufe "); +MODULE_DESCRIPTION("Delock 61959 remote keytable"); diff --git a/include/media/rc-map.h b/include/media/rc-map.h index 5d5d3a30f04a..6628f5d01f52 100644 --- a/include/media/rc-map.h +++ b/include/media/rc-map.h @@ -111,6 +111,7 @@ void rc_map_init(void); #define RC_MAP_BUDGET_CI_OLD "rc-budget-ci-old" #define RC_MAP_CINERGY_1400 "rc-cinergy-1400" #define RC_MAP_CINERGY "rc-cinergy" +#define RC_MAP_DELOCK_61959 "rc-delock-61959" #define RC_MAP_DIB0700_NEC_TABLE "rc-dib0700-nec" #define RC_MAP_DIB0700_RC5_TABLE "rc-dib0700-rc5" #define RC_MAP_DIGITALNOW_TINYTWIN "rc-digitalnow-tinytwin" From 7c1dfdb059505fee12eaf089070145febd9e5ecf Mon Sep 17 00:00:00 2001 From: Jakob Haufe Date: Sat, 13 Apr 2013 11:03:37 -0300 Subject: [PATCH 0024/1048] [media] em28xx: Add support for 1b80:e1cc Delock 61959 Hardware is the same as MaxMedia UB425-TC but ships with a different remote. Signed-off-by: Jakob Haufe Reviewed-by: Antti Palosaari Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/usb/em28xx/em28xx-cards.c | 16 ++++++++++++++++ drivers/media/usb/em28xx/em28xx-dvb.c | 5 +++-- drivers/media/usb/em28xx/em28xx.h | 1 + 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/drivers/media/usb/em28xx/em28xx-cards.c b/drivers/media/usb/em28xx/em28xx-cards.c index 83bfbe4c980f..927956b4dca7 100644 --- a/drivers/media/usb/em28xx/em28xx-cards.c +++ b/drivers/media/usb/em28xx/em28xx-cards.c @@ -374,6 +374,7 @@ static struct em28xx_reg_seq hauppauge_930c_digital[] = { #endif /* 1b80:e425 MaxMedia UB425-TC + * 1b80:e1cc Delock 61959 * GPIO_6 - demod reset, 0=active * GPIO_7 - LED, 0=active */ @@ -2017,6 +2018,19 @@ struct em28xx_board em28xx_boards[] = { .i2c_speed = EM28XX_I2C_CLK_WAIT_ENABLE | EM28XX_I2C_FREQ_400_KHZ, }, + /* 1b80:e1cc Delock 61959 + * Empia EM2874B + Micronas DRX 3913KA2 + NXP TDA18271HDC2 + * mostly the same as MaxMedia UB-425-TC but different remote */ + [EM2874_BOARD_DELOCK_61959] = { + .name = "Delock 61959", + .tuner_type = TUNER_ABSENT, + .tuner_gpio = maxmedia_ub425_tc, + .has_dvb = 1, + .ir_codes = RC_MAP_DELOCK_61959, + .def_i2c_bus = 1, + .i2c_speed = EM28XX_I2C_CLK_WAIT_ENABLE | + EM28XX_I2C_FREQ_400_KHZ, + }, }; const unsigned int em28xx_bcount = ARRAY_SIZE(em28xx_boards); @@ -2178,6 +2192,8 @@ struct usb_device_id em28xx_id_table[] = { .driver_info = EM2884_BOARD_PCTV_510E }, { USB_DEVICE(0x2013, 0x0251), .driver_info = EM2884_BOARD_PCTV_520E }, + { USB_DEVICE(0x1b80, 0xe1cc), + .driver_info = EM2874_BOARD_DELOCK_61959 }, { }, }; MODULE_DEVICE_TABLE(usb, em28xx_id_table); diff --git a/drivers/media/usb/em28xx/em28xx-dvb.c b/drivers/media/usb/em28xx/em28xx-dvb.c index b22f8fed8127..42ede686ab69 100644 --- a/drivers/media/usb/em28xx/em28xx-dvb.c +++ b/drivers/media/usb/em28xx/em28xx-dvb.c @@ -1216,6 +1216,7 @@ static int em28xx_dvb_init(struct em28xx *dev) dvb_attach(a8293_attach, dvb->fe[0], &dev->i2c_adap[dev->def_i2c_bus], &em28xx_a8293_config); break; + case EM2874_BOARD_DELOCK_61959: case EM2874_BOARD_MAXMEDIA_UB425_TC: /* attach demodulator */ dvb->fe[0] = dvb_attach(drxk_attach, &maxmedia_ub425_tc_drxk, @@ -1235,8 +1236,8 @@ static int em28xx_dvb_init(struct em28xx *dev) } /* TODO: we need drx-3913k firmware in order to support DVB-T */ - em28xx_info("MaxMedia UB425-TC: only DVB-C supported by that " \ - "driver version\n"); + em28xx_info("MaxMedia UB425-TC/Delock 61959: only DVB-C " \ + "supported by that driver version\n"); break; case EM2884_BOARD_PCTV_510E: diff --git a/drivers/media/usb/em28xx/em28xx.h b/drivers/media/usb/em28xx/em28xx.h index a9323b63d8e5..59a95802aa68 100644 --- a/drivers/media/usb/em28xx/em28xx.h +++ b/drivers/media/usb/em28xx/em28xx.h @@ -130,6 +130,7 @@ #define EM2884_BOARD_PCTV_520E 86 #define EM2884_BOARD_TERRATEC_HTC_USB_XS 87 #define EM2884_BOARD_C3TECH_DIGITAL_DUO 88 +#define EM2874_BOARD_DELOCK_61959 89 /* Limits minimum and default number of buffers */ #define EM28XX_MIN_BUF 4 From 849325e331cd196914d1e1a9e19edeaa42e75037 Mon Sep 17 00:00:00 2001 From: "Lad, Prabhakar" Date: Fri, 3 May 2013 08:39:25 -0300 Subject: [PATCH 0025/1048] [media] media: davinci: vpbe: fix checkpatch warning for CamelCase This patch fixes checkpatch warning to avoid CamelCase. Signed-off-by: Lad, Prabhakar Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/davinci/vpbe_display.c | 2 +- drivers/media/platform/davinci/vpbe_osd.c | 24 +++++++++---------- include/media/davinci/vpbe_osd.h | 4 ++-- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/drivers/media/platform/davinci/vpbe_display.c b/drivers/media/platform/davinci/vpbe_display.c index 1802f11e939f..1c4ba8965797 100644 --- a/drivers/media/platform/davinci/vpbe_display.c +++ b/drivers/media/platform/davinci/vpbe_display.c @@ -929,7 +929,7 @@ static int vpbe_display_s_fmt(struct file *file, void *priv, cfg->interlaced = vpbe_dev->current_timings.interlaced; if (V4L2_PIX_FMT_UYVY == pixfmt->pixelformat) - cfg->pixfmt = PIXFMT_YCbCrI; + cfg->pixfmt = PIXFMT_YCBCRI; /* Change of the default pixel format for both video windows */ if (V4L2_PIX_FMT_NV12 == pixfmt->pixelformat) { diff --git a/drivers/media/platform/davinci/vpbe_osd.c b/drivers/media/platform/davinci/vpbe_osd.c index 396a51cbede7..6ed82e8b297b 100644 --- a/drivers/media/platform/davinci/vpbe_osd.c +++ b/drivers/media/platform/davinci/vpbe_osd.c @@ -119,7 +119,7 @@ static inline u32 osd_modify(struct osd_state *sd, u32 mask, u32 val, #define is_rgb_pixfmt(pixfmt) \ (((pixfmt) == PIXFMT_RGB565) || ((pixfmt) == PIXFMT_RGB888)) #define is_yc_pixfmt(pixfmt) \ - (((pixfmt) == PIXFMT_YCbCrI) || ((pixfmt) == PIXFMT_YCrCbI) || \ + (((pixfmt) == PIXFMT_YCBCRI) || ((pixfmt) == PIXFMT_YCRCBI) || \ ((pixfmt) == PIXFMT_NV12)) #define MAX_WIN_SIZE OSD_VIDWIN0XP_V0X #define MAX_LINE_LENGTH (OSD_VIDWIN0OFST_V0LO << 5) @@ -360,8 +360,8 @@ static void _osd_enable_color_key(struct osd_state *sd, osd_write(sd, colorkey & OSD_TRANSPVALL_RGBL, OSD_TRANSPVALL); break; - case PIXFMT_YCbCrI: - case PIXFMT_YCrCbI: + case PIXFMT_YCBCRI: + case PIXFMT_YCRCBI: if (sd->vpbe_type == VPBE_VERSION_3) osd_modify(sd, OSD_TRANSPVALU_Y, colorkey, OSD_TRANSPVALU); @@ -813,8 +813,8 @@ static int try_layer_config(struct osd_state *sd, enum osd_layer layer, if (osd->vpbe_type == VPBE_VERSION_1) bad_config = !is_vid_win(layer); break; - case PIXFMT_YCbCrI: - case PIXFMT_YCrCbI: + case PIXFMT_YCBCRI: + case PIXFMT_YCRCBI: bad_config = !is_vid_win(layer); break; case PIXFMT_RGB888: @@ -950,9 +950,9 @@ static void _osd_set_cbcr_order(struct osd_state *sd, * The caller must ensure that all windows using YC pixfmt use the same * Cb/Cr order. */ - if (pixfmt == PIXFMT_YCbCrI) + if (pixfmt == PIXFMT_YCBCRI) osd_clear(sd, OSD_MODE_CS, OSD_MODE); - else if (pixfmt == PIXFMT_YCrCbI) + else if (pixfmt == PIXFMT_YCRCBI) osd_set(sd, OSD_MODE_CS, OSD_MODE); } @@ -981,8 +981,8 @@ static void _osd_set_layer_config(struct osd_state *sd, enum osd_layer layer, winmd |= (2 << OSD_OSDWIN0MD_BMP0MD_SHIFT); _osd_enable_rgb888_pixblend(sd, OSDWIN_OSD0); break; - case PIXFMT_YCbCrI: - case PIXFMT_YCrCbI: + case PIXFMT_YCBCRI: + case PIXFMT_YCRCBI: winmd |= (3 << OSD_OSDWIN0MD_BMP0MD_SHIFT); break; default: @@ -1128,8 +1128,8 @@ static void _osd_set_layer_config(struct osd_state *sd, enum osd_layer layer, _osd_enable_rgb888_pixblend(sd, OSDWIN_OSD1); break; - case PIXFMT_YCbCrI: - case PIXFMT_YCrCbI: + case PIXFMT_YCBCRI: + case PIXFMT_YCRCBI: winmd |= (3 << OSD_OSDWIN1MD_BMP1MD_SHIFT); break; @@ -1508,7 +1508,7 @@ static int osd_initialize(struct osd_state *osd) _osd_init(osd); /* set default Cb/Cr order */ - osd->yc_pixfmt = PIXFMT_YCbCrI; + osd->yc_pixfmt = PIXFMT_YCBCRI; if (osd->vpbe_type == VPBE_VERSION_3) { /* diff --git a/include/media/davinci/vpbe_osd.h b/include/media/davinci/vpbe_osd.h index 42628fcfe1bd..de59364d7ed2 100644 --- a/include/media/davinci/vpbe_osd.h +++ b/include/media/davinci/vpbe_osd.h @@ -82,9 +82,9 @@ enum osd_pix_format { PIXFMT_4BPP, PIXFMT_8BPP, PIXFMT_RGB565, - PIXFMT_YCbCrI, + PIXFMT_YCBCRI, PIXFMT_RGB888, - PIXFMT_YCrCbI, + PIXFMT_YCRCBI, PIXFMT_NV12, PIXFMT_OSD_ATTR, }; From ccc40ed7555d053f60328e9742e559fb75e85002 Mon Sep 17 00:00:00 2001 From: Leonid Kegulskiy Date: Thu, 25 Apr 2013 05:59:54 -0300 Subject: [PATCH 0026/1048] [media] hdpvr: Removed unnecessary get_video_info() call from hdpvr_device_init() Signed-off-by: Leonid Kegulskiy Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/usb/hdpvr/hdpvr-core.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/drivers/media/usb/hdpvr/hdpvr-core.c b/drivers/media/usb/hdpvr/hdpvr-core.c index 8247c19d6260..cb694055ba7d 100644 --- a/drivers/media/usb/hdpvr/hdpvr-core.c +++ b/drivers/media/usb/hdpvr/hdpvr-core.c @@ -220,7 +220,6 @@ static int hdpvr_device_init(struct hdpvr_device *dev) { int ret; u8 *buf; - struct hdpvr_video_info *vidinf; if (device_authorization(dev)) return -EACCES; @@ -242,13 +241,6 @@ static int hdpvr_device_init(struct hdpvr_device *dev) "control request returned %d\n", ret); mutex_unlock(&dev->usbc_mutex); - vidinf = get_video_info(dev); - if (!vidinf) - v4l2_dbg(MSG_INFO, hdpvr_debug, &dev->v4l2_dev, - "no valid video signal or device init failed\n"); - else - kfree(vidinf); - /* enable fan and bling leds */ mutex_lock(&dev->usbc_mutex); buf[0] = 0x1; From f74368769048a803e7a7a3dac6434833f563d3bd Mon Sep 17 00:00:00 2001 From: Leonid Kegulskiy Date: Thu, 25 Apr 2013 05:59:56 -0300 Subject: [PATCH 0027/1048] [media] hdpvr: Added some error handling in hdpvr_start_streaming() Signed-off-by: Leonid Kegulskiy Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/usb/hdpvr/hdpvr-video.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/media/usb/hdpvr/hdpvr-video.c b/drivers/media/usb/hdpvr/hdpvr-video.c index 774ba0e820be..cd90ba81a5bb 100644 --- a/drivers/media/usb/hdpvr/hdpvr-video.c +++ b/drivers/media/usb/hdpvr/hdpvr-video.c @@ -298,8 +298,12 @@ static int hdpvr_start_streaming(struct hdpvr_device *dev) 0xb8, 0x38, 0x1, 0, NULL, 0, 8000); v4l2_dbg(MSG_BUFFER, hdpvr_debug, &dev->v4l2_dev, "encoder start control request returned %d\n", ret); + if (ret < 0) + return ret; - hdpvr_config_call(dev, CTRL_START_STREAMING_VALUE, 0x00); + ret = hdpvr_config_call(dev, CTRL_START_STREAMING_VALUE, 0x00); + if (ret) + return ret; dev->status = STATUS_STREAMING; From 63eb2ca171fc5e7c11b16dccd3dc087b050b788c Mon Sep 17 00:00:00 2001 From: "Lad, Prabhakar" Date: Fri, 3 May 2013 04:17:19 -0300 Subject: [PATCH 0028/1048] [media] media: i2c: tvp7002: enable TVP7002 decoder for media controller based usage This patch enables tvp7002 decoder driver for media controller based usage by adding v4l2_subdev_pad_ops operations support for enum_mbus_code, set_pad_format, get_pad_format and media_entity_init() on probe and media_entity_cleanup() on remove. Signed-off-by: Lad, Prabhakar Acked-by: Laurent Pinchart Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/i2c/tvp7002.c | 96 +++++++++++++++++++++++++++++++++++-- include/media/tvp7002.h | 2 + 2 files changed, 93 insertions(+), 5 deletions(-) diff --git a/drivers/media/i2c/tvp7002.c b/drivers/media/i2c/tvp7002.c index 027809cca5f5..270e6997cc76 100644 --- a/drivers/media/i2c/tvp7002.c +++ b/drivers/media/i2c/tvp7002.c @@ -424,6 +424,7 @@ struct tvp7002 { int streaming; const struct tvp7002_timings_definition *current_timings; + struct media_pad pad; }; /* @@ -880,6 +881,65 @@ static const struct v4l2_ctrl_ops tvp7002_ctrl_ops = { .s_ctrl = tvp7002_s_ctrl, }; +/* + * tvp7002_enum_mbus_code() - Enum supported digital video format on pad + * @sd: pointer to standard V4L2 sub-device structure + * @fh: file handle for the subdev + * @code: pointer to subdev enum mbus code struct + * + * Enumerate supported digital video formats for pad. + */ +static int +tvp7002_enum_mbus_code(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, + struct v4l2_subdev_mbus_code_enum *code) +{ + /* Check requested format index is within range */ + if (code->index != 0) + return -EINVAL; + + code->code = V4L2_MBUS_FMT_YUYV10_1X20; + + return 0; +} + +/* + * tvp7002_get_pad_format() - get video format on pad + * @sd: pointer to standard V4L2 sub-device structure + * @fh: file handle for the subdev + * @fmt: pointer to subdev format struct + * + * get video format for pad. + */ +static int +tvp7002_get_pad_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, + struct v4l2_subdev_format *fmt) +{ + struct tvp7002 *tvp7002 = to_tvp7002(sd); + + fmt->format.code = V4L2_MBUS_FMT_YUYV10_1X20; + fmt->format.width = tvp7002->current_timings->timings.bt.width; + fmt->format.height = tvp7002->current_timings->timings.bt.height; + fmt->format.field = tvp7002->current_timings->scanmode; + fmt->format.colorspace = tvp7002->current_timings->color_space; + + return 0; +} + +/* + * tvp7002_set_pad_format() - set video format on pad + * @sd: pointer to standard V4L2 sub-device structure + * @fh: file handle for the subdev + * @fmt: pointer to subdev format struct + * + * set video format for pad. + */ +static int +tvp7002_set_pad_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, + struct v4l2_subdev_format *fmt) +{ + return tvp7002_get_pad_format(sd, fh, fmt); +} + /* V4L2 core operation handlers */ static const struct v4l2_subdev_core_ops tvp7002_core_ops = { .g_chip_ident = tvp7002_g_chip_ident, @@ -910,10 +970,18 @@ static const struct v4l2_subdev_video_ops tvp7002_video_ops = { .enum_mbus_fmt = tvp7002_enum_mbus_fmt, }; +/* media pad related operation handlers */ +static const struct v4l2_subdev_pad_ops tvp7002_pad_ops = { + .enum_mbus_code = tvp7002_enum_mbus_code, + .get_fmt = tvp7002_get_pad_format, + .set_fmt = tvp7002_set_pad_format, +}; + /* V4L2 top level operation handlers */ static const struct v4l2_subdev_ops tvp7002_ops = { .core = &tvp7002_core_ops, .video = &tvp7002_video_ops, + .pad = &tvp7002_pad_ops, }; /* @@ -993,19 +1061,35 @@ static int tvp7002_probe(struct i2c_client *c, const struct i2c_device_id *id) timings = device->current_timings->timings; error = tvp7002_s_dv_timings(sd, &timings); +#if defined(CONFIG_MEDIA_CONTROLLER) + strlcpy(sd->name, TVP7002_MODULE_NAME, sizeof(sd->name)); + device->pad.flags = MEDIA_PAD_FL_SOURCE; + device->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; + device->sd.entity.flags |= MEDIA_ENT_T_V4L2_SUBDEV_DECODER; + + error = media_entity_init(&device->sd.entity, 1, &device->pad, 0); + if (error < 0) + return error; +#endif + v4l2_ctrl_handler_init(&device->hdl, 1); v4l2_ctrl_new_std(&device->hdl, &tvp7002_ctrl_ops, V4L2_CID_GAIN, 0, 255, 1, 0); sd->ctrl_handler = &device->hdl; if (device->hdl.error) { - int err = device->hdl.error; - - v4l2_ctrl_handler_free(&device->hdl); - return err; + error = device->hdl.error; + goto error; } v4l2_ctrl_handler_setup(&device->hdl); return 0; + +error: + v4l2_ctrl_handler_free(&device->hdl); +#if defined(CONFIG_MEDIA_CONTROLLER) + media_entity_cleanup(&device->sd.entity); +#endif + return error; } /* @@ -1022,7 +1106,9 @@ static int tvp7002_remove(struct i2c_client *c) v4l2_dbg(1, debug, sd, "Removing tvp7002 adapter" "on address 0x%x\n", c->addr); - +#if defined(CONFIG_MEDIA_CONTROLLER) + media_entity_cleanup(&device->sd.entity); +#endif v4l2_device_unregister_subdev(sd); v4l2_ctrl_handler_free(&device->hdl); return 0; diff --git a/include/media/tvp7002.h b/include/media/tvp7002.h index ee4353459ef5..7123048408d6 100644 --- a/include/media/tvp7002.h +++ b/include/media/tvp7002.h @@ -26,6 +26,8 @@ #ifndef _TVP7002_H_ #define _TVP7002_H_ +#define TVP7002_MODULE_NAME "tvp7002" + /* Platform-dependent data * * clk_polarity: From 88107675fba0b83d45744e9f2414dfea21686f87 Mon Sep 17 00:00:00 2001 From: Ismael Luceno Date: Fri, 3 May 2013 15:54:57 -0300 Subject: [PATCH 0029/1048] [media] solo6x10: Approximate frame intervals with non-standard denominator Instead of falling back to 1/25 (PAL) or 1/30 (NTSC). Signed-off-by: Ismael Luceno Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- .../media/solo6x10/solo6x10-v4l2-enc.c | 38 ++++++++----------- 1 file changed, 15 insertions(+), 23 deletions(-) diff --git a/drivers/staging/media/solo6x10/solo6x10-v4l2-enc.c b/drivers/staging/media/solo6x10/solo6x10-v4l2-enc.c index 98e2902afd74..a4c589604b02 100644 --- a/drivers/staging/media/solo6x10/solo6x10-v4l2-enc.c +++ b/drivers/staging/media/solo6x10/solo6x10-v4l2-enc.c @@ -996,12 +996,11 @@ static int solo_g_parm(struct file *file, void *priv, struct v4l2_streamparm *sp) { struct solo_enc_dev *solo_enc = video_drvdata(file); - struct solo_dev *solo_dev = solo_enc->solo_dev; struct v4l2_captureparm *cp = &sp->parm.capture; cp->capability = V4L2_CAP_TIMEPERFRAME; cp->timeperframe.numerator = solo_enc->interval; - cp->timeperframe.denominator = solo_dev->fps; + cp->timeperframe.denominator = solo_enc->solo_dev->fps; cp->capturemode = 0; /* XXX: Shouldn't we be able to get/set this from videobuf? */ cp->readbuffers = 2; @@ -1009,36 +1008,29 @@ static int solo_g_parm(struct file *file, void *priv, return 0; } +static inline int calc_interval(u8 fps, u32 n, u32 d) +{ + if (!n || !d) + return 1; + if (d == fps) + return n; + n *= fps; + return min(15U, n / d + (n % d >= (fps >> 1))); +} + static int solo_s_parm(struct file *file, void *priv, struct v4l2_streamparm *sp) { struct solo_enc_dev *solo_enc = video_drvdata(file); - struct solo_dev *solo_dev = solo_enc->solo_dev; - struct v4l2_captureparm *cp = &sp->parm.capture; + struct v4l2_fract *t = &sp->parm.capture.timeperframe; + u8 fps = solo_enc->solo_dev->fps; if (vb2_is_streaming(&solo_enc->vidq)) return -EBUSY; - if ((cp->timeperframe.numerator == 0) || - (cp->timeperframe.denominator == 0)) { - /* reset framerate */ - cp->timeperframe.numerator = 1; - cp->timeperframe.denominator = solo_dev->fps; - } - - if (cp->timeperframe.denominator != solo_dev->fps) - cp->timeperframe.denominator = solo_dev->fps; - - if (cp->timeperframe.numerator > 15) - cp->timeperframe.numerator = 15; - - solo_enc->interval = cp->timeperframe.numerator; - - cp->capability = V4L2_CAP_TIMEPERFRAME; - cp->readbuffers = 2; - + solo_enc->interval = calc_interval(fps, t->numerator, t->denominator); solo_update_mode(solo_enc); - return 0; + return solo_g_parm(file, priv, sp); } static long solo_enc_default(struct file *file, void *fh, From 5255e4d9dfe2e33a5d68c54f6d1bee28fc5edd66 Mon Sep 17 00:00:00 2001 From: Alexey Khoroshilov Date: Tue, 7 May 2013 17:57:08 -0300 Subject: [PATCH 0030/1048] [media] wl128x: do not call copy_to_user() while holding spinlocks copy_to_user() must not be called with spinlocks held, but it is in fmc_transfer_rds_from_internal_buff(). The patch copies data to tmpbuf, releases spinlock and then passes it to userspace. By the way there is a small unification: replace a couple of hardcoded constants by a macro. Found by Linux Driver Verification project (linuxtesting.org). Signed-off-by: Alexey Khoroshilov Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/radio/wl128x/fmdrv_common.c | 24 +++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/drivers/media/radio/wl128x/fmdrv_common.c b/drivers/media/radio/wl128x/fmdrv_common.c index a002234ed5de..253f307f0b37 100644 --- a/drivers/media/radio/wl128x/fmdrv_common.c +++ b/drivers/media/radio/wl128x/fmdrv_common.c @@ -715,7 +715,7 @@ static void fm_irq_handle_rdsdata_getcmd_resp(struct fmdev *fmdev) struct fm_rdsdata_format rds_fmt; struct fm_rds *rds = &fmdev->rx.rds; unsigned long group_idx, flags; - u8 *rds_data, meta_data, tmpbuf[3]; + u8 *rds_data, meta_data, tmpbuf[FM_RDS_BLK_SIZE]; u8 type, blk_idx; u16 cur_picode; u32 rds_len; @@ -1073,6 +1073,7 @@ int fmc_transfer_rds_from_internal_buff(struct fmdev *fmdev, struct file *file, u8 __user *buf, size_t count) { u32 block_count; + u8 tmpbuf[FM_RDS_BLK_SIZE]; unsigned long flags; int ret; @@ -1087,29 +1088,32 @@ int fmc_transfer_rds_from_internal_buff(struct fmdev *fmdev, struct file *file, } /* Calculate block count from byte count */ - count /= 3; + count /= FM_RDS_BLK_SIZE; block_count = 0; ret = 0; - spin_lock_irqsave(&fmdev->rds_buff_lock, flags); - while (block_count < count) { - if (fmdev->rx.rds.wr_idx == fmdev->rx.rds.rd_idx) - break; + spin_lock_irqsave(&fmdev->rds_buff_lock, flags); - if (copy_to_user(buf, &fmdev->rx.rds.buff[fmdev->rx.rds.rd_idx], - FM_RDS_BLK_SIZE)) + if (fmdev->rx.rds.wr_idx == fmdev->rx.rds.rd_idx) { + spin_unlock_irqrestore(&fmdev->rds_buff_lock, flags); break; - + } + memcpy(tmpbuf, &fmdev->rx.rds.buff[fmdev->rx.rds.rd_idx], + FM_RDS_BLK_SIZE); fmdev->rx.rds.rd_idx += FM_RDS_BLK_SIZE; if (fmdev->rx.rds.rd_idx >= fmdev->rx.rds.buf_size) fmdev->rx.rds.rd_idx = 0; + spin_unlock_irqrestore(&fmdev->rds_buff_lock, flags); + + if (copy_to_user(buf, tmpbuf, FM_RDS_BLK_SIZE)) + break; + block_count++; buf += FM_RDS_BLK_SIZE; ret += FM_RDS_BLK_SIZE; } - spin_unlock_irqrestore(&fmdev->rds_buff_lock, flags); return ret; } From e090901e48ba75508caaa1b98fdbb65591c1163f Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 26 Apr 2013 10:22:47 -0300 Subject: [PATCH 0031/1048] [media] saa7115: move the autodetection code out of the probe function MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As we're now seeing other variants from chinese clones, like gm1113c, we'll need to add more bits at the detection code. So, move it into a separate function. Signed-off-by: Mauro Carvalho Chehab Tested-by: Jon Arne Jørgensen Tested-by: Ezequiel Garcia Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/i2c/saa7115.c | 133 ++++++++++++++++++++++-------------- 1 file changed, 83 insertions(+), 50 deletions(-) diff --git a/drivers/media/i2c/saa7115.c b/drivers/media/i2c/saa7115.c index eecb92df5d96..289f460801db 100644 --- a/drivers/media/i2c/saa7115.c +++ b/drivers/media/i2c/saa7115.c @@ -1573,46 +1573,103 @@ static const struct v4l2_subdev_ops saa711x_ops = { /* ----------------------------------------------------------------------- */ +/** + * saa711x_detect_chip - Detects the saa711x (or clone) variant + * @client: I2C client structure. + * @id: I2C device ID structure. + * @name: Name of the device to be filled. + * @size: Size of the name var. + * + * Detects the Philips/NXP saa711x chip, or some clone of it. + * if 'id' is NULL or id->driver_data is equal to 1, it auto-probes + * the analog demod. + * If the tuner is not found, it returns -ENODEV. + * If auto-detection is disabled and the tuner doesn't match what it was + * requred, it returns -EINVAL and fills 'name'. + * If the chip is found, it returns the chip ID and fills 'name'. + */ +static int saa711x_detect_chip(struct i2c_client *client, + const struct i2c_device_id *id, + char *name, unsigned size) +{ + char chip_ver[size - 1]; + char chip_id; + int i; + int autodetect; + + autodetect = !id || id->driver_data == 1; + + /* Read the chip version register */ + for (i = 0; i < size - 1; i++) { + i2c_smbus_write_byte_data(client, 0, i); + chip_ver[i] = i2c_smbus_read_byte_data(client, 0); + name[i] = (chip_ver[i] & 0x0f) + '0'; + if (name[i] > '9') + name[i] += 'a' - '9' - 1; + } + name[i] = '\0'; + + /* Check if it is a Philips/NXP chip */ + if (!memcmp(name + 1, "f711", 4)) { + chip_id = name[5]; + snprintf(name, size, "saa711%c", chip_id); + + if (!autodetect && strcmp(name, id->name)) + return -EINVAL; + + switch (chip_id) { + case '1': + if (chip_ver[0] & 0xf0) { + snprintf(name, size, "saa711%ca", chip_id); + v4l_info(client, "saa7111a variant found\n"); + return V4L2_IDENT_SAA7111A; + } + return V4L2_IDENT_SAA7111; + case '3': + return V4L2_IDENT_SAA7113; + case '4': + return V4L2_IDENT_SAA7114; + case '5': + return V4L2_IDENT_SAA7115; + case '8': + return V4L2_IDENT_SAA7118; + default: + v4l2_info(client, + "WARNING: Philips/NXP chip unknown - Falling back to saa7111\n"); + return V4L2_IDENT_SAA7111; + } + } + + /* Chip was not discovered. Return its ID and don't bind */ + v4l_dbg(1, debug, client, "chip %*ph @ 0x%x is unknown.\n", + 16, chip_ver, client->addr << 1); + return -ENODEV; +} + static int saa711x_probe(struct i2c_client *client, const struct i2c_device_id *id) { struct saa711x_state *state; struct v4l2_subdev *sd; struct v4l2_ctrl_handler *hdl; - int i; + int ident; char name[17]; - char chip_id; - int autodetect = !id || id->driver_data == 1; /* Check if the adapter supports the needed features */ if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) return -EIO; - for (i = 0; i < 0x0f; i++) { - i2c_smbus_write_byte_data(client, 0, i); - name[i] = (i2c_smbus_read_byte_data(client, 0) & 0x0f) + '0'; - if (name[i] > '9') - name[i] += 'a' - '9' - 1; - } - name[i] = '\0'; - - chip_id = name[5]; - - /* Check whether this chip is part of the saa711x series */ - if (memcmp(name + 1, "f711", 4)) { - v4l_dbg(1, debug, client, "chip found @ 0x%x (ID %s) does not match a known saa711x chip.\n", - client->addr << 1, name); + ident = saa711x_detect_chip(client, id, name, sizeof(name)); + if (ident == -EINVAL) { + /* Chip exists, but doesn't match */ + v4l_warn(client, "found %s while %s was expected\n", + name, id->name); return -ENODEV; } + if (ident < 0) + return ident; - /* Safety check */ - if (!autodetect && id->name[6] != chip_id) { - v4l_warn(client, "found saa711%c while %s was expected\n", - chip_id, id->name); - } - snprintf(client->name, sizeof(client->name), "saa711%c", chip_id); - v4l_info(client, "saa711%c found (%s) @ 0x%x (%s)\n", chip_id, name, - client->addr << 1, client->adapter->name); + strlcpy(client->name, name, sizeof(client->name)); state = devm_kzalloc(&client->dev, sizeof(*state), GFP_KERNEL); if (state == NULL) @@ -1648,31 +1705,7 @@ static int saa711x_probe(struct i2c_client *client, state->output = SAA7115_IPORT_ON; state->enable = 1; state->radio = 0; - switch (chip_id) { - case '1': - state->ident = V4L2_IDENT_SAA7111; - if (saa711x_read(sd, R_00_CHIP_VERSION) & 0xf0) { - v4l_info(client, "saa7111a variant found\n"); - state->ident = V4L2_IDENT_SAA7111A; - } - break; - case '3': - state->ident = V4L2_IDENT_SAA7113; - break; - case '4': - state->ident = V4L2_IDENT_SAA7114; - break; - case '5': - state->ident = V4L2_IDENT_SAA7115; - break; - case '8': - state->ident = V4L2_IDENT_SAA7118; - break; - default: - state->ident = V4L2_IDENT_SAA7111; - v4l2_info(sd, "WARNING: Chip is not known - Falling back to saa7111\n"); - break; - } + state->ident = ident; state->audclk_freq = 48000; From b11460b0532dd22830a9f2fcdcad91b790c6b35b Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 26 Apr 2013 10:22:48 -0300 Subject: [PATCH 0032/1048] [media] saa7115: add detection code for gm7113c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds a code that (auto)detects gm7113c clones. The auto-detection here is not perfect, as, on contrary to what it would be expected by looking into its datasheets some devices would return, instead: saa7115 0-0025: chip 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 @ 0x4a is unknown (found on a device labeled as GM7113C 1145 by Ezequiel Garcia) Signed-off-by: Mauro Carvalho Chehab Tested-by: Jon Arne Jørgensen Tested-by: Ezequiel Garcia Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/i2c/saa7115.c | 36 +++++++++++++++++++++++++++++++++ include/media/v4l2-chip-ident.h | 2 ++ 2 files changed, 38 insertions(+) diff --git a/drivers/media/i2c/saa7115.c b/drivers/media/i2c/saa7115.c index 289f460801db..ca2a863a6d3e 100644 --- a/drivers/media/i2c/saa7115.c +++ b/drivers/media/i2c/saa7115.c @@ -1640,6 +1640,36 @@ static int saa711x_detect_chip(struct i2c_client *client, } } + /* Check if it is a gm7113c */ + if (!memcmp(name, "0000", 4)) { + chip_id = 0; + for (i = 0; i < 4; i++) { + chip_id = chip_id << 1; + chip_id |= (chip_ver[i] & 0x80) ? 1 : 0; + } + + /* + * Note: From the datasheet, only versions 1 and 2 + * exists. However, tests on a device labeled as: + * "GM7113C 1145" returned "10" on all 16 chip + * version (reg 0x00) reads. So, we need to also + * accept at least verion 0. For now, let's just + * assume that a device that returns "0000" for + * the lower nibble is a gm7113c. + */ + + strlcpy(name, "gm7113c", size); + + if (!autodetect && strcmp(name, id->name)) + return -EINVAL; + + v4l_dbg(1, debug, client, + "It seems to be a %s chip (%*ph) @ 0x%x.\n", + name, 16, chip_ver, client->addr << 1); + + return V4L2_IDENT_GM7113C; + } + /* Chip was not discovered. Return its ID and don't bind */ v4l_dbg(1, debug, client, "chip %*ph @ 0x%x is unknown.\n", 16, chip_ver, client->addr << 1); @@ -1669,6 +1699,11 @@ static int saa711x_probe(struct i2c_client *client, if (ident < 0) return ident; + if (ident == V4L2_IDENT_GM7113C) { + v4l_warn(client, "%s not yet supported\n", name); + return -ENODEV; + } + strlcpy(client->name, name, sizeof(client->name)); state = devm_kzalloc(&client->dev, sizeof(*state), GFP_KERNEL); @@ -1754,6 +1789,7 @@ static const struct i2c_device_id saa711x_id[] = { { "saa7114", 0 }, { "saa7115", 0 }, { "saa7118", 0 }, + { "gm7113c", 0 }, { } }; MODULE_DEVICE_TABLE(i2c, saa711x_id); diff --git a/include/media/v4l2-chip-ident.h b/include/media/v4l2-chip-ident.h index c259b36bf1e9..543f89c18896 100644 --- a/include/media/v4l2-chip-ident.h +++ b/include/media/v4l2-chip-ident.h @@ -52,6 +52,8 @@ enum { V4L2_IDENT_SAA7115 = 105, V4L2_IDENT_SAA7118 = 108, + V4L2_IDENT_GM7113C = 140, + /* module saa7127: reserved range 150-199 */ V4L2_IDENT_SAA7127 = 157, V4L2_IDENT_SAA7129 = 159, From 241d89fce7b084ea9c671a1b895001eb76b4eecb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=20Arne=20J=C3=B8rgensen?= Date: Fri, 10 May 2013 03:52:28 -0300 Subject: [PATCH 0033/1048] [media] saa7115: Add register setup and config for gm7113c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The gm7113c chip is similar to the original saa7113 chip, so I try to re-use most of the saa7113 specific setup-/configuration registers. According to the datasheet, the gm7113c chip has not implemented any register-addresses after 0x1f, so I add a new entry to for the chip to the saa711x_has_reg function. The devices I've seen using this chip will fail to get stable video-sync if these registers are not zeroed: R_14_ANAL_ADC_COMPAT_CNTL R_15_VGATE_START_FID_CHG R_16_VGATE_STOP R_17_MISC_VGATE_CONF_AND_MSB The saa711x_set_v4lstd is updated to send a simpler configuration-table to avoid setting these registers. Signed-off-by: Jon Arne Jørgensen Tested-by: Ezequiel Garcia Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/i2c/saa7115.c | 47 +++++++++++++++++++++++++++++-------- 1 file changed, 37 insertions(+), 10 deletions(-) diff --git a/drivers/media/i2c/saa7115.c b/drivers/media/i2c/saa7115.c index ca2a863a6d3e..be32688797e1 100644 --- a/drivers/media/i2c/saa7115.c +++ b/drivers/media/i2c/saa7115.c @@ -127,6 +127,8 @@ static int saa711x_has_reg(const int id, const u8 reg) return 0; switch (id) { + case V4L2_IDENT_GM7113C: + return reg != 0x14 && (reg < 0x18 || reg > 0x1e) && reg < 0x20; case V4L2_IDENT_SAA7113: return reg != 0x14 && (reg < 0x18 || reg > 0x1e) && (reg < 0x20 || reg > 0x3f) && reg != 0x5d && reg < 0x63; @@ -214,7 +216,10 @@ static const unsigned char saa7111_init[] = { 0x00, 0x00 }; -/* SAA7113 init codes */ +/* SAA7113/GM7113C init codes + * It's important that R_14... R_17 == 0x00 + * for the gm7113c chip to deliver stable video + */ static const unsigned char saa7113_init[] = { R_01_INC_DELAY, 0x08, R_02_INPUT_CNTL_1, 0xc2, @@ -448,6 +453,24 @@ static const unsigned char saa7115_cfg_50hz_video[] = { /* ============== SAA7715 VIDEO templates (end) ======= */ +/* ============== GM7113C VIDEO templates ============= */ +static const unsigned char gm7113c_cfg_60hz_video[] = { + R_08_SYNC_CNTL, 0x68, /* 0xBO: auto detection, 0x68 = NTSC */ + R_0E_CHROMA_CNTL_1, 0x07, /* video autodetection is on */ + + 0x00, 0x00 +}; + +static const unsigned char gm7113c_cfg_50hz_video[] = { + R_08_SYNC_CNTL, 0x28, /* 0x28 = PAL */ + R_0E_CHROMA_CNTL_1, 0x07, + + 0x00, 0x00 +}; + +/* ============== GM7113C VIDEO templates (end) ======= */ + + static const unsigned char saa7115_cfg_vbi_on[] = { R_80_GLOBAL_CNTL_1, 0x00, /* reset tasks */ R_88_POWER_SAVE_ADC_PORT_CNTL, 0xd0, /* reset scaler */ @@ -932,11 +955,17 @@ static void saa711x_set_v4lstd(struct v4l2_subdev *sd, v4l2_std_id std) // This works for NTSC-M, SECAM-L and the 50Hz PAL variants. if (std & V4L2_STD_525_60) { v4l2_dbg(1, debug, sd, "decoder set standard 60 Hz\n"); - saa711x_writeregs(sd, saa7115_cfg_60hz_video); + if (state->ident == V4L2_IDENT_GM7113C) + saa711x_writeregs(sd, gm7113c_cfg_60hz_video); + else + saa711x_writeregs(sd, saa7115_cfg_60hz_video); saa711x_set_size(sd, 720, 480); } else { v4l2_dbg(1, debug, sd, "decoder set standard 50 Hz\n"); - saa711x_writeregs(sd, saa7115_cfg_50hz_video); + if (state->ident == V4L2_IDENT_GM7113C) + saa711x_writeregs(sd, gm7113c_cfg_50hz_video); + else + saa711x_writeregs(sd, saa7115_cfg_50hz_video); saa711x_set_size(sd, 720, 576); } @@ -949,7 +978,8 @@ static void saa711x_set_v4lstd(struct v4l2_subdev *sd, v4l2_std_id std) 011 NTSC N (3.58MHz) PAL M (3.58MHz) 100 reserved NTSC-Japan (3.58MHz) */ - if (state->ident <= V4L2_IDENT_SAA7113) { + if (state->ident <= V4L2_IDENT_SAA7113 || + state->ident == V4L2_IDENT_GM7113C) { u8 reg = saa711x_read(sd, R_0E_CHROMA_CNTL_1) & 0x8f; if (std == V4L2_STD_PAL_M) { @@ -1220,7 +1250,8 @@ static int saa711x_s_routing(struct v4l2_subdev *sd, input, output); /* saa7111/3 does not have these inputs */ - if (state->ident <= V4L2_IDENT_SAA7113 && + if ((state->ident <= V4L2_IDENT_SAA7113 || + state->ident == V4L2_IDENT_GM7113C) && (input == SAA7115_COMPOSITE4 || input == SAA7115_COMPOSITE5)) { return -EINVAL; @@ -1699,11 +1730,6 @@ static int saa711x_probe(struct i2c_client *client, if (ident < 0) return ident; - if (ident == V4L2_IDENT_GM7113C) { - v4l_warn(client, "%s not yet supported\n", name); - return -ENODEV; - } - strlcpy(client->name, name, sizeof(client->name)); state = devm_kzalloc(&client->dev, sizeof(*state), GFP_KERNEL); @@ -1753,6 +1779,7 @@ static int saa711x_probe(struct i2c_client *client, case V4L2_IDENT_SAA7111A: saa711x_writeregs(sd, saa7111_init); break; + case V4L2_IDENT_GM7113C: case V4L2_IDENT_SAA7113: saa711x_writeregs(sd, saa7113_init); break; From a0f9354b1a319cb29c331bfd2e5a15d7f9b87fa4 Mon Sep 17 00:00:00 2001 From: Randy Dunlap Date: Wed, 8 May 2013 17:28:13 -0300 Subject: [PATCH 0034/1048] [media] media/usb: fix kconfig dependencies (a.k.a. Kconfig bool depending on a tristate considered harmful) Fix various build errors when CONFIG_USB=m and media USB drivers are builtin. In this case, CONFIG_USB_ZR364XX=y, CONFIG_VIDEO_PVRUSB2=y, and CONFIG_VIDEO_STK1160=y. This is caused by (from drivers/media/usb/Kconfig): menuconfig MEDIA_USB_SUPPORT bool "Media USB Adapters" depends on USB && MEDIA_SUPPORT =m =y so MEDIA_USB_SUPPORT=y and all following Kconfig 'source' lines are included. By adding an "if USB" guard around most of this file, the needed dependencies are enforced. drivers/built-in.o: In function `zr364xx_start_readpipe': zr364xx.c:(.text+0xc726a): undefined reference to `usb_alloc_urb' zr364xx.c:(.text+0xc72bb): undefined reference to `usb_submit_urb' drivers/built-in.o: In function `zr364xx_stop_readpipe': zr364xx.c:(.text+0xc72fd): undefined reference to `usb_kill_urb' zr364xx.c:(.text+0xc7309): undefined reference to `usb_free_urb' drivers/built-in.o: In function `read_pipe_completion': zr364xx.c:(.text+0xc7acc): undefined reference to `usb_submit_urb' drivers/built-in.o: In function `send_control_msg.constprop.12': zr364xx.c:(.text+0xc7d2f): undefined reference to `usb_control_msg' drivers/built-in.o: In function `pvr2_ctl_timeout': pvrusb2-hdw.c:(.text+0xcadb6): undefined reference to `usb_unlink_urb' pvrusb2-hdw.c:(.text+0xcadcb): undefined reference to `usb_unlink_urb' drivers/built-in.o: In function `pvr2_hdw_create': (.text+0xcc42c): undefined reference to `usb_alloc_urb' drivers/built-in.o: In function `pvr2_hdw_create': (.text+0xcc448): undefined reference to `usb_alloc_urb' drivers/built-in.o: In function `pvr2_hdw_create': (.text+0xcc5f9): undefined reference to `usb_set_interface' drivers/built-in.o: In function `pvr2_hdw_create': (.text+0xcc65a): undefined reference to `usb_free_urb' drivers/built-in.o: In function `pvr2_hdw_create': (.text+0xcc666): undefined reference to `usb_free_urb' drivers/built-in.o: In function `pvr2_send_request_ex.part.22': pvrusb2-hdw.c:(.text+0xccbe3): undefined reference to `usb_submit_urb' pvrusb2-hdw.c:(.text+0xccc83): undefined reference to `usb_submit_urb' drivers/built-in.o: In function `pvr2_hdw_remove_usb_stuff.part.25': pvrusb2-hdw.c:(.text+0xcd3f9): undefined reference to `usb_kill_urb' pvrusb2-hdw.c:(.text+0xcd405): undefined reference to `usb_free_urb' pvrusb2-hdw.c:(.text+0xcd421): undefined reference to `usb_kill_urb' pvrusb2-hdw.c:(.text+0xcd42d): undefined reference to `usb_free_urb' drivers/built-in.o: In function `pvr2_hdw_device_reset': (.text+0xcd658): undefined reference to `usb_lock_device_for_reset' drivers/built-in.o: In function `pvr2_hdw_device_reset': (.text+0xcd664): undefined reference to `usb_reset_device' drivers/built-in.o: In function `pvr2_hdw_cpureset_assert': (.text+0xcd6f9): undefined reference to `usb_control_msg' drivers/built-in.o: In function `pvr2_hdw_cpufw_set_enabled': (.text+0xcd84e): undefined reference to `usb_control_msg' drivers/built-in.o: In function `pvr2_upload_firmware1': pvrusb2-hdw.c:(.text+0xcda47): undefined reference to `usb_clear_halt' pvrusb2-hdw.c:(.text+0xcdb04): undefined reference to `usb_control_msg' drivers/built-in.o: In function `pvr2_upload_firmware2': (.text+0xce7dc): undefined reference to `usb_bulk_msg' drivers/built-in.o: In function `pvr2_stream_buffer_count': pvrusb2-io.c:(.text+0xd2e05): undefined reference to `usb_alloc_urb' pvrusb2-io.c:(.text+0xd2e5b): undefined reference to `usb_kill_urb' pvrusb2-io.c:(.text+0xd2e9f): undefined reference to `usb_free_urb' drivers/built-in.o: In function `pvr2_stream_internal_flush': pvrusb2-io.c:(.text+0xd2f9b): undefined reference to `usb_kill_urb' drivers/built-in.o: In function `pvr2_buffer_queue': (.text+0xd3328): undefined reference to `usb_kill_urb' drivers/built-in.o: In function `pvr2_buffer_queue': (.text+0xd33ea): undefined reference to `usb_submit_urb' drivers/built-in.o: In function `stk1160_read_reg': (.text+0xd3efa): undefined reference to `usb_control_msg' drivers/built-in.o: In function `stk1160_write_reg': (.text+0xd3f4f): undefined reference to `usb_control_msg' drivers/built-in.o: In function `stop_streaming': stk1160-v4l.c:(.text+0xd4997): undefined reference to `usb_set_interface' drivers/built-in.o: In function `start_streaming': stk1160-v4l.c:(.text+0xd4a9f): undefined reference to `usb_set_interface' stk1160-v4l.c:(.text+0xd4afa): undefined reference to `usb_submit_urb' stk1160-v4l.c:(.text+0xd4ba3): undefined reference to `usb_set_interface' drivers/built-in.o: In function `stk1160_isoc_irq': stk1160-video.c:(.text+0xd509b): undefined reference to `usb_submit_urb' drivers/built-in.o: In function `stk1160_cancel_isoc': (.text+0xd50ef): undefined reference to `usb_kill_urb' drivers/built-in.o: In function `stk1160_free_isoc': (.text+0xd5155): undefined reference to `usb_free_coherent' drivers/built-in.o: In function `stk1160_free_isoc': (.text+0xd515d): undefined reference to `usb_free_urb' drivers/built-in.o: In function `stk1160_alloc_isoc': (.text+0xd5278): undefined reference to `usb_alloc_urb' drivers/built-in.o: In function `stk1160_alloc_isoc': (.text+0xd52c2): undefined reference to `usb_alloc_coherent' drivers/built-in.o: In function `stk1160_alloc_isoc': (.text+0xd53c4): undefined reference to `usb_free_urb' drivers/built-in.o: In function `zr364xx_driver_init': zr364xx.c:(.init.text+0x463e): undefined reference to `usb_register_driver' drivers/built-in.o: In function `pvr_init': pvrusb2-main.c:(.init.text+0x4662): undefined reference to `usb_register_driver' drivers/built-in.o: In function `stk1160_usb_driver_init': stk1160-core.c:(.init.text+0x467d): undefined reference to `usb_register_driver' drivers/built-in.o: In function `zr364xx_driver_exit': zr364xx.c:(.exit.text+0x1377): undefined reference to `usb_deregister' drivers/built-in.o: In function `pvr_exit': pvrusb2-main.c:(.exit.text+0x1389): undefined reference to `usb_deregister' drivers/built-in.o: In function `stk1160_usb_driver_exit': stk1160-core.c:(.exit.text+0x13a0): undefined reference to `usb_deregister' Suggested-by: "Yann E. MORIN" Signed-off-by: Randy Dunlap Signed-off-by: Mauro Carvalho Chehab --- drivers/media/usb/Kconfig | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/media/usb/Kconfig b/drivers/media/usb/Kconfig index 0a7d520636a9..0d8fe005d1f4 100644 --- a/drivers/media/usb/Kconfig +++ b/drivers/media/usb/Kconfig @@ -1,6 +1,8 @@ +if USB + menuconfig MEDIA_USB_SUPPORT bool "Media USB Adapters" - depends on USB && MEDIA_SUPPORT + depends on MEDIA_SUPPORT help Enable media drivers for USB bus. If you have such devices, say Y. @@ -52,3 +54,4 @@ source "drivers/media/usb/em28xx/Kconfig" endif endif #MEDIA_USB_SUPPORT +endif #USB From 0735647c29bca5f33f38fcf457b3b0e9e5912f51 Mon Sep 17 00:00:00 2001 From: Reinhard Nissl Date: Wed, 8 May 2013 17:54:57 -0300 Subject: [PATCH 0035/1048] [media] stb0899: remove commented value from IQ_SWAP_ON/OFF usages MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As the enum values have changed recently, the comments are void. Signed-off-by: Reinhard Nißl Signed-off-by: Mauro Carvalho Chehab --- drivers/media/pci/mantis/mantis_vp1041.c | 2 +- drivers/media/pci/ttpci/budget-av.c | 2 +- drivers/media/pci/ttpci/budget-ci.c | 2 +- drivers/media/usb/dvb-usb/az6027.c | 2 +- drivers/media/usb/dvb-usb/pctv452e.c | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/media/pci/mantis/mantis_vp1041.c b/drivers/media/pci/mantis/mantis_vp1041.c index 07aa887a4b4a..07a20748b707 100644 --- a/drivers/media/pci/mantis/mantis_vp1041.c +++ b/drivers/media/pci/mantis/mantis_vp1041.c @@ -273,7 +273,7 @@ struct stb0899_config vp1041_stb0899_config = { .demod_address = 0x68, /* 0xd0 >> 1 */ .xtal_freq = 27000000, - .inversion = IQ_SWAP_ON, /* 1 */ + .inversion = IQ_SWAP_ON, .lo_clk = 76500000, .hi_clk = 99000000, diff --git a/drivers/media/pci/ttpci/budget-av.c b/drivers/media/pci/ttpci/budget-av.c index 1f8b1bb0bf9f..0ba3875af22e 100644 --- a/drivers/media/pci/ttpci/budget-av.c +++ b/drivers/media/pci/ttpci/budget-av.c @@ -1128,7 +1128,7 @@ static struct stb0899_config knc1_dvbs2_config = { // .ts_pfbit_toggle = STB0899_MPEG_NORMAL, /* DirecTV, MPEG toggling seq */ .xtal_freq = 27000000, - .inversion = IQ_SWAP_OFF, /* 1 */ + .inversion = IQ_SWAP_OFF, .lo_clk = 76500000, .hi_clk = 90000000, diff --git a/drivers/media/pci/ttpci/budget-ci.c b/drivers/media/pci/ttpci/budget-ci.c index 98e524178765..0acf9202103d 100644 --- a/drivers/media/pci/ttpci/budget-ci.c +++ b/drivers/media/pci/ttpci/budget-ci.c @@ -1280,7 +1280,7 @@ static struct stb0899_config tt3200_config = { .demod_address = 0x68, .xtal_freq = 27000000, - .inversion = IQ_SWAP_ON, /* 1 */ + .inversion = IQ_SWAP_ON, .lo_clk = 76500000, .hi_clk = 99000000, diff --git a/drivers/media/usb/dvb-usb/az6027.c b/drivers/media/usb/dvb-usb/az6027.c index 91e0119e8a87..ea2d5ee86576 100644 --- a/drivers/media/usb/dvb-usb/az6027.c +++ b/drivers/media/usb/dvb-usb/az6027.c @@ -264,7 +264,7 @@ struct stb0899_config az6027_stb0899_config = { .demod_address = 0xd0, /* 0x68, 0xd0 >> 1 */ .xtal_freq = 27000000, - .inversion = IQ_SWAP_ON, /* 1 */ + .inversion = IQ_SWAP_ON, .lo_clk = 76500000, .hi_clk = 99000000, diff --git a/drivers/media/usb/dvb-usb/pctv452e.c b/drivers/media/usb/dvb-usb/pctv452e.c index d1ddfa13de86..449a99605a87 100644 --- a/drivers/media/usb/dvb-usb/pctv452e.c +++ b/drivers/media/usb/dvb-usb/pctv452e.c @@ -828,7 +828,7 @@ static struct stb0899_config stb0899_config = { .block_sync_mode = STB0899_SYNC_FORCED, /* ? */ .xtal_freq = 27000000, /* Assume Hz ? */ - .inversion = IQ_SWAP_ON, /* ? */ + .inversion = IQ_SWAP_ON, .lo_clk = 76500000, .hi_clk = 99000000, From a242f426108c284049a69710f871cc9f11b13e61 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 9 May 2013 15:03:33 -0300 Subject: [PATCH 0036/1048] [media] videobuf_vm_{open,close} race fixes just use videobuf_queue_lock(map->q) to protect map->count; vm_area_operations ->open() and ->close() are called just under vma->vm_mm->mmap_sem, which doesn't help the drivers at all, since clonal VMAs are normally in different address spaces... Signed-off-by: Al Viro Signed-off-by: Mauro Carvalho Chehab --- drivers/media/v4l2-core/videobuf-dma-contig.c | 12 +++++++----- drivers/media/v4l2-core/videobuf-dma-sg.c | 10 ++++++---- drivers/media/v4l2-core/videobuf-vmalloc.c | 10 ++++++---- 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/drivers/media/v4l2-core/videobuf-dma-contig.c b/drivers/media/v4l2-core/videobuf-dma-contig.c index 67f572c3fba2..8204c8810372 100644 --- a/drivers/media/v4l2-core/videobuf-dma-contig.c +++ b/drivers/media/v4l2-core/videobuf-dma-contig.c @@ -66,11 +66,14 @@ static void __videobuf_dc_free(struct device *dev, static void videobuf_vm_open(struct vm_area_struct *vma) { struct videobuf_mapping *map = vma->vm_private_data; + struct videobuf_queue *q = map->q; - dev_dbg(map->q->dev, "vm_open %p [count=%u,vma=%08lx-%08lx]\n", + dev_dbg(q->dev, "vm_open %p [count=%u,vma=%08lx-%08lx]\n", map, map->count, vma->vm_start, vma->vm_end); + videobuf_queue_lock(q); map->count++; + videobuf_queue_unlock(q); } static void videobuf_vm_close(struct vm_area_struct *vma) @@ -82,12 +85,11 @@ static void videobuf_vm_close(struct vm_area_struct *vma) dev_dbg(q->dev, "vm_close %p [count=%u,vma=%08lx-%08lx]\n", map, map->count, vma->vm_start, vma->vm_end); - map->count--; - if (0 == map->count) { + videobuf_queue_lock(q); + if (!--map->count) { struct videobuf_dma_contig_memory *mem; dev_dbg(q->dev, "munmap %p q=%p\n", map, q); - videobuf_queue_lock(q); /* We need first to cancel streams, before unmapping */ if (q->streaming) @@ -126,8 +128,8 @@ static void videobuf_vm_close(struct vm_area_struct *vma) kfree(map); - videobuf_queue_unlock(q); } + videobuf_queue_unlock(q); } static const struct vm_operations_struct videobuf_vm_ops = { diff --git a/drivers/media/v4l2-core/videobuf-dma-sg.c b/drivers/media/v4l2-core/videobuf-dma-sg.c index 828e7c10bd70..9db674ccdc68 100644 --- a/drivers/media/v4l2-core/videobuf-dma-sg.c +++ b/drivers/media/v4l2-core/videobuf-dma-sg.c @@ -338,11 +338,14 @@ EXPORT_SYMBOL_GPL(videobuf_dma_free); static void videobuf_vm_open(struct vm_area_struct *vma) { struct videobuf_mapping *map = vma->vm_private_data; + struct videobuf_queue *q = map->q; dprintk(2, "vm_open %p [count=%d,vma=%08lx-%08lx]\n", map, map->count, vma->vm_start, vma->vm_end); + videobuf_queue_lock(q); map->count++; + videobuf_queue_unlock(q); } static void videobuf_vm_close(struct vm_area_struct *vma) @@ -355,10 +358,9 @@ static void videobuf_vm_close(struct vm_area_struct *vma) dprintk(2, "vm_close %p [count=%d,vma=%08lx-%08lx]\n", map, map->count, vma->vm_start, vma->vm_end); - map->count--; - if (0 == map->count) { + videobuf_queue_lock(q); + if (!--map->count) { dprintk(1, "munmap %p q=%p\n", map, q); - videobuf_queue_lock(q); for (i = 0; i < VIDEO_MAX_FRAME; i++) { if (NULL == q->bufs[i]) continue; @@ -374,9 +376,9 @@ static void videobuf_vm_close(struct vm_area_struct *vma) q->bufs[i]->baddr = 0; q->ops->buf_release(q, q->bufs[i]); } - videobuf_queue_unlock(q); kfree(map); } + videobuf_queue_unlock(q); return; } diff --git a/drivers/media/v4l2-core/videobuf-vmalloc.c b/drivers/media/v4l2-core/videobuf-vmalloc.c index 2ff7fcc77b11..1365c651c177 100644 --- a/drivers/media/v4l2-core/videobuf-vmalloc.c +++ b/drivers/media/v4l2-core/videobuf-vmalloc.c @@ -54,11 +54,14 @@ MODULE_LICENSE("GPL"); static void videobuf_vm_open(struct vm_area_struct *vma) { struct videobuf_mapping *map = vma->vm_private_data; + struct videobuf_queue *q = map->q; dprintk(2, "vm_open %p [count=%u,vma=%08lx-%08lx]\n", map, map->count, vma->vm_start, vma->vm_end); + videobuf_queue_lock(q); map->count++; + videobuf_queue_unlock(q); } static void videobuf_vm_close(struct vm_area_struct *vma) @@ -70,12 +73,11 @@ static void videobuf_vm_close(struct vm_area_struct *vma) dprintk(2, "vm_close %p [count=%u,vma=%08lx-%08lx]\n", map, map->count, vma->vm_start, vma->vm_end); - map->count--; - if (0 == map->count) { + videobuf_queue_lock(q); + if (!--map->count) { struct videobuf_vmalloc_memory *mem; dprintk(1, "munmap %p q=%p\n", map, q); - videobuf_queue_lock(q); /* We need first to cancel streams, before unmapping */ if (q->streaming) @@ -114,8 +116,8 @@ static void videobuf_vm_close(struct vm_area_struct *vma) kfree(map); - videobuf_queue_unlock(q); } + videobuf_queue_unlock(q); return; } From 4c8d558a1403cedd465395d719d13778b0f689f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roberto=20Alc=C3=A2ntara?= Date: Sat, 11 May 2013 11:53:29 -0300 Subject: [PATCH 0037/1048] [media] smscoreapi: Make Siano firmware load more verbose If firmware load fails, report it as an error. Signed-off-by: Roberto Alcantara Signed-off-by: Mauro Carvalho Chehab --- drivers/media/common/siano/smscoreapi.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/media/common/siano/smscoreapi.c b/drivers/media/common/siano/smscoreapi.c index 45ac9eea4882..dbe9b4d9b799 100644 --- a/drivers/media/common/siano/smscoreapi.c +++ b/drivers/media/common/siano/smscoreapi.c @@ -1154,7 +1154,7 @@ static int smscore_load_firmware_from_file(struct smscore_device_t *coredev, char *fw_filename = smscore_get_fw_filename(coredev, mode); if (!fw_filename) { - sms_info("mode %d not supported on this device", mode); + sms_err("mode %d not supported on this device", mode); return -ENOENT; } sms_debug("Firmware name: %s", fw_filename); @@ -1165,14 +1165,14 @@ static int smscore_load_firmware_from_file(struct smscore_device_t *coredev, rc = request_firmware(&fw, fw_filename, coredev->device); if (rc < 0) { - sms_info("failed to open \"%s\"", fw_filename); + sms_err("failed to open firmware file \"%s\"", fw_filename); return rc; } sms_info("read fw %s, buffer size=0x%zx", fw_filename, fw->size); fw_buf = kmalloc(ALIGN(fw->size, SMS_ALLOC_ALIGNMENT), GFP_KERNEL | GFP_DMA); if (!fw_buf) { - sms_info("failed to allocate firmware buffer"); + sms_err("failed to allocate firmware buffer"); return -ENOMEM; } memcpy(fw_buf, fw->data, fw->size); From 2a848b2c7fcc8f5cb370a73ec9ca40d32c6cf18c Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Wed, 17 Apr 2013 08:22:16 -0300 Subject: [PATCH 0038/1048] [media] videobuf-dma-contig: use vm_iomap_memory() vm_iomap_memory() provides a better end user interface than remap_pfn_range(), as it does the needed tests before doing mmap. Signed-off-by: Mauro Carvalho Chehab --- drivers/media/v4l2-core/videobuf-dma-contig.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/drivers/media/v4l2-core/videobuf-dma-contig.c b/drivers/media/v4l2-core/videobuf-dma-contig.c index 8204c8810372..65411adcd0ea 100644 --- a/drivers/media/v4l2-core/videobuf-dma-contig.c +++ b/drivers/media/v4l2-core/videobuf-dma-contig.c @@ -305,14 +305,9 @@ static int __videobuf_mmap_mapper(struct videobuf_queue *q, goto error; /* Try to remap memory */ - size = vma->vm_end - vma->vm_start; - size = (size < mem->size) ? size : mem->size; - vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); - retval = remap_pfn_range(vma, vma->vm_start, - mem->dma_handle >> PAGE_SHIFT, - size, vma->vm_page_prot); + retval = vm_iomap_memory(vma, vma->vm_start, size); if (retval) { dev_err(q->dev, "mmap: remap failed with error %d. ", retval); From 6a084d6b3dc200b855ae8a3c6771abe285a3835d Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Tue, 21 May 2013 11:36:30 -0300 Subject: [PATCH 0039/1048] [media] saa7115: Don't use a dynamic array At least on s390, gcc complains about that: drivers/media/i2c/saa7115.c: In function 'saa711x_detect_chip.constprop.2': drivers/media/i2c/saa7115.c:1647:1: warning: 'saa711x_detect_chip.constprop.2' uses dynamic stack allocation [enabled by default] While for me the above report seems utterly bogus, as the compiler should be optimizing saa711x_detect_chip, merging it with saa711x_detect_chip and changing: char chip_ver[size - 1]; to char chip_ver[16]; because this function is only called on this code snippet: char name[17]; ... ident = saa711x_detect_chip(client, id, name, sizeof(name)); It seems that gcc is not optimizing it, at least on s390. As getting rid of it is easy, let's do it. Reported-by: kbuild test robot Acked-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/i2c/saa7115.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/drivers/media/i2c/saa7115.c b/drivers/media/i2c/saa7115.c index be32688797e1..8316ae448f4c 100644 --- a/drivers/media/i2c/saa7115.c +++ b/drivers/media/i2c/saa7115.c @@ -1602,6 +1602,8 @@ static const struct v4l2_subdev_ops saa711x_ops = { .vbi = &saa711x_vbi_ops, }; +#define CHIP_VER_SIZE 16 + /* ----------------------------------------------------------------------- */ /** @@ -1609,7 +1611,6 @@ static const struct v4l2_subdev_ops saa711x_ops = { * @client: I2C client structure. * @id: I2C device ID structure. * @name: Name of the device to be filled. - * @size: Size of the name var. * * Detects the Philips/NXP saa711x chip, or some clone of it. * if 'id' is NULL or id->driver_data is equal to 1, it auto-probes @@ -1621,9 +1622,9 @@ static const struct v4l2_subdev_ops saa711x_ops = { */ static int saa711x_detect_chip(struct i2c_client *client, const struct i2c_device_id *id, - char *name, unsigned size) + char *name) { - char chip_ver[size - 1]; + char chip_ver[CHIP_VER_SIZE]; char chip_id; int i; int autodetect; @@ -1631,7 +1632,7 @@ static int saa711x_detect_chip(struct i2c_client *client, autodetect = !id || id->driver_data == 1; /* Read the chip version register */ - for (i = 0; i < size - 1; i++) { + for (i = 0; i < CHIP_VER_SIZE; i++) { i2c_smbus_write_byte_data(client, 0, i); chip_ver[i] = i2c_smbus_read_byte_data(client, 0); name[i] = (chip_ver[i] & 0x0f) + '0'; @@ -1643,7 +1644,7 @@ static int saa711x_detect_chip(struct i2c_client *client, /* Check if it is a Philips/NXP chip */ if (!memcmp(name + 1, "f711", 4)) { chip_id = name[5]; - snprintf(name, size, "saa711%c", chip_id); + snprintf(name, CHIP_VER_SIZE, "saa711%c", chip_id); if (!autodetect && strcmp(name, id->name)) return -EINVAL; @@ -1651,7 +1652,7 @@ static int saa711x_detect_chip(struct i2c_client *client, switch (chip_id) { case '1': if (chip_ver[0] & 0xf0) { - snprintf(name, size, "saa711%ca", chip_id); + snprintf(name, CHIP_VER_SIZE, "saa711%ca", chip_id); v4l_info(client, "saa7111a variant found\n"); return V4L2_IDENT_SAA7111A; } @@ -1689,7 +1690,7 @@ static int saa711x_detect_chip(struct i2c_client *client, * the lower nibble is a gm7113c. */ - strlcpy(name, "gm7113c", size); + strlcpy(name, "gm7113c", CHIP_VER_SIZE); if (!autodetect && strcmp(name, id->name)) return -EINVAL; @@ -1714,13 +1715,13 @@ static int saa711x_probe(struct i2c_client *client, struct v4l2_subdev *sd; struct v4l2_ctrl_handler *hdl; int ident; - char name[17]; + char name[CHIP_VER_SIZE + 1]; /* Check if the adapter supports the needed features */ if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) return -EIO; - ident = saa711x_detect_chip(client, id, name, sizeof(name)); + ident = saa711x_detect_chip(client, id, name); if (ident == -EINVAL) { /* Chip exists, but doesn't match */ v4l_warn(client, "found %s while %s was expected\n", From 250a51caa65cc7637f3596300d3591a2c924b32e Mon Sep 17 00:00:00 2001 From: Jakob Normark Date: Sun, 19 May 2013 09:30:23 -0300 Subject: [PATCH 0040/1048] [media] Missing break statement added in smsdvb-main.c Fix missing break that so that n_layers are not accidentally incorrect Kernel version: v3.10-rc1 Signed-off-by: Jakob Normark Signed-off-by: Mauro Carvalho Chehab --- drivers/media/common/siano/smsdvb-main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/media/common/siano/smsdvb-main.c b/drivers/media/common/siano/smsdvb-main.c index 297f1b2f9a32..086262252230 100644 --- a/drivers/media/common/siano/smsdvb-main.c +++ b/drivers/media/common/siano/smsdvb-main.c @@ -140,6 +140,7 @@ static void smsdvb_stats_not_ready(struct dvb_frontend *fe) case DEVICE_MODE_ISDBT: case DEVICE_MODE_ISDBT_BDA: n_layers = 4; + break; default: n_layers = 1; } From 99119595d9ff06f74d97d3623fd8a63138f9b287 Mon Sep 17 00:00:00 2001 From: Randy Dunlap Date: Mon, 20 May 2013 12:32:39 -0300 Subject: [PATCH 0041/1048] [media] media: fix hdpvr kconfig/build errors Fix hdpvr build errors when CONFIG_I2C=m and VIDEO_V4L2=m and VIDEO_HDPVR=y. drivers/built-in.o: In function `hdpvr_disconnect': hdpvr-core.c:(.text+0xef542): undefined reference to `v4l2_device_disconnect' hdpvr-core.c:(.text+0xef57e): undefined reference to `i2c_del_adapter' hdpvr-core.c:(.text+0xef58a): undefined reference to `video_unregister_device' drivers/built-in.o: In function `hdpvr_delete': (.text+0xef5b9): undefined reference to `video_device_release' drivers/built-in.o: In function `hdpvr_probe': hdpvr-core.c:(.text+0xef63a): undefined reference to `v4l2_device_register' hdpvr-core.c:(.text+0xefd97): undefined reference to `i2c_del_adapter' drivers/built-in.o: In function `hdpvr_s_ctrl': hdpvr-video.c:(.text+0xf03c0): undefined reference to `v4l2_ctrl_activate' drivers/built-in.o: In function `hdpvr_device_release': hdpvr-video.c:(.text+0xf0470): undefined reference to `v4l2_device_unregister' hdpvr-video.c:(.text+0xf0479): undefined reference to `v4l2_ctrl_handler_free' hdpvr-video.c:(.text+0xf048f): undefined reference to `i2c_del_adapter' drivers/built-in.o: In function `hdpvr_open': hdpvr-video.c:(.text+0xf0570): undefined reference to `video_devdata' hdpvr-video.c:(.text+0xf057b): undefined reference to `v4l2_fh_init' hdpvr-video.c:(.text+0xf0583): undefined reference to `v4l2_fh_add' drivers/built-in.o: In function `video_drvdata': hdpvr-video.c:(.text+0xf08a0): undefined reference to `video_devdata' drivers/built-in.o: In function `vidioc_s_dv_timings': hdpvr-video.c:(.text+0xf0d34): undefined reference to `v4l_match_dv_timings' drivers/built-in.o: In function `hdpvr_poll': hdpvr-video.c:(.text+0xf1455): undefined reference to `v4l2_ctrl_poll' drivers/built-in.o: In function `hdpvr_release': hdpvr-video.c:(.text+0xf18f6): undefined reference to `v4l2_fh_release' drivers/built-in.o: In function `hdpvr_register_videodev': (.text+0xf1be3): undefined reference to `v4l2_ctrl_handler_init_class' drivers/built-in.o: In function `hdpvr_register_videodev': (.text+0xf1c19): undefined reference to `v4l2_ctrl_new_std' drivers/built-in.o: In function `hdpvr_register_videodev': (.text+0xf1c42): undefined reference to `v4l2_ctrl_new_std' drivers/built-in.o: In function `hdpvr_register_videodev': (.text+0xf1c6b): undefined reference to `v4l2_ctrl_new_std' drivers/built-in.o: In function `hdpvr_register_videodev': (.text+0xf1cac): undefined reference to `v4l2_ctrl_new_std' drivers/built-in.o: In function `hdpvr_register_videodev': (.text+0xf1cd5): undefined reference to `v4l2_ctrl_new_std' drivers/built-in.o:(.text+0xf1cfe): more undefined references to `v4l2_ctrl_new_std' follow drivers/built-in.o: In function `hdpvr_register_videodev': (.text+0xf1d75): undefined reference to `v4l2_ctrl_new_std_menu' drivers/built-in.o: In function `hdpvr_register_videodev': (.text+0xf1d9e): undefined reference to `v4l2_ctrl_new_std_menu' drivers/built-in.o: In function `hdpvr_register_videodev': (.text+0xf1dc3): undefined reference to `v4l2_ctrl_new_std_menu' drivers/built-in.o: In function `hdpvr_register_videodev': (.text+0xf1de5): undefined reference to `v4l2_ctrl_new_std_menu' drivers/built-in.o: In function `hdpvr_register_videodev': (.text+0xf1e18): undefined reference to `v4l2_ctrl_new_std' drivers/built-in.o: In function `hdpvr_register_videodev': (.text+0xf1e4b): undefined reference to `v4l2_ctrl_new_std' drivers/built-in.o: In function `hdpvr_register_videodev': (.text+0xf1e90): undefined reference to `v4l2_ctrl_cluster' drivers/built-in.o: In function `hdpvr_register_videodev': (.text+0xf1e98): undefined reference to `v4l2_ctrl_handler_setup' drivers/built-in.o: In function `hdpvr_register_videodev': (.text+0xf1ec1): undefined reference to `video_device_alloc' drivers/built-in.o: In function `hdpvr_register_videodev': (.text+0xf1f85): undefined reference to `__video_register_device' drivers/built-in.o: In function `hdpvr_register_videodev': (.text+0xf1fac): undefined reference to `v4l2_ctrl_handler_free' drivers/built-in.o: In function `hdpvr_register_ir_tx_i2c': (.text+0xf238f): undefined reference to `i2c_new_device' drivers/built-in.o: In function `hdpvr_register_ir_rx_i2c': (.text+0xf2434): undefined reference to `i2c_new_device' drivers/built-in.o: In function `hdpvr_register_i2c_adapter': (.text+0xf2514): undefined reference to `i2c_add_adapter' drivers/built-in.o:(.rodata+0x1b368): undefined reference to `video_ioctl2' drivers/built-in.o:(.rodata+0x1b690): undefined reference to `v4l2_ctrl_log_status' drivers/built-in.o:(.rodata+0x1b6f8): undefined reference to `v4l2_ctrl_subscribe_event' drivers/built-in.o:(.rodata+0x1b700): undefined reference to `v4l2_event_unsubscribe' Signed-off-by: Randy Dunlap Signed-off-by: Mauro Carvalho Chehab --- drivers/media/usb/hdpvr/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/usb/hdpvr/Kconfig b/drivers/media/usb/hdpvr/Kconfig index de247f3c7d05..d73d9a1952b4 100644 --- a/drivers/media/usb/hdpvr/Kconfig +++ b/drivers/media/usb/hdpvr/Kconfig @@ -1,7 +1,7 @@ config VIDEO_HDPVR tristate "Hauppauge HD PVR support" - depends on VIDEO_DEV + depends on VIDEO_DEV && VIDEO_V4L2 ---help--- This is a video4linux driver for Hauppauge's HD PVR USB device. From 5dd6946c419a3a553842115665e142d1245fb837 Mon Sep 17 00:00:00 2001 From: Wei Yongjun Date: Mon, 13 May 2013 01:48:45 -0300 Subject: [PATCH 0042/1048] [media] v4l: vb2: fix error return code in __vb2_init_fileio() Fix to return -EINVAL in the get kernel address error handling case instead of 0, as done elsewhere in this function. Signed-off-by: Wei Yongjun Reviewed-by: Sakari Ailus Acked-by: Marek Szyprowski Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/v4l2-core/videobuf2-core.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/media/v4l2-core/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c index 7d833eefaf4e..7bd3ee67727d 100644 --- a/drivers/media/v4l2-core/videobuf2-core.c +++ b/drivers/media/v4l2-core/videobuf2-core.c @@ -2193,8 +2193,10 @@ static int __vb2_init_fileio(struct vb2_queue *q, int read) */ for (i = 0; i < q->num_buffers; i++) { fileio->bufs[i].vaddr = vb2_plane_vaddr(q->bufs[i], 0); - if (fileio->bufs[i].vaddr == NULL) + if (fileio->bufs[i].vaddr == NULL) { + ret = -EINVAL; goto err_reqbufs; + } fileio->bufs[i].size = vb2_plane_size(q->bufs[i], 0); } From b2d2cf1015004209d6493f21b99788ded42eac11 Mon Sep 17 00:00:00 2001 From: Wei Yongjun Date: Mon, 13 May 2013 01:57:23 -0300 Subject: [PATCH 0043/1048] [media] vpif_display: fix error return code in vpif_probe() Fix to return -ENODEV in the subdevice register error handling case instead of 0, as done elsewhere in this function. Signed-off-by: Wei Yongjun Acked-by: Lad, Prabhakar Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/davinci/vpif_display.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/media/platform/davinci/vpif_display.c b/drivers/media/platform/davinci/vpif_display.c index 7b1736842690..5b6f9065b881 100644 --- a/drivers/media/platform/davinci/vpif_display.c +++ b/drivers/media/platform/davinci/vpif_display.c @@ -1797,6 +1797,7 @@ static __init int vpif_probe(struct platform_device *pdev) NULL); if (!vpif_obj.sd[i]) { vpif_err("Error registering v4l2 subdevice\n"); + err = -ENODEV; goto probe_subdev_out; } From 4fa94e224b84be7b2522a0f5ce5b64124f146fac Mon Sep 17 00:00:00 2001 From: Wei Yongjun Date: Mon, 13 May 2013 01:57:37 -0300 Subject: [PATCH 0044/1048] [media] vpif_capture: fix error return code in vpif_probe() Fix to return -ENODEV in the subdevice register error handling case instead of 0, as done elsewhere in this function. Signed-off-by: Wei Yongjun Acked-by: Lad, Prabhakar Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/davinci/vpif_capture.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/media/platform/davinci/vpif_capture.c b/drivers/media/platform/davinci/vpif_capture.c index a1b42b037678..caaf4fedadec 100644 --- a/drivers/media/platform/davinci/vpif_capture.c +++ b/drivers/media/platform/davinci/vpif_capture.c @@ -2159,6 +2159,7 @@ static __init int vpif_probe(struct platform_device *pdev) if (!vpif_obj.sd[i]) { vpif_err("Error registering v4l2 subdevice\n"); + err = -ENODEV; goto probe_subdev_out; } v4l2_info(&vpif_obj.v4l2_dev, "registered sub device %s\n", From 6ec735df78c63c3623c76e75a975390f60ae0640 Mon Sep 17 00:00:00 2001 From: Wei Yongjun Date: Mon, 13 May 2013 02:00:10 -0300 Subject: [PATCH 0045/1048] [media] ad9389b: fix error return code in ad9389b_probe() Fix to return a negative error code from the error handling case instead of 0, as done elsewhere in this function. Signed-off-by: Wei Yongjun Acked-by: Hans Verkuil Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/i2c/ad9389b.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/media/i2c/ad9389b.c b/drivers/media/i2c/ad9389b.c index 15043554cc8b..1d4e4e70e8f8 100644 --- a/drivers/media/i2c/ad9389b.c +++ b/drivers/media/i2c/ad9389b.c @@ -1250,12 +1250,14 @@ static int ad9389b_probe(struct i2c_client *client, const struct i2c_device_id * state->edid_i2c_client = i2c_new_dummy(client->adapter, (0x7e>>1)); if (state->edid_i2c_client == NULL) { v4l2_err(sd, "failed to register edid i2c client\n"); + err = -ENOMEM; goto err_entity; } state->work_queue = create_singlethread_workqueue(sd->name); if (state->work_queue == NULL) { v4l2_err(sd, "could not create workqueue\n"); + err = -ENOMEM; goto err_unreg; } From d9fdbeff26b87e68d0e7f0d506e3cfc0f2a28d56 Mon Sep 17 00:00:00 2001 From: Wei Yongjun Date: Mon, 13 May 2013 04:52:16 -0300 Subject: [PATCH 0046/1048] [media] blackfin: fix error return code in bcap_probe() Fix to return a negative error code from the error handling case instead of 0, as done elsewhere in this function. Signed-off-by: Wei Yongjun Acked-by: Scott Jiang Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/blackfin/bfin_capture.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/media/platform/blackfin/bfin_capture.c b/drivers/media/platform/blackfin/bfin_capture.c index 03530bc6bdd1..ca8d56aecfb0 100644 --- a/drivers/media/platform/blackfin/bfin_capture.c +++ b/drivers/media/platform/blackfin/bfin_capture.c @@ -974,7 +974,7 @@ static int bcap_probe(struct platform_device *pdev) int ret; config = pdev->dev.platform_data; - if (!config) { + if (!config || !config->num_inputs) { v4l2_err(pdev->dev.driver, "Unable to get board config\n"); return -ENODEV; } @@ -1081,11 +1081,6 @@ static int bcap_probe(struct platform_device *pdev) NULL); if (bcap_dev->sd) { int i; - if (!config->num_inputs) { - v4l2_err(&bcap_dev->v4l2_dev, - "Unable to work without input\n"); - goto err_unreg_vdev; - } /* update tvnorms from the sub devices */ for (i = 0; i < config->num_inputs; i++) @@ -1093,6 +1088,7 @@ static int bcap_probe(struct platform_device *pdev) } else { v4l2_err(&bcap_dev->v4l2_dev, "Unable to register sub device\n"); + ret = -ENODEV; goto err_unreg_vdev; } From d017650b40b4cb5c4158e3b9af38af164986b022 Mon Sep 17 00:00:00 2001 From: Wei Yongjun Date: Mon, 13 May 2013 10:00:01 -0300 Subject: [PATCH 0047/1048] [media] sta2x11_vip: fix error return code in sta2x11_vip_init_one() The orig code will release all the resources if v4l2_device_register() failed and return 0. But what we need in this case is to return an negative error code to let the caller known we are failed. So the patch save the return value of v4l2_device_register() to 'ret' and return it when error. Signed-off-by: Wei Yongjun Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/pci/sta2x11/sta2x11_vip.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/media/pci/sta2x11/sta2x11_vip.c b/drivers/media/pci/sta2x11/sta2x11_vip.c index 7005695aa4bd..77edc113e485 100644 --- a/drivers/media/pci/sta2x11/sta2x11_vip.c +++ b/drivers/media/pci/sta2x11/sta2x11_vip.c @@ -1047,7 +1047,8 @@ static int sta2x11_vip_init_one(struct pci_dev *pdev, ret = sta2x11_vip_init_controls(vip); if (ret) goto free_mem; - if (v4l2_device_register(&pdev->dev, &vip->v4l2_dev)) + ret = v4l2_device_register(&pdev->dev, &vip->v4l2_dev); + if (ret) goto free_mem; dev_dbg(&pdev->dev, "BAR #0 at 0x%lx 0x%lx irq %d\n", From 5c75a55e3c2820f2fd7e256e577c1b528567f3ae Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Wed, 15 May 2013 17:56:11 -0300 Subject: [PATCH 0048/1048] [media] sony-btf-mpx: Drop needless newline in param description Module parameter descriptions need not be terminated with a newline. Signed-off-by: Jean Delvare Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/i2c/sony-btf-mpx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/i2c/sony-btf-mpx.c b/drivers/media/i2c/sony-btf-mpx.c index efa306165618..32d82320b485 100644 --- a/drivers/media/i2c/sony-btf-mpx.c +++ b/drivers/media/i2c/sony-btf-mpx.c @@ -30,7 +30,7 @@ MODULE_LICENSE("GPL v2"); static int debug; module_param(debug, int, 0644); -MODULE_PARM_DESC(debug, "debug level 0=off(default) 1=on\n"); +MODULE_PARM_DESC(debug, "debug level 0=off(default) 1=on"); /* #define MPX_DEBUG */ From ff29feb9146d1c0020f2ccbb25369582c6a16681 Mon Sep 17 00:00:00 2001 From: "Lad, Prabhakar" Date: Mon, 20 May 2013 06:02:40 -0300 Subject: [PATCH 0049/1048] [media] videodev2.h: fix typos This patch fixes several typos in videodev2.h file Signed-off-by: Lad, Prabhakar Acked-by: Laurent Pinchart Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- include/uapi/linux/videodev2.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h index 16c3cf71eb94..2c5e67a45436 100644 --- a/include/uapi/linux/videodev2.h +++ b/include/uapi/linux/videodev2.h @@ -555,7 +555,7 @@ struct v4l2_jpegcompression { __u32 jpeg_markers; /* Which markers should go into the JPEG * output. Unless you exactly know what * you do, leave them untouched. - * Inluding less markers will make the + * Including less markers will make the * resulting code smaller, but there will * be fewer applications which can read it. * The presence of the APP and COM marker @@ -567,7 +567,7 @@ struct v4l2_jpegcompression { #define V4L2_JPEG_MARKER_DRI (1<<5) /* Define Restart Interval */ #define V4L2_JPEG_MARKER_COM (1<<6) /* Comment segment */ #define V4L2_JPEG_MARKER_APP (1<<7) /* App segment, driver will - * allways use APP0 */ + * always use APP0 */ }; /* @@ -900,7 +900,7 @@ typedef __u64 v4l2_std_id; /* * "Common" PAL - This macro is there to be compatible with the old * V4L1 concept of "PAL": /BGDKHI. - * Several PAL standards are mising here: /M, /N and /Nc + * Several PAL standards are missing here: /M, /N and /Nc */ #define V4L2_STD_PAL (V4L2_STD_PAL_BG |\ V4L2_STD_PAL_DK |\ @@ -1790,7 +1790,7 @@ struct v4l2_event_subscription { #define V4L2_CHIP_MATCH_HOST V4L2_CHIP_MATCH_BRIDGE #define V4L2_CHIP_MATCH_I2C_DRIVER 1 /* Match against I2C driver name */ #define V4L2_CHIP_MATCH_I2C_ADDR 2 /* Match against I2C 7-bit address */ -#define V4L2_CHIP_MATCH_AC97 3 /* Match against anciliary AC97 chip */ +#define V4L2_CHIP_MATCH_AC97 3 /* Match against ancillary AC97 chip */ #define V4L2_CHIP_MATCH_SUBDEV 4 /* Match against subdev index */ struct v4l2_dbg_match { From 4d601c4ca272959ba837b8279f4873b55caaf619 Mon Sep 17 00:00:00 2001 From: Leonid Kegulskiy Date: Mon, 13 May 2013 07:10:42 -0300 Subject: [PATCH 0050/1048] [media] hdpvr: Removed unnecessary use of kzalloc() in get_video_info() [mchehab@redhat.com: CodingStyle fixes] Signed-off-by: Leonid Kegulskiy Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/usb/hdpvr/hdpvr-control.c | 25 +++++------- drivers/media/usb/hdpvr/hdpvr-video.c | 54 ++++++++++++------------- drivers/media/usb/hdpvr/hdpvr.h | 2 +- 3 files changed, 37 insertions(+), 44 deletions(-) diff --git a/drivers/media/usb/hdpvr/hdpvr-control.c b/drivers/media/usb/hdpvr/hdpvr-control.c index ae8f229d1141..df6bcb524d80 100644 --- a/drivers/media/usb/hdpvr/hdpvr-control.c +++ b/drivers/media/usb/hdpvr/hdpvr-control.c @@ -45,20 +45,10 @@ int hdpvr_config_call(struct hdpvr_device *dev, uint value, u8 valbuf) return ret < 0 ? ret : 0; } -struct hdpvr_video_info *get_video_info(struct hdpvr_device *dev) +int get_video_info(struct hdpvr_device *dev, struct hdpvr_video_info *vidinf) { - struct hdpvr_video_info *vidinf = NULL; -#ifdef HDPVR_DEBUG - char print_buf[15]; -#endif int ret; - vidinf = kzalloc(sizeof(struct hdpvr_video_info), GFP_KERNEL); - if (!vidinf) { - v4l2_err(&dev->v4l2_dev, "out of memory\n"); - goto err; - } - mutex_lock(&dev->usbc_mutex); ret = usb_control_msg(dev->udev, usb_rcvctrlpipe(dev->udev, 0), @@ -74,6 +64,7 @@ struct hdpvr_video_info *get_video_info(struct hdpvr_device *dev) #ifdef HDPVR_DEBUG if (hdpvr_debug & MSG_INFO) { + char print_buf[15]; hex_dump_to_buffer(dev->usbc_buf, 5, 16, 1, print_buf, sizeof(print_buf), 0); v4l2_dbg(MSG_INFO, hdpvr_debug, &dev->v4l2_dev, @@ -82,12 +73,14 @@ struct hdpvr_video_info *get_video_info(struct hdpvr_device *dev) #endif mutex_unlock(&dev->usbc_mutex); - if (!vidinf->width || !vidinf->height || !vidinf->fps) { - kfree(vidinf); - vidinf = NULL; + if ((ret > 0 && ret != 5) ||/* fail if unexpected byte count returned */ + !vidinf->width || /* preserve original behavior - */ + !vidinf->height || /* fail if no signal is detected */ + !vidinf->fps) { + ret = -EFAULT; } -err: - return vidinf; + + return ret < 0 ? ret : 0; } int get_input_lines_info(struct hdpvr_device *dev) diff --git a/drivers/media/usb/hdpvr/hdpvr-video.c b/drivers/media/usb/hdpvr/hdpvr-video.c index cd90ba81a5bb..2d02b490756b 100644 --- a/drivers/media/usb/hdpvr/hdpvr-video.c +++ b/drivers/media/usb/hdpvr/hdpvr-video.c @@ -277,20 +277,19 @@ error: static int hdpvr_start_streaming(struct hdpvr_device *dev) { int ret; - struct hdpvr_video_info *vidinf; + struct hdpvr_video_info vidinf; if (dev->status == STATUS_STREAMING) return 0; else if (dev->status != STATUS_IDLE) return -EAGAIN; - vidinf = get_video_info(dev); + ret = get_video_info(dev, &vidinf); - if (vidinf) { + if (!ret) { v4l2_dbg(MSG_BUFFER, hdpvr_debug, &dev->v4l2_dev, - "video signal: %dx%d@%dhz\n", vidinf->width, - vidinf->height, vidinf->fps); - kfree(vidinf); + "video signal: %dx%d@%dhz\n", vidinf.width, + vidinf.height, vidinf.fps); /* start streaming 2 request */ ret = usb_control_msg(dev->udev, @@ -610,21 +609,22 @@ static int vidioc_g_std(struct file *file, void *_fh, static int vidioc_querystd(struct file *file, void *_fh, v4l2_std_id *a) { struct hdpvr_device *dev = video_drvdata(file); - struct hdpvr_video_info *vid_info; + struct hdpvr_video_info vid_info; struct hdpvr_fh *fh = _fh; + int ret; *a = V4L2_STD_ALL; if (dev->options.video_input == HDPVR_COMPONENT) return fh->legacy_mode ? 0 : -ENODATA; - vid_info = get_video_info(dev); - if (vid_info == NULL) + ret = get_video_info(dev, &vid_info); + if (ret) return 0; - if (vid_info->width == 720 && - (vid_info->height == 480 || vid_info->height == 576)) { - *a = (vid_info->height == 480) ? + if (vid_info.width == 720 && + (vid_info.height == 480 || vid_info.height == 576)) { + *a = (vid_info.height == 480) ? V4L2_STD_525_60 : V4L2_STD_625_50; } - kfree(vid_info); + return 0; } @@ -669,7 +669,7 @@ static int vidioc_query_dv_timings(struct file *file, void *_fh, { struct hdpvr_device *dev = video_drvdata(file); struct hdpvr_fh *fh = _fh; - struct hdpvr_video_info *vid_info; + struct hdpvr_video_info vid_info; bool interlaced; int ret = 0; int i; @@ -677,10 +677,10 @@ static int vidioc_query_dv_timings(struct file *file, void *_fh, fh->legacy_mode = false; if (dev->options.video_input) return -ENODATA; - vid_info = get_video_info(dev); - if (vid_info == NULL) + ret = get_video_info(dev, &vid_info); + if (ret) return -ENOLCK; - interlaced = vid_info->fps <= 30; + interlaced = vid_info.fps <= 30; for (i = 0; i < ARRAY_SIZE(hdpvr_dv_timings); i++) { const struct v4l2_bt_timings *bt = &hdpvr_dv_timings[i].bt; unsigned hsize; @@ -692,17 +692,17 @@ static int vidioc_query_dv_timings(struct file *file, void *_fh, bt->il_vfrontporch + bt->il_vsync + bt->il_vbackporch + bt->height; fps = (unsigned)bt->pixelclock / (hsize * vsize); - if (bt->width != vid_info->width || - bt->height != vid_info->height || + if (bt->width != vid_info.width || + bt->height != vid_info.height || bt->interlaced != interlaced || - (fps != vid_info->fps && fps + 1 != vid_info->fps)) + (fps != vid_info.fps && fps + 1 != vid_info.fps)) continue; *timings = hdpvr_dv_timings[i]; break; } if (i == ARRAY_SIZE(hdpvr_dv_timings)) ret = -ERANGE; - kfree(vid_info); + return ret; } @@ -992,6 +992,7 @@ static int vidioc_g_fmt_vid_cap(struct file *file, void *_fh, { struct hdpvr_device *dev = video_drvdata(file); struct hdpvr_fh *fh = _fh; + int ret; /* * The original driver would always returns the current detected @@ -1004,14 +1005,13 @@ static int vidioc_g_fmt_vid_cap(struct file *file, void *_fh, * last set format. */ if (fh->legacy_mode) { - struct hdpvr_video_info *vid_info; + struct hdpvr_video_info vid_info; - vid_info = get_video_info(dev); - if (!vid_info) + ret = get_video_info(dev, &vid_info); + if (ret) return -EFAULT; - f->fmt.pix.width = vid_info->width; - f->fmt.pix.height = vid_info->height; - kfree(vid_info); + f->fmt.pix.width = vid_info.width; + f->fmt.pix.height = vid_info.height; } else { f->fmt.pix.width = dev->width; f->fmt.pix.height = dev->height; diff --git a/drivers/media/usb/hdpvr/hdpvr.h b/drivers/media/usb/hdpvr/hdpvr.h index 1478f3d57630..808ea7a0efe5 100644 --- a/drivers/media/usb/hdpvr/hdpvr.h +++ b/drivers/media/usb/hdpvr/hdpvr.h @@ -303,7 +303,7 @@ int hdpvr_set_audio(struct hdpvr_device *dev, u8 input, int hdpvr_config_call(struct hdpvr_device *dev, uint value, unsigned char valbuf); -struct hdpvr_video_info *get_video_info(struct hdpvr_device *dev); +int get_video_info(struct hdpvr_device *dev, struct hdpvr_video_info *vid_info); /* :0 s b8 81 1800 0003 0003 3 < */ /* :0 0 3 = 0301ff */ From 94204cd4e1452e13ecf5fc6fcec9485e93e8a8f4 Mon Sep 17 00:00:00 2001 From: Fabio Baltieri Date: Thu, 21 Mar 2013 13:31:53 +0100 Subject: [PATCH 0051/1048] ARM: ux500: select WATCHDOG and MUSB for ux500 Enable ux500 specific USB and watchdog drivers by default on u8500_defconfig. Signed-off-by: Fabio Baltieri Signed-off-by: Linus Walleij --- arch/arm/configs/u8500_defconfig | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/arch/arm/configs/u8500_defconfig b/arch/arm/configs/u8500_defconfig index c037aa1065b7..acb62cf36c70 100644 --- a/arch/arm/configs/u8500_defconfig +++ b/arch/arm/configs/u8500_defconfig @@ -70,6 +70,7 @@ CONFIG_GPIO_TC3589X=y # CONFIG_AB8500_BATTERY_THERM_ON_BATCTRL is not set CONFIG_THERMAL=y CONFIG_CPU_THERMAL=y +CONFIG_WATCHDOG=y CONFIG_MFD_STMPE=y CONFIG_MFD_TC3589X=y CONFIG_AB5500_CORE=y @@ -79,7 +80,13 @@ CONFIG_REGULATOR_AB8500=y CONFIG_REGULATOR_FIXED_VOLTAGE=y CONFIG_REGULATOR_GPIO=y # CONFIG_HID_SUPPORT is not set +CONFIG_USB=y +CONFIG_USB_MUSB_HDRC=y +CONFIG_USB_MUSB_UX500=y +CONFIG_USB_PHY=y CONFIG_USB_GADGET=y +CONFIG_USB_GADGET_MUSB_HDRC=y +CONFIG_USB_ETH=m CONFIG_AB8500_USB=y CONFIG_MMC=y CONFIG_MMC_CLKGATE=y From b39ca96c63822a22a1d2f08a247fd49353913fcd Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Fri, 24 May 2013 08:51:25 +0200 Subject: [PATCH 0052/1048] ARM: ux500: update defconfig base Update the defconfig removing/adding selections due to Kconfig changes, and select some new hardware drivers that have been matured in the tree. For example: - CONFIG_NO_HZ and CONFIG_HIGH_RES_TIMERS come from the make oldconfig changes after the recent changes to how NOHZ is handled. - The U5500 config option is now gone as the machine is deleted. So is the AB5500 driver. - CPU_IDLE selected explicitly. - LP5521 Kconfig has been moved around. - AB8500 core is default-selected, as is the AB8500 USB transciever. - The battery and charging management drivers for the AB8500 are not selected again. - Select the crypto devices that have been shaped up to work properly. Cc: Lee Jones Signed-off-by: Linus Walleij --- arch/arm/configs/u8500_defconfig | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/arch/arm/configs/u8500_defconfig b/arch/arm/configs/u8500_defconfig index acb62cf36c70..da0614abafde 100644 --- a/arch/arm/configs/u8500_defconfig +++ b/arch/arm/configs/u8500_defconfig @@ -1,6 +1,7 @@ -CONFIG_EXPERIMENTAL=y # CONFIG_SWAP is not set CONFIG_SYSVIPC=y +CONFIG_NO_HZ=y +CONFIG_HIGH_RES_TIMERS=y CONFIG_BLK_DEV_INITRD=y CONFIG_KALLSYMS_ALL=y CONFIG_MODULES=y @@ -9,10 +10,7 @@ CONFIG_MODULE_UNLOAD=y CONFIG_ARCH_U8500=y CONFIG_MACH_HREFV60=y CONFIG_MACH_SNOWBALL=y -CONFIG_MACH_U5500=y CONFIG_MACH_UX500_DT=y -CONFIG_NO_HZ=y -CONFIG_HIGH_RES_TIMERS=y CONFIG_SMP=y CONFIG_NR_CPUS=2 CONFIG_PREEMPT=y @@ -20,6 +18,7 @@ CONFIG_AEABI=y CONFIG_CMDLINE="root=/dev/ram0 console=ttyAMA2,115200n8" CONFIG_CPU_FREQ=y CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND=y +CONFIG_CPU_IDLE=y CONFIG_VFP=y CONFIG_NEON=y CONFIG_PM_RUNTIME=y @@ -36,7 +35,6 @@ CONFIG_CAIF=y CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" CONFIG_BLK_DEV_RAM=y CONFIG_BLK_DEV_RAM_SIZE=65536 -CONFIG_AB8500_PWM=y CONFIG_SENSORS_BH1780=y CONFIG_NETDEVICES=y CONFIG_SMSC911X=y @@ -60,42 +58,33 @@ CONFIG_VT_HW_CONSOLE_BINDING=y CONFIG_SERIAL_AMBA_PL011=y CONFIG_SERIAL_AMBA_PL011_CONSOLE=y CONFIG_HW_RANDOM=y -CONFIG_HW_RANDOM_NOMADIK=y CONFIG_SPI=y CONFIG_SPI_PL022=y CONFIG_GPIO_STMPE=y CONFIG_GPIO_TC3589X=y -# CONFIG_POWER_SUPPLY is not set -# CONFIG_AB8500_BM is not set -# CONFIG_AB8500_BATTERY_THERM_ON_BATCTRL is not set CONFIG_THERMAL=y CONFIG_CPU_THERMAL=y CONFIG_WATCHDOG=y CONFIG_MFD_STMPE=y CONFIG_MFD_TC3589X=y -CONFIG_AB5500_CORE=y -CONFIG_AB8500_CORE=y -CONFIG_REGULATOR=y -CONFIG_REGULATOR_AB8500=y -CONFIG_REGULATOR_FIXED_VOLTAGE=y CONFIG_REGULATOR_GPIO=y -# CONFIG_HID_SUPPORT is not set +CONFIG_REGULATOR_AB8500=y CONFIG_USB=y CONFIG_USB_MUSB_HDRC=y CONFIG_USB_MUSB_UX500=y CONFIG_USB_PHY=y +CONFIG_AB8500_USB=y CONFIG_USB_GADGET=y CONFIG_USB_GADGET_MUSB_HDRC=y CONFIG_USB_ETH=m -CONFIG_AB8500_USB=y CONFIG_MMC=y CONFIG_MMC_CLKGATE=y CONFIG_MMC_ARMMMCI=y CONFIG_NEW_LEDS=y CONFIG_LEDS_CLASS=y CONFIG_LEDS_LM3530=y -CONFIG_LEDS_LP5521=y CONFIG_LEDS_GPIO=y +CONFIG_LEDS_LP5521=y CONFIG_LEDS_TRIGGERS=y CONFIG_LEDS_TRIGGER_HEARTBEAT=y CONFIG_RTC_CLASS=y @@ -115,7 +104,6 @@ CONFIG_EXT4_FS=y CONFIG_VFAT_FS=y CONFIG_TMPFS=y CONFIG_TMPFS_POSIX_ACL=y -CONFIG_CONFIGFS_FS=m # CONFIG_MISC_FILESYSTEMS is not set CONFIG_NFS_FS=y CONFIG_ROOT_NFS=y @@ -129,3 +117,7 @@ CONFIG_DEBUG_KERNEL=y CONFIG_DEBUG_INFO=y # CONFIG_FTRACE is not set CONFIG_DEBUG_USER=y +CONFIG_CRYPTO_DEV_UX500=y +CONFIG_CRYPTO_DEV_UX500_CRYP=y +CONFIG_CRYPTO_DEV_UX500_HASH=y +CONFIG_CRYPTO_DEV_UX500_DEBUG=y From d78b655050bbb917069839d5aa1a051f0d867566 Mon Sep 17 00:00:00 2001 From: Fabio Baltieri Date: Fri, 24 May 2013 15:28:13 +0200 Subject: [PATCH 0053/1048] ARM: ux500: select SND_SOC_UX500 for ux500 Enable ux500 specific ALSA SoC drivers by default on u8500_defconfig. Signed-off-by: Fabio Baltieri Signed-off-by: Linus Walleij --- arch/arm/configs/u8500_defconfig | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/arch/arm/configs/u8500_defconfig b/arch/arm/configs/u8500_defconfig index da0614abafde..da353e0755b0 100644 --- a/arch/arm/configs/u8500_defconfig +++ b/arch/arm/configs/u8500_defconfig @@ -69,6 +69,11 @@ CONFIG_MFD_STMPE=y CONFIG_MFD_TC3589X=y CONFIG_REGULATOR_GPIO=y CONFIG_REGULATOR_AB8500=y +CONFIG_SOUND=y +CONFIG_SND=y +CONFIG_SND_SOC=y +CONFIG_SND_SOC_UX500=y +CONFIG_SND_SOC_UX500_MACH_MOP500=y CONFIG_USB=y CONFIG_USB_MUSB_HDRC=y CONFIG_USB_MUSB_UX500=y From abc0fd734e1327a85306457a438a1a23cf7c7925 Mon Sep 17 00:00:00 2001 From: "Lad, Prabhakar" Date: Tue, 14 May 2013 06:45:30 -0300 Subject: [PATCH 0054/1048] [media] media: i2c: tvp7002: remove duplicate define this patch removes duplicate #define TVP7002_MODULE_NAME form the driver file, which was also defined in media/tvp7002.h Signed-off-by: Lad, Prabhakar Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/i2c/tvp7002.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/media/i2c/tvp7002.c b/drivers/media/i2c/tvp7002.c index 270e6997cc76..81b4eb40d7a6 100644 --- a/drivers/media/i2c/tvp7002.c +++ b/drivers/media/i2c/tvp7002.c @@ -41,9 +41,6 @@ MODULE_DESCRIPTION("TI TVP7002 Video and Graphics Digitizer driver"); MODULE_AUTHOR("Santiago Nunez-Corrales "); MODULE_LICENSE("GPL"); -/* Module Name */ -#define TVP7002_MODULE_NAME "tvp7002" - /* I2C retry attempts */ #define I2C_RETRY_COUNT (5) From 19ec93057439cffc3b89910cd356892fbe2172fa Mon Sep 17 00:00:00 2001 From: "Lad, Prabhakar" Date: Tue, 14 May 2013 06:45:31 -0300 Subject: [PATCH 0055/1048] [media] media: i2c: tvp7002: rearrange description of structure members This patch rearranges the description of field members of struct tvp7002_config. Also as the all the fields where accepting a value either 0/1, made the members as bool. Signed-off-by: Lad, Prabhakar Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- include/media/tvp7002.h | 44 +++++++++++++++++++---------------------- 1 file changed, 20 insertions(+), 24 deletions(-) diff --git a/include/media/tvp7002.h b/include/media/tvp7002.h index 7123048408d6..fadb6afe9ef0 100644 --- a/include/media/tvp7002.h +++ b/include/media/tvp7002.h @@ -28,31 +28,27 @@ #define TVP7002_MODULE_NAME "tvp7002" -/* Platform-dependent data - * - * clk_polarity: - * 0 -> data clocked out on rising edge of DATACLK signal - * 1 -> data clocked out on falling edge of DATACLK signal - * hs_polarity: - * 0 -> active low HSYNC output - * 1 -> active high HSYNC output - * sog_polarity: - * 0 -> normal operation - * 1 -> operation with polarity inverted - * vs_polarity: - * 0 -> active low VSYNC output - * 1 -> active high VSYNC output - * fid_polarity: - * 0 -> the field ID output is set to logic 1 for an odd - * field (field 1) and set to logic 0 for an even - * field (field 0). - * 1 -> operation with polarity inverted. +/** + * struct tvp7002_config - Platform dependent data + *@clk_polarity: Clock polarity + * 0 - Data clocked out on rising edge of DATACLK signal + * 1 - Data clocked out on falling edge of DATACLK signal + *@hs_polarity: HSYNC polarity + * 0 - Active low HSYNC output, 1 - Active high HSYNC output + *@vs_polarity: VSYNC Polarity + * 0 - Active low VSYNC output, 1 - Active high VSYNC output + *@fid_polarity: Active-high Field ID polarity. + * 0 - The field ID output is set to logic 1 for an odd field + * (field 1) and set to logic 0 for an even field (field 0). + * 1 - Operation with polarity inverted. + *@sog_polarity: Active high Sync on Green output polarity. + * 0 - Normal operation, 1 - Operation with polarity inverted */ struct tvp7002_config { - u8 clk_polarity; - u8 hs_polarity; - u8 vs_polarity; - u8 fid_polarity; - u8 sog_polarity; + bool clk_polarity; + bool hs_polarity; + bool vs_polarity; + bool fid_polarity; + bool sog_polarity; }; #endif From 6266a9d9b0e9824562c3c5604dd812d3befc72f1 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Fri, 10 May 2013 08:06:50 -0300 Subject: [PATCH 0056/1048] [media] bw-qcam: fix timestamp handling bw-qcam didn't set the timestamp and it didn't set q->timestamp_type. Tested-by: Borislav Petkov Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/parport/bw-qcam.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/media/parport/bw-qcam.c b/drivers/media/parport/bw-qcam.c index 06231b85e1a9..d12bd33f39cb 100644 --- a/drivers/media/parport/bw-qcam.c +++ b/drivers/media/parport/bw-qcam.c @@ -687,6 +687,7 @@ static int buffer_finish(struct vb2_buffer *vb) parport_release(qcam->pdev); mutex_unlock(&qcam->lock); + v4l2_get_timestamp(&vb->v4l2_buf.timestamp); if (len != size) vb->state = VB2_BUF_STATE_ERROR; vb2_set_plane_payload(vb, 0, len); @@ -964,6 +965,7 @@ static struct qcam *qcam_init(struct parport *port) q->drv_priv = qcam; q->ops = &qcam_video_qops; q->mem_ops = &vb2_vmalloc_memops; + q->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; err = vb2_queue_init(q); if (err < 0) { v4l2_err(v4l2_dev, "couldn't init vb2_queue for %s.\n", port->name); From a0c6ae257e416e5cdf7018223500d327d58da2d7 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Mon, 13 May 2013 05:24:07 -0300 Subject: [PATCH 0057/1048] [media] timblogiw: Remove redundant platform_set_drvdata() Commit 0998d06310 (device-core: Ensure drvdata = NULL when no driver is bound) removes the need to set driver data field to NULL. Signed-off-by: Sachin Kamat Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/timblogiw.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/media/platform/timblogiw.c b/drivers/media/platform/timblogiw.c index a2f7bdd5104f..99861c631798 100644 --- a/drivers/media/platform/timblogiw.c +++ b/drivers/media/platform/timblogiw.c @@ -834,11 +834,9 @@ static int timblogiw_probe(struct platform_device *pdev) goto err_request; } - return 0; err_request: - platform_set_drvdata(pdev, NULL); v4l2_device_unregister(&lw->v4l2_dev); err_register: kfree(lw); @@ -858,8 +856,6 @@ static int timblogiw_remove(struct platform_device *pdev) kfree(lw); - platform_set_drvdata(pdev, NULL); - return 0; } From d78fe0877867258ac422bc851ee3110f679e1246 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Mon, 13 May 2013 05:24:08 -0300 Subject: [PATCH 0058/1048] [media] rc: gpio-ir-recv: Remove redundant platform_set_drvdata() Commit 0998d06310 (device-core: Ensure drvdata = NULL when no driver is bound) removes the need to set driver data field to NULL. Signed-off-by: Sachin Kamat Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/rc/gpio-ir-recv.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/media/rc/gpio-ir-recv.c b/drivers/media/rc/gpio-ir-recv.c index 8b82ae9bd686..07aacfa5903d 100644 --- a/drivers/media/rc/gpio-ir-recv.c +++ b/drivers/media/rc/gpio-ir-recv.c @@ -178,7 +178,6 @@ static int gpio_ir_recv_probe(struct platform_device *pdev) return 0; err_request_irq: - platform_set_drvdata(pdev, NULL); rc_unregister_device(rcdev); rcdev = NULL; err_register_rc_device: @@ -196,7 +195,6 @@ static int gpio_ir_recv_remove(struct platform_device *pdev) struct gpio_rc_dev *gpio_dev = platform_get_drvdata(pdev); free_irq(gpio_to_irq(gpio_dev->gpio_nr), gpio_dev); - platform_set_drvdata(pdev, NULL); rc_unregister_device(gpio_dev->rcdev); gpio_free(gpio_dev->gpio_nr); kfree(gpio_dev); From dad0e1ce0468d12b50b5735635d9283842ea8de3 Mon Sep 17 00:00:00 2001 From: Philipp Zabel Date: Tue, 21 May 2013 04:18:22 -0300 Subject: [PATCH 0059/1048] [media] coda: v4l2-compliance fix: add bus_info prefix 'platform' Signed-off-by: Philipp Zabel Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/coda.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/platform/coda.c b/drivers/media/platform/coda.c index 48b8d7af386d..d64908a74000 100644 --- a/drivers/media/platform/coda.c +++ b/drivers/media/platform/coda.c @@ -323,7 +323,7 @@ static int vidioc_querycap(struct file *file, void *priv, { strlcpy(cap->driver, CODA_NAME, sizeof(cap->driver)); strlcpy(cap->card, CODA_NAME, sizeof(cap->card)); - strlcpy(cap->bus_info, CODA_NAME, sizeof(cap->bus_info)); + strlcpy(cap->bus_info, "platform:" CODA_NAME, sizeof(cap->bus_info)); /* * This is only a mem-to-mem video device. The capture and output * device capability flags are left only for backward compatibility From 611cbbfefa2170a281981b67f2fa3f7d498cc518 Mon Sep 17 00:00:00 2001 From: Philipp Zabel Date: Tue, 21 May 2013 04:19:27 -0300 Subject: [PATCH 0060/1048] [media] coda: use devm_ioremap_resource Signed-off-by: Philipp Zabel Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/coda.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/drivers/media/platform/coda.c b/drivers/media/platform/coda.c index d64908a74000..421230732051 100644 --- a/drivers/media/platform/coda.c +++ b/drivers/media/platform/coda.c @@ -1976,17 +1976,9 @@ static int coda_probe(struct platform_device *pdev) return -ENOENT; } - if (devm_request_mem_region(&pdev->dev, res->start, - resource_size(res), CODA_NAME) == NULL) { - dev_err(&pdev->dev, "failed to request memory region\n"); - return -ENOENT; - } - dev->regs_base = devm_ioremap(&pdev->dev, res->start, - resource_size(res)); - if (!dev->regs_base) { - dev_err(&pdev->dev, "failed to ioremap address region\n"); - return -ENOENT; - } + dev->regs_base = devm_ioremap_resource(&pdev->dev, res); + if (IS_ERR(dev->regs_base)) + return PTR_ERR(dev->regs_base); /* IRQ */ irq = platform_get_irq(pdev, 0); From 419869c86f9745157fd6398ba65c79fda5982c6f Mon Sep 17 00:00:00 2001 From: Philipp Zabel Date: Thu, 23 May 2013 07:06:30 -0300 Subject: [PATCH 0061/1048] [media] coda: enable dmabuf support Signed-off-by: Philipp Zabel Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/coda.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/coda.c b/drivers/media/platform/coda.c index 421230732051..2d8e50e1c9b8 100644 --- a/drivers/media/platform/coda.c +++ b/drivers/media/platform/coda.c @@ -569,6 +569,14 @@ static int vidioc_qbuf(struct file *file, void *priv, struct v4l2_buffer *buf) return v4l2_m2m_qbuf(file, ctx->m2m_ctx, buf); } +static int vidioc_expbuf(struct file *file, void *priv, + struct v4l2_exportbuffer *eb) +{ + struct coda_ctx *ctx = fh_to_ctx(priv); + + return v4l2_m2m_expbuf(file, ctx->m2m_ctx, eb); +} + static int vidioc_dqbuf(struct file *file, void *priv, struct v4l2_buffer *buf) { struct coda_ctx *ctx = fh_to_ctx(priv); @@ -609,6 +617,7 @@ static const struct v4l2_ioctl_ops coda_ioctl_ops = { .vidioc_querybuf = vidioc_querybuf, .vidioc_qbuf = vidioc_qbuf, + .vidioc_expbuf = vidioc_expbuf, .vidioc_dqbuf = vidioc_dqbuf, .vidioc_streamon = vidioc_streamon, @@ -1422,7 +1431,7 @@ static int coda_queue_init(void *priv, struct vb2_queue *src_vq, int ret; src_vq->type = V4L2_BUF_TYPE_VIDEO_OUTPUT; - src_vq->io_modes = VB2_MMAP | VB2_USERPTR; + src_vq->io_modes = VB2_DMABUF | VB2_MMAP | VB2_USERPTR; src_vq->drv_priv = ctx; src_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer); src_vq->ops = &coda_qops; @@ -1434,7 +1443,7 @@ static int coda_queue_init(void *priv, struct vb2_queue *src_vq, return ret; dst_vq->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - dst_vq->io_modes = VB2_MMAP | VB2_USERPTR; + dst_vq->io_modes = VB2_DMABUF | VB2_MMAP | VB2_USERPTR; dst_vq->drv_priv = ctx; dst_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer); dst_vq->ops = &coda_qops; From c4eb1bfcbd7c2591caecda531072efda9e727dfa Mon Sep 17 00:00:00 2001 From: Philipp Zabel Date: Tue, 21 May 2013 04:24:16 -0300 Subject: [PATCH 0062/1048] [media] coda: set umask 0644 on debug module param Otherwise module/coda/parameters/coda_debug won't show up in sysfs. Signed-off-by: Philipp Zabel Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/coda.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/platform/coda.c b/drivers/media/platform/coda.c index 2d8e50e1c9b8..b1f77d3c8594 100644 --- a/drivers/media/platform/coda.c +++ b/drivers/media/platform/coda.c @@ -67,7 +67,7 @@ #define fh_to_ctx(__fh) container_of(__fh, struct coda_ctx, fh) static int coda_debug; -module_param(coda_debug, int, 0); +module_param(coda_debug, int, 0644); MODULE_PARM_DESC(coda_debug, "Debug level (0-1)"); enum { From 72720ffc74a58ce27ea237c729f38e6a966f2997 Mon Sep 17 00:00:00 2001 From: Philipp Zabel Date: Tue, 21 May 2013 10:31:25 -0300 Subject: [PATCH 0063/1048] [media] coda: fix error return value if v4l2_m2m_ctx_init fails Use ret from the outer scope, instead of redefining it in the conditional clause. That way the error value reaches the end of the function as intended. Signed-off-by: Philipp Zabel Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/coda.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/platform/coda.c b/drivers/media/platform/coda.c index b1f77d3c8594..aebd17251ba2 100644 --- a/drivers/media/platform/coda.c +++ b/drivers/media/platform/coda.c @@ -1484,7 +1484,7 @@ static int coda_open(struct file *file) ctx->m2m_ctx = v4l2_m2m_ctx_init(dev->m2m_dev, ctx, &coda_queue_init); if (IS_ERR(ctx->m2m_ctx)) { - int ret = PTR_ERR(ctx->m2m_ctx); + ret = PTR_ERR(ctx->m2m_ctx); v4l2_err(&dev->v4l2_dev, "%s return error (%d)\n", __func__, ret); From 39cc029f9c74a9917560c51f1b5dd2ed8c4ede8a Mon Sep 17 00:00:00 2001 From: Philipp Zabel Date: Tue, 21 May 2013 10:32:42 -0300 Subject: [PATCH 0064/1048] [media] coda: do not use v4l2_dev in coda_timeout The timeout delayed work might be scheduled even after the v4l2 device is released. Signed-off-by: Philipp Zabel Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/coda.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/platform/coda.c b/drivers/media/platform/coda.c index aebd17251ba2..efb42b2913ca 100644 --- a/drivers/media/platform/coda.c +++ b/drivers/media/platform/coda.c @@ -1676,7 +1676,7 @@ static void coda_timeout(struct work_struct *work) complete(&dev->done); - v4l2_err(&dev->v4l2_dev, "CODA PIC_RUN timeout, stopping all streams\n"); + dev_err(&dev->plat_dev->dev, "CODA PIC_RUN timeout, stopping all streams\n"); mutex_lock(&dev->dev_mutex); list_for_each_entry(ctx, &dev->instances, list) { From 7e89bd9f242930371f89f3d8c32eaf42ea1c74b1 Mon Sep 17 00:00:00 2001 From: "Lad, Prabhakar" Date: Tue, 14 May 2013 01:45:14 -0300 Subject: [PATCH 0065/1048] [media] media: i2c: remove duplicate checks for EPERM in dbg_g/s_register This patch removes check for EPERM in dbg_g/s_register of subdevice drivers as this check is already performed by core. Signed-off-by: Lad, Prabhakar Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/i2c/ad9389b.c | 4 ---- drivers/media/i2c/adv7183.c | 4 ---- drivers/media/i2c/adv7604.c | 4 ---- drivers/media/i2c/cs5345.c | 4 ---- drivers/media/i2c/cx25840/cx25840-core.c | 4 ---- drivers/media/i2c/m52790.c | 4 ---- drivers/media/i2c/mt9v011.c | 4 ---- drivers/media/i2c/ov7670.c | 4 ---- drivers/media/i2c/saa7115.c | 4 ---- drivers/media/i2c/saa7127.c | 4 ---- drivers/media/i2c/saa717x.c | 4 ---- drivers/media/i2c/ths7303.c | 4 ---- drivers/media/i2c/tvp5150.c | 4 ---- drivers/media/i2c/tvp7002.c | 10 ++-------- drivers/media/i2c/upd64031a.c | 4 ---- drivers/media/i2c/upd64083.c | 4 ---- drivers/media/i2c/vs6624.c | 4 ---- 17 files changed, 2 insertions(+), 72 deletions(-) diff --git a/drivers/media/i2c/ad9389b.c b/drivers/media/i2c/ad9389b.c index 1d4e4e70e8f8..ade1fec7e040 100644 --- a/drivers/media/i2c/ad9389b.c +++ b/drivers/media/i2c/ad9389b.c @@ -347,8 +347,6 @@ static int ad9389b_g_register(struct v4l2_subdev *sd, struct v4l2_dbg_register * if (!v4l2_chip_match_i2c_client(client, ®->match)) return -EINVAL; - if (!capable(CAP_SYS_ADMIN)) - return -EPERM; reg->val = ad9389b_rd(sd, reg->reg & 0xff); reg->size = 1; return 0; @@ -360,8 +358,6 @@ static int ad9389b_s_register(struct v4l2_subdev *sd, const struct v4l2_dbg_regi if (!v4l2_chip_match_i2c_client(client, ®->match)) return -EINVAL; - if (!capable(CAP_SYS_ADMIN)) - return -EPERM; ad9389b_wr(sd, reg->reg & 0xff, reg->val & 0xff); return 0; } diff --git a/drivers/media/i2c/adv7183.c b/drivers/media/i2c/adv7183.c index 42b2dec4ca3a..7c48e22b41a2 100644 --- a/drivers/media/i2c/adv7183.c +++ b/drivers/media/i2c/adv7183.c @@ -500,8 +500,6 @@ static int adv7183_g_register(struct v4l2_subdev *sd, struct v4l2_dbg_register * if (!v4l2_chip_match_i2c_client(client, ®->match)) return -EINVAL; - if (!capable(CAP_SYS_ADMIN)) - return -EPERM; reg->val = adv7183_read(sd, reg->reg & 0xff); reg->size = 1; return 0; @@ -513,8 +511,6 @@ static int adv7183_s_register(struct v4l2_subdev *sd, const struct v4l2_dbg_regi if (!v4l2_chip_match_i2c_client(client, ®->match)) return -EINVAL; - if (!capable(CAP_SYS_ADMIN)) - return -EPERM; adv7183_write(sd, reg->reg & 0xff, reg->val & 0xff); return 0; } diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c index 4cdcfc96aa56..5528cd15cc67 100644 --- a/drivers/media/i2c/adv7604.c +++ b/drivers/media/i2c/adv7604.c @@ -647,8 +647,6 @@ static int adv7604_g_register(struct v4l2_subdev *sd, if (!v4l2_chip_match_i2c_client(client, ®->match)) return -EINVAL; - if (!capable(CAP_SYS_ADMIN)) - return -EPERM; reg->size = 1; switch (reg->reg >> 8) { case 0: @@ -705,8 +703,6 @@ static int adv7604_s_register(struct v4l2_subdev *sd, if (!v4l2_chip_match_i2c_client(client, ®->match)) return -EINVAL; - if (!capable(CAP_SYS_ADMIN)) - return -EPERM; switch (reg->reg >> 8) { case 0: io_write(sd, reg->reg & 0xff, reg->val & 0xff); diff --git a/drivers/media/i2c/cs5345.c b/drivers/media/i2c/cs5345.c index 841b9c49dcfa..2661757c3a8c 100644 --- a/drivers/media/i2c/cs5345.c +++ b/drivers/media/i2c/cs5345.c @@ -103,8 +103,6 @@ static int cs5345_g_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *r if (!v4l2_chip_match_i2c_client(client, ®->match)) return -EINVAL; - if (!capable(CAP_SYS_ADMIN)) - return -EPERM; reg->size = 1; reg->val = cs5345_read(sd, reg->reg & 0x1f); return 0; @@ -116,8 +114,6 @@ static int cs5345_s_register(struct v4l2_subdev *sd, const struct v4l2_dbg_regis if (!v4l2_chip_match_i2c_client(client, ®->match)) return -EINVAL; - if (!capable(CAP_SYS_ADMIN)) - return -EPERM; cs5345_write(sd, reg->reg & 0x1f, reg->val & 0xff); return 0; } diff --git a/drivers/media/i2c/cx25840/cx25840-core.c b/drivers/media/i2c/cx25840/cx25840-core.c index bdfec4c768fe..b81e32f371ae 100644 --- a/drivers/media/i2c/cx25840/cx25840-core.c +++ b/drivers/media/i2c/cx25840/cx25840-core.c @@ -1664,8 +1664,6 @@ static int cx25840_g_register(struct v4l2_subdev *sd, struct v4l2_dbg_register * if (!v4l2_chip_match_i2c_client(client, ®->match)) return -EINVAL; - if (!capable(CAP_SYS_ADMIN)) - return -EPERM; reg->size = 1; reg->val = cx25840_read(client, reg->reg & 0x0fff); return 0; @@ -1677,8 +1675,6 @@ static int cx25840_s_register(struct v4l2_subdev *sd, const struct v4l2_dbg_regi if (!v4l2_chip_match_i2c_client(client, ®->match)) return -EINVAL; - if (!capable(CAP_SYS_ADMIN)) - return -EPERM; cx25840_write(client, reg->reg & 0x0fff, reg->val & 0xff); return 0; } diff --git a/drivers/media/i2c/m52790.c b/drivers/media/i2c/m52790.c index 0d153f3b1a5b..3eeb546be6d9 100644 --- a/drivers/media/i2c/m52790.c +++ b/drivers/media/i2c/m52790.c @@ -87,8 +87,6 @@ static int m52790_g_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *r if (!v4l2_chip_match_i2c_client(client, ®->match)) return -EINVAL; - if (!capable(CAP_SYS_ADMIN)) - return -EPERM; if (reg->reg != 0) return -EINVAL; reg->size = 1; @@ -103,8 +101,6 @@ static int m52790_s_register(struct v4l2_subdev *sd, const struct v4l2_dbg_regis if (!v4l2_chip_match_i2c_client(client, ®->match)) return -EINVAL; - if (!capable(CAP_SYS_ADMIN)) - return -EPERM; if (reg->reg != 0) return -EINVAL; state->input = reg->val & 0x0303; diff --git a/drivers/media/i2c/mt9v011.c b/drivers/media/i2c/mt9v011.c index c64c9d9e253d..141919bf77fc 100644 --- a/drivers/media/i2c/mt9v011.c +++ b/drivers/media/i2c/mt9v011.c @@ -411,8 +411,6 @@ static int mt9v011_g_register(struct v4l2_subdev *sd, if (!v4l2_chip_match_i2c_client(client, ®->match)) return -EINVAL; - if (!capable(CAP_SYS_ADMIN)) - return -EPERM; reg->val = mt9v011_read(sd, reg->reg & 0xff); reg->size = 2; @@ -427,8 +425,6 @@ static int mt9v011_s_register(struct v4l2_subdev *sd, if (!v4l2_chip_match_i2c_client(client, ®->match)) return -EINVAL; - if (!capable(CAP_SYS_ADMIN)) - return -EPERM; mt9v011_write(sd, reg->reg & 0xff, reg->val & 0xffff); diff --git a/drivers/media/i2c/ov7670.c b/drivers/media/i2c/ov7670.c index d71602f4fb43..b030279810d3 100644 --- a/drivers/media/i2c/ov7670.c +++ b/drivers/media/i2c/ov7670.c @@ -1479,8 +1479,6 @@ static int ov7670_g_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *r if (!v4l2_chip_match_i2c_client(client, ®->match)) return -EINVAL; - if (!capable(CAP_SYS_ADMIN)) - return -EPERM; ret = ov7670_read(sd, reg->reg & 0xff, &val); reg->val = val; reg->size = 1; @@ -1493,8 +1491,6 @@ static int ov7670_s_register(struct v4l2_subdev *sd, const struct v4l2_dbg_regis if (!v4l2_chip_match_i2c_client(client, ®->match)) return -EINVAL; - if (!capable(CAP_SYS_ADMIN)) - return -EPERM; ov7670_write(sd, reg->reg & 0xff, reg->val & 0xff); return 0; } diff --git a/drivers/media/i2c/saa7115.c b/drivers/media/i2c/saa7115.c index 8316ae448f4c..18cf0bfaf743 100644 --- a/drivers/media/i2c/saa7115.c +++ b/drivers/media/i2c/saa7115.c @@ -1464,8 +1464,6 @@ static int saa711x_g_register(struct v4l2_subdev *sd, struct v4l2_dbg_register * if (!v4l2_chip_match_i2c_client(client, ®->match)) return -EINVAL; - if (!capable(CAP_SYS_ADMIN)) - return -EPERM; reg->val = saa711x_read(sd, reg->reg & 0xff); reg->size = 1; return 0; @@ -1477,8 +1475,6 @@ static int saa711x_s_register(struct v4l2_subdev *sd, const struct v4l2_dbg_regi if (!v4l2_chip_match_i2c_client(client, ®->match)) return -EINVAL; - if (!capable(CAP_SYS_ADMIN)) - return -EPERM; saa711x_write(sd, reg->reg & 0xff, reg->val & 0xff); return 0; } diff --git a/drivers/media/i2c/saa7127.c b/drivers/media/i2c/saa7127.c index 9882c83c1c93..d9c388103e7a 100644 --- a/drivers/media/i2c/saa7127.c +++ b/drivers/media/i2c/saa7127.c @@ -665,8 +665,6 @@ static int saa7127_g_register(struct v4l2_subdev *sd, struct v4l2_dbg_register * if (!v4l2_chip_match_i2c_client(client, ®->match)) return -EINVAL; - if (!capable(CAP_SYS_ADMIN)) - return -EPERM; reg->val = saa7127_read(sd, reg->reg & 0xff); reg->size = 1; return 0; @@ -678,8 +676,6 @@ static int saa7127_s_register(struct v4l2_subdev *sd, const struct v4l2_dbg_regi if (!v4l2_chip_match_i2c_client(client, ®->match)) return -EINVAL; - if (!capable(CAP_SYS_ADMIN)) - return -EPERM; saa7127_write(sd, reg->reg & 0xff, reg->val & 0xff); return 0; } diff --git a/drivers/media/i2c/saa717x.c b/drivers/media/i2c/saa717x.c index 71328109642e..330a04c58939 100644 --- a/drivers/media/i2c/saa717x.c +++ b/drivers/media/i2c/saa717x.c @@ -981,8 +981,6 @@ static int saa717x_g_register(struct v4l2_subdev *sd, struct v4l2_dbg_register * if (!v4l2_chip_match_i2c_client(client, ®->match)) return -EINVAL; - if (!capable(CAP_SYS_ADMIN)) - return -EPERM; reg->val = saa717x_read(sd, reg->reg); reg->size = 1; return 0; @@ -996,8 +994,6 @@ static int saa717x_s_register(struct v4l2_subdev *sd, const struct v4l2_dbg_regi if (!v4l2_chip_match_i2c_client(client, ®->match)) return -EINVAL; - if (!capable(CAP_SYS_ADMIN)) - return -EPERM; saa717x_write(sd, addr, val); return 0; } diff --git a/drivers/media/i2c/ths7303.c b/drivers/media/i2c/ths7303.c index c4339556a2ea..65853eea09a1 100644 --- a/drivers/media/i2c/ths7303.c +++ b/drivers/media/i2c/ths7303.c @@ -236,8 +236,6 @@ static int ths7303_g_register(struct v4l2_subdev *sd, if (!v4l2_chip_match_i2c_client(client, ®->match)) return -EINVAL; - if (!capable(CAP_SYS_ADMIN)) - return -EPERM; reg->size = 1; reg->val = ths7303_read(sd, reg->reg); @@ -251,8 +249,6 @@ static int ths7303_s_register(struct v4l2_subdev *sd, if (!v4l2_chip_match_i2c_client(client, ®->match)) return -EINVAL; - if (!capable(CAP_SYS_ADMIN)) - return -EPERM; ths7303_write(sd, reg->reg, reg->val); return 0; diff --git a/drivers/media/i2c/tvp5150.c b/drivers/media/i2c/tvp5150.c index de9db3bf1ebd..b3cf26628c09 100644 --- a/drivers/media/i2c/tvp5150.c +++ b/drivers/media/i2c/tvp5150.c @@ -1054,8 +1054,6 @@ static int tvp5150_g_register(struct v4l2_subdev *sd, struct v4l2_dbg_register * if (!v4l2_chip_match_i2c_client(client, ®->match)) return -EINVAL; - if (!capable(CAP_SYS_ADMIN)) - return -EPERM; res = tvp5150_read(sd, reg->reg & 0xff); if (res < 0) { v4l2_err(sd, "%s: failed with error = %d\n", __func__, res); @@ -1073,8 +1071,6 @@ static int tvp5150_s_register(struct v4l2_subdev *sd, const struct v4l2_dbg_regi if (!v4l2_chip_match_i2c_client(client, ®->match)) return -EINVAL; - if (!capable(CAP_SYS_ADMIN)) - return -EPERM; tvp5150_write(sd, reg->reg & 0xff, reg->val & 0xff); return 0; } diff --git a/drivers/media/i2c/tvp7002.c b/drivers/media/i2c/tvp7002.c index 81b4eb40d7a6..f339e6faca90 100644 --- a/drivers/media/i2c/tvp7002.c +++ b/drivers/media/i2c/tvp7002.c @@ -736,8 +736,7 @@ static int tvp7002_query_dv_timings(struct v4l2_subdev *sd, * * Get the value of a TVP7002 decoder device register. * Returns zero when successful, -EINVAL if register read fails or - * access to I2C client fails, -EPERM if the call is not allowed - * by disabled CAP_SYS_ADMIN. + * access to I2C client fails. */ static int tvp7002_g_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg) @@ -748,8 +747,6 @@ static int tvp7002_g_register(struct v4l2_subdev *sd, if (!v4l2_chip_match_i2c_client(client, ®->match)) return -EINVAL; - if (!capable(CAP_SYS_ADMIN)) - return -EPERM; ret = tvp7002_read(sd, reg->reg & 0xff, &val); reg->val = val; @@ -762,8 +759,7 @@ static int tvp7002_g_register(struct v4l2_subdev *sd, * @reg: ptr to v4l2_dbg_register struct * * Get the value of a TVP7002 decoder device register. - * Returns zero when successful, -EINVAL if register read fails or - * -EPERM if call not allowed. + * Returns zero when successful, -EINVAL if register read fails. */ static int tvp7002_s_register(struct v4l2_subdev *sd, const struct v4l2_dbg_register *reg) @@ -772,8 +768,6 @@ static int tvp7002_s_register(struct v4l2_subdev *sd, if (!v4l2_chip_match_i2c_client(client, ®->match)) return -EINVAL; - if (!capable(CAP_SYS_ADMIN)) - return -EPERM; return tvp7002_write(sd, reg->reg & 0xff, reg->val & 0xff); } diff --git a/drivers/media/i2c/upd64031a.c b/drivers/media/i2c/upd64031a.c index 4283fc5f39ef..13a4cf8bebdf 100644 --- a/drivers/media/i2c/upd64031a.c +++ b/drivers/media/i2c/upd64031a.c @@ -168,8 +168,6 @@ static int upd64031a_g_register(struct v4l2_subdev *sd, struct v4l2_dbg_register if (!v4l2_chip_match_i2c_client(client, ®->match)) return -EINVAL; - if (!capable(CAP_SYS_ADMIN)) - return -EPERM; reg->val = upd64031a_read(sd, reg->reg & 0xff); reg->size = 1; return 0; @@ -181,8 +179,6 @@ static int upd64031a_s_register(struct v4l2_subdev *sd, const struct v4l2_dbg_re if (!v4l2_chip_match_i2c_client(client, ®->match)) return -EINVAL; - if (!capable(CAP_SYS_ADMIN)) - return -EPERM; upd64031a_write(sd, reg->reg & 0xff, reg->val & 0xff); return 0; } diff --git a/drivers/media/i2c/upd64083.c b/drivers/media/i2c/upd64083.c index b2ac56ca22e6..e296639ab90e 100644 --- a/drivers/media/i2c/upd64083.c +++ b/drivers/media/i2c/upd64083.c @@ -126,8 +126,6 @@ static int upd64083_g_register(struct v4l2_subdev *sd, struct v4l2_dbg_register if (!v4l2_chip_match_i2c_client(client, ®->match)) return -EINVAL; - if (!capable(CAP_SYS_ADMIN)) - return -EPERM; reg->val = upd64083_read(sd, reg->reg & 0xff); reg->size = 1; return 0; @@ -139,8 +137,6 @@ static int upd64083_s_register(struct v4l2_subdev *sd, const struct v4l2_dbg_reg if (!v4l2_chip_match_i2c_client(client, ®->match)) return -EINVAL; - if (!capable(CAP_SYS_ADMIN)) - return -EPERM; upd64083_write(sd, reg->reg & 0xff, reg->val & 0xff); return 0; } diff --git a/drivers/media/i2c/vs6624.c b/drivers/media/i2c/vs6624.c index 7b55b3ddd80f..d2209a35c510 100644 --- a/drivers/media/i2c/vs6624.c +++ b/drivers/media/i2c/vs6624.c @@ -741,8 +741,6 @@ static int vs6624_g_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *r if (!v4l2_chip_match_i2c_client(client, ®->match)) return -EINVAL; - if (!capable(CAP_SYS_ADMIN)) - return -EPERM; reg->val = vs6624_read(sd, reg->reg & 0xffff); reg->size = 1; return 0; @@ -754,8 +752,6 @@ static int vs6624_s_register(struct v4l2_subdev *sd, const struct v4l2_dbg_regis if (!v4l2_chip_match_i2c_client(client, ®->match)) return -EINVAL; - if (!capable(CAP_SYS_ADMIN)) - return -EPERM; vs6624_write(sd, reg->reg & 0xffff, reg->val & 0xff); return 0; } From d5f8fb5b46ed07c4e2a6811eff4ae4368652c9ea Mon Sep 17 00:00:00 2001 From: "Lad, Prabhakar" Date: Tue, 14 May 2013 01:45:15 -0300 Subject: [PATCH 0066/1048] [media] media: dvb-frontends: remove duplicate checks for EPERM in dbg_g/s_register This patch removes check for EPERM in dbg_g/s_register as this check is already performed by core. Signed-off-by: Lad, Prabhakar Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb-frontends/au8522_decoder.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/media/dvb-frontends/au8522_decoder.c b/drivers/media/dvb-frontends/au8522_decoder.c index 2099f21e374d..9d159b48e50b 100644 --- a/drivers/media/dvb-frontends/au8522_decoder.c +++ b/drivers/media/dvb-frontends/au8522_decoder.c @@ -529,8 +529,6 @@ static int au8522_g_register(struct v4l2_subdev *sd, if (!v4l2_chip_match_i2c_client(client, ®->match)) return -EINVAL; - if (!capable(CAP_SYS_ADMIN)) - return -EPERM; reg->val = au8522_readreg(state, reg->reg & 0xffff); return 0; } @@ -543,8 +541,6 @@ static int au8522_s_register(struct v4l2_subdev *sd, if (!v4l2_chip_match_i2c_client(client, ®->match)) return -EINVAL; - if (!capable(CAP_SYS_ADMIN)) - return -EPERM; au8522_writereg(state, reg->reg, reg->val & 0xff); return 0; } From 625b35229bc491e837b385b7ce1e2a8eece3db0f Mon Sep 17 00:00:00 2001 From: "Lad, Prabhakar" Date: Tue, 14 May 2013 01:45:16 -0300 Subject: [PATCH 0067/1048] [media] media: usb: remove duplicate checks for EPERM in vidioc_g/s_register This patch removes check for EPERM in vidioc_g/s_register as this check is already performed by core. Signed-off-by: Lad, Prabhakar Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/usb/pvrusb2/pvrusb2-hdw.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/media/usb/pvrusb2/pvrusb2-hdw.c b/drivers/media/usb/pvrusb2/pvrusb2-hdw.c index e11267f35d87..01d1c2d47cb5 100644 --- a/drivers/media/usb/pvrusb2/pvrusb2-hdw.c +++ b/drivers/media/usb/pvrusb2/pvrusb2-hdw.c @@ -5173,8 +5173,6 @@ int pvr2_hdw_register_access(struct pvr2_hdw *hdw, int stat = 0; int okFl = 0; - if (!capable(CAP_SYS_ADMIN)) return -EPERM; - req.match = *match; req.reg = reg_id; if (setFl) req.val = *val_ptr; From 7eac97d7e714429f7ef1ba5d35f94c07f4c34f8e Mon Sep 17 00:00:00 2001 From: "Lad, Prabhakar" Date: Tue, 14 May 2013 01:45:17 -0300 Subject: [PATCH 0068/1048] [media] media: pci: remove duplicate checks for EPERM This patch removes check for EPERM in dbg_g/s_register and vidioc_g/s_register as this check is already performed by core. Signed-off-by: Lad, Prabhakar Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/pci/bt8xx/bttv-driver.c | 6 ------ drivers/media/pci/cx18/cx18-av-core.c | 4 ---- drivers/media/pci/cx23885/cx23885-ioctl.c | 6 ------ drivers/media/pci/cx23885/cx23888-ir.c | 4 ---- drivers/media/pci/ivtv/ivtv-ioctl.c | 2 -- drivers/media/pci/saa7146/mxb.c | 4 ---- drivers/media/pci/saa7164/saa7164-encoder.c | 6 ------ 7 files changed, 32 deletions(-) diff --git a/drivers/media/pci/bt8xx/bttv-driver.c b/drivers/media/pci/bt8xx/bttv-driver.c index e7d088413411..a334c94a303d 100644 --- a/drivers/media/pci/bt8xx/bttv-driver.c +++ b/drivers/media/pci/bt8xx/bttv-driver.c @@ -1936,9 +1936,6 @@ static int bttv_g_register(struct file *file, void *f, struct bttv_fh *fh = f; struct bttv *btv = fh->btv; - if (!capable(CAP_SYS_ADMIN)) - return -EPERM; - if (!v4l2_chip_match_host(®->match)) { /* TODO: subdev errors should not be ignored, this should become a subdev helper function. */ @@ -1960,9 +1957,6 @@ static int bttv_s_register(struct file *file, void *f, struct bttv_fh *fh = f; struct bttv *btv = fh->btv; - if (!capable(CAP_SYS_ADMIN)) - return -EPERM; - if (!v4l2_chip_match_host(®->match)) { /* TODO: subdev errors should not be ignored, this should become a subdev helper function. */ diff --git a/drivers/media/pci/cx18/cx18-av-core.c b/drivers/media/pci/cx18/cx18-av-core.c index 38b1d64ffc27..ba8caf0fbb85 100644 --- a/drivers/media/pci/cx18/cx18-av-core.c +++ b/drivers/media/pci/cx18/cx18-av-core.c @@ -1258,8 +1258,6 @@ static int cx18_av_g_register(struct v4l2_subdev *sd, return -EINVAL; if ((reg->reg & 0x3) != 0) return -EINVAL; - if (!capable(CAP_SYS_ADMIN)) - return -EPERM; reg->size = 4; reg->val = cx18_av_read4(cx, reg->reg & 0x00000ffc); return 0; @@ -1274,8 +1272,6 @@ static int cx18_av_s_register(struct v4l2_subdev *sd, return -EINVAL; if ((reg->reg & 0x3) != 0) return -EINVAL; - if (!capable(CAP_SYS_ADMIN)) - return -EPERM; cx18_av_write4(cx, reg->reg & 0x00000ffc, reg->val); return 0; } diff --git a/drivers/media/pci/cx23885/cx23885-ioctl.c b/drivers/media/pci/cx23885/cx23885-ioctl.c index acdb6d58db58..00f51251728b 100644 --- a/drivers/media/pci/cx23885/cx23885-ioctl.c +++ b/drivers/media/pci/cx23885/cx23885-ioctl.c @@ -138,9 +138,6 @@ int cx23885_g_register(struct file *file, void *fh, { struct cx23885_dev *dev = ((struct cx23885_fh *)fh)->dev; - if (!capable(CAP_SYS_ADMIN)) - return -EPERM; - if (reg->match.type == V4L2_CHIP_MATCH_HOST) { switch (reg->match.addr) { case 0: @@ -186,9 +183,6 @@ int cx23885_s_register(struct file *file, void *fh, { struct cx23885_dev *dev = ((struct cx23885_fh *)fh)->dev; - if (!capable(CAP_SYS_ADMIN)) - return -EPERM; - if (reg->match.type == V4L2_CHIP_MATCH_HOST) { switch (reg->match.addr) { case 0: diff --git a/drivers/media/pci/cx23885/cx23888-ir.c b/drivers/media/pci/cx23885/cx23888-ir.c index fa672fe41079..cd98651f3ae6 100644 --- a/drivers/media/pci/cx23885/cx23888-ir.c +++ b/drivers/media/pci/cx23885/cx23888-ir.c @@ -1116,8 +1116,6 @@ static int cx23888_ir_g_register(struct v4l2_subdev *sd, return -EINVAL; if (addr < CX23888_IR_CNTRL_REG || addr > CX23888_IR_LEARN_REG) return -EINVAL; - if (!capable(CAP_SYS_ADMIN)) - return -EPERM; reg->size = 4; reg->val = cx23888_ir_read4(state->dev, addr); return 0; @@ -1135,8 +1133,6 @@ static int cx23888_ir_s_register(struct v4l2_subdev *sd, return -EINVAL; if (addr < CX23888_IR_CNTRL_REG || addr > CX23888_IR_LEARN_REG) return -EINVAL; - if (!capable(CAP_SYS_ADMIN)) - return -EPERM; cx23888_ir_write4(state->dev, addr, reg->val); return 0; } diff --git a/drivers/media/pci/ivtv/ivtv-ioctl.c b/drivers/media/pci/ivtv/ivtv-ioctl.c index 9cbbce0eaedc..3e281eccdd88 100644 --- a/drivers/media/pci/ivtv/ivtv-ioctl.c +++ b/drivers/media/pci/ivtv/ivtv-ioctl.c @@ -715,8 +715,6 @@ static int ivtv_itvc(struct ivtv *itv, bool get, u64 reg, u64 *val) { volatile u8 __iomem *reg_start; - if (!capable(CAP_SYS_ADMIN)) - return -EPERM; if (reg >= IVTV_REG_OFFSET && reg < IVTV_REG_OFFSET + IVTV_REG_SIZE) reg_start = itv->reg_mem - IVTV_REG_OFFSET; else if (itv->has_cx23415 && reg >= IVTV_DECODER_OFFSET && diff --git a/drivers/media/pci/saa7146/mxb.c b/drivers/media/pci/saa7146/mxb.c index 71e8bead321b..52cbe7a027cc 100644 --- a/drivers/media/pci/saa7146/mxb.c +++ b/drivers/media/pci/saa7146/mxb.c @@ -669,8 +669,6 @@ static int vidioc_g_register(struct file *file, void *fh, struct v4l2_dbg_regist { struct saa7146_dev *dev = ((struct saa7146_fh *)fh)->dev; - if (!capable(CAP_SYS_ADMIN)) - return -EPERM; if (v4l2_chip_match_host(®->match)) { reg->val = saa7146_read(dev, reg->reg); reg->size = 4; @@ -684,8 +682,6 @@ static int vidioc_s_register(struct file *file, void *fh, const struct v4l2_dbg_ { struct saa7146_dev *dev = ((struct saa7146_fh *)fh)->dev; - if (!capable(CAP_SYS_ADMIN)) - return -EPERM; if (v4l2_chip_match_host(®->match)) { saa7146_write(dev, reg->reg, reg->val); return 0; diff --git a/drivers/media/pci/saa7164/saa7164-encoder.c b/drivers/media/pci/saa7164/saa7164-encoder.c index 0b74fb2300dd..63a72fb71f30 100644 --- a/drivers/media/pci/saa7164/saa7164-encoder.c +++ b/drivers/media/pci/saa7164/saa7164-encoder.c @@ -1306,9 +1306,6 @@ static int saa7164_g_register(struct file *file, void *fh, struct saa7164_dev *dev = port->dev; dprintk(DBGLVL_ENC, "%s()\n", __func__); - if (!capable(CAP_SYS_ADMIN)) - return -EPERM; - return 0; } @@ -1319,9 +1316,6 @@ static int saa7164_s_register(struct file *file, void *fh, struct saa7164_dev *dev = port->dev; dprintk(DBGLVL_ENC, "%s()\n", __func__); - if (!capable(CAP_SYS_ADMIN)) - return -EPERM; - return 0; } #endif From 8487662994aaf2b66ab72a096a05b8404daa6eeb Mon Sep 17 00:00:00 2001 From: Ulf Hansson Date: Mon, 27 May 2013 14:30:15 +0200 Subject: [PATCH 0069/1048] ARM: ux500: Update MMC configs for u8500 defconfig Enable MMC_UNSAFE_RESUME to be accomplish a proper suspend/resume cycle for SD/SDIO/(e)MMC. ARMMMCI host driver supports clock gating through runtime PM, thus MMC_CLKGATE is not needed. Moreover ARMMMCI can do scatter-gather which means we can explicity disable MMC_BLOCK_BOUNCE, since it's default enabled, to skip unnecessary bounce buffer copying. Signed-off-by: Ulf Hansson Signed-off-by: Linus Walleij --- arch/arm/configs/u8500_defconfig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/arm/configs/u8500_defconfig b/arch/arm/configs/u8500_defconfig index da353e0755b0..b2326b019b83 100644 --- a/arch/arm/configs/u8500_defconfig +++ b/arch/arm/configs/u8500_defconfig @@ -83,7 +83,8 @@ CONFIG_USB_GADGET=y CONFIG_USB_GADGET_MUSB_HDRC=y CONFIG_USB_ETH=m CONFIG_MMC=y -CONFIG_MMC_CLKGATE=y +CONFIG_MMC_UNSAFE_RESUME=y +# CONFIG_MMC_BLOCK_BOUNCE is not set CONFIG_MMC_ARMMMCI=y CONFIG_NEW_LEDS=y CONFIG_LEDS_CLASS=y From fb1fcf1779bba4c034635cc8916261a6744584a9 Mon Sep 17 00:00:00 2001 From: Philipp Zabel Date: Thu, 23 May 2013 10:42:53 -0300 Subject: [PATCH 0070/1048] [media] coda: fix ENC_SEQ_OPTION for CODA7 GAMMA_OFFSET is different between CodaDx6 and CODA7. Also, this is a bitfield. Signed-off-by: Philipp Zabel Signed-off-by: Kamil Debski Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/coda.c | 10 ++++++++-- drivers/media/platform/coda.h | 8 ++------ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/drivers/media/platform/coda.c b/drivers/media/platform/coda.c index efb42b2913ca..1f3ab53670f8 100644 --- a/drivers/media/platform/coda.c +++ b/drivers/media/platform/coda.c @@ -1129,8 +1129,14 @@ static int coda_start_streaming(struct vb2_queue *q, unsigned int count) value = (CODA_DEFAULT_GAMMA & CODA_GAMMA_MASK) << CODA_GAMMA_OFFSET; coda_write(dev, value, CODA_CMD_ENC_SEQ_RC_GAMMA); - value = (CODA_DEFAULT_GAMMA > 0) << CODA_OPTION_GAMMA_OFFSET; - value |= (0 & CODA_OPTION_SLICEREPORT_MASK) << CODA_OPTION_SLICEREPORT_OFFSET; + if (CODA_DEFAULT_GAMMA > 0) { + if (dev->devtype->product == CODA_DX6) + value = 1 << CODADX6_OPTION_GAMMA_OFFSET; + else + value = 1 << CODA7_OPTION_GAMMA_OFFSET; + } else { + value = 0; + } coda_write(dev, value, CODA_CMD_ENC_SEQ_OPTION); if (dst_fourcc == V4L2_PIX_FMT_H264) { diff --git a/drivers/media/platform/coda.h b/drivers/media/platform/coda.h index f3f5e43c1ac2..3c350acd5faa 100644 --- a/drivers/media/platform/coda.h +++ b/drivers/media/platform/coda.h @@ -96,16 +96,12 @@ #define CODA_CMD_ENC_SEQ_BB_START 0x180 #define CODA_CMD_ENC_SEQ_BB_SIZE 0x184 #define CODA_CMD_ENC_SEQ_OPTION 0x188 -#define CODA_OPTION_GAMMA_OFFSET 7 -#define CODA_OPTION_GAMMA_MASK 0x01 +#define CODA7_OPTION_GAMMA_OFFSET 8 +#define CODADX6_OPTION_GAMMA_OFFSET 7 #define CODA_OPTION_LIMITQP_OFFSET 6 -#define CODA_OPTION_LIMITQP_MASK 0x01 #define CODA_OPTION_RCINTRAQP_OFFSET 5 -#define CODA_OPTION_RCINTRAQP_MASK 0x01 #define CODA_OPTION_FMO_OFFSET 4 -#define CODA_OPTION_FMO_MASK 0x01 #define CODA_OPTION_SLICEREPORT_OFFSET 1 -#define CODA_OPTION_SLICEREPORT_MASK 0x01 #define CODA_CMD_ENC_SEQ_COD_STD 0x18c #define CODA_STD_MPEG4 0 #define CODA_STD_H263 1 From 47cf0c61aaf47f9940d3eccc64e870d7f8013590 Mon Sep 17 00:00:00 2001 From: Philipp Zabel Date: Thu, 23 May 2013 10:42:54 -0300 Subject: [PATCH 0071/1048] [media] coda: frame stride must be a multiple of 8 Signed-off-by: Philipp Zabel Signed-off-by: Kamil Debski Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/coda.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/coda.c b/drivers/media/platform/coda.c index 1f3ab53670f8..b53c74855702 100644 --- a/drivers/media/platform/coda.c +++ b/drivers/media/platform/coda.c @@ -422,8 +422,9 @@ static int vidioc_try_fmt(struct coda_dev *dev, struct v4l2_format *f) v4l_bound_align_image(&f->fmt.pix.width, MIN_W, MAX_W, W_ALIGN, &f->fmt.pix.height, MIN_H, MAX_H, H_ALIGN, S_ALIGN); - f->fmt.pix.bytesperline = round_up(f->fmt.pix.width, 2); - f->fmt.pix.sizeimage = f->fmt.pix.width * + /* Frame stride must be multiple of 8 */ + f->fmt.pix.bytesperline = round_up(f->fmt.pix.width, 8); + f->fmt.pix.sizeimage = f->fmt.pix.bytesperline * f->fmt.pix.height * 3 / 2; } else { /*encoded formats h.264/mpeg4 */ f->fmt.pix.bytesperline = 0; From f609222a051037ebcbb9c15c90f456c77a23be13 Mon Sep 17 00:00:00 2001 From: Philipp Zabel Date: Thu, 23 May 2013 10:42:55 -0300 Subject: [PATCH 0072/1048] [media] coda: stop setting bytesused in buf_prepare The application must have filled the bytesused field, don't overwrite it here. Signed-off-by: Philipp Zabel Signed-off-by: Kamil Debski Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/coda.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/media/platform/coda.c b/drivers/media/platform/coda.c index b53c74855702..109b9389c0c9 100644 --- a/drivers/media/platform/coda.c +++ b/drivers/media/platform/coda.c @@ -869,8 +869,6 @@ static int coda_buf_prepare(struct vb2_buffer *vb) return -EINVAL; } - vb2_set_plane_payload(vb, 0, q_data->sizeimage); - return 0; } From 9acf7693b7487b5dc744030a1aaa3a20dd8df495 Mon Sep 17 00:00:00 2001 From: Philipp Zabel Date: Thu, 23 May 2013 10:42:56 -0300 Subject: [PATCH 0073/1048] [media] coda: clear registers in coda_hw_init Signed-off-by: Philipp Zabel Signed-off-by: Kamil Debski Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/coda.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/media/platform/coda.c b/drivers/media/platform/coda.c index 109b9389c0c9..ba99e2fb0f85 100644 --- a/drivers/media/platform/coda.c +++ b/drivers/media/platform/coda.c @@ -1753,6 +1753,10 @@ static int coda_hw_init(struct coda_dev *dev) } } + /* Clear registers */ + for (i = 0; i < 64; i++) + coda_write(dev, 0, CODA_REG_BIT_CODE_BUF_ADDR + i * 4); + /* Tell the BIT where to find everything it needs */ coda_write(dev, dev->workbuf.paddr, CODA_REG_BIT_WORK_BUF_ADDR); From cbe8933143a62e0ced2d48183cdbdbdc38659338 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Fri, 31 May 2013 16:09:06 +0100 Subject: [PATCH 0074/1048] ARM: ux500: Enable HIGHMEM in the u8500 defconfig In order to utilise all of the memory located on ux500 based devices we have to enable HIGHMEM. Without it the kernel truncates memory down to what's left after the PAGE_OFFSET has been applied, which doesn't leave an awful lot, especially if we're running large rootfs' such as full Linux desktop distributions or Android. Signed-off-by: Lee Jones Signed-off-by: Linus Walleij --- arch/arm/configs/u8500_defconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm/configs/u8500_defconfig b/arch/arm/configs/u8500_defconfig index b2326b019b83..a0025dc13021 100644 --- a/arch/arm/configs/u8500_defconfig +++ b/arch/arm/configs/u8500_defconfig @@ -1,3 +1,4 @@ +CONFIG_HIGHMEM=y # CONFIG_SWAP is not set CONFIG_SYSVIPC=y CONFIG_NO_HZ=y From d0d04b78f403b0bcfe03315e16b50d196610720d Mon Sep 17 00:00:00 2001 From: Zhouping Liu Date: Thu, 16 May 2013 11:36:23 +0800 Subject: [PATCH 0075/1048] mm, slab: moved kmem_cache_alloc_node comment to correct place After several fixing about kmem_cache_alloc_node(), its comment was splitted. This patch moved it on top of kmem_cache_alloc_node() definition. Signed-off-by: Zhouping Liu Signed-off-by: Pekka Enberg --- mm/slab.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/mm/slab.c b/mm/slab.c index a98f8db93670..273a5ac2ade3 100644 --- a/mm/slab.c +++ b/mm/slab.c @@ -3340,18 +3340,6 @@ done: return obj; } -/** - * kmem_cache_alloc_node - Allocate an object on the specified node - * @cachep: The cache to allocate from. - * @flags: See kmalloc(). - * @nodeid: node number of the target node. - * @caller: return address of caller, used for debug information - * - * Identical to kmem_cache_alloc but it will allocate memory on the given - * node, which can improve the performance for cpu bound structures. - * - * Fallback to other node is possible if __GFP_THISNODE is not set. - */ static __always_inline void * slab_alloc_node(struct kmem_cache *cachep, gfp_t flags, int nodeid, unsigned long caller) @@ -3645,6 +3633,17 @@ EXPORT_SYMBOL(kmem_cache_alloc_trace); #endif #ifdef CONFIG_NUMA +/** + * kmem_cache_alloc_node - Allocate an object on the specified node + * @cachep: The cache to allocate from. + * @flags: See kmalloc(). + * @nodeid: node number of the target node. + * + * Identical to kmem_cache_alloc but it will allocate memory on the given + * node, which can improve the performance for cpu bound structures. + * + * Fallback to other node is possible if __GFP_THISNODE is not set. + */ void *kmem_cache_alloc_node(struct kmem_cache *cachep, gfp_t flags, int nodeid) { void *ret = slab_alloc_node(cachep, flags, nodeid, _RET_IP_); From 86eda90eaa0ed380794d8c0a5c8ab3913cdea8e2 Mon Sep 17 00:00:00 2001 From: Philipp Zabel Date: Thu, 23 May 2013 10:42:57 -0300 Subject: [PATCH 0076/1048] [media] coda: simplify parameter buffer setup code Signed-off-by: Philipp Zabel Signed-off-by: Kamil Debski Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/coda.c | 51 ++++++++++++++++------------------- 1 file changed, 23 insertions(+), 28 deletions(-) diff --git a/drivers/media/platform/coda.c b/drivers/media/platform/coda.c index ba99e2fb0f85..366318d87887 100644 --- a/drivers/media/platform/coda.c +++ b/drivers/media/platform/coda.c @@ -905,21 +905,34 @@ static void coda_free_framebuffers(struct coda_ctx *ctx) } } +static void coda_parabuf_write(struct coda_ctx *ctx, int index, u32 value) +{ + struct coda_dev *dev = ctx->dev; + u32 *p = ctx->parabuf.vaddr; + + if (dev->devtype->product == CODA_DX6) + p[index] = value; + else + p[index ^ 1] = value; +} + static int coda_alloc_framebuffers(struct coda_ctx *ctx, struct coda_q_data *q_data, u32 fourcc) { struct coda_dev *dev = ctx->dev; int height = q_data->height; - int width = q_data->width; - u32 *p; + dma_addr_t paddr; + int ysize; int i; + ysize = round_up(q_data->width, 8) * height; + /* Allocate frame buffers */ ctx->num_internal_frames = CODA_MAX_FRAMEBUFFERS; for (i = 0; i < ctx->num_internal_frames; i++) { ctx->internal_frames[i].size = q_data->sizeimage; if (fourcc == V4L2_PIX_FMT_H264 && dev->devtype->product != CODA_DX6) - ctx->internal_frames[i].size += width / 2 * height / 2; + ctx->internal_frames[i].size += ysize/4; ctx->internal_frames[i].vaddr = dma_alloc_coherent( &dev->plat_dev->dev, ctx->internal_frames[i].size, &ctx->internal_frames[i].paddr, GFP_KERNEL); @@ -930,32 +943,14 @@ static int coda_alloc_framebuffers(struct coda_ctx *ctx, struct coda_q_data *q_d } /* Register frame buffers in the parameter buffer */ - p = ctx->parabuf.vaddr; + for (i = 0; i < ctx->num_internal_frames; i++) { + paddr = ctx->internal_frames[i].paddr; + coda_parabuf_write(ctx, i * 3 + 0, paddr); /* Y */ + coda_parabuf_write(ctx, i * 3 + 1, paddr + ysize); /* Cb */ + coda_parabuf_write(ctx, i * 3 + 2, paddr + ysize + ysize/4); /* Cr */ - if (dev->devtype->product == CODA_DX6) { - for (i = 0; i < ctx->num_internal_frames; i++) { - p[i * 3] = ctx->internal_frames[i].paddr; /* Y */ - p[i * 3 + 1] = p[i * 3] + width * height; /* Cb */ - p[i * 3 + 2] = p[i * 3 + 1] + width / 2 * height / 2; /* Cr */ - } - } else { - for (i = 0; i < ctx->num_internal_frames; i += 2) { - p[i * 3 + 1] = ctx->internal_frames[i].paddr; /* Y */ - p[i * 3] = p[i * 3 + 1] + width * height; /* Cb */ - p[i * 3 + 3] = p[i * 3] + (width / 2) * (height / 2); /* Cr */ - - if (fourcc == V4L2_PIX_FMT_H264) - p[96 + i + 1] = p[i * 3 + 3] + (width / 2) * (height / 2); - - if (i + 1 < ctx->num_internal_frames) { - p[i * 3 + 2] = ctx->internal_frames[i+1].paddr; /* Y */ - p[i * 3 + 5] = p[i * 3 + 2] + width * height ; /* Cb */ - p[i * 3 + 4] = p[i * 3 + 5] + (width / 2) * (height / 2); /* Cr */ - - if (fourcc == V4L2_PIX_FMT_H264) - p[96 + i] = p[i * 3 + 4] + (width / 2) * (height / 2); - } - } + if (dev->devtype->product != CODA_DX6 && fourcc == V4L2_PIX_FMT_H264) + coda_parabuf_write(ctx, 96 + i, ctx->internal_frames[i].paddr + ysize + ysize/4 + ysize/4); } return 0; From b96904e50a70618e2c3d44d267706728ca741a4c Mon Sep 17 00:00:00 2001 From: Philipp Zabel Date: Thu, 23 May 2013 10:42:58 -0300 Subject: [PATCH 0077/1048] [media] coda: per-product list of codecs instead of list of formats This patch adds a list of supported codecs per device type which is used to determine the allowed pixel formats and maximum frame sizes depending on the possible codecs. It allows frame sizes larger than 720 x 576 on CODA7 and adds support for the YVU420 (planar YUV 4:2:0 with switched Cb and Cr) format. Other uncompressed formats that could be added in the future are the chroma interleaved NV12 and NV21 formats and the multiplanar variants YUV420M, YVU420M, NV12M, and NV21M. Further, rawstreamon is renamed to streamon_out and compstreamon is renamed to streamon_cap in preparation for decoding support. The maximum encoded frame buffer size is increased to 1 MiB. Instead of tracking inst_type and codec across S_FMT calls, set the codec and inst_type in start_streaming. Signed-off-by: Philipp Zabel Signed-off-by: Kamil Debski Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/coda.c | 343 +++++++++++++++++++--------------- drivers/media/platform/coda.h | 3 +- 2 files changed, 193 insertions(+), 153 deletions(-) diff --git a/drivers/media/platform/coda.c b/drivers/media/platform/coda.c index 366318d87887..9b7b69e2fa9f 100644 --- a/drivers/media/platform/coda.c +++ b/drivers/media/platform/coda.c @@ -49,16 +49,14 @@ #define CODA_MAX_FRAMEBUFFERS 2 -#define MAX_W 720 -#define MAX_H 576 -#define CODA_MAX_FRAME_SIZE 0x90000 +#define MAX_W 8192 +#define MAX_H 8192 +#define CODA_MAX_FRAME_SIZE 0x100000 #define FMO_SLICE_SAVE_BUF_SIZE (32) #define CODA_DEFAULT_GAMMA 4096 #define MIN_W 176 #define MIN_H 144 -#define MAX_W 720 -#define MAX_H 576 #define S_ALIGN 1 /* multiple of 2 */ #define W_ALIGN 1 /* multiple of 2 */ @@ -75,11 +73,6 @@ enum { V4L2_M2M_DST = 1, }; -enum coda_fmt_type { - CODA_FMT_ENC, - CODA_FMT_RAW, -}; - enum coda_inst_type { CODA_INST_ENCODER, CODA_INST_DECODER, @@ -93,14 +86,21 @@ enum coda_product { struct coda_fmt { char *name; u32 fourcc; - enum coda_fmt_type type; +}; + +struct coda_codec { + u32 mode; + u32 src_fourcc; + u32 dst_fourcc; + u32 max_w; + u32 max_h; }; struct coda_devtype { char *firmware; enum coda_product product; - struct coda_fmt *formats; - unsigned int num_formats; + struct coda_codec *codecs; + unsigned int num_codecs; size_t workbuf_size; }; @@ -109,7 +109,7 @@ struct coda_q_data { unsigned int width; unsigned int height; unsigned int sizeimage; - struct coda_fmt *fmt; + unsigned int fourcc; }; struct coda_aux_buf { @@ -164,11 +164,12 @@ struct coda_ctx { struct coda_dev *dev; struct list_head list; int aborting; - int rawstreamon; - int compstreamon; + int streamon_out; + int streamon_cap; u32 isequence; struct coda_q_data q_data[2]; enum coda_inst_type inst_type; + struct coda_codec *codec; enum v4l2_colorspace colorspace; struct coda_params params; struct v4l2_m2m_ctx *m2m_ctx; @@ -257,62 +258,89 @@ static struct coda_q_data *get_q_data(struct coda_ctx *ctx, } /* - * Add one array of supported formats for each version of Coda: - * i.MX27 -> codadx6 - * i.MX51 -> coda7 - * i.MX6 -> coda960 + * Array of all formats supported by any version of Coda: */ -static struct coda_fmt codadx6_formats[] = { +static struct coda_fmt coda_formats[] = { { - .name = "YUV 4:2:0 Planar", + .name = "YUV 4:2:0 Planar, YCbCr", .fourcc = V4L2_PIX_FMT_YUV420, - .type = CODA_FMT_RAW, + }, + { + .name = "YUV 4:2:0 Planar, YCrCb", + .fourcc = V4L2_PIX_FMT_YVU420, }, { .name = "H264 Encoded Stream", .fourcc = V4L2_PIX_FMT_H264, - .type = CODA_FMT_ENC, }, { .name = "MPEG4 Encoded Stream", .fourcc = V4L2_PIX_FMT_MPEG4, - .type = CODA_FMT_ENC, }, }; -static struct coda_fmt coda7_formats[] = { - { - .name = "YUV 4:2:0 Planar", - .fourcc = V4L2_PIX_FMT_YUV420, - .type = CODA_FMT_RAW, - }, - { - .name = "H264 Encoded Stream", - .fourcc = V4L2_PIX_FMT_H264, - .type = CODA_FMT_ENC, - }, - { - .name = "MPEG4 Encoded Stream", - .fourcc = V4L2_PIX_FMT_MPEG4, - .type = CODA_FMT_ENC, - }, +#define CODA_CODEC(mode, src_fourcc, dst_fourcc, max_w, max_h) \ + { mode, src_fourcc, dst_fourcc, max_w, max_h } + +/* + * Arrays of codecs supported by each given version of Coda: + * i.MX27 -> codadx6 + * i.MX5x -> coda7 + * i.MX6 -> coda960 + * Use V4L2_PIX_FMT_YUV420 as placeholder for all supported YUV 4:2:0 variants + */ +static struct coda_codec codadx6_codecs[] = { + CODA_CODEC(CODADX6_MODE_ENCODE_H264, V4L2_PIX_FMT_YUV420, V4L2_PIX_FMT_H264, 720, 576), + CODA_CODEC(CODADX6_MODE_ENCODE_MP4, V4L2_PIX_FMT_YUV420, V4L2_PIX_FMT_MPEG4, 720, 576), }; -static struct coda_fmt *find_format(struct coda_dev *dev, struct v4l2_format *f) +static struct coda_codec coda7_codecs[] = { + CODA_CODEC(CODA7_MODE_ENCODE_H264, V4L2_PIX_FMT_YUV420, V4L2_PIX_FMT_H264, 1280, 720), + CODA_CODEC(CODA7_MODE_ENCODE_MP4, V4L2_PIX_FMT_YUV420, V4L2_PIX_FMT_MPEG4, 1280, 720), +}; + +static bool coda_format_is_yuv(u32 fourcc) { - struct coda_fmt *formats = dev->devtype->formats; - int num_formats = dev->devtype->num_formats; - unsigned int k; + switch (fourcc) { + case V4L2_PIX_FMT_YUV420: + case V4L2_PIX_FMT_YVU420: + return true; + default: + return false; + } +} - for (k = 0; k < num_formats; k++) { - if (formats[k].fourcc == f->fmt.pix.pixelformat) +/* + * Normalize all supported YUV 4:2:0 formats to the value used in the codec + * tables. + */ +static u32 coda_format_normalize_yuv(u32 fourcc) +{ + return coda_format_is_yuv(fourcc) ? V4L2_PIX_FMT_YUV420 : fourcc; +} + +static struct coda_codec *coda_find_codec(struct coda_dev *dev, int src_fourcc, + int dst_fourcc) +{ + struct coda_codec *codecs = dev->devtype->codecs; + int num_codecs = dev->devtype->num_codecs; + int k; + + src_fourcc = coda_format_normalize_yuv(src_fourcc); + dst_fourcc = coda_format_normalize_yuv(dst_fourcc); + if (src_fourcc == dst_fourcc) + return NULL; + + for (k = 0; k < num_codecs; k++) { + if (codecs[k].src_fourcc == src_fourcc && + codecs[k].dst_fourcc == dst_fourcc) break; } - if (k == num_formats) + if (k == num_codecs) return NULL; - return &formats[k]; + return &codecs[k]; } /* @@ -337,17 +365,34 @@ static int vidioc_querycap(struct file *file, void *priv, } static int enum_fmt(void *priv, struct v4l2_fmtdesc *f, - enum coda_fmt_type type) + enum v4l2_buf_type type) { struct coda_ctx *ctx = fh_to_ctx(priv); - struct coda_dev *dev = ctx->dev; - struct coda_fmt *formats = dev->devtype->formats; + struct coda_codec *codecs = ctx->dev->devtype->codecs; + struct coda_fmt *formats = coda_formats; struct coda_fmt *fmt; - int num_formats = dev->devtype->num_formats; - int i, num = 0; + int num_codecs = ctx->dev->devtype->num_codecs; + int num_formats = ARRAY_SIZE(coda_formats); + int i, k, num = 0; for (i = 0; i < num_formats; i++) { - if (formats[i].type == type) { + /* Both uncompressed formats are always supported */ + if (coda_format_is_yuv(formats[i].fourcc)) { + if (num == f->index) + break; + ++num; + continue; + } + /* Compressed formats may be supported, check the codec list */ + for (k = 0; k < num_codecs; k++) { + if (type == V4L2_BUF_TYPE_VIDEO_CAPTURE && + formats[i].fourcc == codecs[k].dst_fourcc) + break; + if (type == V4L2_BUF_TYPE_VIDEO_OUTPUT && + formats[i].fourcc == codecs[k].src_fourcc) + break; + } + if (k < num_codecs) { if (num == f->index) break; ++num; @@ -368,13 +413,13 @@ static int enum_fmt(void *priv, struct v4l2_fmtdesc *f, static int vidioc_enum_fmt_vid_cap(struct file *file, void *priv, struct v4l2_fmtdesc *f) { - return enum_fmt(priv, f, CODA_FMT_ENC); + return enum_fmt(priv, f, V4L2_BUF_TYPE_VIDEO_CAPTURE); } static int vidioc_enum_fmt_vid_out(struct file *file, void *priv, struct v4l2_fmtdesc *f) { - return enum_fmt(priv, f, CODA_FMT_RAW); + return enum_fmt(priv, f, V4L2_BUF_TYPE_VIDEO_OUTPUT); } static int vidioc_g_fmt(struct file *file, void *priv, struct v4l2_format *f) @@ -390,10 +435,10 @@ static int vidioc_g_fmt(struct file *file, void *priv, struct v4l2_format *f) q_data = get_q_data(ctx, f->type); f->fmt.pix.field = V4L2_FIELD_NONE; - f->fmt.pix.pixelformat = q_data->fmt->fourcc; + f->fmt.pix.pixelformat = q_data->fourcc; f->fmt.pix.width = q_data->width; f->fmt.pix.height = q_data->height; - if (f->fmt.pix.pixelformat == V4L2_PIX_FMT_YUV420) + if (coda_format_is_yuv(f->fmt.pix.pixelformat)) f->fmt.pix.bytesperline = round_up(f->fmt.pix.width, 2); else /* encoded formats h.264/mpeg4 */ f->fmt.pix.bytesperline = 0; @@ -404,8 +449,9 @@ static int vidioc_g_fmt(struct file *file, void *priv, struct v4l2_format *f) return 0; } -static int vidioc_try_fmt(struct coda_dev *dev, struct v4l2_format *f) +static int vidioc_try_fmt(struct coda_codec *codec, struct v4l2_format *f) { + unsigned int max_w, max_h; enum v4l2_field field; field = f->fmt.pix.field; @@ -418,10 +464,18 @@ static int vidioc_try_fmt(struct coda_dev *dev, struct v4l2_format *f) * if any of the dimensions is unsupported */ f->fmt.pix.field = field; - if (f->fmt.pix.pixelformat == V4L2_PIX_FMT_YUV420) { - v4l_bound_align_image(&f->fmt.pix.width, MIN_W, MAX_W, - W_ALIGN, &f->fmt.pix.height, - MIN_H, MAX_H, H_ALIGN, S_ALIGN); + if (codec) { + max_w = codec->max_w; + max_h = codec->max_h; + } else { + max_w = MAX_W; + max_h = MAX_H; + } + v4l_bound_align_image(&f->fmt.pix.width, MIN_W, max_w, + W_ALIGN, &f->fmt.pix.height, + MIN_H, max_h, H_ALIGN, S_ALIGN); + + if (coda_format_is_yuv(f->fmt.pix.pixelformat)) { /* Frame stride must be multiple of 8 */ f->fmt.pix.bytesperline = round_up(f->fmt.pix.width, 8); f->fmt.pix.sizeimage = f->fmt.pix.bytesperline * @@ -437,57 +491,38 @@ static int vidioc_try_fmt(struct coda_dev *dev, struct v4l2_format *f) static int vidioc_try_fmt_vid_cap(struct file *file, void *priv, struct v4l2_format *f) { - int ret; - struct coda_fmt *fmt; struct coda_ctx *ctx = fh_to_ctx(priv); + struct coda_codec *codec = NULL; - fmt = find_format(ctx->dev, f); - /* - * Since decoding support is not implemented yet do not allow - * CODA_FMT_RAW formats in the capture interface. - */ - if (!fmt || !(fmt->type == CODA_FMT_ENC)) - f->fmt.pix.pixelformat = V4L2_PIX_FMT_H264; + /* Determine codec by the encoded format */ + codec = coda_find_codec(ctx->dev, V4L2_PIX_FMT_YUV420, + f->fmt.pix.pixelformat); f->fmt.pix.colorspace = ctx->colorspace; - ret = vidioc_try_fmt(ctx->dev, f); - if (ret < 0) - return ret; - - return 0; + return vidioc_try_fmt(codec, f); } static int vidioc_try_fmt_vid_out(struct file *file, void *priv, struct v4l2_format *f) { struct coda_ctx *ctx = fh_to_ctx(priv); - struct coda_fmt *fmt; - int ret; + struct coda_codec *codec; - fmt = find_format(ctx->dev, f); - /* - * Since decoding support is not implemented yet do not allow - * CODA_FMT formats in the capture interface. - */ - if (!fmt || !(fmt->type == CODA_FMT_RAW)) - f->fmt.pix.pixelformat = V4L2_PIX_FMT_YUV420; + /* Determine codec by encoded format, returns NULL if raw or invalid */ + codec = coda_find_codec(ctx->dev, f->fmt.pix.pixelformat, + V4L2_PIX_FMT_YUV420); if (!f->fmt.pix.colorspace) f->fmt.pix.colorspace = V4L2_COLORSPACE_REC709; - ret = vidioc_try_fmt(ctx->dev, f); - if (ret < 0) - return ret; - - return 0; + return vidioc_try_fmt(codec, f); } static int vidioc_s_fmt(struct coda_ctx *ctx, struct v4l2_format *f) { struct coda_q_data *q_data; struct vb2_queue *vq; - int ret; vq = v4l2_m2m_get_vq(ctx->m2m_ctx, f->type); if (!vq) @@ -502,18 +537,14 @@ static int vidioc_s_fmt(struct coda_ctx *ctx, struct v4l2_format *f) return -EBUSY; } - ret = vidioc_try_fmt(ctx->dev, f); - if (ret) - return ret; - - q_data->fmt = find_format(ctx->dev, f); + q_data->fourcc = f->fmt.pix.pixelformat; q_data->width = f->fmt.pix.width; q_data->height = f->fmt.pix.height; q_data->sizeimage = f->fmt.pix.sizeimage; v4l2_dbg(1, coda_debug, &ctx->dev->v4l2_dev, "Setting format for type %d, wxh: %dx%d, fmt: %d\n", - f->type, q_data->width, q_data->height, q_data->fmt->fourcc); + f->type, q_data->width, q_data->height, q_data->fourcc); return 0; } @@ -521,13 +552,14 @@ static int vidioc_s_fmt(struct coda_ctx *ctx, struct v4l2_format *f) static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, struct v4l2_format *f) { + struct coda_ctx *ctx = fh_to_ctx(priv); int ret; ret = vidioc_try_fmt_vid_cap(file, priv, f); if (ret) return ret; - return vidioc_s_fmt(fh_to_ctx(priv), f); + return vidioc_s_fmt(ctx, f); } static int vidioc_s_fmt_vid_out(struct file *file, void *priv, @@ -644,7 +676,7 @@ static void coda_device_run(void *m2m_priv) dst_buf = v4l2_m2m_next_dst_buf(ctx->m2m_ctx); q_data_src = get_q_data(ctx, V4L2_BUF_TYPE_VIDEO_OUTPUT); q_data_dst = get_q_data(ctx, V4L2_BUF_TYPE_VIDEO_CAPTURE); - dst_fourcc = q_data_dst->fmt->fourcc; + dst_fourcc = q_data_dst->fourcc; src_buf->v4l2_buf.sequence = ctx->isequence; dst_buf->v4l2_buf.sequence = ctx->isequence; @@ -726,9 +758,20 @@ static void coda_device_run(void *m2m_priv) picture_y = vb2_dma_contig_plane_dma_addr(src_buf, 0); - picture_cb = picture_y + q_data_src->width * q_data_src->height; - picture_cr = picture_cb + q_data_src->width / 2 * - q_data_src->height / 2; + switch (q_data_src->fourcc) { + case V4L2_PIX_FMT_YVU420: + /* Switch Cb and Cr for YVU420 format */ + picture_cr = picture_y + q_data_src->width * q_data_src->height; + picture_cb = picture_cr + q_data_src->width / 2 * + q_data_src->height / 2; + break; + case V4L2_PIX_FMT_YUV420: + default: + picture_cb = picture_y + q_data_src->width * q_data_src->height; + picture_cr = picture_cb + q_data_src->width / 2 * + q_data_src->height / 2; + break; + } coda_write(dev, picture_y, CODA_CMD_ENC_PIC_SRC_ADDR_Y); coda_write(dev, picture_cb, CODA_CMD_ENC_PIC_SRC_ADDR_CB); @@ -810,7 +853,12 @@ static struct v4l2_m2m_ops coda_m2m_ops = { static void set_default_params(struct coda_ctx *ctx) { - struct coda_dev *dev = ctx->dev; + int max_w; + int max_h; + + ctx->codec = &ctx->dev->devtype->codecs[0]; + max_w = ctx->codec->max_w; + max_h = ctx->codec->max_h; ctx->params.codec_mode = CODA_MODE_INVALID; ctx->colorspace = V4L2_COLORSPACE_REC709; @@ -818,13 +866,13 @@ static void set_default_params(struct coda_ctx *ctx) ctx->aborting = 0; /* Default formats for output and input queues */ - ctx->q_data[V4L2_M2M_SRC].fmt = &dev->devtype->formats[0]; - ctx->q_data[V4L2_M2M_DST].fmt = &dev->devtype->formats[1]; - ctx->q_data[V4L2_M2M_SRC].width = MAX_W; - ctx->q_data[V4L2_M2M_SRC].height = MAX_H; - ctx->q_data[V4L2_M2M_SRC].sizeimage = (MAX_W * MAX_H * 3) / 2; - ctx->q_data[V4L2_M2M_DST].width = MAX_W; - ctx->q_data[V4L2_M2M_DST].height = MAX_H; + ctx->q_data[V4L2_M2M_SRC].fourcc = ctx->codec->src_fourcc; + ctx->q_data[V4L2_M2M_DST].fourcc = ctx->codec->dst_fourcc; + ctx->q_data[V4L2_M2M_SRC].width = max_w; + ctx->q_data[V4L2_M2M_SRC].height = max_h; + ctx->q_data[V4L2_M2M_SRC].sizeimage = (max_w * max_h * 3) / 2; + ctx->q_data[V4L2_M2M_DST].width = max_w; + ctx->q_data[V4L2_M2M_DST].height = max_h; ctx->q_data[V4L2_M2M_DST].sizeimage = CODA_MAX_FRAME_SIZE; } @@ -990,37 +1038,36 @@ static int coda_start_streaming(struct vb2_queue *q, unsigned int count) return -EINVAL; if (q->type == V4L2_BUF_TYPE_VIDEO_OUTPUT) - ctx->rawstreamon = 1; + ctx->streamon_out = 1; else - ctx->compstreamon = 1; + ctx->streamon_cap = 1; - /* Don't start the coda unless both queues are on */ - if (!(ctx->rawstreamon & ctx->compstreamon)) - return 0; + q_data_src = get_q_data(ctx, V4L2_BUF_TYPE_VIDEO_OUTPUT); + if (ctx->streamon_out) { + if (coda_format_is_yuv(q_data_src->fourcc)) + ctx->inst_type = CODA_INST_ENCODER; + else + ctx->inst_type = CODA_INST_DECODER; + } if (coda_isbusy(dev)) if (wait_for_completion_interruptible_timeout(&dev->done, HZ) <= 0) return -EBUSY; - ctx->gopcounter = ctx->params.gop_size - 1; + /* Don't start the coda unless both queues are on */ + if (!(ctx->streamon_out & ctx->streamon_cap)) + return 0; - q_data_src = get_q_data(ctx, V4L2_BUF_TYPE_VIDEO_OUTPUT); + ctx->gopcounter = ctx->params.gop_size - 1; buf = v4l2_m2m_next_dst_buf(ctx->m2m_ctx); bitstream_buf = vb2_dma_contig_plane_dma_addr(buf, 0); q_data_dst = get_q_data(ctx, V4L2_BUF_TYPE_VIDEO_CAPTURE); bitstream_size = q_data_dst->sizeimage; - dst_fourcc = q_data_dst->fmt->fourcc; + dst_fourcc = q_data_dst->fourcc; - /* Find out whether coda must encode or decode */ - if (q_data_src->fmt->type == CODA_FMT_RAW && - q_data_dst->fmt->type == CODA_FMT_ENC) { - ctx->inst_type = CODA_INST_ENCODER; - } else if (q_data_src->fmt->type == CODA_FMT_ENC && - q_data_dst->fmt->type == CODA_FMT_RAW) { - ctx->inst_type = CODA_INST_DECODER; - v4l2_err(v4l2_dev, "decoding not supported.\n"); - return -EINVAL; - } else { + ctx->codec = coda_find_codec(ctx->dev, q_data_src->fourcc, + q_data_dst->fourcc); + if (!ctx->codec) { v4l2_err(v4l2_dev, "couldn't tell instance type.\n"); return -EINVAL; } @@ -1051,31 +1098,23 @@ static int coda_start_streaming(struct vb2_queue *q, unsigned int count) switch (dev->devtype->product) { case CODA_DX6: value = (q_data_src->width & CODADX6_PICWIDTH_MASK) << CODADX6_PICWIDTH_OFFSET; + value |= (q_data_src->height & CODADX6_PICHEIGHT_MASK) << CODA_PICHEIGHT_OFFSET; break; default: value = (q_data_src->width & CODA7_PICWIDTH_MASK) << CODA7_PICWIDTH_OFFSET; + value |= (q_data_src->height & CODA7_PICHEIGHT_MASK) << CODA_PICHEIGHT_OFFSET; } - value |= (q_data_src->height & CODA_PICHEIGHT_MASK) << CODA_PICHEIGHT_OFFSET; coda_write(dev, value, CODA_CMD_ENC_SEQ_SRC_SIZE); coda_write(dev, ctx->params.framerate, CODA_CMD_ENC_SEQ_SRC_F_RATE); + ctx->params.codec_mode = ctx->codec->mode; switch (dst_fourcc) { case V4L2_PIX_FMT_MPEG4: - if (dev->devtype->product == CODA_DX6) - ctx->params.codec_mode = CODADX6_MODE_ENCODE_MP4; - else - ctx->params.codec_mode = CODA7_MODE_ENCODE_MP4; - coda_write(dev, CODA_STD_MPEG4, CODA_CMD_ENC_SEQ_COD_STD); coda_write(dev, 0, CODA_CMD_ENC_SEQ_MP4_PARA); break; case V4L2_PIX_FMT_H264: - if (dev->devtype->product == CODA_DX6) - ctx->params.codec_mode = CODADX6_MODE_ENCODE_H264; - else - ctx->params.codec_mode = CODA7_MODE_ENCODE_H264; - coda_write(dev, CODA_STD_H264, CODA_CMD_ENC_SEQ_COD_STD); coda_write(dev, 0, CODA_CMD_ENC_SEQ_264_PARA); break; @@ -1274,15 +1313,15 @@ static int coda_stop_streaming(struct vb2_queue *q) if (q->type == V4L2_BUF_TYPE_VIDEO_OUTPUT) { v4l2_dbg(1, coda_debug, &ctx->dev->v4l2_dev, "%s: output\n", __func__); - ctx->rawstreamon = 0; + ctx->streamon_out = 0; } else { v4l2_dbg(1, coda_debug, &ctx->dev->v4l2_dev, "%s: capture\n", __func__); - ctx->compstreamon = 0; + ctx->streamon_cap = 0; } /* Don't stop the coda unless both queues are off */ - if (ctx->rawstreamon || ctx->compstreamon) + if (ctx->streamon_out || ctx->streamon_cap) return 0; if (coda_isbusy(dev)) { @@ -1915,16 +1954,16 @@ enum coda_platform { static const struct coda_devtype coda_devdata[] = { [CODA_IMX27] = { - .firmware = "v4l-codadx6-imx27.bin", - .product = CODA_DX6, - .formats = codadx6_formats, - .num_formats = ARRAY_SIZE(codadx6_formats), + .firmware = "v4l-codadx6-imx27.bin", + .product = CODA_DX6, + .codecs = codadx6_codecs, + .num_codecs = ARRAY_SIZE(codadx6_codecs), }, [CODA_IMX53] = { - .firmware = "v4l-coda7541-imx53.bin", - .product = CODA_7541, - .formats = coda7_formats, - .num_formats = ARRAY_SIZE(coda7_formats), + .firmware = "v4l-coda7541-imx53.bin", + .product = CODA_7541, + .codecs = coda7_codecs, + .num_codecs = ARRAY_SIZE(coda7_codecs), }, }; diff --git a/drivers/media/platform/coda.h b/drivers/media/platform/coda.h index 3c350acd5faa..ace0bf0a3b9c 100644 --- a/drivers/media/platform/coda.h +++ b/drivers/media/platform/coda.h @@ -113,7 +113,8 @@ #define CODADX6_PICWIDTH_OFFSET 10 #define CODADX6_PICWIDTH_MASK 0x3ff #define CODA_PICHEIGHT_OFFSET 0 -#define CODA_PICHEIGHT_MASK 0x3ff +#define CODADX6_PICHEIGHT_MASK 0x3ff +#define CODA7_PICHEIGHT_MASK 0xffff #define CODA_CMD_ENC_SEQ_SRC_F_RATE 0x194 #define CODA_CMD_ENC_SEQ_MP4_PARA 0x198 #define CODA_MP4PARAM_VERID_OFFSET 6 From d35167a1d69ae027615d4345a678555bf1c6fed6 Mon Sep 17 00:00:00 2001 From: Philipp Zabel Date: Thu, 23 May 2013 10:42:59 -0300 Subject: [PATCH 0078/1048] [media] coda: add coda_encode_header helper function In preparation for CODA7541 and CODA960 multi-stream support and for replacement of the completion with a mutex lock, consolidate the header encoding in a helper function. Signed-off-by: Philipp Zabel Signed-off-by: Kamil Debski Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/coda.c | 108 ++++++++++++++++------------------ 1 file changed, 51 insertions(+), 57 deletions(-) diff --git a/drivers/media/platform/coda.c b/drivers/media/platform/coda.c index 9b7b69e2fa9f..34d6fd6c0517 100644 --- a/drivers/media/platform/coda.c +++ b/drivers/media/platform/coda.c @@ -1022,6 +1022,28 @@ static int coda_h264_padding(int size, char *p) return nal_size; } +static int coda_encode_header(struct coda_ctx *ctx, struct vb2_buffer *buf, + int header_code, u8 *header, int *size) +{ + struct coda_dev *dev = ctx->dev; + int ret; + + coda_write(dev, vb2_dma_contig_plane_dma_addr(buf, 0), + CODA_CMD_ENC_HEADER_BB_START); + coda_write(dev, vb2_plane_size(buf, 0), CODA_CMD_ENC_HEADER_BB_SIZE); + coda_write(dev, header_code, CODA_CMD_ENC_HEADER_CODE); + ret = coda_command_sync(ctx, CODA_COMMAND_ENCODE_HEADER); + if (ret < 0) { + v4l2_err(&dev->v4l2_dev, "CODA_COMMAND_ENCODE_HEADER timeout\n"); + return ret; + } + *size = coda_read(dev, CODA_REG_BIT_WR_PTR(ctx->idx)) - + coda_read(dev, CODA_CMD_ENC_HEADER_BB_START); + memcpy(header, vb2_plane_vaddr(buf, 0), *size); + + return 0; +} + static int coda_start_streaming(struct vb2_queue *q, unsigned int count) { struct coda_ctx *ctx = vb2_get_drv_priv(q); @@ -1032,7 +1054,7 @@ static int coda_start_streaming(struct vb2_queue *q, unsigned int count) struct vb2_buffer *buf; u32 dst_fourcc; u32 value; - int ret; + int ret = 0; if (count < 1) return -EINVAL; @@ -1219,33 +1241,22 @@ static int coda_start_streaming(struct vb2_queue *q, unsigned int count) * Get SPS in the first frame and copy it to an * intermediate buffer. */ - coda_write(dev, vb2_dma_contig_plane_dma_addr(buf, 0), CODA_CMD_ENC_HEADER_BB_START); - coda_write(dev, bitstream_size, CODA_CMD_ENC_HEADER_BB_SIZE); - coda_write(dev, CODA_HEADER_H264_SPS, CODA_CMD_ENC_HEADER_CODE); - if (coda_command_sync(ctx, CODA_COMMAND_ENCODE_HEADER)) { - v4l2_err(v4l2_dev, "CODA_COMMAND_ENCODE_HEADER timeout\n"); - return -ETIMEDOUT; - } - ctx->vpu_header_size[0] = coda_read(dev, CODA_REG_BIT_WR_PTR(ctx->idx)) - - coda_read(dev, CODA_CMD_ENC_HEADER_BB_START); - memcpy(&ctx->vpu_header[0][0], vb2_plane_vaddr(buf, 0), - ctx->vpu_header_size[0]); + ret = coda_encode_header(ctx, buf, CODA_HEADER_H264_SPS, + &ctx->vpu_header[0][0], + &ctx->vpu_header_size[0]); + if (ret < 0) + goto out; /* * Get PPS in the first frame and copy it to an * intermediate buffer. */ - coda_write(dev, vb2_dma_contig_plane_dma_addr(buf, 0), CODA_CMD_ENC_HEADER_BB_START); - coda_write(dev, bitstream_size, CODA_CMD_ENC_HEADER_BB_SIZE); - coda_write(dev, CODA_HEADER_H264_PPS, CODA_CMD_ENC_HEADER_CODE); - if (coda_command_sync(ctx, CODA_COMMAND_ENCODE_HEADER)) { - v4l2_err(v4l2_dev, "CODA_COMMAND_ENCODE_HEADER timeout\n"); - return -ETIMEDOUT; - } - ctx->vpu_header_size[1] = coda_read(dev, CODA_REG_BIT_WR_PTR(ctx->idx)) - - coda_read(dev, CODA_CMD_ENC_HEADER_BB_START); - memcpy(&ctx->vpu_header[1][0], vb2_plane_vaddr(buf, 0), - ctx->vpu_header_size[1]); + ret = coda_encode_header(ctx, buf, CODA_HEADER_H264_PPS, + &ctx->vpu_header[1][0], + &ctx->vpu_header_size[1]); + if (ret < 0) + goto out; + /* * Length of H.264 headers is variable and thus it might not be * aligned for the coda to append the encoded frame. In that is @@ -1261,48 +1272,31 @@ static int coda_start_streaming(struct vb2_queue *q, unsigned int count) * Get VOS in the first frame and copy it to an * intermediate buffer */ - coda_write(dev, vb2_dma_contig_plane_dma_addr(buf, 0), CODA_CMD_ENC_HEADER_BB_START); - coda_write(dev, bitstream_size, CODA_CMD_ENC_HEADER_BB_SIZE); - coda_write(dev, CODA_HEADER_MP4V_VOS, CODA_CMD_ENC_HEADER_CODE); - if (coda_command_sync(ctx, CODA_COMMAND_ENCODE_HEADER)) { - v4l2_err(v4l2_dev, "CODA_COMMAND_ENCODE_HEADER timeout\n"); - return -ETIMEDOUT; - } - ctx->vpu_header_size[0] = coda_read(dev, CODA_REG_BIT_WR_PTR(ctx->idx)) - - coda_read(dev, CODA_CMD_ENC_HEADER_BB_START); - memcpy(&ctx->vpu_header[0][0], vb2_plane_vaddr(buf, 0), - ctx->vpu_header_size[0]); + ret = coda_encode_header(ctx, buf, CODA_HEADER_MP4V_VOS, + &ctx->vpu_header[0][0], + &ctx->vpu_header_size[0]); + if (ret < 0) + goto out; - coda_write(dev, vb2_dma_contig_plane_dma_addr(buf, 0), CODA_CMD_ENC_HEADER_BB_START); - coda_write(dev, bitstream_size, CODA_CMD_ENC_HEADER_BB_SIZE); - coda_write(dev, CODA_HEADER_MP4V_VIS, CODA_CMD_ENC_HEADER_CODE); - if (coda_command_sync(ctx, CODA_COMMAND_ENCODE_HEADER)) { - v4l2_err(v4l2_dev, "CODA_COMMAND_ENCODE_HEADER failed\n"); - return -ETIMEDOUT; - } - ctx->vpu_header_size[1] = coda_read(dev, CODA_REG_BIT_WR_PTR(ctx->idx)) - - coda_read(dev, CODA_CMD_ENC_HEADER_BB_START); - memcpy(&ctx->vpu_header[1][0], vb2_plane_vaddr(buf, 0), - ctx->vpu_header_size[1]); + ret = coda_encode_header(ctx, buf, CODA_HEADER_MP4V_VIS, + &ctx->vpu_header[1][0], + &ctx->vpu_header_size[1]); + if (ret < 0) + goto out; - coda_write(dev, vb2_dma_contig_plane_dma_addr(buf, 0), CODA_CMD_ENC_HEADER_BB_START); - coda_write(dev, bitstream_size, CODA_CMD_ENC_HEADER_BB_SIZE); - coda_write(dev, CODA_HEADER_MP4V_VOL, CODA_CMD_ENC_HEADER_CODE); - if (coda_command_sync(ctx, CODA_COMMAND_ENCODE_HEADER)) { - v4l2_err(v4l2_dev, "CODA_COMMAND_ENCODE_HEADER failed\n"); - return -ETIMEDOUT; - } - ctx->vpu_header_size[2] = coda_read(dev, CODA_REG_BIT_WR_PTR(ctx->idx)) - - coda_read(dev, CODA_CMD_ENC_HEADER_BB_START); - memcpy(&ctx->vpu_header[2][0], vb2_plane_vaddr(buf, 0), - ctx->vpu_header_size[2]); + ret = coda_encode_header(ctx, buf, CODA_HEADER_MP4V_VOL, + &ctx->vpu_header[2][0], + &ctx->vpu_header_size[2]); + if (ret < 0) + goto out; break; default: /* No more formats need to save headers at the moment */ break; } - return 0; +out: + return ret; } static int coda_stop_streaming(struct vb2_queue *q) From fcb62825e7289f937f4af26a741e3af8da9242de Mon Sep 17 00:00:00 2001 From: Philipp Zabel Date: Thu, 23 May 2013 10:43:00 -0300 Subject: [PATCH 0079/1048] [media] coda: replace completion with mutex Not only do we need to wait for job completion when we want to call a command on the CODA in start/stop_streaming, we also need to make sure that a new job doesn't start before the command finished. Use a mutex to lock the coda command handling. On timeout, the device_run job must be marked as finished and the mutex released, as otherwise coda_release will block. Signed-off-by: Philipp Zabel Signed-off-by: Kamil Debski Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/coda.c | 66 +++++++++++++++++++---------------- 1 file changed, 35 insertions(+), 31 deletions(-) diff --git a/drivers/media/platform/coda.c b/drivers/media/platform/coda.c index 34d6fd6c0517..f9c4014ee40c 100644 --- a/drivers/media/platform/coda.c +++ b/drivers/media/platform/coda.c @@ -137,12 +137,12 @@ struct coda_dev { spinlock_t irqlock; struct mutex dev_mutex; + struct mutex coda_mutex; struct v4l2_m2m_dev *m2m_dev; struct vb2_alloc_ctx *alloc_ctx; struct list_head instances; unsigned long instance_mask; struct delayed_work timeout; - struct completion done; }; struct coda_params { @@ -672,6 +672,8 @@ static void coda_device_run(void *m2m_priv) u32 pic_stream_buffer_addr, pic_stream_buffer_size; u32 dst_fourcc; + mutex_lock(&dev->coda_mutex); + src_buf = v4l2_m2m_next_src_buf(ctx->m2m_ctx); dst_buf = v4l2_m2m_next_dst_buf(ctx->m2m_ctx); q_data_src = get_q_data(ctx, V4L2_BUF_TYPE_VIDEO_OUTPUT); @@ -792,7 +794,6 @@ static void coda_device_run(void *m2m_priv) /* 1 second timeout in case CODA locks up */ schedule_delayed_work(&dev->timeout, HZ); - INIT_COMPLETION(dev->done); coda_command_async(ctx, CODA_COMMAND_PIC_RUN); } @@ -1072,10 +1073,6 @@ static int coda_start_streaming(struct vb2_queue *q, unsigned int count) ctx->inst_type = CODA_INST_DECODER; } - if (coda_isbusy(dev)) - if (wait_for_completion_interruptible_timeout(&dev->done, HZ) <= 0) - return -EBUSY; - /* Don't start the coda unless both queues are on */ if (!(ctx->streamon_out & ctx->streamon_cap)) return 0; @@ -1098,6 +1095,9 @@ static int coda_start_streaming(struct vb2_queue *q, unsigned int count) v4l2_err(v4l2_dev, "coda is not initialized.\n"); return -EFAULT; } + + mutex_lock(&dev->coda_mutex); + coda_write(dev, ctx->parabuf.paddr, CODA_REG_BIT_PARA_BUF_ADDR); coda_write(dev, bitstream_buf, CODA_REG_BIT_RD_PTR(ctx->idx)); coda_write(dev, bitstream_buf, CODA_REG_BIT_WR_PTR(ctx->idx)); @@ -1143,7 +1143,8 @@ static int coda_start_streaming(struct vb2_queue *q, unsigned int count) default: v4l2_err(v4l2_dev, "dst format (0x%08x) invalid.\n", dst_fourcc); - return -EINVAL; + ret = -EINVAL; + goto out; } switch (ctx->params.slice_mode) { @@ -1206,17 +1207,23 @@ static int coda_start_streaming(struct vb2_queue *q, unsigned int count) } } - if (coda_command_sync(ctx, CODA_COMMAND_SEQ_INIT)) { + ret = coda_command_sync(ctx, CODA_COMMAND_SEQ_INIT); + if (ret < 0) { v4l2_err(v4l2_dev, "CODA_COMMAND_SEQ_INIT timeout\n"); - return -ETIMEDOUT; + goto out; } - if (coda_read(dev, CODA_RET_ENC_SEQ_SUCCESS) == 0) - return -EFAULT; + if (coda_read(dev, CODA_RET_ENC_SEQ_SUCCESS) == 0) { + v4l2_err(v4l2_dev, "CODA_COMMAND_SEQ_INIT failed\n"); + ret = -EFAULT; + goto out; + } ret = coda_alloc_framebuffers(ctx, q_data_src, dst_fourcc); - if (ret < 0) - return ret; + if (ret < 0) { + v4l2_err(v4l2_dev, "failed to allocate framebuffers\n"); + goto out; + } coda_write(dev, ctx->num_internal_frames, CODA_CMD_SET_FRAME_BUF_NUM); coda_write(dev, round_up(q_data_src->width, 8), CODA_CMD_SET_FRAME_BUF_STRIDE); @@ -1228,9 +1235,10 @@ static int coda_start_streaming(struct vb2_queue *q, unsigned int count) coda_write(dev, dev->iram_paddr + 68 * 1024, CODA7_CMD_SET_FRAME_AXI_IPACDC_ADDR); coda_write(dev, 0x0, CODA7_CMD_SET_FRAME_AXI_OVL_ADDR); } - if (coda_command_sync(ctx, CODA_COMMAND_SET_FRAME_BUF)) { + ret = coda_command_sync(ctx, CODA_COMMAND_SET_FRAME_BUF); + if (ret < 0) { v4l2_err(v4l2_dev, "CODA_COMMAND_SET_FRAME_BUF timeout\n"); - return -ETIMEDOUT; + goto out; } /* Save stream headers */ @@ -1296,6 +1304,7 @@ static int coda_start_streaming(struct vb2_queue *q, unsigned int count) } out: + mutex_unlock(&dev->coda_mutex); return ret; } @@ -1318,15 +1327,9 @@ static int coda_stop_streaming(struct vb2_queue *q) if (ctx->streamon_out || ctx->streamon_cap) return 0; - if (coda_isbusy(dev)) { - if (wait_for_completion_interruptible_timeout(&dev->done, HZ) <= 0) { - v4l2_warn(&dev->v4l2_dev, - "%s: timeout, sending SEQ_END anyway\n", __func__); - } - } - cancel_delayed_work(&dev->timeout); + mutex_lock(&dev->coda_mutex); v4l2_dbg(1, coda_debug, &dev->v4l2_dev, "%s: sent command 'SEQ_END' to coda\n", __func__); if (coda_command_sync(ctx, CODA_COMMAND_SEQ_END)) { @@ -1334,6 +1337,7 @@ static int coda_stop_streaming(struct vb2_queue *q) "CODA_COMMAND_SEQ_END failed\n"); return -ETIMEDOUT; } + mutex_unlock(&dev->coda_mutex); coda_free_framebuffers(ctx); @@ -1629,12 +1633,14 @@ static irqreturn_t coda_irq_handler(int irq, void *data) ctx = v4l2_m2m_get_curr_priv(dev->m2m_dev); if (ctx == NULL) { v4l2_err(&dev->v4l2_dev, "Instance released before the end of transaction\n"); + mutex_unlock(&dev->coda_mutex); return IRQ_HANDLED; } if (ctx->aborting) { v4l2_dbg(1, coda_debug, &ctx->dev->v4l2_dev, "task has been aborted\n"); + mutex_unlock(&dev->coda_mutex); return IRQ_HANDLED; } @@ -1644,8 +1650,6 @@ static irqreturn_t coda_irq_handler(int irq, void *data) return IRQ_NONE; } - complete(&dev->done); - src_buf = v4l2_m2m_src_buf_remove(ctx->m2m_ctx); dst_buf = v4l2_m2m_dst_buf_remove(ctx->m2m_ctx); @@ -1693,6 +1697,8 @@ static irqreturn_t coda_irq_handler(int irq, void *data) (dst_buf->v4l2_buf.flags & V4L2_BUF_FLAG_KEYFRAME) ? "KEYFRAME" : "PFRAME"); + mutex_unlock(&dev->coda_mutex); + v4l2_m2m_job_finish(ctx->dev->m2m_dev, ctx->m2m_ctx); return IRQ_HANDLED; @@ -1704,11 +1710,6 @@ static void coda_timeout(struct work_struct *work) struct coda_dev *dev = container_of(to_delayed_work(work), struct coda_dev, timeout); - if (completion_done(&dev->done)) - return; - - complete(&dev->done); - dev_err(&dev->plat_dev->dev, "CODA PIC_RUN timeout, stopping all streams\n"); mutex_lock(&dev->dev_mutex); @@ -1717,6 +1718,10 @@ static void coda_timeout(struct work_struct *work) v4l2_m2m_streamoff(NULL, ctx->m2m_ctx, V4L2_BUF_TYPE_VIDEO_CAPTURE); } mutex_unlock(&dev->dev_mutex); + + mutex_unlock(&dev->coda_mutex); + ctx = v4l2_m2m_get_curr_priv(dev->m2m_dev); + v4l2_m2m_job_finish(ctx->dev->m2m_dev, ctx->m2m_ctx); } static u32 coda_supported_firmwares[] = { @@ -1999,8 +2004,6 @@ static int coda_probe(struct platform_device *pdev) spin_lock_init(&dev->irqlock); INIT_LIST_HEAD(&dev->instances); INIT_DELAYED_WORK(&dev->timeout, coda_timeout); - init_completion(&dev->done); - complete(&dev->done); dev->plat_dev = pdev; dev->clk_per = devm_clk_get(&pdev->dev, "per"); @@ -2054,6 +2057,7 @@ static int coda_probe(struct platform_device *pdev) return ret; mutex_init(&dev->dev_mutex); + mutex_init(&dev->coda_mutex); pdev_id = of_id ? of_id->data : platform_get_device_id(pdev); From 3e748268f391eaf46fe547eb3e51bfec387a63c5 Mon Sep 17 00:00:00 2001 From: Philipp Zabel Date: Thu, 23 May 2013 10:43:01 -0300 Subject: [PATCH 0080/1048] [media] coda: do not call v4l2_m2m_job_finish from .job_abort If we just declare the job finished here while the CODA is still running, the call to v4l2_m2m_ctx_release in coda_release, which is supposed to wait for a running job to finish, will return immediately and free memory that the CODA is still using. Just set the 'aborting' flag and let coda_irq_handler deal with it. Signed-off-by: Philipp Zabel Signed-off-by: Kamil Debski Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/coda.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/media/platform/coda.c b/drivers/media/platform/coda.c index f9c4014ee40c..c4566c447774 100644 --- a/drivers/media/platform/coda.c +++ b/drivers/media/platform/coda.c @@ -812,6 +812,12 @@ static int coda_job_ready(void *m2m_priv) return 0; } + if (ctx->aborting) { + v4l2_dbg(1, coda_debug, &ctx->dev->v4l2_dev, + "not ready: aborting\n"); + return 0; + } + v4l2_dbg(1, coda_debug, &ctx->dev->v4l2_dev, "job ready\n"); return 1; @@ -820,14 +826,11 @@ static int coda_job_ready(void *m2m_priv) static void coda_job_abort(void *priv) { struct coda_ctx *ctx = priv; - struct coda_dev *dev = ctx->dev; ctx->aborting = 1; v4l2_dbg(1, coda_debug, &ctx->dev->v4l2_dev, "Aborting task\n"); - - v4l2_m2m_job_finish(dev->m2m_dev, ctx->m2m_ctx); } static void coda_lock(void *m2m_priv) From afcf44c786765b4eee44eea39ac0fddbbb830926 Mon Sep 17 00:00:00 2001 From: Kamal Mostafa Date: Mon, 15 Apr 2013 16:01:51 -0300 Subject: [PATCH 0081/1048] [media] uvcvideo: quirk PROBE_DEF for Dell Studio / OmniVision webcam BugLink: https://bugs.launchpad.net/bugs/1168430 OminiVision webcam 0x05a9:0x264a (in Dell Studio Hybrid 140g) needs the same UVC_QUIRK_PROBE_DEF as other OmniVision model to be recognized consistently. Signed-off-by: Kamal Mostafa Signed-off-by: Laurent Pinchart Signed-off-by: Mauro Carvalho Chehab --- drivers/media/usb/uvc/uvc_driver.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c index 5dbefa68b1d2..17bd48d16e5a 100644 --- a/drivers/media/usb/uvc/uvc_driver.c +++ b/drivers/media/usb/uvc/uvc_driver.c @@ -2163,6 +2163,15 @@ static struct usb_device_id uvc_ids[] = { .bInterfaceSubClass = 1, .bInterfaceProtocol = 0, .driver_info = UVC_QUIRK_PROBE_DEF }, + /* Dell Studio Hybrid 140g (OmniVision webcam) */ + { .match_flags = USB_DEVICE_ID_MATCH_DEVICE + | USB_DEVICE_ID_MATCH_INT_INFO, + .idVendor = 0x05a9, + .idProduct = 0x264a, + .bInterfaceClass = USB_CLASS_VIDEO, + .bInterfaceSubClass = 1, + .bInterfaceProtocol = 0, + .driver_info = UVC_QUIRK_PROBE_DEF }, /* Apple Built-In iSight */ { .match_flags = USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_INT_INFO, From c2a273b24f2c82184cc0f04ba3a61da51c84724b Mon Sep 17 00:00:00 2001 From: Joseph Salisbury Date: Wed, 15 May 2013 17:38:48 -0300 Subject: [PATCH 0082/1048] [media] uvcvideo: quirk PROBE_DEF for Alienware X51 OmniVision webcam BugLink: http://bugs.launchpad.net/bugs/1180409 OminiVision webcam 0x05a9:0x2643 needs the same UVC_QUIRK_PROBE_DEF as other OmniVision models to work properly. Signed-off-by: Joseph Salisbury Signed-off-by: Laurent Pinchart Signed-off-by: Mauro Carvalho Chehab --- drivers/media/usb/uvc/uvc_driver.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c index 17bd48d16e5a..a7e64af5f82e 100644 --- a/drivers/media/usb/uvc/uvc_driver.c +++ b/drivers/media/usb/uvc/uvc_driver.c @@ -2163,6 +2163,15 @@ static struct usb_device_id uvc_ids[] = { .bInterfaceSubClass = 1, .bInterfaceProtocol = 0, .driver_info = UVC_QUIRK_PROBE_DEF }, + /* Dell Alienware X51 */ + { .match_flags = USB_DEVICE_ID_MATCH_DEVICE + | USB_DEVICE_ID_MATCH_INT_INFO, + .idVendor = 0x05a9, + .idProduct = 0x2643, + .bInterfaceClass = USB_CLASS_VIDEO, + .bInterfaceSubClass = 1, + .bInterfaceProtocol = 0, + .driver_info = UVC_QUIRK_PROBE_DEF }, /* Dell Studio Hybrid 140g (OmniVision webcam) */ { .match_flags = USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_INT_INFO, From 17706f5653a90ff277b5b36c2eb60ff872df5e7a Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Thu, 25 Apr 2013 22:28:51 -0300 Subject: [PATCH 0083/1048] [media] uvcvideo: Fix open/close race condition Maintaining the users count using an atomic variable makes sure that access to the counter won't be racy, but doesn't serialize access to the operations protected by the counter. This creates a race condition that could result in the status URB being submitted multiple times. Use a mutex to protect the users count and serialize access to the status start and stop operations. Reported-by: Shawn Nematbakhsh Signed-off-by: Laurent Pinchart Signed-off-by: Mauro Carvalho Chehab --- drivers/media/usb/uvc/uvc_driver.c | 23 +++++++++++++++++------ drivers/media/usb/uvc/uvc_status.c | 21 ++------------------- drivers/media/usb/uvc/uvc_v4l2.c | 14 ++++++++++---- drivers/media/usb/uvc/uvcvideo.h | 7 +++---- 4 files changed, 32 insertions(+), 33 deletions(-) diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c index a7e64af5f82e..81695d48c13e 100644 --- a/drivers/media/usb/uvc/uvc_driver.c +++ b/drivers/media/usb/uvc/uvc_driver.c @@ -1836,8 +1836,8 @@ static int uvc_probe(struct usb_interface *intf, INIT_LIST_HEAD(&dev->chains); INIT_LIST_HEAD(&dev->streams); atomic_set(&dev->nstreams, 0); - atomic_set(&dev->users, 0); atomic_set(&dev->nmappings, 0); + mutex_init(&dev->lock); dev->udev = usb_get_dev(udev); dev->intf = usb_get_intf(intf); @@ -1950,8 +1950,13 @@ static int uvc_suspend(struct usb_interface *intf, pm_message_t message) /* Controls are cached on the fly so they don't need to be saved. */ if (intf->cur_altsetting->desc.bInterfaceSubClass == - UVC_SC_VIDEOCONTROL) - return uvc_status_suspend(dev); + UVC_SC_VIDEOCONTROL) { + mutex_lock(&dev->lock); + if (dev->users) + uvc_status_stop(dev); + mutex_unlock(&dev->lock); + return 0; + } list_for_each_entry(stream, &dev->streams, list) { if (stream->intf == intf) @@ -1973,14 +1978,20 @@ static int __uvc_resume(struct usb_interface *intf, int reset) if (intf->cur_altsetting->desc.bInterfaceSubClass == UVC_SC_VIDEOCONTROL) { - if (reset) { - int ret = uvc_ctrl_resume_device(dev); + int ret = 0; + if (reset) { + ret = uvc_ctrl_resume_device(dev); if (ret < 0) return ret; } - return uvc_status_resume(dev); + mutex_lock(&dev->lock); + if (dev->users) + ret = uvc_status_start(dev, GFP_NOIO); + mutex_unlock(&dev->lock); + + return ret; } list_for_each_entry(stream, &dev->streams, list) { diff --git a/drivers/media/usb/uvc/uvc_status.c b/drivers/media/usb/uvc/uvc_status.c index b7492775e6ae..f552ab997956 100644 --- a/drivers/media/usb/uvc/uvc_status.c +++ b/drivers/media/usb/uvc/uvc_status.c @@ -206,32 +206,15 @@ void uvc_status_cleanup(struct uvc_device *dev) uvc_input_cleanup(dev); } -int uvc_status_start(struct uvc_device *dev) +int uvc_status_start(struct uvc_device *dev, gfp_t flags) { if (dev->int_urb == NULL) return 0; - return usb_submit_urb(dev->int_urb, GFP_KERNEL); + return usb_submit_urb(dev->int_urb, flags); } void uvc_status_stop(struct uvc_device *dev) { usb_kill_urb(dev->int_urb); } - -int uvc_status_suspend(struct uvc_device *dev) -{ - if (atomic_read(&dev->users)) - usb_kill_urb(dev->int_urb); - - return 0; -} - -int uvc_status_resume(struct uvc_device *dev) -{ - if (dev->int_urb == NULL || atomic_read(&dev->users) == 0) - return 0; - - return usb_submit_urb(dev->int_urb, GFP_NOIO); -} - diff --git a/drivers/media/usb/uvc/uvc_v4l2.c b/drivers/media/usb/uvc/uvc_v4l2.c index b2dc32623a71..3afff92804d3 100644 --- a/drivers/media/usb/uvc/uvc_v4l2.c +++ b/drivers/media/usb/uvc/uvc_v4l2.c @@ -498,16 +498,20 @@ static int uvc_v4l2_open(struct file *file) return -ENOMEM; } - if (atomic_inc_return(&stream->dev->users) == 1) { - ret = uvc_status_start(stream->dev); + mutex_lock(&stream->dev->lock); + if (stream->dev->users == 0) { + ret = uvc_status_start(stream->dev, GFP_KERNEL); if (ret < 0) { - atomic_dec(&stream->dev->users); + mutex_unlock(&stream->dev->lock); usb_autopm_put_interface(stream->dev->intf); kfree(handle); return ret; } } + stream->dev->users++; + mutex_unlock(&stream->dev->lock); + v4l2_fh_init(&handle->vfh, stream->vdev); v4l2_fh_add(&handle->vfh); handle->chain = stream->chain; @@ -538,8 +542,10 @@ static int uvc_v4l2_release(struct file *file) kfree(handle); file->private_data = NULL; - if (atomic_dec_return(&stream->dev->users) == 0) + mutex_lock(&stream->dev->lock); + if (--stream->dev->users == 0) uvc_status_stop(stream->dev); + mutex_unlock(&stream->dev->lock); usb_autopm_put_interface(stream->dev->intf); return 0; diff --git a/drivers/media/usb/uvc/uvcvideo.h b/drivers/media/usb/uvc/uvcvideo.h index af505fdd9b3f..9e35982d099a 100644 --- a/drivers/media/usb/uvc/uvcvideo.h +++ b/drivers/media/usb/uvc/uvcvideo.h @@ -514,7 +514,8 @@ struct uvc_device { char name[32]; enum uvc_device_state state; - atomic_t users; + struct mutex lock; /* Protects users */ + unsigned int users; atomic_t nmappings; /* Video control interface */ @@ -660,10 +661,8 @@ void uvc_video_clock_update(struct uvc_streaming *stream, /* Status */ extern int uvc_status_init(struct uvc_device *dev); extern void uvc_status_cleanup(struct uvc_device *dev); -extern int uvc_status_start(struct uvc_device *dev); +extern int uvc_status_start(struct uvc_device *dev, gfp_t flags); extern void uvc_status_stop(struct uvc_device *dev); -extern int uvc_status_suspend(struct uvc_device *dev); -extern int uvc_status_resume(struct uvc_device *dev); /* Controls */ extern const struct v4l2_subscribed_event_ops uvc_ctrl_sub_ev_ops; From 4d8d5d92cb239142d888c7844db2b078e14d4213 Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Sun, 2 Jun 2013 13:52:17 -0300 Subject: [PATCH 0084/1048] [media] dib8000: Fix dib8000_set_frontend() never setting ret MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit drivers/media/dvb-frontends/dib8000.c: In function ‘dib8000_set_frontend’: drivers/media/dvb-frontends/dib8000.c:3556: warning: ‘ret’ is used uninitialized in this function Remove the variable and return zero instead. Signed-off-by: Geert Uytterhoeven Signed-off-by: Michael Krufky Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb-frontends/dib8000.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/media/dvb-frontends/dib8000.c b/drivers/media/dvb-frontends/dib8000.c index a54182dd0e91..90536147bf04 100644 --- a/drivers/media/dvb-frontends/dib8000.c +++ b/drivers/media/dvb-frontends/dib8000.c @@ -3406,7 +3406,7 @@ static int dib8000_set_frontend(struct dvb_frontend *fe) { struct dib8000_state *state = fe->demodulator_priv; struct dtv_frontend_properties *c = &state->fe[0]->dtv_property_cache; - int l, i, active, time, ret, time_slave = FE_CALLBACK_TIME_NEVER; + int l, i, active, time, time_slave = FE_CALLBACK_TIME_NEVER; u8 exit_condition, index_frontend; u32 delay, callback_time; @@ -3553,7 +3553,7 @@ static int dib8000_set_frontend(struct dvb_frontend *fe) } } - return ret; + return 0; } static int dib8000_read_status(struct dvb_frontend *fe, fe_status_t * stat) From 4aab0398e003ac2effae98ba66a012ed715967ba Mon Sep 17 00:00:00 2001 From: Gianluca Gennari Date: Sun, 2 Jun 2013 14:26:15 -0300 Subject: [PATCH 0085/1048] [media] r820t: do not double-free fe->tuner_priv in r820t_release() fe->tuner_priv is already freed by hybrid_tuner_release_state(). Signed-off-by: Gianluca Gennari Signed-off-by: Michael Krufky Signed-off-by: Mauro Carvalho Chehab --- drivers/media/tuners/r820t.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/media/tuners/r820t.c b/drivers/media/tuners/r820t.c index 4835021aa3b6..64f97389d5b0 100644 --- a/drivers/media/tuners/r820t.c +++ b/drivers/media/tuners/r820t.c @@ -2256,7 +2256,6 @@ static int r820t_release(struct dvb_frontend *fe) mutex_unlock(&r820t_list_mutex); - kfree(fe->tuner_priv); fe->tuner_priv = NULL; return 0; From 703e60655ca520c5380d8c83a9db0d5e9b906856 Mon Sep 17 00:00:00 2001 From: Thomas Meyer Date: Sat, 1 Jun 2013 05:53:10 -0300 Subject: [PATCH 0086/1048] [media] dma-buf: Cocci spatch "ptr_ret.spatch" Signed-off-by: Thomas Meyer Signed-off-by: Mauro Carvalho Chehab --- drivers/base/dma-buf.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/base/dma-buf.c b/drivers/base/dma-buf.c index 08fe897c0b4c..6687ba741879 100644 --- a/drivers/base/dma-buf.c +++ b/drivers/base/dma-buf.c @@ -680,10 +680,7 @@ int dma_buf_debugfs_create_file(const char *name, d = debugfs_create_file(name, S_IRUGO, dma_buf_debugfs_dir, write, &dma_buf_debug_fops); - if (IS_ERR(d)) - return PTR_ERR(d); - - return 0; + return PTR_RET(d); } #else static inline int dma_buf_init_debugfs(void) From ccac68f9818d0ff5c4cde26590a7f284285c724e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Reinhard=20Ni=C3=9Fl?= Date: Sun, 2 Jun 2013 14:37:06 -0300 Subject: [PATCH 0087/1048] [media] stb0899: sign extend raw CRL_FREQ value MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Contrary to the chip's specs, the register's value is signed, so we need to sign extend the value before using it in calculations like when determining the offset frequency. Signed-off-by: Reinhard Nißl Signed-off-by: Michael Krufky Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb-frontends/stb0899_algo.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/media/dvb-frontends/stb0899_algo.c b/drivers/media/dvb-frontends/stb0899_algo.c index 117a56926dca..bd9dbd70af0f 100644 --- a/drivers/media/dvb-frontends/stb0899_algo.c +++ b/drivers/media/dvb-frontends/stb0899_algo.c @@ -1487,6 +1487,10 @@ enum stb0899_status stb0899_dvbs2_algo(struct stb0899_state *state) /* Store signal parameters */ offsetfreq = STB0899_READ_S2REG(STB0899_S2DEMOD, CRL_FREQ); + /* sign extend 30 bit value before using it in calculations */ + if (offsetfreq & (1 << 29)) + offsetfreq |= -1 << 30; + offsetfreq = offsetfreq / ((1 << 30) / 1000); offsetfreq *= (internal->master_clk / 1000000); reg = STB0899_READ_S2REG(STB0899_S2DEMOD, DMD_CNTRL2); From 2eeed77fd1f54eb8cd34f409381eb7be2da4bc51 Mon Sep 17 00:00:00 2001 From: Zoran Turalija Date: Sun, 2 Jun 2013 14:40:51 -0300 Subject: [PATCH 0088/1048] [media] stb0899: allow minimum symbol rate of 1000000 This makes minimum symbol rate driver capabilities on par with windows driver, and allows tuning on linux to transponders that have symbol rate below 5000000, too. Patch was tested successfully on Eutelsat 16A transponders that became reachable with it (1000000 < symbol rate < 5000000): * DVB/S 12507050 V 2532000 3/4 * DVB/S2 12574000 V 4355000 3/4 8PSK * DVB/S 12593000 V 2500000 2/3 * DVB/S 12596940 V 2848000 2/3 * DVB/S 12600750 V 2500000 1/2 * DVB/S 12675590 H 4248000 3/4 Signed-off-by: Zoran Turalija Signed-off-by: Michael Krufky Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb-frontends/stb0899_drv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/dvb-frontends/stb0899_drv.c b/drivers/media/dvb-frontends/stb0899_drv.c index cc278b3d6d5a..527f5c3e0be9 100644 --- a/drivers/media/dvb-frontends/stb0899_drv.c +++ b/drivers/media/dvb-frontends/stb0899_drv.c @@ -1581,7 +1581,7 @@ static struct dvb_frontend_ops stb0899_ops = { .frequency_max = 2150000, .frequency_stepsize = 0, .frequency_tolerance = 0, - .symbol_rate_min = 5000000, + .symbol_rate_min = 1000000, .symbol_rate_max = 45000000, .caps = FE_CAN_INVERSION_AUTO | From fa64cfd2fc8b66918e7889deeaec87d77fb96f89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Reinhard=20Ni=C3=9Fl?= Date: Sun, 2 Jun 2013 14:52:02 -0300 Subject: [PATCH 0089/1048] [media] stb0899: enable auto inversion handling unconditionally MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It seems that current inversion handling addresses only the signal routing on the PCB, i. e. IQ signals are either swapped or not. But when the device is operated in a Satellite Channel Router (SCR) environment, an additional inversion is required due to the way how the SCR works. Therefore it makes sense to me to always enable auto inversion handling and drop the enum value IQ_SWAP_AUTO. Signed-off-by: Reinhard Nißl Signed-off-by: Michael Krufky Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb-frontends/stb0899_algo.c | 61 ++++++++++------------ drivers/media/dvb-frontends/stb0899_drv.h | 1 - 2 files changed, 28 insertions(+), 34 deletions(-) diff --git a/drivers/media/dvb-frontends/stb0899_algo.c b/drivers/media/dvb-frontends/stb0899_algo.c index bd9dbd70af0f..14d720ba1207 100644 --- a/drivers/media/dvb-frontends/stb0899_algo.c +++ b/drivers/media/dvb-frontends/stb0899_algo.c @@ -1373,9 +1373,6 @@ enum stb0899_status stb0899_dvbs2_algo(struct stb0899_state *state) case IQ_SWAP_ON: STB0899_SETFIELD_VAL(SPECTRUM_INVERT, reg, 1); break; - case IQ_SWAP_AUTO: /* use last successful search first */ - STB0899_SETFIELD_VAL(SPECTRUM_INVERT, reg, 1); - break; } stb0899_write_s2reg(state, STB0899_S2DEMOD, STB0899_BASE_DMD_CNTRL2, STB0899_OFF0_DMD_CNTRL2, reg); stb0899_dvbs2_reacquire(state); @@ -1405,41 +1402,39 @@ enum stb0899_status stb0899_dvbs2_algo(struct stb0899_state *state) } if (internal->status != DVBS2_FEC_LOCK) { - if (internal->inversion == IQ_SWAP_AUTO) { - reg = STB0899_READ_S2REG(STB0899_S2DEMOD, DMD_CNTRL2); - iqSpectrum = STB0899_GETFIELD(SPECTRUM_INVERT, reg); - /* IQ Spectrum Inversion */ - STB0899_SETFIELD_VAL(SPECTRUM_INVERT, reg, !iqSpectrum); - stb0899_write_s2reg(state, STB0899_S2DEMOD, STB0899_BASE_DMD_CNTRL2, STB0899_OFF0_DMD_CNTRL2, reg); - /* start acquistion process */ - stb0899_dvbs2_reacquire(state); + reg = STB0899_READ_S2REG(STB0899_S2DEMOD, DMD_CNTRL2); + iqSpectrum = STB0899_GETFIELD(SPECTRUM_INVERT, reg); + /* IQ Spectrum Inversion */ + STB0899_SETFIELD_VAL(SPECTRUM_INVERT, reg, !iqSpectrum); + stb0899_write_s2reg(state, STB0899_S2DEMOD, STB0899_BASE_DMD_CNTRL2, STB0899_OFF0_DMD_CNTRL2, reg); + /* start acquistion process */ + stb0899_dvbs2_reacquire(state); - /* Wait for demod lock (UWP and CSM) */ - internal->status = stb0899_dvbs2_get_dmd_status(state, searchTime); - if (internal->status == DVBS2_DEMOD_LOCK) { - i = 0; - /* Demod Locked, check FEC */ - internal->status = stb0899_dvbs2_get_fec_status(state, FecLockTime); - /*try thrice for false locks, (UWP and CSM Locked but no FEC) */ - while ((internal->status != DVBS2_FEC_LOCK) && (i < 3)) { - /* Read the frequency offset*/ - offsetfreq = STB0899_READ_S2REG(STB0899_S2DEMOD, CRL_FREQ); + /* Wait for demod lock (UWP and CSM) */ + internal->status = stb0899_dvbs2_get_dmd_status(state, searchTime); + if (internal->status == DVBS2_DEMOD_LOCK) { + i = 0; + /* Demod Locked, check FEC */ + internal->status = stb0899_dvbs2_get_fec_status(state, FecLockTime); + /*try thrice for false locks, (UWP and CSM Locked but no FEC) */ + while ((internal->status != DVBS2_FEC_LOCK) && (i < 3)) { + /* Read the frequency offset*/ + offsetfreq = STB0899_READ_S2REG(STB0899_S2DEMOD, CRL_FREQ); - /* Set the Nominal frequency to the found frequency offset for the next reacquire*/ - reg = STB0899_READ_S2REG(STB0899_S2DEMOD, CRL_NOM_FREQ); - STB0899_SETFIELD_VAL(CRL_NOM_FREQ, reg, offsetfreq); - stb0899_write_s2reg(state, STB0899_S2DEMOD, STB0899_BASE_CRL_NOM_FREQ, STB0899_OFF0_CRL_NOM_FREQ, reg); + /* Set the Nominal frequency to the found frequency offset for the next reacquire*/ + reg = STB0899_READ_S2REG(STB0899_S2DEMOD, CRL_NOM_FREQ); + STB0899_SETFIELD_VAL(CRL_NOM_FREQ, reg, offsetfreq); + stb0899_write_s2reg(state, STB0899_S2DEMOD, STB0899_BASE_CRL_NOM_FREQ, STB0899_OFF0_CRL_NOM_FREQ, reg); - stb0899_dvbs2_reacquire(state); - internal->status = stb0899_dvbs2_get_fec_status(state, searchTime); - i++; - } + stb0899_dvbs2_reacquire(state); + internal->status = stb0899_dvbs2_get_fec_status(state, searchTime); + i++; } -/* - if (pParams->DVBS2State == FE_DVBS2_FEC_LOCKED) - pParams->IQLocked = !iqSpectrum; -*/ } +/* + if (pParams->DVBS2State == FE_DVBS2_FEC_LOCKED) + pParams->IQLocked = !iqSpectrum; +*/ } if (internal->status == DVBS2_FEC_LOCK) { dprintk(state->verbose, FE_DEBUG, 1, "----------------> DVB-S2 FEC Lock !"); diff --git a/drivers/media/dvb-frontends/stb0899_drv.h b/drivers/media/dvb-frontends/stb0899_drv.h index 8d26ff6eb1db..1ddad6a8cc07 100644 --- a/drivers/media/dvb-frontends/stb0899_drv.h +++ b/drivers/media/dvb-frontends/stb0899_drv.h @@ -47,7 +47,6 @@ struct stb0899_s2_reg { enum stb0899_inversion { IQ_SWAP_OFF = 0, IQ_SWAP_ON, - IQ_SWAP_AUTO }; #define STB0899_GPIO00 0xf140 From 069ebbfc9eb7bef5e9780c508d8bc378bfea3e94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Reinhard=20Ni=C3=9Fl?= Date: Sun, 2 Jun 2013 14:52:43 -0300 Subject: [PATCH 0090/1048] [media] stb0899: fix inversion enum values to match usage with CFR MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Throughout the zig-zag-implementations, inversion is taken into account when reading and writing the CFR register, which contains the derotator frequency. As swapping IQ signals changes the sign of that register for example, the idea is to compensate that sign change by multiplying the register value with the inversion enum value. The current enum values 0 and 1 for IQ_SWAP_OFF and IQ_SWAP_ON don't work in the case IQ_SWAP_OFF, due to the multiplication by zero (I've only found a single device which actually uses IQ_SWAP_OFF in it's config). I've changed the enum values to +1 and -1 to accommodate to the intended usage. Signed-off-by: Reinhard Nißl Signed-off-by: Michael Krufky Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb-frontends/stb0899_algo.c | 4 ++-- drivers/media/dvb-frontends/stb0899_drv.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/media/dvb-frontends/stb0899_algo.c b/drivers/media/dvb-frontends/stb0899_algo.c index 14d720ba1207..e0d31a2ea578 100644 --- a/drivers/media/dvb-frontends/stb0899_algo.c +++ b/drivers/media/dvb-frontends/stb0899_algo.c @@ -444,7 +444,7 @@ static enum stb0899_status stb0899_check_range(struct stb0899_state *state) int range_offst, tp_freq; range_offst = internal->srch_range / 2000; - tp_freq = internal->freq + (internal->derot_freq * internal->mclk) / 1000; + tp_freq = internal->freq - (internal->derot_freq * internal->mclk) / 1000; if ((tp_freq >= params->freq - range_offst) && (tp_freq <= params->freq + range_offst)) { internal->status = RANGEOK; @@ -638,7 +638,7 @@ enum stb0899_status stb0899_dvbs_algo(struct stb0899_state *state) "RANGE OK ! derot freq=%d, mclk=%d", internal->derot_freq, internal->mclk); - internal->freq = params->freq + ((internal->derot_freq * internal->mclk) / 1000); + internal->freq = params->freq - ((internal->derot_freq * internal->mclk) / 1000); reg = stb0899_read_reg(state, STB0899_PLPARM); internal->fecrate = STB0899_GETFIELD(VITCURPUN, reg); dprintk(state->verbose, FE_DEBUG, 1, diff --git a/drivers/media/dvb-frontends/stb0899_drv.h b/drivers/media/dvb-frontends/stb0899_drv.h index 1ddad6a8cc07..139264d19263 100644 --- a/drivers/media/dvb-frontends/stb0899_drv.h +++ b/drivers/media/dvb-frontends/stb0899_drv.h @@ -45,8 +45,8 @@ struct stb0899_s2_reg { }; enum stb0899_inversion { - IQ_SWAP_OFF = 0, - IQ_SWAP_ON, + IQ_SWAP_OFF = +1, /* inversion affects the sign of e. g. */ + IQ_SWAP_ON = -1, /* the derotator frequency register */ }; #define STB0899_GPIO00 0xf140 From 55b3318b3a49488a14ccfceffde668d548c4e427 Mon Sep 17 00:00:00 2001 From: Zoran Turalija Date: Sun, 2 Jun 2013 14:56:33 -0300 Subject: [PATCH 0091/1048] [media] stb0899: allow minimum symbol rate of 2000000 Looks like product datasheets for tuners containing STB0899 are suggesting specification for min. symbol rate of 2MS/s. Some specs found here, all suggesting 2MS/s for min. symbol rate: Comtech DVBS2-6899 http://comtech.sg1002.myweb.hinet.net/pdf/dvbs2-6899.pdf TechniSat SkyStar HD2 http://www.scaistar.com/skystar2/skystarhd2.htm Azurewave AD-SP400 http://www.pulsat.com/products/AzureWave-AD%252dSP400-High-Definition-PC-Card.html New patch: This makes minimum symbol rate driver capabilities on par with some accessible datasheet specifications*, and allows tuning on linux to transponders that have symbol rate between 2000000-5000000, too. Patch was tested successfully on Eutelsat 16A transponders that became reachable with it (2000000 < symbol rate < 5000000): * DVB/S 12507050 V 2532000 3/4 * DVB/S2 12574000 V 4355000 3/4 8PSK * DVB/S 12593000 V 2500000 2/3 * DVB/S 12596940 V 2848000 2/3 * DVB/S 12600750 V 2500000 1/2 * DVB/S 12675590 H 4248000 3/4 (*) Datasheet: http://comtech.sg1002.myweb.hinet.net/pdf/dvbs2-6899.pdf Maximum Symbol Rate QPSK/LDPC/PCH: 20-30Mbps 8PSK/LDPC/BCH: 10-30Mbps DVB: 2-45Mbps ^--------- min. symbol rate Signed-off-by: Zoran Turalija Signed-off-by: Michael Krufky Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb-frontends/stb0899_drv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/dvb-frontends/stb0899_drv.c b/drivers/media/dvb-frontends/stb0899_drv.c index 527f5c3e0be9..b3ccd3dbbda1 100644 --- a/drivers/media/dvb-frontends/stb0899_drv.c +++ b/drivers/media/dvb-frontends/stb0899_drv.c @@ -1581,7 +1581,7 @@ static struct dvb_frontend_ops stb0899_ops = { .frequency_max = 2150000, .frequency_stepsize = 0, .frequency_tolerance = 0, - .symbol_rate_min = 1000000, + .symbol_rate_min = 2000000, .symbol_rate_max = 45000000, .caps = FE_CAN_INVERSION_AUTO | From 0c1d2b14d09b862ccd6300d774eb579161635710 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Reinhard=20Ni=C3=9Fl?= Date: Sun, 2 Jun 2013 14:59:00 -0300 Subject: [PATCH 0092/1048] [media] stb0899: store successful inversion for next run MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Usually, inversion doesn't change in a system. Storing the last successful inversion value speeds up tuning of DVB-S2 transponders. Signed-off-by: Reinhard Nißl Signed-off-by: Michael Krufky Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb-frontends/stb0899_algo.c | 8 +++++++- drivers/media/dvb-frontends/stb0899_drv.c | 5 ++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/media/dvb-frontends/stb0899_algo.c b/drivers/media/dvb-frontends/stb0899_algo.c index e0d31a2ea578..4b49efb67931 100644 --- a/drivers/media/dvb-frontends/stb0899_algo.c +++ b/drivers/media/dvb-frontends/stb0899_algo.c @@ -1488,9 +1488,15 @@ enum stb0899_status stb0899_dvbs2_algo(struct stb0899_state *state) offsetfreq = offsetfreq / ((1 << 30) / 1000); offsetfreq *= (internal->master_clk / 1000000); + + /* store current inversion for next run */ reg = STB0899_READ_S2REG(STB0899_S2DEMOD, DMD_CNTRL2); if (STB0899_GETFIELD(SPECTRUM_INVERT, reg)) - offsetfreq *= -1; + internal->inversion = IQ_SWAP_ON; + else + internal->inversion = IQ_SWAP_OFF; + + offsetfreq *= internal->inversion; internal->freq = internal->freq - offsetfreq; internal->srate = stb0899_dvbs2_get_srate(state); diff --git a/drivers/media/dvb-frontends/stb0899_drv.c b/drivers/media/dvb-frontends/stb0899_drv.c index b3ccd3dbbda1..82391feb6839 100644 --- a/drivers/media/dvb-frontends/stb0899_drv.c +++ b/drivers/media/dvb-frontends/stb0899_drv.c @@ -1618,19 +1618,18 @@ static struct dvb_frontend_ops stb0899_ops = { struct dvb_frontend *stb0899_attach(struct stb0899_config *config, struct i2c_adapter *i2c) { struct stb0899_state *state = NULL; - enum stb0899_inversion inversion; state = kzalloc(sizeof (struct stb0899_state), GFP_KERNEL); if (state == NULL) goto error; - inversion = config->inversion; state->verbose = &verbose; state->config = config; state->i2c = i2c; state->frontend.ops = stb0899_ops; state->frontend.demodulator_priv = state; - state->internal.inversion = inversion; + /* use configured inversion as default -- we'll later autodetect inversion */ + state->internal.inversion = config->inversion; stb0899_wakeup(&state->frontend); if (stb0899_get_dev_id(state) == -ENODEV) { From b71e2c4cd89929a1160f3a8657135a802cc23df3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Reinhard=20Ni=C3=9Fl?= Date: Sun, 2 Jun 2013 15:01:18 -0300 Subject: [PATCH 0093/1048] [media] stb0899: store autodetected inversion while tuning in non S2 mode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In non S2 mode, the device is able to autodetect inversion. So let's store it for tuning to S2 transponders. Signed-off-by: Reinhard Nißl Signed-off-by: Michael Krufky Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb-frontends/stb0899_algo.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/media/dvb-frontends/stb0899_algo.c b/drivers/media/dvb-frontends/stb0899_algo.c index 4b49efb67931..4ce542c2db4b 100644 --- a/drivers/media/dvb-frontends/stb0899_algo.c +++ b/drivers/media/dvb-frontends/stb0899_algo.c @@ -425,6 +425,14 @@ static enum stb0899_status stb0899_search_data(struct stb0899_state *state) if (internal->status == DATAOK) { stb0899_read_regs(state, STB0899_CFRM, cfr, 2); /* get derotator frequency */ + + /* store autodetected IQ swapping as default for DVB-S2 tuning */ + reg = stb0899_read_reg(state, STB0899_IQSWAP); + if (STB0899_GETFIELD(SYM, reg)) + internal->inversion = IQ_SWAP_ON; + else + internal->inversion = IQ_SWAP_OFF; + internal->derot_freq = state->config->inversion * MAKEWORD16(cfr[0], cfr[1]); dprintk(state->verbose, FE_DEBUG, 1, "------> DATAOK ! Derot Freq=%d", internal->derot_freq); } From 25e529e6dab50049dcb45151407bd874ae6f5315 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Reinhard=20Ni=C3=9Fl?= Date: Sun, 2 Jun 2013 15:02:05 -0300 Subject: [PATCH 0094/1048] [media] stb0899: use autodetected inversion instead of configured inversion MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For consistency, it is necessary to use the autodetected inversion instead of the configured one. Signed-off-by: Reinhard Nißl Signed-off-by: Michael Krufky Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb-frontends/stb0899_algo.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/media/dvb-frontends/stb0899_algo.c b/drivers/media/dvb-frontends/stb0899_algo.c index 4ce542c2db4b..a338e06defd1 100644 --- a/drivers/media/dvb-frontends/stb0899_algo.c +++ b/drivers/media/dvb-frontends/stb0899_algo.c @@ -226,8 +226,8 @@ static enum stb0899_status stb0899_search_tmg(struct stb0899_state *state) next_loop--; if (next_loop) { - STB0899_SETFIELD_VAL(CFRM, cfr[0], MSB(state->config->inversion * derot_freq)); - STB0899_SETFIELD_VAL(CFRL, cfr[1], LSB(state->config->inversion * derot_freq)); + STB0899_SETFIELD_VAL(CFRM, cfr[0], MSB(internal->inversion * derot_freq)); + STB0899_SETFIELD_VAL(CFRL, cfr[1], LSB(internal->inversion * derot_freq)); stb0899_write_regs(state, STB0899_CFRM, cfr, 2); /* derotator frequency */ } internal->direction = -internal->direction; /* Change zigzag direction */ @@ -235,7 +235,7 @@ static enum stb0899_status stb0899_search_tmg(struct stb0899_state *state) if (internal->status == TIMINGOK) { stb0899_read_regs(state, STB0899_CFRM, cfr, 2); /* get derotator frequency */ - internal->derot_freq = state->config->inversion * MAKEWORD16(cfr[0], cfr[1]); + internal->derot_freq = internal->inversion * MAKEWORD16(cfr[0], cfr[1]); dprintk(state->verbose, FE_DEBUG, 1, "------->TIMING OK ! Derot Freq = %d", internal->derot_freq); } @@ -306,8 +306,8 @@ static enum stb0899_status stb0899_search_carrier(struct stb0899_state *state) STB0899_SETFIELD_VAL(CFD_ON, reg, 1); stb0899_write_reg(state, STB0899_CFD, reg); - STB0899_SETFIELD_VAL(CFRM, cfr[0], MSB(state->config->inversion * derot_freq)); - STB0899_SETFIELD_VAL(CFRL, cfr[1], LSB(state->config->inversion * derot_freq)); + STB0899_SETFIELD_VAL(CFRM, cfr[0], MSB(internal->inversion * derot_freq)); + STB0899_SETFIELD_VAL(CFRL, cfr[1], LSB(internal->inversion * derot_freq)); stb0899_write_regs(state, STB0899_CFRM, cfr, 2); /* derotator frequency */ } } @@ -317,7 +317,7 @@ static enum stb0899_status stb0899_search_carrier(struct stb0899_state *state) if (internal->status == CARRIEROK) { stb0899_read_regs(state, STB0899_CFRM, cfr, 2); /* get derotator frequency */ - internal->derot_freq = state->config->inversion * MAKEWORD16(cfr[0], cfr[1]); + internal->derot_freq = internal->inversion * MAKEWORD16(cfr[0], cfr[1]); dprintk(state->verbose, FE_DEBUG, 1, "----> CARRIER OK !, Derot Freq=%d", internal->derot_freq); } else { internal->derot_freq = last_derot_freq; @@ -412,8 +412,8 @@ static enum stb0899_status stb0899_search_data(struct stb0899_state *state) STB0899_SETFIELD_VAL(CFD_ON, reg, 1); stb0899_write_reg(state, STB0899_CFD, reg); - STB0899_SETFIELD_VAL(CFRM, cfr[0], MSB(state->config->inversion * derot_freq)); - STB0899_SETFIELD_VAL(CFRL, cfr[1], LSB(state->config->inversion * derot_freq)); + STB0899_SETFIELD_VAL(CFRM, cfr[0], MSB(internal->inversion * derot_freq)); + STB0899_SETFIELD_VAL(CFRL, cfr[1], LSB(internal->inversion * derot_freq)); stb0899_write_regs(state, STB0899_CFRM, cfr, 2); /* derotator frequency */ stb0899_check_carrier(state); @@ -433,7 +433,7 @@ static enum stb0899_status stb0899_search_data(struct stb0899_state *state) else internal->inversion = IQ_SWAP_OFF; - internal->derot_freq = state->config->inversion * MAKEWORD16(cfr[0], cfr[1]); + internal->derot_freq = internal->inversion * MAKEWORD16(cfr[0], cfr[1]); dprintk(state->verbose, FE_DEBUG, 1, "------> DATAOK ! Derot Freq=%d", internal->derot_freq); } From 7db462cdf6352af6d1ff85e52ffa82539f1c11e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Reinhard=20Ni=C3=9Fl?= Date: Sun, 2 Jun 2013 15:03:13 -0300 Subject: [PATCH 0095/1048] [media] stb0899: sign of CRL_FREQ doesn't depend on inversion MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Contrary to CFR (derotator frequency), which changes signedness depending on inversion, CRL_FREQ does not. Signed-off-by: Reinhard Nißl Signed-off-by: Michael Krufky Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb-frontends/stb0899_algo.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/media/dvb-frontends/stb0899_algo.c b/drivers/media/dvb-frontends/stb0899_algo.c index a338e06defd1..93596e0e640b 100644 --- a/drivers/media/dvb-frontends/stb0899_algo.c +++ b/drivers/media/dvb-frontends/stb0899_algo.c @@ -1504,9 +1504,7 @@ enum stb0899_status stb0899_dvbs2_algo(struct stb0899_state *state) else internal->inversion = IQ_SWAP_OFF; - offsetfreq *= internal->inversion; - - internal->freq = internal->freq - offsetfreq; + internal->freq = internal->freq + offsetfreq; internal->srate = stb0899_dvbs2_get_srate(state); reg = STB0899_READ_S2REG(STB0899_S2DEMOD, UWP_STAT2); From a7fab8511169bd28ba0a00501afd12fc8a1a2c61 Mon Sep 17 00:00:00 2001 From: Alessandro Miceli Date: Fri, 3 May 2013 15:58:21 -0300 Subject: [PATCH 0096/1048] [media] Add support for 'Digital Dual TV Receiver CTVDIGDUAL v2 Tested on a MIPSel box with 3.3.6 kernel The kernel output when the device will be detected follows: usbcore: registered new interface driver dvb_usb_it913x it913x: Chip Version=01 Chip Type=9135 it913x: Remote propriety (raw) mode it913x: Dual mode=3 Tuner Type=38 it913x: Chip Version=01 Chip Type=9135 usb 2-1: dvb_usb_v2: found a 'Digital Dual TV Receiver CTVDIGDUAL_V2' in cold state usb 2-1: dvb_usb_v2: downloading firmware from file 'dvb-usb-it9137-01.fw' it913x: FRM Starting Firmware Download it913x: FRM Firmware Download Completed - Resetting Device it913x: Chip Version=01 Chip Type=9135 it913x: Firmware Version 204147968 usb 2-1: dvb_usb_v2: found a 'Digital Dual TV Receiver CTVDIGDUAL_V2' in warm state usb 2-1: dvb_usb_v2: will pass the complete MPEG2 transport stream to the software demuxer DVB: registering new adapter (Digital Dual TV Receiver CTVDIGDUAL_V2) it913x-fe: ADF table value :00 it913x-fe: Crystal Frequency :12000000 Adc Frequency :20250000 ADC X2: 00 it913x-fe: Tuner LNA type :38 usb 2-1: DVB: registering adapter 1 frontend 0 (Digital Dual TV Receiver CTVDIGDUAL_V2_1)... usb 2-1: dvb_usb_v2: will pass the complete MPEG2 transport stream to the software demuxer DVB: registering new adapter (Digital Dual TV Receiver CTVDIGDUAL_V2) it913x-fe: ADF table value :00 it913x-fe: Crystal Frequency :12000000 Adc Frequency :20250000 ADC X2: 00 it913x-fe: Tuner LNA type :38 usb 2-1: DVB: registering adapter 2 frontend 0 (Digital Dual TV Receiver CTVDIGDUAL_V2_2)... usb 2-1: dvb_usb_v2: 'Digital Dual TV Receiver CTVDIGDUAL_V2' successfully initialized and connected RC part not tested Signed-off-by: Alessandro Miceli Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb-core/dvb-usb-ids.h | 1 + drivers/media/usb/dvb-usb-v2/it913x.c | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/media/dvb-core/dvb-usb-ids.h b/drivers/media/dvb-core/dvb-usb-ids.h index 335a8f4695b4..2e0709a66f8f 100644 --- a/drivers/media/dvb-core/dvb-usb-ids.h +++ b/drivers/media/dvb-core/dvb-usb-ids.h @@ -367,4 +367,5 @@ #define USB_PID_TECHNISAT_USB2_HDCI_V2 0x0002 #define USB_PID_TECHNISAT_AIRSTAR_TELESTICK_2 0x0004 #define USB_PID_TECHNISAT_USB2_DVB_S2 0x0500 +#define USB_PID_CTVDIGDUAL_V2 0xe410 #endif diff --git a/drivers/media/usb/dvb-usb-v2/it913x.c b/drivers/media/usb/dvb-usb-v2/it913x.c index e48cdeb9df41..1cb6899cf797 100644 --- a/drivers/media/usb/dvb-usb-v2/it913x.c +++ b/drivers/media/usb/dvb-usb-v2/it913x.c @@ -45,7 +45,7 @@ MODULE_PARM_DESC(debug, "set debugging level (1=info (or-able))."); static int dvb_usb_it913x_firmware; module_param_named(firmware, dvb_usb_it913x_firmware, int, 0644); -MODULE_PARM_DESC(firmware, "set firmware 0=auto"\ +MODULE_PARM_DESC(firmware, "set firmware 0=auto "\ "1=IT9137 2=IT9135 V1 3=IT9135 V2"); #define FW_IT9137 "dvb-usb-it9137-01.fw" #define FW_IT9135_V1 "dvb-usb-it9135-01.fw" @@ -796,6 +796,9 @@ static const struct usb_device_id it913x_id_table[] = { { DVB_USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_A835B_4835, &it913x_properties, "Avermedia A835B(4835)", RC_MAP_IT913X_V2) }, + { DVB_USB_DEVICE(USB_VID_KWORLD_2, USB_PID_CTVDIGDUAL_V2, + &it913x_properties, "Digital Dual TV Receiver CTVDIGDUAL_V2", + RC_MAP_IT913X_V1) }, {} /* Terminating entry */ }; From 3b98c347838d0a62476ea4c55daf5c315f56cbbb Mon Sep 17 00:00:00 2001 From: Antti Palosaari Date: Mon, 11 Mar 2013 19:05:39 -0300 Subject: [PATCH 0097/1048] [media] af9035: implement I2C adapter read operation Signed-off-by: Antti Palosaari Signed-off-by: Mauro Carvalho Chehab --- drivers/media/usb/dvb-usb-v2/af9035.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/drivers/media/usb/dvb-usb-v2/af9035.c b/drivers/media/usb/dvb-usb-v2/af9035.c index b638fc1cd574..cfcf79b5978a 100644 --- a/drivers/media/usb/dvb-usb-v2/af9035.c +++ b/drivers/media/usb/dvb-usb-v2/af9035.c @@ -268,11 +268,29 @@ static int af9035_i2c_master_xfer(struct i2c_adapter *adap, memcpy(&buf[5], msg[0].buf, msg[0].len); ret = af9035_ctrl_msg(d, &req); } + } else if (num == 1 && (msg[0].flags & I2C_M_RD)) { + if (msg[0].len > 40) { + /* TODO: correct limits > 40 */ + ret = -EOPNOTSUPP; + } else { + /* I2C */ + u8 buf[5]; + struct usb_req req = { CMD_I2C_RD, 0, sizeof(buf), + buf, msg[0].len, msg[0].buf }; + req.mbox |= ((msg[0].addr & 0x80) >> 3); + buf[0] = msg[0].len; + buf[1] = msg[0].addr << 1; + buf[2] = 0x00; /* reg addr len */ + buf[3] = 0x00; /* reg addr MSB */ + buf[4] = 0x00; /* reg addr LSB */ + ret = af9035_ctrl_msg(d, &req); + } } else { /* - * We support only two kind of I2C transactions: - * 1) 1 x read + 1 x write + * We support only three kind of I2C transactions: + * 1) 1 x read + 1 x write (repeated start) * 2) 1 x write + * 3) 1 x read */ ret = -EOPNOTSUPP; } From cb9114e9633c2afd029ac88ed73eb2a0b8f14edf Mon Sep 17 00:00:00 2001 From: Antti Palosaari Date: Mon, 3 Jun 2013 18:42:14 -0300 Subject: [PATCH 0098/1048] [media] af9035: make checkpatch.pl happy! Signed-off-by: Antti Palosaari Signed-off-by: Mauro Carvalho Chehab --- drivers/media/usb/dvb-usb-v2/af9035.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/drivers/media/usb/dvb-usb-v2/af9035.c b/drivers/media/usb/dvb-usb-v2/af9035.c index cfcf79b5978a..7d3b3c210e5f 100644 --- a/drivers/media/usb/dvb-usb-v2/af9035.c +++ b/drivers/media/usb/dvb-usb-v2/af9035.c @@ -91,9 +91,10 @@ static int af9035_ctrl_msg(struct dvb_usb_device *d, struct usb_req *req) checksum = af9035_checksum(state->buf, rlen - 2); tmp_checksum = (state->buf[rlen - 2] << 8) | state->buf[rlen - 1]; if (tmp_checksum != checksum) { - dev_err(&d->udev->dev, "%s: command=%02x checksum mismatch " \ - "(%04x != %04x)\n", KBUILD_MODNAME, req->cmd, - tmp_checksum, checksum); + dev_err(&d->udev->dev, + "%s: command=%02x checksum mismatch (%04x != %04x)\n", + KBUILD_MODNAME, req->cmd, tmp_checksum, + checksum); ret = -EIO; goto exit; } @@ -400,9 +401,10 @@ static int af9035_download_firmware_old(struct dvb_usb_device *d, hdr_checksum = fw->data[fw->size - i + 5] << 8; hdr_checksum |= fw->data[fw->size - i + 6] << 0; - dev_dbg(&d->udev->dev, "%s: core=%d addr=%04x data_len=%d " \ - "checksum=%04x\n", __func__, hdr_core, hdr_addr, - hdr_data_len, hdr_checksum); + dev_dbg(&d->udev->dev, + "%s: core=%d addr=%04x data_len=%d checksum=%04x\n", + __func__, hdr_core, hdr_addr, hdr_data_len, + hdr_checksum); if (((hdr_core != 1) && (hdr_core != 2)) || (hdr_data_len > i)) { @@ -507,7 +509,7 @@ static int af9035_download_firmware(struct dvb_usb_device *d, u8 rbuf[4]; u8 tmp; struct usb_req req = { 0, 0, 0, NULL, 0, NULL }; - struct usb_req req_fw_ver = { CMD_FW_QUERYINFO, 0, 1, wbuf, 4, rbuf } ; + struct usb_req req_fw_ver = { CMD_FW_QUERYINFO, 0, 1, wbuf, 4, rbuf }; dev_dbg(&d->udev->dev, "%s:\n", __func__); /* @@ -1218,9 +1220,9 @@ static int af9035_init(struct dvb_usb_device *d) { 0x80f9a4, 0x00, 0x01 }, }; - dev_dbg(&d->udev->dev, "%s: USB speed=%d frame_size=%04x " \ - "packet_size=%02x\n", __func__, - d->udev->speed, frame_size, packet_size); + dev_dbg(&d->udev->dev, + "%s: USB speed=%d frame_size=%04x packet_size=%02x\n", + __func__, d->udev->speed, frame_size, packet_size); /* init endpoints */ for (i = 0; i < ARRAY_SIZE(tab); i++) { @@ -1495,7 +1497,7 @@ static const struct usb_device_id af9035_id_table[] = { &af9035_props, "AVerMedia Twinstar (A825)", NULL) }, { DVB_USB_DEVICE(USB_VID_ASUS, USB_PID_ASUS_U3100MINI_PLUS, &af9035_props, "Asus U3100Mini Plus", NULL) }, - { DVB_USB_DEVICE(USB_VID_TERRATEC, 0x00aa, + { DVB_USB_DEVICE(USB_VID_TERRATEC, 0x00aa, &af9035_props, "TerraTec Cinergy T Stick (rev. 2)", NULL) }, /* IT9135 devices */ #if 0 From e8292e28e3543fec62406551a026fcc0f2ca3cff Mon Sep 17 00:00:00 2001 From: Antti Palosaari Date: Mon, 3 Jun 2013 18:50:43 -0300 Subject: [PATCH 0099/1048] [media] af9035: minor log writing changes Signed-off-by: Antti Palosaari Signed-off-by: Mauro Carvalho Chehab --- drivers/media/usb/dvb-usb-v2/af9035.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/media/usb/dvb-usb-v2/af9035.c b/drivers/media/usb/dvb-usb-v2/af9035.c index 7d3b3c210e5f..e855ee6c86b5 100644 --- a/drivers/media/usb/dvb-usb-v2/af9035.c +++ b/drivers/media/usb/dvb-usb-v2/af9035.c @@ -55,7 +55,7 @@ static int af9035_ctrl_msg(struct dvb_usb_device *d, struct usb_req *req) if (req->wlen > (BUF_LEN - REQ_HDR_LEN - CHECKSUM_LEN) || req->rlen > (BUF_LEN - ACK_HDR_LEN - CHECKSUM_LEN)) { dev_err(&d->udev->dev, "%s: too much data wlen=%d rlen=%d\n", - __func__, req->wlen, req->rlen); + KBUILD_MODNAME, req->wlen, req->rlen); ret = -EINVAL; goto exit; } @@ -336,8 +336,8 @@ static int af9035_identify_state(struct dvb_usb_device *d, const char **name) dev_info(&d->udev->dev, "%s: prechip_version=%02x chip_version=%02x chip_type=%04x\n", - __func__, state->prechip_version, state->chip_version, - state->chip_type); + KBUILD_MODNAME, state->prechip_version, + state->chip_version, state->chip_type); if (state->chip_type == 0x9135) { if (state->chip_version == 0x02) From d716ef46fbb9de22de09516ecff990fe4e7799e3 Mon Sep 17 00:00:00 2001 From: Antti Palosaari Date: Mon, 3 Jun 2013 19:39:51 -0300 Subject: [PATCH 0100/1048] [media] af9035: correct TS mode handling Signed-off-by: Antti Palosaari Signed-off-by: Mauro Carvalho Chehab --- drivers/media/usb/dvb-usb-v2/af9035.c | 14 ++++++++------ drivers/media/usb/dvb-usb-v2/af9035.h | 11 ++++++++--- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/drivers/media/usb/dvb-usb-v2/af9035.c b/drivers/media/usb/dvb-usb-v2/af9035.c index e855ee6c86b5..1ea17dc2a76e 100644 --- a/drivers/media/usb/dvb-usb-v2/af9035.c +++ b/drivers/media/usb/dvb-usb-v2/af9035.c @@ -518,11 +518,11 @@ static int af9035_download_firmware(struct dvb_usb_device *d, * which is done by master demod. * Master feeds also clock and controls power via GPIO. */ - ret = af9035_rd_reg(d, state->eeprom_addr + EEPROM_DUAL_MODE, &tmp); + ret = af9035_rd_reg(d, state->eeprom_addr + EEPROM_TS_MODE, &tmp); if (ret < 0) goto err; - if (tmp) { + if (tmp == 1 || tmp == 3) { /* configure gpioh1, reset & power slave demod */ ret = af9035_wr_reg_mask(d, 0x00d8b0, 0x01, 0x01); if (ret < 0) @@ -640,13 +640,15 @@ static int af9035_read_config(struct dvb_usb_device *d) } /* check if there is dual tuners */ - ret = af9035_rd_reg(d, state->eeprom_addr + EEPROM_DUAL_MODE, &tmp); + ret = af9035_rd_reg(d, state->eeprom_addr + EEPROM_TS_MODE, &tmp); if (ret < 0) goto err; - state->dual_mode = tmp; - dev_dbg(&d->udev->dev, "%s: dual mode=%d\n", __func__, - state->dual_mode); + if (tmp == 1 || tmp == 3) + state->dual_mode = true; + + dev_dbg(&d->udev->dev, "%s: ts mode=%d dual mode=%d\n", __func__, + tmp, state->dual_mode); if (state->dual_mode) { /* read 2nd demodulator I2C address */ diff --git a/drivers/media/usb/dvb-usb-v2/af9035.h b/drivers/media/usb/dvb-usb-v2/af9035.h index b5827ca3a01e..a1c68d829b8c 100644 --- a/drivers/media/usb/dvb-usb-v2/af9035.h +++ b/drivers/media/usb/dvb-usb-v2/af9035.h @@ -100,8 +100,13 @@ static const u32 clock_lut_it9135[] = { * eeprom is memory mapped as read only. Writing that memory mapped address * will not corrupt eeprom. * - * eeprom has value 0x00 single mode and 0x03 for dual mode as far as I have - * seen to this day. + * TS mode: + * 0 TS + * 1 DCA + PIP + * 3 PIP + * n DCA + * + * Values 0 and 3 are seen to this day. 0 for single TS and 3 for dual TS. */ #define EEPROM_BASE_AF9035 0x42fd @@ -109,7 +114,7 @@ static const u32 clock_lut_it9135[] = { #define EEPROM_SHIFT 0x10 #define EEPROM_IR_MODE 0x10 -#define EEPROM_DUAL_MODE 0x29 +#define EEPROM_TS_MODE 0x29 #define EEPROM_2ND_DEMOD_ADDR 0x2a #define EEPROM_IR_TYPE 0x2c #define EEPROM_1_IF_L 0x30 From 1bddf1b3ac021feb9dafcc2c6ef7018453e22589 Mon Sep 17 00:00:00 2001 From: Andrzej Hajda Date: Mon, 3 Jun 2013 05:16:13 -0300 Subject: [PATCH 0101/1048] [media] media: Rename media_entity_remote_source to media_entity_remote_pad Function media_entity_remote_source actually returns the remote pad to the given one, regardless if this is the source or the sink pad. Name media_entity_remote_pad is more adequate for this function. Signed-off-by: Andrzej Hajda Signed-off-by: Kyungmin Park Acked-by: Sakari Ailus Acked-by: Sylwester Nawrocki Signed-off-by: Laurent Pinchart Signed-off-by: Mauro Carvalho Chehab --- Documentation/media-framework.txt | 2 +- drivers/media/media-entity.c | 13 ++++++------- drivers/media/platform/exynos4-is/fimc-capture.c | 6 +++--- drivers/media/platform/exynos4-is/fimc-lite.c | 4 ++-- drivers/media/platform/exynos4-is/media-dev.c | 2 +- drivers/media/platform/omap3isp/isp.c | 6 +++--- drivers/media/platform/omap3isp/ispccdc.c | 2 +- drivers/media/platform/omap3isp/ispccp2.c | 2 +- drivers/media/platform/omap3isp/ispcsi2.c | 2 +- drivers/media/platform/omap3isp/ispvideo.c | 6 +++--- drivers/media/platform/s3c-camif/camif-capture.c | 2 +- drivers/staging/media/davinci_vpfe/vpfe_video.c | 12 ++++++------ include/media/media-entity.h | 2 +- 13 files changed, 30 insertions(+), 31 deletions(-) diff --git a/Documentation/media-framework.txt b/Documentation/media-framework.txt index 77bd0a42f19d..3702eff30db3 100644 --- a/Documentation/media-framework.txt +++ b/Documentation/media-framework.txt @@ -265,7 +265,7 @@ connected to another pad through an enabled link media_entity_find_link(struct media_pad *source, struct media_pad *sink); - media_entity_remote_source(struct media_pad *pad); + media_entity_remote_pad(struct media_pad *pad); Refer to the kerneldoc documentation for more information. diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c index e1cd13283407..0438209d020a 100644 --- a/drivers/media/media-entity.c +++ b/drivers/media/media-entity.c @@ -560,17 +560,16 @@ media_entity_find_link(struct media_pad *source, struct media_pad *sink) EXPORT_SYMBOL_GPL(media_entity_find_link); /** - * media_entity_remote_source - Find the source pad at the remote end of a link - * @pad: Sink pad at the local end of the link + * media_entity_remote_pad - Find the pad at the remote end of a link + * @pad: Pad at the local end of the link * - * Search for a remote source pad connected to the given sink pad by iterating - * over all links originating or terminating at that pad until an enabled link - * is found. + * Search for a remote pad connected to the given pad by iterating over all + * links originating or terminating at that pad until an enabled link is found. * * Return a pointer to the pad at the remote end of the first found enabled * link, or NULL if no enabled link has been found. */ -struct media_pad *media_entity_remote_source(struct media_pad *pad) +struct media_pad *media_entity_remote_pad(struct media_pad *pad) { unsigned int i; @@ -590,4 +589,4 @@ struct media_pad *media_entity_remote_source(struct media_pad *pad) return NULL; } -EXPORT_SYMBOL_GPL(media_entity_remote_source); +EXPORT_SYMBOL_GPL(media_entity_remote_pad); diff --git a/drivers/media/platform/exynos4-is/fimc-capture.c b/drivers/media/platform/exynos4-is/fimc-capture.c index 528f41369364..a8b9b06d96aa 100644 --- a/drivers/media/platform/exynos4-is/fimc-capture.c +++ b/drivers/media/platform/exynos4-is/fimc-capture.c @@ -773,7 +773,7 @@ static struct media_entity *fimc_pipeline_get_head(struct media_entity *me) struct media_pad *pad = &me->pads[0]; while (!(pad->flags & MEDIA_PAD_FL_SOURCE)) { - pad = media_entity_remote_source(pad); + pad = media_entity_remote_pad(pad); if (!pad) break; me = pad->entity; @@ -845,7 +845,7 @@ static int fimc_pipeline_try_format(struct fimc_ctx *ctx, return ret; } - pad = media_entity_remote_source(&me->pads[sfmt.pad]); + pad = media_entity_remote_pad(&me->pads[sfmt.pad]); if (!pad) return -EINVAL; me = pad->entity; @@ -1146,7 +1146,7 @@ static int fimc_pipeline_validate(struct fimc_dev *fimc) if (p->flags & MEDIA_PAD_FL_SINK) { sink_pad = p; - src_pad = media_entity_remote_source(sink_pad); + src_pad = media_entity_remote_pad(sink_pad); if (src_pad) break; } diff --git a/drivers/media/platform/exynos4-is/fimc-lite.c b/drivers/media/platform/exynos4-is/fimc-lite.c index 14bb7bc8adbe..2f11ae4fd4a4 100644 --- a/drivers/media/platform/exynos4-is/fimc-lite.c +++ b/drivers/media/platform/exynos4-is/fimc-lite.c @@ -139,7 +139,7 @@ static struct v4l2_subdev *__find_remote_sensor(struct media_entity *me) while (pad->flags & MEDIA_PAD_FL_SINK) { /* source pad */ - pad = media_entity_remote_source(pad); + pad = media_entity_remote_pad(pad); if (pad == NULL || media_entity_type(pad->entity) != MEDIA_ENT_T_V4L2_SUBDEV) break; @@ -786,7 +786,7 @@ static int fimc_pipeline_validate(struct fimc_lite *fimc) return -EPIPE; } /* Retrieve format at the source pad */ - pad = media_entity_remote_source(pad); + pad = media_entity_remote_pad(pad); if (pad == NULL || media_entity_type(pad->entity) != MEDIA_ENT_T_V4L2_SUBDEV) break; diff --git a/drivers/media/platform/exynos4-is/media-dev.c b/drivers/media/platform/exynos4-is/media-dev.c index 15ef8f28239b..396e06e14a17 100644 --- a/drivers/media/platform/exynos4-is/media-dev.c +++ b/drivers/media/platform/exynos4-is/media-dev.c @@ -62,7 +62,7 @@ static void fimc_pipeline_prepare(struct fimc_pipeline *p, struct media_pad *spad = &me->pads[i]; if (!(spad->flags & MEDIA_PAD_FL_SINK)) continue; - pad = media_entity_remote_source(spad); + pad = media_entity_remote_pad(spad); if (pad) break; } diff --git a/drivers/media/platform/omap3isp/isp.c b/drivers/media/platform/omap3isp/isp.c index 1d7dbd5c0fba..4c4bd3d1a2bc 100644 --- a/drivers/media/platform/omap3isp/isp.c +++ b/drivers/media/platform/omap3isp/isp.c @@ -877,7 +877,7 @@ static int isp_pipeline_enable(struct isp_pipeline *pipe, if (!(pad->flags & MEDIA_PAD_FL_SINK)) break; - pad = media_entity_remote_source(pad); + pad = media_entity_remote_pad(pad); if (pad == NULL || media_entity_type(pad->entity) != MEDIA_ENT_T_V4L2_SUBDEV) break; @@ -967,7 +967,7 @@ static int isp_pipeline_disable(struct isp_pipeline *pipe) if (!(pad->flags & MEDIA_PAD_FL_SINK)) break; - pad = media_entity_remote_source(pad); + pad = media_entity_remote_pad(pad); if (pad == NULL || media_entity_type(pad->entity) != MEDIA_ENT_T_V4L2_SUBDEV) break; @@ -1083,7 +1083,7 @@ static int isp_pipeline_is_last(struct media_entity *me) pipe = to_isp_pipeline(me); if (pipe->stream_state == ISP_PIPELINE_STREAM_STOPPED) return 0; - pad = media_entity_remote_source(&pipe->output->pad); + pad = media_entity_remote_pad(&pipe->output->pad); return pad->entity == me; } diff --git a/drivers/media/platform/omap3isp/ispccdc.c b/drivers/media/platform/omap3isp/ispccdc.c index 60e60aa64fb4..907a205da5a5 100644 --- a/drivers/media/platform/omap3isp/ispccdc.c +++ b/drivers/media/platform/omap3isp/ispccdc.c @@ -1120,7 +1120,7 @@ static void ccdc_configure(struct isp_ccdc_device *ccdc) u32 syn_mode; u32 ccdc_pattern; - pad = media_entity_remote_source(&ccdc->pads[CCDC_PAD_SINK]); + pad = media_entity_remote_pad(&ccdc->pads[CCDC_PAD_SINK]); sensor = media_entity_to_v4l2_subdev(pad->entity); if (ccdc->input == CCDC_INPUT_PARALLEL) pdata = &((struct isp_v4l2_subdevs_group *)sensor->host_priv) diff --git a/drivers/media/platform/omap3isp/ispccp2.c b/drivers/media/platform/omap3isp/ispccp2.c index c5d84c977e29..13982b0ab560 100644 --- a/drivers/media/platform/omap3isp/ispccp2.c +++ b/drivers/media/platform/omap3isp/ispccp2.c @@ -360,7 +360,7 @@ static int ccp2_if_configure(struct isp_ccp2_device *ccp2) ccp2_pwr_cfg(ccp2); - pad = media_entity_remote_source(&ccp2->pads[CCP2_PAD_SINK]); + pad = media_entity_remote_pad(&ccp2->pads[CCP2_PAD_SINK]); sensor = media_entity_to_v4l2_subdev(pad->entity); pdata = sensor->host_priv; diff --git a/drivers/media/platform/omap3isp/ispcsi2.c b/drivers/media/platform/omap3isp/ispcsi2.c index 783f4b05b153..6db245d84bbb 100644 --- a/drivers/media/platform/omap3isp/ispcsi2.c +++ b/drivers/media/platform/omap3isp/ispcsi2.c @@ -573,7 +573,7 @@ static int csi2_configure(struct isp_csi2_device *csi2) if (csi2->contexts[0].enabled || csi2->ctrl.if_enable) return -EBUSY; - pad = media_entity_remote_source(&csi2->pads[CSI2_PAD_SINK]); + pad = media_entity_remote_pad(&csi2->pads[CSI2_PAD_SINK]); sensor = media_entity_to_v4l2_subdev(pad->entity); pdata = sensor->host_priv; diff --git a/drivers/media/platform/omap3isp/ispvideo.c b/drivers/media/platform/omap3isp/ispvideo.c index 8dac17511e61..a908d006f527 100644 --- a/drivers/media/platform/omap3isp/ispvideo.c +++ b/drivers/media/platform/omap3isp/ispvideo.c @@ -219,7 +219,7 @@ isp_video_remote_subdev(struct isp_video *video, u32 *pad) { struct media_pad *remote; - remote = media_entity_remote_source(&video->pad); + remote = media_entity_remote_pad(&video->pad); if (remote == NULL || media_entity_type(remote->entity) != MEDIA_ENT_T_V4L2_SUBDEV) @@ -314,7 +314,7 @@ static int isp_video_validate_pipeline(struct isp_pipeline *pipe) * entity can be found, and stop checking the pipeline if the * source entity isn't a subdev. */ - pad = media_entity_remote_source(pad); + pad = media_entity_remote_pad(pad); if (pad == NULL) return -EPIPE; @@ -901,7 +901,7 @@ static int isp_video_check_external_subdevs(struct isp_video *video, continue; /* ISP entities have always sink pad == 0. Find source. */ - source_pad = media_entity_remote_source(&ents[i]->pads[0]); + source_pad = media_entity_remote_pad(&ents[i]->pads[0]); if (source_pad == NULL) continue; diff --git a/drivers/media/platform/s3c-camif/camif-capture.c b/drivers/media/platform/s3c-camif/camif-capture.c index 70438a0f62ae..40b298ab87f1 100644 --- a/drivers/media/platform/s3c-camif/camif-capture.c +++ b/drivers/media/platform/s3c-camif/camif-capture.c @@ -845,7 +845,7 @@ static int camif_pipeline_validate(struct camif_dev *camif) int ret; /* Retrieve format at the sensor subdev source pad */ - pad = media_entity_remote_source(&camif->pads[0]); + pad = media_entity_remote_pad(&camif->pads[0]); if (!pad || media_entity_type(pad->entity) != MEDIA_ENT_T_V4L2_SUBDEV) return -EPIPE; diff --git a/drivers/staging/media/davinci_vpfe/vpfe_video.c b/drivers/staging/media/davinci_vpfe/vpfe_video.c index ba913f1d955b..cb5410b390ef 100644 --- a/drivers/staging/media/davinci_vpfe/vpfe_video.c +++ b/drivers/staging/media/davinci_vpfe/vpfe_video.c @@ -39,7 +39,7 @@ static struct media_entity *vpfe_get_input_entity struct vpfe_device *vpfe_dev = video->vpfe_dev; struct media_pad *remote; - remote = media_entity_remote_source(&vpfe_dev->vpfe_isif.pads[0]); + remote = media_entity_remote_pad(&vpfe_dev->vpfe_isif.pads[0]); if (remote == NULL) { pr_err("Invalid media connection to isif/ccdc\n"); return NULL; @@ -56,7 +56,7 @@ static int vpfe_update_current_ext_subdev(struct vpfe_video_device *video) struct media_pad *remote; int i; - remote = media_entity_remote_source(&vpfe_dev->vpfe_isif.pads[0]); + remote = media_entity_remote_pad(&vpfe_dev->vpfe_isif.pads[0]); if (remote == NULL) { pr_err("Invalid media connection to isif/ccdc\n"); return -EINVAL; @@ -89,7 +89,7 @@ static int vpfe_update_current_ext_subdev(struct vpfe_video_device *video) static struct v4l2_subdev * vpfe_video_remote_subdev(struct vpfe_video_device *video, u32 *pad) { - struct media_pad *remote = media_entity_remote_source(&video->pad); + struct media_pad *remote = media_entity_remote_pad(&video->pad); if (remote == NULL || remote->entity->type != MEDIA_ENT_T_V4L2_SUBDEV) return NULL; @@ -114,7 +114,7 @@ __vpfe_video_get_format(struct vpfe_video_device *video, return -EINVAL; fmt.which = V4L2_SUBDEV_FORMAT_ACTIVE; - remote = media_entity_remote_source(&video->pad); + remote = media_entity_remote_pad(&video->pad); fmt.pad = remote->index; ret = v4l2_subdev_call(subdev, pad, get_fmt, NULL, &fmt); @@ -245,7 +245,7 @@ static int vpfe_video_validate_pipeline(struct vpfe_pipeline *pipe) return -EPIPE; /* Retrieve the source format */ - pad = media_entity_remote_source(pad); + pad = media_entity_remote_pad(pad); if (pad == NULL || pad->entity->type != MEDIA_ENT_T_V4L2_SUBDEV) break; @@ -667,7 +667,7 @@ static int vpfe_enum_fmt(struct file *file, void *priv, return -EINVAL; } /* get the remote pad */ - remote = media_entity_remote_source(&video->pad); + remote = media_entity_remote_pad(&video->pad); if (remote == NULL) { v4l2_err(&vpfe_dev->v4l2_dev, "invalid remote pad for video node\n"); diff --git a/include/media/media-entity.h b/include/media/media-entity.h index 0c16f518ee09..4eefedcaa66d 100644 --- a/include/media/media-entity.h +++ b/include/media/media-entity.h @@ -132,7 +132,7 @@ int __media_entity_setup_link(struct media_link *link, u32 flags); int media_entity_setup_link(struct media_link *link, u32 flags); struct media_link *media_entity_find_link(struct media_pad *source, struct media_pad *sink); -struct media_pad *media_entity_remote_source(struct media_pad *pad); +struct media_pad *media_entity_remote_pad(struct media_pad *pad); struct media_entity *media_entity_get(struct media_entity *entity); void media_entity_put(struct media_entity *entity); From 1e41413f9869c4a688b2f937ff50584bd62eeb31 Mon Sep 17 00:00:00 2001 From: Rodrigo Tartajo Date: Sat, 20 Apr 2013 20:02:12 -0300 Subject: [PATCH 0102/1048] [media] rtl2832u: restore ir remote control support Hi, This patch uses the driver from openpli[1] as a template to restore the remote control support. I had to divert from the original to use the in kernel rc protocol decoder. The key repetition does, not seem to work but I cant find the problem in the driver. As a raw rc provider, no key table is hardcoded. Rodrigo. [1]: https://aur.archlinux.org/packages/dvb-usb-rtl2832u-openpli/?comments=all Signed-off-by: Rodrigo Tartajo Signed-off-by: Antti Palosaari Signed-off-by: Mauro Carvalho Chehab --- drivers/media/usb/dvb-usb-v2/dvb_usb.h | 2 +- drivers/media/usb/dvb-usb-v2/rtl28xxu.c | 83 +++++++++++++++++++++---- drivers/media/usb/dvb-usb-v2/rtl28xxu.h | 11 ++++ 3 files changed, 83 insertions(+), 13 deletions(-) diff --git a/drivers/media/usb/dvb-usb-v2/dvb_usb.h b/drivers/media/usb/dvb-usb-v2/dvb_usb.h index 658c6d47fdff..399916bd588f 100644 --- a/drivers/media/usb/dvb-usb-v2/dvb_usb.h +++ b/drivers/media/usb/dvb-usb-v2/dvb_usb.h @@ -140,7 +140,7 @@ struct dvb_usb_rc { int (*change_protocol)(struct rc_dev *dev, u64 *rc_type); int (*query) (struct dvb_usb_device *d); unsigned int interval; - const enum rc_driver_type driver_type; + enum rc_driver_type driver_type; bool bulk_mode; }; diff --git a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c index 22015fe1a0f3..e592662ccc06 100644 --- a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c +++ b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c @@ -1249,11 +1249,21 @@ static int rtl2831u_get_rc_config(struct dvb_usb_device *d, #if IS_ENABLED(CONFIG_RC_CORE) static int rtl2832u_rc_query(struct dvb_usb_device *d) { +#define TICSAT38KHZTONS(x) ((x) * (1000000000/38000)) int ret, i; struct rtl28xxu_priv *priv = d->priv; u8 buf[128]; int len; - struct rtl28xxu_reg_val rc_nec_tab[] = { + struct ir_raw_event ev; //encode single ir event (pulse or space) + struct rtl28xxu_xreg_val rc_sys_init_tab[] = { + { SYS_DEMOD_CTL1, OP_AND, 0xfb }, + { SYS_DEMOD_CTL1, OP_AND, 0xf7 }, + { USB_CTRL, OP_OR , 0x20 }, + { SYS_SYS1, OP_AND, 0xf7 }, + { SYS_GPIO_OUT_EN, OP_OR , 0x08 }, + { SYS_GPIO_OUT_VAL, OP_OR , 0x08 }, + }; // system hard init + struct rtl28xxu_reg_val rc_init_tab[] = { { IR_RX_CTRL, 0x20 }, { IR_RX_BUF_CTRL, 0x80 }, { IR_RX_IF, 0xff }, @@ -1268,13 +1278,40 @@ static int rtl2832u_rc_query(struct dvb_usb_device *d) { IR_MAX_H_TOL_LEN, 0x1e }, { IR_MAX_L_TOL_LEN, 0x1e }, { IR_RX_CTRL, 0x80 }, - }; + }; // hard init + struct rtl28xxu_reg_val rc_reinit_tab[] = { + { IR_RX_CTRL, 0x20 }, + { IR_RX_BUF_CTRL, 0x80 }, + { IR_RX_IF, 0xff }, + { IR_RX_IE, 0xff }, + { IR_RX_CTRL, 0x80 }, + }; // reinit IR + struct rtl28xxu_reg_val rc_clear_tab[] = { + { IR_RX_IF, 0x03 }, + { IR_RX_BUF_CTRL, 0x80 }, + { IR_RX_CTRL, 0x80 }, + }; // clear reception /* init remote controller */ if (!priv->rc_active) { - for (i = 0; i < ARRAY_SIZE(rc_nec_tab); i++) { - ret = rtl28xx_wr_reg(d, rc_nec_tab[i].reg, - rc_nec_tab[i].val); + for (i = 0; i < ARRAY_SIZE(rc_sys_init_tab); i++) { + ret = rtl28xx_rd_reg(d, rc_sys_init_tab[i].reg, &buf[0]); + if (ret) + goto err; + if (rc_sys_init_tab[i].op == OP_AND) { + buf[0] &= rc_sys_init_tab[i].mask; + } + else {//OP_OR + buf[0] |= rc_sys_init_tab[i].mask; + } + ret = rtl28xx_wr_reg(d, rc_sys_init_tab[i].reg, + buf[0]); + if (ret) + goto err; + } + for (i = 0; i < ARRAY_SIZE(rc_init_tab); i++) { + ret = rtl28xx_wr_reg(d, rc_init_tab[i].reg, + rc_init_tab[i].val); if (ret) goto err; } @@ -1286,7 +1323,7 @@ static int rtl2832u_rc_query(struct dvb_usb_device *d) goto err; if (buf[0] != 0x83) - goto exit; + goto err; ret = rtl28xx_rd_reg(d, IR_RX_BC, &buf[0]); if (ret) @@ -1295,26 +1332,48 @@ static int rtl2832u_rc_query(struct dvb_usb_device *d) len = buf[0]; ret = rtl2831_rd_regs(d, IR_RX_BUF, buf, len); - /* TODO: pass raw IR to Kernel IR decoder */ + /* pass raw IR to Kernel IR decoder */ + init_ir_raw_event(&ev); + ir_raw_event_reset(d->rc_dev); + ev.pulse=1; + for(i=0; true; ++i) { // conver count to time + if (i >= len || !(buf[i] & 0x80) != !(ev.pulse)) {//end or transition pulse/space: flush + ir_raw_event_store(d->rc_dev, &ev); + ev.duration = 0; + } + if (i >= len) + break; + ev.pulse = buf[i] >> 7; + ev.duration += TICSAT38KHZTONS(((u32)(buf[i] & 0x7F)) << 1); + } + ir_raw_event_handle(d->rc_dev); - ret = rtl28xx_wr_reg(d, IR_RX_IF, 0x03); - ret = rtl28xx_wr_reg(d, IR_RX_BUF_CTRL, 0x80); - ret = rtl28xx_wr_reg(d, IR_RX_CTRL, 0x80); + for (i = 0; i < ARRAY_SIZE(rc_clear_tab); i++) { + ret = rtl28xx_wr_reg(d, rc_clear_tab[i].reg, + rc_clear_tab[i].val); + if (ret) + goto err; + } -exit: return ret; err: + for (i = 0; i < ARRAY_SIZE(rc_reinit_tab); i++) { + ret = rtl28xx_wr_reg(d, rc_reinit_tab[i].reg, + rc_reinit_tab[i].val); + } dev_dbg(&d->udev->dev, "%s: failed=%d\n", __func__, ret); return ret; +#undef TICSAT38KHZTONS } static int rtl2832u_get_rc_config(struct dvb_usb_device *d, struct dvb_usb_rc *rc) { rc->map_name = RC_MAP_EMPTY; - rc->allowed_protos = RC_BIT_NEC; + rc->allowed_protos = RC_BIT_ALL; rc->query = rtl2832u_rc_query; rc->interval = 400; + rc->driver_type = RC_DRIVER_IR_RAW; return 0; } diff --git a/drivers/media/usb/dvb-usb-v2/rtl28xxu.h b/drivers/media/usb/dvb-usb-v2/rtl28xxu.h index 533a33127289..0177b3871ba4 100644 --- a/drivers/media/usb/dvb-usb-v2/rtl28xxu.h +++ b/drivers/media/usb/dvb-usb-v2/rtl28xxu.h @@ -97,6 +97,17 @@ struct rtl28xxu_reg_val { u8 val; }; +enum OP{ + OP_AND =0, + OP_OR +}; + +struct rtl28xxu_xreg_val { + u16 reg; + u8 op; + u8 mask; +}; + /* * memory map * From f39fac3e409322d23261e89374a7d9daecfd6acb Mon Sep 17 00:00:00 2001 From: Antti Palosaari Date: Tue, 4 Jun 2013 09:17:03 -0300 Subject: [PATCH 0103/1048] [media] rtl28xxu: reimplement rtl2832u remote controller Thanks to Rodrigo for original implementation! Signed-off-by: Antti Palosaari Signed-off-by: Mauro Carvalho Chehab --- drivers/media/usb/dvb-usb-v2/rtl28xxu.c | 152 +++++++++--------------- drivers/media/usb/dvb-usb-v2/rtl28xxu.h | 9 +- 2 files changed, 58 insertions(+), 103 deletions(-) diff --git a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c index e592662ccc06..416701167434 100644 --- a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c +++ b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c @@ -1114,17 +1114,6 @@ static int rtl2832u_power_ctrl(struct dvb_usb_device *d, int onoff) if (ret) goto err; } else { - /* demod_ctl_1 */ - ret = rtl28xx_rd_reg(d, SYS_DEMOD_CTL1, &val); - if (ret) - goto err; - - val |= 0x0c; - - ret = rtl28xx_wr_reg(d, SYS_DEMOD_CTL1, val); - if (ret) - goto err; - /* set output values */ ret = rtl28xx_rd_reg(d, SYS_GPIO_OUT_VAL, &val); if (ret) @@ -1249,72 +1238,44 @@ static int rtl2831u_get_rc_config(struct dvb_usb_device *d, #if IS_ENABLED(CONFIG_RC_CORE) static int rtl2832u_rc_query(struct dvb_usb_device *d) { -#define TICSAT38KHZTONS(x) ((x) * (1000000000/38000)) - int ret, i; + int ret, i, len; struct rtl28xxu_priv *priv = d->priv; + struct ir_raw_event ev; u8 buf[128]; - int len; - struct ir_raw_event ev; //encode single ir event (pulse or space) - struct rtl28xxu_xreg_val rc_sys_init_tab[] = { - { SYS_DEMOD_CTL1, OP_AND, 0xfb }, - { SYS_DEMOD_CTL1, OP_AND, 0xf7 }, - { USB_CTRL, OP_OR , 0x20 }, - { SYS_SYS1, OP_AND, 0xf7 }, - { SYS_GPIO_OUT_EN, OP_OR , 0x08 }, - { SYS_GPIO_OUT_VAL, OP_OR , 0x08 }, - }; // system hard init - struct rtl28xxu_reg_val rc_init_tab[] = { - { IR_RX_CTRL, 0x20 }, - { IR_RX_BUF_CTRL, 0x80 }, - { IR_RX_IF, 0xff }, - { IR_RX_IE, 0xff }, - { IR_MAX_DURATION0, 0xd0 }, - { IR_MAX_DURATION1, 0x07 }, - { IR_IDLE_LEN0, 0xc0 }, - { IR_IDLE_LEN1, 0x00 }, - { IR_GLITCH_LEN, 0x03 }, - { IR_RX_CLK, 0x09 }, - { IR_RX_CFG, 0x1c }, - { IR_MAX_H_TOL_LEN, 0x1e }, - { IR_MAX_L_TOL_LEN, 0x1e }, - { IR_RX_CTRL, 0x80 }, - }; // hard init - struct rtl28xxu_reg_val rc_reinit_tab[] = { - { IR_RX_CTRL, 0x20 }, - { IR_RX_BUF_CTRL, 0x80 }, - { IR_RX_IF, 0xff }, - { IR_RX_IE, 0xff }, - { IR_RX_CTRL, 0x80 }, - }; // reinit IR - struct rtl28xxu_reg_val rc_clear_tab[] = { - { IR_RX_IF, 0x03 }, - { IR_RX_BUF_CTRL, 0x80 }, - { IR_RX_CTRL, 0x80 }, - }; // clear reception + static const struct rtl28xxu_reg_val_mask refresh_tab[] = { + {IR_RX_IF, 0x03, 0xff}, + {IR_RX_BUF_CTRL, 0x80, 0xff}, + {IR_RX_CTRL, 0x80, 0xff}, + }; /* init remote controller */ if (!priv->rc_active) { - for (i = 0; i < ARRAY_SIZE(rc_sys_init_tab); i++) { - ret = rtl28xx_rd_reg(d, rc_sys_init_tab[i].reg, &buf[0]); - if (ret) - goto err; - if (rc_sys_init_tab[i].op == OP_AND) { - buf[0] &= rc_sys_init_tab[i].mask; - } - else {//OP_OR - buf[0] |= rc_sys_init_tab[i].mask; - } - ret = rtl28xx_wr_reg(d, rc_sys_init_tab[i].reg, - buf[0]); - if (ret) - goto err; - } - for (i = 0; i < ARRAY_SIZE(rc_init_tab); i++) { - ret = rtl28xx_wr_reg(d, rc_init_tab[i].reg, - rc_init_tab[i].val); + static const struct rtl28xxu_reg_val_mask init_tab[] = { + {SYS_DEMOD_CTL1, 0x00, 0x04}, + {SYS_DEMOD_CTL1, 0x00, 0x08}, + {USB_CTRL, 0x20, 0x20}, + {SYS_GPIO_DIR, 0x00, 0x08}, + {SYS_GPIO_OUT_EN, 0x08, 0x08}, + {SYS_GPIO_OUT_VAL, 0x08, 0x08}, + {IR_MAX_DURATION0, 0xd0, 0xff}, + {IR_MAX_DURATION1, 0x07, 0xff}, + {IR_IDLE_LEN0, 0xc0, 0xff}, + {IR_IDLE_LEN1, 0x00, 0xff}, + {IR_GLITCH_LEN, 0x03, 0xff}, + {IR_RX_CLK, 0x09, 0xff}, + {IR_RX_CFG, 0x1c, 0xff}, + {IR_MAX_H_TOL_LEN, 0x1e, 0xff}, + {IR_MAX_L_TOL_LEN, 0x1e, 0xff}, + {IR_RX_CTRL, 0x80, 0xff}, + }; + + for (i = 0; i < ARRAY_SIZE(init_tab); i++) { + ret = rtl28xx_wr_reg_mask(d, init_tab[i].reg, + init_tab[i].val, init_tab[i].mask); if (ret) goto err; } + priv->rc_active = true; } @@ -1323,57 +1284,56 @@ static int rtl2832u_rc_query(struct dvb_usb_device *d) goto err; if (buf[0] != 0x83) - goto err; + goto exit; ret = rtl28xx_rd_reg(d, IR_RX_BC, &buf[0]); if (ret) goto err; len = buf[0]; + + /* read raw code from hw */ ret = rtl2831_rd_regs(d, IR_RX_BUF, buf, len); + if (ret) + goto err; - /* pass raw IR to Kernel IR decoder */ - init_ir_raw_event(&ev); - ir_raw_event_reset(d->rc_dev); - ev.pulse=1; - for(i=0; true; ++i) { // conver count to time - if (i >= len || !(buf[i] & 0x80) != !(ev.pulse)) {//end or transition pulse/space: flush - ir_raw_event_store(d->rc_dev, &ev); - ev.duration = 0; - } - if (i >= len) - break; - ev.pulse = buf[i] >> 7; - ev.duration += TICSAT38KHZTONS(((u32)(buf[i] & 0x7F)) << 1); - } - ir_raw_event_handle(d->rc_dev); - - for (i = 0; i < ARRAY_SIZE(rc_clear_tab); i++) { - ret = rtl28xx_wr_reg(d, rc_clear_tab[i].reg, - rc_clear_tab[i].val); + /* let hw receive new code */ + for (i = 0; i < ARRAY_SIZE(refresh_tab); i++) { + ret = rtl28xx_wr_reg_mask(d, refresh_tab[i].reg, + refresh_tab[i].val, refresh_tab[i].mask); if (ret) goto err; } + /* pass data to Kernel IR decoder */ + init_ir_raw_event(&ev); + + for (i = 0; i < len; i++) { + ev.pulse = buf[i] >> 7; + ev.duration = 50800 * (buf[i] & 0x7f); + ir_raw_event_store_with_filter(d->rc_dev, &ev); + } + + /* 'flush' ir_raw_event_store_with_filter() */ + ir_raw_event_set_idle(d->rc_dev, true); + ir_raw_event_handle(d->rc_dev); +exit: return ret; err: - for (i = 0; i < ARRAY_SIZE(rc_reinit_tab); i++) { - ret = rtl28xx_wr_reg(d, rc_reinit_tab[i].reg, - rc_reinit_tab[i].val); - } dev_dbg(&d->udev->dev, "%s: failed=%d\n", __func__, ret); return ret; -#undef TICSAT38KHZTONS } static int rtl2832u_get_rc_config(struct dvb_usb_device *d, struct dvb_usb_rc *rc) { - rc->map_name = RC_MAP_EMPTY; + /* load empty to enable rc */ + if (!rc->map_name) + rc->map_name = RC_MAP_EMPTY; rc->allowed_protos = RC_BIT_ALL; + rc->driver_type = RC_DRIVER_IR_RAW; rc->query = rtl2832u_rc_query; rc->interval = 400; - rc->driver_type = RC_DRIVER_IR_RAW; return 0; } diff --git a/drivers/media/usb/dvb-usb-v2/rtl28xxu.h b/drivers/media/usb/dvb-usb-v2/rtl28xxu.h index 0177b3871ba4..729b3540c2f9 100644 --- a/drivers/media/usb/dvb-usb-v2/rtl28xxu.h +++ b/drivers/media/usb/dvb-usb-v2/rtl28xxu.h @@ -97,14 +97,9 @@ struct rtl28xxu_reg_val { u8 val; }; -enum OP{ - OP_AND =0, - OP_OR -}; - -struct rtl28xxu_xreg_val { +struct rtl28xxu_reg_val_mask { u16 reg; - u8 op; + u8 val; u8 mask; }; From 5a18664e49549762d09e771ad02111d2c2721dc8 Mon Sep 17 00:00:00 2001 From: Antti Palosaari Date: Tue, 4 Jun 2013 16:50:54 -0300 Subject: [PATCH 0104/1048] [media] rtl28xxu: remove redundant IS_ENABLED macro Signed-off-by: Antti Palosaari Signed-off-by: Mauro Carvalho Chehab --- drivers/media/usb/dvb-usb-v2/rtl28xxu.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c index 416701167434..8bbc6abc9d35 100644 --- a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c +++ b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c @@ -1231,11 +1231,7 @@ static int rtl2831u_get_rc_config(struct dvb_usb_device *d, return 0; } -#else - #define rtl2831u_get_rc_config NULL -#endif -#if IS_ENABLED(CONFIG_RC_CORE) static int rtl2832u_rc_query(struct dvb_usb_device *d) { int ret, i, len; @@ -1338,7 +1334,8 @@ static int rtl2832u_get_rc_config(struct dvb_usb_device *d, return 0; } #else - #define rtl2832u_get_rc_config NULL +#define rtl2831u_get_rc_config NULL +#define rtl2832u_get_rc_config NULL #endif static const struct dvb_usb_device_properties rtl2831u_props = { From 6c5a4065ebb785bd60fdab4eebbf6582177d563a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20=C5=A0ustek?= Date: Tue, 14 May 2013 19:42:11 -0300 Subject: [PATCH 0105/1048] [media] rtl28xxu: Add USB ID for Leadtek WinFast DTV Dongle mini MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit USB ID 0413:6a03 is Leadtek WinFast DTV Dongle mini. Decoder Realtek RTL2832U and tuner Infineon TUA9001. Signed-off-by: Miroslav Šustek Signed-off-by: Antti Palosaari Signed-off-by: Mauro Carvalho Chehab --- drivers/media/usb/dvb-usb-v2/rtl28xxu.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c index 8bbc6abc9d35..0045b198a537 100644 --- a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c +++ b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c @@ -1424,6 +1424,8 @@ static const struct usb_device_id rtl28xxu_id_table[] = { &rtl2832u_props, "Compro VideoMate U620F", NULL) }, { DVB_USB_DEVICE(USB_VID_KWORLD_2, 0xd394, &rtl2832u_props, "MaxMedia HU394-T", NULL) }, + { DVB_USB_DEVICE(USB_VID_LEADTEK, 0x6a03, + &rtl2832u_props, "WinFast DTV Dongle mini", NULL) }, { } }; MODULE_DEVICE_TABLE(usb, rtl28xxu_id_table); From 7dc0a0163498f922aa00051d0d8d438926d4d249 Mon Sep 17 00:00:00 2001 From: Antti Palosaari Date: Tue, 4 Jun 2013 17:01:25 -0300 Subject: [PATCH 0106/1048] [media] rtl28xxu: correct some device names ... just because I want to be perfect ;) Signed-off-by: Antti Palosaari Signed-off-by: Mauro Carvalho Chehab --- drivers/media/usb/dvb-usb-v2/rtl28xxu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c index 0045b198a537..93313f70621c 100644 --- a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c +++ b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c @@ -1419,13 +1419,13 @@ static const struct usb_device_id rtl28xxu_id_table[] = { { DVB_USB_DEVICE(USB_VID_KWORLD_2, 0xd393, &rtl2832u_props, "GIGABYTE U7300", NULL) }, { DVB_USB_DEVICE(USB_VID_DEXATEK, 0x1104, - &rtl2832u_props, "Digivox Micro Hd", NULL) }, + &rtl2832u_props, "MSI DIGIVOX Micro HD", NULL) }, { DVB_USB_DEVICE(USB_VID_COMPRO, 0x0620, &rtl2832u_props, "Compro VideoMate U620F", NULL) }, { DVB_USB_DEVICE(USB_VID_KWORLD_2, 0xd394, &rtl2832u_props, "MaxMedia HU394-T", NULL) }, { DVB_USB_DEVICE(USB_VID_LEADTEK, 0x6a03, - &rtl2832u_props, "WinFast DTV Dongle mini", NULL) }, + &rtl2832u_props, "Leadtek WinFast DTV Dongle mini", NULL) }, { } }; MODULE_DEVICE_TABLE(usb, rtl28xxu_id_table); From bc6fc53de8935031078c50b8a06324aeaf1b4034 Mon Sep 17 00:00:00 2001 From: Antti Palosaari Date: Tue, 4 Jun 2013 17:24:06 -0300 Subject: [PATCH 0107/1048] [media] rtl28xxu: map remote for TerraTec Cinergy T Stick Black Signed-off-by: Antti Palosaari Signed-off-by: Mauro Carvalho Chehab --- drivers/media/usb/dvb-usb-v2/rtl28xxu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c index 93313f70621c..04da6be4de27 100644 --- a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c +++ b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c @@ -1395,7 +1395,7 @@ static const struct usb_device_id rtl28xxu_id_table[] = { { DVB_USB_DEVICE(USB_VID_REALTEK, 0x2838, &rtl2832u_props, "Realtek RTL2832U reference design", NULL) }, { DVB_USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_T_STICK_BLACK_REV1, - &rtl2832u_props, "TerraTec Cinergy T Stick Black", NULL) }, + &rtl2832u_props, "TerraTec Cinergy T Stick Black", RC_MAP_TERRATEC_SLIM) }, { DVB_USB_DEVICE(USB_VID_GTEK, USB_PID_DELOCK_USB2_DVBT, &rtl2832u_props, "G-Tek Electronics Group Lifeview LV5TDLX DVB-T", NULL) }, { DVB_USB_DEVICE(USB_VID_TERRATEC, USB_PID_NOXON_DAB_STICK, From 526ca8dc6ad844550e037841bd5f7090db9e1d4f Mon Sep 17 00:00:00 2001 From: Antti Palosaari Date: Tue, 4 Jun 2013 18:26:54 -0300 Subject: [PATCH 0108/1048] [media] rtl28xxu: use masked reg write where possible Use masked register write inside rtl2832u_power_ctrl(). Signed-off-by: Antti Palosaari Signed-off-by: Mauro Carvalho Chehab --- drivers/media/usb/dvb-usb-v2/rtl28xxu.c | 72 ++++++------------------- 1 file changed, 16 insertions(+), 56 deletions(-) diff --git a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c index 04da6be4de27..6f5a3d0c818f 100644 --- a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c +++ b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c @@ -1041,67 +1041,34 @@ err: static int rtl2832u_power_ctrl(struct dvb_usb_device *d, int onoff) { int ret; - u8 val; dev_dbg(&d->udev->dev, "%s: onoff=%d\n", __func__, onoff); if (onoff) { - /* set output values */ - ret = rtl28xx_rd_reg(d, SYS_GPIO_OUT_VAL, &val); + /* GPIO3=1, GPIO4=0 */ + ret = rtl28xx_wr_reg_mask(d, SYS_GPIO_OUT_VAL, 0x08, 0x18); if (ret) goto err; - val |= 0x08; - val &= 0xef; - - ret = rtl28xx_wr_reg(d, SYS_GPIO_OUT_VAL, val); + /* suspend? */ + ret = rtl28xx_wr_reg_mask(d, SYS_DEMOD_CTL1, 0x00, 0x10); if (ret) goto err; - /* demod_ctl_1 */ - ret = rtl28xx_rd_reg(d, SYS_DEMOD_CTL1, &val); + /* enable PLL */ + ret = rtl28xx_wr_reg_mask(d, SYS_DEMOD_CTL, 0x80, 0x80); if (ret) goto err; - val &= 0xef; - - ret = rtl28xx_wr_reg(d, SYS_DEMOD_CTL1, val); - if (ret) - goto err; - - /* demod control */ - /* PLL enable */ - ret = rtl28xx_rd_reg(d, SYS_DEMOD_CTL, &val); - if (ret) - goto err; - - /* bit 7 to 1 */ - val |= 0x80; - - ret = rtl28xx_wr_reg(d, SYS_DEMOD_CTL, val); - if (ret) - goto err; - - ret = rtl28xx_rd_reg(d, SYS_DEMOD_CTL, &val); - if (ret) - goto err; - - val |= 0x20; - - ret = rtl28xx_wr_reg(d, SYS_DEMOD_CTL, val); + /* disable reset */ + ret = rtl28xx_wr_reg_mask(d, SYS_DEMOD_CTL, 0x20, 0x20); if (ret) goto err; mdelay(5); - /*enable ADC_Q and ADC_I */ - ret = rtl28xx_rd_reg(d, SYS_DEMOD_CTL, &val); - if (ret) - goto err; - - val |= 0x48; - - ret = rtl28xx_wr_reg(d, SYS_DEMOD_CTL, val); + /* enable ADC */ + ret = rtl28xx_wr_reg_mask(d, SYS_DEMOD_CTL, 0x48, 0x48); if (ret) goto err; @@ -1114,25 +1081,18 @@ static int rtl2832u_power_ctrl(struct dvb_usb_device *d, int onoff) if (ret) goto err; } else { - /* set output values */ - ret = rtl28xx_rd_reg(d, SYS_GPIO_OUT_VAL, &val); - if (ret) - goto err; - - val |= 0x10; - - ret = rtl28xx_wr_reg(d, SYS_GPIO_OUT_VAL, val); + /* GPIO4=1 */ + ret = rtl28xx_wr_reg_mask(d, SYS_GPIO_OUT_VAL, 0x10, 0x10); if (ret) goto err; - /* demod control */ - ret = rtl28xx_rd_reg(d, SYS_DEMOD_CTL, &val); + /* disable ADC */ + ret = rtl28xx_wr_reg_mask(d, SYS_DEMOD_CTL, 0x00, 0x48); if (ret) goto err; - val &= 0x37; - - ret = rtl28xx_wr_reg(d, SYS_DEMOD_CTL, val); + /* disable PLL */ + ret = rtl28xx_wr_reg_mask(d, SYS_DEMOD_CTL, 0x00, 0x80); if (ret) goto err; From c6be75264b15cdabf067f8b78e954d26f6bab2a4 Mon Sep 17 00:00:00 2001 From: Alessandro Miceli Date: Tue, 4 Jun 2013 16:10:34 -0300 Subject: [PATCH 0109/1048] [media] Add support for Crypto Redi PC50A device (rtl2832u + FC0012 tuner) The device has been tested on a MIPSel box with kernel 3.1.1 and backported media_tree drivers The kernel detects the device with the following output: usbcore: registered new interface driver dvb_usb_rtl28xxu usb 1-2: dvb_usb_v2: found a 'Crypto Redi PC50A' in warm state usb 1-2: dvb_usb_v2: will pass the complete MPEG2 transport stream to the software demuxer DVB: registering new adapter (Crypto Redi PC50A) usb 1-2: DVB: registering adapter 1 frontend 0 (Realtek RTL2832 (DVB-T))... i2c i2c-4: fc0012: Fitipower FC0012 successfully identified usb 1-2: dvb_usb_v2: 'Crypto Redi PC50A' successfully initialized and connected [crope@iki.fi: fix trivial merge conflict] Signed-off-by: Alessandro Miceli Signed-off-by: Antti Palosaari Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb-core/dvb-usb-ids.h | 1 + drivers/media/usb/dvb-usb-v2/rtl28xxu.c | 2 ++ 2 files changed, 3 insertions(+) diff --git a/drivers/media/dvb-core/dvb-usb-ids.h b/drivers/media/dvb-core/dvb-usb-ids.h index 2e0709a66f8f..886da16e14f2 100644 --- a/drivers/media/dvb-core/dvb-usb-ids.h +++ b/drivers/media/dvb-core/dvb-usb-ids.h @@ -367,5 +367,6 @@ #define USB_PID_TECHNISAT_USB2_HDCI_V2 0x0002 #define USB_PID_TECHNISAT_AIRSTAR_TELESTICK_2 0x0004 #define USB_PID_TECHNISAT_USB2_DVB_S2 0x0500 +#define USB_PID_CPYTO_REDI_PC50A 0xa803 #define USB_PID_CTVDIGDUAL_V2 0xe410 #endif diff --git a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c index 6f5a3d0c818f..a49abe4fa75b 100644 --- a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c +++ b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c @@ -1386,6 +1386,8 @@ static const struct usb_device_id rtl28xxu_id_table[] = { &rtl2832u_props, "MaxMedia HU394-T", NULL) }, { DVB_USB_DEVICE(USB_VID_LEADTEK, 0x6a03, &rtl2832u_props, "Leadtek WinFast DTV Dongle mini", NULL) }, + { DVB_USB_DEVICE(USB_VID_GTEK, USB_PID_CPYTO_REDI_PC50A, + &rtl2832u_props, "Crypto Redi PC50A", NULL) }, { } }; MODULE_DEVICE_TABLE(usb, rtl28xxu_id_table); From 7df272563aa3ffc201ddfe2431de9bb7456e3ea6 Mon Sep 17 00:00:00 2001 From: Antti Palosaari Date: Tue, 4 Jun 2013 19:43:30 -0300 Subject: [PATCH 0110/1048] [media] rtl28xxu: correct latest device name Signed-off-by: Antti Palosaari Signed-off-by: Mauro Carvalho Chehab --- drivers/media/usb/dvb-usb-v2/rtl28xxu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c index a49abe4fa75b..9a3c044fda3b 100644 --- a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c +++ b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c @@ -1387,7 +1387,7 @@ static const struct usb_device_id rtl28xxu_id_table[] = { { DVB_USB_DEVICE(USB_VID_LEADTEK, 0x6a03, &rtl2832u_props, "Leadtek WinFast DTV Dongle mini", NULL) }, { DVB_USB_DEVICE(USB_VID_GTEK, USB_PID_CPYTO_REDI_PC50A, - &rtl2832u_props, "Crypto Redi PC50A", NULL) }, + &rtl2832u_props, "Crypto ReDi PC 50 A", NULL) }, { } }; MODULE_DEVICE_TABLE(usb, rtl28xxu_id_table); From b5e9eb6f529b5741322d1981bb176785f115d446 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Sun, 28 Apr 2013 11:47:43 -0300 Subject: [PATCH 0111/1048] [media] drxk_hard: don't re-implement log10 X-Patchwork-Delegate: mchehab@redhat.com Log10 routine is already defined at dvb_math.h and provides a good enough approximation for 100 x log10(). So, instead of reinventing the wheel, use the already existing function. While here, don't use CamelCase on the function name. Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb-frontends/drxk_hard.c | 104 ++---------------------- 1 file changed, 8 insertions(+), 96 deletions(-) diff --git a/drivers/media/dvb-frontends/drxk_hard.c b/drivers/media/dvb-frontends/drxk_hard.c index ec24d71e153d..41b637534ed4 100644 --- a/drivers/media/dvb-frontends/drxk_hard.c +++ b/drivers/media/dvb-frontends/drxk_hard.c @@ -34,6 +34,7 @@ #include "dvb_frontend.h" #include "drxk.h" #include "drxk_hard.h" +#include "dvb_math.h" static int PowerDownDVBT(struct drxk_state *state, bool setPowerMode); static int PowerDownQAM(struct drxk_state *state); @@ -201,98 +202,9 @@ static inline u32 Frac28a(u32 a, u32 c) return Q1; } -static u32 Log10Times100(u32 x) +static inline u32 log10times100(u32 value) { - static const u8 scale = 15; - static const u8 indexWidth = 5; - u8 i = 0; - u32 y = 0; - u32 d = 0; - u32 k = 0; - u32 r = 0; - /* - log2lut[n] = (1< 0; k--) { - if (x & (((u32) 1) << scale)) - break; - x <<= 1; - } - } else { - for (k = scale; k < 31; k++) { - if ((x & (((u32) (-1)) << (scale + 1))) == 0) - break; - x >>= 1; - } - } - /* - Now x has binary point between bit[scale] and bit[scale-1] - and 1.0 <= x < 2.0 */ - - /* correction for divison: log(x) = log(x/y)+log(y) */ - y = k * ((((u32) 1) << scale) * 200); - - /* remove integer part */ - x &= ((((u32) 1) << scale) - 1); - /* get index */ - i = (u8) (x >> (scale - indexWidth)); - /* compute delta (x - a) */ - d = x & ((((u32) 1) << (scale - indexWidth)) - 1); - /* compute log, multiplication (d* (..)) must be within range ! */ - y += log2lut[i] + - ((d * (log2lut[i + 1] - log2lut[i])) >> (scale - indexWidth)); - /* Conver to log10() */ - y /= 108853; /* (log2(10) << scale) */ - r = (y >> 1); - /* rounding */ - if (y & ((u32) 1)) - r++; - return r; + return (100L * intlog10(value)) >> 24; } /****************************************************************************/ @@ -2530,8 +2442,8 @@ static int GetQAMSignalToNoise(struct drxk_state *state, } if (qamSlErrPower > 0) { - qamSlMer = Log10Times100(qamSlSigPower) - - Log10Times100((u32) qamSlErrPower); + qamSlMer = log10times100(qamSlSigPower) - + log10times100((u32) qamSlErrPower); } *pSignalToNoise = qamSlMer; @@ -2620,12 +2532,12 @@ static int GetDVBTSignalToNoise(struct drxk_state *state, */ /* log(x) x = 9bits * 9bits->18 bits */ - a = Log10Times100(EqRegTdTpsPwrOfs * + a = log10times100(EqRegTdTpsPwrOfs * EqRegTdTpsPwrOfs); /* log(x) x = 16bits * 7bits->23 bits */ - b = Log10Times100(EqRegTdReqSmbCnt * tpsCnt); + b = log10times100(EqRegTdReqSmbCnt * tpsCnt); /* log(x) x = (16bits + 16bits) << 15 ->32 bits */ - c = Log10Times100(SqrErrIQ); + c = log10times100(SqrErrIQ); iMER = a + b - c; } From cd7a67a4f18047ca7b8ce2f48b4c540d69c9b793 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Sun, 28 Apr 2013 11:47:44 -0300 Subject: [PATCH 0112/1048] [media] drxk_hard: Don't use CamelCase X-Patchwork-Delegate: mchehab@redhat.com Thare are lots of CamelCase warnings produced by checkpatch.pl. This weren't fixed at the time the driver got submitted due to the lack of manpower do to such cleanup. Now that I have one script that automates this task, cleans it. That makes the driver almost checkpatch-compliant, except for 80 column warnings. Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb-frontends/drxk.h | 2 +- drivers/media/dvb-frontends/drxk_hard.c | 2538 +++++++++++------------ drivers/media/dvb-frontends/drxk_hard.h | 224 +- 3 files changed, 1382 insertions(+), 1382 deletions(-) diff --git a/drivers/media/dvb-frontends/drxk.h b/drivers/media/dvb-frontends/drxk.h index e6667189ddce..f22eb9f13ad5 100644 --- a/drivers/media/dvb-frontends/drxk.h +++ b/drivers/media/dvb-frontends/drxk.h @@ -8,7 +8,7 @@ /** * struct drxk_config - Configure the initial parameters for DRX-K * - * @adr: I2C Address of the DRX-K + * @adr: I2C address of the DRX-K * @parallel_ts: True means that the device uses parallel TS, * Serial otherwise. * @dynamic_clk: True means that the clock will be dynamically diff --git a/drivers/media/dvb-frontends/drxk_hard.c b/drivers/media/dvb-frontends/drxk_hard.c index 41b637534ed4..d2b331a46a6d 100644 --- a/drivers/media/dvb-frontends/drxk_hard.c +++ b/drivers/media/dvb-frontends/drxk_hard.c @@ -36,34 +36,34 @@ #include "drxk_hard.h" #include "dvb_math.h" -static int PowerDownDVBT(struct drxk_state *state, bool setPowerMode); -static int PowerDownQAM(struct drxk_state *state); -static int SetDVBTStandard(struct drxk_state *state, - enum OperationMode oMode); -static int SetQAMStandard(struct drxk_state *state, - enum OperationMode oMode); -static int SetQAM(struct drxk_state *state, u16 IntermediateFreqkHz, - s32 tunerFreqOffset); -static int SetDVBTStandard(struct drxk_state *state, - enum OperationMode oMode); -static int DVBTStart(struct drxk_state *state); -static int SetDVBT(struct drxk_state *state, u16 IntermediateFreqkHz, - s32 tunerFreqOffset); -static int GetQAMLockStatus(struct drxk_state *state, u32 *pLockStatus); -static int GetDVBTLockStatus(struct drxk_state *state, u32 *pLockStatus); -static int SwitchAntennaToQAM(struct drxk_state *state); -static int SwitchAntennaToDVBT(struct drxk_state *state); +static int power_down_dvbt(struct drxk_state *state, bool set_power_mode); +static int power_down_qam(struct drxk_state *state); +static int set_dvbt_standard(struct drxk_state *state, + enum operation_mode o_mode); +static int set_qam_standard(struct drxk_state *state, + enum operation_mode o_mode); +static int set_qam(struct drxk_state *state, u16 intermediate_freqk_hz, + s32 tuner_freq_offset); +static int set_dvbt_standard(struct drxk_state *state, + enum operation_mode o_mode); +static int dvbt_start(struct drxk_state *state); +static int set_dvbt(struct drxk_state *state, u16 intermediate_freqk_hz, + s32 tuner_freq_offset); +static int get_qam_lock_status(struct drxk_state *state, u32 *p_lock_status); +static int get_dvbt_lock_status(struct drxk_state *state, u32 *p_lock_status); +static int switch_antenna_to_qam(struct drxk_state *state); +static int switch_antenna_to_dvbt(struct drxk_state *state); -static bool IsDVBT(struct drxk_state *state) +static bool is_dvbt(struct drxk_state *state) { - return state->m_OperationMode == OM_DVBT; + return state->m_operation_mode == OM_DVBT; } -static bool IsQAM(struct drxk_state *state) +static bool is_qam(struct drxk_state *state) { - return state->m_OperationMode == OM_QAM_ITU_A || - state->m_OperationMode == OM_QAM_ITU_B || - state->m_OperationMode == OM_QAM_ITU_C; + return state->m_operation_mode == OM_QAM_ITU_A || + state->m_operation_mode == OM_QAM_ITU_B || + state->m_operation_mode == OM_QAM_ITU_C; } #define NOA1ROM 0 @@ -432,55 +432,55 @@ static int write32(struct drxk_state *state, u32 reg, u32 data) return write32_flags(state, reg, data, 0); } -static int write_block(struct drxk_state *state, u32 Address, - const int BlockSize, const u8 pBlock[]) +static int write_block(struct drxk_state *state, u32 address, + const int block_size, const u8 p_block[]) { - int status = 0, BlkSize = BlockSize; - u8 Flags = 0; + int status = 0, blk_size = block_size; + u8 flags = 0; if (state->single_master) - Flags |= 0xC0; + flags |= 0xC0; - while (BlkSize > 0) { - int Chunk = BlkSize > state->m_ChunkSize ? - state->m_ChunkSize : BlkSize; - u8 *AdrBuf = &state->Chunk[0]; - u32 AdrLength = 0; + while (blk_size > 0) { + int chunk = blk_size > state->m_chunk_size ? + state->m_chunk_size : blk_size; + u8 *adr_buf = &state->chunk[0]; + u32 adr_length = 0; - if (DRXDAP_FASI_LONG_FORMAT(Address) || (Flags != 0)) { - AdrBuf[0] = (((Address << 1) & 0xFF) | 0x01); - AdrBuf[1] = ((Address >> 16) & 0xFF); - AdrBuf[2] = ((Address >> 24) & 0xFF); - AdrBuf[3] = ((Address >> 7) & 0xFF); - AdrBuf[2] |= Flags; - AdrLength = 4; - if (Chunk == state->m_ChunkSize) - Chunk -= 2; + if (DRXDAP_FASI_LONG_FORMAT(address) || (flags != 0)) { + adr_buf[0] = (((address << 1) & 0xFF) | 0x01); + adr_buf[1] = ((address >> 16) & 0xFF); + adr_buf[2] = ((address >> 24) & 0xFF); + adr_buf[3] = ((address >> 7) & 0xFF); + adr_buf[2] |= flags; + adr_length = 4; + if (chunk == state->m_chunk_size) + chunk -= 2; } else { - AdrBuf[0] = ((Address << 1) & 0xFF); - AdrBuf[1] = (((Address >> 16) & 0x0F) | - ((Address >> 18) & 0xF0)); - AdrLength = 2; + adr_buf[0] = ((address << 1) & 0xFF); + adr_buf[1] = (((address >> 16) & 0x0F) | + ((address >> 18) & 0xF0)); + adr_length = 2; } - memcpy(&state->Chunk[AdrLength], pBlock, Chunk); - dprintk(2, "(0x%08x, 0x%02x)\n", Address, Flags); + memcpy(&state->chunk[adr_length], p_block, chunk); + dprintk(2, "(0x%08x, 0x%02x)\n", address, flags); if (debug > 1) { int i; - if (pBlock) - for (i = 0; i < Chunk; i++) - printk(KERN_CONT " %02x", pBlock[i]); + if (p_block) + for (i = 0; i < chunk; i++) + printk(KERN_CONT " %02x", p_block[i]); printk(KERN_CONT "\n"); } status = i2c_write(state, state->demod_address, - &state->Chunk[0], Chunk + AdrLength); + &state->chunk[0], chunk + adr_length); if (status < 0) { printk(KERN_ERR "drxk: %s: i2c write error at addr 0x%02x\n", - __func__, Address); + __func__, address); break; } - pBlock += Chunk; - Address += (Chunk >> 1); - BlkSize -= Chunk; + p_block += chunk; + address += (chunk >> 1); + blk_size -= chunk; } return status; } @@ -489,11 +489,11 @@ static int write_block(struct drxk_state *state, u32 Address, #define DRXK_MAX_RETRIES_POWERUP 20 #endif -static int PowerUpDevice(struct drxk_state *state) +static int power_up_device(struct drxk_state *state) { int status; u8 data = 0; - u16 retryCount = 0; + u16 retry_count = 0; dprintk(1, "\n"); @@ -504,14 +504,14 @@ static int PowerUpDevice(struct drxk_state *state) status = i2c_write(state, state->demod_address, &data, 1); msleep(10); - retryCount++; + retry_count++; if (status < 0) continue; status = i2c_read1(state, state->demod_address, &data); } while (status < 0 && - (retryCount < DRXK_MAX_RETRIES_POWERUP)); - if (status < 0 && retryCount >= DRXK_MAX_RETRIES_POWERUP) + (retry_count < DRXK_MAX_RETRIES_POWERUP)); + if (status < 0 && retry_count >= DRXK_MAX_RETRIES_POWERUP) goto error; } @@ -527,7 +527,7 @@ static int PowerUpDevice(struct drxk_state *state) if (status < 0) goto error; - state->m_currentPowerMode = DRX_POWER_UP; + state->m_current_power_mode = DRX_POWER_UP; error: if (status < 0) @@ -543,106 +543,106 @@ static int init_state(struct drxk_state *state) * FIXME: most (all?) of the values bellow should be moved into * struct drxk_config, as they are probably board-specific */ - u32 ulVSBIfAgcMode = DRXK_AGC_CTRL_AUTO; - u32 ulVSBIfAgcOutputLevel = 0; - u32 ulVSBIfAgcMinLevel = 0; - u32 ulVSBIfAgcMaxLevel = 0x7FFF; - u32 ulVSBIfAgcSpeed = 3; + u32 ul_vsb_if_agc_mode = DRXK_AGC_CTRL_AUTO; + u32 ul_vsb_if_agc_output_level = 0; + u32 ul_vsb_if_agc_min_level = 0; + u32 ul_vsb_if_agc_max_level = 0x7FFF; + u32 ul_vsb_if_agc_speed = 3; - u32 ulVSBRfAgcMode = DRXK_AGC_CTRL_AUTO; - u32 ulVSBRfAgcOutputLevel = 0; - u32 ulVSBRfAgcMinLevel = 0; - u32 ulVSBRfAgcMaxLevel = 0x7FFF; - u32 ulVSBRfAgcSpeed = 3; - u32 ulVSBRfAgcTop = 9500; - u32 ulVSBRfAgcCutOffCurrent = 4000; + u32 ul_vsb_rf_agc_mode = DRXK_AGC_CTRL_AUTO; + u32 ul_vsb_rf_agc_output_level = 0; + u32 ul_vsb_rf_agc_min_level = 0; + u32 ul_vsb_rf_agc_max_level = 0x7FFF; + u32 ul_vsb_rf_agc_speed = 3; + u32 ul_vsb_rf_agc_top = 9500; + u32 ul_vsb_rf_agc_cut_off_current = 4000; - u32 ulATVIfAgcMode = DRXK_AGC_CTRL_AUTO; - u32 ulATVIfAgcOutputLevel = 0; - u32 ulATVIfAgcMinLevel = 0; - u32 ulATVIfAgcMaxLevel = 0; - u32 ulATVIfAgcSpeed = 3; + u32 ul_atv_if_agc_mode = DRXK_AGC_CTRL_AUTO; + u32 ul_atv_if_agc_output_level = 0; + u32 ul_atv_if_agc_min_level = 0; + u32 ul_atv_if_agc_max_level = 0; + u32 ul_atv_if_agc_speed = 3; - u32 ulATVRfAgcMode = DRXK_AGC_CTRL_OFF; - u32 ulATVRfAgcOutputLevel = 0; - u32 ulATVRfAgcMinLevel = 0; - u32 ulATVRfAgcMaxLevel = 0; - u32 ulATVRfAgcTop = 9500; - u32 ulATVRfAgcCutOffCurrent = 4000; - u32 ulATVRfAgcSpeed = 3; + u32 ul_atv_rf_agc_mode = DRXK_AGC_CTRL_OFF; + u32 ul_atv_rf_agc_output_level = 0; + u32 ul_atv_rf_agc_min_level = 0; + u32 ul_atv_rf_agc_max_level = 0; + u32 ul_atv_rf_agc_top = 9500; + u32 ul_atv_rf_agc_cut_off_current = 4000; + u32 ul_atv_rf_agc_speed = 3; u32 ulQual83 = DEFAULT_MER_83; u32 ulQual93 = DEFAULT_MER_93; - u32 ulMpegLockTimeOut = DEFAULT_DRXK_MPEG_LOCK_TIMEOUT; - u32 ulDemodLockTimeOut = DEFAULT_DRXK_DEMOD_LOCK_TIMEOUT; + u32 ul_mpeg_lock_time_out = DEFAULT_DRXK_MPEG_LOCK_TIMEOUT; + u32 ul_demod_lock_time_out = DEFAULT_DRXK_DEMOD_LOCK_TIMEOUT; /* io_pad_cfg register (8 bit reg.) MSB bit is 1 (default value) */ /* io_pad_cfg_mode output mode is drive always */ /* io_pad_cfg_drive is set to power 2 (23 mA) */ - u32 ulGPIOCfg = 0x0113; - u32 ulInvertTSClock = 0; - u32 ulTSDataStrength = DRXK_MPEG_SERIAL_OUTPUT_PIN_DRIVE_STRENGTH; - u32 ulDVBTBitrate = 50000000; - u32 ulDVBCBitrate = DRXK_QAM_SYMBOLRATE_MAX * 8; + u32 ul_gpio_cfg = 0x0113; + u32 ul_invert_ts_clock = 0; + u32 ul_ts_data_strength = DRXK_MPEG_SERIAL_OUTPUT_PIN_DRIVE_STRENGTH; + u32 ul_dvbt_bitrate = 50000000; + u32 ul_dvbc_bitrate = DRXK_QAM_SYMBOLRATE_MAX * 8; - u32 ulInsertRSByte = 0; + u32 ul_insert_rs_byte = 0; - u32 ulRfMirror = 1; - u32 ulPowerDown = 0; + u32 ul_rf_mirror = 1; + u32 ul_power_down = 0; dprintk(1, "\n"); - state->m_hasLNA = false; - state->m_hasDVBT = false; - state->m_hasDVBC = false; - state->m_hasATV = false; - state->m_hasOOB = false; - state->m_hasAudio = false; + state->m_has_lna = false; + state->m_has_dvbt = false; + state->m_has_dvbc = false; + state->m_has_atv = false; + state->m_has_oob = false; + state->m_has_audio = false; - if (!state->m_ChunkSize) - state->m_ChunkSize = 124; + if (!state->m_chunk_size) + state->m_chunk_size = 124; - state->m_oscClockFreq = 0; - state->m_smartAntInverted = false; - state->m_bPDownOpenBridge = false; + state->m_osc_clock_freq = 0; + state->m_smart_ant_inverted = false; + state->m_b_p_down_open_bridge = false; /* real system clock frequency in kHz */ - state->m_sysClockFreq = 151875; + state->m_sys_clock_freq = 151875; /* Timing div, 250ns/Psys */ /* Timing div, = (delay (nano seconds) * sysclk (kHz))/ 1000 */ - state->m_HICfgTimingDiv = ((state->m_sysClockFreq / 1000) * + state->m_hi_cfg_timing_div = ((state->m_sys_clock_freq / 1000) * HI_I2C_DELAY) / 1000; /* Clipping */ - if (state->m_HICfgTimingDiv > SIO_HI_RA_RAM_PAR_2_CFG_DIV__M) - state->m_HICfgTimingDiv = SIO_HI_RA_RAM_PAR_2_CFG_DIV__M; - state->m_HICfgWakeUpKey = (state->demod_address << 1); + if (state->m_hi_cfg_timing_div > SIO_HI_RA_RAM_PAR_2_CFG_DIV__M) + state->m_hi_cfg_timing_div = SIO_HI_RA_RAM_PAR_2_CFG_DIV__M; + state->m_hi_cfg_wake_up_key = (state->demod_address << 1); /* port/bridge/power down ctrl */ - state->m_HICfgCtrl = SIO_HI_RA_RAM_PAR_5_CFG_SLV0_SLAVE; + state->m_hi_cfg_ctrl = SIO_HI_RA_RAM_PAR_5_CFG_SLV0_SLAVE; - state->m_bPowerDown = (ulPowerDown != 0); + state->m_b_power_down = (ul_power_down != 0); - state->m_DRXK_A3_PATCH_CODE = false; + state->m_drxk_a3_patch_code = false; /* Init AGC and PGA parameters */ /* VSB IF */ - state->m_vsbIfAgcCfg.ctrlMode = (ulVSBIfAgcMode); - state->m_vsbIfAgcCfg.outputLevel = (ulVSBIfAgcOutputLevel); - state->m_vsbIfAgcCfg.minOutputLevel = (ulVSBIfAgcMinLevel); - state->m_vsbIfAgcCfg.maxOutputLevel = (ulVSBIfAgcMaxLevel); - state->m_vsbIfAgcCfg.speed = (ulVSBIfAgcSpeed); - state->m_vsbPgaCfg = 140; + state->m_vsb_if_agc_cfg.ctrl_mode = (ul_vsb_if_agc_mode); + state->m_vsb_if_agc_cfg.output_level = (ul_vsb_if_agc_output_level); + state->m_vsb_if_agc_cfg.min_output_level = (ul_vsb_if_agc_min_level); + state->m_vsb_if_agc_cfg.max_output_level = (ul_vsb_if_agc_max_level); + state->m_vsb_if_agc_cfg.speed = (ul_vsb_if_agc_speed); + state->m_vsb_pga_cfg = 140; /* VSB RF */ - state->m_vsbRfAgcCfg.ctrlMode = (ulVSBRfAgcMode); - state->m_vsbRfAgcCfg.outputLevel = (ulVSBRfAgcOutputLevel); - state->m_vsbRfAgcCfg.minOutputLevel = (ulVSBRfAgcMinLevel); - state->m_vsbRfAgcCfg.maxOutputLevel = (ulVSBRfAgcMaxLevel); - state->m_vsbRfAgcCfg.speed = (ulVSBRfAgcSpeed); - state->m_vsbRfAgcCfg.top = (ulVSBRfAgcTop); - state->m_vsbRfAgcCfg.cutOffCurrent = (ulVSBRfAgcCutOffCurrent); - state->m_vsbPreSawCfg.reference = 0x07; - state->m_vsbPreSawCfg.usePreSaw = true; + state->m_vsb_rf_agc_cfg.ctrl_mode = (ul_vsb_rf_agc_mode); + state->m_vsb_rf_agc_cfg.output_level = (ul_vsb_rf_agc_output_level); + state->m_vsb_rf_agc_cfg.min_output_level = (ul_vsb_rf_agc_min_level); + state->m_vsb_rf_agc_cfg.max_output_level = (ul_vsb_rf_agc_max_level); + state->m_vsb_rf_agc_cfg.speed = (ul_vsb_rf_agc_speed); + state->m_vsb_rf_agc_cfg.top = (ul_vsb_rf_agc_top); + state->m_vsb_rf_agc_cfg.cut_off_current = (ul_vsb_rf_agc_cut_off_current); + state->m_vsb_pre_saw_cfg.reference = 0x07; + state->m_vsb_pre_saw_cfg.use_pre_saw = true; state->m_Quality83percent = DEFAULT_MER_83; state->m_Quality93percent = DEFAULT_MER_93; @@ -652,127 +652,127 @@ static int init_state(struct drxk_state *state) } /* ATV IF */ - state->m_atvIfAgcCfg.ctrlMode = (ulATVIfAgcMode); - state->m_atvIfAgcCfg.outputLevel = (ulATVIfAgcOutputLevel); - state->m_atvIfAgcCfg.minOutputLevel = (ulATVIfAgcMinLevel); - state->m_atvIfAgcCfg.maxOutputLevel = (ulATVIfAgcMaxLevel); - state->m_atvIfAgcCfg.speed = (ulATVIfAgcSpeed); + state->m_atv_if_agc_cfg.ctrl_mode = (ul_atv_if_agc_mode); + state->m_atv_if_agc_cfg.output_level = (ul_atv_if_agc_output_level); + state->m_atv_if_agc_cfg.min_output_level = (ul_atv_if_agc_min_level); + state->m_atv_if_agc_cfg.max_output_level = (ul_atv_if_agc_max_level); + state->m_atv_if_agc_cfg.speed = (ul_atv_if_agc_speed); /* ATV RF */ - state->m_atvRfAgcCfg.ctrlMode = (ulATVRfAgcMode); - state->m_atvRfAgcCfg.outputLevel = (ulATVRfAgcOutputLevel); - state->m_atvRfAgcCfg.minOutputLevel = (ulATVRfAgcMinLevel); - state->m_atvRfAgcCfg.maxOutputLevel = (ulATVRfAgcMaxLevel); - state->m_atvRfAgcCfg.speed = (ulATVRfAgcSpeed); - state->m_atvRfAgcCfg.top = (ulATVRfAgcTop); - state->m_atvRfAgcCfg.cutOffCurrent = (ulATVRfAgcCutOffCurrent); - state->m_atvPreSawCfg.reference = 0x04; - state->m_atvPreSawCfg.usePreSaw = true; + state->m_atv_rf_agc_cfg.ctrl_mode = (ul_atv_rf_agc_mode); + state->m_atv_rf_agc_cfg.output_level = (ul_atv_rf_agc_output_level); + state->m_atv_rf_agc_cfg.min_output_level = (ul_atv_rf_agc_min_level); + state->m_atv_rf_agc_cfg.max_output_level = (ul_atv_rf_agc_max_level); + state->m_atv_rf_agc_cfg.speed = (ul_atv_rf_agc_speed); + state->m_atv_rf_agc_cfg.top = (ul_atv_rf_agc_top); + state->m_atv_rf_agc_cfg.cut_off_current = (ul_atv_rf_agc_cut_off_current); + state->m_atv_pre_saw_cfg.reference = 0x04; + state->m_atv_pre_saw_cfg.use_pre_saw = true; /* DVBT RF */ - state->m_dvbtRfAgcCfg.ctrlMode = DRXK_AGC_CTRL_OFF; - state->m_dvbtRfAgcCfg.outputLevel = 0; - state->m_dvbtRfAgcCfg.minOutputLevel = 0; - state->m_dvbtRfAgcCfg.maxOutputLevel = 0xFFFF; - state->m_dvbtRfAgcCfg.top = 0x2100; - state->m_dvbtRfAgcCfg.cutOffCurrent = 4000; - state->m_dvbtRfAgcCfg.speed = 1; + state->m_dvbt_rf_agc_cfg.ctrl_mode = DRXK_AGC_CTRL_OFF; + state->m_dvbt_rf_agc_cfg.output_level = 0; + state->m_dvbt_rf_agc_cfg.min_output_level = 0; + state->m_dvbt_rf_agc_cfg.max_output_level = 0xFFFF; + state->m_dvbt_rf_agc_cfg.top = 0x2100; + state->m_dvbt_rf_agc_cfg.cut_off_current = 4000; + state->m_dvbt_rf_agc_cfg.speed = 1; /* DVBT IF */ - state->m_dvbtIfAgcCfg.ctrlMode = DRXK_AGC_CTRL_AUTO; - state->m_dvbtIfAgcCfg.outputLevel = 0; - state->m_dvbtIfAgcCfg.minOutputLevel = 0; - state->m_dvbtIfAgcCfg.maxOutputLevel = 9000; - state->m_dvbtIfAgcCfg.top = 13424; - state->m_dvbtIfAgcCfg.cutOffCurrent = 0; - state->m_dvbtIfAgcCfg.speed = 3; - state->m_dvbtIfAgcCfg.FastClipCtrlDelay = 30; - state->m_dvbtIfAgcCfg.IngainTgtMax = 30000; + state->m_dvbt_if_agc_cfg.ctrl_mode = DRXK_AGC_CTRL_AUTO; + state->m_dvbt_if_agc_cfg.output_level = 0; + state->m_dvbt_if_agc_cfg.min_output_level = 0; + state->m_dvbt_if_agc_cfg.max_output_level = 9000; + state->m_dvbt_if_agc_cfg.top = 13424; + state->m_dvbt_if_agc_cfg.cut_off_current = 0; + state->m_dvbt_if_agc_cfg.speed = 3; + state->m_dvbt_if_agc_cfg.fast_clip_ctrl_delay = 30; + state->m_dvbt_if_agc_cfg.ingain_tgt_max = 30000; /* state->m_dvbtPgaCfg = 140; */ - state->m_dvbtPreSawCfg.reference = 4; - state->m_dvbtPreSawCfg.usePreSaw = false; + state->m_dvbt_pre_saw_cfg.reference = 4; + state->m_dvbt_pre_saw_cfg.use_pre_saw = false; /* QAM RF */ - state->m_qamRfAgcCfg.ctrlMode = DRXK_AGC_CTRL_OFF; - state->m_qamRfAgcCfg.outputLevel = 0; - state->m_qamRfAgcCfg.minOutputLevel = 6023; - state->m_qamRfAgcCfg.maxOutputLevel = 27000; - state->m_qamRfAgcCfg.top = 0x2380; - state->m_qamRfAgcCfg.cutOffCurrent = 4000; - state->m_qamRfAgcCfg.speed = 3; + state->m_qam_rf_agc_cfg.ctrl_mode = DRXK_AGC_CTRL_OFF; + state->m_qam_rf_agc_cfg.output_level = 0; + state->m_qam_rf_agc_cfg.min_output_level = 6023; + state->m_qam_rf_agc_cfg.max_output_level = 27000; + state->m_qam_rf_agc_cfg.top = 0x2380; + state->m_qam_rf_agc_cfg.cut_off_current = 4000; + state->m_qam_rf_agc_cfg.speed = 3; /* QAM IF */ - state->m_qamIfAgcCfg.ctrlMode = DRXK_AGC_CTRL_AUTO; - state->m_qamIfAgcCfg.outputLevel = 0; - state->m_qamIfAgcCfg.minOutputLevel = 0; - state->m_qamIfAgcCfg.maxOutputLevel = 9000; - state->m_qamIfAgcCfg.top = 0x0511; - state->m_qamIfAgcCfg.cutOffCurrent = 0; - state->m_qamIfAgcCfg.speed = 3; - state->m_qamIfAgcCfg.IngainTgtMax = 5119; - state->m_qamIfAgcCfg.FastClipCtrlDelay = 50; + state->m_qam_if_agc_cfg.ctrl_mode = DRXK_AGC_CTRL_AUTO; + state->m_qam_if_agc_cfg.output_level = 0; + state->m_qam_if_agc_cfg.min_output_level = 0; + state->m_qam_if_agc_cfg.max_output_level = 9000; + state->m_qam_if_agc_cfg.top = 0x0511; + state->m_qam_if_agc_cfg.cut_off_current = 0; + state->m_qam_if_agc_cfg.speed = 3; + state->m_qam_if_agc_cfg.ingain_tgt_max = 5119; + state->m_qam_if_agc_cfg.fast_clip_ctrl_delay = 50; - state->m_qamPgaCfg = 140; - state->m_qamPreSawCfg.reference = 4; - state->m_qamPreSawCfg.usePreSaw = false; + state->m_qam_pga_cfg = 140; + state->m_qam_pre_saw_cfg.reference = 4; + state->m_qam_pre_saw_cfg.use_pre_saw = false; - state->m_OperationMode = OM_NONE; - state->m_DrxkState = DRXK_UNINITIALIZED; + state->m_operation_mode = OM_NONE; + state->m_drxk_state = DRXK_UNINITIALIZED; /* MPEG output configuration */ - state->m_enableMPEGOutput = true; /* If TRUE; enable MPEG ouput */ - state->m_insertRSByte = false; /* If TRUE; insert RS byte */ - state->m_invertDATA = false; /* If TRUE; invert DATA signals */ - state->m_invertERR = false; /* If TRUE; invert ERR signal */ - state->m_invertSTR = false; /* If TRUE; invert STR signals */ - state->m_invertVAL = false; /* If TRUE; invert VAL signals */ - state->m_invertCLK = (ulInvertTSClock != 0); /* If TRUE; invert CLK signals */ + state->m_enable_mpeg_output = true; /* If TRUE; enable MPEG ouput */ + state->m_insert_rs_byte = false; /* If TRUE; insert RS byte */ + state->m_invert_data = false; /* If TRUE; invert DATA signals */ + state->m_invert_err = false; /* If TRUE; invert ERR signal */ + state->m_invert_str = false; /* If TRUE; invert STR signals */ + state->m_invert_val = false; /* If TRUE; invert VAL signals */ + state->m_invert_clk = (ul_invert_ts_clock != 0); /* If TRUE; invert CLK signals */ /* If TRUE; static MPEG clockrate will be used; otherwise clockrate will adapt to the bitrate of the TS */ - state->m_DVBTBitrate = ulDVBTBitrate; - state->m_DVBCBitrate = ulDVBCBitrate; + state->m_dvbt_bitrate = ul_dvbt_bitrate; + state->m_dvbc_bitrate = ul_dvbc_bitrate; - state->m_TSDataStrength = (ulTSDataStrength & 0x07); + state->m_ts_data_strength = (ul_ts_data_strength & 0x07); /* Maximum bitrate in b/s in case static clockrate is selected */ - state->m_mpegTsStaticBitrate = 19392658; - state->m_disableTEIhandling = false; + state->m_mpeg_ts_static_bitrate = 19392658; + state->m_disable_te_ihandling = false; - if (ulInsertRSByte) - state->m_insertRSByte = true; + if (ul_insert_rs_byte) + state->m_insert_rs_byte = true; - state->m_MpegLockTimeOut = DEFAULT_DRXK_MPEG_LOCK_TIMEOUT; - if (ulMpegLockTimeOut < 10000) - state->m_MpegLockTimeOut = ulMpegLockTimeOut; - state->m_DemodLockTimeOut = DEFAULT_DRXK_DEMOD_LOCK_TIMEOUT; - if (ulDemodLockTimeOut < 10000) - state->m_DemodLockTimeOut = ulDemodLockTimeOut; + state->m_mpeg_lock_time_out = DEFAULT_DRXK_MPEG_LOCK_TIMEOUT; + if (ul_mpeg_lock_time_out < 10000) + state->m_mpeg_lock_time_out = ul_mpeg_lock_time_out; + state->m_demod_lock_time_out = DEFAULT_DRXK_DEMOD_LOCK_TIMEOUT; + if (ul_demod_lock_time_out < 10000) + state->m_demod_lock_time_out = ul_demod_lock_time_out; /* QAM defaults */ - state->m_Constellation = DRX_CONSTELLATION_AUTO; - state->m_qamInterleaveMode = DRXK_QAM_I12_J17; - state->m_fecRsPlen = 204 * 8; /* fecRsPlen annex A */ - state->m_fecRsPrescale = 1; + state->m_constellation = DRX_CONSTELLATION_AUTO; + state->m_qam_interleave_mode = DRXK_QAM_I12_J17; + state->m_fec_rs_plen = 204 * 8; /* fecRsPlen annex A */ + state->m_fec_rs_prescale = 1; - state->m_sqiSpeed = DRXK_DVBT_SQI_SPEED_MEDIUM; - state->m_agcFastClipCtrlDelay = 0; + state->m_sqi_speed = DRXK_DVBT_SQI_SPEED_MEDIUM; + state->m_agcfast_clip_ctrl_delay = 0; - state->m_GPIOCfg = (ulGPIOCfg); + state->m_gpio_cfg = (ul_gpio_cfg); - state->m_bPowerDown = false; - state->m_currentPowerMode = DRX_POWER_DOWN; + state->m_b_power_down = false; + state->m_current_power_mode = DRX_POWER_DOWN; - state->m_rfmirror = (ulRfMirror == 0); - state->m_IfAgcPol = false; + state->m_rfmirror = (ul_rf_mirror == 0); + state->m_if_agc_pol = false; return 0; } -static int DRXX_Open(struct drxk_state *state) +static int drxx_open(struct drxk_state *state) { int status = 0; u32 jtag = 0; @@ -804,10 +804,10 @@ error: return status; } -static int GetDeviceCapabilities(struct drxk_state *state) +static int get_device_capabilities(struct drxk_state *state) { - u16 sioPdrOhwCfg = 0; - u32 sioTopJtagidLo = 0; + u16 sio_pdr_ohw_cfg = 0; + u32 sio_top_jtagid_lo = 0; int status; const char *spin = ""; @@ -821,28 +821,28 @@ static int GetDeviceCapabilities(struct drxk_state *state) status = write16(state, SIO_TOP_COMM_KEY__A, SIO_TOP_COMM_KEY_KEY); if (status < 0) goto error; - status = read16(state, SIO_PDR_OHW_CFG__A, &sioPdrOhwCfg); + status = read16(state, SIO_PDR_OHW_CFG__A, &sio_pdr_ohw_cfg); if (status < 0) goto error; status = write16(state, SIO_TOP_COMM_KEY__A, 0x0000); if (status < 0) goto error; - switch ((sioPdrOhwCfg & SIO_PDR_OHW_CFG_FREF_SEL__M)) { + switch ((sio_pdr_ohw_cfg & SIO_PDR_OHW_CFG_FREF_SEL__M)) { case 0: /* ignore (bypass ?) */ break; case 1: /* 27 MHz */ - state->m_oscClockFreq = 27000; + state->m_osc_clock_freq = 27000; break; case 2: /* 20.25 MHz */ - state->m_oscClockFreq = 20250; + state->m_osc_clock_freq = 20250; break; case 3: /* 4 MHz */ - state->m_oscClockFreq = 20250; + state->m_osc_clock_freq = 20250; break; default: printk(KERN_ERR "drxk: Clock Frequency is unknown\n"); @@ -852,150 +852,150 @@ static int GetDeviceCapabilities(struct drxk_state *state) Determine device capabilities Based on pinning v14 */ - status = read32(state, SIO_TOP_JTAGID_LO__A, &sioTopJtagidLo); + status = read32(state, SIO_TOP_JTAGID_LO__A, &sio_top_jtagid_lo); if (status < 0) goto error; - printk(KERN_INFO "drxk: status = 0x%08x\n", sioTopJtagidLo); + printk(KERN_INFO "drxk: status = 0x%08x\n", sio_top_jtagid_lo); /* driver 0.9.0 */ - switch ((sioTopJtagidLo >> 29) & 0xF) { + switch ((sio_top_jtagid_lo >> 29) & 0xF) { case 0: - state->m_deviceSpin = DRXK_SPIN_A1; + state->m_device_spin = DRXK_SPIN_A1; spin = "A1"; break; case 2: - state->m_deviceSpin = DRXK_SPIN_A2; + state->m_device_spin = DRXK_SPIN_A2; spin = "A2"; break; case 3: - state->m_deviceSpin = DRXK_SPIN_A3; + state->m_device_spin = DRXK_SPIN_A3; spin = "A3"; break; default: - state->m_deviceSpin = DRXK_SPIN_UNKNOWN; + state->m_device_spin = DRXK_SPIN_UNKNOWN; status = -EINVAL; printk(KERN_ERR "drxk: Spin %d unknown\n", - (sioTopJtagidLo >> 29) & 0xF); + (sio_top_jtagid_lo >> 29) & 0xF); goto error2; } - switch ((sioTopJtagidLo >> 12) & 0xFF) { + switch ((sio_top_jtagid_lo >> 12) & 0xFF) { case 0x13: /* typeId = DRX3913K_TYPE_ID */ - state->m_hasLNA = false; - state->m_hasOOB = false; - state->m_hasATV = false; - state->m_hasAudio = false; - state->m_hasDVBT = true; - state->m_hasDVBC = true; - state->m_hasSAWSW = true; - state->m_hasGPIO2 = false; - state->m_hasGPIO1 = false; - state->m_hasIRQN = false; + state->m_has_lna = false; + state->m_has_oob = false; + state->m_has_atv = false; + state->m_has_audio = false; + state->m_has_dvbt = true; + state->m_has_dvbc = true; + state->m_has_sawsw = true; + state->m_has_gpio2 = false; + state->m_has_gpio1 = false; + state->m_has_irqn = false; break; case 0x15: /* typeId = DRX3915K_TYPE_ID */ - state->m_hasLNA = false; - state->m_hasOOB = false; - state->m_hasATV = true; - state->m_hasAudio = false; - state->m_hasDVBT = true; - state->m_hasDVBC = false; - state->m_hasSAWSW = true; - state->m_hasGPIO2 = true; - state->m_hasGPIO1 = true; - state->m_hasIRQN = false; + state->m_has_lna = false; + state->m_has_oob = false; + state->m_has_atv = true; + state->m_has_audio = false; + state->m_has_dvbt = true; + state->m_has_dvbc = false; + state->m_has_sawsw = true; + state->m_has_gpio2 = true; + state->m_has_gpio1 = true; + state->m_has_irqn = false; break; case 0x16: /* typeId = DRX3916K_TYPE_ID */ - state->m_hasLNA = false; - state->m_hasOOB = false; - state->m_hasATV = true; - state->m_hasAudio = false; - state->m_hasDVBT = true; - state->m_hasDVBC = false; - state->m_hasSAWSW = true; - state->m_hasGPIO2 = true; - state->m_hasGPIO1 = true; - state->m_hasIRQN = false; + state->m_has_lna = false; + state->m_has_oob = false; + state->m_has_atv = true; + state->m_has_audio = false; + state->m_has_dvbt = true; + state->m_has_dvbc = false; + state->m_has_sawsw = true; + state->m_has_gpio2 = true; + state->m_has_gpio1 = true; + state->m_has_irqn = false; break; case 0x18: /* typeId = DRX3918K_TYPE_ID */ - state->m_hasLNA = false; - state->m_hasOOB = false; - state->m_hasATV = true; - state->m_hasAudio = true; - state->m_hasDVBT = true; - state->m_hasDVBC = false; - state->m_hasSAWSW = true; - state->m_hasGPIO2 = true; - state->m_hasGPIO1 = true; - state->m_hasIRQN = false; + state->m_has_lna = false; + state->m_has_oob = false; + state->m_has_atv = true; + state->m_has_audio = true; + state->m_has_dvbt = true; + state->m_has_dvbc = false; + state->m_has_sawsw = true; + state->m_has_gpio2 = true; + state->m_has_gpio1 = true; + state->m_has_irqn = false; break; case 0x21: /* typeId = DRX3921K_TYPE_ID */ - state->m_hasLNA = false; - state->m_hasOOB = false; - state->m_hasATV = true; - state->m_hasAudio = true; - state->m_hasDVBT = true; - state->m_hasDVBC = true; - state->m_hasSAWSW = true; - state->m_hasGPIO2 = true; - state->m_hasGPIO1 = true; - state->m_hasIRQN = false; + state->m_has_lna = false; + state->m_has_oob = false; + state->m_has_atv = true; + state->m_has_audio = true; + state->m_has_dvbt = true; + state->m_has_dvbc = true; + state->m_has_sawsw = true; + state->m_has_gpio2 = true; + state->m_has_gpio1 = true; + state->m_has_irqn = false; break; case 0x23: /* typeId = DRX3923K_TYPE_ID */ - state->m_hasLNA = false; - state->m_hasOOB = false; - state->m_hasATV = true; - state->m_hasAudio = true; - state->m_hasDVBT = true; - state->m_hasDVBC = true; - state->m_hasSAWSW = true; - state->m_hasGPIO2 = true; - state->m_hasGPIO1 = true; - state->m_hasIRQN = false; + state->m_has_lna = false; + state->m_has_oob = false; + state->m_has_atv = true; + state->m_has_audio = true; + state->m_has_dvbt = true; + state->m_has_dvbc = true; + state->m_has_sawsw = true; + state->m_has_gpio2 = true; + state->m_has_gpio1 = true; + state->m_has_irqn = false; break; case 0x25: /* typeId = DRX3925K_TYPE_ID */ - state->m_hasLNA = false; - state->m_hasOOB = false; - state->m_hasATV = true; - state->m_hasAudio = true; - state->m_hasDVBT = true; - state->m_hasDVBC = true; - state->m_hasSAWSW = true; - state->m_hasGPIO2 = true; - state->m_hasGPIO1 = true; - state->m_hasIRQN = false; + state->m_has_lna = false; + state->m_has_oob = false; + state->m_has_atv = true; + state->m_has_audio = true; + state->m_has_dvbt = true; + state->m_has_dvbc = true; + state->m_has_sawsw = true; + state->m_has_gpio2 = true; + state->m_has_gpio1 = true; + state->m_has_irqn = false; break; case 0x26: /* typeId = DRX3926K_TYPE_ID */ - state->m_hasLNA = false; - state->m_hasOOB = false; - state->m_hasATV = true; - state->m_hasAudio = false; - state->m_hasDVBT = true; - state->m_hasDVBC = true; - state->m_hasSAWSW = true; - state->m_hasGPIO2 = true; - state->m_hasGPIO1 = true; - state->m_hasIRQN = false; + state->m_has_lna = false; + state->m_has_oob = false; + state->m_has_atv = true; + state->m_has_audio = false; + state->m_has_dvbt = true; + state->m_has_dvbc = true; + state->m_has_sawsw = true; + state->m_has_gpio2 = true; + state->m_has_gpio1 = true; + state->m_has_irqn = false; break; default: printk(KERN_ERR "drxk: DeviceID 0x%02x not supported\n", - ((sioTopJtagidLo >> 12) & 0xFF)); + ((sio_top_jtagid_lo >> 12) & 0xFF)); status = -EINVAL; goto error2; } printk(KERN_INFO "drxk: detected a drx-39%02xk, spin %s, xtal %d.%03d MHz\n", - ((sioTopJtagidLo >> 12) & 0xFF), spin, - state->m_oscClockFreq / 1000, - state->m_oscClockFreq % 1000); + ((sio_top_jtagid_lo >> 12) & 0xFF), spin, + state->m_osc_clock_freq / 1000, + state->m_osc_clock_freq % 1000); error: if (status < 0) @@ -1005,7 +1005,7 @@ error2: return status; } -static int HI_Command(struct drxk_state *state, u16 cmd, u16 *pResult) +static int hi_command(struct drxk_state *state, u16 cmd, u16 *p_result) { int status; bool powerdown_cmd; @@ -1021,24 +1021,24 @@ static int HI_Command(struct drxk_state *state, u16 cmd, u16 *pResult) powerdown_cmd = (bool) ((cmd == SIO_HI_RA_RAM_CMD_CONFIG) && - ((state->m_HICfgCtrl) & + ((state->m_hi_cfg_ctrl) & SIO_HI_RA_RAM_PAR_5_CFG_SLEEP__M) == SIO_HI_RA_RAM_PAR_5_CFG_SLEEP_ZZZ); if (powerdown_cmd == false) { /* Wait until command rdy */ - u32 retryCount = 0; - u16 waitCmd; + u32 retry_count = 0; + u16 wait_cmd; do { msleep(1); - retryCount += 1; + retry_count += 1; status = read16(state, SIO_HI_RA_RAM_CMD__A, - &waitCmd); - } while ((status < 0) && (retryCount < DRXK_MAX_RETRIES) - && (waitCmd != 0)); + &wait_cmd); + } while ((status < 0) && (retry_count < DRXK_MAX_RETRIES) + && (wait_cmd != 0)); if (status < 0) goto error; - status = read16(state, SIO_HI_RA_RAM_RES__A, pResult); + status = read16(state, SIO_HI_RA_RAM_RES__A, p_result); } error: if (status < 0) @@ -1047,7 +1047,7 @@ error: return status; } -static int HI_CfgCommand(struct drxk_state *state) +static int hi_cfg_command(struct drxk_state *state) { int status; @@ -1055,29 +1055,29 @@ static int HI_CfgCommand(struct drxk_state *state) mutex_lock(&state->mutex); - status = write16(state, SIO_HI_RA_RAM_PAR_6__A, state->m_HICfgTimeout); + status = write16(state, SIO_HI_RA_RAM_PAR_6__A, state->m_hi_cfg_timeout); if (status < 0) goto error; - status = write16(state, SIO_HI_RA_RAM_PAR_5__A, state->m_HICfgCtrl); + status = write16(state, SIO_HI_RA_RAM_PAR_5__A, state->m_hi_cfg_ctrl); if (status < 0) goto error; - status = write16(state, SIO_HI_RA_RAM_PAR_4__A, state->m_HICfgWakeUpKey); + status = write16(state, SIO_HI_RA_RAM_PAR_4__A, state->m_hi_cfg_wake_up_key); if (status < 0) goto error; - status = write16(state, SIO_HI_RA_RAM_PAR_3__A, state->m_HICfgBridgeDelay); + status = write16(state, SIO_HI_RA_RAM_PAR_3__A, state->m_hi_cfg_bridge_delay); if (status < 0) goto error; - status = write16(state, SIO_HI_RA_RAM_PAR_2__A, state->m_HICfgTimingDiv); + status = write16(state, SIO_HI_RA_RAM_PAR_2__A, state->m_hi_cfg_timing_div); if (status < 0) goto error; status = write16(state, SIO_HI_RA_RAM_PAR_1__A, SIO_HI_RA_RAM_PAR_1_PAR1_SEC_KEY); if (status < 0) goto error; - status = HI_Command(state, SIO_HI_RA_RAM_CMD_CONFIG, 0); + status = hi_command(state, SIO_HI_RA_RAM_CMD_CONFIG, 0); if (status < 0) goto error; - state->m_HICfgCtrl &= ~SIO_HI_RA_RAM_PAR_5_CFG_SLEEP_ZZZ; + state->m_hi_cfg_ctrl &= ~SIO_HI_RA_RAM_PAR_5_CFG_SLEEP_ZZZ; error: mutex_unlock(&state->mutex); if (status < 0) @@ -1085,28 +1085,28 @@ error: return status; } -static int InitHI(struct drxk_state *state) +static int init_hi(struct drxk_state *state) { dprintk(1, "\n"); - state->m_HICfgWakeUpKey = (state->demod_address << 1); - state->m_HICfgTimeout = 0x96FF; + state->m_hi_cfg_wake_up_key = (state->demod_address << 1); + state->m_hi_cfg_timeout = 0x96FF; /* port/bridge/power down ctrl */ - state->m_HICfgCtrl = SIO_HI_RA_RAM_PAR_5_CFG_SLV0_SLAVE; + state->m_hi_cfg_ctrl = SIO_HI_RA_RAM_PAR_5_CFG_SLV0_SLAVE; - return HI_CfgCommand(state); + return hi_cfg_command(state); } -static int MPEGTSConfigurePins(struct drxk_state *state, bool mpegEnable) +static int mpegts_configure_pins(struct drxk_state *state, bool mpeg_enable) { int status = -1; - u16 sioPdrMclkCfg = 0; - u16 sioPdrMdxCfg = 0; + u16 sio_pdr_mclk_cfg = 0; + u16 sio_pdr_mdx_cfg = 0; u16 err_cfg = 0; dprintk(1, ": mpeg %s, %s mode\n", - mpegEnable ? "enable" : "disable", - state->m_enableParallel ? "parallel" : "serial"); + mpeg_enable ? "enable" : "disable", + state->m_enable_parallel ? "parallel" : "serial"); /* stop lock indicator process */ status = write16(state, SCU_RAM_GPIO__A, SCU_RAM_GPIO_HW_LOCK_IND_DISABLE); @@ -1118,7 +1118,7 @@ static int MPEGTSConfigurePins(struct drxk_state *state, bool mpegEnable) if (status < 0) goto error; - if (mpegEnable == false) { + if (mpeg_enable == false) { /* Set MPEG TS pads to inputmode */ status = write16(state, SIO_PDR_MSTRT_CFG__A, 0x0000); if (status < 0) @@ -1158,19 +1158,19 @@ static int MPEGTSConfigurePins(struct drxk_state *state, bool mpegEnable) goto error; } else { /* Enable MPEG output */ - sioPdrMdxCfg = - ((state->m_TSDataStrength << + sio_pdr_mdx_cfg = + ((state->m_ts_data_strength << SIO_PDR_MD0_CFG_DRIVE__B) | 0x0003); - sioPdrMclkCfg = ((state->m_TSClockkStrength << + sio_pdr_mclk_cfg = ((state->m_ts_clockk_strength << SIO_PDR_MCLK_CFG_DRIVE__B) | 0x0003); - status = write16(state, SIO_PDR_MSTRT_CFG__A, sioPdrMdxCfg); + status = write16(state, SIO_PDR_MSTRT_CFG__A, sio_pdr_mdx_cfg); if (status < 0) goto error; if (state->enable_merr_cfg) - err_cfg = sioPdrMdxCfg; + err_cfg = sio_pdr_mdx_cfg; status = write16(state, SIO_PDR_MERR_CFG__A, err_cfg); if (status < 0) @@ -1179,31 +1179,31 @@ static int MPEGTSConfigurePins(struct drxk_state *state, bool mpegEnable) if (status < 0) goto error; - if (state->m_enableParallel == true) { + if (state->m_enable_parallel == true) { /* paralel -> enable MD1 to MD7 */ - status = write16(state, SIO_PDR_MD1_CFG__A, sioPdrMdxCfg); + status = write16(state, SIO_PDR_MD1_CFG__A, sio_pdr_mdx_cfg); if (status < 0) goto error; - status = write16(state, SIO_PDR_MD2_CFG__A, sioPdrMdxCfg); + status = write16(state, SIO_PDR_MD2_CFG__A, sio_pdr_mdx_cfg); if (status < 0) goto error; - status = write16(state, SIO_PDR_MD3_CFG__A, sioPdrMdxCfg); + status = write16(state, SIO_PDR_MD3_CFG__A, sio_pdr_mdx_cfg); if (status < 0) goto error; - status = write16(state, SIO_PDR_MD4_CFG__A, sioPdrMdxCfg); + status = write16(state, SIO_PDR_MD4_CFG__A, sio_pdr_mdx_cfg); if (status < 0) goto error; - status = write16(state, SIO_PDR_MD5_CFG__A, sioPdrMdxCfg); + status = write16(state, SIO_PDR_MD5_CFG__A, sio_pdr_mdx_cfg); if (status < 0) goto error; - status = write16(state, SIO_PDR_MD6_CFG__A, sioPdrMdxCfg); + status = write16(state, SIO_PDR_MD6_CFG__A, sio_pdr_mdx_cfg); if (status < 0) goto error; - status = write16(state, SIO_PDR_MD7_CFG__A, sioPdrMdxCfg); + status = write16(state, SIO_PDR_MD7_CFG__A, sio_pdr_mdx_cfg); if (status < 0) goto error; } else { - sioPdrMdxCfg = ((state->m_TSDataStrength << + sio_pdr_mdx_cfg = ((state->m_ts_data_strength << SIO_PDR_MD0_CFG_DRIVE__B) | 0x0003); /* serial -> disable MD1 to MD7 */ @@ -1229,10 +1229,10 @@ static int MPEGTSConfigurePins(struct drxk_state *state, bool mpegEnable) if (status < 0) goto error; } - status = write16(state, SIO_PDR_MCLK_CFG__A, sioPdrMclkCfg); + status = write16(state, SIO_PDR_MCLK_CFG__A, sio_pdr_mclk_cfg); if (status < 0) goto error; - status = write16(state, SIO_PDR_MD0_CFG__A, sioPdrMdxCfg); + status = write16(state, SIO_PDR_MD0_CFG__A, sio_pdr_mdx_cfg); if (status < 0) goto error; } @@ -1248,17 +1248,17 @@ error: return status; } -static int MPEGTSDisable(struct drxk_state *state) +static int mpegts_disable(struct drxk_state *state) { dprintk(1, "\n"); - return MPEGTSConfigurePins(state, false); + return mpegts_configure_pins(state, false); } -static int BLChainCmd(struct drxk_state *state, - u16 romOffset, u16 nrOfElements, u32 timeOut) +static int bl_chain_cmd(struct drxk_state *state, + u16 rom_offset, u16 nr_of_elements, u32 time_out) { - u16 blStatus = 0; + u16 bl_status = 0; int status; unsigned long end; @@ -1267,26 +1267,26 @@ static int BLChainCmd(struct drxk_state *state, status = write16(state, SIO_BL_MODE__A, SIO_BL_MODE_CHAIN); if (status < 0) goto error; - status = write16(state, SIO_BL_CHAIN_ADDR__A, romOffset); + status = write16(state, SIO_BL_CHAIN_ADDR__A, rom_offset); if (status < 0) goto error; - status = write16(state, SIO_BL_CHAIN_LEN__A, nrOfElements); + status = write16(state, SIO_BL_CHAIN_LEN__A, nr_of_elements); if (status < 0) goto error; status = write16(state, SIO_BL_ENABLE__A, SIO_BL_ENABLE_ON); if (status < 0) goto error; - end = jiffies + msecs_to_jiffies(timeOut); + end = jiffies + msecs_to_jiffies(time_out); do { msleep(1); - status = read16(state, SIO_BL_STATUS__A, &blStatus); + status = read16(state, SIO_BL_STATUS__A, &bl_status); if (status < 0) goto error; - } while ((blStatus == 0x1) && + } while ((bl_status == 0x1) && ((time_is_after_jiffies(end)))); - if (blStatus == 0x1) { + if (bl_status == 0x1) { printk(KERN_ERR "drxk: SIO not ready\n"); status = -EINVAL; goto error2; @@ -1300,13 +1300,13 @@ error2: } -static int DownloadMicrocode(struct drxk_state *state, - const u8 pMCImage[], u32 Length) +static int download_microcode(struct drxk_state *state, + const u8 p_mc_image[], u32 length) { - const u8 *pSrc = pMCImage; - u32 Address; - u16 nBlocks; - u16 BlockSize; + const u8 *p_src = p_mc_image; + u32 address; + u16 n_blocks; + u16 block_size; u32 offset = 0; u32 i; int status = 0; @@ -1316,114 +1316,114 @@ static int DownloadMicrocode(struct drxk_state *state, /* down the drain (we don't care about MAGIC_WORD) */ #if 0 /* For future reference */ - Drain = (pSrc[0] << 8) | pSrc[1]; + drain = (p_src[0] << 8) | p_src[1]; #endif - pSrc += sizeof(u16); + p_src += sizeof(u16); offset += sizeof(u16); - nBlocks = (pSrc[0] << 8) | pSrc[1]; - pSrc += sizeof(u16); + n_blocks = (p_src[0] << 8) | p_src[1]; + p_src += sizeof(u16); offset += sizeof(u16); - for (i = 0; i < nBlocks; i += 1) { - Address = (pSrc[0] << 24) | (pSrc[1] << 16) | - (pSrc[2] << 8) | pSrc[3]; - pSrc += sizeof(u32); + for (i = 0; i < n_blocks; i += 1) { + address = (p_src[0] << 24) | (p_src[1] << 16) | + (p_src[2] << 8) | p_src[3]; + p_src += sizeof(u32); offset += sizeof(u32); - BlockSize = ((pSrc[0] << 8) | pSrc[1]) * sizeof(u16); - pSrc += sizeof(u16); + block_size = ((p_src[0] << 8) | p_src[1]) * sizeof(u16); + p_src += sizeof(u16); offset += sizeof(u16); #if 0 /* For future reference */ - Flags = (pSrc[0] << 8) | pSrc[1]; + flags = (p_src[0] << 8) | p_src[1]; #endif - pSrc += sizeof(u16); + p_src += sizeof(u16); offset += sizeof(u16); #if 0 /* For future reference */ - BlockCRC = (pSrc[0] << 8) | pSrc[1]; + block_crc = (p_src[0] << 8) | p_src[1]; #endif - pSrc += sizeof(u16); + p_src += sizeof(u16); offset += sizeof(u16); - if (offset + BlockSize > Length) { + if (offset + block_size > length) { printk(KERN_ERR "drxk: Firmware is corrupted.\n"); return -EINVAL; } - status = write_block(state, Address, BlockSize, pSrc); + status = write_block(state, address, block_size, p_src); if (status < 0) { printk(KERN_ERR "drxk: Error %d while loading firmware\n", status); break; } - pSrc += BlockSize; - offset += BlockSize; + p_src += block_size; + offset += block_size; } return status; } -static int DVBTEnableOFDMTokenRing(struct drxk_state *state, bool enable) +static int dvbt_enable_ofdm_token_ring(struct drxk_state *state, bool enable) { int status; u16 data = 0; - u16 desiredCtrl = SIO_OFDM_SH_OFDM_RING_ENABLE_ON; - u16 desiredStatus = SIO_OFDM_SH_OFDM_RING_STATUS_ENABLED; + u16 desired_ctrl = SIO_OFDM_SH_OFDM_RING_ENABLE_ON; + u16 desired_status = SIO_OFDM_SH_OFDM_RING_STATUS_ENABLED; unsigned long end; dprintk(1, "\n"); if (enable == false) { - desiredCtrl = SIO_OFDM_SH_OFDM_RING_ENABLE_OFF; - desiredStatus = SIO_OFDM_SH_OFDM_RING_STATUS_DOWN; + desired_ctrl = SIO_OFDM_SH_OFDM_RING_ENABLE_OFF; + desired_status = SIO_OFDM_SH_OFDM_RING_STATUS_DOWN; } status = read16(state, SIO_OFDM_SH_OFDM_RING_STATUS__A, &data); - if (status >= 0 && data == desiredStatus) { + if (status >= 0 && data == desired_status) { /* tokenring already has correct status */ return status; } /* Disable/enable dvbt tokenring bridge */ - status = write16(state, SIO_OFDM_SH_OFDM_RING_ENABLE__A, desiredCtrl); + status = write16(state, SIO_OFDM_SH_OFDM_RING_ENABLE__A, desired_ctrl); end = jiffies + msecs_to_jiffies(DRXK_OFDM_TR_SHUTDOWN_TIMEOUT); do { status = read16(state, SIO_OFDM_SH_OFDM_RING_STATUS__A, &data); - if ((status >= 0 && data == desiredStatus) || time_is_after_jiffies(end)) + if ((status >= 0 && data == desired_status) || time_is_after_jiffies(end)) break; msleep(1); } while (1); - if (data != desiredStatus) { + if (data != desired_status) { printk(KERN_ERR "drxk: SIO not ready\n"); return -EINVAL; } return status; } -static int MPEGTSStop(struct drxk_state *state) +static int mpegts_stop(struct drxk_state *state) { int status = 0; - u16 fecOcSncMode = 0; - u16 fecOcIprMode = 0; + u16 fec_oc_snc_mode = 0; + u16 fec_oc_ipr_mode = 0; dprintk(1, "\n"); /* Gracefull shutdown (byte boundaries) */ - status = read16(state, FEC_OC_SNC_MODE__A, &fecOcSncMode); + status = read16(state, FEC_OC_SNC_MODE__A, &fec_oc_snc_mode); if (status < 0) goto error; - fecOcSncMode |= FEC_OC_SNC_MODE_SHUTDOWN__M; - status = write16(state, FEC_OC_SNC_MODE__A, fecOcSncMode); + fec_oc_snc_mode |= FEC_OC_SNC_MODE_SHUTDOWN__M; + status = write16(state, FEC_OC_SNC_MODE__A, fec_oc_snc_mode); if (status < 0) goto error; /* Suppress MCLK during absence of data */ - status = read16(state, FEC_OC_IPR_MODE__A, &fecOcIprMode); + status = read16(state, FEC_OC_IPR_MODE__A, &fec_oc_ipr_mode); if (status < 0) goto error; - fecOcIprMode |= FEC_OC_IPR_MODE_MCLK_DIS_DAT_ABS__M; - status = write16(state, FEC_OC_IPR_MODE__A, fecOcIprMode); + fec_oc_ipr_mode |= FEC_OC_IPR_MODE_MCLK_DIS_DAT_ABS__M; + status = write16(state, FEC_OC_IPR_MODE__A, fec_oc_ipr_mode); error: if (status < 0) @@ -1433,13 +1433,13 @@ error: } static int scu_command(struct drxk_state *state, - u16 cmd, u8 parameterLen, - u16 *parameter, u8 resultLen, u16 *result) + u16 cmd, u8 parameter_len, + u16 *parameter, u8 result_len, u16 *result) { #if (SCU_RAM_PARAM_0__A - SCU_RAM_PARAM_15__A) != 15 #error DRXK register mapping no longer compatible with this routine! #endif - u16 curCmd = 0; + u16 cur_cmd = 0; int status = -EINVAL; unsigned long end; u8 buffer[34]; @@ -1449,8 +1449,8 @@ static int scu_command(struct drxk_state *state, dprintk(1, "\n"); - if ((cmd == 0) || ((parameterLen > 0) && (parameter == NULL)) || - ((resultLen > 0) && (result == NULL))) { + if ((cmd == 0) || ((parameter_len > 0) && (parameter == NULL)) || + ((result_len > 0) && (result == NULL))) { printk(KERN_ERR "drxk: Error %d on %s\n", status, __func__); return status; } @@ -1459,7 +1459,7 @@ static int scu_command(struct drxk_state *state, /* assume that the command register is ready since it is checked afterwards */ - for (ii = parameterLen - 1; ii >= 0; ii -= 1) { + for (ii = parameter_len - 1; ii >= 0; ii -= 1) { buffer[cnt++] = (parameter[ii] & 0xFF); buffer[cnt++] = ((parameter[ii] >> 8) & 0xFF); } @@ -1467,26 +1467,26 @@ static int scu_command(struct drxk_state *state, buffer[cnt++] = ((cmd >> 8) & 0xFF); write_block(state, SCU_RAM_PARAM_0__A - - (parameterLen - 1), cnt, buffer); + (parameter_len - 1), cnt, buffer); /* Wait until SCU has processed command */ end = jiffies + msecs_to_jiffies(DRXK_MAX_WAITTIME); do { msleep(1); - status = read16(state, SCU_RAM_COMMAND__A, &curCmd); + status = read16(state, SCU_RAM_COMMAND__A, &cur_cmd); if (status < 0) goto error; - } while (!(curCmd == DRX_SCU_READY) && (time_is_after_jiffies(end))); - if (curCmd != DRX_SCU_READY) { + } while (!(cur_cmd == DRX_SCU_READY) && (time_is_after_jiffies(end))); + if (cur_cmd != DRX_SCU_READY) { printk(KERN_ERR "drxk: SCU not ready\n"); status = -EIO; goto error2; } /* read results */ - if ((resultLen > 0) && (result != NULL)) { + if ((result_len > 0) && (result != NULL)) { s16 err; int ii; - for (ii = resultLen - 1; ii >= 0; ii -= 1) { + for (ii = result_len - 1; ii >= 0; ii -= 1) { status = read16(state, SCU_RAM_PARAM_0__A - ii, &result[ii]); if (status < 0) goto error; @@ -1529,7 +1529,7 @@ error2: return status; } -static int SetIqmAf(struct drxk_state *state, bool active) +static int set_iqm_af(struct drxk_state *state, bool active) { u16 data = 0; int status; @@ -1563,10 +1563,10 @@ error: return status; } -static int CtrlPowerMode(struct drxk_state *state, enum DRXPowerMode *mode) +static int ctrl_power_mode(struct drxk_state *state, enum drx_power_mode *mode) { int status = 0; - u16 sioCcPwdMode = 0; + u16 sio_cc_pwd_mode = 0; dprintk(1, "\n"); @@ -1576,19 +1576,19 @@ static int CtrlPowerMode(struct drxk_state *state, enum DRXPowerMode *mode) switch (*mode) { case DRX_POWER_UP: - sioCcPwdMode = SIO_CC_PWD_MODE_LEVEL_NONE; + sio_cc_pwd_mode = SIO_CC_PWD_MODE_LEVEL_NONE; break; case DRXK_POWER_DOWN_OFDM: - sioCcPwdMode = SIO_CC_PWD_MODE_LEVEL_OFDM; + sio_cc_pwd_mode = SIO_CC_PWD_MODE_LEVEL_OFDM; break; case DRXK_POWER_DOWN_CORE: - sioCcPwdMode = SIO_CC_PWD_MODE_LEVEL_CLOCK; + sio_cc_pwd_mode = SIO_CC_PWD_MODE_LEVEL_CLOCK; break; case DRXK_POWER_DOWN_PLL: - sioCcPwdMode = SIO_CC_PWD_MODE_LEVEL_PLL; + sio_cc_pwd_mode = SIO_CC_PWD_MODE_LEVEL_PLL; break; case DRX_POWER_DOWN: - sioCcPwdMode = SIO_CC_PWD_MODE_LEVEL_OSC; + sio_cc_pwd_mode = SIO_CC_PWD_MODE_LEVEL_OSC; break; default: /* Unknow sleep mode */ @@ -1596,15 +1596,15 @@ static int CtrlPowerMode(struct drxk_state *state, enum DRXPowerMode *mode) } /* If already in requested power mode, do nothing */ - if (state->m_currentPowerMode == *mode) + if (state->m_current_power_mode == *mode) return 0; /* For next steps make sure to start from DRX_POWER_UP mode */ - if (state->m_currentPowerMode != DRX_POWER_UP) { - status = PowerUpDevice(state); + if (state->m_current_power_mode != DRX_POWER_UP) { + status = power_up_device(state); if (status < 0) goto error; - status = DVBTEnableOFDMTokenRing(state, true); + status = dvbt_enable_ofdm_token_ring(state, true); if (status < 0) goto error; } @@ -1621,31 +1621,31 @@ static int CtrlPowerMode(struct drxk_state *state, enum DRXPowerMode *mode) /* Power down device */ /* stop all comm_exec */ /* Stop and power down previous standard */ - switch (state->m_OperationMode) { + switch (state->m_operation_mode) { case OM_DVBT: - status = MPEGTSStop(state); + status = mpegts_stop(state); if (status < 0) goto error; - status = PowerDownDVBT(state, false); + status = power_down_dvbt(state, false); if (status < 0) goto error; break; case OM_QAM_ITU_A: case OM_QAM_ITU_C: - status = MPEGTSStop(state); + status = mpegts_stop(state); if (status < 0) goto error; - status = PowerDownQAM(state); + status = power_down_qam(state); if (status < 0) goto error; break; default: break; } - status = DVBTEnableOFDMTokenRing(state, false); + status = dvbt_enable_ofdm_token_ring(state, false); if (status < 0) goto error; - status = write16(state, SIO_CC_PWD_MODE__A, sioCcPwdMode); + status = write16(state, SIO_CC_PWD_MODE__A, sio_cc_pwd_mode); if (status < 0) goto error; status = write16(state, SIO_CC_UPDATE__A, SIO_CC_UPDATE_KEY); @@ -1653,14 +1653,14 @@ static int CtrlPowerMode(struct drxk_state *state, enum DRXPowerMode *mode) goto error; if (*mode != DRXK_POWER_DOWN_OFDM) { - state->m_HICfgCtrl |= + state->m_hi_cfg_ctrl |= SIO_HI_RA_RAM_PAR_5_CFG_SLEEP_ZZZ; - status = HI_CfgCommand(state); + status = hi_cfg_command(state); if (status < 0) goto error; } } - state->m_currentPowerMode = *mode; + state->m_current_power_mode = *mode; error: if (status < 0) @@ -1669,10 +1669,10 @@ error: return status; } -static int PowerDownDVBT(struct drxk_state *state, bool setPowerMode) +static int power_down_dvbt(struct drxk_state *state, bool set_power_mode) { - enum DRXPowerMode powerMode = DRXK_POWER_DOWN_OFDM; - u16 cmdResult = 0; + enum drx_power_mode power_mode = DRXK_POWER_DOWN_OFDM; + u16 cmd_result = 0; u16 data = 0; int status; @@ -1683,11 +1683,11 @@ static int PowerDownDVBT(struct drxk_state *state, bool setPowerMode) goto error; if (data == SCU_COMM_EXEC_ACTIVE) { /* Send OFDM stop command */ - status = scu_command(state, SCU_RAM_COMMAND_STANDARD_OFDM | SCU_RAM_COMMAND_CMD_DEMOD_STOP, 0, NULL, 1, &cmdResult); + status = scu_command(state, SCU_RAM_COMMAND_STANDARD_OFDM | SCU_RAM_COMMAND_CMD_DEMOD_STOP, 0, NULL, 1, &cmd_result); if (status < 0) goto error; /* Send OFDM reset command */ - status = scu_command(state, SCU_RAM_COMMAND_STANDARD_OFDM | SCU_RAM_COMMAND_CMD_DEMOD_RESET, 0, NULL, 1, &cmdResult); + status = scu_command(state, SCU_RAM_COMMAND_STANDARD_OFDM | SCU_RAM_COMMAND_CMD_DEMOD_RESET, 0, NULL, 1, &cmd_result); if (status < 0) goto error; } @@ -1704,13 +1704,13 @@ static int PowerDownDVBT(struct drxk_state *state, bool setPowerMode) goto error; /* powerdown AFE */ - status = SetIqmAf(state, false); + status = set_iqm_af(state, false); if (status < 0) goto error; /* powerdown to OFDM mode */ - if (setPowerMode) { - status = CtrlPowerMode(state, &powerMode); + if (set_power_mode) { + status = ctrl_power_mode(state, &power_mode); if (status < 0) goto error; } @@ -1720,8 +1720,8 @@ error: return status; } -static int SetOperationMode(struct drxk_state *state, - enum OperationMode oMode) +static int setoperation_mode(struct drxk_state *state, + enum operation_mode o_mode) { int status = 0; @@ -1738,31 +1738,31 @@ static int SetOperationMode(struct drxk_state *state, goto error; /* Device is already at the required mode */ - if (state->m_OperationMode == oMode) + if (state->m_operation_mode == o_mode) return 0; - switch (state->m_OperationMode) { + switch (state->m_operation_mode) { /* OM_NONE was added for start up */ case OM_NONE: break; case OM_DVBT: - status = MPEGTSStop(state); + status = mpegts_stop(state); if (status < 0) goto error; - status = PowerDownDVBT(state, true); + status = power_down_dvbt(state, true); if (status < 0) goto error; - state->m_OperationMode = OM_NONE; + state->m_operation_mode = OM_NONE; break; case OM_QAM_ITU_A: /* fallthrough */ case OM_QAM_ITU_C: - status = MPEGTSStop(state); + status = mpegts_stop(state); if (status < 0) goto error; - status = PowerDownQAM(state); + status = power_down_qam(state); if (status < 0) goto error; - state->m_OperationMode = OM_NONE; + state->m_operation_mode = OM_NONE; break; case OM_QAM_ITU_B: default: @@ -1773,20 +1773,20 @@ static int SetOperationMode(struct drxk_state *state, /* Power up new standard */ - switch (oMode) { + switch (o_mode) { case OM_DVBT: dprintk(1, ": DVB-T\n"); - state->m_OperationMode = oMode; - status = SetDVBTStandard(state, oMode); + state->m_operation_mode = o_mode; + status = set_dvbt_standard(state, o_mode); if (status < 0) goto error; break; case OM_QAM_ITU_A: /* fallthrough */ case OM_QAM_ITU_C: dprintk(1, ": DVB-C Annex %c\n", - (state->m_OperationMode == OM_QAM_ITU_A) ? 'A' : 'C'); - state->m_OperationMode = oMode; - status = SetQAMStandard(state, oMode); + (state->m_operation_mode == OM_QAM_ITU_A) ? 'A' : 'C'); + state->m_operation_mode = o_mode; + status = set_qam_standard(state, o_mode); if (status < 0) goto error; break; @@ -1800,47 +1800,47 @@ error: return status; } -static int Start(struct drxk_state *state, s32 offsetFreq, - s32 IntermediateFrequency) +static int start(struct drxk_state *state, s32 offset_freq, + s32 intermediate_frequency) { int status = -EINVAL; - u16 IFreqkHz; - s32 OffsetkHz = offsetFreq / 1000; + u16 i_freqk_hz; + s32 offsetk_hz = offset_freq / 1000; dprintk(1, "\n"); - if (state->m_DrxkState != DRXK_STOPPED && - state->m_DrxkState != DRXK_DTV_STARTED) + if (state->m_drxk_state != DRXK_STOPPED && + state->m_drxk_state != DRXK_DTV_STARTED) goto error; - state->m_bMirrorFreqSpect = (state->props.inversion == INVERSION_ON); + state->m_b_mirror_freq_spect = (state->props.inversion == INVERSION_ON); - if (IntermediateFrequency < 0) { - state->m_bMirrorFreqSpect = !state->m_bMirrorFreqSpect; - IntermediateFrequency = -IntermediateFrequency; + if (intermediate_frequency < 0) { + state->m_b_mirror_freq_spect = !state->m_b_mirror_freq_spect; + intermediate_frequency = -intermediate_frequency; } - switch (state->m_OperationMode) { + switch (state->m_operation_mode) { case OM_QAM_ITU_A: case OM_QAM_ITU_C: - IFreqkHz = (IntermediateFrequency / 1000); - status = SetQAM(state, IFreqkHz, OffsetkHz); + i_freqk_hz = (intermediate_frequency / 1000); + status = set_qam(state, i_freqk_hz, offsetk_hz); if (status < 0) goto error; - state->m_DrxkState = DRXK_DTV_STARTED; + state->m_drxk_state = DRXK_DTV_STARTED; break; case OM_DVBT: - IFreqkHz = (IntermediateFrequency / 1000); - status = MPEGTSStop(state); + i_freqk_hz = (intermediate_frequency / 1000); + status = mpegts_stop(state); if (status < 0) goto error; - status = SetDVBT(state, IFreqkHz, OffsetkHz); + status = set_dvbt(state, i_freqk_hz, offsetk_hz); if (status < 0) goto error; - status = DVBTStart(state); + status = dvbt_start(state); if (status < 0) goto error; - state->m_DrxkState = DRXK_DTV_STARTED; + state->m_drxk_state = DRXK_DTV_STARTED; break; default: break; @@ -1851,34 +1851,34 @@ error: return status; } -static int ShutDown(struct drxk_state *state) +static int shut_down(struct drxk_state *state) { dprintk(1, "\n"); - MPEGTSStop(state); + mpegts_stop(state); return 0; } -static int GetLockStatus(struct drxk_state *state, u32 *pLockStatus) +static int get_lock_status(struct drxk_state *state, u32 *p_lock_status) { int status = -EINVAL; dprintk(1, "\n"); - if (pLockStatus == NULL) + if (p_lock_status == NULL) goto error; - *pLockStatus = NOT_LOCKED; + *p_lock_status = NOT_LOCKED; /* define the SCU command code */ - switch (state->m_OperationMode) { + switch (state->m_operation_mode) { case OM_QAM_ITU_A: case OM_QAM_ITU_B: case OM_QAM_ITU_C: - status = GetQAMLockStatus(state, pLockStatus); + status = get_qam_lock_status(state, p_lock_status); break; case OM_DVBT: - status = GetDVBTLockStatus(state, pLockStatus); + status = get_dvbt_lock_status(state, p_lock_status); break; default: break; @@ -1889,18 +1889,18 @@ error: return status; } -static int MPEGTSStart(struct drxk_state *state) +static int mpegts_start(struct drxk_state *state) { int status; - u16 fecOcSncMode = 0; + u16 fec_oc_snc_mode = 0; /* Allow OC to sync again */ - status = read16(state, FEC_OC_SNC_MODE__A, &fecOcSncMode); + status = read16(state, FEC_OC_SNC_MODE__A, &fec_oc_snc_mode); if (status < 0) goto error; - fecOcSncMode &= ~FEC_OC_SNC_MODE_SHUTDOWN__M; - status = write16(state, FEC_OC_SNC_MODE__A, fecOcSncMode); + fec_oc_snc_mode &= ~FEC_OC_SNC_MODE_SHUTDOWN__M; + status = write16(state, FEC_OC_SNC_MODE__A, fec_oc_snc_mode); if (status < 0) goto error; status = write16(state, FEC_OC_SNC_UNLOCK__A, 1); @@ -1910,7 +1910,7 @@ error: return status; } -static int MPEGTSDtoInit(struct drxk_state *state) +static int mpegts_dto_init(struct drxk_state *state) { int status; @@ -1957,63 +1957,63 @@ error: return status; } -static int MPEGTSDtoSetup(struct drxk_state *state, - enum OperationMode oMode) +static int mpegts_dto_setup(struct drxk_state *state, + enum operation_mode o_mode) { int status; - u16 fecOcRegMode = 0; /* FEC_OC_MODE register value */ - u16 fecOcRegIprMode = 0; /* FEC_OC_IPR_MODE register value */ - u16 fecOcDtoMode = 0; /* FEC_OC_IPR_INVERT register value */ - u16 fecOcFctMode = 0; /* FEC_OC_IPR_INVERT register value */ - u16 fecOcDtoPeriod = 2; /* FEC_OC_IPR_INVERT register value */ - u16 fecOcDtoBurstLen = 188; /* FEC_OC_IPR_INVERT register value */ - u32 fecOcRcnCtlRate = 0; /* FEC_OC_IPR_INVERT register value */ - u16 fecOcTmdMode = 0; - u16 fecOcTmdIntUpdRate = 0; - u32 maxBitRate = 0; - bool staticCLK = false; + u16 fec_oc_reg_mode = 0; /* FEC_OC_MODE register value */ + u16 fec_oc_reg_ipr_mode = 0; /* FEC_OC_IPR_MODE register value */ + u16 fec_oc_dto_mode = 0; /* FEC_OC_IPR_INVERT register value */ + u16 fec_oc_fct_mode = 0; /* FEC_OC_IPR_INVERT register value */ + u16 fec_oc_dto_period = 2; /* FEC_OC_IPR_INVERT register value */ + u16 fec_oc_dto_burst_len = 188; /* FEC_OC_IPR_INVERT register value */ + u32 fec_oc_rcn_ctl_rate = 0; /* FEC_OC_IPR_INVERT register value */ + u16 fec_oc_tmd_mode = 0; + u16 fec_oc_tmd_int_upd_rate = 0; + u32 max_bit_rate = 0; + bool static_clk = false; dprintk(1, "\n"); /* Check insertion of the Reed-Solomon parity bytes */ - status = read16(state, FEC_OC_MODE__A, &fecOcRegMode); + status = read16(state, FEC_OC_MODE__A, &fec_oc_reg_mode); if (status < 0) goto error; - status = read16(state, FEC_OC_IPR_MODE__A, &fecOcRegIprMode); + status = read16(state, FEC_OC_IPR_MODE__A, &fec_oc_reg_ipr_mode); if (status < 0) goto error; - fecOcRegMode &= (~FEC_OC_MODE_PARITY__M); - fecOcRegIprMode &= (~FEC_OC_IPR_MODE_MVAL_DIS_PAR__M); - if (state->m_insertRSByte == true) { + fec_oc_reg_mode &= (~FEC_OC_MODE_PARITY__M); + fec_oc_reg_ipr_mode &= (~FEC_OC_IPR_MODE_MVAL_DIS_PAR__M); + if (state->m_insert_rs_byte == true) { /* enable parity symbol forward */ - fecOcRegMode |= FEC_OC_MODE_PARITY__M; + fec_oc_reg_mode |= FEC_OC_MODE_PARITY__M; /* MVAL disable during parity bytes */ - fecOcRegIprMode |= FEC_OC_IPR_MODE_MVAL_DIS_PAR__M; + fec_oc_reg_ipr_mode |= FEC_OC_IPR_MODE_MVAL_DIS_PAR__M; /* TS burst length to 204 */ - fecOcDtoBurstLen = 204; + fec_oc_dto_burst_len = 204; } /* Check serial or parrallel output */ - fecOcRegIprMode &= (~(FEC_OC_IPR_MODE_SERIAL__M)); - if (state->m_enableParallel == false) { + fec_oc_reg_ipr_mode &= (~(FEC_OC_IPR_MODE_SERIAL__M)); + if (state->m_enable_parallel == false) { /* MPEG data output is serial -> set ipr_mode[0] */ - fecOcRegIprMode |= FEC_OC_IPR_MODE_SERIAL__M; + fec_oc_reg_ipr_mode |= FEC_OC_IPR_MODE_SERIAL__M; } - switch (oMode) { + switch (o_mode) { case OM_DVBT: - maxBitRate = state->m_DVBTBitrate; - fecOcTmdMode = 3; - fecOcRcnCtlRate = 0xC00000; - staticCLK = state->m_DVBTStaticCLK; + max_bit_rate = state->m_dvbt_bitrate; + fec_oc_tmd_mode = 3; + fec_oc_rcn_ctl_rate = 0xC00000; + static_clk = state->m_dvbt_static_clk; break; case OM_QAM_ITU_A: /* fallthrough */ case OM_QAM_ITU_C: - fecOcTmdMode = 0x0004; - fecOcRcnCtlRate = 0xD2B4EE; /* good for >63 Mb/s */ - maxBitRate = state->m_DVBCBitrate; - staticCLK = state->m_DVBCStaticCLK; + fec_oc_tmd_mode = 0x0004; + fec_oc_rcn_ctl_rate = 0xD2B4EE; /* good for >63 Mb/s */ + max_bit_rate = state->m_dvbc_bitrate; + static_clk = state->m_dvbc_static_clk; break; default: status = -EINVAL; @@ -2022,83 +2022,83 @@ static int MPEGTSDtoSetup(struct drxk_state *state, goto error; /* Configure DTO's */ - if (staticCLK) { - u32 bitRate = 0; + if (static_clk) { + u32 bit_rate = 0; /* Rational DTO for MCLK source (static MCLK rate), Dynamic DTO for optimal grouping (avoid intra-packet gaps), DTO offset enable to sync TS burst with MSTRT */ - fecOcDtoMode = (FEC_OC_DTO_MODE_DYNAMIC__M | + fec_oc_dto_mode = (FEC_OC_DTO_MODE_DYNAMIC__M | FEC_OC_DTO_MODE_OFFSET_ENABLE__M); - fecOcFctMode = (FEC_OC_FCT_MODE_RAT_ENA__M | + fec_oc_fct_mode = (FEC_OC_FCT_MODE_RAT_ENA__M | FEC_OC_FCT_MODE_VIRT_ENA__M); /* Check user defined bitrate */ - bitRate = maxBitRate; - if (bitRate > 75900000UL) { /* max is 75.9 Mb/s */ - bitRate = 75900000UL; + bit_rate = max_bit_rate; + if (bit_rate > 75900000UL) { /* max is 75.9 Mb/s */ + bit_rate = 75900000UL; } /* Rational DTO period: dto_period = (Fsys / bitrate) - 2 - Result should be floored, + result should be floored, to make sure >= requested bitrate */ - fecOcDtoPeriod = (u16) (((state->m_sysClockFreq) - * 1000) / bitRate); - if (fecOcDtoPeriod <= 2) - fecOcDtoPeriod = 0; + fec_oc_dto_period = (u16) (((state->m_sys_clock_freq) + * 1000) / bit_rate); + if (fec_oc_dto_period <= 2) + fec_oc_dto_period = 0; else - fecOcDtoPeriod -= 2; - fecOcTmdIntUpdRate = 8; + fec_oc_dto_period -= 2; + fec_oc_tmd_int_upd_rate = 8; } else { - /* (commonAttr->staticCLK == false) => dynamic mode */ - fecOcDtoMode = FEC_OC_DTO_MODE_DYNAMIC__M; - fecOcFctMode = FEC_OC_FCT_MODE__PRE; - fecOcTmdIntUpdRate = 5; + /* (commonAttr->static_clk == false) => dynamic mode */ + fec_oc_dto_mode = FEC_OC_DTO_MODE_DYNAMIC__M; + fec_oc_fct_mode = FEC_OC_FCT_MODE__PRE; + fec_oc_tmd_int_upd_rate = 5; } /* Write appropriate registers with requested configuration */ - status = write16(state, FEC_OC_DTO_BURST_LEN__A, fecOcDtoBurstLen); + status = write16(state, FEC_OC_DTO_BURST_LEN__A, fec_oc_dto_burst_len); if (status < 0) goto error; - status = write16(state, FEC_OC_DTO_PERIOD__A, fecOcDtoPeriod); + status = write16(state, FEC_OC_DTO_PERIOD__A, fec_oc_dto_period); if (status < 0) goto error; - status = write16(state, FEC_OC_DTO_MODE__A, fecOcDtoMode); + status = write16(state, FEC_OC_DTO_MODE__A, fec_oc_dto_mode); if (status < 0) goto error; - status = write16(state, FEC_OC_FCT_MODE__A, fecOcFctMode); + status = write16(state, FEC_OC_FCT_MODE__A, fec_oc_fct_mode); if (status < 0) goto error; - status = write16(state, FEC_OC_MODE__A, fecOcRegMode); + status = write16(state, FEC_OC_MODE__A, fec_oc_reg_mode); if (status < 0) goto error; - status = write16(state, FEC_OC_IPR_MODE__A, fecOcRegIprMode); + status = write16(state, FEC_OC_IPR_MODE__A, fec_oc_reg_ipr_mode); if (status < 0) goto error; /* Rate integration settings */ - status = write32(state, FEC_OC_RCN_CTL_RATE_LO__A, fecOcRcnCtlRate); + status = write32(state, FEC_OC_RCN_CTL_RATE_LO__A, fec_oc_rcn_ctl_rate); if (status < 0) goto error; - status = write16(state, FEC_OC_TMD_INT_UPD_RATE__A, fecOcTmdIntUpdRate); + status = write16(state, FEC_OC_TMD_INT_UPD_RATE__A, fec_oc_tmd_int_upd_rate); if (status < 0) goto error; - status = write16(state, FEC_OC_TMD_MODE__A, fecOcTmdMode); + status = write16(state, FEC_OC_TMD_MODE__A, fec_oc_tmd_mode); error: if (status < 0) printk(KERN_ERR "drxk: Error %d on %s\n", status, __func__); return status; } -static int MPEGTSConfigurePolarity(struct drxk_state *state) +static int mpegts_configure_polarity(struct drxk_state *state) { - u16 fecOcRegIprInvert = 0; + u16 fec_oc_reg_ipr_invert = 0; /* Data mask for the output data byte */ - u16 InvertDataMask = + u16 invert_data_mask = FEC_OC_IPR_INVERT_MD7__M | FEC_OC_IPR_INVERT_MD6__M | FEC_OC_IPR_INVERT_MD5__M | FEC_OC_IPR_INVERT_MD4__M | FEC_OC_IPR_INVERT_MD3__M | FEC_OC_IPR_INVERT_MD2__M | @@ -2107,40 +2107,40 @@ static int MPEGTSConfigurePolarity(struct drxk_state *state) dprintk(1, "\n"); /* Control selective inversion of output bits */ - fecOcRegIprInvert &= (~(InvertDataMask)); - if (state->m_invertDATA == true) - fecOcRegIprInvert |= InvertDataMask; - fecOcRegIprInvert &= (~(FEC_OC_IPR_INVERT_MERR__M)); - if (state->m_invertERR == true) - fecOcRegIprInvert |= FEC_OC_IPR_INVERT_MERR__M; - fecOcRegIprInvert &= (~(FEC_OC_IPR_INVERT_MSTRT__M)); - if (state->m_invertSTR == true) - fecOcRegIprInvert |= FEC_OC_IPR_INVERT_MSTRT__M; - fecOcRegIprInvert &= (~(FEC_OC_IPR_INVERT_MVAL__M)); - if (state->m_invertVAL == true) - fecOcRegIprInvert |= FEC_OC_IPR_INVERT_MVAL__M; - fecOcRegIprInvert &= (~(FEC_OC_IPR_INVERT_MCLK__M)); - if (state->m_invertCLK == true) - fecOcRegIprInvert |= FEC_OC_IPR_INVERT_MCLK__M; + fec_oc_reg_ipr_invert &= (~(invert_data_mask)); + if (state->m_invert_data == true) + fec_oc_reg_ipr_invert |= invert_data_mask; + fec_oc_reg_ipr_invert &= (~(FEC_OC_IPR_INVERT_MERR__M)); + if (state->m_invert_err == true) + fec_oc_reg_ipr_invert |= FEC_OC_IPR_INVERT_MERR__M; + fec_oc_reg_ipr_invert &= (~(FEC_OC_IPR_INVERT_MSTRT__M)); + if (state->m_invert_str == true) + fec_oc_reg_ipr_invert |= FEC_OC_IPR_INVERT_MSTRT__M; + fec_oc_reg_ipr_invert &= (~(FEC_OC_IPR_INVERT_MVAL__M)); + if (state->m_invert_val == true) + fec_oc_reg_ipr_invert |= FEC_OC_IPR_INVERT_MVAL__M; + fec_oc_reg_ipr_invert &= (~(FEC_OC_IPR_INVERT_MCLK__M)); + if (state->m_invert_clk == true) + fec_oc_reg_ipr_invert |= FEC_OC_IPR_INVERT_MCLK__M; - return write16(state, FEC_OC_IPR_INVERT__A, fecOcRegIprInvert); + return write16(state, FEC_OC_IPR_INVERT__A, fec_oc_reg_ipr_invert); } #define SCU_RAM_AGC_KI_INV_RF_POL__M 0x4000 -static int SetAgcRf(struct drxk_state *state, - struct SCfgAgc *pAgcCfg, bool isDTV) +static int set_agc_rf(struct drxk_state *state, + struct s_cfg_agc *p_agc_cfg, bool is_dtv) { int status = -EINVAL; u16 data = 0; - struct SCfgAgc *pIfAgcSettings; + struct s_cfg_agc *p_if_agc_settings; dprintk(1, "\n"); - if (pAgcCfg == NULL) + if (p_agc_cfg == NULL) goto error; - switch (pAgcCfg->ctrlMode) { + switch (p_agc_cfg->ctrl_mode) { case DRXK_AGC_CTRL_AUTO: /* Enable RF AGC DAC */ status = read16(state, IQM_AF_STDBY__A, &data); @@ -2158,7 +2158,7 @@ static int SetAgcRf(struct drxk_state *state, data &= ~SCU_RAM_AGC_CONFIG_DISABLE_RF_AGC__M; /* Polarity */ - if (state->m_RfAgcPol) + if (state->m_rf_agc_pol) data |= SCU_RAM_AGC_CONFIG_INV_RF_POL__M; else data &= ~SCU_RAM_AGC_CONFIG_INV_RF_POL__M; @@ -2172,7 +2172,7 @@ static int SetAgcRf(struct drxk_state *state, goto error; data &= ~SCU_RAM_AGC_KI_RED_RAGC_RED__M; - data |= (~(pAgcCfg->speed << + data |= (~(p_agc_cfg->speed << SCU_RAM_AGC_KI_RED_RAGC_RED__B) & SCU_RAM_AGC_KI_RED_RAGC_RED__M); @@ -2180,30 +2180,30 @@ static int SetAgcRf(struct drxk_state *state, if (status < 0) goto error; - if (IsDVBT(state)) - pIfAgcSettings = &state->m_dvbtIfAgcCfg; - else if (IsQAM(state)) - pIfAgcSettings = &state->m_qamIfAgcCfg; + if (is_dvbt(state)) + p_if_agc_settings = &state->m_dvbt_if_agc_cfg; + else if (is_qam(state)) + p_if_agc_settings = &state->m_qam_if_agc_cfg; else - pIfAgcSettings = &state->m_atvIfAgcCfg; - if (pIfAgcSettings == NULL) { + p_if_agc_settings = &state->m_atv_if_agc_cfg; + if (p_if_agc_settings == NULL) { status = -EINVAL; goto error; } /* Set TOP, only if IF-AGC is in AUTO mode */ - if (pIfAgcSettings->ctrlMode == DRXK_AGC_CTRL_AUTO) - status = write16(state, SCU_RAM_AGC_IF_IACCU_HI_TGT_MAX__A, pAgcCfg->top); + if (p_if_agc_settings->ctrl_mode == DRXK_AGC_CTRL_AUTO) + status = write16(state, SCU_RAM_AGC_IF_IACCU_HI_TGT_MAX__A, p_agc_cfg->top); if (status < 0) goto error; /* Cut-Off current */ - status = write16(state, SCU_RAM_AGC_RF_IACCU_HI_CO__A, pAgcCfg->cutOffCurrent); + status = write16(state, SCU_RAM_AGC_RF_IACCU_HI_CO__A, p_agc_cfg->cut_off_current); if (status < 0) goto error; /* Max. output level */ - status = write16(state, SCU_RAM_AGC_RF_MAX__A, pAgcCfg->maxOutputLevel); + status = write16(state, SCU_RAM_AGC_RF_MAX__A, p_agc_cfg->max_output_level); if (status < 0) goto error; @@ -2224,7 +2224,7 @@ static int SetAgcRf(struct drxk_state *state, if (status < 0) goto error; data |= SCU_RAM_AGC_CONFIG_DISABLE_RF_AGC__M; - if (state->m_RfAgcPol) + if (state->m_rf_agc_pol) data |= SCU_RAM_AGC_CONFIG_INV_RF_POL__M; else data &= ~SCU_RAM_AGC_CONFIG_INV_RF_POL__M; @@ -2238,7 +2238,7 @@ static int SetAgcRf(struct drxk_state *state, goto error; /* Write value to output pin */ - status = write16(state, SCU_RAM_AGC_RF_IACCU_HI__A, pAgcCfg->outputLevel); + status = write16(state, SCU_RAM_AGC_RF_IACCU_HI__A, p_agc_cfg->output_level); if (status < 0) goto error; break; @@ -2275,16 +2275,16 @@ error: #define SCU_RAM_AGC_KI_INV_IF_POL__M 0x2000 -static int SetAgcIf(struct drxk_state *state, - struct SCfgAgc *pAgcCfg, bool isDTV) +static int set_agc_if(struct drxk_state *state, + struct s_cfg_agc *p_agc_cfg, bool is_dtv) { u16 data = 0; int status = 0; - struct SCfgAgc *pRfAgcSettings; + struct s_cfg_agc *p_rf_agc_settings; dprintk(1, "\n"); - switch (pAgcCfg->ctrlMode) { + switch (p_agc_cfg->ctrl_mode) { case DRXK_AGC_CTRL_AUTO: /* Enable IF AGC DAC */ @@ -2304,7 +2304,7 @@ static int SetAgcIf(struct drxk_state *state, data &= ~SCU_RAM_AGC_CONFIG_DISABLE_IF_AGC__M; /* Polarity */ - if (state->m_IfAgcPol) + if (state->m_if_agc_pol) data |= SCU_RAM_AGC_CONFIG_INV_IF_POL__M; else data &= ~SCU_RAM_AGC_CONFIG_INV_IF_POL__M; @@ -2317,7 +2317,7 @@ static int SetAgcIf(struct drxk_state *state, if (status < 0) goto error; data &= ~SCU_RAM_AGC_KI_RED_IAGC_RED__M; - data |= (~(pAgcCfg->speed << + data |= (~(p_agc_cfg->speed << SCU_RAM_AGC_KI_RED_IAGC_RED__B) & SCU_RAM_AGC_KI_RED_IAGC_RED__M); @@ -2325,14 +2325,14 @@ static int SetAgcIf(struct drxk_state *state, if (status < 0) goto error; - if (IsQAM(state)) - pRfAgcSettings = &state->m_qamRfAgcCfg; + if (is_qam(state)) + p_rf_agc_settings = &state->m_qam_rf_agc_cfg; else - pRfAgcSettings = &state->m_atvRfAgcCfg; - if (pRfAgcSettings == NULL) + p_rf_agc_settings = &state->m_atv_rf_agc_cfg; + if (p_rf_agc_settings == NULL) return -1; /* Restore TOP */ - status = write16(state, SCU_RAM_AGC_IF_IACCU_HI_TGT_MAX__A, pRfAgcSettings->top); + status = write16(state, SCU_RAM_AGC_IF_IACCU_HI_TGT_MAX__A, p_rf_agc_settings->top); if (status < 0) goto error; break; @@ -2356,7 +2356,7 @@ static int SetAgcIf(struct drxk_state *state, data |= SCU_RAM_AGC_CONFIG_DISABLE_IF_AGC__M; /* Polarity */ - if (state->m_IfAgcPol) + if (state->m_if_agc_pol) data |= SCU_RAM_AGC_CONFIG_INV_IF_POL__M; else data &= ~SCU_RAM_AGC_CONFIG_INV_IF_POL__M; @@ -2365,7 +2365,7 @@ static int SetAgcIf(struct drxk_state *state, goto error; /* Write value to output pin */ - status = write16(state, SCU_RAM_AGC_IF_IACCU_HI_TGT_MAX__A, pAgcCfg->outputLevel); + status = write16(state, SCU_RAM_AGC_IF_IACCU_HI_TGT_MAX__A, p_agc_cfg->output_level); if (status < 0) goto error; break; @@ -2390,33 +2390,33 @@ static int SetAgcIf(struct drxk_state *state, if (status < 0) goto error; break; - } /* switch (agcSettingsIf->ctrlMode) */ + } /* switch (agcSettingsIf->ctrl_mode) */ /* always set the top to support configurations without if-loop */ - status = write16(state, SCU_RAM_AGC_INGAIN_TGT_MIN__A, pAgcCfg->top); + status = write16(state, SCU_RAM_AGC_INGAIN_TGT_MIN__A, p_agc_cfg->top); error: if (status < 0) printk(KERN_ERR "drxk: Error %d on %s\n", status, __func__); return status; } -static int GetQAMSignalToNoise(struct drxk_state *state, - s32 *pSignalToNoise) +static int get_qam_signal_to_noise(struct drxk_state *state, + s32 *p_signal_to_noise) { int status = 0; - u16 qamSlErrPower = 0; /* accum. error between + u16 qam_sl_err_power = 0; /* accum. error between raw and sliced symbols */ - u32 qamSlSigPower = 0; /* used for MER, depends of + u32 qam_sl_sig_power = 0; /* used for MER, depends of QAM modulation */ - u32 qamSlMer = 0; /* QAM MER */ + u32 qam_sl_mer = 0; /* QAM MER */ dprintk(1, "\n"); /* MER calculation */ /* get the register value needed for MER */ - status = read16(state, QAM_SL_ERR_POWER__A, &qamSlErrPower); + status = read16(state, QAM_SL_ERR_POWER__A, &qam_sl_err_power); if (status < 0) { printk(KERN_ERR "drxk: Error %d on %s\n", status, __func__); return -EINVAL; @@ -2424,124 +2424,124 @@ static int GetQAMSignalToNoise(struct drxk_state *state, switch (state->props.modulation) { case QAM_16: - qamSlSigPower = DRXK_QAM_SL_SIG_POWER_QAM16 << 2; + qam_sl_sig_power = DRXK_QAM_SL_SIG_POWER_QAM16 << 2; break; case QAM_32: - qamSlSigPower = DRXK_QAM_SL_SIG_POWER_QAM32 << 2; + qam_sl_sig_power = DRXK_QAM_SL_SIG_POWER_QAM32 << 2; break; case QAM_64: - qamSlSigPower = DRXK_QAM_SL_SIG_POWER_QAM64 << 2; + qam_sl_sig_power = DRXK_QAM_SL_SIG_POWER_QAM64 << 2; break; case QAM_128: - qamSlSigPower = DRXK_QAM_SL_SIG_POWER_QAM128 << 2; + qam_sl_sig_power = DRXK_QAM_SL_SIG_POWER_QAM128 << 2; break; default: case QAM_256: - qamSlSigPower = DRXK_QAM_SL_SIG_POWER_QAM256 << 2; + qam_sl_sig_power = DRXK_QAM_SL_SIG_POWER_QAM256 << 2; break; } - if (qamSlErrPower > 0) { - qamSlMer = log10times100(qamSlSigPower) - - log10times100((u32) qamSlErrPower); + if (qam_sl_err_power > 0) { + qam_sl_mer = log10times100(qam_sl_sig_power) - + log10times100((u32) qam_sl_err_power); } - *pSignalToNoise = qamSlMer; + *p_signal_to_noise = qam_sl_mer; return status; } -static int GetDVBTSignalToNoise(struct drxk_state *state, - s32 *pSignalToNoise) +static int get_dvbt_signal_to_noise(struct drxk_state *state, + s32 *p_signal_to_noise) { int status; - u16 regData = 0; - u32 EqRegTdSqrErrI = 0; - u32 EqRegTdSqrErrQ = 0; - u16 EqRegTdSqrErrExp = 0; - u16 EqRegTdTpsPwrOfs = 0; - u16 EqRegTdReqSmbCnt = 0; - u32 tpsCnt = 0; - u32 SqrErrIQ = 0; + u16 reg_data = 0; + u32 eq_reg_td_sqr_err_i = 0; + u32 eq_reg_td_sqr_err_q = 0; + u16 eq_reg_td_sqr_err_exp = 0; + u16 eq_reg_td_tps_pwr_ofs = 0; + u16 eq_reg_td_req_smb_cnt = 0; + u32 tps_cnt = 0; + u32 sqr_err_iq = 0; u32 a = 0; u32 b = 0; u32 c = 0; - u32 iMER = 0; - u16 transmissionParams = 0; + u32 i_mer = 0; + u16 transmission_params = 0; dprintk(1, "\n"); - status = read16(state, OFDM_EQ_TOP_TD_TPS_PWR_OFS__A, &EqRegTdTpsPwrOfs); + status = read16(state, OFDM_EQ_TOP_TD_TPS_PWR_OFS__A, &eq_reg_td_tps_pwr_ofs); if (status < 0) goto error; - status = read16(state, OFDM_EQ_TOP_TD_REQ_SMB_CNT__A, &EqRegTdReqSmbCnt); + status = read16(state, OFDM_EQ_TOP_TD_REQ_SMB_CNT__A, &eq_reg_td_req_smb_cnt); if (status < 0) goto error; - status = read16(state, OFDM_EQ_TOP_TD_SQR_ERR_EXP__A, &EqRegTdSqrErrExp); + status = read16(state, OFDM_EQ_TOP_TD_SQR_ERR_EXP__A, &eq_reg_td_sqr_err_exp); if (status < 0) goto error; - status = read16(state, OFDM_EQ_TOP_TD_SQR_ERR_I__A, ®Data); + status = read16(state, OFDM_EQ_TOP_TD_SQR_ERR_I__A, ®_data); if (status < 0) goto error; /* Extend SQR_ERR_I operational range */ - EqRegTdSqrErrI = (u32) regData; - if ((EqRegTdSqrErrExp > 11) && - (EqRegTdSqrErrI < 0x00000FFFUL)) { - EqRegTdSqrErrI += 0x00010000UL; + eq_reg_td_sqr_err_i = (u32) reg_data; + if ((eq_reg_td_sqr_err_exp > 11) && + (eq_reg_td_sqr_err_i < 0x00000FFFUL)) { + eq_reg_td_sqr_err_i += 0x00010000UL; } - status = read16(state, OFDM_EQ_TOP_TD_SQR_ERR_Q__A, ®Data); + status = read16(state, OFDM_EQ_TOP_TD_SQR_ERR_Q__A, ®_data); if (status < 0) goto error; /* Extend SQR_ERR_Q operational range */ - EqRegTdSqrErrQ = (u32) regData; - if ((EqRegTdSqrErrExp > 11) && - (EqRegTdSqrErrQ < 0x00000FFFUL)) - EqRegTdSqrErrQ += 0x00010000UL; + eq_reg_td_sqr_err_q = (u32) reg_data; + if ((eq_reg_td_sqr_err_exp > 11) && + (eq_reg_td_sqr_err_q < 0x00000FFFUL)) + eq_reg_td_sqr_err_q += 0x00010000UL; - status = read16(state, OFDM_SC_RA_RAM_OP_PARAM__A, &transmissionParams); + status = read16(state, OFDM_SC_RA_RAM_OP_PARAM__A, &transmission_params); if (status < 0) goto error; /* Check input data for MER */ /* MER calculation (in 0.1 dB) without math.h */ - if ((EqRegTdTpsPwrOfs == 0) || (EqRegTdReqSmbCnt == 0)) - iMER = 0; - else if ((EqRegTdSqrErrI + EqRegTdSqrErrQ) == 0) { + if ((eq_reg_td_tps_pwr_ofs == 0) || (eq_reg_td_req_smb_cnt == 0)) + i_mer = 0; + else if ((eq_reg_td_sqr_err_i + eq_reg_td_sqr_err_q) == 0) { /* No error at all, this must be the HW reset value * Apparently no first measurement yet * Set MER to 0.0 */ - iMER = 0; + i_mer = 0; } else { - SqrErrIQ = (EqRegTdSqrErrI + EqRegTdSqrErrQ) << - EqRegTdSqrErrExp; - if ((transmissionParams & + sqr_err_iq = (eq_reg_td_sqr_err_i + eq_reg_td_sqr_err_q) << + eq_reg_td_sqr_err_exp; + if ((transmission_params & OFDM_SC_RA_RAM_OP_PARAM_MODE__M) == OFDM_SC_RA_RAM_OP_PARAM_MODE_2K) - tpsCnt = 17; + tps_cnt = 17; else - tpsCnt = 68; + tps_cnt = 68; /* IMER = 100 * log10 (x) - where x = (EqRegTdTpsPwrOfs^2 * - EqRegTdReqSmbCnt * tpsCnt)/SqrErrIQ + where x = (eq_reg_td_tps_pwr_ofs^2 * + eq_reg_td_req_smb_cnt * tps_cnt)/sqr_err_iq => IMER = a + b -c - where a = 100 * log10 (EqRegTdTpsPwrOfs^2) - b = 100 * log10 (EqRegTdReqSmbCnt * tpsCnt) - c = 100 * log10 (SqrErrIQ) + where a = 100 * log10 (eq_reg_td_tps_pwr_ofs^2) + b = 100 * log10 (eq_reg_td_req_smb_cnt * tps_cnt) + c = 100 * log10 (sqr_err_iq) */ /* log(x) x = 9bits * 9bits->18 bits */ - a = log10times100(EqRegTdTpsPwrOfs * - EqRegTdTpsPwrOfs); + a = log10times100(eq_reg_td_tps_pwr_ofs * + eq_reg_td_tps_pwr_ofs); /* log(x) x = 16bits * 7bits->23 bits */ - b = log10times100(EqRegTdReqSmbCnt * tpsCnt); + b = log10times100(eq_reg_td_req_smb_cnt * tps_cnt); /* log(x) x = (16bits + 16bits) << 15 ->32 bits */ - c = log10times100(SqrErrIQ); + c = log10times100(sqr_err_iq); - iMER = a + b - c; + i_mer = a + b - c; } - *pSignalToNoise = iMER; + *p_signal_to_noise = i_mer; error: if (status < 0) @@ -2549,17 +2549,17 @@ error: return status; } -static int GetSignalToNoise(struct drxk_state *state, s32 *pSignalToNoise) +static int get_signal_to_noise(struct drxk_state *state, s32 *p_signal_to_noise) { dprintk(1, "\n"); - *pSignalToNoise = 0; - switch (state->m_OperationMode) { + *p_signal_to_noise = 0; + switch (state->m_operation_mode) { case OM_DVBT: - return GetDVBTSignalToNoise(state, pSignalToNoise); + return get_dvbt_signal_to_noise(state, p_signal_to_noise); case OM_QAM_ITU_A: case OM_QAM_ITU_C: - return GetQAMSignalToNoise(state, pSignalToNoise); + return get_qam_signal_to_noise(state, p_signal_to_noise); default: break; } @@ -2567,7 +2567,7 @@ static int GetSignalToNoise(struct drxk_state *state, s32 *pSignalToNoise) } #if 0 -static int GetDVBTQuality(struct drxk_state *state, s32 *pQuality) +static int get_dvbt_quality(struct drxk_state *state, s32 *p_quality) { /* SNR Values for quasi errorfree reception rom Nordig 2.2 */ int status = 0; @@ -2592,102 +2592,102 @@ static int GetDVBTQuality(struct drxk_state *state, s32 *pQuality) 225, /* 64-QAM 7/8 */ }; - *pQuality = 0; + *p_quality = 0; do { - s32 SignalToNoise = 0; - u16 Constellation = 0; - u16 CodeRate = 0; - u32 SignalToNoiseRel; - u32 BERQuality; + s32 signal_to_noise = 0; + u16 constellation = 0; + u16 code_rate = 0; + u32 signal_to_noise_rel; + u32 ber_quality; - status = GetDVBTSignalToNoise(state, &SignalToNoise); + status = get_dvbt_signal_to_noise(state, &signal_to_noise); if (status < 0) break; - status = read16(state, OFDM_EQ_TOP_TD_TPS_CONST__A, &Constellation); + status = read16(state, OFDM_EQ_TOP_TD_TPS_CONST__A, &constellation); if (status < 0) break; - Constellation &= OFDM_EQ_TOP_TD_TPS_CONST__M; + constellation &= OFDM_EQ_TOP_TD_TPS_CONST__M; - status = read16(state, OFDM_EQ_TOP_TD_TPS_CODE_HP__A, &CodeRate); + status = read16(state, OFDM_EQ_TOP_TD_TPS_CODE_HP__A, &code_rate); if (status < 0) break; - CodeRate &= OFDM_EQ_TOP_TD_TPS_CODE_HP__M; + code_rate &= OFDM_EQ_TOP_TD_TPS_CODE_HP__M; - if (Constellation > OFDM_EQ_TOP_TD_TPS_CONST_64QAM || - CodeRate > OFDM_EQ_TOP_TD_TPS_CODE_LP_7_8) + if (constellation > OFDM_EQ_TOP_TD_TPS_CONST_64QAM || + code_rate > OFDM_EQ_TOP_TD_TPS_CODE_LP_7_8) break; - SignalToNoiseRel = SignalToNoise - - QE_SN[Constellation * 5 + CodeRate]; - BERQuality = 100; + signal_to_noise_rel = signal_to_noise - + QE_SN[constellation * 5 + code_rate]; + ber_quality = 100; - if (SignalToNoiseRel < -70) - *pQuality = 0; - else if (SignalToNoiseRel < 30) - *pQuality = ((SignalToNoiseRel + 70) * - BERQuality) / 100; + if (signal_to_noise_rel < -70) + *p_quality = 0; + else if (signal_to_noise_rel < 30) + *p_quality = ((signal_to_noise_rel + 70) * + ber_quality) / 100; else - *pQuality = BERQuality; + *p_quality = ber_quality; } while (0); return 0; }; -static int GetDVBCQuality(struct drxk_state *state, s32 *pQuality) +static int get_dvbc_quality(struct drxk_state *state, s32 *p_quality) { int status = 0; - *pQuality = 0; + *p_quality = 0; dprintk(1, "\n"); do { - u32 SignalToNoise = 0; - u32 BERQuality = 100; - u32 SignalToNoiseRel = 0; + u32 signal_to_noise = 0; + u32 ber_quality = 100; + u32 signal_to_noise_rel = 0; - status = GetQAMSignalToNoise(state, &SignalToNoise); + status = get_qam_signal_to_noise(state, &signal_to_noise); if (status < 0) break; switch (state->props.modulation) { case QAM_16: - SignalToNoiseRel = SignalToNoise - 200; + signal_to_noise_rel = signal_to_noise - 200; break; case QAM_32: - SignalToNoiseRel = SignalToNoise - 230; + signal_to_noise_rel = signal_to_noise - 230; break; /* Not in NorDig */ case QAM_64: - SignalToNoiseRel = SignalToNoise - 260; + signal_to_noise_rel = signal_to_noise - 260; break; case QAM_128: - SignalToNoiseRel = SignalToNoise - 290; + signal_to_noise_rel = signal_to_noise - 290; break; default: case QAM_256: - SignalToNoiseRel = SignalToNoise - 320; + signal_to_noise_rel = signal_to_noise - 320; break; } - if (SignalToNoiseRel < -70) - *pQuality = 0; - else if (SignalToNoiseRel < 30) - *pQuality = ((SignalToNoiseRel + 70) * - BERQuality) / 100; + if (signal_to_noise_rel < -70) + *p_quality = 0; + else if (signal_to_noise_rel < 30) + *p_quality = ((signal_to_noise_rel + 70) * + ber_quality) / 100; else - *pQuality = BERQuality; + *p_quality = ber_quality; } while (0); return status; } -static int GetQuality(struct drxk_state *state, s32 *pQuality) +static int get_quality(struct drxk_state *state, s32 *p_quality) { dprintk(1, "\n"); - switch (state->m_OperationMode) { + switch (state->m_operation_mode) { case OM_DVBT: - return GetDVBTQuality(state, pQuality); + return get_dvbt_quality(state, p_quality); case OM_QAM_ITU_A: - return GetDVBCQuality(state, pQuality); + return get_dvbc_quality(state, p_quality); default: break; } @@ -2709,15 +2709,15 @@ static int GetQuality(struct drxk_state *state, s32 *pQuality) #define DRXDAP_FASI_ADDR2BANK(addr) (((addr) >> 16) & 0x3F) #define DRXDAP_FASI_ADDR2OFFSET(addr) ((addr) & 0x7FFF) -static int ConfigureI2CBridge(struct drxk_state *state, bool bEnableBridge) +static int ConfigureI2CBridge(struct drxk_state *state, bool b_enable_bridge) { int status = -EINVAL; dprintk(1, "\n"); - if (state->m_DrxkState == DRXK_UNINITIALIZED) + if (state->m_drxk_state == DRXK_UNINITIALIZED) return 0; - if (state->m_DrxkState == DRXK_POWERED_DOWN) + if (state->m_drxk_state == DRXK_POWERED_DOWN) goto error; if (state->no_i2c_bridge) @@ -2726,7 +2726,7 @@ static int ConfigureI2CBridge(struct drxk_state *state, bool bEnableBridge) status = write16(state, SIO_HI_RA_RAM_PAR_1__A, SIO_HI_RA_RAM_PAR_1_PAR1_SEC_KEY); if (status < 0) goto error; - if (bEnableBridge) { + if (b_enable_bridge) { status = write16(state, SIO_HI_RA_RAM_PAR_2__A, SIO_HI_RA_RAM_PAR_2_BRD_CFG_CLOSED); if (status < 0) goto error; @@ -2736,7 +2736,7 @@ static int ConfigureI2CBridge(struct drxk_state *state, bool bEnableBridge) goto error; } - status = HI_Command(state, SIO_HI_RA_RAM_CMD_BRDCTRL, 0); + status = hi_command(state, SIO_HI_RA_RAM_CMD_BRDCTRL, 0); error: if (status < 0) @@ -2744,30 +2744,30 @@ error: return status; } -static int SetPreSaw(struct drxk_state *state, - struct SCfgPreSaw *pPreSawCfg) +static int set_pre_saw(struct drxk_state *state, + struct s_cfg_pre_saw *p_pre_saw_cfg) { int status = -EINVAL; dprintk(1, "\n"); - if ((pPreSawCfg == NULL) - || (pPreSawCfg->reference > IQM_AF_PDREF__M)) + if ((p_pre_saw_cfg == NULL) + || (p_pre_saw_cfg->reference > IQM_AF_PDREF__M)) goto error; - status = write16(state, IQM_AF_PDREF__A, pPreSawCfg->reference); + status = write16(state, IQM_AF_PDREF__A, p_pre_saw_cfg->reference); error: if (status < 0) printk(KERN_ERR "drxk: Error %d on %s\n", status, __func__); return status; } -static int BLDirectCmd(struct drxk_state *state, u32 targetAddr, - u16 romOffset, u16 nrOfElements, u32 timeOut) +static int bl_direct_cmd(struct drxk_state *state, u32 target_addr, + u16 rom_offset, u16 nr_of_elements, u32 time_out) { - u16 blStatus = 0; - u16 offset = (u16) ((targetAddr >> 0) & 0x00FFFF); - u16 blockbank = (u16) ((targetAddr >> 16) & 0x000FFF); + u16 bl_status = 0; + u16 offset = (u16) ((target_addr >> 0) & 0x00FFFF); + u16 blockbank = (u16) ((target_addr >> 16) & 0x000FFF); int status; unsigned long end; @@ -2783,23 +2783,23 @@ static int BLDirectCmd(struct drxk_state *state, u32 targetAddr, status = write16(state, SIO_BL_TGT_ADDR__A, offset); if (status < 0) goto error; - status = write16(state, SIO_BL_SRC_ADDR__A, romOffset); + status = write16(state, SIO_BL_SRC_ADDR__A, rom_offset); if (status < 0) goto error; - status = write16(state, SIO_BL_SRC_LEN__A, nrOfElements); + status = write16(state, SIO_BL_SRC_LEN__A, nr_of_elements); if (status < 0) goto error; status = write16(state, SIO_BL_ENABLE__A, SIO_BL_ENABLE_ON); if (status < 0) goto error; - end = jiffies + msecs_to_jiffies(timeOut); + end = jiffies + msecs_to_jiffies(time_out); do { - status = read16(state, SIO_BL_STATUS__A, &blStatus); + status = read16(state, SIO_BL_STATUS__A, &bl_status); if (status < 0) goto error; - } while ((blStatus == 0x1) && time_is_after_jiffies(end)); - if (blStatus == 0x1) { + } while ((bl_status == 0x1) && time_is_after_jiffies(end)); + if (bl_status == 0x1) { printk(KERN_ERR "drxk: SIO not ready\n"); status = -EINVAL; goto error2; @@ -2813,14 +2813,14 @@ error2: } -static int ADCSyncMeasurement(struct drxk_state *state, u16 *count) +static int adc_sync_measurement(struct drxk_state *state, u16 *count) { u16 data = 0; int status; dprintk(1, "\n"); - /* Start measurement */ + /* start measurement */ status = write16(state, IQM_AF_COMM_EXEC__A, IQM_AF_COMM_EXEC_ACTIVE); if (status < 0) goto error; @@ -2851,38 +2851,38 @@ error: return status; } -static int ADCSynchronization(struct drxk_state *state) +static int adc_synchronization(struct drxk_state *state) { u16 count = 0; int status; dprintk(1, "\n"); - status = ADCSyncMeasurement(state, &count); + status = adc_sync_measurement(state, &count); if (status < 0) goto error; if (count == 1) { /* Try sampling on a diffrent edge */ - u16 clkNeg = 0; + u16 clk_neg = 0; - status = read16(state, IQM_AF_CLKNEG__A, &clkNeg); + status = read16(state, IQM_AF_CLKNEG__A, &clk_neg); if (status < 0) goto error; - if ((clkNeg & IQM_AF_CLKNEG_CLKNEGDATA__M) == + if ((clk_neg & IQM_AF_CLKNEG_CLKNEGDATA__M) == IQM_AF_CLKNEG_CLKNEGDATA_CLK_ADC_DATA_POS) { - clkNeg &= (~(IQM_AF_CLKNEG_CLKNEGDATA__M)); - clkNeg |= + clk_neg &= (~(IQM_AF_CLKNEG_CLKNEGDATA__M)); + clk_neg |= IQM_AF_CLKNEG_CLKNEGDATA_CLK_ADC_DATA_NEG; } else { - clkNeg &= (~(IQM_AF_CLKNEG_CLKNEGDATA__M)); - clkNeg |= + clk_neg &= (~(IQM_AF_CLKNEG_CLKNEGDATA__M)); + clk_neg |= IQM_AF_CLKNEG_CLKNEGDATA_CLK_ADC_DATA_POS; } - status = write16(state, IQM_AF_CLKNEG__A, clkNeg); + status = write16(state, IQM_AF_CLKNEG__A, clk_neg); if (status < 0) goto error; - status = ADCSyncMeasurement(state, &count); + status = adc_sync_measurement(state, &count); if (status < 0) goto error; } @@ -2895,21 +2895,21 @@ error: return status; } -static int SetFrequencyShifter(struct drxk_state *state, - u16 intermediateFreqkHz, - s32 tunerFreqOffset, bool isDTV) +static int set_frequency_shifter(struct drxk_state *state, + u16 intermediate_freqk_hz, + s32 tuner_freq_offset, bool is_dtv) { - bool selectPosImage = false; - u32 rfFreqResidual = tunerFreqOffset; - u32 fmFrequencyShift = 0; - bool tunerMirror = !state->m_bMirrorFreqSpect; - u32 adcFreq; - bool adcFlip; + bool select_pos_image = false; + u32 rf_freq_residual = tuner_freq_offset; + u32 fm_frequency_shift = 0; + bool tuner_mirror = !state->m_b_mirror_freq_spect; + u32 adc_freq; + bool adc_flip; int status; - u32 ifFreqActual; - u32 samplingFrequency = (u32) (state->m_sysClockFreq / 3); - u32 frequencyShift; - bool imageToSelect; + u32 if_freq_actual; + u32 sampling_frequency = (u32) (state->m_sys_clock_freq / 3); + u32 frequency_shift; + bool image_to_select; dprintk(1, "\n"); @@ -2917,121 +2917,121 @@ static int SetFrequencyShifter(struct drxk_state *state, Program frequency shifter No need to account for mirroring on RF */ - if (isDTV) { - if ((state->m_OperationMode == OM_QAM_ITU_A) || - (state->m_OperationMode == OM_QAM_ITU_C) || - (state->m_OperationMode == OM_DVBT)) - selectPosImage = true; + if (is_dtv) { + if ((state->m_operation_mode == OM_QAM_ITU_A) || + (state->m_operation_mode == OM_QAM_ITU_C) || + (state->m_operation_mode == OM_DVBT)) + select_pos_image = true; else - selectPosImage = false; + select_pos_image = false; } - if (tunerMirror) + if (tuner_mirror) /* tuner doesn't mirror */ - ifFreqActual = intermediateFreqkHz + - rfFreqResidual + fmFrequencyShift; + if_freq_actual = intermediate_freqk_hz + + rf_freq_residual + fm_frequency_shift; else /* tuner mirrors */ - ifFreqActual = intermediateFreqkHz - - rfFreqResidual - fmFrequencyShift; - if (ifFreqActual > samplingFrequency / 2) { + if_freq_actual = intermediate_freqk_hz - + rf_freq_residual - fm_frequency_shift; + if (if_freq_actual > sampling_frequency / 2) { /* adc mirrors */ - adcFreq = samplingFrequency - ifFreqActual; - adcFlip = true; + adc_freq = sampling_frequency - if_freq_actual; + adc_flip = true; } else { /* adc doesn't mirror */ - adcFreq = ifFreqActual; - adcFlip = false; + adc_freq = if_freq_actual; + adc_flip = false; } - frequencyShift = adcFreq; - imageToSelect = state->m_rfmirror ^ tunerMirror ^ - adcFlip ^ selectPosImage; - state->m_IqmFsRateOfs = - Frac28a((frequencyShift), samplingFrequency); + frequency_shift = adc_freq; + image_to_select = state->m_rfmirror ^ tuner_mirror ^ + adc_flip ^ select_pos_image; + state->m_iqm_fs_rate_ofs = + Frac28a((frequency_shift), sampling_frequency); - if (imageToSelect) - state->m_IqmFsRateOfs = ~state->m_IqmFsRateOfs + 1; + if (image_to_select) + state->m_iqm_fs_rate_ofs = ~state->m_iqm_fs_rate_ofs + 1; /* Program frequency shifter with tuner offset compensation */ - /* frequencyShift += tunerFreqOffset; TODO */ + /* frequency_shift += tuner_freq_offset; TODO */ status = write32(state, IQM_FS_RATE_OFS_LO__A, - state->m_IqmFsRateOfs); + state->m_iqm_fs_rate_ofs); if (status < 0) printk(KERN_ERR "drxk: Error %d on %s\n", status, __func__); return status; } -static int InitAGC(struct drxk_state *state, bool isDTV) +static int init_agc(struct drxk_state *state, bool is_dtv) { - u16 ingainTgt = 0; - u16 ingainTgtMin = 0; - u16 ingainTgtMax = 0; - u16 clpCyclen = 0; - u16 clpSumMin = 0; - u16 clpDirTo = 0; - u16 snsSumMin = 0; - u16 snsSumMax = 0; - u16 clpSumMax = 0; - u16 snsDirTo = 0; - u16 kiInnergainMin = 0; - u16 ifIaccuHiTgt = 0; - u16 ifIaccuHiTgtMin = 0; - u16 ifIaccuHiTgtMax = 0; + u16 ingain_tgt = 0; + u16 ingain_tgt_min = 0; + u16 ingain_tgt_max = 0; + u16 clp_cyclen = 0; + u16 clp_sum_min = 0; + u16 clp_dir_to = 0; + u16 sns_sum_min = 0; + u16 sns_sum_max = 0; + u16 clp_sum_max = 0; + u16 sns_dir_to = 0; + u16 ki_innergain_min = 0; + u16 if_iaccu_hi_tgt = 0; + u16 if_iaccu_hi_tgt_min = 0; + u16 if_iaccu_hi_tgt_max = 0; u16 data = 0; - u16 fastClpCtrlDelay = 0; - u16 clpCtrlMode = 0; + u16 fast_clp_ctrl_delay = 0; + u16 clp_ctrl_mode = 0; int status = 0; dprintk(1, "\n"); /* Common settings */ - snsSumMax = 1023; - ifIaccuHiTgtMin = 2047; - clpCyclen = 500; - clpSumMax = 1023; + sns_sum_max = 1023; + if_iaccu_hi_tgt_min = 2047; + clp_cyclen = 500; + clp_sum_max = 1023; /* AGCInit() not available for DVBT; init done in microcode */ - if (!IsQAM(state)) { - printk(KERN_ERR "drxk: %s: mode %d is not DVB-C\n", __func__, state->m_OperationMode); + if (!is_qam(state)) { + printk(KERN_ERR "drxk: %s: mode %d is not DVB-C\n", __func__, state->m_operation_mode); return -EINVAL; } /* FIXME: Analog TV AGC require different settings */ /* Standard specific settings */ - clpSumMin = 8; - clpDirTo = (u16) -9; - clpCtrlMode = 0; - snsSumMin = 8; - snsDirTo = (u16) -9; - kiInnergainMin = (u16) -1030; - ifIaccuHiTgtMax = 0x2380; - ifIaccuHiTgt = 0x2380; - ingainTgtMin = 0x0511; - ingainTgt = 0x0511; - ingainTgtMax = 5119; - fastClpCtrlDelay = state->m_qamIfAgcCfg.FastClipCtrlDelay; + clp_sum_min = 8; + clp_dir_to = (u16) -9; + clp_ctrl_mode = 0; + sns_sum_min = 8; + sns_dir_to = (u16) -9; + ki_innergain_min = (u16) -1030; + if_iaccu_hi_tgt_max = 0x2380; + if_iaccu_hi_tgt = 0x2380; + ingain_tgt_min = 0x0511; + ingain_tgt = 0x0511; + ingain_tgt_max = 5119; + fast_clp_ctrl_delay = state->m_qam_if_agc_cfg.fast_clip_ctrl_delay; - status = write16(state, SCU_RAM_AGC_FAST_CLP_CTRL_DELAY__A, fastClpCtrlDelay); + status = write16(state, SCU_RAM_AGC_FAST_CLP_CTRL_DELAY__A, fast_clp_ctrl_delay); if (status < 0) goto error; - status = write16(state, SCU_RAM_AGC_CLP_CTRL_MODE__A, clpCtrlMode); + status = write16(state, SCU_RAM_AGC_CLP_CTRL_MODE__A, clp_ctrl_mode); if (status < 0) goto error; - status = write16(state, SCU_RAM_AGC_INGAIN_TGT__A, ingainTgt); + status = write16(state, SCU_RAM_AGC_INGAIN_TGT__A, ingain_tgt); if (status < 0) goto error; - status = write16(state, SCU_RAM_AGC_INGAIN_TGT_MIN__A, ingainTgtMin); + status = write16(state, SCU_RAM_AGC_INGAIN_TGT_MIN__A, ingain_tgt_min); if (status < 0) goto error; - status = write16(state, SCU_RAM_AGC_INGAIN_TGT_MAX__A, ingainTgtMax); + status = write16(state, SCU_RAM_AGC_INGAIN_TGT_MAX__A, ingain_tgt_max); if (status < 0) goto error; - status = write16(state, SCU_RAM_AGC_IF_IACCU_HI_TGT_MIN__A, ifIaccuHiTgtMin); + status = write16(state, SCU_RAM_AGC_IF_IACCU_HI_TGT_MIN__A, if_iaccu_hi_tgt_min); if (status < 0) goto error; - status = write16(state, SCU_RAM_AGC_IF_IACCU_HI_TGT_MAX__A, ifIaccuHiTgtMax); + status = write16(state, SCU_RAM_AGC_IF_IACCU_HI_TGT_MAX__A, if_iaccu_hi_tgt_max); if (status < 0) goto error; status = write16(state, SCU_RAM_AGC_IF_IACCU_HI__A, 0); @@ -3046,20 +3046,20 @@ static int InitAGC(struct drxk_state *state, bool isDTV) status = write16(state, SCU_RAM_AGC_RF_IACCU_LO__A, 0); if (status < 0) goto error; - status = write16(state, SCU_RAM_AGC_CLP_SUM_MAX__A, clpSumMax); + status = write16(state, SCU_RAM_AGC_CLP_SUM_MAX__A, clp_sum_max); if (status < 0) goto error; - status = write16(state, SCU_RAM_AGC_SNS_SUM_MAX__A, snsSumMax); + status = write16(state, SCU_RAM_AGC_SNS_SUM_MAX__A, sns_sum_max); if (status < 0) goto error; - status = write16(state, SCU_RAM_AGC_KI_INNERGAIN_MIN__A, kiInnergainMin); + status = write16(state, SCU_RAM_AGC_KI_INNERGAIN_MIN__A, ki_innergain_min); if (status < 0) goto error; - status = write16(state, SCU_RAM_AGC_IF_IACCU_HI_TGT__A, ifIaccuHiTgt); + status = write16(state, SCU_RAM_AGC_IF_IACCU_HI_TGT__A, if_iaccu_hi_tgt); if (status < 0) goto error; - status = write16(state, SCU_RAM_AGC_CLP_CYCLEN__A, clpCyclen); + status = write16(state, SCU_RAM_AGC_CLP_CYCLEN__A, clp_cyclen); if (status < 0) goto error; @@ -3076,16 +3076,16 @@ static int InitAGC(struct drxk_state *state, bool isDTV) status = write16(state, SCU_RAM_AGC_KI_MAXMINGAIN_TH__A, 20); if (status < 0) goto error; - status = write16(state, SCU_RAM_AGC_CLP_SUM_MIN__A, clpSumMin); + status = write16(state, SCU_RAM_AGC_CLP_SUM_MIN__A, clp_sum_min); if (status < 0) goto error; - status = write16(state, SCU_RAM_AGC_SNS_SUM_MIN__A, snsSumMin); + status = write16(state, SCU_RAM_AGC_SNS_SUM_MIN__A, sns_sum_min); if (status < 0) goto error; - status = write16(state, SCU_RAM_AGC_CLP_DIR_TO__A, clpDirTo); + status = write16(state, SCU_RAM_AGC_CLP_DIR_TO__A, clp_dir_to); if (status < 0) goto error; - status = write16(state, SCU_RAM_AGC_SNS_DIR_TO__A, snsDirTo); + status = write16(state, SCU_RAM_AGC_SNS_DIR_TO__A, sns_dir_to); if (status < 0) goto error; status = write16(state, SCU_RAM_AGC_KI_MINGAIN__A, 0x7fff); @@ -3149,34 +3149,34 @@ error: return status; } -static int DVBTQAMGetAccPktErr(struct drxk_state *state, u16 *packetErr) +static int dvbtqam_get_acc_pkt_err(struct drxk_state *state, u16 *packet_err) { int status; dprintk(1, "\n"); - if (packetErr == NULL) + if (packet_err == NULL) status = write16(state, SCU_RAM_FEC_ACCUM_PKT_FAILURES__A, 0); else - status = read16(state, SCU_RAM_FEC_ACCUM_PKT_FAILURES__A, packetErr); + status = read16(state, SCU_RAM_FEC_ACCUM_PKT_FAILURES__A, packet_err); if (status < 0) printk(KERN_ERR "drxk: Error %d on %s\n", status, __func__); return status; } -static int DVBTScCommand(struct drxk_state *state, +static int dvbt_sc_command(struct drxk_state *state, u16 cmd, u16 subcmd, u16 param0, u16 param1, u16 param2, u16 param3, u16 param4) { - u16 curCmd = 0; - u16 errCode = 0; - u16 retryCnt = 0; - u16 scExec = 0; + u16 cur_cmd = 0; + u16 err_code = 0; + u16 retry_cnt = 0; + u16 sc_exec = 0; int status; dprintk(1, "\n"); - status = read16(state, OFDM_SC_COMM_EXEC__A, &scExec); - if (scExec != 1) { + status = read16(state, OFDM_SC_COMM_EXEC__A, &sc_exec); + if (sc_exec != 1) { /* SC is not running */ status = -EINVAL; } @@ -3184,13 +3184,13 @@ static int DVBTScCommand(struct drxk_state *state, goto error; /* Wait until sc is ready to receive command */ - retryCnt = 0; + retry_cnt = 0; do { msleep(1); - status = read16(state, OFDM_SC_RA_RAM_CMD__A, &curCmd); - retryCnt++; - } while ((curCmd != 0) && (retryCnt < DRXK_MAX_RETRIES)); - if (retryCnt >= DRXK_MAX_RETRIES && (status < 0)) + status = read16(state, OFDM_SC_RA_RAM_CMD__A, &cur_cmd); + retry_cnt++; + } while ((cur_cmd != 0) && (retry_cnt < DRXK_MAX_RETRIES)); + if (retry_cnt >= DRXK_MAX_RETRIES && (status < 0)) goto error; /* Write sub-command */ @@ -3236,18 +3236,18 @@ static int DVBTScCommand(struct drxk_state *state, goto error; /* Wait until sc is ready processing command */ - retryCnt = 0; + retry_cnt = 0; do { msleep(1); - status = read16(state, OFDM_SC_RA_RAM_CMD__A, &curCmd); - retryCnt++; - } while ((curCmd != 0) && (retryCnt < DRXK_MAX_RETRIES)); - if (retryCnt >= DRXK_MAX_RETRIES && (status < 0)) + status = read16(state, OFDM_SC_RA_RAM_CMD__A, &cur_cmd); + retry_cnt++; + } while ((cur_cmd != 0) && (retry_cnt < DRXK_MAX_RETRIES)); + if (retry_cnt >= DRXK_MAX_RETRIES && (status < 0)) goto error; /* Check for illegal cmd */ - status = read16(state, OFDM_SC_RA_RAM_CMD_ADDR__A, &errCode); - if (errCode == 0xFFFF) { + status = read16(state, OFDM_SC_RA_RAM_CMD_ADDR__A, &err_code); + if (err_code == 0xFFFF) { /* illegal command */ status = -EINVAL; } @@ -3283,19 +3283,19 @@ error: return status; } -static int PowerUpDVBT(struct drxk_state *state) +static int power_up_dvbt(struct drxk_state *state) { - enum DRXPowerMode powerMode = DRX_POWER_UP; + enum drx_power_mode power_mode = DRX_POWER_UP; int status; dprintk(1, "\n"); - status = CtrlPowerMode(state, &powerMode); + status = ctrl_power_mode(state, &power_mode); if (status < 0) printk(KERN_ERR "drxk: Error %d on %s\n", status, __func__); return status; } -static int DVBTCtrlSetIncEnable(struct drxk_state *state, bool *enabled) +static int dvbt_ctrl_set_inc_enable(struct drxk_state *state, bool *enabled) { int status; @@ -3310,7 +3310,7 @@ static int DVBTCtrlSetIncEnable(struct drxk_state *state, bool *enabled) } #define DEFAULT_FR_THRES_8K 4000 -static int DVBTCtrlSetFrEnable(struct drxk_state *state, bool *enabled) +static int dvbt_ctrl_set_fr_enable(struct drxk_state *state, bool *enabled) { int status; @@ -3330,8 +3330,8 @@ static int DVBTCtrlSetFrEnable(struct drxk_state *state, bool *enabled) return status; } -static int DVBTCtrlSetEchoThreshold(struct drxk_state *state, - struct DRXKCfgDvbtEchoThres_t *echoThres) +static int dvbt_ctrl_set_echo_threshold(struct drxk_state *state, + struct drxk_cfg_dvbt_echo_thres_t *echo_thres) { u16 data = 0; int status; @@ -3341,16 +3341,16 @@ static int DVBTCtrlSetEchoThreshold(struct drxk_state *state, if (status < 0) goto error; - switch (echoThres->fftMode) { + switch (echo_thres->fft_mode) { case DRX_FFTMODE_2K: data &= ~OFDM_SC_RA_RAM_ECHO_THRES_2K__M; - data |= ((echoThres->threshold << + data |= ((echo_thres->threshold << OFDM_SC_RA_RAM_ECHO_THRES_2K__B) & (OFDM_SC_RA_RAM_ECHO_THRES_2K__M)); break; case DRX_FFTMODE_8K: data &= ~OFDM_SC_RA_RAM_ECHO_THRES_8K__M; - data |= ((echoThres->threshold << + data |= ((echo_thres->threshold << OFDM_SC_RA_RAM_ECHO_THRES_8K__B) & (OFDM_SC_RA_RAM_ECHO_THRES_8K__M)); break; @@ -3365,8 +3365,8 @@ error: return status; } -static int DVBTCtrlSetSqiSpeed(struct drxk_state *state, - enum DRXKCfgDvbtSqiSpeed *speed) +static int dvbt_ctrl_set_sqi_speed(struct drxk_state *state, + enum drxk_cfg_dvbt_sqi_speed *speed) { int status = -EINVAL; @@ -3398,29 +3398,29 @@ error: * Called in DVBTSetStandard * */ -static int DVBTActivatePresets(struct drxk_state *state) +static int dvbt_activate_presets(struct drxk_state *state) { int status; bool setincenable = false; bool setfrenable = true; - struct DRXKCfgDvbtEchoThres_t echoThres2k = { 0, DRX_FFTMODE_2K }; - struct DRXKCfgDvbtEchoThres_t echoThres8k = { 0, DRX_FFTMODE_8K }; + struct drxk_cfg_dvbt_echo_thres_t echo_thres2k = { 0, DRX_FFTMODE_2K }; + struct drxk_cfg_dvbt_echo_thres_t echo_thres8k = { 0, DRX_FFTMODE_8K }; dprintk(1, "\n"); - status = DVBTCtrlSetIncEnable(state, &setincenable); + status = dvbt_ctrl_set_inc_enable(state, &setincenable); if (status < 0) goto error; - status = DVBTCtrlSetFrEnable(state, &setfrenable); + status = dvbt_ctrl_set_fr_enable(state, &setfrenable); if (status < 0) goto error; - status = DVBTCtrlSetEchoThreshold(state, &echoThres2k); + status = dvbt_ctrl_set_echo_threshold(state, &echo_thres2k); if (status < 0) goto error; - status = DVBTCtrlSetEchoThreshold(state, &echoThres8k); + status = dvbt_ctrl_set_echo_threshold(state, &echo_thres8k); if (status < 0) goto error; - status = write16(state, SCU_RAM_AGC_INGAIN_TGT_MAX__A, state->m_dvbtIfAgcCfg.IngainTgtMax); + status = write16(state, SCU_RAM_AGC_INGAIN_TGT_MAX__A, state->m_dvbt_if_agc_cfg.ingain_tgt_max); error: if (status < 0) printk(KERN_ERR "drxk: Error %d on %s\n", status, __func__); @@ -3437,25 +3437,25 @@ error: * For ROM code channel filter taps are loaded from the bootloader. For microcode * the DVB-T taps from the drxk_filters.h are used. */ -static int SetDVBTStandard(struct drxk_state *state, - enum OperationMode oMode) +static int set_dvbt_standard(struct drxk_state *state, + enum operation_mode o_mode) { - u16 cmdResult = 0; + u16 cmd_result = 0; u16 data = 0; int status; dprintk(1, "\n"); - PowerUpDVBT(state); + power_up_dvbt(state); /* added antenna switch */ - SwitchAntennaToDVBT(state); + switch_antenna_to_dvbt(state); /* send OFDM reset command */ - status = scu_command(state, SCU_RAM_COMMAND_STANDARD_OFDM | SCU_RAM_COMMAND_CMD_DEMOD_RESET, 0, NULL, 1, &cmdResult); + status = scu_command(state, SCU_RAM_COMMAND_STANDARD_OFDM | SCU_RAM_COMMAND_CMD_DEMOD_RESET, 0, NULL, 1, &cmd_result); if (status < 0) goto error; /* send OFDM setenv command */ - status = scu_command(state, SCU_RAM_COMMAND_STANDARD_OFDM | SCU_RAM_COMMAND_CMD_DEMOD_SET_ENV, 0, NULL, 1, &cmdResult); + status = scu_command(state, SCU_RAM_COMMAND_STANDARD_OFDM | SCU_RAM_COMMAND_CMD_DEMOD_SET_ENV, 0, NULL, 1, &cmd_result); if (status < 0) goto error; @@ -3487,7 +3487,7 @@ static int SetDVBTStandard(struct drxk_state *state, status = write16(state, IQM_AF_AMUX__A, IQM_AF_AMUX_SIGNAL2ADC); if (status < 0) goto error; - status = SetIqmAf(state, true); + status = set_iqm_af(state, true); if (status < 0) goto error; @@ -3530,7 +3530,7 @@ static int SetDVBTStandard(struct drxk_state *state, if (status < 0) goto error; - status = BLChainCmd(state, DRXK_BL_ROM_OFFSET_TAPS_DVBT, DRXK_BLCC_NR_ELEMENTS_TAPS, DRXK_BLC_TIMEOUT); + status = bl_chain_cmd(state, DRXK_BL_ROM_OFFSET_TAPS_DVBT, DRXK_BLCC_NR_ELEMENTS_TAPS, DRXK_BLC_TIMEOUT); if (status < 0) goto error; @@ -3549,10 +3549,10 @@ static int SetDVBTStandard(struct drxk_state *state, goto error; /* IQM will not be reset from here, sync ADC and update/init AGC */ - status = ADCSynchronization(state); + status = adc_synchronization(state); if (status < 0) goto error; - status = SetPreSaw(state, &state->m_dvbtPreSawCfg); + status = set_pre_saw(state, &state->m_dvbt_pre_saw_cfg); if (status < 0) goto error; @@ -3561,10 +3561,10 @@ static int SetDVBTStandard(struct drxk_state *state, if (status < 0) goto error; - status = SetAgcRf(state, &state->m_dvbtRfAgcCfg, true); + status = set_agc_rf(state, &state->m_dvbt_rf_agc_cfg, true); if (status < 0) goto error; - status = SetAgcIf(state, &state->m_dvbtIfAgcCfg, true); + status = set_agc_if(state, &state->m_dvbt_if_agc_cfg, true); if (status < 0) goto error; @@ -3582,9 +3582,9 @@ static int SetDVBTStandard(struct drxk_state *state, if (status < 0) goto error; - if (!state->m_DRXK_A3_ROM_CODE) { - /* AGCInit() is not done for DVBT, so set agcFastClipCtrlDelay */ - status = write16(state, SCU_RAM_AGC_FAST_CLP_CTRL_DELAY__A, state->m_dvbtIfAgcCfg.FastClipCtrlDelay); + if (!state->m_drxk_a3_rom_code) { + /* AGCInit() is not done for DVBT, so set agcfast_clip_ctrl_delay */ + status = write16(state, SCU_RAM_AGC_FAST_CLP_CTRL_DELAY__A, state->m_dvbt_if_agc_cfg.fast_clip_ctrl_delay); if (status < 0) goto error; } @@ -3619,11 +3619,11 @@ static int SetDVBTStandard(struct drxk_state *state, goto error; /* Setup MPEG bus */ - status = MPEGTSDtoSetup(state, OM_DVBT); + status = mpegts_dto_setup(state, OM_DVBT); if (status < 0) goto error; /* Set DVBT Presets */ - status = DVBTActivatePresets(state); + status = dvbt_activate_presets(state); if (status < 0) goto error; @@ -3635,25 +3635,25 @@ error: /*============================================================================*/ /** -* \brief Start dvbt demodulating for channel. +* \brief start dvbt demodulating for channel. * \param demod instance of demodulator. * \return DRXStatus_t. */ -static int DVBTStart(struct drxk_state *state) +static int dvbt_start(struct drxk_state *state) { u16 param1; int status; - /* DRXKOfdmScCmd_t scCmd; */ + /* drxk_ofdm_sc_cmd_t scCmd; */ dprintk(1, "\n"); - /* Start correct processes to get in lock */ + /* start correct processes to get in lock */ /* DRXK: OFDM_SC_RA_RAM_PROC_LOCKTRACK is no longer in mapfile! */ param1 = OFDM_SC_RA_RAM_LOCKTRACK_MIN; - status = DVBTScCommand(state, OFDM_SC_RA_RAM_CMD_PROC_START, 0, OFDM_SC_RA_RAM_SW_EVENT_RUN_NMASK__M, param1, 0, 0, 0); + status = dvbt_sc_command(state, OFDM_SC_RA_RAM_CMD_PROC_START, 0, OFDM_SC_RA_RAM_SW_EVENT_RUN_NMASK__M, param1, 0, 0, 0); if (status < 0) goto error; - /* Start FEC OC */ - status = MPEGTSStart(state); + /* start FEC OC */ + status = mpegts_start(state); if (status < 0) goto error; status = write16(state, FEC_COMM_EXEC__A, FEC_COMM_EXEC_ACTIVE); @@ -3674,20 +3674,20 @@ error: * \return DRXStatus_t. * // original DVBTSetChannel() */ -static int SetDVBT(struct drxk_state *state, u16 IntermediateFreqkHz, - s32 tunerFreqOffset) +static int set_dvbt(struct drxk_state *state, u16 intermediate_freqk_hz, + s32 tuner_freq_offset) { - u16 cmdResult = 0; - u16 transmissionParams = 0; - u16 operationMode = 0; - u32 iqmRcRateOfs = 0; + u16 cmd_result = 0; + u16 transmission_params = 0; + u16 operation_mode = 0; + u32 iqm_rc_rate_ofs = 0; u32 bandwidth = 0; u16 param1; int status; - dprintk(1, "IF =%d, TFO = %d\n", IntermediateFreqkHz, tunerFreqOffset); + dprintk(1, "IF =%d, TFO = %d\n", intermediate_freqk_hz, tuner_freq_offset); - status = scu_command(state, SCU_RAM_COMMAND_STANDARD_OFDM | SCU_RAM_COMMAND_CMD_DEMOD_STOP, 0, NULL, 1, &cmdResult); + status = scu_command(state, SCU_RAM_COMMAND_STANDARD_OFDM | SCU_RAM_COMMAND_CMD_DEMOD_STOP, 0, NULL, 1, &cmd_result); if (status < 0) goto error; @@ -3716,13 +3716,13 @@ static int SetDVBT(struct drxk_state *state, u16 IntermediateFreqkHz, switch (state->props.transmission_mode) { case TRANSMISSION_MODE_AUTO: default: - operationMode |= OFDM_SC_RA_RAM_OP_AUTO_MODE__M; + operation_mode |= OFDM_SC_RA_RAM_OP_AUTO_MODE__M; /* fall through , try first guess DRX_FFTMODE_8K */ case TRANSMISSION_MODE_8K: - transmissionParams |= OFDM_SC_RA_RAM_OP_PARAM_MODE_8K; + transmission_params |= OFDM_SC_RA_RAM_OP_PARAM_MODE_8K; break; case TRANSMISSION_MODE_2K: - transmissionParams |= OFDM_SC_RA_RAM_OP_PARAM_MODE_2K; + transmission_params |= OFDM_SC_RA_RAM_OP_PARAM_MODE_2K; break; } @@ -3730,19 +3730,19 @@ static int SetDVBT(struct drxk_state *state, u16 IntermediateFreqkHz, switch (state->props.guard_interval) { default: case GUARD_INTERVAL_AUTO: - operationMode |= OFDM_SC_RA_RAM_OP_AUTO_GUARD__M; + operation_mode |= OFDM_SC_RA_RAM_OP_AUTO_GUARD__M; /* fall through , try first guess DRX_GUARD_1DIV4 */ case GUARD_INTERVAL_1_4: - transmissionParams |= OFDM_SC_RA_RAM_OP_PARAM_GUARD_4; + transmission_params |= OFDM_SC_RA_RAM_OP_PARAM_GUARD_4; break; case GUARD_INTERVAL_1_32: - transmissionParams |= OFDM_SC_RA_RAM_OP_PARAM_GUARD_32; + transmission_params |= OFDM_SC_RA_RAM_OP_PARAM_GUARD_32; break; case GUARD_INTERVAL_1_16: - transmissionParams |= OFDM_SC_RA_RAM_OP_PARAM_GUARD_16; + transmission_params |= OFDM_SC_RA_RAM_OP_PARAM_GUARD_16; break; case GUARD_INTERVAL_1_8: - transmissionParams |= OFDM_SC_RA_RAM_OP_PARAM_GUARD_8; + transmission_params |= OFDM_SC_RA_RAM_OP_PARAM_GUARD_8; break; } @@ -3751,18 +3751,18 @@ static int SetDVBT(struct drxk_state *state, u16 IntermediateFreqkHz, case HIERARCHY_AUTO: case HIERARCHY_NONE: default: - operationMode |= OFDM_SC_RA_RAM_OP_AUTO_HIER__M; + operation_mode |= OFDM_SC_RA_RAM_OP_AUTO_HIER__M; /* fall through , try first guess SC_RA_RAM_OP_PARAM_HIER_NO */ - /* transmissionParams |= OFDM_SC_RA_RAM_OP_PARAM_HIER_NO; */ + /* transmission_params |= OFDM_SC_RA_RAM_OP_PARAM_HIER_NO; */ /* break; */ case HIERARCHY_1: - transmissionParams |= OFDM_SC_RA_RAM_OP_PARAM_HIER_A1; + transmission_params |= OFDM_SC_RA_RAM_OP_PARAM_HIER_A1; break; case HIERARCHY_2: - transmissionParams |= OFDM_SC_RA_RAM_OP_PARAM_HIER_A2; + transmission_params |= OFDM_SC_RA_RAM_OP_PARAM_HIER_A2; break; case HIERARCHY_4: - transmissionParams |= OFDM_SC_RA_RAM_OP_PARAM_HIER_A4; + transmission_params |= OFDM_SC_RA_RAM_OP_PARAM_HIER_A4; break; } @@ -3771,16 +3771,16 @@ static int SetDVBT(struct drxk_state *state, u16 IntermediateFreqkHz, switch (state->props.modulation) { case QAM_AUTO: default: - operationMode |= OFDM_SC_RA_RAM_OP_AUTO_CONST__M; + operation_mode |= OFDM_SC_RA_RAM_OP_AUTO_CONST__M; /* fall through , try first guess DRX_CONSTELLATION_QAM64 */ case QAM_64: - transmissionParams |= OFDM_SC_RA_RAM_OP_PARAM_CONST_QAM64; + transmission_params |= OFDM_SC_RA_RAM_OP_PARAM_CONST_QAM64; break; case QPSK: - transmissionParams |= OFDM_SC_RA_RAM_OP_PARAM_CONST_QPSK; + transmission_params |= OFDM_SC_RA_RAM_OP_PARAM_CONST_QPSK; break; case QAM_16: - transmissionParams |= OFDM_SC_RA_RAM_OP_PARAM_CONST_QAM16; + transmission_params |= OFDM_SC_RA_RAM_OP_PARAM_CONST_QAM16; break; } #if 0 @@ -3788,13 +3788,13 @@ static int SetDVBT(struct drxk_state *state, u16 IntermediateFreqkHz, /* Priority (only for hierarchical channels) */ switch (channel->priority) { case DRX_PRIORITY_LOW: - transmissionParams |= OFDM_SC_RA_RAM_OP_PARAM_PRIO_LO; - WR16(devAddr, OFDM_EC_SB_PRIOR__A, + transmission_params |= OFDM_SC_RA_RAM_OP_PARAM_PRIO_LO; + WR16(dev_addr, OFDM_EC_SB_PRIOR__A, OFDM_EC_SB_PRIOR_LO); break; case DRX_PRIORITY_HIGH: - transmissionParams |= OFDM_SC_RA_RAM_OP_PARAM_PRIO_HI; - WR16(devAddr, OFDM_EC_SB_PRIOR__A, + transmission_params |= OFDM_SC_RA_RAM_OP_PARAM_PRIO_HI; + WR16(dev_addr, OFDM_EC_SB_PRIOR__A, OFDM_EC_SB_PRIOR_HI)); break; case DRX_PRIORITY_UNKNOWN: /* fall through */ @@ -3804,7 +3804,7 @@ static int SetDVBT(struct drxk_state *state, u16 IntermediateFreqkHz, } #else /* Set Priorty high */ - transmissionParams |= OFDM_SC_RA_RAM_OP_PARAM_PRIO_HI; + transmission_params |= OFDM_SC_RA_RAM_OP_PARAM_PRIO_HI; status = write16(state, OFDM_EC_SB_PRIOR__A, OFDM_EC_SB_PRIOR_HI); if (status < 0) goto error; @@ -3814,22 +3814,22 @@ static int SetDVBT(struct drxk_state *state, u16 IntermediateFreqkHz, switch (state->props.code_rate_HP) { case FEC_AUTO: default: - operationMode |= OFDM_SC_RA_RAM_OP_AUTO_RATE__M; + operation_mode |= OFDM_SC_RA_RAM_OP_AUTO_RATE__M; /* fall through , try first guess DRX_CODERATE_2DIV3 */ case FEC_2_3: - transmissionParams |= OFDM_SC_RA_RAM_OP_PARAM_RATE_2_3; + transmission_params |= OFDM_SC_RA_RAM_OP_PARAM_RATE_2_3; break; case FEC_1_2: - transmissionParams |= OFDM_SC_RA_RAM_OP_PARAM_RATE_1_2; + transmission_params |= OFDM_SC_RA_RAM_OP_PARAM_RATE_1_2; break; case FEC_3_4: - transmissionParams |= OFDM_SC_RA_RAM_OP_PARAM_RATE_3_4; + transmission_params |= OFDM_SC_RA_RAM_OP_PARAM_RATE_3_4; break; case FEC_5_6: - transmissionParams |= OFDM_SC_RA_RAM_OP_PARAM_RATE_5_6; + transmission_params |= OFDM_SC_RA_RAM_OP_PARAM_RATE_5_6; break; case FEC_7_8: - transmissionParams |= OFDM_SC_RA_RAM_OP_PARAM_RATE_7_8; + transmission_params |= OFDM_SC_RA_RAM_OP_PARAM_RATE_7_8; break; } @@ -3906,7 +3906,7 @@ static int SetDVBT(struct drxk_state *state, u16 IntermediateFreqkHz, goto error; } - if (iqmRcRateOfs == 0) { + if (iqm_rc_rate_ofs == 0) { /* Now compute IQM_RC_RATE_OFS (((SysFreq/BandWidth)/2)/2) -1) * 2^23) => @@ -3916,36 +3916,36 @@ static int SetDVBT(struct drxk_state *state, u16 IntermediateFreqkHz, /* assert (MAX(sysClk)/MIN(bandwidth) < 16) => assert(MAX(sysClk) < 16*MIN(bandwidth)) => assert(109714272 > 48000000) = true so Frac 28 can be used */ - iqmRcRateOfs = Frac28a((u32) - ((state->m_sysClockFreq * + iqm_rc_rate_ofs = Frac28a((u32) + ((state->m_sys_clock_freq * 1000) / 3), bandwidth); /* (SysFreq / BandWidth) * (2^21), rounding before truncating */ - if ((iqmRcRateOfs & 0x7fL) >= 0x40) - iqmRcRateOfs += 0x80L; - iqmRcRateOfs = iqmRcRateOfs >> 7; + if ((iqm_rc_rate_ofs & 0x7fL) >= 0x40) + iqm_rc_rate_ofs += 0x80L; + iqm_rc_rate_ofs = iqm_rc_rate_ofs >> 7; /* ((SysFreq / BandWidth) * (2^21)) - (2^23) */ - iqmRcRateOfs = iqmRcRateOfs - (1 << 23); + iqm_rc_rate_ofs = iqm_rc_rate_ofs - (1 << 23); } - iqmRcRateOfs &= + iqm_rc_rate_ofs &= ((((u32) IQM_RC_RATE_OFS_HI__M) << IQM_RC_RATE_OFS_LO__W) | IQM_RC_RATE_OFS_LO__M); - status = write32(state, IQM_RC_RATE_OFS_LO__A, iqmRcRateOfs); + status = write32(state, IQM_RC_RATE_OFS_LO__A, iqm_rc_rate_ofs); if (status < 0) goto error; /* Bandwidth setting done */ #if 0 - status = DVBTSetFrequencyShift(demod, channel, tunerOffset); + status = dvbt_set_frequency_shift(demod, channel, tuner_offset); if (status < 0) goto error; #endif - status = SetFrequencyShifter(state, IntermediateFreqkHz, tunerFreqOffset, true); + status = set_frequency_shifter(state, intermediate_freqk_hz, tuner_freq_offset, true); if (status < 0) goto error; - /*== Start SC, write channel settings to SC ===============================*/ + /*== start SC, write channel settings to SC ===============================*/ /* Activate SCU to enable SCU commands */ status = write16(state, SCU_COMM_EXEC__A, SCU_COMM_EXEC_ACTIVE); @@ -3961,7 +3961,7 @@ static int SetDVBT(struct drxk_state *state, u16 IntermediateFreqkHz, goto error; - status = scu_command(state, SCU_RAM_COMMAND_STANDARD_OFDM | SCU_RAM_COMMAND_CMD_DEMOD_START, 0, NULL, 1, &cmdResult); + status = scu_command(state, SCU_RAM_COMMAND_STANDARD_OFDM | SCU_RAM_COMMAND_CMD_DEMOD_START, 0, NULL, 1, &cmd_result); if (status < 0) goto error; @@ -3971,13 +3971,13 @@ static int SetDVBT(struct drxk_state *state, u16 IntermediateFreqkHz, OFDM_SC_RA_RAM_OP_AUTO_CONST__M | OFDM_SC_RA_RAM_OP_AUTO_HIER__M | OFDM_SC_RA_RAM_OP_AUTO_RATE__M); - status = DVBTScCommand(state, OFDM_SC_RA_RAM_CMD_SET_PREF_PARAM, - 0, transmissionParams, param1, 0, 0, 0); + status = dvbt_sc_command(state, OFDM_SC_RA_RAM_CMD_SET_PREF_PARAM, + 0, transmission_params, param1, 0, 0, 0); if (status < 0) goto error; - if (!state->m_DRXK_A3_ROM_CODE) - status = DVBTCtrlSetSqiSpeed(state, &state->m_sqiSpeed); + if (!state->m_drxk_a3_rom_code) + status = dvbt_ctrl_set_sqi_speed(state, &state->m_sqi_speed); error: if (status < 0) printk(KERN_ERR "drxk: Error %d on %s\n", status, __func__); @@ -3995,7 +3995,7 @@ error: * \return DRXStatus_t. * */ -static int GetDVBTLockStatus(struct drxk_state *state, u32 *pLockStatus) +static int get_dvbt_lock_status(struct drxk_state *state, u32 *p_lock_status) { int status; const u16 mpeg_lock_mask = (OFDM_SC_RA_RAM_LOCK_MPEG__M | @@ -4003,32 +4003,32 @@ static int GetDVBTLockStatus(struct drxk_state *state, u32 *pLockStatus) const u16 fec_lock_mask = (OFDM_SC_RA_RAM_LOCK_FEC__M); const u16 demod_lock_mask = OFDM_SC_RA_RAM_LOCK_DEMOD__M; - u16 ScRaRamLock = 0; - u16 ScCommExec = 0; + u16 sc_ra_ram_lock = 0; + u16 sc_comm_exec = 0; dprintk(1, "\n"); - *pLockStatus = NOT_LOCKED; + *p_lock_status = NOT_LOCKED; /* driver 0.9.0 */ /* Check if SC is running */ - status = read16(state, OFDM_SC_COMM_EXEC__A, &ScCommExec); + status = read16(state, OFDM_SC_COMM_EXEC__A, &sc_comm_exec); if (status < 0) goto end; - if (ScCommExec == OFDM_SC_COMM_EXEC_STOP) + if (sc_comm_exec == OFDM_SC_COMM_EXEC_STOP) goto end; - status = read16(state, OFDM_SC_RA_RAM_LOCK__A, &ScRaRamLock); + status = read16(state, OFDM_SC_RA_RAM_LOCK__A, &sc_ra_ram_lock); if (status < 0) goto end; - if ((ScRaRamLock & mpeg_lock_mask) == mpeg_lock_mask) - *pLockStatus = MPEG_LOCK; - else if ((ScRaRamLock & fec_lock_mask) == fec_lock_mask) - *pLockStatus = FEC_LOCK; - else if ((ScRaRamLock & demod_lock_mask) == demod_lock_mask) - *pLockStatus = DEMOD_LOCK; - else if (ScRaRamLock & OFDM_SC_RA_RAM_LOCK_NODVBT__M) - *pLockStatus = NEVER_LOCK; + if ((sc_ra_ram_lock & mpeg_lock_mask) == mpeg_lock_mask) + *p_lock_status = MPEG_LOCK; + else if ((sc_ra_ram_lock & fec_lock_mask) == fec_lock_mask) + *p_lock_status = FEC_LOCK; + else if ((sc_ra_ram_lock & demod_lock_mask) == demod_lock_mask) + *p_lock_status = DEMOD_LOCK; + else if (sc_ra_ram_lock & OFDM_SC_RA_RAM_LOCK_NODVBT__M) + *p_lock_status = NEVER_LOCK; end: if (status < 0) printk(KERN_ERR "drxk: Error %d on %s\n", status, __func__); @@ -4036,13 +4036,13 @@ end: return status; } -static int PowerUpQAM(struct drxk_state *state) +static int power_up_qam(struct drxk_state *state) { - enum DRXPowerMode powerMode = DRXK_POWER_DOWN_OFDM; + enum drx_power_mode power_mode = DRXK_POWER_DOWN_OFDM; int status; dprintk(1, "\n"); - status = CtrlPowerMode(state, &powerMode); + status = ctrl_power_mode(state, &power_mode); if (status < 0) printk(KERN_ERR "drxk: Error %d on %s\n", status, __func__); @@ -4051,10 +4051,10 @@ static int PowerUpQAM(struct drxk_state *state) /** Power Down QAM */ -static int PowerDownQAM(struct drxk_state *state) +static int power_down_qam(struct drxk_state *state) { u16 data = 0; - u16 cmdResult; + u16 cmd_result; int status = 0; dprintk(1, "\n"); @@ -4070,12 +4070,12 @@ static int PowerDownQAM(struct drxk_state *state) status = write16(state, QAM_COMM_EXEC__A, QAM_COMM_EXEC_STOP); if (status < 0) goto error; - status = scu_command(state, SCU_RAM_COMMAND_STANDARD_QAM | SCU_RAM_COMMAND_CMD_DEMOD_STOP, 0, NULL, 1, &cmdResult); + status = scu_command(state, SCU_RAM_COMMAND_STANDARD_QAM | SCU_RAM_COMMAND_CMD_DEMOD_STOP, 0, NULL, 1, &cmd_result); if (status < 0) goto error; } /* powerdown AFE */ - status = SetIqmAf(state, false); + status = set_iqm_af(state, false); error: if (status < 0) @@ -4097,20 +4097,20 @@ error: * The implementation does not check this. * */ -static int SetQAMMeasurement(struct drxk_state *state, - enum EDrxkConstellation modulation, - u32 symbolRate) +static int set_qam_measurement(struct drxk_state *state, + enum e_drxk_constellation modulation, + u32 symbol_rate) { - u32 fecBitsDesired = 0; /* BER accounting period */ - u32 fecRsPeriodTotal = 0; /* Total period */ - u16 fecRsPrescale = 0; /* ReedSolomon Measurement Prescale */ - u16 fecRsPeriod = 0; /* Value for corresponding I2C register */ + u32 fec_bits_desired = 0; /* BER accounting period */ + u32 fec_rs_period_total = 0; /* Total period */ + u16 fec_rs_prescale = 0; /* ReedSolomon Measurement Prescale */ + u16 fec_rs_period = 0; /* Value for corresponding I2C register */ int status = 0; dprintk(1, "\n"); - fecRsPrescale = 1; - /* fecBitsDesired = symbolRate [kHz] * + fec_rs_prescale = 1; + /* fec_bits_desired = symbol_rate [kHz] * FrameLenght [ms] * (modulation + 1) * SyncLoss (== 1) * @@ -4118,19 +4118,19 @@ static int SetQAMMeasurement(struct drxk_state *state, */ switch (modulation) { case DRX_CONSTELLATION_QAM16: - fecBitsDesired = 4 * symbolRate; + fec_bits_desired = 4 * symbol_rate; break; case DRX_CONSTELLATION_QAM32: - fecBitsDesired = 5 * symbolRate; + fec_bits_desired = 5 * symbol_rate; break; case DRX_CONSTELLATION_QAM64: - fecBitsDesired = 6 * symbolRate; + fec_bits_desired = 6 * symbol_rate; break; case DRX_CONSTELLATION_QAM128: - fecBitsDesired = 7 * symbolRate; + fec_bits_desired = 7 * symbol_rate; break; case DRX_CONSTELLATION_QAM256: - fecBitsDesired = 8 * symbolRate; + fec_bits_desired = 8 * symbol_rate; break; default: status = -EINVAL; @@ -4138,40 +4138,40 @@ static int SetQAMMeasurement(struct drxk_state *state, if (status < 0) goto error; - fecBitsDesired /= 1000; /* symbolRate [Hz] -> symbolRate [kHz] */ - fecBitsDesired *= 500; /* meas. period [ms] */ + fec_bits_desired /= 1000; /* symbol_rate [Hz] -> symbol_rate [kHz] */ + fec_bits_desired *= 500; /* meas. period [ms] */ /* Annex A/C: bits/RsPeriod = 204 * 8 = 1632 */ - /* fecRsPeriodTotal = fecBitsDesired / 1632 */ - fecRsPeriodTotal = (fecBitsDesired / 1632UL) + 1; /* roughly ceil */ + /* fec_rs_period_total = fec_bits_desired / 1632 */ + fec_rs_period_total = (fec_bits_desired / 1632UL) + 1; /* roughly ceil */ - /* fecRsPeriodTotal = fecRsPrescale * fecRsPeriod */ - fecRsPrescale = 1 + (u16) (fecRsPeriodTotal >> 16); - if (fecRsPrescale == 0) { + /* fec_rs_period_total = fec_rs_prescale * fec_rs_period */ + fec_rs_prescale = 1 + (u16) (fec_rs_period_total >> 16); + if (fec_rs_prescale == 0) { /* Divide by zero (though impossible) */ status = -EINVAL; if (status < 0) goto error; } - fecRsPeriod = - ((u16) fecRsPeriodTotal + - (fecRsPrescale >> 1)) / fecRsPrescale; + fec_rs_period = + ((u16) fec_rs_period_total + + (fec_rs_prescale >> 1)) / fec_rs_prescale; /* write corresponding registers */ - status = write16(state, FEC_RS_MEASUREMENT_PERIOD__A, fecRsPeriod); + status = write16(state, FEC_RS_MEASUREMENT_PERIOD__A, fec_rs_period); if (status < 0) goto error; - status = write16(state, FEC_RS_MEASUREMENT_PRESCALE__A, fecRsPrescale); + status = write16(state, FEC_RS_MEASUREMENT_PRESCALE__A, fec_rs_prescale); if (status < 0) goto error; - status = write16(state, FEC_OC_SNC_FAIL_PERIOD__A, fecRsPeriod); + status = write16(state, FEC_OC_SNC_FAIL_PERIOD__A, fec_rs_period); error: if (status < 0) printk(KERN_ERR "drxk: Error %d on %s\n", status, __func__); return status; } -static int SetQAM16(struct drxk_state *state) +static int set_qam16(struct drxk_state *state) { int status = 0; @@ -4364,7 +4364,7 @@ error: * \param demod instance of demod. * \return DRXStatus_t. */ -static int SetQAM32(struct drxk_state *state) +static int set_qam32(struct drxk_state *state) { int status = 0; @@ -4559,7 +4559,7 @@ error: * \param demod instance of demod. * \return DRXStatus_t. */ -static int SetQAM64(struct drxk_state *state) +static int set_qam64(struct drxk_state *state) { int status = 0; @@ -4753,7 +4753,7 @@ error: * \param demod: instance of demod. * \return DRXStatus_t. */ -static int SetQAM128(struct drxk_state *state) +static int set_qam128(struct drxk_state *state) { int status = 0; @@ -4949,7 +4949,7 @@ error: * \param demod: instance of demod. * \return DRXStatus_t. */ -static int SetQAM256(struct drxk_state *state) +static int set_qam256(struct drxk_state *state) { int status = 0; @@ -5144,10 +5144,10 @@ error: * \param channel: pointer to channel data. * \return DRXStatus_t. */ -static int QAMResetQAM(struct drxk_state *state) +static int qam_reset_qam(struct drxk_state *state) { int status; - u16 cmdResult; + u16 cmd_result; dprintk(1, "\n"); /* Stop QAM comstate->m_exec */ @@ -5155,7 +5155,7 @@ static int QAMResetQAM(struct drxk_state *state) if (status < 0) goto error; - status = scu_command(state, SCU_RAM_COMMAND_STANDARD_QAM | SCU_RAM_COMMAND_CMD_DEMOD_RESET, 0, NULL, 1, &cmdResult); + status = scu_command(state, SCU_RAM_COMMAND_STANDARD_QAM | SCU_RAM_COMMAND_CMD_DEMOD_RESET, 0, NULL, 1, &cmd_result); error: if (status < 0) printk(KERN_ERR "drxk: Error %d on %s\n", status, __func__); @@ -5170,18 +5170,18 @@ error: * \param channel: pointer to channel data. * \return DRXStatus_t. */ -static int QAMSetSymbolrate(struct drxk_state *state) +static int qam_set_symbolrate(struct drxk_state *state) { - u32 adcFrequency = 0; - u32 symbFreq = 0; - u32 iqmRcRate = 0; + u32 adc_frequency = 0; + u32 symb_freq = 0; + u32 iqm_rc_rate = 0; u16 ratesel = 0; - u32 lcSymbRate = 0; + u32 lc_symb_rate = 0; int status; dprintk(1, "\n"); /* Select & calculate correct IQM rate */ - adcFrequency = (state->m_sysClockFreq * 1000) / 3; + adc_frequency = (state->m_sys_clock_freq * 1000) / 3; ratesel = 0; /* printk(KERN_DEBUG "drxk: SR %d\n", state->props.symbol_rate); */ if (state->props.symbol_rate <= 1188750) @@ -5197,34 +5197,34 @@ static int QAMSetSymbolrate(struct drxk_state *state) /* IqmRcRate = ((Fadc / (symbolrate * (4<props.symbol_rate * (1 << ratesel); - if (symbFreq == 0) { + symb_freq = state->props.symbol_rate * (1 << ratesel); + if (symb_freq == 0) { /* Divide by zero */ status = -EINVAL; goto error; } - iqmRcRate = (adcFrequency / symbFreq) * (1 << 21) + - (Frac28a((adcFrequency % symbFreq), symbFreq) >> 7) - + iqm_rc_rate = (adc_frequency / symb_freq) * (1 << 21) + + (Frac28a((adc_frequency % symb_freq), symb_freq) >> 7) - (1 << 23); - status = write32(state, IQM_RC_RATE_OFS_LO__A, iqmRcRate); + status = write32(state, IQM_RC_RATE_OFS_LO__A, iqm_rc_rate); if (status < 0) goto error; - state->m_iqmRcRate = iqmRcRate; + state->m_iqm_rc_rate = iqm_rc_rate; /* - LcSymbFreq = round (.125 * symbolrate / adcFreq * (1<<15)) + LcSymbFreq = round (.125 * symbolrate / adc_freq * (1<<15)) */ - symbFreq = state->props.symbol_rate; - if (adcFrequency == 0) { + symb_freq = state->props.symbol_rate; + if (adc_frequency == 0) { /* Divide by zero */ status = -EINVAL; goto error; } - lcSymbRate = (symbFreq / adcFrequency) * (1 << 12) + - (Frac28a((symbFreq % adcFrequency), adcFrequency) >> + lc_symb_rate = (symb_freq / adc_frequency) * (1 << 12) + + (Frac28a((symb_freq % adc_frequency), adc_frequency) >> 16); - if (lcSymbRate > 511) - lcSymbRate = 511; - status = write16(state, QAM_LC_SYMBOL_FREQ__A, (u16) lcSymbRate); + if (lc_symb_rate > 511) + lc_symb_rate = 511; + status = write16(state, QAM_LC_SYMBOL_FREQ__A, (u16) lc_symb_rate); error: if (status < 0) @@ -5241,34 +5241,34 @@ error: * \return DRXStatus_t. */ -static int GetQAMLockStatus(struct drxk_state *state, u32 *pLockStatus) +static int get_qam_lock_status(struct drxk_state *state, u32 *p_lock_status) { int status; - u16 Result[2] = { 0, 0 }; + u16 result[2] = { 0, 0 }; dprintk(1, "\n"); - *pLockStatus = NOT_LOCKED; + *p_lock_status = NOT_LOCKED; status = scu_command(state, SCU_RAM_COMMAND_STANDARD_QAM | SCU_RAM_COMMAND_CMD_DEMOD_GET_LOCK, 0, NULL, 2, - Result); + result); if (status < 0) printk(KERN_ERR "drxk: Error %d on %s\n", status, __func__); - if (Result[1] < SCU_RAM_QAM_LOCKED_LOCKED_DEMOD_LOCKED) { + if (result[1] < SCU_RAM_QAM_LOCKED_LOCKED_DEMOD_LOCKED) { /* 0x0000 NOT LOCKED */ - } else if (Result[1] < SCU_RAM_QAM_LOCKED_LOCKED_LOCKED) { + } else if (result[1] < SCU_RAM_QAM_LOCKED_LOCKED_LOCKED) { /* 0x4000 DEMOD LOCKED */ - *pLockStatus = DEMOD_LOCK; - } else if (Result[1] < SCU_RAM_QAM_LOCKED_LOCKED_NEVER_LOCK) { + *p_lock_status = DEMOD_LOCK; + } else if (result[1] < SCU_RAM_QAM_LOCKED_LOCKED_NEVER_LOCK) { /* 0x8000 DEMOD + FEC LOCKED (system lock) */ - *pLockStatus = MPEG_LOCK; + *p_lock_status = MPEG_LOCK; } else { /* 0xC000 NEVER LOCKED */ /* (system will never be able to lock to the signal) */ /* TODO: check this, intermediate & standard specific lock states are not taken into account here */ - *pLockStatus = NEVER_LOCK; + *p_lock_status = NEVER_LOCK; } return status; } @@ -5280,52 +5280,52 @@ static int GetQAMLockStatus(struct drxk_state *state, u32 *pLockStatus) #define QAM_LOCKRANGE__M 0x10 #define QAM_LOCKRANGE_NORMAL 0x10 -static int QAMDemodulatorCommand(struct drxk_state *state, - int numberOfParameters) +static int qam_demodulator_command(struct drxk_state *state, + int number_of_parameters) { int status; - u16 cmdResult; - u16 setParamParameters[4] = { 0, 0, 0, 0 }; + u16 cmd_result; + u16 set_param_parameters[4] = { 0, 0, 0, 0 }; - setParamParameters[0] = state->m_Constellation; /* modulation */ - setParamParameters[1] = DRXK_QAM_I12_J17; /* interleave mode */ + set_param_parameters[0] = state->m_constellation; /* modulation */ + set_param_parameters[1] = DRXK_QAM_I12_J17; /* interleave mode */ - if (numberOfParameters == 2) { - u16 setEnvParameters[1] = { 0 }; + if (number_of_parameters == 2) { + u16 set_env_parameters[1] = { 0 }; - if (state->m_OperationMode == OM_QAM_ITU_C) - setEnvParameters[0] = QAM_TOP_ANNEX_C; + if (state->m_operation_mode == OM_QAM_ITU_C) + set_env_parameters[0] = QAM_TOP_ANNEX_C; else - setEnvParameters[0] = QAM_TOP_ANNEX_A; + set_env_parameters[0] = QAM_TOP_ANNEX_A; status = scu_command(state, SCU_RAM_COMMAND_STANDARD_QAM | SCU_RAM_COMMAND_CMD_DEMOD_SET_ENV, - 1, setEnvParameters, 1, &cmdResult); + 1, set_env_parameters, 1, &cmd_result); if (status < 0) goto error; status = scu_command(state, SCU_RAM_COMMAND_STANDARD_QAM | SCU_RAM_COMMAND_CMD_DEMOD_SET_PARAM, - numberOfParameters, setParamParameters, - 1, &cmdResult); - } else if (numberOfParameters == 4) { - if (state->m_OperationMode == OM_QAM_ITU_C) - setParamParameters[2] = QAM_TOP_ANNEX_C; + number_of_parameters, set_param_parameters, + 1, &cmd_result); + } else if (number_of_parameters == 4) { + if (state->m_operation_mode == OM_QAM_ITU_C) + set_param_parameters[2] = QAM_TOP_ANNEX_C; else - setParamParameters[2] = QAM_TOP_ANNEX_A; + set_param_parameters[2] = QAM_TOP_ANNEX_A; - setParamParameters[3] |= (QAM_MIRROR_AUTO_ON); + set_param_parameters[3] |= (QAM_MIRROR_AUTO_ON); /* Env parameters */ /* check for LOCKRANGE Extented */ - /* setParamParameters[3] |= QAM_LOCKRANGE_NORMAL; */ + /* set_param_parameters[3] |= QAM_LOCKRANGE_NORMAL; */ status = scu_command(state, SCU_RAM_COMMAND_STANDARD_QAM | SCU_RAM_COMMAND_CMD_DEMOD_SET_PARAM, - numberOfParameters, setParamParameters, - 1, &cmdResult); + number_of_parameters, set_param_parameters, + 1, &cmd_result); } else { printk(KERN_WARNING "drxk: Unknown QAM demodulator parameter " - "count %d\n", numberOfParameters); + "count %d\n", number_of_parameters); status = -EINVAL; } @@ -5336,12 +5336,12 @@ error: return status; } -static int SetQAM(struct drxk_state *state, u16 IntermediateFreqkHz, - s32 tunerFreqOffset) +static int set_qam(struct drxk_state *state, u16 intermediate_freqk_hz, + s32 tuner_freq_offset) { int status; - u16 cmdResult; - int qamDemodParamCount = state->qam_demod_parameter_count; + u16 cmd_result; + int qam_demod_param_count = state->qam_demod_parameter_count; dprintk(1, "\n"); /* @@ -5356,7 +5356,7 @@ static int SetQAM(struct drxk_state *state, u16 IntermediateFreqkHz, status = write16(state, FEC_RS_COMM_EXEC__A, FEC_RS_COMM_EXEC_STOP); if (status < 0) goto error; - status = QAMResetQAM(state); + status = qam_reset_qam(state); if (status < 0) goto error; @@ -5365,27 +5365,27 @@ static int SetQAM(struct drxk_state *state, u16 IntermediateFreqkHz, * -set params; resets IQM,QAM,FEC HW; initializes some * SCU variables */ - status = QAMSetSymbolrate(state); + status = qam_set_symbolrate(state); if (status < 0) goto error; /* Set params */ switch (state->props.modulation) { case QAM_256: - state->m_Constellation = DRX_CONSTELLATION_QAM256; + state->m_constellation = DRX_CONSTELLATION_QAM256; break; case QAM_AUTO: case QAM_64: - state->m_Constellation = DRX_CONSTELLATION_QAM64; + state->m_constellation = DRX_CONSTELLATION_QAM64; break; case QAM_16: - state->m_Constellation = DRX_CONSTELLATION_QAM16; + state->m_constellation = DRX_CONSTELLATION_QAM16; break; case QAM_32: - state->m_Constellation = DRX_CONSTELLATION_QAM32; + state->m_constellation = DRX_CONSTELLATION_QAM32; break; case QAM_128: - state->m_Constellation = DRX_CONSTELLATION_QAM128; + state->m_constellation = DRX_CONSTELLATION_QAM128; break; default: status = -EINVAL; @@ -5398,8 +5398,8 @@ static int SetQAM(struct drxk_state *state, u16 IntermediateFreqkHz, * the correct command. */ if (state->qam_demod_parameter_count == 4 || !state->qam_demod_parameter_count) { - qamDemodParamCount = 4; - status = QAMDemodulatorCommand(state, qamDemodParamCount); + qam_demod_param_count = 4; + status = qam_demodulator_command(state, qam_demod_param_count); } /* Use the 2-parameter command if it was requested or if we're @@ -5407,8 +5407,8 @@ static int SetQAM(struct drxk_state *state, u16 IntermediateFreqkHz, * failed. */ if (state->qam_demod_parameter_count == 2 || (!state->qam_demod_parameter_count && status < 0)) { - qamDemodParamCount = 2; - status = QAMDemodulatorCommand(state, qamDemodParamCount); + qam_demod_param_count = 2; + status = qam_demodulator_command(state, qam_demod_param_count); } if (status < 0) { @@ -5421,13 +5421,13 @@ static int SetQAM(struct drxk_state *state, u16 IntermediateFreqkHz, } else if (!state->qam_demod_parameter_count) { dprintk(1, "Auto-probing the correct QAM demodulator command " "parameters was successful - using %d parameters.\n", - qamDemodParamCount); + qam_demod_param_count); /* * One of our commands was successful. We don't need to * auto-probe anymore, now that we got the correct command. */ - state->qam_demod_parameter_count = qamDemodParamCount; + state->qam_demod_parameter_count = qam_demod_param_count; } /* @@ -5435,16 +5435,16 @@ static int SetQAM(struct drxk_state *state, u16 IntermediateFreqkHz, * signal setup modulation independent registers */ #if 0 - status = SetFrequency(channel, tunerFreqOffset)); + status = set_frequency(channel, tuner_freq_offset)); if (status < 0) goto error; #endif - status = SetFrequencyShifter(state, IntermediateFreqkHz, tunerFreqOffset, true); + status = set_frequency_shifter(state, intermediate_freqk_hz, tuner_freq_offset, true); if (status < 0) goto error; /* Setup BER measurement */ - status = SetQAMMeasurement(state, state->m_Constellation, state->props.symbol_rate); + status = set_qam_measurement(state, state->m_constellation, state->props.symbol_rate); if (status < 0) goto error; @@ -5529,20 +5529,20 @@ static int SetQAM(struct drxk_state *state, u16 IntermediateFreqkHz, /* STEP 4: modulation specific setup */ switch (state->props.modulation) { case QAM_16: - status = SetQAM16(state); + status = set_qam16(state); break; case QAM_32: - status = SetQAM32(state); + status = set_qam32(state); break; case QAM_AUTO: case QAM_64: - status = SetQAM64(state); + status = set_qam64(state); break; case QAM_128: - status = SetQAM128(state); + status = set_qam128(state); break; case QAM_256: - status = SetQAM256(state); + status = set_qam256(state); break; default: status = -EINVAL; @@ -5559,12 +5559,12 @@ static int SetQAM(struct drxk_state *state, u16 IntermediateFreqkHz, /* Re-configure MPEG output, requires knowledge of channel bitrate */ /* extAttr->currentChannel.modulation = channel->modulation; */ /* extAttr->currentChannel.symbolrate = channel->symbolrate; */ - status = MPEGTSDtoSetup(state, state->m_OperationMode); + status = mpegts_dto_setup(state, state->m_operation_mode); if (status < 0) goto error; - /* Start processes */ - status = MPEGTSStart(state); + /* start processes */ + status = mpegts_start(state); if (status < 0) goto error; status = write16(state, FEC_COMM_EXEC__A, FEC_COMM_EXEC_ACTIVE); @@ -5578,7 +5578,7 @@ static int SetQAM(struct drxk_state *state, u16 IntermediateFreqkHz, goto error; /* STEP 5: start QAM demodulator (starts FEC, QAM and IQM HW) */ - status = scu_command(state, SCU_RAM_COMMAND_STANDARD_QAM | SCU_RAM_COMMAND_CMD_DEMOD_START, 0, NULL, 1, &cmdResult); + status = scu_command(state, SCU_RAM_COMMAND_STANDARD_QAM | SCU_RAM_COMMAND_CMD_DEMOD_START, 0, NULL, 1, &cmd_result); if (status < 0) goto error; @@ -5591,8 +5591,8 @@ error: return status; } -static int SetQAMStandard(struct drxk_state *state, - enum OperationMode oMode) +static int set_qam_standard(struct drxk_state *state, + enum operation_mode o_mode) { int status; #ifdef DRXK_QAM_TAPS @@ -5604,14 +5604,14 @@ static int SetQAMStandard(struct drxk_state *state, dprintk(1, "\n"); /* added antenna switch */ - SwitchAntennaToQAM(state); + switch_antenna_to_qam(state); /* Ensure correct power-up mode */ - status = PowerUpQAM(state); + status = power_up_qam(state); if (status < 0) goto error; /* Reset QAM block */ - status = QAMResetQAM(state); + status = qam_reset_qam(state); if (status < 0) goto error; @@ -5626,15 +5626,15 @@ static int SetQAMStandard(struct drxk_state *state, /* Upload IQM Channel Filter settings by boot loader from ROM table */ - switch (oMode) { + switch (o_mode) { case OM_QAM_ITU_A: - status = BLChainCmd(state, DRXK_BL_ROM_OFFSET_TAPS_ITU_A, DRXK_BLCC_NR_ELEMENTS_TAPS, DRXK_BLC_TIMEOUT); + status = bl_chain_cmd(state, DRXK_BL_ROM_OFFSET_TAPS_ITU_A, DRXK_BLCC_NR_ELEMENTS_TAPS, DRXK_BLC_TIMEOUT); break; case OM_QAM_ITU_C: - status = BLDirectCmd(state, IQM_CF_TAP_RE0__A, DRXK_BL_ROM_OFFSET_TAPS_ITU_C, DRXK_BLDC_NR_ELEMENTS_TAPS, DRXK_BLC_TIMEOUT); + status = bl_direct_cmd(state, IQM_CF_TAP_RE0__A, DRXK_BL_ROM_OFFSET_TAPS_ITU_C, DRXK_BLDC_NR_ELEMENTS_TAPS, DRXK_BLC_TIMEOUT); if (status < 0) goto error; - status = BLDirectCmd(state, IQM_CF_TAP_IM0__A, DRXK_BL_ROM_OFFSET_TAPS_ITU_C, DRXK_BLDC_NR_ELEMENTS_TAPS, DRXK_BLC_TIMEOUT); + status = bl_direct_cmd(state, IQM_CF_TAP_IM0__A, DRXK_BL_ROM_OFFSET_TAPS_ITU_C, DRXK_BLDC_NR_ELEMENTS_TAPS, DRXK_BLC_TIMEOUT); break; default: status = -EINVAL; @@ -5705,7 +5705,7 @@ static int SetQAMStandard(struct drxk_state *state, goto error; /* turn on IQMAF. Must be done before setAgc**() */ - status = SetIqmAf(state, true); + status = set_iqm_af(state, true); if (status < 0) goto error; status = write16(state, IQM_AF_START_LOCK__A, 0x01); @@ -5713,7 +5713,7 @@ static int SetQAMStandard(struct drxk_state *state, goto error; /* IQM will not be reset from here, sync ADC and update/init AGC */ - status = ADCSynchronization(state); + status = adc_synchronization(state); if (status < 0) goto error; @@ -5730,18 +5730,18 @@ static int SetQAMStandard(struct drxk_state *state, /* No more resets of the IQM, current standard correctly set => now AGCs can be configured. */ - status = InitAGC(state, true); + status = init_agc(state, true); if (status < 0) goto error; - status = SetPreSaw(state, &(state->m_qamPreSawCfg)); + status = set_pre_saw(state, &(state->m_qam_pre_saw_cfg)); if (status < 0) goto error; /* Configure AGC's */ - status = SetAgcRf(state, &(state->m_qamRfAgcCfg), true); + status = set_agc_rf(state, &(state->m_qam_rf_agc_cfg), true); if (status < 0) goto error; - status = SetAgcIf(state, &(state->m_qamIfAgcCfg), true); + status = set_agc_if(state, &(state->m_qam_if_agc_cfg), true); if (status < 0) goto error; @@ -5753,7 +5753,7 @@ error: return status; } -static int WriteGPIO(struct drxk_state *state) +static int write_gpio(struct drxk_state *state) { int status; u16 value = 0; @@ -5769,10 +5769,10 @@ static int WriteGPIO(struct drxk_state *state) if (status < 0) goto error; - if (state->m_hasSAWSW) { - if (state->UIO_mask & 0x0001) { /* UIO-1 */ + if (state->m_has_sawsw) { + if (state->uio_mask & 0x0001) { /* UIO-1 */ /* write to io pad configuration register - output mode */ - status = write16(state, SIO_PDR_SMA_TX_CFG__A, state->m_GPIOCfg); + status = write16(state, SIO_PDR_SMA_TX_CFG__A, state->m_gpio_cfg); if (status < 0) goto error; @@ -5780,7 +5780,7 @@ static int WriteGPIO(struct drxk_state *state) status = read16(state, SIO_PDR_UIO_OUT_LO__A, &value); if (status < 0) goto error; - if ((state->m_GPIO & 0x0001) == 0) + if ((state->m_gpio & 0x0001) == 0) value &= 0x7FFF; /* write zero to 15th bit - 1st UIO */ else value |= 0x8000; /* write one to 15th bit - 1st UIO */ @@ -5789,9 +5789,9 @@ static int WriteGPIO(struct drxk_state *state) if (status < 0) goto error; } - if (state->UIO_mask & 0x0002) { /* UIO-2 */ + if (state->uio_mask & 0x0002) { /* UIO-2 */ /* write to io pad configuration register - output mode */ - status = write16(state, SIO_PDR_SMA_RX_CFG__A, state->m_GPIOCfg); + status = write16(state, SIO_PDR_SMA_RX_CFG__A, state->m_gpio_cfg); if (status < 0) goto error; @@ -5799,7 +5799,7 @@ static int WriteGPIO(struct drxk_state *state) status = read16(state, SIO_PDR_UIO_OUT_LO__A, &value); if (status < 0) goto error; - if ((state->m_GPIO & 0x0002) == 0) + if ((state->m_gpio & 0x0002) == 0) value &= 0xBFFF; /* write zero to 14th bit - 2st UIO */ else value |= 0x4000; /* write one to 14th bit - 2st UIO */ @@ -5808,9 +5808,9 @@ static int WriteGPIO(struct drxk_state *state) if (status < 0) goto error; } - if (state->UIO_mask & 0x0004) { /* UIO-3 */ + if (state->uio_mask & 0x0004) { /* UIO-3 */ /* write to io pad configuration register - output mode */ - status = write16(state, SIO_PDR_GPIO_CFG__A, state->m_GPIOCfg); + status = write16(state, SIO_PDR_GPIO_CFG__A, state->m_gpio_cfg); if (status < 0) goto error; @@ -5818,7 +5818,7 @@ static int WriteGPIO(struct drxk_state *state) status = read16(state, SIO_PDR_UIO_OUT_LO__A, &value); if (status < 0) goto error; - if ((state->m_GPIO & 0x0004) == 0) + if ((state->m_gpio & 0x0004) == 0) value &= 0xFFFB; /* write zero to 2nd bit - 3rd UIO */ else value |= 0x0004; /* write one to 2nd bit - 3rd UIO */ @@ -5836,7 +5836,7 @@ error: return status; } -static int SwitchAntennaToQAM(struct drxk_state *state) +static int switch_antenna_to_qam(struct drxk_state *state) { int status = 0; bool gpio_state; @@ -5846,22 +5846,22 @@ static int SwitchAntennaToQAM(struct drxk_state *state) if (!state->antenna_gpio) return 0; - gpio_state = state->m_GPIO & state->antenna_gpio; + gpio_state = state->m_gpio & state->antenna_gpio; if (state->antenna_dvbt ^ gpio_state) { /* Antenna is on DVB-T mode. Switch */ if (state->antenna_dvbt) - state->m_GPIO &= ~state->antenna_gpio; + state->m_gpio &= ~state->antenna_gpio; else - state->m_GPIO |= state->antenna_gpio; - status = WriteGPIO(state); + state->m_gpio |= state->antenna_gpio; + status = write_gpio(state); } if (status < 0) printk(KERN_ERR "drxk: Error %d on %s\n", status, __func__); return status; } -static int SwitchAntennaToDVBT(struct drxk_state *state) +static int switch_antenna_to_dvbt(struct drxk_state *state) { int status = 0; bool gpio_state; @@ -5871,15 +5871,15 @@ static int SwitchAntennaToDVBT(struct drxk_state *state) if (!state->antenna_gpio) return 0; - gpio_state = state->m_GPIO & state->antenna_gpio; + gpio_state = state->m_gpio & state->antenna_gpio; if (!(state->antenna_dvbt ^ gpio_state)) { /* Antenna is on DVB-C mode. Switch */ if (state->antenna_dvbt) - state->m_GPIO |= state->antenna_gpio; + state->m_gpio |= state->antenna_gpio; else - state->m_GPIO &= ~state->antenna_gpio; - status = WriteGPIO(state); + state->m_gpio &= ~state->antenna_gpio; + status = write_gpio(state); } if (status < 0) printk(KERN_ERR "drxk: Error %d on %s\n", status, __func__); @@ -5887,7 +5887,7 @@ static int SwitchAntennaToDVBT(struct drxk_state *state) } -static int PowerDownDevice(struct drxk_state *state) +static int power_down_device(struct drxk_state *state) { /* Power down to requested mode */ /* Backup some register settings */ @@ -5898,14 +5898,14 @@ static int PowerDownDevice(struct drxk_state *state) int status; dprintk(1, "\n"); - if (state->m_bPDownOpenBridge) { + if (state->m_b_p_down_open_bridge) { /* Open I2C bridge before power down of DRXK */ status = ConfigureI2CBridge(state, true); if (status < 0) goto error; } /* driver 0.9.0 */ - status = DVBTEnableOFDMTokenRing(state, false); + status = dvbt_enable_ofdm_token_ring(state, false); if (status < 0) goto error; @@ -5915,8 +5915,8 @@ static int PowerDownDevice(struct drxk_state *state) status = write16(state, SIO_CC_UPDATE__A, SIO_CC_UPDATE_KEY); if (status < 0) goto error; - state->m_HICfgCtrl |= SIO_HI_RA_RAM_PAR_5_CFG_SLEEP_ZZZ; - status = HI_CfgCommand(state); + state->m_hi_cfg_ctrl |= SIO_HI_RA_RAM_PAR_5_CFG_SLEEP_ZZZ; + status = hi_cfg_command(state); error: if (status < 0) printk(KERN_ERR "drxk: Error %d on %s\n", status, __func__); @@ -5927,16 +5927,16 @@ error: static int init_drxk(struct drxk_state *state) { int status = 0, n = 0; - enum DRXPowerMode powerMode = DRXK_POWER_DOWN_OFDM; - u16 driverVersion; + enum drx_power_mode power_mode = DRXK_POWER_DOWN_OFDM; + u16 driver_version; dprintk(1, "\n"); - if ((state->m_DrxkState == DRXK_UNINITIALIZED)) { + if ((state->m_drxk_state == DRXK_UNINITIALIZED)) { drxk_i2c_lock(state); - status = PowerUpDevice(state); + status = power_up_device(state); if (status < 0) goto error; - status = DRXX_Open(state); + status = drxx_open(state); if (status < 0) goto error; /* Soft reset of OFDM-, sys- and osc-clockdomain */ @@ -5948,29 +5948,29 @@ static int init_drxk(struct drxk_state *state) goto error; /* TODO is this needed, if yes how much delay in worst case scenario */ msleep(1); - state->m_DRXK_A3_PATCH_CODE = true; - status = GetDeviceCapabilities(state); + state->m_drxk_a3_patch_code = true; + status = get_device_capabilities(state); if (status < 0) goto error; /* Bridge delay, uses oscilator clock */ /* Delay = (delay (nano seconds) * oscclk (kHz))/ 1000 */ /* SDA brdige delay */ - state->m_HICfgBridgeDelay = - (u16) ((state->m_oscClockFreq / 1000) * + state->m_hi_cfg_bridge_delay = + (u16) ((state->m_osc_clock_freq / 1000) * HI_I2C_BRIDGE_DELAY) / 1000; /* Clipping */ - if (state->m_HICfgBridgeDelay > + if (state->m_hi_cfg_bridge_delay > SIO_HI_RA_RAM_PAR_3_CFG_DBL_SDA__M) { - state->m_HICfgBridgeDelay = + state->m_hi_cfg_bridge_delay = SIO_HI_RA_RAM_PAR_3_CFG_DBL_SDA__M; } /* SCL bridge delay, same as SDA for now */ - state->m_HICfgBridgeDelay += - state->m_HICfgBridgeDelay << + state->m_hi_cfg_bridge_delay += + state->m_hi_cfg_bridge_delay << SIO_HI_RA_RAM_PAR_3_CFG_DBL_SCL__B; - status = InitHI(state); + status = init_hi(state); if (status < 0) goto error; /* disable various processes */ @@ -5985,7 +5985,7 @@ static int init_drxk(struct drxk_state *state) } /* disable MPEG port */ - status = MPEGTSDisable(state); + status = mpegts_disable(state); if (status < 0) goto error; @@ -6006,12 +6006,12 @@ static int init_drxk(struct drxk_state *state) status = write16(state, SIO_BL_COMM_EXEC__A, SIO_BL_COMM_EXEC_ACTIVE); if (status < 0) goto error; - status = BLChainCmd(state, 0, 6, 100); + status = bl_chain_cmd(state, 0, 6, 100); if (status < 0) goto error; if (state->fw) { - status = DownloadMicrocode(state, state->fw->data, + status = download_microcode(state, state->fw->data, state->fw->size); if (status < 0) goto error; @@ -6026,14 +6026,14 @@ static int init_drxk(struct drxk_state *state) status = write16(state, SCU_COMM_EXEC__A, SCU_COMM_EXEC_ACTIVE); if (status < 0) goto error; - status = DRXX_Open(state); + status = drxx_open(state); if (status < 0) goto error; /* added for test */ msleep(30); - powerMode = DRXK_POWER_DOWN_OFDM; - status = CtrlPowerMode(state, &powerMode); + power_mode = DRXK_POWER_DOWN_OFDM; + status = ctrl_power_mode(state, &power_mode); if (status < 0) goto error; @@ -6043,20 +6043,20 @@ static int init_drxk(struct drxk_state *state) Not using SCU command interface for SCU register access since no microcode may be present. */ - driverVersion = + driver_version = (((DRXK_VERSION_MAJOR / 100) % 10) << 12) + (((DRXK_VERSION_MAJOR / 10) % 10) << 8) + ((DRXK_VERSION_MAJOR % 10) << 4) + (DRXK_VERSION_MINOR % 10); - status = write16(state, SCU_RAM_DRIVER_VER_HI__A, driverVersion); + status = write16(state, SCU_RAM_DRIVER_VER_HI__A, driver_version); if (status < 0) goto error; - driverVersion = + driver_version = (((DRXK_VERSION_PATCH / 1000) % 10) << 12) + (((DRXK_VERSION_PATCH / 100) % 10) << 8) + (((DRXK_VERSION_PATCH / 10) % 10) << 4) + (DRXK_VERSION_PATCH % 10); - status = write16(state, SCU_RAM_DRIVER_VER_LO__A, driverVersion); + status = write16(state, SCU_RAM_DRIVER_VER_LO__A, driver_version); if (status < 0) goto error; @@ -6069,7 +6069,7 @@ static int init_drxk(struct drxk_state *state) before calling DRX_Open. This solution requires changes to RF AGC speed to be done via the CTRL function after calling DRX_Open */ - /* m_dvbtRfAgcCfg.speed = 3; */ + /* m_dvbt_rf_agc_cfg.speed = 3; */ /* Reset driver debug flags to 0 */ status = write16(state, SCU_RAM_DRIVER_DEBUG__A, 0); @@ -6082,42 +6082,42 @@ static int init_drxk(struct drxk_state *state) if (status < 0) goto error; /* MPEGTS functions are still the same */ - status = MPEGTSDtoInit(state); + status = mpegts_dto_init(state); if (status < 0) goto error; - status = MPEGTSStop(state); + status = mpegts_stop(state); if (status < 0) goto error; - status = MPEGTSConfigurePolarity(state); + status = mpegts_configure_polarity(state); if (status < 0) goto error; - status = MPEGTSConfigurePins(state, state->m_enableMPEGOutput); + status = mpegts_configure_pins(state, state->m_enable_mpeg_output); if (status < 0) goto error; /* added: configure GPIO */ - status = WriteGPIO(state); + status = write_gpio(state); if (status < 0) goto error; - state->m_DrxkState = DRXK_STOPPED; + state->m_drxk_state = DRXK_STOPPED; - if (state->m_bPowerDown) { - status = PowerDownDevice(state); + if (state->m_b_power_down) { + status = power_down_device(state); if (status < 0) goto error; - state->m_DrxkState = DRXK_POWERED_DOWN; + state->m_drxk_state = DRXK_POWERED_DOWN; } else - state->m_DrxkState = DRXK_STOPPED; + state->m_drxk_state = DRXK_STOPPED; /* Initialize the supported delivery systems */ n = 0; - if (state->m_hasDVBC) { + if (state->m_has_dvbc) { state->frontend.ops.delsys[n++] = SYS_DVBC_ANNEX_A; state->frontend.ops.delsys[n++] = SYS_DVBC_ANNEX_C; strlcat(state->frontend.ops.info.name, " DVB-C", sizeof(state->frontend.ops.info.name)); } - if (state->m_hasDVBT) { + if (state->m_has_dvbt) { state->frontend.ops.delsys[n++] = SYS_DVBT; strlcat(state->frontend.ops.info.name, " DVB-T", sizeof(state->frontend.ops.info.name)); @@ -6126,7 +6126,7 @@ static int init_drxk(struct drxk_state *state) } error: if (status < 0) { - state->m_DrxkState = DRXK_NO_DEV; + state->m_drxk_state = DRXK_NO_DEV; drxk_i2c_unlock(state); printk(KERN_ERR "drxk: Error %d on %s\n", status, __func__); } @@ -6182,12 +6182,12 @@ static int drxk_sleep(struct dvb_frontend *fe) dprintk(1, "\n"); - if (state->m_DrxkState == DRXK_NO_DEV) + if (state->m_drxk_state == DRXK_NO_DEV) return -ENODEV; - if (state->m_DrxkState == DRXK_UNINITIALIZED) + if (state->m_drxk_state == DRXK_UNINITIALIZED) return 0; - ShutDown(state); + shut_down(state); return 0; } @@ -6197,7 +6197,7 @@ static int drxk_gate_ctrl(struct dvb_frontend *fe, int enable) dprintk(1, ": %s\n", enable ? "enable" : "disable"); - if (state->m_DrxkState == DRXK_NO_DEV) + if (state->m_drxk_state == DRXK_NO_DEV) return -ENODEV; return ConfigureI2CBridge(state, enable ? true : false); @@ -6212,10 +6212,10 @@ static int drxk_set_parameters(struct dvb_frontend *fe) dprintk(1, "\n"); - if (state->m_DrxkState == DRXK_NO_DEV) + if (state->m_drxk_state == DRXK_NO_DEV) return -ENODEV; - if (state->m_DrxkState == DRXK_UNINITIALIZED) + if (state->m_drxk_state == DRXK_UNINITIALIZED) return -EAGAIN; if (!fe->ops.tuner_ops.get_if_frequency) { @@ -6235,22 +6235,22 @@ static int drxk_set_parameters(struct dvb_frontend *fe) state->props = *p; if (old_delsys != delsys) { - ShutDown(state); + shut_down(state); switch (delsys) { case SYS_DVBC_ANNEX_A: case SYS_DVBC_ANNEX_C: - if (!state->m_hasDVBC) + if (!state->m_has_dvbc) return -EINVAL; state->m_itut_annex_c = (delsys == SYS_DVBC_ANNEX_C) ? true : false; if (state->m_itut_annex_c) - SetOperationMode(state, OM_QAM_ITU_C); + setoperation_mode(state, OM_QAM_ITU_C); else - SetOperationMode(state, OM_QAM_ITU_A); + setoperation_mode(state, OM_QAM_ITU_A); break; case SYS_DVBT: - if (!state->m_hasDVBT) + if (!state->m_has_dvbt) return -EINVAL; - SetOperationMode(state, OM_DVBT); + setoperation_mode(state, OM_DVBT); break; default: return -EINVAL; @@ -6258,7 +6258,7 @@ static int drxk_set_parameters(struct dvb_frontend *fe) } fe->ops.tuner_ops.get_if_frequency(fe, &IF); - Start(state, 0, IF); + start(state, 0, IF); /* After set_frontend, stats aren't avaliable */ p->strength.stat[0].scale = FE_SCALE_RELATIVE; @@ -6278,31 +6278,31 @@ static int drxk_set_parameters(struct dvb_frontend *fe) static int get_strength(struct drxk_state *state, u64 *strength) { int status; - struct SCfgAgc rfAgc, ifAgc; - u32 totalGain = 0; + struct s_cfg_agc rf_agc, if_agc; + u32 total_gain = 0; u32 atten = 0; - u32 agcRange = 0; + u32 agc_range = 0; u16 scu_lvl = 0; u16 scu_coc = 0; /* FIXME: those are part of the tuner presets */ - u16 tunerRfGain = 50; /* Default value on az6007 driver */ - u16 tunerIfGain = 40; /* Default value on az6007 driver */ + u16 tuner_rf_gain = 50; /* Default value on az6007 driver */ + u16 tuner_if_gain = 40; /* Default value on az6007 driver */ *strength = 0; - if (IsDVBT(state)) { - rfAgc = state->m_dvbtRfAgcCfg; - ifAgc = state->m_dvbtIfAgcCfg; - } else if (IsQAM(state)) { - rfAgc = state->m_qamRfAgcCfg; - ifAgc = state->m_qamIfAgcCfg; + if (is_dvbt(state)) { + rf_agc = state->m_dvbt_rf_agc_cfg; + if_agc = state->m_dvbt_if_agc_cfg; + } else if (is_qam(state)) { + rf_agc = state->m_qam_rf_agc_cfg; + if_agc = state->m_qam_if_agc_cfg; } else { - rfAgc = state->m_atvRfAgcCfg; - ifAgc = state->m_atvIfAgcCfg; + rf_agc = state->m_atv_rf_agc_cfg; + if_agc = state->m_atv_if_agc_cfg; } - if (rfAgc.ctrlMode == DRXK_AGC_CTRL_AUTO) { - /* SCU outputLevel */ + if (rf_agc.ctrl_mode == DRXK_AGC_CTRL_AUTO) { + /* SCU output_level */ status = read16(state, SCU_RAM_AGC_RF_IACCU_HI__A, &scu_lvl); if (status < 0) return status; @@ -6313,54 +6313,54 @@ static int get_strength(struct drxk_state *state, u64 *strength) return status; if (((u32) scu_lvl + (u32) scu_coc) < 0xffff) - rfAgc.outputLevel = scu_lvl + scu_coc; + rf_agc.output_level = scu_lvl + scu_coc; else - rfAgc.outputLevel = 0xffff; + rf_agc.output_level = 0xffff; /* Take RF gain into account */ - totalGain += tunerRfGain; + total_gain += tuner_rf_gain; /* clip output value */ - if (rfAgc.outputLevel < rfAgc.minOutputLevel) - rfAgc.outputLevel = rfAgc.minOutputLevel; - if (rfAgc.outputLevel > rfAgc.maxOutputLevel) - rfAgc.outputLevel = rfAgc.maxOutputLevel; + if (rf_agc.output_level < rf_agc.min_output_level) + rf_agc.output_level = rf_agc.min_output_level; + if (rf_agc.output_level > rf_agc.max_output_level) + rf_agc.output_level = rf_agc.max_output_level; - agcRange = (u32) (rfAgc.maxOutputLevel - rfAgc.minOutputLevel); - if (agcRange > 0) { + agc_range = (u32) (rf_agc.max_output_level - rf_agc.min_output_level); + if (agc_range > 0) { atten += 100UL * - ((u32)(tunerRfGain)) * - ((u32)(rfAgc.outputLevel - rfAgc.minOutputLevel)) - / agcRange; + ((u32)(tuner_rf_gain)) * + ((u32)(rf_agc.output_level - rf_agc.min_output_level)) + / agc_range; } } - if (ifAgc.ctrlMode == DRXK_AGC_CTRL_AUTO) { + if (if_agc.ctrl_mode == DRXK_AGC_CTRL_AUTO) { status = read16(state, SCU_RAM_AGC_IF_IACCU_HI__A, - &ifAgc.outputLevel); + &if_agc.output_level); if (status < 0) return status; status = read16(state, SCU_RAM_AGC_INGAIN_TGT_MIN__A, - &ifAgc.top); + &if_agc.top); if (status < 0) return status; /* Take IF gain into account */ - totalGain += (u32) tunerIfGain; + total_gain += (u32) tuner_if_gain; /* clip output value */ - if (ifAgc.outputLevel < ifAgc.minOutputLevel) - ifAgc.outputLevel = ifAgc.minOutputLevel; - if (ifAgc.outputLevel > ifAgc.maxOutputLevel) - ifAgc.outputLevel = ifAgc.maxOutputLevel; + if (if_agc.output_level < if_agc.min_output_level) + if_agc.output_level = if_agc.min_output_level; + if (if_agc.output_level > if_agc.max_output_level) + if_agc.output_level = if_agc.max_output_level; - agcRange = (u32) (ifAgc.maxOutputLevel - ifAgc.minOutputLevel); - if (agcRange > 0) { + agc_range = (u32) (if_agc.max_output_level - if_agc.min_output_level); + if (agc_range > 0) { atten += 100UL * - ((u32)(tunerIfGain)) * - ((u32)(ifAgc.outputLevel - ifAgc.minOutputLevel)) - / agcRange; + ((u32)(tuner_if_gain)) * + ((u32)(if_agc.output_level - if_agc.min_output_level)) + / agc_range; } } @@ -6368,8 +6368,8 @@ static int get_strength(struct drxk_state *state, u64 *strength) * Convert to 0..65535 scale. * If it can't be measured (AGC is disabled), just show 100%. */ - if (totalGain > 0) - *strength = (65535UL * atten / totalGain / 100); + if (total_gain > 0) + *strength = (65535UL * atten / total_gain / 100); else *strength = 65535; @@ -6392,14 +6392,14 @@ static int drxk_get_stats(struct dvb_frontend *fe) u32 pkt_error_count; s32 cnr; - if (state->m_DrxkState == DRXK_NO_DEV) + if (state->m_drxk_state == DRXK_NO_DEV) return -ENODEV; - if (state->m_DrxkState == DRXK_UNINITIALIZED) + if (state->m_drxk_state == DRXK_UNINITIALIZED) return -EAGAIN; /* get status */ state->fe_status = 0; - GetLockStatus(state, &stat); + get_lock_status(state, &stat); if (stat == MPEG_LOCK) state->fe_status |= 0x1f; if (stat == FEC_LOCK) @@ -6415,7 +6415,7 @@ static int drxk_get_stats(struct dvb_frontend *fe) if (stat >= DEMOD_LOCK) { - GetSignalToNoise(state, &cnr); + get_signal_to_noise(state, &cnr); c->cnr.stat[0].svalue = cnr * 100; c->cnr.stat[0].scale = FE_SCALE_DECIBEL; } else { @@ -6522,9 +6522,9 @@ static int drxk_read_signal_strength(struct dvb_frontend *fe, dprintk(1, "\n"); - if (state->m_DrxkState == DRXK_NO_DEV) + if (state->m_drxk_state == DRXK_NO_DEV) return -ENODEV; - if (state->m_DrxkState == DRXK_UNINITIALIZED) + if (state->m_drxk_state == DRXK_UNINITIALIZED) return -EAGAIN; *strength = c->strength.stat[0].uvalue; @@ -6538,12 +6538,12 @@ static int drxk_read_snr(struct dvb_frontend *fe, u16 *snr) dprintk(1, "\n"); - if (state->m_DrxkState == DRXK_NO_DEV) + if (state->m_drxk_state == DRXK_NO_DEV) return -ENODEV; - if (state->m_DrxkState == DRXK_UNINITIALIZED) + if (state->m_drxk_state == DRXK_UNINITIALIZED) return -EAGAIN; - GetSignalToNoise(state, &snr2); + get_signal_to_noise(state, &snr2); /* No negative SNR, clip to zero */ if (snr2 < 0) @@ -6559,12 +6559,12 @@ static int drxk_read_ucblocks(struct dvb_frontend *fe, u32 *ucblocks) dprintk(1, "\n"); - if (state->m_DrxkState == DRXK_NO_DEV) + if (state->m_drxk_state == DRXK_NO_DEV) return -ENODEV; - if (state->m_DrxkState == DRXK_UNINITIALIZED) + if (state->m_drxk_state == DRXK_UNINITIALIZED) return -EAGAIN; - DVBTQAMGetAccPktErr(state, &err); + dvbtqam_get_acc_pkt_err(state, &err); *ucblocks = (u32) err; return 0; } @@ -6577,9 +6577,9 @@ static int drxk_get_tune_settings(struct dvb_frontend *fe, struct dvb_frontend_t dprintk(1, "\n"); - if (state->m_DrxkState == DRXK_NO_DEV) + if (state->m_drxk_state == DRXK_NO_DEV) return -ENODEV; - if (state->m_DrxkState == DRXK_UNINITIALIZED) + if (state->m_drxk_state == DRXK_UNINITIALIZED) return -EAGAIN; switch (p->delivery_system) { @@ -6649,36 +6649,36 @@ struct dvb_frontend *drxk_attach(const struct drxk_config *config, state->no_i2c_bridge = config->no_i2c_bridge; state->antenna_gpio = config->antenna_gpio; state->antenna_dvbt = config->antenna_dvbt; - state->m_ChunkSize = config->chunk_size; + state->m_chunk_size = config->chunk_size; state->enable_merr_cfg = config->enable_merr_cfg; if (config->dynamic_clk) { - state->m_DVBTStaticCLK = 0; - state->m_DVBCStaticCLK = 0; + state->m_dvbt_static_clk = 0; + state->m_dvbc_static_clk = 0; } else { - state->m_DVBTStaticCLK = 1; - state->m_DVBCStaticCLK = 1; + state->m_dvbt_static_clk = 1; + state->m_dvbc_static_clk = 1; } if (config->mpeg_out_clk_strength) - state->m_TSClockkStrength = config->mpeg_out_clk_strength & 0x07; + state->m_ts_clockk_strength = config->mpeg_out_clk_strength & 0x07; else - state->m_TSClockkStrength = 0x06; + state->m_ts_clockk_strength = 0x06; if (config->parallel_ts) - state->m_enableParallel = true; + state->m_enable_parallel = true; else - state->m_enableParallel = false; + state->m_enable_parallel = false; /* NOTE: as more UIO bits will be used, add them to the mask */ - state->UIO_mask = config->antenna_gpio; + state->uio_mask = config->antenna_gpio; /* Default gpio to DVB-C */ if (!state->antenna_dvbt && state->antenna_gpio) - state->m_GPIO |= state->antenna_gpio; + state->m_gpio |= state->antenna_gpio; else - state->m_GPIO &= ~state->antenna_gpio; + state->m_gpio &= ~state->antenna_gpio; mutex_init(&state->mutex); diff --git a/drivers/media/dvb-frontends/drxk_hard.h b/drivers/media/dvb-frontends/drxk_hard.h index b8424f15f9a6..db87a6d75720 100644 --- a/drivers/media/dvb-frontends/drxk_hard.h +++ b/drivers/media/dvb-frontends/drxk_hard.h @@ -46,7 +46,7 @@ #define IQM_RC_ADJ_SEL_B_QAM 0x1 #define IQM_RC_ADJ_SEL_B_VSB 0x2 -enum OperationMode { +enum operation_mode { OM_NONE, OM_QAM_ITU_A, OM_QAM_ITU_B, @@ -54,7 +54,7 @@ enum OperationMode { OM_DVBT }; -enum DRXPowerMode { +enum drx_power_mode { DRX_POWER_UP = 0, DRX_POWER_MODE_1, DRX_POWER_MODE_2, @@ -93,8 +93,8 @@ enum DRXPowerMode { #endif -enum AGC_CTRL_MODE { DRXK_AGC_CTRL_AUTO = 0, DRXK_AGC_CTRL_USER, DRXK_AGC_CTRL_OFF }; -enum EDrxkState { +enum agc_ctrl_mode { DRXK_AGC_CTRL_AUTO = 0, DRXK_AGC_CTRL_USER, DRXK_AGC_CTRL_OFF }; +enum e_drxk_state { DRXK_UNINITIALIZED = 0, DRXK_STOPPED, DRXK_DTV_STARTED, @@ -103,7 +103,7 @@ enum EDrxkState { DRXK_NO_DEV /* If drxk init failed */ }; -enum EDrxkCoefArrayIndex { +enum e_drxk_coef_array_index { DRXK_COEF_IDX_MN = 0, DRXK_COEF_IDX_FM , DRXK_COEF_IDX_L , @@ -113,13 +113,13 @@ enum EDrxkCoefArrayIndex { DRXK_COEF_IDX_I , DRXK_COEF_IDX_MAX }; -enum EDrxkSifAttenuation { +enum e_drxk_sif_attenuation { DRXK_SIF_ATTENUATION_0DB, DRXK_SIF_ATTENUATION_3DB, DRXK_SIF_ATTENUATION_6DB, DRXK_SIF_ATTENUATION_9DB }; -enum EDrxkConstellation { +enum e_drxk_constellation { DRX_CONSTELLATION_BPSK = 0, DRX_CONSTELLATION_QPSK, DRX_CONSTELLATION_PSK8, @@ -133,7 +133,7 @@ enum EDrxkConstellation { DRX_CONSTELLATION_UNKNOWN = DRX_UNKNOWN, DRX_CONSTELLATION_AUTO = DRX_AUTO }; -enum EDrxkInterleaveMode { +enum e_drxk_interleave_mode { DRXK_QAM_I12_J17 = 16, DRXK_QAM_I_UNKNOWN = DRX_UNKNOWN }; @@ -144,14 +144,14 @@ enum { DRXK_SPIN_UNKNOWN }; -enum DRXKCfgDvbtSqiSpeed { +enum drxk_cfg_dvbt_sqi_speed { DRXK_DVBT_SQI_SPEED_FAST = 0, DRXK_DVBT_SQI_SPEED_MEDIUM, DRXK_DVBT_SQI_SPEED_SLOW, DRXK_DVBT_SQI_SPEED_UNKNOWN = DRX_UNKNOWN } ; -enum DRXFftmode_t { +enum drx_fftmode_t { DRX_FFTMODE_2K = 0, DRX_FFTMODE_4K, DRX_FFTMODE_8K, @@ -159,40 +159,40 @@ enum DRXFftmode_t { DRX_FFTMODE_AUTO = DRX_AUTO }; -enum DRXMPEGStrWidth_t { +enum drxmpeg_str_width_t { DRX_MPEG_STR_WIDTH_1, DRX_MPEG_STR_WIDTH_8 }; -enum DRXQamLockRange_t { +enum drx_qam_lock_range_t { DRX_QAM_LOCKRANGE_NORMAL, DRX_QAM_LOCKRANGE_EXTENDED }; -struct DRXKCfgDvbtEchoThres_t { +struct drxk_cfg_dvbt_echo_thres_t { u16 threshold; - enum DRXFftmode_t fftMode; + enum drx_fftmode_t fft_mode; } ; -struct SCfgAgc { - enum AGC_CTRL_MODE ctrlMode; /* off, user, auto */ - u16 outputLevel; /* range dependent on AGC */ - u16 minOutputLevel; /* range dependent on AGC */ - u16 maxOutputLevel; /* range dependent on AGC */ +struct s_cfg_agc { + enum agc_ctrl_mode ctrl_mode; /* off, user, auto */ + u16 output_level; /* range dependent on AGC */ + u16 min_output_level; /* range dependent on AGC */ + u16 max_output_level; /* range dependent on AGC */ u16 speed; /* range dependent on AGC */ u16 top; /* rf-agc take over point */ - u16 cutOffCurrent; /* rf-agc is accelerated if output current + u16 cut_off_current; /* rf-agc is accelerated if output current is below cut-off current */ - u16 IngainTgtMax; - u16 FastClipCtrlDelay; + u16 ingain_tgt_max; + u16 fast_clip_ctrl_delay; }; -struct SCfgPreSaw { +struct s_cfg_pre_saw { u16 reference; /* pre SAW reference value, range 0 .. 31 */ - bool usePreSaw; /* TRUE algorithms must use pre SAW sense */ + bool use_pre_saw; /* TRUE algorithms must use pre SAW sense */ }; -struct DRXKOfdmScCmd_t { +struct drxk_ofdm_sc_cmd_t { u16 cmd; /**< Command number */ u16 subcmd; /**< Sub-command parameter*/ u16 param0; /**< General purpous param */ @@ -213,121 +213,121 @@ struct drxk_state { struct mutex mutex; - u32 m_Instance; /**< Channel 1,2,3 or 4 */ + u32 m_instance; /**< Channel 1,2,3 or 4 */ - int m_ChunkSize; - u8 Chunk[256]; + int m_chunk_size; + u8 chunk[256]; - bool m_hasLNA; - bool m_hasDVBT; - bool m_hasDVBC; - bool m_hasAudio; - bool m_hasATV; - bool m_hasOOB; - bool m_hasSAWSW; /**< TRUE if mat_tx is available */ - bool m_hasGPIO1; /**< TRUE if mat_rx is available */ - bool m_hasGPIO2; /**< TRUE if GPIO is available */ - bool m_hasIRQN; /**< TRUE if IRQN is available */ - u16 m_oscClockFreq; - u16 m_HICfgTimingDiv; - u16 m_HICfgBridgeDelay; - u16 m_HICfgWakeUpKey; - u16 m_HICfgTimeout; - u16 m_HICfgCtrl; - s32 m_sysClockFreq; /**< system clock frequency in kHz */ + bool m_has_lna; + bool m_has_dvbt; + bool m_has_dvbc; + bool m_has_audio; + bool m_has_atv; + bool m_has_oob; + bool m_has_sawsw; /* TRUE if mat_tx is available */ + bool m_has_gpio1; /* TRUE if mat_rx is available */ + bool m_has_gpio2; /* TRUE if GPIO is available */ + bool m_has_irqn; /* TRUE if IRQN is available */ + u16 m_osc_clock_freq; + u16 m_hi_cfg_timing_div; + u16 m_hi_cfg_bridge_delay; + u16 m_hi_cfg_wake_up_key; + u16 m_hi_cfg_timeout; + u16 m_hi_cfg_ctrl; + s32 m_sys_clock_freq; /**< system clock frequency in kHz */ - enum EDrxkState m_DrxkState; /**< State of Drxk (init,stopped,started) */ - enum OperationMode m_OperationMode; /**< digital standards */ - struct SCfgAgc m_vsbRfAgcCfg; /**< settings for VSB RF-AGC */ - struct SCfgAgc m_vsbIfAgcCfg; /**< settings for VSB IF-AGC */ - u16 m_vsbPgaCfg; /**< settings for VSB PGA */ - struct SCfgPreSaw m_vsbPreSawCfg; /**< settings for pre SAW sense */ + enum e_drxk_state m_drxk_state; /**< State of Drxk (init,stopped,started) */ + enum operation_mode m_operation_mode; /**< digital standards */ + struct s_cfg_agc m_vsb_rf_agc_cfg; /**< settings for VSB RF-AGC */ + struct s_cfg_agc m_vsb_if_agc_cfg; /**< settings for VSB IF-AGC */ + u16 m_vsb_pga_cfg; /**< settings for VSB PGA */ + struct s_cfg_pre_saw m_vsb_pre_saw_cfg; /**< settings for pre SAW sense */ s32 m_Quality83percent; /**< MER level (*0.1 dB) for 83% quality indication */ s32 m_Quality93percent; /**< MER level (*0.1 dB) for 93% quality indication */ - bool m_smartAntInverted; - bool m_bDebugEnableBridge; - bool m_bPDownOpenBridge; /**< only open DRXK bridge before power-down once it has been accessed */ - bool m_bPowerDown; /**< Power down when not used */ + bool m_smart_ant_inverted; + bool m_b_debug_enable_bridge; + bool m_b_p_down_open_bridge; /**< only open DRXK bridge before power-down once it has been accessed */ + bool m_b_power_down; /**< Power down when not used */ - u32 m_IqmFsRateOfs; /**< frequency shift as written to DRXK register (28bit fixpoint) */ + u32 m_iqm_fs_rate_ofs; /**< frequency shift as written to DRXK register (28bit fixpoint) */ - bool m_enableMPEGOutput; /**< If TRUE, enable MPEG output */ - bool m_insertRSByte; /**< If TRUE, insert RS byte */ - bool m_enableParallel; /**< If TRUE, parallel out otherwise serial */ - bool m_invertDATA; /**< If TRUE, invert DATA signals */ - bool m_invertERR; /**< If TRUE, invert ERR signal */ - bool m_invertSTR; /**< If TRUE, invert STR signals */ - bool m_invertVAL; /**< If TRUE, invert VAL signals */ - bool m_invertCLK; /**< If TRUE, invert CLK signals */ - bool m_DVBCStaticCLK; - bool m_DVBTStaticCLK; /**< If TRUE, static MPEG clockrate will + bool m_enable_mpeg_output; /**< If TRUE, enable MPEG output */ + bool m_insert_rs_byte; /**< If TRUE, insert RS byte */ + bool m_enable_parallel; /**< If TRUE, parallel out otherwise serial */ + bool m_invert_data; /**< If TRUE, invert DATA signals */ + bool m_invert_err; /**< If TRUE, invert ERR signal */ + bool m_invert_str; /**< If TRUE, invert STR signals */ + bool m_invert_val; /**< If TRUE, invert VAL signals */ + bool m_invert_clk; /**< If TRUE, invert CLK signals */ + bool m_dvbc_static_clk; + bool m_dvbt_static_clk; /**< If TRUE, static MPEG clockrate will be used, otherwise clockrate will adapt to the bitrate of the TS */ - u32 m_DVBTBitrate; - u32 m_DVBCBitrate; + u32 m_dvbt_bitrate; + u32 m_dvbc_bitrate; - u8 m_TSDataStrength; - u8 m_TSClockkStrength; + u8 m_ts_data_strength; + u8 m_ts_clockk_strength; bool m_itut_annex_c; /* If true, uses ITU-T DVB-C Annex C, instead of Annex A */ - enum DRXMPEGStrWidth_t m_widthSTR; /**< MPEG start width */ - u32 m_mpegTsStaticBitrate; /**< Maximum bitrate in b/s in case + enum drxmpeg_str_width_t m_width_str; /**< MPEG start width */ + u32 m_mpeg_ts_static_bitrate; /**< Maximum bitrate in b/s in case static clockrate is selected */ - /* LARGE_INTEGER m_StartTime; */ /**< Contains the time of the last demod start */ - s32 m_MpegLockTimeOut; /**< WaitForLockStatus Timeout (counts from start time) */ - s32 m_DemodLockTimeOut; /**< WaitForLockStatus Timeout (counts from start time) */ + /* LARGE_INTEGER m_startTime; */ /**< Contains the time of the last demod start */ + s32 m_mpeg_lock_time_out; /**< WaitForLockStatus Timeout (counts from start time) */ + s32 m_demod_lock_time_out; /**< WaitForLockStatus Timeout (counts from start time) */ - bool m_disableTEIhandling; + bool m_disable_te_ihandling; - bool m_RfAgcPol; - bool m_IfAgcPol; + bool m_rf_agc_pol; + bool m_if_agc_pol; - struct SCfgAgc m_atvRfAgcCfg; /**< settings for ATV RF-AGC */ - struct SCfgAgc m_atvIfAgcCfg; /**< settings for ATV IF-AGC */ - struct SCfgPreSaw m_atvPreSawCfg; /**< settings for ATV pre SAW sense */ - bool m_phaseCorrectionBypass; - s16 m_atvTopVidPeak; - u16 m_atvTopNoiseTh; - enum EDrxkSifAttenuation m_sifAttenuation; - bool m_enableCVBSOutput; - bool m_enableSIFOutput; - bool m_bMirrorFreqSpect; - enum EDrxkConstellation m_Constellation; /**< Constellation type of the channel */ - u32 m_CurrSymbolRate; /**< Current QAM symbol rate */ - struct SCfgAgc m_qamRfAgcCfg; /**< settings for QAM RF-AGC */ - struct SCfgAgc m_qamIfAgcCfg; /**< settings for QAM IF-AGC */ - u16 m_qamPgaCfg; /**< settings for QAM PGA */ - struct SCfgPreSaw m_qamPreSawCfg; /**< settings for QAM pre SAW sense */ - enum EDrxkInterleaveMode m_qamInterleaveMode; /**< QAM Interleave mode */ - u16 m_fecRsPlen; - u16 m_fecRsPrescale; + struct s_cfg_agc m_atv_rf_agc_cfg; /**< settings for ATV RF-AGC */ + struct s_cfg_agc m_atv_if_agc_cfg; /**< settings for ATV IF-AGC */ + struct s_cfg_pre_saw m_atv_pre_saw_cfg; /**< settings for ATV pre SAW sense */ + bool m_phase_correction_bypass; + s16 m_atv_top_vid_peak; + u16 m_atv_top_noise_th; + enum e_drxk_sif_attenuation m_sif_attenuation; + bool m_enable_cvbs_output; + bool m_enable_sif_output; + bool m_b_mirror_freq_spect; + enum e_drxk_constellation m_constellation; /**< constellation type of the channel */ + u32 m_curr_symbol_rate; /**< Current QAM symbol rate */ + struct s_cfg_agc m_qam_rf_agc_cfg; /**< settings for QAM RF-AGC */ + struct s_cfg_agc m_qam_if_agc_cfg; /**< settings for QAM IF-AGC */ + u16 m_qam_pga_cfg; /**< settings for QAM PGA */ + struct s_cfg_pre_saw m_qam_pre_saw_cfg; /**< settings for QAM pre SAW sense */ + enum e_drxk_interleave_mode m_qam_interleave_mode; /**< QAM Interleave mode */ + u16 m_fec_rs_plen; + u16 m_fec_rs_prescale; - enum DRXKCfgDvbtSqiSpeed m_sqiSpeed; + enum drxk_cfg_dvbt_sqi_speed m_sqi_speed; - u16 m_GPIO; - u16 m_GPIOCfg; + u16 m_gpio; + u16 m_gpio_cfg; - struct SCfgAgc m_dvbtRfAgcCfg; /**< settings for QAM RF-AGC */ - struct SCfgAgc m_dvbtIfAgcCfg; /**< settings for QAM IF-AGC */ - struct SCfgPreSaw m_dvbtPreSawCfg; /**< settings for QAM pre SAW sense */ + struct s_cfg_agc m_dvbt_rf_agc_cfg; /**< settings for QAM RF-AGC */ + struct s_cfg_agc m_dvbt_if_agc_cfg; /**< settings for QAM IF-AGC */ + struct s_cfg_pre_saw m_dvbt_pre_saw_cfg; /**< settings for QAM pre SAW sense */ - u16 m_agcFastClipCtrlDelay; - bool m_adcCompPassed; + u16 m_agcfast_clip_ctrl_delay; + bool m_adc_comp_passed; u16 m_adcCompCoef[64]; - u16 m_adcState; + u16 m_adc_state; u8 *m_microcode; int m_microcode_length; - bool m_DRXK_A3_ROM_CODE; - bool m_DRXK_A3_PATCH_CODE; + bool m_drxk_a3_rom_code; + bool m_drxk_a3_patch_code; bool m_rfmirror; - u8 m_deviceSpin; - u32 m_iqmRcRate; + u8 m_device_spin; + u32 m_iqm_rc_rate; - enum DRXPowerMode m_currentPowerMode; + enum drx_power_mode m_current_power_mode; /* when true, avoids other devices to use the I2C bus */ bool drxk_i2c_exclusive_lock; @@ -337,7 +337,7 @@ struct drxk_state { * at struct drxk_config. */ - u16 UIO_mask; /* Bits used by UIO */ + u16 uio_mask; /* Bits used by UIO */ bool enable_merr_cfg; bool single_master; From 3a4398f58c0a7b70b7debe36fd95cf37e9b2c0a1 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Sun, 28 Apr 2013 11:47:45 -0300 Subject: [PATCH 0113/1048] [media] drxk_hard: use pr_info/pr_warn/pr_err/... macros X-Patchwork-Delegate: mchehab@redhat.com replace all occurrences of printk(KERN_* by pr_info/pr_warn/pr_err/pr_debug/pr_cont macros. Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb-frontends/drxk_hard.c | 182 ++++++++++++------------ 1 file changed, 89 insertions(+), 93 deletions(-) diff --git a/drivers/media/dvb-frontends/drxk_hard.c b/drivers/media/dvb-frontends/drxk_hard.c index d2b331a46a6d..552bce5d8f92 100644 --- a/drivers/media/dvb-frontends/drxk_hard.c +++ b/drivers/media/dvb-frontends/drxk_hard.c @@ -21,6 +21,8 @@ * Or, point your browser to http://www.gnu.org/copyleft/gpl.html */ +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + #include #include #include @@ -264,7 +266,7 @@ static int i2c_write(struct drxk_state *state, u8 adr, u8 *data, int len) status = -EIO; if (status < 0) - printk(KERN_ERR "drxk: i2c write error at addr 0x%02x\n", adr); + pr_err("i2c write error at addr 0x%02x\n", adr); return status; } @@ -287,7 +289,7 @@ static int i2c_read(struct drxk_state *state, if (status >= 0) status = -EIO; - printk(KERN_ERR "drxk: i2c read error at addr 0x%02x\n", adr); + pr_err("i2c read error at addr 0x%02x\n", adr); return status; } if (debug > 2) { @@ -474,7 +476,7 @@ static int write_block(struct drxk_state *state, u32 address, status = i2c_write(state, state->demod_address, &state->chunk[0], chunk + adr_length); if (status < 0) { - printk(KERN_ERR "drxk: %s: i2c write error at addr 0x%02x\n", + pr_err("%s: i2c write error at addr 0x%02x\n", __func__, address); break; } @@ -531,7 +533,7 @@ static int power_up_device(struct drxk_state *state) error: if (status < 0) - printk(KERN_ERR "drxk: Error %d on %s\n", status, __func__); + pr_err("Error %d on %s\n", status, __func__); return status; } @@ -800,7 +802,7 @@ static int drxx_open(struct drxk_state *state) status = write16(state, SIO_TOP_COMM_KEY__A, key); error: if (status < 0) - printk(KERN_ERR "drxk: Error %d on %s\n", status, __func__); + pr_err("Error %d on %s\n", status, __func__); return status; } @@ -845,7 +847,7 @@ static int get_device_capabilities(struct drxk_state *state) state->m_osc_clock_freq = 20250; break; default: - printk(KERN_ERR "drxk: Clock Frequency is unknown\n"); + pr_err("Clock Frequency is unknown\n"); return -EINVAL; } /* @@ -856,7 +858,7 @@ static int get_device_capabilities(struct drxk_state *state) if (status < 0) goto error; - printk(KERN_INFO "drxk: status = 0x%08x\n", sio_top_jtagid_lo); + pr_info("status = 0x%08x\n", sio_top_jtagid_lo); /* driver 0.9.0 */ switch ((sio_top_jtagid_lo >> 29) & 0xF) { @@ -875,8 +877,7 @@ static int get_device_capabilities(struct drxk_state *state) default: state->m_device_spin = DRXK_SPIN_UNKNOWN; status = -EINVAL; - printk(KERN_ERR "drxk: Spin %d unknown\n", - (sio_top_jtagid_lo >> 29) & 0xF); + pr_err("Spin %d unknown\n", (sio_top_jtagid_lo >> 29) & 0xF); goto error2; } switch ((sio_top_jtagid_lo >> 12) & 0xFF) { @@ -985,21 +986,20 @@ static int get_device_capabilities(struct drxk_state *state) state->m_has_irqn = false; break; default: - printk(KERN_ERR "drxk: DeviceID 0x%02x not supported\n", + pr_err("DeviceID 0x%02x not supported\n", ((sio_top_jtagid_lo >> 12) & 0xFF)); status = -EINVAL; goto error2; } - printk(KERN_INFO - "drxk: detected a drx-39%02xk, spin %s, xtal %d.%03d MHz\n", + pr_info("detected a drx-39%02xk, spin %s, xtal %d.%03d MHz\n", ((sio_top_jtagid_lo >> 12) & 0xFF), spin, state->m_osc_clock_freq / 1000, state->m_osc_clock_freq % 1000); error: if (status < 0) - printk(KERN_ERR "drxk: Error %d on %s\n", status, __func__); + pr_err("Error %d on %s\n", status, __func__); error2: return status; @@ -1042,7 +1042,7 @@ static int hi_command(struct drxk_state *state, u16 cmd, u16 *p_result) } error: if (status < 0) - printk(KERN_ERR "drxk: Error %d on %s\n", status, __func__); + pr_err("Error %d on %s\n", status, __func__); return status; } @@ -1081,7 +1081,7 @@ static int hi_cfg_command(struct drxk_state *state) error: mutex_unlock(&state->mutex); if (status < 0) - printk(KERN_ERR "drxk: Error %d on %s\n", status, __func__); + pr_err("Error %d on %s\n", status, __func__); return status; } @@ -1244,7 +1244,7 @@ static int mpegts_configure_pins(struct drxk_state *state, bool mpeg_enable) status = write16(state, SIO_TOP_COMM_KEY__A, 0x0000); error: if (status < 0) - printk(KERN_ERR "drxk: Error %d on %s\n", status, __func__); + pr_err("Error %d on %s\n", status, __func__); return status; } @@ -1287,13 +1287,13 @@ static int bl_chain_cmd(struct drxk_state *state, ((time_is_after_jiffies(end)))); if (bl_status == 0x1) { - printk(KERN_ERR "drxk: SIO not ready\n"); + pr_err("SIO not ready\n"); status = -EINVAL; goto error2; } error: if (status < 0) - printk(KERN_ERR "drxk: Error %d on %s\n", status, __func__); + pr_err("Error %d on %s\n", status, __func__); error2: mutex_unlock(&state->mutex); return status; @@ -1349,13 +1349,13 @@ static int download_microcode(struct drxk_state *state, offset += sizeof(u16); if (offset + block_size > length) { - printk(KERN_ERR "drxk: Firmware is corrupted.\n"); + pr_err("Firmware is corrupted.\n"); return -EINVAL; } status = write_block(state, address, block_size, p_src); if (status < 0) { - printk(KERN_ERR "drxk: Error %d while loading firmware\n", status); + pr_err("Error %d while loading firmware\n", status); break; } p_src += block_size; @@ -1395,7 +1395,7 @@ static int dvbt_enable_ofdm_token_ring(struct drxk_state *state, bool enable) msleep(1); } while (1); if (data != desired_status) { - printk(KERN_ERR "drxk: SIO not ready\n"); + pr_err("SIO not ready\n"); return -EINVAL; } return status; @@ -1427,7 +1427,7 @@ static int mpegts_stop(struct drxk_state *state) error: if (status < 0) - printk(KERN_ERR "drxk: Error %d on %s\n", status, __func__); + pr_err("Error %d on %s\n", status, __func__); return status; } @@ -1451,7 +1451,7 @@ static int scu_command(struct drxk_state *state, if ((cmd == 0) || ((parameter_len > 0) && (parameter == NULL)) || ((result_len > 0) && (result == NULL))) { - printk(KERN_ERR "drxk: Error %d on %s\n", status, __func__); + pr_err("Error %d on %s\n", status, __func__); return status; } @@ -1477,7 +1477,7 @@ static int scu_command(struct drxk_state *state, goto error; } while (!(cur_cmd == DRX_SCU_READY) && (time_is_after_jiffies(end))); if (cur_cmd != DRX_SCU_READY) { - printk(KERN_ERR "drxk: SCU not ready\n"); + pr_err("SCU not ready\n"); status = -EIO; goto error2; } @@ -1515,7 +1515,7 @@ static int scu_command(struct drxk_state *state, sprintf(errname, "ERROR: %d\n", err); p = errname; } - printk(KERN_ERR "drxk: %s while sending cmd 0x%04x with params:", p, cmd); + pr_err("%s while sending cmd 0x%04x with params:", p, cmd); print_hex_dump_bytes("drxk: ", DUMP_PREFIX_NONE, buffer, cnt); status = -EINVAL; goto error2; @@ -1523,7 +1523,7 @@ static int scu_command(struct drxk_state *state, error: if (status < 0) - printk(KERN_ERR "drxk: Error %d on %s\n", status, __func__); + pr_err("Error %d on %s\n", status, __func__); error2: mutex_unlock(&state->mutex); return status; @@ -1559,7 +1559,7 @@ static int set_iqm_af(struct drxk_state *state, bool active) error: if (status < 0) - printk(KERN_ERR "drxk: Error %d on %s\n", status, __func__); + pr_err("Error %d on %s\n", status, __func__); return status; } @@ -1664,7 +1664,7 @@ static int ctrl_power_mode(struct drxk_state *state, enum drx_power_mode *mode) error: if (status < 0) - printk(KERN_ERR "drxk: Error %d on %s\n", status, __func__); + pr_err("Error %d on %s\n", status, __func__); return status; } @@ -1716,7 +1716,7 @@ static int power_down_dvbt(struct drxk_state *state, bool set_power_mode) } error: if (status < 0) - printk(KERN_ERR "drxk: Error %d on %s\n", status, __func__); + pr_err("Error %d on %s\n", status, __func__); return status; } @@ -1796,7 +1796,7 @@ static int setoperation_mode(struct drxk_state *state, } error: if (status < 0) - printk(KERN_ERR "drxk: Error %d on %s\n", status, __func__); + pr_err("Error %d on %s\n", status, __func__); return status; } @@ -1847,7 +1847,7 @@ static int start(struct drxk_state *state, s32 offset_freq, } error: if (status < 0) - printk(KERN_ERR "drxk: Error %d on %s\n", status, __func__); + pr_err("Error %d on %s\n", status, __func__); return status; } @@ -1885,7 +1885,7 @@ static int get_lock_status(struct drxk_state *state, u32 *p_lock_status) } error: if (status < 0) - printk(KERN_ERR "drxk: Error %d on %s\n", status, __func__); + pr_err("Error %d on %s\n", status, __func__); return status; } @@ -1906,7 +1906,7 @@ static int mpegts_start(struct drxk_state *state) status = write16(state, FEC_OC_SNC_UNLOCK__A, 1); error: if (status < 0) - printk(KERN_ERR "drxk: Error %d on %s\n", status, __func__); + pr_err("Error %d on %s\n", status, __func__); return status; } @@ -1952,7 +1952,7 @@ static int mpegts_dto_init(struct drxk_state *state) status = write16(state, FEC_OC_SNC_HWM__A, 12); error: if (status < 0) - printk(KERN_ERR "drxk: Error %d on %s\n", status, __func__); + pr_err("Error %d on %s\n", status, __func__); return status; } @@ -2089,7 +2089,7 @@ static int mpegts_dto_setup(struct drxk_state *state, status = write16(state, FEC_OC_TMD_MODE__A, fec_oc_tmd_mode); error: if (status < 0) - printk(KERN_ERR "drxk: Error %d on %s\n", status, __func__); + pr_err("Error %d on %s\n", status, __func__); return status; } @@ -2269,7 +2269,7 @@ static int set_agc_rf(struct drxk_state *state, } error: if (status < 0) - printk(KERN_ERR "drxk: Error %d on %s\n", status, __func__); + pr_err("Error %d on %s\n", status, __func__); return status; } @@ -2397,7 +2397,7 @@ static int set_agc_if(struct drxk_state *state, status = write16(state, SCU_RAM_AGC_INGAIN_TGT_MIN__A, p_agc_cfg->top); error: if (status < 0) - printk(KERN_ERR "drxk: Error %d on %s\n", status, __func__); + pr_err("Error %d on %s\n", status, __func__); return status; } @@ -2418,7 +2418,7 @@ static int get_qam_signal_to_noise(struct drxk_state *state, /* get the register value needed for MER */ status = read16(state, QAM_SL_ERR_POWER__A, &qam_sl_err_power); if (status < 0) { - printk(KERN_ERR "drxk: Error %d on %s\n", status, __func__); + pr_err("Error %d on %s\n", status, __func__); return -EINVAL; } @@ -2545,7 +2545,7 @@ static int get_dvbt_signal_to_noise(struct drxk_state *state, error: if (status < 0) - printk(KERN_ERR "drxk: Error %d on %s\n", status, __func__); + pr_err("Error %d on %s\n", status, __func__); return status; } @@ -2740,7 +2740,7 @@ static int ConfigureI2CBridge(struct drxk_state *state, bool b_enable_bridge) error: if (status < 0) - printk(KERN_ERR "drxk: Error %d on %s\n", status, __func__); + pr_err("Error %d on %s\n", status, __func__); return status; } @@ -2758,7 +2758,7 @@ static int set_pre_saw(struct drxk_state *state, status = write16(state, IQM_AF_PDREF__A, p_pre_saw_cfg->reference); error: if (status < 0) - printk(KERN_ERR "drxk: Error %d on %s\n", status, __func__); + pr_err("Error %d on %s\n", status, __func__); return status; } @@ -2800,13 +2800,13 @@ static int bl_direct_cmd(struct drxk_state *state, u32 target_addr, goto error; } while ((bl_status == 0x1) && time_is_after_jiffies(end)); if (bl_status == 0x1) { - printk(KERN_ERR "drxk: SIO not ready\n"); + pr_err("SIO not ready\n"); status = -EINVAL; goto error2; } error: if (status < 0) - printk(KERN_ERR "drxk: Error %d on %s\n", status, __func__); + pr_err("Error %d on %s\n", status, __func__); error2: mutex_unlock(&state->mutex); return status; @@ -2847,7 +2847,7 @@ static int adc_sync_measurement(struct drxk_state *state, u16 *count) error: if (status < 0) - printk(KERN_ERR "drxk: Error %d on %s\n", status, __func__); + pr_err("Error %d on %s\n", status, __func__); return status; } @@ -2891,7 +2891,7 @@ static int adc_synchronization(struct drxk_state *state) status = -EINVAL; error: if (status < 0) - printk(KERN_ERR "drxk: Error %d on %s\n", status, __func__); + pr_err("Error %d on %s\n", status, __func__); return status; } @@ -2957,7 +2957,7 @@ static int set_frequency_shifter(struct drxk_state *state, status = write32(state, IQM_FS_RATE_OFS_LO__A, state->m_iqm_fs_rate_ofs); if (status < 0) - printk(KERN_ERR "drxk: Error %d on %s\n", status, __func__); + pr_err("Error %d on %s\n", status, __func__); return status; } @@ -2992,7 +2992,8 @@ static int init_agc(struct drxk_state *state, bool is_dtv) /* AGCInit() not available for DVBT; init done in microcode */ if (!is_qam(state)) { - printk(KERN_ERR "drxk: %s: mode %d is not DVB-C\n", __func__, state->m_operation_mode); + pr_err("%s: mode %d is not DVB-C\n", + __func__, state->m_operation_mode); return -EINVAL; } @@ -3145,7 +3146,7 @@ static int init_agc(struct drxk_state *state, bool is_dtv) status = write16(state, SCU_RAM_AGC_KI__A, data); error: if (status < 0) - printk(KERN_ERR "drxk: Error %d on %s\n", status, __func__); + pr_err("Error %d on %s\n", status, __func__); return status; } @@ -3159,7 +3160,7 @@ static int dvbtqam_get_acc_pkt_err(struct drxk_state *state, u16 *packet_err) else status = read16(state, SCU_RAM_FEC_ACCUM_PKT_FAILURES__A, packet_err); if (status < 0) - printk(KERN_ERR "drxk: Error %d on %s\n", status, __func__); + pr_err("Error %d on %s\n", status, __func__); return status; } @@ -3279,7 +3280,7 @@ static int dvbt_sc_command(struct drxk_state *state, } /* switch (cmd->cmd) */ error: if (status < 0) - printk(KERN_ERR "drxk: Error %d on %s\n", status, __func__); + pr_err("Error %d on %s\n", status, __func__); return status; } @@ -3291,7 +3292,7 @@ static int power_up_dvbt(struct drxk_state *state) dprintk(1, "\n"); status = ctrl_power_mode(state, &power_mode); if (status < 0) - printk(KERN_ERR "drxk: Error %d on %s\n", status, __func__); + pr_err("Error %d on %s\n", status, __func__); return status; } @@ -3305,7 +3306,7 @@ static int dvbt_ctrl_set_inc_enable(struct drxk_state *state, bool *enabled) else status = write16(state, IQM_CF_BYPASSDET__A, 1); if (status < 0) - printk(KERN_ERR "drxk: Error %d on %s\n", status, __func__); + pr_err("Error %d on %s\n", status, __func__); return status; } @@ -3325,7 +3326,7 @@ static int dvbt_ctrl_set_fr_enable(struct drxk_state *state, bool *enabled) status = write16(state, OFDM_SC_RA_RAM_FR_THRES_8K__A, 0); } if (status < 0) - printk(KERN_ERR "drxk: Error %d on %s\n", status, __func__); + pr_err("Error %d on %s\n", status, __func__); return status; } @@ -3361,7 +3362,7 @@ static int dvbt_ctrl_set_echo_threshold(struct drxk_state *state, status = write16(state, OFDM_SC_RA_RAM_ECHO_THRES__A, data); error: if (status < 0) - printk(KERN_ERR "drxk: Error %d on %s\n", status, __func__); + pr_err("Error %d on %s\n", status, __func__); return status; } @@ -3384,7 +3385,7 @@ static int dvbt_ctrl_set_sqi_speed(struct drxk_state *state, (u16) *speed); error: if (status < 0) - printk(KERN_ERR "drxk: Error %d on %s\n", status, __func__); + pr_err("Error %d on %s\n", status, __func__); return status; } @@ -3423,7 +3424,7 @@ static int dvbt_activate_presets(struct drxk_state *state) status = write16(state, SCU_RAM_AGC_INGAIN_TGT_MAX__A, state->m_dvbt_if_agc_cfg.ingain_tgt_max); error: if (status < 0) - printk(KERN_ERR "drxk: Error %d on %s\n", status, __func__); + pr_err("Error %d on %s\n", status, __func__); return status; } @@ -3629,7 +3630,7 @@ static int set_dvbt_standard(struct drxk_state *state, error: if (status < 0) - printk(KERN_ERR "drxk: Error %d on %s\n", status, __func__); + pr_err("Error %d on %s\n", status, __func__); return status; } @@ -3661,7 +3662,7 @@ static int dvbt_start(struct drxk_state *state) goto error; error: if (status < 0) - printk(KERN_ERR "drxk: Error %d on %s\n", status, __func__); + pr_err("Error %d on %s\n", status, __func__); return status; } @@ -3980,7 +3981,7 @@ static int set_dvbt(struct drxk_state *state, u16 intermediate_freqk_hz, status = dvbt_ctrl_set_sqi_speed(state, &state->m_sqi_speed); error: if (status < 0) - printk(KERN_ERR "drxk: Error %d on %s\n", status, __func__); + pr_err("Error %d on %s\n", status, __func__); return status; } @@ -4031,7 +4032,7 @@ static int get_dvbt_lock_status(struct drxk_state *state, u32 *p_lock_status) *p_lock_status = NEVER_LOCK; end: if (status < 0) - printk(KERN_ERR "drxk: Error %d on %s\n", status, __func__); + pr_err("Error %d on %s\n", status, __func__); return status; } @@ -4044,7 +4045,7 @@ static int power_up_qam(struct drxk_state *state) dprintk(1, "\n"); status = ctrl_power_mode(state, &power_mode); if (status < 0) - printk(KERN_ERR "drxk: Error %d on %s\n", status, __func__); + pr_err("Error %d on %s\n", status, __func__); return status; } @@ -4079,7 +4080,7 @@ static int power_down_qam(struct drxk_state *state) error: if (status < 0) - printk(KERN_ERR "drxk: Error %d on %s\n", status, __func__); + pr_err("Error %d on %s\n", status, __func__); return status; } @@ -4167,7 +4168,7 @@ static int set_qam_measurement(struct drxk_state *state, status = write16(state, FEC_OC_SNC_FAIL_PERIOD__A, fec_rs_period); error: if (status < 0) - printk(KERN_ERR "drxk: Error %d on %s\n", status, __func__); + pr_err("Error %d on %s\n", status, __func__); return status; } @@ -4353,7 +4354,7 @@ static int set_qam16(struct drxk_state *state) error: if (status < 0) - printk(KERN_ERR "drxk: Error %d on %s\n", status, __func__); + pr_err("Error %d on %s\n", status, __func__); return status; } @@ -4548,7 +4549,7 @@ static int set_qam32(struct drxk_state *state) status = write16(state, SCU_RAM_QAM_FSM_LCAVG_OFFSET5__A, (u16) -86); error: if (status < 0) - printk(KERN_ERR "drxk: Error %d on %s\n", status, __func__); + pr_err("Error %d on %s\n", status, __func__); return status; } @@ -4741,7 +4742,7 @@ static int set_qam64(struct drxk_state *state) status = write16(state, SCU_RAM_QAM_FSM_LCAVG_OFFSET5__A, (u16) -80); error: if (status < 0) - printk(KERN_ERR "drxk: Error %d on %s\n", status, __func__); + pr_err("Error %d on %s\n", status, __func__); return status; } @@ -4937,7 +4938,7 @@ static int set_qam128(struct drxk_state *state) status = write16(state, SCU_RAM_QAM_FSM_LCAVG_OFFSET5__A, (u16) -23); error: if (status < 0) - printk(KERN_ERR "drxk: Error %d on %s\n", status, __func__); + pr_err("Error %d on %s\n", status, __func__); return status; } @@ -5132,7 +5133,7 @@ static int set_qam256(struct drxk_state *state) status = write16(state, SCU_RAM_QAM_FSM_LCAVG_OFFSET5__A, (u16) -8); error: if (status < 0) - printk(KERN_ERR "drxk: Error %d on %s\n", status, __func__); + pr_err("Error %d on %s\n", status, __func__); return status; } @@ -5158,7 +5159,7 @@ static int qam_reset_qam(struct drxk_state *state) status = scu_command(state, SCU_RAM_COMMAND_STANDARD_QAM | SCU_RAM_COMMAND_CMD_DEMOD_RESET, 0, NULL, 1, &cmd_result); error: if (status < 0) - printk(KERN_ERR "drxk: Error %d on %s\n", status, __func__); + pr_err("Error %d on %s\n", status, __func__); return status; } @@ -5228,7 +5229,7 @@ static int qam_set_symbolrate(struct drxk_state *state) error: if (status < 0) - printk(KERN_ERR "drxk: Error %d on %s\n", status, __func__); + pr_err("Error %d on %s\n", status, __func__); return status; } @@ -5253,7 +5254,7 @@ static int get_qam_lock_status(struct drxk_state *state, u32 *p_lock_status) SCU_RAM_COMMAND_CMD_DEMOD_GET_LOCK, 0, NULL, 2, result); if (status < 0) - printk(KERN_ERR "drxk: Error %d on %s\n", status, __func__); + pr_err("Error %d on %s\n", status, __func__); if (result[1] < SCU_RAM_QAM_LOCKED_LOCKED_DEMOD_LOCKED) { /* 0x0000 NOT LOCKED */ @@ -5324,15 +5325,14 @@ static int qam_demodulator_command(struct drxk_state *state, number_of_parameters, set_param_parameters, 1, &cmd_result); } else { - printk(KERN_WARNING "drxk: Unknown QAM demodulator parameter " - "count %d\n", number_of_parameters); + pr_warn("Unknown QAM demodulator parameter count %d\n", + number_of_parameters); status = -EINVAL; } error: if (status < 0) - printk(KERN_WARNING "drxk: Warning %d on %s\n", - status, __func__); + pr_warn("Warning %d on %s\n", status, __func__); return status; } @@ -5587,7 +5587,7 @@ static int set_qam(struct drxk_state *state, u16 intermediate_freqk_hz, error: if (status < 0) - printk(KERN_ERR "drxk: Error %d on %s\n", status, __func__); + pr_err("Error %d on %s\n", status, __func__); return status; } @@ -5749,7 +5749,7 @@ static int set_qam_standard(struct drxk_state *state, status = write16(state, SCU_COMM_EXEC__A, SCU_COMM_EXEC_ACTIVE); error: if (status < 0) - printk(KERN_ERR "drxk: Error %d on %s\n", status, __func__); + pr_err("Error %d on %s\n", status, __func__); return status; } @@ -5832,7 +5832,7 @@ static int write_gpio(struct drxk_state *state) status = write16(state, SIO_TOP_COMM_KEY__A, 0x0000); error: if (status < 0) - printk(KERN_ERR "drxk: Error %d on %s\n", status, __func__); + pr_err("Error %d on %s\n", status, __func__); return status; } @@ -5857,7 +5857,7 @@ static int switch_antenna_to_qam(struct drxk_state *state) status = write_gpio(state); } if (status < 0) - printk(KERN_ERR "drxk: Error %d on %s\n", status, __func__); + pr_err("Error %d on %s\n", status, __func__); return status; } @@ -5882,7 +5882,7 @@ static int switch_antenna_to_dvbt(struct drxk_state *state) status = write_gpio(state); } if (status < 0) - printk(KERN_ERR "drxk: Error %d on %s\n", status, __func__); + pr_err("Error %d on %s\n", status, __func__); return status; } @@ -5919,7 +5919,7 @@ static int power_down_device(struct drxk_state *state) status = hi_cfg_command(state); error: if (status < 0) - printk(KERN_ERR "drxk: Error %d on %s\n", status, __func__); + pr_err("Error %d on %s\n", status, __func__); return status; } @@ -6060,7 +6060,7 @@ static int init_drxk(struct drxk_state *state) if (status < 0) goto error; - printk(KERN_INFO "DRXK driver version %d.%d.%d\n", + pr_info("DRXK driver version %d.%d.%d\n", DRXK_VERSION_MAJOR, DRXK_VERSION_MINOR, DRXK_VERSION_PATCH); @@ -6128,7 +6128,7 @@ error: if (status < 0) { state->m_drxk_state = DRXK_NO_DEV; drxk_i2c_unlock(state); - printk(KERN_ERR "drxk: Error %d on %s\n", status, __func__); + pr_err("Error %d on %s\n", status, __func__); } return status; @@ -6141,11 +6141,9 @@ static void load_firmware_cb(const struct firmware *fw, dprintk(1, ": %s\n", fw ? "firmware loaded" : "firmware not loaded"); if (!fw) { - printk(KERN_ERR - "drxk: Could not load firmware file %s.\n", + pr_err("Could not load firmware file %s.\n", state->microcode_name); - printk(KERN_INFO - "drxk: Copy %s to your hotplug directory!\n", + pr_info("Copy %s to your hotplug directory!\n", state->microcode_name); state->microcode_name = NULL; @@ -6219,8 +6217,7 @@ static int drxk_set_parameters(struct dvb_frontend *fe) return -EAGAIN; if (!fe->ops.tuner_ops.get_if_frequency) { - printk(KERN_ERR - "drxk: Error: get_if_frequency() not defined at tuner. Can't work without it!\n"); + pr_err("Error: get_if_frequency() not defined at tuner. Can't work without it!\n"); return -EINVAL; } @@ -6704,8 +6701,7 @@ struct dvb_frontend *drxk_attach(const struct drxk_config *config, GFP_KERNEL, state, load_firmware_cb); if (status < 0) { - printk(KERN_ERR - "drxk: failed to request a firmware\n"); + pr_err("failed to request a firmware\n"); return NULL; } } @@ -6733,11 +6729,11 @@ struct dvb_frontend *drxk_attach(const struct drxk_config *config, p->post_bit_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE; p->post_bit_count.stat[0].scale = FE_SCALE_NOT_AVAILABLE; - printk(KERN_INFO "drxk: frontend initialized.\n"); + pr_info("frontend initialized.\n"); return &state->frontend; error: - printk(KERN_ERR "drxk: not found\n"); + pr_err("not found\n"); kfree(state); return NULL; } From 0fb220f2a5cb85365d1ecf11e931d57109955782 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Sun, 28 Apr 2013 11:47:46 -0300 Subject: [PATCH 0114/1048] [media] drxk_hard: don't split strings across lines X-Patchwork-Delegate: mchehab@redhat.com WARNING: quoted string split across lines #5416: FILE: media/dvb-frontends/drxk_hard.c:5416: + dprintk(1, "Could not set demodulator parameters. Make " + "sure qam_demod_parameter_count (%d) is correct for " WARNING: quoted string split across lines #5423: FILE: media/dvb-frontends/drxk_hard.c:5423: + dprintk(1, "Auto-probing the correct QAM demodulator command " + "parameters was successful - using %d parameters.\n", Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb-frontends/drxk_hard.c | 30 ++++++++++++------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/drivers/media/dvb-frontends/drxk_hard.c b/drivers/media/dvb-frontends/drxk_hard.c index 552bce5d8f92..fdbe23a00478 100644 --- a/drivers/media/dvb-frontends/drxk_hard.c +++ b/drivers/media/dvb-frontends/drxk_hard.c @@ -168,7 +168,7 @@ MODULE_PARM_DESC(debug, "enable debug messages"); #define dprintk(level, fmt, arg...) do { \ if (debug >= level) \ - printk(KERN_DEBUG "drxk: %s" fmt, __func__, ## arg); \ + pr_debug(fmt, ##arg); \ } while (0) @@ -258,8 +258,8 @@ static int i2c_write(struct drxk_state *state, u8 adr, u8 *data, int len) if (debug > 2) { int i; for (i = 0; i < len; i++) - printk(KERN_CONT " %02x", data[i]); - printk(KERN_CONT "\n"); + pr_cont(" %02x", data[i]); + pr_cont("\n"); } status = drxk_i2c_transfer(state, &msg, 1); if (status >= 0 && status != 1) @@ -285,7 +285,7 @@ static int i2c_read(struct drxk_state *state, status = drxk_i2c_transfer(state, msgs, 2); if (status != 2) { if (debug > 2) - printk(KERN_CONT ": ERROR!\n"); + pr_cont(": ERROR!\n"); if (status >= 0) status = -EIO; @@ -296,11 +296,11 @@ static int i2c_read(struct drxk_state *state, int i; dprintk(2, ": read from"); for (i = 0; i < len; i++) - printk(KERN_CONT " %02x", msg[i]); - printk(KERN_CONT ", value = "); + pr_cont(" %02x", msg[i]); + pr_cont(", value = "); for (i = 0; i < alen; i++) - printk(KERN_CONT " %02x", answ[i]); - printk(KERN_CONT "\n"); + pr_cont(" %02x", answ[i]); + pr_cont("\n"); } return 0; } @@ -470,8 +470,8 @@ static int write_block(struct drxk_state *state, u32 address, int i; if (p_block) for (i = 0; i < chunk; i++) - printk(KERN_CONT " %02x", p_block[i]); - printk(KERN_CONT "\n"); + pr_cont(" %02x", p_block[i]); + pr_cont("\n"); } status = i2c_write(state, state->demod_address, &state->chunk[0], chunk + adr_length); @@ -5412,15 +5412,15 @@ static int set_qam(struct drxk_state *state, u16 intermediate_freqk_hz, } if (status < 0) { - dprintk(1, "Could not set demodulator parameters. Make " - "sure qam_demod_parameter_count (%d) is correct for " - "your firmware (%s).\n", + dprintk(1, "Could not set demodulator parameters.\n"); + dprintk(1, + "Make sure qam_demod_parameter_count (%d) is correct for your firmware (%s).\n", state->qam_demod_parameter_count, state->microcode_name); goto error; } else if (!state->qam_demod_parameter_count) { - dprintk(1, "Auto-probing the correct QAM demodulator command " - "parameters was successful - using %d parameters.\n", + dprintk(1, + "Auto-probing the QAM command parameters was successful - using %d parameters.\n", qam_demod_param_count); /* From b72852baa0776f6ed416d54cd94b7804f0587f81 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Sun, 28 Apr 2013 11:47:47 -0300 Subject: [PATCH 0115/1048] [media] drxk_hard: use usleep_range() X-Patchwork-Delegate: mchehab@redhat.com Fixes the following checkpatch.pl warnings: WARNING: msleep < 20ms can sleep for up to 20ms; see Documentation/timers/timers-howto.txt + msleep(10); WARNING: msleep < 20ms can sleep for up to 20ms; see Documentation/timers/timers-howto.txt + msleep(1); WARNING: msleep < 20ms can sleep for up to 20ms; see Documentation/timers/timers-howto.txt + msleep(1); WARNING: msleep < 20ms can sleep for up to 20ms; see Documentation/timers/timers-howto.txt + msleep(1); WARNING: msleep < 20ms can sleep for up to 20ms; see Documentation/timers/timers-howto.txt + msleep(1); WARNING: msleep < 20ms can sleep for up to 20ms; see Documentation/timers/timers-howto.txt + msleep(1); WARNING: msleep < 20ms can sleep for up to 20ms; see Documentation/timers/timers-howto.txt + msleep(1); WARNING: msleep < 20ms can sleep for up to 20ms; see Documentation/timers/timers-howto.txt + msleep(1); Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb-frontends/drxk_hard.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/media/dvb-frontends/drxk_hard.c b/drivers/media/dvb-frontends/drxk_hard.c index fdbe23a00478..1fd74f2ed3e2 100644 --- a/drivers/media/dvb-frontends/drxk_hard.c +++ b/drivers/media/dvb-frontends/drxk_hard.c @@ -505,7 +505,7 @@ static int power_up_device(struct drxk_state *state) data = 0; status = i2c_write(state, state->demod_address, &data, 1); - msleep(10); + usleep_range(10000, 11000); retry_count++; if (status < 0) continue; @@ -1017,7 +1017,7 @@ static int hi_command(struct drxk_state *state, u16 cmd, u16 *p_result) if (status < 0) goto error; if (cmd == SIO_HI_RA_RAM_CMD_RESET) - msleep(1); + usleep_range(1000, 2000); powerdown_cmd = (bool) ((cmd == SIO_HI_RA_RAM_CMD_CONFIG) && @@ -1030,7 +1030,7 @@ static int hi_command(struct drxk_state *state, u16 cmd, u16 *p_result) u16 wait_cmd; do { - msleep(1); + usleep_range(1000, 2000); retry_count += 1; status = read16(state, SIO_HI_RA_RAM_CMD__A, &wait_cmd); @@ -1279,7 +1279,7 @@ static int bl_chain_cmd(struct drxk_state *state, end = jiffies + msecs_to_jiffies(time_out); do { - msleep(1); + usleep_range(1000, 2000); status = read16(state, SIO_BL_STATUS__A, &bl_status); if (status < 0) goto error; @@ -1392,7 +1392,7 @@ static int dvbt_enable_ofdm_token_ring(struct drxk_state *state, bool enable) status = read16(state, SIO_OFDM_SH_OFDM_RING_STATUS__A, &data); if ((status >= 0 && data == desired_status) || time_is_after_jiffies(end)) break; - msleep(1); + usleep_range(1000, 2000); } while (1); if (data != desired_status) { pr_err("SIO not ready\n"); @@ -1471,7 +1471,7 @@ static int scu_command(struct drxk_state *state, /* Wait until SCU has processed command */ end = jiffies + msecs_to_jiffies(DRXK_MAX_WAITTIME); do { - msleep(1); + usleep_range(1000, 2000); status = read16(state, SCU_RAM_COMMAND__A, &cur_cmd); if (status < 0) goto error; @@ -3187,7 +3187,7 @@ static int dvbt_sc_command(struct drxk_state *state, /* Wait until sc is ready to receive command */ retry_cnt = 0; do { - msleep(1); + usleep_range(1000, 2000); status = read16(state, OFDM_SC_RA_RAM_CMD__A, &cur_cmd); retry_cnt++; } while ((cur_cmd != 0) && (retry_cnt < DRXK_MAX_RETRIES)); @@ -3239,7 +3239,7 @@ static int dvbt_sc_command(struct drxk_state *state, /* Wait until sc is ready processing command */ retry_cnt = 0; do { - msleep(1); + usleep_range(1000, 2000); status = read16(state, OFDM_SC_RA_RAM_CMD__A, &cur_cmd); retry_cnt++; } while ((cur_cmd != 0) && (retry_cnt < DRXK_MAX_RETRIES)); @@ -5947,7 +5947,7 @@ static int init_drxk(struct drxk_state *state) if (status < 0) goto error; /* TODO is this needed, if yes how much delay in worst case scenario */ - msleep(1); + usleep_range(1000, 2000); state->m_drxk_a3_patch_code = true; status = get_device_capabilities(state); if (status < 0) From 57b8b0035725db6b1a4f7bb815b3dc244942b04d Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Sun, 28 Apr 2013 11:47:48 -0300 Subject: [PATCH 0116/1048] [media] drxk_hard.h: Remove some alien comment markups X-Patchwork-Delegate: mchehab@redhat.com The comments markup language used on Kernel is defined at: Documentation/kernel-doc-nano-HOWTO.txt Remove invalid markups from the header file. Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb-frontends/drxk_hard.h | 100 ++++++++++++------------ 1 file changed, 50 insertions(+), 50 deletions(-) diff --git a/drivers/media/dvb-frontends/drxk_hard.h b/drivers/media/dvb-frontends/drxk_hard.h index db87a6d75720..e77d9f098c93 100644 --- a/drivers/media/dvb-frontends/drxk_hard.h +++ b/drivers/media/dvb-frontends/drxk_hard.h @@ -77,17 +77,17 @@ enum drx_power_mode { }; -/** /brief Intermediate power mode for DRXK, power down OFDM clock domain */ +/* Intermediate power mode for DRXK, power down OFDM clock domain */ #ifndef DRXK_POWER_DOWN_OFDM #define DRXK_POWER_DOWN_OFDM DRX_POWER_MODE_1 #endif -/** /brief Intermediate power mode for DRXK, power down core (sysclk) */ +/* Intermediate power mode for DRXK, power down core (sysclk) */ #ifndef DRXK_POWER_DOWN_CORE #define DRXK_POWER_DOWN_CORE DRX_POWER_MODE_9 #endif -/** /brief Intermediate power mode for DRXK, power down pll (only osc runs) */ +/* Intermediate power mode for DRXK, power down pll (only osc runs) */ #ifndef DRXK_POWER_DOWN_PLL #define DRXK_POWER_DOWN_PLL DRX_POWER_MODE_10 #endif @@ -193,13 +193,13 @@ struct s_cfg_pre_saw { }; struct drxk_ofdm_sc_cmd_t { - u16 cmd; /**< Command number */ - u16 subcmd; /**< Sub-command parameter*/ - u16 param0; /**< General purpous param */ - u16 param1; /**< General purpous param */ - u16 param2; /**< General purpous param */ - u16 param3; /**< General purpous param */ - u16 param4; /**< General purpous param */ + u16 cmd; /* Command number */ + u16 subcmd; /* Sub-command parameter*/ + u16 param0; /* General purpous param */ + u16 param1; /* General purpous param */ + u16 param2; /* General purpous param */ + u16 param3; /* General purpous param */ + u16 param4; /* General purpous param */ }; struct drxk_state { @@ -213,7 +213,7 @@ struct drxk_state { struct mutex mutex; - u32 m_instance; /**< Channel 1,2,3 or 4 */ + u32 m_instance; /* Channel 1,2,3 or 4 */ int m_chunk_size; u8 chunk[256]; @@ -234,33 +234,33 @@ struct drxk_state { u16 m_hi_cfg_wake_up_key; u16 m_hi_cfg_timeout; u16 m_hi_cfg_ctrl; - s32 m_sys_clock_freq; /**< system clock frequency in kHz */ + s32 m_sys_clock_freq; /* system clock frequency in kHz */ - enum e_drxk_state m_drxk_state; /**< State of Drxk (init,stopped,started) */ - enum operation_mode m_operation_mode; /**< digital standards */ - struct s_cfg_agc m_vsb_rf_agc_cfg; /**< settings for VSB RF-AGC */ - struct s_cfg_agc m_vsb_if_agc_cfg; /**< settings for VSB IF-AGC */ - u16 m_vsb_pga_cfg; /**< settings for VSB PGA */ - struct s_cfg_pre_saw m_vsb_pre_saw_cfg; /**< settings for pre SAW sense */ - s32 m_Quality83percent; /**< MER level (*0.1 dB) for 83% quality indication */ - s32 m_Quality93percent; /**< MER level (*0.1 dB) for 93% quality indication */ + enum e_drxk_state m_drxk_state; /* State of Drxk (init,stopped,started) */ + enum operation_mode m_operation_mode; /* digital standards */ + struct s_cfg_agc m_vsb_rf_agc_cfg; /* settings for VSB RF-AGC */ + struct s_cfg_agc m_vsb_if_agc_cfg; /* settings for VSB IF-AGC */ + u16 m_vsb_pga_cfg; /* settings for VSB PGA */ + struct s_cfg_pre_saw m_vsb_pre_saw_cfg; /* settings for pre SAW sense */ + s32 m_Quality83percent; /* MER level (*0.1 dB) for 83% quality indication */ + s32 m_Quality93percent; /* MER level (*0.1 dB) for 93% quality indication */ bool m_smart_ant_inverted; bool m_b_debug_enable_bridge; - bool m_b_p_down_open_bridge; /**< only open DRXK bridge before power-down once it has been accessed */ - bool m_b_power_down; /**< Power down when not used */ + bool m_b_p_down_open_bridge; /* only open DRXK bridge before power-down once it has been accessed */ + bool m_b_power_down; /* Power down when not used */ - u32 m_iqm_fs_rate_ofs; /**< frequency shift as written to DRXK register (28bit fixpoint) */ + u32 m_iqm_fs_rate_ofs; /* frequency shift as written to DRXK register (28bit fixpoint) */ - bool m_enable_mpeg_output; /**< If TRUE, enable MPEG output */ - bool m_insert_rs_byte; /**< If TRUE, insert RS byte */ - bool m_enable_parallel; /**< If TRUE, parallel out otherwise serial */ - bool m_invert_data; /**< If TRUE, invert DATA signals */ - bool m_invert_err; /**< If TRUE, invert ERR signal */ - bool m_invert_str; /**< If TRUE, invert STR signals */ - bool m_invert_val; /**< If TRUE, invert VAL signals */ - bool m_invert_clk; /**< If TRUE, invert CLK signals */ + bool m_enable_mpeg_output; /* If TRUE, enable MPEG output */ + bool m_insert_rs_byte; /* If TRUE, insert RS byte */ + bool m_enable_parallel; /* If TRUE, parallel out otherwise serial */ + bool m_invert_data; /* If TRUE, invert DATA signals */ + bool m_invert_err; /* If TRUE, invert ERR signal */ + bool m_invert_str; /* If TRUE, invert STR signals */ + bool m_invert_val; /* If TRUE, invert VAL signals */ + bool m_invert_clk; /* If TRUE, invert CLK signals */ bool m_dvbc_static_clk; - bool m_dvbt_static_clk; /**< If TRUE, static MPEG clockrate will + bool m_dvbt_static_clk; /* If TRUE, static MPEG clockrate will be used, otherwise clockrate will adapt to the bitrate of the TS */ u32 m_dvbt_bitrate; @@ -271,22 +271,22 @@ struct drxk_state { bool m_itut_annex_c; /* If true, uses ITU-T DVB-C Annex C, instead of Annex A */ - enum drxmpeg_str_width_t m_width_str; /**< MPEG start width */ - u32 m_mpeg_ts_static_bitrate; /**< Maximum bitrate in b/s in case + enum drxmpeg_str_width_t m_width_str; /* MPEG start width */ + u32 m_mpeg_ts_static_bitrate; /* Maximum bitrate in b/s in case static clockrate is selected */ - /* LARGE_INTEGER m_startTime; */ /**< Contains the time of the last demod start */ - s32 m_mpeg_lock_time_out; /**< WaitForLockStatus Timeout (counts from start time) */ - s32 m_demod_lock_time_out; /**< WaitForLockStatus Timeout (counts from start time) */ + /* LARGE_INTEGER m_startTime; */ /* Contains the time of the last demod start */ + s32 m_mpeg_lock_time_out; /* WaitForLockStatus Timeout (counts from start time) */ + s32 m_demod_lock_time_out; /* WaitForLockStatus Timeout (counts from start time) */ bool m_disable_te_ihandling; bool m_rf_agc_pol; bool m_if_agc_pol; - struct s_cfg_agc m_atv_rf_agc_cfg; /**< settings for ATV RF-AGC */ - struct s_cfg_agc m_atv_if_agc_cfg; /**< settings for ATV IF-AGC */ - struct s_cfg_pre_saw m_atv_pre_saw_cfg; /**< settings for ATV pre SAW sense */ + struct s_cfg_agc m_atv_rf_agc_cfg; /* settings for ATV RF-AGC */ + struct s_cfg_agc m_atv_if_agc_cfg; /* settings for ATV IF-AGC */ + struct s_cfg_pre_saw m_atv_pre_saw_cfg; /* settings for ATV pre SAW sense */ bool m_phase_correction_bypass; s16 m_atv_top_vid_peak; u16 m_atv_top_noise_th; @@ -294,13 +294,13 @@ struct drxk_state { bool m_enable_cvbs_output; bool m_enable_sif_output; bool m_b_mirror_freq_spect; - enum e_drxk_constellation m_constellation; /**< constellation type of the channel */ - u32 m_curr_symbol_rate; /**< Current QAM symbol rate */ - struct s_cfg_agc m_qam_rf_agc_cfg; /**< settings for QAM RF-AGC */ - struct s_cfg_agc m_qam_if_agc_cfg; /**< settings for QAM IF-AGC */ - u16 m_qam_pga_cfg; /**< settings for QAM PGA */ - struct s_cfg_pre_saw m_qam_pre_saw_cfg; /**< settings for QAM pre SAW sense */ - enum e_drxk_interleave_mode m_qam_interleave_mode; /**< QAM Interleave mode */ + enum e_drxk_constellation m_constellation; /* constellation type of the channel */ + u32 m_curr_symbol_rate; /* Current QAM symbol rate */ + struct s_cfg_agc m_qam_rf_agc_cfg; /* settings for QAM RF-AGC */ + struct s_cfg_agc m_qam_if_agc_cfg; /* settings for QAM IF-AGC */ + u16 m_qam_pga_cfg; /* settings for QAM PGA */ + struct s_cfg_pre_saw m_qam_pre_saw_cfg; /* settings for QAM pre SAW sense */ + enum e_drxk_interleave_mode m_qam_interleave_mode; /* QAM Interleave mode */ u16 m_fec_rs_plen; u16 m_fec_rs_prescale; @@ -309,9 +309,9 @@ struct drxk_state { u16 m_gpio; u16 m_gpio_cfg; - struct s_cfg_agc m_dvbt_rf_agc_cfg; /**< settings for QAM RF-AGC */ - struct s_cfg_agc m_dvbt_if_agc_cfg; /**< settings for QAM IF-AGC */ - struct s_cfg_pre_saw m_dvbt_pre_saw_cfg; /**< settings for QAM pre SAW sense */ + struct s_cfg_agc m_dvbt_rf_agc_cfg; /* settings for QAM RF-AGC */ + struct s_cfg_agc m_dvbt_if_agc_cfg; /* settings for QAM IF-AGC */ + struct s_cfg_pre_saw m_dvbt_pre_saw_cfg; /* settings for QAM pre SAW sense */ u16 m_agcfast_clip_ctrl_delay; bool m_adc_comp_passed; From d5687ab520d6cf8bf60d8c44932eeb0a1829a75c Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Sun, 28 Apr 2013 11:47:49 -0300 Subject: [PATCH 0117/1048] [media] drxk_hard.h: don't use more than 80 columns X-Patchwork-Delegate: mchehab@redhat.com Almost all 80-col warnings are related to comments. There's one, however, that it is due to a one-line enum declaration for enum agc_ctrl_mode. Break it into one line per enumered data. Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb-frontends/drxk_hard.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/media/dvb-frontends/drxk_hard.h b/drivers/media/dvb-frontends/drxk_hard.h index e77d9f098c93..bae9c71dc3e9 100644 --- a/drivers/media/dvb-frontends/drxk_hard.h +++ b/drivers/media/dvb-frontends/drxk_hard.h @@ -93,7 +93,12 @@ enum drx_power_mode { #endif -enum agc_ctrl_mode { DRXK_AGC_CTRL_AUTO = 0, DRXK_AGC_CTRL_USER, DRXK_AGC_CTRL_OFF }; +enum agc_ctrl_mode { + DRXK_AGC_CTRL_AUTO = 0, + DRXK_AGC_CTRL_USER, + DRXK_AGC_CTRL_OFF +}; + enum e_drxk_state { DRXK_UNINITIALIZED = 0, DRXK_STOPPED, From 949dd08d92cdbbe7f2560f06ac297eee54b7ea49 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Sun, 28 Apr 2013 11:47:50 -0300 Subject: [PATCH 0118/1048] [media] drxk_hard: remove needless parenthesis X-Patchwork-Delegate: mchehab@redhat.com There are several places where: state->var = (some_var) The parenthesis there are doing nothing but making it harder to read and breaking the 80 columns soft limits. Just get rid of it. Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb-frontends/drxk_hard.c | 50 ++++++++++++------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/drivers/media/dvb-frontends/drxk_hard.c b/drivers/media/dvb-frontends/drxk_hard.c index 1fd74f2ed3e2..7f4b5145a8aa 100644 --- a/drivers/media/dvb-frontends/drxk_hard.c +++ b/drivers/media/dvb-frontends/drxk_hard.c @@ -628,21 +628,21 @@ static int init_state(struct drxk_state *state) /* Init AGC and PGA parameters */ /* VSB IF */ - state->m_vsb_if_agc_cfg.ctrl_mode = (ul_vsb_if_agc_mode); - state->m_vsb_if_agc_cfg.output_level = (ul_vsb_if_agc_output_level); - state->m_vsb_if_agc_cfg.min_output_level = (ul_vsb_if_agc_min_level); - state->m_vsb_if_agc_cfg.max_output_level = (ul_vsb_if_agc_max_level); - state->m_vsb_if_agc_cfg.speed = (ul_vsb_if_agc_speed); + state->m_vsb_if_agc_cfg.ctrl_mode = ul_vsb_if_agc_mode; + state->m_vsb_if_agc_cfg.output_level = ul_vsb_if_agc_output_level; + state->m_vsb_if_agc_cfg.min_output_level = ul_vsb_if_agc_min_level; + state->m_vsb_if_agc_cfg.max_output_level = ul_vsb_if_agc_max_level; + state->m_vsb_if_agc_cfg.speed = ul_vsb_if_agc_speed; state->m_vsb_pga_cfg = 140; /* VSB RF */ - state->m_vsb_rf_agc_cfg.ctrl_mode = (ul_vsb_rf_agc_mode); - state->m_vsb_rf_agc_cfg.output_level = (ul_vsb_rf_agc_output_level); - state->m_vsb_rf_agc_cfg.min_output_level = (ul_vsb_rf_agc_min_level); - state->m_vsb_rf_agc_cfg.max_output_level = (ul_vsb_rf_agc_max_level); - state->m_vsb_rf_agc_cfg.speed = (ul_vsb_rf_agc_speed); - state->m_vsb_rf_agc_cfg.top = (ul_vsb_rf_agc_top); - state->m_vsb_rf_agc_cfg.cut_off_current = (ul_vsb_rf_agc_cut_off_current); + state->m_vsb_rf_agc_cfg.ctrl_mode = ul_vsb_rf_agc_mode; + state->m_vsb_rf_agc_cfg.output_level = ul_vsb_rf_agc_output_level; + state->m_vsb_rf_agc_cfg.min_output_level = ul_vsb_rf_agc_min_level; + state->m_vsb_rf_agc_cfg.max_output_level = ul_vsb_rf_agc_max_level; + state->m_vsb_rf_agc_cfg.speed = ul_vsb_rf_agc_speed; + state->m_vsb_rf_agc_cfg.top = ul_vsb_rf_agc_top; + state->m_vsb_rf_agc_cfg.cut_off_current = ul_vsb_rf_agc_cut_off_current; state->m_vsb_pre_saw_cfg.reference = 0x07; state->m_vsb_pre_saw_cfg.use_pre_saw = true; @@ -654,20 +654,20 @@ static int init_state(struct drxk_state *state) } /* ATV IF */ - state->m_atv_if_agc_cfg.ctrl_mode = (ul_atv_if_agc_mode); - state->m_atv_if_agc_cfg.output_level = (ul_atv_if_agc_output_level); - state->m_atv_if_agc_cfg.min_output_level = (ul_atv_if_agc_min_level); - state->m_atv_if_agc_cfg.max_output_level = (ul_atv_if_agc_max_level); - state->m_atv_if_agc_cfg.speed = (ul_atv_if_agc_speed); + state->m_atv_if_agc_cfg.ctrl_mode = ul_atv_if_agc_mode; + state->m_atv_if_agc_cfg.output_level = ul_atv_if_agc_output_level; + state->m_atv_if_agc_cfg.min_output_level = ul_atv_if_agc_min_level; + state->m_atv_if_agc_cfg.max_output_level = ul_atv_if_agc_max_level; + state->m_atv_if_agc_cfg.speed = ul_atv_if_agc_speed; /* ATV RF */ - state->m_atv_rf_agc_cfg.ctrl_mode = (ul_atv_rf_agc_mode); - state->m_atv_rf_agc_cfg.output_level = (ul_atv_rf_agc_output_level); - state->m_atv_rf_agc_cfg.min_output_level = (ul_atv_rf_agc_min_level); - state->m_atv_rf_agc_cfg.max_output_level = (ul_atv_rf_agc_max_level); - state->m_atv_rf_agc_cfg.speed = (ul_atv_rf_agc_speed); - state->m_atv_rf_agc_cfg.top = (ul_atv_rf_agc_top); - state->m_atv_rf_agc_cfg.cut_off_current = (ul_atv_rf_agc_cut_off_current); + state->m_atv_rf_agc_cfg.ctrl_mode = ul_atv_rf_agc_mode; + state->m_atv_rf_agc_cfg.output_level = ul_atv_rf_agc_output_level; + state->m_atv_rf_agc_cfg.min_output_level = ul_atv_rf_agc_min_level; + state->m_atv_rf_agc_cfg.max_output_level = ul_atv_rf_agc_max_level; + state->m_atv_rf_agc_cfg.speed = ul_atv_rf_agc_speed; + state->m_atv_rf_agc_cfg.top = ul_atv_rf_agc_top; + state->m_atv_rf_agc_cfg.cut_off_current = ul_atv_rf_agc_cut_off_current; state->m_atv_pre_saw_cfg.reference = 0x04; state->m_atv_pre_saw_cfg.use_pre_saw = true; @@ -764,7 +764,7 @@ static int init_state(struct drxk_state *state) state->m_sqi_speed = DRXK_DVBT_SQI_SPEED_MEDIUM; state->m_agcfast_clip_ctrl_delay = 0; - state->m_gpio_cfg = (ul_gpio_cfg); + state->m_gpio_cfg = ul_gpio_cfg; state->m_b_power_down = false; state->m_current_power_mode = DRX_POWER_DOWN; From ab5060cdb8829c0503b7be2b239b52e9a25063b4 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Sun, 28 Apr 2013 11:47:51 -0300 Subject: [PATCH 0119/1048] [media] drxk_hard: Remove most 80-cols checkpatch warnings X-Patchwork-Delegate: mchehab@redhat.com There are a few cases where breaking the code into separate lines make it worse to read. However, on several places, breaking it to make checkpatch.pl happier is OK and improves code readability. So, break longer lines where that won't cause harm. Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb-frontends/drxk_hard.c | 406 ++++++++++++++++-------- 1 file changed, 275 insertions(+), 131 deletions(-) diff --git a/drivers/media/dvb-frontends/drxk_hard.c b/drivers/media/dvb-frontends/drxk_hard.c index 7f4b5145a8aa..082014de6875 100644 --- a/drivers/media/dvb-frontends/drxk_hard.c +++ b/drivers/media/dvb-frontends/drxk_hard.c @@ -189,8 +189,10 @@ static inline u32 Frac28a(u32 a, u32 c) u32 R0 = 0; R0 = (a % c) << 4; /* 32-28 == 4 shifts possible at max */ - Q1 = a / c; /* integer part, only the 4 least significant bits - will be visible in the result */ + Q1 = a / c; /* + * integer part, only the 4 least significant + * bits will be visible in the result + */ /* division using radix 16, 7 nibbles in the result */ for (i = 0; i < 7; i++) { @@ -783,7 +785,8 @@ static int drxx_open(struct drxk_state *state) dprintk(1, "\n"); /* stop lock indicator process */ - status = write16(state, SCU_RAM_GPIO__A, SCU_RAM_GPIO_HW_LOCK_IND_DISABLE); + status = write16(state, SCU_RAM_GPIO__A, + SCU_RAM_GPIO_HW_LOCK_IND_DISABLE); if (status < 0) goto error; /* Check device id */ @@ -817,7 +820,8 @@ static int get_device_capabilities(struct drxk_state *state) /* driver 0.9.0 */ /* stop lock indicator process */ - status = write16(state, SCU_RAM_GPIO__A, SCU_RAM_GPIO_HW_LOCK_IND_DISABLE); + status = write16(state, SCU_RAM_GPIO__A, + SCU_RAM_GPIO_HW_LOCK_IND_DISABLE); if (status < 0) goto error; status = write16(state, SIO_TOP_COMM_KEY__A, SIO_TOP_COMM_KEY_KEY); @@ -1055,22 +1059,28 @@ static int hi_cfg_command(struct drxk_state *state) mutex_lock(&state->mutex); - status = write16(state, SIO_HI_RA_RAM_PAR_6__A, state->m_hi_cfg_timeout); + status = write16(state, SIO_HI_RA_RAM_PAR_6__A, + state->m_hi_cfg_timeout); if (status < 0) goto error; - status = write16(state, SIO_HI_RA_RAM_PAR_5__A, state->m_hi_cfg_ctrl); + status = write16(state, SIO_HI_RA_RAM_PAR_5__A, + state->m_hi_cfg_ctrl); if (status < 0) goto error; - status = write16(state, SIO_HI_RA_RAM_PAR_4__A, state->m_hi_cfg_wake_up_key); + status = write16(state, SIO_HI_RA_RAM_PAR_4__A, + state->m_hi_cfg_wake_up_key); if (status < 0) goto error; - status = write16(state, SIO_HI_RA_RAM_PAR_3__A, state->m_hi_cfg_bridge_delay); + status = write16(state, SIO_HI_RA_RAM_PAR_3__A, + state->m_hi_cfg_bridge_delay); if (status < 0) goto error; - status = write16(state, SIO_HI_RA_RAM_PAR_2__A, state->m_hi_cfg_timing_div); + status = write16(state, SIO_HI_RA_RAM_PAR_2__A, + state->m_hi_cfg_timing_div); if (status < 0) goto error; - status = write16(state, SIO_HI_RA_RAM_PAR_1__A, SIO_HI_RA_RAM_PAR_1_PAR1_SEC_KEY); + status = write16(state, SIO_HI_RA_RAM_PAR_1__A, + SIO_HI_RA_RAM_PAR_1_PAR1_SEC_KEY); if (status < 0) goto error; status = hi_command(state, SIO_HI_RA_RAM_CMD_CONFIG, 0); @@ -1109,7 +1119,8 @@ static int mpegts_configure_pins(struct drxk_state *state, bool mpeg_enable) state->m_enable_parallel ? "parallel" : "serial"); /* stop lock indicator process */ - status = write16(state, SCU_RAM_GPIO__A, SCU_RAM_GPIO_HW_LOCK_IND_DISABLE); + status = write16(state, SCU_RAM_GPIO__A, + SCU_RAM_GPIO_HW_LOCK_IND_DISABLE); if (status < 0) goto error; @@ -1181,25 +1192,32 @@ static int mpegts_configure_pins(struct drxk_state *state, bool mpeg_enable) if (state->m_enable_parallel == true) { /* paralel -> enable MD1 to MD7 */ - status = write16(state, SIO_PDR_MD1_CFG__A, sio_pdr_mdx_cfg); + status = write16(state, SIO_PDR_MD1_CFG__A, + sio_pdr_mdx_cfg); if (status < 0) goto error; - status = write16(state, SIO_PDR_MD2_CFG__A, sio_pdr_mdx_cfg); + status = write16(state, SIO_PDR_MD2_CFG__A, + sio_pdr_mdx_cfg); if (status < 0) goto error; - status = write16(state, SIO_PDR_MD3_CFG__A, sio_pdr_mdx_cfg); + status = write16(state, SIO_PDR_MD3_CFG__A, + sio_pdr_mdx_cfg); if (status < 0) goto error; - status = write16(state, SIO_PDR_MD4_CFG__A, sio_pdr_mdx_cfg); + status = write16(state, SIO_PDR_MD4_CFG__A, + sio_pdr_mdx_cfg); if (status < 0) goto error; - status = write16(state, SIO_PDR_MD5_CFG__A, sio_pdr_mdx_cfg); + status = write16(state, SIO_PDR_MD5_CFG__A, + sio_pdr_mdx_cfg); if (status < 0) goto error; - status = write16(state, SIO_PDR_MD6_CFG__A, sio_pdr_mdx_cfg); + status = write16(state, SIO_PDR_MD6_CFG__A, + sio_pdr_mdx_cfg); if (status < 0) goto error; - status = write16(state, SIO_PDR_MD7_CFG__A, sio_pdr_mdx_cfg); + status = write16(state, SIO_PDR_MD7_CFG__A, + sio_pdr_mdx_cfg); if (status < 0) goto error; } else { @@ -1390,7 +1408,8 @@ static int dvbt_enable_ofdm_token_ring(struct drxk_state *state, bool enable) end = jiffies + msecs_to_jiffies(DRXK_OFDM_TR_SHUTDOWN_TIMEOUT); do { status = read16(state, SIO_OFDM_SH_OFDM_RING_STATUS__A, &data); - if ((status >= 0 && data == desired_status) || time_is_after_jiffies(end)) + if ((status >= 0 && data == desired_status) + || time_is_after_jiffies(end)) break; usleep_range(1000, 2000); } while (1); @@ -1487,7 +1506,8 @@ static int scu_command(struct drxk_state *state, int ii; for (ii = result_len - 1; ii >= 0; ii -= 1) { - status = read16(state, SCU_RAM_PARAM_0__A - ii, &result[ii]); + status = read16(state, SCU_RAM_PARAM_0__A - ii, + &result[ii]); if (status < 0) goto error; } @@ -1683,11 +1703,17 @@ static int power_down_dvbt(struct drxk_state *state, bool set_power_mode) goto error; if (data == SCU_COMM_EXEC_ACTIVE) { /* Send OFDM stop command */ - status = scu_command(state, SCU_RAM_COMMAND_STANDARD_OFDM | SCU_RAM_COMMAND_CMD_DEMOD_STOP, 0, NULL, 1, &cmd_result); + status = scu_command(state, + SCU_RAM_COMMAND_STANDARD_OFDM + | SCU_RAM_COMMAND_CMD_DEMOD_STOP, + 0, NULL, 1, &cmd_result); if (status < 0) goto error; /* Send OFDM reset command */ - status = scu_command(state, SCU_RAM_COMMAND_STANDARD_OFDM | SCU_RAM_COMMAND_CMD_DEMOD_RESET, 0, NULL, 1, &cmd_result); + status = scu_command(state, + SCU_RAM_COMMAND_STANDARD_OFDM + | SCU_RAM_COMMAND_CMD_DEMOD_RESET, + 0, NULL, 1, &cmd_result); if (status < 0) goto error; } @@ -1733,7 +1759,8 @@ static int setoperation_mode(struct drxk_state *state, */ /* disable HW lock indicator */ - status = write16(state, SCU_RAM_GPIO__A, SCU_RAM_GPIO_HW_LOCK_IND_DISABLE); + status = write16(state, SCU_RAM_GPIO__A, + SCU_RAM_GPIO_HW_LOCK_IND_DISABLE); if (status < 0) goto error; @@ -2083,7 +2110,8 @@ static int mpegts_dto_setup(struct drxk_state *state, status = write32(state, FEC_OC_RCN_CTL_RATE_LO__A, fec_oc_rcn_ctl_rate); if (status < 0) goto error; - status = write16(state, FEC_OC_TMD_INT_UPD_RATE__A, fec_oc_tmd_int_upd_rate); + status = write16(state, FEC_OC_TMD_INT_UPD_RATE__A, + fec_oc_tmd_int_upd_rate); if (status < 0) goto error; status = write16(state, FEC_OC_TMD_MODE__A, fec_oc_tmd_mode); @@ -2193,17 +2221,21 @@ static int set_agc_rf(struct drxk_state *state, /* Set TOP, only if IF-AGC is in AUTO mode */ if (p_if_agc_settings->ctrl_mode == DRXK_AGC_CTRL_AUTO) - status = write16(state, SCU_RAM_AGC_IF_IACCU_HI_TGT_MAX__A, p_agc_cfg->top); + status = write16(state, + SCU_RAM_AGC_IF_IACCU_HI_TGT_MAX__A, + p_agc_cfg->top); if (status < 0) goto error; /* Cut-Off current */ - status = write16(state, SCU_RAM_AGC_RF_IACCU_HI_CO__A, p_agc_cfg->cut_off_current); + status = write16(state, SCU_RAM_AGC_RF_IACCU_HI_CO__A, + p_agc_cfg->cut_off_current); if (status < 0) goto error; /* Max. output level */ - status = write16(state, SCU_RAM_AGC_RF_MAX__A, p_agc_cfg->max_output_level); + status = write16(state, SCU_RAM_AGC_RF_MAX__A, + p_agc_cfg->max_output_level); if (status < 0) goto error; @@ -2238,7 +2270,8 @@ static int set_agc_rf(struct drxk_state *state, goto error; /* Write value to output pin */ - status = write16(state, SCU_RAM_AGC_RF_IACCU_HI__A, p_agc_cfg->output_level); + status = write16(state, SCU_RAM_AGC_RF_IACCU_HI__A, + p_agc_cfg->output_level); if (status < 0) goto error; break; @@ -2332,7 +2365,8 @@ static int set_agc_if(struct drxk_state *state, if (p_rf_agc_settings == NULL) return -1; /* Restore TOP */ - status = write16(state, SCU_RAM_AGC_IF_IACCU_HI_TGT_MAX__A, p_rf_agc_settings->top); + status = write16(state, SCU_RAM_AGC_IF_IACCU_HI_TGT_MAX__A, + p_rf_agc_settings->top); if (status < 0) goto error; break; @@ -2365,7 +2399,8 @@ static int set_agc_if(struct drxk_state *state, goto error; /* Write value to output pin */ - status = write16(state, SCU_RAM_AGC_IF_IACCU_HI_TGT_MAX__A, p_agc_cfg->output_level); + status = write16(state, SCU_RAM_AGC_IF_IACCU_HI_TGT_MAX__A, + p_agc_cfg->output_level); if (status < 0) goto error; break; @@ -2470,16 +2505,20 @@ static int get_dvbt_signal_to_noise(struct drxk_state *state, dprintk(1, "\n"); - status = read16(state, OFDM_EQ_TOP_TD_TPS_PWR_OFS__A, &eq_reg_td_tps_pwr_ofs); + status = read16(state, OFDM_EQ_TOP_TD_TPS_PWR_OFS__A, + &eq_reg_td_tps_pwr_ofs); if (status < 0) goto error; - status = read16(state, OFDM_EQ_TOP_TD_REQ_SMB_CNT__A, &eq_reg_td_req_smb_cnt); + status = read16(state, OFDM_EQ_TOP_TD_REQ_SMB_CNT__A, + &eq_reg_td_req_smb_cnt); if (status < 0) goto error; - status = read16(state, OFDM_EQ_TOP_TD_SQR_ERR_EXP__A, &eq_reg_td_sqr_err_exp); + status = read16(state, OFDM_EQ_TOP_TD_SQR_ERR_EXP__A, + &eq_reg_td_sqr_err_exp); if (status < 0) goto error; - status = read16(state, OFDM_EQ_TOP_TD_SQR_ERR_I__A, ®_data); + status = read16(state, OFDM_EQ_TOP_TD_SQR_ERR_I__A, + ®_data); if (status < 0) goto error; /* Extend SQR_ERR_I operational range */ @@ -2497,7 +2536,8 @@ static int get_dvbt_signal_to_noise(struct drxk_state *state, (eq_reg_td_sqr_err_q < 0x00000FFFUL)) eq_reg_td_sqr_err_q += 0x00010000UL; - status = read16(state, OFDM_SC_RA_RAM_OP_PARAM__A, &transmission_params); + status = read16(state, OFDM_SC_RA_RAM_OP_PARAM__A, + &transmission_params); if (status < 0) goto error; @@ -2604,12 +2644,14 @@ static int get_dvbt_quality(struct drxk_state *state, s32 *p_quality) status = get_dvbt_signal_to_noise(state, &signal_to_noise); if (status < 0) break; - status = read16(state, OFDM_EQ_TOP_TD_TPS_CONST__A, &constellation); + status = read16(state, OFDM_EQ_TOP_TD_TPS_CONST__A, + &constellation); if (status < 0) break; constellation &= OFDM_EQ_TOP_TD_TPS_CONST__M; - status = read16(state, OFDM_EQ_TOP_TD_TPS_CODE_HP__A, &code_rate); + status = read16(state, OFDM_EQ_TOP_TD_TPS_CODE_HP__A, + &code_rate); if (status < 0) break; code_rate &= OFDM_EQ_TOP_TD_TPS_CODE_HP__M; @@ -2723,15 +2765,18 @@ static int ConfigureI2CBridge(struct drxk_state *state, bool b_enable_bridge) if (state->no_i2c_bridge) return 0; - status = write16(state, SIO_HI_RA_RAM_PAR_1__A, SIO_HI_RA_RAM_PAR_1_PAR1_SEC_KEY); + status = write16(state, SIO_HI_RA_RAM_PAR_1__A, + SIO_HI_RA_RAM_PAR_1_PAR1_SEC_KEY); if (status < 0) goto error; if (b_enable_bridge) { - status = write16(state, SIO_HI_RA_RAM_PAR_2__A, SIO_HI_RA_RAM_PAR_2_BRD_CFG_CLOSED); + status = write16(state, SIO_HI_RA_RAM_PAR_2__A, + SIO_HI_RA_RAM_PAR_2_BRD_CFG_CLOSED); if (status < 0) goto error; } else { - status = write16(state, SIO_HI_RA_RAM_PAR_2__A, SIO_HI_RA_RAM_PAR_2_BRD_CFG_OPEN); + status = write16(state, SIO_HI_RA_RAM_PAR_2__A, + SIO_HI_RA_RAM_PAR_2_BRD_CFG_OPEN); if (status < 0) goto error; } @@ -3013,7 +3058,8 @@ static int init_agc(struct drxk_state *state, bool is_dtv) ingain_tgt_max = 5119; fast_clp_ctrl_delay = state->m_qam_if_agc_cfg.fast_clip_ctrl_delay; - status = write16(state, SCU_RAM_AGC_FAST_CLP_CTRL_DELAY__A, fast_clp_ctrl_delay); + status = write16(state, SCU_RAM_AGC_FAST_CLP_CTRL_DELAY__A, + fast_clp_ctrl_delay); if (status < 0) goto error; @@ -3029,10 +3075,12 @@ static int init_agc(struct drxk_state *state, bool is_dtv) status = write16(state, SCU_RAM_AGC_INGAIN_TGT_MAX__A, ingain_tgt_max); if (status < 0) goto error; - status = write16(state, SCU_RAM_AGC_IF_IACCU_HI_TGT_MIN__A, if_iaccu_hi_tgt_min); + status = write16(state, SCU_RAM_AGC_IF_IACCU_HI_TGT_MIN__A, + if_iaccu_hi_tgt_min); if (status < 0) goto error; - status = write16(state, SCU_RAM_AGC_IF_IACCU_HI_TGT_MAX__A, if_iaccu_hi_tgt_max); + status = write16(state, SCU_RAM_AGC_IF_IACCU_HI_TGT_MAX__A, + if_iaccu_hi_tgt_max); if (status < 0) goto error; status = write16(state, SCU_RAM_AGC_IF_IACCU_HI__A, 0); @@ -3054,10 +3102,12 @@ static int init_agc(struct drxk_state *state, bool is_dtv) if (status < 0) goto error; - status = write16(state, SCU_RAM_AGC_KI_INNERGAIN_MIN__A, ki_innergain_min); + status = write16(state, SCU_RAM_AGC_KI_INNERGAIN_MIN__A, + ki_innergain_min); if (status < 0) goto error; - status = write16(state, SCU_RAM_AGC_IF_IACCU_HI_TGT__A, if_iaccu_hi_tgt); + status = write16(state, SCU_RAM_AGC_IF_IACCU_HI_TGT__A, + if_iaccu_hi_tgt); if (status < 0) goto error; status = write16(state, SCU_RAM_AGC_CLP_CYCLEN__A, clp_cyclen); @@ -3158,7 +3208,8 @@ static int dvbtqam_get_acc_pkt_err(struct drxk_state *state, u16 *packet_err) if (packet_err == NULL) status = write16(state, SCU_RAM_FEC_ACCUM_PKT_FAILURES__A, 0); else - status = read16(state, SCU_RAM_FEC_ACCUM_PKT_FAILURES__A, packet_err); + status = read16(state, SCU_RAM_FEC_ACCUM_PKT_FAILURES__A, + packet_err); if (status < 0) pr_err("Error %d on %s\n", status, __func__); return status; @@ -3332,7 +3383,7 @@ static int dvbt_ctrl_set_fr_enable(struct drxk_state *state, bool *enabled) } static int dvbt_ctrl_set_echo_threshold(struct drxk_state *state, - struct drxk_cfg_dvbt_echo_thres_t *echo_thres) + struct drxk_cfg_dvbt_echo_thres_t *echo_thres) { u16 data = 0; int status; @@ -3421,7 +3472,8 @@ static int dvbt_activate_presets(struct drxk_state *state) status = dvbt_ctrl_set_echo_threshold(state, &echo_thres8k); if (status < 0) goto error; - status = write16(state, SCU_RAM_AGC_INGAIN_TGT_MAX__A, state->m_dvbt_if_agc_cfg.ingain_tgt_max); + status = write16(state, SCU_RAM_AGC_INGAIN_TGT_MAX__A, + state->m_dvbt_if_agc_cfg.ingain_tgt_max); error: if (status < 0) pr_err("Error %d on %s\n", status, __func__); @@ -3451,12 +3503,17 @@ static int set_dvbt_standard(struct drxk_state *state, /* added antenna switch */ switch_antenna_to_dvbt(state); /* send OFDM reset command */ - status = scu_command(state, SCU_RAM_COMMAND_STANDARD_OFDM | SCU_RAM_COMMAND_CMD_DEMOD_RESET, 0, NULL, 1, &cmd_result); + status = scu_command(state, + SCU_RAM_COMMAND_STANDARD_OFDM + | SCU_RAM_COMMAND_CMD_DEMOD_RESET, + 0, NULL, 1, &cmd_result); if (status < 0) goto error; /* send OFDM setenv command */ - status = scu_command(state, SCU_RAM_COMMAND_STANDARD_OFDM | SCU_RAM_COMMAND_CMD_DEMOD_SET_ENV, 0, NULL, 1, &cmd_result); + status = scu_command(state, SCU_RAM_COMMAND_STANDARD_OFDM + | SCU_RAM_COMMAND_CMD_DEMOD_SET_ENV, + 0, NULL, 1, &cmd_result); if (status < 0) goto error; @@ -3510,7 +3567,7 @@ static int set_dvbt_standard(struct drxk_state *state, status = write16(state, IQM_RC_STRETCH__A, 16); if (status < 0) goto error; - status = write16(state, IQM_CF_OUT_ENA__A, 0x4); /* enable output 2 */ + status = write16(state, IQM_CF_OUT_ENA__A, 0x4); /* enable output 2 */ if (status < 0) goto error; status = write16(state, IQM_CF_DS_ENA__A, 0x4); /* decimate output 2 */ @@ -3531,7 +3588,8 @@ static int set_dvbt_standard(struct drxk_state *state, if (status < 0) goto error; - status = bl_chain_cmd(state, DRXK_BL_ROM_OFFSET_TAPS_DVBT, DRXK_BLCC_NR_ELEMENTS_TAPS, DRXK_BLC_TIMEOUT); + status = bl_chain_cmd(state, DRXK_BL_ROM_OFFSET_TAPS_DVBT, + DRXK_BLCC_NR_ELEMENTS_TAPS, DRXK_BLC_TIMEOUT); if (status < 0) goto error; @@ -3585,7 +3643,8 @@ static int set_dvbt_standard(struct drxk_state *state, if (!state->m_drxk_a3_rom_code) { /* AGCInit() is not done for DVBT, so set agcfast_clip_ctrl_delay */ - status = write16(state, SCU_RAM_AGC_FAST_CLP_CTRL_DELAY__A, state->m_dvbt_if_agc_cfg.fast_clip_ctrl_delay); + status = write16(state, SCU_RAM_AGC_FAST_CLP_CTRL_DELAY__A, + state->m_dvbt_if_agc_cfg.fast_clip_ctrl_delay); if (status < 0) goto error; } @@ -3650,7 +3709,9 @@ static int dvbt_start(struct drxk_state *state) /* start correct processes to get in lock */ /* DRXK: OFDM_SC_RA_RAM_PROC_LOCKTRACK is no longer in mapfile! */ param1 = OFDM_SC_RA_RAM_LOCKTRACK_MIN; - status = dvbt_sc_command(state, OFDM_SC_RA_RAM_CMD_PROC_START, 0, OFDM_SC_RA_RAM_SW_EVENT_RUN_NMASK__M, param1, 0, 0, 0); + status = dvbt_sc_command(state, OFDM_SC_RA_RAM_CMD_PROC_START, 0, + OFDM_SC_RA_RAM_SW_EVENT_RUN_NMASK__M, param1, + 0, 0, 0); if (status < 0) goto error; /* start FEC OC */ @@ -3686,9 +3747,12 @@ static int set_dvbt(struct drxk_state *state, u16 intermediate_freqk_hz, u16 param1; int status; - dprintk(1, "IF =%d, TFO = %d\n", intermediate_freqk_hz, tuner_freq_offset); + dprintk(1, "IF =%d, TFO = %d\n", + intermediate_freqk_hz, tuner_freq_offset); - status = scu_command(state, SCU_RAM_COMMAND_STANDARD_OFDM | SCU_RAM_COMMAND_CMD_DEMOD_STOP, 0, NULL, 1, &cmd_result); + status = scu_command(state, SCU_RAM_COMMAND_STANDARD_OFDM + | SCU_RAM_COMMAND_CMD_DEMOD_STOP, + 0, NULL, 1, &cmd_result); if (status < 0) goto error; @@ -3711,7 +3775,7 @@ static int set_dvbt(struct drxk_state *state, u16 intermediate_freqk_hz, if (status < 0) goto error; - /*== Write channel settings to device =====================================*/ + /*== Write channel settings to device ================================*/ /* mode */ switch (state->props.transmission_mode) { @@ -3834,71 +3898,92 @@ static int set_dvbt(struct drxk_state *state, u16 intermediate_freqk_hz, break; } - /* SAW filter selection: normaly not necesarry, but if wanted - the application can select a SAW filter via the driver by using UIOs */ + /* + * SAW filter selection: normaly not necesarry, but if wanted + * the application can select a SAW filter via the driver by + * using UIOs + */ + /* First determine real bandwidth (Hz) */ /* Also set delay for impulse noise cruncher */ - /* Also set parameters for EC_OC fix, note EC_OC_REG_TMD_HIL_MAR is changed - by SC for fix for some 8K,1/8 guard but is restored by InitEC and ResetEC - functions */ + /* + * Also set parameters for EC_OC fix, note EC_OC_REG_TMD_HIL_MAR is + * changed by SC for fix for some 8K,1/8 guard but is restored by + * InitEC and ResetEC functions + */ switch (state->props.bandwidth_hz) { case 0: state->props.bandwidth_hz = 8000000; /* fall though */ case 8000000: bandwidth = DRXK_BANDWIDTH_8MHZ_IN_HZ; - status = write16(state, OFDM_SC_RA_RAM_SRMM_FIX_FACT_8K__A, 3052); + status = write16(state, OFDM_SC_RA_RAM_SRMM_FIX_FACT_8K__A, + 3052); if (status < 0) goto error; /* cochannel protection for PAL 8 MHz */ - status = write16(state, OFDM_SC_RA_RAM_NI_INIT_8K_PER_LEFT__A, 7); + status = write16(state, OFDM_SC_RA_RAM_NI_INIT_8K_PER_LEFT__A, + 7); if (status < 0) goto error; - status = write16(state, OFDM_SC_RA_RAM_NI_INIT_8K_PER_RIGHT__A, 7); + status = write16(state, OFDM_SC_RA_RAM_NI_INIT_8K_PER_RIGHT__A, + 7); if (status < 0) goto error; - status = write16(state, OFDM_SC_RA_RAM_NI_INIT_2K_PER_LEFT__A, 7); + status = write16(state, OFDM_SC_RA_RAM_NI_INIT_2K_PER_LEFT__A, + 7); if (status < 0) goto error; - status = write16(state, OFDM_SC_RA_RAM_NI_INIT_2K_PER_RIGHT__A, 1); + status = write16(state, OFDM_SC_RA_RAM_NI_INIT_2K_PER_RIGHT__A, + 1); if (status < 0) goto error; break; case 7000000: bandwidth = DRXK_BANDWIDTH_7MHZ_IN_HZ; - status = write16(state, OFDM_SC_RA_RAM_SRMM_FIX_FACT_8K__A, 3491); + status = write16(state, OFDM_SC_RA_RAM_SRMM_FIX_FACT_8K__A, + 3491); if (status < 0) goto error; /* cochannel protection for PAL 7 MHz */ - status = write16(state, OFDM_SC_RA_RAM_NI_INIT_8K_PER_LEFT__A, 8); + status = write16(state, OFDM_SC_RA_RAM_NI_INIT_8K_PER_LEFT__A, + 8); if (status < 0) goto error; - status = write16(state, OFDM_SC_RA_RAM_NI_INIT_8K_PER_RIGHT__A, 8); + status = write16(state, OFDM_SC_RA_RAM_NI_INIT_8K_PER_RIGHT__A, + 8); if (status < 0) goto error; - status = write16(state, OFDM_SC_RA_RAM_NI_INIT_2K_PER_LEFT__A, 4); + status = write16(state, OFDM_SC_RA_RAM_NI_INIT_2K_PER_LEFT__A, + 4); if (status < 0) goto error; - status = write16(state, OFDM_SC_RA_RAM_NI_INIT_2K_PER_RIGHT__A, 1); + status = write16(state, OFDM_SC_RA_RAM_NI_INIT_2K_PER_RIGHT__A, + 1); if (status < 0) goto error; break; case 6000000: bandwidth = DRXK_BANDWIDTH_6MHZ_IN_HZ; - status = write16(state, OFDM_SC_RA_RAM_SRMM_FIX_FACT_8K__A, 4073); + status = write16(state, OFDM_SC_RA_RAM_SRMM_FIX_FACT_8K__A, + 4073); if (status < 0) goto error; /* cochannel protection for NTSC 6 MHz */ - status = write16(state, OFDM_SC_RA_RAM_NI_INIT_8K_PER_LEFT__A, 19); + status = write16(state, OFDM_SC_RA_RAM_NI_INIT_8K_PER_LEFT__A, + 19); if (status < 0) goto error; - status = write16(state, OFDM_SC_RA_RAM_NI_INIT_8K_PER_RIGHT__A, 19); + status = write16(state, OFDM_SC_RA_RAM_NI_INIT_8K_PER_RIGHT__A, + 19); if (status < 0) goto error; - status = write16(state, OFDM_SC_RA_RAM_NI_INIT_2K_PER_LEFT__A, 14); + status = write16(state, OFDM_SC_RA_RAM_NI_INIT_2K_PER_LEFT__A, + 14); if (status < 0) goto error; - status = write16(state, OFDM_SC_RA_RAM_NI_INIT_2K_PER_RIGHT__A, 1); + status = write16(state, OFDM_SC_RA_RAM_NI_INIT_2K_PER_RIGHT__A, + 1); if (status < 0) goto error; break; @@ -3914,13 +3999,16 @@ static int set_dvbt(struct drxk_state *state, u16 intermediate_freqk_hz, ((SysFreq / BandWidth) * (2^21)) - (2^23) */ /* (SysFreq / BandWidth) * (2^28) */ - /* assert (MAX(sysClk)/MIN(bandwidth) < 16) - => assert(MAX(sysClk) < 16*MIN(bandwidth)) - => assert(109714272 > 48000000) = true so Frac 28 can be used */ + /* + * assert (MAX(sysClk)/MIN(bandwidth) < 16) + * => assert(MAX(sysClk) < 16*MIN(bandwidth)) + * => assert(109714272 > 48000000) = true + * so Frac 28 can be used + */ iqm_rc_rate_ofs = Frac28a((u32) ((state->m_sys_clock_freq * 1000) / 3), bandwidth); - /* (SysFreq / BandWidth) * (2^21), rounding before truncating */ + /* (SysFreq / BandWidth) * (2^21), rounding before truncating */ if ((iqm_rc_rate_ofs & 0x7fL) >= 0x40) iqm_rc_rate_ofs += 0x80L; iqm_rc_rate_ofs = iqm_rc_rate_ofs >> 7; @@ -3942,11 +4030,12 @@ static int set_dvbt(struct drxk_state *state, u16 intermediate_freqk_hz, if (status < 0) goto error; #endif - status = set_frequency_shifter(state, intermediate_freqk_hz, tuner_freq_offset, true); + status = set_frequency_shifter(state, intermediate_freqk_hz, + tuner_freq_offset, true); if (status < 0) goto error; - /*== start SC, write channel settings to SC ===============================*/ + /*== start SC, write channel settings to SC ==========================*/ /* Activate SCU to enable SCU commands */ status = write16(state, SCU_COMM_EXEC__A, SCU_COMM_EXEC_ACTIVE); @@ -3962,7 +4051,9 @@ static int set_dvbt(struct drxk_state *state, u16 intermediate_freqk_hz, goto error; - status = scu_command(state, SCU_RAM_COMMAND_STANDARD_OFDM | SCU_RAM_COMMAND_CMD_DEMOD_START, 0, NULL, 1, &cmd_result); + status = scu_command(state, SCU_RAM_COMMAND_STANDARD_OFDM + | SCU_RAM_COMMAND_CMD_DEMOD_START, + 0, NULL, 1, &cmd_result); if (status < 0) goto error; @@ -4071,7 +4162,9 @@ static int power_down_qam(struct drxk_state *state) status = write16(state, QAM_COMM_EXEC__A, QAM_COMM_EXEC_STOP); if (status < 0) goto error; - status = scu_command(state, SCU_RAM_COMMAND_STANDARD_QAM | SCU_RAM_COMMAND_CMD_DEMOD_STOP, 0, NULL, 1, &cmd_result); + status = scu_command(state, SCU_RAM_COMMAND_STANDARD_QAM + | SCU_RAM_COMMAND_CMD_DEMOD_STOP, + 0, NULL, 1, &cmd_result); if (status < 0) goto error; } @@ -4139,7 +4232,7 @@ static int set_qam_measurement(struct drxk_state *state, if (status < 0) goto error; - fec_bits_desired /= 1000; /* symbol_rate [Hz] -> symbol_rate [kHz] */ + fec_bits_desired /= 1000; /* symbol_rate [Hz] -> symbol_rate [kHz] */ fec_bits_desired *= 500; /* meas. period [ms] */ /* Annex A/C: bits/RsPeriod = 204 * 8 = 1632 */ @@ -4162,7 +4255,8 @@ static int set_qam_measurement(struct drxk_state *state, status = write16(state, FEC_RS_MEASUREMENT_PERIOD__A, fec_rs_period); if (status < 0) goto error; - status = write16(state, FEC_RS_MEASUREMENT_PRESCALE__A, fec_rs_prescale); + status = write16(state, FEC_RS_MEASUREMENT_PRESCALE__A, + fec_rs_prescale); if (status < 0) goto error; status = write16(state, FEC_OC_SNC_FAIL_PERIOD__A, fec_rs_period); @@ -4228,7 +4322,8 @@ static int set_qam16(struct drxk_state *state) goto error; /* QAM Slicer Settings */ - status = write16(state, SCU_RAM_QAM_SL_SIG_POWER__A, DRXK_QAM_SL_SIG_POWER_QAM16); + status = write16(state, SCU_RAM_QAM_SL_SIG_POWER__A, + DRXK_QAM_SL_SIG_POWER_QAM16); if (status < 0) goto error; @@ -4424,7 +4519,8 @@ static int set_qam32(struct drxk_state *state) /* QAM Slicer Settings */ - status = write16(state, SCU_RAM_QAM_SL_SIG_POWER__A, DRXK_QAM_SL_SIG_POWER_QAM32); + status = write16(state, SCU_RAM_QAM_SL_SIG_POWER__A, + DRXK_QAM_SL_SIG_POWER_QAM32); if (status < 0) goto error; @@ -4617,7 +4713,8 @@ static int set_qam64(struct drxk_state *state) goto error; /* QAM Slicer Settings */ - status = write16(state, SCU_RAM_QAM_SL_SIG_POWER__A, DRXK_QAM_SL_SIG_POWER_QAM64); + status = write16(state, SCU_RAM_QAM_SL_SIG_POWER__A, + DRXK_QAM_SL_SIG_POWER_QAM64); if (status < 0) goto error; @@ -4813,7 +4910,8 @@ static int set_qam128(struct drxk_state *state) /* QAM Slicer Settings */ - status = write16(state, SCU_RAM_QAM_SL_SIG_POWER__A, DRXK_QAM_SL_SIG_POWER_QAM128); + status = write16(state, SCU_RAM_QAM_SL_SIG_POWER__A, + DRXK_QAM_SL_SIG_POWER_QAM128); if (status < 0) goto error; @@ -5008,7 +5106,8 @@ static int set_qam256(struct drxk_state *state) /* QAM Slicer Settings */ - status = write16(state, SCU_RAM_QAM_SL_SIG_POWER__A, DRXK_QAM_SL_SIG_POWER_QAM256); + status = write16(state, SCU_RAM_QAM_SL_SIG_POWER__A, + DRXK_QAM_SL_SIG_POWER_QAM256); if (status < 0) goto error; @@ -5156,7 +5255,9 @@ static int qam_reset_qam(struct drxk_state *state) if (status < 0) goto error; - status = scu_command(state, SCU_RAM_COMMAND_STANDARD_QAM | SCU_RAM_COMMAND_CMD_DEMOD_RESET, 0, NULL, 1, &cmd_result); + status = scu_command(state, SCU_RAM_COMMAND_STANDARD_QAM + | SCU_RAM_COMMAND_CMD_DEMOD_RESET, + 0, NULL, 1, &cmd_result); error: if (status < 0) pr_err("Error %d on %s\n", status, __func__); @@ -5267,8 +5368,10 @@ static int get_qam_lock_status(struct drxk_state *state, u32 *p_lock_status) } else { /* 0xC000 NEVER LOCKED */ /* (system will never be able to lock to the signal) */ - /* TODO: check this, intermediate & standard specific lock states are not - taken into account here */ + /* + * TODO: check this, intermediate & standard specific lock + * states are not taken into account here + */ *p_lock_status = NEVER_LOCK; } return status; @@ -5300,13 +5403,15 @@ static int qam_demodulator_command(struct drxk_state *state, set_env_parameters[0] = QAM_TOP_ANNEX_A; status = scu_command(state, - SCU_RAM_COMMAND_STANDARD_QAM | SCU_RAM_COMMAND_CMD_DEMOD_SET_ENV, + SCU_RAM_COMMAND_STANDARD_QAM + | SCU_RAM_COMMAND_CMD_DEMOD_SET_ENV, 1, set_env_parameters, 1, &cmd_result); if (status < 0) goto error; status = scu_command(state, - SCU_RAM_COMMAND_STANDARD_QAM | SCU_RAM_COMMAND_CMD_DEMOD_SET_PARAM, + SCU_RAM_COMMAND_STANDARD_QAM + | SCU_RAM_COMMAND_CMD_DEMOD_SET_PARAM, number_of_parameters, set_param_parameters, 1, &cmd_result); } else if (number_of_parameters == 4) { @@ -5321,7 +5426,8 @@ static int qam_demodulator_command(struct drxk_state *state, /* set_param_parameters[3] |= QAM_LOCKRANGE_NORMAL; */ status = scu_command(state, - SCU_RAM_COMMAND_STANDARD_QAM | SCU_RAM_COMMAND_CMD_DEMOD_SET_PARAM, + SCU_RAM_COMMAND_STANDARD_QAM + | SCU_RAM_COMMAND_CMD_DEMOD_SET_PARAM, number_of_parameters, set_param_parameters, 1, &cmd_result); } else { @@ -5439,12 +5545,14 @@ static int set_qam(struct drxk_state *state, u16 intermediate_freqk_hz, if (status < 0) goto error; #endif - status = set_frequency_shifter(state, intermediate_freqk_hz, tuner_freq_offset, true); + status = set_frequency_shifter(state, intermediate_freqk_hz, + tuner_freq_offset, true); if (status < 0) goto error; /* Setup BER measurement */ - status = set_qam_measurement(state, state->m_constellation, state->props.symbol_rate); + status = set_qam_measurement(state, state->m_constellation, + state->props.symbol_rate); if (status < 0) goto error; @@ -5517,7 +5625,8 @@ static int set_qam(struct drxk_state *state, u16 intermediate_freqk_hz, goto error; /* Mirroring, QAM-block starting point not inverted */ - status = write16(state, QAM_SY_SP_INV__A, QAM_SY_SP_INV_SPECTRUM_INV_DIS); + status = write16(state, QAM_SY_SP_INV__A, + QAM_SY_SP_INV_SPECTRUM_INV_DIS); if (status < 0) goto error; @@ -5578,7 +5687,9 @@ static int set_qam(struct drxk_state *state, u16 intermediate_freqk_hz, goto error; /* STEP 5: start QAM demodulator (starts FEC, QAM and IQM HW) */ - status = scu_command(state, SCU_RAM_COMMAND_STANDARD_QAM | SCU_RAM_COMMAND_CMD_DEMOD_START, 0, NULL, 1, &cmd_result); + status = scu_command(state, SCU_RAM_COMMAND_STANDARD_QAM + | SCU_RAM_COMMAND_CMD_DEMOD_START, + 0, NULL, 1, &cmd_result); if (status < 0) goto error; @@ -5628,13 +5739,22 @@ static int set_qam_standard(struct drxk_state *state, boot loader from ROM table */ switch (o_mode) { case OM_QAM_ITU_A: - status = bl_chain_cmd(state, DRXK_BL_ROM_OFFSET_TAPS_ITU_A, DRXK_BLCC_NR_ELEMENTS_TAPS, DRXK_BLC_TIMEOUT); + status = bl_chain_cmd(state, DRXK_BL_ROM_OFFSET_TAPS_ITU_A, + DRXK_BLCC_NR_ELEMENTS_TAPS, + DRXK_BLC_TIMEOUT); break; case OM_QAM_ITU_C: - status = bl_direct_cmd(state, IQM_CF_TAP_RE0__A, DRXK_BL_ROM_OFFSET_TAPS_ITU_C, DRXK_BLDC_NR_ELEMENTS_TAPS, DRXK_BLC_TIMEOUT); + status = bl_direct_cmd(state, IQM_CF_TAP_RE0__A, + DRXK_BL_ROM_OFFSET_TAPS_ITU_C, + DRXK_BLDC_NR_ELEMENTS_TAPS, + DRXK_BLC_TIMEOUT); if (status < 0) goto error; - status = bl_direct_cmd(state, IQM_CF_TAP_IM0__A, DRXK_BL_ROM_OFFSET_TAPS_ITU_C, DRXK_BLDC_NR_ELEMENTS_TAPS, DRXK_BLC_TIMEOUT); + status = bl_direct_cmd(state, + IQM_CF_TAP_IM0__A, + DRXK_BL_ROM_OFFSET_TAPS_ITU_C, + DRXK_BLDC_NR_ELEMENTS_TAPS, + DRXK_BLC_TIMEOUT); break; default: status = -EINVAL; @@ -5642,13 +5762,14 @@ static int set_qam_standard(struct drxk_state *state, if (status < 0) goto error; - status = write16(state, IQM_CF_OUT_ENA__A, (1 << IQM_CF_OUT_ENA_QAM__B)); + status = write16(state, IQM_CF_OUT_ENA__A, 1 << IQM_CF_OUT_ENA_QAM__B); if (status < 0) goto error; status = write16(state, IQM_CF_SYMMETRIC__A, 0); if (status < 0) goto error; - status = write16(state, IQM_CF_MIDTAP__A, ((1 << IQM_CF_MIDTAP_RE__B) | (1 << IQM_CF_MIDTAP_IM__B))); + status = write16(state, IQM_CF_MIDTAP__A, + ((1 << IQM_CF_MIDTAP_RE__B) | (1 << IQM_CF_MIDTAP_IM__B))); if (status < 0) goto error; @@ -5760,7 +5881,8 @@ static int write_gpio(struct drxk_state *state) dprintk(1, "\n"); /* stop lock indicator process */ - status = write16(state, SCU_RAM_GPIO__A, SCU_RAM_GPIO_HW_LOCK_IND_DISABLE); + status = write16(state, SCU_RAM_GPIO__A, + SCU_RAM_GPIO_HW_LOCK_IND_DISABLE); if (status < 0) goto error; @@ -5772,7 +5894,8 @@ static int write_gpio(struct drxk_state *state) if (state->m_has_sawsw) { if (state->uio_mask & 0x0001) { /* UIO-1 */ /* write to io pad configuration register - output mode */ - status = write16(state, SIO_PDR_SMA_TX_CFG__A, state->m_gpio_cfg); + status = write16(state, SIO_PDR_SMA_TX_CFG__A, + state->m_gpio_cfg); if (status < 0) goto error; @@ -5791,7 +5914,8 @@ static int write_gpio(struct drxk_state *state) } if (state->uio_mask & 0x0002) { /* UIO-2 */ /* write to io pad configuration register - output mode */ - status = write16(state, SIO_PDR_SMA_RX_CFG__A, state->m_gpio_cfg); + status = write16(state, SIO_PDR_SMA_RX_CFG__A, + state->m_gpio_cfg); if (status < 0) goto error; @@ -5810,7 +5934,8 @@ static int write_gpio(struct drxk_state *state) } if (state->uio_mask & 0x0004) { /* UIO-3 */ /* write to io pad configuration register - output mode */ - status = write16(state, SIO_PDR_GPIO_CFG__A, state->m_gpio_cfg); + status = write16(state, SIO_PDR_GPIO_CFG__A, + state->m_gpio_cfg); if (status < 0) goto error; @@ -5909,7 +6034,8 @@ static int power_down_device(struct drxk_state *state) if (status < 0) goto error; - status = write16(state, SIO_CC_PWD_MODE__A, SIO_CC_PWD_MODE_LEVEL_CLOCK); + status = write16(state, SIO_CC_PWD_MODE__A, + SIO_CC_PWD_MODE_LEVEL_CLOCK); if (status < 0) goto error; status = write16(state, SIO_CC_UPDATE__A, SIO_CC_UPDATE_KEY); @@ -5940,13 +6066,19 @@ static int init_drxk(struct drxk_state *state) if (status < 0) goto error; /* Soft reset of OFDM-, sys- and osc-clockdomain */ - status = write16(state, SIO_CC_SOFT_RST__A, SIO_CC_SOFT_RST_OFDM__M | SIO_CC_SOFT_RST_SYS__M | SIO_CC_SOFT_RST_OSC__M); + status = write16(state, SIO_CC_SOFT_RST__A, + SIO_CC_SOFT_RST_OFDM__M + | SIO_CC_SOFT_RST_SYS__M + | SIO_CC_SOFT_RST_OSC__M); if (status < 0) goto error; status = write16(state, SIO_CC_UPDATE__A, SIO_CC_UPDATE_KEY); if (status < 0) goto error; - /* TODO is this needed, if yes how much delay in worst case scenario */ + /* + * TODO is this needed? If yes, how much delay in + * worst case scenario + */ usleep_range(1000, 2000); state->m_drxk_a3_patch_code = true; status = get_device_capabilities(state); @@ -5979,7 +6111,8 @@ static int init_drxk(struct drxk_state *state) && !(state->m_DRXK_A2_ROM_CODE)) #endif { - status = write16(state, SCU_RAM_GPIO__A, SCU_RAM_GPIO_HW_LOCK_IND_DISABLE); + status = write16(state, SCU_RAM_GPIO__A, + SCU_RAM_GPIO_HW_LOCK_IND_DISABLE); if (status < 0) goto error; } @@ -5998,12 +6131,14 @@ static int init_drxk(struct drxk_state *state) goto error; /* enable token-ring bus through OFDM block for possible ucode upload */ - status = write16(state, SIO_OFDM_SH_OFDM_RING_ENABLE__A, SIO_OFDM_SH_OFDM_RING_ENABLE_ON); + status = write16(state, SIO_OFDM_SH_OFDM_RING_ENABLE__A, + SIO_OFDM_SH_OFDM_RING_ENABLE_ON); if (status < 0) goto error; /* include boot loader section */ - status = write16(state, SIO_BL_COMM_EXEC__A, SIO_BL_COMM_EXEC_ACTIVE); + status = write16(state, SIO_BL_COMM_EXEC__A, + SIO_BL_COMM_EXEC_ACTIVE); if (status < 0) goto error; status = bl_chain_cmd(state, 0, 6, 100); @@ -6018,7 +6153,8 @@ static int init_drxk(struct drxk_state *state) } /* disable token-ring bus through OFDM block for possible ucode upload */ - status = write16(state, SIO_OFDM_SH_OFDM_RING_ENABLE__A, SIO_OFDM_SH_OFDM_RING_ENABLE_OFF); + status = write16(state, SIO_OFDM_SH_OFDM_RING_ENABLE__A, + SIO_OFDM_SH_OFDM_RING_ENABLE_OFF); if (status < 0) goto error; @@ -6048,7 +6184,8 @@ static int init_drxk(struct drxk_state *state) (((DRXK_VERSION_MAJOR / 10) % 10) << 8) + ((DRXK_VERSION_MAJOR % 10) << 4) + (DRXK_VERSION_MINOR % 10); - status = write16(state, SCU_RAM_DRIVER_VER_HI__A, driver_version); + status = write16(state, SCU_RAM_DRIVER_VER_HI__A, + driver_version); if (status < 0) goto error; driver_version = @@ -6056,7 +6193,8 @@ static int init_drxk(struct drxk_state *state) (((DRXK_VERSION_PATCH / 100) % 10) << 8) + (((DRXK_VERSION_PATCH / 10) % 10) << 4) + (DRXK_VERSION_PATCH % 10); - status = write16(state, SCU_RAM_DRIVER_VER_LO__A, driver_version); + status = write16(state, SCU_RAM_DRIVER_VER_LO__A, + driver_version); if (status < 0) goto error; @@ -6064,10 +6202,13 @@ static int init_drxk(struct drxk_state *state) DRXK_VERSION_MAJOR, DRXK_VERSION_MINOR, DRXK_VERSION_PATCH); - /* Dirty fix of default values for ROM/PATCH microcode - Dirty because this fix makes it impossible to setup suitable values - before calling DRX_Open. This solution requires changes to RF AGC speed - to be done via the CTRL function after calling DRX_Open */ + /* + * Dirty fix of default values for ROM/PATCH microcode + * Dirty because this fix makes it impossible to setup + * suitable values before calling DRX_Open. This solution + * requires changes to RF AGC speed to be done via the CTRL + * function after calling DRX_Open + */ /* m_dvbt_rf_agc_cfg.speed = 3; */ @@ -6238,7 +6379,8 @@ static int drxk_set_parameters(struct dvb_frontend *fe) case SYS_DVBC_ANNEX_C: if (!state->m_has_dvbc) return -EINVAL; - state->m_itut_annex_c = (delsys == SYS_DVBC_ANNEX_C) ? true : false; + state->m_itut_annex_c = (delsys == SYS_DVBC_ANNEX_C) ? + true : false; if (state->m_itut_annex_c) setoperation_mode(state, OM_QAM_ITU_C); else @@ -6352,7 +6494,7 @@ static int get_strength(struct drxk_state *state, u64 *strength) if (if_agc.output_level > if_agc.max_output_level) if_agc.output_level = if_agc.max_output_level; - agc_range = (u32) (if_agc.max_output_level - if_agc.min_output_level); + agc_range = (u32)(if_agc.max_output_level - if_agc.min_output_level); if (agc_range > 0) { atten += 100UL * ((u32)(tuner_if_gain)) * @@ -6433,9 +6575,11 @@ static int drxk_get_stats(struct dvb_frontend *fe) /* BER measurement is valid if at least FEC lock is achieved */ - /* OFDM_EC_VD_REQ_SMB_CNT__A and/or OFDM_EC_VD_REQ_BIT_CNT can be written - to set nr of symbols or bits over which - to measure EC_VD_REG_ERR_BIT_CNT__A . See CtrlSetCfg(). */ + /* + * OFDM_EC_VD_REQ_SMB_CNT__A and/or OFDM_EC_VD_REQ_BIT_CNT can be + * written to set nr of symbols or bits over which to measure + * EC_VD_REG_ERR_BIT_CNT__A . See CtrlSetCfg(). + */ /* Read registers for post/preViterbi BER calculation */ status = read16(state, OFDM_EC_VD_ERR_BIT_CNT__A, ®16); @@ -6566,8 +6710,8 @@ static int drxk_read_ucblocks(struct dvb_frontend *fe, u32 *ucblocks) return 0; } -static int drxk_get_tune_settings(struct dvb_frontend *fe, struct dvb_frontend_tune_settings - *sets) +static int drxk_get_tune_settings(struct dvb_frontend *fe, + struct dvb_frontend_tune_settings *sets) { struct drxk_state *state = fe->demodulator_priv; struct dtv_frontend_properties *p = &fe->dtv_property_cache; From 6e7582bf35b8a5a330fd08b398ae445bac86917a Mon Sep 17 00:00:00 2001 From: Jiang Liu Date: Fri, 17 May 2013 14:45:08 +0000 Subject: [PATCH 0120/1048] MIPS: PowerTV: use free_reserved_area() to simplify code Use common help function free_reserved_area() to simplify code. Signed-off-by: Jiang Liu Cc: linux-mips@linux-mips.org Cc: linux-kernel@vger.kernel.org Cc: Andrew Morton Cc: Jiang Liu Cc: David Rientjes Cc: Wen Congyang Cc: Mel Gorman Cc: Minchan Kim Cc: KAMEZAWA Hiroyuki Cc: Michal Hocko Cc: James Bottomley Cc: Sergei Shtylyov Cc: David Howells Cc: Mark Salter Cc: Jianguo Wu Cc: linux-mm@kvack.org Cc: linux-arch@vger.kernel.org Patchwork: https://patchwork.linux-mips.org/patch/5248/ Signed-off-by: Ralf Baechle --- arch/mips/powertv/asic/asic_devices.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/arch/mips/powertv/asic/asic_devices.c b/arch/mips/powertv/asic/asic_devices.c index d38b095fd0d0..9f64c2387808 100644 --- a/arch/mips/powertv/asic/asic_devices.c +++ b/arch/mips/powertv/asic/asic_devices.c @@ -529,17 +529,8 @@ EXPORT_SYMBOL(asic_resource_get); */ void platform_release_memory(void *ptr, int size) { - unsigned long addr; - unsigned long end; - - addr = ((unsigned long)ptr + (PAGE_SIZE - 1)) & PAGE_MASK; - end = ((unsigned long)ptr + size) & PAGE_MASK; - - for (; addr < end; addr += PAGE_SIZE) { - ClearPageReserved(virt_to_page(__va(addr))); - init_page_count(virt_to_page(__va(addr))); - free_page((unsigned long)__va(addr)); - } + free_reserved_area((unsigned long)ptr, (unsigned long)(ptr + size), + -1, NULL); } EXPORT_SYMBOL(platform_release_memory); From 9ddebc46e70b434e485060f7c1b53c5b848a6c8c Mon Sep 17 00:00:00 2001 From: David Daney Date: Wed, 22 May 2013 15:10:46 +0000 Subject: [PATCH 0121/1048] MIPS: OCTEON: Rename Kconfig CAVIUM_OCTEON_REFERENCE_BOARD to CAVIUM_OCTEON_SOC CAVIUM_OCTEON_SOC most place we used to use CPU_CAVIUM_OCTEON. This allows us to CPU_CAVIUM_OCTEON in places where we have no OCTEON SOC. Remove CAVIUM_OCTEON_SIMULATOR as it doesn't really do anything, we can get the same configuration with CAVIUM_OCTEON_SOC. Signed-off-by: David Daney Cc: linux-mips@linux-mips.org Cc: linux-ide@vger.kernel.org Cc: linux-edac@vger.kernel.org Cc: linux-i2c@vger.kernel.org Cc: netdev@vger.kernel.org Cc: spi-devel-general@lists.sourceforge.net Cc: devel@driverdev.osuosl.org Cc: linux-usb@vger.kernel.org Acked-by: Greg Kroah-Hartman Acked-by: Wolfram Sang Acked-by: Mauro Carvalho Chehab Patchwork: https://patchwork.linux-mips.org/patch/5295/ Signed-off-by: Ralf Baechle --- arch/mips/Kconfig | 19 ++----------------- arch/mips/cavium-octeon/Kconfig | 6 +++++- arch/mips/cavium-octeon/Platform | 8 ++++---- arch/mips/configs/cavium_octeon_defconfig | 2 +- arch/mips/pci/Makefile | 4 ++-- drivers/ata/Kconfig | 2 +- drivers/char/hw_random/Kconfig | 2 +- drivers/edac/Kconfig | 6 +++--- drivers/i2c/busses/Kconfig | 2 +- drivers/net/ethernet/octeon/Kconfig | 2 +- drivers/net/phy/Kconfig | 2 +- drivers/spi/Kconfig | 2 +- drivers/staging/octeon/Kconfig | 2 +- drivers/usb/host/Kconfig | 4 ++-- drivers/watchdog/Kconfig | 2 +- 15 files changed, 27 insertions(+), 38 deletions(-) diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig index 7a58ab933b20..ade99730ef3b 100644 --- a/arch/mips/Kconfig +++ b/arch/mips/Kconfig @@ -735,23 +735,8 @@ config WR_PPMC This enables support for the Wind River MIPS32 4KC PPMC evaluation board, which is based on GT64120 bridge chip. -config CAVIUM_OCTEON_SIMULATOR - bool "Cavium Networks Octeon Simulator" - select CEVT_R4K - select 64BIT_PHYS_ADDR - select DMA_COHERENT - select SYS_SUPPORTS_64BIT_KERNEL - select SYS_SUPPORTS_BIG_ENDIAN - select SYS_SUPPORTS_HOTPLUG_CPU - select SYS_HAS_CPU_CAVIUM_OCTEON - select HOLES_IN_ZONE - help - The Octeon simulator is software performance model of the Cavium - Octeon Processor. It supports simulating Octeon processors on x86 - hardware. - -config CAVIUM_OCTEON_REFERENCE_BOARD - bool "Cavium Networks Octeon reference board" +config CAVIUM_OCTEON_SOC + bool "Cavium Networks Octeon SoC based boards" select CEVT_R4K select 64BIT_PHYS_ADDR select DMA_COHERENT diff --git a/arch/mips/cavium-octeon/Kconfig b/arch/mips/cavium-octeon/Kconfig index 75a6df7fd265..a12444a5f1b5 100644 --- a/arch/mips/cavium-octeon/Kconfig +++ b/arch/mips/cavium-octeon/Kconfig @@ -10,6 +10,10 @@ config CAVIUM_CN63XXP1 non-CN63XXP1 hardware, so it is recommended to select "n" unless it is known the workarounds are needed. +endif # CPU_CAVIUM_OCTEON + +if CAVIUM_OCTEON_SOC + config CAVIUM_OCTEON_2ND_KERNEL bool "Build the kernel to be used as a 2nd kernel on the same chip" default "n" @@ -103,4 +107,4 @@ config OCTEON_ILM To compile this driver as a module, choose M here. The module will be called octeon-ilm -endif # CPU_CAVIUM_OCTEON +endif # CAVIUM_OCTEON_SOC diff --git a/arch/mips/cavium-octeon/Platform b/arch/mips/cavium-octeon/Platform index 1e43ccf1a792..8a301cb12d68 100644 --- a/arch/mips/cavium-octeon/Platform +++ b/arch/mips/cavium-octeon/Platform @@ -1,11 +1,11 @@ # # Cavium Octeon # -platform-$(CONFIG_CPU_CAVIUM_OCTEON) += cavium-octeon/ -cflags-$(CONFIG_CPU_CAVIUM_OCTEON) += \ +platform-$(CONFIG_CAVIUM_OCTEON_SOC) += cavium-octeon/ +cflags-$(CONFIG_CAVIUM_OCTEON_SOC) += \ -I$(srctree)/arch/mips/include/asm/mach-cavium-octeon ifdef CONFIG_CAVIUM_OCTEON_2ND_KERNEL -load-$(CONFIG_CPU_CAVIUM_OCTEON) += 0xffffffff84100000 +load-$(CONFIG_CAVIUM_OCTEON_SOC) += 0xffffffff84100000 else -load-$(CONFIG_CPU_CAVIUM_OCTEON) += 0xffffffff81100000 +load-$(CONFIG_CAVIUM_OCTEON_SOC) += 0xffffffff81100000 endif diff --git a/arch/mips/configs/cavium_octeon_defconfig b/arch/mips/configs/cavium_octeon_defconfig index 014ba4bbba7d..1888e5f4d598 100644 --- a/arch/mips/configs/cavium_octeon_defconfig +++ b/arch/mips/configs/cavium_octeon_defconfig @@ -1,4 +1,4 @@ -CONFIG_CAVIUM_OCTEON_REFERENCE_BOARD=y +CONFIG_CAVIUM_OCTEON_SOC=y CONFIG_CAVIUM_CN63XXP1=y CONFIG_CAVIUM_OCTEON_CVMSEG_SIZE=2 CONFIG_SPARSEMEM_MANUAL=y diff --git a/arch/mips/pci/Makefile b/arch/mips/pci/Makefile index 2cb1d315d225..fa3bcd233138 100644 --- a/arch/mips/pci/Makefile +++ b/arch/mips/pci/Makefile @@ -54,10 +54,10 @@ obj-$(CONFIG_VICTOR_MPC30X) += fixup-mpc30x.o obj-$(CONFIG_ZAO_CAPCELLA) += fixup-capcella.o obj-$(CONFIG_WR_PPMC) += fixup-wrppmc.o obj-$(CONFIG_MIKROTIK_RB532) += pci-rc32434.o ops-rc32434.o fixup-rc32434.o -obj-$(CONFIG_CPU_CAVIUM_OCTEON) += pci-octeon.o pcie-octeon.o +obj-$(CONFIG_CAVIUM_OCTEON_SOC) += pci-octeon.o pcie-octeon.o obj-$(CONFIG_CPU_XLR) += pci-xlr.o obj-$(CONFIG_CPU_XLP) += pci-xlp.o ifdef CONFIG_PCI_MSI -obj-$(CONFIG_CPU_CAVIUM_OCTEON) += msi-octeon.o +obj-$(CONFIG_CAVIUM_OCTEON_SOC) += msi-octeon.o endif diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig index a5a3ebcbdd2c..dc20774bd647 100644 --- a/drivers/ata/Kconfig +++ b/drivers/ata/Kconfig @@ -160,7 +160,7 @@ config PDC_ADMA config PATA_OCTEON_CF tristate "OCTEON Boot Bus Compact Flash support" - depends on CPU_CAVIUM_OCTEON + depends on CAVIUM_OCTEON_SOC help This option enables a polled compact flash driver for use with compact flash cards attached to the OCTEON boot bus. diff --git a/drivers/char/hw_random/Kconfig b/drivers/char/hw_random/Kconfig index 2f9dbf7568fb..40a865449f35 100644 --- a/drivers/char/hw_random/Kconfig +++ b/drivers/char/hw_random/Kconfig @@ -167,7 +167,7 @@ config HW_RANDOM_OMAP config HW_RANDOM_OCTEON tristate "Octeon Random Number Generator support" - depends on HW_RANDOM && CPU_CAVIUM_OCTEON + depends on HW_RANDOM && CAVIUM_OCTEON_SOC default HW_RANDOM ---help--- This driver provides kernel-side support for the Random Number diff --git a/drivers/edac/Kconfig b/drivers/edac/Kconfig index e443f2c1dfd1..923d2e82a289 100644 --- a/drivers/edac/Kconfig +++ b/drivers/edac/Kconfig @@ -349,21 +349,21 @@ config EDAC_OCTEON_PC config EDAC_OCTEON_L2C tristate "Cavium Octeon Secondary Caches (L2C)" - depends on EDAC_MM_EDAC && CPU_CAVIUM_OCTEON + depends on EDAC_MM_EDAC && CAVIUM_OCTEON_SOC help Support for error detection and correction on the Cavium Octeon family of SOCs. config EDAC_OCTEON_LMC tristate "Cavium Octeon DRAM Memory Controller (LMC)" - depends on EDAC_MM_EDAC && CPU_CAVIUM_OCTEON + depends on EDAC_MM_EDAC && CAVIUM_OCTEON_SOC help Support for error detection and correction on the Cavium Octeon family of SOCs. config EDAC_OCTEON_PCI tristate "Cavium Octeon PCI Controller" - depends on EDAC_MM_EDAC && PCI && CPU_CAVIUM_OCTEON + depends on EDAC_MM_EDAC && PCI && CAVIUM_OCTEON_SOC help Support for error detection and correction on the Cavium Octeon family of SOCs. diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig index 631736e2e7ed..a8fff7700624 100644 --- a/drivers/i2c/busses/Kconfig +++ b/drivers/i2c/busses/Kconfig @@ -726,7 +726,7 @@ config I2C_VERSATILE config I2C_OCTEON tristate "Cavium OCTEON I2C bus support" - depends on CPU_CAVIUM_OCTEON + depends on CAVIUM_OCTEON_SOC help Say yes if you want to support the I2C serial bus on Cavium OCTEON SOC. diff --git a/drivers/net/ethernet/octeon/Kconfig b/drivers/net/ethernet/octeon/Kconfig index 3de52ffd2872..a7aa28054cc1 100644 --- a/drivers/net/ethernet/octeon/Kconfig +++ b/drivers/net/ethernet/octeon/Kconfig @@ -4,7 +4,7 @@ config OCTEON_MGMT_ETHERNET tristate "Octeon Management port ethernet driver (CN5XXX, CN6XXX)" - depends on CPU_CAVIUM_OCTEON + depends on CAVIUM_OCTEON_SOC select PHYLIB select MDIO_OCTEON default y diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig index 1e11f2bfd9ce..84461e8824f7 100644 --- a/drivers/net/phy/Kconfig +++ b/drivers/net/phy/Kconfig @@ -135,7 +135,7 @@ config MDIO_GPIO config MDIO_OCTEON tristate "Support for MDIO buses on Octeon SOCs" - depends on CPU_CAVIUM_OCTEON + depends on CAVIUM_OCTEON_SOC default y help diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig index 92a9345d7a6b..20158978866f 100644 --- a/drivers/spi/Kconfig +++ b/drivers/spi/Kconfig @@ -266,7 +266,7 @@ config SPI_OC_TINY config SPI_OCTEON tristate "Cavium OCTEON SPI controller" - depends on CPU_CAVIUM_OCTEON + depends on CAVIUM_OCTEON_SOC help SPI host driver for the hardware found on some Cavium OCTEON SOCs. diff --git a/drivers/staging/octeon/Kconfig b/drivers/staging/octeon/Kconfig index 9493128e5fd2..6e1d5f8d3ec1 100644 --- a/drivers/staging/octeon/Kconfig +++ b/drivers/staging/octeon/Kconfig @@ -1,6 +1,6 @@ config OCTEON_ETHERNET tristate "Cavium Networks Octeon Ethernet support" - depends on CPU_CAVIUM_OCTEON && NETDEVICES + depends on CAVIUM_OCTEON_SOC && NETDEVICES select PHYLIB select MDIO_OCTEON help diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig index 344d5e2f87d7..54c121580738 100644 --- a/drivers/usb/host/Kconfig +++ b/drivers/usb/host/Kconfig @@ -285,7 +285,7 @@ config USB_EHCI_HCD_PLATFORM config USB_OCTEON_EHCI bool "Octeon on-chip EHCI support" - depends on CPU_CAVIUM_OCTEON + depends on CAVIUM_OCTEON_SOC default n select USB_EHCI_BIG_ENDIAN_MMIO help @@ -480,7 +480,7 @@ config USB_OHCI_HCD_PLATFORM config USB_OCTEON_OHCI bool "Octeon on-chip OHCI support" - depends on CPU_CAVIUM_OCTEON + depends on CAVIUM_OCTEON_SOC default USB_OCTEON_EHCI select USB_OHCI_BIG_ENDIAN_MMIO select USB_OHCI_LITTLE_ENDIAN diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig index e89fc3133972..9d03af1c596f 100644 --- a/drivers/watchdog/Kconfig +++ b/drivers/watchdog/Kconfig @@ -1072,7 +1072,7 @@ config TXX9_WDT config OCTEON_WDT tristate "Cavium OCTEON SOC family Watchdog Timer" - depends on CPU_CAVIUM_OCTEON + depends on CAVIUM_OCTEON_SOC default y select EXPORT_UASM if OCTEON_WDT = m help From 02a49d5144c58a2b9826946934533a7a9f28c2ec Mon Sep 17 00:00:00 2001 From: David Daney Date: Wed, 22 May 2013 20:46:23 +0000 Subject: [PATCH 0122/1048] MIPS: Octeon: Remove vestiges of CONFIG_CAVIUM_DECODE_RSL This config option doesn't exist any more, remove the leftover code for it too. Signed-off-by: David Daney Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/5302/ Signed-off-by: Ralf Baechle --- arch/mips/cavium-octeon/setup.c | 27 --------------------------- 1 file changed, 27 deletions(-) diff --git a/arch/mips/cavium-octeon/setup.c b/arch/mips/cavium-octeon/setup.c index 01b1b3f94feb..0acc8ef86907 100644 --- a/arch/mips/cavium-octeon/setup.c +++ b/arch/mips/cavium-octeon/setup.c @@ -40,12 +40,6 @@ #include #include -#ifdef CONFIG_CAVIUM_DECODE_RSL -extern void cvmx_interrupt_rsl_decode(void); -extern int __cvmx_interrupt_ecc_report_single_bit_errors; -extern void cvmx_interrupt_rsl_enable(void); -#endif - extern struct plat_smp_ops octeon_smp_ops; #ifdef CONFIG_PCI @@ -462,18 +456,6 @@ static void octeon_halt(void) octeon_kill_core(NULL); } -/** - * Handle all the error condition interrupts that might occur. - * - */ -#ifdef CONFIG_CAVIUM_DECODE_RSL -static irqreturn_t octeon_rlm_interrupt(int cpl, void *dev_id) -{ - cvmx_interrupt_rsl_decode(); - return IRQ_HANDLED; -} -#endif - /** * Return a string representing the system type * @@ -1064,15 +1046,6 @@ void prom_free_prom_memory(void) panic("Core-14449 WAR not in place (%04x).\n" "Please build kernel with proper options (CONFIG_CAVIUM_CN63XXP1).", insn); } -#ifdef CONFIG_CAVIUM_DECODE_RSL - cvmx_interrupt_rsl_enable(); - - /* Add an interrupt handler for general failures. */ - if (request_irq(OCTEON_IRQ_RML, octeon_rlm_interrupt, IRQF_SHARED, - "RML/RSL", octeon_rlm_interrupt)) { - panic("Unable to request_irq(OCTEON_IRQ_RML)"); - } -#endif } int octeon_prune_device_tree(void); From 0ec315121c8391a14bbeb5eecc146c470dfc00cb Mon Sep 17 00:00:00 2001 From: David Daney Date: Wed, 22 May 2013 20:46:44 +0000 Subject: [PATCH 0123/1048] MIPS: OCTEON: Get rid of CONFIG_CAVIUM_OCTEON_HW_FIX_UNALIGNED When you turn it off, the kernel is unusable, so get rid of the option and always allow unaligned access. The Octeon specific memcpy intentionally does unaligned accesses and it must not fault. Signed-off-by: David Daney Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/5303/ Signed-off-by: Ralf Baechle --- arch/mips/cavium-octeon/Kconfig | 11 ----------- .../asm/mach-cavium-octeon/kernel-entry-init.h | 7 +------ 2 files changed, 1 insertion(+), 17 deletions(-) diff --git a/arch/mips/cavium-octeon/Kconfig b/arch/mips/cavium-octeon/Kconfig index a12444a5f1b5..227705d9d5ae 100644 --- a/arch/mips/cavium-octeon/Kconfig +++ b/arch/mips/cavium-octeon/Kconfig @@ -23,17 +23,6 @@ config CAVIUM_OCTEON_2ND_KERNEL with this option to be run at the same time as one built without this option. -config CAVIUM_OCTEON_HW_FIX_UNALIGNED - bool "Enable hardware fixups of unaligned loads and stores" - default "y" - help - Configure the Octeon hardware to automatically fix unaligned loads - and stores. Normally unaligned accesses are fixed using a kernel - exception handler. This option enables the hardware automatic fixups, - which requires only an extra 3 cycles. Disable this option if you - are running code that relies on address exceptions on unaligned - accesses. - config CAVIUM_OCTEON_CVMSEG_SIZE int "Number of L1 cache lines reserved for CVMSEG memory" range 0 54 diff --git a/arch/mips/include/asm/mach-cavium-octeon/kernel-entry-init.h b/arch/mips/include/asm/mach-cavium-octeon/kernel-entry-init.h index 1e7dbb192657..1668ee57acb9 100644 --- a/arch/mips/include/asm/mach-cavium-octeon/kernel-entry-init.h +++ b/arch/mips/include/asm/mach-cavium-octeon/kernel-entry-init.h @@ -34,15 +34,10 @@ ori v0, CONFIG_CAVIUM_OCTEON_CVMSEG_SIZE dmtc0 v0, CP0_CVMMEMCTL_REG # Write the cavium mem control register dmfc0 v0, CP0_CVMCTL_REG # Read the cavium control register -#ifdef CONFIG_CAVIUM_OCTEON_HW_FIX_UNALIGNED # Disable unaligned load/store support but leave HW fixup enabled + # Needed for octeon specific memcpy or v0, v0, 0x5001 xor v0, v0, 0x1001 -#else - # Disable unaligned load/store and HW fixup support - or v0, v0, 0x5001 - xor v0, v0, 0x5001 -#endif # Read the processor ID register mfc0 v1, CP0_PRID_REG # Disable instruction prefetching (Octeon Pass1 errata) From 90a6fb120d9c039b108d37405b0e8ba2258403bf Mon Sep 17 00:00:00 2001 From: Chen Gang Date: Sun, 26 May 2013 06:51:49 +0000 Subject: [PATCH 0124/1048] MIPS: Lantiq: Use strlcpy() instead of strncpy(). 'compatible' is used by strlen() in __of_device_is_compatible(). Ensure strings are always '\0' terminated. 'of_ids is not a structure in "include/uapi/*", so no need to initialize it completly; using strlcpy() instead of strncpy() will do. Signed-off-by: Chen Gang Acked-by: John Crispin Cc: linux-mips@linux-mips.org Cc: Linux-Arch Patchwork: https://patchwork.linux-mips.org/patch/5329/ Signed-off-by: Ralf Baechle --- arch/mips/lantiq/prom.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/mips/lantiq/prom.c b/arch/mips/lantiq/prom.c index 9f9e875967aa..49c460370285 100644 --- a/arch/mips/lantiq/prom.c +++ b/arch/mips/lantiq/prom.c @@ -112,7 +112,7 @@ int __init plat_of_setup(void) if (!of_have_populated_dt()) panic("device tree not present"); - strncpy(of_ids[0].compatible, soc_info.compatible, + strlcpy(of_ids[0].compatible, soc_info.compatible, sizeof(of_ids[0].compatible)); strncpy(of_ids[1].compatible, "simple-bus", sizeof(of_ids[1].compatible)); From 24b1944fc6b7be857c81f0cb0ff264c57b85ee29 Mon Sep 17 00:00:00 2001 From: Chen Gang Date: Sun, 26 May 2013 07:01:46 +0000 Subject: [PATCH 0125/1048] MIPS: Ralink: Use strlcpy() instead of strncpy(). 'compatible' is used by strlen() in __of_device_is_compatible(). Ensure strings are always '\0' terminated. 'of_ids is not a structure in "include/uapi/*", so no need to initialize it completly; using strlcpy() instead of strncpy() will do. Signed-off-by: Chen Gang Acked-by: John Crispin Cc: juhosg@openwrt.org Cc: linux-mips@linux-mips.org Cc: Linux-Arch Patchwork: https://patchwork.linux-mips.org/patch/5330/ Signed-off-by: Ralf Baechle --- arch/mips/ralink/of.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/mips/ralink/of.c b/arch/mips/ralink/of.c index 6b5f3406f414..f25ea5b45051 100644 --- a/arch/mips/ralink/of.c +++ b/arch/mips/ralink/of.c @@ -104,7 +104,7 @@ static int __init plat_of_setup(void) if (!of_have_populated_dt()) panic("device tree not present"); - strncpy(of_ids[0].compatible, soc_info.compatible, len); + strlcpy(of_ids[0].compatible, soc_info.compatible, len); strncpy(of_ids[1].compatible, "palmbus", len); if (of_platform_populate(NULL, of_ids, NULL, NULL)) From 41c8366be83a7c868c5281ad8d9e6715c1564351 Mon Sep 17 00:00:00 2001 From: Chen Gang Date: Sun, 26 May 2013 07:06:06 +0000 Subject: [PATCH 0126/1048] MIPS: using strlcpy() instead of strncpy() Ensure strings are always '\0' terminated. Or in the next pr_info() shit may hit the fan. Signed-off-by: Chen Gang Acked-by: John Crispin Cc: david.daney@cavium.com Cc: linux-mips@linux-mips.org Cc: Linux-Arch Cc: linux-kernel@vger.kernel.org Patchwork: https://patchwork.linux-mips.org/patch/5331/ Signed-off-by: Ralf Baechle --- arch/mips/kernel/prom.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/mips/kernel/prom.c b/arch/mips/kernel/prom.c index 5712bb532245..7e954042f252 100644 --- a/arch/mips/kernel/prom.c +++ b/arch/mips/kernel/prom.c @@ -30,7 +30,7 @@ __init void mips_set_machine_name(const char *name) if (name == NULL) return; - strncpy(mips_machine_name, name, sizeof(mips_machine_name)); + strlcpy(mips_machine_name, name, sizeof(mips_machine_name)); pr_info("MIPS: machine is %s\n", mips_get_machine_name()); } From e7f3b48af7be9f8007a224663a5b91340626fed5 Mon Sep 17 00:00:00 2001 From: Ralf Baechle Date: Wed, 29 May 2013 01:02:18 +0200 Subject: [PATCH 0127/1048] MIPS: Cleanup flags in syscall flags handlers. This will simplify further modifications. Signed-off-by: Ralf Baechle --- arch/mips/include/asm/thread_info.h | 2 ++ arch/mips/kernel/scall32-o32.S | 2 +- arch/mips/kernel/scall64-64.S | 2 +- arch/mips/kernel/scall64-n32.S | 2 +- arch/mips/kernel/scall64-o32.S | 2 +- 5 files changed, 6 insertions(+), 4 deletions(-) diff --git a/arch/mips/include/asm/thread_info.h b/arch/mips/include/asm/thread_info.h index 895320e25662..cdea4f65b944 100644 --- a/arch/mips/include/asm/thread_info.h +++ b/arch/mips/include/asm/thread_info.h @@ -131,6 +131,8 @@ static inline struct thread_info *current_thread_info(void) #define _TIF_FPUBOUND (1< yes diff --git a/arch/mips/kernel/scall64-64.S b/arch/mips/kernel/scall64-64.S index 97a5909a61cf..be6627ead619 100644 --- a/arch/mips/kernel/scall64-64.S +++ b/arch/mips/kernel/scall64-64.S @@ -54,7 +54,7 @@ NESTED(handle_sys64, PT_SIZE, sp) sd a3, PT_R26(sp) # save a3 for syscall restarting - li t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT + li t1, _TIF_WORK_SYSCALL_ENTRY LONG_L t0, TI_FLAGS($28) # syscall tracing enabled? and t0, t1, t0 bnez t0, syscall_trace_entry diff --git a/arch/mips/kernel/scall64-n32.S b/arch/mips/kernel/scall64-n32.S index edcb6594e7b5..cab150789c8d 100644 --- a/arch/mips/kernel/scall64-n32.S +++ b/arch/mips/kernel/scall64-n32.S @@ -47,7 +47,7 @@ NESTED(handle_sysn32, PT_SIZE, sp) sd a3, PT_R26(sp) # save a3 for syscall restarting - li t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT + li t1, _TIF_WORK_SYSCALL_ENTRY LONG_L t0, TI_FLAGS($28) # syscall tracing enabled? and t0, t1, t0 bnez t0, n32_syscall_trace_entry diff --git a/arch/mips/kernel/scall64-o32.S b/arch/mips/kernel/scall64-o32.S index 74f485d3c0ef..37605dc8eef7 100644 --- a/arch/mips/kernel/scall64-o32.S +++ b/arch/mips/kernel/scall64-o32.S @@ -81,7 +81,7 @@ NESTED(handle_sys, PT_SIZE, sp) PTR 4b, bad_stack .previous - li t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT + li t1, _TIF_WORK_SYSCALL_ENTRY LONG_L t0, TI_FLAGS($28) # syscall tracing enabled? and t0, t1, t0 bnez t0, trace_a_syscall From c3fc5cd5c5a5f4738776a965a020a32c1a37c8fd Mon Sep 17 00:00:00 2001 From: Ralf Baechle Date: Wed, 29 May 2013 01:07:19 +0200 Subject: [PATCH 0128/1048] MIPS: Implement HAVE_CONTEXT_TRACKING. This enables support for CONFIG_NO_HZ_FULL. Signed-off-by: Ralf Baechle --- arch/mips/Kconfig | 1 + arch/mips/include/asm/thread_info.h | 11 +++-- arch/mips/kernel/cpu-bugs64.c | 5 ++ arch/mips/kernel/ptrace.c | 12 +++++ arch/mips/kernel/signal.c | 5 ++ arch/mips/kernel/traps.c | 74 +++++++++++++++++++++++------ arch/mips/kernel/unaligned.c | 4 ++ arch/mips/mm/fault.c | 15 +++++- 8 files changed, 108 insertions(+), 19 deletions(-) diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig index ade99730ef3b..87ddac9477fa 100644 --- a/arch/mips/Kconfig +++ b/arch/mips/Kconfig @@ -1,6 +1,7 @@ config MIPS bool default y + select HAVE_CONTEXT_TRACKING select HAVE_GENERIC_DMA_COHERENT select HAVE_IDE select HAVE_OPROFILE diff --git a/arch/mips/include/asm/thread_info.h b/arch/mips/include/asm/thread_info.h index cdea4f65b944..61215a34acc6 100644 --- a/arch/mips/include/asm/thread_info.h +++ b/arch/mips/include/asm/thread_info.h @@ -109,6 +109,7 @@ static inline struct thread_info *current_thread_info(void) #define TIF_RESTORE_SIGMASK 9 /* restore signal mask in do_signal() */ #define TIF_USEDFPU 16 /* FPU was used by this task this quantum (SMP) */ #define TIF_MEMDIE 18 /* is terminating due to OOM killer */ +#define TIF_NOHZ 19 /* in adaptive nohz mode */ #define TIF_FIXADE 20 /* Fix address errors in software */ #define TIF_LOGADE 21 /* Log address errors to syslog */ #define TIF_32BIT_REGS 22 /* also implies 16/32 fprs */ @@ -124,6 +125,7 @@ static inline struct thread_info *current_thread_info(void) #define _TIF_SECCOMP (1< #include #include #include @@ -171,8 +172,12 @@ static volatile int daddi_ov __cpuinitdata; asmlinkage void __init do_daddi_ov(struct pt_regs *regs) { + enum ctx_state prev_state; + + prev_state = exception_enter(); daddi_ov = 1; regs->cp0_epc += 4; + exception_exit(prev_state); } static inline void check_daddi(void) diff --git a/arch/mips/kernel/ptrace.c b/arch/mips/kernel/ptrace.c index 9c6299c733a3..8ae1ebef8b71 100644 --- a/arch/mips/kernel/ptrace.c +++ b/arch/mips/kernel/ptrace.c @@ -15,6 +15,7 @@ * binaries. */ #include +#include #include #include #include @@ -534,6 +535,8 @@ static inline int audit_arch(void) */ asmlinkage void syscall_trace_enter(struct pt_regs *regs) { + user_exit(); + /* do the secure computing check first */ secure_computing_strict(regs->regs[2]); @@ -570,6 +573,13 @@ out: */ asmlinkage void syscall_trace_leave(struct pt_regs *regs) { + /* + * We may come here right after calling schedule_user() + * or do_notify_resume(), in which case we can be in RCU + * user mode. + */ + user_exit(); + audit_syscall_exit(regs); if (!(current->ptrace & PT_PTRACED)) @@ -592,4 +602,6 @@ asmlinkage void syscall_trace_leave(struct pt_regs *regs) send_sig(current->exit_code, current, 1); current->exit_code = 0; } + + user_enter(); } diff --git a/arch/mips/kernel/signal.c b/arch/mips/kernel/signal.c index fd3ef2c2afbc..2f285abc76d5 100644 --- a/arch/mips/kernel/signal.c +++ b/arch/mips/kernel/signal.c @@ -8,6 +8,7 @@ * Copyright (C) 1999, 2000 Silicon Graphics, Inc. */ #include +#include #include #include #include @@ -573,6 +574,8 @@ asmlinkage void do_notify_resume(struct pt_regs *regs, void *unused, { local_irq_enable(); + user_exit(); + /* deal with pending signal delivery */ if (thread_info_flags & _TIF_SIGPENDING) do_signal(regs); @@ -581,6 +584,8 @@ asmlinkage void do_notify_resume(struct pt_regs *regs, void *unused, clear_thread_flag(TIF_NOTIFY_RESUME); tracehook_notify_resume(regs); } + + user_enter(); } #ifdef CONFIG_SMP diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c index a75ae40184aa..beba1e616b6e 100644 --- a/arch/mips/kernel/traps.c +++ b/arch/mips/kernel/traps.c @@ -13,6 +13,7 @@ */ #include #include +#include #include #include #include @@ -423,7 +424,9 @@ asmlinkage void do_be(struct pt_regs *regs) const struct exception_table_entry *fixup = NULL; int data = regs->cp0_cause & 4; int action = MIPS_BE_FATAL; + enum ctx_state prev_state; + prev_state = exception_enter(); /* XXX For now. Fixme, this searches the wrong table ... */ if (data && !user_mode(regs)) fixup = search_dbe_tables(exception_epc(regs)); @@ -436,11 +439,11 @@ asmlinkage void do_be(struct pt_regs *regs) switch (action) { case MIPS_BE_DISCARD: - return; + goto out; case MIPS_BE_FIXUP: if (fixup) { regs->cp0_epc = fixup->nextinsn; - return; + goto out; } break; default: @@ -455,10 +458,13 @@ asmlinkage void do_be(struct pt_regs *regs) field, regs->cp0_epc, field, regs->regs[31]); if (notify_die(DIE_OOPS, "bus error", regs, 0, regs_to_trapnr(regs), SIGBUS) == NOTIFY_STOP) - return; + goto out; die_if_kernel("Oops", regs); force_sig(SIGBUS, current); + +out: + exception_exit(prev_state); } /* @@ -673,8 +679,10 @@ static int simulate_sync(struct pt_regs *regs, unsigned int opcode) asmlinkage void do_ov(struct pt_regs *regs) { + enum ctx_state prev_state; siginfo_t info; + prev_state = exception_enter(); die_if_kernel("Integer overflow", regs); info.si_code = FPE_INTOVF; @@ -682,6 +690,7 @@ asmlinkage void do_ov(struct pt_regs *regs) info.si_errno = 0; info.si_addr = (void __user *) regs->cp0_epc; force_sig_info(SIGFPE, &info, current); + exception_exit(prev_state); } int process_fpemu_return(int sig, void __user *fault_addr) @@ -713,11 +722,13 @@ int process_fpemu_return(int sig, void __user *fault_addr) */ asmlinkage void do_fpe(struct pt_regs *regs, unsigned long fcr31) { + enum ctx_state prev_state; siginfo_t info = {0}; + prev_state = exception_enter(); if (notify_die(DIE_FP, "FP exception", regs, 0, regs_to_trapnr(regs), SIGFPE) == NOTIFY_STOP) - return; + goto out; die_if_kernel("FP exception in kernel code", regs); if (fcr31 & FPU_CSR_UNI_X) { @@ -753,7 +764,7 @@ asmlinkage void do_fpe(struct pt_regs *regs, unsigned long fcr31) /* If something went wrong, signal */ process_fpemu_return(sig, fault_addr); - return; + goto out; } else if (fcr31 & FPU_CSR_INV_X) info.si_code = FPE_FLTINV; else if (fcr31 & FPU_CSR_DIV_X) @@ -770,6 +781,9 @@ asmlinkage void do_fpe(struct pt_regs *regs, unsigned long fcr31) info.si_errno = 0; info.si_addr = (void __user *) regs->cp0_epc; force_sig_info(SIGFPE, &info, current); + +out: + exception_exit(prev_state); } static void do_trap_or_bp(struct pt_regs *regs, unsigned int code, @@ -835,9 +849,11 @@ static void do_trap_or_bp(struct pt_regs *regs, unsigned int code, asmlinkage void do_bp(struct pt_regs *regs) { unsigned int opcode, bcode; + enum ctx_state prev_state; unsigned long epc; u16 instr[2]; + prev_state = exception_enter(); if (get_isa16_mode(regs->cp0_epc)) { /* Calculate EPC. */ epc = exception_epc(regs); @@ -852,7 +868,7 @@ asmlinkage void do_bp(struct pt_regs *regs) goto out_sigsegv; bcode = (instr[0] >> 6) & 0x3f; do_trap_or_bp(regs, bcode, "Break"); - return; + goto out; } } else { if (__get_user(opcode, (unsigned int __user *) exception_epc(regs))) @@ -876,12 +892,12 @@ asmlinkage void do_bp(struct pt_regs *regs) switch (bcode) { case BRK_KPROBE_BP: if (notify_die(DIE_BREAK, "debug", regs, bcode, regs_to_trapnr(regs), SIGTRAP) == NOTIFY_STOP) - return; + goto out; else break; case BRK_KPROBE_SSTEPBP: if (notify_die(DIE_SSTEPBP, "single_step", regs, bcode, regs_to_trapnr(regs), SIGTRAP) == NOTIFY_STOP) - return; + goto out; else break; default: @@ -889,18 +905,24 @@ asmlinkage void do_bp(struct pt_regs *regs) } do_trap_or_bp(regs, bcode, "Break"); + +out: + exception_exit(prev_state); return; out_sigsegv: force_sig(SIGSEGV, current); + goto out; } asmlinkage void do_tr(struct pt_regs *regs) { u32 opcode, tcode = 0; + enum ctx_state prev_state; u16 instr[2]; unsigned long epc = msk_isa16_mode(exception_epc(regs)); + prev_state = exception_enter(); if (get_isa16_mode(regs->cp0_epc)) { if (__get_user(instr[0], (u16 __user *)(epc + 0)) || __get_user(instr[1], (u16 __user *)(epc + 2))) @@ -918,10 +940,14 @@ asmlinkage void do_tr(struct pt_regs *regs) } do_trap_or_bp(regs, tcode, "Trap"); + +out: + exception_exit(prev_state); return; out_sigsegv: force_sig(SIGSEGV, current); + goto out; } asmlinkage void do_ri(struct pt_regs *regs) @@ -929,17 +955,19 @@ asmlinkage void do_ri(struct pt_regs *regs) unsigned int __user *epc = (unsigned int __user *)exception_epc(regs); unsigned long old_epc = regs->cp0_epc; unsigned long old31 = regs->regs[31]; + enum ctx_state prev_state; unsigned int opcode = 0; int status = -1; + prev_state = exception_enter(); if (notify_die(DIE_RI, "RI Fault", regs, 0, regs_to_trapnr(regs), SIGILL) == NOTIFY_STOP) - return; + goto out; die_if_kernel("Reserved instruction in kernel code", regs); if (unlikely(compute_return_epc(regs) < 0)) - return; + goto out; if (get_isa16_mode(regs->cp0_epc)) { unsigned short mmop[2] = { 0 }; @@ -974,6 +1002,9 @@ asmlinkage void do_ri(struct pt_regs *regs) regs->regs[31] = old31; force_sig(status, current); } + +out: + exception_exit(prev_state); } /* @@ -1040,6 +1071,7 @@ static int default_cu2_call(struct notifier_block *nfb, unsigned long action, asmlinkage void do_cpu(struct pt_regs *regs) { + enum ctx_state prev_state; unsigned int __user *epc; unsigned long old_epc, old31; unsigned int opcode; @@ -1047,6 +1079,7 @@ asmlinkage void do_cpu(struct pt_regs *regs) int status; unsigned long __maybe_unused flags; + prev_state = exception_enter(); die_if_kernel("do_cpu invoked from kernel context!", regs); cpid = (regs->cp0_cause >> CAUSEB_CE) & 3; @@ -1060,7 +1093,7 @@ asmlinkage void do_cpu(struct pt_regs *regs) status = -1; if (unlikely(compute_return_epc(regs) < 0)) - return; + goto out; if (get_isa16_mode(regs->cp0_epc)) { unsigned short mmop[2] = { 0 }; @@ -1093,7 +1126,7 @@ asmlinkage void do_cpu(struct pt_regs *regs) force_sig(status, current); } - return; + goto out; case 3: /* @@ -1131,19 +1164,26 @@ asmlinkage void do_cpu(struct pt_regs *regs) mt_ase_fp_affinity(); } - return; + goto out; case 2: raw_notifier_call_chain(&cu2_chain, CU2_EXCEPTION, regs); - return; + goto out; } force_sig(SIGILL, current); + +out: + exception_exit(prev_state); } asmlinkage void do_mdmx(struct pt_regs *regs) { + enum ctx_state prev_state; + + prev_state = exception_enter(); force_sig(SIGILL, current); + exception_exit(prev_state); } /* @@ -1151,8 +1191,10 @@ asmlinkage void do_mdmx(struct pt_regs *regs) */ asmlinkage void do_watch(struct pt_regs *regs) { + enum ctx_state prev_state; u32 cause; + prev_state = exception_enter(); /* * Clear WP (bit 22) bit of cause register so we don't loop * forever. @@ -1174,13 +1216,16 @@ asmlinkage void do_watch(struct pt_regs *regs) mips_clear_watch_registers(); local_irq_enable(); } + exception_exit(prev_state); } asmlinkage void do_mcheck(struct pt_regs *regs) { const int field = 2 * sizeof(unsigned long); int multi_match = regs->cp0_status & ST0_TS; + enum ctx_state prev_state; + prev_state = exception_enter(); show_regs(regs); if (multi_match) { @@ -1202,6 +1247,7 @@ asmlinkage void do_mcheck(struct pt_regs *regs) panic("Caught Machine Check exception - %scaused by multiple " "matching entries in the TLB.", (multi_match) ? "" : "not "); + exception_exit(prev_state); } asmlinkage void do_mt(struct pt_regs *regs) diff --git a/arch/mips/kernel/unaligned.c b/arch/mips/kernel/unaligned.c index 203d8857070d..3eaa02aa8ae0 100644 --- a/arch/mips/kernel/unaligned.c +++ b/arch/mips/kernel/unaligned.c @@ -72,6 +72,7 @@ * A store crossing a page boundary might be executed only partially. * Undo the partial store in this case. */ +#include #include #include #include @@ -1550,9 +1551,11 @@ sigill: } asmlinkage void do_ade(struct pt_regs *regs) { + enum ctx_state prev_state; unsigned int __user *pc; mm_segment_t seg; + prev_state = exception_enter(); perf_sw_event(PERF_COUNT_SW_ALIGNMENT_FAULTS, 1, regs, regs->cp0_badvaddr); /* @@ -1628,6 +1631,7 @@ sigbus: /* * XXX On return from the signal handler we should advance the epc */ + exception_exit(prev_state); } #ifdef CONFIG_DEBUG_FS diff --git a/arch/mips/mm/fault.c b/arch/mips/mm/fault.c index 0fead53d1c26..85df1cd8d446 100644 --- a/arch/mips/mm/fault.c +++ b/arch/mips/mm/fault.c @@ -5,6 +5,7 @@ * * Copyright (C) 1995 - 2000 by Ralf Baechle */ +#include #include #include #include @@ -32,8 +33,8 @@ * and the problem, and then passes it off to one of the appropriate * routines. */ -asmlinkage void __kprobes do_page_fault(struct pt_regs *regs, unsigned long write, - unsigned long address) +static void __kprobes __do_page_fault(struct pt_regs *regs, unsigned long write, + unsigned long address) { struct vm_area_struct * vma = NULL; struct task_struct *tsk = current; @@ -312,3 +313,13 @@ vmalloc_fault: } #endif } + +asmlinkage void __kprobes do_page_fault(struct pt_regs *regs, + unsigned long write, unsigned long address) +{ + enum ctx_state prev_state; + + prev_state = exception_enter(); + __do_page_fault(regs, write, address); + exception_exit(prev_state); +} From 5a5f1efc8f5bce01773c6b769d7912a15e8eee07 Mon Sep 17 00:00:00 2001 From: Markos Chandras Date: Tue, 11 Jun 2013 08:02:55 +0000 Subject: [PATCH 0129/1048] MIPS: kernel: mcount.S: Drop FRAME_POINTER codepath CONFIG_FRAME_POINTER is not selectable for MIPS so this codepath was never executed. Signed-off-by: Markos Chandras Acked-by: Steven J. Hill Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/5440/ Signed-off-by: Ralf Baechle --- arch/mips/kernel/mcount.S | 4 ---- 1 file changed, 4 deletions(-) diff --git a/arch/mips/kernel/mcount.S b/arch/mips/kernel/mcount.S index 33d067148e61..a03e93c4a946 100644 --- a/arch/mips/kernel/mcount.S +++ b/arch/mips/kernel/mcount.S @@ -168,14 +168,10 @@ NESTED(ftrace_graph_caller, PT_SIZE, ra) #endif /* arg3: Get frame pointer of current stack */ -#ifdef CONFIG_FRAME_POINTER - move a2, fp -#else /* ! CONFIG_FRAME_POINTER */ #ifdef CONFIG_64BIT PTR_LA a2, PT_SIZE(sp) #else PTR_LA a2, (PT_SIZE+8)(sp) -#endif #endif jal prepare_ftrace_return From 5e5726789a2c55db2e41ea8e7171ce4ee4066d01 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Mon, 13 May 2013 06:17:54 -0300 Subject: [PATCH 0130/1048] [media] omap3isp: Remove redundant platform_set_drvdata() Commit 0998d06310 (device-core: Ensure drvdata = NULL when no driver is bound) removes the need to set driver data field to NULL. Signed-off-by: Sachin Kamat Acked-by: Sakari Ailus Signed-off-by: Laurent Pinchart Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/omap3isp/isp.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/media/platform/omap3isp/isp.c b/drivers/media/platform/omap3isp/isp.c index 4c4bd3d1a2bc..5a04077b362b 100644 --- a/drivers/media/platform/omap3isp/isp.c +++ b/drivers/media/platform/omap3isp/isp.c @@ -2291,8 +2291,6 @@ error_isp: isp_xclk_cleanup(isp); omap3isp_put(isp); error: - platform_set_drvdata(pdev, NULL); - mutex_destroy(&isp->isp_mutex); return ret; From 31036441d785359999e45bf410c778f64ffcab64 Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Fri, 31 May 2013 19:22:50 -0300 Subject: [PATCH 0131/1048] [media] omap3isp: include linux/mm_types.h The ispqueue.h file uses vm_flags_t, which is defined in linux/mm_types.h, so we must include that header in order to build in all configurations. Signed-off-by: Arnd Bergmann Signed-off-by: Laurent Pinchart Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/omap3isp/ispqueue.h | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/media/platform/omap3isp/ispqueue.h b/drivers/media/platform/omap3isp/ispqueue.h index 908dfd712e8e..3e048ad65647 100644 --- a/drivers/media/platform/omap3isp/ispqueue.h +++ b/drivers/media/platform/omap3isp/ispqueue.h @@ -28,6 +28,7 @@ #include #include +#include #include #include #include From 7c0f812a5d65e712618af880dda4a5cc7ed79463 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Mon, 11 Mar 2013 12:02:13 -0300 Subject: [PATCH 0132/1048] [media] omap3isp: Defer probe when the IOMMU is not available When the OMAP3 ISP driver is compiled in the kernel the device can be probed before the corresponding IOMMU is available. Defer the probe in that case, and fix a crash in the error path. Reported-by: Javier Martin Signed-off-by: Laurent Pinchart Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/omap3isp/isp.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/media/platform/omap3isp/isp.c b/drivers/media/platform/omap3isp/isp.c index 5a04077b362b..ff5a20afa691 100644 --- a/drivers/media/platform/omap3isp/isp.c +++ b/drivers/media/platform/omap3isp/isp.c @@ -2249,6 +2249,7 @@ static int isp_probe(struct platform_device *pdev) ret = iommu_attach_device(isp->domain, &pdev->dev); if (ret) { dev_err(&pdev->dev, "can't attach iommu device: %d\n", ret); + ret = -EPROBE_DEFER; goto free_domain; } @@ -2287,6 +2288,7 @@ detach_dev: iommu_detach_device(isp->domain, &pdev->dev); free_domain: iommu_domain_free(isp->domain); + isp->domain = NULL; error_isp: isp_xclk_cleanup(isp); omap3isp_put(isp); From fe905b8cc992edd3d1f729f4a88c4701e7c3b774 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Wed, 29 May 2013 00:47:41 -0300 Subject: [PATCH 0133/1048] [media] omap3isp: ccp2: Don't ignore the regulator_enable() return value Check the return value and catch errors correctly. Signed-off-by: Laurent Pinchart Acked-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/omap3isp/ispccp2.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/drivers/media/platform/omap3isp/ispccp2.c b/drivers/media/platform/omap3isp/ispccp2.c index 13982b0ab560..e71651429dda 100644 --- a/drivers/media/platform/omap3isp/ispccp2.c +++ b/drivers/media/platform/omap3isp/ispccp2.c @@ -158,13 +158,17 @@ static void ccp2_pwr_cfg(struct isp_ccp2_device *ccp2) * @ccp2: pointer to ISP CCP2 device * @enable: enable/disable flag */ -static void ccp2_if_enable(struct isp_ccp2_device *ccp2, u8 enable) +static int ccp2_if_enable(struct isp_ccp2_device *ccp2, u8 enable) { struct isp_device *isp = to_isp_device(ccp2); + int ret; int i; - if (enable && ccp2->vdds_csib) - regulator_enable(ccp2->vdds_csib); + if (enable && ccp2->vdds_csib) { + ret = regulator_enable(ccp2->vdds_csib); + if (ret < 0) + return ret; + } /* Enable/Disable all the LCx channels */ for (i = 0; i < CCP2_LCx_CHANS_NUM; i++) @@ -179,6 +183,8 @@ static void ccp2_if_enable(struct isp_ccp2_device *ccp2, u8 enable) if (!enable && ccp2->vdds_csib) regulator_disable(ccp2->vdds_csib); + + return 0; } /* @@ -851,7 +857,12 @@ static int ccp2_s_stream(struct v4l2_subdev *sd, int enable) ccp2_print_status(ccp2); /* Enable CSI1/CCP2 interface */ - ccp2_if_enable(ccp2, 1); + ret = ccp2_if_enable(ccp2, 1); + if (ret < 0) { + if (ccp2->phy) + omap3isp_csiphy_release(ccp2->phy); + return ret; + } break; case ISP_PIPELINE_STREAM_SINGLESHOT: From c88e739b1fad662240e99ecbd0bdaac871717987 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Sat, 13 Apr 2013 06:32:15 -0300 Subject: [PATCH 0134/1048] [media] media: info leak in __media_device_enum_links() These structs have holes and reserved struct members which aren't cleared. I've added a memset() so we don't leak stack information. Signed-off-by: Dan Carpenter Signed-off-by: Laurent Pinchart Signed-off-by: Mauro Carvalho Chehab --- drivers/media/media-device.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c index 1957c0df08fd..d5a7a135f75d 100644 --- a/drivers/media/media-device.c +++ b/drivers/media/media-device.c @@ -142,6 +142,8 @@ static long __media_device_enum_links(struct media_device *mdev, for (p = 0; p < entity->num_pads; p++) { struct media_pad_desc pad; + + memset(&pad, 0, sizeof(pad)); media_device_kpad_to_upad(&entity->pads[p], &pad); if (copy_to_user(&links->pads[p], &pad, sizeof(pad))) return -EFAULT; @@ -159,6 +161,7 @@ static long __media_device_enum_links(struct media_device *mdev, if (entity->links[l].source->entity != entity) continue; + memset(&link, 0, sizeof(link)); media_device_kpad_to_upad(entity->links[l].source, &link.source); media_device_kpad_to_upad(entity->links[l].sink, From 4eb1d01d3f5c0bf7e4f02cb1b73b2d85d64cc762 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Tue, 30 Apr 2013 02:16:20 -0300 Subject: [PATCH 0135/1048] [media] s3c-camif: Staticize local symbols These symbols are local to the file and should be static. Signed-off-by: Sachin Kamat Signed-off-by: Sylwester Nawrocki Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/s3c-camif/camif-regs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/s3c-camif/camif-regs.c b/drivers/media/platform/s3c-camif/camif-regs.c index 1a3b4fc05ec6..7b22d6c4613b 100644 --- a/drivers/media/platform/s3c-camif/camif-regs.c +++ b/drivers/media/platform/s3c-camif/camif-regs.c @@ -379,7 +379,7 @@ static void camif_hw_set_prescaler(struct camif_vp *vp) camif_write(camif, S3C_CAMIF_REG_CISCPREDST(vp->id, vp->offset), cfg); } -void camif_s3c244x_hw_set_scaler(struct camif_vp *vp) +static void camif_s3c244x_hw_set_scaler(struct camif_vp *vp) { struct camif_dev *camif = vp->camif; struct camif_scaler *scaler = &vp->scaler; @@ -426,7 +426,7 @@ void camif_s3c244x_hw_set_scaler(struct camif_vp *vp) scaler->main_h_ratio, scaler->main_v_ratio); } -void camif_s3c64xx_hw_set_scaler(struct camif_vp *vp) +static void camif_s3c64xx_hw_set_scaler(struct camif_vp *vp) { struct camif_dev *camif = vp->camif; struct camif_scaler *scaler = &vp->scaler; From 99b63ac8b12dd08ce403b0d4cf498615c1ec311f Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Tue, 30 Apr 2013 02:16:21 -0300 Subject: [PATCH 0136/1048] [media] s3c-camif: Use dev_info instead of printk dev_info is preferred to printk. Silences the related checkpatch warning. WARNING: Prefer netdev_info(netdev, ... then dev_info(dev, ... then pr_info(... to printk(KERN_INFO ... Signed-off-by: Sachin Kamat Signed-off-by: Sylwester Nawrocki Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/s3c-camif/camif-regs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/platform/s3c-camif/camif-regs.c b/drivers/media/platform/s3c-camif/camif-regs.c index 7b22d6c4613b..a9e3b16460b8 100644 --- a/drivers/media/platform/s3c-camif/camif-regs.c +++ b/drivers/media/platform/s3c-camif/camif-regs.c @@ -601,6 +601,6 @@ void camif_hw_dump_regs(struct camif_dev *camif, const char *label) pr_info("--- %s ---\n", label); for (i = 0; i < ARRAY_SIZE(registers); i++) { u32 cfg = readl(camif->io_base + registers[i].offset); - printk(KERN_INFO "%s:\t0x%08x\n", registers[i].name, cfg); + dev_info(camif->dev, "%s:\t0x%08x\n", registers[i].name, cfg); } } From 8638a467cc3357c00dadbf3280497f089802bb96 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Tue, 30 Apr 2013 05:04:09 -0300 Subject: [PATCH 0137/1048] [media] s5c73m3: Fix whitespace related warnings Silences the following type of warning: WARNING: space prohibited before semicolon Signed-off-by: Sachin Kamat Signed-off-by: Sylwester Nawrocki Signed-off-by: Mauro Carvalho Chehab --- drivers/media/i2c/s5c73m3/s5c73m3-spi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/media/i2c/s5c73m3/s5c73m3-spi.c b/drivers/media/i2c/s5c73m3/s5c73m3-spi.c index 6f3a9c00fe65..8079e26eb5e2 100644 --- a/drivers/media/i2c/s5c73m3/s5c73m3-spi.c +++ b/drivers/media/i2c/s5c73m3/s5c73m3-spi.c @@ -73,7 +73,7 @@ int s5c73m3_spi_write(struct s5c73m3 *state, const void *addr, memset(padding, 0, sizeof(padding)); - for (i = 0; i < count ; i++) { + for (i = 0; i < count; i++) { r = spi_xmit(spi_dev, (void *)addr + j, tx_size, SPI_DIR_TX); if (r < 0) return r; @@ -98,7 +98,7 @@ int s5c73m3_spi_read(struct s5c73m3 *state, void *addr, unsigned int i, j = 0; int r = 0; - for (i = 0; i < count ; i++) { + for (i = 0; i < count; i++) { r = spi_xmit(spi_dev, addr + j, tx_size, SPI_DIR_RX); if (r < 0) return r; From 24f99dd0fb546b0933564f9697aa5fa5fe9b41da Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Tue, 30 Apr 2013 00:51:33 -0300 Subject: [PATCH 0138/1048] [media] exynos4-is: Remove redundant NULL check in fimc-lite.c clk_unprepare checks for NULL pointer. Hence convert IS_ERR_OR_NULL to IS_ERR only. [s.nawrocki: replaced initialisations to NULL with ERR_PTR() value] Signed-off-by: Sachin Kamat Signed-off-by: Sylwester Nawrocki Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/exynos4-is/fimc-lite.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/media/platform/exynos4-is/fimc-lite.c b/drivers/media/platform/exynos4-is/fimc-lite.c index 2f11ae4fd4a4..80ebf439e352 100644 --- a/drivers/media/platform/exynos4-is/fimc-lite.c +++ b/drivers/media/platform/exynos4-is/fimc-lite.c @@ -1417,12 +1417,12 @@ static void fimc_lite_unregister_capture_subdev(struct fimc_lite *fimc) static void fimc_lite_clk_put(struct fimc_lite *fimc) { - if (IS_ERR_OR_NULL(fimc->clock)) + if (IS_ERR(fimc->clock)) return; clk_unprepare(fimc->clock); clk_put(fimc->clock); - fimc->clock = NULL; + fimc->clock = ERR_PTR(-EINVAL); } static int fimc_lite_clk_get(struct fimc_lite *fimc) @@ -1436,7 +1436,7 @@ static int fimc_lite_clk_get(struct fimc_lite *fimc) ret = clk_prepare(fimc->clock); if (ret < 0) { clk_put(fimc->clock); - fimc->clock = NULL; + fimc->clock = ERR_PTR(-EINVAL); } return ret; } From d46a5a68b1690fc9f47d6b3e13ccef4e79a87e84 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Tue, 30 Apr 2013 02:16:18 -0300 Subject: [PATCH 0139/1048] [media] s3c-camif: Remove redundant NULL check clk_unprepare checks for NULL pointer. Hence convert IS_ERR_OR_NULL to IS_ERR only. [s.nawrocki: added initialisation of the clock array to ERR_PTR() value] Signed-off-by: Sachin Kamat Signed-off-by: Sylwester Nawrocki Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/s3c-camif/camif-core.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/s3c-camif/camif-core.c b/drivers/media/platform/s3c-camif/camif-core.c index 0d0fab1a7b5e..b38574702fe9 100644 --- a/drivers/media/platform/s3c-camif/camif-core.c +++ b/drivers/media/platform/s3c-camif/camif-core.c @@ -341,10 +341,11 @@ static void camif_clk_put(struct camif_dev *camif) int i; for (i = 0; i < CLK_MAX_NUM; i++) { - if (IS_ERR_OR_NULL(camif->clock[i])) + if (IS_ERR(camif->clock[i])) continue; clk_unprepare(camif->clock[i]); clk_put(camif->clock[i]); + camif->clock[i] = ERR_PTR(-EINVAL); } } @@ -352,6 +353,9 @@ static int camif_clk_get(struct camif_dev *camif) { int ret, i; + for (i = 1; i < CLK_MAX_NUM; i++) + camif->clock[i] = ERR_PTR(-EINVAL); + for (i = 0; i < CLK_MAX_NUM; i++) { camif->clock[i] = clk_get(camif->dev, camif_clocks[i]); if (IS_ERR(camif->clock[i])) { From 6a2f18cf58a59ba7de2a5f912b12d9732702969c Mon Sep 17 00:00:00 2001 From: Wei Yongjun Date: Mon, 13 May 2013 01:49:13 -0300 Subject: [PATCH 0140/1048] [media] s5p-tv: fix error return code in mxr_acquire_video() Fix to return a negative error code in the vb2_dma_contig_init_ctx() error handling case instead of 0, as done elsewhere in this function. Also vb2_dma_contig_init_ctx() return ERR_PTR() in case of error and never return NULL, so use IS_ERR() replace IS_ERR_OR_NULL(). Signed-off-by: Wei Yongjun Signed-off-by: Sylwester Nawrocki Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/s5p-tv/mixer_video.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/s5p-tv/mixer_video.c b/drivers/media/platform/s5p-tv/mixer_video.c index ef0efdf422fe..641b1f071e06 100644 --- a/drivers/media/platform/s5p-tv/mixer_video.c +++ b/drivers/media/platform/s5p-tv/mixer_video.c @@ -81,8 +81,9 @@ int mxr_acquire_video(struct mxr_device *mdev, } mdev->alloc_ctx = vb2_dma_contig_init_ctx(mdev->dev); - if (IS_ERR_OR_NULL(mdev->alloc_ctx)) { + if (IS_ERR(mdev->alloc_ctx)) { mxr_err(mdev, "could not acquire vb2 allocator\n"); + ret = PTR_ERR(mdev->alloc_ctx); goto fail_v4l2_dev; } From c28c99e7741f848ffe808a578b265dd2bb23a52f Mon Sep 17 00:00:00 2001 From: Sylwester Nawrocki Date: Wed, 8 May 2013 14:24:14 -0300 Subject: [PATCH 0141/1048] [media] exynos4-is: Fix example dts in .../bindings/samsung-fimc.txt The s5c73m3 sensor node should be off an I2C bus controller node. Signed-off-by: Sylwester Nawrocki Signed-off-by: Kyungmin Park Signed-off-by: Mauro Carvalho Chehab --- .../bindings/media/samsung-fimc.txt | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/Documentation/devicetree/bindings/media/samsung-fimc.txt b/Documentation/devicetree/bindings/media/samsung-fimc.txt index 51c776b7f7a3..96312f6c4c26 100644 --- a/Documentation/devicetree/bindings/media/samsung-fimc.txt +++ b/Documentation/devicetree/bindings/media/samsung-fimc.txt @@ -127,22 +127,22 @@ Example: }; }; }; - }; - /* MIPI CSI-2 bus IF sensor */ - s5c73m3: sensor@0x1a { - compatible = "samsung,s5c73m3"; - reg = <0x1a>; - vddio-supply = <...>; + /* MIPI CSI-2 bus IF sensor */ + s5c73m3: sensor@0x1a { + compatible = "samsung,s5c73m3"; + reg = <0x1a>; + vddio-supply = <...>; - clock-frequency = <24000000>; - clocks = <...>; - clock-names = "mclk"; + clock-frequency = <24000000>; + clocks = <...>; + clock-names = "mclk"; - port { - s5c73m3_1: endpoint { - data-lanes = <1 2 3 4>; - remote-endpoint = <&csis0_ep>; + port { + s5c73m3_1: endpoint { + data-lanes = <1 2 3 4>; + remote-endpoint = <&csis0_ep>; + }; }; }; }; From 8a0c28f5ba8965790b20a82208226567dad69a2a Mon Sep 17 00:00:00 2001 From: Sylwester Nawrocki Date: Tue, 30 Apr 2013 09:27:08 -0300 Subject: [PATCH 0142/1048] [media] exynos4-is: Remove platform_device_id table at fimc-lite driver The driver id_table is unused since all SoCs containing the FIMC-LITE IP block have been dt-only. Just remove it. Signed-off-by: Sylwester Nawrocki Signed-off-by: Kyungmin Park Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/exynos4-is/fimc-lite.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/drivers/media/platform/exynos4-is/fimc-lite.c b/drivers/media/platform/exynos4-is/fimc-lite.c index 80ebf439e352..d770f33150f5 100644 --- a/drivers/media/platform/exynos4-is/fimc-lite.c +++ b/drivers/media/platform/exynos4-is/fimc-lite.c @@ -1,8 +1,8 @@ /* * Samsung EXYNOS FIMC-LITE (camera host interface) driver * - * Copyright (C) 2012 Samsung Electronics Co., Ltd. - * Sylwester Nawrocki + * Copyright (C) 2012 - 2013 Samsung Electronics Co., Ltd. + * Author: Sylwester Nawrocki * * 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 @@ -1626,15 +1626,6 @@ static struct flite_drvdata fimc_lite_drvdata_exynos4 = { .out_hor_offs_align = 8, }; -static struct platform_device_id fimc_lite_driver_ids[] = { - { - .name = "exynos-fimc-lite", - .driver_data = (unsigned long)&fimc_lite_drvdata_exynos4, - }, - { /* sentinel */ }, -}; -MODULE_DEVICE_TABLE(platform, fimc_lite_driver_ids); - static const struct of_device_id flite_of_match[] = { { .compatible = "samsung,exynos4212-fimc-lite", @@ -1647,7 +1638,6 @@ MODULE_DEVICE_TABLE(of, flite_of_match); static struct platform_driver fimc_lite_driver = { .probe = fimc_lite_probe, .remove = fimc_lite_remove, - .id_table = fimc_lite_driver_ids, .driver = { .of_match_table = flite_of_match, .name = FIMC_LITE_DRV_NAME, From 793ad32d1b7159772feb36ac41e265786729e78c Mon Sep 17 00:00:00 2001 From: Sylwester Nawrocki Date: Tue, 30 Apr 2013 09:27:53 -0300 Subject: [PATCH 0143/1048] [media] exynos4-is: Correct querycap ioctl handling at fimc-lite driver Fill in properly bus_info and card fields and set device_caps. The querycap ioctl handler is renamed for consistency with the other ioctls. Signed-off-by: Sylwester Nawrocki Signed-off-by: Kyungmin Park Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/exynos4-is/fimc-lite.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/drivers/media/platform/exynos4-is/fimc-lite.c b/drivers/media/platform/exynos4-is/fimc-lite.c index d770f33150f5..5634799ab944 100644 --- a/drivers/media/platform/exynos4-is/fimc-lite.c +++ b/drivers/media/platform/exynos4-is/fimc-lite.c @@ -637,13 +637,18 @@ static void fimc_lite_try_compose(struct fimc_lite *fimc, struct v4l2_rect *r) /* * Video node ioctl operations */ -static int fimc_vidioc_querycap_capture(struct file *file, void *priv, +static int fimc_lite_querycap(struct file *file, void *priv, struct v4l2_capability *cap) { + struct fimc_lite *fimc = video_drvdata(file); + strlcpy(cap->driver, FIMC_LITE_DRV_NAME, sizeof(cap->driver)); - cap->bus_info[0] = 0; - cap->card[0] = 0; - cap->capabilities = V4L2_CAP_STREAMING; + strlcpy(cap->card, FIMC_LITE_DRV_NAME, sizeof(cap->card)); + snprintf(cap->bus_info, sizeof(cap->bus_info), "platform:%s", + dev_name(&fimc->pdev->dev)); + + cap->device_caps = V4L2_CAP_STREAMING; + cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS; return 0; } @@ -938,7 +943,7 @@ static int fimc_lite_s_selection(struct file *file, void *fh, } static const struct v4l2_ioctl_ops fimc_lite_ioctl_ops = { - .vidioc_querycap = fimc_vidioc_querycap_capture, + .vidioc_querycap = fimc_lite_querycap, .vidioc_enum_fmt_vid_cap_mplane = fimc_lite_enum_fmt_mplane, .vidioc_try_fmt_vid_cap_mplane = fimc_lite_try_fmt_mplane, .vidioc_s_fmt_vid_cap_mplane = fimc_lite_s_fmt_mplane, From 44048752345460df738b87ebec82c9bfc8257943 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Fri, 17 May 2013 00:31:01 -0300 Subject: [PATCH 0144/1048] [media] s5p-tv: Fix incorrect usage of IS_ERR_OR_NULL in hdmi_drv.c NULL check on clocks obtained using common clock APIs should not be done. Use IS_ERR only. Signed-off-by: Sachin Kamat Signed-off-by: Sylwester Nawrocki Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/s5p-tv/hdmi_drv.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/drivers/media/platform/s5p-tv/hdmi_drv.c b/drivers/media/platform/s5p-tv/hdmi_drv.c index 4e86626dad4b..cd525f193240 100644 --- a/drivers/media/platform/s5p-tv/hdmi_drv.c +++ b/drivers/media/platform/s5p-tv/hdmi_drv.c @@ -755,6 +755,15 @@ static const struct dev_pm_ops hdmi_pm_ops = { .runtime_resume = hdmi_runtime_resume, }; +static void hdmi_resource_clear_clocks(struct hdmi_resources *res) +{ + res->hdmi = ERR_PTR(-EINVAL); + res->sclk_hdmi = ERR_PTR(-EINVAL); + res->sclk_pixel = ERR_PTR(-EINVAL); + res->sclk_hdmiphy = ERR_PTR(-EINVAL); + res->hdmiphy = ERR_PTR(-EINVAL); +} + static void hdmi_resources_cleanup(struct hdmi_device *hdev) { struct hdmi_resources *res = &hdev->res; @@ -765,17 +774,18 @@ static void hdmi_resources_cleanup(struct hdmi_device *hdev) regulator_bulk_free(res->regul_count, res->regul_bulk); /* kfree is NULL-safe */ kfree(res->regul_bulk); - if (!IS_ERR_OR_NULL(res->hdmiphy)) + if (!IS_ERR(res->hdmiphy)) clk_put(res->hdmiphy); - if (!IS_ERR_OR_NULL(res->sclk_hdmiphy)) + if (!IS_ERR(res->sclk_hdmiphy)) clk_put(res->sclk_hdmiphy); - if (!IS_ERR_OR_NULL(res->sclk_pixel)) + if (!IS_ERR(res->sclk_pixel)) clk_put(res->sclk_pixel); - if (!IS_ERR_OR_NULL(res->sclk_hdmi)) + if (!IS_ERR(res->sclk_hdmi)) clk_put(res->sclk_hdmi); - if (!IS_ERR_OR_NULL(res->hdmi)) + if (!IS_ERR(res->hdmi)) clk_put(res->hdmi); memset(res, 0, sizeof(*res)); + hdmi_resource_clear_clocks(res); } static int hdmi_resources_init(struct hdmi_device *hdev) @@ -793,8 +803,9 @@ static int hdmi_resources_init(struct hdmi_device *hdev) dev_dbg(dev, "HDMI resource init\n"); memset(res, 0, sizeof(*res)); - /* get clocks, power */ + hdmi_resource_clear_clocks(res); + /* get clocks, power */ res->hdmi = clk_get(dev, "hdmi"); if (IS_ERR(res->hdmi)) { dev_err(dev, "failed to get clock 'hdmi'\n"); From 0781c057e3fd49e096ec2ea7fa5d6ad18a2f42bb Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Fri, 17 May 2013 00:31:02 -0300 Subject: [PATCH 0145/1048] [media] s5p-tv: Fix incorrect usage of IS_ERR_OR_NULL in mixer_drv.c NULL check on clocks obtained using common clock APIs should not be done. Use IS_ERR only. [s.nawrocki: removed unrelated whitespace change] Signed-off-by: Sachin Kamat Signed-off-by: Sylwester Nawrocki Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/s5p-tv/mixer_drv.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/drivers/media/platform/s5p-tv/mixer_drv.c b/drivers/media/platform/s5p-tv/mixer_drv.c index 5733033a6ead..51805a5e2beb 100644 --- a/drivers/media/platform/s5p-tv/mixer_drv.c +++ b/drivers/media/platform/s5p-tv/mixer_drv.c @@ -211,6 +211,15 @@ fail: return ret; } +static void mxr_resource_clear_clocks(struct mxr_resources *res) +{ + res->mixer = ERR_PTR(-EINVAL); + res->vp = ERR_PTR(-EINVAL); + res->sclk_mixer = ERR_PTR(-EINVAL); + res->sclk_hdmi = ERR_PTR(-EINVAL); + res->sclk_dac = ERR_PTR(-EINVAL); +} + static void mxr_release_plat_resources(struct mxr_device *mdev) { free_irq(mdev->res.irq, mdev); @@ -222,15 +231,15 @@ static void mxr_release_clocks(struct mxr_device *mdev) { struct mxr_resources *res = &mdev->res; - if (!IS_ERR_OR_NULL(res->sclk_dac)) + if (!IS_ERR(res->sclk_dac)) clk_put(res->sclk_dac); - if (!IS_ERR_OR_NULL(res->sclk_hdmi)) + if (!IS_ERR(res->sclk_hdmi)) clk_put(res->sclk_hdmi); - if (!IS_ERR_OR_NULL(res->sclk_mixer)) + if (!IS_ERR(res->sclk_mixer)) clk_put(res->sclk_mixer); - if (!IS_ERR_OR_NULL(res->vp)) + if (!IS_ERR(res->vp)) clk_put(res->vp); - if (!IS_ERR_OR_NULL(res->mixer)) + if (!IS_ERR(res->mixer)) clk_put(res->mixer); } @@ -239,6 +248,8 @@ static int mxr_acquire_clocks(struct mxr_device *mdev) struct mxr_resources *res = &mdev->res; struct device *dev = mdev->dev; + mxr_resource_clear_clocks(res); + res->mixer = clk_get(dev, "mixer"); if (IS_ERR(res->mixer)) { mxr_err(mdev, "failed to get clock 'mixer'\n"); @@ -299,6 +310,7 @@ static void mxr_release_resources(struct mxr_device *mdev) mxr_release_clocks(mdev); mxr_release_plat_resources(mdev); memset(&mdev->res, 0, sizeof(mdev->res)); + mxr_resource_clear_clocks(&mdev->res); } static void mxr_release_layers(struct mxr_device *mdev) From 0425d7963af85a01b3d96b42977cafe41f94e50e Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Thu, 23 May 2013 00:51:18 -0300 Subject: [PATCH 0146/1048] [media] exynos-gsc: Remove redundant use of of_match_ptr macro This is a DT only driver and exynos_gsc_match is always compiled in. Hence of_match_ptr is unnecessary. Signed-off-by: Sachin Kamat Signed-off-by: Sylwester Nawrocki Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/exynos-gsc/gsc-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/platform/exynos-gsc/gsc-core.c b/drivers/media/platform/exynos-gsc/gsc-core.c index 33b5ffc8d66d..559fab2a2d67 100644 --- a/drivers/media/platform/exynos-gsc/gsc-core.c +++ b/drivers/media/platform/exynos-gsc/gsc-core.c @@ -988,7 +988,7 @@ static void *gsc_get_drv_data(struct platform_device *pdev) if (pdev->dev.of_node) { const struct of_device_id *match; - match = of_match_node(of_match_ptr(exynos_gsc_match), + match = of_match_node(exynos_gsc_match, pdev->dev.of_node); if (match) driver_data = (struct gsc_driverdata *)match->data; From a40a138291a3cc9110b300f35977479914a1613b Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Thu, 23 May 2013 00:51:19 -0300 Subject: [PATCH 0147/1048] [media] s5p-mfc: Remove redundant use of of_match_ptr macro 'exynos_mfc_match' is always compiled in. Hence of_match_ptr is unnecessary. Signed-off-by: Sachin Kamat Signed-off-by: Sylwester Nawrocki Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/s5p-mfc/s5p_mfc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc.c b/drivers/media/platform/s5p-mfc/s5p_mfc.c index 01f9ae0dadb0..5d0419bd6aff 100644 --- a/drivers/media/platform/s5p-mfc/s5p_mfc.c +++ b/drivers/media/platform/s5p-mfc/s5p_mfc.c @@ -1426,7 +1426,7 @@ static void *mfc_get_drv_data(struct platform_device *pdev) if (pdev->dev.of_node) { const struct of_device_id *match; - match = of_match_node(of_match_ptr(exynos_mfc_match), + match = of_match_node(exynos_mfc_match, pdev->dev.of_node); if (match) driver_data = (struct s5p_mfc_variant *)match->data; From e0e9f67afcd5e06bc1ff6ecbf130635673a41d48 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Tue, 16 Apr 2013 02:02:21 -0300 Subject: [PATCH 0148/1048] [media] exynos4-is: Staticize local symbols These symbols are used only in their respective files and hence should be made static. [s.nawrocki@samsung.com: dropped the __fimc_is_hw_update_param() function change] Signed-off-by: Sachin Kamat Signed-off-by: Sylwester Nawrocki Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/exynos4-is/fimc-is-i2c.c | 2 +- drivers/media/platform/exynos4-is/fimc-is-param.c | 4 ++-- drivers/media/platform/exynos4-is/fimc-is.c | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/media/platform/exynos4-is/fimc-is-i2c.c b/drivers/media/platform/exynos4-is/fimc-is-i2c.c index c397777d7cbb..617a798d9235 100644 --- a/drivers/media/platform/exynos4-is/fimc-is-i2c.c +++ b/drivers/media/platform/exynos4-is/fimc-is-i2c.c @@ -96,7 +96,7 @@ static int fimc_is_i2c_resume(struct device *dev) return clk_prepare_enable(isp_i2c->clock); } -UNIVERSAL_DEV_PM_OPS(fimc_is_i2c_pm_ops, fimc_is_i2c_suspend, +static UNIVERSAL_DEV_PM_OPS(fimc_is_i2c_pm_ops, fimc_is_i2c_suspend, fimc_is_i2c_resume, NULL); static const struct of_device_id fimc_is_i2c_of_match[] = { diff --git a/drivers/media/platform/exynos4-is/fimc-is-param.c b/drivers/media/platform/exynos4-is/fimc-is-param.c index 53fe2a2b4db3..c435db0da673 100644 --- a/drivers/media/platform/exynos4-is/fimc-is-param.c +++ b/drivers/media/platform/exynos4-is/fimc-is-param.c @@ -38,7 +38,7 @@ static void __hw_param_copy(void *dst, void *src) memcpy(dst, src, FIMC_IS_PARAM_MAX_SIZE); } -void __fimc_is_hw_update_param_global_shotmode(struct fimc_is *is) +static void __fimc_is_hw_update_param_global_shotmode(struct fimc_is *is) { struct param_global_shotmode *dst, *src; @@ -47,7 +47,7 @@ void __fimc_is_hw_update_param_global_shotmode(struct fimc_is *is) __hw_param_copy(dst, src); } -void __fimc_is_hw_update_param_sensor_framerate(struct fimc_is *is) +static void __fimc_is_hw_update_param_sensor_framerate(struct fimc_is *is) { struct param_sensor_framerate *dst, *src; diff --git a/drivers/media/platform/exynos4-is/fimc-is.c b/drivers/media/platform/exynos4-is/fimc-is.c index 47c6363d04e2..cdb6b5e27336 100644 --- a/drivers/media/platform/exynos4-is/fimc-is.c +++ b/drivers/media/platform/exynos4-is/fimc-is.c @@ -137,7 +137,7 @@ static int fimc_is_setup_clocks(struct fimc_is *is) ATCLK_MCUISP_FREQUENCY); } -int fimc_is_enable_clocks(struct fimc_is *is) +static int fimc_is_enable_clocks(struct fimc_is *is) { int i, ret; @@ -157,7 +157,7 @@ int fimc_is_enable_clocks(struct fimc_is *is) return 0; } -void fimc_is_disable_clocks(struct fimc_is *is) +static void fimc_is_disable_clocks(struct fimc_is *is) { int i; From a44e3b206a26e3978d1041b4145e5afc4ed52e86 Mon Sep 17 00:00:00 2001 From: Sylwester Nawrocki Date: Fri, 31 May 2013 19:43:35 -0300 Subject: [PATCH 0149/1048] [media] s5c73m3: Do not ignore errors from regulator_enable() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes following compilation warning: drivers/media/i2c/s5c73m3/s5c73m3-core.c: In function ‘__s5c73m3_power_off’: drivers/media/i2c/s5c73m3/s5c73m3-core.c:1389:19: warning: ignoring return value of ‘regulator_enable’, declared with attribute warn_unused_result Signed-off-by: Sylwester Nawrocki Signed-off-by: Mauro Carvalho Chehab --- drivers/media/i2c/s5c73m3/s5c73m3-core.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/media/i2c/s5c73m3/s5c73m3-core.c b/drivers/media/i2c/s5c73m3/s5c73m3-core.c index d3e867a7a565..402da96f5a71 100644 --- a/drivers/media/i2c/s5c73m3/s5c73m3-core.c +++ b/drivers/media/i2c/s5c73m3/s5c73m3-core.c @@ -1385,9 +1385,12 @@ static int __s5c73m3_power_off(struct s5c73m3 *state) } return 0; err: - for (++i; i < S5C73M3_MAX_SUPPLIES; i++) - regulator_enable(state->supplies[i].consumer); - + for (++i; i < S5C73M3_MAX_SUPPLIES; i++) { + int r = regulator_enable(state->supplies[i].consumer); + if (r < 0) + v4l2_err(&state->oif_sd, "Failed to reenable %s: %d\n", + state->supplies[i].supply, r); + } return ret; } From 045a1faca83cdaa54dd88f9a2875debdea5d79fa Mon Sep 17 00:00:00 2001 From: Sylwester Nawrocki Date: Mon, 10 Jun 2013 08:51:44 -0300 Subject: [PATCH 0150/1048] [media] exynos4-is: Move common functions to a separate module Create a common module (exynos4-is-common.ko) for common functions used across the exynos4-is video device and subdev drivers. Signed-off-by: Sylwester Nawrocki Signed-off-by: Kyungmin Park Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/exynos4-is/Kconfig | 7 +++- drivers/media/platform/exynos4-is/Makefile | 5 ++- drivers/media/platform/exynos4-is/common.c | 41 +++++++++++++++++++ drivers/media/platform/exynos4-is/common.h | 12 ++++++ drivers/media/platform/exynos4-is/fimc-lite.c | 29 ++----------- 5 files changed, 66 insertions(+), 28 deletions(-) create mode 100644 drivers/media/platform/exynos4-is/common.c create mode 100644 drivers/media/platform/exynos4-is/common.h diff --git a/drivers/media/platform/exynos4-is/Kconfig b/drivers/media/platform/exynos4-is/Kconfig index 6ff99b5849f9..c622532174e3 100644 --- a/drivers/media/platform/exynos4-is/Kconfig +++ b/drivers/media/platform/exynos4-is/Kconfig @@ -8,12 +8,16 @@ config VIDEO_SAMSUNG_EXYNOS4_IS if VIDEO_SAMSUNG_EXYNOS4_IS +config VIDEO_EXYNOS4_IS_COMMON + tristate + config VIDEO_S5P_FIMC tristate "S5P/EXYNOS4 FIMC/CAMIF camera interface driver" depends on I2C select VIDEOBUF2_DMA_CONTIG select V4L2_MEM2MEM_DEV select MFD_SYSCON if OF + select VIDEO_EXYNOS4_IS_COMMON help This is a V4L2 driver for Samsung S5P and EXYNOS4 SoC camera host interface and video postprocessor (FIMC) devices. @@ -38,6 +42,7 @@ config VIDEO_EXYNOS_FIMC_LITE tristate "EXYNOS FIMC-LITE camera interface driver" depends on I2C select VIDEOBUF2_DMA_CONTIG + select VIDEO_EXYNOS4_IS_COMMON help This is a V4L2 driver for Samsung EXYNOS4/5 SoC FIMC-LITE camera host interface. @@ -58,4 +63,4 @@ config VIDEO_EXYNOS4_FIMC_IS To compile this driver as a module, choose M here: the module will be called exynos4-fimc-is. -endif # VIDEO_SAMSUNG_S5P_FIMC +endif # VIDEO_SAMSUNG_EXYNOS4_IS diff --git a/drivers/media/platform/exynos4-is/Makefile b/drivers/media/platform/exynos4-is/Makefile index f25f46377399..c2ff29ba6856 100644 --- a/drivers/media/platform/exynos4-is/Makefile +++ b/drivers/media/platform/exynos4-is/Makefile @@ -1,10 +1,13 @@ s5p-fimc-objs := fimc-core.o fimc-reg.o fimc-m2m.o fimc-capture.o media-dev.o exynos-fimc-lite-objs += fimc-lite-reg.o fimc-lite.o +s5p-csis-objs := mipi-csis.o +exynos4-is-common-objs := common.o + exynos-fimc-is-objs := fimc-is.o fimc-isp.o fimc-is-sensor.o fimc-is-regs.o exynos-fimc-is-objs += fimc-is-param.o fimc-is-errno.o fimc-is-i2c.o -s5p-csis-objs := mipi-csis.o obj-$(CONFIG_VIDEO_S5P_MIPI_CSIS) += s5p-csis.o obj-$(CONFIG_VIDEO_EXYNOS_FIMC_LITE) += exynos-fimc-lite.o obj-$(CONFIG_VIDEO_EXYNOS4_FIMC_IS) += exynos-fimc-is.o obj-$(CONFIG_VIDEO_S5P_FIMC) += s5p-fimc.o +obj-$(CONFIG_VIDEO_EXYNOS4_IS_COMMON) += exynos4-is-common.o diff --git a/drivers/media/platform/exynos4-is/common.c b/drivers/media/platform/exynos4-is/common.c new file mode 100644 index 000000000000..57f9010cee50 --- /dev/null +++ b/drivers/media/platform/exynos4-is/common.c @@ -0,0 +1,41 @@ +/* + * Samsung S5P/EXYNOS4 SoC Camera Subsystem driver + * + * Copyright (C) 2013 Samsung Electronics Co., Ltd. + * Author: Sylwester Nawrocki + * + * 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. + */ + +#include +#include +#include "common.h" + +/* Called with the media graph mutex held or entity->stream_count > 0. */ +struct v4l2_subdev *fimc_find_remote_sensor(struct media_entity *entity) +{ + struct media_pad *pad = &entity->pads[0]; + struct v4l2_subdev *sd; + + while (pad->flags & MEDIA_PAD_FL_SINK) { + /* source pad */ + pad = media_entity_remote_pad(pad); + if (pad == NULL || + media_entity_type(pad->entity) != MEDIA_ENT_T_V4L2_SUBDEV) + break; + + sd = media_entity_to_v4l2_subdev(pad->entity); + + if (sd->grp_id == GRP_ID_FIMC_IS_SENSOR || + sd->grp_id == GRP_ID_SENSOR) + return sd; + /* sink pad */ + pad = &sd->entity.pads[0]; + } + return NULL; +} +EXPORT_SYMBOL(fimc_find_remote_sensor); + +MODULE_LICENSE("GPL"); diff --git a/drivers/media/platform/exynos4-is/common.h b/drivers/media/platform/exynos4-is/common.h new file mode 100644 index 000000000000..3c398039ba28 --- /dev/null +++ b/drivers/media/platform/exynos4-is/common.h @@ -0,0 +1,12 @@ +/* + * Copyright (C) 2013 Samsung Electronics Co., Ltd. + * + * 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. + */ + +#include +#include + +struct v4l2_subdev *fimc_find_remote_sensor(struct media_entity *entity); diff --git a/drivers/media/platform/exynos4-is/fimc-lite.c b/drivers/media/platform/exynos4-is/fimc-lite.c index 5634799ab944..6daa88531e6e 100644 --- a/drivers/media/platform/exynos4-is/fimc-lite.c +++ b/drivers/media/platform/exynos4-is/fimc-lite.c @@ -32,6 +32,7 @@ #include #include +#include "common.h" #include "fimc-core.h" #include "fimc-lite.h" #include "fimc-lite-reg.h" @@ -131,30 +132,6 @@ static const struct fimc_fmt *fimc_lite_find_format(const u32 *pixelformat, return def_fmt; } -/* Called with the media graph mutex held or @me stream_count > 0. */ -static struct v4l2_subdev *__find_remote_sensor(struct media_entity *me) -{ - struct media_pad *pad = &me->pads[0]; - struct v4l2_subdev *sd; - - while (pad->flags & MEDIA_PAD_FL_SINK) { - /* source pad */ - pad = media_entity_remote_pad(pad); - if (pad == NULL || - media_entity_type(pad->entity) != MEDIA_ENT_T_V4L2_SUBDEV) - break; - - sd = media_entity_to_v4l2_subdev(pad->entity); - - if (sd->grp_id == GRP_ID_FIMC_IS_SENSOR || - sd->grp_id == GRP_ID_SENSOR) - return sd; - /* sink pad */ - pad = &sd->entity.pads[0]; - } - return NULL; -} - static int fimc_lite_hw_init(struct fimc_lite *fimc, bool isp_output) { struct fimc_source_info *si; @@ -830,7 +807,7 @@ static int fimc_lite_streamon(struct file *file, void *priv, if (ret < 0) goto err_p_stop; - fimc->sensor = __find_remote_sensor(&fimc->subdev.entity); + fimc->sensor = fimc_find_remote_sensor(&fimc->subdev.entity); ret = vb2_ioctl_streamon(file, priv, type); if (!ret) { @@ -1212,7 +1189,7 @@ static int fimc_lite_subdev_s_stream(struct v4l2_subdev *sd, int on) * The pipeline links are protected through entity.stream_count * so there is no need to take the media graph mutex here. */ - fimc->sensor = __find_remote_sensor(&sd->entity); + fimc->sensor = fimc_find_remote_sensor(&sd->entity); if (atomic_read(&fimc->out_path) != FIMC_IO_ISP) return -ENOIOCTLCMD; From bc7584b0b7a99326d31195f81f7494efe9fe0c0f Mon Sep 17 00:00:00 2001 From: Sylwester Nawrocki Date: Fri, 31 May 2013 11:37:18 -0300 Subject: [PATCH 0151/1048] [media] exynos4-is: Add struct exynos_video_entity This patch introduces common structure for the video entities to handle all video nodes and media pipelines associated with them in more generic way. Signed-off-by: Sylwester Nawrocki Signed-off-by: Kyungmin Park Signed-off-by: Mauro Carvalho Chehab --- .../media/platform/exynos4-is/fimc-capture.c | 43 +++++++++++-------- drivers/media/platform/exynos4-is/fimc-core.h | 4 +- .../media/platform/exynos4-is/fimc-lite-reg.c | 2 +- drivers/media/platform/exynos4-is/fimc-lite.c | 20 ++++----- drivers/media/platform/exynos4-is/fimc-lite.h | 4 +- drivers/media/platform/exynos4-is/fimc-reg.c | 7 +-- drivers/media/platform/exynos4-is/media-dev.c | 4 +- drivers/media/platform/exynos4-is/media-dev.h | 8 ++-- include/media/s5p_fimc.h | 5 +++ 9 files changed, 55 insertions(+), 42 deletions(-) diff --git a/drivers/media/platform/exynos4-is/fimc-capture.c b/drivers/media/platform/exynos4-is/fimc-capture.c index a8b9b06d96aa..b80ca59a099d 100644 --- a/drivers/media/platform/exynos4-is/fimc-capture.c +++ b/drivers/media/platform/exynos4-is/fimc-capture.c @@ -320,6 +320,7 @@ static void buffer_queue(struct vb2_buffer *vb); int fimc_capture_resume(struct fimc_dev *fimc) { struct fimc_vid_cap *vid_cap = &fimc->vid_cap; + struct exynos_video_entity *ve = &vid_cap->ve; struct fimc_vid_buffer *buf; int i; @@ -329,7 +330,7 @@ int fimc_capture_resume(struct fimc_dev *fimc) INIT_LIST_HEAD(&fimc->vid_cap.active_buf_q); vid_cap->buf_index = 0; fimc_pipeline_call(fimc, open, &fimc->pipeline, - &vid_cap->vfd.entity, false); + &ve->vdev.entity, false); fimc_capture_hw_init(fimc); clear_bit(ST_CAPT_SUSPENDED, &fimc->state); @@ -397,7 +398,7 @@ static int buffer_prepare(struct vb2_buffer *vb) unsigned long size = ctx->d_frame.payload[i]; if (vb2_plane_size(vb, i) < size) { - v4l2_err(&ctx->fimc_dev->vid_cap.vfd, + v4l2_err(&ctx->fimc_dev->vid_cap.ve.vdev, "User buffer too small (%ld < %ld)\n", vb2_plane_size(vb, i), size); return -EINVAL; @@ -415,6 +416,7 @@ static void buffer_queue(struct vb2_buffer *vb) struct fimc_ctx *ctx = vb2_get_drv_priv(vb->vb2_queue); struct fimc_dev *fimc = ctx->fimc_dev; struct fimc_vid_cap *vid_cap = &fimc->vid_cap; + struct exynos_video_entity *ve = &vid_cap->ve; unsigned long flags; int min_bufs; @@ -454,7 +456,7 @@ static void buffer_queue(struct vb2_buffer *vb) ret = fimc_pipeline_call(fimc, set_stream, &fimc->pipeline, 1); if (ret < 0) - v4l2_err(&vid_cap->vfd, "stream on failed: %d\n", ret); + v4l2_err(&ve->vdev, "stream on failed: %d\n", ret); return; } spin_unlock_irqrestore(&fimc->slock, flags); @@ -503,11 +505,12 @@ static int fimc_capture_set_default_format(struct fimc_dev *fimc); static int fimc_capture_open(struct file *file) { struct fimc_dev *fimc = video_drvdata(file); + struct exynos_video_entity *ve = &fimc->vid_cap.ve; int ret = -EBUSY; dbg("pid: %d, state: 0x%lx", task_pid_nr(current), fimc->state); - fimc_md_graph_lock(fimc); + fimc_md_graph_lock(ve); mutex_lock(&fimc->lock); if (fimc_m2m_active(fimc)) @@ -526,7 +529,7 @@ static int fimc_capture_open(struct file *file) if (v4l2_fh_is_singular_file(file)) { ret = fimc_pipeline_call(fimc, open, &fimc->pipeline, - &fimc->vid_cap.vfd.entity, true); + &fimc->vid_cap.ve.vdev.entity, true); if (!ret && !fimc->vid_cap.user_subdev_api) ret = fimc_capture_set_default_format(fimc); @@ -544,7 +547,7 @@ static int fimc_capture_open(struct file *file) } unlock: mutex_unlock(&fimc->lock); - fimc_md_graph_unlock(fimc); + fimc_md_graph_unlock(ve); return ret; } @@ -560,7 +563,7 @@ static int fimc_capture_release(struct file *file) if (v4l2_fh_is_singular_file(file)) { if (vc->streaming) { - media_entity_pipeline_stop(&vc->vfd.entity); + media_entity_pipeline_stop(&vc->ve.vdev.entity); vc->streaming = false; } clear_bit(ST_CAPT_BUSY, &fimc->state); @@ -935,11 +938,12 @@ static int fimc_cap_try_fmt_mplane(struct file *file, void *fh, struct v4l2_pix_format_mplane *pix = &f->fmt.pix_mp; struct fimc_dev *fimc = video_drvdata(file); struct fimc_ctx *ctx = fimc->vid_cap.ctx; + struct exynos_video_entity *ve = &fimc->vid_cap.ve; struct v4l2_mbus_framefmt mf; struct fimc_fmt *ffmt = NULL; int ret = 0; - fimc_md_graph_lock(fimc); + fimc_md_graph_lock(ve); mutex_lock(&fimc->lock); if (fimc_jpeg_fourcc(pix->pixelformat)) { @@ -975,7 +979,7 @@ static int fimc_cap_try_fmt_mplane(struct file *file, void *fh, pix->plane_fmt, ffmt->memplanes, true); unlock: mutex_unlock(&fimc->lock); - fimc_md_graph_unlock(fimc); + fimc_md_graph_unlock(ve); return ret; } @@ -1076,7 +1080,7 @@ static int fimc_cap_s_fmt_mplane(struct file *file, void *priv, struct fimc_dev *fimc = video_drvdata(file); int ret; - fimc_md_graph_lock(fimc); + fimc_md_graph_lock(&fimc->vid_cap.ve); mutex_lock(&fimc->lock); /* * The graph is walked within __fimc_capture_set_format() to set @@ -1088,8 +1092,8 @@ static int fimc_cap_s_fmt_mplane(struct file *file, void *priv, */ ret = __fimc_capture_set_format(fimc, f); + fimc_md_graph_unlock(&fimc->vid_cap.ve); mutex_unlock(&fimc->lock); - fimc_md_graph_unlock(fimc); return ret; } @@ -1209,7 +1213,7 @@ static int fimc_cap_streamon(struct file *file, void *priv, struct fimc_dev *fimc = video_drvdata(file); struct fimc_pipeline *p = &fimc->pipeline; struct fimc_vid_cap *vc = &fimc->vid_cap; - struct media_entity *entity = &vc->vfd.entity; + struct media_entity *entity = &vc->ve.vdev.entity; struct fimc_source_info *si = NULL; struct v4l2_subdev *sd; int ret; @@ -1259,14 +1263,15 @@ static int fimc_cap_streamoff(struct file *file, void *priv, enum v4l2_buf_type type) { struct fimc_dev *fimc = video_drvdata(file); + struct fimc_vid_cap *vc = &fimc->vid_cap; int ret; ret = vb2_ioctl_streamoff(file, priv, type); if (ret < 0) return ret; - media_entity_pipeline_stop(&fimc->vid_cap.vfd.entity); - fimc->vid_cap.streaming = false; + media_entity_pipeline_stop(&vc->ve.vdev.entity); + vc->streaming = false; return 0; } @@ -1735,7 +1740,7 @@ static int fimc_capture_set_default_format(struct fimc_dev *fimc) static int fimc_register_capture_device(struct fimc_dev *fimc, struct v4l2_device *v4l2_dev) { - struct video_device *vfd = &fimc->vid_cap.vfd; + struct video_device *vfd = &fimc->vid_cap.ve.vdev; struct vb2_queue *q = &fimc->vid_cap.vbq; struct fimc_ctx *ctx; struct fimc_vid_cap *vid_cap; @@ -1840,15 +1845,17 @@ static int fimc_capture_subdev_registered(struct v4l2_subdev *sd) static void fimc_capture_subdev_unregistered(struct v4l2_subdev *sd) { struct fimc_dev *fimc = v4l2_get_subdevdata(sd); + struct video_device *vdev; if (fimc == NULL) return; fimc_unregister_m2m_device(fimc); + vdev = &fimc->vid_cap.ve.vdev; - if (video_is_registered(&fimc->vid_cap.vfd)) { - video_unregister_device(&fimc->vid_cap.vfd); - media_entity_cleanup(&fimc->vid_cap.vfd.entity); + if (video_is_registered(vdev)) { + video_unregister_device(vdev); + media_entity_cleanup(&vdev->entity); fimc->pipeline_ops = NULL; } kfree(fimc->vid_cap.ctx); diff --git a/drivers/media/platform/exynos4-is/fimc-core.h b/drivers/media/platform/exynos4-is/fimc-core.h index 539a3f71c16a..dfecef6bfefe 100644 --- a/drivers/media/platform/exynos4-is/fimc-core.h +++ b/drivers/media/platform/exynos4-is/fimc-core.h @@ -283,8 +283,8 @@ struct fimc_m2m_device { /** * struct fimc_vid_cap - camera capture device information * @ctx: hardware context data - * @vfd: video device node for camera capture mode * @subdev: subdev exposing the FIMC processing block + * @ve: exynos video device entity structure * @vd_pad: fimc video capture node pad * @sd_pads: fimc video processing block pads * @ci_fmt: image format at the FIMC camera input (and the scaler output) @@ -305,8 +305,8 @@ struct fimc_m2m_device { struct fimc_vid_cap { struct fimc_ctx *ctx; struct vb2_alloc_ctx *alloc_ctx; - struct video_device vfd; struct v4l2_subdev subdev; + struct exynos_video_entity ve; struct media_pad vd_pad; struct media_pad sd_pads[FIMC_SD_PADS_NUM]; struct v4l2_mbus_framefmt ci_fmt; diff --git a/drivers/media/platform/exynos4-is/fimc-lite-reg.c b/drivers/media/platform/exynos4-is/fimc-lite-reg.c index 8cc0d39a2fea..eb4f7635f5e0 100644 --- a/drivers/media/platform/exynos4-is/fimc-lite-reg.c +++ b/drivers/media/platform/exynos4-is/fimc-lite-reg.c @@ -137,7 +137,7 @@ void flite_hw_set_source_format(struct fimc_lite *dev, struct flite_frame *f) } if (i == 0 && src_pixfmt_map[i][0] != pixelcode) { - v4l2_err(&dev->vfd, + v4l2_err(&dev->ve.vdev, "Unsupported pixel code, falling back to %#08x\n", src_pixfmt_map[i][0]); } diff --git a/drivers/media/platform/exynos4-is/fimc-lite.c b/drivers/media/platform/exynos4-is/fimc-lite.c index 6daa88531e6e..64198b84f673 100644 --- a/drivers/media/platform/exynos4-is/fimc-lite.c +++ b/drivers/media/platform/exynos4-is/fimc-lite.c @@ -392,7 +392,7 @@ static int buffer_prepare(struct vb2_buffer *vb) unsigned long size = fimc->payload[i]; if (vb2_plane_size(vb, i) < size) { - v4l2_err(&fimc->vfd, + v4l2_err(&fimc->ve.vdev, "User buffer too small (%ld < %ld)\n", vb2_plane_size(vb, i), size); return -EINVAL; @@ -458,7 +458,7 @@ static void fimc_lite_clear_event_counters(struct fimc_lite *fimc) static int fimc_lite_open(struct file *file) { struct fimc_lite *fimc = video_drvdata(file); - struct media_entity *me = &fimc->vfd.entity; + struct media_entity *me = &fimc->ve.vdev.entity; int ret; mutex_lock(&me->parent->graph_mutex); @@ -509,7 +509,7 @@ static int fimc_lite_release(struct file *file) if (v4l2_fh_is_singular_file(file) && atomic_read(&fimc->out_path) == FIMC_IO_DMA) { if (fimc->streaming) { - media_entity_pipeline_stop(&fimc->vfd.entity); + media_entity_pipeline_stop(&fimc->ve.vdev.entity); fimc->streaming = false; } clear_bit(ST_FLITE_IN_USE, &fimc->state); @@ -792,7 +792,7 @@ static int fimc_lite_streamon(struct file *file, void *priv, enum v4l2_buf_type type) { struct fimc_lite *fimc = video_drvdata(file); - struct media_entity *entity = &fimc->vfd.entity; + struct media_entity *entity = &fimc->ve.vdev.entity; struct fimc_pipeline *p = &fimc->pipeline; int ret; @@ -830,7 +830,7 @@ static int fimc_lite_streamoff(struct file *file, void *priv, if (ret < 0) return ret; - media_entity_pipeline_stop(&fimc->vfd.entity); + media_entity_pipeline_stop(&fimc->ve.vdev.entity); fimc->streaming = false; return 0; } @@ -1234,7 +1234,7 @@ static int fimc_lite_subdev_registered(struct v4l2_subdev *sd) { struct fimc_lite *fimc = v4l2_get_subdevdata(sd); struct vb2_queue *q = &fimc->vb_queue; - struct video_device *vfd = &fimc->vfd; + struct video_device *vfd = &fimc->ve.vdev; int ret; memset(vfd, 0, sizeof(*vfd)); @@ -1298,9 +1298,9 @@ static void fimc_lite_subdev_unregistered(struct v4l2_subdev *sd) if (fimc == NULL) return; - if (video_is_registered(&fimc->vfd)) { - video_unregister_device(&fimc->vfd); - media_entity_cleanup(&fimc->vfd.entity); + if (video_is_registered(&fimc->ve.vdev)) { + video_unregister_device(&fimc->ve.vdev); + media_entity_cleanup(&fimc->ve.vdev.entity); fimc->pipeline_ops = NULL; } } @@ -1548,7 +1548,7 @@ static int fimc_lite_resume(struct device *dev) INIT_LIST_HEAD(&fimc->active_buf_q); fimc_pipeline_call(fimc, open, &fimc->pipeline, - &fimc->vfd.entity, false); + &fimc->ve.vdev.entity, false); fimc_lite_hw_init(fimc, atomic_read(&fimc->out_path) == FIMC_IO_ISP); clear_bit(ST_FLITE_SUSPENDED, &fimc->state); diff --git a/drivers/media/platform/exynos4-is/fimc-lite.h b/drivers/media/platform/exynos4-is/fimc-lite.h index 47da5e049247..fa3886a297ba 100644 --- a/drivers/media/platform/exynos4-is/fimc-lite.h +++ b/drivers/media/platform/exynos4-is/fimc-lite.h @@ -95,8 +95,8 @@ struct flite_buffer { * struct fimc_lite - fimc lite structure * @pdev: pointer to FIMC-LITE platform device * @dd: SoC specific driver data structure + * @ve: exynos video device entity structure * @v4l2_dev: pointer to top the level v4l2_device - * @vfd: video device node * @fh: v4l2 file handle * @alloc_ctx: videobuf2 memory allocator context * @subdev: FIMC-LITE subdev @@ -130,8 +130,8 @@ struct flite_buffer { struct fimc_lite { struct platform_device *pdev; struct flite_drvdata *dd; + struct exynos_video_entity ve; struct v4l2_device *v4l2_dev; - struct video_device vfd; struct v4l2_fh fh; struct vb2_alloc_ctx *alloc_ctx; struct v4l2_subdev subdev; diff --git a/drivers/media/platform/exynos4-is/fimc-reg.c b/drivers/media/platform/exynos4-is/fimc-reg.c index f079f36099de..1db8cb4c46ef 100644 --- a/drivers/media/platform/exynos4-is/fimc-reg.c +++ b/drivers/media/platform/exynos4-is/fimc-reg.c @@ -618,7 +618,7 @@ int fimc_hw_set_camera_source(struct fimc_dev *fimc, } if (i == ARRAY_SIZE(pix_desc)) { - v4l2_err(&vc->vfd, + v4l2_err(&vc->ve.vdev, "Camera color format not supported: %d\n", vc->ci_fmt.code); return -EINVAL; @@ -698,7 +698,7 @@ int fimc_hw_set_camera_type(struct fimc_dev *fimc, cfg |= FIMC_REG_CIGCTRL_CAM_JPEG; break; default: - v4l2_err(&vid_cap->vfd, + v4l2_err(&vid_cap->ve.vdev, "Not supported camera pixel format: %#x\n", vid_cap->ci_fmt.code); return -EINVAL; @@ -721,7 +721,8 @@ int fimc_hw_set_camera_type(struct fimc_dev *fimc, WARN_ONCE(1, "ISP Writeback input is not supported\n"); break; default: - v4l2_err(&vid_cap->vfd, "Invalid FIMC bus type selected: %d\n", + v4l2_err(&vid_cap->ve.vdev, + "Invalid FIMC bus type selected: %d\n", source->fimc_bus_type); return -EINVAL; } diff --git a/drivers/media/platform/exynos4-is/media-dev.c b/drivers/media/platform/exynos4-is/media-dev.c index 396e06e14a17..c20b2728d55b 100644 --- a/drivers/media/platform/exynos4-is/media-dev.c +++ b/drivers/media/platform/exynos4-is/media-dev.c @@ -929,7 +929,7 @@ static int __fimc_md_create_flite_source_links(struct fimc_md *fmd) continue; source = &fimc->subdev.entity; - sink = &fimc->vfd.entity; + sink = &fimc->ve.vdev.entity; /* FIMC-LITE's subdev and video node */ ret = media_entity_create_link(source, FLITE_SD_PAD_SOURCE_DMA, sink, 0, 0); @@ -1066,7 +1066,7 @@ static int fimc_md_create_links(struct fimc_md *fmd) continue; source = &fmd->fimc[i]->vid_cap.subdev.entity; - sink = &fmd->fimc[i]->vid_cap.vfd.entity; + sink = &fmd->fimc[i]->vid_cap.ve.vdev.entity; ret = media_entity_create_link(source, FIMC_SD_PAD_SOURCE, sink, 0, flags); diff --git a/drivers/media/platform/exynos4-is/media-dev.h b/drivers/media/platform/exynos4-is/media-dev.h index 44d86b61d660..3e9680c9de8b 100644 --- a/drivers/media/platform/exynos4-is/media-dev.h +++ b/drivers/media/platform/exynos4-is/media-dev.h @@ -127,14 +127,14 @@ static inline struct fimc_md *entity_to_fimc_mdev(struct media_entity *me) container_of(me->parent, struct fimc_md, media_dev); } -static inline void fimc_md_graph_lock(struct fimc_dev *fimc) +static inline void fimc_md_graph_lock(struct exynos_video_entity *ve) { - mutex_lock(&fimc->vid_cap.vfd.entity.parent->graph_mutex); + mutex_lock(&ve->vdev.entity.parent->graph_mutex); } -static inline void fimc_md_graph_unlock(struct fimc_dev *fimc) +static inline void fimc_md_graph_unlock(struct exynos_video_entity *ve) { - mutex_unlock(&fimc->vid_cap.vfd.entity.parent->graph_mutex); + mutex_unlock(&ve->vdev.entity.parent->graph_mutex); } int fimc_md_set_camclk(struct v4l2_subdev *sd, bool on); diff --git a/include/media/s5p_fimc.h b/include/media/s5p_fimc.h index f50969025ef3..f5313b402eb7 100644 --- a/include/media/s5p_fimc.h +++ b/include/media/s5p_fimc.h @@ -13,6 +13,7 @@ #define S5P_FIMC_H_ #include +#include #include /* @@ -157,6 +158,10 @@ struct fimc_pipeline { struct media_pipeline *m_pipeline; }; +struct exynos_video_entity { + struct video_device vdev; +}; + /* * Media pipeline operations to be called from within the fimc(-lite) * video node when it is the last entity of the pipeline. Implemented From 4403106d5cfeb438b19e492e29537a00f9b5495a Mon Sep 17 00:00:00 2001 From: Sylwester Nawrocki Date: Fri, 31 May 2013 11:37:19 -0300 Subject: [PATCH 0152/1048] [media] exynos4-is: Preserve state of controls between /dev/video open/close This patch moves the code for inheriting subdev v4l2 controls on the FIMC video capture nodes from open()/close() fops to the link setup notification callback. This allows for the state of the FIMC controls to be always kept, in opposite to the current situation when it is lost when last process closes video device. There is no visible change for the original V4L2 compliant interface. For the MC aware applications (user_subdev_api == true) inheriting of the controls is dropped, since there can be same controls on the subdevs withing single pipeline, now when the ISP (FIMC-IS) is also used. This patch is a prerequisite to allow /dev/video device to be opened without errors even if there is no media links connecting it to an image source (sensor) subdev. This is required for a libv4l2 plugin to be initialized while a video node is opened and it also should be possible to always open the device to query the capabilities. Signed-off-by: Sylwester Nawrocki Signed-off-by: Kyungmin Park Signed-off-by: Mauro Carvalho Chehab --- .../media/platform/exynos4-is/fimc-capture.c | 96 +++++++++---------- drivers/media/platform/exynos4-is/fimc-core.h | 3 + drivers/media/platform/exynos4-is/media-dev.c | 4 - 3 files changed, 50 insertions(+), 53 deletions(-) diff --git a/drivers/media/platform/exynos4-is/fimc-capture.c b/drivers/media/platform/exynos4-is/fimc-capture.c index b80ca59a099d..07089de6c669 100644 --- a/drivers/media/platform/exynos4-is/fimc-capture.c +++ b/drivers/media/platform/exynos4-is/fimc-capture.c @@ -27,9 +27,10 @@ #include #include -#include "media-dev.h" +#include "common.h" #include "fimc-core.h" #include "fimc-reg.h" +#include "media-dev.h" static int fimc_capture_hw_init(struct fimc_dev *fimc) { @@ -472,40 +473,13 @@ static struct vb2_ops fimc_capture_qops = { .stop_streaming = stop_streaming, }; -/** - * fimc_capture_ctrls_create - initialize the control handler - * Initialize the capture video node control handler and fill it - * with the FIMC controls. Inherit any sensor's controls if the - * 'user_subdev_api' flag is false (default behaviour). - * This function need to be called with the graph mutex held. - */ -int fimc_capture_ctrls_create(struct fimc_dev *fimc) -{ - struct fimc_vid_cap *vid_cap = &fimc->vid_cap; - struct v4l2_subdev *sensor = fimc->pipeline.subdevs[IDX_SENSOR]; - int ret; - - if (WARN_ON(vid_cap->ctx == NULL)) - return -ENXIO; - if (vid_cap->ctx->ctrls.ready) - return 0; - - ret = fimc_ctrls_create(vid_cap->ctx); - - if (ret || vid_cap->user_subdev_api || !sensor || - !vid_cap->ctx->ctrls.ready) - return ret; - - return v4l2_ctrl_add_handler(&vid_cap->ctx->ctrls.handler, - sensor->ctrl_handler, NULL); -} - static int fimc_capture_set_default_format(struct fimc_dev *fimc); static int fimc_capture_open(struct file *file) { struct fimc_dev *fimc = video_drvdata(file); - struct exynos_video_entity *ve = &fimc->vid_cap.ve; + struct fimc_vid_cap *vc = &fimc->vid_cap; + struct exynos_video_entity *ve = &vc->ve; int ret = -EBUSY; dbg("pid: %d, state: 0x%lx", task_pid_nr(current), fimc->state); @@ -530,12 +504,20 @@ static int fimc_capture_open(struct file *file) if (v4l2_fh_is_singular_file(file)) { ret = fimc_pipeline_call(fimc, open, &fimc->pipeline, &fimc->vid_cap.ve.vdev.entity, true); - - if (!ret && !fimc->vid_cap.user_subdev_api) + if (ret == 0) ret = fimc_capture_set_default_format(fimc); - if (!ret) - ret = fimc_capture_ctrls_create(fimc); + if (ret == 0 && vc->user_subdev_api && vc->inh_sensor_ctrls) { + /* + * Recreate controls of the the video node to drop + * any controls inherited from the sensor subdev. + */ + fimc_ctrls_delete(vc->ctx); + + ret = fimc_ctrls_create(vc->ctx); + if (ret == 0) + vc->inh_sensor_ctrls = false; + } if (ret < 0) { clear_bit(ST_CAPT_BUSY, &fimc->state); @@ -574,10 +556,6 @@ static int fimc_capture_release(struct file *file) } pm_runtime_put(&fimc->pdev->dev); - - if (v4l2_fh_is_singular_file(file)) - fimc_ctrls_delete(fimc->vid_cap.ctx); - ret = vb2_fop_release(file); mutex_unlock(&fimc->lock); @@ -1410,6 +1388,8 @@ static int fimc_link_setup(struct media_entity *entity, { struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(entity); struct fimc_dev *fimc = v4l2_get_subdevdata(sd); + struct fimc_vid_cap *vc = &fimc->vid_cap; + struct v4l2_subdev *sensor; if (media_entity_type(remote->entity) != MEDIA_ENT_T_V4L2_SUBDEV) return -EINVAL; @@ -1421,15 +1401,26 @@ static int fimc_link_setup(struct media_entity *entity, local->entity->name, remote->entity->name, flags, fimc->vid_cap.input); - if (flags & MEDIA_LNK_FL_ENABLED) { - if (fimc->vid_cap.input != 0) - return -EBUSY; - fimc->vid_cap.input = sd->grp_id; + if (!(flags & MEDIA_LNK_FL_ENABLED)) { + fimc->vid_cap.input = 0; return 0; } - fimc->vid_cap.input = 0; - return 0; + if (vc->input != 0) + return -EBUSY; + + vc->input = sd->grp_id; + + if (vc->user_subdev_api || vc->inh_sensor_ctrls) + return 0; + + /* Inherit V4L2 controls from the image sensor subdev. */ + sensor = fimc_find_remote_sensor(&vc->subdev.entity); + if (sensor == NULL) + return 0; + + return v4l2_ctrl_add_handler(&vc->ctx->ctrls.handler, + sensor->ctrl_handler, NULL); } static const struct media_entity_operations fimc_sd_media_ops = { @@ -1789,12 +1780,16 @@ static int fimc_register_capture_device(struct fimc_dev *fimc, ret = vb2_queue_init(q); if (ret) - goto err_ent; + goto err_free_ctx; vid_cap->vd_pad.flags = MEDIA_PAD_FL_SINK; ret = media_entity_init(&vfd->entity, 1, &vid_cap->vd_pad, 0); if (ret) - goto err_ent; + goto err_free_ctx; + + ret = fimc_ctrls_create(ctx); + if (ret) + goto err_me_cleanup; /* * For proper order of acquiring/releasing the video * and the graph mutex. @@ -1804,7 +1799,7 @@ static int fimc_register_capture_device(struct fimc_dev *fimc, ret = video_register_device(vfd, VFL_TYPE_GRABBER, -1); if (ret) - goto err_vd; + goto err_ctrl_free; v4l2_info(v4l2_dev, "Registered %s as /dev/%s\n", vfd->name, video_device_node_name(vfd)); @@ -1812,9 +1807,11 @@ static int fimc_register_capture_device(struct fimc_dev *fimc, vfd->ctrl_handler = &ctx->ctrls.handler; return 0; -err_vd: +err_ctrl_free: + fimc_ctrls_delete(ctx); +err_me_cleanup: media_entity_cleanup(&vfd->entity); -err_ent: +err_free_ctx: kfree(ctx); return ret; } @@ -1856,6 +1853,7 @@ static void fimc_capture_subdev_unregistered(struct v4l2_subdev *sd) if (video_is_registered(vdev)) { video_unregister_device(vdev); media_entity_cleanup(&vdev->entity); + fimc_ctrls_delete(fimc->vid_cap.ctx); fimc->pipeline_ops = NULL; } kfree(fimc->vid_cap.ctx); diff --git a/drivers/media/platform/exynos4-is/fimc-core.h b/drivers/media/platform/exynos4-is/fimc-core.h index dfecef6bfefe..61c0c83cc5b7 100644 --- a/drivers/media/platform/exynos4-is/fimc-core.h +++ b/drivers/media/platform/exynos4-is/fimc-core.h @@ -301,6 +301,8 @@ struct fimc_m2m_device { * @refcnt: driver's private reference counter * @input: capture input type, grp_id of the attached subdev * @user_subdev_api: true if subdevs are not configured by the host driver + * @inh_sensor_ctrls: a flag indicating v4l2 controls are inherited from + * an image sensor subdev */ struct fimc_vid_cap { struct fimc_ctx *ctx; @@ -324,6 +326,7 @@ struct fimc_vid_cap { int refcnt; u32 input; bool user_subdev_api; + bool inh_sensor_ctrls; }; /** diff --git a/drivers/media/platform/exynos4-is/media-dev.c b/drivers/media/platform/exynos4-is/media-dev.c index c20b2728d55b..7a562d289977 100644 --- a/drivers/media/platform/exynos4-is/media-dev.c +++ b/drivers/media/platform/exynos4-is/media-dev.c @@ -1272,8 +1272,6 @@ static int fimc_md_link_notify(struct media_pad *source, if (!(flags & MEDIA_LNK_FL_ENABLED)) { if (ref_count > 0) { ret = __fimc_pipeline_close(pipeline); - if (!ret && fimc) - fimc_ctrls_delete(fimc->vid_cap.ctx); } for (i = 0; i < IDX_MAX; i++) pipeline->subdevs[i] = NULL; @@ -1285,8 +1283,6 @@ static int fimc_md_link_notify(struct media_pad *source, */ ret = __fimc_pipeline_open(pipeline, source->entity, true); - if (!ret && fimc) - ret = fimc_capture_ctrls_create(fimc); } mutex_unlock(lock); From 42625fdfbd608f0bdaffaf25e8eb32ef55cddf96 Mon Sep 17 00:00:00 2001 From: Sylwester Nawrocki Date: Fri, 31 May 2013 11:37:20 -0300 Subject: [PATCH 0153/1048] [media] exynos4-is: Media graph/video device locking rework Remove driver private video node reference counters and use entity->use_count instead. This makes the video pipelines power handling more similar to the method used in omap3isp driver. Now the graph mutex is taken always after the video mutex, as it is not possible to ensure apposite order at the all modules. Signed-off-by: Sylwester Nawrocki Signed-off-by: Kyungmin Park Signed-off-by: Mauro Carvalho Chehab --- .../media/platform/exynos4-is/fimc-capture.c | 59 ++++++++----------- drivers/media/platform/exynos4-is/fimc-core.h | 2 - drivers/media/platform/exynos4-is/fimc-lite.c | 23 +++++--- drivers/media/platform/exynos4-is/fimc-lite.h | 2 - drivers/media/platform/exynos4-is/media-dev.c | 12 +--- 5 files changed, 42 insertions(+), 56 deletions(-) diff --git a/drivers/media/platform/exynos4-is/fimc-capture.c b/drivers/media/platform/exynos4-is/fimc-capture.c index 07089de6c669..b6055d2b09d6 100644 --- a/drivers/media/platform/exynos4-is/fimc-capture.c +++ b/drivers/media/platform/exynos4-is/fimc-capture.c @@ -484,7 +484,6 @@ static int fimc_capture_open(struct file *file) dbg("pid: %d, state: 0x%lx", task_pid_nr(current), fimc->state); - fimc_md_graph_lock(ve); mutex_lock(&fimc->lock); if (fimc_m2m_active(fimc)) @@ -502,6 +501,8 @@ static int fimc_capture_open(struct file *file) } if (v4l2_fh_is_singular_file(file)) { + fimc_md_graph_lock(ve); + ret = fimc_pipeline_call(fimc, open, &fimc->pipeline, &fimc->vid_cap.ve.vdev.entity, true); if (ret == 0) @@ -518,18 +519,19 @@ static int fimc_capture_open(struct file *file) if (ret == 0) vc->inh_sensor_ctrls = false; } + if (ret == 0) + ve->vdev.entity.use_count++; + + fimc_md_graph_unlock(ve); if (ret < 0) { clear_bit(ST_CAPT_BUSY, &fimc->state); pm_runtime_put_sync(&fimc->pdev->dev); v4l2_fh_release(file); - } else { - fimc->vid_cap.refcnt++; } } unlock: mutex_unlock(&fimc->lock); - fimc_md_graph_unlock(ve); return ret; } @@ -537,26 +539,32 @@ static int fimc_capture_release(struct file *file) { struct fimc_dev *fimc = video_drvdata(file); struct fimc_vid_cap *vc = &fimc->vid_cap; + bool close = v4l2_fh_is_singular_file(file); int ret; dbg("pid: %d, state: 0x%lx", task_pid_nr(current), fimc->state); mutex_lock(&fimc->lock); - if (v4l2_fh_is_singular_file(file)) { - if (vc->streaming) { - media_entity_pipeline_stop(&vc->ve.vdev.entity); - vc->streaming = false; - } + if (close && vc->streaming) { + media_entity_pipeline_stop(&vc->ve.vdev.entity); + vc->streaming = false; + } + + ret = vb2_fop_release(file); + + if (close) { clear_bit(ST_CAPT_BUSY, &fimc->state); fimc_stop_capture(fimc, false); fimc_pipeline_call(fimc, close, &fimc->pipeline); clear_bit(ST_CAPT_SUSPENDED, &fimc->state); - fimc->vid_cap.refcnt--; + + fimc_md_graph_lock(&vc->ve); + vc->ve.vdev.entity.use_count--; + fimc_md_graph_unlock(&vc->ve); } pm_runtime_put(&fimc->pdev->dev); - ret = vb2_fop_release(file); mutex_unlock(&fimc->lock); return ret; @@ -921,9 +929,6 @@ static int fimc_cap_try_fmt_mplane(struct file *file, void *fh, struct fimc_fmt *ffmt = NULL; int ret = 0; - fimc_md_graph_lock(ve); - mutex_lock(&fimc->lock); - if (fimc_jpeg_fourcc(pix->pixelformat)) { fimc_capture_try_format(ctx, &pix->width, &pix->height, NULL, &pix->pixelformat, @@ -934,16 +939,18 @@ static int fimc_cap_try_fmt_mplane(struct file *file, void *fh, ffmt = fimc_capture_try_format(ctx, &pix->width, &pix->height, NULL, &pix->pixelformat, FIMC_SD_PAD_SOURCE); - if (!ffmt) { - ret = -EINVAL; - goto unlock; - } + if (!ffmt) + return -EINVAL; if (!fimc->vid_cap.user_subdev_api) { mf.width = pix->width; mf.height = pix->height; mf.code = ffmt->mbus_code; + + fimc_md_graph_lock(ve); fimc_pipeline_try_format(ctx, &mf, &ffmt, false); + fimc_md_graph_unlock(ve); + pix->width = mf.width; pix->height = mf.height; if (ffmt) @@ -955,9 +962,6 @@ static int fimc_cap_try_fmt_mplane(struct file *file, void *fh, if (ffmt->flags & FMT_FLAGS_COMPRESSED) fimc_get_sensor_frame_desc(fimc->pipeline.subdevs[IDX_SENSOR], pix->plane_fmt, ffmt->memplanes, true); -unlock: - mutex_unlock(&fimc->lock); - fimc_md_graph_unlock(ve); return ret; } @@ -1059,19 +1063,14 @@ static int fimc_cap_s_fmt_mplane(struct file *file, void *priv, int ret; fimc_md_graph_lock(&fimc->vid_cap.ve); - mutex_lock(&fimc->lock); /* * The graph is walked within __fimc_capture_set_format() to set * the format at subdevs thus the graph mutex needs to be held at - * this point and acquired before the video mutex, to avoid AB-BA - * deadlock when fimc_md_link_notify() is called by other thread. - * Ideally the graph walking and setting format at the whole pipeline - * should be removed from this driver and handled in userspace only. + * this point. */ ret = __fimc_capture_set_format(fimc, f); fimc_md_graph_unlock(&fimc->vid_cap.ve); - mutex_unlock(&fimc->lock); return ret; } @@ -1790,12 +1789,6 @@ static int fimc_register_capture_device(struct fimc_dev *fimc, ret = fimc_ctrls_create(ctx); if (ret) goto err_me_cleanup; - /* - * For proper order of acquiring/releasing the video - * and the graph mutex. - */ - v4l2_disable_ioctl_locking(vfd, VIDIOC_TRY_FMT); - v4l2_disable_ioctl_locking(vfd, VIDIOC_S_FMT); ret = video_register_device(vfd, VFL_TYPE_GRABBER, -1); if (ret) diff --git a/drivers/media/platform/exynos4-is/fimc-core.h b/drivers/media/platform/exynos4-is/fimc-core.h index 61c0c83cc5b7..e3da4ffd7a5e 100644 --- a/drivers/media/platform/exynos4-is/fimc-core.h +++ b/drivers/media/platform/exynos4-is/fimc-core.h @@ -298,7 +298,6 @@ struct fimc_m2m_device { * @frame_count: the frame counter for statistics * @reqbufs_count: the number of buffers requested in REQBUFS ioctl * @input_index: input (camera sensor) index - * @refcnt: driver's private reference counter * @input: capture input type, grp_id of the attached subdev * @user_subdev_api: true if subdevs are not configured by the host driver * @inh_sensor_ctrls: a flag indicating v4l2 controls are inherited from @@ -323,7 +322,6 @@ struct fimc_vid_cap { unsigned int reqbufs_count; bool streaming; int input_index; - int refcnt; u32 input; bool user_subdev_api; bool inh_sensor_ctrls; diff --git a/drivers/media/platform/exynos4-is/fimc-lite.c b/drivers/media/platform/exynos4-is/fimc-lite.c index 64198b84f673..0f372bfffaf0 100644 --- a/drivers/media/platform/exynos4-is/fimc-lite.c +++ b/drivers/media/platform/exynos4-is/fimc-lite.c @@ -461,8 +461,6 @@ static int fimc_lite_open(struct file *file) struct media_entity *me = &fimc->ve.vdev.entity; int ret; - mutex_lock(&me->parent->graph_mutex); - mutex_lock(&fimc->lock); if (atomic_read(&fimc->out_path) != FIMC_IO_DMA) { ret = -EBUSY; @@ -482,11 +480,19 @@ static int fimc_lite_open(struct file *file) atomic_read(&fimc->out_path) != FIMC_IO_DMA) goto unlock; + mutex_lock(&me->parent->graph_mutex); + ret = fimc_pipeline_call(fimc, open, &fimc->pipeline, me, true); + + /* Mark video pipeline ending at this video node as in use. */ + if (ret == 0) + me->use_count++; + + mutex_unlock(&me->parent->graph_mutex); + if (!ret) { fimc_lite_clear_event_counters(fimc); - fimc->ref_count++; goto unlock; } @@ -496,26 +502,28 @@ err_pm: clear_bit(ST_FLITE_IN_USE, &fimc->state); unlock: mutex_unlock(&fimc->lock); - mutex_unlock(&me->parent->graph_mutex); return ret; } static int fimc_lite_release(struct file *file) { struct fimc_lite *fimc = video_drvdata(file); + struct media_entity *entity = &fimc->ve.vdev.entity; mutex_lock(&fimc->lock); if (v4l2_fh_is_singular_file(file) && atomic_read(&fimc->out_path) == FIMC_IO_DMA) { if (fimc->streaming) { - media_entity_pipeline_stop(&fimc->ve.vdev.entity); + media_entity_pipeline_stop(entity); fimc->streaming = false; } clear_bit(ST_FLITE_IN_USE, &fimc->state); fimc_lite_stop_capture(fimc, false); fimc_pipeline_call(fimc, close, &fimc->pipeline); - fimc->ref_count--; + mutex_lock(&entity->parent->graph_mutex); + entity->use_count--; + mutex_unlock(&entity->parent->graph_mutex); } vb2_fop_release(file); @@ -954,8 +962,6 @@ static int fimc_lite_link_setup(struct media_entity *entity, __func__, remote->entity->name, local->entity->name, flags, fimc->source_subdev_grp_id); - mutex_lock(&fimc->lock); - switch (local->index) { case FLITE_SD_PAD_SINK: if (remote_ent_type != MEDIA_ENT_T_V4L2_SUBDEV) { @@ -997,7 +1003,6 @@ static int fimc_lite_link_setup(struct media_entity *entity, } mb(); - mutex_unlock(&fimc->lock); return ret; } diff --git a/drivers/media/platform/exynos4-is/fimc-lite.h b/drivers/media/platform/exynos4-is/fimc-lite.h index fa3886a297ba..25abba98d7e9 100644 --- a/drivers/media/platform/exynos4-is/fimc-lite.h +++ b/drivers/media/platform/exynos4-is/fimc-lite.h @@ -125,7 +125,6 @@ struct flite_buffer { * @active_buf_count: number of video buffers scheduled in hardware * @frame_count: the captured frames counter * @reqbufs_count: the number of buffers requested with REQBUFS ioctl - * @ref_count: driver's private reference counter */ struct fimc_lite { struct platform_device *pdev; @@ -163,7 +162,6 @@ struct fimc_lite { struct vb2_queue vb_queue; unsigned int frame_count; unsigned int reqbufs_count; - int ref_count; struct fimc_lite_events events; bool streaming; diff --git a/drivers/media/platform/exynos4-is/media-dev.c b/drivers/media/platform/exynos4-is/media-dev.c index 7a562d289977..1b4bb25d0a55 100644 --- a/drivers/media/platform/exynos4-is/media-dev.c +++ b/drivers/media/platform/exynos4-is/media-dev.c @@ -1238,9 +1238,7 @@ static int fimc_md_link_notify(struct media_pad *source, struct fimc_dev *fimc = NULL; struct fimc_pipeline *pipeline; struct v4l2_subdev *sd; - struct mutex *lock; int i, ret = 0; - int ref_count; if (media_entity_type(sink->entity) != MEDIA_ENT_T_V4L2_SUBDEV) return 0; @@ -1253,29 +1251,24 @@ static int fimc_md_link_notify(struct media_pad *source, if (WARN_ON(fimc_lite == NULL)) return 0; pipeline = &fimc_lite->pipeline; - lock = &fimc_lite->lock; break; case GRP_ID_FIMC: fimc = v4l2_get_subdevdata(sd); if (WARN_ON(fimc == NULL)) return 0; pipeline = &fimc->pipeline; - lock = &fimc->lock; break; default: return 0; } - mutex_lock(lock); - ref_count = fimc ? fimc->vid_cap.refcnt : fimc_lite->ref_count; - if (!(flags & MEDIA_LNK_FL_ENABLED)) { - if (ref_count > 0) { + if (sink->entity->use_count > 0) { ret = __fimc_pipeline_close(pipeline); } for (i = 0; i < IDX_MAX; i++) pipeline->subdevs[i] = NULL; - } else if (ref_count > 0) { + } else if (sink->entity->use_count > 0) { /* * Link activation. Enable power of pipeline elements only if * the pipeline is already in use, i.e. its video node is open. @@ -1285,7 +1278,6 @@ static int fimc_md_link_notify(struct media_pad *source, source->entity, true); } - mutex_unlock(lock); return ret ? -EPIPE : ret; } From 4bd728a16ee8212e3e468dabb737fe9ef5cea83d Mon Sep 17 00:00:00 2001 From: Sylwester Nawrocki Date: Fri, 31 May 2013 11:37:21 -0300 Subject: [PATCH 0154/1048] [media] exynos4-is: Do not use asynchronous runtime PM in release fop Use pm_runtime_put_sync() instead of pm_runtime_put() to avoid races in handling the 'state' bit flags when the fimc-capture drivers' runtime_resume callback is called from the PM workqueue. Signed-off-by: Sylwester Nawrocki Signed-off-by: Kyungmin Park Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/exynos4-is/fimc-capture.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/exynos4-is/fimc-capture.c b/drivers/media/platform/exynos4-is/fimc-capture.c index b6055d2b09d6..b2f9581f1a8a 100644 --- a/drivers/media/platform/exynos4-is/fimc-capture.c +++ b/drivers/media/platform/exynos4-is/fimc-capture.c @@ -496,7 +496,7 @@ static int fimc_capture_open(struct file *file) ret = v4l2_fh_open(file); if (ret) { - pm_runtime_put(&fimc->pdev->dev); + pm_runtime_put_sync(&fimc->pdev->dev); goto unlock; } @@ -564,7 +564,7 @@ static int fimc_capture_release(struct file *file) fimc_md_graph_unlock(&vc->ve); } - pm_runtime_put(&fimc->pdev->dev); + pm_runtime_put_sync(&fimc->pdev->dev); mutex_unlock(&fimc->lock); return ret; From 403dfbec45419c1838e0ea3be16625986ec17cfd Mon Sep 17 00:00:00 2001 From: Sylwester Nawrocki Date: Fri, 31 May 2013 11:37:22 -0300 Subject: [PATCH 0155/1048] [media] exynos4-is: Use common exynos_media_pipeline data structure This enumeration is now private to exynos4-is and the exynos5 camera subsystem driver may have the subdevs handling designed differently. Signed-off-by: Sylwester Nawrocki Signed-off-by: Kyungmin Park Signed-off-by: Mauro Carvalho Chehab --- .../media/platform/exynos4-is/fimc-capture.c | 67 ++++++----- drivers/media/platform/exynos4-is/fimc-core.h | 2 - drivers/media/platform/exynos4-is/fimc-lite.c | 29 +++-- drivers/media/platform/exynos4-is/fimc-lite.h | 2 - drivers/media/platform/exynos4-is/media-dev.c | 108 +++++++++++------- drivers/media/platform/exynos4-is/media-dev.h | 38 ++++++ include/media/s5p_fimc.h | 53 +++++---- 7 files changed, 186 insertions(+), 113 deletions(-) diff --git a/drivers/media/platform/exynos4-is/fimc-capture.c b/drivers/media/platform/exynos4-is/fimc-capture.c index b2f9581f1a8a..33c6a2f0ad74 100644 --- a/drivers/media/platform/exynos4-is/fimc-capture.c +++ b/drivers/media/platform/exynos4-is/fimc-capture.c @@ -120,8 +120,7 @@ static int fimc_capture_state_cleanup(struct fimc_dev *fimc, bool suspend) spin_unlock_irqrestore(&fimc->slock, flags); if (streaming) - return fimc_pipeline_call(fimc, set_stream, - &fimc->pipeline, 0); + return fimc_pipeline_call(&cap->ve, set_stream, 0); else return 0; } @@ -179,8 +178,9 @@ static int fimc_capture_config_update(struct fimc_ctx *ctx) void fimc_capture_irq_handler(struct fimc_dev *fimc, int deq_buf) { - struct v4l2_subdev *csis = fimc->pipeline.subdevs[IDX_CSIS]; struct fimc_vid_cap *cap = &fimc->vid_cap; + struct fimc_pipeline *p = to_fimc_pipeline(cap->ve.pipe); + struct v4l2_subdev *csis = p->subdevs[IDX_CSIS]; struct fimc_frame *f = &cap->ctx->d_frame; struct fimc_vid_buffer *v_buf; struct timeval *tv; @@ -288,8 +288,7 @@ static int start_streaming(struct vb2_queue *q, unsigned int count) fimc_activate_capture(ctx); if (!test_and_set_bit(ST_CAPT_ISP_STREAM, &fimc->state)) - return fimc_pipeline_call(fimc, set_stream, - &fimc->pipeline, 1); + return fimc_pipeline_call(&vid_cap->ve, set_stream, 1); } return 0; @@ -313,7 +312,7 @@ int fimc_capture_suspend(struct fimc_dev *fimc) int ret = fimc_stop_capture(fimc, suspend); if (ret) return ret; - return fimc_pipeline_call(fimc, close, &fimc->pipeline); + return fimc_pipeline_call(&fimc->vid_cap.ve, close); } static void buffer_queue(struct vb2_buffer *vb); @@ -330,8 +329,7 @@ int fimc_capture_resume(struct fimc_dev *fimc) INIT_LIST_HEAD(&fimc->vid_cap.active_buf_q); vid_cap->buf_index = 0; - fimc_pipeline_call(fimc, open, &fimc->pipeline, - &ve->vdev.entity, false); + fimc_pipeline_call(ve, open, &ve->vdev.entity, false); fimc_capture_hw_init(fimc); clear_bit(ST_CAPT_SUSPENDED, &fimc->state); @@ -455,7 +453,7 @@ static void buffer_queue(struct vb2_buffer *vb) if (test_and_set_bit(ST_CAPT_ISP_STREAM, &fimc->state)) return; - ret = fimc_pipeline_call(fimc, set_stream, &fimc->pipeline, 1); + ret = fimc_pipeline_call(ve, set_stream, 1); if (ret < 0) v4l2_err(&ve->vdev, "stream on failed: %d\n", ret); return; @@ -503,8 +501,8 @@ static int fimc_capture_open(struct file *file) if (v4l2_fh_is_singular_file(file)) { fimc_md_graph_lock(ve); - ret = fimc_pipeline_call(fimc, open, &fimc->pipeline, - &fimc->vid_cap.ve.vdev.entity, true); + ret = fimc_pipeline_call(ve, open, &ve->vdev.entity, true); + if (ret == 0) ret = fimc_capture_set_default_format(fimc); @@ -555,8 +553,7 @@ static int fimc_capture_release(struct file *file) if (close) { clear_bit(ST_CAPT_BUSY, &fimc->state); - fimc_stop_capture(fimc, false); - fimc_pipeline_call(fimc, close, &fimc->pipeline); + fimc_pipeline_call(&vc->ve, close); clear_bit(ST_CAPT_SUSPENDED, &fimc->state); fimc_md_graph_lock(&vc->ve); @@ -786,7 +783,8 @@ static int fimc_pipeline_try_format(struct fimc_ctx *ctx, bool set) { struct fimc_dev *fimc = ctx->fimc_dev; - struct v4l2_subdev *sd = fimc->pipeline.subdevs[IDX_SENSOR]; + struct fimc_pipeline *p = to_fimc_pipeline(fimc->vid_cap.ve.pipe); + struct v4l2_subdev *sd = p->subdevs[IDX_SENSOR]; struct v4l2_subdev_format sfmt; struct v4l2_mbus_framefmt *mf = &sfmt.format; struct media_entity *me; @@ -926,6 +924,7 @@ static int fimc_cap_try_fmt_mplane(struct file *file, void *fh, struct fimc_ctx *ctx = fimc->vid_cap.ctx; struct exynos_video_entity *ve = &fimc->vid_cap.ve; struct v4l2_mbus_framefmt mf; + struct v4l2_subdev *sensor; struct fimc_fmt *ffmt = NULL; int ret = 0; @@ -959,9 +958,18 @@ static int fimc_cap_try_fmt_mplane(struct file *file, void *fh, fimc_adjust_mplane_format(ffmt, pix->width, pix->height, pix); - if (ffmt->flags & FMT_FLAGS_COMPRESSED) - fimc_get_sensor_frame_desc(fimc->pipeline.subdevs[IDX_SENSOR], - pix->plane_fmt, ffmt->memplanes, true); + if (ffmt->flags & FMT_FLAGS_COMPRESSED) { + fimc_md_graph_lock(ve); + + sensor = __fimc_md_get_subdev(ve->pipe, IDX_SENSOR); + if (sensor) + fimc_get_sensor_frame_desc(sensor, pix->plane_fmt, + ffmt->memplanes, true); + else + ret = -EPIPE; + + fimc_md_graph_unlock(ve); + } return ret; } @@ -986,6 +994,7 @@ static int __fimc_capture_set_format(struct fimc_dev *fimc, struct fimc_ctx *ctx = fimc->vid_cap.ctx; struct v4l2_pix_format_mplane *pix = &f->fmt.pix_mp; struct v4l2_mbus_framefmt *mf = &fimc->vid_cap.ci_fmt; + struct fimc_pipeline *p = to_fimc_pipeline(fimc->vid_cap.ve.pipe); struct fimc_frame *ff = &ctx->d_frame; struct fimc_fmt *s_fmt = NULL; int ret, i; @@ -1027,7 +1036,7 @@ static int __fimc_capture_set_format(struct fimc_dev *fimc, fimc_adjust_mplane_format(ff->fmt, pix->width, pix->height, pix); if (ff->fmt->flags & FMT_FLAGS_COMPRESSED) { - ret = fimc_get_sensor_frame_desc(fimc->pipeline.subdevs[IDX_SENSOR], + ret = fimc_get_sensor_frame_desc(p->subdevs[IDX_SENSOR], pix->plane_fmt, ff->fmt->memplanes, true); if (ret < 0) @@ -1078,14 +1087,20 @@ static int fimc_cap_enum_input(struct file *file, void *priv, struct v4l2_input *i) { struct fimc_dev *fimc = video_drvdata(file); - struct v4l2_subdev *sd = fimc->pipeline.subdevs[IDX_SENSOR]; + struct exynos_video_entity *ve = &fimc->vid_cap.ve; + struct v4l2_subdev *sd; if (i->index != 0) return -EINVAL; i->type = V4L2_INPUT_TYPE_CAMERA; + fimc_md_graph_lock(ve); + sd = __fimc_md_get_subdev(ve->pipe, IDX_SENSOR); + fimc_md_graph_unlock(ve); + if (sd) strlcpy(i->name, sd->name, sizeof(i->name)); + return 0; } @@ -1111,6 +1126,7 @@ static int fimc_pipeline_validate(struct fimc_dev *fimc) struct v4l2_subdev_format sink_fmt, src_fmt; struct fimc_vid_cap *vc = &fimc->vid_cap; struct v4l2_subdev *sd = &vc->subdev; + struct fimc_pipeline *p = to_fimc_pipeline(vc->ve.pipe); struct media_pad *sink_pad, *src_pad; int i, ret; @@ -1164,7 +1180,7 @@ static int fimc_pipeline_validate(struct fimc_dev *fimc) src_fmt.format.code != sink_fmt.format.code) return -EPIPE; - if (sd == fimc->pipeline.subdevs[IDX_SENSOR] && + if (sd == p->subdevs[IDX_SENSOR] && fimc_user_defined_mbus_fmt(src_fmt.format.code)) { struct v4l2_plane_pix_format plane_fmt[FIMC_MAX_PLANES]; struct fimc_frame *frame = &vc->ctx->d_frame; @@ -1188,7 +1204,6 @@ static int fimc_cap_streamon(struct file *file, void *priv, enum v4l2_buf_type type) { struct fimc_dev *fimc = video_drvdata(file); - struct fimc_pipeline *p = &fimc->pipeline; struct fimc_vid_cap *vc = &fimc->vid_cap; struct media_entity *entity = &vc->ve.vdev.entity; struct fimc_source_info *si = NULL; @@ -1198,11 +1213,11 @@ static int fimc_cap_streamon(struct file *file, void *priv, if (fimc_capture_active(fimc)) return -EBUSY; - ret = media_entity_pipeline_start(entity, p->m_pipeline); + ret = media_entity_pipeline_start(entity, &vc->ve.pipe->mp); if (ret < 0) return ret; - sd = p->subdevs[IDX_SENSOR]; + sd = __fimc_md_get_subdev(vc->ve.pipe, IDX_SENSOR); if (sd) si = v4l2_get_subdev_hostdata(sd); @@ -1821,12 +1836,12 @@ static int fimc_capture_subdev_registered(struct v4l2_subdev *sd) if (ret) return ret; - fimc->pipeline_ops = v4l2_get_subdev_hostdata(sd); + fimc->vid_cap.ve.pipe = v4l2_get_subdev_hostdata(sd); ret = fimc_register_capture_device(fimc, sd->v4l2_dev); if (ret) { fimc_unregister_m2m_device(fimc); - fimc->pipeline_ops = NULL; + fimc->vid_cap.ve.pipe = NULL; } return ret; @@ -1847,7 +1862,7 @@ static void fimc_capture_subdev_unregistered(struct v4l2_subdev *sd) video_unregister_device(vdev); media_entity_cleanup(&vdev->entity); fimc_ctrls_delete(fimc->vid_cap.ctx); - fimc->pipeline_ops = NULL; + fimc->vid_cap.ve.pipe = NULL; } kfree(fimc->vid_cap.ctx); fimc->vid_cap.ctx = NULL; diff --git a/drivers/media/platform/exynos4-is/fimc-core.h b/drivers/media/platform/exynos4-is/fimc-core.h index e3da4ffd7a5e..c48a79254d83 100644 --- a/drivers/media/platform/exynos4-is/fimc-core.h +++ b/drivers/media/platform/exynos4-is/fimc-core.h @@ -435,8 +435,6 @@ struct fimc_dev { struct fimc_vid_cap vid_cap; unsigned long state; struct vb2_alloc_ctx *alloc_ctx; - struct fimc_pipeline pipeline; - const struct fimc_pipeline_ops *pipeline_ops; }; /** diff --git a/drivers/media/platform/exynos4-is/fimc-lite.c b/drivers/media/platform/exynos4-is/fimc-lite.c index 0f372bfffaf0..24e2a0f8797a 100644 --- a/drivers/media/platform/exynos4-is/fimc-lite.c +++ b/drivers/media/platform/exynos4-is/fimc-lite.c @@ -210,7 +210,7 @@ static int fimc_lite_reinit(struct fimc_lite *fimc, bool suspend) if (!streaming) return 0; - return fimc_pipeline_call(fimc, set_stream, &fimc->pipeline, 0); + return fimc_pipeline_call(&fimc->ve, set_stream, 0); } static int fimc_lite_stop_capture(struct fimc_lite *fimc, bool suspend) @@ -324,8 +324,7 @@ static int start_streaming(struct vb2_queue *q, unsigned int count) flite_hw_capture_start(fimc); if (!test_and_set_bit(ST_SENSOR_STREAM, &fimc->state)) - fimc_pipeline_call(fimc, set_stream, - &fimc->pipeline, 1); + fimc_pipeline_call(&fimc->ve, set_stream, 1); } if (debug > 0) flite_hw_dump_regs(fimc, __func__); @@ -429,8 +428,7 @@ static void buffer_queue(struct vb2_buffer *vb) spin_unlock_irqrestore(&fimc->slock, flags); if (!test_and_set_bit(ST_SENSOR_STREAM, &fimc->state)) - fimc_pipeline_call(fimc, set_stream, - &fimc->pipeline, 1); + fimc_pipeline_call(&fimc->ve, set_stream, 1); return; } spin_unlock_irqrestore(&fimc->slock, flags); @@ -482,8 +480,7 @@ static int fimc_lite_open(struct file *file) mutex_lock(&me->parent->graph_mutex); - ret = fimc_pipeline_call(fimc, open, &fimc->pipeline, - me, true); + ret = fimc_pipeline_call(&fimc->ve, open, me, true); /* Mark video pipeline ending at this video node as in use. */ if (ret == 0) @@ -518,9 +515,10 @@ static int fimc_lite_release(struct file *file) media_entity_pipeline_stop(entity); fimc->streaming = false; } - clear_bit(ST_FLITE_IN_USE, &fimc->state); fimc_lite_stop_capture(fimc, false); - fimc_pipeline_call(fimc, close, &fimc->pipeline); + fimc_pipeline_call(&fimc->ve, close); + clear_bit(ST_FLITE_IN_USE, &fimc->state); + mutex_lock(&entity->parent->graph_mutex); entity->use_count--; mutex_unlock(&entity->parent->graph_mutex); @@ -801,13 +799,12 @@ static int fimc_lite_streamon(struct file *file, void *priv, { struct fimc_lite *fimc = video_drvdata(file); struct media_entity *entity = &fimc->ve.vdev.entity; - struct fimc_pipeline *p = &fimc->pipeline; int ret; if (fimc_lite_active(fimc)) return -EBUSY; - ret = media_entity_pipeline_start(entity, p->m_pipeline); + ret = media_entity_pipeline_start(entity, &fimc->ve.pipe->mp); if (ret < 0) return ret; @@ -1282,12 +1279,12 @@ static int fimc_lite_subdev_registered(struct v4l2_subdev *sd) return ret; video_set_drvdata(vfd, fimc); - fimc->pipeline_ops = v4l2_get_subdev_hostdata(sd); + fimc->ve.pipe = v4l2_get_subdev_hostdata(sd); ret = video_register_device(vfd, VFL_TYPE_GRABBER, -1); if (ret < 0) { media_entity_cleanup(&vfd->entity); - fimc->pipeline_ops = NULL; + fimc->ve.pipe = NULL; return ret; } @@ -1306,7 +1303,7 @@ static void fimc_lite_subdev_unregistered(struct v4l2_subdev *sd) if (video_is_registered(&fimc->ve.vdev)) { video_unregister_device(&fimc->ve.vdev); media_entity_cleanup(&fimc->ve.vdev.entity); - fimc->pipeline_ops = NULL; + fimc->ve.pipe = NULL; } } @@ -1552,7 +1549,7 @@ static int fimc_lite_resume(struct device *dev) return 0; INIT_LIST_HEAD(&fimc->active_buf_q); - fimc_pipeline_call(fimc, open, &fimc->pipeline, + fimc_pipeline_call(&fimc->ve, open, &fimc->ve.vdev.entity, false); fimc_lite_hw_init(fimc, atomic_read(&fimc->out_path) == FIMC_IO_ISP); clear_bit(ST_FLITE_SUSPENDED, &fimc->state); @@ -1579,7 +1576,7 @@ static int fimc_lite_suspend(struct device *dev) if (ret < 0 || !fimc_lite_active(fimc)) return ret; - return fimc_pipeline_call(fimc, close, &fimc->pipeline); + return fimc_pipeline_call(&fimc->ve, close); } #endif /* CONFIG_PM_SLEEP */ diff --git a/drivers/media/platform/exynos4-is/fimc-lite.h b/drivers/media/platform/exynos4-is/fimc-lite.h index 25abba98d7e9..c7aa08477830 100644 --- a/drivers/media/platform/exynos4-is/fimc-lite.h +++ b/drivers/media/platform/exynos4-is/fimc-lite.h @@ -140,8 +140,6 @@ struct fimc_lite { struct v4l2_ctrl_handler ctrl_handler; struct v4l2_ctrl *test_pattern; int index; - struct fimc_pipeline pipeline; - const struct fimc_pipeline_ops *pipeline_ops; struct mutex lock; spinlock_t slock; diff --git a/drivers/media/platform/exynos4-is/media-dev.c b/drivers/media/platform/exynos4-is/media-dev.c index 1b4bb25d0a55..2020e44f63b1 100644 --- a/drivers/media/platform/exynos4-is/media-dev.c +++ b/drivers/media/platform/exynos4-is/media-dev.c @@ -46,7 +46,7 @@ static int __fimc_md_set_camclk(struct fimc_md *fmd, * Caller holds the graph mutex. */ static void fimc_pipeline_prepare(struct fimc_pipeline *p, - struct media_entity *me) + struct media_entity *me) { struct v4l2_subdev *sd; int i; @@ -168,10 +168,11 @@ error: * * Called with the graph mutex held. */ -static int __fimc_pipeline_open(struct fimc_pipeline *p, +static int __fimc_pipeline_open(struct exynos_media_pipeline *ep, struct media_entity *me, bool prepare) { struct fimc_md *fmd = entity_to_fimc_mdev(me); + struct fimc_pipeline *p = to_fimc_pipeline(ep); struct v4l2_subdev *sd; int ret; @@ -214,8 +215,9 @@ err_wbclk: * * Disable power of all subdevs and turn the external sensor clock off. */ -static int __fimc_pipeline_close(struct fimc_pipeline *p) +static int __fimc_pipeline_close(struct exynos_media_pipeline *ep) { + struct fimc_pipeline *p = to_fimc_pipeline(ep); struct v4l2_subdev *sd = p ? p->subdevs[IDX_SENSOR] : NULL; struct fimc_md *fmd; int ret = 0; @@ -242,12 +244,13 @@ static int __fimc_pipeline_close(struct fimc_pipeline *p) * @pipeline: video pipeline structure * @on: passed as the s_stream() callback argument */ -static int __fimc_pipeline_s_stream(struct fimc_pipeline *p, bool on) +static int __fimc_pipeline_s_stream(struct exynos_media_pipeline *ep, bool on) { static const u8 seq[2][IDX_MAX] = { { IDX_FIMC, IDX_SENSOR, IDX_IS_ISP, IDX_CSIS, IDX_FLITE }, { IDX_CSIS, IDX_FLITE, IDX_FIMC, IDX_SENSOR, IDX_IS_ISP }, }; + struct fimc_pipeline *p = to_fimc_pipeline(ep); int i, ret = 0; if (p->subdevs[IDX_SENSOR] == NULL) @@ -271,12 +274,38 @@ error: } /* Media pipeline operations for the FIMC/FIMC-LITE video device driver */ -static const struct fimc_pipeline_ops fimc_pipeline_ops = { +static const struct exynos_media_pipeline_ops fimc_pipeline_ops = { .open = __fimc_pipeline_open, .close = __fimc_pipeline_close, .set_stream = __fimc_pipeline_s_stream, }; +static struct exynos_media_pipeline *fimc_md_pipeline_create( + struct fimc_md *fmd) +{ + struct fimc_pipeline *p; + + p = kzalloc(sizeof(*p), GFP_KERNEL); + if (!p) + return NULL; + + list_add_tail(&p->list, &fmd->pipelines); + + p->ep.ops = &fimc_pipeline_ops; + return &p->ep; +} + +static void fimc_md_pipelines_free(struct fimc_md *fmd) +{ + while (!list_empty(&fmd->pipelines)) { + struct fimc_pipeline *p; + + p = list_entry(fmd->pipelines.next, typeof(*p), list); + list_del(&p->list); + kfree(p); + } +} + /* * Sensor subdevice helper functions */ @@ -592,6 +621,7 @@ static int register_fimc_lite_entity(struct fimc_md *fmd, struct fimc_lite *fimc_lite) { struct v4l2_subdev *sd; + struct exynos_media_pipeline *ep; int ret; if (WARN_ON(fimc_lite->index >= FIMC_LITE_MAX_DEVS || @@ -600,7 +630,12 @@ static int register_fimc_lite_entity(struct fimc_md *fmd, sd = &fimc_lite->subdev; sd->grp_id = GRP_ID_FLITE; - v4l2_set_subdev_hostdata(sd, (void *)&fimc_pipeline_ops); + + ep = fimc_md_pipeline_create(fmd); + if (!ep) + return -ENOMEM; + + v4l2_set_subdev_hostdata(sd, ep); ret = v4l2_device_register_subdev(&fmd->v4l2_dev, sd); if (!ret) @@ -614,6 +649,7 @@ static int register_fimc_lite_entity(struct fimc_md *fmd, static int register_fimc_entity(struct fimc_md *fmd, struct fimc_dev *fimc) { struct v4l2_subdev *sd; + struct exynos_media_pipeline *ep; int ret; if (WARN_ON(fimc->id >= FIMC_MAX_DEVS || fmd->fimc[fimc->id])) @@ -621,7 +657,12 @@ static int register_fimc_entity(struct fimc_md *fmd, struct fimc_dev *fimc) sd = &fimc->vid_cap.subdev; sd->grp_id = GRP_ID_FIMC; - v4l2_set_subdev_hostdata(sd, (void *)&fimc_pipeline_ops); + + ep = fimc_md_pipeline_create(fmd); + if (!ep) + return -ENOMEM; + + v4l2_set_subdev_hostdata(sd, ep); ret = v4l2_device_register_subdev(&fmd->v4l2_dev, sd); if (!ret) { @@ -797,17 +838,19 @@ static void fimc_md_unregister_entities(struct fimc_md *fmd) int i; for (i = 0; i < FIMC_MAX_DEVS; i++) { - if (fmd->fimc[i] == NULL) + struct fimc_dev *dev = fmd->fimc[i]; + if (dev == NULL) continue; - v4l2_device_unregister_subdev(&fmd->fimc[i]->vid_cap.subdev); - fmd->fimc[i]->pipeline_ops = NULL; + v4l2_device_unregister_subdev(&dev->vid_cap.subdev); + dev->vid_cap.ve.pipe = NULL; fmd->fimc[i] = NULL; } for (i = 0; i < FIMC_LITE_MAX_DEVS; i++) { - if (fmd->fimc_lite[i] == NULL) + struct fimc_lite *dev = fmd->fimc_lite[i]; + if (dev == NULL) continue; - v4l2_device_unregister_subdev(&fmd->fimc_lite[i]->subdev); - fmd->fimc_lite[i]->pipeline_ops = NULL; + v4l2_device_unregister_subdev(&dev->subdev); + dev->ve.pipe = NULL; fmd->fimc_lite[i] = NULL; } for (i = 0; i < CSIS_MAX_ENTITIES; i++) { @@ -1234,38 +1277,22 @@ int fimc_md_set_camclk(struct v4l2_subdev *sd, bool on) static int fimc_md_link_notify(struct media_pad *source, struct media_pad *sink, u32 flags) { - struct fimc_lite *fimc_lite = NULL; - struct fimc_dev *fimc = NULL; + struct exynos_video_entity *ve; + struct video_device *vdev; struct fimc_pipeline *pipeline; - struct v4l2_subdev *sd; int i, ret = 0; - if (media_entity_type(sink->entity) != MEDIA_ENT_T_V4L2_SUBDEV) + if (media_entity_type(sink->entity) != MEDIA_ENT_T_DEVNODE_V4L) return 0; - sd = media_entity_to_v4l2_subdev(sink->entity); + vdev = media_entity_to_video_device(sink->entity); + ve = vdev_to_exynos_video_entity(vdev); + pipeline = to_fimc_pipeline(ve->pipe); - switch (sd->grp_id) { - case GRP_ID_FLITE: - fimc_lite = v4l2_get_subdevdata(sd); - if (WARN_ON(fimc_lite == NULL)) - return 0; - pipeline = &fimc_lite->pipeline; - break; - case GRP_ID_FIMC: - fimc = v4l2_get_subdevdata(sd); - if (WARN_ON(fimc == NULL)) - return 0; - pipeline = &fimc->pipeline; - break; - default: - return 0; - } + if (!(flags & MEDIA_LNK_FL_ENABLED) && pipeline->subdevs[IDX_SENSOR]) { + if (sink->entity->use_count > 0) + ret = __fimc_pipeline_close(ve->pipe); - if (!(flags & MEDIA_LNK_FL_ENABLED)) { - if (sink->entity->use_count > 0) { - ret = __fimc_pipeline_close(pipeline); - } for (i = 0; i < IDX_MAX; i++) pipeline->subdevs[i] = NULL; } else if (sink->entity->use_count > 0) { @@ -1274,8 +1301,7 @@ static int fimc_md_link_notify(struct media_pad *source, * the pipeline is already in use, i.e. its video node is open. * Recreate the controls destroyed during the link deactivation. */ - ret = __fimc_pipeline_open(pipeline, - source->entity, true); + ret = __fimc_pipeline_open(ve->pipe, sink->entity, true); } return ret ? -EPIPE : ret; @@ -1358,6 +1384,7 @@ static int fimc_md_probe(struct platform_device *pdev) spin_lock_init(&fmd->slock); fmd->pdev = pdev; + INIT_LIST_HEAD(&fmd->pipelines); strlcpy(fmd->media_dev.model, "SAMSUNG S5P FIMC", sizeof(fmd->media_dev.model)); @@ -1445,6 +1472,7 @@ static int fimc_md_remove(struct platform_device *pdev) return 0; device_remove_file(&pdev->dev, &dev_attr_subdev_conf_mode); fimc_md_unregister_entities(fmd); + fimc_md_pipelines_free(fmd); media_device_unregister(&fmd->media_dev); fimc_md_put_clocks(fmd); return 0; diff --git a/drivers/media/platform/exynos4-is/media-dev.h b/drivers/media/platform/exynos4-is/media-dev.h index 3e9680c9de8b..a704eea2cfbd 100644 --- a/drivers/media/platform/exynos4-is/media-dev.h +++ b/drivers/media/platform/exynos4-is/media-dev.h @@ -18,6 +18,7 @@ #include #include #include +#include #include "fimc-core.h" #include "fimc-lite.h" @@ -40,6 +41,29 @@ enum { FIMC_MAX_WBCLKS }; +enum fimc_subdev_index { + IDX_SENSOR, + IDX_CSIS, + IDX_FLITE, + IDX_IS_ISP, + IDX_FIMC, + IDX_MAX, +}; + +/* + * This structure represents a chain of media entities, including a data + * source entity (e.g. an image sensor subdevice), a data capture entity + * - a video capture device node and any remaining entities. + */ +struct fimc_pipeline { + struct exynos_media_pipeline ep; + struct list_head list; + struct media_entity *vdev_entity; + struct v4l2_subdev *subdevs[IDX_MAX]; +}; + +#define to_fimc_pipeline(_ep) container_of(_ep, struct fimc_pipeline, ep) + struct fimc_csis_info { struct v4l2_subdev *sd; int id; @@ -104,7 +128,9 @@ struct fimc_md { struct pinctrl_state *state_idle; } pinctl; bool user_subdev_api; + spinlock_t slock; + struct list_head pipelines; }; #define is_subdev_pad(pad) (pad == NULL || \ @@ -149,4 +175,16 @@ static inline bool fimc_md_is_isp_available(struct device_node *node) #define fimc_md_is_isp_available(node) (false) #endif /* CONFIG_OF */ +static inline struct v4l2_subdev *__fimc_md_get_subdev( + struct exynos_media_pipeline *ep, + unsigned int index) +{ + struct fimc_pipeline *p = to_fimc_pipeline(ep); + + if (!p || index >= IDX_MAX) + return NULL; + else + return p->subdevs[index]; +} + #endif diff --git a/include/media/s5p_fimc.h b/include/media/s5p_fimc.h index f5313b402eb7..0afadb663bbd 100644 --- a/include/media/s5p_fimc.h +++ b/include/media/s5p_fimc.h @@ -141,41 +141,40 @@ struct fimc_fmt { #define FMT_FLAGS_YUV (1 << 7) }; -enum fimc_subdev_index { - IDX_SENSOR, - IDX_CSIS, - IDX_FLITE, - IDX_IS_ISP, - IDX_FIMC, - IDX_MAX, -}; +struct exynos_media_pipeline; -struct media_pipeline; -struct v4l2_subdev; - -struct fimc_pipeline { - struct v4l2_subdev *subdevs[IDX_MAX]; - struct media_pipeline *m_pipeline; +/* + * Media pipeline operations to be called from within a video node, i.e. the + * last entity within the pipeline. Implemented by related media device driver. + */ +struct exynos_media_pipeline_ops { + int (*prepare)(struct exynos_media_pipeline *p, + struct media_entity *me); + int (*unprepare)(struct exynos_media_pipeline *p); + int (*open)(struct exynos_media_pipeline *p, struct media_entity *me, + bool resume); + int (*close)(struct exynos_media_pipeline *p); + int (*set_stream)(struct exynos_media_pipeline *p, bool state); }; struct exynos_video_entity { struct video_device vdev; + struct exynos_media_pipeline *pipe; }; -/* - * Media pipeline operations to be called from within the fimc(-lite) - * video node when it is the last entity of the pipeline. Implemented - * by corresponding media device driver. - */ -struct fimc_pipeline_ops { - int (*open)(struct fimc_pipeline *p, struct media_entity *me, - bool resume); - int (*close)(struct fimc_pipeline *p); - int (*set_stream)(struct fimc_pipeline *p, bool state); +struct exynos_media_pipeline { + struct media_pipeline mp; + const struct exynos_media_pipeline_ops *ops; }; -#define fimc_pipeline_call(f, op, p, args...) \ - (!(f) ? -ENODEV : (((f)->pipeline_ops && (f)->pipeline_ops->op) ? \ - (f)->pipeline_ops->op((p), ##args) : -ENOIOCTLCMD)) +static inline struct exynos_video_entity *vdev_to_exynos_video_entity( + struct video_device *vdev) +{ + return container_of(vdev, struct exynos_video_entity, vdev); +} + +#define fimc_pipeline_call(ent, op, args...) \ + (!(ent) ? -ENOENT : (((ent)->pipe->ops && (ent)->pipe->ops->op) ? \ + (ent)->pipe->ops->op(((ent)->pipe), ##args) : -ENOIOCTLCMD)) \ #endif /* S5P_FIMC_H_ */ From 36da6fcdc52eae6f06f6a3fde9f8395187222162 Mon Sep 17 00:00:00 2001 From: Sylwester Nawrocki Date: Fri, 31 May 2013 11:37:23 -0300 Subject: [PATCH 0156/1048] [media] exynos4-is: Remove WARN_ON() from __fimc_pipeline_close() It's not a critical error to call __fimc_pipeline_close() with missing sensor subdev entity. Replace WARN_ON() with pr_warn() and return 0 instead of -EINVAL to fix control flow in some conditions. Signed-off-by: Sylwester Nawrocki Signed-off-by: Kyungmin Park Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/exynos4-is/media-dev.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/media/platform/exynos4-is/media-dev.c b/drivers/media/platform/exynos4-is/media-dev.c index 2020e44f63b1..5b307f26f995 100644 --- a/drivers/media/platform/exynos4-is/media-dev.c +++ b/drivers/media/platform/exynos4-is/media-dev.c @@ -220,16 +220,16 @@ static int __fimc_pipeline_close(struct exynos_media_pipeline *ep) struct fimc_pipeline *p = to_fimc_pipeline(ep); struct v4l2_subdev *sd = p ? p->subdevs[IDX_SENSOR] : NULL; struct fimc_md *fmd; - int ret = 0; + int ret; - if (WARN_ON(sd == NULL)) - return -EINVAL; - - if (p->subdevs[IDX_SENSOR]) { - ret = fimc_pipeline_s_power(p, 0); - fimc_md_set_camclk(sd, false); + if (sd == NULL) { + pr_warn("%s(): No sensor subdev\n", __func__); + return 0; } + ret = fimc_pipeline_s_power(p, 0); + fimc_md_set_camclk(sd, false); + fmd = entity_to_fimc_mdev(&sd->entity); /* Disable PXLASYNC clock if this pipeline includes FIMC-IS */ From 52917bcbe06c937e97d941ef21211f981f192f99 Mon Sep 17 00:00:00 2001 From: Sylwester Nawrocki Date: Fri, 31 May 2013 11:37:24 -0300 Subject: [PATCH 0157/1048] [media] exynos4-is: Fix sensor subdev -> FIMC notification setup Ensure the v4l2_device notifications from sensor subdev works also after the media links reconfiguration. Signed-off-by: Sylwester Nawrocki Signed-off-by: Kyungmin Park Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/exynos4-is/media-dev.c | 47 ++++++++++++------- 1 file changed, 31 insertions(+), 16 deletions(-) diff --git a/drivers/media/platform/exynos4-is/media-dev.c b/drivers/media/platform/exynos4-is/media-dev.c index 5b307f26f995..784c9e9daed8 100644 --- a/drivers/media/platform/exynos4-is/media-dev.c +++ b/drivers/media/platform/exynos4-is/media-dev.c @@ -1,8 +1,8 @@ /* * S5P/EXYNOS4 SoC series camera host interface media device driver * - * Copyright (C) 2011 - 2012 Samsung Electronics Co., Ltd. - * Sylwester Nawrocki + * Copyright (C) 2011 - 2013 Samsung Electronics Co., Ltd. + * Author: Sylwester Nawrocki * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published @@ -39,6 +39,26 @@ static int __fimc_md_set_camclk(struct fimc_md *fmd, struct fimc_source_info *si, bool on); + +/* Set up image sensor subdev -> FIMC capture node notifications. */ +static void __setup_sensor_notification(struct fimc_md *fmd, + struct v4l2_subdev *sensor, + struct v4l2_subdev *fimc_sd) +{ + struct fimc_source_info *src_inf; + struct fimc_sensor_info *md_si; + unsigned long flags; + + src_inf = v4l2_get_subdev_hostdata(sensor); + if (!src_inf || WARN_ON(fmd == NULL)) + return; + + md_si = source_to_sensor_info(src_inf); + spin_lock_irqsave(&fmd->slock, flags); + md_si->host = v4l2_get_subdevdata(fimc_sd); + spin_unlock_irqrestore(&fmd->slock, flags); +} + /** * fimc_pipeline_prepare - update pipeline information with subdevice pointers * @me: media entity terminating the pipeline @@ -48,7 +68,9 @@ static int __fimc_md_set_camclk(struct fimc_md *fmd, static void fimc_pipeline_prepare(struct fimc_pipeline *p, struct media_entity *me) { + struct fimc_md *fmd = entity_to_fimc_mdev(me); struct v4l2_subdev *sd; + struct v4l2_subdev *sensor = NULL; int i; for (i = 0; i < IDX_MAX; i++) @@ -73,8 +95,10 @@ static void fimc_pipeline_prepare(struct fimc_pipeline *p, sd = media_entity_to_v4l2_subdev(pad->entity); switch (sd->grp_id) { - case GRP_ID_FIMC_IS_SENSOR: case GRP_ID_SENSOR: + sensor = sd; + /* fall through */ + case GRP_ID_FIMC_IS_SENSOR: p->subdevs[IDX_SENSOR] = sd; break; case GRP_ID_CSIS: @@ -84,7 +108,7 @@ static void fimc_pipeline_prepare(struct fimc_pipeline *p, p->subdevs[IDX_FLITE] = sd; break; case GRP_ID_FIMC: - /* No need to control FIMC subdev through subdev ops */ + p->subdevs[IDX_FIMC] = sd; break; case GRP_ID_FIMC_IS: p->subdevs[IDX_IS_ISP] = sd; @@ -96,6 +120,9 @@ static void fimc_pipeline_prepare(struct fimc_pipeline *p, if (me->num_pads == 1) break; } + + if (sensor && p->subdevs[IDX_FIMC]) + __setup_sensor_notification(fmd, sensor, p->subdevs[IDX_FIMC]); } /** @@ -923,18 +950,6 @@ static int __fimc_md_create_fimc_sink_links(struct fimc_md *fmd, v4l2_info(&fmd->v4l2_dev, "created link [%s] %c> [%s]\n", source->name, flags ? '=' : '-', sink->name); - - if (flags == 0 || sensor == NULL) - continue; - - if (!WARN_ON(si == NULL)) { - unsigned long irq_flags; - struct fimc_sensor_info *inf = source_to_sensor_info(si); - - spin_lock_irqsave(&fmd->slock, irq_flags); - inf->host = fmd->fimc[i]; - spin_unlock_irqrestore(&fmd->slock, irq_flags); - } } for (i = 0; i < FIMC_LITE_MAX_DEVS; i++) { From 26d63d13da2c7de2547f6f455ae20045285dfeb8 Mon Sep 17 00:00:00 2001 From: Sylwester Nawrocki Date: Fri, 31 May 2013 11:37:25 -0300 Subject: [PATCH 0158/1048] [media] exynos4-is: Add locking at fimc(-lite) subdev unregistered handler Protect the fimc/fimc-lite video nodes unregistration with their video lock. This prevents a kernel crash when e.g. udev opens a video node right after the driver registers it and then the driver tries to unregister it and defers its probing. Using video_is_unregistered() together with the video mutex allows safe unregistration of the video nodes at any time. Signed-off-by: Sylwester Nawrocki Signed-off-by: Kyungmin Park Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/exynos4-is/fimc-capture.c | 4 ++++ drivers/media/platform/exynos4-is/fimc-lite.c | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/drivers/media/platform/exynos4-is/fimc-capture.c b/drivers/media/platform/exynos4-is/fimc-capture.c index 33c6a2f0ad74..1578aa4e4bb5 100644 --- a/drivers/media/platform/exynos4-is/fimc-capture.c +++ b/drivers/media/platform/exynos4-is/fimc-capture.c @@ -1855,6 +1855,8 @@ static void fimc_capture_subdev_unregistered(struct v4l2_subdev *sd) if (fimc == NULL) return; + mutex_lock(&fimc->lock); + fimc_unregister_m2m_device(fimc); vdev = &fimc->vid_cap.ve.vdev; @@ -1866,6 +1868,8 @@ static void fimc_capture_subdev_unregistered(struct v4l2_subdev *sd) } kfree(fimc->vid_cap.ctx); fimc->vid_cap.ctx = NULL; + + mutex_unlock(&fimc->lock); } static const struct v4l2_subdev_internal_ops fimc_capture_sd_internal_ops = { diff --git a/drivers/media/platform/exynos4-is/fimc-lite.c b/drivers/media/platform/exynos4-is/fimc-lite.c index 24e2a0f8797a..3f76f8abc4b3 100644 --- a/drivers/media/platform/exynos4-is/fimc-lite.c +++ b/drivers/media/platform/exynos4-is/fimc-lite.c @@ -1300,11 +1300,15 @@ static void fimc_lite_subdev_unregistered(struct v4l2_subdev *sd) if (fimc == NULL) return; + mutex_lock(&fimc->lock); + if (video_is_registered(&fimc->ve.vdev)) { video_unregister_device(&fimc->ve.vdev); media_entity_cleanup(&fimc->ve.vdev.entity); fimc->ve.pipe = NULL; } + + mutex_unlock(&fimc->lock); } static const struct v4l2_subdev_internal_ops fimc_lite_subdev_internal_ops = { From 5c327e73991485008c941436fb96413d9b010254 Mon Sep 17 00:00:00 2001 From: Sylwester Nawrocki Date: Fri, 31 May 2013 13:46:59 -0300 Subject: [PATCH 0159/1048] [media] exynos4-is: Remove leftovers of non-dt FIMC-LITE support FIMC-LITE devices are never looked up by iterating over all platform devices with bus_for_each_device() as these IP blocks are available only on dt-only Exynos SoC platforms. Signed-off-by: Sylwester Nawrocki Signed-off-by: Kyungmin Park Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/exynos4-is/media-dev.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/media/platform/exynos4-is/media-dev.c b/drivers/media/platform/exynos4-is/media-dev.c index 784c9e9daed8..b5624931d16d 100644 --- a/drivers/media/platform/exynos4-is/media-dev.c +++ b/drivers/media/platform/exynos4-is/media-dev.c @@ -804,8 +804,6 @@ static int fimc_md_pdev_match(struct device *dev, void *data) if (!strcmp(pdev->name, CSIS_DRIVER_NAME)) { plat_entity = IDX_CSIS; - } else if (!strcmp(pdev->name, FIMC_LITE_DRV_NAME)) { - plat_entity = IDX_FLITE; } else { p = strstr(pdev->name, "fimc"); if (p && *(p + 4) == 0) From 0e761b21b9d6c7a95a8e2b858af85d07f6c62d99 Mon Sep 17 00:00:00 2001 From: Phil Carmody Date: Fri, 31 May 2013 13:47:00 -0300 Subject: [PATCH 0160/1048] [media] exynos4-is: Simplify bitmask usage Merge the two sets of flags into one array to simplify accessing arbitrary bits from them. Signed-off-by: Phil Carmody Signed-off-by: Sylwester Nawrocki Signed-off-by: Mauro Carvalho Chehab --- .../media/platform/exynos4-is/fimc-is-param.c | 80 +++++++++---------- .../media/platform/exynos4-is/fimc-is-regs.c | 4 +- drivers/media/platform/exynos4-is/fimc-is.c | 8 +- drivers/media/platform/exynos4-is/fimc-is.h | 8 +- drivers/media/platform/exynos4-is/fimc-isp.c | 4 +- 5 files changed, 49 insertions(+), 55 deletions(-) diff --git a/drivers/media/platform/exynos4-is/fimc-is-param.c b/drivers/media/platform/exynos4-is/fimc-is-param.c index c435db0da673..c7e7f694c6ed 100644 --- a/drivers/media/platform/exynos4-is/fimc-is-param.c +++ b/drivers/media/platform/exynos4-is/fimc-is-param.c @@ -168,8 +168,8 @@ unsigned int __get_pending_param_count(struct fimc_is *is) unsigned int count; spin_lock_irqsave(&is->slock, flags); - count = hweight32(config->p_region_index1); - count += hweight32(config->p_region_index2); + count = hweight32(config->p_region_index[0]); + count += hweight32(config->p_region_index[1]); spin_unlock_irqrestore(&is->slock, flags); return count; @@ -177,31 +177,30 @@ unsigned int __get_pending_param_count(struct fimc_is *is) int __is_hw_update_params(struct fimc_is *is) { - unsigned long *p_index1, *p_index2; + unsigned long *p_index; int i, id, ret = 0; id = is->config_index; - p_index1 = &is->config[id].p_region_index1; - p_index2 = &is->config[id].p_region_index2; + p_index = &is->config[id].p_region_index[0]; - if (test_bit(PARAM_GLOBAL_SHOTMODE, p_index1)) + if (test_bit(PARAM_GLOBAL_SHOTMODE, p_index)) __fimc_is_hw_update_param_global_shotmode(is); - if (test_bit(PARAM_SENSOR_FRAME_RATE, p_index1)) + if (test_bit(PARAM_SENSOR_FRAME_RATE, p_index)) __fimc_is_hw_update_param_sensor_framerate(is); for (i = PARAM_ISP_CONTROL; i < PARAM_DRC_CONTROL; i++) { - if (test_bit(i, p_index1)) + if (test_bit(i, p_index)) ret = __fimc_is_hw_update_param(is, i); } for (i = PARAM_DRC_CONTROL; i < PARAM_SCALERC_CONTROL; i++) { - if (test_bit(i, p_index1)) + if (test_bit(i, p_index)) ret = __fimc_is_hw_update_param(is, i); } for (i = PARAM_FD_CONTROL; i <= PARAM_FD_CONFIG; i++) { - if (test_bit((i - 32), p_index2)) + if (test_bit(i, p_index)) ret = __fimc_is_hw_update_param(is, i); } @@ -243,7 +242,7 @@ void __is_set_frame_size(struct fimc_is *is, struct v4l2_mbus_framefmt *mf) fd->otf_input.height = mf->height; if (test_bit(PARAM_ISP_OTF_INPUT, - &is->config[index].p_region_index1)) + &is->config[index].p_region_index[0])) return; /* Update field */ @@ -368,7 +367,7 @@ void __is_set_isp_adjust(struct fimc_is *is, u32 cmd, u32 val) unsigned long *p_index; struct isp_param *isp; - p_index = &is->config[index].p_region_index1; + p_index = &is->config[index].p_region_index[0]; isp = &is->config[index].isp; switch (cmd) { @@ -415,7 +414,7 @@ void __is_set_isp_metering(struct fimc_is *is, u32 id, u32 val) struct isp_param *isp; unsigned long *p_index; - p_index = &is->config[index].p_region_index1; + p_index = &is->config[index].p_region_index[0]; isp = &is->config[index].isp; switch (id) { @@ -476,7 +475,7 @@ void __is_set_fd_control(struct fimc_is *is, u32 val) struct fd_param *fd; unsigned long *p_index; - p_index = &is->config[index].p_region_index2; + p_index = &is->config[index].p_region_index[1]; fd = &is->config[index].fd; fd->control.cmd = val; @@ -491,7 +490,7 @@ void __is_set_fd_config_maxface(struct fimc_is *is, u32 val) struct fd_param *fd; unsigned long *p_index; - p_index = &is->config[index].p_region_index2; + p_index = &is->config[index].p_region_index[1]; fd = &is->config[index].fd; fd->config.max_number = val; @@ -511,7 +510,7 @@ void __is_set_fd_config_rollangle(struct fimc_is *is, u32 val) struct fd_param *fd; unsigned long *p_index; - p_index = &is->config[index].p_region_index2; + p_index = &is->config[index].p_region_index[1]; fd = &is->config[index].fd; fd->config.roll_angle = val; @@ -531,7 +530,7 @@ void __is_set_fd_config_yawangle(struct fimc_is *is, u32 val) struct fd_param *fd; unsigned long *p_index; - p_index = &is->config[index].p_region_index2; + p_index = &is->config[index].p_region_index[1]; fd = &is->config[index].fd; fd->config.yaw_angle = val; @@ -551,7 +550,7 @@ void __is_set_fd_config_smilemode(struct fimc_is *is, u32 val) struct fd_param *fd; unsigned long *p_index; - p_index = &is->config[index].p_region_index2; + p_index = &is->config[index].p_region_index[1]; fd = &is->config[index].fd; fd->config.smile_mode = val; @@ -571,7 +570,7 @@ void __is_set_fd_config_blinkmode(struct fimc_is *is, u32 val) struct fd_param *fd; unsigned long *p_index; - p_index = &is->config[index].p_region_index2; + p_index = &is->config[index].p_region_index[1]; fd = &is->config[index].fd; fd->config.blink_mode = val; @@ -591,7 +590,7 @@ void __is_set_fd_config_eyedetect(struct fimc_is *is, u32 val) struct fd_param *fd; unsigned long *p_index; - p_index = &is->config[index].p_region_index2; + p_index = &is->config[index].p_region_index[1]; fd = &is->config[index].fd; fd->config.eye_detect = val; @@ -611,7 +610,7 @@ void __is_set_fd_config_mouthdetect(struct fimc_is *is, u32 val) struct fd_param *fd; unsigned long *p_index; - p_index = &is->config[index].p_region_index2; + p_index = &is->config[index].p_region_index[1]; fd = &is->config[index].fd; fd->config.mouth_detect = val; @@ -631,7 +630,7 @@ void __is_set_fd_config_orientation(struct fimc_is *is, u32 val) struct fd_param *fd; unsigned long *p_index; - p_index = &is->config[index].p_region_index2; + p_index = &is->config[index].p_region_index[1]; fd = &is->config[index].fd; fd->config.orientation = val; @@ -651,7 +650,7 @@ void __is_set_fd_config_orientation_val(struct fimc_is *is, u32 val) struct fd_param *fd; unsigned long *p_index; - p_index = &is->config[index].p_region_index2; + p_index = &is->config[index].p_region_index[1]; fd = &is->config[index].fd; fd->config.orientation_value = val; @@ -672,7 +671,7 @@ void fimc_is_set_initial_params(struct fimc_is *is) struct isp_param *isp; struct drc_param *drc; struct fd_param *fd; - unsigned long *p_index1, *p_index2; + unsigned long *p_index; unsigned int index; index = is->config_index; @@ -681,8 +680,7 @@ void fimc_is_set_initial_params(struct fimc_is *is) isp = &is->config[index].isp; drc = &is->config[index].drc; fd = &is->config[index].fd; - p_index1 = &is->config[index].p_region_index1; - p_index2 = &is->config[index].p_region_index2; + p_index = &is->config[index].p_region_index[0]; /* Global */ global->shotmode.cmd = 1; @@ -695,7 +693,7 @@ void fimc_is_set_initial_params(struct fimc_is *is) fimc_is_set_param_bit(is, PARAM_ISP_CONTROL); isp->otf_input.cmd = OTF_INPUT_COMMAND_ENABLE; - if (!test_bit(PARAM_ISP_OTF_INPUT, p_index1)) { + if (!test_bit(PARAM_ISP_OTF_INPUT, p_index)) { isp->otf_input.width = DEFAULT_PREVIEW_STILL_WIDTH; isp->otf_input.height = DEFAULT_PREVIEW_STILL_HEIGHT; fimc_is_set_param_bit(is, PARAM_ISP_OTF_INPUT); @@ -738,20 +736,20 @@ void fimc_is_set_initial_params(struct fimc_is *is) isp->aa.target = ISP_AA_TARGET_AE | ISP_AA_TARGET_AWB; fimc_is_set_param_bit(is, PARAM_ISP_AA); - if (!test_bit(PARAM_ISP_FLASH, p_index1)) + if (!test_bit(PARAM_ISP_FLASH, p_index)) __is_set_isp_flash(is, ISP_FLASH_COMMAND_DISABLE, ISP_FLASH_REDEYE_DISABLE); - if (!test_bit(PARAM_ISP_AWB, p_index1)) + if (!test_bit(PARAM_ISP_AWB, p_index)) __is_set_isp_awb(is, ISP_AWB_COMMAND_AUTO, 0); - if (!test_bit(PARAM_ISP_IMAGE_EFFECT, p_index1)) + if (!test_bit(PARAM_ISP_IMAGE_EFFECT, p_index)) __is_set_isp_effect(is, ISP_IMAGE_EFFECT_DISABLE); - if (!test_bit(PARAM_ISP_ISO, p_index1)) + if (!test_bit(PARAM_ISP_ISO, p_index)) __is_set_isp_iso(is, ISP_ISO_COMMAND_AUTO, 0); - if (!test_bit(PARAM_ISP_ADJUST, p_index1)) { + if (!test_bit(PARAM_ISP_ADJUST, p_index)) { __is_set_isp_adjust(is, ISP_ADJUST_COMMAND_MANUAL_CONTRAST, 0); __is_set_isp_adjust(is, ISP_ADJUST_COMMAND_MANUAL_SATURATION, 0); @@ -762,7 +760,7 @@ void fimc_is_set_initial_params(struct fimc_is *is) __is_set_isp_adjust(is, ISP_ADJUST_COMMAND_MANUAL_HUE, 0); } - if (!test_bit(PARAM_ISP_METERING, p_index1)) { + if (!test_bit(PARAM_ISP_METERING, p_index)) { __is_set_isp_metering(is, 0, ISP_METERING_COMMAND_CENTER); __is_set_isp_metering(is, 1, 0); __is_set_isp_metering(is, 2, 0); @@ -770,11 +768,11 @@ void fimc_is_set_initial_params(struct fimc_is *is) __is_set_isp_metering(is, 4, 0); } - if (!test_bit(PARAM_ISP_AFC, p_index1)) + if (!test_bit(PARAM_ISP_AFC, p_index)) __is_set_isp_afc(is, ISP_AFC_COMMAND_AUTO, 0); isp->otf_output.cmd = OTF_OUTPUT_COMMAND_ENABLE; - if (!test_bit(PARAM_ISP_OTF_OUTPUT, p_index1)) { + if (!test_bit(PARAM_ISP_OTF_OUTPUT, p_index)) { isp->otf_output.width = DEFAULT_PREVIEW_STILL_WIDTH; isp->otf_output.height = DEFAULT_PREVIEW_STILL_HEIGHT; fimc_is_set_param_bit(is, PARAM_ISP_OTF_OUTPUT); @@ -784,7 +782,7 @@ void fimc_is_set_initial_params(struct fimc_is *is) isp->otf_output.order = 0; isp->otf_output.err = OTF_OUTPUT_ERROR_NONE; - if (!test_bit(PARAM_ISP_DMA1_OUTPUT, p_index1)) { + if (!test_bit(PARAM_ISP_DMA1_OUTPUT, p_index)) { isp->dma1_output.cmd = DMA_OUTPUT_COMMAND_DISABLE; isp->dma1_output.width = 0; isp->dma1_output.height = 0; @@ -800,7 +798,7 @@ void fimc_is_set_initial_params(struct fimc_is *is) fimc_is_set_param_bit(is, PARAM_ISP_DMA1_OUTPUT); } - if (!test_bit(PARAM_ISP_DMA2_OUTPUT, p_index1)) { + if (!test_bit(PARAM_ISP_DMA2_OUTPUT, p_index)) { isp->dma2_output.cmd = DMA_OUTPUT_COMMAND_DISABLE; isp->dma2_output.width = 0; isp->dma2_output.height = 0; @@ -817,7 +815,7 @@ void fimc_is_set_initial_params(struct fimc_is *is) } /* Sensor */ - if (!test_bit(PARAM_SENSOR_FRAME_RATE, p_index1)) { + if (!test_bit(PARAM_SENSOR_FRAME_RATE, p_index)) { if (is->config_index == 0) __is_set_sensor(is, 0); } @@ -827,7 +825,7 @@ void fimc_is_set_initial_params(struct fimc_is *is) __is_set_drc_control(is, CONTROL_BYPASS_ENABLE); drc->otf_input.cmd = OTF_INPUT_COMMAND_ENABLE; - if (!test_bit(PARAM_DRC_OTF_INPUT, p_index1)) { + if (!test_bit(PARAM_DRC_OTF_INPUT, p_index)) { drc->otf_input.width = DEFAULT_PREVIEW_STILL_WIDTH; drc->otf_input.height = DEFAULT_PREVIEW_STILL_HEIGHT; fimc_is_set_param_bit(is, PARAM_DRC_OTF_INPUT); @@ -850,7 +848,7 @@ void fimc_is_set_initial_params(struct fimc_is *is) fimc_is_set_param_bit(is, PARAM_DRC_DMA_INPUT); drc->otf_output.cmd = OTF_OUTPUT_COMMAND_ENABLE; - if (!test_bit(PARAM_DRC_OTF_OUTPUT, p_index1)) { + if (!test_bit(PARAM_DRC_OTF_OUTPUT, p_index)) { drc->otf_output.width = DEFAULT_PREVIEW_STILL_WIDTH; drc->otf_output.height = DEFAULT_PREVIEW_STILL_HEIGHT; fimc_is_set_param_bit(is, PARAM_DRC_OTF_OUTPUT); @@ -865,7 +863,7 @@ void fimc_is_set_initial_params(struct fimc_is *is) fd->control.bypass = CONTROL_BYPASS_DISABLE; fd->otf_input.cmd = OTF_INPUT_COMMAND_ENABLE; - if (!test_bit((PARAM_FD_OTF_INPUT - 32), p_index2)) { + if (!test_bit(PARAM_FD_OTF_INPUT, p_index)) { fd->otf_input.width = DEFAULT_PREVIEW_STILL_WIDTH; fd->otf_input.height = DEFAULT_PREVIEW_STILL_HEIGHT; fimc_is_set_param_bit(is, PARAM_FD_OTF_INPUT); diff --git a/drivers/media/platform/exynos4-is/fimc-is-regs.c b/drivers/media/platform/exynos4-is/fimc-is-regs.c index b0ff67bc1b05..11b7b0acb56d 100644 --- a/drivers/media/platform/exynos4-is/fimc-is-regs.c +++ b/drivers/media/platform/exynos4-is/fimc-is-regs.c @@ -89,8 +89,8 @@ int fimc_is_hw_set_param(struct fimc_is *is) mcuctl_write(is->config_index, is, MCUCTL_REG_ISSR(2)); mcuctl_write(param_count, is, MCUCTL_REG_ISSR(3)); - mcuctl_write(config->p_region_index1, is, MCUCTL_REG_ISSR(4)); - mcuctl_write(config->p_region_index2, is, MCUCTL_REG_ISSR(5)); + mcuctl_write(config->p_region_index[0], is, MCUCTL_REG_ISSR(4)); + mcuctl_write(config->p_region_index[1], is, MCUCTL_REG_ISSR(5)); fimc_is_hw_set_intgr0_gd0(is); return 0; diff --git a/drivers/media/platform/exynos4-is/fimc-is.c b/drivers/media/platform/exynos4-is/fimc-is.c index cdb6b5e27336..ddb32e4ae0e9 100644 --- a/drivers/media/platform/exynos4-is/fimc-is.c +++ b/drivers/media/platform/exynos4-is/fimc-is.c @@ -530,8 +530,8 @@ static void fimc_is_general_irq_handler(struct fimc_is *is) break; case HIC_SET_PARAMETER: - is->config[is->config_index].p_region_index1 = 0; - is->config[is->config_index].p_region_index2 = 0; + is->config[is->config_index].p_region_index[0] = 0; + is->config[is->config_index].p_region_index[1] = 0; set_bit(IS_ST_BLOCK_CMD_CLEARED, &is->state); pr_debug("HIC_SET_PARAMETER\n"); break; @@ -590,8 +590,8 @@ static void fimc_is_general_irq_handler(struct fimc_is *is) switch (is->i2h_cmd.args[0]) { case HIC_SET_PARAMETER: - is->config[is->config_index].p_region_index1 = 0; - is->config[is->config_index].p_region_index2 = 0; + is->config[is->config_index].p_region_index[0] = 0; + is->config[is->config_index].p_region_index[1] = 0; set_bit(IS_ST_BLOCK_CMD_CLEARED, &is->state); break; } diff --git a/drivers/media/platform/exynos4-is/fimc-is.h b/drivers/media/platform/exynos4-is/fimc-is.h index f5275a5b0156..04b456499d49 100644 --- a/drivers/media/platform/exynos4-is/fimc-is.h +++ b/drivers/media/platform/exynos4-is/fimc-is.h @@ -226,8 +226,7 @@ struct chain_config { struct drc_param drc; struct fd_param fd; - unsigned long p_region_index1; - unsigned long p_region_index2; + unsigned long p_region_index[2]; }; /** @@ -304,10 +303,7 @@ static inline void fimc_is_set_param_bit(struct fimc_is *is, int num) { struct chain_config *cfg = &is->config[is->config_index]; - if (num >= 32) - set_bit(num - 32, &cfg->p_region_index2); - else - set_bit(num, &cfg->p_region_index1); + set_bit(num, &cfg->p_region_index[0]); } static inline void fimc_is_set_param_ctrl_cmd(struct fimc_is *is, int cmd) diff --git a/drivers/media/platform/exynos4-is/fimc-isp.c b/drivers/media/platform/exynos4-is/fimc-isp.c index d63947f7b302..0fefb53a5b56 100644 --- a/drivers/media/platform/exynos4-is/fimc-isp.c +++ b/drivers/media/platform/exynos4-is/fimc-isp.c @@ -317,8 +317,8 @@ static int fimc_isp_subdev_s_power(struct v4l2_subdev *sd, int on) clear_bit(IS_ST_PWR_ON, &is->state); clear_bit(IS_ST_INIT_DONE, &is->state); is->state = 0; - is->config[is->config_index].p_region_index1 = 0; - is->config[is->config_index].p_region_index2 = 0; + is->config[is->config_index].p_region_index[0] = 0; + is->config[is->config_index].p_region_index[1] = 0; set_bit(IS_ST_IDLE, &is->state); wmb(); } From f525e176f938f31a7335ce2bfec433236e0d8d6a Mon Sep 17 00:00:00 2001 From: Sylwester Nawrocki Date: Fri, 31 May 2013 13:47:01 -0300 Subject: [PATCH 0161/1048] [media] exynos4-is: Remove unused code Remove unused macros and fields of struct fimc_is_video. Signed-off-by: Sylwester Nawrocki Signed-off-by: Kyungmin Park Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/exynos4-is/fimc-isp.h | 13 +------------ drivers/media/platform/exynos4-is/media-dev.h | 8 -------- 2 files changed, 1 insertion(+), 20 deletions(-) diff --git a/drivers/media/platform/exynos4-is/fimc-isp.h b/drivers/media/platform/exynos4-is/fimc-isp.h index 800aba7ab4a7..f5c802cf40f9 100644 --- a/drivers/media/platform/exynos4-is/fimc-isp.h +++ b/drivers/media/platform/exynos4-is/fimc-isp.h @@ -118,7 +118,6 @@ struct fimc_is_video { unsigned int frame_count; unsigned int reqbufs_count; int streaming; - unsigned long payload[FIMC_ISP_MAX_PLANES]; const struct fimc_fmt *format; }; @@ -128,15 +127,9 @@ struct fimc_is_video { * @alloc_ctx: videobuf2 memory allocator context * @subdev: ISP v4l2_subdev * @subdev_pads: the ISP subdev media pads - * @ctrl_handler: v4l2 controls handler * @test_pattern: test pattern controls - * @pipeline: video capture pipeline data structure + * @ctrls: v4l2 controls structure * @video_lock: mutex serializing video device and the subdev operations - * @fmt: pointer to color format description structure - * @payload: image size in bytes (w x h x bpp) - * @inp_frame: camera input frame structure - * @out_frame: DMA output frame structure - * @source_subdev_grp_id: group id of remote source subdev * @cac_margin_x: horizontal CAC margin in pixels * @cac_margin_y: vertical CAC margin in pixels * @state: driver state flags @@ -154,10 +147,6 @@ struct fimc_isp { struct mutex video_lock; struct mutex subdev_lock; - struct fimc_isp_frame inp_frame; - struct fimc_isp_frame out_frame; - unsigned int source_subdev_grp_id; - unsigned int cac_margin_x; unsigned int cac_margin_y; diff --git a/drivers/media/platform/exynos4-is/media-dev.h b/drivers/media/platform/exynos4-is/media-dev.h index a704eea2cfbd..62599fd7756f 100644 --- a/drivers/media/platform/exynos4-is/media-dev.h +++ b/drivers/media/platform/exynos4-is/media-dev.h @@ -133,14 +133,6 @@ struct fimc_md { struct list_head pipelines; }; -#define is_subdev_pad(pad) (pad == NULL || \ - media_entity_type(pad->entity) == MEDIA_ENT_T_V4L2_SUBDEV) - -#define me_subtype(me) \ - ((me->type) & (MEDIA_ENT_TYPE_MASK | MEDIA_ENT_SUBTYPE_MASK)) - -#define subdev_has_devnode(__sd) (__sd->flags & V4L2_SUBDEV_FL_HAS_DEVNODE) - static inline struct fimc_sensor_info *source_to_sensor_info(struct fimc_source_info *si) { From 7536b4240f1bdc71f83cf008160e71c38f7ac9ff Mon Sep 17 00:00:00 2001 From: Sylwester Nawrocki Date: Fri, 31 May 2013 13:47:02 -0300 Subject: [PATCH 0162/1048] [media] exynos4-is: Refactor vidioc_s_fmt, vidioc_try_fmt handlers Remove duplicated code in the vidioc_try_fmt and vidioc_s_fmt handlers. This is a pre-requsite to allow successful fimc.capture video open even if its corresponding media entities are not linked into a complete pipeline. Signed-off-by: Sylwester Nawrocki Signed-off-by: Kyungmin Park Signed-off-by: Mauro Carvalho Chehab --- .../media/platform/exynos4-is/fimc-capture.c | 166 +++++++++--------- 1 file changed, 79 insertions(+), 87 deletions(-) diff --git a/drivers/media/platform/exynos4-is/fimc-capture.c b/drivers/media/platform/exynos4-is/fimc-capture.c index 1578aa4e4bb5..2b045b6db569 100644 --- a/drivers/media/platform/exynos4-is/fimc-capture.c +++ b/drivers/media/platform/exynos4-is/fimc-capture.c @@ -503,9 +503,6 @@ static int fimc_capture_open(struct file *file) ret = fimc_pipeline_call(ve, open, &ve->vdev.entity, true); - if (ret == 0) - ret = fimc_capture_set_default_format(fimc); - if (ret == 0 && vc->user_subdev_api && vc->inh_sensor_ctrls) { /* * Recreate controls of the the video node to drop @@ -522,6 +519,9 @@ static int fimc_capture_open(struct file *file) fimc_md_graph_unlock(ve); + if (ret == 0) + ret = fimc_capture_set_default_format(fimc); + if (ret < 0) { clear_bit(ST_CAPT_BUSY, &fimc->state); pm_runtime_put_sync(&fimc->pdev->dev); @@ -916,55 +916,83 @@ static int fimc_cap_g_fmt_mplane(struct file *file, void *fh, return 0; } -static int fimc_cap_try_fmt_mplane(struct file *file, void *fh, - struct v4l2_format *f) +/* + * Try or set format on the fimc.X.capture video node and additionally + * on the whole pipeline if @try is false. + * Locking: the caller must _not_ hold the graph mutex. + */ +static int __video_try_or_set_format(struct fimc_dev *fimc, + struct v4l2_format *f, bool try, + struct fimc_fmt **inp_fmt, + struct fimc_fmt **out_fmt) { struct v4l2_pix_format_mplane *pix = &f->fmt.pix_mp; - struct fimc_dev *fimc = video_drvdata(file); - struct fimc_ctx *ctx = fimc->vid_cap.ctx; - struct exynos_video_entity *ve = &fimc->vid_cap.ve; - struct v4l2_mbus_framefmt mf; - struct v4l2_subdev *sensor; - struct fimc_fmt *ffmt = NULL; + struct fimc_vid_cap *vc = &fimc->vid_cap; + struct exynos_video_entity *ve = &vc->ve; + struct fimc_ctx *ctx = vc->ctx; + unsigned int width = 0, height = 0; int ret = 0; + /* Pre-configure format at the camera input interface, for JPEG only */ if (fimc_jpeg_fourcc(pix->pixelformat)) { fimc_capture_try_format(ctx, &pix->width, &pix->height, NULL, &pix->pixelformat, FIMC_SD_PAD_SINK_CAM); - ctx->s_frame.f_width = pix->width; - ctx->s_frame.f_height = pix->height; + if (try) { + width = pix->width; + height = pix->height; + } else { + ctx->s_frame.f_width = pix->width; + ctx->s_frame.f_height = pix->height; + } } - ffmt = fimc_capture_try_format(ctx, &pix->width, &pix->height, - NULL, &pix->pixelformat, - FIMC_SD_PAD_SOURCE); - if (!ffmt) + + /* Try the format at the scaler and the DMA output */ + *out_fmt = fimc_capture_try_format(ctx, &pix->width, &pix->height, + NULL, &pix->pixelformat, + FIMC_SD_PAD_SOURCE); + if (*out_fmt == NULL) return -EINVAL; - if (!fimc->vid_cap.user_subdev_api) { - mf.width = pix->width; - mf.height = pix->height; - mf.code = ffmt->mbus_code; - - fimc_md_graph_lock(ve); - fimc_pipeline_try_format(ctx, &mf, &ffmt, false); - fimc_md_graph_unlock(ve); - - pix->width = mf.width; - pix->height = mf.height; - if (ffmt) - pix->pixelformat = ffmt->fourcc; + /* Restore image width/height for JPEG (no resizing supported). */ + if (try && fimc_jpeg_fourcc(pix->pixelformat)) { + pix->width = width; + pix->height = height; } - fimc_adjust_mplane_format(ffmt, pix->width, pix->height, pix); + /* Try to match format at the host and the sensor */ + if (!vc->user_subdev_api) { + struct v4l2_mbus_framefmt mbus_fmt; + struct v4l2_mbus_framefmt *mf; + + mf = try ? &mbus_fmt : &fimc->vid_cap.ci_fmt; + + mf->code = (*out_fmt)->mbus_code; + mf->width = pix->width; + mf->height = pix->height; + + fimc_md_graph_lock(ve); + ret = fimc_pipeline_try_format(ctx, mf, inp_fmt, try); + fimc_md_graph_unlock(ve); + + if (ret < 0) + return ret; + + pix->width = mf->width; + pix->height = mf->height; + } + + fimc_adjust_mplane_format(*out_fmt, pix->width, pix->height, pix); + + if ((*out_fmt)->flags & FMT_FLAGS_COMPRESSED) { + struct v4l2_subdev *sensor; - if (ffmt->flags & FMT_FLAGS_COMPRESSED) { fimc_md_graph_lock(ve); sensor = __fimc_md_get_subdev(ve->pipe, IDX_SENSOR); if (sensor) fimc_get_sensor_frame_desc(sensor, pix->plane_fmt, - ffmt->memplanes, true); + (*out_fmt)->memplanes, try); else ret = -EPIPE; @@ -974,6 +1002,15 @@ static int fimc_cap_try_fmt_mplane(struct file *file, void *fh, return ret; } +static int fimc_cap_try_fmt_mplane(struct file *file, void *fh, + struct v4l2_format *f) +{ + struct fimc_dev *fimc = video_drvdata(file); + struct fimc_fmt *out_fmt = NULL, *inp_fmt = NULL; + + return __video_try_or_set_format(fimc, f, true, &inp_fmt, &out_fmt); +} + static void fimc_capture_mark_jpeg_xfer(struct fimc_ctx *ctx, enum fimc_color_fmt color) { @@ -991,58 +1028,23 @@ static void fimc_capture_mark_jpeg_xfer(struct fimc_ctx *ctx, static int __fimc_capture_set_format(struct fimc_dev *fimc, struct v4l2_format *f) { - struct fimc_ctx *ctx = fimc->vid_cap.ctx; + struct fimc_vid_cap *vc = &fimc->vid_cap; + struct fimc_ctx *ctx = vc->ctx; struct v4l2_pix_format_mplane *pix = &f->fmt.pix_mp; - struct v4l2_mbus_framefmt *mf = &fimc->vid_cap.ci_fmt; - struct fimc_pipeline *p = to_fimc_pipeline(fimc->vid_cap.ve.pipe); struct fimc_frame *ff = &ctx->d_frame; - struct fimc_fmt *s_fmt = NULL; + struct fimc_fmt *inp_fmt = NULL; int ret, i; if (vb2_is_busy(&fimc->vid_cap.vbq)) return -EBUSY; - /* Pre-configure format at camera interface input, for JPEG only */ - if (fimc_jpeg_fourcc(pix->pixelformat)) { - fimc_capture_try_format(ctx, &pix->width, &pix->height, - NULL, &pix->pixelformat, - FIMC_SD_PAD_SINK_CAM); - ctx->s_frame.f_width = pix->width; - ctx->s_frame.f_height = pix->height; - } - /* Try the format at the scaler and the DMA output */ - ff->fmt = fimc_capture_try_format(ctx, &pix->width, &pix->height, - NULL, &pix->pixelformat, - FIMC_SD_PAD_SOURCE); - if (!ff->fmt) - return -EINVAL; + ret = __video_try_or_set_format(fimc, f, false, &inp_fmt, &ff->fmt); + if (ret < 0) + return ret; /* Update RGB Alpha control state and value range */ fimc_alpha_ctrl_update(ctx); - /* Try to match format at the host and the sensor */ - if (!fimc->vid_cap.user_subdev_api) { - mf->code = ff->fmt->mbus_code; - mf->width = pix->width; - mf->height = pix->height; - ret = fimc_pipeline_try_format(ctx, mf, &s_fmt, true); - if (ret) - return ret; - - pix->width = mf->width; - pix->height = mf->height; - } - - fimc_adjust_mplane_format(ff->fmt, pix->width, pix->height, pix); - - if (ff->fmt->flags & FMT_FLAGS_COMPRESSED) { - ret = fimc_get_sensor_frame_desc(p->subdevs[IDX_SENSOR], - pix->plane_fmt, ff->fmt->memplanes, - true); - if (ret < 0) - return ret; - } - for (i = 0; i < ff->fmt->memplanes; i++) { ff->bytesperline[i] = pix->plane_fmt[i].bytesperline; ff->payload[i] = pix->plane_fmt[i].sizeimage; @@ -1056,8 +1058,8 @@ static int __fimc_capture_set_format(struct fimc_dev *fimc, fimc_capture_mark_jpeg_xfer(ctx, ff->fmt->color); /* Reset cropping and set format at the camera interface input */ - if (!fimc->vid_cap.user_subdev_api) { - ctx->s_frame.fmt = s_fmt; + if (!vc->user_subdev_api) { + ctx->s_frame.fmt = inp_fmt; set_frame_bounds(&ctx->s_frame, pix->width, pix->height); set_frame_crop(&ctx->s_frame, 0, 0, pix->width, pix->height); } @@ -1069,18 +1071,8 @@ static int fimc_cap_s_fmt_mplane(struct file *file, void *priv, struct v4l2_format *f) { struct fimc_dev *fimc = video_drvdata(file); - int ret; - fimc_md_graph_lock(&fimc->vid_cap.ve); - /* - * The graph is walked within __fimc_capture_set_format() to set - * the format at subdevs thus the graph mutex needs to be held at - * this point. - */ - ret = __fimc_capture_set_format(fimc, f); - - fimc_md_graph_unlock(&fimc->vid_cap.ve); - return ret; + return __fimc_capture_set_format(fimc, f); } static int fimc_cap_enum_input(struct file *file, void *priv, From 0f20956be654cf52a69b9071590faa9c6657b77f Mon Sep 17 00:00:00 2001 From: Sylwester Nawrocki Date: Fri, 31 May 2013 13:47:03 -0300 Subject: [PATCH 0163/1048] [media] exynos4-is: Move __fimc_videoc_querycap() function to the common module Move __fimc_videoc_querycap() function to the common exynos4-is-common.ko module so it don't need to be reimplemented in multiple video node drivers of the exynos4-is. Signed-off-by: Sylwester Nawrocki Signed-off-by: Kyungmin Park Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/exynos4-is/common.c | 12 ++++++++++++ drivers/media/platform/exynos4-is/common.h | 4 ++++ drivers/media/platform/exynos4-is/fimc-core.c | 11 ----------- drivers/media/platform/exynos4-is/fimc-core.h | 2 -- drivers/media/platform/exynos4-is/fimc-m2m.c | 1 + 5 files changed, 17 insertions(+), 13 deletions(-) diff --git a/drivers/media/platform/exynos4-is/common.c b/drivers/media/platform/exynos4-is/common.c index 57f9010cee50..0ec210b4da1d 100644 --- a/drivers/media/platform/exynos4-is/common.c +++ b/drivers/media/platform/exynos4-is/common.c @@ -38,4 +38,16 @@ struct v4l2_subdev *fimc_find_remote_sensor(struct media_entity *entity) } EXPORT_SYMBOL(fimc_find_remote_sensor); +void __fimc_vidioc_querycap(struct device *dev, struct v4l2_capability *cap, + unsigned int caps) +{ + strlcpy(cap->driver, dev->driver->name, sizeof(cap->driver)); + strlcpy(cap->card, dev->driver->name, sizeof(cap->card)); + snprintf(cap->bus_info, sizeof(cap->bus_info), + "platform:%s", dev_name(dev)); + cap->device_caps = caps; + cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS; +} +EXPORT_SYMBOL(__fimc_vidioc_querycap); + MODULE_LICENSE("GPL"); diff --git a/drivers/media/platform/exynos4-is/common.h b/drivers/media/platform/exynos4-is/common.h index 3c398039ba28..75b9c71d9419 100644 --- a/drivers/media/platform/exynos4-is/common.h +++ b/drivers/media/platform/exynos4-is/common.h @@ -6,7 +6,11 @@ * published by the Free Software Foundation. */ +#include +#include #include #include struct v4l2_subdev *fimc_find_remote_sensor(struct media_entity *entity); +void __fimc_vidioc_querycap(struct device *dev, struct v4l2_capability *cap, + unsigned int caps); diff --git a/drivers/media/platform/exynos4-is/fimc-core.c b/drivers/media/platform/exynos4-is/fimc-core.c index 379a5e9d52a7..6489c5160ee8 100644 --- a/drivers/media/platform/exynos4-is/fimc-core.c +++ b/drivers/media/platform/exynos4-is/fimc-core.c @@ -213,17 +213,6 @@ struct fimc_fmt *fimc_get_format(unsigned int index) return &fimc_formats[index]; } -void __fimc_vidioc_querycap(struct device *dev, struct v4l2_capability *cap, - unsigned int caps) -{ - strlcpy(cap->driver, dev->driver->name, sizeof(cap->driver)); - strlcpy(cap->card, dev->driver->name, sizeof(cap->card)); - snprintf(cap->bus_info, sizeof(cap->bus_info), - "platform:%s", dev_name(dev)); - cap->device_caps = caps; - cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS; -} - int fimc_check_scaler_ratio(struct fimc_ctx *ctx, int sw, int sh, int dw, int dh, int rotation) { diff --git a/drivers/media/platform/exynos4-is/fimc-core.h b/drivers/media/platform/exynos4-is/fimc-core.h index c48a79254d83..349c7c01e49a 100644 --- a/drivers/media/platform/exynos4-is/fimc-core.h +++ b/drivers/media/platform/exynos4-is/fimc-core.h @@ -619,8 +619,6 @@ static inline struct fimc_frame *ctx_get_frame(struct fimc_ctx *ctx, /* fimc-core.c */ int fimc_vidioc_enum_fmt_mplane(struct file *file, void *priv, struct v4l2_fmtdesc *f); -void __fimc_vidioc_querycap(struct device *dev, struct v4l2_capability *cap, - unsigned int caps); int fimc_ctrls_create(struct fimc_ctx *ctx); void fimc_ctrls_delete(struct fimc_ctx *ctx); void fimc_ctrls_activate(struct fimc_ctx *ctx, bool active); diff --git a/drivers/media/platform/exynos4-is/fimc-m2m.c b/drivers/media/platform/exynos4-is/fimc-m2m.c index bde1f47f7ed3..8d33b68c76ba 100644 --- a/drivers/media/platform/exynos4-is/fimc-m2m.c +++ b/drivers/media/platform/exynos4-is/fimc-m2m.c @@ -27,6 +27,7 @@ #include #include +#include "common.h" #include "fimc-core.h" #include "fimc-reg.h" #include "media-dev.h" From 4434adff80bf24c1c558a1605599665301185bdb Mon Sep 17 00:00:00 2001 From: Sylwester Nawrocki Date: Fri, 31 May 2013 13:47:04 -0300 Subject: [PATCH 0164/1048] [media] exynos4-is: Add isp_dbg() macro Add a debug trace macro for the FIMC-IS ISP subdev and the ISP video node drivers which are going to be added in subsequent patches. Signed-off-by: Sylwester Nawrocki Signed-off-by: Kyungmin Park Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/exynos4-is/fimc-isp.c | 16 ++++++++-------- drivers/media/platform/exynos4-is/fimc-isp.h | 5 +++++ 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/drivers/media/platform/exynos4-is/fimc-isp.c b/drivers/media/platform/exynos4-is/fimc-isp.c index 0fefb53a5b56..e6b0a4b027a9 100644 --- a/drivers/media/platform/exynos4-is/fimc-isp.c +++ b/drivers/media/platform/exynos4-is/fimc-isp.c @@ -30,8 +30,8 @@ #include "fimc-is-regs.h" #include "fimc-is.h" -static int debug; -module_param_named(debug_isp, debug, int, S_IRUGO | S_IWUSR); +int fimc_isp_debug; +module_param_named(debug_isp, fimc_isp_debug, int, S_IRUGO | S_IWUSR); static const struct fimc_fmt fimc_isp_formats[FIMC_ISP_NUM_FORMATS] = { { @@ -157,8 +157,8 @@ static int fimc_isp_subdev_get_fmt(struct v4l2_subdev *sd, mutex_unlock(&isp->subdev_lock); - v4l2_dbg(1, debug, sd, "%s: pad%d: fmt: 0x%x, %dx%d\n", - __func__, fmt->pad, mf->code, mf->width, mf->height); + isp_dbg(1, sd, "%s: pad%d: fmt: 0x%x, %dx%d\n", __func__, + fmt->pad, mf->code, mf->width, mf->height); return 0; } @@ -191,7 +191,7 @@ static int fimc_isp_subdev_set_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf = &fmt->format; int ret = 0; - v4l2_dbg(1, debug, sd, "%s: pad%d: code: 0x%x, %dx%d\n", + isp_dbg(1, sd, "%s: pad%d: code: 0x%x, %dx%d\n", __func__, fmt->pad, mf->code, mf->width, mf->height); mf->colorspace = V4L2_COLORSPACE_JPEG; @@ -221,7 +221,7 @@ static int fimc_isp_subdev_s_stream(struct v4l2_subdev *sd, int on) struct fimc_is *is = fimc_isp_to_is(isp); int ret; - v4l2_dbg(1, debug, sd, "%s: on: %d\n", __func__, on); + isp_dbg(1, sd, "%s: on: %d\n", __func__, on); if (!test_bit(IS_ST_INIT_DONE, &is->state)) return -EBUSY; @@ -235,8 +235,8 @@ static int fimc_isp_subdev_s_stream(struct v4l2_subdev *sd, int on) return ret; } - v4l2_dbg(1, debug, sd, "changing mode to %d\n", - is->config_index); + isp_dbg(1, sd, "changing mode to %d\n", is->config_index); + ret = fimc_is_itf_mode_change(is); if (ret) return -EINVAL; diff --git a/drivers/media/platform/exynos4-is/fimc-isp.h b/drivers/media/platform/exynos4-is/fimc-isp.h index f5c802cf40f9..756063e77fb8 100644 --- a/drivers/media/platform/exynos4-is/fimc-isp.h +++ b/drivers/media/platform/exynos4-is/fimc-isp.h @@ -26,6 +26,11 @@ #include #include +extern int fimc_isp_debug; + +#define isp_dbg(level, dev, fmt, arg...) \ + v4l2_dbg(level, fimc_isp_debug, dev, fmt, ## arg) + /* FIXME: revisit these constraints */ #define FIMC_ISP_SINK_WIDTH_MIN (16 + 8) #define FIMC_ISP_SINK_HEIGHT_MIN (12 + 8) From 813f5c0ac5ccf7dd9c216a8f7fbe827ca36cb83f Mon Sep 17 00:00:00 2001 From: Sylwester Nawrocki Date: Fri, 31 May 2013 10:37:26 -0300 Subject: [PATCH 0165/1048] [media] media: Change media device link_notify behaviour Currently the media device link_notify callback is invoked before the actual change of state of a link when the link is being enabled, and after the actual change of state when the link is being disabled. This doesn't allow a media device driver to perform any operations on a full graph before a link is disabled, as well as performing any tasks on a modified graph right after a link's state is changed. This patch modifies signature of the link_notify callback. This callback is now called always before and after a link's state change. To distinguish the notifications a 'notification' argument is added to the link_notify callback: MEDIA_DEV_NOTIFY_PRE_LINK_CH indicates notification before link's state change and MEDIA_DEV_NOTIFY_POST_LINK_CH corresponds to a notification after link flags change. [mchehab@redhat.com: whitespace cleanups] Signed-off-by: Sylwester Nawrocki Signed-off-by: Kyungmin Park Acked-by: Laurent Pinchart Acked-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab --- drivers/media/media-entity.c | 18 +++----- drivers/media/platform/exynos4-is/media-dev.c | 18 ++++---- drivers/media/platform/omap3isp/isp.c | 41 +++++++++++-------- include/media/media-device.h | 9 +++- 4 files changed, 47 insertions(+), 39 deletions(-) diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c index 0438209d020a..df72f7d99d80 100644 --- a/drivers/media/media-entity.c +++ b/drivers/media/media-entity.c @@ -496,25 +496,17 @@ int __media_entity_setup_link(struct media_link *link, u32 flags) mdev = source->parent; - if ((flags & MEDIA_LNK_FL_ENABLED) && mdev->link_notify) { - ret = mdev->link_notify(link->source, link->sink, - MEDIA_LNK_FL_ENABLED); + if (mdev->link_notify) { + ret = mdev->link_notify(link, flags, + MEDIA_DEV_NOTIFY_PRE_LINK_CH); if (ret < 0) return ret; } ret = __media_entity_setup_link_notify(link, flags); - if (ret < 0) - goto err; - if (!(flags & MEDIA_LNK_FL_ENABLED) && mdev->link_notify) - mdev->link_notify(link->source, link->sink, 0); - - return 0; - -err: - if ((flags & MEDIA_LNK_FL_ENABLED) && mdev->link_notify) - mdev->link_notify(link->source, link->sink, 0); + if (mdev->link_notify) + mdev->link_notify(link, flags, MEDIA_DEV_NOTIFY_POST_LINK_CH); return ret; } diff --git a/drivers/media/platform/exynos4-is/media-dev.c b/drivers/media/platform/exynos4-is/media-dev.c index b5624931d16d..5298dd6680ae 100644 --- a/drivers/media/platform/exynos4-is/media-dev.c +++ b/drivers/media/platform/exynos4-is/media-dev.c @@ -1287,34 +1287,36 @@ int fimc_md_set_camclk(struct v4l2_subdev *sd, bool on) return __fimc_md_set_camclk(fmd, si, on); } -static int fimc_md_link_notify(struct media_pad *source, - struct media_pad *sink, u32 flags) +static int fimc_md_link_notify(struct media_link *link, u32 flags, + unsigned int notification) { + struct media_entity *sink = link->sink->entity; struct exynos_video_entity *ve; struct video_device *vdev; struct fimc_pipeline *pipeline; int i, ret = 0; - if (media_entity_type(sink->entity) != MEDIA_ENT_T_DEVNODE_V4L) + if (media_entity_type(sink) != MEDIA_ENT_T_DEVNODE_V4L || + notification == MEDIA_DEV_NOTIFY_PRE_LINK_CH) return 0; - vdev = media_entity_to_video_device(sink->entity); + vdev = media_entity_to_video_device(sink); ve = vdev_to_exynos_video_entity(vdev); pipeline = to_fimc_pipeline(ve->pipe); - if (!(flags & MEDIA_LNK_FL_ENABLED) && pipeline->subdevs[IDX_SENSOR]) { - if (sink->entity->use_count > 0) + if (!(link->flags & MEDIA_LNK_FL_ENABLED) && pipeline->subdevs[IDX_SENSOR]) { + if (sink->use_count > 0) ret = __fimc_pipeline_close(ve->pipe); for (i = 0; i < IDX_MAX; i++) pipeline->subdevs[i] = NULL; - } else if (sink->entity->use_count > 0) { + } else if (sink->use_count > 0) { /* * Link activation. Enable power of pipeline elements only if * the pipeline is already in use, i.e. its video node is open. * Recreate the controls destroyed during the link deactivation. */ - ret = __fimc_pipeline_open(ve->pipe, sink->entity, true); + ret = __fimc_pipeline_open(ve->pipe, sink, true); } return ret ? -EPIPE : ret; diff --git a/drivers/media/platform/omap3isp/isp.c b/drivers/media/platform/omap3isp/isp.c index ff5a20afa691..df3a0ec7fd2c 100644 --- a/drivers/media/platform/omap3isp/isp.c +++ b/drivers/media/platform/omap3isp/isp.c @@ -792,9 +792,9 @@ int omap3isp_pipeline_pm_use(struct media_entity *entity, int use) /* * isp_pipeline_link_notify - Link management notification callback - * @source: Pad at the start of the link - * @sink: Pad at the end of the link + * @link: The link * @flags: New link flags that will be applied + * @notification: The link's state change notification type (MEDIA_DEV_NOTIFY_*) * * React to link management on powered pipelines by updating the use count of * all entities in the source and sink sides of the link. Entities are powered @@ -804,29 +804,38 @@ int omap3isp_pipeline_pm_use(struct media_entity *entity, int use) * off is assumed to never fail. This function will not fail for disconnection * events. */ -static int isp_pipeline_link_notify(struct media_pad *source, - struct media_pad *sink, u32 flags) +static int isp_pipeline_link_notify(struct media_link *link, u32 flags, + unsigned int notification) { - int source_use = isp_pipeline_pm_use_count(source->entity); - int sink_use = isp_pipeline_pm_use_count(sink->entity); + struct media_entity *source = link->source->entity; + struct media_entity *sink = link->sink->entity; + int source_use = isp_pipeline_pm_use_count(source); + int sink_use = isp_pipeline_pm_use_count(sink); int ret; - if (!(flags & MEDIA_LNK_FL_ENABLED)) { + if (notification == MEDIA_DEV_NOTIFY_POST_LINK_CH && + !(link->flags & MEDIA_LNK_FL_ENABLED)) { /* Powering off entities is assumed to never fail. */ - isp_pipeline_pm_power(source->entity, -sink_use); - isp_pipeline_pm_power(sink->entity, -source_use); + isp_pipeline_pm_power(source, -sink_use); + isp_pipeline_pm_power(sink, -source_use); return 0; } - ret = isp_pipeline_pm_power(source->entity, sink_use); - if (ret < 0) + if (notification == MEDIA_DEV_NOTIFY_POST_LINK_CH && + (flags & MEDIA_LNK_FL_ENABLED)) { + + ret = isp_pipeline_pm_power(source, sink_use); + if (ret < 0) + return ret; + + ret = isp_pipeline_pm_power(sink, source_use); + if (ret < 0) + isp_pipeline_pm_power(source, -sink_use); + return ret; + } - ret = isp_pipeline_pm_power(sink->entity, source_use); - if (ret < 0) - isp_pipeline_pm_power(source->entity, -sink_use); - - return ret; + return 0; } /* ----------------------------------------------------------------------------- diff --git a/include/media/media-device.h b/include/media/media-device.h index eaade9815bb6..12155a9596c4 100644 --- a/include/media/media-device.h +++ b/include/media/media-device.h @@ -45,6 +45,7 @@ struct device; * @entities: List of registered entities * @lock: Entities list lock * @graph_mutex: Entities graph operation lock + * @link_notify: Link state change notification callback * * This structure represents an abstract high-level media device. It allows easy * access to entities and provides basic media device-level support. The @@ -75,10 +76,14 @@ struct media_device { /* Serializes graph operations. */ struct mutex graph_mutex; - int (*link_notify)(struct media_pad *source, - struct media_pad *sink, u32 flags); + int (*link_notify)(struct media_link *link, u32 flags, + unsigned int notification); }; +/* Supported link_notify @notification values. */ +#define MEDIA_DEV_NOTIFY_PRE_LINK_CH 0 +#define MEDIA_DEV_NOTIFY_POST_LINK_CH 1 + /* media_devnode to media_device */ #define to_media_device(node) container_of(node, struct media_device, devnode) From d3775fa76bed74a46e179c08895fafc968f7292a Mon Sep 17 00:00:00 2001 From: Sylwester Nawrocki Date: Fri, 31 May 2013 10:37:27 -0300 Subject: [PATCH 0166/1048] [media] exynos4-is: Extend link_notify handler to support fimc-is/lite pipelines This patch corrects the link_notify handler to support more complex pipelines, including fimc-lite and fimc-is entities. After the FIMC-IS driver addition the assumptions made in the link_notify callback are no longer valid, e.g. the link between fimc-lite subdev and its video node is not immutable any more and there is more subdevs than just sensor, MIPI-CSIS and FIMC(-LITE). The graph is now walked and for each video node found a media pipeline which ends at this node is disabled/enabled (the subdevs are powered on/off). Signed-off-by: Sylwester Nawrocki Signed-off-by: Kyungmin Park Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/exynos4-is/media-dev.c | 103 ++++++++++++++---- 1 file changed, 81 insertions(+), 22 deletions(-) diff --git a/drivers/media/platform/exynos4-is/media-dev.c b/drivers/media/platform/exynos4-is/media-dev.c index 5298dd6680ae..19f556c5957f 100644 --- a/drivers/media/platform/exynos4-is/media-dev.c +++ b/drivers/media/platform/exynos4-is/media-dev.c @@ -1287,39 +1287,98 @@ int fimc_md_set_camclk(struct v4l2_subdev *sd, bool on) return __fimc_md_set_camclk(fmd, si, on); } -static int fimc_md_link_notify(struct media_link *link, u32 flags, - unsigned int notification) +static int __fimc_md_modify_pipeline(struct media_entity *entity, bool enable) { - struct media_entity *sink = link->sink->entity; struct exynos_video_entity *ve; + struct fimc_pipeline *p; struct video_device *vdev; - struct fimc_pipeline *pipeline; - int i, ret = 0; + int ret; - if (media_entity_type(sink) != MEDIA_ENT_T_DEVNODE_V4L || - notification == MEDIA_DEV_NOTIFY_PRE_LINK_CH) + vdev = media_entity_to_video_device(entity); + if (vdev->entity.use_count == 0) return 0; - vdev = media_entity_to_video_device(sink); ve = vdev_to_exynos_video_entity(vdev); - pipeline = to_fimc_pipeline(ve->pipe); + p = to_fimc_pipeline(ve->pipe); + /* + * Nothing to do if we are disabling the pipeline, some link + * has been disconnected and p->subdevs array is cleared now. + */ + if (!enable && p->subdevs[IDX_SENSOR] == NULL) + return 0; - if (!(link->flags & MEDIA_LNK_FL_ENABLED) && pipeline->subdevs[IDX_SENSOR]) { - if (sink->use_count > 0) - ret = __fimc_pipeline_close(ve->pipe); + if (enable) + ret = __fimc_pipeline_open(ve->pipe, entity, true); + else + ret = __fimc_pipeline_close(ve->pipe); - for (i = 0; i < IDX_MAX; i++) - pipeline->subdevs[i] = NULL; - } else if (sink->use_count > 0) { - /* - * Link activation. Enable power of pipeline elements only if - * the pipeline is already in use, i.e. its video node is open. - * Recreate the controls destroyed during the link deactivation. - */ - ret = __fimc_pipeline_open(ve->pipe, sink, true); + if (ret == 0 && !enable) + memset(p->subdevs, 0, sizeof(p->subdevs)); + + return ret; +} + +/* Locking: called with entity->parent->graph_mutex mutex held. */ +static int __fimc_md_modify_pipelines(struct media_entity *entity, bool enable) +{ + struct media_entity *entity_err = entity; + struct media_entity_graph graph; + int ret; + + /* + * Walk current graph and call the pipeline open/close routine for each + * opened video node that belongs to the graph of entities connected + * through active links. This is needed as we cannot power on/off the + * subdevs in random order. + */ + media_entity_graph_walk_start(&graph, entity); + + while ((entity = media_entity_graph_walk_next(&graph))) { + if (media_entity_type(entity) != MEDIA_ENT_T_DEVNODE) + continue; + + ret = __fimc_md_modify_pipeline(entity, enable); + + if (ret < 0) + goto err; } - return ret ? -EPIPE : ret; + return 0; + err: + media_entity_graph_walk_start(&graph, entity_err); + + while ((entity_err = media_entity_graph_walk_next(&graph))) { + if (media_entity_type(entity_err) != MEDIA_ENT_T_DEVNODE) + continue; + + __fimc_md_modify_pipeline(entity_err, !enable); + + if (entity_err == entity) + break; + } + + return ret; +} + +static int fimc_md_link_notify(struct media_link *link, unsigned int flags, + unsigned int notification) +{ + struct media_entity *sink = link->sink->entity; + int ret = 0; + + /* Before link disconnection */ + if (notification == MEDIA_DEV_NOTIFY_PRE_LINK_CH) { + if (!(flags & MEDIA_LNK_FL_ENABLED)) + ret = __fimc_md_modify_pipelines(sink, false); + else + ; /* TODO: Link state change validation */ + /* After link activation */ + } else if (notification == MEDIA_DEV_NOTIFY_POST_LINK_CH && + (link->flags & MEDIA_LNK_FL_ENABLED)) { + ret = __fimc_md_modify_pipelines(sink, true); + } + + return ret ? -EPIPE : 0; } static ssize_t fimc_md_sysfs_show(struct device *dev, From 984b248f6bdcd0b319e84e43f0be532f989c709a Mon Sep 17 00:00:00 2001 From: Sylwester Nawrocki Date: Mon, 10 Jun 2013 08:54:15 -0300 Subject: [PATCH 0167/1048] [media] s5p-tv: Don't ignore return value of regulator_enable() in sii9234_drv.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch fixes following compilation warning: CC [M] drivers/media/platform/s5p-tv/sii9234_drv.o drivers/media/platform/s5p-tv/sii9234_drv.c: In function ‘sii9234_runtime_resume’: drivers/media/platform/s5p-tv/sii9234_drv.c:252:18: warning: ignoring return value of ‘regulator_enable’, declared with attribute warn_unused_result Signed-off-by: Sylwester Nawrocki Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/s5p-tv/sii9234_drv.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/s5p-tv/sii9234_drv.c b/drivers/media/platform/s5p-tv/sii9234_drv.c index 39b77d24b9c2..3dd762e5b67e 100644 --- a/drivers/media/platform/s5p-tv/sii9234_drv.c +++ b/drivers/media/platform/s5p-tv/sii9234_drv.c @@ -249,7 +249,9 @@ static int sii9234_runtime_resume(struct device *dev) int ret; dev_info(dev, "resume start\n"); - regulator_enable(ctx->power); + ret = regulator_enable(ctx->power); + if (ret < 0) + return ret; ret = sii9234_reset(ctx); if (ret) From d285837eaf5e363ac0ab1bf6deb110e007325949 Mon Sep 17 00:00:00 2001 From: Sylwester Nawrocki Date: Mon, 10 Jun 2013 08:54:30 -0300 Subject: [PATCH 0168/1048] [media] s5p-tv: Do not ignore regulator/clk API return values in sdo_drv.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch fixes following compilation warning: drivers/media/platform/s5p-tv/sdo_drv.c: In function ‘sdo_runtime_resume’: drivers/media/platform/s5p-tv/sdo_drv.c:268:18: warning: ignoring return value of ‘regulator_enable’, declared with attribute warn_unused_result drivers/media/platform/s5p-tv/sdo_drv.c:269:18: warning: ignoring return value of ‘regulator_enable’, declared with attribute warn_unused_result Signed-off-by: Sylwester Nawrocki Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/s5p-tv/sdo_drv.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/drivers/media/platform/s5p-tv/sdo_drv.c b/drivers/media/platform/s5p-tv/sdo_drv.c index ab6f9ef89423..0afa90f0f6ab 100644 --- a/drivers/media/platform/s5p-tv/sdo_drv.c +++ b/drivers/media/platform/s5p-tv/sdo_drv.c @@ -262,11 +262,21 @@ static int sdo_runtime_resume(struct device *dev) { struct v4l2_subdev *sd = dev_get_drvdata(dev); struct sdo_device *sdev = sd_to_sdev(sd); + int ret; dev_info(dev, "resume\n"); - clk_enable(sdev->sclk_dac); - regulator_enable(sdev->vdac); - regulator_enable(sdev->vdet); + + ret = clk_enable(sdev->sclk_dac); + if (ret < 0) + return ret; + + ret = regulator_enable(sdev->vdac); + if (ret < 0) + goto dac_clk_dis; + + ret = regulator_enable(sdev->vdet); + if (ret < 0) + goto vdac_r_dis; /* software reset */ sdo_write_mask(sdev, SDO_CLKCON, ~0, SDO_TVOUT_SW_RESET); @@ -285,6 +295,12 @@ static int sdo_runtime_resume(struct device *dev) SDO_COMPENSATION_CVBS_COMP_OFF); sdo_reg_debug(sdev); return 0; + +vdac_r_dis: + regulator_disable(sdev->vdac); +dac_clk_dis: + clk_disable(sdev->sclk_dac); + return ret; } static const struct dev_pm_ops sdo_pm_ops = { From 62d54876c511628daed2246753e2fe348da022f1 Mon Sep 17 00:00:00 2001 From: Sylwester Nawrocki Date: Mon, 10 Jun 2013 08:54:48 -0300 Subject: [PATCH 0169/1048] [media] s5p-tv: Don't ignore return value of regulator_bulk_enable() in hdmi_drv.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch fixes following compilation warning: CC [M] drivers/media/platform/s5p-tv/hdmi_drv.o drivers/media/platform/s5p-tv/hdmi_drv.c: In function ‘hdmi_resource_poweron’: drivers/media/platform/s5p-tv/hdmi_drv.c:583:23: warning: ignoring return value of ‘regulator_bulk_enable’, declared with attribute warn_unused_result Signed-off-by: Sylwester Nawrocki Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/s5p-tv/hdmi_drv.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/drivers/media/platform/s5p-tv/hdmi_drv.c b/drivers/media/platform/s5p-tv/hdmi_drv.c index cd525f193240..1b34c3629858 100644 --- a/drivers/media/platform/s5p-tv/hdmi_drv.c +++ b/drivers/media/platform/s5p-tv/hdmi_drv.c @@ -576,16 +576,22 @@ static int hdmi_s_stream(struct v4l2_subdev *sd, int enable) return hdmi_streamoff(hdev); } -static void hdmi_resource_poweron(struct hdmi_resources *res) +static int hdmi_resource_poweron(struct hdmi_resources *res) { + int ret; + /* turn HDMI power on */ - regulator_bulk_enable(res->regul_count, res->regul_bulk); + ret = regulator_bulk_enable(res->regul_count, res->regul_bulk); + if (ret < 0) + return ret; /* power-on hdmi physical interface */ clk_enable(res->hdmiphy); /* use VPP as parent clock; HDMIPHY is not working yet */ clk_set_parent(res->sclk_hdmi, res->sclk_pixel); /* turn clocks on */ clk_enable(res->sclk_hdmi); + + return 0; } static void hdmi_resource_poweroff(struct hdmi_resources *res) @@ -728,11 +734,13 @@ static int hdmi_runtime_resume(struct device *dev) { struct v4l2_subdev *sd = dev_get_drvdata(dev); struct hdmi_device *hdev = sd_to_hdmi_dev(sd); - int ret = 0; + int ret; dev_dbg(dev, "%s\n", __func__); - hdmi_resource_poweron(&hdev->res); + ret = hdmi_resource_poweron(&hdev->res); + if (ret < 0) + return ret; /* starting MHL */ ret = v4l2_subdev_call(hdev->mhl_sd, core, s_power, 1); From 36b51146539c42306fd6ab1ff30cfc5a2d13c706 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roberto=20Alc=C3=A2ntara?= Date: Tue, 21 May 2013 16:32:30 -0300 Subject: [PATCH 0170/1048] [media] smscoreapi: memory leak fix Ensure release_firmware is called if kmalloc fails. [mchehab@redhat.com: patch unmangled and converted from -p2 to -p1] Signed-off-by: Roberto Alcantara Signed-off-by: Mauro Carvalho Chehab --- drivers/media/common/siano/smscoreapi.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/drivers/media/common/siano/smscoreapi.c b/drivers/media/common/siano/smscoreapi.c index dbe9b4d9b799..a142f7942a01 100644 --- a/drivers/media/common/siano/smscoreapi.c +++ b/drivers/media/common/siano/smscoreapi.c @@ -1173,15 +1173,16 @@ static int smscore_load_firmware_from_file(struct smscore_device_t *coredev, GFP_KERNEL | GFP_DMA); if (!fw_buf) { sms_err("failed to allocate firmware buffer"); - return -ENOMEM; - } - memcpy(fw_buf, fw->data, fw->size); - fw_buf_size = fw->size; + rc = -ENOMEM; + } else { + memcpy(fw_buf, fw->data, fw->size); + fw_buf_size = fw->size; - rc = (coredev->device_flags & SMS_DEVICE_FAMILY2) ? - smscore_load_firmware_family2(coredev, fw_buf, fw_buf_size) - : loadfirmware_handler(coredev->context, fw_buf, - fw_buf_size); + rc = (coredev->device_flags & SMS_DEVICE_FAMILY2) ? + smscore_load_firmware_family2(coredev, fw_buf, fw_buf_size) + : loadfirmware_handler(coredev->context, fw_buf, + fw_buf_size); + } kfree(fw_buf); release_firmware(fw); From ab6e134a48a58b111f28dfb5c8440a56d6be10c5 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Wed, 29 May 2013 03:55:13 -0300 Subject: [PATCH 0171/1048] [media] hdpvr: fix querystd 'unknown format' return If no format has been detected, then querystd should return V4L2_STD_UNKNOWN, not V4L2_STD_ALL. Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/usb/hdpvr/hdpvr-video.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/usb/hdpvr/hdpvr-video.c b/drivers/media/usb/hdpvr/hdpvr-video.c index 2d02b490756b..81018c478f44 100644 --- a/drivers/media/usb/hdpvr/hdpvr-video.c +++ b/drivers/media/usb/hdpvr/hdpvr-video.c @@ -613,7 +613,7 @@ static int vidioc_querystd(struct file *file, void *_fh, v4l2_std_id *a) struct hdpvr_fh *fh = _fh; int ret; - *a = V4L2_STD_ALL; + *a = V4L2_STD_UNKNOWN; if (dev->options.video_input == HDPVR_COMPONENT) return fh->legacy_mode ? 0 : -ENODATA; ret = get_video_info(dev, &vid_info); From 79f10b625e5eff93c8fad54ba345e5f35feb8461 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Wed, 29 May 2013 03:55:14 -0300 Subject: [PATCH 0172/1048] [media] hdpvr: code cleanup Remove an unnecessary 'else' and invert a condition which makes the code more readable. Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/usb/hdpvr/hdpvr-video.c | 66 +++++++++++++-------------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/drivers/media/usb/hdpvr/hdpvr-video.c b/drivers/media/usb/hdpvr/hdpvr-video.c index 81018c478f44..e9471059056e 100644 --- a/drivers/media/usb/hdpvr/hdpvr-video.c +++ b/drivers/media/usb/hdpvr/hdpvr-video.c @@ -281,43 +281,43 @@ static int hdpvr_start_streaming(struct hdpvr_device *dev) if (dev->status == STATUS_STREAMING) return 0; - else if (dev->status != STATUS_IDLE) + if (dev->status != STATUS_IDLE) return -EAGAIN; ret = get_video_info(dev, &vidinf); - - if (!ret) { - v4l2_dbg(MSG_BUFFER, hdpvr_debug, &dev->v4l2_dev, - "video signal: %dx%d@%dhz\n", vidinf.width, - vidinf.height, vidinf.fps); - - /* start streaming 2 request */ - ret = usb_control_msg(dev->udev, - usb_sndctrlpipe(dev->udev, 0), - 0xb8, 0x38, 0x1, 0, NULL, 0, 8000); - v4l2_dbg(MSG_BUFFER, hdpvr_debug, &dev->v4l2_dev, - "encoder start control request returned %d\n", ret); - if (ret < 0) - return ret; - - ret = hdpvr_config_call(dev, CTRL_START_STREAMING_VALUE, 0x00); - if (ret) - return ret; - - dev->status = STATUS_STREAMING; - - INIT_WORK(&dev->worker, hdpvr_transmit_buffers); - queue_work(dev->workqueue, &dev->worker); - - v4l2_dbg(MSG_BUFFER, hdpvr_debug, &dev->v4l2_dev, - "streaming started\n"); - - return 0; + if (ret) { + msleep(250); + v4l2_dbg(MSG_INFO, hdpvr_debug, &dev->v4l2_dev, + "no video signal at input %d\n", dev->options.video_input); + return -EAGAIN; } - msleep(250); - v4l2_dbg(MSG_INFO, hdpvr_debug, &dev->v4l2_dev, - "no video signal at input %d\n", dev->options.video_input); - return -EAGAIN; + + v4l2_dbg(MSG_BUFFER, hdpvr_debug, &dev->v4l2_dev, + "video signal: %dx%d@%dhz\n", vidinf.width, + vidinf.height, vidinf.fps); + + /* start streaming 2 request */ + ret = usb_control_msg(dev->udev, + usb_sndctrlpipe(dev->udev, 0), + 0xb8, 0x38, 0x1, 0, NULL, 0, 8000); + v4l2_dbg(MSG_BUFFER, hdpvr_debug, &dev->v4l2_dev, + "encoder start control request returned %d\n", ret); + if (ret < 0) + return ret; + + ret = hdpvr_config_call(dev, CTRL_START_STREAMING_VALUE, 0x00); + if (ret) + return ret; + + dev->status = STATUS_STREAMING; + + INIT_WORK(&dev->worker, hdpvr_transmit_buffers); + queue_work(dev->workqueue, &dev->worker); + + v4l2_dbg(MSG_BUFFER, hdpvr_debug, &dev->v4l2_dev, + "streaming started\n"); + + return 0; } From 5f454d82e5958e59c16580b9b4531f4bbc7231f7 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Wed, 29 May 2013 03:55:15 -0300 Subject: [PATCH 0173/1048] [media] hdpvr: improve error handling get_video_info() should never return EFAULT, instead it should return the low-level usb_control_msg() error. Add a valid field to the hdpvr_video_info struct so the driver can easily check if a valid format was detected. Whenever get_video_info is called and it returns an error (e.g. usb_control_msg failed), then return that error to userspace as well. Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/usb/hdpvr/hdpvr-control.c | 21 +++++++++------------ drivers/media/usb/hdpvr/hdpvr-video.c | 18 +++++++++++------- drivers/media/usb/hdpvr/hdpvr.h | 1 + 3 files changed, 21 insertions(+), 19 deletions(-) diff --git a/drivers/media/usb/hdpvr/hdpvr-control.c b/drivers/media/usb/hdpvr/hdpvr-control.c index df6bcb524d80..6053661dc04b 100644 --- a/drivers/media/usb/hdpvr/hdpvr-control.c +++ b/drivers/media/usb/hdpvr/hdpvr-control.c @@ -49,6 +49,7 @@ int get_video_info(struct hdpvr_device *dev, struct hdpvr_video_info *vidinf) { int ret; + vidinf->valid = false; mutex_lock(&dev->usbc_mutex); ret = usb_control_msg(dev->udev, usb_rcvctrlpipe(dev->udev, 0), @@ -56,11 +57,6 @@ int get_video_info(struct hdpvr_device *dev, struct hdpvr_video_info *vidinf) 0x1400, 0x0003, dev->usbc_buf, 5, 1000); - if (ret == 5) { - vidinf->width = dev->usbc_buf[1] << 8 | dev->usbc_buf[0]; - vidinf->height = dev->usbc_buf[3] << 8 | dev->usbc_buf[2]; - vidinf->fps = dev->usbc_buf[4]; - } #ifdef HDPVR_DEBUG if (hdpvr_debug & MSG_INFO) { @@ -73,14 +69,15 @@ int get_video_info(struct hdpvr_device *dev, struct hdpvr_video_info *vidinf) #endif mutex_unlock(&dev->usbc_mutex); - if ((ret > 0 && ret != 5) ||/* fail if unexpected byte count returned */ - !vidinf->width || /* preserve original behavior - */ - !vidinf->height || /* fail if no signal is detected */ - !vidinf->fps) { - ret = -EFAULT; - } + if (ret < 0) + return ret; - return ret < 0 ? ret : 0; + vidinf->width = dev->usbc_buf[1] << 8 | dev->usbc_buf[0]; + vidinf->height = dev->usbc_buf[3] << 8 | dev->usbc_buf[2]; + vidinf->fps = dev->usbc_buf[4]; + vidinf->valid = vidinf->width && vidinf->height && vidinf->fps; + + return 0; } int get_input_lines_info(struct hdpvr_device *dev) diff --git a/drivers/media/usb/hdpvr/hdpvr-video.c b/drivers/media/usb/hdpvr/hdpvr-video.c index e9471059056e..4f8567aa99d8 100644 --- a/drivers/media/usb/hdpvr/hdpvr-video.c +++ b/drivers/media/usb/hdpvr/hdpvr-video.c @@ -285,7 +285,10 @@ static int hdpvr_start_streaming(struct hdpvr_device *dev) return -EAGAIN; ret = get_video_info(dev, &vidinf); - if (ret) { + if (ret < 0) + return ret; + + if (!vidinf.valid) { msleep(250); v4l2_dbg(MSG_INFO, hdpvr_debug, &dev->v4l2_dev, "no video signal at input %d\n", dev->options.video_input); @@ -617,15 +620,12 @@ static int vidioc_querystd(struct file *file, void *_fh, v4l2_std_id *a) if (dev->options.video_input == HDPVR_COMPONENT) return fh->legacy_mode ? 0 : -ENODATA; ret = get_video_info(dev, &vid_info); - if (ret) - return 0; - if (vid_info.width == 720 && + if (vid_info.valid && vid_info.width == 720 && (vid_info.height == 480 || vid_info.height == 576)) { *a = (vid_info.height == 480) ? V4L2_STD_525_60 : V4L2_STD_625_50; } - - return 0; + return ret; } static int vidioc_s_dv_timings(struct file *file, void *_fh, @@ -679,6 +679,8 @@ static int vidioc_query_dv_timings(struct file *file, void *_fh, return -ENODATA; ret = get_video_info(dev, &vid_info); if (ret) + return ret; + if (!vid_info.valid) return -ENOLCK; interlaced = vid_info.fps <= 30; for (i = 0; i < ARRAY_SIZE(hdpvr_dv_timings); i++) { @@ -1008,7 +1010,9 @@ static int vidioc_g_fmt_vid_cap(struct file *file, void *_fh, struct hdpvr_video_info vid_info; ret = get_video_info(dev, &vid_info); - if (ret) + if (ret < 0) + return ret; + if (!vid_info.valid) return -EFAULT; f->fmt.pix.width = vid_info.width; f->fmt.pix.height = vid_info.height; diff --git a/drivers/media/usb/hdpvr/hdpvr.h b/drivers/media/usb/hdpvr/hdpvr.h index 808ea7a0efe5..dc685d44cb3e 100644 --- a/drivers/media/usb/hdpvr/hdpvr.h +++ b/drivers/media/usb/hdpvr/hdpvr.h @@ -154,6 +154,7 @@ struct hdpvr_video_info { u16 width; u16 height; u8 fps; + bool valid; }; enum { From cccb83f7a1848a8b2dda6480c2dc26e80710e50b Mon Sep 17 00:00:00 2001 From: Vladimir Barinov Date: Wed, 29 May 2013 14:50:57 -0300 Subject: [PATCH 0174/1048] [media] adv7180: add more subdev video ops Add subdev video ops for ADV7180 video decoder. This makes decoder usable on the soc-camera drivers. [Sergei: renamed adv7180_try_mbus_fmt() to adv7180_mbus_fmt().] Signed-off-by: Vladimir Barinov Signed-off-by: Sergei Shtylyov Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/i2c/adv7180.c | 46 +++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/drivers/media/i2c/adv7180.c b/drivers/media/i2c/adv7180.c index 04ee1d4a4b93..11f13a83a64b 100644 --- a/drivers/media/i2c/adv7180.c +++ b/drivers/media/i2c/adv7180.c @@ -1,6 +1,8 @@ /* * adv7180.c Analog Devices ADV7180 video decoder driver * Copyright (c) 2009 Intel Corporation + * Copyright (C) 2013 Cogent Embedded, Inc. + * Copyright (C) 2013 Renesas Solutions Corp. * * 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 @@ -397,10 +399,54 @@ static void adv7180_exit_controls(struct adv7180_state *state) v4l2_ctrl_handler_free(&state->ctrl_hdl); } +static int adv7180_enum_mbus_fmt(struct v4l2_subdev *sd, unsigned int index, + enum v4l2_mbus_pixelcode *code) +{ + if (index > 0) + return -EINVAL; + + *code = V4L2_MBUS_FMT_YUYV8_2X8; + + return 0; +} + +static int adv7180_mbus_fmt(struct v4l2_subdev *sd, + struct v4l2_mbus_framefmt *fmt) +{ + struct adv7180_state *state = to_state(sd); + + fmt->code = V4L2_MBUS_FMT_YUYV8_2X8; + fmt->colorspace = V4L2_COLORSPACE_SMPTE170M; + fmt->field = V4L2_FIELD_INTERLACED; + fmt->width = 720; + fmt->height = state->curr_norm & V4L2_STD_525_60 ? 480 : 576; + + return 0; +} + +static int adv7180_g_mbus_config(struct v4l2_subdev *sd, + struct v4l2_mbus_config *cfg) +{ + /* + * The ADV7180 sensor supports BT.601/656 output modes. + * The BT.656 is default and not yet configurable by s/w. + */ + cfg->flags = V4L2_MBUS_MASTER | V4L2_MBUS_PCLK_SAMPLE_RISING | + V4L2_MBUS_DATA_ACTIVE_HIGH; + cfg->type = V4L2_MBUS_BT656; + + return 0; +} + static const struct v4l2_subdev_video_ops adv7180_video_ops = { .querystd = adv7180_querystd, .g_input_status = adv7180_g_input_status, .s_routing = adv7180_s_routing, + .enum_mbus_fmt = adv7180_enum_mbus_fmt, + .try_mbus_fmt = adv7180_mbus_fmt, + .g_mbus_fmt = adv7180_mbus_fmt, + .s_mbus_fmt = adv7180_mbus_fmt, + .g_mbus_config = adv7180_g_mbus_config, }; static const struct v4l2_subdev_core_ops adv7180_core_ops = { From ed3e12d2b03f756f09433f08c4606cdc61ffbc7c Mon Sep 17 00:00:00 2001 From: Vladimir Barinov Date: Wed, 29 May 2013 14:52:28 -0300 Subject: [PATCH 0175/1048] [media] ML86V7667: new video decoder driver Add OKI Semiconductor ML86V7667 video decoder driver. [Sergei: added v4l2_device_unregister_subdev() call to the error cleanup path of ml86v7667_probe(), renamed ml86v7667_try_mbus_fmt() to ml86v7667_mbus_fmt(), killed v4l2_chip_match_i2c_client() checks in the [gs]_register() methods, fixed the prototype of the s_register() method, did some cleanup.] Signed-off-by: Vladimir Barinov Signed-off-by: Sergei Shtylyov Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/i2c/Kconfig | 9 + drivers/media/i2c/Makefile | 1 + drivers/media/i2c/ml86v7667.c | 431 ++++++++++++++++++++++++++++++++++ 3 files changed, 441 insertions(+) create mode 100644 drivers/media/i2c/ml86v7667.c diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig index f981d50a2a8c..9c04ddb2101e 100644 --- a/drivers/media/i2c/Kconfig +++ b/drivers/media/i2c/Kconfig @@ -245,6 +245,15 @@ config VIDEO_KS0127 To compile this driver as a module, choose M here: the module will be called ks0127. +config VIDEO_ML86V7667 + tristate "OKI ML86V7667 video decoder" + depends on VIDEO_V4L2 && I2C + ---help--- + Support for the OKI Semiconductor ML86V7667 video decoder. + + To compile this driver as a module, choose M here: the + module will be called ml86v7667. + config VIDEO_SAA7110 tristate "Philips SAA7110 video decoder" depends on VIDEO_V4L2 && I2C diff --git a/drivers/media/i2c/Makefile b/drivers/media/i2c/Makefile index 720f42d9d9f4..b40ea089861a 100644 --- a/drivers/media/i2c/Makefile +++ b/drivers/media/i2c/Makefile @@ -70,3 +70,4 @@ obj-$(CONFIG_VIDEO_AS3645A) += as3645a.o obj-$(CONFIG_VIDEO_SMIAPP_PLL) += smiapp-pll.o obj-$(CONFIG_VIDEO_AK881X) += ak881x.o obj-$(CONFIG_VIDEO_IR_I2C) += ir-kbd-i2c.o +obj-$(CONFIG_VIDEO_ML86V7667) += ml86v7667.o diff --git a/drivers/media/i2c/ml86v7667.c b/drivers/media/i2c/ml86v7667.c new file mode 100644 index 000000000000..0f256d3cc62b --- /dev/null +++ b/drivers/media/i2c/ml86v7667.c @@ -0,0 +1,431 @@ +/* + * OKI Semiconductor ML86V7667 video decoder driver + * + * Author: Vladimir Barinov + * Copyright (C) 2013 Cogent Embedded, Inc. + * Copyright (C) 2013 Renesas Solutions Corp. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define DRV_NAME "ml86v7667" + +/* Subaddresses */ +#define MRA_REG 0x00 /* Mode Register A */ +#define MRC_REG 0x02 /* Mode Register C */ +#define LUMC_REG 0x0C /* Luminance Control */ +#define CLC_REG 0x10 /* Contrast level control */ +#define SSEPL_REG 0x11 /* Sync separation level */ +#define CHRCA_REG 0x12 /* Chrominance Control A */ +#define ACCC_REG 0x14 /* ACC Loop filter & Chrominance control */ +#define ACCRC_REG 0x15 /* ACC Reference level control */ +#define HUE_REG 0x16 /* Hue control */ +#define ADC2_REG 0x1F /* ADC Register 2 */ +#define PLLR1_REG 0x20 /* PLL Register 1 */ +#define STATUS_REG 0x2C /* STATUS Register */ + +/* Mode Register A register bits */ +#define MRA_OUTPUT_MODE_MASK (3 << 6) +#define MRA_ITUR_BT601 (1 << 6) +#define MRA_ITUR_BT656 (0 << 6) +#define MRA_INPUT_MODE_MASK (7 << 3) +#define MRA_PAL_BT601 (4 << 3) +#define MRA_NTSC_BT601 (0 << 3) +#define MRA_REGISTER_MODE (1 << 0) + +/* Mode Register C register bits */ +#define MRC_AUTOSELECT (1 << 7) + +/* Luminance Control register bits */ +#define LUMC_ONOFF_SHIFT 7 +#define LUMC_ONOFF_MASK (1 << 7) + +/* Contrast level control register bits */ +#define CLC_CONTRAST_ONOFF (1 << 7) +#define CLC_CONTRAST_MASK 0x0F + +/* Sync separation level register bits */ +#define SSEPL_LUMINANCE_ONOFF (1 << 7) +#define SSEPL_LUMINANCE_MASK 0x7F + +/* Chrominance Control A register bits */ +#define CHRCA_MODE_SHIFT 6 +#define CHRCA_MODE_MASK (1 << 6) + +/* ACC Loop filter & Chrominance control register bits */ +#define ACCC_CHROMA_CR_SHIFT 3 +#define ACCC_CHROMA_CR_MASK (7 << 3) +#define ACCC_CHROMA_CB_SHIFT 0 +#define ACCC_CHROMA_CB_MASK (7 << 0) + +/* ACC Reference level control register bits */ +#define ACCRC_CHROMA_MASK 0xfc +#define ACCRC_CHROMA_SHIFT 2 + +/* ADC Register 2 register bits */ +#define ADC2_CLAMP_VOLTAGE_MASK (7 << 1) +#define ADC2_CLAMP_VOLTAGE(n) ((n & 7) << 1) + +/* PLL Register 1 register bits */ +#define PLLR1_FIXED_CLOCK (1 << 7) + +/* STATUS Register register bits */ +#define STATUS_HLOCK_DETECT (1 << 3) +#define STATUS_NTSCPAL (1 << 2) + +struct ml86v7667_priv { + struct v4l2_subdev sd; + struct v4l2_ctrl_handler hdl; + v4l2_std_id std; +}; + +static inline struct ml86v7667_priv *to_ml86v7667(struct v4l2_subdev *subdev) +{ + return container_of(subdev, struct ml86v7667_priv, sd); +} + +static inline struct v4l2_subdev *to_sd(struct v4l2_ctrl *ctrl) +{ + return &container_of(ctrl->handler, struct ml86v7667_priv, hdl)->sd; +} + +static int ml86v7667_mask_set(struct i2c_client *client, const u8 reg, + const u8 mask, const u8 data) +{ + int val = i2c_smbus_read_byte_data(client, reg); + if (val < 0) + return val; + + val = (val & ~mask) | (data & mask); + return i2c_smbus_write_byte_data(client, reg, val); +} + +static int ml86v7667_s_ctrl(struct v4l2_ctrl *ctrl) +{ + struct v4l2_subdev *sd = to_sd(ctrl); + struct i2c_client *client = v4l2_get_subdevdata(sd); + int ret = 0; + + switch (ctrl->id) { + case V4L2_CID_BRIGHTNESS: + ret = ml86v7667_mask_set(client, SSEPL_REG, + SSEPL_LUMINANCE_MASK, ctrl->val); + break; + case V4L2_CID_CONTRAST: + ret = ml86v7667_mask_set(client, CLC_REG, + CLC_CONTRAST_MASK, ctrl->val); + break; + case V4L2_CID_CHROMA_GAIN: + ret = ml86v7667_mask_set(client, ACCRC_REG, ACCRC_CHROMA_MASK, + ctrl->val << ACCRC_CHROMA_SHIFT); + break; + case V4L2_CID_HUE: + ret = ml86v7667_mask_set(client, HUE_REG, ~0, ctrl->val); + break; + case V4L2_CID_RED_BALANCE: + ret = ml86v7667_mask_set(client, ACCC_REG, + ACCC_CHROMA_CR_MASK, + ctrl->val << ACCC_CHROMA_CR_SHIFT); + break; + case V4L2_CID_BLUE_BALANCE: + ret = ml86v7667_mask_set(client, ACCC_REG, + ACCC_CHROMA_CB_MASK, + ctrl->val << ACCC_CHROMA_CB_SHIFT); + break; + case V4L2_CID_SHARPNESS: + ret = ml86v7667_mask_set(client, LUMC_REG, + LUMC_ONOFF_MASK, + ctrl->val << LUMC_ONOFF_SHIFT); + break; + case V4L2_CID_COLOR_KILLER: + ret = ml86v7667_mask_set(client, CHRCA_REG, + CHRCA_MODE_MASK, + ctrl->val << CHRCA_MODE_SHIFT); + break; + } + + return 0; +} + +static int ml86v7667_querystd(struct v4l2_subdev *sd, v4l2_std_id *std) +{ + struct i2c_client *client = v4l2_get_subdevdata(sd); + int status; + + status = i2c_smbus_read_byte_data(client, STATUS_REG); + if (status < 0) + return status; + + if (!(status & STATUS_HLOCK_DETECT)) + return V4L2_STD_UNKNOWN; + + *std = status & STATUS_NTSCPAL ? V4L2_STD_625_50 : V4L2_STD_525_60; + + return 0; +} + +static int ml86v7667_g_input_status(struct v4l2_subdev *sd, u32 *status) +{ + struct i2c_client *client = v4l2_get_subdevdata(sd); + int status_reg; + + status_reg = i2c_smbus_read_byte_data(client, STATUS_REG); + if (status_reg < 0) + return status_reg; + + *status = status_reg & STATUS_HLOCK_DETECT ? 0 : V4L2_IN_ST_NO_SIGNAL; + + return 0; +} + +static int ml86v7667_enum_mbus_fmt(struct v4l2_subdev *sd, unsigned int index, + enum v4l2_mbus_pixelcode *code) +{ + if (index > 0) + return -EINVAL; + + *code = V4L2_MBUS_FMT_YUYV8_2X8; + + return 0; +} + +static int ml86v7667_mbus_fmt(struct v4l2_subdev *sd, + struct v4l2_mbus_framefmt *fmt) +{ + struct ml86v7667_priv *priv = to_ml86v7667(sd); + + fmt->code = V4L2_MBUS_FMT_YUYV8_2X8; + fmt->colorspace = V4L2_COLORSPACE_SMPTE170M; + fmt->field = V4L2_FIELD_INTERLACED; + fmt->width = 720; + fmt->height = priv->std & V4L2_STD_525_60 ? 480 : 576; + + return 0; +} + +static int ml86v7667_g_mbus_config(struct v4l2_subdev *sd, + struct v4l2_mbus_config *cfg) +{ + cfg->flags = V4L2_MBUS_MASTER | V4L2_MBUS_PCLK_SAMPLE_RISING | + V4L2_MBUS_DATA_ACTIVE_HIGH; + cfg->type = V4L2_MBUS_BT656; + + return 0; +} + +static int ml86v7667_s_std(struct v4l2_subdev *sd, v4l2_std_id std) +{ + struct ml86v7667_priv *priv = to_ml86v7667(sd); + struct i2c_client *client = v4l2_get_subdevdata(&priv->sd); + int ret; + u8 mode; + + /* PAL/NTSC ITU-R BT.601 input mode */ + mode = std & V4L2_STD_525_60 ? MRA_NTSC_BT601 : MRA_PAL_BT601; + ret = ml86v7667_mask_set(client, MRA_REG, MRA_INPUT_MODE_MASK, mode); + if (ret < 0) + return ret; + + priv->std = std; + + return 0; +} + +#ifdef CONFIG_VIDEO_ADV_DEBUG +static int ml86v7667_g_register(struct v4l2_subdev *sd, + struct v4l2_dbg_register *reg) +{ + struct i2c_client *client = v4l2_get_subdevdata(sd); + int ret; + + ret = i2c_smbus_read_byte_data(client, (u8)reg->reg); + if (ret < 0) + return ret; + + reg->val = ret; + reg->size = sizeof(u8); + + return 0; +} + +static int ml86v7667_s_register(struct v4l2_subdev *sd, + const struct v4l2_dbg_register *reg) +{ + struct i2c_client *client = v4l2_get_subdevdata(sd); + + return i2c_smbus_write_byte_data(client, (u8)reg->reg, (u8)reg->val); +} +#endif + +static const struct v4l2_ctrl_ops ml86v7667_ctrl_ops = { + .s_ctrl = ml86v7667_s_ctrl, +}; + +static struct v4l2_subdev_video_ops ml86v7667_subdev_video_ops = { + .querystd = ml86v7667_querystd, + .g_input_status = ml86v7667_g_input_status, + .enum_mbus_fmt = ml86v7667_enum_mbus_fmt, + .try_mbus_fmt = ml86v7667_mbus_fmt, + .g_mbus_fmt = ml86v7667_mbus_fmt, + .s_mbus_fmt = ml86v7667_mbus_fmt, + .g_mbus_config = ml86v7667_g_mbus_config, +}; + +static struct v4l2_subdev_core_ops ml86v7667_subdev_core_ops = { + .s_std = ml86v7667_s_std, +#ifdef CONFIG_VIDEO_ADV_DEBUG + .g_register = ml86v7667_g_register, + .s_register = ml86v7667_s_register, +#endif +}; + +static struct v4l2_subdev_ops ml86v7667_subdev_ops = { + .core = &ml86v7667_subdev_core_ops, + .video = &ml86v7667_subdev_video_ops, +}; + +static int ml86v7667_init(struct ml86v7667_priv *priv) +{ + struct i2c_client *client = v4l2_get_subdevdata(&priv->sd); + int val; + int ret; + + /* BT.656-4 output mode, register mode */ + ret = ml86v7667_mask_set(client, MRA_REG, + MRA_OUTPUT_MODE_MASK | MRA_REGISTER_MODE, + MRA_ITUR_BT656 | MRA_REGISTER_MODE); + + /* PLL circuit fixed clock, 32MHz */ + ret |= ml86v7667_mask_set(client, PLLR1_REG, PLLR1_FIXED_CLOCK, + PLLR1_FIXED_CLOCK); + + /* ADC2 clamping voltage maximum */ + ret |= ml86v7667_mask_set(client, ADC2_REG, ADC2_CLAMP_VOLTAGE_MASK, + ADC2_CLAMP_VOLTAGE(7)); + + /* enable luminance function */ + ret |= ml86v7667_mask_set(client, SSEPL_REG, SSEPL_LUMINANCE_ONOFF, + SSEPL_LUMINANCE_ONOFF); + + /* enable contrast function */ + ret |= ml86v7667_mask_set(client, CLC_REG, CLC_CONTRAST_ONOFF, 0); + + /* + * PAL/NTSC autodetection is enabled after reset, + * set the autodetected std in manual std mode and + * disable autodetection + */ + val = i2c_smbus_read_byte_data(client, STATUS_REG); + if (val < 0) + return val; + + priv->std = val & STATUS_NTSCPAL ? V4L2_STD_625_50 : V4L2_STD_525_60; + ret |= ml86v7667_mask_set(client, MRC_REG, MRC_AUTOSELECT, 0); + + val = priv->std & V4L2_STD_525_60 ? MRA_NTSC_BT601 : MRA_PAL_BT601; + ret |= ml86v7667_mask_set(client, MRA_REG, MRA_INPUT_MODE_MASK, val); + + return ret; +} + +static int ml86v7667_probe(struct i2c_client *client, + const struct i2c_device_id *did) +{ + struct ml86v7667_priv *priv; + int ret; + + if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) + return -EIO; + + priv = devm_kzalloc(&client->dev, sizeof(*priv), GFP_KERNEL); + if (!priv) + return -ENOMEM; + + v4l2_i2c_subdev_init(&priv->sd, client, &ml86v7667_subdev_ops); + + v4l2_ctrl_handler_init(&priv->hdl, 8); + v4l2_ctrl_new_std(&priv->hdl, &ml86v7667_ctrl_ops, + V4L2_CID_BRIGHTNESS, -64, 63, 1, 0); + v4l2_ctrl_new_std(&priv->hdl, &ml86v7667_ctrl_ops, + V4L2_CID_CONTRAST, -8, 7, 1, 0); + v4l2_ctrl_new_std(&priv->hdl, &ml86v7667_ctrl_ops, + V4L2_CID_CHROMA_GAIN, -32, 31, 1, 0); + v4l2_ctrl_new_std(&priv->hdl, &ml86v7667_ctrl_ops, + V4L2_CID_HUE, -128, 127, 1, 0); + v4l2_ctrl_new_std(&priv->hdl, &ml86v7667_ctrl_ops, + V4L2_CID_RED_BALANCE, -4, 3, 1, 0); + v4l2_ctrl_new_std(&priv->hdl, &ml86v7667_ctrl_ops, + V4L2_CID_BLUE_BALANCE, -4, 3, 1, 0); + v4l2_ctrl_new_std(&priv->hdl, &ml86v7667_ctrl_ops, + V4L2_CID_SHARPNESS, 0, 1, 1, 0); + v4l2_ctrl_new_std(&priv->hdl, &ml86v7667_ctrl_ops, + V4L2_CID_COLOR_KILLER, 0, 1, 1, 0); + priv->sd.ctrl_handler = &priv->hdl; + + ret = priv->hdl.error; + if (ret) + goto cleanup; + + v4l2_ctrl_handler_setup(&priv->hdl); + + ret = ml86v7667_init(priv); + if (ret) + goto cleanup; + + v4l_info(client, "chip found @ 0x%02x (%s)\n", + client->addr, client->adapter->name); + return 0; + +cleanup: + v4l2_ctrl_handler_free(&priv->hdl); + v4l2_device_unregister_subdev(&priv->sd); + v4l_err(client, "failed to probe @ 0x%02x (%s)\n", + client->addr, client->adapter->name); + return ret; +} + +static int ml86v7667_remove(struct i2c_client *client) +{ + struct v4l2_subdev *sd = i2c_get_clientdata(client); + struct ml86v7667_priv *priv = to_ml86v7667(sd); + + v4l2_ctrl_handler_free(&priv->hdl); + v4l2_device_unregister_subdev(&priv->sd); + + return 0; +} + +static const struct i2c_device_id ml86v7667_id[] = { + {DRV_NAME, 0}, + {}, +}; +MODULE_DEVICE_TABLE(i2c, ml86v7667_id); + +static struct i2c_driver ml86v7667_i2c_driver = { + .driver = { + .name = DRV_NAME, + .owner = THIS_MODULE, + }, + .probe = ml86v7667_probe, + .remove = ml86v7667_remove, + .id_table = ml86v7667_id, +}; + +module_i2c_driver(ml86v7667_i2c_driver); + +MODULE_DESCRIPTION("OKI Semiconductor ML86V7667 video decoder driver"); +MODULE_AUTHOR("Vladimir Barinov"); +MODULE_LICENSE("GPL"); From d13ac96f576ef23670d9e65f8f3771b17fd6dce1 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Fri, 31 May 2013 05:15:17 -0300 Subject: [PATCH 0176/1048] [media] ml86v7667: fix the querystd implementation The *std should be set to V4L2_STD_UNKNOWN, not the function's return code. Also, *std should be ANDed with 525_60 or 625_50. Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/i2c/ml86v7667.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/media/i2c/ml86v7667.c b/drivers/media/i2c/ml86v7667.c index 0f256d3cc62b..cd9f86e743b2 100644 --- a/drivers/media/i2c/ml86v7667.c +++ b/drivers/media/i2c/ml86v7667.c @@ -169,10 +169,10 @@ static int ml86v7667_querystd(struct v4l2_subdev *sd, v4l2_std_id *std) if (status < 0) return status; - if (!(status & STATUS_HLOCK_DETECT)) - return V4L2_STD_UNKNOWN; - - *std = status & STATUS_NTSCPAL ? V4L2_STD_625_50 : V4L2_STD_525_60; + if (status & STATUS_HLOCK_DETECT) + *std &= status & STATUS_NTSCPAL ? V4L2_STD_625_50 : V4L2_STD_525_60; + else + *std = V4L2_STD_UNKNOWN; return 0; } From 542d30f2e00eb10a3e548fb0d0f47646e51c3736 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Sun, 2 Jun 2013 19:41:45 -0300 Subject: [PATCH 0177/1048] [media] radio-keene: set initial frequency The device was never set to the initial frequency. Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/radio/radio-keene.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/media/radio/radio-keene.c b/drivers/media/radio/radio-keene.c index 4c9ae767fb31..99da3d4f8d95 100644 --- a/drivers/media/radio/radio-keene.c +++ b/drivers/media/radio/radio-keene.c @@ -93,7 +93,7 @@ static int keene_cmd_main(struct keene_device *radio, unsigned freq, bool play) /* If bit 4 is set, then tune to the frequency. If bit 3 is set, then unmute; if bit 2 is set, then mute. If bit 1 is set, then enter idle mode; if bit 0 is set, - then enter transit mode. + then enter transmit mode. */ radio->buffer[5] = (radio->muted ? 4 : 8) | (play ? 1 : 2) | (freq ? 0x10 : 0); @@ -350,7 +350,6 @@ static int usb_keene_probe(struct usb_interface *intf, radio->pa = 118; radio->tx = 0x32; radio->stereo = true; - radio->curfreq = 95.16 * FREQ_MUL; if (hdl->error) { retval = hdl->error; @@ -383,6 +382,8 @@ static int usb_keene_probe(struct usb_interface *intf, video_set_drvdata(&radio->vdev, radio); set_bit(V4L2_FL_USE_FH_PRIO, &radio->vdev.flags); + keene_cmd_main(radio, 95.16 * FREQ_MUL, false); + retval = video_register_device(&radio->vdev, VFL_TYPE_RADIO, -1); if (retval < 0) { dev_err(&intf->dev, "could not register video device\n"); From 4b9a4a666c271bcb10469f61515b3c518ccc668f Mon Sep 17 00:00:00 2001 From: Antti Palosaari Date: Sun, 2 Jun 2013 19:41:46 -0300 Subject: [PATCH 0178/1048] [media] radio-keene: add delay in order to settle hardware It was found by trial and error testing that at least 11 ms delay is needed before first I/O, otherwise device will skip given command. Signed-off-by: Antti Palosaari Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/radio/radio-keene.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/media/radio/radio-keene.c b/drivers/media/radio/radio-keene.c index 99da3d4f8d95..21db23b196be 100644 --- a/drivers/media/radio/radio-keene.c +++ b/drivers/media/radio/radio-keene.c @@ -382,6 +382,8 @@ static int usb_keene_probe(struct usb_interface *intf, video_set_drvdata(&radio->vdev, radio); set_bit(V4L2_FL_USE_FH_PRIO, &radio->vdev.flags); + /* at least 11ms is needed in order to settle hardware */ + msleep(20); keene_cmd_main(radio, 95.16 * FREQ_MUL, false); retval = video_register_device(&radio->vdev, VFL_TYPE_RADIO, -1); From 68f9f8ae98a580fa710f9652b01b9690e224fb1f Mon Sep 17 00:00:00 2001 From: "Lad, Prabhakar" Date: Sat, 25 May 2013 13:39:33 -0300 Subject: [PATCH 0179/1048] [media] ARM: davinci: dm365 evm: remove init_enable from ths7303 pdata Remove init_enable from ths7303 pdata as it is being dropped from ths7303_platform_data. The purpose of init_enable was that the device should start streaming video immediately but instead the bridge drivers should call s_stream explicitly for such devices. This is in fact what happens for the dm365, so setting init_enable here never made sense in the first place. Signed-off-by: Lad, Prabhakar [hans.verkuil@cisco.com: improve the commit comment] Acked-by: Sekhar Nori Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- arch/arm/mach-davinci/board-dm365-evm.c | 1 - 1 file changed, 1 deletion(-) diff --git a/arch/arm/mach-davinci/board-dm365-evm.c b/arch/arm/mach-davinci/board-dm365-evm.c index fd38c8d22e3c..afbc439f11d4 100644 --- a/arch/arm/mach-davinci/board-dm365-evm.c +++ b/arch/arm/mach-davinci/board-dm365-evm.c @@ -509,7 +509,6 @@ struct ths7303_platform_data ths7303_pdata = { .ch_1 = 3, .ch_2 = 3, .ch_3 = 3, - .init_enable = 1, }; static struct amp_config_info vpbe_amp = { From d97ada97ae7b29a83bc04fc3a05ef7b75c88e335 Mon Sep 17 00:00:00 2001 From: "Lad, Prabhakar" Date: Sat, 25 May 2013 13:39:34 -0300 Subject: [PATCH 0180/1048] [media] media: i2c: ths7303: remove init_enable option from pdata This patch removes init_enable option from pdata, the init_enable was intended that the device should start streaming video immediately but ideally the bridge drivers should call s_stream explicitly for such devices to start video. Signed-off-by: Lad, Prabhakar Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/i2c/ths7303.c | 4 +--- include/media/ths7303.h | 2 -- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/media/i2c/ths7303.c b/drivers/media/i2c/ths7303.c index 65853eea09a1..8cddcd0cfa09 100644 --- a/drivers/media/i2c/ths7303.c +++ b/drivers/media/i2c/ths7303.c @@ -356,9 +356,7 @@ static int ths7303_setup(struct v4l2_subdev *sd) int ret; u8 mask; - state->stream_on = pdata->init_enable; - - mask = state->stream_on ? 0xff : 0xf8; + mask = 0xf8; ret = ths7303_write(sd, THS7303_CHANNEL_1, pdata->ch_1 & mask); if (ret) diff --git a/include/media/ths7303.h b/include/media/ths7303.h index 980ec51d574d..a7b49297da82 100644 --- a/include/media/ths7303.h +++ b/include/media/ths7303.h @@ -30,13 +30,11 @@ * @ch_1: Bias value for channel one. * @ch_2: Bias value for channel two. * @ch_3: Bias value for channel three. - * @init_enable: initalize on init. */ struct ths7303_platform_data { u8 ch_1; u8 ch_2; u8 ch_3; - u8 init_enable; }; #endif From 8524ce558a0111762efa1a6b5ba9ce5e092b4707 Mon Sep 17 00:00:00 2001 From: "Lad, Prabhakar" Date: Sat, 25 May 2013 13:39:35 -0300 Subject: [PATCH 0181/1048] [media] media: i2c: ths7303: remove unnecessary function ths7303_setup() the ths7303_setup() was doing the same thing as ths7303_setval() except that ths7303_setval() sets it to some particular mode. This patch removes ths7303_setup() function and calls ths7303_setval() in the probe setting the device to 480I_576I filter mode in the probe. Signed-off-by: Lad, Prabhakar Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/i2c/ths7303.c | 31 ++++--------------------------- 1 file changed, 4 insertions(+), 27 deletions(-) diff --git a/drivers/media/i2c/ths7303.c b/drivers/media/i2c/ths7303.c index 8cddcd0cfa09..af06187c74f8 100644 --- a/drivers/media/i2c/ths7303.c +++ b/drivers/media/i2c/ths7303.c @@ -349,30 +349,6 @@ static const struct v4l2_subdev_ops ths7303_ops = { .video = &ths7303_video_ops, }; -static int ths7303_setup(struct v4l2_subdev *sd) -{ - struct ths7303_state *state = to_state(sd); - struct ths7303_platform_data *pdata = &state->pdata; - int ret; - u8 mask; - - mask = 0xf8; - - ret = ths7303_write(sd, THS7303_CHANNEL_1, pdata->ch_1 & mask); - if (ret) - return ret; - - ret = ths7303_write(sd, THS7303_CHANNEL_2, pdata->ch_2 & mask); - if (ret) - return ret; - - ret = ths7303_write(sd, THS7303_CHANNEL_3, pdata->ch_3 & mask); - if (ret) - return ret; - - return 0; -} - static int ths7303_probe(struct i2c_client *client, const struct i2c_device_id *id) { @@ -402,9 +378,10 @@ static int ths7303_probe(struct i2c_client *client, /* store the driver data to differntiate the chip */ state->driver_data = (int)id->driver_data; - if (ths7303_setup(sd) < 0) { - v4l_err(client, "init failed\n"); - return -EIO; + /* set to default 480I_576I filter mode */ + if (ths7303_setval(sd, THS7303_FILTER_MODE_480I_576I) < 0) { + v4l_err(client, "Setting to 480I_576I filter mode failed!\n"); + return -EINVAL; } return 0; From dd8c393b3c39f7ebd9ad69ce50cc836773d512b6 Mon Sep 17 00:00:00 2001 From: "Lad, Prabhakar" Date: Sat, 25 May 2013 13:39:36 -0300 Subject: [PATCH 0182/1048] [media] media: i2c: ths7303: make the pdata as a constant pointer generally the pdata needs to be a constant pointer in the device state structure. This patch makes the pdata as a constant pointer and alongside returns -EINVAL when pdata is NULL. Signed-off-by: Lad, Prabhakar Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/i2c/ths7303.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/media/i2c/ths7303.c b/drivers/media/i2c/ths7303.c index af06187c74f8..b954195cfbe7 100644 --- a/drivers/media/i2c/ths7303.c +++ b/drivers/media/i2c/ths7303.c @@ -35,7 +35,7 @@ struct ths7303_state { struct v4l2_subdev sd; - struct ths7303_platform_data pdata; + const struct ths7303_platform_data *pdata; struct v4l2_bt_timings bt; int std_id; int stream_on; @@ -89,7 +89,7 @@ int ths7303_setval(struct v4l2_subdev *sd, enum ths7303_filter_mode mode) { struct i2c_client *client = v4l2_get_subdevdata(sd); struct ths7303_state *state = to_state(sd); - struct ths7303_platform_data *pdata = &state->pdata; + const struct ths7303_platform_data *pdata = state->pdata; u8 val, sel = 0; int err, disable = 0; @@ -356,6 +356,11 @@ static int ths7303_probe(struct i2c_client *client, struct ths7303_state *state; struct v4l2_subdev *sd; + if (pdata == NULL) { + dev_err(&client->dev, "No platform data\n"); + return -EINVAL; + } + if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) return -ENODEV; @@ -367,11 +372,7 @@ static int ths7303_probe(struct i2c_client *client, if (!state) return -ENOMEM; - if (!pdata) - v4l_warn(client, "No platform data, using default data!\n"); - else - state->pdata = *pdata; - + state->pdata = pdata; sd = &state->sd; v4l2_i2c_subdev_init(sd, client, &ths7303_ops); From b378758658d91656b864170ad896f45269c22e2f Mon Sep 17 00:00:00 2001 From: Ralf Baechle Date: Tue, 11 Jun 2013 23:10:49 +0200 Subject: [PATCH 0183/1048] MIPS: Kconfig: Remove extranous help keyword. Signed-off-by: Ralf Baechle --- arch/mips/Kconfig | 1 - 1 file changed, 1 deletion(-) diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig index 7a58ab933b20..49f98bf9e89d 100644 --- a/arch/mips/Kconfig +++ b/arch/mips/Kconfig @@ -1030,7 +1030,6 @@ config CPU_BIG_ENDIAN config CPU_LITTLE_ENDIAN bool "Little endian" depends on SYS_SUPPORTS_LITTLE_ENDIAN - help endchoice From b8121f0f2fd9668ac4290bd969b664a4c1ca9ad5 Mon Sep 17 00:00:00 2001 From: Ralf Baechle Date: Wed, 12 Jun 2013 19:05:05 +0200 Subject: [PATCH 0184/1048] MIPS: : Don't reference CONFIG_* symbols. Signed-off-by: Ralf Baechle --- arch/mips/include/uapi/asm/fcntl.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/arch/mips/include/uapi/asm/fcntl.h b/arch/mips/include/uapi/asm/fcntl.h index 0bda78f70e1e..6e9e74648f98 100644 --- a/arch/mips/include/uapi/asm/fcntl.h +++ b/arch/mips/include/uapi/asm/fcntl.h @@ -8,6 +8,7 @@ #ifndef _ASM_FCNTL_H #define _ASM_FCNTL_H +#include #define O_APPEND 0x0008 #define O_DSYNC 0x0010 /* used to be O_SYNC, see below */ @@ -55,7 +56,8 @@ * contain all the same fields as struct flock. */ -#ifdef CONFIG_32BIT +#if _MIPS_SIM != _MIPS_SIM_ABI64 + #include struct flock { @@ -70,7 +72,7 @@ struct flock { #define HAVE_ARCH_STRUCT_FLOCK -#endif /* CONFIG_32BIT */ +#endif /* _MIPS_SIM == _MIPS_SIM_ABI32 */ #include From 191b79b0883cb0e604ba63fb3f85cf50ecfc9dc3 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Wed, 29 May 2013 06:59:34 -0300 Subject: [PATCH 0185/1048] [media] v4l2-ioctl: dbg_g/s_register: only match BRIDGE and SUBDEV types Drop support for V4L2_CHIP_MATCH_I2C_DRIVER/ADDR and V4L2_CHIP_MATCH_AC97 types. The following patches will remove support for those in the drivers as well. This means that bridge drivers no longer have to check for the match.type field in their g/s_register implementations. Only if they also implement g_chip_info do they still have to check the match.addr field, otherwise the core will check for that as well. Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/v4l2-core/v4l2-ioctl.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c index f81bda1a48ec..60b8c259da96 100644 --- a/drivers/media/v4l2-core/v4l2-ioctl.c +++ b/drivers/media/v4l2-core/v4l2-ioctl.c @@ -1807,7 +1807,8 @@ static int v4l_dbg_g_register(const struct v4l2_ioctl_ops *ops, return v4l2_subdev_call(sd, core, g_register, p); return -EINVAL; } - if (ops->vidioc_g_register) + if (ops->vidioc_g_register && p->match.type == V4L2_CHIP_MATCH_BRIDGE && + (ops->vidioc_g_chip_info || p->match.addr == 0)) return ops->vidioc_g_register(file, fh, p); return -EINVAL; #else @@ -1834,7 +1835,8 @@ static int v4l_dbg_s_register(const struct v4l2_ioctl_ops *ops, return v4l2_subdev_call(sd, core, s_register, p); return -EINVAL; } - if (ops->vidioc_s_register) + if (ops->vidioc_s_register && p->match.type == V4L2_CHIP_MATCH_BRIDGE && + (ops->vidioc_g_chip_info || p->match.addr == 0)) return ops->vidioc_s_register(file, fh, p); return -EINVAL; #else From e05eb3f8c1125405692bb0c41a13b560bc7f464d Mon Sep 17 00:00:00 2001 From: Ralf Baechle Date: Wed, 12 Jun 2013 10:54:11 +0200 Subject: [PATCH 0186/1048] MIPS: Kconfig: Move ZONE_DMA to a more appropriate place. Signed-off-by: Ralf Baechle --- arch/mips/Kconfig | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig index 87ddac9477fa..f17ba1ea7a47 100644 --- a/arch/mips/Kconfig +++ b/arch/mips/Kconfig @@ -46,9 +46,6 @@ config MIPS menu "Machine selection" -config ZONE_DMA - bool - choice prompt "System type" default SGI_IP22 @@ -2464,6 +2461,9 @@ config I8253 select CLKEVT_I8253 select MIPS_EXTERNAL_TIMER +config ZONE_DMA + bool + config ZONE_DMA32 bool From 0cecddecd3d0f4e2d9499ad2f226969e82910e79 Mon Sep 17 00:00:00 2001 From: Ralf Baechle Date: Tue, 11 Jun 2013 23:10:49 +0200 Subject: [PATCH 0187/1048] MIPS: Kconfig: Remove extranous help keyword. Signed-off-by: Ralf Baechle --- arch/mips/Kconfig | 1 - 1 file changed, 1 deletion(-) diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig index f17ba1ea7a47..a46b0a2f8f0f 100644 --- a/arch/mips/Kconfig +++ b/arch/mips/Kconfig @@ -1013,7 +1013,6 @@ config CPU_BIG_ENDIAN config CPU_LITTLE_ENDIAN bool "Little endian" depends on SYS_SUPPORTS_LITTLE_ENDIAN - help endchoice From 4954a9a211f1863e3ca3958fd56ad06e1bddc22d Mon Sep 17 00:00:00 2001 From: Jayachandran C Date: Mon, 10 Jun 2013 06:28:08 +0000 Subject: [PATCH 0188/1048] MIPS: Support SWIOTLB in default dma operations Provide a default implementation of phys_to_dma and dma_to_phys in mach-generic/dma_coherence.h. If CONFIG_NEED_SG_DMA_LENGTH is defined, the dma_length field in struct scatterlist is used. Set this up in mips_dma_map_sg so that the default mips DMA ops can be used when SWIOTLB is enabled. Signed-off-by: Jayachandran C Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/5409/ Signed-off-by: Ralf Baechle --- arch/mips/include/asm/mach-generic/dma-coherence.h | 12 ++++++++++++ arch/mips/mm/dma-default.c | 3 +++ 2 files changed, 15 insertions(+) diff --git a/arch/mips/include/asm/mach-generic/dma-coherence.h b/arch/mips/include/asm/mach-generic/dma-coherence.h index fe23034aaf72..74cb99257d5b 100644 --- a/arch/mips/include/asm/mach-generic/dma-coherence.h +++ b/arch/mips/include/asm/mach-generic/dma-coherence.h @@ -66,4 +66,16 @@ static inline int plat_device_is_coherent(struct device *dev) #endif } +#ifdef CONFIG_SWIOTLB +static inline dma_addr_t phys_to_dma(struct device *dev, phys_addr_t paddr) +{ + return paddr; +} + +static inline phys_addr_t dma_to_phys(struct device *dev, dma_addr_t daddr) +{ + return daddr; +} +#endif + #endif /* __ASM_MACH_GENERIC_DMA_COHERENCE_H */ diff --git a/arch/mips/mm/dma-default.c b/arch/mips/mm/dma-default.c index caf92ecb37d6..aaccf1c10699 100644 --- a/arch/mips/mm/dma-default.c +++ b/arch/mips/mm/dma-default.c @@ -246,6 +246,9 @@ static int mips_dma_map_sg(struct device *dev, struct scatterlist *sg, if (!plat_device_is_coherent(dev)) __dma_sync(sg_page(sg), sg->offset, sg->length, direction); +#ifdef CONFIG_NEED_SG_DMA_LENGTH + sg->dma_length = sg->length; +#endif sg->dma_address = plat_map_dma_mem_page(dev, sg_page(sg)) + sg->offset; } From 79f8511c83f13689913f54d2f189297c226ec064 Mon Sep 17 00:00:00 2001 From: Ganesan Ramalingam Date: Mon, 10 Jun 2013 06:28:09 +0000 Subject: [PATCH 0189/1048] MIPS: Netlogic: SWIOTLB dma ops for 32-bit DMA Add SWIOTLB config option and related files to Netlogic platform. Some XLP SoC components like the SD/MMC interface cannot do DMA beyond 32-bit physical address. The SD/MMC driver can use memory outside this range for IO, to support this we have to add bounce buffers implemented by SWIOTLB. Signed-off-by: Jayachandran C Cc: linux-mips@linux-mips.org Cc: Ganesan Ramalingam Patchwork: https://patchwork.linux-mips.org/patch/5410/ Signed-off-by: Ralf Baechle --- arch/mips/include/asm/netlogic/common.h | 3 + arch/mips/netlogic/Kconfig | 11 +++ arch/mips/netlogic/common/Makefile | 1 + arch/mips/netlogic/common/nlm-dma.c | 107 ++++++++++++++++++++++++ 4 files changed, 122 insertions(+) create mode 100644 arch/mips/netlogic/common/nlm-dma.c diff --git a/arch/mips/include/asm/netlogic/common.h b/arch/mips/include/asm/netlogic/common.h index aef560a51a7e..70351b95ef88 100644 --- a/arch/mips/include/asm/netlogic/common.h +++ b/arch/mips/include/asm/netlogic/common.h @@ -76,6 +76,9 @@ void nlm_node_init(int node); extern struct plat_smp_ops nlm_smp_ops; extern char nlm_reset_entry[], nlm_reset_entry_end[]; +/* SWIOTLB */ +extern struct dma_map_ops nlm_swiotlb_dma_ops; + extern unsigned int nlm_threads_per_core; extern cpumask_t nlm_cpumask; diff --git a/arch/mips/netlogic/Kconfig b/arch/mips/netlogic/Kconfig index e0873a31ebaa..2447bf97d35a 100644 --- a/arch/mips/netlogic/Kconfig +++ b/arch/mips/netlogic/Kconfig @@ -51,4 +51,15 @@ endif config NLM_COMMON bool +config IOMMU_HELPER + bool + +config NEED_SG_DMA_LENGTH + bool + +config SWIOTLB + def_bool y + select NEED_SG_DMA_LENGTH + select IOMMU_HELPER + endif diff --git a/arch/mips/netlogic/common/Makefile b/arch/mips/netlogic/common/Makefile index 291372a086f5..b29549741e05 100644 --- a/arch/mips/netlogic/common/Makefile +++ b/arch/mips/netlogic/common/Makefile @@ -1,3 +1,4 @@ obj-y += irq.o time.o +obj-y += nlm-dma.o obj-$(CONFIG_SMP) += smp.o smpboot.o obj-$(CONFIG_EARLY_PRINTK) += earlycons.o diff --git a/arch/mips/netlogic/common/nlm-dma.c b/arch/mips/netlogic/common/nlm-dma.c new file mode 100644 index 000000000000..f3d4ae87abc7 --- /dev/null +++ b/arch/mips/netlogic/common/nlm-dma.c @@ -0,0 +1,107 @@ +/* +* Copyright (C) 2003-2013 Broadcom Corporation +* All Rights Reserved + * + * This software is available to you under a choice of one of two + * licenses. You may choose to be licensed under the terms of the GNU + * General Public License (GPL) Version 2, available from the file + * COPYING in the main directory of this source tree, or the Broadcom + * license below: + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY BROADCOM ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL BROADCOM OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +static char *nlm_swiotlb; + +static void *nlm_dma_alloc_coherent(struct device *dev, size_t size, + dma_addr_t *dma_handle, gfp_t gfp, struct dma_attrs *attrs) +{ + void *ret; + + if (dma_alloc_from_coherent(dev, size, dma_handle, &ret)) + return ret; + + /* ignore region specifiers */ + gfp &= ~(__GFP_DMA | __GFP_DMA32 | __GFP_HIGHMEM); + +#ifdef CONFIG_ZONE_DMA32 + if (dev->coherent_dma_mask <= DMA_BIT_MASK(32)) + gfp |= __GFP_DMA32; +#endif + + /* Don't invoke OOM killer */ + gfp |= __GFP_NORETRY; + + return swiotlb_alloc_coherent(dev, size, dma_handle, gfp); +} + +static void nlm_dma_free_coherent(struct device *dev, size_t size, + void *vaddr, dma_addr_t dma_handle, struct dma_attrs *attrs) +{ + int order = get_order(size); + + if (dma_release_from_coherent(dev, order, vaddr)) + return; + + swiotlb_free_coherent(dev, size, vaddr, dma_handle); +} + +struct dma_map_ops nlm_swiotlb_dma_ops = { + .alloc = nlm_dma_alloc_coherent, + .free = nlm_dma_free_coherent, + .map_page = swiotlb_map_page, + .unmap_page = swiotlb_unmap_page, + .map_sg = swiotlb_map_sg_attrs, + .unmap_sg = swiotlb_unmap_sg_attrs, + .sync_single_for_cpu = swiotlb_sync_single_for_cpu, + .sync_single_for_device = swiotlb_sync_single_for_device, + .sync_sg_for_cpu = swiotlb_sync_sg_for_cpu, + .sync_sg_for_device = swiotlb_sync_sg_for_device, + .mapping_error = swiotlb_dma_mapping_error, + .dma_supported = swiotlb_dma_supported +}; + +void __init plat_swiotlb_setup(void) +{ + size_t swiotlbsize; + unsigned long swiotlb_nslabs; + + swiotlbsize = 1 << 20; /* 1 MB for now */ + swiotlb_nslabs = swiotlbsize >> IO_TLB_SHIFT; + swiotlb_nslabs = ALIGN(swiotlb_nslabs, IO_TLB_SEGSIZE); + swiotlbsize = swiotlb_nslabs << IO_TLB_SHIFT; + + nlm_swiotlb = alloc_bootmem_low_pages(swiotlbsize); + swiotlb_init_with_tbl(nlm_swiotlb, swiotlb_nslabs, 1); +} From 2c952e06e4f57716109b609956eda28c900faac0 Mon Sep 17 00:00:00 2001 From: Jayachandran C Date: Mon, 10 Jun 2013 06:30:00 +0000 Subject: [PATCH 0190/1048] MIPS: Move cop2 save/restore to switch_to() Move the common code for saving and restoring platform specific COP2 registers to switch_to(). This will make supporting new platforms (like Netlogic XLP) easier. The platform specific COP2 definitions are to be specified in asm/processor.h and in asm/cop2.h. Signed-off-by: Jayachandran C Cc: linux-mips@linux-mips.org Cc: ddaney.cavm@gmail.com Patchwork: https://patchwork.linux-mips.org/patch/5411/ Signed-off-by: Ralf Baechle --- arch/mips/include/asm/cop2.h | 19 +++++++++++++++++++ arch/mips/include/asm/processor.h | 18 +++++++----------- arch/mips/include/asm/switch_to.h | 19 ++++++++++++++++++- arch/mips/kernel/octeon_switch.S | 27 --------------------------- 4 files changed, 44 insertions(+), 39 deletions(-) diff --git a/arch/mips/include/asm/cop2.h b/arch/mips/include/asm/cop2.h index 3532e2c5f098..b17f38ee1ed4 100644 --- a/arch/mips/include/asm/cop2.h +++ b/arch/mips/include/asm/cop2.h @@ -11,6 +11,25 @@ #include +#if defined(CONFIG_CPU_CAVIUM_OCTEON) + +extern void octeon_cop2_save(struct octeon_cop2_state *); +extern void octeon_cop2_restore(struct octeon_cop2_state *); + +#define cop2_save(r) octeon_cop2_save(r) +#define cop2_restore(r) octeon_cop2_restore(r) + +#define cop2_present 1 +#define cop2_lazy_restore 1 + +#else + +#define cop2_present 0 +#define cop2_lazy_restore 0 +#define cop2_save(r) +#define cop2_restore(r) +#endif + enum cu2_ops { CU2_EXCEPTION, CU2_LWC2_OP, diff --git a/arch/mips/include/asm/processor.h b/arch/mips/include/asm/processor.h index 1470b7b68b0e..7c637a461ced 100644 --- a/arch/mips/include/asm/processor.h +++ b/arch/mips/include/asm/processor.h @@ -137,7 +137,7 @@ union mips_watch_reg_state { struct mips3264_watch_reg_state mips3264; }; -#ifdef CONFIG_CPU_CAVIUM_OCTEON +#if defined(CONFIG_CPU_CAVIUM_OCTEON) struct octeon_cop2_state { /* DMFC2 rt, 0x0201 */ @@ -182,13 +182,16 @@ struct octeon_cop2_state { /* DMFC2 rt, 0x025A; DMFC2 rt, 0x025B - Pass2 */ unsigned long cop2_gfm_result[2]; }; -#define INIT_OCTEON_COP2 {0,} +#define COP2_INIT \ + .cp2 = {0,}, struct octeon_cvmseg_state { unsigned long cvmseg[CONFIG_CAVIUM_OCTEON_CVMSEG_SIZE] [cpu_dcache_line_size() / sizeof(unsigned long)]; }; +#else +#define COP2_INIT #endif typedef struct { @@ -245,13 +248,6 @@ struct thread_struct { #define FPAFF_INIT #endif /* CONFIG_MIPS_MT_FPAFF */ -#ifdef CONFIG_CPU_CAVIUM_OCTEON -#define OCTEON_INIT \ - .cp2 = INIT_OCTEON_COP2, -#else -#define OCTEON_INIT -#endif /* CONFIG_CPU_CAVIUM_OCTEON */ - #define INIT_THREAD { \ /* \ * Saved main processor registers \ @@ -300,9 +296,9 @@ struct thread_struct { .cp0_baduaddr = 0, \ .error_code = 0, \ /* \ - * Cavium Octeon specifics (null if not Octeon) \ + * Platform specific cop2 registers(null if no COP2) \ */ \ - OCTEON_INIT \ + COP2_INIT \ } struct task_struct; diff --git a/arch/mips/include/asm/switch_to.h b/arch/mips/include/asm/switch_to.h index fd16bcb6c311..eb0af15ac656 100644 --- a/arch/mips/include/asm/switch_to.h +++ b/arch/mips/include/asm/switch_to.h @@ -15,6 +15,7 @@ #include #include #include +#include struct task_struct; @@ -66,10 +67,18 @@ do { \ #define switch_to(prev, next, last) \ do { \ - u32 __usedfpu; \ + u32 __usedfpu, __c0_stat; \ __mips_mt_fpaff_switch_to(prev); \ if (cpu_has_dsp) \ __save_dsp(prev); \ + if (cop2_present && (KSTK_STATUS(prev) & ST0_CU2)) { \ + if (cop2_lazy_restore) \ + KSTK_STATUS(prev) &= ~ST0_CU2; \ + __c0_stat = read_c0_status(); \ + write_c0_status(__c0_stat | ST0_CU2); \ + cop2_save(&prev->thread.cp2); \ + write_c0_status(__c0_stat & ~ST0_CU2); \ + } \ __clear_software_ll_bit(); \ __usedfpu = test_and_clear_tsk_thread_flag(prev, TIF_USEDFPU); \ (last) = resume(prev, next, task_thread_info(next), __usedfpu); \ @@ -77,6 +86,14 @@ do { \ #define finish_arch_switch(prev) \ do { \ + u32 __c0_stat; \ + if (cop2_present && !cop2_lazy_restore && \ + (KSTK_STATUS(current) & ST0_CU2)) { \ + __c0_stat = read_c0_status(); \ + write_c0_status(__c0_stat | ST0_CU2); \ + cop2_restore(¤t->thread.cp2); \ + write_c0_status(__c0_stat & ~ST0_CU2); \ + } \ if (cpu_has_dsp) \ __restore_dsp(current); \ if (cpu_has_userlocal) \ diff --git a/arch/mips/kernel/octeon_switch.S b/arch/mips/kernel/octeon_switch.S index 0e23343eb0a9..22e2aa1e8d37 100644 --- a/arch/mips/kernel/octeon_switch.S +++ b/arch/mips/kernel/octeon_switch.S @@ -40,33 +40,6 @@ cpu_save_nonscratch a0 LONG_S ra, THREAD_REG31(a0) - /* check if we need to save COP2 registers */ - PTR_L t2, TASK_THREAD_INFO(a0) - LONG_L t0, ST_OFF(t2) - bbit0 t0, 30, 1f - - /* Disable COP2 in the stored process state */ - li t1, ST0_CU2 - xor t0, t1 - LONG_S t0, ST_OFF(t2) - - /* Enable COP2 so we can save it */ - mfc0 t0, CP0_STATUS - or t0, t1 - mtc0 t0, CP0_STATUS - - /* Save COP2 */ - daddu a0, THREAD_CP2 - jal octeon_cop2_save - dsubu a0, THREAD_CP2 - - /* Disable COP2 now that we are done */ - mfc0 t0, CP0_STATUS - li t1, ST0_CU2 - xor t0, t1 - mtc0 t0, CP0_STATUS - -1: #if CONFIG_CAVIUM_OCTEON_CVMSEG_SIZE > 0 /* Check if we need to store CVMSEG state */ mfc0 t0, $11,7 /* CvmMemCtl */ From 83bee792d7cb20d250be57e99d97f8cc83d9b4d5 Mon Sep 17 00:00:00 2001 From: Jayachandran C Date: Mon, 10 Jun 2013 06:30:01 +0000 Subject: [PATCH 0191/1048] MIPS: Allow kernel to use coprocessor 2 Kernel threads should be able to use COP2 if the platform needs it. Do not call die_if_kernel() for a coprocessor unusable exception if the exception due to COP2 usage. Instead, the default notifier for COP2 exceptions is updated to call die_if_kernel. Signed-off-by: Jayachandran C Cc: linux-mips@linux-mips.org Cc: ddaney.cavm@gmail.com Patchwork: https://patchwork.linux-mips.org/patch/5415/ Signed-off-by: Ralf Baechle --- arch/mips/kernel/traps.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c index beba1e616b6e..142d2bede024 100644 --- a/arch/mips/kernel/traps.c +++ b/arch/mips/kernel/traps.c @@ -1056,15 +1056,9 @@ static int default_cu2_call(struct notifier_block *nfb, unsigned long action, { struct pt_regs *regs = data; - switch (action) { - default: - die_if_kernel("Unhandled kernel unaligned access or invalid " + die_if_kernel("COP2: Unhandled kernel unaligned access or invalid " "instruction", regs); - /* Fall through */ - - case CU2_EXCEPTION: - force_sig(SIGILL, current); - } + force_sig(SIGILL, current); return NOTIFY_OK; } @@ -1080,10 +1074,11 @@ asmlinkage void do_cpu(struct pt_regs *regs) unsigned long __maybe_unused flags; prev_state = exception_enter(); - die_if_kernel("do_cpu invoked from kernel context!", regs); - cpid = (regs->cp0_cause >> CAUSEB_CE) & 3; + if (cpid != 2) + die_if_kernel("do_cpu invoked from kernel context!", regs); + switch (cpid) { case 0: epc = (unsigned int __user *)exception_epc(regs); From 1c146cd46fccfaa5525152f086da2752fe0ed4dd Mon Sep 17 00:00:00 2001 From: Jayachandran C Date: Mon, 10 Jun 2013 06:30:02 +0000 Subject: [PATCH 0192/1048] MIPS: Netlogic: Fix nlm_read_c2_status() definition The sel argument os nlm_read_c2_status() was not used and the macro returned the sel 0 in all cases. Fix this by defining two macros: nlm_read_c2_status0() and nlm_read_c2_status1() to return the two status registers. Add functions to write to the status registers as well. Signed-off-by: Jayachandran C Cc: linux-mips@linux-mips.org Cc: ddaney.cavm@gmail.com Patchwork: https://patchwork.linux-mips.org/patch/5414/ Signed-off-by: Ralf Baechle --- arch/mips/include/asm/netlogic/xlr/fmn.h | 8 ++++++-- arch/mips/netlogic/xlr/fmn.c | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/arch/mips/include/asm/netlogic/xlr/fmn.h b/arch/mips/include/asm/netlogic/xlr/fmn.h index 2a78929cef73..56c7b85ea7dd 100644 --- a/arch/mips/include/asm/netlogic/xlr/fmn.h +++ b/arch/mips/include/asm/netlogic/xlr/fmn.h @@ -175,6 +175,10 @@ #define nlm_write_c2_cc14(s, v) __write_32bit_c2_register($30, s, v) #define nlm_write_c2_cc15(s, v) __write_32bit_c2_register($31, s, v) +#define nlm_read_c2_status0() __read_32bit_c2_register($2, 0) +#define nlm_write_c2_status0(v) __write_32bit_c2_register($2, 0, v) +#define nlm_read_c2_status1() __read_32bit_c2_register($2, 1) +#define nlm_write_c2_status1(v) __write_32bit_c2_register($2, 1, v) #define nlm_read_c2_status(sel) __read_32bit_c2_register($2, 0) #define nlm_read_c2_config() __read_32bit_c2_register($3, 0) #define nlm_write_c2_config(v) __write_32bit_c2_register($3, 0, v) @@ -296,7 +300,7 @@ static inline int nlm_fmn_send(unsigned int size, unsigned int code, */ for (i = 0; i < 8; i++) { nlm_msgsnd(dest); - status = nlm_read_c2_status(0); + status = nlm_read_c2_status0(); if ((status & 0x2) == 1) pr_info("Send pending fail!\n"); if ((status & 0x4) == 0) @@ -316,7 +320,7 @@ static inline int nlm_fmn_receive(int bucket, int *size, int *code, int *stid, /* wait for load pending to clear */ do { - status = nlm_read_c2_status(1); + status = nlm_read_c2_status0(); } while ((status & 0x08) != 0); /* receive error bits */ diff --git a/arch/mips/netlogic/xlr/fmn.c b/arch/mips/netlogic/xlr/fmn.c index 4d74f03de506..0fdce61857cd 100644 --- a/arch/mips/netlogic/xlr/fmn.c +++ b/arch/mips/netlogic/xlr/fmn.c @@ -80,7 +80,7 @@ static irqreturn_t fmn_message_handler(int irq, void *data) while (1) { /* 8 bkts per core, [24:31] each bit represents one bucket * Bit is Zero if bucket is not empty */ - bkt_status = (nlm_read_c2_status() >> 24) & 0xff; + bkt_status = (nlm_read_c2_status0() >> 24) & 0xff; if (bkt_status == 0xff) break; for (bucket = 0; bucket < 8; bucket++) { From 64f6ebe63914835ad5cd5bc4c490f3deaeac2511 Mon Sep 17 00:00:00 2001 From: Jayachandran C Date: Mon, 10 Jun 2013 06:30:03 +0000 Subject: [PATCH 0193/1048] MIPS: Netlogic: rename nlm_cop2_save/restore Rename macro nlm_cop2_enable() to nlm_cop2_enable_irqsave() and the macro nlm_cop2_restore to nlm_cop2_disable_irqrestore(). The new names will reflect the functionality better, and will make nlm_cop2_restore() available to be used later in COP2 save/restore patch. Signed-off-by: Jayachandran C Cc: linux-mips@linux-mips.org Cc: ddaney.cavm@gmail.com Patchwork: https://patchwork.linux-mips.org/patch/5412/ Signed-off-by: Ralf Baechle --- arch/mips/include/asm/netlogic/xlr/fmn.h | 4 ++-- arch/mips/netlogic/xlr/fmn.c | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/arch/mips/include/asm/netlogic/xlr/fmn.h b/arch/mips/include/asm/netlogic/xlr/fmn.h index 56c7b85ea7dd..5604db3d1836 100644 --- a/arch/mips/include/asm/netlogic/xlr/fmn.h +++ b/arch/mips/include/asm/netlogic/xlr/fmn.h @@ -241,7 +241,7 @@ static inline void nlm_msgwait(unsigned int mask) /* * Disable interrupts and enable COP2 access */ -static inline uint32_t nlm_cop2_enable(void) +static inline uint32_t nlm_cop2_enable_irqsave(void) { uint32_t sr = read_c0_status(); @@ -249,7 +249,7 @@ static inline uint32_t nlm_cop2_enable(void) return sr; } -static inline void nlm_cop2_restore(uint32_t sr) +static inline void nlm_cop2_disable_irqrestore(uint32_t sr) { write_c0_status(sr); } diff --git a/arch/mips/netlogic/xlr/fmn.c b/arch/mips/netlogic/xlr/fmn.c index 0fdce61857cd..d428e8471eec 100644 --- a/arch/mips/netlogic/xlr/fmn.c +++ b/arch/mips/netlogic/xlr/fmn.c @@ -74,7 +74,7 @@ static irqreturn_t fmn_message_handler(int irq, void *data) struct nlm_fmn_msg msg; uint32_t mflags, bkt_status; - mflags = nlm_cop2_enable(); + mflags = nlm_cop2_enable_irqsave(); /* Disable message ring interrupt */ nlm_fmn_setup_intr(irq, 0); while (1) { @@ -97,16 +97,16 @@ static irqreturn_t fmn_message_handler(int irq, void *data) pr_warn("No msgring handler for stnid %d\n", src_stnid); else { - nlm_cop2_restore(mflags); + nlm_cop2_disable_irqrestore(mflags); hndlr->action(bucket, src_stnid, size, code, &msg, hndlr->arg); - mflags = nlm_cop2_enable(); + mflags = nlm_cop2_enable_irqsave(); } } }; /* Enable message ring intr, to any thread in core */ nlm_fmn_setup_intr(irq, (1 << nlm_threads_per_core) - 1); - nlm_cop2_restore(mflags); + nlm_cop2_disable_irqrestore(mflags); return IRQ_HANDLED; } @@ -128,7 +128,7 @@ void xlr_percpu_fmn_init(void) bucket_sizes = xlr_board_fmn_config.bucket_size; cpu_fmn_info = &xlr_board_fmn_config.cpu[id]; - flags = nlm_cop2_enable(); + flags = nlm_cop2_enable_irqsave(); /* Setup bucket sizes for the core. */ nlm_write_c2_bucksize(0, bucket_sizes[id * 8 + 0]); @@ -166,7 +166,7 @@ void xlr_percpu_fmn_init(void) /* enable FMN interrupts on this CPU */ nlm_fmn_setup_intr(IRQ_FMN, (1 << nlm_threads_per_core) - 1); - nlm_cop2_restore(flags); + nlm_cop2_disable_irqrestore(flags); } @@ -198,7 +198,7 @@ void nlm_setup_fmn_irq(void) /* setup irq only once */ setup_irq(IRQ_FMN, &fmn_irqaction); - flags = nlm_cop2_enable(); + flags = nlm_cop2_enable_irqsave(); nlm_fmn_setup_intr(IRQ_FMN, (1 << nlm_threads_per_core) - 1); - nlm_cop2_restore(flags); + nlm_cop2_disable_irqrestore(flags); } From 5649d37c2b23ad6545709c976b9abbfa8d5f4e11 Mon Sep 17 00:00:00 2001 From: Jayachandran C Date: Mon, 10 Jun 2013 06:30:04 +0000 Subject: [PATCH 0194/1048] MIPS: Netlogic: COP2 save/restore code Add COP2 register state structure and functions for Netlogic XLP. The RX and TX buffers and status registers are to be saved. Since the registers are 64-bit, do the implementation in inline assembly which works on both 32-bit and 64-bit kernels. Signed-off-by: Jayachandran C Cc: linux-mips@linux-mips.org Cc: ddaney.cavm@gmail.com Patchwork: https://patchwork.linux-mips.org/patch/5413/ Signed-off-by: Ralf Baechle --- arch/mips/include/asm/cop2.h | 10 +++ arch/mips/include/asm/processor.h | 13 ++++ arch/mips/netlogic/xlp/Makefile | 2 +- arch/mips/netlogic/xlp/cop2-ex.c | 118 ++++++++++++++++++++++++++++++ 4 files changed, 142 insertions(+), 1 deletion(-) create mode 100644 arch/mips/netlogic/xlp/cop2-ex.c diff --git a/arch/mips/include/asm/cop2.h b/arch/mips/include/asm/cop2.h index b17f38ee1ed4..c1516cc0285f 100644 --- a/arch/mips/include/asm/cop2.h +++ b/arch/mips/include/asm/cop2.h @@ -22,6 +22,16 @@ extern void octeon_cop2_restore(struct octeon_cop2_state *); #define cop2_present 1 #define cop2_lazy_restore 1 +#elif defined(CONFIG_CPU_XLP) + +extern void nlm_cop2_save(struct nlm_cop2_state *); +extern void nlm_cop2_restore(struct nlm_cop2_state *); +#define cop2_save(r) nlm_cop2_save(r) +#define cop2_restore(r) nlm_cop2_restore(r) + +#define cop2_present 1 +#define cop2_lazy_restore 0 + #else #define cop2_present 0 diff --git a/arch/mips/include/asm/processor.h b/arch/mips/include/asm/processor.h index 7c637a461ced..016dc4bffc80 100644 --- a/arch/mips/include/asm/processor.h +++ b/arch/mips/include/asm/processor.h @@ -190,6 +190,16 @@ struct octeon_cvmseg_state { [cpu_dcache_line_size() / sizeof(unsigned long)]; }; +#elif defined(CONFIG_CPU_XLP) +struct nlm_cop2_state { + u64 rx[4]; + u64 tx[4]; + u32 tx_msg_status; + u32 rx_msg_status; +}; + +#define COP2_INIT \ + .cp2 = {{0}, {0}, 0, 0}, #else #define COP2_INIT #endif @@ -236,6 +246,9 @@ struct thread_struct { #ifdef CONFIG_CPU_CAVIUM_OCTEON struct octeon_cop2_state cp2 __attribute__ ((__aligned__(128))); struct octeon_cvmseg_state cvmseg __attribute__ ((__aligned__(128))); +#endif +#ifdef CONFIG_CPU_XLP + struct nlm_cop2_state cp2; #endif struct mips_abi *abi; }; diff --git a/arch/mips/netlogic/xlp/Makefile b/arch/mips/netlogic/xlp/Makefile index a84d6ed3746c..e8dd14c38cb6 100644 --- a/arch/mips/netlogic/xlp/Makefile +++ b/arch/mips/netlogic/xlp/Makefile @@ -1,3 +1,3 @@ -obj-y += setup.o nlm_hal.o +obj-y += setup.o nlm_hal.o cop2-ex.o obj-$(CONFIG_SMP) += wakeup.o obj-$(CONFIG_USB) += usb-init.o diff --git a/arch/mips/netlogic/xlp/cop2-ex.c b/arch/mips/netlogic/xlp/cop2-ex.c new file mode 100644 index 000000000000..52bc5de42005 --- /dev/null +++ b/arch/mips/netlogic/xlp/cop2-ex.c @@ -0,0 +1,118 @@ +/* + * This file is subject to the terms and conditions of the GNU General Public + * License. See the file "COPYING" in the main directory of this archive + * for more details. + * + * Copyright (C) 2013 Broadcom Corporation. + * + * based on arch/mips/cavium-octeon/cpu.c + * Copyright (C) 2009 Wind River Systems, + * written by Ralf Baechle + */ +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include + +/* + * 64 bit ops are done in inline assembly to support 32 bit + * compilation + */ +void nlm_cop2_save(struct nlm_cop2_state *r) +{ + asm volatile( + ".set push\n" + ".set noat\n" + "dmfc2 $1, $0, 0\n" + "sd $1, 0(%1)\n" + "dmfc2 $1, $0, 1\n" + "sd $1, 8(%1)\n" + "dmfc2 $1, $0, 2\n" + "sd $1, 16(%1)\n" + "dmfc2 $1, $0, 3\n" + "sd $1, 24(%1)\n" + "dmfc2 $1, $1, 0\n" + "sd $1, 0(%2)\n" + "dmfc2 $1, $1, 1\n" + "sd $1, 8(%2)\n" + "dmfc2 $1, $1, 2\n" + "sd $1, 16(%2)\n" + "dmfc2 $1, $1, 3\n" + "sd $1, 24(%2)\n" + ".set pop\n" + : "=m"(*r) + : "r"(r->tx), "r"(r->rx)); + + r->tx_msg_status = __read_32bit_c2_register($2, 0); + r->rx_msg_status = __read_32bit_c2_register($3, 0) & 0x0fffffff; +} + +void nlm_cop2_restore(struct nlm_cop2_state *r) +{ + u32 rstat; + + asm volatile( + ".set push\n" + ".set noat\n" + "ld $1, 0(%1)\n" + "dmtc2 $1, $0, 0\n" + "ld $1, 8(%1)\n" + "dmtc2 $1, $0, 1\n" + "ld $1, 16(%1)\n" + "dmtc2 $1, $0, 2\n" + "ld $1, 24(%1)\n" + "dmtc2 $1, $0, 3\n" + "ld $1, 0(%2)\n" + "dmtc2 $1, $1, 0\n" + "ld $1, 8(%2)\n" + "dmtc2 $1, $1, 1\n" + "ld $1, 16(%2)\n" + "dmtc2 $1, $1, 2\n" + "ld $1, 24(%2)\n" + "dmtc2 $1, $1, 3\n" + ".set pop\n" + : : "m"(*r), "r"(r->tx), "r"(r->rx)); + + __write_32bit_c2_register($2, 0, r->tx_msg_status); + rstat = __read_32bit_c2_register($3, 0) & 0xf0000000u; + __write_32bit_c2_register($3, 0, r->rx_msg_status | rstat); +} + +static int nlm_cu2_call(struct notifier_block *nfb, unsigned long action, + void *data) +{ + unsigned long flags; + unsigned int status; + + switch (action) { + case CU2_EXCEPTION: + if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SYS_RAWIO)) + break; + local_irq_save(flags); + KSTK_STATUS(current) |= ST0_CU2; + status = read_c0_status(); + write_c0_status(status | ST0_CU2); + nlm_cop2_restore(&(current->thread.cp2)); + write_c0_status(status & ~ST0_CU2); + local_irq_restore(flags); + pr_info("COP2 access enabled for pid %d (%s)\n", + current->pid, current->comm); + return NOTIFY_BAD; /* Don't call default notifier */ + } + + return NOTIFY_OK; /* Let default notifier send signals */ +} + +static int __init nlm_cu2_setup(void) +{ + return cu2_notifier(nlm_cu2_call, 0); +} +early_initcall(nlm_cu2_setup); From d6a5078459d95137d8d620787d1099a3016932a9 Mon Sep 17 00:00:00 2001 From: Jayachandran C Date: Mon, 10 Jun 2013 06:33:25 +0000 Subject: [PATCH 0195/1048] MIPS: boot: Fixes for compressed/uart-16550.c Fix uart-16550.c for adding XLR/XLP support, changes are: * Make register read/write use volatile pointers * Support 32 bit IO read/write * Increase timeout in waiting for UART LSR Signed-off-by: Jayachandran C Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/5416/ Signed-off-by: Ralf Baechle --- arch/mips/boot/compressed/uart-16550.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/arch/mips/boot/compressed/uart-16550.c b/arch/mips/boot/compressed/uart-16550.c index 1c7b739b6a1d..90ae4400c40c 100644 --- a/arch/mips/boot/compressed/uart-16550.c +++ b/arch/mips/boot/compressed/uart-16550.c @@ -23,23 +23,27 @@ #define PORT(offset) (UART0_BASE + (4 * offset)) #endif +#ifndef IOTYPE +#define IOTYPE char +#endif + #ifndef PORT #error please define the serial port address for your own machine #endif static inline unsigned int serial_in(int offset) { - return *((char *)PORT(offset)); + return *((volatile IOTYPE *)PORT(offset)) & 0xFF; } static inline void serial_out(int offset, int value) { - *((char *)PORT(offset)) = value; + *((volatile IOTYPE *)PORT(offset)) = value & 0xFF; } void putc(char c) { - int timeout = 1024; + int timeout = 1000000; while (((serial_in(UART_LSR) & UART_LSR_THRE) == 0) && (timeout-- > 0)) ; From 8f0b043045d0b19d7eb8b510bfe279c9bb05d952 Mon Sep 17 00:00:00 2001 From: Jayachandran C Date: Mon, 10 Jun 2013 06:33:26 +0000 Subject: [PATCH 0196/1048] MIPS: Netlogic: Support compressed kernel Add SYS_SUPPORTS_ZBOOT and SYS_SUPPORTS_ZBOOT_UART16550 config options for XLR and XLP. Update boot/compressed/uart-16550.c to add UART port for XLR and XLP. Signed-off-by: Jayachandran C Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/5417/ Signed-off-by: Ralf Baechle --- arch/mips/Kconfig | 4 ++++ arch/mips/boot/compressed/uart-16550.c | 12 ++++++++++++ 2 files changed, 16 insertions(+) diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig index a46b0a2f8f0f..69bf31062ca4 100644 --- a/arch/mips/Kconfig +++ b/arch/mips/Kconfig @@ -788,6 +788,8 @@ config NLM_XLR_BOARD select SYS_HAS_EARLY_PRINTK select USB_ARCH_HAS_OHCI if USB_SUPPORT select USB_ARCH_HAS_EHCI if USB_SUPPORT + select SYS_SUPPORTS_ZBOOT + select SYS_SUPPORTS_ZBOOT_UART16550 help Support for systems based on Netlogic XLR and XLS processors. Say Y here if you have a XLR or XLS based board. @@ -814,6 +816,8 @@ config NLM_XLP_BOARD select SYNC_R4K select SYS_HAS_EARLY_PRINTK select USE_OF + select SYS_SUPPORTS_ZBOOT + select SYS_SUPPORTS_ZBOOT_UART16550 help This board is based on Netlogic XLP Processor. Say Y here if you have a XLP based board. diff --git a/arch/mips/boot/compressed/uart-16550.c b/arch/mips/boot/compressed/uart-16550.c index 90ae4400c40c..c01d343ce6ad 100644 --- a/arch/mips/boot/compressed/uart-16550.c +++ b/arch/mips/boot/compressed/uart-16550.c @@ -23,6 +23,18 @@ #define PORT(offset) (UART0_BASE + (4 * offset)) #endif +#ifdef CONFIG_CPU_XLR +#define UART0_BASE 0x1EF14000 +#define PORT(offset) (CKSEG1ADDR(UART0_BASE) + (4 * offset)) +#define IOTYPE unsigned int +#endif + +#ifdef CONFIG_CPU_XLP +#define UART0_BASE 0x18030100 +#define PORT(offset) (CKSEG1ADDR(UART0_BASE) + (4 * offset)) +#define IOTYPE unsigned int +#endif + #ifndef IOTYPE #define IOTYPE char #endif From aceee09d4f09dd7a6be48d04d329c140a5caaaf7 Mon Sep 17 00:00:00 2001 From: Jayachandran C Date: Mon, 10 Jun 2013 06:41:00 +0000 Subject: [PATCH 0197/1048] MIPS: Netlogic: Split XLP device tree code to dt.c Create new flle arch/mips/netlogic/xlp/dt.c and move the device tree related code there. Signed-off-by: Jayachandran C Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/5422/ Signed-off-by: Ralf Baechle --- arch/mips/include/asm/netlogic/xlp-hal/xlp.h | 1 + arch/mips/netlogic/xlp/Makefile | 2 +- arch/mips/netlogic/xlp/dt.c | 99 ++++++++++++++++++++ arch/mips/netlogic/xlp/setup.c | 73 +-------------- 4 files changed, 105 insertions(+), 70 deletions(-) create mode 100644 arch/mips/netlogic/xlp/dt.c diff --git a/arch/mips/include/asm/netlogic/xlp-hal/xlp.h b/arch/mips/include/asm/netlogic/xlp-hal/xlp.h index 7e47209327a5..f4ea0f7f3965 100644 --- a/arch/mips/include/asm/netlogic/xlp-hal/xlp.h +++ b/arch/mips/include/asm/netlogic/xlp-hal/xlp.h @@ -59,6 +59,7 @@ void xlp_wakeup_secondary_cpus(void); void xlp_mmu_init(void); void nlm_hal_init(void); +void *xlp_dt_init(void *fdtp); #endif /* !__ASSEMBLY__ */ #endif /* _ASM_NLM_XLP_H */ diff --git a/arch/mips/netlogic/xlp/Makefile b/arch/mips/netlogic/xlp/Makefile index e8dd14c38cb6..85ac4a892ced 100644 --- a/arch/mips/netlogic/xlp/Makefile +++ b/arch/mips/netlogic/xlp/Makefile @@ -1,3 +1,3 @@ -obj-y += setup.o nlm_hal.o cop2-ex.o +obj-y += setup.o nlm_hal.o cop2-ex.o dt.o obj-$(CONFIG_SMP) += wakeup.o obj-$(CONFIG_USB) += usb-init.o diff --git a/arch/mips/netlogic/xlp/dt.c b/arch/mips/netlogic/xlp/dt.c new file mode 100644 index 000000000000..a15cdbb8d0bd --- /dev/null +++ b/arch/mips/netlogic/xlp/dt.c @@ -0,0 +1,99 @@ +/* + * Copyright 2003-2013 Broadcom Corporation. + * All Rights Reserved. + * + * This software is available to you under a choice of one of two + * licenses. You may choose to be licensed under the terms of the GNU + * General Public License (GPL) Version 2, available from the file + * COPYING in the main directory of this source tree, or the Broadcom + * license below: + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY BROADCOM ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL BROADCOM OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include + +#include +#include +#include + +extern u32 __dtb_xlp_evp_begin[], __dtb_xlp_svp_begin[], __dtb_start[]; + +void __init *xlp_dt_init(void *fdtp) +{ + if (!fdtp) { + switch (current_cpu_data.processor_id & 0xff00) { +#ifdef CONFIG_DT_XLP_SVP + case PRID_IMP_NETLOGIC_XLP3XX: + fdtp = __dtb_xlp_svp_begin; + break; +#endif +#ifdef CONFIG_DT_XLP_EVP + case PRID_IMP_NETLOGIC_XLP8XX: + fdtp = __dtb_xlp_evp_begin; + break; +#endif + default: + /* Pick a built-in if any, and hope for the best */ + fdtp = __dtb_start; + break; + } + } + initial_boot_params = fdtp; + return fdtp; +} + +void __init device_tree_init(void) +{ + unsigned long base, size; + + if (!initial_boot_params) + return; + + base = virt_to_phys((void *)initial_boot_params); + size = be32_to_cpu(initial_boot_params->totalsize); + + /* Before we do anything, lets reserve the dt blob */ + reserve_bootmem(base, size, BOOTMEM_DEFAULT); + + unflatten_device_tree(); + + /* free the space reserved for the dt blob */ + free_bootmem(base, size); +} + +static struct of_device_id __initdata xlp_ids[] = { + { .compatible = "simple-bus", }, + {}, +}; + +int __init xlp8xx_ds_publish_devices(void) +{ + if (!of_have_populated_dt()) + return 0; + return of_platform_bus_probe(NULL, xlp_ids, NULL); +} + +device_initcall(xlp8xx_ds_publish_devices); diff --git a/arch/mips/netlogic/xlp/setup.c b/arch/mips/netlogic/xlp/setup.c index eaa99d28cb8e..7b6694998cdc 100644 --- a/arch/mips/netlogic/xlp/setup.c +++ b/arch/mips/netlogic/xlp/setup.c @@ -33,19 +33,13 @@ */ #include -#include -#include -#include +#include #include #include #include #include -#include -#include -#include - #include #include @@ -57,7 +51,6 @@ uint64_t nlm_io_base; struct nlm_soc_info nlm_nodes[NLM_NR_NODES]; cpumask_t nlm_cpumask = CPU_MASK_CPU0; unsigned int nlm_threads_per_core; -extern u32 __dtb_xlp_evp_begin[], __dtb_xlp_svp_begin[], __dtb_start[]; static void nlm_linux_exit(void) { @@ -70,39 +63,13 @@ static void nlm_linux_exit(void) void __init plat_mem_setup(void) { - void *fdtp; - panic_timeout = 5; _machine_restart = (void (*)(char *))nlm_linux_exit; _machine_halt = nlm_linux_exit; pm_power_off = nlm_linux_exit; - /* - * If no FDT pointer is passed in, use the built-in FDT. - * device_tree_init() does not handle CKSEG0 pointers in - * 64-bit, so convert pointer. - */ - fdtp = (void *)(long)fw_arg0; - if (!fdtp) { - switch (current_cpu_data.processor_id & 0xff00) { -#ifdef CONFIG_DT_XLP_SVP - case PRID_IMP_NETLOGIC_XLP3XX: - fdtp = __dtb_xlp_svp_begin; - break; -#endif -#ifdef CONFIG_DT_XLP_EVP - case PRID_IMP_NETLOGIC_XLP8XX: - fdtp = __dtb_xlp_evp_begin; - break; -#endif - default: - /* Pick a built-in if any, and hope for the best */ - fdtp = __dtb_start; - break; - } - } - fdtp = phys_to_virt(__pa(fdtp)); - early_init_devtree(fdtp); + /* memory and bootargs from DT */ + early_init_devtree(initial_boot_params); } const char *get_system_type(void) @@ -134,6 +101,7 @@ void __init prom_init(void) nlm_io_base = CKSEG1ADDR(XLP_DEFAULT_IO_BASE); xlp_mmu_init(); nlm_node_init(0); + xlp_dt_init((void *)(long)fw_arg0); #ifdef CONFIG_SMP cpumask_setall(&nlm_cpumask); @@ -145,36 +113,3 @@ void __init prom_init(void) register_smp_ops(&nlm_smp_ops); #endif } - -void __init device_tree_init(void) -{ - unsigned long base, size; - - if (!initial_boot_params) - return; - - base = virt_to_phys((void *)initial_boot_params); - size = be32_to_cpu(initial_boot_params->totalsize); - - /* Before we do anything, lets reserve the dt blob */ - reserve_bootmem(base, size, BOOTMEM_DEFAULT); - - unflatten_device_tree(); - - /* free the space reserved for the dt blob */ - free_bootmem(base, size); -} - -static struct of_device_id __initdata xlp_ids[] = { - { .compatible = "simple-bus", }, - {}, -}; - -int __init xlp8xx_ds_publish_devices(void) -{ - if (!of_have_populated_dt()) - return 0; - return of_platform_bus_probe(NULL, xlp_ids, NULL); -} - -device_initcall(xlp8xx_ds_publish_devices); From 9584c55a5cc0db82329dd1142ca570e2d64ea491 Mon Sep 17 00:00:00 2001 From: Jayachandran C Date: Mon, 10 Jun 2013 06:41:01 +0000 Subject: [PATCH 0198/1048] MIPS: Netlogic: Split reset code out of smpboot.S The reset and core initialization code should be available for uniprocessor as well. This changes is just to take out the code into a different file, without any change to the logic. The change for uniprocessor initialization code is in a later patch. Signed-off-by: Jayachandran C Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/5423/ Signed-off-by: Ralf Baechle --- arch/mips/include/asm/netlogic/common.h | 1 + arch/mips/netlogic/common/Makefile | 2 +- arch/mips/netlogic/common/reset.S | 249 ++++++++++++++++++++++++ arch/mips/netlogic/common/smpboot.S | 187 +----------------- arch/mips/netlogic/xlp/wakeup.c | 1 + 5 files changed, 253 insertions(+), 187 deletions(-) create mode 100644 arch/mips/netlogic/common/reset.S diff --git a/arch/mips/include/asm/netlogic/common.h b/arch/mips/include/asm/netlogic/common.h index 70351b95ef88..d4ede12b84c6 100644 --- a/arch/mips/include/asm/netlogic/common.h +++ b/arch/mips/include/asm/netlogic/common.h @@ -71,6 +71,7 @@ nlm_set_nmi_handler(void *handler) /* * Misc. */ +void nlm_init_boot_cpu(void); unsigned int nlm_get_cpu_frequency(void); void nlm_node_init(int node); extern struct plat_smp_ops nlm_smp_ops; diff --git a/arch/mips/netlogic/common/Makefile b/arch/mips/netlogic/common/Makefile index b29549741e05..a396a39ec491 100644 --- a/arch/mips/netlogic/common/Makefile +++ b/arch/mips/netlogic/common/Makefile @@ -1,4 +1,4 @@ obj-y += irq.o time.o obj-y += nlm-dma.o -obj-$(CONFIG_SMP) += smp.o smpboot.o +obj-$(CONFIG_SMP) += smp.o smpboot.o reset.o obj-$(CONFIG_EARLY_PRINTK) += earlycons.o diff --git a/arch/mips/netlogic/common/reset.S b/arch/mips/netlogic/common/reset.S new file mode 100644 index 000000000000..98691d6b3bbe --- /dev/null +++ b/arch/mips/netlogic/common/reset.S @@ -0,0 +1,249 @@ +/* + * Copyright 2003-2013 Broadcom Corporation. + * All Rights Reserved. + * + * This software is available to you under a choice of one of two + * licenses. You may choose to be licensed under the terms of the GNU + * General Public License (GPL) Version 2, available from the file + * COPYING in the main directory of this source tree, or the Broadcom + * license below: + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY BROADCOM ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL BROADCOM OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include + +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include + +#define CP0_EBASE $15 +#define SYS_CPU_COHERENT_BASE(node) CKSEG1ADDR(XLP_DEFAULT_IO_BASE) + \ + XLP_IO_SYS_OFFSET(node) + XLP_IO_PCI_HDRSZ + \ + SYS_CPU_NONCOHERENT_MODE * 4 + +#define XLP_AX_WORKAROUND /* enable Ax silicon workarounds */ + +/* Enable XLP features and workarounds in the LSU */ +.macro xlp_config_lsu + li t0, LSU_DEFEATURE + mfcr t1, t0 + + lui t2, 0xc080 /* SUE, Enable Unaligned Access, L2HPE */ + or t1, t1, t2 +#ifdef XLP_AX_WORKAROUND + li t2, ~0xe /* S1RCM */ + and t1, t1, t2 +#endif + mtcr t1, t0 + + li t0, ICU_DEFEATURE + mfcr t1, t0 + ori t1, 0x1000 /* Enable Icache partitioning */ + mtcr t1, t0 + + +#ifdef XLP_AX_WORKAROUND + li t0, SCHED_DEFEATURE + lui t1, 0x0100 /* Disable BRU accepting ALU ops */ + mtcr t1, t0 +#endif +.endm + +/* + * Low level flush for L1D cache on XLP, the normal cache ops does + * not do the complete and correct cache flush. + */ +.macro xlp_flush_l1_dcache + li t0, LSU_DEBUG_DATA0 + li t1, LSU_DEBUG_ADDR + li t2, 0 /* index */ + li t3, 0x1000 /* loop count */ +1: + sll v0, t2, 5 + mtcr zero, t0 + ori v1, v0, 0x3 /* way0 | write_enable | write_active */ + mtcr v1, t1 +2: + mfcr v1, t1 + andi v1, 0x1 /* wait for write_active == 0 */ + bnez v1, 2b + nop + mtcr zero, t0 + ori v1, v0, 0x7 /* way1 | write_enable | write_active */ + mtcr v1, t1 +3: + mfcr v1, t1 + andi v1, 0x1 /* wait for write_active == 0 */ + bnez v1, 3b + nop + addi t2, 1 + bne t3, t2, 1b + nop +.endm + +/* + * nlm_reset_entry will be copied to the reset entry point for + * XLR and XLP. The XLP cores start here when they are woken up. This + * is also the NMI entry point. + * + * We use scratch reg 6/7 to save k0/k1 and check for NMI first. + * + * The data corresponding to reset/NMI is stored at RESET_DATA_PHYS + * location, this will have the thread mask (used when core is woken up) + * and the current NMI handler in case we reached here for an NMI. + * + * When a core or thread is newly woken up, it marks itself ready and + * loops in a 'wait'. When the CPU really needs waking up, we send an NMI + * IPI to it, with the NMI handler set to prom_boot_secondary_cpus + */ + .set noreorder + .set noat + .set arch=xlr /* for mfcr/mtcr, XLR is sufficient */ + +FEXPORT(nlm_reset_entry) + dmtc0 k0, $22, 6 + dmtc0 k1, $22, 7 + mfc0 k0, CP0_STATUS + li k1, 0x80000 + and k1, k0, k1 + beqz k1, 1f /* go to real reset entry */ + nop + li k1, CKSEG1ADDR(RESET_DATA_PHYS) /* NMI */ + ld k0, BOOT_NMI_HANDLER(k1) + jr k0 + nop + +1: /* Entry point on core wakeup */ + mfc0 t0, CP0_EBASE, 1 + mfc0 t1, CP0_EBASE, 1 + srl t1, 5 + andi t1, 0x3 /* t1 <- node */ + li t2, 0x40000 + mul t3, t2, t1 /* t3 = node * 0x40000 */ + srl t0, t0, 2 + and t0, t0, 0x7 /* t0 <- core */ + li t1, 0x1 + sll t0, t1, t0 + nor t0, t0, zero /* t0 <- ~(1 << core) */ + li t2, SYS_CPU_COHERENT_BASE(0) + add t2, t2, t3 /* t2 <- SYS offset for node */ + lw t1, 0(t2) + and t1, t1, t0 + sw t1, 0(t2) + + /* read back to ensure complete */ + lw t1, 0(t2) + sync + + /* Configure LSU on Non-0 Cores. */ + xlp_config_lsu + /* FALL THROUGH */ + +/* + * Wake up sibling threads from the initial thread in + * a core. + */ +EXPORT(nlm_boot_siblings) + /* core L1D flush before enable threads */ + xlp_flush_l1_dcache + /* Enable hw threads by writing to MAP_THREADMODE of the core */ + li t0, CKSEG1ADDR(RESET_DATA_PHYS) + lw t1, BOOT_THREAD_MODE(t0) /* t1 <- thread mode */ + li t0, ((CPU_BLOCKID_MAP << 8) | MAP_THREADMODE) + mfcr t2, t0 + or t2, t2, t1 + mtcr t2, t0 + + /* + * The new hardware thread starts at the next instruction + * For all the cases other than core 0 thread 0, we will + * jump to the secondary wait function. + */ + mfc0 v0, CP0_EBASE, 1 + andi v0, 0x3ff /* v0 <- node/core */ + + /* Init MMU in the first thread after changing THREAD_MODE + * register (Ax Errata?) + */ + andi v1, v0, 0x3 /* v1 <- thread id */ + bnez v1, 2f + nop + + li t0, MMU_SETUP + li t1, 0 + mtcr t1, t0 + _ehb + +2: beqz v0, 4f /* boot cpu (cpuid == 0)? */ + nop + + /* setup status reg */ + move t1, zero +#ifdef CONFIG_64BIT + ori t1, ST0_KX +#endif + mtc0 t1, CP0_STATUS + /* mark CPU ready */ + PTR_LA t1, nlm_cpu_ready + sll v1, v0, 2 + PTR_ADDU t1, v1 + li t2, 1 + sw t2, 0(t1) + /* Wait until NMI hits */ +3: wait + j 3b + nop + + /* + * For the boot CPU, we have to restore registers and + * return + */ +4: dmfc0 t0, $4, 2 /* restore SP from UserLocal */ + li t1, 0xfadebeef + dmtc0 t1, $4, 2 /* restore SP from UserLocal */ + PTR_SUBU sp, t0, PT_SIZE + RESTORE_ALL + jr ra + nop +EXPORT(nlm_reset_entry_end) + +LEAF(nlm_init_boot_cpu) +#ifdef CONFIG_CPU_XLP + xlp_config_lsu +#endif + jr ra + nop +END(nlm_init_boot_cpu) diff --git a/arch/mips/netlogic/common/smpboot.S b/arch/mips/netlogic/common/smpboot.S index 026517488584..7c7e884f8912 100644 --- a/arch/mips/netlogic/common/smpboot.S +++ b/arch/mips/netlogic/common/smpboot.S @@ -50,197 +50,12 @@ #include #define CP0_EBASE $15 -#define SYS_CPU_COHERENT_BASE(node) CKSEG1ADDR(XLP_DEFAULT_IO_BASE) + \ - XLP_IO_SYS_OFFSET(node) + XLP_IO_PCI_HDRSZ + \ - SYS_CPU_NONCOHERENT_MODE * 4 - -#define XLP_AX_WORKAROUND /* enable Ax silicon workarounds */ - -/* Enable XLP features and workarounds in the LSU */ -.macro xlp_config_lsu - li t0, LSU_DEFEATURE - mfcr t1, t0 - - lui t2, 0xc080 /* SUE, Enable Unaligned Access, L2HPE */ - or t1, t1, t2 -#ifdef XLP_AX_WORKAROUND - li t2, ~0xe /* S1RCM */ - and t1, t1, t2 -#endif - mtcr t1, t0 - - li t0, ICU_DEFEATURE - mfcr t1, t0 - ori t1, 0x1000 /* Enable Icache partitioning */ - mtcr t1, t0 - - -#ifdef XLP_AX_WORKAROUND - li t0, SCHED_DEFEATURE - lui t1, 0x0100 /* Disable BRU accepting ALU ops */ - mtcr t1, t0 -#endif -.endm - -/* - * This is the code that will be copied to the reset entry point for - * XLR and XLP. The XLP cores start here when they are woken up. This - * is also the NMI entry point. - */ -.macro xlp_flush_l1_dcache - li t0, LSU_DEBUG_DATA0 - li t1, LSU_DEBUG_ADDR - li t2, 0 /* index */ - li t3, 0x1000 /* loop count */ -1: - sll v0, t2, 5 - mtcr zero, t0 - ori v1, v0, 0x3 /* way0 | write_enable | write_active */ - mtcr v1, t1 -2: - mfcr v1, t1 - andi v1, 0x1 /* wait for write_active == 0 */ - bnez v1, 2b - nop - mtcr zero, t0 - ori v1, v0, 0x7 /* way1 | write_enable | write_active */ - mtcr v1, t1 -3: - mfcr v1, t1 - andi v1, 0x1 /* wait for write_active == 0 */ - bnez v1, 3b - nop - addi t2, 1 - bne t3, t2, 1b - nop -.endm - -/* - * The cores can come start when they are woken up. This is also the NMI - * entry, so check that first. - * - * The data corresponding to reset/NMI is stored at RESET_DATA_PHYS - * location, this will have the thread mask (used when core is woken up) - * and the current NMI handler in case we reached here for an NMI. - * - * When a core or thread is newly woken up, it loops in a 'wait'. When - * the CPU really needs waking up, we send an NMI to it, with the NMI - * handler set to prom_boot_secondary_cpus - */ .set noreorder .set noat - .set arch=xlr /* for mfcr/mtcr, XLR is sufficient */ - -FEXPORT(nlm_reset_entry) - dmtc0 k0, $22, 6 - dmtc0 k1, $22, 7 - mfc0 k0, CP0_STATUS - li k1, 0x80000 - and k1, k0, k1 - beqz k1, 1f /* go to real reset entry */ - nop - li k1, CKSEG1ADDR(RESET_DATA_PHYS) /* NMI */ - ld k0, BOOT_NMI_HANDLER(k1) - jr k0 - nop - -1: /* Entry point on core wakeup */ - mfc0 t0, CP0_EBASE, 1 - mfc0 t1, CP0_EBASE, 1 - srl t1, 5 - andi t1, 0x3 /* t1 <- node */ - li t2, 0x40000 - mul t3, t2, t1 /* t3 = node * 0x40000 */ - srl t0, t0, 2 - and t0, t0, 0x7 /* t0 <- core */ - li t1, 0x1 - sll t0, t1, t0 - nor t0, t0, zero /* t0 <- ~(1 << core) */ - li t2, SYS_CPU_COHERENT_BASE(0) - add t2, t2, t3 /* t2 <- SYS offset for node */ - lw t1, 0(t2) - and t1, t1, t0 - sw t1, 0(t2) - - /* read back to ensure complete */ - lw t1, 0(t2) - sync - - /* Configure LSU on Non-0 Cores. */ - xlp_config_lsu - /* FALL THROUGH */ - -/* - * Wake up sibling threads from the initial thread in - * a core. - */ -EXPORT(nlm_boot_siblings) - /* core L1D flush before enable threads */ - xlp_flush_l1_dcache - /* Enable hw threads by writing to MAP_THREADMODE of the core */ - li t0, CKSEG1ADDR(RESET_DATA_PHYS) - lw t1, BOOT_THREAD_MODE(t0) /* t1 <- thread mode */ - li t0, ((CPU_BLOCKID_MAP << 8) | MAP_THREADMODE) - mfcr t2, t0 - or t2, t2, t1 - mtcr t2, t0 - - /* - * The new hardware thread starts at the next instruction - * For all the cases other than core 0 thread 0, we will - * jump to the secondary wait function. - */ - mfc0 v0, CP0_EBASE, 1 - andi v0, 0x3ff /* v0 <- node/core */ - - /* Init MMU in the first thread after changing THREAD_MODE - * register (Ax Errata?) - */ - andi v1, v0, 0x3 /* v1 <- thread id */ - bnez v1, 2f - nop - - li t0, MMU_SETUP - li t1, 0 - mtcr t1, t0 - _ehb - -2: beqz v0, 4f /* boot cpu (cpuid == 0)? */ - nop - - /* setup status reg */ - move t1, zero -#ifdef CONFIG_64BIT - ori t1, ST0_KX -#endif - mtc0 t1, CP0_STATUS - /* mark CPU ready */ - PTR_LA t1, nlm_cpu_ready - sll v1, v0, 2 - PTR_ADDU t1, v1 - li t2, 1 - sw t2, 0(t1) - /* Wait until NMI hits */ -3: wait - j 3b - nop - - /* - * For the boot CPU, we have to restore registers and - * return - */ -4: dmfc0 t0, $4, 2 /* restore SP from UserLocal */ - li t1, 0xfadebeef - dmtc0 t1, $4, 2 /* restore SP from UserLocal */ - PTR_SUBU sp, t0, PT_SIZE - RESTORE_ALL - jr ra - nop -EXPORT(nlm_reset_entry_end) + .set arch=xlr /* for mfcr/mtcr, XLR is sufficient */ FEXPORT(xlp_boot_core0_siblings) /* "Master" cpu starts from here */ - xlp_config_lsu dmtc0 sp, $4, 2 /* SP saved in UserLocal */ SAVE_ALL sync diff --git a/arch/mips/netlogic/xlp/wakeup.c b/arch/mips/netlogic/xlp/wakeup.c index abb3e08cc052..1a7d529fcec0 100644 --- a/arch/mips/netlogic/xlp/wakeup.c +++ b/arch/mips/netlogic/xlp/wakeup.c @@ -137,6 +137,7 @@ void xlp_wakeup_secondary_cpus() * In case of u-boot, the secondaries are in reset * first wakeup core 0 threads */ + nlm_init_boot_cpu(); xlp_boot_core0_siblings(); /* now get other cores out of reset */ From 571886b2a52395f030d439c6259663a033e11e6a Mon Sep 17 00:00:00 2001 From: Jayachandran C Date: Mon, 10 Jun 2013 06:41:02 +0000 Subject: [PATCH 0199/1048] MIPS: Netlogic: Initialization when !CONFIG_SMP The core initialization and reset vector setup needs to be done even when booting uniprocessor. Move this code from smp.c to setup.c Signed-off-by: Jayachandran C Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/5428/ Signed-off-by: Ralf Baechle --- arch/mips/netlogic/common/Makefile | 3 ++- arch/mips/netlogic/common/smp.c | 6 ------ arch/mips/netlogic/xlp/setup.c | 8 ++++++++ arch/mips/netlogic/xlp/wakeup.c | 1 - arch/mips/netlogic/xlr/setup.c | 6 ++++++ 5 files changed, 16 insertions(+), 8 deletions(-) diff --git a/arch/mips/netlogic/common/Makefile b/arch/mips/netlogic/common/Makefile index a396a39ec491..362739d62b1d 100644 --- a/arch/mips/netlogic/common/Makefile +++ b/arch/mips/netlogic/common/Makefile @@ -1,4 +1,5 @@ obj-y += irq.o time.o obj-y += nlm-dma.o -obj-$(CONFIG_SMP) += smp.o smpboot.o reset.o +obj-y += reset.o +obj-$(CONFIG_SMP) += smp.o smpboot.o obj-$(CONFIG_EARLY_PRINTK) += earlycons.o diff --git a/arch/mips/netlogic/common/smp.c b/arch/mips/netlogic/common/smp.c index ffba52489bef..da3d3bc02c20 100644 --- a/arch/mips/netlogic/common/smp.c +++ b/arch/mips/netlogic/common/smp.c @@ -254,15 +254,9 @@ unsupp: int __cpuinit nlm_wakeup_secondary_cpus(void) { - unsigned long reset_vec; char *reset_data; int threadmode; - /* Update reset entry point with CPU init code */ - reset_vec = CKSEG1ADDR(RESET_VEC_PHYS); - memcpy((void *)reset_vec, (void *)nlm_reset_entry, - (nlm_reset_entry_end - nlm_reset_entry)); - /* verify the mask and setup core config variables */ threadmode = nlm_parse_cpumask(&nlm_cpumask); diff --git a/arch/mips/netlogic/xlp/setup.c b/arch/mips/netlogic/xlp/setup.c index 7b6694998cdc..5bdd354fef48 100644 --- a/arch/mips/netlogic/xlp/setup.c +++ b/arch/mips/netlogic/xlp/setup.c @@ -98,11 +98,19 @@ void nlm_percpu_init(int hwcpuid) void __init prom_init(void) { + void *reset_vec; + nlm_io_base = CKSEG1ADDR(XLP_DEFAULT_IO_BASE); + nlm_init_boot_cpu(); xlp_mmu_init(); nlm_node_init(0); xlp_dt_init((void *)(long)fw_arg0); + /* Update reset entry point with CPU init code */ + reset_vec = (void *)CKSEG1ADDR(RESET_VEC_PHYS); + memcpy(reset_vec, (void *)nlm_reset_entry, + (nlm_reset_entry_end - nlm_reset_entry)); + #ifdef CONFIG_SMP cpumask_setall(&nlm_cpumask); nlm_wakeup_secondary_cpus(); diff --git a/arch/mips/netlogic/xlp/wakeup.c b/arch/mips/netlogic/xlp/wakeup.c index 1a7d529fcec0..abb3e08cc052 100644 --- a/arch/mips/netlogic/xlp/wakeup.c +++ b/arch/mips/netlogic/xlp/wakeup.c @@ -137,7 +137,6 @@ void xlp_wakeup_secondary_cpus() * In case of u-boot, the secondaries are in reset * first wakeup core 0 threads */ - nlm_init_boot_cpu(); xlp_boot_core0_siblings(); /* now get other cores out of reset */ diff --git a/arch/mips/netlogic/xlr/setup.c b/arch/mips/netlogic/xlr/setup.c index 89c8c1066632..7e27f8591867 100644 --- a/arch/mips/netlogic/xlr/setup.c +++ b/arch/mips/netlogic/xlr/setup.c @@ -196,6 +196,7 @@ void __init prom_init(void) { int *argv, *envp; /* passed as 32 bit ptrs */ struct psb_info *prom_infop; + void *reset_vec; #ifdef CONFIG_SMP int i; #endif @@ -208,6 +209,11 @@ void __init prom_init(void) nlm_prom_info = *prom_infop; nlm_init_node(); + /* Update reset entry point with CPU init code */ + reset_vec = (void *)CKSEG1ADDR(RESET_VEC_PHYS); + memcpy(reset_vec, (void *)nlm_reset_entry, + (nlm_reset_entry_end - nlm_reset_entry)); + nlm_early_serial_setup(); build_arcs_cmdline(argv); prom_add_memory(); From 53c832197f3adc5a360336f75fe34a95fe2d796b Mon Sep 17 00:00:00 2001 From: Jayachandran C Date: Mon, 10 Jun 2013 06:41:03 +0000 Subject: [PATCH 0200/1048] MIPS: Netlogic: Add nlm_get_boot_data() helper This moves the calculation and casting needed to access the CPU initialization data to a function nlm_get_boot_data() Signed-off-by: Jayachandran C Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/5426/ Signed-off-by: Ralf Baechle --- arch/mips/include/asm/netlogic/common.h | 11 ++++++++--- arch/mips/netlogic/common/smp.c | 6 +++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/arch/mips/include/asm/netlogic/common.h b/arch/mips/include/asm/netlogic/common.h index d4ede12b84c6..1b54adbd1583 100644 --- a/arch/mips/include/asm/netlogic/common.h +++ b/arch/mips/include/asm/netlogic/common.h @@ -59,13 +59,18 @@ int nlm_wakeup_secondary_cpus(void); void nlm_rmiboot_preboot(void); void nlm_percpu_init(int hwcpuid); +static inline void * +nlm_get_boot_data(int offset) +{ + return (void *)(CKSEG1ADDR(RESET_DATA_PHYS) + offset); +} + static inline void nlm_set_nmi_handler(void *handler) { - char *reset_data; + void *nmih = nlm_get_boot_data(BOOT_NMI_HANDLER); - reset_data = (char *)CKSEG1ADDR(RESET_DATA_PHYS); - *(int64_t *)(reset_data + BOOT_NMI_HANDLER) = (long)handler; + *(int64_t *)nmih = (long)handler; } /* diff --git a/arch/mips/netlogic/common/smp.c b/arch/mips/netlogic/common/smp.c index da3d3bc02c20..1f66eef3aea7 100644 --- a/arch/mips/netlogic/common/smp.c +++ b/arch/mips/netlogic/common/smp.c @@ -254,15 +254,15 @@ unsupp: int __cpuinit nlm_wakeup_secondary_cpus(void) { - char *reset_data; + u32 *reset_data; int threadmode; /* verify the mask and setup core config variables */ threadmode = nlm_parse_cpumask(&nlm_cpumask); /* Setup CPU init parameters */ - reset_data = (char *)CKSEG1ADDR(RESET_DATA_PHYS); - *(int *)(reset_data + BOOT_THREAD_MODE) = threadmode; + reset_data = nlm_get_boot_data(BOOT_THREAD_MODE); + *reset_data = threadmode; #ifdef CONFIG_CPU_XLP xlp_wakeup_secondary_cpus(); From 919f9abb3723f088290c62648b12fbfc7600d923 Mon Sep 17 00:00:00 2001 From: Jayachandran C Date: Mon, 10 Jun 2013 06:41:04 +0000 Subject: [PATCH 0201/1048] MIPS: Netlogic: move cpu_ready array to boot area Move the nlm_cpu_ready[] array used by the cpu wakeup code to the boot area, along with rest of the boot parameter code. Signed-off-by: Jayachandran C Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/5425/ Signed-off-by: Ralf Baechle --- arch/mips/include/asm/netlogic/common.h | 6 ++++++ arch/mips/netlogic/common/reset.S | 6 ++++-- arch/mips/netlogic/common/smp.c | 6 +++--- arch/mips/netlogic/common/smpboot.S | 5 +++-- arch/mips/netlogic/xlp/setup.c | 1 + arch/mips/netlogic/xlp/wakeup.c | 3 ++- arch/mips/netlogic/xlr/setup.c | 1 + arch/mips/netlogic/xlr/wakeup.c | 3 ++- 8 files changed, 22 insertions(+), 9 deletions(-) diff --git a/arch/mips/include/asm/netlogic/common.h b/arch/mips/include/asm/netlogic/common.h index 1b54adbd1583..bb68c3398c80 100644 --- a/arch/mips/include/asm/netlogic/common.h +++ b/arch/mips/include/asm/netlogic/common.h @@ -39,11 +39,17 @@ * Common SMP definitions */ #define RESET_VEC_PHYS 0x1fc00000 +#define RESET_VEC_SIZE 8192 /* 8KB reset code and data */ #define RESET_DATA_PHYS (RESET_VEC_PHYS + (1<<10)) + +/* Offsets of parameters in the RESET_DATA_PHYS area */ #define BOOT_THREAD_MODE 0 #define BOOT_NMI_LOCK 4 #define BOOT_NMI_HANDLER 8 +/* CPU ready flags for each CPU */ +#define BOOT_CPU_READY 2048 + #ifndef __ASSEMBLY__ #include #include diff --git a/arch/mips/netlogic/common/reset.S b/arch/mips/netlogic/common/reset.S index 98691d6b3bbe..b11691c629d0 100644 --- a/arch/mips/netlogic/common/reset.S +++ b/arch/mips/netlogic/common/reset.S @@ -216,8 +216,10 @@ EXPORT(nlm_boot_siblings) ori t1, ST0_KX #endif mtc0 t1, CP0_STATUS - /* mark CPU ready */ - PTR_LA t1, nlm_cpu_ready + + /* mark CPU ready, careful here, previous mtcr trashed registers */ + li t3, CKSEG1ADDR(RESET_DATA_PHYS) + ADDIU t1, t3, BOOT_CPU_READY sll v1, v0, 2 PTR_ADDU t1, v1 li t2, 1 diff --git a/arch/mips/netlogic/common/smp.c b/arch/mips/netlogic/common/smp.c index 1f66eef3aea7..885d293b61da 100644 --- a/arch/mips/netlogic/common/smp.c +++ b/arch/mips/netlogic/common/smp.c @@ -145,7 +145,6 @@ void nlm_cpus_done(void) * Boot all other cpus in the system, initialize them, and bring them into * the boot function */ -int nlm_cpu_ready[NR_CPUS]; unsigned long nlm_next_gp; unsigned long nlm_next_sp; static cpumask_t phys_cpu_present_mask; @@ -168,6 +167,7 @@ void __init nlm_smp_setup(void) { unsigned int boot_cpu; int num_cpus, i, ncore; + volatile u32 *cpu_ready = nlm_get_boot_data(BOOT_CPU_READY); char buf[64]; boot_cpu = hard_smp_processor_id(); @@ -181,10 +181,10 @@ void __init nlm_smp_setup(void) num_cpus = 1; for (i = 0; i < NR_CPUS; i++) { /* - * nlm_cpu_ready array is not set for the boot_cpu, + * cpu_ready array is not set for the boot_cpu, * it is only set for ASPs (see smpboot.S) */ - if (nlm_cpu_ready[i]) { + if (cpu_ready[i]) { cpumask_set_cpu(i, &phys_cpu_present_mask); __cpu_number_map[i] = num_cpus; __cpu_logical_map[num_cpus] = i; diff --git a/arch/mips/netlogic/common/smpboot.S b/arch/mips/netlogic/common/smpboot.S index 7c7e884f8912..6029d1b37f88 100644 --- a/arch/mips/netlogic/common/smpboot.S +++ b/arch/mips/netlogic/common/smpboot.S @@ -109,8 +109,9 @@ NESTED(nlm_rmiboot_preboot, 16, sp) andi t2, t0, 0x3 /* thread num */ sll t0, 2 /* offset in cpu array */ - PTR_LA t1, nlm_cpu_ready /* mark CPU ready */ - PTR_ADDU t1, t0 + li t3, CKSEG1ADDR(RESET_DATA_PHYS) + ADDIU t1, t3, BOOT_CPU_READY + ADDU t1, t0 li t3, 1 sw t3, 0(t1) diff --git a/arch/mips/netlogic/xlp/setup.c b/arch/mips/netlogic/xlp/setup.c index 5bdd354fef48..8f6992432f34 100644 --- a/arch/mips/netlogic/xlp/setup.c +++ b/arch/mips/netlogic/xlp/setup.c @@ -108,6 +108,7 @@ void __init prom_init(void) /* Update reset entry point with CPU init code */ reset_vec = (void *)CKSEG1ADDR(RESET_VEC_PHYS); + memset(reset_vec, 0, RESET_VEC_SIZE); memcpy(reset_vec, (void *)nlm_reset_entry, (nlm_reset_entry_end - nlm_reset_entry)); diff --git a/arch/mips/netlogic/xlp/wakeup.c b/arch/mips/netlogic/xlp/wakeup.c index abb3e08cc052..feb573670f90 100644 --- a/arch/mips/netlogic/xlp/wakeup.c +++ b/arch/mips/netlogic/xlp/wakeup.c @@ -82,6 +82,7 @@ static void xlp_enable_secondary_cores(const cpumask_t *wakeup_mask) struct nlm_soc_info *nodep; uint64_t syspcibase; uint32_t syscoremask; + volatile uint32_t *cpu_ready = nlm_get_boot_data(BOOT_CPU_READY); int core, n, cpu, count, val; for (n = 0; n < NLM_NR_NODES; n++) { @@ -125,7 +126,7 @@ static void xlp_enable_secondary_cores(const cpumask_t *wakeup_mask) /* spin until the first hw thread sets its ready */ count = 0x20000000; do { - val = *(volatile int *)&nlm_cpu_ready[cpu]; + val = cpu_ready[cpu]; } while (val == 0 && --count > 0); } } diff --git a/arch/mips/netlogic/xlr/setup.c b/arch/mips/netlogic/xlr/setup.c index 7e27f8591867..214d123b79fa 100644 --- a/arch/mips/netlogic/xlr/setup.c +++ b/arch/mips/netlogic/xlr/setup.c @@ -211,6 +211,7 @@ void __init prom_init(void) /* Update reset entry point with CPU init code */ reset_vec = (void *)CKSEG1ADDR(RESET_VEC_PHYS); + memset(reset_vec, 0, RESET_VEC_SIZE); memcpy(reset_vec, (void *)nlm_reset_entry, (nlm_reset_entry_end - nlm_reset_entry)); diff --git a/arch/mips/netlogic/xlr/wakeup.c b/arch/mips/netlogic/xlr/wakeup.c index 3ebf7411d67b..c06e4c9f0478 100644 --- a/arch/mips/netlogic/xlr/wakeup.c +++ b/arch/mips/netlogic/xlr/wakeup.c @@ -53,6 +53,7 @@ int __cpuinit xlr_wakeup_secondary_cpus(void) { struct nlm_soc_info *nodep; unsigned int i, j, boot_cpu; + volatile u32 *cpu_ready = nlm_get_boot_data(BOOT_CPU_READY); /* * In case of RMI boot, hit with NMI to get the cores @@ -71,7 +72,7 @@ int __cpuinit xlr_wakeup_secondary_cpus(void) nodep->coremask = 1; for (i = 1; i < NLM_CORES_PER_NODE; i++) { for (j = 1000000; j > 0; j--) { - if (nlm_cpu_ready[i * NLM_THREADS_PER_CORE]) + if (cpu_ready[i * NLM_THREADS_PER_CORE]) break; udelay(10); } From fd5f527cc58f7112f0d2c3cf2c29ae3ea5417de5 Mon Sep 17 00:00:00 2001 From: Jayachandran C Date: Mon, 10 Jun 2013 06:41:05 +0000 Subject: [PATCH 0202/1048] MIPS: Netlogic: use branch instead of jump Fix an issue in the reset code. Since this code is copied to the reset vector, using 'j' for looping is not correct. Use relative branch 'b'. Update the usage of 'j' in smpboot.S to be consistent although it is not a bug there. Signed-off-by: Jayachandran C Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/5427/ Signed-off-by: Ralf Baechle --- arch/mips/netlogic/common/reset.S | 2 +- arch/mips/netlogic/common/smpboot.S | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/mips/netlogic/common/reset.S b/arch/mips/netlogic/common/reset.S index b11691c629d0..0ebd50a1d618 100644 --- a/arch/mips/netlogic/common/reset.S +++ b/arch/mips/netlogic/common/reset.S @@ -226,7 +226,7 @@ EXPORT(nlm_boot_siblings) sw t2, 0(t1) /* Wait until NMI hits */ 3: wait - j 3b + b 3b nop /* diff --git a/arch/mips/netlogic/common/smpboot.S b/arch/mips/netlogic/common/smpboot.S index 6029d1b37f88..528c46c5a170 100644 --- a/arch/mips/netlogic/common/smpboot.S +++ b/arch/mips/netlogic/common/smpboot.S @@ -137,7 +137,7 @@ NESTED(nlm_rmiboot_preboot, 16, sp) mtcr t1, t0 /* update core control */ 1: wait - j 1b + b 1b nop END(nlm_rmiboot_preboot) __FINIT From 9f1f1e7b8b76d8503673a3777b3ee743d8c50e13 Mon Sep 17 00:00:00 2001 From: Jayachandran C Date: Mon, 10 Jun 2013 06:41:06 +0000 Subject: [PATCH 0203/1048] MIPS: Netlogic: Fix sign extension in PIC write This does not cause a problem yet, but we do not want to write 1 to reserved bits. Signed-off-by: Jayachandran C Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/5424/ Signed-off-by: Ralf Baechle --- arch/mips/include/asm/netlogic/xlp-hal/pic.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/mips/include/asm/netlogic/xlp-hal/pic.h b/arch/mips/include/asm/netlogic/xlp-hal/pic.h index a981f4681a15..4b5108dfaa16 100644 --- a/arch/mips/include/asm/netlogic/xlp-hal/pic.h +++ b/arch/mips/include/asm/netlogic/xlp-hal/pic.h @@ -315,7 +315,7 @@ nlm_pic_send_ipi(uint64_t base, int hwt, int irq, int nmi) { uint64_t ipi; - ipi = (nmi << 31) | (irq << 20); + ipi = ((uint64_t)nmi << 31) | (irq << 20); ipi |= ((hwt >> 4) << 16) | (1 << (hwt & 0xf)); /* cpuset and mask */ nlm_write_pic_reg(base, PIC_IPI_CTL, ipi); } From 4033d38ceb9d84ed66b925c1740c1a88f8a4a8f9 Mon Sep 17 00:00:00 2001 From: Jayachandran C Date: Mon, 10 Jun 2013 06:41:07 +0000 Subject: [PATCH 0204/1048] MIPS: Netlogic: wait for all hardware threads Earlier we just waited for the first thread of the CPU to come online before proceeding to wake up others. Update it to wait for all the CPUs in the core. This will be useful when the boot-up is slow, like while debugging or when running in a simulator. Signed-off-by: Jayachandran C Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/5429/ Signed-off-by: Ralf Baechle --- arch/mips/netlogic/xlp/wakeup.c | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/arch/mips/netlogic/xlp/wakeup.c b/arch/mips/netlogic/xlp/wakeup.c index feb573670f90..0cce37cbffef 100644 --- a/arch/mips/netlogic/xlp/wakeup.c +++ b/arch/mips/netlogic/xlp/wakeup.c @@ -77,13 +77,28 @@ static int xlp_wakeup_core(uint64_t sysbase, int node, int core) return count != 0; } +static int wait_for_cpus(int cpu, int bootcpu) +{ + volatile uint32_t *cpu_ready = nlm_get_boot_data(BOOT_CPU_READY); + int i, count, notready; + + count = 0x20000000; + do { + notready = nlm_threads_per_core; + for (i = 0; i < nlm_threads_per_core; i++) + if (cpu_ready[cpu + i] || cpu == bootcpu) + --notready; + } while (notready != 0 && --count > 0); + + return count != 0; +} + static void xlp_enable_secondary_cores(const cpumask_t *wakeup_mask) { struct nlm_soc_info *nodep; uint64_t syspcibase; uint32_t syscoremask; - volatile uint32_t *cpu_ready = nlm_get_boot_data(BOOT_CPU_READY); - int core, n, cpu, count, val; + int core, n, cpu; for (n = 0; n < NLM_NR_NODES; n++) { syspcibase = nlm_get_sys_pcibase(n); @@ -123,11 +138,8 @@ static void xlp_enable_secondary_cores(const cpumask_t *wakeup_mask) /* core is up */ nodep->coremask |= 1u << core; - /* spin until the first hw thread sets its ready */ - count = 0x20000000; - do { - val = cpu_ready[cpu]; - } while (val == 0 && --count > 0); + /* spin until the hw threads sets their ready */ + wait_for_cpus(cpu, 0); } } } @@ -139,6 +151,7 @@ void xlp_wakeup_secondary_cpus() * first wakeup core 0 threads */ xlp_boot_core0_siblings(); + wait_for_cpus(0, 0); /* now get other cores out of reset */ xlp_enable_secondary_cores(&nlm_cpumask); From 722138340b9f08d081255ba50928831a972c2e6f Mon Sep 17 00:00:00 2001 From: Jayachandran C Date: Mon, 10 Jun 2013 06:41:08 +0000 Subject: [PATCH 0205/1048] MIPS: Netlogic: Fixup memory regions for prefetch Fix a cache error found in stress test, caused by the prefetch instruction going beyond valid memory when acessing the last page of a region. Add the pref_backup logic similar to XLR in XLP too. Signed-off-by: Jayachandran C Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/5431/ Signed-off-by: Ralf Baechle --- arch/mips/netlogic/xlp/setup.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/arch/mips/netlogic/xlp/setup.c b/arch/mips/netlogic/xlp/setup.c index 8f6992432f34..7b638f7be491 100644 --- a/arch/mips/netlogic/xlp/setup.c +++ b/arch/mips/netlogic/xlp/setup.c @@ -61,6 +61,18 @@ static void nlm_linux_exit(void) cpu_wait(); } +static void nlm_fixup_mem(void) +{ + const int pref_backup = 512; + int i; + + for (i = 0; i < boot_mem_map.nr_map; i++) { + if (boot_mem_map.map[i].type != BOOT_MEM_RAM) + continue; + boot_mem_map.map[i].size -= pref_backup; + } +} + void __init plat_mem_setup(void) { panic_timeout = 5; @@ -70,6 +82,7 @@ void __init plat_mem_setup(void) /* memory and bootargs from DT */ early_init_devtree(initial_boot_params); + nlm_fixup_mem(); } const char *get_system_type(void) From 6099115e7e5e2c49d3822e093ca7df7015ca57a9 Mon Sep 17 00:00:00 2001 From: Jayachandran C Date: Mon, 10 Jun 2013 06:41:09 +0000 Subject: [PATCH 0206/1048] MIPS: Netlogic: Remove workarounds for early SoCs The XLPs in production do not need these workarounds. Remove the code and the associated ifdef. Signed-off-by: Jayachandran C Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/5430/ Signed-off-by: Ralf Baechle --- arch/mips/netlogic/common/reset.S | 23 +---------------------- 1 file changed, 1 insertion(+), 22 deletions(-) diff --git a/arch/mips/netlogic/common/reset.S b/arch/mips/netlogic/common/reset.S index 0ebd50a1d618..adb18288a6c0 100644 --- a/arch/mips/netlogic/common/reset.S +++ b/arch/mips/netlogic/common/reset.S @@ -54,8 +54,6 @@ XLP_IO_SYS_OFFSET(node) + XLP_IO_PCI_HDRSZ + \ SYS_CPU_NONCOHERENT_MODE * 4 -#define XLP_AX_WORKAROUND /* enable Ax silicon workarounds */ - /* Enable XLP features and workarounds in the LSU */ .macro xlp_config_lsu li t0, LSU_DEFEATURE @@ -63,10 +61,6 @@ lui t2, 0xc080 /* SUE, Enable Unaligned Access, L2HPE */ or t1, t1, t2 -#ifdef XLP_AX_WORKAROUND - li t2, ~0xe /* S1RCM */ - and t1, t1, t2 -#endif mtcr t1, t0 li t0, ICU_DEFEATURE @@ -74,12 +68,9 @@ ori t1, 0x1000 /* Enable Icache partitioning */ mtcr t1, t0 - -#ifdef XLP_AX_WORKAROUND li t0, SCHED_DEFEATURE lui t1, 0x0100 /* Disable BRU accepting ALU ops */ mtcr t1, t0 -#endif .endm /* @@ -195,19 +186,7 @@ EXPORT(nlm_boot_siblings) mfc0 v0, CP0_EBASE, 1 andi v0, 0x3ff /* v0 <- node/core */ - /* Init MMU in the first thread after changing THREAD_MODE - * register (Ax Errata?) - */ - andi v1, v0, 0x3 /* v1 <- thread id */ - bnez v1, 2f - nop - - li t0, MMU_SETUP - li t1, 0 - mtcr t1, t0 - _ehb - -2: beqz v0, 4f /* boot cpu (cpuid == 0)? */ + beqz v0, 4f /* boot cpu (cpuid == 0)? */ nop /* setup status reg */ From 8ecd08378c132536c7d47af225e09bd6f3a16779 Mon Sep 17 00:00:00 2001 From: Jayachandran C Date: Mon, 10 Jun 2013 06:41:10 +0000 Subject: [PATCH 0207/1048] MIPS: Netlogic: Fix plat_irq_dispatch Fix an issue in plat_irq_dispatch due to which it can call do_IRQ with a PIC irq that is not mapped. When a per-cpu interrupt and a PIC interrupt are both active, the check 'eirr & PERCPU_IRQ_MASK' will be true, but the interrupt in 'i' will be the number of the PIC interrupt. In this case, we will call do_IRQ on the PIC interrupt without mapping it with nlm_irq_to_xirq(). Fix this by using __ffs64 instead of __ilog2_u64 and using the interrupt number instead of mask to identify per-cpu interrupts. Signed-off-by: Jayachandran C Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/5432/ Signed-off-by: Ralf Baechle --- arch/mips/netlogic/common/irq.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/arch/mips/netlogic/common/irq.c b/arch/mips/netlogic/common/irq.c index 9f84c60bf535..73facb2b33bb 100644 --- a/arch/mips/netlogic/common/irq.c +++ b/arch/mips/netlogic/common/irq.c @@ -253,13 +253,12 @@ asmlinkage void plat_irq_dispatch(void) node = nlm_nodeid(); eirr = read_c0_eirr_and_eimr(); - - i = __ilog2_u64(eirr); - if (i == -1) + if (eirr == 0) return; + i = __ffs64(eirr); /* per-CPU IRQs don't need translation */ - if (eirr & PERCPU_IRQ_MASK) { + if (i < PIC_IRQ_BASE) { do_IRQ(i); return; } From 7777b9395b77664cb736b941f95fb8f656edd111 Mon Sep 17 00:00:00 2001 From: Jayachandran C Date: Tue, 11 Jun 2013 14:41:35 +0000 Subject: [PATCH 0208/1048] MIPS: Allow platform specific scratch registers XLR/XLP COP0 scratch is register 22, sel 0-7. Add a function c0_kscratch() which returns the scratch register for the platform, and use the return value while generating TLB handlers. Setup kscratch_mask to 0xf for XLR/XLP since the config4 register does not exist. This allows the kernel to allocate scratch registers 0-3 if needed. Signed-off-by: Jayachandran C Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/5445/ Signed-off-by: Ralf Baechle --- arch/mips/kernel/cpu-probe.c | 1 + arch/mips/mm/tlbex.c | 41 +++++++++++++++++++++++------------- 2 files changed, 27 insertions(+), 15 deletions(-) diff --git a/arch/mips/kernel/cpu-probe.c b/arch/mips/kernel/cpu-probe.c index c6568bf4b1b0..265c97da6619 100644 --- a/arch/mips/kernel/cpu-probe.c +++ b/arch/mips/kernel/cpu-probe.c @@ -959,6 +959,7 @@ static inline void cpu_probe_netlogic(struct cpuinfo_mips *c, int cpu) set_isa(c, MIPS_CPU_ISA_M64R1); c->tlbsize = ((read_c0_config1() >> 25) & 0x3f) + 1; } + c->kscratch_mask = 0xf; } #ifdef CONFIG_64BIT diff --git a/arch/mips/mm/tlbex.c b/arch/mips/mm/tlbex.c index afeef93f81a7..c052df8ae7d7 100644 --- a/arch/mips/mm/tlbex.c +++ b/arch/mips/mm/tlbex.c @@ -305,6 +305,17 @@ static int check_for_high_segbits __cpuinitdata; static unsigned int kscratch_used_mask __cpuinitdata; +static inline int __maybe_unused c0_kscratch(void) +{ + switch (current_cpu_type()) { + case CPU_XLP: + case CPU_XLR: + return 22; + default: + return 31; + } +} + static int __cpuinit allocate_kscratch(void) { int r; @@ -336,7 +347,7 @@ static struct work_registers __cpuinit build_get_work_registers(u32 **p) if (scratch_reg > 0) { /* Save in CPU local C0_KScratch? */ - UASM_i_MTC0(p, 1, 31, scratch_reg); + UASM_i_MTC0(p, 1, c0_kscratch(), scratch_reg); r.r1 = K0; r.r2 = K1; r.r3 = 1; @@ -385,7 +396,7 @@ static struct work_registers __cpuinit build_get_work_registers(u32 **p) static void __cpuinit build_restore_work_registers(u32 **p) { if (scratch_reg > 0) { - UASM_i_MFC0(p, 1, 31, scratch_reg); + UASM_i_MFC0(p, 1, c0_kscratch(), scratch_reg); return; } /* K0 already points to save area, restore $1 and $2 */ @@ -674,7 +685,7 @@ static __cpuinit void build_restore_pagemask(u32 **p, uasm_il_b(p, r, lid); } if (scratch_reg > 0) - UASM_i_MFC0(p, 1, 31, scratch_reg); + UASM_i_MFC0(p, 1, c0_kscratch(), scratch_reg); else UASM_i_LW(p, 1, scratchpad_offset(0), 0); } else { @@ -817,7 +828,7 @@ build_get_pmde64(u32 **p, struct uasm_label **l, struct uasm_reloc **r, #ifdef CONFIG_MIPS_PGD_C0_CONTEXT if (pgd_reg != -1) { /* pgd is in pgd_reg */ - UASM_i_MFC0(p, ptr, 31, pgd_reg); + UASM_i_MFC0(p, ptr, c0_kscratch(), pgd_reg); } else { /* * &pgd << 11 stored in CONTEXT [23..63]. @@ -930,7 +941,7 @@ build_get_pgd_vmalloc64(u32 **p, struct uasm_label **l, struct uasm_reloc **r, if (mode == refill_scratch) { if (scratch_reg > 0) - UASM_i_MFC0(p, 1, 31, scratch_reg); + UASM_i_MFC0(p, 1, c0_kscratch(), scratch_reg); else UASM_i_LW(p, 1, scratchpad_offset(0), 0); } else { @@ -1096,7 +1107,7 @@ struct mips_huge_tlb_info { static struct mips_huge_tlb_info __cpuinit build_fast_tlb_refill_handler (u32 **p, struct uasm_label **l, struct uasm_reloc **r, unsigned int tmp, - unsigned int ptr, int c0_scratch) + unsigned int ptr, int c0_scratch_reg) { struct mips_huge_tlb_info rv; unsigned int even, odd; @@ -1110,12 +1121,12 @@ build_fast_tlb_refill_handler (u32 **p, struct uasm_label **l, UASM_i_MFC0(p, tmp, C0_BADVADDR); if (pgd_reg != -1) - UASM_i_MFC0(p, ptr, 31, pgd_reg); + UASM_i_MFC0(p, ptr, c0_kscratch(), pgd_reg); else UASM_i_MFC0(p, ptr, C0_CONTEXT); - if (c0_scratch >= 0) - UASM_i_MTC0(p, scratch, 31, c0_scratch); + if (c0_scratch_reg >= 0) + UASM_i_MTC0(p, scratch, c0_kscratch(), c0_scratch_reg); else UASM_i_SW(p, scratch, scratchpad_offset(0), 0); @@ -1130,14 +1141,14 @@ build_fast_tlb_refill_handler (u32 **p, struct uasm_label **l, } } else { if (pgd_reg != -1) - UASM_i_MFC0(p, ptr, 31, pgd_reg); + UASM_i_MFC0(p, ptr, c0_kscratch(), pgd_reg); else UASM_i_MFC0(p, ptr, C0_CONTEXT); UASM_i_MFC0(p, tmp, C0_BADVADDR); - if (c0_scratch >= 0) - UASM_i_MTC0(p, scratch, 31, c0_scratch); + if (c0_scratch_reg >= 0) + UASM_i_MTC0(p, scratch, c0_kscratch(), c0_scratch_reg); else UASM_i_SW(p, scratch, scratchpad_offset(0), 0); @@ -1242,8 +1253,8 @@ build_fast_tlb_refill_handler (u32 **p, struct uasm_label **l, } UASM_i_MTC0(p, odd, C0_ENTRYLO1); /* load it */ - if (c0_scratch >= 0) { - UASM_i_MFC0(p, scratch, 31, c0_scratch); + if (c0_scratch_reg >= 0) { + UASM_i_MFC0(p, scratch, c0_kscratch(), c0_scratch_reg); build_tlb_write_entry(p, l, r, tlb_random); uasm_l_leave(l, *p); rv.restore_scratch = 1; @@ -1490,7 +1501,7 @@ static void __cpuinit build_r4000_setup_pgd(void) } else { /* PGD in c0_KScratch */ uasm_i_jr(&p, 31); - UASM_i_MTC0(&p, a0, 31, pgd_reg); + UASM_i_MTC0(&p, a0, c0_kscratch(), pgd_reg); } if (p - tlbmiss_handler_setup_pgd_array > ARRAY_SIZE(tlbmiss_handler_setup_pgd_array)) panic("tlbmiss_handler_setup_pgd_array space exceeded"); From 0e6ecc1a9aa7cbf991d9711a12cae2b4853ef718 Mon Sep 17 00:00:00 2001 From: Jayachandran C Date: Tue, 11 Jun 2013 14:41:36 +0000 Subject: [PATCH 0209/1048] MIPS: Fixup check for invalid scratch register The invalid value for scratch register is -1, so update the checks of the form (scratch_reg > 0) to be (scratch_reg >= 0). This will fix the case in Netlogic XLP where the scratch_reg can be 0. Signed-off-by: Jayachandran C Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/5444/ Signed-off-by: Ralf Baechle --- arch/mips/mm/tlbex.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/arch/mips/mm/tlbex.c b/arch/mips/mm/tlbex.c index c052df8ae7d7..9b988c050fdd 100644 --- a/arch/mips/mm/tlbex.c +++ b/arch/mips/mm/tlbex.c @@ -345,7 +345,7 @@ static struct work_registers __cpuinit build_get_work_registers(u32 **p) int smp_processor_id_sel; int smp_processor_id_shift; - if (scratch_reg > 0) { + if (scratch_reg >= 0) { /* Save in CPU local C0_KScratch? */ UASM_i_MTC0(p, 1, c0_kscratch(), scratch_reg); r.r1 = K0; @@ -395,7 +395,7 @@ static struct work_registers __cpuinit build_get_work_registers(u32 **p) static void __cpuinit build_restore_work_registers(u32 **p) { - if (scratch_reg > 0) { + if (scratch_reg >= 0) { UASM_i_MFC0(p, 1, c0_kscratch(), scratch_reg); return; } @@ -684,7 +684,7 @@ static __cpuinit void build_restore_pagemask(u32 **p, uasm_i_mtc0(p, 0, C0_PAGEMASK); uasm_il_b(p, r, lid); } - if (scratch_reg > 0) + if (scratch_reg >= 0) UASM_i_MFC0(p, 1, c0_kscratch(), scratch_reg); else UASM_i_LW(p, 1, scratchpad_offset(0), 0); @@ -940,7 +940,7 @@ build_get_pgd_vmalloc64(u32 **p, struct uasm_label **l, struct uasm_reloc **r, uasm_i_jr(p, ptr); if (mode == refill_scratch) { - if (scratch_reg > 0) + if (scratch_reg >= 0) UASM_i_MFC0(p, 1, c0_kscratch(), scratch_reg); else UASM_i_LW(p, 1, scratchpad_offset(0), 0); @@ -1297,7 +1297,7 @@ static void __cpuinit build_r4000_tlb_refill_handler(void) memset(relocs, 0, sizeof(relocs)); memset(final_handler, 0, sizeof(final_handler)); - if ((scratch_reg > 0 || scratchpad_available()) && use_bbit_insns()) { + if ((scratch_reg >= 0 || scratchpad_available()) && use_bbit_insns()) { htlb_info = build_fast_tlb_refill_handler(&p, &l, &r, K0, K1, scratch_reg); vmalloc_mode = refill_scratch; From abca2056dc3dd0d813ba2f8b013e98cf009ba168 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Wed, 29 May 2013 06:59:35 -0300 Subject: [PATCH 0210/1048] [media] v4l2: remove g_chip_ident from bridge drivers where it is easy to do so VIDIOC_DBG_G_CHIP_IDENT has been replaced by VIDIOC_DBG_G_CHIP_INFO. Remove g_chip_ident support from bridge drivers since it is no longer needed. This patch takes care of all the trivial cases. Signed-off-by: Hans Verkuil Acked-by: Lad, Prabhakar Acked-by: Scott Jiang Signed-off-by: Mauro Carvalho Chehab --- drivers/media/common/saa7146/saa7146_video.c | 23 ------- drivers/media/pci/bt8xx/bttv-driver.c | 38 ----------- drivers/media/pci/saa7134/saa7134-empress.c | 17 ----- drivers/media/pci/saa7134/saa7134-video.c | 4 -- drivers/media/pci/saa7146/mxb.c | 15 ++--- drivers/media/pci/saa7164/saa7164-encoder.c | 37 ----------- drivers/media/pci/saa7164/saa7164-vbi.c | 9 --- drivers/media/pci/saa7164/saa7164.h | 1 - .../media/platform/blackfin/bfin_capture.c | 41 ------------ drivers/media/platform/davinci/vpif_capture.c | 66 ------------------- drivers/media/platform/davinci/vpif_display.c | 66 ------------------- drivers/media/platform/sh_vou.c | 31 --------- .../media/platform/soc_camera/soc_camera.c | 34 ---------- drivers/media/platform/via-camera.c | 16 ----- drivers/media/radio/radio-si476x.c | 11 ---- drivers/media/usb/au0828/au0828-video.c | 39 ----------- drivers/media/usb/em28xx/em28xx-video.c | 66 ++----------------- drivers/media/usb/stk1160/stk1160-v4l.c | 41 ------------ 18 files changed, 10 insertions(+), 545 deletions(-) diff --git a/drivers/media/common/saa7146/saa7146_video.c b/drivers/media/common/saa7146/saa7146_video.c index fe907f2e8f59..30779498c173 100644 --- a/drivers/media/common/saa7146/saa7146_video.c +++ b/drivers/media/common/saa7146/saa7146_video.c @@ -1,7 +1,6 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #include -#include #include #include #include @@ -988,26 +987,6 @@ static int vidioc_streamoff(struct file *file, void *__fh, enum v4l2_buf_type ty return err; } -static int vidioc_g_chip_ident(struct file *file, void *__fh, - struct v4l2_dbg_chip_ident *chip) -{ - struct saa7146_fh *fh = __fh; - struct saa7146_dev *dev = fh->dev; - - chip->ident = V4L2_IDENT_NONE; - chip->revision = 0; - if (chip->match.type == V4L2_CHIP_MATCH_HOST) { - if (v4l2_chip_match_host(&chip->match)) - chip->ident = V4L2_IDENT_SAA7146; - return 0; - } - if (chip->match.type != V4L2_CHIP_MATCH_I2C_DRIVER && - chip->match.type != V4L2_CHIP_MATCH_I2C_ADDR) - return -EINVAL; - return v4l2_device_call_until_err(&dev->v4l2_dev, 0, - core, g_chip_ident, chip); -} - const struct v4l2_ioctl_ops saa7146_video_ioctl_ops = { .vidioc_querycap = vidioc_querycap, .vidioc_enum_fmt_vid_cap = vidioc_enum_fmt_vid_cap, @@ -1018,7 +997,6 @@ const struct v4l2_ioctl_ops saa7146_video_ioctl_ops = { .vidioc_g_fmt_vid_overlay = vidioc_g_fmt_vid_overlay, .vidioc_try_fmt_vid_overlay = vidioc_try_fmt_vid_overlay, .vidioc_s_fmt_vid_overlay = vidioc_s_fmt_vid_overlay, - .vidioc_g_chip_ident = vidioc_g_chip_ident, .vidioc_overlay = vidioc_overlay, .vidioc_g_fbuf = vidioc_g_fbuf, @@ -1039,7 +1017,6 @@ const struct v4l2_ioctl_ops saa7146_video_ioctl_ops = { const struct v4l2_ioctl_ops saa7146_vbi_ioctl_ops = { .vidioc_querycap = vidioc_querycap, .vidioc_g_fmt_vbi_cap = vidioc_g_fmt_vbi_cap, - .vidioc_g_chip_ident = vidioc_g_chip_ident, .vidioc_reqbufs = vidioc_reqbufs, .vidioc_querybuf = vidioc_querybuf, diff --git a/drivers/media/pci/bt8xx/bttv-driver.c b/drivers/media/pci/bt8xx/bttv-driver.c index a334c94a303d..bfcfa3e8543e 100644 --- a/drivers/media/pci/bt8xx/bttv-driver.c +++ b/drivers/media/pci/bt8xx/bttv-driver.c @@ -50,7 +50,6 @@ #include #include #include -#include #include #include @@ -1907,28 +1906,6 @@ static int bttv_log_status(struct file *file, void *f) return 0; } -static int bttv_g_chip_ident(struct file *file, void *f, struct v4l2_dbg_chip_ident *chip) -{ - struct bttv_fh *fh = f; - struct bttv *btv = fh->btv; - - chip->ident = V4L2_IDENT_NONE; - chip->revision = 0; - if (chip->match.type == V4L2_CHIP_MATCH_HOST) { - if (v4l2_chip_match_host(&chip->match)) { - chip->ident = btv->id; - if (chip->ident == PCI_DEVICE_ID_FUSION879) - chip->ident = V4L2_IDENT_BT879; - } - return 0; - } - if (chip->match.type != V4L2_CHIP_MATCH_I2C_DRIVER && - chip->match.type != V4L2_CHIP_MATCH_I2C_ADDR) - return -EINVAL; - /* TODO: is this correct? */ - return bttv_call_all_err(btv, core, g_chip_ident, chip); -} - #ifdef CONFIG_VIDEO_ADV_DEBUG static int bttv_g_register(struct file *file, void *f, struct v4l2_dbg_register *reg) @@ -1936,13 +1913,6 @@ static int bttv_g_register(struct file *file, void *f, struct bttv_fh *fh = f; struct bttv *btv = fh->btv; - if (!v4l2_chip_match_host(®->match)) { - /* TODO: subdev errors should not be ignored, this should become a - subdev helper function. */ - bttv_call_all(btv, core, g_register, reg); - return 0; - } - /* bt848 has a 12-bit register space */ reg->reg &= 0xfff; reg->val = btread(reg->reg); @@ -1957,13 +1927,6 @@ static int bttv_s_register(struct file *file, void *f, struct bttv_fh *fh = f; struct bttv *btv = fh->btv; - if (!v4l2_chip_match_host(®->match)) { - /* TODO: subdev errors should not be ignored, this should become a - subdev helper function. */ - bttv_call_all(btv, core, s_register, reg); - return 0; - } - /* bt848 has a 12-bit register space */ btwrite(reg->val, reg->reg & 0xfff); @@ -3203,7 +3166,6 @@ static const struct v4l2_ioctl_ops bttv_ioctl_ops = { .vidioc_querystd = bttv_querystd, .vidioc_subscribe_event = v4l2_ctrl_subscribe_event, .vidioc_unsubscribe_event = v4l2_event_unsubscribe, - .vidioc_g_chip_ident = bttv_g_chip_ident, #ifdef CONFIG_VIDEO_ADV_DEBUG .vidioc_g_register = bttv_g_register, .vidioc_s_register = bttv_s_register, diff --git a/drivers/media/pci/saa7134/saa7134-empress.c b/drivers/media/pci/saa7134/saa7134-empress.c index 66a70814004c..05ab2cb7ef3c 100644 --- a/drivers/media/pci/saa7134/saa7134-empress.c +++ b/drivers/media/pci/saa7134/saa7134-empress.c @@ -28,7 +28,6 @@ #include #include -#include /* ------------------------------------------------------------------ */ @@ -413,21 +412,6 @@ static int empress_querymenu(struct file *file, void *priv, return saa_call_empress(dev, core, querymenu, c); } -static int empress_g_chip_ident(struct file *file, void *fh, - struct v4l2_dbg_chip_ident *chip) -{ - struct saa7134_dev *dev = file->private_data; - - chip->ident = V4L2_IDENT_NONE; - chip->revision = 0; - if (chip->match.type == V4L2_CHIP_MATCH_I2C_DRIVER && - !strcmp(chip->match.name, "saa6752hs")) - return saa_call_empress(dev, core, g_chip_ident, chip); - if (chip->match.type == V4L2_CHIP_MATCH_I2C_ADDR) - return saa_call_empress(dev, core, g_chip_ident, chip); - return -EINVAL; -} - static int empress_s_std(struct file *file, void *priv, v4l2_std_id id) { struct saa7134_dev *dev = file->private_data; @@ -475,7 +459,6 @@ static const struct v4l2_ioctl_ops ts_ioctl_ops = { .vidioc_querymenu = empress_querymenu, .vidioc_g_ctrl = empress_g_ctrl, .vidioc_s_ctrl = empress_s_ctrl, - .vidioc_g_chip_ident = empress_g_chip_ident, .vidioc_s_std = empress_s_std, .vidioc_g_std = empress_g_std, }; diff --git a/drivers/media/pci/saa7134/saa7134-video.c b/drivers/media/pci/saa7134/saa7134-video.c index cc409380ee16..737e643be27a 100644 --- a/drivers/media/pci/saa7134/saa7134-video.c +++ b/drivers/media/pci/saa7134/saa7134-video.c @@ -2258,8 +2258,6 @@ static int vidioc_g_register (struct file *file, void *priv, struct saa7134_fh *fh = priv; struct saa7134_dev *dev = fh->dev; - if (!v4l2_chip_match_host(®->match)) - return -EINVAL; reg->val = saa_readb(reg->reg); reg->size = 1; return 0; @@ -2271,8 +2269,6 @@ static int vidioc_s_register (struct file *file, void *priv, struct saa7134_fh *fh = priv; struct saa7134_dev *dev = fh->dev; - if (!v4l2_chip_match_host(®->match)) - return -EINVAL; saa_writeb(reg->reg&0xffffff, reg->val); return 0; } diff --git a/drivers/media/pci/saa7146/mxb.c b/drivers/media/pci/saa7146/mxb.c index 52cbe7a027cc..8d177691cd7c 100644 --- a/drivers/media/pci/saa7146/mxb.c +++ b/drivers/media/pci/saa7146/mxb.c @@ -669,12 +669,8 @@ static int vidioc_g_register(struct file *file, void *fh, struct v4l2_dbg_regist { struct saa7146_dev *dev = ((struct saa7146_fh *)fh)->dev; - if (v4l2_chip_match_host(®->match)) { - reg->val = saa7146_read(dev, reg->reg); - reg->size = 4; - return 0; - } - call_all(dev, core, g_register, reg); + reg->val = saa7146_read(dev, reg->reg); + reg->size = 4; return 0; } @@ -682,11 +678,8 @@ static int vidioc_s_register(struct file *file, void *fh, const struct v4l2_dbg_ { struct saa7146_dev *dev = ((struct saa7146_fh *)fh)->dev; - if (v4l2_chip_match_host(®->match)) { - saa7146_write(dev, reg->reg, reg->val); - return 0; - } - return call_all(dev, core, s_register, reg); + saa7146_write(dev, reg->reg, reg->val); + return 0; } #endif diff --git a/drivers/media/pci/saa7164/saa7164-encoder.c b/drivers/media/pci/saa7164/saa7164-encoder.c index 63a72fb71f30..e4f53a55eab1 100644 --- a/drivers/media/pci/saa7164/saa7164-encoder.c +++ b/drivers/media/pci/saa7164/saa7164-encoder.c @@ -1288,38 +1288,6 @@ static const struct v4l2_file_operations mpeg_fops = { .unlocked_ioctl = video_ioctl2, }; -static int saa7164_g_chip_ident(struct file *file, void *fh, - struct v4l2_dbg_chip_ident *chip) -{ - struct saa7164_port *port = ((struct saa7164_encoder_fh *)fh)->port; - struct saa7164_dev *dev = port->dev; - dprintk(DBGLVL_ENC, "%s()\n", __func__); - - return 0; -} - -#ifdef CONFIG_VIDEO_ADV_DEBUG -static int saa7164_g_register(struct file *file, void *fh, - struct v4l2_dbg_register *reg) -{ - struct saa7164_port *port = ((struct saa7164_encoder_fh *)fh)->port; - struct saa7164_dev *dev = port->dev; - dprintk(DBGLVL_ENC, "%s()\n", __func__); - - return 0; -} - -static int saa7164_s_register(struct file *file, void *fh, - const struct v4l2_dbg_register *reg) -{ - struct saa7164_port *port = ((struct saa7164_encoder_fh *)fh)->port; - struct saa7164_dev *dev = port->dev; - dprintk(DBGLVL_ENC, "%s()\n", __func__); - - return 0; -} -#endif - static const struct v4l2_ioctl_ops mpeg_ioctl_ops = { .vidioc_s_std = vidioc_s_std, .vidioc_enum_input = vidioc_enum_input, @@ -1340,11 +1308,6 @@ static const struct v4l2_ioctl_ops mpeg_ioctl_ops = { .vidioc_s_ext_ctrls = vidioc_s_ext_ctrls, .vidioc_try_ext_ctrls = vidioc_try_ext_ctrls, .vidioc_queryctrl = vidioc_queryctrl, - .vidioc_g_chip_ident = saa7164_g_chip_ident, -#ifdef CONFIG_VIDEO_ADV_DEBUG - .vidioc_g_register = saa7164_g_register, - .vidioc_s_register = saa7164_s_register, -#endif }; static struct video_device saa7164_mpeg_template = { diff --git a/drivers/media/pci/saa7164/saa7164-vbi.c b/drivers/media/pci/saa7164/saa7164-vbi.c index da224eb39b95..5a1a69b3dd15 100644 --- a/drivers/media/pci/saa7164/saa7164-vbi.c +++ b/drivers/media/pci/saa7164/saa7164-vbi.c @@ -1254,15 +1254,6 @@ static const struct v4l2_ioctl_ops vbi_ioctl_ops = { .vidioc_s_ext_ctrls = vidioc_s_ext_ctrls, .vidioc_try_ext_ctrls = vidioc_try_ext_ctrls, .vidioc_queryctrl = vidioc_queryctrl, -#if 0 - .vidioc_g_chip_ident = saa7164_g_chip_ident, -#endif -#ifdef CONFIG_VIDEO_ADV_DEBUG -#if 0 - .vidioc_g_register = saa7164_g_register, - .vidioc_s_register = saa7164_s_register, -#endif -#endif .vidioc_g_fmt_vbi_cap = saa7164_vbi_fmt, .vidioc_try_fmt_vbi_cap = saa7164_vbi_fmt, .vidioc_s_fmt_vbi_cap = saa7164_vbi_fmt, diff --git a/drivers/media/pci/saa7164/saa7164.h b/drivers/media/pci/saa7164/saa7164.h index 437284e747c9..8d9c7e692242 100644 --- a/drivers/media/pci/saa7164/saa7164.h +++ b/drivers/media/pci/saa7164/saa7164.h @@ -63,7 +63,6 @@ #include #include #include -#include #include "saa7164-reg.h" #include "saa7164-types.h" diff --git a/drivers/media/platform/blackfin/bfin_capture.c b/drivers/media/platform/blackfin/bfin_capture.c index ca8d56aecfb0..6652e71ea794 100644 --- a/drivers/media/platform/blackfin/bfin_capture.c +++ b/drivers/media/platform/blackfin/bfin_capture.c @@ -32,7 +32,6 @@ #include #include -#include #include #include #include @@ -876,41 +875,6 @@ static int bcap_s_parm(struct file *file, void *fh, return v4l2_subdev_call(bcap_dev->sd, video, s_parm, a); } -static int bcap_g_chip_ident(struct file *file, void *priv, - struct v4l2_dbg_chip_ident *chip) -{ - struct bcap_device *bcap_dev = video_drvdata(file); - - chip->ident = V4L2_IDENT_NONE; - chip->revision = 0; - if (chip->match.type != V4L2_CHIP_MATCH_I2C_DRIVER && - chip->match.type != V4L2_CHIP_MATCH_I2C_ADDR) - return -EINVAL; - - return v4l2_subdev_call(bcap_dev->sd, core, - g_chip_ident, chip); -} - -#ifdef CONFIG_VIDEO_ADV_DEBUG -static int bcap_dbg_g_register(struct file *file, void *priv, - struct v4l2_dbg_register *reg) -{ - struct bcap_device *bcap_dev = video_drvdata(file); - - return v4l2_subdev_call(bcap_dev->sd, core, - g_register, reg); -} - -static int bcap_dbg_s_register(struct file *file, void *priv, - const struct v4l2_dbg_register *reg) -{ - struct bcap_device *bcap_dev = video_drvdata(file); - - return v4l2_subdev_call(bcap_dev->sd, core, - s_register, reg); -} -#endif - static int bcap_log_status(struct file *file, void *priv) { struct bcap_device *bcap_dev = video_drvdata(file); @@ -943,11 +907,6 @@ static const struct v4l2_ioctl_ops bcap_ioctl_ops = { .vidioc_streamoff = bcap_streamoff, .vidioc_g_parm = bcap_g_parm, .vidioc_s_parm = bcap_s_parm, - .vidioc_g_chip_ident = bcap_g_chip_ident, -#ifdef CONFIG_VIDEO_ADV_DEBUG - .vidioc_g_register = bcap_dbg_g_register, - .vidioc_s_register = bcap_dbg_s_register, -#endif .vidioc_log_status = bcap_log_status, }; diff --git a/drivers/media/platform/davinci/vpif_capture.c b/drivers/media/platform/davinci/vpif_capture.c index caaf4fedadec..d004531e740d 100644 --- a/drivers/media/platform/davinci/vpif_capture.c +++ b/drivers/media/platform/davinci/vpif_capture.c @@ -24,7 +24,6 @@ #include #include -#include #include #include "vpif.h" @@ -1862,66 +1861,6 @@ static int vpif_g_dv_timings(struct file *file, void *priv, return 0; } -/* - * vpif_g_chip_ident() - Identify the chip - * @file: file ptr - * @priv: file handle - * @chip: chip identity - * - * Returns zero or -EINVAL if read operations fails. - */ -static int vpif_g_chip_ident(struct file *file, void *priv, - struct v4l2_dbg_chip_ident *chip) -{ - chip->ident = V4L2_IDENT_NONE; - chip->revision = 0; - if (chip->match.type != V4L2_CHIP_MATCH_I2C_DRIVER && - chip->match.type != V4L2_CHIP_MATCH_I2C_ADDR) { - vpif_dbg(2, debug, "match_type is invalid.\n"); - return -EINVAL; - } - - return v4l2_device_call_until_err(&vpif_obj.v4l2_dev, 0, core, - g_chip_ident, chip); -} - -#ifdef CONFIG_VIDEO_ADV_DEBUG -/* - * vpif_dbg_g_register() - Read register - * @file: file ptr - * @priv: file handle - * @reg: register to be read - * - * Debugging only - * Returns zero or -EINVAL if read operations fails. - */ -static int vpif_dbg_g_register(struct file *file, void *priv, - struct v4l2_dbg_register *reg){ - struct vpif_fh *fh = priv; - struct channel_obj *ch = fh->channel; - - return v4l2_subdev_call(ch->sd, core, g_register, reg); -} - -/* - * vpif_dbg_s_register() - Write to register - * @file: file ptr - * @priv: file handle - * @reg: register to be modified - * - * Debugging only - * Returns zero or -EINVAL if write operations fails. - */ -static int vpif_dbg_s_register(struct file *file, void *priv, - const struct v4l2_dbg_register *reg) -{ - struct vpif_fh *fh = priv; - struct channel_obj *ch = fh->channel; - - return v4l2_subdev_call(ch->sd, core, s_register, reg); -} -#endif - /* * vpif_log_status() - Status information * @file: file ptr @@ -1963,11 +1902,6 @@ static const struct v4l2_ioctl_ops vpif_ioctl_ops = { .vidioc_query_dv_timings = vpif_query_dv_timings, .vidioc_s_dv_timings = vpif_s_dv_timings, .vidioc_g_dv_timings = vpif_g_dv_timings, - .vidioc_g_chip_ident = vpif_g_chip_ident, -#ifdef CONFIG_VIDEO_ADV_DEBUG - .vidioc_g_register = vpif_dbg_g_register, - .vidioc_s_register = vpif_dbg_s_register, -#endif .vidioc_log_status = vpif_log_status, }; diff --git a/drivers/media/platform/davinci/vpif_display.c b/drivers/media/platform/davinci/vpif_display.c index 5b6f9065b881..6c521f23e40e 100644 --- a/drivers/media/platform/davinci/vpif_display.c +++ b/drivers/media/platform/davinci/vpif_display.c @@ -19,7 +19,6 @@ #include #include -#include #include #include "vpif.h" @@ -1500,66 +1499,6 @@ static int vpif_g_dv_timings(struct file *file, void *priv, return 0; } -/* - * vpif_g_chip_ident() - Identify the chip - * @file: file ptr - * @priv: file handle - * @chip: chip identity - * - * Returns zero or -EINVAL if read operations fails. - */ -static int vpif_g_chip_ident(struct file *file, void *priv, - struct v4l2_dbg_chip_ident *chip) -{ - chip->ident = V4L2_IDENT_NONE; - chip->revision = 0; - if (chip->match.type != V4L2_CHIP_MATCH_I2C_DRIVER && - chip->match.type != V4L2_CHIP_MATCH_I2C_ADDR) { - vpif_dbg(2, debug, "match_type is invalid.\n"); - return -EINVAL; - } - - return v4l2_device_call_until_err(&vpif_obj.v4l2_dev, 0, core, - g_chip_ident, chip); -} - -#ifdef CONFIG_VIDEO_ADV_DEBUG -/* - * vpif_dbg_g_register() - Read register - * @file: file ptr - * @priv: file handle - * @reg: register to be read - * - * Debugging only - * Returns zero or -EINVAL if read operations fails. - */ -static int vpif_dbg_g_register(struct file *file, void *priv, - struct v4l2_dbg_register *reg){ - struct vpif_fh *fh = priv; - struct channel_obj *ch = fh->channel; - - return v4l2_subdev_call(ch->sd, core, g_register, reg); -} - -/* - * vpif_dbg_s_register() - Write to register - * @file: file ptr - * @priv: file handle - * @reg: register to be modified - * - * Debugging only - * Returns zero or -EINVAL if write operations fails. - */ -static int vpif_dbg_s_register(struct file *file, void *priv, - const struct v4l2_dbg_register *reg) -{ - struct vpif_fh *fh = priv; - struct channel_obj *ch = fh->channel; - - return v4l2_subdev_call(ch->sd, core, s_register, reg); -} -#endif - /* * vpif_log_status() - Status information * @file: file ptr @@ -1599,11 +1538,6 @@ static const struct v4l2_ioctl_ops vpif_ioctl_ops = { .vidioc_enum_dv_timings = vpif_enum_dv_timings, .vidioc_s_dv_timings = vpif_s_dv_timings, .vidioc_g_dv_timings = vpif_g_dv_timings, - .vidioc_g_chip_ident = vpif_g_chip_ident, -#ifdef CONFIG_VIDEO_ADV_DEBUG - .vidioc_g_register = vpif_dbg_g_register, - .vidioc_s_register = vpif_dbg_s_register, -#endif .vidioc_log_status = vpif_log_status, }; diff --git a/drivers/media/platform/sh_vou.c b/drivers/media/platform/sh_vou.c index 7d0235069c87..fa8ae7241521 100644 --- a/drivers/media/platform/sh_vou.c +++ b/drivers/media/platform/sh_vou.c @@ -1248,32 +1248,6 @@ static unsigned int sh_vou_poll(struct file *file, poll_table *wait) return res; } -static int sh_vou_g_chip_ident(struct file *file, void *fh, - struct v4l2_dbg_chip_ident *id) -{ - struct sh_vou_device *vou_dev = video_drvdata(file); - - return v4l2_device_call_until_err(&vou_dev->v4l2_dev, 0, core, g_chip_ident, id); -} - -#ifdef CONFIG_VIDEO_ADV_DEBUG -static int sh_vou_g_register(struct file *file, void *fh, - struct v4l2_dbg_register *reg) -{ - struct sh_vou_device *vou_dev = video_drvdata(file); - - return v4l2_device_call_until_err(&vou_dev->v4l2_dev, 0, core, g_register, reg); -} - -static int sh_vou_s_register(struct file *file, void *fh, - const struct v4l2_dbg_register *reg) -{ - struct sh_vou_device *vou_dev = video_drvdata(file); - - return v4l2_device_call_until_err(&vou_dev->v4l2_dev, 0, core, s_register, reg); -} -#endif - /* sh_vou display ioctl operations */ static const struct v4l2_ioctl_ops sh_vou_ioctl_ops = { .vidioc_querycap = sh_vou_querycap, @@ -1292,11 +1266,6 @@ static const struct v4l2_ioctl_ops sh_vou_ioctl_ops = { .vidioc_cropcap = sh_vou_cropcap, .vidioc_g_crop = sh_vou_g_crop, .vidioc_s_crop = sh_vou_s_crop, - .vidioc_g_chip_ident = sh_vou_g_chip_ident, -#ifdef CONFIG_VIDEO_ADV_DEBUG - .vidioc_g_register = sh_vou_g_register, - .vidioc_s_register = sh_vou_s_register, -#endif }; static const struct v4l2_file_operations sh_vou_fops = { diff --git a/drivers/media/platform/soc_camera/soc_camera.c b/drivers/media/platform/soc_camera/soc_camera.c index eea832c5fd01..68efade15a7c 100644 --- a/drivers/media/platform/soc_camera/soc_camera.c +++ b/drivers/media/platform/soc_camera/soc_camera.c @@ -1036,35 +1036,6 @@ static int soc_camera_s_parm(struct file *file, void *fh, return -ENOIOCTLCMD; } -static int soc_camera_g_chip_ident(struct file *file, void *fh, - struct v4l2_dbg_chip_ident *id) -{ - struct soc_camera_device *icd = file->private_data; - struct v4l2_subdev *sd = soc_camera_to_subdev(icd); - - return v4l2_subdev_call(sd, core, g_chip_ident, id); -} - -#ifdef CONFIG_VIDEO_ADV_DEBUG -static int soc_camera_g_register(struct file *file, void *fh, - struct v4l2_dbg_register *reg) -{ - struct soc_camera_device *icd = file->private_data; - struct v4l2_subdev *sd = soc_camera_to_subdev(icd); - - return v4l2_subdev_call(sd, core, g_register, reg); -} - -static int soc_camera_s_register(struct file *file, void *fh, - const struct v4l2_dbg_register *reg) -{ - struct soc_camera_device *icd = file->private_data; - struct v4l2_subdev *sd = soc_camera_to_subdev(icd); - - return v4l2_subdev_call(sd, core, s_register, reg); -} -#endif - static int soc_camera_probe(struct soc_camera_device *icd); /* So far this function cannot fail */ @@ -1495,11 +1466,6 @@ static const struct v4l2_ioctl_ops soc_camera_ioctl_ops = { .vidioc_s_selection = soc_camera_s_selection, .vidioc_g_parm = soc_camera_g_parm, .vidioc_s_parm = soc_camera_s_parm, - .vidioc_g_chip_ident = soc_camera_g_chip_ident, -#ifdef CONFIG_VIDEO_ADV_DEBUG - .vidioc_g_register = soc_camera_g_register, - .vidioc_s_register = soc_camera_s_register, -#endif }; static int video_dev_create(struct soc_camera_device *icd) diff --git a/drivers/media/platform/via-camera.c b/drivers/media/platform/via-camera.c index a794cd6c4441..e3438277b80b 100644 --- a/drivers/media/platform/via-camera.c +++ b/drivers/media/platform/via-camera.c @@ -17,7 +17,6 @@ #include #include #include -#include #include #include #include @@ -805,20 +804,6 @@ static const struct v4l2_file_operations viacam_fops = { * The long list of v4l2 ioctl ops */ -static int viacam_g_chip_ident(struct file *file, void *priv, - struct v4l2_dbg_chip_ident *ident) -{ - struct via_camera *cam = priv; - - ident->ident = V4L2_IDENT_NONE; - ident->revision = 0; - if (v4l2_chip_match_host(&ident->match)) { - ident->ident = V4L2_IDENT_VIA_VX855; - return 0; - } - return sensor_call(cam, core, g_chip_ident, ident); -} - /* * Only one input. */ @@ -1174,7 +1159,6 @@ static int viacam_enum_frameintervals(struct file *filp, void *priv, static const struct v4l2_ioctl_ops viacam_ioctl_ops = { - .vidioc_g_chip_ident = viacam_g_chip_ident, .vidioc_enum_input = viacam_enum_input, .vidioc_g_input = viacam_g_input, .vidioc_s_input = viacam_s_input, diff --git a/drivers/media/radio/radio-si476x.c b/drivers/media/radio/radio-si476x.c index 9430c6a29937..e039d0332831 100644 --- a/drivers/media/radio/radio-si476x.c +++ b/drivers/media/radio/radio-si476x.c @@ -1018,16 +1018,6 @@ static int si476x_radio_s_ctrl(struct v4l2_ctrl *ctrl) return retval; } -static int si476x_radio_g_chip_ident(struct file *file, void *fh, - struct v4l2_dbg_chip_ident *chip) -{ - if (chip->match.type == V4L2_CHIP_MATCH_HOST && - v4l2_chip_match_host(&chip->match)) - return 0; - return -EINVAL; -} - - #ifdef CONFIG_VIDEO_ADV_DEBUG static int si476x_radio_g_register(struct file *file, void *fh, struct v4l2_dbg_register *reg) @@ -1203,7 +1193,6 @@ static const struct v4l2_ioctl_ops si4761_ioctl_ops = { .vidioc_subscribe_event = v4l2_ctrl_subscribe_event, .vidioc_unsubscribe_event = v4l2_event_unsubscribe, - .vidioc_g_chip_ident = si476x_radio_g_chip_ident, #ifdef CONFIG_VIDEO_ADV_DEBUG .vidioc_g_register = si476x_radio_g_register, .vidioc_s_register = si476x_radio_s_register, diff --git a/drivers/media/usb/au0828/au0828-video.c b/drivers/media/usb/au0828/au0828-video.c index 75ac9947cdac..4944a365570a 100644 --- a/drivers/media/usb/au0828/au0828-video.c +++ b/drivers/media/usb/au0828/au0828-video.c @@ -36,7 +36,6 @@ #include #include #include -#include #include #include "au0828.h" #include "au0828-reg.h" @@ -1638,26 +1637,6 @@ static int vidioc_g_fmt_vbi_cap(struct file *file, void *priv, return 0; } -static int vidioc_g_chip_ident(struct file *file, void *priv, - struct v4l2_dbg_chip_ident *chip) -{ - struct au0828_fh *fh = priv; - struct au0828_dev *dev = fh->dev; - chip->ident = V4L2_IDENT_NONE; - chip->revision = 0; - - if (v4l2_chip_match_host(&chip->match)) { - chip->ident = V4L2_IDENT_AU0828; - return 0; - } - - v4l2_device_call_all(&dev->v4l2_dev, 0, core, g_chip_ident, chip); - if (chip->ident == V4L2_IDENT_NONE) - return -EINVAL; - - return 0; -} - static int vidioc_cropcap(struct file *file, void *priv, struct v4l2_cropcap *cc) { @@ -1779,15 +1758,6 @@ static int vidioc_g_register(struct file *file, void *priv, struct au0828_fh *fh = priv; struct au0828_dev *dev = fh->dev; - switch (reg->match.type) { - case V4L2_CHIP_MATCH_I2C_DRIVER: - v4l2_device_call_all(&dev->v4l2_dev, 0, core, g_register, reg); - return 0; - default: - if (!v4l2_chip_match_host(®->match)) - return -EINVAL; - } - reg->val = au0828_read(dev, reg->reg); return 0; } @@ -1798,14 +1768,6 @@ static int vidioc_s_register(struct file *file, void *priv, struct au0828_fh *fh = priv; struct au0828_dev *dev = fh->dev; - switch (reg->match.type) { - case V4L2_CHIP_MATCH_I2C_DRIVER: - v4l2_device_call_all(&dev->v4l2_dev, 0, core, s_register, reg); - return 0; - default: - if (!v4l2_chip_match_host(®->match)) - return -EINVAL; - } return au0828_writereg(dev, reg->reg, reg->val); } #endif @@ -1943,7 +1905,6 @@ static const struct v4l2_ioctl_ops video_ioctl_ops = { .vidioc_g_register = vidioc_g_register, .vidioc_s_register = vidioc_s_register, #endif - .vidioc_g_chip_ident = vidioc_g_chip_ident, .vidioc_log_status = vidioc_log_status, .vidioc_subscribe_event = v4l2_ctrl_subscribe_event, .vidioc_unsubscribe_event = v4l2_event_unsubscribe, diff --git a/drivers/media/usb/em28xx/em28xx-video.c b/drivers/media/usb/em28xx/em28xx-video.c index 32d60e5546bc..1a577ed8ea0c 100644 --- a/drivers/media/usb/em28xx/em28xx-video.c +++ b/drivers/media/usb/em28xx/em28xx-video.c @@ -41,7 +41,6 @@ #include #include #include -#include #include #include @@ -1309,28 +1308,6 @@ static int vidioc_s_frequency(struct file *file, void *priv, return 0; } -static int vidioc_g_chip_ident(struct file *file, void *priv, - struct v4l2_dbg_chip_ident *chip) -{ - struct em28xx_fh *fh = priv; - struct em28xx *dev = fh->dev; - - chip->ident = V4L2_IDENT_NONE; - chip->revision = 0; - if (chip->match.type == V4L2_CHIP_MATCH_BRIDGE) { - if (chip->match.addr > 1) - return -EINVAL; - return 0; - } - if (chip->match.type != V4L2_CHIP_MATCH_I2C_DRIVER && - chip->match.type != V4L2_CHIP_MATCH_I2C_ADDR) - return -EINVAL; - - v4l2_device_call_all(&dev->v4l2_dev, 0, core, g_chip_ident, chip); - - return 0; -} - #ifdef CONFIG_VIDEO_ADV_DEBUG static int vidioc_g_chip_info(struct file *file, void *priv, struct v4l2_dbg_chip_info *chip) @@ -1366,14 +1343,9 @@ static int vidioc_g_register(struct file *file, void *priv, struct em28xx *dev = fh->dev; int ret; - switch (reg->match.type) { - case V4L2_CHIP_MATCH_BRIDGE: - if (reg->match.addr > 1) - return -EINVAL; - if (!reg->match.addr) - break; - /* fall-through */ - case V4L2_CHIP_MATCH_AC97: + if (reg->match.addr > 1) + return -EINVAL; + if (reg->match.addr) { ret = em28xx_read_ac97(dev, reg->reg); if (ret < 0) return ret; @@ -1381,15 +1353,6 @@ static int vidioc_g_register(struct file *file, void *priv, reg->val = ret; reg->size = 1; return 0; - case V4L2_CHIP_MATCH_I2C_DRIVER: - v4l2_device_call_all(&dev->v4l2_dev, 0, core, g_register, reg); - return 0; - case V4L2_CHIP_MATCH_I2C_ADDR: - /* TODO: is this correct? */ - v4l2_device_call_all(&dev->v4l2_dev, 0, core, g_register, reg); - return 0; - default: - return -EINVAL; } /* Match host */ @@ -1421,25 +1384,10 @@ static int vidioc_s_register(struct file *file, void *priv, struct em28xx *dev = fh->dev; __le16 buf; - switch (reg->match.type) { - case V4L2_CHIP_MATCH_BRIDGE: - if (reg->match.addr > 1) - return -EINVAL; - if (!reg->match.addr) - break; - /* fall-through */ - case V4L2_CHIP_MATCH_AC97: - return em28xx_write_ac97(dev, reg->reg, reg->val); - case V4L2_CHIP_MATCH_I2C_DRIVER: - v4l2_device_call_all(&dev->v4l2_dev, 0, core, s_register, reg); - return 0; - case V4L2_CHIP_MATCH_I2C_ADDR: - /* TODO: is this correct? */ - v4l2_device_call_all(&dev->v4l2_dev, 0, core, s_register, reg); - return 0; - default: + if (reg->match.addr > 1) return -EINVAL; - } + if (reg->match.addr) + return em28xx_write_ac97(dev, reg->reg, reg->val); /* Match host */ buf = cpu_to_le16(reg->val); @@ -1795,7 +1743,6 @@ static const struct v4l2_ioctl_ops video_ioctl_ops = { .vidioc_s_frequency = vidioc_s_frequency, .vidioc_subscribe_event = v4l2_ctrl_subscribe_event, .vidioc_unsubscribe_event = v4l2_event_unsubscribe, - .vidioc_g_chip_ident = vidioc_g_chip_ident, #ifdef CONFIG_VIDEO_ADV_DEBUG .vidioc_g_chip_info = vidioc_g_chip_info, .vidioc_g_register = vidioc_g_register, @@ -1826,7 +1773,6 @@ static const struct v4l2_ioctl_ops radio_ioctl_ops = { .vidioc_s_frequency = vidioc_s_frequency, .vidioc_subscribe_event = v4l2_ctrl_subscribe_event, .vidioc_unsubscribe_event = v4l2_event_unsubscribe, - .vidioc_g_chip_ident = vidioc_g_chip_ident, #ifdef CONFIG_VIDEO_ADV_DEBUG .vidioc_g_chip_info = vidioc_g_chip_info, .vidioc_g_register = vidioc_g_register, diff --git a/drivers/media/usb/stk1160/stk1160-v4l.c b/drivers/media/usb/stk1160/stk1160-v4l.c index a59153d2f8bf..876fc26565e3 100644 --- a/drivers/media/usb/stk1160/stk1160-v4l.c +++ b/drivers/media/usb/stk1160/stk1160-v4l.c @@ -31,7 +31,6 @@ #include #include #include -#include #include #include @@ -454,19 +453,6 @@ static int vidioc_s_input(struct file *file, void *priv, unsigned int i) return 0; } -static int vidioc_g_chip_ident(struct file *file, void *priv, - struct v4l2_dbg_chip_ident *chip) -{ - switch (chip->match.type) { - case V4L2_CHIP_MATCH_BRIDGE: - chip->ident = V4L2_IDENT_NONE; - chip->revision = 0; - return 0; - default: - return -EINVAL; - } -} - #ifdef CONFIG_VIDEO_ADV_DEBUG static int vidioc_g_register(struct file *file, void *priv, struct v4l2_dbg_register *reg) @@ -475,19 +461,6 @@ static int vidioc_g_register(struct file *file, void *priv, int rc; u8 val; - switch (reg->match.type) { - case V4L2_CHIP_MATCH_I2C_DRIVER: - v4l2_device_call_all(&dev->v4l2_dev, 0, core, g_register, reg); - return 0; - case V4L2_CHIP_MATCH_I2C_ADDR: - /* TODO: is this correct? */ - v4l2_device_call_all(&dev->v4l2_dev, 0, core, g_register, reg); - return 0; - default: - if (!v4l2_chip_match_host(®->match)) - return -EINVAL; - } - /* Match host */ rc = stk1160_read_reg(dev, reg->reg, &val); reg->val = val; @@ -501,19 +474,6 @@ static int vidioc_s_register(struct file *file, void *priv, { struct stk1160 *dev = video_drvdata(file); - switch (reg->match.type) { - case V4L2_CHIP_MATCH_I2C_DRIVER: - v4l2_device_call_all(&dev->v4l2_dev, 0, core, s_register, reg); - return 0; - case V4L2_CHIP_MATCH_I2C_ADDR: - /* TODO: is this correct? */ - v4l2_device_call_all(&dev->v4l2_dev, 0, core, s_register, reg); - return 0; - default: - if (!v4l2_chip_match_host(®->match)) - return -EINVAL; - } - /* Match host */ return stk1160_write_reg(dev, reg->reg, cpu_to_le16(reg->val)); } @@ -543,7 +503,6 @@ static const struct v4l2_ioctl_ops stk1160_ioctl_ops = { .vidioc_log_status = v4l2_ctrl_log_status, .vidioc_subscribe_event = v4l2_ctrl_subscribe_event, .vidioc_unsubscribe_event = v4l2_event_unsubscribe, - .vidioc_g_chip_ident = vidioc_g_chip_ident, #ifdef CONFIG_VIDEO_ADV_DEBUG .vidioc_g_register = vidioc_g_register, From 076c3454d645ac937bfc293235e3a31e31794114 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Wed, 29 May 2013 06:59:36 -0300 Subject: [PATCH 0211/1048] [media] cx18: remove g_chip_ident support The av-core is really a subdev, so there is no need anymore to act as if it is a 'second' bridge chip. As a result of this the g_chip_ident implementation can be completely dropped. Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/pci/cx18/cx18-av-core.c | 32 ----------- drivers/media/pci/cx18/cx18-av-core.h | 1 - drivers/media/pci/cx18/cx18-ioctl.c | 78 +++------------------------ 3 files changed, 7 insertions(+), 104 deletions(-) diff --git a/drivers/media/pci/cx18/cx18-av-core.c b/drivers/media/pci/cx18/cx18-av-core.c index ba8caf0fbb85..c4890a430dc6 100644 --- a/drivers/media/pci/cx18/cx18-av-core.c +++ b/drivers/media/pci/cx18/cx18-av-core.c @@ -22,7 +22,6 @@ * 02110-1301, USA. */ -#include #include "cx18-driver.h" #include "cx18-io.h" #include "cx18-cards.h" @@ -1231,31 +1230,12 @@ static int cx18_av_log_status(struct v4l2_subdev *sd) return 0; } -static inline int cx18_av_dbg_match(const struct v4l2_dbg_match *match) -{ - return match->type == V4L2_CHIP_MATCH_HOST && match->addr == 1; -} - -static int cx18_av_g_chip_ident(struct v4l2_subdev *sd, - struct v4l2_dbg_chip_ident *chip) -{ - struct cx18_av_state *state = to_cx18_av_state(sd); - - if (cx18_av_dbg_match(&chip->match)) { - chip->ident = state->id; - chip->revision = state->rev; - } - return 0; -} - #ifdef CONFIG_VIDEO_ADV_DEBUG static int cx18_av_g_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg) { struct cx18 *cx = v4l2_get_subdevdata(sd); - if (!cx18_av_dbg_match(®->match)) - return -EINVAL; if ((reg->reg & 0x3) != 0) return -EINVAL; reg->size = 4; @@ -1268,8 +1248,6 @@ static int cx18_av_s_register(struct v4l2_subdev *sd, { struct cx18 *cx = v4l2_get_subdevdata(sd); - if (!cx18_av_dbg_match(®->match)) - return -EINVAL; if ((reg->reg & 0x3) != 0) return -EINVAL; cx18_av_write4(cx, reg->reg & 0x00000ffc, reg->val); @@ -1282,17 +1260,9 @@ static const struct v4l2_ctrl_ops cx18_av_ctrl_ops = { }; static const struct v4l2_subdev_core_ops cx18_av_general_ops = { - .g_chip_ident = cx18_av_g_chip_ident, .log_status = cx18_av_log_status, .load_fw = cx18_av_load_fw, .reset = cx18_av_reset, - .g_ctrl = v4l2_subdev_g_ctrl, - .s_ctrl = v4l2_subdev_s_ctrl, - .s_ext_ctrls = v4l2_subdev_s_ext_ctrls, - .try_ext_ctrls = v4l2_subdev_try_ext_ctrls, - .g_ext_ctrls = v4l2_subdev_g_ext_ctrls, - .queryctrl = v4l2_subdev_queryctrl, - .querymenu = v4l2_subdev_querymenu, .s_std = cx18_av_s_std, #ifdef CONFIG_VIDEO_ADV_DEBUG .g_register = cx18_av_g_register, @@ -1340,8 +1310,6 @@ int cx18_av_probe(struct cx18 *cx) int err; state->rev = cx18_av_read4(cx, CXADEC_CHIP_CTRL) & 0xffff; - state->id = ((state->rev >> 4) == CXADEC_CHIP_TYPE_MAKO) - ? V4L2_IDENT_CX23418_843 : V4L2_IDENT_UNKNOWN; state->vid_input = CX18_AV_COMPOSITE7; state->aud_input = CX18_AV_AUDIO8; diff --git a/drivers/media/pci/cx18/cx18-av-core.h b/drivers/media/pci/cx18/cx18-av-core.h index e9c69d9c9e4a..4c559e86e340 100644 --- a/drivers/media/pci/cx18/cx18-av-core.h +++ b/drivers/media/pci/cx18/cx18-av-core.h @@ -104,7 +104,6 @@ struct cx18_av_state { enum cx18_av_audio_input aud_input; u32 audclk_freq; int audmode; - u32 id; u32 rev; int is_initialized; diff --git a/drivers/media/pci/cx18/cx18-ioctl.c b/drivers/media/pci/cx18/cx18-ioctl.c index aee7b6dacbfe..414b0ecccc91 100644 --- a/drivers/media/pci/cx18/cx18-ioctl.c +++ b/drivers/media/pci/cx18/cx18-ioctl.c @@ -39,7 +39,6 @@ #include "cx18-cards.h" #include "cx18-av-core.h" #include -#include u16 cx18_service2vbi(int type) { @@ -362,73 +361,16 @@ static int cx18_s_fmt_sliced_vbi_cap(struct file *file, void *fh, return 0; } -static int cx18_g_chip_ident(struct file *file, void *fh, - struct v4l2_dbg_chip_ident *chip) -{ - struct cx18 *cx = fh2id(fh)->cx; - int err = 0; - - chip->ident = V4L2_IDENT_NONE; - chip->revision = 0; - switch (chip->match.type) { - case V4L2_CHIP_MATCH_HOST: - switch (chip->match.addr) { - case 0: - chip->ident = V4L2_IDENT_CX23418; - chip->revision = cx18_read_reg(cx, 0xC72028); - break; - case 1: - /* - * The A/V decoder is always present, but in the rare - * case that the card doesn't have analog, we don't - * use it. We find it w/o using the cx->sd_av pointer - */ - cx18_call_hw(cx, CX18_HW_418_AV, - core, g_chip_ident, chip); - break; - default: - /* - * Could return ident = V4L2_IDENT_UNKNOWN if we had - * other host chips at higher addresses, but we don't - */ - err = -EINVAL; /* per V4L2 spec */ - break; - } - break; - case V4L2_CHIP_MATCH_I2C_DRIVER: - /* If needed, returns V4L2_IDENT_AMBIGUOUS without extra work */ - cx18_call_all(cx, core, g_chip_ident, chip); - break; - case V4L2_CHIP_MATCH_I2C_ADDR: - /* - * We could return V4L2_IDENT_UNKNOWN, but we don't do the work - * to look if a chip is at the address with no driver. That's a - * dangerous thing to do with EEPROMs anyway. - */ - cx18_call_all(cx, core, g_chip_ident, chip); - break; - default: - err = -EINVAL; - break; - } - return err; -} - #ifdef CONFIG_VIDEO_ADV_DEBUG static int cx18_g_register(struct file *file, void *fh, struct v4l2_dbg_register *reg) { struct cx18 *cx = fh2id(fh)->cx; - if (v4l2_chip_match_host(®->match)) { - if (reg->reg >= CX18_MEM_OFFSET + CX18_MEM_SIZE) - return -EINVAL; - reg->size = 4; - reg->val = cx18_read_enc(cx, reg->reg); - return 0; - } - /* FIXME - errors shouldn't be ignored */ - cx18_call_all(cx, core, g_register, reg); + if (reg->reg >= CX18_MEM_OFFSET + CX18_MEM_SIZE) + return -EINVAL; + reg->size = 4; + reg->val = cx18_read_enc(cx, reg->reg); return 0; } @@ -437,14 +379,9 @@ static int cx18_s_register(struct file *file, void *fh, { struct cx18 *cx = fh2id(fh)->cx; - if (v4l2_chip_match_host(®->match)) { - if (reg->reg >= CX18_MEM_OFFSET + CX18_MEM_SIZE) - return -EINVAL; - cx18_write_enc(cx, reg->val, reg->reg); - return 0; - } - /* FIXME - errors shouldn't be ignored */ - cx18_call_all(cx, core, s_register, reg); + if (reg->reg >= CX18_MEM_OFFSET + CX18_MEM_SIZE) + return -EINVAL; + cx18_write_enc(cx, reg->val, reg->reg); return 0; } #endif @@ -1162,7 +1099,6 @@ static const struct v4l2_ioctl_ops cx18_ioctl_ops = { .vidioc_try_fmt_vbi_cap = cx18_try_fmt_vbi_cap, .vidioc_try_fmt_sliced_vbi_cap = cx18_try_fmt_sliced_vbi_cap, .vidioc_g_sliced_vbi_cap = cx18_g_sliced_vbi_cap, - .vidioc_g_chip_ident = cx18_g_chip_ident, #ifdef CONFIG_VIDEO_ADV_DEBUG .vidioc_g_register = cx18_g_register, .vidioc_s_register = cx18_s_register, From e84e91ea486cc153713f48a7c867828b150438d1 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Wed, 29 May 2013 06:59:37 -0300 Subject: [PATCH 0212/1048] [media] saa7115: add back the dropped 'found' message The saa7115 driver used to show a 'chip found' message during probe. This was accidentally dropped during recent commits. Add it back as it is quite useful. Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/i2c/saa7115.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/media/i2c/saa7115.c b/drivers/media/i2c/saa7115.c index 18cf0bfaf743..4daa81c55a82 100644 --- a/drivers/media/i2c/saa7115.c +++ b/drivers/media/i2c/saa7115.c @@ -1735,6 +1735,8 @@ static int saa711x_probe(struct i2c_client *client, sd = &state->sd; v4l2_i2c_subdev_init(sd, client, &saa711x_ops); + v4l_info(client, "%s found @ 0x%x (%s)\n", name, + client->addr << 1, client->adapter->name); hdl = &state->hdl; v4l2_ctrl_handler_init(hdl, 6); /* add in ascending ID order */ From 4bd8193674b7d3158e76eb48bdf3a787b71b8572 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Wed, 29 May 2013 06:59:38 -0300 Subject: [PATCH 0213/1048] [media] ivtv: remove g_chip_ident g_chip_ident was used to determine if a saa7114 or saa7115 was used. Instead just check the subdev name. After that the g_chip_ident function can be removed. Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/pci/ivtv/ivtv-driver.c | 8 +----- drivers/media/pci/ivtv/ivtv-ioctl.c | 41 +++------------------------- 2 files changed, 5 insertions(+), 44 deletions(-) diff --git a/drivers/media/pci/ivtv/ivtv-driver.c b/drivers/media/pci/ivtv/ivtv-driver.c index 07b8460953b6..db614528376c 100644 --- a/drivers/media/pci/ivtv/ivtv-driver.c +++ b/drivers/media/pci/ivtv/ivtv-driver.c @@ -58,7 +58,6 @@ #include #include #include -#include #include "tuner-xc2028.h" /* If you have already X v4l cards, then set this to X. This way @@ -968,15 +967,10 @@ static void ivtv_load_and_init_modules(struct ivtv *itv) } if (hw & IVTV_HW_SAA711X) { - struct v4l2_dbg_chip_ident v; - /* determine the exact saa711x model */ itv->hw_flags &= ~IVTV_HW_SAA711X; - v.match.type = V4L2_CHIP_MATCH_I2C_DRIVER; - strlcpy(v.match.name, "saa7115", sizeof(v.match.name)); - ivtv_call_hw(itv, IVTV_HW_SAA711X, core, g_chip_ident, &v); - if (v.ident == V4L2_IDENT_SAA7114) { + if (strstr(itv->sd_video->name, "saa7114")) { itv->hw_flags |= IVTV_HW_SAA7114; /* VBI is not yet supported by the saa7114 driver. */ itv->v4l2_cap &= ~(V4L2_CAP_SLICED_VBI_CAPTURE|V4L2_CAP_VBI_CAPTURE); diff --git a/drivers/media/pci/ivtv/ivtv-ioctl.c b/drivers/media/pci/ivtv/ivtv-ioctl.c index 3e281eccdd88..944300f7c60b 100644 --- a/drivers/media/pci/ivtv/ivtv-ioctl.c +++ b/drivers/media/pci/ivtv/ivtv-ioctl.c @@ -34,7 +34,6 @@ #include "ivtv-cards.h" #include #include -#include #include #include @@ -692,24 +691,6 @@ static int ivtv_s_fmt_vid_out_overlay(struct file *file, void *fh, struct v4l2_f return ret; } -static int ivtv_g_chip_ident(struct file *file, void *fh, struct v4l2_dbg_chip_ident *chip) -{ - struct ivtv *itv = fh2id(fh)->itv; - - chip->ident = V4L2_IDENT_NONE; - chip->revision = 0; - if (chip->match.type == V4L2_CHIP_MATCH_HOST) { - if (v4l2_chip_match_host(&chip->match)) - chip->ident = itv->has_cx23415 ? V4L2_IDENT_CX23415 : V4L2_IDENT_CX23416; - return 0; - } - if (chip->match.type != V4L2_CHIP_MATCH_I2C_DRIVER && - chip->match.type != V4L2_CHIP_MATCH_I2C_ADDR) - return -EINVAL; - /* TODO: is this correct? */ - return ivtv_call_all_err(itv, core, g_chip_ident, chip); -} - #ifdef CONFIG_VIDEO_ADV_DEBUG static int ivtv_itvc(struct ivtv *itv, bool get, u64 reg, u64 *val) { @@ -736,29 +717,16 @@ static int ivtv_g_register(struct file *file, void *fh, struct v4l2_dbg_register { struct ivtv *itv = fh2id(fh)->itv; - if (v4l2_chip_match_host(®->match)) { - reg->size = 4; - return ivtv_itvc(itv, true, reg->reg, ®->val); - } - /* TODO: subdev errors should not be ignored, this should become a - subdev helper function. */ - ivtv_call_all(itv, core, g_register, reg); - return 0; + reg->size = 4; + return ivtv_itvc(itv, true, reg->reg, ®->val); } static int ivtv_s_register(struct file *file, void *fh, const struct v4l2_dbg_register *reg) { struct ivtv *itv = fh2id(fh)->itv; + u64 val = reg->val; - if (v4l2_chip_match_host(®->match)) { - u64 val = reg->val; - - return ivtv_itvc(itv, false, reg->reg, &val); - } - /* TODO: subdev errors should not be ignored, this should become a - subdev helper function. */ - ivtv_call_all(itv, core, s_register, reg); - return 0; + return ivtv_itvc(itv, false, reg->reg, &val); } #endif @@ -1912,7 +1880,6 @@ static const struct v4l2_ioctl_ops ivtv_ioctl_ops = { .vidioc_try_fmt_vid_out_overlay = ivtv_try_fmt_vid_out_overlay, .vidioc_try_fmt_sliced_vbi_out = ivtv_try_fmt_sliced_vbi_out, .vidioc_g_sliced_vbi_cap = ivtv_g_sliced_vbi_cap, - .vidioc_g_chip_ident = ivtv_g_chip_ident, #ifdef CONFIG_VIDEO_ADV_DEBUG .vidioc_g_register = ivtv_g_register, .vidioc_s_register = ivtv_s_register, From 80f8568f47306dc4453bb6630ac607f22ca4c7b4 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Wed, 29 May 2013 06:59:39 -0300 Subject: [PATCH 0214/1048] [media] cx23885: remove g_chip_ident Replace g_chip_ident by g_chip_info. Note that the IR support is implemented as a subdev, so this part no longer needs to be handled as a 'bridge' chip. Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/pci/cx23885/cx23885-417.c | 2 +- drivers/media/pci/cx23885/cx23885-ioctl.c | 139 ++++------------------ drivers/media/pci/cx23885/cx23885-ioctl.h | 4 +- drivers/media/pci/cx23885/cx23885-video.c | 2 +- drivers/media/pci/cx23885/cx23888-ir.c | 27 ----- 5 files changed, 29 insertions(+), 145 deletions(-) diff --git a/drivers/media/pci/cx23885/cx23885-417.c b/drivers/media/pci/cx23885/cx23885-417.c index 6dea11a7a858..68568d35a692 100644 --- a/drivers/media/pci/cx23885/cx23885-417.c +++ b/drivers/media/pci/cx23885/cx23885-417.c @@ -1690,8 +1690,8 @@ static const struct v4l2_ioctl_ops mpeg_ioctl_ops = { .vidioc_log_status = vidioc_log_status, .vidioc_querymenu = vidioc_querymenu, .vidioc_queryctrl = vidioc_queryctrl, - .vidioc_g_chip_ident = cx23885_g_chip_ident, #ifdef CONFIG_VIDEO_ADV_DEBUG + .vidioc_g_chip_info = cx23885_g_chip_info, .vidioc_g_register = cx23885_g_register, .vidioc_s_register = cx23885_s_register, #endif diff --git a/drivers/media/pci/cx23885/cx23885-ioctl.c b/drivers/media/pci/cx23885/cx23885-ioctl.c index 00f51251728b..271d69d1ca8c 100644 --- a/drivers/media/pci/cx23885/cx23885-ioctl.c +++ b/drivers/media/pci/cx23885/cx23885-ioctl.c @@ -24,93 +24,21 @@ #include "cx23885.h" #include "cx23885-ioctl.h" -#include - -int cx23885_g_chip_ident(struct file *file, void *fh, - struct v4l2_dbg_chip_ident *chip) +#ifdef CONFIG_VIDEO_ADV_DEBUG +int cx23885_g_chip_info(struct file *file, void *fh, + struct v4l2_dbg_chip_info *chip) { struct cx23885_dev *dev = ((struct cx23885_fh *)fh)->dev; - int err = 0; - u8 rev; - chip->ident = V4L2_IDENT_NONE; - chip->revision = 0; - switch (chip->match.type) { - case V4L2_CHIP_MATCH_HOST: - switch (chip->match.addr) { - case 0: - rev = cx_read(RDR_CFG2) & 0xff; - switch (dev->pci->device) { - case 0x8852: - /* rev 0x04 could be '885 or '888. Pick '888. */ - if (rev == 0x04) - chip->ident = V4L2_IDENT_CX23888; - else - chip->ident = V4L2_IDENT_CX23885; - break; - case 0x8880: - if (rev == 0x0e || rev == 0x0f) - chip->ident = V4L2_IDENT_CX23887; - else - chip->ident = V4L2_IDENT_CX23888; - break; - default: - chip->ident = V4L2_IDENT_UNKNOWN; - break; - } - chip->revision = (dev->pci->device << 16) | (rev << 8) | - (dev->hwrevision & 0xff); - break; - case 1: - if (dev->v4l_device != NULL) { - chip->ident = V4L2_IDENT_CX23417; - chip->revision = 0; - } - break; - case 2: - /* - * The integrated IR controller on the CX23888 is - * host chip 2. It may not be used/initialized or sd_ir - * may be pointing at the cx25840 subdevice for the - * IR controller on the CX23885. Thus we find it - * without using the dev->sd_ir pointer. - */ - call_hw(dev, CX23885_HW_888_IR, core, g_chip_ident, - chip); - break; - default: - err = -EINVAL; /* per V4L2 spec */ - break; - } - break; - case V4L2_CHIP_MATCH_I2C_DRIVER: - /* If needed, returns V4L2_IDENT_AMBIGUOUS without extra work */ - call_all(dev, core, g_chip_ident, chip); - break; - case V4L2_CHIP_MATCH_I2C_ADDR: - /* - * We could return V4L2_IDENT_UNKNOWN, but we don't do the work - * to look if a chip is at the address with no driver. That's a - * dangerous thing to do with EEPROMs anyway. - */ - call_all(dev, core, g_chip_ident, chip); - break; - default: - err = -EINVAL; - break; - } - return err; -} - -#ifdef CONFIG_VIDEO_ADV_DEBUG -static int cx23885_g_host_register(struct cx23885_dev *dev, - struct v4l2_dbg_register *reg) -{ - if ((reg->reg & 0x3) != 0 || reg->reg >= pci_resource_len(dev->pci, 0)) + if (chip->match.addr > 1) return -EINVAL; - - reg->size = 4; - reg->val = cx_read(reg->reg); + if (chip->match.addr == 1) { + if (dev->v4l_device == NULL) + return -EINVAL; + strlcpy(chip->name, "cx23417", sizeof(chip->name)); + } else { + strlcpy(chip->name, dev->v4l2_dev.name, sizeof(chip->name)); + } return 0; } @@ -138,29 +66,16 @@ int cx23885_g_register(struct file *file, void *fh, { struct cx23885_dev *dev = ((struct cx23885_fh *)fh)->dev; - if (reg->match.type == V4L2_CHIP_MATCH_HOST) { - switch (reg->match.addr) { - case 0: - return cx23885_g_host_register(dev, reg); - case 1: - return cx23417_g_register(dev, reg); - default: - break; - } - } + if (reg->match.addr > 1) + return -EINVAL; + if (reg->match.addr) + return cx23417_g_register(dev, reg); - /* FIXME - any error returns should not be ignored */ - call_all(dev, core, g_register, reg); - return 0; -} - -static int cx23885_s_host_register(struct cx23885_dev *dev, - const struct v4l2_dbg_register *reg) -{ if ((reg->reg & 0x3) != 0 || reg->reg >= pci_resource_len(dev->pci, 0)) return -EINVAL; - cx_write(reg->reg, reg->val); + reg->size = 4; + reg->val = cx_read(reg->reg); return 0; } @@ -183,19 +98,15 @@ int cx23885_s_register(struct file *file, void *fh, { struct cx23885_dev *dev = ((struct cx23885_fh *)fh)->dev; - if (reg->match.type == V4L2_CHIP_MATCH_HOST) { - switch (reg->match.addr) { - case 0: - return cx23885_s_host_register(dev, reg); - case 1: - return cx23417_s_register(dev, reg); - default: - break; - } - } + if (reg->match.addr > 1) + return -EINVAL; + if (reg->match.addr) + return cx23417_s_register(dev, reg); - /* FIXME - any error returns should not be ignored */ - call_all(dev, core, s_register, reg); + if ((reg->reg & 0x3) != 0 || reg->reg >= pci_resource_len(dev->pci, 0)) + return -EINVAL; + + cx_write(reg->reg, reg->val); return 0; } #endif diff --git a/drivers/media/pci/cx23885/cx23885-ioctl.h b/drivers/media/pci/cx23885/cx23885-ioctl.h index a6080964a9ee..92d9f0774366 100644 --- a/drivers/media/pci/cx23885/cx23885-ioctl.h +++ b/drivers/media/pci/cx23885/cx23885-ioctl.h @@ -24,8 +24,8 @@ #ifndef _CX23885_IOCTL_H_ #define _CX23885_IOCTL_H_ -int cx23885_g_chip_ident(struct file *file, void *fh, - struct v4l2_dbg_chip_ident *chip); +int cx23885_g_chip_info(struct file *file, void *fh, + struct v4l2_dbg_chip_info *chip); #ifdef CONFIG_VIDEO_ADV_DEBUG int cx23885_g_register(struct file *file, void *fh, diff --git a/drivers/media/pci/cx23885/cx23885-video.c b/drivers/media/pci/cx23885/cx23885-video.c index ed08c89adde0..ce057398c632 100644 --- a/drivers/media/pci/cx23885/cx23885-video.c +++ b/drivers/media/pci/cx23885/cx23885-video.c @@ -1757,8 +1757,8 @@ static const struct v4l2_ioctl_ops video_ioctl_ops = { .vidioc_s_tuner = vidioc_s_tuner, .vidioc_g_frequency = vidioc_g_frequency, .vidioc_s_frequency = vidioc_s_frequency, - .vidioc_g_chip_ident = cx23885_g_chip_ident, #ifdef CONFIG_VIDEO_ADV_DEBUG + .vidioc_g_chip_info = cx23885_g_chip_info, .vidioc_g_register = cx23885_g_register, .vidioc_s_register = cx23885_s_register, #endif diff --git a/drivers/media/pci/cx23885/cx23888-ir.c b/drivers/media/pci/cx23885/cx23888-ir.c index cd98651f3ae6..2c951dec2d33 100644 --- a/drivers/media/pci/cx23885/cx23888-ir.c +++ b/drivers/media/pci/cx23885/cx23888-ir.c @@ -25,7 +25,6 @@ #include #include -#include #include #include "cx23885.h" @@ -131,8 +130,6 @@ union cx23888_ir_fifo_rec { struct cx23888_ir_state { struct v4l2_subdev sd; struct cx23885_dev *dev; - u32 id; - u32 rev; struct v4l2_subdev_ir_parameters rx_params; struct mutex rx_params_lock; @@ -1086,23 +1083,6 @@ static int cx23888_ir_log_status(struct v4l2_subdev *sd) return 0; } -static inline int cx23888_ir_dbg_match(const struct v4l2_dbg_match *match) -{ - return match->type == V4L2_CHIP_MATCH_HOST && match->addr == 2; -} - -static int cx23888_ir_g_chip_ident(struct v4l2_subdev *sd, - struct v4l2_dbg_chip_ident *chip) -{ - struct cx23888_ir_state *state = to_state(sd); - - if (cx23888_ir_dbg_match(&chip->match)) { - chip->ident = state->id; - chip->revision = state->rev; - } - return 0; -} - #ifdef CONFIG_VIDEO_ADV_DEBUG static int cx23888_ir_g_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg) @@ -1110,8 +1090,6 @@ static int cx23888_ir_g_register(struct v4l2_subdev *sd, struct cx23888_ir_state *state = to_state(sd); u32 addr = CX23888_IR_REG_BASE + (u32) reg->reg; - if (!cx23888_ir_dbg_match(®->match)) - return -EINVAL; if ((addr & 0x3) != 0) return -EINVAL; if (addr < CX23888_IR_CNTRL_REG || addr > CX23888_IR_LEARN_REG) @@ -1127,8 +1105,6 @@ static int cx23888_ir_s_register(struct v4l2_subdev *sd, struct cx23888_ir_state *state = to_state(sd); u32 addr = CX23888_IR_REG_BASE + (u32) reg->reg; - if (!cx23888_ir_dbg_match(®->match)) - return -EINVAL; if ((addr & 0x3) != 0) return -EINVAL; if (addr < CX23888_IR_CNTRL_REG || addr > CX23888_IR_LEARN_REG) @@ -1139,7 +1115,6 @@ static int cx23888_ir_s_register(struct v4l2_subdev *sd, #endif static const struct v4l2_subdev_core_ops cx23888_ir_core_ops = { - .g_chip_ident = cx23888_ir_g_chip_ident, .log_status = cx23888_ir_log_status, #ifdef CONFIG_VIDEO_ADV_DEBUG .g_register = cx23888_ir_g_register, @@ -1213,8 +1188,6 @@ int cx23888_ir_probe(struct cx23885_dev *dev) return -ENOMEM; state->dev = dev; - state->id = V4L2_IDENT_CX23888_IR; - state->rev = 0; sd = &state->sd; v4l2_subdev_init(sd, &cx23888_ir_controller_ops); From 23898919c45ff5fc5d882ec6206b38a5fb6ecd88 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Wed, 29 May 2013 06:59:41 -0300 Subject: [PATCH 0215/1048] [media] saa6752hs: drop obsolete g_chip_ident This op and the v4l2-chip-ident.h header are no longer needed. Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/pci/saa7134/saa6752hs.c | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/drivers/media/pci/saa7134/saa6752hs.c b/drivers/media/pci/saa7134/saa6752hs.c index f147b05bd860..244b2868dfc8 100644 --- a/drivers/media/pci/saa7134/saa6752hs.c +++ b/drivers/media/pci/saa7134/saa6752hs.c @@ -35,7 +35,6 @@ #include #include #include -#include #include #include @@ -92,7 +91,6 @@ static const struct v4l2_format v4l2_format_table[] = struct saa6752hs_state { struct v4l2_subdev sd; - int chip; u32 revision; int has_ac3; struct saa6752hs_mpeg_params params; @@ -914,19 +912,9 @@ static int saa6752hs_s_std(struct v4l2_subdev *sd, v4l2_std_id std) return 0; } -static int saa6752hs_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *chip) -{ - struct i2c_client *client = v4l2_get_subdevdata(sd); - struct saa6752hs_state *h = to_state(sd); - - return v4l2_chip_ident_i2c_client(client, - chip, h->chip, h->revision); -} - /* ----------------------------------------------------------------------- */ static const struct v4l2_subdev_core_ops saa6752hs_core_ops = { - .g_chip_ident = saa6752hs_g_chip_ident, .init = saa6752hs_init, .queryctrl = saa6752hs_queryctrl, .querymenu = saa6752hs_querymenu, @@ -963,11 +951,9 @@ static int saa6752hs_probe(struct i2c_client *client, i2c_master_send(client, &addr, 1); i2c_master_recv(client, data, sizeof(data)); - h->chip = V4L2_IDENT_SAA6752HS; h->revision = (data[8] << 8) | data[9]; h->has_ac3 = 0; if (h->revision == 0x0206) { - h->chip = V4L2_IDENT_SAA6752HS_AC3; h->has_ac3 = 1; v4l_info(client, "support AC-3\n"); } From b1c85cc049a681aee805311faa56fd21b44fb904 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Wed, 29 May 2013 06:59:42 -0300 Subject: [PATCH 0216/1048] [media] gspca: remove g_chip_ident Remove g_chip_ident and replace it with g_chip_info. Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/usb/gspca/gspca.c | 34 ++++++++-------- drivers/media/usb/gspca/gspca.h | 6 +-- drivers/media/usb/gspca/pac7302.c | 19 +-------- drivers/media/usb/gspca/sn9c20x.c | 67 +++++++------------------------ 4 files changed, 35 insertions(+), 91 deletions(-) diff --git a/drivers/media/usb/gspca/gspca.c b/drivers/media/usb/gspca/gspca.c index 5995ec4de6bc..b7ae8721b847 100644 --- a/drivers/media/usb/gspca/gspca.c +++ b/drivers/media/usb/gspca/gspca.c @@ -1029,8 +1029,19 @@ static int gspca_get_mode(struct gspca_dev *gspca_dev, } #ifdef CONFIG_VIDEO_ADV_DEBUG +static int vidioc_g_chip_info(struct file *file, void *priv, + struct v4l2_dbg_chip_info *chip) +{ + struct gspca_dev *gspca_dev = video_drvdata(file); + + gspca_dev->usb_err = 0; + if (gspca_dev->sd_desc->get_chip_info) + return gspca_dev->sd_desc->get_chip_info(gspca_dev, chip); + return chip->match.addr ? -EINVAL : 0; +} + static int vidioc_g_register(struct file *file, void *priv, - struct v4l2_dbg_register *reg) + struct v4l2_dbg_register *reg) { struct gspca_dev *gspca_dev = video_drvdata(file); @@ -1039,7 +1050,7 @@ static int vidioc_g_register(struct file *file, void *priv, } static int vidioc_s_register(struct file *file, void *priv, - const struct v4l2_dbg_register *reg) + const struct v4l2_dbg_register *reg) { struct gspca_dev *gspca_dev = video_drvdata(file); @@ -1048,15 +1059,6 @@ static int vidioc_s_register(struct file *file, void *priv, } #endif -static int vidioc_g_chip_ident(struct file *file, void *priv, - struct v4l2_dbg_chip_ident *chip) -{ - struct gspca_dev *gspca_dev = video_drvdata(file); - - gspca_dev->usb_err = 0; - return gspca_dev->sd_desc->get_chip_ident(gspca_dev, chip); -} - static int vidioc_enum_fmt_vid_cap(struct file *file, void *priv, struct v4l2_fmtdesc *fmtdesc) { @@ -1974,10 +1976,10 @@ static const struct v4l2_ioctl_ops dev_ioctl_ops = { .vidioc_enum_framesizes = vidioc_enum_framesizes, .vidioc_enum_frameintervals = vidioc_enum_frameintervals, #ifdef CONFIG_VIDEO_ADV_DEBUG + .vidioc_g_chip_info = vidioc_g_chip_info, .vidioc_g_register = vidioc_g_register, .vidioc_s_register = vidioc_s_register, #endif - .vidioc_g_chip_ident = vidioc_g_chip_ident, .vidioc_subscribe_event = v4l2_ctrl_subscribe_event, .vidioc_unsubscribe_event = v4l2_event_unsubscribe, }; @@ -2086,14 +2088,10 @@ int gspca_dev_probe2(struct usb_interface *intf, v4l2_disable_ioctl_locking(&gspca_dev->vdev, VIDIOC_DQBUF); v4l2_disable_ioctl_locking(&gspca_dev->vdev, VIDIOC_QBUF); v4l2_disable_ioctl_locking(&gspca_dev->vdev, VIDIOC_QUERYBUF); - if (!gspca_dev->sd_desc->get_chip_ident) - v4l2_disable_ioctl(&gspca_dev->vdev, VIDIOC_DBG_G_CHIP_IDENT); #ifdef CONFIG_VIDEO_ADV_DEBUG - if (!gspca_dev->sd_desc->get_chip_ident || - !gspca_dev->sd_desc->get_register) + if (!gspca_dev->sd_desc->get_register) v4l2_disable_ioctl(&gspca_dev->vdev, VIDIOC_DBG_G_REGISTER); - if (!gspca_dev->sd_desc->get_chip_ident || - !gspca_dev->sd_desc->set_register) + if (!gspca_dev->sd_desc->set_register) v4l2_disable_ioctl(&gspca_dev->vdev, VIDIOC_DBG_S_REGISTER); #endif if (!gspca_dev->sd_desc->get_jcomp) diff --git a/drivers/media/usb/gspca/gspca.h b/drivers/media/usb/gspca/gspca.h index ef8efeb80070..ac0b11f46f50 100644 --- a/drivers/media/usb/gspca/gspca.h +++ b/drivers/media/usb/gspca/gspca.h @@ -78,8 +78,8 @@ typedef int (*cam_get_reg_op) (struct gspca_dev *, struct v4l2_dbg_register *); typedef int (*cam_set_reg_op) (struct gspca_dev *, const struct v4l2_dbg_register *); -typedef int (*cam_ident_op) (struct gspca_dev *, - struct v4l2_dbg_chip_ident *); +typedef int (*cam_chip_info_op) (struct gspca_dev *, + struct v4l2_dbg_chip_info *); typedef void (*cam_streamparm_op) (struct gspca_dev *, struct v4l2_streamparm *); typedef void (*cam_pkt_op) (struct gspca_dev *gspca_dev, @@ -112,8 +112,8 @@ struct sd_desc { #ifdef CONFIG_VIDEO_ADV_DEBUG cam_set_reg_op set_register; cam_get_reg_op get_register; + cam_chip_info_op get_chip_info; #endif - cam_ident_op get_chip_ident; #if IS_ENABLED(CONFIG_INPUT) cam_int_pkt_op int_pkt_scan; /* other_input makes the gspca core create gspca_dev->input even when diff --git a/drivers/media/usb/gspca/pac7302.c b/drivers/media/usb/gspca/pac7302.c index 6008c8d546a3..a91509643563 100644 --- a/drivers/media/usb/gspca/pac7302.c +++ b/drivers/media/usb/gspca/pac7302.c @@ -93,7 +93,6 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #include -#include #include "gspca.h" /* Include pac common sof detection functions */ #include "pac_common.h" @@ -849,8 +848,7 @@ static int sd_dbg_s_register(struct gspca_dev *gspca_dev, * reg->reg: bit0..15: reserved for register index (wIndex is 16bit * long on the USB bus) */ - if (reg->match.type == V4L2_CHIP_MATCH_HOST && - reg->match.addr == 0 && + if (reg->match.addr == 0 && (reg->reg < 0x000000ff) && (reg->val <= 0x000000ff) ) { @@ -871,20 +869,6 @@ static int sd_dbg_s_register(struct gspca_dev *gspca_dev, } return gspca_dev->usb_err; } - -static int sd_chip_ident(struct gspca_dev *gspca_dev, - struct v4l2_dbg_chip_ident *chip) -{ - int ret = -EINVAL; - - if (chip->match.type == V4L2_CHIP_MATCH_HOST && - chip->match.addr == 0) { - chip->revision = 0; - chip->ident = V4L2_IDENT_UNKNOWN; - ret = 0; - } - return ret; -} #endif #if IS_ENABLED(CONFIG_INPUT) @@ -931,7 +915,6 @@ static const struct sd_desc sd_desc = { .dq_callback = do_autogain, #ifdef CONFIG_VIDEO_ADV_DEBUG .set_register = sd_dbg_s_register, - .get_chip_ident = sd_chip_ident, #endif #if IS_ENABLED(CONFIG_INPUT) .int_pkt_scan = sd_int_pkt_scan, diff --git a/drivers/media/usb/gspca/sn9c20x.c b/drivers/media/usb/gspca/sn9c20x.c index ead9a1f58513..23b71f9f5942 100644 --- a/drivers/media/usb/gspca/sn9c20x.c +++ b/drivers/media/usb/gspca/sn9c20x.c @@ -27,7 +27,6 @@ #include "gspca.h" #include "jpeg.h" -#include #include MODULE_AUTHOR("Brian Johnson , " @@ -582,22 +581,6 @@ static const s16 hsv_blue_y[] = { 4, 2, 0, -1, -3, -5, -7, -9, -11 }; -static const u16 i2c_ident[] = { - V4L2_IDENT_OV9650, - V4L2_IDENT_OV9655, - V4L2_IDENT_SOI968, - V4L2_IDENT_OV7660, - V4L2_IDENT_OV7670, - V4L2_IDENT_MT9V011, - V4L2_IDENT_MT9V111, - V4L2_IDENT_MT9V112, - V4L2_IDENT_MT9M001C12ST, - V4L2_IDENT_MT9M111, - V4L2_IDENT_MT9M112, - V4L2_IDENT_HV7131R, -[SENSOR_MT9VPRB] = V4L2_IDENT_UNKNOWN, -}; - static const u16 bridge_init[][2] = { {0x1000, 0x78}, {0x1001, 0x40}, {0x1002, 0x1c}, {0x1020, 0x80}, {0x1061, 0x01}, {0x1067, 0x40}, @@ -1574,18 +1557,14 @@ static int sd_dbg_g_register(struct gspca_dev *gspca_dev, { struct sd *sd = (struct sd *) gspca_dev; - switch (reg->match.type) { - case V4L2_CHIP_MATCH_HOST: - if (reg->match.addr != 0) - return -EINVAL; + switch (reg->match.addr) { + case 0: if (reg->reg < 0x1000 || reg->reg > 0x11ff) return -EINVAL; reg_r(gspca_dev, reg->reg, 1); reg->val = gspca_dev->usb_buf[0]; return gspca_dev->usb_err; - case V4L2_CHIP_MATCH_I2C_ADDR: - if (reg->match.addr != sd->i2c_addr) - return -EINVAL; + case 1: if (sd->sensor >= SENSOR_MT9V011 && sd->sensor <= SENSOR_MT9M112) { i2c_r2(gspca_dev, reg->reg, (u16 *) ®->val); @@ -1602,17 +1581,13 @@ static int sd_dbg_s_register(struct gspca_dev *gspca_dev, { struct sd *sd = (struct sd *) gspca_dev; - switch (reg->match.type) { - case V4L2_CHIP_MATCH_HOST: - if (reg->match.addr != 0) - return -EINVAL; + switch (reg->match.addr) { + case 0: if (reg->reg < 0x1000 || reg->reg > 0x11ff) return -EINVAL; reg_w1(gspca_dev, reg->reg, reg->val); return gspca_dev->usb_err; - case V4L2_CHIP_MATCH_I2C_ADDR: - if (reg->match.addr != sd->i2c_addr) - return -EINVAL; + case 1: if (sd->sensor >= SENSOR_MT9V011 && sd->sensor <= SENSOR_MT9M112) { i2c_w2(gspca_dev, reg->reg, reg->val); @@ -1623,29 +1598,17 @@ static int sd_dbg_s_register(struct gspca_dev *gspca_dev, } return -EINVAL; } -#endif -static int sd_chip_ident(struct gspca_dev *gspca_dev, - struct v4l2_dbg_chip_ident *chip) +static int sd_chip_info(struct gspca_dev *gspca_dev, + struct v4l2_dbg_chip_info *chip) { - struct sd *sd = (struct sd *) gspca_dev; - - switch (chip->match.type) { - case V4L2_CHIP_MATCH_HOST: - if (chip->match.addr != 0) - return -EINVAL; - chip->revision = 0; - chip->ident = V4L2_IDENT_SN9C20X; - return 0; - case V4L2_CHIP_MATCH_I2C_ADDR: - if (chip->match.addr != sd->i2c_addr) - return -EINVAL; - chip->revision = 0; - chip->ident = i2c_ident[sd->sensor]; - return 0; - } - return -EINVAL; + if (chip->match.addr > 1) + return -EINVAL; + if (chip->match.addr == 1) + strlcpy(chip->name, "sensor", sizeof(chip->name)); + return 0; } +#endif static int sd_config(struct gspca_dev *gspca_dev, const struct usb_device_id *id) @@ -2356,8 +2319,8 @@ static const struct sd_desc sd_desc = { #ifdef CONFIG_VIDEO_ADV_DEBUG .set_register = sd_dbg_s_register, .get_register = sd_dbg_g_register, + .get_chip_info = sd_chip_info, #endif - .get_chip_ident = sd_chip_ident, }; #define SN9C20X(sensor, i2c_addr, flags) \ From 08fe9f7ddf31b8c42dd1a689b0a2c1501f10b58c Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Wed, 29 May 2013 06:59:43 -0300 Subject: [PATCH 0217/1048] [media] cx231xx: remove g_chip_ident Remove g_chip_ident and replace it with g_chip_info. Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/usb/cx231xx/cx231xx-417.c | 1 - drivers/media/usb/cx231xx/cx231xx-avcore.c | 1 - drivers/media/usb/cx231xx/cx231xx-cards.c | 1 - drivers/media/usb/cx231xx/cx231xx-vbi.c | 1 - drivers/media/usb/cx231xx/cx231xx-video.c | 417 +++++---------------- drivers/media/usb/cx231xx/cx231xx.h | 2 +- 6 files changed, 103 insertions(+), 320 deletions(-) diff --git a/drivers/media/usb/cx231xx/cx231xx-417.c b/drivers/media/usb/cx231xx/cx231xx-417.c index f548db8043d4..2f63029e7a36 100644 --- a/drivers/media/usb/cx231xx/cx231xx-417.c +++ b/drivers/media/usb/cx231xx/cx231xx-417.c @@ -1840,7 +1840,6 @@ static const struct v4l2_ioctl_ops mpeg_ioctl_ops = { .vidioc_streamon = vidioc_streamon, .vidioc_streamoff = vidioc_streamoff, .vidioc_log_status = vidioc_log_status, - .vidioc_g_chip_ident = cx231xx_g_chip_ident, #ifdef CONFIG_VIDEO_ADV_DEBUG .vidioc_g_register = cx231xx_g_register, .vidioc_s_register = cx231xx_s_register, diff --git a/drivers/media/usb/cx231xx/cx231xx-avcore.c b/drivers/media/usb/cx231xx/cx231xx-avcore.c index 235ba657d52e..89de00bf4f82 100644 --- a/drivers/media/usb/cx231xx/cx231xx-avcore.c +++ b/drivers/media/usb/cx231xx/cx231xx-avcore.c @@ -35,7 +35,6 @@ #include #include -#include #include "cx231xx.h" #include "cx231xx-dif.h" diff --git a/drivers/media/usb/cx231xx/cx231xx-cards.c b/drivers/media/usb/cx231xx/cx231xx-cards.c index 13249e5a7891..27948e1798eb 100644 --- a/drivers/media/usb/cx231xx/cx231xx-cards.c +++ b/drivers/media/usb/cx231xx/cx231xx-cards.c @@ -29,7 +29,6 @@ #include #include #include -#include #include #include "dvb-usb-ids.h" diff --git a/drivers/media/usb/cx231xx/cx231xx-vbi.c b/drivers/media/usb/cx231xx/cx231xx-vbi.c index 1340ff268817..c02794274f51 100644 --- a/drivers/media/usb/cx231xx/cx231xx-vbi.c +++ b/drivers/media/usb/cx231xx/cx231xx-vbi.c @@ -32,7 +32,6 @@ #include #include -#include #include #include diff --git a/drivers/media/usb/cx231xx/cx231xx-video.c b/drivers/media/usb/cx231xx/cx231xx-video.c index cd221474e1b9..54cdd4dc455e 100644 --- a/drivers/media/usb/cx231xx/cx231xx-video.c +++ b/drivers/media/usb/cx231xx/cx231xx-video.c @@ -36,7 +36,6 @@ #include #include #include -#include #include #include @@ -1228,179 +1227,86 @@ int cx231xx_s_frequency(struct file *file, void *priv, return rc; } -int cx231xx_g_chip_ident(struct file *file, void *fh, - struct v4l2_dbg_chip_ident *chip) +#ifdef CONFIG_VIDEO_ADV_DEBUG + +int cx231xx_g_chip_info(struct file *file, void *fh, + struct v4l2_dbg_chip_info *chip) { - chip->ident = V4L2_IDENT_NONE; - chip->revision = 0; - if (chip->match.type == V4L2_CHIP_MATCH_HOST) { - if (v4l2_chip_match_host(&chip->match)) - chip->ident = V4L2_IDENT_CX23100; + switch (chip->match.addr) { + case 0: /* Cx231xx - internal registers */ + return 0; + case 1: /* AFE - read byte */ + strlcpy(chip->name, "AFE (byte)", sizeof(chip->name)); + return 0; + case 2: /* Video Block - read byte */ + strlcpy(chip->name, "Video (byte)", sizeof(chip->name)); + return 0; + case 3: /* I2S block - read byte */ + strlcpy(chip->name, "I2S (byte)", sizeof(chip->name)); + return 0; + case 4: /* AFE - read dword */ + strlcpy(chip->name, "AFE (dword)", sizeof(chip->name)); + return 0; + case 5: /* Video Block - read dword */ + strlcpy(chip->name, "Video (dword)", sizeof(chip->name)); + return 0; + case 6: /* I2S Block - read dword */ + strlcpy(chip->name, "I2S (dword)", sizeof(chip->name)); return 0; } return -EINVAL; } -#ifdef CONFIG_VIDEO_ADV_DEBUG - -/* - -R, --list-registers=type=, - chip=[,min=,max=] - dump registers from to [VIDIOC_DBG_G_REGISTER] - -r, --set-register=type=, - chip=,reg=,val= - set the register [VIDIOC_DBG_S_REGISTER] - - if type == host, then is the hosts chip ID (default 0) - if type == i2cdrv (default), then is the I2C driver name or ID - if type == i2caddr, then is the 7-bit I2C address -*/ - int cx231xx_g_register(struct file *file, void *priv, struct v4l2_dbg_register *reg) { struct cx231xx_fh *fh = priv; struct cx231xx *dev = fh->dev; - int ret = 0; + int ret; u8 value[4] = { 0, 0, 0, 0 }; u32 data = 0; - switch (reg->match.type) { - case V4L2_CHIP_MATCH_HOST: - switch (reg->match.addr) { - case 0: /* Cx231xx - internal registers */ - ret = cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, - (u16)reg->reg, value, 4); - reg->val = value[0] | value[1] << 8 | - value[2] << 16 | value[3] << 24; - break; - case 1: /* AFE - read byte */ - ret = cx231xx_read_i2c_data(dev, AFE_DEVICE_ADDRESS, - (u16)reg->reg, 2, &data, 1); - reg->val = le32_to_cpu(data & 0xff); - break; - case 14: /* AFE - read dword */ - ret = cx231xx_read_i2c_data(dev, AFE_DEVICE_ADDRESS, - (u16)reg->reg, 2, &data, 4); - reg->val = le32_to_cpu(data); - break; - case 2: /* Video Block - read byte */ - ret = cx231xx_read_i2c_data(dev, VID_BLK_I2C_ADDRESS, - (u16)reg->reg, 2, &data, 1); - reg->val = le32_to_cpu(data & 0xff); - break; - case 24: /* Video Block - read dword */ - ret = cx231xx_read_i2c_data(dev, VID_BLK_I2C_ADDRESS, - (u16)reg->reg, 2, &data, 4); - reg->val = le32_to_cpu(data); - break; - case 3: /* I2S block - read byte */ - ret = cx231xx_read_i2c_data(dev, - I2S_BLK_DEVICE_ADDRESS, - (u16)reg->reg, 1, - &data, 1); - reg->val = le32_to_cpu(data & 0xff); - break; - case 34: /* I2S Block - read dword */ - ret = - cx231xx_read_i2c_data(dev, I2S_BLK_DEVICE_ADDRESS, - (u16)reg->reg, 1, &data, 4); - reg->val = le32_to_cpu(data); - break; - } - return ret < 0 ? ret : 0; - - case V4L2_CHIP_MATCH_I2C_DRIVER: - call_all(dev, core, g_register, reg); - return 0; - case V4L2_CHIP_MATCH_I2C_ADDR:/*for register debug*/ - switch (reg->match.addr) { - case 0: /* Cx231xx - internal registers */ - ret = cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, - (u16)reg->reg, value, 4); - reg->val = value[0] | value[1] << 8 | - value[2] << 16 | value[3] << 24; - - break; - case 0x600:/* AFE - read byte */ - ret = cx231xx_read_i2c_master(dev, AFE_DEVICE_ADDRESS, - (u16)reg->reg, 2, - &data, 1 , 0); - reg->val = le32_to_cpu(data & 0xff); - break; - - case 0x880:/* Video Block - read byte */ - if (reg->reg < 0x0b) { - ret = cx231xx_read_i2c_master(dev, - VID_BLK_I2C_ADDRESS, - (u16)reg->reg, 2, - &data, 1 , 0); - reg->val = le32_to_cpu(data & 0xff); - } else { - ret = cx231xx_read_i2c_master(dev, - VID_BLK_I2C_ADDRESS, - (u16)reg->reg, 2, - &data, 4 , 0); - reg->val = le32_to_cpu(data); - } - break; - case 0x980: - ret = cx231xx_read_i2c_master(dev, - I2S_BLK_DEVICE_ADDRESS, - (u16)reg->reg, 1, - &data, 1 , 0); - reg->val = le32_to_cpu(data & 0xff); - break; - case 0x400: - ret = - cx231xx_read_i2c_master(dev, 0x40, - (u16)reg->reg, 1, - &data, 1 , 0); - reg->val = le32_to_cpu(data & 0xff); - break; - case 0xc01: - ret = - cx231xx_read_i2c_master(dev, 0xc0, - (u16)reg->reg, 2, - &data, 38, 1); - reg->val = le32_to_cpu(data); - break; - case 0x022: - ret = - cx231xx_read_i2c_master(dev, 0x02, - (u16)reg->reg, 1, - &data, 1, 2); - reg->val = le32_to_cpu(data & 0xff); - break; - case 0x322: - ret = cx231xx_read_i2c_master(dev, - 0x32, - (u16)reg->reg, 1, - &data, 4 , 2); - reg->val = le32_to_cpu(data); - break; - case 0x342: - ret = cx231xx_read_i2c_master(dev, - 0x34, - (u16)reg->reg, 1, - &data, 4 , 2); - reg->val = le32_to_cpu(data); - break; - - default: - cx231xx_info("no match device address!!\n"); - break; - } - return ret < 0 ? ret : 0; - /*return -EINVAL;*/ + switch (reg->match.addr) { + case 0: /* Cx231xx - internal registers */ + ret = cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, + (u16)reg->reg, value, 4); + reg->val = value[0] | value[1] << 8 | + value[2] << 16 | value[3] << 24; + break; + case 1: /* AFE - read byte */ + ret = cx231xx_read_i2c_data(dev, AFE_DEVICE_ADDRESS, + (u16)reg->reg, 2, &data, 1); + reg->val = data; + break; + case 2: /* Video Block - read byte */ + ret = cx231xx_read_i2c_data(dev, VID_BLK_I2C_ADDRESS, + (u16)reg->reg, 2, &data, 1); + reg->val = data; + break; + case 3: /* I2S block - read byte */ + ret = cx231xx_read_i2c_data(dev, I2S_BLK_DEVICE_ADDRESS, + (u16)reg->reg, 1, &data, 1); + reg->val = data; + break; + case 4: /* AFE - read dword */ + ret = cx231xx_read_i2c_data(dev, AFE_DEVICE_ADDRESS, + (u16)reg->reg, 2, &data, 4); + reg->val = data; + break; + case 5: /* Video Block - read dword */ + ret = cx231xx_read_i2c_data(dev, VID_BLK_I2C_ADDRESS, + (u16)reg->reg, 2, &data, 4); + reg->val = data; + break; + case 6: /* I2S Block - read dword */ + ret = cx231xx_read_i2c_data(dev, I2S_BLK_DEVICE_ADDRESS, + (u16)reg->reg, 1, &data, 4); + reg->val = data; + break; default: - if (!v4l2_chip_match_host(®->match)) - return -EINVAL; + return -EINVAL; } - - call_all(dev, core, g_register, reg); - - return ret; + return ret < 0 ? ret : 0; } int cx231xx_s_register(struct file *file, void *priv, @@ -1408,165 +1314,46 @@ int cx231xx_s_register(struct file *file, void *priv, { struct cx231xx_fh *fh = priv; struct cx231xx *dev = fh->dev; - int ret = 0; - __le64 buf; - u32 value; + int ret; u8 data[4] = { 0, 0, 0, 0 }; - buf = cpu_to_le64(reg->val); - - switch (reg->match.type) { - case V4L2_CHIP_MATCH_HOST: - { - value = (u32) buf & 0xffffffff; - - switch (reg->match.addr) { - case 0: /* cx231xx internal registers */ - data[0] = (u8) value; - data[1] = (u8) (value >> 8); - data[2] = (u8) (value >> 16); - data[3] = (u8) (value >> 24); - ret = cx231xx_write_ctrl_reg(dev, - VRT_SET_REGISTER, - (u16)reg->reg, data, - 4); - break; - case 1: /* AFE - read byte */ - ret = cx231xx_write_i2c_data(dev, - AFE_DEVICE_ADDRESS, - (u16)reg->reg, 2, - value, 1); - break; - case 14: /* AFE - read dword */ - ret = cx231xx_write_i2c_data(dev, - AFE_DEVICE_ADDRESS, - (u16)reg->reg, 2, - value, 4); - break; - case 2: /* Video Block - read byte */ - ret = - cx231xx_write_i2c_data(dev, - VID_BLK_I2C_ADDRESS, - (u16)reg->reg, 2, - value, 1); - break; - case 24: /* Video Block - read dword */ - ret = - cx231xx_write_i2c_data(dev, - VID_BLK_I2C_ADDRESS, - (u16)reg->reg, 2, - value, 4); - break; - case 3: /* I2S block - read byte */ - ret = - cx231xx_write_i2c_data(dev, - I2S_BLK_DEVICE_ADDRESS, - (u16)reg->reg, 1, - value, 1); - break; - case 34: /* I2S block - read dword */ - ret = - cx231xx_write_i2c_data(dev, - I2S_BLK_DEVICE_ADDRESS, - (u16)reg->reg, 1, - value, 4); - break; - } - } - return ret < 0 ? ret : 0; - case V4L2_CHIP_MATCH_I2C_ADDR: - { - value = (u32) buf & 0xffffffff; - - switch (reg->match.addr) { - case 0:/*cx231xx internal registers*/ - data[0] = (u8) value; - data[1] = (u8) (value >> 8); - data[2] = (u8) (value >> 16); - data[3] = (u8) (value >> 24); - ret = cx231xx_write_ctrl_reg(dev, - VRT_SET_REGISTER, - (u16)reg->reg, data, - 4); - break; - case 0x600:/* AFE - read byte */ - ret = cx231xx_write_i2c_master(dev, - AFE_DEVICE_ADDRESS, - (u16)reg->reg, 2, - value, 1 , 0); - break; - - case 0x880:/* Video Block - read byte */ - if (reg->reg < 0x0b) - cx231xx_write_i2c_master(dev, - VID_BLK_I2C_ADDRESS, - (u16)reg->reg, 2, - value, 1, 0); - else - cx231xx_write_i2c_master(dev, - VID_BLK_I2C_ADDRESS, - (u16)reg->reg, 2, - value, 4, 0); - break; - case 0x980: - ret = - cx231xx_write_i2c_master(dev, - I2S_BLK_DEVICE_ADDRESS, - (u16)reg->reg, 1, - value, 1, 0); - break; - case 0x400: - ret = - cx231xx_write_i2c_master(dev, - 0x40, - (u16)reg->reg, 1, - value, 1, 0); - break; - case 0xc01: - ret = - cx231xx_write_i2c_master(dev, - 0xc0, - (u16)reg->reg, 1, - value, 1, 1); - break; - - case 0x022: - ret = - cx231xx_write_i2c_master(dev, - 0x02, - (u16)reg->reg, 1, - value, 1, 2); - break; - case 0x322: - ret = - cx231xx_write_i2c_master(dev, - 0x32, - (u16)reg->reg, 1, - value, 4, 2); - break; - - case 0x342: - ret = - cx231xx_write_i2c_master(dev, - 0x34, - (u16)reg->reg, 1, - value, 4, 2); - break; - default: - cx231xx_info("no match device address, " - "the value is %x\n", reg->match.addr); - break; - - } - - } - default: + switch (reg->match.addr) { + case 0: /* cx231xx internal registers */ + data[0] = (u8) reg->val; + data[1] = (u8) (reg->val >> 8); + data[2] = (u8) (reg->val >> 16); + data[3] = (u8) (reg->val >> 24); + ret = cx231xx_write_ctrl_reg(dev, VRT_SET_REGISTER, + (u16)reg->reg, data, 4); break; + case 1: /* AFE - write byte */ + ret = cx231xx_write_i2c_data(dev, AFE_DEVICE_ADDRESS, + (u16)reg->reg, 2, reg->val, 1); + break; + case 2: /* Video Block - write byte */ + ret = cx231xx_write_i2c_data(dev, VID_BLK_I2C_ADDRESS, + (u16)reg->reg, 2, reg->val, 1); + break; + case 3: /* I2S block - write byte */ + ret = cx231xx_write_i2c_data(dev, I2S_BLK_DEVICE_ADDRESS, + (u16)reg->reg, 1, reg->val, 1); + break; + case 4: /* AFE - write dword */ + ret = cx231xx_write_i2c_data(dev, AFE_DEVICE_ADDRESS, + (u16)reg->reg, 2, reg->val, 4); + break; + case 5: /* Video Block - write dword */ + ret = cx231xx_write_i2c_data(dev, VID_BLK_I2C_ADDRESS, + (u16)reg->reg, 2, reg->val, 4); + break; + case 6: /* I2S block - write dword */ + ret = cx231xx_write_i2c_data(dev, I2S_BLK_DEVICE_ADDRESS, + (u16)reg->reg, 1, reg->val, 4); + break; + default: + return -EINVAL; } - - call_all(dev, core, s_register, reg); - - return ret; + return ret < 0 ? ret : 0; } #endif @@ -2208,8 +1995,8 @@ static const struct v4l2_ioctl_ops video_ioctl_ops = { .vidioc_s_tuner = cx231xx_s_tuner, .vidioc_g_frequency = cx231xx_g_frequency, .vidioc_s_frequency = cx231xx_s_frequency, - .vidioc_g_chip_ident = cx231xx_g_chip_ident, #ifdef CONFIG_VIDEO_ADV_DEBUG + .vidioc_g_chip_info = cx231xx_g_chip_info, .vidioc_g_register = cx231xx_g_register, .vidioc_s_register = cx231xx_s_register, #endif @@ -2240,8 +2027,8 @@ static const struct v4l2_ioctl_ops radio_ioctl_ops = { .vidioc_s_tuner = radio_s_tuner, .vidioc_g_frequency = cx231xx_g_frequency, .vidioc_s_frequency = cx231xx_s_frequency, - .vidioc_g_chip_ident = cx231xx_g_chip_ident, #ifdef CONFIG_VIDEO_ADV_DEBUG + .vidioc_g_chip_info = cx231xx_g_chip_info, .vidioc_g_register = cx231xx_g_register, .vidioc_s_register = cx231xx_s_register, #endif diff --git a/drivers/media/usb/cx231xx/cx231xx.h b/drivers/media/usb/cx231xx/cx231xx.h index 5ad9fd61d3c8..e812119ea7a8 100644 --- a/drivers/media/usb/cx231xx/cx231xx.h +++ b/drivers/media/usb/cx231xx/cx231xx.h @@ -945,7 +945,7 @@ int cx231xx_enum_input(struct file *file, void *priv, struct v4l2_input *i); int cx231xx_g_input(struct file *file, void *priv, unsigned int *i); int cx231xx_s_input(struct file *file, void *priv, unsigned int i); -int cx231xx_g_chip_ident(struct file *file, void *fh, struct v4l2_dbg_chip_ident *chip); +int cx231xx_g_chip_info(struct file *file, void *fh, struct v4l2_dbg_chip_info *chip); int cx231xx_g_register(struct file *file, void *priv, struct v4l2_dbg_register *reg); int cx231xx_s_register(struct file *file, void *priv, From 7486af1ae3ee34b12fcff1b1ce3a9cc6a2eca03a Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Wed, 29 May 2013 06:59:44 -0300 Subject: [PATCH 0218/1048] [media] marvell-ccic: remove g_chip_ident Remove g_chip_ident. This driver used some of the V4L2_IDENT defines, replace those with a driver-specific enum. This makes it possible to drop the v4l2-chip-ident.h define as well. Signed-off-by: Hans Verkuil Cc: Jonathan Corbet Signed-off-by: Mauro Carvalho Chehab --- .../media/platform/marvell-ccic/cafe-driver.c | 3 +- .../media/platform/marvell-ccic/mcam-core.c | 55 +++---------------- .../media/platform/marvell-ccic/mcam-core.h | 8 ++- .../media/platform/marvell-ccic/mmp-driver.c | 3 +- 4 files changed, 16 insertions(+), 53 deletions(-) diff --git a/drivers/media/platform/marvell-ccic/cafe-driver.c b/drivers/media/platform/marvell-ccic/cafe-driver.c index d030f9beae88..7b07fc55cd3c 100644 --- a/drivers/media/platform/marvell-ccic/cafe-driver.c +++ b/drivers/media/platform/marvell-ccic/cafe-driver.c @@ -27,7 +27,6 @@ #include #include #include -#include #include #include #include @@ -469,7 +468,7 @@ static int cafe_pci_probe(struct pci_dev *pdev, goto out; cam->pdev = pdev; mcam = &cam->mcam; - mcam->chip_id = V4L2_IDENT_CAFE; + mcam->chip_id = MCAM_CAFE; spin_lock_init(&mcam->dev_lock); init_waitqueue_head(&cam->smbus_wait); mcam->plat_power_up = cafe_ctlr_power_up; diff --git a/drivers/media/platform/marvell-ccic/mcam-core.c b/drivers/media/platform/marvell-ccic/mcam-core.c index 64ab91edfb81..a187161e980e 100644 --- a/drivers/media/platform/marvell-ccic/mcam-core.c +++ b/drivers/media/platform/marvell-ccic/mcam-core.c @@ -23,7 +23,6 @@ #include #include #include -#include #include #include #include @@ -336,7 +335,7 @@ static void mcam_ctlr_dma_vmalloc(struct mcam_camera *cam) mcam_reg_clear_bit(cam, REG_CTRL1, C1_TWOBUFS); } else mcam_reg_set_bit(cam, REG_CTRL1, C1_TWOBUFS); - if (cam->chip_id == V4L2_IDENT_CAFE) + if (cam->chip_id == MCAM_CAFE) mcam_reg_write(cam, REG_UBAR, 0); /* 32 bits only */ } @@ -796,7 +795,6 @@ static int __mcam_cam_reset(struct mcam_camera *cam) */ static int mcam_cam_init(struct mcam_camera *cam) { - struct v4l2_dbg_chip_ident chip; int ret; mutex_lock(&cam->s_mutex); @@ -804,24 +802,8 @@ static int mcam_cam_init(struct mcam_camera *cam) cam_warn(cam, "Cam init with device in funky state %d", cam->state); ret = __mcam_cam_reset(cam); - if (ret) - goto out; - chip.ident = V4L2_IDENT_NONE; - chip.match.type = V4L2_CHIP_MATCH_I2C_ADDR; - chip.match.addr = cam->sensor_addr; - ret = sensor_call(cam, core, g_chip_ident, &chip); - if (ret) - goto out; - cam->sensor_type = chip.ident; - if (cam->sensor_type != V4L2_IDENT_OV7670) { - cam_err(cam, "Unsupported sensor type 0x%x", cam->sensor_type); - ret = -EINVAL; - goto out; - } -/* Get/set parameters? */ - ret = 0; + /* Get/set parameters? */ cam->state = S_IDLE; -out: mcam_ctlr_power_down(cam); mutex_unlock(&cam->s_mutex); return ret; @@ -1392,20 +1374,6 @@ static int mcam_vidioc_s_parm(struct file *filp, void *priv, return ret; } -static int mcam_vidioc_g_chip_ident(struct file *file, void *priv, - struct v4l2_dbg_chip_ident *chip) -{ - struct mcam_camera *cam = priv; - - chip->ident = V4L2_IDENT_NONE; - chip->revision = 0; - if (v4l2_chip_match_host(&chip->match)) { - chip->ident = cam->chip_id; - return 0; - } - return sensor_call(cam, core, g_chip_ident, chip); -} - static int mcam_vidioc_enum_framesizes(struct file *filp, void *priv, struct v4l2_frmsizeenum *sizes) { @@ -1436,12 +1404,9 @@ static int mcam_vidioc_g_register(struct file *file, void *priv, { struct mcam_camera *cam = priv; - if (v4l2_chip_match_host(®->match)) { - reg->val = mcam_reg_read(cam, reg->reg); - reg->size = 4; - return 0; - } - return sensor_call(cam, core, g_register, reg); + reg->val = mcam_reg_read(cam, reg->reg); + reg->size = 4; + return 0; } static int mcam_vidioc_s_register(struct file *file, void *priv, @@ -1449,11 +1414,8 @@ static int mcam_vidioc_s_register(struct file *file, void *priv, { struct mcam_camera *cam = priv; - if (v4l2_chip_match_host(®->match)) { - mcam_reg_write(cam, reg->reg, reg->val); - return 0; - } - return sensor_call(cam, core, s_register, reg); + mcam_reg_write(cam, reg->reg, reg->val); + return 0; } #endif @@ -1477,7 +1439,6 @@ static const struct v4l2_ioctl_ops mcam_v4l_ioctl_ops = { .vidioc_s_parm = mcam_vidioc_s_parm, .vidioc_enum_framesizes = mcam_vidioc_enum_framesizes, .vidioc_enum_frameintervals = mcam_vidioc_enum_frameintervals, - .vidioc_g_chip_ident = mcam_vidioc_g_chip_ident, #ifdef CONFIG_VIDEO_ADV_DEBUG .vidioc_g_register = mcam_vidioc_g_register, .vidioc_s_register = mcam_vidioc_s_register, @@ -1695,7 +1656,7 @@ int mccic_register(struct mcam_camera *cam) if (buffer_mode >= 0) cam->buffer_mode = buffer_mode; if (cam->buffer_mode == B_DMA_sg && - cam->chip_id == V4L2_IDENT_CAFE) { + cam->chip_id == MCAM_CAFE) { printk(KERN_ERR "marvell-cam: Cafe can't do S/G I/O, " "attempting vmalloc mode instead\n"); cam->buffer_mode = B_vmalloc; diff --git a/drivers/media/platform/marvell-ccic/mcam-core.h b/drivers/media/platform/marvell-ccic/mcam-core.h index 01dec9e5fc2b..46b6ea31e66b 100644 --- a/drivers/media/platform/marvell-ccic/mcam-core.h +++ b/drivers/media/platform/marvell-ccic/mcam-core.h @@ -53,6 +53,11 @@ enum mcam_buffer_mode { B_DMA_sg = 2 }; +enum mcam_chip_id { + MCAM_CAFE, + MCAM_ARMADA610, +}; + /* * Is a given buffer mode supported by the current kernel configuration? */ @@ -98,7 +103,7 @@ struct mcam_camera { unsigned char __iomem *regs; spinlock_t dev_lock; struct device *dev; /* For messages, dma alloc */ - unsigned int chip_id; + enum mcam_chip_id chip_id; short int clock_speed; /* Sensor clock speed, default 30 */ short int use_smbus; /* SMBUS or straight I2c? */ enum mcam_buffer_mode buffer_mode; @@ -152,7 +157,6 @@ struct mcam_camera { void (*frame_complete)(struct mcam_camera *cam, int frame); /* Current operating parameters */ - u32 sensor_type; /* Currently ov7670 only */ struct v4l2_pix_format pix_format; enum v4l2_mbus_pixelcode mbus_code; diff --git a/drivers/media/platform/marvell-ccic/mmp-driver.c b/drivers/media/platform/marvell-ccic/mmp-driver.c index c4c17fe76c0d..cadad647ce0e 100644 --- a/drivers/media/platform/marvell-ccic/mmp-driver.c +++ b/drivers/media/platform/marvell-ccic/mmp-driver.c @@ -18,7 +18,6 @@ #include #include #include -#include #include #include #include @@ -185,7 +184,7 @@ static int mmpcam_probe(struct platform_device *pdev) mcam->plat_power_down = mmpcam_power_down; mcam->dev = &pdev->dev; mcam->use_smbus = 0; - mcam->chip_id = V4L2_IDENT_ARMADA610; + mcam->chip_id = MCAM_ARMADA610; mcam->buffer_mode = B_DMA_sg; spin_lock_init(&mcam->dev_lock); /* From 33001010013749886eca5b5645efd80006dd2e51 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Wed, 29 May 2013 06:59:45 -0300 Subject: [PATCH 0219/1048] [media] tveeprom: remove v4l2-chip-ident.h include Replace the V4L2_IDENT_* usage with tveeprom-specific defines. This header is deprecated, so those defines shouldn't be used anymore. The em28xx driver is the only one that uses the tveeprom audio_processor field, so that has been updated to use the new tveeprom AUDPROC define. Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/common/tveeprom.c | 142 +++++++++++------------- drivers/media/usb/em28xx/em28xx-cards.c | 3 +- include/media/tveeprom.h | 11 ++ 3 files changed, 78 insertions(+), 78 deletions(-) diff --git a/drivers/media/common/tveeprom.c b/drivers/media/common/tveeprom.c index cc1e172dfece..c7dace671a9d 100644 --- a/drivers/media/common/tveeprom.c +++ b/drivers/media/common/tveeprom.c @@ -40,7 +40,6 @@ #include #include #include -#include MODULE_DESCRIPTION("i2c Hauppauge eeprom decoder driver"); MODULE_AUTHOR("John Klar"); @@ -67,13 +66,10 @@ MODULE_PARM_DESC(debug, "Debug level (0-1)"); * The Hauppauge eeprom uses an 8bit field to determine which * tuner formats the tuner supports. */ -static struct HAUPPAUGE_TUNER_FMT -{ +static const struct { int id; - char *name; -} -hauppauge_tuner_fmt[] = -{ + const char * const name; +} hauppauge_tuner_fmt[] = { { V4L2_STD_UNKNOWN, " UNKNOWN" }, { V4L2_STD_UNKNOWN, " FM" }, { V4L2_STD_B|V4L2_STD_GH, " PAL(B/G)" }, @@ -88,13 +84,10 @@ hauppauge_tuner_fmt[] = supplying this information. Note that many tuners where only used for testing and never made it to the outside world. So you will only see a subset in actual produced cards. */ -static struct HAUPPAUGE_TUNER -{ +static const struct { int id; - char *name; -} -hauppauge_tuner[] = -{ + const char * const name; +} hauppauge_tuner[] = { /* 0-9 */ { TUNER_ABSENT, "None" }, { TUNER_ABSENT, "External" }, @@ -298,69 +291,66 @@ hauppauge_tuner[] = { TUNER_ABSENT, "NXP 18272S"}, }; -/* Use V4L2_IDENT_AMBIGUOUS for those audio 'chips' that are +/* Use TVEEPROM_AUDPROC_INTERNAL for those audio 'chips' that are * internal to a video chip, i.e. not a separate audio chip. */ -static struct HAUPPAUGE_AUDIOIC -{ +static const struct { u32 id; - char *name; -} -audioIC[] = -{ + const char * const name; +} audio_ic[] = { /* 0-4 */ - { V4L2_IDENT_NONE, "None" }, - { V4L2_IDENT_UNKNOWN, "TEA6300" }, - { V4L2_IDENT_UNKNOWN, "TEA6320" }, - { V4L2_IDENT_UNKNOWN, "TDA9850" }, - { V4L2_IDENT_MSPX4XX, "MSP3400C" }, + { TVEEPROM_AUDPROC_NONE, "None" }, + { TVEEPROM_AUDPROC_OTHER, "TEA6300" }, + { TVEEPROM_AUDPROC_OTHER, "TEA6320" }, + { TVEEPROM_AUDPROC_OTHER, "TDA9850" }, + { TVEEPROM_AUDPROC_MSP, "MSP3400C" }, /* 5-9 */ - { V4L2_IDENT_MSPX4XX, "MSP3410D" }, - { V4L2_IDENT_MSPX4XX, "MSP3415" }, - { V4L2_IDENT_MSPX4XX, "MSP3430" }, - { V4L2_IDENT_MSPX4XX, "MSP3438" }, - { V4L2_IDENT_UNKNOWN, "CS5331" }, + { TVEEPROM_AUDPROC_MSP, "MSP3410D" }, + { TVEEPROM_AUDPROC_MSP, "MSP3415" }, + { TVEEPROM_AUDPROC_MSP, "MSP3430" }, + { TVEEPROM_AUDPROC_MSP, "MSP3438" }, + { TVEEPROM_AUDPROC_OTHER, "CS5331" }, /* 10-14 */ - { V4L2_IDENT_MSPX4XX, "MSP3435" }, - { V4L2_IDENT_MSPX4XX, "MSP3440" }, - { V4L2_IDENT_MSPX4XX, "MSP3445" }, - { V4L2_IDENT_MSPX4XX, "MSP3411" }, - { V4L2_IDENT_MSPX4XX, "MSP3416" }, + { TVEEPROM_AUDPROC_MSP, "MSP3435" }, + { TVEEPROM_AUDPROC_MSP, "MSP3440" }, + { TVEEPROM_AUDPROC_MSP, "MSP3445" }, + { TVEEPROM_AUDPROC_MSP, "MSP3411" }, + { TVEEPROM_AUDPROC_MSP, "MSP3416" }, /* 15-19 */ - { V4L2_IDENT_MSPX4XX, "MSP3425" }, - { V4L2_IDENT_MSPX4XX, "MSP3451" }, - { V4L2_IDENT_MSPX4XX, "MSP3418" }, - { V4L2_IDENT_UNKNOWN, "Type 0x12" }, - { V4L2_IDENT_UNKNOWN, "OKI7716" }, + { TVEEPROM_AUDPROC_MSP, "MSP3425" }, + { TVEEPROM_AUDPROC_MSP, "MSP3451" }, + { TVEEPROM_AUDPROC_MSP, "MSP3418" }, + { TVEEPROM_AUDPROC_OTHER, "Type 0x12" }, + { TVEEPROM_AUDPROC_OTHER, "OKI7716" }, /* 20-24 */ - { V4L2_IDENT_MSPX4XX, "MSP4410" }, - { V4L2_IDENT_MSPX4XX, "MSP4420" }, - { V4L2_IDENT_MSPX4XX, "MSP4440" }, - { V4L2_IDENT_MSPX4XX, "MSP4450" }, - { V4L2_IDENT_MSPX4XX, "MSP4408" }, + { TVEEPROM_AUDPROC_MSP, "MSP4410" }, + { TVEEPROM_AUDPROC_MSP, "MSP4420" }, + { TVEEPROM_AUDPROC_MSP, "MSP4440" }, + { TVEEPROM_AUDPROC_MSP, "MSP4450" }, + { TVEEPROM_AUDPROC_MSP, "MSP4408" }, /* 25-29 */ - { V4L2_IDENT_MSPX4XX, "MSP4418" }, - { V4L2_IDENT_MSPX4XX, "MSP4428" }, - { V4L2_IDENT_MSPX4XX, "MSP4448" }, - { V4L2_IDENT_MSPX4XX, "MSP4458" }, - { V4L2_IDENT_MSPX4XX, "Type 0x1d" }, + { TVEEPROM_AUDPROC_MSP, "MSP4418" }, + { TVEEPROM_AUDPROC_MSP, "MSP4428" }, + { TVEEPROM_AUDPROC_MSP, "MSP4448" }, + { TVEEPROM_AUDPROC_MSP, "MSP4458" }, + { TVEEPROM_AUDPROC_MSP, "Type 0x1d" }, /* 30-34 */ - { V4L2_IDENT_AMBIGUOUS, "CX880" }, - { V4L2_IDENT_AMBIGUOUS, "CX881" }, - { V4L2_IDENT_AMBIGUOUS, "CX883" }, - { V4L2_IDENT_AMBIGUOUS, "CX882" }, - { V4L2_IDENT_AMBIGUOUS, "CX25840" }, + { TVEEPROM_AUDPROC_INTERNAL, "CX880" }, + { TVEEPROM_AUDPROC_INTERNAL, "CX881" }, + { TVEEPROM_AUDPROC_INTERNAL, "CX883" }, + { TVEEPROM_AUDPROC_INTERNAL, "CX882" }, + { TVEEPROM_AUDPROC_INTERNAL, "CX25840" }, /* 35-39 */ - { V4L2_IDENT_AMBIGUOUS, "CX25841" }, - { V4L2_IDENT_AMBIGUOUS, "CX25842" }, - { V4L2_IDENT_AMBIGUOUS, "CX25843" }, - { V4L2_IDENT_AMBIGUOUS, "CX23418" }, - { V4L2_IDENT_AMBIGUOUS, "CX23885" }, + { TVEEPROM_AUDPROC_INTERNAL, "CX25841" }, + { TVEEPROM_AUDPROC_INTERNAL, "CX25842" }, + { TVEEPROM_AUDPROC_INTERNAL, "CX25843" }, + { TVEEPROM_AUDPROC_INTERNAL, "CX23418" }, + { TVEEPROM_AUDPROC_INTERNAL, "CX23885" }, /* 40-44 */ - { V4L2_IDENT_AMBIGUOUS, "CX23888" }, - { V4L2_IDENT_AMBIGUOUS, "SAA7131" }, - { V4L2_IDENT_AMBIGUOUS, "CX23887" }, - { V4L2_IDENT_AMBIGUOUS, "SAA7164" }, - { V4L2_IDENT_AMBIGUOUS, "AU8522" }, + { TVEEPROM_AUDPROC_INTERNAL, "CX23888" }, + { TVEEPROM_AUDPROC_INTERNAL, "SAA7131" }, + { TVEEPROM_AUDPROC_INTERNAL, "CX23887" }, + { TVEEPROM_AUDPROC_INTERNAL, "SAA7164" }, + { TVEEPROM_AUDPROC_INTERNAL, "AU8522" }, }; /* This list is supplied by Hauppauge. Thanks! */ @@ -453,11 +443,11 @@ void tveeprom_hauppauge_analog(struct i2c_client *c, struct tveeprom *tvee, int i, j, len, done, beenhere, tag, start; int tuner1 = 0, t_format1 = 0, audioic = -1; - char *t_name1 = NULL; + const char *t_name1 = NULL; const char *t_fmt_name1[8] = { " none", "", "", "", "", "", "", "" }; int tuner2 = 0, t_format2 = 0; - char *t_name2 = NULL; + const char *t_name2 = NULL; const char *t_fmt_name2[8] = { " none", "", "", "", "", "", "", "" }; memset(tvee, 0, sizeof(*tvee)); @@ -545,10 +535,10 @@ void tveeprom_hauppauge_analog(struct i2c_client *c, struct tveeprom *tvee, to indicate 4052 mux was removed in favor of using MSP inputs directly. */ audioic = eeprom_data[i+2] & 0x7f; - if (audioic < ARRAY_SIZE(audioIC)) - tvee->audio_processor = audioIC[audioic].id; + if (audioic < ARRAY_SIZE(audio_ic)) + tvee->audio_processor = audio_ic[audioic].id; else - tvee->audio_processor = V4L2_IDENT_UNKNOWN; + tvee->audio_processor = TVEEPROM_AUDPROC_OTHER; break; /* case 0x03: tag 'EEInfo' */ @@ -578,10 +568,10 @@ void tveeprom_hauppauge_analog(struct i2c_client *c, struct tveeprom *tvee, to indicate 4052 mux was removed in favor of using MSP inputs directly. */ audioic = eeprom_data[i+1] & 0x7f; - if (audioic < ARRAY_SIZE(audioIC)) - tvee->audio_processor = audioIC[audioic].id; + if (audioic < ARRAY_SIZE(audio_ic)) + tvee->audio_processor = audio_ic[audioic].id; else - tvee->audio_processor = V4L2_IDENT_UNKNOWN; + tvee->audio_processor = TVEEPROM_AUDPROC_OTHER; break; @@ -726,11 +716,11 @@ void tveeprom_hauppauge_analog(struct i2c_client *c, struct tveeprom *tvee, t_fmt_name2[6], t_fmt_name2[7], t_format2); if (audioic < 0) { tveeprom_info("audio processor is unknown (no idx)\n"); - tvee->audio_processor = V4L2_IDENT_UNKNOWN; + tvee->audio_processor = TVEEPROM_AUDPROC_OTHER; } else { - if (audioic < ARRAY_SIZE(audioIC)) + if (audioic < ARRAY_SIZE(audio_ic)) tveeprom_info("audio processor is %s (idx %d)\n", - audioIC[audioic].name, audioic); + audio_ic[audioic].name, audioic); else tveeprom_info("audio processor is unknown (idx %d)\n", audioic); diff --git a/drivers/media/usb/em28xx/em28xx-cards.c b/drivers/media/usb/em28xx/em28xx-cards.c index 927956b4dca7..e4b0669d49dd 100644 --- a/drivers/media/usb/em28xx/em28xx-cards.c +++ b/drivers/media/usb/em28xx/em28xx-cards.c @@ -37,7 +37,6 @@ #include #include #include -#include #include "em28xx.h" @@ -2669,7 +2668,7 @@ static void em28xx_card_setup(struct em28xx *dev) dev->tuner_type = tv.tuner_type; - if (tv.audio_processor == V4L2_IDENT_MSPX4XX) { + if (tv.audio_processor == TVEEPROM_AUDPROC_MSP) { dev->i2s_speed = 2048000; dev->board.has_msp34xx = 1; } diff --git a/include/media/tveeprom.h b/include/media/tveeprom.h index a8ad75a9152a..4a1191abd936 100644 --- a/include/media/tveeprom.h +++ b/include/media/tveeprom.h @@ -1,6 +1,17 @@ /* */ +enum tveeprom_audio_processor { + /* No audio processor present */ + TVEEPROM_AUDPROC_NONE, + /* The audio processor is internal to the video processor */ + TVEEPROM_AUDPROC_INTERNAL, + /* The audio processor is a MSPXXXX device */ + TVEEPROM_AUDPROC_MSP, + /* The audio processor is another device */ + TVEEPROM_AUDPROC_OTHER, +}; + struct tveeprom { u32 has_radio; /* If has_ir == 0, then it is unknown what the IR capabilities are, From 4b7be2bbe0fa8a0e70a61506dcdf088e3b8a8917 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Wed, 29 May 2013 06:59:47 -0300 Subject: [PATCH 0220/1048] [media] au8522_decoder: remove g_chip_ident op This is no longer needed since the core now handles this through DBG_G_CHIP_INFO. Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb-frontends/au8522_decoder.c | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/drivers/media/dvb-frontends/au8522_decoder.c b/drivers/media/dvb-frontends/au8522_decoder.c index 9d159b48e50b..23a0d05ba426 100644 --- a/drivers/media/dvb-frontends/au8522_decoder.c +++ b/drivers/media/dvb-frontends/au8522_decoder.c @@ -35,7 +35,6 @@ #include #include #include -#include #include #include "au8522.h" #include "au8522_priv.h" @@ -524,11 +523,8 @@ static int au8522_s_ctrl(struct v4l2_ctrl *ctrl) static int au8522_g_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg) { - struct i2c_client *client = v4l2_get_subdevdata(sd); struct au8522_state *state = to_state(sd); - if (!v4l2_chip_match_i2c_client(client, ®->match)) - return -EINVAL; reg->val = au8522_readreg(state, reg->reg & 0xffff); return 0; } @@ -536,11 +532,8 @@ static int au8522_g_register(struct v4l2_subdev *sd, static int au8522_s_register(struct v4l2_subdev *sd, const struct v4l2_dbg_register *reg) { - struct i2c_client *client = v4l2_get_subdevdata(sd); struct au8522_state *state = to_state(sd); - if (!v4l2_chip_match_i2c_client(client, ®->match)) - return -EINVAL; au8522_writereg(state, reg->reg, reg->val & 0xff); return 0; } @@ -632,20 +625,10 @@ static int au8522_g_tuner(struct v4l2_subdev *sd, struct v4l2_tuner *vt) return 0; } -static int au8522_g_chip_ident(struct v4l2_subdev *sd, - struct v4l2_dbg_chip_ident *chip) -{ - struct au8522_state *state = to_state(sd); - struct i2c_client *client = v4l2_get_subdevdata(sd); - - return v4l2_chip_ident_i2c_client(client, chip, state->id, state->rev); -} - /* ----------------------------------------------------------------------- */ static const struct v4l2_subdev_core_ops au8522_core_ops = { .log_status = v4l2_ctrl_subdev_log_status, - .g_chip_ident = au8522_g_chip_ident, .reset = au8522_reset, #ifdef CONFIG_VIDEO_ADV_DEBUG .g_register = au8522_g_register, From 5f7105755ffe17840a209c556a6f56f31122304b Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Wed, 29 May 2013 06:59:48 -0300 Subject: [PATCH 0221/1048] [media] radio: remove g_chip_ident op This is no longer needed since the core now handles this through DBG_G_CHIP_INFO. Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/radio/saa7706h.c | 10 ---------- drivers/media/radio/tef6862.c | 14 -------------- 2 files changed, 24 deletions(-) diff --git a/drivers/media/radio/saa7706h.c b/drivers/media/radio/saa7706h.c index 06c06cc9ff25..d1f30d6762d3 100644 --- a/drivers/media/radio/saa7706h.c +++ b/drivers/media/radio/saa7706h.c @@ -25,7 +25,6 @@ #include #include #include -#include #define DRIVER_NAME "saa7706h" @@ -349,16 +348,7 @@ static int saa7706h_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl) return -EINVAL; } -static int saa7706h_g_chip_ident(struct v4l2_subdev *sd, - struct v4l2_dbg_chip_ident *chip) -{ - struct i2c_client *client = v4l2_get_subdevdata(sd); - - return v4l2_chip_ident_i2c_client(client, chip, V4L2_IDENT_SAA7706H, 0); -} - static const struct v4l2_subdev_core_ops saa7706h_core_ops = { - .g_chip_ident = saa7706h_g_chip_ident, .queryctrl = saa7706h_queryctrl, .g_ctrl = saa7706h_g_ctrl, .s_ctrl = saa7706h_s_ctrl, diff --git a/drivers/media/radio/tef6862.c b/drivers/media/radio/tef6862.c index 82c6c9475d7c..d78afbb08569 100644 --- a/drivers/media/radio/tef6862.c +++ b/drivers/media/radio/tef6862.c @@ -25,7 +25,6 @@ #include #include #include -#include #define DRIVER_NAME "tef6862" @@ -136,14 +135,6 @@ static int tef6862_g_frequency(struct v4l2_subdev *sd, struct v4l2_frequency *f) return 0; } -static int tef6862_g_chip_ident(struct v4l2_subdev *sd, - struct v4l2_dbg_chip_ident *chip) -{ - struct i2c_client *client = v4l2_get_subdevdata(sd); - - return v4l2_chip_ident_i2c_client(client, chip, V4L2_IDENT_TEF6862, 0); -} - static const struct v4l2_subdev_tuner_ops tef6862_tuner_ops = { .g_tuner = tef6862_g_tuner, .s_tuner = tef6862_s_tuner, @@ -151,12 +142,7 @@ static const struct v4l2_subdev_tuner_ops tef6862_tuner_ops = { .g_frequency = tef6862_g_frequency, }; -static const struct v4l2_subdev_core_ops tef6862_core_ops = { - .g_chip_ident = tef6862_g_chip_ident, -}; - static const struct v4l2_subdev_ops tef6862_ops = { - .core = &tef6862_core_ops, .tuner = &tef6862_tuner_ops, }; From cc3590dbb8d74fb28a294047886c34ebc0ae52bc Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Wed, 29 May 2013 06:59:49 -0300 Subject: [PATCH 0222/1048] [media] indycam: remove g_chip_ident op This is no longer needed since the core now handles this through DBG_G_CHIP_INFO. Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/indycam.c | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/drivers/media/platform/indycam.c b/drivers/media/platform/indycam.c index 548236333cce..f1d192bbcb4c 100644 --- a/drivers/media/platform/indycam.c +++ b/drivers/media/platform/indycam.c @@ -23,7 +23,6 @@ #include #include #include -#include #include "indycam.h" @@ -283,20 +282,9 @@ static int indycam_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl) /* I2C-interface */ -static int indycam_g_chip_ident(struct v4l2_subdev *sd, - struct v4l2_dbg_chip_ident *chip) -{ - struct i2c_client *client = v4l2_get_subdevdata(sd); - struct indycam *camera = to_indycam(sd); - - return v4l2_chip_ident_i2c_client(client, chip, V4L2_IDENT_INDYCAM, - camera->version); -} - /* ----------------------------------------------------------------------- */ static const struct v4l2_subdev_core_ops indycam_core_ops = { - .g_chip_ident = indycam_g_chip_ident, .g_ctrl = indycam_g_ctrl, .s_ctrl = indycam_s_ctrl, }; From 6be89daa03a4c99b0d22a59a660b225a592ed0a9 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Wed, 29 May 2013 06:59:50 -0300 Subject: [PATCH 0223/1048] [media] soc_camera sensors: remove g_chip_ident op This is no longer needed since the core now handles this through DBG_G_CHIP_INFO. Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/i2c/soc_camera/imx074.c | 19 --------- drivers/media/i2c/soc_camera/mt9m001.c | 33 +--------------- drivers/media/i2c/soc_camera/mt9m111.c | 33 +--------------- drivers/media/i2c/soc_camera/mt9t031.c | 32 +-------------- drivers/media/i2c/soc_camera/mt9t112.c | 16 -------- drivers/media/i2c/soc_camera/mt9v022.c | 47 +++++++---------------- drivers/media/i2c/soc_camera/ov2640.c | 16 -------- drivers/media/i2c/soc_camera/ov5642.c | 19 --------- drivers/media/i2c/soc_camera/ov6650.c | 12 ------ drivers/media/i2c/soc_camera/ov772x.c | 16 -------- drivers/media/i2c/soc_camera/ov9640.c | 16 -------- drivers/media/i2c/soc_camera/ov9740.c | 17 -------- drivers/media/i2c/soc_camera/rj54n1cb0c.c | 31 +-------------- drivers/media/i2c/soc_camera/tw9910.c | 14 ------- 14 files changed, 21 insertions(+), 300 deletions(-) diff --git a/drivers/media/i2c/soc_camera/imx074.c b/drivers/media/i2c/soc_camera/imx074.c index a2a5cbbdbe28..a315d4386c8e 100644 --- a/drivers/media/i2c/soc_camera/imx074.c +++ b/drivers/media/i2c/soc_camera/imx074.c @@ -19,7 +19,6 @@ #include #include -#include /* IMX074 registers */ @@ -251,23 +250,6 @@ static int imx074_s_stream(struct v4l2_subdev *sd, int enable) return reg_write(client, MODE_SELECT, !!enable); } -static int imx074_g_chip_ident(struct v4l2_subdev *sd, - struct v4l2_dbg_chip_ident *id) -{ - struct i2c_client *client = v4l2_get_subdevdata(sd); - - if (id->match.type != V4L2_CHIP_MATCH_I2C_ADDR) - return -EINVAL; - - if (id->match.addr != client->addr) - return -ENODEV; - - id->ident = V4L2_IDENT_IMX074; - id->revision = 0; - - return 0; -} - static int imx074_s_power(struct v4l2_subdev *sd, int on) { struct i2c_client *client = v4l2_get_subdevdata(sd); @@ -299,7 +281,6 @@ static struct v4l2_subdev_video_ops imx074_subdev_video_ops = { }; static struct v4l2_subdev_core_ops imx074_subdev_core_ops = { - .g_chip_ident = imx074_g_chip_ident, .s_power = imx074_s_power, }; diff --git a/drivers/media/i2c/soc_camera/mt9m001.c b/drivers/media/i2c/soc_camera/mt9m001.c index dd9089805757..3f1f437ee1c6 100644 --- a/drivers/media/i2c/soc_camera/mt9m001.c +++ b/drivers/media/i2c/soc_camera/mt9m001.c @@ -17,7 +17,6 @@ #include #include #include -#include #include /* @@ -97,7 +96,6 @@ struct mt9m001 { const struct mt9m001_datafmt *fmt; const struct mt9m001_datafmt *fmts; int num_fmts; - int model; /* V4L2_IDENT_MT9M001* codes from v4l2-chip-ident.h */ unsigned int total_h; unsigned short y_skip_top; /* Lines to skip at the top */ }; @@ -320,36 +318,15 @@ static int mt9m001_try_fmt(struct v4l2_subdev *sd, return 0; } -static int mt9m001_g_chip_ident(struct v4l2_subdev *sd, - struct v4l2_dbg_chip_ident *id) -{ - struct i2c_client *client = v4l2_get_subdevdata(sd); - struct mt9m001 *mt9m001 = to_mt9m001(client); - - if (id->match.type != V4L2_CHIP_MATCH_I2C_ADDR) - return -EINVAL; - - if (id->match.addr != client->addr) - return -ENODEV; - - id->ident = mt9m001->model; - id->revision = 0; - - return 0; -} - #ifdef CONFIG_VIDEO_ADV_DEBUG static int mt9m001_g_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg) { struct i2c_client *client = v4l2_get_subdevdata(sd); - if (reg->match.type != V4L2_CHIP_MATCH_I2C_ADDR || reg->reg > 0xff) + if (reg->reg > 0xff) return -EINVAL; - if (reg->match.addr != client->addr) - return -ENODEV; - reg->size = 2; reg->val = reg_read(client, reg->reg); @@ -364,12 +341,9 @@ static int mt9m001_s_register(struct v4l2_subdev *sd, { struct i2c_client *client = v4l2_get_subdevdata(sd); - if (reg->match.type != V4L2_CHIP_MATCH_I2C_ADDR || reg->reg > 0xff) + if (reg->reg > 0xff) return -EINVAL; - if (reg->match.addr != client->addr) - return -ENODEV; - if (reg_write(client, reg->reg, reg->val) < 0) return -EIO; @@ -505,11 +479,9 @@ static int mt9m001_video_probe(struct soc_camera_subdev_desc *ssdd, switch (data) { case 0x8411: case 0x8421: - mt9m001->model = V4L2_IDENT_MT9M001C12ST; mt9m001->fmts = mt9m001_colour_fmts; break; case 0x8431: - mt9m001->model = V4L2_IDENT_MT9M001C12STM; mt9m001->fmts = mt9m001_monochrome_fmts; break; default: @@ -580,7 +552,6 @@ static const struct v4l2_ctrl_ops mt9m001_ctrl_ops = { }; static struct v4l2_subdev_core_ops mt9m001_subdev_core_ops = { - .g_chip_ident = mt9m001_g_chip_ident, #ifdef CONFIG_VIDEO_ADV_DEBUG .g_register = mt9m001_g_register, .s_register = mt9m001_s_register, diff --git a/drivers/media/i2c/soc_camera/mt9m111.c b/drivers/media/i2c/soc_camera/mt9m111.c index 8bd4e0d2ea03..1aaca0423df7 100644 --- a/drivers/media/i2c/soc_camera/mt9m111.c +++ b/drivers/media/i2c/soc_camera/mt9m111.c @@ -19,7 +19,6 @@ #include #include #include -#include /* * MT9M111, MT9M112 and MT9M131: @@ -205,8 +204,6 @@ struct mt9m111 { struct v4l2_subdev subdev; struct v4l2_ctrl_handler hdl; struct v4l2_ctrl *gain; - int model; /* V4L2_IDENT_MT9M111 or V4L2_IDENT_MT9M112 code - * from v4l2-chip-ident.h */ struct mt9m111_context *ctx; struct v4l2_rect rect; /* cropping rectangle */ int width; /* output */ @@ -600,24 +597,6 @@ static int mt9m111_s_fmt(struct v4l2_subdev *sd, return ret; } -static int mt9m111_g_chip_ident(struct v4l2_subdev *sd, - struct v4l2_dbg_chip_ident *id) -{ - struct i2c_client *client = v4l2_get_subdevdata(sd); - struct mt9m111 *mt9m111 = container_of(sd, struct mt9m111, subdev); - - if (id->match.type != V4L2_CHIP_MATCH_I2C_ADDR) - return -EINVAL; - - if (id->match.addr != client->addr) - return -ENODEV; - - id->ident = mt9m111->model; - id->revision = 0; - - return 0; -} - #ifdef CONFIG_VIDEO_ADV_DEBUG static int mt9m111_g_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg) @@ -625,10 +604,8 @@ static int mt9m111_g_register(struct v4l2_subdev *sd, struct i2c_client *client = v4l2_get_subdevdata(sd); int val; - if (reg->match.type != V4L2_CHIP_MATCH_I2C_ADDR || reg->reg > 0x2ff) + if (reg->reg > 0x2ff) return -EINVAL; - if (reg->match.addr != client->addr) - return -ENODEV; val = mt9m111_reg_read(client, reg->reg); reg->size = 2; @@ -645,12 +622,9 @@ static int mt9m111_s_register(struct v4l2_subdev *sd, { struct i2c_client *client = v4l2_get_subdevdata(sd); - if (reg->match.type != V4L2_CHIP_MATCH_I2C_ADDR || reg->reg > 0x2ff) + if (reg->reg > 0x2ff) return -EINVAL; - if (reg->match.addr != client->addr) - return -ENODEV; - if (mt9m111_reg_write(client, reg->reg, reg->val) < 0) return -EIO; @@ -856,7 +830,6 @@ static const struct v4l2_ctrl_ops mt9m111_ctrl_ops = { }; static struct v4l2_subdev_core_ops mt9m111_subdev_core_ops = { - .g_chip_ident = mt9m111_g_chip_ident, .s_power = mt9m111_s_power, #ifdef CONFIG_VIDEO_ADV_DEBUG .g_register = mt9m111_g_register, @@ -923,12 +896,10 @@ static int mt9m111_video_probe(struct i2c_client *client) switch (data) { case 0x143a: /* MT9M111 or MT9M131 */ - mt9m111->model = V4L2_IDENT_MT9M111; dev_info(&client->dev, "Detected a MT9M111/MT9M131 chip ID %x\n", data); break; case 0x148c: /* MT9M112 */ - mt9m111->model = V4L2_IDENT_MT9M112; dev_info(&client->dev, "Detected a MT9M112 chip ID %x\n", data); break; default: diff --git a/drivers/media/i2c/soc_camera/mt9t031.c b/drivers/media/i2c/soc_camera/mt9t031.c index 26a15b87a9a2..1d2cc27767fe 100644 --- a/drivers/media/i2c/soc_camera/mt9t031.c +++ b/drivers/media/i2c/soc_camera/mt9t031.c @@ -18,7 +18,6 @@ #include #include -#include #include #include @@ -76,7 +75,6 @@ struct mt9t031 { struct v4l2_ctrl *exposure; }; struct v4l2_rect rect; /* Sensor window */ - int model; /* V4L2_IDENT_MT9T031* codes from v4l2-chip-ident.h */ u16 xskip; u16 yskip; unsigned int total_h; @@ -391,36 +389,15 @@ static int mt9t031_try_fmt(struct v4l2_subdev *sd, return 0; } -static int mt9t031_g_chip_ident(struct v4l2_subdev *sd, - struct v4l2_dbg_chip_ident *id) -{ - struct i2c_client *client = v4l2_get_subdevdata(sd); - struct mt9t031 *mt9t031 = to_mt9t031(client); - - if (id->match.type != V4L2_CHIP_MATCH_I2C_ADDR) - return -EINVAL; - - if (id->match.addr != client->addr) - return -ENODEV; - - id->ident = mt9t031->model; - id->revision = 0; - - return 0; -} - #ifdef CONFIG_VIDEO_ADV_DEBUG static int mt9t031_g_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg) { struct i2c_client *client = v4l2_get_subdevdata(sd); - if (reg->match.type != V4L2_CHIP_MATCH_I2C_ADDR || reg->reg > 0xff) + if (reg->reg > 0xff) return -EINVAL; - if (reg->match.addr != client->addr) - return -ENODEV; - reg->val = reg_read(client, reg->reg); if (reg->val > 0xffff) @@ -434,12 +411,9 @@ static int mt9t031_s_register(struct v4l2_subdev *sd, { struct i2c_client *client = v4l2_get_subdevdata(sd); - if (reg->match.type != V4L2_CHIP_MATCH_I2C_ADDR || reg->reg > 0xff) + if (reg->reg > 0xff) return -EINVAL; - if (reg->match.addr != client->addr) - return -ENODEV; - if (reg_write(client, reg->reg, reg->val) < 0) return -EIO; @@ -650,7 +624,6 @@ static int mt9t031_video_probe(struct i2c_client *client) switch (data) { case 0x1621: - mt9t031->model = V4L2_IDENT_MT9T031; break; default: dev_err(&client->dev, @@ -685,7 +658,6 @@ static const struct v4l2_ctrl_ops mt9t031_ctrl_ops = { }; static struct v4l2_subdev_core_ops mt9t031_subdev_core_ops = { - .g_chip_ident = mt9t031_g_chip_ident, .s_power = mt9t031_s_power, #ifdef CONFIG_VIDEO_ADV_DEBUG .g_register = mt9t031_g_register, diff --git a/drivers/media/i2c/soc_camera/mt9t112.c b/drivers/media/i2c/soc_camera/mt9t112.c index a7256b732804..0391d01e8d25 100644 --- a/drivers/media/i2c/soc_camera/mt9t112.c +++ b/drivers/media/i2c/soc_camera/mt9t112.c @@ -27,7 +27,6 @@ #include #include -#include #include /* you can check PLL/clock info */ @@ -91,7 +90,6 @@ struct mt9t112_priv { struct i2c_client *client; struct v4l2_rect frame; const struct mt9t112_format *format; - int model; int num_formats; u32 flags; /* for flags */ @@ -738,17 +736,6 @@ static int mt9t112_init_camera(const struct i2c_client *client) /************************************************************************ v4l2_subdev_core_ops ************************************************************************/ -static int mt9t112_g_chip_ident(struct v4l2_subdev *sd, - struct v4l2_dbg_chip_ident *id) -{ - struct i2c_client *client = v4l2_get_subdevdata(sd); - struct mt9t112_priv *priv = to_mt9t112(client); - - id->ident = priv->model; - id->revision = 0; - - return 0; -} #ifdef CONFIG_VIDEO_ADV_DEBUG static int mt9t112_g_register(struct v4l2_subdev *sd, @@ -786,7 +773,6 @@ static int mt9t112_s_power(struct v4l2_subdev *sd, int on) } static struct v4l2_subdev_core_ops mt9t112_subdev_core_ops = { - .g_chip_ident = mt9t112_g_chip_ident, #ifdef CONFIG_VIDEO_ADV_DEBUG .g_register = mt9t112_g_register, .s_register = mt9t112_s_register, @@ -1061,12 +1047,10 @@ static int mt9t112_camera_probe(struct i2c_client *client) switch (chipid) { case 0x2680: devname = "mt9t111"; - priv->model = V4L2_IDENT_MT9T111; priv->num_formats = 1; break; case 0x2682: devname = "mt9t112"; - priv->model = V4L2_IDENT_MT9T112; priv->num_formats = ARRAY_SIZE(mt9t112_cfmts); break; default: diff --git a/drivers/media/i2c/soc_camera/mt9v022.c b/drivers/media/i2c/soc_camera/mt9v022.c index a295e598486f..41ff4535eb0d 100644 --- a/drivers/media/i2c/soc_camera/mt9v022.c +++ b/drivers/media/i2c/soc_camera/mt9v022.c @@ -19,7 +19,6 @@ #include #include #include -#include #include /* @@ -133,6 +132,11 @@ static const struct mt9v02x_register mt9v024_register = { .pixclk_fv_lv = MT9V024_PIXCLK_FV_LV, }; +enum mt9v022_model { + MT9V022IX7ATM, + MT9V022IX7ATC, +}; + struct mt9v022 { struct v4l2_subdev subdev; struct v4l2_ctrl_handler hdl; @@ -153,7 +157,7 @@ struct mt9v022 { const struct mt9v022_datafmt *fmts; const struct mt9v02x_register *reg; int num_fmts; - int model; /* V4L2_IDENT_MT9V022* codes from v4l2-chip-ident.h */ + enum mt9v022_model model; u16 chip_control; u16 chip_version; unsigned short y_skip_top; /* Lines to skip at the top */ @@ -406,12 +410,12 @@ static int mt9v022_s_fmt(struct v4l2_subdev *sd, switch (mf->code) { case V4L2_MBUS_FMT_Y8_1X8: case V4L2_MBUS_FMT_Y10_1X10: - if (mt9v022->model != V4L2_IDENT_MT9V022IX7ATM) + if (mt9v022->model != MT9V022IX7ATM) return -EINVAL; break; case V4L2_MBUS_FMT_SBGGR8_1X8: case V4L2_MBUS_FMT_SBGGR10_1X10: - if (mt9v022->model != V4L2_IDENT_MT9V022IX7ATC) + if (mt9v022->model != MT9V022IX7ATC) return -EINVAL; break; default: @@ -457,36 +461,15 @@ static int mt9v022_try_fmt(struct v4l2_subdev *sd, return 0; } -static int mt9v022_g_chip_ident(struct v4l2_subdev *sd, - struct v4l2_dbg_chip_ident *id) -{ - struct i2c_client *client = v4l2_get_subdevdata(sd); - struct mt9v022 *mt9v022 = to_mt9v022(client); - - if (id->match.type != V4L2_CHIP_MATCH_I2C_ADDR) - return -EINVAL; - - if (id->match.addr != client->addr) - return -ENODEV; - - id->ident = mt9v022->model; - id->revision = 0; - - return 0; -} - #ifdef CONFIG_VIDEO_ADV_DEBUG static int mt9v022_g_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg) { struct i2c_client *client = v4l2_get_subdevdata(sd); - if (reg->match.type != V4L2_CHIP_MATCH_I2C_ADDR || reg->reg > 0xff) + if (reg->reg > 0xff) return -EINVAL; - if (reg->match.addr != client->addr) - return -ENODEV; - reg->size = 2; reg->val = reg_read(client, reg->reg); @@ -501,12 +484,9 @@ static int mt9v022_s_register(struct v4l2_subdev *sd, { struct i2c_client *client = v4l2_get_subdevdata(sd); - if (reg->match.type != V4L2_CHIP_MATCH_I2C_ADDR || reg->reg > 0xff) + if (reg->reg > 0xff) return -EINVAL; - if (reg->match.addr != client->addr) - return -ENODEV; - if (reg_write(client, reg->reg, reg->val) < 0) return -EIO; @@ -706,11 +686,11 @@ static int mt9v022_video_probe(struct i2c_client *client) if (sensor_type && (!strcmp("colour", sensor_type) || !strcmp("color", sensor_type))) { ret = reg_write(client, MT9V022_PIXEL_OPERATION_MODE, 4 | 0x11); - mt9v022->model = V4L2_IDENT_MT9V022IX7ATC; + mt9v022->model = MT9V022IX7ATC; mt9v022->fmts = mt9v022_colour_fmts; } else { ret = reg_write(client, MT9V022_PIXEL_OPERATION_MODE, 0x11); - mt9v022->model = V4L2_IDENT_MT9V022IX7ATM; + mt9v022->model = MT9V022IX7ATM; mt9v022->fmts = mt9v022_monochrome_fmts; } @@ -740,7 +720,7 @@ static int mt9v022_video_probe(struct i2c_client *client) mt9v022->fmt = &mt9v022->fmts[0]; dev_info(&client->dev, "Detected a MT9V022 chip ID %x, %s sensor\n", - data, mt9v022->model == V4L2_IDENT_MT9V022IX7ATM ? + data, mt9v022->model == MT9V022IX7ATM ? "monochrome" : "colour"); ret = mt9v022_init(client); @@ -768,7 +748,6 @@ static const struct v4l2_ctrl_ops mt9v022_ctrl_ops = { }; static struct v4l2_subdev_core_ops mt9v022_subdev_core_ops = { - .g_chip_ident = mt9v022_g_chip_ident, #ifdef CONFIG_VIDEO_ADV_DEBUG .g_register = mt9v022_g_register, .s_register = mt9v022_s_register, diff --git a/drivers/media/i2c/soc_camera/ov2640.c b/drivers/media/i2c/soc_camera/ov2640.c index e3168424f9ba..7961cba6880a 100644 --- a/drivers/media/i2c/soc_camera/ov2640.c +++ b/drivers/media/i2c/soc_camera/ov2640.c @@ -22,7 +22,6 @@ #include #include -#include #include #include @@ -304,7 +303,6 @@ struct ov2640_priv { struct v4l2_ctrl_handler hdl; enum v4l2_mbus_pixelcode cfmt_code; const struct ov2640_win_size *win; - int model; }; /* @@ -723,18 +721,6 @@ static int ov2640_s_ctrl(struct v4l2_ctrl *ctrl) return -EINVAL; } -static int ov2640_g_chip_ident(struct v4l2_subdev *sd, - struct v4l2_dbg_chip_ident *id) -{ - struct i2c_client *client = v4l2_get_subdevdata(sd); - struct ov2640_priv *priv = to_ov2640(client); - - id->ident = priv->model; - id->revision = 0; - - return 0; -} - #ifdef CONFIG_VIDEO_ADV_DEBUG static int ov2640_g_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg) @@ -1009,7 +995,6 @@ static int ov2640_video_probe(struct i2c_client *client) switch (VERSION(pid, ver)) { case PID_OV2640: devname = "ov2640"; - priv->model = V4L2_IDENT_OV2640; break; default: dev_err(&client->dev, @@ -1034,7 +1019,6 @@ static const struct v4l2_ctrl_ops ov2640_ctrl_ops = { }; static struct v4l2_subdev_core_ops ov2640_subdev_core_ops = { - .g_chip_ident = ov2640_g_chip_ident, #ifdef CONFIG_VIDEO_ADV_DEBUG .g_register = ov2640_g_register, .s_register = ov2640_s_register, diff --git a/drivers/media/i2c/soc_camera/ov5642.c b/drivers/media/i2c/soc_camera/ov5642.c index 9aa56de69eed..c93a157d1d93 100644 --- a/drivers/media/i2c/soc_camera/ov5642.c +++ b/drivers/media/i2c/soc_camera/ov5642.c @@ -24,7 +24,6 @@ #include #include -#include #include /* OV5642 registers */ @@ -848,23 +847,6 @@ static int ov5642_enum_fmt(struct v4l2_subdev *sd, unsigned int index, return 0; } -static int ov5642_g_chip_ident(struct v4l2_subdev *sd, - struct v4l2_dbg_chip_ident *id) -{ - struct i2c_client *client = v4l2_get_subdevdata(sd); - - if (id->match.type != V4L2_CHIP_MATCH_I2C_ADDR) - return -EINVAL; - - if (id->match.addr != client->addr) - return -ENODEV; - - id->ident = V4L2_IDENT_OV5642; - id->revision = 0; - - return 0; -} - static int ov5642_s_crop(struct v4l2_subdev *sd, const struct v4l2_crop *a) { struct i2c_client *client = v4l2_get_subdevdata(sd); @@ -966,7 +948,6 @@ static struct v4l2_subdev_video_ops ov5642_subdev_video_ops = { static struct v4l2_subdev_core_ops ov5642_subdev_core_ops = { .s_power = ov5642_s_power, - .g_chip_ident = ov5642_g_chip_ident, #ifdef CONFIG_VIDEO_ADV_DEBUG .g_register = ov5642_get_register, .s_register = ov5642_set_register, diff --git a/drivers/media/i2c/soc_camera/ov6650.c b/drivers/media/i2c/soc_camera/ov6650.c index 991202d4bbae..d2869d87d3b1 100644 --- a/drivers/media/i2c/soc_camera/ov6650.c +++ b/drivers/media/i2c/soc_camera/ov6650.c @@ -32,7 +32,6 @@ #include #include -#include #include /* Register definitions */ @@ -390,16 +389,6 @@ static int ov6550_s_ctrl(struct v4l2_ctrl *ctrl) return -EINVAL; } -/* Get chip identification */ -static int ov6650_g_chip_ident(struct v4l2_subdev *sd, - struct v4l2_dbg_chip_ident *id) -{ - id->ident = V4L2_IDENT_OV6650; - id->revision = 0; - - return 0; -} - #ifdef CONFIG_VIDEO_ADV_DEBUG static int ov6650_get_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg) @@ -879,7 +868,6 @@ static const struct v4l2_ctrl_ops ov6550_ctrl_ops = { }; static struct v4l2_subdev_core_ops ov6650_core_ops = { - .g_chip_ident = ov6650_g_chip_ident, #ifdef CONFIG_VIDEO_ADV_DEBUG .g_register = ov6650_get_register, .s_register = ov6650_set_register, diff --git a/drivers/media/i2c/soc_camera/ov772x.c b/drivers/media/i2c/soc_camera/ov772x.c index 713d62e349f6..b2f623603986 100644 --- a/drivers/media/i2c/soc_camera/ov772x.c +++ b/drivers/media/i2c/soc_camera/ov772x.c @@ -27,7 +27,6 @@ #include #include #include -#include #include /* @@ -399,7 +398,6 @@ struct ov772x_priv { struct ov772x_camera_info *info; const struct ov772x_color_format *cfmt; const struct ov772x_win_size *win; - int model; unsigned short flag_vflip:1; unsigned short flag_hflip:1; /* band_filter = COM8[5] ? 256 - BDBASE : 0 */ @@ -620,17 +618,6 @@ static int ov772x_s_ctrl(struct v4l2_ctrl *ctrl) return -EINVAL; } -static int ov772x_g_chip_ident(struct v4l2_subdev *sd, - struct v4l2_dbg_chip_ident *id) -{ - struct ov772x_priv *priv = to_ov772x(sd); - - id->ident = priv->model; - id->revision = 0; - - return 0; -} - #ifdef CONFIG_VIDEO_ADV_DEBUG static int ov772x_g_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg) @@ -965,11 +952,9 @@ static int ov772x_video_probe(struct ov772x_priv *priv) switch (VERSION(pid, ver)) { case OV7720: devname = "ov7720"; - priv->model = V4L2_IDENT_OV7720; break; case OV7725: devname = "ov7725"; - priv->model = V4L2_IDENT_OV7725; break; default: dev_err(&client->dev, @@ -997,7 +982,6 @@ static const struct v4l2_ctrl_ops ov772x_ctrl_ops = { }; static struct v4l2_subdev_core_ops ov772x_subdev_core_ops = { - .g_chip_ident = ov772x_g_chip_ident, #ifdef CONFIG_VIDEO_ADV_DEBUG .g_register = ov772x_g_register, .s_register = ov772x_s_register, diff --git a/drivers/media/i2c/soc_camera/ov9640.c b/drivers/media/i2c/soc_camera/ov9640.c index 20ca62d371c1..6817be329666 100644 --- a/drivers/media/i2c/soc_camera/ov9640.c +++ b/drivers/media/i2c/soc_camera/ov9640.c @@ -28,7 +28,6 @@ #include #include -#include #include #include @@ -287,18 +286,6 @@ static int ov9640_s_ctrl(struct v4l2_ctrl *ctrl) return -EINVAL; } -/* Get chip identification */ -static int ov9640_g_chip_ident(struct v4l2_subdev *sd, - struct v4l2_dbg_chip_ident *id) -{ - struct ov9640_priv *priv = to_ov9640_sensor(sd); - - id->ident = priv->model; - id->revision = priv->revision; - - return 0; -} - #ifdef CONFIG_VIDEO_ADV_DEBUG static int ov9640_get_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg) @@ -615,12 +602,10 @@ static int ov9640_video_probe(struct i2c_client *client) switch (VERSION(pid, ver)) { case OV9640_V2: devname = "ov9640"; - priv->model = V4L2_IDENT_OV9640; priv->revision = 2; break; case OV9640_V3: devname = "ov9640"; - priv->model = V4L2_IDENT_OV9640; priv->revision = 3; break; default: @@ -644,7 +629,6 @@ static const struct v4l2_ctrl_ops ov9640_ctrl_ops = { }; static struct v4l2_subdev_core_ops ov9640_core_ops = { - .g_chip_ident = ov9640_g_chip_ident, #ifdef CONFIG_VIDEO_ADV_DEBUG .g_register = ov9640_get_register, .s_register = ov9640_set_register, diff --git a/drivers/media/i2c/soc_camera/ov9740.c b/drivers/media/i2c/soc_camera/ov9740.c index 012bd6271124..0bc21a643c08 100644 --- a/drivers/media/i2c/soc_camera/ov9740.c +++ b/drivers/media/i2c/soc_camera/ov9740.c @@ -17,7 +17,6 @@ #include #include -#include #include #define to_ov9740(sd) container_of(sd, struct ov9740_priv, subdev) @@ -197,7 +196,6 @@ struct ov9740_priv { struct v4l2_subdev subdev; struct v4l2_ctrl_handler hdl; - int ident; u16 model; u8 revision; u8 manid; @@ -772,18 +770,6 @@ static int ov9740_s_ctrl(struct v4l2_ctrl *ctrl) return 0; } -/* Get chip identification */ -static int ov9740_g_chip_ident(struct v4l2_subdev *sd, - struct v4l2_dbg_chip_ident *id) -{ - struct ov9740_priv *priv = to_ov9740(sd); - - id->ident = priv->ident; - id->revision = priv->revision; - - return 0; -} - static int ov9740_s_power(struct v4l2_subdev *sd, int on) { struct i2c_client *client = v4l2_get_subdevdata(sd); @@ -887,8 +873,6 @@ static int ov9740_video_probe(struct i2c_client *client) goto done; } - priv->ident = V4L2_IDENT_OV9740; - dev_info(&client->dev, "ov9740 Model ID 0x%04x, Revision 0x%02x, " "Manufacturer 0x%02x, SMIA Version 0x%02x\n", priv->model, priv->revision, priv->manid, priv->smiaver); @@ -927,7 +911,6 @@ static struct v4l2_subdev_video_ops ov9740_video_ops = { }; static struct v4l2_subdev_core_ops ov9740_core_ops = { - .g_chip_ident = ov9740_g_chip_ident, .s_power = ov9740_s_power, #ifdef CONFIG_VIDEO_ADV_DEBUG .g_register = ov9740_get_register, diff --git a/drivers/media/i2c/soc_camera/rj54n1cb0c.c b/drivers/media/i2c/soc_camera/rj54n1cb0c.c index 1f9ec3b06b4e..81b515c2fb36 100644 --- a/drivers/media/i2c/soc_camera/rj54n1cb0c.c +++ b/drivers/media/i2c/soc_camera/rj54n1cb0c.c @@ -18,7 +18,6 @@ #include #include #include -#include #include #define RJ54N1_DEV_CODE 0x0400 @@ -1120,37 +1119,16 @@ static int rj54n1_s_fmt(struct v4l2_subdev *sd, return 0; } -static int rj54n1_g_chip_ident(struct v4l2_subdev *sd, - struct v4l2_dbg_chip_ident *id) -{ - struct i2c_client *client = v4l2_get_subdevdata(sd); - - if (id->match.type != V4L2_CHIP_MATCH_I2C_ADDR) - return -EINVAL; - - if (id->match.addr != client->addr) - return -ENODEV; - - id->ident = V4L2_IDENT_RJ54N1CB0C; - id->revision = 0; - - return 0; -} - #ifdef CONFIG_VIDEO_ADV_DEBUG static int rj54n1_g_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg) { struct i2c_client *client = v4l2_get_subdevdata(sd); - if (reg->match.type != V4L2_CHIP_MATCH_I2C_ADDR || - reg->reg < 0x400 || reg->reg > 0x1fff) + if (reg->reg < 0x400 || reg->reg > 0x1fff) /* Registers > 0x0800 are only available from Sharp support */ return -EINVAL; - if (reg->match.addr != client->addr) - return -ENODEV; - reg->size = 1; reg->val = reg_read(client, reg->reg); @@ -1165,14 +1143,10 @@ static int rj54n1_s_register(struct v4l2_subdev *sd, { struct i2c_client *client = v4l2_get_subdevdata(sd); - if (reg->match.type != V4L2_CHIP_MATCH_I2C_ADDR || - reg->reg < 0x400 || reg->reg > 0x1fff) + if (reg->reg < 0x400 || reg->reg > 0x1fff) /* Registers >= 0x0800 are only available from Sharp support */ return -EINVAL; - if (reg->match.addr != client->addr) - return -ENODEV; - if (reg_write(client, reg->reg, reg->val) < 0) return -EIO; @@ -1233,7 +1207,6 @@ static const struct v4l2_ctrl_ops rj54n1_ctrl_ops = { }; static struct v4l2_subdev_core_ops rj54n1_subdev_core_ops = { - .g_chip_ident = rj54n1_g_chip_ident, #ifdef CONFIG_VIDEO_ADV_DEBUG .g_register = rj54n1_g_register, .s_register = rj54n1_s_register, diff --git a/drivers/media/i2c/soc_camera/tw9910.c b/drivers/media/i2c/soc_camera/tw9910.c index bad90b16a6dd..8a2ac244d0b3 100644 --- a/drivers/media/i2c/soc_camera/tw9910.c +++ b/drivers/media/i2c/soc_camera/tw9910.c @@ -27,7 +27,6 @@ #include #include -#include #include #define GET_ID(val) ((val & 0xF8) >> 3) @@ -518,18 +517,6 @@ static int tw9910_s_std(struct v4l2_subdev *sd, v4l2_std_id norm) return 0; } -static int tw9910_g_chip_ident(struct v4l2_subdev *sd, - struct v4l2_dbg_chip_ident *id) -{ - struct i2c_client *client = v4l2_get_subdevdata(sd); - struct tw9910_priv *priv = to_tw9910(client); - - id->ident = V4L2_IDENT_TW9910; - id->revision = priv->revision; - - return 0; -} - #ifdef CONFIG_VIDEO_ADV_DEBUG static int tw9910_g_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg) @@ -823,7 +810,6 @@ done: } static struct v4l2_subdev_core_ops tw9910_subdev_core_ops = { - .g_chip_ident = tw9910_g_chip_ident, .s_std = tw9910_s_std, .g_std = tw9910_g_std, #ifdef CONFIG_VIDEO_ADV_DEBUG From e12771100c93e101a7a8b302b6c5d57cff7b1551 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Wed, 29 May 2013 06:59:51 -0300 Subject: [PATCH 0224/1048] [media] media/i2c: remove g_chip_ident op This is no longer needed since the core now handles this through DBG_G_CHIP_INFO. Signed-off-by: Hans Verkuil Acked-by: Laurent Pinchart Acked-by: Lad, Prabhakar Signed-off-by: Mauro Carvalho Chehab --- drivers/media/i2c/ad9389b.c | 21 +---- drivers/media/i2c/adv7170.c | 13 --- drivers/media/i2c/adv7175.c | 9 -- drivers/media/i2c/adv7180.c | 10 --- drivers/media/i2c/adv7183.c | 22 ----- drivers/media/i2c/adv7343.c | 10 --- drivers/media/i2c/adv7393.c | 10 --- drivers/media/i2c/adv7604.c | 18 ---- drivers/media/i2c/ak881x.c | 34 +------- drivers/media/i2c/bt819.c | 14 --- drivers/media/i2c/bt856.c | 9 -- drivers/media/i2c/bt866.c | 13 --- drivers/media/i2c/cs5345.c | 17 ---- drivers/media/i2c/cs53l32a.c | 10 --- drivers/media/i2c/cx25840/cx25840-core.c | 14 --- drivers/media/i2c/ks0127.c | 16 ---- drivers/media/i2c/m52790.c | 15 ---- drivers/media/i2c/msp3400-driver.c | 10 --- drivers/media/i2c/mt9m032.c | 9 +- drivers/media/i2c/mt9p031.c | 1 - drivers/media/i2c/mt9v011.c | 24 ------ drivers/media/i2c/noon010pc30.c | 1 - drivers/media/i2c/ov7640.c | 1 - drivers/media/i2c/ov7670.c | 17 ---- drivers/media/i2c/saa6588.c | 9 -- drivers/media/i2c/saa7110.c | 9 -- drivers/media/i2c/saa7115.c | 105 +++++++++++------------ drivers/media/i2c/saa7127.c | 47 ++++------ drivers/media/i2c/saa717x.c | 7 -- drivers/media/i2c/saa7185.c | 9 -- drivers/media/i2c/saa7191.c | 10 --- drivers/media/i2c/tda9840.c | 13 --- drivers/media/i2c/tea6415c.c | 13 --- drivers/media/i2c/tea6420.c | 13 --- drivers/media/i2c/ths7303.c | 25 +----- drivers/media/i2c/tvaudio.c | 9 -- drivers/media/i2c/tvp514x.c | 1 - drivers/media/i2c/tvp5150.c | 24 ------ drivers/media/i2c/tvp7002.c | 34 -------- drivers/media/i2c/tw2804.c | 1 - drivers/media/i2c/upd64031a.c | 17 ---- drivers/media/i2c/upd64083.c | 17 ---- drivers/media/i2c/vp27smpx.c | 9 -- drivers/media/i2c/vpx3220.c | 14 --- drivers/media/i2c/vs6624.c | 22 ----- drivers/media/i2c/wm8739.c | 9 -- drivers/media/i2c/wm8775.c | 9 -- 47 files changed, 73 insertions(+), 671 deletions(-) diff --git a/drivers/media/i2c/ad9389b.c b/drivers/media/i2c/ad9389b.c index ade1fec7e040..ba4364dfae66 100644 --- a/drivers/media/i2c/ad9389b.c +++ b/drivers/media/i2c/ad9389b.c @@ -32,7 +32,6 @@ #include #include #include -#include #include #include #include @@ -343,10 +342,6 @@ static const struct v4l2_ctrl_ops ad9389b_ctrl_ops = { #ifdef CONFIG_VIDEO_ADV_DEBUG static int ad9389b_g_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg) { - struct i2c_client *client = v4l2_get_subdevdata(sd); - - if (!v4l2_chip_match_i2c_client(client, ®->match)) - return -EINVAL; reg->val = ad9389b_rd(sd, reg->reg & 0xff); reg->size = 1; return 0; @@ -354,22 +349,11 @@ static int ad9389b_g_register(struct v4l2_subdev *sd, struct v4l2_dbg_register * static int ad9389b_s_register(struct v4l2_subdev *sd, const struct v4l2_dbg_register *reg) { - struct i2c_client *client = v4l2_get_subdevdata(sd); - - if (!v4l2_chip_match_i2c_client(client, ®->match)) - return -EINVAL; ad9389b_wr(sd, reg->reg & 0xff, reg->val & 0xff); return 0; } #endif -static int ad9389b_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *chip) -{ - struct i2c_client *client = v4l2_get_subdevdata(sd); - - return v4l2_chip_ident_i2c_client(client, chip, V4L2_IDENT_AD9389B, 0); -} - static int ad9389b_log_status(struct v4l2_subdev *sd) { struct ad9389b_state *state = get_ad9389b_state(sd); @@ -596,7 +580,6 @@ static int ad9389b_isr(struct v4l2_subdev *sd, u32 status, bool *handled) static const struct v4l2_subdev_core_ops ad9389b_core_ops = { .log_status = ad9389b_log_status, - .g_chip_ident = ad9389b_g_chip_ident, #ifdef CONFIG_VIDEO_ADV_DEBUG .g_register = ad9389b_g_register, .s_register = ad9389b_s_register, @@ -1303,8 +1286,8 @@ static int ad9389b_remove(struct i2c_client *client) /* ----------------------------------------------------------------------- */ static struct i2c_device_id ad9389b_id[] = { - { "ad9389b", V4L2_IDENT_AD9389B }, - { "ad9889b", V4L2_IDENT_AD9389B }, + { "ad9389b", 0 }, + { "ad9889b", 0 }, { } }; MODULE_DEVICE_TABLE(i2c, ad9389b_id); diff --git a/drivers/media/i2c/adv7170.c b/drivers/media/i2c/adv7170.c index d07689d44354..04bb29720aaf 100644 --- a/drivers/media/i2c/adv7170.c +++ b/drivers/media/i2c/adv7170.c @@ -36,7 +36,6 @@ #include #include #include -#include MODULE_DESCRIPTION("Analog Devices ADV7170 video encoder driver"); MODULE_AUTHOR("Maxim Yevtyushkin"); @@ -317,19 +316,8 @@ static int adv7170_s_fmt(struct v4l2_subdev *sd, return ret; } -static int adv7170_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *chip) -{ - struct i2c_client *client = v4l2_get_subdevdata(sd); - - return v4l2_chip_ident_i2c_client(client, chip, V4L2_IDENT_ADV7170, 0); -} - /* ----------------------------------------------------------------------- */ -static const struct v4l2_subdev_core_ops adv7170_core_ops = { - .g_chip_ident = adv7170_g_chip_ident, -}; - static const struct v4l2_subdev_video_ops adv7170_video_ops = { .s_std_output = adv7170_s_std_output, .s_routing = adv7170_s_routing, @@ -339,7 +327,6 @@ static const struct v4l2_subdev_video_ops adv7170_video_ops = { }; static const struct v4l2_subdev_ops adv7170_ops = { - .core = &adv7170_core_ops, .video = &adv7170_video_ops, }; diff --git a/drivers/media/i2c/adv7175.c b/drivers/media/i2c/adv7175.c index eaefa50b8d28..b88f3b3d5ed9 100644 --- a/drivers/media/i2c/adv7175.c +++ b/drivers/media/i2c/adv7175.c @@ -32,7 +32,6 @@ #include #include #include -#include MODULE_DESCRIPTION("Analog Devices ADV7175 video encoder driver"); MODULE_AUTHOR("Dave Perks"); @@ -355,13 +354,6 @@ static int adv7175_s_fmt(struct v4l2_subdev *sd, return ret; } -static int adv7175_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *chip) -{ - struct i2c_client *client = v4l2_get_subdevdata(sd); - - return v4l2_chip_ident_i2c_client(client, chip, V4L2_IDENT_ADV7175, 0); -} - static int adv7175_s_power(struct v4l2_subdev *sd, int on) { if (on) @@ -375,7 +367,6 @@ static int adv7175_s_power(struct v4l2_subdev *sd, int on) /* ----------------------------------------------------------------------- */ static const struct v4l2_subdev_core_ops adv7175_core_ops = { - .g_chip_ident = adv7175_g_chip_ident, .init = adv7175_init, .s_power = adv7175_s_power, }; diff --git a/drivers/media/i2c/adv7180.c b/drivers/media/i2c/adv7180.c index 11f13a83a64b..d7d99f1c69e4 100644 --- a/drivers/media/i2c/adv7180.c +++ b/drivers/media/i2c/adv7180.c @@ -29,7 +29,6 @@ #include #include #include -#include #include #define ADV7180_INPUT_CONTROL_REG 0x00 @@ -274,14 +273,6 @@ static int adv7180_g_input_status(struct v4l2_subdev *sd, u32 *status) return ret; } -static int adv7180_g_chip_ident(struct v4l2_subdev *sd, - struct v4l2_dbg_chip_ident *chip) -{ - struct i2c_client *client = v4l2_get_subdevdata(sd); - - return v4l2_chip_ident_i2c_client(client, chip, V4L2_IDENT_ADV7180, 0); -} - static int adv7180_s_std(struct v4l2_subdev *sd, v4l2_std_id std) { struct adv7180_state *state = to_state(sd); @@ -450,7 +441,6 @@ static const struct v4l2_subdev_video_ops adv7180_video_ops = { }; static const struct v4l2_subdev_core_ops adv7180_core_ops = { - .g_chip_ident = adv7180_g_chip_ident, .s_std = adv7180_s_std, }; diff --git a/drivers/media/i2c/adv7183.c b/drivers/media/i2c/adv7183.c index 7c48e22b41a2..980815d37bb1 100644 --- a/drivers/media/i2c/adv7183.c +++ b/drivers/media/i2c/adv7183.c @@ -28,7 +28,6 @@ #include #include -#include #include #include @@ -481,25 +480,9 @@ static int adv7183_s_stream(struct v4l2_subdev *sd, int enable) return 0; } -static int adv7183_g_chip_ident(struct v4l2_subdev *sd, - struct v4l2_dbg_chip_ident *chip) -{ - int rev; - struct i2c_client *client = v4l2_get_subdevdata(sd); - - /* 0x11 for adv7183, 0x13 for adv7183b */ - rev = adv7183_read(sd, ADV7183_IDENT); - - return v4l2_chip_ident_i2c_client(client, chip, V4L2_IDENT_ADV7183, rev); -} - #ifdef CONFIG_VIDEO_ADV_DEBUG static int adv7183_g_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg) { - struct i2c_client *client = v4l2_get_subdevdata(sd); - - if (!v4l2_chip_match_i2c_client(client, ®->match)) - return -EINVAL; reg->val = adv7183_read(sd, reg->reg & 0xff); reg->size = 1; return 0; @@ -507,10 +490,6 @@ static int adv7183_g_register(struct v4l2_subdev *sd, struct v4l2_dbg_register * static int adv7183_s_register(struct v4l2_subdev *sd, const struct v4l2_dbg_register *reg) { - struct i2c_client *client = v4l2_get_subdevdata(sd); - - if (!v4l2_chip_match_i2c_client(client, ®->match)) - return -EINVAL; adv7183_write(sd, reg->reg & 0xff, reg->val & 0xff); return 0; } @@ -525,7 +504,6 @@ static const struct v4l2_subdev_core_ops adv7183_core_ops = { .g_std = adv7183_g_std, .s_std = adv7183_s_std, .reset = adv7183_reset, - .g_chip_ident = adv7183_g_chip_ident, #ifdef CONFIG_VIDEO_ADV_DEBUG .g_register = adv7183_g_register, .s_register = adv7183_s_register, diff --git a/drivers/media/i2c/adv7343.c b/drivers/media/i2c/adv7343.c index 9fc2b985df0e..7606218ec4a7 100644 --- a/drivers/media/i2c/adv7343.c +++ b/drivers/media/i2c/adv7343.c @@ -28,7 +28,6 @@ #include #include -#include #include #include "adv7343_regs.h" @@ -311,21 +310,12 @@ static int adv7343_s_ctrl(struct v4l2_ctrl *ctrl) return -EINVAL; } -static int adv7343_g_chip_ident(struct v4l2_subdev *sd, - struct v4l2_dbg_chip_ident *chip) -{ - struct i2c_client *client = v4l2_get_subdevdata(sd); - - return v4l2_chip_ident_i2c_client(client, chip, V4L2_IDENT_ADV7343, 0); -} - static const struct v4l2_ctrl_ops adv7343_ctrl_ops = { .s_ctrl = adv7343_s_ctrl, }; static const struct v4l2_subdev_core_ops adv7343_core_ops = { .log_status = adv7343_log_status, - .g_chip_ident = adv7343_g_chip_ident, .g_ext_ctrls = v4l2_subdev_g_ext_ctrls, .try_ext_ctrls = v4l2_subdev_try_ext_ctrls, .s_ext_ctrls = v4l2_subdev_s_ext_ctrls, diff --git a/drivers/media/i2c/adv7393.c b/drivers/media/i2c/adv7393.c index ec505098598a..558f19154eb9 100644 --- a/drivers/media/i2c/adv7393.c +++ b/drivers/media/i2c/adv7393.c @@ -33,7 +33,6 @@ #include #include -#include #include #include "adv7393_regs.h" @@ -301,21 +300,12 @@ static int adv7393_s_ctrl(struct v4l2_ctrl *ctrl) return -EINVAL; } -static int adv7393_g_chip_ident(struct v4l2_subdev *sd, - struct v4l2_dbg_chip_ident *chip) -{ - struct i2c_client *client = v4l2_get_subdevdata(sd); - - return v4l2_chip_ident_i2c_client(client, chip, V4L2_IDENT_ADV7393, 0); -} - static const struct v4l2_ctrl_ops adv7393_ctrl_ops = { .s_ctrl = adv7393_s_ctrl, }; static const struct v4l2_subdev_core_ops adv7393_core_ops = { .log_status = adv7393_log_status, - .g_chip_ident = adv7393_g_chip_ident, .g_ext_ctrls = v4l2_subdev_g_ext_ctrls, .try_ext_ctrls = v4l2_subdev_try_ext_ctrls, .s_ext_ctrls = v4l2_subdev_s_ext_ctrls, diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c index 5528cd15cc67..1d675b58fd71 100644 --- a/drivers/media/i2c/adv7604.c +++ b/drivers/media/i2c/adv7604.c @@ -38,7 +38,6 @@ #include #include #include -#include #include static int debug; @@ -643,10 +642,6 @@ static void adv7604_inv_register(struct v4l2_subdev *sd) static int adv7604_g_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg) { - struct i2c_client *client = v4l2_get_subdevdata(sd); - - if (!v4l2_chip_match_i2c_client(client, ®->match)) - return -EINVAL; reg->size = 1; switch (reg->reg >> 8) { case 0: @@ -699,10 +694,6 @@ static int adv7604_g_register(struct v4l2_subdev *sd, static int adv7604_s_register(struct v4l2_subdev *sd, const struct v4l2_dbg_register *reg) { - struct i2c_client *client = v4l2_get_subdevdata(sd); - - if (!v4l2_chip_match_i2c_client(client, ®->match)) - return -EINVAL; switch (reg->reg >> 8) { case 0: io_write(sd, reg->reg & 0xff, reg->val & 0xff); @@ -980,14 +971,6 @@ static int adv7604_s_ctrl(struct v4l2_ctrl *ctrl) return -EINVAL; } -static int adv7604_g_chip_ident(struct v4l2_subdev *sd, - struct v4l2_dbg_chip_ident *chip) -{ - struct i2c_client *client = v4l2_get_subdevdata(sd); - - return v4l2_chip_ident_i2c_client(client, chip, V4L2_IDENT_ADV7604, 0); -} - /* ----------------------------------------------------------------------- */ static inline bool no_power(struct v4l2_subdev *sd) @@ -1783,7 +1766,6 @@ static const struct v4l2_subdev_core_ops adv7604_core_ops = { .s_ctrl = v4l2_subdev_s_ctrl, .queryctrl = v4l2_subdev_queryctrl, .querymenu = v4l2_subdev_querymenu, - .g_chip_ident = adv7604_g_chip_ident, .interrupt_service_routine = adv7604_isr, #ifdef CONFIG_VIDEO_ADV_DEBUG .g_register = adv7604_g_register, diff --git a/drivers/media/i2c/ak881x.c b/drivers/media/i2c/ak881x.c index b918c3f29cbe..fcd8a3f626fa 100644 --- a/drivers/media/i2c/ak881x.c +++ b/drivers/media/i2c/ak881x.c @@ -16,7 +16,6 @@ #include #include -#include #include #include @@ -33,7 +32,6 @@ struct ak881x { struct v4l2_subdev subdev; struct ak881x_pdata *pdata; unsigned int lines; - int id; /* DEVICE_ID code V4L2_IDENT_AK881X code from v4l2-chip-ident.h */ char revision; /* DEVICE_REVISION content */ }; @@ -62,36 +60,15 @@ static struct ak881x *to_ak881x(const struct i2c_client *client) return container_of(i2c_get_clientdata(client), struct ak881x, subdev); } -static int ak881x_g_chip_ident(struct v4l2_subdev *sd, - struct v4l2_dbg_chip_ident *id) -{ - struct i2c_client *client = v4l2_get_subdevdata(sd); - struct ak881x *ak881x = to_ak881x(client); - - if (id->match.type != V4L2_CHIP_MATCH_I2C_ADDR) - return -EINVAL; - - if (id->match.addr != client->addr) - return -ENODEV; - - id->ident = ak881x->id; - id->revision = ak881x->revision; - - return 0; -} - #ifdef CONFIG_VIDEO_ADV_DEBUG static int ak881x_g_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg) { struct i2c_client *client = v4l2_get_subdevdata(sd); - if (reg->match.type != V4L2_CHIP_MATCH_I2C_ADDR || reg->reg > 0x26) + if (reg->reg > 0x26) return -EINVAL; - if (reg->match.addr != client->addr) - return -ENODEV; - reg->val = reg_read(client, reg->reg); if (reg->val > 0xffff) @@ -105,12 +82,9 @@ static int ak881x_s_register(struct v4l2_subdev *sd, { struct i2c_client *client = v4l2_get_subdevdata(sd); - if (reg->match.type != V4L2_CHIP_MATCH_I2C_ADDR || reg->reg > 0x26) + if (reg->reg > 0x26) return -EINVAL; - if (reg->match.addr != client->addr) - return -ENODEV; - if (reg_write(client, reg->reg, reg->val) < 0) return -EIO; @@ -229,7 +203,6 @@ static int ak881x_s_stream(struct v4l2_subdev *sd, int enable) } static struct v4l2_subdev_core_ops ak881x_subdev_core_ops = { - .g_chip_ident = ak881x_g_chip_ident, #ifdef CONFIG_VIDEO_ADV_DEBUG .g_register = ak881x_g_register, .s_register = ak881x_s_register, @@ -274,10 +247,7 @@ static int ak881x_probe(struct i2c_client *client, switch (data) { case 0x13: - ak881x->id = V4L2_IDENT_AK8813; - break; case 0x14: - ak881x->id = V4L2_IDENT_AK8814; break; default: dev_err(&client->dev, diff --git a/drivers/media/i2c/bt819.c b/drivers/media/i2c/bt819.c index ee9ed67e7910..ae1eac01bbc7 100644 --- a/drivers/media/i2c/bt819.c +++ b/drivers/media/i2c/bt819.c @@ -36,7 +36,6 @@ #include #include #include -#include #include #include @@ -57,7 +56,6 @@ struct bt819 { unsigned char reg[32]; v4l2_std_id norm; - int ident; int input; int enable; }; @@ -373,14 +371,6 @@ static int bt819_s_ctrl(struct v4l2_ctrl *ctrl) return 0; } -static int bt819_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *chip) -{ - struct bt819 *decoder = to_bt819(sd); - struct i2c_client *client = v4l2_get_subdevdata(sd); - - return v4l2_chip_ident_i2c_client(client, chip, decoder->ident, 0); -} - /* ----------------------------------------------------------------------- */ static const struct v4l2_ctrl_ops bt819_ctrl_ops = { @@ -388,7 +378,6 @@ static const struct v4l2_ctrl_ops bt819_ctrl_ops = { }; static const struct v4l2_subdev_core_ops bt819_core_ops = { - .g_chip_ident = bt819_g_chip_ident, .g_ext_ctrls = v4l2_subdev_g_ext_ctrls, .try_ext_ctrls = v4l2_subdev_try_ext_ctrls, .s_ext_ctrls = v4l2_subdev_s_ext_ctrls, @@ -435,15 +424,12 @@ static int bt819_probe(struct i2c_client *client, switch (ver & 0xf0) { case 0x70: name = "bt819a"; - decoder->ident = V4L2_IDENT_BT819A; break; case 0x60: name = "bt817a"; - decoder->ident = V4L2_IDENT_BT817A; break; case 0x20: name = "bt815a"; - decoder->ident = V4L2_IDENT_BT815A; break; default: v4l2_dbg(1, debug, sd, diff --git a/drivers/media/i2c/bt856.c b/drivers/media/i2c/bt856.c index 7e5011163b62..7fc163d0253c 100644 --- a/drivers/media/i2c/bt856.c +++ b/drivers/media/i2c/bt856.c @@ -36,7 +36,6 @@ #include #include #include -#include MODULE_DESCRIPTION("Brooktree-856A video encoder driver"); MODULE_AUTHOR("Mike Bernson & Dave Perks"); @@ -177,17 +176,9 @@ static int bt856_s_routing(struct v4l2_subdev *sd, return 0; } -static int bt856_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *chip) -{ - struct i2c_client *client = v4l2_get_subdevdata(sd); - - return v4l2_chip_ident_i2c_client(client, chip, V4L2_IDENT_BT856, 0); -} - /* ----------------------------------------------------------------------- */ static const struct v4l2_subdev_core_ops bt856_core_ops = { - .g_chip_ident = bt856_g_chip_ident, .init = bt856_init, }; diff --git a/drivers/media/i2c/bt866.c b/drivers/media/i2c/bt866.c index 9355b924b471..a8bf10fc665d 100644 --- a/drivers/media/i2c/bt866.c +++ b/drivers/media/i2c/bt866.c @@ -36,7 +36,6 @@ #include #include #include -#include MODULE_DESCRIPTION("Brooktree-866 video encoder driver"); MODULE_AUTHOR("Mike Bernson & Dave Perks"); @@ -175,26 +174,14 @@ static int bt866_s_routing(struct v4l2_subdev *sd, bt866_write(client, 0xdc, val); #endif -static int bt866_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *chip) -{ - struct i2c_client *client = v4l2_get_subdevdata(sd); - - return v4l2_chip_ident_i2c_client(client, chip, V4L2_IDENT_BT866, 0); -} - /* ----------------------------------------------------------------------- */ -static const struct v4l2_subdev_core_ops bt866_core_ops = { - .g_chip_ident = bt866_g_chip_ident, -}; - static const struct v4l2_subdev_video_ops bt866_video_ops = { .s_std_output = bt866_s_std_output, .s_routing = bt866_s_routing, }; static const struct v4l2_subdev_ops bt866_ops = { - .core = &bt866_core_ops, .video = &bt866_video_ops, }; diff --git a/drivers/media/i2c/cs5345.c b/drivers/media/i2c/cs5345.c index 2661757c3a8c..34b76a9e7515 100644 --- a/drivers/media/i2c/cs5345.c +++ b/drivers/media/i2c/cs5345.c @@ -24,7 +24,6 @@ #include #include #include -#include #include MODULE_DESCRIPTION("i2c device driver for cs5345 Audio ADC"); @@ -99,10 +98,6 @@ static int cs5345_s_ctrl(struct v4l2_ctrl *ctrl) #ifdef CONFIG_VIDEO_ADV_DEBUG static int cs5345_g_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg) { - struct i2c_client *client = v4l2_get_subdevdata(sd); - - if (!v4l2_chip_match_i2c_client(client, ®->match)) - return -EINVAL; reg->size = 1; reg->val = cs5345_read(sd, reg->reg & 0x1f); return 0; @@ -110,22 +105,11 @@ static int cs5345_g_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *r static int cs5345_s_register(struct v4l2_subdev *sd, const struct v4l2_dbg_register *reg) { - struct i2c_client *client = v4l2_get_subdevdata(sd); - - if (!v4l2_chip_match_i2c_client(client, ®->match)) - return -EINVAL; cs5345_write(sd, reg->reg & 0x1f, reg->val & 0xff); return 0; } #endif -static int cs5345_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *chip) -{ - struct i2c_client *client = v4l2_get_subdevdata(sd); - - return v4l2_chip_ident_i2c_client(client, chip, V4L2_IDENT_CS5345, 0); -} - static int cs5345_log_status(struct v4l2_subdev *sd) { u8 v = cs5345_read(sd, 0x09) & 7; @@ -148,7 +132,6 @@ static const struct v4l2_ctrl_ops cs5345_ctrl_ops = { static const struct v4l2_subdev_core_ops cs5345_core_ops = { .log_status = cs5345_log_status, - .g_chip_ident = cs5345_g_chip_ident, .g_ext_ctrls = v4l2_subdev_g_ext_ctrls, .try_ext_ctrls = v4l2_subdev_try_ext_ctrls, .s_ext_ctrls = v4l2_subdev_s_ext_ctrls, diff --git a/drivers/media/i2c/cs53l32a.c b/drivers/media/i2c/cs53l32a.c index 1082fb775ab2..27400c16ef9a 100644 --- a/drivers/media/i2c/cs53l32a.c +++ b/drivers/media/i2c/cs53l32a.c @@ -28,7 +28,6 @@ #include #include #include -#include #include MODULE_DESCRIPTION("i2c device driver for cs53l32a Audio ADC"); @@ -104,14 +103,6 @@ static int cs53l32a_s_ctrl(struct v4l2_ctrl *ctrl) return -EINVAL; } -static int cs53l32a_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *chip) -{ - struct i2c_client *client = v4l2_get_subdevdata(sd); - - return v4l2_chip_ident_i2c_client(client, - chip, V4L2_IDENT_CS53l32A, 0); -} - static int cs53l32a_log_status(struct v4l2_subdev *sd) { struct cs53l32a_state *state = to_state(sd); @@ -130,7 +121,6 @@ static const struct v4l2_ctrl_ops cs53l32a_ctrl_ops = { static const struct v4l2_subdev_core_ops cs53l32a_core_ops = { .log_status = cs53l32a_log_status, - .g_chip_ident = cs53l32a_g_chip_ident, .g_ext_ctrls = v4l2_subdev_g_ext_ctrls, .try_ext_ctrls = v4l2_subdev_try_ext_ctrls, .s_ext_ctrls = v4l2_subdev_s_ext_ctrls, diff --git a/drivers/media/i2c/cx25840/cx25840-core.c b/drivers/media/i2c/cx25840/cx25840-core.c index b81e32f371ae..6fbdad4fe054 100644 --- a/drivers/media/i2c/cx25840/cx25840-core.c +++ b/drivers/media/i2c/cx25840/cx25840-core.c @@ -45,7 +45,6 @@ #include #include #include -#include #include #include "cx25840-core.h" @@ -1662,8 +1661,6 @@ static int cx25840_g_register(struct v4l2_subdev *sd, struct v4l2_dbg_register * { struct i2c_client *client = v4l2_get_subdevdata(sd); - if (!v4l2_chip_match_i2c_client(client, ®->match)) - return -EINVAL; reg->size = 1; reg->val = cx25840_read(client, reg->reg & 0x0fff); return 0; @@ -1673,8 +1670,6 @@ static int cx25840_s_register(struct v4l2_subdev *sd, const struct v4l2_dbg_regi { struct i2c_client *client = v4l2_get_subdevdata(sd); - if (!v4l2_chip_match_i2c_client(client, ®->match)) - return -EINVAL; cx25840_write(client, reg->reg & 0x0fff, reg->val & 0xff); return 0; } @@ -1934,14 +1929,6 @@ static int cx25840_reset(struct v4l2_subdev *sd, u32 val) return 0; } -static int cx25840_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *chip) -{ - struct cx25840_state *state = to_state(sd); - struct i2c_client *client = v4l2_get_subdevdata(sd); - - return v4l2_chip_ident_i2c_client(client, chip, state->id, state->rev); -} - static int cx25840_log_status(struct v4l2_subdev *sd) { struct cx25840_state *state = to_state(sd); @@ -5047,7 +5034,6 @@ static const struct v4l2_ctrl_ops cx25840_ctrl_ops = { static const struct v4l2_subdev_core_ops cx25840_core_ops = { .log_status = cx25840_log_status, - .g_chip_ident = cx25840_g_chip_ident, .g_ctrl = v4l2_subdev_g_ctrl, .s_ctrl = v4l2_subdev_s_ctrl, .s_ext_ctrls = v4l2_subdev_s_ext_ctrls, diff --git a/drivers/media/i2c/ks0127.c b/drivers/media/i2c/ks0127.c index c7227763240e..b5223e850a26 100644 --- a/drivers/media/i2c/ks0127.c +++ b/drivers/media/i2c/ks0127.c @@ -42,7 +42,6 @@ #include #include #include -#include #include "ks0127.h" MODULE_DESCRIPTION("KS0127 video decoder driver"); @@ -200,7 +199,6 @@ struct adjust { struct ks0127 { struct v4l2_subdev sd; v4l2_std_id norm; - int ident; u8 regs[256]; }; @@ -371,12 +369,9 @@ static void ks0127_and_or(struct v4l2_subdev *sd, u8 reg, u8 and_v, u8 or_v) ****************************************************************************/ static void ks0127_init(struct v4l2_subdev *sd) { - struct ks0127 *ks = to_ks0127(sd); u8 *table = reg_defaults; int i; - ks->ident = V4L2_IDENT_KS0127; - v4l2_dbg(1, debug, sd, "reset\n"); msleep(1); @@ -397,7 +392,6 @@ static void ks0127_init(struct v4l2_subdev *sd) if ((ks0127_read(sd, KS_STAT) & 0x80) == 0) { - ks->ident = V4L2_IDENT_KS0122S; v4l2_dbg(1, debug, sd, "ks0122s found\n"); return; } @@ -408,7 +402,6 @@ static void ks0127_init(struct v4l2_subdev *sd) break; case 9: - ks->ident = V4L2_IDENT_KS0127B; v4l2_dbg(1, debug, sd, "ks0127B Revision A found\n"); break; @@ -646,18 +639,9 @@ static int ks0127_g_input_status(struct v4l2_subdev *sd, u32 *status) return ks0127_status(sd, status, NULL); } -static int ks0127_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *chip) -{ - struct i2c_client *client = v4l2_get_subdevdata(sd); - struct ks0127 *ks = to_ks0127(sd); - - return v4l2_chip_ident_i2c_client(client, chip, ks->ident, 0); -} - /* ----------------------------------------------------------------------- */ static const struct v4l2_subdev_core_ops ks0127_core_ops = { - .g_chip_ident = ks0127_g_chip_ident, .s_std = ks0127_s_std, }; diff --git a/drivers/media/i2c/m52790.c b/drivers/media/i2c/m52790.c index 3eeb546be6d9..bf476358704d 100644 --- a/drivers/media/i2c/m52790.c +++ b/drivers/media/i2c/m52790.c @@ -29,7 +29,6 @@ #include #include #include -#include MODULE_DESCRIPTION("i2c device driver for m52790 A/V switch"); MODULE_AUTHOR("Hans Verkuil"); @@ -83,10 +82,7 @@ static int m52790_s_routing(struct v4l2_subdev *sd, static int m52790_g_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg) { struct m52790_state *state = to_state(sd); - struct i2c_client *client = v4l2_get_subdevdata(sd); - if (!v4l2_chip_match_i2c_client(client, ®->match)) - return -EINVAL; if (reg->reg != 0) return -EINVAL; reg->size = 1; @@ -97,10 +93,7 @@ static int m52790_g_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *r static int m52790_s_register(struct v4l2_subdev *sd, const struct v4l2_dbg_register *reg) { struct m52790_state *state = to_state(sd); - struct i2c_client *client = v4l2_get_subdevdata(sd); - if (!v4l2_chip_match_i2c_client(client, ®->match)) - return -EINVAL; if (reg->reg != 0) return -EINVAL; state->input = reg->val & 0x0303; @@ -110,13 +103,6 @@ static int m52790_s_register(struct v4l2_subdev *sd, const struct v4l2_dbg_regis } #endif -static int m52790_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *chip) -{ - struct i2c_client *client = v4l2_get_subdevdata(sd); - - return v4l2_chip_ident_i2c_client(client, chip, V4L2_IDENT_M52790, 0); -} - static int m52790_log_status(struct v4l2_subdev *sd) { struct m52790_state *state = to_state(sd); @@ -132,7 +118,6 @@ static int m52790_log_status(struct v4l2_subdev *sd) static const struct v4l2_subdev_core_ops m52790_core_ops = { .log_status = m52790_log_status, - .g_chip_ident = m52790_g_chip_ident, #ifdef CONFIG_VIDEO_ADV_DEBUG .g_register = m52790_g_register, .s_register = m52790_s_register, diff --git a/drivers/media/i2c/msp3400-driver.c b/drivers/media/i2c/msp3400-driver.c index ae92c20790e3..8190fec68080 100644 --- a/drivers/media/i2c/msp3400-driver.c +++ b/drivers/media/i2c/msp3400-driver.c @@ -570,15 +570,6 @@ static int msp_s_i2s_clock_freq(struct v4l2_subdev *sd, u32 freq) return 0; } -static int msp_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *chip) -{ - struct msp_state *state = to_state(sd); - struct i2c_client *client = v4l2_get_subdevdata(sd); - - return v4l2_chip_ident_i2c_client(client, chip, state->ident, - (state->rev1 << 16) | state->rev2); -} - static int msp_log_status(struct v4l2_subdev *sd) { struct msp_state *state = to_state(sd); @@ -651,7 +642,6 @@ static const struct v4l2_ctrl_ops msp_ctrl_ops = { static const struct v4l2_subdev_core_ops msp_core_ops = { .log_status = msp_log_status, - .g_chip_ident = msp_g_chip_ident, .g_ext_ctrls = v4l2_subdev_g_ext_ctrls, .try_ext_ctrls = v4l2_subdev_try_ext_ctrls, .s_ext_ctrls = v4l2_subdev_s_ext_ctrls, diff --git a/drivers/media/i2c/mt9m032.c b/drivers/media/i2c/mt9m032.c index cca704e02f79..846b15f0bf64 100644 --- a/drivers/media/i2c/mt9m032.c +++ b/drivers/media/i2c/mt9m032.c @@ -554,10 +554,8 @@ static int mt9m032_g_register(struct v4l2_subdev *sd, struct i2c_client *client = v4l2_get_subdevdata(&sensor->subdev); int val; - if (reg->match.type != V4L2_CHIP_MATCH_I2C_ADDR || reg->reg > 0xff) + if (reg->reg > 0xff) return -EINVAL; - if (reg->match.addr != client->addr) - return -ENODEV; val = mt9m032_read(client, reg->reg); if (val < 0) @@ -575,12 +573,9 @@ static int mt9m032_s_register(struct v4l2_subdev *sd, struct mt9m032 *sensor = to_mt9m032(sd); struct i2c_client *client = v4l2_get_subdevdata(&sensor->subdev); - if (reg->match.type != V4L2_CHIP_MATCH_I2C_ADDR || reg->reg > 0xff) + if (reg->reg > 0xff) return -EINVAL; - if (reg->match.addr != client->addr) - return -ENODEV; - return mt9m032_write(client, reg->reg, reg->val); } #endif diff --git a/drivers/media/i2c/mt9p031.c b/drivers/media/i2c/mt9p031.c index bf49899945f8..fe3414866a63 100644 --- a/drivers/media/i2c/mt9p031.c +++ b/drivers/media/i2c/mt9p031.c @@ -25,7 +25,6 @@ #include #include -#include #include #include #include diff --git a/drivers/media/i2c/mt9v011.c b/drivers/media/i2c/mt9v011.c index 141919bf77fc..f74698cf14c9 100644 --- a/drivers/media/i2c/mt9v011.c +++ b/drivers/media/i2c/mt9v011.c @@ -12,7 +12,6 @@ #include #include #include -#include #include #include @@ -407,11 +406,6 @@ static int mt9v011_s_mbus_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt static int mt9v011_g_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg) { - struct i2c_client *client = v4l2_get_subdevdata(sd); - - if (!v4l2_chip_match_i2c_client(client, ®->match)) - return -EINVAL; - reg->val = mt9v011_read(sd, reg->reg & 0xff); reg->size = 2; @@ -421,29 +415,12 @@ static int mt9v011_g_register(struct v4l2_subdev *sd, static int mt9v011_s_register(struct v4l2_subdev *sd, const struct v4l2_dbg_register *reg) { - struct i2c_client *client = v4l2_get_subdevdata(sd); - - if (!v4l2_chip_match_i2c_client(client, ®->match)) - return -EINVAL; - mt9v011_write(sd, reg->reg & 0xff, reg->val & 0xffff); return 0; } #endif -static int mt9v011_g_chip_ident(struct v4l2_subdev *sd, - struct v4l2_dbg_chip_ident *chip) -{ - u16 version; - struct i2c_client *client = v4l2_get_subdevdata(sd); - - version = mt9v011_read(sd, R00_MT9V011_CHIP_VERSION); - - return v4l2_chip_ident_i2c_client(client, chip, V4L2_IDENT_MT9V011, - version); -} - static int mt9v011_s_ctrl(struct v4l2_ctrl *ctrl) { struct mt9v011 *core = @@ -485,7 +462,6 @@ static struct v4l2_ctrl_ops mt9v011_ctrl_ops = { static const struct v4l2_subdev_core_ops mt9v011_core_ops = { .reset = mt9v011_reset, - .g_chip_ident = mt9v011_g_chip_ident, #ifdef CONFIG_VIDEO_ADV_DEBUG .g_register = mt9v011_g_register, .s_register = mt9v011_s_register, diff --git a/drivers/media/i2c/noon010pc30.c b/drivers/media/i2c/noon010pc30.c index 2284b02102db..271d0b7967a6 100644 --- a/drivers/media/i2c/noon010pc30.c +++ b/drivers/media/i2c/noon010pc30.c @@ -19,7 +19,6 @@ #include #include #include -#include #include #include #include diff --git a/drivers/media/i2c/ov7640.c b/drivers/media/i2c/ov7640.c index 5e117abaa2eb..faa64baf09e8 100644 --- a/drivers/media/i2c/ov7640.c +++ b/drivers/media/i2c/ov7640.c @@ -20,7 +20,6 @@ #include #include #include -#include #include MODULE_DESCRIPTION("OmniVision ov7640 sensor driver"); diff --git a/drivers/media/i2c/ov7670.c b/drivers/media/i2c/ov7670.c index b030279810d3..e8a1ce204036 100644 --- a/drivers/media/i2c/ov7670.c +++ b/drivers/media/i2c/ov7670.c @@ -17,7 +17,6 @@ #include #include #include -#include #include #include #include @@ -1462,23 +1461,12 @@ static const struct v4l2_ctrl_ops ov7670_ctrl_ops = { .g_volatile_ctrl = ov7670_g_volatile_ctrl, }; -static int ov7670_g_chip_ident(struct v4l2_subdev *sd, - struct v4l2_dbg_chip_ident *chip) -{ - struct i2c_client *client = v4l2_get_subdevdata(sd); - - return v4l2_chip_ident_i2c_client(client, chip, V4L2_IDENT_OV7670, 0); -} - #ifdef CONFIG_VIDEO_ADV_DEBUG static int ov7670_g_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg) { - struct i2c_client *client = v4l2_get_subdevdata(sd); unsigned char val = 0; int ret; - if (!v4l2_chip_match_i2c_client(client, ®->match)) - return -EINVAL; ret = ov7670_read(sd, reg->reg & 0xff, &val); reg->val = val; reg->size = 1; @@ -1487,10 +1475,6 @@ static int ov7670_g_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *r static int ov7670_s_register(struct v4l2_subdev *sd, const struct v4l2_dbg_register *reg) { - struct i2c_client *client = v4l2_get_subdevdata(sd); - - if (!v4l2_chip_match_i2c_client(client, ®->match)) - return -EINVAL; ov7670_write(sd, reg->reg & 0xff, reg->val & 0xff); return 0; } @@ -1499,7 +1483,6 @@ static int ov7670_s_register(struct v4l2_subdev *sd, const struct v4l2_dbg_regis /* ----------------------------------------------------------------------- */ static const struct v4l2_subdev_core_ops ov7670_core_ops = { - .g_chip_ident = ov7670_g_chip_ident, .reset = ov7670_reset, .init = ov7670_init, #ifdef CONFIG_VIDEO_ADV_DEBUG diff --git a/drivers/media/i2c/saa6588.c b/drivers/media/i2c/saa6588.c index 729e78d94222..70bc72e795d0 100644 --- a/drivers/media/i2c/saa6588.c +++ b/drivers/media/i2c/saa6588.c @@ -33,7 +33,6 @@ #include #include -#include /* insmod options */ @@ -443,17 +442,9 @@ static int saa6588_s_tuner(struct v4l2_subdev *sd, const struct v4l2_tuner *vt) return 0; } -static int saa6588_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *chip) -{ - struct i2c_client *client = v4l2_get_subdevdata(sd); - - return v4l2_chip_ident_i2c_client(client, chip, V4L2_IDENT_SAA6588, 0); -} - /* ----------------------------------------------------------------------- */ static const struct v4l2_subdev_core_ops saa6588_core_ops = { - .g_chip_ident = saa6588_g_chip_ident, .ioctl = saa6588_ioctl, }; diff --git a/drivers/media/i2c/saa7110.c b/drivers/media/i2c/saa7110.c index e4026aa93f42..532105de96f0 100644 --- a/drivers/media/i2c/saa7110.c +++ b/drivers/media/i2c/saa7110.c @@ -35,7 +35,6 @@ #include #include #include -#include #include MODULE_DESCRIPTION("Philips SAA7110 video decoder driver"); @@ -352,13 +351,6 @@ static int saa7110_s_ctrl(struct v4l2_ctrl *ctrl) return 0; } -static int saa7110_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *chip) -{ - struct i2c_client *client = v4l2_get_subdevdata(sd); - - return v4l2_chip_ident_i2c_client(client, chip, V4L2_IDENT_SAA7110, 0); -} - /* ----------------------------------------------------------------------- */ static const struct v4l2_ctrl_ops saa7110_ctrl_ops = { @@ -366,7 +358,6 @@ static const struct v4l2_ctrl_ops saa7110_ctrl_ops = { }; static const struct v4l2_subdev_core_ops saa7110_core_ops = { - .g_chip_ident = saa7110_g_chip_ident, .g_ext_ctrls = v4l2_subdev_g_ext_ctrls, .try_ext_ctrls = v4l2_subdev_try_ext_ctrls, .s_ext_ctrls = v4l2_subdev_s_ext_ctrls, diff --git a/drivers/media/i2c/saa7115.c b/drivers/media/i2c/saa7115.c index 4daa81c55a82..90c43f3fb0f1 100644 --- a/drivers/media/i2c/saa7115.c +++ b/drivers/media/i2c/saa7115.c @@ -46,7 +46,6 @@ #include #include #include -#include #include #include @@ -63,6 +62,16 @@ module_param(debug, bool, 0644); MODULE_PARM_DESC(debug, "Debug level (0-1)"); +enum saa711x_model { + SAA7111A, + SAA7111, + SAA7113, + GM7113C, + SAA7114, + SAA7115, + SAA7118, +}; + struct saa711x_state { struct v4l2_subdev sd; struct v4l2_ctrl_handler hdl; @@ -80,7 +89,7 @@ struct saa711x_state { int radio; int width; int height; - u32 ident; + enum saa711x_model ident; u32 audclk_freq; u32 crystal_freq; bool ucgc; @@ -111,10 +120,10 @@ static inline int saa711x_write(struct v4l2_subdev *sd, u8 reg, u8 value) /* Sanity routine to check if a register is present */ static int saa711x_has_reg(const int id, const u8 reg) { - if (id == V4L2_IDENT_SAA7111) + if (id == SAA7111) return reg < 0x20 && reg != 0x01 && reg != 0x0f && (reg < 0x13 || reg > 0x19) && reg != 0x1d && reg != 0x1e; - if (id == V4L2_IDENT_SAA7111A) + if (id == SAA7111A) return reg < 0x20 && reg != 0x01 && reg != 0x0f && reg != 0x14 && reg != 0x18 && reg != 0x19 && reg != 0x1d && reg != 0x1e; @@ -127,18 +136,18 @@ static int saa711x_has_reg(const int id, const u8 reg) return 0; switch (id) { - case V4L2_IDENT_GM7113C: + case GM7113C: return reg != 0x14 && (reg < 0x18 || reg > 0x1e) && reg < 0x20; - case V4L2_IDENT_SAA7113: + case SAA7113: return reg != 0x14 && (reg < 0x18 || reg > 0x1e) && (reg < 0x20 || reg > 0x3f) && reg != 0x5d && reg < 0x63; - case V4L2_IDENT_SAA7114: + case SAA7114: return (reg < 0x1a || reg > 0x1e) && (reg < 0x20 || reg > 0x2f) && (reg < 0x63 || reg > 0x7f) && reg != 0x33 && reg != 0x37 && reg != 0x81 && reg < 0xf0; - case V4L2_IDENT_SAA7115: + case SAA7115: return (reg < 0x20 || reg > 0x2f) && reg != 0x65 && (reg < 0xfc || reg > 0xfe); - case V4L2_IDENT_SAA7118: + case SAA7118: return (reg < 0x1a || reg > 0x1d) && (reg < 0x20 || reg > 0x22) && (reg < 0x26 || reg > 0x28) && reg != 0x33 && reg != 0x37 && (reg < 0x63 || reg > 0x7f) && reg != 0x81 && reg < 0xf0; @@ -955,14 +964,14 @@ static void saa711x_set_v4lstd(struct v4l2_subdev *sd, v4l2_std_id std) // This works for NTSC-M, SECAM-L and the 50Hz PAL variants. if (std & V4L2_STD_525_60) { v4l2_dbg(1, debug, sd, "decoder set standard 60 Hz\n"); - if (state->ident == V4L2_IDENT_GM7113C) + if (state->ident == GM7113C) saa711x_writeregs(sd, gm7113c_cfg_60hz_video); else saa711x_writeregs(sd, saa7115_cfg_60hz_video); saa711x_set_size(sd, 720, 480); } else { v4l2_dbg(1, debug, sd, "decoder set standard 50 Hz\n"); - if (state->ident == V4L2_IDENT_GM7113C) + if (state->ident == GM7113C) saa711x_writeregs(sd, gm7113c_cfg_50hz_video); else saa711x_writeregs(sd, saa7115_cfg_50hz_video); @@ -978,8 +987,8 @@ static void saa711x_set_v4lstd(struct v4l2_subdev *sd, v4l2_std_id std) 011 NTSC N (3.58MHz) PAL M (3.58MHz) 100 reserved NTSC-Japan (3.58MHz) */ - if (state->ident <= V4L2_IDENT_SAA7113 || - state->ident == V4L2_IDENT_GM7113C) { + if (state->ident <= SAA7113 || + state->ident == GM7113C) { u8 reg = saa711x_read(sd, R_0E_CHROMA_CNTL_1) & 0x8f; if (std == V4L2_STD_PAL_M) { @@ -998,9 +1007,8 @@ static void saa711x_set_v4lstd(struct v4l2_subdev *sd, v4l2_std_id std) /* restart task B if needed */ int taskb = saa711x_read(sd, R_80_GLOBAL_CNTL_1) & 0x10; - if (taskb && state->ident == V4L2_IDENT_SAA7114) { + if (taskb && state->ident == SAA7114) saa711x_writeregs(sd, saa7115_cfg_vbi_on); - } /* switch audio mode too! */ saa711x_s_clock_freq(sd, state->audclk_freq); @@ -1022,7 +1030,7 @@ static void saa711x_set_lcr(struct v4l2_subdev *sd, struct v4l2_sliced_vbi_forma #else /* SAA7113 and SAA7118 also should support VBI - Need testing */ - if (state->ident != V4L2_IDENT_SAA7115) + if (state->ident != SAA7115) return; #endif @@ -1244,14 +1252,14 @@ static int saa711x_s_routing(struct v4l2_subdev *sd, u32 input, u32 output, u32 config) { struct saa711x_state *state = to_state(sd); - u8 mask = (state->ident <= V4L2_IDENT_SAA7111A) ? 0xf8 : 0xf0; + u8 mask = (state->ident <= SAA7111A) ? 0xf8 : 0xf0; v4l2_dbg(1, debug, sd, "decoder set input %d output %d\n", input, output); /* saa7111/3 does not have these inputs */ - if ((state->ident <= V4L2_IDENT_SAA7113 || - state->ident == V4L2_IDENT_GM7113C) && + if ((state->ident <= SAA7113 || + state->ident == GM7113C) && (input == SAA7115_COMPOSITE4 || input == SAA7115_COMPOSITE5)) { return -EINVAL; @@ -1266,7 +1274,7 @@ static int saa711x_s_routing(struct v4l2_subdev *sd, state->input = input; /* saa7111 has slightly different input numbering */ - if (state->ident <= V4L2_IDENT_SAA7111A) { + if (state->ident <= SAA7111A) { if (input >= SAA7115_COMPOSITE4) input -= 2; /* saa7111 specific */ @@ -1289,13 +1297,13 @@ static int saa711x_s_routing(struct v4l2_subdev *sd, (state->input >= SAA7115_SVIDEO0 ? 0x80 : 0x0)); state->output = output; - if (state->ident == V4L2_IDENT_SAA7114 || - state->ident == V4L2_IDENT_SAA7115) { + if (state->ident == SAA7114 || + state->ident == SAA7115) { saa711x_write(sd, R_83_X_PORT_I_O_ENA_AND_OUT_CLK, (saa711x_read(sd, R_83_X_PORT_I_O_ENA_AND_OUT_CLK) & 0xfe) | (state->output & 0x01)); } - if (state->ident > V4L2_IDENT_SAA7111A) { + if (state->ident > SAA7111A) { if (config & SAA7115_IDQ_IS_DEFAULT) saa711x_write(sd, R_85_I_PORT_SIGNAL_POLAR, 0x20); else @@ -1308,7 +1316,7 @@ static int saa711x_s_gpio(struct v4l2_subdev *sd, u32 val) { struct saa711x_state *state = to_state(sd); - if (state->ident > V4L2_IDENT_SAA7111A) + if (state->ident > SAA7111A) return -EINVAL; saa711x_write(sd, 0x11, (saa711x_read(sd, 0x11) & 0x7f) | (val ? 0x80 : 0)); @@ -1398,7 +1406,7 @@ static int saa711x_querystd(struct v4l2_subdev *sd, v4l2_std_id *std) reg1f = saa711x_read(sd, R_1F_STATUS_BYTE_2_VD_DEC); - if (state->ident == V4L2_IDENT_SAA7115) { + if (state->ident == SAA7115) { reg1e = saa711x_read(sd, R_1E_STATUS_BYTE_1_VD_DEC); v4l2_dbg(1, debug, sd, "Status byte 1 (0x1e)=0x%02x\n", reg1e); @@ -1449,7 +1457,7 @@ static int saa711x_g_input_status(struct v4l2_subdev *sd, u32 *status) int reg1f; *status = V4L2_IN_ST_NO_SIGNAL; - if (state->ident == V4L2_IDENT_SAA7115) + if (state->ident == SAA7115) reg1e = saa711x_read(sd, R_1E_STATUS_BYTE_1_VD_DEC); reg1f = saa711x_read(sd, R_1F_STATUS_BYTE_2_VD_DEC); if ((reg1f & 0xc1) == 0x81 && (reg1e & 0xc0) == 0x80) @@ -1460,10 +1468,6 @@ static int saa711x_g_input_status(struct v4l2_subdev *sd, u32 *status) #ifdef CONFIG_VIDEO_ADV_DEBUG static int saa711x_g_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg) { - struct i2c_client *client = v4l2_get_subdevdata(sd); - - if (!v4l2_chip_match_i2c_client(client, ®->match)) - return -EINVAL; reg->val = saa711x_read(sd, reg->reg & 0xff); reg->size = 1; return 0; @@ -1471,23 +1475,11 @@ static int saa711x_g_register(struct v4l2_subdev *sd, struct v4l2_dbg_register * static int saa711x_s_register(struct v4l2_subdev *sd, const struct v4l2_dbg_register *reg) { - struct i2c_client *client = v4l2_get_subdevdata(sd); - - if (!v4l2_chip_match_i2c_client(client, ®->match)) - return -EINVAL; saa711x_write(sd, reg->reg & 0xff, reg->val & 0xff); return 0; } #endif -static int saa711x_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *chip) -{ - struct saa711x_state *state = to_state(sd); - struct i2c_client *client = v4l2_get_subdevdata(sd); - - return v4l2_chip_ident_i2c_client(client, chip, state->ident, 0); -} - static int saa711x_log_status(struct v4l2_subdev *sd) { struct saa711x_state *state = to_state(sd); @@ -1496,7 +1488,7 @@ static int saa711x_log_status(struct v4l2_subdev *sd) int vcr; v4l2_info(sd, "Audio frequency: %d Hz\n", state->audclk_freq); - if (state->ident != V4L2_IDENT_SAA7115) { + if (state->ident != SAA7115) { /* status for the saa7114 */ reg1f = saa711x_read(sd, R_1F_STATUS_BYTE_2_VD_DEC); signalOk = (reg1f & 0xc1) == 0x81; @@ -1547,7 +1539,6 @@ static const struct v4l2_ctrl_ops saa711x_ctrl_ops = { static const struct v4l2_subdev_core_ops saa711x_core_ops = { .log_status = saa711x_log_status, - .g_chip_ident = saa711x_g_chip_ident, .g_ext_ctrls = v4l2_subdev_g_ext_ctrls, .try_ext_ctrls = v4l2_subdev_try_ext_ctrls, .s_ext_ctrls = v4l2_subdev_s_ext_ctrls, @@ -1650,21 +1641,21 @@ static int saa711x_detect_chip(struct i2c_client *client, if (chip_ver[0] & 0xf0) { snprintf(name, CHIP_VER_SIZE, "saa711%ca", chip_id); v4l_info(client, "saa7111a variant found\n"); - return V4L2_IDENT_SAA7111A; + return SAA7111A; } - return V4L2_IDENT_SAA7111; + return SAA7111; case '3': - return V4L2_IDENT_SAA7113; + return SAA7113; case '4': - return V4L2_IDENT_SAA7114; + return SAA7114; case '5': - return V4L2_IDENT_SAA7115; + return SAA7115; case '8': - return V4L2_IDENT_SAA7118; + return SAA7118; default: v4l2_info(client, "WARNING: Philips/NXP chip unknown - Falling back to saa7111\n"); - return V4L2_IDENT_SAA7111; + return SAA7111; } } @@ -1695,7 +1686,7 @@ static int saa711x_detect_chip(struct i2c_client *client, "It seems to be a %s chip (%*ph) @ 0x%x.\n", name, 16, chip_ver, client->addr << 1); - return V4L2_IDENT_GM7113C; + return GM7113C; } /* Chip was not discovered. Return its ID and don't bind */ @@ -1774,19 +1765,19 @@ static int saa711x_probe(struct i2c_client *client, /* init to 60hz/48khz */ state->crystal_freq = SAA7115_FREQ_24_576_MHZ; switch (state->ident) { - case V4L2_IDENT_SAA7111: - case V4L2_IDENT_SAA7111A: + case SAA7111: + case SAA7111A: saa711x_writeregs(sd, saa7111_init); break; - case V4L2_IDENT_GM7113C: - case V4L2_IDENT_SAA7113: + case GM7113C: + case SAA7113: saa711x_writeregs(sd, saa7113_init); break; default: state->crystal_freq = SAA7115_FREQ_32_11_MHZ; saa711x_writeregs(sd, saa7115_init_auto_input); } - if (state->ident > V4L2_IDENT_SAA7111A) + if (state->ident > SAA7111A) saa711x_writeregs(sd, saa7115_init_misc); saa711x_set_v4lstd(sd, V4L2_STD_NTSC); v4l2_ctrl_handler_setup(hdl); diff --git a/drivers/media/i2c/saa7127.c b/drivers/media/i2c/saa7127.c index d9c388103e7a..264b755bedce 100644 --- a/drivers/media/i2c/saa7127.c +++ b/drivers/media/i2c/saa7127.c @@ -54,7 +54,6 @@ #include #include #include -#include #include static int debug; @@ -251,10 +250,15 @@ static struct i2c_reg_value saa7127_init_config_50hz_secam[] = { ********************************************************************** */ +enum saa712x_model { + SAA7127, + SAA7129, +}; + struct saa7127_state { struct v4l2_subdev sd; v4l2_std_id std; - u32 ident; + enum saa712x_model ident; enum saa7127_input_type input_type; enum saa7127_output_type output_type; int video_enable; @@ -482,7 +486,7 @@ static int saa7127_set_std(struct v4l2_subdev *sd, v4l2_std_id std) inittab = saa7127_init_config_60hz; state->reg_61 = SAA7127_60HZ_DAC_CONTROL; - } else if (state->ident == V4L2_IDENT_SAA7129 && + } else if (state->ident == SAA7129 && (std & V4L2_STD_SECAM) && !(std & (V4L2_STD_625_50 & ~V4L2_STD_SECAM))) { @@ -517,7 +521,7 @@ static int saa7127_set_output_type(struct v4l2_subdev *sd, int output) break; case SAA7127_OUTPUT_TYPE_COMPOSITE: - if (state->ident == V4L2_IDENT_SAA7129) + if (state->ident == SAA7129) state->reg_2d = 0x20; /* CVBS only */ else state->reg_2d = 0x08; /* 00001000 CVBS only, RGB DAC's off (high impedance mode) */ @@ -525,7 +529,7 @@ static int saa7127_set_output_type(struct v4l2_subdev *sd, int output) break; case SAA7127_OUTPUT_TYPE_SVIDEO: - if (state->ident == V4L2_IDENT_SAA7129) + if (state->ident == SAA7129) state->reg_2d = 0x18; /* Y + C */ else state->reg_2d = 0xff; /*11111111 croma -> R, luma -> CVBS + G + B */ @@ -543,7 +547,7 @@ static int saa7127_set_output_type(struct v4l2_subdev *sd, int output) break; case SAA7127_OUTPUT_TYPE_BOTH: - if (state->ident == V4L2_IDENT_SAA7129) + if (state->ident == SAA7129) state->reg_2d = 0x38; else state->reg_2d = 0xbf; @@ -661,10 +665,6 @@ static int saa7127_s_vbi_data(struct v4l2_subdev *sd, const struct v4l2_sliced_v #ifdef CONFIG_VIDEO_ADV_DEBUG static int saa7127_g_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg) { - struct i2c_client *client = v4l2_get_subdevdata(sd); - - if (!v4l2_chip_match_i2c_client(client, ®->match)) - return -EINVAL; reg->val = saa7127_read(sd, reg->reg & 0xff); reg->size = 1; return 0; @@ -672,23 +672,11 @@ static int saa7127_g_register(struct v4l2_subdev *sd, struct v4l2_dbg_register * static int saa7127_s_register(struct v4l2_subdev *sd, const struct v4l2_dbg_register *reg) { - struct i2c_client *client = v4l2_get_subdevdata(sd); - - if (!v4l2_chip_match_i2c_client(client, ®->match)) - return -EINVAL; saa7127_write(sd, reg->reg & 0xff, reg->val & 0xff); return 0; } #endif -static int saa7127_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *chip) -{ - struct saa7127_state *state = to_state(sd); - struct i2c_client *client = v4l2_get_subdevdata(sd); - - return v4l2_chip_ident_i2c_client(client, chip, state->ident, 0); -} - static int saa7127_log_status(struct v4l2_subdev *sd) { struct saa7127_state *state = to_state(sd); @@ -708,7 +696,6 @@ static int saa7127_log_status(struct v4l2_subdev *sd) static const struct v4l2_subdev_core_ops saa7127_core_ops = { .log_status = saa7127_log_status, - .g_chip_ident = saa7127_g_chip_ident, #ifdef CONFIG_VIDEO_ADV_DEBUG .g_register = saa7127_g_register, .s_register = saa7127_s_register, @@ -777,10 +764,10 @@ static int saa7127_probe(struct i2c_client *client, if (saa7127_read(sd, SAA7129_REG_FADE_KEY_COL2) == 0xaa) { saa7127_write(sd, SAA7129_REG_FADE_KEY_COL2, read_result); - state->ident = V4L2_IDENT_SAA7129; + state->ident = SAA7129; strlcpy(client->name, "saa7129", I2C_NAME_SIZE); } else { - state->ident = V4L2_IDENT_SAA7127; + state->ident = SAA7127; strlcpy(client->name, "saa7127", I2C_NAME_SIZE); } } @@ -804,7 +791,7 @@ static int saa7127_probe(struct i2c_client *client, saa7127_set_input_type(sd, SAA7127_INPUT_TYPE_NORMAL); saa7127_set_video_enable(sd, 1); - if (state->ident == V4L2_IDENT_SAA7129) + if (state->ident == SAA7129) saa7127_write_inittab(sd, saa7129_init_config_extra); return 0; } @@ -825,10 +812,10 @@ static int saa7127_remove(struct i2c_client *client) static struct i2c_device_id saa7127_id[] = { { "saa7127_auto", 0 }, /* auto-detection */ - { "saa7126", V4L2_IDENT_SAA7127 }, - { "saa7127", V4L2_IDENT_SAA7127 }, - { "saa7128", V4L2_IDENT_SAA7129 }, - { "saa7129", V4L2_IDENT_SAA7129 }, + { "saa7126", SAA7127 }, + { "saa7127", SAA7127 }, + { "saa7128", SAA7129 }, + { "saa7129", SAA7129 }, { } }; MODULE_DEVICE_TABLE(i2c, saa7127_id); diff --git a/drivers/media/i2c/saa717x.c b/drivers/media/i2c/saa717x.c index 330a04c58939..401ca114ab99 100644 --- a/drivers/media/i2c/saa717x.c +++ b/drivers/media/i2c/saa717x.c @@ -977,10 +977,6 @@ static int saa717x_s_video_routing(struct v4l2_subdev *sd, #ifdef CONFIG_VIDEO_ADV_DEBUG static int saa717x_g_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg) { - struct i2c_client *client = v4l2_get_subdevdata(sd); - - if (!v4l2_chip_match_i2c_client(client, ®->match)) - return -EINVAL; reg->val = saa717x_read(sd, reg->reg); reg->size = 1; return 0; @@ -988,12 +984,9 @@ static int saa717x_g_register(struct v4l2_subdev *sd, struct v4l2_dbg_register * static int saa717x_s_register(struct v4l2_subdev *sd, const struct v4l2_dbg_register *reg) { - struct i2c_client *client = v4l2_get_subdevdata(sd); u16 addr = reg->reg & 0xffff; u8 val = reg->val & 0xff; - if (!v4l2_chip_match_i2c_client(client, ®->match)) - return -EINVAL; saa717x_write(sd, addr, val); return 0; } diff --git a/drivers/media/i2c/saa7185.c b/drivers/media/i2c/saa7185.c index e95a0edc7f3e..f56c1c88b27d 100644 --- a/drivers/media/i2c/saa7185.c +++ b/drivers/media/i2c/saa7185.c @@ -32,7 +32,6 @@ #include #include #include -#include MODULE_DESCRIPTION("Philips SAA7185 video encoder driver"); MODULE_AUTHOR("Dave Perks"); @@ -285,17 +284,9 @@ static int saa7185_s_routing(struct v4l2_subdev *sd, return 0; } -static int saa7185_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *chip) -{ - struct i2c_client *client = v4l2_get_subdevdata(sd); - - return v4l2_chip_ident_i2c_client(client, chip, V4L2_IDENT_SAA7185, 0); -} - /* ----------------------------------------------------------------------- */ static const struct v4l2_subdev_core_ops saa7185_core_ops = { - .g_chip_ident = saa7185_g_chip_ident, .init = saa7185_init, }; diff --git a/drivers/media/i2c/saa7191.c b/drivers/media/i2c/saa7191.c index 84f7899a4044..08dcaecbeb98 100644 --- a/drivers/media/i2c/saa7191.c +++ b/drivers/media/i2c/saa7191.c @@ -22,7 +22,6 @@ #include #include #include -#include #include "saa7191.h" @@ -567,18 +566,9 @@ static int saa7191_g_input_status(struct v4l2_subdev *sd, u32 *status) } -static int saa7191_g_chip_ident(struct v4l2_subdev *sd, - struct v4l2_dbg_chip_ident *chip) -{ - struct i2c_client *client = v4l2_get_subdevdata(sd); - - return v4l2_chip_ident_i2c_client(client, chip, V4L2_IDENT_SAA7191, 0); -} - /* ----------------------------------------------------------------------- */ static const struct v4l2_subdev_core_ops saa7191_core_ops = { - .g_chip_ident = saa7191_g_chip_ident, .g_ctrl = saa7191_g_ctrl, .s_ctrl = saa7191_s_ctrl, .s_std = saa7191_s_std, diff --git a/drivers/media/i2c/tda9840.c b/drivers/media/i2c/tda9840.c index 3f1266246ca3..fbdff8b24eec 100644 --- a/drivers/media/i2c/tda9840.c +++ b/drivers/media/i2c/tda9840.c @@ -31,7 +31,6 @@ #include #include #include -#include MODULE_AUTHOR("Michael Hunold "); MODULE_DESCRIPTION("tda9840 driver"); @@ -145,26 +144,14 @@ static int tda9840_g_tuner(struct v4l2_subdev *sd, struct v4l2_tuner *t) return 0; } -static int tda9840_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *chip) -{ - struct i2c_client *client = v4l2_get_subdevdata(sd); - - return v4l2_chip_ident_i2c_client(client, chip, V4L2_IDENT_TDA9840, 0); -} - /* ----------------------------------------------------------------------- */ -static const struct v4l2_subdev_core_ops tda9840_core_ops = { - .g_chip_ident = tda9840_g_chip_ident, -}; - static const struct v4l2_subdev_tuner_ops tda9840_tuner_ops = { .s_tuner = tda9840_s_tuner, .g_tuner = tda9840_g_tuner, }; static const struct v4l2_subdev_ops tda9840_ops = { - .core = &tda9840_core_ops, .tuner = &tda9840_tuner_ops, }; diff --git a/drivers/media/i2c/tea6415c.c b/drivers/media/i2c/tea6415c.c index 52ebc384e453..bbe1a99fda36 100644 --- a/drivers/media/i2c/tea6415c.c +++ b/drivers/media/i2c/tea6415c.c @@ -33,7 +33,6 @@ #include #include #include -#include #include "tea6415c.h" MODULE_AUTHOR("Michael Hunold "); @@ -119,25 +118,13 @@ static int tea6415c_s_routing(struct v4l2_subdev *sd, return ret; } -static int tea6415c_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *chip) -{ - struct i2c_client *client = v4l2_get_subdevdata(sd); - - return v4l2_chip_ident_i2c_client(client, chip, V4L2_IDENT_TEA6415C, 0); -} - /* ----------------------------------------------------------------------- */ -static const struct v4l2_subdev_core_ops tea6415c_core_ops = { - .g_chip_ident = tea6415c_g_chip_ident, -}; - static const struct v4l2_subdev_video_ops tea6415c_video_ops = { .s_routing = tea6415c_s_routing, }; static const struct v4l2_subdev_ops tea6415c_ops = { - .core = &tea6415c_core_ops, .video = &tea6415c_video_ops, }; diff --git a/drivers/media/i2c/tea6420.c b/drivers/media/i2c/tea6420.c index 1f869742e3fe..30a8d75771af 100644 --- a/drivers/media/i2c/tea6420.c +++ b/drivers/media/i2c/tea6420.c @@ -33,7 +33,6 @@ #include #include #include -#include #include "tea6420.h" MODULE_AUTHOR("Michael Hunold "); @@ -90,25 +89,13 @@ static int tea6420_s_routing(struct v4l2_subdev *sd, return 0; } -static int tea6420_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *chip) -{ - struct i2c_client *client = v4l2_get_subdevdata(sd); - - return v4l2_chip_ident_i2c_client(client, chip, V4L2_IDENT_TEA6420, 0); -} - /* ----------------------------------------------------------------------- */ -static const struct v4l2_subdev_core_ops tea6420_core_ops = { - .g_chip_ident = tea6420_g_chip_ident, -}; - static const struct v4l2_subdev_audio_ops tea6420_audio_ops = { .s_routing = tea6420_s_routing, }; static const struct v4l2_subdev_ops tea6420_ops = { - .core = &tea6420_core_ops, .audio = &tea6420_audio_ops, }; diff --git a/drivers/media/i2c/ths7303.c b/drivers/media/i2c/ths7303.c index b954195cfbe7..2e17abc77310 100644 --- a/drivers/media/i2c/ths7303.c +++ b/drivers/media/i2c/ths7303.c @@ -26,7 +26,6 @@ #include #include -#include #include #define THS7303_CHANNEL_1 1 @@ -212,15 +211,6 @@ static int ths7303_s_dv_timings(struct v4l2_subdev *sd, return ths7303_config(sd); } -static int ths7303_g_chip_ident(struct v4l2_subdev *sd, - struct v4l2_dbg_chip_ident *chip) -{ - struct i2c_client *client = v4l2_get_subdevdata(sd); - struct ths7303_state *state = to_state(sd); - - return v4l2_chip_ident_i2c_client(client, chip, state->driver_data, 0); -} - static const struct v4l2_subdev_video_ops ths7303_video_ops = { .s_stream = ths7303_s_stream, .s_std_output = ths7303_s_std_output, @@ -232,11 +222,6 @@ static const struct v4l2_subdev_video_ops ths7303_video_ops = { static int ths7303_g_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg) { - struct i2c_client *client = v4l2_get_subdevdata(sd); - - if (!v4l2_chip_match_i2c_client(client, ®->match)) - return -EINVAL; - reg->size = 1; reg->val = ths7303_read(sd, reg->reg); return 0; @@ -245,11 +230,6 @@ static int ths7303_g_register(struct v4l2_subdev *sd, static int ths7303_s_register(struct v4l2_subdev *sd, const struct v4l2_dbg_register *reg) { - struct i2c_client *client = v4l2_get_subdevdata(sd); - - if (!v4l2_chip_match_i2c_client(client, ®->match)) - return -EINVAL; - ths7303_write(sd, reg->reg, reg->val); return 0; } @@ -336,7 +316,6 @@ static int ths7303_log_status(struct v4l2_subdev *sd) } static const struct v4l2_subdev_core_ops ths7303_core_ops = { - .g_chip_ident = ths7303_g_chip_ident, .log_status = ths7303_log_status, #ifdef CONFIG_VIDEO_ADV_DEBUG .g_register = ths7303_g_register, @@ -398,8 +377,8 @@ static int ths7303_remove(struct i2c_client *client) } static const struct i2c_device_id ths7303_id[] = { - {"ths7303", V4L2_IDENT_THS7303}, - {"ths7353", V4L2_IDENT_THS7353}, + {"ths7303", 0}, + {"ths7353", 0}, {}, }; diff --git a/drivers/media/i2c/tvaudio.c b/drivers/media/i2c/tvaudio.c index fc69e9c27343..38135402019e 100644 --- a/drivers/media/i2c/tvaudio.c +++ b/drivers/media/i2c/tvaudio.c @@ -38,7 +38,6 @@ #include #include -#include #include #include @@ -1838,13 +1837,6 @@ static int tvaudio_s_frequency(struct v4l2_subdev *sd, const struct v4l2_frequen return 0; } -static int tvaudio_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *chip) -{ - struct i2c_client *client = v4l2_get_subdevdata(sd); - - return v4l2_chip_ident_i2c_client(client, chip, V4L2_IDENT_TVAUDIO, 0); -} - static int tvaudio_log_status(struct v4l2_subdev *sd) { struct CHIPSTATE *chip = to_state(sd); @@ -1863,7 +1855,6 @@ static const struct v4l2_ctrl_ops tvaudio_ctrl_ops = { static const struct v4l2_subdev_core_ops tvaudio_core_ops = { .log_status = tvaudio_log_status, - .g_chip_ident = tvaudio_g_chip_ident, .g_ext_ctrls = v4l2_subdev_g_ext_ctrls, .try_ext_ctrls = v4l2_subdev_try_ext_ctrls, .s_ext_ctrls = v4l2_subdev_s_ext_ctrls, diff --git a/drivers/media/i2c/tvp514x.c b/drivers/media/i2c/tvp514x.c index 7438e015d879..b5c17eb89b4e 100644 --- a/drivers/media/i2c/tvp514x.c +++ b/drivers/media/i2c/tvp514x.c @@ -39,7 +39,6 @@ #include #include #include -#include #include #include #include diff --git a/drivers/media/i2c/tvp5150.c b/drivers/media/i2c/tvp5150.c index b3cf26628c09..bef528233f7e 100644 --- a/drivers/media/i2c/tvp5150.c +++ b/drivers/media/i2c/tvp5150.c @@ -12,7 +12,6 @@ #include #include #include -#include #include #include "tvp5150_reg.h" @@ -1031,29 +1030,11 @@ static int tvp5150_g_sliced_fmt(struct v4l2_subdev *sd, struct v4l2_sliced_vbi_f return 0; } -static int tvp5150_g_chip_ident(struct v4l2_subdev *sd, - struct v4l2_dbg_chip_ident *chip) -{ - int rev; - struct i2c_client *client = v4l2_get_subdevdata(sd); - - rev = tvp5150_read(sd, TVP5150_ROM_MAJOR_VER) << 8 | - tvp5150_read(sd, TVP5150_ROM_MINOR_VER); - - return v4l2_chip_ident_i2c_client(client, chip, V4L2_IDENT_TVP5150, - rev); -} - - #ifdef CONFIG_VIDEO_ADV_DEBUG static int tvp5150_g_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg) { int res; - struct i2c_client *client = v4l2_get_subdevdata(sd); - - if (!v4l2_chip_match_i2c_client(client, ®->match)) - return -EINVAL; res = tvp5150_read(sd, reg->reg & 0xff); if (res < 0) { v4l2_err(sd, "%s: failed with error = %d\n", __func__, res); @@ -1067,10 +1048,6 @@ static int tvp5150_g_register(struct v4l2_subdev *sd, struct v4l2_dbg_register * static int tvp5150_s_register(struct v4l2_subdev *sd, const struct v4l2_dbg_register *reg) { - struct i2c_client *client = v4l2_get_subdevdata(sd); - - if (!v4l2_chip_match_i2c_client(client, ®->match)) - return -EINVAL; tvp5150_write(sd, reg->reg & 0xff, reg->val & 0xff); return 0; } @@ -1094,7 +1071,6 @@ static const struct v4l2_subdev_core_ops tvp5150_core_ops = { .log_status = tvp5150_log_status, .s_std = tvp5150_s_std, .reset = tvp5150_reset, - .g_chip_ident = tvp5150_g_chip_ident, #ifdef CONFIG_VIDEO_ADV_DEBUG .g_register = tvp5150_g_register, .s_register = tvp5150_s_register, diff --git a/drivers/media/i2c/tvp7002.c b/drivers/media/i2c/tvp7002.c index f339e6faca90..c2d0280ef3dc 100644 --- a/drivers/media/i2c/tvp7002.c +++ b/drivers/media/i2c/tvp7002.c @@ -32,7 +32,6 @@ #include #include #include -#include #include #include #include "tvp7002_reg.h" @@ -532,29 +531,6 @@ static inline void tvp7002_write_err(struct v4l2_subdev *sd, u8 reg, *err = tvp7002_write(sd, reg, val); } -/* - * tvp7002_g_chip_ident() - Get chip identification number - * @sd: ptr to v4l2_subdev struct - * @chip: ptr to v4l2_dbg_chip_ident struct - * - * Obtains the chip's identification number. - * Returns zero or -EINVAL if read operation fails. - */ -static int tvp7002_g_chip_ident(struct v4l2_subdev *sd, - struct v4l2_dbg_chip_ident *chip) -{ - u8 rev; - int error; - struct i2c_client *client = v4l2_get_subdevdata(sd); - - error = tvp7002_read(sd, TVP7002_CHIP_REV, &rev); - - if (error < 0) - return error; - - return v4l2_chip_ident_i2c_client(client, chip, V4L2_IDENT_TVP7002, rev); -} - /* * tvp7002_write_inittab() - Write initialization values * @sd: ptr to v4l2_subdev struct @@ -741,13 +717,9 @@ static int tvp7002_query_dv_timings(struct v4l2_subdev *sd, static int tvp7002_g_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg) { - struct i2c_client *client = v4l2_get_subdevdata(sd); u8 val; int ret; - if (!v4l2_chip_match_i2c_client(client, ®->match)) - return -EINVAL; - ret = tvp7002_read(sd, reg->reg & 0xff, &val); reg->val = val; return ret; @@ -764,11 +736,6 @@ static int tvp7002_g_register(struct v4l2_subdev *sd, static int tvp7002_s_register(struct v4l2_subdev *sd, const struct v4l2_dbg_register *reg) { - struct i2c_client *client = v4l2_get_subdevdata(sd); - - if (!v4l2_chip_match_i2c_client(client, ®->match)) - return -EINVAL; - return tvp7002_write(sd, reg->reg & 0xff, reg->val & 0xff); } #endif @@ -933,7 +900,6 @@ tvp7002_set_pad_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, /* V4L2 core operation handlers */ static const struct v4l2_subdev_core_ops tvp7002_core_ops = { - .g_chip_ident = tvp7002_g_chip_ident, .log_status = tvp7002_log_status, .g_ext_ctrls = v4l2_subdev_g_ext_ctrls, .try_ext_ctrls = v4l2_subdev_try_ext_ctrls, diff --git a/drivers/media/i2c/tw2804.c b/drivers/media/i2c/tw2804.c index 41a5c9b31006..f58607df6193 100644 --- a/drivers/media/i2c/tw2804.c +++ b/drivers/media/i2c/tw2804.c @@ -23,7 +23,6 @@ #include #include #include -#include #include #define TW2804_REG_AUTOGAIN 0x02 diff --git a/drivers/media/i2c/upd64031a.c b/drivers/media/i2c/upd64031a.c index 13a4cf8bebdf..d248e6a12b8e 100644 --- a/drivers/media/i2c/upd64031a.c +++ b/drivers/media/i2c/upd64031a.c @@ -27,7 +27,6 @@ #include #include #include -#include #include /* --------------------- read registers functions define -------------------- */ @@ -147,13 +146,6 @@ static int upd64031a_s_routing(struct v4l2_subdev *sd, return upd64031a_s_frequency(sd, NULL); } -static int upd64031a_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *chip) -{ - struct i2c_client *client = v4l2_get_subdevdata(sd); - - return v4l2_chip_ident_i2c_client(client, chip, V4L2_IDENT_UPD64031A, 0); -} - static int upd64031a_log_status(struct v4l2_subdev *sd) { v4l2_info(sd, "Status: SA00=0x%02x SA01=0x%02x\n", @@ -164,10 +156,6 @@ static int upd64031a_log_status(struct v4l2_subdev *sd) #ifdef CONFIG_VIDEO_ADV_DEBUG static int upd64031a_g_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg) { - struct i2c_client *client = v4l2_get_subdevdata(sd); - - if (!v4l2_chip_match_i2c_client(client, ®->match)) - return -EINVAL; reg->val = upd64031a_read(sd, reg->reg & 0xff); reg->size = 1; return 0; @@ -175,10 +163,6 @@ static int upd64031a_g_register(struct v4l2_subdev *sd, struct v4l2_dbg_register static int upd64031a_s_register(struct v4l2_subdev *sd, const struct v4l2_dbg_register *reg) { - struct i2c_client *client = v4l2_get_subdevdata(sd); - - if (!v4l2_chip_match_i2c_client(client, ®->match)) - return -EINVAL; upd64031a_write(sd, reg->reg & 0xff, reg->val & 0xff); return 0; } @@ -188,7 +172,6 @@ static int upd64031a_s_register(struct v4l2_subdev *sd, const struct v4l2_dbg_re static const struct v4l2_subdev_core_ops upd64031a_core_ops = { .log_status = upd64031a_log_status, - .g_chip_ident = upd64031a_g_chip_ident, #ifdef CONFIG_VIDEO_ADV_DEBUG .g_register = upd64031a_g_register, .s_register = upd64031a_s_register, diff --git a/drivers/media/i2c/upd64083.c b/drivers/media/i2c/upd64083.c index e296639ab90e..3a152ce7258a 100644 --- a/drivers/media/i2c/upd64083.c +++ b/drivers/media/i2c/upd64083.c @@ -27,7 +27,6 @@ #include #include #include -#include #include MODULE_DESCRIPTION("uPD64083 driver"); @@ -122,10 +121,6 @@ static int upd64083_s_routing(struct v4l2_subdev *sd, #ifdef CONFIG_VIDEO_ADV_DEBUG static int upd64083_g_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg) { - struct i2c_client *client = v4l2_get_subdevdata(sd); - - if (!v4l2_chip_match_i2c_client(client, ®->match)) - return -EINVAL; reg->val = upd64083_read(sd, reg->reg & 0xff); reg->size = 1; return 0; @@ -133,22 +128,11 @@ static int upd64083_g_register(struct v4l2_subdev *sd, struct v4l2_dbg_register static int upd64083_s_register(struct v4l2_subdev *sd, const struct v4l2_dbg_register *reg) { - struct i2c_client *client = v4l2_get_subdevdata(sd); - - if (!v4l2_chip_match_i2c_client(client, ®->match)) - return -EINVAL; upd64083_write(sd, reg->reg & 0xff, reg->val & 0xff); return 0; } #endif -static int upd64083_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *chip) -{ - struct i2c_client *client = v4l2_get_subdevdata(sd); - - return v4l2_chip_ident_i2c_client(client, chip, V4L2_IDENT_UPD64083, 0); -} - static int upd64083_log_status(struct v4l2_subdev *sd) { struct i2c_client *client = v4l2_get_subdevdata(sd); @@ -165,7 +149,6 @@ static int upd64083_log_status(struct v4l2_subdev *sd) static const struct v4l2_subdev_core_ops upd64083_core_ops = { .log_status = upd64083_log_status, - .g_chip_ident = upd64083_g_chip_ident, #ifdef CONFIG_VIDEO_ADV_DEBUG .g_register = upd64083_g_register, .s_register = upd64083_s_register, diff --git a/drivers/media/i2c/vp27smpx.c b/drivers/media/i2c/vp27smpx.c index 208a095d7bcc..6a3a3ff7ee6a 100644 --- a/drivers/media/i2c/vp27smpx.c +++ b/drivers/media/i2c/vp27smpx.c @@ -29,7 +29,6 @@ #include #include #include -#include MODULE_DESCRIPTION("vp27smpx driver"); MODULE_AUTHOR("Hans Verkuil"); @@ -112,13 +111,6 @@ static int vp27smpx_g_tuner(struct v4l2_subdev *sd, struct v4l2_tuner *vt) return 0; } -static int vp27smpx_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *chip) -{ - struct i2c_client *client = v4l2_get_subdevdata(sd); - - return v4l2_chip_ident_i2c_client(client, chip, V4L2_IDENT_VP27SMPX, 0); -} - static int vp27smpx_log_status(struct v4l2_subdev *sd) { struct vp27smpx_state *state = to_state(sd); @@ -132,7 +124,6 @@ static int vp27smpx_log_status(struct v4l2_subdev *sd) static const struct v4l2_subdev_core_ops vp27smpx_core_ops = { .log_status = vp27smpx_log_status, - .g_chip_ident = vp27smpx_g_chip_ident, .s_std = vp27smpx_s_std, }; diff --git a/drivers/media/i2c/vpx3220.c b/drivers/media/i2c/vpx3220.c index f02e74b9b1ac..4c57d8a67c22 100644 --- a/drivers/media/i2c/vpx3220.c +++ b/drivers/media/i2c/vpx3220.c @@ -27,7 +27,6 @@ #include #include #include -#include #include MODULE_DESCRIPTION("vpx3220a/vpx3216b/vpx3214c video decoder driver"); @@ -49,7 +48,6 @@ struct vpx3220 { unsigned char reg[255]; v4l2_std_id norm; - int ident; int input; int enable; }; @@ -442,14 +440,6 @@ static int vpx3220_s_ctrl(struct v4l2_ctrl *ctrl) return -EINVAL; } -static int vpx3220_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *chip) -{ - struct vpx3220 *decoder = to_vpx3220(sd); - struct i2c_client *client = v4l2_get_subdevdata(sd); - - return v4l2_chip_ident_i2c_client(client, chip, decoder->ident, 0); -} - /* ----------------------------------------------------------------------- */ static const struct v4l2_ctrl_ops vpx3220_ctrl_ops = { @@ -457,7 +447,6 @@ static const struct v4l2_ctrl_ops vpx3220_ctrl_ops = { }; static const struct v4l2_subdev_core_ops vpx3220_core_ops = { - .g_chip_ident = vpx3220_g_chip_ident, .init = vpx3220_init, .g_ext_ctrls = v4l2_subdev_g_ext_ctrls, .try_ext_ctrls = v4l2_subdev_try_ext_ctrls, @@ -528,7 +517,6 @@ static int vpx3220_probe(struct i2c_client *client, ver = i2c_smbus_read_byte_data(client, 0x00); pn = (i2c_smbus_read_byte_data(client, 0x02) << 8) + i2c_smbus_read_byte_data(client, 0x01); - decoder->ident = V4L2_IDENT_VPX3220A; if (ver == 0xec) { switch (pn) { case 0x4680: @@ -536,11 +524,9 @@ static int vpx3220_probe(struct i2c_client *client, break; case 0x4260: name = "vpx3216b"; - decoder->ident = V4L2_IDENT_VPX3216B; break; case 0x4280: name = "vpx3214c"; - decoder->ident = V4L2_IDENT_VPX3214C; break; } } diff --git a/drivers/media/i2c/vs6624.c b/drivers/media/i2c/vs6624.c index d2209a35c510..25bdd9312fea 100644 --- a/drivers/media/i2c/vs6624.c +++ b/drivers/media/i2c/vs6624.c @@ -27,7 +27,6 @@ #include #include -#include #include #include #include @@ -722,25 +721,9 @@ static int vs6624_s_stream(struct v4l2_subdev *sd, int enable) return 0; } -static int vs6624_g_chip_ident(struct v4l2_subdev *sd, - struct v4l2_dbg_chip_ident *chip) -{ - int rev; - struct i2c_client *client = v4l2_get_subdevdata(sd); - - rev = (vs6624_read(sd, VS6624_FW_VSN_MAJOR) << 8) - | vs6624_read(sd, VS6624_FW_VSN_MINOR); - - return v4l2_chip_ident_i2c_client(client, chip, V4L2_IDENT_VS6624, rev); -} - #ifdef CONFIG_VIDEO_ADV_DEBUG static int vs6624_g_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg) { - struct i2c_client *client = v4l2_get_subdevdata(sd); - - if (!v4l2_chip_match_i2c_client(client, ®->match)) - return -EINVAL; reg->val = vs6624_read(sd, reg->reg & 0xffff); reg->size = 1; return 0; @@ -748,10 +731,6 @@ static int vs6624_g_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *r static int vs6624_s_register(struct v4l2_subdev *sd, const struct v4l2_dbg_register *reg) { - struct i2c_client *client = v4l2_get_subdevdata(sd); - - if (!v4l2_chip_match_i2c_client(client, ®->match)) - return -EINVAL; vs6624_write(sd, reg->reg & 0xffff, reg->val & 0xff); return 0; } @@ -762,7 +741,6 @@ static const struct v4l2_ctrl_ops vs6624_ctrl_ops = { }; static const struct v4l2_subdev_core_ops vs6624_core_ops = { - .g_chip_ident = vs6624_g_chip_ident, #ifdef CONFIG_VIDEO_ADV_DEBUG .g_register = vs6624_g_register, .s_register = vs6624_s_register, diff --git a/drivers/media/i2c/wm8739.c b/drivers/media/i2c/wm8739.c index ac3faa7bab2d..3be73f6a40e9 100644 --- a/drivers/media/i2c/wm8739.c +++ b/drivers/media/i2c/wm8739.c @@ -29,7 +29,6 @@ #include #include #include -#include #include MODULE_DESCRIPTION("wm8739 driver"); @@ -160,13 +159,6 @@ static int wm8739_s_clock_freq(struct v4l2_subdev *sd, u32 audiofreq) return 0; } -static int wm8739_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *chip) -{ - struct i2c_client *client = v4l2_get_subdevdata(sd); - - return v4l2_chip_ident_i2c_client(client, chip, V4L2_IDENT_WM8739, 0); -} - static int wm8739_log_status(struct v4l2_subdev *sd) { struct wm8739_state *state = to_state(sd); @@ -184,7 +176,6 @@ static const struct v4l2_ctrl_ops wm8739_ctrl_ops = { static const struct v4l2_subdev_core_ops wm8739_core_ops = { .log_status = wm8739_log_status, - .g_chip_ident = wm8739_g_chip_ident, .g_ext_ctrls = v4l2_subdev_g_ext_ctrls, .try_ext_ctrls = v4l2_subdev_try_ext_ctrls, .s_ext_ctrls = v4l2_subdev_s_ext_ctrls, diff --git a/drivers/media/i2c/wm8775.c b/drivers/media/i2c/wm8775.c index 75ded82d513f..3f584a7d0781 100644 --- a/drivers/media/i2c/wm8775.c +++ b/drivers/media/i2c/wm8775.c @@ -33,7 +33,6 @@ #include #include #include -#include #include #include @@ -158,13 +157,6 @@ static int wm8775_s_ctrl(struct v4l2_ctrl *ctrl) return -EINVAL; } -static int wm8775_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *chip) -{ - struct i2c_client *client = v4l2_get_subdevdata(sd); - - return v4l2_chip_ident_i2c_client(client, chip, V4L2_IDENT_WM8775, 0); -} - static int wm8775_log_status(struct v4l2_subdev *sd) { struct wm8775_state *state = to_state(sd); @@ -188,7 +180,6 @@ static const struct v4l2_ctrl_ops wm8775_ctrl_ops = { static const struct v4l2_subdev_core_ops wm8775_core_ops = { .log_status = wm8775_log_status, - .g_chip_ident = wm8775_g_chip_ident, .g_ext_ctrls = v4l2_subdev_g_ext_ctrls, .try_ext_ctrls = v4l2_subdev_try_ext_ctrls, .s_ext_ctrls = v4l2_subdev_s_ext_ctrls, From 29d6a98b3381f5d94f56d4c0cd65a8cf7fb9419a Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Wed, 29 May 2013 06:59:52 -0300 Subject: [PATCH 0225/1048] [media] cx25840: remove the v4l2-chip-ident.h include Replace the V4L2_IDENT_ macros from v4l2-chip-ident.h with driver specific defines. Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/i2c/cx25840/cx25840-core.c | 50 ++++++++++++------------ drivers/media/i2c/cx25840/cx25840-core.h | 34 ++++++++++------ 2 files changed, 48 insertions(+), 36 deletions(-) diff --git a/drivers/media/i2c/cx25840/cx25840-core.c b/drivers/media/i2c/cx25840/cx25840-core.c index 6fbdad4fe054..2e3771d57354 100644 --- a/drivers/media/i2c/cx25840/cx25840-core.c +++ b/drivers/media/i2c/cx25840/cx25840-core.c @@ -497,7 +497,7 @@ static void cx23885_initialize(struct i2c_client *client) /* Sys PLL */ switch (state->id) { - case V4L2_IDENT_CX23888_AV: + case CX23888_AV: /* * 50.0 MHz * (0xb + 0xe8ba26/0x2000000)/4 = 5 * 28.636363 MHz * 572.73 MHz before post divide @@ -510,7 +510,7 @@ static void cx23885_initialize(struct i2c_client *client) cx25840_write4(client, 0x42c, 0x42600000); cx25840_write4(client, 0x44c, 0x161f1000); break; - case V4L2_IDENT_CX23887_AV: + case CX23887_AV: /* * 25.0 MHz * (0x16 + 0x1d1744c/0x2000000)/4 = 5 * 28.636363 MHz * 572.73 MHz before post divide @@ -518,7 +518,7 @@ static void cx23885_initialize(struct i2c_client *client) cx25840_write4(client, 0x11c, 0x01d1744c); cx25840_write4(client, 0x118, 0x00000416); break; - case V4L2_IDENT_CX23885_AV: + case CX23885_AV: default: /* * 28.636363 MHz * (0x14 + 0x0/0x2000000)/4 = 5 * 28.636363 MHz @@ -545,7 +545,7 @@ static void cx23885_initialize(struct i2c_client *client) /* HVR1850 */ switch (state->id) { - case V4L2_IDENT_CX23888_AV: + case CX23888_AV: /* 888/HVR1250 specific */ cx25840_write4(client, 0x10c, 0x13333333); cx25840_write4(client, 0x108, 0x00000515); @@ -569,7 +569,7 @@ static void cx23885_initialize(struct i2c_client *client) * 48 ksps, 16 bits/sample, x16 multiplier = 12.288 MHz */ switch (state->id) { - case V4L2_IDENT_CX23888_AV: + case CX23888_AV: /* * 50.0 MHz * (0x7 + 0x0bedfa4/0x2000000)/3 = 122.88 MHz * 368.64 MHz before post divide @@ -579,7 +579,7 @@ static void cx23885_initialize(struct i2c_client *client) cx25840_write4(client, 0x114, 0x017dbf48); cx25840_write4(client, 0x110, 0x000a030e); break; - case V4L2_IDENT_CX23887_AV: + case CX23887_AV: /* * 25.0 MHz * (0xe + 0x17dbf48/0x2000000)/3 = 122.88 MHz * 368.64 MHz before post divide @@ -588,7 +588,7 @@ static void cx23885_initialize(struct i2c_client *client) cx25840_write4(client, 0x114, 0x017dbf48); cx25840_write4(client, 0x110, 0x000a030e); break; - case V4L2_IDENT_CX23885_AV: + case CX23885_AV: default: /* * 28.636363 MHz * (0xc + 0x1bf0c9e/0x2000000)/3 = 122.88 MHz @@ -5110,18 +5110,18 @@ static u32 get_cx2388x_ident(struct i2c_client *client) ret = cx25840_read4(client, 0x300); if (((ret & 0xffff0000) >> 16) == (ret & 0xffff)) { /* No DIF */ - ret = V4L2_IDENT_CX23885_AV; + ret = CX23885_AV; } else { /* CX23887 has a broken DIF, but the registers * appear valid (but unused), good enough to detect. */ - ret = V4L2_IDENT_CX23887_AV; + ret = CX23887_AV; } } else if (cx25840_read4(client, 0x300) & 0x0fffffff) { /* DIF PLL Freq Word reg exists; chip must be a CX23888 */ - ret = V4L2_IDENT_CX23888_AV; + ret = CX23888_AV; } else { v4l_err(client, "Unable to detect h/w, assuming cx23887\n"); - ret = V4L2_IDENT_CX23887_AV; + ret = CX23887_AV; } /* Back into digital power down */ @@ -5135,7 +5135,7 @@ static int cx25840_probe(struct i2c_client *client, struct cx25840_state *state; struct v4l2_subdev *sd; int default_volume; - u32 id = V4L2_IDENT_NONE; + u32 id; u16 device_id; /* Check if the adapter supports the needed features */ @@ -5151,14 +5151,14 @@ static int cx25840_probe(struct i2c_client *client, /* The high byte of the device ID should be * 0x83 for the cx2583x and 0x84 for the cx2584x */ if ((device_id & 0xff00) == 0x8300) { - id = V4L2_IDENT_CX25836 + ((device_id >> 4) & 0xf) - 6; + id = CX25836 + ((device_id >> 4) & 0xf) - 6; } else if ((device_id & 0xff00) == 0x8400) { - id = V4L2_IDENT_CX25840 + ((device_id >> 4) & 0xf); + id = CX25840 + ((device_id >> 4) & 0xf); } else if (device_id == 0x0000) { id = get_cx2388x_ident(client); } else if ((device_id & 0xfff0) == 0x5A30) { /* The CX23100 (0x5A3C = 23100) doesn't have an A/V decoder */ - id = V4L2_IDENT_CX2310X_AV; + id = CX2310X_AV; } else if ((device_id & 0xff) == (device_id >> 8)) { v4l_err(client, "likely a confused/unresponsive cx2388[578] A/V decoder" @@ -5180,26 +5180,26 @@ static int cx25840_probe(struct i2c_client *client, v4l2_i2c_subdev_init(sd, client, &cx25840_ops); switch (id) { - case V4L2_IDENT_CX23885_AV: + case CX23885_AV: v4l_info(client, "cx23885 A/V decoder found @ 0x%x (%s)\n", client->addr << 1, client->adapter->name); break; - case V4L2_IDENT_CX23887_AV: + case CX23887_AV: v4l_info(client, "cx23887 A/V decoder found @ 0x%x (%s)\n", client->addr << 1, client->adapter->name); break; - case V4L2_IDENT_CX23888_AV: + case CX23888_AV: v4l_info(client, "cx23888 A/V decoder found @ 0x%x (%s)\n", client->addr << 1, client->adapter->name); break; - case V4L2_IDENT_CX2310X_AV: + case CX2310X_AV: v4l_info(client, "cx%d A/V decoder found @ 0x%x (%s)\n", device_id, client->addr << 1, client->adapter->name); break; - case V4L2_IDENT_CX25840: - case V4L2_IDENT_CX25841: - case V4L2_IDENT_CX25842: - case V4L2_IDENT_CX25843: + case CX25840: + case CX25841: + case CX25842: + case CX25843: /* Note: revision '(device_id & 0x0f) == 2' was never built. The marking skips from 0x1 == 22 to 0x3 == 23. */ v4l_info(client, "cx25%3x-2%x found @ 0x%x (%s)\n", @@ -5208,8 +5208,8 @@ static int cx25840_probe(struct i2c_client *client, : (device_id & 0x0f), client->addr << 1, client->adapter->name); break; - case V4L2_IDENT_CX25836: - case V4L2_IDENT_CX25837: + case CX25836: + case CX25837: default: v4l_info(client, "cx25%3x-%x found @ 0x%x (%s)\n", (device_id & 0xfff0) >> 4, device_id & 0x0f, diff --git a/drivers/media/i2c/cx25840/cx25840-core.h b/drivers/media/i2c/cx25840/cx25840-core.h index bd4ada28b490..37bc04217c44 100644 --- a/drivers/media/i2c/cx25840/cx25840-core.h +++ b/drivers/media/i2c/cx25840/cx25840-core.h @@ -23,12 +23,24 @@ #include #include -#include #include #include struct cx25840_ir_state; +enum cx25840_model { + CX23885_AV, + CX23887_AV, + CX23888_AV, + CX2310X_AV, + CX25840, + CX25841, + CX25842, + CX25843, + CX25836, + CX25837, +}; + struct cx25840_state { struct i2c_client *c; struct v4l2_subdev sd; @@ -46,7 +58,7 @@ struct cx25840_state { u32 audclk_freq; int audmode; int vbi_line_offset; - u32 id; + enum cx25840_model id; u32 rev; int is_initialized; wait_queue_head_t fw_wait; /* wake up when the fw load is finished */ @@ -66,35 +78,35 @@ static inline struct v4l2_subdev *to_sd(struct v4l2_ctrl *ctrl) static inline bool is_cx2583x(struct cx25840_state *state) { - return state->id == V4L2_IDENT_CX25836 || - state->id == V4L2_IDENT_CX25837; + return state->id == CX25836 || + state->id == CX25837; } static inline bool is_cx231xx(struct cx25840_state *state) { - return state->id == V4L2_IDENT_CX2310X_AV; + return state->id == CX2310X_AV; } static inline bool is_cx2388x(struct cx25840_state *state) { - return state->id == V4L2_IDENT_CX23885_AV || - state->id == V4L2_IDENT_CX23887_AV || - state->id == V4L2_IDENT_CX23888_AV; + return state->id == CX23885_AV || + state->id == CX23887_AV || + state->id == CX23888_AV; } static inline bool is_cx23885(struct cx25840_state *state) { - return state->id == V4L2_IDENT_CX23885_AV; + return state->id == CX23885_AV; } static inline bool is_cx23887(struct cx25840_state *state) { - return state->id == V4L2_IDENT_CX23887_AV; + return state->id == CX23887_AV; } static inline bool is_cx23888(struct cx25840_state *state) { - return state->id == V4L2_IDENT_CX23888_AV; + return state->id == CX23888_AV; } /* ----------------------------------------------------------------------- */ From b83007024219c0135aa18ca5e756b3935c3b8e31 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Wed, 29 May 2013 06:59:59 -0300 Subject: [PATCH 0226/1048] [media] saa7134: check register address in g_register Prevent reading out-of-range register values. Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/pci/saa7134/saa7134-video.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/media/pci/saa7134/saa7134-video.c b/drivers/media/pci/saa7134/saa7134-video.c index 737e643be27a..db4cc1c54aa6 100644 --- a/drivers/media/pci/saa7134/saa7134-video.c +++ b/drivers/media/pci/saa7134/saa7134-video.c @@ -2258,7 +2258,7 @@ static int vidioc_g_register (struct file *file, void *priv, struct saa7134_fh *fh = priv; struct saa7134_dev *dev = fh->dev; - reg->val = saa_readb(reg->reg); + reg->val = saa_readb(reg->reg & 0xffffff); reg->size = 1; return 0; } @@ -2269,7 +2269,7 @@ static int vidioc_s_register (struct file *file, void *priv, struct saa7134_fh *fh = priv; struct saa7134_dev *dev = fh->dev; - saa_writeb(reg->reg&0xffffff, reg->val); + saa_writeb(reg->reg & 0xffffff, reg->val); return 0; } #endif From d2cac168160aa7afd472d4a04d0da3f146243710 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Wed, 29 May 2013 07:00:00 -0300 Subject: [PATCH 0227/1048] [media] mxb: check register address when reading/writing a register Prevent out-of-range register accesses. Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/pci/saa7146/mxb.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/media/pci/saa7146/mxb.c b/drivers/media/pci/saa7146/mxb.c index 8d177691cd7c..33abe332d175 100644 --- a/drivers/media/pci/saa7146/mxb.c +++ b/drivers/media/pci/saa7146/mxb.c @@ -669,6 +669,8 @@ static int vidioc_g_register(struct file *file, void *fh, struct v4l2_dbg_regist { struct saa7146_dev *dev = ((struct saa7146_fh *)fh)->dev; + if (reg->reg > pci_resource_len(dev->pci, 0) - 4) + return -EINVAL; reg->val = saa7146_read(dev, reg->reg); reg->size = 4; return 0; @@ -678,6 +680,8 @@ static int vidioc_s_register(struct file *file, void *fh, const struct v4l2_dbg_ { struct saa7146_dev *dev = ((struct saa7146_fh *)fh)->dev; + if (reg->reg > pci_resource_len(dev->pci, 0) - 4) + return -EINVAL; saa7146_write(dev, reg->reg, reg->val); return 0; } From 9dd1d6f01750955ae5183f0da73606b314cc1a42 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Wed, 29 May 2013 07:00:01 -0300 Subject: [PATCH 0228/1048] [media] vpbe_display: drop g/s_register ioctls These are no longer needed: register access to subdevices no longer needs the bridge driver to forward them. Signed-off-by: Hans Verkuil Acked-by: Lad, Prabhakar Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/davinci/vpbe_display.c | 29 ------------------- 1 file changed, 29 deletions(-) diff --git a/drivers/media/platform/davinci/vpbe_display.c b/drivers/media/platform/davinci/vpbe_display.c index 1c4ba8965797..48cb0da3d2b3 100644 --- a/drivers/media/platform/davinci/vpbe_display.c +++ b/drivers/media/platform/davinci/vpbe_display.c @@ -1578,31 +1578,6 @@ static int vpbe_display_release(struct file *file) return 0; } -#ifdef CONFIG_VIDEO_ADV_DEBUG -static int vpbe_display_g_register(struct file *file, void *priv, - struct v4l2_dbg_register *reg) -{ - struct v4l2_dbg_match *match = ®->match; - struct vpbe_fh *fh = file->private_data; - struct vpbe_device *vpbe_dev = fh->disp_dev->vpbe_dev; - - if (match->type >= 2) { - v4l2_subdev_call(vpbe_dev->venc, - core, - g_register, - reg); - } - - return 0; -} - -static int vpbe_display_s_register(struct file *file, void *priv, - const struct v4l2_dbg_register *reg) -{ - return 0; -} -#endif - /* vpbe capture ioctl operations */ static const struct v4l2_ioctl_ops vpbe_ioctl_ops = { .vidioc_querycap = vpbe_display_querycap, @@ -1629,10 +1604,6 @@ static const struct v4l2_ioctl_ops vpbe_ioctl_ops = { .vidioc_s_dv_timings = vpbe_display_s_dv_timings, .vidioc_g_dv_timings = vpbe_display_g_dv_timings, .vidioc_enum_dv_timings = vpbe_display_enum_dv_timings, -#ifdef CONFIG_VIDEO_ADV_DEBUG - .vidioc_g_register = vpbe_display_g_register, - .vidioc_s_register = vpbe_display_s_register, -#endif }; static struct v4l2_file_operations vpbe_fops = { From 4e032f3f58800a998bae79150909410d7a37206f Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Wed, 29 May 2013 07:00:02 -0300 Subject: [PATCH 0229/1048] [media] marvell-ccic: check register address Prevent out-of-range register accesses. Signed-off-by: Hans Verkuil Cc: Jonathan Corbet Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/marvell-ccic/cafe-driver.c | 1 + drivers/media/platform/marvell-ccic/mcam-core.c | 4 ++++ drivers/media/platform/marvell-ccic/mcam-core.h | 1 + drivers/media/platform/marvell-ccic/mmp-driver.c | 1 + 4 files changed, 7 insertions(+) diff --git a/drivers/media/platform/marvell-ccic/cafe-driver.c b/drivers/media/platform/marvell-ccic/cafe-driver.c index 7b07fc55cd3c..1f079ff33d4b 100644 --- a/drivers/media/platform/marvell-ccic/cafe-driver.c +++ b/drivers/media/platform/marvell-ccic/cafe-driver.c @@ -500,6 +500,7 @@ static int cafe_pci_probe(struct pci_dev *pdev, printk(KERN_ERR "Unable to ioremap cafe-ccic regs\n"); goto out_disable; } + mcam->regs_size = pci_resource_len(pdev, 0); ret = request_irq(pdev->irq, cafe_irq, IRQF_SHARED, "cafe-ccic", cam); if (ret) goto out_iounmap; diff --git a/drivers/media/platform/marvell-ccic/mcam-core.c b/drivers/media/platform/marvell-ccic/mcam-core.c index a187161e980e..c69cfc4413fc 100644 --- a/drivers/media/platform/marvell-ccic/mcam-core.c +++ b/drivers/media/platform/marvell-ccic/mcam-core.c @@ -1404,6 +1404,8 @@ static int mcam_vidioc_g_register(struct file *file, void *priv, { struct mcam_camera *cam = priv; + if (reg->reg > cam->regs_size - 4) + return -EINVAL; reg->val = mcam_reg_read(cam, reg->reg); reg->size = 4; return 0; @@ -1414,6 +1416,8 @@ static int mcam_vidioc_s_register(struct file *file, void *priv, { struct mcam_camera *cam = priv; + if (reg->reg > cam->regs_size - 4) + return -EINVAL; mcam_reg_write(cam, reg->reg, reg->val); return 0; } diff --git a/drivers/media/platform/marvell-ccic/mcam-core.h b/drivers/media/platform/marvell-ccic/mcam-core.h index 46b6ea31e66b..520c8ded9443 100644 --- a/drivers/media/platform/marvell-ccic/mcam-core.h +++ b/drivers/media/platform/marvell-ccic/mcam-core.h @@ -101,6 +101,7 @@ struct mcam_camera { */ struct i2c_adapter *i2c_adapter; unsigned char __iomem *regs; + unsigned regs_size; /* size in bytes of the register space */ spinlock_t dev_lock; struct device *dev; /* For messages, dma alloc */ enum mcam_chip_id chip_id; diff --git a/drivers/media/platform/marvell-ccic/mmp-driver.c b/drivers/media/platform/marvell-ccic/mmp-driver.c index cadad647ce0e..a634888271cd 100644 --- a/drivers/media/platform/marvell-ccic/mmp-driver.c +++ b/drivers/media/platform/marvell-ccic/mmp-driver.c @@ -202,6 +202,7 @@ static int mmpcam_probe(struct platform_device *pdev) ret = -ENODEV; goto out_free; } + mcam->regs_size = resource_size(res); /* * Power/clock memory is elsewhere; get it too. Perhaps this * should really be managed outside of this driver? From ead5bc4e0bd94e4540bea60b782e2acdb345b803 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Wed, 29 May 2013 07:00:03 -0300 Subject: [PATCH 0230/1048] [media] au0828: set reg->size The size field wasn't filled in. Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/usb/au0828/au0828-video.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/media/usb/au0828/au0828-video.c b/drivers/media/usb/au0828/au0828-video.c index 4944a365570a..f6154546b5c0 100644 --- a/drivers/media/usb/au0828/au0828-video.c +++ b/drivers/media/usb/au0828/au0828-video.c @@ -1759,6 +1759,7 @@ static int vidioc_g_register(struct file *file, void *priv, struct au0828_dev *dev = fh->dev; reg->val = au0828_read(dev, reg->reg); + reg->size = 1; return 0; } From 04ae4cf2cb0c5963b0ea6554f573705c37172313 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Wed, 29 May 2013 07:00:04 -0300 Subject: [PATCH 0231/1048] [media] cx231xx: the reg->size field wasn't filled in Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/usb/cx231xx/cx231xx-video.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/media/usb/cx231xx/cx231xx-video.c b/drivers/media/usb/cx231xx/cx231xx-video.c index 54cdd4dc455e..990626101718 100644 --- a/drivers/media/usb/cx231xx/cx231xx-video.c +++ b/drivers/media/usb/cx231xx/cx231xx-video.c @@ -1272,36 +1272,43 @@ int cx231xx_g_register(struct file *file, void *priv, (u16)reg->reg, value, 4); reg->val = value[0] | value[1] << 8 | value[2] << 16 | value[3] << 24; + reg->size = 4; break; case 1: /* AFE - read byte */ ret = cx231xx_read_i2c_data(dev, AFE_DEVICE_ADDRESS, (u16)reg->reg, 2, &data, 1); reg->val = data; + reg->size = 1; break; case 2: /* Video Block - read byte */ ret = cx231xx_read_i2c_data(dev, VID_BLK_I2C_ADDRESS, (u16)reg->reg, 2, &data, 1); reg->val = data; + reg->size = 1; break; case 3: /* I2S block - read byte */ ret = cx231xx_read_i2c_data(dev, I2S_BLK_DEVICE_ADDRESS, (u16)reg->reg, 1, &data, 1); reg->val = data; + reg->size = 1; break; case 4: /* AFE - read dword */ ret = cx231xx_read_i2c_data(dev, AFE_DEVICE_ADDRESS, (u16)reg->reg, 2, &data, 4); reg->val = data; + reg->size = 4; break; case 5: /* Video Block - read dword */ ret = cx231xx_read_i2c_data(dev, VID_BLK_I2C_ADDRESS, (u16)reg->reg, 2, &data, 4); reg->val = data; + reg->size = 4; break; case 6: /* I2S Block - read dword */ ret = cx231xx_read_i2c_data(dev, I2S_BLK_DEVICE_ADDRESS, (u16)reg->reg, 1, &data, 4); reg->val = data; + reg->size = 4; break; default: return -EINVAL; From f82fadcfecb5d4aff0711d63fd321f7fabb0f2fa Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Wed, 29 May 2013 07:00:05 -0300 Subject: [PATCH 0232/1048] [media] sn9c20x: the reg->size field wasn't filled in Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/usb/gspca/sn9c20x.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/media/usb/gspca/sn9c20x.c b/drivers/media/usb/gspca/sn9c20x.c index 23b71f9f5942..f4453d52801b 100644 --- a/drivers/media/usb/gspca/sn9c20x.c +++ b/drivers/media/usb/gspca/sn9c20x.c @@ -1557,6 +1557,7 @@ static int sd_dbg_g_register(struct gspca_dev *gspca_dev, { struct sd *sd = (struct sd *) gspca_dev; + reg->size = 1; switch (reg->match.addr) { case 0: if (reg->reg < 0x1000 || reg->reg > 0x11ff) @@ -1568,6 +1569,7 @@ static int sd_dbg_g_register(struct gspca_dev *gspca_dev, if (sd->sensor >= SENSOR_MT9V011 && sd->sensor <= SENSOR_MT9M112) { i2c_r2(gspca_dev, reg->reg, (u16 *) ®->val); + reg->size = 2; } else { i2c_r1(gspca_dev, reg->reg, (u8 *) ®->val); } From 43aea90116c4fd80fd3d77b268b4a52ad8bf7bfb Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Wed, 29 May 2013 07:00:06 -0300 Subject: [PATCH 0233/1048] [media] pvrusb2: drop g/s_register ioctls Register access to subdevices no longer needs bridge support for those ioctls. The v4l2 core handles that these days. Signed-off-by: Hans Verkuil Cc: Mike Isely Signed-off-by: Mauro Carvalho Chehab --- drivers/media/usb/pvrusb2/pvrusb2-hdw.c | 36 ------------------------ drivers/media/usb/pvrusb2/pvrusb2-hdw.h | 9 ------ drivers/media/usb/pvrusb2/pvrusb2-v4l2.c | 34 ---------------------- 3 files changed, 79 deletions(-) diff --git a/drivers/media/usb/pvrusb2/pvrusb2-hdw.c b/drivers/media/usb/pvrusb2/pvrusb2-hdw.c index 01d1c2d47cb5..d32920929660 100644 --- a/drivers/media/usb/pvrusb2/pvrusb2-hdw.c +++ b/drivers/media/usb/pvrusb2/pvrusb2-hdw.c @@ -5162,39 +5162,3 @@ static int pvr2_hdw_get_eeprom_addr(struct pvr2_hdw *hdw) } while(0); LOCK_GIVE(hdw->ctl_lock); return result; } - - -int pvr2_hdw_register_access(struct pvr2_hdw *hdw, - const struct v4l2_dbg_match *match, u64 reg_id, - int setFl, u64 *val_ptr) -{ -#ifdef CONFIG_VIDEO_ADV_DEBUG - struct v4l2_dbg_register req; - int stat = 0; - int okFl = 0; - - req.match = *match; - req.reg = reg_id; - if (setFl) req.val = *val_ptr; - /* It would be nice to know if a sub-device answered the request */ - v4l2_device_call_all(&hdw->v4l2_dev, 0, core, g_register, &req); - if (!setFl) *val_ptr = req.val; - if (okFl) { - return stat; - } - return -EINVAL; -#else - return -ENOSYS; -#endif -} - - -/* - Stuff for Emacs to see, in order to encourage consistent editing style: - *** Local Variables: *** - *** mode: c *** - *** fill-column: 75 *** - *** tab-width: 8 *** - *** c-basic-offset: 8 *** - *** End: *** - */ diff --git a/drivers/media/usb/pvrusb2/pvrusb2-hdw.h b/drivers/media/usb/pvrusb2/pvrusb2-hdw.h index 91bae930cd79..1a135cf6ae4e 100644 --- a/drivers/media/usb/pvrusb2/pvrusb2-hdw.h +++ b/drivers/media/usb/pvrusb2/pvrusb2-hdw.h @@ -234,15 +234,6 @@ int pvr2_hdw_v4l_get_minor_number(struct pvr2_hdw *,enum pvr2_v4l_type index); void pvr2_hdw_v4l_store_minor_number(struct pvr2_hdw *, enum pvr2_v4l_type index,int); -/* Direct read/write access to chip's registers: - match - specify criteria to identify target chip (this is a v4l dbg struct) - reg_id - register number to access - setFl - true to set the register, false to read it - val_ptr - storage location for source / result. */ -int pvr2_hdw_register_access(struct pvr2_hdw *, - const struct v4l2_dbg_match *match, u64 reg_id, - int setFl, u64 *val_ptr); - /* The following entry points are all lower level things you normally don't want to worry about. */ diff --git a/drivers/media/usb/pvrusb2/pvrusb2-v4l2.c b/drivers/media/usb/pvrusb2/pvrusb2-v4l2.c index a8a65fa57930..82f619ba5cca 100644 --- a/drivers/media/usb/pvrusb2/pvrusb2-v4l2.c +++ b/drivers/media/usb/pvrusb2/pvrusb2-v4l2.c @@ -800,36 +800,6 @@ static int pvr2_log_status(struct file *file, void *priv) return 0; } -#ifdef CONFIG_VIDEO_ADV_DEBUG -static int pvr2_g_register(struct file *file, void *priv, struct v4l2_dbg_register *req) -{ - struct pvr2_v4l2_fh *fh = file->private_data; - struct pvr2_hdw *hdw = fh->channel.mc_head->hdw; - u64 val; - int ret; - - ret = pvr2_hdw_register_access( - hdw, &req->match, req->reg, - 0, &val); - req->val = val; - return ret; -} - -static int pvr2_s_register(struct file *file, void *priv, const struct v4l2_dbg_register *req) -{ - struct pvr2_v4l2_fh *fh = file->private_data; - struct pvr2_hdw *hdw = fh->channel.mc_head->hdw; - u64 val; - int ret; - - val = req->val; - ret = pvr2_hdw_register_access( - hdw, &req->match, req->reg, - 1, &val); - return ret; -} -#endif - static const struct v4l2_ioctl_ops pvr2_ioctl_ops = { .vidioc_querycap = pvr2_querycap, .vidioc_g_priority = pvr2_g_priority, @@ -864,10 +834,6 @@ static const struct v4l2_ioctl_ops pvr2_ioctl_ops = { .vidioc_g_ext_ctrls = pvr2_g_ext_ctrls, .vidioc_s_ext_ctrls = pvr2_s_ext_ctrls, .vidioc_try_ext_ctrls = pvr2_try_ext_ctrls, -#ifdef CONFIG_VIDEO_ADV_DEBUG - .vidioc_g_register = pvr2_g_register, - .vidioc_s_register = pvr2_s_register, -#endif }; static void pvr2_v4l2_dev_destroy(struct pvr2_v4l2_dev *dip) From 15c4fee344eb0b8a4d13a351220e337f2e929779 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Wed, 29 May 2013 07:00:07 -0300 Subject: [PATCH 0234/1048] [media] media/i2c: fill in missing reg->size fields Signed-off-by: Hans Verkuil Acked-by: Lad, Prabhakar Cc: Guennadi Liakhovetski Signed-off-by: Mauro Carvalho Chehab --- drivers/media/i2c/ak881x.c | 1 + drivers/media/i2c/soc_camera/mt9t031.c | 1 + drivers/media/i2c/soc_camera/tw9910.c | 1 + drivers/media/i2c/tvp7002.c | 1 + 4 files changed, 4 insertions(+) diff --git a/drivers/media/i2c/ak881x.c b/drivers/media/i2c/ak881x.c index fcd8a3f626fa..c14e66756b98 100644 --- a/drivers/media/i2c/ak881x.c +++ b/drivers/media/i2c/ak881x.c @@ -69,6 +69,7 @@ static int ak881x_g_register(struct v4l2_subdev *sd, if (reg->reg > 0x26) return -EINVAL; + reg->size = 1; reg->val = reg_read(client, reg->reg); if (reg->val > 0xffff) diff --git a/drivers/media/i2c/soc_camera/mt9t031.c b/drivers/media/i2c/soc_camera/mt9t031.c index 1d2cc27767fe..8f71c9a02cf0 100644 --- a/drivers/media/i2c/soc_camera/mt9t031.c +++ b/drivers/media/i2c/soc_camera/mt9t031.c @@ -398,6 +398,7 @@ static int mt9t031_g_register(struct v4l2_subdev *sd, if (reg->reg > 0xff) return -EINVAL; + reg->size = 1; reg->val = reg_read(client, reg->reg); if (reg->val > 0xffff) diff --git a/drivers/media/i2c/soc_camera/tw9910.c b/drivers/media/i2c/soc_camera/tw9910.c index 8a2ac244d0b3..b5407dfad4ce 100644 --- a/drivers/media/i2c/soc_camera/tw9910.c +++ b/drivers/media/i2c/soc_camera/tw9910.c @@ -527,6 +527,7 @@ static int tw9910_g_register(struct v4l2_subdev *sd, if (reg->reg > 0xff) return -EINVAL; + reg->size = 1; ret = i2c_smbus_read_byte_data(client, reg->reg); if (ret < 0) return ret; diff --git a/drivers/media/i2c/tvp7002.c b/drivers/media/i2c/tvp7002.c index c2d0280ef3dc..36ad565e5a33 100644 --- a/drivers/media/i2c/tvp7002.c +++ b/drivers/media/i2c/tvp7002.c @@ -722,6 +722,7 @@ static int tvp7002_g_register(struct v4l2_subdev *sd, ret = tvp7002_read(sd, reg->reg & 0xff, &val); reg->val = val; + reg->size = 1; return ret; } From 771d77339b0f7a236d1fc0ef414469b4282b47a9 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Wed, 29 May 2013 07:00:08 -0300 Subject: [PATCH 0235/1048] [media] cx18: fix register range check Ensure that the register is aligned to a dword, otherwise the range check could fail since it assumes dword alignment. Signed-off-by: Hans Verkuil Cc: Andy Walls Signed-off-by: Mauro Carvalho Chehab --- drivers/media/pci/cx18/cx18-ioctl.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/media/pci/cx18/cx18-ioctl.c b/drivers/media/pci/cx18/cx18-ioctl.c index 414b0ecccc91..1110bcb14e2f 100644 --- a/drivers/media/pci/cx18/cx18-ioctl.c +++ b/drivers/media/pci/cx18/cx18-ioctl.c @@ -367,6 +367,8 @@ static int cx18_g_register(struct file *file, void *fh, { struct cx18 *cx = fh2id(fh)->cx; + if (reg->reg & 0x3) + return -EINVAL; if (reg->reg >= CX18_MEM_OFFSET + CX18_MEM_SIZE) return -EINVAL; reg->size = 4; @@ -379,6 +381,8 @@ static int cx18_s_register(struct file *file, void *fh, { struct cx18 *cx = fh2id(fh)->cx; + if (reg->reg & 0x3) + return -EINVAL; if (reg->reg >= CX18_MEM_OFFSET + CX18_MEM_SIZE) return -EINVAL; cx18_write_enc(cx, reg->val, reg->reg); From e9dab5897066aa979db5de02d0751db9734bbf71 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Wed, 29 May 2013 07:00:10 -0300 Subject: [PATCH 0236/1048] [media] ivtv: fix register range check Ensure that the register is aligned to a dword, otherwise the range check could fail since it assumes dword alignment. Signed-off-by: Hans Verkuil Cc: Andy Walls Signed-off-by: Mauro Carvalho Chehab --- drivers/media/pci/ivtv/ivtv-ioctl.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/media/pci/ivtv/ivtv-ioctl.c b/drivers/media/pci/ivtv/ivtv-ioctl.c index 944300f7c60b..807b275a847e 100644 --- a/drivers/media/pci/ivtv/ivtv-ioctl.c +++ b/drivers/media/pci/ivtv/ivtv-ioctl.c @@ -696,6 +696,8 @@ static int ivtv_itvc(struct ivtv *itv, bool get, u64 reg, u64 *val) { volatile u8 __iomem *reg_start; + if (reg & 0x3) + return -EINVAL; if (reg >= IVTV_REG_OFFSET && reg < IVTV_REG_OFFSET + IVTV_REG_SIZE) reg_start = itv->reg_mem - IVTV_REG_OFFSET; else if (itv->has_cx23415 && reg >= IVTV_DECODER_OFFSET && From abbec2d401d6698db44e632f5adbef2a47e6e812 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Wed, 29 May 2013 07:00:11 -0300 Subject: [PATCH 0237/1048] [media] DocBook/media/v4l: update VIDIOC_DBG_ documentation - Remove the "On failure the structure remains unchanged." part since that isn't necessarily true. - Document the 'size' field. Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- .../DocBook/media/v4l/vidioc-dbg-g-chip-info.xml | 3 +-- .../DocBook/media/v4l/vidioc-dbg-g-register.xml | 15 ++++++++++----- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/Documentation/DocBook/media/v4l/vidioc-dbg-g-chip-info.xml b/Documentation/DocBook/media/v4l/vidioc-dbg-g-chip-info.xml index e1cece6c5de1..80e8021369f6 100644 --- a/Documentation/DocBook/media/v4l/vidioc-dbg-g-chip-info.xml +++ b/Documentation/DocBook/media/v4l/vidioc-dbg-g-chip-info.xml @@ -73,8 +73,7 @@ fields of a &v4l2-dbg-chip-info; and call VIDIOC_DBG_G_CHIP_INFO with a pointer to this structure. On success the driver stores information about the selected chip in the name and -flags fields. On failure the structure -remains unchanged. +flags fields. When match.type is V4L2_CHIP_MATCH_BRIDGE, diff --git a/Documentation/DocBook/media/v4l/vidioc-dbg-g-register.xml b/Documentation/DocBook/media/v4l/vidioc-dbg-g-register.xml index d13bac9e2445..e23285fad3bf 100644 --- a/Documentation/DocBook/media/v4l/vidioc-dbg-g-register.xml +++ b/Documentation/DocBook/media/v4l/vidioc-dbg-g-register.xml @@ -76,7 +76,7 @@ compiled with the CONFIG_VIDEO_ADV_DEBUG option to enable these ioctls. To write a register applications must initialize all fields -of a &v4l2-dbg-register; and call +of a &v4l2-dbg-register; except for size and call VIDIOC_DBG_S_REGISTER with a pointer to this structure. The match.type and match.addr or match.name @@ -91,8 +91,8 @@ written into the register. reg fields, and call VIDIOC_DBG_G_REGISTER with a pointer to this structure. On success the driver stores the register value in the -val field. On failure the structure remains -unchanged. +val field and the size (in bytes) of the +value in size. When match.type is V4L2_CHIP_MATCH_BRIDGE, @@ -150,7 +150,7 @@ LinuxTV v4l-dvb repository; see http://linuxtv.org/repo/ for access instructions. - struct <structname>v4l2_dbg_match</structname> @@ -198,6 +198,11 @@ to the type field.matchHow to match the chip, see . + + __u32 + size + The register size in bytes. + __u64 reg @@ -213,7 +218,7 @@ register.
- Chip Match Types From 2249aa5c97a017be4e3b5bb0e9a3ca2d2ed31b27 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Wed, 29 May 2013 07:59:57 -0300 Subject: [PATCH 0238/1048] [media] v4l2-framework: replace g_chip_ident by g_std in the examples The framework documentation used the g_chip_ident op as an example. This op has been removed, so replace its use in the examples by the g_std op. Signed-off-by: Hans Verkuil Cc: Mauro Carvalho Chehab Signed-off-by: Mauro Carvalho Chehab --- Documentation/video4linux/v4l2-framework.txt | 13 ++++++------- Documentation/zh_CN/video4linux/v4l2-framework.txt | 13 ++++++------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/Documentation/video4linux/v4l2-framework.txt b/Documentation/video4linux/v4l2-framework.txt index a300b283a1a0..24353ecab197 100644 --- a/Documentation/video4linux/v4l2-framework.txt +++ b/Documentation/video4linux/v4l2-framework.txt @@ -246,7 +246,6 @@ may be NULL if the subdev driver does not support anything from that category. It looks like this: struct v4l2_subdev_core_ops { - int (*g_chip_ident)(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *chip); int (*log_status)(struct v4l2_subdev *sd); int (*init)(struct v4l2_subdev *sd, u32 val); ... @@ -346,24 +345,24 @@ Afterwards the subdev module can be unloaded and sd->dev == NULL. You can call an ops function either directly: - err = sd->ops->core->g_chip_ident(sd, &chip); + err = sd->ops->core->g_std(sd, &norm); but it is better and easier to use this macro: - err = v4l2_subdev_call(sd, core, g_chip_ident, &chip); + err = v4l2_subdev_call(sd, core, g_std, &norm); The macro will to the right NULL pointer checks and returns -ENODEV if subdev -is NULL, -ENOIOCTLCMD if either subdev->core or subdev->core->g_chip_ident is -NULL, or the actual result of the subdev->ops->core->g_chip_ident ops. +is NULL, -ENOIOCTLCMD if either subdev->core or subdev->core->g_std is +NULL, or the actual result of the subdev->ops->core->g_std ops. It is also possible to call all or a subset of the sub-devices: - v4l2_device_call_all(v4l2_dev, 0, core, g_chip_ident, &chip); + v4l2_device_call_all(v4l2_dev, 0, core, g_std, &norm); Any subdev that does not support this ops is skipped and error results are ignored. If you want to check for errors use this: - err = v4l2_device_call_until_err(v4l2_dev, 0, core, g_chip_ident, &chip); + err = v4l2_device_call_until_err(v4l2_dev, 0, core, g_std, &norm); Any error except -ENOIOCTLCMD will exit the loop with that error. If no errors (except -ENOIOCTLCMD) occurred, then 0 is returned. diff --git a/Documentation/zh_CN/video4linux/v4l2-framework.txt b/Documentation/zh_CN/video4linux/v4l2-framework.txt index 44c1d934c4e3..0da95dbaef34 100644 --- a/Documentation/zh_CN/video4linux/v4l2-framework.txt +++ b/Documentation/zh_CN/video4linux/v4l2-framework.txt @@ -247,7 +247,6 @@ i2c_client 结构体,i2c_set_clientdata() 函数可用于保存一个 v4l2_sub 这些结构体定义如下: struct v4l2_subdev_core_ops { - int (*g_chip_ident)(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *chip); int (*log_status)(struct v4l2_subdev *sd); int (*init)(struct v4l2_subdev *sd, u32 val); ... @@ -337,24 +336,24 @@ subdev->dev 域就指向了 v4l2_device。 注册之设备后,可通过以下方式直接调用其操作函数: - err = sd->ops->core->g_chip_ident(sd, &chip); + err = sd->ops->core->g_std(sd, &norm); 但使用如下宏会比较容易且合适: - err = v4l2_subdev_call(sd, core, g_chip_ident, &chip); + err = v4l2_subdev_call(sd, core, g_std, &norm); 这个宏将会做 NULL 指针检查,如果 subdev 为 NULL,则返回-ENODEV;如果 -subdev->core 或 subdev->core->g_chip_ident 为 NULL,则返回 -ENOIOCTLCMD; -否则将返回 subdev->ops->core->g_chip_ident ops 调用的实际结果。 +subdev->core 或 subdev->core->g_std 为 NULL,则返回 -ENOIOCTLCMD; +否则将返回 subdev->ops->core->g_std ops 调用的实际结果。 有时也可能同时调用所有或一系列子设备的某个操作函数: - v4l2_device_call_all(v4l2_dev, 0, core, g_chip_ident, &chip); + v4l2_device_call_all(v4l2_dev, 0, core, g_std, &norm); 任何不支持此操作的子设备都会被跳过,并忽略错误返回值。但如果你需要 检查出错码,则可使用如下函数: - err = v4l2_device_call_until_err(v4l2_dev, 0, core, g_chip_ident, &chip); + err = v4l2_device_call_until_err(v4l2_dev, 0, core, g_std, &norm); 除 -ENOIOCTLCMD 外的任何错误都会跳出循环并返回错误值。如果(除 -ENOIOCTLCMD 外)没有错误发生,则返回 0。 From 8ff618320ce304cf96d84dcacd606d3b7f82c78d Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Mon, 10 Jun 2013 04:50:11 -0300 Subject: [PATCH 0239/1048] [media] saa7706h: convert to the control framework MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Hans Verkuil Cc: Richard Röjfors Signed-off-by: Mauro Carvalho Chehab --- drivers/media/radio/saa7706h.c | 56 ++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 27 deletions(-) diff --git a/drivers/media/radio/saa7706h.c b/drivers/media/radio/saa7706h.c index d1f30d6762d3..ec805b09c608 100644 --- a/drivers/media/radio/saa7706h.c +++ b/drivers/media/radio/saa7706h.c @@ -25,6 +25,7 @@ #include #include #include +#include #define DRIVER_NAME "saa7706h" @@ -126,6 +127,7 @@ struct saa7706h_state { struct v4l2_subdev sd; + struct v4l2_ctrl_handler hdl; unsigned muted; }; @@ -316,42 +318,32 @@ static int saa7706h_mute(struct v4l2_subdev *sd) return err; } -static int saa7706h_queryctrl(struct v4l2_subdev *sd, struct v4l2_queryctrl *qc) +static int saa7706h_s_ctrl(struct v4l2_ctrl *ctrl) { - switch (qc->id) { - case V4L2_CID_AUDIO_MUTE: - return v4l2_ctrl_query_fill(qc, 0, 1, 1, 1); - } - return -EINVAL; -} - -static int saa7706h_g_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl) -{ - struct saa7706h_state *state = to_state(sd); + struct saa7706h_state *state = + container_of(ctrl->handler, struct saa7706h_state, hdl); switch (ctrl->id) { case V4L2_CID_AUDIO_MUTE: - ctrl->value = state->muted; - return 0; + if (ctrl->val) + return saa7706h_mute(&state->sd); + return saa7706h_unmute(&state->sd); } return -EINVAL; } -static int saa7706h_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl) -{ - switch (ctrl->id) { - case V4L2_CID_AUDIO_MUTE: - if (ctrl->value) - return saa7706h_mute(sd); - return saa7706h_unmute(sd); - } - return -EINVAL; -} +static const struct v4l2_ctrl_ops saa7706h_ctrl_ops = { + .s_ctrl = saa7706h_s_ctrl, +}; static const struct v4l2_subdev_core_ops saa7706h_core_ops = { - .queryctrl = saa7706h_queryctrl, - .g_ctrl = saa7706h_g_ctrl, - .s_ctrl = saa7706h_s_ctrl, + .g_ext_ctrls = v4l2_subdev_g_ext_ctrls, + .try_ext_ctrls = v4l2_subdev_try_ext_ctrls, + .s_ext_ctrls = v4l2_subdev_s_ext_ctrls, + .g_ctrl = v4l2_subdev_g_ctrl, + .s_ctrl = v4l2_subdev_s_ctrl, + .queryctrl = v4l2_subdev_queryctrl, + .querymenu = v4l2_subdev_querymenu, }; static const struct v4l2_subdev_ops saa7706h_ops = { @@ -383,13 +375,20 @@ static int saa7706h_probe(struct i2c_client *client, sd = &state->sd; v4l2_i2c_subdev_init(sd, client, &saa7706h_ops); + v4l2_ctrl_handler_init(&state->hdl, 4); + v4l2_ctrl_new_std(&state->hdl, &saa7706h_ctrl_ops, + V4L2_CID_AUDIO_MUTE, 0, 1, 1, 1); + sd->ctrl_handler = &state->hdl; + err = state->hdl.error; + if (err) + goto err; + /* check the rom versions */ err = saa7706h_get_reg16(sd, SAA7706H_DSP1_ROM_VER); if (err < 0) goto err; if (err != SUPPORTED_DSP1_ROM_VER) v4l2_warn(sd, "Unknown DSP1 ROM code version: 0x%x\n", err); - state->muted = 1; /* startup in a muted state */ @@ -401,6 +400,7 @@ static int saa7706h_probe(struct i2c_client *client, err: v4l2_device_unregister_subdev(sd); + v4l2_ctrl_handler_free(&state->hdl); kfree(to_state(sd)); printk(KERN_ERR DRIVER_NAME ": Failed to probe: %d\n", err); @@ -411,9 +411,11 @@ err: static int saa7706h_remove(struct i2c_client *client) { struct v4l2_subdev *sd = i2c_get_clientdata(client); + struct saa7706h_state *state = to_state(sd); saa7706h_mute(sd); v4l2_device_unregister_subdev(sd); + v4l2_ctrl_handler_free(&state->hdl); kfree(to_state(sd)); return 0; } From 04de560296158c481570a020748d1239e493617b Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Fri, 31 May 2013 06:17:42 -0300 Subject: [PATCH 0240/1048] [media] sr030pc30: convert to the control framework Signed-off-by: Hans Verkuil Acked-by: Sylwester Nawrocki Signed-off-by: Mauro Carvalho Chehab --- drivers/media/i2c/sr030pc30.c | 276 +++++++++++----------------------- 1 file changed, 88 insertions(+), 188 deletions(-) diff --git a/drivers/media/i2c/sr030pc30.c b/drivers/media/i2c/sr030pc30.c index 4c5a9ee60c3e..ae9432637fcb 100644 --- a/drivers/media/i2c/sr030pc30.c +++ b/drivers/media/i2c/sr030pc30.c @@ -23,6 +23,7 @@ #include #include #include +#include #include static int debug; @@ -142,17 +143,24 @@ module_param(debug, int, 0644); struct sr030pc30_info { struct v4l2_subdev sd; + struct v4l2_ctrl_handler hdl; const struct sr030pc30_platform_data *pdata; const struct sr030pc30_format *curr_fmt; const struct sr030pc30_frmsize *curr_win; - unsigned int auto_wb:1; - unsigned int auto_exp:1; unsigned int hflip:1; unsigned int vflip:1; unsigned int sleep:1; - unsigned int exposure; - u8 blue_balance; - u8 red_balance; + struct { + /* auto whitebalance control cluster */ + struct v4l2_ctrl *awb; + struct v4l2_ctrl *red; + struct v4l2_ctrl *blue; + }; + struct { + /* auto exposure control cluster */ + struct v4l2_ctrl *autoexp; + struct v4l2_ctrl *exp; + }; u8 i2c_reg_page; }; @@ -173,52 +181,6 @@ struct i2c_regval { u16 val; }; -static const struct v4l2_queryctrl sr030pc30_ctrl[] = { - { - .id = V4L2_CID_AUTO_WHITE_BALANCE, - .type = V4L2_CTRL_TYPE_BOOLEAN, - .name = "Auto White Balance", - .minimum = 0, - .maximum = 1, - .step = 1, - .default_value = 1, - }, { - .id = V4L2_CID_RED_BALANCE, - .type = V4L2_CTRL_TYPE_INTEGER, - .name = "Red Balance", - .minimum = 0, - .maximum = 127, - .step = 1, - .default_value = 64, - .flags = 0, - }, { - .id = V4L2_CID_BLUE_BALANCE, - .type = V4L2_CTRL_TYPE_INTEGER, - .name = "Blue Balance", - .minimum = 0, - .maximum = 127, - .step = 1, - .default_value = 64, - }, { - .id = V4L2_CID_EXPOSURE_AUTO, - .type = V4L2_CTRL_TYPE_INTEGER, - .name = "Auto Exposure", - .minimum = 0, - .maximum = 1, - .step = 1, - .default_value = 1, - }, { - .id = V4L2_CID_EXPOSURE, - .type = V4L2_CTRL_TYPE_INTEGER, - .name = "Exposure", - .minimum = EXPOS_MIN_MS, - .maximum = EXPOS_MAX_MS, - .step = 1, - .default_value = 1, - }, { - } -}; - /* supported resolutions */ static const struct sr030pc30_frmsize sr030pc30_sizes[] = { { @@ -394,48 +356,6 @@ static int sr030pc30_pwr_ctrl(struct v4l2_subdev *sd, return ret; } -static inline int sr030pc30_enable_autoexposure(struct v4l2_subdev *sd, int on) -{ - struct sr030pc30_info *info = to_sr030pc30(sd); - /* auto anti-flicker is also enabled here */ - int ret = cam_i2c_write(sd, AE_CTL1_REG, on ? 0xDC : 0x0C); - if (!ret) - info->auto_exp = on; - return ret; -} - -static int sr030pc30_set_exposure(struct v4l2_subdev *sd, int value) -{ - struct sr030pc30_info *info = to_sr030pc30(sd); - - unsigned long expos = value * info->pdata->clk_rate / (8 * 1000); - - int ret = cam_i2c_write(sd, EXP_TIMEH_REG, expos >> 16 & 0xFF); - if (!ret) - ret = cam_i2c_write(sd, EXP_TIMEM_REG, expos >> 8 & 0xFF); - if (!ret) - ret = cam_i2c_write(sd, EXP_TIMEL_REG, expos & 0xFF); - if (!ret) { /* Turn off AE */ - info->exposure = value; - ret = sr030pc30_enable_autoexposure(sd, 0); - } - return ret; -} - -/* Automatic white balance control */ -static int sr030pc30_enable_autowhitebalance(struct v4l2_subdev *sd, int on) -{ - struct sr030pc30_info *info = to_sr030pc30(sd); - - int ret = cam_i2c_write(sd, AWB_CTL2_REG, on ? 0x2E : 0x2F); - if (!ret) - ret = cam_i2c_write(sd, AWB_CTL1_REG, on ? 0xFB : 0x7B); - if (!ret) - info->auto_wb = on; - - return ret; -} - static int sr030pc30_set_flip(struct v4l2_subdev *sd) { struct sr030pc30_info *info = to_sr030pc30(sd); @@ -498,107 +418,56 @@ static int sr030pc30_try_frame_size(struct v4l2_mbus_framefmt *mf) return -EINVAL; } -static int sr030pc30_queryctrl(struct v4l2_subdev *sd, - struct v4l2_queryctrl *qc) +static int sr030pc30_s_ctrl(struct v4l2_ctrl *ctrl) { - int i; - - for (i = 0; i < ARRAY_SIZE(sr030pc30_ctrl); i++) - if (qc->id == sr030pc30_ctrl[i].id) { - *qc = sr030pc30_ctrl[i]; - v4l2_dbg(1, debug, sd, "%s id: %d\n", - __func__, qc->id); - return 0; - } - - return -EINVAL; -} - -static inline int sr030pc30_set_bluebalance(struct v4l2_subdev *sd, int value) -{ - int ret = cam_i2c_write(sd, MWB_BGAIN_REG, value); - if (!ret) - to_sr030pc30(sd)->blue_balance = value; - return ret; -} - -static inline int sr030pc30_set_redbalance(struct v4l2_subdev *sd, int value) -{ - int ret = cam_i2c_write(sd, MWB_RGAIN_REG, value); - if (!ret) - to_sr030pc30(sd)->red_balance = value; - return ret; -} - -static int sr030pc30_s_ctrl(struct v4l2_subdev *sd, - struct v4l2_control *ctrl) -{ - int i, ret = 0; - - for (i = 0; i < ARRAY_SIZE(sr030pc30_ctrl); i++) - if (ctrl->id == sr030pc30_ctrl[i].id) - break; - - if (i == ARRAY_SIZE(sr030pc30_ctrl)) - return -EINVAL; - - if (ctrl->value < sr030pc30_ctrl[i].minimum || - ctrl->value > sr030pc30_ctrl[i].maximum) - return -ERANGE; + struct sr030pc30_info *info = + container_of(ctrl->handler, struct sr030pc30_info, hdl); + struct v4l2_subdev *sd = &info->sd; + int ret = 0; v4l2_dbg(1, debug, sd, "%s: ctrl_id: %d, value: %d\n", - __func__, ctrl->id, ctrl->value); + __func__, ctrl->id, ctrl->val); switch (ctrl->id) { case V4L2_CID_AUTO_WHITE_BALANCE: - sr030pc30_enable_autowhitebalance(sd, ctrl->value); - break; - case V4L2_CID_BLUE_BALANCE: - ret = sr030pc30_set_bluebalance(sd, ctrl->value); - break; - case V4L2_CID_RED_BALANCE: - ret = sr030pc30_set_redbalance(sd, ctrl->value); - break; + if (ctrl->is_new) { + ret = cam_i2c_write(sd, AWB_CTL2_REG, + ctrl->val ? 0x2E : 0x2F); + if (!ret) + ret = cam_i2c_write(sd, AWB_CTL1_REG, + ctrl->val ? 0xFB : 0x7B); + } + if (!ret && info->blue->is_new) + ret = cam_i2c_write(sd, MWB_BGAIN_REG, info->blue->val); + if (!ret && info->red->is_new) + ret = cam_i2c_write(sd, MWB_RGAIN_REG, info->red->val); + return ret; + case V4L2_CID_EXPOSURE_AUTO: - sr030pc30_enable_autoexposure(sd, - ctrl->value == V4L2_EXPOSURE_AUTO); - break; - case V4L2_CID_EXPOSURE: - ret = sr030pc30_set_exposure(sd, ctrl->value); - break; + /* auto anti-flicker is also enabled here */ + if (ctrl->is_new) + ret = cam_i2c_write(sd, AE_CTL1_REG, + ctrl->val == V4L2_EXPOSURE_AUTO ? 0xDC : 0x0C); + if (info->exp->is_new) { + unsigned long expos = info->exp->val; + + expos = expos * info->pdata->clk_rate / (8 * 1000); + + if (!ret) + ret = cam_i2c_write(sd, EXP_TIMEH_REG, + expos >> 16 & 0xFF); + if (!ret) + ret = cam_i2c_write(sd, EXP_TIMEM_REG, + expos >> 8 & 0xFF); + if (!ret) + ret = cam_i2c_write(sd, EXP_TIMEL_REG, + expos & 0xFF); + } + return ret; default: return -EINVAL; } - return ret; -} - -static int sr030pc30_g_ctrl(struct v4l2_subdev *sd, - struct v4l2_control *ctrl) -{ - struct sr030pc30_info *info = to_sr030pc30(sd); - - v4l2_dbg(1, debug, sd, "%s: id: %d\n", __func__, ctrl->id); - - switch (ctrl->id) { - case V4L2_CID_AUTO_WHITE_BALANCE: - ctrl->value = info->auto_wb; - break; - case V4L2_CID_BLUE_BALANCE: - ctrl->value = info->blue_balance; - break; - case V4L2_CID_RED_BALANCE: - ctrl->value = info->red_balance; - break; - case V4L2_CID_EXPOSURE_AUTO: - ctrl->value = info->auto_exp; - break; - case V4L2_CID_EXPOSURE: - ctrl->value = info->exposure; - break; - default: - return -EINVAL; - } return 0; } @@ -752,11 +621,19 @@ static int sr030pc30_s_power(struct v4l2_subdev *sd, int on) return ret; } +static const struct v4l2_ctrl_ops sr030pc30_ctrl_ops = { + .s_ctrl = sr030pc30_s_ctrl, +}; + static const struct v4l2_subdev_core_ops sr030pc30_core_ops = { .s_power = sr030pc30_s_power, - .queryctrl = sr030pc30_queryctrl, - .s_ctrl = sr030pc30_s_ctrl, - .g_ctrl = sr030pc30_g_ctrl, + .g_ext_ctrls = v4l2_subdev_g_ext_ctrls, + .try_ext_ctrls = v4l2_subdev_try_ext_ctrls, + .s_ext_ctrls = v4l2_subdev_s_ext_ctrls, + .g_ctrl = v4l2_subdev_g_ctrl, + .s_ctrl = v4l2_subdev_s_ctrl, + .queryctrl = v4l2_subdev_queryctrl, + .querymenu = v4l2_subdev_querymenu, }; static const struct v4l2_subdev_video_ops sr030pc30_video_ops = { @@ -807,6 +684,7 @@ static int sr030pc30_probe(struct i2c_client *client, { struct sr030pc30_info *info; struct v4l2_subdev *sd; + struct v4l2_ctrl_handler *hdl; const struct sr030pc30_platform_data *pdata = client->dev.platform_data; int ret; @@ -830,10 +708,31 @@ static int sr030pc30_probe(struct i2c_client *client, v4l2_i2c_subdev_init(sd, client, &sr030pc30_ops); + hdl = &info->hdl; + v4l2_ctrl_handler_init(hdl, 6); + info->awb = v4l2_ctrl_new_std(hdl, &sr030pc30_ctrl_ops, + V4L2_CID_AUTO_WHITE_BALANCE, 0, 1, 1, 1); + info->red = v4l2_ctrl_new_std(hdl, &sr030pc30_ctrl_ops, + V4L2_CID_RED_BALANCE, 0, 127, 1, 64); + info->blue = v4l2_ctrl_new_std(hdl, &sr030pc30_ctrl_ops, + V4L2_CID_BLUE_BALANCE, 0, 127, 1, 64); + info->autoexp = v4l2_ctrl_new_std(hdl, &sr030pc30_ctrl_ops, + V4L2_CID_EXPOSURE_AUTO, 0, 1, 1, 1); + info->exp = v4l2_ctrl_new_std(hdl, &sr030pc30_ctrl_ops, + V4L2_CID_EXPOSURE, EXPOS_MIN_MS, EXPOS_MAX_MS, 1, 30); + sd->ctrl_handler = hdl; + if (hdl->error) { + int err = hdl->error; + + v4l2_ctrl_handler_free(hdl); + return err; + } + v4l2_ctrl_auto_cluster(3, &info->awb, 0, false); + v4l2_ctrl_auto_cluster(2, &info->autoexp, V4L2_EXPOSURE_MANUAL, false); + v4l2_ctrl_handler_setup(hdl); + info->i2c_reg_page = -1; info->hflip = 1; - info->auto_exp = 1; - info->exposure = 30; return 0; } @@ -843,6 +742,7 @@ static int sr030pc30_remove(struct i2c_client *client) struct v4l2_subdev *sd = i2c_get_clientdata(client); v4l2_device_unregister_subdev(sd); + v4l2_ctrl_handler_free(sd->ctrl_handler); return 0; } From bb732ccca29123850ffcacefe51cf2bc7d16e88c Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Mon, 10 Jun 2013 04:51:42 -0300 Subject: [PATCH 0241/1048] [media] saa6752hs: convert to the control framework Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/pci/saa7134/saa6752hs.c | 505 ++++++++------------------ 1 file changed, 146 insertions(+), 359 deletions(-) diff --git a/drivers/media/pci/saa7134/saa6752hs.c b/drivers/media/pci/saa7134/saa6752hs.c index 244b2868dfc8..8adb7b02ab5a 100644 --- a/drivers/media/pci/saa7134/saa6752hs.c +++ b/drivers/media/pci/saa7134/saa6752hs.c @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -91,6 +92,12 @@ static const struct v4l2_format v4l2_format_table[] = struct saa6752hs_state { struct v4l2_subdev sd; + struct v4l2_ctrl_handler hdl; + struct { /* video bitrate mode control cluster */ + struct v4l2_ctrl *video_bitrate_mode; + struct v4l2_ctrl *video_bitrate; + struct v4l2_ctrl *video_bitrate_peak; + }; u32 revision; int has_ac3; struct saa6752hs_mpeg_params params; @@ -360,314 +367,70 @@ static int saa6752hs_set_bitrate(struct i2c_client *client, return 0; } - -static int get_ctrl(int has_ac3, struct saa6752hs_mpeg_params *params, - struct v4l2_ext_control *ctrl) +static int saa6752hs_try_ctrl(struct v4l2_ctrl *ctrl) { + struct saa6752hs_state *h = + container_of(ctrl->handler, struct saa6752hs_state, hdl); + switch (ctrl->id) { - case V4L2_CID_MPEG_STREAM_TYPE: - ctrl->value = V4L2_MPEG_STREAM_TYPE_MPEG2_TS; - break; - case V4L2_CID_MPEG_STREAM_PID_PMT: - ctrl->value = params->ts_pid_pmt; - break; - case V4L2_CID_MPEG_STREAM_PID_AUDIO: - ctrl->value = params->ts_pid_audio; - break; - case V4L2_CID_MPEG_STREAM_PID_VIDEO: - ctrl->value = params->ts_pid_video; - break; - case V4L2_CID_MPEG_STREAM_PID_PCR: - ctrl->value = params->ts_pid_pcr; - break; - case V4L2_CID_MPEG_AUDIO_ENCODING: - ctrl->value = params->au_encoding; - break; - case V4L2_CID_MPEG_AUDIO_L2_BITRATE: - ctrl->value = params->au_l2_bitrate; - break; - case V4L2_CID_MPEG_AUDIO_AC3_BITRATE: - if (!has_ac3) - return -EINVAL; - ctrl->value = params->au_ac3_bitrate; - break; - case V4L2_CID_MPEG_AUDIO_SAMPLING_FREQ: - ctrl->value = V4L2_MPEG_AUDIO_SAMPLING_FREQ_48000; - break; - case V4L2_CID_MPEG_VIDEO_ENCODING: - ctrl->value = V4L2_MPEG_VIDEO_ENCODING_MPEG_2; - break; - case V4L2_CID_MPEG_VIDEO_ASPECT: - ctrl->value = params->vi_aspect; - break; - case V4L2_CID_MPEG_VIDEO_BITRATE: - ctrl->value = params->vi_bitrate * 1000; - break; - case V4L2_CID_MPEG_VIDEO_BITRATE_PEAK: - ctrl->value = params->vi_bitrate_peak * 1000; - break; case V4L2_CID_MPEG_VIDEO_BITRATE_MODE: - ctrl->value = params->vi_bitrate_mode; + /* peak bitrate shall be >= normal bitrate */ + if (ctrl->val == V4L2_MPEG_VIDEO_BITRATE_MODE_VBR && + h->video_bitrate_peak->val < h->video_bitrate->val) + h->video_bitrate_peak->val = h->video_bitrate->val; break; - default: - return -EINVAL; } return 0; } -static int handle_ctrl(int has_ac3, struct saa6752hs_mpeg_params *params, - struct v4l2_ext_control *ctrl, int set) +static int saa6752hs_s_ctrl(struct v4l2_ctrl *ctrl) { - int old = 0, new; - - new = ctrl->value; - switch (ctrl->id) { - case V4L2_CID_MPEG_STREAM_TYPE: - old = V4L2_MPEG_STREAM_TYPE_MPEG2_TS; - if (set && new != old) - return -ERANGE; - new = old; - break; - case V4L2_CID_MPEG_STREAM_PID_PMT: - old = params->ts_pid_pmt; - if (set && new > MPEG_PID_MAX) - return -ERANGE; - if (new > MPEG_PID_MAX) - new = MPEG_PID_MAX; - params->ts_pid_pmt = new; - break; - case V4L2_CID_MPEG_STREAM_PID_AUDIO: - old = params->ts_pid_audio; - if (set && new > MPEG_PID_MAX) - return -ERANGE; - if (new > MPEG_PID_MAX) - new = MPEG_PID_MAX; - params->ts_pid_audio = new; - break; - case V4L2_CID_MPEG_STREAM_PID_VIDEO: - old = params->ts_pid_video; - if (set && new > MPEG_PID_MAX) - return -ERANGE; - if (new > MPEG_PID_MAX) - new = MPEG_PID_MAX; - params->ts_pid_video = new; - break; - case V4L2_CID_MPEG_STREAM_PID_PCR: - old = params->ts_pid_pcr; - if (set && new > MPEG_PID_MAX) - return -ERANGE; - if (new > MPEG_PID_MAX) - new = MPEG_PID_MAX; - params->ts_pid_pcr = new; - break; - case V4L2_CID_MPEG_AUDIO_ENCODING: - old = params->au_encoding; - if (set && new != V4L2_MPEG_AUDIO_ENCODING_LAYER_2 && - (!has_ac3 || new != V4L2_MPEG_AUDIO_ENCODING_AC3)) - return -ERANGE; - params->au_encoding = new; - break; - case V4L2_CID_MPEG_AUDIO_L2_BITRATE: - old = params->au_l2_bitrate; - if (set && new != V4L2_MPEG_AUDIO_L2_BITRATE_256K && - new != V4L2_MPEG_AUDIO_L2_BITRATE_384K) - return -ERANGE; - if (new <= V4L2_MPEG_AUDIO_L2_BITRATE_256K) - new = V4L2_MPEG_AUDIO_L2_BITRATE_256K; - else - new = V4L2_MPEG_AUDIO_L2_BITRATE_384K; - params->au_l2_bitrate = new; - break; - case V4L2_CID_MPEG_AUDIO_AC3_BITRATE: - if (!has_ac3) - return -EINVAL; - old = params->au_ac3_bitrate; - if (set && new != V4L2_MPEG_AUDIO_AC3_BITRATE_256K && - new != V4L2_MPEG_AUDIO_AC3_BITRATE_384K) - return -ERANGE; - if (new <= V4L2_MPEG_AUDIO_AC3_BITRATE_256K) - new = V4L2_MPEG_AUDIO_AC3_BITRATE_256K; - else - new = V4L2_MPEG_AUDIO_AC3_BITRATE_384K; - params->au_ac3_bitrate = new; - break; - case V4L2_CID_MPEG_AUDIO_SAMPLING_FREQ: - old = V4L2_MPEG_AUDIO_SAMPLING_FREQ_48000; - if (set && new != old) - return -ERANGE; - new = old; - break; - case V4L2_CID_MPEG_VIDEO_ENCODING: - old = V4L2_MPEG_VIDEO_ENCODING_MPEG_2; - if (set && new != old) - return -ERANGE; - new = old; - break; - case V4L2_CID_MPEG_VIDEO_ASPECT: - old = params->vi_aspect; - if (set && new != V4L2_MPEG_VIDEO_ASPECT_16x9 && - new != V4L2_MPEG_VIDEO_ASPECT_4x3) - return -ERANGE; - if (new != V4L2_MPEG_VIDEO_ASPECT_16x9) - new = V4L2_MPEG_VIDEO_ASPECT_4x3; - params->vi_aspect = new; - break; - case V4L2_CID_MPEG_VIDEO_BITRATE: - old = params->vi_bitrate * 1000; - new = 1000 * (new / 1000); - if (set && new > MPEG_VIDEO_TARGET_BITRATE_MAX * 1000) - return -ERANGE; - if (new > MPEG_VIDEO_TARGET_BITRATE_MAX * 1000) - new = MPEG_VIDEO_TARGET_BITRATE_MAX * 1000; - params->vi_bitrate = new / 1000; - break; - case V4L2_CID_MPEG_VIDEO_BITRATE_PEAK: - old = params->vi_bitrate_peak * 1000; - new = 1000 * (new / 1000); - if (set && new > MPEG_VIDEO_TARGET_BITRATE_MAX * 1000) - return -ERANGE; - if (new > MPEG_VIDEO_TARGET_BITRATE_MAX * 1000) - new = MPEG_VIDEO_TARGET_BITRATE_MAX * 1000; - params->vi_bitrate_peak = new / 1000; - break; - case V4L2_CID_MPEG_VIDEO_BITRATE_MODE: - old = params->vi_bitrate_mode; - params->vi_bitrate_mode = new; - break; - default: - return -EINVAL; - } - ctrl->value = new; - return 0; -} - - -static int saa6752hs_queryctrl(struct v4l2_subdev *sd, struct v4l2_queryctrl *qctrl) -{ - struct saa6752hs_state *h = to_state(sd); + struct saa6752hs_state *h = + container_of(ctrl->handler, struct saa6752hs_state, hdl); struct saa6752hs_mpeg_params *params = &h->params; - int err; - - switch (qctrl->id) { - case V4L2_CID_MPEG_AUDIO_ENCODING: - return v4l2_ctrl_query_fill(qctrl, - V4L2_MPEG_AUDIO_ENCODING_LAYER_2, - h->has_ac3 ? V4L2_MPEG_AUDIO_ENCODING_AC3 : - V4L2_MPEG_AUDIO_ENCODING_LAYER_2, - 1, V4L2_MPEG_AUDIO_ENCODING_LAYER_2); - - case V4L2_CID_MPEG_AUDIO_L2_BITRATE: - return v4l2_ctrl_query_fill(qctrl, - V4L2_MPEG_AUDIO_L2_BITRATE_256K, - V4L2_MPEG_AUDIO_L2_BITRATE_384K, 1, - V4L2_MPEG_AUDIO_L2_BITRATE_256K); - - case V4L2_CID_MPEG_AUDIO_AC3_BITRATE: - if (!h->has_ac3) - return -EINVAL; - return v4l2_ctrl_query_fill(qctrl, - V4L2_MPEG_AUDIO_AC3_BITRATE_256K, - V4L2_MPEG_AUDIO_AC3_BITRATE_384K, 1, - V4L2_MPEG_AUDIO_AC3_BITRATE_256K); - - case V4L2_CID_MPEG_AUDIO_SAMPLING_FREQ: - return v4l2_ctrl_query_fill(qctrl, - V4L2_MPEG_AUDIO_SAMPLING_FREQ_48000, - V4L2_MPEG_AUDIO_SAMPLING_FREQ_48000, 1, - V4L2_MPEG_AUDIO_SAMPLING_FREQ_48000); - - case V4L2_CID_MPEG_VIDEO_ENCODING: - return v4l2_ctrl_query_fill(qctrl, - V4L2_MPEG_VIDEO_ENCODING_MPEG_2, - V4L2_MPEG_VIDEO_ENCODING_MPEG_2, 1, - V4L2_MPEG_VIDEO_ENCODING_MPEG_2); - - case V4L2_CID_MPEG_VIDEO_ASPECT: - return v4l2_ctrl_query_fill(qctrl, - V4L2_MPEG_VIDEO_ASPECT_4x3, - V4L2_MPEG_VIDEO_ASPECT_16x9, 1, - V4L2_MPEG_VIDEO_ASPECT_4x3); - - case V4L2_CID_MPEG_VIDEO_BITRATE_PEAK: - err = v4l2_ctrl_query_fill(qctrl, 0, 27000000, 1, 8000000); - if (err == 0 && - params->vi_bitrate_mode == - V4L2_MPEG_VIDEO_BITRATE_MODE_CBR) - qctrl->flags |= V4L2_CTRL_FLAG_INACTIVE; - return err; + switch (ctrl->id) { case V4L2_CID_MPEG_STREAM_TYPE: - return v4l2_ctrl_query_fill(qctrl, - V4L2_MPEG_STREAM_TYPE_MPEG2_TS, - V4L2_MPEG_STREAM_TYPE_MPEG2_TS, 1, - V4L2_MPEG_STREAM_TYPE_MPEG2_TS); - - case V4L2_CID_MPEG_VIDEO_BITRATE_MODE: - return v4l2_ctrl_query_fill(qctrl, - V4L2_MPEG_VIDEO_BITRATE_MODE_VBR, - V4L2_MPEG_VIDEO_BITRATE_MODE_CBR, 1, - V4L2_MPEG_VIDEO_BITRATE_MODE_VBR); - case V4L2_CID_MPEG_VIDEO_BITRATE: - return v4l2_ctrl_query_fill(qctrl, 0, 27000000, 1, 6000000); - case V4L2_CID_MPEG_STREAM_PID_PMT: - return v4l2_ctrl_query_fill(qctrl, 0, (1 << 14) - 1, 1, 16); - case V4L2_CID_MPEG_STREAM_PID_AUDIO: - return v4l2_ctrl_query_fill(qctrl, 0, (1 << 14) - 1, 1, 260); - case V4L2_CID_MPEG_STREAM_PID_VIDEO: - return v4l2_ctrl_query_fill(qctrl, 0, (1 << 14) - 1, 1, 256); - case V4L2_CID_MPEG_STREAM_PID_PCR: - return v4l2_ctrl_query_fill(qctrl, 0, (1 << 14) - 1, 1, 259); - - default: break; - } - return -EINVAL; -} - -static int saa6752hs_querymenu(struct v4l2_subdev *sd, struct v4l2_querymenu *qmenu) -{ - static const u32 mpeg_audio_encoding[] = { - V4L2_MPEG_AUDIO_ENCODING_LAYER_2, - V4L2_CTRL_MENU_IDS_END - }; - static const u32 mpeg_audio_ac3_encoding[] = { - V4L2_MPEG_AUDIO_ENCODING_LAYER_2, - V4L2_MPEG_AUDIO_ENCODING_AC3, - V4L2_CTRL_MENU_IDS_END - }; - static u32 mpeg_audio_l2_bitrate[] = { - V4L2_MPEG_AUDIO_L2_BITRATE_256K, - V4L2_MPEG_AUDIO_L2_BITRATE_384K, - V4L2_CTRL_MENU_IDS_END - }; - static u32 mpeg_audio_ac3_bitrate[] = { - V4L2_MPEG_AUDIO_AC3_BITRATE_256K, - V4L2_MPEG_AUDIO_AC3_BITRATE_384K, - V4L2_CTRL_MENU_IDS_END - }; - struct saa6752hs_state *h = to_state(sd); - struct v4l2_queryctrl qctrl; - int err; - - qctrl.id = qmenu->id; - err = saa6752hs_queryctrl(sd, &qctrl); - if (err) - return err; - switch (qmenu->id) { - case V4L2_CID_MPEG_AUDIO_L2_BITRATE: - return v4l2_ctrl_query_menu_valid_items(qmenu, - mpeg_audio_l2_bitrate); - case V4L2_CID_MPEG_AUDIO_AC3_BITRATE: - if (!h->has_ac3) - return -EINVAL; - return v4l2_ctrl_query_menu_valid_items(qmenu, - mpeg_audio_ac3_bitrate); + case V4L2_CID_MPEG_STREAM_PID_PMT: + params->ts_pid_pmt = ctrl->val; + break; + case V4L2_CID_MPEG_STREAM_PID_AUDIO: + params->ts_pid_audio = ctrl->val; + break; + case V4L2_CID_MPEG_STREAM_PID_VIDEO: + params->ts_pid_video = ctrl->val; + break; + case V4L2_CID_MPEG_STREAM_PID_PCR: + params->ts_pid_pcr = ctrl->val; + break; case V4L2_CID_MPEG_AUDIO_ENCODING: - return v4l2_ctrl_query_menu_valid_items(qmenu, - h->has_ac3 ? mpeg_audio_ac3_encoding : - mpeg_audio_encoding); + params->au_encoding = ctrl->val; + break; + case V4L2_CID_MPEG_AUDIO_L2_BITRATE: + params->au_l2_bitrate = ctrl->val; + break; + case V4L2_CID_MPEG_AUDIO_AC3_BITRATE: + params->au_ac3_bitrate = ctrl->val; + break; + case V4L2_CID_MPEG_AUDIO_SAMPLING_FREQ: + break; + case V4L2_CID_MPEG_VIDEO_ENCODING: + break; + case V4L2_CID_MPEG_VIDEO_ASPECT: + params->vi_aspect = ctrl->val; + break; + case V4L2_CID_MPEG_VIDEO_BITRATE_MODE: + params->vi_bitrate_mode = ctrl->val; + params->vi_bitrate = h->video_bitrate->val / 1000; + params->vi_bitrate_peak = h->video_bitrate_peak->val / 1000; + v4l2_ctrl_activate(h->video_bitrate_peak, + ctrl->val == V4L2_MPEG_VIDEO_BITRATE_MODE_VBR); + break; + default: + return -EINVAL; } - return v4l2_ctrl_query_menu(qmenu, &qctrl, NULL); + return 0; } static int saa6752hs_init(struct v4l2_subdev *sd, u32 leading_null_bytes) @@ -791,58 +554,6 @@ static int saa6752hs_init(struct v4l2_subdev *sd, u32 leading_null_bytes) return 0; } -static int saa6752hs_do_ext_ctrls(struct v4l2_subdev *sd, struct v4l2_ext_controls *ctrls, int set) -{ - struct saa6752hs_state *h = to_state(sd); - struct saa6752hs_mpeg_params params; - int i; - - if (ctrls->ctrl_class != V4L2_CTRL_CLASS_MPEG) - return -EINVAL; - - params = h->params; - for (i = 0; i < ctrls->count; i++) { - int err = handle_ctrl(h->has_ac3, ¶ms, ctrls->controls + i, set); - - if (err) { - ctrls->error_idx = i; - return err; - } - } - if (set) - h->params = params; - return 0; -} - -static int saa6752hs_s_ext_ctrls(struct v4l2_subdev *sd, struct v4l2_ext_controls *ctrls) -{ - return saa6752hs_do_ext_ctrls(sd, ctrls, 1); -} - -static int saa6752hs_try_ext_ctrls(struct v4l2_subdev *sd, struct v4l2_ext_controls *ctrls) -{ - return saa6752hs_do_ext_ctrls(sd, ctrls, 0); -} - -static int saa6752hs_g_ext_ctrls(struct v4l2_subdev *sd, struct v4l2_ext_controls *ctrls) -{ - struct saa6752hs_state *h = to_state(sd); - int i; - - if (ctrls->ctrl_class != V4L2_CTRL_CLASS_MPEG) - return -EINVAL; - - for (i = 0; i < ctrls->count; i++) { - int err = get_ctrl(h->has_ac3, &h->params, ctrls->controls + i); - - if (err) { - ctrls->error_idx = i; - return err; - } - } - return 0; -} - static int saa6752hs_g_mbus_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *f) { struct saa6752hs_state *h = to_state(sd); @@ -914,13 +625,20 @@ static int saa6752hs_s_std(struct v4l2_subdev *sd, v4l2_std_id std) /* ----------------------------------------------------------------------- */ +static const struct v4l2_ctrl_ops saa6752hs_ctrl_ops = { + .try_ctrl = saa6752hs_try_ctrl, + .s_ctrl = saa6752hs_s_ctrl, +}; + static const struct v4l2_subdev_core_ops saa6752hs_core_ops = { .init = saa6752hs_init, - .queryctrl = saa6752hs_queryctrl, - .querymenu = saa6752hs_querymenu, - .g_ext_ctrls = saa6752hs_g_ext_ctrls, - .s_ext_ctrls = saa6752hs_s_ext_ctrls, - .try_ext_ctrls = saa6752hs_try_ext_ctrls, + .g_ext_ctrls = v4l2_subdev_g_ext_ctrls, + .try_ext_ctrls = v4l2_subdev_try_ext_ctrls, + .s_ext_ctrls = v4l2_subdev_s_ext_ctrls, + .g_ctrl = v4l2_subdev_g_ctrl, + .s_ctrl = v4l2_subdev_s_ctrl, + .queryctrl = v4l2_subdev_queryctrl, + .querymenu = v4l2_subdev_querymenu, .s_std = saa6752hs_s_std, }; @@ -939,6 +657,7 @@ static int saa6752hs_probe(struct i2c_client *client, { struct saa6752hs_state *h = kzalloc(sizeof(*h), GFP_KERNEL); struct v4l2_subdev *sd; + struct v4l2_ctrl_handler *hdl; u8 addr = 0x13; u8 data[12]; @@ -955,9 +674,84 @@ static int saa6752hs_probe(struct i2c_client *client, h->has_ac3 = 0; if (h->revision == 0x0206) { h->has_ac3 = 1; - v4l_info(client, "support AC-3\n"); + v4l_info(client, "supports AC-3\n"); } h->params = param_defaults; + + hdl = &h->hdl; + v4l2_ctrl_handler_init(hdl, 14); + v4l2_ctrl_new_std_menu(hdl, &saa6752hs_ctrl_ops, + V4L2_CID_MPEG_AUDIO_ENCODING, + h->has_ac3 ? V4L2_MPEG_AUDIO_ENCODING_AC3 : + V4L2_MPEG_AUDIO_ENCODING_LAYER_2, + 0x0d, V4L2_MPEG_AUDIO_ENCODING_LAYER_2); + + v4l2_ctrl_new_std_menu(hdl, &saa6752hs_ctrl_ops, + V4L2_CID_MPEG_AUDIO_L2_BITRATE, + V4L2_MPEG_AUDIO_L2_BITRATE_384K, + ~((1 << V4L2_MPEG_AUDIO_L2_BITRATE_256K) | + (1 << V4L2_MPEG_AUDIO_L2_BITRATE_384K)), + V4L2_MPEG_AUDIO_L2_BITRATE_256K); + + if (h->has_ac3) + v4l2_ctrl_new_std_menu(hdl, &saa6752hs_ctrl_ops, + V4L2_CID_MPEG_AUDIO_AC3_BITRATE, + V4L2_MPEG_AUDIO_AC3_BITRATE_384K, + ~((1 << V4L2_MPEG_AUDIO_AC3_BITRATE_256K) | + (1 << V4L2_MPEG_AUDIO_AC3_BITRATE_384K)), + V4L2_MPEG_AUDIO_AC3_BITRATE_256K); + + v4l2_ctrl_new_std_menu(hdl, &saa6752hs_ctrl_ops, + V4L2_CID_MPEG_AUDIO_SAMPLING_FREQ, + V4L2_MPEG_AUDIO_SAMPLING_FREQ_48000, + ~(1 << V4L2_MPEG_AUDIO_SAMPLING_FREQ_48000), + V4L2_MPEG_AUDIO_SAMPLING_FREQ_48000); + + v4l2_ctrl_new_std_menu(hdl, &saa6752hs_ctrl_ops, + V4L2_CID_MPEG_VIDEO_ENCODING, + V4L2_MPEG_VIDEO_ENCODING_MPEG_2, + ~(1 << V4L2_MPEG_VIDEO_ENCODING_MPEG_2), + V4L2_MPEG_VIDEO_ENCODING_MPEG_2); + + v4l2_ctrl_new_std_menu(hdl, &saa6752hs_ctrl_ops, + V4L2_CID_MPEG_VIDEO_ASPECT, + V4L2_MPEG_VIDEO_ASPECT_16x9, 0x01, + V4L2_MPEG_VIDEO_ASPECT_4x3); + + h->video_bitrate_peak = v4l2_ctrl_new_std(hdl, &saa6752hs_ctrl_ops, + V4L2_CID_MPEG_VIDEO_BITRATE_PEAK, + 1000000, 27000000, 1000, 8000000); + + v4l2_ctrl_new_std_menu(hdl, &saa6752hs_ctrl_ops, + V4L2_CID_MPEG_STREAM_TYPE, + V4L2_MPEG_STREAM_TYPE_MPEG2_TS, + ~(1 << V4L2_MPEG_STREAM_TYPE_MPEG2_TS), + V4L2_MPEG_STREAM_TYPE_MPEG2_TS); + + h->video_bitrate_mode = v4l2_ctrl_new_std_menu(hdl, &saa6752hs_ctrl_ops, + V4L2_CID_MPEG_VIDEO_BITRATE_MODE, + V4L2_MPEG_VIDEO_BITRATE_MODE_CBR, 0, + V4L2_MPEG_VIDEO_BITRATE_MODE_VBR); + h->video_bitrate = v4l2_ctrl_new_std(hdl, &saa6752hs_ctrl_ops, + V4L2_CID_MPEG_VIDEO_BITRATE, 1000000, 27000000, 1000, 6000000); + v4l2_ctrl_new_std(hdl, &saa6752hs_ctrl_ops, + V4L2_CID_MPEG_STREAM_PID_PMT, 0, (1 << 14) - 1, 1, 16); + v4l2_ctrl_new_std(hdl, &saa6752hs_ctrl_ops, + V4L2_CID_MPEG_STREAM_PID_AUDIO, 0, (1 << 14) - 1, 1, 260); + v4l2_ctrl_new_std(hdl, &saa6752hs_ctrl_ops, + V4L2_CID_MPEG_STREAM_PID_VIDEO, 0, (1 << 14) - 1, 1, 256); + v4l2_ctrl_new_std(hdl, &saa6752hs_ctrl_ops, + V4L2_CID_MPEG_STREAM_PID_PCR, 0, (1 << 14) - 1, 1, 259); + sd->ctrl_handler = hdl; + if (hdl->error) { + int err = hdl->error; + + v4l2_ctrl_handler_free(hdl); + kfree(h); + return err; + } + v4l2_ctrl_cluster(3, &h->video_bitrate_mode); + v4l2_ctrl_handler_setup(hdl); h->standard = 0; /* Assume 625 input lines */ return 0; } @@ -967,6 +761,7 @@ static int saa6752hs_remove(struct i2c_client *client) struct v4l2_subdev *sd = i2c_get_clientdata(client); v4l2_device_unregister_subdev(sd); + v4l2_ctrl_handler_free(&to_state(sd)->hdl); kfree(to_state(sd)); return 0; } @@ -988,11 +783,3 @@ static struct i2c_driver saa6752hs_driver = { }; module_i2c_driver(saa6752hs_driver); - -/* - * Overrides for Emacs so that we follow Linus's tabbing style. - * --------------------------------------------------------------------------- - * Local variables: - * c-basic-offset: 8 - * End: - */ From 099f88ee20c4d387a7bd76e0a5765533b1f5b6b0 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Sun, 3 Feb 2013 08:25:32 -0300 Subject: [PATCH 0242/1048] [media] radio-tea5764: add support for struct v4l2_device Signed-off-by: Hans Verkuil Cc: Fabio Belavenuto Signed-off-by: Mauro Carvalho Chehab --- drivers/media/radio/radio-tea5764.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/drivers/media/radio/radio-tea5764.c b/drivers/media/radio/radio-tea5764.c index 38d563d62595..f6a5471e51aa 100644 --- a/drivers/media/radio/radio-tea5764.c +++ b/drivers/media/radio/radio-tea5764.c @@ -39,6 +39,7 @@ #include /* I2C */ #include #include +#include #define DRIVER_VERSION "0.0.2" @@ -138,6 +139,7 @@ static int radio_nr = -1; static int use_xtal = RADIO_TEA5764_XTAL; struct tea5764_device { + struct v4l2_device v4l2_dev; struct i2c_client *i2c_client; struct video_device *videodev; struct tea5764_regs regs; @@ -497,6 +499,7 @@ static int tea5764_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id) { struct tea5764_device *radio; + struct v4l2_device *v4l2_dev; struct tea5764_regs *r; int ret; @@ -505,31 +508,37 @@ static int tea5764_i2c_probe(struct i2c_client *client, if (!radio) return -ENOMEM; + v4l2_dev = &radio->v4l2_dev; + ret = v4l2_device_register(&client->dev, v4l2_dev); + if (ret < 0) { + v4l2_err(v4l2_dev, "could not register v4l2_device\n"); + goto errfr; + } mutex_init(&radio->mutex); radio->i2c_client = client; ret = tea5764_i2c_read(radio); if (ret) - goto errfr; + goto errunreg; r = &radio->regs; PDEBUG("chipid = %04X, manid = %04X", r->chipid, r->manid); if (r->chipid != TEA5764_CHIPID || (r->manid & 0x0fff) != TEA5764_MANID) { PWARN("This chip is not a TEA5764!"); ret = -EINVAL; - goto errfr; + goto errunreg; } radio->videodev = video_device_alloc(); if (!(radio->videodev)) { ret = -ENOMEM; - goto errfr; + goto errunreg; } - memcpy(radio->videodev, &tea5764_radio_template, - sizeof(tea5764_radio_template)); + *radio->videodev = tea5764_radio_template; i2c_set_clientdata(client, radio); video_set_drvdata(radio->videodev, radio); radio->videodev->lock = &radio->mutex; + radio->videodev->v4l2_dev = v4l2_dev; /* initialize and power off the chip */ tea5764_i2c_read(radio); @@ -547,6 +556,8 @@ static int tea5764_i2c_probe(struct i2c_client *client, return 0; errrel: video_device_release(radio->videodev); +errunreg: + v4l2_device_unregister(v4l2_dev); errfr: kfree(radio); return ret; @@ -560,6 +571,7 @@ static int tea5764_i2c_remove(struct i2c_client *client) if (radio) { tea5764_power_down(radio); video_unregister_device(radio->videodev); + v4l2_device_unregister(&radio->v4l2_dev); kfree(radio); } return 0; From cf9033f9b5d867ae040d37a148cf1c1e645ffe96 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Sun, 3 Feb 2013 08:27:57 -0300 Subject: [PATCH 0243/1048] [media] radio-tea5764: embed struct video_device This simplifies the code as it removes a memory allocation check. Signed-off-by: Hans Verkuil Cc: Fabio Belavenuto Signed-off-by: Mauro Carvalho Chehab --- drivers/media/radio/radio-tea5764.c | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/drivers/media/radio/radio-tea5764.c b/drivers/media/radio/radio-tea5764.c index f6a5471e51aa..4e0bf644b4f9 100644 --- a/drivers/media/radio/radio-tea5764.c +++ b/drivers/media/radio/radio-tea5764.c @@ -141,7 +141,7 @@ static int use_xtal = RADIO_TEA5764_XTAL; struct tea5764_device { struct v4l2_device v4l2_dev; struct i2c_client *i2c_client; - struct video_device *videodev; + struct video_device vdev; struct tea5764_regs regs; struct mutex mutex; }; @@ -303,7 +303,7 @@ static int vidioc_querycap(struct file *file, void *priv, struct v4l2_capability *v) { struct tea5764_device *radio = video_drvdata(file); - struct video_device *dev = radio->videodev; + struct video_device *dev = &radio->vdev; strlcpy(v->driver, dev->dev.driver->name, sizeof(v->driver)); strlcpy(v->card, dev->name, sizeof(v->card)); @@ -491,7 +491,7 @@ static struct video_device tea5764_radio_template = { .name = "TEA5764 FM-Radio", .fops = &tea5764_fops, .ioctl_ops = &tea5764_ioctl_ops, - .release = video_device_release, + .release = video_device_release_empty, }; /* I2C probe: check if the device exists and register with v4l if it is */ @@ -528,17 +528,12 @@ static int tea5764_i2c_probe(struct i2c_client *client, goto errunreg; } - radio->videodev = video_device_alloc(); - if (!(radio->videodev)) { - ret = -ENOMEM; - goto errunreg; - } - *radio->videodev = tea5764_radio_template; + radio->vdev = tea5764_radio_template; i2c_set_clientdata(client, radio); - video_set_drvdata(radio->videodev, radio); - radio->videodev->lock = &radio->mutex; - radio->videodev->v4l2_dev = v4l2_dev; + video_set_drvdata(&radio->vdev, radio); + radio->vdev.lock = &radio->mutex; + radio->vdev.v4l2_dev = v4l2_dev; /* initialize and power off the chip */ tea5764_i2c_read(radio); @@ -546,16 +541,14 @@ static int tea5764_i2c_probe(struct i2c_client *client, tea5764_mute(radio, 1); tea5764_power_down(radio); - ret = video_register_device(radio->videodev, VFL_TYPE_RADIO, radio_nr); + ret = video_register_device(&radio->vdev, VFL_TYPE_RADIO, radio_nr); if (ret < 0) { PWARN("Could not register video device!"); - goto errrel; + goto errunreg; } PINFO("registered."); return 0; -errrel: - video_device_release(radio->videodev); errunreg: v4l2_device_unregister(v4l2_dev); errfr: @@ -570,7 +563,7 @@ static int tea5764_i2c_remove(struct i2c_client *client) PDEBUG("remove"); if (radio) { tea5764_power_down(radio); - video_unregister_device(radio->videodev); + video_unregister_device(&radio->vdev); v4l2_device_unregister(&radio->v4l2_dev); kfree(radio); } From 16b371784ecf1a2d1d7f04760807b3b8138d369f Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Sun, 3 Feb 2013 08:34:18 -0300 Subject: [PATCH 0244/1048] [media] radio-tea5764: convert to the control framework Signed-off-by: Hans Verkuil Cc: Fabio Belavenuto Signed-off-by: Mauro Carvalho Chehab --- drivers/media/radio/radio-tea5764.c | 79 ++++++++++------------------- 1 file changed, 26 insertions(+), 53 deletions(-) diff --git a/drivers/media/radio/radio-tea5764.c b/drivers/media/radio/radio-tea5764.c index 4e0bf644b4f9..5c47a970843e 100644 --- a/drivers/media/radio/radio-tea5764.c +++ b/drivers/media/radio/radio-tea5764.c @@ -40,6 +40,7 @@ #include #include #include +#include #define DRIVER_VERSION "0.0.2" @@ -139,7 +140,8 @@ static int radio_nr = -1; static int use_xtal = RADIO_TEA5764_XTAL; struct tea5764_device { - struct v4l2_device v4l2_dev; + struct v4l2_device v4l2_dev; + struct v4l2_ctrl_handler ctrl_handler; struct i2c_client *i2c_client; struct video_device vdev; struct tea5764_regs regs; @@ -189,18 +191,6 @@ static int tea5764_i2c_write(struct tea5764_device *radio) return 0; } -/* V4L2 code related */ -static struct v4l2_queryctrl radio_qctrl[] = { - { - .id = V4L2_CID_AUDIO_MUTE, - .name = "Mute", - .minimum = 0, - .maximum = 1, - .default_value = 1, - .type = V4L2_CTRL_TYPE_BOOLEAN, - } -}; - static void tea5764_power_up(struct tea5764_device *radio) { struct tea5764_regs *r = &radio->regs; @@ -293,11 +283,6 @@ static void tea5764_mute(struct tea5764_device *radio, int on) tea5764_i2c_write(radio); } -static int tea5764_is_muted(struct tea5764_device *radio) -{ - return radio->regs.tnctrl & TEA5764_TNCTRL_MU; -} - /* V4L2 vidioc */ static int vidioc_querycap(struct file *file, void *priv, struct v4l2_capability *v) @@ -391,42 +376,14 @@ static int vidioc_g_frequency(struct file *file, void *priv, return 0; } -static int vidioc_queryctrl(struct file *file, void *priv, - struct v4l2_queryctrl *qc) +static int tea5764_s_ctrl(struct v4l2_ctrl *ctrl) { - int i; - - for (i = 0; i < ARRAY_SIZE(radio_qctrl); i++) { - if (qc->id && qc->id == radio_qctrl[i].id) { - memcpy(qc, &(radio_qctrl[i]), sizeof(*qc)); - return 0; - } - } - return -EINVAL; -} - -static int vidioc_g_ctrl(struct file *file, void *priv, - struct v4l2_control *ctrl) -{ - struct tea5764_device *radio = video_drvdata(file); + struct tea5764_device *radio = + container_of(ctrl->handler, struct tea5764_device, ctrl_handler); switch (ctrl->id) { case V4L2_CID_AUDIO_MUTE: - tea5764_i2c_read(radio); - ctrl->value = tea5764_is_muted(radio) ? 1 : 0; - return 0; - } - return -EINVAL; -} - -static int vidioc_s_ctrl(struct file *file, void *priv, - struct v4l2_control *ctrl) -{ - struct tea5764_device *radio = video_drvdata(file); - - switch (ctrl->id) { - case V4L2_CID_AUDIO_MUTE: - tea5764_mute(radio, ctrl->value); + tea5764_mute(radio, ctrl->val); return 0; } return -EINVAL; @@ -465,6 +422,10 @@ static int vidioc_s_audio(struct file *file, void *priv, return 0; } +static const struct v4l2_ctrl_ops tea5764_ctrl_ops = { + .s_ctrl = tea5764_s_ctrl, +}; + /* File system interface */ static const struct v4l2_file_operations tea5764_fops = { .owner = THIS_MODULE, @@ -481,9 +442,6 @@ static const struct v4l2_ioctl_ops tea5764_ioctl_ops = { .vidioc_s_input = vidioc_s_input, .vidioc_g_frequency = vidioc_g_frequency, .vidioc_s_frequency = vidioc_s_frequency, - .vidioc_queryctrl = vidioc_queryctrl, - .vidioc_g_ctrl = vidioc_g_ctrl, - .vidioc_s_ctrl = vidioc_s_ctrl, }; /* V4L2 interface */ @@ -500,6 +458,7 @@ static int tea5764_i2c_probe(struct i2c_client *client, { struct tea5764_device *radio; struct v4l2_device *v4l2_dev; + struct v4l2_ctrl_handler *hdl; struct tea5764_regs *r; int ret; @@ -514,6 +473,18 @@ static int tea5764_i2c_probe(struct i2c_client *client, v4l2_err(v4l2_dev, "could not register v4l2_device\n"); goto errfr; } + + hdl = &radio->ctrl_handler; + v4l2_ctrl_handler_init(hdl, 1); + v4l2_ctrl_new_std(hdl, &tea5764_ctrl_ops, + V4L2_CID_AUDIO_MUTE, 0, 1, 1, 1); + v4l2_dev->ctrl_handler = hdl; + if (hdl->error) { + ret = hdl->error; + v4l2_err(v4l2_dev, "Could not register controls\n"); + goto errunreg; + } + mutex_init(&radio->mutex); radio->i2c_client = client; ret = tea5764_i2c_read(radio); @@ -550,6 +521,7 @@ static int tea5764_i2c_probe(struct i2c_client *client, PINFO("registered."); return 0; errunreg: + v4l2_ctrl_handler_free(hdl); v4l2_device_unregister(v4l2_dev); errfr: kfree(radio); @@ -564,6 +536,7 @@ static int tea5764_i2c_remove(struct i2c_client *client) if (radio) { tea5764_power_down(radio); video_unregister_device(&radio->vdev); + v4l2_ctrl_handler_free(&radio->ctrl_handler); v4l2_device_unregister(&radio->v4l2_dev); kfree(radio); } From 827c7cf5135e4ca5b0e7de1ed2ae8c1a362b923c Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Sun, 3 Feb 2013 08:35:06 -0300 Subject: [PATCH 0245/1048] [media] radio-tea5764: audio and input ioctls do not apply to radio devices Deleted those ioctls from this driver. Signed-off-by: Hans Verkuil Cc: Fabio Belavenuto Signed-off-by: Mauro Carvalho Chehab --- drivers/media/radio/radio-tea5764.c | 37 ----------------------------- 1 file changed, 37 deletions(-) diff --git a/drivers/media/radio/radio-tea5764.c b/drivers/media/radio/radio-tea5764.c index 5c47a970843e..5a609903d4c5 100644 --- a/drivers/media/radio/radio-tea5764.c +++ b/drivers/media/radio/radio-tea5764.c @@ -389,39 +389,6 @@ static int tea5764_s_ctrl(struct v4l2_ctrl *ctrl) return -EINVAL; } -static int vidioc_g_input(struct file *filp, void *priv, unsigned int *i) -{ - *i = 0; - return 0; -} - -static int vidioc_s_input(struct file *filp, void *priv, unsigned int i) -{ - if (i != 0) - return -EINVAL; - return 0; -} - -static int vidioc_g_audio(struct file *file, void *priv, - struct v4l2_audio *a) -{ - if (a->index > 1) - return -EINVAL; - - strcpy(a->name, "Radio"); - a->capability = V4L2_AUDCAP_STEREO; - return 0; -} - -static int vidioc_s_audio(struct file *file, void *priv, - const struct v4l2_audio *a) -{ - if (a->index != 0) - return -EINVAL; - - return 0; -} - static const struct v4l2_ctrl_ops tea5764_ctrl_ops = { .s_ctrl = tea5764_s_ctrl, }; @@ -436,10 +403,6 @@ static const struct v4l2_ioctl_ops tea5764_ioctl_ops = { .vidioc_querycap = vidioc_querycap, .vidioc_g_tuner = vidioc_g_tuner, .vidioc_s_tuner = vidioc_s_tuner, - .vidioc_g_audio = vidioc_g_audio, - .vidioc_s_audio = vidioc_s_audio, - .vidioc_g_input = vidioc_g_input, - .vidioc_s_input = vidioc_s_input, .vidioc_g_frequency = vidioc_g_frequency, .vidioc_s_frequency = vidioc_s_frequency, }; From cc9231f88edec9e95ce579484e1c862b6d810854 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Sun, 3 Feb 2013 08:36:42 -0300 Subject: [PATCH 0246/1048] [media] radio-tea5764: add device_caps support Signed-off-by: Hans Verkuil Cc: Fabio Belavenuto Signed-off-by: Mauro Carvalho Chehab --- drivers/media/radio/radio-tea5764.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/media/radio/radio-tea5764.c b/drivers/media/radio/radio-tea5764.c index 5a609903d4c5..077d9063cd4f 100644 --- a/drivers/media/radio/radio-tea5764.c +++ b/drivers/media/radio/radio-tea5764.c @@ -294,7 +294,8 @@ static int vidioc_querycap(struct file *file, void *priv, strlcpy(v->card, dev->name, sizeof(v->card)); snprintf(v->bus_info, sizeof(v->bus_info), "I2C:%s", dev_name(&dev->dev)); - v->capabilities = V4L2_CAP_TUNER | V4L2_CAP_RADIO; + v->device_caps = V4L2_CAP_TUNER | V4L2_CAP_RADIO; + v->capabilities = v->device_caps | V4L2_CAP_DEVICE_CAPS; return 0; } From 090fdf6af8d1baafcdaf44796058f62a73a637bf Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Sun, 3 Feb 2013 08:39:09 -0300 Subject: [PATCH 0247/1048] [media] radio-tea5764: add prio and control event support Signed-off-by: Hans Verkuil Cc: Fabio Belavenuto Signed-off-by: Mauro Carvalho Chehab --- drivers/media/radio/radio-tea5764.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/media/radio/radio-tea5764.c b/drivers/media/radio/radio-tea5764.c index 077d9063cd4f..c22feedb36f5 100644 --- a/drivers/media/radio/radio-tea5764.c +++ b/drivers/media/radio/radio-tea5764.c @@ -41,6 +41,7 @@ #include #include #include +#include #define DRIVER_VERSION "0.0.2" @@ -397,6 +398,9 @@ static const struct v4l2_ctrl_ops tea5764_ctrl_ops = { /* File system interface */ static const struct v4l2_file_operations tea5764_fops = { .owner = THIS_MODULE, + .open = v4l2_fh_open, + .release = v4l2_fh_release, + .poll = v4l2_ctrl_poll, .unlocked_ioctl = video_ioctl2, }; @@ -406,6 +410,9 @@ static const struct v4l2_ioctl_ops tea5764_ioctl_ops = { .vidioc_s_tuner = vidioc_s_tuner, .vidioc_g_frequency = vidioc_g_frequency, .vidioc_s_frequency = vidioc_s_frequency, + .vidioc_log_status = v4l2_ctrl_log_status, + .vidioc_subscribe_event = v4l2_ctrl_subscribe_event, + .vidioc_unsubscribe_event = v4l2_event_unsubscribe, }; /* V4L2 interface */ @@ -469,6 +476,7 @@ static int tea5764_i2c_probe(struct i2c_client *client, video_set_drvdata(&radio->vdev, radio); radio->vdev.lock = &radio->mutex; radio->vdev.v4l2_dev = v4l2_dev; + set_bit(V4L2_FL_USE_FH_PRIO, &radio->vdev.flags); /* initialize and power off the chip */ tea5764_i2c_read(radio); From b73008920a69669d253b2f9268f9f51884684718 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Fri, 31 May 2013 06:19:04 -0300 Subject: [PATCH 0248/1048] [media] radio-tea5764: some cleanups and clamp frequency when out-of-range Some small cleanups and when setting the frequency it is now clamped to the valid frequency range instead of returning an error. Signed-off-by: Hans Verkuil Cc: Fabio Belavenuto Signed-off-by: Mauro Carvalho Chehab --- drivers/media/radio/radio-tea5764.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/drivers/media/radio/radio-tea5764.c b/drivers/media/radio/radio-tea5764.c index c22feedb36f5..036e2f54f4db 100644 --- a/drivers/media/radio/radio-tea5764.c +++ b/drivers/media/radio/radio-tea5764.c @@ -60,8 +60,8 @@ /* Frequency limits in MHz -- these are European values. For Japanese devices, that would be 76000 and 91000. */ -#define FREQ_MIN 87500 -#define FREQ_MAX 108000 +#define FREQ_MIN 87500U +#define FREQ_MAX 108000U #define FREQ_MUL 16 /* TEA5764 registers */ @@ -309,8 +309,7 @@ static int vidioc_g_tuner(struct file *file, void *priv, if (v->index > 0) return -EINVAL; - memset(v, 0, sizeof(*v)); - strcpy(v->name, "FM"); + strlcpy(v->name, "FM", sizeof(v->name)); v->type = V4L2_TUNER_RADIO; tea5764_i2c_read(radio); v->rangelow = FREQ_MIN * FREQ_MUL; @@ -343,19 +342,23 @@ static int vidioc_s_frequency(struct file *file, void *priv, const struct v4l2_frequency *f) { struct tea5764_device *radio = video_drvdata(file); + unsigned freq = f->frequency; if (f->tuner != 0 || f->type != V4L2_TUNER_RADIO) return -EINVAL; - if (f->frequency == 0) { + if (freq == 0) { /* We special case this as a power down control. */ tea5764_power_down(radio); + /* Yes, that's what is returned in this case. This + whole special case is non-compliant and should really + be replaced with something better, but changing this + might well break code that depends on this behavior. + So we keep it as-is. */ + return -EINVAL; } - if (f->frequency < (FREQ_MIN * FREQ_MUL)) - return -EINVAL; - if (f->frequency > (FREQ_MAX * FREQ_MUL)) - return -EINVAL; + clamp(freq, FREQ_MIN * FREQ_MUL, FREQ_MAX * FREQ_MUL); tea5764_power_up(radio); - tea5764_tune(radio, (f->frequency * 125) / 2); + tea5764_tune(radio, (freq * 125) / 2); return 0; } @@ -368,7 +371,6 @@ static int vidioc_g_frequency(struct file *file, void *priv, if (f->tuner != 0) return -EINVAL; tea5764_i2c_read(radio); - memset(f, 0, sizeof(*f)); f->type = V4L2_TUNER_RADIO; if (r->tnctrl & TEA5764_TNCTRL_PUPD0) f->frequency = (tea5764_get_freq(radio) * 2) / 125; From d020f83947c68d9d6e8848fe81cc630ef603d177 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Sun, 3 Feb 2013 09:05:16 -0300 Subject: [PATCH 0249/1048] [media] radio-timb: add device_caps support, remove input/audio ioctls MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The audio and input ioctls are not applicable for radio devices, remove them. Also set the device_caps field in v4l2_querycap. Signed-off-by: Hans Verkuil Cc: Richard Röjfors Signed-off-by: Mauro Carvalho Chehab --- drivers/media/radio/radio-timb.c | 35 ++------------------------------ 1 file changed, 2 insertions(+), 33 deletions(-) diff --git a/drivers/media/radio/radio-timb.c b/drivers/media/radio/radio-timb.c index bb7b143b65d1..cecf7d7c2136 100644 --- a/drivers/media/radio/radio-timb.c +++ b/drivers/media/radio/radio-timb.c @@ -44,7 +44,8 @@ static int timbradio_vidioc_querycap(struct file *file, void *priv, strlcpy(v->driver, DRIVER_NAME, sizeof(v->driver)); strlcpy(v->card, "Timberdale Radio", sizeof(v->card)); snprintf(v->bus_info, sizeof(v->bus_info), "platform:"DRIVER_NAME); - v->capabilities = V4L2_CAP_TUNER | V4L2_CAP_RADIO; + v->device_caps = V4L2_CAP_TUNER | V4L2_CAP_RADIO; + v->capabilities = v->device_caps | V4L2_CAP_DEVICE_CAPS; return 0; } @@ -62,34 +63,6 @@ static int timbradio_vidioc_s_tuner(struct file *file, void *priv, return v4l2_subdev_call(tr->sd_tuner, tuner, s_tuner, v); } -static int timbradio_vidioc_g_input(struct file *filp, void *priv, - unsigned int *i) -{ - *i = 0; - return 0; -} - -static int timbradio_vidioc_s_input(struct file *filp, void *priv, - unsigned int i) -{ - return i ? -EINVAL : 0; -} - -static int timbradio_vidioc_g_audio(struct file *file, void *priv, - struct v4l2_audio *a) -{ - a->index = 0; - strlcpy(a->name, "Radio", sizeof(a->name)); - a->capability = V4L2_AUDCAP_STEREO; - return 0; -} - -static int timbradio_vidioc_s_audio(struct file *file, void *priv, - const struct v4l2_audio *a) -{ - return a->index ? -EINVAL : 0; -} - static int timbradio_vidioc_s_frequency(struct file *file, void *priv, const struct v4l2_frequency *f) { @@ -131,10 +104,6 @@ static const struct v4l2_ioctl_ops timbradio_ioctl_ops = { .vidioc_s_tuner = timbradio_vidioc_s_tuner, .vidioc_g_frequency = timbradio_vidioc_g_frequency, .vidioc_s_frequency = timbradio_vidioc_s_frequency, - .vidioc_g_input = timbradio_vidioc_g_input, - .vidioc_s_input = timbradio_vidioc_s_input, - .vidioc_g_audio = timbradio_vidioc_g_audio, - .vidioc_s_audio = timbradio_vidioc_s_audio, .vidioc_queryctrl = timbradio_vidioc_queryctrl, .vidioc_g_ctrl = timbradio_vidioc_g_ctrl, .vidioc_s_ctrl = timbradio_vidioc_s_ctrl From 38be65abfff07fdbbc4d956b997c214ec9005960 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Fri, 31 May 2013 06:28:49 -0300 Subject: [PATCH 0250/1048] [media] radio-timb: convert to the control framework MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Hans Verkuil Cc: Richard Röjfors Signed-off-by: Mauro Carvalho Chehab --- drivers/media/radio/radio-timb.c | 24 ------------------------ 1 file changed, 24 deletions(-) diff --git a/drivers/media/radio/radio-timb.c b/drivers/media/radio/radio-timb.c index cecf7d7c2136..99694ddf5733 100644 --- a/drivers/media/radio/radio-timb.c +++ b/drivers/media/radio/radio-timb.c @@ -77,36 +77,12 @@ static int timbradio_vidioc_g_frequency(struct file *file, void *priv, return v4l2_subdev_call(tr->sd_tuner, tuner, g_frequency, f); } -static int timbradio_vidioc_queryctrl(struct file *file, void *priv, - struct v4l2_queryctrl *qc) -{ - struct timbradio *tr = video_drvdata(file); - return v4l2_subdev_call(tr->sd_dsp, core, queryctrl, qc); -} - -static int timbradio_vidioc_g_ctrl(struct file *file, void *priv, - struct v4l2_control *ctrl) -{ - struct timbradio *tr = video_drvdata(file); - return v4l2_subdev_call(tr->sd_dsp, core, g_ctrl, ctrl); -} - -static int timbradio_vidioc_s_ctrl(struct file *file, void *priv, - struct v4l2_control *ctrl) -{ - struct timbradio *tr = video_drvdata(file); - return v4l2_subdev_call(tr->sd_dsp, core, s_ctrl, ctrl); -} - static const struct v4l2_ioctl_ops timbradio_ioctl_ops = { .vidioc_querycap = timbradio_vidioc_querycap, .vidioc_g_tuner = timbradio_vidioc_g_tuner, .vidioc_s_tuner = timbradio_vidioc_s_tuner, .vidioc_g_frequency = timbradio_vidioc_g_frequency, .vidioc_s_frequency = timbradio_vidioc_s_frequency, - .vidioc_queryctrl = timbradio_vidioc_queryctrl, - .vidioc_g_ctrl = timbradio_vidioc_g_ctrl, - .vidioc_s_ctrl = timbradio_vidioc_s_ctrl }; static const struct v4l2_file_operations timbradio_fops = { From 5bd8d2abe1edef2559bcfb23e6028df79f81c6e2 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Fri, 31 May 2013 06:50:50 -0300 Subject: [PATCH 0251/1048] [media] radio-timb: actually load the requested subdevs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For some reason the tuner and dsp subdevs were never actually loaded. Added the relevant code to do that. Also remove bogus calls to video_device_release_empty(). Signed-off-by: Hans Verkuil Cc: Richard Röjfors Signed-off-by: Mauro Carvalho Chehab --- drivers/media/radio/radio-timb.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/media/radio/radio-timb.c b/drivers/media/radio/radio-timb.c index 99694ddf5733..1931ef778fcd 100644 --- a/drivers/media/radio/radio-timb.c +++ b/drivers/media/radio/radio-timb.c @@ -126,6 +126,15 @@ static int timbradio_probe(struct platform_device *pdev) tr->video_dev.v4l2_dev = &tr->v4l2_dev; + tr->sd_tuner = v4l2_i2c_new_subdev_board(&tr->v4l2_dev, + i2c_get_adapter(pdata->i2c_adapter), pdata->tuner, NULL); + tr->sd_dsp = v4l2_i2c_new_subdev_board(&tr->v4l2_dev, + i2c_get_adapter(pdata->i2c_adapter), pdata->dsp, NULL); + if (tr->sd_tuner == NULL || tr->sd_dsp == NULL) + goto err_video_req; + + tr->v4l2_dev.ctrl_handler = tr->sd_dsp->ctrl_handler; + err = video_register_device(&tr->video_dev, VFL_TYPE_RADIO, -1); if (err) { dev_err(&pdev->dev, "Error reg video\n"); @@ -138,7 +147,6 @@ static int timbradio_probe(struct platform_device *pdev) return 0; err_video_req: - video_device_release_empty(&tr->video_dev); v4l2_device_unregister(&tr->v4l2_dev); err: dev_err(&pdev->dev, "Failed to register: %d\n", err); @@ -151,10 +159,7 @@ static int timbradio_remove(struct platform_device *pdev) struct timbradio *tr = platform_get_drvdata(pdev); video_unregister_device(&tr->video_dev); - video_device_release_empty(&tr->video_dev); - v4l2_device_unregister(&tr->v4l2_dev); - return 0; } From 46821b1d206cbafab54fa0ba6dd80904722326e2 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Sun, 3 Feb 2013 09:33:21 -0300 Subject: [PATCH 0252/1048] [media] radio-timb: add control events and prio support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Hans Verkuil Cc: Richard Röjfors Signed-off-by: Mauro Carvalho Chehab --- drivers/media/radio/radio-timb.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/media/radio/radio-timb.c b/drivers/media/radio/radio-timb.c index 1931ef778fcd..0817964d9172 100644 --- a/drivers/media/radio/radio-timb.c +++ b/drivers/media/radio/radio-timb.c @@ -19,6 +19,8 @@ #include #include #include +#include +#include #include #include #include @@ -83,10 +85,16 @@ static const struct v4l2_ioctl_ops timbradio_ioctl_ops = { .vidioc_s_tuner = timbradio_vidioc_s_tuner, .vidioc_g_frequency = timbradio_vidioc_g_frequency, .vidioc_s_frequency = timbradio_vidioc_s_frequency, + .vidioc_log_status = v4l2_ctrl_log_status, + .vidioc_subscribe_event = v4l2_ctrl_subscribe_event, + .vidioc_unsubscribe_event = v4l2_event_unsubscribe, }; static const struct v4l2_file_operations timbradio_fops = { .owner = THIS_MODULE, + .open = v4l2_fh_open, + .release = v4l2_fh_release, + .poll = v4l2_ctrl_poll, .unlocked_ioctl = video_ioctl2, }; @@ -118,6 +126,7 @@ static int timbradio_probe(struct platform_device *pdev) tr->video_dev.release = video_device_release_empty; tr->video_dev.minor = -1; tr->video_dev.lock = &tr->lock; + set_bit(V4L2_FL_USE_FH_PRIO, &tr->video_dev.flags); strlcpy(tr->v4l2_dev.name, DRIVER_NAME, sizeof(tr->v4l2_dev.name)); err = v4l2_device_register(NULL, &tr->v4l2_dev); From fa915996fb4e06a90d15fa485742a77cd8c1642b Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Fri, 31 May 2013 06:19:55 -0300 Subject: [PATCH 0253/1048] [media] tef6862: clamp frequency MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Clamp the frequency to the valid frequency range as per the V4L2 specification. Signed-off-by: Hans Verkuil Cc: Richard Röjfors Signed-off-by: Mauro Carvalho Chehab --- drivers/media/radio/tef6862.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/media/radio/tef6862.c b/drivers/media/radio/tef6862.c index d78afbb08569..06ac69245ca1 100644 --- a/drivers/media/radio/tef6862.c +++ b/drivers/media/radio/tef6862.c @@ -30,8 +30,8 @@ #define FREQ_MUL 16000 -#define TEF6862_LO_FREQ (875 * FREQ_MUL / 10) -#define TEF6862_HI_FREQ (108 * FREQ_MUL) +#define TEF6862_LO_FREQ (875U * FREQ_MUL / 10) +#define TEF6862_HI_FREQ (108U * FREQ_MUL) /* Write mode sub addresses */ #define WM_SUB_BANDWIDTH 0x0 @@ -104,6 +104,7 @@ static int tef6862_s_frequency(struct v4l2_subdev *sd, const struct v4l2_frequen { struct tef6862_state *state = to_state(sd); struct i2c_client *client = v4l2_get_subdevdata(sd); + unsigned freq = f->frequency; u16 pll; u8 i2cmsg[3]; int err; @@ -111,7 +112,8 @@ static int tef6862_s_frequency(struct v4l2_subdev *sd, const struct v4l2_frequen if (f->tuner != 0) return -EINVAL; - pll = 1964 + ((f->frequency - TEF6862_LO_FREQ) * 20) / FREQ_MUL; + clamp(freq, TEF6862_LO_FREQ, TEF6862_HI_FREQ); + pll = 1964 + ((freq - TEF6862_LO_FREQ) * 20) / FREQ_MUL; i2cmsg[0] = (MODE_PRESET << MODE_SHIFT) | WM_SUB_PLLM; i2cmsg[1] = (pll >> 8) & 0xff; i2cmsg[2] = pll & 0xff; @@ -120,7 +122,7 @@ static int tef6862_s_frequency(struct v4l2_subdev *sd, const struct v4l2_frequen if (err != sizeof(i2cmsg)) return err < 0 ? err : -EIO; - state->freq = f->frequency; + state->freq = freq; return 0; } From 8f9acd236d9e6bd805b0dac2d0ca59dcd89edc99 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Sun, 3 Feb 2013 09:10:46 -0300 Subject: [PATCH 0254/1048] [media] timblogiw: fix querycap MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Don't set version (the core does that for you), fill in device_caps and prefix bus_info with "platform:". Signed-off-by: Hans Verkuil Cc: Richard Röjfors Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/timblogiw.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/media/platform/timblogiw.c b/drivers/media/platform/timblogiw.c index 99861c631798..b557caf5b1a4 100644 --- a/drivers/media/platform/timblogiw.c +++ b/drivers/media/platform/timblogiw.c @@ -239,13 +239,12 @@ static int timblogiw_querycap(struct file *file, void *priv, struct video_device *vdev = video_devdata(file); dev_dbg(&vdev->dev, "%s: Entry\n", __func__); - memset(cap, 0, sizeof(*cap)); strncpy(cap->card, TIMBLOGIWIN_NAME, sizeof(cap->card)-1); strncpy(cap->driver, DRIVER_NAME, sizeof(cap->driver) - 1); - strlcpy(cap->bus_info, vdev->name, sizeof(cap->bus_info)); - cap->version = TIMBLOGIW_VERSION_CODE; - cap->capabilities = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING | + snprintf(cap->bus_info, sizeof(cap->bus_info), "platform:%s", vdev->name); + cap->device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING | V4L2_CAP_READWRITE; + cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS; return 0; } From 65a110dfb8f6c307712e3296a0f6312c3a211eb6 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Sun, 3 Feb 2013 09:43:15 -0300 Subject: [PATCH 0255/1048] [media] radio-sf16fmi: remove audio/input ioctls The audio and input ioctls do not apply to radio devices. Remove them. Signed-off-by: Hans Verkuil Cc: Ondrej Zary Signed-off-by: Mauro Carvalho Chehab --- drivers/media/radio/radio-sf16fmi.c | 30 ----------------------------- 1 file changed, 30 deletions(-) diff --git a/drivers/media/radio/radio-sf16fmi.c b/drivers/media/radio/radio-sf16fmi.c index adfcc61bdf0b..c1d51ec72831 100644 --- a/drivers/media/radio/radio-sf16fmi.c +++ b/drivers/media/radio/radio-sf16fmi.c @@ -218,32 +218,6 @@ static int vidioc_s_ctrl(struct file *file, void *priv, return -EINVAL; } -static int vidioc_g_input(struct file *filp, void *priv, unsigned int *i) -{ - *i = 0; - return 0; -} - -static int vidioc_s_input(struct file *filp, void *priv, unsigned int i) -{ - return i ? -EINVAL : 0; -} - -static int vidioc_g_audio(struct file *file, void *priv, - struct v4l2_audio *a) -{ - a->index = 0; - strlcpy(a->name, "Radio", sizeof(a->name)); - a->capability = V4L2_AUDCAP_STEREO; - return 0; -} - -static int vidioc_s_audio(struct file *file, void *priv, - const struct v4l2_audio *a) -{ - return a->index ? -EINVAL : 0; -} - static const struct v4l2_file_operations fmi_fops = { .owner = THIS_MODULE, .unlocked_ioctl = video_ioctl2, @@ -253,10 +227,6 @@ static const struct v4l2_ioctl_ops fmi_ioctl_ops = { .vidioc_querycap = vidioc_querycap, .vidioc_g_tuner = vidioc_g_tuner, .vidioc_s_tuner = vidioc_s_tuner, - .vidioc_g_audio = vidioc_g_audio, - .vidioc_s_audio = vidioc_s_audio, - .vidioc_g_input = vidioc_g_input, - .vidioc_s_input = vidioc_s_input, .vidioc_g_frequency = vidioc_g_frequency, .vidioc_s_frequency = vidioc_s_frequency, .vidioc_queryctrl = vidioc_queryctrl, From f90842d62b16356a8316528c91d0757a17d3e9e3 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Sun, 3 Feb 2013 09:44:14 -0300 Subject: [PATCH 0256/1048] [media] radio-sf16fmi: add device_caps support to querycap Signed-off-by: Hans Verkuil Cc: Ondrej Zary Signed-off-by: Mauro Carvalho Chehab --- drivers/media/radio/radio-sf16fmi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/media/radio/radio-sf16fmi.c b/drivers/media/radio/radio-sf16fmi.c index c1d51ec72831..80beda7781bc 100644 --- a/drivers/media/radio/radio-sf16fmi.c +++ b/drivers/media/radio/radio-sf16fmi.c @@ -121,7 +121,8 @@ static int vidioc_querycap(struct file *file, void *priv, strlcpy(v->driver, "radio-sf16fmi", sizeof(v->driver)); strlcpy(v->card, "SF16-FMI/FMP/FMD radio", sizeof(v->card)); strlcpy(v->bus_info, "ISA", sizeof(v->bus_info)); - v->capabilities = V4L2_CAP_TUNER | V4L2_CAP_RADIO; + v->device_caps = V4L2_CAP_TUNER | V4L2_CAP_RADIO; + v->capabilities = v->device_caps | V4L2_CAP_DEVICE_CAPS; return 0; } From 96bb42b8ab3d4f15b5e98a65c6d8decf36f3f930 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Fri, 31 May 2013 06:21:03 -0300 Subject: [PATCH 0257/1048] [media] radio-sf16fmi: clamp frequency Signed-off-by: Hans Verkuil Cc: Ondrej Zary Signed-off-by: Mauro Carvalho Chehab --- drivers/media/radio/radio-sf16fmi.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/media/radio/radio-sf16fmi.c b/drivers/media/radio/radio-sf16fmi.c index 80beda7781bc..9cd0338a3d2b 100644 --- a/drivers/media/radio/radio-sf16fmi.c +++ b/drivers/media/radio/radio-sf16fmi.c @@ -55,8 +55,8 @@ static struct fmi fmi_card; static struct pnp_dev *dev; bool pnp_attached; -#define RSF16_MINFREQ (87 * 16000) -#define RSF16_MAXFREQ (108 * 16000) +#define RSF16_MINFREQ (87U * 16000) +#define RSF16_MAXFREQ (108U * 16000) #define FMI_BIT_TUN_CE (1 << 0) #define FMI_BIT_TUN_CLK (1 << 1) @@ -155,15 +155,14 @@ static int vidioc_s_frequency(struct file *file, void *priv, const struct v4l2_frequency *f) { struct fmi *fmi = video_drvdata(file); + unsigned freq = f->frequency; if (f->tuner != 0 || f->type != V4L2_TUNER_RADIO) return -EINVAL; - if (f->frequency < RSF16_MINFREQ || - f->frequency > RSF16_MAXFREQ) - return -EINVAL; + clamp(freq, RSF16_MINFREQ, RSF16_MAXFREQ); /* rounding in steps of 800 to match the freq that will be used */ - lm7000_set_freq((f->frequency / 800) * 800, fmi, fmi_set_pins); + lm7000_set_freq((freq / 800) * 800, fmi, fmi_set_pins); return 0; } From 268d06bb765da0bdd17344a6877f5898713a7cbb Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Sun, 3 Feb 2013 09:51:06 -0300 Subject: [PATCH 0258/1048] [media] radio-sf16fmi: convert to the control framework Signed-off-by: Hans Verkuil Cc: Ondrej Zary Signed-off-by: Mauro Carvalho Chehab --- drivers/media/radio/radio-sf16fmi.c | 56 +++++++++++++---------------- 1 file changed, 25 insertions(+), 31 deletions(-) diff --git a/drivers/media/radio/radio-sf16fmi.c b/drivers/media/radio/radio-sf16fmi.c index 9cd0338a3d2b..b058f36669ee 100644 --- a/drivers/media/radio/radio-sf16fmi.c +++ b/drivers/media/radio/radio-sf16fmi.c @@ -27,6 +27,7 @@ #include /* outb, outb_p */ #include #include +#include #include "lm7000.h" MODULE_AUTHOR("Petr Vandrovec, vandrove@vc.cvut.cz and M. Kirkwood"); @@ -44,6 +45,7 @@ module_param(radio_nr, int, 0); struct fmi { struct v4l2_device v4l2_dev; + struct v4l2_ctrl_handler hdl; struct video_device vdev; int io; bool mute; @@ -178,46 +180,26 @@ static int vidioc_g_frequency(struct file *file, void *priv, return 0; } -static int vidioc_queryctrl(struct file *file, void *priv, - struct v4l2_queryctrl *qc) +static int fmi_s_ctrl(struct v4l2_ctrl *ctrl) { - switch (qc->id) { - case V4L2_CID_AUDIO_MUTE: - return v4l2_ctrl_query_fill(qc, 0, 1, 1, 1); - } - return -EINVAL; -} - -static int vidioc_g_ctrl(struct file *file, void *priv, - struct v4l2_control *ctrl) -{ - struct fmi *fmi = video_drvdata(file); + struct fmi *fmi = container_of(ctrl->handler, struct fmi, hdl); switch (ctrl->id) { case V4L2_CID_AUDIO_MUTE: - ctrl->value = fmi->mute; - return 0; - } - return -EINVAL; -} - -static int vidioc_s_ctrl(struct file *file, void *priv, - struct v4l2_control *ctrl) -{ - struct fmi *fmi = video_drvdata(file); - - switch (ctrl->id) { - case V4L2_CID_AUDIO_MUTE: - if (ctrl->value) + if (ctrl->val) fmi_mute(fmi); else fmi_unmute(fmi); - fmi->mute = ctrl->value; + fmi->mute = ctrl->val; return 0; } return -EINVAL; } +static const struct v4l2_ctrl_ops fmi_ctrl_ops = { + .s_ctrl = fmi_s_ctrl, +}; + static const struct v4l2_file_operations fmi_fops = { .owner = THIS_MODULE, .unlocked_ioctl = video_ioctl2, @@ -229,9 +211,6 @@ static const struct v4l2_ioctl_ops fmi_ioctl_ops = { .vidioc_s_tuner = vidioc_s_tuner, .vidioc_g_frequency = vidioc_g_frequency, .vidioc_s_frequency = vidioc_s_frequency, - .vidioc_queryctrl = vidioc_queryctrl, - .vidioc_g_ctrl = vidioc_g_ctrl, - .vidioc_s_ctrl = vidioc_s_ctrl, }; /* ladis: this is my card. does any other types exist? */ @@ -281,6 +260,7 @@ static int __init fmi_init(void) { struct fmi *fmi = &fmi_card; struct v4l2_device *v4l2_dev = &fmi->v4l2_dev; + struct v4l2_ctrl_handler *hdl = &fmi->hdl; int res, i; int probe_ports[] = { 0, 0x284, 0x384 }; @@ -333,6 +313,18 @@ static int __init fmi_init(void) return res; } + v4l2_ctrl_handler_init(hdl, 1); + v4l2_ctrl_new_std(hdl, &fmi_ctrl_ops, + V4L2_CID_AUDIO_MUTE, 0, 1, 1, 1); + v4l2_dev->ctrl_handler = hdl; + if (hdl->error) { + res = hdl->error; + v4l2_err(v4l2_dev, "Could not register controls\n"); + v4l2_ctrl_handler_free(hdl); + v4l2_device_unregister(v4l2_dev); + return res; + } + strlcpy(fmi->vdev.name, v4l2_dev->name, sizeof(fmi->vdev.name)); fmi->vdev.v4l2_dev = v4l2_dev; fmi->vdev.fops = &fmi_fops; @@ -346,6 +338,7 @@ static int __init fmi_init(void) fmi_mute(fmi); if (video_register_device(&fmi->vdev, VFL_TYPE_RADIO, radio_nr) < 0) { + v4l2_ctrl_handler_free(hdl); v4l2_device_unregister(v4l2_dev); release_region(fmi->io, 2); if (pnp_attached) @@ -361,6 +354,7 @@ static void __exit fmi_exit(void) { struct fmi *fmi = &fmi_card; + v4l2_ctrl_handler_free(&fmi->hdl); video_unregister_device(&fmi->vdev); v4l2_device_unregister(&fmi->v4l2_dev); release_region(fmi->io, 2); From 0dc5d82dcdfcec4d195b70fe8c0a13e5e6dd8d5a Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Sun, 3 Feb 2013 09:51:59 -0300 Subject: [PATCH 0259/1048] [media] radio-sf16fmi: add control event and prio support Signed-off-by: Hans Verkuil Cc: Ondrej Zary Signed-off-by: Mauro Carvalho Chehab --- drivers/media/radio/radio-sf16fmi.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/media/radio/radio-sf16fmi.c b/drivers/media/radio/radio-sf16fmi.c index b058f36669ee..9e712c8310f2 100644 --- a/drivers/media/radio/radio-sf16fmi.c +++ b/drivers/media/radio/radio-sf16fmi.c @@ -28,6 +28,7 @@ #include #include #include +#include #include "lm7000.h" MODULE_AUTHOR("Petr Vandrovec, vandrove@vc.cvut.cz and M. Kirkwood"); @@ -202,6 +203,9 @@ static const struct v4l2_ctrl_ops fmi_ctrl_ops = { static const struct v4l2_file_operations fmi_fops = { .owner = THIS_MODULE, + .open = v4l2_fh_open, + .release = v4l2_fh_release, + .poll = v4l2_ctrl_poll, .unlocked_ioctl = video_ioctl2, }; @@ -211,6 +215,9 @@ static const struct v4l2_ioctl_ops fmi_ioctl_ops = { .vidioc_s_tuner = vidioc_s_tuner, .vidioc_g_frequency = vidioc_g_frequency, .vidioc_s_frequency = vidioc_s_frequency, + .vidioc_log_status = v4l2_ctrl_log_status, + .vidioc_subscribe_event = v4l2_ctrl_subscribe_event, + .vidioc_unsubscribe_event = v4l2_event_unsubscribe, }; /* ladis: this is my card. does any other types exist? */ @@ -330,6 +337,7 @@ static int __init fmi_init(void) fmi->vdev.fops = &fmi_fops; fmi->vdev.ioctl_ops = &fmi_ioctl_ops; fmi->vdev.release = video_device_release_empty; + set_bit(V4L2_FL_USE_FH_PRIO, &fmi->vdev.flags); video_set_drvdata(&fmi->vdev, fmi); mutex_init(&fmi->lock); From 8c84ac51df883eee994913a33be888553e821005 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Mon, 3 Jun 2013 05:36:38 -0300 Subject: [PATCH 0260/1048] [media] mcam-core: replace current_norm by g_std The current_norm field is deprecated, replace this by properly implementing g_std. Signed-off-by: Hans Verkuil Cc: Jonathan Corbet Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/marvell-ccic/mcam-core.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/marvell-ccic/mcam-core.c b/drivers/media/platform/marvell-ccic/mcam-core.c index c69cfc4413fc..0821ed08c122 100644 --- a/drivers/media/platform/marvell-ccic/mcam-core.c +++ b/drivers/media/platform/marvell-ccic/mcam-core.c @@ -1344,6 +1344,12 @@ static int mcam_vidioc_s_std(struct file *filp, void *priv, v4l2_std_id a) return 0; } +static int mcam_vidioc_g_std(struct file *filp, void *priv, v4l2_std_id *a) +{ + *a = V4L2_STD_NTSC_M; + return 0; +} + /* * G/S_PARM. Most of this is done by the sensor, but we are * the level which controls the number of read buffers. @@ -1433,6 +1439,7 @@ static const struct v4l2_ioctl_ops mcam_v4l_ioctl_ops = { .vidioc_g_input = mcam_vidioc_g_input, .vidioc_s_input = mcam_vidioc_s_input, .vidioc_s_std = mcam_vidioc_s_std, + .vidioc_g_std = mcam_vidioc_g_std, .vidioc_reqbufs = mcam_vidioc_reqbufs, .vidioc_querybuf = mcam_vidioc_querybuf, .vidioc_qbuf = mcam_vidioc_qbuf, @@ -1558,7 +1565,6 @@ static const struct v4l2_file_operations mcam_v4l_fops = { static struct video_device mcam_v4l_template = { .name = "mcam", .tvnorms = V4L2_STD_NTSC_M, - .current_norm = V4L2_STD_NTSC_M, /* make mplayer happy */ .fops = &mcam_v4l_fops, .ioctl_ops = &mcam_v4l_ioctl_ops, From d31e545b00057516eac84ff0e2675bf802c2a522 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Mon, 3 Jun 2013 05:36:39 -0300 Subject: [PATCH 0261/1048] [media] via-camera: replace current_norm by g_std The current_norm field is deprecated. Replace it by properly implementing g_std. Signed-off-by: Hans Verkuil Cc: Jonathan Corbet Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/via-camera.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/via-camera.c b/drivers/media/platform/via-camera.c index e3438277b80b..b4f9d03636e3 100644 --- a/drivers/media/platform/via-camera.c +++ b/drivers/media/platform/via-camera.c @@ -837,6 +837,12 @@ static int viacam_s_std(struct file *filp, void *priv, v4l2_std_id std) return 0; } +static int viacam_g_std(struct file *filp, void *priv, v4l2_std_id *std) +{ + *std = V4L2_STD_NTSC_M; + return 0; +} + /* * Video format stuff. Here is our default format until * user space messes with things. @@ -1163,6 +1169,7 @@ static const struct v4l2_ioctl_ops viacam_ioctl_ops = { .vidioc_g_input = viacam_g_input, .vidioc_s_input = viacam_s_input, .vidioc_s_std = viacam_s_std, + .vidioc_g_std = viacam_g_std, .vidioc_enum_fmt_vid_cap = viacam_enum_fmt_vid_cap, .vidioc_try_fmt_vid_cap = viacam_try_fmt_vid_cap, .vidioc_g_fmt_vid_cap = viacam_g_fmt_vid_cap, @@ -1250,7 +1257,6 @@ static struct video_device viacam_v4l_template = { .name = "via-camera", .minor = -1, .tvnorms = V4L2_STD_NTSC_M, - .current_norm = V4L2_STD_NTSC_M, .fops = &viacam_fops, .ioctl_ops = &viacam_ioctl_ops, .release = video_device_release_empty, /* Check this */ From 5d40810812af73c812613638140c75d351422d9d Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Mon, 3 Jun 2013 05:36:40 -0300 Subject: [PATCH 0262/1048] [media] sh_vou: remove current_norm The current_norm field is deprecated and is replaced by g_std. This driver already implements g_std, so just remove current_norm. Signed-off-by: Hans Verkuil Acked-by: Guennadi Liakhovetski Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/sh_vou.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/media/platform/sh_vou.c b/drivers/media/platform/sh_vou.c index fa8ae7241521..7a9c5e9329f2 100644 --- a/drivers/media/platform/sh_vou.c +++ b/drivers/media/platform/sh_vou.c @@ -1282,7 +1282,6 @@ static const struct video_device sh_vou_video_template = { .fops = &sh_vou_fops, .ioctl_ops = &sh_vou_ioctl_ops, .tvnorms = V4L2_STD_525_60, /* PAL only supported in 8-bit non-bt656 mode */ - .current_norm = V4L2_STD_NTSC_M, .vfl_dir = VFL_DIR_TX, }; @@ -1321,7 +1320,7 @@ static int sh_vou_probe(struct platform_device *pdev) pix = &vou_dev->pix; /* Fill in defaults */ - vou_dev->std = sh_vou_video_template.current_norm; + vou_dev->std = V4L2_STD_NTSC_M; rect->left = 0; rect->top = 0; rect->width = VOU_MAX_IMAGE_WIDTH; From 2766a7a99950b5a0033b449dacc04070654b0357 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Mon, 3 Jun 2013 05:36:41 -0300 Subject: [PATCH 0263/1048] [media] soc_camera: remove use of current_norm The current_norm field is deprecated, so don't set it. Since it is set to V4L2_STD_UNKNOWN which is 0 it didn't do anything anyway. Also remove a few other unnecessary uses of V4L2_STD_UNKNOWN. Signed-off-by: Hans Verkuil Acked-by: Guennadi Liakhovetski Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/soc_camera/soc_camera.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/media/platform/soc_camera/soc_camera.c b/drivers/media/platform/soc_camera/soc_camera.c index 68efade15a7c..0252fbb48154 100644 --- a/drivers/media/platform/soc_camera/soc_camera.c +++ b/drivers/media/platform/soc_camera/soc_camera.c @@ -235,7 +235,6 @@ static int soc_camera_enum_input(struct file *file, void *priv, /* default is camera */ inp->type = V4L2_INPUT_TYPE_CAMERA; - inp->std = V4L2_STD_UNKNOWN; strcpy(inp->name, "Camera"); return 0; @@ -1479,11 +1478,9 @@ static int video_dev_create(struct soc_camera_device *icd) strlcpy(vdev->name, ici->drv_name, sizeof(vdev->name)); vdev->parent = icd->pdev; - vdev->current_norm = V4L2_STD_UNKNOWN; vdev->fops = &soc_camera_fops; vdev->ioctl_ops = &soc_camera_ioctl_ops; vdev->release = video_device_release; - vdev->tvnorms = V4L2_STD_UNKNOWN; vdev->ctrl_handler = &icd->ctrl_handler; vdev->lock = &ici->host_lock; From 28221f88efcf70814491a9695625d8257282d994 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Mon, 3 Jun 2013 05:36:43 -0300 Subject: [PATCH 0264/1048] [media] fsl-viu: remove current_norm The use of current_norm is deprecated, so remove it. This driver actually already implements g_std, which overrides current_norm, but the 'std' field was never initialized correctly. This has been fixed as well. Signed-off-by: Hans Verkuil Cc: Anatolij Gustschin Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/fsl-viu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/platform/fsl-viu.c b/drivers/media/platform/fsl-viu.c index 3a6a0dcdc3e4..221ec428a01e 100644 --- a/drivers/media/platform/fsl-viu.c +++ b/drivers/media/platform/fsl-viu.c @@ -1475,7 +1475,6 @@ static struct video_device viu_template = { .release = video_device_release, .tvnorms = V4L2_STD_NTSC_M | V4L2_STD_PAL, - .current_norm = V4L2_STD_NTSC_M, }; static int viu_of_probe(struct platform_device *op) @@ -1546,6 +1545,7 @@ static int viu_of_probe(struct platform_device *op) viu_dev->vidq.timeout.function = viu_vid_timeout; viu_dev->vidq.timeout.data = (unsigned long)viu_dev; init_timer(&viu_dev->vidq.timeout); + viu_dev->std = V4L2_STD_NTSC_M; viu_dev->first = 1; /* Allocate memory for video device */ From 804be2d4933a44ce76bce3d12b09c5db980523a4 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Mon, 3 Jun 2013 05:36:44 -0300 Subject: [PATCH 0265/1048] [media] tm6000: remove deprecated current_norm Replace current_norm by g_std. Also initialize the standard to the more common NTSC-M format (which is also what current_norm used). Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/usb/tm6000/tm6000-cards.c | 2 +- drivers/media/usb/tm6000/tm6000-video.c | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/drivers/media/usb/tm6000/tm6000-cards.c b/drivers/media/usb/tm6000/tm6000-cards.c index 307d8c5fb7cd..1ccaaddaa307 100644 --- a/drivers/media/usb/tm6000/tm6000-cards.c +++ b/drivers/media/usb/tm6000/tm6000-cards.c @@ -1114,7 +1114,7 @@ static int tm6000_init_dev(struct tm6000_core *dev) /* Default values for STD and resolutions */ dev->width = 720; dev->height = 480; - dev->norm = V4L2_STD_PAL_M; + dev->norm = V4L2_STD_NTSC_M; /* Configure tuner */ tm6000_config_tuner(dev); diff --git a/drivers/media/usb/tm6000/tm6000-video.c b/drivers/media/usb/tm6000/tm6000-video.c index a78de1d1bc9e..cc1aa14996ff 100644 --- a/drivers/media/usb/tm6000/tm6000-video.c +++ b/drivers/media/usb/tm6000/tm6000-video.c @@ -1076,6 +1076,15 @@ static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id norm) return 0; } +static int vidioc_g_std(struct file *file, void *priv, v4l2_std_id *norm) +{ + struct tm6000_fh *fh = priv; + struct tm6000_core *dev = fh->dev; + + *norm = dev->norm; + return 0; +} + static const char *iname[] = { [TM6000_INPUT_TV] = "Television", [TM6000_INPUT_COMPOSITE1] = "Composite 1", @@ -1134,7 +1143,7 @@ static int vidioc_s_input(struct file *file, void *priv, unsigned int i) dev->input = i; - rc = vidioc_s_std(file, priv, dev->vfd->current_norm); + rc = vidioc_s_std(file, priv, dev->norm); return rc; } @@ -1547,6 +1556,7 @@ static const struct v4l2_ioctl_ops video_ioctl_ops = { .vidioc_try_fmt_vid_cap = vidioc_try_fmt_vid_cap, .vidioc_s_fmt_vid_cap = vidioc_s_fmt_vid_cap, .vidioc_s_std = vidioc_s_std, + .vidioc_g_std = vidioc_g_std, .vidioc_enum_input = vidioc_enum_input, .vidioc_g_input = vidioc_g_input, .vidioc_s_input = vidioc_s_input, @@ -1570,7 +1580,6 @@ static struct video_device tm6000_template = { .ioctl_ops = &video_ioctl_ops, .release = video_device_release, .tvnorms = TM6000_STD, - .current_norm = V4L2_STD_NTSC_M, }; static const struct v4l2_file_operations radio_fops = { From 8d2d41e92d99e25f7d42fc83fc39096d89caa35e Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Mon, 3 Jun 2013 05:36:45 -0300 Subject: [PATCH 0266/1048] [media] saa7164: replace current_norm by g_std current_norm is deprecated. Replace it by g_std. Signed-off-by: Hans Verkuil Cc: Steven Toth Signed-off-by: Mauro Carvalho Chehab --- drivers/media/pci/saa7164/saa7164-encoder.c | 13 ++++++++++++- drivers/media/pci/saa7164/saa7164-vbi.c | 13 ++++++++++++- drivers/media/pci/saa7164/saa7164.h | 1 + 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/drivers/media/pci/saa7164/saa7164-encoder.c b/drivers/media/pci/saa7164/saa7164-encoder.c index e4f53a55eab1..7b7ed97b8503 100644 --- a/drivers/media/pci/saa7164/saa7164-encoder.c +++ b/drivers/media/pci/saa7164/saa7164-encoder.c @@ -228,6 +228,7 @@ static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id id) return -EINVAL; port->encodernorm = saa7164_tvnorms[i]; + port->std = id; /* Update the audio decoder while is not running in * auto detect mode. @@ -239,6 +240,15 @@ static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id id) return 0; } +static int vidioc_g_std(struct file *file, void *priv, v4l2_std_id *id) +{ + struct saa7164_encoder_fh *fh = file->private_data; + struct saa7164_port *port = fh->port; + + *id = port->std; + return 0; +} + static int vidioc_enum_input(struct file *file, void *priv, struct v4l2_input *i) { @@ -1290,6 +1300,7 @@ static const struct v4l2_file_operations mpeg_fops = { static const struct v4l2_ioctl_ops mpeg_ioctl_ops = { .vidioc_s_std = vidioc_s_std, + .vidioc_g_std = vidioc_g_std, .vidioc_enum_input = vidioc_enum_input, .vidioc_g_input = vidioc_g_input, .vidioc_s_input = vidioc_s_input, @@ -1316,7 +1327,6 @@ static struct video_device saa7164_mpeg_template = { .ioctl_ops = &mpeg_ioctl_ops, .minor = -1, .tvnorms = SAA7164_NORMS, - .current_norm = V4L2_STD_NTSC_M, }; static struct video_device *saa7164_encoder_alloc( @@ -1383,6 +1393,7 @@ int saa7164_encoder_register(struct saa7164_port *port) port->encoder_params.ctl_aspect = V4L2_MPEG_VIDEO_ASPECT_4x3; port->encoder_params.refdist = 1; port->encoder_params.gop_size = SAA7164_ENCODER_DEFAULT_GOP_SIZE; + port->std = V4L2_STD_NTSC_M; if (port->encodernorm.id & V4L2_STD_525_60) port->height = 480; diff --git a/drivers/media/pci/saa7164/saa7164-vbi.c b/drivers/media/pci/saa7164/saa7164-vbi.c index 5a1a69b3dd15..552c01ad9f63 100644 --- a/drivers/media/pci/saa7164/saa7164-vbi.c +++ b/drivers/media/pci/saa7164/saa7164-vbi.c @@ -200,6 +200,7 @@ static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id id) return -EINVAL; port->encodernorm = saa7164_tvnorms[i]; + port->std = id; /* Update the audio decoder while is not running in * auto detect mode. @@ -211,6 +212,15 @@ static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id id) return 0; } +static int vidioc_g_std(struct file *file, void *priv, v4l2_std_id *id) +{ + struct saa7164_encoder_fh *fh = file->private_data; + struct saa7164_port *port = fh->port; + + *id = port->std; + return 0; +} + static int vidioc_enum_input(struct file *file, void *priv, struct v4l2_input *i) { @@ -1236,6 +1246,7 @@ static const struct v4l2_file_operations vbi_fops = { static const struct v4l2_ioctl_ops vbi_ioctl_ops = { .vidioc_s_std = vidioc_s_std, + .vidioc_g_std = vidioc_g_std, .vidioc_enum_input = vidioc_enum_input, .vidioc_g_input = vidioc_g_input, .vidioc_s_input = vidioc_s_input, @@ -1265,7 +1276,6 @@ static struct video_device saa7164_vbi_template = { .ioctl_ops = &vbi_ioctl_ops, .minor = -1, .tvnorms = SAA7164_NORMS, - .current_norm = V4L2_STD_NTSC_M, }; static struct video_device *saa7164_vbi_alloc( @@ -1324,6 +1334,7 @@ int saa7164_vbi_register(struct saa7164_port *port) goto failed; } + port->std = V4L2_STD_NTSC_M; video_set_drvdata(port->v4l_device, port); result = video_register_device(port->v4l_device, VFL_TYPE_VBI, -1); diff --git a/drivers/media/pci/saa7164/saa7164.h b/drivers/media/pci/saa7164/saa7164.h index 8d9c7e692242..2df47ea28289 100644 --- a/drivers/media/pci/saa7164/saa7164.h +++ b/drivers/media/pci/saa7164/saa7164.h @@ -375,6 +375,7 @@ struct saa7164_port { /* Encoder */ /* Defaults established in saa7164-encoder.c */ struct saa7164_tvnorm encodernorm; + v4l2_std_id std; u32 height; u32 width; u32 freq; From 9c1f5df81300b89c5c5c76b101502dad3977fdcb Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Mon, 3 Jun 2013 05:36:46 -0300 Subject: [PATCH 0267/1048] [media] cx23885: remove use of deprecated current_norm The use of current_norm can be dropped. The g_std ioctl was already implemented, so current_norm didn't do anything useful anyway. Signed-off-by: Hans Verkuil Cc: Steven Toth Signed-off-by: Mauro Carvalho Chehab --- drivers/media/pci/cx23885/cx23885-417.c | 5 +---- drivers/media/pci/cx23885/cx23885-video.c | 7 ++----- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/drivers/media/pci/cx23885/cx23885-417.c b/drivers/media/pci/cx23885/cx23885-417.c index 68568d35a692..f4f9ef0d98e2 100644 --- a/drivers/media/pci/cx23885/cx23885-417.c +++ b/drivers/media/pci/cx23885/cx23885-417.c @@ -1217,8 +1217,7 @@ static int vidioc_g_std(struct file *file, void *priv, v4l2_std_id *id) struct cx23885_fh *fh = file->private_data; struct cx23885_dev *dev = fh->dev; - call_all(dev, core, g_std, id); - + *id = dev->tvnorm; return 0; } @@ -1661,7 +1660,6 @@ static struct v4l2_file_operations mpeg_fops = { }; static const struct v4l2_ioctl_ops mpeg_ioctl_ops = { - .vidioc_querystd = vidioc_g_std, .vidioc_g_std = vidioc_g_std, .vidioc_s_std = vidioc_s_std, .vidioc_enum_input = vidioc_enum_input, @@ -1702,7 +1700,6 @@ static struct video_device cx23885_mpeg_template = { .fops = &mpeg_fops, .ioctl_ops = &mpeg_ioctl_ops, .tvnorms = CX23885_NORMS, - .current_norm = V4L2_STD_NTSC_M, }; void cx23885_417_unregister(struct cx23885_dev *dev) diff --git a/drivers/media/pci/cx23885/cx23885-video.c b/drivers/media/pci/cx23885/cx23885-video.c index ce057398c632..e33d1a7dfdd0 100644 --- a/drivers/media/pci/cx23885/cx23885-video.c +++ b/drivers/media/pci/cx23885/cx23885-video.c @@ -1254,8 +1254,7 @@ static int vidioc_g_std(struct file *file, void *priv, v4l2_std_id *id) struct cx23885_dev *dev = ((struct cx23885_fh *)priv)->dev; dprintk(1, "%s()\n", __func__); - call_all(dev, core, g_std, id); - + *id = dev->tvnorm; return 0; } @@ -1743,7 +1742,6 @@ static const struct v4l2_ioctl_ops video_ioctl_ops = { .vidioc_dqbuf = vidioc_dqbuf, .vidioc_s_std = vidioc_s_std, .vidioc_g_std = vidioc_g_std, - .vidioc_querystd = vidioc_g_std, .vidioc_enum_input = vidioc_enum_input, .vidioc_g_input = vidioc_g_input, .vidioc_s_input = vidioc_s_input, @@ -1773,7 +1771,6 @@ static struct video_device cx23885_video_template = { .fops = &video_fops, .ioctl_ops = &video_ioctl_ops, .tvnorms = CX23885_NORMS, - .current_norm = V4L2_STD_NTSC_M, }; static const struct v4l2_file_operations radio_fops = { @@ -1822,7 +1819,7 @@ int cx23885_video_register(struct cx23885_dev *dev) cx23885_vbi_template = cx23885_video_template; strcpy(cx23885_vbi_template.name, "cx23885-vbi"); - dev->tvnorm = cx23885_video_template.current_norm; + dev->tvnorm = V4L2_STD_NTSC_M; /* init video dma queues */ INIT_LIST_HEAD(&dev->vidq.active); From 3b8436d9db43a810dd44393733b34fda6e0f0b9d Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Mon, 3 Jun 2013 05:36:47 -0300 Subject: [PATCH 0268/1048] [media] usbvision: replace current_norm by g_std current_norm use is deprecated because it is per-devicenode and if you have more device nodes all dependent on the same video source, then this no longer works. Just implement g_std instead. Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/usb/usbvision/usbvision-video.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/media/usb/usbvision/usbvision-video.c b/drivers/media/usb/usbvision/usbvision-video.c index d34c2afe2c24..7ad872a3e31a 100644 --- a/drivers/media/usb/usbvision/usbvision-video.c +++ b/drivers/media/usb/usbvision/usbvision-video.c @@ -608,6 +608,14 @@ static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id id) return 0; } +static int vidioc_g_std(struct file *file, void *priv, v4l2_std_id *id) +{ + struct usb_usbvision *usbvision = video_drvdata(file); + + *id = usbvision->tvnorm_id; + return 0; +} + static int vidioc_g_tuner(struct file *file, void *priv, struct v4l2_tuner *vt) { @@ -1248,6 +1256,7 @@ static const struct v4l2_ioctl_ops usbvision_ioctl_ops = { .vidioc_qbuf = vidioc_qbuf, .vidioc_dqbuf = vidioc_dqbuf, .vidioc_s_std = vidioc_s_std, + .vidioc_g_std = vidioc_g_std, .vidioc_enum_input = vidioc_enum_input, .vidioc_g_input = vidioc_g_input, .vidioc_s_input = vidioc_s_input, @@ -1274,7 +1283,6 @@ static struct video_device usbvision_video_template = { .name = "usbvision-video", .release = video_device_release, .tvnorms = USBVISION_NORMS, - .current_norm = V4L2_STD_PAL }; @@ -1307,9 +1315,6 @@ static struct video_device usbvision_radio_template = { .name = "usbvision-radio", .release = video_device_release, .ioctl_ops = &usbvision_radio_ioctl_ops, - - .tvnorms = USBVISION_NORMS, - .current_norm = V4L2_STD_PAL }; From 776572d95f0a80a3ae732569fd2ee6eadc9c8486 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Mon, 3 Jun 2013 05:36:48 -0300 Subject: [PATCH 0269/1048] [media] saa7134: drop deprecated current_norm Since this driver properly implements g_std, the current_norm field is actually unused anyway. Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/pci/saa7134/saa7134-empress.c | 1 - drivers/media/pci/saa7134/saa7134-video.c | 1 - 2 files changed, 2 deletions(-) diff --git a/drivers/media/pci/saa7134/saa7134-empress.c b/drivers/media/pci/saa7134/saa7134-empress.c index 05ab2cb7ef3c..973fa65eb3d3 100644 --- a/drivers/media/pci/saa7134/saa7134-empress.c +++ b/drivers/media/pci/saa7134/saa7134-empress.c @@ -471,7 +471,6 @@ static struct video_device saa7134_empress_template = { .ioctl_ops = &ts_ioctl_ops, .tvnorms = SAA7134_NORMS, - .current_norm = V4L2_STD_PAL, }; static void empress_signal_update(struct work_struct *work) diff --git a/drivers/media/pci/saa7134/saa7134-video.c b/drivers/media/pci/saa7134/saa7134-video.c index db4cc1c54aa6..b78d515068a7 100644 --- a/drivers/media/pci/saa7134/saa7134-video.c +++ b/drivers/media/pci/saa7134/saa7134-video.c @@ -2439,7 +2439,6 @@ struct video_device saa7134_video_template = { .fops = &video_fops, .ioctl_ops = &video_ioctl_ops, .tvnorms = SAA7134_NORMS, - .current_norm = V4L2_STD_PAL, }; struct video_device saa7134_radio_template = { From 8f73d3bbf8b1114b1ae5ac8950104b3d5d01c7d2 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Mon, 3 Jun 2013 05:36:49 -0300 Subject: [PATCH 0270/1048] [media] dt3155v4l: remove deprecated current_norm Since this driver provides a g_std op the current_norm field isn't used anyway, so just drop it. Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/dt3155v4l/dt3155v4l.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/media/dt3155v4l/dt3155v4l.c b/drivers/staging/media/dt3155v4l/dt3155v4l.c index c32e0acde4f4..90d6ac469355 100644 --- a/drivers/staging/media/dt3155v4l/dt3155v4l.c +++ b/drivers/staging/media/dt3155v4l/dt3155v4l.c @@ -829,7 +829,6 @@ static struct video_device dt3155_vdev = { .minor = -1, .release = video_device_release, .tvnorms = DT3155_CURRENT_NORM, - .current_norm = DT3155_CURRENT_NORM, }; /* same as in drivers/base/dma-coherent.c */ From ca37157506ef53dcf41132aaedab70659509ccee Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Mon, 3 Jun 2013 05:36:50 -0300 Subject: [PATCH 0271/1048] [media] v4l2: remove deprecated current_norm support completely The use of current_norm to keep track of the current standard has been deprecated for quite some time. Now that all drivers that were using it have been converted to use g_std we can drop it from the core. It was a bad idea to introduce this at the time: since it is a per-device node field it didn't work for drivers that create multiple nodes, all sharing the same tuner (e.g. video and vbi nodes, or a raw video node and a compressed video node). In addition it was very surprising behavior that g_std was implemented in the core. Often drivers implemented both g_std and current_norm, because they didn't understand how it should be used. Since the benefits were very limited (if they were there at all), it is better to just drop it and require that drivers just implement g_std. Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/v4l2-core/v4l2-dev.c | 5 ++-- drivers/media/v4l2-core/v4l2-ioctl.c | 34 ++++------------------------ include/media/v4l2-dev.h | 1 - 3 files changed, 6 insertions(+), 34 deletions(-) diff --git a/drivers/media/v4l2-core/v4l2-dev.c b/drivers/media/v4l2-core/v4l2-dev.c index 5923c5dfacd5..2f3fac5345db 100644 --- a/drivers/media/v4l2-core/v4l2-dev.c +++ b/drivers/media/v4l2-core/v4l2-dev.c @@ -675,9 +675,8 @@ static void determine_valid_ioctls(struct video_device *vdev) SET_VALID_IOCTL(ops, VIDIOC_PREPARE_BUF, vidioc_prepare_buf); if (ops->vidioc_s_std) set_bit(_IOC_NR(VIDIOC_ENUMSTD), valid_ioctls); - if (ops->vidioc_g_std || vdev->current_norm) - set_bit(_IOC_NR(VIDIOC_G_STD), valid_ioctls); SET_VALID_IOCTL(ops, VIDIOC_S_STD, vidioc_s_std); + SET_VALID_IOCTL(ops, VIDIOC_G_STD, vidioc_g_std); if (is_rx) { SET_VALID_IOCTL(ops, VIDIOC_QUERYSTD, vidioc_querystd); SET_VALID_IOCTL(ops, VIDIOC_ENUMINPUT, vidioc_enum_input); @@ -705,7 +704,7 @@ static void determine_valid_ioctls(struct video_device *vdev) if (ops->vidioc_cropcap || ops->vidioc_g_selection) set_bit(_IOC_NR(VIDIOC_CROPCAP), valid_ioctls); if (ops->vidioc_g_parm || (vdev->vfl_type == VFL_TYPE_GRABBER && - (ops->vidioc_g_std || vdev->current_norm))) + ops->vidioc_g_std)) set_bit(_IOC_NR(VIDIOC_G_PARM), valid_ioctls); SET_VALID_IOCTL(ops, VIDIOC_S_PARM, vidioc_s_parm); SET_VALID_IOCTL(ops, VIDIOC_S_DV_TIMINGS, vidioc_s_dv_timings); diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c index 60b8c259da96..67745438e6ff 100644 --- a/drivers/media/v4l2-core/v4l2-ioctl.c +++ b/drivers/media/v4l2-core/v4l2-ioctl.c @@ -1364,40 +1364,18 @@ static int v4l_enumstd(const struct v4l2_ioctl_ops *ops, return 0; } -static int v4l_g_std(const struct v4l2_ioctl_ops *ops, - struct file *file, void *fh, void *arg) -{ - struct video_device *vfd = video_devdata(file); - v4l2_std_id *id = arg; - - /* Calls the specific handler */ - if (ops->vidioc_g_std) - return ops->vidioc_g_std(file, fh, arg); - if (vfd->current_norm) { - *id = vfd->current_norm; - return 0; - } - return -ENOTTY; -} - static int v4l_s_std(const struct v4l2_ioctl_ops *ops, struct file *file, void *fh, void *arg) { struct video_device *vfd = video_devdata(file); v4l2_std_id id = *(v4l2_std_id *)arg, norm; - int ret; norm = id & vfd->tvnorms; if (vfd->tvnorms && !norm) /* Check if std is supported */ return -EINVAL; /* Calls the specific handler */ - ret = ops->vidioc_s_std(file, fh, norm); - - /* Updates standard information */ - if (ret >= 0) - vfd->current_norm = norm; - return ret; + return ops->vidioc_s_std(file, fh, norm); } static int v4l_querystd(const struct v4l2_ioctl_ops *ops, @@ -1500,7 +1478,6 @@ static int v4l_prepare_buf(const struct v4l2_ioctl_ops *ops, static int v4l_g_parm(const struct v4l2_ioctl_ops *ops, struct file *file, void *fh, void *arg) { - struct video_device *vfd = video_devdata(file); struct v4l2_streamparm *p = arg; v4l2_std_id std; int ret = check_fmt(file, p->type); @@ -1509,16 +1486,13 @@ static int v4l_g_parm(const struct v4l2_ioctl_ops *ops, return ret; if (ops->vidioc_g_parm) return ops->vidioc_g_parm(file, fh, p); - std = vfd->current_norm; if (p->type != V4L2_BUF_TYPE_VIDEO_CAPTURE && p->type != V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) return -EINVAL; p->parm.capture.readbuffers = 2; - if (is_valid_ioctl(vfd, VIDIOC_G_STD) && ops->vidioc_g_std) - ret = ops->vidioc_g_std(file, fh, &std); + ret = ops->vidioc_g_std(file, fh, &std); if (ret == 0) - v4l2_video_std_frame_period(std, - &p->parm.capture.timeperframe); + v4l2_video_std_frame_period(std, &p->parm.capture.timeperframe); return ret; } @@ -2055,7 +2029,7 @@ static struct v4l2_ioctl_info v4l2_ioctls[] = { IOCTL_INFO_FNC(VIDIOC_STREAMOFF, v4l_streamoff, v4l_print_buftype, INFO_FL_PRIO | INFO_FL_QUEUE), IOCTL_INFO_FNC(VIDIOC_G_PARM, v4l_g_parm, v4l_print_streamparm, INFO_FL_CLEAR(v4l2_streamparm, type)), IOCTL_INFO_FNC(VIDIOC_S_PARM, v4l_s_parm, v4l_print_streamparm, INFO_FL_PRIO), - IOCTL_INFO_FNC(VIDIOC_G_STD, v4l_g_std, v4l_print_std, 0), + IOCTL_INFO_STD(VIDIOC_G_STD, vidioc_g_std, v4l_print_std, 0), IOCTL_INFO_FNC(VIDIOC_S_STD, v4l_s_std, v4l_print_std, INFO_FL_PRIO), IOCTL_INFO_FNC(VIDIOC_ENUMSTD, v4l_enumstd, v4l_print_standard, INFO_FL_CLEAR(v4l2_standard, index)), IOCTL_INFO_FNC(VIDIOC_ENUMINPUT, v4l_enuminput, v4l_print_enuminput, INFO_FL_CLEAR(v4l2_input, index)), diff --git a/include/media/v4l2-dev.h b/include/media/v4l2-dev.h index 95d1c91770f4..b2c3776a1cff 100644 --- a/include/media/v4l2-dev.h +++ b/include/media/v4l2-dev.h @@ -129,7 +129,6 @@ struct video_device /* Video standard vars */ v4l2_std_id tvnorms; /* Supported tv norms */ - v4l2_std_id current_norm; /* Current tvnorm */ /* callbacks */ void (*release)(struct video_device *vdev); From 7dd8fbbe50c01ead78483bc42f744d115afec96b Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Wed, 29 May 2013 10:18:54 -0300 Subject: [PATCH 0272/1048] [media] adv7183: fix querystd If no signal is detected, return V4L2_STD_UNKNOWN. Otherwise AND the standard with the detected standards. Note that the v4l2 core initializes the std with tvnorms before calling the querystd ioctl. Signed-off-by: Hans Verkuil Cc: Scott Jiang Acked-by: Scott Jiang Signed-off-by: Mauro Carvalho Chehab --- drivers/media/i2c/adv7183.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/media/i2c/adv7183.c b/drivers/media/i2c/adv7183.c index 980815d37bb1..6f738d8e3a8f 100644 --- a/drivers/media/i2c/adv7183.c +++ b/drivers/media/i2c/adv7183.c @@ -374,28 +374,28 @@ static int adv7183_querystd(struct v4l2_subdev *sd, v4l2_std_id *std) reg = adv7183_read(sd, ADV7183_STATUS_1); switch ((reg >> 0x4) & 0x7) { case 0: - *std = V4L2_STD_NTSC; + *std &= V4L2_STD_NTSC; break; case 1: - *std = V4L2_STD_NTSC_443; + *std &= V4L2_STD_NTSC_443; break; case 2: - *std = V4L2_STD_PAL_M; + *std &= V4L2_STD_PAL_M; break; case 3: - *std = V4L2_STD_PAL_60; + *std &= V4L2_STD_PAL_60; break; case 4: - *std = V4L2_STD_PAL; + *std &= V4L2_STD_PAL; break; case 5: - *std = V4L2_STD_SECAM; + *std &= V4L2_STD_SECAM; break; case 6: - *std = V4L2_STD_PAL_Nc; + *std &= V4L2_STD_PAL_Nc; break; case 7: - *std = V4L2_STD_SECAM; + *std &= V4L2_STD_SECAM; break; default: *std = V4L2_STD_UNKNOWN; From ddc7f72a3d4049653114647069f8044de5f2499d Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Wed, 29 May 2013 10:18:55 -0300 Subject: [PATCH 0273/1048] [media] bt819: fix querystd Return V4L2_STD_UNKNOWN if no signal is detected. Otherwise AND the standard mask with the detected standards. Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/i2c/bt819.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/media/i2c/bt819.c b/drivers/media/i2c/bt819.c index ae1eac01bbc7..369cf6ff88f7 100644 --- a/drivers/media/i2c/bt819.c +++ b/drivers/media/i2c/bt819.c @@ -215,15 +215,17 @@ static int bt819_status(struct v4l2_subdev *sd, u32 *pstatus, v4l2_std_id *pstd) struct bt819 *decoder = to_bt819(sd); int status = bt819_read(decoder, 0x00); int res = V4L2_IN_ST_NO_SIGNAL; - v4l2_std_id std; + v4l2_std_id std = pstd ? *pstd : V4L2_STD_ALL; if ((status & 0x80)) res = 0; + else + std = V4L2_STD_UNKNOWN; if ((status & 0x10)) - std = V4L2_STD_PAL; + std &= V4L2_STD_PAL; else - std = V4L2_STD_NTSC; + std &= V4L2_STD_NTSC; if (pstd) *pstd = std; if (pstatus) From e83c30c723caf5def0eb8eca5b106b39a3dab71c Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Wed, 29 May 2013 10:18:56 -0300 Subject: [PATCH 0274/1048] [media] ks0127: fix querystd Return V4L2_STD_UNKNOWN if no signal is detected. Otherwise AND the standard mask with the detected standards. Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/i2c/ks0127.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/drivers/media/i2c/ks0127.c b/drivers/media/i2c/ks0127.c index b5223e850a26..c3e94ae82c03 100644 --- a/drivers/media/i2c/ks0127.c +++ b/drivers/media/i2c/ks0127.c @@ -609,17 +609,24 @@ static int ks0127_status(struct v4l2_subdev *sd, u32 *pstatus, v4l2_std_id *pstd { int stat = V4L2_IN_ST_NO_SIGNAL; u8 status; - v4l2_std_id std = V4L2_STD_ALL; + v4l2_std_id std = pstd ? *pstd : V4L2_STD_ALL; status = ks0127_read(sd, KS_STAT); if (!(status & 0x20)) /* NOVID not set */ stat = 0; - if (!(status & 0x01)) /* CLOCK set */ + if (!(status & 0x01)) { /* CLOCK set */ stat |= V4L2_IN_ST_NO_COLOR; - if ((status & 0x08)) /* PALDET set */ - std = V4L2_STD_PAL; + std = V4L2_STD_UNKNOWN; + } else { + if ((status & 0x08)) /* PALDET set */ + std &= V4L2_STD_PAL; + else + std &= V4L2_STD_NTSC; + } + if ((status & 0x10)) /* PALDET set */ + std &= V4L2_STD_525_60; else - std = V4L2_STD_NTSC; + std &= V4L2_STD_625_50; if (pstd) *pstd = std; if (pstatus) From 416e87a41d8430b8dc0f1e94f925b6deb71debbc Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Wed, 29 May 2013 10:18:57 -0300 Subject: [PATCH 0275/1048] [media] saa7110: fix querystd Return V4L2_STD_UNKNOWN if no signal is detected. Otherwise AND the standard mask with the detected standards. Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/i2c/saa7110.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/media/i2c/saa7110.c b/drivers/media/i2c/saa7110.c index 532105de96f0..ac43e929a1d6 100644 --- a/drivers/media/i2c/saa7110.c +++ b/drivers/media/i2c/saa7110.c @@ -202,7 +202,7 @@ static v4l2_std_id determine_norm(struct v4l2_subdev *sd) status = saa7110_read(sd); if (status & 0x40) { v4l2_dbg(1, debug, sd, "status=0x%02x (no signal)\n", status); - return decoder->norm; /* no change*/ + return V4L2_STD_UNKNOWN; } if ((status & 3) == 0) { saa7110_write(sd, 0x06, 0x83); @@ -264,7 +264,7 @@ static int saa7110_g_input_status(struct v4l2_subdev *sd, u32 *pstatus) static int saa7110_querystd(struct v4l2_subdev *sd, v4l2_std_id *std) { - *(v4l2_std_id *)std = determine_norm(sd); + *std &= determine_norm(sd); return 0; } From af1f7284da471e68508457da92deab2517d48ff4 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Wed, 29 May 2013 10:18:58 -0300 Subject: [PATCH 0276/1048] [media] saa7115: fix querystd Return V4L2_STD_UNKNOWN if no signal is detected. Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/i2c/saa7115.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/media/i2c/saa7115.c b/drivers/media/i2c/saa7115.c index 90c43f3fb0f1..7fd766ec64c8 100644 --- a/drivers/media/i2c/saa7115.c +++ b/drivers/media/i2c/saa7115.c @@ -1428,6 +1428,7 @@ static int saa711x_querystd(struct v4l2_subdev *sd, v4l2_std_id *std) *std &= V4L2_STD_SECAM; break; default: + *std = V4L2_STD_UNKNOWN; /* Can't detect anything */ break; } @@ -1436,8 +1437,10 @@ static int saa711x_querystd(struct v4l2_subdev *sd, v4l2_std_id *std) v4l2_dbg(1, debug, sd, "Status byte 2 (0x1f)=0x%02x\n", reg1f); /* horizontal/vertical not locked */ - if (reg1f & 0x40) + if (reg1f & 0x40) { + *std = V4L2_STD_UNKNOWN; goto ret; + } if (reg1f & 0x20) *std &= V4L2_STD_525_60; From ec276a5a26200b342c11739b805b637961f660a7 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Wed, 29 May 2013 10:18:59 -0300 Subject: [PATCH 0277/1048] [media] saa7191: fix querystd Return V4L2_STD_UNKNOWN if no signal is detected. Otherwise AND the standard mask with the detected standards. Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/i2c/saa7191.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/media/i2c/saa7191.c b/drivers/media/i2c/saa7191.c index 08dcaecbeb98..606a4baf944d 100644 --- a/drivers/media/i2c/saa7191.c +++ b/drivers/media/i2c/saa7191.c @@ -271,7 +271,7 @@ static int saa7191_querystd(struct v4l2_subdev *sd, v4l2_std_id *norm) dprintk("SAA7191 extended signal auto-detection...\n"); - *norm = V4L2_STD_NTSC | V4L2_STD_PAL | V4L2_STD_SECAM; + *norm &= V4L2_STD_NTSC | V4L2_STD_PAL | V4L2_STD_SECAM; stdc &= ~SAA7191_STDC_SECS; ctl3 &= ~(SAA7191_CTL3_FSEL); @@ -302,7 +302,7 @@ static int saa7191_querystd(struct v4l2_subdev *sd, v4l2_std_id *norm) if (status & SAA7191_STATUS_FIDT) { /* 60Hz signal -> NTSC */ dprintk("60Hz signal: NTSC\n"); - *norm = V4L2_STD_NTSC; + *norm &= V4L2_STD_NTSC; return 0; } @@ -324,12 +324,13 @@ static int saa7191_querystd(struct v4l2_subdev *sd, v4l2_std_id *norm) if (status & SAA7191_STATUS_FIDT) { dprintk("No 50Hz signal\n"); saa7191_s_std(sd, old_norm); - return -EAGAIN; + *norm = V4L2_STD_UNKNOWN; + return 0; } if (status & SAA7191_STATUS_CODE) { dprintk("PAL\n"); - *norm = V4L2_STD_PAL; + *norm &= V4L2_STD_PAL; return saa7191_s_std(sd, old_norm); } @@ -349,18 +350,19 @@ static int saa7191_querystd(struct v4l2_subdev *sd, v4l2_std_id *norm) /* not 50Hz ? */ if (status & SAA7191_STATUS_FIDT) { dprintk("No 50Hz signal\n"); - err = -EAGAIN; + *norm = V4L2_STD_UNKNOWN; goto out; } if (status & SAA7191_STATUS_CODE) { /* Color detected -> SECAM */ dprintk("SECAM\n"); - *norm = V4L2_STD_SECAM; + *norm &= V4L2_STD_SECAM; return saa7191_s_std(sd, old_norm); } dprintk("No color detected with SECAM - Going back to PAL.\n"); + *norm = V4L2_STD_UNKNOWN; out: return saa7191_s_std(sd, old_norm); From 55852cbbae45e3bbb5ef7a5f1213ed34ff6209f9 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Wed, 29 May 2013 10:19:00 -0300 Subject: [PATCH 0278/1048] [media] tvp514x: fix querystd Return V4L2_STD_UNKNOWN if no signal is detected. Otherwise AND the standard mask with the detected standards. Signed-off-by: Hans Verkuil Acked-by: Lad, Prabhakar Signed-off-by: Mauro Carvalho Chehab --- drivers/media/i2c/tvp514x.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/media/i2c/tvp514x.c b/drivers/media/i2c/tvp514x.c index b5c17eb89b4e..b8061b5e3eac 100644 --- a/drivers/media/i2c/tvp514x.c +++ b/drivers/media/i2c/tvp514x.c @@ -542,8 +542,6 @@ static int tvp514x_querystd(struct v4l2_subdev *sd, v4l2_std_id *std_id) if (std_id == NULL) return -EINVAL; - *std_id = V4L2_STD_UNKNOWN; - /* To query the standard the TVP514x must power on the ADCs. */ if (!decoder->streaming) { tvp514x_s_stream(sd, 1); @@ -552,8 +550,10 @@ static int tvp514x_querystd(struct v4l2_subdev *sd, v4l2_std_id *std_id) /* query the current standard */ current_std = tvp514x_query_current_std(sd); - if (current_std == STD_INVALID) + if (current_std == STD_INVALID) { + *std_id = V4L2_STD_UNKNOWN; return 0; + } input_sel = decoder->input; @@ -594,10 +594,12 @@ static int tvp514x_querystd(struct v4l2_subdev *sd, v4l2_std_id *std_id) } /* check whether signal is locked */ sync_lock_status = tvp514x_read_reg(sd, REG_STATUS1); - if (lock_mask != (sync_lock_status & lock_mask)) + if (lock_mask != (sync_lock_status & lock_mask)) { + *std_id = V4L2_STD_UNKNOWN; return 0; /* No input detected */ + } - *std_id = decoder->std_list[current_std].standard.id; + *std_id &= decoder->std_list[current_std].standard.id; v4l2_dbg(1, debug, sd, "Current STD: %s\n", decoder->std_list[current_std].standard.name); From 32cb3b09f4716583921d3244f67893441bfb9af2 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Wed, 29 May 2013 10:19:01 -0300 Subject: [PATCH 0279/1048] [media] vpx3220: fix querystd Return V4L2_STD_UNKNOWN if no signal is detected. Otherwise AND the standard mask with the detected standards. Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/i2c/vpx3220.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/media/i2c/vpx3220.c b/drivers/media/i2c/vpx3220.c index 4c57d8a67c22..ece90df6a043 100644 --- a/drivers/media/i2c/vpx3220.c +++ b/drivers/media/i2c/vpx3220.c @@ -295,7 +295,7 @@ static int vpx3220_init(struct v4l2_subdev *sd, u32 val) static int vpx3220_status(struct v4l2_subdev *sd, u32 *pstatus, v4l2_std_id *pstd) { int res = V4L2_IN_ST_NO_SIGNAL, status; - v4l2_std_id std = 0; + v4l2_std_id std = pstd ? *pstd : V4L2_STD_ALL; status = vpx3220_fp_read(sd, 0x0f3); @@ -312,19 +312,21 @@ static int vpx3220_status(struct v4l2_subdev *sd, u32 *pstatus, v4l2_std_id *pst case 0x10: case 0x14: case 0x18: - std = V4L2_STD_PAL; + std &= V4L2_STD_PAL; break; case 0x08: - std = V4L2_STD_SECAM; + std &= V4L2_STD_SECAM; break; case 0x04: case 0x0c: case 0x1c: - std = V4L2_STD_NTSC; + std &= V4L2_STD_NTSC; break; } + } else { + std = V4L2_STD_UNKNOWN; } if (pstd) *pstd = std; From 0bde6c3e4c4d594eb66200e37d9aec6ed45a8543 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Wed, 29 May 2013 10:19:02 -0300 Subject: [PATCH 0280/1048] [media] bttv: fix querystd AND the standard mask with the detected standards. Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/pci/bt8xx/bttv-driver.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/media/pci/bt8xx/bttv-driver.c b/drivers/media/pci/bt8xx/bttv-driver.c index bfcfa3e8543e..c6532de0eac7 100644 --- a/drivers/media/pci/bt8xx/bttv-driver.c +++ b/drivers/media/pci/bt8xx/bttv-driver.c @@ -1760,9 +1760,9 @@ static int bttv_querystd(struct file *file, void *f, v4l2_std_id *id) struct bttv *btv = fh->btv; if (btread(BT848_DSTATUS) & BT848_DSTATUS_NUML) - *id = V4L2_STD_625_50; + *id &= V4L2_STD_625_50; else - *id = V4L2_STD_525_60; + *id &= V4L2_STD_525_60; return 0; } From 0b1ffb535720c1c8a758dfaef926413e11a4bbce Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Wed, 29 May 2013 10:19:03 -0300 Subject: [PATCH 0281/1048] [media] zoran: remove bogus autodetect mode in set_norm Currently, if the norm set is V4L2_STD_ALL, then autodetect the current standard and use that. This is non-standard behavior, and in fact it hasn't worked for a very long time: before s_std is called in this driver, the v4l2 core will mask it with the tvnorms field. So even if the application passes V4L2_STD_ALL, the zoran driver will always see a subset of that. Since nobody ever complained about this we just remove this non-standard functionality. Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/pci/zoran/zoran_driver.c | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/drivers/media/pci/zoran/zoran_driver.c b/drivers/media/pci/zoran/zoran_driver.c index 1168a84a737d..4ec2708c0dd0 100644 --- a/drivers/media/pci/zoran/zoran_driver.c +++ b/drivers/media/pci/zoran/zoran_driver.c @@ -1456,29 +1456,6 @@ zoran_set_norm (struct zoran *zr, return -EINVAL; } - if (norm == V4L2_STD_ALL) { - unsigned int status = 0; - v4l2_std_id std = 0; - - decoder_call(zr, video, querystd, &std); - decoder_call(zr, core, s_std, std); - - /* let changes come into effect */ - ssleep(2); - - decoder_call(zr, video, g_input_status, &status); - if (status & V4L2_IN_ST_NO_SIGNAL) { - dprintk(1, - KERN_ERR - "%s: %s - no norm detected\n", - ZR_DEVNAME(zr), __func__); - /* reset norm */ - decoder_call(zr, core, s_std, zr->norm); - return -EIO; - } - - norm = std; - } if (norm & V4L2_STD_SECAM) zr->timing = zr->card.tvn[2]; else if (norm & V4L2_STD_NTSC) From 1a2c6866e35058c8808af37659e0f344f7f79381 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Wed, 29 May 2013 10:19:04 -0300 Subject: [PATCH 0282/1048] [media] v4l2-ioctl: clarify querystd comment Improve the querystd comment. Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/v4l2-core/v4l2-ioctl.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c index 67745438e6ff..19e298863e0e 100644 --- a/drivers/media/v4l2-core/v4l2-ioctl.c +++ b/drivers/media/v4l2-core/v4l2-ioctl.c @@ -1385,10 +1385,10 @@ static int v4l_querystd(const struct v4l2_ioctl_ops *ops, v4l2_std_id *p = arg; /* - * If nothing detected, it should return all supported - * standard. - * Drivers just need to mask the std argument, in order - * to remove the standards that don't apply from the mask. + * If no signal is detected, then the driver should return + * V4L2_STD_UNKNOWN. Otherwise it should return tvnorms with + * any standards that do not apply removed. + * * This means that tuners, audio and video decoders can join * their efforts to improve the standards detection. */ From f41c4332cfeae59e78aeda6c4eb9d0f4d42adbf2 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Wed, 29 May 2013 10:19:05 -0300 Subject: [PATCH 0283/1048] [media] DocBook/media/v4l: clarify the QUERYSTD documentation Explicitly mention that this ioctl should return V4L2_STD_UNKNOWN if not signal was detected. Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- Documentation/DocBook/media/v4l/vidioc-querystd.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Documentation/DocBook/media/v4l/vidioc-querystd.xml b/Documentation/DocBook/media/v4l/vidioc-querystd.xml index fe80a183d957..222348542182 100644 --- a/Documentation/DocBook/media/v4l/vidioc-querystd.xml +++ b/Documentation/DocBook/media/v4l/vidioc-querystd.xml @@ -54,7 +54,8 @@ standard automatically. To do so, applications call VIDIOC_QUERYSTD with a pointer to a &v4l2-std-id; type. The driver stores here a set of candidates, this can be a single flag or a set of supported standards if for example the hardware can only -distinguish between 50 and 60 Hz systems. When detection is not +distinguish between 50 and 60 Hz systems. If no signal was detected, +then the driver will return V4L2_STD_UNKNOWN. When detection is not possible or fails, the set must contain all standards supported by the current video input or output. From 26811ae03539c24c618ce989abecb6e62a908e79 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Wed, 29 May 2013 10:19:06 -0300 Subject: [PATCH 0284/1048] [media] tvp5150: fix s_std support - do exact matching for special formats like PAL-M - drop autodetect support: it's non-standard, and it is bogus as well since there is no way to get back the detected standard since neither g_std nor querystd are implemented. Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/i2c/tvp5150.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/media/i2c/tvp5150.c b/drivers/media/i2c/tvp5150.c index bef528233f7e..89c0b13463b7 100644 --- a/drivers/media/i2c/tvp5150.c +++ b/drivers/media/i2c/tvp5150.c @@ -726,13 +726,11 @@ static int tvp5150_set_std(struct v4l2_subdev *sd, v4l2_std_id std) /* First tests should be against specific std */ - if (std == V4L2_STD_ALL) { - fmt = VIDEO_STD_AUTO_SWITCH_BIT; /* Autodetect mode */ - } else if (std & V4L2_STD_NTSC_443) { + if (std == V4L2_STD_NTSC_443) { fmt = VIDEO_STD_NTSC_4_43_BIT; - } else if (std & V4L2_STD_PAL_M) { + } else if (std == V4L2_STD_PAL_M) { fmt = VIDEO_STD_PAL_M_BIT; - } else if (std & (V4L2_STD_PAL_N | V4L2_STD_PAL_Nc)) { + } else if (std == V4L2_STD_PAL_N || std == V4L2_STD_PAL_Nc) { fmt = VIDEO_STD_PAL_COMBINATION_N_BIT; } else { /* Then, test against generic ones */ From 147351905b6b495f117fd8b7ff927bb61f1234b3 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Mon, 3 Jun 2013 13:26:17 -0300 Subject: [PATCH 0285/1048] [media] media: i2c: ths8200: driver for TI video encoder The full datasheets are available from TI website:- http://www.ti.com/product/ths8200 Note: This patch adds support only for progressive format as of now. Signed-off-by: Hans Verkuil Signed-off-by: Mats Randgaard Signed-off-by: Martin Bugge Signed-off-by: Lad, Prabhakar Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/i2c/Kconfig | 9 + drivers/media/i2c/Makefile | 1 + drivers/media/i2c/ths8200.c | 560 +++++++++++++++++++++++++++++++ drivers/media/i2c/ths8200_regs.h | 161 +++++++++ 4 files changed, 731 insertions(+) create mode 100644 drivers/media/i2c/ths8200.c create mode 100644 drivers/media/i2c/ths8200_regs.h diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig index 9c04ddb2101e..b2cd8ca51af7 100644 --- a/drivers/media/i2c/Kconfig +++ b/drivers/media/i2c/Kconfig @@ -434,6 +434,15 @@ config VIDEO_AK881X help Video output driver for AKM AK8813 and AK8814 TV encoders +config VIDEO_THS8200 + tristate "Texas Instruments THS8200 video encoder" + depends on VIDEO_V4L2 && I2C + ---help--- + Support for the Texas Instruments THS8200 video encoder. + + To compile this driver as a module, choose M here: the + module will be called ths8200. + comment "Camera sensor devices" config VIDEO_APTINA_PLL diff --git a/drivers/media/i2c/Makefile b/drivers/media/i2c/Makefile index b40ea089861a..dc20653bb5ad 100644 --- a/drivers/media/i2c/Makefile +++ b/drivers/media/i2c/Makefile @@ -34,6 +34,7 @@ obj-$(CONFIG_VIDEO_BT856) += bt856.o obj-$(CONFIG_VIDEO_BT866) += bt866.o obj-$(CONFIG_VIDEO_KS0127) += ks0127.o obj-$(CONFIG_VIDEO_THS7303) += ths7303.o +obj-$(CONFIG_VIDEO_THS8200) += ths8200.o obj-$(CONFIG_VIDEO_TVP5150) += tvp5150.o obj-$(CONFIG_VIDEO_TVP514X) += tvp514x.o obj-$(CONFIG_VIDEO_TVP7002) += tvp7002.o diff --git a/drivers/media/i2c/ths8200.c b/drivers/media/i2c/ths8200.c new file mode 100644 index 000000000000..939682967579 --- /dev/null +++ b/drivers/media/i2c/ths8200.c @@ -0,0 +1,560 @@ +/* + * ths8200 - Texas Instruments THS8200 video encoder driver + * + * Copyright 2013 Cisco Systems, Inc. and/or its affiliates. + * + * This program is free software; you may redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation version 2. + * + * This program is distributed .as is. WITHOUT ANY WARRANTY of any + * kind, whether express or implied; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include +#include +#include + +#include + +#include "ths8200_regs.h" + +static int debug; +module_param(debug, int, 0644); +MODULE_PARM_DESC(debug, "debug level (0-2)"); + +MODULE_DESCRIPTION("Texas Instruments THS8200 video encoder driver"); +MODULE_AUTHOR("Mats Randgaard "); +MODULE_AUTHOR("Martin Bugge "); +MODULE_LICENSE("GPL v2"); + +struct ths8200_state { + struct v4l2_subdev sd; + uint8_t chip_version; + /* Is the ths8200 powered on? */ + bool power_on; + struct v4l2_dv_timings dv_timings; +}; + +static const struct v4l2_dv_timings ths8200_timings[] = { + V4L2_DV_BT_CEA_720X480P59_94, + V4L2_DV_BT_CEA_1280X720P24, + V4L2_DV_BT_CEA_1280X720P25, + V4L2_DV_BT_CEA_1280X720P30, + V4L2_DV_BT_CEA_1280X720P50, + V4L2_DV_BT_CEA_1280X720P60, + V4L2_DV_BT_CEA_1920X1080P24, + V4L2_DV_BT_CEA_1920X1080P25, + V4L2_DV_BT_CEA_1920X1080P30, + V4L2_DV_BT_CEA_1920X1080P50, + V4L2_DV_BT_CEA_1920X1080P60, +}; + +static inline struct ths8200_state *to_state(struct v4l2_subdev *sd) +{ + return container_of(sd, struct ths8200_state, sd); +} + +static inline unsigned hblanking(const struct v4l2_bt_timings *t) +{ + return t->hfrontporch + t->hsync + t->hbackporch; +} + +static inline unsigned htotal(const struct v4l2_bt_timings *t) +{ + return t->width + t->hfrontporch + t->hsync + t->hbackporch; +} + +static inline unsigned vblanking(const struct v4l2_bt_timings *t) +{ + return t->vfrontporch + t->vsync + t->vbackporch; +} + +static inline unsigned vtotal(const struct v4l2_bt_timings *t) +{ + return t->height + t->vfrontporch + t->vsync + t->vbackporch; +} + +static int ths8200_read(struct v4l2_subdev *sd, u8 reg) +{ + struct i2c_client *client = v4l2_get_subdevdata(sd); + + return i2c_smbus_read_byte_data(client, reg); +} + +static int ths8200_write(struct v4l2_subdev *sd, u8 reg, u8 val) +{ + struct i2c_client *client = v4l2_get_subdevdata(sd); + int ret; + int i; + + for (i = 0; i < 3; i++) { + ret = i2c_smbus_write_byte_data(client, reg, val); + if (ret == 0) + return 0; + } + v4l2_err(sd, "I2C Write Problem\n"); + return ret; +} + +/* To set specific bits in the register, a clear-mask is given (to be AND-ed), + * and then the value-mask (to be OR-ed). + */ +static inline void +ths8200_write_and_or(struct v4l2_subdev *sd, u8 reg, + uint8_t clr_mask, uint8_t val_mask) +{ + ths8200_write(sd, reg, (ths8200_read(sd, reg) & clr_mask) | val_mask); +} + +#ifdef CONFIG_VIDEO_ADV_DEBUG + +static int ths8200_g_register(struct v4l2_subdev *sd, + struct v4l2_dbg_register *reg) +{ + struct i2c_client *client = v4l2_get_subdevdata(sd); + + reg->val = ths8200_read(sd, reg->reg & 0xff); + reg->size = 1; + + return 0; +} + +static int ths8200_s_register(struct v4l2_subdev *sd, + const struct v4l2_dbg_register *reg) +{ + struct i2c_client *client = v4l2_get_subdevdata(sd); + + ths8200_write(sd, reg->reg & 0xff, reg->val & 0xff); + + return 0; +} +#endif + +static void ths8200_print_timings(struct v4l2_subdev *sd, + struct v4l2_dv_timings *timings, + const char *txt, bool detailed) +{ + struct v4l2_bt_timings *bt = &timings->bt; + u32 htot, vtot; + + if (timings->type != V4L2_DV_BT_656_1120) + return; + + htot = htotal(bt); + vtot = vtotal(bt); + + v4l2_info(sd, "%s %dx%d%s%d (%dx%d)", + txt, bt->width, bt->height, bt->interlaced ? "i" : "p", + (htot * vtot) > 0 ? ((u32)bt->pixelclock / (htot * vtot)) : 0, + htot, vtot); + + if (detailed) { + v4l2_info(sd, " horizontal: fp = %d, %ssync = %d, bp = %d\n", + bt->hfrontporch, + (bt->polarities & V4L2_DV_HSYNC_POS_POL) ? "+" : "-", + bt->hsync, bt->hbackporch); + v4l2_info(sd, " vertical: fp = %d, %ssync = %d, bp = %d\n", + bt->vfrontporch, + (bt->polarities & V4L2_DV_VSYNC_POS_POL) ? "+" : "-", + bt->vsync, bt->vbackporch); + v4l2_info(sd, + " pixelclock: %lld, flags: 0x%x, standards: 0x%x\n", + bt->pixelclock, bt->flags, bt->standards); + } +} + +static int ths8200_log_status(struct v4l2_subdev *sd) +{ + struct ths8200_state *state = to_state(sd); + uint8_t reg_03 = ths8200_read(sd, THS8200_CHIP_CTL); + + v4l2_info(sd, "----- Chip status -----\n"); + v4l2_info(sd, "version: %u\n", state->chip_version); + v4l2_info(sd, "power: %s\n", (reg_03 & 0x0c) ? "off" : "on"); + v4l2_info(sd, "reset: %s\n", (reg_03 & 0x01) ? "off" : "on"); + v4l2_info(sd, "test pattern: %s\n", + (reg_03 & 0x20) ? "enabled" : "disabled"); + v4l2_info(sd, "format: %ux%u\n", + ths8200_read(sd, THS8200_DTG2_PIXEL_CNT_MSB) * 256 + + ths8200_read(sd, THS8200_DTG2_PIXEL_CNT_LSB), + (ths8200_read(sd, THS8200_DTG2_LINE_CNT_MSB) & 0x07) * 256 + + ths8200_read(sd, THS8200_DTG2_LINE_CNT_LSB)); + ths8200_print_timings(sd, &state->dv_timings, + "Configured format:", true); + + return 0; +} + +/* Power up/down ths8200 */ +static int ths8200_s_power(struct v4l2_subdev *sd, int on) +{ + struct ths8200_state *state = to_state(sd); + + v4l2_dbg(1, debug, sd, "%s: power %s\n", __func__, on ? "on" : "off"); + + state->power_on = on; + + /* Power up/down - leave in reset state until input video is present */ + ths8200_write_and_or(sd, THS8200_CHIP_CTL, 0xf2, (on ? 0x00 : 0x0c)); + + return 0; +} + +static const struct v4l2_subdev_core_ops ths8200_core_ops = { + .log_status = ths8200_log_status, + .s_power = ths8200_s_power, +#ifdef CONFIG_VIDEO_ADV_DEBUG + .g_register = ths8200_g_register, + .s_register = ths8200_s_register, +#endif +}; + +/* ----------------------------------------------------------------------------- + * V4L2 subdev video operations + */ + +static int ths8200_s_stream(struct v4l2_subdev *sd, int enable) +{ + struct ths8200_state *state = to_state(sd); + + if (enable && !state->power_on) + ths8200_s_power(sd, true); + + ths8200_write_and_or(sd, THS8200_CHIP_CTL, 0xfe, + (enable ? 0x01 : 0x00)); + + v4l2_dbg(1, debug, sd, "%s: %sable\n", + __func__, (enable ? "en" : "dis")); + + return 0; +} + +static void ths8200_core_init(struct v4l2_subdev *sd) +{ + /* setup clocks */ + ths8200_write_and_or(sd, THS8200_CHIP_CTL, 0x3f, 0xc0); + + /**** Data path control (DATA) ****/ + /* Set FSADJ 700 mV, + * bypass 422-444 interpolation, + * input format 30 bit RGB444 + */ + ths8200_write(sd, THS8200_DATA_CNTL, 0x70); + + /* DTG Mode (Video blocked during blanking + * VESA slave + */ + ths8200_write(sd, THS8200_DTG1_MODE, 0x87); + + /**** Display Timing Generator Control, Part 1 (DTG1). ****/ + + /* Disable embedded syncs on the output by setting + * the amplitude to zero for all channels. + */ + ths8200_write(sd, THS8200_DTG1_Y_SYNC_MSB, 0x2a); + ths8200_write(sd, THS8200_DTG1_CBCR_SYNC_MSB, 0x2a); +} + +static void ths8200_setup(struct v4l2_subdev *sd, struct v4l2_bt_timings *bt) +{ + uint8_t polarity = 0; + uint16_t line_start_active_video = (bt->vsync + bt->vbackporch); + uint16_t line_start_front_porch = (vtotal(bt) - bt->vfrontporch); + + /*** System ****/ + /* Set chip in reset while it is configured */ + ths8200_s_stream(sd, false); + + /* configure video output timings */ + ths8200_write(sd, THS8200_DTG1_SPEC_A, bt->hsync); + ths8200_write(sd, THS8200_DTG1_SPEC_B, bt->hfrontporch); + + /* Zero for progressive scan formats.*/ + if (!bt->interlaced) + ths8200_write(sd, THS8200_DTG1_SPEC_C, 0x00); + + /* Distance from leading edge of h sync to start of active video. + * MSB in 0x2b + */ + ths8200_write(sd, THS8200_DTG1_SPEC_D_LSB, + (bt->hbackporch + bt->hsync) & 0xff); + /* Zero for SDTV-mode. MSB in 0x2b */ + ths8200_write(sd, THS8200_DTG1_SPEC_E_LSB, 0x00); + /* + * MSB for dtg1_spec(d/e/h). See comment for + * corresponding LSB registers. + */ + ths8200_write(sd, THS8200_DTG1_SPEC_DEH_MSB, + ((bt->hbackporch + bt->hsync) & 0x100) >> 1); + + /* h front porch */ + ths8200_write(sd, THS8200_DTG1_SPEC_K_LSB, (bt->hfrontporch) & 0xff); + ths8200_write(sd, THS8200_DTG1_SPEC_K_MSB, + ((bt->hfrontporch) & 0x700) >> 8); + + /* Half the line length. Used to calculate SDTV line types. */ + ths8200_write(sd, THS8200_DTG1_SPEC_G_LSB, (htotal(bt)/2) & 0xff); + ths8200_write(sd, THS8200_DTG1_SPEC_G_MSB, + ((htotal(bt)/2) >> 8) & 0x0f); + + /* Total pixels per line (ex. 720p: 1650) */ + ths8200_write(sd, THS8200_DTG1_TOT_PIXELS_MSB, htotal(bt) >> 8); + ths8200_write(sd, THS8200_DTG1_TOT_PIXELS_LSB, htotal(bt) & 0xff); + + /* Frame height and field height */ + /* Field height should be programmed higher than frame_size for + * progressive scan formats + */ + ths8200_write(sd, THS8200_DTG1_FRAME_FIELD_SZ_MSB, + ((vtotal(bt) >> 4) & 0xf0) + 0x7); + ths8200_write(sd, THS8200_DTG1_FRAME_SZ_LSB, vtotal(bt) & 0xff); + + /* Should be programmed higher than frame_size + * for progressive formats + */ + if (!bt->interlaced) + ths8200_write(sd, THS8200_DTG1_FIELD_SZ_LSB, 0xff); + + /**** Display Timing Generator Control, Part 2 (DTG2). ****/ + /* Set breakpoint line numbers and types + * THS8200 generates line types with different properties. A line type + * that sets all the RGB-outputs to zero is used in the blanking areas, + * while a line type that enable the RGB-outputs is used in active video + * area. The line numbers for start of active video, start of front + * porch and after the last line in the frame must be set with the + * corresponding line types. + * + * Line types: + * 0x9 - Full normal sync pulse: Blocks data when dtg1_pass is off. + * Used in blanking area. + * 0x0 - Active video: Video data is always passed. Used in active + * video area. + */ + ths8200_write_and_or(sd, THS8200_DTG2_BP1_2_MSB, 0x88, + ((line_start_active_video >> 4) & 0x70) + + ((line_start_front_porch >> 8) & 0x07)); + ths8200_write(sd, THS8200_DTG2_BP3_4_MSB, ((vtotal(bt)) >> 4) & 0x70); + ths8200_write(sd, THS8200_DTG2_BP1_LSB, line_start_active_video & 0xff); + ths8200_write(sd, THS8200_DTG2_BP2_LSB, line_start_front_porch & 0xff); + ths8200_write(sd, THS8200_DTG2_BP3_LSB, (vtotal(bt)) & 0xff); + + /* line types */ + ths8200_write(sd, THS8200_DTG2_LINETYPE1, 0x90); + ths8200_write(sd, THS8200_DTG2_LINETYPE2, 0x90); + + /* h sync width transmitted */ + ths8200_write(sd, THS8200_DTG2_HLENGTH_LSB, bt->hsync & 0xff); + ths8200_write_and_or(sd, THS8200_DTG2_HLENGTH_LSB_HDLY_MSB, 0x3f, + (bt->hsync >> 2) & 0xc0); + + /* The pixel value h sync is asserted on */ + ths8200_write_and_or(sd, THS8200_DTG2_HLENGTH_LSB_HDLY_MSB, 0xe0, + (htotal(bt) >> 8) & 0x1f); + ths8200_write(sd, THS8200_DTG2_HLENGTH_HDLY_LSB, htotal(bt)); + + /* v sync width transmitted */ + ths8200_write(sd, THS8200_DTG2_VLENGTH1_LSB, (bt->vsync) & 0xff); + ths8200_write_and_or(sd, THS8200_DTG2_VLENGTH1_MSB_VDLY1_MSB, 0x3f, + ((bt->vsync) >> 2) & 0xc0); + + /* The pixel value v sync is asserted on */ + ths8200_write_and_or(sd, THS8200_DTG2_VLENGTH1_MSB_VDLY1_MSB, 0xf8, + (vtotal(bt)>>8) & 0x7); + ths8200_write(sd, THS8200_DTG2_VDLY1_LSB, vtotal(bt)); + + /* For progressive video vlength2 must be set to all 0 and vdly2 must + * be set to all 1. + */ + ths8200_write(sd, THS8200_DTG2_VLENGTH2_LSB, 0x00); + ths8200_write(sd, THS8200_DTG2_VLENGTH2_MSB_VDLY2_MSB, 0x07); + ths8200_write(sd, THS8200_DTG2_VDLY2_LSB, 0xff); + + /* Internal delay factors to synchronize the sync pulses and the data */ + /* Experimental values delays (hor 4, ver 1) */ + ths8200_write(sd, THS8200_DTG2_HS_IN_DLY_MSB, (htotal(bt)>>8) & 0x1f); + ths8200_write(sd, THS8200_DTG2_HS_IN_DLY_LSB, (htotal(bt) - 4) & 0xff); + ths8200_write(sd, THS8200_DTG2_VS_IN_DLY_MSB, 0); + ths8200_write(sd, THS8200_DTG2_VS_IN_DLY_LSB, 1); + + /* Polarity of received and transmitted sync signals */ + if (bt->polarities & V4L2_DV_HSYNC_POS_POL) { + polarity |= 0x01; /* HS_IN */ + polarity |= 0x08; /* HS_OUT */ + } + if (bt->polarities & V4L2_DV_VSYNC_POS_POL) { + polarity |= 0x02; /* VS_IN */ + polarity |= 0x10; /* VS_OUT */ + } + + /* RGB mode, no embedded timings */ + /* Timing of video input bus is derived from HS, VS, and FID dedicated + * inputs + */ + ths8200_write(sd, THS8200_DTG2_CNTL, 0x47 | polarity); + + /* leave reset */ + ths8200_s_stream(sd, true); + + v4l2_dbg(1, debug, sd, "%s: frame %dx%d, polarity %d\n" + "horizontal: front porch %d, back porch %d, sync %d\n" + "vertical: sync %d\n", __func__, htotal(bt), vtotal(bt), + polarity, bt->hfrontporch, bt->hbackporch, + bt->hsync, bt->vsync); +} + +static int ths8200_s_dv_timings(struct v4l2_subdev *sd, + struct v4l2_dv_timings *timings) +{ + struct ths8200_state *state = to_state(sd); + int i; + + v4l2_dbg(1, debug, sd, "%s:\n", __func__); + + if (timings->type != V4L2_DV_BT_656_1120) + return -EINVAL; + + /* TODO Support interlaced formats */ + if (timings->bt.interlaced) { + v4l2_dbg(1, debug, sd, "TODO Support interlaced formats\n"); + return -EINVAL; + } + + for (i = 0; i < ARRAY_SIZE(ths8200_timings); i++) { + if (v4l_match_dv_timings(&ths8200_timings[i], timings, 10)) + break; + } + + if (i == ARRAY_SIZE(ths8200_timings)) { + v4l2_dbg(1, debug, sd, "Unsupported format\n"); + return -EINVAL; + } + + timings->bt.flags &= ~V4L2_DV_FL_REDUCED_FPS; + + /* save timings */ + state->dv_timings = *timings; + + ths8200_setup(sd, &timings->bt); + + return 0; +} + +static int ths8200_g_dv_timings(struct v4l2_subdev *sd, + struct v4l2_dv_timings *timings) +{ + struct ths8200_state *state = to_state(sd); + + v4l2_dbg(1, debug, sd, "%s:\n", __func__); + + *timings = state->dv_timings; + + return 0; +} + +static int ths8200_enum_dv_timings(struct v4l2_subdev *sd, + struct v4l2_enum_dv_timings *timings) +{ + /* Check requested format index is within range */ + if (timings->index >= ARRAY_SIZE(ths8200_timings)) + return -EINVAL; + + timings->timings = ths8200_timings[timings->index]; + + return 0; +} + +static int ths8200_dv_timings_cap(struct v4l2_subdev *sd, + struct v4l2_dv_timings_cap *cap) +{ + cap->type = V4L2_DV_BT_656_1120; + cap->bt.max_width = 1920; + cap->bt.max_height = 1080; + cap->bt.min_pixelclock = 27000000; + cap->bt.max_pixelclock = 148500000; + cap->bt.standards = V4L2_DV_BT_STD_CEA861; + cap->bt.capabilities = V4L2_DV_BT_CAP_PROGRESSIVE; + + return 0; +} + +/* Specific video subsystem operation handlers */ +static const struct v4l2_subdev_video_ops ths8200_video_ops = { + .s_stream = ths8200_s_stream, + .s_dv_timings = ths8200_s_dv_timings, + .g_dv_timings = ths8200_g_dv_timings, + .enum_dv_timings = ths8200_enum_dv_timings, + .dv_timings_cap = ths8200_dv_timings_cap, +}; + +/* V4L2 top level operation handlers */ +static const struct v4l2_subdev_ops ths8200_ops = { + .core = &ths8200_core_ops, + .video = &ths8200_video_ops, +}; + +static int ths8200_probe(struct i2c_client *client, + const struct i2c_device_id *id) +{ + struct ths8200_state *state; + struct v4l2_subdev *sd; + + /* Check if the adapter supports the needed features */ + if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) + return -EIO; + + state = devm_kzalloc(&client->dev, sizeof(*state), GFP_KERNEL); + if (!state) + return -ENOMEM; + + sd = &state->sd; + v4l2_i2c_subdev_init(sd, client, &ths8200_ops); + + state->chip_version = ths8200_read(sd, THS8200_VERSION); + v4l2_dbg(1, debug, sd, "chip version 0x%x\n", state->chip_version); + + ths8200_core_init(sd); + + v4l2_info(sd, "%s found @ 0x%x (%s)\n", client->name, + client->addr << 1, client->adapter->name); + + return 0; +} + +static int ths8200_remove(struct i2c_client *client) +{ + struct v4l2_subdev *sd = i2c_get_clientdata(client); + + v4l2_dbg(1, debug, sd, "%s removed @ 0x%x (%s)\n", client->name, + client->addr << 1, client->adapter->name); + + ths8200_s_power(sd, false); + + v4l2_device_unregister_subdev(sd); + + return 0; +} + +static struct i2c_device_id ths8200_id[] = { + { "ths8200", 0 }, + {}, +}; +MODULE_DEVICE_TABLE(i2c, ths8200_id); + +static struct i2c_driver ths8200_driver = { + .driver = { + .owner = THIS_MODULE, + .name = "ths8200", + }, + .probe = ths8200_probe, + .remove = ths8200_remove, + .id_table = ths8200_id, +}; + +module_i2c_driver(ths8200_driver); diff --git a/drivers/media/i2c/ths8200_regs.h b/drivers/media/i2c/ths8200_regs.h new file mode 100644 index 000000000000..6bc9fd1111db --- /dev/null +++ b/drivers/media/i2c/ths8200_regs.h @@ -0,0 +1,161 @@ +/* + * ths8200 - Texas Instruments THS8200 video encoder driver + * + * Copyright 2013 Cisco Systems, Inc. and/or its affiliates. + * + * This program is free software; you may redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation version 2. + * + * This program is distributed .as is. WITHOUT ANY WARRANTY of any + * kind, whether express or implied; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#ifndef THS8200_REGS_H +#define THS8200_REGS_H + +/* Register offset macros */ +#define THS8200_VERSION 0x02 +#define THS8200_CHIP_CTL 0x03 +#define THS8200_CSC_R11 0x04 +#define THS8200_CSC_R12 0x05 +#define THS8200_CSC_R21 0x06 +#define THS8200_CSC_R22 0x07 +#define THS8200_CSC_R31 0x08 +#define THS8200_CSC_R32 0x09 +#define THS8200_CSC_G11 0x0a +#define THS8200_CSC_G12 0x0b +#define THS8200_CSC_G21 0x0c +#define THS8200_CSC_G22 0x0d +#define THS8200_CSC_G31 0x0e +#define THS8200_CSC_G32 0x0f +#define THS8200_CSC_B11 0x10 +#define THS8200_CSC_B12 0x11 +#define THS8200_CSC_B21 0x12 +#define THS8200_CSC_B22 0x13 +#define THS8200_CSC_B31 0x14 +#define THS8200_CSC_B32 0x15 +#define THS8200_CSC_OFFS1 0x16 +#define THS8200_CSC_OFFS12 0x17 +#define THS8200_CSC_OFFS23 0x18 +#define THS8200_CSC_OFFS3 0x19 +#define THS8200_TST_CNTL1 0x1a +#define THS8200_TST_CNTL2 0x1b +#define THS8200_DATA_CNTL 0x1c +#define THS8200_DTG1_Y_SYNC1_LSB 0x1d +#define THS8200_DTG1_Y_SYNC2_LSB 0x1e +#define THS8200_DTG1_Y_SYNC3_LSB 0x1f +#define THS8200_DTG1_CBCR_SYNC1_LSB 0x20 +#define THS8200_DTG1_CBCR_SYNC2_LSB 0x21 +#define THS8200_DTG1_CBCR_SYNC3_LSB 0x22 +#define THS8200_DTG1_Y_SYNC_MSB 0x23 +#define THS8200_DTG1_CBCR_SYNC_MSB 0x24 +#define THS8200_DTG1_SPEC_A 0x25 +#define THS8200_DTG1_SPEC_B 0x26 +#define THS8200_DTG1_SPEC_C 0x27 +#define THS8200_DTG1_SPEC_D_LSB 0x28 +#define THS8200_DTG1_SPEC_D1 0x29 +#define THS8200_DTG1_SPEC_E_LSB 0x2a +#define THS8200_DTG1_SPEC_DEH_MSB 0x2b +#define THS8200_DTG1_SPEC_H_LSB 0x2c +#define THS8200_DTG1_SPEC_I_MSB 0x2d +#define THS8200_DTG1_SPEC_I_LSB 0x2e +#define THS8200_DTG1_SPEC_K_LSB 0x2f +#define THS8200_DTG1_SPEC_K_MSB 0x30 +#define THS8200_DTG1_SPEC_K1 0x31 +#define THS8200_DTG1_SPEC_G_LSB 0x32 +#define THS8200_DTG1_SPEC_G_MSB 0x33 +#define THS8200_DTG1_TOT_PIXELS_MSB 0x34 +#define THS8200_DTG1_TOT_PIXELS_LSB 0x35 +#define THS8200_DTG1_FLD_FLIP_LINECNT_MSB 0x36 +#define THS8200_DTG1_LINECNT_LSB 0x37 +#define THS8200_DTG1_MODE 0x38 +#define THS8200_DTG1_FRAME_FIELD_SZ_MSB 0x39 +#define THS8200_DTG1_FRAME_SZ_LSB 0x3a +#define THS8200_DTG1_FIELD_SZ_LSB 0x3b +#define THS8200_DTG1_VESA_CBAR_SIZE 0x3c +#define THS8200_DAC_CNTL_MSB 0x3d +#define THS8200_DAC1_CNTL_LSB 0x3e +#define THS8200_DAC2_CNTL_LSB 0x3f +#define THS8200_DAC3_CNTL_LSB 0x40 +#define THS8200_CSM_CLIP_GY_LOW 0x41 +#define THS8200_CSM_CLIP_BCB_LOW 0x42 +#define THS8200_CSM_CLIP_RCR_LOW 0x43 +#define THS8200_CSM_CLIP_GY_HIGH 0x44 +#define THS8200_CSM_CLIP_BCB_HIGH 0x45 +#define THS8200_CSM_CLIP_RCR_HIGH 0x46 +#define THS8200_CSM_SHIFT_GY 0x47 +#define THS8200_CSM_SHIFT_BCB 0x48 +#define THS8200_CSM_SHIFT_RCR 0x49 +#define THS8200_CSM_GY_CNTL_MULT_MSB 0x4a +#define THS8200_CSM_MULT_BCB_RCR_MSB 0x4b +#define THS8200_CSM_MULT_GY_LSB 0x4c +#define THS8200_CSM_MULT_BCB_LSB 0x4d +#define THS8200_CSM_MULT_RCR_LSB 0x4e +#define THS8200_CSM_MULT_RCR_BCB_CNTL 0x4f +#define THS8200_CSM_MULT_RCR_LSB 0x4e +#define THS8200_DTG2_BP1_2_MSB 0x50 +#define THS8200_DTG2_BP3_4_MSB 0x51 +#define THS8200_DTG2_BP5_6_MSB 0x52 +#define THS8200_DTG2_BP7_8_MSB 0x53 +#define THS8200_DTG2_BP9_10_MSB 0x54 +#define THS8200_DTG2_BP11_12_MSB 0x55 +#define THS8200_DTG2_BP13_14_MSB 0x56 +#define THS8200_DTG2_BP15_16_MSB 0x57 +#define THS8200_DTG2_BP1_LSB 0x58 +#define THS8200_DTG2_BP2_LSB 0x59 +#define THS8200_DTG2_BP3_LSB 0x5a +#define THS8200_DTG2_BP4_LSB 0x5b +#define THS8200_DTG2_BP5_LSB 0x5c +#define THS8200_DTG2_BP6_LSB 0x5d +#define THS8200_DTG2_BP7_LSB 0x5e +#define THS8200_DTG2_BP8_LSB 0x5f +#define THS8200_DTG2_BP9_LSB 0x60 +#define THS8200_DTG2_BP10_LSB 0x61 +#define THS8200_DTG2_BP11_LSB 0x62 +#define THS8200_DTG2_BP12_LSB 0x63 +#define THS8200_DTG2_BP13_LSB 0x64 +#define THS8200_DTG2_BP14_LSB 0x65 +#define THS8200_DTG2_BP15_LSB 0x66 +#define THS8200_DTG2_BP16_LSB 0x67 +#define THS8200_DTG2_LINETYPE1 0x68 +#define THS8200_DTG2_LINETYPE2 0x69 +#define THS8200_DTG2_LINETYPE3 0x6a +#define THS8200_DTG2_LINETYPE4 0x6b +#define THS8200_DTG2_LINETYPE5 0x6c +#define THS8200_DTG2_LINETYPE6 0x6d +#define THS8200_DTG2_LINETYPE7 0x6e +#define THS8200_DTG2_LINETYPE8 0x6f +#define THS8200_DTG2_HLENGTH_LSB 0x70 +#define THS8200_DTG2_HLENGTH_LSB_HDLY_MSB 0x71 +#define THS8200_DTG2_HLENGTH_HDLY_LSB 0x72 +#define THS8200_DTG2_VLENGTH1_LSB 0x73 +#define THS8200_DTG2_VLENGTH1_MSB_VDLY1_MSB 0x74 +#define THS8200_DTG2_VDLY1_LSB 0x75 +#define THS8200_DTG2_VLENGTH2_LSB 0x76 +#define THS8200_DTG2_VLENGTH2_MSB_VDLY2_MSB 0x77 +#define THS8200_DTG2_VDLY2_LSB 0x78 +#define THS8200_DTG2_HS_IN_DLY_MSB 0x79 +#define THS8200_DTG2_HS_IN_DLY_LSB 0x7a +#define THS8200_DTG2_VS_IN_DLY_MSB 0x7b +#define THS8200_DTG2_VS_IN_DLY_LSB 0x7c +#define THS8200_DTG2_PIXEL_CNT_MSB 0x7d +#define THS8200_DTG2_PIXEL_CNT_LSB 0x7e +#define THS8200_DTG2_LINE_CNT_MSB 0x7f +#define THS8200_DTG2_LINE_CNT_LSB 0x80 +#define THS8200_DTG2_CNTL 0x82 +#define THS8200_CGMS_CNTL_HEADER 0x83 +#define THS8200_CGMS_PAYLOAD_MSB 0x84 +#define THS8200_CGMS_PAYLOAD_LSB 0x85 +#define THS8200_MISC_PPL_LSB 0x86 +#define THS8200_MISC_PPL_MSB 0x87 +#define THS8200_MISC_LPF_MSB 0x88 +#define THS8200_MISC_LPF_LSB 0x89 + +#endif /* THS8200_REGS_H */ From 8460d519bc5a7145166f8954f08dde5ee75db85a Mon Sep 17 00:00:00 2001 From: Ismael Luceno Date: Thu, 6 Jun 2013 00:12:17 -0300 Subject: [PATCH 0286/1048] [media] solo6x10: reimplement SAA712x setup routine This cleans up the saa712x setup code and there are no functional changes. Signed-off-by: Ismael Luceno [hans.verkuil@cisco.com: add clarification that this is cleanup only] Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- .../staging/media/solo6x10/solo6x10-tw28.c | 112 +++++++++++------- 1 file changed, 66 insertions(+), 46 deletions(-) diff --git a/drivers/staging/media/solo6x10/solo6x10-tw28.c b/drivers/staging/media/solo6x10/solo6x10-tw28.c index ad00e2b60323..af65ea655f15 100644 --- a/drivers/staging/media/solo6x10/solo6x10-tw28.c +++ b/drivers/staging/media/solo6x10/solo6x10-tw28.c @@ -513,62 +513,82 @@ static int tw2815_setup(struct solo_dev *solo_dev, u8 dev_addr) #define FIRST_ACTIVE_LINE 0x0008 #define LAST_ACTIVE_LINE 0x0102 -static void saa7128_setup(struct solo_dev *solo_dev) +static void saa712x_write_regs(struct solo_dev *dev, const uint8_t *vals, + int start, int n) { - int i; - unsigned char regs[128] = { - 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, + for (;start < n; start++, vals++) { + /* Skip read-only registers */ + switch (start) { + /* case 0x00 ... 0x25: */ + case 0x2e ... 0x37: + case 0x60: + case 0x7d: + continue; + } + solo_i2c_writebyte(dev, SOLO_I2C_SAA, 0x46, start, *vals); + } +} + +#define SAA712x_reg7c (0x80 | ((LAST_ACTIVE_LINE & 0x100) >> 2) \ + | ((FIRST_ACTIVE_LINE & 0x100) >> 4)) + +static void saa712x_setup(struct solo_dev *dev) +{ + const int reg_start = 0x26; + const uint8_t saa7128_regs_ntsc[] = { + /* :0x26 */ + 0x0d, 0x00, + /* :0x28 */ + 0x59, 0x1d, 0x75, 0x3f, 0x06, 0x3f, + /* :0x2e XXX: read-only */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x1C, 0x2B, 0x00, 0x00, 0x00, 0x00, 0x0d, 0x00, - 0x59, 0x1d, 0x75, 0x3f, 0x06, 0x3f, 0x00, 0x00, - 0x1c, 0x33, 0x00, 0x3f, 0x00, 0x00, 0x3f, 0x00, + /* :0x38 */ 0x1a, 0x1a, 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, + /* :0x40 */ 0x00, 0x00, 0x00, 0x68, 0x10, 0x97, 0x4c, 0x18, 0x9b, 0x93, 0x9f, 0xff, 0x7c, 0x34, 0x3f, 0x3f, + /* :0x50 */ 0x3f, 0x83, 0x83, 0x80, 0x0d, 0x0f, 0xc3, 0x06, 0x02, 0x80, 0x71, 0x77, 0xa7, 0x67, 0x66, 0x2e, + /* :0x60 */ 0x7b, 0x11, 0x4f, 0x1f, 0x7c, 0xf0, 0x21, 0x77, - 0x41, 0x88, 0x41, 0x12, 0xed, 0x10, 0x10, 0x00, + 0x41, 0x88, 0x41, 0x52, 0xed, 0x10, 0x10, 0x00, + /* :0x70 */ 0x41, 0xc3, 0x00, 0x3e, 0xb8, 0x02, 0x00, 0x00, - 0x00, 0x00, 0x08, 0xff, 0x80, 0x00, 0xff, 0xff, + 0x00, 0x00, FIRST_ACTIVE_LINE, LAST_ACTIVE_LINE & 0xff, + SAA712x_reg7c, 0x00, 0xff, 0xff, + }, saa7128_regs_pal[] = { + /* :0x26 */ + 0x0d, 0x00, + /* :0x28 */ + 0xe1, 0x1d, 0x75, 0x3f, 0x06, 0x3f, + /* :0x2e XXX: read-only */ + 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + /* :0x38 */ + 0x1a, 0x1a, 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, + /* :0x40 */ + 0x00, 0x00, 0x00, 0x68, 0x10, 0x97, 0x4c, 0x18, + 0x9b, 0x93, 0x9f, 0xff, 0x7c, 0x34, 0x3f, 0x3f, + /* :0x50 */ + 0x3f, 0x83, 0x83, 0x80, 0x0d, 0x0f, 0xc3, 0x06, + 0x02, 0x80, 0x0f, 0x77, 0xa7, 0x67, 0x66, 0x2e, + /* :0x60 */ + 0x7b, 0x02, 0x35, 0xcb, 0x8a, 0x09, 0x2a, 0x77, + 0x41, 0x88, 0x41, 0x52, 0xf1, 0x10, 0x20, 0x00, + /* :0x70 */ + 0x41, 0xc3, 0x00, 0x3e, 0xb8, 0x02, 0x00, 0x00, + 0x00, 0x00, 0x12, 0x30, + SAA712x_reg7c | 0x40, 0x00, 0xff, 0xff, }; - regs[0x7A] = FIRST_ACTIVE_LINE & 0xff; - regs[0x7B] = LAST_ACTIVE_LINE & 0xff; - regs[0x7C] = ((1 << 7) | - (((LAST_ACTIVE_LINE >> 8) & 1) << 6) | - (((FIRST_ACTIVE_LINE >> 8) & 1) << 4)); - - /* PAL: XXX: We could do a second set of regs to avoid this */ - if (solo_dev->video_type != SOLO_VO_FMT_TYPE_NTSC) { - regs[0x28] = 0xE1; - - regs[0x5A] = 0x0F; - regs[0x61] = 0x02; - regs[0x62] = 0x35; - regs[0x63] = 0xCB; - regs[0x64] = 0x8A; - regs[0x65] = 0x09; - regs[0x66] = 0x2A; - - regs[0x6C] = 0xf1; - regs[0x6E] = 0x20; - - regs[0x7A] = 0x06 + 12; - regs[0x7b] = 0x24 + 12; - regs[0x7c] |= 1 << 6; - } - - /* First 0x25 bytes are read-only? */ - for (i = 0x26; i < 128; i++) { - if (i == 0x60 || i == 0x7D) - continue; - solo_i2c_writebyte(solo_dev, SOLO_I2C_SAA, 0x46, i, regs[i]); - } - - return; + if (dev->video_type == SOLO_VO_FMT_TYPE_PAL) + saa712x_write_regs(dev, saa7128_regs_pal, reg_start, + sizeof(saa7128_regs_pal)); + else + saa712x_write_regs(dev, saa7128_regs_ntsc, reg_start, + sizeof(saa7128_regs_ntsc)); } int solo_tw28_init(struct solo_dev *solo_dev) @@ -609,7 +629,7 @@ int solo_tw28_init(struct solo_dev *solo_dev) return -EINVAL; } - saa7128_setup(solo_dev); + saa712x_setup(solo_dev); for (i = 0; i < solo_dev->tw28_cnt; i++) { if ((solo_dev->tw2865 & (1 << i))) From 8fcd4769de1528cd058590b17d783050a53819da Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Fri, 31 May 2013 07:57:10 -0300 Subject: [PATCH 0287/1048] [media] saa7134: remove radio/type field from saa7134_fh This information is already available in vfl_type in video_device. Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/pci/saa7134/saa7134-video.c | 89 ++++++++--------------- drivers/media/pci/saa7134/saa7134.h | 2 - 2 files changed, 32 insertions(+), 59 deletions(-) diff --git a/drivers/media/pci/saa7134/saa7134-video.c b/drivers/media/pci/saa7134/saa7134-video.c index b78d515068a7..aa1a73ed75a4 100644 --- a/drivers/media/pci/saa7134/saa7134-video.c +++ b/drivers/media/pci/saa7134/saa7134-video.c @@ -1287,15 +1287,17 @@ static int saa7134_s_ctrl(struct file *file, void *f, struct v4l2_control *c) /* ------------------------------------------------------------------ */ -static struct videobuf_queue* saa7134_queue(struct saa7134_fh *fh) +static struct videobuf_queue *saa7134_queue(struct file *file) { - struct videobuf_queue* q = NULL; + struct video_device *vdev = video_devdata(file); + struct saa7134_fh *fh = file->private_data; + struct videobuf_queue *q = NULL; - switch (fh->type) { - case V4L2_BUF_TYPE_VIDEO_CAPTURE: + switch (vdev->vfl_type) { + case VFL_TYPE_GRABBER: q = &fh->cap; break; - case V4L2_BUF_TYPE_VBI_CAPTURE: + case VFL_TYPE_VBI: q = &fh->vbi; break; default: @@ -1304,12 +1306,14 @@ static struct videobuf_queue* saa7134_queue(struct saa7134_fh *fh) return q; } -static int saa7134_resource(struct saa7134_fh *fh) +static int saa7134_resource(struct file *file) { - if (fh->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) + struct video_device *vdev = video_devdata(file); + + if (vdev->vfl_type == VFL_TYPE_GRABBER) return RESOURCE_VIDEO; - if (fh->type == V4L2_BUF_TYPE_VBI_CAPTURE) + if (vdev->vfl_type == VFL_TYPE_VBI) return RESOURCE_VBI; BUG(); @@ -1321,23 +1325,6 @@ static int video_open(struct file *file) struct video_device *vdev = video_devdata(file); struct saa7134_dev *dev = video_drvdata(file); struct saa7134_fh *fh; - enum v4l2_buf_type type = 0; - int radio = 0; - - switch (vdev->vfl_type) { - case VFL_TYPE_GRABBER: - type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - break; - case VFL_TYPE_VBI: - type = V4L2_BUF_TYPE_VBI_CAPTURE; - break; - case VFL_TYPE_RADIO: - radio = 1; - break; - } - - dprintk("open dev=%s radio=%d type=%s\n", video_device_node_name(vdev), - radio, v4l2_type_names[type]); /* allocate + initialize per filehandle data */ fh = kzalloc(sizeof(*fh),GFP_KERNEL); @@ -1347,8 +1334,6 @@ static int video_open(struct file *file) v4l2_fh_init(&fh->fh, vdev); file->private_data = fh; fh->dev = dev; - fh->radio = radio; - fh->type = type; fh->fmt = format_by_fourcc(V4L2_PIX_FMT_BGR24); fh->width = 720; fh->height = 576; @@ -1368,7 +1353,7 @@ static int video_open(struct file *file) saa7134_pgtable_alloc(dev->pci,&fh->pt_cap); saa7134_pgtable_alloc(dev->pci,&fh->pt_vbi); - if (fh->radio) { + if (vdev->vfl_type == VFL_TYPE_RADIO) { /* switch to radio mode */ saa7134_tvaudio_setinput(dev,&card(dev).radio); saa_call_all(dev, tuner, s_radio); @@ -1384,19 +1369,20 @@ static int video_open(struct file *file) static ssize_t video_read(struct file *file, char __user *data, size_t count, loff_t *ppos) { + struct video_device *vdev = video_devdata(file); struct saa7134_fh *fh = file->private_data; - switch (fh->type) { - case V4L2_BUF_TYPE_VIDEO_CAPTURE: + switch (vdev->vfl_type) { + case VFL_TYPE_GRABBER: if (res_locked(fh->dev,RESOURCE_VIDEO)) return -EBUSY; - return videobuf_read_one(saa7134_queue(fh), + return videobuf_read_one(saa7134_queue(file), data, count, ppos, file->f_flags & O_NONBLOCK); - case V4L2_BUF_TYPE_VBI_CAPTURE: + case VFL_TYPE_VBI: if (!res_get(fh->dev,fh,RESOURCE_VBI)) return -EBUSY; - return videobuf_read_stream(saa7134_queue(fh), + return videobuf_read_stream(saa7134_queue(file), data, count, ppos, 1, file->f_flags & O_NONBLOCK); break; @@ -1409,11 +1395,12 @@ video_read(struct file *file, char __user *data, size_t count, loff_t *ppos) static unsigned int video_poll(struct file *file, struct poll_table_struct *wait) { + struct video_device *vdev = video_devdata(file); struct saa7134_fh *fh = file->private_data; struct videobuf_buffer *buf = NULL; unsigned int rc = 0; - if (V4L2_BUF_TYPE_VBI_CAPTURE == fh->type) + if (vdev->vfl_type == VFL_TYPE_VBI) return videobuf_poll_stream(file, &fh->vbi, wait); if (res_check(fh,RESOURCE_VIDEO)) { @@ -1451,6 +1438,7 @@ err: static int video_release(struct file *file) { + struct video_device *vdev = video_devdata(file); struct saa7134_fh *fh = file->private_data; struct saa7134_dev *dev = fh->dev; struct saa6588_command cmd; @@ -1489,7 +1477,7 @@ static int video_release(struct file *file) saa_andorb(SAA7134_OFMT_DATA_B, 0x1f, 0); saa_call_all(dev, core, s_power, 0); - if (fh->radio) + if (vdev->vfl_type == VFL_TYPE_RADIO) saa_call_all(dev, core, ioctl, SAA6588_CMD_CLOSE, &cmd); /* free stuff */ @@ -1507,9 +1495,7 @@ static int video_release(struct file *file) static int video_mmap(struct file *file, struct vm_area_struct * vma) { - struct saa7134_fh *fh = file->private_data; - - return videobuf_mmap_mapper(saa7134_queue(fh), vma); + return videobuf_mmap_mapper(saa7134_queue(file), vma); } static ssize_t radio_read(struct file *file, char __user *data, @@ -2057,7 +2043,6 @@ static int saa7134_g_frequency(struct file *file, void *priv, if (0 != f->tuner) return -EINVAL; - f->type = fh->radio ? V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; saa_call_all(dev, tuner, g_frequency, f); return 0; @@ -2071,10 +2056,6 @@ static int saa7134_s_frequency(struct file *file, void *priv, if (0 != f->tuner) return -EINVAL; - if (0 == fh->radio && V4L2_TUNER_ANALOG_TV != f->type) - return -EINVAL; - if (1 == fh->radio && V4L2_TUNER_RADIO != f->type) - return -EINVAL; mutex_lock(&dev->lock); saa_call_all(dev, tuner, s_frequency, f); @@ -2186,27 +2167,23 @@ static int saa7134_overlay(struct file *file, void *f, unsigned int on) static int saa7134_reqbufs(struct file *file, void *priv, struct v4l2_requestbuffers *p) { - struct saa7134_fh *fh = priv; - return videobuf_reqbufs(saa7134_queue(fh), p); + return videobuf_reqbufs(saa7134_queue(file), p); } static int saa7134_querybuf(struct file *file, void *priv, struct v4l2_buffer *b) { - struct saa7134_fh *fh = priv; - return videobuf_querybuf(saa7134_queue(fh), b); + return videobuf_querybuf(saa7134_queue(file), b); } static int saa7134_qbuf(struct file *file, void *priv, struct v4l2_buffer *b) { - struct saa7134_fh *fh = priv; - return videobuf_qbuf(saa7134_queue(fh), b); + return videobuf_qbuf(saa7134_queue(file), b); } static int saa7134_dqbuf(struct file *file, void *priv, struct v4l2_buffer *b) { - struct saa7134_fh *fh = priv; - return videobuf_dqbuf(saa7134_queue(fh), b, + return videobuf_dqbuf(saa7134_queue(file), b, file->f_flags & O_NONBLOCK); } @@ -2215,7 +2192,7 @@ static int saa7134_streamon(struct file *file, void *priv, { struct saa7134_fh *fh = priv; struct saa7134_dev *dev = fh->dev; - int res = saa7134_resource(fh); + int res = saa7134_resource(file); if (!res_get(dev, fh, res)) return -EBUSY; @@ -2231,7 +2208,7 @@ static int saa7134_streamon(struct file *file, void *priv, PM_QOS_CPU_DMA_LATENCY, 20); - return videobuf_streamon(saa7134_queue(fh)); + return videobuf_streamon(saa7134_queue(file)); } static int saa7134_streamoff(struct file *file, void *priv, @@ -2240,11 +2217,11 @@ static int saa7134_streamoff(struct file *file, void *priv, int err; struct saa7134_fh *fh = priv; struct saa7134_dev *dev = fh->dev; - int res = saa7134_resource(fh); + int res = saa7134_resource(file); pm_qos_remove_request(&fh->qos_request); - err = videobuf_streamoff(saa7134_queue(fh)); + err = videobuf_streamoff(saa7134_queue(file)); if (err < 0) return err; res_free(dev, fh, res); @@ -2283,9 +2260,7 @@ static int radio_g_tuner(struct file *file, void *priv, if (0 != t->index) return -EINVAL; - memset(t, 0, sizeof(*t)); strcpy(t->name, "Radio"); - t->type = V4L2_TUNER_RADIO; saa_call_all(dev, tuner, g_tuner, t); t->audmode &= V4L2_TUNER_MODE_MONO | V4L2_TUNER_MODE_STEREO; diff --git a/drivers/media/pci/saa7134/saa7134.h b/drivers/media/pci/saa7134/saa7134.h index d2ad16c1569a..a103678cd499 100644 --- a/drivers/media/pci/saa7134/saa7134.h +++ b/drivers/media/pci/saa7134/saa7134.h @@ -471,8 +471,6 @@ struct saa7134_dmaqueue { struct saa7134_fh { struct v4l2_fh fh; struct saa7134_dev *dev; - unsigned int radio; - enum v4l2_buf_type type; unsigned int resources; struct pm_qos_request qos_request; From b12262f9472d714341d9d83f47cccd76c977aa0e Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Fri, 31 May 2013 08:22:24 -0300 Subject: [PATCH 0288/1048] [media] saa7134: move the overlay fields from saa7134_fh to saa7134_dev This is global data, not per-filehandle data. Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/pci/saa7134/saa7134-video.c | 33 ++++++++++++----------- drivers/media/pci/saa7134/saa7134.h | 9 +++---- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/drivers/media/pci/saa7134/saa7134-video.c b/drivers/media/pci/saa7134/saa7134-video.c index aa1a73ed75a4..331eded72ebc 100644 --- a/drivers/media/pci/saa7134/saa7134-video.c +++ b/drivers/media/pci/saa7134/saa7134-video.c @@ -872,20 +872,20 @@ static int start_preview(struct saa7134_dev *dev, struct saa7134_fh *fh) unsigned long base,control,bpl; int err; - err = verify_preview(dev,&fh->win); + err = verify_preview(dev, &dev->win); if (0 != err) return err; - dev->ovfield = fh->win.field; + dev->ovfield = dev->win.field; dprintk("start_preview %dx%d+%d+%d %s field=%s\n", - fh->win.w.width,fh->win.w.height, - fh->win.w.left,fh->win.w.top, - dev->ovfmt->name,v4l2_field_names[dev->ovfield]); + dev->win.w.width, dev->win.w.height, + dev->win.w.left, dev->win.w.top, + dev->ovfmt->name, v4l2_field_names[dev->ovfield]); /* setup window + clipping */ - set_size(dev,TASK_B,fh->win.w.width,fh->win.w.height, + set_size(dev, TASK_B, dev->win.w.width, dev->win.w.height, V4L2_FIELD_HAS_BOTH(dev->ovfield)); - setup_clipping(dev,fh->clips,fh->nclips, + setup_clipping(dev, dev->clips, dev->nclips, V4L2_FIELD_HAS_BOTH(dev->ovfield)); if (dev->ovfmt->yuv) saa_andorb(SAA7134_DATA_PATH(TASK_B), 0x3f, 0x03); @@ -895,8 +895,8 @@ static int start_preview(struct saa7134_dev *dev, struct saa7134_fh *fh) /* dma: setup channel 1 (= Video Task B) */ base = (unsigned long)dev->ovbuf.base; - base += dev->ovbuf.fmt.bytesperline * fh->win.w.top; - base += dev->ovfmt->depth/8 * fh->win.w.left; + base += dev->ovbuf.fmt.bytesperline * dev->win.w.top; + base += dev->ovfmt->depth/8 * dev->win.w.left; bpl = dev->ovbuf.fmt.bytesperline; control = SAA7134_RS_CONTROL_BURST_16; if (dev->ovfmt->bswap) @@ -1572,12 +1572,13 @@ static int saa7134_g_fmt_vid_overlay(struct file *file, void *priv, struct v4l2_format *f) { struct saa7134_fh *fh = priv; + struct saa7134_dev *dev = fh->dev; if (saa7134_no_overlay > 0) { printk(KERN_ERR "V4L2_BUF_TYPE_VIDEO_OVERLAY: no_overlay\n"); return -EINVAL; } - f->fmt.win = fh->win; + f->fmt.win = dev->win; return 0; } @@ -1682,14 +1683,14 @@ static int saa7134_s_fmt_vid_overlay(struct file *file, void *priv, mutex_lock(&dev->lock); - fh->win = f->fmt.win; - fh->nclips = f->fmt.win.clipcount; + dev->win = f->fmt.win; + dev->nclips = f->fmt.win.clipcount; - if (fh->nclips > 8) - fh->nclips = 8; + if (dev->nclips > 8) + dev->nclips = 8; - if (copy_from_user(fh->clips, f->fmt.win.clips, - sizeof(struct v4l2_clip)*fh->nclips)) { + if (copy_from_user(dev->clips, f->fmt.win.clips, + sizeof(struct v4l2_clip) * dev->nclips)) { mutex_unlock(&dev->lock); return -EFAULT; } diff --git a/drivers/media/pci/saa7134/saa7134.h b/drivers/media/pci/saa7134/saa7134.h index a103678cd499..fa21d14ea16e 100644 --- a/drivers/media/pci/saa7134/saa7134.h +++ b/drivers/media/pci/saa7134/saa7134.h @@ -474,11 +474,6 @@ struct saa7134_fh { unsigned int resources; struct pm_qos_request qos_request; - /* video overlay */ - struct v4l2_window win; - struct v4l2_clip clips[8]; - unsigned int nclips; - /* video capture */ struct saa7134_format *fmt; unsigned int width,height; @@ -590,6 +585,10 @@ struct saa7134_dev { struct saa7134_format *ovfmt; unsigned int ovenable; enum v4l2_field ovfield; + struct v4l2_window win; + struct v4l2_clip clips[8]; + unsigned int nclips; + /* video+ts+vbi capture */ struct saa7134_dmaqueue video_q; From 813b9dffa0cfefdd71b262e1ec4ad5f7d1fb8f89 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Fri, 31 May 2013 08:30:49 -0300 Subject: [PATCH 0289/1048] [media] saa7134: move fmt/width/height from saa7134_fh to saa7134_dev These fields are global, not per-filehandle. Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/pci/saa7134/saa7134-video.c | 57 ++++++++++++----------- drivers/media/pci/saa7134/saa7134.h | 4 +- 2 files changed, 32 insertions(+), 29 deletions(-) diff --git a/drivers/media/pci/saa7134/saa7134-video.c b/drivers/media/pci/saa7134/saa7134-video.c index 331eded72ebc..30832d38fb54 100644 --- a/drivers/media/pci/saa7134/saa7134-video.c +++ b/drivers/media/pci/saa7134/saa7134-video.c @@ -1024,38 +1024,38 @@ static int buffer_prepare(struct videobuf_queue *q, int err; /* sanity checks */ - if (NULL == fh->fmt) + if (NULL == dev->fmt) return -EINVAL; - if (fh->width < 48 || - fh->height < 32 || - fh->width/4 > dev->crop_current.width || - fh->height/4 > dev->crop_current.height || - fh->width > dev->crop_bounds.width || - fh->height > dev->crop_bounds.height) + if (dev->width < 48 || + dev->height < 32 || + dev->width/4 > dev->crop_current.width || + dev->height/4 > dev->crop_current.height || + dev->width > dev->crop_bounds.width || + dev->height > dev->crop_bounds.height) return -EINVAL; - size = (fh->width * fh->height * fh->fmt->depth) >> 3; + size = (dev->width * dev->height * dev->fmt->depth) >> 3; if (0 != buf->vb.baddr && buf->vb.bsize < size) return -EINVAL; dprintk("buffer_prepare [%d,size=%dx%d,bytes=%d,fields=%s,%s]\n", - vb->i,fh->width,fh->height,size,v4l2_field_names[field], - fh->fmt->name); - if (buf->vb.width != fh->width || - buf->vb.height != fh->height || + vb->i, dev->width, dev->height, size, v4l2_field_names[field], + dev->fmt->name); + if (buf->vb.width != dev->width || + buf->vb.height != dev->height || buf->vb.size != size || buf->vb.field != field || - buf->fmt != fh->fmt) { + buf->fmt != dev->fmt) { saa7134_dma_free(q,buf); } if (VIDEOBUF_NEEDS_INIT == buf->vb.state) { struct videobuf_dmabuf *dma=videobuf_to_dma(&buf->vb); - buf->vb.width = fh->width; - buf->vb.height = fh->height; + buf->vb.width = dev->width; + buf->vb.height = dev->height; buf->vb.size = size; buf->vb.field = field; - buf->fmt = fh->fmt; + buf->fmt = dev->fmt; buf->pt = &fh->pt_cap; dev->video_q.curr = NULL; @@ -1082,8 +1082,9 @@ static int buffer_setup(struct videobuf_queue *q, unsigned int *count, unsigned int *size) { struct saa7134_fh *fh = q->priv_data; + struct saa7134_dev *dev = fh->dev; - *size = fh->fmt->depth * fh->width * fh->height >> 3; + *size = dev->fmt->depth * dev->width * dev->height >> 3; if (0 == *count) *count = gbuffers; *count = saa7134_buffer_count(*size,*count); @@ -1334,9 +1335,6 @@ static int video_open(struct file *file) v4l2_fh_init(&fh->fh, vdev); file->private_data = fh; fh->dev = dev; - fh->fmt = format_by_fourcc(V4L2_PIX_FMT_BGR24); - fh->width = 720; - fh->height = 576; videobuf_queue_sg_init(&fh->cap, &video_qops, &dev->pci->dev, &dev->slock, @@ -1556,13 +1554,14 @@ static int saa7134_g_fmt_vid_cap(struct file *file, void *priv, struct v4l2_format *f) { struct saa7134_fh *fh = priv; + struct saa7134_dev *dev = fh->dev; - f->fmt.pix.width = fh->width; - f->fmt.pix.height = fh->height; + f->fmt.pix.width = dev->width; + f->fmt.pix.height = dev->height; f->fmt.pix.field = fh->cap.field; - f->fmt.pix.pixelformat = fh->fmt->fourcc; + f->fmt.pix.pixelformat = dev->fmt->fourcc; f->fmt.pix.bytesperline = - (f->fmt.pix.width * fh->fmt->depth) >> 3; + (f->fmt.pix.width * dev->fmt->depth) >> 3; f->fmt.pix.sizeimage = f->fmt.pix.height * f->fmt.pix.bytesperline; return 0; @@ -1652,15 +1651,16 @@ static int saa7134_s_fmt_vid_cap(struct file *file, void *priv, struct v4l2_format *f) { struct saa7134_fh *fh = priv; + struct saa7134_dev *dev = fh->dev; int err; err = saa7134_try_fmt_vid_cap(file, priv, f); if (0 != err) return err; - fh->fmt = format_by_fourcc(f->fmt.pix.pixelformat); - fh->width = f->fmt.pix.width; - fh->height = f->fmt.pix.height; + dev->fmt = format_by_fourcc(f->fmt.pix.pixelformat); + dev->width = f->fmt.pix.width; + dev->height = f->fmt.pix.height; fh->cap.field = f->fmt.pix.field; return 0; } @@ -2451,6 +2451,9 @@ int saa7134_video_init1(struct saa7134_dev *dev) dev->video_q.timeout.function = saa7134_buffer_timeout; dev->video_q.timeout.data = (unsigned long)(&dev->video_q); dev->video_q.dev = dev; + dev->fmt = format_by_fourcc(V4L2_PIX_FMT_BGR24); + dev->width = 720; + dev->height = 576; if (saa7134_boards[dev->board].video_out) saa7134_videoport_init(dev); diff --git a/drivers/media/pci/saa7134/saa7134.h b/drivers/media/pci/saa7134/saa7134.h index fa21d14ea16e..8a62ff733343 100644 --- a/drivers/media/pci/saa7134/saa7134.h +++ b/drivers/media/pci/saa7134/saa7134.h @@ -475,8 +475,6 @@ struct saa7134_fh { struct pm_qos_request qos_request; /* video capture */ - struct saa7134_format *fmt; - unsigned int width,height; struct videobuf_queue cap; struct saa7134_pgtable pt_cap; @@ -595,6 +593,8 @@ struct saa7134_dev { struct saa7134_dmaqueue vbi_q; unsigned int video_fieldcount; unsigned int vbi_fieldcount; + struct saa7134_format *fmt; + unsigned int width, height; /* various v4l controls */ struct saa7134_tvnorm *tvnorm; /* video */ From 89f3a1422998b35b991c6a059e7acbc99166c5cd Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Fri, 31 May 2013 08:44:58 -0300 Subject: [PATCH 0290/1048] [media] saa7134: move qos_request from saa7134_fh to saa7134_dev This is a global field, not a per-filehandle field. Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/pci/saa7134/saa7134-video.c | 4 ++-- drivers/media/pci/saa7134/saa7134.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/media/pci/saa7134/saa7134-video.c b/drivers/media/pci/saa7134/saa7134-video.c index 30832d38fb54..a7baa246b653 100644 --- a/drivers/media/pci/saa7134/saa7134-video.c +++ b/drivers/media/pci/saa7134/saa7134-video.c @@ -2205,7 +2205,7 @@ static int saa7134_streamon(struct file *file, void *priv, * Unfortunately, I lack register-level documentation to check the * Linux FIFO setup and confirm the perfect value. */ - pm_qos_add_request(&fh->qos_request, + pm_qos_add_request(&dev->qos_request, PM_QOS_CPU_DMA_LATENCY, 20); @@ -2220,7 +2220,7 @@ static int saa7134_streamoff(struct file *file, void *priv, struct saa7134_dev *dev = fh->dev; int res = saa7134_resource(file); - pm_qos_remove_request(&fh->qos_request); + pm_qos_remove_request(&dev->qos_request); err = videobuf_streamoff(saa7134_queue(file)); if (err < 0) diff --git a/drivers/media/pci/saa7134/saa7134.h b/drivers/media/pci/saa7134/saa7134.h index 8a62ff733343..8d1453a48014 100644 --- a/drivers/media/pci/saa7134/saa7134.h +++ b/drivers/media/pci/saa7134/saa7134.h @@ -472,7 +472,6 @@ struct saa7134_fh { struct v4l2_fh fh; struct saa7134_dev *dev; unsigned int resources; - struct pm_qos_request qos_request; /* video capture */ struct videobuf_queue cap; @@ -595,6 +594,7 @@ struct saa7134_dev { unsigned int vbi_fieldcount; struct saa7134_format *fmt; unsigned int width, height; + struct pm_qos_request qos_request; /* various v4l controls */ struct saa7134_tvnorm *tvnorm; /* video */ From 3a0a5a782abb16f257fb1d8fd874ed054ba9a82d Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Fri, 31 May 2013 11:48:50 -0300 Subject: [PATCH 0291/1048] [media] saa7134: fix format-related compliance issues - map overlay format values to the supported ranges - set colorspace - zero priv field - fix cliplist handling - fix field handling - initialize ovbuf values Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/pci/saa7134/saa7134-video.c | 72 ++++++++++++++++------- 1 file changed, 51 insertions(+), 21 deletions(-) diff --git a/drivers/media/pci/saa7134/saa7134-video.c b/drivers/media/pci/saa7134/saa7134-video.c index a7baa246b653..e3457aea6a33 100644 --- a/drivers/media/pci/saa7134/saa7134-video.c +++ b/drivers/media/pci/saa7134/saa7134-video.c @@ -825,20 +825,22 @@ static int setup_clipping(struct saa7134_dev *dev, struct v4l2_clip *clips, return 0; } -static int verify_preview(struct saa7134_dev *dev, struct v4l2_window *win) +static int verify_preview(struct saa7134_dev *dev, struct v4l2_window *win, bool try) { enum v4l2_field field; int maxw, maxh; - if (NULL == dev->ovbuf.base) - return -EINVAL; - if (NULL == dev->ovfmt) - return -EINVAL; - if (win->w.width < 48 || win->w.height < 32) - return -EINVAL; - if (win->clipcount > 2048) + if (!try && (dev->ovbuf.base == NULL || dev->ovfmt == NULL)) return -EINVAL; + if (win->w.width < 48) + win->w.width = 48; + if (win->w.height < 32) + win->w.height = 32; + if (win->clipcount > 8) + win->clipcount = 8; + win->chromakey = 0; + win->global_alpha = 0; field = win->field; maxw = dev->crop_current.width; maxh = dev->crop_current.height; @@ -853,10 +855,9 @@ static int verify_preview(struct saa7134_dev *dev, struct v4l2_window *win) case V4L2_FIELD_BOTTOM: maxh = maxh / 2; break; - case V4L2_FIELD_INTERLACED: - break; default: - return -EINVAL; + field = V4L2_FIELD_INTERLACED; + break; } win->field = field; @@ -872,7 +873,7 @@ static int start_preview(struct saa7134_dev *dev, struct saa7134_fh *fh) unsigned long base,control,bpl; int err; - err = verify_preview(dev, &dev->win); + err = verify_preview(dev, &dev->win, false); if (0 != err) return err; @@ -1564,6 +1565,8 @@ static int saa7134_g_fmt_vid_cap(struct file *file, void *priv, (f->fmt.pix.width * dev->fmt->depth) >> 3; f->fmt.pix.sizeimage = f->fmt.pix.height * f->fmt.pix.bytesperline; + f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M; + f->fmt.pix.priv = 0; return 0; } @@ -1572,14 +1575,32 @@ static int saa7134_g_fmt_vid_overlay(struct file *file, void *priv, { struct saa7134_fh *fh = priv; struct saa7134_dev *dev = fh->dev; + struct v4l2_clip *clips = f->fmt.win.clips; + u32 clipcount = f->fmt.win.clipcount; + int err = 0; + int i; if (saa7134_no_overlay > 0) { printk(KERN_ERR "V4L2_BUF_TYPE_VIDEO_OVERLAY: no_overlay\n"); return -EINVAL; } + mutex_lock(&dev->lock); f->fmt.win = dev->win; + f->fmt.win.clips = clips; + if (clips == NULL) + clipcount = 0; + if (dev->nclips < clipcount) + clipcount = dev->nclips; + f->fmt.win.clipcount = clipcount; - return 0; + for (i = 0; !err && i < clipcount; i++) { + if (copy_to_user(&f->fmt.win.clips[i].c, &dev->clips[i].c, + sizeof(struct v4l2_rect))) + err = -EFAULT; + } + mutex_unlock(&dev->lock); + + return err; } static int saa7134_try_fmt_vid_cap(struct file *file, void *priv, @@ -1609,10 +1630,9 @@ static int saa7134_try_fmt_vid_cap(struct file *file, void *priv, case V4L2_FIELD_BOTTOM: maxh = maxh / 2; break; - case V4L2_FIELD_INTERLACED: - break; default: - return -EINVAL; + field = V4L2_FIELD_INTERLACED; + break; } f->fmt.pix.field = field; @@ -1629,6 +1649,8 @@ static int saa7134_try_fmt_vid_cap(struct file *file, void *priv, (f->fmt.pix.width * fmt->depth) >> 3; f->fmt.pix.sizeimage = f->fmt.pix.height * f->fmt.pix.bytesperline; + f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M; + f->fmt.pix.priv = 0; return 0; } @@ -1644,7 +1666,9 @@ static int saa7134_try_fmt_vid_overlay(struct file *file, void *priv, return -EINVAL; } - return verify_preview(dev, &f->fmt.win); + if (f->fmt.win.clips == NULL) + f->fmt.win.clipcount = 0; + return verify_preview(dev, &f->fmt.win, true); } static int saa7134_s_fmt_vid_cap(struct file *file, void *priv, @@ -1677,7 +1701,9 @@ static int saa7134_s_fmt_vid_overlay(struct file *file, void *priv, printk(KERN_ERR "V4L2_BUF_TYPE_VIDEO_OVERLAY: no_overlay\n"); return -EINVAL; } - err = verify_preview(dev, &f->fmt.win); + if (f->fmt.win.clips == NULL) + f->fmt.win.clipcount = 0; + err = verify_preview(dev, &f->fmt.win, true); if (0 != err) return err; @@ -1686,9 +1712,6 @@ static int saa7134_s_fmt_vid_overlay(struct file *file, void *priv, dev->win = f->fmt.win; dev->nclips = f->fmt.win.clipcount; - if (dev->nclips > 8) - dev->nclips = 8; - if (copy_from_user(dev->clips, f->fmt.win.clips, sizeof(struct v4l2_clip) * dev->nclips)) { mutex_unlock(&dev->lock); @@ -2454,6 +2477,13 @@ int saa7134_video_init1(struct saa7134_dev *dev) dev->fmt = format_by_fourcc(V4L2_PIX_FMT_BGR24); dev->width = 720; dev->height = 576; + dev->win.w.width = dev->width; + dev->win.w.height = dev->height; + dev->win.field = V4L2_FIELD_INTERLACED; + dev->ovbuf.fmt.width = dev->width; + dev->ovbuf.fmt.height = dev->height; + dev->ovbuf.fmt.pixelformat = dev->fmt->fourcc; + dev->ovbuf.fmt.colorspace = V4L2_COLORSPACE_SMPTE170M; if (saa7134_boards[dev->board].video_out) saa7134_videoport_init(dev); From cabc6508984f2d145bdab4a6998072a9e5faf100 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Sat, 1 Jun 2013 10:02:38 -0300 Subject: [PATCH 0292/1048] [media] saa7134: fix empress format compliance bugs Fix uninitialized fields and a missing TRY_FMT implementation in saa6752hs. Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/pci/saa7134/saa6752hs.c | 58 +++++++++++++-------- drivers/media/pci/saa7134/saa7134-empress.c | 13 ++++- 2 files changed, 47 insertions(+), 24 deletions(-) diff --git a/drivers/media/pci/saa7134/saa6752hs.c b/drivers/media/pci/saa7134/saa6752hs.c index 8adb7b02ab5a..8ac4b1f2322d 100644 --- a/drivers/media/pci/saa7134/saa6752hs.c +++ b/drivers/media/pci/saa7134/saa6752hs.c @@ -568,10 +568,36 @@ static int saa6752hs_g_mbus_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefm return 0; } +static int saa6752hs_try_mbus_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *f) +{ + int dist_352, dist_480, dist_720; + + f->code = V4L2_MBUS_FMT_FIXED; + + dist_352 = abs(f->width - 352); + dist_480 = abs(f->width - 480); + dist_720 = abs(f->width - 720); + if (dist_720 < dist_480) { + f->width = 720; + f->height = 576; + } else if (dist_480 < dist_352) { + f->width = 480; + f->height = 576; + } else { + f->width = 352; + if (abs(f->height - 576) < abs(f->height - 288)) + f->height = 576; + else + f->height = 288; + } + f->field = V4L2_FIELD_INTERLACED; + f->colorspace = V4L2_COLORSPACE_SMPTE170M; + return 0; +} + static int saa6752hs_s_mbus_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *f) { struct saa6752hs_state *h = to_state(sd); - int dist_352, dist_480, dist_720; if (f->code != V4L2_MBUS_FMT_FIXED) return -EINVAL; @@ -588,30 +614,15 @@ static int saa6752hs_s_mbus_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefm D1 | 720x576 | 720x480 */ - dist_352 = abs(f->width - 352); - dist_480 = abs(f->width - 480); - dist_720 = abs(f->width - 720); - if (dist_720 < dist_480) { - f->width = 720; - f->height = 576; + saa6752hs_try_mbus_fmt(sd, f); + if (f->width == 720) h->video_format = SAA6752HS_VF_D1; - } else if (dist_480 < dist_352) { - f->width = 480; - f->height = 576; + else if (f->width == 480) h->video_format = SAA6752HS_VF_2_3_D1; - } else { - f->width = 352; - if (abs(f->height - 576) < - abs(f->height - 288)) { - f->height = 576; - h->video_format = SAA6752HS_VF_1_2_D1; - } else { - f->height = 288; - h->video_format = SAA6752HS_VF_SIF; - } - } - f->field = V4L2_FIELD_INTERLACED; - f->colorspace = V4L2_COLORSPACE_SMPTE170M; + else if (f->height == 576) + h->video_format = SAA6752HS_VF_1_2_D1; + else + h->video_format = SAA6752HS_VF_SIF; return 0; } @@ -644,6 +655,7 @@ static const struct v4l2_subdev_core_ops saa6752hs_core_ops = { static const struct v4l2_subdev_video_ops saa6752hs_video_ops = { .s_mbus_fmt = saa6752hs_s_mbus_fmt, + .try_mbus_fmt = saa6752hs_try_mbus_fmt, .g_mbus_fmt = saa6752hs_g_mbus_fmt, }; diff --git a/drivers/media/pci/saa7134/saa7134-empress.c b/drivers/media/pci/saa7134/saa7134-empress.c index 973fa65eb3d3..e66bc3d969cf 100644 --- a/drivers/media/pci/saa7134/saa7134-empress.c +++ b/drivers/media/pci/saa7134/saa7134-empress.c @@ -212,7 +212,7 @@ static int empress_enum_fmt_vid_cap(struct file *file, void *priv, strlcpy(f->description, "MPEG TS", sizeof(f->description)); f->pixelformat = V4L2_PIX_FMT_MPEG; - + f->flags = V4L2_FMT_FLAG_COMPRESSED; return 0; } @@ -227,6 +227,8 @@ static int empress_g_fmt_vid_cap(struct file *file, void *priv, v4l2_fill_pix_format(&f->fmt.pix, &mbus_fmt); f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG; f->fmt.pix.sizeimage = TS_PACKET_SIZE * dev->ts.nr_packets; + f->fmt.pix.bytesperline = 0; + f->fmt.pix.priv = 0; return 0; } @@ -243,6 +245,8 @@ static int empress_s_fmt_vid_cap(struct file *file, void *priv, f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG; f->fmt.pix.sizeimage = TS_PACKET_SIZE * dev->ts.nr_packets; + f->fmt.pix.bytesperline = 0; + f->fmt.pix.priv = 0; return 0; } @@ -251,9 +255,16 @@ static int empress_try_fmt_vid_cap(struct file *file, void *priv, struct v4l2_format *f) { struct saa7134_dev *dev = file->private_data; + struct v4l2_mbus_framefmt mbus_fmt; + + v4l2_fill_mbus_format(&mbus_fmt, &f->fmt.pix, V4L2_MBUS_FMT_FIXED); + saa_call_all(dev, video, try_mbus_fmt, &mbus_fmt); + v4l2_fill_pix_format(&f->fmt.pix, &mbus_fmt); f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG; f->fmt.pix.sizeimage = TS_PACKET_SIZE * dev->ts.nr_packets; + f->fmt.pix.bytesperline = 0; + f->fmt.pix.priv = 0; return 0; } From 3080f8c77f277eb87397d639581ebea859f9ea41 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Mon, 10 Jun 2013 06:57:19 -0300 Subject: [PATCH 0293/1048] [media] ths8200: fix two compiler warnings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit drivers/media/i2c/ths8200.c: In function ‘ths8200_g_register’: drivers/media/i2c/ths8200.c:121:21: warning: unused variable ‘client’ [-Wunused-variable] drivers/media/i2c/ths8200.c: In function ‘ths8200_s_register’: drivers/media/i2c/ths8200.c:132:21: warning: unused variable ‘client’ [-Wunused-variable] Signed-off-by: Hans Verkuil Cc: Prabhakar Lad Signed-off-by: Mauro Carvalho Chehab --- drivers/media/i2c/ths8200.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/media/i2c/ths8200.c b/drivers/media/i2c/ths8200.c index 939682967579..a24f90c5261c 100644 --- a/drivers/media/i2c/ths8200.c +++ b/drivers/media/i2c/ths8200.c @@ -118,8 +118,6 @@ ths8200_write_and_or(struct v4l2_subdev *sd, u8 reg, static int ths8200_g_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg) { - struct i2c_client *client = v4l2_get_subdevdata(sd); - reg->val = ths8200_read(sd, reg->reg & 0xff); reg->size = 1; @@ -129,8 +127,6 @@ static int ths8200_g_register(struct v4l2_subdev *sd, static int ths8200_s_register(struct v4l2_subdev *sd, const struct v4l2_dbg_register *reg) { - struct i2c_client *client = v4l2_get_subdevdata(sd); - ths8200_write(sd, reg->reg & 0xff, reg->val & 0xff); return 0; From 8d4da37c3006f30a7cf75cd7bb33b254afc30279 Mon Sep 17 00:00:00 2001 From: "Lad, Prabhakar" Date: Sun, 26 May 2013 10:08:54 -0300 Subject: [PATCH 0294/1048] [media] media: i2c: mt9p031: add OF support Add OF support for the mt9p031 sensor driver. Alongside this patch sorts the header inclusion alphabetically. Signed-off-by: Lad, Prabhakar Reviewed-by: Sascha Hauer Signed-off-by: Laurent Pinchart Signed-off-by: Mauro Carvalho Chehab --- .../devicetree/bindings/media/i2c/mt9p031.txt | 40 ++++++++++++++++++ drivers/media/i2c/mt9p031.c | 42 ++++++++++++++++++- 2 files changed, 80 insertions(+), 2 deletions(-) create mode 100644 Documentation/devicetree/bindings/media/i2c/mt9p031.txt diff --git a/Documentation/devicetree/bindings/media/i2c/mt9p031.txt b/Documentation/devicetree/bindings/media/i2c/mt9p031.txt new file mode 100644 index 000000000000..cb60443ff78f --- /dev/null +++ b/Documentation/devicetree/bindings/media/i2c/mt9p031.txt @@ -0,0 +1,40 @@ +* Aptina 1/2.5-Inch 5Mp CMOS Digital Image Sensor + +The Aptina MT9P031 is a 1/2.5-inch CMOS active pixel digital image sensor with +an active array size of 2592H x 1944V. It is programmable through a simple +two-wire serial interface. + +Required Properties: +- compatible: value should be either one among the following + (a) "aptina,mt9p031" for mt9p031 sensor + (b) "aptina,mt9p031m" for mt9p031m sensor + +- input-clock-frequency: Input clock frequency. + +- pixel-clock-frequency: Pixel clock frequency. + +Optional Properties: +- reset-gpios: Chip reset GPIO + +For further reading on port node refer to +Documentation/devicetree/bindings/media/video-interfaces.txt. + +Example: + + i2c0@1c22000 { + ... + ... + mt9p031@5d { + compatible = "aptina,mt9p031"; + reg = <0x5d>; + reset-gpios = <&gpio3 30 0>; + + port { + mt9p031_1: endpoint { + input-clock-frequency = <6000000>; + pixel-clock-frequency = <96000000>; + }; + }; + }; + ... + }; diff --git a/drivers/media/i2c/mt9p031.c b/drivers/media/i2c/mt9p031.c index fe3414866a63..1abc86ed2255 100644 --- a/drivers/media/i2c/mt9p031.c +++ b/drivers/media/i2c/mt9p031.c @@ -16,9 +16,10 @@ #include #include #include -#include #include #include +#include +#include #include #include #include @@ -27,6 +28,7 @@ #include #include #include +#include #include #include "aptina-pll.h" @@ -927,10 +929,36 @@ static const struct v4l2_subdev_internal_ops mt9p031_subdev_internal_ops = { * Driver initialization and probing */ +static struct mt9p031_platform_data * +mt9p031_get_pdata(struct i2c_client *client) +{ + struct mt9p031_platform_data *pdata; + struct device_node *np; + + if (!IS_ENABLED(CONFIG_OF) || !client->dev.of_node) + return client->dev.platform_data; + + np = v4l2_of_get_next_endpoint(client->dev.of_node, NULL); + if (!np) + return NULL; + + pdata = devm_kzalloc(&client->dev, sizeof(*pdata), GFP_KERNEL); + if (!pdata) + goto done; + + pdata->reset = of_get_named_gpio(client->dev.of_node, "reset-gpios", 0); + of_property_read_u32(np, "input-clock-frequency", &pdata->ext_freq); + of_property_read_u32(np, "pixel-clock-frequency", &pdata->target_freq); + +done: + of_node_put(np); + return pdata; +} + static int mt9p031_probe(struct i2c_client *client, const struct i2c_device_id *did) { - struct mt9p031_platform_data *pdata = client->dev.platform_data; + struct mt9p031_platform_data *pdata = mt9p031_get_pdata(client); struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent); struct mt9p031 *mt9p031; unsigned int i; @@ -1069,8 +1097,18 @@ static const struct i2c_device_id mt9p031_id[] = { }; MODULE_DEVICE_TABLE(i2c, mt9p031_id); +#if IS_ENABLED(CONFIG_OF) +static const struct of_device_id mt9p031_of_match[] = { + { .compatible = "aptina,mt9p031", }, + { .compatible = "aptina,mt9p031m", }, + { /* sentinel */ }, +}; +MODULE_DEVICE_TABLE(of, mt9p031_of_match); +#endif + static struct i2c_driver mt9p031_i2c_driver = { .driver = { + .of_match_table = of_match_ptr(mt9p031_of_match), .name = "mt9p031", }, .probe = mt9p031_probe, From 7997196cb4fda8a5ad3570a5645bdc73024554ca Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Sat, 8 Jun 2013 04:50:42 -0300 Subject: [PATCH 0295/1048] [media] mt9p031: Use bulk regulator API The sensor is powered by three supplies. Use the bulk regulator API to enable and disable them instead of performing the operations manually. This fixes a warning caused by ignoring the return value of regulator_enable(). Signed-off-by: Laurent Pinchart Signed-off-by: Mauro Carvalho Chehab --- drivers/media/i2c/mt9p031.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/drivers/media/i2c/mt9p031.c b/drivers/media/i2c/mt9p031.c index 1abc86ed2255..4734836fe5a4 100644 --- a/drivers/media/i2c/mt9p031.c +++ b/drivers/media/i2c/mt9p031.c @@ -125,9 +125,7 @@ struct mt9p031 { int power_count; struct clk *clk; - struct regulator *vaa; - struct regulator *vdd; - struct regulator *vdd_io; + struct regulator_bulk_data regulators[3]; enum mt9p031_model model; struct aptina_pll pll; @@ -272,6 +270,8 @@ static inline int mt9p031_pll_disable(struct mt9p031 *mt9p031) static int mt9p031_power_on(struct mt9p031 *mt9p031) { + int ret; + /* Ensure RESET_BAR is low */ if (gpio_is_valid(mt9p031->reset)) { gpio_set_value(mt9p031->reset, 0); @@ -279,9 +279,10 @@ static int mt9p031_power_on(struct mt9p031 *mt9p031) } /* Bring up the supplies */ - regulator_enable(mt9p031->vdd); - regulator_enable(mt9p031->vdd_io); - regulator_enable(mt9p031->vaa); + ret = regulator_bulk_enable(ARRAY_SIZE(mt9p031->regulators), + mt9p031->regulators); + if (ret < 0) + return ret; /* Emable clock */ if (mt9p031->clk) @@ -303,9 +304,8 @@ static void mt9p031_power_off(struct mt9p031 *mt9p031) usleep_range(1000, 2000); } - regulator_disable(mt9p031->vaa); - regulator_disable(mt9p031->vdd_io); - regulator_disable(mt9p031->vdd); + regulator_bulk_disable(ARRAY_SIZE(mt9p031->regulators), + mt9p031->regulators); if (mt9p031->clk) clk_disable_unprepare(mt9p031->clk); @@ -985,14 +985,14 @@ static int mt9p031_probe(struct i2c_client *client, mt9p031->model = did->driver_data; mt9p031->reset = -1; - mt9p031->vaa = devm_regulator_get(&client->dev, "vaa"); - mt9p031->vdd = devm_regulator_get(&client->dev, "vdd"); - mt9p031->vdd_io = devm_regulator_get(&client->dev, "vdd_io"); + mt9p031->regulators[0].supply = "vdd"; + mt9p031->regulators[1].supply = "vdd_io"; + mt9p031->regulators[2].supply = "vaa"; - if (IS_ERR(mt9p031->vaa) || IS_ERR(mt9p031->vdd) || - IS_ERR(mt9p031->vdd_io)) { + ret = devm_regulator_bulk_get(&client->dev, 3, mt9p031->regulators); + if (ret < 0) { dev_err(&client->dev, "Unable to get regulators\n"); - return -ENODEV; + return ret; } v4l2_ctrl_handler_init(&mt9p031->ctrls, ARRAY_SIZE(mt9p031_ctrls) + 6); From 5077ac3b8108007f4a2b4589f2d373cf55453206 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Wed, 22 May 2013 11:25:52 -0300 Subject: [PATCH 0296/1048] Properly handle tristate dependencies on USB/PCI menus As USB/PCI/MEDIA_SUPPORT dependencies can be tristate, we can't simply make the bool menu to be dependent on it. Everything below the menu should also depend on it, otherwise, we risk to allow building them with 'y', while only 'm' would be supported. So, add an IF just before everything below, in order to avoid such risks. Signed-off-by: Mauro Carvalho Chehab --- drivers/media/pci/Kconfig | 4 +++- drivers/media/usb/Kconfig | 3 +-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/media/pci/Kconfig b/drivers/media/pci/Kconfig index d4e2ed3f27e5..53196f1366f3 100644 --- a/drivers/media/pci/Kconfig +++ b/drivers/media/pci/Kconfig @@ -1,6 +1,7 @@ +if PCI && MEDIA_SUPPORT + menuconfig MEDIA_PCI_SUPPORT bool "Media PCI Adapters" - depends on PCI && MEDIA_SUPPORT help Enable media drivers for PCI/PCIe bus. If you have such devices, say Y. @@ -45,3 +46,4 @@ source "drivers/media/pci/ddbridge/Kconfig" endif endif #MEDIA_PCI_SUPPORT +endif #PCI diff --git a/drivers/media/usb/Kconfig b/drivers/media/usb/Kconfig index 0d8fe005d1f4..7cac453e34c7 100644 --- a/drivers/media/usb/Kconfig +++ b/drivers/media/usb/Kconfig @@ -1,8 +1,7 @@ -if USB +if USB && MEDIA_SUPPORT menuconfig MEDIA_USB_SUPPORT bool "Media USB Adapters" - depends on MEDIA_SUPPORT help Enable media drivers for USB bus. If you have such devices, say Y. From e7be28cbfd8b150c5997efc88ed9727b68e636d3 Mon Sep 17 00:00:00 2001 From: Libo Chen Date: Sun, 26 May 2013 22:31:56 -0300 Subject: [PATCH 0297/1048] [media] drivers/media/pci/pt1/pt1: Convert to module_pci_driver use module_pci_driver instead of init/exit, make code clean. Signed-off-by: Libo Chen Signed-off-by: Mauro Carvalho Chehab --- drivers/media/pci/pt1/pt1.c | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/drivers/media/pci/pt1/pt1.c b/drivers/media/pci/pt1/pt1.c index e9211086df49..75ce14229e03 100644 --- a/drivers/media/pci/pt1/pt1.c +++ b/drivers/media/pci/pt1/pt1.c @@ -1225,20 +1225,7 @@ static struct pci_driver pt1_driver = { .id_table = pt1_id_table, }; - -static int __init pt1_init(void) -{ - return pci_register_driver(&pt1_driver); -} - - -static void __exit pt1_cleanup(void) -{ - pci_unregister_driver(&pt1_driver); -} - -module_init(pt1_init); -module_exit(pt1_cleanup); +module_pci_driver(pt1_driver); MODULE_AUTHOR("Takahito HIRANO "); MODULE_DESCRIPTION("Earthsoft PT1/PT2 Driver"); From 2c5f81d29c946165ae01c15e70b1bf2e16929009 Mon Sep 17 00:00:00 2001 From: Libo Chen Date: Sun, 26 May 2013 22:31:43 -0300 Subject: [PATCH 0298/1048] [media] drivers/media/pci/dm1105/dm1105: Convert to module_pci_driver use module_pci_driver instead of init/exit, make code clean. Signed-off-by: Libo Chen Signed-off-by: Mauro Carvalho Chehab --- drivers/media/pci/b2c2/flexcop-pci.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/drivers/media/pci/b2c2/flexcop-pci.c b/drivers/media/pci/b2c2/flexcop-pci.c index 44f8fb5f17ff..447afbd904a4 100644 --- a/drivers/media/pci/b2c2/flexcop-pci.c +++ b/drivers/media/pci/b2c2/flexcop-pci.c @@ -432,18 +432,7 @@ static struct pci_driver flexcop_pci_driver = { .remove = flexcop_pci_remove, }; -static int __init flexcop_pci_module_init(void) -{ - return pci_register_driver(&flexcop_pci_driver); -} - -static void __exit flexcop_pci_module_exit(void) -{ - pci_unregister_driver(&flexcop_pci_driver); -} - -module_init(flexcop_pci_module_init); -module_exit(flexcop_pci_module_exit); +module_pci_driver(flexcop_pci_driver); MODULE_AUTHOR(DRIVER_AUTHOR); MODULE_DESCRIPTION(DRIVER_NAME); From ecef5cc35aefd5bf85abaef9cba74e8ee5a6793a Mon Sep 17 00:00:00 2001 From: Libo Chen Date: Sun, 26 May 2013 22:31:46 -0300 Subject: [PATCH 0299/1048] [media] drivers/media/pci/mantis/hopper_cards: Convert to module_pci_driver use module_pci_driver instead of init/exit, make code clean. Signed-off-by: Libo Chen Signed-off-by: Mauro Carvalho Chehab --- drivers/media/pci/mantis/hopper_cards.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/drivers/media/pci/mantis/hopper_cards.c b/drivers/media/pci/mantis/hopper_cards.c index 6fe9fe5293dc..104914a5bf06 100644 --- a/drivers/media/pci/mantis/hopper_cards.c +++ b/drivers/media/pci/mantis/hopper_cards.c @@ -260,18 +260,7 @@ static struct pci_driver hopper_pci_driver = { .remove = hopper_pci_remove, }; -static int hopper_init(void) -{ - return pci_register_driver(&hopper_pci_driver); -} - -static void hopper_exit(void) -{ - return pci_unregister_driver(&hopper_pci_driver); -} - -module_init(hopper_init); -module_exit(hopper_exit); +module_pci_driver(hopper_pci_driver); MODULE_DESCRIPTION("HOPPER driver"); MODULE_AUTHOR("Manu Abraham"); From 548006ce97e6e6cf63e162d9042ccb78edbd2959 Mon Sep 17 00:00:00 2001 From: Libo Chen Date: Sun, 26 May 2013 22:31:49 -0300 Subject: [PATCH 0300/1048] [media] drivers/media/pci/dm1105/dm1105: Convert to module_pci_driver use module_pci_driver instead of init/exit, make code clean. Signed-off-by: Libo Chen Signed-off-by: Mauro Carvalho Chehab --- drivers/media/pci/dm1105/dm1105.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/drivers/media/pci/dm1105/dm1105.c b/drivers/media/pci/dm1105/dm1105.c index 026767bed5cd..ab797fe466d2 100644 --- a/drivers/media/pci/dm1105/dm1105.c +++ b/drivers/media/pci/dm1105/dm1105.c @@ -1241,18 +1241,7 @@ static struct pci_driver dm1105_driver = { .remove = dm1105_remove, }; -static int __init dm1105_init(void) -{ - return pci_register_driver(&dm1105_driver); -} - -static void __exit dm1105_exit(void) -{ - pci_unregister_driver(&dm1105_driver); -} - -module_init(dm1105_init); -module_exit(dm1105_exit); +module_pci_driver(dm1105_driver); MODULE_AUTHOR("Igor M. Liplianin "); MODULE_DESCRIPTION("SDMC DM1105 DVB driver"); From 6eb2fb3170549737207974c2c6ad34bcc2f3025e Mon Sep 17 00:00:00 2001 From: Libo Chen Date: Sun, 26 May 2013 22:31:53 -0300 Subject: [PATCH 0301/1048] [media] drivers/media/pci/pluto2/pluto2: Convert to module_pci_driver use module_pci_driver instead of init/exit, make code clean. Signed-off-by: Libo Chen Signed-off-by: Mauro Carvalho Chehab --- drivers/media/pci/pluto2/pluto2.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/drivers/media/pci/pluto2/pluto2.c b/drivers/media/pci/pluto2/pluto2.c index 2290faee5852..493828500055 100644 --- a/drivers/media/pci/pluto2/pluto2.c +++ b/drivers/media/pci/pluto2/pluto2.c @@ -796,18 +796,7 @@ static struct pci_driver pluto2_driver = { .remove = pluto2_remove, }; -static int __init pluto2_init(void) -{ - return pci_register_driver(&pluto2_driver); -} - -static void __exit pluto2_exit(void) -{ - pci_unregister_driver(&pluto2_driver); -} - -module_init(pluto2_init); -module_exit(pluto2_exit); +module_pci_driver(pluto2_driver); MODULE_AUTHOR("Andreas Oberritter "); MODULE_DESCRIPTION("Pluto2 driver"); From a19b56e5bcbfb24ccd6a16f934f0c7303394bc42 Mon Sep 17 00:00:00 2001 From: Libo Chen Date: Sun, 26 May 2013 22:31:39 -0300 Subject: [PATCH 0302/1048] [media] drivers/media/pci/mantis/mantis_cards: Convert to module_pci_driver use module_pci_driver instead of init/exit, make code clean Signed-off-by: Libo Chen Signed-off-by: Mauro Carvalho Chehab --- drivers/media/pci/mantis/mantis_cards.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/drivers/media/pci/mantis/mantis_cards.c b/drivers/media/pci/mantis/mantis_cards.c index 932a0d73a7f8..801fc55b6167 100644 --- a/drivers/media/pci/mantis/mantis_cards.c +++ b/drivers/media/pci/mantis/mantis_cards.c @@ -290,18 +290,7 @@ static struct pci_driver mantis_pci_driver = { .remove = mantis_pci_remove, }; -static int mantis_init(void) -{ - return pci_register_driver(&mantis_pci_driver); -} - -static void mantis_exit(void) -{ - return pci_unregister_driver(&mantis_pci_driver); -} - -module_init(mantis_init); -module_exit(mantis_exit); +module_pci_driver(mantis_pci_driver); MODULE_DESCRIPTION("MANTIS driver"); MODULE_AUTHOR("Manu Abraham"); From 07342664d3725de4b21478da222593da491afcd8 Mon Sep 17 00:00:00 2001 From: Thomas Meyer Date: Sat, 1 Jun 2013 05:38:30 -0300 Subject: [PATCH 0303/1048] [media] pvrusb2: Cocci spatch "memdup.spatch" Signed-off-by: Thomas Meyer Signed-off-by: Mauro Carvalho Chehab --- drivers/media/usb/pvrusb2/pvrusb2-io.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/media/usb/pvrusb2/pvrusb2-io.c b/drivers/media/usb/pvrusb2/pvrusb2-io.c index 20b6ae0bb40d..1e354747de3f 100644 --- a/drivers/media/usb/pvrusb2/pvrusb2-io.c +++ b/drivers/media/usb/pvrusb2/pvrusb2-io.c @@ -354,9 +354,9 @@ static int pvr2_stream_buffer_count(struct pvr2_stream *sp,unsigned int cnt) if (scnt < sp->buffer_slot_count) { struct pvr2_buffer **nb = NULL; if (scnt) { - nb = kmalloc(scnt * sizeof(*nb),GFP_KERNEL); + nb = kmemdup(sp->buffers, scnt * sizeof(*nb), + GFP_KERNEL); if (!nb) return -ENOMEM; - memcpy(nb,sp->buffers,scnt * sizeof(*nb)); } kfree(sp->buffers); sp->buffers = nb; From e049ca5e854263c821a15c0e25fe2ae202c365e1 Mon Sep 17 00:00:00 2001 From: Alexey Khoroshilov Date: Sun, 2 Jun 2013 22:58:49 -0300 Subject: [PATCH 0304/1048] [media] staging/media: lirc_imon: fix leaks in imon_probe() Error handling of usb_submit_urb() is not as all others in imon_probe(). It just unlocks mutexes and returns nonzero leaving all already allocated resources unfreed. The patch makes sure all the resources are deallocated. Found by Linux Driver Verification project (linuxtesting.org). Signed-off-by: Alexey Khoroshilov Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/lirc/lirc_imon.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/staging/media/lirc/lirc_imon.c b/drivers/staging/media/lirc/lirc_imon.c index 0a2c45dd4475..4afa7da11f37 100644 --- a/drivers/staging/media/lirc/lirc_imon.c +++ b/drivers/staging/media/lirc/lirc_imon.c @@ -911,8 +911,8 @@ static int imon_probe(struct usb_interface *interface, if (retval) { dev_err(dev, "%s: usb_submit_urb failed for intf0 (%d)\n", __func__, retval); - mutex_unlock(&context->ctx_lock); - goto exit; + alloc_status = 8; + goto unlock; } usb_set_intfdata(interface, context); @@ -937,6 +937,8 @@ unlock: alloc_status_switch: switch (alloc_status) { + case 8: + lirc_unregister_driver(driver->minor); case 7: usb_free_urb(tx_urb); case 6: @@ -959,7 +961,6 @@ alloc_status_switch: retval = 0; } -exit: mutex_unlock(&driver_lock); return retval; From 9601cd159565fa228edc8e5ea3ed2c0ac3fb4d1f Mon Sep 17 00:00:00 2001 From: Paul Bolle Date: Thu, 30 May 2013 09:20:15 +0000 Subject: [PATCH 0305/1048] MIPS: DEC: remove unbuildable promcon.c promcon.o is built if CONFIG_PROM_CONSOLE is set. But there's no Kconfig symbol PROM_CONSOLE, so promcon.c is unbuildable. Remove it. Signed-off-by: Paul Bolle Acked-by: Maciej W. Rozycki Cc: linux-mips@linux-mips.org Cc: linux-kernel@vger.kernel.org Patchwork: https://patchwork.linux-mips.org/patch/5344/ Signed-off-by: Ralf Baechle --- arch/mips/dec/Makefile | 1 - arch/mips/dec/promcon.c | 54 ----------------------------------------- 2 files changed, 55 deletions(-) delete mode 100644 arch/mips/dec/promcon.c diff --git a/arch/mips/dec/Makefile b/arch/mips/dec/Makefile index 9eb2f9c036aa..3d5d2c56de8d 100644 --- a/arch/mips/dec/Makefile +++ b/arch/mips/dec/Makefile @@ -5,6 +5,5 @@ obj-y := ecc-berr.o int-handler.o ioasic-irq.o kn01-berr.o \ kn02-irq.o kn02xa-berr.o reset.o setup.o time.o -obj-$(CONFIG_PROM_CONSOLE) += promcon.o obj-$(CONFIG_TC) += tc.o obj-$(CONFIG_CPU_HAS_WB) += wbflush.o diff --git a/arch/mips/dec/promcon.c b/arch/mips/dec/promcon.c deleted file mode 100644 index c239c25b79ff..000000000000 --- a/arch/mips/dec/promcon.c +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Wrap-around code for a console using the - * DECstation PROM io-routines. - * - * Copyright (c) 1998 Harald Koerfgen - */ - -#include -#include -#include -#include -#include - -#include - -static void prom_console_write(struct console *co, const char *s, - unsigned count) -{ - unsigned i; - - /* - * Now, do each character - */ - for (i = 0; i < count; i++) { - if (*s == 10) - prom_printf("%c", 13); - prom_printf("%c", *s++); - } -} - -static int __init prom_console_setup(struct console *co, char *options) -{ - return 0; -} - -static struct console sercons = { - .name = "ttyS", - .write = prom_console_write, - .setup = prom_console_setup, - .flags = CON_PRINTBUFFER, - .index = -1, -}; - -/* - * Register console. - */ - -static int __init prom_console_init(void) -{ - register_console(&sercons); - - return 0; -} -console_initcall(prom_console_init); From b8061134f83a36b9eb6e38a184f3982f8d8bc58c Mon Sep 17 00:00:00 2001 From: Paul Bolle Date: Thu, 30 May 2013 09:51:21 +0000 Subject: [PATCH 0306/1048] MIPS: MSP71xx: Remove gpio drivers The PMC MSP71XX gpio drivers were added in v2.6.28, see commit 9fa32c6b02 ("MIPS: PMC MSP71XX gpio drivers"). They are only built if CONFIG_HAVE_GPIO_LIB is set. But the Kconfig symbol HAVE_GPIO_LIB was already removed in v2.6.27, see commit 7444a72eff ("gpiolib: allow user-selection"). So these drivers were never buildable. Perhaps no-one noticed because there are no in tree users of msp71xx_init_gpio() and msp71xx_init_gpio_extended(). Anyhow, these drivers can safely be removed. Signed-off-by: Paul Bolle Cc: linux-mips@linux-mips.org Cc: linux-kernel@vger.kernel.org Patchwork: https://patchwork.linux-mips.org/patch/5345/ Signed-off-by: Ralf Baechle --- .../mips/include/asm/mach-pmcs-msp71xx/gpio.h | 46 ---- arch/mips/pmcs-msp71xx/Makefile | 1 - arch/mips/pmcs-msp71xx/gpio.c | 216 ------------------ arch/mips/pmcs-msp71xx/gpio_extended.c | 146 ------------ 4 files changed, 409 deletions(-) delete mode 100644 arch/mips/include/asm/mach-pmcs-msp71xx/gpio.h delete mode 100644 arch/mips/pmcs-msp71xx/gpio.c delete mode 100644 arch/mips/pmcs-msp71xx/gpio_extended.c diff --git a/arch/mips/include/asm/mach-pmcs-msp71xx/gpio.h b/arch/mips/include/asm/mach-pmcs-msp71xx/gpio.h deleted file mode 100644 index ebdbab973e41..000000000000 --- a/arch/mips/include/asm/mach-pmcs-msp71xx/gpio.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * include/asm-mips/pmc-sierra/msp71xx/gpio.h - * - * 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. - * - * @author Patrick Glass - */ - -#ifndef __PMC_MSP71XX_GPIO_H -#define __PMC_MSP71XX_GPIO_H - -/* Max number of gpio's is 28 on chip plus 3 banks of I2C IO Expanders */ -#define ARCH_NR_GPIOS (28 + (3 * 8)) - -/* new generic GPIO API - see Documentation/gpio.txt */ -#include - -#define gpio_get_value __gpio_get_value -#define gpio_set_value __gpio_set_value -#define gpio_cansleep __gpio_cansleep - -/* Setup calls for the gpio and gpio extended */ -extern void msp71xx_init_gpio(void); -extern void msp71xx_init_gpio_extended(void); -extern int msp71xx_set_output_drive(unsigned gpio, int value); - -/* Custom output drive functionss */ -static inline int gpio_set_output_drive(unsigned gpio, int value) -{ - return msp71xx_set_output_drive(gpio, value); -} - -/* IRQ's are not supported for gpio lines */ -static inline int gpio_to_irq(unsigned gpio) -{ - return -EINVAL; -} - -static inline int irq_to_gpio(unsigned irq) -{ - return -EINVAL; -} - -#endif /* __PMC_MSP71XX_GPIO_H */ diff --git a/arch/mips/pmcs-msp71xx/Makefile b/arch/mips/pmcs-msp71xx/Makefile index cefba7733b73..9201c8b3858d 100644 --- a/arch/mips/pmcs-msp71xx/Makefile +++ b/arch/mips/pmcs-msp71xx/Makefile @@ -3,7 +3,6 @@ # obj-y += msp_prom.o msp_setup.o msp_irq.o \ msp_time.o msp_serial.o msp_elb.o -obj-$(CONFIG_HAVE_GPIO_LIB) += gpio.o gpio_extended.o obj-$(CONFIG_PMC_MSP7120_GW) += msp_hwbutton.o obj-$(CONFIG_IRQ_MSP_SLP) += msp_irq_slp.o obj-$(CONFIG_IRQ_MSP_CIC) += msp_irq_cic.o msp_irq_per.o diff --git a/arch/mips/pmcs-msp71xx/gpio.c b/arch/mips/pmcs-msp71xx/gpio.c deleted file mode 100644 index aaccbe524386..000000000000 --- a/arch/mips/pmcs-msp71xx/gpio.c +++ /dev/null @@ -1,216 +0,0 @@ -/* - * Generic PMC MSP71xx GPIO handling. These base gpio are controlled by two - * types of registers. The data register sets the output level when in output - * mode and when in input mode will contain the value at the input. The config - * register sets the various modes for each gpio. - * - * 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. - * - * @author Patrick Glass - */ - -#include -#include -#include -#include -#include -#include - -#define MSP71XX_CFG_OFFSET(gpio) (4 * (gpio)) -#define CONF_MASK 0x0F -#define MSP71XX_GPIO_INPUT 0x01 -#define MSP71XX_GPIO_OUTPUT 0x08 - -#define MSP71XX_GPIO_BASE 0x0B8400000L - -#define to_msp71xx_gpio_chip(c) container_of(c, struct msp71xx_gpio_chip, chip) - -static spinlock_t gpio_lock; - -/* - * struct msp71xx_gpio_chip - container for gpio chip and registers - * @chip: chip structure for the specified gpio bank - * @data_reg: register for reading and writing the gpio pin value - * @config_reg: register to set the mode for the gpio pin bank - * @out_drive_reg: register to set the output drive mode for the gpio pin bank - */ -struct msp71xx_gpio_chip { - struct gpio_chip chip; - void __iomem *data_reg; - void __iomem *config_reg; - void __iomem *out_drive_reg; -}; - -/* - * msp71xx_gpio_get() - return the chip's gpio value - * @chip: chip structure which controls the specified gpio - * @offset: gpio whose value will be returned - * - * It will return 0 if gpio value is low and other if high. - */ -static int msp71xx_gpio_get(struct gpio_chip *chip, unsigned offset) -{ - struct msp71xx_gpio_chip *msp_chip = to_msp71xx_gpio_chip(chip); - - return __raw_readl(msp_chip->data_reg) & (1 << offset); -} - -/* - * msp71xx_gpio_set() - set the output value for the gpio - * @chip: chip structure who controls the specified gpio - * @offset: gpio whose value will be assigned - * @value: logic level to assign to the gpio initially - * - * This will set the gpio bit specified to the desired value. It will set the - * gpio pin low if value is 0 otherwise it will be high. - */ -static void msp71xx_gpio_set(struct gpio_chip *chip, unsigned offset, int value) -{ - struct msp71xx_gpio_chip *msp_chip = to_msp71xx_gpio_chip(chip); - unsigned long flags; - u32 data; - - spin_lock_irqsave(&gpio_lock, flags); - - data = __raw_readl(msp_chip->data_reg); - if (value) - data |= (1 << offset); - else - data &= ~(1 << offset); - __raw_writel(data, msp_chip->data_reg); - - spin_unlock_irqrestore(&gpio_lock, flags); -} - -/* - * msp71xx_set_gpio_mode() - declare the mode for a gpio - * @chip: chip structure which controls the specified gpio - * @offset: gpio whose value will be assigned - * @mode: desired configuration for the gpio (see datasheet) - * - * It will set the gpio pin config to the @mode value passed in. - */ -static int msp71xx_set_gpio_mode(struct gpio_chip *chip, - unsigned offset, int mode) -{ - struct msp71xx_gpio_chip *msp_chip = to_msp71xx_gpio_chip(chip); - const unsigned bit_offset = MSP71XX_CFG_OFFSET(offset); - unsigned long flags; - u32 cfg; - - spin_lock_irqsave(&gpio_lock, flags); - - cfg = __raw_readl(msp_chip->config_reg); - cfg &= ~(CONF_MASK << bit_offset); - cfg |= (mode << bit_offset); - __raw_writel(cfg, msp_chip->config_reg); - - spin_unlock_irqrestore(&gpio_lock, flags); - - return 0; -} - -/* - * msp71xx_direction_output() - declare the direction mode for a gpio - * @chip: chip structure which controls the specified gpio - * @offset: gpio whose value will be assigned - * @value: logic level to assign to the gpio initially - * - * This call will set the mode for the @gpio to output. It will set the - * gpio pin low if value is 0 otherwise it will be high. - */ -static int msp71xx_direction_output(struct gpio_chip *chip, - unsigned offset, int value) -{ - msp71xx_gpio_set(chip, offset, value); - - return msp71xx_set_gpio_mode(chip, offset, MSP71XX_GPIO_OUTPUT); -} - -/* - * msp71xx_direction_input() - declare the direction mode for a gpio - * @chip: chip structure which controls the specified gpio - * @offset: gpio whose to which the value will be assigned - * - * This call will set the mode for the @gpio to input. - */ -static int msp71xx_direction_input(struct gpio_chip *chip, unsigned offset) -{ - return msp71xx_set_gpio_mode(chip, offset, MSP71XX_GPIO_INPUT); -} - -/* - * msp71xx_set_output_drive() - declare the output drive for the gpio line - * @gpio: gpio pin whose output drive you wish to modify - * @value: zero for active drain 1 for open drain drive - * - * This call will set the output drive mode for the @gpio to output. - */ -int msp71xx_set_output_drive(unsigned gpio, int value) -{ - unsigned long flags; - u32 data; - - if (gpio > 15 || gpio < 0) - return -EINVAL; - - spin_lock_irqsave(&gpio_lock, flags); - - data = __raw_readl((void __iomem *)(MSP71XX_GPIO_BASE + 0x190)); - if (value) - data |= (1 << gpio); - else - data &= ~(1 << gpio); - __raw_writel(data, (void __iomem *)(MSP71XX_GPIO_BASE + 0x190)); - - spin_unlock_irqrestore(&gpio_lock, flags); - - return 0; -} -EXPORT_SYMBOL(msp71xx_set_output_drive); - -#define MSP71XX_GPIO_BANK(name, dr, cr, base_gpio, num_gpio) \ -{ \ - .chip = { \ - .label = name, \ - .direction_input = msp71xx_direction_input, \ - .direction_output = msp71xx_direction_output, \ - .get = msp71xx_gpio_get, \ - .set = msp71xx_gpio_set, \ - .base = base_gpio, \ - .ngpio = num_gpio \ - }, \ - .data_reg = (void __iomem *)(MSP71XX_GPIO_BASE + dr), \ - .config_reg = (void __iomem *)(MSP71XX_GPIO_BASE + cr), \ - .out_drive_reg = (void __iomem *)(MSP71XX_GPIO_BASE + 0x190), \ -} - -/* - * struct msp71xx_gpio_banks[] - container array of gpio banks - * @chip: chip structure for the specified gpio bank - * @data_reg: register for reading and writing the gpio pin value - * @config_reg: register to set the mode for the gpio pin bank - * - * This array structure defines the gpio banks for the PMC MIPS Processor. - * We specify the bank name, the data register, the config register, base - * starting gpio number, and the number of gpios exposed by the bank. - */ -static struct msp71xx_gpio_chip msp71xx_gpio_banks[] = { - - MSP71XX_GPIO_BANK("GPIO_1_0", 0x170, 0x180, 0, 2), - MSP71XX_GPIO_BANK("GPIO_5_2", 0x174, 0x184, 2, 4), - MSP71XX_GPIO_BANK("GPIO_9_6", 0x178, 0x188, 6, 4), - MSP71XX_GPIO_BANK("GPIO_15_10", 0x17C, 0x18C, 10, 6), -}; - -void __init msp71xx_init_gpio(void) -{ - int i; - - spin_lock_init(&gpio_lock); - - for (i = 0; i < ARRAY_SIZE(msp71xx_gpio_banks); i++) - gpiochip_add(&msp71xx_gpio_banks[i].chip); -} diff --git a/arch/mips/pmcs-msp71xx/gpio_extended.c b/arch/mips/pmcs-msp71xx/gpio_extended.c deleted file mode 100644 index 2a99f360fae4..000000000000 --- a/arch/mips/pmcs-msp71xx/gpio_extended.c +++ /dev/null @@ -1,146 +0,0 @@ -/* - * Generic PMC MSP71xx EXTENDED (EXD) GPIO handling. The extended gpio is - * a set of hardware registers that have no need for explicit locking as - * it is handled by unique method of writing individual set/clr bits. - * - * 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. - * - * @author Patrick Glass - */ - -#include -#include -#include -#include -#include - -#define MSP71XX_DATA_OFFSET(gpio) (2 * (gpio)) -#define MSP71XX_READ_OFFSET(gpio) (MSP71XX_DATA_OFFSET(gpio) + 1) -#define MSP71XX_CFG_OUT_OFFSET(gpio) (MSP71XX_DATA_OFFSET(gpio) + 16) -#define MSP71XX_CFG_IN_OFFSET(gpio) (MSP71XX_CFG_OUT_OFFSET(gpio) + 1) - -#define MSP71XX_EXD_GPIO_BASE 0x0BC000000L - -#define to_msp71xx_exd_gpio_chip(c) \ - container_of(c, struct msp71xx_exd_gpio_chip, chip) - -/* - * struct msp71xx_exd_gpio_chip - container for gpio chip and registers - * @chip: chip structure for the specified gpio bank - * @reg: register for control and data of gpio pin - */ -struct msp71xx_exd_gpio_chip { - struct gpio_chip chip; - void __iomem *reg; -}; - -/* - * msp71xx_exd_gpio_get() - return the chip's gpio value - * @chip: chip structure which controls the specified gpio - * @offset: gpio whose value will be returned - * - * It will return 0 if gpio value is low and other if high. - */ -static int msp71xx_exd_gpio_get(struct gpio_chip *chip, unsigned offset) -{ - struct msp71xx_exd_gpio_chip *msp71xx_chip = - to_msp71xx_exd_gpio_chip(chip); - const unsigned bit = MSP71XX_READ_OFFSET(offset); - - return __raw_readl(msp71xx_chip->reg) & (1 << bit); -} - -/* - * msp71xx_exd_gpio_set() - set the output value for the gpio - * @chip: chip structure who controls the specified gpio - * @offset: gpio whose value will be assigned - * @value: logic level to assign to the gpio initially - * - * This will set the gpio bit specified to the desired value. It will set the - * gpio pin low if value is 0 otherwise it will be high. - */ -static void msp71xx_exd_gpio_set(struct gpio_chip *chip, - unsigned offset, int value) -{ - struct msp71xx_exd_gpio_chip *msp71xx_chip = - to_msp71xx_exd_gpio_chip(chip); - const unsigned bit = MSP71XX_DATA_OFFSET(offset); - - __raw_writel(1 << (bit + (value ? 1 : 0)), msp71xx_chip->reg); -} - -/* - * msp71xx_exd_direction_output() - declare the direction mode for a gpio - * @chip: chip structure which controls the specified gpio - * @offset: gpio whose value will be assigned - * @value: logic level to assign to the gpio initially - * - * This call will set the mode for the @gpio to output. It will set the - * gpio pin low if value is 0 otherwise it will be high. - */ -static int msp71xx_exd_direction_output(struct gpio_chip *chip, - unsigned offset, int value) -{ - struct msp71xx_exd_gpio_chip *msp71xx_chip = - to_msp71xx_exd_gpio_chip(chip); - - msp71xx_exd_gpio_set(chip, offset, value); - __raw_writel(1 << MSP71XX_CFG_OUT_OFFSET(offset), msp71xx_chip->reg); - return 0; -} - -/* - * msp71xx_exd_direction_input() - declare the direction mode for a gpio - * @chip: chip structure which controls the specified gpio - * @offset: gpio whose to which the value will be assigned - * - * This call will set the mode for the @gpio to input. - */ -static int msp71xx_exd_direction_input(struct gpio_chip *chip, unsigned offset) -{ - struct msp71xx_exd_gpio_chip *msp71xx_chip = - to_msp71xx_exd_gpio_chip(chip); - - __raw_writel(1 << MSP71XX_CFG_IN_OFFSET(offset), msp71xx_chip->reg); - return 0; -} - -#define MSP71XX_EXD_GPIO_BANK(name, exd_reg, base_gpio, num_gpio) \ -{ \ - .chip = { \ - .label = name, \ - .direction_input = msp71xx_exd_direction_input, \ - .direction_output = msp71xx_exd_direction_output, \ - .get = msp71xx_exd_gpio_get, \ - .set = msp71xx_exd_gpio_set, \ - .base = base_gpio, \ - .ngpio = num_gpio, \ - }, \ - .reg = (void __iomem *)(MSP71XX_EXD_GPIO_BASE + exd_reg), \ -} - -/* - * struct msp71xx_exd_gpio_banks[] - container array of gpio banks - * @chip: chip structure for the specified gpio bank - * @reg: register for reading and writing the gpio pin value - * - * This array structure defines the extended gpio banks for the - * PMC MIPS Processor. We specify the bank name, the data/config - * register,the base starting gpio number, and the number of - * gpios exposed by the bank of gpios. - */ -static struct msp71xx_exd_gpio_chip msp71xx_exd_gpio_banks[] = { - - MSP71XX_EXD_GPIO_BANK("GPIO_23_16", 0x188, 16, 8), - MSP71XX_EXD_GPIO_BANK("GPIO_27_24", 0x18C, 24, 4), -}; - -void __init msp71xx_init_gpio_extended(void) -{ - int i; - - for (i = 0; i < ARRAY_SIZE(msp71xx_exd_gpio_banks); i++) - gpiochip_add(&msp71xx_exd_gpio_banks[i].chip); -} From d3478d5b73efb713378bebb31ac9a11f5a6dc587 Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Fri, 14 Jun 2013 01:37:29 +0000 Subject: [PATCH 0307/1048] mips: lasat: sysctl: Convert use of typedef ctl_table to struct ctl_table This typedef is unnecessary and should just be removed. Signed-off-by: Joe Perches Cc: Jiri Kosina Cc: linux-mips@linux-mips.org Cc: linux-kernel@vger.kernel.org Patchwork: https://patchwork.linux-mips.org/patch/5460/ Signed-off-by: Ralf Baechle --- arch/mips/lasat/sysctl.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/arch/mips/lasat/sysctl.c b/arch/mips/lasat/sysctl.c index f27694fb2ad1..3b7f65cc4218 100644 --- a/arch/mips/lasat/sysctl.c +++ b/arch/mips/lasat/sysctl.c @@ -39,7 +39,7 @@ /* And the same for proc */ -int proc_dolasatstring(ctl_table *table, int write, +int proc_dolasatstring(struct ctl_table *table, int write, void *buffer, size_t *lenp, loff_t *ppos) { int r; @@ -54,7 +54,7 @@ int proc_dolasatstring(ctl_table *table, int write, } /* proc function to write EEPROM after changing int entry */ -int proc_dolasatint(ctl_table *table, int write, +int proc_dolasatint(struct ctl_table *table, int write, void *buffer, size_t *lenp, loff_t *ppos) { int r; @@ -72,7 +72,7 @@ int proc_dolasatint(ctl_table *table, int write, static int rtctmp; /* proc function to read/write RealTime Clock */ -int proc_dolasatrtc(ctl_table *table, int write, +int proc_dolasatrtc(struct ctl_table *table, int write, void *buffer, size_t *lenp, loff_t *ppos) { struct timespec ts; @@ -97,7 +97,7 @@ int proc_dolasatrtc(ctl_table *table, int write, #endif #ifdef CONFIG_INET -int proc_lasat_ip(ctl_table *table, int write, +int proc_lasat_ip(struct ctl_table *table, int write, void *buffer, size_t *lenp, loff_t *ppos) { unsigned int ip; @@ -157,7 +157,7 @@ int proc_lasat_ip(ctl_table *table, int write, } #endif -int proc_lasat_prid(ctl_table *table, int write, +int proc_lasat_prid(struct ctl_table *table, int write, void *buffer, size_t *lenp, loff_t *ppos) { int r; @@ -176,7 +176,7 @@ int proc_lasat_prid(ctl_table *table, int write, extern int lasat_boot_to_service; -static ctl_table lasat_table[] = { +static struct ctl_table lasat_table[] = { { .procname = "cpu-hz", .data = &lasat_board_info.li_cpu_hz, @@ -262,7 +262,7 @@ static ctl_table lasat_table[] = { {} }; -static ctl_table lasat_root_table[] = { +static struct ctl_table lasat_root_table[] = { { .procname = "lasat", .mode = 0555, From c5cdc67a58a22c49f558b450c6f748251ceb2e7b Mon Sep 17 00:00:00 2001 From: Grant Likely Date: Thu, 13 Jun 2013 22:19:43 +0000 Subject: [PATCH 0308/1048] irqdomain: Remove temporary MIPS workaround code The MIPS interrupt controllers are all registering their own irq_domains now. Drop the MIPS specific code because it is no longer needed. Signed-off-by: Grant Likely Cc: linux-mips@linux-mips.org Cc: linux-kernel@vger.kernel.org Patchwork: https://patchwork.linux-mips.org/patch/5458/ Signed-off-by: Ralf Baechle --- kernel/irq/irqdomain.c | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c index 54a4d5223238..a341b3d433ad 100644 --- a/kernel/irq/irqdomain.c +++ b/kernel/irq/irqdomain.c @@ -665,18 +665,6 @@ unsigned int irq_create_of_mapping(struct device_node *controller, domain = controller ? irq_find_host(controller) : irq_default_domain; if (!domain) { -#ifdef CONFIG_MIPS - /* - * Workaround to avoid breaking interrupt controller drivers - * that don't yet register an irq_domain. This is temporary - * code. ~~~gcl, Feb 24, 2012 - * - * Scheduled for removal in Linux v3.6. That should be enough - * time. - */ - if (intsize > 0) - return intspec[0]; -#endif pr_warning("no irq domain found for %s !\n", of_node_full_name(controller)); return 0; From f746caa3fcd23663489bb6d4b41091b75a16efa2 Mon Sep 17 00:00:00 2001 From: Ralf Baechle Date: Wed, 12 Jun 2013 20:04:36 +0200 Subject: [PATCH 0309/1048] MIPS: --- arch/mips/include/uapi/asm/resource.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/mips/include/uapi/asm/resource.h b/arch/mips/include/uapi/asm/resource.h index 87cb3085269c..b26439d4ab0b 100644 --- a/arch/mips/include/uapi/asm/resource.h +++ b/arch/mips/include/uapi/asm/resource.h @@ -26,7 +26,7 @@ * but we keep the old value on MIPS32, * for compatibility: */ -#ifdef CONFIG_32BIT +#ifndef __mips64 # define RLIM_INFINITY 0x7fffffffUL #endif From cfb9a4e7a0d821902e8cf77cabd34ef76e214e9d Mon Sep 17 00:00:00 2001 From: Ralf Baechle Date: Wed, 12 Jun 2013 21:06:52 +0200 Subject: [PATCH 0310/1048] MIPS: : Don't reference CONFIG_* symbols. Signed-off-by: Ralf Baechle --- arch/mips/include/uapi/asm/swab.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/arch/mips/include/uapi/asm/swab.h b/arch/mips/include/uapi/asm/swab.h index 97c2f81b4b43..ac9a8f9cd1fb 100644 --- a/arch/mips/include/uapi/asm/swab.h +++ b/arch/mips/include/uapi/asm/swab.h @@ -13,7 +13,7 @@ #define __SWAB_64_THRU_32__ -#ifdef CONFIG_CPU_MIPSR2 +#if defined(__mips_isa_rev) && (__mips_isa_rev >= 2) static inline __attribute_const__ __u16 __arch_swab16(__u16 x) { @@ -39,10 +39,10 @@ static inline __attribute_const__ __u32 __arch_swab32(__u32 x) #define __arch_swab32 __arch_swab32 /* - * Having already checked for CONFIG_CPU_MIPSR2, enable the - * optimized version for 64-bit kernel on r2 CPUs. + * Having already checked for MIPS R2, enable the optimized version for + * 64-bit kernel on r2 CPUs. */ -#ifdef CONFIG_64BIT +#ifdef __mips64 static inline __attribute_const__ __u64 __arch_swab64(__u64 x) { __asm__( @@ -54,6 +54,6 @@ static inline __attribute_const__ __u64 __arch_swab64(__u64 x) return x; } #define __arch_swab64 __arch_swab64 -#endif /* CONFIG_64BIT */ -#endif /* CONFIG_CPU_MIPSR2 */ +#endif /* __mips64 */ +#endif /* MIPS R2 or newer */ #endif /* _ASM_SWAB_H */ From cfceb5e210d28d5dbc4d10e2a9191f4a81c4cece Mon Sep 17 00:00:00 2001 From: Ralf Baechle Date: Wed, 12 Jun 2013 21:16:15 +0200 Subject: [PATCH 0311/1048] MIPS: : Don't reference CONFIG_* symbols. Signed-off-by: Ralf Baechle --- arch/mips/include/uapi/asm/msgbuf.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/arch/mips/include/uapi/asm/msgbuf.h b/arch/mips/include/uapi/asm/msgbuf.h index 0d6c7f14de31..df849e87d9ae 100644 --- a/arch/mips/include/uapi/asm/msgbuf.h +++ b/arch/mips/include/uapi/asm/msgbuf.h @@ -14,25 +14,25 @@ struct msqid64_ds { struct ipc64_perm msg_perm; -#if defined(CONFIG_32BIT) && !defined(CONFIG_CPU_LITTLE_ENDIAN) +#if !defined(__mips64) && defined(__MIPSEB__) unsigned long __unused1; #endif __kernel_time_t msg_stime; /* last msgsnd time */ -#if defined(CONFIG_32BIT) && defined(CONFIG_CPU_LITTLE_ENDIAN) +#if !defined(__mips64) && defined(__MIPSEL__) unsigned long __unused1; #endif -#if defined(CONFIG_32BIT) && !defined(CONFIG_CPU_LITTLE_ENDIAN) +#if !defined(__mips64) && defined(__MIPSEB__) unsigned long __unused2; #endif __kernel_time_t msg_rtime; /* last msgrcv time */ -#if defined(CONFIG_32BIT) && defined(CONFIG_CPU_LITTLE_ENDIAN) +#if !defined(__mips64) && defined(__MIPSEL__) unsigned long __unused2; #endif -#if defined(CONFIG_32BIT) && !defined(CONFIG_CPU_LITTLE_ENDIAN) +#if !defined(__mips64) && defined(__MIPSEB__) unsigned long __unused3; #endif __kernel_time_t msg_ctime; /* last change time */ -#if defined(CONFIG_32BIT) && defined(CONFIG_CPU_LITTLE_ENDIAN) +#if !defined(__mips64) && defined(__MIPSEL__) unsigned long __unused3; #endif unsigned long msg_cbytes; /* current number of bytes on queue */ From c8d5c685647f7ce73ed642a9130e930ab69178d4 Mon Sep 17 00:00:00 2001 From: Ralf Baechle Date: Wed, 12 Jun 2013 21:23:52 +0200 Subject: [PATCH 0312/1048] MIPS: : Don't reference CONFIG_* symbols. Signed-off-by: Ralf Baechle --- arch/mips/include/uapi/asm/siginfo.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/mips/include/uapi/asm/siginfo.h b/arch/mips/include/uapi/asm/siginfo.h index 6a8714193fb9..b7a23064841f 100644 --- a/arch/mips/include/uapi/asm/siginfo.h +++ b/arch/mips/include/uapi/asm/siginfo.h @@ -25,10 +25,10 @@ struct siginfo; /* * Careful to keep union _sifields from shifting ... */ -#ifdef CONFIG_32BIT +#if __SIZEOF_LONG__ == 4 #define __ARCH_SI_PREAMBLE_SIZE (3 * sizeof(int)) #endif -#ifdef CONFIG_64BIT +#if __SIZEOF_LONG__ == 8 #define __ARCH_SI_PREAMBLE_SIZE (4 * sizeof(int)) #endif From 39205750efa6d335fac4f9bcd32b49c7e71c12b7 Mon Sep 17 00:00:00 2001 From: Ralf Baechle Date: Thu, 13 Jun 2013 01:29:24 +0200 Subject: [PATCH 0313/1048] MIPS: Oceton: Fix build error. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If CONFIG_CAVIUM_OCTEON_LOCK_L2_TLB, CONFIG_CAVIUM_OCTEON_LOCK_L2_EXCEPTION, CONFIG_CAVIUM_OCTEON_LOCK_L2_LOW_LEVEL_INTERRUPT and CONFIG_CAVIUM_OCTEON_LOCK_L2_INTERRUPT are all undefined: arch/mips/cavium-octeon/setup.c: In function ‘prom_init’: arch/mips/cavium-octeon/setup.c:715:12: error: unused variable ‘ebase’ [-Werror=unused-variable] Signed-off-by: Ralf Baechle --- arch/mips/cavium-octeon/setup.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/mips/cavium-octeon/setup.c b/arch/mips/cavium-octeon/setup.c index 01b1b3f94feb..1bcc144da287 100644 --- a/arch/mips/cavium-octeon/setup.c +++ b/arch/mips/cavium-octeon/setup.c @@ -7,6 +7,7 @@ * Copyright (C) 2008, 2009 Wind River Systems * written by Ralf Baechle */ +#include #include #include #include @@ -712,7 +713,7 @@ void __init prom_init(void) if (cvmx_read_csr(CVMX_L2D_FUS3) & (3ull << 34)) { pr_info("Skipping L2 locking due to reduced L2 cache size\n"); } else { - uint32_t ebase = read_c0_ebase() & 0x3ffff000; + uint32_t __maybe_unused ebase = read_c0_ebase() & 0x3ffff000; #ifdef CONFIG_CAVIUM_OCTEON_LOCK_L2_TLB /* TLB refill */ cvmx_l2c_lock_mem_region(ebase, 0x100); From 368b062509fac95c1e403ae4d2ff25fd4ca151fe Mon Sep 17 00:00:00 2001 From: David Daney Date: Thu, 20 Jun 2013 16:10:50 +0200 Subject: [PATCH 0314/1048] MIPS: Octeon: Fix build error if CONFIG_BUG=n MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CC init/do_mounts.o In file included from /home/ralf/src/linux/linux-mips/arch/mips/include/asm/dma-mapping.h:10:0, from include/linux/dma-mapping.h:76, from include/linux/skbuff.h:33, from include/linux/icmpv6.h:4, from include/linux/ipv6.h:59, from include/net/ipv6.h:16, from include/linux/sunrpc/clnt.h:26, from include/linux/nfs_fs.h:30, from init/do_mounts.c:30: /home/ralf/src/linux/linux-mips/arch/mips/include/asm/mach-cavium-octeon/dma-coherence.h: In function ‘plat_map_dma_mem’: /home/ralf/src/linux/linux-mips/arch/mips/include/asm/mach-cavium-octeon/dma-coherence.h:24:1: warning: no return statement in function returning non-void [-Wreturn-type] /home/ralf/src/linux/linux-mips/arch/mips/include/asm/mach-cavium-octeon/dma-coherence.h: In function ‘plat_map_dma_mem_page’: /home/ralf/src/linux/linux-mips/arch/mips/include/asm/mach-cavium-octeon/dma-coherence.h:30:1: warning: no return statement in function returning non-void [-Wreturn-type] /home/ralf/src/linux/linux-mips/arch/mips/include/asm/mach-cavium-octeon/dma-coherence.h: In function ‘plat_dma_addr_to_phys’: /home/ralf/src/linux/linux-mips/arch/mips/include/asm/mach-cavium-octeon/dma-coherence.h:36:1: warning: no return statement in function returning non-void [-Wreturn-type] /home/ralf/src/linux/linux-mips/arch/mips/include/asm/mach-cavium-octeon/dma-coherence.h: In function ‘plat_dma_supported’: /home/ralf/src/linux/linux-mips/arch/mips/include/asm/mach-cavium-octeon/dma-coherence.h:47:1: warning: no return statement in function returning non-void [-Wreturn-type] /home/ralf/src/linux/linux-mips/arch/mips/include/asm/mach-cavium-octeon/dma-coherence.h: In function ‘plat_dma_mapping_error’: /home/ralf/src/linux/linux-mips/arch/mips/include/asm/mach-cavium-octeon/dma-coherence.h:63:1: warning: no return statement in function returning non-void [-Wreturn-type] LD init/mounts.o CC init/init_task.o In file included from /home/ralf/src/linux/linux-mips/arch/mips/include/asm/dma-mapping.h:10:0, from include/linux/dma-mapping.h:76, from include/linux/skbuff.h:33, from include/linux/netfilter.h:5, from include/net/netns/netfilter.h:5, from include/net/net_namespace.h:20, from include/linux/init_task.h:14, from init/init_task.c:1: /home/ralf/src/linux/linux-mips/arch/mips/include/asm/mach-cavium-octeon/dma-coherence.h: In function ‘plat_map_dma_mem’: /home/ralf/src/linux/linux-mips/arch/mips/include/asm/mach-cavium-octeon/dma-coherence.h:24:1: warning: no return statement in function returning non-void [-Wreturn-type] /home/ralf/src/linux/linux-mips/arch/mips/include/asm/mach-cavium-octeon/dma-coherence.h: In function ‘plat_map_dma_mem_page’: /home/ralf/src/linux/linux-mips/arch/mips/include/asm/mach-cavium-octeon/dma-coherence.h:30:1: warning: no return statement in function returning non-void [-Wreturn-type] /home/ralf/src/linux/linux-mips/arch/mips/include/asm/mach-cavium-octeon/dma-coherence.h: In function ‘plat_dma_addr_to_phys’: /home/ralf/src/linux/linux-mips/arch/mips/include/asm/mach-cavium-octeon/dma-coherence.h:36:1: warning: no return statement in function returning non-void [-Wreturn-type] /home/ralf/src/linux/linux-mips/arch/mips/include/asm/mach-cavium-octeon/dma-coherence.h: In function ‘plat_dma_supported’: /home/ralf/src/linux/linux-mips/arch/mips/include/asm/mach-cavium-octeon/dma-coherence.h:47:1: warning: no return statement in function returning non-void [-Wreturn-type] /home/ralf/src/linux/linux-mips/arch/mips/include/asm/mach-cavium-octeon/dma-coherence.h: In function ‘plat_dma_mapping_error’: /home/ralf/src/linux/linux-mips/arch/mips/include/asm/mach-cavium-octeon/dma-coherence.h:63:1: warning: no return statement in function returning non-void [-Wreturn-type] LD init/built-in.o CC arch/mips/cavium-octeon/setup.o In file included from /home/ralf/src/linux/linux-mips/arch/mips/include/asm/dma-mapping.h:10:0, from include/linux/dma-mapping.h:76, from include/asm-generic/pci-dma-compat.h:7, from /home/ralf/src/linux/linux-mips/arch/mips/include/asm/pci.h:129, from include/linux/pci.h:1451, from /home/ralf/src/linux/linux-mips/arch/mips/include/asm/octeon/pci-octeon.h:12, from arch/mips/cavium-octeon/setup.c:41: /home/ralf/src/linux/linux-mips/arch/mips/include/asm/mach-cavium-octeon/dma-coherence.h: In function ‘plat_map_dma_mem’: /home/ralf/src/linux/linux-mips/arch/mips/include/asm/mach-cavium-octeon/dma-coherence.h:24:1: error: no return statement in function returning non-void [-Werror=return-type] /home/ralf/src/linux/linux-mips/arch/mips/include/asm/mach-cavium-octeon/dma-coherence.h: In function ‘plat_map_dma_mem_page’: /home/ralf/src/linux/linux-mips/arch/mips/include/asm/mach-cavium-octeon/dma-coherence.h:30:1: error: no return statement in function returning non-void [-Werror=return-type] /home/ralf/src/linux/linux-mips/arch/mips/include/asm/mach-cavium-octeon/dma-coherence.h: In function ‘plat_dma_addr_to_phys’: /home/ralf/src/linux/linux-mips/arch/mips/include/asm/mach-cavium-octeon/dma-coherence.h:36:1: error: no return statement in function returning non-void [-Werror=return-type] /home/ralf/src/linux/linux-mips/arch/mips/include/asm/mach-cavium-octeon/dma-coherence.h: In function ‘plat_dma_supported’: /home/ralf/src/linux/linux-mips/arch/mips/include/asm/mach-cavium-octeon/dma-coherence.h:47:1: error: no return statement in function returning non-void [-Werror=return-type] /home/ralf/src/linux/linux-mips/arch/mips/include/asm/mach-cavium-octeon/dma-coherence.h: In function ‘plat_dma_mapping_error’: /home/ralf/src/linux/linux-mips/arch/mips/include/asm/mach-cavium-octeon/dma-coherence.h:63:1: error: no return statement in function returning non-void [-Werror=return-type] cc1: all warnings being treated as errors make[2]: *** [arch/mips/cavium-octeon/setup.o] Error 1 make[1]: *** [arch/mips/cavium-octeon] Error 2 make: *** [arch/mips] Error 2 [ralf@linux-mips.org: while at it, also include directly.] Signed-off-by: David Daney Patchwork: https://patchwork.linux-mips.org/patch/5519/ Signed-off-by: Ralf Baechle --- arch/mips/include/asm/mach-cavium-octeon/dma-coherence.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/arch/mips/include/asm/mach-cavium-octeon/dma-coherence.h b/arch/mips/include/asm/mach-cavium-octeon/dma-coherence.h index be8fb4240cec..47fb247f9663 100644 --- a/arch/mips/include/asm/mach-cavium-octeon/dma-coherence.h +++ b/arch/mips/include/asm/mach-cavium-octeon/dma-coherence.h @@ -13,6 +13,8 @@ #ifndef __ASM_MACH_CAVIUM_OCTEON_DMA_COHERENCE_H #define __ASM_MACH_CAVIUM_OCTEON_DMA_COHERENCE_H +#include + struct device; extern void octeon_pci_dma_init(void); @@ -21,18 +23,21 @@ static inline dma_addr_t plat_map_dma_mem(struct device *dev, void *addr, size_t size) { BUG(); + return 0; } static inline dma_addr_t plat_map_dma_mem_page(struct device *dev, struct page *page) { BUG(); + return 0; } static inline unsigned long plat_dma_addr_to_phys(struct device *dev, dma_addr_t dma_addr) { BUG(); + return 0; } static inline void plat_unmap_dma_mem(struct device *dev, dma_addr_t dma_addr, @@ -44,6 +49,7 @@ static inline void plat_unmap_dma_mem(struct device *dev, dma_addr_t dma_addr, static inline int plat_dma_supported(struct device *dev, u64 mask) { BUG(); + return 0; } static inline void plat_extra_sync_for_device(struct device *dev) @@ -60,6 +66,7 @@ static inline int plat_dma_mapping_error(struct device *dev, dma_addr_t dma_addr) { BUG(); + return 0; } dma_addr_t phys_to_dma(struct device *dev, phys_addr_t paddr); From 069e2b351de67e7a837b15b3d26c65c19b790cc3 Mon Sep 17 00:00:00 2001 From: Christoph Lameter Date: Fri, 14 Jun 2013 19:55:13 +0000 Subject: [PATCH 0315/1048] slob: Rework #ifdeffery in slab.h Make the SLOB specific stuff harmonize more with the way the other allocators do it. Create the typical kmalloc constants for that purpose. SLOB does not support it but the constants help us avoid #ifdefs. Signed-off-by: Christoph Lameter Signed-off-by: Pekka Enberg --- include/linux/slab.h | 39 ++++++++++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 11 deletions(-) diff --git a/include/linux/slab.h b/include/linux/slab.h index 0c621752caa6..9690c14eb7fb 100644 --- a/include/linux/slab.h +++ b/include/linux/slab.h @@ -169,11 +169,7 @@ struct kmem_cache { struct list_head list; /* List of all slab caches on the system */ }; -#define KMALLOC_MAX_SIZE (1UL << 30) - -#include - -#else /* CONFIG_SLOB */ +#endif /* CONFIG_SLOB */ /* * Kmalloc array related definitions @@ -195,7 +191,9 @@ struct kmem_cache { #ifndef KMALLOC_SHIFT_LOW #define KMALLOC_SHIFT_LOW 5 #endif -#else +#endif + +#ifdef CONFIG_SLUB /* * SLUB allocates up to order 2 pages directly and otherwise * passes the request to the page allocator. @@ -207,6 +205,19 @@ struct kmem_cache { #endif #endif +#ifdef CONFIG_SLOB +/* + * SLOB passes all page size and larger requests to the page allocator. + * No kmalloc array is necessary since objects of different sizes can + * be allocated from the same page. + */ +#define KMALLOC_SHIFT_MAX 30 +#define KMALLOC_SHIFT_HIGH PAGE_SHIFT +#ifndef KMALLOC_SHIFT_LOW +#define KMALLOC_SHIFT_LOW 3 +#endif +#endif + /* Maximum allocatable size */ #define KMALLOC_MAX_SIZE (1UL << KMALLOC_SHIFT_MAX) /* Maximum size for which we actually use a slab cache */ @@ -221,6 +232,7 @@ struct kmem_cache { #define KMALLOC_MIN_SIZE (1 << KMALLOC_SHIFT_LOW) #endif +#ifndef CONFIG_SLOB extern struct kmem_cache *kmalloc_caches[KMALLOC_SHIFT_HIGH + 1]; #ifdef CONFIG_ZONE_DMA extern struct kmem_cache *kmalloc_dma_caches[KMALLOC_SHIFT_HIGH + 1]; @@ -275,13 +287,18 @@ static __always_inline int kmalloc_index(size_t size) /* Will never be reached. Needed because the compiler may complain */ return -1; } +#endif /* !CONFIG_SLOB */ #ifdef CONFIG_SLAB #include -#elif defined(CONFIG_SLUB) +#endif + +#ifdef CONFIG_SLUB #include -#else -#error "Unknown slab allocator" +#endif + +#ifdef CONFIG_SLOB +#include #endif /* @@ -291,6 +308,7 @@ static __always_inline int kmalloc_index(size_t size) */ static __always_inline int kmalloc_size(int n) { +#ifndef CONFIG_SLOB if (n > 2) return 1 << n; @@ -299,10 +317,9 @@ static __always_inline int kmalloc_size(int n) if (n == 2 && KMALLOC_MIN_SIZE <= 64) return 192; - +#endif return 0; } -#endif /* !CONFIG_SLOB */ /* * Setting ARCH_SLAB_MINALIGN in arch headers allows a different alignment. From 7bb151b23b40c32c85f5116827a87fc23f0be4c4 Mon Sep 17 00:00:00 2001 From: Sakari Ailus Date: Tue, 11 Jun 2013 06:50:49 -0300 Subject: [PATCH 0316/1048] [media] davinci_vpfe: Clean up media entity after unregistering subdev media_entity_cleanup() frees the links array which will be accessed by media_entity_remove_links() called by v4l2_device_unregister_subdev(). Signed-off-by: Sakari Ailus Reviewed-by: Sylwester Nawrocki Acked-by: Lad, Prabhakar Acked-by: Laurent Pinchart Signed-off-by: Sylwester Nawrocki Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/davinci_vpfe/dm365_ipipe.c | 4 ++-- drivers/staging/media/davinci_vpfe/dm365_ipipeif.c | 4 ++-- drivers/staging/media/davinci_vpfe/dm365_isif.c | 4 ++-- drivers/staging/media/davinci_vpfe/dm365_resizer.c | 14 +++++++------- drivers/staging/media/davinci_vpfe/vpfe_video.c | 2 +- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/staging/media/davinci_vpfe/dm365_ipipe.c b/drivers/staging/media/davinci_vpfe/dm365_ipipe.c index 05673ed45ce4..766a071b0a22 100644 --- a/drivers/staging/media/davinci_vpfe/dm365_ipipe.c +++ b/drivers/staging/media/davinci_vpfe/dm365_ipipe.c @@ -1751,10 +1751,10 @@ static const struct media_entity_operations ipipe_media_ops = { */ void vpfe_ipipe_unregister_entities(struct vpfe_ipipe_device *vpfe_ipipe) { - /* cleanup entity */ - media_entity_cleanup(&vpfe_ipipe->subdev.entity); /* unregister subdev */ v4l2_device_unregister_subdev(&vpfe_ipipe->subdev); + /* cleanup entity */ + media_entity_cleanup(&vpfe_ipipe->subdev.entity); } /* diff --git a/drivers/staging/media/davinci_vpfe/dm365_ipipeif.c b/drivers/staging/media/davinci_vpfe/dm365_ipipeif.c index b2f4ef84f3db..59540cd4bb98 100644 --- a/drivers/staging/media/davinci_vpfe/dm365_ipipeif.c +++ b/drivers/staging/media/davinci_vpfe/dm365_ipipeif.c @@ -947,10 +947,10 @@ void vpfe_ipipeif_unregister_entities(struct vpfe_ipipeif_device *ipipeif) /* unregister video device */ vpfe_video_unregister(&ipipeif->video_in); - /* cleanup entity */ - media_entity_cleanup(&ipipeif->subdev.entity); /* unregister subdev */ v4l2_device_unregister_subdev(&ipipeif->subdev); + /* cleanup entity */ + media_entity_cleanup(&ipipeif->subdev.entity); } int diff --git a/drivers/staging/media/davinci_vpfe/dm365_isif.c b/drivers/staging/media/davinci_vpfe/dm365_isif.c index 5829360f74c9..ff48fce94fcb 100644 --- a/drivers/staging/media/davinci_vpfe/dm365_isif.c +++ b/drivers/staging/media/davinci_vpfe/dm365_isif.c @@ -1750,10 +1750,10 @@ static const struct media_entity_operations isif_media_ops = { void vpfe_isif_unregister_entities(struct vpfe_isif_device *isif) { vpfe_video_unregister(&isif->video_out); - /* cleanup entity */ - media_entity_cleanup(&isif->subdev.entity); /* unregister subdev */ v4l2_device_unregister_subdev(&isif->subdev); + /* cleanup entity */ + media_entity_cleanup(&isif->subdev.entity); } static void isif_restore_defaults(struct vpfe_isif_device *isif) diff --git a/drivers/staging/media/davinci_vpfe/dm365_resizer.c b/drivers/staging/media/davinci_vpfe/dm365_resizer.c index 126f84c4cb64..8e13bd494c98 100644 --- a/drivers/staging/media/davinci_vpfe/dm365_resizer.c +++ b/drivers/staging/media/davinci_vpfe/dm365_resizer.c @@ -1777,14 +1777,14 @@ void vpfe_resizer_unregister_entities(struct vpfe_resizer_device *vpfe_rsz) vpfe_video_unregister(&vpfe_rsz->resizer_a.video_out); vpfe_video_unregister(&vpfe_rsz->resizer_b.video_out); - /* cleanup entity */ - media_entity_cleanup(&vpfe_rsz->crop_resizer.subdev.entity); - media_entity_cleanup(&vpfe_rsz->resizer_a.subdev.entity); - media_entity_cleanup(&vpfe_rsz->resizer_b.subdev.entity); /* unregister subdev */ v4l2_device_unregister_subdev(&vpfe_rsz->crop_resizer.subdev); v4l2_device_unregister_subdev(&vpfe_rsz->resizer_a.subdev); v4l2_device_unregister_subdev(&vpfe_rsz->resizer_b.subdev); + /* cleanup entity */ + media_entity_cleanup(&vpfe_rsz->crop_resizer.subdev.entity); + media_entity_cleanup(&vpfe_rsz->resizer_a.subdev.entity); + media_entity_cleanup(&vpfe_rsz->resizer_b.subdev.entity); } /* @@ -1865,12 +1865,12 @@ out_create_link: vpfe_video_unregister(&resizer->resizer_b.video_out); out_video_out2_register: vpfe_video_unregister(&resizer->resizer_a.video_out); - media_entity_cleanup(&resizer->crop_resizer.subdev.entity); - media_entity_cleanup(&resizer->resizer_a.subdev.entity); - media_entity_cleanup(&resizer->resizer_b.subdev.entity); v4l2_device_unregister_subdev(&resizer->crop_resizer.subdev); v4l2_device_unregister_subdev(&resizer->resizer_a.subdev); v4l2_device_unregister_subdev(&resizer->resizer_b.subdev); + media_entity_cleanup(&resizer->crop_resizer.subdev.entity); + media_entity_cleanup(&resizer->resizer_a.subdev.entity); + media_entity_cleanup(&resizer->resizer_b.subdev.entity); return ret; } diff --git a/drivers/staging/media/davinci_vpfe/vpfe_video.c b/drivers/staging/media/davinci_vpfe/vpfe_video.c index cb5410b390ef..24d98a6866bb 100644 --- a/drivers/staging/media/davinci_vpfe/vpfe_video.c +++ b/drivers/staging/media/davinci_vpfe/vpfe_video.c @@ -1614,7 +1614,7 @@ int vpfe_video_register(struct vpfe_video_device *video, void vpfe_video_unregister(struct vpfe_video_device *video) { if (video_is_registered(&video->video_dev)) { - media_entity_cleanup(&video->video_dev.entity); video_unregister_device(&video->video_dev); + media_entity_cleanup(&video->video_dev.entity); } } From 2a3e7256851b642f35c3bb550be77b815486b469 Mon Sep 17 00:00:00 2001 From: Sakari Ailus Date: Tue, 11 Jun 2013 06:50:48 -0300 Subject: [PATCH 0317/1048] [media] smiapp: Clean up media entity after unregistering subdev media_entity_cleanup() frees the links array which will be accessed by media_entity_remove_links() called by v4l2_device_unregister_subdev(). Signed-off-by: Sakari Ailus Reviewed-by: Sylwester Nawrocki Acked-by: Laurent Pinchart Signed-off-by: Sylwester Nawrocki Signed-off-by: Mauro Carvalho Chehab --- drivers/media/i2c/smiapp/smiapp-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/i2c/smiapp/smiapp-core.c b/drivers/media/i2c/smiapp/smiapp-core.c index c38545419045..7ac7580f85c9 100644 --- a/drivers/media/i2c/smiapp/smiapp-core.c +++ b/drivers/media/i2c/smiapp/smiapp-core.c @@ -2848,8 +2848,8 @@ static int smiapp_remove(struct i2c_client *client) device_remove_file(&client->dev, &dev_attr_nvm); for (i = 0; i < sensor->ssds_used; i++) { - media_entity_cleanup(&sensor->ssds[i].sd.entity); v4l2_device_unregister_subdev(&sensor->ssds[i].sd); + media_entity_cleanup(&sensor->ssds[i].sd.entity); } smiapp_free_controls(sensor); From 7349cec14d63251d093a213f7d40ed3c732b3734 Mon Sep 17 00:00:00 2001 From: Sylwester Nawrocki Date: Thu, 9 May 2013 08:29:32 -0300 Subject: [PATCH 0318/1048] [media] media: Add a function removing all links of a media entity This function allows to remove all media entity's links to other entities, leaving no references to a media entity's links array at its remote entities. Currently, when a driver of some entity is removed it will free its media entities links[] array, leaving dangling pointers at other entities that are part of same media graph. This is troublesome when drivers of a media device entities are in separate kernel modules, removing only some modules will leave others in an incorrect state. This function is intended to be used when an entity is being unregistered from a media device. With an assumption that normally the media links should be created between media entities registered to a media device, with the graph mutex held. Signed-off-by: Sylwester Nawrocki Reviewed-by: Andrzej Hajda Signed-off-by: Kyungmin Park Acked-by: Laurent Pinchart Acked-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab --- drivers/media/media-entity.c | 50 ++++++++++++++++++++++++++++++++++++ include/media/media-entity.h | 3 +++ 2 files changed, 53 insertions(+) diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c index df72f7d99d80..cb30ffbd5ba8 100644 --- a/drivers/media/media-entity.c +++ b/drivers/media/media-entity.c @@ -429,6 +429,56 @@ media_entity_create_link(struct media_entity *source, u16 source_pad, } EXPORT_SYMBOL_GPL(media_entity_create_link); +void __media_entity_remove_links(struct media_entity *entity) +{ + unsigned int i; + + for (i = 0; i < entity->num_links; i++) { + struct media_link *link = &entity->links[i]; + struct media_entity *remote; + unsigned int r = 0; + + if (link->source->entity == entity) + remote = link->sink->entity; + else + remote = link->source->entity; + + while (r < remote->num_links) { + struct media_link *rlink = &remote->links[r]; + + if (rlink != link->reverse) { + r++; + continue; + } + + if (link->source->entity == entity) + remote->num_backlinks--; + + if (--remote->num_links == 0) + break; + + /* Insert last entry in place of the dropped link. */ + *rlink = remote->links[remote->num_links]; + } + } + + entity->num_links = 0; + entity->num_backlinks = 0; +} +EXPORT_SYMBOL_GPL(__media_entity_remove_links); + +void media_entity_remove_links(struct media_entity *entity) +{ + /* Do nothing if the entity is not registered. */ + if (entity->parent == NULL) + return; + + mutex_lock(&entity->parent->graph_mutex); + __media_entity_remove_links(entity); + mutex_unlock(&entity->parent->graph_mutex); +} +EXPORT_SYMBOL_GPL(media_entity_remove_links); + static int __media_entity_setup_link_notify(struct media_link *link, u32 flags) { int ret; diff --git a/include/media/media-entity.h b/include/media/media-entity.h index 4eefedcaa66d..06bacf937d61 100644 --- a/include/media/media-entity.h +++ b/include/media/media-entity.h @@ -128,6 +128,9 @@ void media_entity_cleanup(struct media_entity *entity); int media_entity_create_link(struct media_entity *source, u16 source_pad, struct media_entity *sink, u16 sink_pad, u32 flags); +void __media_entity_remove_links(struct media_entity *entity); +void media_entity_remove_links(struct media_entity *entity); + int __media_entity_setup_link(struct media_link *link, u32 flags); int media_entity_setup_link(struct media_link *link, u32 flags); struct media_link *media_entity_find_link(struct media_pad *source, From c2efd3e6e04942aa8206ca26c855eabf67cfdbc0 Mon Sep 17 00:00:00 2001 From: Sylwester Nawrocki Date: Thu, 9 May 2013 08:29:33 -0300 Subject: [PATCH 0319/1048] [media] V4L: Remove all links of the media entity when unregistering subdev Remove all links of the subdev's media entity after internal_ops 'unregistered' call and right before unregistering the entity from a media device. It is assumed here that an unregistered (orphan) media entity cannot have links to other entities registered to a media device. It is also assumed the media links should be created/removed with the media graph's mutex held. The above implies that the caller of v4l2_device_unregister_subdev() must not hold the graph's mutex. Reviewed-by: Andrzej Hajda Signed-off-by: Kyungmin Park Acked-by: Sakari Ailus Acked-by: Laurent Pinchart Signed-off-by: Sylwester Nawrocki Signed-off-by: Mauro Carvalho Chehab --- drivers/media/v4l2-core/v4l2-device.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/media/v4l2-core/v4l2-device.c b/drivers/media/v4l2-core/v4l2-device.c index 8ed5da2170bf..2dbfebc0ca85 100644 --- a/drivers/media/v4l2-core/v4l2-device.c +++ b/drivers/media/v4l2-core/v4l2-device.c @@ -269,8 +269,10 @@ void v4l2_device_unregister_subdev(struct v4l2_subdev *sd) sd->v4l2_dev = NULL; #if defined(CONFIG_MEDIA_CONTROLLER) - if (v4l2_dev->mdev) + if (v4l2_dev->mdev) { + media_entity_remove_links(&sd->entity); media_device_unregister_entity(&sd->entity); + } #endif video_unregister_device(sd->devnode); module_put(sd->owner); From e2e324d70defce7ffc4668085dc3c8ae580074e5 Mon Sep 17 00:00:00 2001 From: Gianluca Gennari Date: Sun, 2 Jun 2013 14:30:09 -0300 Subject: [PATCH 0320/1048] [media] r820t: remove redundant initializations in r820t_attach() fe->tuner_priv and fe->ops.tuner_ops are initialized twice in r820t_attach(). Remove the redundant initializations and also move fe->ops.tuner_ops initialization outside of the mutex lock (as in the xc4000 tuner code for example). Signed-off-by: Gianluca Gennari Signed-off-by: Michael Krufky Signed-off-by: Mauro Carvalho Chehab --- drivers/media/tuners/r820t.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/media/tuners/r820t.c b/drivers/media/tuners/r820t.c index 64f97389d5b0..63062a9b4003 100644 --- a/drivers/media/tuners/r820t.c +++ b/drivers/media/tuners/r820t.c @@ -2310,8 +2310,6 @@ struct dvb_frontend *r820t_attach(struct dvb_frontend *fe, break; } - memcpy(&fe->ops.tuner_ops, &r820t_tuner_ops, sizeof(r820t_tuner_ops)); - if (fe->ops.i2c_gate_ctrl) fe->ops.i2c_gate_ctrl(fe, 1); @@ -2326,15 +2324,14 @@ struct dvb_frontend *r820t_attach(struct dvb_frontend *fe, tuner_info("Rafael Micro r820t successfully identified\n"); - fe->tuner_priv = priv; - memcpy(&fe->ops.tuner_ops, &r820t_tuner_ops, - sizeof(struct dvb_tuner_ops)); - if (fe->ops.i2c_gate_ctrl) fe->ops.i2c_gate_ctrl(fe, 0); mutex_unlock(&r820t_list_mutex); + memcpy(&fe->ops.tuner_ops, &r820t_tuner_ops, + sizeof(struct dvb_tuner_ops)); + return fe; err: if (fe->ops.i2c_gate_ctrl) From 757d7ace565c06e1302ba7c9244d839455e13881 Mon Sep 17 00:00:00 2001 From: Gianluca Gennari Date: Sun, 2 Jun 2013 14:31:19 -0300 Subject: [PATCH 0321/1048] [media] r820t: avoid potential memcpy buffer overflow in shadow_store() The memcpy in shadow_store() could exceed buffer limits when r > 0. Signed-off-by: Gianluca Gennari Signed-off-by: Michael Krufky Signed-off-by: Mauro Carvalho Chehab --- drivers/media/tuners/r820t.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/media/tuners/r820t.c b/drivers/media/tuners/r820t.c index 63062a9b4003..0a5f96be08f1 100644 --- a/drivers/media/tuners/r820t.c +++ b/drivers/media/tuners/r820t.c @@ -364,8 +364,8 @@ static void shadow_store(struct r820t_priv *priv, u8 reg, const u8 *val, } if (len <= 0) return; - if (len > NUM_REGS) - len = NUM_REGS; + if (len > NUM_REGS - r) + len = NUM_REGS - r; tuner_dbg("%s: prev reg=%02x len=%d: %*ph\n", __func__, r + REG_SHADOW_START, len, len, val); From bbf94616261e080507e43b07eea0d633462b00dc Mon Sep 17 00:00:00 2001 From: Gianluca Gennari Date: Mon, 17 Jun 2013 20:32:45 -0300 Subject: [PATCH 0322/1048] [media] r820t: fix imr calibration The r820t_imr() calibration function of the Rafael Micro R820T tuner generates this error at every tune attempt: r820t 0-001a: No valid PLL values for 2252021 kHz! The function was inspired by the original Realtek driver for rtl2832 devices with the r820t tuner; anyway, in the original code the XTAL frequency of the tuner was expressed in KHz, while in the kernel driver it is expressed in Hz; so the calibration failed because of an out-of-range initial value. The final result of the computation is then passed to the r820t_set_mux() and r820t_set_pll() functions, but the conversion from KHz to Hz is already correctly implemented. Signed-off-by: Gianluca Gennari Signed-off-by: Michael Krufky Signed-off-by: Mauro Carvalho Chehab --- drivers/media/tuners/r820t.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/media/tuners/r820t.c b/drivers/media/tuners/r820t.c index 0a5f96be08f1..1c23666468cf 100644 --- a/drivers/media/tuners/r820t.c +++ b/drivers/media/tuners/r820t.c @@ -1857,9 +1857,9 @@ static int r820t_imr(struct r820t_priv *priv, unsigned imr_mem, bool im_flag) int reg18, reg19, reg1f; if (priv->cfg->xtal > 24000000) - ring_ref = priv->cfg->xtal / 2; + ring_ref = priv->cfg->xtal / 2000; else - ring_ref = priv->cfg->xtal; + ring_ref = priv->cfg->xtal / 1000; n_ring = 15; for (n = 0; n < 16; n++) { From c778edb5bdb7a96712848493273762427a51e200 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Mon, 17 Jun 2013 20:56:40 -0300 Subject: [PATCH 0323/1048] [media] mxl111sf: don't redefine pr_err/info/debug Remove the silly redefines of pr_err/info/debug. This improves readability and it also gets rid of a bunch of warnings when compiling this driver for older kernels using the compatibility media_build system. Signed-off-by: Hans Verkuil Signed-off-by: Michael Krufky Signed-off-by: Mauro Carvalho Chehab --- drivers/media/usb/dvb-usb-v2/mxl111sf-tuner.c | 8 +- drivers/media/usb/dvb-usb-v2/mxl111sf.c | 90 +++++++++---------- 2 files changed, 45 insertions(+), 53 deletions(-) diff --git a/drivers/media/usb/dvb-usb-v2/mxl111sf-tuner.c b/drivers/media/usb/dvb-usb-v2/mxl111sf-tuner.c index ef4c65fcbb73..879c529640f7 100644 --- a/drivers/media/usb/dvb-usb-v2/mxl111sf-tuner.c +++ b/drivers/media/usb/dvb-usb-v2/mxl111sf-tuner.c @@ -31,8 +31,6 @@ MODULE_PARM_DESC(debug, "set debugging level (1=info (or-able))."); if (mxl111sf_tuner_debug) \ mxl_printk(KERN_DEBUG, fmt, ##arg) -#define err pr_err - /* ------------------------------------------------------------------------ */ struct mxl111sf_tuner_state { @@ -113,7 +111,7 @@ static struct mxl111sf_reg_ctrl_info *mxl111sf_calc_phy_tune_regs(u32 freq, filt_bw = 63; break; default: - err("%s: invalid bandwidth setting!", __func__); + pr_err("%s: invalid bandwidth setting!", __func__); return NULL; } @@ -304,12 +302,12 @@ static int mxl111sf_tuner_set_params(struct dvb_frontend *fe) bw = 8; break; default: - err("%s: bandwidth not set!", __func__); + pr_err("%s: bandwidth not set!", __func__); return -EINVAL; } break; default: - err("%s: modulation type not supported!", __func__); + pr_err("%s: modulation type not supported!", __func__); return -EINVAL; } ret = mxl1x1sf_tune_rf(fe, c->frequency, bw); diff --git a/drivers/media/usb/dvb-usb-v2/mxl111sf.c b/drivers/media/usb/dvb-usb-v2/mxl111sf.c index efdcb15358f1..e97964ef7f56 100644 --- a/drivers/media/usb/dvb-usb-v2/mxl111sf.c +++ b/drivers/media/usb/dvb-usb-v2/mxl111sf.c @@ -52,12 +52,6 @@ MODULE_PARM_DESC(rfswitch, "force rf switch position (0=auto, 1=ext, 2=int)."); DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); -#define deb_info pr_debug -#define deb_reg pr_debug -#define deb_adv pr_debug -#define err pr_err -#define info pr_info - int mxl111sf_ctrl_msg(struct dvb_usb_device *d, u8 cmd, u8 *wbuf, int wlen, u8 *rbuf, int rlen) { @@ -65,7 +59,7 @@ int mxl111sf_ctrl_msg(struct dvb_usb_device *d, int ret; u8 sndbuf[1+wlen]; - deb_adv("%s(wlen = %d, rlen = %d)\n", __func__, wlen, rlen); + pr_debug("%s(wlen = %d, rlen = %d)\n", __func__, wlen, rlen); memset(sndbuf, 0, 1+wlen); @@ -98,12 +92,12 @@ int mxl111sf_read_reg(struct mxl111sf_state *state, u8 addr, u8 *data) if (buf[0] == addr) *data = buf[1]; else { - err("invalid response reading reg: 0x%02x != 0x%02x, 0x%02x", + pr_err("invalid response reading reg: 0x%02x != 0x%02x, 0x%02x", addr, buf[0], buf[1]); ret = -EINVAL; } - deb_reg("R: (0x%02x, 0x%02x)\n", addr, *data); + pr_debug("R: (0x%02x, 0x%02x)\n", addr, *data); fail: return ret; } @@ -113,11 +107,11 @@ int mxl111sf_write_reg(struct mxl111sf_state *state, u8 addr, u8 data) u8 buf[] = { addr, data }; int ret; - deb_reg("W: (0x%02x, 0x%02x)\n", addr, data); + pr_debug("W: (0x%02x, 0x%02x)\n", addr, data); ret = mxl111sf_ctrl_msg(state->d, MXL_CMD_REG_WRITE, buf, 2, NULL, 0); if (mxl_fail(ret)) - err("error writing reg: 0x%02x, val: 0x%02x", addr, data); + pr_err("error writing reg: 0x%02x, val: 0x%02x", addr, data); return ret; } @@ -134,7 +128,7 @@ int mxl111sf_write_reg_mask(struct mxl111sf_state *state, #if 1 /* dont know why this usually errors out on the first try */ if (mxl_fail(ret)) - err("error writing addr: 0x%02x, mask: 0x%02x, " + pr_err("error writing addr: 0x%02x, mask: 0x%02x, " "data: 0x%02x, retrying...", addr, mask, data); ret = mxl111sf_read_reg(state, addr, &val); @@ -167,7 +161,7 @@ int mxl111sf_ctrl_program_regs(struct mxl111sf_state *state, ctrl_reg_info[i].mask, ctrl_reg_info[i].data); if (mxl_fail(ret)) { - err("failed on reg #%d (0x%02x)", i, + pr_err("failed on reg #%d (0x%02x)", i, ctrl_reg_info[i].addr); break; } @@ -225,7 +219,7 @@ static int mxl1x1sf_get_chip_info(struct mxl111sf_state *state) mxl_rev = "UNKNOWN REVISION"; break; } - info("%s detected, %s (0x%x)", mxl_chip, mxl_rev, ver); + pr_info("%s detected, %s (0x%x)", mxl_chip, mxl_rev, ver); fail: return ret; } @@ -239,7 +233,7 @@ fail: " on first probe attempt"); \ ___ret = mxl1x1sf_get_chip_info(state); \ if (mxl_fail(___ret)) \ - err("failed to get chip info during probe"); \ + pr_err("failed to get chip info during probe"); \ else \ mxl_debug("probe needed a retry " \ "in order to succeed."); \ @@ -270,14 +264,14 @@ static int mxl111sf_adap_fe_init(struct dvb_frontend *fe) goto fail; } - deb_info("%s()\n", __func__); + pr_debug("%s()\n", __func__); mutex_lock(&state->fe_lock); state->alt_mode = adap_state->alt_mode; if (usb_set_interface(d->udev, 0, state->alt_mode) < 0) - err("set interface failed"); + pr_err("set interface failed"); err = mxl1x1sf_soft_reset(state); mxl_fail(err); @@ -326,7 +320,7 @@ static int mxl111sf_adap_fe_sleep(struct dvb_frontend *fe) goto fail; } - deb_info("%s()\n", __func__); + pr_debug("%s()\n", __func__); err = (adap_state->fe_sleep) ? adap_state->fe_sleep(fe) : 0; @@ -344,7 +338,7 @@ static int mxl111sf_ep6_streaming_ctrl(struct dvb_frontend *fe, int onoff) struct mxl111sf_adap_state *adap_state = &state->adap_state[fe->id]; int ret = 0; - deb_info("%s(%d)\n", __func__, onoff); + pr_debug("%s(%d)\n", __func__, onoff); if (onoff) { ret = mxl111sf_enable_usb_output(state); @@ -368,7 +362,7 @@ static int mxl111sf_ep5_streaming_ctrl(struct dvb_frontend *fe, int onoff) struct mxl111sf_state *state = fe_to_priv(fe); int ret = 0; - deb_info("%s(%d)\n", __func__, onoff); + pr_debug("%s(%d)\n", __func__, onoff); if (onoff) { ret = mxl111sf_enable_usb_output(state); @@ -394,7 +388,7 @@ static int mxl111sf_ep4_streaming_ctrl(struct dvb_frontend *fe, int onoff) struct mxl111sf_state *state = fe_to_priv(fe); int ret = 0; - deb_info("%s(%d)\n", __func__, onoff); + pr_debug("%s(%d)\n", __func__, onoff); if (onoff) { ret = mxl111sf_enable_usb_output(state); @@ -424,7 +418,7 @@ static int mxl111sf_lgdt3305_frontend_attach(struct dvb_usb_adapter *adap, u8 fe struct mxl111sf_adap_state *adap_state = &state->adap_state[fe_id]; int ret; - deb_adv("%s()\n", __func__); + pr_debug("%s()\n", __func__); /* save a pointer to the dvb_usb_device in device state */ state->d = d; @@ -432,7 +426,7 @@ static int mxl111sf_lgdt3305_frontend_attach(struct dvb_usb_adapter *adap, u8 fe state->alt_mode = adap_state->alt_mode; if (usb_set_interface(d->udev, 0, state->alt_mode) < 0) - err("set interface failed"); + pr_err("set interface failed"); state->gpio_mode = MXL111SF_GPIO_MOD_ATSC; adap_state->gpio_mode = state->gpio_mode; @@ -495,7 +489,7 @@ static int mxl111sf_lg2160_frontend_attach(struct dvb_usb_adapter *adap, u8 fe_i struct mxl111sf_adap_state *adap_state = &state->adap_state[fe_id]; int ret; - deb_adv("%s()\n", __func__); + pr_debug("%s()\n", __func__); /* save a pointer to the dvb_usb_device in device state */ state->d = d; @@ -503,7 +497,7 @@ static int mxl111sf_lg2160_frontend_attach(struct dvb_usb_adapter *adap, u8 fe_i state->alt_mode = adap_state->alt_mode; if (usb_set_interface(d->udev, 0, state->alt_mode) < 0) - err("set interface failed"); + pr_err("set interface failed"); state->gpio_mode = MXL111SF_GPIO_MOD_MH; adap_state->gpio_mode = state->gpio_mode; @@ -580,7 +574,7 @@ static int mxl111sf_lg2161_frontend_attach(struct dvb_usb_adapter *adap, u8 fe_i struct mxl111sf_adap_state *adap_state = &state->adap_state[fe_id]; int ret; - deb_adv("%s()\n", __func__); + pr_debug("%s()\n", __func__); /* save a pointer to the dvb_usb_device in device state */ state->d = d; @@ -588,7 +582,7 @@ static int mxl111sf_lg2161_frontend_attach(struct dvb_usb_adapter *adap, u8 fe_i state->alt_mode = adap_state->alt_mode; if (usb_set_interface(d->udev, 0, state->alt_mode) < 0) - err("set interface failed"); + pr_err("set interface failed"); state->gpio_mode = MXL111SF_GPIO_MOD_MH; adap_state->gpio_mode = state->gpio_mode; @@ -667,7 +661,7 @@ static int mxl111sf_lg2161_ep6_frontend_attach(struct dvb_usb_adapter *adap, u8 struct mxl111sf_adap_state *adap_state = &state->adap_state[fe_id]; int ret; - deb_adv("%s()\n", __func__); + pr_debug("%s()\n", __func__); /* save a pointer to the dvb_usb_device in device state */ state->d = d; @@ -675,7 +669,7 @@ static int mxl111sf_lg2161_ep6_frontend_attach(struct dvb_usb_adapter *adap, u8 state->alt_mode = adap_state->alt_mode; if (usb_set_interface(d->udev, 0, state->alt_mode) < 0) - err("set interface failed"); + pr_err("set interface failed"); state->gpio_mode = MXL111SF_GPIO_MOD_MH; adap_state->gpio_mode = state->gpio_mode; @@ -742,7 +736,7 @@ static int mxl111sf_attach_demod(struct dvb_usb_adapter *adap, u8 fe_id) struct mxl111sf_adap_state *adap_state = &state->adap_state[fe_id]; int ret; - deb_adv("%s()\n", __func__); + pr_debug("%s()\n", __func__); /* save a pointer to the dvb_usb_device in device state */ state->d = d; @@ -750,7 +744,7 @@ static int mxl111sf_attach_demod(struct dvb_usb_adapter *adap, u8 fe_id) state->alt_mode = adap_state->alt_mode; if (usb_set_interface(d->udev, 0, state->alt_mode) < 0) - err("set interface failed"); + pr_err("set interface failed"); state->gpio_mode = MXL111SF_GPIO_MOD_DVBT; adap_state->gpio_mode = state->gpio_mode; @@ -802,7 +796,7 @@ static inline int mxl111sf_set_ant_path(struct mxl111sf_state *state, } #define DbgAntHunt(x, pwr0, pwr1, pwr2, pwr3) \ - err("%s(%d) FINAL input set to %s rxPwr:%d|%d|%d|%d\n", \ + pr_err("%s(%d) FINAL input set to %s rxPwr:%d|%d|%d|%d\n", \ __func__, __LINE__, \ (ANT_PATH_EXTERNAL == x) ? "EXTERNAL" : "INTERNAL", \ pwr0, pwr1, pwr2, pwr3) @@ -868,7 +862,7 @@ static int mxl111sf_attach_tuner(struct dvb_usb_adapter *adap) struct mxl111sf_state *state = adap_to_priv(adap); int i; - deb_adv("%s()\n", __func__); + pr_debug("%s()\n", __func__); for (i = 0; i < state->num_frontends; i++) { if (dvb_attach(mxl111sf_tuner_attach, adap->fe[i], state, @@ -902,7 +896,7 @@ static int mxl111sf_init(struct dvb_usb_device *d) ret = get_chip_info(state); if (mxl_fail(ret)) - err("failed to get chip info during probe"); + pr_err("failed to get chip info during probe"); mutex_init(&state->fe_lock); @@ -950,7 +944,7 @@ static int mxl111sf_frontend_attach_mh(struct dvb_usb_adapter *adap) static int mxl111sf_frontend_attach_atsc_mh(struct dvb_usb_adapter *adap) { int ret; - deb_info("%s\n", __func__); + pr_debug("%s\n", __func__); ret = mxl111sf_lgdt3305_frontend_attach(adap, 0); if (ret < 0) @@ -970,7 +964,7 @@ static int mxl111sf_frontend_attach_atsc_mh(struct dvb_usb_adapter *adap) static int mxl111sf_frontend_attach_mercury(struct dvb_usb_adapter *adap) { int ret; - deb_info("%s\n", __func__); + pr_debug("%s\n", __func__); ret = mxl111sf_lgdt3305_frontend_attach(adap, 0); if (ret < 0) @@ -990,7 +984,7 @@ static int mxl111sf_frontend_attach_mercury(struct dvb_usb_adapter *adap) static int mxl111sf_frontend_attach_mercury_mh(struct dvb_usb_adapter *adap) { int ret; - deb_info("%s\n", __func__); + pr_debug("%s\n", __func__); ret = mxl111sf_attach_demod(adap, 0); if (ret < 0) @@ -1006,7 +1000,7 @@ static int mxl111sf_frontend_attach_mercury_mh(struct dvb_usb_adapter *adap) static void mxl111sf_stream_config_bulk(struct usb_data_stream_properties *stream, u8 endpoint) { - deb_info("%s: endpoint=%d size=8192\n", __func__, endpoint); + pr_debug("%s: endpoint=%d size=8192\n", __func__, endpoint); stream->type = USB_BULK; stream->count = 5; stream->endpoint = endpoint; @@ -1016,7 +1010,7 @@ static void mxl111sf_stream_config_bulk(struct usb_data_stream_properties *strea static void mxl111sf_stream_config_isoc(struct usb_data_stream_properties *stream, u8 endpoint, int framesperurb, int framesize) { - deb_info("%s: endpoint=%d size=%d\n", __func__, endpoint, + pr_debug("%s: endpoint=%d size=%d\n", __func__, endpoint, framesperurb * framesize); stream->type = USB_ISOC; stream->count = 5; @@ -1035,7 +1029,7 @@ static void mxl111sf_stream_config_isoc(struct usb_data_stream_properties *strea static int mxl111sf_get_stream_config_dvbt(struct dvb_frontend *fe, u8 *ts_type, struct usb_data_stream_properties *stream) { - deb_info("%s: fe=%d\n", __func__, fe->id); + pr_debug("%s: fe=%d\n", __func__, fe->id); *ts_type = DVB_USB_FE_TS_TYPE_188; if (dvb_usb_mxl111sf_isoc) @@ -1076,7 +1070,7 @@ static struct dvb_usb_device_properties mxl111sf_props_dvbt = { static int mxl111sf_get_stream_config_atsc(struct dvb_frontend *fe, u8 *ts_type, struct usb_data_stream_properties *stream) { - deb_info("%s: fe=%d\n", __func__, fe->id); + pr_debug("%s: fe=%d\n", __func__, fe->id); *ts_type = DVB_USB_FE_TS_TYPE_188; if (dvb_usb_mxl111sf_isoc) @@ -1117,7 +1111,7 @@ static struct dvb_usb_device_properties mxl111sf_props_atsc = { static int mxl111sf_get_stream_config_mh(struct dvb_frontend *fe, u8 *ts_type, struct usb_data_stream_properties *stream) { - deb_info("%s: fe=%d\n", __func__, fe->id); + pr_debug("%s: fe=%d\n", __func__, fe->id); *ts_type = DVB_USB_FE_TS_TYPE_RAW; if (dvb_usb_mxl111sf_isoc) @@ -1158,7 +1152,7 @@ static struct dvb_usb_device_properties mxl111sf_props_mh = { static int mxl111sf_get_stream_config_atsc_mh(struct dvb_frontend *fe, u8 *ts_type, struct usb_data_stream_properties *stream) { - deb_info("%s: fe=%d\n", __func__, fe->id); + pr_debug("%s: fe=%d\n", __func__, fe->id); if (fe->id == 0) { *ts_type = DVB_USB_FE_TS_TYPE_188; @@ -1184,7 +1178,7 @@ static int mxl111sf_get_stream_config_atsc_mh(struct dvb_frontend *fe, static int mxl111sf_streaming_ctrl_atsc_mh(struct dvb_frontend *fe, int onoff) { - deb_info("%s: fe=%d onoff=%d\n", __func__, fe->id, onoff); + pr_debug("%s: fe=%d onoff=%d\n", __func__, fe->id, onoff); if (fe->id == 0) return mxl111sf_ep6_streaming_ctrl(fe, onoff); @@ -1228,7 +1222,7 @@ static struct dvb_usb_device_properties mxl111sf_props_atsc_mh = { static int mxl111sf_get_stream_config_mercury(struct dvb_frontend *fe, u8 *ts_type, struct usb_data_stream_properties *stream) { - deb_info("%s: fe=%d\n", __func__, fe->id); + pr_debug("%s: fe=%d\n", __func__, fe->id); if (fe->id == 0) { *ts_type = DVB_USB_FE_TS_TYPE_188; @@ -1260,7 +1254,7 @@ static int mxl111sf_get_stream_config_mercury(struct dvb_frontend *fe, static int mxl111sf_streaming_ctrl_mercury(struct dvb_frontend *fe, int onoff) { - deb_info("%s: fe=%d onoff=%d\n", __func__, fe->id, onoff); + pr_debug("%s: fe=%d onoff=%d\n", __func__, fe->id, onoff); if (fe->id == 0) return mxl111sf_ep6_streaming_ctrl(fe, onoff); @@ -1306,7 +1300,7 @@ static struct dvb_usb_device_properties mxl111sf_props_mercury = { static int mxl111sf_get_stream_config_mercury_mh(struct dvb_frontend *fe, u8 *ts_type, struct usb_data_stream_properties *stream) { - deb_info("%s: fe=%d\n", __func__, fe->id); + pr_debug("%s: fe=%d\n", __func__, fe->id); if (fe->id == 0) { *ts_type = DVB_USB_FE_TS_TYPE_188; @@ -1332,7 +1326,7 @@ static int mxl111sf_get_stream_config_mercury_mh(struct dvb_frontend *fe, static int mxl111sf_streaming_ctrl_mercury_mh(struct dvb_frontend *fe, int onoff) { - deb_info("%s: fe=%d onoff=%d\n", __func__, fe->id, onoff); + pr_debug("%s: fe=%d onoff=%d\n", __func__, fe->id, onoff); if (fe->id == 0) return mxl111sf_ep4_streaming_ctrl(fe, onoff); From 907d109bc212bc1193fb01b5c320e8c9a850bbf4 Mon Sep 17 00:00:00 2001 From: Frank Schaefer Date: Mon, 3 Jun 2013 14:12:02 -0300 Subject: [PATCH 0324/1048] [media] em28xx: extend GPIO register definitions for the em25xx, em276x/7x/8x, em2874/174/84 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The em25xx/em276x/7x/8x provides 4 GPIO register sets, each of them consisting of separate read and a write registers. The same registers are also used by the em2874/174/84. Signed-off-by: Frank Schäfer Signed-off-by: Mauro Carvalho Chehab --- drivers/media/usb/em28xx/em28xx-cards.c | 88 ++++++++++++------------- drivers/media/usb/em28xx/em28xx-dvb.c | 60 ++++++++--------- drivers/media/usb/em28xx/em28xx-reg.h | 15 ++++- 3 files changed, 88 insertions(+), 75 deletions(-) diff --git a/drivers/media/usb/em28xx/em28xx-cards.c b/drivers/media/usb/em28xx/em28xx-cards.c index e4b0669d49dd..c0b853541f09 100644 --- a/drivers/media/usb/em28xx/em28xx-cards.c +++ b/drivers/media/usb/em28xx/em28xx-cards.c @@ -285,14 +285,14 @@ static struct em28xx_reg_seq dikom_dk300_digital[] = { /* Reset for the most [digital] boards */ static struct em28xx_reg_seq leadership_digital[] = { - {EM2874_R80_GPIO, 0x70, 0xff, 10}, + {EM2874_R80_GPIO_P0_CTRL, 0x70, 0xff, 10}, { -1, -1, -1, -1}, }; static struct em28xx_reg_seq leadership_reset[] = { - {EM2874_R80_GPIO, 0xf0, 0xff, 10}, - {EM2874_R80_GPIO, 0xb0, 0xff, 10}, - {EM2874_R80_GPIO, 0xf0, 0xff, 10}, + {EM2874_R80_GPIO_P0_CTRL, 0xf0, 0xff, 10}, + {EM2874_R80_GPIO_P0_CTRL, 0xb0, 0xff, 10}, + {EM2874_R80_GPIO_P0_CTRL, 0xf0, 0xff, 10}, { -1, -1, -1, -1}, }; @@ -301,25 +301,25 @@ static struct em28xx_reg_seq leadership_reset[] = { * GPIO_7 - LED */ static struct em28xx_reg_seq pctv_290e[] = { - {EM2874_R80_GPIO, 0x00, 0xff, 80}, - {EM2874_R80_GPIO, 0x40, 0xff, 80}, /* GPIO_6 = 1 */ - {EM2874_R80_GPIO, 0xc0, 0xff, 80}, /* GPIO_7 = 1 */ + {EM2874_R80_GPIO_P0_CTRL, 0x00, 0xff, 80}, + {EM2874_R80_GPIO_P0_CTRL, 0x40, 0xff, 80}, /* GPIO_6 = 1 */ + {EM2874_R80_GPIO_P0_CTRL, 0xc0, 0xff, 80}, /* GPIO_7 = 1 */ {-1, -1, -1, -1}, }; #if 0 static struct em28xx_reg_seq terratec_h5_gpio[] = { {EM28XX_R08_GPIO, 0xff, 0xff, 10}, - {EM2874_R80_GPIO, 0xf6, 0xff, 100}, - {EM2874_R80_GPIO, 0xf2, 0xff, 50}, - {EM2874_R80_GPIO, 0xf6, 0xff, 50}, + {EM2874_R80_GPIO_P0_CTRL, 0xf6, 0xff, 100}, + {EM2874_R80_GPIO_P0_CTRL, 0xf2, 0xff, 50}, + {EM2874_R80_GPIO_P0_CTRL, 0xf6, 0xff, 50}, { -1, -1, -1, -1}, }; static struct em28xx_reg_seq terratec_h5_digital[] = { - {EM2874_R80_GPIO, 0xf6, 0xff, 10}, - {EM2874_R80_GPIO, 0xe6, 0xff, 100}, - {EM2874_R80_GPIO, 0xa6, 0xff, 10}, + {EM2874_R80_GPIO_P0_CTRL, 0xf6, 0xff, 10}, + {EM2874_R80_GPIO_P0_CTRL, 0xe6, 0xff, 100}, + {EM2874_R80_GPIO_P0_CTRL, 0xa6, 0xff, 10}, { -1, -1, -1, -1}, }; #endif @@ -335,39 +335,39 @@ static struct em28xx_reg_seq terratec_h5_digital[] = { * GPIO_7 - LED (green LED) */ static struct em28xx_reg_seq pctv_460e[] = { - {EM2874_R80_GPIO, 0x01, 0xff, 50}, + {EM2874_R80_GPIO_P0_CTRL, 0x01, 0xff, 50}, {0x0d, 0xff, 0xff, 50}, - {EM2874_R80_GPIO, 0x41, 0xff, 50}, /* GPIO_6=1 */ + {EM2874_R80_GPIO_P0_CTRL, 0x41, 0xff, 50}, /* GPIO_6=1 */ {0x0d, 0x42, 0xff, 50}, - {EM2874_R80_GPIO, 0x61, 0xff, 50}, /* GPIO_5=1 */ + {EM2874_R80_GPIO_P0_CTRL, 0x61, 0xff, 50}, /* GPIO_5=1 */ { -1, -1, -1, -1}, }; static struct em28xx_reg_seq c3tech_digital_duo_digital[] = { - {EM2874_R80_GPIO, 0xff, 0xff, 10}, - {EM2874_R80_GPIO, 0xfd, 0xff, 10}, /* xc5000 reset */ - {EM2874_R80_GPIO, 0xf9, 0xff, 35}, - {EM2874_R80_GPIO, 0xfd, 0xff, 10}, - {EM2874_R80_GPIO, 0xff, 0xff, 10}, - {EM2874_R80_GPIO, 0xfe, 0xff, 10}, - {EM2874_R80_GPIO, 0xbe, 0xff, 10}, - {EM2874_R80_GPIO, 0xfe, 0xff, 20}, + {EM2874_R80_GPIO_P0_CTRL, 0xff, 0xff, 10}, + {EM2874_R80_GPIO_P0_CTRL, 0xfd, 0xff, 10}, /* xc5000 reset */ + {EM2874_R80_GPIO_P0_CTRL, 0xf9, 0xff, 35}, + {EM2874_R80_GPIO_P0_CTRL, 0xfd, 0xff, 10}, + {EM2874_R80_GPIO_P0_CTRL, 0xff, 0xff, 10}, + {EM2874_R80_GPIO_P0_CTRL, 0xfe, 0xff, 10}, + {EM2874_R80_GPIO_P0_CTRL, 0xbe, 0xff, 10}, + {EM2874_R80_GPIO_P0_CTRL, 0xfe, 0xff, 20}, { -1, -1, -1, -1}, }; #if 0 static struct em28xx_reg_seq hauppauge_930c_gpio[] = { - {EM2874_R80_GPIO, 0x6f, 0xff, 10}, - {EM2874_R80_GPIO, 0x4f, 0xff, 10}, /* xc5000 reset */ - {EM2874_R80_GPIO, 0x6f, 0xff, 10}, - {EM2874_R80_GPIO, 0x4f, 0xff, 10}, + {EM2874_R80_GPIO_P0_CTRL, 0x6f, 0xff, 10}, + {EM2874_R80_GPIO_P0_CTRL, 0x4f, 0xff, 10}, /* xc5000 reset */ + {EM2874_R80_GPIO_P0_CTRL, 0x6f, 0xff, 10}, + {EM2874_R80_GPIO_P0_CTRL, 0x4f, 0xff, 10}, { -1, -1, -1, -1}, }; static struct em28xx_reg_seq hauppauge_930c_digital[] = { - {EM2874_R80_GPIO, 0xf6, 0xff, 10}, - {EM2874_R80_GPIO, 0xe6, 0xff, 100}, - {EM2874_R80_GPIO, 0xa6, 0xff, 10}, + {EM2874_R80_GPIO_P0_CTRL, 0xf6, 0xff, 10}, + {EM2874_R80_GPIO_P0_CTRL, 0xe6, 0xff, 100}, + {EM2874_R80_GPIO_P0_CTRL, 0xa6, 0xff, 10}, { -1, -1, -1, -1}, }; #endif @@ -378,9 +378,9 @@ static struct em28xx_reg_seq hauppauge_930c_digital[] = { * GPIO_7 - LED, 0=active */ static struct em28xx_reg_seq maxmedia_ub425_tc[] = { - {EM2874_R80_GPIO, 0x83, 0xff, 100}, - {EM2874_R80_GPIO, 0xc3, 0xff, 100}, /* GPIO_6 = 1 */ - {EM2874_R80_GPIO, 0x43, 0xff, 000}, /* GPIO_7 = 0 */ + {EM2874_R80_GPIO_P0_CTRL, 0x83, 0xff, 100}, + {EM2874_R80_GPIO_P0_CTRL, 0xc3, 0xff, 100}, /* GPIO_6 = 1 */ + {EM2874_R80_GPIO_P0_CTRL, 0x43, 0xff, 000}, /* GPIO_7 = 0 */ {-1, -1, -1, -1}, }; @@ -391,9 +391,9 @@ static struct em28xx_reg_seq maxmedia_ub425_tc[] = { * GPIO_7: LED, 1=active */ static struct em28xx_reg_seq pctv_510e[] = { - {EM2874_R80_GPIO, 0x10, 0xff, 100}, - {EM2874_R80_GPIO, 0x14, 0xff, 100}, /* GPIO_2 = 1 */ - {EM2874_R80_GPIO, 0x54, 0xff, 050}, /* GPIO_6 = 1 */ + {EM2874_R80_GPIO_P0_CTRL, 0x10, 0xff, 100}, + {EM2874_R80_GPIO_P0_CTRL, 0x14, 0xff, 100}, /* GPIO_2 = 1 */ + {EM2874_R80_GPIO_P0_CTRL, 0x54, 0xff, 050}, /* GPIO_6 = 1 */ { -1, -1, -1, -1}, }; @@ -404,10 +404,10 @@ static struct em28xx_reg_seq pctv_510e[] = { * GPIO_7: LED, 1=active */ static struct em28xx_reg_seq pctv_520e[] = { - {EM2874_R80_GPIO, 0x10, 0xff, 100}, - {EM2874_R80_GPIO, 0x14, 0xff, 100}, /* GPIO_2 = 1 */ - {EM2874_R80_GPIO, 0x54, 0xff, 050}, /* GPIO_6 = 1 */ - {EM2874_R80_GPIO, 0xd4, 0xff, 000}, /* GPIO_7 = 1 */ + {EM2874_R80_GPIO_P0_CTRL, 0x10, 0xff, 100}, + {EM2874_R80_GPIO_P0_CTRL, 0x14, 0xff, 100}, /* GPIO_2 = 1 */ + {EM2874_R80_GPIO_P0_CTRL, 0x54, 0xff, 050}, /* GPIO_6 = 1 */ + {EM2874_R80_GPIO_P0_CTRL, 0xd4, 0xff, 000}, /* GPIO_7 = 1 */ { -1, -1, -1, -1}, }; @@ -2947,13 +2947,13 @@ static int em28xx_init_dev(struct em28xx *dev, struct usb_device *udev, break; case CHIP_ID_EM2874: chip_name = "em2874"; - dev->reg_gpio_num = EM2874_R80_GPIO; + dev->reg_gpio_num = EM2874_R80_GPIO_P0_CTRL; dev->wait_after_write = 0; dev->eeprom_addrwidth_16bit = 1; break; case CHIP_ID_EM28174: chip_name = "em28174"; - dev->reg_gpio_num = EM2874_R80_GPIO; + dev->reg_gpio_num = EM2874_R80_GPIO_P0_CTRL; dev->wait_after_write = 0; dev->eeprom_addrwidth_16bit = 1; break; @@ -2963,7 +2963,7 @@ static int em28xx_init_dev(struct em28xx *dev, struct usb_device *udev, break; case CHIP_ID_EM2884: chip_name = "em2884"; - dev->reg_gpio_num = EM2874_R80_GPIO; + dev->reg_gpio_num = EM2874_R80_GPIO_P0_CTRL; dev->wait_after_write = 0; dev->eeprom_addrwidth_16bit = 1; break; diff --git a/drivers/media/usb/em28xx/em28xx-dvb.c b/drivers/media/usb/em28xx/em28xx-dvb.c index 42ede686ab69..69aed825f583 100644 --- a/drivers/media/usb/em28xx/em28xx-dvb.c +++ b/drivers/media/usb/em28xx/em28xx-dvb.c @@ -421,23 +421,23 @@ static void hauppauge_hvr930c_init(struct em28xx *dev) int i; struct em28xx_reg_seq hauppauge_hvr930c_init[] = { - {EM2874_R80_GPIO, 0xff, 0xff, 0x65}, - {EM2874_R80_GPIO, 0xfb, 0xff, 0x32}, - {EM2874_R80_GPIO, 0xff, 0xff, 0xb8}, + {EM2874_R80_GPIO_P0_CTRL, 0xff, 0xff, 0x65}, + {EM2874_R80_GPIO_P0_CTRL, 0xfb, 0xff, 0x32}, + {EM2874_R80_GPIO_P0_CTRL, 0xff, 0xff, 0xb8}, { -1, -1, -1, -1}, }; struct em28xx_reg_seq hauppauge_hvr930c_end[] = { - {EM2874_R80_GPIO, 0xef, 0xff, 0x01}, - {EM2874_R80_GPIO, 0xaf, 0xff, 0x65}, - {EM2874_R80_GPIO, 0xef, 0xff, 0x76}, - {EM2874_R80_GPIO, 0xef, 0xff, 0x01}, - {EM2874_R80_GPIO, 0xcf, 0xff, 0x0b}, - {EM2874_R80_GPIO, 0xef, 0xff, 0x40}, + {EM2874_R80_GPIO_P0_CTRL, 0xef, 0xff, 0x01}, + {EM2874_R80_GPIO_P0_CTRL, 0xaf, 0xff, 0x65}, + {EM2874_R80_GPIO_P0_CTRL, 0xef, 0xff, 0x76}, + {EM2874_R80_GPIO_P0_CTRL, 0xef, 0xff, 0x01}, + {EM2874_R80_GPIO_P0_CTRL, 0xcf, 0xff, 0x0b}, + {EM2874_R80_GPIO_P0_CTRL, 0xef, 0xff, 0x40}, - {EM2874_R80_GPIO, 0xcf, 0xff, 0x65}, - {EM2874_R80_GPIO, 0xef, 0xff, 0x65}, - {EM2874_R80_GPIO, 0xcf, 0xff, 0x0b}, - {EM2874_R80_GPIO, 0xef, 0xff, 0x65}, + {EM2874_R80_GPIO_P0_CTRL, 0xcf, 0xff, 0x65}, + {EM2874_R80_GPIO_P0_CTRL, 0xef, 0xff, 0x65}, + {EM2874_R80_GPIO_P0_CTRL, 0xcf, 0xff, 0x0b}, + {EM2874_R80_GPIO_P0_CTRL, 0xef, 0xff, 0x65}, { -1, -1, -1, -1}, }; @@ -488,15 +488,15 @@ static void terratec_h5_init(struct em28xx *dev) int i; struct em28xx_reg_seq terratec_h5_init[] = { {EM28XX_R08_GPIO, 0xff, 0xff, 10}, - {EM2874_R80_GPIO, 0xf6, 0xff, 100}, - {EM2874_R80_GPIO, 0xf2, 0xff, 50}, - {EM2874_R80_GPIO, 0xf6, 0xff, 100}, + {EM2874_R80_GPIO_P0_CTRL, 0xf6, 0xff, 100}, + {EM2874_R80_GPIO_P0_CTRL, 0xf2, 0xff, 50}, + {EM2874_R80_GPIO_P0_CTRL, 0xf6, 0xff, 100}, { -1, -1, -1, -1}, }; struct em28xx_reg_seq terratec_h5_end[] = { - {EM2874_R80_GPIO, 0xe6, 0xff, 100}, - {EM2874_R80_GPIO, 0xa6, 0xff, 50}, - {EM2874_R80_GPIO, 0xe6, 0xff, 100}, + {EM2874_R80_GPIO_P0_CTRL, 0xe6, 0xff, 100}, + {EM2874_R80_GPIO_P0_CTRL, 0xa6, 0xff, 50}, + {EM2874_R80_GPIO_P0_CTRL, 0xe6, 0xff, 100}, { -1, -1, -1, -1}, }; struct { @@ -544,14 +544,14 @@ static void terratec_htc_stick_init(struct em28xx *dev) */ struct em28xx_reg_seq terratec_htc_stick_init[] = { {EM28XX_R08_GPIO, 0xff, 0xff, 10}, - {EM2874_R80_GPIO, 0xf6, 0xff, 100}, - {EM2874_R80_GPIO, 0xe6, 0xff, 50}, - {EM2874_R80_GPIO, 0xf6, 0xff, 100}, + {EM2874_R80_GPIO_P0_CTRL, 0xf6, 0xff, 100}, + {EM2874_R80_GPIO_P0_CTRL, 0xe6, 0xff, 50}, + {EM2874_R80_GPIO_P0_CTRL, 0xf6, 0xff, 100}, { -1, -1, -1, -1}, }; struct em28xx_reg_seq terratec_htc_stick_end[] = { - {EM2874_R80_GPIO, 0xb6, 0xff, 100}, - {EM2874_R80_GPIO, 0xf6, 0xff, 50}, + {EM2874_R80_GPIO_P0_CTRL, 0xb6, 0xff, 100}, + {EM2874_R80_GPIO_P0_CTRL, 0xf6, 0xff, 50}, { -1, -1, -1, -1}, }; @@ -591,15 +591,15 @@ static void terratec_htc_usb_xs_init(struct em28xx *dev) struct em28xx_reg_seq terratec_htc_usb_xs_init[] = { {EM28XX_R08_GPIO, 0xff, 0xff, 10}, - {EM2874_R80_GPIO, 0xb2, 0xff, 100}, - {EM2874_R80_GPIO, 0xb2, 0xff, 50}, - {EM2874_R80_GPIO, 0xb6, 0xff, 100}, + {EM2874_R80_GPIO_P0_CTRL, 0xb2, 0xff, 100}, + {EM2874_R80_GPIO_P0_CTRL, 0xb2, 0xff, 50}, + {EM2874_R80_GPIO_P0_CTRL, 0xb6, 0xff, 100}, { -1, -1, -1, -1}, }; struct em28xx_reg_seq terratec_htc_usb_xs_end[] = { - {EM2874_R80_GPIO, 0xa6, 0xff, 100}, - {EM2874_R80_GPIO, 0xa6, 0xff, 50}, - {EM2874_R80_GPIO, 0xe6, 0xff, 100}, + {EM2874_R80_GPIO_P0_CTRL, 0xa6, 0xff, 100}, + {EM2874_R80_GPIO_P0_CTRL, 0xa6, 0xff, 50}, + {EM2874_R80_GPIO_P0_CTRL, 0xe6, 0xff, 100}, { -1, -1, -1, -1}, }; diff --git a/drivers/media/usb/em28xx/em28xx-reg.h b/drivers/media/usb/em28xx/em28xx-reg.h index 622871db04aa..0233c5bedc55 100644 --- a/drivers/media/usb/em28xx/em28xx-reg.h +++ b/drivers/media/usb/em28xx/em28xx-reg.h @@ -193,7 +193,20 @@ #define EM2874_R50_IR_CONFIG 0x50 #define EM2874_R51_IR 0x51 #define EM2874_R5F_TS_ENABLE 0x5f -#define EM2874_R80_GPIO 0x80 + +/* em2874/174/84, em25xx, em276x/7x/8x GPIO registers */ +/* + * NOTE: not all ports are bonded out; + * Some ports are multiplexed with special function I/O + */ +#define EM2874_R80_GPIO_P0_CTRL 0x80 +#define EM2874_R81_GPIO_P1_CTRL 0x81 +#define EM2874_R82_GPIO_P2_CTRL 0x82 +#define EM2874_R83_GPIO_P3_CTRL 0x83 +#define EM2874_R84_GPIO_P0_STATE 0x84 +#define EM2874_R85_GPIO_P1_STATE 0x85 +#define EM2874_R86_GPIO_P2_STATE 0x86 +#define EM2874_R87_GPIO_P3_STATE 0x87 /* em2874 IR config register (0x50) */ #define EM2874_IR_NEC 0x00 From c074fc4c2990d48acab78d304054a6ff212f3d53 Mon Sep 17 00:00:00 2001 From: Frank Schaefer Date: Mon, 3 Jun 2013 14:12:03 -0300 Subject: [PATCH 0325/1048] [media] em28xx: improve em2820-em2873/83 GPIO port register definitions and descriptions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - add definition for GPIO register 0x09 (reading/input) - extend the information the chip variants that support GPIO registers 0x08/0x09 - rename EM28XX_R08_GPIO to EM2820_R08_GPIO_CTRL Signed-off-by: Frank Schäfer Signed-off-by: Mauro Carvalho Chehab --- drivers/media/usb/em28xx/em28xx-cards.c | 128 ++++++++++++------------ drivers/media/usb/em28xx/em28xx-dvb.c | 6 +- drivers/media/usb/em28xx/em28xx-reg.h | 5 +- 3 files changed, 70 insertions(+), 69 deletions(-) diff --git a/drivers/media/usb/em28xx/em28xx-cards.c b/drivers/media/usb/em28xx/em28xx-cards.c index c0b853541f09..6ee4bed730dd 100644 --- a/drivers/media/usb/em28xx/em28xx-cards.c +++ b/drivers/media/usb/em28xx/em28xx-cards.c @@ -82,26 +82,26 @@ static void em28xx_pre_card_setup(struct em28xx *dev); /* Reset for the most [analog] boards */ static struct em28xx_reg_seq default_analog[] = { - {EM28XX_R08_GPIO, 0x6d, ~EM_GPIO_4, 10}, + {EM2820_R08_GPIO_CTRL, 0x6d, ~EM_GPIO_4, 10}, { -1, -1, -1, -1}, }; /* Reset for the most [digital] boards */ static struct em28xx_reg_seq default_digital[] = { - {EM28XX_R08_GPIO, 0x6e, ~EM_GPIO_4, 10}, + {EM2820_R08_GPIO_CTRL, 0x6e, ~EM_GPIO_4, 10}, { -1, -1, -1, -1}, }; /* Board Hauppauge WinTV HVR 900 analog */ static struct em28xx_reg_seq hauppauge_wintv_hvr_900_analog[] = { - {EM28XX_R08_GPIO, 0x2d, ~EM_GPIO_4, 10}, + {EM2820_R08_GPIO_CTRL, 0x2d, ~EM_GPIO_4, 10}, {0x05, 0xff, 0x10, 10}, { -1, -1, -1, -1}, }; /* Board Hauppauge WinTV HVR 900 digital */ static struct em28xx_reg_seq hauppauge_wintv_hvr_900_digital[] = { - {EM28XX_R08_GPIO, 0x2e, ~EM_GPIO_4, 10}, + {EM2820_R08_GPIO_CTRL, 0x2e, ~EM_GPIO_4, 10}, {EM2880_R04_GPO, 0x04, 0x0f, 10}, {EM2880_R04_GPO, 0x0c, 0x0f, 10}, { -1, -1, -1, -1}, @@ -109,14 +109,14 @@ static struct em28xx_reg_seq hauppauge_wintv_hvr_900_digital[] = { /* Board Hauppauge WinTV HVR 900 (R2) digital */ static struct em28xx_reg_seq hauppauge_wintv_hvr_900R2_digital[] = { - {EM28XX_R08_GPIO, 0x2e, ~EM_GPIO_4, 10}, + {EM2820_R08_GPIO_CTRL, 0x2e, ~EM_GPIO_4, 10}, {EM2880_R04_GPO, 0x0c, 0x0f, 10}, { -1, -1, -1, -1}, }; /* Boards - EM2880 MSI DIGIVOX AD and EM2880_BOARD_MSI_DIGIVOX_AD_II */ static struct em28xx_reg_seq em2880_msi_digivox_ad_analog[] = { - {EM28XX_R08_GPIO, 0x69, ~EM_GPIO_4, 10}, + {EM2820_R08_GPIO_CTRL, 0x69, ~EM_GPIO_4, 10}, { -1, -1, -1, -1}, }; @@ -127,11 +127,11 @@ static struct em28xx_reg_seq em2880_msi_digivox_ad_analog[] = { /* Board - EM2882 Kworld 315U digital */ static struct em28xx_reg_seq em2882_kworld_315u_digital[] = { - {EM28XX_R08_GPIO, 0xff, 0xff, 10}, - {EM28XX_R08_GPIO, 0xfe, 0xff, 10}, + {EM2820_R08_GPIO_CTRL, 0xff, 0xff, 10}, + {EM2820_R08_GPIO_CTRL, 0xfe, 0xff, 10}, {EM2880_R04_GPO, 0x04, 0xff, 10}, {EM2880_R04_GPO, 0x0c, 0xff, 10}, - {EM28XX_R08_GPIO, 0x7e, 0xff, 10}, + {EM2820_R08_GPIO_CTRL, 0x7e, 0xff, 10}, { -1, -1, -1, -1}, }; @@ -144,13 +144,13 @@ static struct em28xx_reg_seq em2882_kworld_315u_tuner_gpio[] = { }; static struct em28xx_reg_seq kworld_330u_analog[] = { - {EM28XX_R08_GPIO, 0x6d, ~EM_GPIO_4, 10}, + {EM2820_R08_GPIO_CTRL, 0x6d, ~EM_GPIO_4, 10}, {EM2880_R04_GPO, 0x00, 0xff, 10}, { -1, -1, -1, -1}, }; static struct em28xx_reg_seq kworld_330u_digital[] = { - {EM28XX_R08_GPIO, 0x6e, ~EM_GPIO_4, 10}, + {EM2820_R08_GPIO_CTRL, 0x6e, ~EM_GPIO_4, 10}, {EM2880_R04_GPO, 0x08, 0xff, 10}, { -1, -1, -1, -1}, }; @@ -162,12 +162,12 @@ static struct em28xx_reg_seq kworld_330u_digital[] = { GOP3 - s5h1409 reset */ static struct em28xx_reg_seq evga_indtube_analog[] = { - {EM28XX_R08_GPIO, 0x79, 0xff, 60}, + {EM2820_R08_GPIO_CTRL, 0x79, 0xff, 60}, { -1, -1, -1, -1}, }; static struct em28xx_reg_seq evga_indtube_digital[] = { - {EM28XX_R08_GPIO, 0x7a, 0xff, 1}, + {EM2820_R08_GPIO_CTRL, 0x7a, 0xff, 1}, {EM2880_R04_GPO, 0x04, 0xff, 10}, {EM2880_R04_GPO, 0x0c, 0xff, 1}, { -1, -1, -1, -1}, @@ -185,31 +185,31 @@ static struct em28xx_reg_seq evga_indtube_digital[] = { * EM_GPIO_7 - currently unknown */ static struct em28xx_reg_seq kworld_a340_digital[] = { - {EM28XX_R08_GPIO, 0x6d, ~EM_GPIO_4, 10}, + {EM2820_R08_GPIO_CTRL, 0x6d, ~EM_GPIO_4, 10}, { -1, -1, -1, -1}, }; /* Pinnacle Hybrid Pro eb1a:2881 */ static struct em28xx_reg_seq pinnacle_hybrid_pro_analog[] = { - {EM28XX_R08_GPIO, 0xfd, ~EM_GPIO_4, 10}, + {EM2820_R08_GPIO_CTRL, 0xfd, ~EM_GPIO_4, 10}, { -1, -1, -1, -1}, }; static struct em28xx_reg_seq pinnacle_hybrid_pro_digital[] = { - {EM28XX_R08_GPIO, 0x6e, ~EM_GPIO_4, 10}, + {EM2820_R08_GPIO_CTRL, 0x6e, ~EM_GPIO_4, 10}, {EM2880_R04_GPO, 0x04, 0xff, 100},/* zl10353 reset */ {EM2880_R04_GPO, 0x0c, 0xff, 1}, { -1, -1, -1, -1}, }; static struct em28xx_reg_seq terratec_cinergy_USB_XS_FR_analog[] = { - {EM28XX_R08_GPIO, 0x6d, ~EM_GPIO_4, 10}, + {EM2820_R08_GPIO_CTRL, 0x6d, ~EM_GPIO_4, 10}, {EM2880_R04_GPO, 0x00, 0xff, 10}, { -1, -1, -1, -1}, }; static struct em28xx_reg_seq terratec_cinergy_USB_XS_FR_digital[] = { - {EM28XX_R08_GPIO, 0x6e, ~EM_GPIO_4, 10}, + {EM2820_R08_GPIO_CTRL, 0x6e, ~EM_GPIO_4, 10}, {EM2880_R04_GPO, 0x08, 0xff, 10}, { -1, -1, -1, -1}, }; @@ -218,66 +218,66 @@ static struct em28xx_reg_seq terratec_cinergy_USB_XS_FR_digital[] = { GPIO4 - CU1216L NIM Other GPIOs seems to be don't care. */ static struct em28xx_reg_seq reddo_dvb_c_usb_box[] = { - {EM28XX_R08_GPIO, 0xfe, 0xff, 10}, - {EM28XX_R08_GPIO, 0xde, 0xff, 10}, - {EM28XX_R08_GPIO, 0xfe, 0xff, 10}, - {EM28XX_R08_GPIO, 0xff, 0xff, 10}, - {EM28XX_R08_GPIO, 0x7f, 0xff, 10}, - {EM28XX_R08_GPIO, 0x6f, 0xff, 10}, - {EM28XX_R08_GPIO, 0xff, 0xff, 10}, + {EM2820_R08_GPIO_CTRL, 0xfe, 0xff, 10}, + {EM2820_R08_GPIO_CTRL, 0xde, 0xff, 10}, + {EM2820_R08_GPIO_CTRL, 0xfe, 0xff, 10}, + {EM2820_R08_GPIO_CTRL, 0xff, 0xff, 10}, + {EM2820_R08_GPIO_CTRL, 0x7f, 0xff, 10}, + {EM2820_R08_GPIO_CTRL, 0x6f, 0xff, 10}, + {EM2820_R08_GPIO_CTRL, 0xff, 0xff, 10}, {-1, -1, -1, -1}, }; /* Callback for the most boards */ static struct em28xx_reg_seq default_tuner_gpio[] = { - {EM28XX_R08_GPIO, EM_GPIO_4, EM_GPIO_4, 10}, - {EM28XX_R08_GPIO, 0, EM_GPIO_4, 10}, - {EM28XX_R08_GPIO, EM_GPIO_4, EM_GPIO_4, 10}, + {EM2820_R08_GPIO_CTRL, EM_GPIO_4, EM_GPIO_4, 10}, + {EM2820_R08_GPIO_CTRL, 0, EM_GPIO_4, 10}, + {EM2820_R08_GPIO_CTRL, EM_GPIO_4, EM_GPIO_4, 10}, { -1, -1, -1, -1}, }; /* Mute/unmute */ static struct em28xx_reg_seq compro_unmute_tv_gpio[] = { - {EM28XX_R08_GPIO, 5, 7, 10}, + {EM2820_R08_GPIO_CTRL, 5, 7, 10}, { -1, -1, -1, -1}, }; static struct em28xx_reg_seq compro_unmute_svid_gpio[] = { - {EM28XX_R08_GPIO, 4, 7, 10}, + {EM2820_R08_GPIO_CTRL, 4, 7, 10}, { -1, -1, -1, -1}, }; static struct em28xx_reg_seq compro_mute_gpio[] = { - {EM28XX_R08_GPIO, 6, 7, 10}, + {EM2820_R08_GPIO_CTRL, 6, 7, 10}, { -1, -1, -1, -1}, }; /* Terratec AV350 */ static struct em28xx_reg_seq terratec_av350_mute_gpio[] = { - {EM28XX_R08_GPIO, 0xff, 0x7f, 10}, + {EM2820_R08_GPIO_CTRL, 0xff, 0x7f, 10}, { -1, -1, -1, -1}, }; static struct em28xx_reg_seq terratec_av350_unmute_gpio[] = { - {EM28XX_R08_GPIO, 0xff, 0xff, 10}, + {EM2820_R08_GPIO_CTRL, 0xff, 0xff, 10}, { -1, -1, -1, -1}, }; static struct em28xx_reg_seq silvercrest_reg_seq[] = { - {EM28XX_R08_GPIO, 0xff, 0xff, 10}, - {EM28XX_R08_GPIO, 0x01, 0xf7, 10}, + {EM2820_R08_GPIO_CTRL, 0xff, 0xff, 10}, + {EM2820_R08_GPIO_CTRL, 0x01, 0xf7, 10}, { -1, -1, -1, -1}, }; static struct em28xx_reg_seq vc211a_enable[] = { - {EM28XX_R08_GPIO, 0xff, 0x07, 10}, - {EM28XX_R08_GPIO, 0xff, 0x0f, 10}, - {EM28XX_R08_GPIO, 0xff, 0x0b, 10}, + {EM2820_R08_GPIO_CTRL, 0xff, 0x07, 10}, + {EM2820_R08_GPIO_CTRL, 0xff, 0x0f, 10}, + {EM2820_R08_GPIO_CTRL, 0xff, 0x0b, 10}, { -1, -1, -1, -1}, }; static struct em28xx_reg_seq dikom_dk300_digital[] = { - {EM28XX_R08_GPIO, 0x6e, ~EM_GPIO_4, 10}, + {EM2820_R08_GPIO_CTRL, 0x6e, ~EM_GPIO_4, 10}, {EM2880_R04_GPO, 0x08, 0xff, 10}, { -1, -1, -1, -1}, }; @@ -309,7 +309,7 @@ static struct em28xx_reg_seq pctv_290e[] = { #if 0 static struct em28xx_reg_seq terratec_h5_gpio[] = { - {EM28XX_R08_GPIO, 0xff, 0xff, 10}, + {EM2820_R08_GPIO_CTRL, 0xff, 0xff, 10}, {EM2874_R80_GPIO_P0_CTRL, 0xf6, 0xff, 100}, {EM2874_R80_GPIO_P0_CTRL, 0xf2, 0xff, 50}, {EM2874_R80_GPIO_P0_CTRL, 0xf6, 0xff, 50}, @@ -2299,9 +2299,9 @@ static void em28xx_pre_card_setup(struct em28xx *dev) break; case EM2861_BOARD_KWORLD_PVRTV_300U: case EM2880_BOARD_KWORLD_DVB_305U: - em28xx_write_reg(dev, EM28XX_R08_GPIO, 0x6d); + em28xx_write_reg(dev, EM2820_R08_GPIO_CTRL, 0x6d); msleep(10); - em28xx_write_reg(dev, EM28XX_R08_GPIO, 0x7d); + em28xx_write_reg(dev, EM2820_R08_GPIO_CTRL, 0x7d); msleep(10); break; case EM2870_BOARD_COMPRO_VIDEOMATE: @@ -2311,45 +2311,45 @@ static void em28xx_pre_card_setup(struct em28xx *dev) msleep(10); em28xx_write_reg(dev, EM2880_R04_GPO, 0x01); msleep(10); - em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xfd); + em28xx_write_reg(dev, EM2820_R08_GPIO_CTRL, 0xfd); mdelay(70); - em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xfc); + em28xx_write_reg(dev, EM2820_R08_GPIO_CTRL, 0xfc); mdelay(70); - em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xdc); + em28xx_write_reg(dev, EM2820_R08_GPIO_CTRL, 0xdc); mdelay(70); - em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xfc); + em28xx_write_reg(dev, EM2820_R08_GPIO_CTRL, 0xfc); mdelay(70); break; case EM2870_BOARD_TERRATEC_XS_MT2060: /* this device needs some gpio writes to get the DVB-T demod work */ - em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xfe); + em28xx_write_reg(dev, EM2820_R08_GPIO_CTRL, 0xfe); mdelay(70); - em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xde); + em28xx_write_reg(dev, EM2820_R08_GPIO_CTRL, 0xde); mdelay(70); - em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xfe); + em28xx_write_reg(dev, EM2820_R08_GPIO_CTRL, 0xfe); mdelay(70); break; case EM2870_BOARD_PINNACLE_PCTV_DVB: /* this device needs some gpio writes to get the DVB-T demod work */ - em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xfe); + em28xx_write_reg(dev, EM2820_R08_GPIO_CTRL, 0xfe); mdelay(70); - em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xde); + em28xx_write_reg(dev, EM2820_R08_GPIO_CTRL, 0xde); mdelay(70); - em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xfe); + em28xx_write_reg(dev, EM2820_R08_GPIO_CTRL, 0xfe); mdelay(70); break; case EM2820_BOARD_GADMEI_UTV310: case EM2820_BOARD_MSI_VOX_USB_2: /* enables audio for that devices */ - em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xfd); + em28xx_write_reg(dev, EM2820_R08_GPIO_CTRL, 0xfd); break; case EM2882_BOARD_KWORLD_ATSC_315U: - em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xff); + em28xx_write_reg(dev, EM2820_R08_GPIO_CTRL, 0xff); msleep(10); - em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xfe); + em28xx_write_reg(dev, EM2820_R08_GPIO_CTRL, 0xfe); msleep(10); em28xx_write_reg(dev, EM2880_R04_GPO, 0x00); msleep(10); @@ -2375,13 +2375,13 @@ static void em28xx_pre_card_setup(struct em28xx *dev) break; case EM2820_BOARD_IODATA_GVMVP_SZ: - em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xff); + em28xx_write_reg(dev, EM2820_R08_GPIO_CTRL, 0xff); msleep(70); - em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xf7); + em28xx_write_reg(dev, EM2820_R08_GPIO_CTRL, 0xf7); msleep(10); - em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xfe); + em28xx_write_reg(dev, EM2820_R08_GPIO_CTRL, 0xfe); msleep(70); - em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xfd); + em28xx_write_reg(dev, EM2820_R08_GPIO_CTRL, 0xfd); msleep(70); break; } @@ -2677,12 +2677,12 @@ static void em28xx_card_setup(struct em28xx *dev) case EM2882_BOARD_KWORLD_ATSC_315U: em28xx_write_reg(dev, 0x0d, 0x42); msleep(10); - em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xfd); + em28xx_write_reg(dev, EM2820_R08_GPIO_CTRL, 0xfd); msleep(10); break; case EM2820_BOARD_KWORLD_PVRTV2800RF: /* GPIO enables sound on KWORLD PVR TV 2800RF */ - em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xf9); + em28xx_write_reg(dev, EM2820_R08_GPIO_CTRL, 0xf9); break; case EM2820_BOARD_UNKNOWN: case EM2800_BOARD_UNKNOWN: @@ -2898,7 +2898,7 @@ static int em28xx_init_dev(struct em28xx *dev, struct usb_device *udev, /* Set the default GPO/GPIO for legacy devices */ dev->reg_gpo_num = EM2880_R04_GPO; - dev->reg_gpio_num = EM28XX_R08_GPIO; + dev->reg_gpio_num = EM2820_R08_GPIO_CTRL; dev->wait_after_write = 5; @@ -3086,7 +3086,7 @@ static int em28xx_init_dev(struct em28xx *dev, struct usb_device *udev, if (dev->board.has_msp34xx) { /* Send a reset to other chips via gpio */ - retval = em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xf7); + retval = em28xx_write_reg(dev, EM2820_R08_GPIO_CTRL, 0xf7); if (retval < 0) { em28xx_errdev("%s: em28xx_write_reg - " "msp34xx(1) failed! error [%d]\n", @@ -3095,7 +3095,7 @@ static int em28xx_init_dev(struct em28xx *dev, struct usb_device *udev, } msleep(3); - retval = em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xff); + retval = em28xx_write_reg(dev, EM2820_R08_GPIO_CTRL, 0xff); if (retval < 0) { em28xx_errdev("%s: em28xx_write_reg - " "msp34xx(2) failed! error [%d]\n", diff --git a/drivers/media/usb/em28xx/em28xx-dvb.c b/drivers/media/usb/em28xx/em28xx-dvb.c index 69aed825f583..bb1e8dca80cd 100644 --- a/drivers/media/usb/em28xx/em28xx-dvb.c +++ b/drivers/media/usb/em28xx/em28xx-dvb.c @@ -487,7 +487,7 @@ static void terratec_h5_init(struct em28xx *dev) { int i; struct em28xx_reg_seq terratec_h5_init[] = { - {EM28XX_R08_GPIO, 0xff, 0xff, 10}, + {EM2820_R08_GPIO_CTRL, 0xff, 0xff, 10}, {EM2874_R80_GPIO_P0_CTRL, 0xf6, 0xff, 100}, {EM2874_R80_GPIO_P0_CTRL, 0xf2, 0xff, 50}, {EM2874_R80_GPIO_P0_CTRL, 0xf6, 0xff, 100}, @@ -543,7 +543,7 @@ static void terratec_htc_stick_init(struct em28xx *dev) * 0xb6: unknown (does not affect DVB-T). */ struct em28xx_reg_seq terratec_htc_stick_init[] = { - {EM28XX_R08_GPIO, 0xff, 0xff, 10}, + {EM2820_R08_GPIO_CTRL, 0xff, 0xff, 10}, {EM2874_R80_GPIO_P0_CTRL, 0xf6, 0xff, 100}, {EM2874_R80_GPIO_P0_CTRL, 0xe6, 0xff, 50}, {EM2874_R80_GPIO_P0_CTRL, 0xf6, 0xff, 100}, @@ -590,7 +590,7 @@ static void terratec_htc_usb_xs_init(struct em28xx *dev) int i; struct em28xx_reg_seq terratec_htc_usb_xs_init[] = { - {EM28XX_R08_GPIO, 0xff, 0xff, 10}, + {EM2820_R08_GPIO_CTRL, 0xff, 0xff, 10}, {EM2874_R80_GPIO_P0_CTRL, 0xb2, 0xff, 100}, {EM2874_R80_GPIO_P0_CTRL, 0xb2, 0xff, 50}, {EM2874_R80_GPIO_P0_CTRL, 0xb6, 0xff, 100}, diff --git a/drivers/media/usb/em28xx/em28xx-reg.h b/drivers/media/usb/em28xx/em28xx-reg.h index 0233c5bedc55..af39ddbe01e0 100644 --- a/drivers/media/usb/em28xx/em28xx-reg.h +++ b/drivers/media/usb/em28xx/em28xx-reg.h @@ -49,8 +49,9 @@ /* GPIO/GPO registers */ -#define EM2880_R04_GPO 0x04 /* em2880-em2883 only */ -#define EM28XX_R08_GPIO 0x08 /* em2820 or upper */ +#define EM2880_R04_GPO 0x04 /* em2880-em2883 only */ +#define EM2820_R08_GPIO_CTRL 0x08 /* em2820-em2873/83 only */ +#define EM2820_R09_GPIO_STATE 0x09 /* em2820-em2873/83 only */ #define EM28XX_R06_I2C_CLK 0x06 From bc677fff1cde38ce8e14d6a2cb703a9fb134ab98 Mon Sep 17 00:00:00 2001 From: Frank Schaefer Date: Mon, 3 Jun 2013 14:12:04 -0300 Subject: [PATCH 0326/1048] [media] em28xx: move snapshot button bit definition for reg 0x0C from em28xx-input.c to em28xx.h MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Frank Schäfer Signed-off-by: Mauro Carvalho Chehab --- drivers/media/usb/em28xx/em28xx-input.c | 1 - drivers/media/usb/em28xx/em28xx-reg.h | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/media/usb/em28xx/em28xx-input.c b/drivers/media/usb/em28xx/em28xx-input.c index 466b19d0d767..ea181e4b68c5 100644 --- a/drivers/media/usb/em28xx/em28xx-input.c +++ b/drivers/media/usb/em28xx/em28xx-input.c @@ -32,7 +32,6 @@ #define EM28XX_SNAPSHOT_KEY KEY_CAMERA #define EM28XX_SBUTTON_QUERY_INTERVAL 500 -#define EM28XX_R0C_USBSUSP_SNAPSHOT 0x20 static unsigned int ir_debug; module_param(ir_debug, int, 0644); diff --git a/drivers/media/usb/em28xx/em28xx-reg.h b/drivers/media/usb/em28xx/em28xx-reg.h index af39ddbe01e0..0e0477847965 100644 --- a/drivers/media/usb/em28xx/em28xx-reg.h +++ b/drivers/media/usb/em28xx/em28xx-reg.h @@ -68,7 +68,8 @@ #define EM28XX_R0A_CHIPID 0x0a -#define EM28XX_R0C_USBSUSP 0x0c /* */ +#define EM28XX_R0C_USBSUSP 0x0c +#define EM28XX_R0C_USBSUSP_SNAPSHOT 0x20 /* 1=button pressed, needs reset */ #define EM28XX_R0E_AUDIOSRC 0x0e #define EM28XX_R0F_XCLK 0x0f From 6914d70ecf53e90814fd6d4c8e413b3a8f708d38 Mon Sep 17 00:00:00 2001 From: Frank Schaefer Date: Mon, 3 Jun 2013 14:12:05 -0300 Subject: [PATCH 0327/1048] [media] em28xx: remove GPIO register caching MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The GPIO register caching is the result of wrong assumptions and incomplete knowledge about the GPIO registers and their functionality. Today, we know that it is not needed. It is also limited to a single register and therefore incomplete (newer chips are using multiple registers). Instead of extending the caching, get rid of it, because it has no real benefits and just bloats/complicates the code. Signed-off-by: Frank Schäfer Signed-off-by: Mauro Carvalho Chehab --- drivers/media/usb/em28xx/em28xx-cards.c | 12 ----------- drivers/media/usb/em28xx/em28xx-core.c | 27 ++----------------------- drivers/media/usb/em28xx/em28xx.h | 6 ------ 3 files changed, 2 insertions(+), 43 deletions(-) diff --git a/drivers/media/usb/em28xx/em28xx-cards.c b/drivers/media/usb/em28xx/em28xx-cards.c index 6ee4bed730dd..dc65742c4bbc 100644 --- a/drivers/media/usb/em28xx/em28xx-cards.c +++ b/drivers/media/usb/em28xx/em28xx-cards.c @@ -2896,10 +2896,6 @@ static int em28xx_init_dev(struct em28xx *dev, struct usb_device *udev, em28xx_set_model(dev); - /* Set the default GPO/GPIO for legacy devices */ - dev->reg_gpo_num = EM2880_R04_GPO; - dev->reg_gpio_num = EM2820_R08_GPIO_CTRL; - dev->wait_after_write = 5; /* Based on the Chip ID, set the device configuration */ @@ -2947,13 +2943,11 @@ static int em28xx_init_dev(struct em28xx *dev, struct usb_device *udev, break; case CHIP_ID_EM2874: chip_name = "em2874"; - dev->reg_gpio_num = EM2874_R80_GPIO_P0_CTRL; dev->wait_after_write = 0; dev->eeprom_addrwidth_16bit = 1; break; case CHIP_ID_EM28174: chip_name = "em28174"; - dev->reg_gpio_num = EM2874_R80_GPIO_P0_CTRL; dev->wait_after_write = 0; dev->eeprom_addrwidth_16bit = 1; break; @@ -2963,7 +2957,6 @@ static int em28xx_init_dev(struct em28xx *dev, struct usb_device *udev, break; case CHIP_ID_EM2884: chip_name = "em2884"; - dev->reg_gpio_num = EM2874_R80_GPIO_P0_CTRL; dev->wait_after_write = 0; dev->eeprom_addrwidth_16bit = 1; break; @@ -2992,11 +2985,6 @@ static int em28xx_init_dev(struct em28xx *dev, struct usb_device *udev, return 0; } - /* Prepopulate cached GPO register content */ - retval = em28xx_read_reg(dev, dev->reg_gpo_num); - if (retval >= 0) - dev->reg_gpo = retval; - em28xx_pre_card_setup(dev); if (!dev->board.is_em2800) { diff --git a/drivers/media/usb/em28xx/em28xx-core.c b/drivers/media/usb/em28xx/em28xx-core.c index a802128ce9c5..fc157af5234a 100644 --- a/drivers/media/usb/em28xx/em28xx-core.c +++ b/drivers/media/usb/em28xx/em28xx-core.c @@ -193,23 +193,7 @@ int em28xx_write_regs_req(struct em28xx *dev, u8 req, u16 reg, char *buf, int em28xx_write_regs(struct em28xx *dev, u16 reg, char *buf, int len) { - int rc; - - rc = em28xx_write_regs_req(dev, USB_REQ_GET_STATUS, reg, buf, len); - - /* Stores GPO/GPIO values at the cache, if changed - Only write values should be stored, since input on a GPIO - register will return the input bits. - Not sure what happens on reading GPO register. - */ - if (rc >= 0) { - if (reg == dev->reg_gpo_num) - dev->reg_gpo = buf[0]; - else if (reg == dev->reg_gpio_num) - dev->reg_gpio = buf[0]; - } - - return rc; + return em28xx_write_regs_req(dev, USB_REQ_GET_STATUS, reg, buf, len); } EXPORT_SYMBOL_GPL(em28xx_write_regs); @@ -231,14 +215,7 @@ int em28xx_write_reg_bits(struct em28xx *dev, u16 reg, u8 val, int oldval; u8 newval; - /* Uses cache for gpo/gpio registers */ - if (reg == dev->reg_gpo_num) - oldval = dev->reg_gpo; - else if (reg == dev->reg_gpio_num) - oldval = dev->reg_gpio; - else - oldval = em28xx_read_reg(dev, reg); - + oldval = em28xx_read_reg(dev, reg); if (oldval < 0) return oldval; diff --git a/drivers/media/usb/em28xx/em28xx.h b/drivers/media/usb/em28xx/em28xx.h index 59a95802aa68..205e9038b1c0 100644 --- a/drivers/media/usb/em28xx/em28xx.h +++ b/drivers/media/usb/em28xx/em28xx.h @@ -637,12 +637,6 @@ struct em28xx { enum em28xx_mode mode; - /* register numbers for GPO/GPIO registers */ - u16 reg_gpo_num, reg_gpio_num; - - /* Caches GPO and GPIO registers */ - unsigned char reg_gpo, reg_gpio; - /* Snapshot button */ char snapshot_button_path[30]; /* path of the input dev */ struct input_dev *sbutton_input_dev; From 414abbd2cd4c2618895f02ed3a76ec6647281436 Mon Sep 17 00:00:00 2001 From: Soeren Moch Date: Wed, 5 Jun 2013 21:26:23 -0300 Subject: [PATCH 0328/1048] [media] media: dmxdev: remove dvb_ringbuffer_flush() on writer side In dvb_ringbuffer lock-less synchronizationof reader and writer threads is done with separateread and write pointers. Sincedvb_ringbuffer_flush() modifies the read pointer, this function must not be called from the writer thread. This patch removes the dvb_ringbuffer_flush() calls in the dmxdev ringbuffer write functions, this fixes Oopses "Unable to handle kernel paging request" I could observe for the call chaindvb_demux_read ->dvb_dmxdev_buffer_read -> dvb_ringbuffer_read_user -> __copy_to_user (the reader side of the ringbuffer). The flush calls at the write side are not necessary anyway since ringbuffer_flush is also called in dvb_dmxdev_buffer_read() when an error condition is set in the ringbuffer. This patch should also be applied to stable kernels. Signed-off-by: Soeren Moch CC: Reviewed-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb-core/dmxdev.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/media/dvb-core/dmxdev.c b/drivers/media/dvb-core/dmxdev.c index a1a3a5159d71..0b4616b87195 100644 --- a/drivers/media/dvb-core/dmxdev.c +++ b/drivers/media/dvb-core/dmxdev.c @@ -377,10 +377,8 @@ static int dvb_dmxdev_section_callback(const u8 *buffer1, size_t buffer1_len, ret = dvb_dmxdev_buffer_write(&dmxdevfilter->buffer, buffer2, buffer2_len); } - if (ret < 0) { - dvb_ringbuffer_flush(&dmxdevfilter->buffer); + if (ret < 0) dmxdevfilter->buffer.error = ret; - } if (dmxdevfilter->params.sec.flags & DMX_ONESHOT) dmxdevfilter->state = DMXDEV_STATE_DONE; spin_unlock(&dmxdevfilter->dev->lock); @@ -416,10 +414,8 @@ static int dvb_dmxdev_ts_callback(const u8 *buffer1, size_t buffer1_len, ret = dvb_dmxdev_buffer_write(buffer, buffer1, buffer1_len); if (ret == buffer1_len) ret = dvb_dmxdev_buffer_write(buffer, buffer2, buffer2_len); - if (ret < 0) { - dvb_ringbuffer_flush(buffer); + if (ret < 0) buffer->error = ret; - } spin_unlock(&dmxdevfilter->dev->lock); wake_up(&buffer->queue); return 0; From e12d0271774fea9fddf1e2a7952a0bffb2ee8e8b Mon Sep 17 00:00:00 2001 From: Steven Rostedt Date: Fri, 10 May 2013 17:12:28 -0400 Subject: [PATCH 0329/1048] nohz: Warn if the machine can not perform nohz_full If the user configures NO_HZ_FULL and defines nohz_full=XXX on the kernel command line, or enables NO_HZ_FULL_ALL, but nohz fails due to the machine having a unstable clock, warn about it. We do not want users thinking that they are getting the benefit of nohz when their machine can not support it. Signed-off-by: Steven Rostedt Cc: Paul E. McKenney Cc: Ingo Molnar Cc: Andrew Morton Cc: Thomas Gleixner Cc: H. Peter Anvin Cc: Peter Zijlstra Cc: Borislav Petkov Cc: Li Zhong Signed-off-by: Frederic Weisbecker --- kernel/time/tick-sched.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c index f4208138fbf4..d87d22cb9bf2 100644 --- a/kernel/time/tick-sched.c +++ b/kernel/time/tick-sched.c @@ -178,6 +178,11 @@ static bool can_stop_full_tick(void) */ if (!sched_clock_stable) { trace_tick_stop(0, "unstable sched clock\n"); + /* + * Don't allow the user to think they can get + * full NO_HZ with this machine. + */ + WARN_ONCE(1, "NO_HZ FULL will not work with unstable sched clock"); return false; } #endif From b8900bc0217fac8e68085997bee2f05e6db931a2 Mon Sep 17 00:00:00 2001 From: Frederic Weisbecker Date: Thu, 6 Jun 2013 15:42:53 +0200 Subject: [PATCH 0330/1048] watchdog: Register / unregister watchdog kthreads on sysctl control The user activation/deactivation of the watchdog through boot parameters or systcl is currently implemented with a dance involving kthreads parking and unparking methods: the threads are unconditionally registered on boot and they park as soon as the user want the watchdog to be disabled. This method involves a few noisy details to handle though: the watchdog kthreads may be unparked anytime due to hotplug operations, after which the watchdog internals have to decide to park again if it is user-disabled. As a result the setup() and unpark() methods need to be able to request a reparking. This is not currently supported in the kthread infrastructure so this piece of the watchdog code only works halfway. Besides, unparking/reparking the watchdog kthreads consume unnecessary cputime on hotplug operations when those could be simply ignored in the first place. As suggested by Srivatsa, let's instead only register the watchdog threads when they are needed. This way we don't need to think about hotplug operations and we don't burden the CPU onlining when the watchdog is simply disabled. Suggested-by: Srivatsa S. Bhat Signed-off-by: Frederic Weisbecker Cc: Srivatsa S. Bhat Cc: Anish Singh Cc: Steven Rostedt Cc: Paul E. McKenney Cc: Ingo Molnar Cc: Thomas Gleixner Cc: Peter Zijlstra Cc: Borislav Petkov Cc: Li Zhong Cc: Don Zickus --- kernel/watchdog.c | 93 +++++++++++++++++++++++++---------------------- 1 file changed, 50 insertions(+), 43 deletions(-) diff --git a/kernel/watchdog.c b/kernel/watchdog.c index 05039e348f07..52c9a9b91bdd 100644 --- a/kernel/watchdog.c +++ b/kernel/watchdog.c @@ -31,7 +31,7 @@ int watchdog_enabled = 1; int __read_mostly watchdog_thresh = 10; -static int __read_mostly watchdog_disabled; +static int __read_mostly watchdog_disabled = 1; static u64 __read_mostly sample_period; static DEFINE_PER_CPU(unsigned long, watchdog_touch_ts); @@ -347,11 +347,6 @@ static void watchdog_enable(unsigned int cpu) hrtimer_init(hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); hrtimer->function = watchdog_timer_fn; - if (!watchdog_enabled) { - kthread_park(current); - return; - } - /* Enable the perf event */ watchdog_nmi_enable(cpu); @@ -374,6 +369,11 @@ static void watchdog_disable(unsigned int cpu) watchdog_nmi_disable(cpu); } +static void watchdog_cleanup(unsigned int cpu, bool online) +{ + watchdog_disable(cpu); +} + static int watchdog_should_run(unsigned int cpu) { return __this_cpu_read(hrtimer_interrupts) != @@ -475,28 +475,40 @@ static int watchdog_nmi_enable(unsigned int cpu) { return 0; } static void watchdog_nmi_disable(unsigned int cpu) { return; } #endif /* CONFIG_HARDLOCKUP_DETECTOR */ +static struct smp_hotplug_thread watchdog_threads = { + .store = &softlockup_watchdog, + .thread_should_run = watchdog_should_run, + .thread_fn = watchdog, + .thread_comm = "watchdog/%u", + .setup = watchdog_enable, + .cleanup = watchdog_cleanup, + .park = watchdog_disable, + .unpark = watchdog_enable, +}; + +static int watchdog_enable_all_cpus(void) +{ + int err = 0; + + if (watchdog_disabled) { + err = smpboot_register_percpu_thread(&watchdog_threads); + if (err) + pr_err("Failed to create watchdog threads, disabled\n"); + else + watchdog_disabled = 0; + } + + return err; +} + /* prepare/enable/disable routines */ /* sysctl functions */ #ifdef CONFIG_SYSCTL -static void watchdog_enable_all_cpus(void) -{ - unsigned int cpu; - - if (watchdog_disabled) { - watchdog_disabled = 0; - for_each_online_cpu(cpu) - kthread_unpark(per_cpu(softlockup_watchdog, cpu)); - } -} - static void watchdog_disable_all_cpus(void) { - unsigned int cpu; - if (!watchdog_disabled) { watchdog_disabled = 1; - for_each_online_cpu(cpu) - kthread_park(per_cpu(softlockup_watchdog, cpu)); + smpboot_unregister_percpu_thread(&watchdog_threads); } } @@ -507,14 +519,14 @@ static void watchdog_disable_all_cpus(void) int proc_dowatchdog(struct ctl_table *table, int write, void __user *buffer, size_t *lenp, loff_t *ppos) { - int ret; + int err, old_thresh, old_enabled; - if (watchdog_disabled < 0) - return -ENODEV; + old_thresh = ACCESS_ONCE(watchdog_thresh); + old_enabled = ACCESS_ONCE(watchdog_enabled); - ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos); - if (ret || !write) - return ret; + err = proc_dointvec_minmax(table, write, buffer, lenp, ppos); + if (err || !write) + return err; set_sample_period(); /* @@ -523,29 +535,24 @@ int proc_dowatchdog(struct ctl_table *table, int write, * watchdog_*_all_cpus() function takes care of this. */ if (watchdog_enabled && watchdog_thresh) - watchdog_enable_all_cpus(); + err = watchdog_enable_all_cpus(); else watchdog_disable_all_cpus(); - return ret; + /* Restore old values on failure */ + if (err) { + watchdog_thresh = old_thresh; + watchdog_enabled = old_enabled; + } + + return err; } #endif /* CONFIG_SYSCTL */ -static struct smp_hotplug_thread watchdog_threads = { - .store = &softlockup_watchdog, - .thread_should_run = watchdog_should_run, - .thread_fn = watchdog, - .thread_comm = "watchdog/%u", - .setup = watchdog_enable, - .park = watchdog_disable, - .unpark = watchdog_enable, -}; - void __init lockup_detector_init(void) { set_sample_period(); - if (smpboot_register_percpu_thread(&watchdog_threads)) { - pr_err("Failed to create watchdog threads, disabled\n"); - watchdog_disabled = -ENODEV; - } + + if (watchdog_enabled) + watchdog_enable_all_cpus(); } From 21bfd4706268c85c9d17ca2fd48de3b19c9d40db Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Tue, 18 Jun 2013 10:27:38 +0300 Subject: [PATCH 0331/1048] RDMA/cxgb3: Timeout condition is never true This is a static checker fix. "count" is unsigned so it's never -1. Since "count" is 16 bits and the addition operation is implicitly casted to int then there is no wrapping here. Signed-off-by: Dan Carpenter Acked-by: Steve Wise Signed-off-by: Roland Dreier --- drivers/infiniband/hw/cxgb3/iwch_qp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/infiniband/hw/cxgb3/iwch_qp.c b/drivers/infiniband/hw/cxgb3/iwch_qp.c index e5649e8b215d..b57c0befd962 100644 --- a/drivers/infiniband/hw/cxgb3/iwch_qp.c +++ b/drivers/infiniband/hw/cxgb3/iwch_qp.c @@ -883,7 +883,8 @@ u16 iwch_rqes_posted(struct iwch_qp *qhp) { union t3_wr *wqe = qhp->wq.queue; u16 count = 0; - while ((count+1) != 0 && fw_riwrh_opcode((struct fw_riwrh *)wqe) == T3_WR_RCV) { + + while (count < USHRT_MAX && fw_riwrh_opcode((struct fw_riwrh *)wqe) == T3_WR_RCV) { count++; wqe++; } From f29fa1cf340e21085672ccfeb6d66f292208567e Mon Sep 17 00:00:00 2001 From: Wei Yongjun Date: Wed, 19 Jun 2013 10:40:09 +0800 Subject: [PATCH 0332/1048] IB/ehca: Fix error return code in ehca_create_slab_caches() Fix to return -ENOMEM in the kmem_cache_create() error handling case instead of 0, as done elsewhere in this function. Signed-off-by: Wei Yongjun Signed-off-by: Roland Dreier --- drivers/infiniband/hw/ehca/ehca_main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/infiniband/hw/ehca/ehca_main.c b/drivers/infiniband/hw/ehca/ehca_main.c index f8a62918a88d..8f43093edace 100644 --- a/drivers/infiniband/hw/ehca/ehca_main.c +++ b/drivers/infiniband/hw/ehca/ehca_main.c @@ -211,6 +211,7 @@ static int ehca_create_slab_caches(void) if (!ctblk_cache) { ehca_gen_err("Cannot create ctblk SLAB cache."); ehca_cleanup_small_qp_cache(); + ret = -ENOMEM; goto create_slab_caches6; } #endif From 27159f5087f9ff59fdc42958a31bca3a291b9f67 Mon Sep 17 00:00:00 2001 From: "Gottumukkala, Naresh" Date: Wed, 5 Jun 2013 08:50:46 +0000 Subject: [PATCH 0333/1048] RDMA/ocrdma: Remove use_cnt for queues Remove use_cnt. Rely on IB midlayer to keep track of the use count. Signed-off-by: Naresh Gottumukkala Signed-off-by: Roland Dreier --- drivers/infiniband/hw/ocrdma/ocrdma.h | 4 --- drivers/infiniband/hw/ocrdma/ocrdma_hw.c | 1 - drivers/infiniband/hw/ocrdma/ocrdma_verbs.c | 39 +-------------------- 3 files changed, 1 insertion(+), 43 deletions(-) diff --git a/drivers/infiniband/hw/ocrdma/ocrdma.h b/drivers/infiniband/hw/ocrdma/ocrdma.h index 48970af23679..21d99f6fb367 100644 --- a/drivers/infiniband/hw/ocrdma/ocrdma.h +++ b/drivers/infiniband/hw/ocrdma/ocrdma.h @@ -97,7 +97,6 @@ struct ocrdma_queue_info { u16 id; /* qid, where to ring the doorbell. */ u16 head, tail; bool created; - atomic_t used; /* Number of valid elements in the queue */ }; struct ocrdma_eq { @@ -198,7 +197,6 @@ struct ocrdma_cq { struct ocrdma_ucontext *ucontext; dma_addr_t pa; u32 len; - atomic_t use_cnt; /* head of all qp's sq and rq for which cqes need to be flushed * by the software. @@ -210,7 +208,6 @@ struct ocrdma_pd { struct ib_pd ibpd; struct ocrdma_dev *dev; struct ocrdma_ucontext *uctx; - atomic_t use_cnt; u32 id; int num_dpp_qp; u32 dpp_page; @@ -246,7 +243,6 @@ struct ocrdma_srq { struct ocrdma_qp_hwq_info rq; struct ocrdma_pd *pd; - atomic_t use_cnt; u32 id; u64 *rqe_wr_id_tbl; u32 *idx_bit_fields; diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_hw.c b/drivers/infiniband/hw/ocrdma/ocrdma_hw.c index 71942af4fce9..910b706a91c7 100644 --- a/drivers/infiniband/hw/ocrdma/ocrdma_hw.c +++ b/drivers/infiniband/hw/ocrdma/ocrdma_hw.c @@ -128,7 +128,6 @@ static inline struct ocrdma_mqe *ocrdma_get_mqe(struct ocrdma_dev *dev) static inline void ocrdma_mq_inc_head(struct ocrdma_dev *dev) { dev->mq.sq.head = (dev->mq.sq.head + 1) & (OCRDMA_MQ_LEN - 1); - atomic_inc(&dev->mq.sq.used); } static inline void *ocrdma_get_mqe_rsp(struct ocrdma_dev *dev) diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c index b29a4246ef41..38c145b28f5c 100644 --- a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c +++ b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c @@ -398,7 +398,6 @@ struct ib_pd *ocrdma_alloc_pd(struct ib_device *ibdev, kfree(pd); return ERR_PTR(status); } - atomic_set(&pd->use_cnt, 0); if (udata && context) { status = ocrdma_copy_pd_uresp(pd, context, udata); @@ -419,12 +418,6 @@ int ocrdma_dealloc_pd(struct ib_pd *ibpd) int status; u64 usr_db; - if (atomic_read(&pd->use_cnt)) { - ocrdma_err("%s(%d) pd=0x%x is in use.\n", - __func__, dev->id, pd->id); - status = -EFAULT; - goto dealloc_err; - } status = ocrdma_mbx_dealloc_pd(dev, pd); if (pd->uctx) { u64 dpp_db = dev->nic_info.dpp_unmapped_addr + @@ -436,7 +429,6 @@ int ocrdma_dealloc_pd(struct ib_pd *ibpd) ocrdma_del_mmap(pd->uctx, usr_db, dev->nic_info.db_page_size); } kfree(pd); -dealloc_err: return status; } @@ -474,7 +466,6 @@ static struct ocrdma_mr *ocrdma_alloc_lkey(struct ib_pd *ibpd, return ERR_PTR(-ENOMEM); } mr->pd = pd; - atomic_inc(&pd->use_cnt); mr->ibmr.lkey = mr->hwmr.lkey; if (mr->hwmr.remote_wr || mr->hwmr.remote_rd) mr->ibmr.rkey = mr->hwmr.lkey; @@ -664,7 +655,6 @@ struct ib_mr *ocrdma_reg_user_mr(struct ib_pd *ibpd, u64 start, u64 len, if (status) goto mbx_err; mr->pd = pd; - atomic_inc(&pd->use_cnt); mr->ibmr.lkey = mr->hwmr.lkey; if (mr->hwmr.remote_wr || mr->hwmr.remote_rd) mr->ibmr.rkey = mr->hwmr.lkey; @@ -689,7 +679,6 @@ int ocrdma_dereg_mr(struct ib_mr *ib_mr) if (mr->hwmr.fr_mr == 0) ocrdma_free_mr_pbl_tbl(dev, &mr->hwmr); - atomic_dec(&mr->pd->use_cnt); /* it could be user registered memory. */ if (mr->umem) ib_umem_release(mr->umem); @@ -752,7 +741,6 @@ struct ib_cq *ocrdma_create_cq(struct ib_device *ibdev, int entries, int vector, spin_lock_init(&cq->cq_lock); spin_lock_init(&cq->comp_handler_lock); - atomic_set(&cq->use_cnt, 0); INIT_LIST_HEAD(&cq->sq_head); INIT_LIST_HEAD(&cq->rq_head); cq->dev = dev; @@ -799,9 +787,6 @@ int ocrdma_destroy_cq(struct ib_cq *ibcq) struct ocrdma_cq *cq = get_ocrdma_cq(ibcq); struct ocrdma_dev *dev = cq->dev; - if (atomic_read(&cq->use_cnt)) - return -EINVAL; - status = ocrdma_mbx_destroy_cq(dev, cq); if (cq->ucontext) { @@ -1023,15 +1008,6 @@ static void ocrdma_set_qp_init_params(struct ocrdma_qp *qp, qp->state = OCRDMA_QPS_RST; } -static void ocrdma_set_qp_use_cnt(struct ocrdma_qp *qp, struct ocrdma_pd *pd) -{ - atomic_inc(&pd->use_cnt); - atomic_inc(&qp->sq_cq->use_cnt); - atomic_inc(&qp->rq_cq->use_cnt); - if (qp->srq) - atomic_inc(&qp->srq->use_cnt); - qp->ibqp.qp_num = qp->id; -} static void ocrdma_store_gsi_qp_cq(struct ocrdma_dev *dev, struct ib_qp_init_attr *attrs) @@ -1099,7 +1075,7 @@ struct ib_qp *ocrdma_create_qp(struct ib_pd *ibpd, goto cpy_err; } ocrdma_store_gsi_qp_cq(dev, attrs); - ocrdma_set_qp_use_cnt(qp, pd); + qp->ibqp.qp_num = qp->id; mutex_unlock(&dev->dev_lock); return &qp->ibqp; @@ -1475,11 +1451,6 @@ int ocrdma_destroy_qp(struct ib_qp *ibqp) ocrdma_del_flush_qp(qp); - atomic_dec(&qp->pd->use_cnt); - atomic_dec(&qp->sq_cq->use_cnt); - atomic_dec(&qp->rq_cq->use_cnt); - if (qp->srq) - atomic_dec(&qp->srq->use_cnt); kfree(qp->wqe_wr_id_tbl); kfree(qp->rqe_wr_id_tbl); kfree(qp); @@ -1565,14 +1536,12 @@ struct ib_srq *ocrdma_create_srq(struct ib_pd *ibpd, goto arm_err; } - atomic_set(&srq->use_cnt, 0); if (udata) { status = ocrdma_copy_srq_uresp(srq, udata); if (status) goto arm_err; } - atomic_inc(&pd->use_cnt); return &srq->ibsrq; arm_err: @@ -1618,18 +1587,12 @@ int ocrdma_destroy_srq(struct ib_srq *ibsrq) srq = get_ocrdma_srq(ibsrq); dev = srq->dev; - if (atomic_read(&srq->use_cnt)) { - ocrdma_err("%s(%d) err, srq=0x%x in use\n", - __func__, dev->id, srq->id); - return -EAGAIN; - } status = ocrdma_mbx_destroy_srq(dev, srq); if (srq->pd->uctx) ocrdma_del_mmap(srq->pd->uctx, (u64) srq->rq.pa, srq->rq.len); - atomic_dec(&srq->pd->use_cnt); kfree(srq->idx_bit_fields); kfree(srq->rqe_wr_id_tbl); kfree(srq); From b1d58b99194a121a44ec77571f84f62a6ccd6431 Mon Sep 17 00:00:00 2001 From: Naresh Gottumukkala Date: Mon, 10 Jun 2013 04:42:38 +0000 Subject: [PATCH 0334/1048] RDMA/ocrdma: Use MCC_CREATE_EXT_V1 for MCC create Use MCC_CREATE_EXT_V1 to create MCC_queue to receive RoCE events. Signed-off-by: Naresh Gottumukkala Signed-off-by: Roland Dreier --- drivers/infiniband/hw/ocrdma/ocrdma_hw.c | 39 ++++++++--------------- drivers/infiniband/hw/ocrdma/ocrdma_sli.h | 20 ++---------- 2 files changed, 15 insertions(+), 44 deletions(-) diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_hw.c b/drivers/infiniband/hw/ocrdma/ocrdma_hw.c index 910b706a91c7..f671d5d9ce3a 100644 --- a/drivers/infiniband/hw/ocrdma/ocrdma_hw.c +++ b/drivers/infiniband/hw/ocrdma/ocrdma_hw.c @@ -563,32 +563,19 @@ static int ocrdma_mbx_create_mq(struct ocrdma_dev *dev, memset(cmd, 0, sizeof(*cmd)); num_pages = PAGES_4K_SPANNED(mq->va, mq->size); - if (dev->nic_info.dev_family == OCRDMA_GEN2_FAMILY) { - ocrdma_init_mch(&cmd->req, OCRDMA_CMD_CREATE_MQ, - OCRDMA_SUBSYS_COMMON, sizeof(*cmd)); - cmd->v0.pages = num_pages; - cmd->v0.async_cqid_valid = OCRDMA_CREATE_MQ_ASYNC_CQ_VALID; - cmd->v0.async_cqid_valid = (cq->id << 1); - cmd->v0.cqid_ringsize |= (ocrdma_encoded_q_len(mq->len) << - OCRDMA_CREATE_MQ_RING_SIZE_SHIFT); - cmd->v0.cqid_ringsize |= - (cq->id << OCRDMA_CREATE_MQ_V0_CQ_ID_SHIFT); - cmd->v0.valid = OCRDMA_CREATE_MQ_VALID; - pa = &cmd->v0.pa[0]; - } else { - ocrdma_init_mch(&cmd->req, OCRDMA_CMD_CREATE_MQ_EXT, - OCRDMA_SUBSYS_COMMON, sizeof(*cmd)); - cmd->req.rsvd_version = 1; - cmd->v1.cqid_pages = num_pages; - cmd->v1.cqid_pages |= (cq->id << OCRDMA_CREATE_MQ_CQ_ID_SHIFT); - cmd->v1.async_cqid_valid = OCRDMA_CREATE_MQ_ASYNC_CQ_VALID; - cmd->v1.async_event_bitmap = Bit(20); - cmd->v1.async_cqid_ringsize = cq->id; - cmd->v1.async_cqid_ringsize |= (ocrdma_encoded_q_len(mq->len) << - OCRDMA_CREATE_MQ_RING_SIZE_SHIFT); - cmd->v1.valid = OCRDMA_CREATE_MQ_VALID; - pa = &cmd->v1.pa[0]; - } + ocrdma_init_mch(&cmd->req, OCRDMA_CMD_CREATE_MQ_EXT, + OCRDMA_SUBSYS_COMMON, sizeof(*cmd)); + cmd->req.rsvd_version = 1; + cmd->cqid_pages = num_pages; + cmd->cqid_pages |= (cq->id << OCRDMA_CREATE_MQ_CQ_ID_SHIFT); + cmd->async_cqid_valid = OCRDMA_CREATE_MQ_ASYNC_CQ_VALID; + cmd->async_event_bitmap = Bit(20); + cmd->async_cqid_ringsize = cq->id; + cmd->async_cqid_ringsize |= (ocrdma_encoded_q_len(mq->len) << + OCRDMA_CREATE_MQ_RING_SIZE_SHIFT); + cmd->valid = OCRDMA_CREATE_MQ_VALID; + pa = &cmd->pa[0]; + ocrdma_build_q_pages(pa, num_pages, mq->dma, PAGE_SIZE_4K); status = be_roce_mcc_cmd(dev->nic_info.netdev, cmd, sizeof(*cmd), NULL, NULL); diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_sli.h b/drivers/infiniband/hw/ocrdma/ocrdma_sli.h index c75cbdfa87e7..cd0512f1fb5b 100644 --- a/drivers/infiniband/hw/ocrdma/ocrdma_sli.h +++ b/drivers/infiniband/hw/ocrdma/ocrdma_sli.h @@ -608,16 +608,8 @@ enum { OCRDMA_CREATE_MQ_ASYNC_CQ_VALID = Bit(0) }; -struct ocrdma_create_mq_v0 { - u32 pages; - u32 cqid_ringsize; - u32 valid; - u32 async_cqid_valid; - u32 rsvd; - struct ocrdma_pa pa[8]; -} __packed; - -struct ocrdma_create_mq_v1 { +struct ocrdma_create_mq_req { + struct ocrdma_mbx_hdr req; u32 cqid_pages; u32 async_event_bitmap; u32 async_cqid_ringsize; @@ -627,14 +619,6 @@ struct ocrdma_create_mq_v1 { struct ocrdma_pa pa[8]; } __packed; -struct ocrdma_create_mq_req { - struct ocrdma_mbx_hdr req; - union { - struct ocrdma_create_mq_v0 v0; - struct ocrdma_create_mq_v1 v1; - }; -} __packed; - struct ocrdma_create_mq_rsp { struct ocrdma_mbx_rsp rsp; u32 id; From ef99c4c2ed63cb0deb94ea70fb47c2d6294e302e Mon Sep 17 00:00:00 2001 From: Naresh Gottumukkala Date: Mon, 10 Jun 2013 04:42:39 +0000 Subject: [PATCH 0335/1048] RDMA/ocrdma: Replace ocrdma_err with pr_err Remove private macro ocrdma_err and replace with standard pr_err. Signed-off-by: Naresh Gottumukkala Signed-off-by: Roland Dreier --- drivers/infiniband/hw/ocrdma/ocrdma.h | 2 - drivers/infiniband/hw/ocrdma/ocrdma_hw.c | 44 +++++----- drivers/infiniband/hw/ocrdma/ocrdma_main.c | 6 +- drivers/infiniband/hw/ocrdma/ocrdma_verbs.c | 92 ++++++++++----------- 4 files changed, 70 insertions(+), 74 deletions(-) diff --git a/drivers/infiniband/hw/ocrdma/ocrdma.h b/drivers/infiniband/hw/ocrdma/ocrdma.h index 21d99f6fb367..9d82d097e25a 100644 --- a/drivers/infiniband/hw/ocrdma/ocrdma.h +++ b/drivers/infiniband/hw/ocrdma/ocrdma.h @@ -42,8 +42,6 @@ #define OCRDMA_ROCE_DEV_VERSION "1.0.0" #define OCRDMA_NODE_DESC "Emulex OneConnect RoCE HCA" -#define ocrdma_err(format, arg...) printk(KERN_ERR format, ##arg) - #define OCRDMA_MAX_AH 512 #define OCRDMA_UVERBS(CMD_NAME) (1ull << IB_USER_VERBS_CMD_##CMD_NAME) diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_hw.c b/drivers/infiniband/hw/ocrdma/ocrdma_hw.c index f671d5d9ce3a..76c9e192ddcc 100644 --- a/drivers/infiniband/hw/ocrdma/ocrdma_hw.c +++ b/drivers/infiniband/hw/ocrdma/ocrdma_hw.c @@ -731,7 +731,7 @@ static void ocrdma_dispatch_ibevent(struct ocrdma_dev *dev, qp_event = 0; srq_event = 0; dev_event = 0; - ocrdma_err("%s() unknown type=0x%x\n", __func__, type); + pr_err("%s() unknown type=0x%x\n", __func__, type); break; } @@ -761,8 +761,8 @@ static void ocrdma_process_acqe(struct ocrdma_dev *dev, void *ae_cqe) if (evt_code == OCRDMA_ASYNC_EVE_CODE) ocrdma_dispatch_ibevent(dev, cqe); else - ocrdma_err("%s(%d) invalid evt code=0x%x\n", - __func__, dev->id, evt_code); + pr_err("%s(%d) invalid evt code=0x%x\n", __func__, + dev->id, evt_code); } static void ocrdma_process_mcqe(struct ocrdma_dev *dev, struct ocrdma_mcqe *cqe) @@ -776,8 +776,8 @@ static void ocrdma_process_mcqe(struct ocrdma_dev *dev, struct ocrdma_mcqe *cqe) dev->mqe_ctx.cmd_done = true; wake_up(&dev->mqe_ctx.cmd_wait); } else - ocrdma_err("%s() cqe for invalid tag0x%x.expected=0x%x\n", - __func__, cqe->tag_lo, dev->mqe_ctx.tag); + pr_err("%s() cqe for invalid tag0x%x.expected=0x%x\n", + __func__, cqe->tag_lo, dev->mqe_ctx.tag); } static int ocrdma_mq_cq_handler(struct ocrdma_dev *dev, u16 cq_id) @@ -796,7 +796,7 @@ static int ocrdma_mq_cq_handler(struct ocrdma_dev *dev, u16 cq_id) else if (cqe->valid_ae_cmpl_cons & OCRDMA_MCQE_CMPL_MASK) ocrdma_process_mcqe(dev, cqe); else - ocrdma_err("%s() cqe->compl is not set.\n", __func__); + pr_err("%s() cqe->compl is not set.\n", __func__); memset(cqe, 0, sizeof(struct ocrdma_mcqe)); ocrdma_mcq_inc_tail(dev); } @@ -855,7 +855,7 @@ static void ocrdma_qp_cq_handler(struct ocrdma_dev *dev, u16 cq_idx) cq = dev->cq_tbl[cq_idx]; if (cq == NULL) { - ocrdma_err("%s%d invalid id=0x%x\n", __func__, dev->id, cq_idx); + pr_err("%s%d invalid id=0x%x\n", __func__, dev->id, cq_idx); return; } spin_lock_irqsave(&cq->cq_lock, flags); @@ -957,7 +957,7 @@ static int ocrdma_mbx_cmd(struct ocrdma_dev *dev, struct ocrdma_mqe *mqe) rsp = ocrdma_get_mqe_rsp(dev); ocrdma_copy_le32_to_cpu(mqe, rsp, (sizeof(*mqe))); if (cqe_status || ext_status) { - ocrdma_err + pr_err ("%s() opcode=0x%x, cqe_status=0x%x, ext_status=0x%x\n", __func__, (rsp->u.rsp.subsys_op & OCRDMA_MBX_RSP_OPCODE_MASK) >> @@ -1339,8 +1339,8 @@ int ocrdma_mbx_create_cq(struct ocrdma_dev *dev, struct ocrdma_cq *cq, if (dpp_cq) return -EINVAL; if (entries > dev->attr.max_cqe) { - ocrdma_err("%s(%d) max_cqe=0x%x, requester_cqe=0x%x\n", - __func__, dev->id, dev->attr.max_cqe, entries); + pr_err("%s(%d) max_cqe=0x%x, requester_cqe=0x%x\n", + __func__, dev->id, dev->attr.max_cqe, entries); return -EINVAL; } if (dpp_cq && (dev->nic_info.dev_family != OCRDMA_GEN2_FAMILY)) @@ -1607,7 +1607,7 @@ int ocrdma_reg_mr(struct ocrdma_dev *dev, status = ocrdma_mbx_reg_mr(dev, hwmr, pdid, cur_pbl_cnt, hwmr->pbe_size, last); if (status) { - ocrdma_err("%s() status=%d\n", __func__, status); + pr_err("%s() status=%d\n", __func__, status); return status; } /* if there is no more pbls to register then exit. */ @@ -1630,7 +1630,7 @@ int ocrdma_reg_mr(struct ocrdma_dev *dev, break; } if (status) - ocrdma_err("%s() err. status=%d\n", __func__, status); + pr_err("%s() err. status=%d\n", __func__, status); return status; } @@ -1827,8 +1827,8 @@ static int ocrdma_set_create_qp_sq_cmd(struct ocrdma_create_qp_req *cmd, status = ocrdma_build_q_conf(&max_wqe_allocated, dev->attr.wqe_size, &hw_pages, &hw_page_size); if (status) { - ocrdma_err("%s() req. max_send_wr=0x%x\n", __func__, - max_wqe_allocated); + pr_err("%s() req. max_send_wr=0x%x\n", __func__, + max_wqe_allocated); return -EINVAL; } qp->sq.max_cnt = max_wqe_allocated; @@ -1877,8 +1877,8 @@ static int ocrdma_set_create_qp_rq_cmd(struct ocrdma_create_qp_req *cmd, status = ocrdma_build_q_conf(&max_rqe_allocated, dev->attr.rqe_size, &hw_pages, &hw_page_size); if (status) { - ocrdma_err("%s() req. max_recv_wr=0x%x\n", __func__, - attrs->cap.max_recv_wr + 1); + pr_err("%s() req. max_recv_wr=0x%x\n", __func__, + attrs->cap.max_recv_wr + 1); return status; } qp->rq.max_cnt = max_rqe_allocated; @@ -2073,10 +2073,10 @@ mbx_err: if (qp->rq.va) dma_free_coherent(&pdev->dev, qp->rq.len, qp->rq.va, qp->rq.pa); rq_err: - ocrdma_err("%s(%d) rq_err\n", __func__, dev->id); + pr_err("%s(%d) rq_err\n", __func__, dev->id); dma_free_coherent(&pdev->dev, qp->sq.len, qp->sq.va, qp->sq.pa); sq_err: - ocrdma_err("%s(%d) sq_err\n", __func__, dev->id); + pr_err("%s(%d) sq_err\n", __func__, dev->id); kfree(cmd); return status; } @@ -2113,7 +2113,7 @@ int ocrdma_resolve_dgid(struct ocrdma_dev *dev, union ib_gid *dgid, else if (rdma_link_local_addr(&in6)) rdma_get_ll_mac(&in6, mac_addr); else { - ocrdma_err("%s() fail to resolve mac_addr.\n", __func__); + pr_err("%s() fail to resolve mac_addr.\n", __func__); return -EINVAL; } return 0; @@ -2348,8 +2348,8 @@ int ocrdma_mbx_create_srq(struct ocrdma_srq *srq, dev->attr.rqe_size, &hw_pages, &hw_page_size); if (status) { - ocrdma_err("%s() req. max_wr=0x%x\n", __func__, - srq_attr->attr.max_wr); + pr_err("%s() req. max_wr=0x%x\n", __func__, + srq_attr->attr.max_wr); status = -EINVAL; goto ret; } @@ -2600,7 +2600,7 @@ mq_err: ocrdma_destroy_qp_eqs(dev); qpeq_err: ocrdma_destroy_eq(dev, &dev->meq); - ocrdma_err("%s() status=%d\n", __func__, status); + pr_err("%s() status=%d\n", __func__, status); return status; } diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_main.c b/drivers/infiniband/hw/ocrdma/ocrdma_main.c index 48928c8e7774..ded416f1adea 100644 --- a/drivers/infiniband/hw/ocrdma/ocrdma_main.c +++ b/drivers/infiniband/hw/ocrdma/ocrdma_main.c @@ -378,7 +378,7 @@ static int ocrdma_alloc_resources(struct ocrdma_dev *dev) spin_lock_init(&dev->flush_q_lock); return 0; alloc_err: - ocrdma_err("%s(%d) error.\n", __func__, dev->id); + pr_err("%s(%d) error.\n", __func__, dev->id); return -ENOMEM; } @@ -396,7 +396,7 @@ static struct ocrdma_dev *ocrdma_add(struct be_dev_info *dev_info) dev = (struct ocrdma_dev *)ib_alloc_device(sizeof(struct ocrdma_dev)); if (!dev) { - ocrdma_err("Unable to allocate ib device\n"); + pr_err("Unable to allocate ib device\n"); return NULL; } dev->mbx_cmd = kzalloc(sizeof(struct ocrdma_mqe_emb_cmd), GFP_KERNEL); @@ -437,7 +437,7 @@ init_err: idr_err: kfree(dev->mbx_cmd); ib_dealloc_device(&dev->ibdev); - ocrdma_err("%s() leaving. ret=%d\n", __func__, status); + pr_err("%s() leaving. ret=%d\n", __func__, status); return NULL; } diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c index 38c145b28f5c..882a8198d820 100644 --- a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c +++ b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c @@ -114,8 +114,8 @@ int ocrdma_query_port(struct ib_device *ibdev, dev = get_ocrdma_dev(ibdev); if (port > 1) { - ocrdma_err("%s(%d) invalid_port=0x%x\n", __func__, - dev->id, port); + pr_err("%s(%d) invalid_port=0x%x\n", __func__, + dev->id, port); return -EINVAL; } netdev = dev->nic_info.netdev; @@ -155,8 +155,7 @@ int ocrdma_modify_port(struct ib_device *ibdev, u8 port, int mask, dev = get_ocrdma_dev(ibdev); if (port > 1) { - ocrdma_err("%s(%d) invalid_port=0x%x\n", __func__, - dev->id, port); + pr_err("%s(%d) invalid_port=0x%x\n", __func__, dev->id, port); return -EINVAL; } return 0; @@ -442,8 +441,8 @@ static struct ocrdma_mr *ocrdma_alloc_lkey(struct ib_pd *ibpd, struct ocrdma_dev *dev = pd->dev; if (acc & IB_ACCESS_REMOTE_WRITE && !(acc & IB_ACCESS_LOCAL_WRITE)) { - ocrdma_err("%s(%d) leaving err, invalid access rights\n", - __func__, dev->id); + pr_err("%s(%d) leaving err, invalid access rights\n", + __func__, dev->id); return ERR_PTR(-EINVAL); } @@ -703,8 +702,8 @@ static int ocrdma_copy_cq_uresp(struct ocrdma_cq *cq, struct ib_udata *udata, uresp.phase_change = cq->phase_change ? 1 : 0; status = ib_copy_to_udata(udata, &uresp, sizeof(uresp)); if (status) { - ocrdma_err("%s(%d) copy error cqid=0x%x.\n", - __func__, cq->dev->id, cq->id); + pr_err("%s(%d) copy error cqid=0x%x.\n", + __func__, cq->dev->id, cq->id); goto err; } uctx = get_ocrdma_ucontext(ib_ctx); @@ -822,57 +821,56 @@ static int ocrdma_check_qp_params(struct ib_pd *ibpd, struct ocrdma_dev *dev, if (attrs->qp_type != IB_QPT_GSI && attrs->qp_type != IB_QPT_RC && attrs->qp_type != IB_QPT_UD) { - ocrdma_err("%s(%d) unsupported qp type=0x%x requested\n", - __func__, dev->id, attrs->qp_type); + pr_err("%s(%d) unsupported qp type=0x%x requested\n", + __func__, dev->id, attrs->qp_type); return -EINVAL; } if (attrs->cap.max_send_wr > dev->attr.max_wqe) { - ocrdma_err("%s(%d) unsupported send_wr=0x%x requested\n", - __func__, dev->id, attrs->cap.max_send_wr); - ocrdma_err("%s(%d) supported send_wr=0x%x\n", - __func__, dev->id, dev->attr.max_wqe); + pr_err("%s(%d) unsupported send_wr=0x%x requested\n", + __func__, dev->id, attrs->cap.max_send_wr); + pr_err("%s(%d) supported send_wr=0x%x\n", + __func__, dev->id, dev->attr.max_wqe); return -EINVAL; } if (!attrs->srq && (attrs->cap.max_recv_wr > dev->attr.max_rqe)) { - ocrdma_err("%s(%d) unsupported recv_wr=0x%x requested\n", - __func__, dev->id, attrs->cap.max_recv_wr); - ocrdma_err("%s(%d) supported recv_wr=0x%x\n", - __func__, dev->id, dev->attr.max_rqe); + pr_err("%s(%d) unsupported recv_wr=0x%x requested\n", + __func__, dev->id, attrs->cap.max_recv_wr); + pr_err("%s(%d) supported recv_wr=0x%x\n", + __func__, dev->id, dev->attr.max_rqe); return -EINVAL; } if (attrs->cap.max_inline_data > dev->attr.max_inline_data) { - ocrdma_err("%s(%d) unsupported inline data size=0x%x" - " requested\n", __func__, dev->id, - attrs->cap.max_inline_data); - ocrdma_err("%s(%d) supported inline data size=0x%x\n", - __func__, dev->id, dev->attr.max_inline_data); + pr_err("%s(%d) unsupported inline data size=0x%x requested\n", + __func__, dev->id, attrs->cap.max_inline_data); + pr_err("%s(%d) supported inline data size=0x%x\n", + __func__, dev->id, dev->attr.max_inline_data); return -EINVAL; } if (attrs->cap.max_send_sge > dev->attr.max_send_sge) { - ocrdma_err("%s(%d) unsupported send_sge=0x%x requested\n", - __func__, dev->id, attrs->cap.max_send_sge); - ocrdma_err("%s(%d) supported send_sge=0x%x\n", - __func__, dev->id, dev->attr.max_send_sge); + pr_err("%s(%d) unsupported send_sge=0x%x requested\n", + __func__, dev->id, attrs->cap.max_send_sge); + pr_err("%s(%d) supported send_sge=0x%x\n", + __func__, dev->id, dev->attr.max_send_sge); return -EINVAL; } if (attrs->cap.max_recv_sge > dev->attr.max_recv_sge) { - ocrdma_err("%s(%d) unsupported recv_sge=0x%x requested\n", - __func__, dev->id, attrs->cap.max_recv_sge); - ocrdma_err("%s(%d) supported recv_sge=0x%x\n", - __func__, dev->id, dev->attr.max_recv_sge); + pr_err("%s(%d) unsupported recv_sge=0x%x requested\n", + __func__, dev->id, attrs->cap.max_recv_sge); + pr_err("%s(%d) supported recv_sge=0x%x\n", + __func__, dev->id, dev->attr.max_recv_sge); return -EINVAL; } /* unprivileged user space cannot create special QP */ if (ibpd->uobject && attrs->qp_type == IB_QPT_GSI) { - ocrdma_err + pr_err ("%s(%d) Userspace can't create special QPs of type=0x%x\n", __func__, dev->id, attrs->qp_type); return -EINVAL; } /* allow creating only one GSI type of QP */ if (attrs->qp_type == IB_QPT_GSI && dev->gsi_qp_created) { - ocrdma_err("%s(%d) GSI special QPs already created.\n", - __func__, dev->id); + pr_err("%s(%d) GSI special QPs already created.\n", + __func__, dev->id); return -EINVAL; } /* verify consumer QPs are not trying to use GSI QP's CQ */ @@ -881,8 +879,8 @@ static int ocrdma_check_qp_params(struct ib_pd *ibpd, struct ocrdma_dev *dev, (dev->gsi_sqcq == get_ocrdma_cq(attrs->recv_cq)) || (dev->gsi_rqcq == get_ocrdma_cq(attrs->send_cq)) || (dev->gsi_rqcq == get_ocrdma_cq(attrs->recv_cq))) { - ocrdma_err("%s(%d) Consumer QP cannot use GSI CQs.\n", - __func__, dev->id); + pr_err("%s(%d) Consumer QP cannot use GSI CQs.\n", + __func__, dev->id); return -EINVAL; } } @@ -934,7 +932,7 @@ static int ocrdma_copy_qp_uresp(struct ocrdma_qp *qp, } status = ib_copy_to_udata(udata, &uresp, sizeof(uresp)); if (status) { - ocrdma_err("%s(%d) user copy error.\n", __func__, dev->id); + pr_err("%s(%d) user copy error.\n", __func__, dev->id); goto err; } status = ocrdma_add_mmap(pd->uctx, uresp.sq_page_addr[0], @@ -1088,7 +1086,7 @@ mbx_err: kfree(qp->wqe_wr_id_tbl); kfree(qp->rqe_wr_id_tbl); kfree(qp); - ocrdma_err("%s(%d) error=%d\n", __func__, dev->id, status); + pr_err("%s(%d) error=%d\n", __func__, dev->id, status); gen_err: return ERR_PTR(status); } @@ -1138,10 +1136,10 @@ int ocrdma_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, spin_unlock_irqrestore(&qp->q_lock, flags); if (!ib_modify_qp_is_ok(old_qps, new_qps, ibqp->qp_type, attr_mask)) { - ocrdma_err("%s(%d) invalid attribute mask=0x%x specified for " - "qpn=0x%x of type=0x%x old_qps=0x%x, new_qps=0x%x\n", - __func__, dev->id, attr_mask, qp->id, ibqp->qp_type, - old_qps, new_qps); + pr_err("%s(%d) invalid attribute mask=0x%x specified for\n" + "qpn=0x%x of type=0x%x old_qps=0x%x, new_qps=0x%x\n", + __func__, dev->id, attr_mask, qp->id, ibqp->qp_type, + old_qps, new_qps); goto param_err; } @@ -1640,9 +1638,9 @@ static int ocrdma_build_inline_sges(struct ocrdma_qp *qp, { if (wr->send_flags & IB_SEND_INLINE) { if (wr->sg_list[0].length > qp->max_inline_data) { - ocrdma_err("%s() supported_len=0x%x," - " unspported len req=0x%x\n", __func__, - qp->max_inline_data, wr->sg_list[0].length); + pr_err("%s() supported_len=0x%x,\n" + " unspported len req=0x%x\n", __func__, + qp->max_inline_data, wr->sg_list[0].length); return -EINVAL; } memcpy(sge, @@ -2057,8 +2055,8 @@ static void ocrdma_update_wc(struct ocrdma_qp *qp, struct ib_wc *ibwc, break; default: ibwc->status = IB_WC_GENERAL_ERR; - ocrdma_err("%s() invalid opcode received = 0x%x\n", - __func__, hdr->cw & OCRDMA_WQE_OPCODE_MASK); + pr_err("%s() invalid opcode received = 0x%x\n", + __func__, hdr->cw & OCRDMA_WQE_OPCODE_MASK); break; }; } From f6ddcf71070d01a7bb34818dd3aaf4bdac5386fa Mon Sep 17 00:00:00 2001 From: Naresh Gottumukkala Date: Mon, 10 Jun 2013 04:42:40 +0000 Subject: [PATCH 0336/1048] RDMA/ocrdma: Set bad_wr in error case Fix post_send to set the bad_wr in error case. Signed-off-by: Naresh Gottumukkala Signed-off-by: Roland Dreier --- drivers/infiniband/hw/ocrdma/ocrdma_verbs.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c index 882a8198d820..06215301a675 100644 --- a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c +++ b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c @@ -1734,12 +1734,14 @@ int ocrdma_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr, spin_lock_irqsave(&qp->q_lock, flags); if (qp->state != OCRDMA_QPS_RTS && qp->state != OCRDMA_QPS_SQD) { spin_unlock_irqrestore(&qp->q_lock, flags); + *bad_wr = wr; return -EINVAL; } while (wr) { if (ocrdma_hwq_free_cnt(&qp->sq) == 0 || wr->num_sge > qp->sq.max_sges) { + *bad_wr = wr; status = -ENOMEM; break; } From df176ea0743fd0fb0514c862797f6bd8c08ab42e Mon Sep 17 00:00:00 2001 From: Naresh Gottumukkala Date: Mon, 10 Jun 2013 04:42:41 +0000 Subject: [PATCH 0337/1048] RDMA/ocrdma: Change macros to inline funtions Signed-off-by: Naresh Gottumukkala Signed-off-by: Roland Dreier --- drivers/infiniband/hw/ocrdma/ocrdma.h | 43 +++++++++++++++++++-- drivers/infiniband/hw/ocrdma/ocrdma_sli.h | 15 ------- drivers/infiniband/hw/ocrdma/ocrdma_verbs.c | 2 +- 3 files changed, 40 insertions(+), 20 deletions(-) diff --git a/drivers/infiniband/hw/ocrdma/ocrdma.h b/drivers/infiniband/hw/ocrdma/ocrdma.h index 9d82d097e25a..7aa7f0f15f8e 100644 --- a/drivers/infiniband/hw/ocrdma/ocrdma.h +++ b/drivers/infiniband/hw/ocrdma/ocrdma.h @@ -290,10 +290,6 @@ struct ocrdma_qp { u8 *ird_q_va; }; -#define OCRDMA_GET_NUM_POSTED_SHIFT_VAL(qp) \ - (((qp->dev->nic_info.dev_family == OCRDMA_GEN2_FAMILY) && \ - (qp->id < 64)) ? 24 : 16) - struct ocrdma_hw_mr { struct ocrdma_dev *dev; u32 lkey; @@ -384,4 +380,43 @@ static inline struct ocrdma_srq *get_ocrdma_srq(struct ib_srq *ibsrq) return container_of(ibsrq, struct ocrdma_srq, ibsrq); } + +static inline int ocrdma_get_num_posted_shift(struct ocrdma_qp *qp) +{ + return ((qp->dev->nic_info.dev_family == OCRDMA_GEN2_FAMILY && + qp->id < 64) ? 24 : 16); +} + +static inline int is_cqe_valid(struct ocrdma_cq *cq, struct ocrdma_cqe *cqe) +{ + int cqe_valid; + cqe_valid = le32_to_cpu(cqe->flags_status_srcqpn) & OCRDMA_CQE_VALID; + return ((cqe_valid == cq->phase) ? 1 : 0); +} + +static inline int is_cqe_for_sq(struct ocrdma_cqe *cqe) +{ + return (le32_to_cpu(cqe->flags_status_srcqpn) & + OCRDMA_CQE_QTYPE) ? 0 : 1; +} + +static inline int is_cqe_invalidated(struct ocrdma_cqe *cqe) +{ + return (le32_to_cpu(cqe->flags_status_srcqpn) & + OCRDMA_CQE_INVALIDATE) ? 1 : 0; +} + +static inline int is_cqe_imm(struct ocrdma_cqe *cqe) +{ + return (le32_to_cpu(cqe->flags_status_srcqpn) & + OCRDMA_CQE_IMM) ? 1 : 0; +} + +static inline int is_cqe_wr_imm(struct ocrdma_cqe *cqe) +{ + return (le32_to_cpu(cqe->flags_status_srcqpn) & + OCRDMA_CQE_WRITE_IMM) ? 1 : 0; +} + + #endif diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_sli.h b/drivers/infiniband/hw/ocrdma/ocrdma_sli.h index cd0512f1fb5b..36b062da2aea 100644 --- a/drivers/infiniband/hw/ocrdma/ocrdma_sli.h +++ b/drivers/infiniband/hw/ocrdma/ocrdma_sli.h @@ -1534,21 +1534,6 @@ struct ocrdma_cqe { u32 flags_status_srcqpn; /* w3 */ } __packed; -#define is_cqe_valid(cq, cqe) \ - (((le32_to_cpu(cqe->flags_status_srcqpn) & OCRDMA_CQE_VALID)\ - == cq->phase) ? 1 : 0) -#define is_cqe_for_sq(cqe) \ - ((le32_to_cpu(cqe->flags_status_srcqpn) & OCRDMA_CQE_QTYPE) ? 0 : 1) -#define is_cqe_for_rq(cqe) \ - ((le32_to_cpu(cqe->flags_status_srcqpn) & OCRDMA_CQE_QTYPE) ? 1 : 0) -#define is_cqe_invalidated(cqe) \ - ((le32_to_cpu(cqe->flags_status_srcqpn) & OCRDMA_CQE_INVALIDATE) ? \ - 1 : 0) -#define is_cqe_imm(cqe) \ - ((le32_to_cpu(cqe->flags_status_srcqpn) & OCRDMA_CQE_IMM) ? 1 : 0) -#define is_cqe_wr_imm(cqe) \ - ((le32_to_cpu(cqe->flags_status_srcqpn) & OCRDMA_CQE_WRITE_IMM) ? 1 : 0) - struct ocrdma_sge { u32 addr_hi; u32 addr_lo; diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c index 06215301a675..dcfbab177faa 100644 --- a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c +++ b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c @@ -1819,7 +1819,7 @@ int ocrdma_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr, static void ocrdma_ring_rq_db(struct ocrdma_qp *qp) { - u32 val = qp->rq.dbid | (1 << OCRDMA_GET_NUM_POSTED_SHIFT_VAL(qp)); + u32 val = qp->rq.dbid | (1 << ocrdma_get_num_posted_shift(qp)); iowrite32(val, qp->rq_db); } From 9884bcdca30ae9f29a0d6af4a4577826b00c5d94 Mon Sep 17 00:00:00 2001 From: Naresh Gottumukkala Date: Mon, 10 Jun 2013 04:42:42 +0000 Subject: [PATCH 0338/1048] RDMA/ocrdma: Reorg structures to avoid padding Reorg structures to better packing to avoid cacheline padding. Signed-off-by: Naresh Gottumukkala Signed-off-by: Roland Dreier --- drivers/infiniband/hw/ocrdma/ocrdma.h | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/drivers/infiniband/hw/ocrdma/ocrdma.h b/drivers/infiniband/hw/ocrdma/ocrdma.h index 7aa7f0f15f8e..d540180a8e42 100644 --- a/drivers/infiniband/hw/ocrdma/ocrdma.h +++ b/drivers/infiniband/hw/ocrdma/ocrdma.h @@ -236,15 +236,16 @@ struct ocrdma_srq { struct ib_srq ibsrq; struct ocrdma_dev *dev; u8 __iomem *db; - /* provide synchronization to multiple context(s) posting rqe */ - spinlock_t q_lock ____cacheline_aligned; - struct ocrdma_qp_hwq_info rq; - struct ocrdma_pd *pd; - u32 id; u64 *rqe_wr_id_tbl; u32 *idx_bit_fields; u32 bit_fields_len; + + /* provide synchronization to multiple context(s) posting rqe */ + spinlock_t q_lock ____cacheline_aligned; + + struct ocrdma_pd *pd; + u32 id; }; struct ocrdma_qp { @@ -252,8 +253,6 @@ struct ocrdma_qp { struct ocrdma_dev *dev; u8 __iomem *sq_db; - /* provide synchronization to multiple context(s) posting wqe, rqe */ - spinlock_t q_lock ____cacheline_aligned; struct ocrdma_qp_hwq_info sq; struct { uint64_t wrid; @@ -263,6 +262,9 @@ struct ocrdma_qp { uint8_t rsvd[3]; } *wqe_wr_id_tbl; u32 max_inline_data; + + /* provide synchronization to multiple context(s) posting wqe, rqe */ + spinlock_t q_lock ____cacheline_aligned; struct ocrdma_cq *sq_cq; /* list maintained per CQ to flush SQ errors */ struct list_head sq_entry; From 3c00ea82c724fab0b98f15428a804cb45eb9ad38 Mon Sep 17 00:00:00 2001 From: Frederic Weisbecker Date: Sun, 19 May 2013 20:45:15 +0200 Subject: [PATCH 0339/1048] watchdog: Rename confusing state variable We have two very conflicting state variable names in the watchdog: * watchdog_enabled: This one reflects the user interface. It's set to 1 by default and can be overriden with boot options or sysctl/procfs interface. * watchdog_disabled: This is the internal toggle state that tells if watchdog threads, timers and NMI events are currently running or not. This state mostly depends on the user settings. It's a convenient state latch. Now we really need to find clearer names because those are just too confusing to encourage deep review. watchdog_enabled now becomes watchdog_user_enabled to reflect its purpose as an interface. watchdog_disabled becomes watchdog_running to suggest its role as a pure internal state. Signed-off-by: Frederic Weisbecker Cc: Srivatsa S. Bhat Cc: Anish Singh Cc: Steven Rostedt Cc: Paul E. McKenney Cc: Ingo Molnar Cc: Thomas Gleixner Cc: Peter Zijlstra Cc: Borislav Petkov Cc: Li Zhong Cc: Don Zickus --- include/linux/nmi.h | 2 +- kernel/sysctl.c | 4 ++-- kernel/watchdog.c | 30 +++++++++++++++--------------- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/include/linux/nmi.h b/include/linux/nmi.h index db50840e6355..6a45fb583ff1 100644 --- a/include/linux/nmi.h +++ b/include/linux/nmi.h @@ -46,7 +46,7 @@ static inline bool trigger_all_cpu_backtrace(void) #ifdef CONFIG_LOCKUP_DETECTOR int hw_nmi_is_cpu_stuck(struct pt_regs *); u64 hw_nmi_get_sample_period(int watchdog_thresh); -extern int watchdog_enabled; +extern int watchdog_user_enabled; extern int watchdog_thresh; struct ctl_table; extern int proc_dowatchdog(struct ctl_table *, int , diff --git a/kernel/sysctl.c b/kernel/sysctl.c index 9edcf456e0fc..b0805652c4ff 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -801,7 +801,7 @@ static struct ctl_table kern_table[] = { #if defined(CONFIG_LOCKUP_DETECTOR) { .procname = "watchdog", - .data = &watchdog_enabled, + .data = &watchdog_user_enabled, .maxlen = sizeof (int), .mode = 0644, .proc_handler = proc_dowatchdog, @@ -828,7 +828,7 @@ static struct ctl_table kern_table[] = { }, { .procname = "nmi_watchdog", - .data = &watchdog_enabled, + .data = &watchdog_user_enabled, .maxlen = sizeof (int), .mode = 0644, .proc_handler = proc_dowatchdog, diff --git a/kernel/watchdog.c b/kernel/watchdog.c index 52c9a9b91bdd..51c4f34d258e 100644 --- a/kernel/watchdog.c +++ b/kernel/watchdog.c @@ -29,9 +29,9 @@ #include #include -int watchdog_enabled = 1; +int watchdog_user_enabled = 1; int __read_mostly watchdog_thresh = 10; -static int __read_mostly watchdog_disabled = 1; +static int __read_mostly watchdog_running; static u64 __read_mostly sample_period; static DEFINE_PER_CPU(unsigned long, watchdog_touch_ts); @@ -63,7 +63,7 @@ static int __init hardlockup_panic_setup(char *str) else if (!strncmp(str, "nopanic", 7)) hardlockup_panic = 0; else if (!strncmp(str, "0", 1)) - watchdog_enabled = 0; + watchdog_user_enabled = 0; return 1; } __setup("nmi_watchdog=", hardlockup_panic_setup); @@ -82,7 +82,7 @@ __setup("softlockup_panic=", softlockup_panic_setup); static int __init nowatchdog_setup(char *str) { - watchdog_enabled = 0; + watchdog_user_enabled = 0; return 1; } __setup("nowatchdog", nowatchdog_setup); @@ -90,7 +90,7 @@ __setup("nowatchdog", nowatchdog_setup); /* deprecated */ static int __init nosoftlockup_setup(char *str) { - watchdog_enabled = 0; + watchdog_user_enabled = 0; return 1; } __setup("nosoftlockup", nosoftlockup_setup); @@ -158,7 +158,7 @@ void touch_all_softlockup_watchdogs(void) #ifdef CONFIG_HARDLOCKUP_DETECTOR void touch_nmi_watchdog(void) { - if (watchdog_enabled) { + if (watchdog_user_enabled) { unsigned cpu; for_each_present_cpu(cpu) { @@ -490,12 +490,12 @@ static int watchdog_enable_all_cpus(void) { int err = 0; - if (watchdog_disabled) { + if (!watchdog_running) { err = smpboot_register_percpu_thread(&watchdog_threads); if (err) pr_err("Failed to create watchdog threads, disabled\n"); else - watchdog_disabled = 0; + watchdog_running = 1; } return err; @@ -506,8 +506,8 @@ static int watchdog_enable_all_cpus(void) #ifdef CONFIG_SYSCTL static void watchdog_disable_all_cpus(void) { - if (!watchdog_disabled) { - watchdog_disabled = 1; + if (watchdog_running) { + watchdog_running = 0; smpboot_unregister_percpu_thread(&watchdog_threads); } } @@ -522,7 +522,7 @@ int proc_dowatchdog(struct ctl_table *table, int write, int err, old_thresh, old_enabled; old_thresh = ACCESS_ONCE(watchdog_thresh); - old_enabled = ACCESS_ONCE(watchdog_enabled); + old_enabled = ACCESS_ONCE(watchdog_user_enabled); err = proc_dointvec_minmax(table, write, buffer, lenp, ppos); if (err || !write) @@ -531,10 +531,10 @@ int proc_dowatchdog(struct ctl_table *table, int write, set_sample_period(); /* * Watchdog threads shouldn't be enabled if they are - * disabled. The 'watchdog_disabled' variable check in + * disabled. The 'watchdog_running' variable check in * watchdog_*_all_cpus() function takes care of this. */ - if (watchdog_enabled && watchdog_thresh) + if (watchdog_user_enabled && watchdog_thresh) err = watchdog_enable_all_cpus(); else watchdog_disable_all_cpus(); @@ -542,7 +542,7 @@ int proc_dowatchdog(struct ctl_table *table, int write, /* Restore old values on failure */ if (err) { watchdog_thresh = old_thresh; - watchdog_enabled = old_enabled; + watchdog_user_enabled = old_enabled; } return err; @@ -553,6 +553,6 @@ void __init lockup_detector_init(void) { set_sample_period(); - if (watchdog_enabled) + if (watchdog_user_enabled) watchdog_enable_all_cpus(); } From 940be35ac0139530d7554aa2352a8388e3d4adca Mon Sep 17 00:00:00 2001 From: Frederic Weisbecker Date: Fri, 7 Jun 2013 13:35:42 +0200 Subject: [PATCH 0340/1048] watchdog: Boot-disable by default on full dynticks When the watchdog runs, it prevents the full dynticks CPUs from stopping their tick because the hard lockup detector uses perf events internally, which in turn rely on the periodic tick. Since this is a rather confusing behaviour that is not easy to track down and identify for those who want to test CONFIG_NO_HZ_FULL, let's default disable the watchdog on boot time when full dynticks is enabled. The user can still enable it later on runtime using proc or sysctl. Reported-by: Steven Rostedt Suggested-by: Peter Zijlstra Signed-off-by: Frederic Weisbecker Cc: Steven Rostedt Cc: Paul E. McKenney Cc: Ingo Molnar Cc: Andrew Morton Cc: Thomas Gleixner Cc: Peter Zijlstra Cc: Li Zhong Cc: Don Zickus Cc: Srivatsa S. Bhat Cc: Anish Singh --- kernel/watchdog.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/kernel/watchdog.c b/kernel/watchdog.c index 51c4f34d258e..1241d8c91d5e 100644 --- a/kernel/watchdog.c +++ b/kernel/watchdog.c @@ -553,6 +553,14 @@ void __init lockup_detector_init(void) { set_sample_period(); +#ifdef CONFIG_NO_HZ_FULL + if (watchdog_user_enabled) { + watchdog_user_enabled = 0; + pr_warning("Disabled lockup detectors by default for full dynticks\n"); + pr_warning("You can reactivate it with 'sysctl -w kernel.watchdog=1'\n"); + } +#endif + if (watchdog_user_enabled) watchdog_enable_all_cpus(); } From 5b8621a68fdcd2baf1d3b413726f913a5254d46a Mon Sep 17 00:00:00 2001 From: Frederic Weisbecker Date: Sat, 8 Jun 2013 13:47:31 +0200 Subject: [PATCH 0341/1048] nohz: Remove obsolete check for full dynticks CPUs to be RCU nocbs Building full dynticks now implies that all CPUs are forced into RCU nocb mode through CONFIG_RCU_NOCB_CPU_ALL. The dynamic check has become useless. Signed-off-by: Frederic Weisbecker Cc: Steven Rostedt Cc: Paul E. McKenney Cc: Ingo Molnar Cc: Andrew Morton Cc: Thomas Gleixner Cc: Peter Zijlstra Cc: Li Zhong Cc: Borislav Petkov --- kernel/time/tick-sched.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c index d87d22cb9bf2..b15750139260 100644 --- a/kernel/time/tick-sched.c +++ b/kernel/time/tick-sched.c @@ -351,16 +351,6 @@ void __init tick_nohz_init(void) } cpu_notifier(tick_nohz_cpu_down_callback, 0); - - /* Make sure full dynticks CPU are also RCU nocbs */ - for_each_cpu(cpu, nohz_full_mask) { - if (!rcu_is_nocb_cpu(cpu)) { - pr_warning("NO_HZ: CPU %d is not RCU nocb: " - "cleared from nohz_full range", cpu); - cpumask_clear_cpu(cpu, nohz_full_mask); - } - } - cpulist_scnprintf(nohz_full_buf, sizeof(nohz_full_buf), nohz_full_mask); pr_info("NO_HZ: Full dynticks CPUs: %s.\n", nohz_full_buf); } From 68651ff6373421fff7452a0fdeed589801a26b6d Mon Sep 17 00:00:00 2001 From: Ralf Baechle Date: Thu, 13 Jun 2013 02:26:34 +0200 Subject: [PATCH 0342/1048] MIPS: Octeon: Fix build error if CONFIG_MTD=n Signed-off-by: Ralf Baechle --- arch/mips/cavium-octeon/Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/mips/cavium-octeon/Makefile b/arch/mips/cavium-octeon/Makefile index 3595affb9772..e3fd50cc709c 100644 --- a/arch/mips/cavium-octeon/Makefile +++ b/arch/mips/cavium-octeon/Makefile @@ -13,10 +13,11 @@ CFLAGS_octeon-platform.o = -I$(src)/../../../scripts/dtc/libfdt CFLAGS_setup.o = -I$(src)/../../../scripts/dtc/libfdt obj-y := cpu.o setup.o serial.o octeon-platform.o octeon-irq.o csrc-octeon.o -obj-y += dma-octeon.o flash_setup.o +obj-y += dma-octeon.o obj-y += octeon-memcpy.o obj-y += executive/ +obj-$(CONFIG_MTD) += flash_setup.o obj-$(CONFIG_SMP) += smp.o obj-$(CONFIG_OCTEON_ILM) += oct_ilm.o From 27f62b9f294b7e2019c94c385abda43a0af6bb8b Mon Sep 17 00:00:00 2001 From: Ralf Baechle Date: Thu, 13 Jun 2013 02:45:53 +0200 Subject: [PATCH 0343/1048] RAPIDIO: IDT_GEN2: Fix build error. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CC drivers/rapidio/switches/idt_gen2.o drivers/rapidio/switches/idt_gen2.c: In function ‘idtg2_show_errlog’: drivers/rapidio/switches/idt_gen2.c:379:30: error: ‘PAGE_SIZE’ undeclared (first use in this function) drivers/rapidio/switches/idt_gen2.c:379:30: note: each undeclared identifier is reported only once for each function it appears in Signed-off-by: Ralf Baechle Acked-by: Alexandre Bounine --- drivers/rapidio/switches/idt_gen2.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/rapidio/switches/idt_gen2.c b/drivers/rapidio/switches/idt_gen2.c index 809b7a3336ba..5d3b0f014d35 100644 --- a/drivers/rapidio/switches/idt_gen2.c +++ b/drivers/rapidio/switches/idt_gen2.c @@ -15,6 +15,8 @@ #include #include #include + +#include #include "../rio.h" #define LOCAL_RTE_CONF_DESTID_SEL 0x010070 From 8d36eb01da5d371feffa280e501377b5c450f5a5 Mon Sep 17 00:00:00 2001 From: Sean Hefty Date: Wed, 29 May 2013 10:09:07 -0700 Subject: [PATCH 0344/1048] RDMA/cma: Define native IB address Define AF_IB and sockaddr_ib to allow the rdma_cm to use native IB addressing. Signed-off-by: Sean Hefty Signed-off-by: Roland Dreier --- include/linux/socket.h | 2 + include/rdma/ib.h | 89 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 91 insertions(+) create mode 100644 include/rdma/ib.h diff --git a/include/linux/socket.h b/include/linux/socket.h index b10ce4b341ea..230c04bda3e2 100644 --- a/include/linux/socket.h +++ b/include/linux/socket.h @@ -167,6 +167,7 @@ struct ucred { #define AF_PPPOX 24 /* PPPoX sockets */ #define AF_WANPIPE 25 /* Wanpipe API Sockets */ #define AF_LLC 26 /* Linux LLC */ +#define AF_IB 27 /* Native InfiniBand address */ #define AF_CAN 29 /* Controller Area Network */ #define AF_TIPC 30 /* TIPC sockets */ #define AF_BLUETOOTH 31 /* Bluetooth sockets */ @@ -211,6 +212,7 @@ struct ucred { #define PF_PPPOX AF_PPPOX #define PF_WANPIPE AF_WANPIPE #define PF_LLC AF_LLC +#define PF_IB AF_IB #define PF_CAN AF_CAN #define PF_TIPC AF_TIPC #define PF_BLUETOOTH AF_BLUETOOTH diff --git a/include/rdma/ib.h b/include/rdma/ib.h new file mode 100644 index 000000000000..cf8f9e700e48 --- /dev/null +++ b/include/rdma/ib.h @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2010 Intel Corporation. All rights reserved. + * + * This software is available to you under a choice of one of two + * licenses. You may choose to be licensed under the terms of the GNU + * General Public License (GPL) Version 2, available from the file + * COPYING in the main directory of this source tree, or the + * OpenIB.org BSD license below: + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#if !defined(_RDMA_IB_H) +#define _RDMA_IB_H + +#include + +struct ib_addr { + union { + __u8 uib_addr8[16]; + __be16 uib_addr16[8]; + __be32 uib_addr32[4]; + __be64 uib_addr64[2]; + } ib_u; +#define sib_addr8 ib_u.uib_addr8 +#define sib_addr16 ib_u.uib_addr16 +#define sib_addr32 ib_u.uib_addr32 +#define sib_addr64 ib_u.uib_addr64 +#define sib_raw ib_u.uib_addr8 +#define sib_subnet_prefix ib_u.uib_addr64[0] +#define sib_interface_id ib_u.uib_addr64[1] +}; + +static inline int ib_addr_any(const struct ib_addr *a) +{ + return ((a->sib_addr64[0] | a->sib_addr64[1]) == 0); +} + +static inline int ib_addr_loopback(const struct ib_addr *a) +{ + return ((a->sib_addr32[0] | a->sib_addr32[1] | + a->sib_addr32[2] | (a->sib_addr32[3] ^ htonl(1))) == 0); +} + +static inline void ib_addr_set(struct ib_addr *addr, + __be32 w1, __be32 w2, __be32 w3, __be32 w4) +{ + addr->sib_addr32[0] = w1; + addr->sib_addr32[1] = w2; + addr->sib_addr32[2] = w3; + addr->sib_addr32[3] = w4; +} + +static inline int ib_addr_cmp(const struct ib_addr *a1, const struct ib_addr *a2) +{ + return memcmp(a1, a2, sizeof(struct ib_addr)); +} + +struct sockaddr_ib { + unsigned short int sib_family; /* AF_IB */ + __be16 sib_pkey; + __be32 sib_flowinfo; + struct ib_addr sib_addr; + __be64 sib_sid; + __be64 sib_sid_mask; + __u64 sib_scope_id; +}; + +#endif /* _RDMA_IB_H */ From c8dea2f9f078395ebac7c92aeb919f02ff3fca88 Mon Sep 17 00:00:00 2001 From: Sean Hefty Date: Wed, 29 May 2013 10:09:08 -0700 Subject: [PATCH 0345/1048] RDMA/cma: Allow enabling reuseaddr in any state The rdma_cm only allows setting reuseaddr if the corresponding rdma_cm_id is in the idle state. Allow setting this value in other states. This brings the behavior more inline with sockets. Signed-off-by: Sean Hefty Signed-off-by: Roland Dreier --- drivers/infiniband/core/cma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c index 34fbc2f60a09..fde428bd2dad 100644 --- a/drivers/infiniband/core/cma.c +++ b/drivers/infiniband/core/cma.c @@ -2097,7 +2097,7 @@ int rdma_set_reuseaddr(struct rdma_cm_id *id, int reuse) id_priv = container_of(id, struct rdma_id_private, id); spin_lock_irqsave(&id_priv->lock, flags); - if (id_priv->state == RDMA_CM_IDLE) { + if (reuse || id_priv->state == RDMA_CM_IDLE) { id_priv->reuseaddr = reuse; ret = 0; } else { From 2e2d190c5eb05d5a2615f4092e5fe821710404f9 Mon Sep 17 00:00:00 2001 From: Sean Hefty Date: Wed, 29 May 2013 10:09:09 -0700 Subject: [PATCH 0346/1048] RDMA/cma: Include AF_IB in loopback and any address checks Enhance checks for loopback and any address to support AF_IB in addition to AF_INET and AF_INT6. This will allow future patches to use AF_IB when binding and resolving addresses. Signed-off-by: Sean Hefty Signed-off-by: Roland Dreier --- drivers/infiniband/core/cma.c | 40 +++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c index fde428bd2dad..22a23a73745e 100644 --- a/drivers/infiniband/core/cma.c +++ b/drivers/infiniband/core/cma.c @@ -50,6 +50,7 @@ #include #include #include +#include #include #include #include @@ -679,26 +680,30 @@ EXPORT_SYMBOL(rdma_init_qp_attr); static inline int cma_zero_addr(struct sockaddr *addr) { - struct in6_addr *ip6; - - if (addr->sa_family == AF_INET) - return ipv4_is_zeronet( - ((struct sockaddr_in *)addr)->sin_addr.s_addr); - else { - ip6 = &((struct sockaddr_in6 *) addr)->sin6_addr; - return (ip6->s6_addr32[0] | ip6->s6_addr32[1] | - ip6->s6_addr32[2] | ip6->s6_addr32[3]) == 0; + switch (addr->sa_family) { + case AF_INET: + return ipv4_is_zeronet(((struct sockaddr_in *)addr)->sin_addr.s_addr); + case AF_INET6: + return ipv6_addr_any(&((struct sockaddr_in6 *) addr)->sin6_addr); + case AF_IB: + return ib_addr_any(&((struct sockaddr_ib *) addr)->sib_addr); + default: + return 0; } } static inline int cma_loopback_addr(struct sockaddr *addr) { - if (addr->sa_family == AF_INET) - return ipv4_is_loopback( - ((struct sockaddr_in *) addr)->sin_addr.s_addr); - else - return ipv6_addr_loopback( - &((struct sockaddr_in6 *) addr)->sin6_addr); + switch (addr->sa_family) { + case AF_INET: + return ipv4_is_loopback(((struct sockaddr_in *) addr)->sin_addr.s_addr); + case AF_INET6: + return ipv6_addr_loopback(&((struct sockaddr_in6 *) addr)->sin6_addr); + case AF_IB: + return ib_addr_loopback(&((struct sockaddr_ib *) addr)->sib_addr); + default: + return 0; + } } static inline int cma_any_addr(struct sockaddr *addr) @@ -715,9 +720,12 @@ static int cma_addr_cmp(struct sockaddr *src, struct sockaddr *dst) case AF_INET: return ((struct sockaddr_in *) src)->sin_addr.s_addr != ((struct sockaddr_in *) dst)->sin_addr.s_addr; - default: + case AF_INET6: return ipv6_addr_cmp(&((struct sockaddr_in6 *) src)->sin6_addr, &((struct sockaddr_in6 *) dst)->sin6_addr); + default: + return ib_addr_cmp(&((struct sockaddr_ib *) src)->sib_addr, + &((struct sockaddr_ib *) dst)->sib_addr); } } From ef560861c01c301cde3da154eb9c1c2619924c3a Mon Sep 17 00:00:00 2001 From: Sean Hefty Date: Wed, 29 May 2013 10:09:10 -0700 Subject: [PATCH 0347/1048] IB/addr: Add AF_IB support to ip_addr_size Add support for AF_IB to ip_addr_size, and rename the function to account for the change. Give the compiler more control over whether the call should be inline or not by moving the definition into the .c file, removing the static inline, and exporting it. Signed-off-by: Sean Hefty Signed-off-by: Roland Dreier --- drivers/infiniband/core/addr.c | 20 ++++++++++++++++++-- drivers/infiniband/core/cma.c | 12 ++++++------ include/rdma/ib_addr.h | 6 +----- 3 files changed, 25 insertions(+), 13 deletions(-) diff --git a/drivers/infiniband/core/addr.c b/drivers/infiniband/core/addr.c index eaec8d7a3b73..e90f2b2eabd7 100644 --- a/drivers/infiniband/core/addr.c +++ b/drivers/infiniband/core/addr.c @@ -45,6 +45,7 @@ #include #include #include +#include MODULE_AUTHOR("Sean Hefty"); MODULE_DESCRIPTION("IB Address Translation"); @@ -70,6 +71,21 @@ static LIST_HEAD(req_list); static DECLARE_DELAYED_WORK(work, process_req); static struct workqueue_struct *addr_wq; +int rdma_addr_size(struct sockaddr *addr) +{ + switch (addr->sa_family) { + case AF_INET: + return sizeof(struct sockaddr_in); + case AF_INET6: + return sizeof(struct sockaddr_in6); + case AF_IB: + return sizeof(struct sockaddr_ib); + default: + return 0; + } +} +EXPORT_SYMBOL(rdma_addr_size); + void rdma_addr_register_client(struct rdma_addr_client *client) { atomic_set(&client->refcount, 1); @@ -369,12 +385,12 @@ int rdma_resolve_ip(struct rdma_addr_client *client, goto err; } - memcpy(src_in, src_addr, ip_addr_size(src_addr)); + memcpy(src_in, src_addr, rdma_addr_size(src_addr)); } else { src_in->sa_family = dst_addr->sa_family; } - memcpy(dst_in, dst_addr, ip_addr_size(dst_addr)); + memcpy(dst_in, dst_addr, rdma_addr_size(dst_addr)); req->addr = addr; req->callback = callback; req->context = context; diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c index 22a23a73745e..2b1041c5844c 100644 --- a/drivers/infiniband/core/cma.c +++ b/drivers/infiniband/core/cma.c @@ -1584,7 +1584,7 @@ static void cma_listen_on_dev(struct rdma_id_private *id_priv, dev_id_priv->state = RDMA_CM_ADDR_BOUND; memcpy(&id->route.addr.src_addr, &id_priv->id.route.addr.src_addr, - ip_addr_size((struct sockaddr *) &id_priv->id.route.addr.src_addr)); + rdma_addr_size((struct sockaddr *) &id_priv->id.route.addr.src_addr)); cma_attach_to_dev(dev_id_priv, cma_dev); list_add_tail(&dev_id_priv->listen_list, &id_priv->listen_list); @@ -1989,7 +1989,7 @@ static void addr_handler(int status, struct sockaddr *src_addr, event.status = status; } else { memcpy(&id_priv->id.route.addr.src_addr, src_addr, - ip_addr_size(src_addr)); + rdma_addr_size(src_addr)); event.event = RDMA_CM_EVENT_ADDR_RESOLVED; } @@ -2079,7 +2079,7 @@ int rdma_resolve_addr(struct rdma_cm_id *id, struct sockaddr *src_addr, return -EINVAL; atomic_inc(&id_priv->refcount); - memcpy(&id->route.addr.dst_addr, dst_addr, ip_addr_size(dst_addr)); + memcpy(&id->route.addr.dst_addr, dst_addr, rdma_addr_size(dst_addr)); if (cma_any_addr(dst_addr)) ret = cma_resolve_loopback(id_priv); else @@ -2399,7 +2399,7 @@ int rdma_bind_addr(struct rdma_cm_id *id, struct sockaddr *addr) goto err1; } - memcpy(&id->route.addr.src_addr, addr, ip_addr_size(addr)); + memcpy(&id->route.addr.src_addr, addr, rdma_addr_size(addr)); if (!(id_priv->options & (1 << CMA_OPTION_AFONLY))) { if (addr->sa_family == AF_INET) id_priv->afonly = 1; @@ -3178,7 +3178,7 @@ int rdma_join_multicast(struct rdma_cm_id *id, struct sockaddr *addr, if (!mc) return -ENOMEM; - memcpy(&mc->addr, addr, ip_addr_size(addr)); + memcpy(&mc->addr, addr, rdma_addr_size(addr)); mc->context = context; mc->id_priv = id_priv; @@ -3223,7 +3223,7 @@ void rdma_leave_multicast(struct rdma_cm_id *id, struct sockaddr *addr) id_priv = container_of(id, struct rdma_id_private, id); spin_lock_irq(&id_priv->lock); list_for_each_entry(mc, &id_priv->mc_list, list) { - if (!memcmp(&mc->addr, addr, ip_addr_size(addr))) { + if (!memcmp(&mc->addr, addr, rdma_addr_size(addr))) { list_del(&mc->list); spin_unlock_irq(&id_priv->lock); diff --git a/include/rdma/ib_addr.h b/include/rdma/ib_addr.h index 99965395c5f3..f3ac0f2c4c66 100644 --- a/include/rdma/ib_addr.h +++ b/include/rdma/ib_addr.h @@ -102,11 +102,7 @@ void rdma_addr_cancel(struct rdma_dev_addr *addr); int rdma_copy_addr(struct rdma_dev_addr *dev_addr, struct net_device *dev, const unsigned char *dst_dev_addr); -static inline int ip_addr_size(struct sockaddr *addr) -{ - return addr->sa_family == AF_INET6 ? - sizeof(struct sockaddr_in6) : sizeof(struct sockaddr_in); -} +int rdma_addr_size(struct sockaddr *addr); static inline u16 ib_addr_get_pkey(struct rdma_dev_addr *dev_addr) { From 58afdcb7382234ebd780e43b17edde92a5853cca Mon Sep 17 00:00:00 2001 From: Sean Hefty Date: Wed, 29 May 2013 10:09:11 -0700 Subject: [PATCH 0348/1048] RDMA/cma: Update port reservation to support AF_IB The AF_IB uses a 64-bit service id (SID), which the user can control through the use of a mask. The rdma_cm will assign values to the unmasked portions of the SID based on the selected port space and port number. Because the IB spec divides the SID range into several regions, a SID/mask combination may fall into one of the existing port space ranges as defined by the RDMA CM IP Annex. Map the AF_IB SID to the correct RDMA port space. Signed-off-by: Sean Hefty Signed-off-by: Roland Dreier --- drivers/infiniband/core/cma.c | 113 ++++++++++++++++++++++++++-------- include/rdma/rdma_cm.h | 5 ++ 2 files changed, 94 insertions(+), 24 deletions(-) diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c index 2b1041c5844c..8465c6adaddb 100644 --- a/drivers/infiniband/core/cma.c +++ b/drivers/infiniband/core/cma.c @@ -729,12 +729,22 @@ static int cma_addr_cmp(struct sockaddr *src, struct sockaddr *dst) } } -static inline __be16 cma_port(struct sockaddr *addr) +static __be16 cma_port(struct sockaddr *addr) { - if (addr->sa_family == AF_INET) + struct sockaddr_ib *sib; + + switch (addr->sa_family) { + case AF_INET: return ((struct sockaddr_in *) addr)->sin_port; - else + case AF_INET6: return ((struct sockaddr_in6 *) addr)->sin6_port; + case AF_IB: + sib = (struct sockaddr_ib *) addr; + return htons((u16) (be64_to_cpu(sib->sib_sid) & + be64_to_cpu(sib->sib_sid_mask))); + default: + return 0; + } } static inline int cma_any_port(struct sockaddr *addr) @@ -2139,10 +2149,29 @@ EXPORT_SYMBOL(rdma_set_afonly); static void cma_bind_port(struct rdma_bind_list *bind_list, struct rdma_id_private *id_priv) { - struct sockaddr_in *sin; + struct sockaddr *addr; + struct sockaddr_ib *sib; + u64 sid, mask; + __be16 port; - sin = (struct sockaddr_in *) &id_priv->id.route.addr.src_addr; - sin->sin_port = htons(bind_list->port); + addr = (struct sockaddr *) &id_priv->id.route.addr.src_addr; + port = htons(bind_list->port); + + switch (addr->sa_family) { + case AF_INET: + ((struct sockaddr_in *) addr)->sin_port = port; + break; + case AF_INET6: + ((struct sockaddr_in6 *) addr)->sin6_port = port; + break; + case AF_IB: + sib = (struct sockaddr_ib *) addr; + sid = be64_to_cpu(sib->sib_sid); + mask = be64_to_cpu(sib->sib_sid_mask); + sib->sib_sid = cpu_to_be64((sid & mask) | (u64) ntohs(port)); + sib->sib_sid_mask = cpu_to_be64(~0ULL); + break; + } id_priv->bind_list = bind_list; hlist_add_head(&id_priv->node, &bind_list->owners); } @@ -2269,30 +2298,66 @@ static int cma_bind_listen(struct rdma_id_private *id_priv) return ret; } +static struct idr *cma_select_inet_ps(struct rdma_id_private *id_priv) +{ + switch (id_priv->id.ps) { + case RDMA_PS_SDP: + return &sdp_ps; + case RDMA_PS_TCP: + return &tcp_ps; + case RDMA_PS_UDP: + return &udp_ps; + case RDMA_PS_IPOIB: + return &ipoib_ps; + case RDMA_PS_IB: + return &ib_ps; + default: + return NULL; + } +} + +static struct idr *cma_select_ib_ps(struct rdma_id_private *id_priv) +{ + struct idr *ps = NULL; + struct sockaddr_ib *sib; + u64 sid_ps, mask, sid; + + sib = (struct sockaddr_ib *) &id_priv->id.route.addr.src_addr; + mask = be64_to_cpu(sib->sib_sid_mask) & RDMA_IB_IP_PS_MASK; + sid = be64_to_cpu(sib->sib_sid) & mask; + + if ((id_priv->id.ps == RDMA_PS_IB) && (sid == (RDMA_IB_IP_PS_IB & mask))) { + sid_ps = RDMA_IB_IP_PS_IB; + ps = &ib_ps; + } else if (((id_priv->id.ps == RDMA_PS_IB) || (id_priv->id.ps == RDMA_PS_TCP)) && + (sid == (RDMA_IB_IP_PS_TCP & mask))) { + sid_ps = RDMA_IB_IP_PS_TCP; + ps = &tcp_ps; + } else if (((id_priv->id.ps == RDMA_PS_IB) || (id_priv->id.ps == RDMA_PS_UDP)) && + (sid == (RDMA_IB_IP_PS_UDP & mask))) { + sid_ps = RDMA_IB_IP_PS_UDP; + ps = &udp_ps; + } + + if (ps) { + sib->sib_sid = cpu_to_be64(sid_ps | ntohs(cma_port((struct sockaddr *) sib))); + sib->sib_sid_mask = cpu_to_be64(RDMA_IB_IP_PS_MASK | + be64_to_cpu(sib->sib_sid_mask)); + } + return ps; +} + static int cma_get_port(struct rdma_id_private *id_priv) { struct idr *ps; int ret; - switch (id_priv->id.ps) { - case RDMA_PS_SDP: - ps = &sdp_ps; - break; - case RDMA_PS_TCP: - ps = &tcp_ps; - break; - case RDMA_PS_UDP: - ps = &udp_ps; - break; - case RDMA_PS_IPOIB: - ps = &ipoib_ps; - break; - case RDMA_PS_IB: - ps = &ib_ps; - break; - default: + if (id_priv->id.route.addr.src_addr.ss_family != AF_IB) + ps = cma_select_inet_ps(id_priv); + else + ps = cma_select_ib_ps(id_priv); + if (!ps) return -EPROTONOSUPPORT; - } mutex_lock(&lock); if (cma_any_port((struct sockaddr *) &id_priv->id.route.addr.src_addr)) diff --git a/include/rdma/rdma_cm.h b/include/rdma/rdma_cm.h index ad3a3142383a..1e6c3c7af898 100644 --- a/include/rdma/rdma_cm.h +++ b/include/rdma/rdma_cm.h @@ -70,6 +70,11 @@ enum rdma_port_space { RDMA_PS_UDP = 0x0111, }; +#define RDMA_IB_IP_PS_MASK 0xFFFFFFFFFFFF0000ULL +#define RDMA_IB_IP_PS_TCP 0x0000000001060000ULL +#define RDMA_IB_IP_PS_UDP 0x0000000001110000ULL +#define RDMA_IB_IP_PS_IB 0x00000000013F0000ULL + struct rdma_addr { struct sockaddr_storage src_addr; struct sockaddr_storage dst_addr; From 680f920a2e24725e694d9958a08226384750217b Mon Sep 17 00:00:00 2001 From: Sean Hefty Date: Wed, 29 May 2013 10:09:12 -0700 Subject: [PATCH 0349/1048] RDMA/cma: Allow user to specify AF_IB when binding Modify rdma_bind_addr to allow the user to specify AF_IB when binding to a device. AF_IB indicates that the user is not mapping an IP address to the native IB addressing. (The mapping may have already been done, or is not needed) Signed-off-by: Sean Hefty Signed-off-by: Roland Dreier --- drivers/infiniband/core/cma.c | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c index 8465c6adaddb..1e9f3115ee91 100644 --- a/drivers/infiniband/core/cma.c +++ b/drivers/infiniband/core/cma.c @@ -359,6 +359,27 @@ static int find_gid_port(struct ib_device *device, union ib_gid *gid, u8 port_nu return -EADDRNOTAVAIL; } +static void cma_translate_ib(struct sockaddr_ib *sib, struct rdma_dev_addr *dev_addr) +{ + dev_addr->dev_type = ARPHRD_INFINIBAND; + rdma_addr_set_sgid(dev_addr, (union ib_gid *) &sib->sib_addr); + ib_addr_set_pkey(dev_addr, ntohs(sib->sib_pkey)); +} + +static int cma_translate_addr(struct sockaddr *addr, struct rdma_dev_addr *dev_addr) +{ + int ret; + + if (addr->sa_family != AF_IB) { + ret = rdma_translate_ip(addr, dev_addr); + } else { + cma_translate_ib((struct sockaddr_ib *) addr, dev_addr); + ret = 0; + } + + return ret; +} + static int cma_acquire_dev(struct rdma_id_private *id_priv) { struct rdma_dev_addr *dev_addr = &id_priv->id.route.addr.dev_addr; @@ -1136,8 +1157,8 @@ static struct rdma_id_private *cma_new_conn_id(struct rdma_cm_id *listen_id, rdma_addr_set_sgid(&rt->addr.dev_addr, &rt->path_rec[0].sgid); ib_addr_set_pkey(&rt->addr.dev_addr, be16_to_cpu(rt->path_rec[0].pkey)); } else { - ret = rdma_translate_ip((struct sockaddr *) &rt->addr.src_addr, - &rt->addr.dev_addr); + ret = cma_translate_addr((struct sockaddr *) &rt->addr.src_addr, + &rt->addr.dev_addr); if (ret) goto err; } @@ -1176,8 +1197,8 @@ static struct rdma_id_private *cma_new_udp_id(struct rdma_cm_id *listen_id, ip_ver, port, src, dst); if (!cma_any_addr((struct sockaddr *) &id->route.addr.src_addr)) { - ret = rdma_translate_ip((struct sockaddr *) &id->route.addr.src_addr, - &id->route.addr.dev_addr); + ret = cma_translate_addr((struct sockaddr *) &id->route.addr.src_addr, + &id->route.addr.dev_addr); if (ret) goto err; } @@ -2443,7 +2464,8 @@ int rdma_bind_addr(struct rdma_cm_id *id, struct sockaddr *addr) struct rdma_id_private *id_priv; int ret; - if (addr->sa_family != AF_INET && addr->sa_family != AF_INET6) + if (addr->sa_family != AF_INET && addr->sa_family != AF_INET6 && + addr->sa_family != AF_IB) return -EAFNOSUPPORT; id_priv = container_of(id, struct rdma_id_private, id); @@ -2455,7 +2477,7 @@ int rdma_bind_addr(struct rdma_cm_id *id, struct sockaddr *addr) goto err1; if (!cma_any_addr(addr)) { - ret = rdma_translate_ip(addr, &id->route.addr.dev_addr); + ret = cma_translate_addr(addr, &id->route.addr.dev_addr); if (ret) goto err1; From 6a3e362d3ce60d6a9f634572486c2c21a4ccfe69 Mon Sep 17 00:00:00 2001 From: Sean Hefty Date: Wed, 29 May 2013 10:09:13 -0700 Subject: [PATCH 0350/1048] RDMA/cma: Do not modify sa_family when setting loopback address cma_resolve_loopback is called after an rdma_cm_id has been bound to a specific sa_family and port. Once the source sa_family for the id has been set, do not modify it. Only the actual IP address portion of the source address needs to be set. As part of this fix, we can simplify setting the source address by moving the loopback address assignment from cma_resolve_loopback to cma_bind_loopback. cma_bind_loopback is only invoked when the source address is the loopback address. Finally, add loopback support for AF_IB as part of the change. Signed-off-by: Sean Hefty Signed-off-by: Roland Dreier --- drivers/infiniband/core/cma.c | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c index 1e9f3115ee91..316ddc38aa13 100644 --- a/drivers/infiniband/core/cma.c +++ b/drivers/infiniband/core/cma.c @@ -1952,6 +1952,23 @@ err: } EXPORT_SYMBOL(rdma_resolve_route); +static void cma_set_loopback(struct sockaddr *addr) +{ + switch (addr->sa_family) { + case AF_INET: + ((struct sockaddr_in *) addr)->sin_addr.s_addr = htonl(INADDR_LOOPBACK); + break; + case AF_INET6: + ipv6_addr_set(&((struct sockaddr_in6 *) addr)->sin6_addr, + 0, 0, 0, htonl(1)); + break; + default: + ib_addr_set(&((struct sockaddr_ib *) addr)->sib_addr, + 0, 0, 0, htonl(1)); + break; + } +} + static int cma_bind_loopback(struct rdma_id_private *id_priv) { struct cma_device *cma_dev; @@ -1992,6 +2009,7 @@ port_found: ib_addr_set_pkey(&id_priv->id.route.addr.dev_addr, pkey); id_priv->id.port_num = p; cma_attach_to_dev(id_priv, cma_dev); + cma_set_loopback((struct sockaddr *) &id_priv->id.route.addr.src_addr); out: mutex_unlock(&lock); return ret; @@ -2039,7 +2057,6 @@ out: static int cma_resolve_loopback(struct rdma_id_private *id_priv) { struct cma_work *work; - struct sockaddr *src, *dst; union ib_gid gid; int ret; @@ -2056,18 +2073,6 @@ static int cma_resolve_loopback(struct rdma_id_private *id_priv) rdma_addr_get_sgid(&id_priv->id.route.addr.dev_addr, &gid); rdma_addr_set_dgid(&id_priv->id.route.addr.dev_addr, &gid); - src = (struct sockaddr *) &id_priv->id.route.addr.src_addr; - if (cma_zero_addr(src)) { - dst = (struct sockaddr *) &id_priv->id.route.addr.dst_addr; - if ((src->sa_family = dst->sa_family) == AF_INET) { - ((struct sockaddr_in *)src)->sin_addr = - ((struct sockaddr_in *)dst)->sin_addr; - } else { - ((struct sockaddr_in6 *)src)->sin6_addr = - ((struct sockaddr_in6 *)dst)->sin6_addr; - } - } - work->id = id_priv; INIT_WORK(&work->work, cma_work_handler); work->old_state = RDMA_CM_ADDR_QUERY; From f4753834b5d06cae9a1d5453c96760571876a014 Mon Sep 17 00:00:00 2001 From: Sean Hefty Date: Wed, 29 May 2013 10:09:14 -0700 Subject: [PATCH 0351/1048] RDMA/cma: Add helper functions to return id address information Provide inline helpers to extract source and destination address data from the rdma_cm_id. Signed-off-by: Sean Hefty Signed-off-by: Roland Dreier --- drivers/infiniband/core/cma.c | 138 +++++++++++++++++----------------- 1 file changed, 71 insertions(+), 67 deletions(-) diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c index 316ddc38aa13..90694530757a 100644 --- a/drivers/infiniband/core/cma.c +++ b/drivers/infiniband/core/cma.c @@ -311,6 +311,21 @@ static void cma_release_dev(struct rdma_id_private *id_priv) mutex_unlock(&lock); } +static inline struct sockaddr *cma_src_addr(struct rdma_id_private *id_priv) +{ + return (struct sockaddr *) &id_priv->id.route.addr.src_addr; +} + +static inline struct sockaddr *cma_dst_addr(struct rdma_id_private *id_priv) +{ + return (struct sockaddr *) &id_priv->id.route.addr.dst_addr; +} + +static inline unsigned short cma_family(struct rdma_id_private *id_priv) +{ + return id_priv->id.route.addr.src_addr.ss_family; +} + static int cma_set_qkey(struct rdma_id_private *id_priv) { struct ib_sa_mcmember_rec rec; @@ -900,8 +915,7 @@ static void cma_cancel_operation(struct rdma_id_private *id_priv, cma_cancel_route(id_priv); break; case RDMA_CM_LISTEN: - if (cma_any_addr((struct sockaddr *) &id_priv->id.route.addr.src_addr) - && !id_priv->cma_dev) + if (cma_any_addr(cma_src_addr(id_priv)) && !id_priv->cma_dev) cma_cancel_listens(id_priv); break; default: @@ -1138,6 +1152,7 @@ static struct rdma_id_private *cma_new_conn_id(struct rdma_cm_id *listen_id, if (IS_ERR(id)) return NULL; + id_priv = container_of(id, struct rdma_id_private, id); cma_save_net_info(&id->route.addr, &listen_id->route.addr, ip_ver, port, src, dst); @@ -1152,19 +1167,17 @@ static struct rdma_id_private *cma_new_conn_id(struct rdma_cm_id *listen_id, if (rt->num_paths == 2) rt->path_rec[1] = *ib_event->param.req_rcvd.alternate_path; - if (cma_any_addr((struct sockaddr *) &rt->addr.src_addr)) { + if (cma_any_addr(cma_src_addr(id_priv))) { rt->addr.dev_addr.dev_type = ARPHRD_INFINIBAND; rdma_addr_set_sgid(&rt->addr.dev_addr, &rt->path_rec[0].sgid); ib_addr_set_pkey(&rt->addr.dev_addr, be16_to_cpu(rt->path_rec[0].pkey)); } else { - ret = cma_translate_addr((struct sockaddr *) &rt->addr.src_addr, - &rt->addr.dev_addr); + ret = cma_translate_addr(cma_src_addr(id_priv), &rt->addr.dev_addr); if (ret) goto err; } rdma_addr_set_dgid(&rt->addr.dev_addr, &rt->path_rec[0].dgid); - id_priv = container_of(id, struct rdma_id_private, id); id_priv->state = RDMA_CM_CONNECT; return id_priv; @@ -1188,7 +1201,7 @@ static struct rdma_id_private *cma_new_udp_id(struct rdma_cm_id *listen_id, if (IS_ERR(id)) return NULL; - + id_priv = container_of(id, struct rdma_id_private, id); if (cma_get_net_info(ib_event->private_data, listen_id->ps, &ip_ver, &port, &src, &dst)) goto err; @@ -1197,13 +1210,11 @@ static struct rdma_id_private *cma_new_udp_id(struct rdma_cm_id *listen_id, ip_ver, port, src, dst); if (!cma_any_addr((struct sockaddr *) &id->route.addr.src_addr)) { - ret = cma_translate_addr((struct sockaddr *) &id->route.addr.src_addr, - &id->route.addr.dev_addr); + ret = cma_translate_addr(cma_src_addr(id_priv), &id->route.addr.dev_addr); if (ret) goto err; } - id_priv = container_of(id, struct rdma_id_private, id); id_priv->state = RDMA_CM_CONNECT; return id_priv; err: @@ -1386,9 +1397,9 @@ static int cma_iw_handler(struct iw_cm_id *iw_id, struct iw_cm_event *iw_event) event.event = RDMA_CM_EVENT_DISCONNECTED; break; case IW_CM_EVENT_CONNECT_REPLY: - sin = (struct sockaddr_in *) &id_priv->id.route.addr.src_addr; + sin = (struct sockaddr_in *) cma_src_addr(id_priv); *sin = iw_event->local_addr; - sin = (struct sockaddr_in *) &id_priv->id.route.addr.dst_addr; + sin = (struct sockaddr_in *) cma_dst_addr(id_priv); *sin = iw_event->remote_addr; switch (iw_event->status) { case 0: @@ -1486,9 +1497,9 @@ static int iw_conn_req_handler(struct iw_cm_id *cm_id, cm_id->context = conn_id; cm_id->cm_handler = cma_iw_handler; - sin = (struct sockaddr_in *) &new_cm_id->route.addr.src_addr; + sin = (struct sockaddr_in *) cma_src_addr(conn_id); *sin = iw_event->local_addr; - sin = (struct sockaddr_in *) &new_cm_id->route.addr.dst_addr; + sin = (struct sockaddr_in *) cma_dst_addr(conn_id); *sin = iw_event->remote_addr; ret = ib_query_device(conn_id->id.device, &attr); @@ -1545,7 +1556,7 @@ static int cma_ib_listen(struct rdma_id_private *id_priv) id_priv->cm_id.ib = id; - addr = (struct sockaddr *) &id_priv->id.route.addr.src_addr; + addr = cma_src_addr(id_priv); svc_id = cma_get_service_id(id_priv->id.ps, addr); if (cma_any_addr(addr) && !id_priv->afonly) ret = ib_cm_listen(id_priv->cm_id.ib, svc_id, 0, NULL); @@ -1576,7 +1587,7 @@ static int cma_iw_listen(struct rdma_id_private *id_priv, int backlog) id_priv->cm_id.iw = id; - sin = (struct sockaddr_in *) &id_priv->id.route.addr.src_addr; + sin = (struct sockaddr_in *) cma_src_addr(id_priv); id_priv->cm_id.iw->local_addr = *sin; ret = iw_cm_listen(id_priv->cm_id.iw, backlog); @@ -1614,8 +1625,8 @@ static void cma_listen_on_dev(struct rdma_id_private *id_priv, dev_id_priv = container_of(id, struct rdma_id_private, id); dev_id_priv->state = RDMA_CM_ADDR_BOUND; - memcpy(&id->route.addr.src_addr, &id_priv->id.route.addr.src_addr, - rdma_addr_size((struct sockaddr *) &id_priv->id.route.addr.src_addr)); + memcpy(cma_src_addr(dev_id_priv), cma_src_addr(id_priv), + rdma_addr_size(cma_src_addr(id_priv))); cma_attach_to_dev(dev_id_priv, cma_dev); list_add_tail(&dev_id_priv->listen_list, &id_priv->listen_list); @@ -1673,29 +1684,28 @@ static void cma_query_handler(int status, struct ib_sa_path_rec *path_rec, static int cma_query_ib_route(struct rdma_id_private *id_priv, int timeout_ms, struct cma_work *work) { - struct rdma_addr *addr = &id_priv->id.route.addr; + struct rdma_dev_addr *dev_addr = &id_priv->id.route.addr.dev_addr; struct ib_sa_path_rec path_rec; ib_sa_comp_mask comp_mask; struct sockaddr_in6 *sin6; memset(&path_rec, 0, sizeof path_rec); - rdma_addr_get_sgid(&addr->dev_addr, &path_rec.sgid); - rdma_addr_get_dgid(&addr->dev_addr, &path_rec.dgid); - path_rec.pkey = cpu_to_be16(ib_addr_get_pkey(&addr->dev_addr)); + rdma_addr_get_sgid(dev_addr, &path_rec.sgid); + rdma_addr_get_dgid(dev_addr, &path_rec.dgid); + path_rec.pkey = cpu_to_be16(ib_addr_get_pkey(dev_addr)); path_rec.numb_path = 1; path_rec.reversible = 1; - path_rec.service_id = cma_get_service_id(id_priv->id.ps, - (struct sockaddr *) &addr->dst_addr); + path_rec.service_id = cma_get_service_id(id_priv->id.ps, cma_dst_addr(id_priv)); comp_mask = IB_SA_PATH_REC_DGID | IB_SA_PATH_REC_SGID | IB_SA_PATH_REC_PKEY | IB_SA_PATH_REC_NUMB_PATH | IB_SA_PATH_REC_REVERSIBLE | IB_SA_PATH_REC_SERVICE_ID; - if (addr->src_addr.ss_family == AF_INET) { + if (cma_family(id_priv) == AF_INET) { path_rec.qos_class = cpu_to_be16((u16) id_priv->tos); comp_mask |= IB_SA_PATH_REC_QOS_CLASS; } else { - sin6 = (struct sockaddr_in6 *) &addr->src_addr; + sin6 = (struct sockaddr_in6 *) cma_src_addr(id_priv); path_rec.traffic_class = (u8) (be32_to_cpu(sin6->sin6_flowinfo) >> 20); comp_mask |= IB_SA_PATH_REC_TRAFFIC_CLASS; } @@ -2009,7 +2019,7 @@ port_found: ib_addr_set_pkey(&id_priv->id.route.addr.dev_addr, pkey); id_priv->id.port_num = p; cma_attach_to_dev(id_priv, cma_dev); - cma_set_loopback((struct sockaddr *) &id_priv->id.route.addr.src_addr); + cma_set_loopback(cma_src_addr(id_priv)); out: mutex_unlock(&lock); return ret; @@ -2037,8 +2047,7 @@ static void addr_handler(int status, struct sockaddr *src_addr, event.event = RDMA_CM_EVENT_ADDR_ERROR; event.status = status; } else { - memcpy(&id_priv->id.route.addr.src_addr, src_addr, - rdma_addr_size(src_addr)); + memcpy(cma_src_addr(id_priv), src_addr, rdma_addr_size(src_addr)); event.event = RDMA_CM_EVENT_ADDR_RESOLVED; } @@ -2115,11 +2124,11 @@ int rdma_resolve_addr(struct rdma_cm_id *id, struct sockaddr *src_addr, return -EINVAL; atomic_inc(&id_priv->refcount); - memcpy(&id->route.addr.dst_addr, dst_addr, rdma_addr_size(dst_addr)); + memcpy(cma_dst_addr(id_priv), dst_addr, rdma_addr_size(dst_addr)); if (cma_any_addr(dst_addr)) ret = cma_resolve_loopback(id_priv); else - ret = rdma_resolve_ip(&addr_client, (struct sockaddr *) &id->route.addr.src_addr, + ret = rdma_resolve_ip(&addr_client, cma_src_addr(id_priv), dst_addr, &id->route.addr.dev_addr, timeout_ms, addr_handler, id_priv); if (ret) @@ -2180,7 +2189,7 @@ static void cma_bind_port(struct rdma_bind_list *bind_list, u64 sid, mask; __be16 port; - addr = (struct sockaddr *) &id_priv->id.route.addr.src_addr; + addr = cma_src_addr(id_priv); port = htons(bind_list->port); switch (addr->sa_family) { @@ -2268,7 +2277,7 @@ static int cma_check_port(struct rdma_bind_list *bind_list, struct rdma_id_private *cur_id; struct sockaddr *addr, *cur_addr; - addr = (struct sockaddr *) &id_priv->id.route.addr.src_addr; + addr = cma_src_addr(id_priv); hlist_for_each_entry(cur_id, &bind_list->owners, node) { if (id_priv == cur_id) continue; @@ -2277,7 +2286,7 @@ static int cma_check_port(struct rdma_bind_list *bind_list, cur_id->reuseaddr) continue; - cur_addr = (struct sockaddr *) &cur_id->id.route.addr.src_addr; + cur_addr = cma_src_addr(cur_id); if (id_priv->afonly && cur_id->afonly && (addr->sa_family != cur_addr->sa_family)) continue; @@ -2297,7 +2306,7 @@ static int cma_use_port(struct idr *ps, struct rdma_id_private *id_priv) unsigned short snum; int ret; - snum = ntohs(cma_port((struct sockaddr *) &id_priv->id.route.addr.src_addr)); + snum = ntohs(cma_port(cma_src_addr(id_priv))); if (snum < PROT_SOCK && !capable(CAP_NET_BIND_SERVICE)) return -EACCES; @@ -2348,7 +2357,7 @@ static struct idr *cma_select_ib_ps(struct rdma_id_private *id_priv) struct sockaddr_ib *sib; u64 sid_ps, mask, sid; - sib = (struct sockaddr_ib *) &id_priv->id.route.addr.src_addr; + sib = (struct sockaddr_ib *) cma_src_addr(id_priv); mask = be64_to_cpu(sib->sib_sid_mask) & RDMA_IB_IP_PS_MASK; sid = be64_to_cpu(sib->sib_sid) & mask; @@ -2378,7 +2387,7 @@ static int cma_get_port(struct rdma_id_private *id_priv) struct idr *ps; int ret; - if (id_priv->id.route.addr.src_addr.ss_family != AF_IB) + if (cma_family(id_priv) != AF_IB) ps = cma_select_inet_ps(id_priv); else ps = cma_select_ib_ps(id_priv); @@ -2386,7 +2395,7 @@ static int cma_get_port(struct rdma_id_private *id_priv) return -EPROTONOSUPPORT; mutex_lock(&lock); - if (cma_any_port((struct sockaddr *) &id_priv->id.route.addr.src_addr)) + if (cma_any_port(cma_src_addr(id_priv))) ret = cma_alloc_any_port(ps, id_priv); else ret = cma_use_port(ps, id_priv); @@ -2421,8 +2430,8 @@ int rdma_listen(struct rdma_cm_id *id, int backlog) id_priv = container_of(id, struct rdma_id_private, id); if (id_priv->state == RDMA_CM_IDLE) { - ((struct sockaddr *) &id->route.addr.src_addr)->sa_family = AF_INET; - ret = rdma_bind_addr(id, (struct sockaddr *) &id->route.addr.src_addr); + id->route.addr.src_addr.ss_family = AF_INET; + ret = rdma_bind_addr(id, cma_src_addr(id_priv)); if (ret) return ret; } @@ -2491,7 +2500,7 @@ int rdma_bind_addr(struct rdma_cm_id *id, struct sockaddr *addr) goto err1; } - memcpy(&id->route.addr.src_addr, addr, rdma_addr_size(addr)); + memcpy(cma_src_addr(id_priv), addr, rdma_addr_size(addr)); if (!(id_priv->options & (1 << CMA_OPTION_AFONLY))) { if (addr->sa_family == AF_INET) id_priv->afonly = 1; @@ -2514,19 +2523,18 @@ err1: } EXPORT_SYMBOL(rdma_bind_addr); -static int cma_format_hdr(void *hdr, enum rdma_port_space ps, - struct rdma_route *route) +static int cma_format_hdr(void *hdr, struct rdma_id_private *id_priv) { struct cma_hdr *cma_hdr; struct sdp_hh *sdp_hdr; - if (route->addr.src_addr.ss_family == AF_INET) { + if (cma_family(id_priv) == AF_INET) { struct sockaddr_in *src4, *dst4; - src4 = (struct sockaddr_in *) &route->addr.src_addr; - dst4 = (struct sockaddr_in *) &route->addr.dst_addr; + src4 = (struct sockaddr_in *) cma_src_addr(id_priv); + dst4 = (struct sockaddr_in *) cma_dst_addr(id_priv); - switch (ps) { + switch (id_priv->id.ps) { case RDMA_PS_SDP: sdp_hdr = hdr; if (sdp_get_majv(sdp_hdr->sdp_version) != SDP_MAJ_VERSION) @@ -2548,10 +2556,10 @@ static int cma_format_hdr(void *hdr, enum rdma_port_space ps, } else { struct sockaddr_in6 *src6, *dst6; - src6 = (struct sockaddr_in6 *) &route->addr.src_addr; - dst6 = (struct sockaddr_in6 *) &route->addr.dst_addr; + src6 = (struct sockaddr_in6 *) cma_src_addr(id_priv); + dst6 = (struct sockaddr_in6 *) cma_dst_addr(id_priv); - switch (ps) { + switch (id_priv->id.ps) { case RDMA_PS_SDP: sdp_hdr = hdr; if (sdp_get_majv(sdp_hdr->sdp_version) != SDP_MAJ_VERSION) @@ -2642,7 +2650,6 @@ static int cma_resolve_ib_udp(struct rdma_id_private *id_priv, struct rdma_conn_param *conn_param) { struct ib_cm_sidr_req_param req; - struct rdma_route *route; struct ib_cm_id *id; int ret; @@ -2659,8 +2666,7 @@ static int cma_resolve_ib_udp(struct rdma_id_private *id_priv, memcpy((void *) req.private_data + sizeof(struct cma_hdr), conn_param->private_data, conn_param->private_data_len); - route = &id_priv->id.route; - ret = cma_format_hdr((void *) req.private_data, id_priv->id.ps, route); + ret = cma_format_hdr((void *) req.private_data, id_priv); if (ret) goto out; @@ -2672,9 +2678,8 @@ static int cma_resolve_ib_udp(struct rdma_id_private *id_priv, } id_priv->cm_id.ib = id; - req.path = route->path_rec; - req.service_id = cma_get_service_id(id_priv->id.ps, - (struct sockaddr *) &route->addr.dst_addr); + req.path = id_priv->id.route.path_rec; + req.service_id = cma_get_service_id(id_priv->id.ps, cma_dst_addr(id_priv)); req.timeout_ms = 1 << (CMA_CM_RESPONSE_TIMEOUT - 8); req.max_cm_retries = CMA_MAX_CM_RETRIES; @@ -2719,7 +2724,7 @@ static int cma_connect_ib(struct rdma_id_private *id_priv, id_priv->cm_id.ib = id; route = &id_priv->id.route; - ret = cma_format_hdr(private_data, id_priv->id.ps, route); + ret = cma_format_hdr(private_data, id_priv); if (ret) goto out; req.private_data = private_data; @@ -2728,8 +2733,7 @@ static int cma_connect_ib(struct rdma_id_private *id_priv, if (route->num_paths == 2) req.alternate_path = &route->path_rec[1]; - req.service_id = cma_get_service_id(id_priv->id.ps, - (struct sockaddr *) &route->addr.dst_addr); + req.service_id = cma_get_service_id(id_priv->id.ps, cma_dst_addr(id_priv)); req.qp_num = id_priv->qp_num; req.qp_type = id_priv->id.qp_type; req.starting_psn = id_priv->seq_num; @@ -2768,10 +2772,10 @@ static int cma_connect_iw(struct rdma_id_private *id_priv, id_priv->cm_id.iw = cm_id; - sin = (struct sockaddr_in*) &id_priv->id.route.addr.src_addr; + sin = (struct sockaddr_in *) cma_src_addr(id_priv); cm_id->local_addr = *sin; - sin = (struct sockaddr_in*) &id_priv->id.route.addr.dst_addr; + sin = (struct sockaddr_in *) cma_dst_addr(id_priv); cm_id->remote_addr = *sin; ret = cma_modify_qp_rtr(id_priv, conn_param); @@ -3536,29 +3540,29 @@ static int cma_get_id_stats(struct sk_buff *skb, struct netlink_callback *cb) id_stats->bound_dev_if = id->route.addr.dev_addr.bound_dev_if; - if (id->route.addr.src_addr.ss_family == AF_INET) { + if (cma_family(id_priv) == AF_INET) { if (ibnl_put_attr(skb, nlh, sizeof(struct sockaddr_in), - &id->route.addr.src_addr, + cma_src_addr(id_priv), RDMA_NL_RDMA_CM_ATTR_SRC_ADDR)) { goto out; } if (ibnl_put_attr(skb, nlh, sizeof(struct sockaddr_in), - &id->route.addr.dst_addr, + cma_dst_addr(id_priv), RDMA_NL_RDMA_CM_ATTR_DST_ADDR)) { goto out; } - } else if (id->route.addr.src_addr.ss_family == AF_INET6) { + } else if (cma_family(id_priv) == AF_INET6) { if (ibnl_put_attr(skb, nlh, sizeof(struct sockaddr_in6), - &id->route.addr.src_addr, + cma_src_addr(id_priv), RDMA_NL_RDMA_CM_ATTR_SRC_ADDR)) { goto out; } if (ibnl_put_attr(skb, nlh, sizeof(struct sockaddr_in6), - &id->route.addr.dst_addr, + cma_dst_addr(id_priv), RDMA_NL_RDMA_CM_ATTR_DST_ADDR)) { goto out; } From b0569e40753aa4f742cfd792447a093ab7937563 Mon Sep 17 00:00:00 2001 From: Sean Hefty Date: Wed, 29 May 2013 10:09:15 -0700 Subject: [PATCH 0352/1048] RDMA/cma: Restrict AF_IB loopback to binding to IB devices only If a user specifies AF_IB as the source address for a loopback connection, limit the resolution to IB devices only. Signed-off-by: Sean Hefty Signed-off-by: Roland Dreier --- drivers/infiniband/core/cma.c | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c index 90694530757a..524cf986d9fa 100644 --- a/drivers/infiniband/core/cma.c +++ b/drivers/infiniband/core/cma.c @@ -1981,26 +1981,38 @@ static void cma_set_loopback(struct sockaddr *addr) static int cma_bind_loopback(struct rdma_id_private *id_priv) { - struct cma_device *cma_dev; + struct cma_device *cma_dev, *cur_dev; struct ib_port_attr port_attr; union ib_gid gid; u16 pkey; int ret; u8 p; + cma_dev = NULL; mutex_lock(&lock); - if (list_empty(&dev_list)) { + list_for_each_entry(cur_dev, &dev_list, list) { + if (cma_family(id_priv) == AF_IB && + rdma_node_get_transport(cur_dev->device->node_type) != RDMA_TRANSPORT_IB) + continue; + + if (!cma_dev) + cma_dev = cur_dev; + + for (p = 1; p <= cur_dev->device->phys_port_cnt; ++p) { + if (!ib_query_port(cur_dev->device, p, &port_attr) && + port_attr.state == IB_PORT_ACTIVE) { + cma_dev = cur_dev; + goto port_found; + } + } + } + + if (!cma_dev) { ret = -ENODEV; goto out; } - list_for_each_entry(cma_dev, &dev_list, list) - for (p = 1; p <= cma_dev->device->phys_port_cnt; ++p) - if (!ib_query_port(cma_dev->device, p, &port_attr) && - port_attr.state == IB_PORT_ACTIVE) - goto port_found; p = 1; - cma_dev = list_entry(dev_list.next, struct cma_device, list); port_found: ret = ib_get_cached_gid(cma_dev->device, p, 0, &gid); From 4ae7152e0bf98ac91a2835dce07f6fdb9f6407bd Mon Sep 17 00:00:00 2001 From: Sean Hefty Date: Wed, 29 May 2013 10:09:16 -0700 Subject: [PATCH 0353/1048] RDMA/cma: Verify that source and dest sa_family are the same Signed-off-by: Sean Hefty Signed-off-by: Roland Dreier --- drivers/infiniband/core/cma.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c index 524cf986d9fa..9f6e719cf620 100644 --- a/drivers/infiniband/core/cma.c +++ b/drivers/infiniband/core/cma.c @@ -1849,14 +1849,9 @@ static int cma_resolve_iboe_route(struct rdma_id_private *id_priv) struct rdma_addr *addr = &route->addr; struct cma_work *work; int ret; - struct sockaddr_in *src_addr = (struct sockaddr_in *)&route->addr.src_addr; - struct sockaddr_in *dst_addr = (struct sockaddr_in *)&route->addr.dst_addr; struct net_device *ndev = NULL; u16 vid; - if (src_addr->sin_family != dst_addr->sin_family) - return -EINVAL; - work = kzalloc(sizeof *work, GFP_KERNEL); if (!work) return -ENOMEM; @@ -2132,6 +2127,9 @@ int rdma_resolve_addr(struct rdma_cm_id *id, struct sockaddr *src_addr, return ret; } + if (cma_family(id_priv) != dst_addr->sa_family) + return -EINVAL; + if (!cma_comp_exch(id_priv, RDMA_CM_ADDR_BOUND, RDMA_CM_ADDR_QUERY)) return -EINVAL; From f17df3b0dede861e3c3e20225731fcbe1b1041c3 Mon Sep 17 00:00:00 2001 From: Sean Hefty Date: Wed, 29 May 2013 10:09:17 -0700 Subject: [PATCH 0354/1048] RDMA/cma: Add support for AF_IB to rdma_resolve_addr() Allow the user to specify the remote address using AF_IB format. When AF_IB is used, the remote address simply needs to be recorded, and no resolution using ARP is done. The local address may still need to be matched with a local IB device. Signed-off-by: Sean Hefty Signed-off-by: Roland Dreier --- drivers/infiniband/core/cma.c | 106 ++++++++++++++++++++++++++++++++-- 1 file changed, 100 insertions(+), 6 deletions(-) diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c index 9f6e719cf620..7a159af08630 100644 --- a/drivers/infiniband/core/cma.c +++ b/drivers/infiniband/core/cma.c @@ -438,6 +438,61 @@ out: return ret; } +/* + * Select the source IB device and address to reach the destination IB address. + */ +static int cma_resolve_ib_dev(struct rdma_id_private *id_priv) +{ + struct cma_device *cma_dev, *cur_dev; + struct sockaddr_ib *addr; + union ib_gid gid, sgid, *dgid; + u16 pkey, index; + u8 port, p; + int i; + + cma_dev = NULL; + addr = (struct sockaddr_ib *) cma_dst_addr(id_priv); + dgid = (union ib_gid *) &addr->sib_addr; + pkey = ntohs(addr->sib_pkey); + + list_for_each_entry(cur_dev, &dev_list, list) { + if (rdma_node_get_transport(cur_dev->device->node_type) != RDMA_TRANSPORT_IB) + continue; + + for (p = 1; p <= cur_dev->device->phys_port_cnt; ++p) { + if (ib_find_cached_pkey(cur_dev->device, p, pkey, &index)) + continue; + + for (i = 0; !ib_get_cached_gid(cur_dev->device, p, i, &gid); i++) { + if (!memcmp(&gid, dgid, sizeof(gid))) { + cma_dev = cur_dev; + sgid = gid; + port = p; + goto found; + } + + if (!cma_dev && (gid.global.subnet_prefix == + dgid->global.subnet_prefix)) { + cma_dev = cur_dev; + sgid = gid; + port = p; + } + } + } + } + + if (!cma_dev) + return -ENODEV; + +found: + cma_attach_to_dev(id_priv, cma_dev); + id_priv->id.port_num = port; + addr = (struct sockaddr_ib *) cma_src_addr(id_priv); + memcpy(&addr->sib_addr, &sgid, sizeof sgid); + cma_translate_ib(addr, &id_priv->id.route.addr.dev_addr); + return 0; +} + static void cma_deref_id(struct rdma_id_private *id_priv) { if (atomic_dec_and_test(&id_priv->refcount)) @@ -2101,14 +2156,48 @@ err: return ret; } +static int cma_resolve_ib_addr(struct rdma_id_private *id_priv) +{ + struct cma_work *work; + int ret; + + work = kzalloc(sizeof *work, GFP_KERNEL); + if (!work) + return -ENOMEM; + + if (!id_priv->cma_dev) { + ret = cma_resolve_ib_dev(id_priv); + if (ret) + goto err; + } + + rdma_addr_set_dgid(&id_priv->id.route.addr.dev_addr, (union ib_gid *) + &(((struct sockaddr_ib *) &id_priv->id.route.addr.dst_addr)->sib_addr)); + + work->id = id_priv; + INIT_WORK(&work->work, cma_work_handler); + work->old_state = RDMA_CM_ADDR_QUERY; + work->new_state = RDMA_CM_ADDR_RESOLVED; + work->event.event = RDMA_CM_EVENT_ADDR_RESOLVED; + queue_work(cma_wq, &work->work); + return 0; +err: + kfree(work); + return ret; +} + static int cma_bind_addr(struct rdma_cm_id *id, struct sockaddr *src_addr, struct sockaddr *dst_addr) { if (!src_addr || !src_addr->sa_family) { src_addr = (struct sockaddr *) &id->route.addr.src_addr; - if ((src_addr->sa_family = dst_addr->sa_family) == AF_INET6) { + src_addr->sa_family = dst_addr->sa_family; + if (dst_addr->sa_family == AF_INET6) { ((struct sockaddr_in6 *) src_addr)->sin6_scope_id = ((struct sockaddr_in6 *) dst_addr)->sin6_scope_id; + } else if (dst_addr->sa_family == AF_IB) { + ((struct sockaddr_ib *) src_addr)->sib_pkey = + ((struct sockaddr_ib *) dst_addr)->sib_pkey; } } return rdma_bind_addr(id, src_addr); @@ -2135,12 +2224,17 @@ int rdma_resolve_addr(struct rdma_cm_id *id, struct sockaddr *src_addr, atomic_inc(&id_priv->refcount); memcpy(cma_dst_addr(id_priv), dst_addr, rdma_addr_size(dst_addr)); - if (cma_any_addr(dst_addr)) + if (cma_any_addr(dst_addr)) { ret = cma_resolve_loopback(id_priv); - else - ret = rdma_resolve_ip(&addr_client, cma_src_addr(id_priv), - dst_addr, &id->route.addr.dev_addr, - timeout_ms, addr_handler, id_priv); + } else { + if (dst_addr->sa_family == AF_IB) { + ret = cma_resolve_ib_addr(id_priv); + } else { + ret = rdma_resolve_ip(&addr_client, cma_src_addr(id_priv), + dst_addr, &id->route.addr.dev_addr, + timeout_ms, addr_handler, id_priv); + } + } if (ret) goto err; From f68194ca88ecca70e7e9064949d9d1f6e4b3a647 Mon Sep 17 00:00:00 2001 From: Sean Hefty Date: Wed, 29 May 2013 10:09:18 -0700 Subject: [PATCH 0355/1048] RDMA/cma: Add support for AF_IB to rdma_resolve_route() Allow rdma_resolve_route() to handle the case where the user specified the source and destination addresses using AF_IB. Signed-off-by: Sean Hefty Signed-off-by: Roland Dreier --- drivers/infiniband/core/cma.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c index 7a159af08630..66cb043ddd49 100644 --- a/drivers/infiniband/core/cma.c +++ b/drivers/infiniband/core/cma.c @@ -1743,6 +1743,7 @@ static int cma_query_ib_route(struct rdma_id_private *id_priv, int timeout_ms, struct ib_sa_path_rec path_rec; ib_sa_comp_mask comp_mask; struct sockaddr_in6 *sin6; + struct sockaddr_ib *sib; memset(&path_rec, 0, sizeof path_rec); rdma_addr_get_sgid(dev_addr, &path_rec.sgid); @@ -1756,13 +1757,21 @@ static int cma_query_ib_route(struct rdma_id_private *id_priv, int timeout_ms, IB_SA_PATH_REC_PKEY | IB_SA_PATH_REC_NUMB_PATH | IB_SA_PATH_REC_REVERSIBLE | IB_SA_PATH_REC_SERVICE_ID; - if (cma_family(id_priv) == AF_INET) { + switch (cma_family(id_priv)) { + case AF_INET: path_rec.qos_class = cpu_to_be16((u16) id_priv->tos); comp_mask |= IB_SA_PATH_REC_QOS_CLASS; - } else { + break; + case AF_INET6: sin6 = (struct sockaddr_in6 *) cma_src_addr(id_priv); path_rec.traffic_class = (u8) (be32_to_cpu(sin6->sin6_flowinfo) >> 20); comp_mask |= IB_SA_PATH_REC_TRAFFIC_CLASS; + break; + case AF_IB: + sib = (struct sockaddr_ib *) cma_src_addr(id_priv); + path_rec.traffic_class = (u8) (be32_to_cpu(sib->sib_flowinfo) >> 20); + comp_mask |= IB_SA_PATH_REC_TRAFFIC_CLASS; + break; } id_priv->query_id = ib_sa_path_rec_get(&sa_client, id_priv->id.device, From 496ce3ce17f4b4f1b5f6edf9d2aedc4787a31c2f Mon Sep 17 00:00:00 2001 From: Sean Hefty Date: Wed, 29 May 2013 10:09:19 -0700 Subject: [PATCH 0356/1048] RDMA/cma: Add support for AF_IB to cma_get_service_id() cma_get_service_id() forms the service ID based on the port space and port number of the rdma_cm_id. Extend the call to support AF_IB, which contains the service ID directly. This will be needed to support any arbitrary SID. Signed-off-by: Sean Hefty Signed-off-by: Roland Dreier --- drivers/infiniband/core/cma.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c index 66cb043ddd49..f1dd0ca34d83 100644 --- a/drivers/infiniband/core/cma.c +++ b/drivers/infiniband/core/cma.c @@ -1379,6 +1379,9 @@ err1: static __be64 cma_get_service_id(enum rdma_port_space ps, struct sockaddr *addr) { + if (addr->sa_family == AF_IB) + return ((struct sockaddr_ib *) addr)->sib_sid; + return cpu_to_be64(((u64)ps << 16) + be16_to_cpu(cma_port(addr))); } From 01602f113f7ceee51e04edd1db972b79bedfe3aa Mon Sep 17 00:00:00 2001 From: Sean Hefty Date: Wed, 29 May 2013 10:09:20 -0700 Subject: [PATCH 0357/1048] RDMA/cma: Remove unused SDP related code The SDP protocol was never merged upstream. Remove unused SDP related code from the RDMA CM. Signed-off-by: Sean Hefty Signed-off-by: Roland Dreier --- drivers/infiniband/core/cma.c | 176 ++++++---------------------------- 1 file changed, 31 insertions(+), 145 deletions(-) diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c index f1dd0ca34d83..daec9319502d 100644 --- a/drivers/infiniband/core/cma.c +++ b/drivers/infiniband/core/cma.c @@ -80,7 +80,6 @@ static LIST_HEAD(dev_list); static LIST_HEAD(listen_any_list); static DEFINE_MUTEX(lock); static struct workqueue_struct *cma_wq; -static DEFINE_IDR(sdp_ps); static DEFINE_IDR(tcp_ps); static DEFINE_IDR(udp_ps); static DEFINE_IDR(ipoib_ps); @@ -196,24 +195,7 @@ struct cma_hdr { union cma_ip_addr dst_addr; }; -struct sdp_hh { - u8 bsdh[16]; - u8 sdp_version; /* Major version: 7:4 */ - u8 ip_version; /* IP version: 7:4 */ - u8 sdp_specific1[10]; - __be16 port; - __be16 sdp_specific2; - union cma_ip_addr src_addr; - union cma_ip_addr dst_addr; -}; - -struct sdp_hah { - u8 bsdh[16]; - u8 sdp_version; -}; - #define CMA_VERSION 0x00 -#define SDP_MAJ_VERSION 0x2 static int cma_comp(struct rdma_id_private *id_priv, enum rdma_cm_state comp) { @@ -262,21 +244,6 @@ static inline void cma_set_ip_ver(struct cma_hdr *hdr, u8 ip_ver) hdr->ip_version = (ip_ver << 4) | (hdr->ip_version & 0xF); } -static inline u8 sdp_get_majv(u8 sdp_version) -{ - return sdp_version >> 4; -} - -static inline u8 sdp_get_ip_ver(struct sdp_hh *hh) -{ - return hh->ip_version >> 4; -} - -static inline void sdp_set_ip_ver(struct sdp_hh *hh, u8 ip_ver) -{ - hh->ip_version = (ip_ver << 4) | (hh->ip_version & 0xF); -} - static void cma_attach_to_dev(struct rdma_id_private *id_priv, struct cma_device *cma_dev) { @@ -847,27 +814,13 @@ static int cma_get_net_info(void *hdr, enum rdma_port_space ps, u8 *ip_ver, __be16 *port, union cma_ip_addr **src, union cma_ip_addr **dst) { - switch (ps) { - case RDMA_PS_SDP: - if (sdp_get_majv(((struct sdp_hh *) hdr)->sdp_version) != - SDP_MAJ_VERSION) - return -EINVAL; + if (((struct cma_hdr *) hdr)->cma_version != CMA_VERSION) + return -EINVAL; - *ip_ver = sdp_get_ip_ver(hdr); - *port = ((struct sdp_hh *) hdr)->port; - *src = &((struct sdp_hh *) hdr)->src_addr; - *dst = &((struct sdp_hh *) hdr)->dst_addr; - break; - default: - if (((struct cma_hdr *) hdr)->cma_version != CMA_VERSION) - return -EINVAL; - - *ip_ver = cma_get_ip_ver(hdr); - *port = ((struct cma_hdr *) hdr)->port; - *src = &((struct cma_hdr *) hdr)->src_addr; - *dst = &((struct cma_hdr *) hdr)->dst_addr; - break; - } + *ip_ver = cma_get_ip_ver(hdr); + *port = ((struct cma_hdr *) hdr)->port; + *src = &((struct cma_hdr *) hdr)->src_addr; + *dst = &((struct cma_hdr *) hdr)->dst_addr; if (*ip_ver != 4 && *ip_ver != 6) return -EINVAL; @@ -914,12 +867,7 @@ static void cma_save_net_info(struct rdma_addr *addr, static inline int cma_user_data_offset(enum rdma_port_space ps) { - switch (ps) { - case RDMA_PS_SDP: - return 0; - default: - return sizeof(struct cma_hdr); - } + return sizeof(struct cma_hdr); } static void cma_cancel_route(struct rdma_id_private *id_priv) @@ -1085,16 +1033,6 @@ reject: return ret; } -static int cma_verify_rep(struct rdma_id_private *id_priv, void *data) -{ - if (id_priv->id.ps == RDMA_PS_SDP && - sdp_get_majv(((struct sdp_hah *) data)->sdp_version) != - SDP_MAJ_VERSION) - return -EINVAL; - - return 0; -} - static void cma_set_rep_event_data(struct rdma_cm_event *event, struct ib_cm_rep_event_param *rep_data, void *private_data) @@ -1129,15 +1067,13 @@ static int cma_ib_handler(struct ib_cm_id *cm_id, struct ib_cm_event *ib_event) event.status = -ETIMEDOUT; break; case IB_CM_REP_RECEIVED: - event.status = cma_verify_rep(id_priv, ib_event->private_data); - if (event.status) - event.event = RDMA_CM_EVENT_CONNECT_ERROR; - else if (id_priv->id.qp && id_priv->id.ps != RDMA_PS_SDP) { + if (id_priv->id.qp) { event.status = cma_rep_recv(id_priv); event.event = event.status ? RDMA_CM_EVENT_CONNECT_ERROR : RDMA_CM_EVENT_ESTABLISHED; - } else + } else { event.event = RDMA_CM_EVENT_CONNECT_RESPONSE; + } cma_set_rep_event_data(&event, &ib_event->param.rep_rcvd, ib_event->private_data); break; @@ -1389,49 +1325,31 @@ static void cma_set_compare_data(enum rdma_port_space ps, struct sockaddr *addr, struct ib_cm_compare_data *compare) { struct cma_hdr *cma_data, *cma_mask; - struct sdp_hh *sdp_data, *sdp_mask; __be32 ip4_addr; struct in6_addr ip6_addr; memset(compare, 0, sizeof *compare); cma_data = (void *) compare->data; cma_mask = (void *) compare->mask; - sdp_data = (void *) compare->data; - sdp_mask = (void *) compare->mask; switch (addr->sa_family) { case AF_INET: ip4_addr = ((struct sockaddr_in *) addr)->sin_addr.s_addr; - if (ps == RDMA_PS_SDP) { - sdp_set_ip_ver(sdp_data, 4); - sdp_set_ip_ver(sdp_mask, 0xF); - sdp_data->dst_addr.ip4.addr = ip4_addr; - sdp_mask->dst_addr.ip4.addr = htonl(~0); - } else { - cma_set_ip_ver(cma_data, 4); - cma_set_ip_ver(cma_mask, 0xF); - if (!cma_any_addr(addr)) { - cma_data->dst_addr.ip4.addr = ip4_addr; - cma_mask->dst_addr.ip4.addr = htonl(~0); - } + cma_set_ip_ver(cma_data, 4); + cma_set_ip_ver(cma_mask, 0xF); + if (!cma_any_addr(addr)) { + cma_data->dst_addr.ip4.addr = ip4_addr; + cma_mask->dst_addr.ip4.addr = htonl(~0); } break; case AF_INET6: ip6_addr = ((struct sockaddr_in6 *) addr)->sin6_addr; - if (ps == RDMA_PS_SDP) { - sdp_set_ip_ver(sdp_data, 6); - sdp_set_ip_ver(sdp_mask, 0xF); - sdp_data->dst_addr.ip6 = ip6_addr; - memset(&sdp_mask->dst_addr.ip6, 0xFF, - sizeof sdp_mask->dst_addr.ip6); - } else { - cma_set_ip_ver(cma_data, 6); - cma_set_ip_ver(cma_mask, 0xF); - if (!cma_any_addr(addr)) { - cma_data->dst_addr.ip6 = ip6_addr; - memset(&cma_mask->dst_addr.ip6, 0xFF, - sizeof cma_mask->dst_addr.ip6); - } + cma_set_ip_ver(cma_data, 6); + cma_set_ip_ver(cma_mask, 0xF); + if (!cma_any_addr(addr)) { + cma_data->dst_addr.ip6 = ip6_addr; + memset(&cma_mask->dst_addr.ip6, 0xFF, + sizeof cma_mask->dst_addr.ip6); } break; default: @@ -2452,8 +2370,6 @@ static int cma_bind_listen(struct rdma_id_private *id_priv) static struct idr *cma_select_inet_ps(struct rdma_id_private *id_priv) { switch (id_priv->id.ps) { - case RDMA_PS_SDP: - return &sdp_ps; case RDMA_PS_TCP: return &tcp_ps; case RDMA_PS_UDP: @@ -2642,58 +2558,29 @@ EXPORT_SYMBOL(rdma_bind_addr); static int cma_format_hdr(void *hdr, struct rdma_id_private *id_priv) { struct cma_hdr *cma_hdr; - struct sdp_hh *sdp_hdr; + cma_hdr = hdr; + cma_hdr->cma_version = CMA_VERSION; if (cma_family(id_priv) == AF_INET) { struct sockaddr_in *src4, *dst4; src4 = (struct sockaddr_in *) cma_src_addr(id_priv); dst4 = (struct sockaddr_in *) cma_dst_addr(id_priv); - switch (id_priv->id.ps) { - case RDMA_PS_SDP: - sdp_hdr = hdr; - if (sdp_get_majv(sdp_hdr->sdp_version) != SDP_MAJ_VERSION) - return -EINVAL; - sdp_set_ip_ver(sdp_hdr, 4); - sdp_hdr->src_addr.ip4.addr = src4->sin_addr.s_addr; - sdp_hdr->dst_addr.ip4.addr = dst4->sin_addr.s_addr; - sdp_hdr->port = src4->sin_port; - break; - default: - cma_hdr = hdr; - cma_hdr->cma_version = CMA_VERSION; - cma_set_ip_ver(cma_hdr, 4); - cma_hdr->src_addr.ip4.addr = src4->sin_addr.s_addr; - cma_hdr->dst_addr.ip4.addr = dst4->sin_addr.s_addr; - cma_hdr->port = src4->sin_port; - break; - } + cma_set_ip_ver(cma_hdr, 4); + cma_hdr->src_addr.ip4.addr = src4->sin_addr.s_addr; + cma_hdr->dst_addr.ip4.addr = dst4->sin_addr.s_addr; + cma_hdr->port = src4->sin_port; } else { struct sockaddr_in6 *src6, *dst6; src6 = (struct sockaddr_in6 *) cma_src_addr(id_priv); dst6 = (struct sockaddr_in6 *) cma_dst_addr(id_priv); - switch (id_priv->id.ps) { - case RDMA_PS_SDP: - sdp_hdr = hdr; - if (sdp_get_majv(sdp_hdr->sdp_version) != SDP_MAJ_VERSION) - return -EINVAL; - sdp_set_ip_ver(sdp_hdr, 6); - sdp_hdr->src_addr.ip6 = src6->sin6_addr; - sdp_hdr->dst_addr.ip6 = dst6->sin6_addr; - sdp_hdr->port = src6->sin6_port; - break; - default: - cma_hdr = hdr; - cma_hdr->cma_version = CMA_VERSION; - cma_set_ip_ver(cma_hdr, 6); - cma_hdr->src_addr.ip6 = src6->sin6_addr; - cma_hdr->dst_addr.ip6 = dst6->sin6_addr; - cma_hdr->port = src6->sin6_port; - break; - } + cma_set_ip_ver(cma_hdr, 6); + cma_hdr->src_addr.ip6 = src6->sin6_addr; + cma_hdr->dst_addr.ip6 = dst6->sin6_addr; + cma_hdr->port = src6->sin6_port; } return 0; } @@ -3747,7 +3634,6 @@ static void __exit cma_cleanup(void) rdma_addr_unregister_client(&addr_client); ib_sa_unregister_client(&sa_client); destroy_workqueue(cma_wq); - idr_destroy(&sdp_ps); idr_destroy(&tcp_ps); idr_destroy(&udp_ps); idr_destroy(&ipoib_ps); From fbaa1a6d852aa6878059acb18cbc336746795a56 Mon Sep 17 00:00:00 2001 From: Sean Hefty Date: Wed, 29 May 2013 10:09:21 -0700 Subject: [PATCH 0358/1048] RDMA/cma: Merge cma_get/save_net_info With the removal of SDP related code, we can merge cma_get_net_info() with cma_save_net_info(), since we're only ever dealing with a single header format. Signed-off-by: Sean Hefty Signed-off-by: Roland Dreier --- drivers/infiniband/core/cma.c | 124 +++++++++++++++++++--------------- 1 file changed, 69 insertions(+), 55 deletions(-) diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c index daec9319502d..112a192eae9c 100644 --- a/drivers/infiniband/core/cma.c +++ b/drivers/infiniband/core/cma.c @@ -810,59 +810,87 @@ static inline int cma_any_port(struct sockaddr *addr) return !cma_port(addr); } -static int cma_get_net_info(void *hdr, enum rdma_port_space ps, - u8 *ip_ver, __be16 *port, - union cma_ip_addr **src, union cma_ip_addr **dst) +static void cma_save_ib_info(struct rdma_cm_id *id, struct rdma_cm_id *listen_id, + struct ib_sa_path_rec *path) { - if (((struct cma_hdr *) hdr)->cma_version != CMA_VERSION) - return -EINVAL; + struct sockaddr_ib *listen_ib, *ib; - *ip_ver = cma_get_ip_ver(hdr); - *port = ((struct cma_hdr *) hdr)->port; - *src = &((struct cma_hdr *) hdr)->src_addr; - *dst = &((struct cma_hdr *) hdr)->dst_addr; + listen_ib = (struct sockaddr_ib *) &listen_id->route.addr.src_addr; + ib = (struct sockaddr_ib *) &id->route.addr.src_addr; + ib->sib_family = listen_ib->sib_family; + ib->sib_pkey = path->pkey; + ib->sib_flowinfo = path->flow_label; + memcpy(&ib->sib_addr, &path->sgid, 16); + ib->sib_sid = listen_ib->sib_sid; + ib->sib_sid_mask = cpu_to_be64(0xffffffffffffffffULL); + ib->sib_scope_id = listen_ib->sib_scope_id; - if (*ip_ver != 4 && *ip_ver != 6) - return -EINVAL; - return 0; + ib = (struct sockaddr_ib *) &id->route.addr.dst_addr; + ib->sib_family = listen_ib->sib_family; + ib->sib_pkey = path->pkey; + ib->sib_flowinfo = path->flow_label; + memcpy(&ib->sib_addr, &path->dgid, 16); } -static void cma_save_net_info(struct rdma_addr *addr, - struct rdma_addr *listen_addr, - u8 ip_ver, __be16 port, - union cma_ip_addr *src, union cma_ip_addr *dst) +static void cma_save_ip4_info(struct rdma_cm_id *id, struct rdma_cm_id *listen_id, + struct cma_hdr *hdr) { struct sockaddr_in *listen4, *ip4; + + listen4 = (struct sockaddr_in *) &listen_id->route.addr.src_addr; + ip4 = (struct sockaddr_in *) &id->route.addr.src_addr; + ip4->sin_family = listen4->sin_family; + ip4->sin_addr.s_addr = hdr->dst_addr.ip4.addr; + ip4->sin_port = listen4->sin_port; + + ip4 = (struct sockaddr_in *) &id->route.addr.dst_addr; + ip4->sin_family = listen4->sin_family; + ip4->sin_addr.s_addr = hdr->src_addr.ip4.addr; + ip4->sin_port = hdr->port; +} + +static void cma_save_ip6_info(struct rdma_cm_id *id, struct rdma_cm_id *listen_id, + struct cma_hdr *hdr) +{ struct sockaddr_in6 *listen6, *ip6; - switch (ip_ver) { - case 4: - listen4 = (struct sockaddr_in *) &listen_addr->src_addr; - ip4 = (struct sockaddr_in *) &addr->src_addr; - ip4->sin_family = listen4->sin_family; - ip4->sin_addr.s_addr = dst->ip4.addr; - ip4->sin_port = listen4->sin_port; + listen6 = (struct sockaddr_in6 *) &listen_id->route.addr.src_addr; + ip6 = (struct sockaddr_in6 *) &id->route.addr.src_addr; + ip6->sin6_family = listen6->sin6_family; + ip6->sin6_addr = hdr->dst_addr.ip6; + ip6->sin6_port = listen6->sin6_port; - ip4 = (struct sockaddr_in *) &addr->dst_addr; - ip4->sin_family = listen4->sin_family; - ip4->sin_addr.s_addr = src->ip4.addr; - ip4->sin_port = port; + ip6 = (struct sockaddr_in6 *) &id->route.addr.dst_addr; + ip6->sin6_family = listen6->sin6_family; + ip6->sin6_addr = hdr->src_addr.ip6; + ip6->sin6_port = hdr->port; +} + +static int cma_save_net_info(struct rdma_cm_id *id, struct rdma_cm_id *listen_id, + struct ib_cm_event *ib_event) +{ + struct cma_hdr *hdr; + + if (listen_id->route.addr.src_addr.ss_family == AF_IB) { + cma_save_ib_info(id, listen_id, ib_event->param.req_rcvd.primary_path); + return 0; + } + + hdr = ib_event->private_data; + if (hdr->cma_version != CMA_VERSION) + return -EINVAL; + + switch (cma_get_ip_ver(hdr)) { + case 4: + cma_save_ip4_info(id, listen_id, hdr); break; case 6: - listen6 = (struct sockaddr_in6 *) &listen_addr->src_addr; - ip6 = (struct sockaddr_in6 *) &addr->src_addr; - ip6->sin6_family = listen6->sin6_family; - ip6->sin6_addr = dst->ip6; - ip6->sin6_port = listen6->sin6_port; - - ip6 = (struct sockaddr_in6 *) &addr->dst_addr; - ip6->sin6_family = listen6->sin6_family; - ip6->sin6_addr = src->ip6; - ip6->sin6_port = port; + cma_save_ip6_info(id, listen_id, hdr); break; default: - break; + return -EINVAL; } + return 0; } static inline int cma_user_data_offset(enum rdma_port_space ps) @@ -1129,23 +1157,16 @@ static struct rdma_id_private *cma_new_conn_id(struct rdma_cm_id *listen_id, struct rdma_id_private *id_priv; struct rdma_cm_id *id; struct rdma_route *rt; - union cma_ip_addr *src, *dst; - __be16 port; - u8 ip_ver; int ret; - if (cma_get_net_info(ib_event->private_data, listen_id->ps, - &ip_ver, &port, &src, &dst)) - return NULL; - id = rdma_create_id(listen_id->event_handler, listen_id->context, listen_id->ps, ib_event->param.req_rcvd.qp_type); if (IS_ERR(id)) return NULL; id_priv = container_of(id, struct rdma_id_private, id); - cma_save_net_info(&id->route.addr, &listen_id->route.addr, - ip_ver, port, src, dst); + if (cma_save_net_info(id, listen_id, ib_event)) + goto err; rt = &id->route; rt->num_paths = ib_event->param.req_rcvd.alternate_path ? 2 : 1; @@ -1182,9 +1203,6 @@ static struct rdma_id_private *cma_new_udp_id(struct rdma_cm_id *listen_id, { struct rdma_id_private *id_priv; struct rdma_cm_id *id; - union cma_ip_addr *src, *dst; - __be16 port; - u8 ip_ver; int ret; id = rdma_create_id(listen_id->event_handler, listen_id->context, @@ -1193,13 +1211,9 @@ static struct rdma_id_private *cma_new_udp_id(struct rdma_cm_id *listen_id, return NULL; id_priv = container_of(id, struct rdma_id_private, id); - if (cma_get_net_info(ib_event->private_data, listen_id->ps, - &ip_ver, &port, &src, &dst)) + if (cma_save_net_info(id, listen_id, ib_event)) goto err; - cma_save_net_info(&id->route.addr, &listen_id->route.addr, - ip_ver, port, src, dst); - if (!cma_any_addr((struct sockaddr *) &id->route.addr.src_addr)) { ret = cma_translate_addr(cma_src_addr(id_priv), &id->route.addr.dev_addr); if (ret) From e8160e15930969de709ba9b46df9571448b78ce5 Mon Sep 17 00:00:00 2001 From: Sean Hefty Date: Wed, 29 May 2013 10:09:22 -0700 Subject: [PATCH 0359/1048] RDMA/cma: Expose private data when using AF_IB If the source or destination address is AF_IB, then do not reserve a portion of the private data in the IB CM REQ or SIDR REQ messages for the cma header. Instead, all private data should be exported to the user. When AF_IB is used, the rdma cm does not have sufficient information to fill in the cma header. Additionally, this will be necessary to support any IB connection through the rdma cm interface, Signed-off-by: Sean Hefty Signed-off-by: Roland Dreier --- drivers/infiniband/core/cma.c | 56 +++++++++++++++++++++-------------- 1 file changed, 34 insertions(+), 22 deletions(-) diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c index 112a192eae9c..7a9b033e37ce 100644 --- a/drivers/infiniband/core/cma.c +++ b/drivers/infiniband/core/cma.c @@ -893,9 +893,9 @@ static int cma_save_net_info(struct rdma_cm_id *id, struct rdma_cm_id *listen_id return 0; } -static inline int cma_user_data_offset(enum rdma_port_space ps) +static inline int cma_user_data_offset(struct rdma_id_private *id_priv) { - return sizeof(struct cma_hdr); + return cma_family(id_priv) == AF_IB ? 0 : sizeof(struct cma_hdr); } static void cma_cancel_route(struct rdma_id_private *id_priv) @@ -1265,7 +1265,7 @@ static int cma_req_handler(struct ib_cm_id *cm_id, struct ib_cm_event *ib_event) return -ECONNABORTED; memset(&event, 0, sizeof event); - offset = cma_user_data_offset(listen_id->id.ps); + offset = cma_user_data_offset(listen_id); event.event = RDMA_CM_EVENT_CONNECT_REQUEST; if (ib_event->event == IB_CM_SIDR_REQ_RECEIVED) { conn_id = cma_new_udp_id(&listen_id->id, ib_event); @@ -2585,7 +2585,7 @@ static int cma_format_hdr(void *hdr, struct rdma_id_private *id_priv) cma_hdr->src_addr.ip4.addr = src4->sin_addr.s_addr; cma_hdr->dst_addr.ip4.addr = dst4->sin_addr.s_addr; cma_hdr->port = src4->sin_port; - } else { + } else if (cma_family(id_priv) == AF_INET6) { struct sockaddr_in6 *src6, *dst6; src6 = (struct sockaddr_in6 *) cma_src_addr(id_priv); @@ -2668,24 +2668,30 @@ static int cma_resolve_ib_udp(struct rdma_id_private *id_priv, { struct ib_cm_sidr_req_param req; struct ib_cm_id *id; - int ret; + int offset, ret; - req.private_data_len = sizeof(struct cma_hdr) + - conn_param->private_data_len; + offset = cma_user_data_offset(id_priv); + req.private_data_len = offset + conn_param->private_data_len; if (req.private_data_len < conn_param->private_data_len) return -EINVAL; - req.private_data = kzalloc(req.private_data_len, GFP_ATOMIC); - if (!req.private_data) - return -ENOMEM; + if (req.private_data_len) { + req.private_data = kzalloc(req.private_data_len, GFP_ATOMIC); + if (!req.private_data) + return -ENOMEM; + } else { + req.private_data = NULL; + } if (conn_param->private_data && conn_param->private_data_len) - memcpy((void *) req.private_data + sizeof(struct cma_hdr), + memcpy((void *) req.private_data + offset, conn_param->private_data, conn_param->private_data_len); - ret = cma_format_hdr((void *) req.private_data, id_priv); - if (ret) - goto out; + if (req.private_data) { + ret = cma_format_hdr((void *) req.private_data, id_priv); + if (ret) + goto out; + } id = ib_create_cm_id(id_priv->id.device, cma_sidr_rep_handler, id_priv); @@ -2720,14 +2726,18 @@ static int cma_connect_ib(struct rdma_id_private *id_priv, int offset, ret; memset(&req, 0, sizeof req); - offset = cma_user_data_offset(id_priv->id.ps); + offset = cma_user_data_offset(id_priv); req.private_data_len = offset + conn_param->private_data_len; if (req.private_data_len < conn_param->private_data_len) return -EINVAL; - private_data = kzalloc(req.private_data_len, GFP_ATOMIC); - if (!private_data) - return -ENOMEM; + if (req.private_data_len) { + private_data = kzalloc(req.private_data_len, GFP_ATOMIC); + if (!private_data) + return -ENOMEM; + } else { + private_data = NULL; + } if (conn_param->private_data && conn_param->private_data_len) memcpy(private_data + offset, conn_param->private_data, @@ -2741,10 +2751,12 @@ static int cma_connect_ib(struct rdma_id_private *id_priv, id_priv->cm_id.ib = id; route = &id_priv->id.route; - ret = cma_format_hdr(private_data, id_priv); - if (ret) - goto out; - req.private_data = private_data; + if (private_data) { + ret = cma_format_hdr(private_data, id_priv); + if (ret) + goto out; + req.private_data = private_data; + } req.primary_path = &route->path_rec[0]; if (route->num_paths == 2) From 5c438135adf90b33cb00e5351becf1e557bbdd9d Mon Sep 17 00:00:00 2001 From: Sean Hefty Date: Wed, 29 May 2013 10:09:23 -0700 Subject: [PATCH 0360/1048] RDMA/cma: Set qkey for AF_IB Allow the user to specify the qkey when using AF_IB. The qkey is added to struct rdma_ucm_conn_param in place of a reserved field, but for backwards compatability, is only accessed if the associated rdma_cm_id is using AF_IB. Signed-off-by: Sean Hefty Signed-off-by: Roland Dreier --- drivers/infiniband/core/cma.c | 35 +++++++++++++++++++------------- drivers/infiniband/core/ucma.c | 8 +++++--- include/rdma/rdma_cm.h | 1 + include/uapi/rdma/rdma_user_cm.h | 2 +- 4 files changed, 28 insertions(+), 18 deletions(-) diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c index 7a9b033e37ce..96d0b9a6e15e 100644 --- a/drivers/infiniband/core/cma.c +++ b/drivers/infiniband/core/cma.c @@ -293,16 +293,25 @@ static inline unsigned short cma_family(struct rdma_id_private *id_priv) return id_priv->id.route.addr.src_addr.ss_family; } -static int cma_set_qkey(struct rdma_id_private *id_priv) +static int cma_set_qkey(struct rdma_id_private *id_priv, u32 qkey) { struct ib_sa_mcmember_rec rec; int ret = 0; - if (id_priv->qkey) + if (id_priv->qkey) { + if (qkey && id_priv->qkey != qkey) + return -EINVAL; return 0; + } + + if (qkey) { + id_priv->qkey = qkey; + return 0; + } switch (id_priv->id.ps) { case RDMA_PS_UDP: + case RDMA_PS_IB: id_priv->qkey = RDMA_UDP_QKEY; break; case RDMA_PS_IPOIB: @@ -689,7 +698,7 @@ static int cma_ib_init_qp_attr(struct rdma_id_private *id_priv, *qp_attr_mask = IB_QP_STATE | IB_QP_PKEY_INDEX | IB_QP_PORT; if (id_priv->id.qp_type == IB_QPT_UD) { - ret = cma_set_qkey(id_priv); + ret = cma_set_qkey(id_priv, 0); if (ret) return ret; @@ -2624,15 +2633,10 @@ static int cma_sidr_rep_handler(struct ib_cm_id *cm_id, event.status = ib_event->param.sidr_rep_rcvd.status; break; } - ret = cma_set_qkey(id_priv); + ret = cma_set_qkey(id_priv, rep->qkey); if (ret) { event.event = RDMA_CM_EVENT_ADDR_ERROR; - event.status = -EINVAL; - break; - } - if (id_priv->qkey != rep->qkey) { - event.event = RDMA_CM_EVENT_UNREACHABLE; - event.status = -EINVAL; + event.status = ret; break; } ib_init_ah_from_path(id_priv->id.device, id_priv->id.port_num, @@ -2922,7 +2926,7 @@ static int cma_accept_iw(struct rdma_id_private *id_priv, } static int cma_send_sidr_rep(struct rdma_id_private *id_priv, - enum ib_cm_sidr_status status, + enum ib_cm_sidr_status status, u32 qkey, const void *private_data, int private_data_len) { struct ib_cm_sidr_rep_param rep; @@ -2931,7 +2935,7 @@ static int cma_send_sidr_rep(struct rdma_id_private *id_priv, memset(&rep, 0, sizeof rep); rep.status = status; if (status == IB_SIDR_SUCCESS) { - ret = cma_set_qkey(id_priv); + ret = cma_set_qkey(id_priv, qkey); if (ret) return ret; rep.qp_num = id_priv->qp_num; @@ -2965,11 +2969,12 @@ int rdma_accept(struct rdma_cm_id *id, struct rdma_conn_param *conn_param) if (id->qp_type == IB_QPT_UD) { if (conn_param) ret = cma_send_sidr_rep(id_priv, IB_SIDR_SUCCESS, + conn_param->qkey, conn_param->private_data, conn_param->private_data_len); else ret = cma_send_sidr_rep(id_priv, IB_SIDR_SUCCESS, - NULL, 0); + 0, NULL, 0); } else { if (conn_param) ret = cma_accept_ib(id_priv, conn_param); @@ -3030,7 +3035,7 @@ int rdma_reject(struct rdma_cm_id *id, const void *private_data, switch (rdma_node_get_transport(id->device->node_type)) { case RDMA_TRANSPORT_IB: if (id->qp_type == IB_QPT_UD) - ret = cma_send_sidr_rep(id_priv, IB_SIDR_REJECT, + ret = cma_send_sidr_rep(id_priv, IB_SIDR_REJECT, 0, private_data, private_data_len); else ret = ib_send_cm_rej(id_priv->cm_id.ib, @@ -3091,6 +3096,8 @@ static int cma_ib_mc_handler(int status, struct ib_sa_multicast *multicast) cma_disable_callback(id_priv, RDMA_CM_ADDR_RESOLVED)) return 0; + if (!status) + status = cma_set_qkey(id_priv, be32_to_cpu(multicast->rec.qkey)); mutex_lock(&id_priv->qp_mutex); if (!status && id_priv->id.qp) status = ib_attach_mcast(id_priv->id.qp, &multicast->rec.mgid, diff --git a/drivers/infiniband/core/ucma.c b/drivers/infiniband/core/ucma.c index 5ca44cd9b00c..e813774bf7a7 100644 --- a/drivers/infiniband/core/ucma.c +++ b/drivers/infiniband/core/ucma.c @@ -709,7 +709,8 @@ out: return ret; } -static void ucma_copy_conn_param(struct rdma_conn_param *dst, +static void ucma_copy_conn_param(struct rdma_cm_id *id, + struct rdma_conn_param *dst, struct rdma_ucm_conn_param *src) { dst->private_data = src->private_data; @@ -721,6 +722,7 @@ static void ucma_copy_conn_param(struct rdma_conn_param *dst, dst->rnr_retry_count = src->rnr_retry_count; dst->srq = src->srq; dst->qp_num = src->qp_num; + dst->qkey = (id->route.addr.src_addr.ss_family == AF_IB) ? src->qkey : 0; } static ssize_t ucma_connect(struct ucma_file *file, const char __user *inbuf, @@ -741,7 +743,7 @@ static ssize_t ucma_connect(struct ucma_file *file, const char __user *inbuf, if (IS_ERR(ctx)) return PTR_ERR(ctx); - ucma_copy_conn_param(&conn_param, &cmd.conn_param); + ucma_copy_conn_param(ctx->cm_id, &conn_param, &cmd.conn_param); ret = rdma_connect(ctx->cm_id, &conn_param); ucma_put_ctx(ctx); return ret; @@ -784,7 +786,7 @@ static ssize_t ucma_accept(struct ucma_file *file, const char __user *inbuf, return PTR_ERR(ctx); if (cmd.conn_param.valid) { - ucma_copy_conn_param(&conn_param, &cmd.conn_param); + ucma_copy_conn_param(ctx->cm_id, &conn_param, &cmd.conn_param); mutex_lock(&file->mut); ret = rdma_accept(ctx->cm_id, &conn_param); if (!ret) diff --git a/include/rdma/rdma_cm.h b/include/rdma/rdma_cm.h index 1e6c3c7af898..966f90ba8d8a 100644 --- a/include/rdma/rdma_cm.h +++ b/include/rdma/rdma_cm.h @@ -98,6 +98,7 @@ struct rdma_conn_param { /* Fields below ignored if a QP is created on the rdma_cm_id. */ u8 srq; u32 qp_num; + u32 qkey; }; struct rdma_ud_param { diff --git a/include/uapi/rdma/rdma_user_cm.h b/include/uapi/rdma/rdma_user_cm.h index 1ee9239ff8c2..29de08f603ac 100644 --- a/include/uapi/rdma/rdma_user_cm.h +++ b/include/uapi/rdma/rdma_user_cm.h @@ -131,7 +131,7 @@ struct rdma_ucm_query_route_resp { struct rdma_ucm_conn_param { __u32 qp_num; - __u32 reserved; + __u32 qkey; __u8 private_data[RDMA_MAX_PRIVATE_DATA]; __u8 private_data_len; __u8 srq; From 94d0c939416480066d4e4d69e0d3c217bc083cea Mon Sep 17 00:00:00 2001 From: Sean Hefty Date: Wed, 29 May 2013 10:09:24 -0700 Subject: [PATCH 0361/1048] RDMA/cma: Only listen on IB devices when using AF_IB If an rdma_cm_id is bound to AF_IB, with a wild card address, only listen on IB devices. Signed-off-by: Sean Hefty Signed-off-by: Roland Dreier --- drivers/infiniband/core/cma.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c index 96d0b9a6e15e..6a0ee9265015 100644 --- a/drivers/infiniband/core/cma.c +++ b/drivers/infiniband/core/cma.c @@ -1616,6 +1616,10 @@ static void cma_listen_on_dev(struct rdma_id_private *id_priv, struct rdma_cm_id *id; int ret; + if (cma_family(id_priv) == AF_IB && + rdma_node_get_transport(cma_dev->device->node_type) != RDMA_TRANSPORT_IB) + return; + id = rdma_create_id(cma_listen_handler, id_priv, id_priv->id.ps, id_priv->id.qp_type); if (IS_ERR(id)) From ee7aed4528fb3c44a36abd79eb23fd5401a5b697 Mon Sep 17 00:00:00 2001 From: Sean Hefty Date: Wed, 29 May 2013 10:09:25 -0700 Subject: [PATCH 0362/1048] RDMA/ucma: Support querying for AF_IB addresses The sockaddr structure for AF_IB is larger than sockaddr_in6. The rdma cm user space ABI uses the latter to exchange address information between user space and the kernel. To support querying for larger addresses, define a new query command that exchanges data using sockaddr_storage, rather than sockaddr_in6. Unlike the existing query_route command, the new command only returns address information. Route (i.e. path record) data is separated. Signed-off-by: Sean Hefty Signed-off-by: Roland Dreier --- drivers/infiniband/core/ucma.c | 76 +++++++++++++++++++++++++++++++- include/uapi/rdma/rdma_user_cm.h | 22 +++++++-- 2 files changed, 93 insertions(+), 5 deletions(-) diff --git a/drivers/infiniband/core/ucma.c b/drivers/infiniband/core/ucma.c index e813774bf7a7..18bdccc0c2ec 100644 --- a/drivers/infiniband/core/ucma.c +++ b/drivers/infiniband/core/ucma.c @@ -47,6 +47,7 @@ #include #include #include +#include MODULE_AUTHOR("Sean Hefty"); MODULE_DESCRIPTION("RDMA Userspace Connection Manager Access"); @@ -649,7 +650,7 @@ static ssize_t ucma_query_route(struct ucma_file *file, const char __user *inbuf, int in_len, int out_len) { - struct rdma_ucm_query_route cmd; + struct rdma_ucm_query cmd; struct rdma_ucm_query_route_resp resp; struct ucma_context *ctx; struct sockaddr *addr; @@ -709,6 +710,76 @@ out: return ret; } +static void ucma_query_device_addr(struct rdma_cm_id *cm_id, + struct rdma_ucm_query_addr_resp *resp) +{ + if (!cm_id->device) + return; + + resp->node_guid = (__force __u64) cm_id->device->node_guid; + resp->port_num = cm_id->port_num; + resp->pkey = (__force __u16) cpu_to_be16( + ib_addr_get_pkey(&cm_id->route.addr.dev_addr)); +} + +static ssize_t ucma_query_addr(struct ucma_context *ctx, + void __user *response, int out_len) +{ + struct rdma_ucm_query_addr_resp resp; + struct sockaddr *addr; + int ret = 0; + + if (out_len < sizeof(resp)) + return -ENOSPC; + + memset(&resp, 0, sizeof resp); + + addr = (struct sockaddr *) &ctx->cm_id->route.addr.src_addr; + resp.src_size = rdma_addr_size(addr); + memcpy(&resp.src_addr, addr, resp.src_size); + + addr = (struct sockaddr *) &ctx->cm_id->route.addr.dst_addr; + resp.dst_size = rdma_addr_size(addr); + memcpy(&resp.dst_addr, addr, resp.dst_size); + + ucma_query_device_addr(ctx->cm_id, &resp); + + if (copy_to_user(response, &resp, sizeof(resp))) + ret = -EFAULT; + + return ret; +} + +static ssize_t ucma_query(struct ucma_file *file, + const char __user *inbuf, + int in_len, int out_len) +{ + struct rdma_ucm_query cmd; + struct ucma_context *ctx; + void __user *response; + int ret; + + if (copy_from_user(&cmd, inbuf, sizeof(cmd))) + return -EFAULT; + + response = (void __user *)(unsigned long) cmd.response; + ctx = ucma_get_ctx(file, cmd.id); + if (IS_ERR(ctx)) + return PTR_ERR(ctx); + + switch (cmd.option) { + case RDMA_USER_CM_QUERY_ADDR: + ret = ucma_query_addr(ctx, response, out_len); + break; + default: + ret = -ENOSYS; + break; + } + + ucma_put_ctx(ctx); + return ret; +} + static void ucma_copy_conn_param(struct rdma_cm_id *id, struct rdma_conn_param *dst, struct rdma_ucm_conn_param *src) @@ -1241,7 +1312,8 @@ static ssize_t (*ucma_cmd_table[])(struct ucma_file *file, [RDMA_USER_CM_CMD_NOTIFY] = ucma_notify, [RDMA_USER_CM_CMD_JOIN_MCAST] = ucma_join_multicast, [RDMA_USER_CM_CMD_LEAVE_MCAST] = ucma_leave_multicast, - [RDMA_USER_CM_CMD_MIGRATE_ID] = ucma_migrate_id + [RDMA_USER_CM_CMD_MIGRATE_ID] = ucma_migrate_id, + [RDMA_USER_CM_CMD_QUERY] = ucma_query }; static ssize_t ucma_write(struct file *filp, const char __user *buf, diff --git a/include/uapi/rdma/rdma_user_cm.h b/include/uapi/rdma/rdma_user_cm.h index 29de08f603ac..3ea7e7a4d54b 100644 --- a/include/uapi/rdma/rdma_user_cm.h +++ b/include/uapi/rdma/rdma_user_cm.h @@ -61,7 +61,8 @@ enum { RDMA_USER_CM_CMD_NOTIFY, RDMA_USER_CM_CMD_JOIN_MCAST, RDMA_USER_CM_CMD_LEAVE_MCAST, - RDMA_USER_CM_CMD_MIGRATE_ID + RDMA_USER_CM_CMD_MIGRATE_ID, + RDMA_USER_CM_CMD_QUERY }; /* @@ -113,10 +114,14 @@ struct rdma_ucm_resolve_route { __u32 timeout_ms; }; -struct rdma_ucm_query_route { +enum { + RDMA_USER_CM_QUERY_ADDR +}; + +struct rdma_ucm_query { __u64 response; __u32 id; - __u32 reserved; + __u32 option; }; struct rdma_ucm_query_route_resp { @@ -129,6 +134,17 @@ struct rdma_ucm_query_route_resp { __u8 reserved[3]; }; +struct rdma_ucm_query_addr_resp { + __u64 node_guid; + __u8 port_num; + __u8 reserved; + __u16 pkey; + __u16 src_size; + __u16 dst_size; + struct sockaddr_storage src_addr; + struct sockaddr_storage dst_addr; +}; + struct rdma_ucm_conn_param { __u32 qp_num; __u32 qkey; From 2e08b5879e9244fa893fe09f5b887f72f4e6c29b Mon Sep 17 00:00:00 2001 From: Sean Hefty Date: Wed, 29 May 2013 10:09:26 -0700 Subject: [PATCH 0363/1048] IB/sa: Export function to pack a path record into wire format Allow converting from struct ib_sa_path_rec to the IB defined SA path record wire format. This will be used to report path data from the rdma cm into user space. Signed-off-by: Sean Hefty Signed-off-by: Roland Dreier --- drivers/infiniband/core/sa_query.c | 6 ++++++ include/rdma/ib_sa.h | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/drivers/infiniband/core/sa_query.c b/drivers/infiniband/core/sa_query.c index 934f45e79e5e..9838ca484389 100644 --- a/drivers/infiniband/core/sa_query.c +++ b/drivers/infiniband/core/sa_query.c @@ -652,6 +652,12 @@ void ib_sa_unpack_path(void *attribute, struct ib_sa_path_rec *rec) } EXPORT_SYMBOL(ib_sa_unpack_path); +void ib_sa_pack_path(struct ib_sa_path_rec *rec, void *attribute) +{ + ib_pack(path_rec_table, ARRAY_SIZE(path_rec_table), rec, attribute); +} +EXPORT_SYMBOL(ib_sa_pack_path); + static void ib_sa_path_rec_callback(struct ib_sa_query *sa_query, int status, struct ib_sa_mad *mad) diff --git a/include/rdma/ib_sa.h b/include/rdma/ib_sa.h index 8275e539bace..125f8714301d 100644 --- a/include/rdma/ib_sa.h +++ b/include/rdma/ib_sa.h @@ -401,6 +401,12 @@ int ib_init_ah_from_path(struct ib_device *device, u8 port_num, struct ib_sa_path_rec *rec, struct ib_ah_attr *ah_attr); +/** + * ib_sa_pack_path - Conert a path record from struct ib_sa_path_rec + * to IB MAD wire format. + */ +void ib_sa_pack_path(struct ib_sa_path_rec *rec, void *attribute); + /** * ib_sa_unpack_path - Convert a path record from MAD format to struct * ib_sa_path_rec. @@ -418,4 +424,5 @@ int ib_sa_guid_info_rec_query(struct ib_sa_client *client, void *context), void *context, struct ib_sa_query **sa_query); + #endif /* IB_SA_H */ From ac53b264b2f39e89781e3b855008123dfdb44aea Mon Sep 17 00:00:00 2001 From: Sean Hefty Date: Wed, 29 May 2013 10:09:27 -0700 Subject: [PATCH 0364/1048] RDMA/ucma: Support querying when IB paths are not reversible The current query_route call can return up to two path records. The assumption being that one is the primary path, with optional support for an alternate path. In both cases, the paths are assumed to be reversible and are used to send CM MADs. With the ability to manually set IB path data, the rdma cm can eventually be capable of using up to 6 paths per connection: forward primary, reverse primary, forward alternate, reverse alternate, reversible primary path for CM MADs reversible alternate path for CM MADs. (It is unclear at this time if IB routing will complicate this) In order to handle more flexible routing topologies, add a new command to report any number of paths. Signed-off-by: Sean Hefty Signed-off-by: Roland Dreier --- drivers/infiniband/core/ucma.c | 35 ++++++++++++++++++++++++++++++++ include/uapi/rdma/rdma_user_cm.h | 9 +++++++- 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/drivers/infiniband/core/ucma.c b/drivers/infiniband/core/ucma.c index 18bdccc0c2ec..722f2ff0400f 100644 --- a/drivers/infiniband/core/ucma.c +++ b/drivers/infiniband/core/ucma.c @@ -750,6 +750,38 @@ static ssize_t ucma_query_addr(struct ucma_context *ctx, return ret; } +static ssize_t ucma_query_path(struct ucma_context *ctx, + void __user *response, int out_len) +{ + struct rdma_ucm_query_path_resp *resp; + int i, ret = 0; + + if (out_len < sizeof(*resp)) + return -ENOSPC; + + resp = kzalloc(out_len, GFP_KERNEL); + if (!resp) + return -ENOMEM; + + resp->num_paths = ctx->cm_id->route.num_paths; + for (i = 0, out_len -= sizeof(*resp); + i < resp->num_paths && out_len > sizeof(struct ib_path_rec_data); + i++, out_len -= sizeof(struct ib_path_rec_data)) { + + resp->path_data[i].flags = IB_PATH_GMP | IB_PATH_PRIMARY | + IB_PATH_BIDIRECTIONAL; + ib_sa_pack_path(&ctx->cm_id->route.path_rec[i], + &resp->path_data[i].path_rec); + } + + if (copy_to_user(response, resp, + sizeof(*resp) + (i * sizeof(struct ib_path_rec_data)))) + ret = -EFAULT; + + kfree(resp); + return ret; +} + static ssize_t ucma_query(struct ucma_file *file, const char __user *inbuf, int in_len, int out_len) @@ -771,6 +803,9 @@ static ssize_t ucma_query(struct ucma_file *file, case RDMA_USER_CM_QUERY_ADDR: ret = ucma_query_addr(ctx, response, out_len); break; + case RDMA_USER_CM_QUERY_PATH: + ret = ucma_query_path(ctx, response, out_len); + break; default: ret = -ENOSYS; break; diff --git a/include/uapi/rdma/rdma_user_cm.h b/include/uapi/rdma/rdma_user_cm.h index 3ea7e7a4d54b..07eb6cfa926c 100644 --- a/include/uapi/rdma/rdma_user_cm.h +++ b/include/uapi/rdma/rdma_user_cm.h @@ -115,7 +115,8 @@ struct rdma_ucm_resolve_route { }; enum { - RDMA_USER_CM_QUERY_ADDR + RDMA_USER_CM_QUERY_ADDR, + RDMA_USER_CM_QUERY_PATH }; struct rdma_ucm_query { @@ -145,6 +146,12 @@ struct rdma_ucm_query_addr_resp { struct sockaddr_storage dst_addr; }; +struct rdma_ucm_query_path_resp { + __u32 num_paths; + __u32 reserved; + struct ib_path_rec_data path_data[0]; +}; + struct rdma_ucm_conn_param { __u32 qp_num; __u32 qkey; From cf53936f229d81131fef475919f163ce566a205f Mon Sep 17 00:00:00 2001 From: Sean Hefty Date: Wed, 29 May 2013 10:09:28 -0700 Subject: [PATCH 0365/1048] RDMA/cma: Export cma_get_service_id() Allow the rdma_ucm to query the IB service ID formed or allocated by the rdma_cm by exporting the cma_get_service_id() functionality. Signed-off-by: Sean Hefty Signed-off-by: Roland Dreier --- drivers/infiniband/core/cma.c | 13 +++++++------ include/rdma/rdma_cm.h | 7 +++++++ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c index 6a0ee9265015..32d74c76e638 100644 --- a/drivers/infiniband/core/cma.c +++ b/drivers/infiniband/core/cma.c @@ -1336,13 +1336,14 @@ err1: return ret; } -static __be64 cma_get_service_id(enum rdma_port_space ps, struct sockaddr *addr) +__be64 rdma_get_service_id(struct rdma_cm_id *id, struct sockaddr *addr) { if (addr->sa_family == AF_IB) return ((struct sockaddr_ib *) addr)->sib_sid; - return cpu_to_be64(((u64)ps << 16) + be16_to_cpu(cma_port(addr))); + return cpu_to_be64(((u64)id->ps << 16) + be16_to_cpu(cma_port(addr))); } +EXPORT_SYMBOL(rdma_get_service_id); static void cma_set_compare_data(enum rdma_port_space ps, struct sockaddr *addr, struct ib_cm_compare_data *compare) @@ -1556,7 +1557,7 @@ static int cma_ib_listen(struct rdma_id_private *id_priv) id_priv->cm_id.ib = id; addr = cma_src_addr(id_priv); - svc_id = cma_get_service_id(id_priv->id.ps, addr); + svc_id = rdma_get_service_id(&id_priv->id, addr); if (cma_any_addr(addr) && !id_priv->afonly) ret = ib_cm_listen(id_priv->cm_id.ib, svc_id, 0, NULL); else { @@ -1699,7 +1700,7 @@ static int cma_query_ib_route(struct rdma_id_private *id_priv, int timeout_ms, path_rec.pkey = cpu_to_be16(ib_addr_get_pkey(dev_addr)); path_rec.numb_path = 1; path_rec.reversible = 1; - path_rec.service_id = cma_get_service_id(id_priv->id.ps, cma_dst_addr(id_priv)); + path_rec.service_id = rdma_get_service_id(&id_priv->id, cma_dst_addr(id_priv)); comp_mask = IB_SA_PATH_REC_DGID | IB_SA_PATH_REC_SGID | IB_SA_PATH_REC_PKEY | IB_SA_PATH_REC_NUMB_PATH | @@ -2710,7 +2711,7 @@ static int cma_resolve_ib_udp(struct rdma_id_private *id_priv, id_priv->cm_id.ib = id; req.path = id_priv->id.route.path_rec; - req.service_id = cma_get_service_id(id_priv->id.ps, cma_dst_addr(id_priv)); + req.service_id = rdma_get_service_id(&id_priv->id, cma_dst_addr(id_priv)); req.timeout_ms = 1 << (CMA_CM_RESPONSE_TIMEOUT - 8); req.max_cm_retries = CMA_MAX_CM_RETRIES; @@ -2770,7 +2771,7 @@ static int cma_connect_ib(struct rdma_id_private *id_priv, if (route->num_paths == 2) req.alternate_path = &route->path_rec[1]; - req.service_id = cma_get_service_id(id_priv->id.ps, cma_dst_addr(id_priv)); + req.service_id = rdma_get_service_id(&id_priv->id, cma_dst_addr(id_priv)); req.qp_num = id_priv->qp_num; req.qp_type = id_priv->id.qp_type; req.starting_psn = id_priv->seq_num; diff --git a/include/rdma/rdma_cm.h b/include/rdma/rdma_cm.h index 966f90ba8d8a..1ed2088dc9f5 100644 --- a/include/rdma/rdma_cm.h +++ b/include/rdma/rdma_cm.h @@ -373,4 +373,11 @@ int rdma_set_reuseaddr(struct rdma_cm_id *id, int reuse); */ int rdma_set_afonly(struct rdma_cm_id *id, int afonly); + /** + * rdma_get_service_id - Return the IB service ID for a specified address. + * @id: Communication identifier associated with the address. + * @addr: Address for the service ID. + */ +__be64 rdma_get_service_id(struct rdma_cm_id *id, struct sockaddr *addr); + #endif /* RDMA_CM_H */ From edaa7a5578988bcf12f68f14fb002bc0c87e2801 Mon Sep 17 00:00:00 2001 From: Sean Hefty Date: Wed, 29 May 2013 10:09:29 -0700 Subject: [PATCH 0366/1048] RDMA/ucma: Add ability to query GID addresses Part of address resolution is mapping IP addresses to IB GIDs. With the changes to support querying larger addresses and more path records, also provide a way to query IB GIDs after resolution completes. Signed-off-by: Sean Hefty Signed-off-by: Roland Dreier --- drivers/infiniband/core/ucma.c | 50 ++++++++++++++++++++++++++++++++ include/uapi/rdma/rdma_user_cm.h | 3 +- 2 files changed, 52 insertions(+), 1 deletion(-) diff --git a/drivers/infiniband/core/ucma.c b/drivers/infiniband/core/ucma.c index 722f2ff0400f..45bb052f573e 100644 --- a/drivers/infiniband/core/ucma.c +++ b/drivers/infiniband/core/ucma.c @@ -48,6 +48,7 @@ #include #include #include +#include MODULE_AUTHOR("Sean Hefty"); MODULE_DESCRIPTION("RDMA Userspace Connection Manager Access"); @@ -782,6 +783,52 @@ static ssize_t ucma_query_path(struct ucma_context *ctx, return ret; } +static ssize_t ucma_query_gid(struct ucma_context *ctx, + void __user *response, int out_len) +{ + struct rdma_ucm_query_addr_resp resp; + struct sockaddr_ib *addr; + int ret = 0; + + if (out_len < sizeof(resp)) + return -ENOSPC; + + memset(&resp, 0, sizeof resp); + + ucma_query_device_addr(ctx->cm_id, &resp); + + addr = (struct sockaddr_ib *) &resp.src_addr; + resp.src_size = sizeof(*addr); + if (ctx->cm_id->route.addr.src_addr.ss_family == AF_IB) { + memcpy(addr, &ctx->cm_id->route.addr.src_addr, resp.src_size); + } else { + addr->sib_family = AF_IB; + addr->sib_pkey = (__force __be16) resp.pkey; + rdma_addr_get_sgid(&ctx->cm_id->route.addr.dev_addr, + (union ib_gid *) &addr->sib_addr); + addr->sib_sid = rdma_get_service_id(ctx->cm_id, (struct sockaddr *) + &ctx->cm_id->route.addr.src_addr); + } + + addr = (struct sockaddr_ib *) &resp.dst_addr; + resp.dst_size = sizeof(*addr); + if (ctx->cm_id->route.addr.dst_addr.ss_family == AF_IB) { + memcpy(addr, &ctx->cm_id->route.addr.dst_addr, resp.dst_size); + } else { + addr->sib_family = AF_IB; + addr->sib_pkey = (__force __be16) resp.pkey; + rdma_addr_get_dgid(&ctx->cm_id->route.addr.dev_addr, + (union ib_gid *) &addr->sib_addr); + addr->sib_sid = rdma_get_service_id(ctx->cm_id, (struct sockaddr *) + &ctx->cm_id->route.addr.dst_addr); + } + + if (copy_to_user(response, &resp, sizeof(resp))) + ret = -EFAULT; + + return ret; +} + static ssize_t ucma_query(struct ucma_file *file, const char __user *inbuf, int in_len, int out_len) @@ -806,6 +853,9 @@ static ssize_t ucma_query(struct ucma_file *file, case RDMA_USER_CM_QUERY_PATH: ret = ucma_query_path(ctx, response, out_len); break; + case RDMA_USER_CM_QUERY_GID: + ret = ucma_query_gid(ctx, response, out_len); + break; default: ret = -ENOSYS; break; diff --git a/include/uapi/rdma/rdma_user_cm.h b/include/uapi/rdma/rdma_user_cm.h index 07eb6cfa926c..ea79253ceb13 100644 --- a/include/uapi/rdma/rdma_user_cm.h +++ b/include/uapi/rdma/rdma_user_cm.h @@ -116,7 +116,8 @@ struct rdma_ucm_resolve_route { enum { RDMA_USER_CM_QUERY_ADDR, - RDMA_USER_CM_QUERY_PATH + RDMA_USER_CM_QUERY_PATH, + RDMA_USER_CM_QUERY_GID }; struct rdma_ucm_query { From 05ad94577ecd5a101889d04aa099b738ec5ee34f Mon Sep 17 00:00:00 2001 From: Sean Hefty Date: Wed, 29 May 2013 10:09:30 -0700 Subject: [PATCH 0367/1048] RDMA/ucma: Name changes to indicate only IP addresses supported Several commands into the RDMA CM from user space are restricted to supporting addresses which fit into a sockaddr_in6 structure: bind address, resolve address, and join multicast. With the addition of AF_IB, we need to support addresses which are larger than sockaddr_in6. This will be done by adding new commands that exchange address information using sockaddr_storage. However, to support existing applications, we maintain the current commands and structures, but rename them to indicate that they only support IPv4 and v6 addresses. Signed-off-by: Sean Hefty Signed-off-by: Roland Dreier --- drivers/infiniband/core/ucma.c | 60 ++++++++++++++++---------------- include/uapi/rdma/rdma_user_cm.h | 12 +++---- 2 files changed, 36 insertions(+), 36 deletions(-) diff --git a/drivers/infiniband/core/ucma.c b/drivers/infiniband/core/ucma.c index 45bb052f573e..82fb1e6e1384 100644 --- a/drivers/infiniband/core/ucma.c +++ b/drivers/infiniband/core/ucma.c @@ -512,10 +512,10 @@ static ssize_t ucma_destroy_id(struct ucma_file *file, const char __user *inbuf, return ret; } -static ssize_t ucma_bind_addr(struct ucma_file *file, const char __user *inbuf, +static ssize_t ucma_bind_ip(struct ucma_file *file, const char __user *inbuf, int in_len, int out_len) { - struct rdma_ucm_bind_addr cmd; + struct rdma_ucm_bind_ip cmd; struct ucma_context *ctx; int ret; @@ -531,11 +531,11 @@ static ssize_t ucma_bind_addr(struct ucma_file *file, const char __user *inbuf, return ret; } -static ssize_t ucma_resolve_addr(struct ucma_file *file, - const char __user *inbuf, - int in_len, int out_len) +static ssize_t ucma_resolve_ip(struct ucma_file *file, + const char __user *inbuf, + int in_len, int out_len) { - struct rdma_ucm_resolve_addr cmd; + struct rdma_ucm_resolve_ip cmd; struct ucma_context *ctx; int ret; @@ -1178,11 +1178,11 @@ static ssize_t ucma_notify(struct ucma_file *file, const char __user *inbuf, return ret; } -static ssize_t ucma_join_multicast(struct ucma_file *file, - const char __user *inbuf, - int in_len, int out_len) +static ssize_t ucma_join_ip_multicast(struct ucma_file *file, + const char __user *inbuf, + int in_len, int out_len) { - struct rdma_ucm_join_mcast cmd; + struct rdma_ucm_join_ip_mcast cmd; struct rdma_ucm_create_id_resp resp; struct ucma_context *ctx; struct ucma_multicast *mc; @@ -1379,26 +1379,26 @@ file_put: static ssize_t (*ucma_cmd_table[])(struct ucma_file *file, const char __user *inbuf, int in_len, int out_len) = { - [RDMA_USER_CM_CMD_CREATE_ID] = ucma_create_id, - [RDMA_USER_CM_CMD_DESTROY_ID] = ucma_destroy_id, - [RDMA_USER_CM_CMD_BIND_ADDR] = ucma_bind_addr, - [RDMA_USER_CM_CMD_RESOLVE_ADDR] = ucma_resolve_addr, - [RDMA_USER_CM_CMD_RESOLVE_ROUTE]= ucma_resolve_route, - [RDMA_USER_CM_CMD_QUERY_ROUTE] = ucma_query_route, - [RDMA_USER_CM_CMD_CONNECT] = ucma_connect, - [RDMA_USER_CM_CMD_LISTEN] = ucma_listen, - [RDMA_USER_CM_CMD_ACCEPT] = ucma_accept, - [RDMA_USER_CM_CMD_REJECT] = ucma_reject, - [RDMA_USER_CM_CMD_DISCONNECT] = ucma_disconnect, - [RDMA_USER_CM_CMD_INIT_QP_ATTR] = ucma_init_qp_attr, - [RDMA_USER_CM_CMD_GET_EVENT] = ucma_get_event, - [RDMA_USER_CM_CMD_GET_OPTION] = NULL, - [RDMA_USER_CM_CMD_SET_OPTION] = ucma_set_option, - [RDMA_USER_CM_CMD_NOTIFY] = ucma_notify, - [RDMA_USER_CM_CMD_JOIN_MCAST] = ucma_join_multicast, - [RDMA_USER_CM_CMD_LEAVE_MCAST] = ucma_leave_multicast, - [RDMA_USER_CM_CMD_MIGRATE_ID] = ucma_migrate_id, - [RDMA_USER_CM_CMD_QUERY] = ucma_query + [RDMA_USER_CM_CMD_CREATE_ID] = ucma_create_id, + [RDMA_USER_CM_CMD_DESTROY_ID] = ucma_destroy_id, + [RDMA_USER_CM_CMD_BIND_IP] = ucma_bind_ip, + [RDMA_USER_CM_CMD_RESOLVE_IP] = ucma_resolve_ip, + [RDMA_USER_CM_CMD_RESOLVE_ROUTE] = ucma_resolve_route, + [RDMA_USER_CM_CMD_QUERY_ROUTE] = ucma_query_route, + [RDMA_USER_CM_CMD_CONNECT] = ucma_connect, + [RDMA_USER_CM_CMD_LISTEN] = ucma_listen, + [RDMA_USER_CM_CMD_ACCEPT] = ucma_accept, + [RDMA_USER_CM_CMD_REJECT] = ucma_reject, + [RDMA_USER_CM_CMD_DISCONNECT] = ucma_disconnect, + [RDMA_USER_CM_CMD_INIT_QP_ATTR] = ucma_init_qp_attr, + [RDMA_USER_CM_CMD_GET_EVENT] = ucma_get_event, + [RDMA_USER_CM_CMD_GET_OPTION] = NULL, + [RDMA_USER_CM_CMD_SET_OPTION] = ucma_set_option, + [RDMA_USER_CM_CMD_NOTIFY] = ucma_notify, + [RDMA_USER_CM_CMD_JOIN_IP_MCAST] = ucma_join_ip_multicast, + [RDMA_USER_CM_CMD_LEAVE_MCAST] = ucma_leave_multicast, + [RDMA_USER_CM_CMD_MIGRATE_ID] = ucma_migrate_id, + [RDMA_USER_CM_CMD_QUERY] = ucma_query }; static ssize_t ucma_write(struct file *filp, const char __user *buf, diff --git a/include/uapi/rdma/rdma_user_cm.h b/include/uapi/rdma/rdma_user_cm.h index ea79253ceb13..79f68f7c9fd2 100644 --- a/include/uapi/rdma/rdma_user_cm.h +++ b/include/uapi/rdma/rdma_user_cm.h @@ -45,8 +45,8 @@ enum { RDMA_USER_CM_CMD_CREATE_ID, RDMA_USER_CM_CMD_DESTROY_ID, - RDMA_USER_CM_CMD_BIND_ADDR, - RDMA_USER_CM_CMD_RESOLVE_ADDR, + RDMA_USER_CM_CMD_BIND_IP, + RDMA_USER_CM_CMD_RESOLVE_IP, RDMA_USER_CM_CMD_RESOLVE_ROUTE, RDMA_USER_CM_CMD_QUERY_ROUTE, RDMA_USER_CM_CMD_CONNECT, @@ -59,7 +59,7 @@ enum { RDMA_USER_CM_CMD_GET_OPTION, RDMA_USER_CM_CMD_SET_OPTION, RDMA_USER_CM_CMD_NOTIFY, - RDMA_USER_CM_CMD_JOIN_MCAST, + RDMA_USER_CM_CMD_JOIN_IP_MCAST, RDMA_USER_CM_CMD_LEAVE_MCAST, RDMA_USER_CM_CMD_MIGRATE_ID, RDMA_USER_CM_CMD_QUERY @@ -96,13 +96,13 @@ struct rdma_ucm_destroy_id_resp { __u32 events_reported; }; -struct rdma_ucm_bind_addr { +struct rdma_ucm_bind_ip { __u64 response; struct sockaddr_in6 addr; __u32 id; }; -struct rdma_ucm_resolve_addr { +struct rdma_ucm_resolve_ip { struct sockaddr_in6 src_addr; struct sockaddr_in6 dst_addr; __u32 id; @@ -216,7 +216,7 @@ struct rdma_ucm_notify { __u32 event; }; -struct rdma_ucm_join_mcast { +struct rdma_ucm_join_ip_mcast { __u64 response; /* rdma_ucm_create_id_resp */ __u64 uid; struct sockaddr_in6 addr; From eebe4c3a62aadb64ba30bde97b96d656e369d934 Mon Sep 17 00:00:00 2001 From: Sean Hefty Date: Wed, 29 May 2013 10:09:31 -0700 Subject: [PATCH 0368/1048] RDMA/ucma: Allow user space to bind to AF_IB Support user space binding to addresses using AF_IB. Since sockaddr_ib is larger than sockaddr_in6, we need to define a larger structure when binding using AF_IB. This time we use sockaddr_storage to cover future cases. Signed-off-by: Sean Hefty Signed-off-by: Roland Dreier --- drivers/infiniband/core/ucma.c | 27 ++++++++++++++++++++++++++- include/uapi/rdma/rdma_user_cm.h | 10 +++++++++- 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/drivers/infiniband/core/ucma.c b/drivers/infiniband/core/ucma.c index 82fb1e6e1384..22ed97ef7da3 100644 --- a/drivers/infiniband/core/ucma.c +++ b/drivers/infiniband/core/ucma.c @@ -531,6 +531,30 @@ static ssize_t ucma_bind_ip(struct ucma_file *file, const char __user *inbuf, return ret; } +static ssize_t ucma_bind(struct ucma_file *file, const char __user *inbuf, + int in_len, int out_len) +{ + struct rdma_ucm_bind cmd; + struct sockaddr *addr; + struct ucma_context *ctx; + int ret; + + if (copy_from_user(&cmd, inbuf, sizeof(cmd))) + return -EFAULT; + + addr = (struct sockaddr *) &cmd.addr; + if (cmd.reserved || !cmd.addr_size || (cmd.addr_size != rdma_addr_size(addr))) + return -EINVAL; + + ctx = ucma_get_ctx(file, cmd.id); + if (IS_ERR(ctx)) + return PTR_ERR(ctx); + + ret = rdma_bind_addr(ctx->cm_id, addr); + ucma_put_ctx(ctx); + return ret; +} + static ssize_t ucma_resolve_ip(struct ucma_file *file, const char __user *inbuf, int in_len, int out_len) @@ -1398,7 +1422,8 @@ static ssize_t (*ucma_cmd_table[])(struct ucma_file *file, [RDMA_USER_CM_CMD_JOIN_IP_MCAST] = ucma_join_ip_multicast, [RDMA_USER_CM_CMD_LEAVE_MCAST] = ucma_leave_multicast, [RDMA_USER_CM_CMD_MIGRATE_ID] = ucma_migrate_id, - [RDMA_USER_CM_CMD_QUERY] = ucma_query + [RDMA_USER_CM_CMD_QUERY] = ucma_query, + [RDMA_USER_CM_CMD_BIND] = ucma_bind }; static ssize_t ucma_write(struct file *filp, const char __user *buf, diff --git a/include/uapi/rdma/rdma_user_cm.h b/include/uapi/rdma/rdma_user_cm.h index 79f68f7c9fd2..895a427bfc91 100644 --- a/include/uapi/rdma/rdma_user_cm.h +++ b/include/uapi/rdma/rdma_user_cm.h @@ -62,7 +62,8 @@ enum { RDMA_USER_CM_CMD_JOIN_IP_MCAST, RDMA_USER_CM_CMD_LEAVE_MCAST, RDMA_USER_CM_CMD_MIGRATE_ID, - RDMA_USER_CM_CMD_QUERY + RDMA_USER_CM_CMD_QUERY, + RDMA_USER_CM_CMD_BIND }; /* @@ -102,6 +103,13 @@ struct rdma_ucm_bind_ip { __u32 id; }; +struct rdma_ucm_bind { + __u32 id; + __u16 addr_size; + __u16 reserved; + struct sockaddr_storage addr; +}; + struct rdma_ucm_resolve_ip { struct sockaddr_in6 src_addr; struct sockaddr_in6 dst_addr; From 209cf2a751f9ff2a516102339e54fcac0176fa78 Mon Sep 17 00:00:00 2001 From: Sean Hefty Date: Wed, 29 May 2013 10:09:32 -0700 Subject: [PATCH 0369/1048] RDMA/ucma: Allow user space to pass AF_IB into resolve Allow user space applications to call resolve_addr using AF_IB. To support sockaddr_ib, we need to define a new structure capable of handling the larger address size. Signed-off-by: Sean Hefty Signed-off-by: Roland Dreier --- drivers/infiniband/core/ucma.c | 30 +++++++++++++++++++++++++++++- include/uapi/rdma/rdma_user_cm.h | 13 ++++++++++++- 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/drivers/infiniband/core/ucma.c b/drivers/infiniband/core/ucma.c index 22ed97ef7da3..00ce99044a48 100644 --- a/drivers/infiniband/core/ucma.c +++ b/drivers/infiniband/core/ucma.c @@ -577,6 +577,33 @@ static ssize_t ucma_resolve_ip(struct ucma_file *file, return ret; } +static ssize_t ucma_resolve_addr(struct ucma_file *file, + const char __user *inbuf, + int in_len, int out_len) +{ + struct rdma_ucm_resolve_addr cmd; + struct sockaddr *src, *dst; + struct ucma_context *ctx; + int ret; + + if (copy_from_user(&cmd, inbuf, sizeof(cmd))) + return -EFAULT; + + src = (struct sockaddr *) &cmd.src_addr; + dst = (struct sockaddr *) &cmd.dst_addr; + if (cmd.reserved || (cmd.src_size && (cmd.src_size != rdma_addr_size(src))) || + !cmd.dst_size || (cmd.dst_size != rdma_addr_size(dst))) + return -EINVAL; + + ctx = ucma_get_ctx(file, cmd.id); + if (IS_ERR(ctx)) + return PTR_ERR(ctx); + + ret = rdma_resolve_addr(ctx->cm_id, src, dst, cmd.timeout_ms); + ucma_put_ctx(ctx); + return ret; +} + static ssize_t ucma_resolve_route(struct ucma_file *file, const char __user *inbuf, int in_len, int out_len) @@ -1423,7 +1450,8 @@ static ssize_t (*ucma_cmd_table[])(struct ucma_file *file, [RDMA_USER_CM_CMD_LEAVE_MCAST] = ucma_leave_multicast, [RDMA_USER_CM_CMD_MIGRATE_ID] = ucma_migrate_id, [RDMA_USER_CM_CMD_QUERY] = ucma_query, - [RDMA_USER_CM_CMD_BIND] = ucma_bind + [RDMA_USER_CM_CMD_BIND] = ucma_bind, + [RDMA_USER_CM_CMD_RESOLVE_ADDR] = ucma_resolve_addr }; static ssize_t ucma_write(struct file *filp, const char __user *buf, diff --git a/include/uapi/rdma/rdma_user_cm.h b/include/uapi/rdma/rdma_user_cm.h index 895a427bfc91..6d03f9c16f1e 100644 --- a/include/uapi/rdma/rdma_user_cm.h +++ b/include/uapi/rdma/rdma_user_cm.h @@ -63,7 +63,8 @@ enum { RDMA_USER_CM_CMD_LEAVE_MCAST, RDMA_USER_CM_CMD_MIGRATE_ID, RDMA_USER_CM_CMD_QUERY, - RDMA_USER_CM_CMD_BIND + RDMA_USER_CM_CMD_BIND, + RDMA_USER_CM_CMD_RESOLVE_ADDR }; /* @@ -117,6 +118,16 @@ struct rdma_ucm_resolve_ip { __u32 timeout_ms; }; +struct rdma_ucm_resolve_addr { + __u32 id; + __u32 timeout_ms; + __u16 src_size; + __u16 dst_size; + __u32 reserved; + struct sockaddr_storage src_addr; + struct sockaddr_storage dst_addr; +}; + struct rdma_ucm_resolve_route { __u32 id; __u32 timeout_ms; From 5bc2b7b397b02026a0596a7807443a18422733fa Mon Sep 17 00:00:00 2001 From: Sean Hefty Date: Wed, 29 May 2013 10:09:33 -0700 Subject: [PATCH 0370/1048] RDMA/ucma: Allow user space to specify AF_IB when joining multicast Allow user space applications to join multicast groups using MGIDs directly. MGIDs may be passed using AF_IB addresses. Since the current multicast join command only supports addresses as large as sockaddr_in6, define a new structure for joining addresses specified using sockaddr_ib. Since AF_IB allows the user to specify the qkey when resolving a remote UD QP address, when joining the multicast group use the qkey value, if one has been assigned. Signed-off-by: Sean Hefty Signed-off-by: Roland Dreier --- drivers/infiniband/core/cma.c | 9 ++++-- drivers/infiniband/core/ucma.c | 55 +++++++++++++++++++++++++------- include/uapi/rdma/rdma_user_cm.h | 12 ++++++- 3 files changed, 62 insertions(+), 14 deletions(-) diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c index 32d74c76e638..3d30c388e043 100644 --- a/drivers/infiniband/core/cma.c +++ b/drivers/infiniband/core/cma.c @@ -3149,6 +3149,8 @@ static void cma_set_mgid(struct rdma_id_private *id_priv, 0xFF10A01B)) { /* IPv6 address is an SA assigned MGID. */ memcpy(mgid, &sin6->sin6_addr, sizeof *mgid); + } else if (addr->sa_family == AF_IB) { + memcpy(mgid, &((struct sockaddr_ib *) addr)->sib_addr, sizeof *mgid); } else if ((addr->sa_family == AF_INET6)) { ipv6_ib_mc_map(&sin6->sin6_addr, dev_addr->broadcast, mc_map); if (id_priv->id.ps == RDMA_PS_UDP) @@ -3176,9 +3178,12 @@ static int cma_join_ib_multicast(struct rdma_id_private *id_priv, if (ret) return ret; + ret = cma_set_qkey(id_priv, 0); + if (ret) + return ret; + cma_set_mgid(id_priv, (struct sockaddr *) &mc->addr, &rec.mgid); - if (id_priv->id.ps == RDMA_PS_UDP) - rec.qkey = cpu_to_be32(RDMA_UDP_QKEY); + rec.qkey = cpu_to_be32(id_priv->qkey); rdma_addr_get_sgid(dev_addr, &rec.port_gid); rec.pkey = cpu_to_be16(ib_addr_get_pkey(dev_addr)); rec.join_state = 1; diff --git a/drivers/infiniband/core/ucma.c b/drivers/infiniband/core/ucma.c index 00ce99044a48..b0f189be543b 100644 --- a/drivers/infiniband/core/ucma.c +++ b/drivers/infiniband/core/ucma.c @@ -1229,23 +1229,23 @@ static ssize_t ucma_notify(struct ucma_file *file, const char __user *inbuf, return ret; } -static ssize_t ucma_join_ip_multicast(struct ucma_file *file, - const char __user *inbuf, - int in_len, int out_len) +static ssize_t ucma_process_join(struct ucma_file *file, + struct rdma_ucm_join_mcast *cmd, int out_len) { - struct rdma_ucm_join_ip_mcast cmd; struct rdma_ucm_create_id_resp resp; struct ucma_context *ctx; struct ucma_multicast *mc; + struct sockaddr *addr; int ret; if (out_len < sizeof(resp)) return -ENOSPC; - if (copy_from_user(&cmd, inbuf, sizeof(cmd))) - return -EFAULT; + addr = (struct sockaddr *) &cmd->addr; + if (cmd->reserved || !cmd->addr_size || (cmd->addr_size != rdma_addr_size(addr))) + return -EINVAL; - ctx = ucma_get_ctx(file, cmd.id); + ctx = ucma_get_ctx(file, cmd->id); if (IS_ERR(ctx)) return PTR_ERR(ctx); @@ -1256,14 +1256,14 @@ static ssize_t ucma_join_ip_multicast(struct ucma_file *file, goto err1; } - mc->uid = cmd.uid; - memcpy(&mc->addr, &cmd.addr, sizeof cmd.addr); + mc->uid = cmd->uid; + memcpy(&mc->addr, addr, cmd->addr_size); ret = rdma_join_multicast(ctx->cm_id, (struct sockaddr *) &mc->addr, mc); if (ret) goto err2; resp.id = mc->id; - if (copy_to_user((void __user *)(unsigned long)cmd.response, + if (copy_to_user((void __user *)(unsigned long) cmd->response, &resp, sizeof(resp))) { ret = -EFAULT; goto err3; @@ -1288,6 +1288,38 @@ err1: return ret; } +static ssize_t ucma_join_ip_multicast(struct ucma_file *file, + const char __user *inbuf, + int in_len, int out_len) +{ + struct rdma_ucm_join_ip_mcast cmd; + struct rdma_ucm_join_mcast join_cmd; + + if (copy_from_user(&cmd, inbuf, sizeof(cmd))) + return -EFAULT; + + join_cmd.response = cmd.response; + join_cmd.uid = cmd.uid; + join_cmd.id = cmd.id; + join_cmd.addr_size = rdma_addr_size((struct sockaddr *) &cmd.addr); + join_cmd.reserved = 0; + memcpy(&join_cmd.addr, &cmd.addr, join_cmd.addr_size); + + return ucma_process_join(file, &join_cmd, out_len); +} + +static ssize_t ucma_join_multicast(struct ucma_file *file, + const char __user *inbuf, + int in_len, int out_len) +{ + struct rdma_ucm_join_mcast cmd; + + if (copy_from_user(&cmd, inbuf, sizeof(cmd))) + return -EFAULT; + + return ucma_process_join(file, &cmd, out_len); +} + static ssize_t ucma_leave_multicast(struct ucma_file *file, const char __user *inbuf, int in_len, int out_len) @@ -1451,7 +1483,8 @@ static ssize_t (*ucma_cmd_table[])(struct ucma_file *file, [RDMA_USER_CM_CMD_MIGRATE_ID] = ucma_migrate_id, [RDMA_USER_CM_CMD_QUERY] = ucma_query, [RDMA_USER_CM_CMD_BIND] = ucma_bind, - [RDMA_USER_CM_CMD_RESOLVE_ADDR] = ucma_resolve_addr + [RDMA_USER_CM_CMD_RESOLVE_ADDR] = ucma_resolve_addr, + [RDMA_USER_CM_CMD_JOIN_MCAST] = ucma_join_multicast }; static ssize_t ucma_write(struct file *filp, const char __user *buf, diff --git a/include/uapi/rdma/rdma_user_cm.h b/include/uapi/rdma/rdma_user_cm.h index 6d03f9c16f1e..99b80abf360a 100644 --- a/include/uapi/rdma/rdma_user_cm.h +++ b/include/uapi/rdma/rdma_user_cm.h @@ -64,7 +64,8 @@ enum { RDMA_USER_CM_CMD_MIGRATE_ID, RDMA_USER_CM_CMD_QUERY, RDMA_USER_CM_CMD_BIND, - RDMA_USER_CM_CMD_RESOLVE_ADDR + RDMA_USER_CM_CMD_RESOLVE_ADDR, + RDMA_USER_CM_CMD_JOIN_MCAST }; /* @@ -242,6 +243,15 @@ struct rdma_ucm_join_ip_mcast { __u32 id; }; +struct rdma_ucm_join_mcast { + __u64 response; /* rdma_ucma_create_id_resp */ + __u64 uid; + __u32 id; + __u16 addr_size; + __u16 reserved; + struct sockaddr_storage addr; +}; + struct rdma_ucm_get_event { __u64 response; }; From ce117ffac2e933344d0ea01b1cb3b56627fcb6e7 Mon Sep 17 00:00:00 2001 From: Sean Hefty Date: Wed, 29 May 2013 10:09:34 -0700 Subject: [PATCH 0371/1048] RDMA/cma: Export AF_IB statistics Report AF_IB source and destination addresses through netlink interface. Signed-off-by: Sean Hefty Signed-off-by: Roland Dreier --- drivers/infiniband/core/cma.c | 37 ++++++++++------------------------- 1 file changed, 10 insertions(+), 27 deletions(-) diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c index 3d30c388e043..f1c279fabe64 100644 --- a/drivers/infiniband/core/cma.c +++ b/drivers/infiniband/core/cma.c @@ -3586,33 +3586,16 @@ static int cma_get_id_stats(struct sk_buff *skb, struct netlink_callback *cb) id_stats->bound_dev_if = id->route.addr.dev_addr.bound_dev_if; - if (cma_family(id_priv) == AF_INET) { - if (ibnl_put_attr(skb, nlh, - sizeof(struct sockaddr_in), - cma_src_addr(id_priv), - RDMA_NL_RDMA_CM_ATTR_SRC_ADDR)) { - goto out; - } - if (ibnl_put_attr(skb, nlh, - sizeof(struct sockaddr_in), - cma_dst_addr(id_priv), - RDMA_NL_RDMA_CM_ATTR_DST_ADDR)) { - goto out; - } - } else if (cma_family(id_priv) == AF_INET6) { - if (ibnl_put_attr(skb, nlh, - sizeof(struct sockaddr_in6), - cma_src_addr(id_priv), - RDMA_NL_RDMA_CM_ATTR_SRC_ADDR)) { - goto out; - } - if (ibnl_put_attr(skb, nlh, - sizeof(struct sockaddr_in6), - cma_dst_addr(id_priv), - RDMA_NL_RDMA_CM_ATTR_DST_ADDR)) { - goto out; - } - } + if (ibnl_put_attr(skb, nlh, + rdma_addr_size(cma_src_addr(id_priv)), + cma_src_addr(id_priv), + RDMA_NL_RDMA_CM_ATTR_SRC_ADDR)) + goto out; + if (ibnl_put_attr(skb, nlh, + rdma_addr_size(cma_src_addr(id_priv)), + cma_dst_addr(id_priv), + RDMA_NL_RDMA_CM_ATTR_DST_ADDR)) + goto out; id_stats->pid = id_priv->owner; id_stats->port_space = id->ps; From facd23664f1d63c33fbc6da52261c8548ed3fbd4 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Sun, 26 May 2013 07:56:06 -0300 Subject: [PATCH 0372/1048] [media] cx88: remove g_chip_ident Remove g_chip_ident from cx88. Also remove the v4l2-chip-ident.h include. The board code used defines from v4l2-chip-ident.h to tell the driver which audio chip is used. Replace this with a cx88-specific enum. Signed-off-by: Hans Verkuil Cc: Mauro Carvalho Chehab Signed-off-by: Mauro Carvalho Chehab --- drivers/media/pci/cx88/cx88-cards.c | 12 ++++++------ drivers/media/pci/cx88/cx88-video.c | 21 ++------------------- drivers/media/pci/cx88/cx88.h | 8 ++++++-- 3 files changed, 14 insertions(+), 27 deletions(-) diff --git a/drivers/media/pci/cx88/cx88-cards.c b/drivers/media/pci/cx88/cx88-cards.c index a87a0e19593e..e18a7ace08b1 100644 --- a/drivers/media/pci/cx88/cx88-cards.c +++ b/drivers/media/pci/cx88/cx88-cards.c @@ -744,7 +744,7 @@ static const struct cx88_board cx88_boards[] = { .tuner_addr = ADDR_UNSET, .radio_addr = ADDR_UNSET, /* Some variants use a tda9874 and so need the tvaudio module. */ - .audio_chip = V4L2_IDENT_TVAUDIO, + .audio_chip = CX88_AUDIO_TVAUDIO, .input = {{ .type = CX88_VMUX_TELEVISION, .vmux = 0, @@ -976,7 +976,7 @@ static const struct cx88_board cx88_boards[] = { .radio_type = UNSET, .tuner_addr = ADDR_UNSET, .radio_addr = ADDR_UNSET, - .audio_chip = V4L2_IDENT_WM8775, + .audio_chip = CX88_AUDIO_WM8775, .i2sinputcntl = 2, .input = {{ .type = CX88_VMUX_DVB, @@ -1014,7 +1014,7 @@ static const struct cx88_board cx88_boards[] = { .radio_type = UNSET, .tuner_addr = ADDR_UNSET, .radio_addr = ADDR_UNSET, - .audio_chip = V4L2_IDENT_WM8775, + .audio_chip = CX88_AUDIO_WM8775, .input = {{ .type = CX88_VMUX_DVB, .vmux = 0, @@ -1376,7 +1376,7 @@ static const struct cx88_board cx88_boards[] = { .tuner_addr = ADDR_UNSET, .radio_addr = ADDR_UNSET, .tda9887_conf = TDA9887_PRESENT, - .audio_chip = V4L2_IDENT_WM8775, + .audio_chip = CX88_AUDIO_WM8775, .input = {{ .type = CX88_VMUX_TELEVISION, .vmux = 0, @@ -1461,7 +1461,7 @@ static const struct cx88_board cx88_boards[] = { .tuner_addr = ADDR_UNSET, .radio_addr = ADDR_UNSET, .tda9887_conf = TDA9887_PRESENT, - .audio_chip = V4L2_IDENT_WM8775, + .audio_chip = CX88_AUDIO_WM8775, /* * gpio0 as reported by Mike Crash */ @@ -1929,7 +1929,7 @@ static const struct cx88_board cx88_boards[] = { .tuner_addr = ADDR_UNSET, .radio_addr = ADDR_UNSET, .tda9887_conf = TDA9887_PRESENT, - .audio_chip = V4L2_IDENT_WM8775, + .audio_chip = CX88_AUDIO_WM8775, /* * GPIO0 (WINTV2000) * diff --git a/drivers/media/pci/cx88/cx88-video.c b/drivers/media/pci/cx88/cx88-video.c index c7a9be1065c0..5b26ece4aea5 100644 --- a/drivers/media/pci/cx88/cx88-video.c +++ b/drivers/media/pci/cx88/cx88-video.c @@ -1353,24 +1353,12 @@ static int vidioc_s_frequency (struct file *file, void *priv, return cx88_set_freq(core, f); } -static int vidioc_g_chip_ident(struct file *file, void *priv, - struct v4l2_dbg_chip_ident *chip) -{ - if (!v4l2_chip_match_host(&chip->match)) - return -EINVAL; - chip->revision = 0; - chip->ident = V4L2_IDENT_UNKNOWN; - return 0; -} - #ifdef CONFIG_VIDEO_ADV_DEBUG static int vidioc_g_register (struct file *file, void *fh, struct v4l2_dbg_register *reg) { struct cx88_core *core = ((struct cx8800_fh*)fh)->dev->core; - if (!v4l2_chip_match_host(®->match)) - return -EINVAL; /* cx2388x has a 24-bit register space */ reg->val = cx_read(reg->reg & 0xffffff); reg->size = 4; @@ -1382,8 +1370,6 @@ static int vidioc_s_register (struct file *file, void *fh, { struct cx88_core *core = ((struct cx8800_fh*)fh)->dev->core; - if (!v4l2_chip_match_host(®->match)) - return -EINVAL; cx_write(reg->reg & 0xffffff, reg->val); return 0; } @@ -1578,7 +1564,6 @@ static const struct v4l2_ioctl_ops video_ioctl_ops = { .vidioc_s_frequency = vidioc_s_frequency, .vidioc_subscribe_event = v4l2_ctrl_subscribe_event, .vidioc_unsubscribe_event = v4l2_event_unsubscribe, - .vidioc_g_chip_ident = vidioc_g_chip_ident, #ifdef CONFIG_VIDEO_ADV_DEBUG .vidioc_g_register = vidioc_g_register, .vidioc_s_register = vidioc_s_register, @@ -1612,7 +1597,6 @@ static const struct v4l2_ioctl_ops vbi_ioctl_ops = { .vidioc_s_tuner = vidioc_s_tuner, .vidioc_g_frequency = vidioc_g_frequency, .vidioc_s_frequency = vidioc_s_frequency, - .vidioc_g_chip_ident = vidioc_g_chip_ident, #ifdef CONFIG_VIDEO_ADV_DEBUG .vidioc_g_register = vidioc_g_register, .vidioc_s_register = vidioc_s_register, @@ -1643,7 +1627,6 @@ static const struct v4l2_ioctl_ops radio_ioctl_ops = { .vidioc_s_frequency = vidioc_s_frequency, .vidioc_subscribe_event = v4l2_ctrl_subscribe_event, .vidioc_unsubscribe_event = v4l2_event_unsubscribe, - .vidioc_g_chip_ident = vidioc_g_chip_ident, #ifdef CONFIG_VIDEO_ADV_DEBUG .vidioc_g_register = vidioc_g_register, .vidioc_s_register = vidioc_s_register, @@ -1794,7 +1777,7 @@ static int cx8800_initdev(struct pci_dev *pci_dev, /* load and configure helper modules */ - if (core->board.audio_chip == V4L2_IDENT_WM8775) { + if (core->board.audio_chip == CX88_AUDIO_WM8775) { struct i2c_board_info wm8775_info = { .type = "wm8775", .addr = 0x36 >> 1, @@ -1815,7 +1798,7 @@ static int cx8800_initdev(struct pci_dev *pci_dev, } } - if (core->board.audio_chip == V4L2_IDENT_TVAUDIO) { + if (core->board.audio_chip == CX88_AUDIO_TVAUDIO) { /* This probes for a tda9874 as is used on some Pixelview Ultra boards. */ v4l2_i2c_new_subdev(&core->v4l2_dev, &core->i2c_adap, diff --git a/drivers/media/pci/cx88/cx88.h b/drivers/media/pci/cx88/cx88.h index 51ce2c0e8bc1..afe0eaea81b4 100644 --- a/drivers/media/pci/cx88/cx88.h +++ b/drivers/media/pci/cx88/cx88.h @@ -30,7 +30,6 @@ #include #include #include -#include #include #include #include @@ -259,6 +258,11 @@ struct cx88_input { unsigned int audioroute:4; }; +enum cx88_audio_chip { + CX88_AUDIO_WM8775, + CX88_AUDIO_TVAUDIO, +}; + struct cx88_board { const char *name; unsigned int tuner_type; @@ -269,7 +273,7 @@ struct cx88_board { struct cx88_input input[MAX_CX88_INPUT]; struct cx88_input radio; enum cx88_board_type mpeg; - unsigned int audio_chip; + enum cx88_audio_chip audio_chip; int num_frontends; /* Used for I2S devices */ From 6ec19898ed6990baa285b8c96a8b1a0d0366bc46 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Sun, 26 May 2013 08:24:00 -0300 Subject: [PATCH 0373/1048] [media] v4l2: remove obsolete v4l2_chip_match_host() This function is no longer needed since it is now the responsibility of the v4l2 core to check if the DBG_G/S_REGISTER and DBG_G_CHIP_INFO ioctls are called for the bridge driver or not. Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/usb/usbvision/usbvision-video.c | 4 ---- drivers/media/v4l2-core/v4l2-common.c | 11 ----------- include/media/v4l2-common.h | 1 - 3 files changed, 16 deletions(-) diff --git a/drivers/media/usb/usbvision/usbvision-video.c b/drivers/media/usb/usbvision/usbvision-video.c index 7ad872a3e31a..f0a0b7f2da92 100644 --- a/drivers/media/usb/usbvision/usbvision-video.c +++ b/drivers/media/usb/usbvision/usbvision-video.c @@ -467,8 +467,6 @@ static int vidioc_g_register(struct file *file, void *priv, struct usb_usbvision *usbvision = video_drvdata(file); int err_code; - if (!v4l2_chip_match_host(®->match)) - return -EINVAL; /* NT100x has a 8-bit register space */ err_code = usbvision_read_reg(usbvision, reg->reg&0xff); if (err_code < 0) { @@ -488,8 +486,6 @@ static int vidioc_s_register(struct file *file, void *priv, struct usb_usbvision *usbvision = video_drvdata(file); int err_code; - if (!v4l2_chip_match_host(®->match)) - return -EINVAL; /* NT100x has a 8-bit register space */ err_code = usbvision_write_reg(usbvision, reg->reg & 0xff, reg->val); if (err_code < 0) { diff --git a/drivers/media/v4l2-core/v4l2-common.c b/drivers/media/v4l2-core/v4l2-common.c index 3fed63f4e026..5fd76609e613 100644 --- a/drivers/media/v4l2-core/v4l2-common.c +++ b/drivers/media/v4l2-core/v4l2-common.c @@ -227,17 +227,6 @@ u32 v4l2_ctrl_next(const u32 * const * ctrl_classes, u32 id) } EXPORT_SYMBOL(v4l2_ctrl_next); -int v4l2_chip_match_host(const struct v4l2_dbg_match *match) -{ - switch (match->type) { - case V4L2_CHIP_MATCH_BRIDGE: - return match->addr == 0; - default: - return 0; - } -} -EXPORT_SYMBOL(v4l2_chip_match_host); - #if IS_ENABLED(CONFIG_I2C) int v4l2_chip_match_i2c_client(struct i2c_client *c, const struct v4l2_dbg_match *match) { diff --git a/include/media/v4l2-common.h b/include/media/v4l2-common.h index 1d93c48cb371..e7821fb3cd86 100644 --- a/include/media/v4l2-common.h +++ b/include/media/v4l2-common.h @@ -106,7 +106,6 @@ struct i2c_client; /* forward reference */ int v4l2_chip_match_i2c_client(struct i2c_client *c, const struct v4l2_dbg_match *match); int v4l2_chip_ident_i2c_client(struct i2c_client *c, struct v4l2_dbg_chip_ident *chip, u32 ident, u32 revision); -int v4l2_chip_match_host(const struct v4l2_dbg_match *match); /* ------------------------------------------------------------------------- */ From aee38734d2e2a908c4fd50918f28f19c088abfb9 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Sun, 26 May 2013 10:01:42 -0300 Subject: [PATCH 0374/1048] [media] v4l2-common: remove unused v4l2_chip_match/ident_i2c_client functions Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/v4l2-core/v4l2-common.c | 47 +-------------------------- include/media/v4l2-common.h | 9 ----- 2 files changed, 1 insertion(+), 55 deletions(-) diff --git a/drivers/media/v4l2-core/v4l2-common.c b/drivers/media/v4l2-core/v4l2-common.c index 5fd76609e613..3b2a7606bc84 100644 --- a/drivers/media/v4l2-core/v4l2-common.c +++ b/drivers/media/v4l2-core/v4l2-common.c @@ -61,7 +61,6 @@ #include #include #include -#include #include @@ -227,51 +226,9 @@ u32 v4l2_ctrl_next(const u32 * const * ctrl_classes, u32 id) } EXPORT_SYMBOL(v4l2_ctrl_next); -#if IS_ENABLED(CONFIG_I2C) -int v4l2_chip_match_i2c_client(struct i2c_client *c, const struct v4l2_dbg_match *match) -{ - int len; - - if (c == NULL || match == NULL) - return 0; - - switch (match->type) { - case V4L2_CHIP_MATCH_I2C_DRIVER: - if (c->driver == NULL || c->driver->driver.name == NULL) - return 0; - len = strlen(c->driver->driver.name); - return len && !strncmp(c->driver->driver.name, match->name, len); - case V4L2_CHIP_MATCH_I2C_ADDR: - return c->addr == match->addr; - case V4L2_CHIP_MATCH_SUBDEV: - return 1; - default: - return 0; - } -} -EXPORT_SYMBOL(v4l2_chip_match_i2c_client); - -int v4l2_chip_ident_i2c_client(struct i2c_client *c, struct v4l2_dbg_chip_ident *chip, - u32 ident, u32 revision) -{ - if (!v4l2_chip_match_i2c_client(c, &chip->match)) - return 0; - if (chip->ident == V4L2_IDENT_NONE) { - chip->ident = ident; - chip->revision = revision; - } - else { - chip->ident = V4L2_IDENT_AMBIGUOUS; - chip->revision = 0; - } - return 0; -} -EXPORT_SYMBOL(v4l2_chip_ident_i2c_client); - -/* ----------------------------------------------------------------- */ - /* I2C Helper functions */ +#if IS_ENABLED(CONFIG_I2C) void v4l2_i2c_subdev_init(struct v4l2_subdev *sd, struct i2c_client *client, const struct v4l2_subdev_ops *ops) @@ -290,8 +247,6 @@ void v4l2_i2c_subdev_init(struct v4l2_subdev *sd, struct i2c_client *client, } EXPORT_SYMBOL_GPL(v4l2_i2c_subdev_init); - - /* Load an i2c sub-device. */ struct v4l2_subdev *v4l2_i2c_new_subdev_board(struct v4l2_device *v4l2_dev, struct i2c_adapter *adapter, struct i2c_board_info *info, diff --git a/include/media/v4l2-common.h b/include/media/v4l2-common.h index e7821fb3cd86..015ff82da73c 100644 --- a/include/media/v4l2-common.h +++ b/include/media/v4l2-common.h @@ -100,15 +100,6 @@ u32 v4l2_ctrl_next(const u32 * const *ctrl_classes, u32 id); /* ------------------------------------------------------------------------- */ -/* Register/chip ident helper function */ - -struct i2c_client; /* forward reference */ -int v4l2_chip_match_i2c_client(struct i2c_client *c, const struct v4l2_dbg_match *match); -int v4l2_chip_ident_i2c_client(struct i2c_client *c, struct v4l2_dbg_chip_ident *chip, - u32 ident, u32 revision); - -/* ------------------------------------------------------------------------- */ - /* I2C Helper functions */ struct i2c_driver; From 12869145718571ffa4f6e650a6f759934eeca0d9 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Sun, 26 May 2013 09:33:00 -0300 Subject: [PATCH 0375/1048] [media] v4l2-int-device: remove unused chip_ident reference Signed-off-by: Hans Verkuil Cc: Mauro Carvalho Chehab Signed-off-by: Mauro Carvalho Chehab --- include/media/v4l2-int-device.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/include/media/v4l2-int-device.h b/include/media/v4l2-int-device.h index e6aa2318367b..0286c95814ff 100644 --- a/include/media/v4l2-int-device.h +++ b/include/media/v4l2-int-device.h @@ -220,8 +220,6 @@ enum v4l2_int_ioctl_num { vidioc_int_reset_num, /* VIDIOC_INT_INIT */ vidioc_int_init_num, - /* VIDIOC_DBG_G_CHIP_IDENT */ - vidioc_int_g_chip_ident_num, /* * @@ -303,6 +301,5 @@ V4L2_INT_WRAPPER_1(enum_frameintervals, struct v4l2_frmivalenum, *); V4L2_INT_WRAPPER_0(reset); V4L2_INT_WRAPPER_0(init); -V4L2_INT_WRAPPER_1(g_chip_ident, int, *); #endif From b71c99801e18eb172ae34851daf25044a3bf644a Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Sun, 26 May 2013 10:03:01 -0300 Subject: [PATCH 0376/1048] [media] v4l2-core: remove support for obsolete VIDIOC_DBG_G_CHIP_IDENT This has been replaced by the new and much better VIDIOC_DBG_G_CHIP_INFO. Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/v4l2-core/v4l2-compat-ioctl32.c | 1 - drivers/media/v4l2-core/v4l2-dev.c | 1 - drivers/media/v4l2-core/v4l2-ioctl.c | 28 -- include/media/v4l2-chip-ident.h | 354 ------------------ include/media/v4l2-ioctl.h | 2 - include/media/v4l2-subdev.h | 4 +- include/uapi/linux/videodev2.h | 17 +- 7 files changed, 4 insertions(+), 403 deletions(-) delete mode 100644 include/media/v4l2-chip-ident.h diff --git a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c index f1295519f285..8f7a6a454a4c 100644 --- a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c +++ b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c @@ -1074,7 +1074,6 @@ long v4l2_compat_ioctl32(struct file *file, unsigned int cmd, unsigned long arg) case VIDIOC_TRY_DECODER_CMD: case VIDIOC_DBG_S_REGISTER: case VIDIOC_DBG_G_REGISTER: - case VIDIOC_DBG_G_CHIP_IDENT: case VIDIOC_S_HW_FREQ_SEEK: case VIDIOC_S_DV_TIMINGS: case VIDIOC_G_DV_TIMINGS: diff --git a/drivers/media/v4l2-core/v4l2-dev.c b/drivers/media/v4l2-core/v4l2-dev.c index 2f3fac5345db..0c061e16502e 100644 --- a/drivers/media/v4l2-core/v4l2-dev.c +++ b/drivers/media/v4l2-core/v4l2-dev.c @@ -596,7 +596,6 @@ static void determine_valid_ioctls(struct video_device *vdev) set_bit(_IOC_NR(VIDIOC_DBG_G_REGISTER), valid_ioctls); set_bit(_IOC_NR(VIDIOC_DBG_S_REGISTER), valid_ioctls); #endif - SET_VALID_IOCTL(ops, VIDIOC_DBG_G_CHIP_IDENT, vidioc_g_chip_ident); /* yes, really vidioc_subscribe_event */ SET_VALID_IOCTL(ops, VIDIOC_DQEVENT, vidioc_subscribe_event); SET_VALID_IOCTL(ops, VIDIOC_SUBSCRIBE_EVENT, vidioc_subscribe_event); diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c index 423cbf948600..c9d9f01d21bc 100644 --- a/drivers/media/v4l2-core/v4l2-ioctl.c +++ b/drivers/media/v4l2-core/v4l2-ioctl.c @@ -26,7 +26,6 @@ #include #include #include -#include #include /* Zero out the end of the struct pointed to by p. Everything after, but @@ -619,20 +618,6 @@ static void v4l_print_decoder_cmd(const void *arg, bool write_only) pr_info("pts=%llu\n", p->stop.pts); } -static void v4l_print_dbg_chip_ident(const void *arg, bool write_only) -{ - const struct v4l2_dbg_chip_ident *p = arg; - - pr_cont("type=%u, ", p->match.type); - if (p->match.type == V4L2_CHIP_MATCH_I2C_DRIVER) - pr_cont("name=%.*s, ", - (int)sizeof(p->match.name), p->match.name); - else - pr_cont("addr=%u, ", p->match.addr); - pr_cont("chip_ident=%u, revision=0x%x\n", - p->ident, p->revision); -} - static void v4l_print_dbg_chip_info(const void *arg, bool write_only) { const struct v4l2_dbg_chip_info *p = arg; @@ -1813,18 +1798,6 @@ static int v4l_dbg_s_register(const struct v4l2_ioctl_ops *ops, #endif } -static int v4l_dbg_g_chip_ident(const struct v4l2_ioctl_ops *ops, - struct file *file, void *fh, void *arg) -{ - struct v4l2_dbg_chip_ident *p = arg; - - p->ident = V4L2_IDENT_NONE; - p->revision = 0; - if (p->match.type == V4L2_CHIP_MATCH_SUBDEV) - return -EINVAL; - return ops->vidioc_g_chip_ident(file, fh, p); -} - static int v4l_dbg_g_chip_info(const struct v4l2_ioctl_ops *ops, struct file *file, void *fh, void *arg) { @@ -2074,7 +2047,6 @@ static struct v4l2_ioctl_info v4l2_ioctls[] = { IOCTL_INFO_STD(VIDIOC_TRY_DECODER_CMD, vidioc_try_decoder_cmd, v4l_print_decoder_cmd, 0), IOCTL_INFO_FNC(VIDIOC_DBG_S_REGISTER, v4l_dbg_s_register, v4l_print_dbg_register, 0), IOCTL_INFO_FNC(VIDIOC_DBG_G_REGISTER, v4l_dbg_g_register, v4l_print_dbg_register, 0), - IOCTL_INFO_FNC(VIDIOC_DBG_G_CHIP_IDENT, v4l_dbg_g_chip_ident, v4l_print_dbg_chip_ident, 0), IOCTL_INFO_FNC(VIDIOC_S_HW_FREQ_SEEK, v4l_s_hw_freq_seek, v4l_print_hw_freq_seek, INFO_FL_PRIO), IOCTL_INFO_STD(VIDIOC_S_DV_TIMINGS, vidioc_s_dv_timings, v4l_print_dv_timings, INFO_FL_PRIO), IOCTL_INFO_STD(VIDIOC_G_DV_TIMINGS, vidioc_g_dv_timings, v4l_print_dv_timings, 0), diff --git a/include/media/v4l2-chip-ident.h b/include/media/v4l2-chip-ident.h deleted file mode 100644 index 543f89c18896..000000000000 --- a/include/media/v4l2-chip-ident.h +++ /dev/null @@ -1,354 +0,0 @@ -/* - v4l2 chip identifiers header - - This header provides a list of chip identifiers that can be returned - through the VIDIOC_DBG_G_CHIP_IDENT ioctl. - - Copyright (C) 2007 Hans Verkuil - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef V4L2_CHIP_IDENT_H_ -#define V4L2_CHIP_IDENT_H_ - -/* VIDIOC_DBG_G_CHIP_IDENT: identifies the actual chip installed on the board */ - -/* KEEP THIS LIST ORDERED BY ID! - Otherwise it will be hard to see which ranges are already in use when - adding support to a new chip family. */ -enum { - /* general idents: reserved range 0-49 */ - V4L2_IDENT_NONE = 0, /* No chip matched */ - V4L2_IDENT_AMBIGUOUS = 1, /* Match too general, multiple chips matched */ - V4L2_IDENT_UNKNOWN = 2, /* Chip found, but cannot identify */ - - /* module tvaudio: reserved range 50-99 */ - V4L2_IDENT_TVAUDIO = 50, /* A tvaudio chip, unknown which it is exactly */ - - /* Sony IMX074 */ - V4L2_IDENT_IMX074 = 74, - - /* module saa7110: just ident 100 */ - V4L2_IDENT_SAA7110 = 100, - - /* module saa7115: reserved range 101-149 */ - V4L2_IDENT_SAA7111 = 101, - V4L2_IDENT_SAA7111A = 102, - V4L2_IDENT_SAA7113 = 103, - V4L2_IDENT_SAA7114 = 104, - V4L2_IDENT_SAA7115 = 105, - V4L2_IDENT_SAA7118 = 108, - - V4L2_IDENT_GM7113C = 140, - - /* module saa7127: reserved range 150-199 */ - V4L2_IDENT_SAA7127 = 157, - V4L2_IDENT_SAA7129 = 159, - - /* module cx25840: reserved range 200-249 */ - V4L2_IDENT_CX25836 = 236, - V4L2_IDENT_CX25837 = 237, - V4L2_IDENT_CX25840 = 240, - V4L2_IDENT_CX25841 = 241, - V4L2_IDENT_CX25842 = 242, - V4L2_IDENT_CX25843 = 243, - - /* OmniVision sensors: reserved range 250-299 */ - V4L2_IDENT_OV7670 = 250, - V4L2_IDENT_OV7720 = 251, - V4L2_IDENT_OV7725 = 252, - V4L2_IDENT_OV7660 = 253, - V4L2_IDENT_OV9650 = 254, - V4L2_IDENT_OV9655 = 255, - V4L2_IDENT_SOI968 = 256, - V4L2_IDENT_OV9640 = 257, - V4L2_IDENT_OV6650 = 258, - V4L2_IDENT_OV2640 = 259, - V4L2_IDENT_OV9740 = 260, - V4L2_IDENT_OV5642 = 261, - - /* module saa7146: reserved range 300-309 */ - V4L2_IDENT_SAA7146 = 300, - - /* Conexant MPEG encoder/decoders: reserved range 400-420 */ - V4L2_IDENT_CX23418_843 = 403, /* Integrated A/V Decoder on the '418 */ - V4L2_IDENT_CX23415 = 415, - V4L2_IDENT_CX23416 = 416, - V4L2_IDENT_CX23417 = 417, - V4L2_IDENT_CX23418 = 418, - - /* module bt819: reserved range 810-819 */ - V4L2_IDENT_BT815A = 815, - V4L2_IDENT_BT817A = 817, - V4L2_IDENT_BT819A = 819, - - /* module au0828 */ - V4L2_IDENT_AU0828 = 828, - - /* module bttv: ident 848 + 849 */ - V4L2_IDENT_BT848 = 848, - V4L2_IDENT_BT849 = 849, - - /* module bt856: just ident 856 */ - V4L2_IDENT_BT856 = 856, - - /* module bt866: just ident 866 */ - V4L2_IDENT_BT866 = 866, - - /* module bttv: ident 878 + 879 */ - V4L2_IDENT_BT878 = 878, - V4L2_IDENT_BT879 = 879, - - /* module ks0127: reserved range 1120-1129 */ - V4L2_IDENT_KS0122S = 1122, - V4L2_IDENT_KS0127 = 1127, - V4L2_IDENT_KS0127B = 1128, - - /* module indycam: just ident 2000 */ - V4L2_IDENT_INDYCAM = 2000, - - /* module vp27smpx: just ident 2700 */ - V4L2_IDENT_VP27SMPX = 2700, - - /* module vpx3220: reserved range: 3210-3229 */ - V4L2_IDENT_VPX3214C = 3214, - V4L2_IDENT_VPX3216B = 3216, - V4L2_IDENT_VPX3220A = 3220, - - /* VX855 just ident 3409 */ - /* Other via devs could use 3314, 3324, 3327, 3336, 3364, 3353 */ - V4L2_IDENT_VIA_VX855 = 3409, - - /* module tvp5150 */ - V4L2_IDENT_TVP5150 = 5150, - - /* module saa5246a: just ident 5246 */ - V4L2_IDENT_SAA5246A = 5246, - - /* module saa5249: just ident 5249 */ - V4L2_IDENT_SAA5249 = 5249, - - /* module cs5345: just ident 5345 */ - V4L2_IDENT_CS5345 = 5345, - - /* module tea6415c: just ident 6415 */ - V4L2_IDENT_TEA6415C = 6415, - - /* module tea6420: just ident 6420 */ - V4L2_IDENT_TEA6420 = 6420, - - /* module saa6588: just ident 6588 */ - V4L2_IDENT_SAA6588 = 6588, - - /* module vs6624: just ident 6624 */ - V4L2_IDENT_VS6624 = 6624, - - /* module saa6752hs: reserved range 6750-6759 */ - V4L2_IDENT_SAA6752HS = 6752, - V4L2_IDENT_SAA6752HS_AC3 = 6753, - - /* modules tef6862: just ident 6862 */ - V4L2_IDENT_TEF6862 = 6862, - - /* module tvp7002: just ident 7002 */ - V4L2_IDENT_TVP7002 = 7002, - - /* module adv7170: just ident 7170 */ - V4L2_IDENT_ADV7170 = 7170, - - /* module adv7175: just ident 7175 */ - V4L2_IDENT_ADV7175 = 7175, - - /* module adv7180: just ident 7180 */ - V4L2_IDENT_ADV7180 = 7180, - - /* module adv7183: just ident 7183 */ - V4L2_IDENT_ADV7183 = 7183, - - /* module saa7185: just ident 7185 */ - V4L2_IDENT_SAA7185 = 7185, - - /* module saa7191: just ident 7191 */ - V4L2_IDENT_SAA7191 = 7191, - - /* module ths7303: just ident 7303 */ - V4L2_IDENT_THS7303 = 7303, - - /* module adv7343: just ident 7343 */ - V4L2_IDENT_ADV7343 = 7343, - - /* module ths7353: just ident 7353 */ - V4L2_IDENT_THS7353 = 7353, - - /* module adv7393: just ident 7393 */ - V4L2_IDENT_ADV7393 = 7393, - - /* module adv7604: just ident 7604 */ - V4L2_IDENT_ADV7604 = 7604, - - /* module saa7706h: just ident 7706 */ - V4L2_IDENT_SAA7706H = 7706, - - /* module mt9v011, just ident 8243 */ - V4L2_IDENT_MT9V011 = 8243, - - /* module wm8739: just ident 8739 */ - V4L2_IDENT_WM8739 = 8739, - - /* module wm8775: just ident 8775 */ - V4L2_IDENT_WM8775 = 8775, - - /* Marvell controllers starting at 8801 */ - V4L2_IDENT_CAFE = 8801, - V4L2_IDENT_ARMADA610 = 8802, - - /* AKM AK8813/AK8814 */ - V4L2_IDENT_AK8813 = 8813, - V4L2_IDENT_AK8814 = 8814, - - /* module cx23885 and cx25840 */ - V4L2_IDENT_CX23885 = 8850, - V4L2_IDENT_CX23885_AV = 8851, /* Integrated A/V decoder */ - V4L2_IDENT_CX23887 = 8870, - V4L2_IDENT_CX23887_AV = 8871, /* Integrated A/V decoder */ - V4L2_IDENT_CX23888 = 8880, - V4L2_IDENT_CX23888_AV = 8881, /* Integrated A/V decoder */ - V4L2_IDENT_CX23888_IR = 8882, /* Integrated infrared controller */ - - /* module ad9389b: just ident 9389 */ - V4L2_IDENT_AD9389B = 9389, - - /* module tda9840: just ident 9840 */ - V4L2_IDENT_TDA9840 = 9840, - - /* module tw9910: just ident 9910 */ - V4L2_IDENT_TW9910 = 9910, - - /* module sn9c20x: just ident 10000 */ - V4L2_IDENT_SN9C20X = 10000, - - /* module cx231xx and cx25840 */ - V4L2_IDENT_CX2310X_AV = 23099, /* Integrated A/V decoder; not in '100 */ - V4L2_IDENT_CX23100 = 23100, - V4L2_IDENT_CX23101 = 23101, - V4L2_IDENT_CX23102 = 23102, - - /* module msp3400: reserved range 34000-34999 for msp34xx */ - V4L2_IDENT_MSPX4XX = 34000, /* generic MSPX4XX identifier, only - use internally (tveeprom.c). */ - - V4L2_IDENT_MSP3400B = 34002, - V4L2_IDENT_MSP3400C = 34003, - V4L2_IDENT_MSP3400D = 34004, - V4L2_IDENT_MSP3400G = 34007, - V4L2_IDENT_MSP3401G = 34017, - V4L2_IDENT_MSP3402G = 34027, - V4L2_IDENT_MSP3405D = 34054, - V4L2_IDENT_MSP3405G = 34057, - V4L2_IDENT_MSP3407D = 34074, - V4L2_IDENT_MSP3407G = 34077, - - V4L2_IDENT_MSP3410B = 34102, - V4L2_IDENT_MSP3410C = 34103, - V4L2_IDENT_MSP3410D = 34104, - V4L2_IDENT_MSP3410G = 34107, - V4L2_IDENT_MSP3411G = 34117, - V4L2_IDENT_MSP3412G = 34127, - V4L2_IDENT_MSP3415D = 34154, - V4L2_IDENT_MSP3415G = 34157, - V4L2_IDENT_MSP3417D = 34174, - V4L2_IDENT_MSP3417G = 34177, - - V4L2_IDENT_MSP3420G = 34207, - V4L2_IDENT_MSP3421G = 34217, - V4L2_IDENT_MSP3422G = 34227, - V4L2_IDENT_MSP3425G = 34257, - V4L2_IDENT_MSP3427G = 34277, - - V4L2_IDENT_MSP3430G = 34307, - V4L2_IDENT_MSP3431G = 34317, - V4L2_IDENT_MSP3435G = 34357, - V4L2_IDENT_MSP3437G = 34377, - - V4L2_IDENT_MSP3440G = 34407, - V4L2_IDENT_MSP3441G = 34417, - V4L2_IDENT_MSP3442G = 34427, - V4L2_IDENT_MSP3445G = 34457, - V4L2_IDENT_MSP3447G = 34477, - - V4L2_IDENT_MSP3450G = 34507, - V4L2_IDENT_MSP3451G = 34517, - V4L2_IDENT_MSP3452G = 34527, - V4L2_IDENT_MSP3455G = 34557, - V4L2_IDENT_MSP3457G = 34577, - - V4L2_IDENT_MSP3460G = 34607, - V4L2_IDENT_MSP3461G = 34617, - V4L2_IDENT_MSP3465G = 34657, - V4L2_IDENT_MSP3467G = 34677, - - /* module msp3400: reserved range 44000-44999 for msp44xx */ - V4L2_IDENT_MSP4400G = 44007, - V4L2_IDENT_MSP4408G = 44087, - V4L2_IDENT_MSP4410G = 44107, - V4L2_IDENT_MSP4418G = 44187, - V4L2_IDENT_MSP4420G = 44207, - V4L2_IDENT_MSP4428G = 44287, - V4L2_IDENT_MSP4440G = 44407, - V4L2_IDENT_MSP4448G = 44487, - V4L2_IDENT_MSP4450G = 44507, - V4L2_IDENT_MSP4458G = 44587, - - /* Micron CMOS sensor chips: 45000-45099 */ - V4L2_IDENT_MT9M001C12ST = 45000, - V4L2_IDENT_MT9M001C12STM = 45005, - V4L2_IDENT_MT9M111 = 45007, - V4L2_IDENT_MT9M112 = 45008, - V4L2_IDENT_MT9V022IX7ATC = 45010, /* No way to detect "normal" I77ATx */ - V4L2_IDENT_MT9V022IX7ATM = 45015, /* and "lead free" IA7ATx chips */ - V4L2_IDENT_MT9T031 = 45020, - V4L2_IDENT_MT9T111 = 45021, - V4L2_IDENT_MT9T112 = 45022, - V4L2_IDENT_MT9V111 = 45031, - V4L2_IDENT_MT9V112 = 45032, - - /* HV7131R CMOS sensor: just ident 46000 */ - V4L2_IDENT_HV7131R = 46000, - - /* Sharp RJ54N1CB0C, 0xCB0C = 51980 */ - V4L2_IDENT_RJ54N1CB0C = 51980, - - /* module m52790: just ident 52790 */ - V4L2_IDENT_M52790 = 52790, - - /* module cs53132a: just ident 53132 */ - V4L2_IDENT_CS53l32A = 53132, - - /* modules upd61151 MPEG2 encoder: just ident 54000 */ - V4L2_IDENT_UPD61161 = 54000, - /* modules upd61152 MPEG2 encoder with AC3: just ident 54001 */ - V4L2_IDENT_UPD61162 = 54001, - - /* module upd64031a: just ident 64031 */ - V4L2_IDENT_UPD64031A = 64031, - - /* module upd64083: just ident 64083 */ - V4L2_IDENT_UPD64083 = 64083, - - /* Don't just add new IDs at the end: KEEP THIS LIST ORDERED BY ID! */ -}; - -#endif diff --git a/include/media/v4l2-ioctl.h b/include/media/v4l2-ioctl.h index 931652f0e2af..e0b74a430b3a 100644 --- a/include/media/v4l2-ioctl.h +++ b/include/media/v4l2-ioctl.h @@ -247,8 +247,6 @@ struct v4l2_ioctl_ops { int (*vidioc_g_chip_info) (struct file *file, void *fh, struct v4l2_dbg_chip_info *chip); #endif - int (*vidioc_g_chip_ident) (struct file *file, void *fh, - struct v4l2_dbg_chip_ident *chip); int (*vidioc_enum_framesizes) (struct file *file, void *fh, struct v4l2_frmsizeenum *fsize); diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h index 5298d678d0f3..21fc9e16d7be 100644 --- a/include/media/v4l2-subdev.h +++ b/include/media/v4l2-subdev.h @@ -88,7 +88,6 @@ struct v4l2_decode_vbi_line { /* Core ops: it is highly recommended to implement at least these ops: - g_chip_ident log_status g_register s_register @@ -145,7 +144,6 @@ struct v4l2_subdev_io_pin_config { performed later. It must not sleep. *Called from an IRQ context*. */ struct v4l2_subdev_core_ops { - int (*g_chip_ident)(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *chip); int (*log_status)(struct v4l2_subdev *sd); int (*s_io_pin_config)(struct v4l2_subdev *sd, size_t n, struct v4l2_subdev_io_pin_config *pincfg); @@ -660,7 +658,7 @@ void v4l2_subdev_init(struct v4l2_subdev *sd, /* Call an ops of a v4l2_subdev, doing the right checks against NULL pointers. - Example: err = v4l2_subdev_call(sd, core, g_chip_ident, &chip); + Example: err = v4l2_subdev_call(sd, core, s_std, norm); */ #define v4l2_subdev_call(sd, o, f, args...) \ (!(sd) ? -ENODEV : (((sd)->ops->o && (sd)->ops->o->f) ? \ diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h index 2c5e67a45436..95ef4551edc1 100644 --- a/include/uapi/linux/videodev2.h +++ b/include/uapi/linux/videodev2.h @@ -1787,11 +1787,13 @@ struct v4l2_event_subscription { /* VIDIOC_DBG_G_REGISTER and VIDIOC_DBG_S_REGISTER */ #define V4L2_CHIP_MATCH_BRIDGE 0 /* Match against chip ID on the bridge (0 for the bridge) */ +#define V4L2_CHIP_MATCH_SUBDEV 4 /* Match against subdev index */ + +/* The following four defines are no longer in use */ #define V4L2_CHIP_MATCH_HOST V4L2_CHIP_MATCH_BRIDGE #define V4L2_CHIP_MATCH_I2C_DRIVER 1 /* Match against I2C driver name */ #define V4L2_CHIP_MATCH_I2C_ADDR 2 /* Match against I2C 7-bit address */ #define V4L2_CHIP_MATCH_AC97 3 /* Match against ancillary AC97 chip */ -#define V4L2_CHIP_MATCH_SUBDEV 4 /* Match against subdev index */ struct v4l2_dbg_match { __u32 type; /* Match type */ @@ -1808,13 +1810,6 @@ struct v4l2_dbg_register { __u64 val; } __attribute__ ((packed)); -/* VIDIOC_DBG_G_CHIP_IDENT */ -struct v4l2_dbg_chip_ident { - struct v4l2_dbg_match match; - __u32 ident; /* chip identifier as specified in */ - __u32 revision; /* chip revision, chip specific */ -} __attribute__ ((packed)); - #define V4L2_CHIP_FL_READABLE (1 << 0) #define V4L2_CHIP_FL_WRITABLE (1 << 1) @@ -1915,12 +1910,6 @@ struct v4l2_create_buffers { #define VIDIOC_DBG_S_REGISTER _IOW('V', 79, struct v4l2_dbg_register) #define VIDIOC_DBG_G_REGISTER _IOWR('V', 80, struct v4l2_dbg_register) -/* Experimental, meant for debugging, testing and internal use. - Never use this ioctl in applications! - Note: this ioctl is deprecated in favor of VIDIOC_DBG_G_CHIP_INFO and - will go away in the future. */ -#define VIDIOC_DBG_G_CHIP_IDENT _IOWR('V', 81, struct v4l2_dbg_chip_ident) - #define VIDIOC_S_HW_FREQ_SEEK _IOW('V', 82, struct v4l2_hw_freq_seek) #define VIDIOC_S_DV_TIMINGS _IOWR('V', 87, struct v4l2_dv_timings) From a6edca3c1b4e78c099a426bbe1e724bf70cf3515 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Sun, 26 May 2013 09:45:23 -0300 Subject: [PATCH 0377/1048] [media] DocBook: remove references to the dropped VIDIOC_DBG_G_CHIP_IDENT ioctl Signed-off-by: Hans Verkuil Cc: Mauro Carvalho Chehab Signed-off-by: Mauro Carvalho Chehab --- Documentation/DocBook/media/v4l/compat.xml | 14 +- Documentation/DocBook/media/v4l/v4l2.xml | 11 +- .../media/v4l/vidioc-dbg-g-chip-ident.xml | 271 ------------------ .../media/v4l/vidioc-dbg-g-chip-info.xml | 17 +- .../media/v4l/vidioc-dbg-g-register.xml | 40 +-- 5 files changed, 24 insertions(+), 329 deletions(-) delete mode 100644 Documentation/DocBook/media/v4l/vidioc-dbg-g-chip-ident.xml diff --git a/Documentation/DocBook/media/v4l/compat.xml b/Documentation/DocBook/media/v4l/compat.xml index f43542ae2981..0c7195e3e093 100644 --- a/Documentation/DocBook/media/v4l/compat.xml +++ b/Documentation/DocBook/media/v4l/compat.xml @@ -2254,7 +2254,7 @@ video encoding. The VIDIOC_G_CHIP_IDENT ioctl was renamed -to VIDIOC_G_CHIP_IDENT_OLD and &VIDIOC-DBG-G-CHIP-IDENT; +to VIDIOC_G_CHIP_IDENT_OLD and VIDIOC_DBG_G_CHIP_IDENT was introduced in its place. The old struct v4l2_chip_ident was renamed to v4l2_chip_ident_old. @@ -2513,6 +2513,16 @@ that used it. It was originally scheduled for removal in 2.6.35. +
+ V4L2 in Linux 3.11 + + + Remove obsolete VIDIOC_DBG_G_CHIP_IDENT ioctl. + + + +
+
Relation of V4L2 to other Linux multimedia APIs @@ -2596,7 +2606,7 @@ and may change in the future. ioctls. - &VIDIOC-DBG-G-CHIP-IDENT; ioctl. + &VIDIOC-DBG-G-CHIP-INFO; ioctl. &VIDIOC-ENUM-DV-TIMINGS;, &VIDIOC-QUERY-DV-TIMINGS; and diff --git a/Documentation/DocBook/media/v4l/v4l2.xml b/Documentation/DocBook/media/v4l/v4l2.xml index bfe823dd0f31..8469fe13945c 100644 --- a/Documentation/DocBook/media/v4l/v4l2.xml +++ b/Documentation/DocBook/media/v4l/v4l2.xml @@ -140,6 +140,14 @@ structs, ioctls) must be noted in more detail in the history chapter (compat.xml), along with the possible impact on existing drivers and applications. --> + + 3.11 + 2013-05-26 + hv + Remove obsolete VIDIOC_DBG_G_CHIP_IDENT ioctl. + + + 3.10 2013-03-25 @@ -493,7 +501,7 @@ and discussions on the V4L mailing list. Video for Linux Two API Specification - Revision 3.10 + Revision 3.11 &sub-common; @@ -547,7 +555,6 @@ and discussions on the V4L mailing list. &sub-create-bufs; &sub-cropcap; - &sub-dbg-g-chip-ident; &sub-dbg-g-chip-info; &sub-dbg-g-register; &sub-decoder-cmd; diff --git a/Documentation/DocBook/media/v4l/vidioc-dbg-g-chip-ident.xml b/Documentation/DocBook/media/v4l/vidioc-dbg-g-chip-ident.xml deleted file mode 100644 index 921e18550d26..000000000000 --- a/Documentation/DocBook/media/v4l/vidioc-dbg-g-chip-ident.xml +++ /dev/null @@ -1,271 +0,0 @@ - - - ioctl VIDIOC_DBG_G_CHIP_IDENT - &manvol; - - - - VIDIOC_DBG_G_CHIP_IDENT - Identify the chips on a TV card - - - - - - int ioctl - int fd - int request - struct v4l2_dbg_chip_ident -*argp - - - - - - Arguments - - - - fd - - &fd; - - - - request - - VIDIOC_DBG_G_CHIP_IDENT - - - - argp - - - - - - - - - Description - - - Experimental - - This is an experimental interface and may change in -the future. - - - For driver debugging purposes this ioctl allows test -applications to query the driver about the chips present on the TV -card. Regular applications must not use it. When you found a chip -specific bug, please contact the linux-media mailing list (&v4l-ml;) -so it can be fixed. - - To query the driver applications must initialize the -match.type and -match.addr or match.name -fields of a &v4l2-dbg-chip-ident; -and call VIDIOC_DBG_G_CHIP_IDENT with a pointer to -this structure. On success the driver stores information about the -selected chip in the ident and -revision fields. On failure the structure -remains unchanged. - - When match.type is -V4L2_CHIP_MATCH_HOST, -match.addr selects the nth non-&i2c; chip -on the TV card. You can enumerate all chips by starting at zero and -incrementing match.addr by one until -VIDIOC_DBG_G_CHIP_IDENT fails with an &EINVAL;. -The number zero always selects the host chip, ⪚ the chip connected -to the PCI or USB bus. - - When match.type is -V4L2_CHIP_MATCH_I2C_DRIVER, -match.name contains the I2C driver name. -For instance -"saa7127" will match any chip -supported by the saa7127 driver, regardless of its &i2c; bus address. -When multiple chips supported by the same driver are present, the -ioctl will return V4L2_IDENT_AMBIGUOUS in the -ident field. - - When match.type is -V4L2_CHIP_MATCH_I2C_ADDR, -match.addr selects a chip by its 7 bit -&i2c; bus address. - - When match.type is -V4L2_CHIP_MATCH_AC97, -match.addr selects the nth AC97 chip -on the TV card. You can enumerate all chips by starting at zero and -incrementing match.addr by one until -VIDIOC_DBG_G_CHIP_IDENT fails with an &EINVAL;. - - On success, the ident field will -contain a chip ID from the Linux -media/v4l2-chip-ident.h header file, and the -revision field will contain a driver -specific value, or zero if no particular revision is associated with -this chip. - - When the driver could not identify the selected chip, -ident will contain -V4L2_IDENT_UNKNOWN. When no chip matched -the ioctl will succeed but the -ident field will contain -V4L2_IDENT_NONE. If multiple chips matched, -ident will contain -V4L2_IDENT_AMBIGUOUS. In all these cases the -revision field remains unchanged. - - This ioctl is optional, not all drivers may support it. It -was introduced in Linux 2.6.21, but the API was changed to the -one described here in 2.6.29. - - We recommended the v4l2-dbg -utility over calling this ioctl directly. It is available from the -LinuxTV v4l-dvb repository; see http://linuxtv.org/repo/ for -access instructions. - - -
- struct <structname>v4l2_dbg_match</structname> - - &cs-ustr; - - - __u32 - type - See for a list of -possible types. - - - union - (anonymous) - - - - __u32 - addr - Match a chip by this number, interpreted according -to the type field. - - - - char - name[32] - Match a chip by this name, interpreted according -to the type field. - - - -
- - - struct <structname>v4l2_dbg_chip_ident</structname> - - &cs-str; - - - struct v4l2_dbg_match - match - How to match the chip, see . - - - __u32 - ident - A chip identifier as defined in the Linux -media/v4l2-chip-ident.h header file, or one of -the values from . - - - __u32 - revision - A chip revision, chip and driver specific. - - - -
- - - - Chip Match Types - - &cs-def; - - - V4L2_CHIP_MATCH_BRIDGE - 0 - Match the nth chip on the card, zero for the - bridge chip. Does not match sub-devices. - - - V4L2_CHIP_MATCH_I2C_DRIVER - 1 - Match an &i2c; chip by its driver name. - - - V4L2_CHIP_MATCH_I2C_ADDR - 2 - Match a chip by its 7 bit &i2c; bus address. - - - V4L2_CHIP_MATCH_AC97 - 3 - Match the nth anciliary AC97 chip. - - - V4L2_CHIP_MATCH_SUBDEV - 4 - Match the nth sub-device. Can't be used with this ioctl. - - - -
- - - - Chip Identifiers - - &cs-def; - - - V4L2_IDENT_NONE - 0 - No chip matched. - - - V4L2_IDENT_AMBIGUOUS - 1 - Multiple chips matched. - - - V4L2_IDENT_UNKNOWN - 2 - A chip is present at this address, but the driver -could not identify it. - - - -
- - - - &return-value; - - - - EINVAL - - The match_type is invalid. - - - - - diff --git a/Documentation/DocBook/media/v4l/vidioc-dbg-g-chip-info.xml b/Documentation/DocBook/media/v4l/vidioc-dbg-g-chip-info.xml index 80e8021369f6..4c4603c135fe 100644 --- a/Documentation/DocBook/media/v4l/vidioc-dbg-g-chip-info.xml +++ b/Documentation/DocBook/media/v4l/vidioc-dbg-g-chip-info.xml @@ -131,7 +131,7 @@ to the type field. char name[32] Match a chip by this name, interpreted according -to the type field. +to the type field. Currently unused. @@ -181,21 +181,6 @@ is set, then the driver supports reading registers from the device. If Match the nth chip on the card, zero for the bridge chip. Does not match sub-devices. - - V4L2_CHIP_MATCH_I2C_DRIVER - 1 - Match an &i2c; chip by its driver name. Can't be used with this ioctl. - - - V4L2_CHIP_MATCH_I2C_ADDR - 2 - Match a chip by its 7 bit &i2c; bus address. Can't be used with this ioctl. - - - V4L2_CHIP_MATCH_AC97 - 3 - Match the nth anciliary AC97 chip. Can't be used with this ioctl. - V4L2_CHIP_MATCH_SUBDEV 4 diff --git a/Documentation/DocBook/media/v4l/vidioc-dbg-g-register.xml b/Documentation/DocBook/media/v4l/vidioc-dbg-g-register.xml index e23285fad3bf..32c4bde9d4b8 100644 --- a/Documentation/DocBook/media/v4l/vidioc-dbg-g-register.xml +++ b/Documentation/DocBook/media/v4l/vidioc-dbg-g-register.xml @@ -101,27 +101,6 @@ on the TV card. The number zero always selects the host chip, ⪚ the chip connected to the PCI or USB bus. You can find out which chips are present with the &VIDIOC-DBG-G-CHIP-INFO; ioctl. - When match.type is -V4L2_CHIP_MATCH_I2C_DRIVER, -match.name contains the I2C driver name. -For instance -"saa7127" will match any chip -supported by the saa7127 driver, regardless of its &i2c; bus address. -When multiple chips supported by the same driver are present, the -effect of these ioctls is undefined. Again with the -&VIDIOC-DBG-G-CHIP-INFO; ioctl you can find out which &i2c; chips are -present. - - When match.type is -V4L2_CHIP_MATCH_I2C_ADDR, -match.addr selects a chip by its 7 bit &i2c; -bus address. - - When match.type is -V4L2_CHIP_MATCH_AC97, -match.addr selects the nth AC97 chip -on the TV card. - When match.type is V4L2_CHIP_MATCH_SUBDEV, match.addr selects the nth sub-device. @@ -160,7 +139,7 @@ access instructions. __u32 type - See for a list of + See for a list of possible types. @@ -179,7 +158,7 @@ to the type field. char name[32] Match a chip by this name, interpreted according -to the type field. +to the type field. Currently unused. @@ -231,21 +210,6 @@ register. Match the nth chip on the card, zero for the bridge chip. Does not match sub-devices. - - V4L2_CHIP_MATCH_I2C_DRIVER - 1 - Match an &i2c; chip by its driver name. - - - V4L2_CHIP_MATCH_I2C_ADDR - 2 - Match a chip by its 7 bit &i2c; bus address. - - - V4L2_CHIP_MATCH_AC97 - 3 - Match the nth anciliary AC97 chip. - V4L2_CHIP_MATCH_SUBDEV 4 From da6a855320a6e056add76ea0503b01efdbb0de36 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Sun, 26 May 2013 10:31:01 -0300 Subject: [PATCH 0378/1048] [media] DocBook: remove obsolete note from the dbg_g_register doc Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- .../DocBook/media/v4l/vidioc-dbg-g-register.xml | 9 --------- 1 file changed, 9 deletions(-) diff --git a/Documentation/DocBook/media/v4l/vidioc-dbg-g-register.xml b/Documentation/DocBook/media/v4l/vidioc-dbg-g-register.xml index 32c4bde9d4b8..3d038e75d12b 100644 --- a/Documentation/DocBook/media/v4l/vidioc-dbg-g-register.xml +++ b/Documentation/DocBook/media/v4l/vidioc-dbg-g-register.xml @@ -105,15 +105,6 @@ present with the &VIDIOC-DBG-G-CHIP-INFO; ioctl. V4L2_CHIP_MATCH_SUBDEV, match.addr selects the nth sub-device. - - Success not guaranteed - - Due to a flaw in the Linux &i2c; bus driver these ioctls may -return successfully without actually reading or writing a register. To -catch the most likely failure we recommend a &VIDIOC-DBG-G-CHIP-INFO; -call confirming the presence of the selected &i2c; chip. - - These ioctls are optional, not all drivers may support them. However when a driver supports these ioctls it must also support &VIDIOC-DBG-G-CHIP-INFO;. Conversely it may support From 7feeb1482153575bc9221eff098e9a1313522dfe Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Wed, 29 May 2013 06:22:02 -0300 Subject: [PATCH 0379/1048] [media] cx88: fix register mask Ensure that the register is aligned to a dword, otherwise the read could read out-of-range data. Signed-off-by: Hans Verkuil Cc: Mauro Carvalho Chehab Signed-off-by: Mauro Carvalho Chehab --- drivers/media/pci/cx88/cx88-video.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/media/pci/cx88/cx88-video.c b/drivers/media/pci/cx88/cx88-video.c index 5b26ece4aea5..ecf21d9f1f34 100644 --- a/drivers/media/pci/cx88/cx88-video.c +++ b/drivers/media/pci/cx88/cx88-video.c @@ -1360,7 +1360,7 @@ static int vidioc_g_register (struct file *file, void *fh, struct cx88_core *core = ((struct cx8800_fh*)fh)->dev->core; /* cx2388x has a 24-bit register space */ - reg->val = cx_read(reg->reg & 0xffffff); + reg->val = cx_read(reg->reg & 0xfffffc); reg->size = 4; return 0; } @@ -1370,7 +1370,7 @@ static int vidioc_s_register (struct file *file, void *fh, { struct cx88_core *core = ((struct cx8800_fh*)fh)->dev->core; - cx_write(reg->reg & 0xffffff, reg->val); + cx_write(reg->reg & 0xfffffc, reg->val); return 0; } #endif From 9e882e3bc97c7774b93f3db483d2e75767b5cad1 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Wed, 12 Jun 2013 06:04:04 -0300 Subject: [PATCH 0380/1048] [media] v4l2-device: check if already unregistered It was possible to unregister an already unregistered v4l2_device struct. Add a check whether that already happened and just return if that was the case. Also refuse to register a v4l2_device if both the dev and name fields are empty. A warning was already produced in that case, but since the name field is now used to detect whether or not the v4l2_device was already unregistered this particular combination should be rejected. Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/v4l2-core/v4l2-device.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/media/v4l2-core/v4l2-device.c b/drivers/media/v4l2-core/v4l2-device.c index 2dbfebc0ca85..02d1b6327117 100644 --- a/drivers/media/v4l2-core/v4l2-device.c +++ b/drivers/media/v4l2-core/v4l2-device.c @@ -44,7 +44,8 @@ int v4l2_device_register(struct device *dev, struct v4l2_device *v4l2_dev) v4l2_dev->dev = dev; if (dev == NULL) { /* If dev == NULL, then name must be filled in by the caller */ - WARN_ON(!v4l2_dev->name[0]); + if (WARN_ON(!v4l2_dev->name[0])) + return -EINVAL; return 0; } @@ -105,7 +106,9 @@ void v4l2_device_unregister(struct v4l2_device *v4l2_dev) { struct v4l2_subdev *sd, *next; - if (v4l2_dev == NULL) + /* Just return if v4l2_dev is NULL or if it was already + * unregistered before. */ + if (v4l2_dev == NULL || !v4l2_dev->name[0]) return; v4l2_device_disconnect(v4l2_dev); @@ -135,6 +138,8 @@ void v4l2_device_unregister(struct v4l2_device *v4l2_dev) } #endif } + /* Mark as unregistered, thus preventing duplicate unregistrations */ + v4l2_dev->name[0] = '\0'; } EXPORT_SYMBOL_GPL(v4l2_device_unregister); From 14381c26771f1a7d6acc57e4c944a9813596e6cf Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Mon, 10 Jun 2013 09:27:41 -0300 Subject: [PATCH 0381/1048] [media] soc_camera: replace vdev->parent by vdev->v4l2_dev The parent field will eventually disappear to be replaced by v4l2_dev. soc_camera does provide a v4l2_device struct but did not point to it in struct video_device. This is now fixed. Now the video nodes can be found under the correct platform bus, and the advanced debug ioctls work correctly as well (the core implementation of those ioctls requires that v4l2_dev is set correctly). Signed-off-by: Hans Verkuil Acked-by: Guennadi Liakhovetski Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/soc_camera/soc_camera.c | 5 +++-- include/media/soc_camera.h | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/media/platform/soc_camera/soc_camera.c b/drivers/media/platform/soc_camera/soc_camera.c index fcdd8734f3ec..5099eebf994d 100644 --- a/drivers/media/platform/soc_camera/soc_camera.c +++ b/drivers/media/platform/soc_camera/soc_camera.c @@ -524,7 +524,7 @@ static int soc_camera_open(struct file *file) return -ENODEV; } - icd = dev_get_drvdata(vdev->parent); + icd = video_get_drvdata(vdev); ici = to_soc_camera_host(icd->parent); ret = try_module_get(ici->ops->owner) ? 0 : -ENODEV; @@ -1477,7 +1477,7 @@ static int video_dev_create(struct soc_camera_device *icd) strlcpy(vdev->name, ici->drv_name, sizeof(vdev->name)); - vdev->parent = icd->pdev; + vdev->v4l2_dev = &ici->v4l2_dev; vdev->fops = &soc_camera_fops; vdev->ioctl_ops = &soc_camera_ioctl_ops; vdev->release = video_device_release; @@ -1500,6 +1500,7 @@ static int soc_camera_video_start(struct soc_camera_device *icd) if (!icd->parent) return -ENODEV; + video_set_drvdata(icd->vdev, icd); ret = video_register_device(icd->vdev, VFL_TYPE_GRABBER, -1); if (ret < 0) { dev_err(icd->pdev, "video_register_device failed: %d\n", ret); diff --git a/include/media/soc_camera.h b/include/media/soc_camera.h index ff77d08c30fd..31a4bfe42194 100644 --- a/include/media/soc_camera.h +++ b/include/media/soc_camera.h @@ -346,9 +346,9 @@ static inline struct soc_camera_subdev_desc *soc_camera_i2c_to_desc(const struct return client->dev.platform_data; } -static inline struct v4l2_subdev *soc_camera_vdev_to_subdev(const struct video_device *vdev) +static inline struct v4l2_subdev *soc_camera_vdev_to_subdev(struct video_device *vdev) { - struct soc_camera_device *icd = dev_get_drvdata(vdev->parent); + struct soc_camera_device *icd = video_get_drvdata(vdev); return soc_camera_to_subdev(icd); } From 874d91db7840d405d62450ac9b65867494ef7179 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Mon, 10 Jun 2013 07:27:37 -0300 Subject: [PATCH 0382/1048] [media] cx23885-417: use v4l2_dev instead of the deprecated parent field Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/pci/cx23885/cx23885-417.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/pci/cx23885/cx23885-417.c b/drivers/media/pci/cx23885/cx23885-417.c index f4f9ef0d98e2..e3fc2c71808a 100644 --- a/drivers/media/pci/cx23885/cx23885-417.c +++ b/drivers/media/pci/cx23885/cx23885-417.c @@ -1732,7 +1732,7 @@ static struct video_device *cx23885_video_dev_alloc( *vfd = *template; snprintf(vfd->name, sizeof(vfd->name), "%s (%s)", cx23885_boards[tsport->dev->board].name, type); - vfd->parent = &pci->dev; + vfd->v4l2_dev = &dev->v4l2_dev; vfd->release = video_device_release; return vfd; } From 9592bd0a9e74c344f674663137e5ccff7a39f7d0 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Mon, 10 Jun 2013 07:30:08 -0300 Subject: [PATCH 0383/1048] [media] zoran: use v4l2_dev instead of the deprecated parent field Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/pci/zoran/zoran_card.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/pci/zoran/zoran_card.c b/drivers/media/pci/zoran/zoran_card.c index bb53d2488ad0..923d59a321f8 100644 --- a/drivers/media/pci/zoran/zoran_card.c +++ b/drivers/media/pci/zoran/zoran_card.c @@ -1050,7 +1050,7 @@ static int zr36057_init (struct zoran *zr) * Now add the template and register the device unit. */ memcpy(zr->video_dev, &zoran_template, sizeof(zoran_template)); - zr->video_dev->parent = &zr->pci_dev->dev; + zr->video_dev->v4l2_dev = &zr->v4l2_dev; strcpy(zr->video_dev->name, ZR_DEVNAME(zr)); /* It's not a mem2mem device, but you can both capture and output from one and the same device. This should really be split up into two From f1741fa8dd4a561e883cf60f103c40eda8790d80 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Wed, 12 Jun 2013 05:46:30 -0300 Subject: [PATCH 0384/1048] [media] sn9c102_core: add v4l2_device and replace parent with v4l2_dev This driver did not yet support struct v4l2_device, so add it. This make it possible to replace the deprecated parent field with the v4l2_dev field, allowing the eventual removal of the parent field. Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/usb/sn9c102/sn9c102.h | 3 +++ drivers/media/usb/sn9c102/sn9c102_core.c | 13 ++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/drivers/media/usb/sn9c102/sn9c102.h b/drivers/media/usb/sn9c102/sn9c102.h index 2bc153e869be..8a917f060503 100644 --- a/drivers/media/usb/sn9c102/sn9c102.h +++ b/drivers/media/usb/sn9c102/sn9c102.h @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -100,6 +101,8 @@ static DECLARE_RWSEM(sn9c102_dev_lock); struct sn9c102_device { struct video_device* v4ldev; + struct v4l2_device v4l2_dev; + enum sn9c102_bridge bridge; struct sn9c102_sensor sensor; diff --git a/drivers/media/usb/sn9c102/sn9c102_core.c b/drivers/media/usb/sn9c102/sn9c102_core.c index c957e9aa6077..2cb44de2b92c 100644 --- a/drivers/media/usb/sn9c102/sn9c102_core.c +++ b/drivers/media/usb/sn9c102/sn9c102_core.c @@ -1737,6 +1737,7 @@ static void sn9c102_release_resources(struct kref *kref) video_device_node_name(cam->v4ldev)); video_set_drvdata(cam->v4ldev, NULL); video_unregister_device(cam->v4ldev); + v4l2_device_unregister(&cam->v4l2_dev); usb_put_dev(cam->usbdev); kfree(cam->control_buffer); kfree(cam); @@ -3254,6 +3255,13 @@ sn9c102_usb_probe(struct usb_interface* intf, const struct usb_device_id* id) cam->usbdev = udev; + /* register v4l2_device early so it can be used for printks */ + if (v4l2_device_register(&intf->dev, &cam->v4l2_dev)) { + dev_err(&intf->dev, "v4l2_device_register failed\n"); + err = -ENOMEM; + goto fail; + } + if (!(cam->control_buffer = kzalloc(8, GFP_KERNEL))) { DBG(1, "kzalloc() failed"); err = -ENOMEM; @@ -3325,7 +3333,7 @@ sn9c102_usb_probe(struct usb_interface* intf, const struct usb_device_id* id) strcpy(cam->v4ldev->name, "SN9C1xx PC Camera"); cam->v4ldev->fops = &sn9c102_fops; cam->v4ldev->release = video_device_release; - cam->v4ldev->parent = &udev->dev; + cam->v4ldev->v4l2_dev = &cam->v4l2_dev; init_completion(&cam->probe); @@ -3377,6 +3385,7 @@ fail: kfree(cam->control_buffer); if (cam->v4ldev) video_device_release(cam->v4ldev); + v4l2_device_unregister(&cam->v4l2_dev); kfree(cam); } return err; @@ -3407,6 +3416,8 @@ static void sn9c102_usb_disconnect(struct usb_interface* intf) wake_up_interruptible_all(&cam->wait_open); + v4l2_device_disconnect(&cam->v4l2_dev); + kref_put(&cam->kref, sn9c102_release_resources); up_write(&sn9c102_dev_lock); From d66de790c77b98589b93cb327bde2cddd2a4c2cc Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Wed, 12 Jun 2013 05:49:50 -0300 Subject: [PATCH 0385/1048] [media] saa7164: add v4l2_device and replace parent with v4l2_dev This driver did not yet support struct v4l2_device, so add it. This make it possible to replace the deprecated parent field with the v4l2_dev field, allowing the eventual removal of the parent field. Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/pci/saa7164/saa7164-core.c | 7 +++++++ drivers/media/pci/saa7164/saa7164-encoder.c | 2 +- drivers/media/pci/saa7164/saa7164-vbi.c | 2 +- drivers/media/pci/saa7164/saa7164.h | 3 +++ 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/media/pci/saa7164/saa7164-core.c b/drivers/media/pci/saa7164/saa7164-core.c index 7618fdae811e..5d27865784c5 100644 --- a/drivers/media/pci/saa7164/saa7164-core.c +++ b/drivers/media/pci/saa7164/saa7164-core.c @@ -1196,6 +1196,11 @@ static int saa7164_initdev(struct pci_dev *pci_dev, if (NULL == dev) return -ENOMEM; + if (v4l2_device_register(&pci_dev->dev, &dev->v4l2_dev)) { + dev_err(&pci_dev->dev, "v4l2_device_register failed\n"); + goto fail_free; + } + /* pci init */ dev->pci = pci_dev; if (pci_enable_device(pci_dev)) { @@ -1367,6 +1372,7 @@ fail_fw: fail_irq: saa7164_dev_unregister(dev); fail_free: + v4l2_device_unregister(&dev->v4l2_dev); kfree(dev); return err; } @@ -1439,6 +1445,7 @@ static void saa7164_finidev(struct pci_dev *pci_dev) mutex_unlock(&devlist); saa7164_dev_unregister(dev); + v4l2_device_unregister(&dev->v4l2_dev); kfree(dev); } diff --git a/drivers/media/pci/saa7164/saa7164-encoder.c b/drivers/media/pci/saa7164/saa7164-encoder.c index 7b7ed97b8503..9266965412c3 100644 --- a/drivers/media/pci/saa7164/saa7164-encoder.c +++ b/drivers/media/pci/saa7164/saa7164-encoder.c @@ -1348,7 +1348,7 @@ static struct video_device *saa7164_encoder_alloc( snprintf(vfd->name, sizeof(vfd->name), "%s %s (%s)", dev->name, type, saa7164_boards[dev->board].name); - vfd->parent = &pci->dev; + vfd->v4l2_dev = &dev->v4l2_dev; vfd->release = video_device_release; return vfd; } diff --git a/drivers/media/pci/saa7164/saa7164-vbi.c b/drivers/media/pci/saa7164/saa7164-vbi.c index 552c01ad9f63..6e025fea2542 100644 --- a/drivers/media/pci/saa7164/saa7164-vbi.c +++ b/drivers/media/pci/saa7164/saa7164-vbi.c @@ -1297,7 +1297,7 @@ static struct video_device *saa7164_vbi_alloc( snprintf(vfd->name, sizeof(vfd->name), "%s %s (%s)", dev->name, type, saa7164_boards[dev->board].name); - vfd->parent = &pci->dev; + vfd->v4l2_dev = &dev->v4l2_dev; vfd->release = video_device_release; return vfd; } diff --git a/drivers/media/pci/saa7164/saa7164.h b/drivers/media/pci/saa7164/saa7164.h index 2df47ea28289..8b29e8990301 100644 --- a/drivers/media/pci/saa7164/saa7164.h +++ b/drivers/media/pci/saa7164/saa7164.h @@ -63,6 +63,7 @@ #include #include #include +#include #include "saa7164-reg.h" #include "saa7164-types.h" @@ -427,6 +428,8 @@ struct saa7164_dev { struct list_head devlist; atomic_t refcount; + struct v4l2_device v4l2_dev; + /* pci stuff */ struct pci_dev *pci; unsigned char pci_rev, pci_lat; From a28fbd04facbffe9374f25c3a19c54ce4f186361 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Mon, 10 Jun 2013 09:16:25 -0300 Subject: [PATCH 0386/1048] [media] pvrusb2: use v4l2_dev instead of the deprecated parent field Signed-off-by: Hans Verkuil Acked-by: Mike Isely Signed-off-by: Mauro Carvalho Chehab --- drivers/media/usb/pvrusb2/pvrusb2-hdw.c | 4 ++++ drivers/media/usb/pvrusb2/pvrusb2-hdw.h | 4 ++++ drivers/media/usb/pvrusb2/pvrusb2-v4l2.c | 7 ++++--- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/drivers/media/usb/pvrusb2/pvrusb2-hdw.c b/drivers/media/usb/pvrusb2/pvrusb2-hdw.c index d32920929660..c4d51d78f837 100644 --- a/drivers/media/usb/pvrusb2/pvrusb2-hdw.c +++ b/drivers/media/usb/pvrusb2/pvrusb2-hdw.c @@ -2704,6 +2704,10 @@ static void pvr2_hdw_remove_usb_stuff(struct pvr2_hdw *hdw) pvr2_hdw_render_useless(hdw); } +void pvr2_hdw_set_v4l2_dev(struct pvr2_hdw *hdw, struct video_device *vdev) +{ + vdev->v4l2_dev = &hdw->v4l2_dev; +} /* Destroy hardware interaction structure */ void pvr2_hdw_destroy(struct pvr2_hdw *hdw) diff --git a/drivers/media/usb/pvrusb2/pvrusb2-hdw.h b/drivers/media/usb/pvrusb2/pvrusb2-hdw.h index 1a135cf6ae4e..41847076f51a 100644 --- a/drivers/media/usb/pvrusb2/pvrusb2-hdw.h +++ b/drivers/media/usb/pvrusb2/pvrusb2-hdw.h @@ -22,6 +22,7 @@ #include #include +#include #include "pvrusb2-io.h" #include "pvrusb2-ctrl.h" @@ -138,6 +139,9 @@ const char *pvr2_hdw_get_device_identifier(struct pvr2_hdw *); /* Called when hardware has been unplugged */ void pvr2_hdw_disconnect(struct pvr2_hdw *); +/* Sets v4l2_dev of a video_device struct */ +void pvr2_hdw_set_v4l2_dev(struct pvr2_hdw *, struct video_device *); + /* Get the number of defined controls */ unsigned int pvr2_hdw_get_ctrl_count(struct pvr2_hdw *); diff --git a/drivers/media/usb/pvrusb2/pvrusb2-v4l2.c b/drivers/media/usb/pvrusb2/pvrusb2-v4l2.c index 82f619ba5cca..d77069e12dc4 100644 --- a/drivers/media/usb/pvrusb2/pvrusb2-v4l2.c +++ b/drivers/media/usb/pvrusb2/pvrusb2-v4l2.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include @@ -870,8 +871,8 @@ static void pvr2_v4l2_dev_destroy(struct pvr2_v4l2_dev *dip) static void pvr2_v4l2_dev_disassociate_parent(struct pvr2_v4l2_dev *dip) { if (!dip) return; - if (!dip->devbase.parent) return; - dip->devbase.parent = NULL; + if (!dip->devbase.v4l2_dev->dev) return; + dip->devbase.v4l2_dev->dev = NULL; device_move(&dip->devbase.dev, NULL, DPM_ORDER_NONE); } @@ -1321,7 +1322,7 @@ static void pvr2_v4l2_dev_init(struct pvr2_v4l2_dev *dip, if (nr_ptr && (unit_number >= 0) && (unit_number < PVR_NUM)) { mindevnum = nr_ptr[unit_number]; } - dip->devbase.parent = &usbdev->dev; + pvr2_hdw_set_v4l2_dev(hdw, &dip->devbase); if ((video_register_device(&dip->devbase, dip->v4l_type, mindevnum) < 0) && (video_register_device(&dip->devbase, From b60f9aa1a9fcf69df963c1f06ee0594d836f6760 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Wed, 12 Jun 2013 06:02:38 -0300 Subject: [PATCH 0387/1048] [media] f_uvc: add v4l2_device and replace parent with v4l2_dev This driver did not yet support struct v4l2_device, so add it. This make it possible to replace the deprecated parent field with the v4l2_dev field, allowing the eventual removal of the parent field. Signed-off-by: Hans Verkuil Acked-by: Laurent Pinchart Signed-off-by: Mauro Carvalho Chehab --- drivers/usb/gadget/f_uvc.c | 9 ++++++++- drivers/usb/gadget/uvc.h | 2 ++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/usb/gadget/f_uvc.c b/drivers/usb/gadget/f_uvc.c index 38dcedddc52c..1d06567ff41e 100644 --- a/drivers/usb/gadget/f_uvc.c +++ b/drivers/usb/gadget/f_uvc.c @@ -413,7 +413,7 @@ uvc_register_video(struct uvc_device *uvc) if (video == NULL) return -ENOMEM; - video->parent = &cdev->gadget->dev; + video->v4l2_dev = &uvc->v4l2_dev; video->fops = &uvc_v4l2_fops; video->release = video_device_release; strlcpy(video->name, cdev->gadget->name, sizeof(video->name)); @@ -570,6 +570,7 @@ uvc_function_unbind(struct usb_configuration *c, struct usb_function *f) INFO(cdev, "uvc_function_unbind\n"); video_unregister_device(uvc->vdev); + v4l2_device_unregister(&uvc->v4l2_dev); uvc->control_ep->driver_data = NULL; uvc->video.ep->driver_data = NULL; @@ -697,6 +698,11 @@ uvc_function_bind(struct usb_configuration *c, struct usb_function *f) if ((ret = usb_function_deactivate(f)) < 0) goto error; + if (v4l2_device_register(&cdev->gadget->dev, &uvc->v4l2_dev)) { + printk(KERN_INFO "v4l2_device_register failed\n"); + goto error; + } + /* Initialise video. */ ret = uvc_video_init(&uvc->video); if (ret < 0) @@ -712,6 +718,7 @@ uvc_function_bind(struct usb_configuration *c, struct usb_function *f) return 0; error: + v4l2_device_unregister(&uvc->v4l2_dev); if (uvc->vdev) video_device_release(uvc->vdev); diff --git a/drivers/usb/gadget/uvc.h b/drivers/usb/gadget/uvc.h index 817e9e19cecf..7a9111de8054 100644 --- a/drivers/usb/gadget/uvc.h +++ b/drivers/usb/gadget/uvc.h @@ -57,6 +57,7 @@ struct uvc_event #include #include #include +#include #include "uvc_queue.h" @@ -145,6 +146,7 @@ enum uvc_state struct uvc_device { struct video_device *vdev; + struct v4l2_device v4l2_dev; enum uvc_state state; struct usb_function func; struct uvc_video video; From 7a86969bd65eb7f19ea1c281c686a75429be950a Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Wed, 12 Jun 2013 06:03:27 -0300 Subject: [PATCH 0388/1048] [media] omap24xxcam: add v4l2_device and replace parent with v4l2_dev This driver did not yet support struct v4l2_device, so add it. This make it possible to replace the deprecated parent field with the v4l2_dev field, allowing the eventual removal of the parent field. Signed-off-by: Hans Verkuil Acked-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/omap24xxcam.c | 9 ++++++++- drivers/media/platform/omap24xxcam.h | 3 +++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/omap24xxcam.c b/drivers/media/platform/omap24xxcam.c index debb44ceb185..d2b440c842b3 100644 --- a/drivers/media/platform/omap24xxcam.c +++ b/drivers/media/platform/omap24xxcam.c @@ -1656,7 +1656,7 @@ static int omap24xxcam_device_register(struct v4l2_int_device *s) } vfd->release = video_device_release; - vfd->parent = cam->dev; + vfd->v4l2_dev = &cam->v4l2_dev; strlcpy(vfd->name, CAM_NAME, sizeof(vfd->name)); vfd->fops = &omap24xxcam_fops; @@ -1752,6 +1752,11 @@ static int omap24xxcam_probe(struct platform_device *pdev) cam->dev = &pdev->dev; + if (v4l2_device_register(&pdev->dev, &cam->v4l2_dev)) { + dev_err(&pdev->dev, "v4l2_device_register failed\n"); + goto err; + } + /* * Impose a lower limit on the amount of memory allocated for * capture. We require at least enough memory to double-buffer @@ -1849,6 +1854,8 @@ static int omap24xxcam_remove(struct platform_device *pdev) cam->mmio_base_phys = 0; } + v4l2_device_unregister(&cam->v4l2_dev); + kfree(cam); return 0; diff --git a/drivers/media/platform/omap24xxcam.h b/drivers/media/platform/omap24xxcam.h index c4395956a493..7f6f79155537 100644 --- a/drivers/media/platform/omap24xxcam.h +++ b/drivers/media/platform/omap24xxcam.h @@ -29,6 +29,7 @@ #include #include +#include /* * @@ -462,6 +463,8 @@ struct omap24xxcam_device { */ struct mutex mutex; + struct v4l2_device v4l2_dev; + /*** general driver state information ***/ atomic_t users; /* From d481c581dfe43be11a17728b5c84c2d4b5beecb2 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Thu, 20 Jun 2013 10:57:10 -0300 Subject: [PATCH 0389/1048] [media] saa7134: use v4l2_dev instead of the deprecated parent field Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/pci/saa7134/saa7134-empress.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/pci/saa7134/saa7134-empress.c b/drivers/media/pci/saa7134/saa7134-empress.c index e66bc3d969cf..3022eb2a7925 100644 --- a/drivers/media/pci/saa7134/saa7134-empress.c +++ b/drivers/media/pci/saa7134/saa7134-empress.c @@ -511,7 +511,7 @@ static int empress_init(struct saa7134_dev *dev) if (NULL == dev->empress_dev) return -ENOMEM; *(dev->empress_dev) = saa7134_empress_template; - dev->empress_dev->parent = &dev->pci->dev; + dev->empress_dev->v4l2_dev = &dev->v4l2_dev; dev->empress_dev->release = video_device_release; snprintf(dev->empress_dev->name, sizeof(dev->empress_dev->name), "%s empress (%s)", dev->name, From 1c1d86a1ea07506c070cfb217a009d53990bdeb0 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Wed, 12 Jun 2013 11:15:12 -0300 Subject: [PATCH 0390/1048] [media] v4l2: always require v4l2_dev, rename parent to dev_parent The last set of drivers still using the parent field of video_device instead of the v4l2_dev field have been converted, so v4l2_dev is now always set. A proper pointer to v4l2_dev is necessary these days otherwise the advanced debugging ioctls will not work when addressing sub-devices. It also ensures that the core can always go from a video_device struct to the top-level v4l2_device struct. There is still one single use case for the parent pointer: if there are multiple busses, each being the parent of one or more video nodes, and if they all share the same v4l2_device struct. In that case one still needs a parent pointer since the v4l2_device struct can only refer to a single parent device. The cx88 driver is one such case. Unfortunately, the cx88 failed to set the parent pointer since 3.6. The next patch will correct this. In order to support this use-case the parent pointer is only renamed to dev_parent, not removed altogether. It has been renamed to ensure that the compiler will catch any (possibly out-of-tree) drivers that were missed during the conversion. Signed-off-by: Hans Verkuil Acked-by: Sakari Ailus Acked-by: Laurent Pinchart Signed-off-by: Mauro Carvalho Chehab --- drivers/media/v4l2-core/v4l2-dev.c | 34 ++++++++++++---------------- drivers/media/v4l2-core/v4l2-ioctl.c | 7 +----- include/media/v4l2-dev.h | 4 ++-- 3 files changed, 18 insertions(+), 27 deletions(-) diff --git a/drivers/media/v4l2-core/v4l2-dev.c b/drivers/media/v4l2-core/v4l2-dev.c index 0c061e16502e..c8859d6ff6ad 100644 --- a/drivers/media/v4l2-core/v4l2-dev.c +++ b/drivers/media/v4l2-core/v4l2-dev.c @@ -495,8 +495,8 @@ static const struct file_operations v4l2_fops = { }; /** - * get_index - assign stream index number based on parent device - * @vdev: video_device to assign index number to, vdev->parent should be assigned + * get_index - assign stream index number based on v4l2_dev + * @vdev: video_device to assign index number to, vdev->v4l2_dev should be assigned * * Note that when this is called the new device has not yet been registered * in the video_device array, but it was able to obtain a minor number. @@ -514,15 +514,11 @@ static int get_index(struct video_device *vdev) static DECLARE_BITMAP(used, VIDEO_NUM_DEVICES); int i; - /* Some drivers do not set the parent. In that case always return 0. */ - if (vdev->parent == NULL) - return 0; - bitmap_zero(used, VIDEO_NUM_DEVICES); for (i = 0; i < VIDEO_NUM_DEVICES; i++) { if (video_device[i] != NULL && - video_device[i]->parent == vdev->parent) { + video_device[i]->v4l2_dev == vdev->v4l2_dev) { set_bit(video_device[i]->index, used); } } @@ -775,6 +771,9 @@ int __video_register_device(struct video_device *vdev, int type, int nr, /* the release callback MUST be present */ if (WARN_ON(!vdev->release)) return -EINVAL; + /* the v4l2_dev pointer MUST be present */ + if (WARN_ON(!vdev->v4l2_dev)) + return -EINVAL; /* v4l2_fh support */ spin_lock_init(&vdev->fh_lock); @@ -802,16 +801,14 @@ int __video_register_device(struct video_device *vdev, int type, int nr, vdev->vfl_type = type; vdev->cdev = NULL; - if (vdev->v4l2_dev) { - if (vdev->v4l2_dev->dev) - vdev->parent = vdev->v4l2_dev->dev; - if (vdev->ctrl_handler == NULL) - vdev->ctrl_handler = vdev->v4l2_dev->ctrl_handler; - /* If the prio state pointer is NULL, then use the v4l2_device - prio state. */ - if (vdev->prio == NULL) - vdev->prio = &vdev->v4l2_dev->prio; - } + if (vdev->dev_parent == NULL) + vdev->dev_parent = vdev->v4l2_dev->dev; + if (vdev->ctrl_handler == NULL) + vdev->ctrl_handler = vdev->v4l2_dev->ctrl_handler; + /* If the prio state pointer is NULL, then use the v4l2_device + prio state. */ + if (vdev->prio == NULL) + vdev->prio = &vdev->v4l2_dev->prio; /* Part 2: find a free minor, device node number and device index. */ #ifdef CONFIG_VIDEO_FIXED_MINOR_RANGES @@ -896,8 +893,7 @@ int __video_register_device(struct video_device *vdev, int type, int nr, /* Part 4: register the device with sysfs */ vdev->dev.class = &video_class; vdev->dev.devt = MKDEV(VIDEO_MAJOR, vdev->minor); - if (vdev->parent) - vdev->dev.parent = vdev->parent; + vdev->dev.parent = vdev->dev_parent; dev_set_name(&vdev->dev, "%s%d", name_base, vdev->num); ret = device_register(&vdev->dev); if (ret < 0) { diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c index c9d9f01d21bc..68e6b5e912ff 100644 --- a/drivers/media/v4l2-core/v4l2-ioctl.c +++ b/drivers/media/v4l2-core/v4l2-ioctl.c @@ -1813,12 +1813,7 @@ static int v4l_dbg_g_chip_info(const struct v4l2_ioctl_ops *ops, p->flags |= V4L2_CHIP_FL_WRITABLE; if (ops->vidioc_g_register) p->flags |= V4L2_CHIP_FL_READABLE; - if (vfd->v4l2_dev) - strlcpy(p->name, vfd->v4l2_dev->name, sizeof(p->name)); - else if (vfd->parent) - strlcpy(p->name, vfd->parent->driver->name, sizeof(p->name)); - else - strlcpy(p->name, "bridge", sizeof(p->name)); + strlcpy(p->name, vfd->v4l2_dev->name, sizeof(p->name)); if (ops->vidioc_g_chip_info) return ops->vidioc_g_chip_info(file, fh, arg); if (p->match.addr) diff --git a/include/media/v4l2-dev.h b/include/media/v4l2-dev.h index b2c3776a1cff..c768c9f8abc2 100644 --- a/include/media/v4l2-dev.h +++ b/include/media/v4l2-dev.h @@ -96,9 +96,9 @@ struct video_device struct device dev; /* v4l device */ struct cdev *cdev; /* character device */ - /* Set either parent or v4l2_dev if your driver uses v4l2_device */ - struct device *parent; /* device parent */ struct v4l2_device *v4l2_dev; /* v4l2_device parent */ + /* Only set parent if that can't be deduced from v4l2_dev */ + struct device *dev_parent; /* device parent */ /* Control handler associated with this device node. May be NULL. */ struct v4l2_ctrl_handler *ctrl_handler; From e5715cfb2802cb5988f856f84454645772f4e2f5 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Wed, 12 Jun 2013 11:23:44 -0300 Subject: [PATCH 0391/1048] [media] cx88: set dev_parent to the correct parent PCI bus The cx88 driver has one v4l2_device, but the video nodes are owned by two different PCI busses. So the dev_parent pointer should be set to the correct parent bus, otherwise sysfs won't show the correct device hierarchy. This broke starting in 3.6 after a driver change, so this patch resurrects the correct behavior. Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/pci/cx88/cx88-core.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/media/pci/cx88/cx88-core.c b/drivers/media/pci/cx88/cx88-core.c index c8f3dcc579d4..ad59dc9235ae 100644 --- a/drivers/media/pci/cx88/cx88-core.c +++ b/drivers/media/pci/cx88/cx88-core.c @@ -1034,7 +1034,14 @@ struct video_device *cx88_vdev_init(struct cx88_core *core, if (NULL == vfd) return NULL; *vfd = *template_; + /* + * The dev pointer of v4l2_device is NULL, instead we set the + * video_device dev_parent pointer to the correct PCI bus device. + * This driver is a rare example where there is one v4l2_device, + * but the video nodes have different parent (PCI) devices. + */ vfd->v4l2_dev = &core->v4l2_dev; + vfd->dev_parent = &pci->dev; vfd->release = video_device_release; snprintf(vfd->name, sizeof(vfd->name), "%s %s (%s)", core->name, type, core->board.name); From 7cb59509a74da98721ac169431a9a0bd372e29b0 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Wed, 12 Jun 2013 11:28:08 -0300 Subject: [PATCH 0392/1048] [media] v4l2-framework: update documentation 'parent' was renamed to 'dev_parent'. Clarify how/when this should be used. Signed-off-by: Hans Verkuil Acked-by: Laurent Pinchart Signed-off-by: Mauro Carvalho Chehab --- Documentation/video4linux/v4l2-framework.txt | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/Documentation/video4linux/v4l2-framework.txt b/Documentation/video4linux/v4l2-framework.txt index 24353ecab197..b5e6347b720f 100644 --- a/Documentation/video4linux/v4l2-framework.txt +++ b/Documentation/video4linux/v4l2-framework.txt @@ -574,9 +574,13 @@ of the video device exits. The default video_device_release() callback just calls kfree to free the allocated memory. +There is also a video_device_release_empty() function that does nothing +(is empty) and can be used if the struct is embedded and there is nothing +to do when it is released. + You should also set these fields: -- v4l2_dev: set to the v4l2_device parent device. +- v4l2_dev: must be set to the v4l2_device parent device. - name: set to something descriptive and unique. @@ -613,15 +617,16 @@ You should also set these fields: If you want to have a separate priority state per (group of) device node(s), then you can point it to your own struct v4l2_prio_state. -- parent: you only set this if v4l2_device was registered with NULL as +- dev_parent: you only set this if v4l2_device was registered with NULL as the parent device struct. This only happens in cases where one hardware device has multiple PCI devices that all share the same v4l2_device core. The cx88 driver is an example of this: one core v4l2_device struct, but - it is used by both an raw video PCI device (cx8800) and a MPEG PCI device - (cx8802). Since the v4l2_device cannot be associated with a particular - PCI device it is setup without a parent device. But when the struct - video_device is setup you do know which parent PCI device to use. + it is used by both a raw video PCI device (cx8800) and a MPEG PCI device + (cx8802). Since the v4l2_device cannot be associated with two PCI devices + at the same time it is setup without a parent device. But when the struct + video_device is initialized you *do* know which parent PCI device to use and + so you set dev_device to the correct PCI device. - flags: optional. Set to V4L2_FL_USE_FH_PRIO if you want to let the framework handle the VIDIOC_G/S_PRIORITY ioctls. This requires that you use struct From 746cb2c31f7d88bac5453e3af45d95670a00ffe8 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 21 Jun 2013 11:19:10 -0300 Subject: [PATCH 0393/1048] [media] pvrusb2: Remove unused variable drivers/media/usb/pvrusb2/pvrusb2-v4l2.c: In function 'pvr2_v4l2_dev_init': drivers/media/usb/pvrusb2/pvrusb2-v4l2.c:1268:21: warning: variable 'usbdev' set but not used [-Wunused-but-set-variable] This warning is due to changeset a28fbd04facb, with removed the usage of usbdev inside pvr2_v4l2_dev_init(). Signed-off-by: Mauro Carvalho Chehab Cc: Hans Verkuil Cc: Mike Isely --- drivers/media/usb/pvrusb2/pvrusb2-v4l2.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/media/usb/pvrusb2/pvrusb2-v4l2.c b/drivers/media/usb/pvrusb2/pvrusb2-v4l2.c index d77069e12dc4..7c280f35eea9 100644 --- a/drivers/media/usb/pvrusb2/pvrusb2-v4l2.c +++ b/drivers/media/usb/pvrusb2/pvrusb2-v4l2.c @@ -1265,7 +1265,6 @@ static void pvr2_v4l2_dev_init(struct pvr2_v4l2_dev *dip, struct pvr2_v4l2 *vp, int v4l_type) { - struct usb_device *usbdev; int mindevnum; int unit_number; struct pvr2_hdw *hdw; @@ -1273,7 +1272,6 @@ static void pvr2_v4l2_dev_init(struct pvr2_v4l2_dev *dip, dip->v4lp = vp; hdw = vp->channel.mc_head->hdw; - usbdev = pvr2_hdw_get_dev(hdw); dip->v4l_type = v4l_type; switch (v4l_type) { case VFL_TYPE_GRABBER: From 01105690c40ceafc28df15e8b3eae6cd668229d5 Mon Sep 17 00:00:00 2001 From: "Lad, Prabhakar" Date: Mon, 17 Jun 2013 11:20:41 -0300 Subject: [PATCH 0394/1048] [media] media: davinci: vpif: remove unwanted header mach/hardware.h and sort the includes alphabetically This patch removes unwanted header include of mach/hardware.h and along side sorts the header inclusion alphabetically. Signed-off-by: Lad, Prabhakar Acked-by: Laurent Pinchart Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/davinci/vpif.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/media/platform/davinci/vpif.c b/drivers/media/platform/davinci/vpif.c index ea82a8bd2803..761c8259a8af 100644 --- a/drivers/media/platform/davinci/vpif.c +++ b/drivers/media/platform/davinci/vpif.c @@ -17,18 +17,16 @@ * GNU General Public License for more details. */ +#include #include +#include +#include #include #include -#include -#include -#include -#include #include +#include #include -#include - #include "vpif.h" MODULE_DESCRIPTION("TI DaVinci Video Port Interface driver"); From c7f808d19d344a33f6687a0558553a415eca2902 Mon Sep 17 00:00:00 2001 From: "Lad, Prabhakar" Date: Mon, 17 Jun 2013 11:20:42 -0300 Subject: [PATCH 0395/1048] [media] media: davinci: vpif: Convert to devm_* api Use devm_ioremap_resource instead of reques_mem_region()/ioremap(). This ensures more consistent error values and simplifies error paths. Signed-off-by: Lad, Prabhakar Acked-by: Laurent Pinchart Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/davinci/vpif.c | 27 ++++----------------------- 1 file changed, 4 insertions(+), 23 deletions(-) diff --git a/drivers/media/platform/davinci/vpif.c b/drivers/media/platform/davinci/vpif.c index 761c8259a8af..164c1b7b4e6f 100644 --- a/drivers/media/platform/davinci/vpif.c +++ b/drivers/media/platform/davinci/vpif.c @@ -37,8 +37,6 @@ MODULE_LICENSE("GPL"); #define VPIF_CH2_MAX_MODES (15) #define VPIF_CH3_MAX_MODES (02) -static resource_size_t res_len; -static struct resource *res; spinlock_t vpif_lock; void __iomem *vpif_base; @@ -421,23 +419,12 @@ EXPORT_SYMBOL(vpif_channel_getfid); static int vpif_probe(struct platform_device *pdev) { - int status = 0; + static struct resource *res; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (!res) - return -ENOENT; - - res_len = resource_size(res); - - res = request_mem_region(res->start, res_len, res->name); - if (!res) - return -EBUSY; - - vpif_base = ioremap(res->start, res_len); - if (!vpif_base) { - status = -EBUSY; - goto fail; - } + vpif_base = devm_ioremap_resource(&pdev->dev, res); + if (IS_ERR(vpif_base)) + return PTR_ERR(vpif_base); pm_runtime_enable(&pdev->dev); pm_runtime_get(&pdev->dev); @@ -445,17 +432,11 @@ static int vpif_probe(struct platform_device *pdev) spin_lock_init(&vpif_lock); dev_info(&pdev->dev, "vpif probe success\n"); return 0; - -fail: - release_mem_region(res->start, res_len); - return status; } static int vpif_remove(struct platform_device *pdev) { pm_runtime_disable(&pdev->dev); - iounmap(vpif_base); - release_mem_region(res->start, res_len); return 0; } From 079b3852b76a186b7c4e858420eee165c9837178 Mon Sep 17 00:00:00 2001 From: "Lad, Prabhakar" Date: Mon, 17 Jun 2013 11:20:43 -0300 Subject: [PATCH 0396/1048] [media] media: davinci: vpif: remove unnecessary braces around defines This patch removes unnecessary braces around defines. Signed-off-by: Lad, Prabhakar Acked-by: Laurent Pinchart Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/davinci/vpif.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/media/platform/davinci/vpif.c b/drivers/media/platform/davinci/vpif.c index 164c1b7b4e6f..cd08e5248387 100644 --- a/drivers/media/platform/davinci/vpif.c +++ b/drivers/media/platform/davinci/vpif.c @@ -32,10 +32,10 @@ MODULE_DESCRIPTION("TI DaVinci Video Port Interface driver"); MODULE_LICENSE("GPL"); -#define VPIF_CH0_MAX_MODES (22) -#define VPIF_CH1_MAX_MODES (02) -#define VPIF_CH2_MAX_MODES (15) -#define VPIF_CH3_MAX_MODES (02) +#define VPIF_CH0_MAX_MODES 22 +#define VPIF_CH1_MAX_MODES 2 +#define VPIF_CH2_MAX_MODES 15 +#define VPIF_CH3_MAX_MODES 2 spinlock_t vpif_lock; From 410ca6053e3c216b8ca0b05f45d6cd76b334a459 Mon Sep 17 00:00:00 2001 From: "Lad, Prabhakar" Date: Mon, 17 Jun 2013 11:20:44 -0300 Subject: [PATCH 0397/1048] [media] media: davinci: vpif_capture: move the freeing of irq and global variables to remove() Ideally the freeing of irq's and the global variables needs to be done in the remove() rather than module_exit(), this patch moves the freeing up of irq's and freeing the memory allocated to channel objects to remove() callback of struct platform_driver. Signed-off-by: Lad, Prabhakar Acked-by: Laurent Pinchart Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/davinci/vpif_capture.c | 29 +++++++------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/drivers/media/platform/davinci/vpif_capture.c b/drivers/media/platform/davinci/vpif_capture.c index d004531e740d..7d3c449d9d7d 100644 --- a/drivers/media/platform/davinci/vpif_capture.c +++ b/drivers/media/platform/davinci/vpif_capture.c @@ -2159,17 +2159,27 @@ vpif_int_err: */ static int vpif_remove(struct platform_device *device) { - int i; struct channel_obj *ch; + struct resource *res; + int irq_num, i = 0; + + while ((res = platform_get_resource(device, IORESOURCE_IRQ, i))) { + for (irq_num = res->start; irq_num <= res->end; irq_num++) + free_irq(irq_num, + (void *)(&vpif_obj.dev[i]->channel_id)); + i++; + } v4l2_device_unregister(&vpif_obj.v4l2_dev); + kfree(vpif_obj.sd); /* un-register device */ for (i = 0; i < VPIF_CAPTURE_MAX_DEVICES; i++) { /* Get the pointer to the channel object */ ch = vpif_obj.dev[i]; /* Unregister video device */ video_unregister_device(ch->video_dev); + kfree(vpif_obj.dev[i]); } return 0; } @@ -2281,24 +2291,7 @@ static __init int vpif_init(void) */ static void vpif_cleanup(void) { - struct platform_device *pdev; - struct resource *res; - int irq_num; - int i = 0; - - pdev = container_of(vpif_dev, struct platform_device, dev); - while ((res = platform_get_resource(pdev, IORESOURCE_IRQ, i))) { - for (irq_num = res->start; irq_num <= res->end; irq_num++) - free_irq(irq_num, - (void *)(&vpif_obj.dev[i]->channel_id)); - i++; - } - platform_driver_unregister(&vpif_driver); - - kfree(vpif_obj.sd); - for (i = 0; i < VPIF_CAPTURE_MAX_DEVICES; i++) - kfree(vpif_obj.dev[i]); } /* Function for module initialization and cleanup */ From fe424b2fc2674a13b7746b2cb3b0eb88b1fe182d Mon Sep 17 00:00:00 2001 From: "Lad, Prabhakar" Date: Mon, 17 Jun 2013 11:20:45 -0300 Subject: [PATCH 0398/1048] [media] media: davinci: vpif_capture: use module_platform_driver() This patch uses module_platform_driver() to simplify the code. Signed-off-by: Lad, Prabhakar Acked-by: Laurent Pinchart Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/davinci/vpif_capture.c | 28 +------------------ 1 file changed, 1 insertion(+), 27 deletions(-) diff --git a/drivers/media/platform/davinci/vpif_capture.c b/drivers/media/platform/davinci/vpif_capture.c index 7d3c449d9d7d..091c7a4c8226 100644 --- a/drivers/media/platform/davinci/vpif_capture.c +++ b/drivers/media/platform/davinci/vpif_capture.c @@ -2270,30 +2270,4 @@ static __refdata struct platform_driver vpif_driver = { .remove = vpif_remove, }; -/** - * vpif_init: initialize the vpif driver - * - * This function registers device and driver to the kernel, requests irq - * handler and allocates memory - * for channel objects - */ -static __init int vpif_init(void) -{ - return platform_driver_register(&vpif_driver); -} - -/** - * vpif_cleanup : This function clean up the vpif capture resources - * - * This will un-registers device and driver to the kernel, frees - * requested irq handler and de-allocates memory allocated for channel - * objects. - */ -static void vpif_cleanup(void) -{ - platform_driver_unregister(&vpif_driver); -} - -/* Function for module initialization and cleanup */ -module_init(vpif_init); -module_exit(vpif_cleanup); +module_platform_driver(vpif_driver); From b2de4f2584b717cb5a0d0d40a3d2fba1c2063f34 Mon Sep 17 00:00:00 2001 From: "Lad, Prabhakar" Date: Mon, 17 Jun 2013 11:20:46 -0300 Subject: [PATCH 0399/1048] [media] media: davinci: vpif_capture: Convert to devm_* api use devm_request_irq() instead of request_irq(). This ensures more consistent error values and simplifies error paths. Signed-off-by: Lad, Prabhakar Acked-by: Laurent Pinchart Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/davinci/vpif_capture.c | 36 +++++++------------ 1 file changed, 12 insertions(+), 24 deletions(-) diff --git a/drivers/media/platform/davinci/vpif_capture.c b/drivers/media/platform/davinci/vpif_capture.c index 091c7a4c8226..a4e0eab47289 100644 --- a/drivers/media/platform/davinci/vpif_capture.c +++ b/drivers/media/platform/davinci/vpif_capture.c @@ -2016,14 +2016,14 @@ static __init int vpif_probe(struct platform_device *pdev) while ((res = platform_get_resource(pdev, IORESOURCE_IRQ, res_idx))) { for (i = res->start; i <= res->end; i++) { - if (request_irq(i, vpif_channel_isr, IRQF_SHARED, - "VPIF_Capture", (void *) - (&vpif_obj.dev[res_idx]->channel_id))) { - err = -EBUSY; - for (j = 0; j < i; j++) - free_irq(j, (void *) - (&vpif_obj.dev[res_idx]->channel_id)); - goto vpif_int_err; + err = devm_request_irq(&pdev->dev, i, vpif_channel_isr, + IRQF_SHARED, "VPIF_Capture", + (void *)(&vpif_obj.dev[res_idx]-> + channel_id)); + if (err) { + err = -EINVAL; + goto vpif_unregister; + } } res_idx++; @@ -2040,7 +2040,7 @@ static __init int vpif_probe(struct platform_device *pdev) video_device_release(ch->video_dev); } err = -ENOMEM; - goto vpif_int_err; + goto vpif_unregister; } /* Initialize field of video device */ @@ -2141,13 +2141,9 @@ vpif_sd_error: /* Note: does nothing if ch->video_dev == NULL */ video_device_release(ch->video_dev); } -vpif_int_err: +vpif_unregister: v4l2_device_unregister(&vpif_obj.v4l2_dev); - for (i = 0; i < res_idx; i++) { - res = platform_get_resource(pdev, IORESOURCE_IRQ, i); - for (j = res->start; j <= res->end; j++) - free_irq(j, (void *)(&vpif_obj.dev[i]->channel_id)); - } + return err; } @@ -2160,15 +2156,7 @@ vpif_int_err: static int vpif_remove(struct platform_device *device) { struct channel_obj *ch; - struct resource *res; - int irq_num, i = 0; - - while ((res = platform_get_resource(device, IORESOURCE_IRQ, i))) { - for (irq_num = res->start; irq_num <= res->end; irq_num++) - free_irq(irq_num, - (void *)(&vpif_obj.dev[i]->channel_id)); - i++; - } + int i; v4l2_device_unregister(&vpif_obj.v4l2_dev); From a76a0b338112580593af0f68327e3cc204d4d8e7 Mon Sep 17 00:00:00 2001 From: "Lad, Prabhakar" Date: Mon, 17 Jun 2013 11:20:47 -0300 Subject: [PATCH 0400/1048] [media] media: davinci: vpif_capture: remove unnecessary loop for IRQ resource For vpif capture driver each IRQ resource contains a single IRQ so drop the second loop. Signed-off-by: Lad, Prabhakar Acked-by: Laurent Pinchart Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/davinci/vpif_capture.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/drivers/media/platform/davinci/vpif_capture.c b/drivers/media/platform/davinci/vpif_capture.c index a4e0eab47289..5514175bbd07 100644 --- a/drivers/media/platform/davinci/vpif_capture.c +++ b/drivers/media/platform/davinci/vpif_capture.c @@ -2015,16 +2015,13 @@ static __init int vpif_probe(struct platform_device *pdev) } while ((res = platform_get_resource(pdev, IORESOURCE_IRQ, res_idx))) { - for (i = res->start; i <= res->end; i++) { - err = devm_request_irq(&pdev->dev, i, vpif_channel_isr, - IRQF_SHARED, "VPIF_Capture", - (void *)(&vpif_obj.dev[res_idx]-> - channel_id)); - if (err) { - err = -EINVAL; - goto vpif_unregister; - - } + err = devm_request_irq(&pdev->dev, res->start, vpif_channel_isr, + IRQF_SHARED, "VPIF_Capture", + (void *)(&vpif_obj.dev[res_idx]-> + channel_id)); + if (err) { + err = -EINVAL; + goto vpif_unregister; } res_idx++; } From 0b361583a5e15bcf4b686cf02bd2cc3925e4005d Mon Sep 17 00:00:00 2001 From: "Lad, Prabhakar" Date: Mon, 17 Jun 2013 11:20:48 -0300 Subject: [PATCH 0401/1048] [media] media: davinci: vpif_display: move the freeing of irq and global variables to remove() Ideally the freeing of irq's and the global variables needs to be done in the remove() rather than module_exit(), this patch moves the freeing up of irq's and freeing the memory allocated to channel objects to remove() callback of struct platform_driver. Signed-off-by: Lad, Prabhakar Acked-by: Laurent Pinchart Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/davinci/vpif_display.c | 30 ++++++++----------- 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/drivers/media/platform/davinci/vpif_display.c b/drivers/media/platform/davinci/vpif_display.c index 6c521f23e40e..371af34a71be 100644 --- a/drivers/media/platform/davinci/vpif_display.c +++ b/drivers/media/platform/davinci/vpif_display.c @@ -1829,10 +1829,20 @@ vpif_int_err: static int vpif_remove(struct platform_device *device) { struct channel_obj *ch; - int i; + struct resource *res; + int irq_num; + int i = 0; + + while ((res = platform_get_resource(device, IORESOURCE_IRQ, i))) { + for (irq_num = res->start; irq_num <= res->end; irq_num++) + free_irq(irq_num, + (void *)(&vpif_obj.dev[i]->channel_id)); + i++; + } v4l2_device_unregister(&vpif_obj.v4l2_dev); + kfree(vpif_obj.sd); /* un-register device */ for (i = 0; i < VPIF_DISPLAY_MAX_DEVICES; i++) { /* Get the pointer to the channel object */ @@ -1841,6 +1851,7 @@ static int vpif_remove(struct platform_device *device) video_unregister_device(ch->video_dev); ch->video_dev = NULL; + kfree(vpif_obj.dev[i]); } return 0; @@ -1938,24 +1949,7 @@ static __init int vpif_init(void) */ static void vpif_cleanup(void) { - struct platform_device *pdev; - struct resource *res; - int irq_num; - int i = 0; - - pdev = container_of(vpif_dev, struct platform_device, dev); - - while ((res = platform_get_resource(pdev, IORESOURCE_IRQ, i))) { - for (irq_num = res->start; irq_num <= res->end; irq_num++) - free_irq(irq_num, - (void *)(&vpif_obj.dev[i]->channel_id)); - i++; - } - platform_driver_unregister(&vpif_driver); - kfree(vpif_obj.sd); - for (i = 0; i < VPIF_DISPLAY_MAX_DEVICES; i++) - kfree(vpif_obj.dev[i]); } module_init(vpif_init); From b8d067b601696f303c6623c7c1c4b7cd6e2c8321 Mon Sep 17 00:00:00 2001 From: "Lad, Prabhakar" Date: Mon, 17 Jun 2013 11:20:49 -0300 Subject: [PATCH 0402/1048] [media] media: davinci: vpif_display: use module_platform_driver() This patch uses module_platform_driver() to simplify the code. Signed-off-by: Lad, Prabhakar Acked-by: Laurent Pinchart Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/davinci/vpif_display.c | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/drivers/media/platform/davinci/vpif_display.c b/drivers/media/platform/davinci/vpif_display.c index 371af34a71be..473d1a9dd1af 100644 --- a/drivers/media/platform/davinci/vpif_display.c +++ b/drivers/media/platform/davinci/vpif_display.c @@ -1937,20 +1937,4 @@ static __refdata struct platform_driver vpif_driver = { .remove = vpif_remove, }; -static __init int vpif_init(void) -{ - return platform_driver_register(&vpif_driver); -} - -/* - * vpif_cleanup: This function un-registers device and driver to the kernel, - * frees requested irq handler and de-allocates memory allocated for channel - * objects. - */ -static void vpif_cleanup(void) -{ - platform_driver_unregister(&vpif_driver); -} - -module_init(vpif_init); -module_exit(vpif_cleanup); +module_platform_driver(vpif_driver); From 9c63e01e2b671c2810b8fbc94278a2c3c1f0491c Mon Sep 17 00:00:00 2001 From: "Lad, Prabhakar" Date: Mon, 17 Jun 2013 11:20:50 -0300 Subject: [PATCH 0403/1048] [media] media: davinci: vpif_display: Convert to devm_* api use devm_request_irq() instead of request_irq(). This ensures more consistent error values and simplifies error paths. Signed-off-by: Lad, Prabhakar Acked-by: Laurent Pinchart Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/davinci/vpif_display.c | 35 ++++++------------- 1 file changed, 10 insertions(+), 25 deletions(-) diff --git a/drivers/media/platform/davinci/vpif_display.c b/drivers/media/platform/davinci/vpif_display.c index 473d1a9dd1af..1bf289d64343 100644 --- a/drivers/media/platform/davinci/vpif_display.c +++ b/drivers/media/platform/davinci/vpif_display.c @@ -1652,15 +1652,14 @@ static __init int vpif_probe(struct platform_device *pdev) while ((res = platform_get_resource(pdev, IORESOURCE_IRQ, res_idx))) { for (i = res->start; i <= res->end; i++) { - if (request_irq(i, vpif_channel_isr, IRQF_SHARED, - "VPIF_Display", (void *) - (&vpif_obj.dev[res_idx]->channel_id))) { - err = -EBUSY; - for (j = 0; j < i; j++) - free_irq(j, (void *) - (&vpif_obj.dev[res_idx]->channel_id)); + err = devm_request_irq(&pdev->dev, i, vpif_channel_isr, + IRQF_SHARED, "VPIF_Display", + (void *)(&vpif_obj.dev[res_idx]-> + channel_id)); + if (err) { + err = -EINVAL; vpif_err("VPIF IRQ request failed\n"); - goto vpif_int_err; + goto vpif_unregister; } } res_idx++; @@ -1678,7 +1677,7 @@ static __init int vpif_probe(struct platform_device *pdev) video_device_release(ch->video_dev); } err = -ENOMEM; - goto vpif_int_err; + goto vpif_unregister; } /* Initialize field of video device */ @@ -1812,13 +1811,8 @@ vpif_sd_error: /* Note: does nothing if ch->video_dev == NULL */ video_device_release(ch->video_dev); } -vpif_int_err: +vpif_unregister: v4l2_device_unregister(&vpif_obj.v4l2_dev); - for (i = 0; i < res_idx; i++) { - res = platform_get_resource(pdev, IORESOURCE_IRQ, i); - for (j = res->start; j <= res->end; j++) - free_irq(j, (void *)(&vpif_obj.dev[i]->channel_id)); - } return err; } @@ -1829,16 +1823,7 @@ vpif_int_err: static int vpif_remove(struct platform_device *device) { struct channel_obj *ch; - struct resource *res; - int irq_num; - int i = 0; - - while ((res = platform_get_resource(device, IORESOURCE_IRQ, i))) { - for (irq_num = res->start; irq_num <= res->end; irq_num++) - free_irq(irq_num, - (void *)(&vpif_obj.dev[i]->channel_id)); - i++; - } + int i; v4l2_device_unregister(&vpif_obj.v4l2_dev); From 379d2cf4b5267ac94f8b4569545bd524e0cca29a Mon Sep 17 00:00:00 2001 From: "Lad, Prabhakar" Date: Mon, 17 Jun 2013 11:20:51 -0300 Subject: [PATCH 0404/1048] [media] media: davinci: vpif_display: remove unnecessary loop for IRQ resource For vpif display driver each IRQ resource contains a single IRQ so drop the second loop. Signed-off-by: Lad, Prabhakar Acked-by: Laurent Pinchart Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/davinci/vpif_display.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/drivers/media/platform/davinci/vpif_display.c b/drivers/media/platform/davinci/vpif_display.c index 1bf289d64343..e6e573650250 100644 --- a/drivers/media/platform/davinci/vpif_display.c +++ b/drivers/media/platform/davinci/vpif_display.c @@ -1651,16 +1651,14 @@ static __init int vpif_probe(struct platform_device *pdev) } while ((res = platform_get_resource(pdev, IORESOURCE_IRQ, res_idx))) { - for (i = res->start; i <= res->end; i++) { - err = devm_request_irq(&pdev->dev, i, vpif_channel_isr, - IRQF_SHARED, "VPIF_Display", - (void *)(&vpif_obj.dev[res_idx]-> - channel_id)); - if (err) { - err = -EINVAL; - vpif_err("VPIF IRQ request failed\n"); - goto vpif_unregister; - } + err = devm_request_irq(&pdev->dev, res->start, vpif_channel_isr, + IRQF_SHARED, "VPIF_Display", + (void *)(&vpif_obj.dev[res_idx]-> + channel_id)); + if (err) { + err = -EINVAL; + vpif_err("VPIF IRQ request failed\n"); + goto vpif_unregister; } res_idx++; } From b610b5928dc04095b9b24b83e4ddbb399d933611 Mon Sep 17 00:00:00 2001 From: "Lad, Prabhakar" Date: Tue, 4 Jun 2013 12:26:23 -0300 Subject: [PATCH 0405/1048] [media] media: i2c: tvp514x: add OF support add OF support for the tvp514x driver. Signed-off-by: Lad, Prabhakar Acked-by: Laurent Pinchart Cc: Hans Verkuil Cc: Mauro Carvalho Chehab Cc: Guennadi Liakhovetski Cc: Sylwester Nawrocki Cc: Sakari Ailus Cc: Grant Likely Cc: Rob Herring Cc: Rob Landley Cc: devicetree-discuss@lists.ozlabs.org Cc: linux-doc@vger.kernel.org Cc: linux-kernel@vger.kernel.org Cc: davinci-linux-open-source@linux.davincidsp.com Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- .../devicetree/bindings/media/i2c/tvp514x.txt | 44 +++++++++++++ drivers/media/i2c/tvp514x.c | 62 +++++++++++++++++-- 2 files changed, 100 insertions(+), 6 deletions(-) create mode 100644 Documentation/devicetree/bindings/media/i2c/tvp514x.txt diff --git a/Documentation/devicetree/bindings/media/i2c/tvp514x.txt b/Documentation/devicetree/bindings/media/i2c/tvp514x.txt new file mode 100644 index 000000000000..46752cc71f2e --- /dev/null +++ b/Documentation/devicetree/bindings/media/i2c/tvp514x.txt @@ -0,0 +1,44 @@ +* Texas Instruments TVP514x video decoder + +The TVP5146/TVP5146m2/TVP5147/TVP5147m1 device is high quality, single-chip +digital video decoder that digitizes and decodes all popular baseband analog +video formats into digital video component. The tvp514x decoder supports analog- +to-digital (A/D) conversion of component RGB and YPbPr signals as well as A/D +conversion and decoding of NTSC, PAL and SECAM composite and S-video into +component YCbCr. + +Required Properties : +- compatible : value should be either one among the following + (a) "ti,tvp5146" for tvp5146 decoder. + (b) "ti,tvp5146m2" for tvp5146m2 decoder. + (c) "ti,tvp5147" for tvp5147 decoder. + (d) "ti,tvp5147m1" for tvp5147m1 decoder. + +- hsync-active: HSYNC Polarity configuration for endpoint. + +- vsync-active: VSYNC Polarity configuration for endpoint. + +- pclk-sample: Clock polarity of the endpoint. + +For further reading on port node refer to Documentation/devicetree/bindings/ +media/video-interfaces.txt. + +Example: + + i2c0@1c22000 { + ... + ... + tvp514x@5c { + compatible = "ti,tvp5146"; + reg = <0x5c>; + + port { + tvp514x_1: endpoint { + hsync-active = <1>; + vsync-active = <1>; + pclk-sample = <0>; + }; + }; + }; + ... + }; diff --git a/drivers/media/i2c/tvp514x.c b/drivers/media/i2c/tvp514x.c index b8061b5e3eac..864eb14ae9b1 100644 --- a/drivers/media/i2c/tvp514x.c +++ b/drivers/media/i2c/tvp514x.c @@ -39,6 +39,7 @@ #include #include #include +#include #include #include #include @@ -1056,6 +1057,42 @@ static struct tvp514x_decoder tvp514x_dev = { }; +static struct tvp514x_platform_data * +tvp514x_get_pdata(struct i2c_client *client) +{ + struct tvp514x_platform_data *pdata; + struct v4l2_of_endpoint bus_cfg; + struct device_node *endpoint; + unsigned int flags; + + if (!IS_ENABLED(CONFIG_OF) || !client->dev.of_node) + return client->dev.platform_data; + + endpoint = v4l2_of_get_next_endpoint(client->dev.of_node, NULL); + if (!endpoint) + return NULL; + + pdata = devm_kzalloc(&client->dev, sizeof(*pdata), GFP_KERNEL); + if (!pdata) + goto done; + + v4l2_of_parse_endpoint(endpoint, &bus_cfg); + flags = bus_cfg.bus.parallel.flags; + + if (flags & V4L2_MBUS_HSYNC_ACTIVE_HIGH) + pdata->hs_polarity = 1; + + if (flags & V4L2_MBUS_VSYNC_ACTIVE_HIGH) + pdata->vs_polarity = 1; + + if (flags & V4L2_MBUS_PCLK_SAMPLE_RISING) + pdata->clk_polarity = 1; + +done: + of_node_put(endpoint); + return pdata; +} + /** * tvp514x_probe() - decoder driver i2c probe handler * @client: i2c driver client device structure @@ -1067,19 +1104,20 @@ static struct tvp514x_decoder tvp514x_dev = { static int tvp514x_probe(struct i2c_client *client, const struct i2c_device_id *id) { + struct tvp514x_platform_data *pdata = tvp514x_get_pdata(client); struct tvp514x_decoder *decoder; struct v4l2_subdev *sd; int ret; + if (pdata == NULL) { + dev_err(&client->dev, "No platform data\n"); + return -EINVAL; + } + /* Check if the adapter supports the needed features */ if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) return -EIO; - if (!client->dev.platform_data) { - v4l2_err(client, "No platform data!!\n"); - return -ENODEV; - } - decoder = devm_kzalloc(&client->dev, sizeof(*decoder), GFP_KERNEL); if (!decoder) return -ENOMEM; @@ -1091,7 +1129,7 @@ tvp514x_probe(struct i2c_client *client, const struct i2c_device_id *id) sizeof(tvp514x_reg_list_default)); /* Copy board specific information here */ - decoder->pdata = client->dev.platform_data; + decoder->pdata = pdata; /** * Fetch platform specific data, and configure the @@ -1231,8 +1269,20 @@ static const struct i2c_device_id tvp514x_id[] = { MODULE_DEVICE_TABLE(i2c, tvp514x_id); +#if IS_ENABLED(CONFIG_OF) +static const struct of_device_id tvp514x_of_match[] = { + { .compatible = "ti,tvp5146", }, + { .compatible = "ti,tvp5146m2", }, + { .compatible = "ti,tvp5147", }, + { .compatible = "ti,tvp5147m1", }, + { /* sentinel */ }, +}; +MODULE_DEVICE_TABLE(of, tvp514x_of_match); +#endif + static struct i2c_driver tvp514x_driver = { .driver = { + .of_match_table = of_match_ptr(tvp514x_of_match), .owner = THIS_MODULE, .name = TVP514X_MODULE_NAME, }, From 090c65b694c362adb19ec9c27de216a808ee443c Mon Sep 17 00:00:00 2001 From: Alexey Khoroshilov Date: Mon, 10 Jun 2013 17:32:29 -0300 Subject: [PATCH 0406/1048] [media] usbvision-video: fix memory leak of alt_max_pkt_size 1. usbvision->alt_max_pkt_size is not deallocated anywhere. 2. if allocation of usbvision->alt_max_pkt_size fails, there is no proper deallocation of already acquired resources. The patch adds kfree(usbvision->alt_max_pkt_size) to usbvision_release() as soon as other deallocations happen there. It calls usbvision_release() if allocation of usbvision->alt_max_pkt_size fails as soon as usbvision_release() is safe to work with incompletely initialized usbvision structure. Found by Linux Driver Verification project (linuxtesting.org). Signed-off-by: Alexey Khoroshilov Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/usb/usbvision/usbvision-video.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/media/usb/usbvision/usbvision-video.c b/drivers/media/usb/usbvision/usbvision-video.c index f0a0b7f2da92..5c9e3123ad2e 100644 --- a/drivers/media/usb/usbvision/usbvision-video.c +++ b/drivers/media/usb/usbvision/usbvision-video.c @@ -1460,6 +1460,7 @@ static void usbvision_release(struct usb_usbvision *usbvision) usbvision_remove_sysfs(usbvision->vdev); usbvision_unregister_video(usbvision); + kfree(usbvision->alt_max_pkt_size); usb_free_urb(usbvision->ctrl_urb); @@ -1575,6 +1576,7 @@ static int usbvision_probe(struct usb_interface *intf, usbvision->alt_max_pkt_size = kmalloc(32 * usbvision->num_alt, GFP_KERNEL); if (usbvision->alt_max_pkt_size == NULL) { dev_err(&intf->dev, "usbvision: out of memory!\n"); + usbvision_release(usbvision); return -ENOMEM; } From 9291682ea490756157cd26dcc94fd46bd725df6b Mon Sep 17 00:00:00 2001 From: Ondrej Zary Date: Fri, 14 Jun 2013 17:01:38 -0300 Subject: [PATCH 0407/1048] [media] radio-sf16fmi: Add module name to bus_info Fix v4l2-compliance in VIDIOC_QUERYCAP by changing "ISA" to "ISA:radio-sf16fmi". Signed-off-by: Ondrej Zary Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/radio/radio-sf16fmi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/radio/radio-sf16fmi.c b/drivers/media/radio/radio-sf16fmi.c index 9e712c8310f2..ed7299d42a24 100644 --- a/drivers/media/radio/radio-sf16fmi.c +++ b/drivers/media/radio/radio-sf16fmi.c @@ -123,7 +123,7 @@ static int vidioc_querycap(struct file *file, void *priv, { strlcpy(v->driver, "radio-sf16fmi", sizeof(v->driver)); strlcpy(v->card, "SF16-FMI/FMP/FMD radio", sizeof(v->card)); - strlcpy(v->bus_info, "ISA", sizeof(v->bus_info)); + strlcpy(v->bus_info, "ISA:radio-sf16fmi", sizeof(v->bus_info)); v->device_caps = V4L2_CAP_TUNER | V4L2_CAP_RADIO; v->capabilities = v->device_caps | V4L2_CAP_DEVICE_CAPS; return 0; From d9ec089ef248064ec9b3d027ed707ac6e0a3f2aa Mon Sep 17 00:00:00 2001 From: Ondrej Zary Date: Fri, 14 Jun 2013 17:01:39 -0300 Subject: [PATCH 0408/1048] [media] radio-sf16fmi: Set frequency during init Set freqency during initialization to fix v4l2-compliance error. This also fixes VIDIOC_G_FREQUENCY always returning zero (broken by me during LM7000 conversion). Signed-off-by: Ondrej Zary Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/radio/radio-sf16fmi.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/drivers/media/radio/radio-sf16fmi.c b/drivers/media/radio/radio-sf16fmi.c index ed7299d42a24..6f4318ff0db3 100644 --- a/drivers/media/radio/radio-sf16fmi.c +++ b/drivers/media/radio/radio-sf16fmi.c @@ -50,7 +50,7 @@ struct fmi struct video_device vdev; int io; bool mute; - unsigned long curfreq; /* freq in kHz */ + u32 curfreq; /* freq in kHz */ struct mutex lock; }; @@ -118,6 +118,14 @@ static inline int fmi_getsigstr(struct fmi *fmi) return (res & 2) ? 0 : 0xFFFF; } +static void fmi_set_freq(struct fmi *fmi) +{ + fmi->curfreq = clamp(fmi->curfreq, RSF16_MINFREQ, RSF16_MAXFREQ); + /* rounding in steps of 800 to match the freq + that will be used */ + lm7000_set_freq((fmi->curfreq / 800) * 800, fmi, fmi_set_pins); +} + static int vidioc_querycap(struct file *file, void *priv, struct v4l2_capability *v) { @@ -158,14 +166,13 @@ static int vidioc_s_frequency(struct file *file, void *priv, const struct v4l2_frequency *f) { struct fmi *fmi = video_drvdata(file); - unsigned freq = f->frequency; if (f->tuner != 0 || f->type != V4L2_TUNER_RADIO) return -EINVAL; - clamp(freq, RSF16_MINFREQ, RSF16_MAXFREQ); - /* rounding in steps of 800 to match the freq - that will be used */ - lm7000_set_freq((freq / 800) * 800, fmi, fmi_set_pins); + + fmi->curfreq = f->frequency; + fmi_set_freq(fmi); + return 0; } @@ -342,8 +349,10 @@ static int __init fmi_init(void) mutex_init(&fmi->lock); - /* mute card - prevents noisy bootups */ - fmi_mute(fmi); + /* mute card and set default frequency */ + fmi->mute = 1; + fmi->curfreq = RSF16_MINFREQ; + fmi_set_freq(fmi); if (video_register_device(&fmi->vdev, VFL_TYPE_RADIO, radio_nr) < 0) { v4l2_ctrl_handler_free(hdl); From 8fc350abc64f26f84c7f6af40e535edb754f942d Mon Sep 17 00:00:00 2001 From: "Lad, Prabhakar" Date: Sat, 15 Jun 2013 12:34:10 -0300 Subject: [PATCH 0409/1048] [media] media: i2c: ths7303: remove unused member driver_data This patch removes the driver_data member from ths7303_state structure. The driver_data member was intended to differentiate between ths7303 and ths7353 chip and get the g_chip_ident, But as of now g_chip_ident is obsolete, so there is no need of driver_data. Signed-off-by: Lad, Prabhakar Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/i2c/ths7303.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/media/i2c/ths7303.c b/drivers/media/i2c/ths7303.c index 2e17abc77310..0a2dacbd7a63 100644 --- a/drivers/media/i2c/ths7303.c +++ b/drivers/media/i2c/ths7303.c @@ -38,7 +38,6 @@ struct ths7303_state { struct v4l2_bt_timings bt; int std_id; int stream_on; - int driver_data; }; enum ths7303_filter_mode { @@ -355,9 +354,6 @@ static int ths7303_probe(struct i2c_client *client, sd = &state->sd; v4l2_i2c_subdev_init(sd, client, &ths7303_ops); - /* store the driver data to differntiate the chip */ - state->driver_data = (int)id->driver_data; - /* set to default 480I_576I filter mode */ if (ths7303_setval(sd, THS7303_FILTER_MODE_480I_576I) < 0) { v4l_err(client, "Setting to 480I_576I filter mode failed!\n"); From f3d27f34fdd7701e499617d2c1d94480a98f6d07 Mon Sep 17 00:00:00 2001 From: Lubomir Rintel Date: Mon, 17 Jun 2013 10:29:06 -0300 Subject: [PATCH 0410/1048] [media] usbtv: Add driver for Fushicai USBTV007 video frame grabber Reverse-engineered driver for cheapo video digitizer, made from observations of Windows XP driver. The protocol is not yet completely understood, so far we don't provide any controls, only support a single format out of three and don't support the audio device. Signed-off-by: Lubomir Rintel Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/usb/Kconfig | 1 + drivers/media/usb/Makefile | 1 + drivers/media/usb/usbtv/Kconfig | 10 + drivers/media/usb/usbtv/Makefile | 1 + drivers/media/usb/usbtv/usbtv.c | 696 +++++++++++++++++++++++++++++++ 5 files changed, 709 insertions(+) create mode 100644 drivers/media/usb/usbtv/Kconfig create mode 100644 drivers/media/usb/usbtv/Makefile create mode 100644 drivers/media/usb/usbtv/usbtv.c diff --git a/drivers/media/usb/Kconfig b/drivers/media/usb/Kconfig index 7cac453e34c7..cfe8056b91aa 100644 --- a/drivers/media/usb/Kconfig +++ b/drivers/media/usb/Kconfig @@ -18,6 +18,7 @@ source "drivers/media/usb/zr364xx/Kconfig" source "drivers/media/usb/stkwebcam/Kconfig" source "drivers/media/usb/s2255/Kconfig" source "drivers/media/usb/sn9c102/Kconfig" +source "drivers/media/usb/usbtv/Kconfig" endif if MEDIA_ANALOG_TV_SUPPORT diff --git a/drivers/media/usb/Makefile b/drivers/media/usb/Makefile index 7f51d7e5f739..0935f47497a6 100644 --- a/drivers/media/usb/Makefile +++ b/drivers/media/usb/Makefile @@ -20,3 +20,4 @@ obj-$(CONFIG_VIDEO_STK1160) += stk1160/ obj-$(CONFIG_VIDEO_CX231XX) += cx231xx/ obj-$(CONFIG_VIDEO_TM6000) += tm6000/ obj-$(CONFIG_VIDEO_EM28XX) += em28xx/ +obj-$(CONFIG_VIDEO_USBTV) += usbtv/ diff --git a/drivers/media/usb/usbtv/Kconfig b/drivers/media/usb/usbtv/Kconfig new file mode 100644 index 000000000000..8864436464bf --- /dev/null +++ b/drivers/media/usb/usbtv/Kconfig @@ -0,0 +1,10 @@ +config VIDEO_USBTV + tristate "USBTV007 video capture support" + depends on VIDEO_DEV + select VIDEOBUF2_VMALLOC + + ---help--- + This is a video4linux2 driver for USBTV007 based video capture devices. + + To compile this driver as a module, choose M here: the + module will be called usbtv diff --git a/drivers/media/usb/usbtv/Makefile b/drivers/media/usb/usbtv/Makefile new file mode 100644 index 000000000000..28b872fa94e1 --- /dev/null +++ b/drivers/media/usb/usbtv/Makefile @@ -0,0 +1 @@ +obj-$(CONFIG_VIDEO_USBTV) += usbtv.o diff --git a/drivers/media/usb/usbtv/usbtv.c b/drivers/media/usb/usbtv/usbtv.c new file mode 100644 index 000000000000..bf43f874685e --- /dev/null +++ b/drivers/media/usb/usbtv/usbtv.c @@ -0,0 +1,696 @@ +/* + * Fushicai USBTV007 Video Grabber Driver + * + * Product web site: + * http://www.fushicai.com/products_detail/&productId=d05449ee-b690-42f9-a661-aa7353894bed.html + * + * Following LWN articles were very useful in construction of this driver: + * Video4Linux2 API series: http://lwn.net/Articles/203924/ + * videobuf2 API explanation: http://lwn.net/Articles/447435/ + * Thanks go to Jonathan Corbet for providing this quality documentation. + * He is awesome. + * + * Copyright (c) 2013 Lubomir Rintel + * All rights reserved. + * No physical hardware was harmed running Windows during the + * reverse-engineering activity + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions, and the following disclaimer, + * without modification. + * 2. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL"). + */ + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +/* Hardware. */ +#define USBTV_VIDEO_ENDP 0x81 +#define USBTV_BASE 0xc000 +#define USBTV_REQUEST_REG 12 + +/* Number of concurrent isochronous urbs submitted. + * Higher numbers was seen to overly saturate the USB bus. */ +#define USBTV_ISOC_TRANSFERS 16 +#define USBTV_ISOC_PACKETS 8 + +#define USBTV_WIDTH 720 +#define USBTV_HEIGHT 480 + +#define USBTV_CHUNK_SIZE 256 +#define USBTV_CHUNK 240 +#define USBTV_CHUNKS (USBTV_WIDTH * USBTV_HEIGHT \ + / 2 / USBTV_CHUNK) + +/* Chunk header. */ +#define USBTV_MAGIC_OK(chunk) ((be32_to_cpu(chunk[0]) & 0xff000000) \ + == 0x88000000) +#define USBTV_FRAME_ID(chunk) ((be32_to_cpu(chunk[0]) & 0x00ff0000) >> 16) +#define USBTV_ODD(chunk) ((be32_to_cpu(chunk[0]) & 0x0000f000) >> 15) +#define USBTV_CHUNK_NO(chunk) (be32_to_cpu(chunk[0]) & 0x00000fff) + +/* A single videobuf2 frame buffer. */ +struct usbtv_buf { + struct vb2_buffer vb; + struct list_head list; +}; + +/* Per-device structure. */ +struct usbtv { + struct device *dev; + struct usb_device *udev; + struct v4l2_device v4l2_dev; + struct video_device vdev; + struct vb2_queue vb2q; + struct mutex v4l2_lock; + struct mutex vb2q_lock; + + /* List of videobuf2 buffers protected by a lock. */ + spinlock_t buflock; + struct list_head bufs; + + /* Number of currently processed frame, useful find + * out when a new one begins. */ + u32 frame_id; + + int iso_size; + unsigned int sequence; + struct urb *isoc_urbs[USBTV_ISOC_TRANSFERS]; +}; + +static int usbtv_setup_capture(struct usbtv *usbtv) +{ + int ret; + int pipe = usb_rcvctrlpipe(usbtv->udev, 0); + int i; + static const u16 protoregs[][2] = { + /* These seem to enable the device. */ + { USBTV_BASE + 0x0008, 0x0001 }, + { USBTV_BASE + 0x01d0, 0x00ff }, + { USBTV_BASE + 0x01d9, 0x0002 }, + + /* These seem to influence color parameters, such as + * brightness, etc. */ + { USBTV_BASE + 0x0239, 0x0040 }, + { USBTV_BASE + 0x0240, 0x0000 }, + { USBTV_BASE + 0x0241, 0x0000 }, + { USBTV_BASE + 0x0242, 0x0002 }, + { USBTV_BASE + 0x0243, 0x0080 }, + { USBTV_BASE + 0x0244, 0x0012 }, + { USBTV_BASE + 0x0245, 0x0090 }, + { USBTV_BASE + 0x0246, 0x0000 }, + + { USBTV_BASE + 0x0278, 0x002d }, + { USBTV_BASE + 0x0279, 0x000a }, + { USBTV_BASE + 0x027a, 0x0032 }, + { 0xf890, 0x000c }, + { 0xf894, 0x0086 }, + + { USBTV_BASE + 0x00ac, 0x00c0 }, + { USBTV_BASE + 0x00ad, 0x0000 }, + { USBTV_BASE + 0x00a2, 0x0012 }, + { USBTV_BASE + 0x00a3, 0x00e0 }, + { USBTV_BASE + 0x00a4, 0x0028 }, + { USBTV_BASE + 0x00a5, 0x0082 }, + { USBTV_BASE + 0x00a7, 0x0080 }, + { USBTV_BASE + 0x0000, 0x0014 }, + { USBTV_BASE + 0x0006, 0x0003 }, + { USBTV_BASE + 0x0090, 0x0099 }, + { USBTV_BASE + 0x0091, 0x0090 }, + { USBTV_BASE + 0x0094, 0x0068 }, + { USBTV_BASE + 0x0095, 0x0070 }, + { USBTV_BASE + 0x009c, 0x0030 }, + { USBTV_BASE + 0x009d, 0x00c0 }, + { USBTV_BASE + 0x009e, 0x00e0 }, + { USBTV_BASE + 0x0019, 0x0006 }, + { USBTV_BASE + 0x008c, 0x00ba }, + { USBTV_BASE + 0x0101, 0x00ff }, + { USBTV_BASE + 0x010c, 0x00b3 }, + { USBTV_BASE + 0x01b2, 0x0080 }, + { USBTV_BASE + 0x01b4, 0x00a0 }, + { USBTV_BASE + 0x014c, 0x00ff }, + { USBTV_BASE + 0x014d, 0x00ca }, + { USBTV_BASE + 0x0113, 0x0053 }, + { USBTV_BASE + 0x0119, 0x008a }, + { USBTV_BASE + 0x013c, 0x0003 }, + { USBTV_BASE + 0x0150, 0x009c }, + { USBTV_BASE + 0x0151, 0x0071 }, + { USBTV_BASE + 0x0152, 0x00c6 }, + { USBTV_BASE + 0x0153, 0x0084 }, + { USBTV_BASE + 0x0154, 0x00bc }, + { USBTV_BASE + 0x0155, 0x00a0 }, + { USBTV_BASE + 0x0156, 0x00a0 }, + { USBTV_BASE + 0x0157, 0x009c }, + { USBTV_BASE + 0x0158, 0x001f }, + { USBTV_BASE + 0x0159, 0x0006 }, + { USBTV_BASE + 0x015d, 0x0000 }, + + { USBTV_BASE + 0x0284, 0x0088 }, + { USBTV_BASE + 0x0003, 0x0004 }, + { USBTV_BASE + 0x001a, 0x0079 }, + { USBTV_BASE + 0x0100, 0x00d3 }, + { USBTV_BASE + 0x010e, 0x0068 }, + { USBTV_BASE + 0x010f, 0x009c }, + { USBTV_BASE + 0x0112, 0x00f0 }, + { USBTV_BASE + 0x0115, 0x0015 }, + { USBTV_BASE + 0x0117, 0x0000 }, + { USBTV_BASE + 0x0118, 0x00fc }, + { USBTV_BASE + 0x012d, 0x0004 }, + { USBTV_BASE + 0x012f, 0x0008 }, + { USBTV_BASE + 0x0220, 0x002e }, + { USBTV_BASE + 0x0225, 0x0008 }, + { USBTV_BASE + 0x024e, 0x0002 }, + { USBTV_BASE + 0x024f, 0x0001 }, + { USBTV_BASE + 0x0254, 0x005f }, + { USBTV_BASE + 0x025a, 0x0012 }, + { USBTV_BASE + 0x025b, 0x0001 }, + { USBTV_BASE + 0x0263, 0x001c }, + { USBTV_BASE + 0x0266, 0x0011 }, + { USBTV_BASE + 0x0267, 0x0005 }, + { USBTV_BASE + 0x024e, 0x0002 }, + { USBTV_BASE + 0x024f, 0x0002 }, + }; + + for (i = 0; i < ARRAY_SIZE(protoregs); i++) { + u16 index = protoregs[i][0]; + u16 value = protoregs[i][1]; + + ret = usb_control_msg(usbtv->udev, pipe, USBTV_REQUEST_REG, + USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, + value, index, NULL, 0, 0); + if (ret < 0) + return ret; + } + + return 0; +} + +/* Called for each 256-byte image chunk. + * First word identifies the chunk, followed by 240 words of image + * data and padding. */ +static void usbtv_image_chunk(struct usbtv *usbtv, u32 *chunk) +{ + int frame_id, odd, chunk_no; + u32 *frame; + struct usbtv_buf *buf; + unsigned long flags; + + /* Ignore corrupted lines. */ + if (!USBTV_MAGIC_OK(chunk)) + return; + frame_id = USBTV_FRAME_ID(chunk); + odd = USBTV_ODD(chunk); + chunk_no = USBTV_CHUNK_NO(chunk); + + /* Deinterlace. TODO: Use interlaced frame format. */ + chunk_no = (chunk_no - chunk_no % 3) * 2 + chunk_no % 3; + chunk_no += !odd * 3; + + if (chunk_no >= USBTV_CHUNKS) + return; + + /* Beginning of a frame. */ + if (chunk_no == 0) + usbtv->frame_id = frame_id; + + spin_lock_irqsave(&usbtv->buflock, flags); + if (list_empty(&usbtv->bufs)) { + /* No free buffers. Userspace likely too slow. */ + spin_unlock_irqrestore(&usbtv->buflock, flags); + return; + } + + /* First available buffer. */ + buf = list_first_entry(&usbtv->bufs, struct usbtv_buf, list); + frame = vb2_plane_vaddr(&buf->vb, 0); + + /* Copy the chunk. */ + memcpy(&frame[chunk_no * USBTV_CHUNK], &chunk[1], + USBTV_CHUNK * sizeof(chunk[1])); + + /* Last chunk in a frame, signalling an end */ + if (usbtv->frame_id && chunk_no == USBTV_CHUNKS-1) { + int size = vb2_plane_size(&buf->vb, 0); + + buf->vb.v4l2_buf.field = V4L2_FIELD_INTERLACED; + buf->vb.v4l2_buf.sequence = usbtv->sequence++; + v4l2_get_timestamp(&buf->vb.v4l2_buf.timestamp); + vb2_set_plane_payload(&buf->vb, 0, size); + vb2_buffer_done(&buf->vb, VB2_BUF_STATE_DONE); + list_del(&buf->list); + } + + spin_unlock_irqrestore(&usbtv->buflock, flags); +} + +/* Got image data. Each packet contains a number of 256-word chunks we + * compose the image from. */ +static void usbtv_iso_cb(struct urb *ip) +{ + int ret; + int i; + struct usbtv *usbtv = (struct usbtv *)ip->context; + + switch (ip->status) { + /* All fine. */ + case 0: + break; + /* Device disconnected or capture stopped? */ + case -ENODEV: + case -ENOENT: + case -ECONNRESET: + case -ESHUTDOWN: + return; + /* Unknown error. Retry. */ + default: + dev_warn(usbtv->dev, "Bad response for ISO request.\n"); + goto resubmit; + } + + for (i = 0; i < ip->number_of_packets; i++) { + int size = ip->iso_frame_desc[i].actual_length; + unsigned char *data = ip->transfer_buffer + + ip->iso_frame_desc[i].offset; + int offset; + + for (offset = 0; USBTV_CHUNK_SIZE * offset < size; offset++) + usbtv_image_chunk(usbtv, + (u32 *)&data[USBTV_CHUNK_SIZE * offset]); + } + +resubmit: + ret = usb_submit_urb(ip, GFP_ATOMIC); + if (ret < 0) + dev_warn(usbtv->dev, "Could not resubmit ISO URB\n"); +} + +static struct urb *usbtv_setup_iso_transfer(struct usbtv *usbtv) +{ + struct urb *ip; + int size = usbtv->iso_size; + int i; + + ip = usb_alloc_urb(USBTV_ISOC_PACKETS, GFP_KERNEL); + if (ip == NULL) + return NULL; + + ip->dev = usbtv->udev; + ip->context = usbtv; + ip->pipe = usb_rcvisocpipe(usbtv->udev, USBTV_VIDEO_ENDP); + ip->interval = 1; + ip->transfer_flags = URB_ISO_ASAP; + ip->transfer_buffer = kzalloc(size * USBTV_ISOC_PACKETS, + GFP_KERNEL); + ip->complete = usbtv_iso_cb; + ip->number_of_packets = USBTV_ISOC_PACKETS; + ip->transfer_buffer_length = size * USBTV_ISOC_PACKETS; + for (i = 0; i < USBTV_ISOC_PACKETS; i++) { + ip->iso_frame_desc[i].offset = size * i; + ip->iso_frame_desc[i].length = size; + } + + return ip; +} + +static void usbtv_stop(struct usbtv *usbtv) +{ + int i; + unsigned long flags; + + /* Cancel running transfers. */ + for (i = 0; i < USBTV_ISOC_TRANSFERS; i++) { + struct urb *ip = usbtv->isoc_urbs[i]; + if (ip == NULL) + continue; + usb_kill_urb(ip); + kfree(ip->transfer_buffer); + usb_free_urb(ip); + usbtv->isoc_urbs[i] = NULL; + } + + /* Return buffers to userspace. */ + spin_lock_irqsave(&usbtv->buflock, flags); + while (!list_empty(&usbtv->bufs)) { + struct usbtv_buf *buf = list_first_entry(&usbtv->bufs, + struct usbtv_buf, list); + vb2_buffer_done(&buf->vb, VB2_BUF_STATE_ERROR); + list_del(&buf->list); + } + spin_unlock_irqrestore(&usbtv->buflock, flags); +} + +static int usbtv_start(struct usbtv *usbtv) +{ + int i; + int ret; + + ret = usb_set_interface(usbtv->udev, 0, 0); + if (ret < 0) + return ret; + + ret = usbtv_setup_capture(usbtv); + if (ret < 0) + return ret; + + ret = usb_set_interface(usbtv->udev, 0, 1); + if (ret < 0) + return ret; + + for (i = 0; i < USBTV_ISOC_TRANSFERS; i++) { + struct urb *ip; + + ip = usbtv_setup_iso_transfer(usbtv); + if (ip == NULL) { + ret = -ENOMEM; + goto start_fail; + } + usbtv->isoc_urbs[i] = ip; + + ret = usb_submit_urb(ip, GFP_KERNEL); + if (ret < 0) + goto start_fail; + } + + return 0; + +start_fail: + usbtv_stop(usbtv); + return ret; +} + +struct usb_device_id usbtv_id_table[] = { + { USB_DEVICE(0x1b71, 0x3002) }, + {} +}; +MODULE_DEVICE_TABLE(usb, usbtv_id_table); + +static int usbtv_querycap(struct file *file, void *priv, + struct v4l2_capability *cap) +{ + struct usbtv *dev = video_drvdata(file); + + strlcpy(cap->driver, "usbtv", sizeof(cap->driver)); + strlcpy(cap->card, "usbtv", sizeof(cap->card)); + usb_make_path(dev->udev, cap->bus_info, sizeof(cap->bus_info)); + cap->device_caps = V4L2_CAP_VIDEO_CAPTURE; + cap->device_caps |= V4L2_CAP_READWRITE | V4L2_CAP_STREAMING; + cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS; + return 0; +} + +static int usbtv_enum_input(struct file *file, void *priv, + struct v4l2_input *i) +{ + if (i->index > 0) + return -EINVAL; + + strlcpy(i->name, "Composite", sizeof(i->name)); + i->type = V4L2_INPUT_TYPE_CAMERA; + i->std = V4L2_STD_525_60; + return 0; +} + +static int usbtv_enum_fmt_vid_cap(struct file *file, void *priv, + struct v4l2_fmtdesc *f) +{ + if (f->index > 0) + return -EINVAL; + + strlcpy(f->description, "16 bpp YUY2, 4:2:2, packed", + sizeof(f->description)); + f->pixelformat = V4L2_PIX_FMT_YUYV; + return 0; +} + +static int usbtv_fmt_vid_cap(struct file *file, void *priv, + struct v4l2_format *f) +{ + f->fmt.pix.width = USBTV_WIDTH; + f->fmt.pix.height = USBTV_HEIGHT; + f->fmt.pix.pixelformat = V4L2_PIX_FMT_YUYV; + f->fmt.pix.field = V4L2_FIELD_INTERLACED; + f->fmt.pix.bytesperline = USBTV_WIDTH * 2; + f->fmt.pix.sizeimage = (f->fmt.pix.bytesperline * f->fmt.pix.height); + f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M; + f->fmt.pix.priv = 0; + return 0; +} + +static int usbtv_g_std(struct file *file, void *priv, v4l2_std_id *norm) +{ + *norm = V4L2_STD_525_60; + return 0; +} + +static int usbtv_g_input(struct file *file, void *priv, unsigned int *i) +{ + *i = 0; + return 0; +} + +static int usbtv_s_input(struct file *file, void *priv, unsigned int i) +{ + if (i > 0) + return -EINVAL; + return 0; +} + +static int usbtv_s_std(struct file *file, void *priv, v4l2_std_id norm) +{ + if (norm & V4L2_STD_525_60) + return 0; + return -EINVAL; +} + +struct v4l2_ioctl_ops usbtv_ioctl_ops = { + .vidioc_querycap = usbtv_querycap, + .vidioc_enum_input = usbtv_enum_input, + .vidioc_enum_fmt_vid_cap = usbtv_enum_fmt_vid_cap, + .vidioc_g_fmt_vid_cap = usbtv_fmt_vid_cap, + .vidioc_try_fmt_vid_cap = usbtv_fmt_vid_cap, + .vidioc_s_fmt_vid_cap = usbtv_fmt_vid_cap, + .vidioc_g_std = usbtv_g_std, + .vidioc_s_std = usbtv_s_std, + .vidioc_g_input = usbtv_g_input, + .vidioc_s_input = usbtv_s_input, + + .vidioc_reqbufs = vb2_ioctl_reqbufs, + .vidioc_prepare_buf = vb2_ioctl_prepare_buf, + .vidioc_querybuf = vb2_ioctl_querybuf, + .vidioc_create_bufs = vb2_ioctl_create_bufs, + .vidioc_qbuf = vb2_ioctl_qbuf, + .vidioc_dqbuf = vb2_ioctl_dqbuf, + .vidioc_streamon = vb2_ioctl_streamon, + .vidioc_streamoff = vb2_ioctl_streamoff, +}; + +struct v4l2_file_operations usbtv_fops = { + .owner = THIS_MODULE, + .unlocked_ioctl = video_ioctl2, + .mmap = vb2_fop_mmap, + .open = v4l2_fh_open, + .release = vb2_fop_release, + .read = vb2_fop_read, + .poll = vb2_fop_poll, +}; + +static int usbtv_queue_setup(struct vb2_queue *vq, + const struct v4l2_format *v4l_fmt, unsigned int *nbuffers, + unsigned int *nplanes, unsigned int sizes[], void *alloc_ctxs[]) +{ + if (*nbuffers < 2) + *nbuffers = 2; + *nplanes = 1; + sizes[0] = USBTV_CHUNK * USBTV_CHUNKS * sizeof(u32); + + return 0; +} + +static void usbtv_buf_queue(struct vb2_buffer *vb) +{ + struct usbtv *usbtv = vb2_get_drv_priv(vb->vb2_queue); + struct usbtv_buf *buf = container_of(vb, struct usbtv_buf, vb); + unsigned long flags; + + if (usbtv->udev == NULL) { + vb2_buffer_done(vb, VB2_BUF_STATE_ERROR); + return; + } + + spin_lock_irqsave(&usbtv->buflock, flags); + list_add_tail(&buf->list, &usbtv->bufs); + spin_unlock_irqrestore(&usbtv->buflock, flags); +} + +static int usbtv_start_streaming(struct vb2_queue *vq, unsigned int count) +{ + struct usbtv *usbtv = vb2_get_drv_priv(vq); + + if (usbtv->udev == NULL) + return -ENODEV; + + return usbtv_start(usbtv); +} + +static int usbtv_stop_streaming(struct vb2_queue *vq) +{ + struct usbtv *usbtv = vb2_get_drv_priv(vq); + + if (usbtv->udev == NULL) + return -ENODEV; + + usbtv_stop(usbtv); + return 0; +} + +struct vb2_ops usbtv_vb2_ops = { + .queue_setup = usbtv_queue_setup, + .buf_queue = usbtv_buf_queue, + .start_streaming = usbtv_start_streaming, + .stop_streaming = usbtv_stop_streaming, +}; + +static void usbtv_release(struct v4l2_device *v4l2_dev) +{ + struct usbtv *usbtv = container_of(v4l2_dev, struct usbtv, v4l2_dev); + + v4l2_device_unregister(&usbtv->v4l2_dev); + vb2_queue_release(&usbtv->vb2q); + kfree(usbtv); +} + +static int usbtv_probe(struct usb_interface *intf, + const struct usb_device_id *id) +{ + int ret; + int size; + struct device *dev = &intf->dev; + struct usbtv *usbtv; + + /* Checks that the device is what we think it is. */ + if (intf->num_altsetting != 2) + return -ENODEV; + if (intf->altsetting[1].desc.bNumEndpoints != 4) + return -ENODEV; + + /* Packet size is split into 11 bits of base size and count of + * extra multiplies of it.*/ + size = usb_endpoint_maxp(&intf->altsetting[1].endpoint[0].desc); + size = (size & 0x07ff) * (((size & 0x1800) >> 11) + 1); + + /* Device structure */ + usbtv = kzalloc(sizeof(struct usbtv), GFP_KERNEL); + if (usbtv == NULL) + return -ENOMEM; + usbtv->dev = dev; + usbtv->udev = usb_get_dev(interface_to_usbdev(intf)); + usbtv->iso_size = size; + spin_lock_init(&usbtv->buflock); + mutex_init(&usbtv->v4l2_lock); + mutex_init(&usbtv->vb2q_lock); + INIT_LIST_HEAD(&usbtv->bufs); + + /* videobuf2 structure */ + usbtv->vb2q.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; + usbtv->vb2q.io_modes = VB2_MMAP | VB2_USERPTR | VB2_READ; + usbtv->vb2q.drv_priv = usbtv; + usbtv->vb2q.buf_struct_size = sizeof(struct usbtv_buf); + usbtv->vb2q.ops = &usbtv_vb2_ops; + usbtv->vb2q.mem_ops = &vb2_vmalloc_memops; + usbtv->vb2q.timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; + usbtv->vb2q.lock = &usbtv->vb2q_lock; + ret = vb2_queue_init(&usbtv->vb2q); + if (ret < 0) { + dev_warn(dev, "Could not initialize videobuf2 queue\n"); + goto usbtv_fail; + } + + /* v4l2 structure */ + usbtv->v4l2_dev.release = usbtv_release; + ret = v4l2_device_register(dev, &usbtv->v4l2_dev); + if (ret < 0) { + dev_warn(dev, "Could not register v4l2 device\n"); + goto v4l2_fail; + } + + usb_set_intfdata(intf, usbtv); + + /* Video structure */ + strlcpy(usbtv->vdev.name, "usbtv", sizeof(usbtv->vdev.name)); + usbtv->vdev.v4l2_dev = &usbtv->v4l2_dev; + usbtv->vdev.release = video_device_release_empty; + usbtv->vdev.fops = &usbtv_fops; + usbtv->vdev.ioctl_ops = &usbtv_ioctl_ops; + usbtv->vdev.tvnorms = V4L2_STD_525_60; + usbtv->vdev.queue = &usbtv->vb2q; + usbtv->vdev.lock = &usbtv->v4l2_lock; + set_bit(V4L2_FL_USE_FH_PRIO, &usbtv->vdev.flags); + video_set_drvdata(&usbtv->vdev, usbtv); + ret = video_register_device(&usbtv->vdev, VFL_TYPE_GRABBER, -1); + if (ret < 0) { + dev_warn(dev, "Could not register video device\n"); + goto vdev_fail; + } + + dev_info(dev, "Fushicai USBTV007 Video Grabber\n"); + return 0; + +vdev_fail: + v4l2_device_unregister(&usbtv->v4l2_dev); +v4l2_fail: + vb2_queue_release(&usbtv->vb2q); +usbtv_fail: + kfree(usbtv); + + return ret; +} + +static void usbtv_disconnect(struct usb_interface *intf) +{ + struct usbtv *usbtv = usb_get_intfdata(intf); + + mutex_lock(&usbtv->vb2q_lock); + mutex_lock(&usbtv->v4l2_lock); + + usbtv_stop(usbtv); + usb_set_intfdata(intf, NULL); + video_unregister_device(&usbtv->vdev); + v4l2_device_disconnect(&usbtv->v4l2_dev); + usb_put_dev(usbtv->udev); + usbtv->udev = NULL; + + mutex_unlock(&usbtv->v4l2_lock); + mutex_unlock(&usbtv->vb2q_lock); + + v4l2_device_put(&usbtv->v4l2_dev); +} + +MODULE_AUTHOR("Lubomir Rintel"); +MODULE_DESCRIPTION("Fushicai USBTV007 Video Grabber Driver"); +MODULE_LICENSE("Dual BSD/GPL"); + +struct usb_driver usbtv_usb_driver = { + .name = "usbtv", + .id_table = usbtv_id_table, + .probe = usbtv_probe, + .disconnect = usbtv_disconnect, +}; + +module_usb_driver(usbtv_usb_driver); From 5e7db0389fd05ba8721df3978b76156917cb4256 Mon Sep 17 00:00:00 2001 From: Alexey Khoroshilov Date: Wed, 19 Jun 2013 16:57:40 -0300 Subject: [PATCH 0411/1048] [media] go7007: fix return 0 for unsupported devices in go7007_usb_probe() probe() should not return 0 for unsupported devices, but go7007_usb_probe() does. The patch fixes it to return -ENODEV. Found by Linux Driver Verification project (linuxtesting.org). Signed-off-by: Alexey Khoroshilov Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/go7007/go7007-usb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/media/go7007/go7007-usb.c b/drivers/staging/media/go7007/go7007-usb.c index 50066e01a6ed..46ed83245035 100644 --- a/drivers/staging/media/go7007/go7007-usb.c +++ b/drivers/staging/media/go7007/go7007-usb.c @@ -1124,7 +1124,7 @@ static int go7007_usb_probe(struct usb_interface *intf, case GO7007_BOARDID_LIFEVIEW_LR192: printk(KERN_ERR "go7007-usb: The Lifeview TV Walker Ultra " "is not supported. Sorry!\n"); - return 0; + return -ENODEV; name = "Lifeview TV Walker Ultra"; board = &board_lifeview_lr192; break; @@ -1140,7 +1140,7 @@ static int go7007_usb_probe(struct usb_interface *intf, default: printk(KERN_ERR "go7007-usb: unknown board ID %d!\n", (unsigned int)id->driver_info); - return 0; + return -ENODEV; } go = go7007_alloc(&board->main_info, &intf->dev); From 23946ef1658dc7f3d8e2fbdbb2110b4cc4267654 Mon Sep 17 00:00:00 2001 From: Ralf Baechle Date: Thu, 13 Jun 2013 12:32:32 +0200 Subject: [PATCH 0412/1048] MIPS: Move gas macro MAPPED_KERNEL_SETUP_TLB to IP27-specific code. It's IP27-specific and can only cause trouble in head.S. Signed-off-by: Ralf Baechle --- .../include/asm/mach-ip27/kernel-entry-init.h | 39 +++++++++++++++++++ arch/mips/kernel/head.S | 39 ------------------- 2 files changed, 39 insertions(+), 39 deletions(-) diff --git a/arch/mips/include/asm/mach-ip27/kernel-entry-init.h b/arch/mips/include/asm/mach-ip27/kernel-entry-init.h index a323efb720dc..3f6bc85ea61d 100644 --- a/arch/mips/include/asm/mach-ip27/kernel-entry-init.h +++ b/arch/mips/include/asm/mach-ip27/kernel-entry-init.h @@ -23,6 +23,45 @@ dsrl \res, NSRI_NODEID_SHFT .endm + /* + * inputs are the text nasid in t1, data nasid in t2. + */ + .macro MAPPED_KERNEL_SETUP_TLB +#ifdef CONFIG_MAPPED_KERNEL + /* + * This needs to read the nasid - assume 0 for now. + * Drop in 0xffffffffc0000000 in tlbhi, 0+VG in tlblo_0, + * 0+DVG in tlblo_1. + */ + dli t0, 0xffffffffc0000000 + dmtc0 t0, CP0_ENTRYHI + li t0, 0x1c000 # Offset of text into node memory + dsll t1, NASID_SHFT # Shift text nasid into place + dsll t2, NASID_SHFT # Same for data nasid + or t1, t1, t0 # Physical load address of kernel text + or t2, t2, t0 # Physical load address of kernel data + dsrl t1, 12 # 4K pfn + dsrl t2, 12 # 4K pfn + dsll t1, 6 # Get pfn into place + dsll t2, 6 # Get pfn into place + li t0, ((_PAGE_GLOBAL|_PAGE_VALID| _CACHE_CACHABLE_COW) >> 6) + or t0, t0, t1 + mtc0 t0, CP0_ENTRYLO0 # physaddr, VG, cach exlwr + li t0, ((_PAGE_GLOBAL|_PAGE_VALID| _PAGE_DIRTY|_CACHE_CACHABLE_COW) >> 6) + or t0, t0, t2 + mtc0 t0, CP0_ENTRYLO1 # physaddr, DVG, cach exlwr + li t0, 0x1ffe000 # MAPPED_KERN_TLBMASK, TLBPGMASK_16M + mtc0 t0, CP0_PAGEMASK + li t0, 0 # KMAP_INX + mtc0 t0, CP0_INDEX + li t0, 1 + mtc0 t0, CP0_WIRED + tlbwi +#else + mtc0 zero, CP0_WIRED +#endif + .endm + /* * Intentionally empty macro, used in head.S. Override in * arch/mips/mach-xxx/kernel-entry-init.h when necessary. diff --git a/arch/mips/kernel/head.S b/arch/mips/kernel/head.S index c61cdaed2b1d..099912324423 100644 --- a/arch/mips/kernel/head.S +++ b/arch/mips/kernel/head.S @@ -27,45 +27,6 @@ #include - /* - * inputs are the text nasid in t1, data nasid in t2. - */ - .macro MAPPED_KERNEL_SETUP_TLB -#ifdef CONFIG_MAPPED_KERNEL - /* - * This needs to read the nasid - assume 0 for now. - * Drop in 0xffffffffc0000000 in tlbhi, 0+VG in tlblo_0, - * 0+DVG in tlblo_1. - */ - dli t0, 0xffffffffc0000000 - dmtc0 t0, CP0_ENTRYHI - li t0, 0x1c000 # Offset of text into node memory - dsll t1, NASID_SHFT # Shift text nasid into place - dsll t2, NASID_SHFT # Same for data nasid - or t1, t1, t0 # Physical load address of kernel text - or t2, t2, t0 # Physical load address of kernel data - dsrl t1, 12 # 4K pfn - dsrl t2, 12 # 4K pfn - dsll t1, 6 # Get pfn into place - dsll t2, 6 # Get pfn into place - li t0, ((_PAGE_GLOBAL|_PAGE_VALID| _CACHE_CACHABLE_COW) >> 6) - or t0, t0, t1 - mtc0 t0, CP0_ENTRYLO0 # physaddr, VG, cach exlwr - li t0, ((_PAGE_GLOBAL|_PAGE_VALID| _PAGE_DIRTY|_CACHE_CACHABLE_COW) >> 6) - or t0, t0, t2 - mtc0 t0, CP0_ENTRYLO1 # physaddr, DVG, cach exlwr - li t0, 0x1ffe000 # MAPPED_KERN_TLBMASK, TLBPGMASK_16M - mtc0 t0, CP0_PAGEMASK - li t0, 0 # KMAP_INX - mtc0 t0, CP0_INDEX - li t0, 1 - mtc0 t0, CP0_WIRED - tlbwi -#else - mtc0 zero, CP0_WIRED -#endif - .endm - /* * For the moment disable interrupts, mark the kernel mode and * set ST0_KX so that the CPU does not spit fire when using From 28963b1e2054f8c0ea968717ecf68c5fa2da6745 Mon Sep 17 00:00:00 2001 From: Ralf Baechle Date: Thu, 13 Jun 2013 13:40:09 +0200 Subject: [PATCH 0413/1048] MIPS: IP27: Fix build error with CONFIG_MAPPED_KERNEL Some of the TLB bit definitions in have become rather complex and are no longer usable from assembler resulting in an explosion like this: AS arch/mips/kernel/head.o arch/mips/kernel/head.S: Assembler messages: arch/mips/kernel/head.S:147: Error: missing ')' arch/mips/kernel/head.S:147: Error: missing ')' arch/mips/kernel/head.S:147: Error: missing ')' arch/mips/kernel/head.S:147: Error: missing ')' arch/mips/kernel/head.S:147: Error: missing ')' arch/mips/kernel/head.S:147: Error: missing ')' arch/mips/kernel/head.S:147: Error: missing ')' arch/mips/kernel/head.S:147: Error: missing ')' arch/mips/kernel/head.S:147: Error: missing ')' arch/mips/kernel/head.S:147: Error: missing ')' arch/mips/kernel/head.S:147: Error: missing ')' arch/mips/kernel/head.S:147: Error: missing ')' arch/mips/kernel/head.S:147: Error: missing ')' arch/mips/kernel/head.S:147: Error: missing ')' arch/mips/kernel/head.S:147: Error: missing ')' arch/mips/kernel/head.S:147: Error: Illegal operands `li $12,(((1<<((cpu_has_rixi?(cpu_has_rixi?((((((cpu_has_rixi?(0):(0)+1)+1)+1)+1)))+1:((((((cpu_has_rixi?(0):(0)+1)+1)+1)+1))))+1:(cpu_has_rixi?((((((cpu_has_rixi?(0):(0)+1)+1)+1)+1)))+1:((((((cpu_has_rixi?(0):(0)+1)+1)+1)+1)))))+1))|(1<<(((cpu_has_rixi?(cpu_has_rixi?((((((cpu_has_rixi?(0):(0)+1)+1)+1)+1)))+1:((((((cpu_has_rixi?(0):(0)+1)+1)+1)+1))))+1:(cpu_has_rixi?((((((cpu_has_rixi?(0):(0)+1)+1)+1)+1)))+1:((((((cpu_has_rixi?(0):(0)+1)+1)+1)+1)))))+1)+1))|(5<<(((((cpu_has_rixi?(cpu_has_rixi?((((((cpu_has_rixi?(0):(0)+1)+1)+1)+1)))+1:((((((cpu_has_rixi?(0):(0)+1)+1)+1)+1))))+1:(cpu_has_rixi?((((((cpu_has_rixi?(0):(0)+1)+1)+1)+1)))+1:((((((cpu_has_rixi?(0):(0)+1)+1)+1)+1)))))+1)+1)+1)+1)))>>6)' arch/mips/kernel/head.S:147: Error: missing ')' arch/mips/kernel/head.S:147: Error: missing ')' arch/mips/kernel/head.S:147: Error: missing ')' arch/mips/kernel/head.S:147: Error: missing ')' arch/mips/kernel/head.S:147: Error: missing ')' arch/mips/kernel/head.S:147: Error: missing ')' arch/mips/kernel/head.S:147: Error: missing ')' arch/mips/kernel/head.S:147: Error: missing ')' arch/mips/kernel/head.S:147: Error: missing ')' arch/mips/kernel/head.S:147: Error: missing ')' arch/mips/kernel/head.S:147: Error: missing ')' arch/mips/kernel/head.S:147: Error: missing ')' arch/mips/kernel/head.S:147: Error: missing ')' arch/mips/kernel/head.S:147: Error: missing ')' arch/mips/kernel/head.S:147: Error: missing ')' arch/mips/kernel/head.S:147: Error: Illegal operands `li $12,(((1<<((cpu_has_rixi?(cpu_has_rixi?((((((cpu_has_rixi?(0):(0)+1)+1)+1)+1)))+1:((((((cpu_has_rixi?(0):(0)+1)+1)+1)+1))))+1:(cpu_has_rixi?((((((cpu_has_rixi?(0):(0)+1)+1)+1)+1)))+1:((((((cpu_has_rixi?(0):(0)+1)+1)+1)+1)))))+1))|(1<<(((cpu_has_rixi?(cpu_has_rixi?((((((cpu_has_rixi?(0):(0)+1)+1)+1)+1)))+1:((((((cpu_has_rixi?(0):(0)+1)+1)+1)+1))))+1:(cpu_has_rixi?((((((cpu_has_rixi?(0):(0)+1)+1)+1)+1)))+1:((((((cpu_has_rixi?(0):(0)+1)+1)+1)+1)))))+1)+1))|(1<<((((cpu_has_rixi?(cpu_has_rixi?((((((cpu_has_rixi?(0):(0)+1)+1)+1)+1)))+1:((((((cpu_has_rixi?(0):(0)+1)+1)+1)+1))))+1:(cpu_has_rixi?((((((cpu_has_rixi?(0):(0)+1)+1)+1)+1)))+1:((((((cpu_has_rixi?(0):(0)+1)+1)+1)+1)))))+1)+1)+1))|(5<<(((((cpu_has_rixi?(cpu_has_rixi?((((((cpu_has_rixi?(0):(0)+1)+1)+1)+1)))+1:((((((cpu_has_rixi?(0):(0)+1)+1)+1)+1))))+1:(cpu_has_rixi?((((((cpu_has_rixi?(0):(0)+1)+1)+1)+1)))+1:((((((cpu_has_rixi?(0):(0)+1)+1)+1)+1)))))+1)+1)+1)+1)))>>6)' make[2]: *** [arch/mips/kernel/head.o] Error 1 Since now MAPPED_KERNEL_SETUP_TLB is in platform-specific code it's safe to hardcode the TLB bits there. Signed-off-by: Ralf Baechle --- arch/mips/include/asm/mach-ip27/kernel-entry-init.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/arch/mips/include/asm/mach-ip27/kernel-entry-init.h b/arch/mips/include/asm/mach-ip27/kernel-entry-init.h index 3f6bc85ea61d..b087cb83da3a 100644 --- a/arch/mips/include/asm/mach-ip27/kernel-entry-init.h +++ b/arch/mips/include/asm/mach-ip27/kernel-entry-init.h @@ -23,6 +23,14 @@ dsrl \res, NSRI_NODEID_SHFT .endm +/* + * TLB bits + */ +#define PAGE_GLOBAL (1 << 6) +#define PAGE_VALID (1 << 7) +#define PAGE_DIRTY (1 << 8) +#define CACHE_CACHABLE_COW (5 << 9) + /* * inputs are the text nasid in t1, data nasid in t2. */ @@ -44,10 +52,10 @@ dsrl t2, 12 # 4K pfn dsll t1, 6 # Get pfn into place dsll t2, 6 # Get pfn into place - li t0, ((_PAGE_GLOBAL|_PAGE_VALID| _CACHE_CACHABLE_COW) >> 6) + li t0, ((PAGE_GLOBAL | PAGE_VALID | CACHE_CACHABLE_COW) >> 6) or t0, t0, t1 mtc0 t0, CP0_ENTRYLO0 # physaddr, VG, cach exlwr - li t0, ((_PAGE_GLOBAL|_PAGE_VALID| _PAGE_DIRTY|_CACHE_CACHABLE_COW) >> 6) + li t0, ((PAGE_GLOBAL | PAGE_VALID | PAGE_DIRTY | CACHE_CACHABLE_COW) >> 6) or t0, t0, t2 mtc0 t0, CP0_ENTRYLO1 # physaddr, DVG, cach exlwr li t0, 0x1ffe000 # MAPPED_KERN_TLBMASK, TLBPGMASK_16M From 8ea2b8b605d0053fc87abde56ff42b19520322f0 Mon Sep 17 00:00:00 2001 From: Ralf Baechle Date: Thu, 13 Jun 2013 14:04:16 +0200 Subject: [PATCH 0414/1048] MIPS: IP27: Fix build errors with CONFIG_PCI disabled. LD init/built-in.o arch/mips/built-in.o: In function `startup_bridge_irq': ip27-irq.c:(.text+0x434): undefined reference to `irq_to_slot' ip27-irq.c:(.text+0x43c): undefined reference to `irq_to_slot' ip27-irq.c:(.text+0x460): undefined reference to `irq_to_bridge' ip27-irq.c:(.text+0x464): undefined reference to `irq_to_bridge' arch/mips/built-in.o: In function `shutdown_bridge_irq': ip27-irq.c:(.text+0x564): undefined reference to `irq_to_bridge' ip27-irq.c:(.text+0x56c): undefined reference to `irq_to_bridge' ip27-irq.c:(.text+0x5a0): undefined reference to `irq_to_slot' ip27-irq.c:(.text+0x5a4): undefined reference to `irq_to_slot' Signed-off-by: Ralf Baechle --- arch/mips/sgi-ip27/Makefile | 1 + arch/mips/sgi-ip27/ip27-irq-pci.c | 266 ++++++++++++++++++++++++++++++ arch/mips/sgi-ip27/ip27-irq.c | 214 ------------------------ 3 files changed, 267 insertions(+), 214 deletions(-) create mode 100644 arch/mips/sgi-ip27/ip27-irq-pci.c diff --git a/arch/mips/sgi-ip27/Makefile b/arch/mips/sgi-ip27/Makefile index 1f29e761d691..da8f6816d346 100644 --- a/arch/mips/sgi-ip27/Makefile +++ b/arch/mips/sgi-ip27/Makefile @@ -7,4 +7,5 @@ obj-y := ip27-berr.o ip27-irq.o ip27-init.o ip27-klconfig.o ip27-klnuma.o \ ip27-xtalk.o obj-$(CONFIG_EARLY_PRINTK) += ip27-console.o +obj-$(CONFIG_PCI) += ip27-irq-pci.o obj-$(CONFIG_SMP) += ip27-smp.o diff --git a/arch/mips/sgi-ip27/ip27-irq-pci.c b/arch/mips/sgi-ip27/ip27-irq-pci.c new file mode 100644 index 000000000000..ec22ec5600f3 --- /dev/null +++ b/arch/mips/sgi-ip27/ip27-irq-pci.c @@ -0,0 +1,266 @@ +/* + * ip27-irq.c: Highlevel interrupt handling for IP27 architecture. + * + * Copyright (C) 1999, 2000 Ralf Baechle (ralf@gnu.org) + * Copyright (C) 1999, 2000 Silicon Graphics, Inc. + * Copyright (C) 1999 - 2001 Kanoj Sarcar + */ + +#undef DEBUG + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +/* + * Linux has a controller-independent x86 interrupt architecture. + * every controller has a 'controller-template', that is used + * by the main code to do the right thing. Each driver-visible + * interrupt source is transparently wired to the appropriate + * controller. Thus drivers need not be aware of the + * interrupt-controller. + * + * Various interrupt controllers we handle: 8259 PIC, SMP IO-APIC, + * PIIX4's internal 8259 PIC and SGI's Visual Workstation Cobalt (IO-)APIC. + * (IO-APICs assumed to be messaging to Pentium local-APICs) + * + * the code is designed to be easily extended with new/different + * interrupt controllers, without having to do assembly magic. + */ + +extern struct bridge_controller *irq_to_bridge[]; +extern int irq_to_slot[]; + +/* + * use these macros to get the encoded nasid and widget id + * from the irq value + */ +#define IRQ_TO_BRIDGE(i) irq_to_bridge[(i)] +#define SLOT_FROM_PCI_IRQ(i) irq_to_slot[i] + +static inline int alloc_level(int cpu, int irq) +{ + struct hub_data *hub = hub_data(cpu_to_node(cpu)); + struct slice_data *si = cpu_data[cpu].data; + int level; + + level = find_first_zero_bit(hub->irq_alloc_mask, LEVELS_PER_SLICE); + if (level >= LEVELS_PER_SLICE) + panic("Cpu %d flooded with devices", cpu); + + __set_bit(level, hub->irq_alloc_mask); + si->level_to_irq[level] = irq; + + return level; +} + +static inline int find_level(cpuid_t *cpunum, int irq) +{ + int cpu, i; + + for_each_online_cpu(cpu) { + struct slice_data *si = cpu_data[cpu].data; + + for (i = BASE_PCI_IRQ; i < LEVELS_PER_SLICE; i++) + if (si->level_to_irq[i] == irq) { + *cpunum = cpu; + + return i; + } + } + + panic("Could not identify cpu/level for irq %d", irq); +} + +static int intr_connect_level(int cpu, int bit) +{ + nasid_t nasid = COMPACT_TO_NASID_NODEID(cpu_to_node(cpu)); + struct slice_data *si = cpu_data[cpu].data; + + set_bit(bit, si->irq_enable_mask); + + if (!cputoslice(cpu)) { + REMOTE_HUB_S(nasid, PI_INT_MASK0_A, si->irq_enable_mask[0]); + REMOTE_HUB_S(nasid, PI_INT_MASK1_A, si->irq_enable_mask[1]); + } else { + REMOTE_HUB_S(nasid, PI_INT_MASK0_B, si->irq_enable_mask[0]); + REMOTE_HUB_S(nasid, PI_INT_MASK1_B, si->irq_enable_mask[1]); + } + + return 0; +} + +static int intr_disconnect_level(int cpu, int bit) +{ + nasid_t nasid = COMPACT_TO_NASID_NODEID(cpu_to_node(cpu)); + struct slice_data *si = cpu_data[cpu].data; + + clear_bit(bit, si->irq_enable_mask); + + if (!cputoslice(cpu)) { + REMOTE_HUB_S(nasid, PI_INT_MASK0_A, si->irq_enable_mask[0]); + REMOTE_HUB_S(nasid, PI_INT_MASK1_A, si->irq_enable_mask[1]); + } else { + REMOTE_HUB_S(nasid, PI_INT_MASK0_B, si->irq_enable_mask[0]); + REMOTE_HUB_S(nasid, PI_INT_MASK1_B, si->irq_enable_mask[1]); + } + + return 0; +} + +/* Startup one of the (PCI ...) IRQs routes over a bridge. */ +static unsigned int startup_bridge_irq(struct irq_data *d) +{ + struct bridge_controller *bc; + bridgereg_t device; + bridge_t *bridge; + int pin, swlevel; + cpuid_t cpu; + + pin = SLOT_FROM_PCI_IRQ(d->irq); + bc = IRQ_TO_BRIDGE(d->irq); + bridge = bc->base; + + pr_debug("bridge_startup(): irq= 0x%x pin=%d\n", d->irq, pin); + /* + * "map" irq to a swlevel greater than 6 since the first 6 bits + * of INT_PEND0 are taken + */ + swlevel = find_level(&cpu, d->irq); + bridge->b_int_addr[pin].addr = (0x20000 | swlevel | (bc->nasid << 8)); + bridge->b_int_enable |= (1 << pin); + bridge->b_int_enable |= 0x7ffffe00; /* more stuff in int_enable */ + + /* + * Enable sending of an interrupt clear packt to the hub on a high to + * low transition of the interrupt pin. + * + * IRIX sets additional bits in the address which are documented as + * reserved in the bridge docs. + */ + bridge->b_int_mode |= (1UL << pin); + + /* + * We assume the bridge to have a 1:1 mapping between devices + * (slots) and intr pins. + */ + device = bridge->b_int_device; + device &= ~(7 << (pin*3)); + device |= (pin << (pin*3)); + bridge->b_int_device = device; + + bridge->b_wid_tflush; + + intr_connect_level(cpu, swlevel); + + return 0; /* Never anything pending. */ +} + +/* Shutdown one of the (PCI ...) IRQs routes over a bridge. */ +static void shutdown_bridge_irq(struct irq_data *d) +{ + struct bridge_controller *bc = IRQ_TO_BRIDGE(d->irq); + bridge_t *bridge = bc->base; + int pin, swlevel; + cpuid_t cpu; + + pr_debug("bridge_shutdown: irq 0x%x\n", d->irq); + pin = SLOT_FROM_PCI_IRQ(d->irq); + + /* + * map irq to a swlevel greater than 6 since the first 6 bits + * of INT_PEND0 are taken + */ + swlevel = find_level(&cpu, d->irq); + intr_disconnect_level(cpu, swlevel); + + bridge->b_int_enable &= ~(1 << pin); + bridge->b_wid_tflush; +} + +static inline void enable_bridge_irq(struct irq_data *d) +{ + cpuid_t cpu; + int swlevel; + + swlevel = find_level(&cpu, d->irq); /* Criminal offence */ + intr_connect_level(cpu, swlevel); +} + +static inline void disable_bridge_irq(struct irq_data *d) +{ + cpuid_t cpu; + int swlevel; + + swlevel = find_level(&cpu, d->irq); /* Criminal offence */ + intr_disconnect_level(cpu, swlevel); +} + +static struct irq_chip bridge_irq_type = { + .name = "bridge", + .irq_startup = startup_bridge_irq, + .irq_shutdown = shutdown_bridge_irq, + .irq_mask = disable_bridge_irq, + .irq_unmask = enable_bridge_irq, +}; + +void register_bridge_irq(unsigned int irq) +{ + irq_set_chip_and_handler(irq, &bridge_irq_type, handle_level_irq); +} + +int request_bridge_irq(struct bridge_controller *bc) +{ + int irq = allocate_irqno(); + int swlevel, cpu; + nasid_t nasid; + + if (irq < 0) + return irq; + + /* + * "map" irq to a swlevel greater than 6 since the first 6 bits + * of INT_PEND0 are taken + */ + cpu = bc->irq_cpu; + swlevel = alloc_level(cpu, irq); + if (unlikely(swlevel < 0)) { + free_irqno(irq); + + return -EAGAIN; + } + + /* Make sure it's not already pending when we connect it. */ + nasid = COMPACT_TO_NASID_NODEID(cpu_to_node(cpu)); + REMOTE_HUB_CLR_INTR(nasid, swlevel); + + intr_connect_level(cpu, swlevel); + + register_bridge_irq(irq); + + return irq; +} diff --git a/arch/mips/sgi-ip27/ip27-irq.c b/arch/mips/sgi-ip27/ip27-irq.c index 2315cfeb2687..3fbaef97a1b8 100644 --- a/arch/mips/sgi-ip27/ip27-irq.c +++ b/arch/mips/sgi-ip27/ip27-irq.c @@ -29,7 +29,6 @@ #include #include -#include #include #include #include @@ -54,50 +53,6 @@ extern asmlinkage void ip27_irq(void); -extern struct bridge_controller *irq_to_bridge[]; -extern int irq_to_slot[]; - -/* - * use these macros to get the encoded nasid and widget id - * from the irq value - */ -#define IRQ_TO_BRIDGE(i) irq_to_bridge[(i)] -#define SLOT_FROM_PCI_IRQ(i) irq_to_slot[i] - -static inline int alloc_level(int cpu, int irq) -{ - struct hub_data *hub = hub_data(cpu_to_node(cpu)); - struct slice_data *si = cpu_data[cpu].data; - int level; - - level = find_first_zero_bit(hub->irq_alloc_mask, LEVELS_PER_SLICE); - if (level >= LEVELS_PER_SLICE) - panic("Cpu %d flooded with devices", cpu); - - __set_bit(level, hub->irq_alloc_mask); - si->level_to_irq[level] = irq; - - return level; -} - -static inline int find_level(cpuid_t *cpunum, int irq) -{ - int cpu, i; - - for_each_online_cpu(cpu) { - struct slice_data *si = cpu_data[cpu].data; - - for (i = BASE_PCI_IRQ; i < LEVELS_PER_SLICE; i++) - if (si->level_to_irq[i] == irq) { - *cpunum = cpu; - - return i; - } - } - - panic("Could not identify cpu/level for irq %d", irq); -} - /* * Find first bit set */ @@ -204,175 +159,6 @@ static void ip27_hub_error(void) panic("CPU %d got a hub error interrupt", smp_processor_id()); } -static int intr_connect_level(int cpu, int bit) -{ - nasid_t nasid = COMPACT_TO_NASID_NODEID(cpu_to_node(cpu)); - struct slice_data *si = cpu_data[cpu].data; - - set_bit(bit, si->irq_enable_mask); - - if (!cputoslice(cpu)) { - REMOTE_HUB_S(nasid, PI_INT_MASK0_A, si->irq_enable_mask[0]); - REMOTE_HUB_S(nasid, PI_INT_MASK1_A, si->irq_enable_mask[1]); - } else { - REMOTE_HUB_S(nasid, PI_INT_MASK0_B, si->irq_enable_mask[0]); - REMOTE_HUB_S(nasid, PI_INT_MASK1_B, si->irq_enable_mask[1]); - } - - return 0; -} - -static int intr_disconnect_level(int cpu, int bit) -{ - nasid_t nasid = COMPACT_TO_NASID_NODEID(cpu_to_node(cpu)); - struct slice_data *si = cpu_data[cpu].data; - - clear_bit(bit, si->irq_enable_mask); - - if (!cputoslice(cpu)) { - REMOTE_HUB_S(nasid, PI_INT_MASK0_A, si->irq_enable_mask[0]); - REMOTE_HUB_S(nasid, PI_INT_MASK1_A, si->irq_enable_mask[1]); - } else { - REMOTE_HUB_S(nasid, PI_INT_MASK0_B, si->irq_enable_mask[0]); - REMOTE_HUB_S(nasid, PI_INT_MASK1_B, si->irq_enable_mask[1]); - } - - return 0; -} - -/* Startup one of the (PCI ...) IRQs routes over a bridge. */ -static unsigned int startup_bridge_irq(struct irq_data *d) -{ - struct bridge_controller *bc; - bridgereg_t device; - bridge_t *bridge; - int pin, swlevel; - cpuid_t cpu; - - pin = SLOT_FROM_PCI_IRQ(d->irq); - bc = IRQ_TO_BRIDGE(d->irq); - bridge = bc->base; - - pr_debug("bridge_startup(): irq= 0x%x pin=%d\n", d->irq, pin); - /* - * "map" irq to a swlevel greater than 6 since the first 6 bits - * of INT_PEND0 are taken - */ - swlevel = find_level(&cpu, d->irq); - bridge->b_int_addr[pin].addr = (0x20000 | swlevel | (bc->nasid << 8)); - bridge->b_int_enable |= (1 << pin); - bridge->b_int_enable |= 0x7ffffe00; /* more stuff in int_enable */ - - /* - * Enable sending of an interrupt clear packt to the hub on a high to - * low transition of the interrupt pin. - * - * IRIX sets additional bits in the address which are documented as - * reserved in the bridge docs. - */ - bridge->b_int_mode |= (1UL << pin); - - /* - * We assume the bridge to have a 1:1 mapping between devices - * (slots) and intr pins. - */ - device = bridge->b_int_device; - device &= ~(7 << (pin*3)); - device |= (pin << (pin*3)); - bridge->b_int_device = device; - - bridge->b_wid_tflush; - - intr_connect_level(cpu, swlevel); - - return 0; /* Never anything pending. */ -} - -/* Shutdown one of the (PCI ...) IRQs routes over a bridge. */ -static void shutdown_bridge_irq(struct irq_data *d) -{ - struct bridge_controller *bc = IRQ_TO_BRIDGE(d->irq); - bridge_t *bridge = bc->base; - int pin, swlevel; - cpuid_t cpu; - - pr_debug("bridge_shutdown: irq 0x%x\n", d->irq); - pin = SLOT_FROM_PCI_IRQ(d->irq); - - /* - * map irq to a swlevel greater than 6 since the first 6 bits - * of INT_PEND0 are taken - */ - swlevel = find_level(&cpu, d->irq); - intr_disconnect_level(cpu, swlevel); - - bridge->b_int_enable &= ~(1 << pin); - bridge->b_wid_tflush; -} - -static inline void enable_bridge_irq(struct irq_data *d) -{ - cpuid_t cpu; - int swlevel; - - swlevel = find_level(&cpu, d->irq); /* Criminal offence */ - intr_connect_level(cpu, swlevel); -} - -static inline void disable_bridge_irq(struct irq_data *d) -{ - cpuid_t cpu; - int swlevel; - - swlevel = find_level(&cpu, d->irq); /* Criminal offence */ - intr_disconnect_level(cpu, swlevel); -} - -static struct irq_chip bridge_irq_type = { - .name = "bridge", - .irq_startup = startup_bridge_irq, - .irq_shutdown = shutdown_bridge_irq, - .irq_mask = disable_bridge_irq, - .irq_unmask = enable_bridge_irq, -}; - -void register_bridge_irq(unsigned int irq) -{ - irq_set_chip_and_handler(irq, &bridge_irq_type, handle_level_irq); -} - -int request_bridge_irq(struct bridge_controller *bc) -{ - int irq = allocate_irqno(); - int swlevel, cpu; - nasid_t nasid; - - if (irq < 0) - return irq; - - /* - * "map" irq to a swlevel greater than 6 since the first 6 bits - * of INT_PEND0 are taken - */ - cpu = bc->irq_cpu; - swlevel = alloc_level(cpu, irq); - if (unlikely(swlevel < 0)) { - free_irqno(irq); - - return -EAGAIN; - } - - /* Make sure it's not already pending when we connect it. */ - nasid = COMPACT_TO_NASID_NODEID(cpu_to_node(cpu)); - REMOTE_HUB_CLR_INTR(nasid, swlevel); - - intr_connect_level(cpu, swlevel); - - register_bridge_irq(irq); - - return irq; -} - asmlinkage void plat_irq_dispatch(void) { unsigned long pending = read_c0_cause() & read_c0_status(); From 73ec78b06ecadb2ce67aae2509e8683ad8b92d14 Mon Sep 17 00:00:00 2001 From: Ralf Baechle Date: Thu, 13 Jun 2013 14:05:03 +0200 Subject: [PATCH 0415/1048] MIPS: IP27: Fix build errors with CONFIG_PCI disabled. LD init/built-in.o arch/mips/built-in.o: In function `xtalk_probe_node': (.cpuinit.text+0x67c): undefined reference to `bridge_probe' arch/mips/built-in.o: In function `xtalk_probe_node': (.cpuinit.text+0x7d8): undefined reference to `bridge_probe' Signed-off-by: Ralf Baechle --- arch/mips/include/asm/xtalk/xtalk.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/arch/mips/include/asm/xtalk/xtalk.h b/arch/mips/include/asm/xtalk/xtalk.h index 680e7efebbaf..26d2ed1fa917 100644 --- a/arch/mips/include/asm/xtalk/xtalk.h +++ b/arch/mips/include/asm/xtalk/xtalk.h @@ -47,6 +47,15 @@ typedef struct xtalk_piomap_s *xtalk_piomap_t; #define XIO_PORT(x) ((xwidgetnum_t)(((x)&XIO_PORT_BITS) >> XIO_PORT_SHIFT)) #define XIO_PACK(p, o) ((((uint64_t)(p))< Date: Thu, 13 Jun 2013 14:34:50 +0200 Subject: [PATCH 0416/1048] MIPS: IP27: Fix build error if CONFIG_PCI=y and CONFIG_NUMA disabled. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Then will define cpp macro as default definition for pcibus_to_node resulting in: CC arch/mips/pci/pci-ip27.o arch/mips/pci/pci-ip27.c:220:7: error: expected identifier or ‘(’ before ‘void’ arch/mips/pci/pci-ip27.c:220:12: error: expected ‘)’ before ‘(’ token make[1]: *** [arch/mips/pci/pci-ip27.o] Error 1 Signed-off-by: Ralf Baechle --- arch/mips/pci/pci-ip27.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/mips/pci/pci-ip27.c b/arch/mips/pci/pci-ip27.c index 6eb65e44d9e4..7b2ac81e1f59 100644 --- a/arch/mips/pci/pci-ip27.c +++ b/arch/mips/pci/pci-ip27.c @@ -217,6 +217,7 @@ static void pci_fixup_ioc3(struct pci_dev *d) pci_disable_swapping(d); } +#ifdef CONFIG_NUMA int pcibus_to_node(struct pci_bus *bus) { struct bridge_controller *bc = BRIDGE_CONTROLLER(bus); @@ -224,6 +225,7 @@ int pcibus_to_node(struct pci_bus *bus) return bc->nasid; } EXPORT_SYMBOL(pcibus_to_node); +#endif /* CONFIG_NUMA */ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_SGI, PCI_DEVICE_ID_SGI_IOC3, pci_fixup_ioc3); From d949b4fe6d23dd92b5fa48cbf7af90ca32beed2e Mon Sep 17 00:00:00 2001 From: David Daney Date: Wed, 12 Jun 2013 17:28:33 +0000 Subject: [PATCH 0417/1048] MIPS: Octeon: Don't clobber bootloader data structures. Commit abe77f90dc (MIPS: Octeon: Add kexec and kdump support) added a bootmem region for the kernel image itself. The problem is that this is rounded up to a 0x100000 boundary, which is memory that may not be owned by the kernel. Depending on the kernel's configuration based size, this 'extra' memory may contain data passed from the bootloader to the kernel itself, which if clobbered makes the kernel crash in various ways. The fix: Quit rounding the size up, so that we only use memory assigned to the kernel. Signed-off-by: David Daney Cc: Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/5449/ Signed-off-by: Ralf Baechle --- arch/mips/cavium-octeon/setup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/mips/cavium-octeon/setup.c b/arch/mips/cavium-octeon/setup.c index 1bcc144da287..2a75ff249e71 100644 --- a/arch/mips/cavium-octeon/setup.c +++ b/arch/mips/cavium-octeon/setup.c @@ -997,7 +997,7 @@ void __init plat_mem_setup(void) cvmx_bootmem_unlock(); /* Add the memory region for the kernel. */ kernel_start = (unsigned long) _text; - kernel_size = ALIGN(_end - _text, 0x100000); + kernel_size = _end - _text; /* Adjust for physical offset. */ kernel_start &= ~0xffffffff80000000ULL; From 25c87eae1725ed77a8b44d782a86abdc279b4ede Mon Sep 17 00:00:00 2001 From: Markos Chandras Date: Tue, 11 Jun 2013 08:49:50 +0000 Subject: [PATCH 0418/1048] lib/Kconfig.debug: Restrict FRAME_POINTER for MIPS FAULT_INJECTION_STACKTRACE_FILTER selects FRAME_POINTER but that symbol is not available for MIPS. Fixes the following problem on a randconfig: warning: (LOCKDEP && FAULT_INJECTION_STACKTRACE_FILTER && LATENCYTOP && KMEMCHECK) selects FRAME_POINTER which has unmet direct dependencies (DEBUG_KERNEL && (CRIS || M68K || FRV || UML || AVR32 || SUPERH || BLACKFIN || MN10300 || METAG) || ARCH_WANT_FRAME_POINTERS) Signed-off-by: Markos Chandras Acked-by: Steven J. Hill Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/5441/ Signed-off-by: Ralf Baechle --- lib/Kconfig.debug | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index 566cf2bc08ea..74fdc5cf4adc 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -1272,7 +1272,7 @@ config FAULT_INJECTION_STACKTRACE_FILTER depends on FAULT_INJECTION_DEBUG_FS && STACKTRACE_SUPPORT depends on !X86_64 select STACKTRACE - select FRAME_POINTER if !PPC && !S390 && !MICROBLAZE && !ARM_UNWIND + select FRAME_POINTER if !MIPS && !PPC && !S390 && !MICROBLAZE && !ARM_UNWIND help Provide stacktrace filter for fault-injection capabilities From 2f963bfbd84207776725db82287b73cfeeab8a92 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Tue, 19 Feb 2013 02:00:39 +0200 Subject: [PATCH 0419/1048] MIPS: Loongson: Fix random early boot hang Some Loongson boards (e.g. Lemote FuLoong mini-PC) use ISA/southbridge device (CS5536 general purpose timer) for the timer interrupt. It starts running early and is already enabled during the PCI configuration, during which there is a small window in pci_read_base() when the register access is temporarily disabled. If the timer interrupts at this point, the system will hang. Fix this by adding a fixup that keeps the register access always enabled. The hang the patch fixes usually looks like this: [ 0.844000] pci 0000:00:0e.0: [1022:2090] type 00 class 0x060100 [ 0.848000] pci 0000:00:0e.0: reg 10: [io 0xb410-0xb417] [ 0.852000] pci 0000:00:0e.0: reg 14: [io 0xb000-0xb0ff] [ 0.856000] pci 0000:00:0e.0: reg 18: [io 0xb380-0xb3bf] [ 28.140000] BUG: soft lockup - CPU#0 stuck for 23s! [swapper:1] [ 28.140000] Modules linked in: [ 28.140000] irq event stamp: 37965 [ 28.140000] hardirqs last enabled at (37964): [] restore_partial+0x6c/0x13c [ 28.140000] hardirqs last disabled at (37965): [] handle_int+0x144/0x15c [ 28.140000] softirqs last enabled at (24316): [] __do_softirq+0x1cc/0x258 [ 28.140000] softirqs last disabled at (24327): [] do_softirq+0xc8/0xd0 [ 28.140000] Cpu 0 [ 28.140000] $ 0 : 0000000000000000 00000000140044e1 980000009f090000 0000000000000001 [ 28.140000] $ 4 : 980000009f090000 0000000000000000 0000000000000100 03b7fff87fbde011 [ 28.140000] $ 8 : ffffffff812b1928 000000000001e000 043ffff87fbde011 fffffff87fbde011 [ 28.140000] $12 : 000000000000000e ffffffff807a0000 0000000000000698 0000000000000000 [ 28.140000] $16 : 0000000000000002 ffffffff81055e20 ffffffff80786810 0000000000000000 [ 28.140000] $20 : 000000000000000a ffffffff807bc244 ffffffff807e6350 ffffffff80770000 [ 28.140000] $24 : 0000000000000d80 00000000fffedbe0 [ 28.140000] $28 : 980000009f07c000 980000009f07fa10 ffffffff81050000 ffffffff802380f8 [ 28.140000] Hi : 0000000000d0fc00 [ 28.140000] Lo : 0000000000f82b40 [ 28.140000] epc : ffffffff8023810c __do_softirq+0xe4/0x258 [ 28.140000] Not tainted [ 28.140000] ra : ffffffff802380f8 __do_softirq+0xd0/0x258 [ 28.140000] Status: 140044e3 KX SX UX KERNEL EXL IE [ 28.140000] Cause : 10008400 [ 28.140000] PrId : 00006303 (ICT Loongson-2) Signed-off-by: Aaro Koskinen Cc: linux-mips@linux-mips.org Cc: linux-kernel@vger.kernel.org Patchwork: https://patchwork.linux-mips.org/patch/4958/ Signed-off-by: Ralf Baechle --- arch/mips/loongson/common/cs5536/cs5536_isa.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/arch/mips/loongson/common/cs5536/cs5536_isa.c b/arch/mips/loongson/common/cs5536/cs5536_isa.c index a6eb2e853d94..924be39e7733 100644 --- a/arch/mips/loongson/common/cs5536/cs5536_isa.c +++ b/arch/mips/loongson/common/cs5536/cs5536_isa.c @@ -13,6 +13,7 @@ * option) any later version. */ +#include #include #include @@ -314,3 +315,16 @@ u32 pci_isa_read_reg(int reg) return conf_data; } + +/* + * The mfgpt timer interrupt is running early, so we must keep the south bridge + * mmio always enabled. Otherwise we may race with the PCI configuration which + * may temporarily disable it. When that happens and the timer interrupt fires, + * we are not able to clear it and the system will hang. + */ +static void cs5536_isa_mmio_always_on(struct pci_dev *dev) +{ + dev->mmio_always_on = 1; +} +DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_CS5536_ISA, + PCI_CLASS_BRIDGE_ISA, 8, cs5536_isa_mmio_always_on); From 2ddbc4e2f9729ce62f9286868eab6f1523f00d67 Mon Sep 17 00:00:00 2001 From: "Steven J. Hill" Date: Thu, 13 Jun 2013 19:55:04 +0000 Subject: [PATCH 0420/1048] MIPS: sead3: Fix ability to perform a soft reset. The soft reset register address and reset value to be written are incorrect for the SEAD-3 platform. This patch fixes them such that the SEAD-3 can actually perform a soft reset instead of causing an exception. Also remove usage of 'include/asm/mips-boards/generic.h' header file. Signed-off-by: Steven J. Hill Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/5454/ Signed-off-by: Ralf Baechle --- arch/mips/mti-sead3/sead3-reset.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/arch/mips/mti-sead3/sead3-reset.c b/arch/mips/mti-sead3/sead3-reset.c index 20475c5e7b9c..e6fb24414a70 100644 --- a/arch/mips/mti-sead3/sead3-reset.c +++ b/arch/mips/mti-sead3/sead3-reset.c @@ -9,7 +9,9 @@ #include #include -#include + +#define SOFTRES_REG 0x1f000050 +#define GORESET 0x4d static void mips_machine_restart(char *command) { @@ -35,5 +37,4 @@ static int __init mips_reboot_setup(void) return 0; } - arch_initcall(mips_reboot_setup); From 36a29af4bed7169f3332c44846576243d5abe9a5 Mon Sep 17 00:00:00 2001 From: "Steven J. Hill" Date: Thu, 13 Jun 2013 19:55:05 +0000 Subject: [PATCH 0421/1048] MIPS: malta: Move defines of reset registers and values. Remove usage of 'include/asm/mips-boards/generic.h' header file. Instead, move the defines for SOFTRES_REG and GORESET local to the platform file. Signed-off-by: Steven J. Hill Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/5455/ Signed-off-by: Ralf Baechle --- arch/mips/mti-malta/malta-reset.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/arch/mips/mti-malta/malta-reset.c b/arch/mips/mti-malta/malta-reset.c index 329420536241..791101216cc2 100644 --- a/arch/mips/mti-malta/malta-reset.c +++ b/arch/mips/mti-malta/malta-reset.c @@ -27,7 +27,9 @@ #include #include -#include + +#define SOFTRES_REG 0x1f000500 +#define GORESET 0x42 static void mips_machine_restart(char *command) { From b72d9a4ef322f55f159df144bc702d9643e5a221 Mon Sep 17 00:00:00 2001 From: "Steven J. Hill" Date: Thu, 13 Jun 2013 19:55:06 +0000 Subject: [PATCH 0422/1048] MIPS: malta: Remove software reset defines from generic header. Remove the software reset register and reset value definitions from the 'include/asm/mips-boards/generic.h' header file. Also clean up header and whitespace in platform file. Signed-off-by: Steven J. Hill Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/5456/ Signed-off-by: Ralf Baechle --- arch/mips/include/asm/mips-boards/generic.h | 6 ----- arch/mips/mti-malta/malta-reset.c | 29 ++++----------------- 2 files changed, 5 insertions(+), 30 deletions(-) diff --git a/arch/mips/include/asm/mips-boards/generic.h b/arch/mips/include/asm/mips-boards/generic.h index bd9746fbe4af..48616816bcbc 100644 --- a/arch/mips/include/asm/mips-boards/generic.h +++ b/arch/mips/include/asm/mips-boards/generic.h @@ -23,12 +23,6 @@ #define ASCII_DISPLAY_WORD_BASE 0x1f000410 #define ASCII_DISPLAY_POS_BASE 0x1f000418 -/* - * Reset register. - */ -#define SOFTRES_REG 0x1f000500 -#define GORESET 0x42 - /* * Revision register. */ diff --git a/arch/mips/mti-malta/malta-reset.c b/arch/mips/mti-malta/malta-reset.c index 791101216cc2..d627d4b2b47f 100644 --- a/arch/mips/mti-malta/malta-reset.c +++ b/arch/mips/mti-malta/malta-reset.c @@ -1,31 +1,14 @@ /* + * This file is subject to the terms and conditions of the GNU General Public + * License. See the file "COPYING" in the main directory of this archive + * for more details. + * * Carsten Langgaard, carstenl@mips.com * Copyright (C) 1999,2000 MIPS Technologies, Inc. All rights reserved. - * - * ######################################################################## - * - * This program is free software; you can distribute 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 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., - * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA. - * - * ######################################################################## - * - * Reset the MIPS boards. - * */ -#include +#include #include -#include #include #define SOFTRES_REG 0x1f000500 @@ -47,7 +30,6 @@ static void mips_machine_halt(void) __raw_writel(GORESET, softres_reg); } - static int __init mips_reboot_setup(void) { _machine_restart = mips_machine_restart; @@ -56,5 +38,4 @@ static int __init mips_reboot_setup(void) return 0; } - arch_initcall(mips_reboot_setup); From 9b1f812acb607bcdfafd8cacec89f9b736e2be0c Mon Sep 17 00:00:00 2001 From: David Daney Date: Thu, 13 Jun 2013 20:10:47 +0000 Subject: [PATCH 0423/1048] MIPS/OCTEON: Override default address space layout. OCTEON II cannot execute code in the default CAC_BASE space, so we supply a value (0x8000000000000000) that does work. Signed-off-by: David Daney Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/5457/ Signed-off-by: Ralf Baechle --- .../include/asm/mach-cavium-octeon/spaces.h | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 arch/mips/include/asm/mach-cavium-octeon/spaces.h diff --git a/arch/mips/include/asm/mach-cavium-octeon/spaces.h b/arch/mips/include/asm/mach-cavium-octeon/spaces.h new file mode 100644 index 000000000000..daa91accf5ab --- /dev/null +++ b/arch/mips/include/asm/mach-cavium-octeon/spaces.h @@ -0,0 +1,24 @@ +/* + * This file is subject to the terms and conditions of the GNU General Public + * License. See the file "COPYING" in the main directory of this archive + * for more details. + * + * Copyright (C) 2012 Cavium, Inc. + */ +#ifndef _ASM_MACH_CAVIUM_OCTEON_SPACES_H +#define _ASM_MACH_CAVIUM_OCTEON_SPACES_H + +#include + +#ifdef CONFIG_64BIT +/* They are all the same and some OCTEON II cores cannot handle 0xa8.. */ +#define CAC_BASE _AC(0x8000000000000000, UL) +#define UNCAC_BASE _AC(0x8000000000000000, UL) +#define IO_BASE _AC(0x8000000000000000, UL) + + +#endif /* CONFIG_64BIT */ + +#include + +#endif /* _ASM_MACH_CAVIUM_OCTEON_SPACES_H */ From 970cb7b963885afff070b315d85a56808bdf2788 Mon Sep 17 00:00:00 2001 From: Markos Chandras Date: Mon, 17 Jun 2013 07:42:11 +0000 Subject: [PATCH 0424/1048] MIPS: ath79: Fix argument for the ap136_pc_init function ap136_pci_init expects a u8 pointer as an argument. Fixes the following build problem on a randconfig: arch/mips/ath79/mach-ap136.c:151:2: error: too many arguments to function 'ap136_pci_init' Signed-off-by: Markos Chandras Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/5476/ Signed-off-by: Ralf Baechle --- arch/mips/ath79/mach-ap136.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/mips/ath79/mach-ap136.c b/arch/mips/ath79/mach-ap136.c index 479dd4b1d0d2..07eac58c3641 100644 --- a/arch/mips/ath79/mach-ap136.c +++ b/arch/mips/ath79/mach-ap136.c @@ -132,7 +132,7 @@ static void __init ap136_pci_init(u8 *eeprom) ath79_register_pci(); } #else -static inline void ap136_pci_init(void) {} +static inline void ap136_pci_init(u8 *eeprom) {} #endif /* CONFIG_PCI */ static void __init ap136_setup(void) From d6095cace181603a1200652c4b249ff648c205a8 Mon Sep 17 00:00:00 2001 From: Markos Chandras Date: Mon, 17 Jun 2013 13:00:41 +0000 Subject: [PATCH 0425/1048] MIPS: sibyte: Remove unused variable. Fixes the following build problem: arch/mips/sibyte/sb1250/bus_watcher.c: In function 'sibyte_bw_int': arch/mips/sibyte/sb1250/bus_watcher.c:179:7: error: unused variable 'bw_buf' [-Werror=unused-variable] Signed-off-by: Markos Chandras Cc: sibyte-users@bitmover.com Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/5481/ Signed-off-by: Ralf Baechle --- arch/mips/sibyte/sb1250/bus_watcher.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/arch/mips/sibyte/sb1250/bus_watcher.c b/arch/mips/sibyte/sb1250/bus_watcher.c index 8871e3345bff..d0ca7b91c417 100644 --- a/arch/mips/sibyte/sb1250/bus_watcher.c +++ b/arch/mips/sibyte/sb1250/bus_watcher.c @@ -175,9 +175,6 @@ static irqreturn_t sibyte_bw_int(int irq, void *data) #ifdef CONFIG_SIBYTE_BW_TRACE int i; #endif -#ifndef CONFIG_PROC_FS - char bw_buf[1024]; -#endif #ifdef CONFIG_SIBYTE_BW_TRACE csr_out32(M_SCD_TRACE_CFG_FREEZE, IOADDR(A_SCD_TRACE_CFG)); From 0156915cc0202e87cac1c8507b2b71eb899a9652 Mon Sep 17 00:00:00 2001 From: Markos Chandras Date: Mon, 17 Jun 2013 13:00:37 +0000 Subject: [PATCH 0426/1048] MIPS: Sibyte: Add missing sched.h header It's needed for the TASK_INTERRUPTIBLE definition. Fixes the following build problem: arch/mips/sibyte/common/sb_tbprof.c:235:4: error: 'TASK_INTERRUPTIBLE' undeclared (first use in this function) [ralf@linux-mips.org: Ideally sched.h should be included into the actual user of TASK_INTERRUPTIBLE, but that seems way too risky that close to a release.] Signed-off-by: Markos Chandras Acked-by: Steven J. Hill Cc: sibyte-users@bitmover.com Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/5479/ Signed-off-by: Ralf Baechle --- arch/mips/sibyte/common/sb_tbprof.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/mips/sibyte/common/sb_tbprof.c b/arch/mips/sibyte/common/sb_tbprof.c index 2188b39a1251..059e28c8fd97 100644 --- a/arch/mips/sibyte/common/sb_tbprof.c +++ b/arch/mips/sibyte/common/sb_tbprof.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include From 39b6f3aa1979ad7df42474d3c63bbc7e25bd31e4 Mon Sep 17 00:00:00 2001 From: Markos Chandras Date: Mon, 17 Jun 2013 13:00:36 +0000 Subject: [PATCH 0427/1048] MIPS: sibyte: Declare the cfe_write() buffer as constant The write() prototype expects a const char * as argument so declare it as such. Fixes the following build problem: arch/mips/sibyte/common/cfe_console.c:23:5: error: passing argument 2 of 'cfe_write' discards 'const' qualifier from pointer target type [-Werror] arch/mips/sibyte/common/cfe_console.c:34:4: error: passing argument 2 of 'cfe_write' makes pointer from integer without a cast [-Werror] Signed-off-by: Markos Chandras Acked-by: Steven J. Hill Cc: sibyte-users@bitmover.com Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/5485/ Signed-off-by: Ralf Baechle --- arch/mips/fw/cfe/cfe_api.c | 4 ++-- arch/mips/include/asm/fw/cfe/cfe_api.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/mips/fw/cfe/cfe_api.c b/arch/mips/fw/cfe/cfe_api.c index d06dc5a6b8d3..cf84f01931c5 100644 --- a/arch/mips/fw/cfe/cfe_api.c +++ b/arch/mips/fw/cfe/cfe_api.c @@ -406,12 +406,12 @@ int cfe_setenv(char *name, char *val) return xiocb.xiocb_status; } -int cfe_write(int handle, unsigned char *buffer, int length) +int cfe_write(int handle, const char *buffer, int length) { return cfe_writeblk(handle, 0, buffer, length); } -int cfe_writeblk(int handle, s64 offset, unsigned char *buffer, int length) +int cfe_writeblk(int handle, s64 offset, const char *buffer, int length) { struct cfe_xiocb xiocb; diff --git a/arch/mips/include/asm/fw/cfe/cfe_api.h b/arch/mips/include/asm/fw/cfe/cfe_api.h index 17347551a1b2..a0ea69e91e2e 100644 --- a/arch/mips/include/asm/fw/cfe/cfe_api.h +++ b/arch/mips/include/asm/fw/cfe/cfe_api.h @@ -115,8 +115,8 @@ int cfe_read(int handle, unsigned char *buffer, int length); int cfe_readblk(int handle, int64_t offset, unsigned char *buffer, int length); int cfe_setenv(char *name, char *val); -int cfe_write(int handle, unsigned char *buffer, int length); -int cfe_writeblk(int handle, int64_t offset, unsigned char *buffer, +int cfe_write(int handle, const char *buffer, int length); +int cfe_writeblk(int handle, int64_t offset, const char *buffer, int length); #endif /* CFE_API_H */ From 55e9741a323fb77a11c368de51f8a4fa757311df Mon Sep 17 00:00:00 2001 From: Ralf Baechle Date: Wed, 19 Jun 2013 19:25:06 +0200 Subject: [PATCH 0428/1048] MIPS: Sibyte: Fix build for SIBYTE_BW_TRACE on BCM1x55 and BCM1x80. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CC arch/mips/mm/cerr-sb1.o arch/mips/mm/cerr-sb1.c: In function ‘sb1_cache_error’: arch/mips/mm/cerr-sb1.c:186:98: error: ‘M_BCM1480_SCD_TRACE_CFG_FREEZE’ undeclared (first use in this function) arch/mips/mm/cerr-sb1.c:186:98: note: each undeclared identifier is reported only once for each function it appears in make[1]: *** [arch/mips/mm/cerr-sb1.o] Error 1 This happens because 8deab1144b553548fb2f1b51affdd36dcd652aaa [[MIPS] Updated Sibyte headers] changed the headers but not all the users. Signed-off-by: Ralf Baechle Reported-by: Markos Chandras Patchwork: https://patchwork.linux-mips.org/patch/5511/ --- arch/mips/mm/cerr-sb1.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/arch/mips/mm/cerr-sb1.c b/arch/mips/mm/cerr-sb1.c index 576add33bf5b..ee5c1ff861ae 100644 --- a/arch/mips/mm/cerr-sb1.c +++ b/arch/mips/mm/cerr-sb1.c @@ -182,11 +182,7 @@ asmlinkage void sb1_cache_error(void) #ifdef CONFIG_SIBYTE_BW_TRACE /* Freeze the trace buffer now */ -#if defined(CONFIG_SIBYTE_BCM1x55) || defined(CONFIG_SIBYTE_BCM1x80) - csr_out32(M_BCM1480_SCD_TRACE_CFG_FREEZE, IOADDR(A_SCD_TRACE_CFG)); -#else csr_out32(M_SCD_TRACE_CFG_FREEZE, IOADDR(A_SCD_TRACE_CFG)); -#endif printk("Trace buffer frozen\n"); #endif From ae5b0e0973ae1326809084aa3243a97f180cc903 Mon Sep 17 00:00:00 2001 From: Ralf Baechle Date: Wed, 19 Jun 2013 20:18:55 +0200 Subject: [PATCH 0429/1048] MIPS: Sibyte: Fix bus watcher build for BCM1x55 and BCM1x80. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CC arch/mips/sibyte/bcm1480/bus_watcher.o CHK kernel/config_data.h arch/mips/sibyte/bcm1480/bus_watcher.c: In function ‘check_bus_watcher’: arch/mips/sibyte/bcm1480/bus_watcher.c:86:82: error: ‘A_SCD_BUS_ERR_STATUS_DEBUG’ undeclared (first use in this function) arch/mips/sibyte/bcm1480/bus_watcher.c:86:82: note: each undeclared identifier is reported only once for each function it appears in make[3]: *** [arch/mips/sibyte/bcm1480/bus_watcher.o] Error 1 make[2]: *** [arch/mips/sibyte/bcm1480] Error 2 make[1]: *** [arch/mips/sibyte] Error 2 make: *** [arch/mips] Error 2 The register moved around though it's otherwise the same but because of the changed address it now also has a different name. Signed-off-by: Ralf Baechle Patchwork: https://patchwork.linux-mips.org/patch/5514/ Reported-by: Markos Chandras --- arch/mips/sibyte/common/Makefile | 1 + arch/mips/sibyte/{sb1250 => common}/bus_watcher.c | 11 ++++++++++- arch/mips/sibyte/sb1250/Makefile | 1 - 3 files changed, 11 insertions(+), 2 deletions(-) rename arch/mips/sibyte/{sb1250 => common}/bus_watcher.c (94%) diff --git a/arch/mips/sibyte/common/Makefile b/arch/mips/sibyte/common/Makefile index 36aa700cc40c..b3d6bf23a662 100644 --- a/arch/mips/sibyte/common/Makefile +++ b/arch/mips/sibyte/common/Makefile @@ -1,3 +1,4 @@ obj-y := cfe.o +obj-$(CONFIG_SIBYTE_BUS_WATCHER) += bus_watcher.o obj-$(CONFIG_SIBYTE_CFE_CONSOLE) += cfe_console.o obj-$(CONFIG_SIBYTE_TBPROF) += sb_tbprof.o diff --git a/arch/mips/sibyte/sb1250/bus_watcher.c b/arch/mips/sibyte/common/bus_watcher.c similarity index 94% rename from arch/mips/sibyte/sb1250/bus_watcher.c rename to arch/mips/sibyte/common/bus_watcher.c index d0ca7b91c417..5581844c9194 100644 --- a/arch/mips/sibyte/sb1250/bus_watcher.c +++ b/arch/mips/sibyte/common/bus_watcher.c @@ -37,6 +37,9 @@ #include #include #include +#if defined(CONFIG_SIBYTE_BCM1x55) || defined(CONFIG_SIBYTE_BCM1x80) +#include +#endif struct bw_stats_struct { @@ -81,9 +84,15 @@ void check_bus_watcher(void) #ifdef CONFIG_SB1_PASS_1_WORKAROUNDS /* Destructive read, clears register and interrupt */ status = csr_in32(IOADDR(A_SCD_BUS_ERR_STATUS)); -#else +#elif defined(CONFIG_SIBYTE_BCM112X) || defined(CONFIG_SIBYTE_SB1250) /* Use non-destructive register */ status = csr_in32(IOADDR(A_SCD_BUS_ERR_STATUS_DEBUG)); +#elif defined(CONFIG_SIBYTE_BCM1x55) || defined(CONFIG_SIBYTE_BCM1x80) + /* Use non-destructive register */ + /* Same as 1250 except BUS_ERR_STATUS_DEBUG is in a different place. */ + status = csr_in32(IOADDR(A_BCM1480_BUS_ERR_STATUS_DEBUG)); +#else +#error bus watcher being built for unknown Sibyte SOC! #endif if (!(status & 0x7fffffff)) { printk("Using last values reaped by bus watcher driver\n"); diff --git a/arch/mips/sibyte/sb1250/Makefile b/arch/mips/sibyte/sb1250/Makefile index d3d969de407b..cdc4c56c3e29 100644 --- a/arch/mips/sibyte/sb1250/Makefile +++ b/arch/mips/sibyte/sb1250/Makefile @@ -1,4 +1,3 @@ obj-y := setup.o irq.o time.o obj-$(CONFIG_SMP) += smp.o -obj-$(CONFIG_SIBYTE_BUS_WATCHER) += bus_watcher.o From 6793f55cbc84d8520e79c67583f60058b4364daa Mon Sep 17 00:00:00 2001 From: Markos Chandras Date: Mon, 17 Jun 2013 13:00:38 +0000 Subject: [PATCH 0430/1048] MIPS: sibyte: Amend dependencies for SIBYTE_BUS_WATCHER SIBYTE_BUS_WATCHER is only visible if CONFIG_SIBYTE_BCM112X or CONFIG_SIBYTE_SB1250 is selected according to the arch/mips/sibyte/Makefile. This fixes the following build problem: arch/mips/mm/cerr-sb1.c:254: undefined reference to `check_bus_watcher' Signed-off-by: Markos Chandras Acked-by: Steven J. Hill Cc: sibyte-users@bitmover.com Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/5482/ Signed-off-by: Ralf Baechle --- arch/mips/sibyte/Kconfig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/mips/sibyte/Kconfig b/arch/mips/sibyte/Kconfig index 01cc1a749c73..5fbd3605d24f 100644 --- a/arch/mips/sibyte/Kconfig +++ b/arch/mips/sibyte/Kconfig @@ -147,7 +147,8 @@ config SIBYTE_CFE_CONSOLE config SIBYTE_BUS_WATCHER bool "Support for Bus Watcher statistics" - depends on SIBYTE_SB1xxx_SOC + depends on SIBYTE_SB1xxx_SOC && \ + (SIBYTE_BCM112X || SIBYTE_SB1250) help Handle and keep statistics on the bus error interrupts (COR_ECC, BAD_ECC, IO_BUS). From c37441c127e000869a960a866fe2207626935e4f Mon Sep 17 00:00:00 2001 From: Markos Chandras Date: Mon, 17 Jun 2013 07:53:47 +0000 Subject: [PATCH 0431/1048] MIPS: powertv: Drop SYS_HAS_EARLY_PRINTK PowerTV does not provide a prom_putchar function needed for early printk so remove this symbol for this platform. Fixes the following problem when EARLY_PRINTK is enabled for powertv: arch/mips/kernel/early_printk.c:24: undefined reference to `prom_putchar' arch/mips/kernel/early_printk.c:23: undefined reference to `prom_putchar' Signed-off-by: Markos Chandras Acked-by: Steven J. Hill Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/5477/ Signed-off-by: Ralf Baechle --- arch/mips/Kconfig | 1 - 1 file changed, 1 deletion(-) diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig index 49f98bf9e89d..cd8fed8eb9ea 100644 --- a/arch/mips/Kconfig +++ b/arch/mips/Kconfig @@ -419,7 +419,6 @@ config POWERTV select CSRC_POWERTV select DMA_NONCOHERENT select HW_HAS_PCI - select SYS_HAS_EARLY_PRINTK select SYS_HAS_CPU_MIPS32_R2 select SYS_SUPPORTS_32BIT_KERNEL select SYS_SUPPORTS_BIG_ENDIAN From c5e1503fd0428ed3a2e5e48734f47c9f4dfe5a3d Mon Sep 17 00:00:00 2001 From: Paul Burton Date: Sat, 15 Jun 2013 15:34:40 +0000 Subject: [PATCH 0432/1048] MIPS: Fix execution hazard during watchpoint register probe Writing a value to a WatchLo* register creates an execution hazard, so if its value is then read before that hazard is cleared then said value may be invalid. The mips_probe_watch_registers function must therefore clear the execution hazard between setting the match bits in a WatchLo* register & reading the register back in order to check which are set. This fixes intermittent incorrect watchpoint register probing on some MIPS cores such as interAptiv & proAptiv. Signed-off-by: Paul Burton Reviewed-by: James Hogan Acked-by: Steven J. Hill Cc: linux-mips@linux-mips.org Patchwork: http://patchwork.linux-mips.org/patch/5474/ Signed-off-by: Ralf Baechle --- arch/mips/kernel/watch.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/arch/mips/kernel/watch.c b/arch/mips/kernel/watch.c index 7726f6157d9e..cbdc4de85bb4 100644 --- a/arch/mips/kernel/watch.c +++ b/arch/mips/kernel/watch.c @@ -111,6 +111,7 @@ __cpuinit void mips_probe_watch_registers(struct cpuinfo_mips *c) * disable the register. */ write_c0_watchlo0(7); + back_to_back_c0_hazard(); t = read_c0_watchlo0(); write_c0_watchlo0(0); c->watch_reg_masks[0] = t & 7; @@ -121,12 +122,14 @@ __cpuinit void mips_probe_watch_registers(struct cpuinfo_mips *c) c->watch_reg_use_cnt = 1; t = read_c0_watchhi0(); write_c0_watchhi0(t | 0xff8); + back_to_back_c0_hazard(); t = read_c0_watchhi0(); c->watch_reg_masks[0] |= (t & 0xff8); if ((t & 0x80000000) == 0) return; write_c0_watchlo1(7); + back_to_back_c0_hazard(); t = read_c0_watchlo1(); write_c0_watchlo1(0); c->watch_reg_masks[1] = t & 7; @@ -135,12 +138,14 @@ __cpuinit void mips_probe_watch_registers(struct cpuinfo_mips *c) c->watch_reg_use_cnt = 2; t = read_c0_watchhi1(); write_c0_watchhi1(t | 0xff8); + back_to_back_c0_hazard(); t = read_c0_watchhi1(); c->watch_reg_masks[1] |= (t & 0xff8); if ((t & 0x80000000) == 0) return; write_c0_watchlo2(7); + back_to_back_c0_hazard(); t = read_c0_watchlo2(); write_c0_watchlo2(0); c->watch_reg_masks[2] = t & 7; @@ -149,12 +154,14 @@ __cpuinit void mips_probe_watch_registers(struct cpuinfo_mips *c) c->watch_reg_use_cnt = 3; t = read_c0_watchhi2(); write_c0_watchhi2(t | 0xff8); + back_to_back_c0_hazard(); t = read_c0_watchhi2(); c->watch_reg_masks[2] |= (t & 0xff8); if ((t & 0x80000000) == 0) return; write_c0_watchlo3(7); + back_to_back_c0_hazard(); t = read_c0_watchlo3(); write_c0_watchlo3(0); c->watch_reg_masks[3] = t & 7; @@ -163,6 +170,7 @@ __cpuinit void mips_probe_watch_registers(struct cpuinfo_mips *c) c->watch_reg_use_cnt = 4; t = read_c0_watchhi3(); write_c0_watchhi3(t | 0xff8); + back_to_back_c0_hazard(); t = read_c0_watchhi3(); c->watch_reg_masks[3] |= (t & 0xff8); if ((t & 0x80000000) == 0) From 318883517ebc56e1f9068597e9875f578016e225 Mon Sep 17 00:00:00 2001 From: Florian Fainelli Date: Tue, 18 Jun 2013 16:55:38 +0000 Subject: [PATCH 0433/1048] MIPS: BCM63XX: remove bogus Kconfig selects Remove the bogus selects on USB-related symbols for 6345 and 6338, not only we do not yet support USB on BCM63XX, but they also cause the following warnings: warning: (BCM63XX_CPU_6338 && BCM63XX_CPU_6345) selects USB_OHCI_BIG_ENDIAN_MMIO which has unmet direct dependencies (USB_SUPPORT && USB && USB_OHCI_HCD) warning: (BCM63XX_CPU_6338 && BCM63XX_CPU_6345) selects USB_OHCI_BIG_ENDIAN_DESC which has unmet direct dependencies (USB_SUPPORT && USB && USB_OHCI_HCD) make[4]: Leaving directory `/home/florian/dev/linux' Just get rid of these bogus Kconfig selects because neither 6345 nor 6338 actually have built-in USB host controllers. Signed-off-by: Florian Fainelli Cc: linux-mips@linux-mips.org Cc: cernekee@gmail.com Cc: jogo@openwrt.org Patchwork: http://patchwork.linux-mips.org/patch/5497/ Signed-off-by: Ralf Baechle --- arch/mips/bcm63xx/Kconfig | 5 ----- 1 file changed, 5 deletions(-) diff --git a/arch/mips/bcm63xx/Kconfig b/arch/mips/bcm63xx/Kconfig index 5639662fd503..165727daa602 100644 --- a/arch/mips/bcm63xx/Kconfig +++ b/arch/mips/bcm63xx/Kconfig @@ -8,14 +8,9 @@ config BCM63XX_CPU_6328 config BCM63XX_CPU_6338 bool "support 6338 CPU" select HW_HAS_PCI - select USB_ARCH_HAS_OHCI - select USB_OHCI_BIG_ENDIAN_DESC - select USB_OHCI_BIG_ENDIAN_MMIO config BCM63XX_CPU_6345 bool "support 6345 CPU" - select USB_OHCI_BIG_ENDIAN_DESC - select USB_OHCI_BIG_ENDIAN_MMIO config BCM63XX_CPU_6348 bool "support 6348 CPU" From cd6cbde6b01b6e82662cad392c0d177b4af17443 Mon Sep 17 00:00:00 2001 From: Ralf Baechle Date: Wed, 19 Jun 2013 10:57:33 +0200 Subject: [PATCH 0434/1048] WATCHDOG: sb_wdog: Fix 32 bit build failure Fixes the following linking problem: drivers/watchdog/sb_wdog.c:211: undefined reference to `__udivdi3' This results from reading a 64 bit register, then dividing the value by 1000000. For 32 bit kernels gcc will use the helper function __udivdi3 from libgcc which the kernel intentionally doesn't provide. In the read registerbits 23..63 are always zero and only bits 0..22 are signficant. So a simple cast to truncate the read value to 32 bits fixes the issue. Reported and initial patch by Markos Chandras . Signed-off-by: Ralf Baechle Reported-by: Markos Chandras --- drivers/watchdog/sb_wdog.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/watchdog/sb_wdog.c b/drivers/watchdog/sb_wdog.c index 25c7a3f9652d..ea5d84a1fdad 100644 --- a/drivers/watchdog/sb_wdog.c +++ b/drivers/watchdog/sb_wdog.c @@ -208,7 +208,7 @@ static long sbwdog_ioctl(struct file *file, unsigned int cmd, * get the remaining count from the ... count register * which is 1*8 before the config register */ - ret = put_user(__raw_readq(user_dog - 8) / 1000000, p); + ret = put_user((u32)__raw_readq(user_dog - 8) / 1000000, p); break; } return ret; From b90b3802624e1f2a509f3e9f39775d94ec4762d7 Mon Sep 17 00:00:00 2001 From: Ralf Baechle Date: Tue, 7 May 2013 14:10:24 +0200 Subject: [PATCH 0435/1048] MIPS: Fix rtlx build error. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CC arch/mips/kernel/rtlx.o /home/ralf/src/linux/upstream-sfr/arch/mips/kernel/rtlx.c: In function ‘file_write’: /home/ralf/src/linux/upstream-sfr/arch/mips/kernel/rtlx.c:439:23: error: unused variable ‘rt’ [-Werror=unused-variable] /home/ralf/src/linux/upstream-sfr/arch/mips/kernel/rtlx.c: In function ‘rtlx_module_init’: /home/ralf/src/linux/upstream-sfr/arch/mips/kernel/rtlx.c:523:3: error: implicit declaration of function ‘set_vi_handler’ [-Werror=implicit-function-declaration] cc1: all warnings being treated as errors Caused by 496ad9aa8ef448058e36ca7a787c61f2e63f0f54 [new helper: file_inode(file)]. Signed-off-by: Ralf Baechle --- arch/mips/kernel/rtlx.c | 1 - 1 file changed, 1 deletion(-) diff --git a/arch/mips/kernel/rtlx.c b/arch/mips/kernel/rtlx.c index 6fa198db8999..d763f11e35e2 100644 --- a/arch/mips/kernel/rtlx.c +++ b/arch/mips/kernel/rtlx.c @@ -437,7 +437,6 @@ static ssize_t file_write(struct file *file, const char __user * buffer, size_t count, loff_t * ppos) { int minor = iminor(file_inode(file)); - struct rtlx_channel *rt = &rtlx->channel[minor]; /* any space left... */ if (!rtlx_write_poll(minor)) { From 73acc7df534ff458a81435178dab3ea037ed6d78 Mon Sep 17 00:00:00 2001 From: Ralf Baechle Date: Thu, 20 Jun 2013 14:56:17 +0200 Subject: [PATCH 0436/1048] MIPS: Fix TLBR-use hazards for R2 cores in the TLB reload handlers MIPS R2 documents state that an execution hazard barrier is needed after a TLBR before reading EntryLo. Original patch by Leonid Yegoshin . Signed-off-by: Ralf Baechle Patchwork: https://patchwork.linux-mips.org/patch/5526/ --- arch/mips/mm/tlbex.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/arch/mips/mm/tlbex.c b/arch/mips/mm/tlbex.c index afeef93f81a7..f0f4dc44f394 100644 --- a/arch/mips/mm/tlbex.c +++ b/arch/mips/mm/tlbex.c @@ -1935,6 +1935,19 @@ static void __cpuinit build_r4000_tlb_load_handler(void) uasm_i_nop(&p); uasm_i_tlbr(&p); + + switch (current_cpu_type()) { + default: + if (cpu_has_mips_r2) { + uasm_i_ehb(&p); + + case CPU_CAVIUM_OCTEON: + case CPU_CAVIUM_OCTEON_PLUS: + case CPU_CAVIUM_OCTEON2: + break; + } + } + /* Examine entrylo 0 or 1 based on ptr. */ if (use_bbit_insns()) { uasm_i_bbit0(&p, wr.r2, ilog2(sizeof(pte_t)), 8); @@ -1989,6 +2002,19 @@ static void __cpuinit build_r4000_tlb_load_handler(void) uasm_i_nop(&p); uasm_i_tlbr(&p); + + switch (current_cpu_type()) { + default: + if (cpu_has_mips_r2) { + uasm_i_ehb(&p); + + case CPU_CAVIUM_OCTEON: + case CPU_CAVIUM_OCTEON_PLUS: + case CPU_CAVIUM_OCTEON2: + break; + } + } + /* Examine entrylo 0 or 1 based on ptr. */ if (use_bbit_insns()) { uasm_i_bbit0(&p, wr.r2, ilog2(sizeof(pte_t)), 8); From dfb033f09e2a98a89b7a09f7e913f0b791dd01e1 Mon Sep 17 00:00:00 2001 From: Tony Wu Date: Thu, 20 Jun 2013 12:32:30 +0000 Subject: [PATCH 0437/1048] MIPS: microMIPS: Fix POOL16C minor opcode enum As pointed out by Maciej, POOL16C minor opcodes were mostly shifted by one bit. Correct those opcodes, and also add jraddiusp to the enum. Signed-off-by: Tony Wu Cc: Maciej W. Rozycki Acked-by: Steven J. Hill Cc: david.daney@cavium.com Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/5527/ Signed-off-by: Ralf Baechle --- arch/mips/include/uapi/asm/inst.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/arch/mips/include/uapi/asm/inst.h b/arch/mips/include/uapi/asm/inst.h index 0f4aec2ad1e6..e5a676e3d3c0 100644 --- a/arch/mips/include/uapi/asm/inst.h +++ b/arch/mips/include/uapi/asm/inst.h @@ -409,10 +409,11 @@ enum mm_32f_73_minor_op { enum mm_16c_minor_op { mm_lwm16_op = 0x04, mm_swm16_op = 0x05, - mm_jr16_op = 0x18, - mm_jrc_op = 0x1a, - mm_jalr16_op = 0x1c, - mm_jalrs16_op = 0x1e, + mm_jr16_op = 0x0c, + mm_jrc_op = 0x0d, + mm_jalr16_op = 0x0e, + mm_jalrs16_op = 0x0f, + mm_jraddiusp_op = 0x18, }; /* From 98505ff9f2fa1a1b33d90d39ab76a54a3b189ee2 Mon Sep 17 00:00:00 2001 From: Paul Bolle Date: Tue, 9 Apr 2013 06:15:58 -0300 Subject: [PATCH 0438/1048] [media] soc-camera: remove two unused configs The last users of Kconfig symbols MX3_VIDEO and VIDEO_MX2_HOSTSUPPORT were removed in v3.2. Their Kconfig entries can be removed now. Signed-off-by: Paul Bolle Signed-off-by: Guennadi Liakhovetski Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/soc_camera/Kconfig | 8 -------- 1 file changed, 8 deletions(-) diff --git a/drivers/media/platform/soc_camera/Kconfig b/drivers/media/platform/soc_camera/Kconfig index b139b525bb16..ffd00106b205 100644 --- a/drivers/media/platform/soc_camera/Kconfig +++ b/drivers/media/platform/soc_camera/Kconfig @@ -27,14 +27,10 @@ config VIDEO_MX1 ---help--- This is a v4l2 driver for the i.MX1/i.MXL CMOS Sensor Interface -config MX3_VIDEO - bool - config VIDEO_MX3 tristate "i.MX3x Camera Sensor Interface driver" depends on VIDEO_DEV && MX3_IPU && SOC_CAMERA select VIDEOBUF2_DMA_CONTIG - select MX3_VIDEO ---help--- This is a v4l2 driver for the i.MX3x Camera Sensor Interface @@ -66,14 +62,10 @@ config VIDEO_OMAP1 ---help--- This is a v4l2 driver for the TI OMAP1 camera interface -config VIDEO_MX2_HOSTSUPPORT - bool - config VIDEO_MX2 tristate "i.MX27 Camera Sensor Interface driver" depends on VIDEO_DEV && SOC_CAMERA && MACH_MX27 select VIDEOBUF2_DMA_CONTIG - select VIDEO_MX2_HOSTSUPPORT ---help--- This is a v4l2 driver for the i.MX27 Camera Sensor Interface From cbdb1f9db40d2131c00430d2638530b711af89e2 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Tue, 30 Apr 2013 06:29:08 -0300 Subject: [PATCH 0439/1048] [media] soc_camera: Constify dev_pm_ops in mt9t031.c Silences the following warning: WARNING: struct dev_pm_ops should normally be const Signed-off-by: Sachin Kamat Signed-off-by: Guennadi Liakhovetski Signed-off-by: Mauro Carvalho Chehab --- drivers/media/i2c/soc_camera/mt9t031.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/i2c/soc_camera/mt9t031.c b/drivers/media/i2c/soc_camera/mt9t031.c index 8f71c9a02cf0..b3dfeb6d1037 100644 --- a/drivers/media/i2c/soc_camera/mt9t031.c +++ b/drivers/media/i2c/soc_camera/mt9t031.c @@ -570,7 +570,7 @@ static int mt9t031_runtime_resume(struct device *dev) return 0; } -static struct dev_pm_ops mt9t031_dev_pm_ops = { +static const struct dev_pm_ops mt9t031_dev_pm_ops = { .runtime_suspend = mt9t031_runtime_suspend, .runtime_resume = mt9t031_runtime_resume, }; From 8b0706802fede74a2ee0341499f0b4586118a7d3 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Tue, 30 Apr 2013 06:29:09 -0300 Subject: [PATCH 0440/1048] [media] soc_camera: Fix checkpatch warning in ov9640.c Silences the following warning: WARNING: please, no space before tabs Signed-off-by: Sachin Kamat Signed-off-by: Guennadi Liakhovetski Signed-off-by: Mauro Carvalho Chehab --- drivers/media/i2c/soc_camera/ov9640.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/i2c/soc_camera/ov9640.c b/drivers/media/i2c/soc_camera/ov9640.c index 6817be329666..7d1f10f301d3 100644 --- a/drivers/media/i2c/soc_camera/ov9640.c +++ b/drivers/media/i2c/soc_camera/ov9640.c @@ -60,7 +60,7 @@ static const struct ov9640_reg ov9640_regs_dflt[] = { /* Configurations * NOTE: for YUV, alter the following registers: - * COM12 |= OV9640_COM12_YUV_AVG + * COM12 |= OV9640_COM12_YUV_AVG * * for RGB, alter the following registers: * COM7 |= OV9640_COM7_RGB From 721110b34cd9fe411182398850aeb5f6cb204935 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Mon, 13 May 2013 06:19:20 -0300 Subject: [PATCH 0441/1048] [media] soc_camera/sh_mobile_csi2: Remove redundant platform_set_drvdata() Commit 0998d06310 (device-core: Ensure drvdata = NULL when no driver is bound) removes the need to set driver data field to NULL. Signed-off-by: Sachin Kamat Signed-off-by: Guennadi Liakhovetski Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/soc_camera/sh_mobile_csi2.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/drivers/media/platform/soc_camera/sh_mobile_csi2.c b/drivers/media/platform/soc_camera/sh_mobile_csi2.c index 09cb4fc88f34..13a1f8f13f65 100644 --- a/drivers/media/platform/soc_camera/sh_mobile_csi2.c +++ b/drivers/media/platform/soc_camera/sh_mobile_csi2.c @@ -340,18 +340,13 @@ static int sh_csi2_probe(struct platform_device *pdev) ret = v4l2_device_register_subdev(pdata->v4l2_dev, &priv->subdev); dev_dbg(&pdev->dev, "%s(%p): ret(register_subdev) = %d\n", __func__, priv, ret); if (ret < 0) - goto esdreg; + return ret; pm_runtime_enable(&pdev->dev); dev_dbg(&pdev->dev, "CSI2 probed.\n"); return 0; - -esdreg: - platform_set_drvdata(pdev, NULL); - - return ret; } static int sh_csi2_remove(struct platform_device *pdev) @@ -360,7 +355,6 @@ static int sh_csi2_remove(struct platform_device *pdev) v4l2_device_unregister_subdev(&priv->subdev); pm_runtime_disable(&pdev->dev); - platform_set_drvdata(pdev, NULL); return 0; } From f253f184186324dceaad10fd61e2e427177eb485 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Mon, 13 May 2013 06:19:21 -0300 Subject: [PATCH 0442/1048] [media] soc_camera_platform: Remove redundant platform_set_drvdata() Commit 0998d06310 (device-core: Ensure drvdata = NULL when no driver is bound) removes the need to set driver data field to NULL. Signed-off-by: Sachin Kamat [g.liakhovetski@gmx.de: further simplified return statement] Signed-off-by: Guennadi Liakhovetski Signed-off-by: Mauro Carvalho Chehab --- .../media/platform/soc_camera/soc_camera_platform.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/drivers/media/platform/soc_camera/soc_camera_platform.c b/drivers/media/platform/soc_camera/soc_camera_platform.c index 1b7a88ca195b..bdf909d2ec35 100644 --- a/drivers/media/platform/soc_camera/soc_camera_platform.c +++ b/drivers/media/platform/soc_camera/soc_camera_platform.c @@ -137,7 +137,6 @@ static int soc_camera_platform_probe(struct platform_device *pdev) struct soc_camera_platform_priv *priv; struct soc_camera_platform_info *p = pdev->dev.platform_data; struct soc_camera_device *icd; - int ret; if (!p) return -EINVAL; @@ -165,15 +164,7 @@ static int soc_camera_platform_probe(struct platform_device *pdev) v4l2_set_subdevdata(&priv->subdev, p); strncpy(priv->subdev.name, dev_name(&pdev->dev), V4L2_SUBDEV_NAME_SIZE); - ret = v4l2_device_register_subdev(&ici->v4l2_dev, &priv->subdev); - if (ret) - goto evdrs; - - return ret; - -evdrs: - platform_set_drvdata(pdev, NULL); - return ret; + return v4l2_device_register_subdev(&ici->v4l2_dev, &priv->subdev); } static int soc_camera_platform_remove(struct platform_device *pdev) @@ -183,7 +174,6 @@ static int soc_camera_platform_remove(struct platform_device *pdev) p->icd->control = NULL; v4l2_device_unregister_subdev(&priv->subdev); - platform_set_drvdata(pdev, NULL); return 0; } From be843eeb0c91eeafabeed9a7acadd1a47c978915 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Fri, 24 May 2013 08:25:06 -0300 Subject: [PATCH 0443/1048] [media] soc_camera: mt9t112: Remove empty function After the switch to devm_* functions, the 'remove' function does not do anything. Delete it. Signed-off-by: Sachin Kamat Cc: Kuninori Morimoto Signed-off-by: Guennadi Liakhovetski Signed-off-by: Mauro Carvalho Chehab --- drivers/media/i2c/soc_camera/mt9t112.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/media/i2c/soc_camera/mt9t112.c b/drivers/media/i2c/soc_camera/mt9t112.c index 0391d01e8d25..9b276dde5ac8 100644 --- a/drivers/media/i2c/soc_camera/mt9t112.c +++ b/drivers/media/i2c/soc_camera/mt9t112.c @@ -1102,11 +1102,6 @@ static int mt9t112_probe(struct i2c_client *client, return ret; } -static int mt9t112_remove(struct i2c_client *client) -{ - return 0; -} - static const struct i2c_device_id mt9t112_id[] = { { "mt9t112", 0 }, { } @@ -1118,7 +1113,6 @@ static struct i2c_driver mt9t112_i2c_driver = { .name = "mt9t112", }, .probe = mt9t112_probe, - .remove = mt9t112_remove, .id_table = mt9t112_id, }; From f88b50ad6851632a0ff78bfa658e3b5484510969 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Fri, 24 May 2013 08:25:07 -0300 Subject: [PATCH 0444/1048] [media] soc_camera: tw9910: Remove empty function After the switch to devm_* functions, the 'remove' function does not do anything. Delete it. Signed-off-by: Sachin Kamat Cc: Kuninori Morimoto Signed-off-by: Guennadi Liakhovetski Signed-off-by: Mauro Carvalho Chehab --- drivers/media/i2c/soc_camera/tw9910.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/media/i2c/soc_camera/tw9910.c b/drivers/media/i2c/soc_camera/tw9910.c index b5407dfad4ce..b15e1d8194da 100644 --- a/drivers/media/i2c/soc_camera/tw9910.c +++ b/drivers/media/i2c/soc_camera/tw9910.c @@ -925,11 +925,6 @@ static int tw9910_probe(struct i2c_client *client, return tw9910_video_probe(client); } -static int tw9910_remove(struct i2c_client *client) -{ - return 0; -} - static const struct i2c_device_id tw9910_id[] = { { "tw9910", 0 }, { } @@ -941,7 +936,6 @@ static struct i2c_driver tw9910_i2c_driver = { .name = "tw9910", }, .probe = tw9910_probe, - .remove = tw9910_remove, .id_table = tw9910_id, }; From 5a442b765a74264f765eb5f1c67720019aaeb172 Mon Sep 17 00:00:00 2001 From: Thomas Meyer Date: Sat, 1 Jun 2013 06:56:26 -0300 Subject: [PATCH 0445/1048] [media] media: Cocci spatch "ptr_ret.spatch" Use the PTR_RET() macro to simplify error processing. Signed-off-by: Thomas Meyer Signed-off-by: Guennadi Liakhovetski Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/sh_veu.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/media/platform/sh_veu.c b/drivers/media/platform/sh_veu.c index 59a9deefb242..aa4cca371cbf 100644 --- a/drivers/media/platform/sh_veu.c +++ b/drivers/media/platform/sh_veu.c @@ -359,10 +359,7 @@ static int sh_veu_context_init(struct sh_veu_dev *veu) veu->m2m_ctx = v4l2_m2m_ctx_init(veu->m2m_dev, veu, sh_veu_queue_init); - if (IS_ERR(veu->m2m_ctx)) - return PTR_ERR(veu->m2m_ctx); - - return 0; + return PTR_RET(veu->m2m_ctx); } static int sh_veu_querycap(struct file *file, void *priv, From 4ef72e347112a834fbd6944565b1f63d4af19c8a Mon Sep 17 00:00:00 2001 From: Guennadi Liakhovetski Date: Thu, 25 Apr 2013 08:05:15 -0300 Subject: [PATCH 0446/1048] [media] V4L2: soc-camera: remove unneeded include path soc-camera isn't sufficiently broken to include any files from the drivers/media/i2c/soc_camera directory in its core or host driver files:-) Signed-off-by: Guennadi Liakhovetski Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/soc_camera/Makefile | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/media/platform/soc_camera/Makefile b/drivers/media/platform/soc_camera/Makefile index 136b7f8ff10d..bedb0428852b 100644 --- a/drivers/media/platform/soc_camera/Makefile +++ b/drivers/media/platform/soc_camera/Makefile @@ -10,5 +10,3 @@ obj-$(CONFIG_VIDEO_OMAP1) += omap1_camera.o obj-$(CONFIG_VIDEO_PXA27x) += pxa_camera.o obj-$(CONFIG_VIDEO_SH_MOBILE_CEU) += sh_mobile_ceu_camera.o obj-$(CONFIG_VIDEO_SH_MOBILE_CSI2) += sh_mobile_csi2.o - -ccflags-y += -I$(srctree)/drivers/media/i2c/soc_camera From b9d4b2da35d44117831c3382710f12a1f9965ed5 Mon Sep 17 00:00:00 2001 From: Alexey Khoroshilov Date: Mon, 10 Jun 2013 16:00:54 -0300 Subject: [PATCH 0447/1048] [media] ttusb-budget: fix memory leak in ttusb_probe() If something goes wrong starting from i2c_add_adapter(), ttusb->iso_urb[] and ttusb itself are not deallocated. Found by Linux Driver Verification project (linuxtesting.org). Signed-off-by: Alexey Khoroshilov Signed-off-by: Mauro Carvalho Chehab --- drivers/media/usb/ttusb-budget/dvb-ttusb-budget.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/media/usb/ttusb-budget/dvb-ttusb-budget.c b/drivers/media/usb/ttusb-budget/dvb-ttusb-budget.c index 21b9049c7b3f..f8a60c197534 100644 --- a/drivers/media/usb/ttusb-budget/dvb-ttusb-budget.c +++ b/drivers/media/usb/ttusb-budget/dvb-ttusb-budget.c @@ -1768,6 +1768,8 @@ err_i2c_del_adapter: i2c_del_adapter(&ttusb->i2c_adap); err_unregister_adapter: dvb_unregister_adapter (&ttusb->adapter); + ttusb_free_iso_urbs(ttusb); + kfree(ttusb); return result; } From f7f6ce2d09c86bd80ee11bd654a1ac1e8f5dfe13 Mon Sep 17 00:00:00 2001 From: Guennadi Liakhovetski Date: Thu, 4 Apr 2013 08:21:12 -0300 Subject: [PATCH 0448/1048] [media] soc-camera: move common code to soc_camera.c All soc-camera host drivers include a pointer to an soc-camera device in their host private struct to check, that only one client is connected. Move this common code to soc_camera.c. Signed-off-by: Guennadi Liakhovetski Acked-by: Hans Verkuil Acked-by: Laurent Pinchart Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/soc_camera/atmel-isi.c | 10 +---- .../media/platform/soc_camera/mx1_camera.c | 20 +++------- .../media/platform/soc_camera/mx2_camera.c | 13 +------ .../media/platform/soc_camera/mx3_camera.c | 9 ----- .../media/platform/soc_camera/omap1_camera.c | 14 +------ .../media/platform/soc_camera/pxa_camera.c | 18 ++------- .../soc_camera/sh_mobile_ceu_camera.c | 13 +------ .../media/platform/soc_camera/soc_camera.c | 38 ++++++++++++++++--- include/media/soc_camera.h | 1 + 9 files changed, 49 insertions(+), 87 deletions(-) diff --git a/drivers/media/platform/soc_camera/atmel-isi.c b/drivers/media/platform/soc_camera/atmel-isi.c index 1abbb36d0755..c9e080a57a60 100644 --- a/drivers/media/platform/soc_camera/atmel-isi.c +++ b/drivers/media/platform/soc_camera/atmel-isi.c @@ -102,7 +102,6 @@ struct atmel_isi { struct list_head video_buffer_list; struct frame_buffer *active; - struct soc_camera_device *icd; struct soc_camera_host soc_host; }; @@ -367,7 +366,7 @@ static void start_dma(struct atmel_isi *isi, struct frame_buffer *buffer) /* Check if already in a frame */ if (isi_readl(isi, ISI_STATUS) & ISI_CTRL_CDC) { - dev_err(isi->icd->parent, "Already in frame handling.\n"); + dev_err(isi->soc_host.icd->parent, "Already in frame handling.\n"); return; } @@ -753,9 +752,6 @@ static int isi_camera_add_device(struct soc_camera_device *icd) struct atmel_isi *isi = ici->priv; int ret; - if (isi->icd) - return -EBUSY; - ret = clk_enable(isi->pclk); if (ret) return ret; @@ -766,7 +762,6 @@ static int isi_camera_add_device(struct soc_camera_device *icd) return ret; } - isi->icd = icd; dev_dbg(icd->parent, "Atmel ISI Camera driver attached to camera %d\n", icd->devnum); return 0; @@ -777,11 +772,8 @@ static void isi_camera_remove_device(struct soc_camera_device *icd) struct soc_camera_host *ici = to_soc_camera_host(icd->parent); struct atmel_isi *isi = ici->priv; - BUG_ON(icd != isi->icd); - clk_disable(isi->mck); clk_disable(isi->pclk); - isi->icd = NULL; dev_dbg(icd->parent, "Atmel ISI Camera driver detached from camera %d\n", icd->devnum); diff --git a/drivers/media/platform/soc_camera/mx1_camera.c b/drivers/media/platform/soc_camera/mx1_camera.c index a3fd8d63546c..5f9ec8efd978 100644 --- a/drivers/media/platform/soc_camera/mx1_camera.c +++ b/drivers/media/platform/soc_camera/mx1_camera.c @@ -104,7 +104,6 @@ struct mx1_buffer { */ struct mx1_camera_dev { struct soc_camera_host soc_host; - struct soc_camera_device *icd; struct mx1_camera_pdata *pdata; struct mx1_buffer *active; struct resource *res; @@ -220,7 +219,7 @@ out: static int mx1_camera_setup_dma(struct mx1_camera_dev *pcdev) { struct videobuf_buffer *vbuf = &pcdev->active->vb; - struct device *dev = pcdev->icd->parent; + struct device *dev = pcdev->soc_host.icd->parent; int ret; if (unlikely(!pcdev->active)) { @@ -331,7 +330,7 @@ static void mx1_camera_wakeup(struct mx1_camera_dev *pcdev, static void mx1_camera_dma_irq(int channel, void *data) { struct mx1_camera_dev *pcdev = data; - struct device *dev = pcdev->icd->parent; + struct device *dev = pcdev->soc_host.icd->parent; struct mx1_buffer *buf; struct videobuf_buffer *vb; unsigned long flags; @@ -389,7 +388,7 @@ static int mclk_get_divisor(struct mx1_camera_dev *pcdev) */ div = (lcdclk + 2 * mclk - 1) / (2 * mclk) - 1; - dev_dbg(pcdev->icd->parent, + dev_dbg(pcdev->soc_host.icd->parent, "System clock %lukHz, target freq %dkHz, divisor %lu\n", lcdclk / 1000, mclk / 1000, div); @@ -400,7 +399,7 @@ static void mx1_camera_activate(struct mx1_camera_dev *pcdev) { unsigned int csicr1 = CSICR1_EN; - dev_dbg(pcdev->icd->parent, "Activate device\n"); + dev_dbg(pcdev->soc_host.icd->parent, "Activate device\n"); clk_prepare_enable(pcdev->clk); @@ -416,7 +415,7 @@ static void mx1_camera_activate(struct mx1_camera_dev *pcdev) static void mx1_camera_deactivate(struct mx1_camera_dev *pcdev) { - dev_dbg(pcdev->icd->parent, "Deactivate device\n"); + dev_dbg(pcdev->soc_host.icd->parent, "Deactivate device\n"); /* Disable all CSI interface */ __raw_writel(0x00, pcdev->base + CSICR1); @@ -433,16 +432,11 @@ static int mx1_camera_add_device(struct soc_camera_device *icd) struct soc_camera_host *ici = to_soc_camera_host(icd->parent); struct mx1_camera_dev *pcdev = ici->priv; - if (pcdev->icd) - return -EBUSY; - dev_info(icd->parent, "MX1 Camera driver attached to camera %d\n", icd->devnum); mx1_camera_activate(pcdev); - pcdev->icd = icd; - return 0; } @@ -452,8 +446,6 @@ static void mx1_camera_remove_device(struct soc_camera_device *icd) struct mx1_camera_dev *pcdev = ici->priv; unsigned int csicr1; - BUG_ON(icd != pcdev->icd); - /* disable interrupts */ csicr1 = __raw_readl(pcdev->base + CSICR1) & ~CSI_IRQ_MASK; __raw_writel(csicr1, pcdev->base + CSICR1); @@ -465,8 +457,6 @@ static void mx1_camera_remove_device(struct soc_camera_device *icd) icd->devnum); mx1_camera_deactivate(pcdev); - - pcdev->icd = NULL; } static int mx1_camera_set_bus_param(struct soc_camera_device *icd) diff --git a/drivers/media/platform/soc_camera/mx2_camera.c b/drivers/media/platform/soc_camera/mx2_camera.c index 5bbeb43e4531..772e0710f59b 100644 --- a/drivers/media/platform/soc_camera/mx2_camera.c +++ b/drivers/media/platform/soc_camera/mx2_camera.c @@ -236,7 +236,6 @@ enum mx2_camera_type { struct mx2_camera_dev { struct device *dev; struct soc_camera_host soc_host; - struct soc_camera_device *icd; struct clk *clk_emma_ahb, *clk_emma_ipg; struct clk *clk_csi_ahb, *clk_csi_per; @@ -394,8 +393,8 @@ static void mx27_update_emma_buf(struct mx2_camera_dev *pcdev, writel(phys, pcdev->base_emma + PRP_DEST_Y_PTR - 0x14 * bufnum); if (prp->out_fmt == V4L2_PIX_FMT_YUV420) { - u32 imgsize = pcdev->icd->user_height * - pcdev->icd->user_width; + u32 imgsize = pcdev->soc_host.icd->user_height * + pcdev->soc_host.icd->user_width; writel(phys + imgsize, pcdev->base_emma + PRP_DEST_CB_PTR - 0x14 * bufnum); @@ -424,9 +423,6 @@ static int mx2_camera_add_device(struct soc_camera_device *icd) int ret; u32 csicr1; - if (pcdev->icd) - return -EBUSY; - ret = clk_prepare_enable(pcdev->clk_csi_ahb); if (ret < 0) return ret; @@ -441,7 +437,6 @@ static int mx2_camera_add_device(struct soc_camera_device *icd) pcdev->csicr1 = csicr1; writel(pcdev->csicr1, pcdev->base_csi + CSICR1); - pcdev->icd = icd; pcdev->frame_count = 0; dev_info(icd->parent, "Camera driver attached to camera %d\n", @@ -460,14 +455,10 @@ static void mx2_camera_remove_device(struct soc_camera_device *icd) struct soc_camera_host *ici = to_soc_camera_host(icd->parent); struct mx2_camera_dev *pcdev = ici->priv; - BUG_ON(icd != pcdev->icd); - dev_info(icd->parent, "Camera driver detached from camera %d\n", icd->devnum); mx2_camera_deactivate(pcdev); - - pcdev->icd = NULL; } /* diff --git a/drivers/media/platform/soc_camera/mx3_camera.c b/drivers/media/platform/soc_camera/mx3_camera.c index 5da337736cd8..71b9b191957c 100644 --- a/drivers/media/platform/soc_camera/mx3_camera.c +++ b/drivers/media/platform/soc_camera/mx3_camera.c @@ -94,7 +94,6 @@ struct mx3_camera_dev { * Interface. If anyone ever builds hardware to enable more than one * camera _simultaneously_, they will have to modify this driver too */ - struct soc_camera_device *icd; struct clk *clk; void __iomem *base; @@ -517,13 +516,9 @@ static int mx3_camera_add_device(struct soc_camera_device *icd) struct soc_camera_host *ici = to_soc_camera_host(icd->parent); struct mx3_camera_dev *mx3_cam = ici->priv; - if (mx3_cam->icd) - return -EBUSY; - mx3_camera_activate(mx3_cam, icd); mx3_cam->buf_total = 0; - mx3_cam->icd = icd; dev_info(icd->parent, "MX3 Camera driver attached to camera %d\n", icd->devnum); @@ -538,8 +533,6 @@ static void mx3_camera_remove_device(struct soc_camera_device *icd) struct mx3_camera_dev *mx3_cam = ici->priv; struct idmac_channel **ichan = &mx3_cam->idmac_channel[0]; - BUG_ON(icd != mx3_cam->icd); - if (*ichan) { dma_release_channel(&(*ichan)->dma_chan); *ichan = NULL; @@ -547,8 +540,6 @@ static void mx3_camera_remove_device(struct soc_camera_device *icd) clk_disable_unprepare(mx3_cam->clk); - mx3_cam->icd = NULL; - dev_info(icd->parent, "MX3 Camera driver detached from camera %d\n", icd->devnum); } diff --git a/drivers/media/platform/soc_camera/omap1_camera.c b/drivers/media/platform/soc_camera/omap1_camera.c index 9689a6e89b7f..c42c23e4eb72 100644 --- a/drivers/media/platform/soc_camera/omap1_camera.c +++ b/drivers/media/platform/soc_camera/omap1_camera.c @@ -150,7 +150,6 @@ struct omap1_cam_buf { struct omap1_cam_dev { struct soc_camera_host soc_host; - struct soc_camera_device *icd; struct clk *clk; unsigned int irq; @@ -564,7 +563,7 @@ static void videobuf_done(struct omap1_cam_dev *pcdev, { struct omap1_cam_buf *buf = pcdev->active; struct videobuf_buffer *vb; - struct device *dev = pcdev->icd->parent; + struct device *dev = pcdev->soc_host.icd->parent; if (WARN_ON(!buf)) { suspend_capture(pcdev); @@ -790,7 +789,7 @@ out: static irqreturn_t cam_isr(int irq, void *data) { struct omap1_cam_dev *pcdev = data; - struct device *dev = pcdev->icd->parent; + struct device *dev = pcdev->soc_host.icd->parent; struct omap1_cam_buf *buf = pcdev->active; u32 it_status; unsigned long flags; @@ -904,9 +903,6 @@ static int omap1_cam_add_device(struct soc_camera_device *icd) struct omap1_cam_dev *pcdev = ici->priv; u32 ctrlclock; - if (pcdev->icd) - return -EBUSY; - clk_enable(pcdev->clk); /* setup sensor clock */ @@ -941,8 +937,6 @@ static int omap1_cam_add_device(struct soc_camera_device *icd) sensor_reset(pcdev, false); - pcdev->icd = icd; - dev_dbg(icd->parent, "OMAP1 Camera driver attached to camera %d\n", icd->devnum); return 0; @@ -954,8 +948,6 @@ static void omap1_cam_remove_device(struct soc_camera_device *icd) struct omap1_cam_dev *pcdev = ici->priv; u32 ctrlclock; - BUG_ON(icd != pcdev->icd); - suspend_capture(pcdev); disable_capture(pcdev); @@ -974,8 +966,6 @@ static void omap1_cam_remove_device(struct soc_camera_device *icd) clk_disable(pcdev->clk); - pcdev->icd = NULL; - dev_dbg(icd->parent, "OMAP1 Camera driver detached from camera %d\n", icd->devnum); } diff --git a/drivers/media/platform/soc_camera/pxa_camera.c b/drivers/media/platform/soc_camera/pxa_camera.c index d665242e8207..686edf7c016c 100644 --- a/drivers/media/platform/soc_camera/pxa_camera.c +++ b/drivers/media/platform/soc_camera/pxa_camera.c @@ -200,7 +200,6 @@ struct pxa_camera_dev { * interface. If anyone ever builds hardware to enable more than * one camera, they will have to modify this driver too */ - struct soc_camera_device *icd; struct clk *clk; unsigned int irq; @@ -966,13 +965,8 @@ static int pxa_camera_add_device(struct soc_camera_device *icd) struct soc_camera_host *ici = to_soc_camera_host(icd->parent); struct pxa_camera_dev *pcdev = ici->priv; - if (pcdev->icd) - return -EBUSY; - pxa_camera_activate(pcdev); - pcdev->icd = icd; - dev_info(icd->parent, "PXA Camera driver attached to camera %d\n", icd->devnum); @@ -985,8 +979,6 @@ static void pxa_camera_remove_device(struct soc_camera_device *icd) struct soc_camera_host *ici = to_soc_camera_host(icd->parent); struct pxa_camera_dev *pcdev = ici->priv; - BUG_ON(icd != pcdev->icd); - dev_info(icd->parent, "PXA Camera driver detached from camera %d\n", icd->devnum); @@ -999,8 +991,6 @@ static void pxa_camera_remove_device(struct soc_camera_device *icd) DCSR(pcdev->dma_chans[2]) = 0; pxa_camera_deactivate(pcdev); - - pcdev->icd = NULL; } static int test_platform_param(struct pxa_camera_dev *pcdev, @@ -1596,8 +1586,8 @@ static int pxa_camera_suspend(struct device *dev) pcdev->save_cicr[i++] = __raw_readl(pcdev->base + CICR3); pcdev->save_cicr[i++] = __raw_readl(pcdev->base + CICR4); - if (pcdev->icd) { - struct v4l2_subdev *sd = soc_camera_to_subdev(pcdev->icd); + if (pcdev->soc_host.icd) { + struct v4l2_subdev *sd = soc_camera_to_subdev(pcdev->soc_host.icd); ret = v4l2_subdev_call(sd, core, s_power, 0); if (ret == -ENOIOCTLCMD) ret = 0; @@ -1622,8 +1612,8 @@ static int pxa_camera_resume(struct device *dev) __raw_writel(pcdev->save_cicr[i++], pcdev->base + CICR3); __raw_writel(pcdev->save_cicr[i++], pcdev->base + CICR4); - if (pcdev->icd) { - struct v4l2_subdev *sd = soc_camera_to_subdev(pcdev->icd); + if (pcdev->soc_host.icd) { + struct v4l2_subdev *sd = soc_camera_to_subdev(pcdev->soc_host.icd); ret = v4l2_subdev_call(sd, core, s_power, 1); if (ret == -ENOIOCTLCMD) ret = 0; diff --git a/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c b/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c index 143d29fe0137..5b7d8e1dd448 100644 --- a/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c +++ b/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c @@ -95,7 +95,6 @@ struct sh_mobile_ceu_buffer { struct sh_mobile_ceu_dev { struct soc_camera_host ici; - struct soc_camera_device *icd; struct platform_device *csi2_pdev; unsigned int irq; @@ -163,7 +162,7 @@ static u32 ceu_read(struct sh_mobile_ceu_dev *priv, unsigned long reg_offs) static int sh_mobile_ceu_soft_reset(struct sh_mobile_ceu_dev *pcdev) { int i, success = 0; - struct soc_camera_device *icd = pcdev->icd; + struct soc_camera_device *icd = pcdev->ici.icd; ceu_write(pcdev, CAPSR, 1 << 16); /* reset */ @@ -277,7 +276,7 @@ static int sh_mobile_ceu_videobuf_setup(struct vb2_queue *vq, */ static int sh_mobile_ceu_capture(struct sh_mobile_ceu_dev *pcdev) { - struct soc_camera_device *icd = pcdev->icd; + struct soc_camera_device *icd = pcdev->ici.icd; dma_addr_t phys_addr_top, phys_addr_bottom; unsigned long top1, top2; unsigned long bottom1, bottom2; @@ -552,9 +551,6 @@ static int sh_mobile_ceu_add_device(struct soc_camera_device *icd) struct v4l2_subdev *csi2_sd; int ret; - if (pcdev->icd) - return -EBUSY; - dev_info(icd->parent, "SuperH Mobile CEU driver attached to camera %d\n", icd->devnum); @@ -583,7 +579,6 @@ static int sh_mobile_ceu_add_device(struct soc_camera_device *icd) */ if (ret == -ENODEV && csi2_sd) csi2_sd->grp_id = 0; - pcdev->icd = icd; return 0; } @@ -595,8 +590,6 @@ static void sh_mobile_ceu_remove_device(struct soc_camera_device *icd) struct sh_mobile_ceu_dev *pcdev = ici->priv; struct v4l2_subdev *csi2_sd = find_csi2(pcdev); - BUG_ON(icd != pcdev->icd); - v4l2_subdev_call(csi2_sd, core, s_power, 0); if (csi2_sd) csi2_sd->grp_id = 0; @@ -618,8 +611,6 @@ static void sh_mobile_ceu_remove_device(struct soc_camera_device *icd) dev_info(icd->parent, "SuperH Mobile CEU driver detached from camera %d\n", icd->devnum); - - pcdev->icd = NULL; } /* diff --git a/drivers/media/platform/soc_camera/soc_camera.c b/drivers/media/platform/soc_camera/soc_camera.c index 5099eebf994d..1e831009f914 100644 --- a/drivers/media/platform/soc_camera/soc_camera.c +++ b/drivers/media/platform/soc_camera/soc_camera.c @@ -504,6 +504,32 @@ static int soc_camera_set_fmt(struct soc_camera_device *icd, return ici->ops->set_bus_param(icd); } +static int soc_camera_add_device(struct soc_camera_device *icd) +{ + struct soc_camera_host *ici = to_soc_camera_host(icd->parent); + int ret; + + if (ici->icd) + return -EBUSY; + + ret = ici->ops->add(icd); + if (!ret) + ici->icd = icd; + + return ret; +} + +static void soc_camera_remove_device(struct soc_camera_device *icd) +{ + struct soc_camera_host *ici = to_soc_camera_host(icd->parent); + + if (WARN_ON(icd != ici->icd)) + return; + + ici->ops->remove(icd); + ici->icd = NULL; +} + static int soc_camera_open(struct file *file) { struct video_device *vdev = video_devdata(file); @@ -567,7 +593,7 @@ static int soc_camera_open(struct file *file) if (sdesc->subdev_desc.reset) sdesc->subdev_desc.reset(icd->pdev); - ret = ici->ops->add(icd); + ret = soc_camera_add_device(icd); if (ret < 0) { dev_err(icd->pdev, "Couldn't activate the camera: %d\n", ret); goto eiciadd; @@ -618,7 +644,7 @@ esfmt: eresume: __soc_camera_power_off(icd); epower: - ici->ops->remove(icd); + soc_camera_remove_device(icd); eiciadd: icd->use_count--; mutex_unlock(&ici->host_lock); @@ -644,7 +670,7 @@ static int soc_camera_close(struct file *file) vb2_queue_release(&icd->vb2_vidq); __soc_camera_power_off(icd); - ici->ops->remove(icd); + soc_camera_remove_device(icd); } if (icd->streamer == file) @@ -1137,7 +1163,7 @@ static int soc_camera_probe(struct soc_camera_device *icd) ssdd->reset(icd->pdev); mutex_lock(&ici->host_lock); - ret = ici->ops->add(icd); + ret = soc_camera_add_device(icd); mutex_unlock(&ici->host_lock); if (ret < 0) goto eadd; @@ -1210,7 +1236,7 @@ static int soc_camera_probe(struct soc_camera_device *icd) icd->field = mf.field; } - ici->ops->remove(icd); + soc_camera_remove_device(icd); mutex_unlock(&ici->host_lock); @@ -1233,7 +1259,7 @@ eadddev: icd->vdev = NULL; evdc: mutex_lock(&ici->host_lock); - ici->ops->remove(icd); + soc_camera_remove_device(icd); mutex_unlock(&ici->host_lock); eadd: v4l2_ctrl_handler_free(&icd->ctrl_handler); diff --git a/include/media/soc_camera.h b/include/media/soc_camera.h index 31a4bfe42194..db23a8f0c26b 100644 --- a/include/media/soc_camera.h +++ b/include/media/soc_camera.h @@ -64,6 +64,7 @@ struct soc_camera_host { struct mutex host_lock; /* Protect pipeline modifications */ unsigned char nr; /* Host number */ u32 capabilities; + struct soc_camera_device *icd; /* Currently attached client */ void *priv; const char *drv_name; struct soc_camera_host_ops *ops; From eb569cf9db804e6ba34b3a1812415e59d5e43d1a Mon Sep 17 00:00:00 2001 From: Guennadi Liakhovetski Date: Thu, 4 Apr 2013 08:51:36 -0300 Subject: [PATCH 0449/1048] [media] soc-camera: add host clock callbacks to start and stop the master clock Currently soc-camera uses a single camera host callback to activate the interface master clock and to configure the interface for a specific client. However, during probing we might not have the information about a client, we just need to activate the clock. Add new camera host driver callbacks to only start and stop the clock without and client-specific configuration. Signed-off-by: Guennadi Liakhovetski Acked-by: Hans Verkuil Acked-by: Laurent Pinchart Signed-off-by: Mauro Carvalho Chehab --- .../media/platform/soc_camera/soc_camera.c | 21 ++++++++++++++++--- include/media/soc_camera.h | 2 ++ 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/drivers/media/platform/soc_camera/soc_camera.c b/drivers/media/platform/soc_camera/soc_camera.c index 1e831009f914..3cc086036070 100644 --- a/drivers/media/platform/soc_camera/soc_camera.c +++ b/drivers/media/platform/soc_camera/soc_camera.c @@ -512,10 +512,23 @@ static int soc_camera_add_device(struct soc_camera_device *icd) if (ici->icd) return -EBUSY; - ret = ici->ops->add(icd); - if (!ret) - ici->icd = icd; + if (ici->ops->clock_start) { + ret = ici->ops->clock_start(ici); + if (ret < 0) + return ret; + } + ret = ici->ops->add(icd); + if (ret < 0) + goto eadd; + + ici->icd = icd; + + return 0; + +eadd: + if (ici->ops->clock_stop) + ici->ops->clock_stop(ici); return ret; } @@ -527,6 +540,8 @@ static void soc_camera_remove_device(struct soc_camera_device *icd) return; ici->ops->remove(icd); + if (ici->ops->clock_stop) + ici->ops->clock_stop(ici); ici->icd = NULL; } diff --git a/include/media/soc_camera.h b/include/media/soc_camera.h index db23a8f0c26b..dfa24df960df 100644 --- a/include/media/soc_camera.h +++ b/include/media/soc_camera.h @@ -74,6 +74,8 @@ struct soc_camera_host_ops { struct module *owner; int (*add)(struct soc_camera_device *); void (*remove)(struct soc_camera_device *); + int (*clock_start)(struct soc_camera_host *); + void (*clock_stop)(struct soc_camera_host *); /* * .get_formats() is called for each client device format, but * .put_formats() is only called once. Further, if any of the calls to From 39b553dbb4a75debf814a261e58f09347eef337f Mon Sep 17 00:00:00 2001 From: Guennadi Liakhovetski Date: Thu, 4 Apr 2013 08:56:00 -0300 Subject: [PATCH 0450/1048] [media] pxa-camera: move interface activation and deactivation to clock callbacks When adding and removing a client, the pxa-camera driver only activates and deactivates its camera interface respectively, which doesn't include any client-specific actions. Move this functionality into .clock_start() and .clock_stop() callbacks. Signed-off-by: Guennadi Liakhovetski Acked-by: Hans Verkuil Acked-by: Laurent Pinchart Signed-off-by: Mauro Carvalho Chehab --- .../media/platform/soc_camera/pxa_camera.c | 36 +++++++++++-------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/drivers/media/platform/soc_camera/pxa_camera.c b/drivers/media/platform/soc_camera/pxa_camera.c index 686edf7c016c..d4df305fcc18 100644 --- a/drivers/media/platform/soc_camera/pxa_camera.c +++ b/drivers/media/platform/soc_camera/pxa_camera.c @@ -955,32 +955,38 @@ static irqreturn_t pxa_camera_irq(int irq, void *data) return IRQ_HANDLED; } -/* - * The following two functions absolutely depend on the fact, that - * there can be only one camera on PXA quick capture interface - * Called with .host_lock held - */ static int pxa_camera_add_device(struct soc_camera_device *icd) { - struct soc_camera_host *ici = to_soc_camera_host(icd->parent); - struct pxa_camera_dev *pcdev = ici->priv; - - pxa_camera_activate(pcdev); - dev_info(icd->parent, "PXA Camera driver attached to camera %d\n", icd->devnum); return 0; } -/* Called with .host_lock held */ static void pxa_camera_remove_device(struct soc_camera_device *icd) { - struct soc_camera_host *ici = to_soc_camera_host(icd->parent); - struct pxa_camera_dev *pcdev = ici->priv; - dev_info(icd->parent, "PXA Camera driver detached from camera %d\n", icd->devnum); +} + +/* + * The following two functions absolutely depend on the fact, that + * there can be only one camera on PXA quick capture interface + * Called with .host_lock held + */ +static int pxa_camera_clock_start(struct soc_camera_host *ici) +{ + struct pxa_camera_dev *pcdev = ici->priv; + + pxa_camera_activate(pcdev); + + return 0; +} + +/* Called with .host_lock held */ +static void pxa_camera_clock_stop(struct soc_camera_host *ici) +{ + struct pxa_camera_dev *pcdev = ici->priv; /* disable capture, disable interrupts */ __raw_writel(0x3ff, pcdev->base + CICR0); @@ -1630,6 +1636,8 @@ static struct soc_camera_host_ops pxa_soc_camera_host_ops = { .owner = THIS_MODULE, .add = pxa_camera_add_device, .remove = pxa_camera_remove_device, + .clock_start = pxa_camera_clock_start, + .clock_stop = pxa_camera_clock_stop, .set_crop = pxa_camera_set_crop, .get_formats = pxa_camera_get_formats, .put_formats = pxa_camera_put_formats, From b5dbfe46e40fa3fd9a6dd43f20cc71050fe5ef2d Mon Sep 17 00:00:00 2001 From: Guennadi Liakhovetski Date: Thu, 4 Apr 2013 09:38:00 -0300 Subject: [PATCH 0451/1048] [media] omap1-camera: move interface activation and deactivation to clock callbacks When adding and removing a client, the omap1-camera driver only activates and deactivates its camera interface respectively, which doesn't include any client-specific actions. Move this functionality into .clock_start() and .clock_stop() callbacks. Signed-off-by: Guennadi Liakhovetski Acked-by: Hans Verkuil Acked-by: Laurent Pinchart Signed-off-by: Mauro Carvalho Chehab --- .../media/platform/soc_camera/omap1_camera.c | 27 ++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/drivers/media/platform/soc_camera/omap1_camera.c b/drivers/media/platform/soc_camera/omap1_camera.c index c42c23e4eb72..6769193c7c7b 100644 --- a/drivers/media/platform/soc_camera/omap1_camera.c +++ b/drivers/media/platform/soc_camera/omap1_camera.c @@ -893,13 +893,26 @@ static void sensor_reset(struct omap1_cam_dev *pcdev, bool reset) CAM_WRITE(pcdev, GPIO, !reset); } +static int omap1_cam_add_device(struct soc_camera_device *icd) +{ + dev_dbg(icd->parent, "OMAP1 Camera driver attached to camera %d\n", + icd->devnum); + + return 0; +} + +static void omap1_cam_remove_device(struct soc_camera_device *icd) +{ + dev_dbg(icd->parent, + "OMAP1 Camera driver detached from camera %d\n", icd->devnum); +} + /* * The following two functions absolutely depend on the fact, that * there can be only one camera on OMAP1 camera sensor interface */ -static int omap1_cam_add_device(struct soc_camera_device *icd) +static int omap1_cam_clock_start(struct soc_camera_host *ici) { - struct soc_camera_host *ici = to_soc_camera_host(icd->parent); struct omap1_cam_dev *pcdev = ici->priv; u32 ctrlclock; @@ -937,14 +950,11 @@ static int omap1_cam_add_device(struct soc_camera_device *icd) sensor_reset(pcdev, false); - dev_dbg(icd->parent, "OMAP1 Camera driver attached to camera %d\n", - icd->devnum); return 0; } -static void omap1_cam_remove_device(struct soc_camera_device *icd) +static void omap1_cam_clock_stop(struct soc_camera_host *ici) { - struct soc_camera_host *ici = to_soc_camera_host(icd->parent); struct omap1_cam_dev *pcdev = ici->priv; u32 ctrlclock; @@ -965,9 +975,6 @@ static void omap1_cam_remove_device(struct soc_camera_device *icd) CAM_WRITE(pcdev, CTRLCLOCK, ctrlclock & ~MCLK_EN); clk_disable(pcdev->clk); - - dev_dbg(icd->parent, - "OMAP1 Camera driver detached from camera %d\n", icd->devnum); } /* Duplicate standard formats based on host capability of byte swapping */ @@ -1525,6 +1532,8 @@ static struct soc_camera_host_ops omap1_host_ops = { .owner = THIS_MODULE, .add = omap1_cam_add_device, .remove = omap1_cam_remove_device, + .clock_start = omap1_cam_clock_start, + .clock_stop = omap1_cam_clock_stop, .get_formats = omap1_cam_get_formats, .set_crop = omap1_cam_set_crop, .set_fmt = omap1_cam_set_fmt, From ffebad7948ee0e9c619ae6e87d99437d907fc7e3 Mon Sep 17 00:00:00 2001 From: Guennadi Liakhovetski Date: Thu, 4 Apr 2013 09:56:09 -0300 Subject: [PATCH 0452/1048] [media] atmel-isi: move interface activation and deactivation to clock callbacks When adding and removing a client, the atmel-isi camera host driver only activates and deactivates its camera interface respectively, which doesn't include any client-specific actions. Move this functionality into .clock_start() and .clock_stop() callbacks. Signed-off-by: Guennadi Liakhovetski Acked-by: Hans Verkuil Acked-by: Laurent Pinchart Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/soc_camera/atmel-isi.c | 28 +++++++++++++------ 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/drivers/media/platform/soc_camera/atmel-isi.c b/drivers/media/platform/soc_camera/atmel-isi.c index c9e080a57a60..104485632501 100644 --- a/drivers/media/platform/soc_camera/atmel-isi.c +++ b/drivers/media/platform/soc_camera/atmel-isi.c @@ -745,10 +745,23 @@ static int isi_camera_get_formats(struct soc_camera_device *icd, return formats; } -/* Called with .host_lock held */ static int isi_camera_add_device(struct soc_camera_device *icd) { - struct soc_camera_host *ici = to_soc_camera_host(icd->parent); + dev_dbg(icd->parent, "Atmel ISI Camera driver attached to camera %d\n", + icd->devnum); + + return 0; +} + +static void isi_camera_remove_device(struct soc_camera_device *icd) +{ + dev_dbg(icd->parent, "Atmel ISI Camera driver detached from camera %d\n", + icd->devnum); +} + +/* Called with .host_lock held */ +static int isi_camera_clock_start(struct soc_camera_host *ici) +{ struct atmel_isi *isi = ici->priv; int ret; @@ -762,21 +775,16 @@ static int isi_camera_add_device(struct soc_camera_device *icd) return ret; } - dev_dbg(icd->parent, "Atmel ISI Camera driver attached to camera %d\n", - icd->devnum); return 0; } + /* Called with .host_lock held */ -static void isi_camera_remove_device(struct soc_camera_device *icd) +static void isi_camera_clock_stop(struct soc_camera_host *ici) { - struct soc_camera_host *ici = to_soc_camera_host(icd->parent); struct atmel_isi *isi = ici->priv; clk_disable(isi->mck); clk_disable(isi->pclk); - - dev_dbg(icd->parent, "Atmel ISI Camera driver detached from camera %d\n", - icd->devnum); } static unsigned int isi_camera_poll(struct file *file, poll_table *pt) @@ -880,6 +888,8 @@ static struct soc_camera_host_ops isi_soc_camera_host_ops = { .owner = THIS_MODULE, .add = isi_camera_add_device, .remove = isi_camera_remove_device, + .clock_start = isi_camera_clock_start, + .clock_stop = isi_camera_clock_stop, .set_fmt = isi_camera_set_fmt, .try_fmt = isi_camera_try_fmt, .get_formats = isi_camera_get_formats, From 663ccaf4cd61f510e8a8e9bb913d2ee9b1e94932 Mon Sep 17 00:00:00 2001 From: Guennadi Liakhovetski Date: Thu, 4 Apr 2013 11:24:43 -0300 Subject: [PATCH 0453/1048] [media] mx3-camera: move interface activation and deactivation to clock callbacks When adding and removing a client, the mx3-camera driver only activates and deactivates its camera interface respectively, which doesn't include any client-specific actions. Move this functionality into .clock_start() and .clock_stop() callbacks. Signed-off-by: Guennadi Liakhovetski Acked-by: Hans Verkuil Acked-by: Laurent Pinchart Signed-off-by: Mauro Carvalho Chehab --- .../media/platform/soc_camera/mx3_camera.c | 39 +++++++++++-------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/drivers/media/platform/soc_camera/mx3_camera.c b/drivers/media/platform/soc_camera/mx3_camera.c index 71b9b191957c..1047e3e8db77 100644 --- a/drivers/media/platform/soc_camera/mx3_camera.c +++ b/drivers/media/platform/soc_camera/mx3_camera.c @@ -460,8 +460,7 @@ static int mx3_camera_init_videobuf(struct vb2_queue *q, } /* First part of ipu_csi_init_interface() */ -static void mx3_camera_activate(struct mx3_camera_dev *mx3_cam, - struct soc_camera_device *icd) +static void mx3_camera_activate(struct mx3_camera_dev *mx3_cam) { u32 conf; long rate; @@ -505,31 +504,40 @@ static void mx3_camera_activate(struct mx3_camera_dev *mx3_cam, clk_prepare_enable(mx3_cam->clk); rate = clk_round_rate(mx3_cam->clk, mx3_cam->mclk); - dev_dbg(icd->parent, "Set SENS_CONF to %x, rate %ld\n", conf, rate); + dev_dbg(mx3_cam->soc_host.v4l2_dev.dev, "Set SENS_CONF to %x, rate %ld\n", conf, rate); if (rate) clk_set_rate(mx3_cam->clk, rate); } -/* Called with .host_lock held */ static int mx3_camera_add_device(struct soc_camera_device *icd) { - struct soc_camera_host *ici = to_soc_camera_host(icd->parent); - struct mx3_camera_dev *mx3_cam = ici->priv; - - mx3_camera_activate(mx3_cam, icd); - - mx3_cam->buf_total = 0; - dev_info(icd->parent, "MX3 Camera driver attached to camera %d\n", icd->devnum); return 0; } -/* Called with .host_lock held */ static void mx3_camera_remove_device(struct soc_camera_device *icd) { - struct soc_camera_host *ici = to_soc_camera_host(icd->parent); + dev_info(icd->parent, "MX3 Camera driver detached from camera %d\n", + icd->devnum); +} + +/* Called with .host_lock held */ +static int mx3_camera_clock_start(struct soc_camera_host *ici) +{ + struct mx3_camera_dev *mx3_cam = ici->priv; + + mx3_camera_activate(mx3_cam); + + mx3_cam->buf_total = 0; + + return 0; +} + +/* Called with .host_lock held */ +static void mx3_camera_clock_stop(struct soc_camera_host *ici) +{ struct mx3_camera_dev *mx3_cam = ici->priv; struct idmac_channel **ichan = &mx3_cam->idmac_channel[0]; @@ -539,9 +547,6 @@ static void mx3_camera_remove_device(struct soc_camera_device *icd) } clk_disable_unprepare(mx3_cam->clk); - - dev_info(icd->parent, "MX3 Camera driver detached from camera %d\n", - icd->devnum); } static int test_platform_param(struct mx3_camera_dev *mx3_cam, @@ -1124,6 +1129,8 @@ static struct soc_camera_host_ops mx3_soc_camera_host_ops = { .owner = THIS_MODULE, .add = mx3_camera_add_device, .remove = mx3_camera_remove_device, + .clock_start = mx3_camera_clock_start, + .clock_stop = mx3_camera_clock_stop, .set_crop = mx3_camera_set_crop, .set_fmt = mx3_camera_set_fmt, .try_fmt = mx3_camera_try_fmt, From 6b417c897000515e308ff45687319f8ede1ccdd2 Mon Sep 17 00:00:00 2001 From: Guennadi Liakhovetski Date: Thu, 4 Apr 2013 11:49:13 -0300 Subject: [PATCH 0454/1048] [media] mx2-camera: move interface activation and deactivation to clock callbacks When adding and removing a client, the mx2-camera driver only activates and deactivates its camera interface respectively, which doesn't include any client-specific actions. Move this functionality into .clock_start() and .clock_stop() callbacks. Signed-off-by: Guennadi Liakhovetski Acked-by: Hans Verkuil Acked-by: Laurent Pinchart Signed-off-by: Mauro Carvalho Chehab --- .../media/platform/soc_camera/mx2_camera.c | 28 ++++++++++++------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/drivers/media/platform/soc_camera/mx2_camera.c b/drivers/media/platform/soc_camera/mx2_camera.c index 772e0710f59b..45a0276be4e5 100644 --- a/drivers/media/platform/soc_camera/mx2_camera.c +++ b/drivers/media/platform/soc_camera/mx2_camera.c @@ -412,13 +412,26 @@ static void mx2_camera_deactivate(struct mx2_camera_dev *pcdev) writel(0, pcdev->base_emma + PRP_CNTL); } +static int mx2_camera_add_device(struct soc_camera_device *icd) +{ + dev_info(icd->parent, "Camera driver attached to camera %d\n", + icd->devnum); + + return 0; +} + +static void mx2_camera_remove_device(struct soc_camera_device *icd) +{ + dev_info(icd->parent, "Camera driver detached from camera %d\n", + icd->devnum); +} + /* * The following two functions absolutely depend on the fact, that * there can be only one camera on mx2 camera sensor interface */ -static int mx2_camera_add_device(struct soc_camera_device *icd) +static int mx2_camera_clock_start(struct soc_camera_host *ici) { - struct soc_camera_host *ici = to_soc_camera_host(icd->parent); struct mx2_camera_dev *pcdev = ici->priv; int ret; u32 csicr1; @@ -439,9 +452,6 @@ static int mx2_camera_add_device(struct soc_camera_device *icd) pcdev->frame_count = 0; - dev_info(icd->parent, "Camera driver attached to camera %d\n", - icd->devnum); - return 0; exit_csi_ahb: @@ -450,14 +460,10 @@ exit_csi_ahb: return ret; } -static void mx2_camera_remove_device(struct soc_camera_device *icd) +static void mx2_camera_clock_stop(struct soc_camera_host *ici) { - struct soc_camera_host *ici = to_soc_camera_host(icd->parent); struct mx2_camera_dev *pcdev = ici->priv; - dev_info(icd->parent, "Camera driver detached from camera %d\n", - icd->devnum); - mx2_camera_deactivate(pcdev); } @@ -1271,6 +1277,8 @@ static struct soc_camera_host_ops mx2_soc_camera_host_ops = { .owner = THIS_MODULE, .add = mx2_camera_add_device, .remove = mx2_camera_remove_device, + .clock_start = mx2_camera_clock_start, + .clock_stop = mx2_camera_clock_stop, .set_fmt = mx2_camera_set_fmt, .set_crop = mx2_camera_set_crop, .get_formats = mx2_camera_get_formats, From d71042c1fa1c3b32bfd55151eef6b2e104301a11 Mon Sep 17 00:00:00 2001 From: Guennadi Liakhovetski Date: Thu, 4 Apr 2013 12:06:32 -0300 Subject: [PATCH 0455/1048] [media] mx1-camera: move interface activation and deactivation to clock callbacks When adding and removing a client, the mx1-camera driver only activates and deactivates its camera interface respectively, which doesn't include any client-specific actions. Move this functionality into .clock_start() and .clock_stop() callbacks. Signed-off-by: Guennadi Liakhovetski Acked-by: Hans Verkuil Acked-by: Laurent Pinchart Signed-off-by: Mauro Carvalho Chehab --- .../media/platform/soc_camera/mx1_camera.c | 38 +++++++++++-------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/drivers/media/platform/soc_camera/mx1_camera.c b/drivers/media/platform/soc_camera/mx1_camera.c index 5f9ec8efd978..fea3e61476ae 100644 --- a/drivers/media/platform/soc_camera/mx1_camera.c +++ b/drivers/media/platform/soc_camera/mx1_camera.c @@ -399,7 +399,7 @@ static void mx1_camera_activate(struct mx1_camera_dev *pcdev) { unsigned int csicr1 = CSICR1_EN; - dev_dbg(pcdev->soc_host.icd->parent, "Activate device\n"); + dev_dbg(pcdev->soc_host.v4l2_dev.dev, "Activate device\n"); clk_prepare_enable(pcdev->clk); @@ -415,7 +415,7 @@ static void mx1_camera_activate(struct mx1_camera_dev *pcdev) static void mx1_camera_deactivate(struct mx1_camera_dev *pcdev) { - dev_dbg(pcdev->soc_host.icd->parent, "Deactivate device\n"); + dev_dbg(pcdev->soc_host.v4l2_dev.dev, "Deactivate device\n"); /* Disable all CSI interface */ __raw_writel(0x00, pcdev->base + CSICR1); @@ -423,26 +423,35 @@ static void mx1_camera_deactivate(struct mx1_camera_dev *pcdev) clk_disable_unprepare(pcdev->clk); } -/* - * The following two functions absolutely depend on the fact, that - * there can be only one camera on i.MX1/i.MXL camera sensor interface - */ static int mx1_camera_add_device(struct soc_camera_device *icd) { - struct soc_camera_host *ici = to_soc_camera_host(icd->parent); - struct mx1_camera_dev *pcdev = ici->priv; - dev_info(icd->parent, "MX1 Camera driver attached to camera %d\n", icd->devnum); - mx1_camera_activate(pcdev); - return 0; } static void mx1_camera_remove_device(struct soc_camera_device *icd) { - struct soc_camera_host *ici = to_soc_camera_host(icd->parent); + dev_info(icd->parent, "MX1 Camera driver detached from camera %d\n", + icd->devnum); +} + +/* + * The following two functions absolutely depend on the fact, that + * there can be only one camera on i.MX1/i.MXL camera sensor interface + */ +static int mx1_camera_clock_start(struct soc_camera_host *ici) +{ + struct mx1_camera_dev *pcdev = ici->priv; + + mx1_camera_activate(pcdev); + + return 0; +} + +static void mx1_camera_clock_stop(struct soc_camera_host *ici) +{ struct mx1_camera_dev *pcdev = ici->priv; unsigned int csicr1; @@ -453,9 +462,6 @@ static void mx1_camera_remove_device(struct soc_camera_device *icd) /* Stop DMA engine */ imx_dma_disable(pcdev->dma_chan); - dev_info(icd->parent, "MX1 Camera driver detached from camera %d\n", - icd->devnum); - mx1_camera_deactivate(pcdev); } @@ -669,6 +675,8 @@ static struct soc_camera_host_ops mx1_soc_camera_host_ops = { .owner = THIS_MODULE, .add = mx1_camera_add_device, .remove = mx1_camera_remove_device, + .clock_start = mx1_camera_clock_start, + .clock_stop = mx1_camera_clock_stop, .set_bus_param = mx1_camera_set_bus_param, .set_fmt = mx1_camera_set_fmt, .try_fmt = mx1_camera_try_fmt, From 0ff6a6e8fb6915e68b93ff169b1eb66c0ba15d56 Mon Sep 17 00:00:00 2001 From: Guennadi Liakhovetski Date: Thu, 4 Apr 2013 12:54:20 -0300 Subject: [PATCH 0456/1048] [media] sh-mobile-ceu-camera: move interface activation and deactivation to clock callbacks When adding and removing a client, the sh-mobile-ceu-camera driver activates and, respectively, deactivates its camera interface and, if necessary, the CSI2 controller. Only handling of the CSI2 interface is client-specific and is only needed, when a data-exchange with the client is taking place. Move the rest to .clock_start() and .clock_stop() callbacks. Signed-off-by: Guennadi Liakhovetski Acked-by: Hans Verkuil Acked-by: Laurent Pinchart Signed-off-by: Mauro Carvalho Chehab --- .../soc_camera/sh_mobile_ceu_camera.c | 58 +++++++++++-------- 1 file changed, 35 insertions(+), 23 deletions(-) diff --git a/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c b/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c index 5b7d8e1dd448..9037472e9ced 100644 --- a/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c +++ b/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c @@ -162,7 +162,6 @@ static u32 ceu_read(struct sh_mobile_ceu_dev *priv, unsigned long reg_offs) static int sh_mobile_ceu_soft_reset(struct sh_mobile_ceu_dev *pcdev) { int i, success = 0; - struct soc_camera_device *icd = pcdev->ici.icd; ceu_write(pcdev, CAPSR, 1 << 16); /* reset */ @@ -186,7 +185,7 @@ static int sh_mobile_ceu_soft_reset(struct sh_mobile_ceu_dev *pcdev) if (2 != success) { - dev_warn(icd->pdev, "soft reset time out\n"); + dev_warn(pcdev->ici.v4l2_dev.dev, "soft reset time out\n"); return -EIO; } @@ -543,35 +542,21 @@ static struct v4l2_subdev *find_csi2(struct sh_mobile_ceu_dev *pcdev) return NULL; } -/* Called with .host_lock held */ static int sh_mobile_ceu_add_device(struct soc_camera_device *icd) { struct soc_camera_host *ici = to_soc_camera_host(icd->parent); struct sh_mobile_ceu_dev *pcdev = ici->priv; - struct v4l2_subdev *csi2_sd; + struct v4l2_subdev *csi2_sd = find_csi2(pcdev); int ret; - dev_info(icd->parent, - "SuperH Mobile CEU driver attached to camera %d\n", - icd->devnum); - - pm_runtime_get_sync(ici->v4l2_dev.dev); - - pcdev->buf_total = 0; - - ret = sh_mobile_ceu_soft_reset(pcdev); - - csi2_sd = find_csi2(pcdev); if (csi2_sd) { csi2_sd->grp_id = soc_camera_grp_id(icd); v4l2_set_subdev_hostdata(csi2_sd, icd); } ret = v4l2_subdev_call(csi2_sd, core, s_power, 1); - if (ret < 0 && ret != -ENOIOCTLCMD && ret != -ENODEV) { - pm_runtime_put(ici->v4l2_dev.dev); + if (ret < 0 && ret != -ENOIOCTLCMD && ret != -ENODEV) return ret; - } /* * -ENODEV is special: either csi2_sd == NULL or the CSI-2 driver @@ -580,19 +565,48 @@ static int sh_mobile_ceu_add_device(struct soc_camera_device *icd) if (ret == -ENODEV && csi2_sd) csi2_sd->grp_id = 0; + dev_info(icd->parent, + "SuperH Mobile CEU driver attached to camera %d\n", + icd->devnum); + return 0; } -/* Called with .host_lock held */ static void sh_mobile_ceu_remove_device(struct soc_camera_device *icd) { struct soc_camera_host *ici = to_soc_camera_host(icd->parent); struct sh_mobile_ceu_dev *pcdev = ici->priv; struct v4l2_subdev *csi2_sd = find_csi2(pcdev); + dev_info(icd->parent, + "SuperH Mobile CEU driver detached from camera %d\n", + icd->devnum); + v4l2_subdev_call(csi2_sd, core, s_power, 0); if (csi2_sd) csi2_sd->grp_id = 0; +} + +/* Called with .host_lock held */ +static int sh_mobile_ceu_clock_start(struct soc_camera_host *ici) +{ + struct sh_mobile_ceu_dev *pcdev = ici->priv; + int ret; + + pm_runtime_get_sync(ici->v4l2_dev.dev); + + pcdev->buf_total = 0; + + ret = sh_mobile_ceu_soft_reset(pcdev); + + return 0; +} + +/* Called with .host_lock held */ +static void sh_mobile_ceu_clock_stop(struct soc_camera_host *ici) +{ + struct sh_mobile_ceu_dev *pcdev = ici->priv; + /* disable capture, disable interrupts */ ceu_write(pcdev, CEIER, 0); sh_mobile_ceu_soft_reset(pcdev); @@ -607,10 +621,6 @@ static void sh_mobile_ceu_remove_device(struct soc_camera_device *icd) spin_unlock_irq(&pcdev->lock); pm_runtime_put(ici->v4l2_dev.dev); - - dev_info(icd->parent, - "SuperH Mobile CEU driver detached from camera %d\n", - icd->devnum); } /* @@ -2027,6 +2037,8 @@ static struct soc_camera_host_ops sh_mobile_ceu_host_ops = { .owner = THIS_MODULE, .add = sh_mobile_ceu_add_device, .remove = sh_mobile_ceu_remove_device, + .clock_start = sh_mobile_ceu_clock_start, + .clock_stop = sh_mobile_ceu_clock_stop, .get_formats = sh_mobile_ceu_get_formats, .put_formats = sh_mobile_ceu_put_formats, .get_crop = sh_mobile_ceu_get_crop, From a78fcc11264b824d9651b55abfeedd16d5cd8415 Mon Sep 17 00:00:00 2001 From: Guennadi Liakhovetski Date: Thu, 4 Apr 2013 13:19:58 -0300 Subject: [PATCH 0457/1048] [media] soc-camera: make .clock_{start,stop} compulsory, .add / .remove optional All existing soc-camera host drivers use .clock_start() and .clock_stop() callbacks to activate and deactivate their camera interfaces, whereas .add() and .remove() callbacks are usually dummy. Make the former two compulsory and the latter two optional. Signed-off-by: Guennadi Liakhovetski Acked-by: Hans Verkuil Acked-by: Laurent Pinchart Signed-off-by: Mauro Carvalho Chehab --- .../media/platform/soc_camera/soc_camera.c | 29 +++++++++---------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/drivers/media/platform/soc_camera/soc_camera.c b/drivers/media/platform/soc_camera/soc_camera.c index 3cc086036070..24393a14aaf6 100644 --- a/drivers/media/platform/soc_camera/soc_camera.c +++ b/drivers/media/platform/soc_camera/soc_camera.c @@ -512,23 +512,22 @@ static int soc_camera_add_device(struct soc_camera_device *icd) if (ici->icd) return -EBUSY; - if (ici->ops->clock_start) { - ret = ici->ops->clock_start(ici); - if (ret < 0) - return ret; - } - - ret = ici->ops->add(icd); + ret = ici->ops->clock_start(ici); if (ret < 0) - goto eadd; + return ret; + + if (ici->ops->add) { + ret = ici->ops->add(icd); + if (ret < 0) + goto eadd; + } ici->icd = icd; return 0; eadd: - if (ici->ops->clock_stop) - ici->ops->clock_stop(ici); + ici->ops->clock_stop(ici); return ret; } @@ -539,9 +538,9 @@ static void soc_camera_remove_device(struct soc_camera_device *icd) if (WARN_ON(icd != ici->icd)) return; - ici->ops->remove(icd); - if (ici->ops->clock_stop) - ici->ops->clock_stop(ici); + if (ici->ops->remove) + ici->ops->remove(icd); + ici->ops->clock_stop(ici); ici->icd = NULL; } @@ -1383,8 +1382,8 @@ int soc_camera_host_register(struct soc_camera_host *ici) ((!ici->ops->init_videobuf || !ici->ops->reqbufs) && !ici->ops->init_videobuf2) || - !ici->ops->add || - !ici->ops->remove || + !ici->ops->clock_start || + !ici->ops->clock_stop || !ici->ops->poll || !ici->v4l2_dev.dev) return -EINVAL; From 90438926e807bca4f80237f436bc7d904151fc2b Mon Sep 17 00:00:00 2001 From: Guennadi Liakhovetski Date: Thu, 4 Apr 2013 14:21:54 -0300 Subject: [PATCH 0458/1048] [media] soc-camera: don't attach the client to the host during probing During client probing we only have to turn on the host's clock, no need to actually attach the client to the host. Signed-off-by: Guennadi Liakhovetski Acked-by: Hans Verkuil Acked-by: Laurent Pinchart Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/soc_camera/soc_camera.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/media/platform/soc_camera/soc_camera.c b/drivers/media/platform/soc_camera/soc_camera.c index 24393a14aaf6..fa8a728b7a5d 100644 --- a/drivers/media/platform/soc_camera/soc_camera.c +++ b/drivers/media/platform/soc_camera/soc_camera.c @@ -1177,7 +1177,7 @@ static int soc_camera_probe(struct soc_camera_device *icd) ssdd->reset(icd->pdev); mutex_lock(&ici->host_lock); - ret = soc_camera_add_device(icd); + ret = ici->ops->clock_start(ici); mutex_unlock(&ici->host_lock); if (ret < 0) goto eadd; @@ -1250,7 +1250,7 @@ static int soc_camera_probe(struct soc_camera_device *icd) icd->field = mf.field; } - soc_camera_remove_device(icd); + ici->ops->clock_stop(ici); mutex_unlock(&ici->host_lock); @@ -1273,7 +1273,7 @@ eadddev: icd->vdev = NULL; evdc: mutex_lock(&ici->host_lock); - soc_camera_remove_device(icd); + ici->ops->clock_stop(ici); mutex_unlock(&ici->host_lock); eadd: v4l2_ctrl_handler_free(&icd->ctrl_handler); From f146e4e79a6f5d457553dfe2ac66b93c7a39f676 Mon Sep 17 00:00:00 2001 From: Guennadi Liakhovetski Date: Mon, 17 Sep 2012 07:42:55 -0300 Subject: [PATCH 0459/1048] [media] sh-mobile-ceu-camera: add primitive OF support Add an OF hook to sh_mobile_ceu_camera.c, no properties so far. Booting with DT also requires platform data to be optional. Signed-off-by: Guennadi Liakhovetski Acked-by: Hans Verkuil Acked-by: Laurent Pinchart Signed-off-by: Mauro Carvalho Chehab --- .../soc_camera/sh_mobile_ceu_camera.c | 33 +++++++++++++------ 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c b/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c index 9037472e9ced..fcc13d8eb070 100644 --- a/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c +++ b/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -118,6 +119,7 @@ struct sh_mobile_ceu_dev { enum v4l2_field field; int sequence; + unsigned long flags; unsigned int image_mode:1; unsigned int is_16bit:1; @@ -706,7 +708,7 @@ static void sh_mobile_ceu_set_rect(struct soc_camera_device *icd) } /* CSI2 special configuration */ - if (pcdev->pdata->csi2) { + if (pcdev->csi2_pdev) { in_width = ((in_width - 2) * 2); left_offset *= 2; } @@ -810,7 +812,7 @@ static int sh_mobile_ceu_set_bus_param(struct soc_camera_device *icd) /* Make choises, based on platform preferences */ if ((common_flags & V4L2_MBUS_HSYNC_ACTIVE_HIGH) && (common_flags & V4L2_MBUS_HSYNC_ACTIVE_LOW)) { - if (pcdev->pdata->flags & SH_CEU_FLAG_HSYNC_LOW) + if (pcdev->flags & SH_CEU_FLAG_HSYNC_LOW) common_flags &= ~V4L2_MBUS_HSYNC_ACTIVE_HIGH; else common_flags &= ~V4L2_MBUS_HSYNC_ACTIVE_LOW; @@ -818,7 +820,7 @@ static int sh_mobile_ceu_set_bus_param(struct soc_camera_device *icd) if ((common_flags & V4L2_MBUS_VSYNC_ACTIVE_HIGH) && (common_flags & V4L2_MBUS_VSYNC_ACTIVE_LOW)) { - if (pcdev->pdata->flags & SH_CEU_FLAG_VSYNC_LOW) + if (pcdev->flags & SH_CEU_FLAG_VSYNC_LOW) common_flags &= ~V4L2_MBUS_VSYNC_ACTIVE_HIGH; else common_flags &= ~V4L2_MBUS_VSYNC_ACTIVE_LOW; @@ -873,11 +875,11 @@ static int sh_mobile_ceu_set_bus_param(struct soc_camera_device *icd) value |= common_flags & V4L2_MBUS_VSYNC_ACTIVE_LOW ? 1 << 1 : 0; value |= common_flags & V4L2_MBUS_HSYNC_ACTIVE_LOW ? 1 << 0 : 0; - if (pcdev->pdata->csi2) /* CSI2 mode */ + if (pcdev->csi2_pdev) /* CSI2 mode */ value |= 3 << 12; else if (pcdev->is_16bit) value |= 1 << 12; - else if (pcdev->pdata->flags & SH_CEU_FLAG_LOWER_8BIT) + else if (pcdev->flags & SH_CEU_FLAG_LOWER_8BIT) value |= 2 << 12; ceu_write(pcdev, CAMCR, value); @@ -1052,7 +1054,7 @@ static int sh_mobile_ceu_get_formats(struct soc_camera_device *icd, unsigned int return 0; } - if (!pcdev->pdata->csi2) { + if (!pcdev->pdata || !pcdev->pdata->csi2) { /* Are there any restrictions in the CSI-2 case? */ ret = sh_mobile_ceu_try_bus_param(icd, fmt->bits_per_sample); if (ret < 0) @@ -2107,13 +2109,17 @@ static int sh_mobile_ceu_probe(struct platform_device *pdev) init_completion(&pcdev->complete); pcdev->pdata = pdev->dev.platform_data; - if (!pcdev->pdata) { + if (!pcdev->pdata && !pdev->dev.of_node) { dev_err(&pdev->dev, "CEU platform data not set.\n"); return -EINVAL; } - pcdev->max_width = pcdev->pdata->max_width ? : 2560; - pcdev->max_height = pcdev->pdata->max_height ? : 1920; + /* TODO: implement per-device bus flags */ + if (pcdev->pdata) { + pcdev->max_width = pcdev->pdata->max_width ? : 2560; + pcdev->max_height = pcdev->pdata->max_height ? : 1920; + pcdev->flags = pcdev->pdata->flags; + } base = devm_ioremap_resource(&pdev->dev, res); if (IS_ERR(base)) @@ -2168,7 +2174,7 @@ static int sh_mobile_ceu_probe(struct platform_device *pdev) goto exit_free_ctx; /* CSI2 interfacing */ - csi2 = pcdev->pdata->csi2; + csi2 = pcdev->pdata ? pcdev->pdata->csi2 : NULL; if (csi2) { struct platform_device *csi2_pdev = platform_device_alloc("sh-mobile-csi2", csi2->id); @@ -2290,10 +2296,17 @@ static const struct dev_pm_ops sh_mobile_ceu_dev_pm_ops = { .runtime_resume = sh_mobile_ceu_runtime_nop, }; +static const struct of_device_id sh_mobile_ceu_of_match[] = { + { .compatible = "renesas,sh-mobile-ceu" }, + { } +}; +MODULE_DEVICE_TABLE(of, sh_mobile_ceu_of_match); + static struct platform_driver sh_mobile_ceu_driver = { .driver = { .name = "sh_mobile_ceu", .pm = &sh_mobile_ceu_dev_pm_ops, + .of_match_table = sh_mobile_ceu_of_match, }, .probe = sh_mobile_ceu_probe, .remove = sh_mobile_ceu_remove, From 812e8b22ea55218449de310a666dd1ce16f924ed Mon Sep 17 00:00:00 2001 From: Guennadi Liakhovetski Date: Mon, 17 Sep 2012 07:48:33 -0300 Subject: [PATCH 0460/1048] [media] sh-mobile-ceu-driver: support max width and height in DT Some CEU implementations have non-standard (larger) maximum supported width and height values. Add two OF properties to specify them. Signed-off-by: Guennadi Liakhovetski Acked-by: Hans Verkuil Acked-by: Laurent Pinchart Signed-off-by: Mauro Carvalho Chehab --- .../bindings/media/sh_mobile_ceu.txt | 18 +++++++++++++++ .../soc_camera/sh_mobile_ceu_camera.c | 23 +++++++++++++++++-- 2 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 Documentation/devicetree/bindings/media/sh_mobile_ceu.txt diff --git a/Documentation/devicetree/bindings/media/sh_mobile_ceu.txt b/Documentation/devicetree/bindings/media/sh_mobile_ceu.txt new file mode 100644 index 000000000000..1ce4e46bcbb7 --- /dev/null +++ b/Documentation/devicetree/bindings/media/sh_mobile_ceu.txt @@ -0,0 +1,18 @@ +Bindings, specific for the sh_mobile_ceu_camera.c driver: + - compatible: Should be "renesas,sh-mobile-ceu" + - reg: register base and size + - interrupts: the interrupt number + - interrupt-parent: the interrupt controller + - renesas,max-width: maximum image width, supported on this SoC + - renesas,max-height: maximum image height, supported on this SoC + +Example: + +ceu0: ceu@0xfe910000 { + compatible = "renesas,sh-mobile-ceu"; + reg = <0xfe910000 0xa0>; + interrupt-parent = <&intcs>; + interrupts = <0x880>; + renesas,max-width = <8188>; + renesas,max-height = <8188>; +}; diff --git a/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c b/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c index fcc13d8eb070..b0f0995fc80b 100644 --- a/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c +++ b/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c @@ -2116,11 +2116,30 @@ static int sh_mobile_ceu_probe(struct platform_device *pdev) /* TODO: implement per-device bus flags */ if (pcdev->pdata) { - pcdev->max_width = pcdev->pdata->max_width ? : 2560; - pcdev->max_height = pcdev->pdata->max_height ? : 1920; + pcdev->max_width = pcdev->pdata->max_width; + pcdev->max_height = pcdev->pdata->max_height; pcdev->flags = pcdev->pdata->flags; } + if (!pcdev->max_width) { + unsigned int v; + err = of_property_read_u32(pdev->dev.of_node, "renesas,max-width", &v); + if (!err) + pcdev->max_width = v; + + if (!pcdev->max_width) + pcdev->max_width = 2560; + } + if (!pcdev->max_height) { + unsigned int v; + err = of_property_read_u32(pdev->dev.of_node, "renesas,max-height", &v); + if (!err) + pcdev->max_height = v; + + if (!pcdev->max_height) + pcdev->max_height = 1920; + } + base = devm_ioremap_resource(&pdev->dev, res); if (IS_ERR(base)) return PTR_ERR(base); From ff5430de70e8137daccecfa1211509f95fcc8d25 Mon Sep 17 00:00:00 2001 From: Guennadi Liakhovetski Date: Tue, 4 Dec 2012 07:42:15 -0300 Subject: [PATCH 0461/1048] [media] V4L2: add temporary clock helpers Typical video devices like camera sensors require an external clock source. Many such devices cannot even access their hardware registers without a running clock. These clock sources should be controlled by their consumers. This should be performed, using the generic clock framework. Unfortunately so far only very few systems have been ported to that framework. This patch adds a set of temporary helpers, mimicking the generic clock API, to V4L2. Platforms, adopting the clock API, should switch to using it. Eventually this temporary API should be removed. Signed-off-by: Guennadi Liakhovetski Acked-by: Hans Verkuil Acked-by: Laurent Pinchart Signed-off-by: Mauro Carvalho Chehab --- drivers/media/v4l2-core/Makefile | 2 +- drivers/media/v4l2-core/v4l2-clk.c | 242 +++++++++++++++++++++++++++++ include/media/v4l2-clk.h | 54 +++++++ 3 files changed, 297 insertions(+), 1 deletion(-) create mode 100644 drivers/media/v4l2-core/v4l2-clk.c create mode 100644 include/media/v4l2-clk.h diff --git a/drivers/media/v4l2-core/Makefile b/drivers/media/v4l2-core/Makefile index aa50c46314b7..628c6307e978 100644 --- a/drivers/media/v4l2-core/Makefile +++ b/drivers/media/v4l2-core/Makefile @@ -5,7 +5,7 @@ tuner-objs := tuner-core.o videodev-objs := v4l2-dev.o v4l2-ioctl.o v4l2-device.o v4l2-fh.o \ - v4l2-event.o v4l2-ctrls.o v4l2-subdev.o + v4l2-event.o v4l2-ctrls.o v4l2-subdev.o v4l2-clk.o ifeq ($(CONFIG_COMPAT),y) videodev-objs += v4l2-compat-ioctl32.o endif diff --git a/drivers/media/v4l2-core/v4l2-clk.c b/drivers/media/v4l2-core/v4l2-clk.c new file mode 100644 index 000000000000..b67de8642b5a --- /dev/null +++ b/drivers/media/v4l2-core/v4l2-clk.c @@ -0,0 +1,242 @@ +/* + * V4L2 clock service + * + * Copyright (C) 2012-2013, Guennadi Liakhovetski + * + * 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. + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +static DEFINE_MUTEX(clk_lock); +static LIST_HEAD(clk_list); + +static struct v4l2_clk *v4l2_clk_find(const char *dev_id, const char *id) +{ + struct v4l2_clk *clk; + + list_for_each_entry(clk, &clk_list, list) { + if (strcmp(dev_id, clk->dev_id)) + continue; + + if (!id || !clk->id || !strcmp(clk->id, id)) + return clk; + } + + return ERR_PTR(-ENODEV); +} + +struct v4l2_clk *v4l2_clk_get(struct device *dev, const char *id) +{ + struct v4l2_clk *clk; + + mutex_lock(&clk_lock); + clk = v4l2_clk_find(dev_name(dev), id); + + if (!IS_ERR(clk)) + atomic_inc(&clk->use_count); + mutex_unlock(&clk_lock); + + return clk; +} +EXPORT_SYMBOL(v4l2_clk_get); + +void v4l2_clk_put(struct v4l2_clk *clk) +{ + struct v4l2_clk *tmp; + + if (IS_ERR(clk)) + return; + + mutex_lock(&clk_lock); + + list_for_each_entry(tmp, &clk_list, list) + if (tmp == clk) + atomic_dec(&clk->use_count); + + mutex_unlock(&clk_lock); +} +EXPORT_SYMBOL(v4l2_clk_put); + +static int v4l2_clk_lock_driver(struct v4l2_clk *clk) +{ + struct v4l2_clk *tmp; + int ret = -ENODEV; + + mutex_lock(&clk_lock); + + list_for_each_entry(tmp, &clk_list, list) + if (tmp == clk) { + ret = !try_module_get(clk->ops->owner); + if (ret) + ret = -EFAULT; + break; + } + + mutex_unlock(&clk_lock); + + return ret; +} + +static void v4l2_clk_unlock_driver(struct v4l2_clk *clk) +{ + module_put(clk->ops->owner); +} + +int v4l2_clk_enable(struct v4l2_clk *clk) +{ + int ret = v4l2_clk_lock_driver(clk); + + if (ret < 0) + return ret; + + mutex_lock(&clk->lock); + + if (++clk->enable == 1 && clk->ops->enable) { + ret = clk->ops->enable(clk); + if (ret < 0) + clk->enable--; + } + + mutex_unlock(&clk->lock); + + return ret; +} +EXPORT_SYMBOL(v4l2_clk_enable); + +/* + * You might Oops if you try to disabled a disabled clock, because then the + * driver isn't locked and could have been unloaded by now, so, don't do that + */ +void v4l2_clk_disable(struct v4l2_clk *clk) +{ + int enable; + + mutex_lock(&clk->lock); + + enable = --clk->enable; + if (WARN(enable < 0, "Unbalanced %s() on %s:%s!\n", __func__, + clk->dev_id, clk->id)) + clk->enable++; + else if (!enable && clk->ops->disable) + clk->ops->disable(clk); + + mutex_unlock(&clk->lock); + + v4l2_clk_unlock_driver(clk); +} +EXPORT_SYMBOL(v4l2_clk_disable); + +unsigned long v4l2_clk_get_rate(struct v4l2_clk *clk) +{ + int ret = v4l2_clk_lock_driver(clk); + + if (ret < 0) + return ret; + + mutex_lock(&clk->lock); + if (!clk->ops->get_rate) + ret = -ENOSYS; + else + ret = clk->ops->get_rate(clk); + mutex_unlock(&clk->lock); + + v4l2_clk_unlock_driver(clk); + + return ret; +} +EXPORT_SYMBOL(v4l2_clk_get_rate); + +int v4l2_clk_set_rate(struct v4l2_clk *clk, unsigned long rate) +{ + int ret = v4l2_clk_lock_driver(clk); + + if (ret < 0) + return ret; + + mutex_lock(&clk->lock); + if (!clk->ops->set_rate) + ret = -ENOSYS; + else + ret = clk->ops->set_rate(clk, rate); + mutex_unlock(&clk->lock); + + v4l2_clk_unlock_driver(clk); + + return ret; +} +EXPORT_SYMBOL(v4l2_clk_set_rate); + +struct v4l2_clk *v4l2_clk_register(const struct v4l2_clk_ops *ops, + const char *dev_id, + const char *id, void *priv) +{ + struct v4l2_clk *clk; + int ret; + + if (!ops || !dev_id) + return ERR_PTR(-EINVAL); + + clk = kzalloc(sizeof(struct v4l2_clk), GFP_KERNEL); + if (!clk) + return ERR_PTR(-ENOMEM); + + clk->id = kstrdup(id, GFP_KERNEL); + clk->dev_id = kstrdup(dev_id, GFP_KERNEL); + if ((id && !clk->id) || !clk->dev_id) { + ret = -ENOMEM; + goto ealloc; + } + clk->ops = ops; + clk->priv = priv; + atomic_set(&clk->use_count, 0); + mutex_init(&clk->lock); + + mutex_lock(&clk_lock); + if (!IS_ERR(v4l2_clk_find(dev_id, id))) { + mutex_unlock(&clk_lock); + ret = -EEXIST; + goto eexist; + } + list_add_tail(&clk->list, &clk_list); + mutex_unlock(&clk_lock); + + return clk; + +eexist: +ealloc: + kfree(clk->id); + kfree(clk->dev_id); + kfree(clk); + return ERR_PTR(ret); +} +EXPORT_SYMBOL(v4l2_clk_register); + +void v4l2_clk_unregister(struct v4l2_clk *clk) +{ + if (WARN(atomic_read(&clk->use_count), + "%s(): Refusing to unregister ref-counted %s:%s clock!\n", + __func__, clk->dev_id, clk->id)) + return; + + mutex_lock(&clk_lock); + list_del(&clk->list); + mutex_unlock(&clk_lock); + + kfree(clk->id); + kfree(clk->dev_id); + kfree(clk); +} +EXPORT_SYMBOL(v4l2_clk_unregister); diff --git a/include/media/v4l2-clk.h b/include/media/v4l2-clk.h new file mode 100644 index 000000000000..0503a90b48bb --- /dev/null +++ b/include/media/v4l2-clk.h @@ -0,0 +1,54 @@ +/* + * V4L2 clock service + * + * Copyright (C) 2012-2013, Guennadi Liakhovetski + * + * 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. + * + * ATTENTION: This is a temporary API and it shall be replaced by the generic + * clock API, when the latter becomes widely available. + */ + +#ifndef MEDIA_V4L2_CLK_H +#define MEDIA_V4L2_CLK_H + +#include +#include +#include + +struct module; +struct device; + +struct v4l2_clk { + struct list_head list; + const struct v4l2_clk_ops *ops; + const char *dev_id; + const char *id; + int enable; + struct mutex lock; /* Protect the enable count */ + atomic_t use_count; + void *priv; +}; + +struct v4l2_clk_ops { + struct module *owner; + int (*enable)(struct v4l2_clk *clk); + void (*disable)(struct v4l2_clk *clk); + unsigned long (*get_rate)(struct v4l2_clk *clk); + int (*set_rate)(struct v4l2_clk *clk, unsigned long); +}; + +struct v4l2_clk *v4l2_clk_register(const struct v4l2_clk_ops *ops, + const char *dev_name, + const char *name, void *priv); +void v4l2_clk_unregister(struct v4l2_clk *clk); +struct v4l2_clk *v4l2_clk_get(struct device *dev, const char *id); +void v4l2_clk_put(struct v4l2_clk *clk); +int v4l2_clk_enable(struct v4l2_clk *clk); +void v4l2_clk_disable(struct v4l2_clk *clk); +unsigned long v4l2_clk_get_rate(struct v4l2_clk *clk); +int v4l2_clk_set_rate(struct v4l2_clk *clk, unsigned long rate); + +#endif From 668773b84604926519e2baf444f382f88d799d41 Mon Sep 17 00:00:00 2001 From: Guennadi Liakhovetski Date: Mon, 10 Jun 2013 15:07:35 -0300 Subject: [PATCH 0462/1048] [media] V4L2: add a device pointer to struct v4l2_subdev It is often useful to have simple means to get from a subdevice to the underlying physical device. This patch adds such a pointer to struct v4l2_subdev and sets it accordingly in the I2C and SPI cases. Signed-off-by: Guennadi Liakhovetski Acked-by: Hans Verkuil Acked-by: Laurent Pinchart Tested-by: Lad, Prabhakar Signed-off-by: Mauro Carvalho Chehab --- drivers/media/v4l2-core/v4l2-common.c | 2 ++ include/media/v4l2-subdev.h | 2 ++ 2 files changed, 4 insertions(+) diff --git a/drivers/media/v4l2-core/v4l2-common.c b/drivers/media/v4l2-core/v4l2-common.c index 3b2a7606bc84..a95e5e23403f 100644 --- a/drivers/media/v4l2-core/v4l2-common.c +++ b/drivers/media/v4l2-core/v4l2-common.c @@ -237,6 +237,7 @@ void v4l2_i2c_subdev_init(struct v4l2_subdev *sd, struct i2c_client *client, sd->flags |= V4L2_SUBDEV_FL_IS_I2C; /* the owner is the same as the i2c_client's driver owner */ sd->owner = client->driver->driver.owner; + sd->dev = &client->dev; /* i2c_client and v4l2_subdev point to one another */ v4l2_set_subdevdata(sd, client); i2c_set_clientdata(client, sd); @@ -370,6 +371,7 @@ void v4l2_spi_subdev_init(struct v4l2_subdev *sd, struct spi_device *spi, sd->flags |= V4L2_SUBDEV_FL_IS_SPI; /* the owner is the same as the spi_device's driver owner */ sd->owner = spi->dev.driver->owner; + sd->dev = &spi->dev; /* spi_device and v4l2_subdev point to one another */ v4l2_set_subdevdata(sd, spi); spi_set_drvdata(spi, sd); diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h index 21fc9e16d7be..5fbb266405f9 100644 --- a/include/media/v4l2-subdev.h +++ b/include/media/v4l2-subdev.h @@ -583,6 +583,8 @@ struct v4l2_subdev { void *host_priv; /* subdev device node */ struct video_device *devnode; + /* pointer to the physical device, if any */ + struct device *dev; }; #define media_entity_to_v4l2_subdev(ent) \ From e9e310491bdbc8c0f33ea0e2ce65eff345a01f71 Mon Sep 17 00:00:00 2001 From: Guennadi Liakhovetski Date: Tue, 8 Jan 2013 07:06:31 -0300 Subject: [PATCH 0463/1048] [media] V4L2: support asynchronous subdevice registration Currently bridge device drivers register devices for all subdevices synchronously, typically, during their probing. E.g. if an I2C CMOS sensor is attached to a video bridge device, the bridge driver will create an I2C device and wait for the respective I2C driver to probe. This makes linking of devices straight forward, but this approach cannot be used with intrinsically asynchronous and unordered device registration systems like the Flattened Device Tree. To support such systems this patch adds an asynchronous subdevice registration framework to V4L2. To use it respective (e.g. I2C) subdevice drivers must register themselves with the framework. A bridge driver on the other hand must register notification callbacks, that will be called upon various related events. Signed-off-by: Guennadi Liakhovetski Acked-by: Hans Verkuil Acked-by: Laurent Pinchart Tested-by: Lad, Prabhakar Signed-off-by: Mauro Carvalho Chehab --- drivers/media/v4l2-core/Makefile | 3 +- drivers/media/v4l2-core/v4l2-async.c | 280 +++++++++++++++++++++++++++ include/media/v4l2-async.h | 105 ++++++++++ include/media/v4l2-subdev.h | 8 + 4 files changed, 395 insertions(+), 1 deletion(-) create mode 100644 drivers/media/v4l2-core/v4l2-async.c create mode 100644 include/media/v4l2-async.h diff --git a/drivers/media/v4l2-core/Makefile b/drivers/media/v4l2-core/Makefile index 628c6307e978..4c33b8d6520c 100644 --- a/drivers/media/v4l2-core/Makefile +++ b/drivers/media/v4l2-core/Makefile @@ -5,7 +5,8 @@ tuner-objs := tuner-core.o videodev-objs := v4l2-dev.o v4l2-ioctl.o v4l2-device.o v4l2-fh.o \ - v4l2-event.o v4l2-ctrls.o v4l2-subdev.o v4l2-clk.o + v4l2-event.o v4l2-ctrls.o v4l2-subdev.o v4l2-clk.o \ + v4l2-async.o ifeq ($(CONFIG_COMPAT),y) videodev-objs += v4l2-compat-ioctl32.o endif diff --git a/drivers/media/v4l2-core/v4l2-async.c b/drivers/media/v4l2-core/v4l2-async.c new file mode 100644 index 000000000000..c80ffb4ba567 --- /dev/null +++ b/drivers/media/v4l2-core/v4l2-async.c @@ -0,0 +1,280 @@ +/* + * V4L2 asynchronous subdevice registration API + * + * Copyright (C) 2012-2013, Guennadi Liakhovetski + * + * 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. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +static bool match_i2c(struct device *dev, struct v4l2_async_subdev *asd) +{ + struct i2c_client *client = i2c_verify_client(dev); + return client && + asd->bus_type == V4L2_ASYNC_BUS_I2C && + asd->match.i2c.adapter_id == client->adapter->nr && + asd->match.i2c.address == client->addr; +} + +static bool match_platform(struct device *dev, struct v4l2_async_subdev *asd) +{ + return asd->bus_type == V4L2_ASYNC_BUS_PLATFORM && + !strcmp(asd->match.platform.name, dev_name(dev)); +} + +static LIST_HEAD(subdev_list); +static LIST_HEAD(notifier_list); +static DEFINE_MUTEX(list_lock); + +static struct v4l2_async_subdev *v4l2_async_belongs(struct v4l2_async_notifier *notifier, + struct v4l2_async_subdev_list *asdl) +{ + struct v4l2_subdev *sd = v4l2_async_to_subdev(asdl); + struct v4l2_async_subdev *asd; + bool (*match)(struct device *, + struct v4l2_async_subdev *); + + list_for_each_entry(asd, ¬ifier->waiting, list) { + /* bus_type has been verified valid before */ + switch (asd->bus_type) { + case V4L2_ASYNC_BUS_CUSTOM: + match = asd->match.custom.match; + if (!match) + /* Match always */ + return asd; + break; + case V4L2_ASYNC_BUS_PLATFORM: + match = match_platform; + break; + case V4L2_ASYNC_BUS_I2C: + match = match_i2c; + break; + default: + /* Cannot happen, unless someone breaks us */ + WARN_ON(true); + return NULL; + } + + /* match cannot be NULL here */ + if (match(sd->dev, asd)) + return asd; + } + + return NULL; +} + +static int v4l2_async_test_notify(struct v4l2_async_notifier *notifier, + struct v4l2_async_subdev_list *asdl, + struct v4l2_async_subdev *asd) +{ + struct v4l2_subdev *sd = v4l2_async_to_subdev(asdl); + int ret; + + /* Remove from the waiting list */ + list_del(&asd->list); + asdl->asd = asd; + asdl->notifier = notifier; + + if (notifier->bound) { + ret = notifier->bound(notifier, sd, asd); + if (ret < 0) + return ret; + } + /* Move from the global subdevice list to notifier's done */ + list_move(&asdl->list, ¬ifier->done); + + ret = v4l2_device_register_subdev(notifier->v4l2_dev, sd); + if (ret < 0) { + if (notifier->unbind) + notifier->unbind(notifier, sd, asd); + return ret; + } + + if (list_empty(¬ifier->waiting) && notifier->complete) + return notifier->complete(notifier); + + return 0; +} + +static void v4l2_async_cleanup(struct v4l2_async_subdev_list *asdl) +{ + struct v4l2_subdev *sd = v4l2_async_to_subdev(asdl); + + v4l2_device_unregister_subdev(sd); + /* Subdevice driver will reprobe and put asdl back onto the list */ + list_del_init(&asdl->list); + asdl->asd = NULL; + sd->dev = NULL; +} + +int v4l2_async_notifier_register(struct v4l2_device *v4l2_dev, + struct v4l2_async_notifier *notifier) +{ + struct v4l2_async_subdev_list *asdl, *tmp; + struct v4l2_async_subdev *asd; + int i; + + if (!notifier->num_subdevs || notifier->num_subdevs > V4L2_MAX_SUBDEVS) + return -EINVAL; + + notifier->v4l2_dev = v4l2_dev; + INIT_LIST_HEAD(¬ifier->waiting); + INIT_LIST_HEAD(¬ifier->done); + + for (i = 0; i < notifier->num_subdevs; i++) { + asd = notifier->subdev[i]; + + switch (asd->bus_type) { + case V4L2_ASYNC_BUS_CUSTOM: + case V4L2_ASYNC_BUS_PLATFORM: + case V4L2_ASYNC_BUS_I2C: + break; + default: + dev_err(notifier->v4l2_dev ? notifier->v4l2_dev->dev : NULL, + "Invalid bus-type %u on %p\n", + asd->bus_type, asd); + return -EINVAL; + } + list_add_tail(&asd->list, ¬ifier->waiting); + } + + mutex_lock(&list_lock); + + /* Keep also completed notifiers on the list */ + list_add(¬ifier->list, ¬ifier_list); + + list_for_each_entry_safe(asdl, tmp, &subdev_list, list) { + int ret; + + asd = v4l2_async_belongs(notifier, asdl); + if (!asd) + continue; + + ret = v4l2_async_test_notify(notifier, asdl, asd); + if (ret < 0) { + mutex_unlock(&list_lock); + return ret; + } + } + + mutex_unlock(&list_lock); + + return 0; +} +EXPORT_SYMBOL(v4l2_async_notifier_register); + +void v4l2_async_notifier_unregister(struct v4l2_async_notifier *notifier) +{ + struct v4l2_async_subdev_list *asdl, *tmp; + unsigned int notif_n_subdev = notifier->num_subdevs; + unsigned int n_subdev = min(notif_n_subdev, V4L2_MAX_SUBDEVS); + struct device *dev[n_subdev]; + int i = 0; + + mutex_lock(&list_lock); + + list_del(¬ifier->list); + + list_for_each_entry_safe(asdl, tmp, ¬ifier->done, list) { + struct v4l2_subdev *sd = v4l2_async_to_subdev(asdl); + + dev[i] = get_device(sd->dev); + + v4l2_async_cleanup(asdl); + + /* If we handled USB devices, we'd have to lock the parent too */ + device_release_driver(dev[i++]); + + if (notifier->unbind) + notifier->unbind(notifier, sd, sd->asdl.asd); + } + + mutex_unlock(&list_lock); + + while (i--) { + struct device *d = dev[i]; + + if (d && device_attach(d) < 0) { + const char *name = "(none)"; + int lock = device_trylock(d); + + if (lock && d->driver) + name = d->driver->name; + dev_err(d, "Failed to re-probe to %s\n", name); + if (lock) + device_unlock(d); + } + put_device(d); + } + /* + * Don't care about the waiting list, it is initialised and populated + * upon notifier registration. + */ +} +EXPORT_SYMBOL(v4l2_async_notifier_unregister); + +int v4l2_async_register_subdev(struct v4l2_subdev *sd) +{ + struct v4l2_async_subdev_list *asdl = &sd->asdl; + struct v4l2_async_notifier *notifier; + + mutex_lock(&list_lock); + + INIT_LIST_HEAD(&asdl->list); + + list_for_each_entry(notifier, ¬ifier_list, list) { + struct v4l2_async_subdev *asd = v4l2_async_belongs(notifier, asdl); + if (asd) { + int ret = v4l2_async_test_notify(notifier, asdl, asd); + mutex_unlock(&list_lock); + return ret; + } + } + + /* None matched, wait for hot-plugging */ + list_add(&asdl->list, &subdev_list); + + mutex_unlock(&list_lock); + + return 0; +} +EXPORT_SYMBOL(v4l2_async_register_subdev); + +void v4l2_async_unregister_subdev(struct v4l2_subdev *sd) +{ + struct v4l2_async_subdev_list *asdl = &sd->asdl; + struct v4l2_async_notifier *notifier = asdl->notifier; + + if (!asdl->asd) { + if (!list_empty(&asdl->list)) + v4l2_async_cleanup(asdl); + return; + } + + mutex_lock(&list_lock); + + list_add(&asdl->asd->list, ¬ifier->waiting); + + v4l2_async_cleanup(asdl); + + if (notifier->unbind) + notifier->unbind(notifier, sd, sd->asdl.asd); + + mutex_unlock(&list_lock); +} +EXPORT_SYMBOL(v4l2_async_unregister_subdev); diff --git a/include/media/v4l2-async.h b/include/media/v4l2-async.h new file mode 100644 index 000000000000..c3ec6ac75f7e --- /dev/null +++ b/include/media/v4l2-async.h @@ -0,0 +1,105 @@ +/* + * V4L2 asynchronous subdevice registration API + * + * Copyright (C) 2012-2013, Guennadi Liakhovetski + * + * 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. + */ + +#ifndef V4L2_ASYNC_H +#define V4L2_ASYNC_H + +#include +#include + +struct device; +struct v4l2_device; +struct v4l2_subdev; +struct v4l2_async_notifier; + +/* A random max subdevice number, used to allocate an array on stack */ +#define V4L2_MAX_SUBDEVS 128U + +enum v4l2_async_bus_type { + V4L2_ASYNC_BUS_CUSTOM, + V4L2_ASYNC_BUS_PLATFORM, + V4L2_ASYNC_BUS_I2C, +}; + +/** + * struct v4l2_async_subdev - sub-device descriptor, as known to a bridge + * @bus_type: subdevice bus type to select the appropriate matching method + * @match: union of per-bus type matching data sets + * @list: used to link struct v4l2_async_subdev objects, waiting to be + * probed, to a notifier->waiting list + */ +struct v4l2_async_subdev { + enum v4l2_async_bus_type bus_type; + union { + struct { + const char *name; + } platform; + struct { + int adapter_id; + unsigned short address; + } i2c; + struct { + bool (*match)(struct device *, + struct v4l2_async_subdev *); + void *priv; + } custom; + } match; + + /* v4l2-async core private: not to be used by drivers */ + struct list_head list; +}; + +/** + * v4l2_async_subdev_list - provided by subdevices + * @list: links struct v4l2_async_subdev_list objects to a global list + * before probing, and onto notifier->done after probing + * @asd: pointer to respective struct v4l2_async_subdev + * @notifier: pointer to managing notifier + */ +struct v4l2_async_subdev_list { + struct list_head list; + struct v4l2_async_subdev *asd; + struct v4l2_async_notifier *notifier; +}; + +/** + * v4l2_async_notifier - v4l2_device notifier data + * @num_subdevs:number of subdevices + * @subdev: array of pointers to subdevice descriptors + * @v4l2_dev: pointer to struct v4l2_device + * @waiting: list of struct v4l2_async_subdev, waiting for their drivers + * @done: list of struct v4l2_async_subdev_list, already probed + * @list: member in a global list of notifiers + * @bound: a subdevice driver has successfully probed one of subdevices + * @complete: all subdevices have been probed successfully + * @unbind: a subdevice is leaving + */ +struct v4l2_async_notifier { + unsigned int num_subdevs; + struct v4l2_async_subdev **subdev; + struct v4l2_device *v4l2_dev; + struct list_head waiting; + struct list_head done; + struct list_head list; + int (*bound)(struct v4l2_async_notifier *notifier, + struct v4l2_subdev *subdev, + struct v4l2_async_subdev *asd); + int (*complete)(struct v4l2_async_notifier *notifier); + void (*unbind)(struct v4l2_async_notifier *notifier, + struct v4l2_subdev *subdev, + struct v4l2_async_subdev *asd); +}; + +int v4l2_async_notifier_register(struct v4l2_device *v4l2_dev, + struct v4l2_async_notifier *notifier); +void v4l2_async_notifier_unregister(struct v4l2_async_notifier *notifier); +int v4l2_async_register_subdev(struct v4l2_subdev *sd); +void v4l2_async_unregister_subdev(struct v4l2_subdev *sd); +#endif diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h index 5fbb266405f9..3250cc5e7925 100644 --- a/include/media/v4l2-subdev.h +++ b/include/media/v4l2-subdev.h @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -585,8 +586,15 @@ struct v4l2_subdev { struct video_device *devnode; /* pointer to the physical device, if any */ struct device *dev; + struct v4l2_async_subdev_list asdl; }; +static inline struct v4l2_subdev *v4l2_async_to_subdev( + struct v4l2_async_subdev_list *asdl) +{ + return container_of(asdl, struct v4l2_subdev, asdl); +} + #define media_entity_to_v4l2_subdev(ent) \ container_of(ent, struct v4l2_subdev, entity) #define vdev_to_v4l2_subdev(vdev) \ From 9aea470b399d797e88be08985c489855759c6c60 Mon Sep 17 00:00:00 2001 From: Guennadi Liakhovetski Date: Fri, 21 Dec 2012 13:01:55 -0300 Subject: [PATCH 0464/1048] [media] soc-camera: switch I2C subdevice drivers to use v4l2-clk Instead of centrally enabling and disabling subdevice master clocks in soc-camera core, let subdevice drivers do that themselves, using the V4L2 clock API and soc-camera convenience wrappers. Signed-off-by: Guennadi Liakhovetski Acked-by: Hans Verkuil Acked-by: Laurent Pinchart Signed-off-by: Mauro Carvalho Chehab --- drivers/media/i2c/soc_camera/imx074.c | 18 +- drivers/media/i2c/soc_camera/mt9m001.c | 17 +- drivers/media/i2c/soc_camera/mt9m111.c | 20 ++- drivers/media/i2c/soc_camera/mt9t031.c | 19 +- drivers/media/i2c/soc_camera/mt9t112.c | 25 ++- drivers/media/i2c/soc_camera/mt9v022.c | 17 +- drivers/media/i2c/soc_camera/ov2640.c | 19 +- drivers/media/i2c/soc_camera/ov5642.c | 20 ++- drivers/media/i2c/soc_camera/ov6650.c | 17 +- drivers/media/i2c/soc_camera/ov772x.c | 15 +- drivers/media/i2c/soc_camera/ov9640.c | 17 +- drivers/media/i2c/soc_camera/ov9640.h | 1 + drivers/media/i2c/soc_camera/ov9740.c | 18 +- drivers/media/i2c/soc_camera/rj54n1cb0c.c | 17 +- drivers/media/i2c/soc_camera/tw9910.c | 24 ++- .../media/platform/soc_camera/soc_camera.c | 162 ++++++++++++++---- .../platform/soc_camera/soc_camera_platform.c | 2 +- include/media/soc_camera.h | 13 +- 18 files changed, 362 insertions(+), 79 deletions(-) diff --git a/drivers/media/i2c/soc_camera/imx074.c b/drivers/media/i2c/soc_camera/imx074.c index a315d4386c8e..2d8367891801 100644 --- a/drivers/media/i2c/soc_camera/imx074.c +++ b/drivers/media/i2c/soc_camera/imx074.c @@ -18,6 +18,7 @@ #include #include +#include #include /* IMX074 registers */ @@ -76,6 +77,7 @@ struct imx074_datafmt { struct imx074 { struct v4l2_subdev subdev; const struct imx074_datafmt *fmt; + struct v4l2_clk *clk; }; static const struct imx074_datafmt imx074_colour_fmts[] = { @@ -254,8 +256,9 @@ static int imx074_s_power(struct v4l2_subdev *sd, int on) { struct i2c_client *client = v4l2_get_subdevdata(sd); struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client); + struct imx074 *priv = to_imx074(client); - return soc_camera_set_power(&client->dev, ssdd, on); + return soc_camera_set_power(&client->dev, ssdd, priv->clk, on); } static int imx074_g_mbus_config(struct v4l2_subdev *sd, @@ -412,6 +415,7 @@ static int imx074_probe(struct i2c_client *client, struct imx074 *priv; struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent); struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client); + int ret; if (!ssdd) { dev_err(&client->dev, "IMX074: missing platform data!\n"); @@ -432,13 +436,23 @@ static int imx074_probe(struct i2c_client *client, priv->fmt = &imx074_colour_fmts[0]; - return imx074_video_probe(client); + priv->clk = v4l2_clk_get(&client->dev, "mclk"); + if (IS_ERR(priv->clk)) + return PTR_ERR(priv->clk); + + ret = imx074_video_probe(client); + if (ret < 0) + v4l2_clk_put(priv->clk); + + return ret; } static int imx074_remove(struct i2c_client *client) { struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client); + struct imx074 *priv = to_imx074(client); + v4l2_clk_put(priv->clk); if (ssdd->free_bus) ssdd->free_bus(ssdd); diff --git a/drivers/media/i2c/soc_camera/mt9m001.c b/drivers/media/i2c/soc_camera/mt9m001.c index 3f1f437ee1c6..df97033fa6ef 100644 --- a/drivers/media/i2c/soc_camera/mt9m001.c +++ b/drivers/media/i2c/soc_camera/mt9m001.c @@ -16,6 +16,7 @@ #include #include +#include #include #include @@ -93,6 +94,7 @@ struct mt9m001 { struct v4l2_ctrl *exposure; }; struct v4l2_rect rect; /* Sensor window */ + struct v4l2_clk *clk; const struct mt9m001_datafmt *fmt; const struct mt9m001_datafmt *fmts; int num_fmts; @@ -355,8 +357,9 @@ static int mt9m001_s_power(struct v4l2_subdev *sd, int on) { struct i2c_client *client = v4l2_get_subdevdata(sd); struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client); + struct mt9m001 *mt9m001 = to_mt9m001(client); - return soc_camera_set_power(&client->dev, ssdd, on); + return soc_camera_set_power(&client->dev, ssdd, mt9m001->clk, on); } static int mt9m001_g_volatile_ctrl(struct v4l2_ctrl *ctrl) @@ -681,9 +684,18 @@ static int mt9m001_probe(struct i2c_client *client, mt9m001->rect.width = MT9M001_MAX_WIDTH; mt9m001->rect.height = MT9M001_MAX_HEIGHT; + mt9m001->clk = v4l2_clk_get(&client->dev, "mclk"); + if (IS_ERR(mt9m001->clk)) { + ret = PTR_ERR(mt9m001->clk); + goto eclkget; + } + ret = mt9m001_video_probe(ssdd, client); - if (ret) + if (ret) { + v4l2_clk_put(mt9m001->clk); +eclkget: v4l2_ctrl_handler_free(&mt9m001->hdl); + } return ret; } @@ -693,6 +705,7 @@ static int mt9m001_remove(struct i2c_client *client) struct mt9m001 *mt9m001 = to_mt9m001(client); struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client); + v4l2_clk_put(mt9m001->clk); v4l2_device_unregister_subdev(&mt9m001->subdev); v4l2_ctrl_handler_free(&mt9m001->hdl); mt9m001_video_remove(ssdd); diff --git a/drivers/media/i2c/soc_camera/mt9m111.c b/drivers/media/i2c/soc_camera/mt9m111.c index 1aaca0423df7..de3605df47c5 100644 --- a/drivers/media/i2c/soc_camera/mt9m111.c +++ b/drivers/media/i2c/soc_camera/mt9m111.c @@ -17,6 +17,7 @@ #include #include +#include #include #include @@ -206,6 +207,7 @@ struct mt9m111 { struct v4l2_ctrl *gain; struct mt9m111_context *ctx; struct v4l2_rect rect; /* cropping rectangle */ + struct v4l2_clk *clk; int width; /* output */ int height; /* sizes */ struct mutex power_lock; /* lock to protect power_count */ @@ -775,14 +777,14 @@ static int mt9m111_power_on(struct mt9m111 *mt9m111) struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client); int ret; - ret = soc_camera_power_on(&client->dev, ssdd); + ret = soc_camera_power_on(&client->dev, ssdd, mt9m111->clk); if (ret < 0) return ret; ret = mt9m111_resume(mt9m111); if (ret < 0) { dev_err(&client->dev, "Failed to resume the sensor: %d\n", ret); - soc_camera_power_off(&client->dev, ssdd); + soc_camera_power_off(&client->dev, ssdd, mt9m111->clk); } return ret; @@ -794,7 +796,7 @@ static void mt9m111_power_off(struct mt9m111 *mt9m111) struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client); mt9m111_suspend(mt9m111); - soc_camera_power_off(&client->dev, ssdd); + soc_camera_power_off(&client->dev, ssdd, mt9m111->clk); } static int mt9m111_s_power(struct v4l2_subdev *sd, int on) @@ -973,9 +975,18 @@ static int mt9m111_probe(struct i2c_client *client, mt9m111->lastpage = -1; mutex_init(&mt9m111->power_lock); + mt9m111->clk = v4l2_clk_get(&client->dev, "mclk"); + if (IS_ERR(mt9m111->clk)) { + ret = PTR_ERR(mt9m111->clk); + goto eclkget; + } + ret = mt9m111_video_probe(client); - if (ret) + if (ret) { + v4l2_clk_put(mt9m111->clk); +eclkget: v4l2_ctrl_handler_free(&mt9m111->hdl); + } return ret; } @@ -984,6 +995,7 @@ static int mt9m111_remove(struct i2c_client *client) { struct mt9m111 *mt9m111 = to_mt9m111(client); + v4l2_clk_put(mt9m111->clk); v4l2_device_unregister_subdev(&mt9m111->subdev); v4l2_ctrl_handler_free(&mt9m111->hdl); diff --git a/drivers/media/i2c/soc_camera/mt9t031.c b/drivers/media/i2c/soc_camera/mt9t031.c index b3dfeb6d1037..47d18d0bafe7 100644 --- a/drivers/media/i2c/soc_camera/mt9t031.c +++ b/drivers/media/i2c/soc_camera/mt9t031.c @@ -18,6 +18,7 @@ #include #include +#include #include #include @@ -75,6 +76,7 @@ struct mt9t031 { struct v4l2_ctrl *exposure; }; struct v4l2_rect rect; /* Sensor window */ + struct v4l2_clk *clk; u16 xskip; u16 yskip; unsigned int total_h; @@ -585,16 +587,17 @@ static int mt9t031_s_power(struct v4l2_subdev *sd, int on) struct i2c_client *client = v4l2_get_subdevdata(sd); struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client); struct video_device *vdev = soc_camera_i2c_to_vdev(client); + struct mt9t031 *mt9t031 = to_mt9t031(client); int ret; if (on) { - ret = soc_camera_power_on(&client->dev, ssdd); + ret = soc_camera_power_on(&client->dev, ssdd, mt9t031->clk); if (ret < 0) return ret; vdev->dev.type = &mt9t031_dev_type; } else { vdev->dev.type = NULL; - soc_camera_power_off(&client->dev, ssdd); + soc_camera_power_off(&client->dev, ssdd, mt9t031->clk); } return 0; @@ -785,9 +788,18 @@ static int mt9t031_probe(struct i2c_client *client, mt9t031->xskip = 1; mt9t031->yskip = 1; + mt9t031->clk = v4l2_clk_get(&client->dev, "mclk"); + if (IS_ERR(mt9t031->clk)) { + ret = PTR_ERR(mt9t031->clk); + goto eclkget; + } + ret = mt9t031_video_probe(client); - if (ret) + if (ret) { + v4l2_clk_put(mt9t031->clk); +eclkget: v4l2_ctrl_handler_free(&mt9t031->hdl); + } return ret; } @@ -796,6 +808,7 @@ static int mt9t031_remove(struct i2c_client *client) { struct mt9t031 *mt9t031 = to_mt9t031(client); + v4l2_clk_put(mt9t031->clk); v4l2_device_unregister_subdev(&mt9t031->subdev); v4l2_ctrl_handler_free(&mt9t031->hdl); diff --git a/drivers/media/i2c/soc_camera/mt9t112.c b/drivers/media/i2c/soc_camera/mt9t112.c index 9b276dde5ac8..46f431a13782 100644 --- a/drivers/media/i2c/soc_camera/mt9t112.c +++ b/drivers/media/i2c/soc_camera/mt9t112.c @@ -27,6 +27,7 @@ #include #include +#include #include /* you can check PLL/clock info */ @@ -89,6 +90,7 @@ struct mt9t112_priv { struct mt9t112_camera_info *info; struct i2c_client *client; struct v4l2_rect frame; + struct v4l2_clk *clk; const struct mt9t112_format *format; int num_formats; u32 flags; @@ -768,8 +770,9 @@ static int mt9t112_s_power(struct v4l2_subdev *sd, int on) { struct i2c_client *client = v4l2_get_subdevdata(sd); struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client); + struct mt9t112_priv *priv = to_mt9t112(client); - return soc_camera_set_power(&client->dev, ssdd, on); + return soc_camera_set_power(&client->dev, ssdd, priv->clk, on); } static struct v4l2_subdev_core_ops mt9t112_subdev_core_ops = { @@ -1092,16 +1095,29 @@ static int mt9t112_probe(struct i2c_client *client, v4l2_i2c_subdev_init(&priv->subdev, client, &mt9t112_subdev_ops); + priv->clk = v4l2_clk_get(&client->dev, "mclk"); + if (IS_ERR(priv->clk)) + return PTR_ERR(priv->clk); + ret = mt9t112_camera_probe(client); - if (ret) - return ret; /* Cannot fail: using the default supported pixel code */ - mt9t112_set_params(priv, &rect, V4L2_MBUS_FMT_UYVY8_2X8); + if (!ret) + mt9t112_set_params(priv, &rect, V4L2_MBUS_FMT_UYVY8_2X8); + else + v4l2_clk_put(priv->clk); return ret; } +static int mt9t112_remove(struct i2c_client *client) +{ + struct mt9t112_priv *priv = to_mt9t112(client); + + v4l2_clk_put(priv->clk); + return 0; +} + static const struct i2c_device_id mt9t112_id[] = { { "mt9t112", 0 }, { } @@ -1113,6 +1129,7 @@ static struct i2c_driver mt9t112_i2c_driver = { .name = "mt9t112", }, .probe = mt9t112_probe, + .remove = mt9t112_remove, .id_table = mt9t112_id, }; diff --git a/drivers/media/i2c/soc_camera/mt9v022.c b/drivers/media/i2c/soc_camera/mt9v022.c index 41ff4535eb0d..f9f95f815b1a 100644 --- a/drivers/media/i2c/soc_camera/mt9v022.c +++ b/drivers/media/i2c/soc_camera/mt9v022.c @@ -19,6 +19,7 @@ #include #include #include +#include #include /* @@ -153,6 +154,7 @@ struct mt9v022 { struct v4l2_ctrl *hblank; struct v4l2_ctrl *vblank; struct v4l2_rect rect; /* Sensor window */ + struct v4l2_clk *clk; const struct mt9v022_datafmt *fmt; const struct mt9v022_datafmt *fmts; const struct mt9v02x_register *reg; @@ -498,8 +500,9 @@ static int mt9v022_s_power(struct v4l2_subdev *sd, int on) { struct i2c_client *client = v4l2_get_subdevdata(sd); struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client); + struct mt9v022 *mt9v022 = to_mt9v022(client); - return soc_camera_set_power(&client->dev, ssdd, on); + return soc_camera_set_power(&client->dev, ssdd, mt9v022->clk, on); } static int mt9v022_g_volatile_ctrl(struct v4l2_ctrl *ctrl) @@ -936,9 +939,18 @@ static int mt9v022_probe(struct i2c_client *client, mt9v022->rect.width = MT9V022_MAX_WIDTH; mt9v022->rect.height = MT9V022_MAX_HEIGHT; + mt9v022->clk = v4l2_clk_get(&client->dev, "mclk"); + if (IS_ERR(mt9v022->clk)) { + ret = PTR_ERR(mt9v022->clk); + goto eclkget; + } + ret = mt9v022_video_probe(client); - if (ret) + if (ret) { + v4l2_clk_put(mt9v022->clk); +eclkget: v4l2_ctrl_handler_free(&mt9v022->hdl); + } return ret; } @@ -948,6 +960,7 @@ static int mt9v022_remove(struct i2c_client *client) struct mt9v022 *mt9v022 = to_mt9v022(client); struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client); + v4l2_clk_put(mt9v022->clk); v4l2_device_unregister_subdev(&mt9v022->subdev); if (ssdd->free_bus) ssdd->free_bus(ssdd); diff --git a/drivers/media/i2c/soc_camera/ov2640.c b/drivers/media/i2c/soc_camera/ov2640.c index 7961cba6880a..6c6b1c3b45e3 100644 --- a/drivers/media/i2c/soc_camera/ov2640.c +++ b/drivers/media/i2c/soc_camera/ov2640.c @@ -22,6 +22,7 @@ #include #include +#include #include #include @@ -302,6 +303,7 @@ struct ov2640_priv { struct v4l2_subdev subdev; struct v4l2_ctrl_handler hdl; enum v4l2_mbus_pixelcode cfmt_code; + struct v4l2_clk *clk; const struct ov2640_win_size *win; }; @@ -758,8 +760,9 @@ static int ov2640_s_power(struct v4l2_subdev *sd, int on) { struct i2c_client *client = v4l2_get_subdevdata(sd); struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client); + struct ov2640_priv *priv = to_ov2640(client); - return soc_camera_set_power(&client->dev, ssdd, on); + return soc_camera_set_power(&client->dev, ssdd, priv->clk, on); } /* Select the nearest higher resolution for capture */ @@ -1097,11 +1100,20 @@ static int ov2640_probe(struct i2c_client *client, if (priv->hdl.error) return priv->hdl.error; + priv->clk = v4l2_clk_get(&client->dev, "mclk"); + if (IS_ERR(priv->clk)) { + ret = PTR_ERR(priv->clk); + goto eclkget; + } + ret = ov2640_video_probe(client); - if (ret) + if (ret) { + v4l2_clk_put(priv->clk); +eclkget: v4l2_ctrl_handler_free(&priv->hdl); - else + } else { dev_info(&adapter->dev, "OV2640 Probed\n"); + } return ret; } @@ -1110,6 +1122,7 @@ static int ov2640_remove(struct i2c_client *client) { struct ov2640_priv *priv = to_ov2640(client); + v4l2_clk_put(priv->clk); v4l2_device_unregister_subdev(&priv->subdev); v4l2_ctrl_handler_free(&priv->hdl); return 0; diff --git a/drivers/media/i2c/soc_camera/ov5642.c b/drivers/media/i2c/soc_camera/ov5642.c index c93a157d1d93..0a5c5d4fedd6 100644 --- a/drivers/media/i2c/soc_camera/ov5642.c +++ b/drivers/media/i2c/soc_camera/ov5642.c @@ -24,6 +24,7 @@ #include #include +#include #include /* OV5642 registers */ @@ -609,6 +610,7 @@ struct ov5642 { struct v4l2_subdev subdev; const struct ov5642_datafmt *fmt; struct v4l2_rect crop_rect; + struct v4l2_clk *clk; /* blanking information */ int total_width; @@ -917,12 +919,13 @@ static int ov5642_s_power(struct v4l2_subdev *sd, int on) { struct i2c_client *client = v4l2_get_subdevdata(sd); struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client); + struct ov5642 *priv = to_ov5642(client); int ret; if (!on) - return soc_camera_power_off(&client->dev, ssdd); + return soc_camera_power_off(&client->dev, ssdd, priv->clk); - ret = soc_camera_power_on(&client->dev, ssdd); + ret = soc_camera_power_on(&client->dev, ssdd, priv->clk); if (ret < 0) return ret; @@ -1002,6 +1005,7 @@ static int ov5642_probe(struct i2c_client *client, { struct ov5642 *priv; struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client); + int ret; if (!ssdd) { dev_err(&client->dev, "OV5642: missing platform data!\n"); @@ -1023,13 +1027,23 @@ static int ov5642_probe(struct i2c_client *client, priv->total_width = OV5642_DEFAULT_WIDTH + BLANKING_EXTRA_WIDTH; priv->total_height = BLANKING_MIN_HEIGHT; - return ov5642_video_probe(client); + priv->clk = v4l2_clk_get(&client->dev, "mclk"); + if (IS_ERR(priv->clk)) + return PTR_ERR(priv->clk); + + ret = ov5642_video_probe(client); + if (ret < 0) + v4l2_clk_put(priv->clk); + + return ret; } static int ov5642_remove(struct i2c_client *client) { struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client); + struct ov5642 *priv = to_ov5642(client); + v4l2_clk_put(priv->clk); if (ssdd->free_bus) ssdd->free_bus(ssdd); diff --git a/drivers/media/i2c/soc_camera/ov6650.c b/drivers/media/i2c/soc_camera/ov6650.c index d2869d87d3b1..ab01598ec83f 100644 --- a/drivers/media/i2c/soc_camera/ov6650.c +++ b/drivers/media/i2c/soc_camera/ov6650.c @@ -32,6 +32,7 @@ #include #include +#include #include /* Register definitions */ @@ -195,6 +196,7 @@ struct ov6650 { struct v4l2_ctrl *blue; struct v4l2_ctrl *red; }; + struct v4l2_clk *clk; bool half_scale; /* scale down output by 2 */ struct v4l2_rect rect; /* sensor cropping window */ unsigned long pclk_limit; /* from host */ @@ -425,8 +427,9 @@ static int ov6650_s_power(struct v4l2_subdev *sd, int on) { struct i2c_client *client = v4l2_get_subdevdata(sd); struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client); + struct ov6650 *priv = to_ov6650(client); - return soc_camera_set_power(&client->dev, ssdd, on); + return soc_camera_set_power(&client->dev, ssdd, priv->clk, on); } static int ov6650_g_crop(struct v4l2_subdev *sd, struct v4l2_crop *a) @@ -1013,9 +1016,18 @@ static int ov6650_probe(struct i2c_client *client, priv->code = V4L2_MBUS_FMT_YUYV8_2X8; priv->colorspace = V4L2_COLORSPACE_JPEG; + priv->clk = v4l2_clk_get(&client->dev, "mclk"); + if (IS_ERR(priv->clk)) { + ret = PTR_ERR(priv->clk); + goto eclkget; + } + ret = ov6650_video_probe(client); - if (ret) + if (ret) { + v4l2_clk_put(priv->clk); +eclkget: v4l2_ctrl_handler_free(&priv->hdl); + } return ret; } @@ -1024,6 +1036,7 @@ static int ov6650_remove(struct i2c_client *client) { struct ov6650 *priv = to_ov6650(client); + v4l2_clk_put(priv->clk); v4l2_device_unregister_subdev(&priv->subdev); v4l2_ctrl_handler_free(&priv->hdl); return 0; diff --git a/drivers/media/i2c/soc_camera/ov772x.c b/drivers/media/i2c/soc_camera/ov772x.c index b2f623603986..7f2b3c8926af 100644 --- a/drivers/media/i2c/soc_camera/ov772x.c +++ b/drivers/media/i2c/soc_camera/ov772x.c @@ -26,6 +26,7 @@ #include #include +#include #include #include @@ -395,6 +396,7 @@ struct ov772x_win_size { struct ov772x_priv { struct v4l2_subdev subdev; struct v4l2_ctrl_handler hdl; + struct v4l2_clk *clk; struct ov772x_camera_info *info; const struct ov772x_color_format *cfmt; const struct ov772x_win_size *win; @@ -655,8 +657,9 @@ static int ov772x_s_power(struct v4l2_subdev *sd, int on) { struct i2c_client *client = v4l2_get_subdevdata(sd); struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client); + struct ov772x_priv *priv = to_ov772x(sd); - return soc_camera_set_power(&client->dev, ssdd, on); + return soc_camera_set_power(&client->dev, ssdd, priv->clk, on); } static const struct ov772x_win_size *ov772x_select_win(u32 width, u32 height) @@ -1072,13 +1075,22 @@ static int ov772x_probe(struct i2c_client *client, if (priv->hdl.error) return priv->hdl.error; + priv->clk = v4l2_clk_get(&client->dev, "mclk"); + if (IS_ERR(priv->clk)) { + ret = PTR_ERR(priv->clk); + goto eclkget; + } + ret = ov772x_video_probe(priv); if (ret < 0) { + v4l2_clk_put(priv->clk); +eclkget: v4l2_ctrl_handler_free(&priv->hdl); } else { priv->cfmt = &ov772x_cfmts[0]; priv->win = &ov772x_win_sizes[0]; } + return ret; } @@ -1086,6 +1098,7 @@ static int ov772x_remove(struct i2c_client *client) { struct ov772x_priv *priv = to_ov772x(i2c_get_clientdata(client)); + v4l2_clk_put(priv->clk); v4l2_device_unregister_subdev(&priv->subdev); v4l2_ctrl_handler_free(&priv->hdl); return 0; diff --git a/drivers/media/i2c/soc_camera/ov9640.c b/drivers/media/i2c/soc_camera/ov9640.c index 7d1f10f301d3..e968c3fdbd9e 100644 --- a/drivers/media/i2c/soc_camera/ov9640.c +++ b/drivers/media/i2c/soc_camera/ov9640.c @@ -28,6 +28,7 @@ #include #include +#include #include #include @@ -324,8 +325,9 @@ static int ov9640_s_power(struct v4l2_subdev *sd, int on) { struct i2c_client *client = v4l2_get_subdevdata(sd); struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client); + struct ov9640_priv *priv = to_ov9640_sensor(sd); - return soc_camera_set_power(&client->dev, ssdd, on); + return soc_camera_set_power(&client->dev, ssdd, priv->clk, on); } /* select nearest higher resolution for capture */ @@ -700,10 +702,18 @@ static int ov9640_probe(struct i2c_client *client, if (priv->hdl.error) return priv->hdl.error; - ret = ov9640_video_probe(client); + priv->clk = v4l2_clk_get(&client->dev, "mclk"); + if (IS_ERR(priv->clk)) { + ret = PTR_ERR(priv->clk); + goto eclkget; + } - if (ret) + ret = ov9640_video_probe(client); + if (ret) { + v4l2_clk_put(priv->clk); +eclkget: v4l2_ctrl_handler_free(&priv->hdl); + } return ret; } @@ -713,6 +723,7 @@ static int ov9640_remove(struct i2c_client *client) struct v4l2_subdev *sd = i2c_get_clientdata(client); struct ov9640_priv *priv = to_ov9640_sensor(sd); + v4l2_clk_put(priv->clk); v4l2_device_unregister_subdev(&priv->subdev); v4l2_ctrl_handler_free(&priv->hdl); return 0; diff --git a/drivers/media/i2c/soc_camera/ov9640.h b/drivers/media/i2c/soc_camera/ov9640.h index 6b33a972c83c..65d13ff17536 100644 --- a/drivers/media/i2c/soc_camera/ov9640.h +++ b/drivers/media/i2c/soc_camera/ov9640.h @@ -199,6 +199,7 @@ struct ov9640_reg { struct ov9640_priv { struct v4l2_subdev subdev; struct v4l2_ctrl_handler hdl; + struct v4l2_clk *clk; int model; int revision; diff --git a/drivers/media/i2c/soc_camera/ov9740.c b/drivers/media/i2c/soc_camera/ov9740.c index 0bc21a643c08..ea76863dfdb4 100644 --- a/drivers/media/i2c/soc_camera/ov9740.c +++ b/drivers/media/i2c/soc_camera/ov9740.c @@ -17,6 +17,7 @@ #include #include +#include #include #define to_ov9740(sd) container_of(sd, struct ov9740_priv, subdev) @@ -195,6 +196,7 @@ struct ov9740_reg { struct ov9740_priv { struct v4l2_subdev subdev; struct v4l2_ctrl_handler hdl; + struct v4l2_clk *clk; u16 model; u8 revision; @@ -778,7 +780,7 @@ static int ov9740_s_power(struct v4l2_subdev *sd, int on) int ret; if (on) { - ret = soc_camera_power_on(&client->dev, ssdd); + ret = soc_camera_power_on(&client->dev, ssdd, priv->clk); if (ret < 0) return ret; @@ -792,7 +794,7 @@ static int ov9740_s_power(struct v4l2_subdev *sd, int on) priv->current_enable = true; } - soc_camera_power_off(&client->dev, ssdd); + soc_camera_power_off(&client->dev, ssdd, priv->clk); } return 0; @@ -958,9 +960,18 @@ static int ov9740_probe(struct i2c_client *client, if (priv->hdl.error) return priv->hdl.error; + priv->clk = v4l2_clk_get(&client->dev, "mclk"); + if (IS_ERR(priv->clk)) { + ret = PTR_ERR(priv->clk); + goto eclkget; + } + ret = ov9740_video_probe(client); - if (ret < 0) + if (ret < 0) { + v4l2_clk_put(priv->clk); +eclkget: v4l2_ctrl_handler_free(&priv->hdl); + } return ret; } @@ -969,6 +980,7 @@ static int ov9740_remove(struct i2c_client *client) { struct ov9740_priv *priv = i2c_get_clientdata(client); + v4l2_clk_put(priv->clk); v4l2_device_unregister_subdev(&priv->subdev); v4l2_ctrl_handler_free(&priv->hdl); return 0; diff --git a/drivers/media/i2c/soc_camera/rj54n1cb0c.c b/drivers/media/i2c/soc_camera/rj54n1cb0c.c index 81b515c2fb36..7e6d97847874 100644 --- a/drivers/media/i2c/soc_camera/rj54n1cb0c.c +++ b/drivers/media/i2c/soc_camera/rj54n1cb0c.c @@ -17,6 +17,7 @@ #include #include +#include #include #include @@ -150,6 +151,7 @@ struct rj54n1_clock_div { struct rj54n1 { struct v4l2_subdev subdev; struct v4l2_ctrl_handler hdl; + struct v4l2_clk *clk; struct rj54n1_clock_div clk_div; const struct rj54n1_datafmt *fmt; struct v4l2_rect rect; /* Sensor window */ @@ -1158,8 +1160,9 @@ static int rj54n1_s_power(struct v4l2_subdev *sd, int on) { struct i2c_client *client = v4l2_get_subdevdata(sd); struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client); + struct rj54n1 *rj54n1 = to_rj54n1(client); - return soc_camera_set_power(&client->dev, ssdd, on); + return soc_camera_set_power(&client->dev, ssdd, rj54n1->clk, on); } static int rj54n1_s_ctrl(struct v4l2_ctrl *ctrl) @@ -1355,9 +1358,18 @@ static int rj54n1_probe(struct i2c_client *client, rj54n1->tgclk_mhz = (rj54n1_priv->mclk_freq / PLL_L * PLL_N) / (clk_div.ratio_tg + 1) / (clk_div.ratio_t + 1); + rj54n1->clk = v4l2_clk_get(&client->dev, "mclk"); + if (IS_ERR(rj54n1->clk)) { + ret = PTR_ERR(rj54n1->clk); + goto eclkget; + } + ret = rj54n1_video_probe(client, rj54n1_priv); - if (ret < 0) + if (ret < 0) { + v4l2_clk_put(rj54n1->clk); +eclkget: v4l2_ctrl_handler_free(&rj54n1->hdl); + } return ret; } @@ -1367,6 +1379,7 @@ static int rj54n1_remove(struct i2c_client *client) struct rj54n1 *rj54n1 = to_rj54n1(client); struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client); + v4l2_clk_put(rj54n1->clk); v4l2_device_unregister_subdev(&rj54n1->subdev); if (ssdd->free_bus) ssdd->free_bus(ssdd); diff --git a/drivers/media/i2c/soc_camera/tw9910.c b/drivers/media/i2c/soc_camera/tw9910.c index b15e1d8194da..ab54628d9411 100644 --- a/drivers/media/i2c/soc_camera/tw9910.c +++ b/drivers/media/i2c/soc_camera/tw9910.c @@ -27,6 +27,7 @@ #include #include +#include #include #define GET_ID(val) ((val & 0xF8) >> 3) @@ -227,6 +228,7 @@ struct tw9910_scale_ctrl { struct tw9910_priv { struct v4l2_subdev subdev; + struct v4l2_clk *clk; struct tw9910_video_info *info; const struct tw9910_scale_ctrl *scale; v4l2_std_id norm; @@ -558,8 +560,9 @@ static int tw9910_s_power(struct v4l2_subdev *sd, int on) { struct i2c_client *client = v4l2_get_subdevdata(sd); struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client); + struct tw9910_priv *priv = to_tw9910(client); - return soc_camera_set_power(&client->dev, ssdd, on); + return soc_camera_set_power(&client->dev, ssdd, priv->clk, on); } static int tw9910_set_frame(struct v4l2_subdev *sd, u32 *width, u32 *height) @@ -899,6 +902,7 @@ static int tw9910_probe(struct i2c_client *client, struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent); struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client); + int ret; if (!ssdd || !ssdd->drv_priv) { dev_err(&client->dev, "TW9910: missing platform data!\n"); @@ -922,7 +926,22 @@ static int tw9910_probe(struct i2c_client *client, v4l2_i2c_subdev_init(&priv->subdev, client, &tw9910_subdev_ops); - return tw9910_video_probe(client); + priv->clk = v4l2_clk_get(&client->dev, "mclk"); + if (IS_ERR(priv->clk)) + return PTR_ERR(priv->clk); + + ret = tw9910_video_probe(client); + if (ret < 0) + v4l2_clk_put(priv->clk); + + return ret; +} + +static int tw9910_remove(struct i2c_client *client) +{ + struct tw9910_priv *priv = to_tw9910(client); + v4l2_clk_put(priv->clk); + return 0; } static const struct i2c_device_id tw9910_id[] = { @@ -936,6 +955,7 @@ static struct i2c_driver tw9910_i2c_driver = { .name = "tw9910", }, .probe = tw9910_probe, + .remove = tw9910_remove, .id_table = tw9910_id, }; diff --git a/drivers/media/platform/soc_camera/soc_camera.c b/drivers/media/platform/soc_camera/soc_camera.c index fa8a728b7a5d..fe3930e882e1 100644 --- a/drivers/media/platform/soc_camera/soc_camera.c +++ b/drivers/media/platform/soc_camera/soc_camera.c @@ -30,6 +30,7 @@ #include #include +#include #include #include #include @@ -50,13 +51,19 @@ static LIST_HEAD(hosts); static LIST_HEAD(devices); static DEFINE_MUTEX(list_lock); /* Protects the list of hosts */ -int soc_camera_power_on(struct device *dev, struct soc_camera_subdev_desc *ssdd) +int soc_camera_power_on(struct device *dev, struct soc_camera_subdev_desc *ssdd, + struct v4l2_clk *clk) { - int ret = regulator_bulk_enable(ssdd->num_regulators, + int ret = clk ? v4l2_clk_enable(clk) : 0; + if (ret < 0) { + dev_err(dev, "Cannot enable clock\n"); + return ret; + } + ret = regulator_bulk_enable(ssdd->num_regulators, ssdd->regulators); if (ret < 0) { dev_err(dev, "Cannot enable regulators\n"); - return ret; + goto eregenable;; } if (ssdd->power) { @@ -64,16 +71,25 @@ int soc_camera_power_on(struct device *dev, struct soc_camera_subdev_desc *ssdd) if (ret < 0) { dev_err(dev, "Platform failed to power-on the camera.\n"); - regulator_bulk_disable(ssdd->num_regulators, - ssdd->regulators); + goto epwron; } } + return 0; + +epwron: + regulator_bulk_disable(ssdd->num_regulators, + ssdd->regulators); +eregenable: + if (clk) + v4l2_clk_disable(clk); + return ret; } EXPORT_SYMBOL(soc_camera_power_on); -int soc_camera_power_off(struct device *dev, struct soc_camera_subdev_desc *ssdd) +int soc_camera_power_off(struct device *dev, struct soc_camera_subdev_desc *ssdd, + struct v4l2_clk *clk) { int ret = 0; int err; @@ -94,6 +110,9 @@ int soc_camera_power_off(struct device *dev, struct soc_camera_subdev_desc *ssdd ret = ret ? : err; } + if (clk) + v4l2_clk_disable(clk); + return ret; } EXPORT_SYMBOL(soc_camera_power_off); @@ -512,9 +531,11 @@ static int soc_camera_add_device(struct soc_camera_device *icd) if (ici->icd) return -EBUSY; - ret = ici->ops->clock_start(ici); - if (ret < 0) - return ret; + if (!icd->clk) { + ret = ici->ops->clock_start(ici); + if (ret < 0) + return ret; + } if (ici->ops->add) { ret = ici->ops->add(icd); @@ -527,7 +548,8 @@ static int soc_camera_add_device(struct soc_camera_device *icd) return 0; eadd: - ici->ops->clock_stop(ici); + if (!icd->clk) + ici->ops->clock_stop(ici); return ret; } @@ -540,7 +562,8 @@ static void soc_camera_remove_device(struct soc_camera_device *icd) if (ici->ops->remove) ici->ops->remove(icd); - ici->ops->clock_stop(ici); + if (!icd->clk) + ici->ops->clock_stop(ici); ici->icd = NULL; } @@ -1094,6 +1117,57 @@ static void scan_add_host(struct soc_camera_host *ici) mutex_unlock(&list_lock); } +/* + * It is invalid to call v4l2_clk_enable() after a successful probing + * asynchronously outside of V4L2 operations, i.e. with .host_lock not held. + */ +static int soc_camera_clk_enable(struct v4l2_clk *clk) +{ + struct soc_camera_device *icd = clk->priv; + struct soc_camera_host *ici; + + if (!icd || !icd->parent) + return -ENODEV; + + ici = to_soc_camera_host(icd->parent); + + if (!try_module_get(ici->ops->owner)) + return -ENODEV; + + /* + * If a different client is currently being probed, the host will tell + * you to go + */ + return ici->ops->clock_start(ici); +} + +static void soc_camera_clk_disable(struct v4l2_clk *clk) +{ + struct soc_camera_device *icd = clk->priv; + struct soc_camera_host *ici; + + if (!icd || !icd->parent) + return; + + ici = to_soc_camera_host(icd->parent); + + ici->ops->clock_stop(ici); + + module_put(ici->ops->owner); +} + +/* + * Eventually, it would be more logical to make the respective host the clock + * owner, but then we would have to copy this struct for each ici. Besides, it + * would introduce the circular dependency problem, unless we port all client + * drivers to release the clock, when not in use. + */ +static const struct v4l2_clk_ops soc_camera_clk_ops = { + .owner = THIS_MODULE, + .enable = soc_camera_clk_enable, + .disable = soc_camera_clk_disable, +}; + #ifdef CONFIG_I2C_BOARDINFO static int soc_camera_init_i2c(struct soc_camera_device *icd, struct soc_camera_desc *sdesc) @@ -1103,19 +1177,32 @@ static int soc_camera_init_i2c(struct soc_camera_device *icd, struct soc_camera_host_desc *shd = &sdesc->host_desc; struct i2c_adapter *adap = i2c_get_adapter(shd->i2c_adapter_id); struct v4l2_subdev *subdev; + char clk_name[V4L2_SUBDEV_NAME_SIZE]; + int ret; if (!adap) { dev_err(icd->pdev, "Cannot get I2C adapter #%d. No driver?\n", shd->i2c_adapter_id); - goto ei2cga; + return -ENODEV; } shd->board_info->platform_data = &sdesc->subdev_desc; + snprintf(clk_name, sizeof(clk_name), "%d-%04x", + shd->i2c_adapter_id, shd->board_info->addr); + + icd->clk = v4l2_clk_register(&soc_camera_clk_ops, clk_name, "mclk", icd); + if (IS_ERR(icd->clk)) { + ret = PTR_ERR(icd->clk); + goto eclkreg; + } + subdev = v4l2_i2c_new_subdev_board(&ici->v4l2_dev, adap, shd->board_info, NULL); - if (!subdev) + if (!subdev) { + ret = -ENODEV; goto ei2cnd; + } client = v4l2_get_subdevdata(subdev); @@ -1124,9 +1211,11 @@ static int soc_camera_init_i2c(struct soc_camera_device *icd, return 0; ei2cnd: + v4l2_clk_unregister(icd->clk); + icd->clk = NULL; +eclkreg: i2c_put_adapter(adap); -ei2cga: - return -ENODEV; + return ret; } static void soc_camera_free_i2c(struct soc_camera_device *icd) @@ -1139,6 +1228,8 @@ static void soc_camera_free_i2c(struct soc_camera_device *icd) v4l2_device_unregister_subdev(i2c_get_clientdata(client)); i2c_unregister_device(client); i2c_put_adapter(adap); + v4l2_clk_unregister(icd->clk); + icd->clk = NULL; } #else #define soc_camera_init_i2c(icd, sdesc) (-ENODEV) @@ -1176,26 +1267,31 @@ static int soc_camera_probe(struct soc_camera_device *icd) if (ssdd->reset) ssdd->reset(icd->pdev); - mutex_lock(&ici->host_lock); - ret = ici->ops->clock_start(ici); - mutex_unlock(&ici->host_lock); - if (ret < 0) - goto eadd; - /* Must have icd->vdev before registering the device */ ret = video_dev_create(icd); if (ret < 0) goto evdc; + /* + * ..._video_start() will create a device node, video_register_device() + * itself is protected against concurrent open() calls, but we also have + * to protect our data also during client probing. + */ + mutex_lock(&ici->host_lock); + /* Non-i2c cameras, e.g., soc_camera_platform, have no board_info */ if (shd->board_info) { ret = soc_camera_init_i2c(icd, sdesc); if (ret < 0) - goto eadddev; + goto eadd; } else if (!shd->add_device || !shd->del_device) { ret = -EINVAL; - goto eadddev; + goto eadd; } else { + ret = ici->ops->clock_start(ici); + if (ret < 0) + goto eadd; + if (shd->module_name) ret = request_module(shd->module_name); @@ -1231,13 +1327,6 @@ static int soc_camera_probe(struct soc_camera_device *icd) icd->field = V4L2_FIELD_ANY; - /* - * ..._video_start() will create a device node, video_register_device() - * itself is protected against concurrent open() calls, but we also have - * to protect our data. - */ - mutex_lock(&ici->host_lock); - ret = soc_camera_video_start(icd); if (ret < 0) goto evidstart; @@ -1250,14 +1339,14 @@ static int soc_camera_probe(struct soc_camera_device *icd) icd->field = mf.field; } - ici->ops->clock_stop(ici); + if (!shd->board_info) + ici->ops->clock_stop(ici); mutex_unlock(&ici->host_lock); return 0; evidstart: - mutex_unlock(&ici->host_lock); soc_camera_free_user_formats(icd); eiufmt: ectrl: @@ -1266,16 +1355,15 @@ ectrl: } else { shd->del_device(icd); module_put(control->driver->owner); - } enodrv: eadddev: + ici->ops->clock_stop(ici); + } +eadd: video_device_release(icd->vdev); icd->vdev = NULL; -evdc: - mutex_lock(&ici->host_lock); - ici->ops->clock_stop(ici); mutex_unlock(&ici->host_lock); -eadd: +evdc: v4l2_ctrl_handler_free(&icd->ctrl_handler); return ret; } diff --git a/drivers/media/platform/soc_camera/soc_camera_platform.c b/drivers/media/platform/soc_camera/soc_camera_platform.c index bdf909d2ec35..ceaddfb85e49 100644 --- a/drivers/media/platform/soc_camera/soc_camera_platform.c +++ b/drivers/media/platform/soc_camera/soc_camera_platform.c @@ -54,7 +54,7 @@ static int soc_camera_platform_s_power(struct v4l2_subdev *sd, int on) { struct soc_camera_platform_info *p = v4l2_get_subdevdata(sd); - return soc_camera_set_power(p->icd->control, &p->icd->sdesc->subdev_desc, on); + return soc_camera_set_power(p->icd->control, &p->icd->sdesc->subdev_desc, NULL, on); } static struct v4l2_subdev_core_ops platform_subdev_core_ops = { diff --git a/include/media/soc_camera.h b/include/media/soc_camera.h index dfa24df960df..f582323fafb7 100644 --- a/include/media/soc_camera.h +++ b/include/media/soc_camera.h @@ -49,6 +49,7 @@ struct soc_camera_device { /* soc_camera.c private count. Only accessed with .host_lock held */ int use_count; struct file *streamer; /* stream owner */ + struct v4l2_clk *clk; union { struct videobuf_queue vb_vidq; struct vb2_queue vb2_vidq; @@ -325,14 +326,16 @@ static inline void soc_camera_limit_side(int *start, int *length, unsigned long soc_camera_apply_board_flags(struct soc_camera_subdev_desc *ssdd, const struct v4l2_mbus_config *cfg); -int soc_camera_power_on(struct device *dev, struct soc_camera_subdev_desc *ssdd); -int soc_camera_power_off(struct device *dev, struct soc_camera_subdev_desc *ssdd); +int soc_camera_power_on(struct device *dev, struct soc_camera_subdev_desc *ssdd, + struct v4l2_clk *clk); +int soc_camera_power_off(struct device *dev, struct soc_camera_subdev_desc *ssdd, + struct v4l2_clk *clk); static inline int soc_camera_set_power(struct device *dev, - struct soc_camera_subdev_desc *ssdd, bool on) + struct soc_camera_subdev_desc *ssdd, struct v4l2_clk *clk, bool on) { - return on ? soc_camera_power_on(dev, ssdd) - : soc_camera_power_off(dev, ssdd); + return on ? soc_camera_power_on(dev, ssdd, clk) + : soc_camera_power_off(dev, ssdd, clk); } /* This is only temporary here - until v4l2-subdev begins to link to video_device */ From e09da11da49c6fd625be52d8b60bbbbe225a9db6 Mon Sep 17 00:00:00 2001 From: Guennadi Liakhovetski Date: Wed, 26 Dec 2012 12:44:11 -0300 Subject: [PATCH 0465/1048] [media] soc-camera: add V4L2-async support Add support for asynchronous subdevice probing, using the v4l2-async API. The legacy synchronous mode is still supported too, which allows to gradually update drivers and platforms. The selected approach adds a notifier for each struct soc_camera_device instance, i.e. for each video device node, even when there are multiple such instances registered with a single soc-camera host simultaneously. Signed-off-by: Guennadi Liakhovetski Acked-by: Hans Verkuil Acked-by: Laurent Pinchart Signed-off-by: Mauro Carvalho Chehab --- .../media/platform/soc_camera/soc_camera.c | 529 +++++++++++++++--- include/media/soc_camera.h | 23 +- 2 files changed, 465 insertions(+), 87 deletions(-) diff --git a/drivers/media/platform/soc_camera/soc_camera.c b/drivers/media/platform/soc_camera/soc_camera.c index fe3930e882e1..2e47b5127d4b 100644 --- a/drivers/media/platform/soc_camera/soc_camera.c +++ b/drivers/media/platform/soc_camera/soc_camera.c @@ -21,22 +21,23 @@ #include #include #include -#include #include +#include #include +#include #include #include -#include #include #include +#include +#include #include #include #include #include #include #include -#include /* Default to VGA resolution */ #define DEFAULT_WIDTH 640 @@ -47,23 +48,39 @@ (icd)->vb_vidq.streaming : \ vb2_is_streaming(&(icd)->vb2_vidq)) +#define MAP_MAX_NUM 32 +static DECLARE_BITMAP(device_map, MAP_MAX_NUM); static LIST_HEAD(hosts); static LIST_HEAD(devices); -static DEFINE_MUTEX(list_lock); /* Protects the list of hosts */ +/* + * Protects lists and bitmaps of hosts and devices. + * Lock nesting: Ok to take ->host_lock under list_lock. + */ +static DEFINE_MUTEX(list_lock); + +struct soc_camera_async_client { + struct v4l2_async_subdev *sensor; + struct v4l2_async_notifier notifier; + struct platform_device *pdev; + struct list_head list; /* needed for clean up */ +}; + +static int soc_camera_video_start(struct soc_camera_device *icd); +static int video_dev_create(struct soc_camera_device *icd); int soc_camera_power_on(struct device *dev, struct soc_camera_subdev_desc *ssdd, struct v4l2_clk *clk) { int ret = clk ? v4l2_clk_enable(clk) : 0; if (ret < 0) { - dev_err(dev, "Cannot enable clock\n"); + dev_err(dev, "Cannot enable clock: %d\n", ret); return ret; } ret = regulator_bulk_enable(ssdd->num_regulators, ssdd->regulators); if (ret < 0) { dev_err(dev, "Cannot enable regulators\n"); - goto eregenable;; + goto eregenable; } if (ssdd->power) { @@ -117,6 +134,14 @@ int soc_camera_power_off(struct device *dev, struct soc_camera_subdev_desc *ssdd } EXPORT_SYMBOL(soc_camera_power_off); +int soc_camera_power_init(struct device *dev, struct soc_camera_subdev_desc *ssdd) +{ + + return devm_regulator_bulk_get(dev, ssdd->num_regulators, + ssdd->regulators); +} +EXPORT_SYMBOL(soc_camera_power_init); + static int __soc_camera_power_on(struct soc_camera_device *icd) { struct v4l2_subdev *sd = soc_camera_to_subdev(icd); @@ -532,7 +557,9 @@ static int soc_camera_add_device(struct soc_camera_device *icd) return -EBUSY; if (!icd->clk) { + mutex_lock(&ici->clk_lock); ret = ici->ops->clock_start(ici); + mutex_unlock(&ici->clk_lock); if (ret < 0) return ret; } @@ -548,8 +575,11 @@ static int soc_camera_add_device(struct soc_camera_device *icd) return 0; eadd: - if (!icd->clk) + if (!icd->clk) { + mutex_lock(&ici->clk_lock); ici->ops->clock_stop(ici); + mutex_unlock(&ici->clk_lock); + } return ret; } @@ -562,8 +592,11 @@ static void soc_camera_remove_device(struct soc_camera_device *icd) if (ici->ops->remove) ici->ops->remove(icd); - if (!icd->clk) + if (!icd->clk) { + mutex_lock(&ici->clk_lock); ici->ops->clock_stop(ici); + mutex_unlock(&ici->clk_lock); + } ici->icd = NULL; } @@ -672,8 +705,8 @@ static int soc_camera_open(struct file *file) return 0; /* - * First four errors are entered with the .host_lock held - * and use_count == 1 + * All errors are entered with the .host_lock held, first four also + * with use_count == 1 */ einitvb: esfmt: @@ -1098,7 +1131,8 @@ static int soc_camera_s_parm(struct file *file, void *fh, return -ENOIOCTLCMD; } -static int soc_camera_probe(struct soc_camera_device *icd); +static int soc_camera_probe(struct soc_camera_host *ici, + struct soc_camera_device *icd); /* So far this function cannot fail */ static void scan_add_host(struct soc_camera_host *ici) @@ -1107,12 +1141,20 @@ static void scan_add_host(struct soc_camera_host *ici) mutex_lock(&list_lock); - list_for_each_entry(icd, &devices, list) { + list_for_each_entry(icd, &devices, list) if (icd->iface == ici->nr) { + struct soc_camera_desc *sdesc = to_soc_camera_desc(icd); + struct soc_camera_subdev_desc *ssdd = &sdesc->subdev_desc; + + /* The camera could have been already on, try to reset */ + if (ssdd->reset) + ssdd->reset(icd->pdev); + icd->parent = ici->v4l2_dev.dev; - soc_camera_probe(icd); + + /* Ignore errors */ + soc_camera_probe(ici, icd); } - } mutex_unlock(&list_lock); } @@ -1125,6 +1167,7 @@ static int soc_camera_clk_enable(struct v4l2_clk *clk) { struct soc_camera_device *icd = clk->priv; struct soc_camera_host *ici; + int ret; if (!icd || !icd->parent) return -ENODEV; @@ -1138,7 +1181,10 @@ static int soc_camera_clk_enable(struct v4l2_clk *clk) * If a different client is currently being probed, the host will tell * you to go */ - return ici->ops->clock_start(ici); + mutex_lock(&ici->clk_lock); + ret = ici->ops->clock_start(ici); + mutex_unlock(&ici->clk_lock); + return ret; } static void soc_camera_clk_disable(struct v4l2_clk *clk) @@ -1151,7 +1197,9 @@ static void soc_camera_clk_disable(struct v4l2_clk *clk) ici = to_soc_camera_host(icd->parent); + mutex_lock(&ici->clk_lock); ici->ops->clock_stop(ici); + mutex_unlock(&ici->clk_lock); module_put(ici->ops->owner); } @@ -1168,18 +1216,117 @@ static const struct v4l2_clk_ops soc_camera_clk_ops = { .disable = soc_camera_clk_disable, }; +static int soc_camera_dyn_pdev(struct soc_camera_desc *sdesc, + struct soc_camera_async_client *sasc) +{ + struct platform_device *pdev; + int ret, i; + + mutex_lock(&list_lock); + i = find_first_zero_bit(device_map, MAP_MAX_NUM); + if (i < MAP_MAX_NUM) + set_bit(i, device_map); + mutex_unlock(&list_lock); + if (i >= MAP_MAX_NUM) + return -ENOMEM; + + pdev = platform_device_alloc("soc-camera-pdrv", i); + if (!pdev) + return -ENOMEM; + + ret = platform_device_add_data(pdev, sdesc, sizeof(*sdesc)); + if (ret < 0) { + platform_device_put(pdev); + return ret; + } + + sasc->pdev = pdev; + + return 0; +} + +static struct soc_camera_device *soc_camera_add_pdev(struct soc_camera_async_client *sasc) +{ + struct platform_device *pdev = sasc->pdev; + int ret; + + ret = platform_device_add(pdev); + if (ret < 0 || !pdev->dev.driver) + return NULL; + + return platform_get_drvdata(pdev); +} + +/* Locking: called with .host_lock held */ +static int soc_camera_probe_finish(struct soc_camera_device *icd) +{ + struct v4l2_subdev *sd = soc_camera_to_subdev(icd); + struct v4l2_mbus_framefmt mf; + int ret; + + sd->grp_id = soc_camera_grp_id(icd); + v4l2_set_subdev_hostdata(sd, icd); + + ret = v4l2_ctrl_add_handler(&icd->ctrl_handler, sd->ctrl_handler, NULL); + if (ret < 0) + return ret; + + ret = soc_camera_add_device(icd); + if (ret < 0) { + dev_err(icd->pdev, "Couldn't activate the camera: %d\n", ret); + return ret; + } + + /* At this point client .probe() should have run already */ + ret = soc_camera_init_user_formats(icd); + if (ret < 0) + goto eusrfmt; + + icd->field = V4L2_FIELD_ANY; + + ret = soc_camera_video_start(icd); + if (ret < 0) + goto evidstart; + + /* Try to improve our guess of a reasonable window format */ + if (!v4l2_subdev_call(sd, video, g_mbus_fmt, &mf)) { + icd->user_width = mf.width; + icd->user_height = mf.height; + icd->colorspace = mf.colorspace; + icd->field = mf.field; + } + soc_camera_remove_device(icd); + + return 0; + +evidstart: + soc_camera_free_user_formats(icd); +eusrfmt: + soc_camera_remove_device(icd); + + return ret; +} + #ifdef CONFIG_I2C_BOARDINFO -static int soc_camera_init_i2c(struct soc_camera_device *icd, +static int soc_camera_i2c_init(struct soc_camera_device *icd, struct soc_camera_desc *sdesc) { struct i2c_client *client; - struct soc_camera_host *ici = to_soc_camera_host(icd->parent); + struct soc_camera_host *ici; struct soc_camera_host_desc *shd = &sdesc->host_desc; - struct i2c_adapter *adap = i2c_get_adapter(shd->i2c_adapter_id); + struct i2c_adapter *adap; struct v4l2_subdev *subdev; char clk_name[V4L2_SUBDEV_NAME_SIZE]; int ret; + /* First find out how we link the main client */ + if (icd->sasc) { + /* Async non-OF probing handled by the subdevice list */ + return -EPROBE_DEFER; + } + + ici = to_soc_camera_host(icd->parent); + adap = i2c_get_adapter(shd->i2c_adapter_id); if (!adap) { dev_err(icd->pdev, "Cannot get I2C adapter #%d. No driver?\n", shd->i2c_adapter_id); @@ -1212,42 +1359,202 @@ static int soc_camera_init_i2c(struct soc_camera_device *icd, return 0; ei2cnd: v4l2_clk_unregister(icd->clk); - icd->clk = NULL; eclkreg: + icd->clk = NULL; i2c_put_adapter(adap); return ret; } -static void soc_camera_free_i2c(struct soc_camera_device *icd) +static void soc_camera_i2c_free(struct soc_camera_device *icd) { struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd)); - struct i2c_adapter *adap = client->adapter; + struct i2c_adapter *adap; icd->control = NULL; + if (icd->sasc) + return; + + adap = client->adapter; v4l2_device_unregister_subdev(i2c_get_clientdata(client)); i2c_unregister_device(client); i2c_put_adapter(adap); v4l2_clk_unregister(icd->clk); icd->clk = NULL; } + +/* + * V4L2 asynchronous notifier callbacks. They are all called under a v4l2-async + * internal global mutex, therefore cannot race against other asynchronous + * events. Until notifier->complete() (soc_camera_async_complete()) is called, + * the video device node is not registered and no V4L fops can occur. Unloading + * of the host driver also calls a v4l2-async function, so also there we're + * protected. + */ +static int soc_camera_async_bound(struct v4l2_async_notifier *notifier, + struct v4l2_subdev *sd, + struct v4l2_async_subdev *asd) +{ + struct soc_camera_async_client *sasc = container_of(notifier, + struct soc_camera_async_client, notifier); + struct soc_camera_device *icd = platform_get_drvdata(sasc->pdev); + + if (asd == sasc->sensor && !WARN_ON(icd->control)) { + struct i2c_client *client = v4l2_get_subdevdata(sd); + + /* + * Only now we get subdevice-specific information like + * regulators, flags, callbacks, etc. + */ + if (client) { + struct soc_camera_desc *sdesc = to_soc_camera_desc(icd); + struct soc_camera_subdev_desc *ssdd = + soc_camera_i2c_to_desc(client); + if (ssdd) { + memcpy(&sdesc->subdev_desc, ssdd, + sizeof(sdesc->subdev_desc)); + if (ssdd->reset) + ssdd->reset(icd->pdev); + } + + icd->control = &client->dev; + } + } + + return 0; +} + +static void soc_camera_async_unbind(struct v4l2_async_notifier *notifier, + struct v4l2_subdev *sd, + struct v4l2_async_subdev *asd) +{ + struct soc_camera_async_client *sasc = container_of(notifier, + struct soc_camera_async_client, notifier); + struct soc_camera_device *icd = platform_get_drvdata(sasc->pdev); + + if (icd->clk) { + v4l2_clk_unregister(icd->clk); + icd->clk = NULL; + } +} + +static int soc_camera_async_complete(struct v4l2_async_notifier *notifier) +{ + struct soc_camera_async_client *sasc = container_of(notifier, + struct soc_camera_async_client, notifier); + struct soc_camera_device *icd = platform_get_drvdata(sasc->pdev); + + if (to_soc_camera_control(icd)) { + struct soc_camera_host *ici = to_soc_camera_host(icd->parent); + int ret; + + mutex_lock(&list_lock); + ret = soc_camera_probe(ici, icd); + mutex_unlock(&list_lock); + if (ret < 0) + return ret; + } + + return 0; +} + +static int scan_async_group(struct soc_camera_host *ici, + struct v4l2_async_subdev **asd, int size) +{ + struct soc_camera_async_subdev *sasd; + struct soc_camera_async_client *sasc; + struct soc_camera_device *icd; + struct soc_camera_desc sdesc = {.host_desc.bus_id = ici->nr,}; + char clk_name[V4L2_SUBDEV_NAME_SIZE]; + int ret, i; + + /* First look for a sensor */ + for (i = 0; i < size; i++) { + sasd = container_of(asd[i], struct soc_camera_async_subdev, asd); + if (sasd->role == SOCAM_SUBDEV_DATA_SOURCE) + break; + } + + if (i == size || asd[i]->bus_type != V4L2_ASYNC_BUS_I2C) { + /* All useless */ + dev_err(ici->v4l2_dev.dev, "No I2C data source found!\n"); + return -ENODEV; + } + + /* Or shall this be managed by the soc-camera device? */ + sasc = devm_kzalloc(ici->v4l2_dev.dev, sizeof(*sasc), GFP_KERNEL); + if (!sasc) + return -ENOMEM; + + /* HACK: just need a != NULL */ + sdesc.host_desc.board_info = ERR_PTR(-ENODATA); + + ret = soc_camera_dyn_pdev(&sdesc, sasc); + if (ret < 0) + return ret; + + sasc->sensor = &sasd->asd; + + icd = soc_camera_add_pdev(sasc); + if (!icd) { + platform_device_put(sasc->pdev); + return -ENOMEM; + } + + sasc->notifier.subdev = asd; + sasc->notifier.num_subdevs = size; + sasc->notifier.bound = soc_camera_async_bound; + sasc->notifier.unbind = soc_camera_async_unbind; + sasc->notifier.complete = soc_camera_async_complete; + + icd->sasc = sasc; + icd->parent = ici->v4l2_dev.dev; + + snprintf(clk_name, sizeof(clk_name), "%d-%04x", + sasd->asd.match.i2c.adapter_id, sasd->asd.match.i2c.address); + + icd->clk = v4l2_clk_register(&soc_camera_clk_ops, clk_name, "mclk", icd); + if (IS_ERR(icd->clk)) { + ret = PTR_ERR(icd->clk); + goto eclkreg; + } + + ret = v4l2_async_notifier_register(&ici->v4l2_dev, &sasc->notifier); + if (!ret) + return 0; + + v4l2_clk_unregister(icd->clk); +eclkreg: + icd->clk = NULL; + platform_device_unregister(sasc->pdev); + dev_err(ici->v4l2_dev.dev, "group probe failed: %d\n", ret); + + return ret; +} + +static void scan_async_host(struct soc_camera_host *ici) +{ + struct v4l2_async_subdev **asd; + int j; + + for (j = 0, asd = ici->asd; ici->asd_sizes[j]; j++) { + scan_async_group(ici, asd, ici->asd_sizes[j]); + asd += ici->asd_sizes[j]; + } +} #else -#define soc_camera_init_i2c(icd, sdesc) (-ENODEV) -#define soc_camera_free_i2c(icd) do {} while (0) +#define soc_camera_i2c_init(icd, sdesc) (-ENODEV) +#define soc_camera_i2c_free(icd) do {} while (0) +#define scan_async_host(ici) do {} while (0) #endif -static int soc_camera_video_start(struct soc_camera_device *icd); -static int video_dev_create(struct soc_camera_device *icd); /* Called during host-driver probe */ -static int soc_camera_probe(struct soc_camera_device *icd) +static int soc_camera_probe(struct soc_camera_host *ici, + struct soc_camera_device *icd) { - struct soc_camera_host *ici = to_soc_camera_host(icd->parent); struct soc_camera_desc *sdesc = to_soc_camera_desc(icd); struct soc_camera_host_desc *shd = &sdesc->host_desc; - struct soc_camera_subdev_desc *ssdd = &sdesc->subdev_desc; struct device *control = NULL; - struct v4l2_subdev *sd; - struct v4l2_mbus_framefmt mf; int ret; dev_info(icd->pdev, "Probing %s\n", dev_name(icd->pdev)); @@ -1263,10 +1570,6 @@ static int soc_camera_probe(struct soc_camera_device *icd) if (ret < 0) return ret; - /* The camera could have been already on, try to reset */ - if (ssdd->reset) - ssdd->reset(icd->pdev); - /* Must have icd->vdev before registering the device */ ret = video_dev_create(icd); if (ret < 0) @@ -1277,18 +1580,19 @@ static int soc_camera_probe(struct soc_camera_device *icd) * itself is protected against concurrent open() calls, but we also have * to protect our data also during client probing. */ - mutex_lock(&ici->host_lock); /* Non-i2c cameras, e.g., soc_camera_platform, have no board_info */ if (shd->board_info) { - ret = soc_camera_init_i2c(icd, sdesc); - if (ret < 0) + ret = soc_camera_i2c_init(icd, sdesc); + if (ret < 0 && ret != -EPROBE_DEFER) goto eadd; } else if (!shd->add_device || !shd->del_device) { ret = -EINVAL; goto eadd; } else { + mutex_lock(&ici->clk_lock); ret = ici->ops->clock_start(ici); + mutex_unlock(&ici->clk_lock); if (ret < 0) goto eadd; @@ -1312,57 +1616,33 @@ static int soc_camera_probe(struct soc_camera_device *icd) } } - sd = soc_camera_to_subdev(icd); - sd->grp_id = soc_camera_grp_id(icd); - v4l2_set_subdev_hostdata(sd, icd); - - ret = v4l2_ctrl_add_handler(&icd->ctrl_handler, sd->ctrl_handler, NULL); - if (ret < 0) - goto ectrl; - - /* At this point client .probe() should have run already */ - ret = soc_camera_init_user_formats(icd); - if (ret < 0) - goto eiufmt; - - icd->field = V4L2_FIELD_ANY; - - ret = soc_camera_video_start(icd); - if (ret < 0) - goto evidstart; - - /* Try to improve our guess of a reasonable window format */ - if (!v4l2_subdev_call(sd, video, g_mbus_fmt, &mf)) { - icd->user_width = mf.width; - icd->user_height = mf.height; - icd->colorspace = mf.colorspace; - icd->field = mf.field; - } - - if (!shd->board_info) - ici->ops->clock_stop(ici); - + mutex_lock(&ici->host_lock); + ret = soc_camera_probe_finish(icd); mutex_unlock(&ici->host_lock); + if (ret < 0) + goto efinish; return 0; -evidstart: - soc_camera_free_user_formats(icd); -eiufmt: -ectrl: +efinish: if (shd->board_info) { - soc_camera_free_i2c(icd); + soc_camera_i2c_free(icd); } else { shd->del_device(icd); module_put(control->driver->owner); enodrv: eadddev: + mutex_lock(&ici->clk_lock); ici->ops->clock_stop(ici); + mutex_unlock(&ici->clk_lock); } eadd: video_device_release(icd->vdev); icd->vdev = NULL; - mutex_unlock(&ici->host_lock); + if (icd->vdev) { + video_device_release(icd->vdev); + icd->vdev = NULL; + } evdc: v4l2_ctrl_handler_free(&icd->ctrl_handler); return ret; @@ -1370,15 +1650,15 @@ evdc: /* * This is called on device_unregister, which only means we have to disconnect - * from the host, but not remove ourselves from the device list + * from the host, but not remove ourselves from the device list. With + * asynchronous client probing this can also be called without + * soc_camera_probe_finish() having run. Careful with clean up. */ static int soc_camera_remove(struct soc_camera_device *icd) { struct soc_camera_desc *sdesc = to_soc_camera_desc(icd); struct video_device *vdev = icd->vdev; - BUG_ON(!icd->parent); - v4l2_ctrl_handler_free(&icd->ctrl_handler); if (vdev) { video_unregister_device(vdev); @@ -1386,15 +1666,27 @@ static int soc_camera_remove(struct soc_camera_device *icd) } if (sdesc->host_desc.board_info) { - soc_camera_free_i2c(icd); + soc_camera_i2c_free(icd); } else { - struct device_driver *drv = to_soc_camera_control(icd)->driver; + struct device *dev = to_soc_camera_control(icd); + struct device_driver *drv = dev ? dev->driver : NULL; if (drv) { sdesc->host_desc.del_device(icd); module_put(drv->owner); } } - soc_camera_free_user_formats(icd); + + if (icd->num_user_formats) + soc_camera_free_user_formats(icd); + + if (icd->clk) { + /* For the synchronous case */ + v4l2_clk_unregister(icd->clk); + icd->clk = NULL; + } + + if (icd->sasc) + platform_device_unregister(icd->sasc->pdev); return 0; } @@ -1505,7 +1797,18 @@ int soc_camera_host_register(struct soc_camera_host *ici) mutex_unlock(&list_lock); mutex_init(&ici->host_lock); - scan_add_host(ici); + mutex_init(&ici->clk_lock); + + if (ici->asd_sizes) + /* + * No OF, host with a list of subdevices. Don't try to mix + * modes by initialising some groups statically and some + * dynamically! + */ + scan_async_host(ici); + else + /* Legacy: static platform devices from board data */ + scan_add_host(ici); return 0; @@ -1518,13 +1821,30 @@ EXPORT_SYMBOL(soc_camera_host_register); /* Unregister all clients! */ void soc_camera_host_unregister(struct soc_camera_host *ici) { - struct soc_camera_device *icd; + struct soc_camera_device *icd, *tmp; + struct soc_camera_async_client *sasc; + LIST_HEAD(notifiers); + + mutex_lock(&list_lock); + list_del(&ici->list); + list_for_each_entry(icd, &devices, list) + if (icd->iface == ici->nr && icd->sasc) { + /* as long as we hold the device, sasc won't be freed */ + get_device(icd->pdev); + list_add(&icd->sasc->list, ¬ifiers); + } + mutex_unlock(&list_lock); + + list_for_each_entry(sasc, ¬ifiers, list) { + /* Must call unlocked to avoid AB-BA dead-lock */ + v4l2_async_notifier_unregister(&sasc->notifier); + put_device(&sasc->pdev->dev); + } mutex_lock(&list_lock); - list_del(&ici->list); - list_for_each_entry(icd, &devices, list) - if (icd->iface == ici->nr && to_soc_camera_control(icd)) + list_for_each_entry_safe(icd, tmp, &devices, list) + if (icd->iface == ici->nr) soc_camera_remove(icd); mutex_unlock(&list_lock); @@ -1539,6 +1859,7 @@ static int soc_camera_device_register(struct soc_camera_device *icd) struct soc_camera_device *ix; int num = -1, i; + mutex_lock(&list_lock); for (i = 0; i < 256 && num < 0; i++) { num = i; /* Check if this index is available on this interface */ @@ -1550,18 +1871,34 @@ static int soc_camera_device_register(struct soc_camera_device *icd) } } - if (num < 0) + if (num < 0) { /* * ok, we have 256 cameras on this host... * man, stay reasonable... */ + mutex_unlock(&list_lock); return -ENOMEM; + } icd->devnum = num; icd->use_count = 0; icd->host_priv = NULL; + /* + * Dynamically allocated devices set the bit earlier, but it doesn't hurt setting + * it again + */ + i = to_platform_device(icd->pdev)->id; + if (i < 0) + /* One static (legacy) soc-camera platform device */ + i = 0; + if (i >= MAP_MAX_NUM) { + mutex_unlock(&list_lock); + return -EBUSY; + } + set_bit(i, device_map); list_add_tail(&icd->list, &devices); + mutex_unlock(&list_lock); return 0; } @@ -1655,6 +1992,12 @@ static int soc_camera_pdrv_probe(struct platform_device *pdev) if (!icd) return -ENOMEM; + /* + * In the asynchronous case ssdd->num_regulators == 0 yet, so, the below + * regulator allocation is a dummy. They will be really requested later + * in soc_camera_async_bind(). Also note, that in that case regulators + * are attached to the I2C device and not to the camera platform device. + */ ret = devm_regulator_bulk_get(&pdev->dev, ssdd->num_regulators, ssdd->regulators); if (ret < 0) @@ -1679,11 +2022,25 @@ static int soc_camera_pdrv_probe(struct platform_device *pdev) static int soc_camera_pdrv_remove(struct platform_device *pdev) { struct soc_camera_device *icd = platform_get_drvdata(pdev); + int i; if (!icd) return -EINVAL; - list_del(&icd->list); + i = pdev->id; + if (i < 0) + i = 0; + + /* + * In synchronous mode with static platform devices this is called in a + * loop from drivers/base/dd.c::driver_detach(), no parallel execution, + * no need to lock. In asynchronous case the caller - + * soc_camera_host_unregister() - already holds the lock + */ + if (test_bit(i, device_map)) { + clear_bit(i, device_map); + list_del(&icd->list); + } return 0; } diff --git a/include/media/soc_camera.h b/include/media/soc_camera.h index f582323fafb7..906ed98c6e95 100644 --- a/include/media/soc_camera.h +++ b/include/media/soc_camera.h @@ -19,11 +19,13 @@ #include #include #include +#include #include #include struct file; struct soc_camera_desc; +struct soc_camera_async_client; struct soc_camera_device { struct list_head list; /* list of all registered devices */ @@ -50,6 +52,9 @@ struct soc_camera_device { int use_count; struct file *streamer; /* stream owner */ struct v4l2_clk *clk; + /* Asynchronous subdevice management */ + struct soc_camera_async_client *sasc; + /* video buffer queue */ union { struct videobuf_queue vb_vidq; struct vb2_queue vb2_vidq; @@ -59,16 +64,30 @@ struct soc_camera_device { /* Host supports programmable stride */ #define SOCAM_HOST_CAP_STRIDE (1 << 0) +enum soc_camera_subdev_role { + SOCAM_SUBDEV_DATA_SOURCE = 1, + SOCAM_SUBDEV_DATA_SINK, + SOCAM_SUBDEV_DATA_PROCESSOR, +}; + +struct soc_camera_async_subdev { + struct v4l2_async_subdev asd; + enum soc_camera_subdev_role role; +}; + struct soc_camera_host { struct v4l2_device v4l2_dev; struct list_head list; - struct mutex host_lock; /* Protect pipeline modifications */ + struct mutex host_lock; /* Main synchronisation lock */ + struct mutex clk_lock; /* Protect pipeline modifications */ unsigned char nr; /* Host number */ u32 capabilities; struct soc_camera_device *icd; /* Currently attached client */ void *priv; const char *drv_name; struct soc_camera_host_ops *ops; + struct v4l2_async_subdev **asd; /* Flat array, arranged in groups */ + int *asd_sizes; /* 0-terminated array of asd group sizes */ }; struct soc_camera_host_ops { @@ -161,6 +180,7 @@ struct soc_camera_host_desc { }; /* + * Platform data for "soc-camera-pdrv" * This MUST be kept binary-identical to struct soc_camera_link below, until * it is completely replaced by this one, after which we can split it into its * two components. @@ -326,6 +346,7 @@ static inline void soc_camera_limit_side(int *start, int *length, unsigned long soc_camera_apply_board_flags(struct soc_camera_subdev_desc *ssdd, const struct v4l2_mbus_config *cfg); +int soc_camera_power_init(struct device *dev, struct soc_camera_subdev_desc *ssdd); int soc_camera_power_on(struct device *dev, struct soc_camera_subdev_desc *ssdd, struct v4l2_clk *clk); int soc_camera_power_off(struct device *dev, struct soc_camera_subdev_desc *ssdd, From 676d2d4f08ccdfab45867aaf1edeeb923b45bdc1 Mon Sep 17 00:00:00 2001 From: Guennadi Liakhovetski Date: Thu, 3 Jan 2013 15:06:35 -0300 Subject: [PATCH 0466/1048] [media] sh_mobile_ceu_camera: add asynchronous subdevice probing support Use the v4l2-async API to support asynchronous subdevice probing, including the CSI2 subdevice. Synchronous probing is still supported too. Signed-off-by: Guennadi Liakhovetski Acked-by: Hans Verkuil Acked-by: Laurent Pinchart Signed-off-by: Mauro Carvalho Chehab --- .../soc_camera/sh_mobile_ceu_camera.c | 134 ++++++++++----- .../platform/soc_camera/sh_mobile_csi2.c | 153 ++++++++++-------- include/media/sh_mobile_ceu.h | 2 + include/media/sh_mobile_csi2.h | 2 +- 4 files changed, 190 insertions(+), 101 deletions(-) diff --git a/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c b/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c index b0f0995fc80b..d1b410b75cc1 100644 --- a/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c +++ b/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c @@ -36,6 +36,7 @@ #include #include +#include #include #include #include @@ -96,6 +97,10 @@ struct sh_mobile_ceu_buffer { struct sh_mobile_ceu_dev { struct soc_camera_host ici; + /* Asynchronous CSI2 linking */ + struct v4l2_async_subdev *csi2_asd; + struct v4l2_subdev *csi2_sd; + /* Synchronous probing compatibility */ struct platform_device *csi2_pdev; unsigned int irq; @@ -185,7 +190,6 @@ static int sh_mobile_ceu_soft_reset(struct sh_mobile_ceu_dev *pcdev) udelay(1); } - if (2 != success) { dev_warn(pcdev->ici.v4l2_dev.dev, "soft reset time out\n"); return -EIO; @@ -534,16 +538,29 @@ static struct v4l2_subdev *find_csi2(struct sh_mobile_ceu_dev *pcdev) { struct v4l2_subdev *sd; - if (!pcdev->csi2_pdev) - return NULL; + if (pcdev->csi2_sd) + return pcdev->csi2_sd; - v4l2_device_for_each_subdev(sd, &pcdev->ici.v4l2_dev) - if (&pcdev->csi2_pdev->dev == v4l2_get_subdevdata(sd)) - return sd; + if (pcdev->csi2_asd) { + char name[] = "sh-mobile-csi2"; + v4l2_device_for_each_subdev(sd, &pcdev->ici.v4l2_dev) + if (!strncmp(name, sd->name, sizeof(name) - 1)) { + pcdev->csi2_sd = sd; + return sd; + } + } return NULL; } +static struct v4l2_subdev *csi2_subdev(struct sh_mobile_ceu_dev *pcdev, + struct soc_camera_device *icd) +{ + struct v4l2_subdev *sd = pcdev->csi2_sd; + + return sd && sd->grp_id == soc_camera_grp_id(icd) ? sd : NULL; +} + static int sh_mobile_ceu_add_device(struct soc_camera_device *icd) { struct soc_camera_host *ici = to_soc_camera_host(icd->parent); @@ -564,12 +581,12 @@ static int sh_mobile_ceu_add_device(struct soc_camera_device *icd) * -ENODEV is special: either csi2_sd == NULL or the CSI-2 driver * has not found this soc-camera device among its clients */ - if (ret == -ENODEV && csi2_sd) + if (csi2_sd && ret == -ENODEV) csi2_sd->grp_id = 0; dev_info(icd->parent, - "SuperH Mobile CEU driver attached to camera %d\n", - icd->devnum); + "SuperH Mobile CEU%s driver attached to camera %d\n", + csi2_sd && csi2_sd->grp_id ? "/CSI-2" : "", icd->devnum); return 0; } @@ -585,8 +602,6 @@ static void sh_mobile_ceu_remove_device(struct soc_camera_device *icd) icd->devnum); v4l2_subdev_call(csi2_sd, core, s_power, 0); - if (csi2_sd) - csi2_sd->grp_id = 0; } /* Called with .host_lock held */ @@ -708,7 +723,7 @@ static void sh_mobile_ceu_set_rect(struct soc_camera_device *icd) } /* CSI2 special configuration */ - if (pcdev->csi2_pdev) { + if (csi2_subdev(pcdev, icd)) { in_width = ((in_width - 2) * 2); left_offset *= 2; } @@ -765,13 +780,7 @@ static void capture_restore(struct sh_mobile_ceu_dev *pcdev, u32 capsr) static struct v4l2_subdev *find_bus_subdev(struct sh_mobile_ceu_dev *pcdev, struct soc_camera_device *icd) { - if (pcdev->csi2_pdev) { - struct v4l2_subdev *csi2_sd = find_csi2(pcdev); - if (csi2_sd && csi2_sd->grp_id == soc_camera_grp_id(icd)) - return csi2_sd; - } - - return soc_camera_to_subdev(icd); + return csi2_subdev(pcdev, icd) ? : soc_camera_to_subdev(icd); } #define CEU_BUS_FLAGS (V4L2_MBUS_MASTER | \ @@ -875,7 +884,7 @@ static int sh_mobile_ceu_set_bus_param(struct soc_camera_device *icd) value |= common_flags & V4L2_MBUS_VSYNC_ACTIVE_LOW ? 1 << 1 : 0; value |= common_flags & V4L2_MBUS_HSYNC_ACTIVE_LOW ? 1 << 0 : 0; - if (pcdev->csi2_pdev) /* CSI2 mode */ + if (csi2_subdev(pcdev, icd)) /* CSI2 mode */ value |= 3 << 12; else if (pcdev->is_16bit) value |= 1 << 12; @@ -1054,7 +1063,7 @@ static int sh_mobile_ceu_get_formats(struct soc_camera_device *icd, unsigned int return 0; } - if (!pcdev->pdata || !pcdev->pdata->csi2) { + if (!csi2_subdev(pcdev, icd)) { /* Are there any restrictions in the CSI-2 case? */ ret = sh_mobile_ceu_try_bus_param(icd, fmt->bits_per_sample); if (ret < 0) @@ -2084,7 +2093,7 @@ static int sh_mobile_ceu_probe(struct platform_device *pdev) struct resource *res; void __iomem *base; unsigned int irq; - int err = 0; + int err, i; struct bus_wait wait = { .completion = COMPLETION_INITIALIZER_ONSTACK(wait.completion), .notifier.notifier_call = bus_notify, @@ -2188,31 +2197,60 @@ static int sh_mobile_ceu_probe(struct platform_device *pdev) goto exit_free_clk; } - err = soc_camera_host_register(&pcdev->ici); - if (err) - goto exit_free_ctx; + if (pcdev->pdata && pcdev->pdata->asd_sizes) { + struct v4l2_async_subdev **asd; + char name[] = "sh-mobile-csi2"; + int j; - /* CSI2 interfacing */ + /* + * CSI2 interfacing: several groups can use CSI2, pick up the + * first one + */ + asd = pcdev->pdata->asd; + for (j = 0; pcdev->pdata->asd_sizes[j]; j++) { + for (i = 0; i < pcdev->pdata->asd_sizes[j]; i++, asd++) { + dev_dbg(&pdev->dev, "%s(): subdev #%d, type %u\n", + __func__, i, (*asd)->bus_type); + if ((*asd)->bus_type == V4L2_ASYNC_BUS_PLATFORM && + !strncmp(name, (*asd)->match.platform.name, + sizeof(name) - 1)) { + pcdev->csi2_asd = *asd; + break; + } + } + if (pcdev->csi2_asd) + break; + } + + pcdev->ici.asd = pcdev->pdata->asd; + pcdev->ici.asd_sizes = pcdev->pdata->asd_sizes; + } + + /* Legacy CSI2 interfacing */ csi2 = pcdev->pdata ? pcdev->pdata->csi2 : NULL; if (csi2) { + /* + * TODO: remove this once all users are converted to + * asynchronous CSI2 probing. If it has to be kept, csi2 + * platform device resources have to be added, using + * platform_device_add_resources() + */ struct platform_device *csi2_pdev = platform_device_alloc("sh-mobile-csi2", csi2->id); struct sh_csi2_pdata *csi2_pdata = csi2->platform_data; if (!csi2_pdev) { err = -ENOMEM; - goto exit_host_unregister; + goto exit_free_ctx; } pcdev->csi2_pdev = csi2_pdev; - err = platform_device_add_data(csi2_pdev, csi2_pdata, sizeof(*csi2_pdata)); + err = platform_device_add_data(csi2_pdev, csi2_pdata, + sizeof(*csi2_pdata)); if (err < 0) goto exit_pdev_put; - csi2_pdata = csi2_pdev->dev.platform_data; - csi2_pdata->v4l2_dev = &pcdev->ici.v4l2_dev; - csi2_pdev->resource = csi2->resource; csi2_pdev->num_resources = csi2->num_resources; @@ -2254,17 +2292,38 @@ static int sh_mobile_ceu_probe(struct platform_device *pdev) err = -ENODEV; goto exit_pdev_unregister; } + + pcdev->csi2_sd = platform_get_drvdata(csi2_pdev); + } + + err = soc_camera_host_register(&pcdev->ici); + if (err) + goto exit_csi2_unregister; + + if (csi2) { + err = v4l2_device_register_subdev(&pcdev->ici.v4l2_dev, + pcdev->csi2_sd); + dev_dbg(&pdev->dev, "%s(): ret(register_subdev) = %d\n", + __func__, err); + if (err < 0) + goto exit_host_unregister; + /* v4l2_device_register_subdev() took a reference too */ + module_put(pcdev->csi2_sd->owner); } return 0; -exit_pdev_unregister: - platform_device_del(pcdev->csi2_pdev); -exit_pdev_put: - pcdev->csi2_pdev->resource = NULL; - platform_device_put(pcdev->csi2_pdev); exit_host_unregister: soc_camera_host_unregister(&pcdev->ici); +exit_csi2_unregister: + if (csi2) { + module_put(pcdev->csi2_pdev->dev.driver->owner); +exit_pdev_unregister: + platform_device_del(pcdev->csi2_pdev); +exit_pdev_put: + pcdev->csi2_pdev->resource = NULL; + platform_device_put(pcdev->csi2_pdev); + } exit_free_ctx: vb2_dma_contig_cleanup_ctx(pcdev->alloc_ctx); exit_free_clk: @@ -2324,6 +2383,7 @@ MODULE_DEVICE_TABLE(of, sh_mobile_ceu_of_match); static struct platform_driver sh_mobile_ceu_driver = { .driver = { .name = "sh_mobile_ceu", + .owner = THIS_MODULE, .pm = &sh_mobile_ceu_dev_pm_ops, .of_match_table = sh_mobile_ceu_of_match, }, @@ -2349,5 +2409,5 @@ module_exit(sh_mobile_ceu_exit); MODULE_DESCRIPTION("SuperH Mobile CEU driver"); MODULE_AUTHOR("Magnus Damm"); MODULE_LICENSE("GPL"); -MODULE_VERSION("0.0.6"); +MODULE_VERSION("0.1.0"); MODULE_ALIAS("platform:sh_mobile_ceu"); diff --git a/drivers/media/platform/soc_camera/sh_mobile_csi2.c b/drivers/media/platform/soc_camera/sh_mobile_csi2.c index 13a1f8f13f65..05dd21a35d63 100644 --- a/drivers/media/platform/soc_camera/sh_mobile_csi2.c +++ b/drivers/media/platform/soc_camera/sh_mobile_csi2.c @@ -36,7 +36,6 @@ struct sh_csi2 { struct v4l2_subdev subdev; - struct list_head list; unsigned int irq; unsigned long mipi_flags; void __iomem *base; @@ -44,6 +43,8 @@ struct sh_csi2 { struct sh_csi2_client_config *client; }; +static void sh_csi2_hwinit(struct sh_csi2 *priv); + static int sh_csi2_try_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf) { @@ -132,10 +133,58 @@ static int sh_csi2_s_fmt(struct v4l2_subdev *sd, static int sh_csi2_g_mbus_config(struct v4l2_subdev *sd, struct v4l2_mbus_config *cfg) { - cfg->flags = V4L2_MBUS_PCLK_SAMPLE_RISING | - V4L2_MBUS_HSYNC_ACTIVE_HIGH | V4L2_MBUS_VSYNC_ACTIVE_HIGH | - V4L2_MBUS_MASTER | V4L2_MBUS_DATA_ACTIVE_HIGH; - cfg->type = V4L2_MBUS_PARALLEL; + struct sh_csi2 *priv = container_of(sd, struct sh_csi2, subdev); + + if (!priv->mipi_flags) { + struct soc_camera_device *icd = v4l2_get_subdev_hostdata(sd); + struct v4l2_subdev *client_sd = soc_camera_to_subdev(icd); + struct sh_csi2_pdata *pdata = priv->pdev->dev.platform_data; + unsigned long common_flags, csi2_flags; + struct v4l2_mbus_config client_cfg = {.type = V4L2_MBUS_CSI2,}; + int ret; + + /* Check if we can support this camera */ + csi2_flags = V4L2_MBUS_CSI2_CONTINUOUS_CLOCK | + V4L2_MBUS_CSI2_1_LANE; + + switch (pdata->type) { + case SH_CSI2C: + if (priv->client->lanes != 1) + csi2_flags |= V4L2_MBUS_CSI2_2_LANE; + break; + case SH_CSI2I: + switch (priv->client->lanes) { + default: + csi2_flags |= V4L2_MBUS_CSI2_4_LANE; + case 3: + csi2_flags |= V4L2_MBUS_CSI2_3_LANE; + case 2: + csi2_flags |= V4L2_MBUS_CSI2_2_LANE; + } + } + + ret = v4l2_subdev_call(client_sd, video, g_mbus_config, &client_cfg); + if (ret == -ENOIOCTLCMD) + common_flags = csi2_flags; + else if (!ret) + common_flags = soc_mbus_config_compatible(&client_cfg, + csi2_flags); + else + common_flags = 0; + + if (!common_flags) + return -EINVAL; + + /* All good: camera MIPI configuration supported */ + priv->mipi_flags = common_flags; + } + + if (cfg) { + cfg->flags = V4L2_MBUS_PCLK_SAMPLE_RISING | + V4L2_MBUS_HSYNC_ACTIVE_HIGH | V4L2_MBUS_VSYNC_ACTIVE_HIGH | + V4L2_MBUS_MASTER | V4L2_MBUS_DATA_ACTIVE_HIGH; + cfg->type = V4L2_MBUS_PARALLEL; + } return 0; } @@ -146,8 +195,17 @@ static int sh_csi2_s_mbus_config(struct v4l2_subdev *sd, struct sh_csi2 *priv = container_of(sd, struct sh_csi2, subdev); struct soc_camera_device *icd = v4l2_get_subdev_hostdata(sd); struct v4l2_subdev *client_sd = soc_camera_to_subdev(icd); - struct v4l2_mbus_config client_cfg = {.type = V4L2_MBUS_CSI2, - .flags = priv->mipi_flags}; + struct v4l2_mbus_config client_cfg = {.type = V4L2_MBUS_CSI2,}; + int ret = sh_csi2_g_mbus_config(sd, NULL); + + if (ret < 0) + return ret; + + pm_runtime_get_sync(&priv->pdev->dev); + + sh_csi2_hwinit(priv); + + client_cfg.flags = priv->mipi_flags; return v4l2_subdev_call(client_sd, video, s_mbus_config, &client_cfg); } @@ -202,19 +260,19 @@ static void sh_csi2_hwinit(struct sh_csi2 *priv) static int sh_csi2_client_connect(struct sh_csi2 *priv) { - struct sh_csi2_pdata *pdata = priv->pdev->dev.platform_data; - struct soc_camera_device *icd = v4l2_get_subdev_hostdata(&priv->subdev); - struct v4l2_subdev *client_sd = soc_camera_to_subdev(icd); struct device *dev = v4l2_get_subdevdata(&priv->subdev); - struct v4l2_mbus_config cfg; - unsigned long common_flags, csi2_flags; - int i, ret; + struct sh_csi2_pdata *pdata = dev->platform_data; + struct soc_camera_device *icd = v4l2_get_subdev_hostdata(&priv->subdev); + int i; if (priv->client) return -EBUSY; for (i = 0; i < pdata->num_clients; i++) - if (&pdata->clients[i].pdev->dev == icd->pdev) + if ((pdata->clients[i].pdev && + &pdata->clients[i].pdev->dev == icd->pdev) || + (icd->control && + strcmp(pdata->clients[i].name, dev_name(icd->control)))) break; dev_dbg(dev, "%s(%p): found #%d\n", __func__, dev, i); @@ -222,46 +280,8 @@ static int sh_csi2_client_connect(struct sh_csi2 *priv) if (i == pdata->num_clients) return -ENODEV; - /* Check if we can support this camera */ - csi2_flags = V4L2_MBUS_CSI2_CONTINUOUS_CLOCK | V4L2_MBUS_CSI2_1_LANE; - - switch (pdata->type) { - case SH_CSI2C: - if (pdata->clients[i].lanes != 1) - csi2_flags |= V4L2_MBUS_CSI2_2_LANE; - break; - case SH_CSI2I: - switch (pdata->clients[i].lanes) { - default: - csi2_flags |= V4L2_MBUS_CSI2_4_LANE; - case 3: - csi2_flags |= V4L2_MBUS_CSI2_3_LANE; - case 2: - csi2_flags |= V4L2_MBUS_CSI2_2_LANE; - } - } - - cfg.type = V4L2_MBUS_CSI2; - ret = v4l2_subdev_call(client_sd, video, g_mbus_config, &cfg); - if (ret == -ENOIOCTLCMD) - common_flags = csi2_flags; - else if (!ret) - common_flags = soc_mbus_config_compatible(&cfg, - csi2_flags); - else - common_flags = 0; - - if (!common_flags) - return -EINVAL; - - /* All good: camera MIPI configuration supported */ - priv->mipi_flags = common_flags; priv->client = pdata->clients + i; - pm_runtime_get_sync(dev); - - sh_csi2_hwinit(priv); - return 0; } @@ -304,11 +324,18 @@ static int sh_csi2_probe(struct platform_device *pdev) /* Platform data specify the PHY, lanes, ECC, CRC */ struct sh_csi2_pdata *pdata = pdev->dev.platform_data; + if (!pdata) + return -EINVAL; + + priv = devm_kzalloc(&pdev->dev, sizeof(struct sh_csi2), GFP_KERNEL); + if (!priv) + return -ENOMEM; + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); /* Interrupt unused so far */ irq = platform_get_irq(pdev, 0); - if (!res || (int)irq <= 0 || !pdata) { + if (!res || (int)irq <= 0) { dev_err(&pdev->dev, "Not enough CSI2 platform resources.\n"); return -ENODEV; } @@ -319,10 +346,6 @@ static int sh_csi2_probe(struct platform_device *pdev) return -EINVAL; } - priv = devm_kzalloc(&pdev->dev, sizeof(struct sh_csi2), GFP_KERNEL); - if (!priv) - return -ENOMEM; - priv->irq = irq; priv->base = devm_ioremap_resource(&pdev->dev, res); @@ -330,15 +353,17 @@ static int sh_csi2_probe(struct platform_device *pdev) return PTR_ERR(priv->base); priv->pdev = pdev; - platform_set_drvdata(pdev, priv); + priv->subdev.owner = THIS_MODULE; + priv->subdev.dev = &pdev->dev; + platform_set_drvdata(pdev, &priv->subdev); v4l2_subdev_init(&priv->subdev, &sh_csi2_subdev_ops); v4l2_set_subdevdata(&priv->subdev, &pdev->dev); snprintf(priv->subdev.name, V4L2_SUBDEV_NAME_SIZE, "%s.mipi-csi", - dev_name(pdata->v4l2_dev->dev)); - ret = v4l2_device_register_subdev(pdata->v4l2_dev, &priv->subdev); - dev_dbg(&pdev->dev, "%s(%p): ret(register_subdev) = %d\n", __func__, priv, ret); + dev_name(&pdev->dev)); + + ret = v4l2_async_register_subdev(&priv->subdev); if (ret < 0) return ret; @@ -351,9 +376,11 @@ static int sh_csi2_probe(struct platform_device *pdev) static int sh_csi2_remove(struct platform_device *pdev) { - struct sh_csi2 *priv = platform_get_drvdata(pdev); + struct v4l2_subdev *subdev = platform_get_drvdata(pdev); + struct sh_csi2 *priv = container_of(subdev, struct sh_csi2, subdev); - v4l2_device_unregister_subdev(&priv->subdev); + v4l2_async_unregister_subdev(&priv->subdev); + v4l2_device_unregister_subdev(subdev); pm_runtime_disable(&pdev->dev); return 0; diff --git a/include/media/sh_mobile_ceu.h b/include/media/sh_mobile_ceu.h index 6fdb6adf6b2b..8937241e5f37 100644 --- a/include/media/sh_mobile_ceu.h +++ b/include/media/sh_mobile_ceu.h @@ -22,6 +22,8 @@ struct sh_mobile_ceu_info { int max_width; int max_height; struct sh_mobile_ceu_companion *csi2; + struct v4l2_async_subdev **asd; /* Flat array, arranged in groups */ + int *asd_sizes; /* 0-terminated array pf asd group sizes */ }; #endif /* __ASM_SH_MOBILE_CEU_H__ */ diff --git a/include/media/sh_mobile_csi2.h b/include/media/sh_mobile_csi2.h index c586c4f7f16b..14030db51f13 100644 --- a/include/media/sh_mobile_csi2.h +++ b/include/media/sh_mobile_csi2.h @@ -33,6 +33,7 @@ struct sh_csi2_client_config { unsigned char lanes; /* bitmask[3:0] */ unsigned char channel; /* 0..3 */ struct platform_device *pdev; /* client platform device */ + const char *name; /* async matching: client name */ }; struct v4l2_device; @@ -42,7 +43,6 @@ struct sh_csi2_pdata { unsigned int flags; struct sh_csi2_client_config *clients; int num_clients; - struct v4l2_device *v4l2_dev; }; #endif From ee17608d6aa04a86e253a9130d6c6d00892f132b Mon Sep 17 00:00:00 2001 From: Guennadi Liakhovetski Date: Wed, 26 Dec 2012 13:13:46 -0300 Subject: [PATCH 0467/1048] [media] imx074: support asynchronous probing Both synchronous and asynchronous imx074 subdevice probing is supported by this patch. Signed-off-by: Guennadi Liakhovetski Acked-by: Hans Verkuil Acked-by: Laurent Pinchart Signed-off-by: Mauro Carvalho Chehab --- drivers/media/i2c/soc_camera/imx074.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/drivers/media/i2c/soc_camera/imx074.c b/drivers/media/i2c/soc_camera/imx074.c index 2d8367891801..1d384a371b41 100644 --- a/drivers/media/i2c/soc_camera/imx074.c +++ b/drivers/media/i2c/soc_camera/imx074.c @@ -18,6 +18,7 @@ #include #include +#include #include #include @@ -437,13 +438,24 @@ static int imx074_probe(struct i2c_client *client, priv->fmt = &imx074_colour_fmts[0]; priv->clk = v4l2_clk_get(&client->dev, "mclk"); - if (IS_ERR(priv->clk)) - return PTR_ERR(priv->clk); + if (IS_ERR(priv->clk)) { + dev_info(&client->dev, "Error %ld getting clock\n", PTR_ERR(priv->clk)); + return -EPROBE_DEFER; + } + + ret = soc_camera_power_init(&client->dev, ssdd); + if (ret < 0) + goto epwrinit; ret = imx074_video_probe(client); if (ret < 0) - v4l2_clk_put(priv->clk); + goto eprobe; + return v4l2_async_register_subdev(&priv->subdev); + +epwrinit: +eprobe: + v4l2_clk_put(priv->clk); return ret; } @@ -452,7 +464,9 @@ static int imx074_remove(struct i2c_client *client) struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client); struct imx074 *priv = to_imx074(client); + v4l2_async_unregister_subdev(&priv->subdev); v4l2_clk_put(priv->clk); + if (ssdd->free_bus) ssdd->free_bus(ssdd); From 8469ba39a6b77917e8879680aed17229bf72f263 Mon Sep 17 00:00:00 2001 From: Mike Marciniszyn Date: Thu, 30 May 2013 18:25:25 -0400 Subject: [PATCH 0468/1048] IB/qib: Add DCA support This patch adds DCA cache warming for systems that support DCA. The code uses cpu affinity notification to react to an affinity change from a user mode program like irqbalance and (re-)program the chip accordingly. This notification avoids reading the current cpu on every interrupt. Reviewed-by: Dean Luick Signed-off-by: Mike Marciniszyn [ Add Kconfig dependency on SMP && GENERIC_HARDIRQS to avoid failure to build due to undefined struct irq_affinity_notify. - Roland ] Signed-off-by: Roland Dreier --- drivers/infiniband/hw/qib/Kconfig | 8 + drivers/infiniband/hw/qib/qib.h | 13 + drivers/infiniband/hw/qib/qib_iba6120.c | 10 + drivers/infiniband/hw/qib/qib_iba7220.c | 10 + drivers/infiniband/hw/qib/qib_iba7322.c | 334 +++++++++++++++++++++++- drivers/infiniband/hw/qib/qib_init.c | 41 +++ 6 files changed, 404 insertions(+), 12 deletions(-) diff --git a/drivers/infiniband/hw/qib/Kconfig b/drivers/infiniband/hw/qib/Kconfig index 1e603a375069..d03ca4c1ff25 100644 --- a/drivers/infiniband/hw/qib/Kconfig +++ b/drivers/infiniband/hw/qib/Kconfig @@ -5,3 +5,11 @@ config INFINIBAND_QIB This is a low-level driver for Intel PCIe QLE InfiniBand host channel adapters. This driver does not support the Intel HyperTransport card (model QHT7140). + +config INFINIBAND_QIB_DCA + bool "QIB DCA support" + depends on INFINIBAND_QIB && DCA && SMP && GENERIC_HARDIRQS && !(INFINIBAND_QIB=y && DCA=m) + default y + ---help--- + Setting this enables DCA support on some Intel chip sets + with the iba7322 HCA. diff --git a/drivers/infiniband/hw/qib/qib.h b/drivers/infiniband/hw/qib/qib.h index 4d11575c2010..cecbd43f9212 100644 --- a/drivers/infiniband/hw/qib/qib.h +++ b/drivers/infiniband/hw/qib/qib.h @@ -428,9 +428,19 @@ struct qib_verbs_txreq { #define ACTIVITY_TIMER 5 #define MAX_NAME_SIZE 64 + +#ifdef CONFIG_INFINIBAND_QIB_DCA +struct qib_irq_notify; +#endif + struct qib_msix_entry { struct msix_entry msix; void *arg; +#ifdef CONFIG_INFINIBAND_QIB_DCA + int dca; + int rcv; + struct qib_irq_notify *notifier; +#endif char name[MAX_NAME_SIZE]; cpumask_var_t mask; }; @@ -828,6 +838,9 @@ struct qib_devdata { struct qib_ctxtdata *); void (*f_writescratch)(struct qib_devdata *, u32); int (*f_tempsense_rd)(struct qib_devdata *, int regnum); +#ifdef CONFIG_INFINIBAND_QIB_DCA + int (*f_notify_dca)(struct qib_devdata *, unsigned long event); +#endif char *boardname; /* human readable board info */ diff --git a/drivers/infiniband/hw/qib/qib_iba6120.c b/drivers/infiniband/hw/qib/qib_iba6120.c index 0232ae56b1fa..84e593d6007b 100644 --- a/drivers/infiniband/hw/qib/qib_iba6120.c +++ b/drivers/infiniband/hw/qib/qib_iba6120.c @@ -3464,6 +3464,13 @@ static int qib_6120_tempsense_rd(struct qib_devdata *dd, int regnum) return -ENXIO; } +#ifdef CONFIG_INFINIBAND_QIB_DCA +static int qib_6120_notify_dca(struct qib_devdata *dd, unsigned long event) +{ + return 0; +} +#endif + /* Dummy function, as 6120 boards never disable EEPROM Write */ static int qib_6120_eeprom_wen(struct qib_devdata *dd, int wen) { @@ -3539,6 +3546,9 @@ struct qib_devdata *qib_init_iba6120_funcs(struct pci_dev *pdev, dd->f_xgxs_reset = qib_6120_xgxs_reset; dd->f_writescratch = writescratch; dd->f_tempsense_rd = qib_6120_tempsense_rd; +#ifdef CONFIG_INFINIBAND_QIB_DCA + dd->f_notify_dca = qib_6120_notify_dca; +#endif /* * Do remaining pcie setup and save pcie values in dd. * Any error printing is already done by the init code. diff --git a/drivers/infiniband/hw/qib/qib_iba7220.c b/drivers/infiniband/hw/qib/qib_iba7220.c index 64d0ecb90cdc..454c2e7668fe 100644 --- a/drivers/infiniband/hw/qib/qib_iba7220.c +++ b/drivers/infiniband/hw/qib/qib_iba7220.c @@ -4513,6 +4513,13 @@ bail: return ret; } +#ifdef CONFIG_INFINIBAND_QIB_DCA +static int qib_7220_notify_dca(struct qib_devdata *dd, unsigned long event) +{ + return 0; +} +#endif + /* Dummy function, as 7220 boards never disable EEPROM Write */ static int qib_7220_eeprom_wen(struct qib_devdata *dd, int wen) { @@ -4587,6 +4594,9 @@ struct qib_devdata *qib_init_iba7220_funcs(struct pci_dev *pdev, dd->f_xgxs_reset = qib_7220_xgxs_reset; dd->f_writescratch = writescratch; dd->f_tempsense_rd = qib_7220_tempsense_rd; +#ifdef CONFIG_INFINIBAND_QIB_DCA + dd->f_notify_dca = qib_7220_notify_dca; +#endif /* * Do remaining pcie setup and save pcie values in dd. * Any error printing is already done by the init code. diff --git a/drivers/infiniband/hw/qib/qib_iba7322.c b/drivers/infiniband/hw/qib/qib_iba7322.c index 3f6b21e9dc11..46ffea033be0 100644 --- a/drivers/infiniband/hw/qib/qib_iba7322.c +++ b/drivers/infiniband/hw/qib/qib_iba7322.c @@ -44,6 +44,9 @@ #include #include #include +#ifdef CONFIG_INFINIBAND_QIB_DCA +#include +#endif #include "qib.h" #include "qib_7322_regs.h" @@ -519,6 +522,14 @@ static const u8 qib_7322_physportstate[0x20] = { [0x17] = IB_PHYSPORTSTATE_CFG_TRAIN }; +#ifdef CONFIG_INFINIBAND_QIB_DCA +struct qib_irq_notify { + int rcv; + void *arg; + struct irq_affinity_notify notify; +}; +#endif + struct qib_chip_specific { u64 __iomem *cregbase; u64 *cntrs; @@ -546,6 +557,12 @@ struct qib_chip_specific { u32 lastbuf_for_pio; u32 stay_in_freeze; u32 recovery_ports_initted; +#ifdef CONFIG_INFINIBAND_QIB_DCA + u32 dca_ctrl; + int rhdr_cpu[18]; + int sdma_cpu[2]; + u64 dca_rcvhdr_ctrl[5]; /* B, C, D, E, F */ +#endif struct qib_msix_entry *msix_entries; unsigned long *sendchkenable; unsigned long *sendgrhchk; @@ -642,28 +659,76 @@ static struct { irq_handler_t handler; int lsb; int port; /* 0 if not port-specific, else port # */ + int dca; } irq_table[] = { - { "", qib_7322intr, -1, 0 }, + { "", qib_7322intr, -1, 0, 0 }, { " (buf avail)", qib_7322bufavail, - SYM_LSB(IntStatus, SendBufAvail), 0 }, + SYM_LSB(IntStatus, SendBufAvail), 0, 0}, { " (sdma 0)", sdma_intr, - SYM_LSB(IntStatus, SDmaInt_0), 1 }, + SYM_LSB(IntStatus, SDmaInt_0), 1, 1 }, { " (sdma 1)", sdma_intr, - SYM_LSB(IntStatus, SDmaInt_1), 2 }, + SYM_LSB(IntStatus, SDmaInt_1), 2, 1 }, { " (sdmaI 0)", sdma_idle_intr, - SYM_LSB(IntStatus, SDmaIdleInt_0), 1 }, + SYM_LSB(IntStatus, SDmaIdleInt_0), 1, 1}, { " (sdmaI 1)", sdma_idle_intr, - SYM_LSB(IntStatus, SDmaIdleInt_1), 2 }, + SYM_LSB(IntStatus, SDmaIdleInt_1), 2, 1}, { " (sdmaP 0)", sdma_progress_intr, - SYM_LSB(IntStatus, SDmaProgressInt_0), 1 }, + SYM_LSB(IntStatus, SDmaProgressInt_0), 1, 1 }, { " (sdmaP 1)", sdma_progress_intr, - SYM_LSB(IntStatus, SDmaProgressInt_1), 2 }, + SYM_LSB(IntStatus, SDmaProgressInt_1), 2, 1 }, { " (sdmaC 0)", sdma_cleanup_intr, - SYM_LSB(IntStatus, SDmaCleanupDone_0), 1 }, + SYM_LSB(IntStatus, SDmaCleanupDone_0), 1, 0 }, { " (sdmaC 1)", sdma_cleanup_intr, - SYM_LSB(IntStatus, SDmaCleanupDone_1), 2 }, + SYM_LSB(IntStatus, SDmaCleanupDone_1), 2 , 0}, }; +#ifdef CONFIG_INFINIBAND_QIB_DCA + +static const struct dca_reg_map { + int shadow_inx; + int lsb; + u64 mask; + u16 regno; +} dca_rcvhdr_reg_map[] = { + { 0, SYM_LSB(DCACtrlB, RcvHdrq0DCAOPH), + ~SYM_MASK(DCACtrlB, RcvHdrq0DCAOPH) , KREG_IDX(DCACtrlB) }, + { 0, SYM_LSB(DCACtrlB, RcvHdrq1DCAOPH), + ~SYM_MASK(DCACtrlB, RcvHdrq1DCAOPH) , KREG_IDX(DCACtrlB) }, + { 0, SYM_LSB(DCACtrlB, RcvHdrq2DCAOPH), + ~SYM_MASK(DCACtrlB, RcvHdrq2DCAOPH) , KREG_IDX(DCACtrlB) }, + { 0, SYM_LSB(DCACtrlB, RcvHdrq3DCAOPH), + ~SYM_MASK(DCACtrlB, RcvHdrq3DCAOPH) , KREG_IDX(DCACtrlB) }, + { 1, SYM_LSB(DCACtrlC, RcvHdrq4DCAOPH), + ~SYM_MASK(DCACtrlC, RcvHdrq4DCAOPH) , KREG_IDX(DCACtrlC) }, + { 1, SYM_LSB(DCACtrlC, RcvHdrq5DCAOPH), + ~SYM_MASK(DCACtrlC, RcvHdrq5DCAOPH) , KREG_IDX(DCACtrlC) }, + { 1, SYM_LSB(DCACtrlC, RcvHdrq6DCAOPH), + ~SYM_MASK(DCACtrlC, RcvHdrq6DCAOPH) , KREG_IDX(DCACtrlC) }, + { 1, SYM_LSB(DCACtrlC, RcvHdrq7DCAOPH), + ~SYM_MASK(DCACtrlC, RcvHdrq7DCAOPH) , KREG_IDX(DCACtrlC) }, + { 2, SYM_LSB(DCACtrlD, RcvHdrq8DCAOPH), + ~SYM_MASK(DCACtrlD, RcvHdrq8DCAOPH) , KREG_IDX(DCACtrlD) }, + { 2, SYM_LSB(DCACtrlD, RcvHdrq9DCAOPH), + ~SYM_MASK(DCACtrlD, RcvHdrq9DCAOPH) , KREG_IDX(DCACtrlD) }, + { 2, SYM_LSB(DCACtrlD, RcvHdrq10DCAOPH), + ~SYM_MASK(DCACtrlD, RcvHdrq10DCAOPH) , KREG_IDX(DCACtrlD) }, + { 2, SYM_LSB(DCACtrlD, RcvHdrq11DCAOPH), + ~SYM_MASK(DCACtrlD, RcvHdrq11DCAOPH) , KREG_IDX(DCACtrlD) }, + { 3, SYM_LSB(DCACtrlE, RcvHdrq12DCAOPH), + ~SYM_MASK(DCACtrlE, RcvHdrq12DCAOPH) , KREG_IDX(DCACtrlE) }, + { 3, SYM_LSB(DCACtrlE, RcvHdrq13DCAOPH), + ~SYM_MASK(DCACtrlE, RcvHdrq13DCAOPH) , KREG_IDX(DCACtrlE) }, + { 3, SYM_LSB(DCACtrlE, RcvHdrq14DCAOPH), + ~SYM_MASK(DCACtrlE, RcvHdrq14DCAOPH) , KREG_IDX(DCACtrlE) }, + { 3, SYM_LSB(DCACtrlE, RcvHdrq15DCAOPH), + ~SYM_MASK(DCACtrlE, RcvHdrq15DCAOPH) , KREG_IDX(DCACtrlE) }, + { 4, SYM_LSB(DCACtrlF, RcvHdrq16DCAOPH), + ~SYM_MASK(DCACtrlF, RcvHdrq16DCAOPH) , KREG_IDX(DCACtrlF) }, + { 4, SYM_LSB(DCACtrlF, RcvHdrq17DCAOPH), + ~SYM_MASK(DCACtrlF, RcvHdrq17DCAOPH) , KREG_IDX(DCACtrlF) }, +}; +#endif + /* ibcctrl bits */ #define QLOGIC_IB_IBCC_LINKINITCMD_DISABLE 1 /* cycle through TS1/TS2 till OK */ @@ -686,6 +751,13 @@ static void write_7322_init_portregs(struct qib_pportdata *); static void setup_7322_link_recovery(struct qib_pportdata *, u32); static void check_7322_rxe_status(struct qib_pportdata *); static u32 __iomem *qib_7322_getsendbuf(struct qib_pportdata *, u64, u32 *); +#ifdef CONFIG_INFINIBAND_QIB_DCA +static void qib_setup_dca(struct qib_devdata *dd); +static void setup_dca_notifier(struct qib_devdata *dd, + struct qib_msix_entry *m); +static void reset_dca_notifier(struct qib_devdata *dd, + struct qib_msix_entry *m); +#endif /** * qib_read_ureg32 - read 32-bit virtualized per-context register @@ -2558,6 +2630,162 @@ static void qib_setup_7322_setextled(struct qib_pportdata *ppd, u32 on) qib_write_kreg_port(ppd, krp_rcvpktledcnt, ledblink); } +#ifdef CONFIG_INFINIBAND_QIB_DCA + +static int qib_7322_notify_dca(struct qib_devdata *dd, unsigned long event) +{ + switch (event) { + case DCA_PROVIDER_ADD: + if (dd->flags & QIB_DCA_ENABLED) + break; + if (!dca_add_requester(&dd->pcidev->dev)) { + qib_devinfo(dd->pcidev, "DCA enabled\n"); + dd->flags |= QIB_DCA_ENABLED; + qib_setup_dca(dd); + } + break; + case DCA_PROVIDER_REMOVE: + if (dd->flags & QIB_DCA_ENABLED) { + dca_remove_requester(&dd->pcidev->dev); + dd->flags &= ~QIB_DCA_ENABLED; + dd->cspec->dca_ctrl = 0; + qib_write_kreg(dd, KREG_IDX(DCACtrlA), + dd->cspec->dca_ctrl); + } + break; + } + return 0; +} + +static void qib_update_rhdrq_dca(struct qib_ctxtdata *rcd, int cpu) +{ + struct qib_devdata *dd = rcd->dd; + struct qib_chip_specific *cspec = dd->cspec; + + if (!(dd->flags & QIB_DCA_ENABLED)) + return; + if (cspec->rhdr_cpu[rcd->ctxt] != cpu) { + const struct dca_reg_map *rmp; + + cspec->rhdr_cpu[rcd->ctxt] = cpu; + rmp = &dca_rcvhdr_reg_map[rcd->ctxt]; + cspec->dca_rcvhdr_ctrl[rmp->shadow_inx] &= rmp->mask; + cspec->dca_rcvhdr_ctrl[rmp->shadow_inx] |= + (u64) dca3_get_tag(&dd->pcidev->dev, cpu) << rmp->lsb; + qib_devinfo(dd->pcidev, + "Ctxt %d cpu %d dca %llx\n", rcd->ctxt, cpu, + (long long) cspec->dca_rcvhdr_ctrl[rmp->shadow_inx]); + qib_write_kreg(dd, rmp->regno, + cspec->dca_rcvhdr_ctrl[rmp->shadow_inx]); + cspec->dca_ctrl |= SYM_MASK(DCACtrlA, RcvHdrqDCAEnable); + qib_write_kreg(dd, KREG_IDX(DCACtrlA), cspec->dca_ctrl); + } +} + +static void qib_update_sdma_dca(struct qib_pportdata *ppd, int cpu) +{ + struct qib_devdata *dd = ppd->dd; + struct qib_chip_specific *cspec = dd->cspec; + unsigned pidx = ppd->port - 1; + + if (!(dd->flags & QIB_DCA_ENABLED)) + return; + if (cspec->sdma_cpu[pidx] != cpu) { + cspec->sdma_cpu[pidx] = cpu; + cspec->dca_rcvhdr_ctrl[4] &= ~(ppd->hw_pidx ? + SYM_MASK(DCACtrlF, SendDma1DCAOPH) : + SYM_MASK(DCACtrlF, SendDma0DCAOPH)); + cspec->dca_rcvhdr_ctrl[4] |= + (u64) dca3_get_tag(&dd->pcidev->dev, cpu) << + (ppd->hw_pidx ? + SYM_LSB(DCACtrlF, SendDma1DCAOPH) : + SYM_LSB(DCACtrlF, SendDma0DCAOPH)); + qib_devinfo(dd->pcidev, + "sdma %d cpu %d dca %llx\n", ppd->hw_pidx, cpu, + (long long) cspec->dca_rcvhdr_ctrl[4]); + qib_write_kreg(dd, KREG_IDX(DCACtrlF), + cspec->dca_rcvhdr_ctrl[4]); + cspec->dca_ctrl |= ppd->hw_pidx ? + SYM_MASK(DCACtrlA, SendDMAHead1DCAEnable) : + SYM_MASK(DCACtrlA, SendDMAHead0DCAEnable); + qib_write_kreg(dd, KREG_IDX(DCACtrlA), cspec->dca_ctrl); + } +} + +static void qib_setup_dca(struct qib_devdata *dd) +{ + struct qib_chip_specific *cspec = dd->cspec; + int i; + + for (i = 0; i < ARRAY_SIZE(cspec->rhdr_cpu); i++) + cspec->rhdr_cpu[i] = -1; + for (i = 0; i < ARRAY_SIZE(cspec->sdma_cpu); i++) + cspec->sdma_cpu[i] = -1; + cspec->dca_rcvhdr_ctrl[0] = + (1ULL << SYM_LSB(DCACtrlB, RcvHdrq0DCAXfrCnt)) | + (1ULL << SYM_LSB(DCACtrlB, RcvHdrq1DCAXfrCnt)) | + (1ULL << SYM_LSB(DCACtrlB, RcvHdrq2DCAXfrCnt)) | + (1ULL << SYM_LSB(DCACtrlB, RcvHdrq3DCAXfrCnt)); + cspec->dca_rcvhdr_ctrl[1] = + (1ULL << SYM_LSB(DCACtrlC, RcvHdrq4DCAXfrCnt)) | + (1ULL << SYM_LSB(DCACtrlC, RcvHdrq5DCAXfrCnt)) | + (1ULL << SYM_LSB(DCACtrlC, RcvHdrq6DCAXfrCnt)) | + (1ULL << SYM_LSB(DCACtrlC, RcvHdrq7DCAXfrCnt)); + cspec->dca_rcvhdr_ctrl[2] = + (1ULL << SYM_LSB(DCACtrlD, RcvHdrq8DCAXfrCnt)) | + (1ULL << SYM_LSB(DCACtrlD, RcvHdrq9DCAXfrCnt)) | + (1ULL << SYM_LSB(DCACtrlD, RcvHdrq10DCAXfrCnt)) | + (1ULL << SYM_LSB(DCACtrlD, RcvHdrq11DCAXfrCnt)); + cspec->dca_rcvhdr_ctrl[3] = + (1ULL << SYM_LSB(DCACtrlE, RcvHdrq12DCAXfrCnt)) | + (1ULL << SYM_LSB(DCACtrlE, RcvHdrq13DCAXfrCnt)) | + (1ULL << SYM_LSB(DCACtrlE, RcvHdrq14DCAXfrCnt)) | + (1ULL << SYM_LSB(DCACtrlE, RcvHdrq15DCAXfrCnt)); + cspec->dca_rcvhdr_ctrl[4] = + (1ULL << SYM_LSB(DCACtrlF, RcvHdrq16DCAXfrCnt)) | + (1ULL << SYM_LSB(DCACtrlF, RcvHdrq17DCAXfrCnt)); + for (i = 0; i < ARRAY_SIZE(cspec->sdma_cpu); i++) + qib_write_kreg(dd, KREG_IDX(DCACtrlB) + i, + cspec->dca_rcvhdr_ctrl[i]); + for (i = 0; i < cspec->num_msix_entries; i++) + setup_dca_notifier(dd, &cspec->msix_entries[i]); +} + +static void qib_irq_notifier_notify(struct irq_affinity_notify *notify, + const cpumask_t *mask) +{ + struct qib_irq_notify *n = + container_of(notify, struct qib_irq_notify, notify); + int cpu = cpumask_first(mask); + + if (n->rcv) { + struct qib_ctxtdata *rcd = (struct qib_ctxtdata *)n->arg; + qib_update_rhdrq_dca(rcd, cpu); + } else { + struct qib_pportdata *ppd = (struct qib_pportdata *)n->arg; + qib_update_sdma_dca(ppd, cpu); + } +} + +static void qib_irq_notifier_release(struct kref *ref) +{ + struct qib_irq_notify *n = + container_of(ref, struct qib_irq_notify, notify.kref); + struct qib_devdata *dd; + + if (n->rcv) { + struct qib_ctxtdata *rcd = (struct qib_ctxtdata *)n->arg; + dd = rcd->dd; + } else { + struct qib_pportdata *ppd = (struct qib_pportdata *)n->arg; + dd = ppd->dd; + } + qib_devinfo(dd->pcidev, + "release on HCA notify 0x%p n 0x%p\n", ref, n); + kfree(n); +} +#endif + /* * Disable MSIx interrupt if enabled, call generic MSIx code * to cleanup, and clear pending MSIx interrupts. @@ -2575,6 +2803,9 @@ static void qib_7322_nomsix(struct qib_devdata *dd) dd->cspec->num_msix_entries = 0; for (i = 0; i < n; i++) { +#ifdef CONFIG_INFINIBAND_QIB_DCA + reset_dca_notifier(dd, &dd->cspec->msix_entries[i]); +#endif irq_set_affinity_hint( dd->cspec->msix_entries[i].msix.vector, NULL); free_cpumask_var(dd->cspec->msix_entries[i].mask); @@ -2602,6 +2833,15 @@ static void qib_setup_7322_cleanup(struct qib_devdata *dd) { int i; +#ifdef CONFIG_INFINIBAND_QIB_DCA + if (dd->flags & QIB_DCA_ENABLED) { + dca_remove_requester(&dd->pcidev->dev); + dd->flags &= ~QIB_DCA_ENABLED; + dd->cspec->dca_ctrl = 0; + qib_write_kreg(dd, KREG_IDX(DCACtrlA), dd->cspec->dca_ctrl); + } +#endif + qib_7322_free_irq(dd); kfree(dd->cspec->cntrs); kfree(dd->cspec->sendchkenable); @@ -3068,6 +3308,53 @@ static irqreturn_t sdma_cleanup_intr(int irq, void *data) return IRQ_HANDLED; } +#ifdef CONFIG_INFINIBAND_QIB_DCA + +static void reset_dca_notifier(struct qib_devdata *dd, struct qib_msix_entry *m) +{ + if (!m->dca) + return; + qib_devinfo(dd->pcidev, + "Disabling notifier on HCA %d irq %d\n", + dd->unit, + m->msix.vector); + irq_set_affinity_notifier( + m->msix.vector, + NULL); + m->notifier = NULL; +} + +static void setup_dca_notifier(struct qib_devdata *dd, struct qib_msix_entry *m) +{ + struct qib_irq_notify *n; + + if (!m->dca) + return; + n = kzalloc(sizeof(*n), GFP_KERNEL); + if (n) { + int ret; + + m->notifier = n; + n->notify.irq = m->msix.vector; + n->notify.notify = qib_irq_notifier_notify; + n->notify.release = qib_irq_notifier_release; + n->arg = m->arg; + n->rcv = m->rcv; + qib_devinfo(dd->pcidev, + "set notifier irq %d rcv %d notify %p\n", + n->notify.irq, n->rcv, &n->notify); + ret = irq_set_affinity_notifier( + n->notify.irq, + &n->notify); + if (ret) { + m->notifier = NULL; + kfree(n); + } + } +} + +#endif + /* * Set up our chip-specific interrupt handler. * The interrupt type has already been setup, so @@ -3149,6 +3436,9 @@ try_intx: void *arg; u64 val; int lsb, reg, sh; +#ifdef CONFIG_INFINIBAND_QIB_DCA + int dca = 0; +#endif dd->cspec->msix_entries[msixnum]. name[sizeof(dd->cspec->msix_entries[msixnum].name) - 1] @@ -3161,6 +3451,9 @@ try_intx: arg = dd->pport + irq_table[i].port - 1; } else arg = dd; +#ifdef CONFIG_INFINIBAND_QIB_DCA + dca = irq_table[i].dca; +#endif lsb = irq_table[i].lsb; handler = irq_table[i].handler; snprintf(dd->cspec->msix_entries[msixnum].name, @@ -3178,6 +3471,9 @@ try_intx: continue; if (qib_krcvq01_no_msi && ctxt < 2) continue; +#ifdef CONFIG_INFINIBAND_QIB_DCA + dca = 1; +#endif lsb = QIB_I_RCVAVAIL_LSB + ctxt; handler = qib_7322pintr; snprintf(dd->cspec->msix_entries[msixnum].name, @@ -3203,6 +3499,11 @@ try_intx: goto try_intx; } dd->cspec->msix_entries[msixnum].arg = arg; +#ifdef CONFIG_INFINIBAND_QIB_DCA + dd->cspec->msix_entries[msixnum].dca = dca; + dd->cspec->msix_entries[msixnum].rcv = + handler == qib_7322pintr; +#endif if (lsb >= 0) { reg = lsb / IBA7322_REDIRECT_VEC_PER_REG; sh = (lsb % IBA7322_REDIRECT_VEC_PER_REG) * @@ -6885,6 +7186,9 @@ struct qib_devdata *qib_init_iba7322_funcs(struct pci_dev *pdev, dd->f_sdma_init_early = qib_7322_sdma_init_early; dd->f_writescratch = writescratch; dd->f_tempsense_rd = qib_7322_tempsense_rd; +#ifdef CONFIG_INFINIBAND_QIB_DCA + dd->f_notify_dca = qib_7322_notify_dca; +#endif /* * Do remaining PCIe setup and save PCIe values in dd. * Any error printing is already done by the init code. @@ -6921,7 +7225,7 @@ struct qib_devdata *qib_init_iba7322_funcs(struct pci_dev *pdev, actual_cnt -= dd->num_pports; tabsize = actual_cnt; - dd->cspec->msix_entries = kmalloc(tabsize * + dd->cspec->msix_entries = kzalloc(tabsize * sizeof(struct qib_msix_entry), GFP_KERNEL); if (!dd->cspec->msix_entries) { qib_dev_err(dd, "No memory for MSIx table\n"); @@ -6941,7 +7245,13 @@ struct qib_devdata *qib_init_iba7322_funcs(struct pci_dev *pdev, /* clear diagctrl register, in case diags were running and crashed */ qib_write_kreg(dd, kr_hwdiagctrl, 0); - +#ifdef CONFIG_INFINIBAND_QIB_DCA + if (!dca_add_requester(&pdev->dev)) { + qib_devinfo(dd->pcidev, "DCA enabled\n"); + dd->flags |= QIB_DCA_ENABLED; + qib_setup_dca(dd); + } +#endif goto bail; bail_cleanup: diff --git a/drivers/infiniband/hw/qib/qib_init.c b/drivers/infiniband/hw/qib/qib_init.c index 173f805790da..4b64c885fa0d 100644 --- a/drivers/infiniband/hw/qib/qib_init.c +++ b/drivers/infiniband/hw/qib/qib_init.c @@ -39,6 +39,9 @@ #include #include #include +#ifdef CONFIG_INFINIBAND_QIB_DCA +#include +#endif #include "qib.h" #include "qib_common.h" @@ -1158,6 +1161,35 @@ struct pci_driver qib_driver = { .err_handler = &qib_pci_err_handler, }; +#ifdef CONFIG_INFINIBAND_QIB_DCA + +static int qib_notify_dca(struct notifier_block *, unsigned long, void *); +static struct notifier_block dca_notifier = { + .notifier_call = qib_notify_dca, + .next = NULL, + .priority = 0 +}; + +static int qib_notify_dca_device(struct device *device, void *data) +{ + struct qib_devdata *dd = dev_get_drvdata(device); + unsigned long event = *(unsigned long *)data; + + return dd->f_notify_dca(dd, event); +} + +static int qib_notify_dca(struct notifier_block *nb, unsigned long event, + void *p) +{ + int rval; + + rval = driver_for_each_device(&qib_driver.driver, NULL, + &event, qib_notify_dca_device); + return rval ? NOTIFY_BAD : NOTIFY_DONE; +} + +#endif + /* * Do all the generic driver unit- and chip-independent memory * allocation and initialization. @@ -1182,6 +1214,9 @@ static int __init qlogic_ib_init(void) */ idr_init(&qib_unit_table); +#ifdef CONFIG_INFINIBAND_QIB_DCA + dca_register_notify(&dca_notifier); +#endif ret = pci_register_driver(&qib_driver); if (ret < 0) { pr_err("Unable to register driver: error %d\n", -ret); @@ -1194,6 +1229,9 @@ static int __init qlogic_ib_init(void) goto bail; /* all OK */ bail_unit: +#ifdef CONFIG_INFINIBAND_QIB_DCA + dca_unregister_notify(&dca_notifier); +#endif idr_destroy(&qib_unit_table); destroy_workqueue(qib_cq_wq); bail_dev: @@ -1217,6 +1255,9 @@ static void __exit qlogic_ib_cleanup(void) "Unable to cleanup counter filesystem: error %d\n", -ret); +#ifdef CONFIG_INFINIBAND_QIB_DCA + dca_unregister_notify(&dca_notifier); +#endif pci_unregister_driver(&qib_driver); destroy_workqueue(qib_cq_wq); From f7cf9a618b48212394c07b169864d20beb23b8e5 Mon Sep 17 00:00:00 2001 From: Mike Marciniszyn Date: Sat, 15 Jun 2013 17:06:58 -0400 Subject: [PATCH 0469/1048] IB/qib: Remove atomic_inc_not_zero() from QP RCU Follow Documentation/RCU/rcuref.txt guidance in removing atomic_inc_not_zero() from QP RCU implementation. This patch also removes an unneeded synchronize_rcu() in the add path. Reviewed-by: Dean Luick Signed-off-by: Mike Marciniszyn Signed-off-by: Roland Dreier --- drivers/infiniband/hw/qib/qib_qp.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/drivers/infiniband/hw/qib/qib_qp.c b/drivers/infiniband/hw/qib/qib_qp.c index a6a2cc2ba260..c1f573a331c7 100644 --- a/drivers/infiniband/hw/qib/qib_qp.c +++ b/drivers/infiniband/hw/qib/qib_qp.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012 Intel Corporation. All rights reserved. + * Copyright (c) 2012, 2013 Intel Corporation. All rights reserved. * Copyright (c) 2006 - 2012 QLogic Corporation. * All rights reserved. * Copyright (c) 2005, 2006 PathScale, Inc. All rights reserved. * @@ -222,8 +222,8 @@ static void insert_qp(struct qib_ibdev *dev, struct qib_qp *qp) unsigned long flags; unsigned n = qpn_hash(dev, qp->ibqp.qp_num); - spin_lock_irqsave(&dev->qpt_lock, flags); atomic_inc(&qp->refcount); + spin_lock_irqsave(&dev->qpt_lock, flags); if (qp->ibqp.qp_num == 0) rcu_assign_pointer(ibp->qp0, qp); @@ -235,7 +235,6 @@ static void insert_qp(struct qib_ibdev *dev, struct qib_qp *qp) } spin_unlock_irqrestore(&dev->qpt_lock, flags); - synchronize_rcu(); } /* @@ -247,36 +246,39 @@ static void remove_qp(struct qib_ibdev *dev, struct qib_qp *qp) struct qib_ibport *ibp = to_iport(qp->ibqp.device, qp->port_num); unsigned n = qpn_hash(dev, qp->ibqp.qp_num); unsigned long flags; + int removed = 1; spin_lock_irqsave(&dev->qpt_lock, flags); if (rcu_dereference_protected(ibp->qp0, lockdep_is_held(&dev->qpt_lock)) == qp) { - atomic_dec(&qp->refcount); rcu_assign_pointer(ibp->qp0, NULL); } else if (rcu_dereference_protected(ibp->qp1, lockdep_is_held(&dev->qpt_lock)) == qp) { - atomic_dec(&qp->refcount); rcu_assign_pointer(ibp->qp1, NULL); } else { struct qib_qp *q; struct qib_qp __rcu **qpp; + removed = 0; qpp = &dev->qp_table[n]; for (; (q = rcu_dereference_protected(*qpp, lockdep_is_held(&dev->qpt_lock))) != NULL; qpp = &q->next) if (q == qp) { - atomic_dec(&qp->refcount); rcu_assign_pointer(*qpp, rcu_dereference_protected(qp->next, lockdep_is_held(&dev->qpt_lock))); + removed = 1; break; } } spin_unlock_irqrestore(&dev->qpt_lock, flags); - synchronize_rcu(); + if (removed) { + synchronize_rcu(); + atomic_dec(&qp->refcount); + } } /** @@ -334,26 +336,25 @@ struct qib_qp *qib_lookup_qpn(struct qib_ibport *ibp, u32 qpn) { struct qib_qp *qp = NULL; + rcu_read_lock(); if (unlikely(qpn <= 1)) { - rcu_read_lock(); if (qpn == 0) qp = rcu_dereference(ibp->qp0); else qp = rcu_dereference(ibp->qp1); + if (qp) + atomic_inc(&qp->refcount); } else { struct qib_ibdev *dev = &ppd_from_ibp(ibp)->dd->verbs_dev; unsigned n = qpn_hash(dev, qpn); - rcu_read_lock(); for (qp = rcu_dereference(dev->qp_table[n]); qp; qp = rcu_dereference(qp->next)) - if (qp->ibqp.qp_num == qpn) + if (qp->ibqp.qp_num == qpn) { + atomic_inc(&qp->refcount); break; + } } - if (qp) - if (unlikely(!atomic_inc_not_zero(&qp->refcount))) - qp = NULL; - rcu_read_unlock(); return qp; } From ab4a13d69bf01b098906c60e7598d10752401a56 Mon Sep 17 00:00:00 2001 From: Vinit Agnihotri Date: Sat, 15 Jun 2013 17:11:38 -0400 Subject: [PATCH 0470/1048] IB/qib: Update minor version number External PSM repositories have advanced the minor number for a variety of reasons. The driver needs to increase to avoid warnings. Signed-off-by: Vinit Agnihotri Signed-off-by: Mike Marciniszyn Signed-off-by: Roland Dreier --- drivers/infiniband/hw/qib/qib_common.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/infiniband/hw/qib/qib_common.h b/drivers/infiniband/hw/qib/qib_common.h index d39e0183ff82..4f255b723ffd 100644 --- a/drivers/infiniband/hw/qib/qib_common.h +++ b/drivers/infiniband/hw/qib/qib_common.h @@ -279,7 +279,7 @@ struct qib_base_info { * may not be implemented; the user code must deal with this if it * cares, or it must abort after initialization reports the difference. */ -#define QIB_USER_SWMINOR 11 +#define QIB_USER_SWMINOR 12 #define QIB_USER_SWVERSION ((QIB_USER_SWMAJOR << 16) | QIB_USER_SWMINOR) From e0f30baca1ebe5547f6760f760b8c4e189fc1203 Mon Sep 17 00:00:00 2001 From: Ramkrishna Vepa Date: Tue, 28 May 2013 12:57:33 -0400 Subject: [PATCH 0471/1048] IB/qib: Add optional NUMA affinity This patch adds context relative numa affinity conditioned on the module parameter numa_aware. The qib_ctxtdata has an additional node_id member and qib_create_ctxtdata() has an addition node_id parameter. The allocations within the hdr queue and eager queue setup routines now take this additional member and adjust allocations as necesary. PSM will pass the either current numa node or the node closest to the HCA depending on numa_aware. Verbs will always use the node closest to the HCA. Reviewed-by: Dean Luick Signed-off-by: Ramkrishna Vepa Signed-off-by: Vinit Agnihotri Signed-off-by: Mike Marciniszyn Signed-off-by: Roland Dreier --- drivers/infiniband/hw/qib/qib.h | 7 ++++- drivers/infiniband/hw/qib/qib_file_ops.c | 6 +++- drivers/infiniband/hw/qib/qib_init.c | 39 +++++++++++++++++++----- 3 files changed, 43 insertions(+), 9 deletions(-) diff --git a/drivers/infiniband/hw/qib/qib.h b/drivers/infiniband/hw/qib/qib.h index cecbd43f9212..2ee82e6550c7 100644 --- a/drivers/infiniband/hw/qib/qib.h +++ b/drivers/infiniband/hw/qib/qib.h @@ -154,6 +154,8 @@ struct qib_ctxtdata { */ /* instead of calculating it */ unsigned ctxt; + /* local node of context */ + int node_id; /* non-zero if ctxt is being shared. */ u16 subctxt_cnt; /* non-zero if ctxt is being shared. */ @@ -1088,6 +1090,8 @@ struct qib_devdata { u16 psxmitwait_check_rate; /* high volume overflow errors defered to tasklet */ struct tasklet_struct error_tasklet; + + int assigned_node_id; /* NUMA node closest to HCA */ }; /* hol_state values */ @@ -1167,7 +1171,7 @@ int qib_create_rcvhdrq(struct qib_devdata *, struct qib_ctxtdata *); int qib_setup_eagerbufs(struct qib_ctxtdata *); void qib_set_ctxtcnt(struct qib_devdata *); int qib_create_ctxts(struct qib_devdata *dd); -struct qib_ctxtdata *qib_create_ctxtdata(struct qib_pportdata *, u32); +struct qib_ctxtdata *qib_create_ctxtdata(struct qib_pportdata *, u32, int); void qib_init_pportdata(struct qib_pportdata *, struct qib_devdata *, u8, u8); void qib_free_ctxtdata(struct qib_devdata *, struct qib_ctxtdata *); @@ -1458,6 +1462,7 @@ extern unsigned qib_n_krcv_queues; extern unsigned qib_sdma_fetch_arb; extern unsigned qib_compat_ddr_negotiate; extern int qib_special_trigger; +extern unsigned qib_numa_aware; extern struct mutex qib_mutex; diff --git a/drivers/infiniband/hw/qib/qib_file_ops.c b/drivers/infiniband/hw/qib/qib_file_ops.c index b56c9428f3c5..65b2fc3f957c 100644 --- a/drivers/infiniband/hw/qib/qib_file_ops.c +++ b/drivers/infiniband/hw/qib/qib_file_ops.c @@ -1263,8 +1263,12 @@ static int setup_ctxt(struct qib_pportdata *ppd, int ctxt, struct qib_ctxtdata *rcd; void *ptmp = NULL; int ret; + int numa_id; - rcd = qib_create_ctxtdata(ppd, ctxt); + numa_id = qib_numa_aware ? numa_node_id() : + dd->assigned_node_id; + + rcd = qib_create_ctxtdata(ppd, ctxt, numa_id); /* * Allocate memory for use in qib_tid_update() at open to diff --git a/drivers/infiniband/hw/qib/qib_init.c b/drivers/infiniband/hw/qib/qib_init.c index 4b64c885fa0d..e02217b5c46d 100644 --- a/drivers/infiniband/hw/qib/qib_init.c +++ b/drivers/infiniband/hw/qib/qib_init.c @@ -67,6 +67,11 @@ ushort qib_cfgctxts; module_param_named(cfgctxts, qib_cfgctxts, ushort, S_IRUGO); MODULE_PARM_DESC(cfgctxts, "Set max number of contexts to use"); +unsigned qib_numa_aware; +module_param_named(numa_aware, qib_numa_aware, uint, S_IRUGO); +MODULE_PARM_DESC(numa_aware, + "0 -> PSM allocation close to HCA, 1 -> PSM allocation local to process"); + /* * If set, do not write to any regs if avoidable, hack to allow * check for deranged default register values. @@ -124,6 +129,11 @@ int qib_create_ctxts(struct qib_devdata *dd) { unsigned i; int ret; + int local_node_id = pcibus_to_node(dd->pcidev->bus); + + if (local_node_id < 0) + local_node_id = numa_node_id(); + dd->assigned_node_id = local_node_id; /* * Allocate full ctxtcnt array, rather than just cfgctxts, because @@ -146,7 +156,8 @@ int qib_create_ctxts(struct qib_devdata *dd) continue; ppd = dd->pport + (i % dd->num_pports); - rcd = qib_create_ctxtdata(ppd, i); + + rcd = qib_create_ctxtdata(ppd, i, dd->assigned_node_id); if (!rcd) { qib_dev_err(dd, "Unable to allocate ctxtdata for Kernel ctxt, failing\n"); @@ -164,14 +175,16 @@ done: /* * Common code for user and kernel context setup. */ -struct qib_ctxtdata *qib_create_ctxtdata(struct qib_pportdata *ppd, u32 ctxt) +struct qib_ctxtdata *qib_create_ctxtdata(struct qib_pportdata *ppd, u32 ctxt, + int node_id) { struct qib_devdata *dd = ppd->dd; struct qib_ctxtdata *rcd; - rcd = kzalloc(sizeof(*rcd), GFP_KERNEL); + rcd = kzalloc_node(sizeof(*rcd), GFP_KERNEL, node_id); if (rcd) { INIT_LIST_HEAD(&rcd->qp_wait_list); + rcd->node_id = node_id; rcd->ppd = ppd; rcd->dd = dd; rcd->cnt = 1; @@ -1524,6 +1537,7 @@ static void qib_remove_one(struct pci_dev *pdev) int qib_create_rcvhdrq(struct qib_devdata *dd, struct qib_ctxtdata *rcd) { unsigned amt; + int old_node_id; if (!rcd->rcvhdrq) { dma_addr_t phys_hdrqtail; @@ -1533,9 +1547,13 @@ int qib_create_rcvhdrq(struct qib_devdata *dd, struct qib_ctxtdata *rcd) sizeof(u32), PAGE_SIZE); gfp_flags = (rcd->ctxt >= dd->first_user_ctxt) ? GFP_USER : GFP_KERNEL; + + old_node_id = dev_to_node(&dd->pcidev->dev); + set_dev_node(&dd->pcidev->dev, rcd->node_id); rcd->rcvhdrq = dma_alloc_coherent( &dd->pcidev->dev, amt, &rcd->rcvhdrq_phys, gfp_flags | __GFP_COMP); + set_dev_node(&dd->pcidev->dev, old_node_id); if (!rcd->rcvhdrq) { qib_dev_err(dd, @@ -1551,9 +1569,11 @@ int qib_create_rcvhdrq(struct qib_devdata *dd, struct qib_ctxtdata *rcd) } if (!(dd->flags & QIB_NODMA_RTAIL)) { + set_dev_node(&dd->pcidev->dev, rcd->node_id); rcd->rcvhdrtail_kvaddr = dma_alloc_coherent( &dd->pcidev->dev, PAGE_SIZE, &phys_hdrqtail, gfp_flags); + set_dev_node(&dd->pcidev->dev, old_node_id); if (!rcd->rcvhdrtail_kvaddr) goto bail_free; rcd->rcvhdrqtailaddr_phys = phys_hdrqtail; @@ -1597,6 +1617,7 @@ int qib_setup_eagerbufs(struct qib_ctxtdata *rcd) unsigned e, egrcnt, egrperchunk, chunk, egrsize, egroff; size_t size; gfp_t gfp_flags; + int old_node_id; /* * GFP_USER, but without GFP_FS, so buffer cache can be @@ -1615,25 +1636,29 @@ int qib_setup_eagerbufs(struct qib_ctxtdata *rcd) size = rcd->rcvegrbuf_size; if (!rcd->rcvegrbuf) { rcd->rcvegrbuf = - kzalloc(chunk * sizeof(rcd->rcvegrbuf[0]), - GFP_KERNEL); + kzalloc_node(chunk * sizeof(rcd->rcvegrbuf[0]), + GFP_KERNEL, rcd->node_id); if (!rcd->rcvegrbuf) goto bail; } if (!rcd->rcvegrbuf_phys) { rcd->rcvegrbuf_phys = - kmalloc(chunk * sizeof(rcd->rcvegrbuf_phys[0]), - GFP_KERNEL); + kmalloc_node(chunk * sizeof(rcd->rcvegrbuf_phys[0]), + GFP_KERNEL, rcd->node_id); if (!rcd->rcvegrbuf_phys) goto bail_rcvegrbuf; } for (e = 0; e < rcd->rcvegrbuf_chunks; e++) { if (rcd->rcvegrbuf[e]) continue; + + old_node_id = dev_to_node(&dd->pcidev->dev); + set_dev_node(&dd->pcidev->dev, rcd->node_id); rcd->rcvegrbuf[e] = dma_alloc_coherent(&dd->pcidev->dev, size, &rcd->rcvegrbuf_phys[e], gfp_flags); + set_dev_node(&dd->pcidev->dev, old_node_id); if (!rcd->rcvegrbuf[e]) goto bail_rcvegrbuf_phys; } From c804f07248895ff9c9dccb6cda703068a0657b6c Mon Sep 17 00:00:00 2001 From: Ramkrishna Vepa Date: Sun, 2 Jun 2013 15:16:11 -0400 Subject: [PATCH 0472/1048] IB/qib: Add dual-rail NUMA awareness for PSM processes The driver currently selects a HCA based on the algorithm that PSM chooses, contexts within a HCA or across. The HCA can also be chosen by the user. Either way, this patch assigns a CPU on the NUMA node local to the selected HCA. This patch also tries to select the HCA closest to the NUMA node of the CPU assigned via taskset to PSM process. If this HCA is unusable then another unit is selected based on the algorithm that is currently enforced or selected by PSM - round robin context selection 'within' or 'across' HCA's. Fixed a bug wherein contexts are setup on the NUMA node on which the processes are opened (setup_ctxt()) and not on the NUMA node that the driver recommends the CPU on. Reviewed-by: Mike Marciniszyn Signed-off-by: Vinit Agnihotri Signed-off-by: Ramkrishna Vepa Signed-off-by: Roland Dreier --- drivers/infiniband/hw/qib/qib_file_ops.c | 174 ++++++++++++++++------- 1 file changed, 125 insertions(+), 49 deletions(-) diff --git a/drivers/infiniband/hw/qib/qib_file_ops.c b/drivers/infiniband/hw/qib/qib_file_ops.c index 65b2fc3f957c..df3808a38381 100644 --- a/drivers/infiniband/hw/qib/qib_file_ops.c +++ b/drivers/infiniband/hw/qib/qib_file_ops.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012 Intel Corporation. All rights reserved. + * Copyright (c) 2012, 2013 Intel Corporation. All rights reserved. * Copyright (c) 2006 - 2012 QLogic Corporation. All rights reserved. * Copyright (c) 2003, 2004, 2005, 2006 PathScale, Inc. All rights reserved. * @@ -1155,6 +1155,49 @@ static unsigned int qib_poll(struct file *fp, struct poll_table_struct *pt) return pollflag; } +static void assign_ctxt_affinity(struct file *fp, struct qib_devdata *dd) +{ + struct qib_filedata *fd = fp->private_data; + const unsigned int weight = cpumask_weight(¤t->cpus_allowed); + const struct cpumask *local_mask = cpumask_of_pcibus(dd->pcidev->bus); + int local_cpu; + + /* + * If process has NOT already set it's affinity, select and + * reserve a processor for it on the local NUMA node. + */ + if ((weight >= qib_cpulist_count) && + (cpumask_weight(local_mask) <= qib_cpulist_count)) { + for_each_cpu(local_cpu, local_mask) + if (!test_and_set_bit(local_cpu, qib_cpulist)) { + fd->rec_cpu_num = local_cpu; + return; + } + } + + /* + * If process has NOT already set it's affinity, select and + * reserve a processor for it, as a rendevous for all + * users of the driver. If they don't actually later + * set affinity to this cpu, or set it to some other cpu, + * it just means that sooner or later we don't recommend + * a cpu, and let the scheduler do it's best. + */ + if (weight >= qib_cpulist_count) { + int cpu; + cpu = find_first_zero_bit(qib_cpulist, + qib_cpulist_count); + if (cpu == qib_cpulist_count) + qib_dev_err(dd, + "no cpus avail for affinity PID %u\n", + current->pid); + else { + __set_bit(cpu, qib_cpulist); + fd->rec_cpu_num = cpu; + } + } +} + /* * Check that userland and driver are compatible for subcontexts. */ @@ -1259,14 +1302,18 @@ bail: static int setup_ctxt(struct qib_pportdata *ppd, int ctxt, struct file *fp, const struct qib_user_info *uinfo) { + struct qib_filedata *fd = fp->private_data; struct qib_devdata *dd = ppd->dd; struct qib_ctxtdata *rcd; void *ptmp = NULL; int ret; int numa_id; - numa_id = qib_numa_aware ? numa_node_id() : - dd->assigned_node_id; + assign_ctxt_affinity(fp, dd); + + numa_id = qib_numa_aware ? ((fd->rec_cpu_num != -1) ? + cpu_to_node(fd->rec_cpu_num) : + numa_node_id()) : dd->assigned_node_id; rcd = qib_create_ctxtdata(ppd, ctxt, numa_id); @@ -1300,6 +1347,9 @@ static int setup_ctxt(struct qib_pportdata *ppd, int ctxt, goto bail; bailerr: + if (fd->rec_cpu_num != -1) + __clear_bit(fd->rec_cpu_num, qib_cpulist); + dd->rcd[ctxt] = NULL; kfree(rcd); kfree(ptmp); @@ -1489,6 +1539,57 @@ static int qib_open(struct inode *in, struct file *fp) return fp->private_data ? 0 : -ENOMEM; } +static int find_hca(unsigned int cpu, int *unit) +{ + int ret = 0, devmax, npresent, nup, ndev; + + *unit = -1; + + devmax = qib_count_units(&npresent, &nup); + if (!npresent) { + ret = -ENXIO; + goto done; + } + if (!nup) { + ret = -ENETDOWN; + goto done; + } + for (ndev = 0; ndev < devmax; ndev++) { + struct qib_devdata *dd = qib_lookup(ndev); + if (dd) { + if (pcibus_to_node(dd->pcidev->bus) < 0) { + ret = -EINVAL; + goto done; + } + if (cpu_to_node(cpu) == + pcibus_to_node(dd->pcidev->bus)) { + *unit = ndev; + goto done; + } + } + } +done: + return ret; +} + +static int do_qib_user_sdma_queue_create(struct file *fp) +{ + struct qib_filedata *fd = fp->private_data; + struct qib_ctxtdata *rcd = fd->rcd; + struct qib_devdata *dd = rcd->dd; + + if (dd->flags & QIB_HAS_SEND_DMA) + + fd->pq = qib_user_sdma_queue_create(&dd->pcidev->dev, + dd->unit, + rcd->ctxt, + fd->subctxt); + if (!fd->pq) + return -ENOMEM; + + return 0; +} + /* * Get ctxt early, so can set affinity prior to memory allocation. */ @@ -1521,61 +1622,36 @@ static int qib_assign_ctxt(struct file *fp, const struct qib_user_info *uinfo) if (qib_compatible_subctxts(swmajor, swminor) && uinfo->spu_subctxt_cnt) { ret = find_shared_ctxt(fp, uinfo); - if (ret) { - if (ret > 0) - ret = 0; - goto done_chk_sdma; + if (ret > 0) { + ret = do_qib_user_sdma_queue_create(fp); + if (!ret) + assign_ctxt_affinity(fp, (ctxt_fp(fp))->dd); + goto done_ok; } } i_minor = iminor(file_inode(fp)) - QIB_USER_MINOR_BASE; if (i_minor) ret = find_free_ctxt(i_minor - 1, fp, uinfo); - else + else { + int unit; + const unsigned int cpu = cpumask_first(¤t->cpus_allowed); + const unsigned int weight = + cpumask_weight(¤t->cpus_allowed); + + if (weight == 1 && !test_bit(cpu, qib_cpulist)) + if (!find_hca(cpu, &unit) && unit >= 0) + if (!find_free_ctxt(unit, fp, uinfo)) { + ret = 0; + goto done_chk_sdma; + } ret = get_a_ctxt(fp, uinfo, alg); - -done_chk_sdma: - if (!ret) { - struct qib_filedata *fd = fp->private_data; - const struct qib_ctxtdata *rcd = fd->rcd; - const struct qib_devdata *dd = rcd->dd; - unsigned int weight; - - if (dd->flags & QIB_HAS_SEND_DMA) { - fd->pq = qib_user_sdma_queue_create(&dd->pcidev->dev, - dd->unit, - rcd->ctxt, - fd->subctxt); - if (!fd->pq) - ret = -ENOMEM; - } - - /* - * If process has NOT already set it's affinity, select and - * reserve a processor for it, as a rendezvous for all - * users of the driver. If they don't actually later - * set affinity to this cpu, or set it to some other cpu, - * it just means that sooner or later we don't recommend - * a cpu, and let the scheduler do it's best. - */ - weight = cpumask_weight(tsk_cpus_allowed(current)); - if (!ret && weight >= qib_cpulist_count) { - int cpu; - cpu = find_first_zero_bit(qib_cpulist, - qib_cpulist_count); - if (cpu != qib_cpulist_count) { - __set_bit(cpu, qib_cpulist); - fd->rec_cpu_num = cpu; - } - } else if (weight == 1 && - test_bit(cpumask_first(tsk_cpus_allowed(current)), - qib_cpulist)) - qib_devinfo(dd->pcidev, - "%s PID %u affinity set to cpu %d; already allocated\n", - current->comm, current->pid, - cpumask_first(tsk_cpus_allowed(current))); } +done_chk_sdma: + if (!ret) + ret = do_qib_user_sdma_queue_create(fp); +done_ok: mutex_unlock(&qib_mutex); done: From 85caafe307a06e4f9993c8f3c994a07374c07831 Mon Sep 17 00:00:00 2001 From: Mike Marciniszyn Date: Tue, 4 Jun 2013 15:05:37 -0400 Subject: [PATCH 0473/1048] IB/qib: Optimize CQ callbacks The current workqueue implemention has the following performance deficiencies on QDR HCAs: - The CQ call backs tend to run on the CPUs processing the receive queues - The single thread queue isn't optimal for multiple HCAs This patch adds a dedicated per HCA bound thread to process CQ callbacks. Reviewed-by: Ramkrishna Vepa Signed-off-by: Mike Marciniszyn Signed-off-by: Roland Dreier --- drivers/infiniband/hw/qib/qib.h | 5 +- drivers/infiniband/hw/qib/qib_cq.c | 67 ++++++++++++++++++++++++--- drivers/infiniband/hw/qib/qib_init.c | 18 ++----- drivers/infiniband/hw/qib/qib_verbs.h | 10 ++-- 4 files changed, 76 insertions(+), 24 deletions(-) diff --git a/drivers/infiniband/hw/qib/qib.h b/drivers/infiniband/hw/qib/qib.h index 2ee82e6550c7..3a78b92cbd4e 100644 --- a/drivers/infiniband/hw/qib/qib.h +++ b/drivers/infiniband/hw/qib/qib.h @@ -1,7 +1,7 @@ #ifndef _QIB_KERNEL_H #define _QIB_KERNEL_H /* - * Copyright (c) 2012 Intel Corporation. All rights reserved. + * Copyright (c) 2012, 2013 Intel Corporation. All rights reserved. * Copyright (c) 2006 - 2012 QLogic Corporation. All rights reserved. * Copyright (c) 2003, 2004, 2005, 2006 PathScale, Inc. All rights reserved. * @@ -51,6 +51,7 @@ #include #include #include +#include #include "qib_common.h" #include "qib_verbs.h" @@ -1090,6 +1091,8 @@ struct qib_devdata { u16 psxmitwait_check_rate; /* high volume overflow errors defered to tasklet */ struct tasklet_struct error_tasklet; + /* per device cq worker */ + struct kthread_worker *worker; int assigned_node_id; /* NUMA node closest to HCA */ }; diff --git a/drivers/infiniband/hw/qib/qib_cq.c b/drivers/infiniband/hw/qib/qib_cq.c index 5246aa486bbe..ab4e11cfab15 100644 --- a/drivers/infiniband/hw/qib/qib_cq.c +++ b/drivers/infiniband/hw/qib/qib_cq.c @@ -1,4 +1,5 @@ /* + * Copyright (c) 2013 Intel Corporation. All rights reserved. * Copyright (c) 2006, 2007, 2008, 2010 QLogic Corporation. All rights reserved. * Copyright (c) 2005, 2006 PathScale, Inc. All rights reserved. * @@ -34,8 +35,10 @@ #include #include #include +#include #include "qib_verbs.h" +#include "qib.h" /** * qib_cq_enter - add a new entry to the completion queue @@ -102,13 +105,18 @@ void qib_cq_enter(struct qib_cq *cq, struct ib_wc *entry, int solicited) if (cq->notify == IB_CQ_NEXT_COMP || (cq->notify == IB_CQ_SOLICITED && (solicited || entry->status != IB_WC_SUCCESS))) { - cq->notify = IB_CQ_NONE; - cq->triggered++; + struct kthread_worker *worker; /* * This will cause send_complete() to be called in * another thread. */ - queue_work(qib_cq_wq, &cq->comptask); + smp_rmb(); + worker = cq->dd->worker; + if (likely(worker)) { + cq->notify = IB_CQ_NONE; + cq->triggered++; + queue_kthread_work(worker, &cq->comptask); + } } spin_unlock_irqrestore(&cq->lock, flags); @@ -163,7 +171,7 @@ bail: return npolled; } -static void send_complete(struct work_struct *work) +static void send_complete(struct kthread_work *work) { struct qib_cq *cq = container_of(work, struct qib_cq, comptask); @@ -287,11 +295,12 @@ struct ib_cq *qib_create_cq(struct ib_device *ibdev, int entries, * The number of entries should be >= the number requested or return * an error. */ + cq->dd = dd_from_dev(dev); cq->ibcq.cqe = entries; cq->notify = IB_CQ_NONE; cq->triggered = 0; spin_lock_init(&cq->lock); - INIT_WORK(&cq->comptask, send_complete); + init_kthread_work(&cq->comptask, send_complete); wc->head = 0; wc->tail = 0; cq->queue = wc; @@ -323,7 +332,7 @@ int qib_destroy_cq(struct ib_cq *ibcq) struct qib_ibdev *dev = to_idev(ibcq->device); struct qib_cq *cq = to_icq(ibcq); - flush_work(&cq->comptask); + flush_kthread_work(&cq->comptask); spin_lock(&dev->n_cqs_lock); dev->n_cqs_allocated--; spin_unlock(&dev->n_cqs_lock); @@ -483,3 +492,49 @@ bail_free: bail: return ret; } + +int qib_cq_init(struct qib_devdata *dd) +{ + int ret = 0; + int cpu; + struct task_struct *task; + + if (dd->worker) + return 0; + dd->worker = kzalloc(sizeof(*dd->worker), GFP_KERNEL); + if (!dd->worker) + return -ENOMEM; + init_kthread_worker(dd->worker); + task = kthread_create_on_node( + kthread_worker_fn, + dd->worker, + dd->assigned_node_id, + "qib_cq%d", dd->unit); + if (IS_ERR(task)) + goto task_fail; + cpu = cpumask_first(cpumask_of_node(dd->assigned_node_id)); + kthread_bind(task, cpu); + wake_up_process(task); +out: + return ret; +task_fail: + ret = PTR_ERR(task); + kfree(dd->worker); + dd->worker = NULL; + goto out; +} + +void qib_cq_exit(struct qib_devdata *dd) +{ + struct kthread_worker *worker; + + worker = dd->worker; + if (!worker) + return; + /* blocks future queuing from send_complete() */ + dd->worker = NULL; + smp_wmb(); + flush_kthread_worker(worker); + kthread_stop(worker->task); + kfree(worker); +} diff --git a/drivers/infiniband/hw/qib/qib_init.c b/drivers/infiniband/hw/qib/qib_init.c index e02217b5c46d..ff36903474ea 100644 --- a/drivers/infiniband/hw/qib/qib_init.c +++ b/drivers/infiniband/hw/qib/qib_init.c @@ -97,8 +97,6 @@ unsigned qib_wc_pat = 1; /* default (1) is to use PAT, not MTRR */ module_param_named(wc_pat, qib_wc_pat, uint, S_IRUGO); MODULE_PARM_DESC(wc_pat, "enable write-combining via PAT mechanism"); -struct workqueue_struct *qib_cq_wq; - static void verify_interrupt(unsigned long); static struct idr qib_unit_table; @@ -445,6 +443,7 @@ static int loadtime_init(struct qib_devdata *dd) dd->intrchk_timer.function = verify_interrupt; dd->intrchk_timer.data = (unsigned long) dd; + ret = qib_cq_init(dd); done: return ret; } @@ -1215,12 +1214,6 @@ static int __init qlogic_ib_init(void) if (ret) goto bail; - qib_cq_wq = create_singlethread_workqueue("qib_cq"); - if (!qib_cq_wq) { - ret = -ENOMEM; - goto bail_dev; - } - /* * These must be called before the driver is registered with * the PCI subsystem. @@ -1233,7 +1226,7 @@ static int __init qlogic_ib_init(void) ret = pci_register_driver(&qib_driver); if (ret < 0) { pr_err("Unable to register driver: error %d\n", -ret); - goto bail_unit; + goto bail_dev; } /* not fatal if it doesn't work */ @@ -1241,13 +1234,11 @@ static int __init qlogic_ib_init(void) pr_err("Unable to register ipathfs\n"); goto bail; /* all OK */ -bail_unit: +bail_dev: #ifdef CONFIG_INFINIBAND_QIB_DCA dca_unregister_notify(&dca_notifier); #endif idr_destroy(&qib_unit_table); - destroy_workqueue(qib_cq_wq); -bail_dev: qib_dev_cleanup(); bail: return ret; @@ -1273,8 +1264,6 @@ static void __exit qlogic_ib_cleanup(void) #endif pci_unregister_driver(&qib_driver); - destroy_workqueue(qib_cq_wq); - qib_cpulist_count = 0; kfree(qib_cpulist); @@ -1365,6 +1354,7 @@ static void cleanup_device_data(struct qib_devdata *dd) } kfree(tmp); kfree(dd->boardname); + qib_cq_exit(dd); } /* diff --git a/drivers/infiniband/hw/qib/qib_verbs.h b/drivers/infiniband/hw/qib/qib_verbs.h index aff8b2c17886..86c2cb3c9caf 100644 --- a/drivers/infiniband/hw/qib/qib_verbs.h +++ b/drivers/infiniband/hw/qib/qib_verbs.h @@ -41,6 +41,7 @@ #include #include #include +#include #include #include #include @@ -267,7 +268,8 @@ struct qib_cq_wc { */ struct qib_cq { struct ib_cq ibcq; - struct work_struct comptask; + struct kthread_work comptask; + struct qib_devdata *dd; spinlock_t lock; /* protect changes in this struct */ u8 notify; u8 triggered; @@ -832,8 +834,6 @@ static inline int qib_send_ok(struct qib_qp *qp) !(qp->s_flags & QIB_S_ANY_WAIT_SEND)); } -extern struct workqueue_struct *qib_cq_wq; - /* * This must be called with s_lock held. */ @@ -972,6 +972,10 @@ int qib_query_srq(struct ib_srq *ibsrq, struct ib_srq_attr *attr); int qib_destroy_srq(struct ib_srq *ibsrq); +int qib_cq_init(struct qib_devdata *dd); + +void qib_cq_exit(struct qib_devdata *dd); + void qib_cq_enter(struct qib_cq *cq, struct ib_wc *entry, int sig); int qib_poll_cq(struct ib_cq *ibcq, int num_entries, struct ib_wc *entry); From ddb8876589702a9396d15d9d4075e6388d0600cf Mon Sep 17 00:00:00 2001 From: Mike Marciniszyn Date: Sat, 15 Jun 2013 17:07:03 -0400 Subject: [PATCH 0474/1048] IB/qib: Convert opcode counters to per-context This fix changes the opcode relative counters for receive to per context. Profiling has shown that when mulitple contexts are being used there is a lot of cache activity associated with these counters. The code formerly kept these counters per port, but only provided the interface to read per HCA. This patch converts the read of counters to per HCA and adds the debugfs hooks to be able to read the file as a sequence of opcodes. Reviewed-by: Dean Luick Signed-off-by: Mike Marciniszyn Signed-off-by: Roland Dreier --- drivers/infiniband/hw/qib/Makefile | 1 + drivers/infiniband/hw/qib/qib.h | 36 ++--- drivers/infiniband/hw/qib/qib_debugfs.c | 166 ++++++++++++++++++++++++ drivers/infiniband/hw/qib/qib_debugfs.h | 45 +++++++ drivers/infiniband/hw/qib/qib_driver.c | 1 - drivers/infiniband/hw/qib/qib_init.c | 41 +++++- drivers/infiniband/hw/qib/qib_verbs.c | 8 +- drivers/infiniband/hw/qib/qib_verbs.h | 9 +- 8 files changed, 284 insertions(+), 23 deletions(-) create mode 100644 drivers/infiniband/hw/qib/qib_debugfs.c create mode 100644 drivers/infiniband/hw/qib/qib_debugfs.h diff --git a/drivers/infiniband/hw/qib/Makefile b/drivers/infiniband/hw/qib/Makefile index f12d7bb8b39f..57f8103e51f8 100644 --- a/drivers/infiniband/hw/qib/Makefile +++ b/drivers/infiniband/hw/qib/Makefile @@ -13,3 +13,4 @@ ib_qib-$(CONFIG_PCI_MSI) += qib_iba6120.o ib_qib-$(CONFIG_X86_64) += qib_wc_x86_64.o ib_qib-$(CONFIG_PPC64) += qib_wc_ppc64.o +ib_qib-$(CONFIG_DEBUG_FS) += qib_debugfs.o diff --git a/drivers/infiniband/hw/qib/qib.h b/drivers/infiniband/hw/qib/qib.h index 3a78b92cbd4e..5453e2b36567 100644 --- a/drivers/infiniband/hw/qib/qib.h +++ b/drivers/infiniband/hw/qib/qib.h @@ -115,6 +115,11 @@ struct qib_eep_log_mask { /* * Below contains all data related to a single context (formerly called port). */ + +#ifdef CONFIG_DEBUG_FS +struct qib_opcode_stats_perctx; +#endif + struct qib_ctxtdata { void **rcvegrbuf; dma_addr_t *rcvegrbuf_phys; @@ -225,12 +230,15 @@ struct qib_ctxtdata { u8 redirect_seq_cnt; /* ctxt rcvhdrq head offset */ u32 head; - u32 pkt_count; /* lookaside fields */ struct qib_qp *lookaside_qp; u32 lookaside_qpn; /* QPs waiting for context processing */ struct list_head qp_wait_list; +#ifdef CONFIG_DEBUG_FS + /* verbs stats per CTX */ + struct qib_opcode_stats_perctx *opstats; +#endif }; struct qib_sge_state; @@ -1495,27 +1503,23 @@ extern struct mutex qib_mutex; * first to avoid possible serial port delays from printk. */ #define qib_early_err(dev, fmt, ...) \ - do { \ - dev_err(dev, fmt, ##__VA_ARGS__); \ - } while (0) + dev_err(dev, fmt, ##__VA_ARGS__) #define qib_dev_err(dd, fmt, ...) \ - do { \ - dev_err(&(dd)->pcidev->dev, "%s: " fmt, \ - qib_get_unit_name((dd)->unit), ##__VA_ARGS__); \ - } while (0) + dev_err(&(dd)->pcidev->dev, "%s: " fmt, \ + qib_get_unit_name((dd)->unit), ##__VA_ARGS__) + +#define qib_dev_warn(dd, fmt, ...) \ + dev_warn(&(dd)->pcidev->dev, "%s: " fmt, \ + qib_get_unit_name((dd)->unit), ##__VA_ARGS__) #define qib_dev_porterr(dd, port, fmt, ...) \ - do { \ - dev_err(&(dd)->pcidev->dev, "%s: IB%u:%u " fmt, \ - qib_get_unit_name((dd)->unit), (dd)->unit, (port), \ - ##__VA_ARGS__); \ - } while (0) + dev_err(&(dd)->pcidev->dev, "%s: IB%u:%u " fmt, \ + qib_get_unit_name((dd)->unit), (dd)->unit, (port), \ + ##__VA_ARGS__) #define qib_devinfo(pcidev, fmt, ...) \ - do { \ - dev_info(&(pcidev)->dev, fmt, ##__VA_ARGS__); \ - } while (0) + dev_info(&(pcidev)->dev, fmt, ##__VA_ARGS__) /* * this is used for formatting hw error messages... diff --git a/drivers/infiniband/hw/qib/qib_debugfs.c b/drivers/infiniband/hw/qib/qib_debugfs.c new file mode 100644 index 000000000000..47d01164cc91 --- /dev/null +++ b/drivers/infiniband/hw/qib/qib_debugfs.c @@ -0,0 +1,166 @@ +#ifdef CONFIG_DEBUG_FS +/* + * Copyright (c) 2013 Intel Corporation. All rights reserved. + * + * This software is available to you under a choice of one of two + * licenses. You may choose to be licensed under the terms of the GNU + * General Public License (GPL) Version 2, available from the file + * COPYING in the main directory of this source tree, or the + * OpenIB.org BSD license below: + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include +#include +#include +#include + +#include "qib.h" +#include "qib_verbs.h" +#include "qib_debugfs.h" + +static struct dentry *qib_dbg_root; + +#define DEBUGFS_FILE(name) \ +static const struct seq_operations _##name##_seq_ops = { \ + .start = _##name##_seq_start, \ + .next = _##name##_seq_next, \ + .stop = _##name##_seq_stop, \ + .show = _##name##_seq_show \ +}; \ +static int _##name##_open(struct inode *inode, struct file *s) \ +{ \ + struct seq_file *seq; \ + int ret; \ + ret = seq_open(s, &_##name##_seq_ops); \ + if (ret) \ + return ret; \ + seq = s->private_data; \ + seq->private = inode->i_private; \ + return 0; \ +} \ +static const struct file_operations _##name##_file_ops = { \ + .owner = THIS_MODULE, \ + .open = _##name##_open, \ + .read = seq_read, \ + .llseek = seq_lseek, \ + .release = seq_release \ +}; + +#define DEBUGFS_FILE_CREATE(name) \ +do { \ + struct dentry *ent; \ + ent = debugfs_create_file(#name , 0400, ibd->qib_ibdev_dbg, \ + ibd, &_##name##_file_ops); \ + if (!ent) \ + pr_warn("create of " #name " failed\n"); \ +} while (0) + +static void *_opcode_stats_seq_start(struct seq_file *s, loff_t *pos) +{ + struct qib_opcode_stats_perctx *opstats; + + if (*pos >= ARRAY_SIZE(opstats->stats)) + return NULL; + return pos; +} + +static void *_opcode_stats_seq_next(struct seq_file *s, void *v, loff_t *pos) +{ + struct qib_opcode_stats_perctx *opstats; + + ++*pos; + if (*pos >= ARRAY_SIZE(opstats->stats)) + return NULL; + return pos; +} + + +static void _opcode_stats_seq_stop(struct seq_file *s, void *v) +{ + /* nothing allocated */ +} + +static int _opcode_stats_seq_show(struct seq_file *s, void *v) +{ + loff_t *spos = v; + loff_t i = *spos, j; + u64 n_packets = 0, n_bytes = 0; + struct qib_ibdev *ibd = (struct qib_ibdev *)s->private; + struct qib_devdata *dd = dd_from_dev(ibd); + + for (j = 0; j < dd->first_user_ctxt; j++) { + if (!dd->rcd[j]) + continue; + n_packets += dd->rcd[j]->opstats->stats[i].n_packets; + n_bytes += dd->rcd[j]->opstats->stats[i].n_bytes; + } + if (!n_packets && !n_bytes) + return SEQ_SKIP; + seq_printf(s, "%02llx %llu/%llu\n", i, + (unsigned long long) n_packets, + (unsigned long long) n_bytes); + + return 0; +} + +DEBUGFS_FILE(opcode_stats) + +void qib_dbg_ibdev_init(struct qib_ibdev *ibd) +{ + char name[10]; + + snprintf(name, sizeof(name), "qib%d", dd_from_dev(ibd)->unit); + ibd->qib_ibdev_dbg = debugfs_create_dir(name, qib_dbg_root); + if (!ibd->qib_ibdev_dbg) { + pr_warn("create of %s failed\n", name); + return; + } + DEBUGFS_FILE_CREATE(opcode_stats); + return; +} + +void qib_dbg_ibdev_exit(struct qib_ibdev *ibd) +{ + if (!qib_dbg_root) + goto out; + debugfs_remove_recursive(ibd->qib_ibdev_dbg); +out: + ibd->qib_ibdev_dbg = NULL; +} + +void qib_dbg_init(void) +{ + qib_dbg_root = debugfs_create_dir(QIB_DRV_NAME, NULL); + if (!qib_dbg_root) + pr_warn("init of debugfs failed\n"); +} + +void qib_dbg_exit(void) +{ + debugfs_remove_recursive(qib_dbg_root); + qib_dbg_root = NULL; +} + +#endif + diff --git a/drivers/infiniband/hw/qib/qib_debugfs.h b/drivers/infiniband/hw/qib/qib_debugfs.h new file mode 100644 index 000000000000..7ae983a91b8b --- /dev/null +++ b/drivers/infiniband/hw/qib/qib_debugfs.h @@ -0,0 +1,45 @@ +#ifndef _QIB_DEBUGFS_H +#define _QIB_DEBUGFS_H + +#ifdef CONFIG_DEBUG_FS +/* + * Copyright (c) 2013 Intel Corporation. All rights reserved. + * + * This software is available to you under a choice of one of two + * licenses. You may choose to be licensed under the terms of the GNU + * General Public License (GPL) Version 2, available from the file + * COPYING in the main directory of this source tree, or the + * OpenIB.org BSD license below: + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +struct qib_ibdev; +void qib_dbg_ibdev_init(struct qib_ibdev *ibd); +void qib_dbg_ibdev_exit(struct qib_ibdev *ibd); +void qib_dbg_init(void); +void qib_dbg_exit(void); + +#endif + +#endif /* _QIB_DEBUGFS_H */ diff --git a/drivers/infiniband/hw/qib/qib_driver.c b/drivers/infiniband/hw/qib/qib_driver.c index 216092477dfc..5bee08f16d74 100644 --- a/drivers/infiniband/hw/qib/qib_driver.c +++ b/drivers/infiniband/hw/qib/qib_driver.c @@ -558,7 +558,6 @@ move_along: } rcd->head = l; - rcd->pkt_count += i; /* * Iterate over all QPs waiting to respond. diff --git a/drivers/infiniband/hw/qib/qib_init.c b/drivers/infiniband/hw/qib/qib_init.c index ff36903474ea..fdae42973056 100644 --- a/drivers/infiniband/hw/qib/qib_init.c +++ b/drivers/infiniband/hw/qib/qib_init.c @@ -46,6 +46,10 @@ #include "qib.h" #include "qib_common.h" #include "qib_mad.h" +#ifdef CONFIG_DEBUG_FS +#include "qib_debugfs.h" +#include "qib_verbs.h" +#endif #undef pr_fmt #define pr_fmt(fmt) QIB_DRV_NAME ": " fmt @@ -188,7 +192,18 @@ struct qib_ctxtdata *qib_create_ctxtdata(struct qib_pportdata *ppd, u32 ctxt, rcd->cnt = 1; rcd->ctxt = ctxt; dd->rcd[ctxt] = rcd; - +#ifdef CONFIG_DEBUG_FS + if (ctxt < dd->first_user_ctxt) { /* N/A for PSM contexts */ + rcd->opstats = kzalloc_node(sizeof(*rcd->opstats), + GFP_KERNEL, node_id); + if (!rcd->opstats) { + kfree(rcd); + qib_dev_err(dd, + "Unable to allocate per ctxt stats buffer\n"); + return NULL; + } + } +#endif dd->f_init_ctxt(rcd); /* @@ -959,6 +974,10 @@ void qib_free_ctxtdata(struct qib_devdata *dd, struct qib_ctxtdata *rcd) vfree(rcd->subctxt_uregbase); vfree(rcd->subctxt_rcvegrbuf); vfree(rcd->subctxt_rcvhdr_base); +#ifdef CONFIG_DEBUG_FS + kfree(rcd->opstats); + rcd->opstats = NULL; +#endif kfree(rcd); } @@ -1048,7 +1067,6 @@ done: dd->f_set_armlaunch(dd, 1); } - void qib_free_devdata(struct qib_devdata *dd) { unsigned long flags; @@ -1058,6 +1076,9 @@ void qib_free_devdata(struct qib_devdata *dd) list_del(&dd->list); spin_unlock_irqrestore(&qib_devs_lock, flags); +#ifdef CONFIG_DEBUG_FS + qib_dbg_ibdev_exit(&dd->verbs_dev); +#endif ib_dealloc_device(&dd->verbs_dev.ibdev); } @@ -1081,6 +1102,10 @@ struct qib_devdata *qib_alloc_devdata(struct pci_dev *pdev, size_t extra) goto bail; } +#ifdef CONFIG_DEBUG_FS + qib_dbg_ibdev_init(&dd->verbs_dev); +#endif + idr_preload(GFP_KERNEL); spin_lock_irqsave(&qib_devs_lock, flags); @@ -1096,6 +1121,9 @@ struct qib_devdata *qib_alloc_devdata(struct pci_dev *pdev, size_t extra) if (ret < 0) { qib_early_err(&pdev->dev, "Could not allocate unit ID: error %d\n", -ret); +#ifdef CONFIG_DEBUG_FS + qib_dbg_ibdev_exit(&dd->verbs_dev); +#endif ib_dealloc_device(&dd->verbs_dev.ibdev); dd = ERR_PTR(ret); goto bail; @@ -1222,6 +1250,9 @@ static int __init qlogic_ib_init(void) #ifdef CONFIG_INFINIBAND_QIB_DCA dca_register_notify(&dca_notifier); +#endif +#ifdef CONFIG_DEBUG_FS + qib_dbg_init(); #endif ret = pci_register_driver(&qib_driver); if (ret < 0) { @@ -1237,6 +1268,9 @@ static int __init qlogic_ib_init(void) bail_dev: #ifdef CONFIG_INFINIBAND_QIB_DCA dca_unregister_notify(&dca_notifier); +#endif +#ifdef CONFIG_DEBUG_FS + qib_dbg_exit(); #endif idr_destroy(&qib_unit_table); qib_dev_cleanup(); @@ -1263,6 +1297,9 @@ static void __exit qlogic_ib_cleanup(void) dca_unregister_notify(&dca_notifier); #endif pci_unregister_driver(&qib_driver); +#ifdef CONFIG_DEBUG_FS + qib_dbg_exit(); +#endif qib_cpulist_count = 0; kfree(qib_cpulist); diff --git a/drivers/infiniband/hw/qib/qib_verbs.c b/drivers/infiniband/hw/qib/qib_verbs.c index 904c384aa361..092b0bb1bb78 100644 --- a/drivers/infiniband/hw/qib/qib_verbs.c +++ b/drivers/infiniband/hw/qib/qib_verbs.c @@ -645,9 +645,11 @@ void qib_ib_rcv(struct qib_ctxtdata *rcd, void *rhdr, void *data, u32 tlen) } else goto drop; - opcode = be32_to_cpu(ohdr->bth[0]) >> 24; - ibp->opstats[opcode & 0x7f].n_bytes += tlen; - ibp->opstats[opcode & 0x7f].n_packets++; + opcode = (be32_to_cpu(ohdr->bth[0]) >> 24) & 0x7f; +#ifdef CONFIG_DEBUG_FS + rcd->opstats->stats[opcode].n_bytes += tlen; + rcd->opstats->stats[opcode].n_packets++; +#endif /* Get the destination QP number. */ qp_num = be32_to_cpu(ohdr->bth[1]) & QIB_QPN_MASK; diff --git a/drivers/infiniband/hw/qib/qib_verbs.h b/drivers/infiniband/hw/qib/qib_verbs.h index 86c2cb3c9caf..4a22a85b9f03 100644 --- a/drivers/infiniband/hw/qib/qib_verbs.h +++ b/drivers/infiniband/hw/qib/qib_verbs.h @@ -660,6 +660,10 @@ struct qib_opcode_stats { u64 n_bytes; /* total number of bytes */ }; +struct qib_opcode_stats_perctx { + struct qib_opcode_stats stats[128]; +}; + struct qib_ibport { struct qib_qp __rcu *qp0; struct qib_qp __rcu *qp1; @@ -726,7 +730,6 @@ struct qib_ibport { u8 vl_high_limit; u8 sl_to_vl[16]; - struct qib_opcode_stats opstats[128]; }; @@ -770,6 +773,10 @@ struct qib_ibdev { spinlock_t n_srqs_lock; u32 n_mcast_grps_allocated; /* number of mcast groups allocated */ spinlock_t n_mcast_grps_lock; +#ifdef CONFIG_DEBUG_FS + /* per HCA debugfs */ + struct dentry *qib_ibdev_dbg; +#endif }; struct qib_verbs_counters { From 17db3a92c144a0f8a81c52e94b7110bc86b5067f Mon Sep 17 00:00:00 2001 From: Mike Marciniszyn Date: Sat, 15 Jun 2013 17:07:09 -0400 Subject: [PATCH 0475/1048] IB/qib: Add per-context stats interface This patch adds a debugfs stats interface for per kernel contexts packet counts. The code uses the opcode stats count and eliminates the counter in the context. Reviewed-by: Dean Luick Signed-off-by: Mike Marciniszyn Signed-off-by: Roland Dreier --- drivers/infiniband/hw/qib/qib_debugfs.c | 63 +++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/drivers/infiniband/hw/qib/qib_debugfs.c b/drivers/infiniband/hw/qib/qib_debugfs.c index 47d01164cc91..a4e6ee154f19 100644 --- a/drivers/infiniband/hw/qib/qib_debugfs.c +++ b/drivers/infiniband/hw/qib/qib_debugfs.c @@ -126,6 +126,68 @@ static int _opcode_stats_seq_show(struct seq_file *s, void *v) DEBUGFS_FILE(opcode_stats) +static void *_ctx_stats_seq_start(struct seq_file *s, loff_t *pos) +{ + struct qib_ibdev *ibd = (struct qib_ibdev *)s->private; + struct qib_devdata *dd = dd_from_dev(ibd); + + if (!*pos) + return SEQ_START_TOKEN; + if (*pos >= dd->first_user_ctxt) + return NULL; + return pos; +} + +static void *_ctx_stats_seq_next(struct seq_file *s, void *v, loff_t *pos) +{ + struct qib_ibdev *ibd = (struct qib_ibdev *)s->private; + struct qib_devdata *dd = dd_from_dev(ibd); + + if (v == SEQ_START_TOKEN) + return pos; + + ++*pos; + if (*pos >= dd->first_user_ctxt) + return NULL; + return pos; +} + +static void _ctx_stats_seq_stop(struct seq_file *s, void *v) +{ + /* nothing allocated */ +} + +static int _ctx_stats_seq_show(struct seq_file *s, void *v) +{ + loff_t *spos; + loff_t i, j; + u64 n_packets = 0; + struct qib_ibdev *ibd = (struct qib_ibdev *)s->private; + struct qib_devdata *dd = dd_from_dev(ibd); + + if (v == SEQ_START_TOKEN) { + seq_puts(s, "Ctx:npkts\n"); + return 0; + } + + spos = v; + i = *spos; + + if (!dd->rcd[i]) + return SEQ_SKIP; + + for (j = 0; j < ARRAY_SIZE(dd->rcd[i]->opstats->stats); j++) + n_packets += dd->rcd[i]->opstats->stats[j].n_packets; + + if (!n_packets) + return SEQ_SKIP; + + seq_printf(s, " %llu:%llu\n", i, n_packets); + return 0; +} + +DEBUGFS_FILE(ctx_stats) + void qib_dbg_ibdev_init(struct qib_ibdev *ibd) { char name[10]; @@ -137,6 +199,7 @@ void qib_dbg_ibdev_init(struct qib_ibdev *ibd) return; } DEBUGFS_FILE_CREATE(opcode_stats); + DEBUGFS_FILE_CREATE(ctx_stats); return; } From 1dd173b01f52c7a197cab20563d5f4967472a852 Mon Sep 17 00:00:00 2001 From: Mike Marciniszyn Date: Sat, 15 Jun 2013 17:07:14 -0400 Subject: [PATCH 0476/1048] IB/qib: Add qp_stats debug file This adds a seq_file iterator for reporting the QP hash table when the qp_stats file is read. Reviewed-by: Dean Luick Signed-off-by: Mike Marciniszyn Signed-off-by: Roland Dreier --- drivers/infiniband/hw/qib/qib_debugfs.c | 54 ++++++++++++++ drivers/infiniband/hw/qib/qib_qp.c | 94 +++++++++++++++++++++++++ drivers/infiniband/hw/qib/qib_verbs.h | 14 +++- 3 files changed, 161 insertions(+), 1 deletion(-) diff --git a/drivers/infiniband/hw/qib/qib_debugfs.c b/drivers/infiniband/hw/qib/qib_debugfs.c index a4e6ee154f19..799a0c3bffc4 100644 --- a/drivers/infiniband/hw/qib/qib_debugfs.c +++ b/drivers/infiniband/hw/qib/qib_debugfs.c @@ -188,6 +188,59 @@ static int _ctx_stats_seq_show(struct seq_file *s, void *v) DEBUGFS_FILE(ctx_stats) +static void *_qp_stats_seq_start(struct seq_file *s, loff_t *pos) +{ + struct qib_qp_iter *iter; + loff_t n = *pos; + + iter = qib_qp_iter_init(s->private); + if (!iter) + return NULL; + + while (n--) { + if (qib_qp_iter_next(iter)) { + kfree(iter); + return NULL; + } + } + + return iter; +} + +static void *_qp_stats_seq_next(struct seq_file *s, void *iter_ptr, + loff_t *pos) +{ + struct qib_qp_iter *iter = iter_ptr; + + (*pos)++; + + if (qib_qp_iter_next(iter)) { + kfree(iter); + return NULL; + } + + return iter; +} + +static void _qp_stats_seq_stop(struct seq_file *s, void *iter_ptr) +{ + /* nothing for now */ +} + +static int _qp_stats_seq_show(struct seq_file *s, void *iter_ptr) +{ + struct qib_qp_iter *iter = iter_ptr; + + if (!iter) + return 0; + + qib_qp_iter_print(s, iter); + + return 0; +} + +DEBUGFS_FILE(qp_stats) + void qib_dbg_ibdev_init(struct qib_ibdev *ibd) { char name[10]; @@ -200,6 +253,7 @@ void qib_dbg_ibdev_init(struct qib_ibdev *ibd) } DEBUGFS_FILE_CREATE(opcode_stats); DEBUGFS_FILE_CREATE(ctx_stats); + DEBUGFS_FILE_CREATE(qp_stats); return; } diff --git a/drivers/infiniband/hw/qib/qib_qp.c b/drivers/infiniband/hw/qib/qib_qp.c index c1f573a331c7..3cca55b51e54 100644 --- a/drivers/infiniband/hw/qib/qib_qp.c +++ b/drivers/infiniband/hw/qib/qib_qp.c @@ -35,6 +35,9 @@ #include #include #include +#ifdef CONFIG_DEBUG_FS +#include +#endif #include "qib.h" @@ -1287,3 +1290,94 @@ void qib_get_credit(struct qib_qp *qp, u32 aeth) } } } + +#ifdef CONFIG_DEBUG_FS + +struct qib_qp_iter { + struct qib_ibdev *dev; + struct qib_qp *qp; + int n; +}; + +struct qib_qp_iter *qib_qp_iter_init(struct qib_ibdev *dev) +{ + struct qib_qp_iter *iter; + + iter = kzalloc(sizeof(*iter), GFP_KERNEL); + if (!iter) + return NULL; + + iter->dev = dev; + if (qib_qp_iter_next(iter)) { + kfree(iter); + return NULL; + } + + return iter; +} + +int qib_qp_iter_next(struct qib_qp_iter *iter) +{ + struct qib_ibdev *dev = iter->dev; + int n = iter->n; + int ret = 1; + struct qib_qp *pqp = iter->qp; + struct qib_qp *qp; + + rcu_read_lock(); + for (; n < dev->qp_table_size; n++) { + if (pqp) + qp = rcu_dereference(pqp->next); + else + qp = rcu_dereference(dev->qp_table[n]); + pqp = qp; + if (qp) { + if (iter->qp) + atomic_dec(&iter->qp->refcount); + atomic_inc(&qp->refcount); + rcu_read_unlock(); + iter->qp = qp; + iter->n = n; + return 0; + } + } + rcu_read_unlock(); + if (iter->qp) + atomic_dec(&iter->qp->refcount); + return ret; +} + +static const char * const qp_type_str[] = { + "SMI", "GSI", "RC", "UC", "UD", +}; + +void qib_qp_iter_print(struct seq_file *s, struct qib_qp_iter *iter) +{ + struct qib_swqe *wqe; + struct qib_qp *qp = iter->qp; + + wqe = get_swqe_ptr(qp, qp->s_last); + seq_printf(s, + "N %d QP%u %s %u %u %u f=%x %u %u %u %u %u PSN %x %x %x %x %x (%u %u %u %u %u %u) QP%u LID %x\n", + iter->n, + qp->ibqp.qp_num, + qp_type_str[qp->ibqp.qp_type], + qp->state, + wqe->wr.opcode, + qp->s_hdrwords, + qp->s_flags, + atomic_read(&qp->s_dma_busy), + !list_empty(&qp->iowait), + qp->timeout, + wqe->ssn, + qp->s_lsn, + qp->s_last_psn, + qp->s_psn, qp->s_next_psn, + qp->s_sending_psn, qp->s_sending_hpsn, + qp->s_last, qp->s_acked, qp->s_cur, + qp->s_tail, qp->s_head, qp->s_size, + qp->remote_qpn, + qp->remote_ah_attr.dlid); +} + +#endif diff --git a/drivers/infiniband/hw/qib/qib_verbs.h b/drivers/infiniband/hw/qib/qib_verbs.h index 4a22a85b9f03..012e2c7575ad 100644 --- a/drivers/infiniband/hw/qib/qib_verbs.h +++ b/drivers/infiniband/hw/qib/qib_verbs.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012 Intel Corporation. All rights reserved. + * Copyright (c) 2012, 2013 Intel Corporation. All rights reserved. * Copyright (c) 2006 - 2012 QLogic Corporation. All rights reserved. * Copyright (c) 2005, 2006 PathScale, Inc. All rights reserved. * @@ -917,6 +917,18 @@ void qib_init_qpn_table(struct qib_devdata *dd, struct qib_qpn_table *qpt); void qib_free_qpn_table(struct qib_qpn_table *qpt); +#ifdef CONFIG_DEBUG_FS + +struct qib_qp_iter; + +struct qib_qp_iter *qib_qp_iter_init(struct qib_ibdev *dev); + +int qib_qp_iter_next(struct qib_qp_iter *iter); + +void qib_qp_iter_print(struct seq_file *s, struct qib_qp_iter *iter); + +#endif + void qib_get_credit(struct qib_qp *qp, u32 aeth); unsigned qib_pkt_delay(u32 plen, u8 snd_mult, u8 rcv_mult); From c94e15c5cb4d02579321382871eb87e17d10858e Mon Sep 17 00:00:00 2001 From: Wei Yongjun Date: Sun, 23 Jun 2013 09:07:19 +0800 Subject: [PATCH 0477/1048] RDMA/ocrdma: Fix error return code in ocrdma_set_create_qp_rq_cmd() Fix to return -ENOMEM in the alloc dma coherent error case instead of 0, as done elsewhere in this function. Signed-off-by: Wei Yongjun Signed-off-by: Roland Dreier --- drivers/infiniband/hw/ocrdma/ocrdma_hw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_hw.c b/drivers/infiniband/hw/ocrdma/ocrdma_hw.c index 76c9e192ddcc..0965278dd2ed 100644 --- a/drivers/infiniband/hw/ocrdma/ocrdma_hw.c +++ b/drivers/infiniband/hw/ocrdma/ocrdma_hw.c @@ -1886,7 +1886,7 @@ static int ocrdma_set_create_qp_rq_cmd(struct ocrdma_create_qp_req *cmd, qp->rq.va = dma_alloc_coherent(&pdev->dev, len, &pa, GFP_KERNEL); if (!qp->rq.va) - return status; + return -ENOMEM; memset(qp->rq.va, 0, len); qp->rq.pa = pa; qp->rq.len = len; From 80b15043e3450e730d30b71c099ab00d75a551ce Mon Sep 17 00:00:00 2001 From: Wei Yongjun Date: Fri, 21 Jun 2013 11:24:27 +0800 Subject: [PATCH 0478/1048] IB/core: Fix error return code in add_port() Fix to return -ENOMEM in the add_port() error handling case instead of 0, as done elsewhere in this function. Signed-off-by: Wei Yongjun Signed-off-by: Roland Dreier --- drivers/infiniband/core/sysfs.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/infiniband/core/sysfs.c b/drivers/infiniband/core/sysfs.c index 246fdc151652..d9b78c4d0aad 100644 --- a/drivers/infiniband/core/sysfs.c +++ b/drivers/infiniband/core/sysfs.c @@ -545,8 +545,10 @@ static int add_port(struct ib_device *device, int port_num, p->gid_group.name = "gids"; p->gid_group.attrs = alloc_group_attrs(show_port_gid, attr.gid_tbl_len); - if (!p->gid_group.attrs) + if (!p->gid_group.attrs) { + ret = -ENOMEM; goto err_remove_pma; + } ret = sysfs_create_group(&p->kobj, &p->gid_group); if (ret) @@ -555,8 +557,10 @@ static int add_port(struct ib_device *device, int port_num, p->pkey_group.name = "pkeys"; p->pkey_group.attrs = alloc_group_attrs(show_port_pkey, attr.pkey_tbl_len); - if (!p->pkey_group.attrs) + if (!p->pkey_group.attrs) { + ret = -ENOMEM; goto err_remove_gid; + } ret = sysfs_create_group(&p->kobj, &p->pkey_group); if (ret) From 05959be7b646e8755a9339ad13e3b87849249f90 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Sat, 22 Jun 2013 11:23:58 -0300 Subject: [PATCH 0479/1048] [media] uvc: Depend on VIDEO_V4L2 The uvcvideo driver lost its dependency on VIDEO_V4L2 during the big media directory reorganization. Add it back. Reported-by: Randy Dunlap Signed-off-by: Laurent Pinchart Acked-by: Randy Dunlap Signed-off-by: Mauro Carvalho Chehab --- drivers/media/usb/uvc/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/media/usb/uvc/Kconfig b/drivers/media/usb/uvc/Kconfig index 541c9f1e4c6a..6ed85efabcaa 100644 --- a/drivers/media/usb/uvc/Kconfig +++ b/drivers/media/usb/uvc/Kconfig @@ -1,5 +1,6 @@ config USB_VIDEO_CLASS tristate "USB Video Class (UVC)" + depends on VIDEO_V4L2 select VIDEOBUF2_VMALLOC ---help--- Support for the USB Video Class (UVC). Currently only video From 0be0aea2ffa2be1590c86dc226291939bd5535b0 Mon Sep 17 00:00:00 2001 From: Markos Chandras Date: Tue, 25 Jun 2013 10:29:27 +0000 Subject: [PATCH 0480/1048] MIPS: Sibyte: Platform: Add load address for CONFIG_SIBYTE_LITTLESUR Fixes the following build problem: mips-linux-gnu-ld:arch/mips/kernel/vmlinux.lds:253: syntax error because VMLINUX_LOAD_ADDRESS was an empty string for that platform so the vmlinux.lds.S created an invalid section entry on line 50. Signed-off-by: Markos Chandras Acked-by: Steven J. Hill Cc: sibyte-users@bitmover.com Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/5548/ Signed-off-by: Ralf Baechle --- arch/mips/sibyte/Platform | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/mips/sibyte/Platform b/arch/mips/sibyte/Platform index d03a07516f83..1bf90dcd49d2 100644 --- a/arch/mips/sibyte/Platform +++ b/arch/mips/sibyte/Platform @@ -41,3 +41,4 @@ load-$(CONFIG_SIBYTE_RHONE) := 0xffffffff80100000 load-$(CONFIG_SIBYTE_SENTOSA) := 0xffffffff80100000 load-$(CONFIG_SIBYTE_SWARM) := 0xffffffff80100000 load-$(CONFIG_SIBYTE_BIGSUR) := 0xffffffff80100000 +load-$(CONFIG_SIBYTE_LITTLESUR) := 0xffffffff80100000 From 5bd807659bfd5d5a393b2269dc3e9699dddd9ad6 Mon Sep 17 00:00:00 2001 From: Markos Chandras Date: Mon, 24 Jun 2013 14:42:21 +0000 Subject: [PATCH 0481/1048] MIPS: SNI: pcimt: Guard sni_controller with CONFIG_PCI Fixes the following build problem: arch/mips/sni/pcimt.c:188:30: error: 'sni_controller' defined but not used [-Werror=unused-variable] Signed-off-by: Markos Chandras Acked-by: Steven J. Hill Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/5547/ Signed-off-by: Ralf Baechle --- arch/mips/sni/pcimt.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/mips/sni/pcimt.c b/arch/mips/sni/pcimt.c index cec4b8ca1438..12336c2a649c 100644 --- a/arch/mips/sni/pcimt.c +++ b/arch/mips/sni/pcimt.c @@ -185,6 +185,7 @@ static void __init sni_pcimt_resource_init(void) extern struct pci_ops sni_pcimt_ops; +#ifdef CONFIG_PCI static struct pci_controller sni_controller = { .pci_ops = &sni_pcimt_ops, .mem_resource = &sni_mem_resource, @@ -193,6 +194,7 @@ static struct pci_controller sni_controller = { .io_offset = 0x00000000UL, .io_map_base = SNI_PORT_BASE }; +#endif static void enable_pcimt_irq(struct irq_data *d) { From 6a72015d3c3602dd969e79510486807c481a0e1b Mon Sep 17 00:00:00 2001 From: Ralf Baechle Date: Tue, 25 Jun 2013 17:10:28 +0200 Subject: [PATCH 0482/1048] MIPS: SNI: pcit: Fix build error with CONFIG_PCI=n disabled. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CC arch/mips/sni/pcit.o arch/mips/sni/pcit.c:150:30: warning: ‘sni_pcit_controller’ defined but not used [-Wunused-variable] Signed-off-by: Ralf Baechle --- arch/mips/sni/pcit.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/arch/mips/sni/pcit.c b/arch/mips/sni/pcit.c index 7cddd03d1fea..05bb51676e82 100644 --- a/arch/mips/sni/pcit.c +++ b/arch/mips/sni/pcit.c @@ -128,13 +128,6 @@ static struct resource pcit_io_resources[] = { } }; -static struct resource sni_mem_resource = { - .start = 0x18000000UL, - .end = 0x1fbfffffUL, - .name = "PCIT PCI MEM", - .flags = IORESOURCE_MEM -}; - static void __init sni_pcit_resource_init(void) { int i; @@ -147,6 +140,14 @@ static void __init sni_pcit_resource_init(void) extern struct pci_ops sni_pcit_ops; +#ifdef CONFIG_PCI +static struct resource sni_mem_resource = { + .start = 0x18000000UL, + .end = 0x1fbfffffUL, + .name = "PCIT PCI MEM", + .flags = IORESOURCE_MEM +}; + static struct pci_controller sni_pcit_controller = { .pci_ops = &sni_pcit_ops, .mem_resource = &sni_mem_resource, @@ -155,6 +156,7 @@ static struct pci_controller sni_pcit_controller = { .io_offset = 0x00000000UL, .io_map_base = SNI_PORT_BASE }; +#endif /* CONFIG_PCI */ static void enable_pcit_irq(struct irq_data *d) { From a3d9086bb121a6459c9ed0452e3c58891a504785 Mon Sep 17 00:00:00 2001 From: Jonas Gorski Date: Fri, 21 Jun 2013 17:48:48 +0000 Subject: [PATCH 0483/1048] MIPS: Flush TLB handlers directly after writing them When having enabled MIPS_PGD_C0_CONTEXT, trap_init() might call the generated tlbmiss_handler_setup_pgd before it was committed to memory, causing boot failures: trap_init() |- per_cpu_trap_init() | |- TLBMISS_HANDLER_SETUP() | |- tlbmiss_handler_setup_pgd() |- flush_tlb_handlers() To avoid this, move flush_tlb_handlers() into build_tlb_refill_handler() right after they were generated. We can do this as the cache handling is initialized just before creating the tlb handlers. This issue was introduced in 3d8bfdd0307223de678962f1c1907a7cec549136 ("MIPS: Use C0_KScratch (if present) to hold PGD pointer."). Signed-off-by: Jonas Gorski Cc: linux-mips@linux-mips.org Cc: Steven J. Hill Cc: Jayachandran C Cc: David Daney Patchwork: https://patchwork.linux-mips.org/patch/5539/ Signed-off-by: Ralf Baechle --- arch/mips/kernel/traps.c | 2 -- arch/mips/mm/tlbex.c | 30 ++++++++++++++++-------------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c index a75ae40184aa..8ef484c6b9d8 100644 --- a/arch/mips/kernel/traps.c +++ b/arch/mips/kernel/traps.c @@ -1627,7 +1627,6 @@ void *set_vi_handler(int n, vi_handler_t addr) } extern void tlb_init(void); -extern void flush_tlb_handlers(void); /* * Timer interrupt @@ -1956,7 +1955,6 @@ void __init trap_init(void) set_handler(0x080, &except_vec3_generic, 0x80); local_flush_icache_range(ebase, ebase + 0x400); - flush_tlb_handlers(); sort_extable(__start___dbe_table, __stop___dbe_table); diff --git a/arch/mips/mm/tlbex.c b/arch/mips/mm/tlbex.c index f0f4dc44f394..7f6cd461dac5 100644 --- a/arch/mips/mm/tlbex.c +++ b/arch/mips/mm/tlbex.c @@ -2181,6 +2181,20 @@ static void __cpuinit build_r4000_tlb_modify_handler(void) dump_handler("r4000_tlb_modify", handle_tlbm, ARRAY_SIZE(handle_tlbm)); } +static void __cpuinit flush_tlb_handlers(void) +{ + local_flush_icache_range((unsigned long)handle_tlbl, + (unsigned long)handle_tlbl + sizeof(handle_tlbl)); + local_flush_icache_range((unsigned long)handle_tlbs, + (unsigned long)handle_tlbs + sizeof(handle_tlbs)); + local_flush_icache_range((unsigned long)handle_tlbm, + (unsigned long)handle_tlbm + sizeof(handle_tlbm)); +#ifdef CONFIG_MIPS_PGD_C0_CONTEXT + local_flush_icache_range((unsigned long)tlbmiss_handler_setup_pgd_array, + (unsigned long)tlbmiss_handler_setup_pgd_array + sizeof(handle_tlbm)); +#endif +} + void __cpuinit build_tlb_refill_handler(void) { /* @@ -2213,6 +2227,7 @@ void __cpuinit build_tlb_refill_handler(void) build_r3000_tlb_load_handler(); build_r3000_tlb_store_handler(); build_r3000_tlb_modify_handler(); + flush_tlb_handlers(); run_once++; } #else @@ -2240,23 +2255,10 @@ void __cpuinit build_tlb_refill_handler(void) build_r4000_tlb_modify_handler(); if (!cpu_has_local_ebase) build_r4000_tlb_refill_handler(); + flush_tlb_handlers(); run_once++; } if (cpu_has_local_ebase) build_r4000_tlb_refill_handler(); } } - -void __cpuinit flush_tlb_handlers(void) -{ - local_flush_icache_range((unsigned long)handle_tlbl, - (unsigned long)handle_tlbl + sizeof(handle_tlbl)); - local_flush_icache_range((unsigned long)handle_tlbs, - (unsigned long)handle_tlbs + sizeof(handle_tlbs)); - local_flush_icache_range((unsigned long)handle_tlbm, - (unsigned long)handle_tlbm + sizeof(handle_tlbm)); -#ifdef CONFIG_MIPS_PGD_C0_CONTEXT - local_flush_icache_range((unsigned long)tlbmiss_handler_setup_pgd_array, - (unsigned long)tlbmiss_handler_setup_pgd_array + sizeof(handle_tlbm)); -#endif -} From 22baa407f9e67636a3fd740a552f8f5e06cf8db5 Mon Sep 17 00:00:00 2001 From: Mitko Haralanov Date: Wed, 26 Jun 2013 10:46:22 -0400 Subject: [PATCH 0484/1048] IB/qib: New transmitter tunning settings for Dell 1.1 backplane The Dell blade chassis got an updated backplane which requires new transmitter tuning settings. Signed-off-by: Mitko Haralanov Signed-off-by: Mike Marciniszyn Signed-off-by: Roland Dreier --- drivers/infiniband/hw/qib/qib_iba7322.c | 59 ++++++++++++++++--------- 1 file changed, 37 insertions(+), 22 deletions(-) diff --git a/drivers/infiniband/hw/qib/qib_iba7322.c b/drivers/infiniband/hw/qib/qib_iba7322.c index 46ffea033be0..f7c4b44b1f93 100644 --- a/drivers/infiniband/hw/qib/qib_iba7322.c +++ b/drivers/infiniband/hw/qib/qib_iba7322.c @@ -590,7 +590,7 @@ struct vendor_txdds_ent { static void write_tx_serdes_param(struct qib_pportdata *, struct txdds_ent *); #define TXDDS_TABLE_SZ 16 /* number of entries per speed in onchip table */ -#define TXDDS_EXTRA_SZ 13 /* number of extra tx settings entries */ +#define TXDDS_EXTRA_SZ 18 /* number of extra tx settings entries */ #define TXDDS_MFG_SZ 2 /* number of mfg tx settings entries */ #define SERDES_CHANS 4 /* yes, it's obvious, but one less magic number */ @@ -7466,15 +7466,20 @@ static const struct txdds_ent txdds_extra_sdr[TXDDS_EXTRA_SZ] = { { 0, 0, 0, 1 }, /* QMH7342 backplane settings */ { 0, 0, 0, 2 }, /* QMH7342 backplane settings */ { 0, 0, 0, 2 }, /* QMH7342 backplane settings */ - { 0, 0, 0, 11 }, /* QME7342 backplane settings */ - { 0, 0, 0, 11 }, /* QME7342 backplane settings */ - { 0, 0, 0, 11 }, /* QME7342 backplane settings */ - { 0, 0, 0, 11 }, /* QME7342 backplane settings */ - { 0, 0, 0, 11 }, /* QME7342 backplane settings */ - { 0, 0, 0, 11 }, /* QME7342 backplane settings */ - { 0, 0, 0, 11 }, /* QME7342 backplane settings */ { 0, 0, 0, 3 }, /* QMH7342 backplane settings */ { 0, 0, 0, 4 }, /* QMH7342 backplane settings */ + { 0, 1, 4, 15 }, /* QME7342 backplane settings 1.0 */ + { 0, 1, 3, 15 }, /* QME7342 backplane settings 1.0 */ + { 0, 1, 0, 12 }, /* QME7342 backplane settings 1.0 */ + { 0, 1, 0, 11 }, /* QME7342 backplane settings 1.0 */ + { 0, 1, 0, 9 }, /* QME7342 backplane settings 1.0 */ + { 0, 1, 0, 14 }, /* QME7342 backplane settings 1.0 */ + { 0, 1, 2, 15 }, /* QME7342 backplane settings 1.0 */ + { 0, 1, 0, 11 }, /* QME7342 backplane settings 1.1 */ + { 0, 1, 0, 7 }, /* QME7342 backplane settings 1.1 */ + { 0, 1, 0, 9 }, /* QME7342 backplane settings 1.1 */ + { 0, 1, 0, 6 }, /* QME7342 backplane settings 1.1 */ + { 0, 1, 0, 8 }, /* QME7342 backplane settings 1.1 */ }; static const struct txdds_ent txdds_extra_ddr[TXDDS_EXTRA_SZ] = { @@ -7483,15 +7488,20 @@ static const struct txdds_ent txdds_extra_ddr[TXDDS_EXTRA_SZ] = { { 0, 0, 0, 7 }, /* QMH7342 backplane settings */ { 0, 0, 0, 8 }, /* QMH7342 backplane settings */ { 0, 0, 0, 8 }, /* QMH7342 backplane settings */ - { 0, 0, 0, 13 }, /* QME7342 backplane settings */ - { 0, 0, 0, 13 }, /* QME7342 backplane settings */ - { 0, 0, 0, 13 }, /* QME7342 backplane settings */ - { 0, 0, 0, 13 }, /* QME7342 backplane settings */ - { 0, 0, 0, 13 }, /* QME7342 backplane settings */ - { 0, 0, 0, 13 }, /* QME7342 backplane settings */ - { 0, 0, 0, 13 }, /* QME7342 backplane settings */ { 0, 0, 0, 9 }, /* QMH7342 backplane settings */ { 0, 0, 0, 10 }, /* QMH7342 backplane settings */ + { 0, 1, 4, 15 }, /* QME7342 backplane settings 1.0 */ + { 0, 1, 3, 15 }, /* QME7342 backplane settings 1.0 */ + { 0, 1, 0, 12 }, /* QME7342 backplane settings 1.0 */ + { 0, 1, 0, 11 }, /* QME7342 backplane settings 1.0 */ + { 0, 1, 0, 9 }, /* QME7342 backplane settings 1.0 */ + { 0, 1, 0, 14 }, /* QME7342 backplane settings 1.0 */ + { 0, 1, 2, 15 }, /* QME7342 backplane settings 1.0 */ + { 0, 1, 0, 11 }, /* QME7342 backplane settings 1.1 */ + { 0, 1, 0, 7 }, /* QME7342 backplane settings 1.1 */ + { 0, 1, 0, 9 }, /* QME7342 backplane settings 1.1 */ + { 0, 1, 0, 6 }, /* QME7342 backplane settings 1.1 */ + { 0, 1, 0, 8 }, /* QME7342 backplane settings 1.1 */ }; static const struct txdds_ent txdds_extra_qdr[TXDDS_EXTRA_SZ] = { @@ -7500,15 +7510,20 @@ static const struct txdds_ent txdds_extra_qdr[TXDDS_EXTRA_SZ] = { { 0, 1, 0, 5 }, /* QMH7342 backplane settings */ { 0, 1, 0, 6 }, /* QMH7342 backplane settings */ { 0, 1, 0, 8 }, /* QMH7342 backplane settings */ - { 0, 1, 12, 10 }, /* QME7342 backplane setting */ - { 0, 1, 12, 11 }, /* QME7342 backplane setting */ - { 0, 1, 12, 12 }, /* QME7342 backplane setting */ - { 0, 1, 12, 14 }, /* QME7342 backplane setting */ - { 0, 1, 12, 6 }, /* QME7342 backplane setting */ - { 0, 1, 12, 7 }, /* QME7342 backplane setting */ - { 0, 1, 12, 8 }, /* QME7342 backplane setting */ { 0, 1, 0, 10 }, /* QMH7342 backplane settings */ { 0, 1, 0, 12 }, /* QMH7342 backplane settings */ + { 0, 1, 4, 15 }, /* QME7342 backplane settings 1.0 */ + { 0, 1, 3, 15 }, /* QME7342 backplane settings 1.0 */ + { 0, 1, 0, 12 }, /* QME7342 backplane settings 1.0 */ + { 0, 1, 0, 11 }, /* QME7342 backplane settings 1.0 */ + { 0, 1, 0, 9 }, /* QME7342 backplane settings 1.0 */ + { 0, 1, 0, 14 }, /* QME7342 backplane settings 1.0 */ + { 0, 1, 2, 15 }, /* QME7342 backplane settings 1.0 */ + { 0, 1, 0, 11 }, /* QME7342 backplane settings 1.1 */ + { 0, 1, 0, 7 }, /* QME7342 backplane settings 1.1 */ + { 0, 1, 0, 9 }, /* QME7342 backplane settings 1.1 */ + { 0, 1, 0, 6 }, /* QME7342 backplane settings 1.1 */ + { 0, 1, 0, 8 }, /* QME7342 backplane settings 1.1 */ }; static const struct txdds_ent txdds_extra_mfg[TXDDS_MFG_SZ] = { From 3f90b82df110ef9cb33761b56ca85ae0d0372d4a Mon Sep 17 00:00:00 2001 From: Ralf Baechle Date: Thu, 27 Jun 2013 02:04:25 +0200 Subject: [PATCH 0485/1048] MIPS: tlbex: Fix size of area to be flushed. Signed-off-by: Ralf Baechle --- arch/mips/mm/tlbex.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/mips/mm/tlbex.c b/arch/mips/mm/tlbex.c index 7f6cd461dac5..2f88fd3a64cf 100644 --- a/arch/mips/mm/tlbex.c +++ b/arch/mips/mm/tlbex.c @@ -2191,7 +2191,7 @@ static void __cpuinit flush_tlb_handlers(void) (unsigned long)handle_tlbm + sizeof(handle_tlbm)); #ifdef CONFIG_MIPS_PGD_C0_CONTEXT local_flush_icache_range((unsigned long)tlbmiss_handler_setup_pgd_array, - (unsigned long)tlbmiss_handler_setup_pgd_array + sizeof(handle_tlbm)); + (unsigned long)tlbmiss_handler_setup_pgd_array + sizeof(tlbmiss_handler_setup_pgd_array)); #endif } From 1fe0cb848890a3f4dd965fdce8b4108feb03971f Mon Sep 17 00:00:00 2001 From: Dotan Barak Date: Wed, 12 Jun 2013 15:20:36 +0200 Subject: [PATCH 0486/1048] IB/srp: Fix remove_one crash due to resource exhaustion If the add_one callback fails during driver load no resources are allocated so there isn't a need to release any resources. Trying to clean the resource may lead to the following kernel panic: BUG: unable to handle kernel NULL pointer dereference at (null) IP: [] srp_remove_one+0x31/0x240 [ib_srp] RIP: 0010:[] [] srp_remove_one+0x31/0x240 [ib_srp] Process rmmod (pid: 4562, threadinfo ffff8800dd738000, task ffff8801167e60c0) Call Trace: [] ib_unregister_client+0x4e/0x120 [ib_core] [] srp_cleanup_module+0x15/0x71 [ib_srp] [] sys_delete_module+0x194/0x260 [] system_call_fastpath+0x16/0x1b Signed-off-by: Dotan Barak Reviewed-by: Eli Cohen Signed-off-by: Bart Van Assche Acked-by: Sebastian Riemer Acked-by: David Dillow Signed-off-by: Roland Dreier --- drivers/infiniband/ulp/srp/ib_srp.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c index 7ccf3284dda3..368d1606e16f 100644 --- a/drivers/infiniband/ulp/srp/ib_srp.c +++ b/drivers/infiniband/ulp/srp/ib_srp.c @@ -2507,6 +2507,8 @@ static void srp_remove_one(struct ib_device *device) struct srp_target_port *target; srp_dev = ib_get_client_data(device, &srp_client); + if (!srp_dev) + return; list_for_each_entry_safe(host, tmp_host, &srp_dev->dev_list, list) { device_unregister(&host->dev); From 086f44f58855ae18bab19fb794cce6c6d2c6143b Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Wed, 12 Jun 2013 15:23:04 +0200 Subject: [PATCH 0487/1048] IB/srp: Avoid skipping srp_reset_host() after a transport error The SCSI error handler assumes that the transport layer is operational if an eh_abort_handler() returns SUCCESS. Hence srp_abort() only should return SUCCESS if sending the ABORT TASK task management function succeeded. This patch avoids the SCSI error handler skipping the srp_reset_host() call after a transport layer error. Signed-off-by: Bart Van Assche Acked-by: David Dillow Signed-off-by: Roland Dreier --- drivers/infiniband/ulp/srp/ib_srp.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c index 368d1606e16f..759c55b9685f 100644 --- a/drivers/infiniband/ulp/srp/ib_srp.c +++ b/drivers/infiniband/ulp/srp/ib_srp.c @@ -1744,18 +1744,23 @@ static int srp_abort(struct scsi_cmnd *scmnd) { struct srp_target_port *target = host_to_target(scmnd->device->host); struct srp_request *req = (struct srp_request *) scmnd->host_scribble; + int ret; shost_printk(KERN_ERR, target->scsi_host, "SRP abort called\n"); if (!req || !srp_claim_req(target, req, scmnd)) return FAILED; - srp_send_tsk_mgmt(target, req->index, scmnd->device->lun, - SRP_TSK_ABORT_TASK); + if (srp_send_tsk_mgmt(target, req->index, scmnd->device->lun, + SRP_TSK_ABORT_TASK) == 0 || + target->transport_offline) + ret = SUCCESS; + else + ret = FAILED; srp_free_req(target, req, scmnd, 0); scmnd->result = DID_ABORT << 16; scmnd->scsi_done(scmnd); - return SUCCESS; + return ret; } static int srp_reset_device(struct scsi_cmnd *scmnd) From 2742c1dadde602baea6f0547c028154aebd6f1ca Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Wed, 12 Jun 2013 15:24:25 +0200 Subject: [PATCH 0488/1048] IB/srp: Skip host settle delay The SRP initiator implements host reset by reconnecting to the SRP target. That means that communication with the target is possible as soon as host reset finished. Hence skip the host settle delay. Signed-off-by: Bart Van Assche Reviewed-by: Sebastian Riemer Reviewed-by: Christoph Hellwig Acked-by: David Dillow Signed-off-by: Roland Dreier --- drivers/infiniband/ulp/srp/ib_srp.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c index 759c55b9685f..bc13c8db7fc2 100644 --- a/drivers/infiniband/ulp/srp/ib_srp.c +++ b/drivers/infiniband/ulp/srp/ib_srp.c @@ -1951,6 +1951,7 @@ static struct scsi_host_template srp_template = { .eh_abort_handler = srp_abort, .eh_device_reset_handler = srp_reset_device, .eh_host_reset_handler = srp_reset_host, + .skip_settle_delay = true, .sg_tablesize = SRP_DEF_SG_TABLESIZE, .can_queue = SRP_CMD_SQ_SIZE, .this_id = -1, From c4d6e6310b90422473f8bd5f9c8d3548f65a38da Mon Sep 17 00:00:00 2001 From: Guennadi Liakhovetski Date: Mon, 24 Jun 2013 05:08:05 -0300 Subject: [PATCH 0489/1048] [media] V4L2: sh_vou: add I2C build dependency The sh_vou driver needs CONFIG_I2C or CONFIG_I2C_MODULE to build, add the respective dependency. Signed-off-by: Guennadi Liakhovetski Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig index 0494d2769fd7..bd99e5055fa1 100644 --- a/drivers/media/platform/Kconfig +++ b/drivers/media/platform/Kconfig @@ -36,7 +36,7 @@ source "drivers/media/platform/blackfin/Kconfig" config VIDEO_SH_VOU tristate "SuperH VOU video output driver" depends on MEDIA_CAMERA_SUPPORT - depends on VIDEO_DEV && ARCH_SHMOBILE + depends on VIDEO_DEV && ARCH_SHMOBILE && I2C select VIDEOBUF_DMA_CONTIG help Support for the Video Output Unit (VOU) on SuperH SoCs. From fe05e141a4d70d9417fd628133ecb32851f2e136 Mon Sep 17 00:00:00 2001 From: Guennadi Liakhovetski Date: Mon, 24 Jun 2013 05:13:51 -0300 Subject: [PATCH 0490/1048] [media] V4L2: fix compilation if CONFIG_I2C is undefined i2c_verify_client() is only available, if I2C is enabled. Fix v4l2-async.c compilation if I2C is disabled. Signed-off-by: Guennadi Liakhovetski Signed-off-by: Mauro Carvalho Chehab --- drivers/media/v4l2-core/v4l2-async.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/media/v4l2-core/v4l2-async.c b/drivers/media/v4l2-core/v4l2-async.c index c80ffb4ba567..aae241730caa 100644 --- a/drivers/media/v4l2-core/v4l2-async.c +++ b/drivers/media/v4l2-core/v4l2-async.c @@ -24,11 +24,15 @@ static bool match_i2c(struct device *dev, struct v4l2_async_subdev *asd) { +#if IS_ENABLED(CONFIG_I2C) struct i2c_client *client = i2c_verify_client(dev); return client && asd->bus_type == V4L2_ASYNC_BUS_I2C && asd->match.i2c.adapter_id == client->adapter->nr && asd->match.i2c.address == client->addr; +#else + return false; +#endif } static bool match_platform(struct device *dev, struct v4l2_async_subdev *asd) From f687f3263e99e34289e076352fad23974ee072ab Mon Sep 17 00:00:00 2001 From: Guennadi Liakhovetski Date: Mon, 24 Jun 2013 05:19:19 -0300 Subject: [PATCH 0491/1048] [media] V4L2: soc-camera: fix uninitialised use compiler warning In scan_async_group() if the size parameter is negative, the sasd pointer will be used uninitialised: drivers/media/platform/soc_camera/soc_camera.c: In function "soc_camera_host_register": drivers/media/platform/soc_camera/soc_camera.c:1514:55: warning: "sasd" may be used uninitialized in this function [-Wmaybe-uninitialized] sasd->asd.match.i2c.adapter_id, sasd->asd.match.i2c.address); ^ drivers/media/platform/soc_camera/soc_camera.c:1464:34: note: "sasd" was declared here struct soc_camera_async_subdev *sasd; Fix this by making "size" and the array, from which it is assigned unsigned. Signed-off-by: Guennadi Liakhovetski Acked-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/soc_camera/soc_camera.c | 2 +- include/media/sh_mobile_ceu.h | 2 +- include/media/soc_camera.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/media/platform/soc_camera/soc_camera.c b/drivers/media/platform/soc_camera/soc_camera.c index 2e47b5127d4b..2dd0e5272941 100644 --- a/drivers/media/platform/soc_camera/soc_camera.c +++ b/drivers/media/platform/soc_camera/soc_camera.c @@ -1459,7 +1459,7 @@ static int soc_camera_async_complete(struct v4l2_async_notifier *notifier) } static int scan_async_group(struct soc_camera_host *ici, - struct v4l2_async_subdev **asd, int size) + struct v4l2_async_subdev **asd, unsigned int size) { struct soc_camera_async_subdev *sasd; struct soc_camera_async_client *sasc; diff --git a/include/media/sh_mobile_ceu.h b/include/media/sh_mobile_ceu.h index 8937241e5f37..7f57056c22ba 100644 --- a/include/media/sh_mobile_ceu.h +++ b/include/media/sh_mobile_ceu.h @@ -23,7 +23,7 @@ struct sh_mobile_ceu_info { int max_height; struct sh_mobile_ceu_companion *csi2; struct v4l2_async_subdev **asd; /* Flat array, arranged in groups */ - int *asd_sizes; /* 0-terminated array pf asd group sizes */ + unsigned int *asd_sizes; /* 0-terminated array pf asd group sizes */ }; #endif /* __ASM_SH_MOBILE_CEU_H__ */ diff --git a/include/media/soc_camera.h b/include/media/soc_camera.h index 906ed98c6e95..34d2414f2b8c 100644 --- a/include/media/soc_camera.h +++ b/include/media/soc_camera.h @@ -87,7 +87,7 @@ struct soc_camera_host { const char *drv_name; struct soc_camera_host_ops *ops; struct v4l2_async_subdev **asd; /* Flat array, arranged in groups */ - int *asd_sizes; /* 0-terminated array of asd group sizes */ + unsigned int *asd_sizes; /* 0-terminated array of asd group sizes */ }; struct soc_camera_host_ops { From c67f1a300a72a67c1fa71cada8380bbe8412d046 Mon Sep 17 00:00:00 2001 From: Guennadi Liakhovetski Date: Mon, 17 Jun 2013 02:50:33 -0300 Subject: [PATCH 0492/1048] [media] V4L2: add documentation for V4L2 clock helpers and asynchronous probing Add documentation for the V4L2 clock and V4L2 asynchronous probing APIs to v4l2-framework.txt. Signed-off-by: Guennadi Liakhovetski Reviewed-by: Sylwester Nawrocki Signed-off-by: Mauro Carvalho Chehab --- Documentation/video4linux/v4l2-framework.txt | 73 +++++++++++++++++++- 1 file changed, 71 insertions(+), 2 deletions(-) diff --git a/Documentation/video4linux/v4l2-framework.txt b/Documentation/video4linux/v4l2-framework.txt index b5e6347b720f..6c4866b49eb5 100644 --- a/Documentation/video4linux/v4l2-framework.txt +++ b/Documentation/video4linux/v4l2-framework.txt @@ -325,8 +325,27 @@ that width, height and the media bus pixel code are equal on both source and sink of the link. Subdev drivers are also free to use this function to perform the checks mentioned above in addition to their own checks. -A device (bridge) driver needs to register the v4l2_subdev with the -v4l2_device: +There are currently two ways to register subdevices with the V4L2 core. The +first (traditional) possibility is to have subdevices registered by bridge +drivers. This can be done when the bridge driver has the complete information +about subdevices connected to it and knows exactly when to register them. This +is typically the case for internal subdevices, like video data processing units +within SoCs or complex PCI(e) boards, camera sensors in USB cameras or connected +to SoCs, which pass information about them to bridge drivers, usually in their +platform data. + +There are however also situations where subdevices have to be registered +asynchronously to bridge devices. An example of such a configuration is a Device +Tree based system where information about subdevices is made available to the +system independently from the bridge devices, e.g. when subdevices are defined +in DT as I2C device nodes. The API used in this second case is described further +below. + +Using one or the other registration method only affects the probing process, the +run-time bridge-subdevice interaction is in both cases the same. + +In the synchronous case a device (bridge) driver needs to register the +v4l2_subdev with the v4l2_device: int err = v4l2_device_register_subdev(v4l2_dev, sd); @@ -393,6 +412,30 @@ controlled through GPIO pins. This distinction is only relevant when setting up the device, but once the subdev is registered it is completely transparent. +In the asynchronous case subdevice probing can be invoked independently of the +bridge driver availability. The subdevice driver then has to verify whether all +the requirements for a successful probing are satisfied. This can include a +check for a master clock availability. If any of the conditions aren't satisfied +the driver might decide to return -EPROBE_DEFER to request further reprobing +attempts. Once all conditions are met the subdevice shall be registered using +the v4l2_async_register_subdev() function. Unregistration is performed using +the v4l2_async_unregister_subdev() call. Subdevices registered this way are +stored in a global list of subdevices, ready to be picked up by bridge drivers. + +Bridge drivers in turn have to register a notifier object with an array of +subdevice descriptors that the bridge device needs for its operation. This is +performed using the v4l2_async_notifier_register() call. To unregister the +notifier the driver has to call v4l2_async_notifier_unregister(). The former of +the two functions takes two arguments: a pointer to struct v4l2_device and a +pointer to struct v4l2_async_notifier. The latter contains a pointer to an array +of pointers to subdevice descriptors of type struct v4l2_async_subdev type. The +V4L2 core will then use these descriptors to match asynchronously registered +subdevices to them. If a match is detected the .bound() notifier callback is +called. After all subdevices have been located the .complete() callback is +called. When a subdevice is removed from the system the .unbind() method is +called. All three callbacks are optional. + + V4L2 sub-device userspace API ----------------------------- @@ -1065,3 +1108,29 @@ available event type is 'class base + 1'. An example on how the V4L2 events may be used can be found in the OMAP 3 ISP driver (drivers/media/platform/omap3isp). + + +V4L2 clocks +----------- + +Many subdevices, like camera sensors, TV decoders and encoders, need a clock +signal to be supplied by the system. Often this clock is supplied by the +respective bridge device. The Linux kernel provides a Common Clock Framework for +this purpose. However, it is not (yet) available on all architectures. Besides, +the nature of the multi-functional (clock, data + synchronisation, I2C control) +connection of subdevices to the system might impose special requirements on the +clock API usage. E.g. V4L2 has to support clock provider driver unregistration +while a subdevice driver is holding a reference to the clock. For these reasons +a V4L2 clock helper API has been developed and is provided to bridge and +subdevice drivers. + +The API consists of two parts: two functions to register and unregister a V4L2 +clock source: v4l2_clk_register() and v4l2_clk_unregister() and calls to control +a clock object, similar to the respective generic clock API calls: +v4l2_clk_get(), v4l2_clk_put(), v4l2_clk_enable(), v4l2_clk_disable(), +v4l2_clk_get_rate(), and v4l2_clk_set_rate(). Clock suppliers have to provide +clock operations that will be called when clock users invoke respective API +methods. + +It is expected that once the CCF becomes available on all relevant +architectures this API will be removed. From eca430c83d3b63df52024d114b7641bd03482f38 Mon Sep 17 00:00:00 2001 From: Guennadi Liakhovetski Date: Wed, 24 Apr 2013 11:15:30 -0300 Subject: [PATCH 0493/1048] [media] V4L2: sh_mobile_ceu_camera: remove CEU specific data from generic functions Several functions in the sh_mobile_ceu_camera driver implement generic algorithms and can be re-used by other V4L2 camera host drivers too. These functions attempt to optimise scaling and cropping functions of the subdevice, e.g. a camera sensor. This patch makes those functions generic for future re-use by other camera host drivers. Signed-off-by: Guennadi Liakhovetski Signed-off-by: Mauro Carvalho Chehab --- .../soc_camera/sh_mobile_ceu_camera.c | 130 ++++++++++-------- 1 file changed, 71 insertions(+), 59 deletions(-) diff --git a/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c b/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c index d1b410b75cc1..e5b99a889925 100644 --- a/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c +++ b/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c @@ -1005,7 +1005,7 @@ static bool sh_mobile_ceu_packing_supported(const struct soc_mbus_pixelfmt *fmt) fmt->packing == SOC_MBUS_PACKING_EXTEND16); } -static int client_g_rect(struct v4l2_subdev *sd, struct v4l2_rect *rect); +static int soc_camera_client_g_rect(struct v4l2_subdev *sd, struct v4l2_rect *rect); static struct soc_camera_device *ctrl_to_icd(struct v4l2_ctrl *ctrl) { @@ -1084,7 +1084,7 @@ static int sh_mobile_ceu_get_formats(struct soc_camera_device *icd, unsigned int /* FIXME: subwindow is lost between close / open */ /* Cache current client geometry */ - ret = client_g_rect(sd, &rect); + ret = soc_camera_client_g_rect(sd, &rect); if (ret < 0) return ret; @@ -1208,18 +1208,23 @@ static bool is_inside(const struct v4l2_rect *r1, const struct v4l2_rect *r2) r1->top + r1->height < r2->top + r2->height; } -static unsigned int scale_down(unsigned int size, unsigned int scale) +static unsigned int soc_camera_shift_scale(unsigned int size, unsigned int shift, + unsigned int scale) { - return (size * 4096 + scale / 2) / scale; + return ((size << shift) + scale / 2) / scale; } -static unsigned int calc_generic_scale(unsigned int input, unsigned int output) +static unsigned int soc_camera_calc_scale(unsigned int input, unsigned int shift, + unsigned int output) { - return (input * 4096 + output / 2) / output; + return soc_camera_shift_scale(input, shift, output); } +#define scale_down(size, scale) soc_camera_shift_scale(size, 12, scale) +#define calc_generic_scale(in, out) soc_camera_shift_scale(in, 12, out) + /* Get and store current client crop */ -static int client_g_rect(struct v4l2_subdev *sd, struct v4l2_rect *rect) +static int soc_camera_client_g_rect(struct v4l2_subdev *sd, struct v4l2_rect *rect) { struct v4l2_crop crop; struct v4l2_cropcap cap; @@ -1244,10 +1249,8 @@ static int client_g_rect(struct v4l2_subdev *sd, struct v4l2_rect *rect) } /* Client crop has changed, update our sub-rectangle to remain within the area */ -static void update_subrect(struct sh_mobile_ceu_cam *cam) +static void update_subrect(struct v4l2_rect *rect, struct v4l2_rect *subrect) { - struct v4l2_rect *rect = &cam->rect, *subrect = &cam->subrect; - if (rect->width < subrect->width) subrect->width = rect->width; @@ -1275,19 +1278,18 @@ static void update_subrect(struct sh_mobile_ceu_cam *cam) * 2. if (1) failed, try to double the client image until we get one big enough * 3. if (2) failed, try to request the maximum image */ -static int client_s_crop(struct soc_camera_device *icd, struct v4l2_crop *crop, - struct v4l2_crop *cam_crop) +static int soc_camera_client_s_crop(struct v4l2_subdev *sd, + struct v4l2_crop *crop, struct v4l2_crop *cam_crop, + struct v4l2_rect *target_rect, struct v4l2_rect *subrect) { - struct v4l2_subdev *sd = soc_camera_to_subdev(icd); struct v4l2_rect *rect = &crop->c, *cam_rect = &cam_crop->c; struct device *dev = sd->v4l2_dev->dev; - struct sh_mobile_ceu_cam *cam = icd->host_priv; struct v4l2_cropcap cap; int ret; unsigned int width, height; v4l2_subdev_call(sd, video, s_crop, crop); - ret = client_g_rect(sd, cam_rect); + ret = soc_camera_client_g_rect(sd, cam_rect); if (ret < 0) return ret; @@ -1299,7 +1301,7 @@ static int client_s_crop(struct soc_camera_device *icd, struct v4l2_crop *crop, /* Even if camera S_CROP failed, but camera rectangle matches */ dev_dbg(dev, "Camera S_CROP successful for %dx%d@%d:%d\n", rect->width, rect->height, rect->left, rect->top); - cam->rect = *cam_rect; + *target_rect = *cam_rect; return 0; } @@ -1365,7 +1367,7 @@ static int client_s_crop(struct soc_camera_device *icd, struct v4l2_crop *crop, cam_rect->top; v4l2_subdev_call(sd, video, s_crop, cam_crop); - ret = client_g_rect(sd, cam_rect); + ret = soc_camera_client_g_rect(sd, cam_rect); dev_geo(dev, "Camera S_CROP %d for %dx%d@%d:%d\n", ret, cam_rect->width, cam_rect->height, cam_rect->left, cam_rect->top); @@ -1379,15 +1381,15 @@ static int client_s_crop(struct soc_camera_device *icd, struct v4l2_crop *crop, */ *cam_rect = cap.bounds; v4l2_subdev_call(sd, video, s_crop, cam_crop); - ret = client_g_rect(sd, cam_rect); + ret = soc_camera_client_g_rect(sd, cam_rect); dev_geo(dev, "Camera S_CROP %d for max %dx%d@%d:%d\n", ret, cam_rect->width, cam_rect->height, cam_rect->left, cam_rect->top); } if (!ret) { - cam->rect = *cam_rect; - update_subrect(cam); + *target_rect = *cam_rect; + update_subrect(target_rect, subrect); } return ret; @@ -1395,15 +1397,13 @@ static int client_s_crop(struct soc_camera_device *icd, struct v4l2_crop *crop, /* Iterative s_mbus_fmt, also updates cached client crop on success */ static int client_s_fmt(struct soc_camera_device *icd, - struct v4l2_mbus_framefmt *mf, bool ceu_can_scale) + struct v4l2_rect *rect, struct v4l2_rect *subrect, + unsigned int max_width, unsigned int max_height, + struct v4l2_mbus_framefmt *mf, bool host_can_scale) { - struct soc_camera_host *ici = to_soc_camera_host(icd->parent); - struct sh_mobile_ceu_dev *pcdev = ici->priv; - struct sh_mobile_ceu_cam *cam = icd->host_priv; struct v4l2_subdev *sd = soc_camera_to_subdev(icd); struct device *dev = icd->parent; unsigned int width = mf->width, height = mf->height, tmp_w, tmp_h; - unsigned int max_width, max_height; struct v4l2_cropcap cap; bool ceu_1to1; int ret; @@ -1423,7 +1423,7 @@ static int client_s_fmt(struct soc_camera_device *icd, } ceu_1to1 = false; - if (!ceu_can_scale) + if (!host_can_scale) goto update_cache; cap.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; @@ -1432,8 +1432,10 @@ static int client_s_fmt(struct soc_camera_device *icd, if (ret < 0) return ret; - max_width = min(cap.bounds.width, pcdev->max_width); - max_height = min(cap.bounds.height, pcdev->max_height); + if (max_width > cap.bounds.width) + max_width = cap.bounds.width; + if (max_height > cap.bounds.height) + max_height = cap.bounds.height; /* Camera set a format, but geometry is not precise, try to improve */ tmp_w = mf->width; @@ -1460,29 +1462,36 @@ static int client_s_fmt(struct soc_camera_device *icd, update_cache: /* Update cache */ - ret = client_g_rect(sd, &cam->rect); + ret = soc_camera_client_g_rect(sd, rect); if (ret < 0) return ret; if (ceu_1to1) - cam->subrect = cam->rect; + *subrect = *rect; else - update_subrect(cam); + update_subrect(rect, subrect); return 0; } /** - * @width - on output: user width, mapped back to input - * @height - on output: user height, mapped back to input + * @icd - soc-camera device + * @rect - camera cropping window + * @subrect - part of rect, sent to the user * @mf - in- / output camera output window + * @width - on input: max host input width + * on output: user width, mapped back to input + * @height - on input: max host input height + * on output: user height, mapped back to input + * @host_can_scale - host can scale this pixel format + * @shift - shift, used for scaling */ -static int client_scale(struct soc_camera_device *icd, +static int soc_camera_client_scale(struct soc_camera_device *icd, + struct v4l2_rect *rect, struct v4l2_rect *subrect, struct v4l2_mbus_framefmt *mf, unsigned int *width, unsigned int *height, - bool ceu_can_scale) + bool host_can_scale, unsigned int shift) { - struct sh_mobile_ceu_cam *cam = icd->host_priv; struct device *dev = icd->parent; struct v4l2_mbus_framefmt mf_tmp = *mf; unsigned int scale_h, scale_v; @@ -1492,7 +1501,8 @@ static int client_scale(struct soc_camera_device *icd, * 5. Apply iterative camera S_FMT for camera user window (also updates * client crop cache and the imaginary sub-rectangle). */ - ret = client_s_fmt(icd, &mf_tmp, ceu_can_scale); + ret = client_s_fmt(icd, rect, subrect, *width, *height, + &mf_tmp, host_can_scale); if (ret < 0) return ret; @@ -1504,8 +1514,8 @@ static int client_scale(struct soc_camera_device *icd, /* unneeded - it is already in "mf_tmp" */ /* 7. Calculate new client scales. */ - scale_h = calc_generic_scale(cam->rect.width, mf_tmp.width); - scale_v = calc_generic_scale(cam->rect.height, mf_tmp.height); + scale_h = soc_camera_calc_scale(rect->width, shift, mf_tmp.width); + scale_v = soc_camera_calc_scale(rect->height, shift, mf_tmp.height); mf->width = mf_tmp.width; mf->height = mf_tmp.height; @@ -1515,8 +1525,8 @@ static int client_scale(struct soc_camera_device *icd, * 8. Calculate new CEU crop - apply camera scales to previously * updated "effective" crop. */ - *width = scale_down(cam->subrect.width, scale_h); - *height = scale_down(cam->subrect.height, scale_v); + *width = soc_camera_shift_scale(subrect->width, shift, scale_h); + *height = soc_camera_shift_scale(subrect->height, shift, scale_v); dev_geo(dev, "8: new client sub-window %ux%u\n", *width, *height); @@ -1559,7 +1569,8 @@ static int sh_mobile_ceu_set_crop(struct soc_camera_device *icd, * 1. - 2. Apply iterative camera S_CROP for new input window, read back * actual camera rectangle. */ - ret = client_s_crop(icd, &a_writable, &cam_crop); + ret = soc_camera_client_s_crop(sd, &a_writable, &cam_crop, + &cam->rect, &cam->subrect); if (ret < 0) return ret; @@ -1683,16 +1694,16 @@ static int sh_mobile_ceu_get_crop(struct soc_camera_device *icd, * client crop. New scales are calculated from the requested output format and * CEU crop, mapped backed onto the client input (subrect). */ -static void calculate_client_output(struct soc_camera_device *icd, - const struct v4l2_pix_format *pix, struct v4l2_mbus_framefmt *mf) +static void soc_camera_calc_client_output(struct soc_camera_device *icd, + struct v4l2_rect *rect, struct v4l2_rect *subrect, + const struct v4l2_pix_format *pix, struct v4l2_mbus_framefmt *mf, + unsigned int shift) { - struct sh_mobile_ceu_cam *cam = icd->host_priv; struct device *dev = icd->parent; - struct v4l2_rect *cam_subrect = &cam->subrect; unsigned int scale_v, scale_h; - if (cam_subrect->width == cam->rect.width && - cam_subrect->height == cam->rect.height) { + if (subrect->width == rect->width && + subrect->height == rect->height) { /* No sub-cropping */ mf->width = pix->width; mf->height = pix->height; @@ -1702,8 +1713,8 @@ static void calculate_client_output(struct soc_camera_device *icd, /* 1.-2. Current camera scales and subwin - cached. */ dev_geo(dev, "2: subwin %ux%u@%u:%u\n", - cam_subrect->width, cam_subrect->height, - cam_subrect->left, cam_subrect->top); + subrect->width, subrect->height, + subrect->left, subrect->top); /* * 3. Calculate new combined scales from input sub-window to requested @@ -1714,8 +1725,8 @@ static void calculate_client_output(struct soc_camera_device *icd, * TODO: CEU cannot scale images larger than VGA to smaller than SubQCIF * (128x96) or larger than VGA */ - scale_h = calc_generic_scale(cam_subrect->width, pix->width); - scale_v = calc_generic_scale(cam_subrect->height, pix->height); + scale_h = soc_camera_calc_scale(subrect->width, shift, pix->width); + scale_v = soc_camera_calc_scale(subrect->height, shift, pix->height); dev_geo(dev, "3: scales %u:%u\n", scale_h, scale_v); @@ -1723,8 +1734,8 @@ static void calculate_client_output(struct soc_camera_device *icd, * 4. Calculate desired client output window by applying combined scales * to client (real) input window. */ - mf->width = scale_down(cam->rect.width, scale_h); - mf->height = scale_down(cam->rect.height, scale_v); + mf->width = soc_camera_shift_scale(rect->width, shift, scale_h); + mf->height = soc_camera_shift_scale(rect->height, shift, scale_v); } /* Similar to set_crop multistage iterative algorithm */ @@ -1739,8 +1750,8 @@ static int sh_mobile_ceu_set_fmt(struct soc_camera_device *icd, struct v4l2_mbus_framefmt mf; __u32 pixfmt = pix->pixelformat; const struct soc_camera_format_xlate *xlate; - /* Keep Compiler Happy */ - unsigned int ceu_sub_width = 0, ceu_sub_height = 0; + unsigned int ceu_sub_width = pcdev->max_width, + ceu_sub_height = pcdev->max_height; u16 scale_v, scale_h; int ret; bool image_mode; @@ -1767,7 +1778,7 @@ static int sh_mobile_ceu_set_fmt(struct soc_camera_device *icd, } /* 1.-4. Calculate desired client output geometry */ - calculate_client_output(icd, pix, &mf); + soc_camera_calc_client_output(icd, &cam->rect, &cam->subrect, pix, &mf, 12); mf.field = pix->field; mf.colorspace = pix->colorspace; mf.code = xlate->code; @@ -1789,8 +1800,9 @@ static int sh_mobile_ceu_set_fmt(struct soc_camera_device *icd, dev_geo(dev, "4: request camera output %ux%u\n", mf.width, mf.height); /* 5. - 9. */ - ret = client_scale(icd, &mf, &ceu_sub_width, &ceu_sub_height, - image_mode && V4L2_FIELD_NONE == field); + ret = soc_camera_client_scale(icd, &cam->rect, &cam->subrect, + &mf, &ceu_sub_width, &ceu_sub_height, + image_mode && V4L2_FIELD_NONE == field, 12); dev_geo(dev, "5-9: client scale return %d\n", ret); From 22e0099ac9a968a4a67fc681864a9ff453bd929f Mon Sep 17 00:00:00 2001 From: Guennadi Liakhovetski Date: Thu, 25 Apr 2013 08:18:45 -0300 Subject: [PATCH 0494/1048] [media] V4L2: soc-camera: move generic functions into a separate file The sh_mobile_ceu_camera driver implements a generic algorithm for setting up an optimal client and host scaling and cropping configuration. This patch makes those functions available for all drivers. Signed-off-by: Guennadi Liakhovetski Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/soc_camera/Kconfig | 4 + drivers/media/platform/soc_camera/Makefile | 4 + .../soc_camera/sh_mobile_ceu_camera.c | 391 +---------------- .../platform/soc_camera/soc_scale_crop.c | 401 ++++++++++++++++++ .../platform/soc_camera/soc_scale_crop.h | 47 ++ 5 files changed, 459 insertions(+), 388 deletions(-) create mode 100644 drivers/media/platform/soc_camera/soc_scale_crop.c create mode 100644 drivers/media/platform/soc_camera/soc_scale_crop.h diff --git a/drivers/media/platform/soc_camera/Kconfig b/drivers/media/platform/soc_camera/Kconfig index ffd00106b205..626dcccc37da 100644 --- a/drivers/media/platform/soc_camera/Kconfig +++ b/drivers/media/platform/soc_camera/Kconfig @@ -8,6 +8,9 @@ config SOC_CAMERA over a bus like PCI or USB. For example some i2c camera connected directly to the data bus of an SoC. +config SOC_CAMERA_SCALE_CROP + tristate + config SOC_CAMERA_PLATFORM tristate "platform camera support" depends on SOC_CAMERA @@ -51,6 +54,7 @@ config VIDEO_SH_MOBILE_CEU tristate "SuperH Mobile CEU Interface driver" depends on VIDEO_DEV && SOC_CAMERA && HAS_DMA && HAVE_CLK select VIDEOBUF2_DMA_CONTIG + select SOC_CAMERA_SCALE_CROP ---help--- This is a v4l2 driver for the SuperH Mobile CEU Interface diff --git a/drivers/media/platform/soc_camera/Makefile b/drivers/media/platform/soc_camera/Makefile index bedb0428852b..39186224c16a 100644 --- a/drivers/media/platform/soc_camera/Makefile +++ b/drivers/media/platform/soc_camera/Makefile @@ -1,4 +1,8 @@ obj-$(CONFIG_SOC_CAMERA) += soc_camera.o soc_mediabus.o +obj-$(CONFIG_SOC_CAMERA_SCALE_CROP) += soc_scale_crop.o + +# a platform subdevice driver stub, allowing to support cameras by adding a +# couple of callback functions to the board code obj-$(CONFIG_SOC_CAMERA_PLATFORM) += soc_camera_platform.o # soc-camera host drivers have to be linked after camera drivers diff --git a/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c b/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c index e5b99a889925..f2de0066089a 100644 --- a/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c +++ b/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c @@ -46,6 +46,8 @@ #include #include +#include "soc_scale_crop.h" + /* register offsets for sh7722 / sh7723 */ #define CAPSR 0x00 /* Capture start register */ @@ -1005,8 +1007,6 @@ static bool sh_mobile_ceu_packing_supported(const struct soc_mbus_pixelfmt *fmt) fmt->packing == SOC_MBUS_PACKING_EXTEND16); } -static int soc_camera_client_g_rect(struct v4l2_subdev *sd, struct v4l2_rect *rect); - static struct soc_camera_device *ctrl_to_icd(struct v4l2_ctrl *ctrl) { return container_of(ctrl->handler, struct soc_camera_device, @@ -1194,344 +1194,8 @@ static void sh_mobile_ceu_put_formats(struct soc_camera_device *icd) icd->host_priv = NULL; } -/* Check if any dimension of r1 is smaller than respective one of r2 */ -static bool is_smaller(const struct v4l2_rect *r1, const struct v4l2_rect *r2) -{ - return r1->width < r2->width || r1->height < r2->height; -} - -/* Check if r1 fails to cover r2 */ -static bool is_inside(const struct v4l2_rect *r1, const struct v4l2_rect *r2) -{ - return r1->left > r2->left || r1->top > r2->top || - r1->left + r1->width < r2->left + r2->width || - r1->top + r1->height < r2->top + r2->height; -} - -static unsigned int soc_camera_shift_scale(unsigned int size, unsigned int shift, - unsigned int scale) -{ - return ((size << shift) + scale / 2) / scale; -} - -static unsigned int soc_camera_calc_scale(unsigned int input, unsigned int shift, - unsigned int output) -{ - return soc_camera_shift_scale(input, shift, output); -} - #define scale_down(size, scale) soc_camera_shift_scale(size, 12, scale) -#define calc_generic_scale(in, out) soc_camera_shift_scale(in, 12, out) - -/* Get and store current client crop */ -static int soc_camera_client_g_rect(struct v4l2_subdev *sd, struct v4l2_rect *rect) -{ - struct v4l2_crop crop; - struct v4l2_cropcap cap; - int ret; - - crop.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - - ret = v4l2_subdev_call(sd, video, g_crop, &crop); - if (!ret) { - *rect = crop.c; - return ret; - } - - /* Camera driver doesn't support .g_crop(), assume default rectangle */ - cap.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - - ret = v4l2_subdev_call(sd, video, cropcap, &cap); - if (!ret) - *rect = cap.defrect; - - return ret; -} - -/* Client crop has changed, update our sub-rectangle to remain within the area */ -static void update_subrect(struct v4l2_rect *rect, struct v4l2_rect *subrect) -{ - if (rect->width < subrect->width) - subrect->width = rect->width; - - if (rect->height < subrect->height) - subrect->height = rect->height; - - if (rect->left > subrect->left) - subrect->left = rect->left; - else if (rect->left + rect->width > - subrect->left + subrect->width) - subrect->left = rect->left + rect->width - - subrect->width; - - if (rect->top > subrect->top) - subrect->top = rect->top; - else if (rect->top + rect->height > - subrect->top + subrect->height) - subrect->top = rect->top + rect->height - - subrect->height; -} - -/* - * The common for both scaling and cropping iterative approach is: - * 1. try if the client can produce exactly what requested by the user - * 2. if (1) failed, try to double the client image until we get one big enough - * 3. if (2) failed, try to request the maximum image - */ -static int soc_camera_client_s_crop(struct v4l2_subdev *sd, - struct v4l2_crop *crop, struct v4l2_crop *cam_crop, - struct v4l2_rect *target_rect, struct v4l2_rect *subrect) -{ - struct v4l2_rect *rect = &crop->c, *cam_rect = &cam_crop->c; - struct device *dev = sd->v4l2_dev->dev; - struct v4l2_cropcap cap; - int ret; - unsigned int width, height; - - v4l2_subdev_call(sd, video, s_crop, crop); - ret = soc_camera_client_g_rect(sd, cam_rect); - if (ret < 0) - return ret; - - /* - * Now cam_crop contains the current camera input rectangle, and it must - * be within camera cropcap bounds - */ - if (!memcmp(rect, cam_rect, sizeof(*rect))) { - /* Even if camera S_CROP failed, but camera rectangle matches */ - dev_dbg(dev, "Camera S_CROP successful for %dx%d@%d:%d\n", - rect->width, rect->height, rect->left, rect->top); - *target_rect = *cam_rect; - return 0; - } - - /* Try to fix cropping, that camera hasn't managed to set */ - dev_geo(dev, "Fix camera S_CROP for %dx%d@%d:%d to %dx%d@%d:%d\n", - cam_rect->width, cam_rect->height, - cam_rect->left, cam_rect->top, - rect->width, rect->height, rect->left, rect->top); - - /* We need sensor maximum rectangle */ - ret = v4l2_subdev_call(sd, video, cropcap, &cap); - if (ret < 0) - return ret; - - /* Put user requested rectangle within sensor bounds */ - soc_camera_limit_side(&rect->left, &rect->width, cap.bounds.left, 2, - cap.bounds.width); - soc_camera_limit_side(&rect->top, &rect->height, cap.bounds.top, 4, - cap.bounds.height); - - /* - * Popular special case - some cameras can only handle fixed sizes like - * QVGA, VGA,... Take care to avoid infinite loop. - */ - width = max(cam_rect->width, 2); - height = max(cam_rect->height, 2); - - /* - * Loop as long as sensor is not covering the requested rectangle and - * is still within its bounds - */ - while (!ret && (is_smaller(cam_rect, rect) || - is_inside(cam_rect, rect)) && - (cap.bounds.width > width || cap.bounds.height > height)) { - - width *= 2; - height *= 2; - - cam_rect->width = width; - cam_rect->height = height; - - /* - * We do not know what capabilities the camera has to set up - * left and top borders. We could try to be smarter in iterating - * them, e.g., if camera current left is to the right of the - * target left, set it to the middle point between the current - * left and minimum left. But that would add too much - * complexity: we would have to iterate each border separately. - * Instead we just drop to the left and top bounds. - */ - if (cam_rect->left > rect->left) - cam_rect->left = cap.bounds.left; - - if (cam_rect->left + cam_rect->width < rect->left + rect->width) - cam_rect->width = rect->left + rect->width - - cam_rect->left; - - if (cam_rect->top > rect->top) - cam_rect->top = cap.bounds.top; - - if (cam_rect->top + cam_rect->height < rect->top + rect->height) - cam_rect->height = rect->top + rect->height - - cam_rect->top; - - v4l2_subdev_call(sd, video, s_crop, cam_crop); - ret = soc_camera_client_g_rect(sd, cam_rect); - dev_geo(dev, "Camera S_CROP %d for %dx%d@%d:%d\n", ret, - cam_rect->width, cam_rect->height, - cam_rect->left, cam_rect->top); - } - - /* S_CROP must not modify the rectangle */ - if (is_smaller(cam_rect, rect) || is_inside(cam_rect, rect)) { - /* - * The camera failed to configure a suitable cropping, - * we cannot use the current rectangle, set to max - */ - *cam_rect = cap.bounds; - v4l2_subdev_call(sd, video, s_crop, cam_crop); - ret = soc_camera_client_g_rect(sd, cam_rect); - dev_geo(dev, "Camera S_CROP %d for max %dx%d@%d:%d\n", ret, - cam_rect->width, cam_rect->height, - cam_rect->left, cam_rect->top); - } - - if (!ret) { - *target_rect = *cam_rect; - update_subrect(target_rect, subrect); - } - - return ret; -} - -/* Iterative s_mbus_fmt, also updates cached client crop on success */ -static int client_s_fmt(struct soc_camera_device *icd, - struct v4l2_rect *rect, struct v4l2_rect *subrect, - unsigned int max_width, unsigned int max_height, - struct v4l2_mbus_framefmt *mf, bool host_can_scale) -{ - struct v4l2_subdev *sd = soc_camera_to_subdev(icd); - struct device *dev = icd->parent; - unsigned int width = mf->width, height = mf->height, tmp_w, tmp_h; - struct v4l2_cropcap cap; - bool ceu_1to1; - int ret; - - ret = v4l2_device_call_until_err(sd->v4l2_dev, - soc_camera_grp_id(icd), video, - s_mbus_fmt, mf); - if (ret < 0) - return ret; - - dev_geo(dev, "camera scaled to %ux%u\n", mf->width, mf->height); - - if (width == mf->width && height == mf->height) { - /* Perfect! The client has done it all. */ - ceu_1to1 = true; - goto update_cache; - } - - ceu_1to1 = false; - if (!host_can_scale) - goto update_cache; - - cap.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - - ret = v4l2_subdev_call(sd, video, cropcap, &cap); - if (ret < 0) - return ret; - - if (max_width > cap.bounds.width) - max_width = cap.bounds.width; - if (max_height > cap.bounds.height) - max_height = cap.bounds.height; - - /* Camera set a format, but geometry is not precise, try to improve */ - tmp_w = mf->width; - tmp_h = mf->height; - - /* width <= max_width && height <= max_height - guaranteed by try_fmt */ - while ((width > tmp_w || height > tmp_h) && - tmp_w < max_width && tmp_h < max_height) { - tmp_w = min(2 * tmp_w, max_width); - tmp_h = min(2 * tmp_h, max_height); - mf->width = tmp_w; - mf->height = tmp_h; - ret = v4l2_device_call_until_err(sd->v4l2_dev, - soc_camera_grp_id(icd), video, - s_mbus_fmt, mf); - dev_geo(dev, "Camera scaled to %ux%u\n", - mf->width, mf->height); - if (ret < 0) { - /* This shouldn't happen */ - dev_err(dev, "Client failed to set format: %d\n", ret); - return ret; - } - } - -update_cache: - /* Update cache */ - ret = soc_camera_client_g_rect(sd, rect); - if (ret < 0) - return ret; - - if (ceu_1to1) - *subrect = *rect; - else - update_subrect(rect, subrect); - - return 0; -} - -/** - * @icd - soc-camera device - * @rect - camera cropping window - * @subrect - part of rect, sent to the user - * @mf - in- / output camera output window - * @width - on input: max host input width - * on output: user width, mapped back to input - * @height - on input: max host input height - * on output: user height, mapped back to input - * @host_can_scale - host can scale this pixel format - * @shift - shift, used for scaling - */ -static int soc_camera_client_scale(struct soc_camera_device *icd, - struct v4l2_rect *rect, struct v4l2_rect *subrect, - struct v4l2_mbus_framefmt *mf, - unsigned int *width, unsigned int *height, - bool host_can_scale, unsigned int shift) -{ - struct device *dev = icd->parent; - struct v4l2_mbus_framefmt mf_tmp = *mf; - unsigned int scale_h, scale_v; - int ret; - - /* - * 5. Apply iterative camera S_FMT for camera user window (also updates - * client crop cache and the imaginary sub-rectangle). - */ - ret = client_s_fmt(icd, rect, subrect, *width, *height, - &mf_tmp, host_can_scale); - if (ret < 0) - return ret; - - dev_geo(dev, "5: camera scaled to %ux%u\n", - mf_tmp.width, mf_tmp.height); - - /* 6. Retrieve camera output window (g_fmt) */ - - /* unneeded - it is already in "mf_tmp" */ - - /* 7. Calculate new client scales. */ - scale_h = soc_camera_calc_scale(rect->width, shift, mf_tmp.width); - scale_v = soc_camera_calc_scale(rect->height, shift, mf_tmp.height); - - mf->width = mf_tmp.width; - mf->height = mf_tmp.height; - mf->colorspace = mf_tmp.colorspace; - - /* - * 8. Calculate new CEU crop - apply camera scales to previously - * updated "effective" crop. - */ - *width = soc_camera_shift_scale(subrect->width, shift, scale_h); - *height = soc_camera_shift_scale(subrect->height, shift, scale_v); - - dev_geo(dev, "8: new client sub-window %ux%u\n", *width, *height); - - return 0; -} +#define calc_generic_scale(in, out) soc_camera_calc_scale(in, 12, out) /* * CEU can scale and crop, but we don't want to waste bandwidth and kill the @@ -1689,55 +1353,6 @@ static int sh_mobile_ceu_get_crop(struct soc_camera_device *icd, return 0; } -/* - * Calculate real client output window by applying new scales to the current - * client crop. New scales are calculated from the requested output format and - * CEU crop, mapped backed onto the client input (subrect). - */ -static void soc_camera_calc_client_output(struct soc_camera_device *icd, - struct v4l2_rect *rect, struct v4l2_rect *subrect, - const struct v4l2_pix_format *pix, struct v4l2_mbus_framefmt *mf, - unsigned int shift) -{ - struct device *dev = icd->parent; - unsigned int scale_v, scale_h; - - if (subrect->width == rect->width && - subrect->height == rect->height) { - /* No sub-cropping */ - mf->width = pix->width; - mf->height = pix->height; - return; - } - - /* 1.-2. Current camera scales and subwin - cached. */ - - dev_geo(dev, "2: subwin %ux%u@%u:%u\n", - subrect->width, subrect->height, - subrect->left, subrect->top); - - /* - * 3. Calculate new combined scales from input sub-window to requested - * user window. - */ - - /* - * TODO: CEU cannot scale images larger than VGA to smaller than SubQCIF - * (128x96) or larger than VGA - */ - scale_h = soc_camera_calc_scale(subrect->width, shift, pix->width); - scale_v = soc_camera_calc_scale(subrect->height, shift, pix->height); - - dev_geo(dev, "3: scales %u:%u\n", scale_h, scale_v); - - /* - * 4. Calculate desired client output window by applying combined scales - * to client (real) input window. - */ - mf->width = soc_camera_shift_scale(rect->width, shift, scale_h); - mf->height = soc_camera_shift_scale(rect->height, shift, scale_v); -} - /* Similar to set_crop multistage iterative algorithm */ static int sh_mobile_ceu_set_fmt(struct soc_camera_device *icd, struct v4l2_format *f) diff --git a/drivers/media/platform/soc_camera/soc_scale_crop.c b/drivers/media/platform/soc_camera/soc_scale_crop.c new file mode 100644 index 000000000000..be7067f55a29 --- /dev/null +++ b/drivers/media/platform/soc_camera/soc_scale_crop.c @@ -0,0 +1,401 @@ +/* + * soc-camera generic scaling-cropping manipulation functions + * + * Copyright (C) 2013 Guennadi Liakhovetski + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + */ + +#include +#include + +#include +#include + +#include "soc_scale_crop.h" + +#ifdef DEBUG_GEOMETRY +#define dev_geo dev_info +#else +#define dev_geo dev_dbg +#endif + +/* Check if any dimension of r1 is smaller than respective one of r2 */ +static bool is_smaller(const struct v4l2_rect *r1, const struct v4l2_rect *r2) +{ + return r1->width < r2->width || r1->height < r2->height; +} + +/* Check if r1 fails to cover r2 */ +static bool is_inside(const struct v4l2_rect *r1, const struct v4l2_rect *r2) +{ + return r1->left > r2->left || r1->top > r2->top || + r1->left + r1->width < r2->left + r2->width || + r1->top + r1->height < r2->top + r2->height; +} + +/* Get and store current client crop */ +int soc_camera_client_g_rect(struct v4l2_subdev *sd, struct v4l2_rect *rect) +{ + struct v4l2_crop crop; + struct v4l2_cropcap cap; + int ret; + + crop.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; + + ret = v4l2_subdev_call(sd, video, g_crop, &crop); + if (!ret) { + *rect = crop.c; + return ret; + } + + /* Camera driver doesn't support .g_crop(), assume default rectangle */ + cap.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; + + ret = v4l2_subdev_call(sd, video, cropcap, &cap); + if (!ret) + *rect = cap.defrect; + + return ret; +} +EXPORT_SYMBOL(soc_camera_client_g_rect); + +/* Client crop has changed, update our sub-rectangle to remain within the area */ +static void update_subrect(struct v4l2_rect *rect, struct v4l2_rect *subrect) +{ + if (rect->width < subrect->width) + subrect->width = rect->width; + + if (rect->height < subrect->height) + subrect->height = rect->height; + + if (rect->left > subrect->left) + subrect->left = rect->left; + else if (rect->left + rect->width > + subrect->left + subrect->width) + subrect->left = rect->left + rect->width - + subrect->width; + + if (rect->top > subrect->top) + subrect->top = rect->top; + else if (rect->top + rect->height > + subrect->top + subrect->height) + subrect->top = rect->top + rect->height - + subrect->height; +} + +/* + * The common for both scaling and cropping iterative approach is: + * 1. try if the client can produce exactly what requested by the user + * 2. if (1) failed, try to double the client image until we get one big enough + * 3. if (2) failed, try to request the maximum image + */ +int soc_camera_client_s_crop(struct v4l2_subdev *sd, + struct v4l2_crop *crop, struct v4l2_crop *cam_crop, + struct v4l2_rect *target_rect, struct v4l2_rect *subrect) +{ + struct v4l2_rect *rect = &crop->c, *cam_rect = &cam_crop->c; + struct device *dev = sd->v4l2_dev->dev; + struct v4l2_cropcap cap; + int ret; + unsigned int width, height; + + v4l2_subdev_call(sd, video, s_crop, crop); + ret = soc_camera_client_g_rect(sd, cam_rect); + if (ret < 0) + return ret; + + /* + * Now cam_crop contains the current camera input rectangle, and it must + * be within camera cropcap bounds + */ + if (!memcmp(rect, cam_rect, sizeof(*rect))) { + /* Even if camera S_CROP failed, but camera rectangle matches */ + dev_dbg(dev, "Camera S_CROP successful for %dx%d@%d:%d\n", + rect->width, rect->height, rect->left, rect->top); + *target_rect = *cam_rect; + return 0; + } + + /* Try to fix cropping, that camera hasn't managed to set */ + dev_geo(dev, "Fix camera S_CROP for %dx%d@%d:%d to %dx%d@%d:%d\n", + cam_rect->width, cam_rect->height, + cam_rect->left, cam_rect->top, + rect->width, rect->height, rect->left, rect->top); + + /* We need sensor maximum rectangle */ + ret = v4l2_subdev_call(sd, video, cropcap, &cap); + if (ret < 0) + return ret; + + /* Put user requested rectangle within sensor bounds */ + soc_camera_limit_side(&rect->left, &rect->width, cap.bounds.left, 2, + cap.bounds.width); + soc_camera_limit_side(&rect->top, &rect->height, cap.bounds.top, 4, + cap.bounds.height); + + /* + * Popular special case - some cameras can only handle fixed sizes like + * QVGA, VGA,... Take care to avoid infinite loop. + */ + width = max(cam_rect->width, 2); + height = max(cam_rect->height, 2); + + /* + * Loop as long as sensor is not covering the requested rectangle and + * is still within its bounds + */ + while (!ret && (is_smaller(cam_rect, rect) || + is_inside(cam_rect, rect)) && + (cap.bounds.width > width || cap.bounds.height > height)) { + + width *= 2; + height *= 2; + + cam_rect->width = width; + cam_rect->height = height; + + /* + * We do not know what capabilities the camera has to set up + * left and top borders. We could try to be smarter in iterating + * them, e.g., if camera current left is to the right of the + * target left, set it to the middle point between the current + * left and minimum left. But that would add too much + * complexity: we would have to iterate each border separately. + * Instead we just drop to the left and top bounds. + */ + if (cam_rect->left > rect->left) + cam_rect->left = cap.bounds.left; + + if (cam_rect->left + cam_rect->width < rect->left + rect->width) + cam_rect->width = rect->left + rect->width - + cam_rect->left; + + if (cam_rect->top > rect->top) + cam_rect->top = cap.bounds.top; + + if (cam_rect->top + cam_rect->height < rect->top + rect->height) + cam_rect->height = rect->top + rect->height - + cam_rect->top; + + v4l2_subdev_call(sd, video, s_crop, cam_crop); + ret = soc_camera_client_g_rect(sd, cam_rect); + dev_geo(dev, "Camera S_CROP %d for %dx%d@%d:%d\n", ret, + cam_rect->width, cam_rect->height, + cam_rect->left, cam_rect->top); + } + + /* S_CROP must not modify the rectangle */ + if (is_smaller(cam_rect, rect) || is_inside(cam_rect, rect)) { + /* + * The camera failed to configure a suitable cropping, + * we cannot use the current rectangle, set to max + */ + *cam_rect = cap.bounds; + v4l2_subdev_call(sd, video, s_crop, cam_crop); + ret = soc_camera_client_g_rect(sd, cam_rect); + dev_geo(dev, "Camera S_CROP %d for max %dx%d@%d:%d\n", ret, + cam_rect->width, cam_rect->height, + cam_rect->left, cam_rect->top); + } + + if (!ret) { + *target_rect = *cam_rect; + update_subrect(target_rect, subrect); + } + + return ret; +} +EXPORT_SYMBOL(soc_camera_client_s_crop); + +/* Iterative s_mbus_fmt, also updates cached client crop on success */ +static int client_s_fmt(struct soc_camera_device *icd, + struct v4l2_rect *rect, struct v4l2_rect *subrect, + unsigned int max_width, unsigned int max_height, + struct v4l2_mbus_framefmt *mf, bool host_can_scale) +{ + struct v4l2_subdev *sd = soc_camera_to_subdev(icd); + struct device *dev = icd->parent; + unsigned int width = mf->width, height = mf->height, tmp_w, tmp_h; + struct v4l2_cropcap cap; + bool ceu_1to1; + int ret; + + ret = v4l2_device_call_until_err(sd->v4l2_dev, + soc_camera_grp_id(icd), video, + s_mbus_fmt, mf); + if (ret < 0) + return ret; + + dev_geo(dev, "camera scaled to %ux%u\n", mf->width, mf->height); + + if (width == mf->width && height == mf->height) { + /* Perfect! The client has done it all. */ + ceu_1to1 = true; + goto update_cache; + } + + ceu_1to1 = false; + if (!host_can_scale) + goto update_cache; + + cap.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; + + ret = v4l2_subdev_call(sd, video, cropcap, &cap); + if (ret < 0) + return ret; + + if (max_width > cap.bounds.width) + max_width = cap.bounds.width; + if (max_height > cap.bounds.height) + max_height = cap.bounds.height; + + /* Camera set a format, but geometry is not precise, try to improve */ + tmp_w = mf->width; + tmp_h = mf->height; + + /* width <= max_width && height <= max_height - guaranteed by try_fmt */ + while ((width > tmp_w || height > tmp_h) && + tmp_w < max_width && tmp_h < max_height) { + tmp_w = min(2 * tmp_w, max_width); + tmp_h = min(2 * tmp_h, max_height); + mf->width = tmp_w; + mf->height = tmp_h; + ret = v4l2_device_call_until_err(sd->v4l2_dev, + soc_camera_grp_id(icd), video, + s_mbus_fmt, mf); + dev_geo(dev, "Camera scaled to %ux%u\n", + mf->width, mf->height); + if (ret < 0) { + /* This shouldn't happen */ + dev_err(dev, "Client failed to set format: %d\n", ret); + return ret; + } + } + +update_cache: + /* Update cache */ + ret = soc_camera_client_g_rect(sd, rect); + if (ret < 0) + return ret; + + if (ceu_1to1) + *subrect = *rect; + else + update_subrect(rect, subrect); + + return 0; +} + +/** + * @icd - soc-camera device + * @rect - camera cropping window + * @subrect - part of rect, sent to the user + * @mf - in- / output camera output window + * @width - on input: max host input width + * on output: user width, mapped back to input + * @height - on input: max host input height + * on output: user height, mapped back to input + * @host_can_scale - host can scale this pixel format + * @shift - shift, used for scaling + */ +int soc_camera_client_scale(struct soc_camera_device *icd, + struct v4l2_rect *rect, struct v4l2_rect *subrect, + struct v4l2_mbus_framefmt *mf, + unsigned int *width, unsigned int *height, + bool host_can_scale, unsigned int shift) +{ + struct device *dev = icd->parent; + struct v4l2_mbus_framefmt mf_tmp = *mf; + unsigned int scale_h, scale_v; + int ret; + + /* + * 5. Apply iterative camera S_FMT for camera user window (also updates + * client crop cache and the imaginary sub-rectangle). + */ + ret = client_s_fmt(icd, rect, subrect, *width, *height, + &mf_tmp, host_can_scale); + if (ret < 0) + return ret; + + dev_geo(dev, "5: camera scaled to %ux%u\n", + mf_tmp.width, mf_tmp.height); + + /* 6. Retrieve camera output window (g_fmt) */ + + /* unneeded - it is already in "mf_tmp" */ + + /* 7. Calculate new client scales. */ + scale_h = soc_camera_calc_scale(rect->width, shift, mf_tmp.width); + scale_v = soc_camera_calc_scale(rect->height, shift, mf_tmp.height); + + mf->width = mf_tmp.width; + mf->height = mf_tmp.height; + mf->colorspace = mf_tmp.colorspace; + + /* + * 8. Calculate new CEU crop - apply camera scales to previously + * updated "effective" crop. + */ + *width = soc_camera_shift_scale(subrect->width, shift, scale_h); + *height = soc_camera_shift_scale(subrect->height, shift, scale_v); + + dev_geo(dev, "8: new client sub-window %ux%u\n", *width, *height); + + return 0; +} +EXPORT_SYMBOL(soc_camera_client_scale); + +/* + * Calculate real client output window by applying new scales to the current + * client crop. New scales are calculated from the requested output format and + * CEU crop, mapped backed onto the client input (subrect). + */ +void soc_camera_calc_client_output(struct soc_camera_device *icd, + struct v4l2_rect *rect, struct v4l2_rect *subrect, + const struct v4l2_pix_format *pix, struct v4l2_mbus_framefmt *mf, + unsigned int shift) +{ + struct device *dev = icd->parent; + unsigned int scale_v, scale_h; + + if (subrect->width == rect->width && + subrect->height == rect->height) { + /* No sub-cropping */ + mf->width = pix->width; + mf->height = pix->height; + return; + } + + /* 1.-2. Current camera scales and subwin - cached. */ + + dev_geo(dev, "2: subwin %ux%u@%u:%u\n", + subrect->width, subrect->height, + subrect->left, subrect->top); + + /* + * 3. Calculate new combined scales from input sub-window to requested + * user window. + */ + + /* + * TODO: CEU cannot scale images larger than VGA to smaller than SubQCIF + * (128x96) or larger than VGA + */ + scale_h = soc_camera_calc_scale(subrect->width, shift, pix->width); + scale_v = soc_camera_calc_scale(subrect->height, shift, pix->height); + + dev_geo(dev, "3: scales %u:%u\n", scale_h, scale_v); + + /* + * 4. Calculate desired client output window by applying combined scales + * to client (real) input window. + */ + mf->width = soc_camera_shift_scale(rect->width, shift, scale_h); + mf->height = soc_camera_shift_scale(rect->height, shift, scale_v); +} +EXPORT_SYMBOL(soc_camera_calc_client_output); diff --git a/drivers/media/platform/soc_camera/soc_scale_crop.h b/drivers/media/platform/soc_camera/soc_scale_crop.h new file mode 100644 index 000000000000..184a30dff541 --- /dev/null +++ b/drivers/media/platform/soc_camera/soc_scale_crop.h @@ -0,0 +1,47 @@ +/* + * soc-camera generic scaling-cropping manipulation functions + * + * Copyright (C) 2013 Guennadi Liakhovetski + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + */ + +#ifndef SOC_SCALE_CROP_H +#define SOC_SCALE_CROP_H + +#include + +struct soc_camera_device; + +struct v4l2_crop; +struct v4l2_mbus_framefmt; +struct v4l2_pix_format; +struct v4l2_rect; +struct v4l2_subdev; + +static inline unsigned int soc_camera_shift_scale(unsigned int size, + unsigned int shift, unsigned int scale) +{ + return DIV_ROUND_CLOSEST(size << shift, scale); +} + +#define soc_camera_calc_scale(in, shift, out) soc_camera_shift_scale(in, shift, out) + +int soc_camera_client_g_rect(struct v4l2_subdev *sd, struct v4l2_rect *rect); +int soc_camera_client_s_crop(struct v4l2_subdev *sd, + struct v4l2_crop *crop, struct v4l2_crop *cam_crop, + struct v4l2_rect *target_rect, struct v4l2_rect *subrect); +int soc_camera_client_scale(struct soc_camera_device *icd, + struct v4l2_rect *rect, struct v4l2_rect *subrect, + struct v4l2_mbus_framefmt *mf, + unsigned int *width, unsigned int *height, + bool host_can_scale, unsigned int shift); +void soc_camera_calc_client_output(struct soc_camera_device *icd, + struct v4l2_rect *rect, struct v4l2_rect *subrect, + const struct v4l2_pix_format *pix, struct v4l2_mbus_framefmt *mf, + unsigned int shift); + +#endif From 79275a994c2e672b2c3a893a1e2840a204adc3f7 Mon Sep 17 00:00:00 2001 From: Guennadi Liakhovetski Date: Tue, 25 Jun 2013 05:59:23 -0300 Subject: [PATCH 0495/1048] [media] V4L2: soc-camera: remove several CEU references in the generic scaler The scaling / cropping library, that has been extracted from the CEU driver still contained a couple of references to the original hardware. Clean them up. Signed-off-by: Guennadi Liakhovetski Signed-off-by: Mauro Carvalho Chehab --- .../media/platform/soc_camera/soc_scale_crop.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/media/platform/soc_camera/soc_scale_crop.c b/drivers/media/platform/soc_camera/soc_scale_crop.c index be7067f55a29..cbd3a34f4f3f 100644 --- a/drivers/media/platform/soc_camera/soc_scale_crop.c +++ b/drivers/media/platform/soc_camera/soc_scale_crop.c @@ -221,7 +221,7 @@ static int client_s_fmt(struct soc_camera_device *icd, struct device *dev = icd->parent; unsigned int width = mf->width, height = mf->height, tmp_w, tmp_h; struct v4l2_cropcap cap; - bool ceu_1to1; + bool host_1to1; int ret; ret = v4l2_device_call_until_err(sd->v4l2_dev, @@ -234,11 +234,11 @@ static int client_s_fmt(struct soc_camera_device *icd, if (width == mf->width && height == mf->height) { /* Perfect! The client has done it all. */ - ceu_1to1 = true; + host_1to1 = true; goto update_cache; } - ceu_1to1 = false; + host_1to1 = false; if (!host_can_scale) goto update_cache; @@ -282,7 +282,7 @@ update_cache: if (ret < 0) return ret; - if (ceu_1to1) + if (host_1to1) *subrect = *rect; else update_subrect(rect, subrect); @@ -338,7 +338,7 @@ int soc_camera_client_scale(struct soc_camera_device *icd, mf->colorspace = mf_tmp.colorspace; /* - * 8. Calculate new CEU crop - apply camera scales to previously + * 8. Calculate new host crop - apply camera scales to previously * updated "effective" crop. */ *width = soc_camera_shift_scale(subrect->width, shift, scale_h); @@ -353,7 +353,7 @@ EXPORT_SYMBOL(soc_camera_client_scale); /* * Calculate real client output window by applying new scales to the current * client crop. New scales are calculated from the requested output format and - * CEU crop, mapped backed onto the client input (subrect). + * host crop, mapped backed onto the client input (subrect). */ void soc_camera_calc_client_output(struct soc_camera_device *icd, struct v4l2_rect *rect, struct v4l2_rect *subrect, @@ -384,7 +384,8 @@ void soc_camera_calc_client_output(struct soc_camera_device *icd, /* * TODO: CEU cannot scale images larger than VGA to smaller than SubQCIF - * (128x96) or larger than VGA + * (128x96) or larger than VGA. This and similar limitations have to be + * taken into account here. */ scale_h = soc_camera_calc_scale(subrect->width, shift, pix->width); scale_v = soc_camera_calc_scale(subrect->height, shift, pix->height); From 2641ff994d12f9f4199d8261d71d2059a8b96ae1 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Thu, 20 Jun 2013 16:28:14 -0300 Subject: [PATCH 0496/1048] [media] ml86v7667: fix compiler warning build/media_build/v4l/ml86v7667.c: In function 'ml86v7667_s_ctrl': build/media_build/v4l/ml86v7667.c:120:6: warning: variable 'ret' set but not used [-Wunused-but-set-variable] int ret = 0; ^ Signed-off-by: Hans Verkuil Cc: Vladimir Barinov Signed-off-by: Mauro Carvalho Chehab --- drivers/media/i2c/ml86v7667.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/i2c/ml86v7667.c b/drivers/media/i2c/ml86v7667.c index cd9f86e743b2..efdc873e58d1 100644 --- a/drivers/media/i2c/ml86v7667.c +++ b/drivers/media/i2c/ml86v7667.c @@ -117,7 +117,7 @@ static int ml86v7667_s_ctrl(struct v4l2_ctrl *ctrl) { struct v4l2_subdev *sd = to_sd(ctrl); struct i2c_client *client = v4l2_get_subdevdata(sd); - int ret = 0; + int ret; switch (ctrl->id) { case V4L2_CID_BRIGHTNESS: From 20420f92474b4ef36635f427aacafa8a80c124a6 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Thu, 20 Jun 2013 16:28:15 -0300 Subject: [PATCH 0497/1048] [media] bfin_capture: fix compiler warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit media-git/drivers/media/platform/blackfin/bfin_capture.c: In function ‘bcap_probe’: media-git/drivers/media/platform/blackfin/bfin_capture.c:1007:16: warning: ignoring return value of ‘vb2_queue_init’, declared with attribute warn_unused_result [-Wunused-result] vb2_queue_init(q); ^ Signed-off-by: Hans Verkuil Acked-by: Scott Jiang Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/blackfin/bfin_capture.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/blackfin/bfin_capture.c b/drivers/media/platform/blackfin/bfin_capture.c index 6652e71ea794..7f838c681cea 100644 --- a/drivers/media/platform/blackfin/bfin_capture.c +++ b/drivers/media/platform/blackfin/bfin_capture.c @@ -1004,7 +1004,9 @@ static int bcap_probe(struct platform_device *pdev) q->mem_ops = &vb2_dma_contig_memops; q->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; - vb2_queue_init(q); + ret = vb2_queue_init(q); + if (ret) + goto err_free_handler; mutex_init(&bcap_dev->mutex); init_completion(&bcap_dev->comp); From fe653786ff9027216d841470b140593f3bf3a695 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Thu, 20 Jun 2013 16:28:16 -0300 Subject: [PATCH 0498/1048] [media] omap_vout: fix compiler warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit media-git/drivers/media/platform/omap/omap_vout.c: In function ‘omapvid_init’: media-git/drivers/media/platform/omap/omap_vout.c:382:17: warning: ‘mode’ may be used uninitialized in this function [-Wmaybe-uninitialized] vout->dss_mode = video_mode_to_dss_mode(vout); ^ media-git/drivers/media/platform/omap/omap_vout.c:332:23: note: ‘mode’ was declared here enum omap_color_mode mode; ^ Signed-off-by: Hans Verkuil Cc: Laurent Pinchart Cc: Prabhakar Lad Acked-by: Lad, Prabhakar Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/omap/omap_vout.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/media/platform/omap/omap_vout.c b/drivers/media/platform/omap/omap_vout.c index d338b19da544..dfd0a21a0658 100644 --- a/drivers/media/platform/omap/omap_vout.c +++ b/drivers/media/platform/omap/omap_vout.c @@ -335,8 +335,6 @@ static int video_mode_to_dss_mode(struct omap_vout_device *vout) ovl = ovid->overlays[0]; switch (pix->pixelformat) { - case 0: - break; case V4L2_PIX_FMT_YUYV: mode = OMAP_DSS_COLOR_YUV2; break; @@ -358,6 +356,7 @@ static int video_mode_to_dss_mode(struct omap_vout_device *vout) break; default: mode = -EINVAL; + break; } return mode; } From 5a1d3e9f18ceb8d791bdc9a78d8ee10ddc80a6e8 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Fri, 21 Jun 2013 02:05:34 -0300 Subject: [PATCH 0499/1048] [media] v4l2-controls.h: fix copy-and-paste error in comment The comment for the FM_RX class was copied from the DV class unchanged. Fixed. Also made the FM_TX comment consistent with the others. Signed-off-by: Hans Verkuil Acked-by: Laurent Pinchart Signed-off-by: Mauro Carvalho Chehab --- include/uapi/linux/v4l2-controls.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/uapi/linux/v4l2-controls.h b/include/uapi/linux/v4l2-controls.h index 69bd5bb0d5af..e90a88a8708f 100644 --- a/include/uapi/linux/v4l2-controls.h +++ b/include/uapi/linux/v4l2-controls.h @@ -53,13 +53,13 @@ #define V4L2_CTRL_CLASS_USER 0x00980000 /* Old-style 'user' controls */ #define V4L2_CTRL_CLASS_MPEG 0x00990000 /* MPEG-compression controls */ #define V4L2_CTRL_CLASS_CAMERA 0x009a0000 /* Camera class controls */ -#define V4L2_CTRL_CLASS_FM_TX 0x009b0000 /* FM Modulator control class */ +#define V4L2_CTRL_CLASS_FM_TX 0x009b0000 /* FM Modulator controls */ #define V4L2_CTRL_CLASS_FLASH 0x009c0000 /* Camera flash controls */ #define V4L2_CTRL_CLASS_JPEG 0x009d0000 /* JPEG-compression controls */ #define V4L2_CTRL_CLASS_IMAGE_SOURCE 0x009e0000 /* Image source controls */ #define V4L2_CTRL_CLASS_IMAGE_PROC 0x009f0000 /* Image processing controls */ #define V4L2_CTRL_CLASS_DV 0x00a00000 /* Digital Video controls */ -#define V4L2_CTRL_CLASS_FM_RX 0x00a10000 /* Digital Video controls */ +#define V4L2_CTRL_CLASS_FM_RX 0x00a10000 /* FM Receiver controls */ /* User-class control IDs */ From fd8d30bf20db099eec4d7f7e678e6d6fa8e492b7 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Fri, 21 Jun 2013 16:16:47 -0300 Subject: [PATCH 0500/1048] [media] saa7164: fix compiler warning build/media_build/v4l/saa7164-core.c: In function 'saa7164_initdev': build/media_build/v4l/saa7164-core.c:1192:6: warning: 'err' may be used uninitialized in this function [-Wmaybe-uninitialized] int err, i; ^ Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/pci/saa7164/saa7164-core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/media/pci/saa7164/saa7164-core.c b/drivers/media/pci/saa7164/saa7164-core.c index 5d27865784c5..d37ee37aaefe 100644 --- a/drivers/media/pci/saa7164/saa7164-core.c +++ b/drivers/media/pci/saa7164/saa7164-core.c @@ -1196,7 +1196,8 @@ static int saa7164_initdev(struct pci_dev *pci_dev, if (NULL == dev) return -ENOMEM; - if (v4l2_device_register(&pci_dev->dev, &dev->v4l2_dev)) { + err = v4l2_device_register(&pci_dev->dev, &dev->v4l2_dev); + if (err < 0) { dev_err(&pci_dev->dev, "v4l2_device_register failed\n"); goto fail_free; } From 12d866ecd008ad8c9b818836fe84994ac8f80e18 Mon Sep 17 00:00:00 2001 From: Emil Goode Date: Sat, 22 Jun 2013 08:02:52 -0300 Subject: [PATCH 0501/1048] [media] saa7134: Fix sparse warnings by adding __user annotation Adding a __user annotation fixes the following sparse warnings. drivers/media/pci/saa7134/saa7134-video.c:1578:45: warning: incorrect type in initializer (different address spaces) drivers/media/pci/saa7134/saa7134-video.c:1578:45: expected struct v4l2_clip *clips drivers/media/pci/saa7134/saa7134-video.c:1578:45: got struct v4l2_clip [noderef] *clips drivers/media/pci/saa7134/saa7134-video.c:1589:26: warning: incorrect type in assignment (different address spaces) drivers/media/pci/saa7134/saa7134-video.c:1589:26: expected struct v4l2_clip [noderef] *clips drivers/media/pci/saa7134/saa7134-video.c:1589:26: got struct v4l2_clip *clips Signed-off-by: Emil Goode Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/pci/saa7134/saa7134-video.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/pci/saa7134/saa7134-video.c b/drivers/media/pci/saa7134/saa7134-video.c index e3457aea6a33..e12bbd8c3f0b 100644 --- a/drivers/media/pci/saa7134/saa7134-video.c +++ b/drivers/media/pci/saa7134/saa7134-video.c @@ -1575,7 +1575,7 @@ static int saa7134_g_fmt_vid_overlay(struct file *file, void *priv, { struct saa7134_fh *fh = priv; struct saa7134_dev *dev = fh->dev; - struct v4l2_clip *clips = f->fmt.win.clips; + struct v4l2_clip __user *clips = f->fmt.win.clips; u32 clipcount = f->fmt.win.clipcount; int err = 0; int i; From f0a12d0c9272ae24491b983c4982acdacdac1baf Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Sun, 23 Jun 2013 10:01:35 -0300 Subject: [PATCH 0502/1048] [media] tvp514x: Fix init seqeunce client->driver->id_table will always point to the first entry in the device id table. So all devices will use the same init sequence. Use the id table entry that gets passed to the driver's probe() function to get the right init sequence. Signed-off-by: Lars-Peter Clausen Acked-by: Lad, Prabhakar Tested-by: Lad, Prabhakar Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/i2c/tvp514x.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/media/i2c/tvp514x.c b/drivers/media/i2c/tvp514x.c index 864eb14ae9b1..03289e57a217 100644 --- a/drivers/media/i2c/tvp514x.c +++ b/drivers/media/i2c/tvp514x.c @@ -123,6 +123,8 @@ struct tvp514x_decoder { /* mc related members */ struct media_pad pad; struct v4l2_mbus_framefmt format; + + struct tvp514x_reg *int_seq; }; /* TVP514x default register values */ @@ -864,7 +866,6 @@ tvp514x_s_parm(struct v4l2_subdev *sd, struct v4l2_streamparm *a) static int tvp514x_s_stream(struct v4l2_subdev *sd, int enable) { int err = 0; - struct i2c_client *client = v4l2_get_subdevdata(sd); struct tvp514x_decoder *decoder = to_decoder(sd); if (decoder->streaming == enable) @@ -884,11 +885,8 @@ static int tvp514x_s_stream(struct v4l2_subdev *sd, int enable) } case 1: { - struct tvp514x_reg *int_seq = (struct tvp514x_reg *) - client->driver->id_table->driver_data; - /* Power Up Sequence */ - err = tvp514x_write_regs(sd, int_seq); + err = tvp514x_write_regs(sd, decoder->int_seq); if (err) { v4l2_err(sd, "Unable to turn on decoder\n"); return err; @@ -1128,6 +1126,8 @@ tvp514x_probe(struct i2c_client *client, const struct i2c_device_id *id) memcpy(decoder->tvp514x_regs, tvp514x_reg_list_default, sizeof(tvp514x_reg_list_default)); + decoder->int_seq = (struct tvp514x_reg *)id->driver_data; + /* Copy board specific information here */ decoder->pdata = pdata; From ae09e9e73a7d59bf0f8cc92e51c51abbd4cab732 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Sat, 22 Jun 2013 02:38:37 -0300 Subject: [PATCH 0503/1048] [media] wl128x: add missing struct v4l2_device This struct is now required for all video device nodes, but it was missing in this driver. Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/radio/wl128x/fmdrv.h | 2 ++ drivers/media/radio/wl128x/fmdrv_v4l2.c | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/drivers/media/radio/wl128x/fmdrv.h b/drivers/media/radio/wl128x/fmdrv.h index aac0f025f767..a587c9bac930 100644 --- a/drivers/media/radio/wl128x/fmdrv.h +++ b/drivers/media/radio/wl128x/fmdrv.h @@ -30,6 +30,7 @@ #include #include #include +#include #include #define FM_DRV_VERSION "0.1.1" @@ -202,6 +203,7 @@ struct fmtx_data { /* FM driver operation structure */ struct fmdev { struct video_device *radio_dev; /* V4L2 video device pointer */ + struct v4l2_device v4l2_dev; /* V4L2 top level struct */ struct snd_card *card; /* Card which holds FM mixer controls */ u16 asci_id; spinlock_t rds_buff_lock; /* To protect access to RDS buffer */ diff --git a/drivers/media/radio/wl128x/fmdrv_v4l2.c b/drivers/media/radio/wl128x/fmdrv_v4l2.c index 5dec323f4247..b55012c11842 100644 --- a/drivers/media/radio/wl128x/fmdrv_v4l2.c +++ b/drivers/media/radio/wl128x/fmdrv_v4l2.c @@ -533,6 +533,11 @@ int fm_v4l2_init_video_device(struct fmdev *fmdev, int radio_nr) struct v4l2_ctrl *ctrl; int ret; + strlcpy(fmdev->v4l2_dev.name, FM_DRV_NAME, sizeof(fmdev->v4l2_dev.name)); + ret = v4l2_device_register(NULL, &fmdev->v4l2_dev); + if (ret < 0) + return ret; + /* Init mutex for core locking */ mutex_init(&fmdev->mutex); @@ -549,6 +554,7 @@ int fm_v4l2_init_video_device(struct fmdev *fmdev, int radio_nr) video_set_drvdata(gradio_dev, fmdev); gradio_dev->lock = &fmdev->mutex; + gradio_dev->v4l2_dev = &fmdev->v4l2_dev; /* Register with V4L2 subsystem as RADIO device */ if (video_register_device(gradio_dev, VFL_TYPE_RADIO, radio_nr)) { @@ -611,5 +617,7 @@ void *fm_v4l2_deinit_video_device(void) /* Unregister RADIO device from V4L2 subsystem */ video_unregister_device(gradio_dev); + v4l2_device_unregister(&fmdev->v4l2_dev); + return fmdev; } From 8f484d8767d3d80bc20bb341a4b3e35894ef704b Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Thu, 27 Jun 2013 02:44:04 -0300 Subject: [PATCH 0504/1048] [media] mem2mem: set missing v4l2_dev pointer The m2m-deinterlace, mem2mem_testdev and mx2_emmaprp drivers didn't set the v4l2_dev pointer in struct video_device, even though a v4l2_device was registered correctly. These days this v4l2_dev pointer must be set correctly, so this patch adds that for these three drivers. Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/m2m-deinterlace.c | 1 + drivers/media/platform/mem2mem_testdev.c | 3 ++- drivers/media/platform/mx2_emmaprp.c | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/m2m-deinterlace.c b/drivers/media/platform/m2m-deinterlace.c index 758564649589..540516ca872c 100644 --- a/drivers/media/platform/m2m-deinterlace.c +++ b/drivers/media/platform/m2m-deinterlace.c @@ -1033,6 +1033,7 @@ static int deinterlace_probe(struct platform_device *pdev) *vfd = deinterlace_videodev; vfd->lock = &pcdev->dev_mutex; + vfd->v4l2_dev = &pcdev->v4l2_dev; ret = video_register_device(vfd, VFL_TYPE_GRABBER, 0); if (ret) { diff --git a/drivers/media/platform/mem2mem_testdev.c b/drivers/media/platform/mem2mem_testdev.c index 4cc7f65d7d76..6a17676f9d72 100644 --- a/drivers/media/platform/mem2mem_testdev.c +++ b/drivers/media/platform/mem2mem_testdev.c @@ -1051,6 +1051,7 @@ static int m2mtest_probe(struct platform_device *pdev) *vfd = m2mtest_videodev; vfd->lock = &dev->dev_mutex; + vfd->v4l2_dev = &dev->v4l2_dev; ret = video_register_device(vfd, VFL_TYPE_GRABBER, 0); if (ret) { @@ -1061,7 +1062,7 @@ static int m2mtest_probe(struct platform_device *pdev) video_set_drvdata(vfd, dev); snprintf(vfd->name, sizeof(vfd->name), "%s", m2mtest_videodev.name); dev->vfd = vfd; - v4l2_info(&dev->v4l2_dev, MEM2MEM_TEST_MODULE_NAME + v4l2_info(&dev->v4l2_dev, "Device registered as /dev/video%d\n", vfd->num); setup_timer(&dev->timer, device_isr, (long)dev); diff --git a/drivers/media/platform/mx2_emmaprp.c b/drivers/media/platform/mx2_emmaprp.c index f7440e585b6b..c690435853bd 100644 --- a/drivers/media/platform/mx2_emmaprp.c +++ b/drivers/media/platform/mx2_emmaprp.c @@ -937,6 +937,7 @@ static int emmaprp_probe(struct platform_device *pdev) *vfd = emmaprp_videodev; vfd->lock = &pcdev->dev_mutex; + vfd->v4l2_dev = &pcdev->v4l2_dev; video_set_drvdata(vfd, pcdev); snprintf(vfd->name, sizeof(vfd->name), "%s", emmaprp_videodev.name); From fc84e65fff543564ea5a5f619053101c099353d4 Mon Sep 17 00:00:00 2001 From: "Lad, Prabhakar" Date: Mon, 24 Jun 2013 11:47:25 -0300 Subject: [PATCH 0505/1048] [media] media: i2c: tvp7002: remove manual setting of subdev name This patch removes manual setting of subdev name in the probe, ideally subdev names must be unique. Signed-off-by: Lad, Prabhakar Cc: Hans Verkuil Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/i2c/tvp7002.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/media/i2c/tvp7002.c b/drivers/media/i2c/tvp7002.c index 36ad565e5a33..a4e49483de6a 100644 --- a/drivers/media/i2c/tvp7002.c +++ b/drivers/media/i2c/tvp7002.c @@ -1020,7 +1020,6 @@ static int tvp7002_probe(struct i2c_client *c, const struct i2c_device_id *id) error = tvp7002_s_dv_timings(sd, &timings); #if defined(CONFIG_MEDIA_CONTROLLER) - strlcpy(sd->name, TVP7002_MODULE_NAME, sizeof(sd->name)); device->pad.flags = MEDIA_PAD_FL_SOURCE; device->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; device->sd.entity.flags |= MEDIA_ENT_T_V4L2_SUBDEV_DECODER; From f042ff650f47ea2868e5f89fa76370d4ebe43f4b Mon Sep 17 00:00:00 2001 From: "Lad, Prabhakar" Date: Mon, 24 Jun 2013 11:47:26 -0300 Subject: [PATCH 0506/1048] [media] media: i2c: tvp514x: remove manual setting of subdev name This patch removes manual setting of subdev name in the probe, ideally subdev names must be unique. Signed-off-by: Lad, Prabhakar Cc: Hans Verkuil Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/i2c/tvp514x.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/media/i2c/tvp514x.c b/drivers/media/i2c/tvp514x.c index 03289e57a217..9c6d66a9868f 100644 --- a/drivers/media/i2c/tvp514x.c +++ b/drivers/media/i2c/tvp514x.c @@ -1148,7 +1148,6 @@ tvp514x_probe(struct i2c_client *client, const struct i2c_device_id *id) /* Register with V4L2 layer as slave device */ sd = &decoder->sd; v4l2_i2c_subdev_init(sd, client, &tvp514x_ops); - strlcpy(sd->name, TVP514X_MODULE_NAME, sizeof(sd->name)); #if defined(CONFIG_MEDIA_CONTROLLER) decoder->pad.flags = MEDIA_PAD_FL_SOURCE; From 47d1f33ff43e3d4f74fff1892d44d1de34a80be2 Mon Sep 17 00:00:00 2001 From: Sylwester Nawrocki Date: Tue, 11 Jun 2013 10:44:38 -0300 Subject: [PATCH 0507/1048] [media] exynos4-is: Drop drvdata handling in fimc-lite for non-dt platforms The FIMC-LITE IP block is available only on platforms instantiated from device tree. Signed-off-by: Sylwester Nawrocki Signed-off-by: Kyungmin Park Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/exynos4-is/fimc-lite.c | 3 --- drivers/media/platform/exynos4-is/fimc-lite.h | 3 --- 2 files changed, 6 deletions(-) diff --git a/drivers/media/platform/exynos4-is/fimc-lite.c b/drivers/media/platform/exynos4-is/fimc-lite.c index 3f76f8abc4b3..00c525c377d8 100644 --- a/drivers/media/platform/exynos4-is/fimc-lite.c +++ b/drivers/media/platform/exynos4-is/fimc-lite.c @@ -1449,9 +1449,6 @@ static int fimc_lite_probe(struct platform_device *pdev) if (of_id) drv_data = (struct flite_drvdata *)of_id->data; fimc->index = of_alias_get_id(dev->of_node, "fimc-lite"); - } else { - drv_data = fimc_lite_get_drvdata(pdev); - fimc->index = pdev->id; } if (!drv_data || fimc->index < 0 || fimc->index >= FIMC_LITE_MAX_DEVS) diff --git a/drivers/media/platform/exynos4-is/fimc-lite.h b/drivers/media/platform/exynos4-is/fimc-lite.h index c7aa08477830..4b1068425dad 100644 --- a/drivers/media/platform/exynos4-is/fimc-lite.h +++ b/drivers/media/platform/exynos4-is/fimc-lite.h @@ -56,9 +56,6 @@ struct flite_drvdata { unsigned short out_hor_offs_align; }; -#define fimc_lite_get_drvdata(_pdev) \ - ((struct flite_drvdata *) platform_get_device_id(_pdev)->driver_data) - struct fimc_lite_events { unsigned int data_overflow; }; From 086eca2905d0d1ea6b5e22d62648c6b818c51846 Mon Sep 17 00:00:00 2001 From: Sylwester Nawrocki Date: Fri, 14 Jun 2013 12:38:15 -0300 Subject: [PATCH 0508/1048] [media] exynos4-is: Add Exynos5250 SoC support to fimc-lite driver This patch adds support for the Exynos5250 SoC variant of the FIMC-LITE IP. A 'compatible' string is added for Exynos5250 compatible devices and the capture DMA handling is reworked to use the FLITE_REG_CIFCNTSEQ register, masking output DMA buffer address slots. The frame interrupt is enabled so there are now 2 interrupts per frame. This likely can be optimized in future by using any status registers that allow to figure out what the last and the currently written frame buffer is. It would also be more reliable in cases where there are high interrupt service latencies. Signed-off-by: Shaik Ameer Basha Signed-off-by: Arun Kumar K Signed-off-by: Sylwester Nawrocki Signed-off-by: Kyungmin Park --- .../bindings/media/exynos-fimc-lite.txt | 6 ++- .../media/platform/exynos4-is/fimc-lite-reg.c | 53 +++++++++++++++++-- .../media/platform/exynos4-is/fimc-lite-reg.h | 10 +++- drivers/media/platform/exynos4-is/fimc-lite.c | 50 ++++++++++++++--- drivers/media/platform/exynos4-is/fimc-lite.h | 22 +++++++- 5 files changed, 125 insertions(+), 16 deletions(-) diff --git a/Documentation/devicetree/bindings/media/exynos-fimc-lite.txt b/Documentation/devicetree/bindings/media/exynos-fimc-lite.txt index de9f6b78ee51..0bf6fb7fbeab 100644 --- a/Documentation/devicetree/bindings/media/exynos-fimc-lite.txt +++ b/Documentation/devicetree/bindings/media/exynos-fimc-lite.txt @@ -2,8 +2,10 @@ Exynos4x12/Exynos5 SoC series camera host interface (FIMC-LITE) Required properties: -- compatible : should be "samsung,exynos4212-fimc-lite" for Exynos4212 and - Exynos4412 SoCs; +- compatible : should be one of: + "samsung,exynos4212-fimc-lite" for Exynos4212/4412 SoCs, + "samsung,exynos5250-fimc-lite" for Exynos5250 compatible + devices; - reg : physical base address and size of the device memory mapped registers; - interrupts : should contain FIMC-LITE interrupt; diff --git a/drivers/media/platform/exynos4-is/fimc-lite-reg.c b/drivers/media/platform/exynos4-is/fimc-lite-reg.c index eb4f7635f5e0..72a343e3b5e8 100644 --- a/drivers/media/platform/exynos4-is/fimc-lite-reg.c +++ b/drivers/media/platform/exynos4-is/fimc-lite-reg.c @@ -2,15 +2,16 @@ * Register interface file for EXYNOS FIMC-LITE (camera interface) driver * * Copyright (C) 2012 Samsung Electronics Co., Ltd. - * Sylwester Nawrocki + * Author: Sylwester Nawrocki * * 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. */ -#include +#include #include +#include #include #include "fimc-lite-reg.h" @@ -68,7 +69,8 @@ void flite_hw_set_interrupt_mask(struct fimc_lite *dev) if (atomic_read(&dev->out_path) == FIMC_IO_DMA) { intsrc = FLITE_REG_CIGCTRL_IRQ_OVFEN | FLITE_REG_CIGCTRL_IRQ_LASTEN | - FLITE_REG_CIGCTRL_IRQ_STARTEN; + FLITE_REG_CIGCTRL_IRQ_STARTEN | + FLITE_REG_CIGCTRL_IRQ_ENDEN; } else { /* An output to the FIMC-IS */ intsrc = FLITE_REG_CIGCTRL_IRQ_OVFEN | @@ -215,6 +217,18 @@ void flite_hw_set_camera_bus(struct fimc_lite *dev, flite_hw_set_camera_port(dev, si->mux_id); } +static void flite_hw_set_pack12(struct fimc_lite *dev, int on) +{ + u32 cfg = readl(dev->regs + FLITE_REG_CIODMAFMT); + + cfg &= ~FLITE_REG_CIODMAFMT_PACK12; + + if (on) + cfg |= FLITE_REG_CIODMAFMT_PACK12; + + writel(cfg, dev->regs + FLITE_REG_CIODMAFMT); +} + static void flite_hw_set_out_order(struct fimc_lite *dev, struct flite_frame *f) { static const u32 pixcode[4][2] = { @@ -250,6 +264,38 @@ void flite_hw_set_dma_window(struct fimc_lite *dev, struct flite_frame *f) writel(cfg, dev->regs + FLITE_REG_CIOOFF); } +void flite_hw_set_dma_buffer(struct fimc_lite *dev, struct flite_buffer *buf) +{ + unsigned int index; + u32 cfg; + + if (dev->dd->max_dma_bufs == 1) + index = 0; + else + index = buf->index; + + if (index == 0) + writel(buf->paddr, dev->regs + FLITE_REG_CIOSA); + else + writel(buf->paddr, dev->regs + FLITE_REG_CIOSAN(index - 1)); + + cfg = readl(dev->regs + FLITE_REG_CIFCNTSEQ); + cfg |= BIT(index); + writel(cfg, dev->regs + FLITE_REG_CIFCNTSEQ); +} + +void flite_hw_mask_dma_buffer(struct fimc_lite *dev, u32 index) +{ + u32 cfg; + + if (dev->dd->max_dma_bufs == 1) + index = 0; + + cfg = readl(dev->regs + FLITE_REG_CIFCNTSEQ); + cfg &= ~BIT(index); + writel(cfg, dev->regs + FLITE_REG_CIFCNTSEQ); +} + /* Enable/disable output DMA, set output pixel size and offsets (composition) */ void flite_hw_set_output_dma(struct fimc_lite *dev, struct flite_frame *f, bool enable) @@ -267,6 +313,7 @@ void flite_hw_set_output_dma(struct fimc_lite *dev, struct flite_frame *f, flite_hw_set_out_order(dev, f); flite_hw_set_dma_window(dev, f); + flite_hw_set_pack12(dev, 0); } void flite_hw_dump_regs(struct fimc_lite *dev, const char *label) diff --git a/drivers/media/platform/exynos4-is/fimc-lite-reg.h b/drivers/media/platform/exynos4-is/fimc-lite-reg.h index 390383941c19..10a7d7bbcc27 100644 --- a/drivers/media/platform/exynos4-is/fimc-lite-reg.h +++ b/drivers/media/platform/exynos4-is/fimc-lite-reg.h @@ -120,6 +120,9 @@ /* b0: 1 - camera B, 0 - camera A */ #define FLITE_REG_CIGENERAL_CAM_B (1 << 0) +#define FLITE_REG_CIFCNTSEQ 0x100 +#define FLITE_REG_CIOSAN(x) (0x200 + (4 * (x))) + /* ---------------------------------------------------------------------------- * Function declarations */ @@ -142,9 +145,12 @@ void flite_hw_set_output_dma(struct fimc_lite *dev, struct flite_frame *f, void flite_hw_set_dma_window(struct fimc_lite *dev, struct flite_frame *f); void flite_hw_set_test_pattern(struct fimc_lite *dev, bool on); void flite_hw_dump_regs(struct fimc_lite *dev, const char *label); +void flite_hw_set_dma_buffer(struct fimc_lite *dev, struct flite_buffer *buf); +void flite_hw_mask_dma_buffer(struct fimc_lite *dev, u32 index); -static inline void flite_hw_set_output_addr(struct fimc_lite *dev, u32 paddr) +static inline void flite_hw_set_dma_buf_mask(struct fimc_lite *dev, u32 mask) { - writel(paddr, dev->regs + FLITE_REG_CIOSA); + writel(mask, dev->regs + FLITE_REG_CIFCNTSEQ); } + #endif /* FIMC_LITE_REG_H */ diff --git a/drivers/media/platform/exynos4-is/fimc-lite.c b/drivers/media/platform/exynos4-is/fimc-lite.c index 00c525c377d8..07767c8b1c62 100644 --- a/drivers/media/platform/exynos4-is/fimc-lite.c +++ b/drivers/media/platform/exynos4-is/fimc-lite.c @@ -153,6 +153,7 @@ static int fimc_lite_hw_init(struct fimc_lite *fimc, bool isp_output) flite_hw_set_camera_bus(fimc, si); flite_hw_set_source_format(fimc, &fimc->inp_frame); flite_hw_set_window_offset(fimc, &fimc->inp_frame); + flite_hw_set_dma_buf_mask(fimc, 0); flite_hw_set_output_dma(fimc, &fimc->out_frame, !isp_output); flite_hw_set_interrupt_mask(fimc); flite_hw_set_test_pattern(fimc, fimc->test_pattern->val); @@ -276,19 +277,23 @@ static irqreturn_t flite_irq_handler(int irq, void *priv) if ((intsrc & FLITE_REG_CISTATUS_IRQ_SRC_FRMSTART) && test_bit(ST_FLITE_RUN, &fimc->state) && - !list_empty(&fimc->active_buf_q) && !list_empty(&fimc->pending_buf_q)) { + vbuf = fimc_lite_pending_queue_pop(fimc); + flite_hw_set_dma_buffer(fimc, vbuf); + fimc_lite_active_queue_add(fimc, vbuf); + } + + if ((intsrc & FLITE_REG_CISTATUS_IRQ_SRC_FRMEND) && + test_bit(ST_FLITE_RUN, &fimc->state) && + !list_empty(&fimc->active_buf_q)) { vbuf = fimc_lite_active_queue_pop(fimc); ktime_get_ts(&ts); tv = &vbuf->vb.v4l2_buf.timestamp; tv->tv_sec = ts.tv_sec; tv->tv_usec = ts.tv_nsec / NSEC_PER_USEC; vbuf->vb.v4l2_buf.sequence = fimc->frame_count++; + flite_hw_mask_dma_buffer(fimc, vbuf->index); vb2_buffer_done(&vbuf->vb, VB2_BUF_STATE_DONE); - - vbuf = fimc_lite_pending_queue_pop(fimc); - flite_hw_set_output_addr(fimc, vbuf->paddr); - fimc_lite_active_queue_add(fimc, vbuf); } if (test_bit(ST_FLITE_CONFIG, &fimc->state)) @@ -307,10 +312,16 @@ done: static int start_streaming(struct vb2_queue *q, unsigned int count) { struct fimc_lite *fimc = q->drv_priv; + unsigned long flags; int ret; + spin_lock_irqsave(&fimc->slock, flags); + + fimc->buf_index = 0; fimc->frame_count = 0; + spin_unlock_irqrestore(&fimc->slock, flags); + ret = fimc_lite_hw_init(fimc, false); if (ret) { fimc_lite_reinit(fimc, false); @@ -412,10 +423,14 @@ static void buffer_queue(struct vb2_buffer *vb) spin_lock_irqsave(&fimc->slock, flags); buf->paddr = vb2_dma_contig_plane_dma_addr(vb, 0); + buf->index = fimc->buf_index++; + if (fimc->buf_index >= fimc->reqbufs_count) + fimc->buf_index = 0; + if (!test_bit(ST_FLITE_SUSPENDED, &fimc->state) && !test_bit(ST_FLITE_STREAM, &fimc->state) && list_empty(&fimc->active_buf_q)) { - flite_hw_set_output_addr(fimc, buf->paddr); + flite_hw_set_dma_buffer(fimc, buf); fimc_lite_active_queue_add(fimc, buf); } else { fimc_lite_pending_queue_add(fimc, buf); @@ -1451,8 +1466,12 @@ static int fimc_lite_probe(struct platform_device *pdev) fimc->index = of_alias_get_id(dev->of_node, "fimc-lite"); } - if (!drv_data || fimc->index < 0 || fimc->index >= FIMC_LITE_MAX_DEVS) + if (!drv_data || fimc->index >= drv_data->num_instances || + fimc->index < 0) { + dev_err(dev, "Wrong %s node alias\n", + dev->of_node->full_name); return -EINVAL; + } fimc->dd = drv_data; fimc->pdev = pdev; @@ -1609,6 +1628,19 @@ static struct flite_drvdata fimc_lite_drvdata_exynos4 = { .out_width_align = 8, .win_hor_offs_align = 2, .out_hor_offs_align = 8, + .max_dma_bufs = 1, + .num_instances = 2, +}; + +/* EXYNOS5250 */ +static struct flite_drvdata fimc_lite_drvdata_exynos5 = { + .max_width = 8192, + .max_height = 8192, + .out_width_align = 8, + .win_hor_offs_align = 2, + .out_hor_offs_align = 8, + .max_dma_bufs = 32, + .num_instances = 3, }; static const struct of_device_id flite_of_match[] = { @@ -1616,6 +1648,10 @@ static const struct of_device_id flite_of_match[] = { .compatible = "samsung,exynos4212-fimc-lite", .data = &fimc_lite_drvdata_exynos4, }, + { + .compatible = "samsung,exynos5250-fimc-lite", + .data = &fimc_lite_drvdata_exynos5, + }, { /* sentinel */ }, }; MODULE_DEVICE_TABLE(of, flite_of_match); diff --git a/drivers/media/platform/exynos4-is/fimc-lite.h b/drivers/media/platform/exynos4-is/fimc-lite.h index 4b1068425dad..c98f3da74870 100644 --- a/drivers/media/platform/exynos4-is/fimc-lite.h +++ b/drivers/media/platform/exynos4-is/fimc-lite.h @@ -27,7 +27,7 @@ #define FIMC_LITE_DRV_NAME "exynos-fimc-lite" #define FLITE_CLK_NAME "flite" -#define FIMC_LITE_MAX_DEVS 2 +#define FIMC_LITE_MAX_DEVS 3 #define FLITE_REQ_BUFS_MIN 2 /* Bit index definitions for struct fimc_lite::state */ @@ -48,12 +48,26 @@ enum { #define FLITE_SD_PAD_SOURCE_ISP 2 #define FLITE_SD_PADS_NUM 3 +/** + * struct flite_drvdata - FIMC-LITE IP variant data structure + * @max_width: maximum camera interface input width in pixels + * @max_height: maximum camera interface input height in pixels + * @out_width_align: minimum output width alignment in pixels + * @win_hor_offs_align: minimum camera interface crop window horizontal + * offset alignment in pixels + * @out_hor_offs_align: minimum output DMA compose rectangle horizontal + * offset alignment in pixels + * @max_dma_bufs: number of output DMA buffer start address registers + * @num_instances: total number of FIMC-LITE IP instances available + */ struct flite_drvdata { unsigned short max_width; unsigned short max_height; unsigned short out_width_align; unsigned short win_hor_offs_align; unsigned short out_hor_offs_align; + unsigned short max_dma_bufs; + unsigned short num_instances; }; struct fimc_lite_events { @@ -80,12 +94,14 @@ struct flite_frame { * struct flite_buffer - video buffer structure * @vb: vb2 buffer * @list: list head for the buffers queue - * @paddr: precalculated physical address + * @paddr: DMA buffer start address + * @index: DMA start address register's index */ struct flite_buffer { struct vb2_buffer vb; struct list_head list; dma_addr_t paddr; + unsigned short index; }; /** @@ -119,6 +135,7 @@ struct flite_buffer { * @pending_buf_q: pending buffers queue head * @active_buf_q: the queue head of buffers scheduled in hardware * @vb_queue: vb2 buffers queue + * @buf_index: helps to keep track of the DMA start address register index * @active_buf_count: number of video buffers scheduled in hardware * @frame_count: the captured frames counter * @reqbufs_count: the number of buffers requested with REQBUFS ioctl @@ -155,6 +172,7 @@ struct fimc_lite { struct list_head pending_buf_q; struct list_head active_buf_q; struct vb2_queue vb_queue; + unsigned short buf_index; unsigned int frame_count; unsigned int reqbufs_count; From f7354e6c230ec62d221e51aa3f970fd3d5eb2067 Mon Sep 17 00:00:00 2001 From: Sylwester Nawrocki Date: Fri, 31 May 2013 10:38:23 -0300 Subject: [PATCH 0509/1048] [media] exynos4-is: Add support for Exynos5250 MIPI-CSIS Add compatible property for the Exynos5250 and enable the frame start and frame end interrupts. These interrupts are needed for the Exynos5 FIMC-IS firmware. The driver enables those interrupt only where available, depending on the 'compatible' property. This can be optimized further, by exposing some API at the subdev driver, so the host driver can enable extra interrupts only for the image processing chains involving FIMC-IS. Signed-off-by: Shaik Ameer Basha Signed-off-by: Sylwester Nawrocki Signed-off-by: Kyungmin Park --- .../bindings/media/samsung-mipi-csis.txt | 4 +- drivers/media/platform/exynos4-is/mipi-csis.c | 67 ++++++++++++++++--- 2 files changed, 58 insertions(+), 13 deletions(-) diff --git a/Documentation/devicetree/bindings/media/samsung-mipi-csis.txt b/Documentation/devicetree/bindings/media/samsung-mipi-csis.txt index 5f8e28e2484f..be45f0b1a449 100644 --- a/Documentation/devicetree/bindings/media/samsung-mipi-csis.txt +++ b/Documentation/devicetree/bindings/media/samsung-mipi-csis.txt @@ -5,8 +5,8 @@ Required properties: - compatible : "samsung,s5pv210-csis" for S5PV210 (S5PC110), "samsung,exynos4210-csis" for Exynos4210 (S5PC210), - "samsung,exynos4212-csis" for Exynos4212/Exynos4412 - SoC series; + "samsung,exynos4212-csis" for Exynos4212/Exynos4412, + "samsung,exynos5250-csis" for Exynos5250; - reg : offset and length of the register set for the device; - interrupts : should contain MIPI CSIS interrupt; the format of the interrupt specifier depends on the interrupt controller; diff --git a/drivers/media/platform/exynos4-is/mipi-csis.c b/drivers/media/platform/exynos4-is/mipi-csis.c index 254d70fe762a..0914230b42de 100644 --- a/drivers/media/platform/exynos4-is/mipi-csis.c +++ b/drivers/media/platform/exynos4-is/mipi-csis.c @@ -1,8 +1,8 @@ /* - * Samsung S5P/EXYNOS4 SoC series MIPI-CSI receiver driver + * Samsung S5P/EXYNOS SoC series MIPI-CSI receiver driver * - * Copyright (C) 2011 - 2012 Samsung Electronics Co., Ltd. - * Sylwester Nawrocki + * Copyright (C) 2011 - 2013 Samsung Electronics Co., Ltd. + * Author: Sylwester Nawrocki * * 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 @@ -66,11 +66,12 @@ MODULE_PARM_DESC(debug, "Debug level (0-2)"); /* Interrupt mask */ #define S5PCSIS_INTMSK 0x10 -#define S5PCSIS_INTMSK_EN_ALL 0xf000103f #define S5PCSIS_INTMSK_EVEN_BEFORE (1 << 31) #define S5PCSIS_INTMSK_EVEN_AFTER (1 << 30) #define S5PCSIS_INTMSK_ODD_BEFORE (1 << 29) #define S5PCSIS_INTMSK_ODD_AFTER (1 << 28) +#define S5PCSIS_INTMSK_FRAME_START (1 << 27) +#define S5PCSIS_INTMSK_FRAME_END (1 << 26) #define S5PCSIS_INTMSK_ERR_SOT_HS (1 << 12) #define S5PCSIS_INTMSK_ERR_LOST_FS (1 << 5) #define S5PCSIS_INTMSK_ERR_LOST_FE (1 << 4) @@ -78,6 +79,8 @@ MODULE_PARM_DESC(debug, "Debug level (0-2)"); #define S5PCSIS_INTMSK_ERR_ECC (1 << 2) #define S5PCSIS_INTMSK_ERR_CRC (1 << 1) #define S5PCSIS_INTMSK_ERR_UNKNOWN (1 << 0) +#define S5PCSIS_INTMSK_EXYNOS4_EN_ALL 0xf000103f +#define S5PCSIS_INTMSK_EXYNOS5_EN_ALL 0xfc00103f /* Interrupt source */ #define S5PCSIS_INTSRC 0x14 @@ -88,6 +91,8 @@ MODULE_PARM_DESC(debug, "Debug level (0-2)"); #define S5PCSIS_INTSRC_ODD_AFTER (1 << 28) #define S5PCSIS_INTSRC_ODD (0x3 << 28) #define S5PCSIS_INTSRC_NON_IMAGE_DATA (0xff << 28) +#define S5PCSIS_INTSRC_FRAME_START (1 << 27) +#define S5PCSIS_INTSRC_FRAME_END (1 << 26) #define S5PCSIS_INTSRC_ERR_SOT_HS (0xf << 12) #define S5PCSIS_INTSRC_ERR_LOST_FS (1 << 5) #define S5PCSIS_INTSRC_ERR_LOST_FE (1 << 4) @@ -151,6 +156,9 @@ static const struct s5pcsis_event s5pcsis_events[] = { { S5PCSIS_INTSRC_EVEN_AFTER, "Non-image data after even frame" }, { S5PCSIS_INTSRC_ODD_BEFORE, "Non-image data before odd frame" }, { S5PCSIS_INTSRC_ODD_AFTER, "Non-image data after odd frame" }, + /* Frame start/end */ + { S5PCSIS_INTSRC_FRAME_START, "Frame Start" }, + { S5PCSIS_INTSRC_FRAME_END, "Frame End" }, }; #define S5PCSIS_NUM_EVENTS ARRAY_SIZE(s5pcsis_events) @@ -159,6 +167,11 @@ struct csis_pktbuf { unsigned int len; }; +struct csis_drvdata { + /* Mask of all used interrupts in S5PCSIS_INTMSK register */ + u32 interrupt_mask; +}; + /** * struct csis_state - the driver's internal state data structure * @lock: mutex serializing the subdev and power management operations, @@ -171,6 +184,7 @@ struct csis_pktbuf { * @supplies: CSIS regulator supplies * @clock: CSIS clocks * @irq: requested s5p-mipi-csis irq number + * @interrupt_mask: interrupt mask of the all used interrupts * @flags: the state variable for power and streaming control * @clock_frequency: device bus clock frequency * @hs_settle: HS-RX settle time @@ -193,6 +207,7 @@ struct csis_state { struct regulator_bulk_data supplies[CSIS_NUM_SUPPLIES]; struct clk *clock[NUM_CSIS_CLOCKS]; int irq; + u32 interrupt_mask; u32 flags; u32 clk_frequency; @@ -274,9 +289,10 @@ static const struct csis_pix_format *find_csis_format( static void s5pcsis_enable_interrupts(struct csis_state *state, bool on) { u32 val = s5pcsis_read(state, S5PCSIS_INTMSK); - - val = on ? val | S5PCSIS_INTMSK_EN_ALL : - val & ~S5PCSIS_INTMSK_EN_ALL; + if (on) + val |= state->interrupt_mask; + else + val &= ~state->interrupt_mask; s5pcsis_write(state, S5PCSIS_INTMSK, val); } @@ -771,8 +787,12 @@ static int s5pcsis_parse_dt(struct platform_device *pdev, #define s5pcsis_parse_dt(pdev, state) (-ENOSYS) #endif +static const struct of_device_id s5pcsis_of_match[]; + static int s5pcsis_probe(struct platform_device *pdev) { + const struct of_device_id *of_id; + const struct csis_drvdata *drv_data; struct device *dev = &pdev->dev; struct resource *mem_res; struct csis_state *state; @@ -787,10 +807,19 @@ static int s5pcsis_probe(struct platform_device *pdev) spin_lock_init(&state->slock); state->pdev = pdev; - if (dev->of_node) + if (dev->of_node) { + of_id = of_match_node(s5pcsis_of_match, dev->of_node); + if (WARN_ON(of_id == NULL)) + return -EINVAL; + + drv_data = of_id->data; + state->interrupt_mask = drv_data->interrupt_mask; + ret = s5pcsis_parse_dt(pdev, state); - else + } else { ret = s5pcsis_get_platform_data(pdev, state); + } + if (ret < 0) return ret; @@ -994,9 +1023,25 @@ static const struct dev_pm_ops s5pcsis_pm_ops = { SET_SYSTEM_SLEEP_PM_OPS(s5pcsis_suspend, s5pcsis_resume) }; +static const struct csis_drvdata exynos4_csis_drvdata = { + .interrupt_mask = S5PCSIS_INTMSK_EXYNOS4_EN_ALL, +}; + +static const struct csis_drvdata exynos5_csis_drvdata = { + .interrupt_mask = S5PCSIS_INTMSK_EXYNOS5_EN_ALL, +}; + static const struct of_device_id s5pcsis_of_match[] = { - { .compatible = "samsung,s5pv210-csis" }, - { .compatible = "samsung,exynos4210-csis" }, + { + .compatible = "samsung,s5pv210-csis", + .data = &exynos4_csis_drvdata, + }, { + .compatible = "samsung,exynos4210-csis", + .data = &exynos4_csis_drvdata, + }, { + .compatible = "samsung,exynos5250-csis", + .data = &exynos5_csis_drvdata, + }, { /* sentinel */ }, }; MODULE_DEVICE_TABLE(of, s5pcsis_of_match); From 72f2a7686cd37324ba5b5111ab294d307f1df50d Mon Sep 17 00:00:00 2001 From: Sylwester Nawrocki Date: Fri, 31 May 2013 10:36:19 -0300 Subject: [PATCH 0510/1048] [media] exynos4-is: Change fimc-is firmware file names This patch changes the firmware file names of the FIMC-IS subsystem. It is needed since there are different firmwares used across various SoC series, e.g. Exynos4 and Exynos5. Also the sensor specific "setfile" name is changed, to account for it depends on an image sensor and is also specific to the FIMC-IS and the SoC. This is a change for a driver merged in 3.10. Signed-off-by: Sylwester Nawrocki Signed-off-by: Kyungmin Park Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/exynos4-is/fimc-is.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/exynos4-is/fimc-is.h b/drivers/media/platform/exynos4-is/fimc-is.h index 08fa518c34f7..61bb0127e19d 100644 --- a/drivers/media/platform/exynos4-is/fimc-is.h +++ b/drivers/media/platform/exynos4-is/fimc-is.h @@ -33,8 +33,8 @@ #define FIMC_IS_DRV_NAME "exynos4-fimc-is" -#define FIMC_IS_FW_FILENAME "fimc_is_fw.bin" -#define FIMC_IS_SETFILE_6A3 "setfile.bin" +#define FIMC_IS_FW_FILENAME "exynos4_fimc_is_fw.bin" +#define FIMC_IS_SETFILE_6A3 "exynos4_s5k6a3_setfile.bin" #define FIMC_IS_FW_LOAD_TIMEOUT 1000 /* ms */ #define FIMC_IS_POWER_ON_TIMEOUT 1000 /* us */ From 188ab116dd9273bb8950481e7764d7eb4f21afb6 Mon Sep 17 00:00:00 2001 From: Sylwester Nawrocki Date: Fri, 14 Jun 2013 19:28:40 -0300 Subject: [PATCH 0511/1048] [media] Documentation: Update driver's directory in video4linux/fimc.txt Update the documentation with the driver's path changed in commit 56fa1a6a6a7da91e7ece8b01b0ae8adb2926e434 [media] s5p-fimc: Change the driver directory to exynos4-is Signed-off-by: Sylwester Nawrocki Signed-off-by: Kyungmin Park Signed-off-by: Mauro Carvalho Chehab --- Documentation/video4linux/fimc.txt | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/Documentation/video4linux/fimc.txt b/Documentation/video4linux/fimc.txt index 25f4d3402722..e51f1b5b7324 100644 --- a/Documentation/video4linux/fimc.txt +++ b/Documentation/video4linux/fimc.txt @@ -1,6 +1,6 @@ Samsung S5P/EXYNOS4 FIMC driver -Copyright (C) 2012 Samsung Electronics Co., Ltd. +Copyright (C) 2012 - 2013 Samsung Electronics Co., Ltd. --------------------------------------------------------------------------- The FIMC (Fully Interactive Mobile Camera) device available in Samsung @@ -10,7 +10,7 @@ data from LCD controller (FIMD) through the SoC internal writeback data path. There are multiple FIMC instances in the SoCs (up to 4), having slightly different capabilities, like pixel alignment constraints, rotator availability, LCD writeback support, etc. The driver is located at -drivers/media/platform/s5p-fimc directory. +drivers/media/platform/exynos4-is directory. 1. Supported SoCs ================= @@ -36,21 +36,21 @@ Not currently supported: ===================== - media device driver - drivers/media/platform/s5p-fimc/fimc-mdevice.[ch] + drivers/media/platform/exynos4-is/media-dev.[ch] - camera capture video device driver - drivers/media/platform/s5p-fimc/fimc-capture.c + drivers/media/platform/exynos4-is/fimc-capture.c - MIPI-CSI2 receiver subdev - drivers/media/platform/s5p-fimc/mipi-csis.[ch] + drivers/media/platform/exynos4-is/mipi-csis.[ch] - video post-processor (mem-to-mem) - drivers/media/platform/s5p-fimc/fimc-core.c + drivers/media/platform/exynos4-is/fimc-core.c - common files - drivers/media/platform/s5p-fimc/fimc-core.h - drivers/media/platform/s5p-fimc/fimc-reg.h - drivers/media/platform/s5p-fimc/regs-fimc.h + drivers/media/platform/exynos4-is/fimc-core.h + drivers/media/platform/exynos4-is/fimc-reg.h + drivers/media/platform/exynos4-is/regs-fimc.h 4. User space interfaces ======================== @@ -143,7 +143,8 @@ or retrieve the information from /dev/media? with help of the media-ctl tool: 6. Platform support =================== -The machine code (plat-s5p and arch/arm/mach-*) must select following options +The machine code (arch/arm/plat-samsung and arch/arm/mach-*) must select +following options: CONFIG_S5P_DEV_FIMC0 mandatory CONFIG_S5P_DEV_FIMC1 \ From 038f5c4be7e8cc100c35a5aedb2557004c280cfa Mon Sep 17 00:00:00 2001 From: Sylwester Nawrocki Date: Tue, 28 May 2013 18:26:20 -0300 Subject: [PATCH 0512/1048] [media] MAINTAINERS: Update S5P/Exynos FIMC driver entry This change is mainly to update the driver's path changed from drivers/media/platform/s5p-fimc to drivers/media/platform/exynos4-is/. While at it, remove non-existent files rule, move the whole entry to the Samsung drivers section and add the patch tracking system site URL. Signed-off-by: Sylwester Nawrocki Signed-off-by: Kyungmin Park Signed-off-by: Mauro Carvalho Chehab --- MAINTAINERS | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/MAINTAINERS b/MAINTAINERS index 5be702cc8449..af77eb1d8293 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1153,15 +1153,6 @@ L: linux-media@vger.kernel.org S: Maintained F: drivers/media/platform/s5p-g2d/ -ARM/SAMSUNG S5P SERIES FIMC SUPPORT -M: Kyungmin Park -M: Sylwester Nawrocki -L: linux-arm-kernel@lists.infradead.org -L: linux-media@vger.kernel.org -S: Maintained -F: arch/arm/plat-samsung/include/plat/*fimc* -F: drivers/media/platform/s5p-fimc/ - ARM/SAMSUNG S5P SERIES Multi Format Codec (MFC) SUPPORT M: Kyungmin Park M: Kamil Debski @@ -6965,6 +6956,15 @@ F: drivers/regulator/s5m*.c F: drivers/rtc/rtc-sec.c F: include/linux/mfd/samsung/ +SAMSUNG S5P/EXYNOS4 SOC SERIES CAMERA SUBSYSTEM DRIVERS +M: Kyungmin Park +M: Sylwester Nawrocki +L: linux-media@vger.kernel.org +Q: https://patchwork.linuxtv.org/project/linux-media/list/ +S: Supported +F: drivers/media/platform/exynos4-is/ +F: include/media/s5p_fimc.h + SAMSUNG S3C24XX/S3C64XX SOC SERIES CAMIF DRIVER M: Sylwester Nawrocki L: linux-media@vger.kernel.org From b1d2dc5c4d39d4e6c405419ad1f444bf59874111 Mon Sep 17 00:00:00 2001 From: Sylwester Nawrocki Date: Thu, 20 Jun 2013 10:57:47 -0300 Subject: [PATCH 0513/1048] [media] exynos4-is: Fix format propagation on FIMC-LITE.n subdevs FIMC-LITE subdevs have one sink pad and two source pads on which the image formats are always same. This patch implements missing format propagation from the sink pad to the source pads, to allow user space to negotiate TRY format on whole media pipeline involving FIMC-LITE.n subdevs. The subdev try_fmt helper is simplified. Signed-off-by: Sylwester Nawrocki Signed-off-by: Jacek Anaszewski Signed-off-by: Kyungmin Park Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/exynos4-is/fimc-lite.c | 92 ++++++++++++------- 1 file changed, 59 insertions(+), 33 deletions(-) diff --git a/drivers/media/platform/exynos4-is/fimc-lite.c b/drivers/media/platform/exynos4-is/fimc-lite.c index 07767c8b1c62..993bd798f3d2 100644 --- a/drivers/media/platform/exynos4-is/fimc-lite.c +++ b/drivers/media/platform/exynos4-is/fimc-lite.c @@ -560,37 +560,51 @@ static const struct v4l2_file_operations fimc_lite_fops = { * Format and crop negotiation helpers */ -static const struct fimc_fmt *fimc_lite_try_format(struct fimc_lite *fimc, - u32 *width, u32 *height, - u32 *code, u32 *fourcc, int pad) +static const struct fimc_fmt *fimc_lite_subdev_try_fmt(struct fimc_lite *fimc, + struct v4l2_subdev_fh *fh, + struct v4l2_subdev_format *format) { struct flite_drvdata *dd = fimc->dd; - const struct fimc_fmt *fmt; - unsigned int flags = 0; + struct v4l2_mbus_framefmt *mf = &format->format; + const struct fimc_fmt *fmt = NULL; - if (pad == FLITE_SD_PAD_SINK) { - v4l_bound_align_image(width, 8, dd->max_width, - ffs(dd->out_width_align) - 1, - height, 0, dd->max_height, 0, 0); + if (format->pad == FLITE_SD_PAD_SINK) { + v4l_bound_align_image(&mf->width, 8, dd->max_width, + ffs(dd->out_width_align) - 1, + &mf->height, 0, dd->max_height, 0, 0); + + fmt = fimc_lite_find_format(NULL, &mf->code, 0, 0); + if (WARN_ON(!fmt)) + return NULL; + + mf->code = fmt->mbus_code; } else { - v4l_bound_align_image(width, 8, fimc->inp_frame.rect.width, - ffs(dd->out_width_align) - 1, - height, 0, fimc->inp_frame.rect.height, - 0, 0); - flags = fimc->inp_frame.fmt->flags; + struct flite_frame *sink = &fimc->inp_frame; + struct v4l2_mbus_framefmt *sink_fmt; + struct v4l2_rect *rect; + + if (format->which == V4L2_SUBDEV_FORMAT_TRY) { + sink_fmt = v4l2_subdev_get_try_format(fh, + FLITE_SD_PAD_SINK); + + mf->code = sink_fmt->code; + + rect = v4l2_subdev_get_try_crop(fh, + FLITE_SD_PAD_SINK); + } else { + mf->code = sink->fmt->mbus_code; + rect = &sink->rect; + } + + /* Allow changing format only on sink pad */ + mf->width = rect->width; + mf->height = rect->height; } - fmt = fimc_lite_find_format(fourcc, code, flags, 0); - if (WARN_ON(!fmt)) - return NULL; + mf->field = V4L2_FIELD_NONE; - if (code) - *code = fmt->mbus_code; - if (fourcc) - *fourcc = fmt->fourcc; - - v4l2_dbg(1, debug, &fimc->subdev, "code: 0x%x, %dx%d\n", - code ? *code : 0, *width, *height); + v4l2_dbg(1, debug, &fimc->subdev, "code: %#x (%d), %dx%d\n", + mf->code, mf->colorspace, mf->width, mf->height); return fmt; } @@ -1035,6 +1049,15 @@ static int fimc_lite_subdev_enum_mbus_code(struct v4l2_subdev *sd, return 0; } +static struct v4l2_mbus_framefmt *__fimc_lite_subdev_get_try_fmt( + struct v4l2_subdev_fh *fh, unsigned int pad) +{ + if (pad != FLITE_SD_PAD_SINK) + pad = FLITE_SD_PAD_SOURCE_DMA; + + return v4l2_subdev_get_try_format(fh, pad); +} + static int fimc_lite_subdev_get_fmt(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, struct v4l2_subdev_format *fmt) @@ -1044,7 +1067,7 @@ static int fimc_lite_subdev_get_fmt(struct v4l2_subdev *sd, struct flite_frame *f = &fimc->inp_frame; if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) { - mf = v4l2_subdev_get_try_format(fh, fmt->pad); + mf = __fimc_lite_subdev_get_try_fmt(fh, fmt->pad); fmt->format = *mf; return 0; } @@ -1090,12 +1113,20 @@ static int fimc_lite_subdev_set_fmt(struct v4l2_subdev *sd, return -EBUSY; } - ffmt = fimc_lite_try_format(fimc, &mf->width, &mf->height, - &mf->code, NULL, fmt->pad); + ffmt = fimc_lite_subdev_try_fmt(fimc, fh, fmt); if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) { - mf = v4l2_subdev_get_try_format(fh, fmt->pad); + struct v4l2_mbus_framefmt *src_fmt; + + mf = __fimc_lite_subdev_get_try_fmt(fh, fmt->pad); *mf = fmt->format; + + if (fmt->pad == FLITE_SD_PAD_SINK) { + unsigned int pad = FLITE_SD_PAD_SOURCE_DMA; + src_fmt = __fimc_lite_subdev_get_try_fmt(fh, pad); + *src_fmt = *mf; + } + mutex_unlock(&fimc->lock); return 0; } @@ -1113,11 +1144,6 @@ static int fimc_lite_subdev_set_fmt(struct v4l2_subdev *sd, source->rect = sink->rect; source->f_width = mf->width; source->f_height = mf->height; - } else { - /* Allow changing format only on sink pad */ - mf->code = sink->fmt->mbus_code; - mf->width = sink->rect.width; - mf->height = sink->rect.height; } mutex_unlock(&fimc->lock); From a055d97037ad09ad9b87f6a6e74a65a44b942102 Mon Sep 17 00:00:00 2001 From: Sylwester Nawrocki Date: Tue, 18 Jun 2013 08:00:42 -0300 Subject: [PATCH 0514/1048] [media] exynos4-is: Set valid initial format at FIMC-LITE Ensure the image resolution and crop rectangle on the FIMC-LITE.n subdevs and fimc-lite.n.capture video nodes is properly configured upon the driver's initialization. Signed-off-by: Sylwester Nawrocki Signed-off-by: Kyungmin Park Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/exynos4-is/fimc-lite.c | 23 ++++++++++++++++--- drivers/media/platform/exynos4-is/fimc-lite.h | 2 ++ 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/drivers/media/platform/exynos4-is/fimc-lite.c b/drivers/media/platform/exynos4-is/fimc-lite.c index 993bd798f3d2..4fa2e05186bd 100644 --- a/drivers/media/platform/exynos4-is/fimc-lite.c +++ b/drivers/media/platform/exynos4-is/fimc-lite.c @@ -1281,9 +1281,6 @@ static int fimc_lite_subdev_registered(struct v4l2_subdev *sd) int ret; memset(vfd, 0, sizeof(*vfd)); - - fimc->inp_frame.fmt = &fimc_lite_formats[0]; - fimc->out_frame.fmt = &fimc_lite_formats[0]; atomic_set(&fimc->out_path, FIMC_IO_DMA); snprintf(vfd->name, sizeof(vfd->name), "fimc-lite.%d.capture", @@ -1399,6 +1396,23 @@ static const struct v4l2_ctrl_config fimc_lite_ctrl = { .step = 1, }; +static void fimc_lite_set_default_config(struct fimc_lite *fimc) +{ + struct flite_frame *sink = &fimc->inp_frame; + struct flite_frame *source = &fimc->out_frame; + + sink->fmt = &fimc_lite_formats[0]; + sink->f_width = FLITE_DEFAULT_WIDTH; + sink->f_height = FLITE_DEFAULT_HEIGHT; + + sink->rect.width = FLITE_DEFAULT_WIDTH; + sink->rect.height = FLITE_DEFAULT_HEIGHT; + sink->rect.left = 0; + sink->rect.top = 0; + + *source = *sink; +} + static int fimc_lite_create_capture_subdev(struct fimc_lite *fimc) { struct v4l2_ctrl_handler *handler = &fimc->ctrl_handler; @@ -1544,8 +1558,11 @@ static int fimc_lite_probe(struct platform_device *pdev) ret = PTR_ERR(fimc->alloc_ctx); goto err_pm; } + pm_runtime_put(dev); + fimc_lite_set_default_config(fimc); + dev_dbg(dev, "FIMC-LITE.%d registered successfully\n", fimc->index); return 0; diff --git a/drivers/media/platform/exynos4-is/fimc-lite.h b/drivers/media/platform/exynos4-is/fimc-lite.h index c98f3da74870..7428b2d22b52 100644 --- a/drivers/media/platform/exynos4-is/fimc-lite.h +++ b/drivers/media/platform/exynos4-is/fimc-lite.h @@ -29,6 +29,8 @@ #define FLITE_CLK_NAME "flite" #define FIMC_LITE_MAX_DEVS 3 #define FLITE_REQ_BUFS_MIN 2 +#define FLITE_DEFAULT_WIDTH 640 +#define FLITE_DEFAULT_HEIGHT 480 /* Bit index definitions for struct fimc_lite::state */ enum { From 5cfaad64d88a1bb52a6f779be02a69a2d50860fb Mon Sep 17 00:00:00 2001 From: Sylwester Nawrocki Date: Tue, 18 Jun 2013 13:42:30 -0300 Subject: [PATCH 0515/1048] [media] exynos4-is: Fix format propagation on FIMC-IS-ISP subdev Ensure TRY formats are propagated from the sink pad to the source pads of the FIMC-IS-ISP subdev and the TRY and ACTIVE formats are separated. [mchehab@redhat.com: Whitespace cleanup] Signed-off-by: Sylwester Nawrocki Signed-off-by: Kyungmin Park Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/exynos4-is/fimc-isp.c | 92 ++++++++++++++------ drivers/media/platform/exynos4-is/fimc-isp.h | 3 +- 2 files changed, 66 insertions(+), 29 deletions(-) diff --git a/drivers/media/platform/exynos4-is/fimc-isp.c b/drivers/media/platform/exynos4-is/fimc-isp.c index ecb82a9517f3..f859b3cdd409 100644 --- a/drivers/media/platform/exynos4-is/fimc-isp.c +++ b/drivers/media/platform/exynos4-is/fimc-isp.c @@ -128,31 +128,28 @@ static int fimc_isp_subdev_get_fmt(struct v4l2_subdev *sd, struct v4l2_subdev_format *fmt) { struct fimc_isp *isp = v4l2_get_subdevdata(sd); - struct fimc_is *is = fimc_isp_to_is(isp); struct v4l2_mbus_framefmt *mf = &fmt->format; - struct v4l2_mbus_framefmt cur_fmt; if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) { - mf = v4l2_subdev_get_try_format(fh, fmt->pad); - fmt->format = *mf; + *mf = *v4l2_subdev_get_try_format(fh, fmt->pad); return 0; } mf->colorspace = V4L2_COLORSPACE_SRGB; mutex_lock(&isp->subdev_lock); - __is_get_frame_size(is, &cur_fmt); if (fmt->pad == FIMC_ISP_SD_PAD_SINK) { - /* full camera input frame size */ - mf->width = cur_fmt.width + FIMC_ISP_CAC_MARGIN_WIDTH; - mf->height = cur_fmt.height + FIMC_ISP_CAC_MARGIN_HEIGHT; - mf->code = V4L2_MBUS_FMT_SGRBG10_1X10; + /* ISP OTF input image format */ + *mf = isp->sink_fmt; } else { - /* crop size */ - mf->width = cur_fmt.width; - mf->height = cur_fmt.height; - mf->code = V4L2_MBUS_FMT_YUV10_1X30; + /* ISP OTF output image format */ + *mf = isp->src_fmt; + + if (fmt->pad == FIMC_ISP_SD_PAD_SRC_FIFO) { + mf->colorspace = V4L2_COLORSPACE_JPEG; + mf->code = V4L2_MBUS_FMT_YUV10_1X30; + } } mutex_unlock(&isp->subdev_lock); @@ -164,21 +161,37 @@ static int fimc_isp_subdev_get_fmt(struct v4l2_subdev *sd, } static void __isp_subdev_try_format(struct fimc_isp *isp, - struct v4l2_subdev_format *fmt) + struct v4l2_subdev_fh *fh, + struct v4l2_subdev_format *fmt) { struct v4l2_mbus_framefmt *mf = &fmt->format; + struct v4l2_mbus_framefmt *format; + + mf->colorspace = V4L2_COLORSPACE_SRGB; if (fmt->pad == FIMC_ISP_SD_PAD_SINK) { v4l_bound_align_image(&mf->width, FIMC_ISP_SINK_WIDTH_MIN, FIMC_ISP_SINK_WIDTH_MAX, 0, &mf->height, FIMC_ISP_SINK_HEIGHT_MIN, FIMC_ISP_SINK_HEIGHT_MAX, 0, 0); - isp->subdev_fmt = *mf; + mf->code = V4L2_MBUS_FMT_SGRBG10_1X10; } else { + if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) + format = v4l2_subdev_get_try_format(fh, + FIMC_ISP_SD_PAD_SINK); + else + format = &isp->sink_fmt; + /* Allow changing format only on sink pad */ - mf->width = isp->subdev_fmt.width - FIMC_ISP_CAC_MARGIN_WIDTH; - mf->height = isp->subdev_fmt.height - FIMC_ISP_CAC_MARGIN_HEIGHT; - mf->code = isp->subdev_fmt.code; + mf->width = format->width - FIMC_ISP_CAC_MARGIN_WIDTH; + mf->height = format->height - FIMC_ISP_CAC_MARGIN_HEIGHT; + + if (fmt->pad == FIMC_ISP_SD_PAD_SRC_FIFO) { + mf->code = V4L2_MBUS_FMT_YUV10_1X30; + mf->colorspace = V4L2_COLORSPACE_JPEG; + } else { + mf->code = format->code; + } } } @@ -194,24 +207,47 @@ static int fimc_isp_subdev_set_fmt(struct v4l2_subdev *sd, isp_dbg(1, sd, "%s: pad%d: code: 0x%x, %dx%d\n", __func__, fmt->pad, mf->code, mf->width, mf->height); - mf->colorspace = V4L2_COLORSPACE_SRGB; - mutex_lock(&isp->subdev_lock); - __isp_subdev_try_format(isp, fmt); + __isp_subdev_try_format(isp, fh, fmt); if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) { mf = v4l2_subdev_get_try_format(fh, fmt->pad); *mf = fmt->format; - mutex_unlock(&isp->subdev_lock); - return 0; + + /* Propagate format to the source pads */ + if (fmt->pad == FIMC_ISP_SD_PAD_SINK) { + struct v4l2_subdev_format format = *fmt; + unsigned int pad; + + for (pad = FIMC_ISP_SD_PAD_SRC_FIFO; + pad < FIMC_ISP_SD_PADS_NUM; pad++) { + format.pad = pad; + __isp_subdev_try_format(isp, fh, &format); + mf = v4l2_subdev_get_try_format(fh, pad); + *mf = format.format; + } + } + } else { + if (sd->entity.stream_count == 0) { + if (fmt->pad == FIMC_ISP_SD_PAD_SINK) { + struct v4l2_subdev_format format = *fmt; + + isp->sink_fmt = *mf; + + format.pad = FIMC_ISP_SD_PAD_SRC_DMA; + __isp_subdev_try_format(isp, fh, &format); + + isp->src_fmt = format.format; + __is_set_frame_size(is, &isp->src_fmt); + } else { + isp->src_fmt = *mf; + } + } else { + ret = -EBUSY; + } } - if (sd->entity.stream_count == 0) - __is_set_frame_size(is, mf); - else - ret = -EBUSY; mutex_unlock(&isp->subdev_lock); - return ret; } diff --git a/drivers/media/platform/exynos4-is/fimc-isp.h b/drivers/media/platform/exynos4-is/fimc-isp.h index 756063e77fb8..03bf95ab017b 100644 --- a/drivers/media/platform/exynos4-is/fimc-isp.h +++ b/drivers/media/platform/exynos4-is/fimc-isp.h @@ -145,7 +145,8 @@ struct fimc_isp { struct vb2_alloc_ctx *alloc_ctx; struct v4l2_subdev subdev; struct media_pad subdev_pads[FIMC_ISP_SD_PADS_NUM]; - struct v4l2_mbus_framefmt subdev_fmt; + struct v4l2_mbus_framefmt src_fmt; + struct v4l2_mbus_framefmt sink_fmt; struct v4l2_ctrl *test_pattern; struct fimc_isp_ctrls ctrls; From 949457305ea602591e1fe060e6d8385a6b4a9516 Mon Sep 17 00:00:00 2001 From: Sylwester Nawrocki Date: Tue, 18 Jun 2013 14:50:50 -0300 Subject: [PATCH 0516/1048] [media] exynos4-is: Set valid initial format on FIMC-IS-ISP subdev pads Ensure there is a valid initial resolution and pixel format set at the FIMC-IS-ISP subdev pads. Signed-off-by: Sylwester Nawrocki Signed-off-by: Kyungmin Park Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/exynos4-is/fimc-isp.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/drivers/media/platform/exynos4-is/fimc-isp.c b/drivers/media/platform/exynos4-is/fimc-isp.c index f859b3cdd409..cf520a7d7f71 100644 --- a/drivers/media/platform/exynos4-is/fimc-isp.c +++ b/drivers/media/platform/exynos4-is/fimc-isp.c @@ -645,6 +645,22 @@ static const struct v4l2_ctrl_ops fimc_isp_ctrl_ops = { .s_ctrl = fimc_is_s_ctrl, }; +static void __isp_subdev_set_default_format(struct fimc_isp *isp) +{ + struct fimc_is *is = fimc_isp_to_is(isp); + + isp->sink_fmt.width = DEFAULT_PREVIEW_STILL_WIDTH + + FIMC_ISP_CAC_MARGIN_WIDTH; + isp->sink_fmt.height = DEFAULT_PREVIEW_STILL_HEIGHT + + FIMC_ISP_CAC_MARGIN_HEIGHT; + isp->sink_fmt.code = V4L2_MBUS_FMT_SGRBG10_1X10; + + isp->src_fmt.width = DEFAULT_PREVIEW_STILL_WIDTH; + isp->src_fmt.height = DEFAULT_PREVIEW_STILL_HEIGHT; + isp->src_fmt.code = V4L2_MBUS_FMT_SGRBG10_1X10; + __is_set_frame_size(is, &isp->src_fmt); +} + int fimc_isp_subdev_create(struct fimc_isp *isp) { const struct v4l2_ctrl_ops *ops = &fimc_isp_ctrl_ops; @@ -725,6 +741,8 @@ int fimc_isp_subdev_create(struct fimc_isp *isp) sd->entity.ops = &fimc_is_subdev_media_ops; v4l2_set_subdevdata(sd, isp); + __isp_subdev_set_default_format(isp); + return 0; } From 3ad8624524e5cae532381461e929bee649a92994 Mon Sep 17 00:00:00 2001 From: Sylwester Nawrocki Date: Tue, 18 Jun 2013 14:56:11 -0300 Subject: [PATCH 0517/1048] [media] exynos4-is: Set valid initial format on FIMC.n subdevs Ensure there are valid initial image formats on the FIMC.n subdev pads. Signed-off-by: Sylwester Nawrocki Signed-off-by: Kyungmin Park Signed-off-by: Mauro Carvalho Chehab --- .../media/platform/exynos4-is/fimc-capture.c | 19 +++++++++++++++++-- drivers/media/platform/exynos4-is/fimc-core.h | 2 ++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/exynos4-is/fimc-capture.c b/drivers/media/platform/exynos4-is/fimc-capture.c index 2b045b6db569..fb27ff7e1e07 100644 --- a/drivers/media/platform/exynos4-is/fimc-capture.c +++ b/drivers/media/platform/exynos4-is/fimc-capture.c @@ -1722,8 +1722,8 @@ static int fimc_capture_set_default_format(struct fimc_dev *fimc) struct v4l2_format fmt = { .type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, .fmt.pix_mp = { - .width = 640, - .height = 480, + .width = FIMC_DEFAULT_WIDTH, + .height = FIMC_DEFAULT_HEIGHT, .pixelformat = V4L2_PIX_FMT_YUYV, .field = V4L2_FIELD_NONE, .colorspace = V4L2_COLORSPACE_JPEG, @@ -1741,6 +1741,7 @@ static int fimc_register_capture_device(struct fimc_dev *fimc, struct vb2_queue *q = &fimc->vid_cap.vbq; struct fimc_ctx *ctx; struct fimc_vid_cap *vid_cap; + struct fimc_fmt *fmt; int ret = -ENOMEM; ctx = kzalloc(sizeof(*ctx), GFP_KERNEL); @@ -1788,6 +1789,20 @@ static int fimc_register_capture_device(struct fimc_dev *fimc, if (ret) goto err_free_ctx; + /* Default format configuration */ + fmt = fimc_find_format(NULL, NULL, FMT_FLAGS_CAM, 0); + vid_cap->ci_fmt.width = FIMC_DEFAULT_WIDTH; + vid_cap->ci_fmt.height = FIMC_DEFAULT_HEIGHT; + vid_cap->ci_fmt.code = fmt->mbus_code; + + ctx->s_frame.width = FIMC_DEFAULT_WIDTH; + ctx->s_frame.height = FIMC_DEFAULT_HEIGHT; + ctx->s_frame.fmt = fmt; + + fmt = fimc_find_format(NULL, NULL, FMT_FLAGS_WRITEBACK, 0); + vid_cap->wb_fmt = vid_cap->ci_fmt; + vid_cap->wb_fmt.code = fmt->mbus_code; + vid_cap->vd_pad.flags = MEDIA_PAD_FL_SINK; ret = media_entity_init(&vfd->entity, 1, &vid_cap->vd_pad, 0); if (ret) diff --git a/drivers/media/platform/exynos4-is/fimc-core.h b/drivers/media/platform/exynos4-is/fimc-core.h index 349c7c01e49a..3d376faec777 100644 --- a/drivers/media/platform/exynos4-is/fimc-core.h +++ b/drivers/media/platform/exynos4-is/fimc-core.h @@ -48,6 +48,8 @@ #define FIMC_DEF_MIN_SIZE 16 #define FIMC_DEF_HEIGHT_ALIGN 2 #define FIMC_DEF_HOR_OFFS_ALIGN 1 +#define FIMC_DEFAULT_WIDTH 640 +#define FIMC_DEFAULT_HEIGHT 480 /* indices to the clocks array */ enum { From 1c26190a8d492adadac4711fe5762d46204b18b0 Mon Sep 17 00:00:00 2001 From: Sylwester Nawrocki Date: Thu, 20 Jun 2013 10:49:09 -0300 Subject: [PATCH 0518/1048] [media] exynos4-is: Correct colorspace handling at FIMC-LITE Ensure the colorspace is properly adjusted by the driver for YUV and Bayer image formats. The subdev try_fmt helper is simplified. Signed-off-by: Sylwester Nawrocki Signed-off-by: Kyungmin Park Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/exynos4-is/fimc-lite.c | 17 +++++++++++++---- include/media/s5p_fimc.h | 2 ++ 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/drivers/media/platform/exynos4-is/fimc-lite.c b/drivers/media/platform/exynos4-is/fimc-lite.c index 4fa2e05186bd..08fbfedea90f 100644 --- a/drivers/media/platform/exynos4-is/fimc-lite.c +++ b/drivers/media/platform/exynos4-is/fimc-lite.c @@ -44,6 +44,7 @@ static const struct fimc_fmt fimc_lite_formats[] = { { .name = "YUV 4:2:2 packed, YCbYCr", .fourcc = V4L2_PIX_FMT_YUYV, + .colorspace = V4L2_COLORSPACE_JPEG, .depth = { 16 }, .color = FIMC_FMT_YCBYCR422, .memplanes = 1, @@ -52,6 +53,7 @@ static const struct fimc_fmt fimc_lite_formats[] = { }, { .name = "YUV 4:2:2 packed, CbYCrY", .fourcc = V4L2_PIX_FMT_UYVY, + .colorspace = V4L2_COLORSPACE_JPEG, .depth = { 16 }, .color = FIMC_FMT_CBYCRY422, .memplanes = 1, @@ -60,6 +62,7 @@ static const struct fimc_fmt fimc_lite_formats[] = { }, { .name = "YUV 4:2:2 packed, CrYCbY", .fourcc = V4L2_PIX_FMT_VYUY, + .colorspace = V4L2_COLORSPACE_JPEG, .depth = { 16 }, .color = FIMC_FMT_CRYCBY422, .memplanes = 1, @@ -68,6 +71,7 @@ static const struct fimc_fmt fimc_lite_formats[] = { }, { .name = "YUV 4:2:2 packed, YCrYCb", .fourcc = V4L2_PIX_FMT_YVYU, + .colorspace = V4L2_COLORSPACE_JPEG, .depth = { 16 }, .color = FIMC_FMT_YCRYCB422, .memplanes = 1, @@ -76,6 +80,7 @@ static const struct fimc_fmt fimc_lite_formats[] = { }, { .name = "RAW8 (GRBG)", .fourcc = V4L2_PIX_FMT_SGRBG8, + .colorspace = V4L2_COLORSPACE_SRGB, .depth = { 8 }, .color = FIMC_FMT_RAW8, .memplanes = 1, @@ -84,6 +89,7 @@ static const struct fimc_fmt fimc_lite_formats[] = { }, { .name = "RAW10 (GRBG)", .fourcc = V4L2_PIX_FMT_SGRBG10, + .colorspace = V4L2_COLORSPACE_SRGB, .depth = { 10 }, .color = FIMC_FMT_RAW10, .memplanes = 1, @@ -92,6 +98,7 @@ static const struct fimc_fmt fimc_lite_formats[] = { }, { .name = "RAW12 (GRBG)", .fourcc = V4L2_PIX_FMT_SGRBG12, + .colorspace = V4L2_COLORSPACE_SRGB, .depth = { 12 }, .color = FIMC_FMT_RAW12, .memplanes = 1, @@ -577,6 +584,7 @@ static const struct fimc_fmt *fimc_lite_subdev_try_fmt(struct fimc_lite *fimc, if (WARN_ON(!fmt)) return NULL; + mf->colorspace = fmt->colorspace; mf->code = fmt->mbus_code; } else { struct flite_frame *sink = &fimc->inp_frame; @@ -588,11 +596,13 @@ static const struct fimc_fmt *fimc_lite_subdev_try_fmt(struct fimc_lite *fimc, FLITE_SD_PAD_SINK); mf->code = sink_fmt->code; + mf->colorspace = sink_fmt->colorspace; rect = v4l2_subdev_get_try_crop(fh, FLITE_SD_PAD_SINK); } else { mf->code = sink->fmt->mbus_code; + mf->colorspace = sink->fmt->colorspace; rect = &sink->rect; } @@ -696,7 +706,7 @@ static int fimc_lite_g_fmt_mplane(struct file *file, void *fh, pixm->width = frame->f_width; pixm->height = frame->f_height; pixm->field = V4L2_FIELD_NONE; - pixm->colorspace = V4L2_COLORSPACE_JPEG; + pixm->colorspace = fmt->colorspace; return 0; } @@ -739,7 +749,7 @@ static int fimc_lite_try_fmt(struct fimc_lite *fimc, fmt->depth[0]) / 8; pixm->num_planes = fmt->memplanes; pixm->pixelformat = fmt->fourcc; - pixm->colorspace = V4L2_COLORSPACE_JPEG; + pixm->colorspace = fmt->colorspace; pixm->field = V4L2_FIELD_NONE; return 0; } @@ -1071,9 +1081,9 @@ static int fimc_lite_subdev_get_fmt(struct v4l2_subdev *sd, fmt->format = *mf; return 0; } - mf->colorspace = V4L2_COLORSPACE_JPEG; mutex_lock(&fimc->lock); + mf->colorspace = f->fmt->colorspace; mf->code = f->fmt->mbus_code; if (fmt->pad == FLITE_SD_PAD_SINK) { @@ -1102,7 +1112,6 @@ static int fimc_lite_subdev_set_fmt(struct v4l2_subdev *sd, v4l2_dbg(1, debug, sd, "pad%d: code: 0x%x, %dx%d\n", fmt->pad, mf->code, mf->width, mf->height); - mf->colorspace = V4L2_COLORSPACE_JPEG; mutex_lock(&fimc->lock); if ((atomic_read(&fimc->out_path) == FIMC_IO_ISP && diff --git a/include/media/s5p_fimc.h b/include/media/s5p_fimc.h index 0afadb663bbd..b975c285c8a9 100644 --- a/include/media/s5p_fimc.h +++ b/include/media/s5p_fimc.h @@ -116,6 +116,7 @@ struct s5p_platform_fimc { * @color: the driver's private color format id * @memplanes: number of physically non-contiguous data planes * @colplanes: number of physically contiguous data planes + * @colorspace: v4l2 colorspace (V4L2_COLORSPACE_*) * @depth: per plane driver's private 'number of bits per pixel' * @mdataplanes: bitmask indicating meta data plane(s), (1 << plane_no) * @flags: flags indicating which operation mode format applies to @@ -127,6 +128,7 @@ struct fimc_fmt { u32 color; u16 memplanes; u16 colplanes; + u8 colorspace; u8 depth[FIMC_MAX_PLANES]; u16 mdataplanes; u16 flags; From 94fccb78414a87f3c4bc7049ff8b6e80156944d9 Mon Sep 17 00:00:00 2001 From: Wei Yongjun Date: Tue, 18 Jun 2013 14:08:00 +0100 Subject: [PATCH 0519/1048] iio: dac: ad7303: fix error return code in ad7303_probe() Fix to return a negative error code from the error handling case instead of 0, as done elsewhere in this function. Signed-off-by: Wei Yongjun Acked-by: Lars-Peter Clausen Signed-off-by: Jonathan Cameron --- drivers/iio/dac/ad7303.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/iio/dac/ad7303.c b/drivers/iio/dac/ad7303.c index 85aeef60dc5f..d546f50f9258 100644 --- a/drivers/iio/dac/ad7303.c +++ b/drivers/iio/dac/ad7303.c @@ -235,8 +235,10 @@ static int ad7303_probe(struct spi_device *spi) if (ext_ref) { st->vref_reg = regulator_get(&spi->dev, "REF"); - if (IS_ERR(st->vref_reg)) + if (IS_ERR(st->vref_reg)) { + ret = PTR_ERR(st->vref_reg); goto err_disable_vdd_reg; + } ret = regulator_enable(st->vref_reg); if (ret) From 8bade406649245292d6fcd1947cd7ad2ad8c80c1 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sat, 22 Jun 2013 12:00:04 +0100 Subject: [PATCH 0520/1048] iio:trigger: device_unregister->device_del to avoid double free iio_trigger unregistration and freeing has been separated in this code for some time, but it looks like the calls to the device handling were not appropriately updated. Signed-off-by: Jonathan Cameron Reported-by: Otavio Salvador Tested-by: Otavio Salvador Reviewed-by: Lars-Peter Clausen --- drivers/iio/industrialio-trigger.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/industrialio-trigger.c b/drivers/iio/industrialio-trigger.c index 4d6c7d84e155..ea8a4146620d 100644 --- a/drivers/iio/industrialio-trigger.c +++ b/drivers/iio/industrialio-trigger.c @@ -104,7 +104,7 @@ void iio_trigger_unregister(struct iio_trigger *trig_info) ida_simple_remove(&iio_trigger_ida, trig_info->id); /* Possible issue in here */ - device_unregister(&trig_info->dev); + device_del(&trig_info->dev); } EXPORT_SYMBOL(iio_trigger_unregister); From f820b60582f75e73e83b8505d7e48fe59770f558 Mon Sep 17 00:00:00 2001 From: Takanari Hayama Date: Mon, 1 Jul 2013 16:38:53 +0900 Subject: [PATCH 0521/1048] ARM: shmobile: r8a73a4: Fix resources for SCIFB0 Fix base address and IRQ resources associated with SCIFB0. This bug was introduced by e481a528901d0cd18b5b5fcbdc55207ea3b6ef68 ("ARM: shmobile: r8a73a4 SCIF support V3") which was included in v3.10. Signed-off-by: Takanari Hayama Acked-by: Magnus Damm [ horms+renesas@verge.net.au: Add information about commit and version this bug was added in ] Signed-off-by: Simon Horman Cc: stable@vger.kernel.org --- arch/arm/mach-shmobile/setup-r8a73a4.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/mach-shmobile/setup-r8a73a4.c b/arch/arm/mach-shmobile/setup-r8a73a4.c index c5a75a7a508f..7f45c2edbca9 100644 --- a/arch/arm/mach-shmobile/setup-r8a73a4.c +++ b/arch/arm/mach-shmobile/setup-r8a73a4.c @@ -62,7 +62,7 @@ enum { SCIFA0, SCIFA1, SCIFB0, SCIFB1, SCIFB2, SCIFB3 }; static const struct plat_sci_port scif[] = { SCIFA_DATA(SCIFA0, 0xe6c40000, gic_spi(144)), /* SCIFA0 */ SCIFA_DATA(SCIFA1, 0xe6c50000, gic_spi(145)), /* SCIFA1 */ - SCIFB_DATA(SCIFB0, 0xe6c50000, gic_spi(145)), /* SCIFB0 */ + SCIFB_DATA(SCIFB0, 0xe6c20000, gic_spi(148)), /* SCIFB0 */ SCIFB_DATA(SCIFB1, 0xe6c30000, gic_spi(149)), /* SCIFB1 */ SCIFB_DATA(SCIFB2, 0xe6ce0000, gic_spi(150)), /* SCIFB2 */ SCIFB_DATA(SCIFB3, 0xe6cf0000, gic_spi(151)), /* SCIFB3 */ From 23df34155b29674465813b327647cd79722aa659 Mon Sep 17 00:00:00 2001 From: Markos Chandras Date: Mon, 1 Jul 2013 09:38:30 +0000 Subject: [PATCH 0522/1048] MIPS: Boot: Compressed: Remove -fstack-protector from CFLAGS When building with -fstack-protector, gcc emits the __stack_chk_guard and __stack_chk_fail symbols to check for stack stability. These symbols are defined in vmlinux but the generated vmlinux.bin that is used to create the compressed vmlinuz image has no symbol table so the linker can't find these symbols during the final linking phase. As a result of which, we need either to redefine these symbols just for the compressed image or drop the -fstack-protector option when building the compressed image. This patch implements the latter of two options. Fixes the following linking problem: dbg.c:(.text+0x7c): undefined reference to `__stack_chk_guard' dbg.c:(.text+0x80): undefined reference to `__stack_chk_guard' dbg.c:(.text+0xd4): undefined reference to `__stack_chk_guard' dbg.c:(.text+0xec): undefined reference to `__stack_chk_fail' [ralf@linux-mips.org: I'm applying this before the patch that actually adds stack protector support for MIPS. This means, it will not be possible to trigger above error message with any commit from the tree but rather they are what one would hit without this commit.] Signed-off-by: Markos Chandras Cc: linux-mips@linux-mips.org Cc: Markos Chandras Patchwork: https://patchwork.linux-mips.org/patch/5575/ Signed-off-by: Ralf Baechle --- arch/mips/boot/compressed/Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/mips/boot/compressed/Makefile b/arch/mips/boot/compressed/Makefile index bbaa1d4beb6d..bb1dbf4abb9d 100644 --- a/arch/mips/boot/compressed/Makefile +++ b/arch/mips/boot/compressed/Makefile @@ -18,6 +18,8 @@ BOOT_HEAP_SIZE := 0x400000 # Disable Function Tracer KBUILD_CFLAGS := $(shell echo $(KBUILD_CFLAGS) | sed -e "s/-pg//") +KBUILD_CFLAGS := $(filter-out -fstack-protector, $(KBUILD_CFLAGS)) + KBUILD_CFLAGS := $(LINUXINCLUDE) $(KBUILD_CFLAGS) -D__KERNEL__ \ -DBOOT_HEAP_SIZE=$(BOOT_HEAP_SIZE) -D"VMLINUX_LOAD_ADDRESS_ULL=$(VMLINUX_LOAD_ADDRESS)ull" From 36ecafc5ad17861e2bc1fb12af4cc97680e25942 Mon Sep 17 00:00:00 2001 From: Gregory Fong Date: Wed, 12 Jun 2013 17:08:54 +0000 Subject: [PATCH 0523/1048] MIPS: initial stack protector support Implements basic stack protector support based on ARM version in c743f38013aeff58ef6252601e397b5ba281c633 , with Kconfig option, constant canary value set at boot time, and script to check if compiler actually supports stack protector. Tested by creating a kernel module that writes past end of char[]. Signed-off-by: Gregory Fong Cc: linux-mips@linux-mips.org Cc: Filippo Arcidiacono Cc: Carmelo Amoroso Patchwork: https://patchwork.linux-mips.org/patch/5448/ Signed-off-by: Ralf Baechle --- arch/mips/Kconfig | 13 +++++++++ arch/mips/Makefile | 4 +++ arch/mips/include/asm/stackprotector.h | 40 ++++++++++++++++++++++++++ arch/mips/kernel/process.c | 6 ++++ 4 files changed, 63 insertions(+) create mode 100644 arch/mips/include/asm/stackprotector.h diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig index 69bf31062ca4..6dbeb273afc6 100644 --- a/arch/mips/Kconfig +++ b/arch/mips/Kconfig @@ -2367,6 +2367,19 @@ config SECCOMP If unsure, say Y. Only embedded should say N here. +config CC_STACKPROTECTOR + bool "Enable -fstack-protector buffer overflow detection (EXPERIMENTAL)" + help + This option turns on the -fstack-protector GCC feature. This + feature puts, at the beginning of functions, a canary value on + the stack just before the return address, and validates + the value just before actually returning. Stack based buffer + overflows (that need to overwrite this return address) now also + overwrite the canary, which gets detected and the attack is then + neutralized via a kernel panic. + + This feature requires gcc version 4.2 or above. + config USE_OF bool select OF diff --git a/arch/mips/Makefile b/arch/mips/Makefile index dd58a04ef4bc..37f9ef324f2f 100644 --- a/arch/mips/Makefile +++ b/arch/mips/Makefile @@ -227,6 +227,10 @@ KBUILD_CPPFLAGS += -DDATAOFFSET=$(if $(dataoffset-y),$(dataoffset-y),0) LDFLAGS += -m $(ld-emul) +ifdef CONFIG_CC_STACKPROTECTOR + KBUILD_CFLAGS += -fstack-protector +endif + ifdef CONFIG_MIPS CHECKFLAGS += $(shell $(CC) $(KBUILD_CFLAGS) -dM -E -x c /dev/null | \ egrep -vw '__GNUC_(|MINOR_|PATCHLEVEL_)_' | \ diff --git a/arch/mips/include/asm/stackprotector.h b/arch/mips/include/asm/stackprotector.h new file mode 100644 index 000000000000..eb9b1035e926 --- /dev/null +++ b/arch/mips/include/asm/stackprotector.h @@ -0,0 +1,40 @@ +/* + * GCC stack protector support. + * + * (This is directly adopted from the ARM implementation) + * + * Stack protector works by putting predefined pattern at the start of + * the stack frame and verifying that it hasn't been overwritten when + * returning from the function. The pattern is called stack canary + * and gcc expects it to be defined by a global variable called + * "__stack_chk_guard" on MIPS. This unfortunately means that on SMP + * we cannot have a different canary value per task. + */ + +#ifndef _ASM_STACKPROTECTOR_H +#define _ASM_STACKPROTECTOR_H 1 + +#include +#include + +extern unsigned long __stack_chk_guard; + +/* + * Initialize the stackprotector canary value. + * + * NOTE: this must only be called from functions that never return, + * and it must always be inlined. + */ +static __always_inline void boot_init_stack_canary(void) +{ + unsigned long canary; + + /* Try to get a semi random initial value. */ + get_random_bytes(&canary, sizeof(canary)); + canary ^= LINUX_VERSION_CODE; + + current->stack_canary = canary; + __stack_chk_guard = current->stack_canary; +} + +#endif /* _ASM_STACKPROTECTOR_H */ diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c index c6a041d9d05d..7d62894f7e23 100644 --- a/arch/mips/kernel/process.c +++ b/arch/mips/kernel/process.c @@ -201,6 +201,12 @@ int dump_task_fpu(struct task_struct *t, elf_fpregset_t *fpr) return 1; } +#ifdef CONFIG_CC_STACKPROTECTOR +#include +unsigned long __stack_chk_guard __read_mostly; +EXPORT_SYMBOL(__stack_chk_guard); +#endif + /* * */ From 1400eb656760d14274ed08e45824ccbcc366585b Mon Sep 17 00:00:00 2001 From: Gregory Fong Date: Mon, 17 Jun 2013 19:36:07 +0000 Subject: [PATCH 0524/1048] MIPS: r4k,octeon,r2300: stack protector: change canary per task For non-SMP, uses the new random canary value that is stored in the task struct whenever a new task is forked. Based on ARM version in df0698be14c6683606d5df2d83e3ae40f85ed0d9 and subject to the same limitations: the variable GCC expects, __stack_chk_guard, is global, so this will not work on SMP. Quoting Nicolas Pitre : "One way to overcome this GCC limitation would be to locate the __stack_chk_guard variable into a memory page of its own for each CPU, and then use TLB locking to have each CPU see its own page at the same virtual address for each of them." Signed-off-by: Gregory Fong Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/5488/ Signed-off-by: Ralf Baechle --- arch/mips/kernel/asm-offsets.c | 3 +++ arch/mips/kernel/octeon_switch.S | 7 +++++++ arch/mips/kernel/r2300_switch.S | 7 +++++++ arch/mips/kernel/r4k_switch.S | 6 ++++++ 4 files changed, 23 insertions(+) diff --git a/arch/mips/kernel/asm-offsets.c b/arch/mips/kernel/asm-offsets.c index 0845091ba480..0c2e853c3db4 100644 --- a/arch/mips/kernel/asm-offsets.c +++ b/arch/mips/kernel/asm-offsets.c @@ -82,6 +82,9 @@ void output_task_defines(void) OFFSET(TASK_FLAGS, task_struct, flags); OFFSET(TASK_MM, task_struct, mm); OFFSET(TASK_PID, task_struct, pid); +#if defined(CONFIG_CC_STACKPROTECTOR) + OFFSET(TASK_STACK_CANARY, task_struct, stack_canary); +#endif DEFINE(TASK_STRUCT_SIZE, sizeof(struct task_struct)); BLANK(); } diff --git a/arch/mips/kernel/octeon_switch.S b/arch/mips/kernel/octeon_switch.S index 22e2aa1e8d37..4204d76af854 100644 --- a/arch/mips/kernel/octeon_switch.S +++ b/arch/mips/kernel/octeon_switch.S @@ -71,6 +71,13 @@ mtc0 t0, $11,7 /* CvmMemCtl */ #endif 3: + +#if defined(CONFIG_CC_STACKPROTECTOR) && !defined(CONFIG_SMP) + PTR_L t8, __stack_chk_guard + LONG_L t9, TASK_STACK_CANARY(a1) + LONG_S t9, 0(t8) +#endif + /* * The order of restoring the registers takes care of the race * updating $28, $29 and kernelsp without disabling ints. diff --git a/arch/mips/kernel/r2300_switch.S b/arch/mips/kernel/r2300_switch.S index 5266c6ee2b35..38af83f84c4a 100644 --- a/arch/mips/kernel/r2300_switch.S +++ b/arch/mips/kernel/r2300_switch.S @@ -65,6 +65,13 @@ LEAF(resume) fpu_save_single a0, t0 # clobbers t0 1: + +#if defined(CONFIG_CC_STACKPROTECTOR) && !defined(CONFIG_SMP) + PTR_L t8, __stack_chk_guard + LONG_L t9, TASK_STACK_CANARY(a1) + LONG_S t9, 0(t8) +#endif + /* * The order of restoring the registers takes care of the race * updating $28, $29 and kernelsp without disabling ints. diff --git a/arch/mips/kernel/r4k_switch.S b/arch/mips/kernel/r4k_switch.S index 5e51219990aa..921238a6bd26 100644 --- a/arch/mips/kernel/r4k_switch.S +++ b/arch/mips/kernel/r4k_switch.S @@ -68,6 +68,12 @@ # clobbers t1 1: +#if defined(CONFIG_CC_STACKPROTECTOR) && !defined(CONFIG_SMP) + PTR_L t8, __stack_chk_guard + LONG_L t9, TASK_STACK_CANARY(a1) + LONG_S t9, 0(t8) +#endif + /* * The order of restoring the registers takes care of the race * updating $28, $29 and kernelsp without disabling ints. From 937ad1042572bb3641fcbbc477f5c6b137b3a5e0 Mon Sep 17 00:00:00 2001 From: Kevin Cernekee Date: Mon, 3 Jun 2013 14:39:34 +0000 Subject: [PATCH 0525/1048] MIPS: BCM63XX: Handle SW IRQs 0-1 MIPS software IRQs 0 and 1 are used for interprocessor signaling (IPI) on BMIPS SMP. Make the board support code aware of them. Signed-off-by: Kevin Cernekee [jogo@openwrt.org: move sw irqs behind timer irq] Signed-off-by: Jonas Gorski Cc: linux-mips@linux-mips.org Cc: John Crispin Cc: Maxime Bizon Cc: Florian Fainelli Patchwork: https://patchwork.linux-mips.org/patch/5354/ Signed-off-by: Ralf Baechle --- arch/mips/bcm63xx/irq.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/mips/bcm63xx/irq.c b/arch/mips/bcm63xx/irq.c index c0ab3887f42e..d744606e19e9 100644 --- a/arch/mips/bcm63xx/irq.c +++ b/arch/mips/bcm63xx/irq.c @@ -294,6 +294,10 @@ asmlinkage void plat_irq_dispatch(void) if (cause & CAUSEF_IP7) do_IRQ(7); + if (cause & CAUSEF_IP0) + do_IRQ(0); + if (cause & CAUSEF_IP1) + do_IRQ(1); if (cause & CAUSEF_IP2) dispatch_internal(); if (!is_ext_irq_cascaded) { From d6e3469832185db579e5b38fa2e0ff1b79f43886 Mon Sep 17 00:00:00 2001 From: Jonas Gorski Date: Mon, 3 Jun 2013 14:39:35 +0000 Subject: [PATCH 0526/1048] MIPS: BCM63XX: select BMIPS4350 and default to 2 CPUs for supported SoCs All BCM63XX SoCs starting with BCM6358 have a BMIPS4350 instead of a BMIPS3300, so select it unless support for any of the older SoCs is selected. All BMIPS4350 have only two CPUs, so select the appropriate default. Signed-off-by: Jonas Gorski Cc: linux-mips@linux-mips.org Cc: John Crispin Cc: Maxime Bizon Cc: Florian Fainelli Cc: Kevin Cernekee Patchwork: https://patchwork.linux-mips.org/patch/5355/ Signed-off-by: Ralf Baechle --- arch/mips/Kconfig | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig index 6dbeb273afc6..26779ccae116 100644 --- a/arch/mips/Kconfig +++ b/arch/mips/Kconfig @@ -126,6 +126,8 @@ config BCM63XX select DMA_NONCOHERENT select IRQ_CPU select SYS_HAS_CPU_MIPS32_R1 + select SYS_HAS_CPU_BMIPS4350 if !BCM63XX_CPU_6338 && !BCM63XX_CPU_6345 && !BCM63XX_CPU_6348 + select NR_CPUS_DEFAULT_2 select SYS_SUPPORTS_32BIT_KERNEL select SYS_SUPPORTS_BIG_ENDIAN select SYS_HAS_EARLY_PRINTK From 4b54f06522ed97e7870e7146840fc8169bbcdb48 Mon Sep 17 00:00:00 2001 From: Jonas Gorski Date: Sat, 15 Jun 2013 10:12:46 +0000 Subject: [PATCH 0527/1048] MIPS: remove alloc_pci_controller prototype Commit 610019baddcb4c4c323c12cd44ca7f73d7145d6f ("[MIPS] Remove unused function alloc_pci_controller.") removed the function, but left the prototype in the header file. Remove it as well so people don't get tempted to use it and wonder why it doesn't work. Signed-off-by: Jonas Gorski Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/5473/ Signed-off-by: Ralf Baechle --- arch/mips/include/asm/pci.h | 1 - 1 file changed, 1 deletion(-) diff --git a/arch/mips/include/asm/pci.h b/arch/mips/include/asm/pci.h index b8e24fd4cbc5..fa8e0aa250ca 100644 --- a/arch/mips/include/asm/pci.h +++ b/arch/mips/include/asm/pci.h @@ -52,7 +52,6 @@ struct pci_controller { /* * Used by boards to register their PCI busses before the actual scanning. */ -extern struct pci_controller * alloc_pci_controller(void); extern void register_pci_controller(struct pci_controller *hose); /* From a932fec84c633a5123b7d449a0588018678684cb Mon Sep 17 00:00:00 2001 From: Ralf Baechle Date: Tue, 18 Jun 2013 10:40:39 +0200 Subject: [PATCH 0528/1048] MIPS: Use proper include guard symbol for . Signed-off-by: Ralf Baechle --- arch/mips/include/uapi/asm/fcntl.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/mips/include/uapi/asm/fcntl.h b/arch/mips/include/uapi/asm/fcntl.h index 0bda78f70e1e..07afa6fe1e44 100644 --- a/arch/mips/include/uapi/asm/fcntl.h +++ b/arch/mips/include/uapi/asm/fcntl.h @@ -5,8 +5,8 @@ * * Copyright (C) 1995, 96, 97, 98, 99, 2003, 05 Ralf Baechle */ -#ifndef _ASM_FCNTL_H -#define _ASM_FCNTL_H +#ifndef _UAPI_ASM_FCNTL_H +#define _UAPI_ASM_FCNTL_H #define O_APPEND 0x0008 @@ -74,4 +74,4 @@ struct flock { #include -#endif /* _ASM_FCNTL_H */ +#endif /* _UAPI_ASM_FCNTL_H */ From 5a772eee5544f4f84139868f7cd05806b805610d Mon Sep 17 00:00:00 2001 From: Ralf Baechle Date: Tue, 18 Jun 2013 13:39:12 +0200 Subject: [PATCH 0529/1048] MIPS: fcntl.h: Use __kernel_off_t, not off_t. Signed-off-by: Ralf Baechle --- arch/mips/include/uapi/asm/fcntl.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/mips/include/uapi/asm/fcntl.h b/arch/mips/include/uapi/asm/fcntl.h index 07afa6fe1e44..314c79b76d2a 100644 --- a/arch/mips/include/uapi/asm/fcntl.h +++ b/arch/mips/include/uapi/asm/fcntl.h @@ -61,8 +61,8 @@ struct flock { short l_type; short l_whence; - off_t l_start; - off_t l_len; + __kernel_off_t l_start; + __kernel_off_t l_len; long l_sysid; __kernel_pid_t l_pid; long pad[4]; From 169c3c164f0dd791dfa023ab02c12cb286a72e6e Mon Sep 17 00:00:00 2001 From: Paul Gortmaker Date: Tue, 18 Jun 2013 17:01:10 +0000 Subject: [PATCH 0530/1048] MIPS: Delete Wind River ppmc eval board support. This board has been EOL for many years now; lets not burden people doing build coverage and other tree wide work with working on essentially dead files. [ralf@linux-mips.org: Also remove arch/mips/include/asm/mach-wrppmc/war.h.] Signed-off-by: Paul Gortmaker Cc: linux-mips@linux-mips.org Cc: Paul Gortmaker Patchwork: http://patchwork.linux-mips.org/patch/5503/ Signed-off-by: Ralf Baechle --- arch/mips/Kbuild.platforms | 1 - arch/mips/Kconfig | 23 ---- arch/mips/configs/wrppmc_defconfig | 97 ------------- .../include/asm/mach-wrppmc/mach-gt64120.h | 83 ------------ arch/mips/include/asm/mach-wrppmc/war.h | 24 ---- arch/mips/pci/Makefile | 1 - arch/mips/pci/fixup-wrppmc.c | 37 ----- arch/mips/wrppmc/Makefile | 12 -- arch/mips/wrppmc/Platform | 7 - arch/mips/wrppmc/irq.c | 56 -------- arch/mips/wrppmc/pci.c | 52 ------- arch/mips/wrppmc/reset.c | 41 ------ arch/mips/wrppmc/serial.c | 80 ----------- arch/mips/wrppmc/setup.c | 128 ------------------ arch/mips/wrppmc/time.c | 39 ------ 15 files changed, 681 deletions(-) delete mode 100644 arch/mips/configs/wrppmc_defconfig delete mode 100644 arch/mips/include/asm/mach-wrppmc/mach-gt64120.h delete mode 100644 arch/mips/include/asm/mach-wrppmc/war.h delete mode 100644 arch/mips/pci/fixup-wrppmc.c delete mode 100644 arch/mips/wrppmc/Makefile delete mode 100644 arch/mips/wrppmc/Platform delete mode 100644 arch/mips/wrppmc/irq.c delete mode 100644 arch/mips/wrppmc/pci.c delete mode 100644 arch/mips/wrppmc/reset.c delete mode 100644 arch/mips/wrppmc/serial.c delete mode 100644 arch/mips/wrppmc/setup.c delete mode 100644 arch/mips/wrppmc/time.c diff --git a/arch/mips/Kbuild.platforms b/arch/mips/Kbuild.platforms index 4b597d91a8d5..d9d81c219253 100644 --- a/arch/mips/Kbuild.platforms +++ b/arch/mips/Kbuild.platforms @@ -30,7 +30,6 @@ platforms += sibyte platforms += sni platforms += txx9 platforms += vr41xx -platforms += wrppmc # include the platform specific files include $(patsubst %, $(srctree)/arch/mips/%/Platform, $(platforms)) diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig index 26779ccae116..f4cc348034b7 100644 --- a/arch/mips/Kconfig +++ b/arch/mips/Kconfig @@ -712,29 +712,6 @@ config MIKROTIK_RB532 Support the Mikrotik(tm) RouterBoard 532 series, based on the IDT RC32434 SoC. -config WR_PPMC - bool "Wind River PPMC board" - select CEVT_R4K - select CSRC_R4K - select IRQ_CPU - select BOOT_ELF32 - select DMA_NONCOHERENT - select HW_HAS_PCI - select PCI_GT64XXX_PCI0 - select SWAP_IO_SPACE - select SYS_HAS_CPU_MIPS32_R1 - select SYS_HAS_CPU_MIPS32_R2 - select SYS_HAS_CPU_MIPS64_R1 - select SYS_HAS_CPU_NEVADA - select SYS_HAS_CPU_RM7000 - select SYS_SUPPORTS_32BIT_KERNEL - select SYS_SUPPORTS_64BIT_KERNEL - select SYS_SUPPORTS_BIG_ENDIAN - select SYS_SUPPORTS_LITTLE_ENDIAN - help - This enables support for the Wind River MIPS32 4KC PPMC evaluation - board, which is based on GT64120 bridge chip. - config CAVIUM_OCTEON_SOC bool "Cavium Networks Octeon SoC based boards" select CEVT_R4K diff --git a/arch/mips/configs/wrppmc_defconfig b/arch/mips/configs/wrppmc_defconfig deleted file mode 100644 index 44a451be359e..000000000000 --- a/arch/mips/configs/wrppmc_defconfig +++ /dev/null @@ -1,97 +0,0 @@ -CONFIG_WR_PPMC=y -CONFIG_HZ_1000=y -CONFIG_EXPERIMENTAL=y -# CONFIG_SWAP is not set -CONFIG_SYSVIPC=y -CONFIG_BSD_PROCESS_ACCT=y -CONFIG_LOG_BUF_SHIFT=14 -CONFIG_BLK_DEV_INITRD=y -# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set -CONFIG_EXPERT=y -CONFIG_KALLSYMS_EXTRA_PASS=y -# CONFIG_EPOLL is not set -CONFIG_SLAB=y -CONFIG_MODULES=y -CONFIG_MODULE_UNLOAD=y -CONFIG_MODVERSIONS=y -CONFIG_MODULE_SRCVERSION_ALL=y -CONFIG_PCI=y -CONFIG_HOTPLUG_PCI=y -CONFIG_BINFMT_MISC=y -CONFIG_PM=y -CONFIG_NET=y -CONFIG_PACKET=y -CONFIG_UNIX=y -CONFIG_XFRM_MIGRATE=y -CONFIG_INET=y -CONFIG_IP_MULTICAST=y -CONFIG_IP_PNP=y -CONFIG_IP_PNP_DHCP=y -CONFIG_IP_PNP_BOOTP=y -CONFIG_IP_PNP_RARP=y -CONFIG_IP_MROUTE=y -CONFIG_ARPD=y -CONFIG_INET_XFRM_MODE_TRANSPORT=m -CONFIG_INET_XFRM_MODE_TUNNEL=m -CONFIG_INET_XFRM_MODE_BEET=m -CONFIG_TCP_MD5SIG=y -# CONFIG_IPV6 is not set -CONFIG_NETWORK_SECMARK=y -CONFIG_FW_LOADER=m -CONFIG_BLK_DEV_RAM=y -CONFIG_SGI_IOC4=m -CONFIG_NETDEVICES=y -CONFIG_PHYLIB=y -CONFIG_VITESSE_PHY=m -CONFIG_SMSC_PHY=m -CONFIG_NET_ETHERNET=y -CONFIG_NET_PCI=y -CONFIG_E100=y -CONFIG_QLA3XXX=m -CONFIG_CHELSIO_T3=m -CONFIG_NETXEN_NIC=m -# CONFIG_INPUT is not set -# CONFIG_SERIO is not set -# CONFIG_VT is not set -CONFIG_SERIAL_8250=y -CONFIG_SERIAL_8250_CONSOLE=y -CONFIG_SERIAL_8250_NR_UARTS=1 -CONFIG_SERIAL_8250_RUNTIME_UARTS=1 -# CONFIG_HW_RANDOM is not set -CONFIG_PROC_KCORE=y -CONFIG_TMPFS=y -CONFIG_TMPFS_POSIX_ACL=y -CONFIG_NFS_FS=y -CONFIG_NFS_V3=y -CONFIG_ROOT_NFS=y -CONFIG_DLM=m -CONFIG_CMDLINE_BOOL=y -CONFIG_CMDLINE="console=ttyS0,115200n8" -CONFIG_CRYPTO_NULL=m -CONFIG_CRYPTO_CBC=m -CONFIG_CRYPTO_ECB=m -CONFIG_CRYPTO_LRW=m -CONFIG_CRYPTO_PCBC=m -CONFIG_CRYPTO_XCBC=m -CONFIG_CRYPTO_MD4=m -CONFIG_CRYPTO_MICHAEL_MIC=m -CONFIG_CRYPTO_SHA256=m -CONFIG_CRYPTO_SHA512=m -CONFIG_CRYPTO_TGR192=m -CONFIG_CRYPTO_WP512=m -CONFIG_CRYPTO_ANUBIS=m -CONFIG_CRYPTO_ARC4=m -CONFIG_CRYPTO_BLOWFISH=m -CONFIG_CRYPTO_CAMELLIA=m -CONFIG_CRYPTO_CAST5=m -CONFIG_CRYPTO_CAST6=m -CONFIG_CRYPTO_DES=m -CONFIG_CRYPTO_FCRYPT=m -CONFIG_CRYPTO_KHAZAD=m -CONFIG_CRYPTO_SERPENT=m -CONFIG_CRYPTO_TEA=m -CONFIG_CRYPTO_TWOFISH=m -CONFIG_CRYPTO_DEFLATE=m -CONFIG_CRC_CCITT=y -CONFIG_CRC16=y -CONFIG_LIBCRC32C=y diff --git a/arch/mips/include/asm/mach-wrppmc/mach-gt64120.h b/arch/mips/include/asm/mach-wrppmc/mach-gt64120.h deleted file mode 100644 index 00fa3684ac98..000000000000 --- a/arch/mips/include/asm/mach-wrppmc/mach-gt64120.h +++ /dev/null @@ -1,83 +0,0 @@ -/* - * This is a direct copy of the ev96100.h file, with a global - * search and replace. The numbers are the same. - * - * The reason I'm duplicating this is so that the 64120/96100 - * defines won't be confusing in the source code. - */ -#ifndef __ASM_MIPS_GT64120_H -#define __ASM_MIPS_GT64120_H - -/* - * This is the CPU physical memory map of PPMC Board: - * - * 0x00000000-0x03FFFFFF - 64MB SDRAM (SCS[0]#) - * 0x1C000000-0x1C000000 - LED (CS0) - * 0x1C800000-0x1C800007 - UART 16550 port (CS1) - * 0x1F000000-0x1F000000 - MailBox (CS3) - * 0x1FC00000-0x20000000 - 4MB Flash (BOOT CS) - */ - -#define WRPPMC_SDRAM_SCS0_BASE 0x00000000 -#define WRPPMC_SDRAM_SCS0_SIZE 0x04000000 - -#define WRPPMC_UART16550_BASE 0x1C800000 -#define WRPPMC_UART16550_CLOCK 3686400 /* 3.68MHZ */ - -#define WRPPMC_LED_BASE 0x1C000000 -#define WRPPMC_MBOX_BASE 0x1F000000 - -#define WRPPMC_BOOTROM_BASE 0x1FC00000 -#define WRPPMC_BOOTROM_SIZE 0x00400000 /* 4M Flash */ - -#define WRPPMC_MIPS_TIMER_IRQ 7 /* MIPS compare/count timer interrupt */ -#define WRPPMC_UART16550_IRQ 6 -#define WRPPMC_PCI_INTA_IRQ 3 - -/* - * PCI Bus I/O and Memory resources allocation - * - * NOTE: We only have PCI_0 hose interface - */ -#define GT_PCI_MEM_BASE 0x13000000UL -#define GT_PCI_MEM_SIZE 0x02000000UL -#define GT_PCI_IO_BASE 0x11000000UL -#define GT_PCI_IO_SIZE 0x02000000UL - -/* - * PCI interrupts will come in on either the INTA or INTD interrupt lines, - * which are mapped to the #2 and #5 interrupt pins of the MIPS. On our - * boards, they all either come in on IntD or they all come in on IntA, they - * aren't mixed. There can be numerous PCI interrupts, so we keep a list of the - * "requested" interrupt numbers and go through the list whenever we get an - * IntA/D. - * - * Interrupts < 8 are directly wired to the processor; PCI INTA is 8 and - * INTD is 11. - */ -#define GT_TIMER 4 -#define GT_INTA 2 -#define GT_INTD 5 - -#ifndef __ASSEMBLY__ - -/* - * GT64120 internal register space base address - */ -extern unsigned long gt64120_base; - -#define GT64120_BASE (gt64120_base) - -/* define WRPPMC_EARLY_DEBUG to enable early output something to UART */ -#undef WRPPMC_EARLY_DEBUG - -#ifdef WRPPMC_EARLY_DEBUG -extern void wrppmc_led_on(int mask); -extern void wrppmc_led_off(int mask); -extern void wrppmc_early_printk(const char *fmt, ...); -#else -#define wrppmc_early_printk(fmt, ...) do {} while (0) -#endif /* WRPPMC_EARLY_DEBUG */ - -#endif /* __ASSEMBLY__ */ -#endif /* __ASM_MIPS_GT64120_H */ diff --git a/arch/mips/include/asm/mach-wrppmc/war.h b/arch/mips/include/asm/mach-wrppmc/war.h deleted file mode 100644 index e86084c0bd6b..000000000000 --- a/arch/mips/include/asm/mach-wrppmc/war.h +++ /dev/null @@ -1,24 +0,0 @@ -/* - * This file is subject to the terms and conditions of the GNU General Public - * License. See the file "COPYING" in the main directory of this archive - * for more details. - * - * Copyright (C) 2002, 2004, 2007 by Ralf Baechle - */ -#ifndef __ASM_MIPS_MACH_WRPPMC_WAR_H -#define __ASM_MIPS_MACH_WRPPMC_WAR_H - -#define R4600_V1_INDEX_ICACHEOP_WAR 0 -#define R4600_V1_HIT_CACHEOP_WAR 0 -#define R4600_V2_HIT_CACHEOP_WAR 0 -#define R5432_CP0_INTERRUPT_WAR 0 -#define BCM1250_M3_WAR 0 -#define SIBYTE_1956_WAR 0 -#define MIPS4K_ICACHE_REFILL_WAR 0 -#define MIPS_CACHE_SYNC_WAR 0 -#define TX49XX_ICACHE_INDEX_INV_WAR 0 -#define ICACHE_REFILLS_WORKAROUND_WAR 1 -#define R10000_LLSC_WAR 0 -#define MIPS34K_MISSED_ITLB_WAR 0 - -#endif /* __ASM_MIPS_MACH_WRPPMC_WAR_H */ diff --git a/arch/mips/pci/Makefile b/arch/mips/pci/Makefile index fa3bcd233138..b56fbc06c60e 100644 --- a/arch/mips/pci/Makefile +++ b/arch/mips/pci/Makefile @@ -52,7 +52,6 @@ obj-$(CONFIG_TOSHIBA_RBTX4927) += fixup-rbtx4927.o obj-$(CONFIG_TOSHIBA_RBTX4938) += fixup-rbtx4938.o obj-$(CONFIG_VICTOR_MPC30X) += fixup-mpc30x.o obj-$(CONFIG_ZAO_CAPCELLA) += fixup-capcella.o -obj-$(CONFIG_WR_PPMC) += fixup-wrppmc.o obj-$(CONFIG_MIKROTIK_RB532) += pci-rc32434.o ops-rc32434.o fixup-rc32434.o obj-$(CONFIG_CAVIUM_OCTEON_SOC) += pci-octeon.o pcie-octeon.o obj-$(CONFIG_CPU_XLR) += pci-xlr.o diff --git a/arch/mips/pci/fixup-wrppmc.c b/arch/mips/pci/fixup-wrppmc.c deleted file mode 100644 index 29737edd121f..000000000000 --- a/arch/mips/pci/fixup-wrppmc.c +++ /dev/null @@ -1,37 +0,0 @@ -/* - * fixup-wrppmc.c: PPMC board specific PCI fixup - * - * This file is subject to the terms and conditions of the GNU General Public - * License. See the file "COPYING" in the main directory of this archive - * for more details. - * - * Copyright (C) 2006, Wind River Inc. Rongkai.zhan (rongkai.zhan@windriver.com) - */ -#include -#include -#include - -/* PCI interrupt pins */ -#define PCI_INTA 1 -#define PCI_INTB 2 -#define PCI_INTC 3 -#define PCI_INTD 4 - -#define PCI_SLOT_MAXNR 32 /* Each PCI bus has 32 physical slots */ - -static char pci_irq_tab[PCI_SLOT_MAXNR][5] __initdata = { - /* 0 INTA INTB INTC INTD */ - [0] = {0, 0, 0, 0, 0}, /* Slot 0: GT64120 PCI bridge */ - [6] = {0, WRPPMC_PCI_INTA_IRQ, 0, 0, 0}, -}; - -int __init pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin) -{ - return pci_irq_tab[slot][pin]; -} - -/* Do platform specific device initialization at pci_enable_device() time */ -int pcibios_plat_dev_init(struct pci_dev *dev) -{ - return 0; -} diff --git a/arch/mips/wrppmc/Makefile b/arch/mips/wrppmc/Makefile deleted file mode 100644 index 307cc6920ce6..000000000000 --- a/arch/mips/wrppmc/Makefile +++ /dev/null @@ -1,12 +0,0 @@ -# -# This file is subject to the terms and conditions of the GNU General Public -# License. See the file "COPYING" in the main directory of this archive -# for more details. -# -# Copyright 2006 Wind River System, Inc. -# Author: Rongkai.Zhan -# -# Makefile for the Wind River MIPS 4Kc PPMC Eval Board -# - -obj-y += irq.o pci.o reset.o serial.o setup.o time.o diff --git a/arch/mips/wrppmc/Platform b/arch/mips/wrppmc/Platform deleted file mode 100644 index dc78b25b95fe..000000000000 --- a/arch/mips/wrppmc/Platform +++ /dev/null @@ -1,7 +0,0 @@ -# -# Wind River PPMC Board (4KC + GT64120) -# -platform-$(CONFIG_WR_PPMC) += wrppmc/ -cflags-$(CONFIG_WR_PPMC) += \ - -I$(srctree)/arch/mips/include/asm/mach-wrppmc -load-$(CONFIG_WR_PPMC) += 0xffffffff80100000 diff --git a/arch/mips/wrppmc/irq.c b/arch/mips/wrppmc/irq.c deleted file mode 100644 index f237bf4d5c3a..000000000000 --- a/arch/mips/wrppmc/irq.c +++ /dev/null @@ -1,56 +0,0 @@ -/* - * irq.c: GT64120 Interrupt Controller - * - * Copyright (C) 2006, Wind River System Inc. - * Author: Rongkai.Zhan, - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - */ -#include -#include -#include - -#include -#include -#include - -asmlinkage void plat_irq_dispatch(void) -{ - unsigned int pending = read_c0_status() & read_c0_cause() & ST0_IM; - - if (pending & STATUSF_IP7) - do_IRQ(WRPPMC_MIPS_TIMER_IRQ); /* CPU Compare/Count internal timer */ - else if (pending & STATUSF_IP6) - do_IRQ(WRPPMC_UART16550_IRQ); /* UART 16550 port */ - else if (pending & STATUSF_IP3) - do_IRQ(WRPPMC_PCI_INTA_IRQ); /* PCI INT_A */ - else - spurious_interrupt(); -} - -/** - * Initialize GT64120 Interrupt Controller - */ -void gt64120_init_pic(void) -{ - /* clear CPU Interrupt Cause Registers */ - GT_WRITE(GT_INTRCAUSE_OFS, (0x1F << 21)); - GT_WRITE(GT_HINTRCAUSE_OFS, 0x00); - - /* Disable all interrupts from GT64120 bridge chip */ - GT_WRITE(GT_INTRMASK_OFS, 0x00); - GT_WRITE(GT_HINTRMASK_OFS, 0x00); - GT_WRITE(GT_PCI0_ICMASK_OFS, 0x00); - GT_WRITE(GT_PCI0_HICMASK_OFS, 0x00); -} - -void __init arch_init_irq(void) -{ - /* IRQ 0 - 7 are for MIPS common irq_cpu controller */ - mips_cpu_irq_init(); - - gt64120_init_pic(); -} diff --git a/arch/mips/wrppmc/pci.c b/arch/mips/wrppmc/pci.c deleted file mode 100644 index 8b8a0e1a40ca..000000000000 --- a/arch/mips/wrppmc/pci.c +++ /dev/null @@ -1,52 +0,0 @@ -/* - * pci.c: GT64120 PCI support. - * - * Copyright (C) 2006, Wind River System Inc. Rongkai.Zhan - * - * This file is subject to the terms and conditions of the GNU General Public - * License. See the file "COPYING" in the main directory of this archive - * for more details. - */ -#include -#include -#include -#include - -#include - -extern struct pci_ops gt64xxx_pci0_ops; - -static struct resource pci0_io_resource = { - .name = "pci_0 io", - .start = GT_PCI_IO_BASE, - .end = GT_PCI_IO_BASE + GT_PCI_IO_SIZE - 1, - .flags = IORESOURCE_IO, -}; - -static struct resource pci0_mem_resource = { - .name = "pci_0 memory", - .start = GT_PCI_MEM_BASE, - .end = GT_PCI_MEM_BASE + GT_PCI_MEM_SIZE - 1, - .flags = IORESOURCE_MEM, -}; - -static struct pci_controller hose_0 = { - .pci_ops = >64xxx_pci0_ops, - .io_resource = &pci0_io_resource, - .mem_resource = &pci0_mem_resource, -}; - -static int __init gt64120_pci_init(void) -{ - (void) GT_READ(GT_PCI0_CMD_OFS); /* Huh??? -- Ralf */ - (void) GT_READ(GT_PCI0_BARE_OFS); - - /* reset the whole PCI I/O space range */ - ioport_resource.start = GT_PCI_IO_BASE; - ioport_resource.end = GT_PCI_IO_BASE + GT_PCI_IO_SIZE - 1; - - register_pci_controller(&hose_0); - return 0; -} - -arch_initcall(gt64120_pci_init); diff --git a/arch/mips/wrppmc/reset.c b/arch/mips/wrppmc/reset.c deleted file mode 100644 index 80beb188ed47..000000000000 --- a/arch/mips/wrppmc/reset.c +++ /dev/null @@ -1,41 +0,0 @@ -/* - * This file is subject to the terms and conditions of the GNU General Public - * License. See the file "COPYING" in the main directory of this archive - * for more details. - * - * Copyright (C) 1997 Ralf Baechle - */ -#include -#include - -#include -#include -#include -#include - -void wrppmc_machine_restart(char *command) -{ - /* - * Ouch, we're still alive ... This time we take the silver bullet ... - * ... and find that we leave the hardware in a state in which the - * kernel in the flush locks up somewhen during of after the PCI - * detection stuff. - */ - local_irq_disable(); - set_c0_status(ST0_BEV | ST0_ERL); - change_c0_config(CONF_CM_CMASK, CONF_CM_UNCACHED); - flush_cache_all(); - write_c0_wired(0); - __asm__ __volatile__("jr\t%0"::"r"(0xbfc00000)); -} - -void wrppmc_machine_halt(void) -{ - local_irq_disable(); - - printk(KERN_NOTICE "You can safely turn off the power\n"); - while (1) { - if (cpu_wait) - cpu_wait(); - } -} diff --git a/arch/mips/wrppmc/serial.c b/arch/mips/wrppmc/serial.c deleted file mode 100644 index 83f0f7d05187..000000000000 --- a/arch/mips/wrppmc/serial.c +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Registration of WRPPMC UART platform device. - * - * Copyright (C) 2007 Yoichi Yuasa - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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 - */ -#include -#include -#include -#include -#include - -#include - -static struct resource wrppmc_uart_resource[] __initdata = { - { - .start = WRPPMC_UART16550_BASE, - .end = WRPPMC_UART16550_BASE + 7, - .flags = IORESOURCE_MEM, - }, - { - .start = WRPPMC_UART16550_IRQ, - .end = WRPPMC_UART16550_IRQ, - .flags = IORESOURCE_IRQ, - }, -}; - -static struct plat_serial8250_port wrppmc_serial8250_port[] = { - { - .irq = WRPPMC_UART16550_IRQ, - .uartclk = WRPPMC_UART16550_CLOCK, - .iotype = UPIO_MEM, - .flags = UPF_IOREMAP | UPF_SKIP_TEST, - .mapbase = WRPPMC_UART16550_BASE, - }, - {}, -}; - -static __init int wrppmc_uart_add(void) -{ - struct platform_device *pdev; - int retval; - - pdev = platform_device_alloc("serial8250", -1); - if (!pdev) - return -ENOMEM; - - pdev->id = PLAT8250_DEV_PLATFORM; - pdev->dev.platform_data = wrppmc_serial8250_port; - - retval = platform_device_add_resources(pdev, wrppmc_uart_resource, - ARRAY_SIZE(wrppmc_uart_resource)); - if (retval) - goto err_free_device; - - retval = platform_device_add(pdev); - if (retval) - goto err_free_device; - - return 0; - -err_free_device: - platform_device_put(pdev); - - return retval; -} -device_initcall(wrppmc_uart_add); diff --git a/arch/mips/wrppmc/setup.c b/arch/mips/wrppmc/setup.c deleted file mode 100644 index ca65c84031a7..000000000000 --- a/arch/mips/wrppmc/setup.c +++ /dev/null @@ -1,128 +0,0 @@ -/* - * setup.c: Setup pointers to hardware dependent routines. - * - * This file is subject to the terms and conditions of the GNU General Public - * License. See the file "COPYING" in the main directory of this archive - * for more details. - * - * Copyright (C) 1996, 1997, 2004 by Ralf Baechle (ralf@linux-mips.org) - * Copyright (C) 2006, Wind River System Inc. Rongkai.zhan - */ -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -unsigned long gt64120_base = KSEG1ADDR(0x14000000); - -#ifdef WRPPMC_EARLY_DEBUG - -static volatile unsigned char * wrppmc_led = \ - (volatile unsigned char *)KSEG1ADDR(WRPPMC_LED_BASE); - -/* - * PPMC LED control register: - * -) bit[0] controls DS1 LED (1 - OFF, 0 - ON) - * -) bit[1] controls DS2 LED (1 - OFF, 0 - ON) - * -) bit[2] controls DS4 LED (1 - OFF, 0 - ON) - */ -void wrppmc_led_on(int mask) -{ - unsigned char value = *wrppmc_led; - - value &= (0xF8 | mask); - *wrppmc_led = value; -} - -/* If mask = 0, turn off all LEDs */ -void wrppmc_led_off(int mask) -{ - unsigned char value = *wrppmc_led; - - value |= (0x7 & mask); - *wrppmc_led = value; -} - -/* - * We assume that bootloader has initialized UART16550 correctly - */ -void __init wrppmc_early_putc(char ch) -{ - static volatile unsigned char *wrppmc_uart = \ - (volatile unsigned char *)KSEG1ADDR(WRPPMC_UART16550_BASE); - unsigned char value; - - /* Wait until Transmit-Holding-Register is empty */ - while (1) { - value = *(wrppmc_uart + 5); - if (value & 0x20) - break; - } - - *wrppmc_uart = ch; -} - -void __init wrppmc_early_printk(const char *fmt, ...) -{ - static char pbuf[256] = {'\0', }; - char *ch = pbuf; - va_list args; - unsigned int i; - - memset(pbuf, 0, 256); - va_start(args, fmt); - i = vsprintf(pbuf, fmt, args); - va_end(args); - - /* Print the string */ - while (*ch != '\0') { - wrppmc_early_putc(*ch); - /* if print '\n', also print '\r' */ - if (*ch++ == '\n') - wrppmc_early_putc('\r'); - } -} -#endif /* WRPPMC_EARLY_DEBUG */ - -void __init prom_free_prom_memory(void) -{ -} - -void __init plat_mem_setup(void) -{ - extern void wrppmc_machine_restart(char *command); - extern void wrppmc_machine_halt(void); - - _machine_restart = wrppmc_machine_restart; - _machine_halt = wrppmc_machine_halt; - pm_power_off = wrppmc_machine_halt; - - /* This makes the operations of 'in/out[bwl]' to the - * physical address ( < KSEG0) can work via KSEG1 - */ - set_io_port_base(KSEG1); -} - -const char *get_system_type(void) -{ - return "Wind River PPMC (GT64120)"; -} - -/* - * Initializes basic routines and structures pointers, memory size (as - * given by the bios and saves the command line. - */ -void __init prom_init(void) -{ - add_memory_region(WRPPMC_SDRAM_SCS0_BASE, WRPPMC_SDRAM_SCS0_SIZE, BOOT_MEM_RAM); - add_memory_region(WRPPMC_BOOTROM_BASE, WRPPMC_BOOTROM_SIZE, BOOT_MEM_ROM_DATA); - - wrppmc_early_printk("prom_init: GT64120 SDRAM Bank 0: 0x%x - 0x%08lx\n", - WRPPMC_SDRAM_SCS0_BASE, (WRPPMC_SDRAM_SCS0_BASE + WRPPMC_SDRAM_SCS0_SIZE)); -} diff --git a/arch/mips/wrppmc/time.c b/arch/mips/wrppmc/time.c deleted file mode 100644 index 668dbd5f12c5..000000000000 --- a/arch/mips/wrppmc/time.c +++ /dev/null @@ -1,39 +0,0 @@ -/* - * time.c: MIPS CPU Count/Compare timer hookup - * - * Author: Mark.Zhan, - * - * This file is subject to the terms and conditions of the GNU General Public - * License. See the file "COPYING" in the main directory of this archive - * for more details. - * - * Copyright (C) 1996, 1997, 2004 by Ralf Baechle (ralf@linux-mips.org) - * Copyright (C) 2006, Wind River System Inc. - */ -#include -#include -#include - -#include -#include - -#define WRPPMC_CPU_CLK_FREQ 40000000 /* 40MHZ */ - -/* - * Estimate CPU frequency. Sets mips_hpt_frequency as a side-effect - * - * NOTE: We disable all GT64120 timers, and use MIPS processor internal - * timer as the source of kernel clock tick. - */ -void __init plat_time_init(void) -{ - /* Disable GT64120 timers */ - GT_WRITE(GT_TC_CONTROL_OFS, 0x00); - GT_WRITE(GT_TC0_OFS, 0x00); - GT_WRITE(GT_TC1_OFS, 0x00); - GT_WRITE(GT_TC2_OFS, 0x00); - GT_WRITE(GT_TC3_OFS, 0x00); - - /* Use MIPS compare/count internal timer */ - mips_hpt_frequency = WRPPMC_CPU_CLK_FREQ; -} From ae8de61c726f4f2c4b1b4d8263c9c71b82503e0d Mon Sep 17 00:00:00 2001 From: Florian Fainelli Date: Tue, 18 Jun 2013 16:55:39 +0000 Subject: [PATCH 0531/1048] MIPS: BCM63XX: select BOOT_RAW Enabling BOOT_RAW is mandatory to get a binary image (objcopy from ELF to binary) to work. This does not affect the ELF kernels which are used by CFE on BCM63XX DSL platforms, but is going to be necessary to support BCM63XX on Cable Modem chips such as BCM3368. Signed-off-by: Florian Fainelli Cc: linux-mips@linux-mips.org Cc: cernekee@gmail.com Cc: jogo@openwrt.org Patchwork: https://patchwork.linux-mips.org/patch/5500/ Signed-off-by: Ralf Baechle --- arch/mips/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig index f4cc348034b7..ba63cdbd13fe 100644 --- a/arch/mips/Kconfig +++ b/arch/mips/Kconfig @@ -121,6 +121,7 @@ config BCM47XX config BCM63XX bool "Broadcom BCM63XX based boards" + select BOOT_RAW select CEVT_R4K select CSRC_R4K select DMA_NONCOHERENT From 7b9334215f53135fb9cbdf0b44833cbc8e7d57b2 Mon Sep 17 00:00:00 2001 From: Florian Fainelli Date: Tue, 18 Jun 2013 16:55:40 +0000 Subject: [PATCH 0532/1048] MIPS: BCM63XX: add support for BCM3368 Cable Modem The Broadcom BCM3368 Cable Modem SoC is extremely similar to the existing BCM63xx DSL SoCs, in particular BCM6358, therefore little effort in the existing code base is required to get it supported. This patch adds support for the following on-chip peripherals: - two UARTS - GPIO - Ethernet - SPI - PCI - NOR Flash The most noticeable difference with 3368 is that it has its peripheral register at 0xfff8_0000 we check that separately in ioremap.h. Since 3368 is identical to 6358 for its clock and reset bits, we use them verbatim. Signed-off-by: Florian Fainelli Cc: linux-mips@linux-mips.org Cc: cernekee@gmail.com Cc: jogo@openwrt.org Patchwork: https://patchwork.linux-mips.org/patch/5499/ Signed-off-by: Ralf Baechle --- arch/mips/bcm63xx/Kconfig | 4 + arch/mips/bcm63xx/clk.c | 18 +-- arch/mips/bcm63xx/cpu.c | 28 ++++- arch/mips/bcm63xx/dev-flash.c | 1 + arch/mips/bcm63xx/dev-spi.c | 6 +- arch/mips/bcm63xx/dev-uart.c | 3 +- arch/mips/bcm63xx/irq.c | 19 +++ arch/mips/bcm63xx/prom.c | 4 +- arch/mips/bcm63xx/reset.c | 29 ++++- arch/mips/bcm63xx/setup.c | 3 + .../include/asm/mach-bcm63xx/bcm63xx_cpu.h | 110 ++++++++++++++++++ .../include/asm/mach-bcm63xx/bcm63xx_gpio.h | 1 + .../include/asm/mach-bcm63xx/bcm63xx_regs.h | 45 ++++++- arch/mips/include/asm/mach-bcm63xx/ioremap.h | 4 + arch/mips/pci/pci-bcm63xx.c | 3 +- 15 files changed, 259 insertions(+), 19 deletions(-) diff --git a/arch/mips/bcm63xx/Kconfig b/arch/mips/bcm63xx/Kconfig index 5639662fd503..afe52d4ed3b9 100644 --- a/arch/mips/bcm63xx/Kconfig +++ b/arch/mips/bcm63xx/Kconfig @@ -1,6 +1,10 @@ menu "CPU support" depends on BCM63XX +config BCM63XX_CPU_3368 + bool "support 3368 CPU" + select HW_HAS_PCI + config BCM63XX_CPU_6328 bool "support 6328 CPU" select HW_HAS_PCI diff --git a/arch/mips/bcm63xx/clk.c b/arch/mips/bcm63xx/clk.c index c726a97fc798..fda2690a8ef1 100644 --- a/arch/mips/bcm63xx/clk.c +++ b/arch/mips/bcm63xx/clk.c @@ -84,7 +84,7 @@ static void enetx_set(struct clk *clk, int enable) else clk_disable_unlocked(&clk_enet_misc); - if (BCMCPU_IS_6358()) { + if (BCMCPU_IS_3368() || BCMCPU_IS_6358()) { u32 mask; if (clk->id == 0) @@ -110,9 +110,8 @@ static struct clk clk_enet1 = { */ static void ephy_set(struct clk *clk, int enable) { - if (!BCMCPU_IS_6358()) - return; - bcm_hwclock_set(CKCTL_6358_EPHY_EN, enable); + if (BCMCPU_IS_3368() || BCMCPU_IS_6358()) + bcm_hwclock_set(CKCTL_6358_EPHY_EN, enable); } @@ -155,9 +154,10 @@ static struct clk clk_enetsw = { */ static void pcm_set(struct clk *clk, int enable) { - if (!BCMCPU_IS_6358()) - return; - bcm_hwclock_set(CKCTL_6358_PCM_EN, enable); + if (BCMCPU_IS_3368()) + bcm_hwclock_set(CKCTL_3368_PCM_EN, enable); + if (BCMCPU_IS_6358()) + bcm_hwclock_set(CKCTL_6358_PCM_EN, enable); } static struct clk clk_pcm = { @@ -211,7 +211,7 @@ static void spi_set(struct clk *clk, int enable) mask = CKCTL_6338_SPI_EN; else if (BCMCPU_IS_6348()) mask = CKCTL_6348_SPI_EN; - else if (BCMCPU_IS_6358()) + else if (BCMCPU_IS_3368() || BCMCPU_IS_6358()) mask = CKCTL_6358_SPI_EN; else if (BCMCPU_IS_6362()) mask = CKCTL_6362_SPI_EN; @@ -338,7 +338,7 @@ struct clk *clk_get(struct device *dev, const char *id) return &clk_xtm; if (!strcmp(id, "periph")) return &clk_periph; - if (BCMCPU_IS_6358() && !strcmp(id, "pcm")) + if ((BCMCPU_IS_3368() || BCMCPU_IS_6358()) && !strcmp(id, "pcm")) return &clk_pcm; if ((BCMCPU_IS_6362() || BCMCPU_IS_6368()) && !strcmp(id, "ipsec")) return &clk_ipsec; diff --git a/arch/mips/bcm63xx/cpu.c b/arch/mips/bcm63xx/cpu.c index 79fe32df5e96..7e17374a9ae8 100644 --- a/arch/mips/bcm63xx/cpu.c +++ b/arch/mips/bcm63xx/cpu.c @@ -29,6 +29,14 @@ static u8 bcm63xx_cpu_rev; static unsigned int bcm63xx_cpu_freq; static unsigned int bcm63xx_memory_size; +static const unsigned long bcm3368_regs_base[] = { + __GEN_CPU_REGS_TABLE(3368) +}; + +static const int bcm3368_irqs[] = { + __GEN_CPU_IRQ_TABLE(3368) +}; + static const unsigned long bcm6328_regs_base[] = { __GEN_CPU_REGS_TABLE(6328) }; @@ -116,6 +124,9 @@ unsigned int bcm63xx_get_memory_size(void) static unsigned int detect_cpu_clock(void) { switch (bcm63xx_get_cpu_id()) { + case BCM3368_CPU_ID: + return 300000000; + case BCM6328_CPU_ID: { unsigned int tmp, mips_pll_fcvo; @@ -266,7 +277,7 @@ static unsigned int detect_memory_size(void) banks = (val & SDRAM_CFG_BANK_MASK) ? 2 : 1; } - if (BCMCPU_IS_6358() || BCMCPU_IS_6368()) { + if (BCMCPU_IS_3368() || BCMCPU_IS_6358() || BCMCPU_IS_6368()) { val = bcm_memc_readl(MEMC_CFG_REG); rows = (val & MEMC_CFG_ROW_MASK) >> MEMC_CFG_ROW_SHIFT; cols = (val & MEMC_CFG_COL_MASK) >> MEMC_CFG_COL_SHIFT; @@ -302,10 +313,17 @@ void __init bcm63xx_cpu_init(void) chipid_reg = BCM_6345_PERF_BASE; break; case CPU_BMIPS4350: - if ((read_c0_prid() & 0xf0) == 0x10) + switch ((read_c0_prid() & 0xff)) { + case 0x04: + chipid_reg = BCM_3368_PERF_BASE; + break; + case 0x10: chipid_reg = BCM_6345_PERF_BASE; - else + break; + default: chipid_reg = BCM_6368_PERF_BASE; + break; + } break; } @@ -322,6 +340,10 @@ void __init bcm63xx_cpu_init(void) bcm63xx_cpu_rev = (tmp & REV_REVID_MASK) >> REV_REVID_SHIFT; switch (bcm63xx_cpu_id) { + case BCM3368_CPU_ID: + bcm63xx_regs_base = bcm3368_regs_base; + bcm63xx_irqs = bcm3368_irqs; + break; case BCM6328_CPU_ID: bcm63xx_regs_base = bcm6328_regs_base; bcm63xx_irqs = bcm6328_irqs; diff --git a/arch/mips/bcm63xx/dev-flash.c b/arch/mips/bcm63xx/dev-flash.c index 588d1ec622e4..172dd8397178 100644 --- a/arch/mips/bcm63xx/dev-flash.c +++ b/arch/mips/bcm63xx/dev-flash.c @@ -71,6 +71,7 @@ static int __init bcm63xx_detect_flash_type(void) case BCM6348_CPU_ID: /* no way to auto detect so assume parallel */ return BCM63XX_FLASH_TYPE_PARALLEL; + case BCM3368_CPU_ID: case BCM6358_CPU_ID: val = bcm_gpio_readl(GPIO_STRAPBUS_REG); if (val & STRAPBUS_6358_BOOT_SEL_PARALLEL) diff --git a/arch/mips/bcm63xx/dev-spi.c b/arch/mips/bcm63xx/dev-spi.c index 3065bb61820d..d12daed749bc 100644 --- a/arch/mips/bcm63xx/dev-spi.c +++ b/arch/mips/bcm63xx/dev-spi.c @@ -37,7 +37,8 @@ static __init void bcm63xx_spi_regs_init(void) { if (BCMCPU_IS_6338() || BCMCPU_IS_6348()) bcm63xx_regs_spi = bcm6348_regs_spi; - if (BCMCPU_IS_6358() || BCMCPU_IS_6362() || BCMCPU_IS_6368()) + if (BCMCPU_IS_3368() || BCMCPU_IS_6358() || + BCMCPU_IS_6362() || BCMCPU_IS_6368()) bcm63xx_regs_spi = bcm6358_regs_spi; } #else @@ -87,7 +88,8 @@ int __init bcm63xx_spi_register(void) spi_pdata.msg_ctl_width = SPI_6348_MSG_CTL_WIDTH; } - if (BCMCPU_IS_6358() || BCMCPU_IS_6362() || BCMCPU_IS_6368()) { + if (BCMCPU_IS_3368() || BCMCPU_IS_6358() || BCMCPU_IS_6362() || + BCMCPU_IS_6368()) { spi_resources[0].end += BCM_6358_RSET_SPI_SIZE - 1; spi_pdata.fifo_size = SPI_6358_MSG_DATA_SIZE; spi_pdata.msg_type_shift = SPI_6358_MSG_TYPE_SHIFT; diff --git a/arch/mips/bcm63xx/dev-uart.c b/arch/mips/bcm63xx/dev-uart.c index d6e42c608325..3bc7f3bfc9ad 100644 --- a/arch/mips/bcm63xx/dev-uart.c +++ b/arch/mips/bcm63xx/dev-uart.c @@ -54,7 +54,8 @@ int __init bcm63xx_uart_register(unsigned int id) if (id >= ARRAY_SIZE(bcm63xx_uart_devices)) return -ENODEV; - if (id == 1 && (!BCMCPU_IS_6358() && !BCMCPU_IS_6368())) + if (id == 1 && (!BCMCPU_IS_3368() && !BCMCPU_IS_6358() && + !BCMCPU_IS_6368())) return -ENODEV; if (id == 0) { diff --git a/arch/mips/bcm63xx/irq.c b/arch/mips/bcm63xx/irq.c index d744606e19e9..1525f8a3841b 100644 --- a/arch/mips/bcm63xx/irq.c +++ b/arch/mips/bcm63xx/irq.c @@ -27,6 +27,17 @@ static void __internal_irq_unmask_32(unsigned int irq) __maybe_unused; static void __internal_irq_unmask_64(unsigned int irq) __maybe_unused; #ifndef BCMCPU_RUNTIME_DETECT +#ifdef CONFIG_BCM63XX_CPU_3368 +#define irq_stat_reg PERF_IRQSTAT_3368_REG +#define irq_mask_reg PERF_IRQMASK_3368_REG +#define irq_bits 32 +#define is_ext_irq_cascaded 0 +#define ext_irq_start 0 +#define ext_irq_end 0 +#define ext_irq_count 4 +#define ext_irq_cfg_reg1 PERF_EXTIRQ_CFG_REG_3368 +#define ext_irq_cfg_reg2 0 +#endif #ifdef CONFIG_BCM63XX_CPU_6328 #define irq_stat_reg PERF_IRQSTAT_6328_REG #define irq_mask_reg PERF_IRQMASK_6328_REG @@ -140,6 +151,13 @@ static void bcm63xx_init_irq(void) irq_mask_addr = bcm63xx_regset_address(RSET_PERF); switch (bcm63xx_get_cpu_id()) { + case BCM3368_CPU_ID: + irq_stat_addr += PERF_IRQSTAT_3368_REG; + irq_mask_addr += PERF_IRQMASK_3368_REG; + irq_bits = 32; + ext_irq_count = 4; + ext_irq_cfg_reg1 = PERF_EXTIRQ_CFG_REG_3368; + break; case BCM6328_CPU_ID: irq_stat_addr += PERF_IRQSTAT_6328_REG; irq_mask_addr += PERF_IRQMASK_6328_REG; @@ -479,6 +497,7 @@ static int bcm63xx_external_irq_set_type(struct irq_data *d, reg &= ~EXTIRQ_CFG_BOTHEDGE_6348(irq); break; + case BCM3368_CPU_ID: case BCM6328_CPU_ID: case BCM6338_CPU_ID: case BCM6345_CPU_ID: diff --git a/arch/mips/bcm63xx/prom.c b/arch/mips/bcm63xx/prom.c index fd698087fbfd..f3ff28f4c258 100644 --- a/arch/mips/bcm63xx/prom.c +++ b/arch/mips/bcm63xx/prom.c @@ -26,7 +26,9 @@ void __init prom_init(void) bcm_wdt_writel(WDT_STOP_2, WDT_CTL_REG); /* disable all hardware blocks clock for now */ - if (BCMCPU_IS_6328()) + if (BCMCPU_IS_3368()) + mask = CKCTL_3368_ALL_SAFE_EN; + else if (BCMCPU_IS_6328()) mask = CKCTL_6328_ALL_SAFE_EN; else if (BCMCPU_IS_6338()) mask = CKCTL_6338_ALL_SAFE_EN; diff --git a/arch/mips/bcm63xx/reset.c b/arch/mips/bcm63xx/reset.c index 317931c6cf58..acbeb1fe7c57 100644 --- a/arch/mips/bcm63xx/reset.c +++ b/arch/mips/bcm63xx/reset.c @@ -30,6 +30,19 @@ [BCM63XX_RESET_PCIE] = BCM## __cpu ##_RESET_PCIE, \ [BCM63XX_RESET_PCIE_EXT] = BCM## __cpu ##_RESET_PCIE_EXT, +#define BCM3368_RESET_SPI SOFTRESET_3368_SPI_MASK +#define BCM3368_RESET_ENET SOFTRESET_3368_ENET_MASK +#define BCM3368_RESET_USBH 0 +#define BCM3368_RESET_USBD SOFTRESET_3368_USBS_MASK +#define BCM3368_RESET_DSL 0 +#define BCM3368_RESET_SAR 0 +#define BCM3368_RESET_EPHY SOFTRESET_3368_EPHY_MASK +#define BCM3368_RESET_ENETSW 0 +#define BCM3368_RESET_PCM SOFTRESET_3368_PCM_MASK +#define BCM3368_RESET_MPI SOFTRESET_3368_MPI_MASK +#define BCM3368_RESET_PCIE 0 +#define BCM3368_RESET_PCIE_EXT 0 + #define BCM6328_RESET_SPI SOFTRESET_6328_SPI_MASK #define BCM6328_RESET_ENET 0 #define BCM6328_RESET_USBH SOFTRESET_6328_USBH_MASK @@ -117,6 +130,10 @@ /* * core reset bits */ +static const u32 bcm3368_reset_bits[] = { + __GEN_RESET_BITS_TABLE(3368) +}; + static const u32 bcm6328_reset_bits[] = { __GEN_RESET_BITS_TABLE(6328) }; @@ -146,7 +163,10 @@ static int reset_reg; static int __init bcm63xx_reset_bits_init(void) { - if (BCMCPU_IS_6328()) { + if (BCMCPU_IS_3368()) { + reset_reg = PERF_SOFTRESET_6358_REG; + bcm63xx_reset_bits = bcm3368_reset_bits; + } else if (BCMCPU_IS_6328()) { reset_reg = PERF_SOFTRESET_6328_REG; bcm63xx_reset_bits = bcm6328_reset_bits; } else if (BCMCPU_IS_6338()) { @@ -170,6 +190,13 @@ static int __init bcm63xx_reset_bits_init(void) } #else +#ifdef CONFIG_BCM63XX_CPU_3368 +static const u32 bcm63xx_reset_bits[] = { + __GEN_RESET_BITS_TABLE(3368) +}; +#define reset_reg PERF_SOFTRESET_6358_REG +#endif + #ifdef CONFIG_BCM63XX_CPU_6328 static const u32 bcm63xx_reset_bits[] = { __GEN_RESET_BITS_TABLE(6328) diff --git a/arch/mips/bcm63xx/setup.c b/arch/mips/bcm63xx/setup.c index 24a24445db64..6660c7ddf87b 100644 --- a/arch/mips/bcm63xx/setup.c +++ b/arch/mips/bcm63xx/setup.c @@ -68,6 +68,9 @@ void bcm63xx_machine_reboot(void) /* mask and clear all external irq */ switch (bcm63xx_get_cpu_id()) { + case BCM3368_CPU_ID: + perf_regs[0] = PERF_EXTIRQ_CFG_REG_3368; + break; case BCM6328_CPU_ID: perf_regs[0] = PERF_EXTIRQ_CFG_REG_6328; break; diff --git a/arch/mips/include/asm/mach-bcm63xx/bcm63xx_cpu.h b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_cpu.h index 336228990808..9d3c08e4a7e4 100644 --- a/arch/mips/include/asm/mach-bcm63xx/bcm63xx_cpu.h +++ b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_cpu.h @@ -9,6 +9,7 @@ * compile time if only one CPU support is enabled (idea stolen from * arm mach-types) */ +#define BCM3368_CPU_ID 0x3368 #define BCM6328_CPU_ID 0x6328 #define BCM6338_CPU_ID 0x6338 #define BCM6345_CPU_ID 0x6345 @@ -22,6 +23,19 @@ u16 __bcm63xx_get_cpu_id(void); u8 bcm63xx_get_cpu_rev(void); unsigned int bcm63xx_get_cpu_freq(void); +#ifdef CONFIG_BCM63XX_CPU_3368 +# ifdef bcm63xx_get_cpu_id +# undef bcm63xx_get_cpu_id +# define bcm63xx_get_cpu_id() __bcm63xx_get_cpu_id() +# define BCMCPU_RUNTIME_DETECT +# else +# define bcm63xx_get_cpu_id() BCM3368_CPU_ID +# endif +# define BCMCPU_IS_3368() (bcm63xx_get_cpu_id() == BCM3368_CPU_ID) +#else +# define BCMCPU_IS_3368() (0) +#endif + #ifdef CONFIG_BCM63XX_CPU_6328 # ifdef bcm63xx_get_cpu_id # undef bcm63xx_get_cpu_id @@ -190,6 +204,53 @@ enum bcm63xx_regs_set { #define RSET_XTMDMAS_SIZE(chans) (16 * (chans)) #define RSET_RNG_SIZE 20 +/* + * 3368 register sets base address + */ +#define BCM_3368_DSL_LMEM_BASE (0xdeadbeef) +#define BCM_3368_PERF_BASE (0xfff8c000) +#define BCM_3368_TIMER_BASE (0xfff8c040) +#define BCM_3368_WDT_BASE (0xfff8c080) +#define BCM_3368_UART0_BASE (0xfff8c100) +#define BCM_3368_UART1_BASE (0xfff8c120) +#define BCM_3368_GPIO_BASE (0xfff8c080) +#define BCM_3368_SPI_BASE (0xfff8c800) +#define BCM_3368_HSSPI_BASE (0xdeadbeef) +#define BCM_3368_UDC0_BASE (0xdeadbeef) +#define BCM_3368_USBDMA_BASE (0xdeadbeef) +#define BCM_3368_OHCI0_BASE (0xdeadbeef) +#define BCM_3368_OHCI_PRIV_BASE (0xdeadbeef) +#define BCM_3368_USBH_PRIV_BASE (0xdeadbeef) +#define BCM_3368_USBD_BASE (0xdeadbeef) +#define BCM_3368_MPI_BASE (0xfff80000) +#define BCM_3368_PCMCIA_BASE (0xfff80054) +#define BCM_3368_PCIE_BASE (0xdeadbeef) +#define BCM_3368_SDRAM_REGS_BASE (0xdeadbeef) +#define BCM_3368_DSL_BASE (0xdeadbeef) +#define BCM_3368_UBUS_BASE (0xdeadbeef) +#define BCM_3368_ENET0_BASE (0xfff98000) +#define BCM_3368_ENET1_BASE (0xfff98800) +#define BCM_3368_ENETDMA_BASE (0xfff99800) +#define BCM_3368_ENETDMAC_BASE (0xfff99900) +#define BCM_3368_ENETDMAS_BASE (0xfff99a00) +#define BCM_3368_ENETSW_BASE (0xdeadbeef) +#define BCM_3368_EHCI0_BASE (0xdeadbeef) +#define BCM_3368_SDRAM_BASE (0xdeadbeef) +#define BCM_3368_MEMC_BASE (0xfff84000) +#define BCM_3368_DDR_BASE (0xdeadbeef) +#define BCM_3368_M2M_BASE (0xdeadbeef) +#define BCM_3368_ATM_BASE (0xdeadbeef) +#define BCM_3368_XTM_BASE (0xdeadbeef) +#define BCM_3368_XTMDMA_BASE (0xdeadbeef) +#define BCM_3368_XTMDMAC_BASE (0xdeadbeef) +#define BCM_3368_XTMDMAS_BASE (0xdeadbeef) +#define BCM_3368_PCM_BASE (0xfff9c200) +#define BCM_3368_PCMDMA_BASE (0xdeadbeef) +#define BCM_3368_PCMDMAC_BASE (0xdeadbeef) +#define BCM_3368_PCMDMAS_BASE (0xdeadbeef) +#define BCM_3368_RNG_BASE (0xdeadbeef) +#define BCM_3368_MISC_BASE (0xdeadbeef) + /* * 6328 register sets base address */ @@ -620,6 +681,9 @@ static inline unsigned long bcm63xx_regset_address(enum bcm63xx_regs_set set) #ifdef BCMCPU_RUNTIME_DETECT return bcm63xx_regs_base[set]; #else +#ifdef CONFIG_BCM63XX_CPU_3368 + __GEN_RSET(3368) +#endif #ifdef CONFIG_BCM63XX_CPU_6328 __GEN_RSET(6328) #endif @@ -686,6 +750,52 @@ enum bcm63xx_irq { IRQ_XTM_DMA0, }; +/* + * 3368 irqs + */ +#define BCM_3368_TIMER_IRQ (IRQ_INTERNAL_BASE + 0) +#define BCM_3368_SPI_IRQ (IRQ_INTERNAL_BASE + 1) +#define BCM_3368_UART0_IRQ (IRQ_INTERNAL_BASE + 2) +#define BCM_3368_UART1_IRQ (IRQ_INTERNAL_BASE + 3) +#define BCM_3368_DSL_IRQ 0 +#define BCM_3368_UDC0_IRQ 0 +#define BCM_3368_OHCI0_IRQ 0 +#define BCM_3368_ENET0_IRQ (IRQ_INTERNAL_BASE + 8) +#define BCM_3368_ENET1_IRQ (IRQ_INTERNAL_BASE + 6) +#define BCM_3368_ENET_PHY_IRQ (IRQ_INTERNAL_BASE + 9) +#define BCM_3368_ENET0_RXDMA_IRQ (IRQ_INTERNAL_BASE + 15) +#define BCM_3368_ENET0_TXDMA_IRQ (IRQ_INTERNAL_BASE + 16) +#define BCM_3368_HSSPI_IRQ 0 +#define BCM_3368_EHCI0_IRQ 0 +#define BCM_3368_USBD_IRQ 0 +#define BCM_3368_USBD_RXDMA0_IRQ 0 +#define BCM_3368_USBD_TXDMA0_IRQ 0 +#define BCM_3368_USBD_RXDMA1_IRQ 0 +#define BCM_3368_USBD_TXDMA1_IRQ 0 +#define BCM_3368_USBD_RXDMA2_IRQ 0 +#define BCM_3368_USBD_TXDMA2_IRQ 0 +#define BCM_3368_ENET1_RXDMA_IRQ (IRQ_INTERNAL_BASE + 17) +#define BCM_3368_ENET1_TXDMA_IRQ (IRQ_INTERNAL_BASE + 18) +#define BCM_3368_PCI_IRQ (IRQ_INTERNAL_BASE + 31) +#define BCM_3368_PCMCIA_IRQ 0 +#define BCM_3368_ATM_IRQ 0 +#define BCM_3368_ENETSW_RXDMA0_IRQ 0 +#define BCM_3368_ENETSW_RXDMA1_IRQ 0 +#define BCM_3368_ENETSW_RXDMA2_IRQ 0 +#define BCM_3368_ENETSW_RXDMA3_IRQ 0 +#define BCM_3368_ENETSW_TXDMA0_IRQ 0 +#define BCM_3368_ENETSW_TXDMA1_IRQ 0 +#define BCM_3368_ENETSW_TXDMA2_IRQ 0 +#define BCM_3368_ENETSW_TXDMA3_IRQ 0 +#define BCM_3368_XTM_IRQ 0 +#define BCM_3368_XTM_DMA0_IRQ 0 + +#define BCM_3368_EXT_IRQ0 (IRQ_INTERNAL_BASE + 25) +#define BCM_3368_EXT_IRQ1 (IRQ_INTERNAL_BASE + 26) +#define BCM_3368_EXT_IRQ2 (IRQ_INTERNAL_BASE + 27) +#define BCM_3368_EXT_IRQ3 (IRQ_INTERNAL_BASE + 28) + + /* * 6328 irqs */ diff --git a/arch/mips/include/asm/mach-bcm63xx/bcm63xx_gpio.h b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_gpio.h index 35baa1a60a64..565ff36a1119 100644 --- a/arch/mips/include/asm/mach-bcm63xx/bcm63xx_gpio.h +++ b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_gpio.h @@ -11,6 +11,7 @@ static inline unsigned long bcm63xx_gpio_count(void) switch (bcm63xx_get_cpu_id()) { case BCM6328_CPU_ID: return 32; + case BCM3368_CPU_ID: case BCM6358_CPU_ID: return 40; case BCM6338_CPU_ID: diff --git a/arch/mips/include/asm/mach-bcm63xx/bcm63xx_regs.h b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_regs.h index 3203fe49b34d..654213746b32 100644 --- a/arch/mips/include/asm/mach-bcm63xx/bcm63xx_regs.h +++ b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_regs.h @@ -15,6 +15,39 @@ /* Clock Control register */ #define PERF_CKCTL_REG 0x4 +#define CKCTL_3368_MAC_EN (1 << 3) +#define CKCTL_3368_TC_EN (1 << 5) +#define CKCTL_3368_US_TOP_EN (1 << 6) +#define CKCTL_3368_DS_TOP_EN (1 << 7) +#define CKCTL_3368_APM_EN (1 << 8) +#define CKCTL_3368_SPI_EN (1 << 9) +#define CKCTL_3368_USBS_EN (1 << 10) +#define CKCTL_3368_BMU_EN (1 << 11) +#define CKCTL_3368_PCM_EN (1 << 12) +#define CKCTL_3368_NTP_EN (1 << 13) +#define CKCTL_3368_ACP_B_EN (1 << 14) +#define CKCTL_3368_ACP_A_EN (1 << 15) +#define CKCTL_3368_EMUSB_EN (1 << 17) +#define CKCTL_3368_ENET0_EN (1 << 18) +#define CKCTL_3368_ENET1_EN (1 << 19) +#define CKCTL_3368_USBU_EN (1 << 20) +#define CKCTL_3368_EPHY_EN (1 << 21) + +#define CKCTL_3368_ALL_SAFE_EN (CKCTL_3368_MAC_EN | \ + CKCTL_3368_TC_EN | \ + CKCTL_3368_US_TOP_EN | \ + CKCTL_3368_DS_TOP_EN | \ + CKCTL_3368_APM_EN | \ + CKCTL_3368_SPI_EN | \ + CKCTL_3368_USBS_EN | \ + CKCTL_3368_BMU_EN | \ + CKCTL_3368_PCM_EN | \ + CKCTL_3368_NTP_EN | \ + CKCTL_3368_ACP_B_EN | \ + CKCTL_3368_ACP_A_EN | \ + CKCTL_3368_EMUSB_EN | \ + CKCTL_3368_USBU_EN) + #define CKCTL_6328_PHYMIPS_EN (1 << 0) #define CKCTL_6328_ADSL_QPROC_EN (1 << 1) #define CKCTL_6328_ADSL_AFE_EN (1 << 2) @@ -181,6 +214,7 @@ #define SYS_PLL_SOFT_RESET 0x1 /* Interrupt Mask register */ +#define PERF_IRQMASK_3368_REG 0xc #define PERF_IRQMASK_6328_REG 0x20 #define PERF_IRQMASK_6338_REG 0xc #define PERF_IRQMASK_6345_REG 0xc @@ -190,6 +224,7 @@ #define PERF_IRQMASK_6368_REG 0x20 /* Interrupt Status register */ +#define PERF_IRQSTAT_3368_REG 0x10 #define PERF_IRQSTAT_6328_REG 0x28 #define PERF_IRQSTAT_6338_REG 0x10 #define PERF_IRQSTAT_6345_REG 0x10 @@ -199,6 +234,7 @@ #define PERF_IRQSTAT_6368_REG 0x28 /* External Interrupt Configuration register */ +#define PERF_EXTIRQ_CFG_REG_3368 0x14 #define PERF_EXTIRQ_CFG_REG_6328 0x18 #define PERF_EXTIRQ_CFG_REG_6338 0x14 #define PERF_EXTIRQ_CFG_REG_6345 0x14 @@ -236,6 +272,13 @@ #define PERF_SOFTRESET_6362_REG 0x10 #define PERF_SOFTRESET_6368_REG 0x10 +#define SOFTRESET_3368_SPI_MASK (1 << 0) +#define SOFTRESET_3368_ENET_MASK (1 << 2) +#define SOFTRESET_3368_MPI_MASK (1 << 3) +#define SOFTRESET_3368_EPHY_MASK (1 << 6) +#define SOFTRESET_3368_USBS_MASK (1 << 11) +#define SOFTRESET_3368_PCM_MASK (1 << 13) + #define SOFTRESET_6328_SPI_MASK (1 << 0) #define SOFTRESET_6328_EPHY_MASK (1 << 1) #define SOFTRESET_6328_SAR_MASK (1 << 2) @@ -1293,7 +1336,7 @@ #define SPI_6348_RX_DATA 0x80 #define SPI_6348_RX_DATA_SIZE 0x3f -/* BCM 6358/6262/6368 SPI core */ +/* BCM 3368/6358/6262/6368 SPI core */ #define SPI_6358_MSG_CTL 0x00 /* 16-bits register */ #define SPI_6358_MSG_CTL_WIDTH 16 #define SPI_6358_MSG_DATA 0x02 diff --git a/arch/mips/include/asm/mach-bcm63xx/ioremap.h b/arch/mips/include/asm/mach-bcm63xx/ioremap.h index 94e3011ba7df..ff15e3b14e7a 100644 --- a/arch/mips/include/asm/mach-bcm63xx/ioremap.h +++ b/arch/mips/include/asm/mach-bcm63xx/ioremap.h @@ -11,6 +11,10 @@ static inline phys_t fixup_bigphys_addr(phys_t phys_addr, phys_t size) static inline int is_bcm63xx_internal_registers(phys_t offset) { switch (bcm63xx_get_cpu_id()) { + case BCM3368_CPU_ID: + if (offset >= 0xfff80000) + return 1; + break; case BCM6338_CPU_ID: case BCM6345_CPU_ID: case BCM6348_CPU_ID: diff --git a/arch/mips/pci/pci-bcm63xx.c b/arch/mips/pci/pci-bcm63xx.c index 2eb954239bc5..151d9b5870bb 100644 --- a/arch/mips/pci/pci-bcm63xx.c +++ b/arch/mips/pci/pci-bcm63xx.c @@ -266,7 +266,7 @@ static int __init bcm63xx_register_pci(void) /* setup PCI to local bus access, used by PCI device to target * local RAM while bus mastering */ bcm63xx_int_cfg_writel(0, PCI_BASE_ADDRESS_3); - if (BCMCPU_IS_6358() || BCMCPU_IS_6368()) + if (BCMCPU_IS_3368() || BCMCPU_IS_6358() || BCMCPU_IS_6368()) val = MPI_SP0_REMAP_ENABLE_MASK; else val = 0; @@ -338,6 +338,7 @@ static int __init bcm63xx_pci_init(void) case BCM6328_CPU_ID: case BCM6362_CPU_ID: return bcm63xx_register_pcie(); + case BCM3368_CPU_ID: case BCM6348_CPU_ID: case BCM6358_CPU_ID: case BCM6368_CPU_ID: From d753601a2a5ff67bbc96ce6512a16305bfd293e7 Mon Sep 17 00:00:00 2001 From: Florian Fainelli Date: Tue, 18 Jun 2013 16:55:41 +0000 Subject: [PATCH 0533/1048] MIPS: BCM63XX: recognize Cable Modem firmware format Add the firmware header format which is used by Broadcom Cable Modem SoCs such as the BCM3368 SoC. We export the bcm_hcs firmware format structure because it is used by user-land tools to create firmware images for these SoCs and will later be used by a corresponding MTD parser. Signed-off-by: Florian Fainelli Cc: linux-mips@linux-mips.org Cc: cernekee@gmail.com Cc: jogo@openwrt.org Patchwork: https://patchwork.linux-mips.org/patch/5496/ Signed-off-by: Ralf Baechle --- arch/mips/bcm63xx/boards/board_bcm963xx.c | 14 +++++++++++-- include/uapi/linux/Kbuild | 1 + include/uapi/linux/bcm933xx_hcs.h | 24 +++++++++++++++++++++++ 3 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 include/uapi/linux/bcm933xx_hcs.h diff --git a/arch/mips/bcm63xx/boards/board_bcm963xx.c b/arch/mips/bcm63xx/boards/board_bcm963xx.c index a9505c4867e8..46eabb9aff51 100644 --- a/arch/mips/bcm63xx/boards/board_bcm963xx.c +++ b/arch/mips/bcm63xx/boards/board_bcm963xx.c @@ -28,8 +28,12 @@ #include #include +#include + #define PFX "board_bcm963xx: " +#define HCS_OFFSET_128K 0x20000 + static struct board_info board; /* @@ -722,8 +726,9 @@ void __init board_prom_init(void) unsigned int i; u8 *boot_addr, *cfe; char cfe_version[32]; - char *board_name; + char *board_name = NULL; u32 val; + struct bcm_hcs *hcs; /* read base address of boot chip select (0) * 6328/6362 do not have MPI but boot from a fixed address @@ -747,7 +752,12 @@ void __init board_prom_init(void) bcm63xx_nvram_init(boot_addr + BCM963XX_NVRAM_OFFSET); - board_name = bcm63xx_nvram_get_name(); + if (BCMCPU_IS_3368()) { + hcs = (struct bcm_hcs *)boot_addr; + board_name = hcs->filename; + } else { + board_name = bcm63xx_nvram_get_name(); + } /* find board by name */ for (i = 0; i < ARRAY_SIZE(bcm963xx_boards); i++) { if (strncmp(board_name, bcm963xx_boards[i]->name, 16)) diff --git a/include/uapi/linux/Kbuild b/include/uapi/linux/Kbuild index ab5d4992e568..ba1c11ab0d11 100644 --- a/include/uapi/linux/Kbuild +++ b/include/uapi/linux/Kbuild @@ -62,6 +62,7 @@ header-y += auxvec.h header-y += ax25.h header-y += b1lli.h header-y += baycom.h +header-y += bcm933xx_hcs.h header-y += bfs_fs.h header-y += binfmts.h header-y += blkpg.h diff --git a/include/uapi/linux/bcm933xx_hcs.h b/include/uapi/linux/bcm933xx_hcs.h new file mode 100644 index 000000000000..d22821831549 --- /dev/null +++ b/include/uapi/linux/bcm933xx_hcs.h @@ -0,0 +1,24 @@ +/* + * Broadcom Cable Modem firmware format + */ + +#ifndef __BCM933XX_HCS_H +#define __BCM933XX_HCS_H + +#include + +struct bcm_hcs { + __u16 magic; + __u16 control; + __u16 rev_maj; + __u16 rev_min; + __u32 build_date; + __u32 filelen; + __u32 ldaddress; + char filename[64]; + __u16 hcs; + __u16 her_znaet_chto; + __u32 crc; +}; + +#endif /* __BCM933XX_HCS */ From 0680dc866d10806c85c40b54bbf8cf5be61206d1 Mon Sep 17 00:00:00 2001 From: Florian Fainelli Date: Tue, 18 Jun 2013 16:55:42 +0000 Subject: [PATCH 0534/1048] MIPS: BCM63XX: provide a MAC address for BCM3368 chips The BCM3368 SoC uses a NVRAM format which is not compatible with the one used by CFE, provide a default MAC address which is suitable for use and which is the default one also being used by the bootloader on these chips. Signed-off-by: Florian Fainelli Cc: linux-mips@linux-mips.org Cc: cernekee@gmail.com Cc: jogo@openwrt.org Patchwork: https://patchwork.linux-mips.org/patch/5498/ Signed-off-by: Ralf Baechle --- arch/mips/bcm63xx/nvram.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/arch/mips/bcm63xx/nvram.c b/arch/mips/bcm63xx/nvram.c index a4b8864f9307..e652e578a679 100644 --- a/arch/mips/bcm63xx/nvram.c +++ b/arch/mips/bcm63xx/nvram.c @@ -42,6 +42,7 @@ void __init bcm63xx_nvram_init(void *addr) { unsigned int check_len; u32 crc, expected_crc; + u8 hcs_mac_addr[ETH_ALEN] = { 0x00, 0x10, 0x18, 0xff, 0xff, 0xff }; /* extract nvram data */ memcpy(&nvram, addr, sizeof(nvram)); @@ -62,6 +63,15 @@ void __init bcm63xx_nvram_init(void *addr) if (crc != expected_crc) pr_warn("nvram checksum failed, contents may be invalid (expected %08x, got %08x)\n", expected_crc, crc); + + /* Cable modems have a different NVRAM which is embedded in the eCos + * firmware and not easily extractible, give at least a MAC address + * pool. + */ + if (BCMCPU_IS_3368()) { + memcpy(nvram.mac_addr_base, hcs_mac_addr, ETH_ALEN); + nvram.mac_addr_count = 2; + } } u8 *bcm63xx_nvram_get_name(void) From 0b35f0c59a601a88ec8c08ebab0b5a733c8de79f Mon Sep 17 00:00:00 2001 From: Florian Fainelli Date: Tue, 18 Jun 2013 16:55:43 +0000 Subject: [PATCH 0535/1048] MIPS: BCM63XX: let board specify an external GPIO to reset PHY Some boards may need to reset their external PHY or switch they are attached to, add a hook for doing this along with providing custom linux/gpio.h flags for doing this. Signed-off-by: Florian Fainelli Cc: linux-mips@linux-mips.org Cc: cernekee@gmail.com Cc: jogo@openwrt.org Cc: Florian Fainelli Patchwork: https://patchwork.linux-mips.org/patch/5501/ Signed-off-by: Ralf Baechle --- arch/mips/bcm63xx/boards/board_bcm963xx.c | 4 ++++ arch/mips/include/asm/mach-bcm63xx/board_bcm963xx.h | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/arch/mips/bcm63xx/boards/board_bcm963xx.c b/arch/mips/bcm63xx/boards/board_bcm963xx.c index 46eabb9aff51..611a420dbfdd 100644 --- a/arch/mips/bcm63xx/boards/board_bcm963xx.c +++ b/arch/mips/bcm63xx/boards/board_bcm963xx.c @@ -883,5 +883,9 @@ int __init board_register_devices(void) platform_device_register(&bcm63xx_gpio_leds); + if (board.ephy_reset_gpio && board.ephy_reset_gpio_flags) + gpio_request_one(board.ephy_reset_gpio, + board.ephy_reset_gpio_flags, "ephy-reset"); + return 0; } diff --git a/arch/mips/include/asm/mach-bcm63xx/board_bcm963xx.h b/arch/mips/include/asm/mach-bcm63xx/board_bcm963xx.h index 682bcf3b492a..5981fe0c3dfb 100644 --- a/arch/mips/include/asm/mach-bcm63xx/board_bcm963xx.h +++ b/arch/mips/include/asm/mach-bcm63xx/board_bcm963xx.h @@ -45,6 +45,12 @@ struct board_info { /* GPIO LEDs */ struct gpio_led leds[5]; + + /* External PHY reset GPIO */ + unsigned int ephy_reset_gpio; + + /* External PHY reset GPIO flags from gpio.h */ + unsigned long ephy_reset_gpio_flags; }; #endif /* ! BOARD_BCM963XX_H_ */ From 450acb0b120ebcdc7d2ea6888b5302a6a5a12420 Mon Sep 17 00:00:00 2001 From: Florian Fainelli Date: Tue, 18 Jun 2013 16:55:44 +0000 Subject: [PATCH 0536/1048] MIPS: BCM63XX: add support for the Netgear CVG834G Add support for the Netgear CVG834G and enable the two UARTs, Ethernet on the first MAC, PCI and the two leds. Signed-off-by: Florian Fainelli Cc: linux-mips@linux-mips.org Cc: cernekee@gmail.com Cc: jogo@openwrt.org Cc: Florian Fainelli Patchwork: https://patchwork.linux-mips.org/patch/5502/ Signed-off-by: Ralf Baechle --- arch/mips/bcm63xx/boards/board_bcm963xx.c | 35 +++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/arch/mips/bcm63xx/boards/board_bcm963xx.c b/arch/mips/bcm63xx/boards/board_bcm963xx.c index 611a420dbfdd..d3304dc02aee 100644 --- a/arch/mips/bcm63xx/boards/board_bcm963xx.c +++ b/arch/mips/bcm63xx/boards/board_bcm963xx.c @@ -36,6 +36,38 @@ static struct board_info board; +/* + * known 3368 boards + */ +#ifdef CONFIG_BCM63XX_CPU_3368 +static struct board_info __initdata board_cvg834g = { + .name = "CVG834G_E15R3921", + .expected_cpu_id = 0x3368, + + .has_uart0 = 1, + .has_uart1 = 1, + + .has_enet0 = 1, + .has_pci = 1, + + .enet0 = { + .has_phy = 1, + .use_internal_phy = 1, + }, + + .leds = { + { + .name = "CVG834G:green:power", + .gpio = 37, + .default_trigger= "default-on", + }, + }, + + .ephy_reset_gpio = 36, + .ephy_reset_gpio_flags = GPIOF_INIT_HIGH, +}; +#endif + /* * known 6328 boards */ @@ -643,6 +675,9 @@ static struct board_info __initdata board_DWVS0 = { * all boards */ static const struct board_info __initconst *bcm963xx_boards[] = { +#ifdef CONFIG_BCM63XX_CPU_3368 + &board_cvg834g, +#endif #ifdef CONFIG_BCM63XX_CPU_6328 &board_96328avng, #endif From 5219343f83a033fe5dfcbb0274b5a78e8b2d0fee Mon Sep 17 00:00:00 2001 From: David Daney Date: Wed, 19 Jun 2013 20:37:26 +0000 Subject: [PATCH 0537/1048] MIPS: OCTEON: Set proper UART clock in internal device trees. Following patch to use generic 8250 drivers will need proper clock information. So when using the internal device tree, populate the "clock-frequency" property with the correct value. Signed-off-by: David Daney Cc: linux-mips@linux-mips.org Cc: Jamie Iles Cc: Greg Kroah-Hartman Cc: Jiri Slaby Cc: linux-serial@vger.kernel.org Cc: linux-kernel@vger.kernel.org Patchwork: https://patchwork.linux-mips.org/patch/5515/ Signed-off-by: Ralf Baechle --- arch/mips/cavium-octeon/octeon-platform.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/arch/mips/cavium-octeon/octeon-platform.c b/arch/mips/cavium-octeon/octeon-platform.c index 389512e2abd6..7b746e7bf7a1 100644 --- a/arch/mips/cavium-octeon/octeon-platform.c +++ b/arch/mips/cavium-octeon/octeon-platform.c @@ -490,8 +490,15 @@ int __init octeon_prune_device_tree(void) if (alias_prop) { uart = fdt_path_offset(initial_boot_params, alias_prop); - if (uart_mask & (1 << i)) + if (uart_mask & (1 << i)) { + __be32 f; + + f = cpu_to_be32(octeon_get_io_clock_rate()); + fdt_setprop_inplace(initial_boot_params, + uart, "clock-frequency", + &f, sizeof(f)); continue; + } pr_debug("Deleting uart%d\n", i); fdt_nop_node(initial_boot_params, uart); fdt_nop_property(initial_boot_params, aliases, From d5f1af7ece96cf52e0b110c72210ac15c2f65438 Mon Sep 17 00:00:00 2001 From: David Daney Date: Wed, 19 Jun 2013 20:37:27 +0000 Subject: [PATCH 0538/1048] tty/8250_dw: Add support for OCTEON UARTS. A few differences needed by OCTEON: o These are DWC UARTS, but have USR at a different offset. o Internal SoC buses require reading back from registers to maintain write ordering. o 8250 on OCTEON appears with 64-bit wide registers, so when using readb/writeb in big endian mode we have to adjust the membase to hit the proper part of the register. o No UCV register, so we hard code some properties. Because OCTEON doesn't have a UCV register, I change where dw8250_setup_port(), which reads the UCV, is called by pushing it in to the OF and ACPI probe functions, and move unchanged dw8250_setup_port() earlier in the file. Signed-off-by: David Daney Acked-by: Greg Kroah-Hartman Cc: Arnd Bergmann Cc: Heikki Krogerus Cc: linux-mips@linux-mips.org Cc: Jamie Iles Cc: Jiri Slaby Cc: linux-serial@vger.kernel.org Cc: linux-kernel@vger.kernel.org Patchwork: https://patchwork.linux-mips.org/patch/5516/ Acked-by: Arnd Bergmann Reviewed-by: Heikki Krogerus Signed-off-by: Ralf Baechle --- drivers/tty/serial/8250/8250_dw.c | 180 +++++++++++++++++------------- 1 file changed, 105 insertions(+), 75 deletions(-) diff --git a/drivers/tty/serial/8250/8250_dw.c b/drivers/tty/serial/8250/8250_dw.c index d07b6af3a937..76a8daadff47 100644 --- a/drivers/tty/serial/8250/8250_dw.c +++ b/drivers/tty/serial/8250/8250_dw.c @@ -29,6 +29,8 @@ #include #include +#include + #include "8250.h" /* Offsets for the DesignWare specific registers */ @@ -57,6 +59,7 @@ struct dw8250_data { int last_lcr; int line; struct clk *clk; + u8 usr_reg; }; static void dw8250_serial_out(struct uart_port *p, int offset, int value) @@ -77,6 +80,13 @@ static unsigned int dw8250_serial_in(struct uart_port *p, int offset) return readb(p->membase + offset); } +/* Read Back (rb) version to ensure register access ording. */ +static void dw8250_serial_out_rb(struct uart_port *p, int offset, int value) +{ + dw8250_serial_out(p, offset, value); + dw8250_serial_in(p, UART_LCR); +} + static void dw8250_serial_out32(struct uart_port *p, int offset, int value) { struct dw8250_data *d = p->private_data; @@ -104,7 +114,7 @@ static int dw8250_handle_irq(struct uart_port *p) return 1; } else if ((iir & UART_IIR_BUSY) == UART_IIR_BUSY) { /* Clear the USR and write the LCR again. */ - (void)p->serial_in(p, DW_UART_USR); + (void)p->serial_in(p, d->usr_reg); p->serial_out(p, UART_LCR, d->last_lcr); return 1; @@ -125,77 +135,6 @@ dw8250_do_pm(struct uart_port *port, unsigned int state, unsigned int old) pm_runtime_put_sync_suspend(port->dev); } -static int dw8250_probe_of(struct uart_port *p) -{ - struct device_node *np = p->dev->of_node; - u32 val; - - if (!of_property_read_u32(np, "reg-io-width", &val)) { - switch (val) { - case 1: - break; - case 4: - p->iotype = UPIO_MEM32; - p->serial_in = dw8250_serial_in32; - p->serial_out = dw8250_serial_out32; - break; - default: - dev_err(p->dev, "unsupported reg-io-width (%u)\n", val); - return -EINVAL; - } - } - - if (!of_property_read_u32(np, "reg-shift", &val)) - p->regshift = val; - - /* clock got configured through clk api, all done */ - if (p->uartclk) - return 0; - - /* try to find out clock frequency from DT as fallback */ - if (of_property_read_u32(np, "clock-frequency", &val)) { - dev_err(p->dev, "clk or clock-frequency not defined\n"); - return -EINVAL; - } - p->uartclk = val; - - return 0; -} - -#ifdef CONFIG_ACPI -static int dw8250_probe_acpi(struct uart_8250_port *up) -{ - const struct acpi_device_id *id; - struct uart_port *p = &up->port; - - id = acpi_match_device(p->dev->driver->acpi_match_table, p->dev); - if (!id) - return -ENODEV; - - p->iotype = UPIO_MEM32; - p->serial_in = dw8250_serial_in32; - p->serial_out = dw8250_serial_out32; - p->regshift = 2; - - if (!p->uartclk) - p->uartclk = (unsigned int)id->driver_data; - - up->dma = devm_kzalloc(p->dev, sizeof(*up->dma), GFP_KERNEL); - if (!up->dma) - return -ENOMEM; - - up->dma->rxconf.src_maxburst = p->fifosize / 4; - up->dma->txconf.dst_maxburst = p->fifosize / 4; - - return 0; -} -#else -static inline int dw8250_probe_acpi(struct uart_8250_port *up) -{ - return -ENODEV; -} -#endif /* CONFIG_ACPI */ - static void dw8250_setup_port(struct uart_8250_port *up) { struct uart_port *p = &up->port; @@ -228,6 +167,97 @@ static void dw8250_setup_port(struct uart_8250_port *up) up->capabilities |= UART_CAP_AFE; } +static int dw8250_probe_of(struct uart_port *p, + struct dw8250_data *data) +{ + struct device_node *np = p->dev->of_node; + u32 val; + bool has_ucv = true; + + if (of_device_is_compatible(np, "cavium,octeon-3860-uart")) { +#ifdef __BIG_ENDIAN + /* + * Low order bits of these 64-bit registers, when + * accessed as a byte, are 7 bytes further down in the + * address space in big endian mode. + */ + p->membase += 7; +#endif + p->serial_out = dw8250_serial_out_rb; + p->flags = ASYNC_SKIP_TEST | UPF_SHARE_IRQ | UPF_FIXED_TYPE; + p->type = PORT_OCTEON; + data->usr_reg = 0x27; + has_ucv = false; + } else if (!of_property_read_u32(np, "reg-io-width", &val)) { + switch (val) { + case 1: + break; + case 4: + p->iotype = UPIO_MEM32; + p->serial_in = dw8250_serial_in32; + p->serial_out = dw8250_serial_out32; + break; + default: + dev_err(p->dev, "unsupported reg-io-width (%u)\n", val); + return -EINVAL; + } + } + if (has_ucv) + dw8250_setup_port(container_of(p, struct uart_8250_port, port)); + + if (!of_property_read_u32(np, "reg-shift", &val)) + p->regshift = val; + + /* clock got configured through clk api, all done */ + if (p->uartclk) + return 0; + + /* try to find out clock frequency from DT as fallback */ + if (of_property_read_u32(np, "clock-frequency", &val)) { + dev_err(p->dev, "clk or clock-frequency not defined\n"); + return -EINVAL; + } + p->uartclk = val; + + return 0; +} + +#ifdef CONFIG_ACPI +static int dw8250_probe_acpi(struct uart_8250_port *up) +{ + const struct acpi_device_id *id; + struct uart_port *p = &up->port; + + dw8250_setup_port(up); + + id = acpi_match_device(p->dev->driver->acpi_match_table, p->dev); + if (!id) + return -ENODEV; + + p->iotype = UPIO_MEM32; + p->serial_in = dw8250_serial_in32; + p->serial_out = dw8250_serial_out32; + p->regshift = 2; + + if (!p->uartclk) + p->uartclk = (unsigned int)id->driver_data; + + up->dma = devm_kzalloc(p->dev, sizeof(*up->dma), GFP_KERNEL); + if (!up->dma) + return -ENOMEM; + + up->dma->rxconf.src_maxburst = p->fifosize / 4; + up->dma->txconf.dst_maxburst = p->fifosize / 4; + + return 0; +} +#else +static inline int dw8250_probe_acpi(struct uart_8250_port *up) +{ + return -ENODEV; +} +#endif /* CONFIG_ACPI */ + static int dw8250_probe(struct platform_device *pdev) { struct uart_8250_port uart = {}; @@ -259,6 +289,7 @@ static int dw8250_probe(struct platform_device *pdev) if (!data) return -ENOMEM; + data->usr_reg = DW_UART_USR; data->clk = devm_clk_get(&pdev->dev, NULL); if (!IS_ERR(data->clk)) { clk_prepare_enable(data->clk); @@ -270,10 +301,8 @@ static int dw8250_probe(struct platform_device *pdev) uart.port.serial_out = dw8250_serial_out; uart.port.private_data = data; - dw8250_setup_port(&uart); - if (pdev->dev.of_node) { - err = dw8250_probe_of(&uart.port); + err = dw8250_probe_of(&uart.port, data); if (err) return err; } else if (ACPI_HANDLE(&pdev->dev)) { @@ -362,6 +391,7 @@ static const struct dev_pm_ops dw8250_pm_ops = { static const struct of_device_id dw8250_of_match[] = { { .compatible = "snps,dw-apb-uart" }, + { .compatible = "cavium,octeon-3860-uart" }, { /* Sentinel */ } }; MODULE_DEVICE_TABLE(of, dw8250_of_match); From fde179901e2ebe55ebbbd4c635e1fff322640f7d Mon Sep 17 00:00:00 2001 From: David Daney Date: Wed, 19 Jun 2013 20:37:28 +0000 Subject: [PATCH 0539/1048] MIPS: OCTEON: Remove custom serial setup code. We will use 8250_dw instead. Signed-off-by: David Daney Cc: linux-mips@linux-mips.org Cc: Jamie Iles Cc: Greg Kroah-Hartman Cc: Jiri Slaby Cc: linux-serial@vger.kernel.org Cc: linux-kernel@vger.kernel.org Patchwork: https://patchwork.linux-mips.org/patch/5517/ Signed-off-by: Ralf Baechle --- arch/mips/cavium-octeon/Makefile | 2 +- arch/mips/cavium-octeon/serial.c | 109 ------------------------------- 2 files changed, 1 insertion(+), 110 deletions(-) delete mode 100644 arch/mips/cavium-octeon/serial.c diff --git a/arch/mips/cavium-octeon/Makefile b/arch/mips/cavium-octeon/Makefile index 3595affb9772..b703583779fb 100644 --- a/arch/mips/cavium-octeon/Makefile +++ b/arch/mips/cavium-octeon/Makefile @@ -12,7 +12,7 @@ CFLAGS_octeon-platform.o = -I$(src)/../../../scripts/dtc/libfdt CFLAGS_setup.o = -I$(src)/../../../scripts/dtc/libfdt -obj-y := cpu.o setup.o serial.o octeon-platform.o octeon-irq.o csrc-octeon.o +obj-y := cpu.o setup.o octeon-platform.o octeon-irq.o csrc-octeon.o obj-y += dma-octeon.o flash_setup.o obj-y += octeon-memcpy.o obj-y += executive/ diff --git a/arch/mips/cavium-octeon/serial.c b/arch/mips/cavium-octeon/serial.c deleted file mode 100644 index f393f65f3923..000000000000 --- a/arch/mips/cavium-octeon/serial.c +++ /dev/null @@ -1,109 +0,0 @@ -/* - * This file is subject to the terms and conditions of the GNU General Public - * License. See the file "COPYING" in the main directory of this archive - * for more details. - * - * Copyright (C) 2004-2007 Cavium Networks - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include - -#define DEBUG_UART 1 - -unsigned int octeon_serial_in(struct uart_port *up, int offset) -{ - int rv = cvmx_read_csr((uint64_t)(up->membase + (offset << 3))); - if (offset == UART_IIR && (rv & 0xf) == 7) { - /* Busy interrupt, read the USR (39) and try again. */ - cvmx_read_csr((uint64_t)(up->membase + (39 << 3))); - rv = cvmx_read_csr((uint64_t)(up->membase + (offset << 3))); - } - return rv; -} - -void octeon_serial_out(struct uart_port *up, int offset, int value) -{ - /* - * If bits 6 or 7 of the OCTEON UART's LCR are set, it quits - * working. - */ - if (offset == UART_LCR) - value &= 0x9f; - cvmx_write_csr((uint64_t)(up->membase + (offset << 3)), (u8)value); -} - -static int octeon_serial_probe(struct platform_device *pdev) -{ - int irq, res; - struct resource *res_mem; - struct uart_8250_port up; - - /* All adaptors have an irq. */ - irq = platform_get_irq(pdev, 0); - if (irq < 0) - return irq; - - memset(&up, 0, sizeof(up)); - - up.port.flags = ASYNC_SKIP_TEST | UPF_SHARE_IRQ | UPF_FIXED_TYPE; - up.port.type = PORT_OCTEON; - up.port.iotype = UPIO_MEM; - up.port.regshift = 3; - up.port.dev = &pdev->dev; - - if (octeon_is_simulation()) - /* Make simulator output fast*/ - up.port.uartclk = 115200 * 16; - else - up.port.uartclk = octeon_get_io_clock_rate(); - - up.port.serial_in = octeon_serial_in; - up.port.serial_out = octeon_serial_out; - up.port.irq = irq; - - res_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (res_mem == NULL) { - dev_err(&pdev->dev, "found no memory resource\n"); - return -ENXIO; - } - up.port.mapbase = res_mem->start; - up.port.membase = ioremap(res_mem->start, resource_size(res_mem)); - - res = serial8250_register_8250_port(&up); - - return res >= 0 ? 0 : res; -} - -static struct of_device_id octeon_serial_match[] = { - { - .compatible = "cavium,octeon-3860-uart", - }, - {}, -}; -MODULE_DEVICE_TABLE(of, octeon_serial_match); - -static struct platform_driver octeon_serial_driver = { - .probe = octeon_serial_probe, - .driver = { - .owner = THIS_MODULE, - .name = "octeon_serial", - .of_match_table = octeon_serial_match, - }, -}; - -static int __init octeon_serial_init(void) -{ - return platform_driver_register(&octeon_serial_driver); -} -late_initcall(octeon_serial_init); From 1afb49d0e6429ba3997a3dfccb281bc473c4543e Mon Sep 17 00:00:00 2001 From: David Daney Date: Wed, 19 Jun 2013 20:37:29 +0000 Subject: [PATCH 0540/1048] MIPS: Update cavium_octeon_defconfig The serial port changes make it advisable to enable the proper UART drivers. Signed-off-by: David Daney Cc: linux-mips@linux-mips.org Cc: Jamie Iles Cc: Greg Kroah-Hartman Cc: Jiri Slaby Cc: linux-serial@vger.kernel.org Cc: linux-kernel@vger.kernel.org Patchwork: https://patchwork.linux-mips.org/patch/5518/ Signed-off-by: Ralf Baechle --- arch/mips/configs/cavium_octeon_defconfig | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/arch/mips/configs/cavium_octeon_defconfig b/arch/mips/configs/cavium_octeon_defconfig index 1888e5f4d598..dace58268ce1 100644 --- a/arch/mips/configs/cavium_octeon_defconfig +++ b/arch/mips/configs/cavium_octeon_defconfig @@ -1,13 +1,11 @@ CONFIG_CAVIUM_OCTEON_SOC=y CONFIG_CAVIUM_CN63XXP1=y CONFIG_CAVIUM_OCTEON_CVMSEG_SIZE=2 -CONFIG_SPARSEMEM_MANUAL=y CONFIG_TRANSPARENT_HUGEPAGE=y CONFIG_SMP=y CONFIG_NR_CPUS=32 CONFIG_HZ_100=y CONFIG_PREEMPT=y -CONFIG_EXPERIMENTAL=y CONFIG_SYSVIPC=y CONFIG_POSIX_MQUEUE=y CONFIG_BSD_PROCESS_ACCT=y @@ -50,7 +48,6 @@ CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" # CONFIG_FW_LOADER is not set CONFIG_MTD=y # CONFIG_MTD_OF_PARTS is not set -CONFIG_MTD_CHAR=y CONFIG_MTD_BLOCK=y CONFIG_MTD_CFI=y CONFIG_MTD_CFI_AMDSTD=y @@ -114,6 +111,7 @@ CONFIG_SERIAL_8250=y CONFIG_SERIAL_8250_CONSOLE=y CONFIG_SERIAL_8250_NR_UARTS=2 CONFIG_SERIAL_8250_RUNTIME_UARTS=2 +CONFIG_SERIAL_8250_DW=y # CONFIG_HW_RANDOM is not set CONFIG_I2C=y CONFIG_I2C_OCTEON=y From a7543d6003bcd73b57d5244ce78cfe9462755f90 Mon Sep 17 00:00:00 2001 From: Ralf Baechle Date: Tue, 25 Jun 2013 12:57:54 +0200 Subject: [PATCH 0541/1048] MIPS: Sibyte: Remove duplicate but harmless line from Platform file. Signed-off-by: Ralf Baechle --- arch/mips/sibyte/Platform | 1 - 1 file changed, 1 deletion(-) diff --git a/arch/mips/sibyte/Platform b/arch/mips/sibyte/Platform index d03a07516f83..af9ee6afa31a 100644 --- a/arch/mips/sibyte/Platform +++ b/arch/mips/sibyte/Platform @@ -13,7 +13,6 @@ cflags-$(CONFIG_SIBYTE_BCM112X) += \ -I$(srctree)/arch/mips/include/asm/mach-sibyte \ -DSIBYTE_HDR_FEATURES=SIBYTE_HDR_FMASK_1250_112x_ALL -platform-$(CONFIG_SIBYTE_SB1250) += sibyte/ cflags-$(CONFIG_SIBYTE_SB1250) += \ -I$(srctree)/arch/mips/include/asm/mach-sibyte \ -DSIBYTE_HDR_FEATURES=SIBYTE_HDR_FMASK_1250_112x_ALL From f69df6d33c020d3510a31d142edda3bd2107dff4 Mon Sep 17 00:00:00 2001 From: Ralf Baechle Date: Tue, 25 Jun 2013 14:13:13 +0200 Subject: [PATCH 0542/1048] MIPS: Sibyte: Fix comment. Signed-off-by: Ralf Baechle --- arch/mips/sibyte/Platform | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/mips/sibyte/Platform b/arch/mips/sibyte/Platform index af9ee6afa31a..6cb6dcf241f2 100644 --- a/arch/mips/sibyte/Platform +++ b/arch/mips/sibyte/Platform @@ -30,7 +30,8 @@ cflags-$(CONFIG_SIBYTE_BCM1x80) += \ # Sibyte BCM91120C (CRhine) board # Sibyte BCM91125C (CRhone) board # Sibyte BCM91125E (Rhone) board -# Sibyte SWARM board +# Sibyte BCM91250A (SWARM) board +# Sibyte BCM91250C2 (LittleSur) board # Sibyte BCM91x80 (BigSur) board # load-$(CONFIG_SIBYTE_CARMEL) := 0xffffffff80100000 From 0dad5d262278d24babbd62241fd238a3a3a0a39a Mon Sep 17 00:00:00 2001 From: Ralf Baechle Date: Tue, 25 Jun 2013 16:39:34 +0200 Subject: [PATCH 0543/1048] MIPS: Malta: Move platform-specific PCI code to arch/mips/pci. Signed-off-by: Ralf Baechle --- arch/mips/mti-malta/Makefile | 1 - arch/mips/pci/Makefile | 2 +- arch/mips/{mti-malta/malta-pci.c => pci/pci-malta.c} | 0 3 files changed, 1 insertion(+), 2 deletions(-) rename arch/mips/{mti-malta/malta-pci.c => pci/pci-malta.c} (100%) diff --git a/arch/mips/mti-malta/Makefile b/arch/mips/mti-malta/Makefile index 0388fc8b5613..72fdedbf76db 100644 --- a/arch/mips/mti-malta/Makefile +++ b/arch/mips/mti-malta/Makefile @@ -10,7 +10,6 @@ obj-y := malta-amon.o malta-display.o malta-init.o \ malta-reset.o malta-setup.o malta-time.o obj-$(CONFIG_EARLY_PRINTK) += malta-console.o -obj-$(CONFIG_PCI) += malta-pci.o # FIXME FIXME FIXME obj-$(CONFIG_MIPS_MT_SMTC) += malta-smtc.o diff --git a/arch/mips/pci/Makefile b/arch/mips/pci/Makefile index b56fbc06c60e..c382042911dd 100644 --- a/arch/mips/pci/Makefile +++ b/arch/mips/pci/Makefile @@ -29,7 +29,7 @@ obj-$(CONFIG_LASAT) += pci-lasat.o obj-$(CONFIG_MIPS_COBALT) += fixup-cobalt.o obj-$(CONFIG_LEMOTE_FULOONG2E) += fixup-fuloong2e.o ops-loongson2.o obj-$(CONFIG_LEMOTE_MACH2F) += fixup-lemote2f.o ops-loongson2.o -obj-$(CONFIG_MIPS_MALTA) += fixup-malta.o +obj-$(CONFIG_MIPS_MALTA) += fixup-malta.o pci-malta.o obj-$(CONFIG_PMC_MSP7120_GW) += fixup-pmcmsp.o ops-pmcmsp.o obj-$(CONFIG_PMC_MSP7120_EVAL) += fixup-pmcmsp.o ops-pmcmsp.o obj-$(CONFIG_PMC_MSP7120_FPGA) += fixup-pmcmsp.o ops-pmcmsp.o diff --git a/arch/mips/mti-malta/malta-pci.c b/arch/mips/pci/pci-malta.c similarity index 100% rename from arch/mips/mti-malta/malta-pci.c rename to arch/mips/pci/pci-malta.c From 1990e5429c2149a30a81ff634215c1aa76560a89 Mon Sep 17 00:00:00 2001 From: Ralf Baechle Date: Wed, 26 Jun 2013 17:06:34 +0200 Subject: [PATCH 0544/1048] MIPS: Get rid of MIPS I flag and test macros. MIPS I is the ancestor of all MIPS ISA and architecture variants. Anything ever build in the MIPS empire is either MIPS I or at least contains MIPS I. If it's running Linux, that is. So there is little point in having cpu_has_mips_1 because it will always evaluate as true - though usually only at runtime. Thus there is no point in having the MIPS_CPU_ISA_I ISA flag, so get rid of it. Little complication: traps.c was using a test for a pure MIPS I ISA as a test for an R3000-style cp0. To deal with that, use a check for cpu_has_3kex or cpu_has_4kex instead. cpu_has_3kex is a new macro. At the moment its default implementation is !cpu_has_4kex but this may eventually change if Linux is ever going to support the oddball MIPS processors R6000 and R8000 so users of either of these macros should not make any assumptions. Signed-off-by: Ralf Baechle Patchwork: https://patchwork.linux-mips.org/patch/5551/ --- arch/mips/include/asm/cpu-features.h | 11 ++++++++++- arch/mips/include/asm/cpu.h | 21 ++++++++++----------- arch/mips/kernel/cpu-probe.c | 8 +------- arch/mips/kernel/proc.c | 4 +--- arch/mips/kernel/traps.c | 4 ++-- 5 files changed, 24 insertions(+), 24 deletions(-) diff --git a/arch/mips/include/asm/cpu-features.h b/arch/mips/include/asm/cpu-features.h index e5ec8fcd8afa..9609812bc8f2 100644 --- a/arch/mips/include/asm/cpu-features.h +++ b/arch/mips/include/asm/cpu-features.h @@ -24,6 +24,16 @@ #ifndef cpu_has_tlb #define cpu_has_tlb (cpu_data[0].options & MIPS_CPU_TLB) #endif + +/* + * For the moment we don't consider R6000 and R8000 so we can assume that + * anything that doesn't support R4000-style exceptions and interrupts is + * R3000-like. Users should still treat these two macro definitions as + * opaque. + */ +#ifndef cpu_has_3kex +#define cpu_has_3kex (!cpu_has_4kex) +#endif #ifndef cpu_has_4kex #define cpu_has_4kex (cpu_data[0].options & MIPS_CPU_4KEX) #endif @@ -136,7 +146,6 @@ #endif #endif -# define cpu_has_mips_1 (cpu_data[0].isa_level & MIPS_CPU_ISA_I) #ifndef cpu_has_mips_2 # define cpu_has_mips_2 (cpu_data[0].isa_level & MIPS_CPU_ISA_II) #endif diff --git a/arch/mips/include/asm/cpu.h b/arch/mips/include/asm/cpu.h index dd86ab205483..632bbe5a79ea 100644 --- a/arch/mips/include/asm/cpu.h +++ b/arch/mips/include/asm/cpu.h @@ -282,18 +282,17 @@ enum cpu_type_enum { * ISA Level encodings * */ -#define MIPS_CPU_ISA_I 0x00000001 -#define MIPS_CPU_ISA_II 0x00000002 -#define MIPS_CPU_ISA_III 0x00000004 -#define MIPS_CPU_ISA_IV 0x00000008 -#define MIPS_CPU_ISA_V 0x00000010 -#define MIPS_CPU_ISA_M32R1 0x00000020 -#define MIPS_CPU_ISA_M32R2 0x00000040 -#define MIPS_CPU_ISA_M64R1 0x00000080 -#define MIPS_CPU_ISA_M64R2 0x00000100 +#define MIPS_CPU_ISA_II 0x00000001 +#define MIPS_CPU_ISA_III 0x00000002 +#define MIPS_CPU_ISA_IV 0x00000004 +#define MIPS_CPU_ISA_V 0x00000008 +#define MIPS_CPU_ISA_M32R1 0x00000010 +#define MIPS_CPU_ISA_M32R2 0x00000020 +#define MIPS_CPU_ISA_M64R1 0x00000040 +#define MIPS_CPU_ISA_M64R2 0x00000080 -#define MIPS_CPU_ISA_32BIT (MIPS_CPU_ISA_I | MIPS_CPU_ISA_II | \ - MIPS_CPU_ISA_M32R1 | MIPS_CPU_ISA_M32R2) +#define MIPS_CPU_ISA_32BIT (MIPS_CPU_ISA_II | MIPS_CPU_ISA_M32R1 | \ + MIPS_CPU_ISA_M32R2) #define MIPS_CPU_ISA_64BIT (MIPS_CPU_ISA_III | MIPS_CPU_ISA_IV | \ MIPS_CPU_ISA_V | MIPS_CPU_ISA_M64R1 | MIPS_CPU_ISA_M64R2) diff --git a/arch/mips/kernel/cpu-probe.c b/arch/mips/kernel/cpu-probe.c index 265c97da6619..f87039dbefe9 100644 --- a/arch/mips/kernel/cpu-probe.c +++ b/arch/mips/kernel/cpu-probe.c @@ -146,8 +146,7 @@ static void __cpuinit set_isa(struct cpuinfo_mips *c, unsigned int isa) case MIPS_CPU_ISA_IV: c->isa_level |= MIPS_CPU_ISA_IV; case MIPS_CPU_ISA_III: - c->isa_level |= MIPS_CPU_ISA_I | MIPS_CPU_ISA_II | - MIPS_CPU_ISA_III; + c->isa_level |= MIPS_CPU_ISA_II | MIPS_CPU_ISA_III; break; case MIPS_CPU_ISA_M32R2: @@ -156,8 +155,6 @@ static void __cpuinit set_isa(struct cpuinfo_mips *c, unsigned int isa) c->isa_level |= MIPS_CPU_ISA_M32R1; case MIPS_CPU_ISA_II: c->isa_level |= MIPS_CPU_ISA_II; - case MIPS_CPU_ISA_I: - c->isa_level |= MIPS_CPU_ISA_I; break; } } @@ -332,7 +329,6 @@ static inline void cpu_probe_legacy(struct cpuinfo_mips *c, unsigned int cpu) case PRID_IMP_R2000: c->cputype = CPU_R2000; __cpu_name[cpu] = "R2000"; - set_isa(c, MIPS_CPU_ISA_I); c->options = MIPS_CPU_TLB | MIPS_CPU_3K_CACHE | MIPS_CPU_NOFPUEX; if (__cpu_has_fpu()) @@ -352,7 +348,6 @@ static inline void cpu_probe_legacy(struct cpuinfo_mips *c, unsigned int cpu) c->cputype = CPU_R3000; __cpu_name[cpu] = "R3000"; } - set_isa(c, MIPS_CPU_ISA_I); c->options = MIPS_CPU_TLB | MIPS_CPU_3K_CACHE | MIPS_CPU_NOFPUEX; if (__cpu_has_fpu()) @@ -455,7 +450,6 @@ static inline void cpu_probe_legacy(struct cpuinfo_mips *c, unsigned int cpu) break; #endif case PRID_IMP_TX39: - set_isa(c, MIPS_CPU_ISA_I); c->options = MIPS_CPU_TLB | MIPS_CPU_TX39_CACHE; if ((c->processor_id & 0xf0) == (PRID_REV_TX3927 & 0xf0)) { diff --git a/arch/mips/kernel/proc.c b/arch/mips/kernel/proc.c index acb34373679e..8c58d8a84bf3 100644 --- a/arch/mips/kernel/proc.c +++ b/arch/mips/kernel/proc.c @@ -66,9 +66,7 @@ static int show_cpuinfo(struct seq_file *m, void *v) seq_printf(m, "]\n"); } if (cpu_has_mips_r) { - seq_printf(m, "isa\t\t\t:"); - if (cpu_has_mips_1) - seq_printf(m, "%s", " mips1"); + seq_printf(m, "isa\t\t\t: mips1"); if (cpu_has_mips_2) seq_printf(m, "%s", " mips2"); if (cpu_has_mips_3) diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c index 142d2bede024..d97ea234e2d3 100644 --- a/arch/mips/kernel/traps.c +++ b/arch/mips/kernel/traps.c @@ -265,7 +265,7 @@ static void __show_regs(const struct pt_regs *regs) printk("Status: %08x ", (uint32_t) regs->cp0_status); - if (current_cpu_data.isa_level == MIPS_CPU_ISA_I) { + if (cpu_has_3kex) { if (regs->cp0_status & ST0_KUO) printk("KUo "); if (regs->cp0_status & ST0_IEO) @@ -278,7 +278,7 @@ static void __show_regs(const struct pt_regs *regs) printk("KUc "); if (regs->cp0_status & ST0_IEC) printk("IEc "); - } else { + } else if (cpu_has_4kex) { if (regs->cp0_status & ST0_KX) printk("KX "); if (regs->cp0_status & ST0_SX) From 6ba045f9fbdafb48da42aa8576ea7a3980443136 Mon Sep 17 00:00:00 2001 From: Jayachandran C Date: Sun, 23 Jun 2013 17:16:19 +0000 Subject: [PATCH 0545/1048] MIPS: Move generated code to .text for microMIPS Prepare of a next patch which will call tlbmiss_handler_setup_pgd on microMIPS. MicroMIPS complains if the called code s not in the .text section. To fix this we generate code into space reserved in arch/mips/mm/tlb-funcs.S While there, move the rest of the generated functions (handle_tlbl, handle_tlbs, handle_tlbm) to the same file. Signed-off-by: Jayachandran C Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/5542/ Signed-off-by: Ralf Baechle --- arch/mips/include/asm/mmu_context.h | 6 +- arch/mips/mm/Makefile | 2 +- arch/mips/mm/tlb-funcs.S | 37 +++++++++++++ arch/mips/mm/tlbex.c | 86 +++++++++++++++-------------- 4 files changed, 84 insertions(+), 47 deletions(-) create mode 100644 arch/mips/mm/tlb-funcs.S diff --git a/arch/mips/include/asm/mmu_context.h b/arch/mips/include/asm/mmu_context.h index 820116067c10..1fed8bdcf2a0 100644 --- a/arch/mips/include/asm/mmu_context.h +++ b/arch/mips/include/asm/mmu_context.h @@ -28,11 +28,7 @@ #define TLBMISS_HANDLER_SETUP_PGD(pgd) \ do { \ - void (*tlbmiss_handler_setup_pgd)(unsigned long); \ - extern u32 tlbmiss_handler_setup_pgd_array[16]; \ - \ - tlbmiss_handler_setup_pgd = \ - (__typeof__(tlbmiss_handler_setup_pgd)) tlbmiss_handler_setup_pgd_array; \ + extern void tlbmiss_handler_setup_pgd(unsigned long); \ tlbmiss_handler_setup_pgd((unsigned long)(pgd)); \ } while (0) diff --git a/arch/mips/mm/Makefile b/arch/mips/mm/Makefile index e87aae1f2e80..7f4f93ab22b7 100644 --- a/arch/mips/mm/Makefile +++ b/arch/mips/mm/Makefile @@ -4,7 +4,7 @@ obj-y += cache.o dma-default.o extable.o fault.o \ gup.o init.o mmap.o page.o page-funcs.o \ - tlbex.o tlbex-fault.o uasm-mips.o + tlbex.o tlbex-fault.o tlb-funcs.o uasm-mips.o obj-$(CONFIG_32BIT) += ioremap.o pgtable-32.o obj-$(CONFIG_64BIT) += pgtable-64.o diff --git a/arch/mips/mm/tlb-funcs.S b/arch/mips/mm/tlb-funcs.S new file mode 100644 index 000000000000..30a494db99c2 --- /dev/null +++ b/arch/mips/mm/tlb-funcs.S @@ -0,0 +1,37 @@ +/* + * This file is subject to the terms and conditions of the GNU General Public + * License. See the file "COPYING" in the main directory of this archive + * for more details. + * + * Micro-assembler generated tlb handler functions. + * + * Copyright (C) 2013 Broadcom Corporation. + * + * Based on mm/page-funcs.c + * Copyright (C) 2012 MIPS Technologies, Inc. + * Copyright (C) 2012 Ralf Baechle + */ +#include +#include + +#define FASTPATH_SIZE 128 + +LEAF(tlbmiss_handler_setup_pgd) + .space 16 * 4 +END(tlbmiss_handler_setup_pgd) +EXPORT(tlbmiss_handler_setup_pgd_end) + +LEAF(handle_tlbm) + .space FASTPATH_SIZE * 4 +END(handle_tlbm) +EXPORT(handle_tlbm_end) + +LEAF(handle_tlbs) + .space FASTPATH_SIZE * 4 +END(handle_tlbs) +EXPORT(handle_tlbs_end) + +LEAF(handle_tlbl) + .space FASTPATH_SIZE * 4 +END(handle_tlbl) +EXPORT(handle_tlbl_end) diff --git a/arch/mips/mm/tlbex.c b/arch/mips/mm/tlbex.c index 9b988c050fdd..4712f3cd73b7 100644 --- a/arch/mips/mm/tlbex.c +++ b/arch/mips/mm/tlbex.c @@ -1455,27 +1455,25 @@ static void __cpuinit build_r4000_tlb_refill_handler(void) dump_handler("r4000_tlb_refill", (u32 *)ebase, 64); } -/* - * 128 instructions for the fastpath handler is generous and should - * never be exceeded. - */ -#define FASTPATH_SIZE 128 +extern u32 handle_tlbl[], handle_tlbl_end[]; +extern u32 handle_tlbs[], handle_tlbs_end[]; +extern u32 handle_tlbm[], handle_tlbm_end[]; -u32 handle_tlbl[FASTPATH_SIZE] __cacheline_aligned; -u32 handle_tlbs[FASTPATH_SIZE] __cacheline_aligned; -u32 handle_tlbm[FASTPATH_SIZE] __cacheline_aligned; #ifdef CONFIG_MIPS_PGD_C0_CONTEXT -u32 tlbmiss_handler_setup_pgd_array[16] __cacheline_aligned; +extern u32 tlbmiss_handler_setup_pgd[], tlbmiss_handler_setup_pgd_end[]; static void __cpuinit build_r4000_setup_pgd(void) { const int a0 = 4; const int a1 = 5; u32 *p = tlbmiss_handler_setup_pgd_array; + const int tlbmiss_handler_setup_pgd_size = + tlbmiss_handler_setup_pgd_end - tlbmiss_handler_setup_pgd; struct uasm_label *l = labels; struct uasm_reloc *r = relocs; - memset(tlbmiss_handler_setup_pgd_array, 0, sizeof(tlbmiss_handler_setup_pgd_array)); + memset(tlbmiss_handler_setup_pgd, 0, tlbmiss_handler_setup_pgd_size * + sizeof(tlbmiss_handler_setup_pgd[0])); memset(labels, 0, sizeof(labels)); memset(relocs, 0, sizeof(relocs)); @@ -1503,15 +1501,15 @@ static void __cpuinit build_r4000_setup_pgd(void) uasm_i_jr(&p, 31); UASM_i_MTC0(&p, a0, c0_kscratch(), pgd_reg); } - if (p - tlbmiss_handler_setup_pgd_array > ARRAY_SIZE(tlbmiss_handler_setup_pgd_array)) - panic("tlbmiss_handler_setup_pgd_array space exceeded"); - uasm_resolve_relocs(relocs, labels); - pr_debug("Wrote tlbmiss_handler_setup_pgd_array (%u instructions).\n", - (unsigned int)(p - tlbmiss_handler_setup_pgd_array)); + if (p >= tlbmiss_handler_setup_pgd_end) + panic("tlbmiss_handler_setup_pgd space exceeded"); - dump_handler("tlbmiss_handler", - tlbmiss_handler_setup_pgd_array, - ARRAY_SIZE(tlbmiss_handler_setup_pgd_array)); + uasm_resolve_relocs(relocs, labels); + pr_debug("Wrote tlbmiss_handler_setup_pgd (%u instructions).\n", + (unsigned int)(p - tlbmiss_handler_setup_pgd)); + + dump_handler("tlbmiss_handler", tlbmiss_handler_setup_pgd, + tlbmiss_handler_setup_pgd_size); } #endif @@ -1756,10 +1754,11 @@ build_r3000_tlbchange_handler_head(u32 **p, unsigned int pte, static void __cpuinit build_r3000_tlb_load_handler(void) { u32 *p = handle_tlbl; + const int handle_tlbl_size = handle_tlbl_end - handle_tlbl; struct uasm_label *l = labels; struct uasm_reloc *r = relocs; - memset(handle_tlbl, 0, sizeof(handle_tlbl)); + memset(handle_tlbl, 0, handle_tlbl_size * sizeof(handle_tlbl[0])); memset(labels, 0, sizeof(labels)); memset(relocs, 0, sizeof(relocs)); @@ -1773,23 +1772,24 @@ static void __cpuinit build_r3000_tlb_load_handler(void) uasm_i_j(&p, (unsigned long)tlb_do_page_fault_0 & 0x0fffffff); uasm_i_nop(&p); - if ((p - handle_tlbl) > FASTPATH_SIZE) + if (p >= handle_tlbl_end) panic("TLB load handler fastpath space exceeded"); uasm_resolve_relocs(relocs, labels); pr_debug("Wrote TLB load handler fastpath (%u instructions).\n", (unsigned int)(p - handle_tlbl)); - dump_handler("r3000_tlb_load", handle_tlbl, ARRAY_SIZE(handle_tlbl)); + dump_handler("r3000_tlb_load", handle_tlbl, handle_tlbl_size); } static void __cpuinit build_r3000_tlb_store_handler(void) { u32 *p = handle_tlbs; + const int handle_tlbs_size = handle_tlbs_end - handle_tlbs; struct uasm_label *l = labels; struct uasm_reloc *r = relocs; - memset(handle_tlbs, 0, sizeof(handle_tlbs)); + memset(handle_tlbs, 0, handle_tlbs_size * sizeof(handle_tlbs[0])); memset(labels, 0, sizeof(labels)); memset(relocs, 0, sizeof(relocs)); @@ -1803,23 +1803,24 @@ static void __cpuinit build_r3000_tlb_store_handler(void) uasm_i_j(&p, (unsigned long)tlb_do_page_fault_1 & 0x0fffffff); uasm_i_nop(&p); - if ((p - handle_tlbs) > FASTPATH_SIZE) + if (p >= handle_tlbs) panic("TLB store handler fastpath space exceeded"); uasm_resolve_relocs(relocs, labels); pr_debug("Wrote TLB store handler fastpath (%u instructions).\n", (unsigned int)(p - handle_tlbs)); - dump_handler("r3000_tlb_store", handle_tlbs, ARRAY_SIZE(handle_tlbs)); + dump_handler("r3000_tlb_store", handle_tlbs, handle_tlbs_size); } static void __cpuinit build_r3000_tlb_modify_handler(void) { u32 *p = handle_tlbm; + const int handle_tlbm_size = handle_tlbm_end - handle_tlbm; struct uasm_label *l = labels; struct uasm_reloc *r = relocs; - memset(handle_tlbm, 0, sizeof(handle_tlbm)); + memset(handle_tlbm, 0, handle_tlbm_size * sizeof(handle_tlbm[0])); memset(labels, 0, sizeof(labels)); memset(relocs, 0, sizeof(relocs)); @@ -1833,14 +1834,14 @@ static void __cpuinit build_r3000_tlb_modify_handler(void) uasm_i_j(&p, (unsigned long)tlb_do_page_fault_1 & 0x0fffffff); uasm_i_nop(&p); - if ((p - handle_tlbm) > FASTPATH_SIZE) + if (p >= handle_tlbm_end) panic("TLB modify handler fastpath space exceeded"); uasm_resolve_relocs(relocs, labels); pr_debug("Wrote TLB modify handler fastpath (%u instructions).\n", (unsigned int)(p - handle_tlbm)); - dump_handler("r3000_tlb_modify", handle_tlbm, ARRAY_SIZE(handle_tlbm)); + dump_handler("r3000_tlb_modify", handle_tlbm, handle_tlbm_size); } #endif /* CONFIG_MIPS_PGD_C0_CONTEXT */ @@ -1904,11 +1905,12 @@ build_r4000_tlbchange_handler_tail(u32 **p, struct uasm_label **l, static void __cpuinit build_r4000_tlb_load_handler(void) { u32 *p = handle_tlbl; + const int handle_tlbl_size = handle_tlbl_end - handle_tlbl; struct uasm_label *l = labels; struct uasm_reloc *r = relocs; struct work_registers wr; - memset(handle_tlbl, 0, sizeof(handle_tlbl)); + memset(handle_tlbl, 0, handle_tlbl_size * sizeof(handle_tlbl[0])); memset(labels, 0, sizeof(labels)); memset(relocs, 0, sizeof(relocs)); @@ -2047,24 +2049,25 @@ static void __cpuinit build_r4000_tlb_load_handler(void) uasm_i_j(&p, (unsigned long)tlb_do_page_fault_0 & 0x0fffffff); uasm_i_nop(&p); - if ((p - handle_tlbl) > FASTPATH_SIZE) + if (p >= handle_tlbl_end) panic("TLB load handler fastpath space exceeded"); uasm_resolve_relocs(relocs, labels); pr_debug("Wrote TLB load handler fastpath (%u instructions).\n", (unsigned int)(p - handle_tlbl)); - dump_handler("r4000_tlb_load", handle_tlbl, ARRAY_SIZE(handle_tlbl)); + dump_handler("r4000_tlb_load", handle_tlbl, handle_tlbl_size); } static void __cpuinit build_r4000_tlb_store_handler(void) { u32 *p = handle_tlbs; + const int handle_tlbs_size = handle_tlbs_end - handle_tlbs; struct uasm_label *l = labels; struct uasm_reloc *r = relocs; struct work_registers wr; - memset(handle_tlbs, 0, sizeof(handle_tlbs)); + memset(handle_tlbs, 0, handle_tlbs_size * sizeof(handle_tlbs[0])); memset(labels, 0, sizeof(labels)); memset(relocs, 0, sizeof(relocs)); @@ -2101,24 +2104,25 @@ static void __cpuinit build_r4000_tlb_store_handler(void) uasm_i_j(&p, (unsigned long)tlb_do_page_fault_1 & 0x0fffffff); uasm_i_nop(&p); - if ((p - handle_tlbs) > FASTPATH_SIZE) + if (p >= handle_tlbs_end) panic("TLB store handler fastpath space exceeded"); uasm_resolve_relocs(relocs, labels); pr_debug("Wrote TLB store handler fastpath (%u instructions).\n", (unsigned int)(p - handle_tlbs)); - dump_handler("r4000_tlb_store", handle_tlbs, ARRAY_SIZE(handle_tlbs)); + dump_handler("r4000_tlb_store", handle_tlbs, handle_tlbs_size); } static void __cpuinit build_r4000_tlb_modify_handler(void) { u32 *p = handle_tlbm; + const int handle_tlbm_size = handle_tlbm_end - handle_tlbm; struct uasm_label *l = labels; struct uasm_reloc *r = relocs; struct work_registers wr; - memset(handle_tlbm, 0, sizeof(handle_tlbm)); + memset(handle_tlbm, 0, handle_tlbm_size * sizeof(handle_tlbm[0])); memset(labels, 0, sizeof(labels)); memset(relocs, 0, sizeof(relocs)); @@ -2156,14 +2160,14 @@ static void __cpuinit build_r4000_tlb_modify_handler(void) uasm_i_j(&p, (unsigned long)tlb_do_page_fault_1 & 0x0fffffff); uasm_i_nop(&p); - if ((p - handle_tlbm) > FASTPATH_SIZE) + if (p >= handle_tlbm_end) panic("TLB modify handler fastpath space exceeded"); uasm_resolve_relocs(relocs, labels); pr_debug("Wrote TLB modify handler fastpath (%u instructions).\n", (unsigned int)(p - handle_tlbm)); - dump_handler("r4000_tlb_modify", handle_tlbm, ARRAY_SIZE(handle_tlbm)); + dump_handler("r4000_tlb_modify", handle_tlbm, handle_tlbm_size); } void __cpuinit build_tlb_refill_handler(void) @@ -2235,13 +2239,13 @@ void __cpuinit build_tlb_refill_handler(void) void __cpuinit flush_tlb_handlers(void) { local_flush_icache_range((unsigned long)handle_tlbl, - (unsigned long)handle_tlbl + sizeof(handle_tlbl)); + (unsigned long)handle_tlbl_end); local_flush_icache_range((unsigned long)handle_tlbs, - (unsigned long)handle_tlbs + sizeof(handle_tlbs)); + (unsigned long)handle_tlbs_end); local_flush_icache_range((unsigned long)handle_tlbm, - (unsigned long)handle_tlbm + sizeof(handle_tlbm)); + (unsigned long)handle_tlbm_end); #ifdef CONFIG_MIPS_PGD_C0_CONTEXT - local_flush_icache_range((unsigned long)tlbmiss_handler_setup_pgd_array, - (unsigned long)tlbmiss_handler_setup_pgd_array + sizeof(handle_tlbm)); + local_flush_icache_range((unsigned long)tlbmiss_handler_setup_pgd, + (unsigned long)tlbmiss_handler_setup_pgd_end); #endif } From a135a9b5d9683ace787c7d86f1e642d9acfacdde Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Sun, 23 Jun 2013 20:38:44 +0000 Subject: [PATCH 0546/1048] MIPS: Octeon: Enable interfaces on EdgeRouter Lite Enable interfaces on EdgeRouter Lite. Tested with cavium_octeon_defconfig and busybox shell. DHCP & ping works with eth0, eth1 and eth2. The board type "UBNT_E100" is taken from the sources of the vendor kernel shipped with the product. Signed-off-by: Aaro Koskinen Acked-by: David Daney Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/5546/ Signed-off-by: Ralf Baechle --- .../cavium-octeon/executive/cvmx-helper-board.c | 13 +++++++++++++ arch/mips/include/asm/octeon/cvmx-bootinfo.h | 2 ++ 2 files changed, 15 insertions(+) diff --git a/arch/mips/cavium-octeon/executive/cvmx-helper-board.c b/arch/mips/cavium-octeon/executive/cvmx-helper-board.c index 7c6497781895..0a1283ce47f5 100644 --- a/arch/mips/cavium-octeon/executive/cvmx-helper-board.c +++ b/arch/mips/cavium-octeon/executive/cvmx-helper-board.c @@ -181,6 +181,11 @@ int cvmx_helper_board_get_mii_address(int ipd_port) return ipd_port - 16 + 4; else return -1; + case CVMX_BOARD_TYPE_UBNT_E100: + if (ipd_port >= 0 && ipd_port <= 2) + return 7 - ipd_port; + else + return -1; } /* Some unknown board. Somebody forgot to update this function... */ @@ -706,6 +711,14 @@ int __cvmx_helper_board_hardware_enable(int interface) } } } + } else if (cvmx_sysinfo_get()->board_type == + CVMX_BOARD_TYPE_UBNT_E100) { + cvmx_write_csr(CVMX_ASXX_RX_CLK_SETX(0, interface), 0); + cvmx_write_csr(CVMX_ASXX_TX_CLK_SETX(0, interface), 0x10); + cvmx_write_csr(CVMX_ASXX_RX_CLK_SETX(1, interface), 0); + cvmx_write_csr(CVMX_ASXX_TX_CLK_SETX(1, interface), 0x10); + cvmx_write_csr(CVMX_ASXX_RX_CLK_SETX(2, interface), 0); + cvmx_write_csr(CVMX_ASXX_TX_CLK_SETX(2, interface), 0x10); } return 0; } diff --git a/arch/mips/include/asm/octeon/cvmx-bootinfo.h b/arch/mips/include/asm/octeon/cvmx-bootinfo.h index 284fa8d773ba..7b7818d1e4d5 100644 --- a/arch/mips/include/asm/octeon/cvmx-bootinfo.h +++ b/arch/mips/include/asm/octeon/cvmx-bootinfo.h @@ -227,6 +227,7 @@ enum cvmx_board_types_enum { * use any numbers in this range. */ CVMX_BOARD_TYPE_CUST_PRIVATE_MIN = 20001, + CVMX_BOARD_TYPE_UBNT_E100 = 20002, CVMX_BOARD_TYPE_CUST_PRIVATE_MAX = 30000, /* The remaining range is reserved for future use. */ @@ -325,6 +326,7 @@ static inline const char *cvmx_board_type_to_string(enum /* Customer private range */ ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_CUST_PRIVATE_MIN) + ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_UBNT_E100) ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_CUST_PRIVATE_MAX) } return "Unsupported Board"; From 8dfdd02a4c9de3aa7f2bfdec515e57340e401c87 Mon Sep 17 00:00:00 2001 From: David Daney Date: Fri, 21 Jun 2013 21:14:53 +0000 Subject: [PATCH 0547/1048] MIPS: Don't save/restore OCTEON wide multiplier state on syscalls. The ABI allows these to be clobbered on syscalls, so only save and restore the multiplier state when the temporary registers need to be preserved. Signed-off-by: David Daney Cc: linux-mips@linux-mips.org Cc: David Daney Patchwork: https://patchwork.linux-mips.org/patch/5540/ Signed-off-by: Ralf Baechle --- arch/mips/include/asm/stackframe.h | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/arch/mips/include/asm/stackframe.h b/arch/mips/include/asm/stackframe.h index a89d1b10d027..23fc95e65673 100644 --- a/arch/mips/include/asm/stackframe.h +++ b/arch/mips/include/asm/stackframe.h @@ -69,6 +69,14 @@ LONG_S $24, PT_R24(sp) #ifndef CONFIG_CPU_HAS_SMARTMIPS LONG_S v1, PT_LO(sp) +#endif +#ifdef CONFIG_CPU_CAVIUM_OCTEON + /* + * The Octeon multiplier state is affected by general + * multiply instructions. It must be saved before and + * kernel code might corrupt it + */ + jal octeon_mult_save #endif .endm @@ -218,17 +226,8 @@ ori $28, sp, _THREAD_MASK xori $28, _THREAD_MASK #ifdef CONFIG_CPU_CAVIUM_OCTEON - .set mips64 - pref 0, 0($28) /* Prefetch the current pointer */ - pref 0, PT_R31(sp) /* Prefetch the $31(ra) */ - /* The Octeon multiplier state is affected by general multiply - instructions. It must be saved before and kernel code might - corrupt it */ - jal octeon_mult_save - LONG_L v1, 0($28) /* Load the current pointer */ - /* Restore $31(ra) that was changed by the jal */ - LONG_L ra, PT_R31(sp) - pref 0, 0(v1) /* Prefetch the current thread */ + .set mips64 + pref 0, 0($28) /* Prefetch the current pointer */ #endif .set pop .endm @@ -248,6 +247,10 @@ .endm .macro RESTORE_TEMP +#ifdef CONFIG_CPU_CAVIUM_OCTEON + /* Restore the Octeon multiplier state */ + jal octeon_mult_restore +#endif #ifdef CONFIG_CPU_HAS_SMARTMIPS LONG_L $24, PT_ACX(sp) mtlhx $24 @@ -360,10 +363,6 @@ DVPE 5 # dvpe a1 jal mips_ihb #endif /* CONFIG_MIPS_MT_SMTC */ -#ifdef CONFIG_CPU_CAVIUM_OCTEON - /* Restore the Octeon multiplier state */ - jal octeon_mult_restore -#endif mfc0 a0, CP0_STATUS ori a0, STATMASK xori a0, STATMASK From c214c03512b67e56dea3f4471705f8caae49553a Mon Sep 17 00:00:00 2001 From: Tony Wu Date: Fri, 21 Jun 2013 10:13:08 +0000 Subject: [PATCH 0548/1048] MIPS: GIC: Fix gic_set_affinity infinite loop There is an infinite loop in gic_set_affinity. When irq_set_affinity gets called on gic controller, it blocks forever. Signed-off-by: Tony Wu Cc: Steven J. Hill Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/5537/ Signed-off-by: Ralf Baechle --- arch/mips/kernel/irq-gic.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/arch/mips/kernel/irq-gic.c b/arch/mips/kernel/irq-gic.c index c01b307317a9..5b5ddb231f26 100644 --- a/arch/mips/kernel/irq-gic.c +++ b/arch/mips/kernel/irq-gic.c @@ -219,16 +219,15 @@ static int gic_set_affinity(struct irq_data *d, const struct cpumask *cpumask, /* Assumption : cpumask refers to a single CPU */ spin_lock_irqsave(&gic_lock, flags); - for (;;) { - /* Re-route this IRQ */ - GIC_SH_MAP_TO_VPE_SMASK(irq, first_cpu(tmp)); - /* Update the pcpu_masks */ - for (i = 0; i < NR_CPUS; i++) - clear_bit(irq, pcpu_masks[i].pcpu_mask); - set_bit(irq, pcpu_masks[first_cpu(tmp)].pcpu_mask); + /* Re-route this IRQ */ + GIC_SH_MAP_TO_VPE_SMASK(irq, first_cpu(tmp)); + + /* Update the pcpu_masks */ + for (i = 0; i < NR_CPUS; i++) + clear_bit(irq, pcpu_masks[i].pcpu_mask); + set_bit(irq, pcpu_masks[first_cpu(tmp)].pcpu_mask); - } cpumask_copy(d->affinity, cpumask); spin_unlock_irqrestore(&gic_lock, flags); From 3ddc14add5e6341cf8ef4058c34c67ba7fd15317 Mon Sep 17 00:00:00 2001 From: David Daney Date: Fri, 24 May 2013 20:54:10 +0000 Subject: [PATCH 0549/1048] MIPS: Only set cpu_has_mmips if SYS_SUPPORTS_MICROMIPS As Jonas Gorske said in his patch: Disable cpu_has_mmips for everything but SEAD3 and MALTA. Most of these platforms are from before the micromips introduction, so they are very unlikely to implement it. Reduces an -Os compiled, uncompressed kernel image by 8KiB for BCM63XX. This patch taks a different approach than his, we gate the runtime test for microMIPS by the config symbol SYS_SUPPORTS_MICROMIPS. Signed-off-by: David Daney Cc: Jonas Gorski Cc: Steven J. Hill Acked-by: Steven J. Hill Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/5327/ Signed-off-by: Ralf Baechle --- arch/mips/include/asm/cpu-features.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/arch/mips/include/asm/cpu-features.h b/arch/mips/include/asm/cpu-features.h index 9609812bc8f2..8e0c125c59a1 100644 --- a/arch/mips/include/asm/cpu-features.h +++ b/arch/mips/include/asm/cpu-features.h @@ -109,7 +109,11 @@ #define cpu_has_rixi (cpu_data[0].options & MIPS_CPU_RIXI) #endif #ifndef cpu_has_mmips -#define cpu_has_mmips (cpu_data[0].options & MIPS_CPU_MICROMIPS) +# ifdef CONFIG_SYS_SUPPORTS_MICROMIPS +# define cpu_has_mmips (cpu_data[0].options & MIPS_CPU_MICROMIPS) +# else +# define cpu_has_mmips 0 +# endif #endif #ifndef cpu_has_vtag_icache #define cpu_has_vtag_icache (cpu_data[0].icache.flags & MIPS_CACHE_VTAG) From 4df715aaf566110bedb3751ed235a3bacdebbdde Mon Sep 17 00:00:00 2001 From: Florian Fainelli Date: Wed, 26 Jun 2013 18:11:56 +0000 Subject: [PATCH 0550/1048] MIPS: BMIPS: support booting from physical CPU other than 0 BMIPS43xx CPUs have two hardware threads, and on some SoCs such as 3368, the bootloader has configured the system to boot from TP1 instead of the more usual TP0. Create the physical to logical CPU mapping to cope with that, do not remap the software interrupts to be cross CPUs such that we do not have to do use the logical CPU mapping further down the code, and finally, reset the slave TP1 only if booted from TP0. Signed-off-by: Jonas Gorski Signed-off-by: Florian Fainelli Cc: linux-mips@linux-mips.org Cc: blogic@openwrt.org Cc: cernekee@gmail.com Patchwork: https://patchwork.linux-mips.org/patch/5553/ Patchwork: https://patchwork.linux-mips.org/patch/5556/ Signed-off-by: Ralf Baechle --- arch/mips/kernel/smp-bmips.c | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/arch/mips/kernel/smp-bmips.c b/arch/mips/kernel/smp-bmips.c index 8e393b8443f7..aea6c0885838 100644 --- a/arch/mips/kernel/smp-bmips.c +++ b/arch/mips/kernel/smp-bmips.c @@ -63,7 +63,7 @@ static irqreturn_t bmips_ipi_interrupt(int irq, void *dev_id); static void __init bmips_smp_setup(void) { - int i; + int i, cpu = 1, boot_cpu = 0; #if defined(CONFIG_CPU_BMIPS4350) || defined(CONFIG_CPU_BMIPS4380) /* arbitration priority */ @@ -72,13 +72,22 @@ static void __init bmips_smp_setup(void) /* NBK and weak order flags */ set_c0_brcm_config_0(0x30000); + /* Find out if we are running on TP0 or TP1 */ + boot_cpu = !!(read_c0_brcm_cmt_local() & (1 << 31)); + /* * MIPS interrupts 0,1 (SW INT 0,1) cross over to the other thread * MIPS interrupt 2 (HW INT 0) is the CPU0 L1 controller output * MIPS interrupt 3 (HW INT 1) is the CPU1 L1 controller output + * + * If booting from TP1, leave the existing CMT interrupt routing + * such that TP0 responds to SW1 and TP1 responds to SW0. */ - change_c0_brcm_cmt_intr(0xf8018000, - (0x02 << 27) | (0x03 << 15)); + if (boot_cpu == 0) + change_c0_brcm_cmt_intr(0xf8018000, + (0x02 << 27) | (0x03 << 15)); + else + change_c0_brcm_cmt_intr(0xf8018000, (0x1d << 27)); /* single core, 2 threads (2 pipelines) */ max_cpus = 2; @@ -106,9 +115,15 @@ static void __init bmips_smp_setup(void) if (!board_ebase_setup) board_ebase_setup = &bmips_ebase_setup; + __cpu_number_map[boot_cpu] = 0; + __cpu_logical_map[0] = boot_cpu; + for (i = 0; i < max_cpus; i++) { - __cpu_number_map[i] = 1; - __cpu_logical_map[i] = 1; + if (i != boot_cpu) { + __cpu_number_map[i] = cpu; + __cpu_logical_map[cpu] = i; + cpu++; + } set_cpu_possible(i, 1); set_cpu_present(i, 1); } @@ -157,7 +172,9 @@ static void bmips_boot_secondary(int cpu, struct task_struct *idle) bmips_send_ipi_single(cpu, 0); else { #if defined(CONFIG_CPU_BMIPS4350) || defined(CONFIG_CPU_BMIPS4380) - set_c0_brcm_cmt_ctrl(0x01); + /* Reset slave TP1 if booting from TP0 */ + if (cpu_logical_map(cpu) == 0) + set_c0_brcm_cmt_ctrl(0x01); #elif defined(CONFIG_CPU_BMIPS5000) if (cpu & 0x01) write_c0_brcm_action(ACTION_BOOT_THREAD(cpu)); From fc192e50f868d8f34b15a18c38407f4b9468a31d Mon Sep 17 00:00:00 2001 From: Tony Wu Date: Fri, 21 Jun 2013 10:10:46 +0000 Subject: [PATCH 0551/1048] MIPS: Cleanup indentation and whitespace Signed-off-by: Tony Wu Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/5536/ Signed-off-by: Ralf Baechle --- arch/mips/include/asm/cpu-features.h | 32 +++++++++---------- .../asm/mach-generic/kernel-entry-init.h | 4 +-- arch/mips/include/asm/processor.h | 4 +-- arch/mips/kernel/branch.c | 1 - arch/mips/kernel/unaligned.c | 1 + arch/mips/mm/page.c | 2 +- 6 files changed, 22 insertions(+), 22 deletions(-) diff --git a/arch/mips/include/asm/cpu-features.h b/arch/mips/include/asm/cpu-features.h index 8e0c125c59a1..1dc086087a72 100644 --- a/arch/mips/include/asm/cpu-features.h +++ b/arch/mips/include/asm/cpu-features.h @@ -97,13 +97,13 @@ #define cpu_has_mips16 (cpu_data[0].ases & MIPS_ASE_MIPS16) #endif #ifndef cpu_has_mdmx -#define cpu_has_mdmx (cpu_data[0].ases & MIPS_ASE_MDMX) +#define cpu_has_mdmx (cpu_data[0].ases & MIPS_ASE_MDMX) #endif #ifndef cpu_has_mips3d -#define cpu_has_mips3d (cpu_data[0].ases & MIPS_ASE_MIPS3D) +#define cpu_has_mips3d (cpu_data[0].ases & MIPS_ASE_MIPS3D) #endif #ifndef cpu_has_smartmips -#define cpu_has_smartmips (cpu_data[0].ases & MIPS_ASE_SMARTMIPS) +#define cpu_has_smartmips (cpu_data[0].ases & MIPS_ASE_SMARTMIPS) #endif #ifndef cpu_has_rixi #define cpu_has_rixi (cpu_data[0].options & MIPS_CPU_RIXI) @@ -125,7 +125,7 @@ #define cpu_has_ic_fills_f_dc (cpu_data[0].icache.flags & MIPS_CACHE_IC_F_DC) #endif #ifndef cpu_has_pindexed_dcache -#define cpu_has_pindexed_dcache (cpu_data[0].dcache.flags & MIPS_CACHE_PINDEX) +#define cpu_has_pindexed_dcache (cpu_data[0].dcache.flags & MIPS_CACHE_PINDEX) #endif #ifndef cpu_has_local_ebase #define cpu_has_local_ebase 1 @@ -162,18 +162,18 @@ #ifndef cpu_has_mips_5 # define cpu_has_mips_5 (cpu_data[0].isa_level & MIPS_CPU_ISA_V) #endif -# ifndef cpu_has_mips32r1 +#ifndef cpu_has_mips32r1 # define cpu_has_mips32r1 (cpu_data[0].isa_level & MIPS_CPU_ISA_M32R1) -# endif -# ifndef cpu_has_mips32r2 +#endif +#ifndef cpu_has_mips32r2 # define cpu_has_mips32r2 (cpu_data[0].isa_level & MIPS_CPU_ISA_M32R2) -# endif -# ifndef cpu_has_mips64r1 +#endif +#ifndef cpu_has_mips64r1 # define cpu_has_mips64r1 (cpu_data[0].isa_level & MIPS_CPU_ISA_M64R1) -# endif -# ifndef cpu_has_mips64r2 +#endif +#ifndef cpu_has_mips64r2 # define cpu_has_mips64r2 (cpu_data[0].isa_level & MIPS_CPU_ISA_M64R2) -# endif +#endif /* * Shortcuts ... @@ -195,9 +195,9 @@ * has CLO and CLZ but not DCLO nor DCLZ. For 64-bit kernels * cpu_has_clo_clz also indicates the availability of DCLO and DCLZ. */ -# ifndef cpu_has_clo_clz -# define cpu_has_clo_clz cpu_has_mips_r -# endif +#ifndef cpu_has_clo_clz +#define cpu_has_clo_clz cpu_has_mips_r +#endif #ifndef cpu_has_dsp #define cpu_has_dsp (cpu_data[0].ases & MIPS_ASE_DSP) @@ -223,7 +223,7 @@ # define cpu_has_64bits (cpu_data[0].isa_level & MIPS_CPU_ISA_64BIT) # endif # ifndef cpu_has_64bit_zero_reg -# define cpu_has_64bit_zero_reg (cpu_data[0].isa_level & MIPS_CPU_ISA_64BIT) +# define cpu_has_64bit_zero_reg (cpu_data[0].isa_level & MIPS_CPU_ISA_64BIT) # endif # ifndef cpu_has_64bit_gp_regs # define cpu_has_64bit_gp_regs 0 diff --git a/arch/mips/include/asm/mach-generic/kernel-entry-init.h b/arch/mips/include/asm/mach-generic/kernel-entry-init.h index 7e66505fa574..13b0751b010a 100644 --- a/arch/mips/include/asm/mach-generic/kernel-entry-init.h +++ b/arch/mips/include/asm/mach-generic/kernel-entry-init.h @@ -12,8 +12,8 @@ /* Intentionally empty macro, used in head.S. Override in * arch/mips/mach-xxx/kernel-entry-init.h when necessary. */ -.macro kernel_entry_setup -.endm + .macro kernel_entry_setup + .endm /* * Do SMP slave processor setup necessary before we can savely execute C code. diff --git a/arch/mips/include/asm/processor.h b/arch/mips/include/asm/processor.h index 016dc4bffc80..3605b844ad87 100644 --- a/arch/mips/include/asm/processor.h +++ b/arch/mips/include/asm/processor.h @@ -244,8 +244,8 @@ struct thread_struct { unsigned long cp0_baduaddr; /* Last kernel fault accessing USEG */ unsigned long error_code; #ifdef CONFIG_CPU_CAVIUM_OCTEON - struct octeon_cop2_state cp2 __attribute__ ((__aligned__(128))); - struct octeon_cvmseg_state cvmseg __attribute__ ((__aligned__(128))); + struct octeon_cop2_state cp2 __attribute__ ((__aligned__(128))); + struct octeon_cvmseg_state cvmseg __attribute__ ((__aligned__(128))); #endif #ifdef CONFIG_CPU_XLP struct nlm_cop2_state cp2; diff --git a/arch/mips/kernel/branch.c b/arch/mips/kernel/branch.c index 46c2ad0703a0..4d78bf445a9c 100644 --- a/arch/mips/kernel/branch.c +++ b/arch/mips/kernel/branch.c @@ -467,5 +467,4 @@ unaligned: printk("%s: unaligned epc - sending SIGBUS.\n", current->comm); force_sig(SIGBUS, current); return -EFAULT; - } diff --git a/arch/mips/kernel/unaligned.c b/arch/mips/kernel/unaligned.c index 3eaa02aa8ae0..8eaf310ffc6c 100644 --- a/arch/mips/kernel/unaligned.c +++ b/arch/mips/kernel/unaligned.c @@ -1549,6 +1549,7 @@ sigill: ("Unhandled kernel unaligned access or invalid instruction", regs); force_sig(SIGILL, current); } + asmlinkage void do_ade(struct pt_regs *regs) { enum ctx_state prev_state; diff --git a/arch/mips/mm/page.c b/arch/mips/mm/page.c index 4eb8dcfaf1ce..2c0bd580b9da 100644 --- a/arch/mips/mm/page.c +++ b/arch/mips/mm/page.c @@ -232,7 +232,7 @@ static inline void __cpuinit build_clear_pref(u32 **buf, int off) uasm_i_cache(buf, Create_Dirty_Excl_D, off, A0); } - } + } } extern u32 __clear_page_start; From 42a111797e8fa961d6168922e873d6b4be87e904 Mon Sep 17 00:00:00 2001 From: Tony Wu Date: Fri, 21 Jun 2013 10:09:23 +0000 Subject: [PATCH 0552/1048] MIPS: Fix typos and cleanup comment Signed-off-by: Tony Wu Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/5535/ Signed-off-by: Ralf Baechle --- arch/mips/include/asm/gic.h | 2 +- arch/mips/kernel/process.c | 3 --- arch/mips/mm/tlbex.c | 2 +- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/arch/mips/include/asm/gic.h b/arch/mips/include/asm/gic.h index 7153b32de18e..b2e3e93dd7d8 100644 --- a/arch/mips/include/asm/gic.h +++ b/arch/mips/include/asm/gic.h @@ -347,7 +347,7 @@ struct gic_shared_intr_map { #define GIC_CPU_INT2 2 /* . */ #define GIC_CPU_INT3 3 /* . */ #define GIC_CPU_INT4 4 /* . */ -#define GIC_CPU_INT5 5 /* Core Interrupt 5 */ +#define GIC_CPU_INT5 5 /* Core Interrupt 7 */ /* Local GIC interrupts. */ #define GIC_INT_TMR (GIC_CPU_INT5) diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c index 7d62894f7e23..ddc76103e78c 100644 --- a/arch/mips/kernel/process.c +++ b/arch/mips/kernel/process.c @@ -207,9 +207,6 @@ unsigned long __stack_chk_guard __read_mostly; EXPORT_SYMBOL(__stack_chk_guard); #endif -/* - * - */ struct mips_frame_info { void *func; unsigned long func_size; diff --git a/arch/mips/mm/tlbex.c b/arch/mips/mm/tlbex.c index 4712f3cd73b7..357e0fd65e94 100644 --- a/arch/mips/mm/tlbex.c +++ b/arch/mips/mm/tlbex.c @@ -972,7 +972,7 @@ build_get_pgde32(u32 **p, unsigned int tmp, unsigned int ptr) uasm_i_srl(p, ptr, ptr, 19); #else /* - * smp_processor_id() << 3 is stored in CONTEXT. + * smp_processor_id() << 2 is stored in CONTEXT. */ uasm_i_mfc0(p, ptr, C0_CONTEXT); UASM_i_LA_mostly(p, tmp, pgdc); From 74338805ec6869594d583535f941cb478c94dd73 Mon Sep 17 00:00:00 2001 From: David Daney Date: Fri, 24 May 2013 20:54:08 +0000 Subject: [PATCH 0553/1048] MIPS: Declare emulate_load_store_microMIPS as a static function. It is only used from within a single file, it should not be globally visible. Signed-off-by: David Daney Acked-by: Steven J. Hill Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/5325/ Signed-off-by: Ralf Baechle --- arch/mips/kernel/unaligned.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/mips/kernel/unaligned.c b/arch/mips/kernel/unaligned.c index 8eaf310ffc6c..c369a5d35527 100644 --- a/arch/mips/kernel/unaligned.c +++ b/arch/mips/kernel/unaligned.c @@ -685,7 +685,8 @@ const int reg16to32[] = { 16, 17, 2, 3, 4, 5, 6, 7 }; /* Recode table from 16-bit STORE register notation to 32-bit GPR. */ const int reg16to32st[] = { 0, 17, 2, 3, 4, 5, 6, 7 }; -void emulate_load_store_microMIPS(struct pt_regs *regs, void __user * addr) +static void emulate_load_store_microMIPS(struct pt_regs *regs, + void __user *addr) { unsigned long value; unsigned int res; From fe6d29095d4370bed3a525404c45bbd6aa7c191b Mon Sep 17 00:00:00 2001 From: David Daney Date: Fri, 24 May 2013 20:54:09 +0000 Subject: [PATCH 0554/1048] MIPS: Don't try to decode microMIPS branch instructions where they cannot exist. In mm_isBranchInstr() we can short circuit the entire function if !cpu_has_mmips. Signed-off-by: David Daney Acked-by: Steven J. Hill Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/5326/ Signed-off-by: Ralf Baechle --- arch/mips/math-emu/cp1emu.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/mips/math-emu/cp1emu.c b/arch/mips/math-emu/cp1emu.c index f03771900813..e773659ccf9f 100644 --- a/arch/mips/math-emu/cp1emu.c +++ b/arch/mips/math-emu/cp1emu.c @@ -471,6 +471,9 @@ int mm_isBranchInstr(struct pt_regs *regs, struct mm_decoded_insn dec_insn, unsigned int fcr31; unsigned int bit; + if (!cpu_has_mmips) + return 0; + switch (insn.mm_i_format.opcode) { case mm_pool32a_op: if ((insn.mm_i_format.simmediate & MM_POOL32A_MINOR_MASK) == From c6213c6c9c189aeb97010673e3129a8929d2223e Mon Sep 17 00:00:00 2001 From: "Steven J. Hill" Date: Wed, 5 Jun 2013 21:25:17 +0000 Subject: [PATCH 0555/1048] MIPS: microMIPS: Fix improper definition of ISA exception bit. The ISA exception bit selects whether exceptions are taken in classic or microMIPS mode. This bit is Config3.ISAOnExc and was improperly defined as bits 16 and 17 instead of just bit 16. A new function was added so that platforms could set this bit when running a kernel compiled with only microMIPS instructions. Signed-off-by: Steven J. Hill Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/5377/ Signed-off-by: Ralf Baechle --- arch/mips/include/asm/mipsregs.h | 2 +- arch/mips/kernel/cpu-probe.c | 3 --- arch/mips/kernel/traps.c | 9 +++++++++ 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/arch/mips/include/asm/mipsregs.h b/arch/mips/include/asm/mipsregs.h index 87e6207b05e4..fed1c3e9b486 100644 --- a/arch/mips/include/asm/mipsregs.h +++ b/arch/mips/include/asm/mipsregs.h @@ -596,7 +596,7 @@ #define MIPS_CONF3_RXI (_ULCAST_(1) << 12) #define MIPS_CONF3_ULRI (_ULCAST_(1) << 13) #define MIPS_CONF3_ISA (_ULCAST_(3) << 14) -#define MIPS_CONF3_ISA_OE (_ULCAST_(3) << 16) +#define MIPS_CONF3_ISA_OE (_ULCAST_(1) << 16) #define MIPS_CONF3_VZ (_ULCAST_(1) << 23) #define MIPS_CONF4_MMUSIZEEXT (_ULCAST_(255) << 0) diff --git a/arch/mips/kernel/cpu-probe.c b/arch/mips/kernel/cpu-probe.c index f87039dbefe9..c7b1b3c5a761 100644 --- a/arch/mips/kernel/cpu-probe.c +++ b/arch/mips/kernel/cpu-probe.c @@ -269,9 +269,6 @@ static inline unsigned int decode_config3(struct cpuinfo_mips *c) c->options |= MIPS_CPU_ULRI; if (config3 & MIPS_CONF3_ISA) c->options |= MIPS_CPU_MICROMIPS; -#ifdef CONFIG_CPU_MICROMIPS - write_c0_config3(read_c0_config3() | MIPS_CONF3_ISA_OE); -#endif if (config3 & MIPS_CONF3_VZ) c->ases |= MIPS_ASE_VZ; diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c index d97ea234e2d3..b0f3ad26063e 100644 --- a/arch/mips/kernel/traps.c +++ b/arch/mips/kernel/traps.c @@ -1878,6 +1878,15 @@ void __init trap_init(void) ebase += (read_c0_ebase() & 0x3ffff000); } + if (cpu_has_mmips) { + unsigned int config3 = read_c0_config3(); + + if (IS_ENABLED(CONFIG_CPU_MICROMIPS)) + write_c0_config3(config3 | MIPS_CONF3_ISA_OE); + else + write_c0_config3(config3 & ~MIPS_CONF3_ISA_OE); + } + if (board_ebase_setup) board_ebase_setup(); per_cpu_trap_init(true); From 271792eff2a272b527ce5aa74d499e346fb851de Mon Sep 17 00:00:00 2001 From: Markos Chandras Date: Mon, 17 Jun 2013 13:00:40 +0000 Subject: [PATCH 0556/1048] SSB: Kconfig: Amend SSB_EMBEDDED dependencies SSB_EMBEDDED needs functions from driver_pcicore which are only available if SSD_DRIVER_HOSTMODE is selected so make it depend on that symbol. Fixes the following linking problem: drivers/ssb/embedded.c:202: undefined reference to `ssb_pcicore_plat_dev_init' drivers/built-in.o: In function `ssb_pcibios_map_irq': drivers/ssb/embedded.c:247: undefined reference to `ssb_pcicore_pcibios_map_irq' Signed-off-by: Markos Chandras Acked-by: Steven J. Hill Cc: sibyte-users@bitmover.com Cc: netdev@vger.kernel.org Cc: Michael Buesch Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/5484/ Acked-by: Florian Fainelli Signed-off-by: Ralf Baechle --- drivers/ssb/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/ssb/Kconfig b/drivers/ssb/Kconfig index 5ff3a4f19443..36171fd2826b 100644 --- a/drivers/ssb/Kconfig +++ b/drivers/ssb/Kconfig @@ -144,7 +144,7 @@ config SSB_SFLASH # Assumption: We are on embedded, if we compile the MIPS core. config SSB_EMBEDDED bool - depends on SSB_DRIVER_MIPS + depends on SSB_DRIVER_MIPS && SSB_PCICORE_HOSTMODE default y config SSB_DRIVER_EXTIF From 4287f7915f33c1eb770e22589936cd9cd8a60b45 Mon Sep 17 00:00:00 2001 From: Deng-Cheng Zhu Date: Mon, 8 Apr 2013 15:53:00 +0000 Subject: [PATCH 0557/1048] MIPS: APSP: Remove Now that KSPD is gone, kspd.h has no reason to be there. Signed-off-by: Deng-Cheng Zhu Cc: Steven J. Hill Cc: linux-mips@linux-mips.org Cc: kevink@paralogos.com Cc: macro@linux-mips.org Cc: john@phrozen.org Patchwork: https://patchwork.linux-mips.org/patch/5060/ Signed-off-by: Ralf Baechle --- arch/mips/include/asm/kspd.h | 32 -------------------------------- 1 file changed, 32 deletions(-) delete mode 100644 arch/mips/include/asm/kspd.h diff --git a/arch/mips/include/asm/kspd.h b/arch/mips/include/asm/kspd.h deleted file mode 100644 index ec6832950ace..000000000000 --- a/arch/mips/include/asm/kspd.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (C) 2005 MIPS Technologies, Inc. All rights reserved. - * - * This program is free software; you can distribute 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 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., - * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA. - * - */ - -#ifndef _ASM_KSPD_H -#define _ASM_KSPD_H - -struct kspd_notifications { - void (*kspd_sp_exit)(int sp_id); - - struct list_head list; -}; - -static inline void kspd_notify(struct kspd_notifications *notify) -{ -} - -#endif From ed3ce16c3d2ba7cac321d29ec0a7d21408ea8437 Mon Sep 17 00:00:00 2001 From: Leonid Yegoshin Date: Thu, 20 Jun 2013 14:36:30 +0000 Subject: [PATCH 0558/1048] Revert "MIPS: make CAC_ADDR and UNCAC_ADDR account for PHYS_OFFSET" This reverts commit 3f4579252aa166641861a64f1c2883365ca126c2. It is invalid because the macros CAC_ADDR and UNCAC_ADDR have a kernel virtual address as an argument and also returns a kernel virtual address. Using and physical address PHYS_OFFSET is blatantly wrong for a macro common to multiple platforms. Signed-off-by: Leonid Yegoshin Acked-by: Steven J. Hill Cc: linux-mips@linux-mips.org Cc: Florian Fainelli Patchwork: https://patchwork.linux-mips.org/patch/5528/ Signed-off-by: Ralf Baechle --- arch/mips/include/asm/mach-ar7/spaces.h | 7 +++++-- arch/mips/include/asm/mach-ip28/spaces.h | 9 ++++++--- arch/mips/include/asm/page.h | 6 ++---- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/arch/mips/include/asm/mach-ar7/spaces.h b/arch/mips/include/asm/mach-ar7/spaces.h index ac28f273449c..660ab64c0fc9 100644 --- a/arch/mips/include/asm/mach-ar7/spaces.h +++ b/arch/mips/include/asm/mach-ar7/spaces.h @@ -14,8 +14,11 @@ * This handles the memory map. * We handle pages at KSEG0 for kernels with 32 bit address space. */ -#define PAGE_OFFSET 0x94000000UL -#define PHYS_OFFSET 0x14000000UL +#define PAGE_OFFSET _AC(0x94000000, UL) +#define PHYS_OFFSET _AC(0x14000000, UL) + +#define UNCAC_BASE _AC(0xb4000000, UL) /* 0xa0000000 + PHYS_OFFSET */ +#define IO_BASE UNCAC_BASE #include diff --git a/arch/mips/include/asm/mach-ip28/spaces.h b/arch/mips/include/asm/mach-ip28/spaces.h index 5edf05d9dad8..5d6a76434d00 100644 --- a/arch/mips/include/asm/mach-ip28/spaces.h +++ b/arch/mips/include/asm/mach-ip28/spaces.h @@ -11,11 +11,14 @@ #ifndef _ASM_MACH_IP28_SPACES_H #define _ASM_MACH_IP28_SPACES_H -#define CAC_BASE 0xa800000000000000 +#define CAC_BASE _AC(0xa800000000000000, UL) -#define HIGHMEM_START (~0UL) +#define HIGHMEM_START (~0UL) -#define PHYS_OFFSET _AC(0x20000000, UL) +#define PHYS_OFFSET _AC(0x20000000, UL) + +#define UNCAC_BASE _AC(0xc0000000, UL) /* 0xa0000000 + PHYS_OFFSET */ +#define IO_BASE UNCAC_BASE #include diff --git a/arch/mips/include/asm/page.h b/arch/mips/include/asm/page.h index f59552fae917..f6be4741f7e8 100644 --- a/arch/mips/include/asm/page.h +++ b/arch/mips/include/asm/page.h @@ -205,10 +205,8 @@ extern int __virt_addr_valid(const volatile void *kaddr); #define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | VM_EXEC | \ VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC) -#define UNCAC_ADDR(addr) ((addr) - PAGE_OFFSET + UNCAC_BASE + \ - PHYS_OFFSET) -#define CAC_ADDR(addr) ((addr) - UNCAC_BASE + PAGE_OFFSET - \ - PHYS_OFFSET) +#define UNCAC_ADDR(addr) ((addr) - PAGE_OFFSET + UNCAC_BASE) +#define CAC_ADDR(addr) ((addr) - UNCAC_BASE + PAGE_OFFSET) #include #include From 78276207a70e805cc022364218eefb8aa05ea647 Mon Sep 17 00:00:00 2001 From: Leonid Yegoshin Date: Thu, 20 Jun 2013 14:36:42 +0000 Subject: [PATCH 0559/1048] MIPS: Malta: Update GCMP detection. Add GCMP detection for IASim Marvell chip emulation support. Signed-off-by: Leonid Yegoshin Acked-by: Steven J. Hill Cc: linux-mips@linux-mips.org Cc: Leonid Yegoshin Patchwork: https://patchwork.linux-mips.org/patch/5529/ Signed-off-by: Ralf Baechle --- arch/mips/mti-malta/malta-int.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/arch/mips/mti-malta/malta-int.c b/arch/mips/mti-malta/malta-int.c index 0a1339ac3ec8..c69da3734699 100644 --- a/arch/mips/mti-malta/malta-int.c +++ b/arch/mips/mti-malta/malta-int.c @@ -422,8 +422,10 @@ static struct gic_intr_map gic_intr_map[GIC_NUM_INTRS] = { */ int __init gcmp_probe(unsigned long addr, unsigned long size) { - if (mips_revision_sconid != MIPS_REVISION_SCON_ROCIT) { + if ((mips_revision_sconid != MIPS_REVISION_SCON_ROCIT) && + (mips_revision_sconid != MIPS_REVISION_SCON_GT64120)) { gcmp_present = 0; + pr_debug("GCMP NOT present\n"); return gcmp_present; } From 78857614104a26cdada4c53eea104752042bf5a1 Mon Sep 17 00:00:00 2001 From: Markos Chandras Date: Mon, 17 Jun 2013 08:09:00 +0000 Subject: [PATCH 0560/1048] MIPS: Expose missing pci_io{map,unmap} declarations The GENERIC_PCI_IOMAP does not depend on CONFIG_PCI so move it to the CONFIG_MIPS symbol so it's always selected for MIPS. This fixes the missing pci_iomap declaration for MIPS. Moreover, the pci_iounmap function was not defined in the io.h header file if the CONFIG_PCI symbol is not set, but it should since MIPS is not using CONFIG_GENERIC_IOMAP. This fixes the following problem on a allyesconfig: drivers/net/ethernet/3com/3c59x.c:1031:2: error: implicit declaration of function 'pci_iomap' [-Werror=implicit-function-declaration] drivers/net/ethernet/3com/3c59x.c:1044:3: error: implicit declaration of function 'pci_iounmap' [-Werror=implicit-function-declaration] Signed-off-by: Markos Chandras Acked-by: Steven J. Hill Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/5478/ Signed-off-by: Ralf Baechle --- arch/mips/Kconfig | 2 +- arch/mips/include/asm/io.h | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig index ba63cdbd13fe..3a3e54cc7703 100644 --- a/arch/mips/Kconfig +++ b/arch/mips/Kconfig @@ -28,6 +28,7 @@ config MIPS select HAVE_GENERIC_HARDIRQS select GENERIC_IRQ_PROBE select GENERIC_IRQ_SHOW + select GENERIC_PCI_IOMAP select HAVE_ARCH_JUMP_LABEL select ARCH_WANT_IPC_PARSE_VERSION select IRQ_FORCED_THREADING @@ -2391,7 +2392,6 @@ config PCI bool "Support for PCI controller" depends on HW_HAS_PCI select PCI_DOMAINS - select GENERIC_PCI_IOMAP select NO_GENERIC_PCI_IOPORT_MAP help Find out whether you have a PCI motherboard. PCI is the name of a diff --git a/arch/mips/include/asm/io.h b/arch/mips/include/asm/io.h index b7e59853fd33..b84e1fb3fabf 100644 --- a/arch/mips/include/asm/io.h +++ b/arch/mips/include/asm/io.h @@ -170,6 +170,11 @@ static inline void * isa_bus_to_virt(unsigned long address) extern void __iomem * __ioremap(phys_t offset, phys_t size, unsigned long flags); extern void __iounmap(const volatile void __iomem *addr); +#ifndef CONFIG_PCI +struct pci_dev; +static inline void pci_iounmap(struct pci_dev *dev, void __iomem *addr) {} +#endif + static inline void __iomem * __ioremap_mode(phys_t offset, unsigned long size, unsigned long flags) { From edd4201ebc2f1a7ab2158ad91ddc0af71e58dce7 Mon Sep 17 00:00:00 2001 From: Florian Fainelli Date: Fri, 31 May 2013 13:07:44 +0000 Subject: [PATCH 0561/1048] MIPS: define write{b,w,l,q}_relaxed MIPS does define read{b,w,l,q}_relaxed but does not define their write counterparts: write{b,w,l,q}_relaxed. This patch adds the missing definitions for the write*_relaxed I/O accessors. Signed-off-by: Florian Fainelli Acked-by: John Crispin Cc: linux-mips@linux-mips.org Cc: cernekee@gmail.com Cc: jogo@openwrt.org Patchwork: https://patchwork.linux-mips.org/patch/5352/ Signed-off-by: Ralf Baechle --- arch/mips/include/asm/io.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/arch/mips/include/asm/io.h b/arch/mips/include/asm/io.h index b84e1fb3fabf..3321dd5a8872 100644 --- a/arch/mips/include/asm/io.h +++ b/arch/mips/include/asm/io.h @@ -454,6 +454,11 @@ __BUILDIO(q, u64) #define readl_relaxed readl #define readq_relaxed readq +#define writeb_relaxed writeb +#define writew_relaxed writew +#define writel_relaxed writel +#define writeq_relaxed writeq + #define readb_be(addr) \ __raw_readb((__force unsigned *)(addr)) #define readw_be(addr) \ From a068dde168e0c618e1dc2151a0922254ec3bbf04 Mon Sep 17 00:00:00 2001 From: Kevin Cernekee Date: Tue, 18 Jun 2013 08:34:31 +0000 Subject: [PATCH 0562/1048] MIPS: BCM63xx: Add SMP support to prom.c This involves two changes to the BSP code: 1) register_smp_ops() for BMIPS SMP 2) The CPU1 boot vector on some of the BCM63xx platforms conflicts with the special interrupt vector (IV). Move it to 0x8000_0380 at boot time, to resolve the conflict. Signed-off-by: Kevin Cernekee [jogo@openwrt.org: moved SMP ops registration into ifdef guard, changed ifdef guards to if (IS_ENABLED())] Signed-off-by: Jonas Gorski Cc: linux-mips@linux-mips.org Cc: John Crispin Cc: Maxime Bizon Cc: Florian Fainelli Patchwork: https://patchwork.linux-mips.org/patch/5489/ Signed-off-by: Ralf Baechle --- arch/mips/bcm63xx/prom.c | 41 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/arch/mips/bcm63xx/prom.c b/arch/mips/bcm63xx/prom.c index f3ff28f4c258..3b21454c56a0 100644 --- a/arch/mips/bcm63xx/prom.c +++ b/arch/mips/bcm63xx/prom.c @@ -8,7 +8,11 @@ #include #include +#include #include +#include +#include +#include #include #include #include @@ -54,6 +58,43 @@ void __init prom_init(void) /* do low level board init */ board_prom_init(); + + if (IS_ENABLED(CONFIG_CPU_BMIPS4350) && IS_ENABLED(CONFIG_SMP)) { + /* set up SMP */ + register_smp_ops(&bmips_smp_ops); + + /* + * BCM6328 might not have its second CPU enabled, while BCM6358 + * needs special handling for its shared TLB, so disable SMP + * for now. + */ + if (BCMCPU_IS_6328()) { + bmips_smp_enabled = 0; + } else if (BCMCPU_IS_6358()) { + bmips_smp_enabled = 0; + } + + if (!bmips_smp_enabled) + return; + + /* + * The bootloader has set up the CPU1 reset vector at + * 0xa000_0200. + * This conflicts with the special interrupt vector (IV). + * The bootloader has also set up CPU1 to respond to the wrong + * IPI interrupt. + * Here we will start up CPU1 in the background and ask it to + * reconfigure itself then go back to sleep. + */ + memcpy((void *)0xa0000200, &bmips_smp_movevec, 0x20); + __sync(); + set_c0_cause(C_SW0); + cpumask_set_cpu(1, &bmips_booted_mask); + + /* + * FIXME: we really should have some sort of hazard barrier here + */ + } } void __init prom_free_prom_memory(void) From 7ac836ce2aa7b931f6347e554cb65f9e9cc1da57 Mon Sep 17 00:00:00 2001 From: Jonas Gorski Date: Tue, 18 Jun 2013 08:34:32 +0000 Subject: [PATCH 0563/1048] MIPS: BCM63xx: Enable second core SMP on BCM6328 if available BCM6328 has a OTP which tells us if the second core is available. Signed-off-by: Jonas Gorski Cc: linux-mips@linux-mips.org Cc: John Crispin Cc: Maxime Bizon Cc: Florian Fainelli Cc: Kevin Cernekee Patchwork: https://patchwork.linux-mips.org/patch/5490/ Signed-off-by: Ralf Baechle --- arch/mips/bcm63xx/prom.c | 6 +++++- arch/mips/include/asm/mach-bcm63xx/bcm63xx_cpu.h | 2 ++ arch/mips/include/asm/mach-bcm63xx/bcm63xx_regs.h | 7 +++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/arch/mips/bcm63xx/prom.c b/arch/mips/bcm63xx/prom.c index 3b21454c56a0..8ac4e095e68e 100644 --- a/arch/mips/bcm63xx/prom.c +++ b/arch/mips/bcm63xx/prom.c @@ -69,7 +69,11 @@ void __init prom_init(void) * for now. */ if (BCMCPU_IS_6328()) { - bmips_smp_enabled = 0; + reg = bcm_readl(BCM_6328_OTP_BASE + + OTP_USER_BITS_6328_REG(3)); + + if (reg & OTP_6328_REG3_TP1_DISABLED) + bmips_smp_enabled = 0; } else if (BCMCPU_IS_6358()) { bmips_smp_enabled = 0; } diff --git a/arch/mips/include/asm/mach-bcm63xx/bcm63xx_cpu.h b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_cpu.h index 9d3c08e4a7e4..22390a2a0661 100644 --- a/arch/mips/include/asm/mach-bcm63xx/bcm63xx_cpu.h +++ b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_cpu.h @@ -296,6 +296,8 @@ enum bcm63xx_regs_set { #define BCM_6328_PCMDMAS_BASE (0xdeadbeef) #define BCM_6328_RNG_BASE (0xdeadbeef) #define BCM_6328_MISC_BASE (0xb0001800) +#define BCM_6328_OTP_BASE (0xb0000600) + /* * 6338 register sets base address */ diff --git a/arch/mips/include/asm/mach-bcm63xx/bcm63xx_regs.h b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_regs.h index 654213746b32..018628fe6f15 100644 --- a/arch/mips/include/asm/mach-bcm63xx/bcm63xx_regs.h +++ b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_regs.h @@ -1477,4 +1477,11 @@ #define PCIE_DEVICE_OFFSET 0x8000 +/************************************************************************* + * _REG relative to RSET_OTP + *************************************************************************/ + +#define OTP_USER_BITS_6328_REG(i) (0x20 + (i) * 4) +#define OTP_6328_REG3_TP1_DISABLED BIT(9) + #endif /* BCM63XX_REGS_H_ */ From 1535ac096d26538888d00881f5026cbc8b6dc20d Mon Sep 17 00:00:00 2001 From: "Steven J. Hill" Date: Thu, 27 Jun 2013 15:27:59 +0000 Subject: [PATCH 0564/1048] MIPS: SEAD3: Disable L2 cache on SEAD-3. The cores used on the SEAD-3 platform do not have L2 caches, so this option should not be turned on. Originally fixed on public 'linux-mti-3.8' release branch. Signed-off-by: Steven J. Hill Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/5559/ Signed-off-by: Ralf Baechle --- arch/mips/Kconfig | 1 - 1 file changed, 1 deletion(-) diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig index 3a3e54cc7703..567c45b33651 100644 --- a/arch/mips/Kconfig +++ b/arch/mips/Kconfig @@ -342,7 +342,6 @@ config MIPS_SEAD3 select DMA_NONCOHERENT select IRQ_CPU select IRQ_GIC - select MIPS_CPU_SCACHE select MIPS_MSC select SYS_HAS_CPU_MIPS32_R1 select SYS_HAS_CPU_MIPS32_R2 From 99e1c1398f44a056b16e78122133988c82b66d97 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Fri, 28 Jun 2013 14:49:58 +0200 Subject: [PATCH 0565/1048] IB/srp: Fail I/O fast if target offline If reconnecting failed we know that no command completion will be received anymore. Hence let the SCSI error handler fail such commands immediately. Signed-off-by: Bart Van Assche Acked-by: David Dillow Signed-off-by: Roland Dreier --- drivers/infiniband/ulp/srp/ib_srp.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c index bc13c8db7fc2..1f331011653e 100644 --- a/drivers/infiniband/ulp/srp/ib_srp.c +++ b/drivers/infiniband/ulp/srp/ib_srp.c @@ -1754,6 +1754,8 @@ static int srp_abort(struct scsi_cmnd *scmnd) SRP_TSK_ABORT_TASK) == 0 || target->transport_offline) ret = SUCCESS; + else if (target->transport_offline) + ret = FAST_IO_FAIL; else ret = FAILED; srp_free_req(target, req, scmnd, 0); From 96fc248a4c6fe1e5ffac4903b39d2dd5cbe2dc9a Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Fri, 28 Jun 2013 14:51:26 +0200 Subject: [PATCH 0566/1048] IB/srp: Maintain a single connection per I_T nexus An SRP target is required to maintain a single connection between initiator and target. This means that if the 'add_target' attribute is used to create a second connection to a target, the first connection will be logged out and that the SCSI error handler will kick in. The SCSI error handler will cause the SRP initiator to reconnect, which will cause I/O over the second connection to fail. Avoid such ping-pong behavior by disabling relogins. If reconnecting manually is necessary, that is possible by deleting and recreating an rport via sysfs. Signed-off-by: Bart Van Assche Signed-off-by: Sebastian Riemer Acked-by: David Dillow Signed-off-by: Roland Dreier --- drivers/infiniband/ulp/srp/ib_srp.c | 44 +++++++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 2 deletions(-) diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c index 1f331011653e..830ef0037087 100644 --- a/drivers/infiniband/ulp/srp/ib_srp.c +++ b/drivers/infiniband/ulp/srp/ib_srp.c @@ -542,11 +542,11 @@ static void srp_remove_work(struct work_struct *work) WARN_ON_ONCE(target->state != SRP_TARGET_REMOVED); + srp_remove_target(target); + spin_lock(&target->srp_host->target_lock); list_del(&target->list); spin_unlock(&target->srp_host->target_lock); - - srp_remove_target(target); } static void srp_rport_delete(struct srp_rport *rport) @@ -2009,6 +2009,36 @@ static struct class srp_class = { .dev_release = srp_release_dev }; +/** + * srp_conn_unique() - check whether the connection to a target is unique + */ +static bool srp_conn_unique(struct srp_host *host, + struct srp_target_port *target) +{ + struct srp_target_port *t; + bool ret = false; + + if (target->state == SRP_TARGET_REMOVED) + goto out; + + ret = true; + + spin_lock(&host->target_lock); + list_for_each_entry(t, &host->target_list, list) { + if (t != target && + target->id_ext == t->id_ext && + target->ioc_guid == t->ioc_guid && + target->initiator_ext == t->initiator_ext) { + ret = false; + break; + } + } + spin_unlock(&host->target_lock); + +out: + return ret; +} + /* * Target ports are added by writing * @@ -2265,6 +2295,16 @@ static ssize_t srp_create_target(struct device *dev, if (ret) goto err; + if (!srp_conn_unique(target->srp_host, target)) { + shost_printk(KERN_INFO, target->scsi_host, + PFX "Already connected to target port with id_ext=%016llx;ioc_guid=%016llx;initiator_ext=%016llx\n", + be64_to_cpu(target->id_ext), + be64_to_cpu(target->ioc_guid), + be64_to_cpu(target->initiator_ext)); + ret = -EEXIST; + goto err; + } + if (!host->srp_dev->fmr_pool && !target->allow_ext_sg && target->cmd_sg_cnt < target->sg_tablesize) { pr_warn("No FMR pool and no external indirect descriptors, limiting sg_tablesize to cmd_sg_cnt\n"); From 4b5e5f41c8e114bb856347134657eb9e1cccc822 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Fri, 28 Jun 2013 14:57:42 +0200 Subject: [PATCH 0567/1048] IB/srp: Make HCA completion vector configurable Several InfiniBand HCAs allow configuring the completion vector per CQ. This allows spreading the workload created by IB completion interrupts over multiple MSI-X vectors and hence over multiple CPU cores. In other words, configuring the completion vector properly not only allows reducing latency on an initiator connected to multiple SRP targets but also allows improving throughput. Signed-off-by: Bart Van Assche Acked-by: David Dillow Signed-off-by: Roland Dreier --- Documentation/ABI/stable/sysfs-driver-ib_srp | 7 ++++++ drivers/infiniband/ulp/srp/ib_srp.c | 26 ++++++++++++++++++-- drivers/infiniband/ulp/srp/ib_srp.h | 1 + 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/Documentation/ABI/stable/sysfs-driver-ib_srp b/Documentation/ABI/stable/sysfs-driver-ib_srp index 481aae95c7d1..5c53d28f775c 100644 --- a/Documentation/ABI/stable/sysfs-driver-ib_srp +++ b/Documentation/ABI/stable/sysfs-driver-ib_srp @@ -54,6 +54,13 @@ Description: Interface for making ib_srp connect to a new target. ib_srp. Specifying a value that exceeds cmd_sg_entries is only safe with partial memory descriptor list support enabled (allow_ext_sg=1). + * comp_vector, a number in the range 0..n-1 specifying the + MSI-X completion vector. Some HCA's allocate multiple (n) + MSI-X vectors per HCA port. If the IRQ affinity masks of + these interrupts have been configured such that each MSI-X + interrupt is handled by a different CPU then the comp_vector + parameter can be used to spread the SRP completion workload + over multiple CPU's. What: /sys/class/infiniband_srp/srp--/ibdev Date: January 2, 2006 diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c index 830ef0037087..9b30366cb017 100644 --- a/drivers/infiniband/ulp/srp/ib_srp.c +++ b/drivers/infiniband/ulp/srp/ib_srp.c @@ -231,14 +231,16 @@ static int srp_create_target_ib(struct srp_target_port *target) return -ENOMEM; recv_cq = ib_create_cq(target->srp_host->srp_dev->dev, - srp_recv_completion, NULL, target, SRP_RQ_SIZE, 0); + srp_recv_completion, NULL, target, SRP_RQ_SIZE, + target->comp_vector); if (IS_ERR(recv_cq)) { ret = PTR_ERR(recv_cq); goto err; } send_cq = ib_create_cq(target->srp_host->srp_dev->dev, - srp_send_completion, NULL, target, SRP_SQ_SIZE, 0); + srp_send_completion, NULL, target, SRP_SQ_SIZE, + target->comp_vector); if (IS_ERR(send_cq)) { ret = PTR_ERR(send_cq); goto err_recv_cq; @@ -1898,6 +1900,14 @@ static ssize_t show_local_ib_device(struct device *dev, return sprintf(buf, "%s\n", target->srp_host->srp_dev->dev->name); } +static ssize_t show_comp_vector(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct srp_target_port *target = host_to_target(class_to_shost(dev)); + + return sprintf(buf, "%d\n", target->comp_vector); +} + static ssize_t show_cmd_sg_entries(struct device *dev, struct device_attribute *attr, char *buf) { @@ -1924,6 +1934,7 @@ static DEVICE_ATTR(req_lim, S_IRUGO, show_req_lim, NULL); static DEVICE_ATTR(zero_req_lim, S_IRUGO, show_zero_req_lim, NULL); static DEVICE_ATTR(local_ib_port, S_IRUGO, show_local_ib_port, NULL); static DEVICE_ATTR(local_ib_device, S_IRUGO, show_local_ib_device, NULL); +static DEVICE_ATTR(comp_vector, S_IRUGO, show_comp_vector, NULL); static DEVICE_ATTR(cmd_sg_entries, S_IRUGO, show_cmd_sg_entries, NULL); static DEVICE_ATTR(allow_ext_sg, S_IRUGO, show_allow_ext_sg, NULL); @@ -1938,6 +1949,7 @@ static struct device_attribute *srp_host_attrs[] = { &dev_attr_zero_req_lim, &dev_attr_local_ib_port, &dev_attr_local_ib_device, + &dev_attr_comp_vector, &dev_attr_cmd_sg_entries, &dev_attr_allow_ext_sg, NULL @@ -2061,6 +2073,7 @@ enum { SRP_OPT_CMD_SG_ENTRIES = 1 << 9, SRP_OPT_ALLOW_EXT_SG = 1 << 10, SRP_OPT_SG_TABLESIZE = 1 << 11, + SRP_OPT_COMP_VECTOR = 1 << 12, SRP_OPT_ALL = (SRP_OPT_ID_EXT | SRP_OPT_IOC_GUID | SRP_OPT_DGID | @@ -2081,6 +2094,7 @@ static const match_table_t srp_opt_tokens = { { SRP_OPT_CMD_SG_ENTRIES, "cmd_sg_entries=%u" }, { SRP_OPT_ALLOW_EXT_SG, "allow_ext_sg=%u" }, { SRP_OPT_SG_TABLESIZE, "sg_tablesize=%u" }, + { SRP_OPT_COMP_VECTOR, "comp_vector=%u" }, { SRP_OPT_ERR, NULL } }; @@ -2236,6 +2250,14 @@ static int srp_parse_options(const char *buf, struct srp_target_port *target) target->sg_tablesize = token; break; + case SRP_OPT_COMP_VECTOR: + if (match_int(args, &token) || token < 0) { + pr_warn("bad comp_vector parameter '%s'\n", p); + goto out; + } + target->comp_vector = token; + break; + default: pr_warn("unknown parameter or missing value '%s' in target creation request\n", p); diff --git a/drivers/infiniband/ulp/srp/ib_srp.h b/drivers/infiniband/ulp/srp/ib_srp.h index 66fbedda4571..e641088c14dc 100644 --- a/drivers/infiniband/ulp/srp/ib_srp.h +++ b/drivers/infiniband/ulp/srp/ib_srp.h @@ -156,6 +156,7 @@ struct srp_target_port { char target_name[32]; unsigned int scsi_id; unsigned int sg_tablesize; + int comp_vector; struct ib_sa_path_rec path; __be16 orig_dgid[8]; From e8ca413558de8ea235a1223074c4ed09616b9034 Mon Sep 17 00:00:00 2001 From: Vu Pham Date: Fri, 28 Jun 2013 14:59:08 +0200 Subject: [PATCH 0568/1048] IB/srp: Bump driver version and release date Signed-off-by: Vu Pham Signed-off-by: Bart Van Assche Signed-off-by: Roland Dreier --- drivers/infiniband/ulp/srp/ib_srp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c index 9b30366cb017..9d8b46eafdb2 100644 --- a/drivers/infiniband/ulp/srp/ib_srp.c +++ b/drivers/infiniband/ulp/srp/ib_srp.c @@ -53,8 +53,8 @@ #define DRV_NAME "ib_srp" #define PFX DRV_NAME ": " -#define DRV_VERSION "0.2" -#define DRV_RELDATE "November 1, 2005" +#define DRV_VERSION "1.0" +#define DRV_RELDATE "July 1, 2013" MODULE_AUTHOR("Roland Dreier"); MODULE_DESCRIPTION("InfiniBand SCSI RDMA Protocol initiator " From 1eb14ea1e6bcd11d6d0ba937fc39808bb4d3453e Mon Sep 17 00:00:00 2001 From: Magnus Damm Date: Mon, 1 Jul 2013 20:48:07 +0900 Subject: [PATCH 0569/1048] ARM: shmobile: emev2 GIO3 resource fix Fix GIO3 base addresses for EMEV2. This bug was introduced by 088efd9273b5076a0aead479aa31f1066d182b3e ("mach-shmobile: Emma Mobile EV2 GPIO support V3") which was included in v3.5. Signed-off-by: Magnus Damm Signed-off-by: Simon Horman Cc: stable@vger.kernel.org --- arch/arm/mach-shmobile/setup-emev2.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/arm/mach-shmobile/setup-emev2.c b/arch/arm/mach-shmobile/setup-emev2.c index 899a86c31ec9..1ccddd228112 100644 --- a/arch/arm/mach-shmobile/setup-emev2.c +++ b/arch/arm/mach-shmobile/setup-emev2.c @@ -287,14 +287,14 @@ static struct gpio_em_config gio3_config = { static struct resource gio3_resources[] = { [0] = { .name = "GIO_096", - .start = 0xe0050100, - .end = 0xe005012b, + .start = 0xe0050180, + .end = 0xe00501ab, .flags = IORESOURCE_MEM, }, [1] = { .name = "GIO_096", - .start = 0xe0050140, - .end = 0xe005015f, + .start = 0xe00501c0, + .end = 0xe00501df, .flags = IORESOURCE_MEM, }, [2] = { From 0c1dcfd53b1066c411d3885cf8156abf59694360 Mon Sep 17 00:00:00 2001 From: Sebastian Hesselbarth Date: Tue, 11 Jun 2013 08:38:50 +0200 Subject: [PATCH 0570/1048] clocksource: Add Marvell Orion SoC timer This patch add a DT enabled driver for timers found on Marvell Orion SoCs (Kirkwood, Dove, Orion5x, and Discovery Innovation). It installs a free- running clocksource on timer0 and a clockevent source on timer1. Corresponding device tree documentation is also added. Signed-off-by: Sebastian Hesselbarth Signed-off-by: Daniel Lezcano Tested-by: Ezequiel Garcia Tested-by: Andrew Lunn --- .../bindings/timer/marvell,orion-timer.txt | 17 ++ drivers/clocksource/Kconfig | 5 + drivers/clocksource/Makefile | 1 + drivers/clocksource/time-orion.c | 150 ++++++++++++++++++ 4 files changed, 173 insertions(+) create mode 100644 Documentation/devicetree/bindings/timer/marvell,orion-timer.txt create mode 100644 drivers/clocksource/time-orion.c diff --git a/Documentation/devicetree/bindings/timer/marvell,orion-timer.txt b/Documentation/devicetree/bindings/timer/marvell,orion-timer.txt new file mode 100644 index 000000000000..62bb8260cf6a --- /dev/null +++ b/Documentation/devicetree/bindings/timer/marvell,orion-timer.txt @@ -0,0 +1,17 @@ +Marvell Orion SoC timer + +Required properties: +- compatible: shall be "marvell,orion-timer" +- reg: base address of the timer register starting with TIMERS CONTROL register +- interrupt-parent: phandle of the bridge interrupt controller +- interrupts: should contain the interrupts for Timer0 and Timer1 +- clocks: phandle of timer reference clock (tclk) + +Example: + timer: timer { + compatible = "marvell,orion-timer"; + reg = <0x20300 0x20>; + interrupt-parent = <&bridge_intc>; + interrupts = <1>, <2>; + clocks = <&core_clk 0>; + }; diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig index 0a04257edf65..c082e3e4bd0a 100644 --- a/drivers/clocksource/Kconfig +++ b/drivers/clocksource/Kconfig @@ -25,6 +25,11 @@ config DW_APB_TIMER_OF config ARMADA_370_XP_TIMER bool +config ORION_TIMER + select CLKSRC_OF + select CLKSRC_MMIO + bool + config SUN4I_TIMER bool diff --git a/drivers/clocksource/Makefile b/drivers/clocksource/Makefile index 9ba8b4d867e3..49bea7fad85c 100644 --- a/drivers/clocksource/Makefile +++ b/drivers/clocksource/Makefile @@ -15,6 +15,7 @@ obj-$(CONFIG_DW_APB_TIMER_OF) += dw_apb_timer_of.o obj-$(CONFIG_CLKSRC_NOMADIK_MTU) += nomadik-mtu.o obj-$(CONFIG_CLKSRC_DBX500_PRCMU) += clksrc-dbx500-prcmu.o obj-$(CONFIG_ARMADA_370_XP_TIMER) += time-armada-370-xp.o +obj-$(CONFIG_ORION_TIMER) += time-orion.o obj-$(CONFIG_ARCH_BCM2835) += bcm2835_timer.o obj-$(CONFIG_ARCH_MARCO) += timer-marco.o obj-$(CONFIG_ARCH_MXS) += mxs_timer.o diff --git a/drivers/clocksource/time-orion.c b/drivers/clocksource/time-orion.c new file mode 100644 index 000000000000..ecbeb6810215 --- /dev/null +++ b/drivers/clocksource/time-orion.c @@ -0,0 +1,150 @@ +/* + * Marvell Orion SoC timer handling. + * + * Sebastian Hesselbarth + * + * This file is licensed under the terms of the GNU General Public + * License version 2. This program is licensed "as is" without any + * warranty of any kind, whether express or implied. + * + * Timer 0 is used as free-running clocksource, while timer 1 is + * used as clock_event_device. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define TIMER_CTRL 0x00 +#define TIMER0_EN BIT(0) +#define TIMER0_RELOAD_EN BIT(1) +#define TIMER1_EN BIT(2) +#define TIMER1_RELOAD_EN BIT(3) +#define TIMER0_RELOAD 0x10 +#define TIMER0_VAL 0x14 +#define TIMER1_RELOAD 0x18 +#define TIMER1_VAL 0x1c + +#define ORION_ONESHOT_MIN 1 +#define ORION_ONESHOT_MAX 0xfffffffe + +static void __iomem *timer_base; +static DEFINE_SPINLOCK(timer_ctrl_lock); + +/* + * Thread-safe access to TIMER_CTRL register + * (shared with watchdog timer) + */ +void orion_timer_ctrl_clrset(u32 clr, u32 set) +{ + spin_lock(&timer_ctrl_lock); + writel((readl(timer_base + TIMER_CTRL) & ~clr) | set, + timer_base + TIMER_CTRL); + spin_unlock(&timer_ctrl_lock); +} +EXPORT_SYMBOL(orion_timer_ctrl_clrset); + +/* + * Free-running clocksource handling. + */ +static u32 notrace orion_read_sched_clock(void) +{ + return ~readl(timer_base + TIMER0_VAL); +} + +/* + * Clockevent handling. + */ +static u32 ticks_per_jiffy; + +static int orion_clkevt_next_event(unsigned long delta, + struct clock_event_device *dev) +{ + /* setup and enable one-shot timer */ + writel(delta, timer_base + TIMER1_VAL); + orion_timer_ctrl_clrset(TIMER1_RELOAD_EN, TIMER1_EN); + + return 0; +} + +static void orion_clkevt_mode(enum clock_event_mode mode, + struct clock_event_device *dev) +{ + if (mode == CLOCK_EVT_MODE_PERIODIC) { + /* setup and enable periodic timer at 1/HZ intervals */ + writel(ticks_per_jiffy - 1, timer_base + TIMER1_RELOAD); + writel(ticks_per_jiffy - 1, timer_base + TIMER1_VAL); + orion_timer_ctrl_clrset(0, TIMER1_RELOAD_EN | TIMER1_EN); + } else { + /* disable timer */ + orion_timer_ctrl_clrset(TIMER1_RELOAD_EN | TIMER1_EN, 0); + } +} + +static struct clock_event_device orion_clkevt = { + .name = "orion_event", + .features = CLOCK_EVT_FEAT_ONESHOT | CLOCK_EVT_FEAT_PERIODIC, + .shift = 32, + .rating = 300, + .set_next_event = orion_clkevt_next_event, + .set_mode = orion_clkevt_mode, +}; + +static irqreturn_t orion_clkevt_irq_handler(int irq, void *dev_id) +{ + orion_clkevt.event_handler(&orion_clkevt); + return IRQ_HANDLED; +} + +static struct irqaction orion_clkevt_irq = { + .name = "orion_event", + .flags = IRQF_TIMER, + .handler = orion_clkevt_irq_handler, +}; + +static void __init orion_timer_init(struct device_node *np) +{ + struct clk *clk; + int irq; + + /* timer registers are shared with watchdog timer */ + timer_base = of_iomap(np, 0); + if (!timer_base) + panic("%s: unable to map resource\n", np->name); + + clk = of_clk_get(np, 0); + if (IS_ERR(clk)) + panic("%s: unable to get clk\n", np->name); + clk_prepare_enable(clk); + + /* we are only interested in timer1 irq */ + irq = irq_of_parse_and_map(np, 1); + if (irq <= 0) + panic("%s: unable to parse timer1 irq\n", np->name); + + /* setup timer0 as free-running clocksource */ + writel(~0, timer_base + TIMER0_VAL); + writel(~0, timer_base + TIMER0_RELOAD); + orion_timer_ctrl_clrset(0, TIMER0_RELOAD_EN | TIMER0_EN); + clocksource_mmio_init(timer_base + TIMER0_VAL, "orion_clocksource", + clk_get_rate(clk), 300, 32, + clocksource_mmio_readl_down); + setup_sched_clock(orion_read_sched_clock, 32, clk_get_rate(clk)); + + /* setup timer1 as clockevent timer */ + if (setup_irq(irq, &orion_clkevt_irq)) + panic("%s: unable to setup irq\n", np->name); + + ticks_per_jiffy = (clk_get_rate(clk) + HZ/2) / HZ; + orion_clkevt.cpumask = cpumask_of(0); + orion_clkevt.irq = irq; + clockevents_config_and_register(&orion_clkevt, clk_get_rate(clk), + ORION_ONESHOT_MIN, ORION_ONESHOT_MAX); +} +CLOCKSOURCE_OF_DECLARE(orion_timer, "marvell,orion-timer", orion_timer_init); From 7aa2d05299f92ab73591988ab514f0ddc98138f3 Mon Sep 17 00:00:00 2001 From: Markos Chandras Date: Tue, 2 Jul 2013 09:13:44 +0000 Subject: [PATCH 0571/1048] MIPS: BCM63xx: CLK: Add dummy clk_{set,round}_rate() functions Several drivers use the clk_{set,round}_rate() functions that need to be defined in the platform's clock code. The Broadcom BCM63xx platform hardcodes the clock rate so we create new clk_{set,round}_rate() functions which just return 0 like those in include/linux/clk.h for the common clock framework do. Also fixes the following build problem on a randconfig: drivers/built-in.o: In function `nop_usb_xceiv_probe': phy-nop.c:(.text+0x3ec26c): undefined reference to `clk_set_rate' Signed-off-by: Markos Chandras Acked-by: Steven J. Hill Acked-by: Florian Fainelli Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/5580/ Signed-off-by: Ralf Baechle --- arch/mips/bcm63xx/clk.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/arch/mips/bcm63xx/clk.c b/arch/mips/bcm63xx/clk.c index fda2690a8ef1..43da4ae04cc2 100644 --- a/arch/mips/bcm63xx/clk.c +++ b/arch/mips/bcm63xx/clk.c @@ -318,6 +318,18 @@ unsigned long clk_get_rate(struct clk *clk) EXPORT_SYMBOL(clk_get_rate); +int clk_set_rate(struct clk *clk, unsigned long rate) +{ + return 0; +} +EXPORT_SYMBOL_GPL(clk_set_rate); + +long clk_round_rate(struct clk *clk, unsigned long rate) +{ + return 0; +} +EXPORT_SYMBOL_GPL(clk_round_rate); + struct clk *clk_get(struct device *dev, const char *id) { if (!strcmp(id, "enet0")) From 704e6460ab75af0735b1ca7c0dcaa4ff0a4001b2 Mon Sep 17 00:00:00 2001 From: Markos Chandras Date: Fri, 28 Jun 2013 11:25:27 +0000 Subject: [PATCH 0572/1048] MIPS: Kconfig: Add missing MODULES dependency to VPE_LOADER The vpe.c code uses the 'struct module' which is only available if CONFIG_MODULES is selected. Also fixes the following build problem on a lantiq allmodconfig: In file included from arch/mips/kernel/vpe.c:41:0: include/linux/moduleloader.h: In function 'apply_relocate': include/linux/moduleloader.h:48:63: error: dereferencing pointer to incomplete type include/linux/moduleloader.h: In function 'apply_relocate_add': include/linux/moduleloader.h:70:63: error: dereferencing pointer to incomplete type Signed-off-by: Markos Chandras Reviewed-by: James Hogan Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/5562/ Signed-off-by: Ralf Baechle --- arch/mips/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig index 567c45b33651..1e7a40e00bc0 100644 --- a/arch/mips/Kconfig +++ b/arch/mips/Kconfig @@ -1929,7 +1929,7 @@ config MIPS_MT_FPAFF config MIPS_VPE_LOADER bool "VPE loader support." - depends on SYS_SUPPORTS_MULTITHREADING + depends on SYS_SUPPORTS_MULTITHREADING && MODULES select CPU_MIPSR2_IRQ_VI select CPU_MIPSR2_IRQ_EI select MIPS_MT From d96760f98e8eb9d35a2eace586d8b93b0e58cbd5 Mon Sep 17 00:00:00 2001 From: Girish K S Date: Thu, 27 Jun 2013 12:26:53 +0530 Subject: [PATCH 0573/1048] spi: s3c64xx: add missing check for polling mode After the patch "spi/s3c64xx: Fix non-dmaengine usage" with commit id 563b444e33810f3120838620c990480304e24e63 submitted by Mark Brown, the spi device detection in polling mode breaks. This revealed the missing check for polling during dma prepare. This patch adds the missing check. Signed-off-by: Girish K S Signed-off-by: Mark Brown --- drivers/spi/spi-s3c64xx.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c index eb53df27e7ea..63e2070c6c14 100644 --- a/drivers/spi/spi-s3c64xx.c +++ b/drivers/spi/spi-s3c64xx.c @@ -434,6 +434,9 @@ static int s3c64xx_spi_prepare_transfer(struct spi_master *spi) dma_cap_mask_t mask; int ret; + if (is_polling(sdd)) + return 0; + dma_cap_zero(mask); dma_cap_set(DMA_SLAVE, mask); From 1c297a66654a3295ae87e2b7f3724d214eb2b5ec Mon Sep 17 00:00:00 2001 From: Alexandre Belloni Date: Mon, 1 Jul 2013 15:20:00 +0100 Subject: [PATCH 0574/1048] iio: Fix iio_channel_has_info Since the info_mask split, iio_channel_has_info() is not working correctly. info_mask_separate and info_mask_shared_by_type, it is not possible to compare them directly with the iio_chan_info_enum enum. Correct that bit using the BIT() macro. Cc: # 3.10.x Signed-off-by: Alexandre Belloni Signed-off-by: Jonathan Cameron --- include/linux/iio/iio.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/linux/iio/iio.h b/include/linux/iio/iio.h index 8d171f427632..3d35b7023591 100644 --- a/include/linux/iio/iio.h +++ b/include/linux/iio/iio.h @@ -211,8 +211,8 @@ struct iio_chan_spec { static inline bool iio_channel_has_info(const struct iio_chan_spec *chan, enum iio_chan_info_enum type) { - return (chan->info_mask_separate & type) | - (chan->info_mask_shared_by_type & type); + return (chan->info_mask_separate & BIT(type)) | + (chan->info_mask_shared_by_type & BIT(type)); } #define IIO_ST(si, rb, sb, sh) \ From 9cc98f01e270b206a8a513418afd81b23535bd10 Mon Sep 17 00:00:00 2001 From: Olof Johansson Date: Tue, 25 Jun 2013 18:36:05 -0700 Subject: [PATCH 0575/1048] ARM: Make multi_v7_defconfig usable on hardware This updates multi_v7_defconfig to boot on at least Tegra2 Seaboard and Panda ES. I lack working hardware for most of the platforms that were enabled to compare with, so I could only verify those two for now. Still, I enabled all of the available ones for build coverage purposes. Beyond base platforms, things like PRINTK_TIME, filesystems, MMC, USB, INET and UNIX networking was enabled. I'm sure we'll keep adding more over time, but this gets us off the ground for semi-regular boot testing. Acked-by: Tony Lindgren Acked-by: Stephen Warren Signed-off-by: Olof Johansson --- arch/arm/configs/multi_v7_defconfig | 121 +++++++++++++++++++++------- 1 file changed, 93 insertions(+), 28 deletions(-) diff --git a/arch/arm/configs/multi_v7_defconfig b/arch/arm/configs/multi_v7_defconfig index 340d550c12b0..6d8d3c456b5f 100644 --- a/arch/arm/configs/multi_v7_defconfig +++ b/arch/arm/configs/multi_v7_defconfig @@ -1,88 +1,153 @@ -CONFIG_EXPERIMENTAL=y +CONFIG_IRQ_DOMAIN_DEBUG=y CONFIG_NO_HZ=y CONFIG_HIGH_RES_TIMERS=y CONFIG_BLK_DEV_INITRD=y CONFIG_ARCH_MVEBU=y CONFIG_MACH_ARMADA_370=y -CONFIG_ARCH_SIRF=y CONFIG_MACH_ARMADA_XP=y +CONFIG_ARCH_BCM=y +CONFIG_GPIO_PCA953X=y CONFIG_ARCH_HIGHBANK=y +CONFIG_ARCH_KEYSTONE=y +CONFIG_ARCH_MXC=y +CONFIG_MACH_IMX51_DT=y +CONFIG_SOC_IMX53=y +CONFIG_SOC_IMX6Q=y +CONFIG_SOC_IMX6SL=y +CONFIG_SOC_VF610=y +CONFIG_ARCH_OMAP2PLUS=y +CONFIG_SOC_OMAP5=y +CONFIG_SOC_AM43XX=y +CONFIG_ARCH_ROCKCHIP=y CONFIG_ARCH_SOCFPGA=y -CONFIG_ARCH_SUNXI=y -CONFIG_ARCH_WM8850=y -# CONFIG_ARCH_VEXPRESS_CORTEX_A5_A9_ERRATA is not set -CONFIG_ARCH_ZYNQ=y -CONFIG_ARM_ERRATA_754322=y CONFIG_PLAT_SPEAR=y CONFIG_ARCH_SPEAR13XX=y CONFIG_MACH_SPEAR1310=y CONFIG_MACH_SPEAR1340=y +CONFIG_ARCH_STI=y +CONFIG_ARCH_SUNXI=y +CONFIG_ARCH_SIRF=y +CONFIG_ARCH_TEGRA=y +CONFIG_ARCH_TEGRA_2x_SOC=y +CONFIG_ARCH_TEGRA_3x_SOC=y +CONFIG_ARCH_TEGRA_114_SOC=y +CONFIG_TEGRA_PCI=y +CONFIG_TEGRA_EMC_SCALING_ENABLE=y +CONFIG_ARCH_U8500=y +CONFIG_MACH_SNOWBALL=y +CONFIG_MACH_UX500_DT=y +CONFIG_ARCH_VEXPRESS=y +CONFIG_ARCH_VEXPRESS_CA9X4=y +CONFIG_ARCH_VIRT=y +CONFIG_ARCH_WM8850=y +CONFIG_ARCH_ZYNQ=y CONFIG_SMP=y -CONFIG_ARM_ARCH_TIMER=y -CONFIG_AEABI=y -CONFIG_HIGHMEM=y CONFIG_HIGHPTE=y CONFIG_ARM_APPENDED_DTB=y -CONFIG_VFP=y -CONFIG_NEON=y CONFIG_NET=y +CONFIG_UNIX=y +CONFIG_INET=y +CONFIG_DEVTMPFS=y +CONFIG_DEVTMPFS_MOUNT=y CONFIG_BLK_DEV_SD=y CONFIG_ATA=y +CONFIG_SATA_AHCI_PLATFORM=y CONFIG_SATA_HIGHBANK=y CONFIG_SATA_MV=y -CONFIG_SATA_AHCI_PLATFORM=y CONFIG_NETDEVICES=y -CONFIG_SUN4I_EMAC=y CONFIG_NET_CALXEDA_XGMAC=y CONFIG_SMSC911X=y CONFIG_STMMAC_ETH=y +CONFIG_KEYBOARD_SPEAR=y CONFIG_SERIO_AMBAKMI=y -CONFIG_MDIO_SUN4I=y CONFIG_SERIAL_8250=y CONFIG_SERIAL_8250_CONSOLE=y CONFIG_SERIAL_8250_DW=y -CONFIG_KEYBOARD_SPEAR=y CONFIG_SERIAL_AMBA_PL011=y CONFIG_SERIAL_AMBA_PL011_CONSOLE=y -CONFIG_SERIAL_OF_PLATFORM=y CONFIG_SERIAL_SIRFSOC=y CONFIG_SERIAL_SIRFSOC_CONSOLE=y +CONFIG_SERIAL_TEGRA=y CONFIG_SERIAL_VT8500=y CONFIG_SERIAL_VT8500_CONSOLE=y +CONFIG_SERIAL_OF_PLATFORM=y +CONFIG_SERIAL_OMAP=y +CONFIG_SERIAL_OMAP_CONSOLE=y CONFIG_SERIAL_XILINX_PS_UART=y CONFIG_SERIAL_XILINX_PS_UART_CONSOLE=y -CONFIG_IPMI_HANDLER=y -CONFIG_IPMI_SI=y -CONFIG_I2C=y CONFIG_I2C_DESIGNWARE_PLATFORM=y CONFIG_I2C_SIRF=y +CONFIG_I2C_TEGRA=y CONFIG_SPI=y CONFIG_SPI_PL022=y CONFIG_SPI_SIRF=y -CONFIG_GPIO_PL061=y -CONFIG_FB=y +CONFIG_SPI_TEGRA114=y +CONFIG_SPI_TEGRA20_SLINK=y +CONFIG_PINCTRL_SINGLE=y +CONFIG_GPIO_GENERIC_PLATFORM=y +CONFIG_GPIO_TWL4030=y +CONFIG_REGULATOR_GPIO=y +CONFIG_REGULATOR_AB8500=y +CONFIG_REGULATOR_TPS51632=y +CONFIG_REGULATOR_TPS62360=y +CONFIG_REGULATOR_TWL4030=y +CONFIG_REGULATOR_VEXPRESS=y +CONFIG_DRM=y +CONFIG_TEGRA_HOST1X=y +CONFIG_DRM_TEGRA=y CONFIG_FB_ARMCLCD=y CONFIG_FB_WM8505=y -CONFIG_FRAMEBUFFER_CONSOLE=y +CONFIG_FB_SIMPLE=y CONFIG_USB=y +CONFIG_USB_XHCI_HCD=y +CONFIG_USB_EHCI_HCD=y +CONFIG_USB_EHCI_MXC=y +CONFIG_USB_EHCI_TEGRA=y +CONFIG_USB_EHCI_HCD_PLATFORM=y CONFIG_USB_ISP1760_HCD=y CONFIG_USB_STORAGE=y +CONFIG_AB8500_USB=y +CONFIG_NOP_USB_XCEIV=y +CONFIG_OMAP_USB2=y +CONFIG_OMAP_USB3=y +CONFIG_SAMSUNG_USB2PHY=y +CONFIG_SAMSUNG_USB3PHY=y +CONFIG_USB_GPIO_VBUS=y +CONFIG_USB_ISP1301=y +CONFIG_USB_MXS_PHY=y CONFIG_MMC=y CONFIG_MMC_ARMMMCI=y CONFIG_MMC_SDHCI=y CONFIG_MMC_SDHCI_PLTFM=y +CONFIG_MMC_SDHCI_TEGRA=y CONFIG_MMC_SDHCI_SPEAR=y -CONFIG_MMC_WMT=y +CONFIG_MMC_OMAP=y +CONFIG_MMC_OMAP_HS=y CONFIG_EDAC=y CONFIG_EDAC_MM_EDAC=y CONFIG_EDAC_HIGHBANK_MC=y CONFIG_EDAC_HIGHBANK_L2=y CONFIG_RTC_CLASS=y +CONFIG_RTC_DRV_TWL4030=y CONFIG_RTC_DRV_PL031=y CONFIG_RTC_DRV_VT8500=y +CONFIG_RTC_DRV_TEGRA=y +CONFIG_DMADEVICES=y +CONFIG_DW_DMAC=y +CONFIG_TEGRA20_APB_DMA=y +CONFIG_STE_DMA40=y +CONFIG_SIRF_DMA=y +CONFIG_TI_EDMA=y +CONFIG_PL330_DMA=y +CONFIG_IMX_SDMA=y +CONFIG_IMX_DMA=y +CONFIG_MXS_DMA=y +CONFIG_DMA_OMAP=y CONFIG_PWM=y CONFIG_PWM_VT8500=y -CONFIG_DMADEVICES=y -CONFIG_PL330_DMA=y -CONFIG_SIRF_DMA=y -CONFIG_DW_DMAC=y +CONFIG_EXT4_FS=y +CONFIG_TMPFS=y +CONFIG_PRINTK_TIME=y +CONFIG_DEBUG_FS=y +CONFIG_DEBUG_KERNEL=y +CONFIG_LOCKUP_DETECTOR=y From 57691a1e27a7d1995775b7e25e2ec0d7a415edc0 Mon Sep 17 00:00:00 2001 From: Dmitry Torokhov Date: Thu, 27 Jun 2013 23:29:25 -0700 Subject: [PATCH 0576/1048] Input: ads7846 - make sure we do not change platform data Let's declare platform data a const pointer so that we don't accitentally change it. Also fetch it with dev_get_platdata(). Signed-off-by: Dmitry Torokhov --- drivers/input/touchscreen/ads7846.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c index 84ccf140c1bb..5ff041995198 100644 --- a/drivers/input/touchscreen/ads7846.c +++ b/drivers/input/touchscreen/ads7846.c @@ -961,9 +961,9 @@ static int ads7846_resume(struct device *dev) static SIMPLE_DEV_PM_OPS(ads7846_pm, ads7846_suspend, ads7846_resume); static int ads7846_setup_pendown(struct spi_device *spi, - struct ads7846 *ts) + struct ads7846 *ts, + const struct ads7846_platform_data *pdata) { - struct ads7846_platform_data *pdata = spi->dev.platform_data; int err; /* @@ -1003,7 +1003,7 @@ static int ads7846_setup_pendown(struct spi_device *spi, * use formula #2 for pressure, not #3. */ static void ads7846_setup_spi_msg(struct ads7846 *ts, - const struct ads7846_platform_data *pdata) + const struct ads7846_platform_data *pdata) { struct spi_message *m = &ts->msg[0]; struct spi_transfer *x = ts->xfer; @@ -1203,10 +1203,10 @@ static void ads7846_setup_spi_msg(struct ads7846 *ts, static int ads7846_probe(struct spi_device *spi) { + const struct ads7846_platform_data *pdata = dev_get_platdata(&spi->dev); struct ads7846 *ts; struct ads7846_packet *packet; struct input_dev *input_dev; - struct ads7846_platform_data *pdata = spi->dev.platform_data; unsigned long irq_flags; int err; @@ -1281,7 +1281,7 @@ static int ads7846_probe(struct spi_device *spi) ts->filter = ads7846_no_filter; } - err = ads7846_setup_pendown(spi, ts); + err = ads7846_setup_pendown(spi, ts, pdata); if (err) goto err_cleanup_filter; From a608026eacaee59cf0f1fa5caad60320f5b4a373 Mon Sep 17 00:00:00 2001 From: Daniel Mack Date: Thu, 27 Jun 2013 23:42:17 -0700 Subject: [PATCH 0577/1048] Input: ads7846 - add device tree bindings Signed-off-by: Daniel Mack Signed-off-by: Dmitry Torokhov --- .../devicetree/bindings/input/ads7846.txt | 91 ++++++++++++++ drivers/input/touchscreen/ads7846.c | 115 ++++++++++++++++-- 2 files changed, 195 insertions(+), 11 deletions(-) create mode 100644 Documentation/devicetree/bindings/input/ads7846.txt diff --git a/Documentation/devicetree/bindings/input/ads7846.txt b/Documentation/devicetree/bindings/input/ads7846.txt new file mode 100644 index 000000000000..5f7619c22743 --- /dev/null +++ b/Documentation/devicetree/bindings/input/ads7846.txt @@ -0,0 +1,91 @@ +Device tree bindings for TI's ADS7843, ADS7845, ADS7846, ADS7873, TSC2046 +SPI driven touch screen controllers. + +The node for this driver must be a child node of a SPI controller, hence +all mandatory properties described in + + Documentation/devicetree/bindings/spi/spi-bus.txt + +must be specified. + +Additional required properties: + + compatible Must be one of the following, depending on the + model: + "ti,tsc2046" + "ti,ads7843" + "ti,ads7845" + "ti,ads7846" + "ti,ads7873" + + interrupt-parent + interrupts An interrupt node describing the IRQ line the chip's + !PENIRQ pin is connected to. + vcc-supply A regulator node for the supply voltage. + + +Optional properties: + + ti,vref-delay-usecs vref supply delay in usecs, 0 for + external vref (u16). + ti,vref-mv The VREF voltage, in millivolts (u16). + ti,keep-vref-on set to keep vref on for differential + measurements as well + ti,swap-xy swap x and y axis + ti,settle-delay-usec Settling time of the analog signals; + a function of Vcc and the capacitance + on the X/Y drivers. If set to non-zero, + two samples are taken with settle_delay + us apart, and the second one is used. + ~150 uSec with 0.01uF caps (u16). + ti,penirq-recheck-delay-usecs If set to non-zero, after samples are + taken this delay is applied and penirq + is rechecked, to help avoid false + events. This value is affected by the + material used to build the touch layer + (u16). + ti,x-plate-ohms Resistance of the X-plate, + in Ohms (u16). + ti,y-plate-ohms Resistance of the Y-plate, + in Ohms (u16). + ti,x-min Minimum value on the X axis (u16). + ti,y-min Minimum value on the Y axis (u16). + ti,x-max Maximum value on the X axis (u16). + ti,y-max Minimum value on the Y axis (u16). + ti,pressure-min Minimum reported pressure value + (threshold) - u16. + ti,pressure-max Maximum reported pressure value (u16). + ti,debounce-max Max number of additional readings per + sample (u16). + ti,debounce-tol Tolerance used for filtering (u16). + ti,debounce-rep Additional consecutive good readings + required after the first two (u16). + ti,pendown-gpio-debounce Platform specific debounce time for the + pendown-gpio (u32). + pendown-gpio GPIO handle describing the pin the !PENIRQ + line is connected to. + linux,wakeup use any event on touchscreen as wakeup event. + + +Example for a TSC2046 chip connected to an McSPI controller of an OMAP SoC:: + + spi_controller { + tsc2046@0 { + reg = <0>; /* CS0 */ + compatible = "ti,tsc2046"; + interrupt-parent = <&gpio1>; + interrupts = <8 0>; /* BOOT6 / GPIO 8 */ + spi-max-frequency = <1000000>; + pendown-gpio = <&gpio1 8 0>; + vcc-supply = <®_vcc3>; + + ti,x-min = /bits/ 16 <0>; + ti,x-max = /bits/ 16 <8000>; + ti,y-min = /bits/ 16 <0>; + ti,y-max = /bits/ 16 <4800>; + ti,x-plate-ohms = /bits/ 16 <40>; + ti,pressure-max = /bits/ 16 <255>; + + linux,wakeup; + }; + }; diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c index 5ff041995198..ea195360747e 100644 --- a/drivers/input/touchscreen/ads7846.c +++ b/drivers/input/touchscreen/ads7846.c @@ -27,6 +27,9 @@ #include #include #include +#include +#include +#include #include #include #include @@ -1201,9 +1204,87 @@ static void ads7846_setup_spi_msg(struct ads7846 *ts, spi_message_add_tail(x, m); } +#ifdef CONFIG_OF +static const struct of_device_id ads7846_dt_ids[] = { + { .compatible = "ti,tsc2046", .data = (void *) 7846 }, + { .compatible = "ti,ads7843", .data = (void *) 7843 }, + { .compatible = "ti,ads7845", .data = (void *) 7845 }, + { .compatible = "ti,ads7846", .data = (void *) 7846 }, + { .compatible = "ti,ads7873", .data = (void *) 7873 }, + { } +}; +MODULE_DEVICE_TABLE(of, ads7846_dt_ids); + +static const struct ads7846_platform_data *ads7846_probe_dt(struct device *dev) +{ + struct ads7846_platform_data *pdata; + struct device_node *node = dev->of_node; + const struct of_device_id *match; + + if (!node) { + dev_err(dev, "Device does not have associated DT data\n"); + return ERR_PTR(-EINVAL); + } + + match = of_match_device(ads7846_dt_ids, dev); + if (!match) { + dev_err(dev, "Unknown device model\n"); + return ERR_PTR(-EINVAL); + } + + pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); + if (!pdata) + return ERR_PTR(-ENOMEM); + + pdata->model = (unsigned long)match->data; + + of_property_read_u16(node, "ti,vref-delay-usecs", + &pdata->vref_delay_usecs); + of_property_read_u16(node, "ti,vref-mv", &pdata->vref_mv); + pdata->keep_vref_on = of_property_read_bool(node, "ti,keep-vref-on"); + + pdata->swap_xy = of_property_read_bool(node, "ti,swap-xy"); + + of_property_read_u16(node, "ti,settle-delay-usec", + &pdata->settle_delay_usecs); + of_property_read_u16(node, "ti,penirq-recheck-delay-usecs", + &pdata->penirq_recheck_delay_usecs); + + of_property_read_u16(node, "ti,x-plate-ohms", &pdata->x_plate_ohms); + of_property_read_u16(node, "ti,y-plate-ohms", &pdata->y_plate_ohms); + + of_property_read_u16(node, "ti,x-min", &pdata->x_min); + of_property_read_u16(node, "ti,y-min", &pdata->y_min); + of_property_read_u16(node, "ti,x-max", &pdata->x_max); + of_property_read_u16(node, "ti,y-max", &pdata->y_max); + + of_property_read_u16(node, "ti,pressure-min", &pdata->pressure_min); + of_property_read_u16(node, "ti,pressure-max", &pdata->pressure_max); + + of_property_read_u16(node, "ti,debounce-max", &pdata->debounce_max); + of_property_read_u16(node, "ti,debounce-tol", &pdata->debounce_tol); + of_property_read_u16(node, "ti,debounce-rep", &pdata->debounce_rep); + + of_property_read_u32(node, "ti,pendown-gpio-debounce", + &pdata->gpio_pendown_debounce); + + pdata->wakeup = of_property_read_bool(node, "linux,wakeup"); + + pdata->gpio_pendown = of_get_named_gpio(dev->of_node, "pendown-gpio", 0); + + return pdata; +} +#else +static const struct ads7846_platform_data *ads7846_probe_dt(struct device *dev) +{ + dev_err(dev, "no platform data defined\n"); + return ERR_PTR(-EINVAL); +} +#endif + static int ads7846_probe(struct spi_device *spi) { - const struct ads7846_platform_data *pdata = dev_get_platdata(&spi->dev); + const struct ads7846_platform_data *pdata; struct ads7846 *ts; struct ads7846_packet *packet; struct input_dev *input_dev; @@ -1212,22 +1293,18 @@ static int ads7846_probe(struct spi_device *spi) if (!spi->irq) { dev_dbg(&spi->dev, "no IRQ?\n"); - return -ENODEV; - } - - if (!pdata) { - dev_dbg(&spi->dev, "no platform data?\n"); - return -ENODEV; + return -EINVAL; } /* don't exceed max specified sample rate */ if (spi->max_speed_hz > (125000 * SAMPLE_BITS)) { - dev_dbg(&spi->dev, "f(sample) %d KHz?\n", + dev_err(&spi->dev, "f(sample) %d KHz?\n", (spi->max_speed_hz/SAMPLE_BITS)/1000); return -EINVAL; } - /* We'd set TX word size 8 bits and RX word size to 13 bits ... except + /* + * We'd set TX word size 8 bits and RX word size to 13 bits ... except * that even if the hardware can do that, the SPI controller driver * may not. So we stick to very-portable 8 bit words, both RX and TX. */ @@ -1250,17 +1327,25 @@ static int ads7846_probe(struct spi_device *spi) ts->packet = packet; ts->spi = spi; ts->input = input_dev; - ts->vref_mv = pdata->vref_mv; - ts->swap_xy = pdata->swap_xy; mutex_init(&ts->lock); init_waitqueue_head(&ts->wait); + pdata = dev_get_platdata(&spi->dev); + if (!pdata) { + pdata = ads7846_probe_dt(&spi->dev); + if (IS_ERR(pdata)) + return PTR_ERR(pdata); + } + ts->model = pdata->model ? : 7846; ts->vref_delay_usecs = pdata->vref_delay_usecs ? : 100; ts->x_plate_ohms = pdata->x_plate_ohms ? : 400; ts->pressure_max = pdata->pressure_max ? : ~0; + ts->vref_mv = pdata->vref_mv; + ts->swap_xy = pdata->swap_xy; + if (pdata->filter != NULL) { if (pdata->filter_init != NULL) { err = pdata->filter_init(pdata, &ts->filter_data); @@ -1370,6 +1455,13 @@ static int ads7846_probe(struct spi_device *spi) device_init_wakeup(&spi->dev, pdata->wakeup); + /* + * If device does not carry platform data we must have allocated it + * when parsing DT data. + */ + if (!dev_get_platdata(&spi->dev)) + devm_kfree(&spi->dev, (void *)pdata); + return 0; err_remove_attr_group: @@ -1437,6 +1529,7 @@ static struct spi_driver ads7846_driver = { .name = "ads7846", .owner = THIS_MODULE, .pm = &ads7846_pm, + .of_match_table = of_match_ptr(ads7846_dt_ids), }, .probe = ads7846_probe, .remove = ads7846_remove, From 9f310dedfecdf53974e6e7c21d8d4dc7e8ab8c14 Mon Sep 17 00:00:00 2001 From: Stephen Warren Date: Mon, 1 Jul 2013 15:07:05 -0600 Subject: [PATCH 0578/1048] ARM: tegra: fix VBUS regulator GPIO polarity in DT Commit 4c94c8b "ARM: tegra: update device trees for USB binding rework" added regulator definitions for GPIO-controlled USB VBUS. However, none of these contained the essential DT property enable-active-high. Add this so that the regulator definitions are correct. Signed-off-by: Stephen Warren Signed-off-by: Arnd Bergmann --- arch/arm/boot/dts/tegra20-seaboard.dts | 1 + arch/arm/boot/dts/tegra20-trimslice.dts | 1 + arch/arm/boot/dts/tegra20-whistler.dts | 2 ++ 3 files changed, 4 insertions(+) diff --git a/arch/arm/boot/dts/tegra20-seaboard.dts b/arch/arm/boot/dts/tegra20-seaboard.dts index ab177b406b78..365760b33a26 100644 --- a/arch/arm/boot/dts/tegra20-seaboard.dts +++ b/arch/arm/boot/dts/tegra20-seaboard.dts @@ -828,6 +828,7 @@ regulator-name = "vdd_vbus_wup1"; regulator-min-microvolt = <5000000>; regulator-max-microvolt = <5000000>; + enable-active-high; gpio = <&gpio 24 0>; /* PD0 */ }; }; diff --git a/arch/arm/boot/dts/tegra20-trimslice.dts b/arch/arm/boot/dts/tegra20-trimslice.dts index 170159910455..ed4b901b0227 100644 --- a/arch/arm/boot/dts/tegra20-trimslice.dts +++ b/arch/arm/boot/dts/tegra20-trimslice.dts @@ -410,6 +410,7 @@ regulator-name = "usb1_vbus"; regulator-min-microvolt = <5000000>; regulator-max-microvolt = <5000000>; + enable-active-high; gpio = <&gpio 170 0>; /* PV2 */ }; }; diff --git a/arch/arm/boot/dts/tegra20-whistler.dts b/arch/arm/boot/dts/tegra20-whistler.dts index ea078ab8edeb..ab67c94db280 100644 --- a/arch/arm/boot/dts/tegra20-whistler.dts +++ b/arch/arm/boot/dts/tegra20-whistler.dts @@ -586,6 +586,7 @@ regulator-name = "vbus1"; regulator-min-microvolt = <5000000>; regulator-max-microvolt = <5000000>; + enable-active-high; gpio = <&tca6416 0 0>; /* GPIO_PMU0 */ }; @@ -595,6 +596,7 @@ regulator-name = "vbus3"; regulator-min-microvolt = <5000000>; regulator-max-microvolt = <5000000>; + enable-active-high; gpio = <&tca6416 1 0>; /* GPIO_PMU1 */ }; }; From c1b40e447af8695666d4c11cfec4a7407e6a124d Mon Sep 17 00:00:00 2001 From: Stuart Menefy Date: Wed, 26 Jun 2013 12:48:38 +0100 Subject: [PATCH 0579/1048] clocksource: arm_global_timer: Add ARM global timer support This is a simple driver for the global timer module found in the Cortex A9-MP cores from revision r1p0 onwards. This should be able to perform the functions of the system timer and the local timer in an SMP system. The global timer has the following features: The global timer is a 64-bit incrementing counter with an auto-incrementing feature. It continues incrementing after sending interrupts. The global timer is memory mapped in the private memory region. The global timer is accessible to all Cortex-A9 processors in the cluster. Each Cortex-A9 processor has a private 64-bit comparator that is used to assert a private interrupt when the global timer has reached the comparator value. All the Cortex-A9 processors in a design use the banked ID, ID27, for this interrupt. ID27 is sent to the Interrupt Controller as a Private Peripheral Interrupt. The global timer is clocked by PERIPHCLK. Signed-off-by: Stuart Menefy Signed-off-by: Srinivas Kandagatla CC: Arnd Bergmann CC: Rob Herring CC: Linus Walleij CC: Will Deacon CC: Thomas Gleixner Signed-off-by: Daniel Lezcano --- .../devicetree/bindings/arm/global_timer.txt | 24 ++ drivers/clocksource/Kconfig | 13 + drivers/clocksource/Makefile | 1 + drivers/clocksource/arm_global_timer.c | 321 ++++++++++++++++++ 4 files changed, 359 insertions(+) create mode 100644 Documentation/devicetree/bindings/arm/global_timer.txt create mode 100644 drivers/clocksource/arm_global_timer.c diff --git a/Documentation/devicetree/bindings/arm/global_timer.txt b/Documentation/devicetree/bindings/arm/global_timer.txt new file mode 100644 index 000000000000..1e548981eda4 --- /dev/null +++ b/Documentation/devicetree/bindings/arm/global_timer.txt @@ -0,0 +1,24 @@ + +* ARM Global Timer + Cortex-A9 are often associated with a per-core Global timer. + +** Timer node required properties: + +- compatible : Should be "arm,cortex-a9-global-timer" + Driver supports versions r2p0 and above. + +- interrupts : One interrupt to each core + +- reg : Specify the base address and the size of the GT timer + register window. + +- clocks : Should be phandle to a clock. + +Example: + + timer@2c000600 { + compatible = "arm,cortex-a9-global-timer"; + reg = <0x2c000600 0x20>; + interrupts = <1 13 0xf01>; + clocks = <&arm_periph_clk>; + }; diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig index c082e3e4bd0a..42c8eccb1e86 100644 --- a/drivers/clocksource/Kconfig +++ b/drivers/clocksource/Kconfig @@ -72,6 +72,19 @@ config ARM_ARCH_TIMER bool select CLKSRC_OF if OF +config ARM_GLOBAL_TIMER + bool + select CLKSRC_OF if OF + help + This options enables support for the ARM global timer unit + +config CLKSRC_ARM_GLOBAL_TIMER_SCHED_CLOCK + bool + depends on ARM_GLOBAL_TIMER + default y + help + Use ARM global timer clock source as sched_clock + config CLKSRC_METAG_GENERIC def_bool y if METAG help diff --git a/drivers/clocksource/Makefile b/drivers/clocksource/Makefile index 49bea7fad85c..8b00c5cebfa4 100644 --- a/drivers/clocksource/Makefile +++ b/drivers/clocksource/Makefile @@ -31,5 +31,6 @@ obj-$(CONFIG_CLKSRC_SAMSUNG_PWM) += samsung_pwm_timer.o obj-$(CONFIG_VF_PIT_TIMER) += vf_pit_timer.o obj-$(CONFIG_ARM_ARCH_TIMER) += arm_arch_timer.o +obj-$(CONFIG_ARM_GLOBAL_TIMER) += arm_global_timer.o obj-$(CONFIG_CLKSRC_METAG_GENERIC) += metag_generic.o obj-$(CONFIG_ARCH_HAS_TICK_BROADCAST) += dummy_timer.o diff --git a/drivers/clocksource/arm_global_timer.c b/drivers/clocksource/arm_global_timer.c new file mode 100644 index 000000000000..db8afc7427a6 --- /dev/null +++ b/drivers/clocksource/arm_global_timer.c @@ -0,0 +1,321 @@ +/* + * drivers/clocksource/arm_global_timer.c + * + * Copyright (C) 2013 STMicroelectronics (R&D) Limited. + * Author: Stuart Menefy + * Author: Srinivas Kandagatla + * + * 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. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#define GT_COUNTER0 0x00 +#define GT_COUNTER1 0x04 + +#define GT_CONTROL 0x08 +#define GT_CONTROL_TIMER_ENABLE BIT(0) /* this bit is NOT banked */ +#define GT_CONTROL_COMP_ENABLE BIT(1) /* banked */ +#define GT_CONTROL_IRQ_ENABLE BIT(2) /* banked */ +#define GT_CONTROL_AUTO_INC BIT(3) /* banked */ + +#define GT_INT_STATUS 0x0c +#define GT_INT_STATUS_EVENT_FLAG BIT(0) + +#define GT_COMP0 0x10 +#define GT_COMP1 0x14 +#define GT_AUTO_INC 0x18 + +/* + * We are expecting to be clocked by the ARM peripheral clock. + * + * Note: it is assumed we are using a prescaler value of zero, so this is + * the units for all operations. + */ +static void __iomem *gt_base; +static unsigned long gt_clk_rate; +static int gt_ppi; +static struct clock_event_device __percpu *gt_evt; + +/* + * To get the value from the Global Timer Counter register proceed as follows: + * 1. Read the upper 32-bit timer counter register + * 2. Read the lower 32-bit timer counter register + * 3. Read the upper 32-bit timer counter register again. If the value is + * different to the 32-bit upper value read previously, go back to step 2. + * Otherwise the 64-bit timer counter value is correct. + */ +static u64 gt_counter_read(void) +{ + u64 counter; + u32 lower; + u32 upper, old_upper; + + upper = readl_relaxed(gt_base + GT_COUNTER1); + do { + old_upper = upper; + lower = readl_relaxed(gt_base + GT_COUNTER0); + upper = readl_relaxed(gt_base + GT_COUNTER1); + } while (upper != old_upper); + + counter = upper; + counter <<= 32; + counter |= lower; + return counter; +} + +/** + * To ensure that updates to comparator value register do not set the + * Interrupt Status Register proceed as follows: + * 1. Clear the Comp Enable bit in the Timer Control Register. + * 2. Write the lower 32-bit Comparator Value Register. + * 3. Write the upper 32-bit Comparator Value Register. + * 4. Set the Comp Enable bit and, if necessary, the IRQ enable bit. + */ +static void gt_compare_set(unsigned long delta, int periodic) +{ + u64 counter = gt_counter_read(); + unsigned long ctrl; + + counter += delta; + ctrl = GT_CONTROL_TIMER_ENABLE; + writel(ctrl, gt_base + GT_CONTROL); + writel(lower_32_bits(counter), gt_base + GT_COMP0); + writel(upper_32_bits(counter), gt_base + GT_COMP1); + + if (periodic) { + writel(delta, gt_base + GT_AUTO_INC); + ctrl |= GT_CONTROL_AUTO_INC; + } + + ctrl |= GT_CONTROL_COMP_ENABLE | GT_CONTROL_IRQ_ENABLE; + writel(ctrl, gt_base + GT_CONTROL); +} + +static void gt_clockevent_set_mode(enum clock_event_mode mode, + struct clock_event_device *clk) +{ + unsigned long ctrl; + + switch (mode) { + case CLOCK_EVT_MODE_PERIODIC: + gt_compare_set(DIV_ROUND_CLOSEST(gt_clk_rate, HZ), 1); + break; + case CLOCK_EVT_MODE_ONESHOT: + case CLOCK_EVT_MODE_UNUSED: + case CLOCK_EVT_MODE_SHUTDOWN: + ctrl = readl(gt_base + GT_CONTROL); + ctrl &= ~(GT_CONTROL_COMP_ENABLE | + GT_CONTROL_IRQ_ENABLE | GT_CONTROL_AUTO_INC); + writel(ctrl, gt_base + GT_CONTROL); + break; + default: + break; + } +} + +static int gt_clockevent_set_next_event(unsigned long evt, + struct clock_event_device *unused) +{ + gt_compare_set(evt, 0); + return 0; +} + +static irqreturn_t gt_clockevent_interrupt(int irq, void *dev_id) +{ + struct clock_event_device *evt = dev_id; + + if (!(readl_relaxed(gt_base + GT_INT_STATUS) & + GT_INT_STATUS_EVENT_FLAG)) + return IRQ_NONE; + + /** + * ERRATA 740657( Global Timer can send 2 interrupts for + * the same event in single-shot mode) + * Workaround: + * Either disable single-shot mode. + * Or + * Modify the Interrupt Handler to avoid the + * offending sequence. This is achieved by clearing + * the Global Timer flag _after_ having incremented + * the Comparator register value to a higher value. + */ + if (evt->mode == CLOCK_EVT_MODE_ONESHOT) + gt_compare_set(ULONG_MAX, 0); + + writel_relaxed(GT_INT_STATUS_EVENT_FLAG, gt_base + GT_INT_STATUS); + evt->event_handler(evt); + + return IRQ_HANDLED; +} + +static int __cpuinit gt_clockevents_init(struct clock_event_device *clk) +{ + int cpu = smp_processor_id(); + + clk->name = "arm_global_timer"; + clk->features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT; + clk->set_mode = gt_clockevent_set_mode; + clk->set_next_event = gt_clockevent_set_next_event; + clk->cpumask = cpumask_of(cpu); + clk->rating = 300; + clk->irq = gt_ppi; + clockevents_config_and_register(clk, gt_clk_rate, + 1, 0xffffffff); + enable_percpu_irq(clk->irq, IRQ_TYPE_NONE); + return 0; +} + +static void gt_clockevents_stop(struct clock_event_device *clk) +{ + gt_clockevent_set_mode(CLOCK_EVT_MODE_UNUSED, clk); + disable_percpu_irq(clk->irq); +} + +static cycle_t gt_clocksource_read(struct clocksource *cs) +{ + return gt_counter_read(); +} + +static struct clocksource gt_clocksource = { + .name = "arm_global_timer", + .rating = 300, + .read = gt_clocksource_read, + .mask = CLOCKSOURCE_MASK(64), + .flags = CLOCK_SOURCE_IS_CONTINUOUS, +}; + +#ifdef CONFIG_CLKSRC_ARM_GLOBAL_TIMER_SCHED_CLOCK +static u32 notrace gt_sched_clock_read(void) +{ + return gt_counter_read(); +} +#endif + +static void __init gt_clocksource_init(void) +{ + writel(0, gt_base + GT_CONTROL); + writel(0, gt_base + GT_COUNTER0); + writel(0, gt_base + GT_COUNTER1); + /* enables timer on all the cores */ + writel(GT_CONTROL_TIMER_ENABLE, gt_base + GT_CONTROL); + +#ifdef CONFIG_CLKSRC_ARM_GLOBAL_TIMER_SCHED_CLOCK + setup_sched_clock(gt_sched_clock_read, 32, gt_clk_rate); +#endif + clocksource_register_hz(>_clocksource, gt_clk_rate); +} + +static int __cpuinit gt_cpu_notify(struct notifier_block *self, + unsigned long action, void *hcpu) +{ + switch (action & ~CPU_TASKS_FROZEN) { + case CPU_STARTING: + gt_clockevents_init(this_cpu_ptr(gt_evt)); + break; + case CPU_DYING: + gt_clockevents_stop(this_cpu_ptr(gt_evt)); + break; + } + + return NOTIFY_OK; +} +static struct notifier_block gt_cpu_nb __cpuinitdata = { + .notifier_call = gt_cpu_notify, +}; + +static void __init global_timer_of_register(struct device_node *np) +{ + struct clk *gt_clk; + int err = 0; + + /* + * In r2p0 the comparators for each processor with the global timer + * fire when the timer value is greater than or equal to. In previous + * revisions the comparators fired when the timer value was equal to. + */ + if ((read_cpuid_id() & 0xf0000f) < 0x200000) { + pr_warn("global-timer: non support for this cpu version.\n"); + return; + } + + gt_ppi = irq_of_parse_and_map(np, 0); + if (!gt_ppi) { + pr_warn("global-timer: unable to parse irq\n"); + return; + } + + gt_base = of_iomap(np, 0); + if (!gt_base) { + pr_warn("global-timer: invalid base address\n"); + return; + } + + gt_clk = of_clk_get(np, 0); + if (!IS_ERR(gt_clk)) { + err = clk_prepare_enable(gt_clk); + if (err) + goto out_unmap; + } else { + pr_warn("global-timer: clk not found\n"); + err = -EINVAL; + goto out_unmap; + } + + gt_clk_rate = clk_get_rate(gt_clk); + gt_evt = alloc_percpu(struct clock_event_device); + if (!gt_evt) { + pr_warn("global-timer: can't allocate memory\n"); + err = -ENOMEM; + goto out_clk; + } + + err = request_percpu_irq(gt_ppi, gt_clockevent_interrupt, + "gt", gt_evt); + if (err) { + pr_warn("global-timer: can't register interrupt %d (%d)\n", + gt_ppi, err); + goto out_free; + } + + err = register_cpu_notifier(>_cpu_nb); + if (err) { + pr_warn("global-timer: unable to register cpu notifier.\n"); + goto out_irq; + } + + /* Immediately configure the timer on the boot CPU */ + gt_clocksource_init(); + gt_clockevents_init(this_cpu_ptr(gt_evt)); + + return; + +out_irq: + free_percpu_irq(gt_ppi, gt_evt); +out_free: + free_percpu(gt_evt); +out_clk: + clk_disable_unprepare(gt_clk); +out_unmap: + iounmap(gt_base); + WARN(err, "ARM Global timer register failed (%d)\n", err); +} + +/* Only tested on r2p2 and r3p0 */ +CLOCKSOURCE_OF_DECLARE(arm_gt, "arm,cortex-a9-global-timer", + global_timer_of_register); From f91d1b63a4e096d3023aaaafec9d9d3aff25997f Mon Sep 17 00:00:00 2001 From: Alexandre Belloni Date: Mon, 1 Jul 2013 17:40:00 +0100 Subject: [PATCH 0580/1048] iio: inkern: fix iio_convert_raw_to_processed_unlocked When reading IIO_CHAN_INFO_OFFSET, the return value of iio_channel_read() for success will be IIO_VAL*, checking for 0 is not correct. Without this fix the offset applied by iio drivers will be ignored when converting a raw value to one in appropriate base units (e.g mV) in a IIO client drivers that use iio_convert_raw_to_processed including iio-hwmon. Cc: # 3.10.x Signed-off-by: Alexandre Belloni Signed-off-by: Jonathan Cameron --- drivers/iio/inkern.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c index 98ddc323add0..0cf5f8e06cfc 100644 --- a/drivers/iio/inkern.c +++ b/drivers/iio/inkern.c @@ -451,7 +451,7 @@ static int iio_convert_raw_to_processed_unlocked(struct iio_channel *chan, int ret; ret = iio_channel_read(chan, &offset, NULL, IIO_CHAN_INFO_OFFSET); - if (ret == 0) + if (ret >= 0) raw64 += offset; scale_type = iio_channel_read(chan, &scale_val, &scale_val2, From e1b1fa66a0398f0b52ae79a2bdc7de87c205d074 Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Sat, 29 Jun 2013 22:20:00 +0100 Subject: [PATCH 0581/1048] iio: mxs-lradc: Fix misuse of iio->trig The struct iio_dev .trig field is to be used only by the IIO core, the driver shall not fill this field. This fixes ugly crash when the driver is compiled as a module and the module is rmmod'd. Signed-off-by: Marek Vasut Cc: Fabio Estevam Cc: Jonathan Cameron Cc: Shawn Guo Signed-off-by: Jonathan Cameron --- drivers/staging/iio/adc/mxs-lradc.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/staging/iio/adc/mxs-lradc.c b/drivers/staging/iio/adc/mxs-lradc.c index d92c97a59d61..c5edf1cad07a 100644 --- a/drivers/staging/iio/adc/mxs-lradc.c +++ b/drivers/staging/iio/adc/mxs-lradc.c @@ -661,12 +661,13 @@ static int mxs_lradc_trigger_init(struct iio_dev *iio) { int ret; struct iio_trigger *trig; + struct mxs_lradc *lradc = iio_priv(iio); trig = iio_trigger_alloc("%s-dev%i", iio->name, iio->id); if (trig == NULL) return -ENOMEM; - trig->dev.parent = iio->dev.parent; + trig->dev.parent = lradc->dev; iio_trigger_set_drvdata(trig, iio); trig->ops = &mxs_lradc_trigger_ops; @@ -676,15 +677,17 @@ static int mxs_lradc_trigger_init(struct iio_dev *iio) return ret; } - iio->trig = trig; + lradc->trig = trig; return 0; } static void mxs_lradc_trigger_remove(struct iio_dev *iio) { - iio_trigger_unregister(iio->trig); - iio_trigger_free(iio->trig); + struct mxs_lradc *lradc = iio_priv(iio); + + iio_trigger_unregister(lradc->trig); + iio_trigger_free(lradc->trig); } static int mxs_lradc_buffer_preenable(struct iio_dev *iio) From 035dc1e0f9008b48630e02bf0eaa7cc547416d1d Mon Sep 17 00:00:00 2001 From: Daniel Vetter Date: Wed, 3 Jul 2013 12:56:54 +0200 Subject: [PATCH 0582/1048] drm/i915: reinit status page registers after gpu reset This fixes gpu reset on my gm45 - without this patch the bsd thing is forever stuck since the seqno updates never reach the status page. Tbh I have no idea how this ever worked without rewriting the hws registers after a gpu reset. To satisfy my OCD also give the functions a bit more consistent names: - Use status_page everywhere, also for the physical addressed one. - Use init for the allocation part and setup for the register setup part consistently. Long term I'd really like to share the hw init parts completely between gpu reset, resume and driver load, i.e. to call i915_gem_init_hw instead of the individual pieces we might need. v2: Add the missing paragraph to the commit message about what bug exactly this patch here fixes. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=65495 Cc: Chris Wilson Reviewed-by: Chris Wilson Tested-by: lu hua Signed-off-by: Daniel Vetter --- drivers/gpu/drm/i915/intel_ringbuffer.c | 29 ++++++++++++++++--------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.c b/drivers/gpu/drm/i915/intel_ringbuffer.c index e51ab552046c..18ca76e3e5ef 100644 --- a/drivers/gpu/drm/i915/intel_ringbuffer.c +++ b/drivers/gpu/drm/i915/intel_ringbuffer.c @@ -379,6 +379,17 @@ u32 intel_ring_get_active_head(struct intel_ring_buffer *ring) return I915_READ(acthd_reg); } +static void ring_setup_phys_status_page(struct intel_ring_buffer *ring) +{ + struct drm_i915_private *dev_priv = ring->dev->dev_private; + u32 addr; + + addr = dev_priv->status_page_dmah->busaddr; + if (INTEL_INFO(ring->dev)->gen >= 4) + addr |= (dev_priv->status_page_dmah->busaddr >> 28) & 0xf0; + I915_WRITE(HWS_PGA, addr); +} + static int init_ring_common(struct intel_ring_buffer *ring) { struct drm_device *dev = ring->dev; @@ -390,6 +401,11 @@ static int init_ring_common(struct intel_ring_buffer *ring) if (HAS_FORCE_WAKE(dev)) gen6_gt_force_wake_get(dev_priv); + if (I915_NEED_GFX_HWS(dev)) + intel_ring_setup_status_page(ring); + else + ring_setup_phys_status_page(ring); + /* Stop the ring if it's running. */ I915_WRITE_CTL(ring, 0); I915_WRITE_HEAD(ring, 0); @@ -1223,7 +1239,6 @@ static int init_status_page(struct intel_ring_buffer *ring) ring->status_page.obj = obj; memset(ring->status_page.page_addr, 0, PAGE_SIZE); - intel_ring_setup_status_page(ring); DRM_DEBUG_DRIVER("%s hws offset: 0x%08x\n", ring->name, ring->status_page.gfx_addr); @@ -1237,10 +1252,9 @@ err: return ret; } -static int init_phys_hws_pga(struct intel_ring_buffer *ring) +static int init_phys_status_page(struct intel_ring_buffer *ring) { struct drm_i915_private *dev_priv = ring->dev->dev_private; - u32 addr; if (!dev_priv->status_page_dmah) { dev_priv->status_page_dmah = @@ -1249,11 +1263,6 @@ static int init_phys_hws_pga(struct intel_ring_buffer *ring) return -ENOMEM; } - addr = dev_priv->status_page_dmah->busaddr; - if (INTEL_INFO(ring->dev)->gen >= 4) - addr |= (dev_priv->status_page_dmah->busaddr >> 28) & 0xf0; - I915_WRITE(HWS_PGA, addr); - ring->status_page.page_addr = dev_priv->status_page_dmah->vaddr; memset(ring->status_page.page_addr, 0, PAGE_SIZE); @@ -1281,7 +1290,7 @@ static int intel_init_ring_buffer(struct drm_device *dev, return ret; } else { BUG_ON(ring->id != RCS); - ret = init_phys_hws_pga(ring); + ret = init_phys_status_page(ring); if (ret) return ret; } @@ -1893,7 +1902,7 @@ int intel_render_ring_init_dri(struct drm_device *dev, u64 start, u32 size) } if (!I915_NEED_GFX_HWS(dev)) { - ret = init_phys_hws_pga(ring); + ret = init_phys_status_page(ring); if (ret) return ret; } From 37bd6ca8ab6c103603e04e320d3debeb4596e481 Mon Sep 17 00:00:00 2001 From: Afzal Mohammed Date: Tue, 28 May 2013 11:54:48 +0530 Subject: [PATCH 0583/1048] ARM: OMAP2+: timer: initialize before using oh_name of_property_read_string_index(...,&oh_name) in omap_dm_timer_init_one does not alter the value of 'oh_name' even if the relevant function fails and as 'oh_name' in stack may have a non-zero value, it would be misunderstood by timer code that DT has specified "ti,hwmod" property for timer. 'oh_name' in this scenario would be a junk value, this would result in module not being enabled by hwmod API's for timer, and in turn crash. Signed-off-by: Afzal Mohammed Acked-by: Jon Hunter Signed-off-by: Tony Lindgren --- arch/arm/mach-omap2/timer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/mach-omap2/timer.c b/arch/arm/mach-omap2/timer.c index 3bdb0fb02028..5f148e721790 100644 --- a/arch/arm/mach-omap2/timer.c +++ b/arch/arm/mach-omap2/timer.c @@ -220,7 +220,7 @@ static int __init omap_dm_timer_init_one(struct omap_dm_timer *timer, int posted) { char name[10]; /* 10 = sizeof("gptXX_Xck0") */ - const char *oh_name; + const char *oh_name = NULL; struct device_node *np; struct omap_hwmod *oh; struct resource irq, mem; From b46355a920a3dbdce7365d2e39eefd6c7b87c22a Mon Sep 17 00:00:00 2001 From: Nishanth Menon Date: Wed, 26 Jun 2013 09:39:46 -0500 Subject: [PATCH 0584/1048] ARM: OMAP4: sleep: build OMAP4 specific functions only for OMAP4 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CPU sleep and resume functions for Cortex-A9 based OMAP4 and Cortex-A15 based OMAP5 are different. Hence, even though we reuse most of the remaining file as part of OMAP4/5 consolidation, build OMAP4 specific sleep/resume operations only for OMAP4. SCU is not used OMAP5. This fixes the following build failure with OMAP5 only build: arch/arm/mach-omap2/built-in.o: In function `scu_gp_set': arch/arm/mach-omap2/sleep44xx.S:132: undefined reference to `scu_power_mode' arch/arm/mach-omap2/built-in.o: In function `scu_gp_clear': arch/arm/mach-omap2/sleep44xx.S:229: undefined reference to `scu_power_mode' Reported-by: Pekon Gupta Reported-by: Vincent Stehlé Acked-by: Santosh Shilimkar Signed-off-by: Nishanth Menon Signed-off-by: Tony Lindgren --- arch/arm/mach-omap2/sleep44xx.S | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/arch/arm/mach-omap2/sleep44xx.S b/arch/arm/mach-omap2/sleep44xx.S index 88ff83a0942e..9086ce03ae12 100644 --- a/arch/arm/mach-omap2/sleep44xx.S +++ b/arch/arm/mach-omap2/sleep44xx.S @@ -34,6 +34,8 @@ ppa_zero_params: ppa_por_params: .word 1, 0 +#ifdef CONFIG_ARCH_OMAP4 + /* * ============================= * == CPU suspend finisher == @@ -326,7 +328,9 @@ skip_l2en: b cpu_resume @ Jump to generic resume ENDPROC(omap4_cpu_resume) -#endif +#endif /* CONFIG_ARCH_OMAP4 */ + +#endif /* defined(CONFIG_SMP) && defined(CONFIG_PM) */ #ifndef CONFIG_OMAP4_ERRATA_I688 ENTRY(omap_bus_sync) From 2abc75a8c52af5e9cd32223554e6071e07b44559 Mon Sep 17 00:00:00 2001 From: Nishanth Menon Date: Wed, 26 Jun 2013 09:39:47 -0500 Subject: [PATCH 0585/1048] ARM: scu: provide inline dummy functions when SCU is not present MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On platforms such as Cortex-A15 based OMAP5, SCU is not used, however since much code is shared between Cortex-A9 based OMAP4 (which uses SCU) and OMAP5, It does help to have inline functions returning error values when SCU is not present on the platform. arch/arm/mach-omap2/omap-smp.c which is common between OMAP4 and 5 handles the SCU usage only for OMAP4. This fixes the following build failure with OMAP5 only build: arch/arm/mach-omap2/built-in.o: In function `omap4_smp_init_cpus': arch/arm/mach-omap2/omap-smp.c:185: undefined reference to `scu_get_core_count' arch/arm/mach-omap2/built-in.o: In function `omap4_smp_prepare_cpus': arch/arm/mach-omap2/omap-smp.c:211: undefined reference to `scu_enable' Reported-by: Pekon Gupta Reported-by: Vincent Stehlé Acked-by: Santosh Shilimkar Signed-off-by: Nishanth Menon Signed-off-by: Tony Lindgren --- arch/arm/include/asm/smp_scu.h | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/arch/arm/include/asm/smp_scu.h b/arch/arm/include/asm/smp_scu.h index 18d169373612..0393fbab8dd5 100644 --- a/arch/arm/include/asm/smp_scu.h +++ b/arch/arm/include/asm/smp_scu.h @@ -23,10 +23,21 @@ static inline unsigned long scu_a9_get_base(void) return pa; } +#ifdef CONFIG_HAVE_ARM_SCU unsigned int scu_get_core_count(void __iomem *); int scu_power_mode(void __iomem *, unsigned int); +#else +static inline unsigned int scu_get_core_count(void __iomem *scu_base) +{ + return 0; +} +static inline int scu_power_mode(void __iomem *scu_base, unsigned int mode) +{ + return -EINVAL; +} +#endif -#ifdef CONFIG_SMP +#if defined(CONFIG_SMP) && defined(CONFIG_HAVE_ARM_SCU) void scu_enable(void __iomem *scu_base); #else static inline void scu_enable(void __iomem *scu_base) {} From 62618c17e077b22bb12bdf754ca5bf89f2ae4dcd Mon Sep 17 00:00:00 2001 From: Santosh Shilimkar Date: Wed, 19 Jun 2013 15:52:12 -0400 Subject: [PATCH 0586/1048] ARM: OMAP5: Enable Cortex A15 errata 798181 ARM errata 798181 is applicable for OMAP5 based devices. So enable the same in the build. Errata extract and workaround information is as below. On Cortex-A15 (r0p0..r3p2) the TLBI*IS/DSB operations are not adequately shooting down all use of the old entries. The ARM_ERRATA_798181 option enables the Linux kernel workaround for this erratum which sends an IPI to the CPUs that are running the same ASID as the one being invalidated. Cc: Tony Lindgren Signed-off-by: Santosh Shilimkar Signed-off-by: Tony Lindgren --- arch/arm/mach-omap2/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm/mach-omap2/Kconfig b/arch/arm/mach-omap2/Kconfig index c7b32a966f67..e658f7a272e4 100644 --- a/arch/arm/mach-omap2/Kconfig +++ b/arch/arm/mach-omap2/Kconfig @@ -114,6 +114,7 @@ config SOC_OMAP5 select HAVE_SMP select COMMON_CLK select HAVE_ARM_ARCH_TIMER + select ARM_ERRATA_798181 comment "OMAP Core Type" depends on ARCH_OMAP2 From 9847bd481084249b30308776ecf660b486a6c3d8 Mon Sep 17 00:00:00 2001 From: Paul Bolle Date: Thu, 30 May 2013 13:20:23 +0200 Subject: [PATCH 0587/1048] ARM: OMAP2+: Remove obsolete Makefile line The OMAP runtime PM implementation was removed in v3.0. But one Makefile line, which was used to tweak CFLAGS, was overlooked. Remove it too. Signed-off-by: Paul Bolle Signed-off-by: Tony Lindgren --- arch/arm/mach-omap2/Makefile | 4 ---- 1 file changed, 4 deletions(-) diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile index ea5a27ff9941..d4f671547c37 100644 --- a/arch/arm/mach-omap2/Makefile +++ b/arch/arm/mach-omap2/Makefile @@ -95,10 +95,6 @@ obj-$(CONFIG_POWER_AVS_OMAP_CLASS3) += smartreflex-class3.o AFLAGS_sleep24xx.o :=-Wa,-march=armv6 AFLAGS_sleep34xx.o :=-Wa,-march=armv7-a$(plus_sec) -ifeq ($(CONFIG_PM_VERBOSE),y) -CFLAGS_pm_bus.o += -DDEBUG -endif - endif ifeq ($(CONFIG_CPU_IDLE),y) From 1261674a2dded2b5b055f51fb44677a8654d3f06 Mon Sep 17 00:00:00 2001 From: Thomas Meyer Date: Sat, 1 Jun 2013 11:44:44 +0200 Subject: [PATCH 0588/1048] ARM: OMAP2+: Cocci spatch "ptr_ret.spatch" Cocci spatch "ptr_ret.spatch" Signed-off-by: Thomas Meyer Acked-by: Kevin Hilman Signed-off-by: Tony Lindgren --- arch/arm/mach-omap2/devices.c | 4 ++-- arch/arm/mach-omap2/fb.c | 5 +---- arch/arm/mach-omap2/gpmc.c | 2 +- arch/arm/mach-omap2/pmu.c | 5 +---- 4 files changed, 5 insertions(+), 11 deletions(-) diff --git a/arch/arm/mach-omap2/devices.c b/arch/arm/mach-omap2/devices.c index aef96e45cb20..c3bc58b88fa6 100644 --- a/arch/arm/mach-omap2/devices.c +++ b/arch/arm/mach-omap2/devices.c @@ -66,7 +66,7 @@ static int __init omap3_l3_init(void) WARN(IS_ERR(pdev), "could not build omap_device for %s\n", oh_name); - return IS_ERR(pdev) ? PTR_ERR(pdev) : 0; + return PTR_RET(pdev); } omap_postcore_initcall(omap3_l3_init); @@ -100,7 +100,7 @@ static int __init omap4_l3_init(void) WARN(IS_ERR(pdev), "could not build omap_device for %s\n", oh_name); - return IS_ERR(pdev) ? PTR_ERR(pdev) : 0; + return PTR_RET(pdev); } omap_postcore_initcall(omap4_l3_init); diff --git a/arch/arm/mach-omap2/fb.c b/arch/arm/mach-omap2/fb.c index 190ae493c6ef..2ca33cc0c484 100644 --- a/arch/arm/mach-omap2/fb.c +++ b/arch/arm/mach-omap2/fb.c @@ -83,10 +83,7 @@ static int __init omap_init_vrfb(void) pdev = platform_device_register_resndata(NULL, "omapvrfb", -1, res, num_res, NULL, 0); - if (IS_ERR(pdev)) - return PTR_ERR(pdev); - else - return 0; + return PTR_RET(pdev); } omap_arch_initcall(omap_init_vrfb); diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c index 1c7969e965d7..f3fdd6afa213 100644 --- a/arch/arm/mach-omap2/gpmc.c +++ b/arch/arm/mach-omap2/gpmc.c @@ -1734,7 +1734,7 @@ static int __init omap_gpmc_init(void) pdev = omap_device_build(DEVICE_NAME, -1, oh, NULL, 0); WARN(IS_ERR(pdev), "could not build omap_device for %s\n", oh_name); - return IS_ERR(pdev) ? PTR_ERR(pdev) : 0; + return PTR_RET(pdev); } omap_postcore_initcall(omap_gpmc_init); diff --git a/arch/arm/mach-omap2/pmu.c b/arch/arm/mach-omap2/pmu.c index 9ace8eae7ee8..33c8846b4193 100644 --- a/arch/arm/mach-omap2/pmu.c +++ b/arch/arm/mach-omap2/pmu.c @@ -54,10 +54,7 @@ static int __init omap2_init_pmu(unsigned oh_num, char *oh_names[]) WARN(IS_ERR(omap_pmu_dev), "Can't build omap_device for %s.\n", dev_name); - if (IS_ERR(omap_pmu_dev)) - return PTR_ERR(omap_pmu_dev); - - return 0; + return PTR_RET(omap_pmu_dev); } static int __init omap_init_pmu(void) From ea2409bab7ee7c309e558f257a3b6b7e8233f209 Mon Sep 17 00:00:00 2001 From: Pavel Machek Date: Mon, 1 Jul 2013 23:15:04 +0200 Subject: [PATCH 0589/1048] ARM: OMAP2+: N900: enable N900-specific drivers even if device tree is enabled We still need video & sound drivers with device tree enabled. Signed-off-by: Pavel Machek Signed-off-by: Tony Lindgren --- arch/arm/mach-omap2/board-rx51-video.c | 2 +- sound/soc/omap/rx51.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/arm/mach-omap2/board-rx51-video.c b/arch/arm/mach-omap2/board-rx51-video.c index bd74f9f6063b..bdd1e3a179e1 100644 --- a/arch/arm/mach-omap2/board-rx51-video.c +++ b/arch/arm/mach-omap2/board-rx51-video.c @@ -61,7 +61,7 @@ static struct omap_dss_board_info rx51_dss_board_info = { static int __init rx51_video_init(void) { - if (!machine_is_nokia_rx51()) + if (!machine_is_nokia_rx51() && !of_machine_is_compatible("nokia,omap3-n900")) return 0; if (omap_mux_init_gpio(RX51_LCD_RESET_GPIO, OMAP_PIN_OUTPUT)) { diff --git a/sound/soc/omap/rx51.c b/sound/soc/omap/rx51.c index 249cd230ad8f..611179c3bca4 100644 --- a/sound/soc/omap/rx51.c +++ b/sound/soc/omap/rx51.c @@ -396,7 +396,7 @@ static int __init rx51_soc_init(void) { int err; - if (!machine_is_nokia_rx51()) + if (!machine_is_nokia_rx51() && !of_machine_is_compatible("nokia,omap3-n900")) return -ENODEV; err = gpio_request_one(RX51_TVOUT_SEL_GPIO, From e94eb1ac8ef14ae6a745815d2c184225febfd189 Mon Sep 17 00:00:00 2001 From: Enric Balletbo i Serra Date: Wed, 19 Jun 2013 18:24:43 +0200 Subject: [PATCH 0590/1048] ARM: OMAP3: igep0020: Set DSS pins in correct mux mode. Platform code used to depend on bootloadres for correctly setting the mux pin modes. But bootloaders should only set the minimum required mux pins. So, DSS mux pins are not set in U-Boot anymore and video display is broken on IGEPv2 when booting with newer U-Boot versions. Setup the DSS pin muxes to enable display functionality. Signed-off-by: Enric Balletbo i Serra Reviewed-by: Javier Martinez Canillas Signed-off-by: Tony Lindgren --- arch/arm/mach-omap2/board-igep0020.c | 31 ++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/arch/arm/mach-omap2/board-igep0020.c b/arch/arm/mach-omap2/board-igep0020.c index b54562d1235e..87e65dde8e13 100644 --- a/arch/arm/mach-omap2/board-igep0020.c +++ b/arch/arm/mach-omap2/board-igep0020.c @@ -553,6 +553,37 @@ static struct usbhs_omap_platform_data igep3_usbhs_bdata __initdata = { #ifdef CONFIG_OMAP_MUX static struct omap_board_mux board_mux[] __initdata = { + /* Display Sub System */ + OMAP3_MUX(DSS_PCLK, OMAP_MUX_MODE0 | OMAP_PIN_OUTPUT), + OMAP3_MUX(DSS_HSYNC, OMAP_MUX_MODE0 | OMAP_PIN_OUTPUT), + OMAP3_MUX(DSS_VSYNC, OMAP_MUX_MODE0 | OMAP_PIN_OUTPUT), + OMAP3_MUX(DSS_ACBIAS, OMAP_MUX_MODE0 | OMAP_PIN_OUTPUT), + OMAP3_MUX(DSS_DATA0, OMAP_MUX_MODE0 | OMAP_PIN_OUTPUT), + OMAP3_MUX(DSS_DATA1, OMAP_MUX_MODE0 | OMAP_PIN_OUTPUT), + OMAP3_MUX(DSS_DATA2, OMAP_MUX_MODE0 | OMAP_PIN_OUTPUT), + OMAP3_MUX(DSS_DATA3, OMAP_MUX_MODE0 | OMAP_PIN_OUTPUT), + OMAP3_MUX(DSS_DATA4, OMAP_MUX_MODE0 | OMAP_PIN_OUTPUT), + OMAP3_MUX(DSS_DATA5, OMAP_MUX_MODE0 | OMAP_PIN_OUTPUT), + OMAP3_MUX(DSS_DATA6, OMAP_MUX_MODE0 | OMAP_PIN_OUTPUT), + OMAP3_MUX(DSS_DATA7, OMAP_MUX_MODE0 | OMAP_PIN_OUTPUT), + OMAP3_MUX(DSS_DATA8, OMAP_MUX_MODE0 | OMAP_PIN_OUTPUT), + OMAP3_MUX(DSS_DATA9, OMAP_MUX_MODE0 | OMAP_PIN_OUTPUT), + OMAP3_MUX(DSS_DATA10, OMAP_MUX_MODE0 | OMAP_PIN_OUTPUT), + OMAP3_MUX(DSS_DATA11, OMAP_MUX_MODE0 | OMAP_PIN_OUTPUT), + OMAP3_MUX(DSS_DATA12, OMAP_MUX_MODE0 | OMAP_PIN_OUTPUT), + OMAP3_MUX(DSS_DATA13, OMAP_MUX_MODE0 | OMAP_PIN_OUTPUT), + OMAP3_MUX(DSS_DATA14, OMAP_MUX_MODE0 | OMAP_PIN_OUTPUT), + OMAP3_MUX(DSS_DATA15, OMAP_MUX_MODE0 | OMAP_PIN_OUTPUT), + OMAP3_MUX(DSS_DATA16, OMAP_MUX_MODE0 | OMAP_PIN_OUTPUT), + OMAP3_MUX(DSS_DATA17, OMAP_MUX_MODE0 | OMAP_PIN_OUTPUT), + OMAP3_MUX(DSS_DATA18, OMAP_MUX_MODE0 | OMAP_PIN_OUTPUT), + OMAP3_MUX(DSS_DATA19, OMAP_MUX_MODE0 | OMAP_PIN_OUTPUT), + OMAP3_MUX(DSS_DATA20, OMAP_MUX_MODE0 | OMAP_PIN_OUTPUT), + OMAP3_MUX(DSS_DATA21, OMAP_MUX_MODE0 | OMAP_PIN_OUTPUT), + OMAP3_MUX(DSS_DATA22, OMAP_MUX_MODE0 | OMAP_PIN_OUTPUT), + OMAP3_MUX(DSS_DATA23, OMAP_MUX_MODE0 | OMAP_PIN_OUTPUT), + /* TFP410 PanelBus DVI Transmitte (GPIO_170) */ + OMAP3_MUX(HDQ_SIO, OMAP_MUX_MODE4 | OMAP_PIN_OUTPUT), /* SMSC9221 LAN Controller ETH IRQ (GPIO_176) */ OMAP3_MUX(MCSPI1_CS2, OMAP_MUX_MODE4 | OMAP_PIN_INPUT), { .reg_offset = OMAP_MUX_TERMINATOR }, From 7f161ce76d356c496af6ef5ee3a896d4bf18e3eb Mon Sep 17 00:00:00 2001 From: Wei Yongjun Date: Thu, 20 Jun 2013 08:01:05 +0800 Subject: [PATCH 0591/1048] ARM: OMAP2+: devices: remove duplicated include from devices.c Remove duplicated include. Signed-off-by: Wei Yongjun Signed-off-by: Tony Lindgren --- arch/arm/mach-omap2/devices.c | 1 - 1 file changed, 1 deletion(-) diff --git a/arch/arm/mach-omap2/devices.c b/arch/arm/mach-omap2/devices.c index c3bc58b88fa6..3c1279f27d1f 100644 --- a/arch/arm/mach-omap2/devices.c +++ b/arch/arm/mach-omap2/devices.c @@ -15,7 +15,6 @@ #include #include #include -#include #include #include #include From 84793c77e13093627f462da616c55f425c2161be Mon Sep 17 00:00:00 2001 From: Eduardo Valentin Date: Fri, 7 Jun 2013 16:46:07 -0400 Subject: [PATCH 0592/1048] ARM: OMAP2+: omap2plus_defconfig: enable TI bandgap driver Enable the bandgap driver for TI SoCs thermal support. Cc: Russell King Cc: Tony Lindgren Cc: Javier Martinez Canillas Cc: AnilKumar Ch Cc: Santosh Shilimkar Cc: Tomi Valkeinen Cc: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Eduardo Valentin Signed-off-by: Tony Lindgren --- arch/arm/configs/omap2plus_defconfig | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/arch/arm/configs/omap2plus_defconfig b/arch/arm/configs/omap2plus_defconfig index 2ac0ffb12f03..b160bb90fb11 100644 --- a/arch/arm/configs/omap2plus_defconfig +++ b/arch/arm/configs/omap2plus_defconfig @@ -152,6 +152,13 @@ CONFIG_W1=y CONFIG_POWER_SUPPLY=y CONFIG_SENSORS_LM75=m CONFIG_WATCHDOG=y +CONFIG_THERMAL=y +CONFIG_THERMAL_HWMON=y +CONFIG_THERMAL_DEFAULT_GOV_STEP_WISE=y +CONFIG_THERMAL_GOV_FAIR_SHARE=y +CONFIG_THERMAL_GOV_STEP_WISE=y +CONFIG_THERMAL_GOV_USER_SPACE=y +CONFIG_CPU_THERMAL=y CONFIG_OMAP_WATCHDOG=y CONFIG_TWL4030_WATCHDOG=y CONFIG_MFD_TPS65217=y @@ -239,6 +246,10 @@ CONFIG_RTC_DRV_TWL4030=y CONFIG_RTC_DRV_OMAP=y CONFIG_DMADEVICES=y CONFIG_DMA_OMAP=y +CONFIG_TI_SOC_THERMAL=y +CONFIG_TI_THERMAL=y +CONFIG_OMAP4_THERMAL=y +CONFIG_OMAP5_THERMAL=y CONFIG_EXT2_FS=y CONFIG_EXT3_FS=y # CONFIG_EXT3_FS_XATTR is not set From 9c18ae3e8f2d76213a244e811b48332f0ebc4e04 Mon Sep 17 00:00:00 2001 From: Eduardo Valentin Date: Fri, 7 Jun 2013 16:46:08 -0400 Subject: [PATCH 0593/1048] ARM: OMAP2+: omap2plus_defconfig: enable DRA752 thermal support by default Make DRA752 thermal support enabled on omap2plus_defconfig Cc: Russell King Cc: Tony Lindgren Cc: Javier Martinez Canillas Cc: AnilKumar Ch Cc: Santosh Shilimkar Cc: Tomi Valkeinen Cc: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Eduardo Valentin Signed-off-by: Tony Lindgren --- arch/arm/configs/omap2plus_defconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm/configs/omap2plus_defconfig b/arch/arm/configs/omap2plus_defconfig index b160bb90fb11..61b76b0f7e82 100644 --- a/arch/arm/configs/omap2plus_defconfig +++ b/arch/arm/configs/omap2plus_defconfig @@ -250,6 +250,7 @@ CONFIG_TI_SOC_THERMAL=y CONFIG_TI_THERMAL=y CONFIG_OMAP4_THERMAL=y CONFIG_OMAP5_THERMAL=y +CONFIG_DRA752_THERMAL=y CONFIG_EXT2_FS=y CONFIG_EXT3_FS=y # CONFIG_EXT3_FS_XATTR is not set From fb15bdfbd76dae771069d2a93ebe4bbf84f361d0 Mon Sep 17 00:00:00 2001 From: Joel Fernandes Date: Wed, 26 Jun 2013 22:42:03 -0500 Subject: [PATCH 0594/1048] ARM: OMAP2+: Enable TI_EDMA in omap2plus_defconfig Build EDMA in by default to avoid fewer people stepping on their toes with broken DMA on drivers needing EDMA. Signed-off-by: Joel Fernandes Signed-off-by: Tony Lindgren --- arch/arm/configs/omap2plus_defconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm/configs/omap2plus_defconfig b/arch/arm/configs/omap2plus_defconfig index 61b76b0f7e82..009fa6944687 100644 --- a/arch/arm/configs/omap2plus_defconfig +++ b/arch/arm/configs/omap2plus_defconfig @@ -245,6 +245,7 @@ CONFIG_RTC_DRV_TWL92330=y CONFIG_RTC_DRV_TWL4030=y CONFIG_RTC_DRV_OMAP=y CONFIG_DMADEVICES=y +CONFIG_TI_EDMA=y CONFIG_DMA_OMAP=y CONFIG_TI_SOC_THERMAL=y CONFIG_TI_THERMAL=y From c24a6ae18abde53b048372b066b93b71b1b91154 Mon Sep 17 00:00:00 2001 From: Tom Rini Date: Mon, 1 Jul 2013 09:13:13 -0400 Subject: [PATCH 0595/1048] ARM: OMAP2+: omap2plus_defconfig: Enable appended DTB support As this config must support boards which cannot support separate device trees, enable support for appended ones. Cc: Tony Lindgren Cc: Russell King Signed-off-by: Tom Rini Signed-off-by: Tony Lindgren --- arch/arm/configs/omap2plus_defconfig | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/arm/configs/omap2plus_defconfig b/arch/arm/configs/omap2plus_defconfig index 009fa6944687..a58d57017fed 100644 --- a/arch/arm/configs/omap2plus_defconfig +++ b/arch/arm/configs/omap2plus_defconfig @@ -34,6 +34,8 @@ CONFIG_NR_CPUS=2 CONFIG_LEDS=y CONFIG_ZBOOT_ROM_TEXT=0x0 CONFIG_ZBOOT_ROM_BSS=0x0 +CONFIG_ARM_APPENDED_DTB=y +CONFIG_ARM_ATAG_DTB_COMPAT=y CONFIG_CMDLINE="root=/dev/mmcblk0p2 rootwait console=ttyO2,115200" CONFIG_KEXEC=y CONFIG_FPE_NWFPE=y From f2e055e7c9c6084bfbaa68701e52562acf96419e Mon Sep 17 00:00:00 2001 From: Daniel Mack Date: Thu, 4 Jul 2013 13:11:03 +0200 Subject: [PATCH 0596/1048] regmap: cache: bail in regmap_async_complete() for bus-less maps Commit f8bd822cb ("regmap: cache: Factor out block sync") made regcache_rbtree_sync() call regmap_async_complete(), which in turn does not check for map->bus before dereferencing it. This causes a NULL pointer dereference on bus-less maps. Signed-off-by: Daniel Mack Cc: stable@vger.kernel.org [v3.10 only] Signed-off-by: Mark Brown --- drivers/base/regmap/regmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c index a941dcfe7590..d0c81d1f409c 100644 --- a/drivers/base/regmap/regmap.c +++ b/drivers/base/regmap/regmap.c @@ -1717,7 +1717,7 @@ int regmap_async_complete(struct regmap *map) int ret; /* Nothing to do with no async support */ - if (!map->bus->async_write) + if (!map->bus || !map->bus->async_write) return 0; trace_regmap_async_complete_start(map->dev); From 95dc8dd14e2e84cc3adabc8310768c13758e7d96 Mon Sep 17 00:00:00 2001 From: Steve French Date: Thu, 4 Jul 2013 10:35:21 -0500 Subject: [PATCH 0597/1048] Limit allocation of crypto mechanisms to dialect which requires Updated patch to try to prevent allocation of cifs, smb2 or smb3 crypto secmech structures unless needed. Currently cifs allocates all crypto mechanisms when the first session is established (4 functions and 4 contexts), rather than only allocating these when needed (smb3 needs two, the rest of the dialects only need one). Acked-by: Jeff Layton Reviewed-by: Shirish Pargaonkar Signed-off-by: Steve French --- fs/cifs/cifsencrypt.c | 195 ++++++++++++++++++---------------------- fs/cifs/cifsproto.h | 1 - fs/cifs/connect.c | 6 -- fs/cifs/smb2transport.c | 90 ++++++++++++++++++- 4 files changed, 174 insertions(+), 118 deletions(-) diff --git a/fs/cifs/cifsencrypt.c b/fs/cifs/cifsencrypt.c index 3d8bf941d126..45e57cc38200 100644 --- a/fs/cifs/cifsencrypt.c +++ b/fs/cifs/cifsencrypt.c @@ -1,7 +1,7 @@ /* * fs/cifs/cifsencrypt.c * - * Copyright (C) International Business Machines Corp., 2005,2006 + * Copyright (C) International Business Machines Corp., 2005,2013 * Author(s): Steve French (sfrench@us.ibm.com) * * This library is free software; you can redistribute it and/or modify @@ -31,6 +31,36 @@ #include #include +static int +cifs_crypto_shash_md5_allocate(struct TCP_Server_Info *server) +{ + int rc; + unsigned int size; + + if (server->secmech.sdescmd5 != NULL) + return 0; /* already allocated */ + + server->secmech.md5 = crypto_alloc_shash("md5", 0, 0); + if (IS_ERR(server->secmech.md5)) { + cifs_dbg(VFS, "could not allocate crypto md5\n"); + return PTR_ERR(server->secmech.md5); + } + + size = sizeof(struct shash_desc) + + crypto_shash_descsize(server->secmech.md5); + server->secmech.sdescmd5 = kmalloc(size, GFP_KERNEL); + if (!server->secmech.sdescmd5) { + rc = -ENOMEM; + crypto_free_shash(server->secmech.md5); + server->secmech.md5 = NULL; + return rc; + } + server->secmech.sdescmd5->shash.tfm = server->secmech.md5; + server->secmech.sdescmd5->shash.flags = 0x0; + + return 0; +} + /* * Calculate and return the CIFS signature based on the mac key and SMB PDU. * The 16 byte signature must be allocated by the caller. Note we only use the @@ -50,8 +80,11 @@ static int cifs_calc_signature(struct smb_rqst *rqst, return -EINVAL; if (!server->secmech.sdescmd5) { - cifs_dbg(VFS, "%s: Can't generate signature\n", __func__); - return -1; + rc = cifs_crypto_shash_md5_allocate(server); + if (rc) { + cifs_dbg(VFS, "%s: Can't alloc md5 crypto\n", __func__); + return -1; + } } rc = crypto_shash_init(&server->secmech.sdescmd5->shash); @@ -556,6 +589,33 @@ CalcNTLMv2_response(const struct cifs_ses *ses, char *ntlmv2_hash) return rc; } +static int crypto_hmacmd5_alloc(struct TCP_Server_Info *server) +{ + unsigned int size; + + /* check if already allocated */ + if (server->secmech.sdeschmacmd5) + return 0; + + server->secmech.hmacmd5 = crypto_alloc_shash("hmac(md5)", 0, 0); + if (IS_ERR(server->secmech.hmacmd5)) { + cifs_dbg(VFS, "could not allocate crypto hmacmd5\n"); + return PTR_ERR(server->secmech.hmacmd5); + } + + size = sizeof(struct shash_desc) + + crypto_shash_descsize(server->secmech.hmacmd5); + server->secmech.sdeschmacmd5 = kmalloc(size, GFP_KERNEL); + if (!server->secmech.sdeschmacmd5) { + crypto_free_shash(server->secmech.hmacmd5); + server->secmech.hmacmd5 = NULL; + return -ENOMEM; + } + server->secmech.sdeschmacmd5->shash.tfm = server->secmech.hmacmd5; + server->secmech.sdeschmacmd5->shash.flags = 0x0; + + return 0; +} int setup_ntlmv2_rsp(struct cifs_ses *ses, const struct nls_table *nls_cp) @@ -606,6 +666,12 @@ setup_ntlmv2_rsp(struct cifs_ses *ses, const struct nls_table *nls_cp) memcpy(ses->auth_key.response + baselen, tiblob, tilen); + rc = crypto_hmacmd5_alloc(ses->server); + if (rc) { + cifs_dbg(VFS, "could not crypto alloc hmacmd5 rc %d\n", rc); + goto setup_ntlmv2_rsp_ret; + } + /* calculate ntlmv2_hash */ rc = calc_ntlmv2_hash(ses, ntlmv2_hash, nls_cp); if (rc) { @@ -705,123 +771,32 @@ calc_seckey(struct cifs_ses *ses) void cifs_crypto_shash_release(struct TCP_Server_Info *server) { - if (server->secmech.cmacaes) + if (server->secmech.cmacaes) { crypto_free_shash(server->secmech.cmacaes); + server->secmech.cmacaes = NULL; + } - if (server->secmech.hmacsha256) + if (server->secmech.hmacsha256) { crypto_free_shash(server->secmech.hmacsha256); + server->secmech.hmacsha256 = NULL; + } - if (server->secmech.md5) + if (server->secmech.md5) { crypto_free_shash(server->secmech.md5); + server->secmech.md5 = NULL; + } - if (server->secmech.hmacmd5) + if (server->secmech.hmacmd5) { crypto_free_shash(server->secmech.hmacmd5); + server->secmech.hmacmd5 = NULL; + } kfree(server->secmech.sdesccmacaes); - + server->secmech.sdesccmacaes = NULL; kfree(server->secmech.sdeschmacsha256); - + server->secmech.sdeschmacsha256 = NULL; kfree(server->secmech.sdeschmacmd5); - + server->secmech.sdeschmacmd5 = NULL; kfree(server->secmech.sdescmd5); -} - -int -cifs_crypto_shash_allocate(struct TCP_Server_Info *server) -{ - int rc; - unsigned int size; - - server->secmech.hmacmd5 = crypto_alloc_shash("hmac(md5)", 0, 0); - if (IS_ERR(server->secmech.hmacmd5)) { - cifs_dbg(VFS, "could not allocate crypto hmacmd5\n"); - return PTR_ERR(server->secmech.hmacmd5); - } - - server->secmech.md5 = crypto_alloc_shash("md5", 0, 0); - if (IS_ERR(server->secmech.md5)) { - cifs_dbg(VFS, "could not allocate crypto md5\n"); - rc = PTR_ERR(server->secmech.md5); - goto crypto_allocate_md5_fail; - } - - server->secmech.hmacsha256 = crypto_alloc_shash("hmac(sha256)", 0, 0); - if (IS_ERR(server->secmech.hmacsha256)) { - cifs_dbg(VFS, "could not allocate crypto hmacsha256\n"); - rc = PTR_ERR(server->secmech.hmacsha256); - goto crypto_allocate_hmacsha256_fail; - } - - server->secmech.cmacaes = crypto_alloc_shash("cmac(aes)", 0, 0); - if (IS_ERR(server->secmech.cmacaes)) { - cifs_dbg(VFS, "could not allocate crypto cmac-aes"); - rc = PTR_ERR(server->secmech.cmacaes); - goto crypto_allocate_cmacaes_fail; - } - - size = sizeof(struct shash_desc) + - crypto_shash_descsize(server->secmech.hmacmd5); - server->secmech.sdeschmacmd5 = kmalloc(size, GFP_KERNEL); - if (!server->secmech.sdeschmacmd5) { - rc = -ENOMEM; - goto crypto_allocate_hmacmd5_sdesc_fail; - } - server->secmech.sdeschmacmd5->shash.tfm = server->secmech.hmacmd5; - server->secmech.sdeschmacmd5->shash.flags = 0x0; - - size = sizeof(struct shash_desc) + - crypto_shash_descsize(server->secmech.md5); - server->secmech.sdescmd5 = kmalloc(size, GFP_KERNEL); - if (!server->secmech.sdescmd5) { - rc = -ENOMEM; - goto crypto_allocate_md5_sdesc_fail; - } - server->secmech.sdescmd5->shash.tfm = server->secmech.md5; - server->secmech.sdescmd5->shash.flags = 0x0; - - size = sizeof(struct shash_desc) + - crypto_shash_descsize(server->secmech.hmacsha256); - server->secmech.sdeschmacsha256 = kmalloc(size, GFP_KERNEL); - if (!server->secmech.sdeschmacsha256) { - rc = -ENOMEM; - goto crypto_allocate_hmacsha256_sdesc_fail; - } - server->secmech.sdeschmacsha256->shash.tfm = server->secmech.hmacsha256; - server->secmech.sdeschmacsha256->shash.flags = 0x0; - - size = sizeof(struct shash_desc) + - crypto_shash_descsize(server->secmech.cmacaes); - server->secmech.sdesccmacaes = kmalloc(size, GFP_KERNEL); - if (!server->secmech.sdesccmacaes) { - cifs_dbg(VFS, "%s: Can't alloc cmacaes\n", __func__); - rc = -ENOMEM; - goto crypto_allocate_cmacaes_sdesc_fail; - } - server->secmech.sdesccmacaes->shash.tfm = server->secmech.cmacaes; - server->secmech.sdesccmacaes->shash.flags = 0x0; - - return 0; - -crypto_allocate_cmacaes_sdesc_fail: - kfree(server->secmech.sdeschmacsha256); - -crypto_allocate_hmacsha256_sdesc_fail: - kfree(server->secmech.sdescmd5); - -crypto_allocate_md5_sdesc_fail: - kfree(server->secmech.sdeschmacmd5); - -crypto_allocate_hmacmd5_sdesc_fail: - crypto_free_shash(server->secmech.cmacaes); - -crypto_allocate_cmacaes_fail: - crypto_free_shash(server->secmech.hmacsha256); - -crypto_allocate_hmacsha256_fail: - crypto_free_shash(server->secmech.md5); - -crypto_allocate_md5_fail: - crypto_free_shash(server->secmech.hmacmd5); - - return rc; + server->secmech.sdescmd5 = NULL; } diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h index c8ff018fae68..f7e584d047e2 100644 --- a/fs/cifs/cifsproto.h +++ b/fs/cifs/cifsproto.h @@ -433,7 +433,6 @@ extern int SMBNTencrypt(unsigned char *, unsigned char *, unsigned char *, const struct nls_table *); extern int setup_ntlm_response(struct cifs_ses *, const struct nls_table *); extern int setup_ntlmv2_rsp(struct cifs_ses *, const struct nls_table *); -extern int cifs_crypto_shash_allocate(struct TCP_Server_Info *); extern void cifs_crypto_shash_release(struct TCP_Server_Info *); extern int calc_seckey(struct cifs_ses *); extern void generate_smb3signingkey(struct TCP_Server_Info *); diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index afcb8a1a33b7..fa68813396b5 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c @@ -2108,12 +2108,6 @@ cifs_get_tcp_session(struct smb_vol *volume_info) goto out_err; } - rc = cifs_crypto_shash_allocate(tcp_ses); - if (rc) { - cifs_dbg(VFS, "could not setup hash structures rc %d\n", rc); - goto out_err; - } - tcp_ses->ops = volume_info->ops; tcp_ses->vals = volume_info->vals; cifs_set_net_ns(tcp_ses, get_net(current->nsproxy->net_ns)); diff --git a/fs/cifs/smb2transport.c b/fs/cifs/smb2transport.c index 09b4fbaadeb6..301b191270b9 100644 --- a/fs/cifs/smb2transport.c +++ b/fs/cifs/smb2transport.c @@ -39,6 +39,77 @@ #include "smb2status.h" #include "smb2glob.h" +static int +smb2_crypto_shash_allocate(struct TCP_Server_Info *server) +{ + unsigned int size; + + if (server->secmech.sdeschmacsha256 != NULL) + return 0; /* already allocated */ + + server->secmech.hmacsha256 = crypto_alloc_shash("hmac(sha256)", 0, 0); + if (IS_ERR(server->secmech.hmacsha256)) { + cifs_dbg(VFS, "could not allocate crypto hmacsha256\n"); + return PTR_ERR(server->secmech.hmacsha256); + } + + size = sizeof(struct shash_desc) + + crypto_shash_descsize(server->secmech.hmacsha256); + server->secmech.sdeschmacsha256 = kmalloc(size, GFP_KERNEL); + if (!server->secmech.sdeschmacsha256) { + crypto_free_shash(server->secmech.hmacsha256); + server->secmech.hmacsha256 = NULL; + return -ENOMEM; + } + server->secmech.sdeschmacsha256->shash.tfm = server->secmech.hmacsha256; + server->secmech.sdeschmacsha256->shash.flags = 0x0; + + return 0; +} + +static int +smb3_crypto_shash_allocate(struct TCP_Server_Info *server) +{ + unsigned int size; + int rc; + + if (server->secmech.sdesccmacaes != NULL) + return 0; /* already allocated */ + + rc = smb2_crypto_shash_allocate(server); + if (rc) + return rc; + + server->secmech.cmacaes = crypto_alloc_shash("cmac(aes)", 0, 0); + if (IS_ERR(server->secmech.cmacaes)) { + cifs_dbg(VFS, "could not allocate crypto cmac-aes"); + kfree(server->secmech.sdeschmacsha256); + server->secmech.sdeschmacsha256 = NULL; + crypto_free_shash(server->secmech.hmacsha256); + server->secmech.hmacsha256 = NULL; + return PTR_ERR(server->secmech.cmacaes); + } + + size = sizeof(struct shash_desc) + + crypto_shash_descsize(server->secmech.cmacaes); + server->secmech.sdesccmacaes = kmalloc(size, GFP_KERNEL); + if (!server->secmech.sdesccmacaes) { + cifs_dbg(VFS, "%s: Can't alloc cmacaes\n", __func__); + kfree(server->secmech.sdeschmacsha256); + server->secmech.sdeschmacsha256 = NULL; + crypto_free_shash(server->secmech.hmacsha256); + crypto_free_shash(server->secmech.cmacaes); + server->secmech.hmacsha256 = NULL; + server->secmech.cmacaes = NULL; + return -ENOMEM; + } + server->secmech.sdesccmacaes->shash.tfm = server->secmech.cmacaes; + server->secmech.sdesccmacaes->shash.flags = 0x0; + + return 0; +} + + int smb2_calc_signature(struct smb_rqst *rqst, struct TCP_Server_Info *server) { @@ -52,6 +123,12 @@ smb2_calc_signature(struct smb_rqst *rqst, struct TCP_Server_Info *server) memset(smb2_signature, 0x0, SMB2_HMACSHA256_SIZE); memset(smb2_pdu->Signature, 0x0, SMB2_SIGNATURE_SIZE); + rc = smb2_crypto_shash_allocate(server); + if (rc) { + cifs_dbg(VFS, "%s: shah256 alloc failed\n", __func__); + return rc; + } + rc = crypto_shash_setkey(server->secmech.hmacsha256, server->session_key.response, SMB2_NTLMV2_SESSKEY_SIZE); if (rc) { @@ -61,7 +138,7 @@ smb2_calc_signature(struct smb_rqst *rqst, struct TCP_Server_Info *server) rc = crypto_shash_init(&server->secmech.sdeschmacsha256->shash); if (rc) { - cifs_dbg(VFS, "%s: Could not init md5\n", __func__); + cifs_dbg(VFS, "%s: Could not init sha256", __func__); return rc; } @@ -129,6 +206,12 @@ generate_smb3signingkey(struct TCP_Server_Info *server) memset(prfhash, 0x0, SMB2_HMACSHA256_SIZE); memset(server->smb3signingkey, 0x0, SMB3_SIGNKEY_SIZE); + rc = smb3_crypto_shash_allocate(server); + if (rc) { + cifs_dbg(VFS, "%s: crypto alloc failed\n", __func__); + goto smb3signkey_ret; + } + rc = crypto_shash_setkey(server->secmech.hmacsha256, server->session_key.response, SMB2_NTLMV2_SESSKEY_SIZE); if (rc) { @@ -210,6 +293,11 @@ smb3_calc_signature(struct smb_rqst *rqst, struct TCP_Server_Info *server) return rc; } + /* + * we already allocate sdesccmacaes when we init smb3 signing key, + * so unlike smb2 case we do not have to check here if secmech are + * initialized + */ rc = crypto_shash_init(&server->secmech.sdesccmacaes->shash); if (rc) { cifs_dbg(VFS, "%s: Could not init cmac aes\n", __func__); From 6658b9f70ebca5fc0795b1d6d733996af1e2caa7 Mon Sep 17 00:00:00 2001 From: Steve French Date: Thu, 4 Jul 2013 14:38:48 -0500 Subject: [PATCH 0598/1048] [CIFS] use sensible file nlink values if unprovided Certain servers may not set the NumberOfLinks field in query file/path info responses. In such a case, cifs_inode_needs_reval() assumes that all regular files are hardlinks and triggers revalidation, leading to excessive and unnecessary network traffic. This change hardcodes cf_nlink (and subsequently i_nlink) when not returned by the server, similar to what already occurs in cifs_mkdir(). Cc: Signed-off-by: David Disseldorp Signed-off-by: Steve French --- fs/cifs/inode.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c index 20efd81266c6..449b6cf09b09 100644 --- a/fs/cifs/inode.c +++ b/fs/cifs/inode.c @@ -558,6 +558,11 @@ cifs_all_info_to_fattr(struct cifs_fattr *fattr, FILE_ALL_INFO *info, fattr->cf_mode &= ~(S_IWUGO); fattr->cf_nlink = le32_to_cpu(info->NumberOfLinks); + if (fattr->cf_nlink < 1) { + cifs_dbg(1, "replacing bogus file nlink value %u\n", + fattr->cf_nlink); + fattr->cf_nlink = 1; + } } fattr->cf_uid = cifs_sb->mnt_uid; From e658718e478fb2591f38afd9643eab06698790fe Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Fri, 5 Jul 2013 11:33:49 +0800 Subject: [PATCH 0599/1048] irqchip: vt8500: Staticize local symbols This driver is converted to use IRQCHIP_DECLARE and irqchip_init. vt8500_handle_irq() and vt8500_irq_init() are only referenced in this file, so make them static. Signed-off-by: Axel Lin Acked-by: Tony Prisk Cc: Olof Johansson Link: http://lkml.kernel.org/r/1372995229.4038.1.camel@phoenix Signed-off-by: Thomas Gleixner --- drivers/irqchip/irq-vt8500.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/irqchip/irq-vt8500.c b/drivers/irqchip/irq-vt8500.c index d97059550a2c..1846e7d66681 100644 --- a/drivers/irqchip/irq-vt8500.c +++ b/drivers/irqchip/irq-vt8500.c @@ -178,7 +178,8 @@ static struct irq_domain_ops vt8500_irq_domain_ops = { .xlate = irq_domain_xlate_onecell, }; -asmlinkage void __exception_irq_entry vt8500_handle_irq(struct pt_regs *regs) +static asmlinkage +void __exception_irq_entry vt8500_handle_irq(struct pt_regs *regs) { u32 stat, i; int irqnr, virq; @@ -203,7 +204,8 @@ asmlinkage void __exception_irq_entry vt8500_handle_irq(struct pt_regs *regs) } } -int __init vt8500_irq_init(struct device_node *node, struct device_node *parent) +static int __init vt8500_irq_init(struct device_node *node, + struct device_node *parent) { int irq, i; struct device_node *np = node; From baaecfa7249f1d5553a31f8ad0b9c7ffabcaa339 Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Fri, 5 Jul 2013 15:41:10 +0800 Subject: [PATCH 0600/1048] irqchip: sun4i: Staticize sun4i_irq_ack() sun4i_irq_ack() is only referenced in this file, so make it static. Signed-off-by: Axel Lin Acked-by: Maxime Ripard Link: http://lkml.kernel.org/r/1373010070.14756.2.camel@phoenix Signed-off-by: Thomas Gleixner --- drivers/irqchip/irq-sun4i.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/irqchip/irq-sun4i.c b/drivers/irqchip/irq-sun4i.c index b66d4ae06898..a5438d889245 100644 --- a/drivers/irqchip/irq-sun4i.c +++ b/drivers/irqchip/irq-sun4i.c @@ -38,7 +38,7 @@ static struct irq_domain *sun4i_irq_domain; static asmlinkage void __exception_irq_entry sun4i_handle_irq(struct pt_regs *regs); -void sun4i_irq_ack(struct irq_data *irqd) +static void sun4i_irq_ack(struct irq_data *irqd) { unsigned int irq = irqd_to_hwirq(irqd); unsigned int irq_off = irq % 32; From 5b8aae489a07ac7d5a2cb897d6ca1fddb0c0043a Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Fri, 5 Jul 2013 15:39:11 +0800 Subject: [PATCH 0601/1048] irqchip: nvic: Fix wrong num_ct argument for irq_alloc_domain_generic_chips() The third parameter of irq_alloc_domain_generic_chips() is the number of irq_chip_type instances associated with these chips rather than numbanks. Signed-off-by: Axel Lin Cc: Uwe Kleine-Koenig Cc: Catalin Marinas Cc: Arnd Bergmann Cc: Grant Likely Cc: kernel@pengutronix.de Cc: linux-arm-kernel@lists.infradead.org Signed-off-by: Thomas Gleixner --- drivers/irqchip/irq-nvic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/irqchip/irq-nvic.c b/drivers/irqchip/irq-nvic.c index 8d0c8b3181c5..70bdf6edb7bb 100644 --- a/drivers/irqchip/irq-nvic.c +++ b/drivers/irqchip/irq-nvic.c @@ -84,7 +84,7 @@ static int __init nvic_of_init(struct device_node *node, return -ENOMEM; } - ret = irq_alloc_domain_generic_chips(nvic_irq_domain, 32, numbanks, + ret = irq_alloc_domain_generic_chips(nvic_irq_domain, 32, 1, "nvic_irq", handle_fasteoi_irq, clr, 0, IRQ_GC_INIT_MASK_CACHE); if (ret) { From 002fca5df168922103a2bb52748f9984e6de80b2 Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Fri, 5 Jul 2013 17:13:12 +0800 Subject: [PATCH 0602/1048] genirq: generic chip: Use DIV_ROUND_UP to calculate numchips The number of interrupts in a domain may be not divisible by the number of interrupts each chip handles. Integer division may truncate the result, thus use DIV_ROUND_UP to count numchips. Seems all users of irq_alloc_domain_generic_chips() in current code do not have this issue. I just found the issue while reading the code. Signed-off-by: Axel Lin Cc: Grant Likely Cc: Tony Lindgren Cc: Arnd Bergmann Link: http://lkml.kernel.org/r/1373015592.18252.2.camel@phoenix Signed-off-by: Thomas Gleixner --- kernel/irq/generic-chip.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/irq/generic-chip.c b/kernel/irq/generic-chip.c index 1c39eccc1eaf..2f274f30b7e2 100644 --- a/kernel/irq/generic-chip.c +++ b/kernel/irq/generic-chip.c @@ -278,7 +278,7 @@ int irq_alloc_domain_generic_chips(struct irq_domain *d, int irqs_per_chip, if (d->revmap_type != IRQ_DOMAIN_MAP_LINEAR) return -EINVAL; - numchips = d->revmap_data.linear.size / irqs_per_chip; + numchips = DIV_ROUND_UP(d->revmap_data.linear.size, irqs_per_chip); if (!numchips) return -EINVAL; From 4de563ae821b1935b3c467a4606e5738b0b0df87 Mon Sep 17 00:00:00 2001 From: Jonas Jensen Date: Thu, 4 Jul 2013 14:38:51 +0200 Subject: [PATCH 0603/1048] irqchip: Add support for MOXA ART SoCs This patch adds an irqchip driver for the main interrupt controller found on MOXA ART SoCs. Signed-off-by: Jonas Jensen Cc: grant.likely@secretlab.ca Cc: thomas.petazzoni@free-electrons.com Cc: arnd@arndb.de Cc: u.kleine-koenig@pengutronix.de Cc: linux@arm.linux.org.uk Cc: linux-arm-kernel@lists.infradead.org Link: http://lkml.kernel.org/r/1372941531-6393-1-git-send-email-jonas.jensen@gmail.com Signed-off-by: Thomas Gleixner --- drivers/irqchip/Makefile | 1 + drivers/irqchip/irq-moxart.c | 117 +++++++++++++++++++++++++++++++++++ 2 files changed, 118 insertions(+) create mode 100644 drivers/irqchip/irq-moxart.c diff --git a/drivers/irqchip/Makefile b/drivers/irqchip/Makefile index 2065ef6a949c..e65c41a7366b 100644 --- a/drivers/irqchip/Makefile +++ b/drivers/irqchip/Makefile @@ -7,6 +7,7 @@ obj-$(CONFIG_ARCH_MXS) += irq-mxs.o obj-$(CONFIG_ARCH_S3C24XX) += irq-s3c24xx.o obj-$(CONFIG_METAG) += irq-metag-ext.o obj-$(CONFIG_METAG_PERFCOUNTER_IRQS) += irq-metag.o +obj-$(CONFIG_ARCH_MOXART) += irq-moxart.o obj-$(CONFIG_ORION_IRQCHIP) += irq-orion.o obj-$(CONFIG_ARCH_SUNXI) += irq-sun4i.o obj-$(CONFIG_ARCH_SPEAR3XX) += spear-shirq.o diff --git a/drivers/irqchip/irq-moxart.c b/drivers/irqchip/irq-moxart.c new file mode 100644 index 000000000000..5552fc2bf28a --- /dev/null +++ b/drivers/irqchip/irq-moxart.c @@ -0,0 +1,117 @@ +/* + * MOXA ART SoCs IRQ chip driver. + * + * Copyright (C) 2013 Jonas Jensen + * + * Jonas Jensen + * + * This file is licensed under the terms of the GNU General Public + * License version 2. This program is licensed "as is" without any + * warranty of any kind, whether express or implied. + */ + +#include +#include +#include +#include +#include +#include + +#include + +#include "irqchip.h" + +#define IRQ_SOURCE_REG 0 +#define IRQ_MASK_REG 0x04 +#define IRQ_CLEAR_REG 0x08 +#define IRQ_MODE_REG 0x0c +#define IRQ_LEVEL_REG 0x10 +#define IRQ_STATUS_REG 0x14 + +#define FIQ_SOURCE_REG 0x20 +#define FIQ_MASK_REG 0x24 +#define FIQ_CLEAR_REG 0x28 +#define FIQ_MODE_REG 0x2c +#define FIQ_LEVEL_REG 0x30 +#define FIQ_STATUS_REG 0x34 + + +struct moxart_irq_data { + void __iomem *base; + struct irq_domain *domain; + unsigned int interrupt_mask; +}; + +static struct moxart_irq_data intc; + +static asmlinkage void __exception_irq_entry handle_irq(struct pt_regs *regs) +{ + u32 irqstat; + int hwirq; + + irqstat = readl(intc.base + IRQ_STATUS_REG); + + while (irqstat) { + hwirq = ffs(irqstat) - 1; + handle_IRQ(irq_linear_revmap(intc.domain, hwirq), regs); + irqstat &= ~(1 << hwirq); + } +} + +static int __init moxart_of_intc_init(struct device_node *node, + struct device_node *parent) +{ + unsigned int clr = IRQ_NOREQUEST | IRQ_NOPROBE | IRQ_NOAUTOEN; + int ret; + struct irq_chip_generic *gc; + + intc.base = of_iomap(node, 0); + if (!intc.base) { + pr_err("%s: unable to map IC registers\n", + node->full_name); + return -EINVAL; + } + + intc.domain = irq_domain_add_linear(node, 32, &irq_generic_chip_ops, + intc.base); + if (!intc.domain) { + pr_err("%s: unable to create IRQ domain\n", node->full_name); + return -EINVAL; + } + + ret = irq_alloc_domain_generic_chips(intc.domain, 32, 1, + "MOXARTINTC", handle_edge_irq, + clr, 0, IRQ_GC_INIT_MASK_CACHE); + if (ret) { + pr_err("%s: could not allocate generic chip\n", + node->full_name); + irq_domain_remove(intc.domain); + return -EINVAL; + } + + ret = of_property_read_u32(node, "interrupt-mask", + &intc.interrupt_mask); + if (ret) + pr_err("%s: could not read interrupt-mask DT property\n", + node->full_name); + + gc = irq_get_domain_generic_chip(intc.domain, 0); + + gc->reg_base = intc.base; + gc->chip_types[0].regs.mask = IRQ_MASK_REG; + gc->chip_types[0].regs.ack = IRQ_CLEAR_REG; + gc->chip_types[0].chip.irq_ack = irq_gc_ack_set_bit; + gc->chip_types[0].chip.irq_mask = irq_gc_mask_clr_bit; + gc->chip_types[0].chip.irq_unmask = irq_gc_mask_set_bit; + + writel(0, intc.base + IRQ_MASK_REG); + writel(0xffffffff, intc.base + IRQ_CLEAR_REG); + + writel(intc.interrupt_mask, intc.base + IRQ_MODE_REG); + writel(intc.interrupt_mask, intc.base + IRQ_LEVEL_REG); + + set_handle_irq(handle_irq); + + return 0; +} +IRQCHIP_DECLARE(moxa_moxart_ic, "moxa,moxart-ic", moxart_of_intc_init); From 016fcab8ff46fca29375d484226ec91932aa4a07 Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Thu, 4 Jul 2013 20:01:02 -0300 Subject: [PATCH 0604/1048] ASoC: sglt5000: Fix the default value of CHIP_SSS_CTRL According to the sgtl5000 reference manual, the default value of CHIP_SSS_CTRL is 0x10. Reported-by: Oskar Schirmer Signed-off-by: Fabio Estevam Signed-off-by: Mark Brown Cc: stable@vger.kernel.org --- sound/soc/codecs/sgtl5000.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/codecs/sgtl5000.c b/sound/soc/codecs/sgtl5000.c index d441559dc92c..d659d3adcfb3 100644 --- a/sound/soc/codecs/sgtl5000.c +++ b/sound/soc/codecs/sgtl5000.c @@ -38,7 +38,7 @@ static const struct reg_default sgtl5000_reg_defaults[] = { { SGTL5000_CHIP_CLK_CTRL, 0x0008 }, { SGTL5000_CHIP_I2S_CTRL, 0x0010 }, - { SGTL5000_CHIP_SSS_CTRL, 0x0008 }, + { SGTL5000_CHIP_SSS_CTRL, 0x0010 }, { SGTL5000_CHIP_DAC_VOL, 0x3c3c }, { SGTL5000_CHIP_PAD_STRENGTH, 0x015f }, { SGTL5000_CHIP_ANA_HP_CTRL, 0x1818 }, From 5c78dfe87ea04b501ee000a7f03b9432ac9d008c Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Thu, 4 Jul 2013 20:01:03 -0300 Subject: [PATCH 0605/1048] ASoC: sglt5000: Fix SGTL5000_PLL_FRAC_DIV_MASK SGTL5000_PLL_FRAC_DIV_MASK is used to mask bits 0-10 (11 bits in total) of register CHIP_PLL_CTRL, so fix the mask to accomodate all this bit range. Reported-by: Oskar Schirmer Signed-off-by: Fabio Estevam Signed-off-by: Mark Brown Cc: stable@vger.kernel.org --- sound/soc/codecs/sgtl5000.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/codecs/sgtl5000.h b/sound/soc/codecs/sgtl5000.h index 4b69229a9818..2f8c88931f69 100644 --- a/sound/soc/codecs/sgtl5000.h +++ b/sound/soc/codecs/sgtl5000.h @@ -347,7 +347,7 @@ #define SGTL5000_PLL_INT_DIV_MASK 0xf800 #define SGTL5000_PLL_INT_DIV_SHIFT 11 #define SGTL5000_PLL_INT_DIV_WIDTH 5 -#define SGTL5000_PLL_FRAC_DIV_MASK 0x0700 +#define SGTL5000_PLL_FRAC_DIV_MASK 0x07ff #define SGTL5000_PLL_FRAC_DIV_SHIFT 0 #define SGTL5000_PLL_FRAC_DIV_WIDTH 11 From 82e414fa1dbbc07e7b6d582e4fbcc9b0a5299f7f Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Fri, 5 Jul 2013 12:36:24 +0100 Subject: [PATCH 0606/1048] ASoC: wm8994: Remove overly noisy debug logging This was committed in error. Signed-off-by: Mark Brown --- sound/soc/codecs/wm8994.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/sound/soc/codecs/wm8994.c b/sound/soc/codecs/wm8994.c index 25580b5a853f..1b89aa9029e8 100644 --- a/sound/soc/codecs/wm8994.c +++ b/sound/soc/codecs/wm8994.c @@ -3856,8 +3856,6 @@ static void wm8958_mic_work(struct work_struct *work) mic_complete_work.work); struct snd_soc_codec *codec = wm8994->hubs.codec; - dev_crit(codec->dev, "MIC WORK %x\n", wm8994->mic_status); - pm_runtime_get_sync(codec->dev); mutex_lock(&wm8994->accdet_lock); @@ -3867,8 +3865,6 @@ static void wm8958_mic_work(struct work_struct *work) mutex_unlock(&wm8994->accdet_lock); pm_runtime_put(codec->dev); - - dev_crit(codec->dev, "MIC WORK %x DONE\n", wm8994->mic_status); } static irqreturn_t wm8958_mic_irq(int irq, void *data) From 07ecbf244bc5b7537f615647871fa2a71ffab072 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 5 Jul 2013 10:31:43 -0300 Subject: [PATCH 0607/1048] [media] stb0899: restore minimal rate to 5Mbauds According with Manu Abraham, stb0899 seek algorithm is broken for symbol rates bellow to 5Mbauds. So, revert those patches: 55b3318 [media] stb0899: allow minimum symbol rate of 2000000 2eeed77 [media] stb0899: allow minimum symbol rate of 1000000 Requested-by: Manu Abraham Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb-frontends/stb0899_drv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/dvb-frontends/stb0899_drv.c b/drivers/media/dvb-frontends/stb0899_drv.c index 82391feb6839..3dd5714eadba 100644 --- a/drivers/media/dvb-frontends/stb0899_drv.c +++ b/drivers/media/dvb-frontends/stb0899_drv.c @@ -1581,7 +1581,7 @@ static struct dvb_frontend_ops stb0899_ops = { .frequency_max = 2150000, .frequency_stepsize = 0, .frequency_tolerance = 0, - .symbol_rate_min = 2000000, + .symbol_rate_min = 5000000, .symbol_rate_max = 45000000, .caps = FE_CAN_INVERSION_AUTO | From 896eba3ba41e1a978e9e47cf2837ef8963996bca Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Mon, 3 Jun 2013 15:55:41 +0200 Subject: [PATCH 0608/1048] ARM: omap5: omap5 has SCU and TWD These are selected by omap4 but used in common omap4/5 SMP code, so building an omap5-only kernel is actually broken without this patch. Signed-off-by: Arnd Bergmann Cc: Tony Lindgren --- arch/arm/mach-omap2/Kconfig | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/arm/mach-omap2/Kconfig b/arch/arm/mach-omap2/Kconfig index 1fdb46216590..1f8127afa744 100644 --- a/arch/arm/mach-omap2/Kconfig +++ b/arch/arm/mach-omap2/Kconfig @@ -110,6 +110,8 @@ config SOC_OMAP5 select ARM_CPU_SUSPEND if PM select ARM_GIC select CPU_V7 + select HAVE_ARM_SCU if SMP + select HAVE_ARM_TWD if LOCAL_TIMERS select HAVE_SMP select COMMON_CLK select HAVE_ARM_ARCH_TIMER From 514a590847ff42dc00ba6c6165736128ad7730a8 Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Thu, 13 Jun 2013 14:13:37 +0200 Subject: [PATCH 0609/1048] ARM: zynq: use DT_MACHINE_START The zynq platform code only supports DT based booting, so we should use DT_MACHINE_START rather than MACHINE_START. Signed-off-by: Arnd Bergmann Cc: Michal Simek --- arch/arm/mach-zynq/common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/mach-zynq/common.c b/arch/arm/mach-zynq/common.c index 4130e65a0e3f..5b799c29886e 100644 --- a/arch/arm/mach-zynq/common.c +++ b/arch/arm/mach-zynq/common.c @@ -101,7 +101,7 @@ static const char * const zynq_dt_match[] = { NULL }; -MACHINE_START(XILINX_EP107, "Xilinx Zynq Platform") +DT_MACHINE_START(XILINX_EP107, "Xilinx Zynq Platform") .smp = smp_ops(zynq_smp_ops), .map_io = zynq_map_io, .init_machine = zynq_init_machine, From 59d92875a6d9f056233fafd6abd41f86eba931ef Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Wed, 1 May 2013 00:02:26 +0200 Subject: [PATCH 0610/1048] ARM: OMAP: build mach-omap code only if needed If we build a kernel with CONFIG_ARCH_OMAP2PLUS enabled but all of the individual SoCs disabled, we run into a large number of link errors because if incorrect dependencies: arch/arm/mach-omap2/built-in.o: In function `_add_initiator_dep': arch/arm/mach-omap2/omap_hwmod.c:691: undefined reference to `clkdm_add_sleepdep' arch/arm/mach-omap2/built-in.o: In function `_del_initiator_dep': arch/arm/mach-omap2/omap_hwmod.c:720: undefined reference to `clkdm_del_sleepdep' arch/arm/mach-omap2/built-in.o: In function `_enable': arch/arm/mach-omap2/omap_hwmod.c:2145: undefined reference to `clkdm_in_hwsup' arch/arm/mach-omap2/omap_hwmod.c:2147: undefined reference to `clkdm_hwmod_enable' arch/arm/mach-omap2/omap_hwmod.c:2191: undefined reference to `clkdm_hwmod_disable' arch/arm/mach-omap2/omap_hwmod.c:2146: undefined reference to `clkdm_missing_idle_reporting' arch/arm/mach-omap2/built-in.o: In function `_idle': arch/arm/mach-omap2/omap_hwmod.c:2235: undefined reference to `clkdm_hwmod_disable' arch/arm/mach-omap2/built-in.o: In function `_shutdown': arch/arm/mach-omap2/omap_hwmod.c:2338: undefined reference to `clkdm_hwmod_disable' arch/arm/mach-omap2/built-in.o: In function `omap_hwmod_get_context_loss_count': arch/arm/mach-omap2/omap_hwmod.c:4071: undefined reference to `pwrdm_get_context_loss_count' arch/arm/mach-omap2/built-in.o: In function `omap_pm_clkdms_setup': arch/arm/mach-omap2/pm.c:114: undefined reference to `clkdm_allow_idle' arch/arm/mach-omap2/pm.c:117: undefined reference to `clkdm_sleep' arch/arm/mach-omap2/built-in.o: In function `omap2_common_pm_late_init': arch/arm/mach-omap2/pm.c:294: undefined reference to `omap_voltage_late_init' arch/arm/mach-omap2/built-in.o: In function `omap2_gpio_dev_init': arch/arm/mach-omap2/gpio.c:133: undefined reference to `pwrdm_can_ever_lose_context' We can avoid this if we make CONFIG_ARCH_OMAP2PLUS a silent option that gets enabled any time that one of the SoC versions is enabled. Cc: Tony Lindgren Signed-off-by: Arnd Bergmann --- arch/arm/configs/omap2plus_defconfig | 4 + arch/arm/mach-omap2/Kconfig | 166 +++++++++++++-------------- 2 files changed, 87 insertions(+), 83 deletions(-) diff --git a/arch/arm/configs/omap2plus_defconfig b/arch/arm/configs/omap2plus_defconfig index 2ac0ffb12f03..f9b7fccd795d 100644 --- a/arch/arm/configs/omap2plus_defconfig +++ b/arch/arm/configs/omap2plus_defconfig @@ -22,6 +22,10 @@ CONFIG_MODULE_SRCVERSION_ALL=y # CONFIG_BLK_DEV_BSG is not set CONFIG_ARCH_MULTI_V6=y CONFIG_ARCH_OMAP2PLUS=y +CONFIG_ARCH_OMAP2=y +CONFIG_ARCH_OMAP3=y +CONFIG_ARCH_OMAP4=y +CONFIG_SOC_AM33XX=y CONFIG_OMAP_RESET_CLOCKS=y CONFIG_OMAP_MUX_DEBUG=y CONFIG_ARCH_VEXPRESS_CA9X4=y diff --git a/arch/arm/mach-omap2/Kconfig b/arch/arm/mach-omap2/Kconfig index 1f8127afa744..5c1405157bb6 100644 --- a/arch/arm/mach-omap2/Kconfig +++ b/arch/arm/mach-omap2/Kconfig @@ -1,8 +1,90 @@ config ARCH_OMAP bool +config ARCH_OMAP2 + bool "TI OMAP2" + depends on ARCH_MULTI_V6 + select ARCH_OMAP2PLUS + select CPU_V6 + select MULTI_IRQ_HANDLER + select SOC_HAS_OMAP2_SDRC + select COMMON_CLK + +config ARCH_OMAP3 + bool "TI OMAP3" + depends on ARCH_MULTI_V7 + select ARCH_OMAP2PLUS + select ARCH_HAS_OPP + select ARM_CPU_SUSPEND if PM + select CPU_V7 + select MULTI_IRQ_HANDLER + select OMAP_INTERCONNECT + select PM_OPP if PM + select PM_RUNTIME if CPU_IDLE + select SOC_HAS_OMAP2_SDRC + select COMMON_CLK + select USB_ARCH_HAS_EHCI if USB_SUPPORT + +config ARCH_OMAP4 + bool "TI OMAP4" + depends on ARCH_MULTI_V7 + select ARCH_OMAP2PLUS + select ARCH_HAS_OPP + select ARCH_NEEDS_CPU_IDLE_COUPLED if SMP + select ARM_CPU_SUSPEND if PM + select ARM_ERRATA_720789 + select ARM_GIC + select CACHE_L2X0 + select CPU_V7 + select HAVE_ARM_SCU if SMP + select HAVE_ARM_TWD if LOCAL_TIMERS + select HAVE_SMP + select LOCAL_TIMERS if SMP + select OMAP_INTERCONNECT + select PL310_ERRATA_588369 + select PL310_ERRATA_727915 + select PM_OPP if PM + select PM_RUNTIME if CPU_IDLE + select USB_ARCH_HAS_EHCI if USB_SUPPORT + select COMMON_CLK + select ARM_ERRATA_754322 + select ARM_ERRATA_775420 + +config SOC_OMAP5 + bool "TI OMAP5" + depends on ARCH_MULTI_V7 + select ARCH_OMAP2PLUS + select ARM_CPU_SUSPEND if PM + select ARM_GIC + select CPU_V7 + select HAVE_ARM_SCU if SMP + select HAVE_ARM_TWD if LOCAL_TIMERS + select HAVE_SMP + select COMMON_CLK + select HAVE_ARM_ARCH_TIMER + +config SOC_AM33XX + bool "AM33XX support" + depends on ARCH_MULTI_V7 + select ARCH_OMAP2PLUS + select ARM_CPU_SUSPEND if PM + select CPU_V7 + select MULTI_IRQ_HANDLER + select COMMON_CLK + +config SOC_AM43XX + bool "TI AM43x" + depends on ARCH_MULTI_V7 + select CPU_V7 + select ARCH_OMAP2PLUS + select MULTI_IRQ_HANDLER + select ARM_GIC + select COMMON_CLK + select MACH_OMAP_GENERIC + config ARCH_OMAP2PLUS - bool "TI OMAP2/3/4/5 SoCs with device tree support" if (ARCH_MULTI_V6 || ARCH_MULTI_V7) + bool + select ARCH_HAS_BANDGAP select ARCH_HAS_CPUFREQ select ARCH_HAS_HOLES_MEMORYMODEL select ARCH_OMAP @@ -17,7 +99,6 @@ config ARCH_OMAP2PLUS select PROC_DEVICETREE if PROC_FS select SOC_BUS select SPARSE_IRQ - select TI_PRIV_EDMA select USE_OF help Systems based on OMAP2, OMAP3, OMAP4 or OMAP5 @@ -52,70 +133,6 @@ config SOC_HAS_REALTIME_COUNTER depends on SOC_OMAP5 default y -config ARCH_OMAP2 - bool "TI OMAP2" - depends on ARCH_OMAP2PLUS - depends on ARCH_MULTI_V6 - default y - select CPU_V6 - select MULTI_IRQ_HANDLER - select SOC_HAS_OMAP2_SDRC - select COMMON_CLK - -config ARCH_OMAP3 - bool "TI OMAP3" - depends on ARCH_OMAP2PLUS - depends on ARCH_MULTI_V7 - default y - select ARCH_HAS_OPP - select ARM_CPU_SUSPEND if PM - select CPU_V7 - select MULTI_IRQ_HANDLER - select OMAP_INTERCONNECT - select PM_OPP if PM - select PM_RUNTIME if CPU_IDLE - select SOC_HAS_OMAP2_SDRC - select COMMON_CLK - select USB_ARCH_HAS_EHCI if USB_SUPPORT - -config ARCH_OMAP4 - bool "TI OMAP4" - default y - depends on ARCH_OMAP2PLUS - depends on ARCH_MULTI_V7 - select ARCH_HAS_OPP - select ARCH_NEEDS_CPU_IDLE_COUPLED if SMP - select ARM_CPU_SUSPEND if PM - select ARM_ERRATA_720789 - select ARM_GIC - select CACHE_L2X0 - select CPU_V7 - select HAVE_ARM_SCU if SMP - select HAVE_ARM_TWD if LOCAL_TIMERS - select HAVE_SMP - select LOCAL_TIMERS if SMP - select OMAP_INTERCONNECT - select PL310_ERRATA_588369 - select PL310_ERRATA_727915 - select PM_OPP if PM - select PM_RUNTIME if CPU_IDLE - select USB_ARCH_HAS_EHCI if USB_SUPPORT - select COMMON_CLK - select ARM_ERRATA_754322 - select ARM_ERRATA_775420 - -config SOC_OMAP5 - bool "TI OMAP5" - depends on ARCH_MULTI_V7 - select ARM_CPU_SUSPEND if PM - select ARM_GIC - select CPU_V7 - select HAVE_ARM_SCU if SMP - select HAVE_ARM_TWD if LOCAL_TIMERS - select HAVE_SMP - select COMMON_CLK - select HAVE_ARM_ARCH_TIMER - comment "OMAP Core Type" depends on ARCH_OMAP2 @@ -143,23 +160,6 @@ config SOC_TI81XX depends on ARCH_OMAP3 default y -config SOC_AM33XX - bool "AM33XX support" - depends on ARCH_MULTI_V7 - default y - select ARM_CPU_SUSPEND if PM - select CPU_V7 - select MULTI_IRQ_HANDLER - select COMMON_CLK - -config SOC_AM43XX - bool "TI AM43x" - select CPU_V7 - select MULTI_IRQ_HANDLER - select ARM_GIC - select COMMON_CLK - select MACH_OMAP_GENERIC - config OMAP_PACKAGE_ZAF bool From 5562b80033231bd50bd6809ab2db3b2ce5670dc3 Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Fri, 5 Jul 2013 16:08:44 +0200 Subject: [PATCH 0611/1048] ARM: sti: move DEBUG_STI_UART into alphabetical order This was accidentally added in the wrong place, messing up the ordering of the file. Signed-off-by: Arnd Bergmann --- arch/arm/Kconfig.debug | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/arch/arm/Kconfig.debug b/arch/arm/Kconfig.debug index 77c1411c9a91..ff4920b1f6c5 100644 --- a/arch/arm/Kconfig.debug +++ b/arch/arm/Kconfig.debug @@ -510,6 +510,16 @@ choice Say Y here if you want the debug print routines to direct their output to the uart1 port on SiRFmarco devices. + config DEBUG_STI_UART + depends on ARCH_STI + bool "Use StiH415/416 ASC for low-level debug" + help + Say Y here if you want kernel low-level debugging support + on StiH415/416 based platforms like B2000, B2020. + It support UART2 and SBC_UART1. + + If unsure, say N. + config DEBUG_U300_UART bool "Kernel low-level debugging messages via U300 UART0" depends on ARCH_U300 @@ -557,16 +567,6 @@ choice This option selects UART0 on VIA/Wondermedia System-on-a-chip devices, including VT8500, WM8505, WM8650 and WM8850. - config DEBUG_STI_UART - depends on ARCH_STI - bool "Use StiH415/416 ASC for low-level debug" - help - Say Y here if you want kernel low-level debugging support - on StiH415/416 based platforms like B2000, B2020. - It support UART2 and SBC_UART1. - - If unsure, say N. - config DEBUG_LL_UART_NONE bool "No low-level debugging UART" depends on !ARCH_MULTIPLATFORM From 069d0a7870f45a3eb0540825d6dc517eda2a525a Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Fri, 5 Jul 2013 16:20:17 +0200 Subject: [PATCH 0612/1048] ARM: OMAP: omap_common_late_init may be unused Some OMAP SoCs use this function while others do not, and that causes a warning when building multi_v7_defconfig. Marking the function __maybe_unused silences the harmless warning without the need to add complex #ifdef logic. Signed-off-by: Arnd Bergmann Cc: Tony Lindgren --- arch/arm/mach-omap2/io.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/mach-omap2/io.c b/arch/arm/mach-omap2/io.c index fe3253a100e7..4a3f06f02859 100644 --- a/arch/arm/mach-omap2/io.c +++ b/arch/arm/mach-omap2/io.c @@ -394,7 +394,7 @@ static void __init omap_hwmod_init_postsetup(void) omap_pm_if_early_init(); } -static void __init omap_common_late_init(void) +static void __init __maybe_unused omap_common_late_init(void) { omap_mux_late_init(); omap2_common_pm_late_init(); From 7a6a731bd00ca90d0e250867c3b9c05b5ff0fa49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Mork?= Date: Wed, 21 Nov 2012 09:54:48 +0100 Subject: [PATCH 0613/1048] [SCSI] megaraid_sas: fix memory leak if SGL has zero length entries MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit commit 98cb7e44 ([SCSI] megaraid_sas: Sanity check user supplied length before passing it to dma_alloc_coherent()) introduced a memory leak. Memory allocated for entries following zero length SGL entries will not be freed. Reference: http://bugs.debian.org/688198 Signed-off-by: Bjørn Mork Cc: Acked-by: Adam Radford Signed-off-by: James Bottomley --- drivers/scsi/megaraid/megaraid_sas_base.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c index 6002d363c637..0177295599e0 100644 --- a/drivers/scsi/megaraid/megaraid_sas_base.c +++ b/drivers/scsi/megaraid/megaraid_sas_base.c @@ -4958,10 +4958,12 @@ megasas_mgmt_fw_ioctl(struct megasas_instance *instance, sense, sense_handle); } - for (i = 0; i < ioc->sge_count && kbuff_arr[i]; i++) { - dma_free_coherent(&instance->pdev->dev, - kern_sge32[i].length, - kbuff_arr[i], kern_sge32[i].phys_addr); + for (i = 0; i < ioc->sge_count; i++) { + if (kbuff_arr[i]) + dma_free_coherent(&instance->pdev->dev, + kern_sge32[i].length, + kbuff_arr[i], + kern_sge32[i].phys_addr); } megasas_return_cmd(instance, cmd); From c8a2ba3f50f7445b3d1b822ba1a8168b4234baca Mon Sep 17 00:00:00 2001 From: Yijing Wang Date: Thu, 27 Jun 2013 15:02:49 +0800 Subject: [PATCH 0614/1048] [SCSI] pm8001: use pdev->pm_cap instead of pci_find_capability(..,PCI_CAP_ID_PM) Pci core has been saved pm cap register offset by pdev->pm_cap in pci_pm_init() in init path. So we can use pdev->pm_cap instead of using pci_find_capability(pdev, PCI_CAP_ID_PM) for better performance and simplified code. Tested-by: Lindar Liu Signed-off-by: Yijing Wang Acked-by: Lindar Liu Signed-off-by: James Bottomley --- drivers/scsi/pm8001/pm8001_init.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/scsi/pm8001/pm8001_init.c b/drivers/scsi/pm8001/pm8001_init.c index e4b9bc7f5410..3861aa1f4520 100644 --- a/drivers/scsi/pm8001/pm8001_init.c +++ b/drivers/scsi/pm8001/pm8001_init.c @@ -912,14 +912,13 @@ static int pm8001_pci_suspend(struct pci_dev *pdev, pm_message_t state) { struct sas_ha_struct *sha = pci_get_drvdata(pdev); struct pm8001_hba_info *pm8001_ha; - int i , pos; + int i; u32 device_state; pm8001_ha = sha->lldd_ha; flush_workqueue(pm8001_wq); scsi_block_requests(pm8001_ha->shost); - pos = pci_find_capability(pdev, PCI_CAP_ID_PM); - if (pos == 0) { - printk(KERN_ERR " PCI PM not supported\n"); + if (!pdev->pm_cap) { + dev_err(&pdev->dev, " PCI PM not supported\n"); return -ENODEV; } PM8001_CHIP_DISP->interrupt_disable(pm8001_ha, 0xFF); From 39f1601c3f840f6e055f7d9726a1a1e9acbefd78 Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Fri, 5 Jul 2013 16:25:44 +0200 Subject: [PATCH 0615/1048] ARM: ixp4xx: avoid circular header dependency With the new linux/reboot.h header file dependency added, we can no longer build ixp4xx. The easiest way to avoid that is to remove the inclusion of mach/hardware.h from mach/timex.h, which does not need that header anyway. Signed-off-by: Arnd Bergmann Cc: Imre Kaloz Cc: Krzysztof Halasa Cc: Jason Cooper --- arch/arm/mach-ixp4xx/dsmg600-setup.c | 2 ++ arch/arm/mach-ixp4xx/include/mach/timex.h | 2 +- arch/arm/mach-ixp4xx/omixp-setup.c | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/arch/arm/mach-ixp4xx/dsmg600-setup.c b/arch/arm/mach-ixp4xx/dsmg600-setup.c index 5d413f8c5700..63de1b3fd06b 100644 --- a/arch/arm/mach-ixp4xx/dsmg600-setup.c +++ b/arch/arm/mach-ixp4xx/dsmg600-setup.c @@ -27,6 +27,8 @@ #include #include +#include + #include #include #include diff --git a/arch/arm/mach-ixp4xx/include/mach/timex.h b/arch/arm/mach-ixp4xx/include/mach/timex.h index c9e930f29339..0396d89f947c 100644 --- a/arch/arm/mach-ixp4xx/include/mach/timex.h +++ b/arch/arm/mach-ixp4xx/include/mach/timex.h @@ -3,7 +3,7 @@ * */ -#include +#include /* * We use IXP425 General purpose timer for our timer needs, it runs at diff --git a/arch/arm/mach-ixp4xx/omixp-setup.c b/arch/arm/mach-ixp4xx/omixp-setup.c index 46a89f5e8269..75ef03dc9964 100644 --- a/arch/arm/mach-ixp4xx/omixp-setup.c +++ b/arch/arm/mach-ixp4xx/omixp-setup.c @@ -27,6 +27,8 @@ #include #include +#include + static struct resource omixp_flash_resources[] = { { .flags = IORESOURCE_MEM, From c1fe55e0b6227093d6faa09ce6932fbcd86aeea2 Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Mon, 17 Jun 2013 09:56:42 +0200 Subject: [PATCH 0616/1048] ARM: exynos: select PM_GENERIC_DOMAINS only when used This fixes building exynos kernels with CONFIG_PM disabled. Signed-off-by: Arnd Bergmann Cc: Kukjin Kim --- arch/arm/mach-exynos/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/mach-exynos/Kconfig b/arch/arm/mach-exynos/Kconfig index 2d503b3684c4..ba70a846d1c6 100644 --- a/arch/arm/mach-exynos/Kconfig +++ b/arch/arm/mach-exynos/Kconfig @@ -38,7 +38,7 @@ config CPU_EXYNOS4210 depends on ARCH_EXYNOS4 select ARM_CPU_SUSPEND if PM select PINCTRL_EXYNOS - select PM_GENERIC_DOMAINS + select PM_GENERIC_DOMAINS if PM select S5P_PM if PM select S5P_SLEEP if PM select SAMSUNG_DMADEV From 27d7c4ed1f7dfa3fc462e870dc60a4c9c2253f3e Mon Sep 17 00:00:00 2001 From: Jan Kara Date: Fri, 5 Jul 2013 21:57:22 -0400 Subject: [PATCH 0617/1048] ext4: silence warning in ext4_writepages() The loop in mpage_map_and_submit_extent() is guaranteed to always run at least once since the caller of mpage_map_and_submit_extent() makes sure map->m_len > 0. So make that explicit using do-while instead of pure while which also silences the compiler warning about uninitialized 'err' variable. Signed-off-by: Jan Kara Signed-off-by: "Theodore Ts'o" Reviewed-by: Lukas Czerner --- fs/ext4/inode.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 0188e65e1f58..19a1643cbdfa 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -2163,7 +2163,7 @@ static int mpage_map_and_submit_extent(handle_t *handle, mpd->io_submit.io_end->offset = ((loff_t)map->m_lblk) << inode->i_blkbits; - while (map->m_len) { + do { err = mpage_map_one_extent(handle, mpd); if (err < 0) { struct super_block *sb = inode->i_sb; @@ -2201,7 +2201,7 @@ static int mpage_map_and_submit_extent(handle_t *handle, err = mpage_map_and_submit_buffers(mpd); if (err < 0) return err; - } + } while (map->m_len); /* Update on-disk size after IO is submitted */ disksize = ((loff_t)mpd->first_page) << PAGE_CACHE_SHIFT; From 960fd856fdc3b08b3638f3f9b6b4bfceb77660c7 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Fri, 5 Jul 2013 23:11:16 -0400 Subject: [PATCH 0618/1048] ext4: fix ext4_get_group_number() The function ext4_get_group_number() was introduced as an optimization in commit bd86298e60b8. Unfortunately, this commit incorrectly calculate the group number for file systems with a 1k block size (when s_first_data_block is 1 instead of zero). This could cause the following kernel BUG: [ 568.877799] ------------[ cut here ]------------ [ 568.877833] kernel BUG at fs/ext4/mballoc.c:3728! [ 568.877840] Oops: Exception in kernel mode, sig: 5 [#1] [ 568.877845] SMP NR_CPUS=32 NUMA pSeries [ 568.877852] Modules linked in: binfmt_misc [ 568.877861] CPU: 1 PID: 3516 Comm: fs_mark Not tainted 3.10.0-03216-g7c6809f-dirty #1 [ 568.877867] task: c0000001fb0b8000 ti: c0000001fa954000 task.ti: c0000001fa954000 [ 568.877873] NIP: c0000000002f42a4 LR: c0000000002f4274 CTR: c000000000317ef8 [ 568.877879] REGS: c0000001fa956ed0 TRAP: 0700 Not tainted (3.10.0-03216-g7c6809f-dirty) [ 568.877884] MSR: 8000000000029032 CR: 24000428 XER: 00000000 [ 568.877902] SOFTE: 1 [ 568.877905] CFAR: c0000000002b5464 [ 568.877908] GPR00: 0000000000000001 c0000001fa957150 c000000000c6a408 c0000001fb588000 GPR04: 0000000000003fff c0000001fa9571c0 c0000001fa9571c4 000138098c50625f GPR08: 1301200000000000 0000000000000002 0000000000000001 0000000000000000 GPR12: 0000000024000422 c00000000f33a300 0000000000008000 c0000001fa9577f0 GPR16: c0000001fb7d0100 c000000000c29190 c0000000007f46e8 c000000000a14672 GPR20: 0000000000000001 0000000000000008 ffffffffffffffff 0000000000000000 GPR24: 0000000000000100 c0000001fa957278 c0000001fdb2bc78 c0000001fa957288 GPR28: 0000000000100100 c0000001fa957288 c0000001fb588000 c0000001fdb2bd10 [ 568.877993] NIP [c0000000002f42a4] .ext4_mb_release_group_pa+0xec/0x1c0 [ 568.877999] LR [c0000000002f4274] .ext4_mb_release_group_pa+0xbc/0x1c0 [ 568.878004] Call Trace: [ 568.878008] [c0000001fa957150] [c0000000002f4274] .ext4_mb_release_group_pa+0xbc/0x1c0 (unreliable) [ 568.878017] [c0000001fa957200] [c0000000002fb070] .ext4_mb_discard_lg_preallocations+0x394/0x444 [ 568.878025] [c0000001fa957340] [c0000000002fb45c] .ext4_mb_release_context+0x33c/0x734 [ 568.878032] [c0000001fa957440] [c0000000002fbcf8] .ext4_mb_new_blocks+0x4a4/0x5f4 [ 568.878039] [c0000001fa957510] [c0000000002ef56c] .ext4_ext_map_blocks+0xc28/0x1178 [ 568.878047] [c0000001fa957640] [c0000000002c1a94] .ext4_map_blocks+0x2c8/0x490 [ 568.878054] [c0000001fa957730] [c0000000002c536c] .ext4_writepages+0x738/0xc60 [ 568.878062] [c0000001fa957950] [c000000000168a78] .do_writepages+0x5c/0x80 [ 568.878069] [c0000001fa9579d0] [c00000000015d1c4] .__filemap_fdatawrite_range+0x88/0xb0 [ 568.878078] [c0000001fa957aa0] [c00000000015d23c] .filemap_write_and_wait_range+0x50/0xfc [ 568.878085] [c0000001fa957b30] [c0000000002b8edc] .ext4_sync_file+0x220/0x3c4 [ 568.878092] [c0000001fa957be0] [c0000000001f849c] .vfs_fsync_range+0x64/0x80 [ 568.878098] [c0000001fa957c70] [c0000000001f84f0] .vfs_fsync+0x38/0x4c [ 568.878105] [c0000001fa957d00] [c0000000001f87f4] .do_fsync+0x54/0x90 [ 568.878111] [c0000001fa957db0] [c0000000001f8894] .SyS_fsync+0x28/0x3c [ 568.878120] [c0000001fa957e30] [c000000000009c88] syscall_exit+0x0/0x7c [ 568.878125] Instruction dump: [ 568.878130] 60000000 813d0034 81610070 38000000 7f8b4800 419e001c 813f007c 7d2bfe70 [ 568.878144] 7d604a78 7c005850 54000ffe 7c0007b4 <0b000000> e8a10076 e87f0090 7fa4eb78 [ 568.878160] ---[ end trace 594d911d9654770b ]--- In addition fix the STD_GROUP optimization so that it works for bigalloc file systems as well. Signed-off-by: "Theodore Ts'o" Reported-by: Li Zhong Reviewed-by: Lukas Czerner Cc: stable@vger.kernel.org # 3.10 --- fs/ext4/balloc.c | 4 ++-- fs/ext4/super.c | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c index 58339393fa6e..ddd715e42a5c 100644 --- a/fs/ext4/balloc.c +++ b/fs/ext4/balloc.c @@ -38,8 +38,8 @@ ext4_group_t ext4_get_group_number(struct super_block *sb, ext4_group_t group; if (test_opt2(sb, STD_GROUP_SIZE)) - group = (le32_to_cpu(EXT4_SB(sb)->s_es->s_first_data_block) + - block) >> + group = (block - + le32_to_cpu(EXT4_SB(sb)->s_es->s_first_data_block)) >> (EXT4_BLOCK_SIZE_BITS(sb) + EXT4_CLUSTER_BITS(sb) + 3); else ext4_get_group_no_and_offset(sb, block, &group, NULL); diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 85b3dd60169b..8862d4ddf71f 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -3624,10 +3624,6 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) sbi->s_addr_per_block_bits = ilog2(EXT4_ADDR_PER_BLOCK(sb)); sbi->s_desc_per_block_bits = ilog2(EXT4_DESC_PER_BLOCK(sb)); - /* Do we have standard group size of blocksize * 8 blocks ? */ - if (sbi->s_blocks_per_group == blocksize << 3) - set_opt2(sb, STD_GROUP_SIZE); - for (i = 0; i < 4; i++) sbi->s_hash_seed[i] = le32_to_cpu(es->s_hash_seed[i]); sbi->s_def_hash_version = es->s_def_hash_version; @@ -3697,6 +3693,10 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) goto failed_mount; } + /* Do we have standard group size of clustersize * 8 blocks ? */ + if (sbi->s_blocks_per_group == clustersize << 3) + set_opt2(sb, STD_GROUP_SIZE); + /* * Test whether we have more sectors than will fit in sector_t, * and whether the max offset is addressable by the page cache. From 2a961d0995cdadbfba565b28beada59c5ae7ebae Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Wed, 3 Jul 2013 22:25:00 +0100 Subject: [PATCH 0619/1048] iio: mxs-lradc: Remove useless check in read_raw The removed check in the read_raw implementation was always true, therefore remove it. This also fixes a bug, by closely inspecting the code, one can notice the iio_validate_scan_mask_onehot() will always return 1 and therefore the subsequent condition will always succeed, therefore making the mxs_lradc_read_raw() function always return -EINVAL; . Signed-off-by: Marek Vasut Tested-by: Otavio Salvador Acked-by: Hector Palacios Signed-off-by: Jonathan Cameron --- drivers/staging/iio/adc/mxs-lradc.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/drivers/staging/iio/adc/mxs-lradc.c b/drivers/staging/iio/adc/mxs-lradc.c index c5edf1cad07a..9f52a2857929 100644 --- a/drivers/staging/iio/adc/mxs-lradc.c +++ b/drivers/staging/iio/adc/mxs-lradc.c @@ -234,7 +234,6 @@ static int mxs_lradc_read_raw(struct iio_dev *iio_dev, { struct mxs_lradc *lradc = iio_priv(iio_dev); int ret; - unsigned long mask; if (m != IIO_CHAN_INFO_RAW) return -EINVAL; @@ -243,12 +242,6 @@ static int mxs_lradc_read_raw(struct iio_dev *iio_dev, if (chan->channel > LRADC_MAX_TOTAL_CHANS) return -EINVAL; - /* Validate the channel if it doesn't intersect with reserved chans. */ - bitmap_set(&mask, chan->channel, 1); - ret = iio_validate_scan_mask_onehot(iio_dev, &mask); - if (ret) - return -EINVAL; - /* * See if there is no buffered operation in progess. If there is, simply * bail out. This can be improved to support both buffered and raw IO at From bc93aa7640fe97df8d69b50fdce70da1126e12b3 Mon Sep 17 00:00:00 2001 From: Wei Yongjun Date: Sat, 6 Jul 2013 05:20:00 +0100 Subject: [PATCH 0620/1048] iio: ti_am335x_adc: add missing .driver_module to struct iio_info Add missing .driver_module of struct iio_info. This prevents the module from being removed from underneath its users. Signed-off-by: Wei Yongjun Signed-off-by: Jonathan Cameron --- drivers/iio/adc/ti_am335x_adc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/iio/adc/ti_am335x_adc.c b/drivers/iio/adc/ti_am335x_adc.c index 5f9a7e7d3135..985f58873d03 100644 --- a/drivers/iio/adc/ti_am335x_adc.c +++ b/drivers/iio/adc/ti_am335x_adc.c @@ -134,6 +134,7 @@ static int tiadc_read_raw(struct iio_dev *indio_dev, static const struct iio_info tiadc_info = { .read_raw = &tiadc_read_raw, + .driver_module = THIS_MODULE, }; static int tiadc_probe(struct platform_device *pdev) From bb3779610254ea5efbf8ec727138e041d801747c Mon Sep 17 00:00:00 2001 From: Wei Yongjun Date: Thu, 4 Jul 2013 14:46:00 +0100 Subject: [PATCH 0621/1048] staging:iio:ad7291: add missing .driver_module to struct iio_info Add missing .driver_module of struct iio_info. This prevents the module from being removed from underneath its users. Signed-off-by: Wei Yongjun Signed-off-by: Jonathan Cameron --- drivers/staging/iio/adc/ad7291.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/iio/adc/ad7291.c b/drivers/staging/iio/adc/ad7291.c index 3fc79e582750..a2e61c2fc8d1 100644 --- a/drivers/staging/iio/adc/ad7291.c +++ b/drivers/staging/iio/adc/ad7291.c @@ -517,6 +517,7 @@ static const struct iio_info ad7291_info = { .read_event_value = &ad7291_read_event_value, .write_event_value = &ad7291_write_event_value, .event_attrs = &ad7291_event_attribute_group, + .driver_module = THIS_MODULE, }; static int ad7291_probe(struct i2c_client *client, From 62f548d0c2d2418e39b8e4b7ec39b5ca2ef4380d Mon Sep 17 00:00:00 2001 From: Ferruh Yigit Date: Thu, 4 Jul 2013 14:02:57 -0700 Subject: [PATCH 0622/1048] Input: cyttsp4 - use 16bit address for I2C/SPI communication In TSG4, register map is 512bytes long and to access all of it, one bit from address byte is used (which bit to use differs for I2C and SPI); Since common code used for TSG3 and TSG4 for I2C, this parameter wrongly used as u8. TSG3 does not access beyond 255 bytes but TSG4 may. Tested-on:TMA3XX DVB && TMA4XX DVB Signed-off-by: Ferruh Yigit Acked-by: Javier Martinez Canillas Signed-off-by: Dmitry Torokhov --- drivers/input/touchscreen/cyttsp4_core.h | 12 ++++---- drivers/input/touchscreen/cyttsp4_spi.c | 20 ++++++------- drivers/input/touchscreen/cyttsp_core.h | 8 ++--- drivers/input/touchscreen/cyttsp_i2c_common.c | 30 ++++++++++++++----- drivers/input/touchscreen/cyttsp_spi.c | 6 ++-- 5 files changed, 44 insertions(+), 32 deletions(-) diff --git a/drivers/input/touchscreen/cyttsp4_core.h b/drivers/input/touchscreen/cyttsp4_core.h index 86a254354136..8e0d4d490b20 100644 --- a/drivers/input/touchscreen/cyttsp4_core.h +++ b/drivers/input/touchscreen/cyttsp4_core.h @@ -369,9 +369,9 @@ struct cyttsp4 { struct cyttsp4_bus_ops { u16 bustype; - int (*write)(struct device *dev, u8 *xfer_buf, u8 addr, u8 length, + int (*write)(struct device *dev, u8 *xfer_buf, u16 addr, u8 length, const void *values); - int (*read)(struct device *dev, u8 *xfer_buf, u8 addr, u8 length, + int (*read)(struct device *dev, u8 *xfer_buf, u16 addr, u8 length, void *values); }; @@ -448,13 +448,13 @@ enum cyttsp4_event_id { /* y-axis, 0:origin is on top side of panel, 1: bottom */ #define CY_PCFG_ORIGIN_Y_MASK 0x80 -static inline int cyttsp4_adap_read(struct cyttsp4 *ts, u8 addr, int size, +static inline int cyttsp4_adap_read(struct cyttsp4 *ts, u16 addr, int size, void *buf) { return ts->bus_ops->read(ts->dev, ts->xfer_buf, addr, size, buf); } -static inline int cyttsp4_adap_write(struct cyttsp4 *ts, u8 addr, int size, +static inline int cyttsp4_adap_write(struct cyttsp4 *ts, u16 addr, int size, const void *buf) { return ts->bus_ops->write(ts->dev, ts->xfer_buf, addr, size, buf); @@ -463,9 +463,9 @@ static inline int cyttsp4_adap_write(struct cyttsp4 *ts, u8 addr, int size, extern struct cyttsp4 *cyttsp4_probe(const struct cyttsp4_bus_ops *ops, struct device *dev, u16 irq, size_t xfer_buf_size); extern int cyttsp4_remove(struct cyttsp4 *ts); -int cyttsp_i2c_write_block_data(struct device *dev, u8 *xfer_buf, u8 addr, +int cyttsp_i2c_write_block_data(struct device *dev, u8 *xfer_buf, u16 addr, u8 length, const void *values); -int cyttsp_i2c_read_block_data(struct device *dev, u8 *xfer_buf, u8 addr, +int cyttsp_i2c_read_block_data(struct device *dev, u8 *xfer_buf, u16 addr, u8 length, void *values); extern const struct dev_pm_ops cyttsp4_pm_ops; diff --git a/drivers/input/touchscreen/cyttsp4_spi.c b/drivers/input/touchscreen/cyttsp4_spi.c index f8f891bead34..a71e1141d638 100644 --- a/drivers/input/touchscreen/cyttsp4_spi.c +++ b/drivers/input/touchscreen/cyttsp4_spi.c @@ -44,7 +44,7 @@ #define CY_SPI_DATA_BUF_SIZE (CY_SPI_CMD_BYTES + CY_SPI_DATA_SIZE) static int cyttsp_spi_xfer(struct device *dev, u8 *xfer_buf, - u8 op, u8 reg, u8 *buf, int length) + u8 op, u16 reg, u8 *buf, int length) { struct spi_device *spi = to_spi_device(dev); struct spi_message msg; @@ -63,14 +63,12 @@ static int cyttsp_spi_xfer(struct device *dev, u8 *xfer_buf, memset(wr_buf, 0, CY_SPI_DATA_BUF_SIZE); memset(rd_buf, 0, CY_SPI_CMD_BYTES); - if (reg > 255) - wr_buf[0] = op + CY_SPI_A8_BIT; - else - wr_buf[0] = op; - if (op == CY_SPI_WR_OP) - wr_buf[1] = reg % 256; - if (op == CY_SPI_WR_OP && length > 0) - memcpy(wr_buf + CY_SPI_CMD_BYTES, buf, length); + wr_buf[0] = op + (((reg >> 8) & 0x1) ? CY_SPI_A8_BIT : 0); + if (op == CY_SPI_WR_OP) { + wr_buf[1] = reg & 0xFF; + if (length > 0) + memcpy(wr_buf + CY_SPI_CMD_BYTES, buf, length); + } memset(xfer, 0, sizeof(xfer)); spi_message_init(&msg); @@ -130,7 +128,7 @@ static int cyttsp_spi_xfer(struct device *dev, u8 *xfer_buf, } static int cyttsp_spi_read_block_data(struct device *dev, u8 *xfer_buf, - u8 addr, u8 length, void *data) + u16 addr, u8 length, void *data) { int rc; @@ -143,7 +141,7 @@ static int cyttsp_spi_read_block_data(struct device *dev, u8 *xfer_buf, } static int cyttsp_spi_write_block_data(struct device *dev, u8 *xfer_buf, - u8 addr, u8 length, const void *data) + u16 addr, u8 length, const void *data) { return cyttsp_spi_xfer(dev, xfer_buf, CY_SPI_WR_OP, addr, (void *)data, length); diff --git a/drivers/input/touchscreen/cyttsp_core.h b/drivers/input/touchscreen/cyttsp_core.h index 0cf564a79fb5..07074110a902 100644 --- a/drivers/input/touchscreen/cyttsp_core.h +++ b/drivers/input/touchscreen/cyttsp_core.h @@ -112,9 +112,9 @@ struct cyttsp; struct cyttsp_bus_ops { u16 bustype; - int (*write)(struct device *dev, u8 *xfer_buf, u8 addr, u8 length, + int (*write)(struct device *dev, u8 *xfer_buf, u16 addr, u8 length, const void *values); - int (*read)(struct device *dev, u8 *xfer_buf, u8 addr, u8 length, + int (*read)(struct device *dev, u8 *xfer_buf, u16 addr, u8 length, void *values); }; @@ -145,9 +145,9 @@ struct cyttsp *cyttsp_probe(const struct cyttsp_bus_ops *bus_ops, struct device *dev, int irq, size_t xfer_buf_size); void cyttsp_remove(struct cyttsp *ts); -int cyttsp_i2c_write_block_data(struct device *dev, u8 *xfer_buf, u8 addr, +int cyttsp_i2c_write_block_data(struct device *dev, u8 *xfer_buf, u16 addr, u8 length, const void *values); -int cyttsp_i2c_read_block_data(struct device *dev, u8 *xfer_buf, u8 addr, +int cyttsp_i2c_read_block_data(struct device *dev, u8 *xfer_buf, u16 addr, u8 length, void *values); extern const struct dev_pm_ops cyttsp_pm_ops; diff --git a/drivers/input/touchscreen/cyttsp_i2c_common.c b/drivers/input/touchscreen/cyttsp_i2c_common.c index 07c553fbcef2..1d7b6f154168 100644 --- a/drivers/input/touchscreen/cyttsp_i2c_common.c +++ b/drivers/input/touchscreen/cyttsp_i2c_common.c @@ -32,18 +32,20 @@ #include int cyttsp_i2c_read_block_data(struct device *dev, u8 *xfer_buf, - u8 addr, u8 length, void *values) + u16 addr, u8 length, void *values) { struct i2c_client *client = to_i2c_client(dev); + u8 client_addr = client->addr | ((addr >> 8) & 0x1); + u8 addr_lo = addr & 0xFF; struct i2c_msg msgs[] = { { - .addr = client->addr, + .addr = client_addr, .flags = 0, .len = 1, - .buf = &addr, + .buf = &addr_lo, }, { - .addr = client->addr, + .addr = client_addr, .flags = I2C_M_RD, .len = length, .buf = values, @@ -60,17 +62,29 @@ int cyttsp_i2c_read_block_data(struct device *dev, u8 *xfer_buf, EXPORT_SYMBOL_GPL(cyttsp_i2c_read_block_data); int cyttsp_i2c_write_block_data(struct device *dev, u8 *xfer_buf, - u8 addr, u8 length, const void *values) + u16 addr, u8 length, const void *values) { struct i2c_client *client = to_i2c_client(dev); + u8 client_addr = client->addr | ((addr >> 8) & 0x1); + u8 addr_lo = addr & 0xFF; + struct i2c_msg msgs[] = { + { + .addr = client_addr, + .flags = 0, + .len = length + 1, + .buf = xfer_buf, + }, + }; int retval; - xfer_buf[0] = addr; + xfer_buf[0] = addr_lo; memcpy(&xfer_buf[1], values, length); - retval = i2c_master_send(client, xfer_buf, length + 1); + retval = i2c_transfer(client->adapter, msgs, ARRAY_SIZE(msgs)); + if (retval < 0) + return retval; - return retval < 0 ? retval : 0; + return retval != ARRAY_SIZE(msgs) ? -EIO : 0; } EXPORT_SYMBOL_GPL(cyttsp_i2c_write_block_data); diff --git a/drivers/input/touchscreen/cyttsp_spi.c b/drivers/input/touchscreen/cyttsp_spi.c index 1df625337b84..4728bcb1916c 100644 --- a/drivers/input/touchscreen/cyttsp_spi.c +++ b/drivers/input/touchscreen/cyttsp_spi.c @@ -41,7 +41,7 @@ #define CY_SPI_BITS_PER_WORD 8 static int cyttsp_spi_xfer(struct device *dev, u8 *xfer_buf, - u8 op, u8 reg, u8 *buf, int length) + u8 op, u16 reg, u8 *buf, int length) { struct spi_device *spi = to_spi_device(dev); struct spi_message msg; @@ -126,14 +126,14 @@ static int cyttsp_spi_xfer(struct device *dev, u8 *xfer_buf, } static int cyttsp_spi_read_block_data(struct device *dev, u8 *xfer_buf, - u8 addr, u8 length, void *data) + u16 addr, u8 length, void *data) { return cyttsp_spi_xfer(dev, xfer_buf, CY_SPI_RD_OP, addr, data, length); } static int cyttsp_spi_write_block_data(struct device *dev, u8 *xfer_buf, - u8 addr, u8 length, const void *data) + u16 addr, u8 length, const void *data) { return cyttsp_spi_xfer(dev, xfer_buf, CY_SPI_WR_OP, addr, (void *)data, length); From 9eebed7de660c0b5ab129a9de4f89d20b60de68c Mon Sep 17 00:00:00 2001 From: Matteo Delfino Date: Sat, 6 Jul 2013 21:52:26 -0700 Subject: [PATCH 0623/1048] Input: elantech - fix for newer hardware versions (v7) * Fix version recognition in elantech_set_properties The new hardware reports itself as v7 but the packets' structure is unaltered. * Fix packet type recognition in elantech_packet_check_v4 The bitmask used for v6 is too wide, only the last three bits of the third byte in a packet (packet[3] & 0x03) are actually used to distinguish between packet types. Starting from v7, additional information (to be interpreted) is stored in the remaining bits (packets[3] & 0x1c). In addition, the value stored in (packet[0] & 0x0c) is no longer a constant but contains additional information yet to be deciphered. This change should be backwards compatible with v6 hardware. Additional-author: Giovanni Frigione Signed-off-by: Matteo Delfino Signed-off-by: Dmitry Torokhov --- drivers/input/mouse/elantech.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/drivers/input/mouse/elantech.c b/drivers/input/mouse/elantech.c index 1e8e42fb03a4..57b2637e153a 100644 --- a/drivers/input/mouse/elantech.c +++ b/drivers/input/mouse/elantech.c @@ -694,18 +694,18 @@ static int elantech_packet_check_v3(struct psmouse *psmouse) static int elantech_packet_check_v4(struct psmouse *psmouse) { unsigned char *packet = psmouse->packet; + unsigned char packet_type = packet[3] & 0x03; - if ((packet[0] & 0x0c) == 0x04 && - (packet[3] & 0x1f) == 0x11) + switch (packet_type) { + case 0: + return PACKET_V4_STATUS; + + case 1: return PACKET_V4_HEAD; - if ((packet[0] & 0x0c) == 0x04 && - (packet[3] & 0x1f) == 0x12) + case 2: return PACKET_V4_MOTION; - - if ((packet[0] & 0x0c) == 0x04 && - (packet[3] & 0x1f) == 0x10) - return PACKET_V4_STATUS; + } return PACKET_UNKNOWN; } @@ -1282,6 +1282,7 @@ static int elantech_set_properties(struct elantech_data *etd) etd->hw_version = 3; break; case 6: + case 7: etd->hw_version = 4; break; default: From 46146e7d4b383d5b34014d072553498c7cd52821 Mon Sep 17 00:00:00 2001 From: Daniel Tang Date: Sat, 6 Jul 2013 21:53:26 -0700 Subject: [PATCH 0624/1048] Input: nspire-keypad - replace magic offset with define Signed-off-by: Daniel Tang Signed-off-by: Dmitry Torokhov --- drivers/input/keyboard/nspire-keypad.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/input/keyboard/nspire-keypad.c b/drivers/input/keyboard/nspire-keypad.c index e0a1339e40e6..20d872d6f603 100644 --- a/drivers/input/keyboard/nspire-keypad.c +++ b/drivers/input/keyboard/nspire-keypad.c @@ -122,7 +122,7 @@ static int nspire_keypad_chip_init(struct nspire_keypad *keypad) /* Enable interrupts */ keypad->int_mask = 1 << 1; - writel(keypad->int_mask, keypad->reg_base + 0xc); + writel(keypad->int_mask, keypad->reg_base + KEYPAD_INTMSK); /* Disable GPIO interrupts to prevent hanging on touchpad */ /* Possibly used to detect touchpad events */ From 0fa8103be4c20f893486c533e4c6dfbc5ccddeb4 Mon Sep 17 00:00:00 2001 From: Wanpeng Li Date: Thu, 4 Jul 2013 08:33:22 +0800 Subject: [PATCH 0625/1048] mm/slab: Fix drain freelist excessively The drain_freelist is called to drain slabs_free lists for cache reap, cache shrink, memory hotplug callback etc. The tofree parameter should be the number of slab to free instead of the number of slab objects to free. This patch fix the callers that pass # of objects. Make sure they pass # of slabs. Acked-by: Christoph Lameter Signed-off-by: Wanpeng Li Signed-off-by: Pekka Enberg --- mm/slab.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/mm/slab.c b/mm/slab.c index 273a5ac2ade3..c9b4da9a1fe5 100644 --- a/mm/slab.c +++ b/mm/slab.c @@ -1180,6 +1180,12 @@ static int init_cache_node_node(int node) return 0; } +static inline int slabs_tofree(struct kmem_cache *cachep, + struct kmem_cache_node *n) +{ + return (n->free_objects + cachep->num - 1) / cachep->num; +} + static void __cpuinit cpuup_canceled(long cpu) { struct kmem_cache *cachep; @@ -1241,7 +1247,7 @@ free_array_cache: n = cachep->node[node]; if (!n) continue; - drain_freelist(cachep, n, n->free_objects); + drain_freelist(cachep, n, slabs_tofree(cachep, n)); } } @@ -1408,7 +1414,7 @@ static int __meminit drain_cache_node_node(int node) if (!n) continue; - drain_freelist(cachep, n, n->free_objects); + drain_freelist(cachep, n, slabs_tofree(cachep, n)); if (!list_empty(&n->slabs_full) || !list_empty(&n->slabs_partial)) { @@ -2534,7 +2540,7 @@ static int __cache_shrink(struct kmem_cache *cachep) if (!n) continue; - drain_freelist(cachep, n, n->free_objects); + drain_freelist(cachep, n, slabs_tofree(cachep, n)); ret += !list_empty(&n->slabs_full) || !list_empty(&n->slabs_partial); From e25839f67948ca54fa55a45686d72c266f65f099 Mon Sep 17 00:00:00 2001 From: Wanpeng Li Date: Thu, 4 Jul 2013 08:33:23 +0800 Subject: [PATCH 0626/1048] mm/slab: Sharing s_next and s_stop between slab and slub This patch shares s_next and s_stop between slab and slub. Acked-by: Christoph Lameter Signed-off-by: Wanpeng Li Signed-off-by: Pekka Enberg --- mm/slab.c | 10 ---------- mm/slab.h | 3 +++ mm/slab_common.c | 4 ++-- 3 files changed, 5 insertions(+), 12 deletions(-) diff --git a/mm/slab.c b/mm/slab.c index c9b4da9a1fe5..4a907a072669 100644 --- a/mm/slab.c +++ b/mm/slab.c @@ -4438,16 +4438,6 @@ static int leaks_show(struct seq_file *m, void *p) return 0; } -static void *s_next(struct seq_file *m, void *p, loff_t *pos) -{ - return seq_list_next(p, &slab_caches, pos); -} - -static void s_stop(struct seq_file *m, void *p) -{ - mutex_unlock(&slab_mutex); -} - static const struct seq_operations slabstats_op = { .start = leaks_start, .next = s_next, diff --git a/mm/slab.h b/mm/slab.h index f96b49e4704e..95c88604aab7 100644 --- a/mm/slab.h +++ b/mm/slab.h @@ -271,3 +271,6 @@ struct kmem_cache_node { #endif }; + +void *s_next(struct seq_file *m, void *p, loff_t *pos); +void s_stop(struct seq_file *m, void *p); diff --git a/mm/slab_common.c b/mm/slab_common.c index d2517b05d5bc..68518eb67229 100644 --- a/mm/slab_common.c +++ b/mm/slab_common.c @@ -529,12 +529,12 @@ static void *s_start(struct seq_file *m, loff_t *pos) return seq_list_start(&slab_caches, *pos); } -static void *s_next(struct seq_file *m, void *p, loff_t *pos) +void *s_next(struct seq_file *m, void *p, loff_t *pos) { return seq_list_next(p, &slab_caches, pos); } -static void s_stop(struct seq_file *m, void *p) +void s_stop(struct seq_file *m, void *p) { mutex_unlock(&slab_mutex); } From e9b4db2b8dba6b6c666e54b20ce46f3e597a6d96 Mon Sep 17 00:00:00 2001 From: Wanpeng Li Date: Thu, 4 Jul 2013 08:33:24 +0800 Subject: [PATCH 0627/1048] mm/slab: Fix /proc/slabinfo unwriteable for slab Slab have some tunables like limit, batchcount, and sharedfactor can be tuned through function slabinfo_write. Commit (b7454ad3: mm/sl[au]b: Move slabinfo processing to slab_common.c) uncorrectly change /proc/slabinfo unwriteable for slab, this patch fix it by revert to original mode. Acked-by: Christoph Lameter Signed-off-by: Wanpeng Li Signed-off-by: Pekka Enberg --- mm/slab_common.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/mm/slab_common.c b/mm/slab_common.c index 68518eb67229..13ae037c71d4 100644 --- a/mm/slab_common.c +++ b/mm/slab_common.c @@ -495,6 +495,13 @@ void __init create_kmalloc_caches(unsigned long flags) #ifdef CONFIG_SLABINFO + +#ifdef CONFIG_SLAB +#define SLABINFO_RIGHTS (S_IWUSR | S_IRUSR) +#else +#define SLABINFO_RIGHTS S_IRUSR +#endif + void print_slabinfo_header(struct seq_file *m) { /* @@ -631,7 +638,8 @@ static const struct file_operations proc_slabinfo_operations = { static int __init slab_proc_init(void) { - proc_create("slabinfo", S_IRUSR, NULL, &proc_slabinfo_operations); + proc_create("slabinfo", SLABINFO_RIGHTS, NULL, + &proc_slabinfo_operations); return 0; } module_init(slab_proc_init); From a446336454cf9ce3234a6013d1c3b482358d9459 Mon Sep 17 00:00:00 2001 From: Wanpeng Li Date: Thu, 4 Jul 2013 08:33:25 +0800 Subject: [PATCH 0628/1048] mm/slub: Drop unnecessary nr_partials This patch remove unused nr_partials variable. Acked-by: Christoph Lameter Signed-off-by: Wanpeng Li Signed-off-by: Pekka Enberg --- mm/slub.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/mm/slub.c b/mm/slub.c index 4df2c0c337fb..f788be3a0b12 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -5266,7 +5266,6 @@ __initcall(slab_sysfs_init); #ifdef CONFIG_SLABINFO void get_slabinfo(struct kmem_cache *s, struct slabinfo *sinfo) { - unsigned long nr_partials = 0; unsigned long nr_slabs = 0; unsigned long nr_objs = 0; unsigned long nr_free = 0; @@ -5278,7 +5277,6 @@ void get_slabinfo(struct kmem_cache *s, struct slabinfo *sinfo) if (!n) continue; - nr_partials += n->nr_partial; nr_slabs += atomic_long_read(&n->nr_slabs); nr_objs += atomic_long_read(&n->total_objects); nr_free += count_partial(n, count_free); From c17fd13ec0677e61f3692ecb9d4b21f79848fa04 Mon Sep 17 00:00:00 2001 From: Wanpeng Li Date: Thu, 4 Jul 2013 08:33:26 +0800 Subject: [PATCH 0629/1048] mm/slub: Use node_nr_slabs and node_nr_objs in get_slabinfo Use existing interface node_nr_slabs and node_nr_objs to get nr_slabs and nr_objs. Acked-by: Christoph Lameter Signed-off-by: Wanpeng Li Signed-off-by: Pekka Enberg --- mm/slub.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/slub.c b/mm/slub.c index f788be3a0b12..5ee6c7cd9fc4 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -5277,8 +5277,8 @@ void get_slabinfo(struct kmem_cache *s, struct slabinfo *sinfo) if (!n) continue; - nr_slabs += atomic_long_read(&n->nr_slabs); - nr_objs += atomic_long_read(&n->total_objects); + nr_slabs += node_nr_slabs(n); + nr_objs += node_nr_objs(n); nr_free += count_partial(n, count_free); } From 318df36e57c0ca9f2146660d41ff28e8650af423 Mon Sep 17 00:00:00 2001 From: Joonsoo Kim Date: Wed, 19 Jun 2013 15:33:55 +0900 Subject: [PATCH 0630/1048] slub: do not put a slab to cpu partial list when cpu_partial is 0 In free path, we don't check number of cpu_partial, so one slab can be linked in cpu partial list even if cpu_partial is 0. To prevent this, we should check number of cpu_partial in put_cpu_partial(). Acked-by: Christoph Lameeter Reviewed-by: Wanpeng Li Signed-off-by: Joonsoo Kim Signed-off-by: Pekka Enberg --- mm/slub.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mm/slub.c b/mm/slub.c index 5ee6c7cd9fc4..54cc4d544f3c 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -1954,6 +1954,9 @@ static void put_cpu_partial(struct kmem_cache *s, struct page *page, int drain) int pages; int pobjects; + if (!s->cpu_partial) + return; + do { pages = 0; pobjects = 0; From a6d78159f8a717263bea71bef738256dafe6260d Mon Sep 17 00:00:00 2001 From: Sasha Levin Date: Thu, 20 Dec 2012 14:11:39 -0500 Subject: [PATCH 0631/1048] slob: use DIV_ROUND_UP where possible Acked-by: Christoph Lameter Signed-off-by: Sasha Levin Signed-off-by: Pekka Enberg --- mm/slob.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/slob.c b/mm/slob.c index a99fdf7a0907..f729c46639fa 100644 --- a/mm/slob.c +++ b/mm/slob.c @@ -122,7 +122,7 @@ static inline void clear_slob_page_free(struct page *sp) } #define SLOB_UNIT sizeof(slob_t) -#define SLOB_UNITS(size) (((size) + SLOB_UNIT - 1)/SLOB_UNIT) +#define SLOB_UNITS(size) DIV_ROUND_UP(size, SLOB_UNIT) /* * struct slob_rcu is inserted at the tail of allocated slob blocks, which From 0f8f8094d28eb53368ac09186ea6b3a324cc7d44 Mon Sep 17 00:00:00 2001 From: Christoph Lameter Date: Tue, 2 Jul 2013 12:12:10 -0700 Subject: [PATCH 0632/1048] slab: fix init_lock_keys Some architectures (e.g. powerpc built with CONFIG_PPC_256K_PAGES=y CONFIG_FORCE_MAX_ZONEORDER=11) get PAGE_SHIFT + MAX_ORDER > 26. In 3.10 kernels, CONFIG_LOCKDEP=y with PAGE_SHIFT + MAX_ORDER > 26 makes init_lock_keys() dereference beyond kmalloc_caches[26]. This leads to an unbootable system (kernel panic at initializing SLAB) if one of kmalloc_caches[26...PAGE_SHIFT+MAX_ORDER-1] is not NULL. Fix this by making sure that init_lock_keys() does not dereference beyond kmalloc_caches[26] arrays. Signed-off-by: Christoph Lameter Reported-by: Tetsuo Handa Cc: Pekka Enberg Cc: [3.10.x] Signed-off-by: Andrew Morton Signed-off-by: Pekka Enberg --- mm/slab.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/slab.c b/mm/slab.c index 4a907a072669..9bf225162fcb 100644 --- a/mm/slab.c +++ b/mm/slab.c @@ -565,7 +565,7 @@ static void init_node_lock_keys(int q) if (slab_state < UP) return; - for (i = 1; i < PAGE_SHIFT + MAX_ORDER; i++) { + for (i = 1; i <= KMALLOC_SHIFT_HIGH; i++) { struct kmem_cache_node *n; struct kmem_cache *cache = kmalloc_caches[i]; From e7efa615ccf78394338144ff0187be331240748a Mon Sep 17 00:00:00 2001 From: Michael Opdenacker Date: Tue, 25 Jun 2013 18:16:55 +0200 Subject: [PATCH 0633/1048] slab: add kmalloc() to kernel API documentation At the moment, kmalloc() isn't even listed in the kernel API documentation (DocBook/kernel-api.html after running "make htmldocs"). Another issue is that the documentation for kmalloc_node() refers to kcalloc()'s documentation to describe its 'flags' parameter, while kcalloc() refered to kmalloc()'s documentation, which doesn't exist! This patch is a proposed fix for this. It also removes the documentation for kmalloc() in include/linux/slob_def.h which isn't included to generate the documentation anyway. This way, kmalloc() is described in only one place. Acked-by: Christoph Lameter Acked-by: Randy Dunlap Signed-off-by: Michael Opdenacker Signed-off-by: Pekka Enberg --- include/linux/slab.h | 18 ++++++++++++++---- include/linux/slob_def.h | 8 -------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/include/linux/slab.h b/include/linux/slab.h index 9690c14eb7fb..6c5cc0ea8713 100644 --- a/include/linux/slab.h +++ b/include/linux/slab.h @@ -373,9 +373,8 @@ int cache_show(struct kmem_cache *s, struct seq_file *m); void print_slabinfo_header(struct seq_file *m); /** - * kmalloc_array - allocate memory for an array. - * @n: number of elements. - * @size: element size. + * kmalloc - allocate memory + * @size: how many bytes of memory are required. * @flags: the type of memory to allocate. * * The @flags argument may be one of: @@ -422,6 +421,17 @@ void print_slabinfo_header(struct seq_file *m); * There are other flags available as well, but these are not intended * for general use, and so are not documented here. For a full list of * potential flags, always refer to linux/gfp.h. + * + * kmalloc is the normal method of allocating memory + * in the kernel. + */ +static __always_inline void *kmalloc(size_t size, gfp_t flags); + +/** + * kmalloc_array - allocate memory for an array. + * @n: number of elements. + * @size: element size. + * @flags: the type of memory to allocate (see kmalloc). */ static inline void *kmalloc_array(size_t n, size_t size, gfp_t flags) { @@ -445,7 +455,7 @@ static inline void *kcalloc(size_t n, size_t size, gfp_t flags) /** * kmalloc_node - allocate memory from a specific node * @size: how many bytes of memory are required. - * @flags: the type of memory to allocate (see kcalloc). + * @flags: the type of memory to allocate (see kmalloc). * @node: node to allocate from. * * kmalloc() for non-local nodes, used to allocate from a specific node diff --git a/include/linux/slob_def.h b/include/linux/slob_def.h index f28e14a12e3f..095a5a4a8516 100644 --- a/include/linux/slob_def.h +++ b/include/linux/slob_def.h @@ -18,14 +18,6 @@ static __always_inline void *kmalloc_node(size_t size, gfp_t flags, int node) return __kmalloc_node(size, flags, node); } -/** - * kmalloc - allocate memory - * @size: how many bytes of memory are required. - * @flags: the type of memory to allocate (see kcalloc). - * - * kmalloc is the normal method of allocating memory - * in the kernel. - */ static __always_inline void *kmalloc(size_t size, gfp_t flags) { return __kmalloc_node(size, flags, NUMA_NO_NODE); From 345c905d13a4ec9f774b6b4bc038fe4aef26cced Mon Sep 17 00:00:00 2001 From: Joonsoo Kim Date: Wed, 19 Jun 2013 14:05:52 +0900 Subject: [PATCH 0634/1048] slub: Make cpu partial slab support configurable CPU partial support can introduce level of indeterminism that is not wanted in certain context (like a realtime kernel). Make it configurable. This patch is based on Christoph Lameter's "slub: Make cpu partial slab support configurable V2". Acked-by: Christoph Lameter Signed-off-by: Joonsoo Kim Signed-off-by: Pekka Enberg --- init/Kconfig | 11 +++++++++++ mm/slub.c | 27 +++++++++++++++++++++------ 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/init/Kconfig b/init/Kconfig index 7d30240e5bfe..3b34a88cf34e 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -1511,6 +1511,17 @@ config SLOB endchoice +config SLUB_CPU_PARTIAL + default y + depends on SLUB + bool "SLUB per cpu partial cache" + help + Per cpu partial caches accellerate objects allocation and freeing + that is local to a processor at the price of more indeterminism + in the latency of the free. On overflow these caches will be cleared + which requires the taking of locks that may cause latency spikes. + Typically one would choose no for a realtime system. + config MMAP_ALLOW_UNINITIALIZED bool "Allow mmapped anonymous memory to be uninitialized" depends on EXPERT && !MMU diff --git a/mm/slub.c b/mm/slub.c index 54cc4d544f3c..ef60536c5d69 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -122,6 +122,15 @@ static inline int kmem_cache_debug(struct kmem_cache *s) #endif } +static inline bool kmem_cache_has_cpu_partial(struct kmem_cache *s) +{ +#ifdef CONFIG_SLUB_CPU_PARTIAL + return !kmem_cache_debug(s); +#else + return false; +#endif +} + /* * Issues still to be resolved: * @@ -1572,7 +1581,8 @@ static void *get_partial_node(struct kmem_cache *s, struct kmem_cache_node *n, put_cpu_partial(s, page, 0); stat(s, CPU_PARTIAL_NODE); } - if (kmem_cache_debug(s) || available > s->cpu_partial / 2) + if (!kmem_cache_has_cpu_partial(s) + || available > s->cpu_partial / 2) break; } @@ -1883,6 +1893,7 @@ redo: static void unfreeze_partials(struct kmem_cache *s, struct kmem_cache_cpu *c) { +#ifdef CONFIG_SLUB_CPU_PARTIAL struct kmem_cache_node *n = NULL, *n2 = NULL; struct page *page, *discard_page = NULL; @@ -1937,6 +1948,7 @@ static void unfreeze_partials(struct kmem_cache *s, discard_slab(s, page); stat(s, FREE_SLAB); } +#endif } /* @@ -1950,6 +1962,7 @@ static void unfreeze_partials(struct kmem_cache *s, */ static void put_cpu_partial(struct kmem_cache *s, struct page *page, int drain) { +#ifdef CONFIG_SLUB_CPU_PARTIAL struct page *oldpage; int pages; int pobjects; @@ -1989,6 +2002,7 @@ static void put_cpu_partial(struct kmem_cache *s, struct page *page, int drain) page->next = oldpage; } while (this_cpu_cmpxchg(s->cpu_slab->partial, oldpage, page) != oldpage); +#endif } static inline void flush_slab(struct kmem_cache *s, struct kmem_cache_cpu *c) @@ -2497,7 +2511,7 @@ static void __slab_free(struct kmem_cache *s, struct page *page, new.inuse--; if ((!new.inuse || !prior) && !was_frozen) { - if (!kmem_cache_debug(s) && !prior) + if (kmem_cache_has_cpu_partial(s) && !prior) /* * Slab was on no list before and will be partially empty @@ -2552,8 +2566,9 @@ static void __slab_free(struct kmem_cache *s, struct page *page, * Objects left in the slab. If it was not on the partial list before * then add it. */ - if (kmem_cache_debug(s) && unlikely(!prior)) { - remove_full(s, page); + if (!kmem_cache_has_cpu_partial(s) && unlikely(!prior)) { + if (kmem_cache_debug(s)) + remove_full(s, page); add_partial(n, page, DEACTIVATE_TO_TAIL); stat(s, FREE_ADD_PARTIAL); } @@ -3061,7 +3076,7 @@ static int kmem_cache_open(struct kmem_cache *s, unsigned long flags) * per node list when we run out of per cpu objects. We only fetch 50% * to keep some capacity around for frees. */ - if (kmem_cache_debug(s)) + if (!kmem_cache_has_cpu_partial(s)) s->cpu_partial = 0; else if (s->size >= PAGE_SIZE) s->cpu_partial = 2; @@ -4456,7 +4471,7 @@ static ssize_t cpu_partial_store(struct kmem_cache *s, const char *buf, err = strict_strtoul(buf, 10, &objects); if (err) return err; - if (objects && kmem_cache_debug(s)) + if (objects && !kmem_cache_has_cpu_partial(s)) return -EINVAL; s->cpu_partial = objects; From c1e854e924f354657ea2ad08fd7b38aac81c59b1 Mon Sep 17 00:00:00 2001 From: Steven Rostedt Date: Thu, 17 Jan 2013 12:13:46 -0500 Subject: [PATCH 0635/1048] slob: Check for NULL pointer before calling ctor() While doing some code inspection, I noticed that the slob constructor method can be called with a NULL pointer. If memory is tight and slob fails to allocate with slob_alloc() or slob_new_pages() it still calls the ctor() method with a NULL pointer. Looking at the first ctor() method I found, I noticed that it can not handle a NULL pointer (I'm sure others probably can't either): static void sighand_ctor(void *data) { struct sighand_struct *sighand = data; spin_lock_init(&sighand->siglock); init_waitqueue_head(&sighand->signalfd_wqh); } The solution is to only call the ctor() method if allocation succeeded. Acked-by: Christoph Lameter Signed-off-by: Steven Rostedt Signed-off-by: Pekka Enberg --- mm/slob.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/slob.c b/mm/slob.c index f729c46639fa..3d73b3b8fb1d 100644 --- a/mm/slob.c +++ b/mm/slob.c @@ -554,7 +554,7 @@ void *kmem_cache_alloc_node(struct kmem_cache *c, gfp_t flags, int node) flags, node); } - if (c->ctor) + if (b && c->ctor) c->ctor(b); kmemleak_alloc_recursive(b, c->size, 1, c->flags, flags); From 0134f16bc91cc15a38c867b81568b791c9b626aa Mon Sep 17 00:00:00 2001 From: Jack Morgenstein Date: Sun, 7 Jul 2013 17:25:52 +0300 Subject: [PATCH 0636/1048] IB/core: Add reserved values to enums for low-level driver use Continue the approach taken by commit d2b57063e4a ("IB/core: Reserve bits in enum ib_qp_create_flags for low-level driver use") and add reserved entries to the ib_qp_type and ib_wr_opcode enums. Low-level drivers can then define macros to use these reserved values, giving proper names to the macros for readability. Also add a range of reserved flags to enum ib_send_flags. The mlx5 IB driver uses the new additions. Signed-off-by: Jack Morgenstein Signed-off-by: Roland Dreier --- include/rdma/ib_verbs.h | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h index 98cc4b29fc5b..645c3cedce9c 100644 --- a/include/rdma/ib_verbs.h +++ b/include/rdma/ib_verbs.h @@ -610,7 +610,21 @@ enum ib_qp_type { IB_QPT_RAW_PACKET = 8, IB_QPT_XRC_INI = 9, IB_QPT_XRC_TGT, - IB_QPT_MAX + IB_QPT_MAX, + /* Reserve a range for qp types internal to the low level driver. + * These qp types will not be visible at the IB core layer, so the + * IB_QPT_MAX usages should not be affected in the core layer + */ + IB_QPT_RESERVED1 = 0x1000, + IB_QPT_RESERVED2, + IB_QPT_RESERVED3, + IB_QPT_RESERVED4, + IB_QPT_RESERVED5, + IB_QPT_RESERVED6, + IB_QPT_RESERVED7, + IB_QPT_RESERVED8, + IB_QPT_RESERVED9, + IB_QPT_RESERVED10, }; enum ib_qp_create_flags { @@ -766,6 +780,19 @@ enum ib_wr_opcode { IB_WR_MASKED_ATOMIC_CMP_AND_SWP, IB_WR_MASKED_ATOMIC_FETCH_AND_ADD, IB_WR_BIND_MW, + /* reserve values for low level drivers' internal use. + * These values will not be used at all in the ib core layer. + */ + IB_WR_RESERVED1 = 0xf0, + IB_WR_RESERVED2, + IB_WR_RESERVED3, + IB_WR_RESERVED4, + IB_WR_RESERVED5, + IB_WR_RESERVED6, + IB_WR_RESERVED7, + IB_WR_RESERVED8, + IB_WR_RESERVED9, + IB_WR_RESERVED10, }; enum ib_send_flags { @@ -773,7 +800,11 @@ enum ib_send_flags { IB_SEND_SIGNALED = (1<<1), IB_SEND_SOLICITED = (1<<2), IB_SEND_INLINE = (1<<3), - IB_SEND_IP_CSUM = (1<<4) + IB_SEND_IP_CSUM = (1<<4), + + /* reserve bits 26-31 for low level drivers' internal use */ + IB_SEND_RESERVED_START = (1 << 26), + IB_SEND_RESERVED_END = (1 << 31), }; struct ib_sge { From 6f94d5de090947eb41efe9d3841d75ad91fd6dc7 Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Tue, 4 Jun 2013 12:05:07 -0700 Subject: [PATCH 0637/1048] [SCSI] storvsc: Implement multi-channel support Signed-off-by: K. Y. Srinivasan Reviewed-by: Haiyang Zhang Signed-off-by: James Bottomley --- drivers/scsi/storvsc_drv.c | 131 +++++++++++++++++++++++++++++++++++-- 1 file changed, 127 insertions(+), 4 deletions(-) diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c index 945198910460..1d4d42506ef8 100644 --- a/drivers/scsi/storvsc_drv.c +++ b/drivers/scsi/storvsc_drv.c @@ -328,6 +328,8 @@ static int storvsc_timeout = 180; #define STORVSC_MAX_IO_REQUESTS 128 +static void storvsc_on_channel_callback(void *context); + /* * In Hyper-V, each port/path/target maps to 1 scsi host adapter. In * reality, the path/target is not used (ie always set to 0) so our @@ -364,6 +366,7 @@ struct storvsc_device { bool destroy; bool drain_notify; + bool open_sub_channel; atomic_t num_outstanding_req; struct Scsi_Host *host; @@ -755,12 +758,104 @@ static unsigned int copy_to_bounce_buffer(struct scatterlist *orig_sgl, return total_copied; } +static void handle_sc_creation(struct vmbus_channel *new_sc) +{ + struct hv_device *device = new_sc->primary_channel->device_obj; + struct storvsc_device *stor_device; + struct vmstorage_channel_properties props; + + stor_device = get_out_stor_device(device); + if (!stor_device) + return; + + if (stor_device->open_sub_channel == false) + return; + + memset(&props, 0, sizeof(struct vmstorage_channel_properties)); + + vmbus_open(new_sc, + storvsc_ringbuffer_size, + storvsc_ringbuffer_size, + (void *)&props, + sizeof(struct vmstorage_channel_properties), + storvsc_on_channel_callback, new_sc); +} + +static void handle_multichannel_storage(struct hv_device *device, int max_chns) +{ + struct storvsc_device *stor_device; + int num_cpus = num_online_cpus(); + int num_sc; + struct storvsc_cmd_request *request; + struct vstor_packet *vstor_packet; + int ret, t; + + num_sc = ((max_chns > num_cpus) ? num_cpus : max_chns); + stor_device = get_out_stor_device(device); + if (!stor_device) + return; + + request = &stor_device->init_request; + vstor_packet = &request->vstor_packet; + + stor_device->open_sub_channel = true; + /* + * Establish a handler for dealing with subchannels. + */ + vmbus_set_sc_create_callback(device->channel, handle_sc_creation); + + /* + * Check to see if sub-channels have already been created. This + * can happen when this driver is re-loaded after unloading. + */ + + if (vmbus_are_subchannels_present(device->channel)) + return; + + stor_device->open_sub_channel = false; + /* + * Request the host to create sub-channels. + */ + memset(request, 0, sizeof(struct storvsc_cmd_request)); + init_completion(&request->wait_event); + vstor_packet->operation = VSTOR_OPERATION_CREATE_SUB_CHANNELS; + vstor_packet->flags = REQUEST_COMPLETION_FLAG; + vstor_packet->sub_channel_count = num_sc; + + ret = vmbus_sendpacket(device->channel, vstor_packet, + (sizeof(struct vstor_packet) - + vmscsi_size_delta), + (unsigned long)request, + VM_PKT_DATA_INBAND, + VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED); + + if (ret != 0) + return; + + t = wait_for_completion_timeout(&request->wait_event, 10*HZ); + if (t == 0) + return; + + if (vstor_packet->operation != VSTOR_OPERATION_COMPLETE_IO || + vstor_packet->status != 0) + return; + + /* + * Now that we created the sub-channels, invoke the check; this + * may trigger the callback. + */ + stor_device->open_sub_channel = true; + vmbus_are_subchannels_present(device->channel); +} + static int storvsc_channel_init(struct hv_device *device) { struct storvsc_device *stor_device; struct storvsc_cmd_request *request; struct vstor_packet *vstor_packet; int ret, t; + int max_chns; + bool process_sub_channels = false; stor_device = get_out_stor_device(device); if (!stor_device) @@ -855,6 +950,19 @@ static int storvsc_channel_init(struct hv_device *device) vstor_packet->status != 0) goto cleanup; + /* + * Check to see if multi-channel support is there. + * Hosts that implement protocol version of 5.1 and above + * support multi-channel. + */ + max_chns = vstor_packet->storage_channel_properties.max_channel_cnt; + if ((vmbus_proto_version != VERSION_WIN7) && + (vmbus_proto_version != VERSION_WS2008)) { + if (vstor_packet->storage_channel_properties.flags & + STORAGE_CHANNEL_SUPPORTS_MULTI_CHANNEL) + process_sub_channels = true; + } + memset(vstor_packet, 0, sizeof(struct vstor_packet)); vstor_packet->operation = VSTOR_OPERATION_END_INITIALIZATION; vstor_packet->flags = REQUEST_COMPLETION_FLAG; @@ -879,6 +987,9 @@ static int storvsc_channel_init(struct hv_device *device) vstor_packet->status != 0) goto cleanup; + if (process_sub_channels) + handle_multichannel_storage(device, max_chns); + cleanup: return ret; @@ -1100,7 +1211,8 @@ static void storvsc_on_receive(struct hv_device *device, static void storvsc_on_channel_callback(void *context) { - struct hv_device *device = (struct hv_device *)context; + struct vmbus_channel *channel = (struct vmbus_channel *)context; + struct hv_device *device; struct storvsc_device *stor_device; u32 bytes_recvd; u64 request_id; @@ -1108,13 +1220,17 @@ static void storvsc_on_channel_callback(void *context) struct storvsc_cmd_request *request; int ret; + if (channel->primary_channel != NULL) + device = channel->primary_channel->device_obj; + else + device = channel->device_obj; stor_device = get_in_stor_device(device); if (!stor_device) return; do { - ret = vmbus_recvpacket(device->channel, packet, + ret = vmbus_recvpacket(channel, packet, ALIGN((sizeof(struct vstor_packet) - vmscsi_size_delta), 8), &bytes_recvd, &request_id); @@ -1155,7 +1271,7 @@ static int storvsc_connect_to_vsp(struct hv_device *device, u32 ring_size) ring_size, (void *)&props, sizeof(struct vmstorage_channel_properties), - storvsc_on_channel_callback, device); + storvsc_on_channel_callback, device->channel); if (ret != 0) return ret; @@ -1207,6 +1323,7 @@ static int storvsc_do_io(struct hv_device *device, { struct storvsc_device *stor_device; struct vstor_packet *vstor_packet; + struct vmbus_channel *outgoing_channel; int ret = 0; vstor_packet = &request->vstor_packet; @@ -1217,6 +1334,11 @@ static int storvsc_do_io(struct hv_device *device, request->device = device; + /* + * Select an an appropriate channel to send the request out. + */ + + outgoing_channel = vmbus_get_outgoing_channel(device->channel); vstor_packet->flags |= REQUEST_COMPLETION_FLAG; @@ -1234,7 +1356,7 @@ static int storvsc_do_io(struct hv_device *device, vstor_packet->operation = VSTOR_OPERATION_EXECUTE_SRB; if (request->data_buffer.len) { - ret = vmbus_sendpacket_multipagebuffer(device->channel, + ret = vmbus_sendpacket_multipagebuffer(outgoing_channel, &request->data_buffer, vstor_packet, (sizeof(struct vstor_packet) - @@ -1643,6 +1765,7 @@ static int storvsc_probe(struct hv_device *device, } stor_device->destroy = false; + stor_device->open_sub_channel = false; init_waitqueue_head(&stor_device->waiting_to_drain); stor_device->device = device; stor_device->host = host; From bde6d0f9877e19fc9d309bbd624da422b18cdc3d Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Tue, 4 Jun 2013 12:05:08 -0700 Subject: [PATCH 0638/1048] [SCSI] storvsc: Support FC devices Signed-off-by: K. Y. Srinivasan Reviewed-by: Haiyang Zhang Signed-off-by: James Bottomley --- drivers/scsi/storvsc_drv.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c index 1d4d42506ef8..b864e7c3da4b 100644 --- a/drivers/scsi/storvsc_drv.c +++ b/drivers/scsi/storvsc_drv.c @@ -1702,6 +1702,7 @@ static struct scsi_host_template scsi_driver = { enum { SCSI_GUID, IDE_GUID, + SFC_GUID, }; static const struct hv_vmbus_device_id id_table[] = { @@ -1713,6 +1714,11 @@ static const struct hv_vmbus_device_id id_table[] = { { HV_IDE_GUID, .driver_data = IDE_GUID }, + /* Fibre Channel GUID */ + { + HV_SYNTHFC_GUID, + .driver_data = SFC_GUID + }, { }, }; From 276a2439ce7917b8c3043af7ad6bf17bbcc24030 Mon Sep 17 00:00:00 2001 From: Wanpeng Li Date: Mon, 8 Jul 2013 08:08:28 +0800 Subject: [PATCH 0639/1048] mm/slab: Give s_next and s_stop slab-specific names Give s_next and s_stop slab-specific names instead of exporting "s_next" and "s_stop". Signed-off-by: Wanpeng Li Signed-off-by: Pekka Enberg --- mm/slab.c | 4 ++-- mm/slab.h | 4 ++-- mm/slab_common.c | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/mm/slab.c b/mm/slab.c index 9bf225162fcb..57ab42297d96 100644 --- a/mm/slab.c +++ b/mm/slab.c @@ -4440,8 +4440,8 @@ static int leaks_show(struct seq_file *m, void *p) static const struct seq_operations slabstats_op = { .start = leaks_start, - .next = s_next, - .stop = s_stop, + .next = slab_next, + .stop = slab_stop, .show = leaks_show, }; diff --git a/mm/slab.h b/mm/slab.h index 95c88604aab7..620ceeddbe1a 100644 --- a/mm/slab.h +++ b/mm/slab.h @@ -272,5 +272,5 @@ struct kmem_cache_node { }; -void *s_next(struct seq_file *m, void *p, loff_t *pos); -void s_stop(struct seq_file *m, void *p); +void *slab_next(struct seq_file *m, void *p, loff_t *pos); +void slab_stop(struct seq_file *m, void *p); diff --git a/mm/slab_common.c b/mm/slab_common.c index 13ae037c71d4..eacdffaf71c9 100644 --- a/mm/slab_common.c +++ b/mm/slab_common.c @@ -536,12 +536,12 @@ static void *s_start(struct seq_file *m, loff_t *pos) return seq_list_start(&slab_caches, *pos); } -void *s_next(struct seq_file *m, void *p, loff_t *pos) +void *slab_next(struct seq_file *m, void *p, loff_t *pos) { return seq_list_next(p, &slab_caches, pos); } -void s_stop(struct seq_file *m, void *p) +void slab_stop(struct seq_file *m, void *p) { mutex_unlock(&slab_mutex); } @@ -618,8 +618,8 @@ static int s_show(struct seq_file *m, void *p) */ static const struct seq_operations slabinfo_op = { .start = s_start, - .next = s_next, - .stop = s_stop, + .next = slab_next, + .stop = slab_stop, .show = s_show, }; From 1b2c14b44adcb7836528640bfdc40bf7499d987d Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Mon, 8 Jul 2013 10:48:28 -0300 Subject: [PATCH 0640/1048] MAINTAINERS & ABI: Update to point to my new email As mchehab@redhat.com is no longer valid, update it to reflect the new one. Signed-off-by: Mauro Carvalho Chehab --- Documentation/ABI/testing/sysfs-devices-edac | 14 ++++----- MAINTAINERS | 32 ++++++++++---------- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/Documentation/ABI/testing/sysfs-devices-edac b/Documentation/ABI/testing/sysfs-devices-edac index 30ee78aaed75..6568e0010e1a 100644 --- a/Documentation/ABI/testing/sysfs-devices-edac +++ b/Documentation/ABI/testing/sysfs-devices-edac @@ -77,7 +77,7 @@ Description: Read/Write attribute file that controls memory scrubbing. What: /sys/devices/system/edac/mc/mc*/max_location Date: April 2012 -Contact: Mauro Carvalho Chehab +Contact: Mauro Carvalho Chehab linux-edac@vger.kernel.org Description: This attribute file displays the information about the last available memory slot in this memory controller. It is used by @@ -85,7 +85,7 @@ Description: This attribute file displays the information about the last What: /sys/devices/system/edac/mc/mc*/(dimm|rank)*/size Date: April 2012 -Contact: Mauro Carvalho Chehab +Contact: Mauro Carvalho Chehab linux-edac@vger.kernel.org Description: This attribute file will display the size of dimm or rank. For dimm*/size, this is the size, in MB of the DIMM memory @@ -96,14 +96,14 @@ Description: This attribute file will display the size of dimm or rank. What: /sys/devices/system/edac/mc/mc*/(dimm|rank)*/dimm_dev_type Date: April 2012 -Contact: Mauro Carvalho Chehab +Contact: Mauro Carvalho Chehab linux-edac@vger.kernel.org Description: This attribute file will display what type of DRAM device is being utilized on this DIMM (x1, x2, x4, x8, ...). What: /sys/devices/system/edac/mc/mc*/(dimm|rank)*/dimm_edac_mode Date: April 2012 -Contact: Mauro Carvalho Chehab +Contact: Mauro Carvalho Chehab linux-edac@vger.kernel.org Description: This attribute file will display what type of Error detection and correction is being utilized. For example: S4ECD4ED would @@ -111,7 +111,7 @@ Description: This attribute file will display what type of Error detection What: /sys/devices/system/edac/mc/mc*/(dimm|rank)*/dimm_label Date: April 2012 -Contact: Mauro Carvalho Chehab +Contact: Mauro Carvalho Chehab linux-edac@vger.kernel.org Description: This control file allows this DIMM to have a label assigned to it. With this label in the module, when errors occur @@ -126,14 +126,14 @@ Description: This control file allows this DIMM to have a label assigned What: /sys/devices/system/edac/mc/mc*/(dimm|rank)*/dimm_location Date: April 2012 -Contact: Mauro Carvalho Chehab +Contact: Mauro Carvalho Chehab linux-edac@vger.kernel.org Description: This attribute file will display the location (csrow/channel, branch/channel/slot or channel/slot) of the dimm or rank. What: /sys/devices/system/edac/mc/mc*/(dimm|rank)*/dimm_mem_type Date: April 2012 -Contact: Mauro Carvalho Chehab +Contact: Mauro Carvalho Chehab linux-edac@vger.kernel.org Description: This attribute file will display what type of memory is currently on this csrow. Normally, either buffered or diff --git a/MAINTAINERS b/MAINTAINERS index af77eb1d8293..90644d12e9f2 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1557,7 +1557,7 @@ F: include/net/ax25.h F: net/ax25/ AZ6007 DVB DRIVER -M: Mauro Carvalho Chehab +M: Mauro Carvalho Chehab L: linux-media@vger.kernel.org W: http://linuxtv.org T: git git://linuxtv.org/media_tree.git @@ -1841,7 +1841,7 @@ F: Documentation/filesystems/btrfs.txt F: fs/btrfs/ BTTV VIDEO4LINUX DRIVER -M: Mauro Carvalho Chehab +M: Mauro Carvalho Chehab L: linux-media@vger.kernel.org W: http://linuxtv.org T: git git://linuxtv.org/media_tree.git @@ -2312,7 +2312,7 @@ F: drivers/media/common/cx2341x* F: include/media/cx2341x* CX88 VIDEO4LINUX DRIVER -M: Mauro Carvalho Chehab +M: Mauro Carvalho Chehab L: linux-media@vger.kernel.org W: http://linuxtv.org T: git git://linuxtv.org/media_tree.git @@ -2930,7 +2930,7 @@ S: Maintained F: drivers/edac/e7xxx_edac.c EDAC-GHES -M: Mauro Carvalho Chehab +M: Mauro Carvalho Chehab L: linux-edac@vger.kernel.org W: bluesmoke.sourceforge.net S: Maintained @@ -2958,21 +2958,21 @@ S: Maintained F: drivers/edac/i5000_edac.c EDAC-I5400 -M: Mauro Carvalho Chehab +M: Mauro Carvalho Chehab L: linux-edac@vger.kernel.org W: bluesmoke.sourceforge.net S: Maintained F: drivers/edac/i5400_edac.c EDAC-I7300 -M: Mauro Carvalho Chehab +M: Mauro Carvalho Chehab L: linux-edac@vger.kernel.org W: bluesmoke.sourceforge.net S: Maintained F: drivers/edac/i7300_edac.c EDAC-I7CORE -M: Mauro Carvalho Chehab +M: Mauro Carvalho Chehab L: linux-edac@vger.kernel.org W: bluesmoke.sourceforge.net S: Maintained @@ -3001,7 +3001,7 @@ S: Maintained F: drivers/edac/r82600_edac.c EDAC-SBRIDGE -M: Mauro Carvalho Chehab +M: Mauro Carvalho Chehab L: linux-edac@vger.kernel.org W: bluesmoke.sourceforge.net S: Maintained @@ -3061,7 +3061,7 @@ S: Maintained F: drivers/net/ethernet/ibm/ehea/ EM28XX VIDEO4LINUX DRIVER -M: Mauro Carvalho Chehab +M: Mauro Carvalho Chehab L: linux-media@vger.kernel.org W: http://linuxtv.org T: git git://linuxtv.org/media_tree.git @@ -5229,7 +5229,7 @@ S: Maintained F: drivers/media/radio/radio-maxiradio* MEDIA INPUT INFRASTRUCTURE (V4L/DVB) -M: Mauro Carvalho Chehab +M: Mauro Carvalho Chehab P: LinuxTV.org Project L: linux-media@vger.kernel.org W: http://linuxtv.org @@ -6911,7 +6911,7 @@ S: Odd Fixes F: drivers/media/i2c/saa6588* SAA7134 VIDEO4LINUX DRIVER -M: Mauro Carvalho Chehab +M: Mauro Carvalho Chehab L: linux-media@vger.kernel.org W: http://linuxtv.org T: git git://linuxtv.org/media_tree.git @@ -7282,7 +7282,7 @@ S: Odd Fixes F: drivers/media/radio/radio-si4713.h SIANO DVB DRIVER -M: Mauro Carvalho Chehab +M: Mauro Carvalho Chehab L: linux-media@vger.kernel.org W: http://linuxtv.org T: git git://linuxtv.org/media_tree.git @@ -7986,7 +7986,7 @@ S: Maintained F: drivers/media/i2c/tda9840* TEA5761 TUNER DRIVER -M: Mauro Carvalho Chehab +M: Mauro Carvalho Chehab L: linux-media@vger.kernel.org W: http://linuxtv.org T: git git://linuxtv.org/media_tree.git @@ -7994,7 +7994,7 @@ S: Odd fixes F: drivers/media/tuners/tea5761.* TEA5767 TUNER DRIVER -M: Mauro Carvalho Chehab +M: Mauro Carvalho Chehab L: linux-media@vger.kernel.org W: http://linuxtv.org T: git git://linuxtv.org/media_tree.git @@ -8232,7 +8232,7 @@ F: include/linux/shmem_fs.h F: mm/shmem.c TM6000 VIDEO4LINUX DRIVER -M: Mauro Carvalho Chehab +M: Mauro Carvalho Chehab L: linux-media@vger.kernel.org W: http://linuxtv.org T: git git://linuxtv.org/media_tree.git @@ -9087,7 +9087,7 @@ S: Maintained F: arch/x86/kernel/cpu/mcheck/* XC2028/3028 TUNER DRIVER -M: Mauro Carvalho Chehab +M: Mauro Carvalho Chehab L: linux-media@vger.kernel.org W: http://linuxtv.org T: git git://linuxtv.org/media_tree.git From bb6a4df6db9e69e225bfc5a9d95a1675342e1873 Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Tue, 4 Jun 2013 12:05:09 -0700 Subject: [PATCH 0641/1048] [SCSI] storvsc: Increase the value of STORVSC_MAX_IO_REQUESTS Increase the value of STORVSC_MAX_IO_REQUESTS to 200 requests. The current ringbuffer size can support this higher value. Signed-off-by: K. Y. Srinivasan Reviewed-by: Haiyang Zhang Signed-off-by: James Bottomley --- drivers/scsi/storvsc_drv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c index b864e7c3da4b..83ec1aa85964 100644 --- a/drivers/scsi/storvsc_drv.c +++ b/drivers/scsi/storvsc_drv.c @@ -326,7 +326,7 @@ MODULE_PARM_DESC(storvsc_ringbuffer_size, "Ring buffer size (bytes)"); */ static int storvsc_timeout = 180; -#define STORVSC_MAX_IO_REQUESTS 128 +#define STORVSC_MAX_IO_REQUESTS 200 static void storvsc_on_channel_callback(void *context); From b253c9d1d858a3f115f791ee4fe2b9399ae7dbbd Mon Sep 17 00:00:00 2001 From: Matthew Garrett Date: Mon, 8 Jul 2013 11:44:40 -0400 Subject: [PATCH 0642/1048] hp-wmi: Enable hotkeys on some systems Kyle Evans discovered that he needed to set some bits in an EC register in order to receive hotkey events. Doing so blindly broke some otherwise working HP laptops. It turns out that there's a WMI call that accesses the same register, so let's try calling that instead. Signed-off-by: Matthew Garrett Cc: Kyle Evans --- drivers/platform/x86/hp-wmi.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/drivers/platform/x86/hp-wmi.c b/drivers/platform/x86/hp-wmi.c index d111c8687f9b..6e142c3b5e97 100644 --- a/drivers/platform/x86/hp-wmi.c +++ b/drivers/platform/x86/hp-wmi.c @@ -53,6 +53,7 @@ MODULE_ALIAS("wmi:5FB7F034-2C63-45e9-BE91-3D44E2C707E4"); #define HPWMI_ALS_QUERY 0x3 #define HPWMI_HARDWARE_QUERY 0x4 #define HPWMI_WIRELESS_QUERY 0x5 +#define HPWMI_BIOS_QUERY 0x9 #define HPWMI_HOTKEY_QUERY 0xc #define HPWMI_WIRELESS2_QUERY 0x1b @@ -291,6 +292,19 @@ static int hp_wmi_tablet_state(void) return (state & 0x4) ? 1 : 0; } +static int hp_wmi_enable_hotkeys(void) +{ + int ret; + int query = 0x6e; + + ret = hp_wmi_perform_query(HPWMI_BIOS_QUERY, 1, &query, sizeof(query), + 0); + + if (ret) + return -EINVAL; + return 0; +} + static int hp_wmi_set_block(void *data, bool blocked) { enum hp_wmi_radio r = (enum hp_wmi_radio) data; @@ -948,6 +962,8 @@ static int __init hp_wmi_init(void) err = hp_wmi_input_setup(); if (err) return err; + + hp_wmi_enable_hotkeys(); } if (bios_capable) { From 9f2082025902b59193dbdcd63550c1e8bc58e706 Mon Sep 17 00:00:00 2001 From: Wei Yongjun Date: Thu, 9 May 2013 10:03:02 +0800 Subject: [PATCH 0643/1048] dell-laptop: fix error return code in dell_init() Fix to return -ENOMEM in the alloc_page() error handling case instead of 0, as done elsewhere in this function. Signed-off-by: Wei Yongjun Signed-off-by: Matthew Garrett --- drivers/platform/x86/dell-laptop.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/platform/x86/dell-laptop.c b/drivers/platform/x86/dell-laptop.c index 1134119521ac..bb77e18b3dd4 100644 --- a/drivers/platform/x86/dell-laptop.c +++ b/drivers/platform/x86/dell-laptop.c @@ -551,9 +551,10 @@ static int __init dell_init(void) * is passed to SMI handler. */ bufferpage = alloc_page(GFP_KERNEL | GFP_DMA32); - - if (!bufferpage) + if (!bufferpage) { + ret = -ENOMEM; goto fail_buffer; + } buffer = page_address(bufferpage); if (quirks && quirks->touchpad_led) From e1a98e61c21694c9c690c7f253010cd44e89e7fd Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Tue, 14 May 2013 02:44:26 +0100 Subject: [PATCH 0644/1048] amilo-rfkill: Add dependency on SERIO_I8042 I forgot to add this when changing the driver to use the proper i8042 functions. Reported-by: kbuild test robot Signed-off-by: Ben Hutchings Signed-off-by: Matthew Garrett --- drivers/platform/x86/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig index 85772616efbf..37645b923c52 100644 --- a/drivers/platform/x86/Kconfig +++ b/drivers/platform/x86/Kconfig @@ -176,6 +176,7 @@ config FUJITSU_TABLET config AMILO_RFKILL tristate "Fujitsu-Siemens Amilo rfkill support" depends on RFKILL + depends on SERIO_I8042 ---help--- This is a driver for enabling wifi on some Fujitsu-Siemens Amilo laptops. From 754d1243915d0fda6874fa0f1a926d85eb09e0b4 Mon Sep 17 00:00:00 2001 From: Giridhar Malavali Date: Tue, 25 Jun 2013 11:27:16 -0400 Subject: [PATCH 0645/1048] [SCSI] qla2xxx: Clear the MBX_INTR_WAIT flag when the mailbox time-out happens. Signed-off-by: Giridhar Malavali Signed-off-by: Saurav Kashyap Signed-off-by: James Bottomley --- drivers/scsi/qla2xxx/qla_dbg.c | 2 +- drivers/scsi/qla2xxx/qla_mbx.c | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_dbg.c b/drivers/scsi/qla2xxx/qla_dbg.c index cfa2a20dee97..3cc2105dd902 100644 --- a/drivers/scsi/qla2xxx/qla_dbg.c +++ b/drivers/scsi/qla2xxx/qla_dbg.c @@ -12,7 +12,7 @@ * | Level | Last Value Used | Holes | * ---------------------------------------------------------------------- * | Module Init and Probe | 0x014f | 0x4b,0xba,0xfa | - * | Mailbox commands | 0x1179 | 0x111a-0x111b | + * | Mailbox commands | 0x117a | 0x111a-0x111b | * | | | 0x1155-0x1158 | * | Device Discovery | 0x2095 | 0x2020-0x2022, | * | | | 0x2016 | diff --git a/drivers/scsi/qla2xxx/qla_mbx.c b/drivers/scsi/qla2xxx/qla_mbx.c index 3587ec267fa6..144effd45ddf 100644 --- a/drivers/scsi/qla2xxx/qla_mbx.c +++ b/drivers/scsi/qla2xxx/qla_mbx.c @@ -177,8 +177,14 @@ qla2x00_mailbox_command(scsi_qla_host_t *vha, mbx_cmd_t *mcp) WRT_REG_WORD(®->isp.hccr, HCCR_SET_HOST_INT); spin_unlock_irqrestore(&ha->hardware_lock, flags); - wait_for_completion_timeout(&ha->mbx_intr_comp, mcp->tov * HZ); - + if (!wait_for_completion_timeout(&ha->mbx_intr_comp, + mcp->tov * HZ)) { + ql_dbg(ql_dbg_mbx, vha, 0x117a, + "cmd=%x Timeout.\n", command); + spin_lock_irqsave(&ha->hardware_lock, flags); + clear_bit(MBX_INTR_WAIT, &ha->mbx_cmd_flags); + spin_unlock_irqrestore(&ha->hardware_lock, flags); + } } else { ql_dbg(ql_dbg_mbx, vha, 0x1011, "Cmd=%x Polling Mode.\n", command); From 8edf3edd8da076008093a8a04d349bbef02ecd88 Mon Sep 17 00:00:00 2001 From: Giridhar Malavali Date: Tue, 25 Jun 2013 11:27:17 -0400 Subject: [PATCH 0646/1048] [SCSI] qla2xxx: Set the index in outstanding command array to NULL when cmd is aborted when the request timeout. Call the generic BSG free routine to unmap the DMA buffers. Signed-off-by: Giridhar Malavali Signed-off-by: Saurav Kashyap Signed-off-by: James Bottomley --- drivers/scsi/qla2xxx/qla_bsg.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_bsg.c b/drivers/scsi/qla2xxx/qla_bsg.c index 39719f892488..5ba0cc1f982b 100644 --- a/drivers/scsi/qla2xxx/qla_bsg.c +++ b/drivers/scsi/qla2xxx/qla_bsg.c @@ -2153,6 +2153,7 @@ qla24xx_bsg_timeout(struct fc_bsg_job *bsg_job) (sp->type == SRB_ELS_CMD_HST) || (sp->type == SRB_FXIOCB_BCMD)) && (sp->u.bsg_job == bsg_job)) { + req->outstanding_cmds[cnt] = NULL; spin_unlock_irqrestore(&ha->hardware_lock, flags); if (ha->isp_ops->abort_command(sp)) { ql_log(ql_log_warn, vha, 0x7089, @@ -2180,8 +2181,6 @@ qla24xx_bsg_timeout(struct fc_bsg_job *bsg_job) done: spin_unlock_irqrestore(&ha->hardware_lock, flags); - if (bsg_job->request->msgcode == FC_BSG_HST_CT) - kfree(sp->fcport); - qla2x00_rel_sp(vha, sp); + sp->free(vha, sp); return 0; } From 3491255e12c5cd5310d855fe276f7971737a1c10 Mon Sep 17 00:00:00 2001 From: Saurav Kashyap Date: Tue, 25 Jun 2013 11:27:18 -0400 Subject: [PATCH 0647/1048] [SCSI] qla2xxx: Move qla2x00_free_device to the correct location. Signed-off-by: Giridhar Malavali Signed-off-by: Saurav Kashyap Signed-off-by: James Bottomley --- drivers/scsi/qla2xxx/qla_os.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c index ad72c1d85111..c2e2e20d2e21 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c @@ -104,8 +104,6 @@ MODULE_PARM_DESC(ql2xshiftctondsd, "Set to control shifting of command type processing " "based on total number of SG elements."); -static void qla2x00_free_device(scsi_qla_host_t *); - int ql2xfdmienable=1; module_param(ql2xfdmienable, int, S_IRUGO); MODULE_PARM_DESC(ql2xfdmienable, @@ -237,6 +235,7 @@ static int qla2xxx_eh_host_reset(struct scsi_cmnd *); static int qla2x00_change_queue_depth(struct scsi_device *, int, int); static int qla2x00_change_queue_type(struct scsi_device *, int); +static void qla2x00_free_device(scsi_qla_host_t *); struct scsi_host_template qla2xxx_driver_template = { .module = THIS_MODULE, From 8fbfe2d21445253411c1ff0f69e3129fc11ba57c Mon Sep 17 00:00:00 2001 From: Chad Dupuis Date: Tue, 25 Jun 2013 11:27:19 -0400 Subject: [PATCH 0648/1048] [SCSI] qla2xxx: Do not query FC statistics during chip reset. During a chip reset, the mailbox call to get FC statistics from the ISP will not work resulting in needless mailbox accesses and errors printing out: qla2xxx [0000:05:00.0]-00af:11: Performing ISP error recovery - ha=ffff881fad044800. qla2xxx [0000:05:00.0]-1020:11: **** Failed mbx[0]=4001, mb[1]=4953, mb[2]=5020, mb[3]=b100, cmd=6d ****. qla2xxx [0000:05:00.0]-1020:11: **** Failed mbx[0]=4001, mb[1]=4953, mb[2]=5020, mb[3]=b100, cmd=6d ****. qla2xxx [0000:05:00.0]-1020:11: **** Failed mbx[0]=4001, mb[1]=4953, mb[2]=5020, mb[3]=b100, cmd=6d ****. qla2xxx [0000:05:00.0]-1020:11: **** Failed mbx[0]=4001, mb[1]=4953, mb[2]=5020, mb[3]=b100, cmd=6d ****. qla2xxx [0000:05:00.0]-1020:11: **** Failed mbx[0]=4001, mb[1]=4953, mb[2]=5020, mb[3]=b100, cmd=6d ****. To prevent this, check for a chip reset when an application queries for FC stats and return immediately if a chip reset is occurring. Signed-off-by: Chad Dupuis Signed-off-by: Saurav Kashyap Signed-off-by: James Bottomley --- drivers/scsi/qla2xxx/qla_attr.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c index bf60c631abb5..d7a99ae7f39d 100644 --- a/drivers/scsi/qla2xxx/qla_attr.c +++ b/drivers/scsi/qla2xxx/qla_attr.c @@ -1691,6 +1691,9 @@ qla2x00_get_fc_host_stats(struct Scsi_Host *shost) if (unlikely(pci_channel_offline(ha->pdev))) goto done; + if (qla2x00_reset_active(vha)) + goto done; + stats = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &stats_dma); if (stats == NULL) { ql_log(ql_log_warn, vha, 0x707d, @@ -1703,7 +1706,7 @@ qla2x00_get_fc_host_stats(struct Scsi_Host *shost) if (IS_FWI2_CAPABLE(ha)) { rval = qla24xx_get_isp_stats(base_vha, stats, stats_dma); } else if (atomic_read(&base_vha->loop_state) == LOOP_READY && - !qla2x00_reset_active(vha) && !ha->dpc_active) { + !ha->dpc_active) { /* Must be in a 'READY' state for statistics retrieval. */ rval = qla2x00_get_link_status(base_vha, base_vha->loop_id, stats, stats_dma); From b8eb4136b08f24b159d76b273216d524a26ac8f9 Mon Sep 17 00:00:00 2001 From: Chad Dupuis Date: Tue, 25 Jun 2013 11:27:20 -0400 Subject: [PATCH 0649/1048] [SCSI] qla2xxx: Do not take a second firmware dump when intentionally generating one. When we are intentionally generating a firmware dump by executing the MBC_GEN_SYSTEM_ERROR command, the command actually times out. The normal course of action when a mailbox command times out is to take a firmware dump. However, in this special case we do not want to do this since the MBA_SYSTEM_ERR AEN already generates a firmware dump. Signed-off-by: Chad Dupuis Signed-off-by: Saurav Kashyap Signed-off-by: James Bottomley --- drivers/scsi/qla2xxx/qla_mbx.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_mbx.c b/drivers/scsi/qla2xxx/qla_mbx.c index 144effd45ddf..7257c3c4f2d0 100644 --- a/drivers/scsi/qla2xxx/qla_mbx.c +++ b/drivers/scsi/qla2xxx/qla_mbx.c @@ -281,9 +281,11 @@ qla2x00_mailbox_command(scsi_qla_host_t *vha, mbx_cmd_t *mcp) /* * Attempt to capture a firmware dump for further analysis - * of the current firmware state + * of the current firmware state. We do not need to do this + * if we are intentionally generating a dump. */ - ha->isp_ops->fw_dump(vha, 0); + if (mcp->mb[0] != MBC_GEN_SYSTEM_ERROR) + ha->isp_ops->fw_dump(vha, 0); rval = QLA_FUNCTION_TIMEOUT; } From 1f8deefecdda5a43961dd8062a6cab27e20af5e9 Mon Sep 17 00:00:00 2001 From: Saurav Kashyap Date: Tue, 25 Jun 2013 11:27:21 -0400 Subject: [PATCH 0650/1048] [SCSI] qla2xxx: Fix sparse warning from qla_mr.c and qla_iocb.c. Signed-off-by: Giridhar Malavali Signed-off-by: Saurav Kashyap Signed-off-by: James Bottomley --- drivers/scsi/qla2xxx/qla_def.h | 34 +++--- drivers/scsi/qla2xxx/qla_gbl.h | 2 +- drivers/scsi/qla2xxx/qla_inline.h | 2 +- drivers/scsi/qla2xxx/qla_iocb.c | 4 +- drivers/scsi/qla2xxx/qla_mr.c | 167 ++++++++++++++++-------------- drivers/scsi/qla2xxx/qla_mr.h | 98 +++++++++--------- 6 files changed, 157 insertions(+), 150 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h index c32efc753229..95ca32a71e75 100644 --- a/drivers/scsi/qla2xxx/qla_def.h +++ b/drivers/scsi/qla2xxx/qla_def.h @@ -323,7 +323,7 @@ struct srb_iocb { uint32_t lun; uint32_t data; struct completion comp; - uint32_t comp_status; + __le16 comp_status; } tmf; struct { #define SRB_FXDISC_REQ_DMA_VALID BIT_0 @@ -338,21 +338,21 @@ struct srb_iocb { void *rsp_addr; dma_addr_t req_dma_handle; dma_addr_t rsp_dma_handle; - uint32_t adapter_id; - uint32_t adapter_id_hi; - uint32_t req_func_type; - uint32_t req_data; - uint32_t req_data_extra; - uint32_t result; - uint32_t seq_number; - uint32_t fw_flags; + __le32 adapter_id; + __le32 adapter_id_hi; + __le16 req_func_type; + __le32 req_data; + __le32 req_data_extra; + __le32 result; + __le32 seq_number; + __le16 fw_flags; struct completion fxiocb_comp; - uint32_t reserved_0; + __le32 reserved_0; uint8_t reserved_1; } fxiocb; struct { uint32_t cmd_hndl; - uint32_t comp_status; + __le16 comp_status; struct completion comp; } abt; } u; @@ -1196,14 +1196,14 @@ typedef struct { struct init_cb_fx { uint16_t version; uint16_t reserved_1[13]; - uint16_t request_q_outpointer; - uint16_t response_q_inpointer; + __le16 request_q_outpointer; + __le16 response_q_inpointer; uint16_t reserved_2[2]; - uint16_t response_q_length; - uint16_t request_q_length; + __le16 response_q_length; + __le16 request_q_length; uint16_t reserved_3[2]; - uint32_t request_q_address[2]; - uint32_t response_q_address[2]; + __le32 request_q_address[2]; + __le32 response_q_address[2]; uint16_t reserved_4[4]; uint8_t response_q_msivec; uint8_t reserved_5[19]; diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h index 026bfde33e67..2d98232a08eb 100644 --- a/drivers/scsi/qla2xxx/qla_gbl.h +++ b/drivers/scsi/qla2xxx/qla_gbl.h @@ -587,7 +587,7 @@ extern int qlafx00_init_firmware(scsi_qla_host_t *, uint16_t); extern int qlafx00_fw_ready(scsi_qla_host_t *); extern int qlafx00_configure_devices(scsi_qla_host_t *); extern int qlafx00_reset_initialize(scsi_qla_host_t *); -extern int qlafx00_fx_disc(scsi_qla_host_t *, fc_port_t *, uint8_t); +extern int qlafx00_fx_disc(scsi_qla_host_t *, fc_port_t *, uint16_t); extern int qlafx00_process_aen(struct scsi_qla_host *, struct qla_work_evt *); extern int qlafx00_post_aenfx_work(struct scsi_qla_host *, uint32_t, uint32_t *, int); diff --git a/drivers/scsi/qla2xxx/qla_inline.h b/drivers/scsi/qla2xxx/qla_inline.h index 0a5c8951cebb..28c38b4929ce 100644 --- a/drivers/scsi/qla2xxx/qla_inline.h +++ b/drivers/scsi/qla2xxx/qla_inline.h @@ -83,7 +83,7 @@ static inline void host_to_adap(uint8_t *src, uint8_t *dst, uint32_t bsize) { uint32_t *isrc = (uint32_t *) src; - uint32_t *odest = (uint32_t *) dst; + __le32 *odest = (__le32 *) dst; uint32_t iter = bsize >> 2; for (; iter ; iter--) diff --git a/drivers/scsi/qla2xxx/qla_iocb.c b/drivers/scsi/qla2xxx/qla_iocb.c index 15e4080b347c..9de372f00d4a 100644 --- a/drivers/scsi/qla2xxx/qla_iocb.c +++ b/drivers/scsi/qla2xxx/qla_iocb.c @@ -1863,8 +1863,8 @@ skip_cmd_array: pkt = req->ring_ptr; memset(pkt, 0, REQUEST_ENTRY_SIZE); if (IS_QLAFX00(ha)) { - WRT_REG_BYTE(&pkt->entry_count, req_cnt); - WRT_REG_WORD(&pkt->handle, handle); + WRT_REG_BYTE((void __iomem *)&pkt->entry_count, req_cnt); + WRT_REG_WORD((void __iomem *)&pkt->handle, handle); } else { pkt->entry_count = req_cnt; pkt->handle = handle; diff --git a/drivers/scsi/qla2xxx/qla_mr.c b/drivers/scsi/qla2xxx/qla_mr.c index a6df55838365..d7993797f46e 100644 --- a/drivers/scsi/qla2xxx/qla_mr.c +++ b/drivers/scsi/qla2xxx/qla_mr.c @@ -707,7 +707,7 @@ qlafx00_tmf_iocb_timeout(void *data) srb_t *sp = (srb_t *)data; struct srb_iocb *tmf = &sp->u.iocb_cmd; - tmf->u.tmf.comp_status = CS_TIMEOUT; + tmf->u.tmf.comp_status = cpu_to_le16((uint16_t)CS_TIMEOUT); complete(&tmf->u.tmf.comp); } @@ -1418,7 +1418,8 @@ qlafx00_init_response_q_entries(struct rsp_que *rsp) pkt = rsp->ring_ptr; for (cnt = 0; cnt < rsp->length; cnt++) { pkt->signature = RESPONSE_PROCESSED; - WRT_REG_DWORD(&pkt->signature, RESPONSE_PROCESSED); + WRT_REG_DWORD((void __iomem *)&pkt->signature, + RESPONSE_PROCESSED); pkt++; } } @@ -1733,7 +1734,7 @@ qla2x00_fxdisc_sp_done(void *data, void *ptr, int res) } int -qlafx00_fx_disc(scsi_qla_host_t *vha, fc_port_t *fcport, uint8_t fx_type) +qlafx00_fx_disc(scsi_qla_host_t *vha, fc_port_t *fcport, uint16_t fx_type) { srb_t *sp; struct srb_iocb *fdisc; @@ -1759,13 +1760,13 @@ qlafx00_fx_disc(scsi_qla_host_t *vha, fc_port_t *fcport, uint8_t fx_type) fdisc->u.fxiocb.flags = SRB_FXDISC_RESP_DMA_VALID | SRB_FXDISC_REQ_DWRD_VALID; fdisc->u.fxiocb.rsp_len = QLAFX00_PORT_DATA_INFO; - fdisc->u.fxiocb.req_data = fcport->port_id; + fdisc->u.fxiocb.req_data = cpu_to_le32(fcport->port_id); break; case FXDISC_GET_TGT_NODE_INFO: fdisc->u.fxiocb.flags = SRB_FXDISC_RESP_DMA_VALID | SRB_FXDISC_REQ_DWRD_VALID; fdisc->u.fxiocb.rsp_len = QLAFX00_TGT_NODE_INFO; - fdisc->u.fxiocb.req_data = fcport->tgt_id; + fdisc->u.fxiocb.req_data = cpu_to_le32(fcport->tgt_id); break; case FXDISC_GET_TGT_NODE_LIST: fdisc->u.fxiocb.flags = @@ -1851,7 +1852,7 @@ qlafx00_fx_disc(scsi_qla_host_t *vha, fc_port_t *fcport, uint8_t fx_type) sp->name = "fxdisc"; qla2x00_init_timer(sp, FXDISC_TIMEOUT); fdisc->timeout = qla2x00_fxdisc_iocb_timeout; - fdisc->u.fxiocb.req_func_type = fx_type; + fdisc->u.fxiocb.req_func_type = cpu_to_le16(fx_type); sp->done = qla2x00_fxdisc_sp_done; rval = qla2x00_start_sp(sp); @@ -1904,7 +1905,7 @@ qlafx00_fx_disc(scsi_qla_host_t *vha, fc_port_t *fcport, uint8_t fx_type) (uint8_t *)pinfo, 16); memcpy(vha->hw->gid_list, pinfo, QLAFX00_TGT_NODE_LIST_SIZE); } - rval = fdisc->u.fxiocb.result; + rval = le32_to_cpu(fdisc->u.fxiocb.result); done_unmap_dma: if (fdisc->u.fxiocb.rsp_addr) @@ -1927,7 +1928,7 @@ qlafx00_abort_iocb_timeout(void *data) srb_t *sp = (srb_t *)data; struct srb_iocb *abt = &sp->u.iocb_cmd; - abt->u.abt.comp_status = CS_TIMEOUT; + abt->u.abt.comp_status = cpu_to_le16((uint16_t)CS_TIMEOUT); complete(&abt->u.abt.comp); } @@ -2169,14 +2170,14 @@ qlafx00_handle_sense(srb_t *sp, uint8_t *sense_data, uint32_t par_sense_len, static void qlafx00_tm_iocb_entry(scsi_qla_host_t *vha, struct req_que *req, struct tsk_mgmt_entry_fx00 *pkt, srb_t *sp, - uint16_t sstatus, uint16_t cpstatus) + __le16 sstatus, __le16 cpstatus) { struct srb_iocb *tmf; tmf = &sp->u.iocb_cmd; - if (cpstatus != CS_COMPLETE || - (sstatus & SS_RESPONSE_INFO_LEN_VALID)) - cpstatus = CS_INCOMPLETE; + if (cpstatus != cpu_to_le16((uint16_t)CS_COMPLETE) || + (sstatus & cpu_to_le16((uint16_t)SS_RESPONSE_INFO_LEN_VALID))) + cpstatus = cpu_to_le16((uint16_t)CS_INCOMPLETE); tmf->u.tmf.comp_status = cpstatus; sp->done(vha, sp, 0); } @@ -2194,7 +2195,7 @@ qlafx00_abort_iocb_entry(scsi_qla_host_t *vha, struct req_que *req, return; abt = &sp->u.iocb_cmd; - abt->u.abt.comp_status = le32_to_cpu(pkt->tgt_id_sts); + abt->u.abt.comp_status = pkt->tgt_id_sts; sp->done(vha, sp, 0); } @@ -2216,12 +2217,12 @@ qlafx00_ioctl_iosb_entry(scsi_qla_host_t *vha, struct req_que *req, if (sp->type == SRB_FXIOCB_DCMD) { iocb_job = &sp->u.iocb_cmd; - iocb_job->u.fxiocb.seq_number = le32_to_cpu(pkt->seq_no); - iocb_job->u.fxiocb.fw_flags = le32_to_cpu(pkt->fw_iotcl_flags); - iocb_job->u.fxiocb.result = le32_to_cpu(pkt->status); + iocb_job->u.fxiocb.seq_number = pkt->seq_no; + iocb_job->u.fxiocb.fw_flags = pkt->fw_iotcl_flags; + iocb_job->u.fxiocb.result = pkt->status; if (iocb_job->u.fxiocb.flags & SRB_FXDISC_RSP_DWRD_VALID) iocb_job->u.fxiocb.req_data = - le32_to_cpu(pkt->dataword_r); + pkt->dataword_r; } else { bsg_job = sp->u.bsg_job; @@ -2275,10 +2276,10 @@ qlafx00_status_entry(scsi_qla_host_t *vha, struct rsp_que *rsp, void *pkt) fc_port_t *fcport; struct scsi_cmnd *cp; struct sts_entry_fx00 *sts; - uint16_t comp_status; - uint16_t scsi_status; + __le16 comp_status; + __le16 scsi_status; uint16_t ox_id; - uint8_t lscsi_status; + __le16 lscsi_status; int32_t resid; uint32_t sense_len, par_sense_len, rsp_info_len, resid_len, fw_resid_len; @@ -2292,8 +2293,8 @@ qlafx00_status_entry(scsi_qla_host_t *vha, struct rsp_que *rsp, void *pkt) sts = (struct sts_entry_fx00 *) pkt; - comp_status = le16_to_cpu(sts->comp_status); - scsi_status = le16_to_cpu(sts->scsi_status) & SS_MASK; + comp_status = sts->comp_status; + scsi_status = sts->scsi_status & cpu_to_le16((uint16_t)SS_MASK); hindex = sts->handle; handle = LSW(hindex); @@ -2339,38 +2340,40 @@ qlafx00_status_entry(scsi_qla_host_t *vha, struct rsp_que *rsp, void *pkt) return; } - lscsi_status = scsi_status & STATUS_MASK; + lscsi_status = scsi_status & cpu_to_le16((uint16_t)STATUS_MASK); fcport = sp->fcport; ox_id = 0; sense_len = par_sense_len = rsp_info_len = resid_len = fw_resid_len = 0; - if (scsi_status & SS_SENSE_LEN_VALID) - sense_len = le32_to_cpu(sts->sense_len); - if (scsi_status & (SS_RESIDUAL_UNDER | SS_RESIDUAL_OVER)) + if (scsi_status & cpu_to_le16((uint16_t)SS_SENSE_LEN_VALID)) + sense_len = sts->sense_len; + if (scsi_status & cpu_to_le16(((uint16_t)SS_RESIDUAL_UNDER + | (uint16_t)SS_RESIDUAL_OVER))) resid_len = le32_to_cpu(sts->residual_len); - if (comp_status == CS_DATA_UNDERRUN) + if (comp_status == cpu_to_le16((uint16_t)CS_DATA_UNDERRUN)) fw_resid_len = le32_to_cpu(sts->residual_len); rsp_info = sense_data = sts->data; par_sense_len = sizeof(sts->data); /* Check for overrun. */ if (comp_status == CS_COMPLETE && - scsi_status & SS_RESIDUAL_OVER) - comp_status = CS_DATA_OVERRUN; + scsi_status & cpu_to_le16((uint16_t)SS_RESIDUAL_OVER)) + comp_status = cpu_to_le16((uint16_t)CS_DATA_OVERRUN); /* * Based on Host and scsi status generate status code for Linux */ - switch (comp_status) { + switch (le16_to_cpu(comp_status)) { case CS_COMPLETE: case CS_QUEUE_FULL: if (scsi_status == 0) { res = DID_OK << 16; break; } - if (scsi_status & (SS_RESIDUAL_UNDER | SS_RESIDUAL_OVER)) { + if (scsi_status & cpu_to_le16(((uint16_t)SS_RESIDUAL_UNDER + | (uint16_t)SS_RESIDUAL_OVER))) { resid = resid_len; scsi_set_resid(cp, resid); @@ -2386,19 +2389,20 @@ qlafx00_status_entry(scsi_qla_host_t *vha, struct rsp_que *rsp, void *pkt) break; } } - res = DID_OK << 16 | lscsi_status; + res = DID_OK << 16 | le16_to_cpu(lscsi_status); - if (lscsi_status == SAM_STAT_TASK_SET_FULL) { + if (lscsi_status == + cpu_to_le16((uint16_t)SAM_STAT_TASK_SET_FULL)) { ql_dbg(ql_dbg_io, fcport->vha, 0x3051, "QUEUE FULL detected.\n"); break; } logit = 0; - if (lscsi_status != SS_CHECK_CONDITION) + if (lscsi_status != cpu_to_le16((uint16_t)SS_CHECK_CONDITION)) break; memset(cp->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE); - if (!(scsi_status & SS_SENSE_LEN_VALID)) + if (!(scsi_status & cpu_to_le16((uint16_t)SS_SENSE_LEN_VALID))) break; qlafx00_handle_sense(sp, sense_data, par_sense_len, sense_len, @@ -2412,7 +2416,7 @@ qlafx00_status_entry(scsi_qla_host_t *vha, struct rsp_que *rsp, void *pkt) else resid = resid_len; scsi_set_resid(cp, resid); - if (scsi_status & SS_RESIDUAL_UNDER) { + if (scsi_status & cpu_to_le16((uint16_t)SS_RESIDUAL_UNDER)) { if ((IS_FWI2_CAPABLE(ha) || IS_QLAFX00(ha)) && fw_resid_len != resid_len) { ql_dbg(ql_dbg_io, fcport->vha, 0x3052, @@ -2420,7 +2424,8 @@ qlafx00_status_entry(scsi_qla_host_t *vha, struct rsp_que *rsp, void *pkt) "(0x%x of 0x%x bytes).\n", resid, scsi_bufflen(cp)); - res = DID_ERROR << 16 | lscsi_status; + res = DID_ERROR << 16 | + le16_to_cpu(lscsi_status); goto check_scsi_status; } @@ -2436,8 +2441,9 @@ qlafx00_status_entry(scsi_qla_host_t *vha, struct rsp_que *rsp, void *pkt) res = DID_ERROR << 16; break; } - } else if (lscsi_status != SAM_STAT_TASK_SET_FULL && - lscsi_status != SAM_STAT_BUSY) { + } else if (lscsi_status != + cpu_to_le16((uint16_t)SAM_STAT_TASK_SET_FULL) && + lscsi_status != cpu_to_le16((uint16_t)SAM_STAT_BUSY)) { /* * scsi status of task set and busy are considered * to be task not completed. @@ -2448,7 +2454,7 @@ qlafx00_status_entry(scsi_qla_host_t *vha, struct rsp_que *rsp, void *pkt) "of 0x%x bytes).\n", resid, scsi_bufflen(cp)); - res = DID_ERROR << 16 | lscsi_status; + res = DID_ERROR << 16 | le16_to_cpu(lscsi_status); goto check_scsi_status; } else { ql_dbg(ql_dbg_io, fcport->vha, 0x3055, @@ -2456,7 +2462,7 @@ qlafx00_status_entry(scsi_qla_host_t *vha, struct rsp_que *rsp, void *pkt) scsi_status, lscsi_status); } - res = DID_OK << 16 | lscsi_status; + res = DID_OK << 16 | le16_to_cpu(lscsi_status); logit = 0; check_scsi_status: @@ -2465,17 +2471,20 @@ check_scsi_status: * Status. */ if (lscsi_status != 0) { - if (lscsi_status == SAM_STAT_TASK_SET_FULL) { + if (lscsi_status == + cpu_to_le16((uint16_t)SAM_STAT_TASK_SET_FULL)) { ql_dbg(ql_dbg_io, fcport->vha, 0x3056, "QUEUE FULL detected.\n"); logit = 1; break; } - if (lscsi_status != SS_CHECK_CONDITION) + if (lscsi_status != + cpu_to_le16((uint16_t)SS_CHECK_CONDITION)) break; memset(cp->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE); - if (!(scsi_status & SS_SENSE_LEN_VALID)) + if (!(scsi_status & + cpu_to_le16((uint16_t)SS_SENSE_LEN_VALID))) break; qlafx00_handle_sense(sp, sense_data, par_sense_len, @@ -2629,7 +2638,7 @@ qlafx00_multistatus_entry(struct scsi_qla_host *vha, uint32_t handle, hindex, handle_count, i; uint16_t que; struct req_que *req; - uint32_t *handle_ptr; + __le32 *handle_ptr; stsmfx = (struct multi_sts_entry_fx00 *) pkt; @@ -2643,7 +2652,7 @@ qlafx00_multistatus_entry(struct scsi_qla_host *vha, return; } - handle_ptr = (uint32_t *) &stsmfx->handles[0]; + handle_ptr = &stsmfx->handles[0]; for (i = 0; i < handle_count; i++) { hindex = le32_to_cpu(*handle_ptr); @@ -2714,10 +2723,11 @@ qlafx00_process_response_queue(struct scsi_qla_host *vha, if (!vha->flags.online) return; - while (RD_REG_DWORD(&(rsp->ring_ptr->signature)) != + while (RD_REG_DWORD((void __iomem *)&(rsp->ring_ptr->signature)) != RESPONSE_PROCESSED) { lptr = rsp->ring_ptr; - memcpy_fromio(rsp->rsp_pkt, lptr, sizeof(rsp->rsp_pkt)); + memcpy_fromio(rsp->rsp_pkt, (void __iomem *)lptr, + sizeof(rsp->rsp_pkt)); pkt = (struct sts_entry_fx00 *)rsp->rsp_pkt; rsp->ring_index++; @@ -2768,7 +2778,8 @@ qlafx00_process_response_queue(struct scsi_qla_host *vha, break; } next_iter: - WRT_REG_DWORD(&lptr->signature, RESPONSE_PROCESSED); + WRT_REG_DWORD((void __iomem *)&lptr->signature, + RESPONSE_PROCESSED); wmb(); } @@ -2958,8 +2969,7 @@ qlafx00_prep_cont_type1_iocb(struct req_que *req, cont_pkt = (cont_a64_entry_t *)req->ring_ptr; /* Load packet defaults. */ - *((uint32_t *)(&lcont_pkt->entry_type)) = - __constant_cpu_to_le32(CONTINUE_A64_TYPE_FX00); + lcont_pkt->entry_type = CONTINUE_A64_TYPE_FX00; return cont_pkt; } @@ -2969,7 +2979,7 @@ qlafx00_build_scsi_iocbs(srb_t *sp, struct cmd_type_7_fx00 *cmd_pkt, uint16_t tot_dsds, struct cmd_type_7_fx00 *lcmd_pkt) { uint16_t avail_dsds; - uint32_t *cur_dsd; + __le32 *cur_dsd; scsi_qla_host_t *vha; struct scsi_cmnd *cmd; struct scatterlist *sg; @@ -2986,8 +2996,7 @@ qlafx00_build_scsi_iocbs(srb_t *sp, struct cmd_type_7_fx00 *cmd_pkt, cont_pkt = NULL; /* Update entry type to indicate Command Type 3 IOCB */ - *((uint32_t *)(&lcmd_pkt->entry_type)) = - __constant_cpu_to_le32(FX00_COMMAND_TYPE_7); + lcmd_pkt->entry_type = FX00_COMMAND_TYPE_7; /* No data transfer */ if (!scsi_bufflen(cmd) || cmd->sc_data_direction == DMA_NONE) { @@ -3006,7 +3015,7 @@ qlafx00_build_scsi_iocbs(srb_t *sp, struct cmd_type_7_fx00 *cmd_pkt, /* One DSD is available in the Command Type 3 IOCB */ avail_dsds = 1; - cur_dsd = (uint32_t *)&lcmd_pkt->dseg_0_address; + cur_dsd = (__le32 *)&lcmd_pkt->dseg_0_address; /* Load data segments */ scsi_for_each_sg(cmd, sg, tot_dsds, i) { @@ -3021,7 +3030,7 @@ qlafx00_build_scsi_iocbs(srb_t *sp, struct cmd_type_7_fx00 *cmd_pkt, memset(&lcont_pkt, 0, REQUEST_ENTRY_SIZE); cont_pkt = qlafx00_prep_cont_type1_iocb(req, &lcont_pkt); - cur_dsd = (uint32_t *)lcont_pkt.dseg_0_address; + cur_dsd = (__le32 *)lcont_pkt.dseg_0_address; avail_dsds = 5; cont = 1; } @@ -3224,13 +3233,13 @@ qlafx00_tm_iocb(srb_t *sp, struct tsk_mgmt_entry_fx00 *ptm_iocb) tm_iocb.timeout = cpu_to_le16(qla2x00_get_async_timeout(vha) + 2); tm_iocb.tgt_id = cpu_to_le16(sp->fcport->tgt_id); tm_iocb.control_flags = cpu_to_le32(fxio->u.tmf.flags); - if (tm_iocb.control_flags == TCF_LUN_RESET) { + if (tm_iocb.control_flags == cpu_to_le32((uint32_t)TCF_LUN_RESET)) { int_to_scsilun(fxio->u.tmf.lun, &llun); host_to_adap((uint8_t *)&llun, (uint8_t *)&tm_iocb.lun, sizeof(struct scsi_lun)); } - memcpy((void __iomem *)ptm_iocb, &tm_iocb, + memcpy((void *)ptm_iocb, &tm_iocb, sizeof(struct tsk_mgmt_entry_fx00)); wmb(); } @@ -3252,7 +3261,7 @@ qlafx00_abort_iocb(srb_t *sp, struct abort_iocb_entry_fx00 *pabt_iocb) abt_iocb.tgt_id_sts = cpu_to_le16(sp->fcport->tgt_id); abt_iocb.req_que_no = cpu_to_le16(req->id); - memcpy((void __iomem *)pabt_iocb, &abt_iocb, + memcpy((void *)pabt_iocb, &abt_iocb, sizeof(struct abort_iocb_entry_fx00)); wmb(); } @@ -3273,13 +3282,12 @@ qlafx00_fxdisc_iocb(srb_t *sp, struct fxdisc_entry_fx00 *pfxiocb) if (sp->type == SRB_FXIOCB_DCMD) { fx_iocb.func_num = - cpu_to_le16(sp->u.iocb_cmd.u.fxiocb.req_func_type); - fx_iocb.adapid = cpu_to_le32(fxio->u.fxiocb.adapter_id); - fx_iocb.adapid_hi = cpu_to_le32(fxio->u.fxiocb.adapter_id_hi); - fx_iocb.reserved_0 = cpu_to_le32(fxio->u.fxiocb.reserved_0); - fx_iocb.reserved_1 = cpu_to_le32(fxio->u.fxiocb.reserved_1); - fx_iocb.dataword_extra = - cpu_to_le32(fxio->u.fxiocb.req_data_extra); + sp->u.iocb_cmd.u.fxiocb.req_func_type; + fx_iocb.adapid = fxio->u.fxiocb.adapter_id; + fx_iocb.adapid_hi = fxio->u.fxiocb.adapter_id_hi; + fx_iocb.reserved_0 = fxio->u.fxiocb.reserved_0; + fx_iocb.reserved_1 = fxio->u.fxiocb.reserved_1; + fx_iocb.dataword_extra = fxio->u.fxiocb.req_data_extra; if (fxio->u.fxiocb.flags & SRB_FXDISC_REQ_DMA_VALID) { fx_iocb.req_dsdcnt = cpu_to_le16(1); @@ -3306,8 +3314,7 @@ qlafx00_fxdisc_iocb(srb_t *sp, struct fxdisc_entry_fx00 *pfxiocb) } if (fxio->u.fxiocb.flags & SRB_FXDISC_REQ_DWRD_VALID) { - fx_iocb.dataword = - cpu_to_le32(fxio->u.fxiocb.req_data); + fx_iocb.dataword = fxio->u.fxiocb.req_data; } fx_iocb.flags = fxio->u.fxiocb.flags; } else { @@ -3323,21 +3330,21 @@ qlafx00_fxdisc_iocb(srb_t *sp, struct fxdisc_entry_fx00 *pfxiocb) fx_iocb.reserved_1 = piocb_rqst->reserved_1; fx_iocb.dataword_extra = piocb_rqst->dataword_extra; fx_iocb.dataword = piocb_rqst->dataword; - fx_iocb.req_xfrcnt = cpu_to_le16(piocb_rqst->req_len); - fx_iocb.rsp_xfrcnt = cpu_to_le16(piocb_rqst->rsp_len); + fx_iocb.req_xfrcnt = piocb_rqst->req_len; + fx_iocb.rsp_xfrcnt = piocb_rqst->rsp_len; if (piocb_rqst->flags & SRB_FXDISC_REQ_DMA_VALID) { int avail_dsds, tot_dsds; cont_a64_entry_t lcont_pkt; cont_a64_entry_t *cont_pkt = NULL; - uint32_t *cur_dsd; + __le32 *cur_dsd; int index = 0, cont = 0; fx_iocb.req_dsdcnt = cpu_to_le16(bsg_job->request_payload.sg_cnt); tot_dsds = - cpu_to_le32(bsg_job->request_payload.sg_cnt); - cur_dsd = (uint32_t *)&fx_iocb.dseg_rq_address[0]; + bsg_job->request_payload.sg_cnt; + cur_dsd = (__le32 *)&fx_iocb.dseg_rq_address[0]; avail_dsds = 1; for_each_sg(bsg_job->request_payload.sg_list, sg, tot_dsds, index) { @@ -3355,7 +3362,7 @@ qlafx00_fxdisc_iocb(srb_t *sp, struct fxdisc_entry_fx00 *pfxiocb) qlafx00_prep_cont_type1_iocb( sp->fcport->vha->req, &lcont_pkt); - cur_dsd = (uint32_t *) + cur_dsd = (__le32 *) lcont_pkt.dseg_0_address; avail_dsds = 5; cont = 1; @@ -3393,13 +3400,13 @@ qlafx00_fxdisc_iocb(srb_t *sp, struct fxdisc_entry_fx00 *pfxiocb) int avail_dsds, tot_dsds; cont_a64_entry_t lcont_pkt; cont_a64_entry_t *cont_pkt = NULL; - uint32_t *cur_dsd; + __le32 *cur_dsd; int index = 0, cont = 0; fx_iocb.rsp_dsdcnt = cpu_to_le16(bsg_job->reply_payload.sg_cnt); - tot_dsds = cpu_to_le32(bsg_job->reply_payload.sg_cnt); - cur_dsd = (uint32_t *)&fx_iocb.dseg_rsp_address[0]; + tot_dsds = bsg_job->reply_payload.sg_cnt; + cur_dsd = (__le32 *)&fx_iocb.dseg_rsp_address[0]; avail_dsds = 1; for_each_sg(bsg_job->reply_payload.sg_list, sg, @@ -3418,7 +3425,7 @@ qlafx00_fxdisc_iocb(srb_t *sp, struct fxdisc_entry_fx00 *pfxiocb) qlafx00_prep_cont_type1_iocb( sp->fcport->vha->req, &lcont_pkt); - cur_dsd = (uint32_t *) + cur_dsd = (__le32 *) lcont_pkt.dseg_0_address; avail_dsds = 5; cont = 1; @@ -3453,7 +3460,7 @@ qlafx00_fxdisc_iocb(srb_t *sp, struct fxdisc_entry_fx00 *pfxiocb) } if (piocb_rqst->flags & SRB_FXDISC_REQ_DWRD_VALID) - fx_iocb.dataword = cpu_to_le32(piocb_rqst->dataword); + fx_iocb.dataword = piocb_rqst->dataword; fx_iocb.flags = piocb_rqst->flags; fx_iocb.entry_count = entry_cnt; } @@ -3462,7 +3469,7 @@ qlafx00_fxdisc_iocb(srb_t *sp, struct fxdisc_entry_fx00 *pfxiocb) sp->fcport->vha, 0x3047, (uint8_t *)&fx_iocb, sizeof(struct fxdisc_entry_fx00)); - memcpy((void __iomem *)pfxiocb, &fx_iocb, + memcpy((void *)pfxiocb, &fx_iocb, sizeof(struct fxdisc_entry_fx00)); wmb(); } diff --git a/drivers/scsi/qla2xxx/qla_mr.h b/drivers/scsi/qla2xxx/qla_mr.h index cc327dc2fd10..1a092af0e2c3 100644 --- a/drivers/scsi/qla2xxx/qla_mr.h +++ b/drivers/scsi/qla2xxx/qla_mr.h @@ -24,10 +24,10 @@ struct cmd_type_7_fx00 { uint32_t handle; /* System handle. */ uint32_t handle_hi; - uint16_t tgt_idx; /* Target Idx. */ + __le16 tgt_idx; /* Target Idx. */ uint16_t timeout; /* Command timeout. */ - uint16_t dseg_count; /* Data segment count. */ + __le16 dseg_count; /* Data segment count. */ uint16_t scsi_rsp_dsd_len; struct scsi_lun lun; /* LUN (LE). */ @@ -41,7 +41,7 @@ struct cmd_type_7_fx00 { uint8_t crn; uint8_t fcp_cdb[MAX_CMDSZ]; /* SCSI command words. */ - uint32_t byte_count; /* Total byte count. */ + __le32 byte_count; /* Total byte count. */ uint32_t dseg_0_address[2]; /* Data segment 0 address. */ uint32_t dseg_0_len; /* Data segment 0 length. */ @@ -81,16 +81,16 @@ struct sts_entry_fx00 { uint32_t handle; /* System handle. */ uint32_t handle_hi; /* System handle. */ - uint16_t comp_status; /* Completion status. */ + __le16 comp_status; /* Completion status. */ uint16_t reserved_0; /* OX_ID used by the firmware. */ - uint32_t residual_len; /* FW calc residual transfer length. */ + __le32 residual_len; /* FW calc residual transfer length. */ uint16_t reserved_1; uint16_t state_flags; /* State flags. */ uint16_t reserved_2; - uint16_t scsi_status; /* SCSI status. */ + __le16 scsi_status; /* SCSI status. */ uint32_t sense_len; /* FCP SENSE length. */ uint8_t data[32]; /* FCP response/sense information. */ @@ -106,7 +106,7 @@ struct multi_sts_entry_fx00 { uint8_t handle_count; uint8_t entry_status; - uint32_t handles[MAX_HANDLE_COUNT]; + __le32 handles[MAX_HANDLE_COUNT]; }; #define TSK_MGMT_IOCB_TYPE_FX00 0x05 @@ -116,21 +116,21 @@ struct tsk_mgmt_entry_fx00 { uint8_t sys_define; uint8_t entry_status; /* Entry Status. */ - uint32_t handle; /* System handle. */ + __le32 handle; /* System handle. */ uint32_t handle_hi; /* System handle. */ - uint16_t tgt_id; /* Target Idx. */ + __le16 tgt_id; /* Target Idx. */ uint16_t reserved_1; uint16_t delay; /* Activity delay in seconds. */ - uint16_t timeout; /* Command timeout. */ + __le16 timeout; /* Command timeout. */ struct scsi_lun lun; /* LUN (LE). */ - uint32_t control_flags; /* Control Flags. */ + __le32 control_flags; /* Control Flags. */ uint8_t reserved_2[32]; }; @@ -143,16 +143,16 @@ struct abort_iocb_entry_fx00 { uint8_t sys_define; /* System defined. */ uint8_t entry_status; /* Entry Status. */ - uint32_t handle; /* System handle. */ - uint32_t handle_hi; /* System handle. */ + __le32 handle; /* System handle. */ + __le32 handle_hi; /* System handle. */ - uint16_t tgt_id_sts; /* Completion status. */ - uint16_t options; + __le16 tgt_id_sts; /* Completion status. */ + __le16 options; - uint32_t abort_handle; /* System handle. */ - uint32_t abort_handle_hi; /* System handle. */ + __le32 abort_handle; /* System handle. */ + __le32 abort_handle_hi; /* System handle. */ - uint16_t req_que_no; + __le16 req_que_no; uint8_t reserved_1[38]; }; @@ -167,17 +167,17 @@ struct ioctl_iocb_entry_fx00 { uint32_t reserved_0; /* System handle. */ uint16_t comp_func_num; - uint16_t fw_iotcl_flags; + __le16 fw_iotcl_flags; - uint32_t dataword_r; /* Data word returned */ + __le32 dataword_r; /* Data word returned */ uint32_t adapid; /* Adapter ID */ uint32_t adapid_hi; /* Adapter ID high */ uint32_t reserved_1; - uint32_t seq_no; + __le32 seq_no; uint8_t reserved_2[20]; uint32_t residuallen; - uint32_t status; + __le32 status; }; #define STATUS_CONT_TYPE_FX00 0x04 @@ -189,26 +189,26 @@ struct fxdisc_entry_fx00 { uint8_t sys_define; /* System Defined. */ uint8_t entry_status; /* Entry Status. */ - uint32_t handle; /* System handle. */ - uint32_t reserved_0; /* System handle. */ + __le32 handle; /* System handle. */ + __le32 reserved_0; /* System handle. */ - uint16_t func_num; - uint16_t req_xfrcnt; - uint16_t req_dsdcnt; - uint16_t rsp_xfrcnt; - uint16_t rsp_dsdcnt; + __le16 func_num; + __le16 req_xfrcnt; + __le16 req_dsdcnt; + __le16 rsp_xfrcnt; + __le16 rsp_dsdcnt; uint8_t flags; uint8_t reserved_1; - uint32_t dseg_rq_address[2]; /* Data segment 0 address. */ - uint32_t dseg_rq_len; /* Data segment 0 length. */ - uint32_t dseg_rsp_address[2]; /* Data segment 1 address. */ - uint32_t dseg_rsp_len; /* Data segment 1 length. */ + __le32 dseg_rq_address[2]; /* Data segment 0 address. */ + __le32 dseg_rq_len; /* Data segment 0 length. */ + __le32 dseg_rsp_address[2]; /* Data segment 1 address. */ + __le32 dseg_rsp_len; /* Data segment 1 length. */ - uint32_t dataword; - uint32_t adapid; - uint32_t adapid_hi; - uint32_t dataword_extra; + __le32 dataword; + __le32 adapid; + __le32 adapid_hi; + __le32 dataword_extra; }; struct qlafx00_tgt_node_info { @@ -421,43 +421,43 @@ struct config_info_data { WRT_REG_DWORD((ha)->cregbase + off, val) struct qla_mt_iocb_rqst_fx00 { - uint32_t reserved_0; + __le32 reserved_0; - uint16_t func_type; + __le16 func_type; uint8_t flags; uint8_t reserved_1; - uint32_t dataword; + __le32 dataword; - uint32_t adapid; - uint32_t adapid_hi; + __le32 adapid; + __le32 adapid_hi; - uint32_t dataword_extra; + __le32 dataword_extra; - uint32_t req_len; + __le32 req_len; - uint32_t rsp_len; + __le32 rsp_len; }; struct qla_mt_iocb_rsp_fx00 { uint32_t reserved_1; uint16_t func_type; - uint16_t ioctl_flags; + __le16 ioctl_flags; - uint32_t ioctl_data; + __le32 ioctl_data; uint32_t adapid; uint32_t adapid_hi; uint32_t reserved_2; - uint32_t seq_number; + __le32 seq_number; uint8_t reserved_3[20]; int32_t res_count; - uint32_t status; + __le32 status; }; From 090fc2e2cf6a2763f609af6f128a812d5051d935 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Tue, 25 Jun 2013 11:27:22 -0400 Subject: [PATCH 0651/1048] [SCSI] qla2xxx: Clean up qla24xx_iidma() Remove dead code and simplify a pointer computation. Signed-off-by: Bart Van Assche Signed-off-by: Saurav Kashyap Signed-off-by: James Bottomley --- drivers/scsi/qla2xxx/qla_bsg.c | 9 +-------- drivers/scsi/qla2xxx/qla_dbg.c | 3 ++- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_bsg.c b/drivers/scsi/qla2xxx/qla_bsg.c index 5ba0cc1f982b..9a30b696d758 100644 --- a/drivers/scsi/qla2xxx/qla_bsg.c +++ b/drivers/scsi/qla2xxx/qla_bsg.c @@ -1282,14 +1282,7 @@ qla24xx_iidma(struct fc_bsg_job *bsg_job) return -EINVAL; } - port_param = (struct qla_port_param *)((char *)bsg_job->request + - sizeof(struct fc_bsg_request)); - if (!port_param) { - ql_log(ql_log_warn, vha, 0x7047, - "port_param header not provided.\n"); - return -EINVAL; - } - + port_param = (void *)bsg_job->request + sizeof(struct fc_bsg_request); if (port_param->fc_scsi_addr.dest_type != EXT_DEF_TYPE_WWPN) { ql_log(ql_log_warn, vha, 0x7048, "Invalid destination type.\n"); diff --git a/drivers/scsi/qla2xxx/qla_dbg.c b/drivers/scsi/qla2xxx/qla_dbg.c index 3cc2105dd902..91a11667a477 100644 --- a/drivers/scsi/qla2xxx/qla_dbg.c +++ b/drivers/scsi/qla2xxx/qla_dbg.c @@ -35,7 +35,8 @@ * | | | 0x70a5,0x70a6, | * | | | 0x70a8,0x70ab, | * | | | 0x70ad-0x70ae, | - * | | | 0x70d1-0x70da | + * | | | 0x70d1-0x70da, | + * | | | 0x7047 | * | Task Management | 0x803c | 0x8025-0x8026 | * | | | 0x800b,0x8039 | * | AER/EEH | 0x9011 | | From a44c72f309224973ffc7c7dfeee6e354c6f3d739 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Tue, 25 Jun 2013 11:27:23 -0400 Subject: [PATCH 0652/1048] [SCSI] qla2xxx: Clean up qla84xx_mgmt_cmd() Remove dead code, simplify a pointer computation and move the ql84_mgmt assignment to just before its first use. Signed-off-by: Bart Van Assche Signed-off-by: Saurav Kashyap Signed-off-by: James Bottomley --- drivers/scsi/qla2xxx/qla_bsg.c | 10 +--------- drivers/scsi/qla2xxx/qla_dbg.c | 2 +- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_bsg.c b/drivers/scsi/qla2xxx/qla_bsg.c index 9a30b696d758..b85f0021db3b 100644 --- a/drivers/scsi/qla2xxx/qla_bsg.c +++ b/drivers/scsi/qla2xxx/qla_bsg.c @@ -1084,14 +1084,6 @@ qla84xx_mgmt_cmd(struct fc_bsg_job *bsg_job) return -EINVAL; } - ql84_mgmt = (struct qla_bsg_a84_mgmt *)((char *)bsg_job->request + - sizeof(struct fc_bsg_request)); - if (!ql84_mgmt) { - ql_log(ql_log_warn, vha, 0x703b, - "MGMT header not provided, exiting.\n"); - return -EINVAL; - } - mn = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &mn_dma); if (!mn) { ql_log(ql_log_warn, vha, 0x703c, @@ -1102,7 +1094,7 @@ qla84xx_mgmt_cmd(struct fc_bsg_job *bsg_job) memset(mn, 0, sizeof(struct access_chip_84xx)); mn->entry_type = ACCESS_CHIP_IOCB_TYPE; mn->entry_count = 1; - + ql84_mgmt = (void *)bsg_job->request + sizeof(struct fc_bsg_request); switch (ql84_mgmt->mgmt.cmd) { case QLA84_MGMT_READ_MEM: case QLA84_MGMT_GET_INFO: diff --git a/drivers/scsi/qla2xxx/qla_dbg.c b/drivers/scsi/qla2xxx/qla_dbg.c index 91a11667a477..74a2121783c9 100644 --- a/drivers/scsi/qla2xxx/qla_dbg.c +++ b/drivers/scsi/qla2xxx/qla_dbg.c @@ -36,7 +36,7 @@ * | | | 0x70a8,0x70ab, | * | | | 0x70ad-0x70ae, | * | | | 0x70d1-0x70da, | - * | | | 0x7047 | + * | | | 0x7047,0x703b | * | Task Management | 0x803c | 0x8025-0x8026 | * | | | 0x800b,0x8039 | * | AER/EEH | 0x9011 | | From 6593d5bdbdb26d848ac5afa469cdca7abd3298df Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Tue, 25 Jun 2013 11:27:24 -0400 Subject: [PATCH 0653/1048] [SCSI] qla2xxx: Remove dead code in qla2x00_configure_hba() At the end of qla2x00_configure_hba() we know that rval == QLA_SUCCESS. Hence remove the dead code. Signed-off-by: Bart Van Assche Signed-off-by: Saurav Kashyap Signed-off-by: James Bottomley --- drivers/scsi/qla2xxx/qla_dbg.c | 1 + drivers/scsi/qla2xxx/qla_init.c | 8 -------- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_dbg.c b/drivers/scsi/qla2xxx/qla_dbg.c index 74a2121783c9..91dbd8159eb1 100644 --- a/drivers/scsi/qla2xxx/qla_dbg.c +++ b/drivers/scsi/qla2xxx/qla_dbg.c @@ -15,6 +15,7 @@ * | Mailbox commands | 0x117a | 0x111a-0x111b | * | | | 0x1155-0x1158 | * | Device Discovery | 0x2095 | 0x2020-0x2022, | + * | | | 0x2011-0x2012, | * | | | 0x2016 | * | Queue Command and IO tracing | 0x3058 | 0x3006-0x300b | * | | | 0x3027-0x3028 | diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c index 3565dfd8f370..f2216ed2ad8c 100644 --- a/drivers/scsi/qla2xxx/qla_init.c +++ b/drivers/scsi/qla2xxx/qla_init.c @@ -2309,14 +2309,6 @@ qla2x00_configure_hba(scsi_qla_host_t *vha) "Topology - %s, Host Loop address 0x%x.\n", connect_type, vha->loop_id); - if (rval) { - ql_log(ql_log_warn, vha, 0x2011, - "%s FAILED\n", __func__); - } else { - ql_dbg(ql_dbg_disc, vha, 0x2012, - "%s success\n", __func__); - } - return(rval); } From c5dcfaac943da1a2981e7488f74b0d4259fbb43f Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Tue, 25 Jun 2013 11:27:25 -0400 Subject: [PATCH 0654/1048] [SCSI] qla2xxx: Remove two superfluous tests. Since ha->model_desc is an array comparing it against NULL is superfluous. Hence remove these tests. Signed-off-by: Bart Van Assche Signed-off-by: Saurav Kashyap Signed-off-by: James Bottomley --- drivers/scsi/qla2xxx/qla_gs.c | 3 +-- drivers/scsi/qla2xxx/qla_os.c | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_gs.c b/drivers/scsi/qla2xxx/qla_gs.c index d0ea8b921177..f26442a73d1e 100644 --- a/drivers/scsi/qla2xxx/qla_gs.c +++ b/drivers/scsi/qla2xxx/qla_gs.c @@ -1370,8 +1370,7 @@ qla2x00_fdmi_rhba(scsi_qla_host_t *vha) /* Model description. */ eiter = (struct ct_fdmi_hba_attr *) (entries + size); eiter->type = __constant_cpu_to_be16(FDMI_HBA_MODEL_DESCRIPTION); - if (ha->model_desc) - strncpy(eiter->a.model_desc, ha->model_desc, 80); + strncpy(eiter->a.model_desc, ha->model_desc, 80); alen = strlen(eiter->a.model_desc); alen += (alen & 3) ? (4 - (alen & 3)) : 4; eiter->len = cpu_to_be16(4 + alen); diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c index c2e2e20d2e21..6df5223888f8 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c @@ -2839,8 +2839,7 @@ skip_dpc: qla2x00_dfs_setup(base_vha); ql_log(ql_log_info, base_vha, 0x00fb, - "QLogic %s - %s.\n", - ha->model_number, ha->model_desc ? ha->model_desc : ""); + "QLogic %s - %s.\n", ha->model_number, ha->model_desc); ql_log(ql_log_info, base_vha, 0x00fc, "ISP%04X: %s @ %s hdma%c host#=%ld fw=%s.\n", pdev->device, ha->isp_ops->pci_info_str(base_vha, pci_info), From 4e541debb8f8746bd61f41cbb129ce9c6987b9d8 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Tue, 25 Jun 2013 11:27:26 -0400 Subject: [PATCH 0655/1048] [SCSI] qla2xxx: Remove a dead assignment in qla24xx_build_scsi_crc_2_iocbs(). Since the value of cur_seg is not used and since scsi_prot_sglist() has no side effects it is safe to remove the statement "cur_seg = scsi_port_sglist(cmd)". Detected by Coverity. Signed-off-by: Bart Van Assche Signed-off-by: Saurav Kashyap Signed-off-by: James Bottomley --- drivers/scsi/qla2xxx/qla_iocb.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_iocb.c b/drivers/scsi/qla2xxx/qla_iocb.c index 9de372f00d4a..42ef481db942 100644 --- a/drivers/scsi/qla2xxx/qla_iocb.c +++ b/drivers/scsi/qla2xxx/qla_iocb.c @@ -1189,7 +1189,6 @@ qla24xx_build_scsi_crc_2_iocbs(srb_t *sp, struct cmd_type_crc_2 *cmd_pkt, uint32_t *cur_dsd, *fcp_dl; scsi_qla_host_t *vha; struct scsi_cmnd *cmd; - struct scatterlist *cur_seg; int sgc; uint32_t total_bytes = 0; uint32_t data_bytes; @@ -1396,7 +1395,6 @@ qla24xx_build_scsi_crc_2_iocbs(srb_t *sp, struct cmd_type_crc_2 *cmd_pkt, if (bundling && tot_prot_dsds) { /* Walks dif segments */ - cur_seg = scsi_prot_sglist(cmd); cmd_pkt->control_flags |= __constant_cpu_to_le16(CF_DIF_SEG_DESCR_ENABLE); cur_dsd = (uint32_t *) &crc_ctx_pkt->u.bundling.dif_address; From 7f544d00698282655c7abed2262a39f5d9fe9283 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Tue, 25 Jun 2013 11:27:27 -0400 Subject: [PATCH 0656/1048] [SCSI] qla2xxx: Remove redundant assignments. The value of the pointer called "nxt" is not used after the "nxt = qla24xx_copy_eft(ha, nxt)" statement. Hence keep the function call but remove the assignment. Signed-off-by: Bart Van Assche Signed-off-by: Saurav Kashyap Signed-off-by: James Bottomley --- drivers/scsi/qla2xxx/qla_dbg.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_dbg.c b/drivers/scsi/qla2xxx/qla_dbg.c index 91dbd8159eb1..df132fec6d86 100644 --- a/drivers/scsi/qla2xxx/qla_dbg.c +++ b/drivers/scsi/qla2xxx/qla_dbg.c @@ -1470,7 +1470,7 @@ qla25xx_fw_dump(scsi_qla_host_t *vha, int hardware_locked) nxt = qla2xxx_copy_queues(ha, nxt); - nxt = qla24xx_copy_eft(ha, nxt); + qla24xx_copy_eft(ha, nxt); /* Chain entries -- started with MQ. */ nxt_chain = qla25xx_copy_fce(ha, nxt_chain, &last_chain); @@ -1789,7 +1789,7 @@ qla81xx_fw_dump(scsi_qla_host_t *vha, int hardware_locked) nxt = qla2xxx_copy_queues(ha, nxt); - nxt = qla24xx_copy_eft(ha, nxt); + qla24xx_copy_eft(ha, nxt); /* Chain entries -- started with MQ. */ nxt_chain = qla25xx_copy_fce(ha, nxt_chain, &last_chain); @@ -2291,7 +2291,7 @@ qla83xx_fw_dump(scsi_qla_host_t *vha, int hardware_locked) copy_queue: nxt = qla2xxx_copy_queues(ha, nxt); - nxt = qla24xx_copy_eft(ha, nxt); + qla24xx_copy_eft(ha, nxt); /* Chain entries -- started with MQ. */ nxt_chain = qla25xx_copy_fce(ha, nxt_chain, &last_chain); From 6ec6f9094a76aa9e732ede2add6cf32d0c2206e3 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Tue, 25 Jun 2013 11:27:28 -0400 Subject: [PATCH 0657/1048] [SCSI] qla2xxx: Help Coverity with analyzing ct_sns_pkt initialization. Coverity reports "Overrunning struct type ct_sns_req of 1228 bytes by passing it to a function which accesses it at byte offset 8207" for each qla2x00_prep_ct_req(), qla2x00_prep_ct_fdmi_req() and qla24xx_prep_ct_fm_req() call. Help Coverity to recognize that these calls do not trigger a buffer overflow by making it explicit that these three functions initializes both the request and reply structures. This patch does not change any functionality. Signed-off-by: Bart Van Assche Signed-off-by: Saurav Kashyap Signed-off-by: James Bottomley --- drivers/scsi/qla2xxx/qla_gs.c | 83 ++++++++++++++++------------------- 1 file changed, 39 insertions(+), 44 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_gs.c b/drivers/scsi/qla2xxx/qla_gs.c index f26442a73d1e..0926451980ed 100644 --- a/drivers/scsi/qla2xxx/qla_gs.c +++ b/drivers/scsi/qla2xxx/qla_gs.c @@ -99,17 +99,17 @@ qla24xx_prep_ms_iocb(scsi_qla_host_t *vha, uint32_t req_size, uint32_t rsp_size) * Returns a pointer to the intitialized @ct_req. */ static inline struct ct_sns_req * -qla2x00_prep_ct_req(struct ct_sns_req *ct_req, uint16_t cmd, uint16_t rsp_size) +qla2x00_prep_ct_req(struct ct_sns_pkt *p, uint16_t cmd, uint16_t rsp_size) { - memset(ct_req, 0, sizeof(struct ct_sns_pkt)); + memset(p, 0, sizeof(struct ct_sns_pkt)); - ct_req->header.revision = 0x01; - ct_req->header.gs_type = 0xFC; - ct_req->header.gs_subtype = 0x02; - ct_req->command = cpu_to_be16(cmd); - ct_req->max_rsp_size = cpu_to_be16((rsp_size - 16) / 4); + p->p.req.header.revision = 0x01; + p->p.req.header.gs_type = 0xFC; + p->p.req.header.gs_subtype = 0x02; + p->p.req.command = cpu_to_be16(cmd); + p->p.req.max_rsp_size = cpu_to_be16((rsp_size - 16) / 4); - return (ct_req); + return &p->p.req; } static int @@ -188,7 +188,7 @@ qla2x00_ga_nxt(scsi_qla_host_t *vha, fc_port_t *fcport) GA_NXT_RSP_SIZE); /* Prepare CT request */ - ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, GA_NXT_CMD, + ct_req = qla2x00_prep_ct_req(ha->ct_sns, GA_NXT_CMD, GA_NXT_RSP_SIZE); ct_rsp = &ha->ct_sns->p.rsp; @@ -284,8 +284,7 @@ qla2x00_gid_pt(scsi_qla_host_t *vha, sw_info_t *list) gid_pt_rsp_size); /* Prepare CT request */ - ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, GID_PT_CMD, - gid_pt_rsp_size); + ct_req = qla2x00_prep_ct_req(ha->ct_sns, GID_PT_CMD, gid_pt_rsp_size); ct_rsp = &ha->ct_sns->p.rsp; /* Prepare CT arguments -- port_type */ @@ -359,7 +358,7 @@ qla2x00_gpn_id(scsi_qla_host_t *vha, sw_info_t *list) GPN_ID_RSP_SIZE); /* Prepare CT request */ - ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, GPN_ID_CMD, + ct_req = qla2x00_prep_ct_req(ha->ct_sns, GPN_ID_CMD, GPN_ID_RSP_SIZE); ct_rsp = &ha->ct_sns->p.rsp; @@ -421,7 +420,7 @@ qla2x00_gnn_id(scsi_qla_host_t *vha, sw_info_t *list) GNN_ID_RSP_SIZE); /* Prepare CT request */ - ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, GNN_ID_CMD, + ct_req = qla2x00_prep_ct_req(ha->ct_sns, GNN_ID_CMD, GNN_ID_RSP_SIZE); ct_rsp = &ha->ct_sns->p.rsp; @@ -495,7 +494,7 @@ qla2x00_rft_id(scsi_qla_host_t *vha) RFT_ID_RSP_SIZE); /* Prepare CT request */ - ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, RFT_ID_CMD, + ct_req = qla2x00_prep_ct_req(ha->ct_sns, RFT_ID_CMD, RFT_ID_RSP_SIZE); ct_rsp = &ha->ct_sns->p.rsp; @@ -551,7 +550,7 @@ qla2x00_rff_id(scsi_qla_host_t *vha) RFF_ID_RSP_SIZE); /* Prepare CT request */ - ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, RFF_ID_CMD, + ct_req = qla2x00_prep_ct_req(ha->ct_sns, RFF_ID_CMD, RFF_ID_RSP_SIZE); ct_rsp = &ha->ct_sns->p.rsp; @@ -606,8 +605,7 @@ qla2x00_rnn_id(scsi_qla_host_t *vha) RNN_ID_RSP_SIZE); /* Prepare CT request */ - ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, RNN_ID_CMD, - RNN_ID_RSP_SIZE); + ct_req = qla2x00_prep_ct_req(ha->ct_sns, RNN_ID_CMD, RNN_ID_RSP_SIZE); ct_rsp = &ha->ct_sns->p.rsp; /* Prepare CT arguments -- port_id, node_name */ @@ -676,7 +674,7 @@ qla2x00_rsnn_nn(scsi_qla_host_t *vha) ms_pkt = ha->isp_ops->prep_ms_iocb(vha, 0, RSNN_NN_RSP_SIZE); /* Prepare CT request */ - ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, RSNN_NN_CMD, + ct_req = qla2x00_prep_ct_req(ha->ct_sns, RSNN_NN_CMD, RSNN_NN_RSP_SIZE); ct_rsp = &ha->ct_sns->p.rsp; @@ -1262,18 +1260,18 @@ qla2x00_update_ms_fdmi_iocb(scsi_qla_host_t *vha, uint32_t req_size) * Returns a pointer to the intitialized @ct_req. */ static inline struct ct_sns_req * -qla2x00_prep_ct_fdmi_req(struct ct_sns_req *ct_req, uint16_t cmd, +qla2x00_prep_ct_fdmi_req(struct ct_sns_pkt *p, uint16_t cmd, uint16_t rsp_size) { - memset(ct_req, 0, sizeof(struct ct_sns_pkt)); + memset(p, 0, sizeof(struct ct_sns_pkt)); - ct_req->header.revision = 0x01; - ct_req->header.gs_type = 0xFA; - ct_req->header.gs_subtype = 0x10; - ct_req->command = cpu_to_be16(cmd); - ct_req->max_rsp_size = cpu_to_be16((rsp_size - 16) / 4); + p->p.req.header.revision = 0x01; + p->p.req.header.gs_type = 0xFA; + p->p.req.header.gs_subtype = 0x10; + p->p.req.command = cpu_to_be16(cmd); + p->p.req.max_rsp_size = cpu_to_be16((rsp_size - 16) / 4); - return ct_req; + return &p->p.req; } /** @@ -1301,8 +1299,7 @@ qla2x00_fdmi_rhba(scsi_qla_host_t *vha) ms_pkt = ha->isp_ops->prep_ms_fdmi_iocb(vha, 0, RHBA_RSP_SIZE); /* Prepare CT request */ - ct_req = qla2x00_prep_ct_fdmi_req(&ha->ct_sns->p.req, RHBA_CMD, - RHBA_RSP_SIZE); + ct_req = qla2x00_prep_ct_fdmi_req(ha->ct_sns, RHBA_CMD, RHBA_RSP_SIZE); ct_rsp = &ha->ct_sns->p.rsp; /* Prepare FDMI command arguments -- attribute block, attributes. */ @@ -1490,8 +1487,7 @@ qla2x00_fdmi_dhba(scsi_qla_host_t *vha) DHBA_RSP_SIZE); /* Prepare CT request */ - ct_req = qla2x00_prep_ct_fdmi_req(&ha->ct_sns->p.req, DHBA_CMD, - DHBA_RSP_SIZE); + ct_req = qla2x00_prep_ct_fdmi_req(ha->ct_sns, DHBA_CMD, DHBA_RSP_SIZE); ct_rsp = &ha->ct_sns->p.rsp; /* Prepare FDMI command arguments -- portname. */ @@ -1547,8 +1543,7 @@ qla2x00_fdmi_rpa(scsi_qla_host_t *vha) ms_pkt = ha->isp_ops->prep_ms_fdmi_iocb(vha, 0, RPA_RSP_SIZE); /* Prepare CT request */ - ct_req = qla2x00_prep_ct_fdmi_req(&ha->ct_sns->p.req, RPA_CMD, - RPA_RSP_SIZE); + ct_req = qla2x00_prep_ct_fdmi_req(ha->ct_sns, RPA_CMD, RPA_RSP_SIZE); ct_rsp = &ha->ct_sns->p.rsp; /* Prepare FDMI command arguments -- attribute block, attributes. */ @@ -1775,7 +1770,7 @@ qla2x00_gfpn_id(scsi_qla_host_t *vha, sw_info_t *list) GFPN_ID_RSP_SIZE); /* Prepare CT request */ - ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, GFPN_ID_CMD, + ct_req = qla2x00_prep_ct_req(ha->ct_sns, GFPN_ID_CMD, GFPN_ID_RSP_SIZE); ct_rsp = &ha->ct_sns->p.rsp; @@ -1842,18 +1837,18 @@ qla24xx_prep_ms_fm_iocb(scsi_qla_host_t *vha, uint32_t req_size, static inline struct ct_sns_req * -qla24xx_prep_ct_fm_req(struct ct_sns_req *ct_req, uint16_t cmd, +qla24xx_prep_ct_fm_req(struct ct_sns_pkt *p, uint16_t cmd, uint16_t rsp_size) { - memset(ct_req, 0, sizeof(struct ct_sns_pkt)); + memset(p, 0, sizeof(struct ct_sns_pkt)); - ct_req->header.revision = 0x01; - ct_req->header.gs_type = 0xFA; - ct_req->header.gs_subtype = 0x01; - ct_req->command = cpu_to_be16(cmd); - ct_req->max_rsp_size = cpu_to_be16((rsp_size - 16) / 4); + p->p.req.header.revision = 0x01; + p->p.req.header.gs_type = 0xFA; + p->p.req.header.gs_subtype = 0x01; + p->p.req.command = cpu_to_be16(cmd); + p->p.req.max_rsp_size = cpu_to_be16((rsp_size - 16) / 4); - return ct_req; + return &p->p.req; } /** @@ -1889,8 +1884,8 @@ qla2x00_gpsc(scsi_qla_host_t *vha, sw_info_t *list) GPSC_RSP_SIZE); /* Prepare CT request */ - ct_req = qla24xx_prep_ct_fm_req(&ha->ct_sns->p.req, - GPSC_CMD, GPSC_RSP_SIZE); + ct_req = qla24xx_prep_ct_fm_req(ha->ct_sns, GPSC_CMD, + GPSC_RSP_SIZE); ct_rsp = &ha->ct_sns->p.rsp; /* Prepare CT arguments -- port_name */ @@ -2000,7 +1995,7 @@ qla2x00_gff_id(scsi_qla_host_t *vha, sw_info_t *list) GFF_ID_RSP_SIZE); /* Prepare CT request */ - ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, GFF_ID_CMD, + ct_req = qla2x00_prep_ct_req(ha->ct_sns, GFF_ID_CMD, GFF_ID_RSP_SIZE); ct_rsp = &ha->ct_sns->p.rsp; From b2ec76c5926438bda26b0e316246ae0e79bc810a Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Tue, 25 Jun 2013 11:27:29 -0400 Subject: [PATCH 0658/1048] [SCSI] qla2xxx: Fix qla2xxx_check_risc_status(). Change the 'rval' variable from QLA_FUNCTION_TIMEOUT into QLA_SUCCESS before starting a loop that is only executed if rval is initialized to QLA_SUCCESS. Coverity reported that loop as "dead code". Signed-off-by: Bart Van Assche Signed-off-by: Saurav Kashyap Signed-off-by: James Bottomley --- drivers/scsi/qla2xxx/qla_isr.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c index d2a4c75e5b8f..2d8e7b812352 100644 --- a/drivers/scsi/qla2xxx/qla_isr.c +++ b/drivers/scsi/qla2xxx/qla_isr.c @@ -2485,6 +2485,7 @@ qla2xxx_check_risc_status(scsi_qla_host_t *vha) if (rval == QLA_SUCCESS) goto next_test; + rval = QLA_SUCCESS; WRT_REG_DWORD(®->iobase_window, 0x0003); for (cnt = 100; (RD_REG_DWORD(®->iobase_window) & BIT_0) == 0 && rval == QLA_SUCCESS; cnt--) { From 6e97c9d5b85caaef9c2da7e410008df7e6d9d38a Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Tue, 25 Jun 2013 11:27:30 -0400 Subject: [PATCH 0659/1048] [SCSI] qla2xxx: Remove an unused variable from qla2x00_remove_one(). Signed-off-by: Bart Van Assche Signed-off-by: Saurav Kashyap Signed-off-by: James Bottomley --- drivers/scsi/qla2xxx/qla_os.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c index 6df5223888f8..3e21e9fc9d91 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c @@ -2979,14 +2979,12 @@ qla2x00_remove_one(struct pci_dev *pdev) set_bit(UNLOADING, &base_vha->dpc_flags); mutex_lock(&ha->vport_lock); while (ha->cur_vport_count) { - struct Scsi_Host *scsi_host; - spin_lock_irqsave(&ha->vport_slock, flags); BUG_ON(base_vha->list.next == &ha->vp_list); /* This assumes first entry in ha->vp_list is always base vha */ vha = list_first_entry(&base_vha->list, scsi_qla_host_t, list); - scsi_host = scsi_host_get(vha->host); + scsi_host_get(vha->host); spin_unlock_irqrestore(&ha->vport_slock, flags); mutex_unlock(&ha->vport_lock); From 8c0eb596baa51f2b43949c698c644727ef17805c Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Tue, 25 Jun 2013 11:27:31 -0400 Subject: [PATCH 0660/1048] [SCSI] qla2xxx: Fix a memory leak in an error path of qla2x00_process_els() Avoid that the fcport structure gets leaked if bsg_job->request->msgcode == FC_BSG_HST_ELS_NOLOGIN, the fcport allocation succeeds and the !vha->flags.online branch is taken. This was detected by Coverity. However, Coverity does not recognize that all qla2x00_process_els() callers specify either FC_BSG_RPT_ELS or FC_BSG_HST_ELS_NOLOGIN in the field bsg_job->request->msgcode and that the value of that field is not modified inside that function. This results in a false positive report about a possible memory leak in an error path for bsg_job->request->msgcode values other than the two mentioned values. Make it easy for Coverity (and for humans) to recognize that there is no fcport leak in the error path by changing the bsg_job->request->msgcode == FC_BSG_HST_ELS_NOLOGIN test into bsg_job->request->msgcode != FC_BSG_RPT_ELS. Signed-off-by: Bart Van Assche Signed-off-by: Saurav Kashyap Signed-off-by: James Bottomley --- drivers/scsi/qla2xxx/qla_bsg.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_bsg.c b/drivers/scsi/qla2xxx/qla_bsg.c index b85f0021db3b..417eaad50ae2 100644 --- a/drivers/scsi/qla2xxx/qla_bsg.c +++ b/drivers/scsi/qla2xxx/qla_bsg.c @@ -269,6 +269,12 @@ qla2x00_process_els(struct fc_bsg_job *bsg_job) type = "FC_BSG_HST_ELS_NOLOGIN"; } + if (!vha->flags.online) { + ql_log(ql_log_warn, vha, 0x7005, "Host not online.\n"); + rval = -EIO; + goto done; + } + /* pass through is supported only for ISP 4Gb or higher */ if (!IS_FWI2_CAPABLE(ha)) { ql_dbg(ql_dbg_user, vha, 0x7001, @@ -326,12 +332,6 @@ qla2x00_process_els(struct fc_bsg_job *bsg_job) NPH_FABRIC_CONTROLLER : NPH_F_PORT; } - if (!vha->flags.online) { - ql_log(ql_log_warn, vha, 0x7005, "Host not online.\n"); - rval = -EIO; - goto done; - } - req_sg_cnt = dma_map_sg(&ha->pdev->dev, bsg_job->request_payload.sg_list, bsg_job->request_payload.sg_cnt, DMA_TO_DEVICE); @@ -399,7 +399,7 @@ done_unmap_sg: goto done_free_fcport; done_free_fcport: - if (bsg_job->request->msgcode == FC_BSG_HST_ELS_NOLOGIN) + if (bsg_job->request->msgcode == FC_BSG_RPT_ELS) kfree(fcport); done: return rval; From e126ba97dba9edeb6fafa3665b5f8497fc9cdf8c Mon Sep 17 00:00:00 2001 From: Eli Cohen Date: Sun, 7 Jul 2013 17:25:49 +0300 Subject: [PATCH 0661/1048] mlx5: Add driver for Mellanox Connect-IB adapters The driver is comprised of two kernel modules: mlx5_ib and mlx5_core. This partitioning resembles what we have for mlx4, except that mlx5_ib is the pci device driver and not mlx5_core. mlx5_core is essentially a library that provides general functionality that is intended to be used by other Mellanox devices that will be introduced in the future. mlx5_ib has a similar role as any hardware device under drivers/infiniband/hw. Signed-off-by: Eli Cohen Signed-off-by: Jack Morgenstein Signed-off-by: Or Gerlitz [ Merge in coccinelle fixes from Fengguang Wu . - Roland ] Signed-off-by: Roland Dreier --- MAINTAINERS | 22 + drivers/infiniband/Kconfig | 1 + drivers/infiniband/Makefile | 1 + drivers/infiniband/hw/mlx5/Kconfig | 10 + drivers/infiniband/hw/mlx5/Makefile | 3 + drivers/infiniband/hw/mlx5/ah.c | 92 + drivers/infiniband/hw/mlx5/cq.c | 843 ++++++ drivers/infiniband/hw/mlx5/doorbell.c | 100 + drivers/infiniband/hw/mlx5/mad.c | 139 + drivers/infiniband/hw/mlx5/main.c | 1504 ++++++++++ drivers/infiniband/hw/mlx5/mem.c | 162 ++ drivers/infiniband/hw/mlx5/mlx5_ib.h | 545 ++++ drivers/infiniband/hw/mlx5/mr.c | 1007 +++++++ drivers/infiniband/hw/mlx5/qp.c | 2524 +++++++++++++++++ drivers/infiniband/hw/mlx5/srq.c | 473 +++ drivers/infiniband/hw/mlx5/user.h | 121 + drivers/net/ethernet/mellanox/Kconfig | 1 + drivers/net/ethernet/mellanox/Makefile | 1 + .../net/ethernet/mellanox/mlx5/core/Kconfig | 18 + .../net/ethernet/mellanox/mlx5/core/Makefile | 5 + .../net/ethernet/mellanox/mlx5/core/alloc.c | 238 ++ drivers/net/ethernet/mellanox/mlx5/core/cmd.c | 1515 ++++++++++ drivers/net/ethernet/mellanox/mlx5/core/cq.c | 224 ++ .../net/ethernet/mellanox/mlx5/core/debugfs.c | 587 ++++ drivers/net/ethernet/mellanox/mlx5/core/eq.c | 521 ++++ drivers/net/ethernet/mellanox/mlx5/core/fw.c | 185 ++ .../net/ethernet/mellanox/mlx5/core/health.c | 217 ++ drivers/net/ethernet/mellanox/mlx5/core/mad.c | 78 + .../net/ethernet/mellanox/mlx5/core/main.c | 475 ++++ drivers/net/ethernet/mellanox/mlx5/core/mcg.c | 106 + .../ethernet/mellanox/mlx5/core/mlx5_core.h | 73 + drivers/net/ethernet/mellanox/mlx5/core/mr.c | 136 + .../ethernet/mellanox/mlx5/core/pagealloc.c | 435 +++ drivers/net/ethernet/mellanox/mlx5/core/pd.c | 101 + .../net/ethernet/mellanox/mlx5/core/port.c | 104 + drivers/net/ethernet/mellanox/mlx5/core/qp.c | 301 ++ drivers/net/ethernet/mellanox/mlx5/core/srq.c | 223 ++ drivers/net/ethernet/mellanox/mlx5/core/uar.c | 223 ++ include/linux/mlx5/cmd.h | 51 + include/linux/mlx5/cq.h | 165 ++ include/linux/mlx5/device.h | 893 ++++++ include/linux/mlx5/doorbell.h | 79 + include/linux/mlx5/driver.h | 769 +++++ include/linux/mlx5/qp.h | 467 +++ include/linux/mlx5/srq.h | 41 + 45 files changed, 15779 insertions(+) create mode 100644 drivers/infiniband/hw/mlx5/Kconfig create mode 100644 drivers/infiniband/hw/mlx5/Makefile create mode 100644 drivers/infiniband/hw/mlx5/ah.c create mode 100644 drivers/infiniband/hw/mlx5/cq.c create mode 100644 drivers/infiniband/hw/mlx5/doorbell.c create mode 100644 drivers/infiniband/hw/mlx5/mad.c create mode 100644 drivers/infiniband/hw/mlx5/main.c create mode 100644 drivers/infiniband/hw/mlx5/mem.c create mode 100644 drivers/infiniband/hw/mlx5/mlx5_ib.h create mode 100644 drivers/infiniband/hw/mlx5/mr.c create mode 100644 drivers/infiniband/hw/mlx5/qp.c create mode 100644 drivers/infiniband/hw/mlx5/srq.c create mode 100644 drivers/infiniband/hw/mlx5/user.h create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/Kconfig create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/Makefile create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/alloc.c create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/cmd.c create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/cq.c create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/debugfs.c create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/eq.c create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/fw.c create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/health.c create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/mad.c create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/main.c create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/mcg.c create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/mr.c create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/pd.c create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/port.c create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/qp.c create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/srq.c create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/uar.c create mode 100644 include/linux/mlx5/cmd.h create mode 100644 include/linux/mlx5/cq.h create mode 100644 include/linux/mlx5/device.h create mode 100644 include/linux/mlx5/doorbell.h create mode 100644 include/linux/mlx5/driver.h create mode 100644 include/linux/mlx5/qp.h create mode 100644 include/linux/mlx5/srq.h diff --git a/MAINTAINERS b/MAINTAINERS index 60d6a3393500..b4265364ed27 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -5365,6 +5365,28 @@ W: http://linuxtv.org S: Odd Fixes F: drivers/media/radio/radio-miropcm20* +Mellanox MLX5 core VPI driver +M: Eli Cohen +L: netdev@vger.kernel.org +L: linux-rdma@vger.kernel.org +W: http://www.mellanox.com +Q: http://patchwork.ozlabs.org/project/netdev/list/ +Q: http://patchwork.kernel.org/project/linux-rdma/list/ +T: git://openfabrics.org/~eli/connect-ib.git +S: Supported +F: drivers/net/ethernet/mellanox/mlx5/core/ +F: include/linux/mlx5/ + +Mellanox MLX5 IB driver +M: Eli Cohen +L: linux-rdma@vger.kernel.org +W: http://www.mellanox.com +Q: http://patchwork.kernel.org/project/linux-rdma/list/ +T: git://openfabrics.org/~eli/connect-ib.git +S: Supported +F: include/linux/mlx5/ +F: drivers/infiniband/hw/mlx5/ + MODULE SUPPORT M: Rusty Russell S: Maintained diff --git a/drivers/infiniband/Kconfig b/drivers/infiniband/Kconfig index c85b56c28099..5ceda710f516 100644 --- a/drivers/infiniband/Kconfig +++ b/drivers/infiniband/Kconfig @@ -50,6 +50,7 @@ source "drivers/infiniband/hw/amso1100/Kconfig" source "drivers/infiniband/hw/cxgb3/Kconfig" source "drivers/infiniband/hw/cxgb4/Kconfig" source "drivers/infiniband/hw/mlx4/Kconfig" +source "drivers/infiniband/hw/mlx5/Kconfig" source "drivers/infiniband/hw/nes/Kconfig" source "drivers/infiniband/hw/ocrdma/Kconfig" diff --git a/drivers/infiniband/Makefile b/drivers/infiniband/Makefile index b126fefe0b1c..1fe69888515f 100644 --- a/drivers/infiniband/Makefile +++ b/drivers/infiniband/Makefile @@ -7,6 +7,7 @@ obj-$(CONFIG_INFINIBAND_AMSO1100) += hw/amso1100/ obj-$(CONFIG_INFINIBAND_CXGB3) += hw/cxgb3/ obj-$(CONFIG_INFINIBAND_CXGB4) += hw/cxgb4/ obj-$(CONFIG_MLX4_INFINIBAND) += hw/mlx4/ +obj-$(CONFIG_MLX5_INFINIBAND) += hw/mlx5/ obj-$(CONFIG_INFINIBAND_NES) += hw/nes/ obj-$(CONFIG_INFINIBAND_OCRDMA) += hw/ocrdma/ obj-$(CONFIG_INFINIBAND_IPOIB) += ulp/ipoib/ diff --git a/drivers/infiniband/hw/mlx5/Kconfig b/drivers/infiniband/hw/mlx5/Kconfig new file mode 100644 index 000000000000..8e6aebfaf8a4 --- /dev/null +++ b/drivers/infiniband/hw/mlx5/Kconfig @@ -0,0 +1,10 @@ +config MLX5_INFINIBAND + tristate "Mellanox Connect-IB HCA support" + depends on NETDEVICES && ETHERNET && PCI && X86 + select NET_VENDOR_MELLANOX + select MLX5_CORE + ---help--- + This driver provides low-level InfiniBand support for + Mellanox Connect-IB PCI Express host channel adapters (HCAs). + This is required to use InfiniBand protocols such as + IP-over-IB or SRP with these devices. diff --git a/drivers/infiniband/hw/mlx5/Makefile b/drivers/infiniband/hw/mlx5/Makefile new file mode 100644 index 000000000000..4ea0135af484 --- /dev/null +++ b/drivers/infiniband/hw/mlx5/Makefile @@ -0,0 +1,3 @@ +obj-$(CONFIG_MLX5_INFINIBAND) += mlx5_ib.o + +mlx5_ib-y := main.o cq.o doorbell.o qp.o mem.o srq.o mr.o ah.o mad.o diff --git a/drivers/infiniband/hw/mlx5/ah.c b/drivers/infiniband/hw/mlx5/ah.c new file mode 100644 index 000000000000..39ab0caefdf9 --- /dev/null +++ b/drivers/infiniband/hw/mlx5/ah.c @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2013, Mellanox Technologies inc. All rights reserved. + * + * This software is available to you under a choice of one of two + * licenses. You may choose to be licensed under the terms of the GNU + * General Public License (GPL) Version 2, available from the file + * COPYING in the main directory of this source tree, or the + * OpenIB.org BSD license below: + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include "mlx5_ib.h" + +struct ib_ah *create_ib_ah(struct ib_ah_attr *ah_attr, + struct mlx5_ib_ah *ah) +{ + if (ah_attr->ah_flags & IB_AH_GRH) { + memcpy(ah->av.rgid, &ah_attr->grh.dgid, 16); + ah->av.grh_gid_fl = cpu_to_be32(ah_attr->grh.flow_label | + (1 << 30) | + ah_attr->grh.sgid_index << 20); + ah->av.hop_limit = ah_attr->grh.hop_limit; + ah->av.tclass = ah_attr->grh.traffic_class; + } + + ah->av.rlid = cpu_to_be16(ah_attr->dlid); + ah->av.fl_mlid = ah_attr->src_path_bits & 0x7f; + ah->av.stat_rate_sl = (ah_attr->static_rate << 4) | (ah_attr->sl & 0xf); + + return &ah->ibah; +} + +struct ib_ah *mlx5_ib_create_ah(struct ib_pd *pd, struct ib_ah_attr *ah_attr) +{ + struct mlx5_ib_ah *ah; + + ah = kzalloc(sizeof(*ah), GFP_ATOMIC); + if (!ah) + return ERR_PTR(-ENOMEM); + + return create_ib_ah(ah_attr, ah); /* never fails */ +} + +int mlx5_ib_query_ah(struct ib_ah *ibah, struct ib_ah_attr *ah_attr) +{ + struct mlx5_ib_ah *ah = to_mah(ibah); + u32 tmp; + + memset(ah_attr, 0, sizeof(*ah_attr)); + + tmp = be32_to_cpu(ah->av.grh_gid_fl); + if (tmp & (1 << 30)) { + ah_attr->ah_flags = IB_AH_GRH; + ah_attr->grh.sgid_index = (tmp >> 20) & 0xff; + ah_attr->grh.flow_label = tmp & 0xfffff; + memcpy(&ah_attr->grh.dgid, ah->av.rgid, 16); + ah_attr->grh.hop_limit = ah->av.hop_limit; + ah_attr->grh.traffic_class = ah->av.tclass; + } + ah_attr->dlid = be16_to_cpu(ah->av.rlid); + ah_attr->static_rate = ah->av.stat_rate_sl >> 4; + ah_attr->sl = ah->av.stat_rate_sl & 0xf; + + return 0; +} + +int mlx5_ib_destroy_ah(struct ib_ah *ah) +{ + kfree(to_mah(ah)); + return 0; +} diff --git a/drivers/infiniband/hw/mlx5/cq.c b/drivers/infiniband/hw/mlx5/cq.c new file mode 100644 index 000000000000..344ab03948a3 --- /dev/null +++ b/drivers/infiniband/hw/mlx5/cq.c @@ -0,0 +1,843 @@ +/* + * Copyright (c) 2013, Mellanox Technologies inc. All rights reserved. + * + * This software is available to you under a choice of one of two + * licenses. You may choose to be licensed under the terms of the GNU + * General Public License (GPL) Version 2, available from the file + * COPYING in the main directory of this source tree, or the + * OpenIB.org BSD license below: + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include +#include +#include "mlx5_ib.h" +#include "user.h" + +static void mlx5_ib_cq_comp(struct mlx5_core_cq *cq) +{ + struct ib_cq *ibcq = &to_mibcq(cq)->ibcq; + + ibcq->comp_handler(ibcq, ibcq->cq_context); +} + +static void mlx5_ib_cq_event(struct mlx5_core_cq *mcq, enum mlx5_event type) +{ + struct mlx5_ib_cq *cq = container_of(mcq, struct mlx5_ib_cq, mcq); + struct mlx5_ib_dev *dev = to_mdev(cq->ibcq.device); + struct ib_cq *ibcq = &cq->ibcq; + struct ib_event event; + + if (type != MLX5_EVENT_TYPE_CQ_ERROR) { + mlx5_ib_warn(dev, "Unexpected event type %d on CQ %06x\n", + type, mcq->cqn); + return; + } + + if (ibcq->event_handler) { + event.device = &dev->ib_dev; + event.event = IB_EVENT_CQ_ERR; + event.element.cq = ibcq; + ibcq->event_handler(&event, ibcq->cq_context); + } +} + +static void *get_cqe_from_buf(struct mlx5_ib_cq_buf *buf, int n, int size) +{ + return mlx5_buf_offset(&buf->buf, n * size); +} + +static void *get_cqe(struct mlx5_ib_cq *cq, int n) +{ + return get_cqe_from_buf(&cq->buf, n, cq->mcq.cqe_sz); +} + +static void *get_sw_cqe(struct mlx5_ib_cq *cq, int n) +{ + void *cqe = get_cqe(cq, n & cq->ibcq.cqe); + struct mlx5_cqe64 *cqe64; + + cqe64 = (cq->mcq.cqe_sz == 64) ? cqe : cqe + 64; + return ((cqe64->op_own & MLX5_CQE_OWNER_MASK) ^ + !!(n & (cq->ibcq.cqe + 1))) ? NULL : cqe; +} + +static void *next_cqe_sw(struct mlx5_ib_cq *cq) +{ + return get_sw_cqe(cq, cq->mcq.cons_index); +} + +static enum ib_wc_opcode get_umr_comp(struct mlx5_ib_wq *wq, int idx) +{ + switch (wq->wr_data[idx]) { + case MLX5_IB_WR_UMR: + return 0; + + case IB_WR_LOCAL_INV: + return IB_WC_LOCAL_INV; + + case IB_WR_FAST_REG_MR: + return IB_WC_FAST_REG_MR; + + default: + pr_warn("unknown completion status\n"); + return 0; + } +} + +static void handle_good_req(struct ib_wc *wc, struct mlx5_cqe64 *cqe, + struct mlx5_ib_wq *wq, int idx) +{ + wc->wc_flags = 0; + switch (be32_to_cpu(cqe->sop_drop_qpn) >> 24) { + case MLX5_OPCODE_RDMA_WRITE_IMM: + wc->wc_flags |= IB_WC_WITH_IMM; + case MLX5_OPCODE_RDMA_WRITE: + wc->opcode = IB_WC_RDMA_WRITE; + break; + case MLX5_OPCODE_SEND_IMM: + wc->wc_flags |= IB_WC_WITH_IMM; + case MLX5_OPCODE_SEND: + case MLX5_OPCODE_SEND_INVAL: + wc->opcode = IB_WC_SEND; + break; + case MLX5_OPCODE_RDMA_READ: + wc->opcode = IB_WC_RDMA_READ; + wc->byte_len = be32_to_cpu(cqe->byte_cnt); + break; + case MLX5_OPCODE_ATOMIC_CS: + wc->opcode = IB_WC_COMP_SWAP; + wc->byte_len = 8; + break; + case MLX5_OPCODE_ATOMIC_FA: + wc->opcode = IB_WC_FETCH_ADD; + wc->byte_len = 8; + break; + case MLX5_OPCODE_ATOMIC_MASKED_CS: + wc->opcode = IB_WC_MASKED_COMP_SWAP; + wc->byte_len = 8; + break; + case MLX5_OPCODE_ATOMIC_MASKED_FA: + wc->opcode = IB_WC_MASKED_FETCH_ADD; + wc->byte_len = 8; + break; + case MLX5_OPCODE_BIND_MW: + wc->opcode = IB_WC_BIND_MW; + break; + case MLX5_OPCODE_UMR: + wc->opcode = get_umr_comp(wq, idx); + break; + } +} + +enum { + MLX5_GRH_IN_BUFFER = 1, + MLX5_GRH_IN_CQE = 2, +}; + +static void handle_responder(struct ib_wc *wc, struct mlx5_cqe64 *cqe, + struct mlx5_ib_qp *qp) +{ + struct mlx5_ib_dev *dev = to_mdev(qp->ibqp.device); + struct mlx5_ib_srq *srq; + struct mlx5_ib_wq *wq; + u16 wqe_ctr; + u8 g; + + if (qp->ibqp.srq || qp->ibqp.xrcd) { + struct mlx5_core_srq *msrq = NULL; + + if (qp->ibqp.xrcd) { + msrq = mlx5_core_get_srq(&dev->mdev, + be32_to_cpu(cqe->srqn)); + srq = to_mibsrq(msrq); + } else { + srq = to_msrq(qp->ibqp.srq); + } + if (srq) { + wqe_ctr = be16_to_cpu(cqe->wqe_counter); + wc->wr_id = srq->wrid[wqe_ctr]; + mlx5_ib_free_srq_wqe(srq, wqe_ctr); + if (msrq && atomic_dec_and_test(&msrq->refcount)) + complete(&msrq->free); + } + } else { + wq = &qp->rq; + wc->wr_id = wq->wrid[wq->tail & (wq->wqe_cnt - 1)]; + ++wq->tail; + } + wc->byte_len = be32_to_cpu(cqe->byte_cnt); + + switch (cqe->op_own >> 4) { + case MLX5_CQE_RESP_WR_IMM: + wc->opcode = IB_WC_RECV_RDMA_WITH_IMM; + wc->wc_flags = IB_WC_WITH_IMM; + wc->ex.imm_data = cqe->imm_inval_pkey; + break; + case MLX5_CQE_RESP_SEND: + wc->opcode = IB_WC_RECV; + wc->wc_flags = 0; + break; + case MLX5_CQE_RESP_SEND_IMM: + wc->opcode = IB_WC_RECV; + wc->wc_flags = IB_WC_WITH_IMM; + wc->ex.imm_data = cqe->imm_inval_pkey; + break; + case MLX5_CQE_RESP_SEND_INV: + wc->opcode = IB_WC_RECV; + wc->wc_flags = IB_WC_WITH_INVALIDATE; + wc->ex.invalidate_rkey = be32_to_cpu(cqe->imm_inval_pkey); + break; + } + wc->slid = be16_to_cpu(cqe->slid); + wc->sl = (be32_to_cpu(cqe->flags_rqpn) >> 24) & 0xf; + wc->src_qp = be32_to_cpu(cqe->flags_rqpn) & 0xffffff; + wc->dlid_path_bits = cqe->ml_path; + g = (be32_to_cpu(cqe->flags_rqpn) >> 28) & 3; + wc->wc_flags |= g ? IB_WC_GRH : 0; + wc->pkey_index = be32_to_cpu(cqe->imm_inval_pkey) & 0xffff; +} + +static void dump_cqe(struct mlx5_ib_dev *dev, struct mlx5_err_cqe *cqe) +{ + __be32 *p = (__be32 *)cqe; + int i; + + mlx5_ib_warn(dev, "dump error cqe\n"); + for (i = 0; i < sizeof(*cqe) / 16; i++, p += 4) + pr_info("%08x %08x %08x %08x\n", be32_to_cpu(p[0]), + be32_to_cpu(p[1]), be32_to_cpu(p[2]), + be32_to_cpu(p[3])); +} + +static void mlx5_handle_error_cqe(struct mlx5_ib_dev *dev, + struct mlx5_err_cqe *cqe, + struct ib_wc *wc) +{ + int dump = 1; + + switch (cqe->syndrome) { + case MLX5_CQE_SYNDROME_LOCAL_LENGTH_ERR: + wc->status = IB_WC_LOC_LEN_ERR; + break; + case MLX5_CQE_SYNDROME_LOCAL_QP_OP_ERR: + wc->status = IB_WC_LOC_QP_OP_ERR; + break; + case MLX5_CQE_SYNDROME_LOCAL_PROT_ERR: + wc->status = IB_WC_LOC_PROT_ERR; + break; + case MLX5_CQE_SYNDROME_WR_FLUSH_ERR: + dump = 0; + wc->status = IB_WC_WR_FLUSH_ERR; + break; + case MLX5_CQE_SYNDROME_MW_BIND_ERR: + wc->status = IB_WC_MW_BIND_ERR; + break; + case MLX5_CQE_SYNDROME_BAD_RESP_ERR: + wc->status = IB_WC_BAD_RESP_ERR; + break; + case MLX5_CQE_SYNDROME_LOCAL_ACCESS_ERR: + wc->status = IB_WC_LOC_ACCESS_ERR; + break; + case MLX5_CQE_SYNDROME_REMOTE_INVAL_REQ_ERR: + wc->status = IB_WC_REM_INV_REQ_ERR; + break; + case MLX5_CQE_SYNDROME_REMOTE_ACCESS_ERR: + wc->status = IB_WC_REM_ACCESS_ERR; + break; + case MLX5_CQE_SYNDROME_REMOTE_OP_ERR: + wc->status = IB_WC_REM_OP_ERR; + break; + case MLX5_CQE_SYNDROME_TRANSPORT_RETRY_EXC_ERR: + wc->status = IB_WC_RETRY_EXC_ERR; + dump = 0; + break; + case MLX5_CQE_SYNDROME_RNR_RETRY_EXC_ERR: + wc->status = IB_WC_RNR_RETRY_EXC_ERR; + dump = 0; + break; + case MLX5_CQE_SYNDROME_REMOTE_ABORTED_ERR: + wc->status = IB_WC_REM_ABORT_ERR; + break; + default: + wc->status = IB_WC_GENERAL_ERR; + break; + } + + wc->vendor_err = cqe->vendor_err_synd; + if (dump) + dump_cqe(dev, cqe); +} + +static int is_atomic_response(struct mlx5_ib_qp *qp, uint16_t idx) +{ + /* TBD: waiting decision + */ + return 0; +} + +static void *mlx5_get_atomic_laddr(struct mlx5_ib_qp *qp, uint16_t idx) +{ + struct mlx5_wqe_data_seg *dpseg; + void *addr; + + dpseg = mlx5_get_send_wqe(qp, idx) + sizeof(struct mlx5_wqe_ctrl_seg) + + sizeof(struct mlx5_wqe_raddr_seg) + + sizeof(struct mlx5_wqe_atomic_seg); + addr = (void *)(unsigned long)be64_to_cpu(dpseg->addr); + return addr; +} + +static void handle_atomic(struct mlx5_ib_qp *qp, struct mlx5_cqe64 *cqe64, + uint16_t idx) +{ + void *addr; + int byte_count; + int i; + + if (!is_atomic_response(qp, idx)) + return; + + byte_count = be32_to_cpu(cqe64->byte_cnt); + addr = mlx5_get_atomic_laddr(qp, idx); + + if (byte_count == 4) { + *(uint32_t *)addr = be32_to_cpu(*((__be32 *)addr)); + } else { + for (i = 0; i < byte_count; i += 8) { + *(uint64_t *)addr = be64_to_cpu(*((__be64 *)addr)); + addr += 8; + } + } + + return; +} + +static void handle_atomics(struct mlx5_ib_qp *qp, struct mlx5_cqe64 *cqe64, + u16 tail, u16 head) +{ + int idx; + + do { + idx = tail & (qp->sq.wqe_cnt - 1); + handle_atomic(qp, cqe64, idx); + if (idx == head) + break; + + tail = qp->sq.w_list[idx].next; + } while (1); + tail = qp->sq.w_list[idx].next; + qp->sq.last_poll = tail; +} + +static int mlx5_poll_one(struct mlx5_ib_cq *cq, + struct mlx5_ib_qp **cur_qp, + struct ib_wc *wc) +{ + struct mlx5_ib_dev *dev = to_mdev(cq->ibcq.device); + struct mlx5_err_cqe *err_cqe; + struct mlx5_cqe64 *cqe64; + struct mlx5_core_qp *mqp; + struct mlx5_ib_wq *wq; + uint8_t opcode; + uint32_t qpn; + u16 wqe_ctr; + void *cqe; + int idx; + + cqe = next_cqe_sw(cq); + if (!cqe) + return -EAGAIN; + + cqe64 = (cq->mcq.cqe_sz == 64) ? cqe : cqe + 64; + + ++cq->mcq.cons_index; + + /* Make sure we read CQ entry contents after we've checked the + * ownership bit. + */ + rmb(); + + /* TBD: resize CQ */ + + qpn = ntohl(cqe64->sop_drop_qpn) & 0xffffff; + if (!*cur_qp || (qpn != (*cur_qp)->ibqp.qp_num)) { + /* We do not have to take the QP table lock here, + * because CQs will be locked while QPs are removed + * from the table. + */ + mqp = __mlx5_qp_lookup(&dev->mdev, qpn); + if (unlikely(!mqp)) { + mlx5_ib_warn(dev, "CQE@CQ %06x for unknown QPN %6x\n", + cq->mcq.cqn, qpn); + return -EINVAL; + } + + *cur_qp = to_mibqp(mqp); + } + + wc->qp = &(*cur_qp)->ibqp; + opcode = cqe64->op_own >> 4; + switch (opcode) { + case MLX5_CQE_REQ: + wq = &(*cur_qp)->sq; + wqe_ctr = be16_to_cpu(cqe64->wqe_counter); + idx = wqe_ctr & (wq->wqe_cnt - 1); + handle_good_req(wc, cqe64, wq, idx); + handle_atomics(*cur_qp, cqe64, wq->last_poll, idx); + wc->wr_id = wq->wrid[idx]; + wq->tail = wq->wqe_head[idx] + 1; + wc->status = IB_WC_SUCCESS; + break; + case MLX5_CQE_RESP_WR_IMM: + case MLX5_CQE_RESP_SEND: + case MLX5_CQE_RESP_SEND_IMM: + case MLX5_CQE_RESP_SEND_INV: + handle_responder(wc, cqe64, *cur_qp); + wc->status = IB_WC_SUCCESS; + break; + case MLX5_CQE_RESIZE_CQ: + break; + case MLX5_CQE_REQ_ERR: + case MLX5_CQE_RESP_ERR: + err_cqe = (struct mlx5_err_cqe *)cqe64; + mlx5_handle_error_cqe(dev, err_cqe, wc); + mlx5_ib_dbg(dev, "%s error cqe on cqn 0x%x:\n", + opcode == MLX5_CQE_REQ_ERR ? + "Requestor" : "Responder", cq->mcq.cqn); + mlx5_ib_dbg(dev, "syndrome 0x%x, vendor syndrome 0x%x\n", + err_cqe->syndrome, err_cqe->vendor_err_synd); + if (opcode == MLX5_CQE_REQ_ERR) { + wq = &(*cur_qp)->sq; + wqe_ctr = be16_to_cpu(cqe64->wqe_counter); + idx = wqe_ctr & (wq->wqe_cnt - 1); + wc->wr_id = wq->wrid[idx]; + wq->tail = wq->wqe_head[idx] + 1; + } else { + struct mlx5_ib_srq *srq; + + if ((*cur_qp)->ibqp.srq) { + srq = to_msrq((*cur_qp)->ibqp.srq); + wqe_ctr = be16_to_cpu(cqe64->wqe_counter); + wc->wr_id = srq->wrid[wqe_ctr]; + mlx5_ib_free_srq_wqe(srq, wqe_ctr); + } else { + wq = &(*cur_qp)->rq; + wc->wr_id = wq->wrid[wq->tail & (wq->wqe_cnt - 1)]; + ++wq->tail; + } + } + break; + } + + return 0; +} + +int mlx5_ib_poll_cq(struct ib_cq *ibcq, int num_entries, struct ib_wc *wc) +{ + struct mlx5_ib_cq *cq = to_mcq(ibcq); + struct mlx5_ib_qp *cur_qp = NULL; + unsigned long flags; + int npolled; + int err = 0; + + spin_lock_irqsave(&cq->lock, flags); + + for (npolled = 0; npolled < num_entries; npolled++) { + err = mlx5_poll_one(cq, &cur_qp, wc + npolled); + if (err) + break; + } + + if (npolled) + mlx5_cq_set_ci(&cq->mcq); + + spin_unlock_irqrestore(&cq->lock, flags); + + if (err == 0 || err == -EAGAIN) + return npolled; + else + return err; +} + +int mlx5_ib_arm_cq(struct ib_cq *ibcq, enum ib_cq_notify_flags flags) +{ + mlx5_cq_arm(&to_mcq(ibcq)->mcq, + (flags & IB_CQ_SOLICITED_MASK) == IB_CQ_SOLICITED ? + MLX5_CQ_DB_REQ_NOT_SOL : MLX5_CQ_DB_REQ_NOT, + to_mdev(ibcq->device)->mdev.priv.uuari.uars[0].map, + MLX5_GET_DOORBELL_LOCK(&to_mdev(ibcq->device)->mdev.priv.cq_uar_lock)); + + return 0; +} + +static int alloc_cq_buf(struct mlx5_ib_dev *dev, struct mlx5_ib_cq_buf *buf, + int nent, int cqe_size) +{ + int err; + + err = mlx5_buf_alloc(&dev->mdev, nent * cqe_size, + PAGE_SIZE * 2, &buf->buf); + if (err) + return err; + + buf->cqe_size = cqe_size; + + return 0; +} + +static void free_cq_buf(struct mlx5_ib_dev *dev, struct mlx5_ib_cq_buf *buf) +{ + mlx5_buf_free(&dev->mdev, &buf->buf); +} + +static int create_cq_user(struct mlx5_ib_dev *dev, struct ib_udata *udata, + struct ib_ucontext *context, struct mlx5_ib_cq *cq, + int entries, struct mlx5_create_cq_mbox_in **cqb, + int *cqe_size, int *index, int *inlen) +{ + struct mlx5_ib_create_cq ucmd; + int page_shift; + int npages; + int ncont; + int err; + + if (ib_copy_from_udata(&ucmd, udata, sizeof(ucmd))) + return -EFAULT; + + if (ucmd.cqe_size != 64 && ucmd.cqe_size != 128) + return -EINVAL; + + *cqe_size = ucmd.cqe_size; + + cq->buf.umem = ib_umem_get(context, ucmd.buf_addr, + entries * ucmd.cqe_size, + IB_ACCESS_LOCAL_WRITE, 1); + if (IS_ERR(cq->buf.umem)) { + err = PTR_ERR(cq->buf.umem); + return err; + } + + err = mlx5_ib_db_map_user(to_mucontext(context), ucmd.db_addr, + &cq->db); + if (err) + goto err_umem; + + mlx5_ib_cont_pages(cq->buf.umem, ucmd.buf_addr, &npages, &page_shift, + &ncont, NULL); + mlx5_ib_dbg(dev, "addr 0x%llx, size %u, npages %d, page_shift %d, ncont %d\n", + ucmd.buf_addr, entries * ucmd.cqe_size, npages, page_shift, ncont); + + *inlen = sizeof(**cqb) + sizeof(*(*cqb)->pas) * ncont; + *cqb = mlx5_vzalloc(*inlen); + if (!*cqb) { + err = -ENOMEM; + goto err_db; + } + mlx5_ib_populate_pas(dev, cq->buf.umem, page_shift, (*cqb)->pas, 0); + (*cqb)->ctx.log_pg_sz = page_shift - PAGE_SHIFT; + + *index = to_mucontext(context)->uuari.uars[0].index; + + return 0; + +err_db: + mlx5_ib_db_unmap_user(to_mucontext(context), &cq->db); + +err_umem: + ib_umem_release(cq->buf.umem); + return err; +} + +static void destroy_cq_user(struct mlx5_ib_cq *cq, struct ib_ucontext *context) +{ + mlx5_ib_db_unmap_user(to_mucontext(context), &cq->db); + ib_umem_release(cq->buf.umem); +} + +static void init_cq_buf(struct mlx5_ib_cq *cq, int nent) +{ + int i; + void *cqe; + struct mlx5_cqe64 *cqe64; + + for (i = 0; i < nent; i++) { + cqe = get_cqe(cq, i); + cqe64 = (cq->buf.cqe_size == 64) ? cqe : cqe + 64; + cqe64->op_own = 0xf1; + } +} + +static int create_cq_kernel(struct mlx5_ib_dev *dev, struct mlx5_ib_cq *cq, + int entries, int cqe_size, + struct mlx5_create_cq_mbox_in **cqb, + int *index, int *inlen) +{ + int err; + + err = mlx5_db_alloc(&dev->mdev, &cq->db); + if (err) + return err; + + cq->mcq.set_ci_db = cq->db.db; + cq->mcq.arm_db = cq->db.db + 1; + *cq->mcq.set_ci_db = 0; + *cq->mcq.arm_db = 0; + cq->mcq.cqe_sz = cqe_size; + + err = alloc_cq_buf(dev, &cq->buf, entries, cqe_size); + if (err) + goto err_db; + + init_cq_buf(cq, entries); + + *inlen = sizeof(**cqb) + sizeof(*(*cqb)->pas) * cq->buf.buf.npages; + *cqb = mlx5_vzalloc(*inlen); + if (!*cqb) { + err = -ENOMEM; + goto err_buf; + } + mlx5_fill_page_array(&cq->buf.buf, (*cqb)->pas); + + (*cqb)->ctx.log_pg_sz = cq->buf.buf.page_shift - PAGE_SHIFT; + *index = dev->mdev.priv.uuari.uars[0].index; + + return 0; + +err_buf: + free_cq_buf(dev, &cq->buf); + +err_db: + mlx5_db_free(&dev->mdev, &cq->db); + return err; +} + +static void destroy_cq_kernel(struct mlx5_ib_dev *dev, struct mlx5_ib_cq *cq) +{ + free_cq_buf(dev, &cq->buf); + mlx5_db_free(&dev->mdev, &cq->db); +} + +struct ib_cq *mlx5_ib_create_cq(struct ib_device *ibdev, int entries, + int vector, struct ib_ucontext *context, + struct ib_udata *udata) +{ + struct mlx5_create_cq_mbox_in *cqb = NULL; + struct mlx5_ib_dev *dev = to_mdev(ibdev); + struct mlx5_ib_cq *cq; + int uninitialized_var(index); + int uninitialized_var(inlen); + int cqe_size; + int irqn; + int eqn; + int err; + + entries = roundup_pow_of_two(entries + 1); + if (entries < 1 || entries > dev->mdev.caps.max_cqes) + return ERR_PTR(-EINVAL); + + cq = kzalloc(sizeof(*cq), GFP_KERNEL); + if (!cq) + return ERR_PTR(-ENOMEM); + + cq->ibcq.cqe = entries - 1; + mutex_init(&cq->resize_mutex); + spin_lock_init(&cq->lock); + cq->resize_buf = NULL; + cq->resize_umem = NULL; + + if (context) { + err = create_cq_user(dev, udata, context, cq, entries, + &cqb, &cqe_size, &index, &inlen); + if (err) + goto err_create; + } else { + /* for now choose 64 bytes till we have a proper interface */ + cqe_size = 64; + err = create_cq_kernel(dev, cq, entries, cqe_size, &cqb, + &index, &inlen); + if (err) + goto err_create; + } + + cq->cqe_size = cqe_size; + cqb->ctx.cqe_sz_flags = cqe_sz_to_mlx_sz(cqe_size) << 5; + cqb->ctx.log_sz_usr_page = cpu_to_be32((ilog2(entries) << 24) | index); + err = mlx5_vector2eqn(dev, vector, &eqn, &irqn); + if (err) + goto err_cqb; + + cqb->ctx.c_eqn = cpu_to_be16(eqn); + cqb->ctx.db_record_addr = cpu_to_be64(cq->db.dma); + + err = mlx5_core_create_cq(&dev->mdev, &cq->mcq, cqb, inlen); + if (err) + goto err_cqb; + + mlx5_ib_dbg(dev, "cqn 0x%x\n", cq->mcq.cqn); + cq->mcq.irqn = irqn; + cq->mcq.comp = mlx5_ib_cq_comp; + cq->mcq.event = mlx5_ib_cq_event; + + if (context) + if (ib_copy_to_udata(udata, &cq->mcq.cqn, sizeof(__u32))) { + err = -EFAULT; + goto err_cmd; + } + + + mlx5_vfree(cqb); + return &cq->ibcq; + +err_cmd: + mlx5_core_destroy_cq(&dev->mdev, &cq->mcq); + +err_cqb: + mlx5_vfree(cqb); + if (context) + destroy_cq_user(cq, context); + else + destroy_cq_kernel(dev, cq); + +err_create: + kfree(cq); + + return ERR_PTR(err); +} + + +int mlx5_ib_destroy_cq(struct ib_cq *cq) +{ + struct mlx5_ib_dev *dev = to_mdev(cq->device); + struct mlx5_ib_cq *mcq = to_mcq(cq); + struct ib_ucontext *context = NULL; + + if (cq->uobject) + context = cq->uobject->context; + + mlx5_core_destroy_cq(&dev->mdev, &mcq->mcq); + if (context) + destroy_cq_user(mcq, context); + else + destroy_cq_kernel(dev, mcq); + + kfree(mcq); + + return 0; +} + +static int is_equal_rsn(struct mlx5_cqe64 *cqe64, struct mlx5_ib_srq *srq, + u32 rsn) +{ + u32 lrsn; + + if (srq) + lrsn = be32_to_cpu(cqe64->srqn) & 0xffffff; + else + lrsn = be32_to_cpu(cqe64->sop_drop_qpn) & 0xffffff; + + return rsn == lrsn; +} + +void __mlx5_ib_cq_clean(struct mlx5_ib_cq *cq, u32 rsn, struct mlx5_ib_srq *srq) +{ + struct mlx5_cqe64 *cqe64, *dest64; + void *cqe, *dest; + u32 prod_index; + int nfreed = 0; + u8 owner_bit; + + if (!cq) + return; + + /* First we need to find the current producer index, so we + * know where to start cleaning from. It doesn't matter if HW + * adds new entries after this loop -- the QP we're worried + * about is already in RESET, so the new entries won't come + * from our QP and therefore don't need to be checked. + */ + for (prod_index = cq->mcq.cons_index; get_sw_cqe(cq, prod_index); prod_index++) + if (prod_index == cq->mcq.cons_index + cq->ibcq.cqe) + break; + + /* Now sweep backwards through the CQ, removing CQ entries + * that match our QP by copying older entries on top of them. + */ + while ((int) --prod_index - (int) cq->mcq.cons_index >= 0) { + cqe = get_cqe(cq, prod_index & cq->ibcq.cqe); + cqe64 = (cq->mcq.cqe_sz == 64) ? cqe : cqe + 64; + if (is_equal_rsn(cqe64, srq, rsn)) { + if (srq) + mlx5_ib_free_srq_wqe(srq, be16_to_cpu(cqe64->wqe_counter)); + ++nfreed; + } else if (nfreed) { + dest = get_cqe(cq, (prod_index + nfreed) & cq->ibcq.cqe); + dest64 = (cq->mcq.cqe_sz == 64) ? dest : dest + 64; + owner_bit = dest64->op_own & MLX5_CQE_OWNER_MASK; + memcpy(dest, cqe, cq->mcq.cqe_sz); + dest64->op_own = owner_bit | + (dest64->op_own & ~MLX5_CQE_OWNER_MASK); + } + } + + if (nfreed) { + cq->mcq.cons_index += nfreed; + /* Make sure update of buffer contents is done before + * updating consumer index. + */ + wmb(); + mlx5_cq_set_ci(&cq->mcq); + } +} + +void mlx5_ib_cq_clean(struct mlx5_ib_cq *cq, u32 qpn, struct mlx5_ib_srq *srq) +{ + if (!cq) + return; + + spin_lock_irq(&cq->lock); + __mlx5_ib_cq_clean(cq, qpn, srq); + spin_unlock_irq(&cq->lock); +} + +int mlx5_ib_modify_cq(struct ib_cq *cq, u16 cq_count, u16 cq_period) +{ + return -ENOSYS; +} + +int mlx5_ib_resize_cq(struct ib_cq *ibcq, int entries, struct ib_udata *udata) +{ + return -ENOSYS; +} + +int mlx5_ib_get_cqe_size(struct mlx5_ib_dev *dev, struct ib_cq *ibcq) +{ + struct mlx5_ib_cq *cq; + + if (!ibcq) + return 128; + + cq = to_mcq(ibcq); + return cq->cqe_size; +} diff --git a/drivers/infiniband/hw/mlx5/doorbell.c b/drivers/infiniband/hw/mlx5/doorbell.c new file mode 100644 index 000000000000..256a23344f28 --- /dev/null +++ b/drivers/infiniband/hw/mlx5/doorbell.c @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2013, Mellanox Technologies inc. All rights reserved. + * + * This software is available to you under a choice of one of two + * licenses. You may choose to be licensed under the terms of the GNU + * General Public License (GPL) Version 2, available from the file + * COPYING in the main directory of this source tree, or the + * OpenIB.org BSD license below: + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include +#include +#include + +#include "mlx5_ib.h" + +struct mlx5_ib_user_db_page { + struct list_head list; + struct ib_umem *umem; + unsigned long user_virt; + int refcnt; +}; + +int mlx5_ib_db_map_user(struct mlx5_ib_ucontext *context, unsigned long virt, + struct mlx5_db *db) +{ + struct mlx5_ib_user_db_page *page; + struct ib_umem_chunk *chunk; + int err = 0; + + mutex_lock(&context->db_page_mutex); + + list_for_each_entry(page, &context->db_page_list, list) + if (page->user_virt == (virt & PAGE_MASK)) + goto found; + + page = kmalloc(sizeof(*page), GFP_KERNEL); + if (!page) { + err = -ENOMEM; + goto out; + } + + page->user_virt = (virt & PAGE_MASK); + page->refcnt = 0; + page->umem = ib_umem_get(&context->ibucontext, virt & PAGE_MASK, + PAGE_SIZE, 0, 0); + if (IS_ERR(page->umem)) { + err = PTR_ERR(page->umem); + kfree(page); + goto out; + } + + list_add(&page->list, &context->db_page_list); + +found: + chunk = list_entry(page->umem->chunk_list.next, struct ib_umem_chunk, list); + db->dma = sg_dma_address(chunk->page_list) + (virt & ~PAGE_MASK); + db->u.user_page = page; + ++page->refcnt; + +out: + mutex_unlock(&context->db_page_mutex); + + return err; +} + +void mlx5_ib_db_unmap_user(struct mlx5_ib_ucontext *context, struct mlx5_db *db) +{ + mutex_lock(&context->db_page_mutex); + + if (!--db->u.user_page->refcnt) { + list_del(&db->u.user_page->list); + ib_umem_release(db->u.user_page->umem); + kfree(db->u.user_page); + } + + mutex_unlock(&context->db_page_mutex); +} diff --git a/drivers/infiniband/hw/mlx5/mad.c b/drivers/infiniband/hw/mlx5/mad.c new file mode 100644 index 000000000000..5c8938be0e08 --- /dev/null +++ b/drivers/infiniband/hw/mlx5/mad.c @@ -0,0 +1,139 @@ +/* + * Copyright (c) 2013, Mellanox Technologies inc. All rights reserved. + * + * This software is available to you under a choice of one of two + * licenses. You may choose to be licensed under the terms of the GNU + * General Public License (GPL) Version 2, available from the file + * COPYING in the main directory of this source tree, or the + * OpenIB.org BSD license below: + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include +#include +#include +#include "mlx5_ib.h" + +enum { + MLX5_IB_VENDOR_CLASS1 = 0x9, + MLX5_IB_VENDOR_CLASS2 = 0xa +}; + +int mlx5_MAD_IFC(struct mlx5_ib_dev *dev, int ignore_mkey, int ignore_bkey, + int port, struct ib_wc *in_wc, struct ib_grh *in_grh, + void *in_mad, void *response_mad) +{ + u8 op_modifier = 0; + + /* Key check traps can't be generated unless we have in_wc to + * tell us where to send the trap. + */ + if (ignore_mkey || !in_wc) + op_modifier |= 0x1; + if (ignore_bkey || !in_wc) + op_modifier |= 0x2; + + return mlx5_core_mad_ifc(&dev->mdev, in_mad, response_mad, op_modifier, port); +} + +int mlx5_ib_process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num, + struct ib_wc *in_wc, struct ib_grh *in_grh, + struct ib_mad *in_mad, struct ib_mad *out_mad) +{ + u16 slid; + int err; + + slid = in_wc ? in_wc->slid : be16_to_cpu(IB_LID_PERMISSIVE); + + if (in_mad->mad_hdr.method == IB_MGMT_METHOD_TRAP && slid == 0) + return IB_MAD_RESULT_SUCCESS | IB_MAD_RESULT_CONSUMED; + + if (in_mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_SUBN_LID_ROUTED || + in_mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE) { + if (in_mad->mad_hdr.method != IB_MGMT_METHOD_GET && + in_mad->mad_hdr.method != IB_MGMT_METHOD_SET && + in_mad->mad_hdr.method != IB_MGMT_METHOD_TRAP_REPRESS) + return IB_MAD_RESULT_SUCCESS; + + /* Don't process SMInfo queries -- the SMA can't handle them. + */ + if (in_mad->mad_hdr.attr_id == IB_SMP_ATTR_SM_INFO) + return IB_MAD_RESULT_SUCCESS; + } else if (in_mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_PERF_MGMT || + in_mad->mad_hdr.mgmt_class == MLX5_IB_VENDOR_CLASS1 || + in_mad->mad_hdr.mgmt_class == MLX5_IB_VENDOR_CLASS2 || + in_mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_CONG_MGMT) { + if (in_mad->mad_hdr.method != IB_MGMT_METHOD_GET && + in_mad->mad_hdr.method != IB_MGMT_METHOD_SET) + return IB_MAD_RESULT_SUCCESS; + } else { + return IB_MAD_RESULT_SUCCESS; + } + + err = mlx5_MAD_IFC(to_mdev(ibdev), + mad_flags & IB_MAD_IGNORE_MKEY, + mad_flags & IB_MAD_IGNORE_BKEY, + port_num, in_wc, in_grh, in_mad, out_mad); + if (err) + return IB_MAD_RESULT_FAILURE; + + /* set return bit in status of directed route responses */ + if (in_mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE) + out_mad->mad_hdr.status |= cpu_to_be16(1 << 15); + + if (in_mad->mad_hdr.method == IB_MGMT_METHOD_TRAP_REPRESS) + /* no response for trap repress */ + return IB_MAD_RESULT_SUCCESS | IB_MAD_RESULT_CONSUMED; + + return IB_MAD_RESULT_SUCCESS | IB_MAD_RESULT_REPLY; +} + +int mlx5_query_ext_port_caps(struct mlx5_ib_dev *dev, u8 port) +{ + struct ib_smp *in_mad = NULL; + struct ib_smp *out_mad = NULL; + int err = -ENOMEM; + u16 packet_error; + + in_mad = kzalloc(sizeof(*in_mad), GFP_KERNEL); + out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL); + if (!in_mad || !out_mad) + goto out; + + init_query_mad(in_mad); + in_mad->attr_id = MLX5_ATTR_EXTENDED_PORT_INFO; + in_mad->attr_mod = cpu_to_be32(port); + + err = mlx5_MAD_IFC(dev, 1, 1, 1, NULL, NULL, in_mad, out_mad); + + packet_error = be16_to_cpu(out_mad->status); + + dev->mdev.caps.ext_port_cap[port - 1] = (!err && !packet_error) ? + MLX_EXT_PORT_CAP_FLAG_EXTENDED_PORT_INFO : 0; + +out: + kfree(in_mad); + kfree(out_mad); + return err; +} diff --git a/drivers/infiniband/hw/mlx5/main.c b/drivers/infiniband/hw/mlx5/main.c new file mode 100644 index 000000000000..6b1007f9bc29 --- /dev/null +++ b/drivers/infiniband/hw/mlx5/main.c @@ -0,0 +1,1504 @@ +/* + * Copyright (c) 2013, Mellanox Technologies inc. All rights reserved. + * + * This software is available to you under a choice of one of two + * licenses. You may choose to be licensed under the terms of the GNU + * General Public License (GPL) Version 2, available from the file + * COPYING in the main directory of this source tree, or the + * OpenIB.org BSD license below: + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "user.h" +#include "mlx5_ib.h" + +#define DRIVER_NAME "mlx5_ib" +#define DRIVER_VERSION "1.0" +#define DRIVER_RELDATE "June 2013" + +MODULE_AUTHOR("Eli Cohen "); +MODULE_DESCRIPTION("Mellanox Connect-IB HCA IB driver"); +MODULE_LICENSE("Dual BSD/GPL"); +MODULE_VERSION(DRIVER_VERSION); + +static int prof_sel = 2; +module_param_named(prof_sel, prof_sel, int, 0444); +MODULE_PARM_DESC(prof_sel, "profile selector. Valid range 0 - 2"); + +static char mlx5_version[] = + DRIVER_NAME ": Mellanox Connect-IB Infiniband driver v" + DRIVER_VERSION " (" DRIVER_RELDATE ")\n"; + +struct mlx5_profile profile[] = { + [0] = { + .mask = 0, + }, + [1] = { + .mask = MLX5_PROF_MASK_QP_SIZE, + .log_max_qp = 12, + }, + [2] = { + .mask = MLX5_PROF_MASK_QP_SIZE | + MLX5_PROF_MASK_MR_CACHE, + .log_max_qp = 17, + .mr_cache[0] = { + .size = 500, + .limit = 250 + }, + .mr_cache[1] = { + .size = 500, + .limit = 250 + }, + .mr_cache[2] = { + .size = 500, + .limit = 250 + }, + .mr_cache[3] = { + .size = 500, + .limit = 250 + }, + .mr_cache[4] = { + .size = 500, + .limit = 250 + }, + .mr_cache[5] = { + .size = 500, + .limit = 250 + }, + .mr_cache[6] = { + .size = 500, + .limit = 250 + }, + .mr_cache[7] = { + .size = 500, + .limit = 250 + }, + .mr_cache[8] = { + .size = 500, + .limit = 250 + }, + .mr_cache[9] = { + .size = 500, + .limit = 250 + }, + .mr_cache[10] = { + .size = 500, + .limit = 250 + }, + .mr_cache[11] = { + .size = 500, + .limit = 250 + }, + .mr_cache[12] = { + .size = 64, + .limit = 32 + }, + .mr_cache[13] = { + .size = 32, + .limit = 16 + }, + .mr_cache[14] = { + .size = 16, + .limit = 8 + }, + .mr_cache[15] = { + .size = 8, + .limit = 4 + }, + }, +}; + +int mlx5_vector2eqn(struct mlx5_ib_dev *dev, int vector, int *eqn, int *irqn) +{ + struct mlx5_eq_table *table = &dev->mdev.priv.eq_table; + struct mlx5_eq *eq, *n; + int err = -ENOENT; + + spin_lock(&table->lock); + list_for_each_entry_safe(eq, n, &dev->eqs_list, list) { + if (eq->index == vector) { + *eqn = eq->eqn; + *irqn = eq->irqn; + err = 0; + break; + } + } + spin_unlock(&table->lock); + + return err; +} + +static int alloc_comp_eqs(struct mlx5_ib_dev *dev) +{ + struct mlx5_eq_table *table = &dev->mdev.priv.eq_table; + struct mlx5_eq *eq, *n; + int ncomp_vec; + int nent; + int err; + int i; + + INIT_LIST_HEAD(&dev->eqs_list); + ncomp_vec = table->num_comp_vectors; + nent = MLX5_COMP_EQ_SIZE; + for (i = 0; i < ncomp_vec; i++) { + eq = kzalloc(sizeof(*eq), GFP_KERNEL); + if (!eq) { + err = -ENOMEM; + goto clean; + } + + snprintf(eq->name, MLX5_MAX_EQ_NAME, "mlx5_comp%d", i); + err = mlx5_create_map_eq(&dev->mdev, eq, + i + MLX5_EQ_VEC_COMP_BASE, nent, 0, + eq->name, + &dev->mdev.priv.uuari.uars[0]); + if (err) { + kfree(eq); + goto clean; + } + mlx5_ib_dbg(dev, "allocated completion EQN %d\n", eq->eqn); + eq->index = i; + spin_lock(&table->lock); + list_add_tail(&eq->list, &dev->eqs_list); + spin_unlock(&table->lock); + } + + dev->num_comp_vectors = ncomp_vec; + return 0; + +clean: + spin_lock(&table->lock); + list_for_each_entry_safe(eq, n, &dev->eqs_list, list) { + list_del(&eq->list); + spin_unlock(&table->lock); + if (mlx5_destroy_unmap_eq(&dev->mdev, eq)) + mlx5_ib_warn(dev, "failed to destroy EQ 0x%x\n", eq->eqn); + kfree(eq); + spin_lock(&table->lock); + } + spin_unlock(&table->lock); + return err; +} + +static void free_comp_eqs(struct mlx5_ib_dev *dev) +{ + struct mlx5_eq_table *table = &dev->mdev.priv.eq_table; + struct mlx5_eq *eq, *n; + + spin_lock(&table->lock); + list_for_each_entry_safe(eq, n, &dev->eqs_list, list) { + list_del(&eq->list); + spin_unlock(&table->lock); + if (mlx5_destroy_unmap_eq(&dev->mdev, eq)) + mlx5_ib_warn(dev, "failed to destroy EQ 0x%x\n", eq->eqn); + kfree(eq); + spin_lock(&table->lock); + } + spin_unlock(&table->lock); +} + +static int mlx5_ib_query_device(struct ib_device *ibdev, + struct ib_device_attr *props) +{ + struct mlx5_ib_dev *dev = to_mdev(ibdev); + struct ib_smp *in_mad = NULL; + struct ib_smp *out_mad = NULL; + int err = -ENOMEM; + int max_rq_sg; + int max_sq_sg; + u64 flags; + + in_mad = kzalloc(sizeof(*in_mad), GFP_KERNEL); + out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL); + if (!in_mad || !out_mad) + goto out; + + init_query_mad(in_mad); + in_mad->attr_id = IB_SMP_ATTR_NODE_INFO; + + err = mlx5_MAD_IFC(to_mdev(ibdev), 1, 1, 1, NULL, NULL, in_mad, out_mad); + if (err) + goto out; + + memset(props, 0, sizeof(*props)); + + props->fw_ver = ((u64)fw_rev_maj(&dev->mdev) << 32) | + (fw_rev_min(&dev->mdev) << 16) | + fw_rev_sub(&dev->mdev); + props->device_cap_flags = IB_DEVICE_CHANGE_PHY_PORT | + IB_DEVICE_PORT_ACTIVE_EVENT | + IB_DEVICE_SYS_IMAGE_GUID | + IB_DEVICE_RC_RNR_NAK_GEN | + IB_DEVICE_BLOCK_MULTICAST_LOOPBACK; + flags = dev->mdev.caps.flags; + if (flags & MLX5_DEV_CAP_FLAG_BAD_PKEY_CNTR) + props->device_cap_flags |= IB_DEVICE_BAD_PKEY_CNTR; + if (flags & MLX5_DEV_CAP_FLAG_BAD_QKEY_CNTR) + props->device_cap_flags |= IB_DEVICE_BAD_QKEY_CNTR; + if (flags & MLX5_DEV_CAP_FLAG_APM) + props->device_cap_flags |= IB_DEVICE_AUTO_PATH_MIG; + props->device_cap_flags |= IB_DEVICE_LOCAL_DMA_LKEY; + if (flags & MLX5_DEV_CAP_FLAG_XRC) + props->device_cap_flags |= IB_DEVICE_XRC; + props->device_cap_flags |= IB_DEVICE_MEM_MGT_EXTENSIONS; + + props->vendor_id = be32_to_cpup((__be32 *)(out_mad->data + 36)) & + 0xffffff; + props->vendor_part_id = be16_to_cpup((__be16 *)(out_mad->data + 30)); + props->hw_ver = be32_to_cpup((__be32 *)(out_mad->data + 32)); + memcpy(&props->sys_image_guid, out_mad->data + 4, 8); + + props->max_mr_size = ~0ull; + props->page_size_cap = dev->mdev.caps.min_page_sz; + props->max_qp = 1 << dev->mdev.caps.log_max_qp; + props->max_qp_wr = dev->mdev.caps.max_wqes; + max_rq_sg = dev->mdev.caps.max_rq_desc_sz / sizeof(struct mlx5_wqe_data_seg); + max_sq_sg = (dev->mdev.caps.max_sq_desc_sz - sizeof(struct mlx5_wqe_ctrl_seg)) / + sizeof(struct mlx5_wqe_data_seg); + props->max_sge = min(max_rq_sg, max_sq_sg); + props->max_cq = 1 << dev->mdev.caps.log_max_cq; + props->max_cqe = dev->mdev.caps.max_cqes - 1; + props->max_mr = 1 << dev->mdev.caps.log_max_mkey; + props->max_pd = 1 << dev->mdev.caps.log_max_pd; + props->max_qp_rd_atom = dev->mdev.caps.max_ra_req_qp; + props->max_qp_init_rd_atom = dev->mdev.caps.max_ra_res_qp; + props->max_res_rd_atom = props->max_qp_rd_atom * props->max_qp; + props->max_srq = 1 << dev->mdev.caps.log_max_srq; + props->max_srq_wr = dev->mdev.caps.max_srq_wqes - 1; + props->max_srq_sge = max_rq_sg - 1; + props->max_fast_reg_page_list_len = (unsigned int)-1; + props->local_ca_ack_delay = dev->mdev.caps.local_ca_ack_delay; + props->atomic_cap = dev->mdev.caps.flags & MLX5_DEV_CAP_FLAG_ATOMIC ? + IB_ATOMIC_HCA : IB_ATOMIC_NONE; + props->masked_atomic_cap = IB_ATOMIC_HCA; + props->max_pkeys = be16_to_cpup((__be16 *)(out_mad->data + 28)); + props->max_mcast_grp = 1 << dev->mdev.caps.log_max_mcg; + props->max_mcast_qp_attach = dev->mdev.caps.max_qp_mcg; + props->max_total_mcast_qp_attach = props->max_mcast_qp_attach * + props->max_mcast_grp; + props->max_map_per_fmr = INT_MAX; /* no limit in ConnectIB */ + +out: + kfree(in_mad); + kfree(out_mad); + + return err; +} + +int mlx5_ib_query_port(struct ib_device *ibdev, u8 port, + struct ib_port_attr *props) +{ + struct mlx5_ib_dev *dev = to_mdev(ibdev); + struct ib_smp *in_mad = NULL; + struct ib_smp *out_mad = NULL; + int ext_active_speed; + int err = -ENOMEM; + + if (port < 1 || port > dev->mdev.caps.num_ports) { + mlx5_ib_warn(dev, "invalid port number %d\n", port); + return -EINVAL; + } + + in_mad = kzalloc(sizeof(*in_mad), GFP_KERNEL); + out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL); + if (!in_mad || !out_mad) + goto out; + + memset(props, 0, sizeof(*props)); + + init_query_mad(in_mad); + in_mad->attr_id = IB_SMP_ATTR_PORT_INFO; + in_mad->attr_mod = cpu_to_be32(port); + + err = mlx5_MAD_IFC(dev, 1, 1, port, NULL, NULL, in_mad, out_mad); + if (err) { + mlx5_ib_warn(dev, "err %d\n", err); + goto out; + } + + + props->lid = be16_to_cpup((__be16 *)(out_mad->data + 16)); + props->lmc = out_mad->data[34] & 0x7; + props->sm_lid = be16_to_cpup((__be16 *)(out_mad->data + 18)); + props->sm_sl = out_mad->data[36] & 0xf; + props->state = out_mad->data[32] & 0xf; + props->phys_state = out_mad->data[33] >> 4; + props->port_cap_flags = be32_to_cpup((__be32 *)(out_mad->data + 20)); + props->gid_tbl_len = out_mad->data[50]; + props->max_msg_sz = 1 << to_mdev(ibdev)->mdev.caps.log_max_msg; + props->pkey_tbl_len = to_mdev(ibdev)->mdev.caps.port[port - 1].pkey_table_len; + props->bad_pkey_cntr = be16_to_cpup((__be16 *)(out_mad->data + 46)); + props->qkey_viol_cntr = be16_to_cpup((__be16 *)(out_mad->data + 48)); + props->active_width = out_mad->data[31] & 0xf; + props->active_speed = out_mad->data[35] >> 4; + props->max_mtu = out_mad->data[41] & 0xf; + props->active_mtu = out_mad->data[36] >> 4; + props->subnet_timeout = out_mad->data[51] & 0x1f; + props->max_vl_num = out_mad->data[37] >> 4; + props->init_type_reply = out_mad->data[41] >> 4; + + /* Check if extended speeds (EDR/FDR/...) are supported */ + if (props->port_cap_flags & IB_PORT_EXTENDED_SPEEDS_SUP) { + ext_active_speed = out_mad->data[62] >> 4; + + switch (ext_active_speed) { + case 1: + props->active_speed = 16; /* FDR */ + break; + case 2: + props->active_speed = 32; /* EDR */ + break; + } + } + + /* If reported active speed is QDR, check if is FDR-10 */ + if (props->active_speed == 4) { + if (dev->mdev.caps.ext_port_cap[port - 1] & + MLX_EXT_PORT_CAP_FLAG_EXTENDED_PORT_INFO) { + init_query_mad(in_mad); + in_mad->attr_id = MLX5_ATTR_EXTENDED_PORT_INFO; + in_mad->attr_mod = cpu_to_be32(port); + + err = mlx5_MAD_IFC(dev, 1, 1, port, + NULL, NULL, in_mad, out_mad); + if (err) + goto out; + + /* Checking LinkSpeedActive for FDR-10 */ + if (out_mad->data[15] & 0x1) + props->active_speed = 8; + } + } + +out: + kfree(in_mad); + kfree(out_mad); + + return err; +} + +static int mlx5_ib_query_gid(struct ib_device *ibdev, u8 port, int index, + union ib_gid *gid) +{ + struct ib_smp *in_mad = NULL; + struct ib_smp *out_mad = NULL; + int err = -ENOMEM; + + in_mad = kzalloc(sizeof(*in_mad), GFP_KERNEL); + out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL); + if (!in_mad || !out_mad) + goto out; + + init_query_mad(in_mad); + in_mad->attr_id = IB_SMP_ATTR_PORT_INFO; + in_mad->attr_mod = cpu_to_be32(port); + + err = mlx5_MAD_IFC(to_mdev(ibdev), 1, 1, port, NULL, NULL, in_mad, out_mad); + if (err) + goto out; + + memcpy(gid->raw, out_mad->data + 8, 8); + + init_query_mad(in_mad); + in_mad->attr_id = IB_SMP_ATTR_GUID_INFO; + in_mad->attr_mod = cpu_to_be32(index / 8); + + err = mlx5_MAD_IFC(to_mdev(ibdev), 1, 1, port, NULL, NULL, in_mad, out_mad); + if (err) + goto out; + + memcpy(gid->raw + 8, out_mad->data + (index % 8) * 8, 8); + +out: + kfree(in_mad); + kfree(out_mad); + return err; +} + +static int mlx5_ib_query_pkey(struct ib_device *ibdev, u8 port, u16 index, + u16 *pkey) +{ + struct ib_smp *in_mad = NULL; + struct ib_smp *out_mad = NULL; + int err = -ENOMEM; + + in_mad = kzalloc(sizeof(*in_mad), GFP_KERNEL); + out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL); + if (!in_mad || !out_mad) + goto out; + + init_query_mad(in_mad); + in_mad->attr_id = IB_SMP_ATTR_PKEY_TABLE; + in_mad->attr_mod = cpu_to_be32(index / 32); + + err = mlx5_MAD_IFC(to_mdev(ibdev), 1, 1, port, NULL, NULL, in_mad, out_mad); + if (err) + goto out; + + *pkey = be16_to_cpu(((__be16 *)out_mad->data)[index % 32]); + +out: + kfree(in_mad); + kfree(out_mad); + return err; +} + +struct mlx5_reg_node_desc { + u8 desc[64]; +}; + +static int mlx5_ib_modify_device(struct ib_device *ibdev, int mask, + struct ib_device_modify *props) +{ + struct mlx5_ib_dev *dev = to_mdev(ibdev); + struct mlx5_reg_node_desc in; + struct mlx5_reg_node_desc out; + int err; + + if (mask & ~IB_DEVICE_MODIFY_NODE_DESC) + return -EOPNOTSUPP; + + if (!(mask & IB_DEVICE_MODIFY_NODE_DESC)) + return 0; + + /* + * If possible, pass node desc to FW, so it can generate + * a 144 trap. If cmd fails, just ignore. + */ + memcpy(&in, props->node_desc, 64); + err = mlx5_core_access_reg(&dev->mdev, &in, sizeof(in), &out, + sizeof(out), MLX5_REG_NODE_DESC, 0, 1); + if (err) + return err; + + memcpy(ibdev->node_desc, props->node_desc, 64); + + return err; +} + +static int mlx5_ib_modify_port(struct ib_device *ibdev, u8 port, int mask, + struct ib_port_modify *props) +{ + struct mlx5_ib_dev *dev = to_mdev(ibdev); + struct ib_port_attr attr; + u32 tmp; + int err; + + mutex_lock(&dev->cap_mask_mutex); + + err = mlx5_ib_query_port(ibdev, port, &attr); + if (err) + goto out; + + tmp = (attr.port_cap_flags | props->set_port_cap_mask) & + ~props->clr_port_cap_mask; + + err = mlx5_set_port_caps(&dev->mdev, port, tmp); + +out: + mutex_unlock(&dev->cap_mask_mutex); + return err; +} + +static struct ib_ucontext *mlx5_ib_alloc_ucontext(struct ib_device *ibdev, + struct ib_udata *udata) +{ + struct mlx5_ib_dev *dev = to_mdev(ibdev); + struct mlx5_ib_alloc_ucontext_req req; + struct mlx5_ib_alloc_ucontext_resp resp; + struct mlx5_ib_ucontext *context; + struct mlx5_uuar_info *uuari; + struct mlx5_uar *uars; + int num_uars; + int uuarn; + int err; + int i; + + if (!dev->ib_active) + return ERR_PTR(-EAGAIN); + + err = ib_copy_from_udata(&req, udata, sizeof(req)); + if (err) + return ERR_PTR(err); + + if (req.total_num_uuars > MLX5_MAX_UUARS) + return ERR_PTR(-ENOMEM); + + if (req.total_num_uuars == 0) + return ERR_PTR(-EINVAL); + + req.total_num_uuars = ALIGN(req.total_num_uuars, MLX5_BF_REGS_PER_PAGE); + if (req.num_low_latency_uuars > req.total_num_uuars - 1) + return ERR_PTR(-EINVAL); + + num_uars = req.total_num_uuars / MLX5_BF_REGS_PER_PAGE; + resp.qp_tab_size = 1 << dev->mdev.caps.log_max_qp; + resp.bf_reg_size = dev->mdev.caps.bf_reg_size; + resp.cache_line_size = L1_CACHE_BYTES; + resp.max_sq_desc_sz = dev->mdev.caps.max_sq_desc_sz; + resp.max_rq_desc_sz = dev->mdev.caps.max_rq_desc_sz; + resp.max_send_wqebb = dev->mdev.caps.max_wqes; + resp.max_recv_wr = dev->mdev.caps.max_wqes; + resp.max_srq_recv_wr = dev->mdev.caps.max_srq_wqes; + + context = kzalloc(sizeof(*context), GFP_KERNEL); + if (!context) + return ERR_PTR(-ENOMEM); + + uuari = &context->uuari; + mutex_init(&uuari->lock); + uars = kcalloc(num_uars, sizeof(*uars), GFP_KERNEL); + if (!uars) { + err = -ENOMEM; + goto out_ctx; + } + + uuari->bitmap = kcalloc(BITS_TO_LONGS(req.total_num_uuars), + sizeof(*uuari->bitmap), + GFP_KERNEL); + if (!uuari->bitmap) { + err = -ENOMEM; + goto out_uar_ctx; + } + /* + * clear all fast path uuars + */ + for (i = 0; i < req.total_num_uuars; i++) { + uuarn = i & 3; + if (uuarn == 2 || uuarn == 3) + set_bit(i, uuari->bitmap); + } + + uuari->count = kcalloc(req.total_num_uuars, sizeof(*uuari->count), GFP_KERNEL); + if (!uuari->count) { + err = -ENOMEM; + goto out_bitmap; + } + + for (i = 0; i < num_uars; i++) { + err = mlx5_cmd_alloc_uar(&dev->mdev, &uars[i].index); + if (err) + goto out_count; + } + + INIT_LIST_HEAD(&context->db_page_list); + mutex_init(&context->db_page_mutex); + + resp.tot_uuars = req.total_num_uuars; + resp.num_ports = dev->mdev.caps.num_ports; + err = ib_copy_to_udata(udata, &resp, sizeof(resp)); + if (err) + goto out_uars; + + uuari->num_low_latency_uuars = req.num_low_latency_uuars; + uuari->uars = uars; + uuari->num_uars = num_uars; + return &context->ibucontext; + +out_uars: + for (i--; i >= 0; i--) + mlx5_cmd_free_uar(&dev->mdev, uars[i].index); +out_count: + kfree(uuari->count); + +out_bitmap: + kfree(uuari->bitmap); + +out_uar_ctx: + kfree(uars); + +out_ctx: + kfree(context); + return ERR_PTR(err); +} + +static int mlx5_ib_dealloc_ucontext(struct ib_ucontext *ibcontext) +{ + struct mlx5_ib_ucontext *context = to_mucontext(ibcontext); + struct mlx5_ib_dev *dev = to_mdev(ibcontext->device); + struct mlx5_uuar_info *uuari = &context->uuari; + int i; + + for (i = 0; i < uuari->num_uars; i++) { + if (mlx5_cmd_free_uar(&dev->mdev, uuari->uars[i].index)) + mlx5_ib_warn(dev, "failed to free UAR 0x%x\n", uuari->uars[i].index); + } + + kfree(uuari->count); + kfree(uuari->bitmap); + kfree(uuari->uars); + kfree(context); + + return 0; +} + +static phys_addr_t uar_index2pfn(struct mlx5_ib_dev *dev, int index) +{ + return (pci_resource_start(dev->mdev.pdev, 0) >> PAGE_SHIFT) + index; +} + +static int get_command(unsigned long offset) +{ + return (offset >> MLX5_IB_MMAP_CMD_SHIFT) & MLX5_IB_MMAP_CMD_MASK; +} + +static int get_arg(unsigned long offset) +{ + return offset & ((1 << MLX5_IB_MMAP_CMD_SHIFT) - 1); +} + +static int get_index(unsigned long offset) +{ + return get_arg(offset); +} + +static int mlx5_ib_mmap(struct ib_ucontext *ibcontext, struct vm_area_struct *vma) +{ + struct mlx5_ib_ucontext *context = to_mucontext(ibcontext); + struct mlx5_ib_dev *dev = to_mdev(ibcontext->device); + struct mlx5_uuar_info *uuari = &context->uuari; + unsigned long command; + unsigned long idx; + phys_addr_t pfn; + + command = get_command(vma->vm_pgoff); + switch (command) { + case MLX5_IB_MMAP_REGULAR_PAGE: + if (vma->vm_end - vma->vm_start != PAGE_SIZE) + return -EINVAL; + + idx = get_index(vma->vm_pgoff); + pfn = uar_index2pfn(dev, uuari->uars[idx].index); + mlx5_ib_dbg(dev, "uar idx 0x%lx, pfn 0x%llx\n", idx, + (unsigned long long)pfn); + + if (idx >= uuari->num_uars) + return -EINVAL; + + vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot); + if (io_remap_pfn_range(vma, vma->vm_start, pfn, + PAGE_SIZE, vma->vm_page_prot)) + return -EAGAIN; + + mlx5_ib_dbg(dev, "mapped WC at 0x%lx, PA 0x%llx\n", + vma->vm_start, + (unsigned long long)pfn << PAGE_SHIFT); + break; + + case MLX5_IB_MMAP_GET_CONTIGUOUS_PAGES: + return -ENOSYS; + + default: + return -EINVAL; + } + + return 0; +} + +static int alloc_pa_mkey(struct mlx5_ib_dev *dev, u32 *key, u32 pdn) +{ + struct mlx5_create_mkey_mbox_in *in; + struct mlx5_mkey_seg *seg; + struct mlx5_core_mr mr; + int err; + + in = kzalloc(sizeof(*in), GFP_KERNEL); + if (!in) + return -ENOMEM; + + seg = &in->seg; + seg->flags = MLX5_PERM_LOCAL_READ | MLX5_ACCESS_MODE_PA; + seg->flags_pd = cpu_to_be32(pdn | MLX5_MKEY_LEN64); + seg->qpn_mkey7_0 = cpu_to_be32(0xffffff << 8); + seg->start_addr = 0; + + err = mlx5_core_create_mkey(&dev->mdev, &mr, in, sizeof(*in)); + if (err) { + mlx5_ib_warn(dev, "failed to create mkey, %d\n", err); + goto err_in; + } + + kfree(in); + *key = mr.key; + + return 0; + +err_in: + kfree(in); + + return err; +} + +static void free_pa_mkey(struct mlx5_ib_dev *dev, u32 key) +{ + struct mlx5_core_mr mr; + int err; + + memset(&mr, 0, sizeof(mr)); + mr.key = key; + err = mlx5_core_destroy_mkey(&dev->mdev, &mr); + if (err) + mlx5_ib_warn(dev, "failed to destroy mkey 0x%x\n", key); +} + +static struct ib_pd *mlx5_ib_alloc_pd(struct ib_device *ibdev, + struct ib_ucontext *context, + struct ib_udata *udata) +{ + struct mlx5_ib_alloc_pd_resp resp; + struct mlx5_ib_pd *pd; + int err; + + pd = kmalloc(sizeof(*pd), GFP_KERNEL); + if (!pd) + return ERR_PTR(-ENOMEM); + + err = mlx5_core_alloc_pd(&to_mdev(ibdev)->mdev, &pd->pdn); + if (err) { + kfree(pd); + return ERR_PTR(err); + } + + if (context) { + resp.pdn = pd->pdn; + if (ib_copy_to_udata(udata, &resp, sizeof(resp))) { + mlx5_core_dealloc_pd(&to_mdev(ibdev)->mdev, pd->pdn); + kfree(pd); + return ERR_PTR(-EFAULT); + } + } else { + err = alloc_pa_mkey(to_mdev(ibdev), &pd->pa_lkey, pd->pdn); + if (err) { + mlx5_core_dealloc_pd(&to_mdev(ibdev)->mdev, pd->pdn); + kfree(pd); + return ERR_PTR(err); + } + } + + return &pd->ibpd; +} + +static int mlx5_ib_dealloc_pd(struct ib_pd *pd) +{ + struct mlx5_ib_dev *mdev = to_mdev(pd->device); + struct mlx5_ib_pd *mpd = to_mpd(pd); + + if (!pd->uobject) + free_pa_mkey(mdev, mpd->pa_lkey); + + mlx5_core_dealloc_pd(&mdev->mdev, mpd->pdn); + kfree(mpd); + + return 0; +} + +static int mlx5_ib_mcg_attach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid) +{ + struct mlx5_ib_dev *dev = to_mdev(ibqp->device); + int err; + + err = mlx5_core_attach_mcg(&dev->mdev, gid, ibqp->qp_num); + if (err) + mlx5_ib_warn(dev, "failed attaching QPN 0x%x, MGID %pI6\n", + ibqp->qp_num, gid->raw); + + return err; +} + +static int mlx5_ib_mcg_detach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid) +{ + struct mlx5_ib_dev *dev = to_mdev(ibqp->device); + int err; + + err = mlx5_core_detach_mcg(&dev->mdev, gid, ibqp->qp_num); + if (err) + mlx5_ib_warn(dev, "failed detaching QPN 0x%x, MGID %pI6\n", + ibqp->qp_num, gid->raw); + + return err; +} + +static int init_node_data(struct mlx5_ib_dev *dev) +{ + struct ib_smp *in_mad = NULL; + struct ib_smp *out_mad = NULL; + int err = -ENOMEM; + + in_mad = kzalloc(sizeof(*in_mad), GFP_KERNEL); + out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL); + if (!in_mad || !out_mad) + goto out; + + init_query_mad(in_mad); + in_mad->attr_id = IB_SMP_ATTR_NODE_DESC; + + err = mlx5_MAD_IFC(dev, 1, 1, 1, NULL, NULL, in_mad, out_mad); + if (err) + goto out; + + memcpy(dev->ib_dev.node_desc, out_mad->data, 64); + + in_mad->attr_id = IB_SMP_ATTR_NODE_INFO; + + err = mlx5_MAD_IFC(dev, 1, 1, 1, NULL, NULL, in_mad, out_mad); + if (err) + goto out; + + dev->mdev.rev_id = be32_to_cpup((__be32 *)(out_mad->data + 32)); + memcpy(&dev->ib_dev.node_guid, out_mad->data + 12, 8); + +out: + kfree(in_mad); + kfree(out_mad); + return err; +} + +static ssize_t show_fw_pages(struct device *device, struct device_attribute *attr, + char *buf) +{ + struct mlx5_ib_dev *dev = + container_of(device, struct mlx5_ib_dev, ib_dev.dev); + + return sprintf(buf, "%d\n", dev->mdev.priv.fw_pages); +} + +static ssize_t show_reg_pages(struct device *device, + struct device_attribute *attr, char *buf) +{ + struct mlx5_ib_dev *dev = + container_of(device, struct mlx5_ib_dev, ib_dev.dev); + + return sprintf(buf, "%d\n", dev->mdev.priv.reg_pages); +} + +static ssize_t show_hca(struct device *device, struct device_attribute *attr, + char *buf) +{ + struct mlx5_ib_dev *dev = + container_of(device, struct mlx5_ib_dev, ib_dev.dev); + return sprintf(buf, "MT%d\n", dev->mdev.pdev->device); +} + +static ssize_t show_fw_ver(struct device *device, struct device_attribute *attr, + char *buf) +{ + struct mlx5_ib_dev *dev = + container_of(device, struct mlx5_ib_dev, ib_dev.dev); + return sprintf(buf, "%d.%d.%d\n", fw_rev_maj(&dev->mdev), + fw_rev_min(&dev->mdev), fw_rev_sub(&dev->mdev)); +} + +static ssize_t show_rev(struct device *device, struct device_attribute *attr, + char *buf) +{ + struct mlx5_ib_dev *dev = + container_of(device, struct mlx5_ib_dev, ib_dev.dev); + return sprintf(buf, "%x\n", dev->mdev.rev_id); +} + +static ssize_t show_board(struct device *device, struct device_attribute *attr, + char *buf) +{ + struct mlx5_ib_dev *dev = + container_of(device, struct mlx5_ib_dev, ib_dev.dev); + return sprintf(buf, "%.*s\n", MLX5_BOARD_ID_LEN, + dev->mdev.board_id); +} + +static DEVICE_ATTR(hw_rev, S_IRUGO, show_rev, NULL); +static DEVICE_ATTR(fw_ver, S_IRUGO, show_fw_ver, NULL); +static DEVICE_ATTR(hca_type, S_IRUGO, show_hca, NULL); +static DEVICE_ATTR(board_id, S_IRUGO, show_board, NULL); +static DEVICE_ATTR(fw_pages, S_IRUGO, show_fw_pages, NULL); +static DEVICE_ATTR(reg_pages, S_IRUGO, show_reg_pages, NULL); + +static struct device_attribute *mlx5_class_attributes[] = { + &dev_attr_hw_rev, + &dev_attr_fw_ver, + &dev_attr_hca_type, + &dev_attr_board_id, + &dev_attr_fw_pages, + &dev_attr_reg_pages, +}; + +static void mlx5_ib_event(struct mlx5_core_dev *dev, enum mlx5_dev_event event, + void *data) +{ + struct mlx5_ib_dev *ibdev = container_of(dev, struct mlx5_ib_dev, mdev); + struct ib_event ibev; + u8 port = 0; + + switch (event) { + case MLX5_DEV_EVENT_SYS_ERROR: + ibdev->ib_active = false; + ibev.event = IB_EVENT_DEVICE_FATAL; + break; + + case MLX5_DEV_EVENT_PORT_UP: + ibev.event = IB_EVENT_PORT_ACTIVE; + port = *(u8 *)data; + break; + + case MLX5_DEV_EVENT_PORT_DOWN: + ibev.event = IB_EVENT_PORT_ERR; + port = *(u8 *)data; + break; + + case MLX5_DEV_EVENT_PORT_INITIALIZED: + /* not used by ULPs */ + return; + + case MLX5_DEV_EVENT_LID_CHANGE: + ibev.event = IB_EVENT_LID_CHANGE; + port = *(u8 *)data; + break; + + case MLX5_DEV_EVENT_PKEY_CHANGE: + ibev.event = IB_EVENT_PKEY_CHANGE; + port = *(u8 *)data; + break; + + case MLX5_DEV_EVENT_GUID_CHANGE: + ibev.event = IB_EVENT_GID_CHANGE; + port = *(u8 *)data; + break; + + case MLX5_DEV_EVENT_CLIENT_REREG: + ibev.event = IB_EVENT_CLIENT_REREGISTER; + port = *(u8 *)data; + break; + } + + ibev.device = &ibdev->ib_dev; + ibev.element.port_num = port; + + if (ibdev->ib_active) + ib_dispatch_event(&ibev); +} + +static void get_ext_port_caps(struct mlx5_ib_dev *dev) +{ + int port; + + for (port = 1; port <= dev->mdev.caps.num_ports; port++) + mlx5_query_ext_port_caps(dev, port); +} + +static int get_port_caps(struct mlx5_ib_dev *dev) +{ + struct ib_device_attr *dprops = NULL; + struct ib_port_attr *pprops = NULL; + int err = 0; + int port; + + pprops = kmalloc(sizeof(*pprops), GFP_KERNEL); + if (!pprops) + goto out; + + dprops = kmalloc(sizeof(*dprops), GFP_KERNEL); + if (!dprops) + goto out; + + err = mlx5_ib_query_device(&dev->ib_dev, dprops); + if (err) { + mlx5_ib_warn(dev, "query_device failed %d\n", err); + goto out; + } + + for (port = 1; port <= dev->mdev.caps.num_ports; port++) { + err = mlx5_ib_query_port(&dev->ib_dev, port, pprops); + if (err) { + mlx5_ib_warn(dev, "query_port %d failed %d\n", port, err); + break; + } + dev->mdev.caps.port[port - 1].pkey_table_len = dprops->max_pkeys; + dev->mdev.caps.port[port - 1].gid_table_len = pprops->gid_tbl_len; + mlx5_ib_dbg(dev, "pkey_table_len %d, gid_table_len %d\n", + dprops->max_pkeys, pprops->gid_tbl_len); + } + +out: + kfree(pprops); + kfree(dprops); + + return err; +} + +static void destroy_umrc_res(struct mlx5_ib_dev *dev) +{ + int err; + + err = mlx5_mr_cache_cleanup(dev); + if (err) + mlx5_ib_warn(dev, "mr cache cleanup failed\n"); + + mlx5_ib_destroy_qp(dev->umrc.qp); + ib_destroy_cq(dev->umrc.cq); + ib_dereg_mr(dev->umrc.mr); + ib_dealloc_pd(dev->umrc.pd); +} + +enum { + MAX_UMR_WR = 128, +}; + +static int create_umr_res(struct mlx5_ib_dev *dev) +{ + struct ib_qp_init_attr *init_attr = NULL; + struct ib_qp_attr *attr = NULL; + struct ib_pd *pd; + struct ib_cq *cq; + struct ib_qp *qp; + struct ib_mr *mr; + int ret; + + attr = kzalloc(sizeof(*attr), GFP_KERNEL); + init_attr = kzalloc(sizeof(*init_attr), GFP_KERNEL); + if (!attr || !init_attr) { + ret = -ENOMEM; + goto error_0; + } + + pd = ib_alloc_pd(&dev->ib_dev); + if (IS_ERR(pd)) { + mlx5_ib_dbg(dev, "Couldn't create PD for sync UMR QP\n"); + ret = PTR_ERR(pd); + goto error_0; + } + + mr = ib_get_dma_mr(pd, IB_ACCESS_LOCAL_WRITE); + if (IS_ERR(mr)) { + mlx5_ib_dbg(dev, "Couldn't create DMA MR for sync UMR QP\n"); + ret = PTR_ERR(mr); + goto error_1; + } + + cq = ib_create_cq(&dev->ib_dev, mlx5_umr_cq_handler, NULL, NULL, 128, + 0); + if (IS_ERR(cq)) { + mlx5_ib_dbg(dev, "Couldn't create CQ for sync UMR QP\n"); + ret = PTR_ERR(cq); + goto error_2; + } + ib_req_notify_cq(cq, IB_CQ_NEXT_COMP); + + init_attr->send_cq = cq; + init_attr->recv_cq = cq; + init_attr->sq_sig_type = IB_SIGNAL_ALL_WR; + init_attr->cap.max_send_wr = MAX_UMR_WR; + init_attr->cap.max_send_sge = 1; + init_attr->qp_type = MLX5_IB_QPT_REG_UMR; + init_attr->port_num = 1; + qp = mlx5_ib_create_qp(pd, init_attr, NULL); + if (IS_ERR(qp)) { + mlx5_ib_dbg(dev, "Couldn't create sync UMR QP\n"); + ret = PTR_ERR(qp); + goto error_3; + } + qp->device = &dev->ib_dev; + qp->real_qp = qp; + qp->uobject = NULL; + qp->qp_type = MLX5_IB_QPT_REG_UMR; + + attr->qp_state = IB_QPS_INIT; + attr->port_num = 1; + ret = mlx5_ib_modify_qp(qp, attr, IB_QP_STATE | IB_QP_PKEY_INDEX | + IB_QP_PORT, NULL); + if (ret) { + mlx5_ib_dbg(dev, "Couldn't modify UMR QP\n"); + goto error_4; + } + + memset(attr, 0, sizeof(*attr)); + attr->qp_state = IB_QPS_RTR; + attr->path_mtu = IB_MTU_256; + + ret = mlx5_ib_modify_qp(qp, attr, IB_QP_STATE, NULL); + if (ret) { + mlx5_ib_dbg(dev, "Couldn't modify umr QP to rtr\n"); + goto error_4; + } + + memset(attr, 0, sizeof(*attr)); + attr->qp_state = IB_QPS_RTS; + ret = mlx5_ib_modify_qp(qp, attr, IB_QP_STATE, NULL); + if (ret) { + mlx5_ib_dbg(dev, "Couldn't modify umr QP to rts\n"); + goto error_4; + } + + dev->umrc.qp = qp; + dev->umrc.cq = cq; + dev->umrc.mr = mr; + dev->umrc.pd = pd; + + sema_init(&dev->umrc.sem, MAX_UMR_WR); + ret = mlx5_mr_cache_init(dev); + if (ret) { + mlx5_ib_warn(dev, "mr cache init failed %d\n", ret); + goto error_4; + } + + kfree(attr); + kfree(init_attr); + + return 0; + +error_4: + mlx5_ib_destroy_qp(qp); + +error_3: + ib_destroy_cq(cq); + +error_2: + ib_dereg_mr(mr); + +error_1: + ib_dealloc_pd(pd); + +error_0: + kfree(attr); + kfree(init_attr); + return ret; +} + +static int create_dev_resources(struct mlx5_ib_resources *devr) +{ + struct ib_srq_init_attr attr; + struct mlx5_ib_dev *dev; + int ret = 0; + + dev = container_of(devr, struct mlx5_ib_dev, devr); + + devr->p0 = mlx5_ib_alloc_pd(&dev->ib_dev, NULL, NULL); + if (IS_ERR(devr->p0)) { + ret = PTR_ERR(devr->p0); + goto error0; + } + devr->p0->device = &dev->ib_dev; + devr->p0->uobject = NULL; + atomic_set(&devr->p0->usecnt, 0); + + devr->c0 = mlx5_ib_create_cq(&dev->ib_dev, 1, 0, NULL, NULL); + if (IS_ERR(devr->c0)) { + ret = PTR_ERR(devr->c0); + goto error1; + } + devr->c0->device = &dev->ib_dev; + devr->c0->uobject = NULL; + devr->c0->comp_handler = NULL; + devr->c0->event_handler = NULL; + devr->c0->cq_context = NULL; + atomic_set(&devr->c0->usecnt, 0); + + devr->x0 = mlx5_ib_alloc_xrcd(&dev->ib_dev, NULL, NULL); + if (IS_ERR(devr->x0)) { + ret = PTR_ERR(devr->x0); + goto error2; + } + devr->x0->device = &dev->ib_dev; + devr->x0->inode = NULL; + atomic_set(&devr->x0->usecnt, 0); + mutex_init(&devr->x0->tgt_qp_mutex); + INIT_LIST_HEAD(&devr->x0->tgt_qp_list); + + devr->x1 = mlx5_ib_alloc_xrcd(&dev->ib_dev, NULL, NULL); + if (IS_ERR(devr->x1)) { + ret = PTR_ERR(devr->x1); + goto error3; + } + devr->x1->device = &dev->ib_dev; + devr->x1->inode = NULL; + atomic_set(&devr->x1->usecnt, 0); + mutex_init(&devr->x1->tgt_qp_mutex); + INIT_LIST_HEAD(&devr->x1->tgt_qp_list); + + memset(&attr, 0, sizeof(attr)); + attr.attr.max_sge = 1; + attr.attr.max_wr = 1; + attr.srq_type = IB_SRQT_XRC; + attr.ext.xrc.cq = devr->c0; + attr.ext.xrc.xrcd = devr->x0; + + devr->s0 = mlx5_ib_create_srq(devr->p0, &attr, NULL); + if (IS_ERR(devr->s0)) { + ret = PTR_ERR(devr->s0); + goto error4; + } + devr->s0->device = &dev->ib_dev; + devr->s0->pd = devr->p0; + devr->s0->uobject = NULL; + devr->s0->event_handler = NULL; + devr->s0->srq_context = NULL; + devr->s0->srq_type = IB_SRQT_XRC; + devr->s0->ext.xrc.xrcd = devr->x0; + devr->s0->ext.xrc.cq = devr->c0; + atomic_inc(&devr->s0->ext.xrc.xrcd->usecnt); + atomic_inc(&devr->s0->ext.xrc.cq->usecnt); + atomic_inc(&devr->p0->usecnt); + atomic_set(&devr->s0->usecnt, 0); + + return 0; + +error4: + mlx5_ib_dealloc_xrcd(devr->x1); +error3: + mlx5_ib_dealloc_xrcd(devr->x0); +error2: + mlx5_ib_destroy_cq(devr->c0); +error1: + mlx5_ib_dealloc_pd(devr->p0); +error0: + return ret; +} + +static void destroy_dev_resources(struct mlx5_ib_resources *devr) +{ + mlx5_ib_destroy_srq(devr->s0); + mlx5_ib_dealloc_xrcd(devr->x0); + mlx5_ib_dealloc_xrcd(devr->x1); + mlx5_ib_destroy_cq(devr->c0); + mlx5_ib_dealloc_pd(devr->p0); +} + +static int init_one(struct pci_dev *pdev, + const struct pci_device_id *id) +{ + struct mlx5_core_dev *mdev; + struct mlx5_ib_dev *dev; + int err; + int i; + + printk_once(KERN_INFO "%s", mlx5_version); + + dev = (struct mlx5_ib_dev *)ib_alloc_device(sizeof(*dev)); + if (!dev) + return -ENOMEM; + + mdev = &dev->mdev; + mdev->event = mlx5_ib_event; + if (prof_sel >= ARRAY_SIZE(profile)) { + pr_warn("selected pofile out of range, selceting default\n"); + prof_sel = 0; + } + mdev->profile = &profile[prof_sel]; + err = mlx5_dev_init(mdev, pdev); + if (err) + goto err_free; + + err = get_port_caps(dev); + if (err) + goto err_cleanup; + + get_ext_port_caps(dev); + + err = alloc_comp_eqs(dev); + if (err) + goto err_cleanup; + + MLX5_INIT_DOORBELL_LOCK(&dev->uar_lock); + + strlcpy(dev->ib_dev.name, "mlx5_%d", IB_DEVICE_NAME_MAX); + dev->ib_dev.owner = THIS_MODULE; + dev->ib_dev.node_type = RDMA_NODE_IB_CA; + dev->ib_dev.local_dma_lkey = mdev->caps.reserved_lkey; + dev->num_ports = mdev->caps.num_ports; + dev->ib_dev.phys_port_cnt = dev->num_ports; + dev->ib_dev.num_comp_vectors = dev->num_comp_vectors; + dev->ib_dev.dma_device = &mdev->pdev->dev; + + dev->ib_dev.uverbs_abi_ver = MLX5_IB_UVERBS_ABI_VERSION; + dev->ib_dev.uverbs_cmd_mask = + (1ull << IB_USER_VERBS_CMD_GET_CONTEXT) | + (1ull << IB_USER_VERBS_CMD_QUERY_DEVICE) | + (1ull << IB_USER_VERBS_CMD_QUERY_PORT) | + (1ull << IB_USER_VERBS_CMD_ALLOC_PD) | + (1ull << IB_USER_VERBS_CMD_DEALLOC_PD) | + (1ull << IB_USER_VERBS_CMD_REG_MR) | + (1ull << IB_USER_VERBS_CMD_DEREG_MR) | + (1ull << IB_USER_VERBS_CMD_CREATE_COMP_CHANNEL) | + (1ull << IB_USER_VERBS_CMD_CREATE_CQ) | + (1ull << IB_USER_VERBS_CMD_RESIZE_CQ) | + (1ull << IB_USER_VERBS_CMD_DESTROY_CQ) | + (1ull << IB_USER_VERBS_CMD_CREATE_QP) | + (1ull << IB_USER_VERBS_CMD_MODIFY_QP) | + (1ull << IB_USER_VERBS_CMD_QUERY_QP) | + (1ull << IB_USER_VERBS_CMD_DESTROY_QP) | + (1ull << IB_USER_VERBS_CMD_ATTACH_MCAST) | + (1ull << IB_USER_VERBS_CMD_DETACH_MCAST) | + (1ull << IB_USER_VERBS_CMD_CREATE_SRQ) | + (1ull << IB_USER_VERBS_CMD_MODIFY_SRQ) | + (1ull << IB_USER_VERBS_CMD_QUERY_SRQ) | + (1ull << IB_USER_VERBS_CMD_DESTROY_SRQ) | + (1ull << IB_USER_VERBS_CMD_CREATE_XSRQ) | + (1ull << IB_USER_VERBS_CMD_OPEN_QP); + + dev->ib_dev.query_device = mlx5_ib_query_device; + dev->ib_dev.query_port = mlx5_ib_query_port; + dev->ib_dev.query_gid = mlx5_ib_query_gid; + dev->ib_dev.query_pkey = mlx5_ib_query_pkey; + dev->ib_dev.modify_device = mlx5_ib_modify_device; + dev->ib_dev.modify_port = mlx5_ib_modify_port; + dev->ib_dev.alloc_ucontext = mlx5_ib_alloc_ucontext; + dev->ib_dev.dealloc_ucontext = mlx5_ib_dealloc_ucontext; + dev->ib_dev.mmap = mlx5_ib_mmap; + dev->ib_dev.alloc_pd = mlx5_ib_alloc_pd; + dev->ib_dev.dealloc_pd = mlx5_ib_dealloc_pd; + dev->ib_dev.create_ah = mlx5_ib_create_ah; + dev->ib_dev.query_ah = mlx5_ib_query_ah; + dev->ib_dev.destroy_ah = mlx5_ib_destroy_ah; + dev->ib_dev.create_srq = mlx5_ib_create_srq; + dev->ib_dev.modify_srq = mlx5_ib_modify_srq; + dev->ib_dev.query_srq = mlx5_ib_query_srq; + dev->ib_dev.destroy_srq = mlx5_ib_destroy_srq; + dev->ib_dev.post_srq_recv = mlx5_ib_post_srq_recv; + dev->ib_dev.create_qp = mlx5_ib_create_qp; + dev->ib_dev.modify_qp = mlx5_ib_modify_qp; + dev->ib_dev.query_qp = mlx5_ib_query_qp; + dev->ib_dev.destroy_qp = mlx5_ib_destroy_qp; + dev->ib_dev.post_send = mlx5_ib_post_send; + dev->ib_dev.post_recv = mlx5_ib_post_recv; + dev->ib_dev.create_cq = mlx5_ib_create_cq; + dev->ib_dev.modify_cq = mlx5_ib_modify_cq; + dev->ib_dev.resize_cq = mlx5_ib_resize_cq; + dev->ib_dev.destroy_cq = mlx5_ib_destroy_cq; + dev->ib_dev.poll_cq = mlx5_ib_poll_cq; + dev->ib_dev.req_notify_cq = mlx5_ib_arm_cq; + dev->ib_dev.get_dma_mr = mlx5_ib_get_dma_mr; + dev->ib_dev.reg_user_mr = mlx5_ib_reg_user_mr; + dev->ib_dev.dereg_mr = mlx5_ib_dereg_mr; + dev->ib_dev.attach_mcast = mlx5_ib_mcg_attach; + dev->ib_dev.detach_mcast = mlx5_ib_mcg_detach; + dev->ib_dev.process_mad = mlx5_ib_process_mad; + dev->ib_dev.alloc_fast_reg_mr = mlx5_ib_alloc_fast_reg_mr; + dev->ib_dev.alloc_fast_reg_page_list = mlx5_ib_alloc_fast_reg_page_list; + dev->ib_dev.free_fast_reg_page_list = mlx5_ib_free_fast_reg_page_list; + + if (mdev->caps.flags & MLX5_DEV_CAP_FLAG_XRC) { + dev->ib_dev.alloc_xrcd = mlx5_ib_alloc_xrcd; + dev->ib_dev.dealloc_xrcd = mlx5_ib_dealloc_xrcd; + dev->ib_dev.uverbs_cmd_mask |= + (1ull << IB_USER_VERBS_CMD_OPEN_XRCD) | + (1ull << IB_USER_VERBS_CMD_CLOSE_XRCD); + } + + err = init_node_data(dev); + if (err) + goto err_eqs; + + mutex_init(&dev->cap_mask_mutex); + spin_lock_init(&dev->mr_lock); + + err = create_dev_resources(&dev->devr); + if (err) + goto err_eqs; + + if (ib_register_device(&dev->ib_dev, NULL)) + goto err_rsrc; + + err = create_umr_res(dev); + if (err) + goto err_dev; + + for (i = 0; i < ARRAY_SIZE(mlx5_class_attributes); i++) { + if (device_create_file(&dev->ib_dev.dev, + mlx5_class_attributes[i])) + goto err_umrc; + } + + dev->ib_active = true; + + return 0; + +err_umrc: + destroy_umrc_res(dev); + +err_dev: + ib_unregister_device(&dev->ib_dev); + +err_rsrc: + destroy_dev_resources(&dev->devr); + +err_eqs: + free_comp_eqs(dev); + +err_cleanup: + mlx5_dev_cleanup(mdev); + +err_free: + ib_dealloc_device((struct ib_device *)dev); + + return err; +} + +static void remove_one(struct pci_dev *pdev) +{ + struct mlx5_ib_dev *dev = mlx5_pci2ibdev(pdev); + + destroy_umrc_res(dev); + ib_unregister_device(&dev->ib_dev); + destroy_dev_resources(&dev->devr); + free_comp_eqs(dev); + mlx5_dev_cleanup(&dev->mdev); + ib_dealloc_device(&dev->ib_dev); +} + +static DEFINE_PCI_DEVICE_TABLE(mlx5_ib_pci_table) = { + { PCI_VDEVICE(MELLANOX, 4113) }, /* MT4113 Connect-IB */ + { 0, } +}; + +MODULE_DEVICE_TABLE(pci, mlx5_ib_pci_table); + +static struct pci_driver mlx5_ib_driver = { + .name = DRIVER_NAME, + .id_table = mlx5_ib_pci_table, + .probe = init_one, + .remove = remove_one +}; + +static int __init mlx5_ib_init(void) +{ + return pci_register_driver(&mlx5_ib_driver); +} + +static void __exit mlx5_ib_cleanup(void) +{ + pci_unregister_driver(&mlx5_ib_driver); +} + +module_init(mlx5_ib_init); +module_exit(mlx5_ib_cleanup); diff --git a/drivers/infiniband/hw/mlx5/mem.c b/drivers/infiniband/hw/mlx5/mem.c new file mode 100644 index 000000000000..3a5322870b96 --- /dev/null +++ b/drivers/infiniband/hw/mlx5/mem.c @@ -0,0 +1,162 @@ +/* + * Copyright (c) 2013, Mellanox Technologies inc. All rights reserved. + * + * This software is available to you under a choice of one of two + * licenses. You may choose to be licensed under the terms of the GNU + * General Public License (GPL) Version 2, available from the file + * COPYING in the main directory of this source tree, or the + * OpenIB.org BSD license below: + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include +#include +#include "mlx5_ib.h" + +/* @umem: umem object to scan + * @addr: ib virtual address requested by the user + * @count: number of PAGE_SIZE pages covered by umem + * @shift: page shift for the compound pages found in the region + * @ncont: number of compund pages + * @order: log2 of the number of compound pages + */ +void mlx5_ib_cont_pages(struct ib_umem *umem, u64 addr, int *count, int *shift, + int *ncont, int *order) +{ + struct ib_umem_chunk *chunk; + unsigned long tmp; + unsigned long m; + int i, j, k; + u64 base = 0; + int p = 0; + int skip; + int mask; + u64 len; + u64 pfn; + + addr = addr >> PAGE_SHIFT; + tmp = (unsigned long)addr; + m = find_first_bit(&tmp, sizeof(tmp)); + skip = 1 << m; + mask = skip - 1; + i = 0; + list_for_each_entry(chunk, &umem->chunk_list, list) + for (j = 0; j < chunk->nmap; j++) { + len = sg_dma_len(&chunk->page_list[j]) >> PAGE_SHIFT; + pfn = sg_dma_address(&chunk->page_list[j]) >> PAGE_SHIFT; + for (k = 0; k < len; k++) { + if (!(i & mask)) { + tmp = (unsigned long)pfn; + m = min(m, find_first_bit(&tmp, sizeof(tmp))); + skip = 1 << m; + mask = skip - 1; + base = pfn; + p = 0; + } else { + if (base + p != pfn) { + tmp = (unsigned long)p; + m = find_first_bit(&tmp, sizeof(tmp)); + skip = 1 << m; + mask = skip - 1; + base = pfn; + p = 0; + } + } + p++; + i++; + } + } + + if (i) { + m = min_t(unsigned long, ilog2(roundup_pow_of_two(i)), m); + + if (order) + *order = ilog2(roundup_pow_of_two(i) >> m); + + *ncont = DIV_ROUND_UP(i, (1 << m)); + } else { + m = 0; + + if (order) + *order = 0; + + *ncont = 0; + } + *shift = PAGE_SHIFT + m; + *count = i; +} + +void mlx5_ib_populate_pas(struct mlx5_ib_dev *dev, struct ib_umem *umem, + int page_shift, __be64 *pas, int umr) +{ + int shift = page_shift - PAGE_SHIFT; + int mask = (1 << shift) - 1; + struct ib_umem_chunk *chunk; + int i, j, k; + u64 cur = 0; + u64 base; + int len; + + i = 0; + list_for_each_entry(chunk, &umem->chunk_list, list) + for (j = 0; j < chunk->nmap; j++) { + len = sg_dma_len(&chunk->page_list[j]) >> PAGE_SHIFT; + base = sg_dma_address(&chunk->page_list[j]); + for (k = 0; k < len; k++) { + if (!(i & mask)) { + cur = base + (k << PAGE_SHIFT); + if (umr) + cur |= 3; + + pas[i >> shift] = cpu_to_be64(cur); + mlx5_ib_dbg(dev, "pas[%d] 0x%llx\n", + i >> shift, be64_to_cpu(pas[i >> shift])); + } else + mlx5_ib_dbg(dev, "=====> 0x%llx\n", + base + (k << PAGE_SHIFT)); + i++; + } + } +} + +int mlx5_ib_get_buf_offset(u64 addr, int page_shift, u32 *offset) +{ + u64 page_size; + u64 page_mask; + u64 off_size; + u64 off_mask; + u64 buf_off; + + page_size = 1 << page_shift; + page_mask = page_size - 1; + buf_off = addr & page_mask; + off_size = page_size >> 6; + off_mask = off_size - 1; + + if (buf_off & off_mask) + return -EINVAL; + + *offset = buf_off >> ilog2(off_size); + return 0; +} diff --git a/drivers/infiniband/hw/mlx5/mlx5_ib.h b/drivers/infiniband/hw/mlx5/mlx5_ib.h new file mode 100644 index 000000000000..836be9157242 --- /dev/null +++ b/drivers/infiniband/hw/mlx5/mlx5_ib.h @@ -0,0 +1,545 @@ +/* + * Copyright (c) 2013, Mellanox Technologies inc. All rights reserved. + * + * This software is available to you under a choice of one of two + * licenses. You may choose to be licensed under the terms of the GNU + * General Public License (GPL) Version 2, available from the file + * COPYING in the main directory of this source tree, or the + * OpenIB.org BSD license below: + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#ifndef MLX5_IB_H +#define MLX5_IB_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define mlx5_ib_dbg(dev, format, arg...) \ +pr_debug("%s:%s:%d:(pid %d): " format, (dev)->ib_dev.name, __func__, \ + __LINE__, current->pid, ##arg) + +#define mlx5_ib_err(dev, format, arg...) \ +pr_err("%s:%s:%d:(pid %d): " format, (dev)->ib_dev.name, __func__, \ + __LINE__, current->pid, ##arg) + +#define mlx5_ib_warn(dev, format, arg...) \ +pr_warn("%s:%s:%d:(pid %d): " format, (dev)->ib_dev.name, __func__, \ + __LINE__, current->pid, ##arg) + +enum { + MLX5_IB_MMAP_CMD_SHIFT = 8, + MLX5_IB_MMAP_CMD_MASK = 0xff, +}; + +enum mlx5_ib_mmap_cmd { + MLX5_IB_MMAP_REGULAR_PAGE = 0, + MLX5_IB_MMAP_GET_CONTIGUOUS_PAGES = 1, /* always last */ +}; + +enum { + MLX5_RES_SCAT_DATA32_CQE = 0x1, + MLX5_RES_SCAT_DATA64_CQE = 0x2, + MLX5_REQ_SCAT_DATA32_CQE = 0x11, + MLX5_REQ_SCAT_DATA64_CQE = 0x22, +}; + +enum mlx5_ib_latency_class { + MLX5_IB_LATENCY_CLASS_LOW, + MLX5_IB_LATENCY_CLASS_MEDIUM, + MLX5_IB_LATENCY_CLASS_HIGH, + MLX5_IB_LATENCY_CLASS_FAST_PATH +}; + +enum mlx5_ib_mad_ifc_flags { + MLX5_MAD_IFC_IGNORE_MKEY = 1, + MLX5_MAD_IFC_IGNORE_BKEY = 2, + MLX5_MAD_IFC_NET_VIEW = 4, +}; + +struct mlx5_ib_ucontext { + struct ib_ucontext ibucontext; + struct list_head db_page_list; + + /* protect doorbell record alloc/free + */ + struct mutex db_page_mutex; + struct mlx5_uuar_info uuari; +}; + +static inline struct mlx5_ib_ucontext *to_mucontext(struct ib_ucontext *ibucontext) +{ + return container_of(ibucontext, struct mlx5_ib_ucontext, ibucontext); +} + +struct mlx5_ib_pd { + struct ib_pd ibpd; + u32 pdn; + u32 pa_lkey; +}; + +/* Use macros here so that don't have to duplicate + * enum ib_send_flags and enum ib_qp_type for low-level driver + */ + +#define MLX5_IB_SEND_UMR_UNREG IB_SEND_RESERVED_START +#define MLX5_IB_QPT_REG_UMR IB_QPT_RESERVED1 +#define MLX5_IB_WR_UMR IB_WR_RESERVED1 + +struct wr_list { + u16 opcode; + u16 next; +}; + +struct mlx5_ib_wq { + u64 *wrid; + u32 *wr_data; + struct wr_list *w_list; + unsigned *wqe_head; + u16 unsig_count; + + /* serialize post to the work queue + */ + spinlock_t lock; + int wqe_cnt; + int max_post; + int max_gs; + int offset; + int wqe_shift; + unsigned head; + unsigned tail; + u16 cur_post; + u16 last_poll; + void *qend; +}; + +enum { + MLX5_QP_USER, + MLX5_QP_KERNEL, + MLX5_QP_EMPTY +}; + +struct mlx5_ib_qp { + struct ib_qp ibqp; + struct mlx5_core_qp mqp; + struct mlx5_buf buf; + + struct mlx5_db db; + struct mlx5_ib_wq rq; + + u32 doorbell_qpn; + u8 sq_signal_bits; + u8 fm_cache; + int sq_max_wqes_per_wr; + int sq_spare_wqes; + struct mlx5_ib_wq sq; + + struct ib_umem *umem; + int buf_size; + + /* serialize qp state modifications + */ + struct mutex mutex; + u16 xrcdn; + u32 flags; + u8 port; + u8 alt_port; + u8 atomic_rd_en; + u8 resp_depth; + u8 state; + int mlx_type; + int wq_sig; + int scat_cqe; + int max_inline_data; + struct mlx5_bf *bf; + int has_rq; + + /* only for user space QPs. For kernel + * we have it from the bf object + */ + int uuarn; + + int create_type; + u32 pa_lkey; +}; + +struct mlx5_ib_cq_buf { + struct mlx5_buf buf; + struct ib_umem *umem; + int cqe_size; +}; + +enum mlx5_ib_qp_flags { + MLX5_IB_QP_BLOCK_MULTICAST_LOOPBACK = 1 << 0, + MLX5_IB_QP_SIGNATURE_HANDLING = 1 << 1, +}; + +struct mlx5_shared_mr_info { + int mr_id; + struct ib_umem *umem; +}; + +struct mlx5_ib_cq { + struct ib_cq ibcq; + struct mlx5_core_cq mcq; + struct mlx5_ib_cq_buf buf; + struct mlx5_db db; + + /* serialize access to the CQ + */ + spinlock_t lock; + + /* protect resize cq + */ + struct mutex resize_mutex; + struct mlx5_ib_cq_resize *resize_buf; + struct ib_umem *resize_umem; + int cqe_size; +}; + +struct mlx5_ib_srq { + struct ib_srq ibsrq; + struct mlx5_core_srq msrq; + struct mlx5_buf buf; + struct mlx5_db db; + u64 *wrid; + /* protect SRQ hanlding + */ + spinlock_t lock; + int head; + int tail; + u16 wqe_ctr; + struct ib_umem *umem; + /* serialize arming a SRQ + */ + struct mutex mutex; + int wq_sig; +}; + +struct mlx5_ib_xrcd { + struct ib_xrcd ibxrcd; + u32 xrcdn; +}; + +struct mlx5_ib_mr { + struct ib_mr ibmr; + struct mlx5_core_mr mmr; + struct ib_umem *umem; + struct mlx5_shared_mr_info *smr_info; + struct list_head list; + int order; + int umred; + __be64 *pas; + dma_addr_t dma; + int npages; + struct completion done; + enum ib_wc_status status; +}; + +struct mlx5_ib_fast_reg_page_list { + struct ib_fast_reg_page_list ibfrpl; + __be64 *mapped_page_list; + dma_addr_t map; +}; + +struct umr_common { + struct ib_pd *pd; + struct ib_cq *cq; + struct ib_qp *qp; + struct ib_mr *mr; + /* control access to UMR QP + */ + struct semaphore sem; +}; + +enum { + MLX5_FMR_INVALID, + MLX5_FMR_VALID, + MLX5_FMR_BUSY, +}; + +struct mlx5_ib_fmr { + struct ib_fmr ibfmr; + struct mlx5_core_mr mr; + int access_flags; + int state; + /* protect fmr state + */ + spinlock_t lock; + u64 wrid; + struct ib_send_wr wr[2]; + u8 page_shift; + struct ib_fast_reg_page_list page_list; +}; + +struct mlx5_cache_ent { + struct list_head head; + /* sync access to the cahce entry + */ + spinlock_t lock; + + + struct dentry *dir; + char name[4]; + u32 order; + u32 size; + u32 cur; + u32 miss; + u32 limit; + + struct dentry *fsize; + struct dentry *fcur; + struct dentry *fmiss; + struct dentry *flimit; + + struct mlx5_ib_dev *dev; + struct work_struct work; + struct delayed_work dwork; +}; + +struct mlx5_mr_cache { + struct workqueue_struct *wq; + struct mlx5_cache_ent ent[MAX_MR_CACHE_ENTRIES]; + int stopped; + struct dentry *root; + unsigned long last_add; +}; + +struct mlx5_ib_resources { + struct ib_cq *c0; + struct ib_xrcd *x0; + struct ib_xrcd *x1; + struct ib_pd *p0; + struct ib_srq *s0; +}; + +struct mlx5_ib_dev { + struct ib_device ib_dev; + struct mlx5_core_dev mdev; + MLX5_DECLARE_DOORBELL_LOCK(uar_lock); + struct list_head eqs_list; + int num_ports; + int num_comp_vectors; + /* serialize update of capability mask + */ + struct mutex cap_mask_mutex; + bool ib_active; + struct umr_common umrc; + /* sync used page count stats + */ + spinlock_t mr_lock; + struct mlx5_ib_resources devr; + struct mlx5_mr_cache cache; +}; + +static inline struct mlx5_ib_cq *to_mibcq(struct mlx5_core_cq *mcq) +{ + return container_of(mcq, struct mlx5_ib_cq, mcq); +} + +static inline struct mlx5_ib_xrcd *to_mxrcd(struct ib_xrcd *ibxrcd) +{ + return container_of(ibxrcd, struct mlx5_ib_xrcd, ibxrcd); +} + +static inline struct mlx5_ib_dev *to_mdev(struct ib_device *ibdev) +{ + return container_of(ibdev, struct mlx5_ib_dev, ib_dev); +} + +static inline struct mlx5_ib_fmr *to_mfmr(struct ib_fmr *ibfmr) +{ + return container_of(ibfmr, struct mlx5_ib_fmr, ibfmr); +} + +static inline struct mlx5_ib_cq *to_mcq(struct ib_cq *ibcq) +{ + return container_of(ibcq, struct mlx5_ib_cq, ibcq); +} + +static inline struct mlx5_ib_qp *to_mibqp(struct mlx5_core_qp *mqp) +{ + return container_of(mqp, struct mlx5_ib_qp, mqp); +} + +static inline struct mlx5_ib_pd *to_mpd(struct ib_pd *ibpd) +{ + return container_of(ibpd, struct mlx5_ib_pd, ibpd); +} + +static inline struct mlx5_ib_srq *to_msrq(struct ib_srq *ibsrq) +{ + return container_of(ibsrq, struct mlx5_ib_srq, ibsrq); +} + +static inline struct mlx5_ib_qp *to_mqp(struct ib_qp *ibqp) +{ + return container_of(ibqp, struct mlx5_ib_qp, ibqp); +} + +static inline struct mlx5_ib_srq *to_mibsrq(struct mlx5_core_srq *msrq) +{ + return container_of(msrq, struct mlx5_ib_srq, msrq); +} + +static inline struct mlx5_ib_mr *to_mmr(struct ib_mr *ibmr) +{ + return container_of(ibmr, struct mlx5_ib_mr, ibmr); +} + +static inline struct mlx5_ib_fast_reg_page_list *to_mfrpl(struct ib_fast_reg_page_list *ibfrpl) +{ + return container_of(ibfrpl, struct mlx5_ib_fast_reg_page_list, ibfrpl); +} + +struct mlx5_ib_ah { + struct ib_ah ibah; + struct mlx5_av av; +}; + +static inline struct mlx5_ib_ah *to_mah(struct ib_ah *ibah) +{ + return container_of(ibah, struct mlx5_ib_ah, ibah); +} + +static inline struct mlx5_ib_dev *mlx5_core2ibdev(struct mlx5_core_dev *dev) +{ + return container_of(dev, struct mlx5_ib_dev, mdev); +} + +static inline struct mlx5_ib_dev *mlx5_pci2ibdev(struct pci_dev *pdev) +{ + return mlx5_core2ibdev(pci2mlx5_core_dev(pdev)); +} + +int mlx5_ib_db_map_user(struct mlx5_ib_ucontext *context, unsigned long virt, + struct mlx5_db *db); +void mlx5_ib_db_unmap_user(struct mlx5_ib_ucontext *context, struct mlx5_db *db); +void __mlx5_ib_cq_clean(struct mlx5_ib_cq *cq, u32 qpn, struct mlx5_ib_srq *srq); +void mlx5_ib_cq_clean(struct mlx5_ib_cq *cq, u32 qpn, struct mlx5_ib_srq *srq); +void mlx5_ib_free_srq_wqe(struct mlx5_ib_srq *srq, int wqe_index); +int mlx5_MAD_IFC(struct mlx5_ib_dev *dev, int ignore_mkey, int ignore_bkey, + int port, struct ib_wc *in_wc, struct ib_grh *in_grh, + void *in_mad, void *response_mad); +struct ib_ah *create_ib_ah(struct ib_ah_attr *ah_attr, + struct mlx5_ib_ah *ah); +struct ib_ah *mlx5_ib_create_ah(struct ib_pd *pd, struct ib_ah_attr *ah_attr); +int mlx5_ib_query_ah(struct ib_ah *ibah, struct ib_ah_attr *ah_attr); +int mlx5_ib_destroy_ah(struct ib_ah *ah); +struct ib_srq *mlx5_ib_create_srq(struct ib_pd *pd, + struct ib_srq_init_attr *init_attr, + struct ib_udata *udata); +int mlx5_ib_modify_srq(struct ib_srq *ibsrq, struct ib_srq_attr *attr, + enum ib_srq_attr_mask attr_mask, struct ib_udata *udata); +int mlx5_ib_query_srq(struct ib_srq *ibsrq, struct ib_srq_attr *srq_attr); +int mlx5_ib_destroy_srq(struct ib_srq *srq); +int mlx5_ib_post_srq_recv(struct ib_srq *ibsrq, struct ib_recv_wr *wr, + struct ib_recv_wr **bad_wr); +struct ib_qp *mlx5_ib_create_qp(struct ib_pd *pd, + struct ib_qp_init_attr *init_attr, + struct ib_udata *udata); +int mlx5_ib_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, + int attr_mask, struct ib_udata *udata); +int mlx5_ib_query_qp(struct ib_qp *ibqp, struct ib_qp_attr *qp_attr, int qp_attr_mask, + struct ib_qp_init_attr *qp_init_attr); +int mlx5_ib_destroy_qp(struct ib_qp *qp); +int mlx5_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr, + struct ib_send_wr **bad_wr); +int mlx5_ib_post_recv(struct ib_qp *ibqp, struct ib_recv_wr *wr, + struct ib_recv_wr **bad_wr); +void *mlx5_get_send_wqe(struct mlx5_ib_qp *qp, int n); +struct ib_cq *mlx5_ib_create_cq(struct ib_device *ibdev, int entries, + int vector, struct ib_ucontext *context, + struct ib_udata *udata); +int mlx5_ib_destroy_cq(struct ib_cq *cq); +int mlx5_ib_poll_cq(struct ib_cq *ibcq, int num_entries, struct ib_wc *wc); +int mlx5_ib_arm_cq(struct ib_cq *ibcq, enum ib_cq_notify_flags flags); +int mlx5_ib_modify_cq(struct ib_cq *cq, u16 cq_count, u16 cq_period); +int mlx5_ib_resize_cq(struct ib_cq *ibcq, int entries, struct ib_udata *udata); +struct ib_mr *mlx5_ib_get_dma_mr(struct ib_pd *pd, int acc); +struct ib_mr *mlx5_ib_reg_user_mr(struct ib_pd *pd, u64 start, u64 length, + u64 virt_addr, int access_flags, + struct ib_udata *udata); +int mlx5_ib_dereg_mr(struct ib_mr *ibmr); +struct ib_mr *mlx5_ib_alloc_fast_reg_mr(struct ib_pd *pd, + int max_page_list_len); +struct ib_fast_reg_page_list *mlx5_ib_alloc_fast_reg_page_list(struct ib_device *ibdev, + int page_list_len); +void mlx5_ib_free_fast_reg_page_list(struct ib_fast_reg_page_list *page_list); +struct ib_fmr *mlx5_ib_fmr_alloc(struct ib_pd *pd, int acc, + struct ib_fmr_attr *fmr_attr); +int mlx5_ib_map_phys_fmr(struct ib_fmr *ibfmr, u64 *page_list, + int npages, u64 iova); +int mlx5_ib_unmap_fmr(struct list_head *fmr_list); +int mlx5_ib_fmr_dealloc(struct ib_fmr *ibfmr); +int mlx5_ib_process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num, + struct ib_wc *in_wc, struct ib_grh *in_grh, + struct ib_mad *in_mad, struct ib_mad *out_mad); +struct ib_xrcd *mlx5_ib_alloc_xrcd(struct ib_device *ibdev, + struct ib_ucontext *context, + struct ib_udata *udata); +int mlx5_ib_dealloc_xrcd(struct ib_xrcd *xrcd); +int mlx5_vector2eqn(struct mlx5_ib_dev *dev, int vector, int *eqn, int *irqn); +int mlx5_ib_get_buf_offset(u64 addr, int page_shift, u32 *offset); +int mlx5_query_ext_port_caps(struct mlx5_ib_dev *dev, u8 port); +int mlx5_ib_query_port(struct ib_device *ibdev, u8 port, + struct ib_port_attr *props); +int mlx5_ib_init_fmr(struct mlx5_ib_dev *dev); +void mlx5_ib_cleanup_fmr(struct mlx5_ib_dev *dev); +void mlx5_ib_cont_pages(struct ib_umem *umem, u64 addr, int *count, int *shift, + int *ncont, int *order); +void mlx5_ib_populate_pas(struct mlx5_ib_dev *dev, struct ib_umem *umem, + int page_shift, __be64 *pas, int umr); +void mlx5_ib_copy_pas(u64 *old, u64 *new, int step, int num); +int mlx5_ib_get_cqe_size(struct mlx5_ib_dev *dev, struct ib_cq *ibcq); +int mlx5_mr_cache_init(struct mlx5_ib_dev *dev); +int mlx5_mr_cache_cleanup(struct mlx5_ib_dev *dev); +int mlx5_mr_ib_cont_pages(struct ib_umem *umem, u64 addr, int *count, int *shift); +void mlx5_umr_cq_handler(struct ib_cq *cq, void *cq_context); + +static inline void init_query_mad(struct ib_smp *mad) +{ + mad->base_version = 1; + mad->mgmt_class = IB_MGMT_CLASS_SUBN_LID_ROUTED; + mad->class_version = 1; + mad->method = IB_MGMT_METHOD_GET; +} + +static inline u8 convert_access(int acc) +{ + return (acc & IB_ACCESS_REMOTE_ATOMIC ? MLX5_PERM_ATOMIC : 0) | + (acc & IB_ACCESS_REMOTE_WRITE ? MLX5_PERM_REMOTE_WRITE : 0) | + (acc & IB_ACCESS_REMOTE_READ ? MLX5_PERM_REMOTE_READ : 0) | + (acc & IB_ACCESS_LOCAL_WRITE ? MLX5_PERM_LOCAL_WRITE : 0) | + MLX5_PERM_LOCAL_READ; +} + +#endif /* MLX5_IB_H */ diff --git a/drivers/infiniband/hw/mlx5/mr.c b/drivers/infiniband/hw/mlx5/mr.c new file mode 100644 index 000000000000..e2daa8f02476 --- /dev/null +++ b/drivers/infiniband/hw/mlx5/mr.c @@ -0,0 +1,1007 @@ +/* + * Copyright (c) 2013, Mellanox Technologies inc. All rights reserved. + * + * This software is available to you under a choice of one of two + * licenses. You may choose to be licensed under the terms of the GNU + * General Public License (GPL) Version 2, available from the file + * COPYING in the main directory of this source tree, or the + * OpenIB.org BSD license below: + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + + +#include +#include +#include +#include +#include +#include "mlx5_ib.h" + +enum { + DEF_CACHE_SIZE = 10, +}; + +static __be64 *mr_align(__be64 *ptr, int align) +{ + unsigned long mask = align - 1; + + return (__be64 *)(((unsigned long)ptr + mask) & ~mask); +} + +static int order2idx(struct mlx5_ib_dev *dev, int order) +{ + struct mlx5_mr_cache *cache = &dev->cache; + + if (order < cache->ent[0].order) + return 0; + else + return order - cache->ent[0].order; +} + +static int add_keys(struct mlx5_ib_dev *dev, int c, int num) +{ + struct device *ddev = dev->ib_dev.dma_device; + struct mlx5_mr_cache *cache = &dev->cache; + struct mlx5_cache_ent *ent = &cache->ent[c]; + struct mlx5_create_mkey_mbox_in *in; + struct mlx5_ib_mr *mr; + int npages = 1 << ent->order; + int size = sizeof(u64) * npages; + int err = 0; + int i; + + in = kzalloc(sizeof(*in), GFP_KERNEL); + if (!in) + return -ENOMEM; + + for (i = 0; i < num; i++) { + mr = kzalloc(sizeof(*mr), GFP_KERNEL); + if (!mr) { + err = -ENOMEM; + goto out; + } + mr->order = ent->order; + mr->umred = 1; + mr->pas = kmalloc(size + 0x3f, GFP_KERNEL); + if (!mr->pas) { + kfree(mr); + err = -ENOMEM; + goto out; + } + mr->dma = dma_map_single(ddev, mr_align(mr->pas, 0x40), size, + DMA_TO_DEVICE); + if (dma_mapping_error(ddev, mr->dma)) { + kfree(mr->pas); + kfree(mr); + err = -ENOMEM; + goto out; + } + + in->seg.status = 1 << 6; + in->seg.xlt_oct_size = cpu_to_be32((npages + 1) / 2); + in->seg.qpn_mkey7_0 = cpu_to_be32(0xffffff << 8); + in->seg.flags = MLX5_ACCESS_MODE_MTT | MLX5_PERM_UMR_EN; + in->seg.log2_page_size = 12; + + err = mlx5_core_create_mkey(&dev->mdev, &mr->mmr, in, + sizeof(*in)); + if (err) { + mlx5_ib_warn(dev, "create mkey failed %d\n", err); + dma_unmap_single(ddev, mr->dma, size, DMA_TO_DEVICE); + kfree(mr->pas); + kfree(mr); + goto out; + } + cache->last_add = jiffies; + + spin_lock(&ent->lock); + list_add_tail(&mr->list, &ent->head); + ent->cur++; + ent->size++; + spin_unlock(&ent->lock); + } + +out: + kfree(in); + return err; +} + +static void remove_keys(struct mlx5_ib_dev *dev, int c, int num) +{ + struct device *ddev = dev->ib_dev.dma_device; + struct mlx5_mr_cache *cache = &dev->cache; + struct mlx5_cache_ent *ent = &cache->ent[c]; + struct mlx5_ib_mr *mr; + int size; + int err; + int i; + + for (i = 0; i < num; i++) { + spin_lock(&ent->lock); + if (list_empty(&ent->head)) { + spin_unlock(&ent->lock); + return; + } + mr = list_first_entry(&ent->head, struct mlx5_ib_mr, list); + list_del(&mr->list); + ent->cur--; + ent->size--; + spin_unlock(&ent->lock); + err = mlx5_core_destroy_mkey(&dev->mdev, &mr->mmr); + if (err) { + mlx5_ib_warn(dev, "failed destroy mkey\n"); + } else { + size = ALIGN(sizeof(u64) * (1 << mr->order), 0x40); + dma_unmap_single(ddev, mr->dma, size, DMA_TO_DEVICE); + kfree(mr->pas); + kfree(mr); + } + } +} + +static ssize_t size_write(struct file *filp, const char __user *buf, + size_t count, loff_t *pos) +{ + struct mlx5_cache_ent *ent = filp->private_data; + struct mlx5_ib_dev *dev = ent->dev; + char lbuf[20]; + u32 var; + int err; + int c; + + if (copy_from_user(lbuf, buf, sizeof(lbuf))) + return -EPERM; + + c = order2idx(dev, ent->order); + lbuf[sizeof(lbuf) - 1] = 0; + + if (sscanf(lbuf, "%u", &var) != 1) + return -EINVAL; + + if (var < ent->limit) + return -EINVAL; + + if (var > ent->size) { + err = add_keys(dev, c, var - ent->size); + if (err) + return err; + } else if (var < ent->size) { + remove_keys(dev, c, ent->size - var); + } + + return count; +} + +static ssize_t size_read(struct file *filp, char __user *buf, size_t count, + loff_t *pos) +{ + struct mlx5_cache_ent *ent = filp->private_data; + char lbuf[20]; + int err; + + if (*pos) + return 0; + + err = snprintf(lbuf, sizeof(lbuf), "%d\n", ent->size); + if (err < 0) + return err; + + if (copy_to_user(buf, lbuf, err)) + return -EPERM; + + *pos += err; + + return err; +} + +static const struct file_operations size_fops = { + .owner = THIS_MODULE, + .open = simple_open, + .write = size_write, + .read = size_read, +}; + +static ssize_t limit_write(struct file *filp, const char __user *buf, + size_t count, loff_t *pos) +{ + struct mlx5_cache_ent *ent = filp->private_data; + struct mlx5_ib_dev *dev = ent->dev; + char lbuf[20]; + u32 var; + int err; + int c; + + if (copy_from_user(lbuf, buf, sizeof(lbuf))) + return -EPERM; + + c = order2idx(dev, ent->order); + lbuf[sizeof(lbuf) - 1] = 0; + + if (sscanf(lbuf, "%u", &var) != 1) + return -EINVAL; + + if (var > ent->size) + return -EINVAL; + + ent->limit = var; + + if (ent->cur < ent->limit) { + err = add_keys(dev, c, 2 * ent->limit - ent->cur); + if (err) + return err; + } + + return count; +} + +static ssize_t limit_read(struct file *filp, char __user *buf, size_t count, + loff_t *pos) +{ + struct mlx5_cache_ent *ent = filp->private_data; + char lbuf[20]; + int err; + + if (*pos) + return 0; + + err = snprintf(lbuf, sizeof(lbuf), "%d\n", ent->limit); + if (err < 0) + return err; + + if (copy_to_user(buf, lbuf, err)) + return -EPERM; + + *pos += err; + + return err; +} + +static const struct file_operations limit_fops = { + .owner = THIS_MODULE, + .open = simple_open, + .write = limit_write, + .read = limit_read, +}; + +static int someone_adding(struct mlx5_mr_cache *cache) +{ + int i; + + for (i = 0; i < MAX_MR_CACHE_ENTRIES; i++) { + if (cache->ent[i].cur < cache->ent[i].limit) + return 1; + } + + return 0; +} + +static void __cache_work_func(struct mlx5_cache_ent *ent) +{ + struct mlx5_ib_dev *dev = ent->dev; + struct mlx5_mr_cache *cache = &dev->cache; + int i = order2idx(dev, ent->order); + + if (cache->stopped) + return; + + ent = &dev->cache.ent[i]; + if (ent->cur < 2 * ent->limit) { + add_keys(dev, i, 1); + if (ent->cur < 2 * ent->limit) + queue_work(cache->wq, &ent->work); + } else if (ent->cur > 2 * ent->limit) { + if (!someone_adding(cache) && + time_after(jiffies, cache->last_add + 60 * HZ)) { + remove_keys(dev, i, 1); + if (ent->cur > ent->limit) + queue_work(cache->wq, &ent->work); + } else { + queue_delayed_work(cache->wq, &ent->dwork, 60 * HZ); + } + } +} + +static void delayed_cache_work_func(struct work_struct *work) +{ + struct mlx5_cache_ent *ent; + + ent = container_of(work, struct mlx5_cache_ent, dwork.work); + __cache_work_func(ent); +} + +static void cache_work_func(struct work_struct *work) +{ + struct mlx5_cache_ent *ent; + + ent = container_of(work, struct mlx5_cache_ent, work); + __cache_work_func(ent); +} + +static struct mlx5_ib_mr *alloc_cached_mr(struct mlx5_ib_dev *dev, int order) +{ + struct mlx5_mr_cache *cache = &dev->cache; + struct mlx5_ib_mr *mr = NULL; + struct mlx5_cache_ent *ent; + int c; + int i; + + c = order2idx(dev, order); + if (c < 0 || c >= MAX_MR_CACHE_ENTRIES) { + mlx5_ib_warn(dev, "order %d, cache index %d\n", order, c); + return NULL; + } + + for (i = c; i < MAX_MR_CACHE_ENTRIES; i++) { + ent = &cache->ent[i]; + + mlx5_ib_dbg(dev, "order %d, cache index %d\n", ent->order, i); + + spin_lock(&ent->lock); + if (!list_empty(&ent->head)) { + mr = list_first_entry(&ent->head, struct mlx5_ib_mr, + list); + list_del(&mr->list); + ent->cur--; + spin_unlock(&ent->lock); + if (ent->cur < ent->limit) + queue_work(cache->wq, &ent->work); + break; + } + spin_unlock(&ent->lock); + + queue_work(cache->wq, &ent->work); + + if (mr) + break; + } + + if (!mr) + cache->ent[c].miss++; + + return mr; +} + +static void free_cached_mr(struct mlx5_ib_dev *dev, struct mlx5_ib_mr *mr) +{ + struct mlx5_mr_cache *cache = &dev->cache; + struct mlx5_cache_ent *ent; + int shrink = 0; + int c; + + c = order2idx(dev, mr->order); + if (c < 0 || c >= MAX_MR_CACHE_ENTRIES) { + mlx5_ib_warn(dev, "order %d, cache index %d\n", mr->order, c); + return; + } + ent = &cache->ent[c]; + spin_lock(&ent->lock); + list_add_tail(&mr->list, &ent->head); + ent->cur++; + if (ent->cur > 2 * ent->limit) + shrink = 1; + spin_unlock(&ent->lock); + + if (shrink) + queue_work(cache->wq, &ent->work); +} + +static void clean_keys(struct mlx5_ib_dev *dev, int c) +{ + struct device *ddev = dev->ib_dev.dma_device; + struct mlx5_mr_cache *cache = &dev->cache; + struct mlx5_cache_ent *ent = &cache->ent[c]; + struct mlx5_ib_mr *mr; + int size; + int err; + + while (1) { + spin_lock(&ent->lock); + if (list_empty(&ent->head)) { + spin_unlock(&ent->lock); + return; + } + mr = list_first_entry(&ent->head, struct mlx5_ib_mr, list); + list_del(&mr->list); + ent->cur--; + ent->size--; + spin_unlock(&ent->lock); + err = mlx5_core_destroy_mkey(&dev->mdev, &mr->mmr); + if (err) { + mlx5_ib_warn(dev, "failed destroy mkey\n"); + } else { + size = ALIGN(sizeof(u64) * (1 << mr->order), 0x40); + dma_unmap_single(ddev, mr->dma, size, DMA_TO_DEVICE); + kfree(mr->pas); + kfree(mr); + } + } +} + +static int mlx5_mr_cache_debugfs_init(struct mlx5_ib_dev *dev) +{ + struct mlx5_mr_cache *cache = &dev->cache; + struct mlx5_cache_ent *ent; + int i; + + if (!mlx5_debugfs_root) + return 0; + + cache->root = debugfs_create_dir("mr_cache", dev->mdev.priv.dbg_root); + if (!cache->root) + return -ENOMEM; + + for (i = 0; i < MAX_MR_CACHE_ENTRIES; i++) { + ent = &cache->ent[i]; + sprintf(ent->name, "%d", ent->order); + ent->dir = debugfs_create_dir(ent->name, cache->root); + if (!ent->dir) + return -ENOMEM; + + ent->fsize = debugfs_create_file("size", 0600, ent->dir, ent, + &size_fops); + if (!ent->fsize) + return -ENOMEM; + + ent->flimit = debugfs_create_file("limit", 0600, ent->dir, ent, + &limit_fops); + if (!ent->flimit) + return -ENOMEM; + + ent->fcur = debugfs_create_u32("cur", 0400, ent->dir, + &ent->cur); + if (!ent->fcur) + return -ENOMEM; + + ent->fmiss = debugfs_create_u32("miss", 0600, ent->dir, + &ent->miss); + if (!ent->fmiss) + return -ENOMEM; + } + + return 0; +} + +static void mlx5_mr_cache_debugfs_cleanup(struct mlx5_ib_dev *dev) +{ + if (!mlx5_debugfs_root) + return; + + debugfs_remove_recursive(dev->cache.root); +} + +int mlx5_mr_cache_init(struct mlx5_ib_dev *dev) +{ + struct mlx5_mr_cache *cache = &dev->cache; + struct mlx5_cache_ent *ent; + int limit; + int size; + int err; + int i; + + cache->wq = create_singlethread_workqueue("mkey_cache"); + if (!cache->wq) { + mlx5_ib_warn(dev, "failed to create work queue\n"); + return -ENOMEM; + } + + for (i = 0; i < MAX_MR_CACHE_ENTRIES; i++) { + INIT_LIST_HEAD(&cache->ent[i].head); + spin_lock_init(&cache->ent[i].lock); + + ent = &cache->ent[i]; + INIT_LIST_HEAD(&ent->head); + spin_lock_init(&ent->lock); + ent->order = i + 2; + ent->dev = dev; + + if (dev->mdev.profile->mask & MLX5_PROF_MASK_MR_CACHE) { + size = dev->mdev.profile->mr_cache[i].size; + limit = dev->mdev.profile->mr_cache[i].limit; + } else { + size = DEF_CACHE_SIZE; + limit = 0; + } + INIT_WORK(&ent->work, cache_work_func); + INIT_DELAYED_WORK(&ent->dwork, delayed_cache_work_func); + ent->limit = limit; + queue_work(cache->wq, &ent->work); + } + + err = mlx5_mr_cache_debugfs_init(dev); + if (err) + mlx5_ib_warn(dev, "cache debugfs failure\n"); + + return 0; +} + +int mlx5_mr_cache_cleanup(struct mlx5_ib_dev *dev) +{ + int i; + + dev->cache.stopped = 1; + destroy_workqueue(dev->cache.wq); + + mlx5_mr_cache_debugfs_cleanup(dev); + + for (i = 0; i < MAX_MR_CACHE_ENTRIES; i++) + clean_keys(dev, i); + + return 0; +} + +struct ib_mr *mlx5_ib_get_dma_mr(struct ib_pd *pd, int acc) +{ + struct mlx5_ib_dev *dev = to_mdev(pd->device); + struct mlx5_core_dev *mdev = &dev->mdev; + struct mlx5_create_mkey_mbox_in *in; + struct mlx5_mkey_seg *seg; + struct mlx5_ib_mr *mr; + int err; + + mr = kzalloc(sizeof(*mr), GFP_KERNEL); + if (!mr) + return ERR_PTR(-ENOMEM); + + in = kzalloc(sizeof(*in), GFP_KERNEL); + if (!in) { + err = -ENOMEM; + goto err_free; + } + + seg = &in->seg; + seg->flags = convert_access(acc) | MLX5_ACCESS_MODE_PA; + seg->flags_pd = cpu_to_be32(to_mpd(pd)->pdn | MLX5_MKEY_LEN64); + seg->qpn_mkey7_0 = cpu_to_be32(0xffffff << 8); + seg->start_addr = 0; + + err = mlx5_core_create_mkey(mdev, &mr->mmr, in, sizeof(*in)); + if (err) + goto err_in; + + kfree(in); + mr->ibmr.lkey = mr->mmr.key; + mr->ibmr.rkey = mr->mmr.key; + mr->umem = NULL; + + return &mr->ibmr; + +err_in: + kfree(in); + +err_free: + kfree(mr); + + return ERR_PTR(err); +} + +static int get_octo_len(u64 addr, u64 len, int page_size) +{ + u64 offset; + int npages; + + offset = addr & (page_size - 1); + npages = ALIGN(len + offset, page_size) >> ilog2(page_size); + return (npages + 1) / 2; +} + +static int use_umr(int order) +{ + return order <= 17; +} + +static void prep_umr_reg_wqe(struct ib_pd *pd, struct ib_send_wr *wr, + struct ib_sge *sg, u64 dma, int n, u32 key, + int page_shift, u64 virt_addr, u64 len, + int access_flags) +{ + struct mlx5_ib_dev *dev = to_mdev(pd->device); + struct ib_mr *mr = dev->umrc.mr; + + sg->addr = dma; + sg->length = ALIGN(sizeof(u64) * n, 64); + sg->lkey = mr->lkey; + + wr->next = NULL; + wr->send_flags = 0; + wr->sg_list = sg; + if (n) + wr->num_sge = 1; + else + wr->num_sge = 0; + + wr->opcode = MLX5_IB_WR_UMR; + wr->wr.fast_reg.page_list_len = n; + wr->wr.fast_reg.page_shift = page_shift; + wr->wr.fast_reg.rkey = key; + wr->wr.fast_reg.iova_start = virt_addr; + wr->wr.fast_reg.length = len; + wr->wr.fast_reg.access_flags = access_flags; + wr->wr.fast_reg.page_list = (struct ib_fast_reg_page_list *)pd; +} + +static void prep_umr_unreg_wqe(struct mlx5_ib_dev *dev, + struct ib_send_wr *wr, u32 key) +{ + wr->send_flags = MLX5_IB_SEND_UMR_UNREG; + wr->opcode = MLX5_IB_WR_UMR; + wr->wr.fast_reg.rkey = key; +} + +void mlx5_umr_cq_handler(struct ib_cq *cq, void *cq_context) +{ + struct mlx5_ib_mr *mr; + struct ib_wc wc; + int err; + + while (1) { + err = ib_poll_cq(cq, 1, &wc); + if (err < 0) { + pr_warn("poll cq error %d\n", err); + return; + } + if (err == 0) + break; + + mr = (struct mlx5_ib_mr *)(unsigned long)wc.wr_id; + mr->status = wc.status; + complete(&mr->done); + } + ib_req_notify_cq(cq, IB_CQ_NEXT_COMP); +} + +static struct mlx5_ib_mr *reg_umr(struct ib_pd *pd, struct ib_umem *umem, + u64 virt_addr, u64 len, int npages, + int page_shift, int order, int access_flags) +{ + struct mlx5_ib_dev *dev = to_mdev(pd->device); + struct umr_common *umrc = &dev->umrc; + struct ib_send_wr wr, *bad; + struct mlx5_ib_mr *mr; + struct ib_sge sg; + int err; + int i; + + for (i = 0; i < 10; i++) { + mr = alloc_cached_mr(dev, order); + if (mr) + break; + + err = add_keys(dev, order2idx(dev, order), 1); + if (err) { + mlx5_ib_warn(dev, "add_keys failed\n"); + break; + } + } + + if (!mr) + return ERR_PTR(-EAGAIN); + + mlx5_ib_populate_pas(dev, umem, page_shift, mr_align(mr->pas, 0x40), 1); + + memset(&wr, 0, sizeof(wr)); + wr.wr_id = (u64)(unsigned long)mr; + prep_umr_reg_wqe(pd, &wr, &sg, mr->dma, npages, mr->mmr.key, page_shift, virt_addr, len, access_flags); + + /* We serialize polls so one process does not kidnap another's + * completion. This is not a problem since wr is completed in + * around 1 usec + */ + down(&umrc->sem); + init_completion(&mr->done); + err = ib_post_send(umrc->qp, &wr, &bad); + if (err) { + mlx5_ib_warn(dev, "post send failed, err %d\n", err); + up(&umrc->sem); + goto error; + } + wait_for_completion(&mr->done); + up(&umrc->sem); + + if (mr->status != IB_WC_SUCCESS) { + mlx5_ib_warn(dev, "reg umr failed\n"); + err = -EFAULT; + goto error; + } + + return mr; + +error: + free_cached_mr(dev, mr); + return ERR_PTR(err); +} + +static struct mlx5_ib_mr *reg_create(struct ib_pd *pd, u64 virt_addr, + u64 length, struct ib_umem *umem, + int npages, int page_shift, + int access_flags) +{ + struct mlx5_ib_dev *dev = to_mdev(pd->device); + struct mlx5_create_mkey_mbox_in *in; + struct mlx5_ib_mr *mr; + int inlen; + int err; + + mr = kzalloc(sizeof(*mr), GFP_KERNEL); + if (!mr) + return ERR_PTR(-ENOMEM); + + inlen = sizeof(*in) + sizeof(*in->pas) * ((npages + 1) / 2) * 2; + in = mlx5_vzalloc(inlen); + if (!in) { + err = -ENOMEM; + goto err_1; + } + mlx5_ib_populate_pas(dev, umem, page_shift, in->pas, 0); + + in->seg.flags = convert_access(access_flags) | + MLX5_ACCESS_MODE_MTT; + in->seg.flags_pd = cpu_to_be32(to_mpd(pd)->pdn); + in->seg.start_addr = cpu_to_be64(virt_addr); + in->seg.len = cpu_to_be64(length); + in->seg.bsfs_octo_size = 0; + in->seg.xlt_oct_size = cpu_to_be32(get_octo_len(virt_addr, length, 1 << page_shift)); + in->seg.log2_page_size = page_shift; + in->seg.qpn_mkey7_0 = cpu_to_be32(0xffffff << 8); + in->xlat_oct_act_size = cpu_to_be32(get_octo_len(virt_addr, length, 1 << page_shift)); + err = mlx5_core_create_mkey(&dev->mdev, &mr->mmr, in, inlen); + if (err) { + mlx5_ib_warn(dev, "create mkey failed\n"); + goto err_2; + } + mr->umem = umem; + mlx5_vfree(in); + + mlx5_ib_dbg(dev, "mkey = 0x%x\n", mr->mmr.key); + + return mr; + +err_2: + mlx5_vfree(in); + +err_1: + kfree(mr); + + return ERR_PTR(err); +} + +struct ib_mr *mlx5_ib_reg_user_mr(struct ib_pd *pd, u64 start, u64 length, + u64 virt_addr, int access_flags, + struct ib_udata *udata) +{ + struct mlx5_ib_dev *dev = to_mdev(pd->device); + struct mlx5_ib_mr *mr = NULL; + struct ib_umem *umem; + int page_shift; + int npages; + int ncont; + int order; + int err; + + mlx5_ib_dbg(dev, "start 0x%llx, virt_addr 0x%llx, length 0x%llx\n", + start, virt_addr, length); + umem = ib_umem_get(pd->uobject->context, start, length, access_flags, + 0); + if (IS_ERR(umem)) { + mlx5_ib_dbg(dev, "umem get failed\n"); + return (void *)umem; + } + + mlx5_ib_cont_pages(umem, start, &npages, &page_shift, &ncont, &order); + if (!npages) { + mlx5_ib_warn(dev, "avoid zero region\n"); + err = -EINVAL; + goto error; + } + + mlx5_ib_dbg(dev, "npages %d, ncont %d, order %d, page_shift %d\n", + npages, ncont, order, page_shift); + + if (use_umr(order)) { + mr = reg_umr(pd, umem, virt_addr, length, ncont, page_shift, + order, access_flags); + if (PTR_ERR(mr) == -EAGAIN) { + mlx5_ib_dbg(dev, "cache empty for order %d", order); + mr = NULL; + } + } + + if (!mr) + mr = reg_create(pd, virt_addr, length, umem, ncont, page_shift, + access_flags); + + if (IS_ERR(mr)) { + err = PTR_ERR(mr); + goto error; + } + + mlx5_ib_dbg(dev, "mkey 0x%x\n", mr->mmr.key); + + mr->umem = umem; + mr->npages = npages; + spin_lock(&dev->mr_lock); + dev->mdev.priv.reg_pages += npages; + spin_unlock(&dev->mr_lock); + mr->ibmr.lkey = mr->mmr.key; + mr->ibmr.rkey = mr->mmr.key; + + return &mr->ibmr; + +error: + ib_umem_release(umem); + return ERR_PTR(err); +} + +static int unreg_umr(struct mlx5_ib_dev *dev, struct mlx5_ib_mr *mr) +{ + struct umr_common *umrc = &dev->umrc; + struct ib_send_wr wr, *bad; + int err; + + memset(&wr, 0, sizeof(wr)); + wr.wr_id = (u64)(unsigned long)mr; + prep_umr_unreg_wqe(dev, &wr, mr->mmr.key); + + down(&umrc->sem); + init_completion(&mr->done); + err = ib_post_send(umrc->qp, &wr, &bad); + if (err) { + up(&umrc->sem); + mlx5_ib_dbg(dev, "err %d\n", err); + goto error; + } + wait_for_completion(&mr->done); + up(&umrc->sem); + if (mr->status != IB_WC_SUCCESS) { + mlx5_ib_warn(dev, "unreg umr failed\n"); + err = -EFAULT; + goto error; + } + return 0; + +error: + return err; +} + +int mlx5_ib_dereg_mr(struct ib_mr *ibmr) +{ + struct mlx5_ib_dev *dev = to_mdev(ibmr->device); + struct mlx5_ib_mr *mr = to_mmr(ibmr); + struct ib_umem *umem = mr->umem; + int npages = mr->npages; + int umred = mr->umred; + int err; + + if (!umred) { + err = mlx5_core_destroy_mkey(&dev->mdev, &mr->mmr); + if (err) { + mlx5_ib_warn(dev, "failed to destroy mkey 0x%x (%d)\n", + mr->mmr.key, err); + return err; + } + } else { + err = unreg_umr(dev, mr); + if (err) { + mlx5_ib_warn(dev, "failed unregister\n"); + return err; + } + free_cached_mr(dev, mr); + } + + if (umem) { + ib_umem_release(umem); + spin_lock(&dev->mr_lock); + dev->mdev.priv.reg_pages -= npages; + spin_unlock(&dev->mr_lock); + } + + if (!umred) + kfree(mr); + + return 0; +} + +struct ib_mr *mlx5_ib_alloc_fast_reg_mr(struct ib_pd *pd, + int max_page_list_len) +{ + struct mlx5_ib_dev *dev = to_mdev(pd->device); + struct mlx5_create_mkey_mbox_in *in; + struct mlx5_ib_mr *mr; + int err; + + mr = kzalloc(sizeof(*mr), GFP_KERNEL); + if (!mr) + return ERR_PTR(-ENOMEM); + + in = kzalloc(sizeof(*in), GFP_KERNEL); + if (!in) { + err = -ENOMEM; + goto err_free; + } + + in->seg.status = 1 << 6; /* free */ + in->seg.xlt_oct_size = cpu_to_be32((max_page_list_len + 1) / 2); + in->seg.qpn_mkey7_0 = cpu_to_be32(0xffffff << 8); + in->seg.flags = MLX5_PERM_UMR_EN | MLX5_ACCESS_MODE_MTT; + in->seg.flags_pd = cpu_to_be32(to_mpd(pd)->pdn); + /* + * TBD not needed - issue 197292 */ + in->seg.log2_page_size = PAGE_SHIFT; + + err = mlx5_core_create_mkey(&dev->mdev, &mr->mmr, in, sizeof(*in)); + kfree(in); + if (err) + goto err_free; + + mr->ibmr.lkey = mr->mmr.key; + mr->ibmr.rkey = mr->mmr.key; + mr->umem = NULL; + + return &mr->ibmr; + +err_free: + kfree(mr); + return ERR_PTR(err); +} + +struct ib_fast_reg_page_list *mlx5_ib_alloc_fast_reg_page_list(struct ib_device *ibdev, + int page_list_len) +{ + struct mlx5_ib_fast_reg_page_list *mfrpl; + int size = page_list_len * sizeof(u64); + + mfrpl = kmalloc(sizeof(*mfrpl), GFP_KERNEL); + if (!mfrpl) + return ERR_PTR(-ENOMEM); + + mfrpl->ibfrpl.page_list = kmalloc(size, GFP_KERNEL); + if (!mfrpl->ibfrpl.page_list) + goto err_free; + + mfrpl->mapped_page_list = dma_alloc_coherent(ibdev->dma_device, + size, &mfrpl->map, + GFP_KERNEL); + if (!mfrpl->mapped_page_list) + goto err_free; + + WARN_ON(mfrpl->map & 0x3f); + + return &mfrpl->ibfrpl; + +err_free: + kfree(mfrpl->ibfrpl.page_list); + kfree(mfrpl); + return ERR_PTR(-ENOMEM); +} + +void mlx5_ib_free_fast_reg_page_list(struct ib_fast_reg_page_list *page_list) +{ + struct mlx5_ib_fast_reg_page_list *mfrpl = to_mfrpl(page_list); + struct mlx5_ib_dev *dev = to_mdev(page_list->device); + int size = page_list->max_page_list_len * sizeof(u64); + + dma_free_coherent(&dev->mdev.pdev->dev, size, mfrpl->mapped_page_list, + mfrpl->map); + kfree(mfrpl->ibfrpl.page_list); + kfree(mfrpl); +} diff --git a/drivers/infiniband/hw/mlx5/qp.c b/drivers/infiniband/hw/mlx5/qp.c new file mode 100644 index 000000000000..16ac54c9819f --- /dev/null +++ b/drivers/infiniband/hw/mlx5/qp.c @@ -0,0 +1,2524 @@ +/* + * Copyright (c) 2013, Mellanox Technologies inc. All rights reserved. + * + * This software is available to you under a choice of one of two + * licenses. You may choose to be licensed under the terms of the GNU + * General Public License (GPL) Version 2, available from the file + * COPYING in the main directory of this source tree, or the + * OpenIB.org BSD license below: + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include +#include +#include "mlx5_ib.h" +#include "user.h" + +/* not supported currently */ +static int wq_signature; + +enum { + MLX5_IB_ACK_REQ_FREQ = 8, +}; + +enum { + MLX5_IB_DEFAULT_SCHED_QUEUE = 0x83, + MLX5_IB_DEFAULT_QP0_SCHED_QUEUE = 0x3f, + MLX5_IB_LINK_TYPE_IB = 0, + MLX5_IB_LINK_TYPE_ETH = 1 +}; + +enum { + MLX5_IB_SQ_STRIDE = 6, + MLX5_IB_CACHE_LINE_SIZE = 64, +}; + +static const u32 mlx5_ib_opcode[] = { + [IB_WR_SEND] = MLX5_OPCODE_SEND, + [IB_WR_SEND_WITH_IMM] = MLX5_OPCODE_SEND_IMM, + [IB_WR_RDMA_WRITE] = MLX5_OPCODE_RDMA_WRITE, + [IB_WR_RDMA_WRITE_WITH_IMM] = MLX5_OPCODE_RDMA_WRITE_IMM, + [IB_WR_RDMA_READ] = MLX5_OPCODE_RDMA_READ, + [IB_WR_ATOMIC_CMP_AND_SWP] = MLX5_OPCODE_ATOMIC_CS, + [IB_WR_ATOMIC_FETCH_AND_ADD] = MLX5_OPCODE_ATOMIC_FA, + [IB_WR_SEND_WITH_INV] = MLX5_OPCODE_SEND_INVAL, + [IB_WR_LOCAL_INV] = MLX5_OPCODE_UMR, + [IB_WR_FAST_REG_MR] = MLX5_OPCODE_UMR, + [IB_WR_MASKED_ATOMIC_CMP_AND_SWP] = MLX5_OPCODE_ATOMIC_MASKED_CS, + [IB_WR_MASKED_ATOMIC_FETCH_AND_ADD] = MLX5_OPCODE_ATOMIC_MASKED_FA, + [MLX5_IB_WR_UMR] = MLX5_OPCODE_UMR, +}; + +struct umr_wr { + u64 virt_addr; + struct ib_pd *pd; + unsigned int page_shift; + unsigned int npages; + u32 length; + int access_flags; + u32 mkey; +}; + +static int is_qp0(enum ib_qp_type qp_type) +{ + return qp_type == IB_QPT_SMI; +} + +static int is_qp1(enum ib_qp_type qp_type) +{ + return qp_type == IB_QPT_GSI; +} + +static int is_sqp(enum ib_qp_type qp_type) +{ + return is_qp0(qp_type) || is_qp1(qp_type); +} + +static void *get_wqe(struct mlx5_ib_qp *qp, int offset) +{ + return mlx5_buf_offset(&qp->buf, offset); +} + +static void *get_recv_wqe(struct mlx5_ib_qp *qp, int n) +{ + return get_wqe(qp, qp->rq.offset + (n << qp->rq.wqe_shift)); +} + +void *mlx5_get_send_wqe(struct mlx5_ib_qp *qp, int n) +{ + return get_wqe(qp, qp->sq.offset + (n << MLX5_IB_SQ_STRIDE)); +} + +static void mlx5_ib_qp_event(struct mlx5_core_qp *qp, int type) +{ + struct ib_qp *ibqp = &to_mibqp(qp)->ibqp; + struct ib_event event; + + if (type == MLX5_EVENT_TYPE_PATH_MIG) + to_mibqp(qp)->port = to_mibqp(qp)->alt_port; + + if (ibqp->event_handler) { + event.device = ibqp->device; + event.element.qp = ibqp; + switch (type) { + case MLX5_EVENT_TYPE_PATH_MIG: + event.event = IB_EVENT_PATH_MIG; + break; + case MLX5_EVENT_TYPE_COMM_EST: + event.event = IB_EVENT_COMM_EST; + break; + case MLX5_EVENT_TYPE_SQ_DRAINED: + event.event = IB_EVENT_SQ_DRAINED; + break; + case MLX5_EVENT_TYPE_SRQ_LAST_WQE: + event.event = IB_EVENT_QP_LAST_WQE_REACHED; + break; + case MLX5_EVENT_TYPE_WQ_CATAS_ERROR: + event.event = IB_EVENT_QP_FATAL; + break; + case MLX5_EVENT_TYPE_PATH_MIG_FAILED: + event.event = IB_EVENT_PATH_MIG_ERR; + break; + case MLX5_EVENT_TYPE_WQ_INVAL_REQ_ERROR: + event.event = IB_EVENT_QP_REQ_ERR; + break; + case MLX5_EVENT_TYPE_WQ_ACCESS_ERROR: + event.event = IB_EVENT_QP_ACCESS_ERR; + break; + default: + pr_warn("mlx5_ib: Unexpected event type %d on QP %06x\n", type, qp->qpn); + return; + } + + ibqp->event_handler(&event, ibqp->qp_context); + } +} + +static int set_rq_size(struct mlx5_ib_dev *dev, struct ib_qp_cap *cap, + int has_rq, struct mlx5_ib_qp *qp, struct mlx5_ib_create_qp *ucmd) +{ + int wqe_size; + int wq_size; + + /* Sanity check RQ size before proceeding */ + if (cap->max_recv_wr > dev->mdev.caps.max_wqes) + return -EINVAL; + + if (!has_rq) { + qp->rq.max_gs = 0; + qp->rq.wqe_cnt = 0; + qp->rq.wqe_shift = 0; + } else { + if (ucmd) { + qp->rq.wqe_cnt = ucmd->rq_wqe_count; + qp->rq.wqe_shift = ucmd->rq_wqe_shift; + qp->rq.max_gs = (1 << qp->rq.wqe_shift) / sizeof(struct mlx5_wqe_data_seg) - qp->wq_sig; + qp->rq.max_post = qp->rq.wqe_cnt; + } else { + wqe_size = qp->wq_sig ? sizeof(struct mlx5_wqe_signature_seg) : 0; + wqe_size += cap->max_recv_sge * sizeof(struct mlx5_wqe_data_seg); + wqe_size = roundup_pow_of_two(wqe_size); + wq_size = roundup_pow_of_two(cap->max_recv_wr) * wqe_size; + wq_size = max_t(int, wq_size, MLX5_SEND_WQE_BB); + qp->rq.wqe_cnt = wq_size / wqe_size; + if (wqe_size > dev->mdev.caps.max_rq_desc_sz) { + mlx5_ib_dbg(dev, "wqe_size %d, max %d\n", + wqe_size, + dev->mdev.caps.max_rq_desc_sz); + return -EINVAL; + } + qp->rq.wqe_shift = ilog2(wqe_size); + qp->rq.max_gs = (1 << qp->rq.wqe_shift) / sizeof(struct mlx5_wqe_data_seg) - qp->wq_sig; + qp->rq.max_post = qp->rq.wqe_cnt; + } + } + + return 0; +} + +static int sq_overhead(enum ib_qp_type qp_type) +{ + int size; + + switch (qp_type) { + case IB_QPT_XRC_INI: + size = sizeof(struct mlx5_wqe_xrc_seg); + /* fall through */ + case IB_QPT_RC: + size += sizeof(struct mlx5_wqe_ctrl_seg) + + sizeof(struct mlx5_wqe_atomic_seg) + + sizeof(struct mlx5_wqe_raddr_seg); + break; + + case IB_QPT_UC: + size = sizeof(struct mlx5_wqe_ctrl_seg) + + sizeof(struct mlx5_wqe_raddr_seg); + break; + + case IB_QPT_UD: + case IB_QPT_SMI: + case IB_QPT_GSI: + size = sizeof(struct mlx5_wqe_ctrl_seg) + + sizeof(struct mlx5_wqe_datagram_seg); + break; + + case MLX5_IB_QPT_REG_UMR: + size = sizeof(struct mlx5_wqe_ctrl_seg) + + sizeof(struct mlx5_wqe_umr_ctrl_seg) + + sizeof(struct mlx5_mkey_seg); + break; + + default: + return -EINVAL; + } + + return size; +} + +static int calc_send_wqe(struct ib_qp_init_attr *attr) +{ + int inl_size = 0; + int size; + + size = sq_overhead(attr->qp_type); + if (size < 0) + return size; + + if (attr->cap.max_inline_data) { + inl_size = size + sizeof(struct mlx5_wqe_inline_seg) + + attr->cap.max_inline_data; + } + + size += attr->cap.max_send_sge * sizeof(struct mlx5_wqe_data_seg); + + return ALIGN(max_t(int, inl_size, size), MLX5_SEND_WQE_BB); +} + +static int calc_sq_size(struct mlx5_ib_dev *dev, struct ib_qp_init_attr *attr, + struct mlx5_ib_qp *qp) +{ + int wqe_size; + int wq_size; + + if (!attr->cap.max_send_wr) + return 0; + + wqe_size = calc_send_wqe(attr); + mlx5_ib_dbg(dev, "wqe_size %d\n", wqe_size); + if (wqe_size < 0) + return wqe_size; + + if (wqe_size > dev->mdev.caps.max_sq_desc_sz) { + mlx5_ib_dbg(dev, "\n"); + return -EINVAL; + } + + qp->max_inline_data = wqe_size - sq_overhead(attr->qp_type) - + sizeof(struct mlx5_wqe_inline_seg); + attr->cap.max_inline_data = qp->max_inline_data; + + wq_size = roundup_pow_of_two(attr->cap.max_send_wr * wqe_size); + qp->sq.wqe_cnt = wq_size / MLX5_SEND_WQE_BB; + qp->sq.wqe_shift = ilog2(MLX5_SEND_WQE_BB); + qp->sq.max_gs = attr->cap.max_send_sge; + qp->sq.max_post = 1 << ilog2(wq_size / wqe_size); + + return wq_size; +} + +static int set_user_buf_size(struct mlx5_ib_dev *dev, + struct mlx5_ib_qp *qp, + struct mlx5_ib_create_qp *ucmd) +{ + int desc_sz = 1 << qp->sq.wqe_shift; + + if (desc_sz > dev->mdev.caps.max_sq_desc_sz) { + mlx5_ib_warn(dev, "desc_sz %d, max_sq_desc_sz %d\n", + desc_sz, dev->mdev.caps.max_sq_desc_sz); + return -EINVAL; + } + + if (ucmd->sq_wqe_count && ((1 << ilog2(ucmd->sq_wqe_count)) != ucmd->sq_wqe_count)) { + mlx5_ib_warn(dev, "sq_wqe_count %d, sq_wqe_count %d\n", + ucmd->sq_wqe_count, ucmd->sq_wqe_count); + return -EINVAL; + } + + qp->sq.wqe_cnt = ucmd->sq_wqe_count; + + if (qp->sq.wqe_cnt > dev->mdev.caps.max_wqes) { + mlx5_ib_warn(dev, "wqe_cnt %d, max_wqes %d\n", + qp->sq.wqe_cnt, dev->mdev.caps.max_wqes); + return -EINVAL; + } + + qp->buf_size = (qp->rq.wqe_cnt << qp->rq.wqe_shift) + + (qp->sq.wqe_cnt << 6); + + return 0; +} + +static int qp_has_rq(struct ib_qp_init_attr *attr) +{ + if (attr->qp_type == IB_QPT_XRC_INI || + attr->qp_type == IB_QPT_XRC_TGT || attr->srq || + attr->qp_type == MLX5_IB_QPT_REG_UMR || + !attr->cap.max_recv_wr) + return 0; + + return 1; +} + +static int alloc_high_class_uuar(struct mlx5_uuar_info *uuari) +{ + int nuuars = uuari->num_uars * MLX5_BF_REGS_PER_PAGE; + int start_uuar; + int i; + + start_uuar = nuuars - uuari->num_low_latency_uuars; + for (i = start_uuar; i < nuuars; i++) { + if (!test_bit(i, uuari->bitmap)) { + set_bit(i, uuari->bitmap); + uuari->count[i]++; + return i; + } + } + + return -ENOMEM; +} + +static int alloc_med_class_uuar(struct mlx5_uuar_info *uuari) +{ + int nuuars = uuari->num_uars * MLX5_BF_REGS_PER_PAGE; + int minidx = 1; + int uuarn; + int end; + int i; + + end = nuuars - uuari->num_low_latency_uuars; + + for (i = 1; i < end; i++) { + uuarn = i & 3; + if (uuarn == 2 || uuarn == 3) + continue; + + if (uuari->count[i] < uuari->count[minidx]) + minidx = i; + } + + uuari->count[minidx]++; + return minidx; +} + +static int alloc_uuar(struct mlx5_uuar_info *uuari, + enum mlx5_ib_latency_class lat) +{ + int uuarn = -EINVAL; + + mutex_lock(&uuari->lock); + switch (lat) { + case MLX5_IB_LATENCY_CLASS_LOW: + uuarn = 0; + uuari->count[uuarn]++; + break; + + case MLX5_IB_LATENCY_CLASS_MEDIUM: + uuarn = alloc_med_class_uuar(uuari); + break; + + case MLX5_IB_LATENCY_CLASS_HIGH: + uuarn = alloc_high_class_uuar(uuari); + break; + + case MLX5_IB_LATENCY_CLASS_FAST_PATH: + uuarn = 2; + break; + } + mutex_unlock(&uuari->lock); + + return uuarn; +} + +static void free_med_class_uuar(struct mlx5_uuar_info *uuari, int uuarn) +{ + clear_bit(uuarn, uuari->bitmap); + --uuari->count[uuarn]; +} + +static void free_high_class_uuar(struct mlx5_uuar_info *uuari, int uuarn) +{ + clear_bit(uuarn, uuari->bitmap); + --uuari->count[uuarn]; +} + +static void free_uuar(struct mlx5_uuar_info *uuari, int uuarn) +{ + int nuuars = uuari->num_uars * MLX5_BF_REGS_PER_PAGE; + int high_uuar = nuuars - uuari->num_low_latency_uuars; + + mutex_lock(&uuari->lock); + if (uuarn == 0) { + --uuari->count[uuarn]; + goto out; + } + + if (uuarn < high_uuar) { + free_med_class_uuar(uuari, uuarn); + goto out; + } + + free_high_class_uuar(uuari, uuarn); + +out: + mutex_unlock(&uuari->lock); +} + +static enum mlx5_qp_state to_mlx5_state(enum ib_qp_state state) +{ + switch (state) { + case IB_QPS_RESET: return MLX5_QP_STATE_RST; + case IB_QPS_INIT: return MLX5_QP_STATE_INIT; + case IB_QPS_RTR: return MLX5_QP_STATE_RTR; + case IB_QPS_RTS: return MLX5_QP_STATE_RTS; + case IB_QPS_SQD: return MLX5_QP_STATE_SQD; + case IB_QPS_SQE: return MLX5_QP_STATE_SQER; + case IB_QPS_ERR: return MLX5_QP_STATE_ERR; + default: return -1; + } +} + +static int to_mlx5_st(enum ib_qp_type type) +{ + switch (type) { + case IB_QPT_RC: return MLX5_QP_ST_RC; + case IB_QPT_UC: return MLX5_QP_ST_UC; + case IB_QPT_UD: return MLX5_QP_ST_UD; + case MLX5_IB_QPT_REG_UMR: return MLX5_QP_ST_REG_UMR; + case IB_QPT_XRC_INI: + case IB_QPT_XRC_TGT: return MLX5_QP_ST_XRC; + case IB_QPT_SMI: return MLX5_QP_ST_QP0; + case IB_QPT_GSI: return MLX5_QP_ST_QP1; + case IB_QPT_RAW_IPV6: return MLX5_QP_ST_RAW_IPV6; + case IB_QPT_RAW_ETHERTYPE: return MLX5_QP_ST_RAW_ETHERTYPE; + case IB_QPT_RAW_PACKET: + case IB_QPT_MAX: + default: return -EINVAL; + } +} + +static int uuarn_to_uar_index(struct mlx5_uuar_info *uuari, int uuarn) +{ + return uuari->uars[uuarn / MLX5_BF_REGS_PER_PAGE].index; +} + +static int create_user_qp(struct mlx5_ib_dev *dev, struct ib_pd *pd, + struct mlx5_ib_qp *qp, struct ib_udata *udata, + struct mlx5_create_qp_mbox_in **in, + struct mlx5_ib_create_qp_resp *resp, int *inlen) +{ + struct mlx5_ib_ucontext *context; + struct mlx5_ib_create_qp ucmd; + int page_shift; + int uar_index; + int npages; + u32 offset; + int uuarn; + int ncont; + int err; + + err = ib_copy_from_udata(&ucmd, udata, sizeof(ucmd)); + if (err) { + mlx5_ib_dbg(dev, "copy failed\n"); + return err; + } + + context = to_mucontext(pd->uobject->context); + /* + * TBD: should come from the verbs when we have the API + */ + uuarn = alloc_uuar(&context->uuari, MLX5_IB_LATENCY_CLASS_HIGH); + if (uuarn < 0) { + mlx5_ib_dbg(dev, "failed to allocate low latency UUAR\n"); + mlx5_ib_dbg(dev, "reverting to high latency\n"); + uuarn = alloc_uuar(&context->uuari, MLX5_IB_LATENCY_CLASS_LOW); + if (uuarn < 0) { + mlx5_ib_dbg(dev, "uuar allocation failed\n"); + return uuarn; + } + } + + uar_index = uuarn_to_uar_index(&context->uuari, uuarn); + mlx5_ib_dbg(dev, "uuarn 0x%x, uar_index 0x%x\n", uuarn, uar_index); + + err = set_user_buf_size(dev, qp, &ucmd); + if (err) + goto err_uuar; + + qp->umem = ib_umem_get(pd->uobject->context, ucmd.buf_addr, + qp->buf_size, 0, 0); + if (IS_ERR(qp->umem)) { + mlx5_ib_dbg(dev, "umem_get failed\n"); + err = PTR_ERR(qp->umem); + goto err_uuar; + } + + mlx5_ib_cont_pages(qp->umem, ucmd.buf_addr, &npages, &page_shift, + &ncont, NULL); + err = mlx5_ib_get_buf_offset(ucmd.buf_addr, page_shift, &offset); + if (err) { + mlx5_ib_warn(dev, "bad offset\n"); + goto err_umem; + } + mlx5_ib_dbg(dev, "addr 0x%llx, size %d, npages %d, page_shift %d, ncont %d, offset %d\n", + ucmd.buf_addr, qp->buf_size, npages, page_shift, ncont, offset); + + *inlen = sizeof(**in) + sizeof(*(*in)->pas) * ncont; + *in = mlx5_vzalloc(*inlen); + if (!*in) { + err = -ENOMEM; + goto err_umem; + } + mlx5_ib_populate_pas(dev, qp->umem, page_shift, (*in)->pas, 0); + (*in)->ctx.log_pg_sz_remote_qpn = + cpu_to_be32((page_shift - PAGE_SHIFT) << 24); + (*in)->ctx.params2 = cpu_to_be32(offset << 6); + + (*in)->ctx.qp_counter_set_usr_page = cpu_to_be32(uar_index); + resp->uuar_index = uuarn; + qp->uuarn = uuarn; + + err = mlx5_ib_db_map_user(context, ucmd.db_addr, &qp->db); + if (err) { + mlx5_ib_dbg(dev, "map failed\n"); + goto err_free; + } + + err = ib_copy_to_udata(udata, resp, sizeof(*resp)); + if (err) { + mlx5_ib_dbg(dev, "copy failed\n"); + goto err_unmap; + } + qp->create_type = MLX5_QP_USER; + + return 0; + +err_unmap: + mlx5_ib_db_unmap_user(context, &qp->db); + +err_free: + mlx5_vfree(*in); + +err_umem: + ib_umem_release(qp->umem); + +err_uuar: + free_uuar(&context->uuari, uuarn); + return err; +} + +static void destroy_qp_user(struct ib_pd *pd, struct mlx5_ib_qp *qp) +{ + struct mlx5_ib_ucontext *context; + + context = to_mucontext(pd->uobject->context); + mlx5_ib_db_unmap_user(context, &qp->db); + ib_umem_release(qp->umem); + free_uuar(&context->uuari, qp->uuarn); +} + +static int create_kernel_qp(struct mlx5_ib_dev *dev, + struct ib_qp_init_attr *init_attr, + struct mlx5_ib_qp *qp, + struct mlx5_create_qp_mbox_in **in, int *inlen) +{ + enum mlx5_ib_latency_class lc = MLX5_IB_LATENCY_CLASS_LOW; + struct mlx5_uuar_info *uuari; + int uar_index; + int uuarn; + int err; + + uuari = &dev->mdev.priv.uuari; + if (init_attr->create_flags & IB_QP_CREATE_BLOCK_MULTICAST_LOOPBACK) + qp->flags |= MLX5_IB_QP_BLOCK_MULTICAST_LOOPBACK; + + if (init_attr->qp_type == MLX5_IB_QPT_REG_UMR) + lc = MLX5_IB_LATENCY_CLASS_FAST_PATH; + + uuarn = alloc_uuar(uuari, lc); + if (uuarn < 0) { + mlx5_ib_dbg(dev, "\n"); + return -ENOMEM; + } + + qp->bf = &uuari->bfs[uuarn]; + uar_index = qp->bf->uar->index; + + err = calc_sq_size(dev, init_attr, qp); + if (err < 0) { + mlx5_ib_dbg(dev, "err %d\n", err); + goto err_uuar; + } + + qp->rq.offset = 0; + qp->sq.offset = qp->rq.wqe_cnt << qp->rq.wqe_shift; + qp->buf_size = err + (qp->rq.wqe_cnt << qp->rq.wqe_shift); + + err = mlx5_buf_alloc(&dev->mdev, qp->buf_size, PAGE_SIZE * 2, &qp->buf); + if (err) { + mlx5_ib_dbg(dev, "err %d\n", err); + goto err_uuar; + } + + qp->sq.qend = mlx5_get_send_wqe(qp, qp->sq.wqe_cnt); + *inlen = sizeof(**in) + sizeof(*(*in)->pas) * qp->buf.npages; + *in = mlx5_vzalloc(*inlen); + if (!*in) { + err = -ENOMEM; + goto err_buf; + } + (*in)->ctx.qp_counter_set_usr_page = cpu_to_be32(uar_index); + (*in)->ctx.log_pg_sz_remote_qpn = cpu_to_be32((qp->buf.page_shift - PAGE_SHIFT) << 24); + /* Set "fast registration enabled" for all kernel QPs */ + (*in)->ctx.params1 |= cpu_to_be32(1 << 11); + (*in)->ctx.sq_crq_size |= cpu_to_be16(1 << 4); + + mlx5_fill_page_array(&qp->buf, (*in)->pas); + + err = mlx5_db_alloc(&dev->mdev, &qp->db); + if (err) { + mlx5_ib_dbg(dev, "err %d\n", err); + goto err_free; + } + + qp->db.db[0] = 0; + qp->db.db[1] = 0; + + qp->sq.wrid = kmalloc(qp->sq.wqe_cnt * sizeof(*qp->sq.wrid), GFP_KERNEL); + qp->sq.wr_data = kmalloc(qp->sq.wqe_cnt * sizeof(*qp->sq.wr_data), GFP_KERNEL); + qp->rq.wrid = kmalloc(qp->rq.wqe_cnt * sizeof(*qp->rq.wrid), GFP_KERNEL); + qp->sq.w_list = kmalloc(qp->sq.wqe_cnt * sizeof(*qp->sq.w_list), GFP_KERNEL); + qp->sq.wqe_head = kmalloc(qp->sq.wqe_cnt * sizeof(*qp->sq.wqe_head), GFP_KERNEL); + + if (!qp->sq.wrid || !qp->sq.wr_data || !qp->rq.wrid || + !qp->sq.w_list || !qp->sq.wqe_head) { + err = -ENOMEM; + goto err_wrid; + } + qp->create_type = MLX5_QP_KERNEL; + + return 0; + +err_wrid: + mlx5_db_free(&dev->mdev, &qp->db); + kfree(qp->sq.wqe_head); + kfree(qp->sq.w_list); + kfree(qp->sq.wrid); + kfree(qp->sq.wr_data); + kfree(qp->rq.wrid); + +err_free: + mlx5_vfree(*in); + +err_buf: + mlx5_buf_free(&dev->mdev, &qp->buf); + +err_uuar: + free_uuar(&dev->mdev.priv.uuari, uuarn); + return err; +} + +static void destroy_qp_kernel(struct mlx5_ib_dev *dev, struct mlx5_ib_qp *qp) +{ + mlx5_db_free(&dev->mdev, &qp->db); + kfree(qp->sq.wqe_head); + kfree(qp->sq.w_list); + kfree(qp->sq.wrid); + kfree(qp->sq.wr_data); + kfree(qp->rq.wrid); + mlx5_buf_free(&dev->mdev, &qp->buf); + free_uuar(&dev->mdev.priv.uuari, qp->bf->uuarn); +} + +static __be32 get_rx_type(struct mlx5_ib_qp *qp, struct ib_qp_init_attr *attr) +{ + if (attr->srq || (attr->qp_type == IB_QPT_XRC_TGT) || + (attr->qp_type == IB_QPT_XRC_INI)) + return cpu_to_be32(MLX5_SRQ_RQ); + else if (!qp->has_rq) + return cpu_to_be32(MLX5_ZERO_LEN_RQ); + else + return cpu_to_be32(MLX5_NON_ZERO_RQ); +} + +static int is_connected(enum ib_qp_type qp_type) +{ + if (qp_type == IB_QPT_RC || qp_type == IB_QPT_UC) + return 1; + + return 0; +} + +static int create_qp_common(struct mlx5_ib_dev *dev, struct ib_pd *pd, + struct ib_qp_init_attr *init_attr, + struct ib_udata *udata, struct mlx5_ib_qp *qp) +{ + struct mlx5_ib_resources *devr = &dev->devr; + struct mlx5_ib_create_qp_resp resp; + struct mlx5_create_qp_mbox_in *in; + struct mlx5_ib_create_qp ucmd; + int inlen = sizeof(*in); + int err; + + mutex_init(&qp->mutex); + spin_lock_init(&qp->sq.lock); + spin_lock_init(&qp->rq.lock); + + if (init_attr->sq_sig_type == IB_SIGNAL_ALL_WR) + qp->sq_signal_bits = MLX5_WQE_CTRL_CQ_UPDATE; + + if (pd && pd->uobject) { + if (ib_copy_from_udata(&ucmd, udata, sizeof(ucmd))) { + mlx5_ib_dbg(dev, "copy failed\n"); + return -EFAULT; + } + + qp->wq_sig = !!(ucmd.flags & MLX5_QP_FLAG_SIGNATURE); + qp->scat_cqe = !!(ucmd.flags & MLX5_QP_FLAG_SCATTER_CQE); + } else { + qp->wq_sig = !!wq_signature; + } + + qp->has_rq = qp_has_rq(init_attr); + err = set_rq_size(dev, &init_attr->cap, qp->has_rq, + qp, (pd && pd->uobject) ? &ucmd : NULL); + if (err) { + mlx5_ib_dbg(dev, "err %d\n", err); + return err; + } + + if (pd) { + if (pd->uobject) { + mlx5_ib_dbg(dev, "requested sq_wqe_count (%d)\n", ucmd.sq_wqe_count); + if (ucmd.rq_wqe_shift != qp->rq.wqe_shift || + ucmd.rq_wqe_count != qp->rq.wqe_cnt) { + mlx5_ib_dbg(dev, "invalid rq params\n"); + return -EINVAL; + } + if (ucmd.sq_wqe_count > dev->mdev.caps.max_wqes) { + mlx5_ib_dbg(dev, "requested sq_wqe_count (%d) > max allowed (%d)\n", + ucmd.sq_wqe_count, dev->mdev.caps.max_wqes); + return -EINVAL; + } + err = create_user_qp(dev, pd, qp, udata, &in, &resp, &inlen); + if (err) + mlx5_ib_dbg(dev, "err %d\n", err); + } else { + err = create_kernel_qp(dev, init_attr, qp, &in, &inlen); + if (err) + mlx5_ib_dbg(dev, "err %d\n", err); + else + qp->pa_lkey = to_mpd(pd)->pa_lkey; + } + + if (err) + return err; + } else { + in = mlx5_vzalloc(sizeof(*in)); + if (!in) + return -ENOMEM; + + qp->create_type = MLX5_QP_EMPTY; + } + + if (is_sqp(init_attr->qp_type)) + qp->port = init_attr->port_num; + + in->ctx.flags = cpu_to_be32(to_mlx5_st(init_attr->qp_type) << 16 | + MLX5_QP_PM_MIGRATED << 11); + + if (init_attr->qp_type != MLX5_IB_QPT_REG_UMR) + in->ctx.flags_pd = cpu_to_be32(to_mpd(pd ? pd : devr->p0)->pdn); + else + in->ctx.flags_pd = cpu_to_be32(MLX5_QP_LAT_SENSITIVE); + + if (qp->wq_sig) + in->ctx.flags_pd |= cpu_to_be32(MLX5_QP_ENABLE_SIG); + + if (qp->scat_cqe && is_connected(init_attr->qp_type)) { + int rcqe_sz; + int scqe_sz; + + rcqe_sz = mlx5_ib_get_cqe_size(dev, init_attr->recv_cq); + scqe_sz = mlx5_ib_get_cqe_size(dev, init_attr->send_cq); + + if (rcqe_sz == 128) + in->ctx.cs_res = MLX5_RES_SCAT_DATA64_CQE; + else + in->ctx.cs_res = MLX5_RES_SCAT_DATA32_CQE; + + if (init_attr->sq_sig_type == IB_SIGNAL_ALL_WR) { + if (scqe_sz == 128) + in->ctx.cs_req = MLX5_REQ_SCAT_DATA64_CQE; + else + in->ctx.cs_req = MLX5_REQ_SCAT_DATA32_CQE; + } + } + + if (qp->rq.wqe_cnt) { + in->ctx.rq_size_stride = (qp->rq.wqe_shift - 4); + in->ctx.rq_size_stride |= ilog2(qp->rq.wqe_cnt) << 3; + } + + in->ctx.rq_type_srqn = get_rx_type(qp, init_attr); + + if (qp->sq.wqe_cnt) + in->ctx.sq_crq_size |= cpu_to_be16(ilog2(qp->sq.wqe_cnt) << 11); + else + in->ctx.sq_crq_size |= cpu_to_be16(0x8000); + + /* Set default resources */ + switch (init_attr->qp_type) { + case IB_QPT_XRC_TGT: + in->ctx.cqn_recv = cpu_to_be32(to_mcq(devr->c0)->mcq.cqn); + in->ctx.cqn_send = cpu_to_be32(to_mcq(devr->c0)->mcq.cqn); + in->ctx.rq_type_srqn |= cpu_to_be32(to_msrq(devr->s0)->msrq.srqn); + in->ctx.xrcd = cpu_to_be32(to_mxrcd(init_attr->xrcd)->xrcdn); + break; + case IB_QPT_XRC_INI: + in->ctx.cqn_recv = cpu_to_be32(to_mcq(devr->c0)->mcq.cqn); + in->ctx.xrcd = cpu_to_be32(to_mxrcd(devr->x1)->xrcdn); + in->ctx.rq_type_srqn |= cpu_to_be32(to_msrq(devr->s0)->msrq.srqn); + break; + default: + if (init_attr->srq) { + in->ctx.xrcd = cpu_to_be32(to_mxrcd(devr->x0)->xrcdn); + in->ctx.rq_type_srqn |= cpu_to_be32(to_msrq(init_attr->srq)->msrq.srqn); + } else { + in->ctx.xrcd = cpu_to_be32(to_mxrcd(devr->x1)->xrcdn); + in->ctx.rq_type_srqn |= cpu_to_be32(to_msrq(devr->s0)->msrq.srqn); + } + } + + if (init_attr->send_cq) + in->ctx.cqn_send = cpu_to_be32(to_mcq(init_attr->send_cq)->mcq.cqn); + + if (init_attr->recv_cq) + in->ctx.cqn_recv = cpu_to_be32(to_mcq(init_attr->recv_cq)->mcq.cqn); + + in->ctx.db_rec_addr = cpu_to_be64(qp->db.dma); + + err = mlx5_core_create_qp(&dev->mdev, &qp->mqp, in, inlen); + if (err) { + mlx5_ib_dbg(dev, "create qp failed\n"); + goto err_create; + } + + mlx5_vfree(in); + /* Hardware wants QPN written in big-endian order (after + * shifting) for send doorbell. Precompute this value to save + * a little bit when posting sends. + */ + qp->doorbell_qpn = swab32(qp->mqp.qpn << 8); + + qp->mqp.event = mlx5_ib_qp_event; + + return 0; + +err_create: + if (qp->create_type == MLX5_QP_USER) + destroy_qp_user(pd, qp); + else if (qp->create_type == MLX5_QP_KERNEL) + destroy_qp_kernel(dev, qp); + + mlx5_vfree(in); + return err; +} + +static void mlx5_ib_lock_cqs(struct mlx5_ib_cq *send_cq, struct mlx5_ib_cq *recv_cq) + __acquires(&send_cq->lock) __acquires(&recv_cq->lock) +{ + if (send_cq) { + if (recv_cq) { + if (send_cq->mcq.cqn < recv_cq->mcq.cqn) { + spin_lock_irq(&send_cq->lock); + spin_lock_nested(&recv_cq->lock, + SINGLE_DEPTH_NESTING); + } else if (send_cq->mcq.cqn == recv_cq->mcq.cqn) { + spin_lock_irq(&send_cq->lock); + __acquire(&recv_cq->lock); + } else { + spin_lock_irq(&recv_cq->lock); + spin_lock_nested(&send_cq->lock, + SINGLE_DEPTH_NESTING); + } + } else { + spin_lock_irq(&send_cq->lock); + } + } else if (recv_cq) { + spin_lock_irq(&recv_cq->lock); + } +} + +static void mlx5_ib_unlock_cqs(struct mlx5_ib_cq *send_cq, struct mlx5_ib_cq *recv_cq) + __releases(&send_cq->lock) __releases(&recv_cq->lock) +{ + if (send_cq) { + if (recv_cq) { + if (send_cq->mcq.cqn < recv_cq->mcq.cqn) { + spin_unlock(&recv_cq->lock); + spin_unlock_irq(&send_cq->lock); + } else if (send_cq->mcq.cqn == recv_cq->mcq.cqn) { + __release(&recv_cq->lock); + spin_unlock_irq(&send_cq->lock); + } else { + spin_unlock(&send_cq->lock); + spin_unlock_irq(&recv_cq->lock); + } + } else { + spin_unlock_irq(&send_cq->lock); + } + } else if (recv_cq) { + spin_unlock_irq(&recv_cq->lock); + } +} + +static struct mlx5_ib_pd *get_pd(struct mlx5_ib_qp *qp) +{ + return to_mpd(qp->ibqp.pd); +} + +static void get_cqs(struct mlx5_ib_qp *qp, + struct mlx5_ib_cq **send_cq, struct mlx5_ib_cq **recv_cq) +{ + switch (qp->ibqp.qp_type) { + case IB_QPT_XRC_TGT: + *send_cq = NULL; + *recv_cq = NULL; + break; + case MLX5_IB_QPT_REG_UMR: + case IB_QPT_XRC_INI: + *send_cq = to_mcq(qp->ibqp.send_cq); + *recv_cq = NULL; + break; + + case IB_QPT_SMI: + case IB_QPT_GSI: + case IB_QPT_RC: + case IB_QPT_UC: + case IB_QPT_UD: + case IB_QPT_RAW_IPV6: + case IB_QPT_RAW_ETHERTYPE: + *send_cq = to_mcq(qp->ibqp.send_cq); + *recv_cq = to_mcq(qp->ibqp.recv_cq); + break; + + case IB_QPT_RAW_PACKET: + case IB_QPT_MAX: + default: + *send_cq = NULL; + *recv_cq = NULL; + break; + } +} + +static void destroy_qp_common(struct mlx5_ib_dev *dev, struct mlx5_ib_qp *qp) +{ + struct mlx5_ib_cq *send_cq, *recv_cq; + struct mlx5_modify_qp_mbox_in *in; + int err; + + in = kzalloc(sizeof(*in), GFP_KERNEL); + if (!in) + return; + if (qp->state != IB_QPS_RESET) + if (mlx5_core_qp_modify(&dev->mdev, to_mlx5_state(qp->state), + MLX5_QP_STATE_RST, in, sizeof(*in), &qp->mqp)) + mlx5_ib_warn(dev, "mlx5_ib: modify QP %06x to RESET failed\n", + qp->mqp.qpn); + + get_cqs(qp, &send_cq, &recv_cq); + + if (qp->create_type == MLX5_QP_KERNEL) { + mlx5_ib_lock_cqs(send_cq, recv_cq); + __mlx5_ib_cq_clean(recv_cq, qp->mqp.qpn, + qp->ibqp.srq ? to_msrq(qp->ibqp.srq) : NULL); + if (send_cq != recv_cq) + __mlx5_ib_cq_clean(send_cq, qp->mqp.qpn, NULL); + mlx5_ib_unlock_cqs(send_cq, recv_cq); + } + + err = mlx5_core_destroy_qp(&dev->mdev, &qp->mqp); + if (err) + mlx5_ib_warn(dev, "failed to destroy QP 0x%x\n", qp->mqp.qpn); + kfree(in); + + + if (qp->create_type == MLX5_QP_KERNEL) + destroy_qp_kernel(dev, qp); + else if (qp->create_type == MLX5_QP_USER) + destroy_qp_user(&get_pd(qp)->ibpd, qp); +} + +static const char *ib_qp_type_str(enum ib_qp_type type) +{ + switch (type) { + case IB_QPT_SMI: + return "IB_QPT_SMI"; + case IB_QPT_GSI: + return "IB_QPT_GSI"; + case IB_QPT_RC: + return "IB_QPT_RC"; + case IB_QPT_UC: + return "IB_QPT_UC"; + case IB_QPT_UD: + return "IB_QPT_UD"; + case IB_QPT_RAW_IPV6: + return "IB_QPT_RAW_IPV6"; + case IB_QPT_RAW_ETHERTYPE: + return "IB_QPT_RAW_ETHERTYPE"; + case IB_QPT_XRC_INI: + return "IB_QPT_XRC_INI"; + case IB_QPT_XRC_TGT: + return "IB_QPT_XRC_TGT"; + case IB_QPT_RAW_PACKET: + return "IB_QPT_RAW_PACKET"; + case MLX5_IB_QPT_REG_UMR: + return "MLX5_IB_QPT_REG_UMR"; + case IB_QPT_MAX: + default: + return "Invalid QP type"; + } +} + +struct ib_qp *mlx5_ib_create_qp(struct ib_pd *pd, + struct ib_qp_init_attr *init_attr, + struct ib_udata *udata) +{ + struct mlx5_ib_dev *dev; + struct mlx5_ib_qp *qp; + u16 xrcdn = 0; + int err; + + if (pd) { + dev = to_mdev(pd->device); + } else { + /* being cautious here */ + if (init_attr->qp_type != IB_QPT_XRC_TGT && + init_attr->qp_type != MLX5_IB_QPT_REG_UMR) { + pr_warn("%s: no PD for transport %s\n", __func__, + ib_qp_type_str(init_attr->qp_type)); + return ERR_PTR(-EINVAL); + } + dev = to_mdev(to_mxrcd(init_attr->xrcd)->ibxrcd.device); + } + + switch (init_attr->qp_type) { + case IB_QPT_XRC_TGT: + case IB_QPT_XRC_INI: + if (!(dev->mdev.caps.flags & MLX5_DEV_CAP_FLAG_XRC)) { + mlx5_ib_dbg(dev, "XRC not supported\n"); + return ERR_PTR(-ENOSYS); + } + init_attr->recv_cq = NULL; + if (init_attr->qp_type == IB_QPT_XRC_TGT) { + xrcdn = to_mxrcd(init_attr->xrcd)->xrcdn; + init_attr->send_cq = NULL; + } + + /* fall through */ + case IB_QPT_RC: + case IB_QPT_UC: + case IB_QPT_UD: + case IB_QPT_SMI: + case IB_QPT_GSI: + case MLX5_IB_QPT_REG_UMR: + qp = kzalloc(sizeof(*qp), GFP_KERNEL); + if (!qp) + return ERR_PTR(-ENOMEM); + + err = create_qp_common(dev, pd, init_attr, udata, qp); + if (err) { + mlx5_ib_dbg(dev, "create_qp_common failed\n"); + kfree(qp); + return ERR_PTR(err); + } + + if (is_qp0(init_attr->qp_type)) + qp->ibqp.qp_num = 0; + else if (is_qp1(init_attr->qp_type)) + qp->ibqp.qp_num = 1; + else + qp->ibqp.qp_num = qp->mqp.qpn; + + mlx5_ib_dbg(dev, "ib qpnum 0x%x, mlx qpn 0x%x, rcqn 0x%x, scqn 0x%x\n", + qp->ibqp.qp_num, qp->mqp.qpn, to_mcq(init_attr->recv_cq)->mcq.cqn, + to_mcq(init_attr->send_cq)->mcq.cqn); + + qp->xrcdn = xrcdn; + + break; + + case IB_QPT_RAW_IPV6: + case IB_QPT_RAW_ETHERTYPE: + case IB_QPT_RAW_PACKET: + case IB_QPT_MAX: + default: + mlx5_ib_dbg(dev, "unsupported qp type %d\n", + init_attr->qp_type); + /* Don't support raw QPs */ + return ERR_PTR(-EINVAL); + } + + return &qp->ibqp; +} + +int mlx5_ib_destroy_qp(struct ib_qp *qp) +{ + struct mlx5_ib_dev *dev = to_mdev(qp->device); + struct mlx5_ib_qp *mqp = to_mqp(qp); + + destroy_qp_common(dev, mqp); + + kfree(mqp); + + return 0; +} + +static __be32 to_mlx5_access_flags(struct mlx5_ib_qp *qp, const struct ib_qp_attr *attr, + int attr_mask) +{ + u32 hw_access_flags = 0; + u8 dest_rd_atomic; + u32 access_flags; + + if (attr_mask & IB_QP_MAX_DEST_RD_ATOMIC) + dest_rd_atomic = attr->max_dest_rd_atomic; + else + dest_rd_atomic = qp->resp_depth; + + if (attr_mask & IB_QP_ACCESS_FLAGS) + access_flags = attr->qp_access_flags; + else + access_flags = qp->atomic_rd_en; + + if (!dest_rd_atomic) + access_flags &= IB_ACCESS_REMOTE_WRITE; + + if (access_flags & IB_ACCESS_REMOTE_READ) + hw_access_flags |= MLX5_QP_BIT_RRE; + if (access_flags & IB_ACCESS_REMOTE_ATOMIC) + hw_access_flags |= (MLX5_QP_BIT_RAE | MLX5_ATOMIC_MODE_CX); + if (access_flags & IB_ACCESS_REMOTE_WRITE) + hw_access_flags |= MLX5_QP_BIT_RWE; + + return cpu_to_be32(hw_access_flags); +} + +enum { + MLX5_PATH_FLAG_FL = 1 << 0, + MLX5_PATH_FLAG_FREE_AR = 1 << 1, + MLX5_PATH_FLAG_COUNTER = 1 << 2, +}; + +static int ib_rate_to_mlx5(struct mlx5_ib_dev *dev, u8 rate) +{ + if (rate == IB_RATE_PORT_CURRENT) { + return 0; + } else if (rate < IB_RATE_2_5_GBPS || rate > IB_RATE_300_GBPS) { + return -EINVAL; + } else { + while (rate != IB_RATE_2_5_GBPS && + !(1 << (rate + MLX5_STAT_RATE_OFFSET) & + dev->mdev.caps.stat_rate_support)) + --rate; + } + + return rate + MLX5_STAT_RATE_OFFSET; +} + +static int mlx5_set_path(struct mlx5_ib_dev *dev, const struct ib_ah_attr *ah, + struct mlx5_qp_path *path, u8 port, int attr_mask, + u32 path_flags, const struct ib_qp_attr *attr) +{ + int err; + + path->fl = (path_flags & MLX5_PATH_FLAG_FL) ? 0x80 : 0; + path->free_ar = (path_flags & MLX5_PATH_FLAG_FREE_AR) ? 0x80 : 0; + + if (attr_mask & IB_QP_PKEY_INDEX) + path->pkey_index = attr->pkey_index; + + path->grh_mlid = ah->src_path_bits & 0x7f; + path->rlid = cpu_to_be16(ah->dlid); + + if (ah->ah_flags & IB_AH_GRH) { + path->grh_mlid |= 1 << 7; + path->mgid_index = ah->grh.sgid_index; + path->hop_limit = ah->grh.hop_limit; + path->tclass_flowlabel = + cpu_to_be32((ah->grh.traffic_class << 20) | + (ah->grh.flow_label)); + memcpy(path->rgid, ah->grh.dgid.raw, 16); + } + + err = ib_rate_to_mlx5(dev, ah->static_rate); + if (err < 0) + return err; + path->static_rate = err; + path->port = port; + + if (ah->ah_flags & IB_AH_GRH) { + if (ah->grh.sgid_index >= dev->mdev.caps.port[port - 1].gid_table_len) { + pr_err(KERN_ERR "sgid_index (%u) too large. max is %d\n", + ah->grh.sgid_index, dev->mdev.caps.port[port - 1].gid_table_len); + return -EINVAL; + } + + path->grh_mlid |= 1 << 7; + path->mgid_index = ah->grh.sgid_index; + path->hop_limit = ah->grh.hop_limit; + path->tclass_flowlabel = + cpu_to_be32((ah->grh.traffic_class << 20) | + (ah->grh.flow_label)); + memcpy(path->rgid, ah->grh.dgid.raw, 16); + } + + if (attr_mask & IB_QP_TIMEOUT) + path->ackto_lt = attr->timeout << 3; + + path->sl = ah->sl & 0xf; + + return 0; +} + +static enum mlx5_qp_optpar opt_mask[MLX5_QP_NUM_STATE][MLX5_QP_NUM_STATE][MLX5_QP_ST_MAX] = { + [MLX5_QP_STATE_INIT] = { + [MLX5_QP_STATE_INIT] = { + [MLX5_QP_ST_RC] = MLX5_QP_OPTPAR_RRE | + MLX5_QP_OPTPAR_RAE | + MLX5_QP_OPTPAR_RWE | + MLX5_QP_OPTPAR_PKEY_INDEX | + MLX5_QP_OPTPAR_PRI_PORT, + [MLX5_QP_ST_UC] = MLX5_QP_OPTPAR_RWE | + MLX5_QP_OPTPAR_PKEY_INDEX | + MLX5_QP_OPTPAR_PRI_PORT, + [MLX5_QP_ST_UD] = MLX5_QP_OPTPAR_PKEY_INDEX | + MLX5_QP_OPTPAR_Q_KEY | + MLX5_QP_OPTPAR_PRI_PORT, + }, + [MLX5_QP_STATE_RTR] = { + [MLX5_QP_ST_RC] = MLX5_QP_OPTPAR_ALT_ADDR_PATH | + MLX5_QP_OPTPAR_RRE | + MLX5_QP_OPTPAR_RAE | + MLX5_QP_OPTPAR_RWE | + MLX5_QP_OPTPAR_PKEY_INDEX, + [MLX5_QP_ST_UC] = MLX5_QP_OPTPAR_ALT_ADDR_PATH | + MLX5_QP_OPTPAR_RWE | + MLX5_QP_OPTPAR_PKEY_INDEX, + [MLX5_QP_ST_UD] = MLX5_QP_OPTPAR_PKEY_INDEX | + MLX5_QP_OPTPAR_Q_KEY, + [MLX5_QP_ST_MLX] = MLX5_QP_OPTPAR_PKEY_INDEX | + MLX5_QP_OPTPAR_Q_KEY, + }, + }, + [MLX5_QP_STATE_RTR] = { + [MLX5_QP_STATE_RTS] = { + [MLX5_QP_ST_RC] = MLX5_QP_OPTPAR_ALT_ADDR_PATH | + MLX5_QP_OPTPAR_RRE | + MLX5_QP_OPTPAR_RAE | + MLX5_QP_OPTPAR_RWE | + MLX5_QP_OPTPAR_PM_STATE | + MLX5_QP_OPTPAR_RNR_TIMEOUT, + [MLX5_QP_ST_UC] = MLX5_QP_OPTPAR_ALT_ADDR_PATH | + MLX5_QP_OPTPAR_RWE | + MLX5_QP_OPTPAR_PM_STATE, + [MLX5_QP_ST_UD] = MLX5_QP_OPTPAR_Q_KEY, + }, + }, + [MLX5_QP_STATE_RTS] = { + [MLX5_QP_STATE_RTS] = { + [MLX5_QP_ST_RC] = MLX5_QP_OPTPAR_RRE | + MLX5_QP_OPTPAR_RAE | + MLX5_QP_OPTPAR_RWE | + MLX5_QP_OPTPAR_RNR_TIMEOUT | + MLX5_QP_OPTPAR_PM_STATE, + [MLX5_QP_ST_UC] = MLX5_QP_OPTPAR_RWE | + MLX5_QP_OPTPAR_PM_STATE, + [MLX5_QP_ST_UD] = MLX5_QP_OPTPAR_Q_KEY | + MLX5_QP_OPTPAR_SRQN | + MLX5_QP_OPTPAR_CQN_RCV, + }, + }, + [MLX5_QP_STATE_SQER] = { + [MLX5_QP_STATE_RTS] = { + [MLX5_QP_ST_UD] = MLX5_QP_OPTPAR_Q_KEY, + [MLX5_QP_ST_MLX] = MLX5_QP_OPTPAR_Q_KEY, + }, + }, +}; + +static int ib_nr_to_mlx5_nr(int ib_mask) +{ + switch (ib_mask) { + case IB_QP_STATE: + return 0; + case IB_QP_CUR_STATE: + return 0; + case IB_QP_EN_SQD_ASYNC_NOTIFY: + return 0; + case IB_QP_ACCESS_FLAGS: + return MLX5_QP_OPTPAR_RWE | MLX5_QP_OPTPAR_RRE | + MLX5_QP_OPTPAR_RAE; + case IB_QP_PKEY_INDEX: + return MLX5_QP_OPTPAR_PKEY_INDEX; + case IB_QP_PORT: + return MLX5_QP_OPTPAR_PRI_PORT; + case IB_QP_QKEY: + return MLX5_QP_OPTPAR_Q_KEY; + case IB_QP_AV: + return MLX5_QP_OPTPAR_PRIMARY_ADDR_PATH | + MLX5_QP_OPTPAR_PRI_PORT; + case IB_QP_PATH_MTU: + return 0; + case IB_QP_TIMEOUT: + return MLX5_QP_OPTPAR_ACK_TIMEOUT; + case IB_QP_RETRY_CNT: + return MLX5_QP_OPTPAR_RETRY_COUNT; + case IB_QP_RNR_RETRY: + return MLX5_QP_OPTPAR_RNR_RETRY; + case IB_QP_RQ_PSN: + return 0; + case IB_QP_MAX_QP_RD_ATOMIC: + return MLX5_QP_OPTPAR_SRA_MAX; + case IB_QP_ALT_PATH: + return MLX5_QP_OPTPAR_ALT_ADDR_PATH; + case IB_QP_MIN_RNR_TIMER: + return MLX5_QP_OPTPAR_RNR_TIMEOUT; + case IB_QP_SQ_PSN: + return 0; + case IB_QP_MAX_DEST_RD_ATOMIC: + return MLX5_QP_OPTPAR_RRA_MAX | MLX5_QP_OPTPAR_RWE | + MLX5_QP_OPTPAR_RRE | MLX5_QP_OPTPAR_RAE; + case IB_QP_PATH_MIG_STATE: + return MLX5_QP_OPTPAR_PM_STATE; + case IB_QP_CAP: + return 0; + case IB_QP_DEST_QPN: + return 0; + } + return 0; +} + +static int ib_mask_to_mlx5_opt(int ib_mask) +{ + int result = 0; + int i; + + for (i = 0; i < 8 * sizeof(int); i++) { + if ((1 << i) & ib_mask) + result |= ib_nr_to_mlx5_nr(1 << i); + } + + return result; +} + +static int __mlx5_ib_modify_qp(struct ib_qp *ibqp, + const struct ib_qp_attr *attr, int attr_mask, + enum ib_qp_state cur_state, enum ib_qp_state new_state) +{ + struct mlx5_ib_dev *dev = to_mdev(ibqp->device); + struct mlx5_ib_qp *qp = to_mqp(ibqp); + struct mlx5_ib_cq *send_cq, *recv_cq; + struct mlx5_qp_context *context; + struct mlx5_modify_qp_mbox_in *in; + struct mlx5_ib_pd *pd; + enum mlx5_qp_state mlx5_cur, mlx5_new; + enum mlx5_qp_optpar optpar; + int sqd_event; + int mlx5_st; + int err; + + in = kzalloc(sizeof(*in), GFP_KERNEL); + if (!in) + return -ENOMEM; + + context = &in->ctx; + err = to_mlx5_st(ibqp->qp_type); + if (err < 0) + goto out; + + context->flags = cpu_to_be32(err << 16); + + if (!(attr_mask & IB_QP_PATH_MIG_STATE)) { + context->flags |= cpu_to_be32(MLX5_QP_PM_MIGRATED << 11); + } else { + switch (attr->path_mig_state) { + case IB_MIG_MIGRATED: + context->flags |= cpu_to_be32(MLX5_QP_PM_MIGRATED << 11); + break; + case IB_MIG_REARM: + context->flags |= cpu_to_be32(MLX5_QP_PM_REARM << 11); + break; + case IB_MIG_ARMED: + context->flags |= cpu_to_be32(MLX5_QP_PM_ARMED << 11); + break; + } + } + + if (ibqp->qp_type == IB_QPT_GSI || ibqp->qp_type == IB_QPT_SMI) { + context->mtu_msgmax = (IB_MTU_256 << 5) | 8; + } else if (ibqp->qp_type == IB_QPT_UD || + ibqp->qp_type == MLX5_IB_QPT_REG_UMR) { + context->mtu_msgmax = (IB_MTU_4096 << 5) | 12; + } else if (attr_mask & IB_QP_PATH_MTU) { + if (attr->path_mtu < IB_MTU_256 || + attr->path_mtu > IB_MTU_4096) { + mlx5_ib_warn(dev, "invalid mtu %d\n", attr->path_mtu); + err = -EINVAL; + goto out; + } + context->mtu_msgmax = (attr->path_mtu << 5) | dev->mdev.caps.log_max_msg; + } + + if (attr_mask & IB_QP_DEST_QPN) + context->log_pg_sz_remote_qpn = cpu_to_be32(attr->dest_qp_num); + + if (attr_mask & IB_QP_PKEY_INDEX) + context->pri_path.pkey_index = attr->pkey_index; + + /* todo implement counter_index functionality */ + + if (is_sqp(ibqp->qp_type)) + context->pri_path.port = qp->port; + + if (attr_mask & IB_QP_PORT) + context->pri_path.port = attr->port_num; + + if (attr_mask & IB_QP_AV) { + err = mlx5_set_path(dev, &attr->ah_attr, &context->pri_path, + attr_mask & IB_QP_PORT ? attr->port_num : qp->port, + attr_mask, 0, attr); + if (err) + goto out; + } + + if (attr_mask & IB_QP_TIMEOUT) + context->pri_path.ackto_lt |= attr->timeout << 3; + + if (attr_mask & IB_QP_ALT_PATH) { + err = mlx5_set_path(dev, &attr->alt_ah_attr, &context->alt_path, + attr->alt_port_num, attr_mask, 0, attr); + if (err) + goto out; + } + + pd = get_pd(qp); + get_cqs(qp, &send_cq, &recv_cq); + + context->flags_pd = cpu_to_be32(pd ? pd->pdn : to_mpd(dev->devr.p0)->pdn); + context->cqn_send = send_cq ? cpu_to_be32(send_cq->mcq.cqn) : 0; + context->cqn_recv = recv_cq ? cpu_to_be32(recv_cq->mcq.cqn) : 0; + context->params1 = cpu_to_be32(MLX5_IB_ACK_REQ_FREQ << 28); + + if (attr_mask & IB_QP_RNR_RETRY) + context->params1 |= cpu_to_be32(attr->rnr_retry << 13); + + if (attr_mask & IB_QP_RETRY_CNT) + context->params1 |= cpu_to_be32(attr->retry_cnt << 16); + + if (attr_mask & IB_QP_MAX_QP_RD_ATOMIC) { + if (attr->max_rd_atomic) + context->params1 |= + cpu_to_be32(fls(attr->max_rd_atomic - 1) << 21); + } + + if (attr_mask & IB_QP_SQ_PSN) + context->next_send_psn = cpu_to_be32(attr->sq_psn); + + if (attr_mask & IB_QP_MAX_DEST_RD_ATOMIC) { + if (attr->max_dest_rd_atomic) + context->params2 |= + cpu_to_be32(fls(attr->max_dest_rd_atomic - 1) << 21); + } + + if (attr_mask & (IB_QP_ACCESS_FLAGS | IB_QP_MAX_DEST_RD_ATOMIC)) + context->params2 |= to_mlx5_access_flags(qp, attr, attr_mask); + + if (attr_mask & IB_QP_MIN_RNR_TIMER) + context->rnr_nextrecvpsn |= cpu_to_be32(attr->min_rnr_timer << 24); + + if (attr_mask & IB_QP_RQ_PSN) + context->rnr_nextrecvpsn |= cpu_to_be32(attr->rq_psn); + + if (attr_mask & IB_QP_QKEY) + context->qkey = cpu_to_be32(attr->qkey); + + if (qp->rq.wqe_cnt && cur_state == IB_QPS_RESET && new_state == IB_QPS_INIT) + context->db_rec_addr = cpu_to_be64(qp->db.dma); + + if (cur_state == IB_QPS_RTS && new_state == IB_QPS_SQD && + attr_mask & IB_QP_EN_SQD_ASYNC_NOTIFY && attr->en_sqd_async_notify) + sqd_event = 1; + else + sqd_event = 0; + + if (!ibqp->uobject && cur_state == IB_QPS_RESET && new_state == IB_QPS_INIT) + context->sq_crq_size |= cpu_to_be16(1 << 4); + + + mlx5_cur = to_mlx5_state(cur_state); + mlx5_new = to_mlx5_state(new_state); + mlx5_st = to_mlx5_st(ibqp->qp_type); + if (mlx5_cur < 0 || mlx5_new < 0 || mlx5_st < 0) + goto out; + + optpar = ib_mask_to_mlx5_opt(attr_mask); + optpar &= opt_mask[mlx5_cur][mlx5_new][mlx5_st]; + in->optparam = cpu_to_be32(optpar); + err = mlx5_core_qp_modify(&dev->mdev, to_mlx5_state(cur_state), + to_mlx5_state(new_state), in, sqd_event, + &qp->mqp); + if (err) + goto out; + + qp->state = new_state; + + if (attr_mask & IB_QP_ACCESS_FLAGS) + qp->atomic_rd_en = attr->qp_access_flags; + if (attr_mask & IB_QP_MAX_DEST_RD_ATOMIC) + qp->resp_depth = attr->max_dest_rd_atomic; + if (attr_mask & IB_QP_PORT) + qp->port = attr->port_num; + if (attr_mask & IB_QP_ALT_PATH) + qp->alt_port = attr->alt_port_num; + + /* + * If we moved a kernel QP to RESET, clean up all old CQ + * entries and reinitialize the QP. + */ + if (new_state == IB_QPS_RESET && !ibqp->uobject) { + mlx5_ib_cq_clean(recv_cq, qp->mqp.qpn, + ibqp->srq ? to_msrq(ibqp->srq) : NULL); + if (send_cq != recv_cq) + mlx5_ib_cq_clean(send_cq, qp->mqp.qpn, NULL); + + qp->rq.head = 0; + qp->rq.tail = 0; + qp->sq.head = 0; + qp->sq.tail = 0; + qp->sq.cur_post = 0; + qp->sq.last_poll = 0; + qp->db.db[MLX5_RCV_DBR] = 0; + qp->db.db[MLX5_SND_DBR] = 0; + } + +out: + kfree(in); + return err; +} + +int mlx5_ib_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, + int attr_mask, struct ib_udata *udata) +{ + struct mlx5_ib_dev *dev = to_mdev(ibqp->device); + struct mlx5_ib_qp *qp = to_mqp(ibqp); + enum ib_qp_state cur_state, new_state; + int err = -EINVAL; + int port; + + mutex_lock(&qp->mutex); + + cur_state = attr_mask & IB_QP_CUR_STATE ? attr->cur_qp_state : qp->state; + new_state = attr_mask & IB_QP_STATE ? attr->qp_state : cur_state; + + if (ibqp->qp_type != MLX5_IB_QPT_REG_UMR && + !ib_modify_qp_is_ok(cur_state, new_state, ibqp->qp_type, attr_mask)) + goto out; + + if ((attr_mask & IB_QP_PORT) && + (attr->port_num == 0 || attr->port_num > dev->mdev.caps.num_ports)) + goto out; + + if (attr_mask & IB_QP_PKEY_INDEX) { + port = attr_mask & IB_QP_PORT ? attr->port_num : qp->port; + if (attr->pkey_index >= dev->mdev.caps.port[port - 1].pkey_table_len) + goto out; + } + + if (attr_mask & IB_QP_MAX_QP_RD_ATOMIC && + attr->max_rd_atomic > dev->mdev.caps.max_ra_res_qp) + goto out; + + if (attr_mask & IB_QP_MAX_DEST_RD_ATOMIC && + attr->max_dest_rd_atomic > dev->mdev.caps.max_ra_req_qp) + goto out; + + if (cur_state == new_state && cur_state == IB_QPS_RESET) { + err = 0; + goto out; + } + + err = __mlx5_ib_modify_qp(ibqp, attr, attr_mask, cur_state, new_state); + +out: + mutex_unlock(&qp->mutex); + return err; +} + +static int mlx5_wq_overflow(struct mlx5_ib_wq *wq, int nreq, struct ib_cq *ib_cq) +{ + struct mlx5_ib_cq *cq; + unsigned cur; + + cur = wq->head - wq->tail; + if (likely(cur + nreq < wq->max_post)) + return 0; + + cq = to_mcq(ib_cq); + spin_lock(&cq->lock); + cur = wq->head - wq->tail; + spin_unlock(&cq->lock); + + return cur + nreq >= wq->max_post; +} + +static __always_inline void set_raddr_seg(struct mlx5_wqe_raddr_seg *rseg, + u64 remote_addr, u32 rkey) +{ + rseg->raddr = cpu_to_be64(remote_addr); + rseg->rkey = cpu_to_be32(rkey); + rseg->reserved = 0; +} + +static void set_atomic_seg(struct mlx5_wqe_atomic_seg *aseg, struct ib_send_wr *wr) +{ + if (wr->opcode == IB_WR_ATOMIC_CMP_AND_SWP) { + aseg->swap_add = cpu_to_be64(wr->wr.atomic.swap); + aseg->compare = cpu_to_be64(wr->wr.atomic.compare_add); + } else if (wr->opcode == IB_WR_MASKED_ATOMIC_FETCH_AND_ADD) { + aseg->swap_add = cpu_to_be64(wr->wr.atomic.compare_add); + aseg->compare = cpu_to_be64(wr->wr.atomic.compare_add_mask); + } else { + aseg->swap_add = cpu_to_be64(wr->wr.atomic.compare_add); + aseg->compare = 0; + } +} + +static void set_masked_atomic_seg(struct mlx5_wqe_masked_atomic_seg *aseg, + struct ib_send_wr *wr) +{ + aseg->swap_add = cpu_to_be64(wr->wr.atomic.swap); + aseg->swap_add_mask = cpu_to_be64(wr->wr.atomic.swap_mask); + aseg->compare = cpu_to_be64(wr->wr.atomic.compare_add); + aseg->compare_mask = cpu_to_be64(wr->wr.atomic.compare_add_mask); +} + +static void set_datagram_seg(struct mlx5_wqe_datagram_seg *dseg, + struct ib_send_wr *wr) +{ + memcpy(&dseg->av, &to_mah(wr->wr.ud.ah)->av, sizeof(struct mlx5_av)); + dseg->av.dqp_dct = cpu_to_be32(wr->wr.ud.remote_qpn | MLX5_EXTENDED_UD_AV); + dseg->av.key.qkey.qkey = cpu_to_be32(wr->wr.ud.remote_qkey); +} + +static void set_data_ptr_seg(struct mlx5_wqe_data_seg *dseg, struct ib_sge *sg) +{ + dseg->byte_count = cpu_to_be32(sg->length); + dseg->lkey = cpu_to_be32(sg->lkey); + dseg->addr = cpu_to_be64(sg->addr); +} + +static __be16 get_klm_octo(int npages) +{ + return cpu_to_be16(ALIGN(npages, 8) / 2); +} + +static __be64 frwr_mkey_mask(void) +{ + u64 result; + + result = MLX5_MKEY_MASK_LEN | + MLX5_MKEY_MASK_PAGE_SIZE | + MLX5_MKEY_MASK_START_ADDR | + MLX5_MKEY_MASK_EN_RINVAL | + MLX5_MKEY_MASK_KEY | + MLX5_MKEY_MASK_LR | + MLX5_MKEY_MASK_LW | + MLX5_MKEY_MASK_RR | + MLX5_MKEY_MASK_RW | + MLX5_MKEY_MASK_A | + MLX5_MKEY_MASK_SMALL_FENCE | + MLX5_MKEY_MASK_FREE; + + return cpu_to_be64(result); +} + +static void set_frwr_umr_segment(struct mlx5_wqe_umr_ctrl_seg *umr, + struct ib_send_wr *wr, int li) +{ + memset(umr, 0, sizeof(*umr)); + + if (li) { + umr->mkey_mask = cpu_to_be64(MLX5_MKEY_MASK_FREE); + umr->flags = 1 << 7; + return; + } + + umr->flags = (1 << 5); /* fail if not free */ + umr->klm_octowords = get_klm_octo(wr->wr.fast_reg.page_list_len); + umr->mkey_mask = frwr_mkey_mask(); +} + +static void set_reg_umr_segment(struct mlx5_wqe_umr_ctrl_seg *umr, + struct ib_send_wr *wr) +{ + struct umr_wr *umrwr = (struct umr_wr *)&wr->wr.fast_reg; + u64 mask; + + memset(umr, 0, sizeof(*umr)); + + if (!(wr->send_flags & MLX5_IB_SEND_UMR_UNREG)) { + umr->flags = 1 << 5; /* fail if not free */ + umr->klm_octowords = get_klm_octo(umrwr->npages); + mask = MLX5_MKEY_MASK_LEN | + MLX5_MKEY_MASK_PAGE_SIZE | + MLX5_MKEY_MASK_START_ADDR | + MLX5_MKEY_MASK_PD | + MLX5_MKEY_MASK_LR | + MLX5_MKEY_MASK_LW | + MLX5_MKEY_MASK_RR | + MLX5_MKEY_MASK_RW | + MLX5_MKEY_MASK_A | + MLX5_MKEY_MASK_FREE; + umr->mkey_mask = cpu_to_be64(mask); + } else { + umr->flags = 2 << 5; /* fail if free */ + mask = MLX5_MKEY_MASK_FREE; + umr->mkey_mask = cpu_to_be64(mask); + } + + if (!wr->num_sge) + umr->flags |= (1 << 7); /* inline */ +} + +static u8 get_umr_flags(int acc) +{ + return (acc & IB_ACCESS_REMOTE_ATOMIC ? MLX5_PERM_ATOMIC : 0) | + (acc & IB_ACCESS_REMOTE_WRITE ? MLX5_PERM_REMOTE_WRITE : 0) | + (acc & IB_ACCESS_REMOTE_READ ? MLX5_PERM_REMOTE_READ : 0) | + (acc & IB_ACCESS_LOCAL_WRITE ? MLX5_PERM_LOCAL_WRITE : 0) | + MLX5_PERM_LOCAL_READ | MLX5_PERM_UMR_EN | MLX5_ACCESS_MODE_MTT; +} + +static void set_mkey_segment(struct mlx5_mkey_seg *seg, struct ib_send_wr *wr, + int li, int *writ) +{ + memset(seg, 0, sizeof(*seg)); + if (li) { + seg->status = 1 << 6; + return; + } + + seg->flags = get_umr_flags(wr->wr.fast_reg.access_flags); + *writ = seg->flags & (MLX5_PERM_LOCAL_WRITE | IB_ACCESS_REMOTE_WRITE); + seg->qpn_mkey7_0 = cpu_to_be32((wr->wr.fast_reg.rkey & 0xff) | 0xffffff00); + seg->flags_pd = cpu_to_be32(MLX5_MKEY_REMOTE_INVAL); + seg->start_addr = cpu_to_be64(wr->wr.fast_reg.iova_start); + seg->len = cpu_to_be64(wr->wr.fast_reg.length); + seg->xlt_oct_size = cpu_to_be32((wr->wr.fast_reg.page_list_len + 1) / 2); + seg->log2_page_size = wr->wr.fast_reg.page_shift; +} + +static void set_reg_mkey_segment(struct mlx5_mkey_seg *seg, struct ib_send_wr *wr) +{ + memset(seg, 0, sizeof(*seg)); + if (wr->send_flags & MLX5_IB_SEND_UMR_UNREG) { + seg->status = 1 << 6; + return; + } + + seg->flags = convert_access(wr->wr.fast_reg.access_flags); + seg->flags_pd = cpu_to_be32(to_mpd((struct ib_pd *)wr->wr.fast_reg.page_list)->pdn); + seg->start_addr = cpu_to_be64(wr->wr.fast_reg.iova_start); + seg->len = cpu_to_be64(wr->wr.fast_reg.length); + seg->log2_page_size = wr->wr.fast_reg.page_shift; + seg->qpn_mkey7_0 = cpu_to_be32(0xffffff << 8); +} + +static void set_frwr_pages(struct mlx5_wqe_data_seg *dseg, + struct ib_send_wr *wr, + struct mlx5_core_dev *mdev, + struct mlx5_ib_pd *pd, + int writ) +{ + struct mlx5_ib_fast_reg_page_list *mfrpl = to_mfrpl(wr->wr.fast_reg.page_list); + u64 *page_list = wr->wr.fast_reg.page_list->page_list; + u64 perm = MLX5_EN_RD | (writ ? MLX5_EN_WR : 0); + int i; + + for (i = 0; i < wr->wr.fast_reg.page_list_len; i++) + mfrpl->mapped_page_list[i] = cpu_to_be64(page_list[i] | perm); + dseg->addr = cpu_to_be64(mfrpl->map); + dseg->byte_count = cpu_to_be32(ALIGN(sizeof(u64) * wr->wr.fast_reg.page_list_len, 64)); + dseg->lkey = cpu_to_be32(pd->pa_lkey); +} + +static __be32 send_ieth(struct ib_send_wr *wr) +{ + switch (wr->opcode) { + case IB_WR_SEND_WITH_IMM: + case IB_WR_RDMA_WRITE_WITH_IMM: + return wr->ex.imm_data; + + case IB_WR_SEND_WITH_INV: + return cpu_to_be32(wr->ex.invalidate_rkey); + + default: + return 0; + } +} + +static u8 calc_sig(void *wqe, int size) +{ + u8 *p = wqe; + u8 res = 0; + int i; + + for (i = 0; i < size; i++) + res ^= p[i]; + + return ~res; +} + +static u8 wq_sig(void *wqe) +{ + return calc_sig(wqe, (*((u8 *)wqe + 8) & 0x3f) << 4); +} + +static int set_data_inl_seg(struct mlx5_ib_qp *qp, struct ib_send_wr *wr, + void *wqe, int *sz) +{ + struct mlx5_wqe_inline_seg *seg; + void *qend = qp->sq.qend; + void *addr; + int inl = 0; + int copy; + int len; + int i; + + seg = wqe; + wqe += sizeof(*seg); + for (i = 0; i < wr->num_sge; i++) { + addr = (void *)(unsigned long)(wr->sg_list[i].addr); + len = wr->sg_list[i].length; + inl += len; + + if (unlikely(inl > qp->max_inline_data)) + return -ENOMEM; + + if (unlikely(wqe + len > qend)) { + copy = qend - wqe; + memcpy(wqe, addr, copy); + addr += copy; + len -= copy; + wqe = mlx5_get_send_wqe(qp, 0); + } + memcpy(wqe, addr, len); + wqe += len; + } + + seg->byte_count = cpu_to_be32(inl | MLX5_INLINE_SEG); + + *sz = ALIGN(inl + sizeof(seg->byte_count), 16) / 16; + + return 0; +} + +static int set_frwr_li_wr(void **seg, struct ib_send_wr *wr, int *size, + struct mlx5_core_dev *mdev, struct mlx5_ib_pd *pd, struct mlx5_ib_qp *qp) +{ + int writ = 0; + int li; + + li = wr->opcode == IB_WR_LOCAL_INV ? 1 : 0; + if (unlikely(wr->send_flags & IB_SEND_INLINE)) + return -EINVAL; + + set_frwr_umr_segment(*seg, wr, li); + *seg += sizeof(struct mlx5_wqe_umr_ctrl_seg); + *size += sizeof(struct mlx5_wqe_umr_ctrl_seg) / 16; + if (unlikely((*seg == qp->sq.qend))) + *seg = mlx5_get_send_wqe(qp, 0); + set_mkey_segment(*seg, wr, li, &writ); + *seg += sizeof(struct mlx5_mkey_seg); + *size += sizeof(struct mlx5_mkey_seg) / 16; + if (unlikely((*seg == qp->sq.qend))) + *seg = mlx5_get_send_wqe(qp, 0); + if (!li) { + set_frwr_pages(*seg, wr, mdev, pd, writ); + *seg += sizeof(struct mlx5_wqe_data_seg); + *size += (sizeof(struct mlx5_wqe_data_seg) / 16); + } + return 0; +} + +static void dump_wqe(struct mlx5_ib_qp *qp, int idx, int size_16) +{ + __be32 *p = NULL; + int tidx = idx; + int i, j; + + pr_debug("dump wqe at %p\n", mlx5_get_send_wqe(qp, tidx)); + for (i = 0, j = 0; i < size_16 * 4; i += 4, j += 4) { + if ((i & 0xf) == 0) { + void *buf = mlx5_get_send_wqe(qp, tidx); + tidx = (tidx + 1) & (qp->sq.wqe_cnt - 1); + p = buf; + j = 0; + } + pr_debug("%08x %08x %08x %08x\n", be32_to_cpu(p[j]), + be32_to_cpu(p[j + 1]), be32_to_cpu(p[j + 2]), + be32_to_cpu(p[j + 3])); + } +} + +static void mlx5_bf_copy(u64 __iomem *dst, u64 *src, + unsigned bytecnt, struct mlx5_ib_qp *qp) +{ + while (bytecnt > 0) { + __iowrite64_copy(dst++, src++, 8); + __iowrite64_copy(dst++, src++, 8); + __iowrite64_copy(dst++, src++, 8); + __iowrite64_copy(dst++, src++, 8); + __iowrite64_copy(dst++, src++, 8); + __iowrite64_copy(dst++, src++, 8); + __iowrite64_copy(dst++, src++, 8); + __iowrite64_copy(dst++, src++, 8); + bytecnt -= 64; + if (unlikely(src == qp->sq.qend)) + src = mlx5_get_send_wqe(qp, 0); + } +} + +static u8 get_fence(u8 fence, struct ib_send_wr *wr) +{ + if (unlikely(wr->opcode == IB_WR_LOCAL_INV && + wr->send_flags & IB_SEND_FENCE)) + return MLX5_FENCE_MODE_STRONG_ORDERING; + + if (unlikely(fence)) { + if (wr->send_flags & IB_SEND_FENCE) + return MLX5_FENCE_MODE_SMALL_AND_FENCE; + else + return fence; + + } else { + return 0; + } +} + +int mlx5_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr, + struct ib_send_wr **bad_wr) +{ + struct mlx5_wqe_ctrl_seg *ctrl = NULL; /* compiler warning */ + struct mlx5_ib_dev *dev = to_mdev(ibqp->device); + struct mlx5_core_dev *mdev = &dev->mdev; + struct mlx5_ib_qp *qp = to_mqp(ibqp); + struct mlx5_wqe_data_seg *dpseg; + struct mlx5_wqe_xrc_seg *xrc; + struct mlx5_bf *bf = qp->bf; + int uninitialized_var(size); + void *qend = qp->sq.qend; + unsigned long flags; + u32 mlx5_opcode; + unsigned idx; + int err = 0; + int inl = 0; + int num_sge; + void *seg; + int nreq; + int i; + u8 next_fence = 0; + u8 opmod = 0; + u8 fence; + + spin_lock_irqsave(&qp->sq.lock, flags); + + for (nreq = 0; wr; nreq++, wr = wr->next) { + if (unlikely(wr->opcode >= sizeof(mlx5_ib_opcode) / sizeof(mlx5_ib_opcode[0]))) { + mlx5_ib_warn(dev, "\n"); + err = -EINVAL; + *bad_wr = wr; + goto out; + } + + if (unlikely(mlx5_wq_overflow(&qp->sq, nreq, qp->ibqp.send_cq))) { + mlx5_ib_warn(dev, "\n"); + err = -ENOMEM; + *bad_wr = wr; + goto out; + } + + fence = qp->fm_cache; + num_sge = wr->num_sge; + if (unlikely(num_sge > qp->sq.max_gs)) { + mlx5_ib_warn(dev, "\n"); + err = -ENOMEM; + *bad_wr = wr; + goto out; + } + + idx = qp->sq.cur_post & (qp->sq.wqe_cnt - 1); + seg = mlx5_get_send_wqe(qp, idx); + ctrl = seg; + *(uint32_t *)(seg + 8) = 0; + ctrl->imm = send_ieth(wr); + ctrl->fm_ce_se = qp->sq_signal_bits | + (wr->send_flags & IB_SEND_SIGNALED ? + MLX5_WQE_CTRL_CQ_UPDATE : 0) | + (wr->send_flags & IB_SEND_SOLICITED ? + MLX5_WQE_CTRL_SOLICITED : 0); + + seg += sizeof(*ctrl); + size = sizeof(*ctrl) / 16; + + switch (ibqp->qp_type) { + case IB_QPT_XRC_INI: + xrc = seg; + xrc->xrc_srqn = htonl(wr->xrc_remote_srq_num); + seg += sizeof(*xrc); + size += sizeof(*xrc) / 16; + /* fall through */ + case IB_QPT_RC: + switch (wr->opcode) { + case IB_WR_RDMA_READ: + case IB_WR_RDMA_WRITE: + case IB_WR_RDMA_WRITE_WITH_IMM: + set_raddr_seg(seg, wr->wr.rdma.remote_addr, + wr->wr.rdma.rkey); + seg += sizeof(struct mlx5_wqe_raddr_seg); + size += sizeof(struct mlx5_wqe_raddr_seg) / 16; + break; + + case IB_WR_ATOMIC_CMP_AND_SWP: + case IB_WR_ATOMIC_FETCH_AND_ADD: + set_raddr_seg(seg, wr->wr.atomic.remote_addr, + wr->wr.atomic.rkey); + seg += sizeof(struct mlx5_wqe_raddr_seg); + + set_atomic_seg(seg, wr); + seg += sizeof(struct mlx5_wqe_atomic_seg); + + size += (sizeof(struct mlx5_wqe_raddr_seg) + + sizeof(struct mlx5_wqe_atomic_seg)) / 16; + break; + + case IB_WR_MASKED_ATOMIC_CMP_AND_SWP: + set_raddr_seg(seg, wr->wr.atomic.remote_addr, + wr->wr.atomic.rkey); + seg += sizeof(struct mlx5_wqe_raddr_seg); + + set_masked_atomic_seg(seg, wr); + seg += sizeof(struct mlx5_wqe_masked_atomic_seg); + + size += (sizeof(struct mlx5_wqe_raddr_seg) + + sizeof(struct mlx5_wqe_masked_atomic_seg)) / 16; + break; + + case IB_WR_LOCAL_INV: + next_fence = MLX5_FENCE_MODE_INITIATOR_SMALL; + qp->sq.wr_data[idx] = IB_WR_LOCAL_INV; + ctrl->imm = cpu_to_be32(wr->ex.invalidate_rkey); + err = set_frwr_li_wr(&seg, wr, &size, mdev, to_mpd(ibqp->pd), qp); + if (err) { + mlx5_ib_warn(dev, "\n"); + *bad_wr = wr; + goto out; + } + num_sge = 0; + break; + + case IB_WR_FAST_REG_MR: + next_fence = MLX5_FENCE_MODE_INITIATOR_SMALL; + qp->sq.wr_data[idx] = IB_WR_FAST_REG_MR; + ctrl->imm = cpu_to_be32(wr->wr.fast_reg.rkey); + err = set_frwr_li_wr(&seg, wr, &size, mdev, to_mpd(ibqp->pd), qp); + if (err) { + mlx5_ib_warn(dev, "\n"); + *bad_wr = wr; + goto out; + } + num_sge = 0; + break; + + default: + break; + } + break; + + case IB_QPT_UC: + switch (wr->opcode) { + case IB_WR_RDMA_WRITE: + case IB_WR_RDMA_WRITE_WITH_IMM: + set_raddr_seg(seg, wr->wr.rdma.remote_addr, + wr->wr.rdma.rkey); + seg += sizeof(struct mlx5_wqe_raddr_seg); + size += sizeof(struct mlx5_wqe_raddr_seg) / 16; + break; + + default: + break; + } + break; + + case IB_QPT_UD: + case IB_QPT_SMI: + case IB_QPT_GSI: + set_datagram_seg(seg, wr); + seg += sizeof(struct mlx5_wqe_datagram_seg); + size += sizeof(struct mlx5_wqe_datagram_seg) / 16; + if (unlikely((seg == qend))) + seg = mlx5_get_send_wqe(qp, 0); + break; + + case MLX5_IB_QPT_REG_UMR: + if (wr->opcode != MLX5_IB_WR_UMR) { + err = -EINVAL; + mlx5_ib_warn(dev, "bad opcode\n"); + goto out; + } + qp->sq.wr_data[idx] = MLX5_IB_WR_UMR; + ctrl->imm = cpu_to_be32(wr->wr.fast_reg.rkey); + set_reg_umr_segment(seg, wr); + seg += sizeof(struct mlx5_wqe_umr_ctrl_seg); + size += sizeof(struct mlx5_wqe_umr_ctrl_seg) / 16; + if (unlikely((seg == qend))) + seg = mlx5_get_send_wqe(qp, 0); + set_reg_mkey_segment(seg, wr); + seg += sizeof(struct mlx5_mkey_seg); + size += sizeof(struct mlx5_mkey_seg) / 16; + if (unlikely((seg == qend))) + seg = mlx5_get_send_wqe(qp, 0); + break; + + default: + break; + } + + if (wr->send_flags & IB_SEND_INLINE && num_sge) { + int uninitialized_var(sz); + + err = set_data_inl_seg(qp, wr, seg, &sz); + if (unlikely(err)) { + mlx5_ib_warn(dev, "\n"); + *bad_wr = wr; + goto out; + } + inl = 1; + size += sz; + } else { + dpseg = seg; + for (i = 0; i < num_sge; i++) { + if (unlikely(dpseg == qend)) { + seg = mlx5_get_send_wqe(qp, 0); + dpseg = seg; + } + if (likely(wr->sg_list[i].length)) { + set_data_ptr_seg(dpseg, wr->sg_list + i); + size += sizeof(struct mlx5_wqe_data_seg) / 16; + dpseg++; + } + } + } + + mlx5_opcode = mlx5_ib_opcode[wr->opcode]; + ctrl->opmod_idx_opcode = cpu_to_be32(((u32)(qp->sq.cur_post) << 8) | + mlx5_opcode | + ((u32)opmod << 24)); + ctrl->qpn_ds = cpu_to_be32(size | (qp->mqp.qpn << 8)); + ctrl->fm_ce_se |= get_fence(fence, wr); + qp->fm_cache = next_fence; + if (unlikely(qp->wq_sig)) + ctrl->signature = wq_sig(ctrl); + + qp->sq.wrid[idx] = wr->wr_id; + qp->sq.w_list[idx].opcode = mlx5_opcode; + qp->sq.wqe_head[idx] = qp->sq.head + nreq; + qp->sq.cur_post += DIV_ROUND_UP(size * 16, MLX5_SEND_WQE_BB); + qp->sq.w_list[idx].next = qp->sq.cur_post; + + if (0) + dump_wqe(qp, idx, size); + } + +out: + if (likely(nreq)) { + qp->sq.head += nreq; + + /* Make sure that descriptors are written before + * updating doorbell record and ringing the doorbell + */ + wmb(); + + qp->db.db[MLX5_SND_DBR] = cpu_to_be32(qp->sq.cur_post); + + if (bf->need_lock) + spin_lock(&bf->lock); + + /* TBD enable WC */ + if (0 && nreq == 1 && bf->uuarn && inl && size > 1 && size <= bf->buf_size / 16) { + mlx5_bf_copy(bf->reg + bf->offset, (u64 *)ctrl, ALIGN(size * 16, 64), qp); + /* wc_wmb(); */ + } else { + mlx5_write64((__be32 *)ctrl, bf->regreg + bf->offset, + MLX5_GET_DOORBELL_LOCK(&bf->lock32)); + /* Make sure doorbells don't leak out of SQ spinlock + * and reach the HCA out of order. + */ + mmiowb(); + } + bf->offset ^= bf->buf_size; + if (bf->need_lock) + spin_unlock(&bf->lock); + } + + spin_unlock_irqrestore(&qp->sq.lock, flags); + + return err; +} + +static void set_sig_seg(struct mlx5_rwqe_sig *sig, int size) +{ + sig->signature = calc_sig(sig, size); +} + +int mlx5_ib_post_recv(struct ib_qp *ibqp, struct ib_recv_wr *wr, + struct ib_recv_wr **bad_wr) +{ + struct mlx5_ib_qp *qp = to_mqp(ibqp); + struct mlx5_wqe_data_seg *scat; + struct mlx5_rwqe_sig *sig; + unsigned long flags; + int err = 0; + int nreq; + int ind; + int i; + + spin_lock_irqsave(&qp->rq.lock, flags); + + ind = qp->rq.head & (qp->rq.wqe_cnt - 1); + + for (nreq = 0; wr; nreq++, wr = wr->next) { + if (mlx5_wq_overflow(&qp->rq, nreq, qp->ibqp.recv_cq)) { + err = -ENOMEM; + *bad_wr = wr; + goto out; + } + + if (unlikely(wr->num_sge > qp->rq.max_gs)) { + err = -EINVAL; + *bad_wr = wr; + goto out; + } + + scat = get_recv_wqe(qp, ind); + if (qp->wq_sig) + scat++; + + for (i = 0; i < wr->num_sge; i++) + set_data_ptr_seg(scat + i, wr->sg_list + i); + + if (i < qp->rq.max_gs) { + scat[i].byte_count = 0; + scat[i].lkey = cpu_to_be32(MLX5_INVALID_LKEY); + scat[i].addr = 0; + } + + if (qp->wq_sig) { + sig = (struct mlx5_rwqe_sig *)scat; + set_sig_seg(sig, (qp->rq.max_gs + 1) << 2); + } + + qp->rq.wrid[ind] = wr->wr_id; + + ind = (ind + 1) & (qp->rq.wqe_cnt - 1); + } + +out: + if (likely(nreq)) { + qp->rq.head += nreq; + + /* Make sure that descriptors are written before + * doorbell record. + */ + wmb(); + + *qp->db.db = cpu_to_be32(qp->rq.head & 0xffff); + } + + spin_unlock_irqrestore(&qp->rq.lock, flags); + + return err; +} + +static inline enum ib_qp_state to_ib_qp_state(enum mlx5_qp_state mlx5_state) +{ + switch (mlx5_state) { + case MLX5_QP_STATE_RST: return IB_QPS_RESET; + case MLX5_QP_STATE_INIT: return IB_QPS_INIT; + case MLX5_QP_STATE_RTR: return IB_QPS_RTR; + case MLX5_QP_STATE_RTS: return IB_QPS_RTS; + case MLX5_QP_STATE_SQ_DRAINING: + case MLX5_QP_STATE_SQD: return IB_QPS_SQD; + case MLX5_QP_STATE_SQER: return IB_QPS_SQE; + case MLX5_QP_STATE_ERR: return IB_QPS_ERR; + default: return -1; + } +} + +static inline enum ib_mig_state to_ib_mig_state(int mlx5_mig_state) +{ + switch (mlx5_mig_state) { + case MLX5_QP_PM_ARMED: return IB_MIG_ARMED; + case MLX5_QP_PM_REARM: return IB_MIG_REARM; + case MLX5_QP_PM_MIGRATED: return IB_MIG_MIGRATED; + default: return -1; + } +} + +static int to_ib_qp_access_flags(int mlx5_flags) +{ + int ib_flags = 0; + + if (mlx5_flags & MLX5_QP_BIT_RRE) + ib_flags |= IB_ACCESS_REMOTE_READ; + if (mlx5_flags & MLX5_QP_BIT_RWE) + ib_flags |= IB_ACCESS_REMOTE_WRITE; + if (mlx5_flags & MLX5_QP_BIT_RAE) + ib_flags |= IB_ACCESS_REMOTE_ATOMIC; + + return ib_flags; +} + +static void to_ib_ah_attr(struct mlx5_ib_dev *ibdev, struct ib_ah_attr *ib_ah_attr, + struct mlx5_qp_path *path) +{ + struct mlx5_core_dev *dev = &ibdev->mdev; + + memset(ib_ah_attr, 0, sizeof(*ib_ah_attr)); + ib_ah_attr->port_num = path->port; + + if (ib_ah_attr->port_num == 0 || ib_ah_attr->port_num > dev->caps.num_ports) + return; + + ib_ah_attr->sl = path->sl & 0xf; + + ib_ah_attr->dlid = be16_to_cpu(path->rlid); + ib_ah_attr->src_path_bits = path->grh_mlid & 0x7f; + ib_ah_attr->static_rate = path->static_rate ? path->static_rate - 5 : 0; + ib_ah_attr->ah_flags = (path->grh_mlid & (1 << 7)) ? IB_AH_GRH : 0; + if (ib_ah_attr->ah_flags) { + ib_ah_attr->grh.sgid_index = path->mgid_index; + ib_ah_attr->grh.hop_limit = path->hop_limit; + ib_ah_attr->grh.traffic_class = + (be32_to_cpu(path->tclass_flowlabel) >> 20) & 0xff; + ib_ah_attr->grh.flow_label = + be32_to_cpu(path->tclass_flowlabel) & 0xfffff; + memcpy(ib_ah_attr->grh.dgid.raw, + path->rgid, sizeof(ib_ah_attr->grh.dgid.raw)); + } +} + +int mlx5_ib_query_qp(struct ib_qp *ibqp, struct ib_qp_attr *qp_attr, int qp_attr_mask, + struct ib_qp_init_attr *qp_init_attr) +{ + struct mlx5_ib_dev *dev = to_mdev(ibqp->device); + struct mlx5_ib_qp *qp = to_mqp(ibqp); + struct mlx5_query_qp_mbox_out *outb; + struct mlx5_qp_context *context; + int mlx5_state; + int err = 0; + + mutex_lock(&qp->mutex); + outb = kzalloc(sizeof(*outb), GFP_KERNEL); + if (!outb) { + err = -ENOMEM; + goto out; + } + context = &outb->ctx; + err = mlx5_core_qp_query(&dev->mdev, &qp->mqp, outb, sizeof(*outb)); + if (err) + goto out_free; + + mlx5_state = be32_to_cpu(context->flags) >> 28; + + qp->state = to_ib_qp_state(mlx5_state); + qp_attr->qp_state = qp->state; + qp_attr->path_mtu = context->mtu_msgmax >> 5; + qp_attr->path_mig_state = + to_ib_mig_state((be32_to_cpu(context->flags) >> 11) & 0x3); + qp_attr->qkey = be32_to_cpu(context->qkey); + qp_attr->rq_psn = be32_to_cpu(context->rnr_nextrecvpsn) & 0xffffff; + qp_attr->sq_psn = be32_to_cpu(context->next_send_psn) & 0xffffff; + qp_attr->dest_qp_num = be32_to_cpu(context->log_pg_sz_remote_qpn) & 0xffffff; + qp_attr->qp_access_flags = + to_ib_qp_access_flags(be32_to_cpu(context->params2)); + + if (qp->ibqp.qp_type == IB_QPT_RC || qp->ibqp.qp_type == IB_QPT_UC) { + to_ib_ah_attr(dev, &qp_attr->ah_attr, &context->pri_path); + to_ib_ah_attr(dev, &qp_attr->alt_ah_attr, &context->alt_path); + qp_attr->alt_pkey_index = context->alt_path.pkey_index & 0x7f; + qp_attr->alt_port_num = qp_attr->alt_ah_attr.port_num; + } + + qp_attr->pkey_index = context->pri_path.pkey_index & 0x7f; + qp_attr->port_num = context->pri_path.port; + + /* qp_attr->en_sqd_async_notify is only applicable in modify qp */ + qp_attr->sq_draining = mlx5_state == MLX5_QP_STATE_SQ_DRAINING; + + qp_attr->max_rd_atomic = 1 << ((be32_to_cpu(context->params1) >> 21) & 0x7); + + qp_attr->max_dest_rd_atomic = + 1 << ((be32_to_cpu(context->params2) >> 21) & 0x7); + qp_attr->min_rnr_timer = + (be32_to_cpu(context->rnr_nextrecvpsn) >> 24) & 0x1f; + qp_attr->timeout = context->pri_path.ackto_lt >> 3; + qp_attr->retry_cnt = (be32_to_cpu(context->params1) >> 16) & 0x7; + qp_attr->rnr_retry = (be32_to_cpu(context->params1) >> 13) & 0x7; + qp_attr->alt_timeout = context->alt_path.ackto_lt >> 3; + qp_attr->cur_qp_state = qp_attr->qp_state; + qp_attr->cap.max_recv_wr = qp->rq.wqe_cnt; + qp_attr->cap.max_recv_sge = qp->rq.max_gs; + + if (!ibqp->uobject) { + qp_attr->cap.max_send_wr = qp->sq.wqe_cnt; + qp_attr->cap.max_send_sge = qp->sq.max_gs; + } else { + qp_attr->cap.max_send_wr = 0; + qp_attr->cap.max_send_sge = 0; + } + + /* We don't support inline sends for kernel QPs (yet), and we + * don't know what userspace's value should be. + */ + qp_attr->cap.max_inline_data = 0; + + qp_init_attr->cap = qp_attr->cap; + + qp_init_attr->create_flags = 0; + if (qp->flags & MLX5_IB_QP_BLOCK_MULTICAST_LOOPBACK) + qp_init_attr->create_flags |= IB_QP_CREATE_BLOCK_MULTICAST_LOOPBACK; + + qp_init_attr->sq_sig_type = qp->sq_signal_bits & MLX5_WQE_CTRL_CQ_UPDATE ? + IB_SIGNAL_ALL_WR : IB_SIGNAL_REQ_WR; + +out_free: + kfree(outb); + +out: + mutex_unlock(&qp->mutex); + return err; +} + +struct ib_xrcd *mlx5_ib_alloc_xrcd(struct ib_device *ibdev, + struct ib_ucontext *context, + struct ib_udata *udata) +{ + struct mlx5_ib_dev *dev = to_mdev(ibdev); + struct mlx5_ib_xrcd *xrcd; + int err; + + if (!(dev->mdev.caps.flags & MLX5_DEV_CAP_FLAG_XRC)) + return ERR_PTR(-ENOSYS); + + xrcd = kmalloc(sizeof(*xrcd), GFP_KERNEL); + if (!xrcd) + return ERR_PTR(-ENOMEM); + + err = mlx5_core_xrcd_alloc(&dev->mdev, &xrcd->xrcdn); + if (err) { + kfree(xrcd); + return ERR_PTR(-ENOMEM); + } + + return &xrcd->ibxrcd; +} + +int mlx5_ib_dealloc_xrcd(struct ib_xrcd *xrcd) +{ + struct mlx5_ib_dev *dev = to_mdev(xrcd->device); + u32 xrcdn = to_mxrcd(xrcd)->xrcdn; + int err; + + err = mlx5_core_xrcd_dealloc(&dev->mdev, xrcdn); + if (err) { + mlx5_ib_warn(dev, "failed to dealloc xrcdn 0x%x\n", xrcdn); + return err; + } + + kfree(xrcd); + + return 0; +} diff --git a/drivers/infiniband/hw/mlx5/srq.c b/drivers/infiniband/hw/mlx5/srq.c new file mode 100644 index 000000000000..84d297afd6a9 --- /dev/null +++ b/drivers/infiniband/hw/mlx5/srq.c @@ -0,0 +1,473 @@ +/* + * Copyright (c) 2013, Mellanox Technologies inc. All rights reserved. + * + * This software is available to you under a choice of one of two + * licenses. You may choose to be licensed under the terms of the GNU + * General Public License (GPL) Version 2, available from the file + * COPYING in the main directory of this source tree, or the + * OpenIB.org BSD license below: + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include +#include +#include +#include +#include + +#include "mlx5_ib.h" +#include "user.h" + +/* not supported currently */ +static int srq_signature; + +static void *get_wqe(struct mlx5_ib_srq *srq, int n) +{ + return mlx5_buf_offset(&srq->buf, n << srq->msrq.wqe_shift); +} + +static void mlx5_ib_srq_event(struct mlx5_core_srq *srq, enum mlx5_event type) +{ + struct ib_event event; + struct ib_srq *ibsrq = &to_mibsrq(srq)->ibsrq; + + if (ibsrq->event_handler) { + event.device = ibsrq->device; + event.element.srq = ibsrq; + switch (type) { + case MLX5_EVENT_TYPE_SRQ_RQ_LIMIT: + event.event = IB_EVENT_SRQ_LIMIT_REACHED; + break; + case MLX5_EVENT_TYPE_SRQ_CATAS_ERROR: + event.event = IB_EVENT_SRQ_ERR; + break; + default: + pr_warn("mlx5_ib: Unexpected event type %d on SRQ %06x\n", + type, srq->srqn); + return; + } + + ibsrq->event_handler(&event, ibsrq->srq_context); + } +} + +static int create_srq_user(struct ib_pd *pd, struct mlx5_ib_srq *srq, + struct mlx5_create_srq_mbox_in **in, + struct ib_udata *udata, int buf_size, int *inlen) +{ + struct mlx5_ib_dev *dev = to_mdev(pd->device); + struct mlx5_ib_create_srq ucmd; + int err; + int npages; + int page_shift; + int ncont; + u32 offset; + + if (ib_copy_from_udata(&ucmd, udata, sizeof(ucmd))) { + mlx5_ib_dbg(dev, "failed copy udata\n"); + return -EFAULT; + } + srq->wq_sig = !!(ucmd.flags & MLX5_SRQ_FLAG_SIGNATURE); + + srq->umem = ib_umem_get(pd->uobject->context, ucmd.buf_addr, buf_size, + 0, 0); + if (IS_ERR(srq->umem)) { + mlx5_ib_dbg(dev, "failed umem get, size %d\n", buf_size); + err = PTR_ERR(srq->umem); + return err; + } + + mlx5_ib_cont_pages(srq->umem, ucmd.buf_addr, &npages, + &page_shift, &ncont, NULL); + err = mlx5_ib_get_buf_offset(ucmd.buf_addr, page_shift, + &offset); + if (err) { + mlx5_ib_warn(dev, "bad offset\n"); + goto err_umem; + } + + *inlen = sizeof(**in) + sizeof(*(*in)->pas) * ncont; + *in = mlx5_vzalloc(*inlen); + if (!(*in)) { + err = -ENOMEM; + goto err_umem; + } + + mlx5_ib_populate_pas(dev, srq->umem, page_shift, (*in)->pas, 0); + + err = mlx5_ib_db_map_user(to_mucontext(pd->uobject->context), + ucmd.db_addr, &srq->db); + if (err) { + mlx5_ib_dbg(dev, "map doorbell failed\n"); + goto err_in; + } + + (*in)->ctx.log_pg_sz = page_shift - PAGE_SHIFT; + (*in)->ctx.pgoff_cqn = cpu_to_be32(offset << 26); + + return 0; + +err_in: + mlx5_vfree(*in); + +err_umem: + ib_umem_release(srq->umem); + + return err; +} + +static int create_srq_kernel(struct mlx5_ib_dev *dev, struct mlx5_ib_srq *srq, + struct mlx5_create_srq_mbox_in **in, int buf_size, + int *inlen) +{ + int err; + int i; + struct mlx5_wqe_srq_next_seg *next; + int page_shift; + int npages; + + err = mlx5_db_alloc(&dev->mdev, &srq->db); + if (err) { + mlx5_ib_warn(dev, "alloc dbell rec failed\n"); + return err; + } + + *srq->db.db = 0; + + if (mlx5_buf_alloc(&dev->mdev, buf_size, PAGE_SIZE * 2, &srq->buf)) { + mlx5_ib_dbg(dev, "buf alloc failed\n"); + err = -ENOMEM; + goto err_db; + } + page_shift = srq->buf.page_shift; + + srq->head = 0; + srq->tail = srq->msrq.max - 1; + srq->wqe_ctr = 0; + + for (i = 0; i < srq->msrq.max; i++) { + next = get_wqe(srq, i); + next->next_wqe_index = + cpu_to_be16((i + 1) & (srq->msrq.max - 1)); + } + + npages = DIV_ROUND_UP(srq->buf.npages, 1 << (page_shift - PAGE_SHIFT)); + mlx5_ib_dbg(dev, "buf_size %d, page_shift %d, npages %d, calc npages %d\n", + buf_size, page_shift, srq->buf.npages, npages); + *inlen = sizeof(**in) + sizeof(*(*in)->pas) * npages; + *in = mlx5_vzalloc(*inlen); + if (!*in) { + err = -ENOMEM; + goto err_buf; + } + mlx5_fill_page_array(&srq->buf, (*in)->pas); + + srq->wrid = kmalloc(srq->msrq.max * sizeof(u64), GFP_KERNEL); + if (!srq->wrid) { + mlx5_ib_dbg(dev, "kmalloc failed %lu\n", + (unsigned long)(srq->msrq.max * sizeof(u64))); + err = -ENOMEM; + goto err_in; + } + srq->wq_sig = !!srq_signature; + + (*in)->ctx.log_pg_sz = page_shift - PAGE_SHIFT; + + return 0; + +err_in: + mlx5_vfree(*in); + +err_buf: + mlx5_buf_free(&dev->mdev, &srq->buf); + +err_db: + mlx5_db_free(&dev->mdev, &srq->db); + return err; +} + +static void destroy_srq_user(struct ib_pd *pd, struct mlx5_ib_srq *srq) +{ + mlx5_ib_db_unmap_user(to_mucontext(pd->uobject->context), &srq->db); + ib_umem_release(srq->umem); +} + + +static void destroy_srq_kernel(struct mlx5_ib_dev *dev, struct mlx5_ib_srq *srq) +{ + kfree(srq->wrid); + mlx5_buf_free(&dev->mdev, &srq->buf); + mlx5_db_free(&dev->mdev, &srq->db); +} + +struct ib_srq *mlx5_ib_create_srq(struct ib_pd *pd, + struct ib_srq_init_attr *init_attr, + struct ib_udata *udata) +{ + struct mlx5_ib_dev *dev = to_mdev(pd->device); + struct mlx5_ib_srq *srq; + int desc_size; + int buf_size; + int err; + struct mlx5_create_srq_mbox_in *uninitialized_var(in); + int uninitialized_var(inlen); + int is_xrc; + u32 flgs, xrcdn; + + /* Sanity check SRQ size before proceeding */ + if (init_attr->attr.max_wr >= dev->mdev.caps.max_srq_wqes) { + mlx5_ib_dbg(dev, "max_wr %d, cap %d\n", + init_attr->attr.max_wr, + dev->mdev.caps.max_srq_wqes); + return ERR_PTR(-EINVAL); + } + + srq = kmalloc(sizeof(*srq), GFP_KERNEL); + if (!srq) + return ERR_PTR(-ENOMEM); + + mutex_init(&srq->mutex); + spin_lock_init(&srq->lock); + srq->msrq.max = roundup_pow_of_two(init_attr->attr.max_wr + 1); + srq->msrq.max_gs = init_attr->attr.max_sge; + + desc_size = sizeof(struct mlx5_wqe_srq_next_seg) + + srq->msrq.max_gs * sizeof(struct mlx5_wqe_data_seg); + desc_size = roundup_pow_of_two(desc_size); + desc_size = max_t(int, 32, desc_size); + srq->msrq.max_avail_gather = (desc_size - sizeof(struct mlx5_wqe_srq_next_seg)) / + sizeof(struct mlx5_wqe_data_seg); + srq->msrq.wqe_shift = ilog2(desc_size); + buf_size = srq->msrq.max * desc_size; + mlx5_ib_dbg(dev, "desc_size 0x%x, req wr 0x%x, srq size 0x%x, max_gs 0x%x, max_avail_gather 0x%x\n", + desc_size, init_attr->attr.max_wr, srq->msrq.max, srq->msrq.max_gs, + srq->msrq.max_avail_gather); + + if (pd->uobject) + err = create_srq_user(pd, srq, &in, udata, buf_size, &inlen); + else + err = create_srq_kernel(dev, srq, &in, buf_size, &inlen); + + if (err) { + mlx5_ib_warn(dev, "create srq %s failed, err %d\n", + pd->uobject ? "user" : "kernel", err); + goto err_srq; + } + + is_xrc = (init_attr->srq_type == IB_SRQT_XRC); + in->ctx.state_log_sz = ilog2(srq->msrq.max); + flgs = ((srq->msrq.wqe_shift - 4) | (is_xrc << 5) | (srq->wq_sig << 7)) << 24; + xrcdn = 0; + if (is_xrc) { + xrcdn = to_mxrcd(init_attr->ext.xrc.xrcd)->xrcdn; + in->ctx.pgoff_cqn |= cpu_to_be32(to_mcq(init_attr->ext.xrc.cq)->mcq.cqn); + } else if (init_attr->srq_type == IB_SRQT_BASIC) { + xrcdn = to_mxrcd(dev->devr.x0)->xrcdn; + in->ctx.pgoff_cqn |= cpu_to_be32(to_mcq(dev->devr.c0)->mcq.cqn); + } + + in->ctx.flags_xrcd = cpu_to_be32((flgs & 0xFF000000) | (xrcdn & 0xFFFFFF)); + + in->ctx.pd = cpu_to_be32(to_mpd(pd)->pdn); + in->ctx.db_record = cpu_to_be64(srq->db.dma); + err = mlx5_core_create_srq(&dev->mdev, &srq->msrq, in, inlen); + mlx5_vfree(in); + if (err) { + mlx5_ib_dbg(dev, "create SRQ failed, err %d\n", err); + goto err_srq; + } + + mlx5_ib_dbg(dev, "create SRQ with srqn 0x%x\n", srq->msrq.srqn); + + srq->msrq.event = mlx5_ib_srq_event; + srq->ibsrq.ext.xrc.srq_num = srq->msrq.srqn; + + if (pd->uobject) + if (ib_copy_to_udata(udata, &srq->msrq.srqn, sizeof(__u32))) { + mlx5_ib_dbg(dev, "copy to user failed\n"); + err = -EFAULT; + goto err_core; + } + + init_attr->attr.max_wr = srq->msrq.max - 1; + + return &srq->ibsrq; + +err_core: + mlx5_core_destroy_srq(&dev->mdev, &srq->msrq); + if (pd->uobject) + destroy_srq_user(pd, srq); + else + destroy_srq_kernel(dev, srq); + +err_srq: + kfree(srq); + + return ERR_PTR(err); +} + +int mlx5_ib_modify_srq(struct ib_srq *ibsrq, struct ib_srq_attr *attr, + enum ib_srq_attr_mask attr_mask, struct ib_udata *udata) +{ + struct mlx5_ib_dev *dev = to_mdev(ibsrq->device); + struct mlx5_ib_srq *srq = to_msrq(ibsrq); + int ret; + + /* We don't support resizing SRQs yet */ + if (attr_mask & IB_SRQ_MAX_WR) + return -EINVAL; + + if (attr_mask & IB_SRQ_LIMIT) { + if (attr->srq_limit >= srq->msrq.max) + return -EINVAL; + + mutex_lock(&srq->mutex); + ret = mlx5_core_arm_srq(&dev->mdev, &srq->msrq, attr->srq_limit, 1); + mutex_unlock(&srq->mutex); + + if (ret) + return ret; + } + + return 0; +} + +int mlx5_ib_query_srq(struct ib_srq *ibsrq, struct ib_srq_attr *srq_attr) +{ + struct mlx5_ib_dev *dev = to_mdev(ibsrq->device); + struct mlx5_ib_srq *srq = to_msrq(ibsrq); + int ret; + struct mlx5_query_srq_mbox_out *out; + + out = kzalloc(sizeof(*out), GFP_KERNEL); + if (!out) + return -ENOMEM; + + ret = mlx5_core_query_srq(&dev->mdev, &srq->msrq, out); + if (ret) + goto out_box; + + srq_attr->srq_limit = be16_to_cpu(out->ctx.lwm); + srq_attr->max_wr = srq->msrq.max - 1; + srq_attr->max_sge = srq->msrq.max_gs; + +out_box: + kfree(out); + return ret; +} + +int mlx5_ib_destroy_srq(struct ib_srq *srq) +{ + struct mlx5_ib_dev *dev = to_mdev(srq->device); + struct mlx5_ib_srq *msrq = to_msrq(srq); + + mlx5_core_destroy_srq(&dev->mdev, &msrq->msrq); + + if (srq->uobject) { + mlx5_ib_db_unmap_user(to_mucontext(srq->uobject->context), &msrq->db); + ib_umem_release(msrq->umem); + } else { + kfree(msrq->wrid); + mlx5_buf_free(&dev->mdev, &msrq->buf); + mlx5_db_free(&dev->mdev, &msrq->db); + } + + kfree(srq); + return 0; +} + +void mlx5_ib_free_srq_wqe(struct mlx5_ib_srq *srq, int wqe_index) +{ + struct mlx5_wqe_srq_next_seg *next; + + /* always called with interrupts disabled. */ + spin_lock(&srq->lock); + + next = get_wqe(srq, srq->tail); + next->next_wqe_index = cpu_to_be16(wqe_index); + srq->tail = wqe_index; + + spin_unlock(&srq->lock); +} + +int mlx5_ib_post_srq_recv(struct ib_srq *ibsrq, struct ib_recv_wr *wr, + struct ib_recv_wr **bad_wr) +{ + struct mlx5_ib_srq *srq = to_msrq(ibsrq); + struct mlx5_wqe_srq_next_seg *next; + struct mlx5_wqe_data_seg *scat; + unsigned long flags; + int err = 0; + int nreq; + int i; + + spin_lock_irqsave(&srq->lock, flags); + + for (nreq = 0; wr; nreq++, wr = wr->next) { + if (unlikely(wr->num_sge > srq->msrq.max_gs)) { + err = -EINVAL; + *bad_wr = wr; + break; + } + + if (unlikely(srq->head == srq->tail)) { + err = -ENOMEM; + *bad_wr = wr; + break; + } + + srq->wrid[srq->head] = wr->wr_id; + + next = get_wqe(srq, srq->head); + srq->head = be16_to_cpu(next->next_wqe_index); + scat = (struct mlx5_wqe_data_seg *)(next + 1); + + for (i = 0; i < wr->num_sge; i++) { + scat[i].byte_count = cpu_to_be32(wr->sg_list[i].length); + scat[i].lkey = cpu_to_be32(wr->sg_list[i].lkey); + scat[i].addr = cpu_to_be64(wr->sg_list[i].addr); + } + + if (i < srq->msrq.max_avail_gather) { + scat[i].byte_count = 0; + scat[i].lkey = cpu_to_be32(MLX5_INVALID_LKEY); + scat[i].addr = 0; + } + } + + if (likely(nreq)) { + srq->wqe_ctr += nreq; + + /* Make sure that descriptors are written before + * doorbell record. + */ + wmb(); + + *srq->db.db = cpu_to_be32(srq->wqe_ctr); + } + + spin_unlock_irqrestore(&srq->lock, flags); + + return err; +} diff --git a/drivers/infiniband/hw/mlx5/user.h b/drivers/infiniband/hw/mlx5/user.h new file mode 100644 index 000000000000..a886de3e593c --- /dev/null +++ b/drivers/infiniband/hw/mlx5/user.h @@ -0,0 +1,121 @@ +/* + * Copyright (c) 2013, Mellanox Technologies inc. All rights reserved. + * + * This software is available to you under a choice of one of two + * licenses. You may choose to be licensed under the terms of the GNU + * General Public License (GPL) Version 2, available from the file + * COPYING in the main directory of this source tree, or the + * OpenIB.org BSD license below: + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#ifndef MLX5_IB_USER_H +#define MLX5_IB_USER_H + +#include + +enum { + MLX5_QP_FLAG_SIGNATURE = 1 << 0, + MLX5_QP_FLAG_SCATTER_CQE = 1 << 1, +}; + +enum { + MLX5_SRQ_FLAG_SIGNATURE = 1 << 0, +}; + + +/* Increment this value if any changes that break userspace ABI + * compatibility are made. + */ +#define MLX5_IB_UVERBS_ABI_VERSION 1 + +/* Make sure that all structs defined in this file remain laid out so + * that they pack the same way on 32-bit and 64-bit architectures (to + * avoid incompatibility between 32-bit userspace and 64-bit kernels). + * In particular do not use pointer types -- pass pointers in __u64 + * instead. + */ + +struct mlx5_ib_alloc_ucontext_req { + __u32 total_num_uuars; + __u32 num_low_latency_uuars; +}; + +struct mlx5_ib_alloc_ucontext_resp { + __u32 qp_tab_size; + __u32 bf_reg_size; + __u32 tot_uuars; + __u32 cache_line_size; + __u16 max_sq_desc_sz; + __u16 max_rq_desc_sz; + __u32 max_send_wqebb; + __u32 max_recv_wr; + __u32 max_srq_recv_wr; + __u16 num_ports; + __u16 reserved; +}; + +struct mlx5_ib_alloc_pd_resp { + __u32 pdn; +}; + +struct mlx5_ib_create_cq { + __u64 buf_addr; + __u64 db_addr; + __u32 cqe_size; +}; + +struct mlx5_ib_create_cq_resp { + __u32 cqn; + __u32 reserved; +}; + +struct mlx5_ib_resize_cq { + __u64 buf_addr; +}; + +struct mlx5_ib_create_srq { + __u64 buf_addr; + __u64 db_addr; + __u32 flags; +}; + +struct mlx5_ib_create_srq_resp { + __u32 srqn; + __u32 reserved; +}; + +struct mlx5_ib_create_qp { + __u64 buf_addr; + __u64 db_addr; + __u32 sq_wqe_count; + __u32 rq_wqe_count; + __u32 rq_wqe_shift; + __u32 flags; +}; + +struct mlx5_ib_create_qp_resp { + __u32 uuar_index; +}; +#endif /* MLX5_IB_USER_H */ diff --git a/drivers/net/ethernet/mellanox/Kconfig b/drivers/net/ethernet/mellanox/Kconfig index bcdbc14aeff0..8cf7563a8d92 100644 --- a/drivers/net/ethernet/mellanox/Kconfig +++ b/drivers/net/ethernet/mellanox/Kconfig @@ -19,5 +19,6 @@ config NET_VENDOR_MELLANOX if NET_VENDOR_MELLANOX source "drivers/net/ethernet/mellanox/mlx4/Kconfig" +source "drivers/net/ethernet/mellanox/mlx5/core/Kconfig" endif # NET_VENDOR_MELLANOX diff --git a/drivers/net/ethernet/mellanox/Makefile b/drivers/net/ethernet/mellanox/Makefile index 37afb9683372..38fe32ef5e5f 100644 --- a/drivers/net/ethernet/mellanox/Makefile +++ b/drivers/net/ethernet/mellanox/Makefile @@ -3,3 +3,4 @@ # obj-$(CONFIG_MLX4_CORE) += mlx4/ +obj-$(CONFIG_MLX5_CORE) += mlx5/core/ diff --git a/drivers/net/ethernet/mellanox/mlx5/core/Kconfig b/drivers/net/ethernet/mellanox/mlx5/core/Kconfig new file mode 100644 index 000000000000..21962828925a --- /dev/null +++ b/drivers/net/ethernet/mellanox/mlx5/core/Kconfig @@ -0,0 +1,18 @@ +# +# Mellanox driver configuration +# + +config MLX5_CORE + tristate + depends on PCI && X86 + default n + +config MLX5_DEBUG + bool "Verbose debugging output" if (MLX5_CORE && EXPERT) + depends on MLX5_CORE + default y + ---help--- + This option causes debugging code to be compiled into the + mlx5_core driver. The output can be turned on via the + debug_mask module parameter (which can also be set after + the driver is loaded through sysfs). diff --git a/drivers/net/ethernet/mellanox/mlx5/core/Makefile b/drivers/net/ethernet/mellanox/mlx5/core/Makefile new file mode 100644 index 000000000000..105780bb980b --- /dev/null +++ b/drivers/net/ethernet/mellanox/mlx5/core/Makefile @@ -0,0 +1,5 @@ +obj-$(CONFIG_MLX5_CORE) += mlx5_core.o + +mlx5_core-y := main.o cmd.o debugfs.o fw.o eq.o uar.o pagealloc.o \ + health.o mcg.o cq.o srq.o alloc.o qp.o port.o mr.o pd.o \ + mad.o diff --git a/drivers/net/ethernet/mellanox/mlx5/core/alloc.c b/drivers/net/ethernet/mellanox/mlx5/core/alloc.c new file mode 100644 index 000000000000..b215742b842f --- /dev/null +++ b/drivers/net/ethernet/mellanox/mlx5/core/alloc.c @@ -0,0 +1,238 @@ +/* + * Copyright (c) 2013, Mellanox Technologies inc. All rights reserved. + * + * This software is available to you under a choice of one of two + * licenses. You may choose to be licensed under the terms of the GNU + * General Public License (GPL) Version 2, available from the file + * COPYING in the main directory of this source tree, or the + * OpenIB.org BSD license below: + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "mlx5_core.h" + +/* Handling for queue buffers -- we allocate a bunch of memory and + * register it in a memory region at HCA virtual address 0. If the + * requested size is > max_direct, we split the allocation into + * multiple pages, so we don't require too much contiguous memory. + */ + +int mlx5_buf_alloc(struct mlx5_core_dev *dev, int size, int max_direct, + struct mlx5_buf *buf) +{ + dma_addr_t t; + + buf->size = size; + if (size <= max_direct) { + buf->nbufs = 1; + buf->npages = 1; + buf->page_shift = get_order(size) + PAGE_SHIFT; + buf->direct.buf = dma_zalloc_coherent(&dev->pdev->dev, + size, &t, GFP_KERNEL); + if (!buf->direct.buf) + return -ENOMEM; + + buf->direct.map = t; + + while (t & ((1 << buf->page_shift) - 1)) { + --buf->page_shift; + buf->npages *= 2; + } + } else { + int i; + + buf->direct.buf = NULL; + buf->nbufs = (size + PAGE_SIZE - 1) / PAGE_SIZE; + buf->npages = buf->nbufs; + buf->page_shift = PAGE_SHIFT; + buf->page_list = kcalloc(buf->nbufs, sizeof(*buf->page_list), + GFP_KERNEL); + if (!buf->page_list) + return -ENOMEM; + + for (i = 0; i < buf->nbufs; i++) { + buf->page_list[i].buf = + dma_zalloc_coherent(&dev->pdev->dev, PAGE_SIZE, + &t, GFP_KERNEL); + if (!buf->page_list[i].buf) + goto err_free; + + buf->page_list[i].map = t; + } + + if (BITS_PER_LONG == 64) { + struct page **pages; + pages = kmalloc(sizeof(*pages) * buf->nbufs, GFP_KERNEL); + if (!pages) + goto err_free; + for (i = 0; i < buf->nbufs; i++) + pages[i] = virt_to_page(buf->page_list[i].buf); + buf->direct.buf = vmap(pages, buf->nbufs, VM_MAP, PAGE_KERNEL); + kfree(pages); + if (!buf->direct.buf) + goto err_free; + } + } + + return 0; + +err_free: + mlx5_buf_free(dev, buf); + + return -ENOMEM; +} +EXPORT_SYMBOL_GPL(mlx5_buf_alloc); + +void mlx5_buf_free(struct mlx5_core_dev *dev, struct mlx5_buf *buf) +{ + int i; + + if (buf->nbufs == 1) + dma_free_coherent(&dev->pdev->dev, buf->size, buf->direct.buf, + buf->direct.map); + else { + if (BITS_PER_LONG == 64 && buf->direct.buf) + vunmap(buf->direct.buf); + + for (i = 0; i < buf->nbufs; i++) + if (buf->page_list[i].buf) + dma_free_coherent(&dev->pdev->dev, PAGE_SIZE, + buf->page_list[i].buf, + buf->page_list[i].map); + kfree(buf->page_list); + } +} +EXPORT_SYMBOL_GPL(mlx5_buf_free); + +static struct mlx5_db_pgdir *mlx5_alloc_db_pgdir(struct device *dma_device) +{ + struct mlx5_db_pgdir *pgdir; + + pgdir = kzalloc(sizeof(*pgdir), GFP_KERNEL); + if (!pgdir) + return NULL; + + bitmap_fill(pgdir->bitmap, MLX5_DB_PER_PAGE); + pgdir->db_page = dma_alloc_coherent(dma_device, PAGE_SIZE, + &pgdir->db_dma, GFP_KERNEL); + if (!pgdir->db_page) { + kfree(pgdir); + return NULL; + } + + return pgdir; +} + +static int mlx5_alloc_db_from_pgdir(struct mlx5_db_pgdir *pgdir, + struct mlx5_db *db) +{ + int offset; + int i; + + i = find_first_bit(pgdir->bitmap, MLX5_DB_PER_PAGE); + if (i >= MLX5_DB_PER_PAGE) + return -ENOMEM; + + __clear_bit(i, pgdir->bitmap); + + db->u.pgdir = pgdir; + db->index = i; + offset = db->index * L1_CACHE_BYTES; + db->db = pgdir->db_page + offset / sizeof(*pgdir->db_page); + db->dma = pgdir->db_dma + offset; + + return 0; +} + +int mlx5_db_alloc(struct mlx5_core_dev *dev, struct mlx5_db *db) +{ + struct mlx5_db_pgdir *pgdir; + int ret = 0; + + mutex_lock(&dev->priv.pgdir_mutex); + + list_for_each_entry(pgdir, &dev->priv.pgdir_list, list) + if (!mlx5_alloc_db_from_pgdir(pgdir, db)) + goto out; + + pgdir = mlx5_alloc_db_pgdir(&(dev->pdev->dev)); + if (!pgdir) { + ret = -ENOMEM; + goto out; + } + + list_add(&pgdir->list, &dev->priv.pgdir_list); + + /* This should never fail -- we just allocated an empty page: */ + WARN_ON(mlx5_alloc_db_from_pgdir(pgdir, db)); + +out: + mutex_unlock(&dev->priv.pgdir_mutex); + + return ret; +} +EXPORT_SYMBOL_GPL(mlx5_db_alloc); + +void mlx5_db_free(struct mlx5_core_dev *dev, struct mlx5_db *db) +{ + mutex_lock(&dev->priv.pgdir_mutex); + + __set_bit(db->index, db->u.pgdir->bitmap); + + if (bitmap_full(db->u.pgdir->bitmap, MLX5_DB_PER_PAGE)) { + dma_free_coherent(&(dev->pdev->dev), PAGE_SIZE, + db->u.pgdir->db_page, db->u.pgdir->db_dma); + list_del(&db->u.pgdir->list); + kfree(db->u.pgdir); + } + + mutex_unlock(&dev->priv.pgdir_mutex); +} +EXPORT_SYMBOL_GPL(mlx5_db_free); + + +void mlx5_fill_page_array(struct mlx5_buf *buf, __be64 *pas) +{ + u64 addr; + int i; + + for (i = 0; i < buf->npages; i++) { + if (buf->nbufs == 1) + addr = buf->direct.map + (i << buf->page_shift); + else + addr = buf->page_list[i].map; + + pas[i] = cpu_to_be64(addr); + } +} +EXPORT_SYMBOL_GPL(mlx5_fill_page_array); diff --git a/drivers/net/ethernet/mellanox/mlx5/core/cmd.c b/drivers/net/ethernet/mellanox/mlx5/core/cmd.c new file mode 100644 index 000000000000..c1c0eef89694 --- /dev/null +++ b/drivers/net/ethernet/mellanox/mlx5/core/cmd.c @@ -0,0 +1,1515 @@ +/* + * Copyright (c) 2013, Mellanox Technologies inc. All rights reserved. + * + * This software is available to you under a choice of one of two + * licenses. You may choose to be licensed under the terms of the GNU + * General Public License (GPL) Version 2, available from the file + * COPYING in the main directory of this source tree, or the + * OpenIB.org BSD license below: + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "mlx5_core.h" + +enum { + CMD_IF_REV = 3, +}; + +enum { + CMD_MODE_POLLING, + CMD_MODE_EVENTS +}; + +enum { + NUM_LONG_LISTS = 2, + NUM_MED_LISTS = 64, + LONG_LIST_SIZE = (2ULL * 1024 * 1024 * 1024 / PAGE_SIZE) * 8 + 16 + + MLX5_CMD_DATA_BLOCK_SIZE, + MED_LIST_SIZE = 16 + MLX5_CMD_DATA_BLOCK_SIZE, +}; + +enum { + MLX5_CMD_DELIVERY_STAT_OK = 0x0, + MLX5_CMD_DELIVERY_STAT_SIGNAT_ERR = 0x1, + MLX5_CMD_DELIVERY_STAT_TOK_ERR = 0x2, + MLX5_CMD_DELIVERY_STAT_BAD_BLK_NUM_ERR = 0x3, + MLX5_CMD_DELIVERY_STAT_OUT_PTR_ALIGN_ERR = 0x4, + MLX5_CMD_DELIVERY_STAT_IN_PTR_ALIGN_ERR = 0x5, + MLX5_CMD_DELIVERY_STAT_FW_ERR = 0x6, + MLX5_CMD_DELIVERY_STAT_IN_LENGTH_ERR = 0x7, + MLX5_CMD_DELIVERY_STAT_OUT_LENGTH_ERR = 0x8, + MLX5_CMD_DELIVERY_STAT_RES_FLD_NOT_CLR_ERR = 0x9, + MLX5_CMD_DELIVERY_STAT_CMD_DESCR_ERR = 0x10, +}; + +enum { + MLX5_CMD_STAT_OK = 0x0, + MLX5_CMD_STAT_INT_ERR = 0x1, + MLX5_CMD_STAT_BAD_OP_ERR = 0x2, + MLX5_CMD_STAT_BAD_PARAM_ERR = 0x3, + MLX5_CMD_STAT_BAD_SYS_STATE_ERR = 0x4, + MLX5_CMD_STAT_BAD_RES_ERR = 0x5, + MLX5_CMD_STAT_RES_BUSY = 0x6, + MLX5_CMD_STAT_LIM_ERR = 0x8, + MLX5_CMD_STAT_BAD_RES_STATE_ERR = 0x9, + MLX5_CMD_STAT_IX_ERR = 0xa, + MLX5_CMD_STAT_NO_RES_ERR = 0xf, + MLX5_CMD_STAT_BAD_INP_LEN_ERR = 0x50, + MLX5_CMD_STAT_BAD_OUTP_LEN_ERR = 0x51, + MLX5_CMD_STAT_BAD_QP_STATE_ERR = 0x10, + MLX5_CMD_STAT_BAD_PKT_ERR = 0x30, + MLX5_CMD_STAT_BAD_SIZE_OUTS_CQES_ERR = 0x40, +}; + +static struct mlx5_cmd_work_ent *alloc_cmd(struct mlx5_cmd *cmd, + struct mlx5_cmd_msg *in, + struct mlx5_cmd_msg *out, + mlx5_cmd_cbk_t cbk, + void *context, int page_queue) +{ + gfp_t alloc_flags = cbk ? GFP_ATOMIC : GFP_KERNEL; + struct mlx5_cmd_work_ent *ent; + + ent = kzalloc(sizeof(*ent), alloc_flags); + if (!ent) + return ERR_PTR(-ENOMEM); + + ent->in = in; + ent->out = out; + ent->callback = cbk; + ent->context = context; + ent->cmd = cmd; + ent->page_queue = page_queue; + + return ent; +} + +static u8 alloc_token(struct mlx5_cmd *cmd) +{ + u8 token; + + spin_lock(&cmd->token_lock); + token = cmd->token++ % 255 + 1; + spin_unlock(&cmd->token_lock); + + return token; +} + +static int alloc_ent(struct mlx5_cmd *cmd) +{ + unsigned long flags; + int ret; + + spin_lock_irqsave(&cmd->alloc_lock, flags); + ret = find_first_bit(&cmd->bitmask, cmd->max_reg_cmds); + if (ret < cmd->max_reg_cmds) + clear_bit(ret, &cmd->bitmask); + spin_unlock_irqrestore(&cmd->alloc_lock, flags); + + return ret < cmd->max_reg_cmds ? ret : -ENOMEM; +} + +static void free_ent(struct mlx5_cmd *cmd, int idx) +{ + unsigned long flags; + + spin_lock_irqsave(&cmd->alloc_lock, flags); + set_bit(idx, &cmd->bitmask); + spin_unlock_irqrestore(&cmd->alloc_lock, flags); +} + +static struct mlx5_cmd_layout *get_inst(struct mlx5_cmd *cmd, int idx) +{ + return cmd->cmd_buf + (idx << cmd->log_stride); +} + +static u8 xor8_buf(void *buf, int len) +{ + u8 *ptr = buf; + u8 sum = 0; + int i; + + for (i = 0; i < len; i++) + sum ^= ptr[i]; + + return sum; +} + +static int verify_block_sig(struct mlx5_cmd_prot_block *block) +{ + if (xor8_buf(block->rsvd0, sizeof(*block) - sizeof(block->data) - 1) != 0xff) + return -EINVAL; + + if (xor8_buf(block, sizeof(*block)) != 0xff) + return -EINVAL; + + return 0; +} + +static void calc_block_sig(struct mlx5_cmd_prot_block *block, u8 token) +{ + block->token = token; + block->ctrl_sig = ~xor8_buf(block->rsvd0, sizeof(*block) - sizeof(block->data) - 2); + block->sig = ~xor8_buf(block, sizeof(*block) - 1); +} + +static void calc_chain_sig(struct mlx5_cmd_msg *msg, u8 token) +{ + struct mlx5_cmd_mailbox *next = msg->next; + + while (next) { + calc_block_sig(next->buf, token); + next = next->next; + } +} + +static void set_signature(struct mlx5_cmd_work_ent *ent) +{ + ent->lay->sig = ~xor8_buf(ent->lay, sizeof(*ent->lay)); + calc_chain_sig(ent->in, ent->token); + calc_chain_sig(ent->out, ent->token); +} + +static void poll_timeout(struct mlx5_cmd_work_ent *ent) +{ + unsigned long poll_end = jiffies + msecs_to_jiffies(MLX5_CMD_TIMEOUT_MSEC + 1000); + u8 own; + + do { + own = ent->lay->status_own; + if (!(own & CMD_OWNER_HW)) { + ent->ret = 0; + return; + } + usleep_range(5000, 10000); + } while (time_before(jiffies, poll_end)); + + ent->ret = -ETIMEDOUT; +} + +static void free_cmd(struct mlx5_cmd_work_ent *ent) +{ + kfree(ent); +} + + +static int verify_signature(struct mlx5_cmd_work_ent *ent) +{ + struct mlx5_cmd_mailbox *next = ent->out->next; + int err; + u8 sig; + + sig = xor8_buf(ent->lay, sizeof(*ent->lay)); + if (sig != 0xff) + return -EINVAL; + + while (next) { + err = verify_block_sig(next->buf); + if (err) + return err; + + next = next->next; + } + + return 0; +} + +static void dump_buf(void *buf, int size, int data_only, int offset) +{ + __be32 *p = buf; + int i; + + for (i = 0; i < size; i += 16) { + pr_debug("%03x: %08x %08x %08x %08x\n", offset, be32_to_cpu(p[0]), + be32_to_cpu(p[1]), be32_to_cpu(p[2]), + be32_to_cpu(p[3])); + p += 4; + offset += 16; + } + if (!data_only) + pr_debug("\n"); +} + +const char *mlx5_command_str(int command) +{ + switch (command) { + case MLX5_CMD_OP_QUERY_HCA_CAP: + return "QUERY_HCA_CAP"; + + case MLX5_CMD_OP_SET_HCA_CAP: + return "SET_HCA_CAP"; + + case MLX5_CMD_OP_QUERY_ADAPTER: + return "QUERY_ADAPTER"; + + case MLX5_CMD_OP_INIT_HCA: + return "INIT_HCA"; + + case MLX5_CMD_OP_TEARDOWN_HCA: + return "TEARDOWN_HCA"; + + case MLX5_CMD_OP_QUERY_PAGES: + return "QUERY_PAGES"; + + case MLX5_CMD_OP_MANAGE_PAGES: + return "MANAGE_PAGES"; + + case MLX5_CMD_OP_CREATE_MKEY: + return "CREATE_MKEY"; + + case MLX5_CMD_OP_QUERY_MKEY: + return "QUERY_MKEY"; + + case MLX5_CMD_OP_DESTROY_MKEY: + return "DESTROY_MKEY"; + + case MLX5_CMD_OP_QUERY_SPECIAL_CONTEXTS: + return "QUERY_SPECIAL_CONTEXTS"; + + case MLX5_CMD_OP_CREATE_EQ: + return "CREATE_EQ"; + + case MLX5_CMD_OP_DESTROY_EQ: + return "DESTROY_EQ"; + + case MLX5_CMD_OP_QUERY_EQ: + return "QUERY_EQ"; + + case MLX5_CMD_OP_CREATE_CQ: + return "CREATE_CQ"; + + case MLX5_CMD_OP_DESTROY_CQ: + return "DESTROY_CQ"; + + case MLX5_CMD_OP_QUERY_CQ: + return "QUERY_CQ"; + + case MLX5_CMD_OP_MODIFY_CQ: + return "MODIFY_CQ"; + + case MLX5_CMD_OP_CREATE_QP: + return "CREATE_QP"; + + case MLX5_CMD_OP_DESTROY_QP: + return "DESTROY_QP"; + + case MLX5_CMD_OP_RST2INIT_QP: + return "RST2INIT_QP"; + + case MLX5_CMD_OP_INIT2RTR_QP: + return "INIT2RTR_QP"; + + case MLX5_CMD_OP_RTR2RTS_QP: + return "RTR2RTS_QP"; + + case MLX5_CMD_OP_RTS2RTS_QP: + return "RTS2RTS_QP"; + + case MLX5_CMD_OP_SQERR2RTS_QP: + return "SQERR2RTS_QP"; + + case MLX5_CMD_OP_2ERR_QP: + return "2ERR_QP"; + + case MLX5_CMD_OP_RTS2SQD_QP: + return "RTS2SQD_QP"; + + case MLX5_CMD_OP_SQD2RTS_QP: + return "SQD2RTS_QP"; + + case MLX5_CMD_OP_2RST_QP: + return "2RST_QP"; + + case MLX5_CMD_OP_QUERY_QP: + return "QUERY_QP"; + + case MLX5_CMD_OP_CONF_SQP: + return "CONF_SQP"; + + case MLX5_CMD_OP_MAD_IFC: + return "MAD_IFC"; + + case MLX5_CMD_OP_INIT2INIT_QP: + return "INIT2INIT_QP"; + + case MLX5_CMD_OP_SUSPEND_QP: + return "SUSPEND_QP"; + + case MLX5_CMD_OP_UNSUSPEND_QP: + return "UNSUSPEND_QP"; + + case MLX5_CMD_OP_SQD2SQD_QP: + return "SQD2SQD_QP"; + + case MLX5_CMD_OP_ALLOC_QP_COUNTER_SET: + return "ALLOC_QP_COUNTER_SET"; + + case MLX5_CMD_OP_DEALLOC_QP_COUNTER_SET: + return "DEALLOC_QP_COUNTER_SET"; + + case MLX5_CMD_OP_QUERY_QP_COUNTER_SET: + return "QUERY_QP_COUNTER_SET"; + + case MLX5_CMD_OP_CREATE_PSV: + return "CREATE_PSV"; + + case MLX5_CMD_OP_DESTROY_PSV: + return "DESTROY_PSV"; + + case MLX5_CMD_OP_QUERY_PSV: + return "QUERY_PSV"; + + case MLX5_CMD_OP_QUERY_SIG_RULE_TABLE: + return "QUERY_SIG_RULE_TABLE"; + + case MLX5_CMD_OP_QUERY_BLOCK_SIZE_TABLE: + return "QUERY_BLOCK_SIZE_TABLE"; + + case MLX5_CMD_OP_CREATE_SRQ: + return "CREATE_SRQ"; + + case MLX5_CMD_OP_DESTROY_SRQ: + return "DESTROY_SRQ"; + + case MLX5_CMD_OP_QUERY_SRQ: + return "QUERY_SRQ"; + + case MLX5_CMD_OP_ARM_RQ: + return "ARM_RQ"; + + case MLX5_CMD_OP_RESIZE_SRQ: + return "RESIZE_SRQ"; + + case MLX5_CMD_OP_ALLOC_PD: + return "ALLOC_PD"; + + case MLX5_CMD_OP_DEALLOC_PD: + return "DEALLOC_PD"; + + case MLX5_CMD_OP_ALLOC_UAR: + return "ALLOC_UAR"; + + case MLX5_CMD_OP_DEALLOC_UAR: + return "DEALLOC_UAR"; + + case MLX5_CMD_OP_ATTACH_TO_MCG: + return "ATTACH_TO_MCG"; + + case MLX5_CMD_OP_DETACH_FROM_MCG: + return "DETACH_FROM_MCG"; + + case MLX5_CMD_OP_ALLOC_XRCD: + return "ALLOC_XRCD"; + + case MLX5_CMD_OP_DEALLOC_XRCD: + return "DEALLOC_XRCD"; + + case MLX5_CMD_OP_ACCESS_REG: + return "MLX5_CMD_OP_ACCESS_REG"; + + default: return "unknown command opcode"; + } +} + +static void dump_command(struct mlx5_core_dev *dev, + struct mlx5_cmd_work_ent *ent, int input) +{ + u16 op = be16_to_cpu(((struct mlx5_inbox_hdr *)(ent->lay->in))->opcode); + struct mlx5_cmd_msg *msg = input ? ent->in : ent->out; + struct mlx5_cmd_mailbox *next = msg->next; + int data_only; + int offset = 0; + int dump_len; + + data_only = !!(mlx5_core_debug_mask & (1 << MLX5_CMD_DATA)); + + if (data_only) + mlx5_core_dbg_mask(dev, 1 << MLX5_CMD_DATA, + "dump command data %s(0x%x) %s\n", + mlx5_command_str(op), op, + input ? "INPUT" : "OUTPUT"); + else + mlx5_core_dbg(dev, "dump command %s(0x%x) %s\n", + mlx5_command_str(op), op, + input ? "INPUT" : "OUTPUT"); + + if (data_only) { + if (input) { + dump_buf(ent->lay->in, sizeof(ent->lay->in), 1, offset); + offset += sizeof(ent->lay->in); + } else { + dump_buf(ent->lay->out, sizeof(ent->lay->out), 1, offset); + offset += sizeof(ent->lay->out); + } + } else { + dump_buf(ent->lay, sizeof(*ent->lay), 0, offset); + offset += sizeof(*ent->lay); + } + + while (next && offset < msg->len) { + if (data_only) { + dump_len = min_t(int, MLX5_CMD_DATA_BLOCK_SIZE, msg->len - offset); + dump_buf(next->buf, dump_len, 1, offset); + offset += MLX5_CMD_DATA_BLOCK_SIZE; + } else { + mlx5_core_dbg(dev, "command block:\n"); + dump_buf(next->buf, sizeof(struct mlx5_cmd_prot_block), 0, offset); + offset += sizeof(struct mlx5_cmd_prot_block); + } + next = next->next; + } + + if (data_only) + pr_debug("\n"); +} + +static void cmd_work_handler(struct work_struct *work) +{ + struct mlx5_cmd_work_ent *ent = container_of(work, struct mlx5_cmd_work_ent, work); + struct mlx5_cmd *cmd = ent->cmd; + struct mlx5_core_dev *dev = container_of(cmd, struct mlx5_core_dev, cmd); + struct mlx5_cmd_layout *lay; + struct semaphore *sem; + + sem = ent->page_queue ? &cmd->pages_sem : &cmd->sem; + down(sem); + if (!ent->page_queue) { + ent->idx = alloc_ent(cmd); + if (ent->idx < 0) { + mlx5_core_err(dev, "failed to allocate command entry\n"); + up(sem); + return; + } + } else { + ent->idx = cmd->max_reg_cmds; + } + + ent->token = alloc_token(cmd); + cmd->ent_arr[ent->idx] = ent; + lay = get_inst(cmd, ent->idx); + ent->lay = lay; + memset(lay, 0, sizeof(*lay)); + memcpy(lay->in, ent->in->first.data, sizeof(lay->in)); + if (ent->in->next) + lay->in_ptr = cpu_to_be64(ent->in->next->dma); + lay->inlen = cpu_to_be32(ent->in->len); + if (ent->out->next) + lay->out_ptr = cpu_to_be64(ent->out->next->dma); + lay->outlen = cpu_to_be32(ent->out->len); + lay->type = MLX5_PCI_CMD_XPORT; + lay->token = ent->token; + lay->status_own = CMD_OWNER_HW; + if (!cmd->checksum_disabled) + set_signature(ent); + dump_command(dev, ent, 1); + ktime_get_ts(&ent->ts1); + + /* ring doorbell after the descriptor is valid */ + wmb(); + iowrite32be(1 << ent->idx, &dev->iseg->cmd_dbell); + mlx5_core_dbg(dev, "write 0x%x to command doorbell\n", 1 << ent->idx); + mmiowb(); + if (cmd->mode == CMD_MODE_POLLING) { + poll_timeout(ent); + /* make sure we read the descriptor after ownership is SW */ + rmb(); + mlx5_cmd_comp_handler(dev, 1UL << ent->idx); + } +} + +static const char *deliv_status_to_str(u8 status) +{ + switch (status) { + case MLX5_CMD_DELIVERY_STAT_OK: + return "no errors"; + case MLX5_CMD_DELIVERY_STAT_SIGNAT_ERR: + return "signature error"; + case MLX5_CMD_DELIVERY_STAT_TOK_ERR: + return "token error"; + case MLX5_CMD_DELIVERY_STAT_BAD_BLK_NUM_ERR: + return "bad block number"; + case MLX5_CMD_DELIVERY_STAT_OUT_PTR_ALIGN_ERR: + return "output pointer not aligned to block size"; + case MLX5_CMD_DELIVERY_STAT_IN_PTR_ALIGN_ERR: + return "input pointer not aligned to block size"; + case MLX5_CMD_DELIVERY_STAT_FW_ERR: + return "firmware internal error"; + case MLX5_CMD_DELIVERY_STAT_IN_LENGTH_ERR: + return "command input length error"; + case MLX5_CMD_DELIVERY_STAT_OUT_LENGTH_ERR: + return "command ouput length error"; + case MLX5_CMD_DELIVERY_STAT_RES_FLD_NOT_CLR_ERR: + return "reserved fields not cleared"; + case MLX5_CMD_DELIVERY_STAT_CMD_DESCR_ERR: + return "bad command descriptor type"; + default: + return "unknown status code"; + } +} + +static u16 msg_to_opcode(struct mlx5_cmd_msg *in) +{ + struct mlx5_inbox_hdr *hdr = (struct mlx5_inbox_hdr *)(in->first.data); + + return be16_to_cpu(hdr->opcode); +} + +static int wait_func(struct mlx5_core_dev *dev, struct mlx5_cmd_work_ent *ent) +{ + unsigned long timeout = msecs_to_jiffies(MLX5_CMD_TIMEOUT_MSEC); + struct mlx5_cmd *cmd = &dev->cmd; + int err; + + if (cmd->mode == CMD_MODE_POLLING) { + wait_for_completion(&ent->done); + err = ent->ret; + } else { + if (!wait_for_completion_timeout(&ent->done, timeout)) + err = -ETIMEDOUT; + else + err = 0; + } + if (err == -ETIMEDOUT) { + mlx5_core_warn(dev, "%s(0x%x) timeout. Will cause a leak of a command resource\n", + mlx5_command_str(msg_to_opcode(ent->in)), + msg_to_opcode(ent->in)); + } + mlx5_core_dbg(dev, "err %d, delivery status %s(%d)\n", err, + deliv_status_to_str(ent->status), ent->status); + + return err; +} + +/* Notes: + * 1. Callback functions may not sleep + * 2. page queue commands do not support asynchrous completion + */ +static int mlx5_cmd_invoke(struct mlx5_core_dev *dev, struct mlx5_cmd_msg *in, + struct mlx5_cmd_msg *out, mlx5_cmd_cbk_t callback, + void *context, int page_queue, u8 *status) +{ + struct mlx5_cmd *cmd = &dev->cmd; + struct mlx5_cmd_work_ent *ent; + ktime_t t1, t2, delta; + struct mlx5_cmd_stats *stats; + int err = 0; + s64 ds; + u16 op; + + if (callback && page_queue) + return -EINVAL; + + ent = alloc_cmd(cmd, in, out, callback, context, page_queue); + if (IS_ERR(ent)) + return PTR_ERR(ent); + + if (!callback) + init_completion(&ent->done); + + INIT_WORK(&ent->work, cmd_work_handler); + if (page_queue) { + cmd_work_handler(&ent->work); + } else if (!queue_work(cmd->wq, &ent->work)) { + mlx5_core_warn(dev, "failed to queue work\n"); + err = -ENOMEM; + goto out_free; + } + + if (!callback) { + err = wait_func(dev, ent); + if (err == -ETIMEDOUT) + goto out; + + t1 = timespec_to_ktime(ent->ts1); + t2 = timespec_to_ktime(ent->ts2); + delta = ktime_sub(t2, t1); + ds = ktime_to_ns(delta); + op = be16_to_cpu(((struct mlx5_inbox_hdr *)in->first.data)->opcode); + if (op < ARRAY_SIZE(cmd->stats)) { + stats = &cmd->stats[op]; + spin_lock(&stats->lock); + stats->sum += ds; + ++stats->n; + spin_unlock(&stats->lock); + } + mlx5_core_dbg_mask(dev, 1 << MLX5_CMD_TIME, + "fw exec time for %s is %lld nsec\n", + mlx5_command_str(op), ds); + *status = ent->status; + free_cmd(ent); + } + + return err; + +out_free: + free_cmd(ent); +out: + return err; +} + +static ssize_t dbg_write(struct file *filp, const char __user *buf, + size_t count, loff_t *pos) +{ + struct mlx5_core_dev *dev = filp->private_data; + struct mlx5_cmd_debug *dbg = &dev->cmd.dbg; + char lbuf[3]; + int err; + + if (!dbg->in_msg || !dbg->out_msg) + return -ENOMEM; + + if (copy_from_user(lbuf, buf, sizeof(lbuf))) + return -EPERM; + + lbuf[sizeof(lbuf) - 1] = 0; + + if (strcmp(lbuf, "go")) + return -EINVAL; + + err = mlx5_cmd_exec(dev, dbg->in_msg, dbg->inlen, dbg->out_msg, dbg->outlen); + + return err ? err : count; +} + + +static const struct file_operations fops = { + .owner = THIS_MODULE, + .open = simple_open, + .write = dbg_write, +}; + +static int mlx5_copy_to_msg(struct mlx5_cmd_msg *to, void *from, int size) +{ + struct mlx5_cmd_prot_block *block; + struct mlx5_cmd_mailbox *next; + int copy; + + if (!to || !from) + return -ENOMEM; + + copy = min_t(int, size, sizeof(to->first.data)); + memcpy(to->first.data, from, copy); + size -= copy; + from += copy; + + next = to->next; + while (size) { + if (!next) { + /* this is a BUG */ + return -ENOMEM; + } + + copy = min_t(int, size, MLX5_CMD_DATA_BLOCK_SIZE); + block = next->buf; + memcpy(block->data, from, copy); + from += copy; + size -= copy; + next = next->next; + } + + return 0; +} + +static int mlx5_copy_from_msg(void *to, struct mlx5_cmd_msg *from, int size) +{ + struct mlx5_cmd_prot_block *block; + struct mlx5_cmd_mailbox *next; + int copy; + + if (!to || !from) + return -ENOMEM; + + copy = min_t(int, size, sizeof(from->first.data)); + memcpy(to, from->first.data, copy); + size -= copy; + to += copy; + + next = from->next; + while (size) { + if (!next) { + /* this is a BUG */ + return -ENOMEM; + } + + copy = min_t(int, size, MLX5_CMD_DATA_BLOCK_SIZE); + block = next->buf; + if (xor8_buf(block, sizeof(*block)) != 0xff) + return -EINVAL; + + memcpy(to, block->data, copy); + to += copy; + size -= copy; + next = next->next; + } + + return 0; +} + +static struct mlx5_cmd_mailbox *alloc_cmd_box(struct mlx5_core_dev *dev, + gfp_t flags) +{ + struct mlx5_cmd_mailbox *mailbox; + + mailbox = kmalloc(sizeof(*mailbox), flags); + if (!mailbox) + return ERR_PTR(-ENOMEM); + + mailbox->buf = pci_pool_alloc(dev->cmd.pool, flags, + &mailbox->dma); + if (!mailbox->buf) { + mlx5_core_dbg(dev, "failed allocation\n"); + kfree(mailbox); + return ERR_PTR(-ENOMEM); + } + memset(mailbox->buf, 0, sizeof(struct mlx5_cmd_prot_block)); + mailbox->next = NULL; + + return mailbox; +} + +static void free_cmd_box(struct mlx5_core_dev *dev, + struct mlx5_cmd_mailbox *mailbox) +{ + pci_pool_free(dev->cmd.pool, mailbox->buf, mailbox->dma); + kfree(mailbox); +} + +static struct mlx5_cmd_msg *mlx5_alloc_cmd_msg(struct mlx5_core_dev *dev, + gfp_t flags, int size) +{ + struct mlx5_cmd_mailbox *tmp, *head = NULL; + struct mlx5_cmd_prot_block *block; + struct mlx5_cmd_msg *msg; + int blen; + int err; + int n; + int i; + + msg = kzalloc(sizeof(*msg), GFP_KERNEL); + if (!msg) + return ERR_PTR(-ENOMEM); + + blen = size - min_t(int, sizeof(msg->first.data), size); + n = (blen + MLX5_CMD_DATA_BLOCK_SIZE - 1) / MLX5_CMD_DATA_BLOCK_SIZE; + + for (i = 0; i < n; i++) { + tmp = alloc_cmd_box(dev, flags); + if (IS_ERR(tmp)) { + mlx5_core_warn(dev, "failed allocating block\n"); + err = PTR_ERR(tmp); + goto err_alloc; + } + + block = tmp->buf; + tmp->next = head; + block->next = cpu_to_be64(tmp->next ? tmp->next->dma : 0); + block->block_num = cpu_to_be32(n - i - 1); + head = tmp; + } + msg->next = head; + msg->len = size; + return msg; + +err_alloc: + while (head) { + tmp = head->next; + free_cmd_box(dev, head); + head = tmp; + } + kfree(msg); + + return ERR_PTR(err); +} + +static void mlx5_free_cmd_msg(struct mlx5_core_dev *dev, + struct mlx5_cmd_msg *msg) +{ + struct mlx5_cmd_mailbox *head = msg->next; + struct mlx5_cmd_mailbox *next; + + while (head) { + next = head->next; + free_cmd_box(dev, head); + head = next; + } + kfree(msg); +} + +static ssize_t data_write(struct file *filp, const char __user *buf, + size_t count, loff_t *pos) +{ + struct mlx5_core_dev *dev = filp->private_data; + struct mlx5_cmd_debug *dbg = &dev->cmd.dbg; + void *ptr; + int err; + + if (*pos != 0) + return -EINVAL; + + kfree(dbg->in_msg); + dbg->in_msg = NULL; + dbg->inlen = 0; + + ptr = kzalloc(count, GFP_KERNEL); + if (!ptr) + return -ENOMEM; + + if (copy_from_user(ptr, buf, count)) { + err = -EPERM; + goto out; + } + dbg->in_msg = ptr; + dbg->inlen = count; + + *pos = count; + + return count; + +out: + kfree(ptr); + return err; +} + +static ssize_t data_read(struct file *filp, char __user *buf, size_t count, + loff_t *pos) +{ + struct mlx5_core_dev *dev = filp->private_data; + struct mlx5_cmd_debug *dbg = &dev->cmd.dbg; + int copy; + + if (*pos) + return 0; + + if (!dbg->out_msg) + return -ENOMEM; + + copy = min_t(int, count, dbg->outlen); + if (copy_to_user(buf, dbg->out_msg, copy)) + return -EPERM; + + *pos += copy; + + return copy; +} + +static const struct file_operations dfops = { + .owner = THIS_MODULE, + .open = simple_open, + .write = data_write, + .read = data_read, +}; + +static ssize_t outlen_read(struct file *filp, char __user *buf, size_t count, + loff_t *pos) +{ + struct mlx5_core_dev *dev = filp->private_data; + struct mlx5_cmd_debug *dbg = &dev->cmd.dbg; + char outlen[8]; + int err; + + if (*pos) + return 0; + + err = snprintf(outlen, sizeof(outlen), "%d", dbg->outlen); + if (err < 0) + return err; + + if (copy_to_user(buf, &outlen, err)) + return -EPERM; + + *pos += err; + + return err; +} + +static ssize_t outlen_write(struct file *filp, const char __user *buf, + size_t count, loff_t *pos) +{ + struct mlx5_core_dev *dev = filp->private_data; + struct mlx5_cmd_debug *dbg = &dev->cmd.dbg; + char outlen_str[8]; + int outlen; + void *ptr; + int err; + + if (*pos != 0 || count > 6) + return -EINVAL; + + kfree(dbg->out_msg); + dbg->out_msg = NULL; + dbg->outlen = 0; + + if (copy_from_user(outlen_str, buf, count)) + return -EPERM; + + outlen_str[7] = 0; + + err = sscanf(outlen_str, "%d", &outlen); + if (err < 0) + return err; + + ptr = kzalloc(outlen, GFP_KERNEL); + if (!ptr) + return -ENOMEM; + + dbg->out_msg = ptr; + dbg->outlen = outlen; + + *pos = count; + + return count; +} + +static const struct file_operations olfops = { + .owner = THIS_MODULE, + .open = simple_open, + .write = outlen_write, + .read = outlen_read, +}; + +static void set_wqname(struct mlx5_core_dev *dev) +{ + struct mlx5_cmd *cmd = &dev->cmd; + + snprintf(cmd->wq_name, sizeof(cmd->wq_name), "mlx5_cmd_%s", + dev_name(&dev->pdev->dev)); +} + +static void clean_debug_files(struct mlx5_core_dev *dev) +{ + struct mlx5_cmd_debug *dbg = &dev->cmd.dbg; + + if (!mlx5_debugfs_root) + return; + + mlx5_cmdif_debugfs_cleanup(dev); + debugfs_remove_recursive(dbg->dbg_root); +} + +static int create_debugfs_files(struct mlx5_core_dev *dev) +{ + struct mlx5_cmd_debug *dbg = &dev->cmd.dbg; + int err = -ENOMEM; + + if (!mlx5_debugfs_root) + return 0; + + dbg->dbg_root = debugfs_create_dir("cmd", dev->priv.dbg_root); + if (!dbg->dbg_root) + return err; + + dbg->dbg_in = debugfs_create_file("in", 0400, dbg->dbg_root, + dev, &dfops); + if (!dbg->dbg_in) + goto err_dbg; + + dbg->dbg_out = debugfs_create_file("out", 0200, dbg->dbg_root, + dev, &dfops); + if (!dbg->dbg_out) + goto err_dbg; + + dbg->dbg_outlen = debugfs_create_file("out_len", 0600, dbg->dbg_root, + dev, &olfops); + if (!dbg->dbg_outlen) + goto err_dbg; + + dbg->dbg_status = debugfs_create_u8("status", 0600, dbg->dbg_root, + &dbg->status); + if (!dbg->dbg_status) + goto err_dbg; + + dbg->dbg_run = debugfs_create_file("run", 0200, dbg->dbg_root, dev, &fops); + if (!dbg->dbg_run) + goto err_dbg; + + mlx5_cmdif_debugfs_init(dev); + + return 0; + +err_dbg: + clean_debug_files(dev); + return err; +} + +void mlx5_cmd_use_events(struct mlx5_core_dev *dev) +{ + struct mlx5_cmd *cmd = &dev->cmd; + int i; + + for (i = 0; i < cmd->max_reg_cmds; i++) + down(&cmd->sem); + + down(&cmd->pages_sem); + + flush_workqueue(cmd->wq); + + cmd->mode = CMD_MODE_EVENTS; + + up(&cmd->pages_sem); + for (i = 0; i < cmd->max_reg_cmds; i++) + up(&cmd->sem); +} + +void mlx5_cmd_use_polling(struct mlx5_core_dev *dev) +{ + struct mlx5_cmd *cmd = &dev->cmd; + int i; + + for (i = 0; i < cmd->max_reg_cmds; i++) + down(&cmd->sem); + + down(&cmd->pages_sem); + + flush_workqueue(cmd->wq); + cmd->mode = CMD_MODE_POLLING; + + up(&cmd->pages_sem); + for (i = 0; i < cmd->max_reg_cmds; i++) + up(&cmd->sem); +} + +void mlx5_cmd_comp_handler(struct mlx5_core_dev *dev, unsigned long vector) +{ + struct mlx5_cmd *cmd = &dev->cmd; + struct mlx5_cmd_work_ent *ent; + mlx5_cmd_cbk_t callback; + void *context; + int err; + int i; + + for (i = 0; i < (1 << cmd->log_sz); i++) { + if (test_bit(i, &vector)) { + ent = cmd->ent_arr[i]; + ktime_get_ts(&ent->ts2); + memcpy(ent->out->first.data, ent->lay->out, sizeof(ent->lay->out)); + dump_command(dev, ent, 0); + if (!ent->ret) { + if (!cmd->checksum_disabled) + ent->ret = verify_signature(ent); + else + ent->ret = 0; + ent->status = ent->lay->status_own >> 1; + mlx5_core_dbg(dev, "command completed. ret 0x%x, delivery status %s(0x%x)\n", + ent->ret, deliv_status_to_str(ent->status), ent->status); + } + free_ent(cmd, ent->idx); + if (ent->callback) { + callback = ent->callback; + context = ent->context; + err = ent->ret; + free_cmd(ent); + callback(err, context); + } else { + complete(&ent->done); + } + if (ent->page_queue) + up(&cmd->pages_sem); + else + up(&cmd->sem); + } + } +} +EXPORT_SYMBOL(mlx5_cmd_comp_handler); + +static int status_to_err(u8 status) +{ + return status ? -1 : 0; /* TBD more meaningful codes */ +} + +static struct mlx5_cmd_msg *alloc_msg(struct mlx5_core_dev *dev, int in_size) +{ + struct mlx5_cmd_msg *msg = ERR_PTR(-ENOMEM); + struct mlx5_cmd *cmd = &dev->cmd; + struct cache_ent *ent = NULL; + + if (in_size > MED_LIST_SIZE && in_size <= LONG_LIST_SIZE) + ent = &cmd->cache.large; + else if (in_size > 16 && in_size <= MED_LIST_SIZE) + ent = &cmd->cache.med; + + if (ent) { + spin_lock(&ent->lock); + if (!list_empty(&ent->head)) { + msg = list_entry(ent->head.next, typeof(*msg), list); + /* For cached lists, we must explicitly state what is + * the real size + */ + msg->len = in_size; + list_del(&msg->list); + } + spin_unlock(&ent->lock); + } + + if (IS_ERR(msg)) + msg = mlx5_alloc_cmd_msg(dev, GFP_KERNEL, in_size); + + return msg; +} + +static void free_msg(struct mlx5_core_dev *dev, struct mlx5_cmd_msg *msg) +{ + if (msg->cache) { + spin_lock(&msg->cache->lock); + list_add_tail(&msg->list, &msg->cache->head); + spin_unlock(&msg->cache->lock); + } else { + mlx5_free_cmd_msg(dev, msg); + } +} + +static int is_manage_pages(struct mlx5_inbox_hdr *in) +{ + return be16_to_cpu(in->opcode) == MLX5_CMD_OP_MANAGE_PAGES; +} + +int mlx5_cmd_exec(struct mlx5_core_dev *dev, void *in, int in_size, void *out, + int out_size) +{ + struct mlx5_cmd_msg *inb; + struct mlx5_cmd_msg *outb; + int pages_queue; + int err; + u8 status = 0; + + pages_queue = is_manage_pages(in); + + inb = alloc_msg(dev, in_size); + if (IS_ERR(inb)) { + err = PTR_ERR(inb); + return err; + } + + err = mlx5_copy_to_msg(inb, in, in_size); + if (err) { + mlx5_core_warn(dev, "err %d\n", err); + goto out_in; + } + + outb = mlx5_alloc_cmd_msg(dev, GFP_KERNEL, out_size); + if (IS_ERR(outb)) { + err = PTR_ERR(outb); + goto out_in; + } + + err = mlx5_cmd_invoke(dev, inb, outb, NULL, NULL, pages_queue, &status); + if (err) + goto out_out; + + mlx5_core_dbg(dev, "err %d, status %d\n", err, status); + if (status) { + err = status_to_err(status); + goto out_out; + } + + err = mlx5_copy_from_msg(out, outb, out_size); + +out_out: + mlx5_free_cmd_msg(dev, outb); + +out_in: + free_msg(dev, inb); + return err; +} +EXPORT_SYMBOL(mlx5_cmd_exec); + +static void destroy_msg_cache(struct mlx5_core_dev *dev) +{ + struct mlx5_cmd *cmd = &dev->cmd; + struct mlx5_cmd_msg *msg; + struct mlx5_cmd_msg *n; + + list_for_each_entry_safe(msg, n, &cmd->cache.large.head, list) { + list_del(&msg->list); + mlx5_free_cmd_msg(dev, msg); + } + + list_for_each_entry_safe(msg, n, &cmd->cache.med.head, list) { + list_del(&msg->list); + mlx5_free_cmd_msg(dev, msg); + } +} + +static int create_msg_cache(struct mlx5_core_dev *dev) +{ + struct mlx5_cmd *cmd = &dev->cmd; + struct mlx5_cmd_msg *msg; + int err; + int i; + + spin_lock_init(&cmd->cache.large.lock); + INIT_LIST_HEAD(&cmd->cache.large.head); + spin_lock_init(&cmd->cache.med.lock); + INIT_LIST_HEAD(&cmd->cache.med.head); + + for (i = 0; i < NUM_LONG_LISTS; i++) { + msg = mlx5_alloc_cmd_msg(dev, GFP_KERNEL, LONG_LIST_SIZE); + if (IS_ERR(msg)) { + err = PTR_ERR(msg); + goto ex_err; + } + msg->cache = &cmd->cache.large; + list_add_tail(&msg->list, &cmd->cache.large.head); + } + + for (i = 0; i < NUM_MED_LISTS; i++) { + msg = mlx5_alloc_cmd_msg(dev, GFP_KERNEL, MED_LIST_SIZE); + if (IS_ERR(msg)) { + err = PTR_ERR(msg); + goto ex_err; + } + msg->cache = &cmd->cache.med; + list_add_tail(&msg->list, &cmd->cache.med.head); + } + + return 0; + +ex_err: + destroy_msg_cache(dev); + return err; +} + +int mlx5_cmd_init(struct mlx5_core_dev *dev) +{ + int size = sizeof(struct mlx5_cmd_prot_block); + int align = roundup_pow_of_two(size); + struct mlx5_cmd *cmd = &dev->cmd; + u32 cmd_h, cmd_l; + u16 cmd_if_rev; + int err; + int i; + + cmd_if_rev = cmdif_rev(dev); + if (cmd_if_rev != CMD_IF_REV) { + dev_err(&dev->pdev->dev, + "Driver cmdif rev(%d) differs from firmware's(%d)\n", + CMD_IF_REV, cmd_if_rev); + return -EINVAL; + } + + cmd->pool = pci_pool_create("mlx5_cmd", dev->pdev, size, align, 0); + if (!cmd->pool) + return -ENOMEM; + + cmd->cmd_buf = (void *)__get_free_pages(GFP_ATOMIC, 0); + if (!cmd->cmd_buf) { + err = -ENOMEM; + goto err_free_pool; + } + cmd->dma = dma_map_single(&dev->pdev->dev, cmd->cmd_buf, PAGE_SIZE, + DMA_BIDIRECTIONAL); + if (dma_mapping_error(&dev->pdev->dev, cmd->dma)) { + err = -ENOMEM; + goto err_free; + } + + cmd_l = ioread32be(&dev->iseg->cmdq_addr_l_sz) & 0xff; + cmd->log_sz = cmd_l >> 4 & 0xf; + cmd->log_stride = cmd_l & 0xf; + if (1 << cmd->log_sz > MLX5_MAX_COMMANDS) { + dev_err(&dev->pdev->dev, "firmware reports too many outstanding commands %d\n", + 1 << cmd->log_sz); + err = -EINVAL; + goto err_map; + } + + if (cmd->log_sz + cmd->log_stride > PAGE_SHIFT) { + dev_err(&dev->pdev->dev, "command queue size overflow\n"); + err = -EINVAL; + goto err_map; + } + + cmd->max_reg_cmds = (1 << cmd->log_sz) - 1; + cmd->bitmask = (1 << cmd->max_reg_cmds) - 1; + + cmd->cmdif_rev = ioread32be(&dev->iseg->cmdif_rev_fw_sub) >> 16; + if (cmd->cmdif_rev > CMD_IF_REV) { + dev_err(&dev->pdev->dev, "driver does not support command interface version. driver %d, firmware %d\n", + CMD_IF_REV, cmd->cmdif_rev); + err = -ENOTSUPP; + goto err_map; + } + + spin_lock_init(&cmd->alloc_lock); + spin_lock_init(&cmd->token_lock); + for (i = 0; i < ARRAY_SIZE(cmd->stats); i++) + spin_lock_init(&cmd->stats[i].lock); + + sema_init(&cmd->sem, cmd->max_reg_cmds); + sema_init(&cmd->pages_sem, 1); + + cmd_h = (u32)((u64)(cmd->dma) >> 32); + cmd_l = (u32)(cmd->dma); + if (cmd_l & 0xfff) { + dev_err(&dev->pdev->dev, "invalid command queue address\n"); + err = -ENOMEM; + goto err_map; + } + + iowrite32be(cmd_h, &dev->iseg->cmdq_addr_h); + iowrite32be(cmd_l, &dev->iseg->cmdq_addr_l_sz); + + /* Make sure firmware sees the complete address before we proceed */ + wmb(); + + mlx5_core_dbg(dev, "descriptor at dma 0x%llx\n", (unsigned long long)(cmd->dma)); + + cmd->mode = CMD_MODE_POLLING; + + err = create_msg_cache(dev); + if (err) { + dev_err(&dev->pdev->dev, "failed to create command cache\n"); + goto err_map; + } + + set_wqname(dev); + cmd->wq = create_singlethread_workqueue(cmd->wq_name); + if (!cmd->wq) { + dev_err(&dev->pdev->dev, "failed to create command workqueue\n"); + err = -ENOMEM; + goto err_cache; + } + + err = create_debugfs_files(dev); + if (err) { + err = -ENOMEM; + goto err_wq; + } + + return 0; + +err_wq: + destroy_workqueue(cmd->wq); + +err_cache: + destroy_msg_cache(dev); + +err_map: + dma_unmap_single(&dev->pdev->dev, cmd->dma, PAGE_SIZE, + DMA_BIDIRECTIONAL); +err_free: + free_pages((unsigned long)cmd->cmd_buf, 0); + +err_free_pool: + pci_pool_destroy(cmd->pool); + + return err; +} +EXPORT_SYMBOL(mlx5_cmd_init); + +void mlx5_cmd_cleanup(struct mlx5_core_dev *dev) +{ + struct mlx5_cmd *cmd = &dev->cmd; + + clean_debug_files(dev); + destroy_workqueue(cmd->wq); + destroy_msg_cache(dev); + dma_unmap_single(&dev->pdev->dev, cmd->dma, PAGE_SIZE, + DMA_BIDIRECTIONAL); + free_pages((unsigned long)cmd->cmd_buf, 0); + pci_pool_destroy(cmd->pool); +} +EXPORT_SYMBOL(mlx5_cmd_cleanup); + +static const char *cmd_status_str(u8 status) +{ + switch (status) { + case MLX5_CMD_STAT_OK: + return "OK"; + case MLX5_CMD_STAT_INT_ERR: + return "internal error"; + case MLX5_CMD_STAT_BAD_OP_ERR: + return "bad operation"; + case MLX5_CMD_STAT_BAD_PARAM_ERR: + return "bad parameter"; + case MLX5_CMD_STAT_BAD_SYS_STATE_ERR: + return "bad system state"; + case MLX5_CMD_STAT_BAD_RES_ERR: + return "bad resource"; + case MLX5_CMD_STAT_RES_BUSY: + return "resource busy"; + case MLX5_CMD_STAT_LIM_ERR: + return "limits exceeded"; + case MLX5_CMD_STAT_BAD_RES_STATE_ERR: + return "bad resource state"; + case MLX5_CMD_STAT_IX_ERR: + return "bad index"; + case MLX5_CMD_STAT_NO_RES_ERR: + return "no resources"; + case MLX5_CMD_STAT_BAD_INP_LEN_ERR: + return "bad input length"; + case MLX5_CMD_STAT_BAD_OUTP_LEN_ERR: + return "bad output length"; + case MLX5_CMD_STAT_BAD_QP_STATE_ERR: + return "bad QP state"; + case MLX5_CMD_STAT_BAD_PKT_ERR: + return "bad packet (discarded)"; + case MLX5_CMD_STAT_BAD_SIZE_OUTS_CQES_ERR: + return "bad size too many outstanding CQEs"; + default: + return "unknown status"; + } +} + +int mlx5_cmd_status_to_err(struct mlx5_outbox_hdr *hdr) +{ + if (!hdr->status) + return 0; + + pr_warn("command failed, status %s(0x%x), syndrome 0x%x\n", + cmd_status_str(hdr->status), hdr->status, + be32_to_cpu(hdr->syndrome)); + + switch (hdr->status) { + case MLX5_CMD_STAT_OK: return 0; + case MLX5_CMD_STAT_INT_ERR: return -EIO; + case MLX5_CMD_STAT_BAD_OP_ERR: return -EINVAL; + case MLX5_CMD_STAT_BAD_PARAM_ERR: return -EINVAL; + case MLX5_CMD_STAT_BAD_SYS_STATE_ERR: return -EIO; + case MLX5_CMD_STAT_BAD_RES_ERR: return -EINVAL; + case MLX5_CMD_STAT_RES_BUSY: return -EBUSY; + case MLX5_CMD_STAT_LIM_ERR: return -EINVAL; + case MLX5_CMD_STAT_BAD_RES_STATE_ERR: return -EINVAL; + case MLX5_CMD_STAT_IX_ERR: return -EINVAL; + case MLX5_CMD_STAT_NO_RES_ERR: return -EAGAIN; + case MLX5_CMD_STAT_BAD_INP_LEN_ERR: return -EIO; + case MLX5_CMD_STAT_BAD_OUTP_LEN_ERR: return -EIO; + case MLX5_CMD_STAT_BAD_QP_STATE_ERR: return -EINVAL; + case MLX5_CMD_STAT_BAD_PKT_ERR: return -EINVAL; + case MLX5_CMD_STAT_BAD_SIZE_OUTS_CQES_ERR: return -EINVAL; + default: return -EIO; + } +} diff --git a/drivers/net/ethernet/mellanox/mlx5/core/cq.c b/drivers/net/ethernet/mellanox/mlx5/core/cq.c new file mode 100644 index 000000000000..c2d660be6f76 --- /dev/null +++ b/drivers/net/ethernet/mellanox/mlx5/core/cq.c @@ -0,0 +1,224 @@ +/* + * Copyright (c) 2013, Mellanox Technologies inc. All rights reserved. + * + * This software is available to you under a choice of one of two + * licenses. You may choose to be licensed under the terms of the GNU + * General Public License (GPL) Version 2, available from the file + * COPYING in the main directory of this source tree, or the + * OpenIB.org BSD license below: + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include +#include +#include +#include +#include +#include +#include +#include "mlx5_core.h" + +void mlx5_cq_completion(struct mlx5_core_dev *dev, u32 cqn) +{ + struct mlx5_core_cq *cq; + struct mlx5_cq_table *table = &dev->priv.cq_table; + + spin_lock(&table->lock); + cq = radix_tree_lookup(&table->tree, cqn); + if (likely(cq)) + atomic_inc(&cq->refcount); + spin_unlock(&table->lock); + + if (!cq) { + mlx5_core_warn(dev, "Completion event for bogus CQ 0x%x\n", cqn); + return; + } + + ++cq->arm_sn; + + cq->comp(cq); + + if (atomic_dec_and_test(&cq->refcount)) + complete(&cq->free); +} + +void mlx5_cq_event(struct mlx5_core_dev *dev, u32 cqn, int event_type) +{ + struct mlx5_cq_table *table = &dev->priv.cq_table; + struct mlx5_core_cq *cq; + + spin_lock(&table->lock); + + cq = radix_tree_lookup(&table->tree, cqn); + if (cq) + atomic_inc(&cq->refcount); + + spin_unlock(&table->lock); + + if (!cq) { + mlx5_core_warn(dev, "Async event for bogus CQ 0x%x\n", cqn); + return; + } + + cq->event(cq, event_type); + + if (atomic_dec_and_test(&cq->refcount)) + complete(&cq->free); +} + + +int mlx5_core_create_cq(struct mlx5_core_dev *dev, struct mlx5_core_cq *cq, + struct mlx5_create_cq_mbox_in *in, int inlen) +{ + int err; + struct mlx5_cq_table *table = &dev->priv.cq_table; + struct mlx5_create_cq_mbox_out out; + struct mlx5_destroy_cq_mbox_in din; + struct mlx5_destroy_cq_mbox_out dout; + + in->hdr.opcode = cpu_to_be16(MLX5_CMD_OP_CREATE_CQ); + memset(&out, 0, sizeof(out)); + err = mlx5_cmd_exec(dev, in, inlen, &out, sizeof(out)); + if (err) + return err; + + if (out.hdr.status) + return mlx5_cmd_status_to_err(&out.hdr); + + cq->cqn = be32_to_cpu(out.cqn) & 0xffffff; + cq->cons_index = 0; + cq->arm_sn = 0; + atomic_set(&cq->refcount, 1); + init_completion(&cq->free); + + spin_lock_irq(&table->lock); + err = radix_tree_insert(&table->tree, cq->cqn, cq); + spin_unlock_irq(&table->lock); + if (err) + goto err_cmd; + + cq->pid = current->pid; + err = mlx5_debug_cq_add(dev, cq); + if (err) + mlx5_core_dbg(dev, "failed adding CP 0x%x to debug file system\n", + cq->cqn); + + return 0; + +err_cmd: + memset(&din, 0, sizeof(din)); + memset(&dout, 0, sizeof(dout)); + din.hdr.opcode = cpu_to_be16(MLX5_CMD_OP_DESTROY_CQ); + mlx5_cmd_exec(dev, &din, sizeof(din), &dout, sizeof(dout)); + return err; +} +EXPORT_SYMBOL(mlx5_core_create_cq); + +int mlx5_core_destroy_cq(struct mlx5_core_dev *dev, struct mlx5_core_cq *cq) +{ + struct mlx5_cq_table *table = &dev->priv.cq_table; + struct mlx5_destroy_cq_mbox_in in; + struct mlx5_destroy_cq_mbox_out out; + struct mlx5_core_cq *tmp; + int err; + + spin_lock_irq(&table->lock); + tmp = radix_tree_delete(&table->tree, cq->cqn); + spin_unlock_irq(&table->lock); + if (!tmp) { + mlx5_core_warn(dev, "cq 0x%x not found in tree\n", cq->cqn); + return -EINVAL; + } + if (tmp != cq) { + mlx5_core_warn(dev, "corruption on srqn 0x%x\n", cq->cqn); + return -EINVAL; + } + + memset(&in, 0, sizeof(in)); + memset(&out, 0, sizeof(out)); + in.hdr.opcode = cpu_to_be16(MLX5_CMD_OP_DESTROY_CQ); + in.cqn = cpu_to_be32(cq->cqn); + err = mlx5_cmd_exec(dev, &in, sizeof(in), &out, sizeof(out)); + if (err) + return err; + + if (out.hdr.status) + return mlx5_cmd_status_to_err(&out.hdr); + + synchronize_irq(cq->irqn); + + mlx5_debug_cq_remove(dev, cq); + if (atomic_dec_and_test(&cq->refcount)) + complete(&cq->free); + wait_for_completion(&cq->free); + + return 0; +} +EXPORT_SYMBOL(mlx5_core_destroy_cq); + +int mlx5_core_query_cq(struct mlx5_core_dev *dev, struct mlx5_core_cq *cq, + struct mlx5_query_cq_mbox_out *out) +{ + struct mlx5_query_cq_mbox_in in; + int err; + + memset(&in, 0, sizeof(in)); + memset(out, 0, sizeof(*out)); + + in.hdr.opcode = cpu_to_be16(MLX5_CMD_OP_QUERY_CQ); + in.cqn = cpu_to_be32(cq->cqn); + err = mlx5_cmd_exec(dev, &in, sizeof(in), out, sizeof(*out)); + if (err) + return err; + + if (out->hdr.status) + return mlx5_cmd_status_to_err(&out->hdr); + + return err; +} +EXPORT_SYMBOL(mlx5_core_query_cq); + + +int mlx5_core_modify_cq(struct mlx5_core_dev *dev, struct mlx5_core_cq *cq, + int type, struct mlx5_cq_modify_params *params) +{ + return -ENOSYS; +} + +int mlx5_init_cq_table(struct mlx5_core_dev *dev) +{ + struct mlx5_cq_table *table = &dev->priv.cq_table; + int err; + + spin_lock_init(&table->lock); + INIT_RADIX_TREE(&table->tree, GFP_ATOMIC); + err = mlx5_cq_debugfs_init(dev); + + return err; +} + +void mlx5_cleanup_cq_table(struct mlx5_core_dev *dev) +{ + mlx5_cq_debugfs_cleanup(dev); +} diff --git a/drivers/net/ethernet/mellanox/mlx5/core/debugfs.c b/drivers/net/ethernet/mellanox/mlx5/core/debugfs.c new file mode 100644 index 000000000000..5e9cf2b9aaf7 --- /dev/null +++ b/drivers/net/ethernet/mellanox/mlx5/core/debugfs.c @@ -0,0 +1,587 @@ +/* + * Copyright (c) 2013, Mellanox Technologies inc. All rights reserved. + * + * This software is available to you under a choice of one of two + * licenses. You may choose to be licensed under the terms of the GNU + * General Public License (GPL) Version 2, available from the file + * COPYING in the main directory of this source tree, or the + * OpenIB.org BSD license below: + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include +#include +#include +#include +#include +#include "mlx5_core.h" + +enum { + QP_PID, + QP_STATE, + QP_XPORT, + QP_MTU, + QP_N_RECV, + QP_RECV_SZ, + QP_N_SEND, + QP_LOG_PG_SZ, + QP_RQPN, +}; + +static char *qp_fields[] = { + [QP_PID] = "pid", + [QP_STATE] = "state", + [QP_XPORT] = "transport", + [QP_MTU] = "mtu", + [QP_N_RECV] = "num_recv", + [QP_RECV_SZ] = "rcv_wqe_sz", + [QP_N_SEND] = "num_send", + [QP_LOG_PG_SZ] = "log2_page_sz", + [QP_RQPN] = "remote_qpn", +}; + +enum { + EQ_NUM_EQES, + EQ_INTR, + EQ_LOG_PG_SZ, +}; + +static char *eq_fields[] = { + [EQ_NUM_EQES] = "num_eqes", + [EQ_INTR] = "intr", + [EQ_LOG_PG_SZ] = "log_page_size", +}; + +enum { + CQ_PID, + CQ_NUM_CQES, + CQ_LOG_PG_SZ, +}; + +static char *cq_fields[] = { + [CQ_PID] = "pid", + [CQ_NUM_CQES] = "num_cqes", + [CQ_LOG_PG_SZ] = "log_page_size", +}; + +struct dentry *mlx5_debugfs_root; +EXPORT_SYMBOL(mlx5_debugfs_root); + +void mlx5_register_debugfs(void) +{ + mlx5_debugfs_root = debugfs_create_dir("mlx5", NULL); + if (IS_ERR_OR_NULL(mlx5_debugfs_root)) + mlx5_debugfs_root = NULL; +} + +void mlx5_unregister_debugfs(void) +{ + debugfs_remove(mlx5_debugfs_root); +} + +int mlx5_qp_debugfs_init(struct mlx5_core_dev *dev) +{ + if (!mlx5_debugfs_root) + return 0; + + atomic_set(&dev->num_qps, 0); + + dev->priv.qp_debugfs = debugfs_create_dir("QPs", dev->priv.dbg_root); + if (!dev->priv.qp_debugfs) + return -ENOMEM; + + return 0; +} + +void mlx5_qp_debugfs_cleanup(struct mlx5_core_dev *dev) +{ + if (!mlx5_debugfs_root) + return; + + debugfs_remove_recursive(dev->priv.qp_debugfs); +} + +int mlx5_eq_debugfs_init(struct mlx5_core_dev *dev) +{ + if (!mlx5_debugfs_root) + return 0; + + dev->priv.eq_debugfs = debugfs_create_dir("EQs", dev->priv.dbg_root); + if (!dev->priv.eq_debugfs) + return -ENOMEM; + + return 0; +} + +void mlx5_eq_debugfs_cleanup(struct mlx5_core_dev *dev) +{ + if (!mlx5_debugfs_root) + return; + + debugfs_remove_recursive(dev->priv.eq_debugfs); +} + +static ssize_t average_read(struct file *filp, char __user *buf, size_t count, + loff_t *pos) +{ + struct mlx5_cmd_stats *stats; + u64 field = 0; + int ret; + int err; + char tbuf[22]; + + if (*pos) + return 0; + + stats = filp->private_data; + spin_lock(&stats->lock); + if (stats->n) + field = stats->sum / stats->n; + spin_unlock(&stats->lock); + ret = snprintf(tbuf, sizeof(tbuf), "%llu\n", field); + if (ret > 0) { + err = copy_to_user(buf, tbuf, ret); + if (err) + return err; + } + + *pos += ret; + return ret; +} + + +static ssize_t average_write(struct file *filp, const char __user *buf, + size_t count, loff_t *pos) +{ + struct mlx5_cmd_stats *stats; + + stats = filp->private_data; + spin_lock(&stats->lock); + stats->sum = 0; + stats->n = 0; + spin_unlock(&stats->lock); + + *pos += count; + + return count; +} + +static const struct file_operations stats_fops = { + .owner = THIS_MODULE, + .open = simple_open, + .read = average_read, + .write = average_write, +}; + +int mlx5_cmdif_debugfs_init(struct mlx5_core_dev *dev) +{ + struct mlx5_cmd_stats *stats; + struct dentry **cmd; + const char *namep; + int err; + int i; + + if (!mlx5_debugfs_root) + return 0; + + cmd = &dev->priv.cmdif_debugfs; + *cmd = debugfs_create_dir("commands", dev->priv.dbg_root); + if (!*cmd) + return -ENOMEM; + + for (i = 0; i < ARRAY_SIZE(dev->cmd.stats); i++) { + stats = &dev->cmd.stats[i]; + namep = mlx5_command_str(i); + if (strcmp(namep, "unknown command opcode")) { + stats->root = debugfs_create_dir(namep, *cmd); + if (!stats->root) { + mlx5_core_warn(dev, "failed adding command %d\n", + i); + err = -ENOMEM; + goto out; + } + + stats->avg = debugfs_create_file("average", 0400, + stats->root, stats, + &stats_fops); + if (!stats->avg) { + mlx5_core_warn(dev, "failed creating debugfs file\n"); + err = -ENOMEM; + goto out; + } + + stats->count = debugfs_create_u64("n", 0400, + stats->root, + &stats->n); + if (!stats->count) { + mlx5_core_warn(dev, "failed creating debugfs file\n"); + err = -ENOMEM; + goto out; + } + } + } + + return 0; +out: + debugfs_remove_recursive(dev->priv.cmdif_debugfs); + return err; +} + +void mlx5_cmdif_debugfs_cleanup(struct mlx5_core_dev *dev) +{ + if (!mlx5_debugfs_root) + return; + + debugfs_remove_recursive(dev->priv.cmdif_debugfs); +} + +int mlx5_cq_debugfs_init(struct mlx5_core_dev *dev) +{ + if (!mlx5_debugfs_root) + return 0; + + dev->priv.cq_debugfs = debugfs_create_dir("CQs", dev->priv.dbg_root); + if (!dev->priv.cq_debugfs) + return -ENOMEM; + + return 0; +} + +void mlx5_cq_debugfs_cleanup(struct mlx5_core_dev *dev) +{ + if (!mlx5_debugfs_root) + return; + + debugfs_remove_recursive(dev->priv.cq_debugfs); +} + +static u64 qp_read_field(struct mlx5_core_dev *dev, struct mlx5_core_qp *qp, + int index) +{ + struct mlx5_query_qp_mbox_out *out; + struct mlx5_qp_context *ctx; + u64 param = 0; + int err; + int no_sq; + + out = kzalloc(sizeof(*out), GFP_KERNEL); + if (!out) + return param; + + err = mlx5_core_qp_query(dev, qp, out, sizeof(*out)); + if (err) { + mlx5_core_warn(dev, "failed to query qp\n"); + goto out; + } + + ctx = &out->ctx; + switch (index) { + case QP_PID: + param = qp->pid; + break; + case QP_STATE: + param = be32_to_cpu(ctx->flags) >> 28; + break; + case QP_XPORT: + param = (be32_to_cpu(ctx->flags) >> 16) & 0xff; + break; + case QP_MTU: + param = ctx->mtu_msgmax >> 5; + break; + case QP_N_RECV: + param = 1 << ((ctx->rq_size_stride >> 3) & 0xf); + break; + case QP_RECV_SZ: + param = 1 << ((ctx->rq_size_stride & 7) + 4); + break; + case QP_N_SEND: + no_sq = be16_to_cpu(ctx->sq_crq_size) >> 15; + if (!no_sq) + param = 1 << (be16_to_cpu(ctx->sq_crq_size) >> 11); + else + param = 0; + break; + case QP_LOG_PG_SZ: + param = ((cpu_to_be32(ctx->log_pg_sz_remote_qpn) >> 24) & 0x1f); + param += 12; + break; + case QP_RQPN: + param = cpu_to_be32(ctx->log_pg_sz_remote_qpn) & 0xffffff; + break; + } + +out: + kfree(out); + return param; +} + +static u64 eq_read_field(struct mlx5_core_dev *dev, struct mlx5_eq *eq, + int index) +{ + struct mlx5_query_eq_mbox_out *out; + struct mlx5_eq_context *ctx; + u64 param = 0; + int err; + + out = kzalloc(sizeof(*out), GFP_KERNEL); + if (!out) + return param; + + ctx = &out->ctx; + + err = mlx5_core_eq_query(dev, eq, out, sizeof(*out)); + if (err) { + mlx5_core_warn(dev, "failed to query eq\n"); + goto out; + } + + switch (index) { + case EQ_NUM_EQES: + param = 1 << ((be32_to_cpu(ctx->log_sz_usr_page) >> 24) & 0x1f); + break; + case EQ_INTR: + param = ctx->intr; + break; + case EQ_LOG_PG_SZ: + param = (ctx->log_page_size & 0x1f) + 12; + break; + } + +out: + kfree(out); + return param; +} + +static u64 cq_read_field(struct mlx5_core_dev *dev, struct mlx5_core_cq *cq, + int index) +{ + struct mlx5_query_cq_mbox_out *out; + struct mlx5_cq_context *ctx; + u64 param = 0; + int err; + + out = kzalloc(sizeof(*out), GFP_KERNEL); + if (!out) + return param; + + ctx = &out->ctx; + + err = mlx5_core_query_cq(dev, cq, out); + if (err) { + mlx5_core_warn(dev, "failed to query cq\n"); + goto out; + } + + switch (index) { + case CQ_PID: + param = cq->pid; + break; + case CQ_NUM_CQES: + param = 1 << ((be32_to_cpu(ctx->log_sz_usr_page) >> 24) & 0x1f); + break; + case CQ_LOG_PG_SZ: + param = (ctx->log_pg_sz & 0x1f) + 12; + break; + } + +out: + kfree(out); + return param; +} + +static ssize_t dbg_read(struct file *filp, char __user *buf, size_t count, + loff_t *pos) +{ + struct mlx5_field_desc *desc; + struct mlx5_rsc_debug *d; + char tbuf[18]; + u64 field; + int ret; + int err; + + if (*pos) + return 0; + + desc = filp->private_data; + d = (void *)(desc - desc->i) - sizeof(*d); + switch (d->type) { + case MLX5_DBG_RSC_QP: + field = qp_read_field(d->dev, d->object, desc->i); + break; + + case MLX5_DBG_RSC_EQ: + field = eq_read_field(d->dev, d->object, desc->i); + break; + + case MLX5_DBG_RSC_CQ: + field = cq_read_field(d->dev, d->object, desc->i); + break; + + default: + mlx5_core_warn(d->dev, "invalid resource type %d\n", d->type); + return -EINVAL; + } + + ret = snprintf(tbuf, sizeof(tbuf), "0x%llx\n", field); + if (ret > 0) { + err = copy_to_user(buf, tbuf, ret); + if (err) + return err; + } + + *pos += ret; + return ret; +} + +static const struct file_operations fops = { + .owner = THIS_MODULE, + .open = simple_open, + .read = dbg_read, +}; + +static int add_res_tree(struct mlx5_core_dev *dev, enum dbg_rsc_type type, + struct dentry *root, struct mlx5_rsc_debug **dbg, + int rsn, char **field, int nfile, void *data) +{ + struct mlx5_rsc_debug *d; + char resn[32]; + int err; + int i; + + d = kzalloc(sizeof(*d) + nfile * sizeof(d->fields[0]), GFP_KERNEL); + if (!d) + return -ENOMEM; + + d->dev = dev; + d->object = data; + d->type = type; + sprintf(resn, "0x%x", rsn); + d->root = debugfs_create_dir(resn, root); + if (!d->root) { + err = -ENOMEM; + goto out_free; + } + + for (i = 0; i < nfile; i++) { + d->fields[i].i = i; + d->fields[i].dent = debugfs_create_file(field[i], 0400, + d->root, &d->fields[i], + &fops); + if (!d->fields[i].dent) { + err = -ENOMEM; + goto out_rem; + } + } + *dbg = d; + + return 0; +out_rem: + debugfs_remove_recursive(d->root); + +out_free: + kfree(d); + return err; +} + +static void rem_res_tree(struct mlx5_rsc_debug *d) +{ + debugfs_remove_recursive(d->root); + kfree(d); +} + +int mlx5_debug_qp_add(struct mlx5_core_dev *dev, struct mlx5_core_qp *qp) +{ + int err; + + if (!mlx5_debugfs_root) + return 0; + + err = add_res_tree(dev, MLX5_DBG_RSC_QP, dev->priv.qp_debugfs, + &qp->dbg, qp->qpn, qp_fields, + ARRAY_SIZE(qp_fields), qp); + if (err) + qp->dbg = NULL; + + return err; +} + +void mlx5_debug_qp_remove(struct mlx5_core_dev *dev, struct mlx5_core_qp *qp) +{ + if (!mlx5_debugfs_root) + return; + + if (qp->dbg) + rem_res_tree(qp->dbg); +} + + +int mlx5_debug_eq_add(struct mlx5_core_dev *dev, struct mlx5_eq *eq) +{ + int err; + + if (!mlx5_debugfs_root) + return 0; + + err = add_res_tree(dev, MLX5_DBG_RSC_EQ, dev->priv.eq_debugfs, + &eq->dbg, eq->eqn, eq_fields, + ARRAY_SIZE(eq_fields), eq); + if (err) + eq->dbg = NULL; + + return err; +} + +void mlx5_debug_eq_remove(struct mlx5_core_dev *dev, struct mlx5_eq *eq) +{ + if (!mlx5_debugfs_root) + return; + + if (eq->dbg) + rem_res_tree(eq->dbg); +} + +int mlx5_debug_cq_add(struct mlx5_core_dev *dev, struct mlx5_core_cq *cq) +{ + int err; + + if (!mlx5_debugfs_root) + return 0; + + err = add_res_tree(dev, MLX5_DBG_RSC_CQ, dev->priv.cq_debugfs, + &cq->dbg, cq->cqn, cq_fields, + ARRAY_SIZE(cq_fields), cq); + if (err) + cq->dbg = NULL; + + return err; +} + +void mlx5_debug_cq_remove(struct mlx5_core_dev *dev, struct mlx5_core_cq *cq) +{ + if (!mlx5_debugfs_root) + return; + + if (cq->dbg) + rem_res_tree(cq->dbg); +} diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eq.c b/drivers/net/ethernet/mellanox/mlx5/core/eq.c new file mode 100644 index 000000000000..c02cbcfd0fb8 --- /dev/null +++ b/drivers/net/ethernet/mellanox/mlx5/core/eq.c @@ -0,0 +1,521 @@ +/* + * Copyright (c) 2013, Mellanox Technologies inc. All rights reserved. + * + * This software is available to you under a choice of one of two + * licenses. You may choose to be licensed under the terms of the GNU + * General Public License (GPL) Version 2, available from the file + * COPYING in the main directory of this source tree, or the + * OpenIB.org BSD license below: + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include +#include +#include +#include +#include "mlx5_core.h" + +enum { + MLX5_EQE_SIZE = sizeof(struct mlx5_eqe), + MLX5_EQE_OWNER_INIT_VAL = 0x1, +}; + +enum { + MLX5_EQ_STATE_ARMED = 0x9, + MLX5_EQ_STATE_FIRED = 0xa, + MLX5_EQ_STATE_ALWAYS_ARMED = 0xb, +}; + +enum { + MLX5_NUM_SPARE_EQE = 0x80, + MLX5_NUM_ASYNC_EQE = 0x100, + MLX5_NUM_CMD_EQE = 32, +}; + +enum { + MLX5_EQ_DOORBEL_OFFSET = 0x40, +}; + +#define MLX5_ASYNC_EVENT_MASK ((1ull << MLX5_EVENT_TYPE_PATH_MIG) | \ + (1ull << MLX5_EVENT_TYPE_COMM_EST) | \ + (1ull << MLX5_EVENT_TYPE_SQ_DRAINED) | \ + (1ull << MLX5_EVENT_TYPE_CQ_ERROR) | \ + (1ull << MLX5_EVENT_TYPE_WQ_CATAS_ERROR) | \ + (1ull << MLX5_EVENT_TYPE_PATH_MIG_FAILED) | \ + (1ull << MLX5_EVENT_TYPE_WQ_INVAL_REQ_ERROR) | \ + (1ull << MLX5_EVENT_TYPE_WQ_ACCESS_ERROR) | \ + (1ull << MLX5_EVENT_TYPE_PORT_CHANGE) | \ + (1ull << MLX5_EVENT_TYPE_SRQ_CATAS_ERROR) | \ + (1ull << MLX5_EVENT_TYPE_SRQ_LAST_WQE) | \ + (1ull << MLX5_EVENT_TYPE_SRQ_RQ_LIMIT)) + +struct map_eq_in { + u64 mask; + u32 reserved; + u32 unmap_eqn; +}; + +struct cre_des_eq { + u8 reserved[15]; + u8 eqn; +}; + +static int mlx5_cmd_destroy_eq(struct mlx5_core_dev *dev, u8 eqn) +{ + struct mlx5_destroy_eq_mbox_in in; + struct mlx5_destroy_eq_mbox_out out; + int err; + + memset(&in, 0, sizeof(in)); + memset(&out, 0, sizeof(out)); + in.hdr.opcode = cpu_to_be16(MLX5_CMD_OP_DESTROY_EQ); + in.eqn = eqn; + err = mlx5_cmd_exec(dev, &in, sizeof(in), &out, sizeof(out)); + if (!err) + goto ex; + + if (out.hdr.status) + err = mlx5_cmd_status_to_err(&out.hdr); + +ex: + return err; +} + +static struct mlx5_eqe *get_eqe(struct mlx5_eq *eq, u32 entry) +{ + return mlx5_buf_offset(&eq->buf, entry * MLX5_EQE_SIZE); +} + +static struct mlx5_eqe *next_eqe_sw(struct mlx5_eq *eq) +{ + struct mlx5_eqe *eqe = get_eqe(eq, eq->cons_index & (eq->nent - 1)); + + return ((eqe->owner & 1) ^ !!(eq->cons_index & eq->nent)) ? NULL : eqe; +} + +static const char *eqe_type_str(u8 type) +{ + switch (type) { + case MLX5_EVENT_TYPE_COMP: + return "MLX5_EVENT_TYPE_COMP"; + case MLX5_EVENT_TYPE_PATH_MIG: + return "MLX5_EVENT_TYPE_PATH_MIG"; + case MLX5_EVENT_TYPE_COMM_EST: + return "MLX5_EVENT_TYPE_COMM_EST"; + case MLX5_EVENT_TYPE_SQ_DRAINED: + return "MLX5_EVENT_TYPE_SQ_DRAINED"; + case MLX5_EVENT_TYPE_SRQ_LAST_WQE: + return "MLX5_EVENT_TYPE_SRQ_LAST_WQE"; + case MLX5_EVENT_TYPE_SRQ_RQ_LIMIT: + return "MLX5_EVENT_TYPE_SRQ_RQ_LIMIT"; + case MLX5_EVENT_TYPE_CQ_ERROR: + return "MLX5_EVENT_TYPE_CQ_ERROR"; + case MLX5_EVENT_TYPE_WQ_CATAS_ERROR: + return "MLX5_EVENT_TYPE_WQ_CATAS_ERROR"; + case MLX5_EVENT_TYPE_PATH_MIG_FAILED: + return "MLX5_EVENT_TYPE_PATH_MIG_FAILED"; + case MLX5_EVENT_TYPE_WQ_INVAL_REQ_ERROR: + return "MLX5_EVENT_TYPE_WQ_INVAL_REQ_ERROR"; + case MLX5_EVENT_TYPE_WQ_ACCESS_ERROR: + return "MLX5_EVENT_TYPE_WQ_ACCESS_ERROR"; + case MLX5_EVENT_TYPE_SRQ_CATAS_ERROR: + return "MLX5_EVENT_TYPE_SRQ_CATAS_ERROR"; + case MLX5_EVENT_TYPE_INTERNAL_ERROR: + return "MLX5_EVENT_TYPE_INTERNAL_ERROR"; + case MLX5_EVENT_TYPE_PORT_CHANGE: + return "MLX5_EVENT_TYPE_PORT_CHANGE"; + case MLX5_EVENT_TYPE_GPIO_EVENT: + return "MLX5_EVENT_TYPE_GPIO_EVENT"; + case MLX5_EVENT_TYPE_REMOTE_CONFIG: + return "MLX5_EVENT_TYPE_REMOTE_CONFIG"; + case MLX5_EVENT_TYPE_DB_BF_CONGESTION: + return "MLX5_EVENT_TYPE_DB_BF_CONGESTION"; + case MLX5_EVENT_TYPE_STALL_EVENT: + return "MLX5_EVENT_TYPE_STALL_EVENT"; + case MLX5_EVENT_TYPE_CMD: + return "MLX5_EVENT_TYPE_CMD"; + case MLX5_EVENT_TYPE_PAGE_REQUEST: + return "MLX5_EVENT_TYPE_PAGE_REQUEST"; + default: + return "Unrecognized event"; + } +} + +static enum mlx5_dev_event port_subtype_event(u8 subtype) +{ + switch (subtype) { + case MLX5_PORT_CHANGE_SUBTYPE_DOWN: + return MLX5_DEV_EVENT_PORT_DOWN; + case MLX5_PORT_CHANGE_SUBTYPE_ACTIVE: + return MLX5_DEV_EVENT_PORT_UP; + case MLX5_PORT_CHANGE_SUBTYPE_INITIALIZED: + return MLX5_DEV_EVENT_PORT_INITIALIZED; + case MLX5_PORT_CHANGE_SUBTYPE_LID: + return MLX5_DEV_EVENT_LID_CHANGE; + case MLX5_PORT_CHANGE_SUBTYPE_PKEY: + return MLX5_DEV_EVENT_PKEY_CHANGE; + case MLX5_PORT_CHANGE_SUBTYPE_GUID: + return MLX5_DEV_EVENT_GUID_CHANGE; + case MLX5_PORT_CHANGE_SUBTYPE_CLIENT_REREG: + return MLX5_DEV_EVENT_CLIENT_REREG; + } + return -1; +} + +static void eq_update_ci(struct mlx5_eq *eq, int arm) +{ + __be32 __iomem *addr = eq->doorbell + (arm ? 0 : 2); + u32 val = (eq->cons_index & 0xffffff) | (eq->eqn << 24); + __raw_writel((__force u32) cpu_to_be32(val), addr); + /* We still want ordering, just not swabbing, so add a barrier */ + mb(); +} + +static int mlx5_eq_int(struct mlx5_core_dev *dev, struct mlx5_eq *eq) +{ + struct mlx5_eqe *eqe; + int eqes_found = 0; + int set_ci = 0; + u32 cqn; + u32 srqn; + u8 port; + + while ((eqe = next_eqe_sw(eq))) { + /* + * Make sure we read EQ entry contents after we've + * checked the ownership bit. + */ + rmb(); + + mlx5_core_dbg(eq->dev, "eqn %d, eqe type %s\n", eq->eqn, eqe_type_str(eqe->type)); + switch (eqe->type) { + case MLX5_EVENT_TYPE_COMP: + cqn = be32_to_cpu(eqe->data.comp.cqn) & 0xffffff; + mlx5_cq_completion(dev, cqn); + break; + + case MLX5_EVENT_TYPE_PATH_MIG: + case MLX5_EVENT_TYPE_COMM_EST: + case MLX5_EVENT_TYPE_SQ_DRAINED: + case MLX5_EVENT_TYPE_SRQ_LAST_WQE: + case MLX5_EVENT_TYPE_WQ_CATAS_ERROR: + case MLX5_EVENT_TYPE_PATH_MIG_FAILED: + case MLX5_EVENT_TYPE_WQ_INVAL_REQ_ERROR: + case MLX5_EVENT_TYPE_WQ_ACCESS_ERROR: + mlx5_core_dbg(dev, "event %s(%d) arrived\n", + eqe_type_str(eqe->type), eqe->type); + mlx5_qp_event(dev, be32_to_cpu(eqe->data.qp_srq.qp_srq_n) & 0xffffff, + eqe->type); + break; + + case MLX5_EVENT_TYPE_SRQ_RQ_LIMIT: + case MLX5_EVENT_TYPE_SRQ_CATAS_ERROR: + srqn = be32_to_cpu(eqe->data.qp_srq.qp_srq_n) & 0xffffff; + mlx5_core_dbg(dev, "SRQ event %s(%d): srqn 0x%x\n", + eqe_type_str(eqe->type), eqe->type, srqn); + mlx5_srq_event(dev, srqn, eqe->type); + break; + + case MLX5_EVENT_TYPE_CMD: + mlx5_cmd_comp_handler(dev, be32_to_cpu(eqe->data.cmd.vector)); + break; + + case MLX5_EVENT_TYPE_PORT_CHANGE: + port = (eqe->data.port.port >> 4) & 0xf; + switch (eqe->sub_type) { + case MLX5_PORT_CHANGE_SUBTYPE_DOWN: + case MLX5_PORT_CHANGE_SUBTYPE_ACTIVE: + case MLX5_PORT_CHANGE_SUBTYPE_LID: + case MLX5_PORT_CHANGE_SUBTYPE_PKEY: + case MLX5_PORT_CHANGE_SUBTYPE_GUID: + case MLX5_PORT_CHANGE_SUBTYPE_CLIENT_REREG: + case MLX5_PORT_CHANGE_SUBTYPE_INITIALIZED: + dev->event(dev, port_subtype_event(eqe->sub_type), &port); + break; + default: + mlx5_core_warn(dev, "Port event with unrecognized subtype: port %d, sub_type %d\n", + port, eqe->sub_type); + } + break; + case MLX5_EVENT_TYPE_CQ_ERROR: + cqn = be32_to_cpu(eqe->data.cq_err.cqn) & 0xffffff; + mlx5_core_warn(dev, "CQ error on CQN 0x%x, syndrom 0x%x\n", + cqn, eqe->data.cq_err.syndrome); + mlx5_cq_event(dev, cqn, eqe->type); + break; + + case MLX5_EVENT_TYPE_PAGE_REQUEST: + { + u16 func_id = be16_to_cpu(eqe->data.req_pages.func_id); + s16 npages = be16_to_cpu(eqe->data.req_pages.num_pages); + + mlx5_core_dbg(dev, "page request for func 0x%x, napges %d\n", func_id, npages); + mlx5_core_req_pages_handler(dev, func_id, npages); + } + break; + + + default: + mlx5_core_warn(dev, "Unhandled event 0x%x on EQ 0x%x\n", eqe->type, eq->eqn); + break; + } + + ++eq->cons_index; + eqes_found = 1; + ++set_ci; + + /* The HCA will think the queue has overflowed if we + * don't tell it we've been processing events. We + * create our EQs with MLX5_NUM_SPARE_EQE extra + * entries, so we must update our consumer index at + * least that often. + */ + if (unlikely(set_ci >= MLX5_NUM_SPARE_EQE)) { + eq_update_ci(eq, 0); + set_ci = 0; + } + } + + eq_update_ci(eq, 1); + + return eqes_found; +} + +static irqreturn_t mlx5_msix_handler(int irq, void *eq_ptr) +{ + struct mlx5_eq *eq = eq_ptr; + struct mlx5_core_dev *dev = eq->dev; + + mlx5_eq_int(dev, eq); + + /* MSI-X vectors always belong to us */ + return IRQ_HANDLED; +} + +static void init_eq_buf(struct mlx5_eq *eq) +{ + struct mlx5_eqe *eqe; + int i; + + for (i = 0; i < eq->nent; i++) { + eqe = get_eqe(eq, i); + eqe->owner = MLX5_EQE_OWNER_INIT_VAL; + } +} + +int mlx5_create_map_eq(struct mlx5_core_dev *dev, struct mlx5_eq *eq, u8 vecidx, + int nent, u64 mask, const char *name, struct mlx5_uar *uar) +{ + struct mlx5_eq_table *table = &dev->priv.eq_table; + struct mlx5_create_eq_mbox_in *in; + struct mlx5_create_eq_mbox_out out; + int err; + int inlen; + + eq->nent = roundup_pow_of_two(nent + MLX5_NUM_SPARE_EQE); + err = mlx5_buf_alloc(dev, eq->nent * MLX5_EQE_SIZE, 2 * PAGE_SIZE, + &eq->buf); + if (err) + return err; + + init_eq_buf(eq); + + inlen = sizeof(*in) + sizeof(in->pas[0]) * eq->buf.npages; + in = mlx5_vzalloc(inlen); + if (!in) { + err = -ENOMEM; + goto err_buf; + } + memset(&out, 0, sizeof(out)); + + mlx5_fill_page_array(&eq->buf, in->pas); + + in->hdr.opcode = cpu_to_be16(MLX5_CMD_OP_CREATE_EQ); + in->ctx.log_sz_usr_page = cpu_to_be32(ilog2(eq->nent) << 24 | uar->index); + in->ctx.intr = vecidx; + in->ctx.log_page_size = PAGE_SHIFT - 12; + in->events_mask = cpu_to_be64(mask); + + err = mlx5_cmd_exec(dev, in, inlen, &out, sizeof(out)); + if (err) + goto err_in; + + if (out.hdr.status) { + err = mlx5_cmd_status_to_err(&out.hdr); + goto err_in; + } + + eq->eqn = out.eq_number; + err = request_irq(table->msix_arr[vecidx].vector, mlx5_msix_handler, 0, + name, eq); + if (err) + goto err_eq; + + eq->irqn = vecidx; + eq->dev = dev; + eq->doorbell = uar->map + MLX5_EQ_DOORBEL_OFFSET; + + err = mlx5_debug_eq_add(dev, eq); + if (err) + goto err_irq; + + /* EQs are created in ARMED state + */ + eq_update_ci(eq, 1); + + mlx5_vfree(in); + return 0; + +err_irq: + free_irq(table->msix_arr[vecidx].vector, eq); + +err_eq: + mlx5_cmd_destroy_eq(dev, eq->eqn); + +err_in: + mlx5_vfree(in); + +err_buf: + mlx5_buf_free(dev, &eq->buf); + return err; +} +EXPORT_SYMBOL_GPL(mlx5_create_map_eq); + +int mlx5_destroy_unmap_eq(struct mlx5_core_dev *dev, struct mlx5_eq *eq) +{ + struct mlx5_eq_table *table = &dev->priv.eq_table; + int err; + + mlx5_debug_eq_remove(dev, eq); + free_irq(table->msix_arr[eq->irqn].vector, eq); + err = mlx5_cmd_destroy_eq(dev, eq->eqn); + if (err) + mlx5_core_warn(dev, "failed to destroy a previously created eq: eqn %d\n", + eq->eqn); + mlx5_buf_free(dev, &eq->buf); + + return err; +} +EXPORT_SYMBOL_GPL(mlx5_destroy_unmap_eq); + +int mlx5_eq_init(struct mlx5_core_dev *dev) +{ + int err; + + spin_lock_init(&dev->priv.eq_table.lock); + + err = mlx5_eq_debugfs_init(dev); + + return err; +} + + +void mlx5_eq_cleanup(struct mlx5_core_dev *dev) +{ + mlx5_eq_debugfs_cleanup(dev); +} + +int mlx5_start_eqs(struct mlx5_core_dev *dev) +{ + struct mlx5_eq_table *table = &dev->priv.eq_table; + int err; + + err = mlx5_create_map_eq(dev, &table->cmd_eq, MLX5_EQ_VEC_CMD, + MLX5_NUM_CMD_EQE, 1ull << MLX5_EVENT_TYPE_CMD, + "mlx5_cmd_eq", &dev->priv.uuari.uars[0]); + if (err) { + mlx5_core_warn(dev, "failed to create cmd EQ %d\n", err); + return err; + } + + mlx5_cmd_use_events(dev); + + err = mlx5_create_map_eq(dev, &table->async_eq, MLX5_EQ_VEC_ASYNC, + MLX5_NUM_ASYNC_EQE, MLX5_ASYNC_EVENT_MASK, + "mlx5_async_eq", &dev->priv.uuari.uars[0]); + if (err) { + mlx5_core_warn(dev, "failed to create async EQ %d\n", err); + goto err1; + } + + err = mlx5_create_map_eq(dev, &table->pages_eq, + MLX5_EQ_VEC_PAGES, + dev->caps.max_vf + 1, + 1 << MLX5_EVENT_TYPE_PAGE_REQUEST, "mlx5_pages_eq", + &dev->priv.uuari.uars[0]); + if (err) { + mlx5_core_warn(dev, "failed to create pages EQ %d\n", err); + goto err2; + } + + return err; + +err2: + mlx5_destroy_unmap_eq(dev, &table->async_eq); + +err1: + mlx5_cmd_use_polling(dev); + mlx5_destroy_unmap_eq(dev, &table->cmd_eq); + return err; +} + +int mlx5_stop_eqs(struct mlx5_core_dev *dev) +{ + struct mlx5_eq_table *table = &dev->priv.eq_table; + int err; + + err = mlx5_destroy_unmap_eq(dev, &table->pages_eq); + if (err) + return err; + + mlx5_destroy_unmap_eq(dev, &table->async_eq); + mlx5_cmd_use_polling(dev); + + err = mlx5_destroy_unmap_eq(dev, &table->cmd_eq); + if (err) + mlx5_cmd_use_events(dev); + + return err; +} + +int mlx5_core_eq_query(struct mlx5_core_dev *dev, struct mlx5_eq *eq, + struct mlx5_query_eq_mbox_out *out, int outlen) +{ + struct mlx5_query_eq_mbox_in in; + int err; + + memset(&in, 0, sizeof(in)); + memset(out, 0, outlen); + in.hdr.opcode = cpu_to_be16(MLX5_CMD_OP_QUERY_EQ); + in.eqn = eq->eqn; + err = mlx5_cmd_exec(dev, &in, sizeof(in), out, outlen); + if (err) + return err; + + if (out->hdr.status) + err = mlx5_cmd_status_to_err(&out->hdr); + + return err; +} +EXPORT_SYMBOL_GPL(mlx5_core_eq_query); diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fw.c b/drivers/net/ethernet/mellanox/mlx5/core/fw.c new file mode 100644 index 000000000000..72a5222447f5 --- /dev/null +++ b/drivers/net/ethernet/mellanox/mlx5/core/fw.c @@ -0,0 +1,185 @@ +/* + * Copyright (c) 2013, Mellanox Technologies inc. All rights reserved. + * + * This software is available to you under a choice of one of two + * licenses. You may choose to be licensed under the terms of the GNU + * General Public License (GPL) Version 2, available from the file + * COPYING in the main directory of this source tree, or the + * OpenIB.org BSD license below: + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include +#include +#include +#include "mlx5_core.h" + +int mlx5_cmd_query_adapter(struct mlx5_core_dev *dev) +{ + struct mlx5_cmd_query_adapter_mbox_out *out; + struct mlx5_cmd_query_adapter_mbox_in in; + int err; + + out = kzalloc(sizeof(*out), GFP_KERNEL); + if (!out) + return -ENOMEM; + + memset(&in, 0, sizeof(in)); + in.hdr.opcode = cpu_to_be16(MLX5_CMD_OP_QUERY_ADAPTER); + err = mlx5_cmd_exec(dev, &in, sizeof(in), out, sizeof(*out)); + if (err) + goto out_out; + + if (out->hdr.status) { + err = mlx5_cmd_status_to_err(&out->hdr); + goto out_out; + } + + memcpy(dev->board_id, out->vsd_psid, sizeof(out->vsd_psid)); + +out_out: + kfree(out); + + return err; +} + +int mlx5_cmd_query_hca_cap(struct mlx5_core_dev *dev, + struct mlx5_caps *caps) +{ + struct mlx5_cmd_query_hca_cap_mbox_out *out; + struct mlx5_cmd_query_hca_cap_mbox_in in; + struct mlx5_query_special_ctxs_mbox_out ctx_out; + struct mlx5_query_special_ctxs_mbox_in ctx_in; + int err; + u16 t16; + + out = kzalloc(sizeof(*out), GFP_KERNEL); + if (!out) + return -ENOMEM; + + memset(&in, 0, sizeof(in)); + in.hdr.opcode = cpu_to_be16(MLX5_CMD_OP_QUERY_HCA_CAP); + in.hdr.opmod = cpu_to_be16(0x1); + err = mlx5_cmd_exec(dev, &in, sizeof(in), out, sizeof(*out)); + if (err) + goto out_out; + + if (out->hdr.status) { + err = mlx5_cmd_status_to_err(&out->hdr); + goto out_out; + } + + + caps->log_max_eq = out->hca_cap.log_max_eq & 0xf; + caps->max_cqes = 1 << out->hca_cap.log_max_cq_sz; + caps->max_wqes = 1 << out->hca_cap.log_max_qp_sz; + caps->max_sq_desc_sz = be16_to_cpu(out->hca_cap.max_desc_sz_sq); + caps->max_rq_desc_sz = be16_to_cpu(out->hca_cap.max_desc_sz_rq); + caps->flags = be64_to_cpu(out->hca_cap.flags); + caps->stat_rate_support = be16_to_cpu(out->hca_cap.stat_rate_support); + caps->log_max_msg = out->hca_cap.log_max_msg & 0x1f; + caps->num_ports = out->hca_cap.num_ports & 0xf; + caps->log_max_cq = out->hca_cap.log_max_cq & 0x1f; + if (caps->num_ports > MLX5_MAX_PORTS) { + mlx5_core_err(dev, "device has %d ports while the driver supports max %d ports\n", + caps->num_ports, MLX5_MAX_PORTS); + err = -EINVAL; + goto out_out; + } + caps->log_max_qp = out->hca_cap.log_max_qp & 0x1f; + caps->log_max_mkey = out->hca_cap.log_max_mkey & 0x3f; + caps->log_max_pd = out->hca_cap.log_max_pd & 0x1f; + caps->log_max_srq = out->hca_cap.log_max_srqs & 0x1f; + caps->local_ca_ack_delay = out->hca_cap.local_ca_ack_delay & 0x1f; + caps->log_max_mcg = out->hca_cap.log_max_mcg; + caps->max_qp_mcg = be16_to_cpu(out->hca_cap.max_qp_mcg); + caps->max_ra_res_qp = 1 << (out->hca_cap.log_max_ra_res_qp & 0x3f); + caps->max_ra_req_qp = 1 << (out->hca_cap.log_max_ra_req_qp & 0x3f); + caps->max_srq_wqes = 1 << out->hca_cap.log_max_srq_sz; + t16 = be16_to_cpu(out->hca_cap.bf_log_bf_reg_size); + if (t16 & 0x8000) { + caps->bf_reg_size = 1 << (t16 & 0x1f); + caps->bf_regs_per_page = MLX5_BF_REGS_PER_PAGE; + } else { + caps->bf_reg_size = 0; + caps->bf_regs_per_page = 0; + } + caps->min_page_sz = ~(u32)((1 << out->hca_cap.log_pg_sz) - 1); + + memset(&ctx_in, 0, sizeof(ctx_in)); + memset(&ctx_out, 0, sizeof(ctx_out)); + ctx_in.hdr.opcode = cpu_to_be16(MLX5_CMD_OP_QUERY_SPECIAL_CONTEXTS); + err = mlx5_cmd_exec(dev, &ctx_in, sizeof(ctx_in), + &ctx_out, sizeof(ctx_out)); + if (err) + goto out_out; + + if (ctx_out.hdr.status) + err = mlx5_cmd_status_to_err(&ctx_out.hdr); + + caps->reserved_lkey = be32_to_cpu(ctx_out.reserved_lkey); + +out_out: + kfree(out); + + return err; +} + +int mlx5_cmd_init_hca(struct mlx5_core_dev *dev) +{ + struct mlx5_cmd_init_hca_mbox_in in; + struct mlx5_cmd_init_hca_mbox_out out; + int err; + + memset(&in, 0, sizeof(in)); + memset(&out, 0, sizeof(out)); + in.hdr.opcode = cpu_to_be16(MLX5_CMD_OP_INIT_HCA); + err = mlx5_cmd_exec(dev, &in, sizeof(in), &out, sizeof(out)); + if (err) + return err; + + if (out.hdr.status) + err = mlx5_cmd_status_to_err(&out.hdr); + + return err; +} + +int mlx5_cmd_teardown_hca(struct mlx5_core_dev *dev) +{ + struct mlx5_cmd_teardown_hca_mbox_in in; + struct mlx5_cmd_teardown_hca_mbox_out out; + int err; + + memset(&in, 0, sizeof(in)); + memset(&out, 0, sizeof(out)); + in.hdr.opcode = cpu_to_be16(MLX5_CMD_OP_TEARDOWN_HCA); + err = mlx5_cmd_exec(dev, &in, sizeof(in), &out, sizeof(out)); + if (err) + return err; + + if (out.hdr.status) + err = mlx5_cmd_status_to_err(&out.hdr); + + return err; +} diff --git a/drivers/net/ethernet/mellanox/mlx5/core/health.c b/drivers/net/ethernet/mellanox/mlx5/core/health.c new file mode 100644 index 000000000000..ea4b9bca6d4a --- /dev/null +++ b/drivers/net/ethernet/mellanox/mlx5/core/health.c @@ -0,0 +1,217 @@ +/* + * Copyright (c) 2013, Mellanox Technologies inc. All rights reserved. + * + * This software is available to you under a choice of one of two + * licenses. You may choose to be licensed under the terms of the GNU + * General Public License (GPL) Version 2, available from the file + * COPYING in the main directory of this source tree, or the + * OpenIB.org BSD license below: + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include +#include +#include +#include +#include +#include +#include "mlx5_core.h" + +enum { + MLX5_HEALTH_POLL_INTERVAL = 2 * HZ, + MAX_MISSES = 3, +}; + +enum { + MLX5_HEALTH_SYNDR_FW_ERR = 0x1, + MLX5_HEALTH_SYNDR_IRISC_ERR = 0x7, + MLX5_HEALTH_SYNDR_CRC_ERR = 0x9, + MLX5_HEALTH_SYNDR_FETCH_PCI_ERR = 0xa, + MLX5_HEALTH_SYNDR_HW_FTL_ERR = 0xb, + MLX5_HEALTH_SYNDR_ASYNC_EQ_OVERRUN_ERR = 0xc, + MLX5_HEALTH_SYNDR_EQ_ERR = 0xd, + MLX5_HEALTH_SYNDR_FFSER_ERR = 0xf, +}; + +static DEFINE_SPINLOCK(health_lock); + +static LIST_HEAD(health_list); +static struct work_struct health_work; + +static health_handler_t reg_handler; +int mlx5_register_health_report_handler(health_handler_t handler) +{ + spin_lock_irq(&health_lock); + if (reg_handler) { + spin_unlock_irq(&health_lock); + return -EEXIST; + } + reg_handler = handler; + spin_unlock_irq(&health_lock); + + return 0; +} +EXPORT_SYMBOL(mlx5_register_health_report_handler); + +void mlx5_unregister_health_report_handler(void) +{ + spin_lock_irq(&health_lock); + reg_handler = NULL; + spin_unlock_irq(&health_lock); +} +EXPORT_SYMBOL(mlx5_unregister_health_report_handler); + +static void health_care(struct work_struct *work) +{ + struct mlx5_core_health *health, *n; + struct mlx5_core_dev *dev; + struct mlx5_priv *priv; + LIST_HEAD(tlist); + + spin_lock_irq(&health_lock); + list_splice_init(&health_list, &tlist); + + spin_unlock_irq(&health_lock); + + list_for_each_entry_safe(health, n, &tlist, list) { + priv = container_of(health, struct mlx5_priv, health); + dev = container_of(priv, struct mlx5_core_dev, priv); + mlx5_core_warn(dev, "handling bad device here\n"); + spin_lock_irq(&health_lock); + if (reg_handler) + reg_handler(dev->pdev, health->health, + sizeof(health->health)); + + list_del_init(&health->list); + spin_unlock_irq(&health_lock); + } +} + +static const char *hsynd_str(u8 synd) +{ + switch (synd) { + case MLX5_HEALTH_SYNDR_FW_ERR: + return "firmware internal error"; + case MLX5_HEALTH_SYNDR_IRISC_ERR: + return "irisc not responding"; + case MLX5_HEALTH_SYNDR_CRC_ERR: + return "firmware CRC error"; + case MLX5_HEALTH_SYNDR_FETCH_PCI_ERR: + return "ICM fetch PCI error"; + case MLX5_HEALTH_SYNDR_HW_FTL_ERR: + return "HW fatal error\n"; + case MLX5_HEALTH_SYNDR_ASYNC_EQ_OVERRUN_ERR: + return "async EQ buffer overrun"; + case MLX5_HEALTH_SYNDR_EQ_ERR: + return "EQ error"; + case MLX5_HEALTH_SYNDR_FFSER_ERR: + return "FFSER error"; + default: + return "unrecognized error"; + } +} + +static void print_health_info(struct mlx5_core_dev *dev) +{ + struct mlx5_core_health *health = &dev->priv.health; + struct health_buffer __iomem *h = health->health; + int i; + + for (i = 0; i < ARRAY_SIZE(h->assert_var); i++) + pr_info("assert_var[%d] 0x%08x\n", i, be32_to_cpu(h->assert_var[i])); + + pr_info("assert_exit_ptr 0x%08x\n", be32_to_cpu(h->assert_exit_ptr)); + pr_info("assert_callra 0x%08x\n", be32_to_cpu(h->assert_callra)); + pr_info("fw_ver 0x%08x\n", be32_to_cpu(h->fw_ver)); + pr_info("hw_id 0x%08x\n", be32_to_cpu(h->hw_id)); + pr_info("irisc_index %d\n", h->irisc_index); + pr_info("synd 0x%x: %s\n", h->synd, hsynd_str(h->synd)); + pr_info("ext_sync 0x%04x\n", be16_to_cpu(h->ext_sync)); +} + +static void poll_health(unsigned long data) +{ + struct mlx5_core_dev *dev = (struct mlx5_core_dev *)data; + struct mlx5_core_health *health = &dev->priv.health; + unsigned long next; + u32 count; + + count = ioread32be(health->health_counter); + if (count == health->prev) + ++health->miss_counter; + else + health->miss_counter = 0; + + health->prev = count; + if (health->miss_counter == MAX_MISSES) { + mlx5_core_err(dev, "device's health compromised\n"); + print_health_info(dev); + spin_lock_irq(&health_lock); + list_add_tail(&health->list, &health_list); + spin_unlock_irq(&health_lock); + + queue_work(mlx5_core_wq, &health_work); + } else { + get_random_bytes(&next, sizeof(next)); + next %= HZ; + next += jiffies + MLX5_HEALTH_POLL_INTERVAL; + mod_timer(&health->timer, next); + } +} + +void mlx5_start_health_poll(struct mlx5_core_dev *dev) +{ + struct mlx5_core_health *health = &dev->priv.health; + + INIT_LIST_HEAD(&health->list); + init_timer(&health->timer); + health->health = &dev->iseg->health; + health->health_counter = &dev->iseg->health_counter; + + health->timer.data = (unsigned long)dev; + health->timer.function = poll_health; + health->timer.expires = round_jiffies(jiffies + MLX5_HEALTH_POLL_INTERVAL); + add_timer(&health->timer); +} + +void mlx5_stop_health_poll(struct mlx5_core_dev *dev) +{ + struct mlx5_core_health *health = &dev->priv.health; + + del_timer_sync(&health->timer); + + spin_lock_irq(&health_lock); + if (!list_empty(&health->list)) + list_del_init(&health->list); + spin_unlock_irq(&health_lock); +} + +void mlx5_health_cleanup(void) +{ +} + +void __init mlx5_health_init(void) +{ + INIT_WORK(&health_work, health_care); +} diff --git a/drivers/net/ethernet/mellanox/mlx5/core/mad.c b/drivers/net/ethernet/mellanox/mlx5/core/mad.c new file mode 100644 index 000000000000..18d6fd5dd90b --- /dev/null +++ b/drivers/net/ethernet/mellanox/mlx5/core/mad.c @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2013, Mellanox Technologies inc. All rights reserved. + * + * This software is available to you under a choice of one of two + * licenses. You may choose to be licensed under the terms of the GNU + * General Public License (GPL) Version 2, available from the file + * COPYING in the main directory of this source tree, or the + * OpenIB.org BSD license below: + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include +#include +#include +#include +#include "mlx5_core.h" + +int mlx5_core_mad_ifc(struct mlx5_core_dev *dev, void *inb, void *outb, + u16 opmod, int port) +{ + struct mlx5_mad_ifc_mbox_in *in = NULL; + struct mlx5_mad_ifc_mbox_out *out = NULL; + int err; + + in = kzalloc(sizeof(*in), GFP_KERNEL); + if (!in) + return -ENOMEM; + + out = kzalloc(sizeof(*out), GFP_KERNEL); + if (!out) { + err = -ENOMEM; + goto out; + } + + in->hdr.opcode = cpu_to_be16(MLX5_CMD_OP_MAD_IFC); + in->hdr.opmod = cpu_to_be16(opmod); + in->port = port; + + memcpy(in->data, inb, sizeof(in->data)); + + err = mlx5_cmd_exec(dev, in, sizeof(*in), out, sizeof(*out)); + if (err) + goto out; + + if (out->hdr.status) { + err = mlx5_cmd_status_to_err(&out->hdr); + goto out; + } + + memcpy(outb, out->data, sizeof(out->data)); + +out: + kfree(out); + kfree(in); + return err; +} +EXPORT_SYMBOL_GPL(mlx5_core_mad_ifc); diff --git a/drivers/net/ethernet/mellanox/mlx5/core/main.c b/drivers/net/ethernet/mellanox/mlx5/core/main.c new file mode 100644 index 000000000000..f21cc397d1bc --- /dev/null +++ b/drivers/net/ethernet/mellanox/mlx5/core/main.c @@ -0,0 +1,475 @@ +/* + * Copyright (c) 2013, Mellanox Technologies inc. All rights reserved. + * + * This software is available to you under a choice of one of two + * licenses. You may choose to be licensed under the terms of the GNU + * General Public License (GPL) Version 2, available from the file + * COPYING in the main directory of this source tree, or the + * OpenIB.org BSD license below: + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "mlx5_core.h" + +#define DRIVER_NAME "mlx5_core" +#define DRIVER_VERSION "1.0" +#define DRIVER_RELDATE "June 2013" + +MODULE_AUTHOR("Eli Cohen "); +MODULE_DESCRIPTION("Mellanox ConnectX-IB HCA core library"); +MODULE_LICENSE("Dual BSD/GPL"); +MODULE_VERSION(DRIVER_VERSION); + +int mlx5_core_debug_mask; +module_param_named(debug_mask, mlx5_core_debug_mask, int, 0644); +MODULE_PARM_DESC(debug_mask, "debug mask: 1 = dump cmd data, 2 = dump cmd exec time, 3 = both. Default=0"); + +struct workqueue_struct *mlx5_core_wq; + +static int set_dma_caps(struct pci_dev *pdev) +{ + int err; + + err = pci_set_dma_mask(pdev, DMA_BIT_MASK(64)); + if (err) { + dev_warn(&pdev->dev, "Warning: couldn't set 64-bit PCI DMA mask.\n"); + err = pci_set_dma_mask(pdev, DMA_BIT_MASK(32)); + if (err) { + dev_err(&pdev->dev, "Can't set PCI DMA mask, aborting.\n"); + return err; + } + } + + err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64)); + if (err) { + dev_warn(&pdev->dev, + "Warning: couldn't set 64-bit consistent PCI DMA mask.\n"); + err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32)); + if (err) { + dev_err(&pdev->dev, + "Can't set consistent PCI DMA mask, aborting.\n"); + return err; + } + } + + dma_set_max_seg_size(&pdev->dev, 2u * 1024 * 1024 * 1024); + return err; +} + +static int request_bar(struct pci_dev *pdev) +{ + int err = 0; + + if (!(pci_resource_flags(pdev, 0) & IORESOURCE_MEM)) { + dev_err(&pdev->dev, "Missing registers BAR, aborting.\n"); + return -ENODEV; + } + + err = pci_request_regions(pdev, DRIVER_NAME); + if (err) + dev_err(&pdev->dev, "Couldn't get PCI resources, aborting\n"); + + return err; +} + +static void release_bar(struct pci_dev *pdev) +{ + pci_release_regions(pdev); +} + +static int mlx5_enable_msix(struct mlx5_core_dev *dev) +{ + struct mlx5_eq_table *table = &dev->priv.eq_table; + int num_eqs = 1 << dev->caps.log_max_eq; + int nvec; + int err; + int i; + + nvec = dev->caps.num_ports * num_online_cpus() + MLX5_EQ_VEC_COMP_BASE; + nvec = min_t(int, nvec, num_eqs); + if (nvec <= MLX5_EQ_VEC_COMP_BASE) + return -ENOMEM; + + table->msix_arr = kzalloc(nvec * sizeof(*table->msix_arr), GFP_KERNEL); + if (!table->msix_arr) + return -ENOMEM; + + for (i = 0; i < nvec; i++) + table->msix_arr[i].entry = i; + +retry: + table->num_comp_vectors = nvec - MLX5_EQ_VEC_COMP_BASE; + err = pci_enable_msix(dev->pdev, table->msix_arr, nvec); + if (err <= 0) { + return err; + } else if (err > 2) { + nvec = err; + goto retry; + } + + mlx5_core_dbg(dev, "received %d MSI vectors out of %d requested\n", err, nvec); + + return 0; +} + +static void mlx5_disable_msix(struct mlx5_core_dev *dev) +{ + struct mlx5_eq_table *table = &dev->priv.eq_table; + + pci_disable_msix(dev->pdev); + kfree(table->msix_arr); +} + +struct mlx5_reg_host_endianess { + u8 he; + u8 rsvd[15]; +}; + +static int handle_hca_cap(struct mlx5_core_dev *dev) +{ + struct mlx5_cmd_query_hca_cap_mbox_out *query_out = NULL; + struct mlx5_cmd_set_hca_cap_mbox_in *set_ctx = NULL; + struct mlx5_cmd_query_hca_cap_mbox_in query_ctx; + struct mlx5_cmd_set_hca_cap_mbox_out set_out; + struct mlx5_profile *prof = dev->profile; + u64 flags; + int csum = 1; + int err; + + memset(&query_ctx, 0, sizeof(query_ctx)); + query_out = kzalloc(sizeof(*query_out), GFP_KERNEL); + if (!query_out) + return -ENOMEM; + + set_ctx = kzalloc(sizeof(*set_ctx), GFP_KERNEL); + if (!set_ctx) { + err = -ENOMEM; + goto query_ex; + } + + query_ctx.hdr.opcode = cpu_to_be16(MLX5_CMD_OP_QUERY_HCA_CAP); + query_ctx.hdr.opmod = cpu_to_be16(0x1); + err = mlx5_cmd_exec(dev, &query_ctx, sizeof(query_ctx), + query_out, sizeof(*query_out)); + if (err) + goto query_ex; + + err = mlx5_cmd_status_to_err(&query_out->hdr); + if (err) { + mlx5_core_warn(dev, "query hca cap failed, %d\n", err); + goto query_ex; + } + + memcpy(&set_ctx->hca_cap, &query_out->hca_cap, + sizeof(set_ctx->hca_cap)); + + if (prof->mask & MLX5_PROF_MASK_CMDIF_CSUM) { + csum = !!prof->cmdif_csum; + flags = be64_to_cpu(set_ctx->hca_cap.flags); + if (csum) + flags |= MLX5_DEV_CAP_FLAG_CMDIF_CSUM; + else + flags &= ~MLX5_DEV_CAP_FLAG_CMDIF_CSUM; + + set_ctx->hca_cap.flags = cpu_to_be64(flags); + } + + if (dev->profile->mask & MLX5_PROF_MASK_QP_SIZE) + set_ctx->hca_cap.log_max_qp = dev->profile->log_max_qp; + + memset(&set_out, 0, sizeof(set_out)); + set_ctx->hca_cap.uar_page_sz = cpu_to_be16(PAGE_SHIFT - 12); + set_ctx->hdr.opcode = cpu_to_be16(MLX5_CMD_OP_SET_HCA_CAP); + err = mlx5_cmd_exec(dev, set_ctx, sizeof(*set_ctx), + &set_out, sizeof(set_out)); + if (err) { + mlx5_core_warn(dev, "set hca cap failed, %d\n", err); + goto query_ex; + } + + err = mlx5_cmd_status_to_err(&set_out.hdr); + if (err) + goto query_ex; + + if (!csum) + dev->cmd.checksum_disabled = 1; + +query_ex: + kfree(query_out); + kfree(set_ctx); + + return err; +} + +static int set_hca_ctrl(struct mlx5_core_dev *dev) +{ + struct mlx5_reg_host_endianess he_in; + struct mlx5_reg_host_endianess he_out; + int err; + + memset(&he_in, 0, sizeof(he_in)); + he_in.he = MLX5_SET_HOST_ENDIANNESS; + err = mlx5_core_access_reg(dev, &he_in, sizeof(he_in), + &he_out, sizeof(he_out), + MLX5_REG_HOST_ENDIANNESS, 0, 1); + return err; +} + +int mlx5_dev_init(struct mlx5_core_dev *dev, struct pci_dev *pdev) +{ + struct mlx5_priv *priv = &dev->priv; + int err; + + dev->pdev = pdev; + pci_set_drvdata(dev->pdev, dev); + strncpy(priv->name, dev_name(&pdev->dev), MLX5_MAX_NAME_LEN); + priv->name[MLX5_MAX_NAME_LEN - 1] = 0; + + mutex_init(&priv->pgdir_mutex); + INIT_LIST_HEAD(&priv->pgdir_list); + spin_lock_init(&priv->mkey_lock); + + priv->dbg_root = debugfs_create_dir(dev_name(&pdev->dev), mlx5_debugfs_root); + if (!priv->dbg_root) + return -ENOMEM; + + err = pci_enable_device(pdev); + if (err) { + dev_err(&pdev->dev, "Cannot enable PCI device, aborting.\n"); + goto err_dbg; + } + + err = request_bar(pdev); + if (err) { + dev_err(&pdev->dev, "error requesting BARs, aborting.\n"); + goto err_disable; + } + + pci_set_master(pdev); + + err = set_dma_caps(pdev); + if (err) { + dev_err(&pdev->dev, "Failed setting DMA capabilities mask, aborting\n"); + goto err_clr_master; + } + + dev->iseg_base = pci_resource_start(dev->pdev, 0); + dev->iseg = ioremap(dev->iseg_base, sizeof(*dev->iseg)); + if (!dev->iseg) { + err = -ENOMEM; + dev_err(&pdev->dev, "Failed mapping initialization segment, aborting\n"); + goto err_clr_master; + } + dev_info(&pdev->dev, "firmware version: %d.%d.%d\n", fw_rev_maj(dev), + fw_rev_min(dev), fw_rev_sub(dev)); + + err = mlx5_cmd_init(dev); + if (err) { + dev_err(&pdev->dev, "Failed initializing command interface, aborting\n"); + goto err_unmap; + } + + mlx5_pagealloc_init(dev); + err = set_hca_ctrl(dev); + if (err) { + dev_err(&pdev->dev, "set_hca_ctrl failed\n"); + goto err_pagealloc_cleanup; + } + + err = handle_hca_cap(dev); + if (err) { + dev_err(&pdev->dev, "handle_hca_cap failed\n"); + goto err_pagealloc_cleanup; + } + + err = mlx5_satisfy_startup_pages(dev); + if (err) { + dev_err(&pdev->dev, "failed to allocate startup pages\n"); + goto err_pagealloc_cleanup; + } + + err = mlx5_pagealloc_start(dev); + if (err) { + dev_err(&pdev->dev, "mlx5_pagealloc_start failed\n"); + goto err_reclaim_pages; + } + + err = mlx5_cmd_init_hca(dev); + if (err) { + dev_err(&pdev->dev, "init hca failed\n"); + goto err_pagealloc_stop; + } + + mlx5_start_health_poll(dev); + + err = mlx5_cmd_query_hca_cap(dev, &dev->caps); + if (err) { + dev_err(&pdev->dev, "query hca failed\n"); + goto err_stop_poll; + } + + err = mlx5_cmd_query_adapter(dev); + if (err) { + dev_err(&pdev->dev, "query adapter failed\n"); + goto err_stop_poll; + } + + err = mlx5_enable_msix(dev); + if (err) { + dev_err(&pdev->dev, "enable msix failed\n"); + goto err_stop_poll; + } + + err = mlx5_eq_init(dev); + if (err) { + dev_err(&pdev->dev, "failed to initialize eq\n"); + goto disable_msix; + } + + err = mlx5_alloc_uuars(dev, &priv->uuari); + if (err) { + dev_err(&pdev->dev, "Failed allocating uar, aborting\n"); + goto err_eq_cleanup; + } + + err = mlx5_start_eqs(dev); + if (err) { + dev_err(&pdev->dev, "Failed to start pages and async EQs\n"); + goto err_free_uar; + } + + MLX5_INIT_DOORBELL_LOCK(&priv->cq_uar_lock); + + mlx5_init_cq_table(dev); + mlx5_init_qp_table(dev); + mlx5_init_srq_table(dev); + + return 0; + +err_free_uar: + mlx5_free_uuars(dev, &priv->uuari); + +err_eq_cleanup: + mlx5_eq_cleanup(dev); + +disable_msix: + mlx5_disable_msix(dev); + +err_stop_poll: + mlx5_stop_health_poll(dev); + mlx5_cmd_teardown_hca(dev); + +err_pagealloc_stop: + mlx5_pagealloc_stop(dev); + +err_reclaim_pages: + mlx5_reclaim_startup_pages(dev); + +err_pagealloc_cleanup: + mlx5_pagealloc_cleanup(dev); + mlx5_cmd_cleanup(dev); + +err_unmap: + iounmap(dev->iseg); + +err_clr_master: + pci_clear_master(dev->pdev); + release_bar(dev->pdev); + +err_disable: + pci_disable_device(dev->pdev); + +err_dbg: + debugfs_remove(priv->dbg_root); + return err; +} +EXPORT_SYMBOL(mlx5_dev_init); + +void mlx5_dev_cleanup(struct mlx5_core_dev *dev) +{ + struct mlx5_priv *priv = &dev->priv; + + mlx5_cleanup_srq_table(dev); + mlx5_cleanup_qp_table(dev); + mlx5_cleanup_cq_table(dev); + mlx5_stop_eqs(dev); + mlx5_free_uuars(dev, &priv->uuari); + mlx5_eq_cleanup(dev); + mlx5_disable_msix(dev); + mlx5_stop_health_poll(dev); + mlx5_cmd_teardown_hca(dev); + mlx5_pagealloc_stop(dev); + mlx5_reclaim_startup_pages(dev); + mlx5_pagealloc_cleanup(dev); + mlx5_cmd_cleanup(dev); + iounmap(dev->iseg); + pci_clear_master(dev->pdev); + release_bar(dev->pdev); + pci_disable_device(dev->pdev); + debugfs_remove(priv->dbg_root); +} +EXPORT_SYMBOL(mlx5_dev_cleanup); + +static int __init init(void) +{ + int err; + + mlx5_register_debugfs(); + mlx5_core_wq = create_singlethread_workqueue("mlx5_core_wq"); + if (!mlx5_core_wq) { + err = -ENOMEM; + goto err_debug; + } + mlx5_health_init(); + + return 0; + + mlx5_health_cleanup(); +err_debug: + mlx5_unregister_debugfs(); + return err; +} + +static void __exit cleanup(void) +{ + mlx5_health_cleanup(); + destroy_workqueue(mlx5_core_wq); + mlx5_unregister_debugfs(); +} + +module_init(init); +module_exit(cleanup); diff --git a/drivers/net/ethernet/mellanox/mlx5/core/mcg.c b/drivers/net/ethernet/mellanox/mlx5/core/mcg.c new file mode 100644 index 000000000000..44837640bd7c --- /dev/null +++ b/drivers/net/ethernet/mellanox/mlx5/core/mcg.c @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2013, Mellanox Technologies inc. All rights reserved. + * + * This software is available to you under a choice of one of two + * licenses. You may choose to be licensed under the terms of the GNU + * General Public License (GPL) Version 2, available from the file + * COPYING in the main directory of this source tree, or the + * OpenIB.org BSD license below: + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include +#include +#include +#include +#include +#include "mlx5_core.h" + +struct mlx5_attach_mcg_mbox_in { + struct mlx5_inbox_hdr hdr; + __be32 qpn; + __be32 rsvd; + u8 gid[16]; +}; + +struct mlx5_attach_mcg_mbox_out { + struct mlx5_outbox_hdr hdr; + u8 rsvf[8]; +}; + +struct mlx5_detach_mcg_mbox_in { + struct mlx5_inbox_hdr hdr; + __be32 qpn; + __be32 rsvd; + u8 gid[16]; +}; + +struct mlx5_detach_mcg_mbox_out { + struct mlx5_outbox_hdr hdr; + u8 rsvf[8]; +}; + +int mlx5_core_attach_mcg(struct mlx5_core_dev *dev, union ib_gid *mgid, u32 qpn) +{ + struct mlx5_attach_mcg_mbox_in in; + struct mlx5_attach_mcg_mbox_out out; + int err; + + memset(&in, 0, sizeof(in)); + memset(&out, 0, sizeof(out)); + in.hdr.opcode = cpu_to_be16(MLX5_CMD_OP_ATTACH_TO_MCG); + memcpy(in.gid, mgid, sizeof(*mgid)); + in.qpn = cpu_to_be32(qpn); + err = mlx5_cmd_exec(dev, &in, sizeof(in), &out, sizeof(out)); + if (err) + return err; + + if (out.hdr.status) + err = mlx5_cmd_status_to_err(&out.hdr); + + return err; +} +EXPORT_SYMBOL(mlx5_core_attach_mcg); + +int mlx5_core_detach_mcg(struct mlx5_core_dev *dev, union ib_gid *mgid, u32 qpn) +{ + struct mlx5_detach_mcg_mbox_in in; + struct mlx5_detach_mcg_mbox_out out; + int err; + + memset(&in, 0, sizeof(in)); + memset(&out, 0, sizeof(out)); + in.hdr.opcode = cpu_to_be16(MLX5_CMD_OP_DETACH_FROM_MCG); + memcpy(in.gid, mgid, sizeof(*mgid)); + in.qpn = cpu_to_be32(qpn); + err = mlx5_cmd_exec(dev, &in, sizeof(in), &out, sizeof(out)); + if (err) + return err; + + if (out.hdr.status) + err = mlx5_cmd_status_to_err(&out.hdr); + + return err; +} +EXPORT_SYMBOL(mlx5_core_detach_mcg); diff --git a/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h b/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h new file mode 100644 index 000000000000..68b74e1ae1b0 --- /dev/null +++ b/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2013, Mellanox Technologies inc. All rights reserved. + * + * This software is available to you under a choice of one of two + * licenses. You may choose to be licensed under the terms of the GNU + * General Public License (GPL) Version 2, available from the file + * COPYING in the main directory of this source tree, or the + * OpenIB.org BSD license below: + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#ifndef __MLX5_CORE_H__ +#define __MLX5_CORE_H__ + +#include +#include +#include + +extern int mlx5_core_debug_mask; + +#define mlx5_core_dbg(dev, format, arg...) \ +pr_debug("%s:%s:%d:(pid %d): " format, (dev)->priv.name, __func__, __LINE__, \ + current->pid, ##arg) + +#define mlx5_core_dbg_mask(dev, mask, format, arg...) \ +do { \ + if ((mask) & mlx5_core_debug_mask) \ + pr_debug("%s:%s:%d:(pid %d): " format, (dev)->priv.name, \ + __func__, __LINE__, current->pid, ##arg); \ +} while (0) + +#define mlx5_core_err(dev, format, arg...) \ +pr_err("%s:%s:%d:(pid %d): " format, (dev)->priv.name, __func__, __LINE__, \ + current->pid, ##arg) + +#define mlx5_core_warn(dev, format, arg...) \ +pr_warn("%s:%s:%d:(pid %d): " format, (dev)->priv.name, __func__, __LINE__, \ + current->pid, ##arg) + +enum { + MLX5_CMD_DATA, /* print command payload only */ + MLX5_CMD_TIME, /* print command execution time */ +}; + + +int mlx5_cmd_query_hca_cap(struct mlx5_core_dev *dev, + struct mlx5_caps *caps); +int mlx5_cmd_query_adapter(struct mlx5_core_dev *dev); +int mlx5_cmd_init_hca(struct mlx5_core_dev *dev); +int mlx5_cmd_teardown_hca(struct mlx5_core_dev *dev); + +#endif /* __MLX5_CORE_H__ */ diff --git a/drivers/net/ethernet/mellanox/mlx5/core/mr.c b/drivers/net/ethernet/mellanox/mlx5/core/mr.c new file mode 100644 index 000000000000..5b44e2e46daf --- /dev/null +++ b/drivers/net/ethernet/mellanox/mlx5/core/mr.c @@ -0,0 +1,136 @@ +/* + * Copyright (c) 2013, Mellanox Technologies inc. All rights reserved. + * + * This software is available to you under a choice of one of two + * licenses. You may choose to be licensed under the terms of the GNU + * General Public License (GPL) Version 2, available from the file + * COPYING in the main directory of this source tree, or the + * OpenIB.org BSD license below: + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include +#include +#include +#include +#include "mlx5_core.h" + +int mlx5_core_create_mkey(struct mlx5_core_dev *dev, struct mlx5_core_mr *mr, + struct mlx5_create_mkey_mbox_in *in, int inlen) +{ + struct mlx5_create_mkey_mbox_out out; + int err; + u8 key; + + memset(&out, 0, sizeof(out)); + spin_lock(&dev->priv.mkey_lock); + key = dev->priv.mkey_key++; + spin_unlock(&dev->priv.mkey_lock); + in->seg.qpn_mkey7_0 |= cpu_to_be32(key); + in->hdr.opcode = cpu_to_be16(MLX5_CMD_OP_CREATE_MKEY); + err = mlx5_cmd_exec(dev, in, inlen, &out, sizeof(out)); + if (err) { + mlx5_core_dbg(dev, "cmd exec faile %d\n", err); + return err; + } + + if (out.hdr.status) { + mlx5_core_dbg(dev, "status %d\n", out.hdr.status); + return mlx5_cmd_status_to_err(&out.hdr); + } + + mr->key = mlx5_idx_to_mkey(be32_to_cpu(out.mkey) & 0xffffff) | key; + mlx5_core_dbg(dev, "out 0x%x, key 0x%x, mkey 0x%x\n", be32_to_cpu(out.mkey), key, mr->key); + + return err; +} +EXPORT_SYMBOL(mlx5_core_create_mkey); + +int mlx5_core_destroy_mkey(struct mlx5_core_dev *dev, struct mlx5_core_mr *mr) +{ + struct mlx5_destroy_mkey_mbox_in in; + struct mlx5_destroy_mkey_mbox_out out; + int err; + + memset(&in, 0, sizeof(in)); + memset(&out, 0, sizeof(out)); + + in.hdr.opcode = cpu_to_be16(MLX5_CMD_OP_DESTROY_MKEY); + in.mkey = cpu_to_be32(mlx5_mkey_to_idx(mr->key)); + err = mlx5_cmd_exec(dev, &in, sizeof(in), &out, sizeof(out)); + if (err) + return err; + + if (out.hdr.status) + return mlx5_cmd_status_to_err(&out.hdr); + + return err; +} +EXPORT_SYMBOL(mlx5_core_destroy_mkey); + +int mlx5_core_query_mkey(struct mlx5_core_dev *dev, struct mlx5_core_mr *mr, + struct mlx5_query_mkey_mbox_out *out, int outlen) +{ + struct mlx5_destroy_mkey_mbox_in in; + int err; + + memset(&in, 0, sizeof(in)); + memset(out, 0, outlen); + + in.hdr.opcode = cpu_to_be16(MLX5_CMD_OP_QUERY_MKEY); + in.mkey = cpu_to_be32(mlx5_mkey_to_idx(mr->key)); + err = mlx5_cmd_exec(dev, &in, sizeof(in), out, outlen); + if (err) + return err; + + if (out->hdr.status) + return mlx5_cmd_status_to_err(&out->hdr); + + return err; +} +EXPORT_SYMBOL(mlx5_core_query_mkey); + +int mlx5_core_dump_fill_mkey(struct mlx5_core_dev *dev, struct mlx5_core_mr *mr, + u32 *mkey) +{ + struct mlx5_query_special_ctxs_mbox_in in; + struct mlx5_query_special_ctxs_mbox_out out; + int err; + + memset(&in, 0, sizeof(in)); + memset(&out, 0, sizeof(out)); + + in.hdr.opcode = cpu_to_be16(MLX5_CMD_OP_QUERY_SPECIAL_CONTEXTS); + err = mlx5_cmd_exec(dev, &in, sizeof(in), &out, sizeof(out)); + if (err) + return err; + + if (out.hdr.status) + return mlx5_cmd_status_to_err(&out.hdr); + + *mkey = be32_to_cpu(out.dump_fill_mkey); + + return err; +} +EXPORT_SYMBOL(mlx5_core_dump_fill_mkey); diff --git a/drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c b/drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c new file mode 100644 index 000000000000..f0bf46339b28 --- /dev/null +++ b/drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c @@ -0,0 +1,435 @@ +/* + * Copyright (c) 2013, Mellanox Technologies inc. All rights reserved. + * + * This software is available to you under a choice of one of two + * licenses. You may choose to be licensed under the terms of the GNU + * General Public License (GPL) Version 2, available from the file + * COPYING in the main directory of this source tree, or the + * OpenIB.org BSD license below: + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include +#include +#include +#include +#include +#include "mlx5_core.h" + +enum { + MLX5_PAGES_CANT_GIVE = 0, + MLX5_PAGES_GIVE = 1, + MLX5_PAGES_TAKE = 2 +}; + +struct mlx5_pages_req { + struct mlx5_core_dev *dev; + u32 func_id; + s16 npages; + struct work_struct work; +}; + +struct fw_page { + struct rb_node rb_node; + u64 addr; + struct page *page; + u16 func_id; +}; + +struct mlx5_query_pages_inbox { + struct mlx5_inbox_hdr hdr; + u8 rsvd[8]; +}; + +struct mlx5_query_pages_outbox { + struct mlx5_outbox_hdr hdr; + u8 reserved[2]; + __be16 func_id; + __be16 init_pages; + __be16 num_pages; +}; + +struct mlx5_manage_pages_inbox { + struct mlx5_inbox_hdr hdr; + __be16 rsvd0; + __be16 func_id; + __be16 rsvd1; + __be16 num_entries; + u8 rsvd2[16]; + __be64 pas[0]; +}; + +struct mlx5_manage_pages_outbox { + struct mlx5_outbox_hdr hdr; + u8 rsvd0[2]; + __be16 num_entries; + u8 rsvd1[20]; + __be64 pas[0]; +}; + +static int insert_page(struct mlx5_core_dev *dev, u64 addr, struct page *page, u16 func_id) +{ + struct rb_root *root = &dev->priv.page_root; + struct rb_node **new = &root->rb_node; + struct rb_node *parent = NULL; + struct fw_page *nfp; + struct fw_page *tfp; + + while (*new) { + parent = *new; + tfp = rb_entry(parent, struct fw_page, rb_node); + if (tfp->addr < addr) + new = &parent->rb_left; + else if (tfp->addr > addr) + new = &parent->rb_right; + else + return -EEXIST; + } + + nfp = kmalloc(sizeof(*nfp), GFP_KERNEL); + if (!nfp) + return -ENOMEM; + + nfp->addr = addr; + nfp->page = page; + nfp->func_id = func_id; + + rb_link_node(&nfp->rb_node, parent, new); + rb_insert_color(&nfp->rb_node, root); + + return 0; +} + +static struct page *remove_page(struct mlx5_core_dev *dev, u64 addr) +{ + struct rb_root *root = &dev->priv.page_root; + struct rb_node *tmp = root->rb_node; + struct page *result = NULL; + struct fw_page *tfp; + + while (tmp) { + tfp = rb_entry(tmp, struct fw_page, rb_node); + if (tfp->addr < addr) { + tmp = tmp->rb_left; + } else if (tfp->addr > addr) { + tmp = tmp->rb_right; + } else { + rb_erase(&tfp->rb_node, root); + result = tfp->page; + kfree(tfp); + break; + } + } + + return result; +} + +static int mlx5_cmd_query_pages(struct mlx5_core_dev *dev, u16 *func_id, + s16 *pages, s16 *init_pages) +{ + struct mlx5_query_pages_inbox in; + struct mlx5_query_pages_outbox out; + int err; + + memset(&in, 0, sizeof(in)); + memset(&out, 0, sizeof(out)); + in.hdr.opcode = cpu_to_be16(MLX5_CMD_OP_QUERY_PAGES); + err = mlx5_cmd_exec(dev, &in, sizeof(in), &out, sizeof(out)); + if (err) + return err; + + if (out.hdr.status) + return mlx5_cmd_status_to_err(&out.hdr); + + if (pages) + *pages = be16_to_cpu(out.num_pages); + if (init_pages) + *init_pages = be16_to_cpu(out.init_pages); + *func_id = be16_to_cpu(out.func_id); + + return err; +} + +static int give_pages(struct mlx5_core_dev *dev, u16 func_id, int npages, + int notify_fail) +{ + struct mlx5_manage_pages_inbox *in; + struct mlx5_manage_pages_outbox out; + struct page *page; + int inlen; + u64 addr; + int err; + int i; + + inlen = sizeof(*in) + npages * sizeof(in->pas[0]); + in = mlx5_vzalloc(inlen); + if (!in) { + mlx5_core_warn(dev, "vzalloc failed %d\n", inlen); + return -ENOMEM; + } + memset(&out, 0, sizeof(out)); + + for (i = 0; i < npages; i++) { + page = alloc_page(GFP_HIGHUSER); + if (!page) { + err = -ENOMEM; + mlx5_core_warn(dev, "failed to allocate page\n"); + goto out_alloc; + } + addr = dma_map_page(&dev->pdev->dev, page, 0, + PAGE_SIZE, DMA_BIDIRECTIONAL); + if (dma_mapping_error(&dev->pdev->dev, addr)) { + mlx5_core_warn(dev, "failed dma mapping page\n"); + __free_page(page); + err = -ENOMEM; + goto out_alloc; + } + err = insert_page(dev, addr, page, func_id); + if (err) { + mlx5_core_err(dev, "failed to track allocated page\n"); + dma_unmap_page(&dev->pdev->dev, addr, PAGE_SIZE, DMA_BIDIRECTIONAL); + __free_page(page); + err = -ENOMEM; + goto out_alloc; + } + in->pas[i] = cpu_to_be64(addr); + } + + in->hdr.opcode = cpu_to_be16(MLX5_CMD_OP_MANAGE_PAGES); + in->hdr.opmod = cpu_to_be16(MLX5_PAGES_GIVE); + in->func_id = cpu_to_be16(func_id); + in->num_entries = cpu_to_be16(npages); + err = mlx5_cmd_exec(dev, in, inlen, &out, sizeof(out)); + mlx5_core_dbg(dev, "err %d\n", err); + if (err) { + mlx5_core_warn(dev, "func_id 0x%x, npages %d, err %d\n", func_id, npages, err); + goto out_alloc; + } + dev->priv.fw_pages += npages; + + if (out.hdr.status) { + err = mlx5_cmd_status_to_err(&out.hdr); + if (err) { + mlx5_core_warn(dev, "func_id 0x%x, npages %d, status %d\n", func_id, npages, out.hdr.status); + goto out_alloc; + } + } + + mlx5_core_dbg(dev, "err %d\n", err); + + goto out_free; + +out_alloc: + if (notify_fail) { + memset(in, 0, inlen); + memset(&out, 0, sizeof(out)); + in->hdr.opcode = cpu_to_be16(MLX5_CMD_OP_MANAGE_PAGES); + in->hdr.opmod = cpu_to_be16(MLX5_PAGES_CANT_GIVE); + if (mlx5_cmd_exec(dev, in, sizeof(*in), &out, sizeof(out))) + mlx5_core_warn(dev, "\n"); + } + for (i--; i >= 0; i--) { + addr = be64_to_cpu(in->pas[i]); + page = remove_page(dev, addr); + if (!page) { + mlx5_core_err(dev, "BUG: can't remove page at addr 0x%llx\n", + addr); + continue; + } + dma_unmap_page(&dev->pdev->dev, addr, PAGE_SIZE, DMA_BIDIRECTIONAL); + __free_page(page); + } + +out_free: + mlx5_vfree(in); + return err; +} + +static int reclaim_pages(struct mlx5_core_dev *dev, u32 func_id, int npages, + int *nclaimed) +{ + struct mlx5_manage_pages_inbox in; + struct mlx5_manage_pages_outbox *out; + struct page *page; + int num_claimed; + int outlen; + u64 addr; + int err; + int i; + + memset(&in, 0, sizeof(in)); + outlen = sizeof(*out) + npages * sizeof(out->pas[0]); + out = mlx5_vzalloc(outlen); + if (!out) + return -ENOMEM; + + in.hdr.opcode = cpu_to_be16(MLX5_CMD_OP_MANAGE_PAGES); + in.hdr.opmod = cpu_to_be16(MLX5_PAGES_TAKE); + in.func_id = cpu_to_be16(func_id); + in.num_entries = cpu_to_be16(npages); + mlx5_core_dbg(dev, "npages %d, outlen %d\n", npages, outlen); + err = mlx5_cmd_exec(dev, &in, sizeof(in), out, outlen); + if (err) { + mlx5_core_err(dev, "failed recliaming pages\n"); + goto out_free; + } + dev->priv.fw_pages -= npages; + + if (out->hdr.status) { + err = mlx5_cmd_status_to_err(&out->hdr); + goto out_free; + } + + num_claimed = be16_to_cpu(out->num_entries); + if (nclaimed) + *nclaimed = num_claimed; + + for (i = 0; i < num_claimed; i++) { + addr = be64_to_cpu(out->pas[i]); + page = remove_page(dev, addr); + if (!page) { + mlx5_core_warn(dev, "FW reported unknown DMA address 0x%llx\n", addr); + } else { + dma_unmap_page(&dev->pdev->dev, addr, PAGE_SIZE, DMA_BIDIRECTIONAL); + __free_page(page); + } + } + +out_free: + mlx5_vfree(out); + return err; +} + +static void pages_work_handler(struct work_struct *work) +{ + struct mlx5_pages_req *req = container_of(work, struct mlx5_pages_req, work); + struct mlx5_core_dev *dev = req->dev; + int err = 0; + + if (req->npages < 0) + err = reclaim_pages(dev, req->func_id, -1 * req->npages, NULL); + else if (req->npages > 0) + err = give_pages(dev, req->func_id, req->npages, 1); + + if (err) + mlx5_core_warn(dev, "%s fail %d\n", req->npages < 0 ? + "reclaim" : "give", err); + + kfree(req); +} + +void mlx5_core_req_pages_handler(struct mlx5_core_dev *dev, u16 func_id, + s16 npages) +{ + struct mlx5_pages_req *req; + + req = kzalloc(sizeof(*req), GFP_ATOMIC); + if (!req) { + mlx5_core_warn(dev, "failed to allocate pages request\n"); + return; + } + + req->dev = dev; + req->func_id = func_id; + req->npages = npages; + INIT_WORK(&req->work, pages_work_handler); + queue_work(dev->priv.pg_wq, &req->work); +} + +int mlx5_satisfy_startup_pages(struct mlx5_core_dev *dev) +{ + s16 uninitialized_var(init_pages); + u16 uninitialized_var(func_id); + int err; + + err = mlx5_cmd_query_pages(dev, &func_id, NULL, &init_pages); + if (err) + return err; + + mlx5_core_dbg(dev, "requested %d init pages for func_id 0x%x\n", init_pages, func_id); + + return give_pages(dev, func_id, init_pages, 0); +} + +static int optimal_reclaimed_pages(void) +{ + struct mlx5_cmd_prot_block *block; + struct mlx5_cmd_layout *lay; + int ret; + + ret = (sizeof(lay->in) + sizeof(block->data) - + sizeof(struct mlx5_manage_pages_outbox)) / 8; + + return ret; +} + +int mlx5_reclaim_startup_pages(struct mlx5_core_dev *dev) +{ + unsigned long end = jiffies + msecs_to_jiffies(5000); + struct fw_page *fwp; + struct rb_node *p; + int err; + + do { + p = rb_first(&dev->priv.page_root); + if (p) { + fwp = rb_entry(p, struct fw_page, rb_node); + err = reclaim_pages(dev, fwp->func_id, optimal_reclaimed_pages(), NULL); + if (err) { + mlx5_core_warn(dev, "failed reclaiming pages (%d)\n", err); + return err; + } + } + if (time_after(jiffies, end)) { + mlx5_core_warn(dev, "FW did not return all pages. giving up...\n"); + break; + } + } while (p); + + return 0; +} + +void mlx5_pagealloc_init(struct mlx5_core_dev *dev) +{ + dev->priv.page_root = RB_ROOT; +} + +void mlx5_pagealloc_cleanup(struct mlx5_core_dev *dev) +{ + /* nothing */ +} + +int mlx5_pagealloc_start(struct mlx5_core_dev *dev) +{ + dev->priv.pg_wq = create_singlethread_workqueue("mlx5_page_allocator"); + if (!dev->priv.pg_wq) + return -ENOMEM; + + return 0; +} + +void mlx5_pagealloc_stop(struct mlx5_core_dev *dev) +{ + destroy_workqueue(dev->priv.pg_wq); +} diff --git a/drivers/net/ethernet/mellanox/mlx5/core/pd.c b/drivers/net/ethernet/mellanox/mlx5/core/pd.c new file mode 100644 index 000000000000..790da5c4ca4f --- /dev/null +++ b/drivers/net/ethernet/mellanox/mlx5/core/pd.c @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2013, Mellanox Technologies inc. All rights reserved. + * + * This software is available to you under a choice of one of two + * licenses. You may choose to be licensed under the terms of the GNU + * General Public License (GPL) Version 2, available from the file + * COPYING in the main directory of this source tree, or the + * OpenIB.org BSD license below: + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include +#include +#include +#include +#include "mlx5_core.h" + +struct mlx5_alloc_pd_mbox_in { + struct mlx5_inbox_hdr hdr; + u8 rsvd[8]; +}; + +struct mlx5_alloc_pd_mbox_out { + struct mlx5_outbox_hdr hdr; + __be32 pdn; + u8 rsvd[4]; +}; + +struct mlx5_dealloc_pd_mbox_in { + struct mlx5_inbox_hdr hdr; + __be32 pdn; + u8 rsvd[4]; +}; + +struct mlx5_dealloc_pd_mbox_out { + struct mlx5_outbox_hdr hdr; + u8 rsvd[8]; +}; + +int mlx5_core_alloc_pd(struct mlx5_core_dev *dev, u32 *pdn) +{ + struct mlx5_alloc_pd_mbox_in in; + struct mlx5_alloc_pd_mbox_out out; + int err; + + memset(&in, 0, sizeof(in)); + memset(&out, 0, sizeof(out)); + in.hdr.opcode = cpu_to_be16(MLX5_CMD_OP_ALLOC_PD); + err = mlx5_cmd_exec(dev, &in, sizeof(in), &out, sizeof(out)); + if (err) + return err; + + if (out.hdr.status) + return mlx5_cmd_status_to_err(&out.hdr); + + *pdn = be32_to_cpu(out.pdn) & 0xffffff; + return err; +} +EXPORT_SYMBOL(mlx5_core_alloc_pd); + +int mlx5_core_dealloc_pd(struct mlx5_core_dev *dev, u32 pdn) +{ + struct mlx5_dealloc_pd_mbox_in in; + struct mlx5_dealloc_pd_mbox_out out; + int err; + + memset(&in, 0, sizeof(in)); + memset(&out, 0, sizeof(out)); + in.hdr.opcode = cpu_to_be16(MLX5_CMD_OP_DEALLOC_PD); + in.pdn = cpu_to_be32(pdn); + err = mlx5_cmd_exec(dev, &in, sizeof(in), &out, sizeof(out)); + if (err) + return err; + + if (out.hdr.status) + return mlx5_cmd_status_to_err(&out.hdr); + + return err; +} +EXPORT_SYMBOL(mlx5_core_dealloc_pd); diff --git a/drivers/net/ethernet/mellanox/mlx5/core/port.c b/drivers/net/ethernet/mellanox/mlx5/core/port.c new file mode 100644 index 000000000000..f6afe7b5a675 --- /dev/null +++ b/drivers/net/ethernet/mellanox/mlx5/core/port.c @@ -0,0 +1,104 @@ +/* + * Copyright (c) 2013, Mellanox Technologies inc. All rights reserved. + * + * This software is available to you under a choice of one of two + * licenses. You may choose to be licensed under the terms of the GNU + * General Public License (GPL) Version 2, available from the file + * COPYING in the main directory of this source tree, or the + * OpenIB.org BSD license below: + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include +#include +#include +#include "mlx5_core.h" + +int mlx5_core_access_reg(struct mlx5_core_dev *dev, void *data_in, + int size_in, void *data_out, int size_out, + u16 reg_num, int arg, int write) +{ + struct mlx5_access_reg_mbox_in *in = NULL; + struct mlx5_access_reg_mbox_out *out = NULL; + int err = -ENOMEM; + + in = mlx5_vzalloc(sizeof(*in) + size_in); + if (!in) + return -ENOMEM; + + out = mlx5_vzalloc(sizeof(*out) + size_out); + if (!out) + goto ex1; + + memcpy(in->data, data_in, size_in); + in->hdr.opcode = cpu_to_be16(MLX5_CMD_OP_ACCESS_REG); + in->hdr.opmod = cpu_to_be16(!write); + in->arg = cpu_to_be32(arg); + in->register_id = cpu_to_be16(reg_num); + err = mlx5_cmd_exec(dev, in, sizeof(*in) + size_in, out, + sizeof(out) + size_out); + if (err) + goto ex2; + + if (out->hdr.status) + err = mlx5_cmd_status_to_err(&out->hdr); + + if (!err) + memcpy(data_out, out->data, size_out); + +ex2: + mlx5_vfree(out); +ex1: + mlx5_vfree(in); + return err; +} +EXPORT_SYMBOL_GPL(mlx5_core_access_reg); + + +struct mlx5_reg_pcap { + u8 rsvd0; + u8 port_num; + u8 rsvd1[2]; + __be32 caps_127_96; + __be32 caps_95_64; + __be32 caps_63_32; + __be32 caps_31_0; +}; + +int mlx5_set_port_caps(struct mlx5_core_dev *dev, int port_num, u32 caps) +{ + struct mlx5_reg_pcap in; + struct mlx5_reg_pcap out; + int err; + + memset(&in, 0, sizeof(in)); + in.caps_127_96 = cpu_to_be32(caps); + in.port_num = port_num; + + err = mlx5_core_access_reg(dev, &in, sizeof(in), &out, + sizeof(out), MLX5_REG_PCAP, 0, 1); + + return err; +} +EXPORT_SYMBOL_GPL(mlx5_set_port_caps); diff --git a/drivers/net/ethernet/mellanox/mlx5/core/qp.c b/drivers/net/ethernet/mellanox/mlx5/core/qp.c new file mode 100644 index 000000000000..54faf8bfcaf4 --- /dev/null +++ b/drivers/net/ethernet/mellanox/mlx5/core/qp.c @@ -0,0 +1,301 @@ +/* + * Copyright (c) 2013, Mellanox Technologies inc. All rights reserved. + * + * This software is available to you under a choice of one of two + * licenses. You may choose to be licensed under the terms of the GNU + * General Public License (GPL) Version 2, available from the file + * COPYING in the main directory of this source tree, or the + * OpenIB.org BSD license below: + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + + +#include +#include +#include +#include +#include + +#include "mlx5_core.h" + +void mlx5_qp_event(struct mlx5_core_dev *dev, u32 qpn, int event_type) +{ + struct mlx5_qp_table *table = &dev->priv.qp_table; + struct mlx5_core_qp *qp; + + spin_lock(&table->lock); + + qp = radix_tree_lookup(&table->tree, qpn); + if (qp) + atomic_inc(&qp->refcount); + + spin_unlock(&table->lock); + + if (!qp) { + mlx5_core_warn(dev, "Async event for bogus QP 0x%x\n", qpn); + return; + } + + qp->event(qp, event_type); + + if (atomic_dec_and_test(&qp->refcount)) + complete(&qp->free); +} + +int mlx5_core_create_qp(struct mlx5_core_dev *dev, + struct mlx5_core_qp *qp, + struct mlx5_create_qp_mbox_in *in, + int inlen) +{ + struct mlx5_qp_table *table = &dev->priv.qp_table; + struct mlx5_create_qp_mbox_out out; + struct mlx5_destroy_qp_mbox_in din; + struct mlx5_destroy_qp_mbox_out dout; + int err; + + memset(&dout, 0, sizeof(dout)); + in->hdr.opcode = cpu_to_be16(MLX5_CMD_OP_CREATE_QP); + + err = mlx5_cmd_exec(dev, in, inlen, &out, sizeof(out)); + if (err) { + mlx5_core_warn(dev, "ret %d", err); + return err; + } + + if (out.hdr.status) { + pr_warn("current num of QPs 0x%x\n", atomic_read(&dev->num_qps)); + return mlx5_cmd_status_to_err(&out.hdr); + } + + qp->qpn = be32_to_cpu(out.qpn) & 0xffffff; + mlx5_core_dbg(dev, "qpn = 0x%x\n", qp->qpn); + + spin_lock_irq(&table->lock); + err = radix_tree_insert(&table->tree, qp->qpn, qp); + spin_unlock_irq(&table->lock); + if (err) { + mlx5_core_warn(dev, "err %d", err); + goto err_cmd; + } + + err = mlx5_debug_qp_add(dev, qp); + if (err) + mlx5_core_dbg(dev, "failed adding QP 0x%x to debug file system\n", + qp->qpn); + + qp->pid = current->pid; + atomic_set(&qp->refcount, 1); + atomic_inc(&dev->num_qps); + init_completion(&qp->free); + + return 0; + +err_cmd: + memset(&din, 0, sizeof(din)); + memset(&dout, 0, sizeof(dout)); + din.hdr.opcode = cpu_to_be16(MLX5_CMD_OP_DESTROY_QP); + din.qpn = cpu_to_be32(qp->qpn); + mlx5_cmd_exec(dev, &din, sizeof(din), &out, sizeof(dout)); + + return err; +} +EXPORT_SYMBOL_GPL(mlx5_core_create_qp); + +int mlx5_core_destroy_qp(struct mlx5_core_dev *dev, + struct mlx5_core_qp *qp) +{ + struct mlx5_destroy_qp_mbox_in in; + struct mlx5_destroy_qp_mbox_out out; + struct mlx5_qp_table *table = &dev->priv.qp_table; + unsigned long flags; + int err; + + mlx5_debug_qp_remove(dev, qp); + + spin_lock_irqsave(&table->lock, flags); + radix_tree_delete(&table->tree, qp->qpn); + spin_unlock_irqrestore(&table->lock, flags); + + if (atomic_dec_and_test(&qp->refcount)) + complete(&qp->free); + wait_for_completion(&qp->free); + + memset(&in, 0, sizeof(in)); + memset(&out, 0, sizeof(out)); + in.hdr.opcode = cpu_to_be16(MLX5_CMD_OP_DESTROY_QP); + in.qpn = cpu_to_be32(qp->qpn); + err = mlx5_cmd_exec(dev, &in, sizeof(in), &out, sizeof(out)); + if (err) + return err; + + if (out.hdr.status) + return mlx5_cmd_status_to_err(&out.hdr); + + atomic_dec(&dev->num_qps); + return 0; +} +EXPORT_SYMBOL_GPL(mlx5_core_destroy_qp); + +int mlx5_core_qp_modify(struct mlx5_core_dev *dev, enum mlx5_qp_state cur_state, + enum mlx5_qp_state new_state, + struct mlx5_modify_qp_mbox_in *in, int sqd_event, + struct mlx5_core_qp *qp) +{ + static const u16 optab[MLX5_QP_NUM_STATE][MLX5_QP_NUM_STATE] = { + [MLX5_QP_STATE_RST] = { + [MLX5_QP_STATE_RST] = MLX5_CMD_OP_2RST_QP, + [MLX5_QP_STATE_ERR] = MLX5_CMD_OP_2ERR_QP, + [MLX5_QP_STATE_INIT] = MLX5_CMD_OP_RST2INIT_QP, + }, + [MLX5_QP_STATE_INIT] = { + [MLX5_QP_STATE_RST] = MLX5_CMD_OP_2RST_QP, + [MLX5_QP_STATE_ERR] = MLX5_CMD_OP_2ERR_QP, + [MLX5_QP_STATE_INIT] = MLX5_CMD_OP_INIT2INIT_QP, + [MLX5_QP_STATE_RTR] = MLX5_CMD_OP_INIT2RTR_QP, + }, + [MLX5_QP_STATE_RTR] = { + [MLX5_QP_STATE_RST] = MLX5_CMD_OP_2RST_QP, + [MLX5_QP_STATE_ERR] = MLX5_CMD_OP_2ERR_QP, + [MLX5_QP_STATE_RTS] = MLX5_CMD_OP_RTR2RTS_QP, + }, + [MLX5_QP_STATE_RTS] = { + [MLX5_QP_STATE_RST] = MLX5_CMD_OP_2RST_QP, + [MLX5_QP_STATE_ERR] = MLX5_CMD_OP_2ERR_QP, + [MLX5_QP_STATE_RTS] = MLX5_CMD_OP_RTS2RTS_QP, + [MLX5_QP_STATE_SQD] = MLX5_CMD_OP_RTS2SQD_QP, + }, + [MLX5_QP_STATE_SQD] = { + [MLX5_QP_STATE_RST] = MLX5_CMD_OP_2RST_QP, + [MLX5_QP_STATE_ERR] = MLX5_CMD_OP_2ERR_QP, + [MLX5_QP_STATE_RTS] = MLX5_CMD_OP_SQD2RTS_QP, + [MLX5_QP_STATE_SQD] = MLX5_CMD_OP_SQD2SQD_QP, + }, + [MLX5_QP_STATE_SQER] = { + [MLX5_QP_STATE_RST] = MLX5_CMD_OP_2RST_QP, + [MLX5_QP_STATE_ERR] = MLX5_CMD_OP_2ERR_QP, + [MLX5_QP_STATE_RTS] = MLX5_CMD_OP_SQERR2RTS_QP, + }, + [MLX5_QP_STATE_ERR] = { + [MLX5_QP_STATE_RST] = MLX5_CMD_OP_2RST_QP, + [MLX5_QP_STATE_ERR] = MLX5_CMD_OP_2ERR_QP, + } + }; + + struct mlx5_modify_qp_mbox_out out; + int err = 0; + u16 op; + + if (cur_state >= MLX5_QP_NUM_STATE || new_state >= MLX5_QP_NUM_STATE || + !optab[cur_state][new_state]) + return -EINVAL; + + memset(&out, 0, sizeof(out)); + op = optab[cur_state][new_state]; + in->hdr.opcode = cpu_to_be16(op); + in->qpn = cpu_to_be32(qp->qpn); + err = mlx5_cmd_exec(dev, in, sizeof(*in), &out, sizeof(out)); + if (err) + return err; + + return mlx5_cmd_status_to_err(&out.hdr); +} +EXPORT_SYMBOL_GPL(mlx5_core_qp_modify); + +void mlx5_init_qp_table(struct mlx5_core_dev *dev) +{ + struct mlx5_qp_table *table = &dev->priv.qp_table; + + spin_lock_init(&table->lock); + INIT_RADIX_TREE(&table->tree, GFP_ATOMIC); + mlx5_qp_debugfs_init(dev); +} + +void mlx5_cleanup_qp_table(struct mlx5_core_dev *dev) +{ + mlx5_qp_debugfs_cleanup(dev); +} + +int mlx5_core_qp_query(struct mlx5_core_dev *dev, struct mlx5_core_qp *qp, + struct mlx5_query_qp_mbox_out *out, int outlen) +{ + struct mlx5_query_qp_mbox_in in; + int err; + + memset(&in, 0, sizeof(in)); + memset(out, 0, outlen); + in.hdr.opcode = cpu_to_be16(MLX5_CMD_OP_QUERY_QP); + in.qpn = cpu_to_be32(qp->qpn); + err = mlx5_cmd_exec(dev, &in, sizeof(in), out, outlen); + if (err) + return err; + + if (out->hdr.status) + return mlx5_cmd_status_to_err(&out->hdr); + + return err; +} +EXPORT_SYMBOL_GPL(mlx5_core_qp_query); + +int mlx5_core_xrcd_alloc(struct mlx5_core_dev *dev, u32 *xrcdn) +{ + struct mlx5_alloc_xrcd_mbox_in in; + struct mlx5_alloc_xrcd_mbox_out out; + int err; + + memset(&in, 0, sizeof(in)); + memset(&out, 0, sizeof(out)); + in.hdr.opcode = cpu_to_be16(MLX5_CMD_OP_ALLOC_XRCD); + err = mlx5_cmd_exec(dev, &in, sizeof(in), &out, sizeof(out)); + if (err) + return err; + + if (out.hdr.status) + err = mlx5_cmd_status_to_err(&out.hdr); + else + *xrcdn = be32_to_cpu(out.xrcdn); + + return err; +} +EXPORT_SYMBOL_GPL(mlx5_core_xrcd_alloc); + +int mlx5_core_xrcd_dealloc(struct mlx5_core_dev *dev, u32 xrcdn) +{ + struct mlx5_dealloc_xrcd_mbox_in in; + struct mlx5_dealloc_xrcd_mbox_out out; + int err; + + memset(&in, 0, sizeof(in)); + memset(&out, 0, sizeof(out)); + in.hdr.opcode = cpu_to_be16(MLX5_CMD_OP_DEALLOC_XRCD); + in.xrcdn = cpu_to_be32(xrcdn); + err = mlx5_cmd_exec(dev, &in, sizeof(in), &out, sizeof(out)); + if (err) + return err; + + if (out.hdr.status) + err = mlx5_cmd_status_to_err(&out.hdr); + + return err; +} +EXPORT_SYMBOL_GPL(mlx5_core_xrcd_dealloc); diff --git a/drivers/net/ethernet/mellanox/mlx5/core/srq.c b/drivers/net/ethernet/mellanox/mlx5/core/srq.c new file mode 100644 index 000000000000..38bce93f8314 --- /dev/null +++ b/drivers/net/ethernet/mellanox/mlx5/core/srq.c @@ -0,0 +1,223 @@ +/* + * Copyright (c) 2013, Mellanox Technologies inc. All rights reserved. + * + * This software is available to you under a choice of one of two + * licenses. You may choose to be licensed under the terms of the GNU + * General Public License (GPL) Version 2, available from the file + * COPYING in the main directory of this source tree, or the + * OpenIB.org BSD license below: + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include +#include +#include +#include +#include +#include +#include "mlx5_core.h" + +void mlx5_srq_event(struct mlx5_core_dev *dev, u32 srqn, int event_type) +{ + struct mlx5_srq_table *table = &dev->priv.srq_table; + struct mlx5_core_srq *srq; + + spin_lock(&table->lock); + + srq = radix_tree_lookup(&table->tree, srqn); + if (srq) + atomic_inc(&srq->refcount); + + spin_unlock(&table->lock); + + if (!srq) { + mlx5_core_warn(dev, "Async event for bogus SRQ 0x%08x\n", srqn); + return; + } + + srq->event(srq, event_type); + + if (atomic_dec_and_test(&srq->refcount)) + complete(&srq->free); +} + +struct mlx5_core_srq *mlx5_core_get_srq(struct mlx5_core_dev *dev, u32 srqn) +{ + struct mlx5_srq_table *table = &dev->priv.srq_table; + struct mlx5_core_srq *srq; + + spin_lock(&table->lock); + + srq = radix_tree_lookup(&table->tree, srqn); + if (srq) + atomic_inc(&srq->refcount); + + spin_unlock(&table->lock); + + return srq; +} +EXPORT_SYMBOL(mlx5_core_get_srq); + +int mlx5_core_create_srq(struct mlx5_core_dev *dev, struct mlx5_core_srq *srq, + struct mlx5_create_srq_mbox_in *in, int inlen) +{ + struct mlx5_create_srq_mbox_out out; + struct mlx5_srq_table *table = &dev->priv.srq_table; + struct mlx5_destroy_srq_mbox_in din; + struct mlx5_destroy_srq_mbox_out dout; + int err; + + memset(&out, 0, sizeof(out)); + in->hdr.opcode = cpu_to_be16(MLX5_CMD_OP_CREATE_SRQ); + err = mlx5_cmd_exec(dev, in, inlen, &out, sizeof(out)); + if (err) + return err; + + if (out.hdr.status) + return mlx5_cmd_status_to_err(&out.hdr); + + srq->srqn = be32_to_cpu(out.srqn) & 0xffffff; + + atomic_set(&srq->refcount, 1); + init_completion(&srq->free); + + spin_lock_irq(&table->lock); + err = radix_tree_insert(&table->tree, srq->srqn, srq); + spin_unlock_irq(&table->lock); + if (err) { + mlx5_core_warn(dev, "err %d, srqn 0x%x\n", err, srq->srqn); + goto err_cmd; + } + + return 0; + +err_cmd: + memset(&din, 0, sizeof(din)); + memset(&dout, 0, sizeof(dout)); + din.srqn = cpu_to_be32(srq->srqn); + din.hdr.opcode = cpu_to_be16(MLX5_CMD_OP_DESTROY_SRQ); + mlx5_cmd_exec(dev, &din, sizeof(din), &dout, sizeof(dout)); + return err; +} +EXPORT_SYMBOL(mlx5_core_create_srq); + +int mlx5_core_destroy_srq(struct mlx5_core_dev *dev, struct mlx5_core_srq *srq) +{ + struct mlx5_destroy_srq_mbox_in in; + struct mlx5_destroy_srq_mbox_out out; + struct mlx5_srq_table *table = &dev->priv.srq_table; + struct mlx5_core_srq *tmp; + int err; + + spin_lock_irq(&table->lock); + tmp = radix_tree_delete(&table->tree, srq->srqn); + spin_unlock_irq(&table->lock); + if (!tmp) { + mlx5_core_warn(dev, "srq 0x%x not found in tree\n", srq->srqn); + return -EINVAL; + } + if (tmp != srq) { + mlx5_core_warn(dev, "corruption on srqn 0x%x\n", srq->srqn); + return -EINVAL; + } + + memset(&in, 0, sizeof(in)); + memset(&out, 0, sizeof(out)); + in.hdr.opcode = cpu_to_be16(MLX5_CMD_OP_DESTROY_SRQ); + in.srqn = cpu_to_be32(srq->srqn); + err = mlx5_cmd_exec(dev, &in, sizeof(in), &out, sizeof(out)); + if (err) + return err; + + if (out.hdr.status) + return mlx5_cmd_status_to_err(&out.hdr); + + if (atomic_dec_and_test(&srq->refcount)) + complete(&srq->free); + wait_for_completion(&srq->free); + + return 0; +} +EXPORT_SYMBOL(mlx5_core_destroy_srq); + +int mlx5_core_query_srq(struct mlx5_core_dev *dev, struct mlx5_core_srq *srq, + struct mlx5_query_srq_mbox_out *out) +{ + struct mlx5_query_srq_mbox_in in; + int err; + + memset(&in, 0, sizeof(in)); + memset(out, 0, sizeof(*out)); + + in.hdr.opcode = cpu_to_be16(MLX5_CMD_OP_QUERY_SRQ); + in.srqn = cpu_to_be32(srq->srqn); + err = mlx5_cmd_exec(dev, &in, sizeof(in), out, sizeof(*out)); + if (err) + return err; + + if (out->hdr.status) + return mlx5_cmd_status_to_err(&out->hdr); + + return err; +} +EXPORT_SYMBOL(mlx5_core_query_srq); + +int mlx5_core_arm_srq(struct mlx5_core_dev *dev, struct mlx5_core_srq *srq, + u16 lwm, int is_srq) +{ + struct mlx5_arm_srq_mbox_in in; + struct mlx5_arm_srq_mbox_out out; + int err; + + memset(&in, 0, sizeof(in)); + memset(&out, 0, sizeof(out)); + + in.hdr.opcode = cpu_to_be16(MLX5_CMD_OP_ARM_RQ); + in.hdr.opmod = cpu_to_be16(!!is_srq); + in.srqn = cpu_to_be32(srq->srqn); + in.lwm = cpu_to_be16(lwm); + + err = mlx5_cmd_exec(dev, &in, sizeof(in), &out, sizeof(out)); + if (err) + return err; + + if (out.hdr.status) + return mlx5_cmd_status_to_err(&out.hdr); + + return err; +} +EXPORT_SYMBOL(mlx5_core_arm_srq); + +void mlx5_init_srq_table(struct mlx5_core_dev *dev) +{ + struct mlx5_srq_table *table = &dev->priv.srq_table; + + spin_lock_init(&table->lock); + INIT_RADIX_TREE(&table->tree, GFP_ATOMIC); +} + +void mlx5_cleanup_srq_table(struct mlx5_core_dev *dev) +{ + /* nothing */ +} diff --git a/drivers/net/ethernet/mellanox/mlx5/core/uar.c b/drivers/net/ethernet/mellanox/mlx5/core/uar.c new file mode 100644 index 000000000000..71d4a3937200 --- /dev/null +++ b/drivers/net/ethernet/mellanox/mlx5/core/uar.c @@ -0,0 +1,223 @@ +/* + * Copyright (c) 2013, Mellanox Technologies inc. All rights reserved. + * + * This software is available to you under a choice of one of two + * licenses. You may choose to be licensed under the terms of the GNU + * General Public License (GPL) Version 2, available from the file + * COPYING in the main directory of this source tree, or the + * OpenIB.org BSD license below: + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include +#include +#include +#include +#include "mlx5_core.h" + +enum { + NUM_DRIVER_UARS = 4, + NUM_LOW_LAT_UUARS = 4, +}; + + +struct mlx5_alloc_uar_mbox_in { + struct mlx5_inbox_hdr hdr; + u8 rsvd[8]; +}; + +struct mlx5_alloc_uar_mbox_out { + struct mlx5_outbox_hdr hdr; + __be32 uarn; + u8 rsvd[4]; +}; + +struct mlx5_free_uar_mbox_in { + struct mlx5_inbox_hdr hdr; + __be32 uarn; + u8 rsvd[4]; +}; + +struct mlx5_free_uar_mbox_out { + struct mlx5_outbox_hdr hdr; + u8 rsvd[8]; +}; + +int mlx5_cmd_alloc_uar(struct mlx5_core_dev *dev, u32 *uarn) +{ + struct mlx5_alloc_uar_mbox_in in; + struct mlx5_alloc_uar_mbox_out out; + int err; + + memset(&in, 0, sizeof(in)); + memset(&out, 0, sizeof(out)); + in.hdr.opcode = cpu_to_be16(MLX5_CMD_OP_ALLOC_UAR); + err = mlx5_cmd_exec(dev, &in, sizeof(in), &out, sizeof(out)); + if (err) + goto ex; + + if (out.hdr.status) { + err = mlx5_cmd_status_to_err(&out.hdr); + goto ex; + } + + *uarn = be32_to_cpu(out.uarn) & 0xffffff; + +ex: + return err; +} +EXPORT_SYMBOL(mlx5_cmd_alloc_uar); + +int mlx5_cmd_free_uar(struct mlx5_core_dev *dev, u32 uarn) +{ + struct mlx5_free_uar_mbox_in in; + struct mlx5_free_uar_mbox_out out; + int err; + + memset(&in, 0, sizeof(in)); + in.hdr.opcode = cpu_to_be16(MLX5_CMD_OP_DEALLOC_UAR); + in.uarn = cpu_to_be32(uarn); + err = mlx5_cmd_exec(dev, &in, sizeof(in), &out, sizeof(out)); + if (err) + goto ex; + + if (out.hdr.status) + err = mlx5_cmd_status_to_err(&out.hdr); + +ex: + return err; +} +EXPORT_SYMBOL(mlx5_cmd_free_uar); + +static int need_uuar_lock(int uuarn) +{ + int tot_uuars = NUM_DRIVER_UARS * MLX5_BF_REGS_PER_PAGE; + + if (uuarn == 0 || tot_uuars - NUM_LOW_LAT_UUARS) + return 0; + + return 1; +} + +int mlx5_alloc_uuars(struct mlx5_core_dev *dev, struct mlx5_uuar_info *uuari) +{ + int tot_uuars = NUM_DRIVER_UARS * MLX5_BF_REGS_PER_PAGE; + struct mlx5_bf *bf; + phys_addr_t addr; + int err; + int i; + + uuari->num_uars = NUM_DRIVER_UARS; + uuari->num_low_latency_uuars = NUM_LOW_LAT_UUARS; + + mutex_init(&uuari->lock); + uuari->uars = kcalloc(uuari->num_uars, sizeof(*uuari->uars), GFP_KERNEL); + if (!uuari->uars) + return -ENOMEM; + + uuari->bfs = kcalloc(tot_uuars, sizeof(*uuari->bfs), GFP_KERNEL); + if (!uuari->bfs) { + err = -ENOMEM; + goto out_uars; + } + + uuari->bitmap = kcalloc(BITS_TO_LONGS(tot_uuars), sizeof(*uuari->bitmap), + GFP_KERNEL); + if (!uuari->bitmap) { + err = -ENOMEM; + goto out_bfs; + } + + uuari->count = kcalloc(tot_uuars, sizeof(*uuari->count), GFP_KERNEL); + if (!uuari->count) { + err = -ENOMEM; + goto out_bitmap; + } + + for (i = 0; i < uuari->num_uars; i++) { + err = mlx5_cmd_alloc_uar(dev, &uuari->uars[i].index); + if (err) + goto out_count; + + addr = dev->iseg_base + ((phys_addr_t)(uuari->uars[i].index) << PAGE_SHIFT); + uuari->uars[i].map = ioremap(addr, PAGE_SIZE); + if (!uuari->uars[i].map) { + mlx5_cmd_free_uar(dev, uuari->uars[i].index); + goto out_count; + } + mlx5_core_dbg(dev, "allocated uar index 0x%x, mmaped at %p\n", + uuari->uars[i].index, uuari->uars[i].map); + } + + for (i = 0; i < tot_uuars; i++) { + bf = &uuari->bfs[i]; + + bf->buf_size = dev->caps.bf_reg_size / 2; + bf->uar = &uuari->uars[i / MLX5_BF_REGS_PER_PAGE]; + bf->regreg = uuari->uars[i / MLX5_BF_REGS_PER_PAGE].map; + bf->reg = NULL; /* Add WC support */ + bf->offset = (i % MLX5_BF_REGS_PER_PAGE) * dev->caps.bf_reg_size + + MLX5_BF_OFFSET; + bf->need_lock = need_uuar_lock(i); + spin_lock_init(&bf->lock); + spin_lock_init(&bf->lock32); + bf->uuarn = i; + } + + return 0; + +out_count: + for (i--; i >= 0; i--) { + iounmap(uuari->uars[i].map); + mlx5_cmd_free_uar(dev, uuari->uars[i].index); + } + kfree(uuari->count); + +out_bitmap: + kfree(uuari->bitmap); + +out_bfs: + kfree(uuari->bfs); + +out_uars: + kfree(uuari->uars); + return err; +} + +int mlx5_free_uuars(struct mlx5_core_dev *dev, struct mlx5_uuar_info *uuari) +{ + int i = uuari->num_uars; + + for (i--; i >= 0; i--) { + iounmap(uuari->uars[i].map); + mlx5_cmd_free_uar(dev, uuari->uars[i].index); + } + + kfree(uuari->count); + kfree(uuari->bitmap); + kfree(uuari->bfs); + kfree(uuari->uars); + + return 0; +} diff --git a/include/linux/mlx5/cmd.h b/include/linux/mlx5/cmd.h new file mode 100644 index 000000000000..2826a4b6071e --- /dev/null +++ b/include/linux/mlx5/cmd.h @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2013, Mellanox Technologies inc. All rights reserved. + * + * This software is available to you under a choice of one of two + * licenses. You may choose to be licensed under the terms of the GNU + * General Public License (GPL) Version 2, available from the file + * COPYING in the main directory of this source tree, or the + * OpenIB.org BSD license below: + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#ifndef MLX5_CMD_H +#define MLX5_CMD_H + +#include + +struct manage_pages_layout { + u64 ptr; + u32 reserved; + u16 num_entries; + u16 func_id; +}; + + +struct mlx5_cmd_alloc_uar_imm_out { + u32 rsvd[3]; + u32 uarn; +}; + +#endif /* MLX5_CMD_H */ diff --git a/include/linux/mlx5/cq.h b/include/linux/mlx5/cq.h new file mode 100644 index 000000000000..3db67f73d96d --- /dev/null +++ b/include/linux/mlx5/cq.h @@ -0,0 +1,165 @@ +/* + * Copyright (c) 2013, Mellanox Technologies inc. All rights reserved. + * + * This software is available to you under a choice of one of two + * licenses. You may choose to be licensed under the terms of the GNU + * General Public License (GPL) Version 2, available from the file + * COPYING in the main directory of this source tree, or the + * OpenIB.org BSD license below: + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#ifndef MLX5_CORE_CQ_H +#define MLX5_CORE_CQ_H + +#include +#include + + +struct mlx5_core_cq { + u32 cqn; + int cqe_sz; + __be32 *set_ci_db; + __be32 *arm_db; + atomic_t refcount; + struct completion free; + unsigned vector; + int irqn; + void (*comp) (struct mlx5_core_cq *); + void (*event) (struct mlx5_core_cq *, enum mlx5_event); + struct mlx5_uar *uar; + u32 cons_index; + unsigned arm_sn; + struct mlx5_rsc_debug *dbg; + int pid; +}; + + +enum { + MLX5_CQE_SYNDROME_LOCAL_LENGTH_ERR = 0x01, + MLX5_CQE_SYNDROME_LOCAL_QP_OP_ERR = 0x02, + MLX5_CQE_SYNDROME_LOCAL_PROT_ERR = 0x04, + MLX5_CQE_SYNDROME_WR_FLUSH_ERR = 0x05, + MLX5_CQE_SYNDROME_MW_BIND_ERR = 0x06, + MLX5_CQE_SYNDROME_BAD_RESP_ERR = 0x10, + MLX5_CQE_SYNDROME_LOCAL_ACCESS_ERR = 0x11, + MLX5_CQE_SYNDROME_REMOTE_INVAL_REQ_ERR = 0x12, + MLX5_CQE_SYNDROME_REMOTE_ACCESS_ERR = 0x13, + MLX5_CQE_SYNDROME_REMOTE_OP_ERR = 0x14, + MLX5_CQE_SYNDROME_TRANSPORT_RETRY_EXC_ERR = 0x15, + MLX5_CQE_SYNDROME_RNR_RETRY_EXC_ERR = 0x16, + MLX5_CQE_SYNDROME_REMOTE_ABORTED_ERR = 0x22, +}; + +enum { + MLX5_CQE_OWNER_MASK = 1, + MLX5_CQE_REQ = 0, + MLX5_CQE_RESP_WR_IMM = 1, + MLX5_CQE_RESP_SEND = 2, + MLX5_CQE_RESP_SEND_IMM = 3, + MLX5_CQE_RESP_SEND_INV = 4, + MLX5_CQE_RESIZE_CQ = 0xff, /* TBD */ + MLX5_CQE_REQ_ERR = 13, + MLX5_CQE_RESP_ERR = 14, +}; + +enum { + MLX5_CQ_MODIFY_RESEIZE = 0, + MLX5_CQ_MODIFY_MODER = 1, + MLX5_CQ_MODIFY_MAPPING = 2, +}; + +struct mlx5_cq_modify_params { + int type; + union { + struct { + u32 page_offset; + u8 log_cq_size; + } resize; + + struct { + } moder; + + struct { + } mapping; + } params; +}; + +enum { + CQE_SIZE_64 = 0, + CQE_SIZE_128 = 1, +}; + +static inline int cqe_sz_to_mlx_sz(u8 size) +{ + return size == 64 ? CQE_SIZE_64 : CQE_SIZE_128; +} + +static inline void mlx5_cq_set_ci(struct mlx5_core_cq *cq) +{ + *cq->set_ci_db = cpu_to_be32(cq->cons_index & 0xffffff); +} + +enum { + MLX5_CQ_DB_REQ_NOT_SOL = 1 << 24, + MLX5_CQ_DB_REQ_NOT = 0 << 24 +}; + +static inline void mlx5_cq_arm(struct mlx5_core_cq *cq, u32 cmd, + void __iomem *uar_page, + spinlock_t *doorbell_lock) +{ + __be32 doorbell[2]; + u32 sn; + u32 ci; + + sn = cq->arm_sn & 3; + ci = cq->cons_index & 0xffffff; + + *cq->arm_db = cpu_to_be32(sn << 28 | cmd | ci); + + /* Make sure that the doorbell record in host memory is + * written before ringing the doorbell via PCI MMIO. + */ + wmb(); + + doorbell[0] = cpu_to_be32(sn << 28 | cmd | ci); + doorbell[1] = cpu_to_be32(cq->cqn); + + mlx5_write64(doorbell, uar_page + MLX5_CQ_DOORBELL, doorbell_lock); +} + +int mlx5_init_cq_table(struct mlx5_core_dev *dev); +void mlx5_cleanup_cq_table(struct mlx5_core_dev *dev); +int mlx5_core_create_cq(struct mlx5_core_dev *dev, struct mlx5_core_cq *cq, + struct mlx5_create_cq_mbox_in *in, int inlen); +int mlx5_core_destroy_cq(struct mlx5_core_dev *dev, struct mlx5_core_cq *cq); +int mlx5_core_query_cq(struct mlx5_core_dev *dev, struct mlx5_core_cq *cq, + struct mlx5_query_cq_mbox_out *out); +int mlx5_core_modify_cq(struct mlx5_core_dev *dev, struct mlx5_core_cq *cq, + int type, struct mlx5_cq_modify_params *params); +int mlx5_debug_cq_add(struct mlx5_core_dev *dev, struct mlx5_core_cq *cq); +void mlx5_debug_cq_remove(struct mlx5_core_dev *dev, struct mlx5_core_cq *cq); + +#endif /* MLX5_CORE_CQ_H */ diff --git a/include/linux/mlx5/device.h b/include/linux/mlx5/device.h new file mode 100644 index 000000000000..51390915e538 --- /dev/null +++ b/include/linux/mlx5/device.h @@ -0,0 +1,893 @@ +/* + * Copyright (c) 2013, Mellanox Technologies inc. All rights reserved. + * + * This software is available to you under a choice of one of two + * licenses. You may choose to be licensed under the terms of the GNU + * General Public License (GPL) Version 2, available from the file + * COPYING in the main directory of this source tree, or the + * OpenIB.org BSD license below: + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#ifndef MLX5_DEVICE_H +#define MLX5_DEVICE_H + +#include +#include + +#if defined(__LITTLE_ENDIAN) +#define MLX5_SET_HOST_ENDIANNESS 0 +#elif defined(__BIG_ENDIAN) +#define MLX5_SET_HOST_ENDIANNESS 0x80 +#else +#error Host endianness not defined +#endif + +enum { + MLX5_MAX_COMMANDS = 32, + MLX5_CMD_DATA_BLOCK_SIZE = 512, + MLX5_PCI_CMD_XPORT = 7, +}; + +enum { + MLX5_EXTENDED_UD_AV = 0x80000000, +}; + +enum { + MLX5_CQ_STATE_ARMED = 9, + MLX5_CQ_STATE_ALWAYS_ARMED = 0xb, + MLX5_CQ_STATE_FIRED = 0xa, +}; + +enum { + MLX5_STAT_RATE_OFFSET = 5, +}; + +enum { + MLX5_INLINE_SEG = 0x80000000, +}; + +enum { + MLX5_PERM_LOCAL_READ = 1 << 2, + MLX5_PERM_LOCAL_WRITE = 1 << 3, + MLX5_PERM_REMOTE_READ = 1 << 4, + MLX5_PERM_REMOTE_WRITE = 1 << 5, + MLX5_PERM_ATOMIC = 1 << 6, + MLX5_PERM_UMR_EN = 1 << 7, +}; + +enum { + MLX5_PCIE_CTRL_SMALL_FENCE = 1 << 0, + MLX5_PCIE_CTRL_RELAXED_ORDERING = 1 << 2, + MLX5_PCIE_CTRL_NO_SNOOP = 1 << 3, + MLX5_PCIE_CTRL_TLP_PROCE_EN = 1 << 6, + MLX5_PCIE_CTRL_TPH_MASK = 3 << 4, +}; + +enum { + MLX5_ACCESS_MODE_PA = 0, + MLX5_ACCESS_MODE_MTT = 1, + MLX5_ACCESS_MODE_KLM = 2 +}; + +enum { + MLX5_MKEY_REMOTE_INVAL = 1 << 24, + MLX5_MKEY_FLAG_SYNC_UMR = 1 << 29, + MLX5_MKEY_BSF_EN = 1 << 30, + MLX5_MKEY_LEN64 = 1 << 31, +}; + +enum { + MLX5_EN_RD = (u64)1, + MLX5_EN_WR = (u64)2 +}; + +enum { + MLX5_BF_REGS_PER_PAGE = 4, + MLX5_MAX_UAR_PAGES = 1 << 8, + MLX5_MAX_UUARS = MLX5_MAX_UAR_PAGES * MLX5_BF_REGS_PER_PAGE, +}; + +enum { + MLX5_MKEY_MASK_LEN = 1ull << 0, + MLX5_MKEY_MASK_PAGE_SIZE = 1ull << 1, + MLX5_MKEY_MASK_START_ADDR = 1ull << 6, + MLX5_MKEY_MASK_PD = 1ull << 7, + MLX5_MKEY_MASK_EN_RINVAL = 1ull << 8, + MLX5_MKEY_MASK_BSF_EN = 1ull << 12, + MLX5_MKEY_MASK_KEY = 1ull << 13, + MLX5_MKEY_MASK_QPN = 1ull << 14, + MLX5_MKEY_MASK_LR = 1ull << 17, + MLX5_MKEY_MASK_LW = 1ull << 18, + MLX5_MKEY_MASK_RR = 1ull << 19, + MLX5_MKEY_MASK_RW = 1ull << 20, + MLX5_MKEY_MASK_A = 1ull << 21, + MLX5_MKEY_MASK_SMALL_FENCE = 1ull << 23, + MLX5_MKEY_MASK_FREE = 1ull << 29, +}; + +enum mlx5_event { + MLX5_EVENT_TYPE_COMP = 0x0, + + MLX5_EVENT_TYPE_PATH_MIG = 0x01, + MLX5_EVENT_TYPE_COMM_EST = 0x02, + MLX5_EVENT_TYPE_SQ_DRAINED = 0x03, + MLX5_EVENT_TYPE_SRQ_LAST_WQE = 0x13, + MLX5_EVENT_TYPE_SRQ_RQ_LIMIT = 0x14, + + MLX5_EVENT_TYPE_CQ_ERROR = 0x04, + MLX5_EVENT_TYPE_WQ_CATAS_ERROR = 0x05, + MLX5_EVENT_TYPE_PATH_MIG_FAILED = 0x07, + MLX5_EVENT_TYPE_WQ_INVAL_REQ_ERROR = 0x10, + MLX5_EVENT_TYPE_WQ_ACCESS_ERROR = 0x11, + MLX5_EVENT_TYPE_SRQ_CATAS_ERROR = 0x12, + + MLX5_EVENT_TYPE_INTERNAL_ERROR = 0x08, + MLX5_EVENT_TYPE_PORT_CHANGE = 0x09, + MLX5_EVENT_TYPE_GPIO_EVENT = 0x15, + MLX5_EVENT_TYPE_REMOTE_CONFIG = 0x19, + + MLX5_EVENT_TYPE_DB_BF_CONGESTION = 0x1a, + MLX5_EVENT_TYPE_STALL_EVENT = 0x1b, + + MLX5_EVENT_TYPE_CMD = 0x0a, + MLX5_EVENT_TYPE_PAGE_REQUEST = 0xb, +}; + +enum { + MLX5_PORT_CHANGE_SUBTYPE_DOWN = 1, + MLX5_PORT_CHANGE_SUBTYPE_ACTIVE = 4, + MLX5_PORT_CHANGE_SUBTYPE_INITIALIZED = 5, + MLX5_PORT_CHANGE_SUBTYPE_LID = 6, + MLX5_PORT_CHANGE_SUBTYPE_PKEY = 7, + MLX5_PORT_CHANGE_SUBTYPE_GUID = 8, + MLX5_PORT_CHANGE_SUBTYPE_CLIENT_REREG = 9, +}; + +enum { + MLX5_DEV_CAP_FLAG_RC = 1LL << 0, + MLX5_DEV_CAP_FLAG_UC = 1LL << 1, + MLX5_DEV_CAP_FLAG_UD = 1LL << 2, + MLX5_DEV_CAP_FLAG_XRC = 1LL << 3, + MLX5_DEV_CAP_FLAG_SRQ = 1LL << 6, + MLX5_DEV_CAP_FLAG_BAD_PKEY_CNTR = 1LL << 8, + MLX5_DEV_CAP_FLAG_BAD_QKEY_CNTR = 1LL << 9, + MLX5_DEV_CAP_FLAG_APM = 1LL << 17, + MLX5_DEV_CAP_FLAG_ATOMIC = 1LL << 18, + MLX5_DEV_CAP_FLAG_ON_DMND_PG = 1LL << 24, + MLX5_DEV_CAP_FLAG_RESIZE_SRQ = 1LL << 32, + MLX5_DEV_CAP_FLAG_REMOTE_FENCE = 1LL << 38, + MLX5_DEV_CAP_FLAG_TLP_HINTS = 1LL << 39, + MLX5_DEV_CAP_FLAG_SIG_HAND_OVER = 1LL << 40, + MLX5_DEV_CAP_FLAG_DCT = 1LL << 41, + MLX5_DEV_CAP_FLAG_CMDIF_CSUM = 1LL << 46, +}; + +enum { + MLX5_OPCODE_NOP = 0x00, + MLX5_OPCODE_SEND_INVAL = 0x01, + MLX5_OPCODE_RDMA_WRITE = 0x08, + MLX5_OPCODE_RDMA_WRITE_IMM = 0x09, + MLX5_OPCODE_SEND = 0x0a, + MLX5_OPCODE_SEND_IMM = 0x0b, + MLX5_OPCODE_RDMA_READ = 0x10, + MLX5_OPCODE_ATOMIC_CS = 0x11, + MLX5_OPCODE_ATOMIC_FA = 0x12, + MLX5_OPCODE_ATOMIC_MASKED_CS = 0x14, + MLX5_OPCODE_ATOMIC_MASKED_FA = 0x15, + MLX5_OPCODE_BIND_MW = 0x18, + MLX5_OPCODE_CONFIG_CMD = 0x1f, + + MLX5_RECV_OPCODE_RDMA_WRITE_IMM = 0x00, + MLX5_RECV_OPCODE_SEND = 0x01, + MLX5_RECV_OPCODE_SEND_IMM = 0x02, + MLX5_RECV_OPCODE_SEND_INVAL = 0x03, + + MLX5_CQE_OPCODE_ERROR = 0x1e, + MLX5_CQE_OPCODE_RESIZE = 0x16, + + MLX5_OPCODE_SET_PSV = 0x20, + MLX5_OPCODE_GET_PSV = 0x21, + MLX5_OPCODE_CHECK_PSV = 0x22, + MLX5_OPCODE_RGET_PSV = 0x26, + MLX5_OPCODE_RCHECK_PSV = 0x27, + + MLX5_OPCODE_UMR = 0x25, + +}; + +enum { + MLX5_SET_PORT_RESET_QKEY = 0, + MLX5_SET_PORT_GUID0 = 16, + MLX5_SET_PORT_NODE_GUID = 17, + MLX5_SET_PORT_SYS_GUID = 18, + MLX5_SET_PORT_GID_TABLE = 19, + MLX5_SET_PORT_PKEY_TABLE = 20, +}; + +enum { + MLX5_MAX_PAGE_SHIFT = 31 +}; + +struct mlx5_inbox_hdr { + __be16 opcode; + u8 rsvd[4]; + __be16 opmod; +}; + +struct mlx5_outbox_hdr { + u8 status; + u8 rsvd[3]; + __be32 syndrome; +}; + +struct mlx5_cmd_query_adapter_mbox_in { + struct mlx5_inbox_hdr hdr; + u8 rsvd[8]; +}; + +struct mlx5_cmd_query_adapter_mbox_out { + struct mlx5_outbox_hdr hdr; + u8 rsvd0[24]; + u8 intapin; + u8 rsvd1[13]; + __be16 vsd_vendor_id; + u8 vsd[208]; + u8 vsd_psid[16]; +}; + +struct mlx5_hca_cap { + u8 rsvd1[16]; + u8 log_max_srq_sz; + u8 log_max_qp_sz; + u8 rsvd2; + u8 log_max_qp; + u8 log_max_strq_sz; + u8 log_max_srqs; + u8 rsvd4[2]; + u8 rsvd5; + u8 log_max_cq_sz; + u8 rsvd6; + u8 log_max_cq; + u8 log_max_eq_sz; + u8 log_max_mkey; + u8 rsvd7; + u8 log_max_eq; + u8 max_indirection; + u8 log_max_mrw_sz; + u8 log_max_bsf_list_sz; + u8 log_max_klm_list_sz; + u8 rsvd_8_0; + u8 log_max_ra_req_dc; + u8 rsvd_8_1; + u8 log_max_ra_res_dc; + u8 rsvd9; + u8 log_max_ra_req_qp; + u8 rsvd10; + u8 log_max_ra_res_qp; + u8 rsvd11[4]; + __be16 max_qp_count; + __be16 rsvd12; + u8 rsvd13; + u8 local_ca_ack_delay; + u8 rsvd14; + u8 num_ports; + u8 log_max_msg; + u8 rsvd15[3]; + __be16 stat_rate_support; + u8 rsvd16[2]; + __be64 flags; + u8 rsvd17; + u8 uar_sz; + u8 rsvd18; + u8 log_pg_sz; + __be16 bf_log_bf_reg_size; + u8 rsvd19[4]; + __be16 max_desc_sz_sq; + u8 rsvd20[2]; + __be16 max_desc_sz_rq; + u8 rsvd21[2]; + __be16 max_desc_sz_sq_dc; + u8 rsvd22[4]; + __be16 max_qp_mcg; + u8 rsvd23; + u8 log_max_mcg; + u8 rsvd24; + u8 log_max_pd; + u8 rsvd25; + u8 log_max_xrcd; + u8 rsvd26[40]; + __be32 uar_page_sz; + u8 rsvd27[28]; + u8 log_msx_atomic_size_qp; + u8 rsvd28[2]; + u8 log_msx_atomic_size_dc; + u8 rsvd29[76]; +}; + + +struct mlx5_cmd_query_hca_cap_mbox_in { + struct mlx5_inbox_hdr hdr; + u8 rsvd[8]; +}; + + +struct mlx5_cmd_query_hca_cap_mbox_out { + struct mlx5_outbox_hdr hdr; + u8 rsvd0[8]; + struct mlx5_hca_cap hca_cap; +}; + + +struct mlx5_cmd_set_hca_cap_mbox_in { + struct mlx5_inbox_hdr hdr; + u8 rsvd[8]; + struct mlx5_hca_cap hca_cap; +}; + + +struct mlx5_cmd_set_hca_cap_mbox_out { + struct mlx5_outbox_hdr hdr; + u8 rsvd0[8]; +}; + + +struct mlx5_cmd_init_hca_mbox_in { + struct mlx5_inbox_hdr hdr; + u8 rsvd0[2]; + __be16 profile; + u8 rsvd1[4]; +}; + +struct mlx5_cmd_init_hca_mbox_out { + struct mlx5_outbox_hdr hdr; + u8 rsvd[8]; +}; + +struct mlx5_cmd_teardown_hca_mbox_in { + struct mlx5_inbox_hdr hdr; + u8 rsvd0[2]; + __be16 profile; + u8 rsvd1[4]; +}; + +struct mlx5_cmd_teardown_hca_mbox_out { + struct mlx5_outbox_hdr hdr; + u8 rsvd[8]; +}; + +struct mlx5_cmd_layout { + u8 type; + u8 rsvd0[3]; + __be32 inlen; + __be64 in_ptr; + __be32 in[4]; + __be32 out[4]; + __be64 out_ptr; + __be32 outlen; + u8 token; + u8 sig; + u8 rsvd1; + u8 status_own; +}; + + +struct health_buffer { + __be32 assert_var[5]; + __be32 rsvd0[3]; + __be32 assert_exit_ptr; + __be32 assert_callra; + __be32 rsvd1[2]; + __be32 fw_ver; + __be32 hw_id; + __be32 rsvd2; + u8 irisc_index; + u8 synd; + __be16 ext_sync; +}; + +struct mlx5_init_seg { + __be32 fw_rev; + __be32 cmdif_rev_fw_sub; + __be32 rsvd0[2]; + __be32 cmdq_addr_h; + __be32 cmdq_addr_l_sz; + __be32 cmd_dbell; + __be32 rsvd1[121]; + struct health_buffer health; + __be32 rsvd2[884]; + __be32 health_counter; + __be32 rsvd3[1023]; + __be64 ieee1588_clk; + __be32 ieee1588_clk_type; + __be32 clr_intx; +}; + +struct mlx5_eqe_comp { + __be32 reserved[6]; + __be32 cqn; +}; + +struct mlx5_eqe_qp_srq { + __be32 reserved[6]; + __be32 qp_srq_n; +}; + +struct mlx5_eqe_cq_err { + __be32 cqn; + u8 reserved1[7]; + u8 syndrome; +}; + +struct mlx5_eqe_dropped_packet { +}; + +struct mlx5_eqe_port_state { + u8 reserved0[8]; + u8 port; +}; + +struct mlx5_eqe_gpio { + __be32 reserved0[2]; + __be64 gpio_event; +}; + +struct mlx5_eqe_congestion { + u8 type; + u8 rsvd0; + u8 congestion_level; +}; + +struct mlx5_eqe_stall_vl { + u8 rsvd0[3]; + u8 port_vl; +}; + +struct mlx5_eqe_cmd { + __be32 vector; + __be32 rsvd[6]; +}; + +struct mlx5_eqe_page_req { + u8 rsvd0[2]; + __be16 func_id; + u8 rsvd1[2]; + __be16 num_pages; + __be32 rsvd2[5]; +}; + +union ev_data { + __be32 raw[7]; + struct mlx5_eqe_cmd cmd; + struct mlx5_eqe_comp comp; + struct mlx5_eqe_qp_srq qp_srq; + struct mlx5_eqe_cq_err cq_err; + struct mlx5_eqe_dropped_packet dp; + struct mlx5_eqe_port_state port; + struct mlx5_eqe_gpio gpio; + struct mlx5_eqe_congestion cong; + struct mlx5_eqe_stall_vl stall_vl; + struct mlx5_eqe_page_req req_pages; +} __packed; + +struct mlx5_eqe { + u8 rsvd0; + u8 type; + u8 rsvd1; + u8 sub_type; + __be32 rsvd2[7]; + union ev_data data; + __be16 rsvd3; + u8 signature; + u8 owner; +} __packed; + +struct mlx5_cmd_prot_block { + u8 data[MLX5_CMD_DATA_BLOCK_SIZE]; + u8 rsvd0[48]; + __be64 next; + __be32 block_num; + u8 rsvd1; + u8 token; + u8 ctrl_sig; + u8 sig; +}; + +struct mlx5_err_cqe { + u8 rsvd0[32]; + __be32 srqn; + u8 rsvd1[18]; + u8 vendor_err_synd; + u8 syndrome; + __be32 s_wqe_opcode_qpn; + __be16 wqe_counter; + u8 signature; + u8 op_own; +}; + +struct mlx5_cqe64 { + u8 rsvd0[17]; + u8 ml_path; + u8 rsvd20[4]; + __be16 slid; + __be32 flags_rqpn; + u8 rsvd28[4]; + __be32 srqn; + __be32 imm_inval_pkey; + u8 rsvd40[4]; + __be32 byte_cnt; + __be64 timestamp; + __be32 sop_drop_qpn; + __be16 wqe_counter; + u8 signature; + u8 op_own; +}; + +struct mlx5_wqe_srq_next_seg { + u8 rsvd0[2]; + __be16 next_wqe_index; + u8 signature; + u8 rsvd1[11]; +}; + +union mlx5_ext_cqe { + struct ib_grh grh; + u8 inl[64]; +}; + +struct mlx5_cqe128 { + union mlx5_ext_cqe inl_grh; + struct mlx5_cqe64 cqe64; +}; + +struct mlx5_srq_ctx { + u8 state_log_sz; + u8 rsvd0[3]; + __be32 flags_xrcd; + __be32 pgoff_cqn; + u8 rsvd1[4]; + u8 log_pg_sz; + u8 rsvd2[7]; + __be32 pd; + __be16 lwm; + __be16 wqe_cnt; + u8 rsvd3[8]; + __be64 db_record; +}; + +struct mlx5_create_srq_mbox_in { + struct mlx5_inbox_hdr hdr; + __be32 input_srqn; + u8 rsvd0[4]; + struct mlx5_srq_ctx ctx; + u8 rsvd1[208]; + __be64 pas[0]; +}; + +struct mlx5_create_srq_mbox_out { + struct mlx5_outbox_hdr hdr; + __be32 srqn; + u8 rsvd[4]; +}; + +struct mlx5_destroy_srq_mbox_in { + struct mlx5_inbox_hdr hdr; + __be32 srqn; + u8 rsvd[4]; +}; + +struct mlx5_destroy_srq_mbox_out { + struct mlx5_outbox_hdr hdr; + u8 rsvd[8]; +}; + +struct mlx5_query_srq_mbox_in { + struct mlx5_inbox_hdr hdr; + __be32 srqn; + u8 rsvd0[4]; +}; + +struct mlx5_query_srq_mbox_out { + struct mlx5_outbox_hdr hdr; + u8 rsvd0[8]; + struct mlx5_srq_ctx ctx; + u8 rsvd1[32]; + __be64 pas[0]; +}; + +struct mlx5_arm_srq_mbox_in { + struct mlx5_inbox_hdr hdr; + __be32 srqn; + __be16 rsvd; + __be16 lwm; +}; + +struct mlx5_arm_srq_mbox_out { + struct mlx5_outbox_hdr hdr; + u8 rsvd[8]; +}; + +struct mlx5_cq_context { + u8 status; + u8 cqe_sz_flags; + u8 st; + u8 rsvd3; + u8 rsvd4[6]; + __be16 page_offset; + __be32 log_sz_usr_page; + __be16 cq_period; + __be16 cq_max_count; + __be16 rsvd20; + __be16 c_eqn; + u8 log_pg_sz; + u8 rsvd25[7]; + __be32 last_notified_index; + __be32 solicit_producer_index; + __be32 consumer_counter; + __be32 producer_counter; + u8 rsvd48[8]; + __be64 db_record_addr; +}; + +struct mlx5_create_cq_mbox_in { + struct mlx5_inbox_hdr hdr; + __be32 input_cqn; + u8 rsvdx[4]; + struct mlx5_cq_context ctx; + u8 rsvd6[192]; + __be64 pas[0]; +}; + +struct mlx5_create_cq_mbox_out { + struct mlx5_outbox_hdr hdr; + __be32 cqn; + u8 rsvd0[4]; +}; + +struct mlx5_destroy_cq_mbox_in { + struct mlx5_inbox_hdr hdr; + __be32 cqn; + u8 rsvd0[4]; +}; + +struct mlx5_destroy_cq_mbox_out { + struct mlx5_outbox_hdr hdr; + u8 rsvd0[8]; +}; + +struct mlx5_query_cq_mbox_in { + struct mlx5_inbox_hdr hdr; + __be32 cqn; + u8 rsvd0[4]; +}; + +struct mlx5_query_cq_mbox_out { + struct mlx5_outbox_hdr hdr; + u8 rsvd0[8]; + struct mlx5_cq_context ctx; + u8 rsvd6[16]; + __be64 pas[0]; +}; + +struct mlx5_eq_context { + u8 status; + u8 ec_oi; + u8 st; + u8 rsvd2[7]; + __be16 page_pffset; + __be32 log_sz_usr_page; + u8 rsvd3[7]; + u8 intr; + u8 log_page_size; + u8 rsvd4[15]; + __be32 consumer_counter; + __be32 produser_counter; + u8 rsvd5[16]; +}; + +struct mlx5_create_eq_mbox_in { + struct mlx5_inbox_hdr hdr; + u8 rsvd0[3]; + u8 input_eqn; + u8 rsvd1[4]; + struct mlx5_eq_context ctx; + u8 rsvd2[8]; + __be64 events_mask; + u8 rsvd3[176]; + __be64 pas[0]; +}; + +struct mlx5_create_eq_mbox_out { + struct mlx5_outbox_hdr hdr; + u8 rsvd0[3]; + u8 eq_number; + u8 rsvd1[4]; +}; + +struct mlx5_destroy_eq_mbox_in { + struct mlx5_inbox_hdr hdr; + u8 rsvd0[3]; + u8 eqn; + u8 rsvd1[4]; +}; + +struct mlx5_destroy_eq_mbox_out { + struct mlx5_outbox_hdr hdr; + u8 rsvd[8]; +}; + +struct mlx5_map_eq_mbox_in { + struct mlx5_inbox_hdr hdr; + __be64 mask; + u8 mu; + u8 rsvd0[2]; + u8 eqn; + u8 rsvd1[24]; +}; + +struct mlx5_map_eq_mbox_out { + struct mlx5_outbox_hdr hdr; + u8 rsvd[8]; +}; + +struct mlx5_query_eq_mbox_in { + struct mlx5_inbox_hdr hdr; + u8 rsvd0[3]; + u8 eqn; + u8 rsvd1[4]; +}; + +struct mlx5_query_eq_mbox_out { + struct mlx5_outbox_hdr hdr; + u8 rsvd[8]; + struct mlx5_eq_context ctx; +}; + +struct mlx5_mkey_seg { + /* This is a two bit field occupying bits 31-30. + * bit 31 is always 0, + * bit 30 is zero for regular MRs and 1 (e.g free) for UMRs that do not have tanslation + */ + u8 status; + u8 pcie_control; + u8 flags; + u8 version; + __be32 qpn_mkey7_0; + u8 rsvd1[4]; + __be32 flags_pd; + __be64 start_addr; + __be64 len; + __be32 bsfs_octo_size; + u8 rsvd2[16]; + __be32 xlt_oct_size; + u8 rsvd3[3]; + u8 log2_page_size; + u8 rsvd4[4]; +}; + +struct mlx5_query_special_ctxs_mbox_in { + struct mlx5_inbox_hdr hdr; + u8 rsvd[8]; +}; + +struct mlx5_query_special_ctxs_mbox_out { + struct mlx5_outbox_hdr hdr; + __be32 dump_fill_mkey; + __be32 reserved_lkey; +}; + +struct mlx5_create_mkey_mbox_in { + struct mlx5_inbox_hdr hdr; + __be32 input_mkey_index; + u8 rsvd0[4]; + struct mlx5_mkey_seg seg; + u8 rsvd1[16]; + __be32 xlat_oct_act_size; + __be32 bsf_coto_act_size; + u8 rsvd2[168]; + __be64 pas[0]; +}; + +struct mlx5_create_mkey_mbox_out { + struct mlx5_outbox_hdr hdr; + __be32 mkey; + u8 rsvd[4]; +}; + +struct mlx5_destroy_mkey_mbox_in { + struct mlx5_inbox_hdr hdr; + __be32 mkey; + u8 rsvd[4]; +}; + +struct mlx5_destroy_mkey_mbox_out { + struct mlx5_outbox_hdr hdr; + u8 rsvd[8]; +}; + +struct mlx5_query_mkey_mbox_in { + struct mlx5_inbox_hdr hdr; + __be32 mkey; +}; + +struct mlx5_query_mkey_mbox_out { + struct mlx5_outbox_hdr hdr; + __be64 pas[0]; +}; + +struct mlx5_modify_mkey_mbox_in { + struct mlx5_inbox_hdr hdr; + __be32 mkey; + __be64 pas[0]; +}; + +struct mlx5_modify_mkey_mbox_out { + struct mlx5_outbox_hdr hdr; +}; + +struct mlx5_dump_mkey_mbox_in { + struct mlx5_inbox_hdr hdr; +}; + +struct mlx5_dump_mkey_mbox_out { + struct mlx5_outbox_hdr hdr; + __be32 mkey; +}; + +struct mlx5_mad_ifc_mbox_in { + struct mlx5_inbox_hdr hdr; + __be16 remote_lid; + u8 rsvd0; + u8 port; + u8 rsvd1[4]; + u8 data[256]; +}; + +struct mlx5_mad_ifc_mbox_out { + struct mlx5_outbox_hdr hdr; + u8 rsvd[8]; + u8 data[256]; +}; + +struct mlx5_access_reg_mbox_in { + struct mlx5_inbox_hdr hdr; + u8 rsvd0[2]; + __be16 register_id; + __be32 arg; + __be32 data[0]; +}; + +struct mlx5_access_reg_mbox_out { + struct mlx5_outbox_hdr hdr; + u8 rsvd[8]; + __be32 data[0]; +}; + +#define MLX5_ATTR_EXTENDED_PORT_INFO cpu_to_be16(0xff90) + +enum { + MLX_EXT_PORT_CAP_FLAG_EXTENDED_PORT_INFO = 1 << 0 +}; + +#endif /* MLX5_DEVICE_H */ diff --git a/include/linux/mlx5/doorbell.h b/include/linux/mlx5/doorbell.h new file mode 100644 index 000000000000..163a818411e7 --- /dev/null +++ b/include/linux/mlx5/doorbell.h @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2013, Mellanox Technologies inc. All rights reserved. + * + * This software is available to you under a choice of one of two + * licenses. You may choose to be licensed under the terms of the GNU + * General Public License (GPL) Version 2, available from the file + * COPYING in the main directory of this source tree, or the + * OpenIB.org BSD license below: + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#ifndef MLX5_DOORBELL_H +#define MLX5_DOORBELL_H + +#define MLX5_BF_OFFSET 0x800 +#define MLX5_CQ_DOORBELL 0x20 + +#if BITS_PER_LONG == 64 +/* Assume that we can just write a 64-bit doorbell atomically. s390 + * actually doesn't have writeq() but S/390 systems don't even have + * PCI so we won't worry about it. + */ + +#define MLX5_DECLARE_DOORBELL_LOCK(name) +#define MLX5_INIT_DOORBELL_LOCK(ptr) do { } while (0) +#define MLX5_GET_DOORBELL_LOCK(ptr) (NULL) + +static inline void mlx5_write64(__be32 val[2], void __iomem *dest, + spinlock_t *doorbell_lock) +{ + __raw_writeq(*(u64 *)val, dest); +} + +#else + +/* Just fall back to a spinlock to protect the doorbell if + * BITS_PER_LONG is 32 -- there's no portable way to do atomic 64-bit + * MMIO writes. + */ + +#define MLX5_DECLARE_DOORBELL_LOCK(name) spinlock_t name; +#define MLX5_INIT_DOORBELL_LOCK(ptr) spin_lock_init(ptr) +#define MLX5_GET_DOORBELL_LOCK(ptr) (ptr) + +static inline void mlx5_write64(__be32 val[2], void __iomem *dest, + spinlock_t *doorbell_lock) +{ + unsigned long flags; + + spin_lock_irqsave(doorbell_lock, flags); + __raw_writel((__force u32) val[0], dest); + __raw_writel((__force u32) val[1], dest + 4); + spin_unlock_irqrestore(doorbell_lock, flags); +} + +#endif + +#endif /* MLX5_DOORBELL_H */ diff --git a/include/linux/mlx5/driver.h b/include/linux/mlx5/driver.h new file mode 100644 index 000000000000..e47f1e4c9b03 --- /dev/null +++ b/include/linux/mlx5/driver.h @@ -0,0 +1,769 @@ +/* + * Copyright (c) 2013, Mellanox Technologies inc. All rights reserved. + * + * This software is available to you under a choice of one of two + * licenses. You may choose to be licensed under the terms of the GNU + * General Public License (GPL) Version 2, available from the file + * COPYING in the main directory of this source tree, or the + * OpenIB.org BSD license below: + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#ifndef MLX5_DRIVER_H +#define MLX5_DRIVER_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +enum { + MLX5_BOARD_ID_LEN = 64, + MLX5_MAX_NAME_LEN = 16, +}; + +enum { + /* one minute for the sake of bringup. Generally, commands must always + * complete and we may need to increase this timeout value + */ + MLX5_CMD_TIMEOUT_MSEC = 7200 * 1000, + MLX5_CMD_WQ_MAX_NAME = 32, +}; + +enum { + CMD_OWNER_SW = 0x0, + CMD_OWNER_HW = 0x1, + CMD_STATUS_SUCCESS = 0, +}; + +enum mlx5_sqp_t { + MLX5_SQP_SMI = 0, + MLX5_SQP_GSI = 1, + MLX5_SQP_IEEE_1588 = 2, + MLX5_SQP_SNIFFER = 3, + MLX5_SQP_SYNC_UMR = 4, +}; + +enum { + MLX5_MAX_PORTS = 2, +}; + +enum { + MLX5_EQ_VEC_PAGES = 0, + MLX5_EQ_VEC_CMD = 1, + MLX5_EQ_VEC_ASYNC = 2, + MLX5_EQ_VEC_COMP_BASE, +}; + +enum { + MLX5_MAX_EQ_NAME = 20 +}; + +enum { + MLX5_ATOMIC_MODE_IB_COMP = 1 << 16, + MLX5_ATOMIC_MODE_CX = 2 << 16, + MLX5_ATOMIC_MODE_8B = 3 << 16, + MLX5_ATOMIC_MODE_16B = 4 << 16, + MLX5_ATOMIC_MODE_32B = 5 << 16, + MLX5_ATOMIC_MODE_64B = 6 << 16, + MLX5_ATOMIC_MODE_128B = 7 << 16, + MLX5_ATOMIC_MODE_256B = 8 << 16, +}; + +enum { + MLX5_CMD_OP_QUERY_HCA_CAP = 0x100, + MLX5_CMD_OP_QUERY_ADAPTER = 0x101, + MLX5_CMD_OP_INIT_HCA = 0x102, + MLX5_CMD_OP_TEARDOWN_HCA = 0x103, + MLX5_CMD_OP_QUERY_PAGES = 0x107, + MLX5_CMD_OP_MANAGE_PAGES = 0x108, + MLX5_CMD_OP_SET_HCA_CAP = 0x109, + + MLX5_CMD_OP_CREATE_MKEY = 0x200, + MLX5_CMD_OP_QUERY_MKEY = 0x201, + MLX5_CMD_OP_DESTROY_MKEY = 0x202, + MLX5_CMD_OP_QUERY_SPECIAL_CONTEXTS = 0x203, + + MLX5_CMD_OP_CREATE_EQ = 0x301, + MLX5_CMD_OP_DESTROY_EQ = 0x302, + MLX5_CMD_OP_QUERY_EQ = 0x303, + + MLX5_CMD_OP_CREATE_CQ = 0x400, + MLX5_CMD_OP_DESTROY_CQ = 0x401, + MLX5_CMD_OP_QUERY_CQ = 0x402, + MLX5_CMD_OP_MODIFY_CQ = 0x403, + + MLX5_CMD_OP_CREATE_QP = 0x500, + MLX5_CMD_OP_DESTROY_QP = 0x501, + MLX5_CMD_OP_RST2INIT_QP = 0x502, + MLX5_CMD_OP_INIT2RTR_QP = 0x503, + MLX5_CMD_OP_RTR2RTS_QP = 0x504, + MLX5_CMD_OP_RTS2RTS_QP = 0x505, + MLX5_CMD_OP_SQERR2RTS_QP = 0x506, + MLX5_CMD_OP_2ERR_QP = 0x507, + MLX5_CMD_OP_RTS2SQD_QP = 0x508, + MLX5_CMD_OP_SQD2RTS_QP = 0x509, + MLX5_CMD_OP_2RST_QP = 0x50a, + MLX5_CMD_OP_QUERY_QP = 0x50b, + MLX5_CMD_OP_CONF_SQP = 0x50c, + MLX5_CMD_OP_MAD_IFC = 0x50d, + MLX5_CMD_OP_INIT2INIT_QP = 0x50e, + MLX5_CMD_OP_SUSPEND_QP = 0x50f, + MLX5_CMD_OP_UNSUSPEND_QP = 0x510, + MLX5_CMD_OP_SQD2SQD_QP = 0x511, + MLX5_CMD_OP_ALLOC_QP_COUNTER_SET = 0x512, + MLX5_CMD_OP_DEALLOC_QP_COUNTER_SET = 0x513, + MLX5_CMD_OP_QUERY_QP_COUNTER_SET = 0x514, + + MLX5_CMD_OP_CREATE_PSV = 0x600, + MLX5_CMD_OP_DESTROY_PSV = 0x601, + MLX5_CMD_OP_QUERY_PSV = 0x602, + MLX5_CMD_OP_QUERY_SIG_RULE_TABLE = 0x603, + MLX5_CMD_OP_QUERY_BLOCK_SIZE_TABLE = 0x604, + + MLX5_CMD_OP_CREATE_SRQ = 0x700, + MLX5_CMD_OP_DESTROY_SRQ = 0x701, + MLX5_CMD_OP_QUERY_SRQ = 0x702, + MLX5_CMD_OP_ARM_RQ = 0x703, + MLX5_CMD_OP_RESIZE_SRQ = 0x704, + + MLX5_CMD_OP_ALLOC_PD = 0x800, + MLX5_CMD_OP_DEALLOC_PD = 0x801, + MLX5_CMD_OP_ALLOC_UAR = 0x802, + MLX5_CMD_OP_DEALLOC_UAR = 0x803, + + MLX5_CMD_OP_ATTACH_TO_MCG = 0x806, + MLX5_CMD_OP_DETACH_FROM_MCG = 0x807, + + + MLX5_CMD_OP_ALLOC_XRCD = 0x80e, + MLX5_CMD_OP_DEALLOC_XRCD = 0x80f, + + MLX5_CMD_OP_ACCESS_REG = 0x805, + MLX5_CMD_OP_MAX = 0x810, +}; + +enum { + MLX5_REG_PCAP = 0x5001, + MLX5_REG_PMTU = 0x5003, + MLX5_REG_PTYS = 0x5004, + MLX5_REG_PAOS = 0x5006, + MLX5_REG_PMAOS = 0x5012, + MLX5_REG_PUDE = 0x5009, + MLX5_REG_PMPE = 0x5010, + MLX5_REG_PELC = 0x500e, + MLX5_REG_PMLP = 0, /* TBD */ + MLX5_REG_NODE_DESC = 0x6001, + MLX5_REG_HOST_ENDIANNESS = 0x7004, +}; + +enum dbg_rsc_type { + MLX5_DBG_RSC_QP, + MLX5_DBG_RSC_EQ, + MLX5_DBG_RSC_CQ, +}; + +struct mlx5_field_desc { + struct dentry *dent; + int i; +}; + +struct mlx5_rsc_debug { + struct mlx5_core_dev *dev; + void *object; + enum dbg_rsc_type type; + struct dentry *root; + struct mlx5_field_desc fields[0]; +}; + +enum mlx5_dev_event { + MLX5_DEV_EVENT_SYS_ERROR, + MLX5_DEV_EVENT_PORT_UP, + MLX5_DEV_EVENT_PORT_DOWN, + MLX5_DEV_EVENT_PORT_INITIALIZED, + MLX5_DEV_EVENT_LID_CHANGE, + MLX5_DEV_EVENT_PKEY_CHANGE, + MLX5_DEV_EVENT_GUID_CHANGE, + MLX5_DEV_EVENT_CLIENT_REREG, +}; + +struct mlx5_uuar_info { + struct mlx5_uar *uars; + int num_uars; + int num_low_latency_uuars; + unsigned long *bitmap; + unsigned int *count; + struct mlx5_bf *bfs; + + /* + * protect uuar allocation data structs + */ + struct mutex lock; +}; + +struct mlx5_bf { + void __iomem *reg; + void __iomem *regreg; + int buf_size; + struct mlx5_uar *uar; + unsigned long offset; + int need_lock; + /* protect blue flame buffer selection when needed + */ + spinlock_t lock; + + /* serialize 64 bit writes when done as two 32 bit accesses + */ + spinlock_t lock32; + int uuarn; +}; + +struct mlx5_cmd_first { + __be32 data[4]; +}; + +struct mlx5_cmd_msg { + struct list_head list; + struct cache_ent *cache; + u32 len; + struct mlx5_cmd_first first; + struct mlx5_cmd_mailbox *next; +}; + +struct mlx5_cmd_debug { + struct dentry *dbg_root; + struct dentry *dbg_in; + struct dentry *dbg_out; + struct dentry *dbg_outlen; + struct dentry *dbg_status; + struct dentry *dbg_run; + void *in_msg; + void *out_msg; + u8 status; + u16 inlen; + u16 outlen; +}; + +struct cache_ent { + /* protect block chain allocations + */ + spinlock_t lock; + struct list_head head; +}; + +struct cmd_msg_cache { + struct cache_ent large; + struct cache_ent med; + +}; + +struct mlx5_cmd_stats { + u64 sum; + u64 n; + struct dentry *root; + struct dentry *avg; + struct dentry *count; + /* protect command average calculations */ + spinlock_t lock; +}; + +struct mlx5_cmd { + void *cmd_buf; + dma_addr_t dma; + u16 cmdif_rev; + u8 log_sz; + u8 log_stride; + int max_reg_cmds; + int events; + u32 __iomem *vector; + + /* protect command queue allocations + */ + spinlock_t alloc_lock; + + /* protect token allocations + */ + spinlock_t token_lock; + u8 token; + unsigned long bitmask; + char wq_name[MLX5_CMD_WQ_MAX_NAME]; + struct workqueue_struct *wq; + struct semaphore sem; + struct semaphore pages_sem; + int mode; + struct mlx5_cmd_work_ent *ent_arr[MLX5_MAX_COMMANDS]; + struct pci_pool *pool; + struct mlx5_cmd_debug dbg; + struct cmd_msg_cache cache; + int checksum_disabled; + struct mlx5_cmd_stats stats[MLX5_CMD_OP_MAX]; +}; + +struct mlx5_port_caps { + int gid_table_len; + int pkey_table_len; +}; + +struct mlx5_caps { + u8 log_max_eq; + u8 log_max_cq; + u8 log_max_qp; + u8 log_max_mkey; + u8 log_max_pd; + u8 log_max_srq; + u32 max_cqes; + int max_wqes; + int max_sq_desc_sz; + int max_rq_desc_sz; + u64 flags; + u16 stat_rate_support; + int log_max_msg; + int num_ports; + int max_ra_res_qp; + int max_ra_req_qp; + int max_srq_wqes; + int bf_reg_size; + int bf_regs_per_page; + struct mlx5_port_caps port[MLX5_MAX_PORTS]; + u8 ext_port_cap[MLX5_MAX_PORTS]; + int max_vf; + u32 reserved_lkey; + u8 local_ca_ack_delay; + u8 log_max_mcg; + u16 max_qp_mcg; + int min_page_sz; +}; + +struct mlx5_cmd_mailbox { + void *buf; + dma_addr_t dma; + struct mlx5_cmd_mailbox *next; +}; + +struct mlx5_buf_list { + void *buf; + dma_addr_t map; +}; + +struct mlx5_buf { + struct mlx5_buf_list direct; + struct mlx5_buf_list *page_list; + int nbufs; + int npages; + int page_shift; + int size; +}; + +struct mlx5_eq { + struct mlx5_core_dev *dev; + __be32 __iomem *doorbell; + u32 cons_index; + struct mlx5_buf buf; + int size; + u8 irqn; + u8 eqn; + int nent; + u64 mask; + char name[MLX5_MAX_EQ_NAME]; + struct list_head list; + int index; + struct mlx5_rsc_debug *dbg; +}; + + +struct mlx5_core_mr { + u64 iova; + u64 size; + u32 key; + u32 pd; + u32 access; +}; + +struct mlx5_core_srq { + u32 srqn; + int max; + int max_gs; + int max_avail_gather; + int wqe_shift; + void (*event) (struct mlx5_core_srq *, enum mlx5_event); + + atomic_t refcount; + struct completion free; +}; + +struct mlx5_eq_table { + void __iomem *update_ci; + void __iomem *update_arm_ci; + struct list_head *comp_eq_head; + struct mlx5_eq pages_eq; + struct mlx5_eq async_eq; + struct mlx5_eq cmd_eq; + struct msix_entry *msix_arr; + int num_comp_vectors; + /* protect EQs list + */ + spinlock_t lock; +}; + +struct mlx5_uar { + u32 index; + struct list_head bf_list; + unsigned free_bf_bmap; + void __iomem *wc_map; + void __iomem *map; +}; + + +struct mlx5_core_health { + struct health_buffer __iomem *health; + __be32 __iomem *health_counter; + struct timer_list timer; + struct list_head list; + u32 prev; + int miss_counter; +}; + +struct mlx5_cq_table { + /* protect radix tree + */ + spinlock_t lock; + struct radix_tree_root tree; +}; + +struct mlx5_qp_table { + /* protect radix tree + */ + spinlock_t lock; + struct radix_tree_root tree; +}; + +struct mlx5_srq_table { + /* protect radix tree + */ + spinlock_t lock; + struct radix_tree_root tree; +}; + +struct mlx5_priv { + char name[MLX5_MAX_NAME_LEN]; + struct mlx5_eq_table eq_table; + struct mlx5_uuar_info uuari; + MLX5_DECLARE_DOORBELL_LOCK(cq_uar_lock); + + /* pages stuff */ + struct workqueue_struct *pg_wq; + struct rb_root page_root; + int fw_pages; + int reg_pages; + + struct mlx5_core_health health; + + struct mlx5_srq_table srq_table; + + /* start: qp staff */ + struct mlx5_qp_table qp_table; + struct dentry *qp_debugfs; + struct dentry *eq_debugfs; + struct dentry *cq_debugfs; + struct dentry *cmdif_debugfs; + /* end: qp staff */ + + /* start: cq staff */ + struct mlx5_cq_table cq_table; + /* end: cq staff */ + + /* start: alloc staff */ + struct mutex pgdir_mutex; + struct list_head pgdir_list; + /* end: alloc staff */ + struct dentry *dbg_root; + + /* protect mkey key part */ + spinlock_t mkey_lock; + u8 mkey_key; +}; + +struct mlx5_core_dev { + struct pci_dev *pdev; + u8 rev_id; + char board_id[MLX5_BOARD_ID_LEN]; + struct mlx5_cmd cmd; + struct mlx5_caps caps; + phys_addr_t iseg_base; + struct mlx5_init_seg __iomem *iseg; + void (*event) (struct mlx5_core_dev *dev, + enum mlx5_dev_event event, + void *data); + struct mlx5_priv priv; + struct mlx5_profile *profile; + atomic_t num_qps; +}; + +struct mlx5_db { + __be32 *db; + union { + struct mlx5_db_pgdir *pgdir; + struct mlx5_ib_user_db_page *user_page; + } u; + dma_addr_t dma; + int index; +}; + +enum { + MLX5_DB_PER_PAGE = PAGE_SIZE / L1_CACHE_BYTES, +}; + +enum { + MLX5_COMP_EQ_SIZE = 1024, +}; + +struct mlx5_db_pgdir { + struct list_head list; + DECLARE_BITMAP(bitmap, MLX5_DB_PER_PAGE); + __be32 *db_page; + dma_addr_t db_dma; +}; + +typedef void (*mlx5_cmd_cbk_t)(int status, void *context); + +struct mlx5_cmd_work_ent { + struct mlx5_cmd_msg *in; + struct mlx5_cmd_msg *out; + mlx5_cmd_cbk_t callback; + void *context; + int idx; + struct completion done; + struct mlx5_cmd *cmd; + struct work_struct work; + struct mlx5_cmd_layout *lay; + int ret; + int page_queue; + u8 status; + u8 token; + struct timespec ts1; + struct timespec ts2; +}; + +struct mlx5_pas { + u64 pa; + u8 log_sz; +}; + +static inline void *mlx5_buf_offset(struct mlx5_buf *buf, int offset) +{ + if (likely(BITS_PER_LONG == 64 || buf->nbufs == 1)) + return buf->direct.buf + offset; + else + return buf->page_list[offset >> PAGE_SHIFT].buf + + (offset & (PAGE_SIZE - 1)); +} + +extern struct workqueue_struct *mlx5_core_wq; + +#define STRUCT_FIELD(header, field) \ + .struct_offset_bytes = offsetof(struct ib_unpacked_ ## header, field), \ + .struct_size_bytes = sizeof((struct ib_unpacked_ ## header *)0)->field + +struct ib_field { + size_t struct_offset_bytes; + size_t struct_size_bytes; + int offset_bits; + int size_bits; +}; + +static inline struct mlx5_core_dev *pci2mlx5_core_dev(struct pci_dev *pdev) +{ + return pci_get_drvdata(pdev); +} + +extern struct dentry *mlx5_debugfs_root; + +static inline u16 fw_rev_maj(struct mlx5_core_dev *dev) +{ + return ioread32be(&dev->iseg->fw_rev) & 0xffff; +} + +static inline u16 fw_rev_min(struct mlx5_core_dev *dev) +{ + return ioread32be(&dev->iseg->fw_rev) >> 16; +} + +static inline u16 fw_rev_sub(struct mlx5_core_dev *dev) +{ + return ioread32be(&dev->iseg->cmdif_rev_fw_sub) & 0xffff; +} + +static inline u16 cmdif_rev(struct mlx5_core_dev *dev) +{ + return ioread32be(&dev->iseg->cmdif_rev_fw_sub) >> 16; +} + +static inline void *mlx5_vzalloc(unsigned long size) +{ + void *rtn; + + rtn = kzalloc(size, GFP_KERNEL | __GFP_NOWARN); + if (!rtn) + rtn = vzalloc(size); + return rtn; +} + +static inline void mlx5_vfree(const void *addr) +{ + if (addr && is_vmalloc_addr(addr)) + vfree(addr); + else + kfree(addr); +} + +int mlx5_dev_init(struct mlx5_core_dev *dev, struct pci_dev *pdev); +void mlx5_dev_cleanup(struct mlx5_core_dev *dev); +int mlx5_cmd_init(struct mlx5_core_dev *dev); +void mlx5_cmd_cleanup(struct mlx5_core_dev *dev); +void mlx5_cmd_use_events(struct mlx5_core_dev *dev); +void mlx5_cmd_use_polling(struct mlx5_core_dev *dev); +int mlx5_cmd_status_to_err(struct mlx5_outbox_hdr *hdr); +int mlx5_cmd_exec(struct mlx5_core_dev *dev, void *in, int in_size, void *out, + int out_size); +int mlx5_cmd_alloc_uar(struct mlx5_core_dev *dev, u32 *uarn); +int mlx5_cmd_free_uar(struct mlx5_core_dev *dev, u32 uarn); +int mlx5_alloc_uuars(struct mlx5_core_dev *dev, struct mlx5_uuar_info *uuari); +int mlx5_free_uuars(struct mlx5_core_dev *dev, struct mlx5_uuar_info *uuari); +void mlx5_health_cleanup(void); +void __init mlx5_health_init(void); +void mlx5_start_health_poll(struct mlx5_core_dev *dev); +void mlx5_stop_health_poll(struct mlx5_core_dev *dev); +int mlx5_buf_alloc(struct mlx5_core_dev *dev, int size, int max_direct, + struct mlx5_buf *buf); +void mlx5_buf_free(struct mlx5_core_dev *dev, struct mlx5_buf *buf); +struct mlx5_cmd_mailbox *mlx5_alloc_cmd_mailbox_chain(struct mlx5_core_dev *dev, + gfp_t flags, int npages); +void mlx5_free_cmd_mailbox_chain(struct mlx5_core_dev *dev, + struct mlx5_cmd_mailbox *head); +int mlx5_core_create_srq(struct mlx5_core_dev *dev, struct mlx5_core_srq *srq, + struct mlx5_create_srq_mbox_in *in, int inlen); +int mlx5_core_destroy_srq(struct mlx5_core_dev *dev, struct mlx5_core_srq *srq); +int mlx5_core_query_srq(struct mlx5_core_dev *dev, struct mlx5_core_srq *srq, + struct mlx5_query_srq_mbox_out *out); +int mlx5_core_arm_srq(struct mlx5_core_dev *dev, struct mlx5_core_srq *srq, + u16 lwm, int is_srq); +int mlx5_core_create_mkey(struct mlx5_core_dev *dev, struct mlx5_core_mr *mr, + struct mlx5_create_mkey_mbox_in *in, int inlen); +int mlx5_core_destroy_mkey(struct mlx5_core_dev *dev, struct mlx5_core_mr *mr); +int mlx5_core_query_mkey(struct mlx5_core_dev *dev, struct mlx5_core_mr *mr, + struct mlx5_query_mkey_mbox_out *out, int outlen); +int mlx5_core_dump_fill_mkey(struct mlx5_core_dev *dev, struct mlx5_core_mr *mr, + u32 *mkey); +int mlx5_core_alloc_pd(struct mlx5_core_dev *dev, u32 *pdn); +int mlx5_core_dealloc_pd(struct mlx5_core_dev *dev, u32 pdn); +int mlx5_core_mad_ifc(struct mlx5_core_dev *dev, void *inb, void *outb, + u16 opmod, int port); +void mlx5_pagealloc_init(struct mlx5_core_dev *dev); +void mlx5_pagealloc_cleanup(struct mlx5_core_dev *dev); +int mlx5_pagealloc_start(struct mlx5_core_dev *dev); +void mlx5_pagealloc_stop(struct mlx5_core_dev *dev); +void mlx5_core_req_pages_handler(struct mlx5_core_dev *dev, u16 func_id, + s16 npages); +int mlx5_satisfy_startup_pages(struct mlx5_core_dev *dev); +int mlx5_reclaim_startup_pages(struct mlx5_core_dev *dev); +void mlx5_register_debugfs(void); +void mlx5_unregister_debugfs(void); +int mlx5_eq_init(struct mlx5_core_dev *dev); +void mlx5_eq_cleanup(struct mlx5_core_dev *dev); +void mlx5_fill_page_array(struct mlx5_buf *buf, __be64 *pas); +void mlx5_cq_completion(struct mlx5_core_dev *dev, u32 cqn); +void mlx5_qp_event(struct mlx5_core_dev *dev, u32 qpn, int event_type); +void mlx5_srq_event(struct mlx5_core_dev *dev, u32 srqn, int event_type); +struct mlx5_core_srq *mlx5_core_get_srq(struct mlx5_core_dev *dev, u32 srqn); +void mlx5_cmd_comp_handler(struct mlx5_core_dev *dev, unsigned long vector); +void mlx5_cq_event(struct mlx5_core_dev *dev, u32 cqn, int event_type); +int mlx5_create_map_eq(struct mlx5_core_dev *dev, struct mlx5_eq *eq, u8 vecidx, + int nent, u64 mask, const char *name, struct mlx5_uar *uar); +int mlx5_destroy_unmap_eq(struct mlx5_core_dev *dev, struct mlx5_eq *eq); +int mlx5_start_eqs(struct mlx5_core_dev *dev); +int mlx5_stop_eqs(struct mlx5_core_dev *dev); +int mlx5_core_attach_mcg(struct mlx5_core_dev *dev, union ib_gid *mgid, u32 qpn); +int mlx5_core_detach_mcg(struct mlx5_core_dev *dev, union ib_gid *mgid, u32 qpn); + +int mlx5_qp_debugfs_init(struct mlx5_core_dev *dev); +void mlx5_qp_debugfs_cleanup(struct mlx5_core_dev *dev); +int mlx5_core_access_reg(struct mlx5_core_dev *dev, void *data_in, + int size_in, void *data_out, int size_out, + u16 reg_num, int arg, int write); +int mlx5_set_port_caps(struct mlx5_core_dev *dev, int port_num, u32 caps); + +int mlx5_debug_eq_add(struct mlx5_core_dev *dev, struct mlx5_eq *eq); +void mlx5_debug_eq_remove(struct mlx5_core_dev *dev, struct mlx5_eq *eq); +int mlx5_core_eq_query(struct mlx5_core_dev *dev, struct mlx5_eq *eq, + struct mlx5_query_eq_mbox_out *out, int outlen); +int mlx5_eq_debugfs_init(struct mlx5_core_dev *dev); +void mlx5_eq_debugfs_cleanup(struct mlx5_core_dev *dev); +int mlx5_cq_debugfs_init(struct mlx5_core_dev *dev); +void mlx5_cq_debugfs_cleanup(struct mlx5_core_dev *dev); +int mlx5_db_alloc(struct mlx5_core_dev *dev, struct mlx5_db *db); +void mlx5_db_free(struct mlx5_core_dev *dev, struct mlx5_db *db); + +typedef void (*health_handler_t)(struct pci_dev *pdev, void *buf, int size); +int mlx5_register_health_report_handler(health_handler_t handler); +void mlx5_unregister_health_report_handler(void); +const char *mlx5_command_str(int command); +int mlx5_cmdif_debugfs_init(struct mlx5_core_dev *dev); +void mlx5_cmdif_debugfs_cleanup(struct mlx5_core_dev *dev); + +static inline u32 mlx5_mkey_to_idx(u32 mkey) +{ + return mkey >> 8; +} + +static inline u32 mlx5_idx_to_mkey(u32 mkey_idx) +{ + return mkey_idx << 8; +} + +enum { + MLX5_PROF_MASK_QP_SIZE = (u64)1 << 0, + MLX5_PROF_MASK_CMDIF_CSUM = (u64)1 << 1, + MLX5_PROF_MASK_MR_CACHE = (u64)1 << 2, +}; + +enum { + MAX_MR_CACHE_ENTRIES = 16, +}; + +struct mlx5_profile { + u64 mask; + u32 log_max_qp; + int cmdif_csum; + struct { + int size; + int limit; + } mr_cache[MAX_MR_CACHE_ENTRIES]; +}; + +#endif /* MLX5_DRIVER_H */ diff --git a/include/linux/mlx5/qp.h b/include/linux/mlx5/qp.h new file mode 100644 index 000000000000..d9e3eacb3a7f --- /dev/null +++ b/include/linux/mlx5/qp.h @@ -0,0 +1,467 @@ +/* + * Copyright (c) 2013, Mellanox Technologies inc. All rights reserved. + * + * This software is available to you under a choice of one of two + * licenses. You may choose to be licensed under the terms of the GNU + * General Public License (GPL) Version 2, available from the file + * COPYING in the main directory of this source tree, or the + * OpenIB.org BSD license below: + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#ifndef MLX5_QP_H +#define MLX5_QP_H + +#include +#include + +#define MLX5_INVALID_LKEY 0x100 + +enum mlx5_qp_optpar { + MLX5_QP_OPTPAR_ALT_ADDR_PATH = 1 << 0, + MLX5_QP_OPTPAR_RRE = 1 << 1, + MLX5_QP_OPTPAR_RAE = 1 << 2, + MLX5_QP_OPTPAR_RWE = 1 << 3, + MLX5_QP_OPTPAR_PKEY_INDEX = 1 << 4, + MLX5_QP_OPTPAR_Q_KEY = 1 << 5, + MLX5_QP_OPTPAR_RNR_TIMEOUT = 1 << 6, + MLX5_QP_OPTPAR_PRIMARY_ADDR_PATH = 1 << 7, + MLX5_QP_OPTPAR_SRA_MAX = 1 << 8, + MLX5_QP_OPTPAR_RRA_MAX = 1 << 9, + MLX5_QP_OPTPAR_PM_STATE = 1 << 10, + MLX5_QP_OPTPAR_RETRY_COUNT = 1 << 12, + MLX5_QP_OPTPAR_RNR_RETRY = 1 << 13, + MLX5_QP_OPTPAR_ACK_TIMEOUT = 1 << 14, + MLX5_QP_OPTPAR_PRI_PORT = 1 << 16, + MLX5_QP_OPTPAR_SRQN = 1 << 18, + MLX5_QP_OPTPAR_CQN_RCV = 1 << 19, + MLX5_QP_OPTPAR_DC_HS = 1 << 20, + MLX5_QP_OPTPAR_DC_KEY = 1 << 21, +}; + +enum mlx5_qp_state { + MLX5_QP_STATE_RST = 0, + MLX5_QP_STATE_INIT = 1, + MLX5_QP_STATE_RTR = 2, + MLX5_QP_STATE_RTS = 3, + MLX5_QP_STATE_SQER = 4, + MLX5_QP_STATE_SQD = 5, + MLX5_QP_STATE_ERR = 6, + MLX5_QP_STATE_SQ_DRAINING = 7, + MLX5_QP_STATE_SUSPENDED = 9, + MLX5_QP_NUM_STATE +}; + +enum { + MLX5_QP_ST_RC = 0x0, + MLX5_QP_ST_UC = 0x1, + MLX5_QP_ST_UD = 0x2, + MLX5_QP_ST_XRC = 0x3, + MLX5_QP_ST_MLX = 0x4, + MLX5_QP_ST_DCI = 0x5, + MLX5_QP_ST_DCT = 0x6, + MLX5_QP_ST_QP0 = 0x7, + MLX5_QP_ST_QP1 = 0x8, + MLX5_QP_ST_RAW_ETHERTYPE = 0x9, + MLX5_QP_ST_RAW_IPV6 = 0xa, + MLX5_QP_ST_SNIFFER = 0xb, + MLX5_QP_ST_SYNC_UMR = 0xe, + MLX5_QP_ST_PTP_1588 = 0xd, + MLX5_QP_ST_REG_UMR = 0xc, + MLX5_QP_ST_MAX +}; + +enum { + MLX5_QP_PM_MIGRATED = 0x3, + MLX5_QP_PM_ARMED = 0x0, + MLX5_QP_PM_REARM = 0x1 +}; + +enum { + MLX5_NON_ZERO_RQ = 0 << 24, + MLX5_SRQ_RQ = 1 << 24, + MLX5_CRQ_RQ = 2 << 24, + MLX5_ZERO_LEN_RQ = 3 << 24 +}; + +enum { + /* params1 */ + MLX5_QP_BIT_SRE = 1 << 15, + MLX5_QP_BIT_SWE = 1 << 14, + MLX5_QP_BIT_SAE = 1 << 13, + /* params2 */ + MLX5_QP_BIT_RRE = 1 << 15, + MLX5_QP_BIT_RWE = 1 << 14, + MLX5_QP_BIT_RAE = 1 << 13, + MLX5_QP_BIT_RIC = 1 << 4, +}; + +enum { + MLX5_WQE_CTRL_CQ_UPDATE = 2 << 2, + MLX5_WQE_CTRL_SOLICITED = 1 << 1, +}; + +enum { + MLX5_SEND_WQE_BB = 64, +}; + +enum { + MLX5_WQE_FMR_PERM_LOCAL_READ = 1 << 27, + MLX5_WQE_FMR_PERM_LOCAL_WRITE = 1 << 28, + MLX5_WQE_FMR_PERM_REMOTE_READ = 1 << 29, + MLX5_WQE_FMR_PERM_REMOTE_WRITE = 1 << 30, + MLX5_WQE_FMR_PERM_ATOMIC = 1 << 31 +}; + +enum { + MLX5_FENCE_MODE_NONE = 0 << 5, + MLX5_FENCE_MODE_INITIATOR_SMALL = 1 << 5, + MLX5_FENCE_MODE_STRONG_ORDERING = 3 << 5, + MLX5_FENCE_MODE_SMALL_AND_FENCE = 4 << 5, +}; + +enum { + MLX5_QP_LAT_SENSITIVE = 1 << 28, + MLX5_QP_ENABLE_SIG = 1 << 31, +}; + +enum { + MLX5_RCV_DBR = 0, + MLX5_SND_DBR = 1, +}; + +struct mlx5_wqe_fmr_seg { + __be32 flags; + __be32 mem_key; + __be64 buf_list; + __be64 start_addr; + __be64 reg_len; + __be32 offset; + __be32 page_size; + u32 reserved[2]; +}; + +struct mlx5_wqe_ctrl_seg { + __be32 opmod_idx_opcode; + __be32 qpn_ds; + u8 signature; + u8 rsvd[2]; + u8 fm_ce_se; + __be32 imm; +}; + +struct mlx5_wqe_xrc_seg { + __be32 xrc_srqn; + u8 rsvd[12]; +}; + +struct mlx5_wqe_masked_atomic_seg { + __be64 swap_add; + __be64 compare; + __be64 swap_add_mask; + __be64 compare_mask; +}; + +struct mlx5_av { + union { + struct { + __be32 qkey; + __be32 reserved; + } qkey; + __be64 dc_key; + } key; + __be32 dqp_dct; + u8 stat_rate_sl; + u8 fl_mlid; + __be16 rlid; + u8 reserved0[10]; + u8 tclass; + u8 hop_limit; + __be32 grh_gid_fl; + u8 rgid[16]; +}; + +struct mlx5_wqe_datagram_seg { + struct mlx5_av av; +}; + +struct mlx5_wqe_raddr_seg { + __be64 raddr; + __be32 rkey; + u32 reserved; +}; + +struct mlx5_wqe_atomic_seg { + __be64 swap_add; + __be64 compare; +}; + +struct mlx5_wqe_data_seg { + __be32 byte_count; + __be32 lkey; + __be64 addr; +}; + +struct mlx5_wqe_umr_ctrl_seg { + u8 flags; + u8 rsvd0[3]; + __be16 klm_octowords; + __be16 bsf_octowords; + __be64 mkey_mask; + u8 rsvd1[32]; +}; + +struct mlx5_seg_set_psv { + __be32 psv_num; + __be16 syndrome; + __be16 status; + __be32 transient_sig; + __be32 ref_tag; +}; + +struct mlx5_seg_get_psv { + u8 rsvd[19]; + u8 num_psv; + __be32 l_key; + __be64 va; + __be32 psv_index[4]; +}; + +struct mlx5_seg_check_psv { + u8 rsvd0[2]; + __be16 err_coalescing_op; + u8 rsvd1[2]; + __be16 xport_err_op; + u8 rsvd2[2]; + __be16 xport_err_mask; + u8 rsvd3[7]; + u8 num_psv; + __be32 l_key; + __be64 va; + __be32 psv_index[4]; +}; + +struct mlx5_rwqe_sig { + u8 rsvd0[4]; + u8 signature; + u8 rsvd1[11]; +}; + +struct mlx5_wqe_signature_seg { + u8 rsvd0[4]; + u8 signature; + u8 rsvd1[11]; +}; + +struct mlx5_wqe_inline_seg { + __be32 byte_count; +}; + +struct mlx5_core_qp { + void (*event) (struct mlx5_core_qp *, int); + int qpn; + atomic_t refcount; + struct completion free; + struct mlx5_rsc_debug *dbg; + int pid; +}; + +struct mlx5_qp_path { + u8 fl; + u8 rsvd3; + u8 free_ar; + u8 pkey_index; + u8 rsvd0; + u8 grh_mlid; + __be16 rlid; + u8 ackto_lt; + u8 mgid_index; + u8 static_rate; + u8 hop_limit; + __be32 tclass_flowlabel; + u8 rgid[16]; + u8 rsvd1[4]; + u8 sl; + u8 port; + u8 rsvd2[6]; +}; + +struct mlx5_qp_context { + __be32 flags; + __be32 flags_pd; + u8 mtu_msgmax; + u8 rq_size_stride; + __be16 sq_crq_size; + __be32 qp_counter_set_usr_page; + __be32 wire_qpn; + __be32 log_pg_sz_remote_qpn; + struct mlx5_qp_path pri_path; + struct mlx5_qp_path alt_path; + __be32 params1; + u8 reserved2[4]; + __be32 next_send_psn; + __be32 cqn_send; + u8 reserved3[8]; + __be32 last_acked_psn; + __be32 ssn; + __be32 params2; + __be32 rnr_nextrecvpsn; + __be32 xrcd; + __be32 cqn_recv; + __be64 db_rec_addr; + __be32 qkey; + __be32 rq_type_srqn; + __be32 rmsn; + __be16 hw_sq_wqe_counter; + __be16 sw_sq_wqe_counter; + __be16 hw_rcyclic_byte_counter; + __be16 hw_rq_counter; + __be16 sw_rcyclic_byte_counter; + __be16 sw_rq_counter; + u8 rsvd0[5]; + u8 cgs; + u8 cs_req; + u8 cs_res; + __be64 dc_access_key; + u8 rsvd1[24]; +}; + +struct mlx5_create_qp_mbox_in { + struct mlx5_inbox_hdr hdr; + __be32 input_qpn; + u8 rsvd0[4]; + __be32 opt_param_mask; + u8 rsvd1[4]; + struct mlx5_qp_context ctx; + u8 rsvd3[16]; + __be64 pas[0]; +}; + +struct mlx5_create_qp_mbox_out { + struct mlx5_outbox_hdr hdr; + __be32 qpn; + u8 rsvd0[4]; +}; + +struct mlx5_destroy_qp_mbox_in { + struct mlx5_inbox_hdr hdr; + __be32 qpn; + u8 rsvd0[4]; +}; + +struct mlx5_destroy_qp_mbox_out { + struct mlx5_outbox_hdr hdr; + u8 rsvd0[8]; +}; + +struct mlx5_modify_qp_mbox_in { + struct mlx5_inbox_hdr hdr; + __be32 qpn; + u8 rsvd1[4]; + __be32 optparam; + u8 rsvd0[4]; + struct mlx5_qp_context ctx; +}; + +struct mlx5_modify_qp_mbox_out { + struct mlx5_outbox_hdr hdr; + u8 rsvd0[8]; +}; + +struct mlx5_query_qp_mbox_in { + struct mlx5_inbox_hdr hdr; + __be32 qpn; + u8 rsvd[4]; +}; + +struct mlx5_query_qp_mbox_out { + struct mlx5_outbox_hdr hdr; + u8 rsvd1[8]; + __be32 optparam; + u8 rsvd0[4]; + struct mlx5_qp_context ctx; + u8 rsvd2[16]; + __be64 pas[0]; +}; + +struct mlx5_conf_sqp_mbox_in { + struct mlx5_inbox_hdr hdr; + __be32 qpn; + u8 rsvd[3]; + u8 type; +}; + +struct mlx5_conf_sqp_mbox_out { + struct mlx5_outbox_hdr hdr; + u8 rsvd[8]; +}; + +struct mlx5_alloc_xrcd_mbox_in { + struct mlx5_inbox_hdr hdr; + u8 rsvd[8]; +}; + +struct mlx5_alloc_xrcd_mbox_out { + struct mlx5_outbox_hdr hdr; + __be32 xrcdn; + u8 rsvd[4]; +}; + +struct mlx5_dealloc_xrcd_mbox_in { + struct mlx5_inbox_hdr hdr; + __be32 xrcdn; + u8 rsvd[4]; +}; + +struct mlx5_dealloc_xrcd_mbox_out { + struct mlx5_outbox_hdr hdr; + u8 rsvd[8]; +}; + +static inline struct mlx5_core_qp *__mlx5_qp_lookup(struct mlx5_core_dev *dev, u32 qpn) +{ + return radix_tree_lookup(&dev->priv.qp_table.tree, qpn); +} + +int mlx5_core_create_qp(struct mlx5_core_dev *dev, + struct mlx5_core_qp *qp, + struct mlx5_create_qp_mbox_in *in, + int inlen); +int mlx5_core_qp_modify(struct mlx5_core_dev *dev, enum mlx5_qp_state cur_state, + enum mlx5_qp_state new_state, + struct mlx5_modify_qp_mbox_in *in, int sqd_event, + struct mlx5_core_qp *qp); +int mlx5_core_destroy_qp(struct mlx5_core_dev *dev, + struct mlx5_core_qp *qp); +int mlx5_core_qp_query(struct mlx5_core_dev *dev, struct mlx5_core_qp *qp, + struct mlx5_query_qp_mbox_out *out, int outlen); + +int mlx5_core_xrcd_alloc(struct mlx5_core_dev *dev, u32 *xrcdn); +int mlx5_core_xrcd_dealloc(struct mlx5_core_dev *dev, u32 xrcdn); +void mlx5_init_qp_table(struct mlx5_core_dev *dev); +void mlx5_cleanup_qp_table(struct mlx5_core_dev *dev); +int mlx5_debug_qp_add(struct mlx5_core_dev *dev, struct mlx5_core_qp *qp); +void mlx5_debug_qp_remove(struct mlx5_core_dev *dev, struct mlx5_core_qp *qp); + +#endif /* MLX5_QP_H */ diff --git a/include/linux/mlx5/srq.h b/include/linux/mlx5/srq.h new file mode 100644 index 000000000000..e1a363a33663 --- /dev/null +++ b/include/linux/mlx5/srq.h @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2013, Mellanox Technologies inc. All rights reserved. + * + * This software is available to you under a choice of one of two + * licenses. You may choose to be licensed under the terms of the GNU + * General Public License (GPL) Version 2, available from the file + * COPYING in the main directory of this source tree, or the + * OpenIB.org BSD license below: + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#ifndef MLX5_SRQ_H +#define MLX5_SRQ_H + +#include + +void mlx5_init_srq_table(struct mlx5_core_dev *dev); +void mlx5_cleanup_srq_table(struct mlx5_core_dev *dev); + +#endif /* MLX5_SRQ_H */ From 63884c90ffa3f73a81b81f169c51c34d2b9cf75e Mon Sep 17 00:00:00 2001 From: Roland Dreier Date: Mon, 1 Jul 2013 14:15:17 -0700 Subject: [PATCH 0662/1048] mlx5: Fix parameter type of health_handler_t This deals with the sparse warning: drivers/net/ethernet/mellanox/mlx5/core/health.c:94:54: warning: incorrect type in argument 2 (different address spaces) drivers/net/ethernet/mellanox/mlx5/core/health.c:94:54: expected void *buf drivers/net/ethernet/mellanox/mlx5/core/health.c:94:54: got struct health_buffer [noderef] *health Signed-off-by: Roland Dreier --- include/linux/mlx5/driver.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/mlx5/driver.h b/include/linux/mlx5/driver.h index e47f1e4c9b03..f22e4419839b 100644 --- a/include/linux/mlx5/driver.h +++ b/include/linux/mlx5/driver.h @@ -729,7 +729,7 @@ void mlx5_cq_debugfs_cleanup(struct mlx5_core_dev *dev); int mlx5_db_alloc(struct mlx5_core_dev *dev, struct mlx5_db *db); void mlx5_db_free(struct mlx5_core_dev *dev, struct mlx5_db *db); -typedef void (*health_handler_t)(struct pci_dev *pdev, void *buf, int size); +typedef void (*health_handler_t)(struct pci_dev *pdev, struct health_buffer __iomem *buf, int size); int mlx5_register_health_report_handler(health_handler_t handler); void mlx5_unregister_health_report_handler(void); const char *mlx5_command_str(int command); From ad32b95f8281ac5a292da83ff27616aceee4b770 Mon Sep 17 00:00:00 2001 From: Roland Dreier Date: Mon, 8 Jul 2013 00:13:35 -0700 Subject: [PATCH 0663/1048] IB/mlx5: Make profile[] static in main.c Signed-off-by: Roland Dreier --- drivers/infiniband/hw/mlx5/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/infiniband/hw/mlx5/main.c b/drivers/infiniband/hw/mlx5/main.c index 6b1007f9bc29..8000fff4d444 100644 --- a/drivers/infiniband/hw/mlx5/main.c +++ b/drivers/infiniband/hw/mlx5/main.c @@ -62,7 +62,7 @@ static char mlx5_version[] = DRIVER_NAME ": Mellanox Connect-IB Infiniband driver v" DRIVER_VERSION " (" DRIVER_RELDATE ")\n"; -struct mlx5_profile profile[] = { +static struct mlx5_profile profile[] = { [0] = { .mask = 0, }, From 582c016e68dc5dfea4d3582512157f165a428149 Mon Sep 17 00:00:00 2001 From: Roland Dreier Date: Mon, 8 Jul 2013 10:52:28 -0700 Subject: [PATCH 0664/1048] mlx5_core: Fixes for sparse warnings - use be32_to_cpu() instead of cpu_to_be32() where appropriate. - use proper accessors for pointers marked __iomem. Signed-off-by: Roland Dreier --- .../net/ethernet/mellanox/mlx5/core/debugfs.c | 4 +-- .../net/ethernet/mellanox/mlx5/core/health.c | 26 +++++++++++++------ 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/debugfs.c b/drivers/net/ethernet/mellanox/mlx5/core/debugfs.c index 5e9cf2b9aaf7..a550a8ef94a1 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/debugfs.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/debugfs.c @@ -323,11 +323,11 @@ static u64 qp_read_field(struct mlx5_core_dev *dev, struct mlx5_core_qp *qp, param = 0; break; case QP_LOG_PG_SZ: - param = ((cpu_to_be32(ctx->log_pg_sz_remote_qpn) >> 24) & 0x1f); + param = (be32_to_cpu(ctx->log_pg_sz_remote_qpn) >> 24) & 0x1f; param += 12; break; case QP_RQPN: - param = cpu_to_be32(ctx->log_pg_sz_remote_qpn) & 0xffffff; + param = be32_to_cpu(ctx->log_pg_sz_remote_qpn) & 0xffffff; break; } diff --git a/drivers/net/ethernet/mellanox/mlx5/core/health.c b/drivers/net/ethernet/mellanox/mlx5/core/health.c index ea4b9bca6d4a..748f10a155c4 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/health.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/health.c @@ -132,6 +132,16 @@ static const char *hsynd_str(u8 synd) } } +static u16 read_be16(__be16 __iomem *p) +{ + return swab16(readl((__force u16 __iomem *) p)); +} + +static u32 read_be32(__be32 __iomem *p) +{ + return swab32(readl((__force u32 __iomem *) p)); +} + static void print_health_info(struct mlx5_core_dev *dev) { struct mlx5_core_health *health = &dev->priv.health; @@ -139,15 +149,15 @@ static void print_health_info(struct mlx5_core_dev *dev) int i; for (i = 0; i < ARRAY_SIZE(h->assert_var); i++) - pr_info("assert_var[%d] 0x%08x\n", i, be32_to_cpu(h->assert_var[i])); + pr_info("assert_var[%d] 0x%08x\n", i, read_be32(h->assert_var + i)); - pr_info("assert_exit_ptr 0x%08x\n", be32_to_cpu(h->assert_exit_ptr)); - pr_info("assert_callra 0x%08x\n", be32_to_cpu(h->assert_callra)); - pr_info("fw_ver 0x%08x\n", be32_to_cpu(h->fw_ver)); - pr_info("hw_id 0x%08x\n", be32_to_cpu(h->hw_id)); - pr_info("irisc_index %d\n", h->irisc_index); - pr_info("synd 0x%x: %s\n", h->synd, hsynd_str(h->synd)); - pr_info("ext_sync 0x%04x\n", be16_to_cpu(h->ext_sync)); + pr_info("assert_exit_ptr 0x%08x\n", read_be32(&h->assert_exit_ptr)); + pr_info("assert_callra 0x%08x\n", read_be32(&h->assert_callra)); + pr_info("fw_ver 0x%08x\n", read_be32(&h->fw_ver)); + pr_info("hw_id 0x%08x\n", read_be32(&h->hw_id)); + pr_info("irisc_index %d\n", readb(&h->irisc_index)); + pr_info("synd 0x%x: %s\n", readb(&h->synd), hsynd_str(readb(&h->synd))); + pr_info("ext_sync 0x%04x\n", read_be16(&h->ext_sync)); } static void poll_health(unsigned long data) From da183c7af8444cb2c1beedaa498a9359f19ff665 Mon Sep 17 00:00:00 2001 From: Roland Dreier Date: Mon, 8 Jul 2013 11:15:45 -0700 Subject: [PATCH 0665/1048] IB/uverbs: Use get_unused_fd_flags(O_CLOEXEC) instead of get_unused_fd() The macro get_unused_fd() is used to allocate a file descriptor with default flags. Those default flags (0) can be "unsafe": O_CLOEXEC must be used by default to not leak file descriptor across exec(). Replace calls to get_unused_fd() in uverbs with calls to get_unused_fd_flags(O_CLOEXEC). Inheriting uverbs fds across exec() cannot be used to do anything useful. Based on a patch/suggestion from Yann Droneaud . Signed-off-by: Roland Dreier --- drivers/infiniband/core/uverbs_cmd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c index a7d00f6b3bc1..b3c07b0c9f26 100644 --- a/drivers/infiniband/core/uverbs_cmd.c +++ b/drivers/infiniband/core/uverbs_cmd.c @@ -334,7 +334,7 @@ ssize_t ib_uverbs_get_context(struct ib_uverbs_file *file, resp.num_comp_vectors = file->device->num_comp_vectors; - ret = get_unused_fd(); + ret = get_unused_fd_flags(O_CLOEXEC); if (ret < 0) goto err_free; resp.async_fd = ret; @@ -1184,7 +1184,7 @@ ssize_t ib_uverbs_create_comp_channel(struct ib_uverbs_file *file, if (copy_from_user(&cmd, buf, sizeof cmd)) return -EFAULT; - ret = get_unused_fd(); + ret = get_unused_fd_flags(O_CLOEXEC); if (ret < 0) return ret; resp.fd = ret; From 5125bc22e7871b46e71312d6cc4455e9eea1619d Mon Sep 17 00:00:00 2001 From: Robert Richter Date: Fri, 3 May 2013 15:49:53 +0200 Subject: [PATCH 0666/1048] tools: Get only verbose output with V=1 Fix having verbose build with V=0, e.g: make V=0 -C tools/ perf Signed-off-by: Robert Richter Link: http://lkml.kernel.org/r/20130503134953.GU8356@rric.localhost Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/Documentation/Makefile | 2 +- tools/perf/config/utilities.mak | 2 +- tools/scripts/Makefile.include | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/perf/Documentation/Makefile b/tools/perf/Documentation/Makefile index eb30044a922a..f75175757892 100644 --- a/tools/perf/Documentation/Makefile +++ b/tools/perf/Documentation/Makefile @@ -150,7 +150,7 @@ NO_SUBDIR = : endif ifneq ($(findstring $(MAKEFLAGS),s),s) -ifndef V +ifneq ($(V),1) QUIET_ASCIIDOC = @echo ' ' ASCIIDOC $@; QUIET_XMLTO = @echo ' ' XMLTO $@; QUIET_DB2TEXI = @echo ' ' DB2TEXI $@; diff --git a/tools/perf/config/utilities.mak b/tools/perf/config/utilities.mak index 8ef3bd30a549..faffb52fcf80 100644 --- a/tools/perf/config/utilities.mak +++ b/tools/perf/config/utilities.mak @@ -181,7 +181,7 @@ _gea_err = $(if $(1),$(error Please set '$(1)' appropriately)) # try-cc # Usage: option = $(call try-cc, source-to-build, cc-options, msg) -ifndef V +ifneq ($(V),1) TRY_CC_OUTPUT= > /dev/null 2>&1 endif TRY_CC_MSG=echo " CHK $(3)" 1>&2; diff --git a/tools/scripts/Makefile.include b/tools/scripts/Makefile.include index f03e681f8891..0d0506d55c71 100644 --- a/tools/scripts/Makefile.include +++ b/tools/scripts/Makefile.include @@ -59,7 +59,7 @@ QUIET_SUBDIR0 = +$(MAKE) $(COMMAND_O) -C # space to separate -C and subdir QUIET_SUBDIR1 = ifneq ($(findstring $(MAKEFLAGS),s),s) -ifndef V +ifneq ($(V),1) QUIET_CC = @echo ' ' CC $@; QUIET_AR = @echo ' ' AR $@; QUIET_LINK = @echo ' ' LINK $@; From 761a0f395d5d8b7aafe563ecefbc8cf71a214a91 Mon Sep 17 00:00:00 2001 From: Robert Richter Date: Mon, 6 May 2013 20:40:14 +0200 Subject: [PATCH 0667/1048] perf tools: Fix output directory of Documentation/ The OUTPUT directory is wrongly determind leading to: make[3]: *** No rule to make target `.../.build/perf/PERF-VERSION-FILE'. Stop. Fixing this by using the generic approach in script/Makefile.include. Signed-off-by: Robert Richter Link: http://lkml.kernel.org/r/1367865614-30876-1-git-send-email-rric@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/Documentation/Makefile | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/tools/perf/Documentation/Makefile b/tools/perf/Documentation/Makefile index f75175757892..5a37a7c84e69 100644 --- a/tools/perf/Documentation/Makefile +++ b/tools/perf/Documentation/Makefile @@ -1,12 +1,6 @@ +include ../../scripts/Makefile.include include ../config/utilities.mak -OUTPUT := ./ -ifeq ("$(origin O)", "command line") - ifneq ($(O),) - OUTPUT := $(O)/ - endif -endif - MAN1_TXT= \ $(filter-out $(addsuffix .txt, $(ARTICLES) $(SP_ARTICLES)), \ $(wildcard perf-*.txt)) \ @@ -277,7 +271,7 @@ $(MAN_HTML): $(OUTPUT)%.html : %.txt $(OUTPUT)%.1 $(OUTPUT)%.5 $(OUTPUT)%.7 : $(OUTPUT)%.xml $(QUIET_XMLTO)$(RM) $@ && \ - $(XMLTO) -o $(OUTPUT) -m $(MANPAGE_XSL) $(XMLTO_EXTRA) man $< + $(XMLTO) -o $(OUTPUT). -m $(MANPAGE_XSL) $(XMLTO_EXTRA) man $< $(OUTPUT)%.xml : %.txt $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \ From 107de3724eff5a6fa6474a4d2aa5460b63749ebf Mon Sep 17 00:00:00 2001 From: Robert Richter Date: Tue, 11 Jun 2013 17:22:38 +0200 Subject: [PATCH 0668/1048] perf tools: Fix build errors with O and DESTDIR make vars set Fixing build errors with O and DESTDIR make vars set: $ make prefix=/usr/local O=$builddir DESTDIR=$destdir -C tools/ perf ... make[1]: Entering directory `.../.source/perf/tools/perf' CC .../.build/perf/perf/util/parse-events.o util/parse-events.c:14:32: fatal error: parse-events-bison.h: No such file or directory compilation terminated. make[1]: *** [.../.build/perf/perf/util/parse-events.o] Error 1 ... and: LINK /.../.build/perf/perf/perf gcc: error: /.../.build/perf/perf//.../.source/perf/tools/lib/lk/liblk.a: No such file or directory Signed-off-by: Robert Richter Signed-off-by: Robert Richter Cc: Ingo Molnar Cc: Jiri Olsa Cc: Robert Richter Link: http://lkml.kernel.org/r/1370964158-4135-1-git-send-email-rric@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/Makefile | 5 ++--- tools/perf/config/Makefile | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/tools/perf/Makefile b/tools/perf/Makefile index 203cb0eecff2..641fccddb249 100644 --- a/tools/perf/Makefile +++ b/tools/perf/Makefile @@ -121,17 +121,16 @@ SCRIPT_SH += perf-archive.sh grep-libs = $(filter -l%,$(1)) strip-libs = $(filter-out -l%,$(1)) -LK_PATH=$(LK_DIR) - ifneq ($(OUTPUT),) TE_PATH=$(OUTPUT) ifneq ($(subdir),) - LK_PATH=$(OUTPUT)$(LK_DIR) + LK_PATH=$(objtree)/lib/lk/ else LK_PATH=$(OUTPUT) endif else TE_PATH=$(TRACE_EVENT_DIR) + LK_PATH=$(LK_DIR) endif LIBTRACEEVENT = $(TE_PATH)libtraceevent.a diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile index f139dcd2796e..f4468954d3dc 100644 --- a/tools/perf/config/Makefile +++ b/tools/perf/config/Makefile @@ -39,7 +39,7 @@ src-perf := $(srctree)/tools/perf endif ifeq ($(obj-perf),) -obj-perf := $(objtree) +obj-perf := $(OUTPUT) endif ifneq ($(obj-perf),) From 13966721a11f4a2ba8038191e48083b5f31822bb Mon Sep 17 00:00:00 2001 From: "Kirill A. Shutemov" Date: Thu, 6 Jun 2013 14:35:03 +0300 Subject: [PATCH 0669/1048] perf bench: Fix memory allocation fail check in mem{set,cpy} workloads Addresses of allocated memory areas saved to '*src' and '*dst', so we need to check them for NULL, not 'src' and 'dst'. Signed-off-by: Kirill A. Shutemov Acked-by: Hitoshi Mitake Cc: Hitoshi Mitake Cc: Ingo Molnar Cc: Paul Mackerras Cc: Peter Zijlstra Link: http://lkml.kernel.org/r/1370518503-4230-1-git-send-email-kirill.shutemov@linux.intel.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/bench/mem-memcpy.c | 4 ++-- tools/perf/bench/mem-memset.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/perf/bench/mem-memcpy.c b/tools/perf/bench/mem-memcpy.c index 93c83e3cb4a7..25fd3f1966f1 100644 --- a/tools/perf/bench/mem-memcpy.c +++ b/tools/perf/bench/mem-memcpy.c @@ -111,11 +111,11 @@ static double timeval2double(struct timeval *ts) static void alloc_mem(void **dst, void **src, size_t length) { *dst = zalloc(length); - if (!dst) + if (!*dst) die("memory allocation failed - maybe length is too large?\n"); *src = zalloc(length); - if (!src) + if (!*src) die("memory allocation failed - maybe length is too large?\n"); } diff --git a/tools/perf/bench/mem-memset.c b/tools/perf/bench/mem-memset.c index c6e4bc523492..4a2f12081964 100644 --- a/tools/perf/bench/mem-memset.c +++ b/tools/perf/bench/mem-memset.c @@ -111,7 +111,7 @@ static double timeval2double(struct timeval *ts) static void alloc_mem(void **dst, size_t length) { *dst = zalloc(length); - if (!dst) + if (!*dst) die("memory allocation failed - maybe length is too large?\n"); } From 756bbc84e30b57ca1010b550ea30594fd0b0494f Mon Sep 17 00:00:00 2001 From: Joonsoo Kim Date: Wed, 19 Jun 2013 10:02:30 +0900 Subject: [PATCH 0670/1048] perf tools: Include termios.h explicitly Building perf for android fails because it can't find the definition of struct winsize. This definition is in termios.h, so I add this header to util.h to solve the problem. It is missed by commit '2c803e52' which moves get_term_dimensions() from builtin-top.c to util.c, but missed to move termios.h header. Signed-off-by: Joonsoo Kim Acked-by: David Ahern Cc: David Ahern Cc: Ingo Molnar Cc: Namhyung Kim Cc: Paul Mackerras Cc: Peter Zijlstra Link: http://lkml.kernel.org/r/1371603750-15053-3-git-send-email-iamjoonsoo.kim@lge.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/util.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h index 7a484c97e500..2732fad03908 100644 --- a/tools/perf/util/util.h +++ b/tools/perf/util/util.h @@ -72,6 +72,7 @@ #include "types.h" #include #include +#include extern const char *graph_line; extern const char *graph_dotted_line; @@ -274,6 +275,5 @@ void dump_stack(void); extern unsigned int page_size; -struct winsize; void get_term_dimensions(struct winsize *ws); #endif /* GIT_COMPAT_UTIL_H */ From 079787f209416416383c74ea5d5044be2d586f5e Mon Sep 17 00:00:00 2001 From: Joonsoo Kim Date: Wed, 19 Jun 2013 10:02:29 +0900 Subject: [PATCH 0671/1048] tools lib lk: Fix for cross build Currently, lib lk doesn't use CROSS_COMPILE environment variable, so cross build always fails. This is a quick fix for this problem. Signed-off-by: Joonsoo Kim Cc: Ingo Molnar Cc: Namhyung Kim Cc: Paul Mackerras Cc: Peter Zijlstra Link: http://lkml.kernel.org/r/1371603750-15053-2-git-send-email-iamjoonsoo.kim@lge.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/lib/lk/Makefile | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tools/lib/lk/Makefile b/tools/lib/lk/Makefile index 2c5a19733357..f0ecc0a13300 100644 --- a/tools/lib/lk/Makefile +++ b/tools/lib/lk/Makefile @@ -3,6 +3,21 @@ include ../../scripts/Makefile.include CC = $(CROSS_COMPILE)gcc AR = $(CROSS_COMPILE)ar +# Makefiles suck: This macro sets a default value of $(2) for the +# variable named by $(1), unless the variable has been set by +# environment or command line. This is necessary for CC and AR +# because make sets default values, so the simpler ?= approach +# won't work as expected. +define allow-override + $(if $(or $(findstring environment,$(origin $(1))),\ + $(findstring command line,$(origin $(1)))),,\ + $(eval $(1) = $(2))) +endef + +# Allow setting CC and AR, or setting CROSS_COMPILE as a prefix. +$(call allow-override,CC,$(CROSS_COMPILE)gcc) +$(call allow-override,AR,$(CROSS_COMPILE)ar) + # guard against environment variables LIB_H= LIB_OBJS= From d07f0b120642f442d81a61f68a9325fb7717004f Mon Sep 17 00:00:00 2001 From: Stephane Eranian Date: Tue, 4 Jun 2013 17:44:26 +0200 Subject: [PATCH 0672/1048] perf stat: Avoid sending SIGTERM to random processes This patch fixes a problem with perf stat whereby on termination it may send a SIGTERM signal to random processes on systems with high PID recycling. I got some actual bug reports on this. There is race between the SIGCHLD and sig_atexit() handlers. This patch addresses this problem by clearing child_pid in the SIGCHLD handler. Signed-off-by: Stephane Eranian Cc: Ingo Molnar Cc: Jiri Olsa Cc: Namhyung Kim Cc: Peter Zijlstra Link: http://lkml.kernel.org/r/20130604154426.GA2928@quad Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/builtin-stat.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index 7e910bab1097..95768afaae3e 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c @@ -87,7 +87,7 @@ static int run_count = 1; static bool no_inherit = false; static bool scale = true; static enum aggr_mode aggr_mode = AGGR_GLOBAL; -static pid_t child_pid = -1; +static volatile pid_t child_pid = -1; static bool null_run = false; static int detailed_run = 0; static bool big_num = true; @@ -1148,13 +1148,34 @@ static void skip_signal(int signo) done = 1; signr = signo; + /* + * render child_pid harmless + * won't send SIGTERM to a random + * process in case of race condition + * and fast PID recycling + */ + child_pid = -1; } static void sig_atexit(void) { + sigset_t set, oset; + + /* + * avoid race condition with SIGCHLD handler + * in skip_signal() which is modifying child_pid + * goal is to avoid send SIGTERM to a random + * process + */ + sigemptyset(&set); + sigaddset(&set, SIGCHLD); + sigprocmask(SIG_BLOCK, &set, &oset); + if (child_pid != -1) kill(child_pid, SIGTERM); + sigprocmask(SIG_SETMASK, &oset, NULL); + if (signr == -1) return; From 563aecb2e63a16f86c7daabfdcfee23f3e7c5955 Mon Sep 17 00:00:00 2001 From: Jiri Olsa Date: Wed, 5 Jun 2013 13:35:06 +0200 Subject: [PATCH 0673/1048] perf record: Remove -A/--append option It's no longer working and needed. Quite straightforward discussion/vote was in here: http://marc.info/?t=137028288300004&r=1&w=2 Signed-off-by: Jiri Olsa Cc: Andi Kleen Cc: Corey Ashford Cc: David Ahern Cc: Frederic Weisbecker Cc: Ingo Molnar Cc: Namhyung Kim Cc: Paul Mackerras Cc: Peter Zijlstra Link: http://lkml.kernel.org/n/tip-8fgdva12hl8w3xzzpsvvg7nx@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/Documentation/perf-record.txt | 4 +- tools/perf/builtin-record.c | 82 +++--------------------- tools/perf/util/header.c | 13 +--- 3 files changed, 11 insertions(+), 88 deletions(-) diff --git a/tools/perf/Documentation/perf-record.txt b/tools/perf/Documentation/perf-record.txt index d4da111ef53d..7e3258066bc9 100644 --- a/tools/perf/Documentation/perf-record.txt +++ b/tools/perf/Documentation/perf-record.txt @@ -65,12 +65,10 @@ OPTIONS -r:: --realtime=:: Collect data with this RT SCHED_FIFO priority. + -D:: --no-delay:: Collect data without buffering. --A:: ---append:: - Append to the output file to do incremental profiling. -f:: --force:: diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index fff985cf3852..2990570b5c6d 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c @@ -61,11 +61,6 @@ static void __handle_on_exit_funcs(void) } #endif -enum write_mode_t { - WRITE_FORCE, - WRITE_APPEND -}; - struct perf_record { struct perf_tool tool; struct perf_record_opts opts; @@ -77,12 +72,9 @@ struct perf_record { int output; unsigned int page_size; int realtime_prio; - enum write_mode_t write_mode; bool no_buildid; bool no_buildid_cache; bool force; - bool file_new; - bool append_file; long samples; off_t post_processing_offset; }; @@ -200,25 +192,6 @@ static void perf_record__sig_exit(int exit_status __maybe_unused, void *arg) signal(signr, SIG_DFL); } -static bool perf_evlist__equal(struct perf_evlist *evlist, - struct perf_evlist *other) -{ - struct perf_evsel *pos, *pair; - - if (evlist->nr_entries != other->nr_entries) - return false; - - pair = perf_evlist__first(other); - - list_for_each_entry(pos, &evlist->entries, node) { - if (memcmp(&pos->attr, &pair->attr, sizeof(pos->attr) != 0)) - return false; - pair = perf_evsel__next(pair); - } - - return true; -} - static int perf_record__open(struct perf_record *rec) { char msg[512]; @@ -273,16 +246,7 @@ try_again: goto out; } - if (rec->file_new) - session->evlist = evlist; - else { - if (!perf_evlist__equal(session->evlist, evlist)) { - fprintf(stderr, "incompatible append\n"); - rc = -1; - goto out; - } - } - + session->evlist = evlist; perf_session__set_id_hdr_size(session); out: return rc; @@ -415,23 +379,15 @@ static int __cmd_record(struct perf_record *rec, int argc, const char **argv) if (!strcmp(output_name, "-")) opts->pipe_output = true; else if (!stat(output_name, &st) && st.st_size) { - if (rec->write_mode == WRITE_FORCE) { - char oldname[PATH_MAX]; - snprintf(oldname, sizeof(oldname), "%s.old", - output_name); - unlink(oldname); - rename(output_name, oldname); - } - } else if (rec->write_mode == WRITE_APPEND) { - rec->write_mode = WRITE_FORCE; + char oldname[PATH_MAX]; + snprintf(oldname, sizeof(oldname), "%s.old", + output_name); + unlink(oldname); + rename(output_name, oldname); } } - flags = O_CREAT|O_RDWR; - if (rec->write_mode == WRITE_APPEND) - rec->file_new = 0; - else - flags |= O_TRUNC; + flags = O_CREAT|O_RDWR|O_TRUNC; if (opts->pipe_output) output = STDOUT_FILENO; @@ -445,7 +401,7 @@ static int __cmd_record(struct perf_record *rec, int argc, const char **argv) rec->output = output; session = perf_session__new(output_name, O_WRONLY, - rec->write_mode == WRITE_FORCE, false, NULL); + true, false, NULL); if (session == NULL) { pr_err("Not enough memory for reading perf file header\n"); return -1; @@ -465,12 +421,6 @@ static int __cmd_record(struct perf_record *rec, int argc, const char **argv) if (!rec->opts.branch_stack) perf_header__clear_feat(&session->header, HEADER_BRANCH_STACK); - if (!rec->file_new) { - err = perf_session__read_header(session, output); - if (err < 0) - goto out_delete_session; - } - if (forks) { err = perf_evlist__prepare_workload(evsel_list, &opts->target, argv, opts->pipe_output, @@ -498,7 +448,7 @@ static int __cmd_record(struct perf_record *rec, int argc, const char **argv) err = perf_header__write_pipe(output); if (err < 0) goto out_delete_session; - } else if (rec->file_new) { + } else { err = perf_session__write_header(session, evsel_list, output, false); if (err < 0) @@ -869,8 +819,6 @@ static struct perf_record record = { .uses_mmap = true, }, }, - .write_mode = WRITE_FORCE, - .file_new = true, }; #define CALLCHAIN_HELP "do call-graph (stack chain/backtrace) recording: " @@ -906,8 +854,6 @@ const struct option record_options[] = { "collect raw sample records from all opened counters"), OPT_BOOLEAN('a', "all-cpus", &record.opts.target.system_wide, "system-wide collection from all CPUs"), - OPT_BOOLEAN('A', "append", &record.append_file, - "append to the output file to do incremental profiling"), OPT_STRING('C', "cpu", &record.opts.target.cpu_list, "cpu", "list of cpus to monitor"), OPT_BOOLEAN('f', "force", &record.force, @@ -977,16 +923,6 @@ int cmd_record(int argc, const char **argv, const char *prefix __maybe_unused) if (!argc && perf_target__none(&rec->opts.target)) usage_with_options(record_usage, record_options); - if (rec->force && rec->append_file) { - ui__error("Can't overwrite and append at the same time." - " You need to choose between -f and -A"); - usage_with_options(record_usage, record_options); - } else if (rec->append_file) { - rec->write_mode = WRITE_APPEND; - } else { - rec->write_mode = WRITE_FORCE; - } - if (nr_cgroups && !rec->opts.target.system_wide) { ui__error("cgroup monitoring only available in" " system-wide mode\n"); diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c index 738d3b8d9745..93dd31573fb5 100644 --- a/tools/perf/util/header.c +++ b/tools/perf/util/header.c @@ -2303,29 +2303,18 @@ int perf_session__write_header(struct perf_session *session, struct perf_file_header f_header; struct perf_file_attr f_attr; struct perf_header *header = &session->header; - struct perf_evsel *evsel, *pair = NULL; + struct perf_evsel *evsel; int err; lseek(fd, sizeof(f_header), SEEK_SET); - if (session->evlist != evlist) - pair = perf_evlist__first(session->evlist); - list_for_each_entry(evsel, &evlist->entries, node) { evsel->id_offset = lseek(fd, 0, SEEK_CUR); err = do_write(fd, evsel->id, evsel->ids * sizeof(u64)); if (err < 0) { -out_err_write: pr_debug("failed to write perf header\n"); return err; } - if (session->evlist != evlist) { - err = do_write(fd, pair->id, pair->ids * sizeof(u64)); - if (err < 0) - goto out_err_write; - evsel->ids += pair->ids; - pair = perf_evsel__next(pair); - } } header->attr_offset = lseek(fd, 0, SEEK_CUR); From 4a4d371a4dfbd3b84a7eab8d535d4c7c3647b09e Mon Sep 17 00:00:00 2001 From: Jiri Olsa Date: Wed, 5 Jun 2013 13:37:21 +0200 Subject: [PATCH 0674/1048] perf record: Remove -f/--force option It no longer have any affect on the processing and is marked as obsolete anyway. Signed-off-by: Jiri Olsa Cc: Andi Kleen Cc: Corey Ashford Cc: David Ahern Cc: Frederic Weisbecker Cc: Ingo Molnar Cc: Namhyung Kim Cc: Paul Mackerras Cc: Peter Zijlstra Link: http://lkml.kernel.org/n/tip-tvwyspiqr4getzfib2lw06ty@git.kernel.org Link: http://lkml.kernel.org/r/1372307120-737-1-git-send-email-namhyung@kernel.org [ combined patch removing the -f usage in various sub-commands, such as 'perf sched', etc, by Namhyung Kim ] Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/Documentation/examples.txt | 4 ++-- tools/perf/Documentation/perf-record.txt | 4 ---- tools/perf/builtin-kmem.c | 2 +- tools/perf/builtin-lock.c | 2 +- tools/perf/builtin-record.c | 3 --- tools/perf/builtin-sched.c | 1 - tools/perf/builtin-timechart.c | 4 ++-- 7 files changed, 6 insertions(+), 14 deletions(-) diff --git a/tools/perf/Documentation/examples.txt b/tools/perf/Documentation/examples.txt index 77f952762426..a4e392156488 100644 --- a/tools/perf/Documentation/examples.txt +++ b/tools/perf/Documentation/examples.txt @@ -66,7 +66,7 @@ Furthermore, these tracepoints can be used to sample the workload as well. For example the page allocations done by a 'git gc' can be captured the following way: - titan:~/git> perf record -f -e kmem:mm_page_alloc -c 1 ./git gc + titan:~/git> perf record -e kmem:mm_page_alloc -c 1 ./git gc Counting objects: 1148, done. Delta compression using up to 2 threads. Compressing objects: 100% (450/450), done. @@ -120,7 +120,7 @@ Furthermore, call-graph sampling can be done too, of page allocations - to see precisely what kind of page allocations there are: - titan:~/git> perf record -f -g -e kmem:mm_page_alloc -c 1 ./git gc + titan:~/git> perf record -g -e kmem:mm_page_alloc -c 1 ./git gc Counting objects: 1148, done. Delta compression using up to 2 threads. Compressing objects: 100% (450/450), done. diff --git a/tools/perf/Documentation/perf-record.txt b/tools/perf/Documentation/perf-record.txt index 7e3258066bc9..e297b74471b8 100644 --- a/tools/perf/Documentation/perf-record.txt +++ b/tools/perf/Documentation/perf-record.txt @@ -70,10 +70,6 @@ OPTIONS --no-delay:: Collect data without buffering. --f:: ---force:: - Overwrite existing data file. (deprecated) - -c:: --count=:: Event period to sample. diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c index 46878daca5cc..0259502638b4 100644 --- a/tools/perf/builtin-kmem.c +++ b/tools/perf/builtin-kmem.c @@ -708,7 +708,7 @@ static int parse_line_opt(const struct option *opt __maybe_unused, static int __cmd_record(int argc, const char **argv) { const char * const record_args[] = { - "record", "-a", "-R", "-f", "-c", "1", + "record", "-a", "-R", "-c", "1", "-e", "kmem:kmalloc", "-e", "kmem:kmalloc_node", "-e", "kmem:kfree", diff --git a/tools/perf/builtin-lock.c b/tools/perf/builtin-lock.c index 425830069749..76543a4a7a30 100644 --- a/tools/perf/builtin-lock.c +++ b/tools/perf/builtin-lock.c @@ -878,7 +878,7 @@ static int __cmd_report(void) static int __cmd_record(int argc, const char **argv) { const char *record_args[] = { - "record", "-R", "-f", "-m", "1024", "-c", "1", + "record", "-R", "-m", "1024", "-c", "1", }; unsigned int rec_argc, i, j; const char **rec_argv; diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index 2990570b5c6d..ecca62e27b28 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c @@ -74,7 +74,6 @@ struct perf_record { int realtime_prio; bool no_buildid; bool no_buildid_cache; - bool force; long samples; off_t post_processing_offset; }; @@ -856,8 +855,6 @@ const struct option record_options[] = { "system-wide collection from all CPUs"), OPT_STRING('C', "cpu", &record.opts.target.cpu_list, "cpu", "list of cpus to monitor"), - OPT_BOOLEAN('f', "force", &record.force, - "overwrite existing data file (deprecated)"), OPT_U64('c', "count", &record.opts.user_interval, "event period to sample"), OPT_STRING('o', "output", &record.output_name, "file", "output file name"), diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c index 2da2a6ca22bf..fed9ae432c16 100644 --- a/tools/perf/builtin-sched.c +++ b/tools/perf/builtin-sched.c @@ -1632,7 +1632,6 @@ static int __cmd_record(int argc, const char **argv) "record", "-a", "-R", - "-f", "-m", "1024", "-c", "1", "-e", "sched:sched_switch", diff --git a/tools/perf/builtin-timechart.c b/tools/perf/builtin-timechart.c index ab4cf232b852..4536a92b18f3 100644 --- a/tools/perf/builtin-timechart.c +++ b/tools/perf/builtin-timechart.c @@ -1005,7 +1005,7 @@ static int __cmd_record(int argc, const char **argv) { #ifdef SUPPORT_OLD_POWER_EVENTS const char * const record_old_args[] = { - "record", "-a", "-R", "-f", "-c", "1", + "record", "-a", "-R", "-c", "1", "-e", "power:power_start", "-e", "power:power_end", "-e", "power:power_frequency", @@ -1014,7 +1014,7 @@ static int __cmd_record(int argc, const char **argv) }; #endif const char * const record_new_args[] = { - "record", "-a", "-R", "-f", "-c", "1", + "record", "-a", "-R", "-c", "1", "-e", "power:cpu_frequency", "-e", "power:cpu_idle", "-e", "sched:sched_wakeup", From bcf3145fbeb1bd91ad2ca67b1946077530f7bfb1 Mon Sep 17 00:00:00 2001 From: Namhyung Kim Date: Wed, 26 Jun 2013 16:14:15 +0900 Subject: [PATCH 0675/1048] perf evlist: Enhance perf_evlist__start_workload() When perf tries to start a workload, it relies on a pipe which the workload was blocked for reading. After closing the pipe on the parent, the workload (child) can start the actual work via exec(). However, if another process was forked after creating a workload, this mechanism cannot work since the other process (child) also inherits the pipe, so that closing the pipe in parent cannot unblock the workload. Fix it by using explicit write call can then closing it. For similar reason, the pipe fd on parent should be marked as CLOEXEC so that it can be closed after another child exec'ed. Signed-off-by: Namhyung Kim Cc: David Ahern Cc: Frederic Weisbecker Cc: Ingo Molnar Cc: Jiri Olsa Cc: Paul Mackerras Cc: Peter Zijlstra Cc: Stephane Eranian Cc: Steven Rostedt Link: http://lkml.kernel.org/r/1372230862-15861-13-git-send-email-namhyung@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/evlist.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index 99b43dd18c57..8065ce8fa9a5 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c @@ -821,6 +821,7 @@ int perf_evlist__prepare_workload(struct perf_evlist *evlist, goto out_close_pipes; } + fcntl(go_pipe[1], F_SETFD, FD_CLOEXEC); evlist->workload.cork_fd = go_pipe[1]; close(child_ready_pipe[0]); return 0; @@ -837,10 +838,17 @@ out_close_ready_pipe: int perf_evlist__start_workload(struct perf_evlist *evlist) { if (evlist->workload.cork_fd > 0) { + char bf; + int ret; /* * Remove the cork, let it rip! */ - return close(evlist->workload.cork_fd); + ret = write(evlist->workload.cork_fd, &bf, 1); + if (ret < 0) + perror("enable to write to pipe"); + + close(evlist->workload.cork_fd); + return ret; } return 0; From 0276c22a3f22b7f6696fa07b0a77635726b2c0fd Mon Sep 17 00:00:00 2001 From: Jiri Olsa Date: Mon, 10 Jun 2013 08:21:21 +0200 Subject: [PATCH 0676/1048] perf tools: Fix -x/--exclude-other option for report command Currently we have symbol_conf.exclude_other being set as true every time so the -x/--exclude-other has nothing to do. Also we have no way to see the data with symbol_conf.exclude_other being false which is useful sometimes. Fixing it by making symbol_conf.exclude_other false by default. 1) Example without -x option: $ perf report -i perf.data.delete -p perf_session__delete -s parent + 99.91% [other] + 0.08% perf_session__delete + 0.00% perf_session__delete_dead_threads + 0.00% perf_session__delete_threads 2) Example with -x option: $ ./perf report -i perf.data.delete -p perf_session__delete -s parent -x + 96.22% perf_session__delete + 1.89% perf_session__delete_dead_threads + 1.89% perf_session__delete_threads In Example 1) we get the sorted out data together with the rest "[other]". This could help us estimate how much time we spent in the sorted data. In Example 2) the total is just the sorted data. Signed-off-by: Jiri Olsa Cc: Andi Kleen Cc: Corey Ashford Cc: David Ahern Cc: Frederic Weisbecker Cc: Ingo Molnar Cc: Namhyung Kim Cc: Paul Mackerras Cc: Peter Zijlstra Link: http://lkml.kernel.org/n/tip-sg8fvu0fyqohf9ur9l38lhkw@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/builtin-diff.c | 1 - tools/perf/builtin-report.c | 3 +-- tools/perf/builtin-top.c | 2 -- tools/perf/util/symbol.c | 1 - 4 files changed, 1 insertion(+), 6 deletions(-) diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c index da8f8eb383a0..0aac5f3e594d 100644 --- a/tools/perf/builtin-diff.c +++ b/tools/perf/builtin-diff.c @@ -607,7 +607,6 @@ int cmd_diff(int argc, const char **argv, const char *prefix __maybe_unused) input_new = "perf.data.guest"; } - symbol_conf.exclude_other = false; if (symbol__init() < 0) return -1; diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index ca98d34cd58b..3662047cc6b1 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c @@ -939,8 +939,7 @@ repeat: */ if (!strstr(sort_order, "parent")) sort_parent.elide = 1; - } else - symbol_conf.exclude_other = false; + } if (argc) { /* diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index f036af9b6f09..e06c4f869330 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c @@ -1130,8 +1130,6 @@ int cmd_top(int argc, const char **argv, const char *prefix __maybe_unused) if (top.evlist == NULL) return -ENOMEM; - symbol_conf.exclude_other = false; - argc = parse_options(argc, argv, options, top_usage, 0); if (argc) usage_with_options(top_usage, options); diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c index 8cf3b5426a9a..d5528e1cc03a 100644 --- a/tools/perf/util/symbol.c +++ b/tools/perf/util/symbol.c @@ -32,7 +32,6 @@ int vmlinux_path__nr_entries; char **vmlinux_path; struct symbol_conf symbol_conf = { - .exclude_other = true, .use_modules = true, .try_vmlinux_path = true, .annotate_src = true, From 7e40c92019cef784fffbdfc51c6e731e7ee6ba10 Mon Sep 17 00:00:00 2001 From: Runzhen Wang Date: Fri, 28 Jun 2013 16:14:56 +0800 Subject: [PATCH 0677/1048] perf tools: fix a typo of a Power7 event name In the Power7 PMU guide: https://www.power.org/documentation/commonly-used-metrics-for-performance-analysis/ PM_BRU_MPRED is referred to as PM_BR_MPRED. It fixed the typo by changing the name of the event in kernel and documentation accordingly. This patch changes the ABI, there are some reasons I think it's ok: - It is relatively new interface, specific to the Power7 platform. - No tools that we know of actually use this interface at this point (none are listed near the interface). - Users of this interface (eg oprofile users migrating to perf) would be more used to the "PM_BR_MPRED" rather than "PM_BRU_MPRED". - These are in the ABI/testing at this point rather than ABI/stable, so hoping we have some wiggle room. Signed-off-by: Runzhen Wang Acked-by: Michael Ellerman Cc: icycoder@gmail.com Cc: linuxppc-dev@lists.ozlabs.org Cc: Michael Ellerman Cc: Paul Mackerras Cc: Runzhen Wang Cc: Sukadev Bhattiprolu Cc: Xiao Guangrong Link: http://lkml.kernel.org/r/1372407297-6996-2-git-send-email-runzhen@linux.vnet.ibm.com Signed-off-by: Arnaldo Carvalho de Melo --- .../testing/sysfs-bus-event_source-devices-events | 2 +- arch/powerpc/perf/power7-pmu.c | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Documentation/ABI/testing/sysfs-bus-event_source-devices-events b/Documentation/ABI/testing/sysfs-bus-event_source-devices-events index 8b25ffb42562..3c1cc24361bd 100644 --- a/Documentation/ABI/testing/sysfs-bus-event_source-devices-events +++ b/Documentation/ABI/testing/sysfs-bus-event_source-devices-events @@ -29,7 +29,7 @@ Description: Generic performance monitoring events What: /sys/devices/cpu/events/PM_1PLUS_PPC_CMPL /sys/devices/cpu/events/PM_BRU_FIN - /sys/devices/cpu/events/PM_BRU_MPRED + /sys/devices/cpu/events/PM_BR_MPRED /sys/devices/cpu/events/PM_CMPLU_STALL /sys/devices/cpu/events/PM_CMPLU_STALL_BRU /sys/devices/cpu/events/PM_CMPLU_STALL_DCACHE_MISS diff --git a/arch/powerpc/perf/power7-pmu.c b/arch/powerpc/perf/power7-pmu.c index 13c3f0e547a2..d1821b8bbc4c 100644 --- a/arch/powerpc/perf/power7-pmu.c +++ b/arch/powerpc/perf/power7-pmu.c @@ -60,7 +60,7 @@ #define PME_PM_LD_REF_L1 0xc880 #define PME_PM_LD_MISS_L1 0x400f0 #define PME_PM_BRU_FIN 0x10068 -#define PME_PM_BRU_MPRED 0x400f6 +#define PME_PM_BR_MPRED 0x400f6 #define PME_PM_CMPLU_STALL_FXU 0x20014 #define PME_PM_CMPLU_STALL_DIV 0x40014 @@ -349,7 +349,7 @@ static int power7_generic_events[] = { [PERF_COUNT_HW_CACHE_REFERENCES] = PME_PM_LD_REF_L1, [PERF_COUNT_HW_CACHE_MISSES] = PME_PM_LD_MISS_L1, [PERF_COUNT_HW_BRANCH_INSTRUCTIONS] = PME_PM_BRU_FIN, - [PERF_COUNT_HW_BRANCH_MISSES] = PME_PM_BRU_MPRED, + [PERF_COUNT_HW_BRANCH_MISSES] = PME_PM_BR_MPRED, }; #define C(x) PERF_COUNT_HW_CACHE_##x @@ -405,7 +405,7 @@ GENERIC_EVENT_ATTR(instructions, INST_CMPL); GENERIC_EVENT_ATTR(cache-references, LD_REF_L1); GENERIC_EVENT_ATTR(cache-misses, LD_MISS_L1); GENERIC_EVENT_ATTR(branch-instructions, BRU_FIN); -GENERIC_EVENT_ATTR(branch-misses, BRU_MPRED); +GENERIC_EVENT_ATTR(branch-misses, BR_MPRED); POWER_EVENT_ATTR(CYC, CYC); POWER_EVENT_ATTR(GCT_NOSLOT_CYC, GCT_NOSLOT_CYC); @@ -414,7 +414,7 @@ POWER_EVENT_ATTR(INST_CMPL, INST_CMPL); POWER_EVENT_ATTR(LD_REF_L1, LD_REF_L1); POWER_EVENT_ATTR(LD_MISS_L1, LD_MISS_L1); POWER_EVENT_ATTR(BRU_FIN, BRU_FIN) -POWER_EVENT_ATTR(BRU_MPRED, BRU_MPRED); +POWER_EVENT_ATTR(BR_MPRED, BR_MPRED); POWER_EVENT_ATTR(CMPLU_STALL_FXU, CMPLU_STALL_FXU); POWER_EVENT_ATTR(CMPLU_STALL_DIV, CMPLU_STALL_DIV); @@ -449,7 +449,7 @@ static struct attribute *power7_events_attr[] = { GENERIC_EVENT_PTR(LD_REF_L1), GENERIC_EVENT_PTR(LD_MISS_L1), GENERIC_EVENT_PTR(BRU_FIN), - GENERIC_EVENT_PTR(BRU_MPRED), + GENERIC_EVENT_PTR(BR_MPRED), POWER_EVENT_PTR(CYC), POWER_EVENT_PTR(GCT_NOSLOT_CYC), @@ -458,7 +458,7 @@ static struct attribute *power7_events_attr[] = { POWER_EVENT_PTR(LD_REF_L1), POWER_EVENT_PTR(LD_MISS_L1), POWER_EVENT_PTR(BRU_FIN), - POWER_EVENT_PTR(BRU_MPRED), + POWER_EVENT_PTR(BR_MPRED), POWER_EVENT_PTR(CMPLU_STALL_FXU), POWER_EVENT_PTR(CMPLU_STALL_DIV), From 7cab84e8975cfb8a59ce3e79ce75e5eedd384484 Mon Sep 17 00:00:00 2001 From: David Ahern Date: Tue, 2 Jul 2013 13:27:20 -0600 Subject: [PATCH 0678/1048] perf evsel: Fix count parameter to read call in event_format__new per realloc above the length of the buffer is alloc_size, not BUFSIZ. Adjust length per size as done for buf start. Addresses some valgrind complaints: ==1870== Syscall param read(buf) points to unaddressable byte(s) ==1870== at 0x4E3F610: __read_nocancel (in /lib64/libpthread-2.14.90.so) ==1870== by 0x44AEE1: event_format__new (unistd.h:45) ==1870== by 0x44B025: perf_evsel__newtp (evsel.c:158) ==1870== by 0x451919: add_tracepoint_event (parse-events.c:395) ==1870== by 0x479815: parse_events_parse (parse-events.y:292) ==1870== by 0x45463A: parse_events_option (parse-events.c:861) ==1870== by 0x44FEE4: get_value (parse-options.c:113) ==1870== by 0x450767: parse_options_step (parse-options.c:192) ==1870== by 0x450C40: parse_options (parse-options.c:422) ==1870== by 0x42735F: cmd_record (builtin-record.c:918) ==1870== by 0x419D72: run_builtin (perf.c:319) ==1870== by 0x4195F2: main (perf.c:376) ==1870== Address 0xcffebf0 is 0 bytes after a block of size 8,192 alloc'd ==1870== at 0x4C2A62F: malloc (vg_replace_malloc.c:270) ==1870== by 0x4C2A7A3: realloc (vg_replace_malloc.c:662) ==1870== by 0x44AF07: event_format__new (evsel.c:121) ==1870== by 0x44B025: perf_evsel__newtp (evsel.c:158) ==1870== by 0x451919: add_tracepoint_event (parse-events.c:395) ==1870== by 0x479815: parse_events_parse (parse-events.y:292) ==1870== by 0x45463A: parse_events_option (parse-events.c:861) ==1870== by 0x44FEE4: get_value (parse-options.c:113) ==1870== by 0x450767: parse_options_step (parse-options.c:192) ==1870== by 0x450C40: parse_options (parse-options.c:422) ==1870== by 0x42735F: cmd_record (builtin-record.c:918) ==1870== by 0x419D72: run_builtin (perf.c:319) Signed-off-by: David Ahern Cc: Frederic Weisbecker Cc: Ingo Molnar Cc: Jiri Olsa Cc: Namhyung Kim Cc: Peter Zijlstra Link: http://lkml.kernel.org/r/1372793245-4136-2-git-send-email-dsahern@gmail.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/evsel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index 63b6f8c8edf2..df99ebe852ae 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -124,7 +124,7 @@ struct event_format *event_format__new(const char *sys, const char *name) bf = nbf; } - n = read(fd, bf + size, BUFSIZ); + n = read(fd, bf + size, alloc_size - size); if (n < 0) goto out_free_bf; size += n; From b2c34fde048f3c85ef0716a8cdabbe46ac67d1e6 Mon Sep 17 00:00:00 2001 From: Adrian Hunter Date: Thu, 4 Jul 2013 16:20:23 +0300 Subject: [PATCH 0679/1048] perf tools: Fix parse_events_terms() segfault on error path On the error path, 'data.terms' may not have been initialised. Signed-off-by: Adrian Hunter Acked-by: Jiri Olsa Cc: David Ahern Cc: Frederic Weisbecker Cc: Ingo Molnar Cc: Jiri Olsa Cc: Mike Galbraith Cc: Namhyung Kim Cc: Paul Mackerras Cc: Peter Zijlstra Cc: Stephane Eranian Link: http://lkml.kernel.org/r/1372944040-32690-5-git-send-email-adrian.hunter@intel.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/parse-events.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c index 6c8bb0fb189b..d8dcb8dbb1e2 100644 --- a/tools/perf/util/parse-events.c +++ b/tools/perf/util/parse-events.c @@ -860,7 +860,8 @@ int parse_events_terms(struct list_head *terms, const char *str) return 0; } - parse_events__free_terms(data.terms); + if (data.terms) + parse_events__free_terms(data.terms); return ret; } From 4be8be6b430611def94bcd583b7b302d197a9520 Mon Sep 17 00:00:00 2001 From: Adrian Hunter Date: Thu, 4 Jul 2013 16:20:24 +0300 Subject: [PATCH 0680/1048] perf tools: Fix new_term() missing free on error path On the error path, newly allocated 'term' must be freed. Signed-off-by: Adrian Hunter Acked-by: Jiri Olsa Cc: David Ahern Cc: Frederic Weisbecker Cc: Ingo Molnar Cc: Jiri Olsa Cc: Mike Galbraith Cc: Namhyung Kim Cc: Paul Mackerras Cc: Peter Zijlstra Cc: Stephane Eranian Link: http://lkml.kernel.org/r/1372944040-32690-6-git-send-email-adrian.hunter@intel.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/parse-events.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c index d8dcb8dbb1e2..995fc25db8c6 100644 --- a/tools/perf/util/parse-events.c +++ b/tools/perf/util/parse-events.c @@ -1184,6 +1184,7 @@ static int new_term(struct parse_events_term **_term, int type_val, term->val.str = str; break; default: + free(term); return -EINVAL; } From 7e0d6fc90fc6f9faea63a2b67233ae767903573c Mon Sep 17 00:00:00 2001 From: Adrian Hunter Date: Thu, 4 Jul 2013 16:20:29 +0300 Subject: [PATCH 0681/1048] perf tools: Update symbol_conf.nr_events when processing attribute events Signed-off-by: Adrian Hunter Cc: David Ahern Cc: Frederic Weisbecker Cc: Ingo Molnar Cc: Jiri Olsa Cc: Mike Galbraith Cc: Namhyung Kim Cc: Paul Mackerras Cc: Peter Zijlstra Cc: Stephane Eranian Link: http://lkml.kernel.org/r/1372944040-32690-11-git-send-email-adrian.hunter@intel.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/header.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c index 93dd31573fb5..a4dafbee2511 100644 --- a/tools/perf/util/header.c +++ b/tools/perf/util/header.c @@ -2956,6 +2956,8 @@ int perf_event__process_attr(union perf_event *event, perf_evlist__id_add(evlist, evsel, 0, i, event->attr.id[i]); } + symbol_conf.nr_events = evlist->nr_entries; + return 0; } From 54bd269205c188967d565f1f5552b13d08ca1be0 Mon Sep 17 00:00:00 2001 From: Adrian Hunter Date: Thu, 4 Jul 2013 16:20:34 +0300 Subject: [PATCH 0682/1048] perf evsel: Fix missing increment in sample parsing The final sample format bit used to be PERF_SAMPLE_STACK_USER which neglected to do a final increment of the array pointer. The result is that the following parsing might start at the wrong place. Signed-off-by: Adrian Hunter Cc: David Ahern Cc: Frederic Weisbecker Cc: Ingo Molnar Cc: Jiri Olsa Cc: Mike Galbraith Cc: Namhyung Kim Cc: Paul Mackerras Cc: Peter Zijlstra Cc: Stephane Eranian Link: http://lkml.kernel.org/r/1372944040-32690-16-git-send-email-adrian.hunter@intel.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/evsel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index df99ebe852ae..c9c7494506a1 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -1170,7 +1170,7 @@ int perf_evsel__parse_sample(struct perf_evsel *evsel, union perf_event *event, } else { data->user_stack.data = (char *)array; array += size / sizeof(*array); - data->user_stack.size = *array; + data->user_stack.size = *array++; } } From f9ceffb605be7b3b3b2a6e6d14dd0d7a97eae580 Mon Sep 17 00:00:00 2001 From: Waiman Long Date: Thu, 9 May 2013 10:42:48 -0400 Subject: [PATCH 0683/1048] perf symbols: Fix vdso list searching When "perf record" was used on a large machine with a lot of CPUs, the perf post-processing time (the time after the workload was done until the perf command itself exited) could take a lot of minutes and even hours depending on how large the resulting perf.data file was. While running AIM7 1500-user high_systime workload on a 80-core x86-64 system with a 3.9 kernel (with only the -s -a options used), the workload itself took about 2 minutes to run and the perf.data file had a size of 1108.746 MB. However, the post-processing step took more than 10 minutes. With a gprof-profiled perf binary, the time spent by perf was as follows: % cumulative self self total time seconds seconds calls s/call s/call name 96.90 822.10 822.10 192156 0.00 0.00 dsos__find 0.81 828.96 6.86 172089958 0.00 0.00 rb_next 0.41 832.44 3.48 48539289 0.00 0.00 rb_erase So 97% (822 seconds) of the time was spent in a single dsos_find() function. After analyzing the call-graph data below: ----------------------------------------------- 0.00 822.12 192156/192156 map__new [6] [7] 96.9 0.00 822.12 192156 vdso__dso_findnew [7] 822.10 0.00 192156/192156 dsos__find [8] 0.01 0.00 192156/192156 dsos__add [62] 0.01 0.00 192156/192366 dso__new [61] 0.00 0.00 1/45282525 memdup [31] 0.00 0.00 192156/192230 dso__set_long_name [91] ----------------------------------------------- 822.10 0.00 192156/192156 vdso__dso_findnew [7] [8] 96.9 822.10 0.00 192156 dsos__find [8] ----------------------------------------------- It was found that the vdso__dso_findnew() function failed to locate VDSO__MAP_NAME ("[vdso]") in the dso list and have to insert a new entry at the end for 192156 times. This problem is due to the fact that there are 2 types of name in the dso entry - short name and long name. The initial dso__new() adds "[vdso]" to both the short and long names. After that, vdso__dso_findnew() modifies the long name to something like /tmp/perf-vdso.so-NoXkDj. The dsos__find() function only compares the long name. As a result, the same vdso entry is duplicated many time in the dso list. This bug increases memory consumption as well as slows the symbol processing time to a crawl. To resolve this problem, the dsos__find() function interface was modified to enable searching either the long name or the short name. The vdso__dso_findnew() will now search only the short name while the other call sites search for the long name as before. With this change, the cpu time of perf was reduced from 848.38s to 15.77s and dsos__find() only accounted for 0.06% of the total time. 0.06 15.73 0.01 192151 0.00 0.00 dsos__find Signed-off-by: Waiman Long Acked-by: Ingo Molnar Cc: "Chandramouleeswaran, Aswin" Cc: "Norton, Scott J" Cc: Ingo Molnar Cc: Jiri Olsa Cc: Namhyung Kim Cc: Paul Mackerras Cc: Peter Zijlstra Cc: Stephane Eranian Link: http://lkml.kernel.org/r/1368110568-64714-1-git-send-email-Waiman.Long@hp.com [ replaced TRUE/FALSE with stdbool.h equivalents, fixing builds where those macros are not present (NO_LIBPYTHON=1 NO_LIBPERL=1), fix from Jiri Olsa ] Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/dso.c | 10 ++++++++-- tools/perf/util/dso.h | 3 ++- tools/perf/util/vdso.c | 2 +- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c index 6f7d5a9d6b05..c4374f07603c 100644 --- a/tools/perf/util/dso.c +++ b/tools/perf/util/dso.c @@ -513,10 +513,16 @@ void dsos__add(struct list_head *head, struct dso *dso) list_add_tail(&dso->node, head); } -struct dso *dsos__find(struct list_head *head, const char *name) +struct dso *dsos__find(struct list_head *head, const char *name, bool cmp_short) { struct dso *pos; + if (cmp_short) { + list_for_each_entry(pos, head, node) + if (strcmp(pos->short_name, name) == 0) + return pos; + return NULL; + } list_for_each_entry(pos, head, node) if (strcmp(pos->long_name, name) == 0) return pos; @@ -525,7 +531,7 @@ struct dso *dsos__find(struct list_head *head, const char *name) struct dso *__dsos__findnew(struct list_head *head, const char *name) { - struct dso *dso = dsos__find(head, name); + struct dso *dso = dsos__find(head, name, false); if (!dso) { dso = dso__new(name); diff --git a/tools/perf/util/dso.h b/tools/perf/util/dso.h index 450199ab51b5..d51aaf272c68 100644 --- a/tools/perf/util/dso.h +++ b/tools/perf/util/dso.h @@ -133,7 +133,8 @@ struct dso *dso__kernel_findnew(struct machine *machine, const char *name, const char *short_name, int dso_type); void dsos__add(struct list_head *head, struct dso *dso); -struct dso *dsos__find(struct list_head *head, const char *name); +struct dso *dsos__find(struct list_head *head, const char *name, + bool cmp_short); struct dso *__dsos__findnew(struct list_head *head, const char *name); bool __dsos__read_build_ids(struct list_head *head, bool with_hits); diff --git a/tools/perf/util/vdso.c b/tools/perf/util/vdso.c index e60951fcdb12..39159822d58f 100644 --- a/tools/perf/util/vdso.c +++ b/tools/perf/util/vdso.c @@ -91,7 +91,7 @@ void vdso__exit(void) struct dso *vdso__dso_findnew(struct list_head *head) { - struct dso *dso = dsos__find(head, VDSO__MAP_NAME); + struct dso *dso = dsos__find(head, VDSO__MAP_NAME, true); if (!dso) { char *file; From 582ec0829b3dd74d8c0f58403a3f9df8cbaa9c7d Mon Sep 17 00:00:00 2001 From: Stephane Eranian Date: Fri, 5 Jul 2013 19:06:45 +0200 Subject: [PATCH 0684/1048] perf stat: Fix per-socket output bug for uncore events This patch fixes a problem reported by Andi Kleen on perf stat when measuring uncore events: # perf stat --per-socket -e uncore_pcu/event=0x0/ -I1000 -a sleep 2 It would not report counts for the second socket. That was due to a cpu mapping bug in print_aggr(). This patch also fixes the socket numbering bug for events. Reported-by: Andi Kleen Signed-off-by: Stephane Eranian Tested-by: Andi Kleen Cc: Andi Kleen Cc: Ingo Molnar Cc: Jiri Olsa Cc: Namhyung Kim Cc: Peter Zijlstra Cc: zheng.z.yan@intel.com Link: http://lkml.kernel.org/r/20130705170645.GA32519@quad Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/builtin-stat.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index 95768afaae3e..352fbd7ff4a1 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c @@ -924,7 +924,7 @@ static void abs_printout(int cpu, int nr, struct perf_evsel *evsel, double avg) static void print_aggr(char *prefix) { struct perf_evsel *counter; - int cpu, s, s2, id, nr; + int cpu, cpu2, s, s2, id, nr; u64 ena, run, val; if (!(aggr_map || aggr_get_id)) @@ -936,7 +936,8 @@ static void print_aggr(char *prefix) val = ena = run = 0; nr = 0; for (cpu = 0; cpu < perf_evsel__nr_cpus(counter); cpu++) { - s2 = aggr_get_id(evsel_list->cpus, cpu); + cpu2 = perf_evsel__cpus(counter)->map[cpu]; + s2 = aggr_get_id(evsel_list->cpus, cpu2); if (s2 != id) continue; val += counter->counts->cpu[cpu].val; @@ -948,7 +949,7 @@ static void print_aggr(char *prefix) fprintf(output, "%s", prefix); if (run == 0 || ena == 0) { - aggr_printout(counter, cpu, nr); + aggr_printout(counter, id, nr); fprintf(output, "%*s%s%*s", csv_output ? 0 : 18, From a4147f0f91386540316e468f3a3674a498dada5f Mon Sep 17 00:00:00 2001 From: Robert Richter Date: Wed, 8 May 2013 11:43:34 +0200 Subject: [PATCH 0685/1048] perf tools: Fix perf version generation The tag of the perf version is wrongly determined, always the latest tag is taken regardless of the HEAD commit: $ perf --version perf version 3.9.rc8.gd7f5d3 $ git describe d7f5d3 v3.9-rc7-154-gd7f5d33 $ head -n 4 Makefile VERSION = 3 PATCHLEVEL = 9 SUBLEVEL = 0 EXTRAVERSION = -rc7 In other cases no tag might be found. This patch fixes this. This new implementation handles also the case if there are no tags at all found in the git repo but there is a commit id. Signed-off-by: Robert Richter Link: http://lkml.kernel.org/r/1368006214-12912-1-git-send-email-rric@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/PERF-VERSION-GEN | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/tools/perf/util/PERF-VERSION-GEN b/tools/perf/util/PERF-VERSION-GEN index 055fef34b6f6..15a77b7c0e36 100755 --- a/tools/perf/util/PERF-VERSION-GEN +++ b/tools/perf/util/PERF-VERSION-GEN @@ -13,13 +13,22 @@ LF=' # First check if there is a .git to get the version from git describe # otherwise try to get the version from the kernel Makefile # -if test -d ../../.git -o -f ../../.git && - VN=$(git tag 2>/dev/null | tail -1 | grep -E "v[0-9].[0-9]*") +CID= +TAG= +if test -d ../../.git -o -f ../../.git then - VN=$(echo $VN"-g"$(git log -1 --abbrev=4 --pretty=format:"%h" HEAD)) - VN=$(echo "$VN" | sed -e 's/-/./g'); -else - VN=$(MAKEFLAGS= make -sC ../.. kernelversion) + TAG=$(git describe --abbrev=0 --match "v[0-9].[0-9]*" 2>/dev/null ) + CID=$(git log -1 --abbrev=4 --pretty=format:"%h" 2>/dev/null) && CID="-g$CID" +fi +if test -z "$TAG" +then + TAG=$(MAKEFLAGS= make -sC ../.. kernelversion) +fi +VN="$TAG$CID" +if test -n "$CID" +then + # format version string, strip trailing zero of sublevel: + VN=$(echo "$VN" | sed -e 's/-/./g;s/\([0-9]*[.][0-9]*\)[.]0/\1/') fi VN=$(expr "$VN" : v*'\(.*\)') From 48e3b9855d6e1b408ec4a808f243e858a78f4482 Mon Sep 17 00:00:00 2001 From: Sreekanth Reddy Date: Sat, 29 Jun 2013 03:50:34 +0530 Subject: [PATCH 0686/1048] [SCSI] mpt3sas: 2013 source code copyright The Copyright String in all mpt3sas files are changed to 2012-2013. Signed-off-by: Sreekanth Reddy Signed-off-by: James Bottomley --- drivers/scsi/mpt3sas/Kconfig | 2 +- drivers/scsi/mpt3sas/mpt3sas_base.c | 2 +- drivers/scsi/mpt3sas/mpt3sas_base.h | 2 +- drivers/scsi/mpt3sas/mpt3sas_config.c | 2 +- drivers/scsi/mpt3sas/mpt3sas_ctl.c | 2 +- drivers/scsi/mpt3sas/mpt3sas_ctl.h | 2 +- drivers/scsi/mpt3sas/mpt3sas_debug.h | 2 +- drivers/scsi/mpt3sas/mpt3sas_scsih.c | 2 +- drivers/scsi/mpt3sas/mpt3sas_transport.c | 2 +- drivers/scsi/mpt3sas/mpt3sas_trigger_diag.c | 2 +- drivers/scsi/mpt3sas/mpt3sas_trigger_diag.h | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/scsi/mpt3sas/Kconfig b/drivers/scsi/mpt3sas/Kconfig index 81471bf415d8..d53e1b02e893 100644 --- a/drivers/scsi/mpt3sas/Kconfig +++ b/drivers/scsi/mpt3sas/Kconfig @@ -2,7 +2,7 @@ # Kernel configuration file for the MPT3SAS # # This code is based on drivers/scsi/mpt3sas/Kconfig -# Copyright (C) 2012 LSI Corporation +# Copyright (C) 2012-2013 LSI Corporation # (mailto:DL-MPTFusionLinux@lsi.com) # This program is free software; you can redistribute it and/or diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c b/drivers/scsi/mpt3sas/mpt3sas_base.c index 18360032a520..673a1b53a23f 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_base.c +++ b/drivers/scsi/mpt3sas/mpt3sas_base.c @@ -3,7 +3,7 @@ * for access to MPT (Message Passing Technology) firmware. * * This code is based on drivers/scsi/mpt3sas/mpt3sas_base.c - * Copyright (C) 2012 LSI Corporation + * Copyright (C) 2012-2013 LSI Corporation * (mailto:DL-MPTFusionLinux@lsi.com) * * This program is free software; you can redistribute it and/or diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.h b/drivers/scsi/mpt3sas/mpt3sas_base.h index 994656cbfac9..36106470530b 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_base.h +++ b/drivers/scsi/mpt3sas/mpt3sas_base.h @@ -3,7 +3,7 @@ * for access to MPT (Message Passing Technology) firmware. * * This code is based on drivers/scsi/mpt3sas/mpt3sas_base.h - * Copyright (C) 2012 LSI Corporation + * Copyright (C) 2012-2013 LSI Corporation * (mailto:DL-MPTFusionLinux@lsi.com) * * This program is free software; you can redistribute it and/or diff --git a/drivers/scsi/mpt3sas/mpt3sas_config.c b/drivers/scsi/mpt3sas/mpt3sas_config.c index 4db0c7a18bd8..936ec0391990 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_config.c +++ b/drivers/scsi/mpt3sas/mpt3sas_config.c @@ -2,7 +2,7 @@ * This module provides common API for accessing firmware configuration pages * * This code is based on drivers/scsi/mpt3sas/mpt3sas_base.c - * Copyright (C) 2012 LSI Corporation + * Copyright (C) 2012-2013 LSI Corporation * (mailto:DL-MPTFusionLinux@lsi.com) * * This program is free software; you can redistribute it and/or diff --git a/drivers/scsi/mpt3sas/mpt3sas_ctl.c b/drivers/scsi/mpt3sas/mpt3sas_ctl.c index 0b402b6f2d26..9b89de14a0a3 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_ctl.c +++ b/drivers/scsi/mpt3sas/mpt3sas_ctl.c @@ -3,7 +3,7 @@ * controllers * * This code is based on drivers/scsi/mpt3sas/mpt3sas_ctl.c - * Copyright (C) 2012 LSI Corporation + * Copyright (C) 2012-2013 LSI Corporation * (mailto:DL-MPTFusionLinux@lsi.com) * * This program is free software; you can redistribute it and/or diff --git a/drivers/scsi/mpt3sas/mpt3sas_ctl.h b/drivers/scsi/mpt3sas/mpt3sas_ctl.h index bd89f4f00550..53b0c480d98f 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_ctl.h +++ b/drivers/scsi/mpt3sas/mpt3sas_ctl.h @@ -3,7 +3,7 @@ * controllers * * This code is based on drivers/scsi/mpt3sas/mpt3sas_ctl.h - * Copyright (C) 2012 LSI Corporation + * Copyright (C) 2012-2013 LSI Corporation * (mailto:DL-MPTFusionLinux@lsi.com) * * This program is free software; you can redistribute it and/or diff --git a/drivers/scsi/mpt3sas/mpt3sas_debug.h b/drivers/scsi/mpt3sas/mpt3sas_debug.h index 35405e7044f8..545b22d2cbdf 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_debug.h +++ b/drivers/scsi/mpt3sas/mpt3sas_debug.h @@ -2,7 +2,7 @@ * Logging Support for MPT (Message Passing Technology) based controllers * * This code is based on drivers/scsi/mpt3sas/mpt3sas_debug.c - * Copyright (C) 2012 LSI Corporation + * Copyright (C) 2012-2013 LSI Corporation * (mailto:DL-MPTFusionLinux@lsi.com) * * This program is free software; you can redistribute it and/or diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c index dcbf7c880cb2..73d3b81a0d06 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c +++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c @@ -2,7 +2,7 @@ * Scsi Host Layer for MPT (Message Passing Technology) based controllers * * This code is based on drivers/scsi/mpt3sas/mpt3sas_scsih.c - * Copyright (C) 2012 LSI Corporation + * Copyright (C) 2012-2013 LSI Corporation * (mailto:DL-MPTFusionLinux@lsi.com) * * This program is free software; you can redistribute it and/or diff --git a/drivers/scsi/mpt3sas/mpt3sas_transport.c b/drivers/scsi/mpt3sas/mpt3sas_transport.c index 87ca2b7287c3..dcadd56860ff 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_transport.c +++ b/drivers/scsi/mpt3sas/mpt3sas_transport.c @@ -2,7 +2,7 @@ * SAS Transport Layer for MPT (Message Passing Technology) based controllers * * This code is based on drivers/scsi/mpt3sas/mpt3sas_transport.c - * Copyright (C) 2012 LSI Corporation + * Copyright (C) 2012-2013 LSI Corporation * (mailto:DL-MPTFusionLinux@lsi.com) * * This program is free software; you can redistribute it and/or diff --git a/drivers/scsi/mpt3sas/mpt3sas_trigger_diag.c b/drivers/scsi/mpt3sas/mpt3sas_trigger_diag.c index 6f8d6213040b..f6533ab20364 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_trigger_diag.c +++ b/drivers/scsi/mpt3sas/mpt3sas_trigger_diag.c @@ -3,7 +3,7 @@ * (Message Passing Technology) based controllers * * This code is based on drivers/scsi/mpt3sas/mpt3sas_trigger_diag.c - * Copyright (C) 2012 LSI Corporation + * Copyright (C) 2012-2013 LSI Corporation * (mailto:DL-MPTFusionLinux@lsi.com) * * This program is free software; you can redistribute it and/or diff --git a/drivers/scsi/mpt3sas/mpt3sas_trigger_diag.h b/drivers/scsi/mpt3sas/mpt3sas_trigger_diag.h index a10c30907394..bb693923bef1 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_trigger_diag.h +++ b/drivers/scsi/mpt3sas/mpt3sas_trigger_diag.h @@ -4,7 +4,7 @@ * controllers * * This code is based on drivers/scsi/mpt3sas/mpt3sas_base.h - * Copyright (C) 2012 LSI Corporation + * Copyright (C) 2012-2013 LSI Corporation * (mailto:DL-MPTFusionLinux@lsi.com) * * This program is free software; you can redistribute it and/or From b453ff84de6caf3ad3a988da8444c13b71e3f507 Mon Sep 17 00:00:00 2001 From: Sreekanth Reddy Date: Sat, 29 Jun 2013 03:51:19 +0530 Subject: [PATCH 0687/1048] [SCSI] mpt3sas: Updated the Hardware timing requirements Hardware timing requirements is updated in order to comply with firmware requirement. Signed-off-by: Sreekanth Reddy Signed-off-by: James Bottomley --- drivers/scsi/mpt3sas/mpt3sas_base.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c b/drivers/scsi/mpt3sas/mpt3sas_base.c index 673a1b53a23f..5dc280c75325 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_base.c +++ b/drivers/scsi/mpt3sas/mpt3sas_base.c @@ -4090,11 +4090,15 @@ _base_diag_reset(struct MPT3SAS_ADAPTER *ioc, int sleep_flag) writel(host_diagnostic | MPI2_DIAG_RESET_ADAPTER, &ioc->chip->HostDiagnostic); - /* don't access any registers for 50 milliseconds */ - msleep(50); + /*This delay allows the chip PCIe hardware time to finish reset tasks*/ + if (sleep_flag == CAN_SLEEP) + msleep(MPI2_HARD_RESET_PCIE_FIRST_READ_DELAY_MICRO_SEC/1000); + else + mdelay(MPI2_HARD_RESET_PCIE_FIRST_READ_DELAY_MICRO_SEC/1000); - /* 300 second max wait */ - for (count = 0; count < 3000000 ; count++) { + /* Approximately 300 second max wait */ + for (count = 0; count < (300000000 / + MPI2_HARD_RESET_PCIE_SECOND_READ_DELAY_MICRO_SEC); count++) { host_diagnostic = readl(&ioc->chip->HostDiagnostic); @@ -4103,11 +4107,13 @@ _base_diag_reset(struct MPT3SAS_ADAPTER *ioc, int sleep_flag) if (!(host_diagnostic & MPI2_DIAG_RESET_ADAPTER)) break; - /* wait 1 msec */ + /* Wait to pass the second read delay window */ if (sleep_flag == CAN_SLEEP) - usleep_range(1000, 1500); + msleep(MPI2_HARD_RESET_PCIE_SECOND_READ_DELAY_MICRO_SEC + / 1000); else - mdelay(1); + mdelay(MPI2_HARD_RESET_PCIE_SECOND_READ_DELAY_MICRO_SEC + / 1000); } if (host_diagnostic & MPI2_DIAG_HCB_MODE) { From b65cfedf4560af65305bd7b3b9f26c02c6fb3660 Mon Sep 17 00:00:00 2001 From: Sreekanth Reddy Date: Sat, 29 Jun 2013 03:52:03 +0530 Subject: [PATCH 0688/1048] [SCSI] mpt3sas: fix for kernel panic when driver loads with HBA conected to non LUN 0 configured expander With some enclosures when LUN 0 is not created but LUN 1 or LUN X is created then SCSI scan procedure calls target_alloc, slave_alloc call back functions for LUN 0 and slave_destory() for same LUN 0. In these kind of cases within slave_destroy, pointer to scsi_target in _sas_device structure is set to NULL, following which when slave_alloc for LUN 1 is called then starget would not be set properly for this LUN. So, scsi_target pointer pointing to NULL value would lead to a crash later in the discovery procedure. To solve this issue set the sas_device's scsi_target pointer to scsi_device's scsi_target if it is NULL earlier in slave_alloc callback function. Signed-off-by: Sreekanth Reddy Cc: stable@vger.kernel.org Signed-off-by: James Bottomley --- drivers/scsi/mpt3sas/mpt3sas_scsih.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c index 73d3b81a0d06..9ebc9dce3046 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c +++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c @@ -1273,6 +1273,7 @@ _scsih_slave_alloc(struct scsi_device *sdev) struct MPT3SAS_DEVICE *sas_device_priv_data; struct scsi_target *starget; struct _raid_device *raid_device; + struct _sas_device *sas_device; unsigned long flags; sas_device_priv_data = kzalloc(sizeof(struct scsi_device), GFP_KERNEL); @@ -1301,6 +1302,19 @@ _scsih_slave_alloc(struct scsi_device *sdev) spin_unlock_irqrestore(&ioc->raid_device_lock, flags); } + if (!(sas_target_priv_data->flags & MPT_TARGET_FLAGS_VOLUME)) { + spin_lock_irqsave(&ioc->sas_device_lock, flags); + sas_device = mpt3sas_scsih_sas_device_find_by_sas_address(ioc, + sas_target_priv_data->sas_address); + if (sas_device && (sas_device->starget == NULL)) { + sdev_printk(KERN_INFO, sdev, + "%s : sas_device->starget set to starget @ %d\n", + __func__, __LINE__); + sas_device->starget = starget; + } + spin_unlock_irqrestore(&ioc->sas_device_lock, flags); + } + return 0; } From 14be49ac965ebd3f8561d57e01ddb22f93f9b454 Mon Sep 17 00:00:00 2001 From: Sreekanth Reddy Date: Sat, 29 Jun 2013 03:53:02 +0530 Subject: [PATCH 0689/1048] [SCSI] mpt3sas: Infinite loops can occur if MPI2_IOCSTATUS_CONFIG_INVALID_PAGE is not returned Infinite loop can occur if IOCStatus is not equal to MPI2_IOCSTATUS_CONFIG_INVALID_PAGE value in the while loops in functions _scsih_search_responding_sas_devices, _scsih_search_responding_raid_devices and _scsih_search_responding_expanders So, Instead of checking for MPI2_IOCSTATUS_CONFIG_INVALID_PAGE value, in this patch code is modified to check for IOCStatus not equals to MPI2_IOCSTATUS_SUCCESS to break the while loop. Signed-off-by: Sreekanth Reddy Cc: stable@vger.kernel.org Signed-off-by: James Bottomley --- drivers/scsi/mpt3sas/mpt3sas_scsih.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c index 9ebc9dce3046..632eba75971c 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c +++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c @@ -6406,7 +6406,7 @@ _scsih_search_responding_sas_devices(struct MPT3SAS_ADAPTER *ioc) handle))) { ioc_status = le16_to_cpu(mpi_reply.IOCStatus) & MPI2_IOCSTATUS_MASK; - if (ioc_status == MPI2_IOCSTATUS_CONFIG_INVALID_PAGE) + if (ioc_status != MPI2_IOCSTATUS_SUCCESS) break; handle = le16_to_cpu(sas_device_pg0.DevHandle); device_info = le32_to_cpu(sas_device_pg0.DeviceInfo); @@ -6508,7 +6508,7 @@ _scsih_search_responding_raid_devices(struct MPT3SAS_ADAPTER *ioc) &volume_pg1, MPI2_RAID_VOLUME_PGAD_FORM_GET_NEXT_HANDLE, handle))) { ioc_status = le16_to_cpu(mpi_reply.IOCStatus) & MPI2_IOCSTATUS_MASK; - if (ioc_status == MPI2_IOCSTATUS_CONFIG_INVALID_PAGE) + if (ioc_status != MPI2_IOCSTATUS_SUCCESS) break; handle = le16_to_cpu(volume_pg1.DevHandle); @@ -6532,7 +6532,7 @@ _scsih_search_responding_raid_devices(struct MPT3SAS_ADAPTER *ioc) phys_disk_num))) { ioc_status = le16_to_cpu(mpi_reply.IOCStatus) & MPI2_IOCSTATUS_MASK; - if (ioc_status == MPI2_IOCSTATUS_CONFIG_INVALID_PAGE) + if (ioc_status != MPI2_IOCSTATUS_SUCCESS) break; phys_disk_num = pd_pg0.PhysDiskNum; handle = le16_to_cpu(pd_pg0.DevHandle); @@ -6611,7 +6611,7 @@ _scsih_search_responding_expanders(struct MPT3SAS_ADAPTER *ioc) ioc_status = le16_to_cpu(mpi_reply.IOCStatus) & MPI2_IOCSTATUS_MASK; - if (ioc_status == MPI2_IOCSTATUS_CONFIG_INVALID_PAGE) + if (ioc_status != MPI2_IOCSTATUS_SUCCESS) break; handle = le16_to_cpu(expander_pg0.DevHandle); @@ -6756,8 +6756,6 @@ _scsih_scan_for_devices_after_reset(struct MPT3SAS_ADAPTER *ioc) MPI2_SAS_EXPAND_PGAD_FORM_GET_NEXT_HNDL, handle))) { ioc_status = le16_to_cpu(mpi_reply.IOCStatus) & MPI2_IOCSTATUS_MASK; - if (ioc_status == MPI2_IOCSTATUS_CONFIG_INVALID_PAGE) - break; if (ioc_status != MPI2_IOCSTATUS_SUCCESS) { pr_info(MPT3SAS_FMT "\tbreak from expander scan: " \ "ioc_status(0x%04x), loginfo(0x%08x)\n", @@ -6801,8 +6799,6 @@ _scsih_scan_for_devices_after_reset(struct MPT3SAS_ADAPTER *ioc) phys_disk_num))) { ioc_status = le16_to_cpu(mpi_reply.IOCStatus) & MPI2_IOCSTATUS_MASK; - if (ioc_status == MPI2_IOCSTATUS_CONFIG_INVALID_PAGE) - break; if (ioc_status != MPI2_IOCSTATUS_SUCCESS) { pr_info(MPT3SAS_FMT "\tbreak from phys disk scan: "\ "ioc_status(0x%04x), loginfo(0x%08x)\n", @@ -6868,8 +6864,6 @@ _scsih_scan_for_devices_after_reset(struct MPT3SAS_ADAPTER *ioc) &volume_pg1, MPI2_RAID_VOLUME_PGAD_FORM_GET_NEXT_HANDLE, handle))) { ioc_status = le16_to_cpu(mpi_reply.IOCStatus) & MPI2_IOCSTATUS_MASK; - if (ioc_status == MPI2_IOCSTATUS_CONFIG_INVALID_PAGE) - break; if (ioc_status != MPI2_IOCSTATUS_SUCCESS) { pr_info(MPT3SAS_FMT "\tbreak from volume scan: " \ "ioc_status(0x%04x), loginfo(0x%08x)\n", @@ -6928,8 +6922,6 @@ _scsih_scan_for_devices_after_reset(struct MPT3SAS_ADAPTER *ioc) handle))) { ioc_status = le16_to_cpu(mpi_reply.IOCStatus) & MPI2_IOCSTATUS_MASK; - if (ioc_status == MPI2_IOCSTATUS_CONFIG_INVALID_PAGE) - break; if (ioc_status != MPI2_IOCSTATUS_SUCCESS) { pr_info(MPT3SAS_FMT "\tbreak from end device scan:"\ " ioc_status(0x%04x), loginfo(0x%08x)\n", From 17263e754d87fac1be2825b43d984f594a68845e Mon Sep 17 00:00:00 2001 From: Sreekanth Reddy Date: Sat, 29 Jun 2013 03:54:07 +0530 Subject: [PATCH 0690/1048] [SCSI] mpt3sas: MPI2.5 Rev F v2.5.1.1 specification Change set in MPI v2.5 Rev F(v2.5.1.1) specification and 2.00.29 header files 1. Added a bit to the IOCExceptions field of the IOCFacts Reply to indicate that the IOC detected a partial memory failure. 2. Added ElapsedSeconds field to RAID Volume Indicator Structure. Added Elapsed Seconds Valid flag to Flags field of this structure. 3. Added ElapsedSeconds field to Integrated RAID Operations Status Event Data. 4. Added two new AbortType values for TargetModeAbort Request, one to abort all I/Os from a single initiator, and the other to abort only Command IUs. 5. Added a new chapter covering DMA Flags and Multicast Modes. 6. In the IOCSettings field of BIOS Page 1, modified the Adapter Support bits description to specify X86 BIOS. 7. Marked bit 0 of the ControlFlags field of SAS IO Unit Page 1 as obsolete. This was the Clear SATA Affiliation flag. 8. Added additional requirements for certain IOCs that support more than eight MSI-x vectors. Signed-off-by: Sreekanth Reddy Signed-off-by: James Bottomley --- drivers/scsi/mpt3sas/mpi/mpi2.h | 12 +++++++++--- drivers/scsi/mpt3sas/mpi/mpi2_cnfg.h | 15 +++++++++++++-- drivers/scsi/mpt3sas/mpi/mpi2_init.h | 2 +- drivers/scsi/mpt3sas/mpi/mpi2_ioc.h | 10 +++++++--- drivers/scsi/mpt3sas/mpi/mpi2_raid.h | 10 +++++++--- drivers/scsi/mpt3sas/mpi/mpi2_sas.h | 2 +- drivers/scsi/mpt3sas/mpi/mpi2_tool.h | 10 ++++++---- drivers/scsi/mpt3sas/mpi/mpi2_type.h | 2 +- 8 files changed, 45 insertions(+), 18 deletions(-) diff --git a/drivers/scsi/mpt3sas/mpi/mpi2.h b/drivers/scsi/mpt3sas/mpi/mpi2.h index 03317ffea62c..20da8f907c00 100644 --- a/drivers/scsi/mpt3sas/mpi/mpi2.h +++ b/drivers/scsi/mpt3sas/mpi/mpi2.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2012 LSI Corporation. + * Copyright (c) 2000-2013 LSI Corporation. * * * Name: mpi2.h @@ -8,7 +8,7 @@ * scatter/gather formats. * Creation Date: June 21, 2006 * - * mpi2.h Version: 02.00.26 + * mpi2.h Version: 02.00.29 * * NOTE: Names (typedefs, defines, etc.) beginning with an MPI25 or Mpi25 * prefix are for use only on MPI v2.5 products, and must not be used @@ -82,6 +82,10 @@ * 03-29-12 02.00.25 Bumped MPI2_HEADER_VERSION_UNIT. * Added Hard Reset delay timings. * 07-10-12 02.00.26 Bumped MPI2_HEADER_VERSION_UNIT. + * 07-26-12 02.00.27 Bumped MPI2_HEADER_VERSION_UNIT. + * 11-27-12 02.00.28 Bumped MPI2_HEADER_VERSION_UNIT. + * 12-20-12 02.00.29 Bumped MPI2_HEADER_VERSION_UNIT. + * Added MPI25_SUP_REPLY_POST_HOST_INDEX_OFFSET. * -------------------------------------------------------------------------- */ @@ -115,7 +119,7 @@ #define MPI2_VERSION_02_05 (0x0205) /*Unit and Dev versioning for this MPI header set */ -#define MPI2_HEADER_VERSION_UNIT (0x1A) +#define MPI2_HEADER_VERSION_UNIT (0x1D) #define MPI2_HEADER_VERSION_DEV (0x00) #define MPI2_HEADER_VERSION_UNIT_MASK (0xFF00) #define MPI2_HEADER_VERSION_UNIT_SHIFT (8) @@ -274,6 +278,8 @@ typedef volatile struct _MPI2_SYSTEM_INTERFACE_REGS { #define MPI2_REPLY_POST_HOST_INDEX_MASK (0x00FFFFFF) #define MPI2_RPHI_MSIX_INDEX_MASK (0xFF000000) #define MPI2_RPHI_MSIX_INDEX_SHIFT (24) +#define MPI25_SUP_REPLY_POST_HOST_INDEX_OFFSET (0x0000030C) /*MPI v2.5 only*/ + /* *Defines for the HCBSize and address diff --git a/drivers/scsi/mpt3sas/mpi/mpi2_cnfg.h b/drivers/scsi/mpt3sas/mpi/mpi2_cnfg.h index d8b2c3eedb57..889aa7067899 100644 --- a/drivers/scsi/mpt3sas/mpi/mpi2_cnfg.h +++ b/drivers/scsi/mpt3sas/mpi/mpi2_cnfg.h @@ -1,12 +1,12 @@ /* - * Copyright (c) 2000-2011 LSI Corporation. + * Copyright (c) 2000-2013 LSI Corporation. * * * Name: mpi2_cnfg.h * Title: MPI Configuration messages and pages * Creation Date: November 10, 2006 * - * mpi2_cnfg.h Version: 02.00.22 + * mpi2_cnfg.h Version: 02.00.24 * * NOTE: Names (typedefs, defines, etc.) beginning with an MPI25 or Mpi25 * prefix are for use only on MPI v2.5 products, and must not be used @@ -155,6 +155,11 @@ * Added UEFIVersion field to BIOS Page 1 and defined new * BiosOptions bits. * Incorporating additions for MPI v2.5. + * 11-27-12 02.00.23 Added MPI2_MANPAGE7_FLAG_EVENTREPLAY_SLOT_ORDER. + * Added MPI2_BIOSPAGE1_OPTIONS_MASK_OEM_ID. + * 12-20-12 02.00.24 Marked MPI2_SASIOUNIT1_CONTROL_CLEAR_AFFILIATION as + * obsolete for MPI v2.5 and later. + * Added some defines for 12G SAS speeds. * -------------------------------------------------------------------------- */ @@ -714,6 +719,7 @@ typedef struct _MPI2_CONFIG_PAGE_MAN_7 { #define MPI2_MANUFACTURING7_PAGEVERSION (0x01) /*defines for the Flags field */ +#define MPI2_MANPAGE7_FLAG_EVENTREPLAY_SLOT_ORDER (0x00000002) #define MPI2_MANPAGE7_FLAG_USE_SLOT_INFO (0x00000001) @@ -1310,6 +1316,9 @@ typedef struct _MPI2_CONFIG_PAGE_BIOS_1 { #define MPI2_BIOSPAGE1_PAGEVERSION (0x05) /*values for BIOS Page 1 BiosOptions field */ +#define MPI2_BIOSPAGE1_OPTIONS_MASK_OEM_ID (0x000000F0) +#define MPI2_BIOSPAGE1_OPTIONS_LSI_OEM_ID (0x00000000) + #define MPI2_BIOSPAGE1_OPTIONS_MASK_UEFI_HII_REGISTRATION (0x00000006) #define MPI2_BIOSPAGE1_OPTIONS_ENABLE_UEFI_HII (0x00000000) #define MPI2_BIOSPAGE1_OPTIONS_DISABLE_UEFI_HII (0x00000002) @@ -1884,6 +1893,7 @@ typedef struct _MPI2_CONFIG_PAGE_RD_PDISK_1 { #define MPI2_SAS_PRATE_MAX_RATE_1_5 (0x80) #define MPI2_SAS_PRATE_MAX_RATE_3_0 (0x90) #define MPI2_SAS_PRATE_MAX_RATE_6_0 (0xA0) +#define MPI25_SAS_PRATE_MAX_RATE_12_0 (0xB0) #define MPI2_SAS_PRATE_MIN_RATE_MASK (0x0F) #define MPI2_SAS_PRATE_MIN_RATE_NOT_PROGRAMMABLE (0x00) #define MPI2_SAS_PRATE_MIN_RATE_1_5 (0x08) @@ -1897,6 +1907,7 @@ typedef struct _MPI2_CONFIG_PAGE_RD_PDISK_1 { #define MPI2_SAS_HWRATE_MAX_RATE_1_5 (0x80) #define MPI2_SAS_HWRATE_MAX_RATE_3_0 (0x90) #define MPI2_SAS_HWRATE_MAX_RATE_6_0 (0xA0) +#define MPI25_SAS_HWRATE_MAX_RATE_12_0 (0xB0) #define MPI2_SAS_HWRATE_MIN_RATE_MASK (0x0F) #define MPI2_SAS_HWRATE_MIN_RATE_1_5 (0x08) #define MPI2_SAS_HWRATE_MIN_RATE_3_0 (0x09) diff --git a/drivers/scsi/mpt3sas/mpi/mpi2_init.h b/drivers/scsi/mpt3sas/mpi/mpi2_init.h index a079e5242474..f7928bf66478 100644 --- a/drivers/scsi/mpt3sas/mpi/mpi2_init.h +++ b/drivers/scsi/mpt3sas/mpi/mpi2_init.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2012 LSI Corporation. + * Copyright (c) 2000-2013 LSI Corporation. * * * Name: mpi2_init.h diff --git a/drivers/scsi/mpt3sas/mpi/mpi2_ioc.h b/drivers/scsi/mpt3sas/mpi/mpi2_ioc.h index 0de425d8fd70..e2bb82143720 100644 --- a/drivers/scsi/mpt3sas/mpi/mpi2_ioc.h +++ b/drivers/scsi/mpt3sas/mpi/mpi2_ioc.h @@ -1,12 +1,12 @@ /* - * Copyright (c) 2000-2012 LSI Corporation. + * Copyright (c) 2000-2013 LSI Corporation. * * * Name: mpi2_ioc.h * Title: MPI IOC, Port, Event, FW Download, and FW Upload messages * Creation Date: October 11, 2006 * - * mpi2_ioc.h Version: 02.00.21 + * mpi2_ioc.h Version: 02.00.22 * * NOTE: Names (typedefs, defines, etc.) beginning with an MPI25 or Mpi25 * prefix are for use only on MPI v2.5 products, and must not be used @@ -124,6 +124,9 @@ * Marked MPI2_PM_CONTROL_FEATURE_PCIE_LINK as obsolete. * 11-18-11 02.00.20 Incorporating additions for MPI v2.5. * 03-29-12 02.00.21 Added a product specific range to event values. + * 07-26-12 02.00.22 Added MPI2_IOCFACTS_EXCEPT_PARTIAL_MEMORY_FAILURE. + * Added ElapsedSeconds field to + * MPI2_EVENT_DATA_IR_OPERATION_STATUS. * -------------------------------------------------------------------------- */ @@ -283,6 +286,7 @@ typedef struct _MPI2_IOC_FACTS_REPLY { #define MPI2_IOCFACTS_HDRVERSION_DEV_SHIFT (0) /*IOCExceptions */ +#define MPI2_IOCFACTS_EXCEPT_PARTIAL_MEMORY_FAILURE (0x0200) #define MPI2_IOCFACTS_EXCEPT_IR_FOREIGN_CONFIG_MAX (0x0100) #define MPI2_IOCFACTS_EXCEPT_BOOTSTAT_MASK (0x00E0) @@ -634,7 +638,7 @@ typedef struct _MPI2_EVENT_DATA_IR_OPERATION_STATUS { U8 RAIDOperation; /*0x04 */ U8 PercentComplete; /*0x05 */ U16 Reserved2; /*0x06 */ - U32 Resereved3; /*0x08 */ + U32 ElapsedSeconds; /*0x08 */ } MPI2_EVENT_DATA_IR_OPERATION_STATUS, *PTR_MPI2_EVENT_DATA_IR_OPERATION_STATUS, Mpi2EventDataIrOperationStatus_t, diff --git a/drivers/scsi/mpt3sas/mpi/mpi2_raid.h b/drivers/scsi/mpt3sas/mpi/mpi2_raid.h index d1d9866cf300..71765236afef 100644 --- a/drivers/scsi/mpt3sas/mpi/mpi2_raid.h +++ b/drivers/scsi/mpt3sas/mpi/mpi2_raid.h @@ -1,12 +1,12 @@ /* - * Copyright (c) 2000-2012 LSI Corporation. + * Copyright (c) 2000-2013 LSI Corporation. * * * Name: mpi2_raid.h * Title: MPI Integrated RAID messages and structures * Creation Date: April 26, 2007 * - * mpi2_raid.h Version: 02.00.08 + * mpi2_raid.h Version: 02.00.09 * * Version History * --------------- @@ -28,6 +28,8 @@ * Added product-specific range to RAID Action values. * 11-18-11 02.00.07 Incorporating additions for MPI v2.5. * 02-06-12 02.00.08 Added MPI2_RAID_ACTION_PHYSDISK_HIDDEN. + * 07-26-12 02.00.09 Added ElapsedSeconds field to MPI2_RAID_VOL_INDICATOR. + * Added MPI2_RAID_VOL_FLAGS_ELAPSED_SECONDS_VALID define. * -------------------------------------------------------------------------- */ @@ -269,10 +271,12 @@ typedef struct _MPI2_RAID_VOL_INDICATOR { U64 TotalBlocks; /*0x00 */ U64 BlocksRemaining; /*0x08 */ U32 Flags; /*0x10 */ + U32 ElapsedSeconds; /* 0x14 */ } MPI2_RAID_VOL_INDICATOR, *PTR_MPI2_RAID_VOL_INDICATOR, Mpi2RaidVolIndicator_t, *pMpi2RaidVolIndicator_t; /*defines for RAID Volume Indicator Flags field */ +#define MPI2_RAID_VOL_FLAGS_ELAPSED_SECONDS_VALID (0x80000000) #define MPI2_RAID_VOL_FLAGS_OP_MASK (0x0000000F) #define MPI2_RAID_VOL_FLAGS_OP_BACKGROUND_INIT (0x00000000) #define MPI2_RAID_VOL_FLAGS_OP_ONLINE_CAP_EXPANSION (0x00000001) @@ -312,7 +316,7 @@ typedef struct _MPI2_RAID_COMPATIBILITY_RESULT_STRUCT { /*RAID Action Reply ActionData union */ typedef union _MPI2_RAID_ACTION_REPLY_DATA { - U32 Word[5]; + U32 Word[6]; MPI2_RAID_VOL_INDICATOR RaidVolumeIndicator; U16 VolDevHandle; U8 VolumeState; diff --git a/drivers/scsi/mpt3sas/mpi/mpi2_sas.h b/drivers/scsi/mpt3sas/mpi/mpi2_sas.h index b4e7084aba31..cba046f6a4b4 100644 --- a/drivers/scsi/mpt3sas/mpi/mpi2_sas.h +++ b/drivers/scsi/mpt3sas/mpi/mpi2_sas.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2012 LSI Corporation. + * Copyright (c) 2000-2013 LSI Corporation. * * * Name: mpi2_sas.h diff --git a/drivers/scsi/mpt3sas/mpi/mpi2_tool.h b/drivers/scsi/mpt3sas/mpi/mpi2_tool.h index 71453d11c1c1..34e9a7ba76b0 100644 --- a/drivers/scsi/mpt3sas/mpi/mpi2_tool.h +++ b/drivers/scsi/mpt3sas/mpi/mpi2_tool.h @@ -1,12 +1,12 @@ /* - * Copyright (c) 2000-2012 LSI Corporation. + * Copyright (c) 2000-2013 LSI Corporation. * * * Name: mpi2_tool.h * Title: MPI diagnostic tool structures and definitions * Creation Date: March 26, 2007 * - * mpi2_tool.h Version: 02.00.09 + * mpi2_tool.h Version: 02.00.10 * * Version History * --------------- @@ -30,6 +30,8 @@ * 11-18-11 02.00.08 Incorporating additions for MPI v2.5. * 07-10-12 02.00.09 Add MPI v2.5 Toolbox Diagnostic CLI Tool Request * message. + * 07-26-12 02.00.10 Modified MPI2_TOOLBOX_DIAGNOSTIC_CLI_REQUEST so that + * it uses MPI Chain SGE as well as MPI Simple SGE. * -------------------------------------------------------------------------- */ @@ -279,7 +281,7 @@ typedef struct _MPI2_TOOLBOX_DIAGNOSTIC_CLI_REQUEST { U16 Reserved6; /*0x0E */ U32 DataLength; /*0x10 */ U8 DiagnosticCliCommand[MPI2_TOOLBOX_DIAG_CLI_CMD_LENGTH];/*0x14 */ - MPI2_SGE_SIMPLE_UNION SGL; /*0x70 */ + MPI2_MPI_SGE_IO_UNION SGL; /*0x70 */ } MPI2_TOOLBOX_DIAGNOSTIC_CLI_REQUEST, *PTR_MPI2_TOOLBOX_DIAGNOSTIC_CLI_REQUEST, Mpi2ToolboxDiagnosticCliRequest_t, @@ -302,7 +304,7 @@ typedef struct _MPI25_TOOLBOX_DIAGNOSTIC_CLI_REQUEST { U32 Reserved5; /*0x0C */ U32 DataLength; /*0x10 */ U8 DiagnosticCliCommand[MPI2_TOOLBOX_DIAG_CLI_CMD_LENGTH];/*0x14 */ - MPI25_SGE_IO_UNION SGL; /*0x70 */ + MPI25_SGE_IO_UNION SGL; /* 0x70 */ } MPI25_TOOLBOX_DIAGNOSTIC_CLI_REQUEST, *PTR_MPI25_TOOLBOX_DIAGNOSTIC_CLI_REQUEST, Mpi25ToolboxDiagnosticCliRequest_t, diff --git a/drivers/scsi/mpt3sas/mpi/mpi2_type.h b/drivers/scsi/mpt3sas/mpi/mpi2_type.h index 516f959573f5..ba1fed50966e 100644 --- a/drivers/scsi/mpt3sas/mpi/mpi2_type.h +++ b/drivers/scsi/mpt3sas/mpi/mpi2_type.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2007 LSI Corporation. + * Copyright (c) 2000-2013 LSI Corporation. * * * Name: mpi2_type.h From f5edbe77d93b99f169d752d91bf31df0432ca990 Mon Sep 17 00:00:00 2001 From: Sreekanth Reddy Date: Sat, 29 Jun 2013 03:54:51 +0530 Subject: [PATCH 0691/1048] [SCSI] mpt3sas: when async scanning is enabled then while scanning, devices are removed but their transport layer entries are not removed When Async scanning mode is enabled and device scanning is in progress, devices should not be removed. But in actuality, devices are removed but their transport layer entries are not removed. This causes error to add the same device to the transport layer after host reset or diagnostic reset. So, in this patch, modified the code in such a way that device is not removed when Async scanning mode is enabled and device scanning is in progress. Signed-off-by: Sreekanth Reddy Signed-off-by: James Bottomley --- drivers/scsi/mpt3sas/mpt3sas_scsih.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c index 632eba75971c..8cbe8fd21fc4 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c +++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c @@ -675,11 +675,12 @@ _scsih_sas_device_add(struct MPT3SAS_ADAPTER *ioc, * devices while scanning is turned on due to an oops in * scsi_sysfs_add_sdev()->add_device()->sysfs_addrm_start() */ - if (!ioc->is_driver_loading) + if (!ioc->is_driver_loading) { mpt3sas_transport_port_remove(ioc, sas_device->sas_address, sas_device->sas_address_parent); - _scsih_sas_device_remove(ioc, sas_device); + _scsih_sas_device_remove(ioc, sas_device); + } } } @@ -7531,10 +7532,12 @@ _scsih_probe_boot_devices(struct MPT3SAS_ADAPTER *ioc) sas_address_parent)) { _scsih_sas_device_remove(ioc, sas_device); } else if (!sas_device->starget) { - if (!ioc->is_driver_loading) - mpt3sas_transport_port_remove(ioc, sas_address, + if (!ioc->is_driver_loading) { + mpt3sas_transport_port_remove(ioc, + sas_address, sas_address_parent); - _scsih_sas_device_remove(ioc, sas_device); + _scsih_sas_device_remove(ioc, sas_device); + } } } } @@ -7590,13 +7593,14 @@ _scsih_probe_sas(struct MPT3SAS_ADAPTER *ioc) * oops in scsi_sysfs_add_sdev()->add_device()-> * sysfs_addrm_start() */ - if (!ioc->is_driver_loading) + if (!ioc->is_driver_loading) { mpt3sas_transport_port_remove(ioc, sas_device->sas_address, sas_device->sas_address_parent); - list_del(&sas_device->list); - kfree(sas_device); - continue; + list_del(&sas_device->list); + kfree(sas_device); + continue; + } } spin_lock_irqsave(&ioc->sas_device_lock, flags); From e9ce9c86c28c5d44dc408ffe5069597cbbe4663a Mon Sep 17 00:00:00 2001 From: Sreekanth Reddy Date: Sat, 29 Jun 2013 03:55:45 +0530 Subject: [PATCH 0692/1048] [SCSI] mpt3sas: Bump driver version to v02.100.00.00 Bump driver version to v02.100.00.00. Signed-off-by: Sreekanth Reddy Signed-off-by: James Bottomley --- drivers/scsi/mpt3sas/mpt3sas_base.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.h b/drivers/scsi/mpt3sas/mpt3sas_base.h index 36106470530b..0ebf5d913c80 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_base.h +++ b/drivers/scsi/mpt3sas/mpt3sas_base.h @@ -70,10 +70,10 @@ #define MPT3SAS_DRIVER_NAME "mpt3sas" #define MPT3SAS_AUTHOR "LSI Corporation " #define MPT3SAS_DESCRIPTION "LSI MPT Fusion SAS 3.0 Device Driver" -#define MPT3SAS_DRIVER_VERSION "01.100.01.00" -#define MPT3SAS_MAJOR_VERSION 1 +#define MPT3SAS_DRIVER_VERSION "02.100.00.00" +#define MPT3SAS_MAJOR_VERSION 2 #define MPT3SAS_MINOR_VERSION 100 -#define MPT3SAS_BUILD_VERSION 1 +#define MPT3SAS_BUILD_VERSION 0 #define MPT3SAS_RELEASE_VERSION 00 /* From 518d9df87105a078984c90c75cf6e7f67e3c928c Mon Sep 17 00:00:00 2001 From: Akinobu Mita Date: Sat, 29 Jun 2013 17:59:14 +0900 Subject: [PATCH 0693/1048] [SCSI] scsi_debug: fix invalid address passed to kunmap_atomic() In the function prot_verify_write(), the kmap address 'daddr' is incremented in the loop for each data page. Finally 'daddr' reaches the next page boundary in the end of the loop, and the invalid address is passed to kunmap_atomic(). Fix the issue by not incrementing 'daddr' in the loop and offsetting it by the loop counter on demand. Signed-off-by: Akinobu Mita Acked-by: Douglas Gilbert Acked-by: "Martin K. Petersen" Signed-off-by: James Bottomley --- drivers/scsi/scsi_debug.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c index 0a537a0515ca..d51bddde5b1f 100644 --- a/drivers/scsi/scsi_debug.c +++ b/drivers/scsi/scsi_debug.c @@ -1899,7 +1899,7 @@ static int prot_verify_write(struct scsi_cmnd *SCpnt, sector_t start_sec, daddr = kmap_atomic(sg_page(dsgl)) + dsgl->offset; /* For each sector-sized chunk in data page */ - for (j = 0 ; j < dsgl->length ; j += scsi_debug_sector_size) { + for (j = 0; j < dsgl->length; j += scsi_debug_sector_size) { /* If we're at the end of the current * protection page advance to the next one @@ -1917,11 +1917,11 @@ static int prot_verify_write(struct scsi_cmnd *SCpnt, sector_t start_sec, switch (scsi_debug_guard) { case 1: - csum = ip_compute_csum(daddr, + csum = ip_compute_csum(daddr + j, scsi_debug_sector_size); break; case 0: - csum = cpu_to_be16(crc_t10dif(daddr, + csum = cpu_to_be16(crc_t10dif(daddr + j, scsi_debug_sector_size)); break; default: @@ -1938,7 +1938,7 @@ static int prot_verify_write(struct scsi_cmnd *SCpnt, sector_t start_sec, be16_to_cpu(sdt->guard_tag), be16_to_cpu(csum)); ret = 0x01; - dump_sector(daddr, scsi_debug_sector_size); + dump_sector(daddr + j, scsi_debug_sector_size); goto out; } @@ -1949,7 +1949,7 @@ static int prot_verify_write(struct scsi_cmnd *SCpnt, sector_t start_sec, "%s: REF check failed on sector %lu\n", __func__, (unsigned long)sector); ret = 0x03; - dump_sector(daddr, scsi_debug_sector_size); + dump_sector(daddr + j, scsi_debug_sector_size); goto out; } @@ -1959,7 +1959,7 @@ static int prot_verify_write(struct scsi_cmnd *SCpnt, sector_t start_sec, "%s: REF check failed on sector %lu\n", __func__, (unsigned long)sector); ret = 0x03; - dump_sector(daddr, scsi_debug_sector_size); + dump_sector(daddr + j, scsi_debug_sector_size); goto out; } @@ -1977,7 +1977,6 @@ static int prot_verify_write(struct scsi_cmnd *SCpnt, sector_t start_sec, start_sec++; ei_lba++; - daddr += scsi_debug_sector_size; ppage_offset += sizeof(struct sd_dif_tuple); } From fc3fc352b6e7a6452596f8a13cedeaa6bcfe9689 Mon Sep 17 00:00:00 2001 From: Akinobu Mita Date: Sat, 29 Jun 2013 17:59:15 +0900 Subject: [PATCH 0694/1048] [SCSI] scsi_debug: fix incorrectly nested kmap_atomic() In the function prot_verify_write(), kmap_atomic()/kunmap_atomic() for data page and kmap_atomic()/kunmap_atomic() for protection information page are not nested each other. It worked perfectly before commit 3e4d3af501cccdc8a8cca41bdbe57d54ad7e7e73 ("mm: stack based kmap_atomic()"). Because the kmap_atomic slot KM_IRQ0 was used for data page and the slot KM_IRQ1 was used for protection page. But KM_types are gone and kmap_atomic() is using stack based implementation. So two different kmap_atomic() usages must be strictly nested now. This change ensures kmap_atomic() usage is strictly nested. Signed-off-by: Akinobu Mita Acked-by: Douglas Gilbert Acked-by: "Martin K. Petersen" Signed-off-by: James Bottomley --- drivers/scsi/scsi_debug.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c index d51bddde5b1f..bcf73e44d2fb 100644 --- a/drivers/scsi/scsi_debug.c +++ b/drivers/scsi/scsi_debug.c @@ -1891,12 +1891,12 @@ static int prot_verify_write(struct scsi_cmnd *SCpnt, sector_t start_sec, BUG_ON(scsi_sg_count(SCpnt) == 0); BUG_ON(scsi_prot_sg_count(SCpnt) == 0); - paddr = kmap_atomic(sg_page(psgl)) + psgl->offset; ppage_offset = 0; /* For each data page */ scsi_for_each_sg(SCpnt, dsgl, scsi_sg_count(SCpnt), i) { daddr = kmap_atomic(sg_page(dsgl)) + dsgl->offset; + paddr = kmap_atomic(sg_page(psgl)) + psgl->offset; /* For each sector-sized chunk in data page */ for (j = 0; j < dsgl->length; j += scsi_debug_sector_size) { @@ -1980,19 +1980,18 @@ static int prot_verify_write(struct scsi_cmnd *SCpnt, sector_t start_sec, ppage_offset += sizeof(struct sd_dif_tuple); } + kunmap_atomic(paddr); kunmap_atomic(daddr); } - kunmap_atomic(paddr); - dix_writes++; return 0; out: dif_errors++; - kunmap_atomic(daddr); kunmap_atomic(paddr); + kunmap_atomic(daddr); return ret; } From 7cb69d0397233546d82191e524235fdb9d1d91aa Mon Sep 17 00:00:00 2001 From: Akinobu Mita Date: Sat, 29 Jun 2013 17:59:16 +0900 Subject: [PATCH 0695/1048] [SCSI] scsi_debug: fix NULL pointer dereference with parameters dif=0 dix=1 The protection info dif_storep is allocated only when parameter dif is not zero. But it will be accessed when reading or writing to the storage installed with parameter dix is not zero. So kernel crashes if scsi_debug module is loaded with parameters dix=1 and dif=0. This fixes it by making dif_storep available if parameter dix is not zero instead of checking if parameter dif is not zero. Signed-off-by: Akinobu Mita Acked-by: Douglas Gilbert Acked-by: "Martin K. Petersen" Signed-off-by: James Bottomley --- drivers/scsi/scsi_debug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c index bcf73e44d2fb..e83e661b0257 100644 --- a/drivers/scsi/scsi_debug.c +++ b/drivers/scsi/scsi_debug.c @@ -3372,7 +3372,7 @@ static int __init scsi_debug_init(void) if (scsi_debug_num_parts > 0) sdebug_build_parts(fake_storep, sz); - if (scsi_debug_dif) { + if (scsi_debug_dix) { int dif_size; dif_size = sdebug_store_sectors * sizeof(struct sd_dif_tuple); From e9926b4376544d5a2dc4d310d4d0006c634b1a93 Mon Sep 17 00:00:00 2001 From: Akinobu Mita Date: Sat, 29 Jun 2013 17:59:17 +0900 Subject: [PATCH 0696/1048] [SCSI] scsi_debug: invalidate protection info for unmapped region When UNMAP command is issued with the data integrity support enabled, the protection info for the unmapped region is remain unchanged. So READ command for the region later on causes data integrity failure. This fixes it by invalidating protection info for the unmapped region by filling with 0xff pattern. Signed-off-by: Akinobu Mita Acked-by: Douglas Gilbert Acked-by: "Martin K. Petersen" Signed-off-by: James Bottomley --- drivers/scsi/scsi_debug.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c index e83e661b0257..83efec2919b1 100644 --- a/drivers/scsi/scsi_debug.c +++ b/drivers/scsi/scsi_debug.c @@ -2064,6 +2064,11 @@ static void unmap_region(sector_t lba, unsigned int len) scsi_debug_sector_size * scsi_debug_unmap_granularity); } + if (dif_storep) { + memset(dif_storep + lba, 0xff, + sizeof(*dif_storep) * + scsi_debug_unmap_granularity); + } } lba = map_index_to_lba(index + 1); } From e18d8bea33077d259cc826c6d3fa76d36af61876 Mon Sep 17 00:00:00 2001 From: Akinobu Mita Date: Sat, 29 Jun 2013 17:59:18 +0900 Subject: [PATCH 0697/1048] [SCSI] scsi_debug: simplify offset calculation for dif_storep dif_storep is declared as pointer to unsigned char type. But it is actually used to store vmalloced array of struct sd_dif_tuple. This changes the type of dif_storep to the pointer to struct sd_dif_tuple. It simplifies offset calculation for dif_storep and enables to remove hardcoded size of struct sd_dif_tuple. Signed-off-by: Akinobu Mita Acked-by: Douglas Gilbert Acked-by: "Martin K. Petersen" Signed-off-by: James Bottomley --- drivers/scsi/scsi_debug.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c index 83efec2919b1..fc8b3aa083d4 100644 --- a/drivers/scsi/scsi_debug.c +++ b/drivers/scsi/scsi_debug.c @@ -258,7 +258,7 @@ struct sdebug_queued_cmd { static struct sdebug_queued_cmd queued_arr[SCSI_DEBUG_CANQUEUE]; static unsigned char * fake_storep; /* ramdisk storage */ -static unsigned char *dif_storep; /* protection info */ +static struct sd_dif_tuple *dif_storep; /* protection info */ static void *map_storep; /* provisioning map */ static unsigned long map_size; @@ -277,11 +277,6 @@ static char sdebug_proc_name[] = "scsi_debug"; static struct bus_type pseudo_lld_bus; -static inline sector_t dif_offset(sector_t sector) -{ - return sector << 3; -} - static struct device_driver sdebug_driverfs_driver = { .name = sdebug_proc_name, .bus = &pseudo_lld_bus, @@ -1727,7 +1722,7 @@ static int prot_verify_read(struct scsi_cmnd *SCpnt, sector_t start_sec, start_sec = do_div(tmp_sec, sdebug_store_sectors); - sdt = (struct sd_dif_tuple *)(dif_storep + dif_offset(start_sec)); + sdt = dif_storep + start_sec; for (i = 0 ; i < sectors ; i++) { u16 csum; @@ -1782,16 +1777,17 @@ static int prot_verify_read(struct scsi_cmnd *SCpnt, sector_t start_sec, ei_lba++; } - resid = sectors * 8; /* Bytes of protection data to copy into sgl */ + /* Bytes of protection data to copy into sgl */ + resid = sectors * sizeof(*dif_storep); sector = start_sec; scsi_for_each_prot_sg(SCpnt, psgl, scsi_prot_sg_count(SCpnt), i) { int len = min(psgl->length, resid); paddr = kmap_atomic(sg_page(psgl)) + psgl->offset; - memcpy(paddr, dif_storep + dif_offset(sector), len); + memcpy(paddr, dif_storep + sector, len); - sector += len >> 3; + sector += len / sizeof(*dif_storep); if (sector >= sdebug_store_sectors) { /* Force wrap */ tmp_sec = sector; @@ -1968,7 +1964,7 @@ static int prot_verify_write(struct scsi_cmnd *SCpnt, sector_t start_sec, * correctness we need to verify each sector * before writing it to "stable" storage */ - memcpy(dif_storep + dif_offset(sector), sdt, 8); + memcpy(dif_storep + sector, sdt, sizeof(*sdt)); sector++; From 9d8812df35be58a5da0c44182c1e4ba2507cc6a7 Mon Sep 17 00:00:00 2001 From: Olof Johansson Date: Tue, 9 Jul 2013 01:31:23 -0700 Subject: [PATCH 0698/1048] ARM: omap2: add select of TI_PRIV_EDMA "ARM: OMAP: build mach-omap code only if needed" moved around the ARCH_OMAP2PLUS stanza, but accidentally dropped the seleciton of TI_PRIV_EDMA in the process. Add it back. Cc: Arnd Bergmann Cc: Tony Lindgren Signed-off-by: Olof Johansson --- arch/arm/mach-omap2/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm/mach-omap2/Kconfig b/arch/arm/mach-omap2/Kconfig index 5c1405157bb6..58152b15ecaa 100644 --- a/arch/arm/mach-omap2/Kconfig +++ b/arch/arm/mach-omap2/Kconfig @@ -99,6 +99,7 @@ config ARCH_OMAP2PLUS select PROC_DEVICETREE if PROC_FS select SOC_BUS select SPARSE_IRQ + select TI_PRIV_EDMA select USE_OF help Systems based on OMAP2, OMAP3, OMAP4 or OMAP5 From 8c69d7af12265e5be9326110b695e010b47505bd Mon Sep 17 00:00:00 2001 From: Stephen Warren Date: Fri, 5 Jul 2013 22:59:42 +0100 Subject: [PATCH 0699/1048] ARM: 7780/1: add missing linker section markup to head-common.S Macro __INIT is used to place various code in head-common.S into the init section. This should be matched by a closing __FINIT. Also, add an explicit ".text" to ensure subsequent code is placed into the correct section; __FINIT is simply a closing marker to match __INIT and doesn't guarantee to revert to .text. This historically caused no problem, because macro __CPUINIT was used at the exact location where __FINIT was missing, which then placed following code into the cpuinit section. However, with commit 22f0a2736 "init.h: remove __cpuinit sections from the kernel" applied, __CPUINIT becomes a no-op, thus leaving all this code in the init section, rather than the regular text section. This caused issues such as secondary CPU boot failures or crashes. Signed-off-by: Stephen Warren Acked-by: Paul Gortmaker Signed-off-by: Russell King --- arch/arm/kernel/head-common.S | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/arm/kernel/head-common.S b/arch/arm/kernel/head-common.S index 5b391a689b47..76ab5ca50610 100644 --- a/arch/arm/kernel/head-common.S +++ b/arch/arm/kernel/head-common.S @@ -133,6 +133,9 @@ ENTRY(lookup_processor_type) ldmfd sp!, {r4 - r6, r9, pc} ENDPROC(lookup_processor_type) + __FINIT + .text + /* * Read processor ID register (CP#15, CR0), and look up in the linker-built * supported processor list. Note that we can't use the absolute addresses From ee4de5d99aeac44f4507b7538b2b3faedc5205b9 Mon Sep 17 00:00:00 2001 From: Stephen Boyd Date: Sat, 6 Jul 2013 00:25:51 +0100 Subject: [PATCH 0700/1048] ARM: 7781/1: mmu: Add debug_ll_io_init() mappings to early mappings Failure to add the mapping created in debug_ll_io_init() can lead to the BUG_ON() triggering in lib/ioremap.c:27 if the static virtual address decided for the debug_ll mapping overlaps with another mapping that is created later. This happens because the generic ioremap code has no idea there is a mapping there and it tries to place a mapping in the same location and blows up when it sees that there is a pte already present. kernel BUG at lib/ioremap.c:27! Internal error: Oops - BUG: 0 [#1] PREEMPT SMP ARM Modules linked in: CPU: 0 PID: 1 Comm: swapper/0 Not tainted 3.10.0-rc2-00042-g2af0c67-dirty #316 task: ef088000 ti: ef082000 task.ti: ef082000 PC is at ioremap_page_range+0x16c/0x198 LR is at ioremap_page_range+0xf0/0x198 pc : [] lr : [] psr: 20000113 sp : ef083e78 ip : af140000 fp : ef083ebc r10: ef7fc100 r9 : ef7fc104 r8 : 000af174 r7 : 00000647 r6 : beffffff r5 : f004c000 r4 : f0040000 r3 : af173417 r2 : 16440653 r1 : af173e07 r0 : ef7fc8fc Flags: nzCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment kernel Control: 10c5787d Table: 8020406a DAC: 00000015 Process swapper/0 (pid: 1, stack limit = 0xef082238) Stack: (0xef083e78 to 0xef084000) 3e60: 00040000 ef083eec 3e80: bf134000 f004bfff c0207c00 f004c000 c02fc120 f000c000 c15e7800 00040000 3ea0: ef083eec 00000647 c098ba9c c0953544 ef083edc ef083ec0 c021b82c c04cb714 3ec0: c09cdc50 00000040 ef0f1e00 ef1003c0 ef083f14 ef083ee0 c09535bc c021b7bc 3ee0: c0953544 c04d0c6c c094e2cc c1600be4 c07440c4 c09a6888 00000002 c0a15f00 3f00: ef082000 00000000 ef083f54 ef083f18 c0208728 c0953550 00000002 c1600bfc 3f20: c08e3fac c0839918 ef083f54 c1600b80 c09a6888 c0a15f00 0000008b c094e2cc 3f40: c098ba9c c098bab8 ef083f94 ef083f58 c094ea0c c020865c 00000002 00000002 3f60: c094e2cc 00000000 c025b674 00000000 c06ff860 00000000 00000000 00000000 3f80: 00000000 00000000 ef083fac ef083f98 c06ff878 c094e910 00000000 00000000 3fa0: 00000000 ef083fb0 c020efe8 c06ff86c 00000000 00000000 00000000 00000000 3fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 3fe0: 00000000 00000000 00000000 00000000 00000013 00000000 00000000 c0595108 [] (ioremap_page_range+0x16c/0x198) from [] (__alloc_remap_buffer.isra.18+0x7c/0xc4) [] (__alloc_remap_buffer.isra.18+0x7c/0xc4) from [] (atomic_pool_init+0x78/0x128) [] (atomic_pool_init+0x78/0x128) from [] (do_one_initcall+0xd8/0x198) [] (do_one_initcall+0xd8/0x198) from [] (kernel_init_freeable+0x108/0x1d0) [] (kernel_init_freeable+0x108/0x1d0) from [] (kernel_init+0x18/0xf4) [] (kernel_init+0x18/0xf4) from [] (ret_from_fork+0x14/0x20) Code: e50b0040 ebf54b2f e51b0040 eaffffee (e7f001f2) Fix it by telling generic layers about the static mapping via iotable_init(). This also has the nice side effect of letting you see the mapping in procfs' vmallocinfo file. Cc: Rob Herring Cc: Stephen Warren Signed-off-by: Stephen Boyd Signed-off-by: Russell King --- arch/arm/mm/mmu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c index 4d409e6a552d..f6ad0182df40 100644 --- a/arch/arm/mm/mmu.c +++ b/arch/arm/mm/mmu.c @@ -949,7 +949,7 @@ void __init debug_ll_io_init(void) map.virtual &= PAGE_MASK; map.length = PAGE_SIZE; map.type = MT_DEVICE; - create_mapping(&map); + iotable_init(&map, 1); } #endif From 319e0b4f02f73983c03a2ca38595fc6367929edf Mon Sep 17 00:00:00 2001 From: Russell King Date: Tue, 9 Jul 2013 09:52:55 +0100 Subject: [PATCH 0701/1048] ARM: mm: fix boot on SA1110 Assabet Commit 83db0384 (mm/ARM: use common help functions to free reserved pages) broke booting on the Assabet by trying to convert a PFN to a virtual address using the __va() macro. This macro takes the physical address, not a PFN. Fix this. Cc: # 3.10 Signed-off-by: Russell King --- arch/arm/mm/init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c index 9a5cdc01fcdf..0ecc43fd6229 100644 --- a/arch/arm/mm/init.c +++ b/arch/arm/mm/init.c @@ -600,7 +600,7 @@ void __init mem_init(void) #ifdef CONFIG_SA1111 /* now that our DMA memory is actually so designated, we can free it */ - free_reserved_area(__va(PHYS_PFN_OFFSET), swapper_pg_dir, 0, NULL); + free_reserved_area(__va(PHYS_OFFSET), swapper_pg_dir, 0, NULL); #endif free_highpages(); From beb40ea42bd65511bc275a7d58d3753835906be5 Mon Sep 17 00:00:00 2001 From: Akinobu Mita Date: Sat, 29 Jun 2013 17:59:19 +0900 Subject: [PATCH 0702/1048] [SCSI] scsi_debug: reduce duplication between prot_verify_read and prot_verify_write In order to reduce code duplication between prot_verify_read() and prot_verify_write(), this moves common code into the new functions. [jejb: fix unitialised variable warning] Signed-off-by: Akinobu Mita Acked-by: Douglas Gilbert Acked-by: "Martin K. Petersen" Signed-off-by: James Bottomley --- drivers/scsi/scsi_debug.c | 137 +++++++++++++++----------------------- 1 file changed, 52 insertions(+), 85 deletions(-) diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c index fc8b3aa083d4..3f096a6681ac 100644 --- a/drivers/scsi/scsi_debug.c +++ b/drivers/scsi/scsi_debug.c @@ -1710,6 +1710,50 @@ static int do_device_access(struct scsi_cmnd *scmd, return ret; } +static u16 dif_compute_csum(const void *buf, int len) +{ + u16 csum; + + switch (scsi_debug_guard) { + case 1: + csum = ip_compute_csum(buf, len); + break; + case 0: + csum = cpu_to_be16(crc_t10dif(buf, len)); + break; + } + return csum; +} + +static int dif_verify(struct sd_dif_tuple *sdt, const void *data, + sector_t sector, u32 ei_lba) +{ + u16 csum = dif_compute_csum(data, scsi_debug_sector_size); + + if (sdt->guard_tag != csum) { + pr_err("%s: GUARD check failed on sector %lu rcvd 0x%04x, data 0x%04x\n", + __func__, + (unsigned long)sector, + be16_to_cpu(sdt->guard_tag), + be16_to_cpu(csum)); + return 0x01; + } + if (scsi_debug_dif == SD_DIF_TYPE1_PROTECTION && + be32_to_cpu(sdt->ref_tag) != (sector & 0xffffffff)) { + pr_err("%s: REF check failed on sector %lu\n", + __func__, (unsigned long)sector); + return 0x03; + } + if (scsi_debug_dif == SD_DIF_TYPE2_PROTECTION && + be32_to_cpu(sdt->ref_tag) != ei_lba) { + pr_err("%s: REF check failed on sector %lu\n", + __func__, (unsigned long)sector); + dif_errors++; + return 0x03; + } + return 0; +} + static int prot_verify_read(struct scsi_cmnd *SCpnt, sector_t start_sec, unsigned int sectors, u32 ei_lba) { @@ -1725,53 +1769,19 @@ static int prot_verify_read(struct scsi_cmnd *SCpnt, sector_t start_sec, sdt = dif_storep + start_sec; for (i = 0 ; i < sectors ; i++) { - u16 csum; + int ret; if (sdt[i].app_tag == 0xffff) continue; sector = start_sec + i; - switch (scsi_debug_guard) { - case 1: - csum = ip_compute_csum(fake_storep + - sector * scsi_debug_sector_size, - scsi_debug_sector_size); - break; - case 0: - csum = crc_t10dif(fake_storep + - sector * scsi_debug_sector_size, - scsi_debug_sector_size); - csum = cpu_to_be16(csum); - break; - default: - BUG(); - } - - if (sdt[i].guard_tag != csum) { - printk(KERN_ERR "%s: GUARD check failed on sector %lu" \ - " rcvd 0x%04x, data 0x%04x\n", __func__, - (unsigned long)sector, - be16_to_cpu(sdt[i].guard_tag), - be16_to_cpu(csum)); + ret = dif_verify(&sdt[i], + fake_storep + sector * scsi_debug_sector_size, + sector, ei_lba); + if (ret) { dif_errors++; - return 0x01; - } - - if (scsi_debug_dif == SD_DIF_TYPE1_PROTECTION && - be32_to_cpu(sdt[i].ref_tag) != (sector & 0xffffffff)) { - printk(KERN_ERR "%s: REF check failed on sector %lu\n", - __func__, (unsigned long)sector); - dif_errors++; - return 0x03; - } - - if (scsi_debug_dif == SD_DIF_TYPE2_PROTECTION && - be32_to_cpu(sdt[i].ref_tag) != ei_lba) { - printk(KERN_ERR "%s: REF check failed on sector %lu\n", - __func__, (unsigned long)sector); - dif_errors++; - return 0x03; + return ret; } ei_lba++; @@ -1880,7 +1890,6 @@ static int prot_verify_write(struct scsi_cmnd *SCpnt, sector_t start_sec, sector_t tmp_sec = start_sec; sector_t sector; int ppage_offset; - unsigned short csum; sector = do_div(tmp_sec, sdebug_store_sectors); @@ -1911,50 +1920,8 @@ static int prot_verify_write(struct scsi_cmnd *SCpnt, sector_t start_sec, sdt = paddr + ppage_offset; - switch (scsi_debug_guard) { - case 1: - csum = ip_compute_csum(daddr + j, - scsi_debug_sector_size); - break; - case 0: - csum = cpu_to_be16(crc_t10dif(daddr + j, - scsi_debug_sector_size)); - break; - default: - BUG(); - ret = 0; - goto out; - } - - if (sdt->guard_tag != csum) { - printk(KERN_ERR - "%s: GUARD check failed on sector %lu " \ - "rcvd 0x%04x, calculated 0x%04x\n", - __func__, (unsigned long)sector, - be16_to_cpu(sdt->guard_tag), - be16_to_cpu(csum)); - ret = 0x01; - dump_sector(daddr + j, scsi_debug_sector_size); - goto out; - } - - if (scsi_debug_dif == SD_DIF_TYPE1_PROTECTION && - be32_to_cpu(sdt->ref_tag) - != (start_sec & 0xffffffff)) { - printk(KERN_ERR - "%s: REF check failed on sector %lu\n", - __func__, (unsigned long)sector); - ret = 0x03; - dump_sector(daddr + j, scsi_debug_sector_size); - goto out; - } - - if (scsi_debug_dif == SD_DIF_TYPE2_PROTECTION && - be32_to_cpu(sdt->ref_tag) != ei_lba) { - printk(KERN_ERR - "%s: REF check failed on sector %lu\n", - __func__, (unsigned long)sector); - ret = 0x03; + ret = dif_verify(sdt, daddr + j, start_sec, ei_lba); + if (ret) { dump_sector(daddr + j, scsi_debug_sector_size); goto out; } From fec3c1b4575431e2020c5c6502d18b281925ca45 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Sat, 29 Jun 2013 00:21:04 +0300 Subject: [PATCH 0703/1048] [SCSI] megaraid_sas: fix a bug for 64 bit arches On 64 bit then -1UL and -1U are not equal, so these conditions don't work as intended and it breaks error handling. Signed-off-by: Dan Carpenter Acked-by: Sumit Saxena Signed-off-by: James Bottomley --- drivers/scsi/megaraid/megaraid_sas_fp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/megaraid/megaraid_sas_fp.c b/drivers/scsi/megaraid/megaraid_sas_fp.c index 8056eacba758..4f401f753f8e 100644 --- a/drivers/scsi/megaraid/megaraid_sas_fp.c +++ b/drivers/scsi/megaraid/megaraid_sas_fp.c @@ -585,7 +585,7 @@ u8 get_arm(struct megasas_instance *instance, u32 ld, u8 span, u64 stripe, case 1: /* start with logical arm */ arm = get_arm_from_strip(instance, ld, stripe, map); - if (arm != -1UL) + if (arm != -1U) arm *= 2; break; } @@ -637,7 +637,7 @@ static u8 mr_spanset_get_phy_params(struct megasas_instance *instance, u32 ld, if (raid->level == 6) { logArm = get_arm_from_strip(instance, ld, stripRow, map); - if (logArm == -1UL) + if (logArm == -1U) return FALSE; rowMod = mega_mod64(row, SPAN_ROW_SIZE(map, ld, span)); armQ = SPAN_ROW_SIZE(map, ld, span) - 1 - rowMod; From e2eb7244bc9e4fd130fc8a961224968e22ba48ee Mon Sep 17 00:00:00 2001 From: James Bottomley Date: Tue, 2 Jul 2013 15:05:26 +0200 Subject: [PATCH 0704/1048] [SCSI] Fix race between starved list and device removal scsi_run_queue() examines all SCSI devices that are present on the starved list. Since scsi_run_queue() unlocks the SCSI host lock a SCSI device can get removed after it has been removed from the starved list and before its queue is run. Protect against that race condition by holding a reference on the queue while running it. Reported-by: Chanho Min Reviewed-by: Bart Van Assche Signed-off-by: James Bottomley --- drivers/scsi/scsi_lib.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 86d522004a20..df8bd5ab3c0b 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -434,6 +434,8 @@ static void scsi_run_queue(struct request_queue *q) list_splice_init(&shost->starved_list, &starved_list); while (!list_empty(&starved_list)) { + struct request_queue *slq; + /* * As long as shost is accepting commands and we have * starved queues, call blk_run_queue. scsi_request_fn @@ -456,11 +458,25 @@ static void scsi_run_queue(struct request_queue *q) continue; } - spin_unlock(shost->host_lock); - spin_lock(sdev->request_queue->queue_lock); - __blk_run_queue(sdev->request_queue); - spin_unlock(sdev->request_queue->queue_lock); - spin_lock(shost->host_lock); + /* + * Once we drop the host lock, a racing scsi_remove_device() + * call may remove the sdev from the starved list and destroy + * it and the queue. Mitigate by taking a reference to the + * queue and never touching the sdev again after we drop the + * host lock. Note: if __scsi_remove_device() invokes + * blk_cleanup_queue() before the queue is run from this + * function then blk_run_queue() will return immediately since + * blk_cleanup_queue() marks the queue with QUEUE_FLAG_DYING. + */ + slq = sdev->request_queue; + if (!blk_get_queue(slq)) + continue; + spin_unlock_irqrestore(shost->host_lock, flags); + + blk_run_queue(slq); + blk_put_queue(slq); + + spin_lock_irqsave(shost->host_lock, flags); } /* put any unprocessed entries back */ list_splice(&starved_list, &shost->starved_list); From 0516c08d10835a8f9169051504cbc9929b3a7f3e Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Tue, 2 Jul 2013 15:06:33 +0200 Subject: [PATCH 0705/1048] [SCSI] enable destruction of blocked devices which fail LUN scanning If something goes wrong during LUN scanning, e.g. a transport layer failure occurs, then __scsi_remove_device() can get invoked by the LUN scanning code for a SCSI device in state SDEV_CREATED_BLOCK and before the SCSI device has been added to sysfs (is_visible == 0). Make sure that even in this case the transition into state SDEV_DEL occurs. This avoids that __scsi_remove_device() can get invoked a second time by scsi_forget_host() if this last function is invoked from another thread than the thread that performs LUN scanning. Signed-off-by: Bart Van Assche Signed-off-by: James Bottomley --- drivers/scsi/scsi_lib.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index df8bd5ab3c0b..124392f3091e 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -2193,6 +2193,7 @@ scsi_device_set_state(struct scsi_device *sdev, enum scsi_device_state state) case SDEV_OFFLINE: case SDEV_TRANSPORT_OFFLINE: case SDEV_CANCEL: + case SDEV_CREATED_BLOCK: break; default: goto illegal; From bf51d5e2cda5d36d98e4b46ac7fca9461e512c41 Mon Sep 17 00:00:00 2001 From: Paulo Zanoni Date: Wed, 3 Jul 2013 17:12:13 -0300 Subject: [PATCH 0706/1048] drm/i915: switch disable_power_well default value to 1 Now that the audio driver is using our power well API, everything should be working correctly, so let's give it a try. Signed-off-by: Paulo Zanoni Signed-off-by: Daniel Vetter --- drivers/gpu/drm/i915/i915_drv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c index 062cbda1bf4a..f4af1ca0fb62 100644 --- a/drivers/gpu/drm/i915/i915_drv.c +++ b/drivers/gpu/drm/i915/i915_drv.c @@ -123,10 +123,10 @@ module_param_named(preliminary_hw_support, i915_preliminary_hw_support, int, 060 MODULE_PARM_DESC(preliminary_hw_support, "Enable preliminary hardware support. (default: false)"); -int i915_disable_power_well __read_mostly = 0; +int i915_disable_power_well __read_mostly = 1; module_param_named(disable_power_well, i915_disable_power_well, int, 0600); MODULE_PARM_DESC(disable_power_well, - "Disable the power well when possible (default: false)"); + "Disable the power well when possible (default: true)"); int i915_enable_ips __read_mostly = 1; module_param_named(enable_ips, i915_enable_ips, int, 0600); From 067556084a0e412013af6b0250a3143ae5afde6d Mon Sep 17 00:00:00 2001 From: Xiong Zhang Date: Fri, 5 Jul 2013 18:53:29 +0800 Subject: [PATCH 0707/1048] drm/i915: Correct obj->mm_list link to dev_priv->dev_priv->mm.inactive_list obj->mm_list link to dev_priv->mm.inactive_list/active_list obj->global_list link to dev_priv->mm.unbound_list/bound_list This regression has been introduced in commit 93927ca52a55c23e0a6a305e7e9082e8411ac9fa Author: Daniel Vetter Date: Thu Jan 10 18:03:00 2013 +0100 drm/i915: Revert shrinker changes from "Track unbound pages" Cc: stable@vger.kernel.org Signed-off-by: Xiong Zhang [danvet: Add regression notice.] Signed-off-by: Daniel Vetter --- drivers/gpu/drm/i915/i915_gem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c index 769f75262feb..7f368d79f7d2 100644 --- a/drivers/gpu/drm/i915/i915_gem.c +++ b/drivers/gpu/drm/i915/i915_gem.c @@ -4623,7 +4623,7 @@ i915_gem_inactive_shrink(struct shrinker *shrinker, struct shrink_control *sc) list_for_each_entry(obj, &dev_priv->mm.unbound_list, global_list) if (obj->pages_pin_count == 0) cnt += obj->base.size >> PAGE_SHIFT; - list_for_each_entry(obj, &dev_priv->mm.inactive_list, global_list) + list_for_each_entry(obj, &dev_priv->mm.inactive_list, mm_list) if (obj->pin_count == 0 && obj->pages_pin_count == 0) cnt += obj->base.size >> PAGE_SHIFT; From aaf8a5167291b65e9116cb8736d862965b57c13a Mon Sep 17 00:00:00 2001 From: Daniel Vetter Date: Fri, 5 Jul 2013 23:39:50 +0200 Subject: [PATCH 0708/1048] drm/i915: fix up ring cleanup for the i830/i845 CS tlb w/a It's not a good idea to also run the pipe_control cleanup. This regression has been introduced whith the original cs tlb w/a in commit b45305fce5bb1abec263fcff9d81ebecd6306ede Author: Daniel Vetter Date: Mon Dec 17 16:21:27 2012 +0100 drm/i915: Implement workaround for broken CS tlb on i830/845 Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=64610 Cc: Chris Wilson Cc: stable@vger.kernel.org Reviewed-by: Chris Wilson Signed-off-by: Daniel Vetter --- drivers/gpu/drm/i915/intel_ringbuffer.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.c b/drivers/gpu/drm/i915/intel_ringbuffer.c index 18ca76e3e5ef..664118d8c1d6 100644 --- a/drivers/gpu/drm/i915/intel_ringbuffer.c +++ b/drivers/gpu/drm/i915/intel_ringbuffer.c @@ -534,9 +534,6 @@ cleanup_pipe_control(struct intel_ring_buffer *ring) struct pipe_control *pc = ring->private; struct drm_i915_gem_object *obj; - if (!ring->private) - return; - obj = pc->obj; kunmap(sg_page(obj->pages->sgl)); @@ -544,7 +541,6 @@ cleanup_pipe_control(struct intel_ring_buffer *ring) drm_gem_object_unreference(&obj->base); kfree(pc); - ring->private = NULL; } static int init_render_ring(struct intel_ring_buffer *ring) @@ -617,7 +613,10 @@ static void render_ring_cleanup(struct intel_ring_buffer *ring) if (HAS_BROKEN_CS_TLB(dev)) drm_gem_object_unreference(to_gem_object(ring->private)); - cleanup_pipe_control(ring); + if (INTEL_INFO(dev)->gen >= 5) + cleanup_pipe_control(ring); + + ring->private = NULL; } static void From d4eead50eb206b875f54f66cc0f6ec7d54122c28 Mon Sep 17 00:00:00 2001 From: Imre Deak Date: Tue, 9 Jul 2013 17:05:26 +0300 Subject: [PATCH 0709/1048] drm/i915: fix lane bandwidth capping for DP 1.2 sinks DP 1.2 compatible displays may report a 5.4Gbps maximum bandwidth which the driver will treat as an invalid value and use 1.62Gbps instead. Fix this by capping to 2.7Gbps for sinks reporting a 5.4Gbps max bw. Also add a warning for reserved values. v2: - allow only bw values explicitly listed in the DP standard (Daniel, Chris) Signed-off-by: Imre Deak Signed-off-by: Daniel Vetter --- drivers/gpu/drm/i915/intel_dp.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c index b73971234013..26e162bb3a51 100644 --- a/drivers/gpu/drm/i915/intel_dp.c +++ b/drivers/gpu/drm/i915/intel_dp.c @@ -75,7 +75,12 @@ intel_dp_max_link_bw(struct intel_dp *intel_dp) case DP_LINK_BW_1_62: case DP_LINK_BW_2_7: break; + case DP_LINK_BW_5_4: /* 1.2 capable displays may advertise higher bw */ + max_link_bw = DP_LINK_BW_2_7; + break; default: + WARN(1, "invalid max DP link bw val %x, using 1.62Gbps\n", + max_link_bw); max_link_bw = DP_LINK_BW_1_62; break; } From e0335f67a281cb8eb11868e614ee9390fbbe9b1d Mon Sep 17 00:00:00 2001 From: Mark Rustad Date: Sat, 18 May 2013 04:01:36 +0000 Subject: [PATCH 0710/1048] libfc: Reject PLOGI from nodes with incompatible role Reject a PLOGI from a node with an incompatible role, that is, initiator-to-initiator or target-to-target. Signed-off-by: Mark Rustad Reviewed-by: Yi Zou Tested-by: Jack Morgan Signed-off-by: Robert Love --- drivers/scsi/libfc/fc_rport.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/drivers/scsi/libfc/fc_rport.c b/drivers/scsi/libfc/fc_rport.c index 6bbb9447b75d..c710d908fda6 100644 --- a/drivers/scsi/libfc/fc_rport.c +++ b/drivers/scsi/libfc/fc_rport.c @@ -926,6 +926,20 @@ err: kref_put(&rdata->kref, rdata->local_port->tt.rport_destroy); } +static bool +fc_rport_compatible_roles(struct fc_lport *lport, struct fc_rport_priv *rdata) +{ + if (rdata->ids.roles == FC_PORT_ROLE_UNKNOWN) + return true; + if ((rdata->ids.roles & FC_PORT_ROLE_FCP_TARGET) && + (lport->service_params & FCP_SPPF_INIT_FCN)) + return true; + if ((rdata->ids.roles & FC_PORT_ROLE_FCP_INITIATOR) && + (lport->service_params & FCP_SPPF_TARG_FCN)) + return true; + return false; +} + /** * fc_rport_enter_plogi() - Send Port Login (PLOGI) request * @rdata: The remote port to send a PLOGI to @@ -938,6 +952,12 @@ static void fc_rport_enter_plogi(struct fc_rport_priv *rdata) struct fc_lport *lport = rdata->local_port; struct fc_frame *fp; + if (!fc_rport_compatible_roles(lport, rdata)) { + FC_RPORT_DBG(rdata, "PLOGI suppressed for incompatible role\n"); + fc_rport_state_enter(rdata, RPORT_ST_PLOGI_WAIT); + return; + } + FC_RPORT_DBG(rdata, "Port entered PLOGI state from %s state\n", fc_rport_state(rdata)); @@ -1646,6 +1666,13 @@ static void fc_rport_recv_plogi_req(struct fc_lport *lport, rjt_data.explan = ELS_EXPL_NONE; goto reject; } + if (!fc_rport_compatible_roles(lport, rdata)) { + FC_RPORT_DBG(rdata, "Received PLOGI for incompatible role\n"); + mutex_unlock(&rdata->rp_mutex); + rjt_data.reason = ELS_RJT_LOGIC; + rjt_data.explan = ELS_EXPL_NONE; + goto reject; + } /* * Get session payload size from incoming PLOGI. From f07d46bbc9ba9a08b338dec7bb858977d4d822fb Mon Sep 17 00:00:00 2001 From: Neerav Parikh Date: Sat, 18 May 2013 05:12:28 +0000 Subject: [PATCH 0711/1048] fcoe: Fix smatch warning in fcoe_fdmi_info function This patch fixes a smatch warning as below: smatch warnings: drivers/scsi/fcoe/fcoe.c:782 fcoe_fdmi_info() warn: 'fdmi' puts 896 bytes on stack Reported-by: Fengguang Wu Signed-off-by: Neerav Parikh Tested-by: Jack Morgan Signed-off-by: Robert Love --- drivers/scsi/fcoe/fcoe.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/drivers/scsi/fcoe/fcoe.c b/drivers/scsi/fcoe/fcoe.c index 32ae6c67ea3a..3336e5754930 100644 --- a/drivers/scsi/fcoe/fcoe.c +++ b/drivers/scsi/fcoe/fcoe.c @@ -774,7 +774,6 @@ static void fcoe_fdmi_info(struct fc_lport *lport, struct net_device *netdev) struct fcoe_port *port; struct net_device *realdev; int rc; - struct netdev_fcoe_hbainfo fdmi; port = lport_priv(lport); fcoe = port->priv; @@ -788,9 +787,13 @@ static void fcoe_fdmi_info(struct fc_lport *lport, struct net_device *netdev) return; if (realdev->netdev_ops->ndo_fcoe_get_hbainfo) { - memset(&fdmi, 0, sizeof(fdmi)); + struct netdev_fcoe_hbainfo *fdmi; + fdmi = kzalloc(sizeof(*fdmi), GFP_KERNEL); + if (!fdmi) + return; + rc = realdev->netdev_ops->ndo_fcoe_get_hbainfo(realdev, - &fdmi); + fdmi); if (rc) { printk(KERN_INFO "fcoe: Failed to retrieve FDMI " "information from netdev.\n"); @@ -800,38 +803,39 @@ static void fcoe_fdmi_info(struct fc_lport *lport, struct net_device *netdev) snprintf(fc_host_serial_number(lport->host), FC_SERIAL_NUMBER_SIZE, "%s", - fdmi.serial_number); + fdmi->serial_number); snprintf(fc_host_manufacturer(lport->host), FC_SERIAL_NUMBER_SIZE, "%s", - fdmi.manufacturer); + fdmi->manufacturer); snprintf(fc_host_model(lport->host), FC_SYMBOLIC_NAME_SIZE, "%s", - fdmi.model); + fdmi->model); snprintf(fc_host_model_description(lport->host), FC_SYMBOLIC_NAME_SIZE, "%s", - fdmi.model_description); + fdmi->model_description); snprintf(fc_host_hardware_version(lport->host), FC_VERSION_STRING_SIZE, "%s", - fdmi.hardware_version); + fdmi->hardware_version); snprintf(fc_host_driver_version(lport->host), FC_VERSION_STRING_SIZE, "%s", - fdmi.driver_version); + fdmi->driver_version); snprintf(fc_host_optionrom_version(lport->host), FC_VERSION_STRING_SIZE, "%s", - fdmi.optionrom_version); + fdmi->optionrom_version); snprintf(fc_host_firmware_version(lport->host), FC_VERSION_STRING_SIZE, "%s", - fdmi.firmware_version); + fdmi->firmware_version); /* Enable FDMI lport states */ lport->fdmi_enabled = 1; + kfree(fdmi); } else { lport->fdmi_enabled = 0; printk(KERN_INFO "fcoe: No FDMI support.\n"); From 418a8cfe69c3b6bd4598e9870b9f412e2c247214 Mon Sep 17 00:00:00 2001 From: Yi Zou Date: Sat, 18 May 2013 06:28:17 +0000 Subject: [PATCH 0712/1048] fcoe: fix the link error status block sparse warnings Both fcoe_fc_els_lesb and fc_els_lesb are in __be32 already, and both are exactly the same size in bytes, with somewhat different member names to reflect the fact the former is for Ethernet media the latter is for Fiber Channel, so, remove conversion and use __be32 directly. This fixes the warning from sparse check. Signed-off-by: Yi Zou Reported-by: Fengguang Wu Tested-by: Jack Morgan Signed-off-by: Robert Love --- drivers/scsi/fcoe/fcoe_transport.c | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/drivers/scsi/fcoe/fcoe_transport.c b/drivers/scsi/fcoe/fcoe_transport.c index f3a5a53e8631..bedd42211727 100644 --- a/drivers/scsi/fcoe/fcoe_transport.c +++ b/drivers/scsi/fcoe/fcoe_transport.c @@ -180,24 +180,10 @@ void fcoe_ctlr_get_lesb(struct fcoe_ctlr_device *ctlr_dev) { struct fcoe_ctlr *fip = fcoe_ctlr_device_priv(ctlr_dev); struct net_device *netdev = fcoe_get_netdev(fip->lp); - struct fcoe_fc_els_lesb *fcoe_lesb; - struct fc_els_lesb fc_lesb; + struct fc_els_lesb *fc_lesb; - __fcoe_get_lesb(fip->lp, &fc_lesb, netdev); - fcoe_lesb = (struct fcoe_fc_els_lesb *)(&fc_lesb); - - ctlr_dev->lesb.lesb_link_fail = - ntohl(fcoe_lesb->lesb_link_fail); - ctlr_dev->lesb.lesb_vlink_fail = - ntohl(fcoe_lesb->lesb_vlink_fail); - ctlr_dev->lesb.lesb_miss_fka = - ntohl(fcoe_lesb->lesb_miss_fka); - ctlr_dev->lesb.lesb_symb_err = - ntohl(fcoe_lesb->lesb_symb_err); - ctlr_dev->lesb.lesb_err_block = - ntohl(fcoe_lesb->lesb_err_block); - ctlr_dev->lesb.lesb_fcs_error = - ntohl(fcoe_lesb->lesb_fcs_error); + fc_lesb = (struct fc_els_lesb *)(&ctlr_dev->lesb); + __fcoe_get_lesb(fip->lp, fc_lesb, netdev); } EXPORT_SYMBOL_GPL(fcoe_ctlr_get_lesb); From 4a80f083dd70a200763e77d3eeee48bdf753c7df Mon Sep 17 00:00:00 2001 From: Robert Love Date: Tue, 11 Jun 2013 07:28:03 +0000 Subject: [PATCH 0713/1048] libfc: Remove extra space in fc_exch_timer_cancel definition Simply remove an extra space that violates coding style. Signed-off-by: Robert Love Tested-by: Jack Morgan Acked-by: Neil Horman --- drivers/scsi/libfc/fc_exch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/libfc/fc_exch.c b/drivers/scsi/libfc/fc_exch.c index 8b928c67e4b9..e98ea6af84e0 100644 --- a/drivers/scsi/libfc/fc_exch.c +++ b/drivers/scsi/libfc/fc_exch.c @@ -337,7 +337,7 @@ static void fc_exch_release(struct fc_exch *ep) * fc_exch_timer_cancel() - cancel exch timer * @ep: The exchange whose timer to be canceled */ -static inline void fc_exch_timer_cancel(struct fc_exch *ep) +static inline void fc_exch_timer_cancel(struct fc_exch *ep) { if (cancel_delayed_work(&ep->timeout_work)) { FC_EXCH_DBG(ep, "Exchange timer canceled\n"); From 3a2926054acf876313afaaddac00a8ad255f6d68 Mon Sep 17 00:00:00 2001 From: Robert Love Date: Tue, 11 Jun 2013 07:28:09 +0000 Subject: [PATCH 0714/1048] libfc: Differentiate echange timer cancellation debug statements There are two debug statements with the same output string regarding echange timer cancellation. This patch simply changes the output of one string so that they can be differentiated. Signed-off-by: Robert Love Tested-by: Jack Morgan Acked-by: Neil Horman --- drivers/scsi/libfc/fc_exch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/libfc/fc_exch.c b/drivers/scsi/libfc/fc_exch.c index e98ea6af84e0..587992952b3c 100644 --- a/drivers/scsi/libfc/fc_exch.c +++ b/drivers/scsi/libfc/fc_exch.c @@ -1567,7 +1567,7 @@ static void fc_exch_abts_resp(struct fc_exch *ep, struct fc_frame *fp) fc_exch_rctl_name(fh->fh_r_ctl)); if (cancel_delayed_work_sync(&ep->timeout_work)) { - FC_EXCH_DBG(ep, "Exchange timer canceled\n"); + FC_EXCH_DBG(ep, "Exchange timer canceled due to ABTS response\n"); fc_exch_release(ep); /* release from pending timer hold */ } From a2ceb1fbaa875172345f611a3d37c3662f7e5082 Mon Sep 17 00:00:00 2001 From: Robert Love Date: Tue, 11 Jun 2013 07:28:19 +0000 Subject: [PATCH 0715/1048] libfcoe: Fix meaningless log statement ctlr_dev was initialized to NULL, and never re-assigned. This caused the log statement to always report failure. This patch removes the unused variable and fixes the log statement to always report 'success', as that is what should be logged if the code reaches this point. Signed-off-by: Robert Love Tested-by: Jack Morgan Acked-by: Neil Horman --- drivers/scsi/fcoe/fcoe_transport.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/scsi/fcoe/fcoe_transport.c b/drivers/scsi/fcoe/fcoe_transport.c index bedd42211727..f1ae5edb2de1 100644 --- a/drivers/scsi/fcoe/fcoe_transport.c +++ b/drivers/scsi/fcoe/fcoe_transport.c @@ -707,7 +707,6 @@ ssize_t fcoe_ctlr_create_store(struct bus_type *bus, { struct net_device *netdev = NULL; struct fcoe_transport *ft = NULL; - struct fcoe_ctlr_device *ctlr_dev = NULL; int rc = 0; int err; @@ -754,9 +753,8 @@ ssize_t fcoe_ctlr_create_store(struct bus_type *bus, goto out_putdev; } - LIBFCOE_TRANSPORT_DBG("transport %s %s to create fcoe on %s.\n", - ft->name, (ctlr_dev) ? "succeeded" : "failed", - netdev->name); + LIBFCOE_TRANSPORT_DBG("transport %s succeeded to create fcoe on %s.\n", + ft->name, netdev->name); out_putdev: dev_put(netdev); From d17efa001aacaa774581972230b1a9db1e618ded Mon Sep 17 00:00:00 2001 From: Mark Rustad Date: Sat, 18 May 2013 04:10:07 +0000 Subject: [PATCH 0716/1048] fcoe: Stop fc_rport_priv structure leak When repeatedly doing rmmod and modprobe on the ixgbe driver while FCoE is active in a VN2VN configuration, memory leaks would be discovered by kmemleak with the following backtrace: unreferenced object 0xffff88003d076000 (size 1024): comm "kworker/0:3", pid 2998, jiffies 4295436448 (age 1015.332s) hex dump (first 32 bytes): 48 8a fe 6f 00 88 ff ff 00 00 00 00 00 00 00 00 H..o............ 01 00 00 00 02 00 00 00 7b ac 87 21 1b 00 00 10 ........{..!.... backtrace: [] kmemleak_alloc+0x5b/0xc0 [] __kmalloc+0xd8/0x1b0 [] fc_rport_create+0x48/0x1f0 [libfc] [] fcoe_ctlr_vn_add.isra.10+0x56/0x1a0 [libfcoe] [] fcoe_ctlr_vn_recv+0x8b0/0xab0 [libfcoe] [] fcoe_ctlr_recv_work+0x4c6/0xf60 [libfcoe] [] process_one_work+0x1e4/0x4d0 [] worker_thread+0x10f/0x380 [] kthread+0xea/0xf0 [] ret_from_fork+0x7c/0xb0 [] 0xffffffffffffffff This patch stops the leak of the fc_rport_priv structure. Signed-off-by: Mark Rustad Tested-by: Jack Morgan Signed-off-by: Robert Love --- drivers/scsi/fcoe/fcoe_ctlr.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/scsi/fcoe/fcoe_ctlr.c b/drivers/scsi/fcoe/fcoe_ctlr.c index 795843dde8ec..203415e02518 100644 --- a/drivers/scsi/fcoe/fcoe_ctlr.c +++ b/drivers/scsi/fcoe/fcoe_ctlr.c @@ -2090,7 +2090,11 @@ static struct fc_rport_operations fcoe_ctlr_vn_rport_ops = { */ static void fcoe_ctlr_disc_stop_locked(struct fc_lport *lport) { + struct fc_rport_priv *rdata; + mutex_lock(&lport->disc.disc_mutex); + list_for_each_entry_rcu(rdata, &lport->disc.rports, peers) + lport->tt.rport_logoff(rdata); lport->disc.disc_callback = NULL; mutex_unlock(&lport->disc.disc_mutex); } From 7a5ed75a782a1f2de7fc773981ecd88bfa7595b1 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Tue, 25 Jun 2013 17:49:40 +0000 Subject: [PATCH 0717/1048] fcoe: Reduce number of sparse warnings Declare local variables and functions 'static'. This patch does not change any functionality. Signed-off-by: Bart Van Assche Signed-off-by: Robert Love --- drivers/scsi/fcoe/fcoe_sysfs.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/scsi/fcoe/fcoe_sysfs.c b/drivers/scsi/fcoe/fcoe_sysfs.c index 8c05ae017f5b..c9382d6eee78 100644 --- a/drivers/scsi/fcoe/fcoe_sysfs.c +++ b/drivers/scsi/fcoe/fcoe_sysfs.c @@ -507,7 +507,7 @@ static const struct attribute_group *fcoe_fcf_attr_groups[] = { NULL, }; -struct bus_type fcoe_bus_type; +static struct bus_type fcoe_bus_type; static int fcoe_bus_match(struct device *dev, struct device_driver *drv) @@ -541,25 +541,25 @@ static void fcoe_fcf_device_release(struct device *dev) kfree(fcf); } -struct device_type fcoe_ctlr_device_type = { +static struct device_type fcoe_ctlr_device_type = { .name = "fcoe_ctlr", .groups = fcoe_ctlr_attr_groups, .release = fcoe_ctlr_device_release, }; -struct device_type fcoe_fcf_device_type = { +static struct device_type fcoe_fcf_device_type = { .name = "fcoe_fcf", .groups = fcoe_fcf_attr_groups, .release = fcoe_fcf_device_release, }; -struct bus_attribute fcoe_bus_attr_group[] = { +static struct bus_attribute fcoe_bus_attr_group[] = { __ATTR(ctlr_create, S_IWUSR, NULL, fcoe_ctlr_create_store), __ATTR(ctlr_destroy, S_IWUSR, NULL, fcoe_ctlr_destroy_store), __ATTR_NULL }; -struct bus_type fcoe_bus_type = { +static struct bus_type fcoe_bus_type = { .name = "fcoe", .match = &fcoe_bus_match, .bus_attrs = fcoe_bus_attr_group, @@ -569,7 +569,7 @@ struct bus_type fcoe_bus_type = { * fcoe_ctlr_device_flush_work() - Flush a FIP ctlr's workqueue * @ctlr: Pointer to the FIP ctlr whose workqueue is to be flushed */ -void fcoe_ctlr_device_flush_work(struct fcoe_ctlr_device *ctlr) +static void fcoe_ctlr_device_flush_work(struct fcoe_ctlr_device *ctlr) { if (!fcoe_ctlr_work_q(ctlr)) { printk(KERN_ERR @@ -590,8 +590,8 @@ void fcoe_ctlr_device_flush_work(struct fcoe_ctlr_device *ctlr) * Return value: * 1 on success / 0 already queued / < 0 for error */ -int fcoe_ctlr_device_queue_work(struct fcoe_ctlr_device *ctlr, - struct work_struct *work) +static int fcoe_ctlr_device_queue_work(struct fcoe_ctlr_device *ctlr, + struct work_struct *work) { if (unlikely(!fcoe_ctlr_work_q(ctlr))) { printk(KERN_ERR @@ -609,7 +609,7 @@ int fcoe_ctlr_device_queue_work(struct fcoe_ctlr_device *ctlr, * fcoe_ctlr_device_flush_devloss() - Flush a FIP ctlr's devloss workqueue * @ctlr: Pointer to FIP ctlr whose workqueue is to be flushed */ -void fcoe_ctlr_device_flush_devloss(struct fcoe_ctlr_device *ctlr) +static void fcoe_ctlr_device_flush_devloss(struct fcoe_ctlr_device *ctlr) { if (!fcoe_ctlr_devloss_work_q(ctlr)) { printk(KERN_ERR @@ -631,9 +631,9 @@ void fcoe_ctlr_device_flush_devloss(struct fcoe_ctlr_device *ctlr) * Return value: * 1 on success / 0 already queued / < 0 for error */ -int fcoe_ctlr_device_queue_devloss_work(struct fcoe_ctlr_device *ctlr, - struct delayed_work *work, - unsigned long delay) +static int fcoe_ctlr_device_queue_devloss_work(struct fcoe_ctlr_device *ctlr, + struct delayed_work *work, + unsigned long delay) { if (unlikely(!fcoe_ctlr_devloss_work_q(ctlr))) { printk(KERN_ERR From a69c7c077228b0bef38ccb1d385c099e132fe54b Mon Sep 17 00:00:00 2001 From: Eric Sandeen Date: Wed, 28 Mar 2012 12:21:11 -0500 Subject: [PATCH 0718/1048] xfs: use XFS_BMAP_BMDR_SPACE vs. XFS_BROOT_SIZE_ADJ XFS_BROOT_SIZE_ADJ is an undocumented macro which accounts for the difference in size between the on-disk and in-core btree root. It's much clearer to just use the newly-added XFS_BMAP_BMDR_SPACE macro which gives us the on-disk size directly. In one case, we must test that the if_broot exists before applying the macro, however. Signed-off-by: Eric Sandeen Reviewed-by: Dave Chinner Reviewed-by: Ben Myers Signed-off-by: Ben Myers --- fs/xfs/xfs_dinode.h | 3 --- fs/xfs/xfs_inode.c | 14 +++++++------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/fs/xfs/xfs_dinode.h b/fs/xfs/xfs_dinode.h index f7a0e95d197a..07d735a80a0f 100644 --- a/fs/xfs/xfs_dinode.h +++ b/fs/xfs/xfs_dinode.h @@ -132,9 +132,6 @@ typedef enum xfs_dinode_fmt { #define XFS_LITINO(mp, version) \ ((int)(((mp)->m_sb.sb_inodesize) - xfs_dinode_size(version))) -#define XFS_BROOT_SIZE_ADJ(ip) \ - (XFS_BMBT_BLOCK_LEN((ip)->i_mount) - sizeof(xfs_bmdr_block_t)) - /* * Inode data & attribute fork sizes, per inode. */ diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index 9ecfe1e559fc..b78481f99d9d 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -2156,8 +2156,8 @@ xfs_iroot_realloc( np = (char *)XFS_BMAP_BROOT_PTR_ADDR(mp, ifp->if_broot, 1, (int)new_size); ifp->if_broot_bytes = (int)new_size; - ASSERT(ifp->if_broot_bytes <= - XFS_IFORK_SIZE(ip, whichfork) + XFS_BROOT_SIZE_ADJ(ip)); + ASSERT(XFS_BMAP_BMDR_SPACE(ifp->if_broot) <= + XFS_IFORK_SIZE(ip, whichfork)); memmove(np, op, cur_max * (uint)sizeof(xfs_dfsbno_t)); return; } @@ -2210,8 +2210,9 @@ xfs_iroot_realloc( kmem_free(ifp->if_broot); ifp->if_broot = new_broot; ifp->if_broot_bytes = (int)new_size; - ASSERT(ifp->if_broot_bytes <= - XFS_IFORK_SIZE(ip, whichfork) + XFS_BROOT_SIZE_ADJ(ip)); + if (ifp->if_broot) + ASSERT(XFS_BMAP_BMDR_SPACE(ifp->if_broot) <= + XFS_IFORK_SIZE(ip, whichfork)); return; } @@ -2522,9 +2523,8 @@ xfs_iflush_fork( if ((iip->ili_fields & brootflag[whichfork]) && (ifp->if_broot_bytes > 0)) { ASSERT(ifp->if_broot != NULL); - ASSERT(ifp->if_broot_bytes <= - (XFS_IFORK_SIZE(ip, whichfork) + - XFS_BROOT_SIZE_ADJ(ip))); + ASSERT(XFS_BMAP_BMDR_SPACE(ifp->if_broot) <= + XFS_IFORK_SIZE(ip, whichfork)); xfs_bmbt_to_bmdr(mp, ifp->if_broot, ifp->if_broot_bytes, (xfs_bmdr_block_t *)cp, XFS_DFORK_SIZE(dip, mp, whichfork)); From a363a9da65d253fa7354ce5fd630f4f94df934cc Mon Sep 17 00:00:00 2001 From: Michael Witten Date: Wed, 17 Apr 2013 02:23:16 +0000 Subject: [PATCH 0719/1048] perf tools: Revert regression in configuration of Python support Among other things, the following: commit 31160d7feab786c991780d7f0ce2755a469e0e5e Date: Tue Jan 8 16:22:36 2013 -0500 perf tools: Fix GNU make v3.80 compatibility issue attempts to aid the user by tapping into an existing error message, as described in the commit message: ... Also fix an issue where _get_attempt was called with only one argument. This prevented the error message from printing the name of the variable that can be used to fix the problem. or more precisely: -$(if $($(1)),$(call _ge_attempt,$($(1)),$(1)),$(call _ge_attempt,$(2))) +$(if $($(1)),$(call _ge_attempt,$($(1)),$(1)),$(call _ge_attempt,$(2),$(1))) However, The "missing" argument was in fact missing on purpose; it's absence is a signal that the error message should be skipped, because the failure would be due to the default value, not any user-supplied value. This can be seen in how `_ge_attempt' uses `gea_err' (in the config/utilities.mak file): _ge_attempt = $(if $(get-executable),$(get-executable),$(_gea_warn)$(call _gea_err,$(2))) _gea_warn = $(warning The path '$(1)' is not executable.) _gea_err = $(if $(1),$(error Please set '$(1)' appropriately)) That is, because the argument is no longer missing, the value `$(1)' (associated with `_gea_err') always evaluates to true, thus always triggering the error condition that is meant to be reserved for only the case when a user explicitly supplies an invalid value. Concretely, the result is a regression in the Makefile's configuration of python support; rather than gracefully disable support when the relevant executables cannot be found according to default values, the build process halts in error as though the user explicitly supplied the values. This new commit simply reverts the offending one-line change. Reported-by: Pekka Enberg Link: http://lkml.kernel.org/r/CAOJsxLHv17Ys3M7P5q25imkUxQW6LE_vABxh1N3Tt7Mv6Ho4iw@mail.gmail.com Signed-off-by: Michael Witten --- tools/perf/config/utilities.mak | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/perf/config/utilities.mak b/tools/perf/config/utilities.mak index faffb52fcf80..94d2d4f9c35d 100644 --- a/tools/perf/config/utilities.mak +++ b/tools/perf/config/utilities.mak @@ -173,7 +173,7 @@ _ge-abspath = $(if $(is-executable),$(1)) # Usage: absolute-executable-path-or-empty = $(call get-executable-or-default,variable,default) # define get-executable-or-default -$(if $($(1)),$(call _ge_attempt,$($(1)),$(1)),$(call _ge_attempt,$(2),$(1))) +$(if $($(1)),$(call _ge_attempt,$($(1)),$(1)),$(call _ge_attempt,$(2))) endef _ge_attempt = $(if $(get-executable),$(get-executable),$(_gea_warn)$(call _gea_err,$(2))) _gea_warn = $(warning The path '$(1)' is not executable.) From 9cee4c5b7b706157554cb06ca949997240da725a Mon Sep 17 00:00:00 2001 From: Jie Liu Date: Mon, 1 Jul 2013 21:51:32 +0800 Subject: [PATCH 0720/1048] xfs: clean up unused codes at xfs_bulkstat() There are some unused codes at xfs_bulkstat(): - Variable bp is defined to point to the on-disk inode cluster buffer, but it proved to be of no practical help. - We process the chunks of good inodes which were fetched by iterating btree records from an AG. When processing inodes from each chunk, the code recomputing agbno if run into the first inode of a cluster, however, the agbno is not being used thereafter. This patch tries to clean up those things. Signed-off-by: Jie Liu Reviewed-by: Dave Chinner Signed-off-by: Ben Myers --- fs/xfs/xfs_itable.c | 28 +--------------------------- 1 file changed, 1 insertion(+), 27 deletions(-) diff --git a/fs/xfs/xfs_itable.c b/fs/xfs/xfs_itable.c index bc92c5306a17..b93e14b86754 100644 --- a/fs/xfs/xfs_itable.c +++ b/fs/xfs/xfs_itable.c @@ -221,7 +221,6 @@ xfs_bulkstat( char __user *ubufp; /* pointer into user's buffer */ int ubelem; /* spaces used in user's buffer */ int ubused; /* bytes used by formatter */ - xfs_buf_t *bp; /* ptr to on-disk inode cluster buf */ /* * Get the last inode value, see if there's nothing to do. @@ -263,7 +262,6 @@ xfs_bulkstat( rval = 0; while (XFS_BULKSTAT_UBLEFT(ubleft) && agno < mp->m_sb.sb_agcount) { cond_resched(); - bp = NULL; error = xfs_ialloc_read_agi(mp, NULL, agno, &agbp); if (error) { /* @@ -436,27 +434,7 @@ xfs_bulkstat( irbp->ir_freecount < XFS_INODES_PER_CHUNK; chunkidx++, clustidx++, agino++) { ASSERT(chunkidx < XFS_INODES_PER_CHUNK); - /* - * Recompute agbno if this is the - * first inode of the cluster. - * - * Careful with clustidx. There can be - * multiple clusters per chunk, a single - * cluster per chunk or a cluster that has - * inodes represented from several different - * chunks (if blocksize is large). - * - * Because of this, the starting clustidx is - * initialized to zero in this loop but must - * later be reset after reading in the cluster - * buffer. - */ - if ((chunkidx & (nicluster - 1)) == 0) { - agbno = XFS_AGINO_TO_AGBNO(mp, - irbp->ir_startino) + - ((chunkidx & nimask) >> - mp->m_sb.sb_inopblog); - } + ino = XFS_AGINO_TO_INO(mp, agno, agino); /* * Skip if this inode is free. @@ -502,10 +480,6 @@ xfs_bulkstat( cond_resched(); } - - if (bp) - xfs_buf_relse(bp); - /* * Set up for the next loop iteration. */ From 862a62937e76a91da218c1ee4dceb7b0700fed67 Mon Sep 17 00:00:00 2001 From: Yann Droneaud Date: Tue, 2 Jul 2013 18:39:34 +0200 Subject: [PATCH 0721/1048] xfs: use get_unused_fd_flags(0) instead of get_unused_fd() Macro get_unused_fd() is used to allocate a file descriptor with default flags. Those default flags (0) can be "unsafe": O_CLOEXEC must be used by default to not leak file descriptor across exec(). Instead of macro get_unused_fd(), functions anon_inode_getfd() or get_unused_fd_flags() should be used with flags given by userspace. If not possible, flags should be set to O_CLOEXEC to provide userspace with a default safe behavor. In a further patch, get_unused_fd() will be removed so that new code start using anon_inode_getfd() or get_unused_fd_flags() with correct flags. This patch replaces calls to get_unused_fd() with equivalent call to get_unused_fd_flags(0) to preserve current behavor for existing code. The hard coded flag value (0) should be reviewed on a per-subsystem basis, and, if possible, set to O_CLOEXEC. Signed-off-by: Yann Droneaud Reviewed-by: Ben Myers Signed-off-by: Ben Myers --- fs/xfs/xfs_ioctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c index 5e999680094a..dc5b65983e5f 100644 --- a/fs/xfs/xfs_ioctl.c +++ b/fs/xfs/xfs_ioctl.c @@ -248,7 +248,7 @@ xfs_open_by_handle( goto out_dput; } - fd = get_unused_fd(); + fd = get_unused_fd_flags(0); if (fd < 0) { error = fd; goto out_dput; From fd832478422834be03029ffab6df96f4df35f3e6 Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Tue, 9 Jul 2013 18:34:01 +0100 Subject: [PATCH 0722/1048] ARM: 7782/1: Kconfig: Let ARM_ERRATA_364296 not depend on CONFIG_SMP imx_v6_v7_defconfig handles both multi-core and single-core SoCs, and it has CONFIG_SMP=y selected by default. With such config we cannot select ARM_ERRATA_364296, as it depends on !SMP. Let ARM_ERRATA_364296 be undependent on CONFIG_SMP, so that we can select this erratum for the ARM1136 SoCs, even if CONFIG_SMP=y is enabled. Reviewed-by: Dave Martin Signed-off-by: Fabio Estevam Signed-off-by: Russell King --- arch/arm/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 136f263ed47b..6271d7eb8b29 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -1300,7 +1300,7 @@ config ARM_ERRATA_754327 config ARM_ERRATA_364296 bool "ARM errata: Possible cache data corruption with hit-under-miss enabled" - depends on CPU_V6 && !SMP + depends on CPU_V6 help This options enables the workaround for the 364296 ARM1136 r0p2 erratum (possible cache data corruption with From 8f6817a0a57cf15935f8f076d0ade34da01cf26d Mon Sep 17 00:00:00 2001 From: Peter Meerwald Date: Sun, 7 Jul 2013 21:24:00 +0100 Subject: [PATCH 0723/1048] iio staging: fix lis3l02dq, read error handling Signed-off-by: Peter Meerwald Signed-off-by: Jonathan Cameron --- drivers/staging/iio/accel/lis3l02dq_core.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/staging/iio/accel/lis3l02dq_core.c b/drivers/staging/iio/accel/lis3l02dq_core.c index 1bfe5d81792b..8ed75a94f465 100644 --- a/drivers/staging/iio/accel/lis3l02dq_core.c +++ b/drivers/staging/iio/accel/lis3l02dq_core.c @@ -257,6 +257,8 @@ static int lis3l02dq_read_raw(struct iio_dev *indio_dev, ret = lis3l02dq_read_reg_s16(indio_dev, reg, val); } mutex_unlock(&indio_dev->mlock); + if (ret < 0) + goto error_ret; return IIO_VAL_INT; case IIO_CHAN_INFO_SCALE: *val = 0; From cbbe6f82b489e7ceba4ad7c833bd3a76cd0084cb Mon Sep 17 00:00:00 2001 From: Jason Liu Date: Mon, 1 Jul 2013 09:53:30 +0100 Subject: [PATCH 0724/1048] ARM: 7778/1: smp_twd: twd_update_frequency need be run on all online CPUs When the local timer freq changed, the twd_update_frequency function should be run all the CPUs include itself, otherwise, the twd freq will not get updated and the local timer will not run correcttly. smp_call_function will run functions on all other CPUs, but not include himself, this is not correct,use on_each_cpu instead to fix this issue. Cc: Linus Walleij Cc: Rob Herring Cc: Shawn Guo Cc: Arnd Bergmann Cc: stable@vger.kernel.org Acked-by: Linus Walleij Acked-by: Shawn Guo Signed-off-by: Jason Liu Signed-off-by: Russell King --- arch/arm/kernel/smp_twd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/kernel/smp_twd.c b/arch/arm/kernel/smp_twd.c index 90525d9d290b..f6fd1d4398c6 100644 --- a/arch/arm/kernel/smp_twd.c +++ b/arch/arm/kernel/smp_twd.c @@ -120,7 +120,7 @@ static int twd_rate_change(struct notifier_block *nb, * changing cpu. */ if (flags == POST_RATE_CHANGE) - smp_call_function(twd_update_frequency, + on_each_cpu(twd_update_frequency, (void *)&cnd->new_rate, 1); return NOTIFY_OK; From 3e5b7d8b491c3710b7e007eab0a643f923932e3d Mon Sep 17 00:00:00 2001 From: Dave Chinner Date: Wed, 10 Jul 2013 07:03:59 +1000 Subject: [PATCH 0725/1048] xfs: update mount options documentation Because it's horribly out of date. And mark various deprecated options as deprecated and give them a removal date. Signed-off-by: Dave Chinner Reviewed-by: Mark Tinguely Signed-off-by: Ben Myers --- Documentation/filesystems/xfs.txt | 307 ++++++++++++++++++++---------- 1 file changed, 204 insertions(+), 103 deletions(-) diff --git a/Documentation/filesystems/xfs.txt b/Documentation/filesystems/xfs.txt index 83577f0232a0..12525b17d9ed 100644 --- a/Documentation/filesystems/xfs.txt +++ b/Documentation/filesystems/xfs.txt @@ -18,6 +18,8 @@ Mount Options ============= When mounting an XFS filesystem, the following options are accepted. +For boolean mount options, the names with the (*) suffix is the +default behaviour. allocsize=size Sets the buffered I/O end-of-file preallocation size when @@ -25,97 +27,128 @@ When mounting an XFS filesystem, the following options are accepted. Valid values for this option are page size (typically 4KiB) through to 1GiB, inclusive, in power-of-2 increments. - attr2/noattr2 - The options enable/disable (default is disabled for backward - compatibility on-disk) an "opportunistic" improvement to be - made in the way inline extended attributes are stored on-disk. - When the new form is used for the first time (by setting or - removing extended attributes) the on-disk superblock feature - bit field will be updated to reflect this format being in use. + The default behaviour is for dynamic end-of-file + preallocation size, which uses a set of heuristics to + optimise the preallocation size based on the current + allocation patterns within the file and the access patterns + to the file. Specifying a fixed allocsize value turns off + the dynamic behaviour. + + attr2 + noattr2 + The options enable/disable an "opportunistic" improvement to + be made in the way inline extended attributes are stored + on-disk. When the new form is used for the first time when + attr2 is selected (either when setting or removing extended + attributes) the on-disk superblock feature bit field will be + updated to reflect this format being in use. + + The default behaviour is determined by the on-disk feature + bit indicating that attr2 behaviour is active. If either + mount option it set, then that becomes the new default used + by the filesystem. CRC enabled filesystems always use the attr2 format, and so will reject the noattr2 mount option if it is set. - barrier - Enables the use of block layer write barriers for writes into - the journal and unwritten extent conversion. This allows for - drive level write caching to be enabled, for devices that - support write barriers. + barrier (*) + nobarrier + Enables/disables the use of block layer write barriers for + writes into the journal and for data integrity operations. + This allows for drive level write caching to be enabled, for + devices that support write barriers. discard - Issue command to let the block device reclaim space freed by the - filesystem. This is useful for SSD devices, thinly provisioned - LUNs and virtual machine images, but may have a performance - impact. + nodiscard (*) + Enable/disable the issuing of commands to let the block + device reclaim space freed by the filesystem. This is + useful for SSD devices, thinly provisioned LUNs and virtual + machine images, but may have a performance impact. - dmapi - Enable the DMAPI (Data Management API) event callouts. - Use with the "mtpt" option. + Note: It is currently recommended that you use the fstrim + application to discard unused blocks rather than the discard + mount option because the performance impact of this option + is quite severe. - grpid/bsdgroups and nogrpid/sysvgroups - These options define what group ID a newly created file gets. - When grpid is set, it takes the group ID of the directory in - which it is created; otherwise (the default) it takes the fsgid - of the current process, unless the directory has the setgid bit - set, in which case it takes the gid from the parent directory, - and also gets the setgid bit set if it is a directory itself. + grpid/bsdgroups + nogrpid/sysvgroups (*) + These options define what group ID a newly created file + gets. When grpid is set, it takes the group ID of the + directory in which it is created; otherwise it takes the + fsgid of the current process, unless the directory has the + setgid bit set, in which case it takes the gid from the + parent directory, and also gets the setgid bit set if it is + a directory itself. - ihashsize=value - In memory inode hashes have been removed, so this option has - no function as of August 2007. Option is deprecated. + filestreams + Make the data allocator use the filestreams allocation mode + across the entire filesystem rather than just on directories + configured to use it. - ikeep/noikeep - When ikeep is specified, XFS does not delete empty inode clusters - and keeps them around on disk. ikeep is the traditional XFS - behaviour. When noikeep is specified, empty inode clusters - are returned to the free space pool. The default is noikeep for - non-DMAPI mounts, while ikeep is the default when DMAPI is in use. - - inode64 - Indicates that XFS is allowed to create inodes at any location - in the filesystem, including those which will result in inode - numbers occupying more than 32 bits of significance. This is - the default allocation option. Applications which do not handle - inode numbers bigger than 32 bits, should use inode32 option. + ikeep + noikeep (*) + When ikeep is specified, XFS does not delete empty inode + clusters and keeps them around on disk. When noikeep is + specified, empty inode clusters are returned to the free + space pool. inode32 - Indicates that XFS is limited to create inodes at locations which - will not result in inode numbers with more than 32 bits of - significance. This is provided for backwards compatibility, since - 64 bits inode numbers might cause problems for some applications - that cannot handle large inode numbers. + inode64 (*) + When inode32 is specified, it indicates that XFS limits + inode creation to locations which will not result in inode + numbers with more than 32 bits of significance. - largeio/nolargeio + When inode64 is specified, it indicates that XFS is allowed + to create inodes at any location in the filesystem, + including those which will result in inode numbers occupying + more than 32 bits of significance. + + inode32 is provided for backwards compatibility with older + systems and applications, since 64 bits inode numbers might + cause problems for some applications that cannot handle + large inode numbers. If applications are in use which do + not handle inode numbers bigger than 32 bits, the inode32 + option should be specified. + + + largeio + nolargeio (*) If "nolargeio" is specified, the optimal I/O reported in - st_blksize by stat(2) will be as small as possible to allow user - applications to avoid inefficient read/modify/write I/O. - If "largeio" specified, a filesystem that has a "swidth" specified - will return the "swidth" value (in bytes) in st_blksize. If the - filesystem does not have a "swidth" specified but does specify - an "allocsize" then "allocsize" (in bytes) will be returned - instead. - If neither of these two options are specified, then filesystem - will behave as if "nolargeio" was specified. + st_blksize by stat(2) will be as small as possible to allow + user applications to avoid inefficient read/modify/write + I/O. This is typically the page size of the machine, as + this is the granularity of the page cache. + + If "largeio" specified, a filesystem that was created with a + "swidth" specified will return the "swidth" value (in bytes) + in st_blksize. If the filesystem does not have a "swidth" + specified but does specify an "allocsize" then "allocsize" + (in bytes) will be returned instead. Otherwise the behaviour + is the same as if "nolargeio" was specified. logbufs=value - Set the number of in-memory log buffers. Valid numbers range - from 2-8 inclusive. - The default value is 8 buffers for filesystems with a - blocksize of 64KiB, 4 buffers for filesystems with a blocksize - of 32KiB, 3 buffers for filesystems with a blocksize of 16KiB - and 2 buffers for all other configurations. Increasing the - number of buffers may increase performance on some workloads - at the cost of the memory used for the additional log buffers - and their associated control structures. + Set the number of in-memory log buffers. Valid numbers + range from 2-8 inclusive. + + The default value is 8 buffers. + + If the memory cost of 8 log buffers is too high on small + systems, then it may be reduced at some cost to performance + on metadata intensive workloads. The logbsize option below + controls the size of each buffer and so is also relevent to + this case. logbsize=value - Set the size of each in-memory log buffer. - Size may be specified in bytes, or in kilobytes with a "k" suffix. - Valid sizes for version 1 and version 2 logs are 16384 (16k) and - 32768 (32k). Valid sizes for version 2 logs also include - 65536 (64k), 131072 (128k) and 262144 (256k). - The default value for machines with more than 32MiB of memory - is 32768, machines with less memory use 16384 by default. + Set the size of each in-memory log buffer. The size may be + specified in bytes, or in kilobytes with a "k" suffix. + Valid sizes for version 1 and version 2 logs are 16384 (16k) + and 32768 (32k). Valid sizes for version 2 logs also + include 65536 (64k), 131072 (128k) and 262144 (256k). The + logbsize must be an integer multiple of the log + stripe unit configured at mkfs time. + + The default value for for version 1 logs is 32768, while the + default value for version 2 logs is MAX(32768, log_sunit). logdev=device and rtdev=device Use an external log (metadata journal) and/or real-time device. @@ -124,16 +157,11 @@ When mounting an XFS filesystem, the following options are accepted. optional, and the log section can be separate from the data section or contained within it. - mtpt=mountpoint - Use with the "dmapi" option. The value specified here will be - included in the DMAPI mount event, and should be the path of - the actual mountpoint that is used. - noalign - Data allocations will not be aligned at stripe unit boundaries. - - noatime - Access timestamps are not updated when a file is read. + Data allocations will not be aligned at stripe unit + boundaries. This is only relevant to filesystems created + with non-zero data alignment parameters (sunit, swidth) by + mkfs. norecovery The filesystem will be mounted without running log recovery. @@ -144,8 +172,14 @@ When mounting an XFS filesystem, the following options are accepted. the mount will fail. nouuid - Don't check for double mounted file systems using the file system uuid. - This is useful to mount LVM snapshot volumes. + Don't check for double mounted file systems using the file + system uuid. This is useful to mount LVM snapshot volumes, + and often used in combination with "norecovery" for mounting + read-only snapshots. + + noquota + Forcibly turns off all quota accounting and enforcement + within the filesystem. uquota/usrquota/uqnoenforce/quota User disk quota accounting enabled, and limits (optionally) @@ -160,24 +194,64 @@ When mounting an XFS filesystem, the following options are accepted. enforced. Refer to xfs_quota(8) for further details. sunit=value and swidth=value - Used to specify the stripe unit and width for a RAID device or - a stripe volume. "value" must be specified in 512-byte block - units. - If this option is not specified and the filesystem was made on - a stripe volume or the stripe width or unit were specified for - the RAID device at mkfs time, then the mount system call will - restore the value from the superblock. For filesystems that - are made directly on RAID devices, these options can be used - to override the information in the superblock if the underlying - disk layout changes after the filesystem has been created. - The "swidth" option is required if the "sunit" option has been - specified, and must be a multiple of the "sunit" value. + Used to specify the stripe unit and width for a RAID device + or a stripe volume. "value" must be specified in 512-byte + block units. These options are only relevant to filesystems + that were created with non-zero data alignment parameters. + + The sunit and swidth parameters specified must be compatible + with the existing filesystem alignment characteristics. In + general, that means the only valid changes to sunit are + increasing it by a power-of-2 multiple. Valid swidth values + are any integer multiple of a valid sunit value. + + Typically the only time these mount options are necessary if + after an underlying RAID device has had it's geometry + modified, such as adding a new disk to a RAID5 lun and + reshaping it. swalloc Data allocations will be rounded up to stripe width boundaries when the current end of file is being extended and the file size is larger than the stripe width size. + wsync + When specified, all filesystem namespace operations are + executed synchronously. This ensures that when the namespace + operation (create, unlink, etc) completes, the change to the + namespace is on stable storage. This is useful in HA setups + where failover must not result in clients seeing + inconsistent namespace presentation during or after a + failover event. + + +Deprecated Mount Options +======================== + + delaylog/nodelaylog + Delayed logging is the only logging method that XFS supports + now, so these mount options are now ignored. + + Due for removal in 3.12. + + ihashsize=value + In memory inode hashes have been removed, so this option has + no function as of August 2007. Option is deprecated. + + Due for removal in 3.12. + + irixsgid + This behaviour is now controlled by a sysctl, so the mount + option is ignored. + + Due for removal in 3.12. + + osyncisdsync + osyncisosync + O_SYNC and O_DSYNC are fully supported, so there is no need + for these options any more. + + Due for removal in 3.12. sysctls ======= @@ -189,15 +263,20 @@ The following sysctls are available for the XFS filesystem: in /proc/fs/xfs/stat. It then immediately resets to "0". fs.xfs.xfssyncd_centisecs (Min: 100 Default: 3000 Max: 720000) - The interval at which the xfssyncd thread flushes metadata - out to disk. This thread will flush log activity out, and - do some processing on unlinked inodes. + The interval at which the filesystem flushes metadata + out to disk and runs internal cache cleanup routines. - fs.xfs.xfsbufd_centisecs (Min: 50 Default: 100 Max: 3000) - The interval at which xfsbufd scans the dirty metadata buffers list. + fs.xfs.filestream_centisecs (Min: 1 Default: 3000 Max: 360000) + The interval at which the filesystem ages filestreams cache + references and returns timed-out AGs back to the free stream + pool. - fs.xfs.age_buffer_centisecs (Min: 100 Default: 1500 Max: 720000) - The age at which xfsbufd flushes dirty metadata buffers to disk. + fs.xfs.speculative_prealloc_lifetime + (Units: seconds Min: 1 Default: 300 Max: 86400) + The interval at which the background scanning for inodes + with unused speculative preallocation runs. The scan + removes unused preallocation from clean inodes and releases + the unused space back to the free pool. fs.xfs.error_level (Min: 0 Default: 3 Max: 11) A volume knob for error reporting when internal errors occur. @@ -254,9 +333,31 @@ The following sysctls are available for the XFS filesystem: by the xfs_io(8) chattr command on a directory to be inherited by files in that directory. + fs.xfs.inherit_nodefrag (Min: 0 Default: 1 Max: 1) + Setting this to "1" will cause the "nodefrag" flag set + by the xfs_io(8) chattr command on a directory to be + inherited by files in that directory. + fs.xfs.rotorstep (Min: 1 Default: 1 Max: 256) In "inode32" allocation mode, this option determines how many files the allocator attempts to allocate in the same allocation group before moving to the next allocation group. The intent is to control the rate at which the allocator moves between allocation groups when allocating extents for new files. + +Deprecated Sysctls +================== + + fs.xfs.xfsbufd_centisecs (Min: 50 Default: 100 Max: 3000) + Dirty metadata is now tracked by the log subsystem and + flushing is driven by log space and idling demands. The + xfsbufd no longer exists, so this syctl does nothing. + + Due for removal in 3.14. + + fs.xfs.age_buffer_centisecs (Min: 100 Default: 1500 Max: 720000) + Dirty metadata is now tracked by the log subsystem and + flushing is driven by log space and idling demands. The + xfsbufd no longer exists, so this syctl does nothing. + + Due for removal in 3.14. From f3508bcddf8fae6ebd21000d708cf09e7e77a963 Mon Sep 17 00:00:00 2001 From: Dave Chinner Date: Wed, 10 Jul 2013 07:04:00 +1000 Subject: [PATCH 0726/1048] xfs: remove local fork format handling from xfs_bmapi_write() The conversion from local format to extent format requires interpretation of the data in the fork being converted, so it cannot be done in a generic way. It is up to the caller to convert the fork format to extent format before calling into xfs_bmapi_write() so format conversion can be done correctly. The code in xfs_bmapi_write() to convert the format is used implicitly by the attribute and directory code, but they specifically zero the fork size so that the conversion does not do any allocation or manipulation. Move this conversion into the shortform to leaf functions for the dir/attr code so the conversions are explicitly controlled by all callers. Now we can remove the conversion code in xfs_bmapi_write. Signed-off-by: Dave Chinner Reviewed-by: Mark Tinguely Signed-off-by: Ben Myers --- fs/xfs/xfs_attr_leaf.c | 2 + fs/xfs/xfs_bmap.c | 199 +++++++++++++++++----------------------- fs/xfs/xfs_bmap.h | 1 + fs/xfs/xfs_dir2_block.c | 20 ++-- 4 files changed, 98 insertions(+), 124 deletions(-) diff --git a/fs/xfs/xfs_attr_leaf.c b/fs/xfs/xfs_attr_leaf.c index 31d3cd129269..b800fbcafc7f 100644 --- a/fs/xfs/xfs_attr_leaf.c +++ b/fs/xfs/xfs_attr_leaf.c @@ -690,6 +690,8 @@ xfs_attr_shortform_to_leaf(xfs_da_args_t *args) sf = (xfs_attr_shortform_t *)tmpbuffer; xfs_idata_realloc(dp, -size, XFS_ATTR_FORK); + xfs_bmap_local_to_extents_empty(dp, XFS_ATTR_FORK); + bp = NULL; error = xfs_da_grow_inode(args, &blkno); if (error) { diff --git a/fs/xfs/xfs_bmap.c b/fs/xfs/xfs_bmap.c index 89042848f9ec..05c698ccb238 100644 --- a/fs/xfs/xfs_bmap.c +++ b/fs/xfs/xfs_bmap.c @@ -1161,6 +1161,24 @@ xfs_bmap_extents_to_btree( * since the file data needs to get logged so things will stay consistent. * (The bmap-level manipulations are ok, though). */ +void +xfs_bmap_local_to_extents_empty( + struct xfs_inode *ip, + int whichfork) +{ + struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, whichfork); + + ASSERT(XFS_IFORK_FORMAT(ip, whichfork) == XFS_DINODE_FMT_LOCAL); + ASSERT(ifp->if_bytes == 0); + ASSERT(XFS_IFORK_NEXTENTS(ip, whichfork) == 0); + + xfs_bmap_forkoff_reset(ip->i_mount, ip, whichfork); + ifp->if_flags &= ~XFS_IFINLINE; + ifp->if_flags |= XFS_IFEXTENTS; + XFS_IFORK_FMT_SET(ip, whichfork, XFS_DINODE_FMT_EXTENTS); +} + + STATIC int /* error */ xfs_bmap_local_to_extents( xfs_trans_t *tp, /* transaction pointer */ @@ -1174,9 +1192,12 @@ xfs_bmap_local_to_extents( struct xfs_inode *ip, struct xfs_ifork *ifp)) { - int error; /* error return value */ + int error = 0; int flags; /* logging flags returned */ xfs_ifork_t *ifp; /* inode fork pointer */ + xfs_alloc_arg_t args; /* allocation arguments */ + xfs_buf_t *bp; /* buffer for extent block */ + xfs_bmbt_rec_host_t *ep; /* extent record pointer */ /* * We don't want to deal with the case of keeping inode data inline yet. @@ -1185,68 +1206,65 @@ xfs_bmap_local_to_extents( ASSERT(!(S_ISREG(ip->i_d.di_mode) && whichfork == XFS_DATA_FORK)); ifp = XFS_IFORK_PTR(ip, whichfork); ASSERT(XFS_IFORK_FORMAT(ip, whichfork) == XFS_DINODE_FMT_LOCAL); + + if (!ifp->if_bytes) { + xfs_bmap_local_to_extents_empty(ip, whichfork); + flags = XFS_ILOG_CORE; + goto done; + } + flags = 0; error = 0; - if (ifp->if_bytes) { - xfs_alloc_arg_t args; /* allocation arguments */ - xfs_buf_t *bp; /* buffer for extent block */ - xfs_bmbt_rec_host_t *ep;/* extent record pointer */ - - ASSERT((ifp->if_flags & - (XFS_IFINLINE|XFS_IFEXTENTS|XFS_IFEXTIREC)) == XFS_IFINLINE); - memset(&args, 0, sizeof(args)); - args.tp = tp; - args.mp = ip->i_mount; - args.firstblock = *firstblock; - /* - * Allocate a block. We know we need only one, since the - * file currently fits in an inode. - */ - if (*firstblock == NULLFSBLOCK) { - args.fsbno = XFS_INO_TO_FSB(args.mp, ip->i_ino); - args.type = XFS_ALLOCTYPE_START_BNO; - } else { - args.fsbno = *firstblock; - args.type = XFS_ALLOCTYPE_NEAR_BNO; - } - args.total = total; - args.minlen = args.maxlen = args.prod = 1; - error = xfs_alloc_vextent(&args); - if (error) - goto done; - - /* Can't fail, the space was reserved. */ - ASSERT(args.fsbno != NULLFSBLOCK); - ASSERT(args.len == 1); - *firstblock = args.fsbno; - bp = xfs_btree_get_bufl(args.mp, tp, args.fsbno, 0); - - /* initialise the block and copy the data */ - init_fn(tp, bp, ip, ifp); - - /* account for the change in fork size and log everything */ - xfs_trans_log_buf(tp, bp, 0, ifp->if_bytes - 1); - xfs_bmap_forkoff_reset(args.mp, ip, whichfork); - xfs_idata_realloc(ip, -ifp->if_bytes, whichfork); - xfs_iext_add(ifp, 0, 1); - ep = xfs_iext_get_ext(ifp, 0); - xfs_bmbt_set_allf(ep, 0, args.fsbno, 1, XFS_EXT_NORM); - trace_xfs_bmap_post_update(ip, 0, - whichfork == XFS_ATTR_FORK ? BMAP_ATTRFORK : 0, - _THIS_IP_); - XFS_IFORK_NEXT_SET(ip, whichfork, 1); - ip->i_d.di_nblocks = 1; - xfs_trans_mod_dquot_byino(tp, ip, - XFS_TRANS_DQ_BCOUNT, 1L); - flags |= xfs_ilog_fext(whichfork); + ASSERT((ifp->if_flags & (XFS_IFINLINE|XFS_IFEXTENTS|XFS_IFEXTIREC)) == + XFS_IFINLINE); + memset(&args, 0, sizeof(args)); + args.tp = tp; + args.mp = ip->i_mount; + args.firstblock = *firstblock; + /* + * Allocate a block. We know we need only one, since the + * file currently fits in an inode. + */ + if (*firstblock == NULLFSBLOCK) { + args.fsbno = XFS_INO_TO_FSB(args.mp, ip->i_ino); + args.type = XFS_ALLOCTYPE_START_BNO; } else { - ASSERT(XFS_IFORK_NEXTENTS(ip, whichfork) == 0); - xfs_bmap_forkoff_reset(ip->i_mount, ip, whichfork); + args.fsbno = *firstblock; + args.type = XFS_ALLOCTYPE_NEAR_BNO; } - ifp->if_flags &= ~XFS_IFINLINE; - ifp->if_flags |= XFS_IFEXTENTS; - XFS_IFORK_FMT_SET(ip, whichfork, XFS_DINODE_FMT_EXTENTS); + args.total = total; + args.minlen = args.maxlen = args.prod = 1; + error = xfs_alloc_vextent(&args); + if (error) + goto done; + + /* Can't fail, the space was reserved. */ + ASSERT(args.fsbno != NULLFSBLOCK); + ASSERT(args.len == 1); + *firstblock = args.fsbno; + bp = xfs_btree_get_bufl(args.mp, tp, args.fsbno, 0); + + /* initialise the block and copy the data */ + init_fn(tp, bp, ip, ifp); + + /* account for the change in fork size and log everything */ + xfs_trans_log_buf(tp, bp, 0, ifp->if_bytes - 1); + xfs_idata_realloc(ip, -ifp->if_bytes, whichfork); + xfs_bmap_local_to_extents_empty(ip, whichfork); flags |= XFS_ILOG_CORE; + + xfs_iext_add(ifp, 0, 1); + ep = xfs_iext_get_ext(ifp, 0); + xfs_bmbt_set_allf(ep, 0, args.fsbno, 1, XFS_EXT_NORM); + trace_xfs_bmap_post_update(ip, 0, + whichfork == XFS_ATTR_FORK ? BMAP_ATTRFORK : 0, + _THIS_IP_); + XFS_IFORK_NEXT_SET(ip, whichfork, 1); + ip->i_d.di_nblocks = 1; + xfs_trans_mod_dquot_byino(tp, ip, + XFS_TRANS_DQ_BCOUNT, 1L); + flags |= xfs_ilog_fext(whichfork); + done: *logflagsp = flags; return error; @@ -1322,25 +1340,6 @@ xfs_bmap_add_attrfork_extents( return error; } -/* - * Block initialisation function for local to extent format conversion. - * - * This shouldn't actually be called by anyone, so make sure debug kernels cause - * a noticable failure. - */ -STATIC void -xfs_bmap_local_to_extents_init_fn( - struct xfs_trans *tp, - struct xfs_buf *bp, - struct xfs_inode *ip, - struct xfs_ifork *ifp) -{ - ASSERT(0); - bp->b_ops = &xfs_bmbt_buf_ops; - memcpy(bp->b_addr, ifp->if_u1.if_data, ifp->if_bytes); - xfs_trans_buf_set_type(tp, bp, XFS_BLFT_BTREE_BUF); -} - /* * Called from xfs_bmap_add_attrfork to handle local format files. Each * different data fork content type needs a different callout to do the @@ -1381,9 +1380,9 @@ xfs_bmap_add_attrfork_local( flags, XFS_DATA_FORK, xfs_symlink_local_to_remote); - return xfs_bmap_local_to_extents(tp, ip, firstblock, 1, flags, - XFS_DATA_FORK, - xfs_bmap_local_to_extents_init_fn); + /* should only be called for types that support local format data */ + ASSERT(0); + return EFSCORRUPTED; } /* @@ -4907,20 +4906,19 @@ xfs_bmapi_write( orig_mval = mval; orig_nmap = *nmap; #endif + whichfork = (flags & XFS_BMAPI_ATTRFORK) ? + XFS_ATTR_FORK : XFS_DATA_FORK; ASSERT(*nmap >= 1); ASSERT(*nmap <= XFS_BMAP_MAX_NMAP); ASSERT(!(flags & XFS_BMAPI_IGSTATE)); ASSERT(tp != NULL); ASSERT(len > 0); - - whichfork = (flags & XFS_BMAPI_ATTRFORK) ? - XFS_ATTR_FORK : XFS_DATA_FORK; + ASSERT(XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_LOCAL); if (unlikely(XFS_TEST_ERROR( (XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_EXTENTS && - XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_BTREE && - XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_LOCAL), + XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_BTREE), mp, XFS_ERRTAG_BMAPIFORMAT, XFS_RANDOM_BMAPIFORMAT))) { XFS_ERROR_REPORT("xfs_bmapi_write", XFS_ERRLEVEL_LOW, mp); return XFS_ERROR(EFSCORRUPTED); @@ -4933,37 +4931,6 @@ xfs_bmapi_write( XFS_STATS_INC(xs_blk_mapw); - if (XFS_IFORK_FORMAT(ip, whichfork) == XFS_DINODE_FMT_LOCAL) { - /* - * XXX (dgc): This assumes we are only called for inodes that - * contain content neutral data in local format. Anything that - * contains caller-specific data in local format that needs - * transformation to move to a block format needs to do the - * conversion to extent format itself. - * - * Directory data forks and attribute forks handle this - * themselves, but with the addition of metadata verifiers every - * data fork in local format now contains caller specific data - * and as such conversion through this function is likely to be - * broken. - * - * The only likely user of this branch is for remote symlinks, - * but we cannot overwrite the data fork contents of the symlink - * (EEXIST occurs higher up the stack) and so it will never go - * from local format to extent format here. Hence I don't think - * this branch is ever executed intentionally and we should - * consider removing it and asserting that xfs_bmapi_write() - * cannot be called directly on local format forks. i.e. callers - * are completely responsible for local to extent format - * conversion, not xfs_bmapi_write(). - */ - error = xfs_bmap_local_to_extents(tp, ip, firstblock, total, - &bma.logflags, whichfork, - xfs_bmap_local_to_extents_init_fn); - if (error) - goto error0; - } - if (*firstblock == NULLFSBLOCK) { if (XFS_IFORK_FORMAT(ip, whichfork) == XFS_DINODE_FMT_BTREE) bma.minleft = be16_to_cpu(ifp->if_broot->bb_level) + 1; diff --git a/fs/xfs/xfs_bmap.h b/fs/xfs/xfs_bmap.h index 5f469c3516eb..1cf1292d29b7 100644 --- a/fs/xfs/xfs_bmap.h +++ b/fs/xfs/xfs_bmap.h @@ -172,6 +172,7 @@ void xfs_bmap_trace_exlist(struct xfs_inode *ip, xfs_extnum_t cnt, #endif int xfs_bmap_add_attrfork(struct xfs_inode *ip, int size, int rsvd); +void xfs_bmap_local_to_extents_empty(struct xfs_inode *ip, int whichfork); void xfs_bmap_add_free(xfs_fsblock_t bno, xfs_filblks_t len, struct xfs_bmap_free *flist, struct xfs_mount *mp); void xfs_bmap_cancel(struct xfs_bmap_free *flist); diff --git a/fs/xfs/xfs_dir2_block.c b/fs/xfs/xfs_dir2_block.c index e59f5fc816fe..53b9aa26d567 100644 --- a/fs/xfs/xfs_dir2_block.c +++ b/fs/xfs/xfs_dir2_block.c @@ -29,6 +29,7 @@ #include "xfs_dinode.h" #include "xfs_inode.h" #include "xfs_inode_item.h" +#include "xfs_bmap.h" #include "xfs_buf_item.h" #include "xfs_dir2.h" #include "xfs_dir2_format.h" @@ -1167,13 +1168,15 @@ xfs_dir2_sf_to_block( __be16 *tagp; /* end of data entry */ xfs_trans_t *tp; /* transaction pointer */ struct xfs_name name; + struct xfs_ifork *ifp; trace_xfs_dir2_sf_to_block(args); dp = args->dp; tp = args->trans; mp = dp->i_mount; - ASSERT(dp->i_df.if_flags & XFS_IFINLINE); + ifp = XFS_IFORK_PTR(dp, XFS_DATA_FORK); + ASSERT(ifp->if_flags & XFS_IFINLINE); /* * Bomb out if the shortform directory is way too short. */ @@ -1182,22 +1185,23 @@ xfs_dir2_sf_to_block( return XFS_ERROR(EIO); } - oldsfp = (xfs_dir2_sf_hdr_t *)dp->i_df.if_u1.if_data; + oldsfp = (xfs_dir2_sf_hdr_t *)ifp->if_u1.if_data; - ASSERT(dp->i_df.if_bytes == dp->i_d.di_size); - ASSERT(dp->i_df.if_u1.if_data != NULL); + ASSERT(ifp->if_bytes == dp->i_d.di_size); + ASSERT(ifp->if_u1.if_data != NULL); ASSERT(dp->i_d.di_size >= xfs_dir2_sf_hdr_size(oldsfp->i8count)); + ASSERT(dp->i_d.di_nextents == 0); /* * Copy the directory into a temporary buffer. * Then pitch the incore inode data so we can make extents. */ - sfp = kmem_alloc(dp->i_df.if_bytes, KM_SLEEP); - memcpy(sfp, oldsfp, dp->i_df.if_bytes); + sfp = kmem_alloc(ifp->if_bytes, KM_SLEEP); + memcpy(sfp, oldsfp, ifp->if_bytes); - xfs_idata_realloc(dp, -dp->i_df.if_bytes, XFS_DATA_FORK); + xfs_idata_realloc(dp, -ifp->if_bytes, XFS_DATA_FORK); + xfs_bmap_local_to_extents_empty(dp, XFS_DATA_FORK); dp->i_d.di_size = 0; - xfs_trans_log_inode(tp, dp, XFS_ILOG_CORE); /* * Add block 0 to the inode. From b0a9dab78aee2a479d7c226e6939d553967e4024 Mon Sep 17 00:00:00 2001 From: Dave Chinner Date: Wed, 10 Jul 2013 07:04:01 +1000 Subject: [PATCH 0727/1048] xfs: dquot log reservations are too small During review of the separate project quota inode patches, it became obvious that the dquot log reservation calculation underestimated the number dquots that can be modified in a transaction. This has it's roots way back in the Irix quota implementation. That is, when quotas were first implemented in XFS, it only supported user and project quotas as Irix did not have group quotas. Hence the worst case operation involving dquot modification was calculated to involve 2 user dquots and 1 project dquot or 1 user dequot and 2 project dquots. i.e. 3 dquots. This was determined back in 1996, and has remained unchanged ever since. However, back in 2001, the Linux XFS port dropped all support for project quota and implmented group quotas over the top. This was effectively done with a search-and-replace of project with group, and as such the log reservation was not changed. However, with the advent of group quotas, chmod and rename now could modify more than 3 dquots in a single transaction - both could modify 4 dquots. Hence this log reservation has been wrong for a long time. In 2005, project quota support was reintroduced into Linux, but it was implemented to be mutually exclusive to group quotas and so this didn't add any new changes to the dquot log reservation. Hence when project quotas were in use (rather than group quotas) the log reservation was again valid, just like in the Irix days. Now, with the addition of the separate project quota inode, group and project quotas are no longer mutually exclusive, and hence operations can now modify three dquots per inode where previously it was only two. The worst case here is the rename transaction, which can allocate/free space on two different directory inodes, and if they have different uid/gid/prid configurations and are world writeable, then rename can actually modify 6 different dquots now. Further, the dquot log reservation doesn't take into account the space used by the dquot log format structure that precedes the dquot that is logged, and hence further underestimates the worst case log space required by dquots during a transaction. This has been missing since the first commit in 1996. Hence the worst case log reservation needs to be increased from 3 to 6, and it needs to take into account a log format header for each of those dquots. Signed-off-by: Dave Chinner Reviewed-by: Mark Tinguely Signed-off-by: Ben Myers --- fs/xfs/xfs_quota.h | 25 +++++++++++++++++++++---- fs/xfs/xfs_trans_dquot.c | 9 ++++----- 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/fs/xfs/xfs_quota.h b/fs/xfs/xfs_quota.h index c3483bab9cde..40d508be9a00 100644 --- a/fs/xfs/xfs_quota.h +++ b/fs/xfs/xfs_quota.h @@ -108,11 +108,28 @@ typedef struct xfs_dqblk { { XFS_DQ_FREEING, "FREEING" } /* - * In the worst case, when both user and group quotas are on, - * we can have a max of three dquots changing in a single transaction. + * We have the possibility of all three quota types being active at once, and + * hence free space modification requires modification of all three current + * dquots in a single transaction. For this case we need to have a reservation + * of at least 3 dquots. + * + * However, a chmod operation can change both UID and GID in a single + * transaction, resulting in requiring {old, new} x {uid, gid} dquots to be + * modified. Hence for this case we need to reserve space for at least 4 dquots. + * + * And in the worst case, there's a rename operation that can be modifying up to + * 4 inodes with dquots attached to them. In reality, the only inodes that can + * have their dquots modified are the source and destination directory inodes + * due to directory name creation and removal. That can require space allocation + * and/or freeing on both directory inodes, and hence all three dquots on each + * inode can be modified. And if the directories are world writeable, all the + * dquots can be unique and so 6 dquots can be modified.... + * + * And, of course, we also need to take into account the dquot log format item + * used to describe each dquot. */ -#define XFS_DQUOT_LOGRES(mp) (sizeof(xfs_disk_dquot_t) * 3) - +#define XFS_DQUOT_LOGRES(mp) \ + ((sizeof(struct xfs_dq_logformat) + sizeof(struct xfs_disk_dquot)) * 6) /* * These are the structures used to lay out dquots and quotaoff diff --git a/fs/xfs/xfs_trans_dquot.c b/fs/xfs/xfs_trans_dquot.c index 3ba64d540168..db041a5e1f6d 100644 --- a/fs/xfs/xfs_trans_dquot.c +++ b/fs/xfs/xfs_trans_dquot.c @@ -291,11 +291,10 @@ xfs_trans_mod_dquot( /* - * Given an array of dqtrx structures, lock all the dquots associated - * and join them to the transaction, provided they have been modified. - * We know that the highest number of dquots (of one type - usr OR grp), - * involved in a transaction is 2 and that both usr and grp combined - 3. - * So, we don't attempt to make this very generic. + * Given an array of dqtrx structures, lock all the dquots associated and join + * them to the transaction, provided they have been modified. We know that the + * highest number of dquots of one type - usr, grp OR prj - involved in a + * transaction is 2 so we don't need to make this very generic. */ STATIC void xfs_trans_dqlockedjoin( From 655ee63cf3714ac0a7ebee4a7dd00fdc54b006fc Mon Sep 17 00:00:00 2001 From: Douglas Gilbert Date: Tue, 2 Jul 2013 00:17:34 -0400 Subject: [PATCH 0728/1048] [SCSI] scsi constants: command, sense key + additional sense strings It has been several years since the SCSI constants.c file has been updated. The attached is against lk 3.10 and brings the command strings, sense keys and additional sense code strings into sync with spc4r36g.pdf. Certain SCSI command names that previously only took the opcode (i.e. byte 0 of the cdb) into account, have been split into several command names using the associated service action field to differentiate. For example, persistent reservations that previously had 2 commands (i.e. "in" and "out") have been expanded to 12 commands (e.g. "Persistent reserve in, read reservation"). Sync SCSI command names, sense key strings and additional sense code strings with SPC-4 draft revision 36g [jejb: whitespace fix] Signed-off-by: Douglas Gilbert Signed-off-by: James Bottomley --- drivers/scsi/constants.c | 235 +++++++++++++++++++++++++++++++-------- 1 file changed, 187 insertions(+), 48 deletions(-) diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c index 76e4c039f0d5..d35a5d6c8d7c 100644 --- a/drivers/scsi/constants.c +++ b/drivers/scsi/constants.c @@ -1,10 +1,10 @@ -/* +/* * ASCII values for a number of symbolic constants, printing functions, * etc. * Additions for SCSI 2 and Linux 2.2.x by D. Gilbert (990422) * Additions for SCSI 3+ (SPC-3 T10/1416-D Rev 07 3 May 2002) * by D. Gilbert and aeb (20020609) - * Update to SPC-4 T10/1713-D Rev 20, 22 May 2009, D. Gilbert 20090624 + * Updated to SPC-4 T10/1713-D Rev 36g, D. Gilbert 20130701 */ #include @@ -21,12 +21,13 @@ /* Commands with service actions that change the command name */ -#define MAINTENANCE_IN 0xa3 -#define MAINTENANCE_OUT 0xa4 #define SERVICE_ACTION_IN_12 0xab #define SERVICE_ACTION_OUT_12 0xa9 +#define SERVICE_ACTION_BIDIRECTIONAL 0x9d #define SERVICE_ACTION_IN_16 0x9e #define SERVICE_ACTION_OUT_16 0x9f +#define THIRD_PARTY_COPY_OUT 0x83 +#define THIRD_PARTY_COPY_IN 0x84 @@ -36,11 +37,11 @@ static const char * cdb_byte0_names[] = { /* 04-07 */ "Format Unit/Medium", "Read Block Limits", NULL, "Reassign Blocks", /* 08-0d */ "Read(6)", NULL, "Write(6)", "Seek(6)", NULL, NULL, -/* 0e-12 */ NULL, "Read Reverse", "Write Filemarks", "Space", "Inquiry", +/* 0e-12 */ NULL, "Read Reverse", "Write Filemarks", "Space", "Inquiry", /* 13-16 */ "Verify(6)", "Recover Buffered Data", "Mode Select(6)", "Reserve(6)", /* 17-1a */ "Release(6)", "Copy", "Erase", "Mode Sense(6)", -/* 1b-1d */ "Start/Stop Unit", "Receive Diagnostic", "Send Diagnostic", +/* 1b-1d */ "Start/Stop Unit", "Receive Diagnostic", "Send Diagnostic", /* 1e-1f */ "Prevent/Allow Medium Removal", NULL, /* 20-22 */ NULL, NULL, NULL, /* 23-28 */ "Read Format Capacities", "Set Window", @@ -48,16 +49,16 @@ static const char * cdb_byte0_names[] = { /* 29-2d */ "Read Generation", "Write(10)", "Seek(10)", "Erase(10)", "Read updated block", /* 2e-31 */ "Write Verify(10)", "Verify(10)", "Search High", "Search Equal", -/* 32-34 */ "Search Low", "Set Limits", "Prefetch/Read Position", +/* 32-34 */ "Search Low", "Set Limits", "Prefetch/Read Position", /* 35-37 */ "Synchronize Cache(10)", "Lock/Unlock Cache(10)", - "Read Defect Data(10)", -/* 38-3c */ "Medium Scan", "Compare", "Copy Verify", "Write Buffer", - "Read Buffer", + "Read Defect Data(10)", +/* 38-3c */ "Medium Scan", "Compare", "Copy Verify", "Write Buffer", + "Read Buffer", /* 3d-3f */ "Update Block", "Read Long(10)", "Write Long(10)", /* 40-41 */ "Change Definition", "Write Same(10)", /* 42-48 */ "Unmap/Read sub-channel", "Read TOC/PMA/ATIP", "Read density support", "Play audio(10)", "Get configuration", - "Play audio msf", "Play audio track/index", + "Play audio msf", "Sanitize/Play audio track/index", /* 49-4f */ "Play track relative(10)", "Get event status notification", "Pause/resume", "Log Select", "Log Sense", "Stop play/scan", NULL, @@ -72,17 +73,17 @@ static const char * cdb_byte0_names[] = { /* 70-77 */ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* 78-7f */ NULL, NULL, NULL, NULL, NULL, NULL, "Extended CDB", "Variable length", -/* 80-84 */ "Xdwrite(16)", "Rebuild(16)", "Regenerate(16)", "Extended copy", - "Receive copy results", +/* 80-84 */ "Xdwrite(16)", "Rebuild(16)", "Regenerate(16)", + "Third party copy out", "Third party copy in", /* 85-89 */ "ATA command pass through(16)", "Access control in", - "Access control out", "Read(16)", "Memory Export Out(16)", + "Access control out", "Read(16)", "Compare and Write", /* 8a-8f */ "Write(16)", "ORWrite", "Read attributes", "Write attributes", "Write and verify(16)", "Verify(16)", /* 90-94 */ "Pre-fetch(16)", "Synchronize cache(16)", "Lock/unlock cache(16)", "Write same(16)", NULL, /* 95-99 */ NULL, NULL, NULL, NULL, NULL, -/* 9a-9f */ NULL, NULL, NULL, NULL, "Service action in(16)", - "Service action out(16)", +/* 9a-9f */ NULL, NULL, NULL, "Service action bidirectional", + "Service action in(16)", "Service action out(16)", /* a0-a5 */ "Report luns", "ATA command pass through(12)/Blank", "Security protocol in", "Maintenance in", "Maintenance out", "Move medium/play audio(12)", @@ -122,6 +123,7 @@ static const struct value_name_pair maint_out_arr[] = { {0x6, "Set identifying information"}, {0xa, "Set target port groups"}, {0xb, "Change aliases"}, + {0xc, "Remove I_T nexus"}, {0xe, "Set priority"}, {0xf, "Set timestamp"}, {0x10, "Management protocol out"}, @@ -138,10 +140,16 @@ static const struct value_name_pair serv_out12_arr[] = { }; #define SERV_OUT12_SZ ARRAY_SIZE(serv_out12_arr) +static const struct value_name_pair serv_bidi_arr[] = { + {-1, "dummy entry"}, +}; +#define SERV_BIDI_SZ ARRAY_SIZE(serv_bidi_arr) + static const struct value_name_pair serv_in16_arr[] = { {0x10, "Read capacity(16)"}, {0x11, "Read long(16)"}, {0x12, "Get LBA status"}, + {0x13, "Report referrals"}, }; #define SERV_IN16_SZ ARRAY_SIZE(serv_in16_arr) @@ -151,6 +159,51 @@ static const struct value_name_pair serv_out16_arr[] = { }; #define SERV_OUT16_SZ ARRAY_SIZE(serv_out16_arr) +static const struct value_name_pair pr_in_arr[] = { + {0x0, "Persistent reserve in, read keys"}, + {0x1, "Persistent reserve in, read reservation"}, + {0x2, "Persistent reserve in, report capabilities"}, + {0x3, "Persistent reserve in, read full status"}, +}; +#define PR_IN_SZ ARRAY_SIZE(pr_in_arr) + +static const struct value_name_pair pr_out_arr[] = { + {0x0, "Persistent reserve out, register"}, + {0x1, "Persistent reserve out, reserve"}, + {0x2, "Persistent reserve out, release"}, + {0x3, "Persistent reserve out, clear"}, + {0x4, "Persistent reserve out, preempt"}, + {0x5, "Persistent reserve out, preempt and abort"}, + {0x6, "Persistent reserve out, register and ignore existing key"}, + {0x7, "Persistent reserve out, register and move"}, +}; +#define PR_OUT_SZ ARRAY_SIZE(pr_out_arr) + +/* SPC-4 rev 34 renamed the Extended Copy opcode to Third Party Copy Out. + LID1 (List Identifier length: 1 byte) is the Extended Copy found in SPC-2 + and SPC-3 */ +static const struct value_name_pair tpc_out_arr[] = { + {0x0, "Extended copy(LID1)"}, + {0x1, "Extended copy(LID4)"}, + {0x10, "Populate token"}, + {0x11, "Write using token"}, + {0x1c, "Copy operation abort"}, +}; +#define TPC_OUT_SZ ARRAY_SIZE(tpc_out_arr) + +static const struct value_name_pair tpc_in_arr[] = { + {0x0, "Receive copy status(LID1)"}, + {0x1, "Receive copy data(LID1)"}, + {0x3, "Receive copy operating parameters"}, + {0x4, "Receive copy failure details(LID1)"}, + {0x5, "Receive copy status(LID4)"}, + {0x6, "Receive copy data(LID4)"}, + {0x7, "Receive ROD token information"}, + {0x8, "Report all ROD tokens"}, +}; +#define TPC_IN_SZ ARRAY_SIZE(tpc_in_arr) + + static const struct value_name_pair variable_length_arr[] = { {0x1, "Rebuild(32)"}, {0x2, "Regenerate(32)"}, @@ -207,6 +260,7 @@ static const char * get_sa_name(const struct value_name_pair * arr, static void print_opcode_name(unsigned char * cdbp, int cdb_len) { int sa, len, cdb0; + int fin_name = 0; const char * name; cdb0 = cdbp[0]; @@ -219,7 +273,8 @@ static void print_opcode_name(unsigned char * cdbp, int cdb_len) break; } sa = (cdbp[8] << 8) + cdbp[9]; - name = get_sa_name(variable_length_arr, VARIABLE_LENGTH_SZ, sa); + name = get_sa_name(variable_length_arr, VARIABLE_LENGTH_SZ, + sa); if (name) printk("%s", name); else @@ -232,50 +287,57 @@ static void print_opcode_name(unsigned char * cdbp, int cdb_len) case MAINTENANCE_IN: sa = cdbp[1] & 0x1f; name = get_sa_name(maint_in_arr, MAINT_IN_SZ, sa); - if (name) - printk("%s", name); - else - printk("cdb[0]=0x%x, sa=0x%x", cdb0, sa); + fin_name = 1; break; case MAINTENANCE_OUT: sa = cdbp[1] & 0x1f; name = get_sa_name(maint_out_arr, MAINT_OUT_SZ, sa); - if (name) - printk("%s", name); - else - printk("cdb[0]=0x%x, sa=0x%x", cdb0, sa); + fin_name = 1; + break; + case PERSISTENT_RESERVE_IN: + sa = cdbp[1] & 0x1f; + name = get_sa_name(pr_in_arr, PR_IN_SZ, sa); + fin_name = 1; + break; + case PERSISTENT_RESERVE_OUT: + sa = cdbp[1] & 0x1f; + name = get_sa_name(pr_out_arr, PR_OUT_SZ, sa); + fin_name = 1; break; case SERVICE_ACTION_IN_12: sa = cdbp[1] & 0x1f; name = get_sa_name(serv_in12_arr, SERV_IN12_SZ, sa); - if (name) - printk("%s", name); - else - printk("cdb[0]=0x%x, sa=0x%x", cdb0, sa); + fin_name = 1; break; case SERVICE_ACTION_OUT_12: sa = cdbp[1] & 0x1f; name = get_sa_name(serv_out12_arr, SERV_OUT12_SZ, sa); - if (name) - printk("%s", name); - else - printk("cdb[0]=0x%x, sa=0x%x", cdb0, sa); + fin_name = 1; + break; + case SERVICE_ACTION_BIDIRECTIONAL: + sa = cdbp[1] & 0x1f; + name = get_sa_name(serv_bidi_arr, SERV_BIDI_SZ, sa); + fin_name = 1; break; case SERVICE_ACTION_IN_16: sa = cdbp[1] & 0x1f; name = get_sa_name(serv_in16_arr, SERV_IN16_SZ, sa); - if (name) - printk("%s", name); - else - printk("cdb[0]=0x%x, sa=0x%x", cdb0, sa); + fin_name = 1; break; case SERVICE_ACTION_OUT_16: sa = cdbp[1] & 0x1f; name = get_sa_name(serv_out16_arr, SERV_OUT16_SZ, sa); - if (name) - printk("%s", name); - else - printk("cdb[0]=0x%x, sa=0x%x", cdb0, sa); + fin_name = 1; + break; + case THIRD_PARTY_COPY_IN: + sa = cdbp[1] & 0x1f; + name = get_sa_name(tpc_in_arr, TPC_IN_SZ, sa); + fin_name = 1; + break; + case THIRD_PARTY_COPY_OUT: + sa = cdbp[1] & 0x1f; + name = get_sa_name(tpc_out_arr, TPC_OUT_SZ, sa); + fin_name = 1; break; default: if (cdb0 < 0xc0) { @@ -288,6 +350,12 @@ static void print_opcode_name(unsigned char * cdbp, int cdb_len) printk("cdb[0]=0x%x (vendor)", cdb0); break; } + if (fin_name) { + if (name) + printk("%s", name); + else + printk("cdb[0]=0x%x, sa=0x%x", cdb0, sa); + } } #else /* ifndef CONFIG_SCSI_CONSTANTS */ @@ -312,10 +380,15 @@ static void print_opcode_name(unsigned char * cdbp, int cdb_len) break; case MAINTENANCE_IN: case MAINTENANCE_OUT: + case PERSISTENT_RESERVE_IN: + case PERSISTENT_RESERVE_OUT: case SERVICE_ACTION_IN_12: case SERVICE_ACTION_OUT_12: + case SERVICE_ACTION_BIDIRECTIONAL: case SERVICE_ACTION_IN_16: case SERVICE_ACTION_OUT_16: + case THIRD_PARTY_COPY_IN: + case THIRD_PARTY_COPY_OUT: sa = cdbp[1] & 0x1f; printk("cdb[0]=0x%x, sa=0x%x", cdb0, sa); break; @@ -327,7 +400,7 @@ static void print_opcode_name(unsigned char * cdbp, int cdb_len) break; } } -#endif +#endif void __scsi_print_command(unsigned char *cdb) { @@ -336,7 +409,7 @@ void __scsi_print_command(unsigned char *cdb) print_opcode_name(cdb, 0); len = scsi_command_size(cdb); /* print out all bytes in cdb */ - for (k = 0; k < len; ++k) + for (k = 0; k < len; ++k) printk(" %02x", cdb[k]); printk("\n"); } @@ -404,8 +477,9 @@ struct error_info { /* * The canonical list of T10 Additional Sense Codes is available at: - * http://www.t10.org/lists/asc-num.txt + * http://www.t10.org/lists/asc-num.txt [most recent: 20130605] */ + static const struct error_info additional[] = { {0x0000, "No additional sense information"}, @@ -430,6 +504,8 @@ static const struct error_info additional[] = {0x001C, "Verify operation in progress"}, {0x001D, "ATA pass through information available"}, {0x001E, "Conflicting SA creation request"}, + {0x001F, "Logical unit transitioning to another power condition"}, + {0x0020, "Extended copy information available"}, {0x0100, "No index/sector signal"}, @@ -460,6 +536,17 @@ static const struct error_info additional[] = {0x0412, "Logical unit not ready, offline"}, {0x0413, "Logical unit not ready, SA creation in progress"}, {0x0414, "Logical unit not ready, space allocation in progress"}, + {0x0415, "Logical unit not ready, robotics disabled"}, + {0x0416, "Logical unit not ready, configuration required"}, + {0x0417, "Logical unit not ready, calibration required"}, + {0x0418, "Logical unit not ready, a door is open"}, + {0x0419, "Logical unit not ready, operating in sequential mode"}, + {0x041A, "Logical unit not ready, start stop unit command in " + "progress"}, + {0x041B, "Logical unit not ready, sanitize in progress"}, + {0x041C, "Logical unit not ready, additional power use not yet " + "granted"}, + {0x041D, "Logical unit not ready, configuration in progress"}, {0x0500, "Logical unit does not respond to selection"}, @@ -490,6 +577,7 @@ static const struct error_info additional[] = {0x0B06, "Warning - non-volatile cache now volatile"}, {0x0B07, "Warning - degraded power to non-volatile cache"}, {0x0B08, "Warning - power loss expected"}, + {0x0B09, "Warning - device statistics notification active"}, {0x0C00, "Write error"}, {0x0C01, "Write error - recovered with auto reallocation"}, @@ -505,6 +593,7 @@ static const struct error_info additional[] = {0x0C0B, "Auxiliary memory write error"}, {0x0C0C, "Write error - unexpected unsolicited data"}, {0x0C0D, "Write error - not enough unsolicited data"}, + {0x0C0E, "Multiple write errors"}, {0x0C0F, "Defects in error window"}, {0x0D00, "Error detected by third party temporary initiator"}, @@ -523,6 +612,8 @@ static const struct error_info additional[] = {0x1001, "Logical block guard check failed"}, {0x1002, "Logical block application tag check failed"}, {0x1003, "Logical block reference tag check failed"}, + {0x1004, "Logical block protection error on recover buffered data"}, + {0x1005, "Logical block protection method error"}, {0x1100, "Unrecovered read error"}, {0x1101, "Read retries exhausted"}, @@ -545,6 +636,7 @@ static const struct error_info additional[] = {0x1112, "Auxiliary memory read error"}, {0x1113, "Read error - failed retransmission request"}, {0x1114, "Read error - lba marked bad by application client"}, + {0x1115, "Write after sanitize required"}, {0x1200, "Address mark not found for id field"}, @@ -622,6 +714,7 @@ static const struct error_info additional[] = {0x2009, "Access denied - invalid LU identifier"}, {0x200A, "Access denied - invalid proxy token"}, {0x200B, "Access denied - ACL LUN conflict"}, + {0x200C, "Illegal command when not in append-only mode"}, {0x2100, "Logical block address out of range"}, {0x2101, "Invalid element address"}, @@ -630,6 +723,19 @@ static const struct error_info additional[] = {0x2200, "Illegal function (use 20 00, 24 00, or 26 00)"}, + {0x2300, "Invalid token operation, cause not reportable"}, + {0x2301, "Invalid token operation, unsupported token type"}, + {0x2302, "Invalid token operation, remote token usage not supported"}, + {0x2303, "Invalid token operation, remote rod token creation not " + "supported"}, + {0x2304, "Invalid token operation, token unknown"}, + {0x2305, "Invalid token operation, token corrupt"}, + {0x2306, "Invalid token operation, token revoked"}, + {0x2307, "Invalid token operation, token expired"}, + {0x2308, "Invalid token operation, token cancelled"}, + {0x2309, "Invalid token operation, token deleted"}, + {0x230A, "Invalid token operation, invalid token length"}, + {0x2400, "Invalid field in cdb"}, {0x2401, "CDB decryption error"}, {0x2402, "Obsolete"}, @@ -705,6 +811,7 @@ static const struct error_info additional[] = "event"}, {0x2A13, "Data encryption key instance counter has changed"}, {0x2A14, "SA creation capabilities data has changed"}, + {0x2A15, "Medium removal prevention preempted"}, {0x2B00, "Copy cannot execute since host cannot disconnect"}, @@ -720,6 +827,7 @@ static const struct error_info additional[] = {0x2C09, "Previous reservation conflict status"}, {0x2C0A, "Partition or collection contains user objects"}, {0x2C0B, "Not reserved"}, + {0x2C0C, "Orwrite generation does not match"}, {0x2D00, "Overwrite error on update in place"}, @@ -728,6 +836,7 @@ static const struct error_info additional[] = {0x2F00, "Commands cleared by another initiator"}, {0x2F01, "Commands cleared by power loss notification"}, {0x2F02, "Commands cleared by device server"}, + {0x2F03, "Some commands cleared by queuing layer event"}, {0x3000, "Incompatible medium installed"}, {0x3001, "Cannot read medium - unknown format"}, @@ -745,10 +854,12 @@ static const struct error_info additional[] = {0x3010, "Medium not formatted"}, {0x3011, "Incompatible volume type"}, {0x3012, "Incompatible volume qualifier"}, + {0x3013, "Cleaning volume expired"}, {0x3100, "Medium format corrupted"}, {0x3101, "Format command failed"}, {0x3102, "Zoned formatting failed due to spare linking"}, + {0x3103, "Sanitize command failed"}, {0x3200, "No defect spare location available"}, {0x3201, "Defect list update failure"}, @@ -809,6 +920,8 @@ static const struct error_info additional[] = {0x3B19, "Element enabled"}, {0x3B1A, "Data transfer device removed"}, {0x3B1B, "Data transfer device inserted"}, + {0x3B1C, "Too many logical objects on partition to support " + "operation"}, {0x3D00, "Invalid bits in identify message"}, @@ -839,6 +952,7 @@ static const struct error_info additional[] = {0x3F12, "iSCSI IP address added"}, {0x3F13, "iSCSI IP address removed"}, {0x3F14, "iSCSI IP address changed"}, + {0x3F15, "Inspect referrals sense descriptors"}, /* * {0x40NN, "Ram failure"}, * {0x40NN, "Diagnostic failure on component nn"}, @@ -848,6 +962,7 @@ static const struct error_info additional[] = {0x4300, "Message error"}, {0x4400, "Internal target failure"}, + {0x4401, "Persistent reservation information lost"}, {0x4471, "ATA device failed set features"}, {0x4500, "Select or reselect failure"}, @@ -876,6 +991,21 @@ static const struct error_info additional[] = {0x4B04, "Nak received"}, {0x4B05, "Data offset error"}, {0x4B06, "Initiator response timeout"}, + {0x4B07, "Connection lost"}, + {0x4B08, "Data-in buffer overflow - data buffer size"}, + {0x4B09, "Data-in buffer overflow - data buffer descriptor area"}, + {0x4B0A, "Data-in buffer error"}, + {0x4B0B, "Data-out buffer overflow - data buffer size"}, + {0x4B0C, "Data-out buffer overflow - data buffer descriptor area"}, + {0x4B0D, "Data-out buffer error"}, + {0x4B0E, "PCIe fabric error"}, + {0x4B0F, "PCIe completion timeout"}, + {0x4B10, "PCIe completer abort"}, + {0x4B11, "PCIe poisoned tlp received"}, + {0x4B12, "PCIe eCRC check failed"}, + {0x4B13, "PCIe unsupported request"}, + {0x4B14, "PCIe acs violation"}, + {0x4B15, "PCIe tlp prefix blocked"}, {0x4C00, "Logical unit failed self-configuration"}, /* @@ -897,6 +1027,10 @@ static const struct error_info additional[] = {0x5302, "Medium removal prevented"}, {0x5303, "Medium removal prevented by data transfer element"}, {0x5304, "Medium thread or unthread failure"}, + {0x5305, "Volume identifier invalid"}, + {0x5306, "Volume identifier missing"}, + {0x5307, "Duplicate volume identifier"}, + {0x5308, "Element status unknown"}, {0x5400, "Scsi to host system interface failure"}, @@ -911,6 +1045,9 @@ static const struct error_info additional[] = {0x5508, "Maximum number of supplemental decryption keys exceeded"}, {0x5509, "Medium auxiliary memory not accessible"}, {0x550A, "Data currently unavailable"}, + {0x550B, "Insufficient power for operation"}, + {0x550C, "Insufficient resources to create rod"}, + {0x550D, "Insufficient resources to create rod token"}, {0x5700, "Unable to recover table-of-contents"}, @@ -1069,6 +1206,7 @@ static const struct error_info additional[] = {0x670B, "ATA device feature not enabled"}, {0x6800, "Logical unit not configured"}, + {0x6801, "Subsidiary logical unit not configured"}, {0x6900, "Data loss on logical unit"}, {0x6901, "Multiple logical unit failures"}, @@ -1185,10 +1323,13 @@ static const char * const snstext[] = { "Vendor Specific(9)", "Copy Aborted", /* A: COPY or COMPARE was aborted */ "Aborted Command", /* B: The target aborted the command */ - "Equal", /* C: A SEARCH DATA command found data equal */ + "Equal", /* C: A SEARCH DATA command found data equal, + reserved in SPC-4 rev 36 */ "Volume Overflow", /* D: Medium full with still data to be written */ "Miscompare", /* E: Source data and data on the medium do not agree */ + "Completed", /* F: command completed sense data reported, + may occur for successful command */ }; #endif @@ -1306,7 +1447,7 @@ scsi_decode_sense_buffer(const unsigned char *sense_buffer, int sense_len, struct scsi_sense_hdr *sshdr) { int k, num, res; - + res = scsi_normalize_sense(sense_buffer, sense_len, sshdr); if (0 == res) { /* this may be SCSI-1 sense data */ @@ -1459,5 +1600,3 @@ void scsi_print_result(struct scsi_cmnd *cmd) scsi_show_result(cmd->result); } EXPORT_SYMBOL(scsi_print_result); - - From c11e5f35ab490bd30591563816fbc83526521777 Mon Sep 17 00:00:00 2001 From: Guenter Roeck Date: Tue, 9 Jul 2013 16:00:31 -0700 Subject: [PATCH 0729/1048] Partially revert "drm/i915: unconditionally use mt forcewake on hsw/ivb" This patch partially reverts commit 36ec8f877481449bdfa072e6adf2060869e2b970 for IvyBridge CPUs. The original commit results in repeated 'Timed out waiting for forcewake old ack to clear' messages on a Supermicro C7H61 board (BIOS version 2.00 and 2.00b) with i7-3770K CPU. It ultimately results in a hangup if the system is highly loaded. Reverting the commit for IvyBridge CPUs fixes the issue. Issue a warning if the CPU is IvyBridge and mt forcewake is disabled, since this condition can result in secondary issues. v2: Only revert patch for Ivybridge CPUs Issue info message if mt forcewake is disabled on Ivybridge Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=60541 Cc: Jesse Barnes Cc: Daniel Vetter Cc: Mika Kuoppala Signed-off-by: Guenter Roeck Cc: stable@vger.kernel.org Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=66139 Signed-off-by: Daniel Vetter --- drivers/gpu/drm/i915/intel_pm.c | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c index ccbdd83f5220..d10e6735771f 100644 --- a/drivers/gpu/drm/i915/intel_pm.c +++ b/drivers/gpu/drm/i915/intel_pm.c @@ -5500,9 +5500,38 @@ void intel_gt_init(struct drm_device *dev) if (IS_VALLEYVIEW(dev)) { dev_priv->gt.force_wake_get = vlv_force_wake_get; dev_priv->gt.force_wake_put = vlv_force_wake_put; - } else if (IS_IVYBRIDGE(dev) || IS_HASWELL(dev)) { + } else if (IS_HASWELL(dev)) { dev_priv->gt.force_wake_get = __gen6_gt_force_wake_mt_get; dev_priv->gt.force_wake_put = __gen6_gt_force_wake_mt_put; + } else if (IS_IVYBRIDGE(dev)) { + u32 ecobus; + + /* IVB configs may use multi-threaded forcewake */ + + /* A small trick here - if the bios hasn't configured + * MT forcewake, and if the device is in RC6, then + * force_wake_mt_get will not wake the device and the + * ECOBUS read will return zero. Which will be + * (correctly) interpreted by the test below as MT + * forcewake being disabled. + */ + mutex_lock(&dev->struct_mutex); + __gen6_gt_force_wake_mt_get(dev_priv); + ecobus = I915_READ_NOTRACE(ECOBUS); + __gen6_gt_force_wake_mt_put(dev_priv); + mutex_unlock(&dev->struct_mutex); + + if (ecobus & FORCEWAKE_MT_ENABLE) { + dev_priv->gt.force_wake_get = + __gen6_gt_force_wake_mt_get; + dev_priv->gt.force_wake_put = + __gen6_gt_force_wake_mt_put; + } else { + DRM_INFO("No MT forcewake available on Ivybridge, this can result in issues\n"); + DRM_INFO("when using vblank-synced partial screen updates.\n"); + dev_priv->gt.force_wake_get = __gen6_gt_force_wake_get; + dev_priv->gt.force_wake_put = __gen6_gt_force_wake_put; + } } else if (IS_GEN6(dev)) { dev_priv->gt.force_wake_get = __gen6_gt_force_wake_get; dev_priv->gt.force_wake_put = __gen6_gt_force_wake_put; From 02978ff57a5bdfbf703d2bc5a4d933a53ede3144 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Tue, 9 Jul 2013 09:22:39 +0100 Subject: [PATCH 0730/1048] drm/i915: Fix write-read race with multiple rings Daniel noticed a problem where is we wrote to an object with ring A in the middle of a very long running batch, then executed a quick batch on ring B before a batch that reads from the same object, its obj->ring would now point to ring B, but its last_write_seqno would be still relative to ring A. This would allow for the user to read from the object before the GPU had completed the write, as set_domain would only check that ring B had passed the last_write_seqno. To fix this simply (and inelegantly), we bump the last_write_seqno when switching rings so that the last_write_seqno is always relative to the current obj->ring. This fixes igt/tests/gem_write_read_ring_switch. Signed-off-by: Chris Wilson Cc: Daniel Vetter Cc: stable@vger.kernel.org [danvet: Add note about the newly created igt which exercises this bug.] Signed-off-by: Daniel Vetter --- drivers/gpu/drm/i915/i915_gem.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c index 7f368d79f7d2..8fd8e82ebda4 100644 --- a/drivers/gpu/drm/i915/i915_gem.c +++ b/drivers/gpu/drm/i915/i915_gem.c @@ -1880,6 +1880,10 @@ i915_gem_object_move_to_active(struct drm_i915_gem_object *obj, u32 seqno = intel_ring_get_seqno(ring); BUG_ON(ring == NULL); + if (obj->ring != ring && obj->last_write_seqno) { + /* Keep the seqno relative to the current ring */ + obj->last_write_seqno = seqno; + } obj->ring = ring; /* Add a reference if we're newly entering the active list. */ From e07619539017ac31004a038d1d886e2ed4d0e61a Mon Sep 17 00:00:00 2001 From: Michal Simek Date: Wed, 10 Jul 2013 09:25:28 +0200 Subject: [PATCH 0731/1048] spi/xilinx: Revert master->setup function removal master->setup() must be initialized to be able to successfully run spi_bitbang_start() and satisfy if/else logic there. "spi: convert drivers to use bits_per_word_mask" (sha1: 24778be20f87d5aadb19624fc768b3159fa43efc) Signed-off-by: Michal Simek Signed-off-by: Mark Brown --- drivers/spi/spi-xilinx.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/drivers/spi/spi-xilinx.c b/drivers/spi/spi-xilinx.c index fb56fcfdf65e..09a942852593 100644 --- a/drivers/spi/spi-xilinx.c +++ b/drivers/spi/spi-xilinx.c @@ -233,6 +233,21 @@ static int xilinx_spi_setup_transfer(struct spi_device *spi, return 0; } +static int xilinx_spi_setup(struct spi_device *spi) +{ + /* always return 0, we can not check the number of bits. + * There are cases when SPI setup is called before any driver is + * there, in that case the SPI core defaults to 8 bits, which we + * do not support in some cases. But if we return an error, the + * SPI device would not be registered and no driver can get hold of it + * When the driver is there, it will call SPI setup again with the + * correct number of bits per transfer. + * If a driver setups with the wrong bit number, it will fail when + * it tries to do a transfer + */ + return 0; +} + static void xilinx_spi_fill_tx_fifo(struct xilinx_spi *xspi) { u8 sr; @@ -360,6 +375,7 @@ struct spi_master *xilinx_spi_init(struct device *dev, struct resource *mem, xspi->bitbang.chipselect = xilinx_spi_chipselect; xspi->bitbang.setup_transfer = xilinx_spi_setup_transfer; xspi->bitbang.txrx_bufs = xilinx_spi_txrx_bufs; + xspi->bitbang.master->setup = xilinx_spi_setup; init_completion(&xspi->done); if (!request_mem_region(mem->start, resource_size(mem), From d18b9619034230b6f945e215276425636ca401fe Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Wed, 10 Jul 2013 13:36:23 +0100 Subject: [PATCH 0732/1048] drm/i915: Fix incoherence with fence updates on Sandybridge+ This hopefully fixes the root cause behind the workaround added in commit 25ff1195f8a0b3724541ae7bbe331b4296de9c06 Author: Chris Wilson Date: Thu Apr 4 21:31:03 2013 +0100 drm/i915: Workaround incoherence between fences and LLC across multiple CPUs Thanks to further investigation by Jon Bloomfield, he realised that the 64-bit register might be broken up by the hardware into two 32-bit writes (a problem we have encountered elsewhere). This non-atomicity would then cause an issue where a second thread would see an intermediate register state (new high dword, old low dword), and this register would randomly be used in preference to its own thread register. This would cause the second thread to read from and write into a fairly random tiled location. Breaking the operation into 3 explicit 32-bit updates (first disable the fence, poke the upper bits, then poke the lower bits and enable) ensures that, given proper serialisation between the 32-bit register write and the memory transfer, that the fence value is always consistent. Armed with this knowledge, we can explain how the previous workaround work. The key to the corruption is that a second thread sees an erroneous fence register that conflicts and overrides its own. By serialising the fence update across all CPUs, we have a small window where no GTT access is occurring and so hide the potential corruption. This also leads to the conclusion that the earlier workaround was incomplete. v2: Be overly paranoid about the order in which fence updates become visible to the GPU to make really sure that we turn the fence off before doing the update, and then only switch the fence on afterwards. Signed-off-by: Jon Bloomfield Signed-off-by: Chris Wilson Cc: Daniel Vetter Cc: Carsten Emde Cc: stable@vger.kernel.org Signed-off-by: Daniel Vetter --- drivers/gpu/drm/i915/i915_gem.c | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c index 8fd8e82ebda4..a34e8e2ba98a 100644 --- a/drivers/gpu/drm/i915/i915_gem.c +++ b/drivers/gpu/drm/i915/i915_gem.c @@ -2668,7 +2668,6 @@ static void i965_write_fence_reg(struct drm_device *dev, int reg, drm_i915_private_t *dev_priv = dev->dev_private; int fence_reg; int fence_pitch_shift; - uint64_t val; if (INTEL_INFO(dev)->gen >= 6) { fence_reg = FENCE_REG_SANDYBRIDGE_0; @@ -2678,8 +2677,23 @@ static void i965_write_fence_reg(struct drm_device *dev, int reg, fence_pitch_shift = I965_FENCE_PITCH_SHIFT; } + fence_reg += reg * 8; + + /* To w/a incoherency with non-atomic 64-bit register updates, + * we split the 64-bit update into two 32-bit writes. In order + * for a partial fence not to be evaluated between writes, we + * precede the update with write to turn off the fence register, + * and only enable the fence as the last step. + * + * For extra levels of paranoia, we make sure each step lands + * before applying the next step. + */ + I915_WRITE(fence_reg, 0); + POSTING_READ(fence_reg); + if (obj) { u32 size = obj->gtt_space->size; + uint64_t val; val = (uint64_t)((obj->gtt_offset + size - 4096) & 0xfffff000) << 32; @@ -2688,12 +2702,16 @@ static void i965_write_fence_reg(struct drm_device *dev, int reg, if (obj->tiling_mode == I915_TILING_Y) val |= 1 << I965_FENCE_TILING_Y_SHIFT; val |= I965_FENCE_REG_VALID; - } else - val = 0; - fence_reg += reg * 8; - I915_WRITE64(fence_reg, val); - POSTING_READ(fence_reg); + I915_WRITE(fence_reg + 4, val >> 32); + POSTING_READ(fence_reg + 4); + + I915_WRITE(fence_reg + 0, val); + POSTING_READ(fence_reg); + } else { + I915_WRITE(fence_reg + 4, 0); + POSTING_READ(fence_reg + 4); + } } static void i915_write_fence_reg(struct drm_device *dev, int reg, From 46a0b638f35b45fc13d3dc0deb6a7e17988170b2 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Wed, 10 Jul 2013 13:36:24 +0100 Subject: [PATCH 0733/1048] Revert "drm/i915: Workaround incoherence between fences and LLC across multiple CPUs" This reverts commit 25ff119 and the follow on for Valleyview commit 2dc8aae. commit 25ff1195f8a0b3724541ae7bbe331b4296de9c06 Author: Chris Wilson Date: Thu Apr 4 21:31:03 2013 +0100 drm/i915: Workaround incoherence between fences and LLC across multiple CPUs commit 2dc8aae06d53458dd3624dc0accd4f81100ee631 Author: Chris Wilson Date: Wed May 22 17:08:06 2013 +0100 drm/i915: Workaround incoherence with fence updates on Valleyview Jon Bloomfield came up with a plausible explanation and cheap fix (drm/i915: Fix incoherence with fence updates on Sandybridge+) for the race condition, so lets run with it. This is a candidate for stable as the old workaround incurs a significant cost (calling wbinvd on all CPUs before performing the register write) for some workloads as noted by Carsten Emde. Link: http://lists.freedesktop.org/archives/intel-gfx/2013-June/028819.html References: https://www.osadl.org/?id=1543#c7602 References: https://bugs.freedesktop.org/show_bug.cgi?id=63825 Signed-off-by: Chris Wilson Cc: Daniel Vetter Cc: Jon Bloomfield Cc: Carsten Emde Cc: stable@vger.kernel.org Signed-off-by: Daniel Vetter --- drivers/gpu/drm/i915/i915_gem.c | 45 +++------------------------------ 1 file changed, 3 insertions(+), 42 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c index a34e8e2ba98a..06d66e09da17 100644 --- a/drivers/gpu/drm/i915/i915_gem.c +++ b/drivers/gpu/drm/i915/i915_gem.c @@ -2829,56 +2829,17 @@ static inline int fence_number(struct drm_i915_private *dev_priv, return fence - dev_priv->fence_regs; } -struct write_fence { - struct drm_device *dev; - struct drm_i915_gem_object *obj; - int fence; -}; - -static void i915_gem_write_fence__ipi(void *data) -{ - struct write_fence *args = data; - - /* Required for SNB+ with LLC */ - wbinvd(); - - /* Required for VLV */ - i915_gem_write_fence(args->dev, args->fence, args->obj); -} - static void i915_gem_object_update_fence(struct drm_i915_gem_object *obj, struct drm_i915_fence_reg *fence, bool enable) { struct drm_i915_private *dev_priv = obj->base.dev->dev_private; - struct write_fence args = { - .dev = obj->base.dev, - .fence = fence_number(dev_priv, fence), - .obj = enable ? obj : NULL, - }; + int reg = fence_number(dev_priv, fence); - /* In order to fully serialize access to the fenced region and - * the update to the fence register we need to take extreme - * measures on SNB+. In theory, the write to the fence register - * flushes all memory transactions before, and coupled with the - * mb() placed around the register write we serialise all memory - * operations with respect to the changes in the tiler. Yet, on - * SNB+ we need to take a step further and emit an explicit wbinvd() - * on each processor in order to manually flush all memory - * transactions before updating the fence register. - * - * However, Valleyview complicates matter. There the wbinvd is - * insufficient and unlike SNB/IVB requires the serialising - * register write. (Note that that register write by itself is - * conversely not sufficient for SNB+.) To compromise, we do both. - */ - if (INTEL_INFO(args.dev)->gen >= 6) - on_each_cpu(i915_gem_write_fence__ipi, &args, 1); - else - i915_gem_write_fence(args.dev, args.fence, args.obj); + i915_gem_write_fence(obj->base.dev, reg, enable ? obj : NULL); if (enable) { - obj->fence_reg = args.fence; + obj->fence_reg = reg; fence->obj = obj; list_move_tail(&fence->lru_list, &dev_priv->mm.fence_list); } else { From 42c49d7f249c2487f36d3314753d5d8ebcee8249 Mon Sep 17 00:00:00 2001 From: Carlos Maiolino Date: Fri, 21 Jun 2013 14:45:53 -0300 Subject: [PATCH 0734/1048] xfs: fix sgid inheritance for subdirectories inheriting default acls [V3] XFS removes sgid bits of subdirectories under a directory containing a default acl. When a default acl is set, it implies xfs to call xfs_setattr_nonsize() in its code path. Such function is shared among mkdir and chmod system calls, and does some checks unneeded by mkdir (calling inode_change_ok()). Such checks remove sgid bit from the inode after it has been granted. With this patch, we extend the meaning of XFS_ATTR_NOACL flag to avoid these checks when acls are being inherited (thanks hch). Also, xfs_setattr_mode, doesn't need to re-check for group id and capabilities permissions, this only implies in another try to remove sgid bit from the directories. Such check is already done either on inode_change_ok() or xfs_setattr_nonsize(). Changelog: V2: Extends the meaning of XFS_ATTR_NOACL instead of wrap the tests into another function V3: Remove S_ISDIR check in xfs_setattr_nonsize() from the patch Signed-off-by: Carlos Maiolino Reviewed-by: Ben Myers Signed-off-by: Ben Myers --- fs/xfs/xfs_iops.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c index c69bbc493cb0..8865261e5417 100644 --- a/fs/xfs/xfs_iops.c +++ b/fs/xfs/xfs_iops.c @@ -467,9 +467,6 @@ xfs_setattr_mode( ASSERT(tp); ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); - if (!in_group_p(inode->i_gid) && !capable(CAP_FSETID)) - mode &= ~S_ISGID; - ip->i_d.di_mode &= S_IFMT; ip->i_d.di_mode |= mode & ~S_IFMT; @@ -495,15 +492,18 @@ xfs_setattr_nonsize( trace_xfs_setattr(ip); - if (mp->m_flags & XFS_MOUNT_RDONLY) - return XFS_ERROR(EROFS); + /* If acls are being inherited, we already have this checked */ + if (!(flags & XFS_ATTR_NOACL)) { + if (mp->m_flags & XFS_MOUNT_RDONLY) + return XFS_ERROR(EROFS); - if (XFS_FORCED_SHUTDOWN(mp)) - return XFS_ERROR(EIO); + if (XFS_FORCED_SHUTDOWN(mp)) + return XFS_ERROR(EIO); - error = -inode_change_ok(inode, iattr); - if (error) - return XFS_ERROR(error); + error = -inode_change_ok(inode, iattr); + if (error) + return XFS_ERROR(error); + } ASSERT((mask & ATTR_SIZE) == 0); From d14c496588733ec1b586ec068932c1db228dd770 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Thu, 9 May 2013 00:17:44 -0400 Subject: [PATCH 0735/1048] perf tools: Fix -ldw/-lelf link test when static linking Since libelf sometimes uses libpthread, we have to list that after -lelf when someone tries to build statically. Else things go boom: Makefile:479: *** No libelf.h/libelf found, please install \ libelf-dev/elfutils-libelf-devel. Stop. Similarly, the -ldw test fails as it often uses -lz: Makefile:462: No libdw.h found or old libdw.h found or elfutils is older \ than 0.138, disables dwarf support. Please install new elfutils-devel/libdw-dev And if we add debugging to try-cc, we see: + echo '#include int main(void) { Dwarf *dbg = dwarf_begin(0, DWARF_C_READ); return (long)dbg; }' + i686-pc-linux-gnu-gcc -x c - -O2 -pipe -march=atom -mtune=atom -mfpmath=sse -g \ -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE \ -ldw -lelf -static -lpthread -lrt -lelf -lm -o .24368 /usr/lib/libdw.a(dwarf_begin_elf.o):function check_section.isra.1: error: undefined reference to 'inflateInit_' /usr/lib/libdw.a(dwarf_begin_elf.o):function check_section.isra.1: error: undefined reference to 'inflate' /usr/lib/libdw.a(dwarf_begin_elf.o):function check_section.isra.1: error: undefined reference to 'inflateReset' /usr/lib/libdw.a(dwarf_begin_elf.o):function check_section.isra.1: error: undefined reference to 'inflateEnd' + echo '#include int main(void) { Elf *elf = elf_begin(0, ELF_C_READ, 0); return (long)elf; }' + i686-pc-linux-gnu-gcc -x c - -O2 -pipe -march=atom -mtune=atom -mfpmath=sse -g \ -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE \ -static -lpthread -lrt -lelf -lm -o .19216 /usr/lib/libelf.a(elf_begin.o):function file_read_elf: error: undefined reference to 'pthread_rwlock_init' /usr/lib/libelf.a(elf_begin.o):function __libelf_read_mmaped_file: error: undefined reference to 'pthread_rwlock_init' /usr/lib/libelf.a(elf_begin.o):function __libelf_read_mmaped_file: error: undefined reference to 'pthread_rwlock_init' /usr/lib/libelf.a(elf_begin.o):function read_file: error: undefined reference to 'pthread_rwlock_init' /usr/lib/libelf.a(elf_begin.o):function lock_dup_elf.8072: error: undefined reference to 'pthread_rwlock_unlock' /usr/lib/libelf.a(elf_begin.o):function lock_dup_elf.8072: error: undefined reference to 'pthread_rwlock_wrlock' /usr/lib/libelf.a(elf_begin.o):function elf_begin: error: undefined reference to 'pthread_rwlock_rdlock' /usr/lib/libelf.a(elf_begin.o):function elf_begin: error: undefined reference to 'pthread_rwlock_unlock' Signed-off-by: Mike Frysinger Cc: Ingo Molnar Cc: Paul Mackerras Cc: Peter Zijlstra Link: http://lkml.kernel.org/r/1368073064-18276-1-git-send-email-vapier@gentoo.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/lib/lk/Makefile | 2 +- tools/perf/config/Makefile | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/lib/lk/Makefile b/tools/lib/lk/Makefile index f0ecc0a13300..280dd8205430 100644 --- a/tools/lib/lk/Makefile +++ b/tools/lib/lk/Makefile @@ -29,7 +29,7 @@ LIB_OBJS += $(OUTPUT)debugfs.o LIBFILE = liblk.a CFLAGS = -ggdb3 -Wall -Wextra -std=gnu99 -Werror -O6 -D_FORTIFY_SOURCE=2 $(EXTRA_WARNINGS) $(EXTRA_CFLAGS) -fPIC -EXTLIBS = -lpthread -lrt -lelf -lm +EXTLIBS = -lelf -lpthread -lrt -lm ALL_CFLAGS = $(CFLAGS) $(BASIC_CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 ALL_LDFLAGS = $(LDFLAGS) diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile index f4468954d3dc..b5d9238cb181 100644 --- a/tools/perf/config/Makefile +++ b/tools/perf/config/Makefile @@ -85,7 +85,7 @@ CFLAGS += -Wall CFLAGS += -Wextra CFLAGS += -std=gnu99 -EXTLIBS = -lpthread -lrt -lelf -lm +EXTLIBS = -lelf -lpthread -lrt -lm ifeq ($(call try-cc,$(SOURCE_HELLO),$(CFLAGS) -Werror -fstack-protector-all,-fstack-protector-all),y) CFLAGS += -fstack-protector-all @@ -165,7 +165,7 @@ else LIBDW_LDFLAGS := -L$(LIBDW_DIR)/lib endif - FLAGS_DWARF=$(CFLAGS) $(LIBDW_CFLAGS) -ldw -lelf $(LIBDW_LDFLAGS) $(LDFLAGS) $(EXTLIBS) + FLAGS_DWARF=$(CFLAGS) $(LIBDW_CFLAGS) -ldw -lz -lelf $(LIBDW_LDFLAGS) $(LDFLAGS) $(EXTLIBS) ifneq ($(call try-cc,$(SOURCE_DWARF),$(FLAGS_DWARF),libdw),y) msg := $(warning No libdw.h found or old libdw.h found or elfutils is older than 0.138, disables dwarf support. Please install new elfutils-devel/libdw-dev); NO_DWARF := 1 From 750ade7e82709c2835cb221a7b6a9ef0a6a9c0ac Mon Sep 17 00:00:00 2001 From: Ramkumar Ramachandra Date: Tue, 9 Jul 2013 15:30:30 +0530 Subject: [PATCH 0736/1048] perf script: Fix broken include in Context.xs 765532c8 (perf script: Finish the rename from trace to script, 2010-12-23) made a mistake during find-and-replace replacing "../../../util/trace-event.h" with "../../../util/script-event.h", a non-existent file. Fix this include. Signed-off-by: Ramkumar Ramachandra Cc: Namhyung Kim Link: http://lkml.kernel.org/r/1373364033-7918-3-git-send-email-artagnon@gmail.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/scripts/perl/Perf-Trace-Util/Context.xs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/perf/scripts/perl/Perf-Trace-Util/Context.xs b/tools/perf/scripts/perl/Perf-Trace-Util/Context.xs index c1e2ed1ed34e..8c7ea42444d1 100644 --- a/tools/perf/scripts/perl/Perf-Trace-Util/Context.xs +++ b/tools/perf/scripts/perl/Perf-Trace-Util/Context.xs @@ -23,7 +23,7 @@ #include "perl.h" #include "XSUB.h" #include "../../../perf.h" -#include "../../../util/script-event.h" +#include "../../../util/trace-event.h" MODULE = Perf::Trace::Context PACKAGE = Perf::Trace::Context PROTOTYPES: ENABLE From fd55439638a27e34d87b91d618c0ba6b42302940 Mon Sep 17 00:00:00 2001 From: Pavel Shilovsky Date: Tue, 9 Jul 2013 19:44:56 +0400 Subject: [PATCH 0737/1048] CIFS: Fix lease context buffer parsing to prevent missing RqLs context if it's not the first one. Signed-off-by: Pavel Shilovsky Signed-off-by: Steven French --- fs/cifs/smb2pdu.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c index 2b312e4eeaa6..19fafeb767fa 100644 --- a/fs/cifs/smb2pdu.c +++ b/fs/cifs/smb2pdu.c @@ -853,23 +853,24 @@ parse_lease_state(struct smb2_create_rsp *rsp) char *data_offset; struct create_lease *lc; bool found = false; + unsigned int next = 0; + char *name; - data_offset = (char *)rsp; - data_offset += 4 + le32_to_cpu(rsp->CreateContextsOffset); + data_offset = (char *)rsp + 4 + le32_to_cpu(rsp->CreateContextsOffset); lc = (struct create_lease *)data_offset; do { - char *name = le16_to_cpu(lc->ccontext.NameOffset) + (char *)lc; + lc = (struct create_lease *)((char *)lc + next); + name = le16_to_cpu(lc->ccontext.NameOffset) + (char *)lc; if (le16_to_cpu(lc->ccontext.NameLength) != 4 || strncmp(name, "RqLs", 4)) { - lc = (struct create_lease *)((char *)lc - + le32_to_cpu(lc->ccontext.Next)); + next = le32_to_cpu(lc->ccontext.Next); continue; } if (lc->lcontext.LeaseFlags & SMB2_LEASE_FLAG_BREAK_IN_PROGRESS) return SMB2_OPLOCK_LEVEL_NOCHANGE; found = true; break; - } while (le32_to_cpu(lc->ccontext.Next) != 0); + } while (next != 0); if (!found) return 0; From ca81983fe5e095ee90c0f7b6013e7c446af17088 Mon Sep 17 00:00:00 2001 From: Pavel Shilovsky Date: Fri, 5 Jul 2013 12:21:26 +0400 Subject: [PATCH 0738/1048] CIFS: Respect create_options in smb2_open_file and eliminated unused file_attribute parms of SMB2_open. Signed-off-by: Pavel Shilovsky Signed-off-by: Steven French --- fs/cifs/smb2file.c | 2 +- fs/cifs/smb2inode.c | 25 ++++++++++++------------- fs/cifs/smb2ops.c | 6 +++--- fs/cifs/smb2pdu.c | 10 +++++++--- fs/cifs/smb2proto.h | 4 ++-- 5 files changed, 25 insertions(+), 22 deletions(-) diff --git a/fs/cifs/smb2file.c b/fs/cifs/smb2file.c index 5da1b55a2258..46a4299b7ae8 100644 --- a/fs/cifs/smb2file.c +++ b/fs/cifs/smb2file.c @@ -88,7 +88,7 @@ smb2_open_file(const unsigned int xid, struct cifs_tcon *tcon, const char *path, rc = SMB2_open(xid, tcon, smb2_path, &fid->persistent_fid, &fid->volatile_fid, desired_access, disposition, - 0, 0, smb2_oplock, smb2_data); + create_options, smb2_oplock, smb2_data); if (rc) goto out; diff --git a/fs/cifs/smb2inode.c b/fs/cifs/smb2inode.c index fff6dfba6204..f50eefd9e005 100644 --- a/fs/cifs/smb2inode.c +++ b/fs/cifs/smb2inode.c @@ -41,8 +41,7 @@ static int smb2_open_op_close(const unsigned int xid, struct cifs_tcon *tcon, struct cifs_sb_info *cifs_sb, const char *full_path, __u32 desired_access, __u32 create_disposition, - __u32 file_attributes, __u32 create_options, - void *data, int command) + __u32 create_options, void *data, int command) { int rc, tmprc = 0; u64 persistent_fid, volatile_fid; @@ -54,8 +53,8 @@ smb2_open_op_close(const unsigned int xid, struct cifs_tcon *tcon, return -ENOMEM; rc = SMB2_open(xid, tcon, utf16_path, &persistent_fid, &volatile_fid, - desired_access, create_disposition, file_attributes, - create_options, &oplock, NULL); + desired_access, create_disposition, create_options, + &oplock, NULL); if (rc) { kfree(utf16_path); return rc; @@ -129,8 +128,8 @@ smb2_query_path_info(const unsigned int xid, struct cifs_tcon *tcon, return -ENOMEM; rc = smb2_open_op_close(xid, tcon, cifs_sb, full_path, - FILE_READ_ATTRIBUTES, FILE_OPEN, 0, 0, - smb2_data, SMB2_OP_QUERY_INFO); + FILE_READ_ATTRIBUTES, FILE_OPEN, 0, smb2_data, + SMB2_OP_QUERY_INFO); if (rc) goto out; @@ -145,7 +144,7 @@ smb2_mkdir(const unsigned int xid, struct cifs_tcon *tcon, const char *name, struct cifs_sb_info *cifs_sb) { return smb2_open_op_close(xid, tcon, cifs_sb, name, - FILE_WRITE_ATTRIBUTES, FILE_CREATE, 0, + FILE_WRITE_ATTRIBUTES, FILE_CREATE, CREATE_NOT_FILE, NULL, SMB2_OP_MKDIR); } @@ -164,7 +163,7 @@ smb2_mkdir_setinfo(struct inode *inode, const char *name, dosattrs = cifs_i->cifsAttrs | ATTR_READONLY; data.Attributes = cpu_to_le32(dosattrs); tmprc = smb2_open_op_close(xid, tcon, cifs_sb, name, - FILE_WRITE_ATTRIBUTES, FILE_CREATE, 0, + FILE_WRITE_ATTRIBUTES, FILE_CREATE, CREATE_NOT_FILE, &data, SMB2_OP_SET_INFO); if (tmprc == 0) cifs_i->cifsAttrs = dosattrs; @@ -175,7 +174,7 @@ smb2_rmdir(const unsigned int xid, struct cifs_tcon *tcon, const char *name, struct cifs_sb_info *cifs_sb) { return smb2_open_op_close(xid, tcon, cifs_sb, name, DELETE, FILE_OPEN, - 0, CREATE_NOT_FILE | CREATE_DELETE_ON_CLOSE, + CREATE_NOT_FILE | CREATE_DELETE_ON_CLOSE, NULL, SMB2_OP_DELETE); } @@ -184,7 +183,7 @@ smb2_unlink(const unsigned int xid, struct cifs_tcon *tcon, const char *name, struct cifs_sb_info *cifs_sb) { return smb2_open_op_close(xid, tcon, cifs_sb, name, DELETE, FILE_OPEN, - 0, CREATE_DELETE_ON_CLOSE, NULL, + CREATE_DELETE_ON_CLOSE, NULL, SMB2_OP_DELETE); } @@ -203,7 +202,7 @@ smb2_set_path_attr(const unsigned int xid, struct cifs_tcon *tcon, } rc = smb2_open_op_close(xid, tcon, cifs_sb, from_name, access, - FILE_OPEN, 0, 0, smb2_to_name, command); + FILE_OPEN, 0, smb2_to_name, command); smb2_rename_path: kfree(smb2_to_name); return rc; @@ -234,7 +233,7 @@ smb2_set_path_size(const unsigned int xid, struct cifs_tcon *tcon, { __le64 eof = cpu_to_le64(size); return smb2_open_op_close(xid, tcon, cifs_sb, full_path, - FILE_WRITE_DATA, FILE_OPEN, 0, 0, &eof, + FILE_WRITE_DATA, FILE_OPEN, 0, &eof, SMB2_OP_SET_EOF); } @@ -250,7 +249,7 @@ smb2_set_file_info(struct inode *inode, const char *full_path, if (IS_ERR(tlink)) return PTR_ERR(tlink); rc = smb2_open_op_close(xid, tlink_tcon(tlink), cifs_sb, full_path, - FILE_WRITE_ATTRIBUTES, FILE_OPEN, 0, 0, buf, + FILE_WRITE_ATTRIBUTES, FILE_OPEN, 0, buf, SMB2_OP_SET_INFO); cifs_put_tlink(tlink); return rc; diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c index 6d15cab95b99..92bdc7ec5c99 100644 --- a/fs/cifs/smb2ops.c +++ b/fs/cifs/smb2ops.c @@ -222,7 +222,7 @@ smb2_is_path_accessible(const unsigned int xid, struct cifs_tcon *tcon, return -ENOMEM; rc = SMB2_open(xid, tcon, utf16_path, &persistent_fid, &volatile_fid, - FILE_READ_ATTRIBUTES, FILE_OPEN, 0, 0, &oplock, NULL); + FILE_READ_ATTRIBUTES, FILE_OPEN, 0, &oplock, NULL); if (rc) { kfree(utf16_path); return rc; @@ -450,7 +450,7 @@ smb2_query_dir_first(const unsigned int xid, struct cifs_tcon *tcon, return -ENOMEM; rc = SMB2_open(xid, tcon, utf16_path, &persistent_fid, &volatile_fid, - FILE_READ_ATTRIBUTES | FILE_READ_DATA, FILE_OPEN, 0, 0, + FILE_READ_ATTRIBUTES | FILE_READ_DATA, FILE_OPEN, 0, &oplock, NULL); kfree(utf16_path); if (rc) { @@ -533,7 +533,7 @@ smb2_queryfs(const unsigned int xid, struct cifs_tcon *tcon, u8 oplock = SMB2_OPLOCK_LEVEL_NONE; rc = SMB2_open(xid, tcon, &srch_path, &persistent_fid, &volatile_fid, - FILE_READ_ATTRIBUTES, FILE_OPEN, 0, 0, &oplock, NULL); + FILE_READ_ATTRIBUTES, FILE_OPEN, 0, &oplock, NULL); if (rc) return rc; buf->f_type = SMB2_MAGIC_NUMBER; diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c index 19fafeb767fa..4c046a5b81af 100644 --- a/fs/cifs/smb2pdu.c +++ b/fs/cifs/smb2pdu.c @@ -881,8 +881,8 @@ parse_lease_state(struct smb2_create_rsp *rsp) int SMB2_open(const unsigned int xid, struct cifs_tcon *tcon, __le16 *path, u64 *persistent_fid, u64 *volatile_fid, __u32 desired_access, - __u32 create_disposition, __u32 file_attributes, __u32 create_options, - __u8 *oplock, struct smb2_file_all_info *buf) + __u32 create_disposition, __u32 create_options, __u8 *oplock, + struct smb2_file_all_info *buf) { struct smb2_create_req *req; struct smb2_create_rsp *rsp; @@ -895,6 +895,7 @@ SMB2_open(const unsigned int xid, struct cifs_tcon *tcon, __le16 *path, int copy_size; int rc = 0; int num_iovecs = 2; + __u32 file_attributes = 0; cifs_dbg(FYI, "create/open\n"); @@ -907,13 +908,16 @@ SMB2_open(const unsigned int xid, struct cifs_tcon *tcon, __le16 *path, if (rc) return rc; + if (create_options & CREATE_OPTION_READONLY) + file_attributes |= ATTR_READONLY; + req->ImpersonationLevel = IL_IMPERSONATION; req->DesiredAccess = cpu_to_le32(desired_access); /* File attributes ignored on open (used in create though) */ req->FileAttributes = cpu_to_le32(file_attributes); req->ShareAccess = FILE_SHARE_ALL_LE; req->CreateDisposition = cpu_to_le32(create_disposition); - req->CreateOptions = cpu_to_le32(create_options); + req->CreateOptions = cpu_to_le32(create_options & CREATE_OPTIONS_MASK); uni_path_len = (2 * UniStrnlen((wchar_t *)path, PATH_MAX)) + 2; req->NameOffset = cpu_to_le16(sizeof(struct smb2_create_req) - 8 /* pad */ - 4 /* do not count rfc1001 len field */); diff --git a/fs/cifs/smb2proto.h b/fs/cifs/smb2proto.h index d4e1eb807457..d71a3e2a772d 100644 --- a/fs/cifs/smb2proto.h +++ b/fs/cifs/smb2proto.h @@ -109,8 +109,8 @@ extern int SMB2_tdis(const unsigned int xid, struct cifs_tcon *tcon); extern int SMB2_open(const unsigned int xid, struct cifs_tcon *tcon, __le16 *path, u64 *persistent_fid, u64 *volatile_fid, __u32 desired_access, __u32 create_disposition, - __u32 file_attributes, __u32 create_options, - __u8 *oplock, struct smb2_file_all_info *buf); + __u32 create_options, __u8 *oplock, + struct smb2_file_all_info *buf); extern int SMB2_ioctl(const unsigned int xid, struct cifs_tcon *tcon, u64 persistent_fid, u64 volatile_fid, u32 opcode, bool is_fsctl, char *in_data, u32 indatalen, From 59aa371841ddb3a1a434497c6590542a785fa37c Mon Sep 17 00:00:00 2001 From: Pavel Shilovsky Date: Thu, 4 Jul 2013 19:41:24 +0400 Subject: [PATCH 0739/1048] CIFS: Simplify SMB2_open code path by passing a filename to a separate iovec regardless of its length. Signed-off-by: Pavel Shilovsky Signed-off-by: Steven French --- fs/cifs/smb2pdu.c | 57 +++++++++++++++++++---------------------------- fs/cifs/smb2pdu.h | 2 +- 2 files changed, 24 insertions(+), 35 deletions(-) diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c index 4c046a5b81af..9a35dcda9099 100644 --- a/fs/cifs/smb2pdu.c +++ b/fs/cifs/smb2pdu.c @@ -894,7 +894,7 @@ SMB2_open(const unsigned int xid, struct cifs_tcon *tcon, __le16 *path, __le16 *copy_path = NULL; int copy_size; int rc = 0; - int num_iovecs = 2; + unsigned int num_iovecs = 2; __u32 file_attributes = 0; cifs_dbg(FYI, "create/open\n"); @@ -919,47 +919,36 @@ SMB2_open(const unsigned int xid, struct cifs_tcon *tcon, __le16 *path, req->CreateDisposition = cpu_to_le32(create_disposition); req->CreateOptions = cpu_to_le32(create_options & CREATE_OPTIONS_MASK); uni_path_len = (2 * UniStrnlen((wchar_t *)path, PATH_MAX)) + 2; - req->NameOffset = cpu_to_le16(sizeof(struct smb2_create_req) - - 8 /* pad */ - 4 /* do not count rfc1001 len field */); + /* do not count rfc1001 len field */ + req->NameOffset = cpu_to_le16(sizeof(struct smb2_create_req) - 4); iov[0].iov_base = (char *)req; /* 4 for rfc1002 length field */ iov[0].iov_len = get_rfc1002_length(req) + 4; /* MUST set path len (NameLength) to 0 opening root of share */ - if (uni_path_len >= 4) { - req->NameLength = cpu_to_le16(uni_path_len - 2); - /* -1 since last byte is buf[0] which is sent below (path) */ - iov[0].iov_len--; - if (uni_path_len % 8 != 0) { - copy_size = uni_path_len / 8 * 8; - if (copy_size < uni_path_len) - copy_size += 8; + req->NameLength = cpu_to_le16(uni_path_len - 2); + /* -1 since last byte is buf[0] which is sent below (path) */ + iov[0].iov_len--; + if (uni_path_len % 8 != 0) { + copy_size = uni_path_len / 8 * 8; + if (copy_size < uni_path_len) + copy_size += 8; - copy_path = kzalloc(copy_size, GFP_KERNEL); - if (!copy_path) - return -ENOMEM; - memcpy((char *)copy_path, (const char *)path, - uni_path_len); - uni_path_len = copy_size; - path = copy_path; - } - - iov[1].iov_len = uni_path_len; - iov[1].iov_base = path; - /* - * -1 since last byte is buf[0] which was counted in - * smb2_buf_len. - */ - inc_rfc1001_len(req, uni_path_len - 1); - } else { - iov[0].iov_len += 7; - req->hdr.smb2_buf_length = cpu_to_be32(be32_to_cpu( - req->hdr.smb2_buf_length) + 8 - 1); - num_iovecs = 1; - req->NameLength = 0; + copy_path = kzalloc(copy_size, GFP_KERNEL); + if (!copy_path) + return -ENOMEM; + memcpy((char *)copy_path, (const char *)path, + uni_path_len); + uni_path_len = copy_size; + path = copy_path; } + iov[1].iov_len = uni_path_len; + iov[1].iov_base = path; + /* -1 since last byte is buf[0] which was counted in smb2_buf_len */ + inc_rfc1001_len(req, uni_path_len - 1); + if (!server->oplocks) *oplock = SMB2_OPLOCK_LEVEL_NONE; @@ -976,7 +965,7 @@ SMB2_open(const unsigned int xid, struct cifs_tcon *tcon, __le16 *path, iov[num_iovecs].iov_len = sizeof(struct create_lease); req->RequestedOplockLevel = SMB2_OPLOCK_LEVEL_LEASE; req->CreateContextsOffset = cpu_to_le32( - sizeof(struct smb2_create_req) - 4 - 8 + + sizeof(struct smb2_create_req) - 4 + iov[num_iovecs-1].iov_len); req->CreateContextsLength = cpu_to_le32( sizeof(struct create_lease)); diff --git a/fs/cifs/smb2pdu.h b/fs/cifs/smb2pdu.h index f31043b26bd3..8b1025f6f0da 100644 --- a/fs/cifs/smb2pdu.h +++ b/fs/cifs/smb2pdu.h @@ -428,7 +428,7 @@ struct smb2_create_req { __le16 NameLength; __le32 CreateContextsOffset; __le32 CreateContextsLength; - __u8 Buffer[8]; + __u8 Buffer[0]; } __packed; struct smb2_create_rsp { From d22cbfecbd9047465d9067a6eedc43434c888593 Mon Sep 17 00:00:00 2001 From: Pavel Shilovsky Date: Thu, 4 Jul 2013 19:10:00 +0400 Subject: [PATCH 0740/1048] CIFS: Simplify SMB2 create context handling to make it easier to add other create context further. Signed-off-by: Pavel Shilovsky Signed-off-by: Steven French --- fs/cifs/smb2pdu.c | 38 ++++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c index 9a35dcda9099..e65ccdb528cf 100644 --- a/fs/cifs/smb2pdu.c +++ b/fs/cifs/smb2pdu.c @@ -878,6 +878,29 @@ parse_lease_state(struct smb2_create_rsp *rsp) return smb2_map_lease_to_oplock(lc->lcontext.LeaseState); } +static int +add_lease_context(struct kvec *iov, unsigned int *num_iovec, __u8 *oplock) +{ + struct smb2_create_req *req = iov[0].iov_base; + unsigned int num = *num_iovec; + + iov[num].iov_base = create_lease_buf(oplock+1, *oplock); + if (iov[num].iov_base == NULL) + return -ENOMEM; + iov[num].iov_len = sizeof(struct create_lease); + req->RequestedOplockLevel = SMB2_OPLOCK_LEVEL_LEASE; + if (!req->CreateContextsOffset) + req->CreateContextsOffset = cpu_to_le32( + sizeof(struct smb2_create_req) - 4 + + iov[num - 1].iov_len); + req->CreateContextsLength = cpu_to_le32( + le32_to_cpu(req->CreateContextsLength) + + sizeof(struct create_lease)); + inc_rfc1001_len(&req->hdr, sizeof(struct create_lease)); + *num_iovec = num + 1; + return 0; +} + int SMB2_open(const unsigned int xid, struct cifs_tcon *tcon, __le16 *path, u64 *persistent_fid, u64 *volatile_fid, __u32 desired_access, @@ -956,21 +979,12 @@ SMB2_open(const unsigned int xid, struct cifs_tcon *tcon, __le16 *path, *oplock == SMB2_OPLOCK_LEVEL_NONE) req->RequestedOplockLevel = *oplock; else { - iov[num_iovecs].iov_base = create_lease_buf(oplock+1, *oplock); - if (iov[num_iovecs].iov_base == NULL) { + rc = add_lease_context(iov, &num_iovecs, oplock); + if (rc) { cifs_small_buf_release(req); kfree(copy_path); - return -ENOMEM; + return rc; } - iov[num_iovecs].iov_len = sizeof(struct create_lease); - req->RequestedOplockLevel = SMB2_OPLOCK_LEVEL_LEASE; - req->CreateContextsOffset = cpu_to_le32( - sizeof(struct smb2_create_req) - 4 + - iov[num_iovecs-1].iov_len); - req->CreateContextsLength = cpu_to_le32( - sizeof(struct create_lease)); - inc_rfc1001_len(&req->hdr, sizeof(struct create_lease)); - num_iovecs++; } rc = SendReceive2(xid, ses, iov, num_iovecs, &resp_buftype, 0); From 63eb3def3267a5744863801e8221898b0ba9d41d Mon Sep 17 00:00:00 2001 From: Pavel Shilovsky Date: Thu, 4 Jul 2013 18:41:09 +0400 Subject: [PATCH 0741/1048] CIFS: Request durable open for SMB2 opens by passing durable context together with a handle caching lease or batch oplock. Signed-off-by: Pavel Shilovsky Signed-off-by: Steven French --- fs/cifs/smb2file.c | 2 +- fs/cifs/smb2pdu.c | 62 +++++++++++++++++++++++++++++++++++++++++++++- fs/cifs/smb2pdu.h | 6 +++++ 3 files changed, 68 insertions(+), 2 deletions(-) diff --git a/fs/cifs/smb2file.c b/fs/cifs/smb2file.c index 46a4299b7ae8..150a9b1bc7fa 100644 --- a/fs/cifs/smb2file.c +++ b/fs/cifs/smb2file.c @@ -81,7 +81,7 @@ smb2_open_file(const unsigned int xid, struct cifs_tcon *tcon, const char *path, } desired_access |= FILE_READ_ATTRIBUTES; - *smb2_oplock = SMB2_OPLOCK_LEVEL_EXCLUSIVE; + *smb2_oplock = SMB2_OPLOCK_LEVEL_BATCH; if (tcon->ses->server->capabilities & SMB2_GLOBAL_CAP_LEASING) memcpy(smb2_oplock + 1, fid->lease_key, SMB2_LEASE_KEY_SIZE); diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c index e65ccdb528cf..140a613073fb 100644 --- a/fs/cifs/smb2pdu.c +++ b/fs/cifs/smb2pdu.c @@ -847,6 +847,28 @@ create_lease_buf(u8 *lease_key, u8 oplock) return buf; } +static struct create_durable * +create_durable_buf(void) +{ + struct create_durable *buf; + + buf = kzalloc(sizeof(struct create_durable), GFP_KERNEL); + if (!buf) + return NULL; + + buf->ccontext.DataOffset = cpu_to_le16(offsetof + (struct create_durable, Reserved)); + buf->ccontext.DataLength = cpu_to_le32(16); + buf->ccontext.NameOffset = cpu_to_le16(offsetof + (struct create_durable, Name)); + buf->ccontext.NameLength = cpu_to_le16(4); + buf->Name[0] = 'D'; + buf->Name[1] = 'H'; + buf->Name[2] = 'n'; + buf->Name[3] = 'Q'; + return buf; +} + static __u8 parse_lease_state(struct smb2_create_rsp *rsp) { @@ -901,6 +923,28 @@ add_lease_context(struct kvec *iov, unsigned int *num_iovec, __u8 *oplock) return 0; } +static int +add_durable_context(struct kvec *iov, unsigned int *num_iovec) +{ + struct smb2_create_req *req = iov[0].iov_base; + unsigned int num = *num_iovec; + + iov[num].iov_base = create_durable_buf(); + if (iov[num].iov_base == NULL) + return -ENOMEM; + iov[num].iov_len = sizeof(struct create_durable); + if (!req->CreateContextsOffset) + req->CreateContextsOffset = + cpu_to_le32(sizeof(struct smb2_create_req) - 4 + + iov[1].iov_len); + req->CreateContextsLength = + cpu_to_le32(le32_to_cpu(req->CreateContextsLength) + + sizeof(struct create_durable)); + inc_rfc1001_len(&req->hdr, sizeof(struct create_durable)); + *num_iovec = num + 1; + return 0; +} + int SMB2_open(const unsigned int xid, struct cifs_tcon *tcon, __le16 *path, u64 *persistent_fid, u64 *volatile_fid, __u32 desired_access, @@ -911,7 +955,7 @@ SMB2_open(const unsigned int xid, struct cifs_tcon *tcon, __le16 *path, struct smb2_create_rsp *rsp; struct TCP_Server_Info *server; struct cifs_ses *ses = tcon->ses; - struct kvec iov[3]; + struct kvec iov[4]; int resp_buftype; int uni_path_len; __le16 *copy_path = NULL; @@ -987,6 +1031,22 @@ SMB2_open(const unsigned int xid, struct cifs_tcon *tcon, __le16 *path, } } + if (*oplock == SMB2_OPLOCK_LEVEL_BATCH) { + /* need to set Next field of lease context if we request it */ + if (tcon->ses->server->capabilities & SMB2_GLOBAL_CAP_LEASING) { + struct create_context *ccontext = + (struct create_context *)iov[num_iovecs-1].iov_base; + ccontext->Next = sizeof(struct create_lease); + } + rc = add_durable_context(iov, &num_iovecs); + if (rc) { + cifs_small_buf_release(req); + kfree(copy_path); + kfree(iov[num_iovecs-1].iov_base); + return rc; + } + } + rc = SendReceive2(xid, ses, iov, num_iovecs, &resp_buftype, 0); rsp = (struct smb2_create_rsp *)iov[0].iov_base; diff --git a/fs/cifs/smb2pdu.h b/fs/cifs/smb2pdu.h index 8b1025f6f0da..3e30f0ad5749 100644 --- a/fs/cifs/smb2pdu.h +++ b/fs/cifs/smb2pdu.h @@ -485,6 +485,12 @@ struct create_lease { struct lease_context lcontext; } __packed; +struct create_durable { + struct create_context ccontext; + __u8 Name[8]; + __u8 Reserved[16]; +} __packed; + /* this goes in the ioctl buffer when doing a copychunk request */ struct copychunk_ioctl { char SourceKey[24]; From 226730b4d8adae393dc07092655cdd29d2a2ff07 Mon Sep 17 00:00:00 2001 From: Pavel Shilovsky Date: Fri, 5 Jul 2013 12:00:30 +0400 Subject: [PATCH 0742/1048] CIFS: Introduce cifs_open_parms struct and pass it to the open() call. Signed-off-by: Pavel Shilovsky Signed-off-by: Steven French --- fs/cifs/cifsglob.h | 16 +++++++++++++--- fs/cifs/dir.c | 13 ++++++++++--- fs/cifs/file.c | 26 ++++++++++++++++++++------ fs/cifs/smb1ops.c | 27 +++++++++++++++------------ fs/cifs/smb2file.c | 22 +++++++++++----------- fs/cifs/smb2proto.h | 8 +++----- 6 files changed, 72 insertions(+), 40 deletions(-) diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h index e66b08882548..982fdf92c791 100644 --- a/fs/cifs/cifsglob.h +++ b/fs/cifs/cifsglob.h @@ -194,6 +194,7 @@ struct cifs_writedata; struct cifs_io_parms; struct cifs_search_info; struct cifsInodeInfo; +struct cifs_open_parms; struct smb_version_operations { int (*send_cancel)(struct TCP_Server_Info *, void *, @@ -307,9 +308,8 @@ struct smb_version_operations { const char *, const char *, struct cifs_sb_info *); /* open a file for non-posix mounts */ - int (*open)(const unsigned int, struct cifs_tcon *, const char *, int, - int, int, struct cifs_fid *, __u32 *, FILE_ALL_INFO *, - struct cifs_sb_info *); + int (*open)(const unsigned int, struct cifs_open_parms *, + __u32 *, FILE_ALL_INFO *); /* set fid protocol-specific info */ void (*set_fid)(struct cifsFileInfo *, struct cifs_fid *, __u32); /* close a file */ @@ -912,6 +912,16 @@ struct cifs_search_info { bool smallBuf:1; /* so we know which buf_release function to call */ }; +struct cifs_open_parms { + struct cifs_tcon *tcon; + struct cifs_sb_info *cifs_sb; + int disposition; + int desired_access; + int create_options; + const char *path; + struct cifs_fid *fid; +}; + struct cifs_fid { __u16 netfid; #ifdef CONFIG_CIFS_SMB2 diff --git a/fs/cifs/dir.c b/fs/cifs/dir.c index 5175aebf6737..c27c242ac5ba 100644 --- a/fs/cifs/dir.c +++ b/fs/cifs/dir.c @@ -204,6 +204,7 @@ cifs_do_create(struct inode *inode, struct dentry *direntry, unsigned int xid, struct inode *newinode = NULL; int disposition; struct TCP_Server_Info *server = tcon->ses->server; + struct cifs_open_parms oparms; *oplock = 0; if (tcon->ses->server->oplocks) @@ -319,9 +320,15 @@ cifs_do_create(struct inode *inode, struct dentry *direntry, unsigned int xid, if (backup_cred(cifs_sb)) create_options |= CREATE_OPEN_BACKUP_INTENT; - rc = server->ops->open(xid, tcon, full_path, disposition, - desired_access, create_options, fid, oplock, - buf, cifs_sb); + oparms.tcon = tcon; + oparms.cifs_sb = cifs_sb; + oparms.desired_access = desired_access; + oparms.create_options = create_options; + oparms.disposition = disposition; + oparms.path = full_path; + oparms.fid = fid; + + rc = server->ops->open(xid, &oparms, oplock, buf); if (rc) { cifs_dbg(FYI, "cifs_create returned 0x%x\n", rc); goto out; diff --git a/fs/cifs/file.c b/fs/cifs/file.c index 91d8629e69a2..f36f9a7893da 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c @@ -183,6 +183,7 @@ cifs_nt_open(char *full_path, struct inode *inode, struct cifs_sb_info *cifs_sb, int create_options = CREATE_NOT_DIR; FILE_ALL_INFO *buf; struct TCP_Server_Info *server = tcon->ses->server; + struct cifs_open_parms oparms; if (!server->ops->open) return -ENOSYS; @@ -224,9 +225,15 @@ cifs_nt_open(char *full_path, struct inode *inode, struct cifs_sb_info *cifs_sb, if (backup_cred(cifs_sb)) create_options |= CREATE_OPEN_BACKUP_INTENT; - rc = server->ops->open(xid, tcon, full_path, disposition, - desired_access, create_options, fid, oplock, buf, - cifs_sb); + oparms.tcon = tcon; + oparms.cifs_sb = cifs_sb; + oparms.desired_access = desired_access; + oparms.create_options = create_options; + oparms.disposition = disposition; + oparms.path = full_path; + oparms.fid = fid; + + rc = server->ops->open(xid, &oparms, oplock, buf); if (rc) goto out; @@ -588,6 +595,7 @@ cifs_reopen_file(struct cifsFileInfo *cfile, bool can_flush) int disposition = FILE_OPEN; int create_options = CREATE_NOT_DIR; struct cifs_fid fid; + struct cifs_open_parms oparms; xid = get_xid(); mutex_lock(&cfile->fh_mutex); @@ -656,6 +664,14 @@ cifs_reopen_file(struct cifsFileInfo *cfile, bool can_flush) if (server->ops->get_lease_key) server->ops->get_lease_key(inode, &fid); + oparms.tcon = tcon; + oparms.cifs_sb = cifs_sb; + oparms.desired_access = desired_access; + oparms.create_options = create_options; + oparms.disposition = disposition; + oparms.path = full_path; + oparms.fid = &fid; + /* * Can not refresh inode by passing in file_info buf to be returned by * CIFSSMBOpen and then calling get_inode_info with returned buf since @@ -663,9 +679,7 @@ cifs_reopen_file(struct cifsFileInfo *cfile, bool can_flush) * version of file size can be stale. If we knew for sure that inode was * not dirty locally we could do this. */ - rc = server->ops->open(xid, tcon, full_path, disposition, - desired_access, create_options, &fid, &oplock, - NULL, cifs_sb); + rc = server->ops->open(xid, &oparms, &oplock, NULL); if (rc) { mutex_unlock(&cfile->fh_mutex); cifs_dbg(FYI, "cifs_reopen returned 0x%x\n", rc); diff --git a/fs/cifs/smb1ops.c b/fs/cifs/smb1ops.c index e813f04511d8..6457690731a2 100644 --- a/fs/cifs/smb1ops.c +++ b/fs/cifs/smb1ops.c @@ -674,20 +674,23 @@ cifs_mkdir_setinfo(struct inode *inode, const char *full_path, } static int -cifs_open_file(const unsigned int xid, struct cifs_tcon *tcon, const char *path, - int disposition, int desired_access, int create_options, - struct cifs_fid *fid, __u32 *oplock, FILE_ALL_INFO *buf, - struct cifs_sb_info *cifs_sb) +cifs_open_file(const unsigned int xid, struct cifs_open_parms *oparms, + __u32 *oplock, FILE_ALL_INFO *buf) { - if (!(tcon->ses->capabilities & CAP_NT_SMBS)) - return SMBLegacyOpen(xid, tcon, path, disposition, - desired_access, create_options, - &fid->netfid, oplock, buf, - cifs_sb->local_nls, cifs_sb->mnt_cifs_flags + if (!(oparms->tcon->ses->capabilities & CAP_NT_SMBS)) + return SMBLegacyOpen(xid, oparms->tcon, oparms->path, + oparms->disposition, + oparms->desired_access, + oparms->create_options, + &oparms->fid->netfid, oplock, buf, + oparms->cifs_sb->local_nls, + oparms->cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR); - return CIFSSMBOpen(xid, tcon, path, disposition, desired_access, - create_options, &fid->netfid, oplock, buf, - cifs_sb->local_nls, cifs_sb->mnt_cifs_flags & + return CIFSSMBOpen(xid, oparms->tcon, oparms->path, + oparms->disposition, oparms->desired_access, + oparms->create_options, &oparms->fid->netfid, oplock, + buf, oparms->cifs_sb->local_nls, + oparms->cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR); } diff --git a/fs/cifs/smb2file.c b/fs/cifs/smb2file.c index 150a9b1bc7fa..5bab192f64e8 100644 --- a/fs/cifs/smb2file.c +++ b/fs/cifs/smb2file.c @@ -57,17 +57,16 @@ smb2_set_oplock_level(struct cifsInodeInfo *cinode, __u32 oplock) } int -smb2_open_file(const unsigned int xid, struct cifs_tcon *tcon, const char *path, - int disposition, int desired_access, int create_options, - struct cifs_fid *fid, __u32 *oplock, FILE_ALL_INFO *buf, - struct cifs_sb_info *cifs_sb) +smb2_open_file(const unsigned int xid, struct cifs_open_parms *oparms, + __u32 *oplock, FILE_ALL_INFO *buf) { int rc; __le16 *smb2_path; struct smb2_file_all_info *smb2_data = NULL; __u8 smb2_oplock[17]; + struct cifs_fid *fid = oparms->fid; - smb2_path = cifs_convert_path_to_utf16(path, cifs_sb); + smb2_path = cifs_convert_path_to_utf16(oparms->path, oparms->cifs_sb); if (smb2_path == NULL) { rc = -ENOMEM; goto out; @@ -80,21 +79,22 @@ smb2_open_file(const unsigned int xid, struct cifs_tcon *tcon, const char *path, goto out; } - desired_access |= FILE_READ_ATTRIBUTES; + oparms->desired_access |= FILE_READ_ATTRIBUTES; *smb2_oplock = SMB2_OPLOCK_LEVEL_BATCH; - if (tcon->ses->server->capabilities & SMB2_GLOBAL_CAP_LEASING) + if (oparms->tcon->ses->server->capabilities & SMB2_GLOBAL_CAP_LEASING) memcpy(smb2_oplock + 1, fid->lease_key, SMB2_LEASE_KEY_SIZE); - rc = SMB2_open(xid, tcon, smb2_path, &fid->persistent_fid, - &fid->volatile_fid, desired_access, disposition, - create_options, smb2_oplock, smb2_data); + rc = SMB2_open(xid, oparms->tcon, smb2_path, &fid->persistent_fid, + &fid->volatile_fid, oparms->desired_access, + oparms->disposition, oparms->create_options, smb2_oplock, + smb2_data); if (rc) goto out; if (buf) { /* open response does not have IndexNumber field - get it */ - rc = SMB2_get_srv_num(xid, tcon, fid->persistent_fid, + rc = SMB2_get_srv_num(xid, oparms->tcon, fid->persistent_fid, fid->volatile_fid, &smb2_data->IndexNumber); if (rc) { diff --git a/fs/cifs/smb2proto.h b/fs/cifs/smb2proto.h index d71a3e2a772d..206efde13f71 100644 --- a/fs/cifs/smb2proto.h +++ b/fs/cifs/smb2proto.h @@ -84,11 +84,9 @@ extern int smb2_create_hardlink(const unsigned int xid, struct cifs_tcon *tcon, const char *from_name, const char *to_name, struct cifs_sb_info *cifs_sb); -extern int smb2_open_file(const unsigned int xid, struct cifs_tcon *tcon, - const char *full_path, int disposition, - int desired_access, int create_options, - struct cifs_fid *fid, __u32 *oplock, - FILE_ALL_INFO *buf, struct cifs_sb_info *cifs_sb); +extern int smb2_open_file(const unsigned int xid, + struct cifs_open_parms *oparms, + __u32 *oplock, FILE_ALL_INFO *buf); extern void smb2_set_oplock_level(struct cifsInodeInfo *cinode, __u32 oplock); extern int smb2_unlock_range(struct cifsFileInfo *cfile, struct file_lock *flock, const unsigned int xid); From 064f6047a123d61dd52bb44605c999cd8ef727d9 Mon Sep 17 00:00:00 2001 From: Pavel Shilovsky Date: Tue, 9 Jul 2013 18:20:30 +0400 Subject: [PATCH 0743/1048] CIFS: Make SMB2_open use cifs_open_parms struct to prepare it for further durable handle reconnect processing. Signed-off-by: Pavel Shilovsky Signed-off-by: Steven French --- fs/cifs/smb2file.c | 5 +---- fs/cifs/smb2inode.c | 35 ++++++++++++++++++------------- fs/cifs/smb2ops.c | 51 +++++++++++++++++++++++++++++---------------- fs/cifs/smb2pdu.c | 19 ++++++++--------- fs/cifs/smb2proto.h | 6 ++---- 5 files changed, 66 insertions(+), 50 deletions(-) diff --git a/fs/cifs/smb2file.c b/fs/cifs/smb2file.c index 5bab192f64e8..398992962cc6 100644 --- a/fs/cifs/smb2file.c +++ b/fs/cifs/smb2file.c @@ -85,10 +85,7 @@ smb2_open_file(const unsigned int xid, struct cifs_open_parms *oparms, if (oparms->tcon->ses->server->capabilities & SMB2_GLOBAL_CAP_LEASING) memcpy(smb2_oplock + 1, fid->lease_key, SMB2_LEASE_KEY_SIZE); - rc = SMB2_open(xid, oparms->tcon, smb2_path, &fid->persistent_fid, - &fid->volatile_fid, oparms->desired_access, - oparms->disposition, oparms->create_options, smb2_oplock, - smb2_data); + rc = SMB2_open(xid, oparms, smb2_path, smb2_oplock, smb2_data); if (rc) goto out; diff --git a/fs/cifs/smb2inode.c b/fs/cifs/smb2inode.c index f50eefd9e005..9841df771f08 100644 --- a/fs/cifs/smb2inode.c +++ b/fs/cifs/smb2inode.c @@ -44,17 +44,22 @@ smb2_open_op_close(const unsigned int xid, struct cifs_tcon *tcon, __u32 create_options, void *data, int command) { int rc, tmprc = 0; - u64 persistent_fid, volatile_fid; __le16 *utf16_path; __u8 oplock = SMB2_OPLOCK_LEVEL_NONE; + struct cifs_open_parms oparms; + struct cifs_fid fid; utf16_path = cifs_convert_path_to_utf16(full_path, cifs_sb); if (!utf16_path) return -ENOMEM; - rc = SMB2_open(xid, tcon, utf16_path, &persistent_fid, &volatile_fid, - desired_access, create_disposition, create_options, - &oplock, NULL); + oparms.tcon = tcon; + oparms.desired_access = desired_access; + oparms.disposition = create_disposition; + oparms.create_options = create_options; + oparms.fid = &fid; + + rc = SMB2_open(xid, &oparms, utf16_path, &oplock, NULL); if (rc) { kfree(utf16_path); return rc; @@ -64,8 +69,8 @@ smb2_open_op_close(const unsigned int xid, struct cifs_tcon *tcon, case SMB2_OP_DELETE: break; case SMB2_OP_QUERY_INFO: - tmprc = SMB2_query_info(xid, tcon, persistent_fid, - volatile_fid, + tmprc = SMB2_query_info(xid, tcon, fid.persistent_fid, + fid.volatile_fid, (struct smb2_file_all_info *)data); break; case SMB2_OP_MKDIR: @@ -75,19 +80,21 @@ smb2_open_op_close(const unsigned int xid, struct cifs_tcon *tcon, */ break; case SMB2_OP_RENAME: - tmprc = SMB2_rename(xid, tcon, persistent_fid, volatile_fid, - (__le16 *)data); + tmprc = SMB2_rename(xid, tcon, fid.persistent_fid, + fid.volatile_fid, (__le16 *)data); break; case SMB2_OP_HARDLINK: - tmprc = SMB2_set_hardlink(xid, tcon, persistent_fid, - volatile_fid, (__le16 *)data); + tmprc = SMB2_set_hardlink(xid, tcon, fid.persistent_fid, + fid.volatile_fid, (__le16 *)data); break; case SMB2_OP_SET_EOF: - tmprc = SMB2_set_eof(xid, tcon, persistent_fid, volatile_fid, - current->tgid, (__le64 *)data); + tmprc = SMB2_set_eof(xid, tcon, fid.persistent_fid, + fid.volatile_fid, current->tgid, + (__le64 *)data); break; case SMB2_OP_SET_INFO: - tmprc = SMB2_set_info(xid, tcon, persistent_fid, volatile_fid, + tmprc = SMB2_set_info(xid, tcon, fid.persistent_fid, + fid.volatile_fid, (FILE_BASIC_INFO *)data); break; default: @@ -95,7 +102,7 @@ smb2_open_op_close(const unsigned int xid, struct cifs_tcon *tcon, break; } - rc = SMB2_close(xid, tcon, persistent_fid, volatile_fid); + rc = SMB2_close(xid, tcon, fid.persistent_fid, fid.volatile_fid); if (tmprc) rc = tmprc; kfree(utf16_path); diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c index 92bdc7ec5c99..1bc7d7e64cf5 100644 --- a/fs/cifs/smb2ops.c +++ b/fs/cifs/smb2ops.c @@ -213,22 +213,28 @@ smb2_is_path_accessible(const unsigned int xid, struct cifs_tcon *tcon, struct cifs_sb_info *cifs_sb, const char *full_path) { int rc; - __u64 persistent_fid, volatile_fid; __le16 *utf16_path; __u8 oplock = SMB2_OPLOCK_LEVEL_NONE; + struct cifs_open_parms oparms; + struct cifs_fid fid; utf16_path = cifs_convert_path_to_utf16(full_path, cifs_sb); if (!utf16_path) return -ENOMEM; - rc = SMB2_open(xid, tcon, utf16_path, &persistent_fid, &volatile_fid, - FILE_READ_ATTRIBUTES, FILE_OPEN, 0, &oplock, NULL); + oparms.tcon = tcon; + oparms.desired_access = FILE_READ_ATTRIBUTES; + oparms.disposition = FILE_OPEN; + oparms.create_options = 0; + oparms.fid = &fid; + + rc = SMB2_open(xid, &oparms, utf16_path, &oplock, NULL); if (rc) { kfree(utf16_path); return rc; } - rc = SMB2_close(xid, tcon, persistent_fid, volatile_fid); + rc = SMB2_close(xid, tcon, fid.persistent_fid, fid.volatile_fid); kfree(utf16_path); return rc; } @@ -443,15 +449,19 @@ smb2_query_dir_first(const unsigned int xid, struct cifs_tcon *tcon, __le16 *utf16_path; int rc; __u8 oplock = SMB2_OPLOCK_LEVEL_NONE; - __u64 persistent_fid, volatile_fid; + struct cifs_open_parms oparms; utf16_path = cifs_convert_path_to_utf16(path, cifs_sb); if (!utf16_path) return -ENOMEM; - rc = SMB2_open(xid, tcon, utf16_path, &persistent_fid, &volatile_fid, - FILE_READ_ATTRIBUTES | FILE_READ_DATA, FILE_OPEN, 0, - &oplock, NULL); + oparms.tcon = tcon; + oparms.desired_access = FILE_READ_ATTRIBUTES | FILE_READ_DATA; + oparms.disposition = FILE_OPEN; + oparms.create_options = 0; + oparms.fid = fid; + + rc = SMB2_open(xid, &oparms, utf16_path, &oplock, NULL); kfree(utf16_path); if (rc) { cifs_dbg(VFS, "open dir failed\n"); @@ -460,14 +470,12 @@ smb2_query_dir_first(const unsigned int xid, struct cifs_tcon *tcon, srch_inf->entries_in_buffer = 0; srch_inf->index_of_last_entry = 0; - fid->persistent_fid = persistent_fid; - fid->volatile_fid = volatile_fid; - rc = SMB2_query_directory(xid, tcon, persistent_fid, volatile_fid, 0, - srch_inf); + rc = SMB2_query_directory(xid, tcon, fid->persistent_fid, + fid->volatile_fid, 0, srch_inf); if (rc) { cifs_dbg(VFS, "query directory failed\n"); - SMB2_close(xid, tcon, persistent_fid, volatile_fid); + SMB2_close(xid, tcon, fid->persistent_fid, fid->volatile_fid); } return rc; } @@ -528,17 +536,24 @@ smb2_queryfs(const unsigned int xid, struct cifs_tcon *tcon, struct kstatfs *buf) { int rc; - u64 persistent_fid, volatile_fid; __le16 srch_path = 0; /* Null - open root of share */ u8 oplock = SMB2_OPLOCK_LEVEL_NONE; + struct cifs_open_parms oparms; + struct cifs_fid fid; - rc = SMB2_open(xid, tcon, &srch_path, &persistent_fid, &volatile_fid, - FILE_READ_ATTRIBUTES, FILE_OPEN, 0, &oplock, NULL); + oparms.tcon = tcon; + oparms.desired_access = FILE_READ_ATTRIBUTES; + oparms.disposition = FILE_OPEN; + oparms.create_options = 0; + oparms.fid = &fid; + + rc = SMB2_open(xid, &oparms, &srch_path, &oplock, NULL); if (rc) return rc; buf->f_type = SMB2_MAGIC_NUMBER; - rc = SMB2_QFS_info(xid, tcon, persistent_fid, volatile_fid, buf); - SMB2_close(xid, tcon, persistent_fid, volatile_fid); + rc = SMB2_QFS_info(xid, tcon, fid.persistent_fid, fid.volatile_fid, + buf); + SMB2_close(xid, tcon, fid.persistent_fid, fid.volatile_fid); return rc; } diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c index 140a613073fb..9d7341d696fc 100644 --- a/fs/cifs/smb2pdu.c +++ b/fs/cifs/smb2pdu.c @@ -946,14 +946,13 @@ add_durable_context(struct kvec *iov, unsigned int *num_iovec) } int -SMB2_open(const unsigned int xid, struct cifs_tcon *tcon, __le16 *path, - u64 *persistent_fid, u64 *volatile_fid, __u32 desired_access, - __u32 create_disposition, __u32 create_options, __u8 *oplock, - struct smb2_file_all_info *buf) +SMB2_open(const unsigned int xid, struct cifs_open_parms *oparms, __le16 *path, + __u8 *oplock, struct smb2_file_all_info *buf) { struct smb2_create_req *req; struct smb2_create_rsp *rsp; struct TCP_Server_Info *server; + struct cifs_tcon *tcon = oparms->tcon; struct cifs_ses *ses = tcon->ses; struct kvec iov[4]; int resp_buftype; @@ -975,16 +974,16 @@ SMB2_open(const unsigned int xid, struct cifs_tcon *tcon, __le16 *path, if (rc) return rc; - if (create_options & CREATE_OPTION_READONLY) + if (oparms->create_options & CREATE_OPTION_READONLY) file_attributes |= ATTR_READONLY; req->ImpersonationLevel = IL_IMPERSONATION; - req->DesiredAccess = cpu_to_le32(desired_access); + req->DesiredAccess = cpu_to_le32(oparms->desired_access); /* File attributes ignored on open (used in create though) */ req->FileAttributes = cpu_to_le32(file_attributes); req->ShareAccess = FILE_SHARE_ALL_LE; - req->CreateDisposition = cpu_to_le32(create_disposition); - req->CreateOptions = cpu_to_le32(create_options & CREATE_OPTIONS_MASK); + req->CreateDisposition = cpu_to_le32(oparms->disposition); + req->CreateOptions = cpu_to_le32(oparms->create_options & CREATE_OPTIONS_MASK); uni_path_len = (2 * UniStrnlen((wchar_t *)path, PATH_MAX)) + 2; /* do not count rfc1001 len field */ req->NameOffset = cpu_to_le16(sizeof(struct smb2_create_req) - 4); @@ -1055,8 +1054,8 @@ SMB2_open(const unsigned int xid, struct cifs_tcon *tcon, __le16 *path, goto creat_exit; } - *persistent_fid = rsp->PersistentFileId; - *volatile_fid = rsp->VolatileFileId; + oparms->fid->persistent_fid = rsp->PersistentFileId; + oparms->fid->volatile_fid = rsp->VolatileFileId; if (buf) { memcpy(buf, &rsp->CreationTime, 32); diff --git a/fs/cifs/smb2proto.h b/fs/cifs/smb2proto.h index 206efde13f71..1a5ecbed40ed 100644 --- a/fs/cifs/smb2proto.h +++ b/fs/cifs/smb2proto.h @@ -104,10 +104,8 @@ extern int SMB2_tcon(const unsigned int xid, struct cifs_ses *ses, const char *tree, struct cifs_tcon *tcon, const struct nls_table *); extern int SMB2_tdis(const unsigned int xid, struct cifs_tcon *tcon); -extern int SMB2_open(const unsigned int xid, struct cifs_tcon *tcon, - __le16 *path, u64 *persistent_fid, u64 *volatile_fid, - __u32 desired_access, __u32 create_disposition, - __u32 create_options, __u8 *oplock, +extern int SMB2_open(const unsigned int xid, struct cifs_open_parms *oparms, + __le16 *path, __u8 *oplock, struct smb2_file_all_info *buf); extern int SMB2_ioctl(const unsigned int xid, struct cifs_tcon *tcon, u64 persistent_fid, u64 volatile_fid, u32 opcode, From 9cbc0b7339b0542a1d13922d2745a2636ce44853 Mon Sep 17 00:00:00 2001 From: Pavel Shilovsky Date: Tue, 9 Jul 2013 18:40:58 +0400 Subject: [PATCH 0744/1048] CIFS: Reconnect durable handles for SMB2 On reconnects, we need to reopen file and then obtain all byte-range locks held by the client. SMB2 protocol provides feature to make this process atomic by reconnecting to the same file handle with all it's byte-range locks. This patch adds this capability for SMB2 shares. Signed-off-by: Pavel Shilovsky Signed-off-by: Steven French --- fs/cifs/cifsglob.h | 1 + fs/cifs/dir.c | 1 + fs/cifs/file.c | 15 +++++++++------ fs/cifs/smb2file.c | 3 ++- fs/cifs/smb2inode.c | 1 + fs/cifs/smb2ops.c | 3 +++ fs/cifs/smb2pdu.c | 38 ++++++++++++++++++++++++++++++++++---- fs/cifs/smb2pdu.h | 8 +++++++- 8 files changed, 58 insertions(+), 12 deletions(-) diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h index 982fdf92c791..1fdc37041057 100644 --- a/fs/cifs/cifsglob.h +++ b/fs/cifs/cifsglob.h @@ -920,6 +920,7 @@ struct cifs_open_parms { int create_options; const char *path; struct cifs_fid *fid; + bool reconnect:1; }; struct cifs_fid { diff --git a/fs/cifs/dir.c b/fs/cifs/dir.c index c27c242ac5ba..d62ce0d48141 100644 --- a/fs/cifs/dir.c +++ b/fs/cifs/dir.c @@ -327,6 +327,7 @@ cifs_do_create(struct inode *inode, struct dentry *direntry, unsigned int xid, oparms.disposition = disposition; oparms.path = full_path; oparms.fid = fid; + oparms.reconnect = false; rc = server->ops->open(xid, &oparms, oplock, buf); if (rc) { diff --git a/fs/cifs/file.c b/fs/cifs/file.c index f36f9a7893da..ba7eed2ee662 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c @@ -232,6 +232,7 @@ cifs_nt_open(char *full_path, struct inode *inode, struct cifs_sb_info *cifs_sb, oparms.disposition = disposition; oparms.path = full_path; oparms.fid = fid; + oparms.reconnect = false; rc = server->ops->open(xid, &oparms, oplock, buf); @@ -594,7 +595,6 @@ cifs_reopen_file(struct cifsFileInfo *cfile, bool can_flush) int desired_access; int disposition = FILE_OPEN; int create_options = CREATE_NOT_DIR; - struct cifs_fid fid; struct cifs_open_parms oparms; xid = get_xid(); @@ -645,7 +645,7 @@ cifs_reopen_file(struct cifsFileInfo *cfile, bool can_flush) rc = cifs_posix_open(full_path, NULL, inode->i_sb, cifs_sb->mnt_file_mode /* ignored */, - oflags, &oplock, &fid.netfid, xid); + oflags, &oplock, &cfile->fid.netfid, xid); if (rc == 0) { cifs_dbg(FYI, "posix reopen succeeded\n"); goto reopen_success; @@ -662,7 +662,7 @@ cifs_reopen_file(struct cifsFileInfo *cfile, bool can_flush) create_options |= CREATE_OPEN_BACKUP_INTENT; if (server->ops->get_lease_key) - server->ops->get_lease_key(inode, &fid); + server->ops->get_lease_key(inode, &cfile->fid); oparms.tcon = tcon; oparms.cifs_sb = cifs_sb; @@ -670,7 +670,8 @@ cifs_reopen_file(struct cifsFileInfo *cfile, bool can_flush) oparms.create_options = create_options; oparms.disposition = disposition; oparms.path = full_path; - oparms.fid = &fid; + oparms.fid = &cfile->fid; + oparms.reconnect = true; /* * Can not refresh inode by passing in file_info buf to be returned by @@ -710,8 +711,9 @@ reopen_success: * to the server to get the new inode info. */ - server->ops->set_fid(cfile, &fid, oplock); - cifs_relock_file(cfile); + server->ops->set_fid(cfile, &cfile->fid, oplock); + if (oparms.reconnect) + cifs_relock_file(cfile); reopen_error_exit: kfree(full_path); @@ -1508,6 +1510,7 @@ cifs_setlk(struct file *file, struct file_lock *flock, __u32 type, if (!rc) goto out; + /* * Windows 7 server can delay breaking lease from read to None * if we set a byte-range lock on a file - break it explicitly diff --git a/fs/cifs/smb2file.c b/fs/cifs/smb2file.c index 398992962cc6..04a81a4142c3 100644 --- a/fs/cifs/smb2file.c +++ b/fs/cifs/smb2file.c @@ -40,7 +40,8 @@ smb2_set_oplock_level(struct cifsInodeInfo *cinode, __u32 oplock) oplock &= 0xFF; if (oplock == SMB2_OPLOCK_LEVEL_NOCHANGE) return; - if (oplock == SMB2_OPLOCK_LEVEL_EXCLUSIVE) { + if (oplock == SMB2_OPLOCK_LEVEL_EXCLUSIVE || + oplock == SMB2_OPLOCK_LEVEL_BATCH) { cinode->clientCanCacheAll = true; cinode->clientCanCacheRead = true; cifs_dbg(FYI, "Exclusive Oplock granted on inode %p\n", diff --git a/fs/cifs/smb2inode.c b/fs/cifs/smb2inode.c index 9841df771f08..c6ec1633309a 100644 --- a/fs/cifs/smb2inode.c +++ b/fs/cifs/smb2inode.c @@ -58,6 +58,7 @@ smb2_open_op_close(const unsigned int xid, struct cifs_tcon *tcon, oparms.disposition = create_disposition; oparms.create_options = create_options; oparms.fid = &fid; + oparms.reconnect = false; rc = SMB2_open(xid, &oparms, utf16_path, &oplock, NULL); if (rc) { diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c index 1bc7d7e64cf5..f259e6cc8357 100644 --- a/fs/cifs/smb2ops.c +++ b/fs/cifs/smb2ops.c @@ -227,6 +227,7 @@ smb2_is_path_accessible(const unsigned int xid, struct cifs_tcon *tcon, oparms.disposition = FILE_OPEN; oparms.create_options = 0; oparms.fid = &fid; + oparms.reconnect = false; rc = SMB2_open(xid, &oparms, utf16_path, &oplock, NULL); if (rc) { @@ -460,6 +461,7 @@ smb2_query_dir_first(const unsigned int xid, struct cifs_tcon *tcon, oparms.disposition = FILE_OPEN; oparms.create_options = 0; oparms.fid = fid; + oparms.reconnect = false; rc = SMB2_open(xid, &oparms, utf16_path, &oplock, NULL); kfree(utf16_path); @@ -546,6 +548,7 @@ smb2_queryfs(const unsigned int xid, struct cifs_tcon *tcon, oparms.disposition = FILE_OPEN; oparms.create_options = 0; oparms.fid = &fid; + oparms.reconnect = false; rc = SMB2_open(xid, &oparms, &srch_path, &oplock, NULL); if (rc) diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c index 9d7341d696fc..c7ad06fc9d63 100644 --- a/fs/cifs/smb2pdu.c +++ b/fs/cifs/smb2pdu.c @@ -857,7 +857,7 @@ create_durable_buf(void) return NULL; buf->ccontext.DataOffset = cpu_to_le16(offsetof - (struct create_durable, Reserved)); + (struct create_durable, Data)); buf->ccontext.DataLength = cpu_to_le32(16); buf->ccontext.NameOffset = cpu_to_le16(offsetof (struct create_durable, Name)); @@ -869,6 +869,30 @@ create_durable_buf(void) return buf; } +static struct create_durable * +create_reconnect_durable_buf(struct cifs_fid *fid) +{ + struct create_durable *buf; + + buf = kzalloc(sizeof(struct create_durable), GFP_KERNEL); + if (!buf) + return NULL; + + buf->ccontext.DataOffset = cpu_to_le16(offsetof + (struct create_durable, Data)); + buf->ccontext.DataLength = cpu_to_le32(16); + buf->ccontext.NameOffset = cpu_to_le16(offsetof + (struct create_durable, Name)); + buf->ccontext.NameLength = cpu_to_le16(4); + buf->Data.Fid.PersistentFileId = fid->persistent_fid; + buf->Data.Fid.VolatileFileId = fid->volatile_fid; + buf->Name[0] = 'D'; + buf->Name[1] = 'H'; + buf->Name[2] = 'n'; + buf->Name[3] = 'C'; + return buf; +} + static __u8 parse_lease_state(struct smb2_create_rsp *rsp) { @@ -924,12 +948,18 @@ add_lease_context(struct kvec *iov, unsigned int *num_iovec, __u8 *oplock) } static int -add_durable_context(struct kvec *iov, unsigned int *num_iovec) +add_durable_context(struct kvec *iov, unsigned int *num_iovec, + struct cifs_open_parms *oparms) { struct smb2_create_req *req = iov[0].iov_base; unsigned int num = *num_iovec; - iov[num].iov_base = create_durable_buf(); + if (oparms->reconnect) { + iov[num].iov_base = create_reconnect_durable_buf(oparms->fid); + /* indicate that we don't need to relock the file */ + oparms->reconnect = false; + } else + iov[num].iov_base = create_durable_buf(); if (iov[num].iov_base == NULL) return -ENOMEM; iov[num].iov_len = sizeof(struct create_durable); @@ -1037,7 +1067,7 @@ SMB2_open(const unsigned int xid, struct cifs_open_parms *oparms, __le16 *path, (struct create_context *)iov[num_iovecs-1].iov_base; ccontext->Next = sizeof(struct create_lease); } - rc = add_durable_context(iov, &num_iovecs); + rc = add_durable_context(iov, &num_iovecs, oparms); if (rc) { cifs_small_buf_release(req); kfree(copy_path); diff --git a/fs/cifs/smb2pdu.h b/fs/cifs/smb2pdu.h index 3e30f0ad5749..36b0d37ea69b 100644 --- a/fs/cifs/smb2pdu.h +++ b/fs/cifs/smb2pdu.h @@ -488,7 +488,13 @@ struct create_lease { struct create_durable { struct create_context ccontext; __u8 Name[8]; - __u8 Reserved[16]; + union { + __u8 Reserved[16]; + struct { + __u64 PersistentFileId; + __u64 VolatileFileId; + } Fid; + } Data; } __packed; /* this goes in the ioctl buffer when doing a copychunk request */ From 1c46943f84f7532a9503810d44b0772581c0325c Mon Sep 17 00:00:00 2001 From: Steve French Date: Wed, 10 Jul 2013 12:50:57 -0500 Subject: [PATCH 0745/1048] [CIFS] Fix minor endian error in durable handle patch series Fix endian warning: CHECK fs/cifs/smb2pdu.c fs/cifs/smb2pdu.c:1068:40: warning: incorrect type in assignment (different base types) fs/cifs/smb2pdu.c:1068:40: expected restricted __le32 [usertype] Next fs/cifs/smb2pdu.c:1068:40: got unsigned long Signed-off-by: Steve French --- fs/cifs/smb2pdu.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c index c7ad06fc9d63..abc9c2809b51 100644 --- a/fs/cifs/smb2pdu.c +++ b/fs/cifs/smb2pdu.c @@ -1065,7 +1065,8 @@ SMB2_open(const unsigned int xid, struct cifs_open_parms *oparms, __le16 *path, if (tcon->ses->server->capabilities & SMB2_GLOBAL_CAP_LEASING) { struct create_context *ccontext = (struct create_context *)iov[num_iovecs-1].iov_base; - ccontext->Next = sizeof(struct create_lease); + ccontext->Next = + cpu_to_le32(sizeof(struct create_lease)); } rc = add_durable_context(iov, &num_iovecs, oparms); if (rc) { From 4c241b364b5899e46924bfd4f9599c45f8e4a146 Mon Sep 17 00:00:00 2001 From: Libo Chen Date: Mon, 20 May 2013 10:30:07 +0800 Subject: [PATCH 0746/1048] x86: msi-laptop: fix memleak 1. fix two visible mistakes: * when load_scm_model_init faild, we should call platform_device_del(msipf_device) * msipf_attribute_group should be remove in err case 2. change some tags, give them real meaning. Signed-off-by: Libo Chen Signed-off-by: Matthew Garrett --- drivers/platform/x86/msi-laptop.c | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/drivers/platform/x86/msi-laptop.c b/drivers/platform/x86/msi-laptop.c index 6b2293875672..62f8030b9e77 100644 --- a/drivers/platform/x86/msi-laptop.c +++ b/drivers/platform/x86/msi-laptop.c @@ -1098,29 +1098,29 @@ static int __init msi_init(void) ret = platform_device_add(msipf_device); if (ret) - goto fail_platform_device1; + goto fail_device_add; if (quirks->load_scm_model && (load_scm_model_init(msipf_device) < 0)) { ret = -EINVAL; - goto fail_platform_device1; + goto fail_scm_model_init; } ret = sysfs_create_group(&msipf_device->dev.kobj, &msipf_attribute_group); if (ret) - goto fail_platform_device2; + goto fail_create_group; if (!quirks->old_ec_model) { if (threeg_exists) ret = device_create_file(&msipf_device->dev, &dev_attr_threeg); if (ret) - goto fail_platform_device2; + goto fail_create_attr; } else { ret = sysfs_create_group(&msipf_device->dev.kobj, &msipf_old_attribute_group); if (ret) - goto fail_platform_device2; + goto fail_create_attr; /* Disable automatic brightness control by default because * this module was probably loaded to do brightness control in @@ -1134,26 +1134,22 @@ static int __init msi_init(void) return 0; -fail_platform_device2: - +fail_create_attr: + sysfs_remove_group(&msipf_device->dev.kobj, &msipf_attribute_group); +fail_create_group: if (quirks->load_scm_model) { i8042_remove_filter(msi_laptop_i8042_filter); cancel_delayed_work_sync(&msi_rfkill_dwork); cancel_work_sync(&msi_rfkill_work); rfkill_cleanup(); } +fail_scm_model_init: platform_device_del(msipf_device); - -fail_platform_device1: - +fail_device_add: platform_device_put(msipf_device); - fail_platform_driver: - platform_driver_unregister(&msipf_driver); - fail_backlight: - backlight_device_unregister(msibl_device); return ret; From 38bdd729ca39e1924a31970e41b13b6ce6ec1755 Mon Sep 17 00:00:00 2001 From: Libo Chen Date: Mon, 20 May 2013 10:30:24 +0800 Subject: [PATCH 0747/1048] x86: asus-laptop: fix invalid point access asus->name is null or point to const string,so it is not suitable to kfree it. Signed-off-by: Libo Chen Signed-off-by: Matthew Garrett --- drivers/platform/x86/asus-laptop.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/platform/x86/asus-laptop.c b/drivers/platform/x86/asus-laptop.c index 0eea09c1c134..8e268da6fdbd 100644 --- a/drivers/platform/x86/asus-laptop.c +++ b/drivers/platform/x86/asus-laptop.c @@ -1935,7 +1935,6 @@ fail_input: fail_backlight: asus_platform_exit(asus); fail_platform: - kfree(asus->name); kfree(asus); return result; From 0ed60654a24c730dcb555da8439e5639253b6eca Mon Sep 17 00:00:00 2001 From: vic Date: Wed, 22 May 2013 21:32:10 +0300 Subject: [PATCH 0748/1048] asus-wmi: append newline to messages Append newline to messages. Signed-off-by: Viktar Vauchkevich Signed-off-by: Matthew Garrett --- drivers/platform/x86/asus-wmi.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c index c11b2426dac1..0e58d748d7f6 100644 --- a/drivers/platform/x86/asus-wmi.c +++ b/drivers/platform/x86/asus-wmi.c @@ -1045,7 +1045,7 @@ static ssize_t asus_hwmon_pwm1(struct device *dev, else if (value == 3) value = 255; else if (value != 0) { - pr_err("Unknown fan speed %#x", value); + pr_err("Unknown fan speed %#x\n", value); value = -1; } @@ -1557,11 +1557,11 @@ static int asus_wmi_platform_init(struct asus_wmi *asus) /* INIT enable hotkeys on some models */ if (!asus_wmi_evaluate_method(ASUS_WMI_METHODID_INIT, 0, 0, &rv)) - pr_info("Initialization: %#x", rv); + pr_info("Initialization: %#x\n", rv); /* We don't know yet what to do with this version... */ if (!asus_wmi_evaluate_method(ASUS_WMI_METHODID_SPEC, 0, 0x9, &rv)) { - pr_info("BIOS WMI version: %d.%d", rv >> 16, rv & 0xFF); + pr_info("BIOS WMI version: %d.%d\n", rv >> 16, rv & 0xFF); asus->spec = rv; } @@ -1572,7 +1572,7 @@ static int asus_wmi_platform_init(struct asus_wmi *asus) * The significance of others is yet to be found. */ if (!asus_wmi_evaluate_method(ASUS_WMI_METHODID_SFUN, 0, 0, &rv)) { - pr_info("SFUN value: %#x", rv); + pr_info("SFUN value: %#x\n", rv); asus->sfun = rv; } @@ -1712,7 +1712,7 @@ static int asus_wmi_debugfs_init(struct asus_wmi *asus) asus->debug.root = debugfs_create_dir(asus->driver->name, NULL); if (!asus->debug.root) { - pr_err("failed to create debugfs directory"); + pr_err("failed to create debugfs directory\n"); goto error_debugfs; } @@ -1985,17 +1985,17 @@ EXPORT_SYMBOL_GPL(asus_wmi_unregister_driver); static int __init asus_wmi_init(void) { if (!wmi_has_guid(ASUS_WMI_MGMT_GUID)) { - pr_info("Asus Management GUID not found"); + pr_info("Asus Management GUID not found\n"); return -ENODEV; } - pr_info("ASUS WMI generic driver loaded"); + pr_info("ASUS WMI generic driver loaded\n"); return 0; } static void __exit asus_wmi_exit(void) { - pr_info("ASUS WMI generic driver unloaded"); + pr_info("ASUS WMI generic driver unloaded\n"); } module_init(asus_wmi_init); From 3aabf444f70f5855d8a0a06285fdd55e76a740d5 Mon Sep 17 00:00:00 2001 From: Viktar Vauchkevich Date: Thu, 23 May 2013 07:17:11 +0300 Subject: [PATCH 0749/1048] asus-nb-wmi: ignore ALS notification key code Ignore Ambient Light Sensor notification key code 0xC6 found in ASUS UX31a. When the illuminance changes dmesg shows: [10814.939979] asus_wmi: Unknown key c6 pressed Signed-off-by: Viktar Vauchkevich Signed-off-by: Matthew Garrett --- drivers/platform/x86/asus-nb-wmi.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/platform/x86/asus-nb-wmi.c b/drivers/platform/x86/asus-nb-wmi.c index 8fcb41e18b9c..7340566c5865 100644 --- a/drivers/platform/x86/asus-nb-wmi.c +++ b/drivers/platform/x86/asus-nb-wmi.c @@ -256,6 +256,7 @@ static const struct key_entry asus_nb_wmi_keymap[] = { { KE_KEY, 0xB5, { KEY_CALC } }, { KE_KEY, 0xC4, { KEY_KBDILLUMUP } }, { KE_KEY, 0xC5, { KEY_KBDILLUMDOWN } }, + { KE_IGNORE, 0xC6, }, /* Ambient Light Sensor notification */ { KE_END, 0}, }; From b5f4f9ef0125845cd03dc9de5dbe1344e60474d0 Mon Sep 17 00:00:00 2001 From: Libo Chen Date: Mon, 27 May 2013 10:31:33 +0800 Subject: [PATCH 0750/1048] drivers/platform/x86/intel_ips: Convert to module_pci_driver use module_pci_driver instead of init/exit, make code clean. Signed-off-by: Libo Chen Signed-off-by: Matthew Garrett --- drivers/platform/x86/intel_ips.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/drivers/platform/x86/intel_ips.c b/drivers/platform/x86/intel_ips.c index 5051aa970e0a..18dcb58ba965 100644 --- a/drivers/platform/x86/intel_ips.c +++ b/drivers/platform/x86/intel_ips.c @@ -1731,18 +1731,7 @@ static struct pci_driver ips_pci_driver = { .shutdown = ips_shutdown, }; -static int __init ips_init(void) -{ - return pci_register_driver(&ips_pci_driver); -} -module_init(ips_init); - -static void ips_exit(void) -{ - pci_unregister_driver(&ips_pci_driver); - return; -} -module_exit(ips_exit); +module_pci_driver(ips_pci_driver); MODULE_LICENSE("GPL"); MODULE_AUTHOR("Jesse Barnes "); From e8f56c80aedacfb1552509c0e4ed265266328bc4 Mon Sep 17 00:00:00 2001 From: AceLan Kao Date: Thu, 30 May 2013 10:31:50 +0800 Subject: [PATCH 0751/1048] asus-wmi: control wlan-led only if wapf == 4 Controlling the wlan led seems to have some side effects to the machines with wapf value is not equal to 4. It will make the keyboard backlight out of order. So, the patch will enable the wlan led function only if the wapf == 4. Bug: https://bugzilla.kernel.org/show_bug.cgi?id=46791 Reported-by: Mirto Silvio Busico Tested-by: Karol Herbst Tested-by: drunkenbatman Signed-off-by: AceLan Kao Signed-off-by: Matthew Garrett --- drivers/platform/x86/asus-wmi.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c index 0e58d748d7f6..19c313b056c3 100644 --- a/drivers/platform/x86/asus-wmi.c +++ b/drivers/platform/x86/asus-wmi.c @@ -558,7 +558,7 @@ static int asus_wmi_led_init(struct asus_wmi *asus) goto error; } - if (wlan_led_presence(asus)) { + if (wlan_led_presence(asus) && (asus->driver->quirks->wapf == 4)) { INIT_WORK(&asus->wlan_led_work, wlan_led_update); asus->wlan_led.name = "asus::wlan"; @@ -886,7 +886,8 @@ static int asus_new_rfkill(struct asus_wmi *asus, if (!*rfkill) return -EINVAL; - if (dev_id == ASUS_WMI_DEVID_WLAN) + if ((dev_id == ASUS_WMI_DEVID_WLAN) && + (asus->driver->quirks->wapf == 4)) rfkill_set_led_trigger_name(*rfkill, "asus-wlan"); rfkill_init_sw_state(*rfkill, !result); From 8667ca9518bbe0eff2222e69d611f4c8549fcbde Mon Sep 17 00:00:00 2001 From: Alex Hung Date: Thu, 13 Jun 2013 16:46:25 +0800 Subject: [PATCH 0752/1048] hp-wmi: add supports for POST code error HP laptops include a POST code error query 0x2A that reports which point BIOS fails to boot at. The error code is kept in CMOS until it is cleared. Signed-off-by: Alex Hung Signed-off-by: Matthew Garrett --- drivers/platform/x86/hp-wmi.c | 47 +++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/drivers/platform/x86/hp-wmi.c b/drivers/platform/x86/hp-wmi.c index 6e142c3b5e97..97bb05edcb5a 100644 --- a/drivers/platform/x86/hp-wmi.c +++ b/drivers/platform/x86/hp-wmi.c @@ -56,6 +56,7 @@ MODULE_ALIAS("wmi:5FB7F034-2C63-45e9-BE91-3D44E2C707E4"); #define HPWMI_BIOS_QUERY 0x9 #define HPWMI_HOTKEY_QUERY 0xc #define HPWMI_WIRELESS2_QUERY 0x1b +#define HPWMI_POSTCODEERROR_QUERY 0x2a enum hp_wmi_radio { HPWMI_WIFI = 0, @@ -400,6 +401,16 @@ static int hp_wmi_rfkill2_refresh(void) return 0; } +static int hp_wmi_post_code_state(void) +{ + int state = 0; + int ret = hp_wmi_perform_query(HPWMI_POSTCODEERROR_QUERY, 0, &state, + sizeof(state), sizeof(state)); + if (ret) + return -EINVAL; + return state; +} + static ssize_t show_display(struct device *dev, struct device_attribute *attr, char *buf) { @@ -445,6 +456,16 @@ static ssize_t show_tablet(struct device *dev, struct device_attribute *attr, return sprintf(buf, "%d\n", value); } +static ssize_t show_postcode(struct device *dev, struct device_attribute *attr, + char *buf) +{ + /* Get the POST error code of previous boot failure. */ + int value = hp_wmi_post_code_state(); + if (value < 0) + return -EINVAL; + return sprintf(buf, "0x%x\n", value); +} + static ssize_t set_als(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { @@ -457,11 +478,33 @@ static ssize_t set_als(struct device *dev, struct device_attribute *attr, return count; } +static ssize_t set_postcode(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + int ret; + u32 tmp; + long unsigned int tmp2; + + ret = kstrtoul(buf, 10, &tmp2); + if (ret || tmp2 != 1) + return -EINVAL; + + /* Clear the POST error code. It is kept until until cleared. */ + tmp = (u32) tmp2; + ret = hp_wmi_perform_query(HPWMI_POSTCODEERROR_QUERY, 1, &tmp, + sizeof(tmp), sizeof(tmp)); + if (ret) + return -EINVAL; + + return count; +} + static DEVICE_ATTR(display, S_IRUGO, show_display, NULL); static DEVICE_ATTR(hddtemp, S_IRUGO, show_hddtemp, NULL); static DEVICE_ATTR(als, S_IRUGO | S_IWUSR, show_als, set_als); static DEVICE_ATTR(dock, S_IRUGO, show_dock, NULL); static DEVICE_ATTR(tablet, S_IRUGO, show_tablet, NULL); +static DEVICE_ATTR(postcode, S_IRUGO | S_IWUSR, show_postcode, set_postcode); static void hp_wmi_notify(u32 value, void *context) { @@ -642,6 +685,7 @@ static void cleanup_sysfs(struct platform_device *device) device_remove_file(&device->dev, &dev_attr_als); device_remove_file(&device->dev, &dev_attr_dock); device_remove_file(&device->dev, &dev_attr_tablet); + device_remove_file(&device->dev, &dev_attr_postcode); } static int hp_wmi_rfkill_setup(struct platform_device *device) @@ -857,6 +901,9 @@ static int __init hp_wmi_bios_setup(struct platform_device *device) if (err) goto add_sysfs_error; err = device_create_file(&device->dev, &dev_attr_tablet); + if (err) + goto add_sysfs_error; + err = device_create_file(&device->dev, &dev_attr_postcode); if (err) goto add_sysfs_error; return 0; From 34a956db3774e8cba3f6b52aa9c1d67cf9a496fe Mon Sep 17 00:00:00 2001 From: Matthew Garrett Date: Tue, 2 Jul 2013 18:41:03 -0400 Subject: [PATCH 0753/1048] Add support driver for Intel Rapid Start Technology Intel Rapid Start Technology is a firmware-based suspend-to-disk implementation. Once placed in S3, the device will wake once either a timeout elapses or the battery reaches a critical level. It will then resume to the firmware and copy the contents of RAM to a specialised partition, and then power off the machine. If the user turns the machine back on the firmware will copy the contents of the partition back to RAM and then resume from S3 as normal. This driver provides an interface for configuring the wakeup events and timeout. It still requires firmware support and an appropriate suspend partition. Signed-off-by: Matthew Garrett Signed-off-by: Matthew Garrett --- .../testing/sysfs-driver-intel-rapid-start | 21 ++ drivers/platform/x86/Kconfig | 12 + drivers/platform/x86/Makefile | 1 + drivers/platform/x86/intel-rst.c | 209 ++++++++++++++++++ 4 files changed, 243 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-driver-intel-rapid-start create mode 100644 drivers/platform/x86/intel-rst.c diff --git a/Documentation/ABI/testing/sysfs-driver-intel-rapid-start b/Documentation/ABI/testing/sysfs-driver-intel-rapid-start new file mode 100644 index 000000000000..5a7d2e217d40 --- /dev/null +++ b/Documentation/ABI/testing/sysfs-driver-intel-rapid-start @@ -0,0 +1,21 @@ +What: /sys/bus/acpi/intel-rapid-start/wakeup_events +Date: July 2, 2013 +KernelVersion: 3.11 +Contact: Matthew Garrett +Description: An integer representing a set of wakeup events as follows: + 1: Wake to enter hibernation when the wakeup timer expires + 2: Wake to enter hibernation when the battery reaches a + critical level + + These values are ORed together. For example, a value of 3 + indicates that the system will wake to enter hibernation when + either the wakeup timer expires or the battery reaches a + critical level. + +What: /sys/bus/acpi/intel-rapid-start/wakeup_time +Date: July 2, 2013 +KernelVersion: 3.11 +Contact: Matthew Garrett +Description: An integer representing the length of time the system will + remain asleep before waking up to enter hibernation. + This value is in minutes. diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig index 37645b923c52..36057f481162 100644 --- a/drivers/platform/x86/Kconfig +++ b/drivers/platform/x86/Kconfig @@ -782,6 +782,18 @@ config APPLE_GMUX graphics as well as the backlight. Currently only backlight control is supported by the driver. +config INTEL_RST + tristate "Intel Rapid Start Technology Driver" + depends on ACPI + ---help--- + This driver provides support for modifying paramaters on systems + equipped with Intel's Rapid Start Technology. When put in an ACPI + sleep state, these devices will wake after either a configured + timeout or when the system battery reaches a critical state, + automatically copying memory contents to disk. On resume, the + firmware will copy the memory contents back to RAM and resume the OS + as usual. + config PVPANIC tristate "pvpanic device support" depends on ACPI diff --git a/drivers/platform/x86/Makefile b/drivers/platform/x86/Makefile index ef0ec746f78c..5c669ce8d243 100644 --- a/drivers/platform/x86/Makefile +++ b/drivers/platform/x86/Makefile @@ -51,5 +51,6 @@ obj-$(CONFIG_INTEL_OAKTRAIL) += intel_oaktrail.o obj-$(CONFIG_SAMSUNG_Q10) += samsung-q10.o obj-$(CONFIG_APPLE_GMUX) += apple-gmux.o obj-$(CONFIG_CHROMEOS_LAPTOP) += chromeos_laptop.o +obj-$(CONFIG_INTEL_RST) += intel-rst.o obj-$(CONFIG_PVPANIC) += pvpanic.o diff --git a/drivers/platform/x86/intel-rst.c b/drivers/platform/x86/intel-rst.c new file mode 100644 index 000000000000..9385afd9b558 --- /dev/null +++ b/drivers/platform/x86/intel-rst.c @@ -0,0 +1,209 @@ +/* + * Copyright 2013 Matthew Garrett + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * 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. + */ + + +#include +#include +#include +#include + +MODULE_LICENSE("GPL"); + +static ssize_t irst_show_wakeup_events(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct acpi_device *acpi; + struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL }; + union acpi_object *result; + acpi_status status; + + acpi = to_acpi_device(dev); + + status = acpi_evaluate_object(acpi->handle, "GFFS", NULL, &output); + if (!ACPI_SUCCESS(status)) + return -EINVAL; + + result = output.pointer; + + if (result->type != ACPI_TYPE_INTEGER) { + kfree(result); + return -EINVAL; + } + + return sprintf(buf, "%lld\n", result->integer.value); +} + +static ssize_t irst_store_wakeup_events(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) +{ + struct acpi_device *acpi; + struct acpi_object_list input; + union acpi_object param; + acpi_status status; + unsigned long value; + int error; + + acpi = to_acpi_device(dev); + + error = kstrtoul(buf, 0, &value); + + if (error) + return error; + + param.type = ACPI_TYPE_INTEGER; + param.integer.value = value; + + input.count = 1; + input.pointer = ¶m; + + status = acpi_evaluate_object(acpi->handle, "SFFS", &input, NULL); + + if (!ACPI_SUCCESS(status)) + return -EINVAL; + + return count; +} + +static struct device_attribute irst_wakeup_attr = { + .attr = { .name = "wakeup_events", .mode = 0600 }, + .show = irst_show_wakeup_events, + .store = irst_store_wakeup_events +}; + +static ssize_t irst_show_wakeup_time(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct acpi_device *acpi; + struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL }; + union acpi_object *result; + acpi_status status; + + acpi = to_acpi_device(dev); + + status = acpi_evaluate_object(acpi->handle, "GFTV", NULL, &output); + if (!ACPI_SUCCESS(status)) + return -EINVAL; + + result = output.pointer; + + if (result->type != ACPI_TYPE_INTEGER) { + kfree(result); + return -EINVAL; + } + + return sprintf(buf, "%lld\n", result->integer.value); +} + +static ssize_t irst_store_wakeup_time(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) +{ + struct acpi_device *acpi; + struct acpi_object_list input; + union acpi_object param; + acpi_status status; + unsigned long value; + int error; + + acpi = to_acpi_device(dev); + + error = kstrtoul(buf, 0, &value); + + if (error) + return error; + + param.type = ACPI_TYPE_INTEGER; + param.integer.value = value; + + input.count = 1; + input.pointer = ¶m; + + status = acpi_evaluate_object(acpi->handle, "SFTV", &input, NULL); + + if (!ACPI_SUCCESS(status)) + return -EINVAL; + + return count; +} + +static struct device_attribute irst_timeout_attr = { + .attr = { .name = "wakeup_time", .mode = 0600 }, + .show = irst_show_wakeup_time, + .store = irst_store_wakeup_time +}; + +static int irst_add(struct acpi_device *acpi) +{ + int error = 0; + + error = device_create_file(&acpi->dev, &irst_timeout_attr); + if (error) + goto out; + + error = device_create_file(&acpi->dev, &irst_wakeup_attr); + if (error) + goto out_timeout; + + return 0; + +out_timeout: + device_remove_file(&acpi->dev, &irst_timeout_attr); +out: + return error; +} + +static int irst_remove(struct acpi_device *acpi) +{ + device_remove_file(&acpi->dev, &irst_wakeup_attr); + device_remove_file(&acpi->dev, &irst_timeout_attr); + + return 0; +} + +static const struct acpi_device_id irst_ids[] = { + {"INT3392", 0}, + {"", 0} +}; + +static struct acpi_driver irst_driver = { + .owner = THIS_MODULE, + .name = "intel_rapid_start", + .class = "intel_rapid_start", + .ids = irst_ids, + .ops = { + .add = irst_add, + .remove = irst_remove, + }, +}; + +static int irst_init(void) +{ + return acpi_bus_register_driver(&irst_driver); +} + +static void irst_exit(void) +{ + acpi_bus_unregister_driver(&irst_driver); +} + +module_init(irst_init); +module_exit(irst_exit); + +MODULE_DEVICE_TABLE(acpi, irst_ids); From 5c7f80f75512557dd0728ada77e8e8a8c7c8458b Mon Sep 17 00:00:00 2001 From: Matthew Garrett Date: Wed, 3 Jul 2013 00:50:13 -0400 Subject: [PATCH 0754/1048] Add trivial driver to disable Intel Smart Connect Intel Smart Connect is an Intel-specific ACPI interface for configuring devices to wake up at regular intervals so they can pull down mail or other internet updates, and then go to sleep again. If a user enables this in Windows and then reboots into Linux, the device may wake up if it's put to sleep. Since there's no Linux userland support for any of this, the machine will then remain awake until something else puts it back to sleep. I haven't figured out all that much about how this works (there's a bunch of different ACPI calls available on the device), but this seems to be enough to turn it off. We can add more features to this driver if anyone ever cares about figuring out what the rest of the calls do or writing some Linux userspace to implement the rest of it. Signed-off-by: Matthew Garrett Signed-off-by: Matthew Garrett --- drivers/platform/x86/Kconfig | 14 ++++ drivers/platform/x86/Makefile | 1 + drivers/platform/x86/intel-smartconnect.c | 90 +++++++++++++++++++++++ 3 files changed, 105 insertions(+) create mode 100644 drivers/platform/x86/intel-smartconnect.c diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig index 36057f481162..a3d76c59a394 100644 --- a/drivers/platform/x86/Kconfig +++ b/drivers/platform/x86/Kconfig @@ -794,6 +794,20 @@ config INTEL_RST firmware will copy the memory contents back to RAM and resume the OS as usual. +config INTEL_SMARTCONNECT + tristate "Intel Smart Connect disabling driver" + depends on ACPI + ---help--- + Intel Smart Connect is a technology intended to permit devices to + update state by resuming for a short period of time at regular + intervals. If a user enables this functionality under Windows and + then reboots into Linux, the system may remain configured to resume + on suspend. In the absence of any userspace to support it, the system + will then remain awake until something triggers another suspend. + + This driver checks to determine whether the device has Intel Smart + Connect enabled, and if so disables it. + config PVPANIC tristate "pvpanic device support" depends on ACPI diff --git a/drivers/platform/x86/Makefile b/drivers/platform/x86/Makefile index 5c669ce8d243..5dbe19324351 100644 --- a/drivers/platform/x86/Makefile +++ b/drivers/platform/x86/Makefile @@ -52,5 +52,6 @@ obj-$(CONFIG_SAMSUNG_Q10) += samsung-q10.o obj-$(CONFIG_APPLE_GMUX) += apple-gmux.o obj-$(CONFIG_CHROMEOS_LAPTOP) += chromeos_laptop.o obj-$(CONFIG_INTEL_RST) += intel-rst.o +obj-$(CONFIG_INTEL_SMARTCONNECT) += intel-smartconnect.o obj-$(CONFIG_PVPANIC) += pvpanic.o diff --git a/drivers/platform/x86/intel-smartconnect.c b/drivers/platform/x86/intel-smartconnect.c new file mode 100644 index 000000000000..f74e93d096bc --- /dev/null +++ b/drivers/platform/x86/intel-smartconnect.c @@ -0,0 +1,90 @@ +/* + * Copyright 2013 Matthew Garrett + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * 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. + */ + + +#include +#include +#include + +MODULE_LICENSE("GPL"); + +static int smartconnect_acpi_init(struct acpi_device *acpi) +{ + struct acpi_object_list input; + struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL }; + union acpi_object *result; + union acpi_object param; + acpi_status status; + + status = acpi_evaluate_object(acpi->handle, "GAOS", NULL, &output); + if (!ACPI_SUCCESS(status)) + return -EINVAL; + + result = output.pointer; + + if (result->type != ACPI_TYPE_INTEGER) { + kfree(result); + return -EINVAL; + } + + if (result->integer.value & 0x1) { + param.type = ACPI_TYPE_INTEGER; + param.integer.value = 0; + + input.count = 1; + input.pointer = ¶m; + + dev_info(&acpi->dev, "Disabling Intel Smart Connect\n"); + status = acpi_evaluate_object(acpi->handle, "SAOS", &input, + NULL); + } + + kfree(result); + + return 0; +} + +static const struct acpi_device_id smartconnect_ids[] = { + {"INT33A0", 0}, + {"", 0} +}; + +static struct acpi_driver smartconnect_driver = { + .owner = THIS_MODULE, + .name = "intel_smart_connect", + .class = "intel_smart_connect", + .ids = smartconnect_ids, + .ops = { + .add = smartconnect_acpi_init, + }, +}; + +static int smartconnect_init(void) +{ + return acpi_bus_register_driver(&smartconnect_driver); +} + +static void smartconnect_exit(void) +{ + acpi_bus_unregister_driver(&smartconnect_driver); +} + +module_init(smartconnect_init); +module_exit(smartconnect_exit); + +MODULE_DEVICE_TABLE(acpi, smartconnect_ids); From 144a19ac94526c4609fa8b8264e6f9c3d48f7a55 Mon Sep 17 00:00:00 2001 From: AceLan Kao Date: Wed, 3 Jul 2013 14:35:15 +0800 Subject: [PATCH 0755/1048] asus-nb-wmi: set wapf=4 for ASUSTeK COMPUTER INC. 1015E/U Need to set wapf to 4 for ASUSTeK COMPUTER INC. 1015E/U, so that user can toggle wifi function through function key correctly. Signed-off-by: AceLan Kao Signed-off-by: Matthew Garrett --- drivers/platform/x86/asus-nb-wmi.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/drivers/platform/x86/asus-nb-wmi.c b/drivers/platform/x86/asus-nb-wmi.c index 7340566c5865..563f59efa669 100644 --- a/drivers/platform/x86/asus-nb-wmi.c +++ b/drivers/platform/x86/asus-nb-wmi.c @@ -180,6 +180,24 @@ static struct dmi_system_id asus_quirks[] = { }, .driver_data = &quirk_asus_x401u, }, + { + .callback = dmi_matched, + .ident = "ASUSTeK COMPUTER INC. 1015E", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), + DMI_MATCH(DMI_PRODUCT_NAME, "1015E"), + }, + .driver_data = &quirk_asus_x401u, + }, + { + .callback = dmi_matched, + .ident = "ASUSTeK COMPUTER INC. 1015U", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), + DMI_MATCH(DMI_PRODUCT_NAME, "1015U"), + }, + .driver_data = &quirk_asus_x401u, + }, {}, }; From 283672e425b24fe4046535973460e8732f4bd485 Mon Sep 17 00:00:00 2001 From: Seth Forshee Date: Wed, 3 Jul 2013 08:14:16 -0500 Subject: [PATCH 0756/1048] toshiba_acpi: Add dependency on SERIO_I8042 Configuring this option as a module with ACPI_TOSHIBA built-in results in the following errors: drivers/built-in.o: In function `toshiba_acpi_remove': >> toshiba_acpi.c:(.text+0x314bb0): undefined reference to `i8042_remove_filter' drivers/built-in.o: In function `toshiba_acpi_add': >> toshiba_acpi.c:(.devinit.text+0xb822): undefined reference to `i8042_install_filter' >> toshiba_acpi.c:(.devinit.text+0xb98b): undefined reference to `i8042_remove_filter' Add a dependency to prevent ACPI_TOSHIBA from being built-in when SERIO_I8042=m. Reported-by: kbuild test robot Cc: Azael Avalos Signed-off-by: Seth Forshee Signed-off-by: Matthew Garrett --- drivers/platform/x86/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig index a3d76c59a394..36a9e6023395 100644 --- a/drivers/platform/x86/Kconfig +++ b/drivers/platform/x86/Kconfig @@ -592,6 +592,7 @@ config ACPI_TOSHIBA depends on BACKLIGHT_CLASS_DEVICE depends on INPUT depends on RFKILL || RFKILL = n + depends on SERIO_I8042 || SERIO_I8042 = n select INPUT_POLLDEV select INPUT_SPARSEKMAP ---help--- From fef8ce166b2d5cdba8bbf85fa48c4cb8d75ffec4 Mon Sep 17 00:00:00 2001 From: Libo Chen Date: Tue, 9 Jul 2013 20:34:28 +0800 Subject: [PATCH 0757/1048] x86 platform drivers: fix gpio leak when request_irq fails, we should release gpiochip v2: fix warning: ignoring return value of 'gpiochip_remove Signed-off-by: Libo Chen Signed-off-by: Matthew Garrett --- drivers/platform/x86/intel_pmic_gpio.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/platform/x86/intel_pmic_gpio.c b/drivers/platform/x86/intel_pmic_gpio.c index 6f4b7289a059..2805988485f6 100644 --- a/drivers/platform/x86/intel_pmic_gpio.c +++ b/drivers/platform/x86/intel_pmic_gpio.c @@ -288,7 +288,7 @@ static int platform_pmic_gpio_probe(struct platform_device *pdev) retval = request_irq(pg->irq, pmic_irq_handler, 0, "pmic", pg); if (retval) { pr_warn("Interrupt request failed\n"); - goto err; + goto fail_request_irq; } for (i = 0; i < 8; i++) { @@ -299,6 +299,10 @@ static int platform_pmic_gpio_probe(struct platform_device *pdev) irq_set_chip_data(i + pg->irq_base, pg); } return 0; + +fail_request_irq: + if (gpiochip_remove(&pg->chip)) + pr_err("gpiochip_remove failed\n"); err: iounmap(pg->gpiointr); err2: From 076bb0c82a44fbe46fe2c8527a5b5b64b69f679d Mon Sep 17 00:00:00 2001 From: Eliezer Tamir Date: Wed, 10 Jul 2013 17:13:17 +0300 Subject: [PATCH 0758/1048] net: rename include/net/ll_poll.h to include/net/busy_poll.h Rename the file and correct all the places where it is included. Signed-off-by: Eliezer Tamir Signed-off-by: David S. Miller --- drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c | 2 +- drivers/net/ethernet/intel/ixgbe/ixgbe.h | 2 +- drivers/net/ethernet/mellanox/mlx4/en_netdev.c | 2 +- drivers/net/ethernet/mellanox/mlx4/en_rx.c | 2 +- fs/select.c | 2 +- include/net/{ll_poll.h => busy_poll.h} | 0 net/core/datagram.c | 2 +- net/core/sock.c | 2 +- net/core/sysctl_net_core.c | 2 +- net/ipv4/tcp.c | 2 +- net/ipv4/tcp_ipv4.c | 2 +- net/ipv4/udp.c | 2 +- net/ipv6/tcp_ipv6.c | 2 +- net/ipv6/udp.c | 2 +- net/socket.c | 2 +- 15 files changed, 14 insertions(+), 14 deletions(-) rename include/net/{ll_poll.h => busy_poll.h} (100%) diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c index ec3aa1d451e8..05b6b4e8b073 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c @@ -24,7 +24,7 @@ #include #include #include -#include +#include #include #include "bnx2x_cmn.h" #include "bnx2x_init.h" diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe.h b/drivers/net/ethernet/intel/ixgbe/ixgbe.h index fb098b46c6a6..7be725cdfea8 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe.h +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe.h @@ -52,7 +52,7 @@ #include #endif -#include +#include #ifdef CONFIG_NET_LL_RX_POLL #define LL_EXTENDED_STATS diff --git a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c index caf204770569..0fb2438dc2c7 100644 --- a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c +++ b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c @@ -38,7 +38,7 @@ #include #include #include -#include +#include #include #include diff --git a/drivers/net/ethernet/mellanox/mlx4/en_rx.c b/drivers/net/ethernet/mellanox/mlx4/en_rx.c index 76997b93fdfe..90746d37ac9b 100644 --- a/drivers/net/ethernet/mellanox/mlx4/en_rx.c +++ b/drivers/net/ethernet/mellanox/mlx4/en_rx.c @@ -31,7 +31,7 @@ * */ -#include +#include #include #include #include diff --git a/fs/select.c b/fs/select.c index f9f49c40cfd4..35d4adc749d9 100644 --- a/fs/select.c +++ b/fs/select.c @@ -28,7 +28,7 @@ #include #include #include -#include +#include #include diff --git a/include/net/ll_poll.h b/include/net/busy_poll.h similarity index 100% rename from include/net/ll_poll.h rename to include/net/busy_poll.h diff --git a/net/core/datagram.c b/net/core/datagram.c index 6e9ab31e457e..8ab48cd89559 100644 --- a/net/core/datagram.c +++ b/net/core/datagram.c @@ -56,7 +56,7 @@ #include #include #include -#include +#include /* * Is a socket 'connection oriented' ? diff --git a/net/core/sock.c b/net/core/sock.c index ab06b719f5b1..9bfe83f4d670 100644 --- a/net/core/sock.c +++ b/net/core/sock.c @@ -139,7 +139,7 @@ #include #endif -#include +#include static DEFINE_MUTEX(proto_list_mutex); static LIST_HEAD(proto_list); diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c index afc677eadd93..1a298cb3daee 100644 --- a/net/core/sysctl_net_core.c +++ b/net/core/sysctl_net_core.c @@ -19,7 +19,7 @@ #include #include #include -#include +#include static int one = 1; diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index 15cbfa94bd8e..5423223e93c2 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -279,7 +279,7 @@ #include #include -#include +#include int sysctl_tcp_fin_timeout __read_mostly = TCP_FIN_TIMEOUT; diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index 35675e46aff8..3a261b41a00c 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c @@ -75,7 +75,7 @@ #include #include #include -#include +#include #include #include diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c index 6b270e53c207..bcc0ff2c16da 100644 --- a/net/ipv4/udp.c +++ b/net/ipv4/udp.c @@ -109,7 +109,7 @@ #include #include #include -#include +#include #include "udp_impl.h" struct udp_table udp_table __read_mostly; diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c index 5cffa5c3e6b8..345bd92d4ddb 100644 --- a/net/ipv6/tcp_ipv6.c +++ b/net/ipv6/tcp_ipv6.c @@ -63,7 +63,7 @@ #include #include #include -#include +#include #include diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c index b6f31437a1f8..40e72034da07 100644 --- a/net/ipv6/udp.c +++ b/net/ipv6/udp.c @@ -46,7 +46,7 @@ #include #include #include -#include +#include #include #include diff --git a/net/socket.c b/net/socket.c index 45afa648364a..6a3e9a3f50ad 100644 --- a/net/socket.c +++ b/net/socket.c @@ -104,7 +104,7 @@ #include #include #include -#include +#include #ifdef CONFIG_NET_LL_RX_POLL unsigned int sysctl_net_ll_read __read_mostly; From 8b80cda536ea9bceec0364e897868a30ee13b992 Mon Sep 17 00:00:00 2001 From: Eliezer Tamir Date: Wed, 10 Jul 2013 17:13:26 +0300 Subject: [PATCH 0759/1048] net: rename ll methods to busy-poll Rename ndo_ll_poll to ndo_busy_poll. Rename sk_mark_ll to sk_mark_napi_id. Rename skb_mark_ll to skb_mark_napi_id. Correct all useres of these functions. Update comments and defines in include/net/busy_poll.h Signed-off-by: Eliezer Tamir Signed-off-by: David S. Miller --- .../net/ethernet/broadcom/bnx2x/bnx2x_cmn.c | 2 +- .../net/ethernet/broadcom/bnx2x/bnx2x_main.c | 2 +- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 4 ++-- .../net/ethernet/mellanox/mlx4/en_netdev.c | 2 +- drivers/net/ethernet/mellanox/mlx4/en_rx.c | 2 +- include/linux/netdevice.h | 2 +- include/net/busy_poll.h | 22 ++++++++++--------- net/ipv4/tcp_ipv4.c | 2 +- net/ipv4/udp.c | 2 +- net/ipv6/tcp_ipv6.c | 2 +- net/ipv6/udp.c | 2 +- 11 files changed, 23 insertions(+), 21 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c index 05b6b4e8b073..3353efe79194 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c @@ -990,7 +990,7 @@ reuse_rx: __vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q), le16_to_cpu(cqe_fp->vlan_tag)); - skb_mark_ll(skb, &fp->napi); + skb_mark_napi_id(skb, &fp->napi); if (bnx2x_fp_ll_polling(fp)) netif_receive_skb(skb); diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c index 15a528bda87c..e5da07858a2f 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c @@ -12027,7 +12027,7 @@ static const struct net_device_ops bnx2x_netdev_ops = { #endif #ifdef CONFIG_NET_LL_RX_POLL - .ndo_ll_poll = bnx2x_low_latency_recv, + .ndo_busy_poll = bnx2x_low_latency_recv, #endif }; diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c index 047ebaaf0141..bad8f14b1941 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c @@ -1978,7 +1978,7 @@ static int ixgbe_clean_rx_irq(struct ixgbe_q_vector *q_vector, } #endif /* IXGBE_FCOE */ - skb_mark_ll(skb, &q_vector->napi); + skb_mark_napi_id(skb, &q_vector->napi); ixgbe_rx_skb(q_vector, skb); /* update budget accounting */ @@ -7228,7 +7228,7 @@ static const struct net_device_ops ixgbe_netdev_ops = { .ndo_poll_controller = ixgbe_netpoll, #endif #ifdef CONFIG_NET_LL_RX_POLL - .ndo_ll_poll = ixgbe_low_latency_recv, + .ndo_busy_poll = ixgbe_low_latency_recv, #endif #ifdef IXGBE_FCOE .ndo_fcoe_ddp_setup = ixgbe_fcoe_ddp_get, diff --git a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c index 0fb2438dc2c7..5eac871399d8 100644 --- a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c +++ b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c @@ -2141,7 +2141,7 @@ static const struct net_device_ops mlx4_netdev_ops = { .ndo_rx_flow_steer = mlx4_en_filter_rfs, #endif #ifdef CONFIG_NET_LL_RX_POLL - .ndo_ll_poll = mlx4_en_low_latency_recv, + .ndo_busy_poll = mlx4_en_low_latency_recv, #endif }; diff --git a/drivers/net/ethernet/mellanox/mlx4/en_rx.c b/drivers/net/ethernet/mellanox/mlx4/en_rx.c index 90746d37ac9b..dec455c8f627 100644 --- a/drivers/net/ethernet/mellanox/mlx4/en_rx.c +++ b/drivers/net/ethernet/mellanox/mlx4/en_rx.c @@ -767,7 +767,7 @@ int mlx4_en_process_rx_cq(struct net_device *dev, struct mlx4_en_cq *cq, int bud timestamp); } - skb_mark_ll(skb, &cq->napi); + skb_mark_napi_id(skb, &cq->napi); /* Push it up the stack */ netif_receive_skb(skb); diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index bb82871b8494..0741a1e919a5 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -974,7 +974,7 @@ struct net_device_ops { void (*ndo_netpoll_cleanup)(struct net_device *dev); #endif #ifdef CONFIG_NET_LL_RX_POLL - int (*ndo_ll_poll)(struct napi_struct *dev); + int (*ndo_busy_poll)(struct napi_struct *dev); #endif int (*ndo_set_vf_mac)(struct net_device *dev, int queue, u8 *mac); diff --git a/include/net/busy_poll.h b/include/net/busy_poll.h index 76f034087743..4ff71908fd42 100644 --- a/include/net/busy_poll.h +++ b/include/net/busy_poll.h @@ -1,5 +1,5 @@ /* - * Low Latency Sockets + * net busy poll support * Copyright(c) 2013 Intel Corporation. * * This program is free software; you can redistribute it and/or modify it @@ -21,8 +21,8 @@ * e1000-devel Mailing List */ -#ifndef _LINUX_NET_LL_POLL_H -#define _LINUX_NET_LL_POLL_H +#ifndef _LINUX_NET_BUSY_POLL_H +#define _LINUX_NET_BUSY_POLL_H #include #include @@ -110,11 +110,11 @@ static inline bool sk_busy_loop(struct sock *sk, int nonblock) goto out; ops = napi->dev->netdev_ops; - if (!ops->ndo_ll_poll) + if (!ops->ndo_busy_poll) goto out; do { - rc = ops->ndo_ll_poll(napi); + rc = ops->ndo_busy_poll(napi); if (rc == LL_FLUSH_FAILED) break; /* permanent failure */ @@ -134,13 +134,14 @@ out: } /* used in the NIC receive handler to mark the skb */ -static inline void skb_mark_ll(struct sk_buff *skb, struct napi_struct *napi) +static inline void skb_mark_napi_id(struct sk_buff *skb, + struct napi_struct *napi) { skb->napi_id = napi->napi_id; } /* used in the protocol hanlder to propagate the napi_id to the socket */ -static inline void sk_mark_ll(struct sock *sk, struct sk_buff *skb) +static inline void sk_mark_napi_id(struct sock *sk, struct sk_buff *skb) { sk->sk_napi_id = skb->napi_id; } @@ -166,11 +167,12 @@ static inline bool sk_busy_poll(struct sock *sk, int nonblock) return false; } -static inline void skb_mark_ll(struct sk_buff *skb, struct napi_struct *napi) +static inline void skb_mark_napi_id(struct sk_buff *skb, + struct napi_struct *napi) { } -static inline void sk_mark_ll(struct sock *sk, struct sk_buff *skb) +static inline void sk_mark_napi_id(struct sock *sk, struct sk_buff *skb) { } @@ -180,4 +182,4 @@ static inline bool busy_loop_timeout(unsigned long end_time) } #endif /* CONFIG_NET_LL_RX_POLL */ -#endif /* _LINUX_NET_LL_POLL_H */ +#endif /* _LINUX_NET_BUSY_POLL_H */ diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index 3a261b41a00c..b299da5ff499 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c @@ -1994,7 +1994,7 @@ process: if (sk_filter(sk, skb)) goto discard_and_relse; - sk_mark_ll(sk, skb); + sk_mark_napi_id(sk, skb); skb->dev = NULL; bh_lock_sock_nested(sk); diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c index bcc0ff2c16da..a0d7151ffbd9 100644 --- a/net/ipv4/udp.c +++ b/net/ipv4/udp.c @@ -1713,7 +1713,7 @@ int __udp4_lib_rcv(struct sk_buff *skb, struct udp_table *udptable, if (sk != NULL) { int ret; - sk_mark_ll(sk, skb); + sk_mark_napi_id(sk, skb); ret = udp_queue_rcv_skb(sk, skb); sock_put(sk); diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c index 345bd92d4ddb..6e1649d58533 100644 --- a/net/ipv6/tcp_ipv6.c +++ b/net/ipv6/tcp_ipv6.c @@ -1499,7 +1499,7 @@ process: if (sk_filter(sk, skb)) goto discard_and_relse; - sk_mark_ll(sk, skb); + sk_mark_napi_id(sk, skb); skb->dev = NULL; bh_lock_sock_nested(sk); diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c index 40e72034da07..f4058150262b 100644 --- a/net/ipv6/udp.c +++ b/net/ipv6/udp.c @@ -844,7 +844,7 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable, if (sk != NULL) { int ret; - sk_mark_ll(sk, skb); + sk_mark_napi_id(sk, skb); ret = udpv6_queue_rcv_skb(sk, skb); sock_put(sk); From 64b0dc517ea1b35d02565a779e6cb77ae9045685 Mon Sep 17 00:00:00 2001 From: Eliezer Tamir Date: Wed, 10 Jul 2013 17:13:36 +0300 Subject: [PATCH 0760/1048] net: rename busy poll socket op and globals Rename LL_SO to BUSY_POLL_SO Rename sysctl_net_ll_{read,poll} to sysctl_busy_{read,poll} Fix up users of these variables. Fix documentation for sysctl. a patch for the socket.7 man page will follow separately, because of limitations of my mail setup. Signed-off-by: Eliezer Tamir Signed-off-by: David S. Miller --- Documentation/sysctl/net.txt | 17 +++++++++-------- arch/alpha/include/uapi/asm/socket.h | 2 +- arch/avr32/include/uapi/asm/socket.h | 2 +- arch/cris/include/uapi/asm/socket.h | 2 +- arch/frv/include/uapi/asm/socket.h | 2 +- arch/h8300/include/uapi/asm/socket.h | 2 +- arch/ia64/include/uapi/asm/socket.h | 2 +- arch/m32r/include/uapi/asm/socket.h | 2 +- arch/mips/include/uapi/asm/socket.h | 2 +- arch/mn10300/include/uapi/asm/socket.h | 2 +- arch/parisc/include/uapi/asm/socket.h | 2 +- arch/powerpc/include/uapi/asm/socket.h | 2 +- arch/s390/include/uapi/asm/socket.h | 2 +- arch/sparc/include/uapi/asm/socket.h | 2 +- arch/xtensa/include/uapi/asm/socket.h | 2 +- include/net/busy_poll.h | 8 ++++---- include/uapi/asm-generic/socket.h | 2 +- net/core/sock.c | 6 +++--- net/core/sysctl_net_core.c | 8 ++++---- net/socket.c | 4 ++-- 20 files changed, 37 insertions(+), 36 deletions(-) diff --git a/Documentation/sysctl/net.txt b/Documentation/sysctl/net.txt index d69e14c9002c..1c15043aaee4 100644 --- a/Documentation/sysctl/net.txt +++ b/Documentation/sysctl/net.txt @@ -50,26 +50,27 @@ The maximum number of packets that kernel can handle on a NAPI interrupt, it's a Per-CPU variable. Default: 64 -low_latency_read +busy_read ---------------- Low latency busy poll timeout for socket reads. (needs CONFIG_NET_LL_RX_POLL) Approximate time in us to busy loop waiting for packets on the device queue. -This sets the default value of the SO_LL socket option. -Can be set or overridden per socket by setting socket option SO_LL, which is -the preferred method of enabling. -If you need to enable the feature globally via sysctl, a value of 50 is recommended. +This sets the default value of the SO_BUSY_POLL socket option. +Can be set or overridden per socket by setting socket option SO_BUSY_POLL, +which is the preferred method of enabling. If you need to enable the feature +globally via sysctl, a value of 50 is recommended. Will increase power usage. Default: 0 (off) -low_latency_poll +busy_poll ---------------- Low latency busy poll timeout for poll and select. (needs CONFIG_NET_LL_RX_POLL) Approximate time in us to busy loop waiting for events. Recommended value depends on the number of sockets you poll on. For several sockets 50, for several hundreds 100. For more than that you probably want to use epoll. -Note that only sockets with SO_LL set will be busy polled, so you want to either -selectively set SO_LL on those sockets or set sysctl.net.low_latency_read globally. +Note that only sockets with SO_BUSY_POLL set will be busy polled, +so you want to either selectively set SO_BUSY_POLL on those sockets or set +sysctl.net.busy_read globally. Will increase power usage. Default: 0 (off) diff --git a/arch/alpha/include/uapi/asm/socket.h b/arch/alpha/include/uapi/asm/socket.h index 4885825e498d..467de010ea7e 100644 --- a/arch/alpha/include/uapi/asm/socket.h +++ b/arch/alpha/include/uapi/asm/socket.h @@ -81,6 +81,6 @@ #define SO_SELECT_ERR_QUEUE 45 -#define SO_LL 46 +#define SO_BUSY_POLL 46 #endif /* _UAPI_ASM_SOCKET_H */ diff --git a/arch/avr32/include/uapi/asm/socket.h b/arch/avr32/include/uapi/asm/socket.h index 79b61798ebf8..11c4259c62fb 100644 --- a/arch/avr32/include/uapi/asm/socket.h +++ b/arch/avr32/include/uapi/asm/socket.h @@ -74,6 +74,6 @@ #define SO_SELECT_ERR_QUEUE 45 -#define SO_LL 46 +#define SO_BUSY_POLL 46 #endif /* __ASM_AVR32_SOCKET_H */ diff --git a/arch/cris/include/uapi/asm/socket.h b/arch/cris/include/uapi/asm/socket.h index 47b1ec55092d..eb723e51554e 100644 --- a/arch/cris/include/uapi/asm/socket.h +++ b/arch/cris/include/uapi/asm/socket.h @@ -76,7 +76,7 @@ #define SO_SELECT_ERR_QUEUE 45 -#define SO_LL 46 +#define SO_BUSY_POLL 46 #endif /* _ASM_SOCKET_H */ diff --git a/arch/frv/include/uapi/asm/socket.h b/arch/frv/include/uapi/asm/socket.h index dbc08520f22c..f0cb1c341163 100644 --- a/arch/frv/include/uapi/asm/socket.h +++ b/arch/frv/include/uapi/asm/socket.h @@ -74,7 +74,7 @@ #define SO_SELECT_ERR_QUEUE 45 -#define SO_LL 46 +#define SO_BUSY_POLL 46 #endif /* _ASM_SOCKET_H */ diff --git a/arch/h8300/include/uapi/asm/socket.h b/arch/h8300/include/uapi/asm/socket.h index a38d38a6520b..9490758c5e2b 100644 --- a/arch/h8300/include/uapi/asm/socket.h +++ b/arch/h8300/include/uapi/asm/socket.h @@ -74,6 +74,6 @@ #define SO_SELECT_ERR_QUEUE 45 -#define SO_LL 46 +#define SO_BUSY_POLL 46 #endif /* _ASM_SOCKET_H */ diff --git a/arch/ia64/include/uapi/asm/socket.h b/arch/ia64/include/uapi/asm/socket.h index d3358b760681..556d0701a155 100644 --- a/arch/ia64/include/uapi/asm/socket.h +++ b/arch/ia64/include/uapi/asm/socket.h @@ -83,6 +83,6 @@ #define SO_SELECT_ERR_QUEUE 45 -#define SO_LL 46 +#define SO_BUSY_POLL 46 #endif /* _ASM_IA64_SOCKET_H */ diff --git a/arch/m32r/include/uapi/asm/socket.h b/arch/m32r/include/uapi/asm/socket.h index 44aaf4639a4a..24be7c8da86a 100644 --- a/arch/m32r/include/uapi/asm/socket.h +++ b/arch/m32r/include/uapi/asm/socket.h @@ -74,6 +74,6 @@ #define SO_SELECT_ERR_QUEUE 45 -#define SO_LL 46 +#define SO_BUSY_POLL 46 #endif /* _ASM_M32R_SOCKET_H */ diff --git a/arch/mips/include/uapi/asm/socket.h b/arch/mips/include/uapi/asm/socket.h index 6a07992ba6c6..61c01f054d1b 100644 --- a/arch/mips/include/uapi/asm/socket.h +++ b/arch/mips/include/uapi/asm/socket.h @@ -92,6 +92,6 @@ #define SO_SELECT_ERR_QUEUE 45 -#define SO_LL 46 +#define SO_BUSY_POLL 46 #endif /* _UAPI_ASM_SOCKET_H */ diff --git a/arch/mn10300/include/uapi/asm/socket.h b/arch/mn10300/include/uapi/asm/socket.h index db80fd3e398b..e2a2b203eb00 100644 --- a/arch/mn10300/include/uapi/asm/socket.h +++ b/arch/mn10300/include/uapi/asm/socket.h @@ -74,6 +74,6 @@ #define SO_SELECT_ERR_QUEUE 45 -#define SO_LL 46 +#define SO_BUSY_POLL 46 #endif /* _ASM_SOCKET_H */ diff --git a/arch/parisc/include/uapi/asm/socket.h b/arch/parisc/include/uapi/asm/socket.h index f866fff9a004..71700e636a8e 100644 --- a/arch/parisc/include/uapi/asm/socket.h +++ b/arch/parisc/include/uapi/asm/socket.h @@ -73,7 +73,7 @@ #define SO_SELECT_ERR_QUEUE 0x4026 -#define SO_LL 0x4027 +#define SO_BUSY_POLL 0x4027 /* O_NONBLOCK clashes with the bits used for socket types. Therefore we * have to define SOCK_NONBLOCK to a different value here. diff --git a/arch/powerpc/include/uapi/asm/socket.h b/arch/powerpc/include/uapi/asm/socket.h index 405fb09bda94..a6d74467c9ed 100644 --- a/arch/powerpc/include/uapi/asm/socket.h +++ b/arch/powerpc/include/uapi/asm/socket.h @@ -81,6 +81,6 @@ #define SO_SELECT_ERR_QUEUE 45 -#define SO_LL 46 +#define SO_BUSY_POLL 46 #endif /* _ASM_POWERPC_SOCKET_H */ diff --git a/arch/s390/include/uapi/asm/socket.h b/arch/s390/include/uapi/asm/socket.h index 0c5105fbaaf3..92494494692e 100644 --- a/arch/s390/include/uapi/asm/socket.h +++ b/arch/s390/include/uapi/asm/socket.h @@ -80,6 +80,6 @@ #define SO_SELECT_ERR_QUEUE 45 -#define SO_LL 46 +#define SO_BUSY_POLL 46 #endif /* _ASM_SOCKET_H */ diff --git a/arch/sparc/include/uapi/asm/socket.h b/arch/sparc/include/uapi/asm/socket.h index b46c3fa0b265..4e1d66c3ce71 100644 --- a/arch/sparc/include/uapi/asm/socket.h +++ b/arch/sparc/include/uapi/asm/socket.h @@ -70,7 +70,7 @@ #define SO_SELECT_ERR_QUEUE 0x0029 -#define SO_LL 0x0030 +#define SO_BUSY_POLL 0x0030 /* Security levels - as per NRL IPv6 - don't actually do anything */ #define SO_SECURITY_AUTHENTICATION 0x5001 diff --git a/arch/xtensa/include/uapi/asm/socket.h b/arch/xtensa/include/uapi/asm/socket.h index b21ace4fc9ba..c114483010c1 100644 --- a/arch/xtensa/include/uapi/asm/socket.h +++ b/arch/xtensa/include/uapi/asm/socket.h @@ -85,6 +85,6 @@ #define SO_SELECT_ERR_QUEUE 45 -#define SO_LL 46 +#define SO_BUSY_POLL 46 #endif /* _XTENSA_SOCKET_H */ diff --git a/include/net/busy_poll.h b/include/net/busy_poll.h index 4ff71908fd42..a14339c2985f 100644 --- a/include/net/busy_poll.h +++ b/include/net/busy_poll.h @@ -30,8 +30,8 @@ #ifdef CONFIG_NET_LL_RX_POLL struct napi_struct; -extern unsigned int sysctl_net_ll_read __read_mostly; -extern unsigned int sysctl_net_ll_poll __read_mostly; +extern unsigned int sysctl_net_busy_read __read_mostly; +extern unsigned int sysctl_net_busy_poll __read_mostly; /* return values from ndo_ll_poll */ #define LL_FLUSH_FAILED -1 @@ -39,7 +39,7 @@ extern unsigned int sysctl_net_ll_poll __read_mostly; static inline bool net_busy_loop_on(void) { - return sysctl_net_ll_poll; + return sysctl_net_busy_poll; } /* a wrapper to make debug_smp_processor_id() happy @@ -72,7 +72,7 @@ static inline unsigned long sk_busy_loop_end_time(struct sock *sk) /* in poll/select we use the global sysctl_net_ll_poll value */ static inline unsigned long busy_loop_end_time(void) { - return busy_loop_us_clock() + ACCESS_ONCE(sysctl_net_ll_poll); + return busy_loop_us_clock() + ACCESS_ONCE(sysctl_net_busy_poll); } static inline bool sk_can_busy_loop(struct sock *sk) diff --git a/include/uapi/asm-generic/socket.h b/include/uapi/asm-generic/socket.h index ca3a20d772ac..f04b69b6abf2 100644 --- a/include/uapi/asm-generic/socket.h +++ b/include/uapi/asm-generic/socket.h @@ -76,6 +76,6 @@ #define SO_SELECT_ERR_QUEUE 45 -#define SO_LL 46 +#define SO_BUSY_POLL 46 #endif /* __ASM_GENERIC_SOCKET_H */ diff --git a/net/core/sock.c b/net/core/sock.c index 9bfe83f4d670..548d716c5f62 100644 --- a/net/core/sock.c +++ b/net/core/sock.c @@ -901,7 +901,7 @@ set_rcvbuf: break; #ifdef CONFIG_NET_LL_RX_POLL - case SO_LL: + case SO_BUSY_POLL: /* allow unprivileged users to decrease the value */ if ((val > sk->sk_ll_usec) && !capable(CAP_NET_ADMIN)) ret = -EPERM; @@ -1171,7 +1171,7 @@ int sock_getsockopt(struct socket *sock, int level, int optname, break; #ifdef CONFIG_NET_LL_RX_POLL - case SO_LL: + case SO_BUSY_POLL: v.val = sk->sk_ll_usec; break; #endif @@ -2294,7 +2294,7 @@ void sock_init_data(struct socket *sock, struct sock *sk) #ifdef CONFIG_NET_LL_RX_POLL sk->sk_napi_id = 0; - sk->sk_ll_usec = sysctl_net_ll_read; + sk->sk_ll_usec = sysctl_net_busy_read; #endif /* diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c index 1a298cb3daee..660968616637 100644 --- a/net/core/sysctl_net_core.c +++ b/net/core/sysctl_net_core.c @@ -300,15 +300,15 @@ static struct ctl_table net_core_table[] = { #endif /* CONFIG_NET_FLOW_LIMIT */ #ifdef CONFIG_NET_LL_RX_POLL { - .procname = "low_latency_poll", - .data = &sysctl_net_ll_poll, + .procname = "busy_poll", + .data = &sysctl_net_busy_poll, .maxlen = sizeof(unsigned int), .mode = 0644, .proc_handler = proc_dointvec }, { - .procname = "low_latency_read", - .data = &sysctl_net_ll_read, + .procname = "busy_read", + .data = &sysctl_net_busy_read, .maxlen = sizeof(unsigned int), .mode = 0644, .proc_handler = proc_dointvec diff --git a/net/socket.c b/net/socket.c index 6a3e9a3f50ad..829b460acb87 100644 --- a/net/socket.c +++ b/net/socket.c @@ -107,8 +107,8 @@ #include #ifdef CONFIG_NET_LL_RX_POLL -unsigned int sysctl_net_ll_read __read_mostly; -unsigned int sysctl_net_ll_poll __read_mostly; +unsigned int sysctl_net_busy_read __read_mostly; +unsigned int sysctl_net_busy_poll __read_mostly; #endif static int sock_no_open(struct inode *irrelevant, struct file *dontcare); From 45dd95c443c2d81d8d41e55afeafd4c61042fa76 Mon Sep 17 00:00:00 2001 From: hayeswang Date: Mon, 8 Jul 2013 17:09:01 +0800 Subject: [PATCH 0761/1048] r8169: add a new chip for RTL8411 Add a new chip for RTL8411 series. Signed-off-by: Hayes Wang Signed-off-by: David S. Miller --- drivers/net/ethernet/realtek/r8169.c | 67 ++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c index 393f961a013c..4106a743ca74 100644 --- a/drivers/net/ethernet/realtek/r8169.c +++ b/drivers/net/ethernet/realtek/r8169.c @@ -46,6 +46,7 @@ #define FIRMWARE_8105E_1 "rtl_nic/rtl8105e-1.fw" #define FIRMWARE_8402_1 "rtl_nic/rtl8402-1.fw" #define FIRMWARE_8411_1 "rtl_nic/rtl8411-1.fw" +#define FIRMWARE_8411_2 "rtl_nic/rtl8411-2.fw" #define FIRMWARE_8106E_1 "rtl_nic/rtl8106e-1.fw" #define FIRMWARE_8106E_2 "rtl_nic/rtl8106e-2.fw" #define FIRMWARE_8168G_2 "rtl_nic/rtl8168g-2.fw" @@ -144,6 +145,7 @@ enum mac_version { RTL_GIGA_MAC_VER_41, RTL_GIGA_MAC_VER_42, RTL_GIGA_MAC_VER_43, + RTL_GIGA_MAC_VER_44, RTL_GIGA_MAC_NONE = 0xff, }; @@ -276,6 +278,9 @@ static const struct { [RTL_GIGA_MAC_VER_43] = _R("RTL8106e", RTL_TD_1, FIRMWARE_8106E_2, JUMBO_1K, true), + [RTL_GIGA_MAC_VER_44] = + _R("RTL8411", RTL_TD_1, FIRMWARE_8411_2, + JUMBO_9K, false), }; #undef _R @@ -394,6 +399,7 @@ enum rtl8168_8101_registers { #define CSIAR_FUNC_CARD 0x00000000 #define CSIAR_FUNC_SDIO 0x00010000 #define CSIAR_FUNC_NIC 0x00020000 +#define CSIAR_FUNC_NIC2 0x00010000 PMCH = 0x6f, EPHYAR = 0x80, #define EPHYAR_FLAG 0x80000000 @@ -826,6 +832,7 @@ MODULE_FIRMWARE(FIRMWARE_8168F_1); MODULE_FIRMWARE(FIRMWARE_8168F_2); MODULE_FIRMWARE(FIRMWARE_8402_1); MODULE_FIRMWARE(FIRMWARE_8411_1); +MODULE_FIRMWARE(FIRMWARE_8411_2); MODULE_FIRMWARE(FIRMWARE_8106E_1); MODULE_FIRMWARE(FIRMWARE_8106E_2); MODULE_FIRMWARE(FIRMWARE_8168G_2); @@ -2051,6 +2058,7 @@ static void rtl8169_get_mac_version(struct rtl8169_private *tp, int mac_version; } mac_info[] = { /* 8168G family. */ + { 0x7cf00000, 0x5c800000, RTL_GIGA_MAC_VER_44 }, { 0x7cf00000, 0x50900000, RTL_GIGA_MAC_VER_42 }, { 0x7cf00000, 0x4c100000, RTL_GIGA_MAC_VER_41 }, { 0x7cf00000, 0x4c000000, RTL_GIGA_MAC_VER_40 }, @@ -3651,6 +3659,7 @@ static void rtl_hw_phy_config(struct net_device *dev) break; case RTL_GIGA_MAC_VER_42: case RTL_GIGA_MAC_VER_43: + case RTL_GIGA_MAC_VER_44: rtl8168g_2_hw_phy_config(tp); break; @@ -3863,6 +3872,7 @@ static void rtl_init_mdio_ops(struct rtl8169_private *tp) case RTL_GIGA_MAC_VER_41: case RTL_GIGA_MAC_VER_42: case RTL_GIGA_MAC_VER_43: + case RTL_GIGA_MAC_VER_44: ops->write = r8168g_mdio_write; ops->read = r8168g_mdio_read; break; @@ -3916,6 +3926,7 @@ static void rtl_wol_suspend_quirk(struct rtl8169_private *tp) case RTL_GIGA_MAC_VER_41: case RTL_GIGA_MAC_VER_42: case RTL_GIGA_MAC_VER_43: + case RTL_GIGA_MAC_VER_44: RTL_W32(RxConfig, RTL_R32(RxConfig) | AcceptBroadcast | AcceptMulticast | AcceptMyPhys); break; @@ -4178,6 +4189,7 @@ static void rtl_init_pll_power_ops(struct rtl8169_private *tp) case RTL_GIGA_MAC_VER_40: case RTL_GIGA_MAC_VER_41: case RTL_GIGA_MAC_VER_42: + case RTL_GIGA_MAC_VER_44: ops->down = r8168_pll_power_down; ops->up = r8168_pll_power_up; break; @@ -4224,6 +4236,7 @@ static void rtl_init_rxcfg(struct rtl8169_private *tp) case RTL_GIGA_MAC_VER_41: case RTL_GIGA_MAC_VER_42: case RTL_GIGA_MAC_VER_43: + case RTL_GIGA_MAC_VER_44: RTL_W32(RxConfig, RX128_INT_EN | RX_DMA_BURST | RX_EARLY_OFF); break; default: @@ -4384,6 +4397,7 @@ static void rtl_init_jumbo_ops(struct rtl8169_private *tp) case RTL_GIGA_MAC_VER_41: case RTL_GIGA_MAC_VER_42: case RTL_GIGA_MAC_VER_43: + case RTL_GIGA_MAC_VER_44: default: ops->disable = NULL; ops->enable = NULL; @@ -4493,6 +4507,7 @@ static void rtl8169_hw_reset(struct rtl8169_private *tp) tp->mac_version == RTL_GIGA_MAC_VER_41 || tp->mac_version == RTL_GIGA_MAC_VER_42 || tp->mac_version == RTL_GIGA_MAC_VER_43 || + tp->mac_version == RTL_GIGA_MAC_VER_44 || tp->mac_version == RTL_GIGA_MAC_VER_38) { RTL_W8(ChipCmd, RTL_R8(ChipCmd) | StopReq); rtl_udelay_loop_wait_high(tp, &rtl_txcfg_empty_cond, 100, 666); @@ -4782,6 +4797,29 @@ static u32 r8402_csi_read(struct rtl8169_private *tp, int addr) RTL_R32(CSIDR) : ~0; } +static void r8411_csi_write(struct rtl8169_private *tp, int addr, int value) +{ + void __iomem *ioaddr = tp->mmio_addr; + + RTL_W32(CSIDR, value); + RTL_W32(CSIAR, CSIAR_WRITE_CMD | (addr & CSIAR_ADDR_MASK) | + CSIAR_BYTE_ENABLE << CSIAR_BYTE_ENABLE_SHIFT | + CSIAR_FUNC_NIC2); + + rtl_udelay_loop_wait_low(tp, &rtl_csiar_cond, 10, 100); +} + +static u32 r8411_csi_read(struct rtl8169_private *tp, int addr) +{ + void __iomem *ioaddr = tp->mmio_addr; + + RTL_W32(CSIAR, (addr & CSIAR_ADDR_MASK) | CSIAR_FUNC_NIC2 | + CSIAR_BYTE_ENABLE << CSIAR_BYTE_ENABLE_SHIFT); + + return rtl_udelay_loop_wait_high(tp, &rtl_csiar_cond, 10, 100) ? + RTL_R32(CSIDR) : ~0; +} + static void rtl_init_csi_ops(struct rtl8169_private *tp) { struct csi_ops *ops = &tp->csi_ops; @@ -4811,6 +4849,11 @@ static void rtl_init_csi_ops(struct rtl8169_private *tp) ops->read = r8402_csi_read; break; + case RTL_GIGA_MAC_VER_44: + ops->write = r8411_csi_write; + ops->read = r8411_csi_read; + break; + default: ops->write = r8169_csi_write; ops->read = r8169_csi_read; @@ -5255,6 +5298,25 @@ static void rtl_hw_start_8168g_2(struct rtl8169_private *tp) rtl_ephy_init(tp, e_info_8168g_2, ARRAY_SIZE(e_info_8168g_2)); } +static void rtl_hw_start_8411_2(struct rtl8169_private *tp) +{ + void __iomem *ioaddr = tp->mmio_addr; + static const struct ephy_info e_info_8411_2[] = { + { 0x00, 0x0000, 0x0008 }, + { 0x0c, 0x3df0, 0x0200 }, + { 0x0f, 0xffff, 0x5200 }, + { 0x19, 0x0020, 0x0000 }, + { 0x1e, 0x0000, 0x2000 } + }; + + rtl_hw_start_8168g_1(tp); + + /* disable aspm and clock request before access ephy */ + RTL_W8(Config2, RTL_R8(Config2) & ~ClkReqEn); + RTL_W8(Config5, RTL_R8(Config5) & ~ASPM_en); + rtl_ephy_init(tp, e_info_8411_2, ARRAY_SIZE(e_info_8411_2)); +} + static void rtl_hw_start_8168(struct net_device *dev) { struct rtl8169_private *tp = netdev_priv(dev); @@ -5361,6 +5423,10 @@ static void rtl_hw_start_8168(struct net_device *dev) rtl_hw_start_8168g_2(tp); break; + case RTL_GIGA_MAC_VER_44: + rtl_hw_start_8411_2(tp); + break; + default: printk(KERN_ERR PFX "%s: unknown chipset (mac_version = %d).\n", dev->name, tp->mac_version); @@ -6877,6 +6943,7 @@ static void rtl_hw_initialize(struct rtl8169_private *tp) case RTL_GIGA_MAC_VER_41: case RTL_GIGA_MAC_VER_42: case RTL_GIGA_MAC_VER_43: + case RTL_GIGA_MAC_VER_44: rtl_hw_init_8168g(tp); break; From 822dbba33458cd6ad0e715f3f4a57ebc99d54d1b Mon Sep 17 00:00:00 2001 From: Jan Kara Date: Wed, 10 Jul 2013 21:31:04 -0400 Subject: [PATCH 0762/1048] ext4: fix warning in ext4_evict_inode() The following race can lead to ext4_evict_inode() seeing i_ioend_count > 0 and thus triggering a sanity check warning: CPU1 CPU2 ext4_end_bio() ext4_evict_inode() ext4_finish_bio() end_page_writeback(); truncate_inode_pages() evict page WARN_ON(i_ioend_count > 0); ext4_put_io_end_defer() ext4_release_io_end() dec i_ioend_count This is possible use-after-free bug since we decrement i_ioend_count in possibly released inode. Since i_ioend_count is used only for sanity checks one possible solution would be to just remove it but for now I'd like to keep those sanity checks to help debugging the new ext4 writeback code. This patch changes ext4_end_bio() to call ext4_put_io_end_defer() before ext4_finish_bio() in the shortcut case when unwritten extent conversion isn't needed. In that case we don't need the io_end so we are safe to drop it early. Reported-by: Guenter Roeck Tested-by: Guenter Roeck Signed-off-by: Jan Kara Signed-off-by: "Theodore Ts'o" --- fs/ext4/page-io.c | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/fs/ext4/page-io.c b/fs/ext4/page-io.c index 48786cdb5e6c..d63cc5e9d3b5 100644 --- a/fs/ext4/page-io.c +++ b/fs/ext4/page-io.c @@ -308,6 +308,7 @@ ext4_io_end_t *ext4_get_io_end(ext4_io_end_t *io_end) return io_end; } +/* BIO completion function for page writeback */ static void ext4_end_bio(struct bio *bio, int error) { ext4_io_end_t *io_end = bio->bi_private; @@ -318,18 +319,6 @@ static void ext4_end_bio(struct bio *bio, int error) if (test_bit(BIO_UPTODATE, &bio->bi_flags)) error = 0; - if (io_end->flag & EXT4_IO_END_UNWRITTEN) { - /* - * Link bio into list hanging from io_end. We have to do it - * atomically as bio completions can be racing against each - * other. - */ - bio->bi_private = xchg(&io_end->bio, bio); - } else { - ext4_finish_bio(bio); - bio_put(bio); - } - if (error) { struct inode *inode = io_end->inode; @@ -341,7 +330,24 @@ static void ext4_end_bio(struct bio *bio, int error) (unsigned long long) bi_sector >> (inode->i_blkbits - 9)); } - ext4_put_io_end_defer(io_end); + + if (io_end->flag & EXT4_IO_END_UNWRITTEN) { + /* + * Link bio into list hanging from io_end. We have to do it + * atomically as bio completions can be racing against each + * other. + */ + bio->bi_private = xchg(&io_end->bio, bio); + ext4_put_io_end_defer(io_end); + } else { + /* + * Drop io_end reference early. Inode can get freed once + * we finish the bio. + */ + ext4_put_io_end_defer(io_end); + ext4_finish_bio(bio); + bio_put(bio); + } } void ext4_io_submit(struct ext4_io_submit *io) From 440d57bc5ff55ec1efb3efc9cbe9420b4bbdfefa Mon Sep 17 00:00:00 2001 From: dingtianhong Date: Wed, 10 Jul 2013 12:04:02 +0800 Subject: [PATCH 0763/1048] ifb: fix rcu_sched self-detected stalls According to the commit 16b0dc29c1af9df341428f4c49ada4f626258082 (dummy: fix rcu_sched self-detected stalls) Eric Dumazet fix the problem in dummy, but the ifb will occur the same problem like the dummy modules. Trying to "modprobe ifb numifbs=30000" triggers : INFO: rcu_sched self-detected stall on CPU After this splat, RTNL is locked and reboot is needed. We must call cond_resched() to avoid this, even holding RTNL. Signed-off-by: Ding Tianhong Signed-off-by: David S. Miller --- drivers/net/ifb.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/net/ifb.c b/drivers/net/ifb.c index dc9f6a45515d..a11f7a45cb5f 100644 --- a/drivers/net/ifb.c +++ b/drivers/net/ifb.c @@ -292,8 +292,10 @@ static int __init ifb_init_module(void) rtnl_lock(); err = __rtnl_link_register(&ifb_link_ops); - for (i = 0; i < numifbs && !err; i++) + for (i = 0; i < numifbs && !err; i++) { err = ifb_init_one(i); + cond_resched(); + } if (err) __rtnl_link_unregister(&ifb_link_ops); rtnl_unlock(); From 3dd5c3308e8b671e8e8882ba972f51cefbe9fd0d Mon Sep 17 00:00:00 2001 From: Jason Wang Date: Wed, 10 Jul 2013 13:43:27 +0800 Subject: [PATCH 0764/1048] tuntap: correctly linearize skb when zerocopy is used Userspace may produce vectors greater than MAX_SKB_FRAGS. When we try to linearize parts of the skb to let the rest of iov to be fit in the frags, we need count copylen into linear when calling tun_alloc_skb() instead of partly counting it into data_len. Since this breaks zerocopy_sg_from_iovec() since its inner counter assumes nr_frags should be zero at beginning. This cause nr_frags to be increased wrongly without setting the correct frags. This bug were introduced from 0690899b4d4501b3505be069b9a687e68ccbe15b (tun: experimental zero copy tx support) Cc: Michael S. Tsirkin Signed-off-by: Jason Wang Acked-by: Michael S. Tsirkin Signed-off-by: David S. Miller --- drivers/net/tun.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/net/tun.c b/drivers/net/tun.c index 7eab5fcd064f..5cdcf92eb310 100644 --- a/drivers/net/tun.c +++ b/drivers/net/tun.c @@ -1042,7 +1042,7 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile, { struct tun_pi pi = { 0, cpu_to_be16(ETH_P_IP) }; struct sk_buff *skb; - size_t len = total_len, align = NET_SKB_PAD; + size_t len = total_len, align = NET_SKB_PAD, linear; struct virtio_net_hdr gso = { 0 }; int offset = 0; int copylen; @@ -1106,10 +1106,13 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile, copylen = gso.hdr_len; if (!copylen) copylen = GOODCOPY_LEN; - } else + linear = copylen; + } else { copylen = len; + linear = gso.hdr_len; + } - skb = tun_alloc_skb(tfile, align, copylen, gso.hdr_len, noblock); + skb = tun_alloc_skb(tfile, align, copylen, linear, noblock); if (IS_ERR(skb)) { if (PTR_ERR(skb) != -EAGAIN) tun->dev->stats.rx_dropped++; From 61d46bf979d5cd7c164709a80ad5676a35494aae Mon Sep 17 00:00:00 2001 From: Jason Wang Date: Wed, 10 Jul 2013 13:43:28 +0800 Subject: [PATCH 0765/1048] macvtap: correctly linearize skb when zerocopy is used Userspace may produce vectors greater than MAX_SKB_FRAGS. When we try to linearize parts of the skb to let the rest of iov to be fit in the frags, we need count copylen into linear when calling macvtap_alloc_skb() instead of partly counting it into data_len. Since this breaks zerocopy_sg_from_iovec() since its inner counter assumes nr_frags should be zero at beginning. This cause nr_frags to be increased wrongly without setting the correct frags. This bug were introduced from b92946e2919134ebe2a4083e4302236295ea2a73 (macvtap: zerocopy: validate vectors before building skb). Cc: Michael S. Tsirkin Signed-off-by: Jason Wang Acked-by: Michael S. Tsirkin Signed-off-by: David S. Miller --- drivers/net/macvtap.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c index f2c4a3b218fc..876c72246ae9 100644 --- a/drivers/net/macvtap.c +++ b/drivers/net/macvtap.c @@ -712,6 +712,7 @@ static ssize_t macvtap_get_user(struct macvtap_queue *q, struct msghdr *m, int vnet_hdr_len = 0; int copylen = 0; bool zerocopy = false; + size_t linear; if (q->flags & IFF_VNET_HDR) { vnet_hdr_len = q->vnet_hdr_sz; @@ -766,11 +767,14 @@ static ssize_t macvtap_get_user(struct macvtap_queue *q, struct msghdr *m, copylen = vnet_hdr.hdr_len; if (!copylen) copylen = GOODCOPY_LEN; - } else + linear = copylen; + } else { copylen = len; + linear = vnet_hdr.hdr_len; + } skb = macvtap_alloc_skb(&q->sk, NET_IP_ALIGN, copylen, - vnet_hdr.hdr_len, noblock, &err); + linear, noblock, &err); if (!skb) goto err; From 1eb4f758286884e7566627164bca4c4a16952a83 Mon Sep 17 00:00:00 2001 From: Hannes Frederic Sowa Date: Wed, 10 Jul 2013 23:00:57 +0200 Subject: [PATCH 0766/1048] ipv6: in case of link failure remove route directly instead of letting it expire We could end up expiring a route which is part of an ecmp route set. Doing so would invalidate the rt->rt6i_nsiblings calculations and could provoke the following panic: [ 80.144667] ------------[ cut here ]------------ [ 80.145172] kernel BUG at net/ipv6/ip6_fib.c:733! [ 80.145172] invalid opcode: 0000 [#1] SMP [ 80.145172] Modules linked in: 8021q nf_conntrack_netbios_ns nf_conntrack_broadcast ipt_MASQUERADE ip6table_mangle ip6t_REJECT nf_conntrack_ipv6 nf_defrag_ipv6 iptable_nat nf_nat_ipv4 nf_nat iptable_mangle nf_conntrack_ipv4 nf_defrag_ipv4 xt_conntrack nf_conntrack ebtable_filter ebtables ip6table_filter ip6_tables +snd_hda_intel snd_hda_codec snd_hwdep snd_seq snd_seq_device snd_pcm snd_page_alloc snd_timer virtio_balloon snd soundcore i2c_piix4 i2c_core virtio_net virtio_blk [ 80.145172] CPU: 1 PID: 786 Comm: ping6 Not tainted 3.10.0+ #118 [ 80.145172] Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011 [ 80.145172] task: ffff880117fa0000 ti: ffff880118770000 task.ti: ffff880118770000 [ 80.145172] RIP: 0010:[] [] fib6_add+0x75d/0x830 [ 80.145172] RSP: 0018:ffff880118771798 EFLAGS: 00010202 [ 80.145172] RAX: 0000000000000000 RBX: 0000000000000000 RCX: ffff88011350e480 [ 80.145172] RDX: ffff88011350e238 RSI: 0000000000000004 RDI: ffff88011350f738 [ 80.145172] RBP: ffff880118771848 R08: ffff880117903280 R09: 0000000000000001 [ 80.145172] R10: 0000000000000000 R11: 0000000000000000 R12: ffff88011350f680 [ 80.145172] R13: ffff880117903280 R14: ffff880118771890 R15: ffff88011350ef90 [ 80.145172] FS: 00007f02b5127740(0000) GS:ffff88011fd00000(0000) knlGS:0000000000000000 [ 80.145172] CS: 0010 DS: 0000 ES: 0000 CR0: 000000008005003b [ 80.145172] CR2: 00007f981322a000 CR3: 00000001181b1000 CR4: 00000000000006e0 [ 80.145172] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [ 80.145172] DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400 [ 80.145172] Stack: [ 80.145172] 0000000000000001 ffff880100000000 ffff880100000000 ffff880117903280 [ 80.145172] 0000000000000000 ffff880119a4cf00 0000000000000400 00000000000007fa [ 80.145172] 0000000000000000 0000000000000000 0000000000000000 ffff88011350f680 [ 80.145172] Call Trace: [ 80.145172] [] ? rt6_bind_peer+0x4b/0x90 [ 80.145172] [] __ip6_ins_rt+0x45/0x70 [ 80.145172] [] ip6_ins_rt+0x35/0x40 [ 80.145172] [] ip6_pol_route.isra.44+0x3a4/0x4b0 [ 80.145172] [] ip6_pol_route_output+0x2a/0x30 [ 80.145172] [] fib6_rule_action+0xd7/0x210 [ 80.145172] [] ? ip6_pol_route_input+0x30/0x30 [ 80.145172] [] fib_rules_lookup+0xc6/0x140 [ 80.145172] [] fib6_rule_lookup+0x44/0x80 [ 80.145172] [] ? ip6_pol_route_input+0x30/0x30 [ 80.145172] [] ip6_route_output+0x73/0xb0 [ 80.145172] [] ip6_dst_lookup_tail+0x2c3/0x2e0 [ 80.145172] [] ? list_del+0x11/0x40 [ 80.145172] [] ? remove_wait_queue+0x3c/0x50 [ 80.145172] [] ip6_dst_lookup_flow+0x3d/0xa0 [ 80.145172] [] rawv6_sendmsg+0x267/0xc20 [ 80.145172] [] inet_sendmsg+0x63/0xb0 [ 80.145172] [] ? selinux_socket_sendmsg+0x23/0x30 [ 80.145172] [] sock_sendmsg+0xa6/0xd0 [ 80.145172] [] SYSC_sendto+0x128/0x180 [ 80.145172] [] ? update_curr+0xec/0x170 [ 80.145172] [] ? kvm_clock_get_cycles+0x9/0x10 [ 80.145172] [] ? __getnstimeofday+0x3e/0xd0 [ 80.145172] [] SyS_sendto+0xe/0x10 [ 80.145172] [] system_call_fastpath+0x16/0x1b [ 80.145172] Code: fe ff ff 41 f6 45 2a 06 0f 85 ca fe ff ff 49 8b 7e 08 4c 89 ee e8 94 ef ff ff e9 b9 fe ff ff 48 8b 82 28 05 00 00 e9 01 ff ff ff <0f> 0b 49 8b 54 24 30 0d 00 00 40 00 89 83 14 01 00 00 48 89 53 [ 80.145172] RIP [] fib6_add+0x75d/0x830 [ 80.145172] RSP [ 80.387413] ---[ end trace 02f20b7a8b81ed95 ]--- [ 80.390154] Kernel panic - not syncing: Fatal exception in interrupt Cc: Nicolas Dichtel Cc: YOSHIFUJI Hideaki Signed-off-by: Hannes Frederic Sowa Signed-off-by: David S. Miller --- net/ipv6/route.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/net/ipv6/route.c b/net/ipv6/route.c index bd5fd7054031..5b127e09c224 100644 --- a/net/ipv6/route.c +++ b/net/ipv6/route.c @@ -1080,10 +1080,13 @@ static void ip6_link_failure(struct sk_buff *skb) rt = (struct rt6_info *) skb_dst(skb); if (rt) { - if (rt->rt6i_flags & RTF_CACHE) - rt6_update_expires(rt, 0); - else if (rt->rt6i_node && (rt->rt6i_flags & RTF_DEFAULT)) + if (rt->rt6i_flags & RTF_CACHE) { + dst_hold(&rt->dst); + if (ip6_del_rt(rt)) + dst_free(&rt->dst); + } else if (rt->rt6i_node && (rt->rt6i_flags & RTF_DEFAULT)) { rt->rt6i_node->fn_sernum = -1; + } } } From b41e6a51d57e231d2ed237f17f002cc536c0987c Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Wed, 10 Jul 2013 23:03:34 +0200 Subject: [PATCH 0767/1048] sh_eth: SH_ETH should depend on HAS_DMA If NO_DMA=y: drivers/built-in.o: In function `sh_eth_free_dma_buffer': drivers/net/ethernet/renesas/sh_eth.c:1103: undefined reference to `dma_free_coherent' drivers/net/ethernet/renesas/sh_eth.c:1110: undefined reference to `dma_free_coherent' drivers/built-in.o: In function `sh_eth_ring_init': drivers/net/ethernet/renesas/sh_eth.c:1065: undefined reference to `dma_alloc_coherent' drivers/net/ethernet/renesas/sh_eth.c:1086: undefined reference to `dma_free_coherent' drivers/built-in.o: In function `sh_eth_ring_format': drivers/net/ethernet/renesas/sh_eth.c:988: undefined reference to `dma_map_single' drivers/built-in.o: In function `sh_eth_txfree': drivers/net/ethernet/renesas/sh_eth.c:1220: undefined reference to `dma_unmap_single' drivers/built-in.o: In function `sh_eth_rx': drivers/net/ethernet/renesas/sh_eth.c:1323: undefined reference to `dma_map_single' drivers/built-in.o: In function `sh_eth_start_xmit': drivers/net/ethernet/renesas/sh_eth.c:1954: undefined reference to `dma_map_single' Signed-off-by: Geert Uytterhoeven Signed-off-by: David S. Miller --- drivers/net/ethernet/renesas/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/ethernet/renesas/Kconfig b/drivers/net/ethernet/renesas/Kconfig index 544514e66187..19a8a045e077 100644 --- a/drivers/net/ethernet/renesas/Kconfig +++ b/drivers/net/ethernet/renesas/Kconfig @@ -4,6 +4,7 @@ config SH_ETH tristate "Renesas SuperH Ethernet support" + depends on HAS_DMA select CRC32 select MII select MDIO_BITBANG From d320c079efd46db1be0640d00bd6723d9e738f9f Mon Sep 17 00:00:00 2001 From: Matt Fleming Date: Thu, 11 Jul 2013 07:30:33 +0100 Subject: [PATCH 0768/1048] efivars: check for EFI_RUNTIME_SERVICES The efivars code requires EFI runtime services to function, so check that they are enabled. This fixes a crash when booting with the "noefi" kernel parameter, and also when mixing kernel and firmware "bitness", e.g. 32-bit kernel with 64-bit firmware. Tested-by: Dave Young Signed-off-by: Matt Fleming --- drivers/firmware/efi/efivars.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/firmware/efi/efivars.c b/drivers/firmware/efi/efivars.c index 8bd1bb6dbe47..8a7432a4b413 100644 --- a/drivers/firmware/efi/efivars.c +++ b/drivers/firmware/efi/efivars.c @@ -583,6 +583,9 @@ int efivars_sysfs_init(void) struct kobject *parent_kobj = efivars_kobject(); int error = 0; + if (!efi_enabled(EFI_RUNTIME_SERVICES)) + return -ENODEV; + /* No efivars has been registered yet */ if (!parent_kobj) return 0; From 8216a67eb5e92224b4509b7f55ec4891c9021fdb Mon Sep 17 00:00:00 2001 From: Matt Fleming Date: Thu, 11 Jul 2013 10:32:32 +0100 Subject: [PATCH 0769/1048] Revert "UEFI: Don't pass boot services regions to SetVirtualAddressMap()" This reverts commit 1acba98f810a14b1255e34bc620594f83de37e36. The firmware on both Dave's Thinkpad and Maarten's Macbook Pro appear to rely on the old behaviour, and their machines fail to boot with the above commit. Reported-by: Dave Young Reported-by: Maarten Lankhorst Cc: Seth Forshee Cc: Matthew Garrett Signed-off-by: Matt Fleming --- arch/x86/platform/efi/efi.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c index c8d5577044bb..90f6ed127096 100644 --- a/arch/x86/platform/efi/efi.c +++ b/arch/x86/platform/efi/efi.c @@ -931,13 +931,6 @@ void __init efi_enter_virtual_mode(void) va = efi_ioremap(md->phys_addr, size, md->type, md->attribute); - if (!(md->attribute & EFI_MEMORY_RUNTIME)) { - if (!va) - pr_err("ioremap of 0x%llX failed!\n", - (unsigned long long)md->phys_addr); - continue; - } - md->virt_addr = (u64) (unsigned long) va; if (!va) { From 103ccee4ef1595468cf79c93068d253c7f2d85a8 Mon Sep 17 00:00:00 2001 From: Stephen Warren Date: Wed, 10 Jul 2013 10:38:18 -0600 Subject: [PATCH 0770/1048] spi: revert master->setup function removal for altera and nuc900 Commit 24778be "spi: convert drivers to use bits_per_word_mask" removed what appeared to be redundant code from many drivers. However, it appears that in the spi-bitbang case, these functions are required by the spi-bitbang core, even if they don't do anything. Restore them. For 3.12, the spi-bitbang core should be adjusted not to require these callbacks to exist if they don't need to do anything. This is the equivalent of Michal Simek's patch "spi/xilinx: Revert master->setup function removal", applied to other affected drivers. Signed-off-by: Stephen Warren Signed-off-by: Mark Brown --- drivers/spi/spi-altera.c | 12 ++++++++++++ drivers/spi/spi-nuc900.c | 13 +++++++++++++ 2 files changed, 25 insertions(+) diff --git a/drivers/spi/spi-altera.c b/drivers/spi/spi-altera.c index 8a6bb37910da..81b9adb6e766 100644 --- a/drivers/spi/spi-altera.c +++ b/drivers/spi/spi-altera.c @@ -103,6 +103,16 @@ static void altera_spi_chipsel(struct spi_device *spi, int value) } } +static int altera_spi_setupxfer(struct spi_device *spi, struct spi_transfer *t) +{ + return 0; +} + +static int altera_spi_setup(struct spi_device *spi) +{ + return 0; +} + static inline unsigned int hw_txbyte(struct altera_spi *hw, int count) { if (hw->tx) { @@ -221,6 +231,7 @@ static int altera_spi_probe(struct platform_device *pdev) master->bus_num = pdev->id; master->num_chipselect = 16; master->mode_bits = SPI_CS_HIGH; + master->setup = altera_spi_setup; hw = spi_master_get_devdata(master); platform_set_drvdata(pdev, hw); @@ -229,6 +240,7 @@ static int altera_spi_probe(struct platform_device *pdev) hw->bitbang.master = spi_master_get(master); if (!hw->bitbang.master) return err; + hw->bitbang.setup_transfer = altera_spi_setupxfer; hw->bitbang.chipselect = altera_spi_chipsel; hw->bitbang.txrx_bufs = altera_spi_txrx; diff --git a/drivers/spi/spi-nuc900.c b/drivers/spi/spi-nuc900.c index 2ad3d74ac021..150d85453c27 100644 --- a/drivers/spi/spi-nuc900.c +++ b/drivers/spi/spi-nuc900.c @@ -174,6 +174,17 @@ static void nuc900_spi_gobusy(struct nuc900_spi *hw) spin_unlock_irqrestore(&hw->lock, flags); } +static int nuc900_spi_setupxfer(struct spi_device *spi, + struct spi_transfer *t) +{ + return 0; +} + +static int nuc900_spi_setup(struct spi_device *spi) +{ + return 0; +} + static inline unsigned int hw_txbyte(struct nuc900_spi *hw, int count) { return hw->tx ? hw->tx[count] : 0; @@ -366,8 +377,10 @@ static int nuc900_spi_probe(struct platform_device *pdev) master->num_chipselect = hw->pdata->num_cs; master->bus_num = hw->pdata->bus_num; hw->bitbang.master = hw->master; + hw->bitbang.setup_transfer = nuc900_spi_setupxfer; hw->bitbang.chipselect = nuc900_spi_chipsel; hw->bitbang.txrx_bufs = nuc900_spi_txrx; + hw->bitbang.master->setup = nuc900_spi_setup; hw->res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (hw->res == NULL) { From 770100108be7dbe614361dbcc450096b4cdfc98b Mon Sep 17 00:00:00 2001 From: Padmavathi Venna Date: Thu, 11 Jul 2013 12:38:25 +0530 Subject: [PATCH 0771/1048] ASoC: Samsung: Set RFS and BFS in slave mode As per the User Manual, the RFS and BFS should be set in slave mode for correct operation. Signed-off-by: Padmavathi Venna Signed-off-by: Andrew Bresticker Reviewed-by: Simon Glass Signed-off-by: Mark Brown --- sound/soc/samsung/i2s.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sound/soc/samsung/i2s.c b/sound/soc/samsung/i2s.c index 7a1734697434..959c702235c8 100644 --- a/sound/soc/samsung/i2s.c +++ b/sound/soc/samsung/i2s.c @@ -742,13 +742,13 @@ static int config_setup(struct i2s_dai *i2s) return -EAGAIN; } - /* Don't bother RFS, BFS & PSR in Slave mode */ - if (is_slave(i2s)) - return 0; - set_bfs(i2s, bfs); set_rfs(i2s, rfs); + /* Don't bother with PSR in Slave mode */ + if (is_slave(i2s)) + return 0; + if (!(i2s->quirks & QUIRK_NO_MUXPSR)) { psr = i2s->rclk_srcrate / i2s->frmclk / rfs; writel(((psr - 1) << 8) | PSR_PSREN, i2s->addr + I2SPSR); From 92f8ff73f18672b03ec8b92197cdddf2b5de7ea0 Mon Sep 17 00:00:00 2001 From: Chandra Seetharaman Date: Thu, 11 Jul 2013 00:00:40 -0500 Subject: [PATCH 0772/1048] xfs: Add pquota fields where gquota is used. Add project quota changes to all the places where group quota field is used: * add separate project quota members into various structures * split project quota and group quotas so that instead of overriding the group quota members incore, the new project quota members are used instead * get rid of usage of the OQUOTA flag incore, in favor of separate group and project quota flags. * add a project dquot argument to various functions. Not using the pquotino field from superblock yet. Signed-off-by: Chandra Seetharaman Reviewed-by: Ben Myers Signed-off-by: Ben Myers --- fs/xfs/xfs_dquot.c | 15 ++- fs/xfs/xfs_dquot.h | 7 +- fs/xfs/xfs_icache.c | 1 + fs/xfs/xfs_inode.h | 1 + fs/xfs/xfs_ioctl.c | 14 +-- fs/xfs/xfs_iops.c | 4 +- fs/xfs/xfs_qm.c | 241 ++++++++++++++++++++++++++++----------- fs/xfs/xfs_qm.h | 20 ++-- fs/xfs/xfs_qm_bhv.c | 10 +- fs/xfs/xfs_qm_syscalls.c | 19 ++- fs/xfs/xfs_quota.h | 32 +++--- fs/xfs/xfs_symlink.c | 10 +- fs/xfs/xfs_trans_dquot.c | 26 ++++- fs/xfs/xfs_vnodeops.c | 13 ++- 14 files changed, 290 insertions(+), 123 deletions(-) diff --git a/fs/xfs/xfs_dquot.c b/fs/xfs/xfs_dquot.c index f01012de06d0..0adf27ecf3f1 100644 --- a/fs/xfs/xfs_dquot.c +++ b/fs/xfs/xfs_dquot.c @@ -936,6 +936,7 @@ xfs_qm_dqput_final( { struct xfs_quotainfo *qi = dqp->q_mount->m_quotainfo; struct xfs_dquot *gdqp; + struct xfs_dquot *pdqp; trace_xfs_dqput_free(dqp); @@ -949,21 +950,29 @@ xfs_qm_dqput_final( /* * If we just added a udquot to the freelist, then we want to release - * the gdquot reference that it (probably) has. Otherwise it'll keep - * the gdquot from getting reclaimed. + * the gdquot/pdquot reference that it (probably) has. Otherwise it'll + * keep the gdquot/pdquot from getting reclaimed. */ gdqp = dqp->q_gdquot; if (gdqp) { xfs_dqlock(gdqp); dqp->q_gdquot = NULL; } + + pdqp = dqp->q_pdquot; + if (pdqp) { + xfs_dqlock(pdqp); + dqp->q_pdquot = NULL; + } xfs_dqunlock(dqp); /* - * If we had a group quota hint, release it now. + * If we had a group/project quota hint, release it now. */ if (gdqp) xfs_qm_dqput(gdqp); + if (pdqp) + xfs_qm_dqput(pdqp); } /* diff --git a/fs/xfs/xfs_dquot.h b/fs/xfs/xfs_dquot.h index b596626249b8..55abbca2883d 100644 --- a/fs/xfs/xfs_dquot.h +++ b/fs/xfs/xfs_dquot.h @@ -53,6 +53,7 @@ typedef struct xfs_dquot { xfs_fileoff_t q_fileoffset; /* offset in quotas file */ struct xfs_dquot*q_gdquot; /* group dquot, hint only */ + struct xfs_dquot*q_pdquot; /* project dquot, hint only */ xfs_disk_dquot_t q_core; /* actual usage & quotas */ xfs_dq_logitem_t q_logitem; /* dquot log item */ xfs_qcnt_t q_res_bcount; /* total regular nblks used+reserved */ @@ -118,8 +119,9 @@ static inline int xfs_this_quota_on(struct xfs_mount *mp, int type) case XFS_DQ_USER: return XFS_IS_UQUOTA_ON(mp); case XFS_DQ_GROUP: + return XFS_IS_GQUOTA_ON(mp); case XFS_DQ_PROJ: - return XFS_IS_OQUOTA_ON(mp); + return XFS_IS_PQUOTA_ON(mp); default: return 0; } @@ -131,8 +133,9 @@ static inline xfs_dquot_t *xfs_inode_dquot(struct xfs_inode *ip, int type) case XFS_DQ_USER: return ip->i_udquot; case XFS_DQ_GROUP: - case XFS_DQ_PROJ: return ip->i_gdquot; + case XFS_DQ_PROJ: + return ip->i_pdquot; default: return NULL; } diff --git a/fs/xfs/xfs_icache.c b/fs/xfs/xfs_icache.c index 9560dc1f15a9..3f90e1ceb8d6 100644 --- a/fs/xfs/xfs_icache.c +++ b/fs/xfs/xfs_icache.c @@ -337,6 +337,7 @@ xfs_iget_cache_miss( iflags |= XFS_IDONTCACHE; ip->i_udquot = NULL; ip->i_gdquot = NULL; + ip->i_pdquot = NULL; xfs_iflags_set(ip, iflags); /* insert the new inode */ diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h index 91129794aaec..b55fd347ab5b 100644 --- a/fs/xfs/xfs_inode.h +++ b/fs/xfs/xfs_inode.h @@ -250,6 +250,7 @@ typedef struct xfs_inode { struct xfs_mount *i_mount; /* fs mount struct ptr */ struct xfs_dquot *i_udquot; /* user dquot */ struct xfs_dquot *i_gdquot; /* group dquot */ + struct xfs_dquot *i_pdquot; /* project dquot */ /* Inode location stuff */ xfs_ino_t i_ino; /* inode number (agno/agino)*/ diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c index dc5b65983e5f..6e2bca5d44d6 100644 --- a/fs/xfs/xfs_ioctl.c +++ b/fs/xfs/xfs_ioctl.c @@ -928,7 +928,7 @@ xfs_ioctl_setattr( struct xfs_trans *tp; unsigned int lock_flags = 0; struct xfs_dquot *udqp = NULL; - struct xfs_dquot *gdqp = NULL; + struct xfs_dquot *pdqp = NULL; struct xfs_dquot *olddquot = NULL; int code; @@ -957,7 +957,7 @@ xfs_ioctl_setattr( if (XFS_IS_QUOTA_ON(mp) && (mask & FSX_PROJID)) { code = xfs_qm_vop_dqalloc(ip, ip->i_d.di_uid, ip->i_d.di_gid, fa->fsx_projid, - XFS_QMOPT_PQUOTA, &udqp, &gdqp); + XFS_QMOPT_PQUOTA, &udqp, NULL, &pdqp); if (code) return code; } @@ -994,8 +994,8 @@ xfs_ioctl_setattr( XFS_IS_PQUOTA_ON(mp) && xfs_get_projid(ip) != fa->fsx_projid) { ASSERT(tp); - code = xfs_qm_vop_chown_reserve(tp, ip, udqp, gdqp, - capable(CAP_FOWNER) ? + code = xfs_qm_vop_chown_reserve(tp, ip, udqp, NULL, + pdqp, capable(CAP_FOWNER) ? XFS_QMOPT_FORCE_RES : 0); if (code) /* out of quota */ goto error_return; @@ -1113,7 +1113,7 @@ xfs_ioctl_setattr( if (xfs_get_projid(ip) != fa->fsx_projid) { if (XFS_IS_QUOTA_RUNNING(mp) && XFS_IS_PQUOTA_ON(mp)) { olddquot = xfs_qm_vop_chown(tp, ip, - &ip->i_gdquot, gdqp); + &ip->i_pdquot, pdqp); } xfs_set_projid(ip, fa->fsx_projid); @@ -1160,13 +1160,13 @@ xfs_ioctl_setattr( */ xfs_qm_dqrele(olddquot); xfs_qm_dqrele(udqp); - xfs_qm_dqrele(gdqp); + xfs_qm_dqrele(pdqp); return code; error_return: xfs_qm_dqrele(udqp); - xfs_qm_dqrele(gdqp); + xfs_qm_dqrele(pdqp); xfs_trans_cancel(tp, 0); if (lock_flags) xfs_iunlock(ip, lock_flags); diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c index 8865261e5417..96dda62d497b 100644 --- a/fs/xfs/xfs_iops.c +++ b/fs/xfs/xfs_iops.c @@ -539,7 +539,7 @@ xfs_setattr_nonsize( ASSERT(udqp == NULL); ASSERT(gdqp == NULL); error = xfs_qm_vop_dqalloc(ip, uid, gid, xfs_get_projid(ip), - qflags, &udqp, &gdqp); + qflags, &udqp, &gdqp, NULL); if (error) return error; } @@ -575,7 +575,7 @@ xfs_setattr_nonsize( (XFS_IS_GQUOTA_ON(mp) && igid != gid))) { ASSERT(tp); error = xfs_qm_vop_chown_reserve(tp, ip, udqp, gdqp, - capable(CAP_FOWNER) ? + NULL, capable(CAP_FOWNER) ? XFS_QMOPT_FORCE_RES : 0); if (error) /* out of quota */ goto out_trans_cancel; diff --git a/fs/xfs/xfs_qm.c b/fs/xfs/xfs_qm.c index 7a3e007b49f4..d320794d03ce 100644 --- a/fs/xfs/xfs_qm.c +++ b/fs/xfs/xfs_qm.c @@ -137,6 +137,7 @@ xfs_qm_dqpurge( struct xfs_mount *mp = dqp->q_mount; struct xfs_quotainfo *qi = mp->m_quotainfo; struct xfs_dquot *gdqp = NULL; + struct xfs_dquot *pdqp = NULL; xfs_dqlock(dqp); if ((dqp->dq_flags & XFS_DQ_FREEING) || dqp->q_nrefs != 0) { @@ -145,8 +146,7 @@ xfs_qm_dqpurge( } /* - * If this quota has a group hint attached, prepare for releasing it - * now. + * If this quota has a hint attached, prepare for releasing it now. */ gdqp = dqp->q_gdquot; if (gdqp) { @@ -154,6 +154,12 @@ xfs_qm_dqpurge( dqp->q_gdquot = NULL; } + pdqp = dqp->q_pdquot; + if (pdqp) { + xfs_dqlock(pdqp); + dqp->q_pdquot = NULL; + } + dqp->dq_flags |= XFS_DQ_FREEING; xfs_dqflock(dqp); @@ -208,6 +214,8 @@ xfs_qm_dqpurge( if (gdqp) xfs_qm_dqput(gdqp); + if (pdqp) + xfs_qm_dqput(pdqp); return 0; } @@ -364,6 +372,10 @@ xfs_qm_unmount_quotas( IRELE(mp->m_quotainfo->qi_gquotaip); mp->m_quotainfo->qi_gquotaip = NULL; } + if (mp->m_quotainfo->qi_pquotaip) { + IRELE(mp->m_quotainfo->qi_pquotaip); + mp->m_quotainfo->qi_pquotaip = NULL; + } } } @@ -410,7 +422,10 @@ xfs_qm_dqattach_one( * be reclaimed as long as we have a ref from inode and we * hold the ilock. */ - dqp = udqhint->q_gdquot; + if (type == XFS_DQ_GROUP) + dqp = udqhint->q_gdquot; + else + dqp = udqhint->q_pdquot; if (dqp && be32_to_cpu(dqp->q_core.d_id) == id) { ASSERT(*IO_idqpp == NULL); @@ -453,28 +468,42 @@ xfs_qm_dqattach_one( /* - * Given a udquot and gdquot, attach a ptr to the group dquot in the - * udquot as a hint for future lookups. + * Given a udquot and group/project type, attach the group/project + * dquot pointer to the udquot as a hint for future lookups. */ STATIC void -xfs_qm_dqattach_grouphint( - xfs_dquot_t *udq, - xfs_dquot_t *gdq) +xfs_qm_dqattach_hint( + struct xfs_inode *ip, + int type) { - xfs_dquot_t *tmp; + struct xfs_dquot **dqhintp; + struct xfs_dquot *dqp; + struct xfs_dquot *udq = ip->i_udquot; + + ASSERT(type == XFS_DQ_GROUP || type == XFS_DQ_PROJ); xfs_dqlock(udq); - tmp = udq->q_gdquot; - if (tmp) { - if (tmp == gdq) + if (type == XFS_DQ_GROUP) { + dqp = ip->i_gdquot; + dqhintp = &udq->q_gdquot; + } else { + dqp = ip->i_pdquot; + dqhintp = &udq->q_pdquot; + } + + if (*dqhintp) { + struct xfs_dquot *tmp; + + if (*dqhintp == dqp) goto done; - udq->q_gdquot = NULL; + tmp = *dqhintp; + *dqhintp = NULL; xfs_qm_dqrele(tmp); } - udq->q_gdquot = xfs_qm_dqhold(gdq); + *dqhintp = xfs_qm_dqhold(dqp); done: xfs_dqunlock(udq); } @@ -527,12 +556,8 @@ xfs_qm_dqattach_locked( } ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); - if (XFS_IS_OQUOTA_ON(mp)) { - error = XFS_IS_GQUOTA_ON(mp) ? - xfs_qm_dqattach_one(ip, ip->i_d.di_gid, XFS_DQ_GROUP, - flags & XFS_QMOPT_DQALLOC, - ip->i_udquot, &ip->i_gdquot) : - xfs_qm_dqattach_one(ip, xfs_get_projid(ip), XFS_DQ_PROJ, + if (XFS_IS_GQUOTA_ON(mp)) { + error = xfs_qm_dqattach_one(ip, ip->i_d.di_gid, XFS_DQ_GROUP, flags & XFS_QMOPT_DQALLOC, ip->i_udquot, &ip->i_gdquot); /* @@ -544,14 +569,28 @@ xfs_qm_dqattach_locked( nquotas++; } + ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); + if (XFS_IS_PQUOTA_ON(mp)) { + error = xfs_qm_dqattach_one(ip, xfs_get_projid(ip), XFS_DQ_PROJ, + flags & XFS_QMOPT_DQALLOC, + ip->i_udquot, &ip->i_pdquot); + /* + * Don't worry about the udquot that we may have + * attached above. It'll get detached, if not already. + */ + if (error) + goto done; + nquotas++; + } + /* - * Attach this group quota to the user quota as a hint. + * Attach this group/project quota to the user quota as a hint. * This WON'T, in general, result in a thrash. */ - if (nquotas == 2) { + if (nquotas > 1 && ip->i_udquot) { ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); - ASSERT(ip->i_udquot); - ASSERT(ip->i_gdquot); + ASSERT(ip->i_gdquot || !XFS_IS_GQUOTA_ON(mp)); + ASSERT(ip->i_pdquot || !XFS_IS_PQUOTA_ON(mp)); /* * We do not have i_udquot locked at this point, but this check @@ -560,7 +599,10 @@ xfs_qm_dqattach_locked( * succeed in general. */ if (ip->i_udquot->q_gdquot != ip->i_gdquot) - xfs_qm_dqattach_grouphint(ip->i_udquot, ip->i_gdquot); + xfs_qm_dqattach_hint(ip, XFS_DQ_GROUP); + + if (ip->i_udquot->q_pdquot != ip->i_pdquot) + xfs_qm_dqattach_hint(ip, XFS_DQ_PROJ); } done: @@ -568,8 +610,10 @@ xfs_qm_dqattach_locked( if (!error) { if (XFS_IS_UQUOTA_ON(mp)) ASSERT(ip->i_udquot); - if (XFS_IS_OQUOTA_ON(mp)) + if (XFS_IS_GQUOTA_ON(mp)) ASSERT(ip->i_gdquot); + if (XFS_IS_PQUOTA_ON(mp)) + ASSERT(ip->i_pdquot); } ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); #endif @@ -602,7 +646,7 @@ void xfs_qm_dqdetach( xfs_inode_t *ip) { - if (!(ip->i_udquot || ip->i_gdquot)) + if (!(ip->i_udquot || ip->i_gdquot || ip->i_pdquot)) return; trace_xfs_dquot_dqdetach(ip); @@ -616,6 +660,10 @@ xfs_qm_dqdetach( xfs_qm_dqrele(ip->i_gdquot); ip->i_gdquot = NULL; } + if (ip->i_pdquot) { + xfs_qm_dqrele(ip->i_pdquot); + ip->i_pdquot = NULL; + } } int @@ -660,6 +708,7 @@ xfs_qm_init_quotainfo( INIT_RADIX_TREE(&qinf->qi_uquota_tree, GFP_NOFS); INIT_RADIX_TREE(&qinf->qi_gquota_tree, GFP_NOFS); + INIT_RADIX_TREE(&qinf->qi_pquota_tree, GFP_NOFS); mutex_init(&qinf->qi_tree_lock); INIT_LIST_HEAD(&qinf->qi_lru_list); @@ -761,6 +810,10 @@ xfs_qm_destroy_quotainfo( IRELE(qi->qi_gquotaip); qi->qi_gquotaip = NULL; } + if (qi->qi_pquotaip) { + IRELE(qi->qi_pquotaip); + qi->qi_pquotaip = NULL; + } mutex_destroy(&qi->qi_quotaofflock); kmem_free(qi); mp->m_quotainfo = NULL; @@ -1269,13 +1322,14 @@ xfs_qm_quotacheck( LIST_HEAD (buffer_list); struct xfs_inode *uip = mp->m_quotainfo->qi_uquotaip; struct xfs_inode *gip = mp->m_quotainfo->qi_gquotaip; + struct xfs_inode *pip = mp->m_quotainfo->qi_pquotaip; count = INT_MAX; structsz = 1; lastino = 0; flags = 0; - ASSERT(uip || gip); + ASSERT(uip || gip || pip); ASSERT(XFS_IS_QUOTA_RUNNING(mp)); xfs_notice(mp, "Quotacheck needed: Please wait."); @@ -1294,13 +1348,19 @@ xfs_qm_quotacheck( } if (gip) { - error = xfs_qm_dqiterate(mp, gip, XFS_IS_GQUOTA_ON(mp) ? - XFS_QMOPT_GQUOTA : XFS_QMOPT_PQUOTA, + error = xfs_qm_dqiterate(mp, gip, XFS_QMOPT_GQUOTA, &buffer_list); if (error) goto error_return; - flags |= XFS_IS_GQUOTA_ON(mp) ? - XFS_GQUOTA_CHKD : XFS_PQUOTA_CHKD; + flags |= XFS_GQUOTA_CHKD; + } + + if (pip) { + error = xfs_qm_dqiterate(mp, pip, XFS_QMOPT_PQUOTA, + &buffer_list); + if (error) + goto error_return; + flags |= XFS_PQUOTA_CHKD; } do { @@ -1397,6 +1457,7 @@ xfs_qm_init_quotainos( { struct xfs_inode *uip = NULL; struct xfs_inode *gip = NULL; + struct xfs_inode *pip = NULL; int error; __int64_t sbflags = 0; uint flags = 0; @@ -1415,7 +1476,7 @@ xfs_qm_init_quotainos( if (error) return XFS_ERROR(error); } - if (XFS_IS_OQUOTA_ON(mp) && + if (XFS_IS_GQUOTA_ON(mp) && mp->m_sb.sb_gquotino != NULLFSINO) { ASSERT(mp->m_sb.sb_gquotino > 0); error = xfs_iget(mp, NULL, mp->m_sb.sb_gquotino, @@ -1423,6 +1484,15 @@ xfs_qm_init_quotainos( if (error) goto error_rele; } + /* XXX: Use gquotino for now */ + if (XFS_IS_PQUOTA_ON(mp) && + mp->m_sb.sb_gquotino != NULLFSINO) { + ASSERT(mp->m_sb.sb_gquotino > 0); + error = xfs_iget(mp, NULL, mp->m_sb.sb_gquotino, + 0, 0, &pip); + if (error) + goto error_rele; + } } else { flags |= XFS_QMOPT_SBVERSION; sbflags |= (XFS_SB_VERSIONNUM | XFS_SB_UQUOTINO | @@ -1430,7 +1500,7 @@ xfs_qm_init_quotainos( } /* - * Create the two inodes, if they don't exist already. The changes + * Create the three inodes, if they don't exist already. The changes * made above will get added to a transaction and logged in one of * the qino_alloc calls below. If the device is readonly, * temporarily switch to read-write to do this. @@ -1444,17 +1514,27 @@ xfs_qm_init_quotainos( flags &= ~XFS_QMOPT_SBVERSION; } - if (XFS_IS_OQUOTA_ON(mp) && gip == NULL) { - flags |= (XFS_IS_GQUOTA_ON(mp) ? - XFS_QMOPT_GQUOTA : XFS_QMOPT_PQUOTA); + if (XFS_IS_GQUOTA_ON(mp) && gip == NULL) { error = xfs_qm_qino_alloc(mp, &gip, - sbflags | XFS_SB_GQUOTINO, flags); + sbflags | XFS_SB_GQUOTINO, + flags | XFS_QMOPT_GQUOTA); + if (error) + goto error_rele; + + flags &= ~XFS_QMOPT_SBVERSION; + } + if (XFS_IS_PQUOTA_ON(mp) && pip == NULL) { + /* XXX: Use XFS_SB_GQUOTINO for now */ + error = xfs_qm_qino_alloc(mp, &pip, + sbflags | XFS_SB_GQUOTINO, + flags | XFS_QMOPT_PQUOTA); if (error) goto error_rele; } mp->m_quotainfo->qi_uquotaip = uip; mp->m_quotainfo->qi_gquotaip = gip; + mp->m_quotainfo->qi_pquotaip = pip; return 0; @@ -1463,6 +1543,8 @@ error_rele: IRELE(uip); if (gip) IRELE(gip); + if (pip) + IRELE(pip); return XFS_ERROR(error); } @@ -1657,11 +1739,13 @@ xfs_qm_vop_dqalloc( prid_t prid, uint flags, struct xfs_dquot **O_udqpp, - struct xfs_dquot **O_gdqpp) + struct xfs_dquot **O_gdqpp, + struct xfs_dquot **O_pdqpp) { struct xfs_mount *mp = ip->i_mount; struct xfs_dquot *uq = NULL; struct xfs_dquot *gq = NULL; + struct xfs_dquot *pq = NULL; int error; uint lockflags; @@ -1741,24 +1825,25 @@ xfs_qm_vop_dqalloc( ASSERT(ip->i_gdquot); gq = xfs_qm_dqhold(ip->i_gdquot); } - } else if ((flags & XFS_QMOPT_PQUOTA) && XFS_IS_PQUOTA_ON(mp)) { + } + if ((flags & XFS_QMOPT_PQUOTA) && XFS_IS_PQUOTA_ON(mp)) { if (xfs_get_projid(ip) != prid) { xfs_iunlock(ip, lockflags); error = xfs_qm_dqget(mp, NULL, (xfs_dqid_t)prid, XFS_DQ_PROJ, XFS_QMOPT_DQALLOC | XFS_QMOPT_DOWARN, - &gq); + &pq); if (error) { ASSERT(error != ENOENT); goto error_rele; } - xfs_dqunlock(gq); + xfs_dqunlock(pq); lockflags = XFS_ILOCK_SHARED; xfs_ilock(ip, lockflags); } else { - ASSERT(ip->i_gdquot); - gq = xfs_qm_dqhold(ip->i_gdquot); + ASSERT(ip->i_pdquot); + pq = xfs_qm_dqhold(ip->i_pdquot); } } if (uq) @@ -1773,9 +1858,15 @@ xfs_qm_vop_dqalloc( *O_gdqpp = gq; else if (gq) xfs_qm_dqrele(gq); + if (O_pdqpp) + *O_pdqpp = pq; + else if (pq) + xfs_qm_dqrele(pq); return 0; error_rele: + if (gq) + xfs_qm_dqrele(gq); if (uq) xfs_qm_dqrele(uq); return error; @@ -1830,14 +1921,17 @@ xfs_qm_vop_chown_reserve( struct xfs_inode *ip, struct xfs_dquot *udqp, struct xfs_dquot *gdqp, + struct xfs_dquot *pdqp, uint flags) { struct xfs_mount *mp = ip->i_mount; uint delblks, blkflags, prjflags = 0; struct xfs_dquot *udq_unres = NULL; struct xfs_dquot *gdq_unres = NULL; + struct xfs_dquot *pdq_unres = NULL; struct xfs_dquot *udq_delblks = NULL; struct xfs_dquot *gdq_delblks = NULL; + struct xfs_dquot *pdq_delblks = NULL; int error; @@ -1861,24 +1955,28 @@ xfs_qm_vop_chown_reserve( udq_unres = ip->i_udquot; } } - if (XFS_IS_OQUOTA_ON(ip->i_mount) && gdqp) { - if (XFS_IS_PQUOTA_ON(ip->i_mount) && - xfs_get_projid(ip) != be32_to_cpu(gdqp->q_core.d_id)) - prjflags = XFS_QMOPT_ENOSPC; + if (XFS_IS_GQUOTA_ON(ip->i_mount) && gdqp && + ip->i_d.di_gid != be32_to_cpu(gdqp->q_core.d_id)) { + gdq_delblks = gdqp; + if (delblks) { + ASSERT(ip->i_gdquot); + gdq_unres = ip->i_gdquot; + } + } - if (prjflags || - (XFS_IS_GQUOTA_ON(ip->i_mount) && - ip->i_d.di_gid != be32_to_cpu(gdqp->q_core.d_id))) { - gdq_delblks = gdqp; - if (delblks) { - ASSERT(ip->i_gdquot); - gdq_unres = ip->i_gdquot; - } + if (XFS_IS_PQUOTA_ON(ip->i_mount) && pdqp && + xfs_get_projid(ip) != be32_to_cpu(pdqp->q_core.d_id)) { + prjflags = XFS_QMOPT_ENOSPC; + pdq_delblks = pdqp; + if (delblks) { + ASSERT(ip->i_pdquot); + pdq_unres = ip->i_pdquot; } } error = xfs_trans_reserve_quota_bydquots(tp, ip->i_mount, - udq_delblks, gdq_delblks, ip->i_d.di_nblocks, 1, + udq_delblks, gdq_delblks, pdq_delblks, + ip->i_d.di_nblocks, 1, flags | blkflags | prjflags); if (error) return error; @@ -1893,16 +1991,17 @@ xfs_qm_vop_chown_reserve( /* * Do the reservations first. Unreservation can't fail. */ - ASSERT(udq_delblks || gdq_delblks); - ASSERT(udq_unres || gdq_unres); + ASSERT(udq_delblks || gdq_delblks || pdq_delblks); + ASSERT(udq_unres || gdq_unres || pdq_unres); error = xfs_trans_reserve_quota_bydquots(NULL, ip->i_mount, - udq_delblks, gdq_delblks, (xfs_qcnt_t)delblks, 0, + udq_delblks, gdq_delblks, pdq_delblks, + (xfs_qcnt_t)delblks, 0, flags | blkflags | prjflags); if (error) return error; xfs_trans_reserve_quota_bydquots(NULL, ip->i_mount, - udq_unres, gdq_unres, -((xfs_qcnt_t)delblks), 0, - blkflags); + udq_unres, gdq_unres, pdq_unres, + -((xfs_qcnt_t)delblks), 0, blkflags); } return (0); @@ -1941,7 +2040,8 @@ xfs_qm_vop_create_dqattach( struct xfs_trans *tp, struct xfs_inode *ip, struct xfs_dquot *udqp, - struct xfs_dquot *gdqp) + struct xfs_dquot *gdqp, + struct xfs_dquot *pdqp) { struct xfs_mount *mp = tp->t_mountp; @@ -1961,13 +2061,18 @@ xfs_qm_vop_create_dqattach( } if (gdqp) { ASSERT(ip->i_gdquot == NULL); - ASSERT(XFS_IS_OQUOTA_ON(mp)); - ASSERT((XFS_IS_GQUOTA_ON(mp) ? - ip->i_d.di_gid : xfs_get_projid(ip)) == - be32_to_cpu(gdqp->q_core.d_id)); - + ASSERT(XFS_IS_GQUOTA_ON(mp)); + ASSERT(ip->i_d.di_gid == be32_to_cpu(gdqp->q_core.d_id)); ip->i_gdquot = xfs_qm_dqhold(gdqp); xfs_trans_mod_dquot(tp, gdqp, XFS_TRANS_DQ_ICOUNT, 1); } + if (pdqp) { + ASSERT(ip->i_pdquot == NULL); + ASSERT(XFS_IS_PQUOTA_ON(mp)); + ASSERT(xfs_get_projid(ip) == be32_to_cpu(pdqp->q_core.d_id)); + + ip->i_pdquot = xfs_qm_dqhold(pdqp); + xfs_trans_mod_dquot(tp, pdqp, XFS_TRANS_DQ_ICOUNT, 1); + } } diff --git a/fs/xfs/xfs_qm.h b/fs/xfs/xfs_qm.h index bdb4f8b95207..579d6a02a5b6 100644 --- a/fs/xfs/xfs_qm.h +++ b/fs/xfs/xfs_qm.h @@ -44,9 +44,11 @@ extern struct kmem_zone *xfs_qm_dqtrxzone; typedef struct xfs_quotainfo { struct radix_tree_root qi_uquota_tree; struct radix_tree_root qi_gquota_tree; + struct radix_tree_root qi_pquota_tree; struct mutex qi_tree_lock; - xfs_inode_t *qi_uquotaip; /* user quota inode */ - xfs_inode_t *qi_gquotaip; /* group quota inode */ + struct xfs_inode *qi_uquotaip; /* user quota inode */ + struct xfs_inode *qi_gquotaip; /* group quota inode */ + struct xfs_inode *qi_pquotaip; /* project quota inode */ struct list_head qi_lru_list; struct mutex qi_lru_lock; int qi_lru_count; @@ -78,8 +80,9 @@ xfs_dquot_tree( case XFS_DQ_USER: return &qi->qi_uquota_tree; case XFS_DQ_GROUP: - case XFS_DQ_PROJ: return &qi->qi_gquota_tree; + case XFS_DQ_PROJ: + return &qi->qi_pquota_tree; default: ASSERT(0); } @@ -93,8 +96,9 @@ xfs_dq_to_quota_inode(struct xfs_dquot *dqp) case XFS_DQ_USER: return dqp->q_mount->m_quotainfo->qi_uquotaip; case XFS_DQ_GROUP: - case XFS_DQ_PROJ: return dqp->q_mount->m_quotainfo->qi_gquotaip; + case XFS_DQ_PROJ: + return dqp->q_mount->m_quotainfo->qi_pquotaip; default: ASSERT(0); } @@ -107,18 +111,20 @@ extern void xfs_trans_mod_dquot(struct xfs_trans *, struct xfs_dquot *, uint, long); extern int xfs_trans_reserve_quota_bydquots(struct xfs_trans *, struct xfs_mount *, struct xfs_dquot *, - struct xfs_dquot *, long, long, uint); + struct xfs_dquot *, struct xfs_dquot *, + long, long, uint); extern void xfs_trans_dqjoin(struct xfs_trans *, struct xfs_dquot *); extern void xfs_trans_log_dquot(struct xfs_trans *, struct xfs_dquot *); /* - * We keep the usr and grp dquots separately so that locking will be easier - * to do at commit time. All transactions that we know of at this point + * We keep the usr, grp, and prj dquots separately so that locking will be + * easier to do at commit time. All transactions that we know of at this point * affect no more than two dquots of one type. Hence, the TRANS_MAXDQS value. */ enum { XFS_QM_TRANS_USR = 0, XFS_QM_TRANS_GRP, + XFS_QM_TRANS_PRJ, XFS_QM_TRANS_DQTYPES }; #define XFS_QM_TRANS_MAXDQS 2 diff --git a/fs/xfs/xfs_qm_bhv.c b/fs/xfs/xfs_qm_bhv.c index 2d02eac1c9a8..437a52d91f6d 100644 --- a/fs/xfs/xfs_qm_bhv.c +++ b/fs/xfs/xfs_qm_bhv.c @@ -112,16 +112,16 @@ xfs_qm_newmount( if (((uquotaondisk && !XFS_IS_UQUOTA_ON(mp)) || (!uquotaondisk && XFS_IS_UQUOTA_ON(mp)) || - (pquotaondisk && !XFS_IS_PQUOTA_ON(mp)) || - (!pquotaondisk && XFS_IS_PQUOTA_ON(mp)) || (gquotaondisk && !XFS_IS_GQUOTA_ON(mp)) || - (!gquotaondisk && XFS_IS_OQUOTA_ON(mp))) && + (!gquotaondisk && XFS_IS_GQUOTA_ON(mp)) || + (pquotaondisk && !XFS_IS_PQUOTA_ON(mp)) || + (!pquotaondisk && XFS_IS_PQUOTA_ON(mp))) && xfs_dev_is_read_only(mp, "changing quota state")) { xfs_warn(mp, "please mount with%s%s%s%s.", (!quotaondisk ? "out quota" : ""), (uquotaondisk ? " usrquota" : ""), - (pquotaondisk ? " prjquota" : ""), - (gquotaondisk ? " grpquota" : "")); + (gquotaondisk ? " grpquota" : ""), + (pquotaondisk ? " prjquota" : "")); return XFS_ERROR(EPERM); } diff --git a/fs/xfs/xfs_qm_syscalls.c b/fs/xfs/xfs_qm_syscalls.c index a08801ae24e2..b9363838b42b 100644 --- a/fs/xfs/xfs_qm_syscalls.c +++ b/fs/xfs/xfs_qm_syscalls.c @@ -119,7 +119,8 @@ xfs_qm_scall_quotaoff( dqtype |= XFS_QMOPT_GQUOTA; flags |= (XFS_GQUOTA_CHKD | XFS_GQUOTA_ENFD); inactivate_flags |= XFS_GQUOTA_ACTIVE; - } else if (flags & XFS_PQUOTA_ACCT) { + } + if (flags & XFS_PQUOTA_ACCT) { dqtype |= XFS_QMOPT_PQUOTA; flags |= (XFS_PQUOTA_CHKD | XFS_PQUOTA_ENFD); inactivate_flags |= XFS_PQUOTA_ACTIVE; @@ -214,10 +215,14 @@ xfs_qm_scall_quotaoff( IRELE(q->qi_uquotaip); q->qi_uquotaip = NULL; } - if ((dqtype & (XFS_QMOPT_GQUOTA|XFS_QMOPT_PQUOTA)) && q->qi_gquotaip) { + if ((dqtype & XFS_QMOPT_GQUOTA) && q->qi_gquotaip) { IRELE(q->qi_gquotaip); q->qi_gquotaip = NULL; } + if ((dqtype & XFS_QMOPT_PQUOTA) && q->qi_pquotaip) { + IRELE(q->qi_pquotaip); + q->qi_pquotaip = NULL; + } out_unlock: mutex_unlock(&q->qi_quotaofflock); @@ -859,9 +864,11 @@ xfs_dqrele_inode( { /* skip quota inodes */ if (ip == ip->i_mount->m_quotainfo->qi_uquotaip || - ip == ip->i_mount->m_quotainfo->qi_gquotaip) { + ip == ip->i_mount->m_quotainfo->qi_gquotaip || + ip == ip->i_mount->m_quotainfo->qi_pquotaip) { ASSERT(ip->i_udquot == NULL); ASSERT(ip->i_gdquot == NULL); + ASSERT(ip->i_pdquot == NULL); return 0; } @@ -870,10 +877,14 @@ xfs_dqrele_inode( xfs_qm_dqrele(ip->i_udquot); ip->i_udquot = NULL; } - if (flags & (XFS_PQUOTA_ACCT|XFS_GQUOTA_ACCT) && ip->i_gdquot) { + if ((flags & XFS_GQUOTA_ACCT) && ip->i_gdquot) { xfs_qm_dqrele(ip->i_gdquot); ip->i_gdquot = NULL; } + if ((flags & XFS_PQUOTA_ACCT) && ip->i_pdquot) { + xfs_qm_dqrele(ip->i_pdquot); + ip->i_pdquot = NULL; + } xfs_iunlock(ip, XFS_ILOCK_EXCL); return 0; } diff --git a/fs/xfs/xfs_quota.h b/fs/xfs/xfs_quota.h index 40d508be9a00..09777c41d5b7 100644 --- a/fs/xfs/xfs_quota.h +++ b/fs/xfs/xfs_quota.h @@ -288,10 +288,10 @@ typedef struct xfs_qoff_logformat { * we didn't have the inode locked, the appropriate dquot(s) will be * attached atomically. */ -#define XFS_NOT_DQATTACHED(mp, ip) ((XFS_IS_UQUOTA_ON(mp) &&\ - (ip)->i_udquot == NULL) || \ - (XFS_IS_OQUOTA_ON(mp) && \ - (ip)->i_gdquot == NULL)) +#define XFS_NOT_DQATTACHED(mp, ip) \ + ((XFS_IS_UQUOTA_ON(mp) && (ip)->i_udquot == NULL) || \ + (XFS_IS_GQUOTA_ON(mp) && (ip)->i_gdquot == NULL) || \ + (XFS_IS_PQUOTA_ON(mp) && (ip)->i_pdquot == NULL)) #define XFS_QM_NEED_QUOTACHECK(mp) \ ((XFS_IS_UQUOTA_ON(mp) && \ @@ -346,17 +346,18 @@ extern int xfs_trans_reserve_quota_nblks(struct xfs_trans *, struct xfs_inode *, long, long, uint); extern int xfs_trans_reserve_quota_bydquots(struct xfs_trans *, struct xfs_mount *, struct xfs_dquot *, - struct xfs_dquot *, long, long, uint); + struct xfs_dquot *, struct xfs_dquot *, long, long, uint); extern int xfs_qm_vop_dqalloc(struct xfs_inode *, uid_t, gid_t, prid_t, uint, - struct xfs_dquot **, struct xfs_dquot **); + struct xfs_dquot **, struct xfs_dquot **, struct xfs_dquot **); extern void xfs_qm_vop_create_dqattach(struct xfs_trans *, struct xfs_inode *, - struct xfs_dquot *, struct xfs_dquot *); + struct xfs_dquot *, struct xfs_dquot *, struct xfs_dquot *); extern int xfs_qm_vop_rename_dqattach(struct xfs_inode **); extern struct xfs_dquot *xfs_qm_vop_chown(struct xfs_trans *, struct xfs_inode *, struct xfs_dquot **, struct xfs_dquot *); extern int xfs_qm_vop_chown_reserve(struct xfs_trans *, struct xfs_inode *, - struct xfs_dquot *, struct xfs_dquot *, uint); + struct xfs_dquot *, struct xfs_dquot *, + struct xfs_dquot *, uint); extern int xfs_qm_dqattach(struct xfs_inode *, uint); extern int xfs_qm_dqattach_locked(struct xfs_inode *, uint); extern void xfs_qm_dqdetach(struct xfs_inode *); @@ -370,10 +371,12 @@ extern void xfs_qm_unmount_quotas(struct xfs_mount *); #else static inline int xfs_qm_vop_dqalloc(struct xfs_inode *ip, uid_t uid, gid_t gid, prid_t prid, - uint flags, struct xfs_dquot **udqp, struct xfs_dquot **gdqp) + uint flags, struct xfs_dquot **udqp, struct xfs_dquot **gdqp, + struct xfs_dquot **pdqp) { *udqp = NULL; *gdqp = NULL; + *pdqp = NULL; return 0; } #define xfs_trans_dup_dqinfo(tp, tp2) @@ -388,14 +391,15 @@ static inline int xfs_trans_reserve_quota_nblks(struct xfs_trans *tp, } static inline int xfs_trans_reserve_quota_bydquots(struct xfs_trans *tp, struct xfs_mount *mp, struct xfs_dquot *udqp, - struct xfs_dquot *gdqp, long nblks, long nions, uint flags) + struct xfs_dquot *gdqp, struct xfs_dquot *pdqp, + long nblks, long nions, uint flags) { return 0; } -#define xfs_qm_vop_create_dqattach(tp, ip, u, g) +#define xfs_qm_vop_create_dqattach(tp, ip, u, g, p) #define xfs_qm_vop_rename_dqattach(it) (0) #define xfs_qm_vop_chown(tp, ip, old, new) (NULL) -#define xfs_qm_vop_chown_reserve(tp, ip, u, g, fl) (0) +#define xfs_qm_vop_chown_reserve(tp, ip, u, g, p, fl) (0) #define xfs_qm_dqattach(ip, fl) (0) #define xfs_qm_dqattach_locked(ip, fl) (0) #define xfs_qm_dqdetach(ip) @@ -409,8 +413,8 @@ static inline int xfs_trans_reserve_quota_bydquots(struct xfs_trans *tp, #define xfs_trans_unreserve_quota_nblks(tp, ip, nblks, ninos, flags) \ xfs_trans_reserve_quota_nblks(tp, ip, -(nblks), -(ninos), flags) -#define xfs_trans_reserve_quota(tp, mp, ud, gd, nb, ni, f) \ - xfs_trans_reserve_quota_bydquots(tp, mp, ud, gd, nb, ni, \ +#define xfs_trans_reserve_quota(tp, mp, ud, gd, pd, nb, ni, f) \ + xfs_trans_reserve_quota_bydquots(tp, mp, ud, gd, pd, nb, ni, \ f | XFS_QMOPT_RES_REGBLKS) extern int xfs_qm_dqcheck(struct xfs_mount *, xfs_disk_dquot_t *, diff --git a/fs/xfs/xfs_symlink.c b/fs/xfs/xfs_symlink.c index e830fb56e27f..f4895b662fcb 100644 --- a/fs/xfs/xfs_symlink.c +++ b/fs/xfs/xfs_symlink.c @@ -360,6 +360,7 @@ xfs_symlink( prid_t prid; struct xfs_dquot *udqp = NULL; struct xfs_dquot *gdqp = NULL; + struct xfs_dquot *pdqp = NULL; uint resblks; *ipp = NULL; @@ -386,7 +387,7 @@ xfs_symlink( * Make sure that we have allocated dquot(s) on disk. */ error = xfs_qm_vop_dqalloc(dp, current_fsuid(), current_fsgid(), prid, - XFS_QMOPT_QUOTALL | XFS_QMOPT_INHERIT, &udqp, &gdqp); + XFS_QMOPT_QUOTALL | XFS_QMOPT_INHERIT, &udqp, &gdqp, &pdqp); if (error) goto std_return; @@ -427,7 +428,8 @@ xfs_symlink( /* * Reserve disk quota : blocks and inode. */ - error = xfs_trans_reserve_quota(tp, mp, udqp, gdqp, resblks, 1, 0); + error = xfs_trans_reserve_quota(tp, mp, udqp, gdqp, + pdqp, resblks, 1, 0); if (error) goto error_return; @@ -465,7 +467,7 @@ xfs_symlink( /* * Also attach the dquot(s) to it, if applicable. */ - xfs_qm_vop_create_dqattach(tp, ip, udqp, gdqp); + xfs_qm_vop_create_dqattach(tp, ip, udqp, gdqp, pdqp); if (resblks) resblks -= XFS_IALLOC_SPACE_RES(mp); @@ -563,6 +565,7 @@ xfs_symlink( error = xfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES); xfs_qm_dqrele(udqp); xfs_qm_dqrele(gdqp); + xfs_qm_dqrele(pdqp); *ipp = ip; return 0; @@ -576,6 +579,7 @@ xfs_symlink( xfs_trans_cancel(tp, cancel_flags); xfs_qm_dqrele(udqp); xfs_qm_dqrele(gdqp); + xfs_qm_dqrele(pdqp); if (unlock_dp_on_error) xfs_iunlock(dp, XFS_ILOCK_EXCL); diff --git a/fs/xfs/xfs_trans_dquot.c b/fs/xfs/xfs_trans_dquot.c index db041a5e1f6d..61407a847b86 100644 --- a/fs/xfs/xfs_trans_dquot.c +++ b/fs/xfs/xfs_trans_dquot.c @@ -163,8 +163,10 @@ xfs_trans_mod_dquot_byino( if (XFS_IS_UQUOTA_ON(mp) && ip->i_udquot) (void) xfs_trans_mod_dquot(tp, ip->i_udquot, field, delta); - if (XFS_IS_OQUOTA_ON(mp) && ip->i_gdquot) + if (XFS_IS_GQUOTA_ON(mp) && ip->i_gdquot) (void) xfs_trans_mod_dquot(tp, ip->i_gdquot, field, delta); + if (XFS_IS_PQUOTA_ON(mp) && ip->i_pdquot) + (void) xfs_trans_mod_dquot(tp, ip->i_pdquot, field, delta); } STATIC struct xfs_dqtrx * @@ -177,8 +179,12 @@ xfs_trans_get_dqtrx( if (XFS_QM_ISUDQ(dqp)) qa = tp->t_dqinfo->dqs[XFS_QM_TRANS_USR]; - else + else if (XFS_QM_ISGDQ(dqp)) qa = tp->t_dqinfo->dqs[XFS_QM_TRANS_GRP]; + else if (XFS_QM_ISPDQ(dqp)) + qa = tp->t_dqinfo->dqs[XFS_QM_TRANS_PRJ]; + else + return NULL; for (i = 0; i < XFS_QM_TRANS_MAXDQS; i++) { if (qa[i].qt_dquot == NULL || @@ -727,8 +733,8 @@ error_return: /* * Given dquot(s), make disk block and/or inode reservations against them. - * The fact that this does the reservation against both the usr and - * grp/prj quotas is important, because this follows a both-or-nothing + * The fact that this does the reservation against user, group and + * project quotas is important, because this follows a all-or-nothing * approach. * * flags = XFS_QMOPT_FORCE_RES evades limit enforcement. Used by chown. @@ -743,6 +749,7 @@ xfs_trans_reserve_quota_bydquots( struct xfs_mount *mp, struct xfs_dquot *udqp, struct xfs_dquot *gdqp, + struct xfs_dquot *pdqp, long nblks, long ninos, uint flags) @@ -770,11 +777,21 @@ xfs_trans_reserve_quota_bydquots( goto unwind_usr; } + if (pdqp) { + error = xfs_trans_dqresv(tp, mp, pdqp, nblks, ninos, flags); + if (error) + goto unwind_grp; + } + /* * Didn't change anything critical, so, no need to log */ return 0; +unwind_grp: + flags |= XFS_QMOPT_FORCE_RES; + if (gdqp) + xfs_trans_dqresv(tp, mp, gdqp, -nblks, -ninos, flags); unwind_usr: flags |= XFS_QMOPT_FORCE_RES; if (udqp) @@ -816,6 +833,7 @@ xfs_trans_reserve_quota_nblks( */ return xfs_trans_reserve_quota_bydquots(tp, mp, ip->i_udquot, ip->i_gdquot, + ip->i_pdquot, nblks, ninos, flags); } diff --git a/fs/xfs/xfs_vnodeops.c b/fs/xfs/xfs_vnodeops.c index 42c0ef288aeb..dc730ac272be 100644 --- a/fs/xfs/xfs_vnodeops.c +++ b/fs/xfs/xfs_vnodeops.c @@ -489,6 +489,7 @@ xfs_create( prid_t prid; struct xfs_dquot *udqp = NULL; struct xfs_dquot *gdqp = NULL; + struct xfs_dquot *pdqp = NULL; uint resblks; uint log_res; uint log_count; @@ -507,7 +508,8 @@ xfs_create( * Make sure that we have allocated dquot(s) on disk. */ error = xfs_qm_vop_dqalloc(dp, current_fsuid(), current_fsgid(), prid, - XFS_QMOPT_QUOTALL | XFS_QMOPT_INHERIT, &udqp, &gdqp); + XFS_QMOPT_QUOTALL | XFS_QMOPT_INHERIT, + &udqp, &gdqp, &pdqp); if (error) return error; @@ -559,7 +561,8 @@ xfs_create( /* * Reserve disk quota and the inode. */ - error = xfs_trans_reserve_quota(tp, mp, udqp, gdqp, resblks, 1, 0); + error = xfs_trans_reserve_quota(tp, mp, udqp, gdqp, + pdqp, resblks, 1, 0); if (error) goto out_trans_cancel; @@ -623,7 +626,7 @@ xfs_create( * These ids of the inode couldn't have changed since the new * inode has been locked ever since it was created. */ - xfs_qm_vop_create_dqattach(tp, ip, udqp, gdqp); + xfs_qm_vop_create_dqattach(tp, ip, udqp, gdqp, pdqp); error = xfs_bmap_finish(&tp, &free_list, &committed); if (error) @@ -635,6 +638,7 @@ xfs_create( xfs_qm_dqrele(udqp); xfs_qm_dqrele(gdqp); + xfs_qm_dqrele(pdqp); *ipp = ip; return 0; @@ -656,6 +660,7 @@ xfs_create( xfs_qm_dqrele(udqp); xfs_qm_dqrele(gdqp); + xfs_qm_dqrele(pdqp); if (unlock_dp_on_error) xfs_iunlock(dp, XFS_ILOCK_EXCL); @@ -1568,7 +1573,7 @@ xfs_free_file_space( } xfs_ilock(ip, XFS_ILOCK_EXCL); error = xfs_trans_reserve_quota(tp, mp, - ip->i_udquot, ip->i_gdquot, + ip->i_udquot, ip->i_gdquot, ip->i_pdquot, resblks, 0, XFS_QMOPT_RES_REGBLKS); if (error) goto error1; From f6becf0b2ffef0bed813d7f910b5d276c5dc45e1 Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Thu, 11 Jul 2013 14:35:43 +0200 Subject: [PATCH 0773/1048] ASoC: omap-pcm: Request the DMA channel differently when DT is involved When booting with DT the platform_get_resource_byname() is not available to get the DMA resource. In this case the DAI drivers will set the filter_data to the name of the DMA and omap-pcm can use this to request the DMA channel. Signed-off-by: Peter Ujfalusi Reviewed-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/omap/omap-pcm.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/sound/soc/omap/omap-pcm.c b/sound/soc/omap/omap-pcm.c index c28e042f2208..a11405de86e8 100644 --- a/sound/soc/omap/omap-pcm.c +++ b/sound/soc/omap/omap-pcm.c @@ -113,14 +113,25 @@ static int omap_pcm_open(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_dmaengine_dai_dma_data *dma_data; + int ret; snd_soc_set_runtime_hwparams(substream, &omap_pcm_hardware); dma_data = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream); - return snd_dmaengine_pcm_open_request_chan(substream, - omap_dma_filter_fn, - dma_data->filter_data); + /* DT boot: filter_data is the DMA name */ + if (rtd->cpu_dai->dev->of_node) { + struct dma_chan *chan; + + chan = dma_request_slave_channel(rtd->cpu_dai->dev, + dma_data->filter_data); + ret = snd_dmaengine_pcm_open(substream, chan); + } else { + ret = snd_dmaengine_pcm_open_request_chan(substream, + omap_dma_filter_fn, + dma_data->filter_data); + } + return ret; } static int omap_pcm_mmap(struct snd_pcm_substream *substream, From a8035f073cb508a0c1223db2662510575627b41d Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Thu, 11 Jul 2013 14:35:44 +0200 Subject: [PATCH 0774/1048] ASoC: omap-mcpdm: Do not use platform_get_resource_byname() for DMA The DMA resource no longer available via this API when booting with DT. McPDM is only available on OMAP4/5 and both can boot with DT only. Set the dma_data.filter_data to the DMA name which will be used by omap-pcm to request the DMA channel. Signed-off-by: Peter Ujfalusi Reviewed-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/omap/omap-mcpdm.c | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/sound/soc/omap/omap-mcpdm.c b/sound/soc/omap/omap-mcpdm.c index eb05c7ed6d05..a49dc52f8abc 100644 --- a/sound/soc/omap/omap-mcpdm.c +++ b/sound/soc/omap/omap-mcpdm.c @@ -66,7 +66,6 @@ struct omap_mcpdm { bool restart; struct snd_dmaengine_dai_dma_data dma_data[2]; - unsigned int dma_req[2]; }; /* @@ -477,19 +476,8 @@ static int asoc_mcpdm_probe(struct platform_device *pdev) mcpdm->dma_data[0].addr = res->start + MCPDM_REG_DN_DATA; mcpdm->dma_data[1].addr = res->start + MCPDM_REG_UP_DATA; - res = platform_get_resource_byname(pdev, IORESOURCE_DMA, "dn_link"); - if (!res) - return -ENODEV; - - mcpdm->dma_req[0] = res->start; - mcpdm->dma_data[0].filter_data = &mcpdm->dma_req[0]; - - res = platform_get_resource_byname(pdev, IORESOURCE_DMA, "up_link"); - if (!res) - return -ENODEV; - - mcpdm->dma_req[1] = res->start; - mcpdm->dma_data[1].filter_data = &mcpdm->dma_req[1]; + mcpdm->dma_data[0].filter_data = "dn_link"; + mcpdm->dma_data[1].filter_data = "up_link"; res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "mpu"); if (res == NULL) From 2ebef44789223389708505e33c67d44e9f999d4a Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Thu, 11 Jul 2013 14:35:45 +0200 Subject: [PATCH 0775/1048] ASoC: omap-dmic: Do not use platform_get_resource_byname() for DMA The DMA resource no longer available via this API when booting with DT. DMIC is only available on OMAP4/5 and both can boot with DT only. Set the dma_data.filter_data to the DMA name which will be used by omap-pcm to request the DMA channel. Signed-off-by: Peter Ujfalusi Reviewed-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/omap/omap-dmic.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/sound/soc/omap/omap-dmic.c b/sound/soc/omap/omap-dmic.c index 2ad0370146fd..4db1f8e6e172 100644 --- a/sound/soc/omap/omap-dmic.c +++ b/sound/soc/omap/omap-dmic.c @@ -57,7 +57,6 @@ struct omap_dmic { struct mutex mutex; struct snd_dmaengine_dai_dma_data dma_data; - unsigned int dma_req; }; static inline void omap_dmic_write(struct omap_dmic *dmic, u16 reg, u32 val) @@ -478,15 +477,7 @@ static int asoc_dmic_probe(struct platform_device *pdev) } dmic->dma_data.addr = res->start + OMAP_DMIC_DATA_REG; - res = platform_get_resource(pdev, IORESOURCE_DMA, 0); - if (!res) { - dev_err(dmic->dev, "invalid dma resource\n"); - ret = -ENODEV; - goto err_put_clk; - } - - dmic->dma_req = res->start; - dmic->dma_data.filter_data = &dmic->dma_req; + dmic->dma_data.filter_data = "up_link"; res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "mpu"); if (!res) { From 9ab1fac4829b3da0ba4d3f44d95d3e8ad13e6629 Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Thu, 11 Jul 2013 14:35:46 +0200 Subject: [PATCH 0776/1048] ASoC: omap-mcbsp: Use different method for DMA request when booted with DT The DMA resource no longer available via this API when booting with DT. When the board is booted with DT do not use platform_get_resource_byname(), instead set the dma_data.filter_data to the name of the DMA channel and omap-pcm can use this name to request the DMA channel. Signed-off-by: Peter Ujfalusi Reviewed-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/omap/mcbsp.c | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/sound/soc/omap/mcbsp.c b/sound/soc/omap/mcbsp.c index eb68c7db1cf3..361e4c03646e 100644 --- a/sound/soc/omap/mcbsp.c +++ b/sound/soc/omap/mcbsp.c @@ -1012,28 +1012,33 @@ int omap_mcbsp_init(struct platform_device *pdev) } } - res = platform_get_resource_byname(pdev, IORESOURCE_DMA, "rx"); - if (!res) { - dev_err(&pdev->dev, "invalid rx DMA channel\n"); - return -ENODEV; - } - /* RX DMA request number, and port address configuration */ - mcbsp->dma_req[1] = res->start; - mcbsp->dma_data[1].filter_data = &mcbsp->dma_req[1]; - mcbsp->dma_data[1].addr = omap_mcbsp_dma_reg_params(mcbsp, 1); - mcbsp->dma_data[1].maxburst = 4; + if (!pdev->dev.of_node) { + res = platform_get_resource_byname(pdev, IORESOURCE_DMA, "tx"); + if (!res) { + dev_err(&pdev->dev, "invalid tx DMA channel\n"); + return -ENODEV; + } + mcbsp->dma_req[0] = res->start; + mcbsp->dma_data[0].filter_data = &mcbsp->dma_req[0]; - res = platform_get_resource_byname(pdev, IORESOURCE_DMA, "tx"); - if (!res) { - dev_err(&pdev->dev, "invalid tx DMA channel\n"); - return -ENODEV; + res = platform_get_resource_byname(pdev, IORESOURCE_DMA, "rx"); + if (!res) { + dev_err(&pdev->dev, "invalid rx DMA channel\n"); + return -ENODEV; + } + mcbsp->dma_req[1] = res->start; + mcbsp->dma_data[1].filter_data = &mcbsp->dma_req[1]; + } else { + mcbsp->dma_data[0].filter_data = "tx"; + mcbsp->dma_data[1].filter_data = "rx"; } - /* TX DMA request number, and port address configuration */ - mcbsp->dma_req[0] = res->start; - mcbsp->dma_data[0].filter_data = &mcbsp->dma_req[0]; + mcbsp->dma_data[0].addr = omap_mcbsp_dma_reg_params(mcbsp, 0); mcbsp->dma_data[0].maxburst = 4; + mcbsp->dma_data[1].addr = omap_mcbsp_dma_reg_params(mcbsp, 1); + mcbsp->dma_data[1].maxburst = 4; + mcbsp->fclk = clk_get(&pdev->dev, "fck"); if (IS_ERR(mcbsp->fclk)) { ret = PTR_ERR(mcbsp->fclk); From 110ecd69a9feea82a152bbf9b12aba57e6396883 Mon Sep 17 00:00:00 2001 From: Sasha Levin Date: Thu, 11 Jul 2013 13:16:54 -0400 Subject: [PATCH 0777/1048] 9p: fix off by one causing access violations and memory corruption p9_release_pages() would attempt to dereference one value past the end of pages[]. This would cause the following crashes: [ 6293.171817] BUG: unable to handle kernel paging request at ffff8807c96f3000 [ 6293.174146] IP: [] p9_release_pages+0x3b/0x60 [ 6293.176447] PGD 79c5067 PUD 82c1e3067 PMD 82c197067 PTE 80000007c96f3060 [ 6293.180060] Oops: 0000 [#1] PREEMPT SMP DEBUG_PAGEALLOC [ 6293.180060] Modules linked in: [ 6293.180060] CPU: 62 PID: 174043 Comm: modprobe Tainted: G W 3.10.0-next-20130710-sasha #3954 [ 6293.180060] task: ffff8807b803b000 ti: ffff880787dde000 task.ti: ffff880787dde000 [ 6293.180060] RIP: 0010:[] [] p9_release_pages+0x3b/0x60 [ 6293.214316] RSP: 0000:ffff880787ddfc28 EFLAGS: 00010202 [ 6293.214316] RAX: 0000000000000001 RBX: ffff8807c96f2ff8 RCX: 0000000000000000 [ 6293.222017] RDX: ffff8807b803b000 RSI: 0000000000000001 RDI: ffffea001c7e3d40 [ 6293.222017] RBP: ffff880787ddfc48 R08: 0000000000000000 R09: 0000000000000000 [ 6293.222017] R10: 0000000000000001 R11: 0000000000000000 R12: 0000000000000001 [ 6293.222017] R13: 0000000000000001 R14: ffff8807cc50c070 R15: ffff8807cc50c070 [ 6293.222017] FS: 00007f572641d700(0000) GS:ffff8807f3600000(0000) knlGS:0000000000000000 [ 6293.256784] CS: 0010 DS: 0000 ES: 0000 CR0: 000000008005003b [ 6293.256784] CR2: ffff8807c96f3000 CR3: 00000007c8e81000 CR4: 00000000000006e0 [ 6293.256784] Stack: [ 6293.256784] ffff880787ddfcc8 ffff880787ddfcc8 0000000000000000 ffff880787ddfcc8 [ 6293.256784] ffff880787ddfd48 ffffffff84128be8 ffff880700000002 0000000000000001 [ 6293.256784] ffff8807b803b000 ffff880787ddfce0 0000100000000000 0000000000000000 [ 6293.256784] Call Trace: [ 6293.256784] [] p9_virtio_zc_request+0x598/0x630 [ 6293.256784] [] ? wake_up_bit+0x40/0x40 [ 6293.256784] [] p9_client_zc_rpc+0x111/0x3a0 [ 6293.256784] [] ? sched_clock_cpu+0x108/0x120 [ 6293.256784] [] p9_client_read+0xe1/0x2c0 [ 6293.256784] [] v9fs_file_read+0x90/0xc0 [ 6293.256784] [] vfs_read+0xc3/0x130 [ 6293.256784] [] ? trace_hardirqs_on+0xd/0x10 [ 6293.256784] [] SyS_read+0x62/0xa0 [ 6293.256784] [] tracesys+0xdd/0xe2 [ 6293.256784] Code: 66 90 48 89 fb 41 89 f5 48 8b 3f 48 85 ff 74 29 85 f6 74 25 45 31 e4 66 0f 1f 84 00 00 00 00 00 e8 eb 14 12 fd 41 ff c4 49 63 c4 <48> 8b 3c c3 48 85 ff 74 05 45 39 e5 75 e7 48 83 c4 08 5b 41 5c [ 6293.256784] RIP [] p9_release_pages+0x3b/0x60 [ 6293.256784] RSP [ 6293.256784] CR2: ffff8807c96f3000 [ 6293.256784] ---[ end trace 50822ee72cd360fc ]--- Signed-off-by: Sasha Levin Signed-off-by: David S. Miller --- net/9p/trans_common.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/net/9p/trans_common.c b/net/9p/trans_common.c index de8df957867d..2ee3879161b1 100644 --- a/net/9p/trans_common.c +++ b/net/9p/trans_common.c @@ -24,11 +24,11 @@ */ void p9_release_pages(struct page **pages, int nr_pages) { - int i = 0; - while (pages[i] && nr_pages--) { - put_page(pages[i]); - i++; - } + int i; + + for (i = 0; i < nr_pages; i++) + if (pages[i]) + put_page(pages[i]); } EXPORT_SYMBOL(p9_release_pages); From f89e57c4f5d7efdbe73b6214c73058aa335870e4 Mon Sep 17 00:00:00 2001 From: Pravin B Shelar Date: Thu, 11 Jul 2013 11:38:06 -0700 Subject: [PATCH 0778/1048] vxlan: Fix kernel crash on rmmod. vxlan exit module unregisters vxlan net and then it unregisters rtnl ops which triggers vxlan_dellink() from __rtnl_kill_links(). vxlan_dellink() deletes vxlan-dev from vxlan_list which has list-head in vxlan-net-struct but that is already gone due to net-unregister. That is how we are getting following crash. Following commit fixes the crash by fixing module exit path. BUG: unable to handle kernel paging request at ffff8804102c8000 IP: [] __list_del_entry+0x29/0xd0 PGD 2972067 PUD 83e019067 PMD 83df97067 PTE 80000004102c8060 Oops: 0000 [#1] SMP DEBUG_PAGEALLOC Modules linked in: --- CPU: 19 PID: 6712 Comm: rmmod Tainted: GF 3.10.0+ #95 Hardware name: Dell Inc. PowerEdge R620/0KCKR5, BIOS 1.4.8 10/25/2012 task: ffff88080c47c580 ti: ffff88080ac50000 task.ti: ffff88080ac50000 RIP: 0010:[] [] __list_del_entry+0x29/0xd0 RSP: 0018:ffff88080ac51e08 EFLAGS: 00010206 RAX: ffff8804102c8000 RBX: ffff88040f0d4b10 RCX: dead000000200200 RDX: ffff8804102c8000 RSI: ffff88080ac51e58 RDI: ffff88040f0d4b10 RBP: ffff88080ac51e08 R08: 0000000000000001 R09: 2222222222222222 R10: 2222222222222222 R11: 2222222222222222 R12: ffff88080ac51e58 R13: ffffffffa07b8840 R14: ffffffff81ae48c0 R15: ffff88080ac51e58 FS: 00007f9ef105c700(0000) GS:ffff88082a800000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: ffff8804102c8000 CR3: 00000008227e5000 CR4: 00000000000407e0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400 Stack: ffff88080ac51e28 ffffffff812cc6a1 2222222222222222 ffff88040f0d4000 ffff88080ac51e48 ffffffffa07b3311 ffff88040f0d4000 ffffffff81ae49c8 ffff88080ac51e98 ffffffff81492fc2 ffff88080ac51e58 ffff88080ac51e58 Call Trace: [] list_del+0x11/0x40 [] vxlan_dellink+0x51/0x70 [vxlan] [] __rtnl_link_unregister+0xa2/0xb0 [] rtnl_link_unregister+0x1e/0x30 [] vxlan_cleanup_module+0x1c/0x2f [vxlan] [] SyS_delete_module+0x1d1/0x2c0 [] ? trace_hardirqs_on_thunk+0x3a/0x3f [] system_call_fastpath+0x16/0x1b Code: eb 9f 55 48 8b 17 48 b9 00 01 10 00 00 00 ad de 48 8b 47 08 48 89 e5 48 39 ca 74 29 48 b9 00 02 20 00 00 00 ad de 48 39 c8 74 7a <4c> 8b 00 4c 39 c7 75 53 4c 8b 42 08 4c 39 c7 75 2b 48 89 42 08 RIP [] __list_del_entry+0x29/0xd0 RSP CR2: ffff8804102c8000 Signed-off-by: Pravin B Shelar Signed-off-by: David S. Miller --- drivers/net/vxlan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c index 227b54a1f88a..0ba1e7edbb1b 100644 --- a/drivers/net/vxlan.c +++ b/drivers/net/vxlan.c @@ -1916,9 +1916,9 @@ late_initcall(vxlan_init_module); static void __exit vxlan_cleanup_module(void) { - unregister_pernet_device(&vxlan_net_ops); rtnl_link_unregister(&vxlan_link_ops); destroy_workqueue(vxlan_wq); + unregister_pernet_device(&vxlan_net_ops); rcu_barrier(); } module_exit(vxlan_cleanup_module); From a8798a5c77c9981e88caef1373a3310bf8aed219 Mon Sep 17 00:00:00 2001 From: Maarten Lankhorst Date: Thu, 11 Jul 2013 15:53:21 +0200 Subject: [PATCH 0779/1048] alx: fix lockdep annotation Move spin_lock_init to be called before the spinlocks are used, preventing a lockdep splat. Signed-off-by: Maarten Lankhorst Signed-off-by: David S. Miller --- drivers/net/ethernet/atheros/alx/main.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/atheros/alx/main.c b/drivers/net/ethernet/atheros/alx/main.c index 0e0b242a9dd4..027398ebbba6 100644 --- a/drivers/net/ethernet/atheros/alx/main.c +++ b/drivers/net/ethernet/atheros/alx/main.c @@ -1245,6 +1245,8 @@ static int alx_probe(struct pci_dev *pdev, const struct pci_device_id *ent) SET_NETDEV_DEV(netdev, &pdev->dev); alx = netdev_priv(netdev); + spin_lock_init(&alx->hw.mdio_lock); + spin_lock_init(&alx->irq_lock); alx->dev = netdev; alx->hw.pdev = pdev; alx->msg_enable = NETIF_MSG_LINK | NETIF_MSG_HW | NETIF_MSG_IFUP | @@ -1327,9 +1329,6 @@ static int alx_probe(struct pci_dev *pdev, const struct pci_device_id *ent) INIT_WORK(&alx->link_check_wk, alx_link_check); INIT_WORK(&alx->reset_wk, alx_reset); - spin_lock_init(&alx->hw.mdio_lock); - spin_lock_init(&alx->irq_lock); - netif_carrier_off(netdev); err = register_netdev(netdev); From 1b4fc0e249d61916b8a525b0e7b3c028232457c9 Mon Sep 17 00:00:00 2001 From: Dmitry Kravkov Date: Thu, 11 Jul 2013 15:48:21 +0300 Subject: [PATCH 0780/1048] bnx2x: fix tunneling CSUM calculation Since commit c957d09ffda417f6c8e3d1f10e2b05228607d6d7 "bnx2x: Remove sparse and coccinelle warnings" driver provided wrong partial csum for HW in tunneing scenarios. Reported-by: Eric Dumazet CC: Alexander Duyck CC: Pravin Shelar CC: Cong Wang Signed-off-by: Dmitry Kravkov Tested-by: Eric Dumazet Signed-off-by: David S. Miller --- drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c index 3353efe79194..ee350bde1818 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c @@ -3543,9 +3543,9 @@ static void bnx2x_update_pbds_gso_enc(struct sk_buff *skb, /* outer IP header info */ if (xmit_type & XMIT_CSUM_V4) { struct iphdr *iph = ip_hdr(skb); - u16 csum = (__force u16)(~iph->check) - - (__force u16)iph->tot_len - - (__force u16)iph->frag_off; + u32 csum = (__force u32)(~iph->check) - + (__force u32)iph->tot_len - + (__force u32)iph->frag_off; pbd2->fw_ip_csum_wo_len_flags_frag = bswab16(csum_fold((__force __wsum)csum)); From afc154e978de1eb11c555bc8bcec1552f75ebc43 Mon Sep 17 00:00:00 2001 From: Hannes Frederic Sowa Date: Thu, 11 Jul 2013 12:43:42 +0200 Subject: [PATCH 0781/1048] ipv6: fix route selection if kernel is not compiled with CONFIG_IPV6_ROUTER_PREF This is a follow-up patch to 3630d40067a21d4dfbadc6002bb469ce26ac5d52 ("ipv6: rt6_check_neigh should successfully verify neigh if no NUD information are available"). Since the removal of rt->n in rt6_info we can end up with a dst == NULL in rt6_check_neigh. In case the kernel is not compiled with CONFIG_IPV6_ROUTER_PREF we should also select a route with unkown NUD state but we must not avoid doing round robin selection on routes with the same target. So introduce and pass down a boolean ``do_rr'' to indicate when we should update rt->rr_ptr. As soon as no route is valid we do backtracking and do a lookup on a higher level in the fib trie. v2: a) Improved rt6_check_neigh logic (no need to create neighbour there) and documented return values. v3: a) Introduce enum rt6_nud_state to get rid of the magic numbers (thanks to David Miller). b) Update and shorten commit message a bit to actualy reflect the source. Reported-by: Pierre Emeriaud Cc: YOSHIFUJI Hideaki Signed-off-by: Hannes Frederic Sowa Signed-off-by: David S. Miller --- net/ipv6/route.c | 69 ++++++++++++++++++++++++++++++------------------ 1 file changed, 43 insertions(+), 26 deletions(-) diff --git a/net/ipv6/route.c b/net/ipv6/route.c index 5b127e09c224..a8c891aa2464 100644 --- a/net/ipv6/route.c +++ b/net/ipv6/route.c @@ -65,6 +65,12 @@ #include #endif +enum rt6_nud_state { + RT6_NUD_FAIL_HARD = -2, + RT6_NUD_FAIL_SOFT = -1, + RT6_NUD_SUCCEED = 1 +}; + static struct rt6_info *ip6_rt_copy(struct rt6_info *ort, const struct in6_addr *dest); static struct dst_entry *ip6_dst_check(struct dst_entry *dst, u32 cookie); @@ -531,28 +537,29 @@ static inline int rt6_check_dev(struct rt6_info *rt, int oif) return 0; } -static inline bool rt6_check_neigh(struct rt6_info *rt) +static inline enum rt6_nud_state rt6_check_neigh(struct rt6_info *rt) { struct neighbour *neigh; - bool ret = false; + enum rt6_nud_state ret = RT6_NUD_FAIL_HARD; if (rt->rt6i_flags & RTF_NONEXTHOP || !(rt->rt6i_flags & RTF_GATEWAY)) - return true; + return RT6_NUD_SUCCEED; rcu_read_lock_bh(); neigh = __ipv6_neigh_lookup_noref(rt->dst.dev, &rt->rt6i_gateway); if (neigh) { read_lock(&neigh->lock); if (neigh->nud_state & NUD_VALID) - ret = true; + ret = RT6_NUD_SUCCEED; #ifdef CONFIG_IPV6_ROUTER_PREF else if (!(neigh->nud_state & NUD_FAILED)) - ret = true; + ret = RT6_NUD_SUCCEED; #endif read_unlock(&neigh->lock); - } else if (IS_ENABLED(CONFIG_IPV6_ROUTER_PREF)) { - ret = true; + } else { + ret = IS_ENABLED(CONFIG_IPV6_ROUTER_PREF) ? + RT6_NUD_SUCCEED : RT6_NUD_FAIL_SOFT; } rcu_read_unlock_bh(); @@ -566,43 +573,52 @@ static int rt6_score_route(struct rt6_info *rt, int oif, m = rt6_check_dev(rt, oif); if (!m && (strict & RT6_LOOKUP_F_IFACE)) - return -1; + return RT6_NUD_FAIL_HARD; #ifdef CONFIG_IPV6_ROUTER_PREF m |= IPV6_DECODE_PREF(IPV6_EXTRACT_PREF(rt->rt6i_flags)) << 2; #endif - if (!rt6_check_neigh(rt) && (strict & RT6_LOOKUP_F_REACHABLE)) - return -1; + if (strict & RT6_LOOKUP_F_REACHABLE) { + int n = rt6_check_neigh(rt); + if (n < 0) + return n; + } return m; } static struct rt6_info *find_match(struct rt6_info *rt, int oif, int strict, - int *mpri, struct rt6_info *match) + int *mpri, struct rt6_info *match, + bool *do_rr) { int m; + bool match_do_rr = false; if (rt6_check_expired(rt)) goto out; m = rt6_score_route(rt, oif, strict); - if (m < 0) + if (m == RT6_NUD_FAIL_SOFT && !IS_ENABLED(CONFIG_IPV6_ROUTER_PREF)) { + match_do_rr = true; + m = 0; /* lowest valid score */ + } else if (m < 0) { goto out; - - if (m > *mpri) { - if (strict & RT6_LOOKUP_F_REACHABLE) - rt6_probe(match); - *mpri = m; - match = rt; - } else if (strict & RT6_LOOKUP_F_REACHABLE) { - rt6_probe(rt); } + if (strict & RT6_LOOKUP_F_REACHABLE) + rt6_probe(rt); + + if (m > *mpri) { + *do_rr = match_do_rr; + *mpri = m; + match = rt; + } out: return match; } static struct rt6_info *find_rr_leaf(struct fib6_node *fn, struct rt6_info *rr_head, - u32 metric, int oif, int strict) + u32 metric, int oif, int strict, + bool *do_rr) { struct rt6_info *rt, *match; int mpri = -1; @@ -610,10 +626,10 @@ static struct rt6_info *find_rr_leaf(struct fib6_node *fn, match = NULL; for (rt = rr_head; rt && rt->rt6i_metric == metric; rt = rt->dst.rt6_next) - match = find_match(rt, oif, strict, &mpri, match); + match = find_match(rt, oif, strict, &mpri, match, do_rr); for (rt = fn->leaf; rt && rt != rr_head && rt->rt6i_metric == metric; rt = rt->dst.rt6_next) - match = find_match(rt, oif, strict, &mpri, match); + match = find_match(rt, oif, strict, &mpri, match, do_rr); return match; } @@ -622,15 +638,16 @@ static struct rt6_info *rt6_select(struct fib6_node *fn, int oif, int strict) { struct rt6_info *match, *rt0; struct net *net; + bool do_rr = false; rt0 = fn->rr_ptr; if (!rt0) fn->rr_ptr = rt0 = fn->leaf; - match = find_rr_leaf(fn, rt0, rt0->rt6i_metric, oif, strict); + match = find_rr_leaf(fn, rt0, rt0->rt6i_metric, oif, strict, + &do_rr); - if (!match && - (strict & RT6_LOOKUP_F_REACHABLE)) { + if (do_rr) { struct rt6_info *next = rt0->dst.rt6_next; /* no entries matched; do round-robin */ From a7960784e9ddd526e4fb791bc23e4fe6f039c28e Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Tue, 30 Apr 2013 13:59:48 +0900 Subject: [PATCH 0782/1048] watchdog: at32ap700x_wdt: use devm_*() functions Use devm_*() functions to make cleanup paths simpler. Signed-off-by: Jingoo Han Acked-by: Guenter Roeck Signed-off-by: Wim Van Sebroeck --- drivers/watchdog/at32ap700x_wdt.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/drivers/watchdog/at32ap700x_wdt.c b/drivers/watchdog/at32ap700x_wdt.c index 7a715e3e6828..c4cb5526112a 100644 --- a/drivers/watchdog/at32ap700x_wdt.c +++ b/drivers/watchdog/at32ap700x_wdt.c @@ -321,13 +321,14 @@ static int __init at32_wdt_probe(struct platform_device *pdev) return -ENXIO; } - wdt = kzalloc(sizeof(struct wdt_at32ap700x), GFP_KERNEL); + wdt = devm_kzalloc(&pdev->dev, sizeof(struct wdt_at32ap700x), + GFP_KERNEL); if (!wdt) { dev_dbg(&pdev->dev, "no memory for wdt structure\n"); return -ENOMEM; } - wdt->regs = ioremap(regs->start, resource_size(regs)); + wdt->regs = devm_ioremap(&pdev->dev, regs->start, resource_size(regs)); if (!wdt->regs) { ret = -ENOMEM; dev_dbg(&pdev->dev, "could not map I/O memory\n"); @@ -342,7 +343,7 @@ static int __init at32_wdt_probe(struct platform_device *pdev) dev_info(&pdev->dev, "CPU must be reset with external " "reset or POR due to silicon errata.\n"); ret = -EIO; - goto err_iounmap; + goto err_free; } else { wdt->users = 0; } @@ -375,10 +376,7 @@ static int __init at32_wdt_probe(struct platform_device *pdev) err_register: platform_set_drvdata(pdev, NULL); -err_iounmap: - iounmap(wdt->regs); err_free: - kfree(wdt); wdt = NULL; return ret; } @@ -391,8 +389,6 @@ static int __exit at32_wdt_remove(struct platform_device *pdev) at32_wdt_stop(); misc_deregister(&wdt->miscdev); - iounmap(wdt->regs); - kfree(wdt); wdt = NULL; platform_set_drvdata(pdev, NULL); } From 321e31231d781aa91e94e8e3974db1edb428b6a4 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Sat, 4 May 2013 01:41:14 +0530 Subject: [PATCH 0783/1048] watchdog: at32ap700x: Remove redundant platform_set_drvdata() Commit 0998d06310 (device-core: Ensure drvdata = NULL when no driver is bound) removes the need to set driver data field to NULL. Signed-off-by: Sachin Kamat Acked-by: Hans-Christian Egtvedt Signed-off-by: Wim Van Sebroeck --- drivers/watchdog/at32ap700x_wdt.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/watchdog/at32ap700x_wdt.c b/drivers/watchdog/at32ap700x_wdt.c index c4cb5526112a..b178e717ef09 100644 --- a/drivers/watchdog/at32ap700x_wdt.c +++ b/drivers/watchdog/at32ap700x_wdt.c @@ -365,7 +365,7 @@ static int __init at32_wdt_probe(struct platform_device *pdev) ret = misc_register(&wdt->miscdev); if (ret) { dev_dbg(&pdev->dev, "failed to register wdt miscdev\n"); - goto err_register; + goto err_free; } dev_info(&pdev->dev, @@ -374,8 +374,6 @@ static int __init at32_wdt_probe(struct platform_device *pdev) return 0; -err_register: - platform_set_drvdata(pdev, NULL); err_free: wdt = NULL; return ret; @@ -390,7 +388,6 @@ static int __exit at32_wdt_remove(struct platform_device *pdev) misc_deregister(&wdt->miscdev); wdt = NULL; - platform_set_drvdata(pdev, NULL); } return 0; } From 626d65aa5255fdd98e62f74cf43d3166e9832fb2 Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Tue, 30 Apr 2013 14:00:33 +0900 Subject: [PATCH 0784/1048] watchdog: bcm63xx_wdt: use devm_ioremap_nocache() Use devm_ioremap_nocache() to make cleanup paths simpler. Signed-off-by: Jingoo Han Reviewed-by: Guenter Roeck Acked-by: Florian Fainelli Signed-off-by: Wim Van Sebroeck --- drivers/watchdog/bcm63xx_wdt.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/watchdog/bcm63xx_wdt.c b/drivers/watchdog/bcm63xx_wdt.c index b2b80d4ac818..a14a58d9d110 100644 --- a/drivers/watchdog/bcm63xx_wdt.c +++ b/drivers/watchdog/bcm63xx_wdt.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -249,7 +250,8 @@ static int bcm63xx_wdt_probe(struct platform_device *pdev) return -ENODEV; } - bcm63xx_wdt_device.regs = ioremap_nocache(r->start, resource_size(r)); + bcm63xx_wdt_device.regs = devm_ioremap_nocache(&pdev->dev, r->start, + resource_size(r)); if (!bcm63xx_wdt_device.regs) { dev_err(&pdev->dev, "failed to remap I/O resources\n"); return -ENXIO; @@ -258,7 +260,7 @@ static int bcm63xx_wdt_probe(struct platform_device *pdev) ret = bcm63xx_timer_register(TIMER_WDT_ID, bcm63xx_wdt_isr, NULL); if (ret < 0) { dev_err(&pdev->dev, "failed to register wdt timer isr\n"); - goto unmap; + return ret; } if (bcm63xx_wdt_settimeout(wdt_time)) { @@ -281,8 +283,6 @@ static int bcm63xx_wdt_probe(struct platform_device *pdev) unregister_timer: bcm63xx_timer_unregister(TIMER_WDT_ID); -unmap: - iounmap(bcm63xx_wdt_device.regs); return ret; } @@ -293,7 +293,6 @@ static int bcm63xx_wdt_remove(struct platform_device *pdev) misc_deregister(&bcm63xx_wdt_miscdev); bcm63xx_timer_unregister(TIMER_WDT_ID); - iounmap(bcm63xx_wdt_device.regs); return 0; } From ce9a1bf8e6c65d2ab6786e759952a3548347ad6f Mon Sep 17 00:00:00 2001 From: Helmut Schaa Date: Thu, 11 Jul 2013 13:57:34 +0200 Subject: [PATCH 0785/1048] drivers: net: phy: at803x: Add missing mdio device id at803x supports Atheros 8030, 8031 and 8035 PHYs. 8031 was missing from the mdio device id table. Signed-off-by: Helmut Schaa Signed-off-by: David S. Miller --- drivers/net/phy/at803x.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/phy/at803x.c b/drivers/net/phy/at803x.c index 1f7091b3c27c..ac22283aaf23 100644 --- a/drivers/net/phy/at803x.c +++ b/drivers/net/phy/at803x.c @@ -217,6 +217,7 @@ module_exit(atheros_exit); static struct mdio_device_id __maybe_unused atheros_tbl[] = { { 0x004dd076, 0xffffffef }, + { 0x004dd074, 0xffffffef }, { 0x004dd072, 0xffffffef }, { } }; From ac1bb694c05302a0552c5a34ba701f246004bc03 Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Tue, 30 Apr 2013 14:00:49 +0900 Subject: [PATCH 0786/1048] watchdog: mv64x60_wdt: use devm_ioremap() Use devm_ioremap() to make cleanup paths simpler. Signed-off-by: Jingoo Han Reviewed-by: Guenter Roeck Signed-off-by: Wim Van Sebroeck --- drivers/watchdog/mv64x60_wdt.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/watchdog/mv64x60_wdt.c b/drivers/watchdog/mv64x60_wdt.c index c7fb878ca493..e4cf98019265 100644 --- a/drivers/watchdog/mv64x60_wdt.c +++ b/drivers/watchdog/mv64x60_wdt.c @@ -276,7 +276,7 @@ static int mv64x60_wdt_probe(struct platform_device *dev) if (!r) return -ENODEV; - mv64x60_wdt_regs = ioremap(r->start, resource_size(r)); + mv64x60_wdt_regs = devm_ioremap(&dev->dev, r->start, resource_size(r)); if (mv64x60_wdt_regs == NULL) return -ENOMEM; @@ -293,8 +293,6 @@ static int mv64x60_wdt_remove(struct platform_device *dev) mv64x60_wdt_handler_disable(); - iounmap(mv64x60_wdt_regs); - return 0; } From 3666eb028827c3a9df942cbc0a16388898c5a686 Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Tue, 30 Apr 2013 14:01:25 +0900 Subject: [PATCH 0787/1048] watchdog: nuc900_wdt: use devm_*() functions Use devm_*() functions to make cleanup paths simpler. Signed-off-by: Jingoo Han Reviewed-by: Guenter Roeck Signed-off-by: Wim Van Sebroeck --- drivers/watchdog/nuc900_wdt.c | 50 ++++++++--------------------------- 1 file changed, 11 insertions(+), 39 deletions(-) diff --git a/drivers/watchdog/nuc900_wdt.c b/drivers/watchdog/nuc900_wdt.c index 04c45a102992..e2b6d2cf5c9d 100644 --- a/drivers/watchdog/nuc900_wdt.c +++ b/drivers/watchdog/nuc900_wdt.c @@ -61,7 +61,6 @@ MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started " "(default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); struct nuc900_wdt { - struct resource *res; struct clk *wdt_clock; struct platform_device *pdev; void __iomem *wdt_base; @@ -244,9 +243,11 @@ static struct miscdevice nuc900wdt_miscdev = { static int nuc900wdt_probe(struct platform_device *pdev) { + struct resource *res; int ret = 0; - nuc900_wdt = kzalloc(sizeof(struct nuc900_wdt), GFP_KERNEL); + nuc900_wdt = devm_kzalloc(&pdev->dev, sizeof(*nuc900_wdt), + GFP_KERNEL); if (!nuc900_wdt) return -ENOMEM; @@ -254,33 +255,20 @@ static int nuc900wdt_probe(struct platform_device *pdev) spin_lock_init(&nuc900_wdt->wdt_lock); - nuc900_wdt->res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (nuc900_wdt->res == NULL) { + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (res == NULL) { dev_err(&pdev->dev, "no memory resource specified\n"); - ret = -ENOENT; - goto err_get; + return -ENOENT; } - if (!request_mem_region(nuc900_wdt->res->start, - resource_size(nuc900_wdt->res), pdev->name)) { - dev_err(&pdev->dev, "failed to get memory region\n"); - ret = -ENOENT; - goto err_get; - } + nuc900_wdt->wdt_base = devm_ioremap_resource(&pdev->dev, res); + if (IS_ERR(nuc900_wdt->wdt_base)) + return PTR_ERR(nuc900_wdt->wdt_base); - nuc900_wdt->wdt_base = ioremap(nuc900_wdt->res->start, - resource_size(nuc900_wdt->res)); - if (nuc900_wdt->wdt_base == NULL) { - dev_err(&pdev->dev, "failed to ioremap() region\n"); - ret = -EINVAL; - goto err_req; - } - - nuc900_wdt->wdt_clock = clk_get(&pdev->dev, NULL); + nuc900_wdt->wdt_clock = devm_clk_get(&pdev->dev, NULL); if (IS_ERR(nuc900_wdt->wdt_clock)) { dev_err(&pdev->dev, "failed to find watchdog clock source\n"); - ret = PTR_ERR(nuc900_wdt->wdt_clock); - goto err_map; + return PTR_ERR(nuc900_wdt->wdt_clock); } clk_enable(nuc900_wdt->wdt_clock); @@ -298,14 +286,6 @@ static int nuc900wdt_probe(struct platform_device *pdev) err_clk: clk_disable(nuc900_wdt->wdt_clock); - clk_put(nuc900_wdt->wdt_clock); -err_map: - iounmap(nuc900_wdt->wdt_base); -err_req: - release_mem_region(nuc900_wdt->res->start, - resource_size(nuc900_wdt->res)); -err_get: - kfree(nuc900_wdt); return ret; } @@ -314,14 +294,6 @@ static int nuc900wdt_remove(struct platform_device *pdev) misc_deregister(&nuc900wdt_miscdev); clk_disable(nuc900_wdt->wdt_clock); - clk_put(nuc900_wdt->wdt_clock); - - iounmap(nuc900_wdt->wdt_base); - - release_mem_region(nuc900_wdt->res->start, - resource_size(nuc900_wdt->res)); - - kfree(nuc900_wdt); return 0; } From 52ccc5aca4c9cf35974c1ea3b53fc43044b29361 Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Tue, 30 Apr 2013 14:01:41 +0900 Subject: [PATCH 0788/1048] watchdog: rc32434_wdt: use devm_ioremap_nocache() functions Use devm_ioremap_nocache() functions to make cleanup paths simpler. Signed-off-by: Jingoo Han Reviewed-by: Guenter Roeck Signed-off-by: Wim Van Sebroeck --- drivers/watchdog/rc32434_wdt.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/drivers/watchdog/rc32434_wdt.c b/drivers/watchdog/rc32434_wdt.c index f78bc008cbb7..9cf6bc7a234f 100644 --- a/drivers/watchdog/rc32434_wdt.c +++ b/drivers/watchdog/rc32434_wdt.c @@ -32,6 +32,7 @@ #include /* For platform_driver framework */ #include /* For spin_lock/spin_unlock/... */ #include /* For copy_to_user/put_user/... */ +#include /* For devm_ioremap_nocache */ #include /* For the Watchdog registers */ @@ -271,7 +272,7 @@ static int rc32434_wdt_probe(struct platform_device *pdev) return -ENODEV; } - wdt_reg = ioremap_nocache(r->start, resource_size(r)); + wdt_reg = devm_ioremap_nocache(&pdev->dev, r->start, resource_size(r)); if (!wdt_reg) { pr_err("failed to remap I/O resources\n"); return -ENXIO; @@ -293,23 +294,18 @@ static int rc32434_wdt_probe(struct platform_device *pdev) ret = misc_register(&rc32434_wdt_miscdev); if (ret < 0) { pr_err("failed to register watchdog device\n"); - goto unmap; + return ret; } pr_info("Watchdog Timer version " VERSION ", timer margin: %d sec\n", timeout); return 0; - -unmap: - iounmap(wdt_reg); - return ret; } static int rc32434_wdt_remove(struct platform_device *pdev) { misc_deregister(&rc32434_wdt_miscdev); - iounmap(wdt_reg); return 0; } From a508e2e634f9ea462c3beb56e12aa50ba9e8b0a9 Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Tue, 30 Apr 2013 14:01:59 +0900 Subject: [PATCH 0789/1048] watchdog: riowd: use devm_kzalloc() Use devm_kzalloc() to make cleanup paths simpler. Signed-off-by: Jingoo Han Reviewed-by: Guenter Roeck Signed-off-by: Wim Van Sebroeck --- drivers/watchdog/riowd.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/watchdog/riowd.c b/drivers/watchdog/riowd.c index 0040451aec1d..13363adc364f 100644 --- a/drivers/watchdog/riowd.c +++ b/drivers/watchdog/riowd.c @@ -183,7 +183,7 @@ static int riowd_probe(struct platform_device *op) goto out; err = -ENOMEM; - p = kzalloc(sizeof(*p), GFP_KERNEL); + p = devm_kzalloc(&op->dev, sizeof(*p), GFP_KERNEL); if (!p) goto out; @@ -192,7 +192,7 @@ static int riowd_probe(struct platform_device *op) p->regs = of_ioremap(&op->resource[0], 0, 2, DRIVER_NAME); if (!p->regs) { pr_err("Cannot map registers\n"); - goto out_free; + goto out; } /* Make miscdev useable right away */ riowd_device = p; @@ -213,9 +213,6 @@ out_iounmap: riowd_device = NULL; of_iounmap(&op->resource[0], p->regs, 2); -out_free: - kfree(p); - out: return err; } @@ -226,7 +223,6 @@ static int riowd_remove(struct platform_device *op) misc_deregister(&riowd_miscdev); of_iounmap(&op->resource[0], p->regs, 2); - kfree(p); return 0; } From b94828ffb2261a9803948ccd74f2b75105b1bf87 Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Thu, 23 May 2013 19:44:38 +0900 Subject: [PATCH 0790/1048] watchdog: riowd: use platform_{get,set}_drvdata() Use the wrapper functions for getting and setting the driver data using platform_device instead of using dev_{get,set}_drvdata() with &pdev->dev, so we can directly pass a struct platform_device. Signed-off-by: Jingoo Han Reviewed-by: Guenter Roeck Signed-off-by: Wim Van Sebroeck --- drivers/watchdog/riowd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/watchdog/riowd.c b/drivers/watchdog/riowd.c index 13363adc364f..3dd8ed28adc8 100644 --- a/drivers/watchdog/riowd.c +++ b/drivers/watchdog/riowd.c @@ -206,7 +206,7 @@ static int riowd_probe(struct platform_device *op) pr_info("Hardware watchdog [%i minutes], regs at %p\n", riowd_timeout, p->regs); - dev_set_drvdata(&op->dev, p); + platform_set_drvdata(op, p); return 0; out_iounmap: @@ -219,7 +219,7 @@ out: static int riowd_remove(struct platform_device *op) { - struct riowd *p = dev_get_drvdata(&op->dev); + struct riowd *p = platform_get_drvdata(op); misc_deregister(&riowd_miscdev); of_iounmap(&op->resource[0], p->regs, 2); From 9d8a7f16f47fca776b60ab63901dc8481ceb6e1f Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Thu, 2 May 2013 14:52:16 +0900 Subject: [PATCH 0791/1048] watchdog: ts72xx_wdt: use devm_*() functions Use devm_*() functions to make cleanup paths simpler. Signed-off-by: Jingoo Han Acked-by: Guenter Roeck Signed-off-by: Wim Van Sebroeck --- drivers/watchdog/ts72xx_wdt.c | 67 ++++++----------------------------- 1 file changed, 10 insertions(+), 57 deletions(-) diff --git a/drivers/watchdog/ts72xx_wdt.c b/drivers/watchdog/ts72xx_wdt.c index b8a92459f10f..4da59b4d73f0 100644 --- a/drivers/watchdog/ts72xx_wdt.c +++ b/drivers/watchdog/ts72xx_wdt.c @@ -396,7 +396,7 @@ static int ts72xx_wdt_probe(struct platform_device *pdev) struct resource *r1, *r2; int error = 0; - wdt = kzalloc(sizeof(struct ts72xx_wdt), GFP_KERNEL); + wdt = devm_kzalloc(&pdev->dev, sizeof(struct ts72xx_wdt), GFP_KERNEL); if (!wdt) { dev_err(&pdev->dev, "failed to allocate memory\n"); return -ENOMEM; @@ -405,44 +405,22 @@ static int ts72xx_wdt_probe(struct platform_device *pdev) r1 = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!r1) { dev_err(&pdev->dev, "failed to get memory resource\n"); - error = -ENODEV; - goto fail; + return -ENODEV; } - r1 = request_mem_region(r1->start, resource_size(r1), pdev->name); - if (!r1) { - dev_err(&pdev->dev, "cannot request memory region\n"); - error = -EBUSY; - goto fail; - } - - wdt->control_reg = ioremap(r1->start, resource_size(r1)); - if (!wdt->control_reg) { - dev_err(&pdev->dev, "failed to map memory\n"); - error = -ENODEV; - goto fail_free_control; - } + wdt->control_reg = devm_ioremap_resource(&pdev->dev, r1); + if (IS_ERR(wdt->control_reg)) + return PTR_ERR(wdt->control_reg); r2 = platform_get_resource(pdev, IORESOURCE_MEM, 1); if (!r2) { dev_err(&pdev->dev, "failed to get memory resource\n"); - error = -ENODEV; - goto fail_unmap_control; + return -ENODEV; } - r2 = request_mem_region(r2->start, resource_size(r2), pdev->name); - if (!r2) { - dev_err(&pdev->dev, "cannot request memory region\n"); - error = -EBUSY; - goto fail_unmap_control; - } - - wdt->feed_reg = ioremap(r2->start, resource_size(r2)); - if (!wdt->feed_reg) { - dev_err(&pdev->dev, "failed to map memory\n"); - error = -ENODEV; - goto fail_free_feed; - } + wdt->feed_reg = devm_ioremap_resource(&pdev->dev, r2); + if (IS_ERR(wdt->feed_reg)) + return PTR_ERR(wdt->feed_reg); platform_set_drvdata(pdev, wdt); ts72xx_wdt_pdev = pdev; @@ -455,45 +433,20 @@ static int ts72xx_wdt_probe(struct platform_device *pdev) error = misc_register(&ts72xx_wdt_miscdev); if (error) { dev_err(&pdev->dev, "failed to register miscdev\n"); - goto fail_unmap_feed; + return error; } dev_info(&pdev->dev, "TS-72xx Watchdog driver\n"); return 0; - -fail_unmap_feed: - platform_set_drvdata(pdev, NULL); - iounmap(wdt->feed_reg); -fail_free_feed: - release_mem_region(r2->start, resource_size(r2)); -fail_unmap_control: - iounmap(wdt->control_reg); -fail_free_control: - release_mem_region(r1->start, resource_size(r1)); -fail: - kfree(wdt); - return error; } static int ts72xx_wdt_remove(struct platform_device *pdev) { - struct ts72xx_wdt *wdt = platform_get_drvdata(pdev); - struct resource *res; int error; error = misc_deregister(&ts72xx_wdt_miscdev); - platform_set_drvdata(pdev, NULL); - iounmap(wdt->feed_reg); - res = platform_get_resource(pdev, IORESOURCE_MEM, 1); - release_mem_region(res->start, resource_size(res)); - - iounmap(wdt->control_reg); - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - release_mem_region(res->start, resource_size(res)); - - kfree(wdt); return error; } From cf3cc8c252cbd8d50ed61ef5e176bc577f38cf71 Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Mon, 29 Apr 2013 18:15:26 +0900 Subject: [PATCH 0792/1048] watchdog: dw_wdt: use devm_clk_get() Use devm_clk_get() to make cleanup paths more simple. Signed-off-by: Jingoo Han Reviewed-by: Guenter Roeck Signed-off-by: Wim Van Sebroeck --- drivers/watchdog/dw_wdt.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/watchdog/dw_wdt.c b/drivers/watchdog/dw_wdt.c index 203766989382..2e70fd07ea40 100644 --- a/drivers/watchdog/dw_wdt.c +++ b/drivers/watchdog/dw_wdt.c @@ -305,13 +305,13 @@ static int dw_wdt_drv_probe(struct platform_device *pdev) if (IS_ERR(dw_wdt.regs)) return PTR_ERR(dw_wdt.regs); - dw_wdt.clk = clk_get(&pdev->dev, NULL); + dw_wdt.clk = devm_clk_get(&pdev->dev, NULL); if (IS_ERR(dw_wdt.clk)) return PTR_ERR(dw_wdt.clk); ret = clk_enable(dw_wdt.clk); if (ret) - goto out_put_clk; + return ret; spin_lock_init(&dw_wdt.lock); @@ -327,8 +327,6 @@ static int dw_wdt_drv_probe(struct platform_device *pdev) out_disable_clk: clk_disable(dw_wdt.clk); -out_put_clk: - clk_put(dw_wdt.clk); return ret; } @@ -338,7 +336,6 @@ static int dw_wdt_drv_remove(struct platform_device *pdev) misc_deregister(&dw_wdt_miscdev); clk_disable(dw_wdt.clk); - clk_put(dw_wdt.clk); return 0; } From 2c8a01894a12665d8059fad8f0a293c98a264121 Mon Sep 17 00:00:00 2001 From: dingtianhong Date: Thu, 11 Jul 2013 19:04:02 +0800 Subject: [PATCH 0793/1048] dummy: fix oops when loading the dummy failed We rename the dummy in modprobe.conf like this: install dummy0 /sbin/modprobe -o dummy0 --ignore-install dummy install dummy1 /sbin/modprobe -o dummy1 --ignore-install dummy We got oops when we run the command: modprobe dummy0 modprobe dummy1 ------------[ cut here ]------------ [ 3302.187584] BUG: unable to handle kernel NULL pointer dereference at 0000000000000008 [ 3302.195411] IP: [] __rtnl_link_unregister+0x9a/0xd0 [ 3302.201844] PGD 85c94a067 PUD 8517bd067 PMD 0 [ 3302.206305] Oops: 0002 [#1] SMP [ 3302.299737] task: ffff88105ccea300 ti: ffff880eba4a0000 task.ti: ffff880eba4a0000 [ 3302.307186] RIP: 0010:[] [] __rtnl_link_unregister+0x9a/0xd0 [ 3302.316044] RSP: 0018:ffff880eba4a1dd8 EFLAGS: 00010246 [ 3302.321332] RAX: 0000000000000000 RBX: ffffffff81a9d738 RCX: 0000000000000002 [ 3302.328436] RDX: 0000000000000000 RSI: ffffffffa04d602c RDI: ffff880eba4a1dd8 [ 3302.335541] RBP: ffff880eba4a1e18 R08: dead000000200200 R09: dead000000100100 [ 3302.342644] R10: 0000000000000080 R11: 0000000000000003 R12: ffffffff81a9d788 [ 3302.349748] R13: ffffffffa04d7020 R14: ffffffff81a9d670 R15: ffff880eba4a1dd8 [ 3302.364910] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 3302.370630] CR2: 0000000000000008 CR3: 000000085e15e000 CR4: 00000000000427e0 [ 3302.377734] DR0: 0000000000000003 DR1: 00000000000000b0 DR2: 0000000000000001 [ 3302.384838] DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400 [ 3302.391940] Stack: [ 3302.393944] ffff880eba4a1dd8 ffff880eba4a1dd8 ffff880eba4a1e18 ffffffffa04d70c0 [ 3302.401350] 00000000ffffffef ffffffffa01a8000 0000000000000000 ffffffff816111c8 [ 3302.408758] ffff880eba4a1e48 ffffffffa01a80be ffff880eba4a1e48 ffffffffa04d70c0 [ 3302.416164] Call Trace: [ 3302.418605] [] ? 0xffffffffa01a7fff [ 3302.423727] [] dummy_init_module+0xbe/0x1000 [dummy0] [ 3302.430405] [] ? 0xffffffffa01a7fff [ 3302.435535] [] do_one_initcall+0x152/0x1b0 [ 3302.441263] [] do_init_module+0x7b/0x200 [ 3302.446824] [] load_module+0x4e2/0x530 [ 3302.452215] [] ? ddebug_dyndbg_boot_param_cb+0x60/0x60 [ 3302.458979] [] SyS_init_module+0xd1/0x130 [ 3302.464627] [] system_call_fastpath+0x16/0x1b [ 3302.490090] RIP [] __rtnl_link_unregister+0x9a/0xd0 [ 3302.496607] RSP [ 3302.500084] CR2: 0000000000000008 [ 3302.503466] ---[ end trace 8342d49cd49f78ed ]--- The reason is that when loading dummy, if __rtnl_link_register() return failed, the init_module should return and avoid take the wrong path. Signed-off-by: Tan Xiaojun Signed-off-by: Ding Tianhong Signed-off-by: David S. Miller --- drivers/net/dummy.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/net/dummy.c b/drivers/net/dummy.c index 42aa54af6842..b710c6b2d659 100644 --- a/drivers/net/dummy.c +++ b/drivers/net/dummy.c @@ -185,6 +185,8 @@ static int __init dummy_init_module(void) rtnl_lock(); err = __rtnl_link_register(&dummy_link_ops); + if (err < 0) + goto out; for (i = 0; i < numdummies && !err; i++) { err = dummy_init_one(); @@ -192,6 +194,8 @@ static int __init dummy_init_module(void) } if (err < 0) __rtnl_link_unregister(&dummy_link_ops); + +out: rtnl_unlock(); return err; From f2966cd5691058b8674a20766525bedeaea9cbcf Mon Sep 17 00:00:00 2001 From: dingtianhong Date: Thu, 11 Jul 2013 19:04:06 +0800 Subject: [PATCH 0794/1048] ifb: fix oops when loading the ifb failed If __rtnl_link_register() return faild when loading the ifb, it will take the wrong path and get oops, so fix it just like dummy. Signed-off-by: Ding Tianhong Signed-off-by: David S. Miller --- drivers/net/ifb.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/net/ifb.c b/drivers/net/ifb.c index a11f7a45cb5f..a3bed28197d2 100644 --- a/drivers/net/ifb.c +++ b/drivers/net/ifb.c @@ -291,6 +291,8 @@ static int __init ifb_init_module(void) rtnl_lock(); err = __rtnl_link_register(&ifb_link_ops); + if (err < 0) + goto out; for (i = 0; i < numifbs && !err; i++) { err = ifb_init_one(i); @@ -298,6 +300,8 @@ static int __init ifb_init_module(void) } if (err) __rtnl_link_unregister(&ifb_link_ops); + +out: rtnl_unlock(); return err; From 0b9302619963e46931c64693fd24d467c39bbb4c Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Tue, 14 May 2013 12:11:03 +0530 Subject: [PATCH 0795/1048] watchdog: dw_wdt: Staticize local symbol 'dw_wdt_write' is used only in this file. Make it static. Signed-off-by: Sachin Kamat Signed-off-by: Wim Van Sebroeck --- drivers/watchdog/dw_wdt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/watchdog/dw_wdt.c b/drivers/watchdog/dw_wdt.c index 2e70fd07ea40..e621098bf663 100644 --- a/drivers/watchdog/dw_wdt.c +++ b/drivers/watchdog/dw_wdt.c @@ -154,8 +154,8 @@ static int dw_wdt_open(struct inode *inode, struct file *filp) return nonseekable_open(inode, filp); } -ssize_t dw_wdt_write(struct file *filp, const char __user *buf, size_t len, - loff_t *offset) +static ssize_t dw_wdt_write(struct file *filp, const char __user *buf, + size_t len, loff_t *offset) { if (!len) return 0; From bdf495742716211259dba644e0950129db6f2641 Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Mon, 29 Apr 2013 18:15:53 +0900 Subject: [PATCH 0796/1048] watchdog: imx2_wdt: use devm_clk_get() Use devm_clk_get() to make cleanup paths more simple. Signed-off-by: Jingoo Han Reviewed-by: Guenter Roeck Signed-off-by: Wim Van Sebroeck --- drivers/watchdog/imx2_wdt.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/watchdog/imx2_wdt.c b/drivers/watchdog/imx2_wdt.c index 62946c2cb4f8..693ac3f4de5a 100644 --- a/drivers/watchdog/imx2_wdt.c +++ b/drivers/watchdog/imx2_wdt.c @@ -261,7 +261,7 @@ static int __init imx2_wdt_probe(struct platform_device *pdev) if (IS_ERR(imx2_wdt.base)) return PTR_ERR(imx2_wdt.base); - imx2_wdt.clk = clk_get(&pdev->dev, NULL); + imx2_wdt.clk = devm_clk_get(&pdev->dev, NULL); if (IS_ERR(imx2_wdt.clk)) { dev_err(&pdev->dev, "can't get Watchdog clock\n"); return PTR_ERR(imx2_wdt.clk); @@ -286,7 +286,6 @@ static int __init imx2_wdt_probe(struct platform_device *pdev) fail: imx2_wdt_miscdev.parent = NULL; - clk_put(imx2_wdt.clk); return ret; } @@ -299,8 +298,7 @@ static int __exit imx2_wdt_remove(struct platform_device *pdev) dev_crit(imx2_wdt_miscdev.parent, "Device removed: Expect reboot!\n"); - } else - clk_put(imx2_wdt.clk); + } imx2_wdt_miscdev.parent = NULL; return 0; From 259181feb003e3244d4ba15256735ca259be217a Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Mon, 29 Apr 2013 18:16:14 +0900 Subject: [PATCH 0797/1048] watchdog: pnx4008_wdt: use devm_clk_get() Use devm_clk_get() to make cleanup paths more simple. Signed-off-by: Jingoo Han Reviewed-by: Guenter Roeck Signed-off-by: Wim Van Sebroeck --- drivers/watchdog/pnx4008_wdt.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/watchdog/pnx4008_wdt.c b/drivers/watchdog/pnx4008_wdt.c index a3684a30eb69..b30bd430f591 100644 --- a/drivers/watchdog/pnx4008_wdt.c +++ b/drivers/watchdog/pnx4008_wdt.c @@ -159,13 +159,13 @@ static int pnx4008_wdt_probe(struct platform_device *pdev) if (IS_ERR(wdt_base)) return PTR_ERR(wdt_base); - wdt_clk = clk_get(&pdev->dev, NULL); + wdt_clk = devm_clk_get(&pdev->dev, NULL); if (IS_ERR(wdt_clk)) return PTR_ERR(wdt_clk); ret = clk_enable(wdt_clk); if (ret) - goto out; + return ret; pnx4008_wdd.bootstatus = (readl(WDTIM_RES(wdt_base)) & WDOG_RESET) ? WDIOF_CARDRESET : 0; @@ -186,8 +186,6 @@ static int pnx4008_wdt_probe(struct platform_device *pdev) disable_clk: clk_disable(wdt_clk); -out: - clk_put(wdt_clk); return ret; } @@ -196,7 +194,6 @@ static int pnx4008_wdt_remove(struct platform_device *pdev) watchdog_unregister_device(&pnx4008_wdd); clk_disable(wdt_clk); - clk_put(wdt_clk); return 0; } From 2f7b9b4883f4d67821bbd80f8fdfb8630d24cc60 Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Mon, 29 Apr 2013 18:16:33 +0900 Subject: [PATCH 0798/1048] watchdog: shwdt: use devm_clk_get() Use devm_clk_get() to make cleanup paths more simple. Signed-off-by: Jingoo Han Reviewed-by: Guenter Roeck Signed-off-by: Wim Van Sebroeck --- drivers/watchdog/shwdt.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/drivers/watchdog/shwdt.c b/drivers/watchdog/shwdt.c index 6185af2b3310..ea2154bfe5ab 100644 --- a/drivers/watchdog/shwdt.c +++ b/drivers/watchdog/shwdt.c @@ -241,7 +241,7 @@ static int sh_wdt_probe(struct platform_device *pdev) wdt->dev = &pdev->dev; - wdt->clk = clk_get(&pdev->dev, NULL); + wdt->clk = devm_clk_get(&pdev->dev, NULL); if (IS_ERR(wdt->clk)) { /* * Clock framework support is optional, continue on @@ -251,10 +251,8 @@ static int sh_wdt_probe(struct platform_device *pdev) } wdt->base = devm_ioremap_resource(wdt->dev, res); - if (IS_ERR(wdt->base)) { - rc = PTR_ERR(wdt->base); - goto err; - } + if (IS_ERR(wdt->base)) + return PTR_ERR(wdt->base); watchdog_set_nowayout(&sh_wdt_dev, nowayout); watchdog_set_drvdata(&sh_wdt_dev, wdt); @@ -277,7 +275,7 @@ static int sh_wdt_probe(struct platform_device *pdev) rc = watchdog_register_device(&sh_wdt_dev); if (unlikely(rc)) { dev_err(&pdev->dev, "Can't register watchdog (err=%d)\n", rc); - goto err; + return rc; } init_timer(&wdt->timer); @@ -292,11 +290,6 @@ static int sh_wdt_probe(struct platform_device *pdev) pm_runtime_enable(&pdev->dev); return 0; - -err: - clk_put(wdt->clk); - - return rc; } static int sh_wdt_remove(struct platform_device *pdev) @@ -308,7 +301,6 @@ static int sh_wdt_remove(struct platform_device *pdev) watchdog_unregister_device(&sh_wdt_dev); pm_runtime_disable(&pdev->dev); - clk_put(wdt->clk); return 0; } From 3b8ccd447375acebed9af0a3798e1ab4e58bedf4 Mon Sep 17 00:00:00 2001 From: Camelia Groza Date: Thu, 11 Jul 2013 09:55:51 +0300 Subject: [PATCH 0799/1048] inet: fix spacing in assignment Found using checkpatch.pl Signed-off-by: Camelia Groza Signed-off-by: David S. Miller --- net/ipv4/inet_hashtables.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c index 6af375afeeef..7bd8983dbfcf 100644 --- a/net/ipv4/inet_hashtables.c +++ b/net/ipv4/inet_hashtables.c @@ -467,7 +467,7 @@ void inet_unhash(struct sock *sk) lock = inet_ehash_lockp(hashinfo, sk->sk_hash); spin_lock_bh(lock); - done =__sk_nulls_del_node_init_rcu(sk); + done = __sk_nulls_del_node_init_rcu(sk); if (done) sock_prot_inuse_add(sock_net(sk), sk->sk_prot, -1); spin_unlock_bh(lock); From 4d2327ca9d44dbf5b4ead443f380ad58baa8c201 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Sat, 4 May 2013 01:41:16 +0530 Subject: [PATCH 0800/1048] watchdog: shwdt: Remove redundant platform_set_drvdata() Commit 0998d06310 (device-core: Ensure drvdata = NULL when no driver is bound) removes the need to set driver data field to NULL. Signed-off-by: Sachin Kamat Cc: Paul Mundt Signed-off-by: Wim Van Sebroeck --- drivers/watchdog/shwdt.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/watchdog/shwdt.c b/drivers/watchdog/shwdt.c index ea2154bfe5ab..5bca79457768 100644 --- a/drivers/watchdog/shwdt.c +++ b/drivers/watchdog/shwdt.c @@ -296,8 +296,6 @@ static int sh_wdt_remove(struct platform_device *pdev) { struct sh_wdt *wdt = platform_get_drvdata(pdev); - platform_set_drvdata(pdev, NULL); - watchdog_unregister_device(&sh_wdt_dev); pm_runtime_disable(&pdev->dev); From 07bf971a38427e2659603468e5947c39754edb13 Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Mon, 29 Apr 2013 18:16:49 +0900 Subject: [PATCH 0801/1048] watchdog: sp805_wdt: use devm_clk_get() Use devm_clk_get() to make cleanup paths more simple. Signed-off-by: Jingoo Han Acked-by: Viresh Kumar Signed-off-by: Wim Van Sebroeck --- drivers/watchdog/sp805_wdt.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/watchdog/sp805_wdt.c b/drivers/watchdog/sp805_wdt.c index 8872642505c0..58df98aec122 100644 --- a/drivers/watchdog/sp805_wdt.c +++ b/drivers/watchdog/sp805_wdt.c @@ -231,7 +231,7 @@ sp805_wdt_probe(struct amba_device *adev, const struct amba_id *id) goto err; } - wdt->clk = clk_get(&adev->dev, NULL); + wdt->clk = devm_clk_get(&adev->dev, NULL); if (IS_ERR(wdt->clk)) { dev_warn(&adev->dev, "Clock not found\n"); ret = PTR_ERR(wdt->clk); @@ -251,15 +251,13 @@ sp805_wdt_probe(struct amba_device *adev, const struct amba_id *id) if (ret) { dev_err(&adev->dev, "watchdog_register_device() failed: %d\n", ret); - goto err_register; + goto err; } amba_set_drvdata(adev, wdt); dev_info(&adev->dev, "registration successful\n"); return 0; -err_register: - clk_put(wdt->clk); err: dev_err(&adev->dev, "Probe Failed!!!\n"); return ret; @@ -272,7 +270,6 @@ static int sp805_wdt_remove(struct amba_device *adev) watchdog_unregister_device(&wdt->wdd); amba_set_drvdata(adev, NULL); watchdog_set_drvdata(&wdt->wdd, NULL); - clk_put(wdt->clk); return 0; } From d3a33a9500f262a40fcf3a9b9b9c3e03890b14dd Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Mon, 29 Apr 2013 18:30:43 +0900 Subject: [PATCH 0802/1048] watchdog: mtx1-wdt: use devm_gpio_request_one() Use devm_gpio_request_one() to make cleanup paths simpler. Signed-off-by: Jingoo Han Reviewed-by: Guenter Roeck Signed-off-by: Wim Van Sebroeck --- drivers/watchdog/mtx-1_wdt.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/watchdog/mtx-1_wdt.c b/drivers/watchdog/mtx-1_wdt.c index 14dab6ff87aa..b4341110ad4f 100644 --- a/drivers/watchdog/mtx-1_wdt.c +++ b/drivers/watchdog/mtx-1_wdt.c @@ -209,7 +209,7 @@ static int mtx1_wdt_probe(struct platform_device *pdev) int ret; mtx1_wdt_device.gpio = pdev->resource[0].start; - ret = gpio_request_one(mtx1_wdt_device.gpio, + ret = devm_gpio_request_one(&pdev->dev, mtx1_wdt_device.gpio, GPIOF_OUT_INIT_HIGH, "mtx1-wdt"); if (ret < 0) { dev_err(&pdev->dev, "failed to request gpio"); @@ -241,7 +241,6 @@ static int mtx1_wdt_remove(struct platform_device *pdev) wait_for_completion(&mtx1_wdt_device.stop); } - gpio_free(mtx1_wdt_device.gpio); misc_deregister(&mtx1_wdt_misc); return 0; } From 7a5da030c6ecdd6229f079902a17e641c7f2fbd6 Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Mon, 29 Apr 2013 18:31:20 +0900 Subject: [PATCH 0803/1048] watchdog: wm831x_wdt: use devm_gpio_request_one() Use devm_gpio_request_one() to make cleanup paths simpler. Also, GPIOF_DIR_OUT | GPIOF_INIT_LOW is replaced with GPIOF_OUT_INIT_LOW. Signed-off-by: Jingoo Han Reviewed-by: Guenter Roeck Signed-off-by: Wim Van Sebroeck --- drivers/watchdog/wm831x_wdt.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/drivers/watchdog/wm831x_wdt.c b/drivers/watchdog/wm831x_wdt.c index 9dcb6d082277..3348ddd618c7 100644 --- a/drivers/watchdog/wm831x_wdt.c +++ b/drivers/watchdog/wm831x_wdt.c @@ -247,9 +247,10 @@ static int wm831x_wdt_probe(struct platform_device *pdev) reg |= pdata->software << WM831X_WDOG_RST_SRC_SHIFT; if (pdata->update_gpio) { - ret = gpio_request_one(pdata->update_gpio, - GPIOF_DIR_OUT | GPIOF_INIT_LOW, - "Watchdog update"); + ret = devm_gpio_request_one(&pdev->dev, + pdata->update_gpio, + GPIOF_OUT_INIT_LOW, + "Watchdog update"); if (ret < 0) { dev_err(wm831x->dev, "Failed to request update GPIO: %d\n", @@ -270,7 +271,7 @@ static int wm831x_wdt_probe(struct platform_device *pdev) } else { dev_err(wm831x->dev, "Failed to unlock security key: %d\n", ret); - goto err_gpio; + goto err; } } @@ -278,16 +279,13 @@ static int wm831x_wdt_probe(struct platform_device *pdev) if (ret != 0) { dev_err(wm831x->dev, "watchdog_register_device() failed: %d\n", ret); - goto err_gpio; + goto err; } dev_set_drvdata(&pdev->dev, driver_data); return 0; -err_gpio: - if (driver_data->update_gpio) - gpio_free(driver_data->update_gpio); err: return ret; } @@ -298,9 +296,6 @@ static int wm831x_wdt_remove(struct platform_device *pdev) watchdog_unregister_device(&driver_data->wdt); - if (driver_data->update_gpio) - gpio_free(driver_data->update_gpio); - return 0; } From 1ae995dca9da3a5671aa471e1c355e47437a1056 Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Thu, 23 May 2013 19:44:53 +0900 Subject: [PATCH 0804/1048] watchdog: wm831x: use platform_{get,set}_drvdata() Use the wrapper functions for getting and setting the driver data using platform_device instead of using dev_{get,set}_drvdata() with &pdev->dev, so we can directly pass a struct platform_device. Signed-off-by: Jingoo Han Reviewed-by: Guenter Roeck Signed-off-by: Wim Van Sebroeck --- drivers/watchdog/wm831x_wdt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/watchdog/wm831x_wdt.c b/drivers/watchdog/wm831x_wdt.c index 3348ddd618c7..d4e47eda4182 100644 --- a/drivers/watchdog/wm831x_wdt.c +++ b/drivers/watchdog/wm831x_wdt.c @@ -282,7 +282,7 @@ static int wm831x_wdt_probe(struct platform_device *pdev) goto err; } - dev_set_drvdata(&pdev->dev, driver_data); + platform_set_drvdata(pdev, driver_data); return 0; @@ -292,7 +292,7 @@ err: static int wm831x_wdt_remove(struct platform_device *pdev) { - struct wm831x_wdt_drvdata *driver_data = dev_get_drvdata(&pdev->dev); + struct wm831x_wdt_drvdata *driver_data = platform_get_drvdata(pdev); watchdog_unregister_device(&driver_data->wdt); From 3828924af2e24a615b302fe1da69527d58474cdc Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Thu, 14 Mar 2013 10:30:21 +0900 Subject: [PATCH 0805/1048] watchdog: s3c2410_wdt: use dev_err()/dev_info() instead of pr_err()/pr_info() dev_err()/dev_info() are more preferred than pr_err()/pr_info(). Signed-off-by: Jingoo Han Reviewed-by: Guenter Roeck Signed-off-by: Wim Van Sebroeck --- drivers/watchdog/s3c2410_wdt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/watchdog/s3c2410_wdt.c b/drivers/watchdog/s3c2410_wdt.c index 3a9f6961db2d..c3beb3adc6f7 100644 --- a/drivers/watchdog/s3c2410_wdt.c +++ b/drivers/watchdog/s3c2410_wdt.c @@ -358,7 +358,7 @@ static int s3c2410wdt_probe(struct platform_device *pdev) ret = s3c2410wdt_cpufreq_register(); if (ret < 0) { - pr_err("failed to register cpufreq\n"); + dev_err(dev, "failed to register cpufreq\n"); goto err_clk; } @@ -473,7 +473,7 @@ static int s3c2410wdt_resume(struct platform_device *dev) writel(wtdat_save, wdt_base + S3C2410_WTCNT); /* Reset count */ writel(wtcon_save, wdt_base + S3C2410_WTCON); - pr_info("watchdog %sabled\n", + dev_info(&dev->dev, "watchdog %sabled\n", (wtcon_save & S3C2410_WTCON_ENABLE) ? "en" : "dis"); return 0; From 0183984c61fdd298dde717ff1c5c2f6ce2ef3f73 Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Thu, 14 Mar 2013 10:31:21 +0900 Subject: [PATCH 0806/1048] watchdog: s3c2410_wdt: convert s3c2410wdt to dev_pm_ops Instead of using legacy suspend/resume methods, using newer dev_pm_ops structure allows better control over power management. Signed-off-by: Jingoo Han Reviewed-by: Guenter Roeck Signed-off-by: Wim Van Sebroeck --- drivers/watchdog/s3c2410_wdt.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/drivers/watchdog/s3c2410_wdt.c b/drivers/watchdog/s3c2410_wdt.c index c3beb3adc6f7..6a22cf5d35bd 100644 --- a/drivers/watchdog/s3c2410_wdt.c +++ b/drivers/watchdog/s3c2410_wdt.c @@ -448,12 +448,12 @@ static void s3c2410wdt_shutdown(struct platform_device *dev) s3c2410wdt_stop(&s3c2410_wdd); } -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP static unsigned long wtcon_save; static unsigned long wtdat_save; -static int s3c2410wdt_suspend(struct platform_device *dev, pm_message_t state) +static int s3c2410wdt_suspend(struct device *dev) { /* Save watchdog state, and turn it off. */ wtcon_save = readl(wdt_base + S3C2410_WTCON); @@ -465,7 +465,7 @@ static int s3c2410wdt_suspend(struct platform_device *dev, pm_message_t state) return 0; } -static int s3c2410wdt_resume(struct platform_device *dev) +static int s3c2410wdt_resume(struct device *dev) { /* Restore watchdog state. */ @@ -473,16 +473,15 @@ static int s3c2410wdt_resume(struct platform_device *dev) writel(wtdat_save, wdt_base + S3C2410_WTCNT); /* Reset count */ writel(wtcon_save, wdt_base + S3C2410_WTCON); - dev_info(&dev->dev, "watchdog %sabled\n", + dev_info(dev, "watchdog %sabled\n", (wtcon_save & S3C2410_WTCON_ENABLE) ? "en" : "dis"); return 0; } +#endif -#else -#define s3c2410wdt_suspend NULL -#define s3c2410wdt_resume NULL -#endif /* CONFIG_PM */ +static SIMPLE_DEV_PM_OPS(s3c2410wdt_pm_ops, s3c2410wdt_suspend, + s3c2410wdt_resume); #ifdef CONFIG_OF static const struct of_device_id s3c2410_wdt_match[] = { @@ -496,11 +495,10 @@ static struct platform_driver s3c2410wdt_driver = { .probe = s3c2410wdt_probe, .remove = s3c2410wdt_remove, .shutdown = s3c2410wdt_shutdown, - .suspend = s3c2410wdt_suspend, - .resume = s3c2410wdt_resume, .driver = { .owner = THIS_MODULE, .name = "s3c2410-wdt", + .pm = &s3c2410wdt_pm_ops, .of_match_table = of_match_ptr(s3c2410_wdt_match), }, }; From 26556b6e0bf044622a5d3dcade0ac6657b23c2a7 Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Thu, 23 May 2013 19:43:43 +0900 Subject: [PATCH 0807/1048] watchdog: cpwd: use platform_{get,set}_drvdata() Use the wrapper functions for getting and setting the driver data using platform_device instead of using dev_{get,set}_drvdata() with &pdev->dev, so we can directly pass a struct platform_device. Signed-off-by: Jingoo Han Reviewed-by: Guenter Roeck Signed-off-by: Wim Van Sebroeck --- drivers/watchdog/cpwd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/watchdog/cpwd.c b/drivers/watchdog/cpwd.c index 70387582843f..213225edd059 100644 --- a/drivers/watchdog/cpwd.c +++ b/drivers/watchdog/cpwd.c @@ -621,7 +621,7 @@ static int cpwd_probe(struct platform_device *op) WD_BADMODEL); } - dev_set_drvdata(&op->dev, p); + platform_set_drvdata(op, p); cpwd_device = p; err = 0; @@ -642,7 +642,7 @@ out_free: static int cpwd_remove(struct platform_device *op) { - struct cpwd *p = dev_get_drvdata(&op->dev); + struct cpwd *p = platform_get_drvdata(op); int i; for (i = 0; i < WD_NUMDEVS; i++) { From 552a96415ff297475c20a05d384398ef1c729794 Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Thu, 23 May 2013 19:44:09 +0900 Subject: [PATCH 0808/1048] watchdog: da9052: use platform_{get,set}_drvdata() Use the wrapper functions for getting and setting the driver data using platform_device instead of using dev_{get,set}_drvdata() with &pdev->dev, so we can directly pass a struct platform_device. Signed-off-by: Jingoo Han Reviewed-by: Guenter Roeck Signed-off-by: Wim Van Sebroeck --- drivers/watchdog/da9052_wdt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/watchdog/da9052_wdt.c b/drivers/watchdog/da9052_wdt.c index 367445009c64..f09c54e9686f 100644 --- a/drivers/watchdog/da9052_wdt.c +++ b/drivers/watchdog/da9052_wdt.c @@ -215,14 +215,14 @@ static int da9052_wdt_probe(struct platform_device *pdev) goto err; } - dev_set_drvdata(&pdev->dev, driver_data); + platform_set_drvdata(pdev, driver_data); err: return ret; } static int da9052_wdt_remove(struct platform_device *pdev) { - struct da9052_wdt_data *driver_data = dev_get_drvdata(&pdev->dev); + struct da9052_wdt_data *driver_data = platform_get_drvdata(pdev); watchdog_unregister_device(&driver_data->wdt); kref_put(&driver_data->kref, da9052_wdt_release_resources); From 76692c944cd8e85d833dc30d7346463e18b6d30e Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Thu, 23 May 2013 19:44:23 +0900 Subject: [PATCH 0809/1048] watchdog: da9055: use platform_{get,set}_drvdata() Use the wrapper functions for getting and setting the driver data using platform_device instead of using dev_{get,set}_drvdata() with &pdev->dev, so we can directly pass a struct platform_device. Signed-off-by: Jingoo Han Reviewed-by: Guenter Roeck Signed-off-by: Wim Van Sebroeck --- drivers/watchdog/da9055_wdt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/watchdog/da9055_wdt.c b/drivers/watchdog/da9055_wdt.c index f5ad10546fc9..575f37a965a4 100644 --- a/drivers/watchdog/da9055_wdt.c +++ b/drivers/watchdog/da9055_wdt.c @@ -174,7 +174,7 @@ static int da9055_wdt_probe(struct platform_device *pdev) goto err; } - dev_set_drvdata(&pdev->dev, driver_data); + platform_set_drvdata(pdev, driver_data); ret = watchdog_register_device(&driver_data->wdt); if (ret != 0) @@ -187,7 +187,7 @@ err: static int da9055_wdt_remove(struct platform_device *pdev) { - struct da9055_wdt_data *driver_data = dev_get_drvdata(&pdev->dev); + struct da9055_wdt_data *driver_data = platform_get_drvdata(pdev); watchdog_unregister_device(&driver_data->wdt); kref_put(&driver_data->kref, da9055_wdt_release_resources); From 6697dbd27b6507c11815725ab31473ba74c49f06 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Sat, 4 May 2013 01:41:15 +0530 Subject: [PATCH 0810/1048] watchdog: mpcore: Remove redundant platform_set_drvdata() Commit 0998d06310 (device-core: Ensure drvdata = NULL when no driver is bound) removes the need to set driver data field to NULL. Signed-off-by: Sachin Kamat Signed-off-by: Wim Van Sebroeck --- drivers/watchdog/mpcore_wdt.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/watchdog/mpcore_wdt.c b/drivers/watchdog/mpcore_wdt.c index 233cfadcb21f..4f5ac408c7a3 100644 --- a/drivers/watchdog/mpcore_wdt.c +++ b/drivers/watchdog/mpcore_wdt.c @@ -379,8 +379,6 @@ static int mpcore_wdt_probe(struct platform_device *pdev) static int mpcore_wdt_remove(struct platform_device *pdev) { - platform_set_drvdata(pdev, NULL); - misc_deregister(&mpcore_wdt_miscdev); mpcore_wdt_pdev = NULL; From 6638f4e5e5114fcb0c9dcec05cb3e33454f4a9ac Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Sat, 4 May 2013 01:41:18 +0530 Subject: [PATCH 0811/1048] watchdog: twl4030: Remove redundant platform_set_drvdata() Commit 0998d06310 (device-core: Ensure drvdata = NULL when no driver is bound) removes the need to set driver data field to NULL. Signed-off-by: Sachin Kamat Cc: Timo Kokkonen Signed-off-by: Wim Van Sebroeck --- drivers/watchdog/twl4030_wdt.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/watchdog/twl4030_wdt.c b/drivers/watchdog/twl4030_wdt.c index 0f03106f7516..2d4535dc2676 100644 --- a/drivers/watchdog/twl4030_wdt.c +++ b/drivers/watchdog/twl4030_wdt.c @@ -90,10 +90,8 @@ static int twl4030_wdt_probe(struct platform_device *pdev) twl4030_wdt_stop(wdt); ret = watchdog_register_device(wdt); - if (ret) { - platform_set_drvdata(pdev, NULL); + if (ret) return ret; - } return 0; } @@ -103,7 +101,6 @@ static int twl4030_wdt_remove(struct platform_device *pdev) struct watchdog_device *wdt = platform_get_drvdata(pdev); watchdog_unregister_device(wdt); - platform_set_drvdata(pdev, NULL); return 0; } From 5f314970b25a6960dd056b0038ffc7b88dc2973e Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Sun, 12 May 2013 20:04:03 +0200 Subject: [PATCH 0812/1048] watchdog: jz4740: Pass device to clk_get In preparation to switching the jz4740 clk driver to the common clk framework make sure to pass the device to clk_get(). Signed-off-by: Lars-Peter Clausen Signed-off-by: Wim Van Sebroeck --- drivers/watchdog/jz4740_wdt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/watchdog/jz4740_wdt.c b/drivers/watchdog/jz4740_wdt.c index 1cb25f69a96d..d1afdf684c18 100644 --- a/drivers/watchdog/jz4740_wdt.c +++ b/drivers/watchdog/jz4740_wdt.c @@ -177,7 +177,7 @@ static int jz4740_wdt_probe(struct platform_device *pdev) goto err_out; } - drvdata->rtc_clk = clk_get(NULL, "rtc"); + drvdata->rtc_clk = clk_get(&pdev->dev, "rtc"); if (IS_ERR(drvdata->rtc_clk)) { dev_err(&pdev->dev, "cannot find RTC clock\n"); ret = PTR_ERR(drvdata->rtc_clk); From fcf95670fd29359a382e0755e573b36076d6283e Mon Sep 17 00:00:00 2001 From: Hector Palacios Date: Mon, 8 Apr 2013 17:06:32 +0200 Subject: [PATCH 0813/1048] watchdog: core: don't try to stop device if not running A watchdog device may be stopped from userspace using WDIOC_SETOPTIONS ioctl and flag WDIOS_DISABLECARD. If the device is closed after this operation, watchdog_release() is called and status bits checked for stopping it. Besides, if the device has not been unregistered a critical message "watchdog did not stop!" is printed, although the ioctl may have successfully stopped it already. Without the patch a user application sample code like this will successfully stop the watchdog, but the kernel will output the message "watchdog did not stop!": wd_fd = open("/dev/watchdog", O_RDWR); flags = WDIOS_DISABLECARD; ioctl(wd_fd, WDIOC_SETOPTIONS, &flags); close(wd_fd); Signed-off-by: Hector Palacios Reviewed-by: Guenter Roeck Signed-off-by: Wim Van Sebroeck --- drivers/watchdog/watchdog_dev.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/watchdog/watchdog_dev.c b/drivers/watchdog/watchdog_dev.c index faf4e189fe42..6aaefbad303e 100644 --- a/drivers/watchdog/watchdog_dev.c +++ b/drivers/watchdog/watchdog_dev.c @@ -469,8 +469,10 @@ static int watchdog_release(struct inode *inode, struct file *file) * or if WDIOF_MAGICCLOSE is not set. If nowayout was set then * watchdog_stop will fail. */ - if (test_and_clear_bit(WDOG_ALLOW_RELEASE, &wdd->status) || - !(wdd->info->options & WDIOF_MAGICCLOSE)) + if (!test_bit(WDOG_ACTIVE, &wdd->status)) + err = 0; + else if (test_and_clear_bit(WDOG_ALLOW_RELEASE, &wdd->status) || + !(wdd->info->options & WDIOF_MAGICCLOSE)) err = watchdog_stop(wdd); /* If the watchdog was not stopped, send a keepalive ping */ From cdbaa0bb26d8116d00be24e6b49043777b382f3a Mon Sep 17 00:00:00 2001 From: Alexander Duyck Date: Wed, 10 Jul 2013 17:05:06 -0700 Subject: [PATCH 0814/1048] gso: Update tunnel segmentation to support Tx checksum offload This change makes it so that the GRE and VXLAN tunnels can make use of Tx checksum offload support provided by some drivers via the hw_enc_features. Without this fix enabling GSO means sacrificing Tx checksum offload and this actually leads to a performance regression as shown below: Utilization Send Throughput local GSO 10^6bits/s % S state 6276.51 8.39 enabled 7123.52 8.42 disabled To resolve this it was necessary to address two items. First netif_skb_features needed to be updated so that it would correctly handle the Trans Ether Bridging protocol without impacting the need to check for Q-in-Q tagging. To do this it was necessary to update harmonize_features so that it used skb_network_protocol instead of just using the outer protocol. Second it was necessary to update the GRE and UDP tunnel segmentation offloads so that they would reset the encapsulation bit and inner header offsets after the offload was complete. As a result of this change I have seen the following results on a interface with Tx checksum enabled for encapsulated frames: Utilization Send Throughput local GSO 10^6bits/s % S state 7123.52 8.42 disabled 8321.75 5.43 enabled v2: Instead of replacing refrence to skb->protocol with skb_network_protocol just replace the protocol reference in harmonize_features to allow for double VLAN tag checks. Signed-off-by: Alexander Duyck Signed-off-by: David S. Miller --- net/core/dev.c | 14 ++++++-------- net/ipv4/gre_offload.c | 3 +++ net/ipv4/udp.c | 4 +++- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/net/core/dev.c b/net/core/dev.c index 560dafd83adf..a3d8d44cb7f4 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -2481,10 +2481,10 @@ static int dev_gso_segment(struct sk_buff *skb, netdev_features_t features) } static netdev_features_t harmonize_features(struct sk_buff *skb, - __be16 protocol, netdev_features_t features) + netdev_features_t features) { if (skb->ip_summed != CHECKSUM_NONE && - !can_checksum_protocol(features, protocol)) { + !can_checksum_protocol(features, skb_network_protocol(skb))) { features &= ~NETIF_F_ALL_CSUM; } else if (illegal_highdma(skb->dev, skb)) { features &= ~NETIF_F_SG; @@ -2505,20 +2505,18 @@ netdev_features_t netif_skb_features(struct sk_buff *skb) struct vlan_ethhdr *veh = (struct vlan_ethhdr *)skb->data; protocol = veh->h_vlan_encapsulated_proto; } else if (!vlan_tx_tag_present(skb)) { - return harmonize_features(skb, protocol, features); + return harmonize_features(skb, features); } features &= (skb->dev->vlan_features | NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_STAG_TX); - if (protocol != htons(ETH_P_8021Q) && protocol != htons(ETH_P_8021AD)) { - return harmonize_features(skb, protocol, features); - } else { + if (protocol == htons(ETH_P_8021Q) || protocol == htons(ETH_P_8021AD)) features &= NETIF_F_SG | NETIF_F_HIGHDMA | NETIF_F_FRAGLIST | NETIF_F_GEN_CSUM | NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_STAG_TX; - return harmonize_features(skb, protocol, features); - } + + return harmonize_features(skb, features); } EXPORT_SYMBOL(netif_skb_features); diff --git a/net/ipv4/gre_offload.c b/net/ipv4/gre_offload.c index 775d5b532ece..55e6bfb3a289 100644 --- a/net/ipv4/gre_offload.c +++ b/net/ipv4/gre_offload.c @@ -100,6 +100,9 @@ static struct sk_buff *gre_gso_segment(struct sk_buff *skb, } __skb_push(skb, tnl_hlen - ghl); + skb_reset_inner_headers(skb); + skb->encapsulation = 1; + skb_reset_mac_header(skb); skb_set_network_header(skb, mac_len); skb->mac_len = mac_len; diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c index a0d7151ffbd9..766e6bab9113 100644 --- a/net/ipv4/udp.c +++ b/net/ipv4/udp.c @@ -2323,6 +2323,9 @@ struct sk_buff *skb_udp_tunnel_segment(struct sk_buff *skb, struct udphdr *uh; int udp_offset = outer_hlen - tnl_hlen; + skb_reset_inner_headers(skb); + skb->encapsulation = 1; + skb->mac_len = mac_len; skb_push(skb, outer_hlen); @@ -2345,7 +2348,6 @@ struct sk_buff *skb_udp_tunnel_segment(struct sk_buff *skb, uh->check = CSUM_MANGLED_0; } - skb->ip_summed = CHECKSUM_NONE; skb->protocol = protocol; } while ((skb = skb->next)); out: From 48388069bd6736065ed5143cb42d22a16b1744a5 Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Tue, 28 May 2013 12:25:49 +0300 Subject: [PATCH 0815/1048] watchdog: wdrtas: don't use custom version of print_hex_dump Kernel has nice helpers to dump buffers. Signed-off-by: Andy Shevchenko Reviewed-by: Guenter Roeck Signed-off-by: Wim Van Sebroeck --- drivers/watchdog/wdrtas.c | 29 +++-------------------------- 1 file changed, 3 insertions(+), 26 deletions(-) diff --git a/drivers/watchdog/wdrtas.c b/drivers/watchdog/wdrtas.c index 0a77655cda60..3045debd5411 100644 --- a/drivers/watchdog/wdrtas.c +++ b/drivers/watchdog/wdrtas.c @@ -161,31 +161,6 @@ static void wdrtas_timer_stop(void) wdrtas_set_interval(0); } -/** - * wdrtas_log_scanned_event - logs an event we received during keepalive - * - * wdrtas_log_scanned_event prints a message to the log buffer dumping - * the results of the last event-scan call - */ -static void wdrtas_log_scanned_event(void) -{ - int i; - - for (i = 0; i < WDRTAS_LOGBUFFER_LEN; i += 16) - pr_info("dumping event (line %i/%i), data = " - "%02x %02x %02x %02x %02x %02x %02x %02x " - "%02x %02x %02x %02x %02x %02x %02x %02x\n", - (i / 16) + 1, (WDRTAS_LOGBUFFER_LEN / 16), - wdrtas_logbuffer[i + 0], wdrtas_logbuffer[i + 1], - wdrtas_logbuffer[i + 2], wdrtas_logbuffer[i + 3], - wdrtas_logbuffer[i + 4], wdrtas_logbuffer[i + 5], - wdrtas_logbuffer[i + 6], wdrtas_logbuffer[i + 7], - wdrtas_logbuffer[i + 8], wdrtas_logbuffer[i + 9], - wdrtas_logbuffer[i + 10], wdrtas_logbuffer[i + 11], - wdrtas_logbuffer[i + 12], wdrtas_logbuffer[i + 13], - wdrtas_logbuffer[i + 14], wdrtas_logbuffer[i + 15]); -} - /** * wdrtas_timer_keepalive - resets watchdog timer to keep system alive * @@ -205,7 +180,9 @@ static void wdrtas_timer_keepalive(void) if (result < 0) pr_err("event-scan failed: %li\n", result); if (result == 0) - wdrtas_log_scanned_event(); + print_hex_dump(KERN_INFO, "dumping event, data: ", + DUMP_PREFIX_OFFSET, 16, 1, + wdrtas_logbuffer, WDRTAS_LOGBUFFER_LEN, false); } while (result == 0); } From 9419c07ccebf6080159b4440dab9b3e484c96d7a Mon Sep 17 00:00:00 2001 From: Michal Simek Date: Fri, 31 May 2013 07:56:33 +0200 Subject: [PATCH 0816/1048] watchdog: xilinx: Fix driver header - Remove reference for IP version - Fix header coding style - Remove notes which are visible from the code - Fix driver license according to header Signed-off-by: Michal Simek Reviewed-by: Guenter Roeck Signed-off-by: Wim Van Sebroeck --- drivers/watchdog/of_xilinx_wdt.c | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/drivers/watchdog/of_xilinx_wdt.c b/drivers/watchdog/of_xilinx_wdt.c index 2761ddb08501..d4a35ab89e01 100644 --- a/drivers/watchdog/of_xilinx_wdt.c +++ b/drivers/watchdog/of_xilinx_wdt.c @@ -1,23 +1,13 @@ /* -* of_xilinx_wdt.c 1.01 A Watchdog Device Driver for Xilinx xps_timebase_wdt -* -* (C) Copyright 2011 (Alejandro Cabrera ) -* -* ----------------------- -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public License -* as published by the Free Software Foundation; either version -* 2 of the License, or (at your option) any later version. -* -* ----------------------- -* 30-May-2011 Alejandro Cabrera -* - If "xlnx,wdt-enable-once" wasn't found on device tree the -* module will use CONFIG_WATCHDOG_NOWAYOUT -* - If the device tree parameters ("clock-frequency" and -* "xlnx,wdt-interval") wasn't found the driver won't -* know the wdt reset interval -*/ + * Watchdog Device Driver for Xilinx axi/xps_timebase_wdt + * + * (C) Copyright 2011 (Alejandro Cabrera ) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version + * 2 of the License, or (at your option) any later version. + */ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt @@ -413,5 +403,5 @@ module_platform_driver(xwdt_driver); MODULE_AUTHOR("Alejandro Cabrera "); MODULE_DESCRIPTION("Xilinx Watchdog driver"); -MODULE_LICENSE("GPL"); +MODULE_LICENSE("GPL v2"); MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR); From 8fce9b367d672332d2d101175b10737ee5c18b59 Mon Sep 17 00:00:00 2001 From: Michal Simek Date: Fri, 31 May 2013 07:56:34 +0200 Subject: [PATCH 0817/1048] watchdog: xilinx: Setup the origin compatible string Watchdog 1.01.a is also compatible with 1.00.a. Add the origin version to compatible list. Signed-off-by: Michal Simek Reviewed-by: Guenter Roeck Signed-off-by: Wim Van Sebroeck --- drivers/watchdog/of_xilinx_wdt.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/watchdog/of_xilinx_wdt.c b/drivers/watchdog/of_xilinx_wdt.c index d4a35ab89e01..4dd281f2c33f 100644 --- a/drivers/watchdog/of_xilinx_wdt.c +++ b/drivers/watchdog/of_xilinx_wdt.c @@ -384,6 +384,7 @@ static int xwdt_remove(struct platform_device *dev) /* Match table for of_platform binding */ static struct of_device_id xwdt_of_match[] = { + { .compatible = "xlnx,xps-timebase-wdt-1.00.a", }, { .compatible = "xlnx,xps-timebase-wdt-1.01.a", }, {}, }; From 6e63a3a294fdf91eaaac1061a9c7a5f53d16ac25 Mon Sep 17 00:00:00 2001 From: Viresh Kumar Date: Wed, 19 Jun 2013 20:38:58 +0530 Subject: [PATCH 0818/1048] watchdog: delete mpcore_wdt driver Interrupt request doesn't use the right API: The TWD watchdog uses a per-cpu interrupt (usually interrupt #30), and the GIC configuration should flag it as such. With this setup, request_irq() should fail, and the right API is request_percpu_irq(), together with enable_percpu_irq()/disable_percpu_irq(). Nothing ensures the userspace ioctl() will end-up kicking the watchdog on the right CPU. There are no users of this driver since a long time and it makes more sense to get rid of it as nobody is looking to fix it. In case somebody wakes up after this has been removed and needs it, please revert this driver and pick these updates (These were never pushed to mainline): http://comments.gmane.org/gmane.linux.ports.arm.kernel/245998 Signed-off-by: Viresh Kumar Acked-by: Guenter Roeck Signed-off-by: Wim Van Sebroeck --- .../watchdog/watchdog-parameters.txt | 8 - arch/arm/configs/spear13xx_defconfig | 1 - drivers/watchdog/Kconfig | 9 - drivers/watchdog/Makefile | 1 - drivers/watchdog/mpcore_wdt.c | 454 ------------------ 5 files changed, 473 deletions(-) delete mode 100644 drivers/watchdog/mpcore_wdt.c diff --git a/Documentation/watchdog/watchdog-parameters.txt b/Documentation/watchdog/watchdog-parameters.txt index 04fddbacdbde..f9492fed4104 100644 --- a/Documentation/watchdog/watchdog-parameters.txt +++ b/Documentation/watchdog/watchdog-parameters.txt @@ -194,14 +194,6 @@ reset: Watchdog Interrupt/Reset Mode. 0 = interrupt, 1 = reset nowayout: Watchdog cannot be stopped once started (default=kernel config parameter) ------------------------------------------------- -mpcore_wdt: -mpcore_margin: MPcore timer margin in seconds. - (0 < mpcore_margin < 65536, default=60) -nowayout: Watchdog cannot be stopped once started - (default=kernel config parameter) -mpcore_noboot: MPcore watchdog action, set to 1 to ignore reboots, - 0 to reboot (default=0 -------------------------------------------------- mv64x60_wdt: nowayout: Watchdog cannot be stopped once started (default=kernel config parameter) diff --git a/arch/arm/configs/spear13xx_defconfig b/arch/arm/configs/spear13xx_defconfig index 1fdb82694ca2..82eaa552ed14 100644 --- a/arch/arm/configs/spear13xx_defconfig +++ b/arch/arm/configs/spear13xx_defconfig @@ -61,7 +61,6 @@ CONFIG_GPIO_SYSFS=y CONFIG_GPIO_PL061=y # CONFIG_HWMON is not set CONFIG_WATCHDOG=y -CONFIG_MPCORE_WATCHDOG=y # CONFIG_HID_SUPPORT is not set CONFIG_USB=y # CONFIG_USB_DEVICE_CLASS is not set diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig index 7460d349df59..6042e9ed542c 100644 --- a/drivers/watchdog/Kconfig +++ b/drivers/watchdog/Kconfig @@ -221,15 +221,6 @@ config DW_WATCHDOG To compile this driver as a module, choose M here: the module will be called dw_wdt. -config MPCORE_WATCHDOG - tristate "MPcore watchdog" - depends on HAVE_ARM_TWD - help - Watchdog timer embedded into the MPcore system. - - To compile this driver as a module, choose M here: the - module will be called mpcore_wdt. - config EP93XX_WATCHDOG tristate "EP93xx Watchdog" depends on ARCH_EP93XX diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile index ec268995b261..291828b356c5 100644 --- a/drivers/watchdog/Makefile +++ b/drivers/watchdog/Makefile @@ -41,7 +41,6 @@ obj-$(CONFIG_KS8695_WATCHDOG) += ks8695_wdt.o obj-$(CONFIG_S3C2410_WATCHDOG) += s3c2410_wdt.o obj-$(CONFIG_SA1100_WATCHDOG) += sa1100_wdt.o obj-$(CONFIG_DW_WATCHDOG) += dw_wdt.o -obj-$(CONFIG_MPCORE_WATCHDOG) += mpcore_wdt.o obj-$(CONFIG_EP93XX_WATCHDOG) += ep93xx_wdt.o obj-$(CONFIG_PNX4008_WATCHDOG) += pnx4008_wdt.o obj-$(CONFIG_IOP_WATCHDOG) += iop_wdt.o diff --git a/drivers/watchdog/mpcore_wdt.c b/drivers/watchdog/mpcore_wdt.c deleted file mode 100644 index 4f5ac408c7a3..000000000000 --- a/drivers/watchdog/mpcore_wdt.c +++ /dev/null @@ -1,454 +0,0 @@ -/* - * Watchdog driver for the mpcore watchdog timer - * - * (c) Copyright 2004 ARM Limited - * - * Based on the SoftDog driver: - * (c) Copyright 1996 Alan Cox , - * All Rights Reserved. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version - * 2 of the License, or (at your option) any later version. - * - * Neither Alan Cox nor CymruNet Ltd. admit liability nor provide - * warranty for any of this software. This material is provided - * "AS-IS" and at no charge. - * - * (c) Copyright 1995 Alan Cox - * - */ - -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -struct mpcore_wdt { - unsigned long timer_alive; - struct device *dev; - void __iomem *base; - int irq; - unsigned int perturb; - char expect_close; -}; - -static struct platform_device *mpcore_wdt_pdev; -static DEFINE_SPINLOCK(wdt_lock); - -#define TIMER_MARGIN 60 -static int mpcore_margin = TIMER_MARGIN; -module_param(mpcore_margin, int, 0); -MODULE_PARM_DESC(mpcore_margin, - "MPcore timer margin in seconds. (0 < mpcore_margin < 65536, default=" - __MODULE_STRING(TIMER_MARGIN) ")"); - -static bool nowayout = WATCHDOG_NOWAYOUT; -module_param(nowayout, bool, 0); -MODULE_PARM_DESC(nowayout, - "Watchdog cannot be stopped once started (default=" - __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); - -#define ONLY_TESTING 0 -static int mpcore_noboot = ONLY_TESTING; -module_param(mpcore_noboot, int, 0); -MODULE_PARM_DESC(mpcore_noboot, "MPcore watchdog action, " - "set to 1 to ignore reboots, 0 to reboot (default=" - __MODULE_STRING(ONLY_TESTING) ")"); - -/* - * This is the interrupt handler. Note that we only use this - * in testing mode, so don't actually do a reboot here. - */ -static irqreturn_t mpcore_wdt_fire(int irq, void *arg) -{ - struct mpcore_wdt *wdt = arg; - - /* Check it really was our interrupt */ - if (readl(wdt->base + TWD_WDOG_INTSTAT)) { - dev_crit(wdt->dev, "Triggered - Reboot ignored\n"); - /* Clear the interrupt on the watchdog */ - writel(1, wdt->base + TWD_WDOG_INTSTAT); - return IRQ_HANDLED; - } - return IRQ_NONE; -} - -/* - * mpcore_wdt_keepalive - reload the timer - * - * Note that the spec says a DIFFERENT value must be written to the reload - * register each time. The "perturb" variable deals with this by adding 1 - * to the count every other time the function is called. - */ -static void mpcore_wdt_keepalive(struct mpcore_wdt *wdt) -{ - unsigned long count; - - spin_lock(&wdt_lock); - /* Assume prescale is set to 256 */ - count = __raw_readl(wdt->base + TWD_WDOG_COUNTER); - count = (0xFFFFFFFFU - count) * (HZ / 5); - count = (count / 256) * mpcore_margin; - - /* Reload the counter */ - writel(count + wdt->perturb, wdt->base + TWD_WDOG_LOAD); - wdt->perturb = wdt->perturb ? 0 : 1; - spin_unlock(&wdt_lock); -} - -static void mpcore_wdt_stop(struct mpcore_wdt *wdt) -{ - spin_lock(&wdt_lock); - writel(0x12345678, wdt->base + TWD_WDOG_DISABLE); - writel(0x87654321, wdt->base + TWD_WDOG_DISABLE); - writel(0x0, wdt->base + TWD_WDOG_CONTROL); - spin_unlock(&wdt_lock); -} - -static void mpcore_wdt_start(struct mpcore_wdt *wdt) -{ - dev_info(wdt->dev, "enabling watchdog\n"); - - /* This loads the count register but does NOT start the count yet */ - mpcore_wdt_keepalive(wdt); - - if (mpcore_noboot) { - /* Enable watchdog - prescale=256, watchdog mode=0, enable=1 */ - writel(0x0000FF01, wdt->base + TWD_WDOG_CONTROL); - } else { - /* Enable watchdog - prescale=256, watchdog mode=1, enable=1 */ - writel(0x0000FF09, wdt->base + TWD_WDOG_CONTROL); - } -} - -static int mpcore_wdt_set_heartbeat(int t) -{ - if (t < 0x0001 || t > 0xFFFF) - return -EINVAL; - - mpcore_margin = t; - return 0; -} - -/* - * /dev/watchdog handling - */ -static int mpcore_wdt_open(struct inode *inode, struct file *file) -{ - struct mpcore_wdt *wdt = platform_get_drvdata(mpcore_wdt_pdev); - - if (test_and_set_bit(0, &wdt->timer_alive)) - return -EBUSY; - - if (nowayout) - __module_get(THIS_MODULE); - - file->private_data = wdt; - - /* - * Activate timer - */ - mpcore_wdt_start(wdt); - - return nonseekable_open(inode, file); -} - -static int mpcore_wdt_release(struct inode *inode, struct file *file) -{ - struct mpcore_wdt *wdt = file->private_data; - - /* - * Shut off the timer. - * Lock it in if it's a module and we set nowayout - */ - if (wdt->expect_close == 42) - mpcore_wdt_stop(wdt); - else { - dev_crit(wdt->dev, - "unexpected close, not stopping watchdog!\n"); - mpcore_wdt_keepalive(wdt); - } - clear_bit(0, &wdt->timer_alive); - wdt->expect_close = 0; - return 0; -} - -static ssize_t mpcore_wdt_write(struct file *file, const char *data, - size_t len, loff_t *ppos) -{ - struct mpcore_wdt *wdt = file->private_data; - - /* - * Refresh the timer. - */ - if (len) { - if (!nowayout) { - size_t i; - - /* In case it was set long ago */ - wdt->expect_close = 0; - - for (i = 0; i != len; i++) { - char c; - - if (get_user(c, data + i)) - return -EFAULT; - if (c == 'V') - wdt->expect_close = 42; - } - } - mpcore_wdt_keepalive(wdt); - } - return len; -} - -static const struct watchdog_info ident = { - .options = WDIOF_SETTIMEOUT | - WDIOF_KEEPALIVEPING | - WDIOF_MAGICCLOSE, - .identity = "MPcore Watchdog", -}; - -static long mpcore_wdt_ioctl(struct file *file, unsigned int cmd, - unsigned long arg) -{ - struct mpcore_wdt *wdt = file->private_data; - int ret; - union { - struct watchdog_info ident; - int i; - } uarg; - - if (_IOC_DIR(cmd) && _IOC_SIZE(cmd) > sizeof(uarg)) - return -ENOTTY; - - if (_IOC_DIR(cmd) & _IOC_WRITE) { - ret = copy_from_user(&uarg, (void __user *)arg, _IOC_SIZE(cmd)); - if (ret) - return -EFAULT; - } - - switch (cmd) { - case WDIOC_GETSUPPORT: - uarg.ident = ident; - ret = 0; - break; - - case WDIOC_GETSTATUS: - case WDIOC_GETBOOTSTATUS: - uarg.i = 0; - ret = 0; - break; - - case WDIOC_SETOPTIONS: - ret = -EINVAL; - if (uarg.i & WDIOS_DISABLECARD) { - mpcore_wdt_stop(wdt); - ret = 0; - } - if (uarg.i & WDIOS_ENABLECARD) { - mpcore_wdt_start(wdt); - ret = 0; - } - break; - - case WDIOC_KEEPALIVE: - mpcore_wdt_keepalive(wdt); - ret = 0; - break; - - case WDIOC_SETTIMEOUT: - ret = mpcore_wdt_set_heartbeat(uarg.i); - if (ret) - break; - - mpcore_wdt_keepalive(wdt); - /* Fall */ - case WDIOC_GETTIMEOUT: - uarg.i = mpcore_margin; - ret = 0; - break; - - default: - return -ENOTTY; - } - - if (ret == 0 && _IOC_DIR(cmd) & _IOC_READ) { - ret = copy_to_user((void __user *)arg, &uarg, _IOC_SIZE(cmd)); - if (ret) - ret = -EFAULT; - } - return ret; -} - -/* - * System shutdown handler. Turn off the watchdog if we're - * restarting or halting the system. - */ -static void mpcore_wdt_shutdown(struct platform_device *pdev) -{ - struct mpcore_wdt *wdt = platform_get_drvdata(pdev); - - if (system_state == SYSTEM_RESTART || system_state == SYSTEM_HALT) - mpcore_wdt_stop(wdt); -} - -/* - * Kernel Interfaces - */ -static const struct file_operations mpcore_wdt_fops = { - .owner = THIS_MODULE, - .llseek = no_llseek, - .write = mpcore_wdt_write, - .unlocked_ioctl = mpcore_wdt_ioctl, - .open = mpcore_wdt_open, - .release = mpcore_wdt_release, -}; - -static struct miscdevice mpcore_wdt_miscdev = { - .minor = WATCHDOG_MINOR, - .name = "watchdog", - .fops = &mpcore_wdt_fops, -}; - -static int mpcore_wdt_probe(struct platform_device *pdev) -{ - struct mpcore_wdt *wdt; - struct resource *res; - int ret; - - /* We only accept one device, and it must have an id of -1 */ - if (pdev->id != -1) - return -ENODEV; - - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (!res) - return -ENODEV; - - wdt = devm_kzalloc(&pdev->dev, sizeof(struct mpcore_wdt), GFP_KERNEL); - if (!wdt) - return -ENOMEM; - - wdt->dev = &pdev->dev; - wdt->irq = platform_get_irq(pdev, 0); - if (wdt->irq >= 0) { - ret = devm_request_irq(wdt->dev, wdt->irq, mpcore_wdt_fire, 0, - "mpcore_wdt", wdt); - if (ret) { - dev_err(wdt->dev, - "cannot register IRQ%d for watchdog\n", - wdt->irq); - return ret; - } - } - - wdt->base = devm_ioremap(wdt->dev, res->start, resource_size(res)); - if (!wdt->base) - return -ENOMEM; - - mpcore_wdt_miscdev.parent = &pdev->dev; - ret = misc_register(&mpcore_wdt_miscdev); - if (ret) { - dev_err(wdt->dev, - "cannot register miscdev on minor=%d (err=%d)\n", - WATCHDOG_MINOR, ret); - return ret; - } - - mpcore_wdt_stop(wdt); - platform_set_drvdata(pdev, wdt); - mpcore_wdt_pdev = pdev; - - return 0; -} - -static int mpcore_wdt_remove(struct platform_device *pdev) -{ - misc_deregister(&mpcore_wdt_miscdev); - - mpcore_wdt_pdev = NULL; - - return 0; -} - -#ifdef CONFIG_PM -static int mpcore_wdt_suspend(struct platform_device *pdev, pm_message_t msg) -{ - struct mpcore_wdt *wdt = platform_get_drvdata(pdev); - mpcore_wdt_stop(wdt); /* Turn the WDT off */ - return 0; -} - -static int mpcore_wdt_resume(struct platform_device *pdev) -{ - struct mpcore_wdt *wdt = platform_get_drvdata(pdev); - /* re-activate timer */ - if (test_bit(0, &wdt->timer_alive)) - mpcore_wdt_start(wdt); - return 0; -} -#else -#define mpcore_wdt_suspend NULL -#define mpcore_wdt_resume NULL -#endif - -/* work with hotplug and coldplug */ -MODULE_ALIAS("platform:mpcore_wdt"); - -static struct platform_driver mpcore_wdt_driver = { - .probe = mpcore_wdt_probe, - .remove = mpcore_wdt_remove, - .suspend = mpcore_wdt_suspend, - .resume = mpcore_wdt_resume, - .shutdown = mpcore_wdt_shutdown, - .driver = { - .owner = THIS_MODULE, - .name = "mpcore_wdt", - }, -}; - -static int __init mpcore_wdt_init(void) -{ - /* - * Check that the margin value is within it's range; - * if not reset to the default - */ - if (mpcore_wdt_set_heartbeat(mpcore_margin)) { - mpcore_wdt_set_heartbeat(TIMER_MARGIN); - pr_info("mpcore_margin value must be 0 < mpcore_margin < 65536, using %d\n", - TIMER_MARGIN); - } - - pr_info("MPcore Watchdog Timer: 0.1. mpcore_noboot=%d mpcore_margin=%d sec (nowayout= %d)\n", - mpcore_noboot, mpcore_margin, nowayout); - - return platform_driver_register(&mpcore_wdt_driver); -} - -static void __exit mpcore_wdt_exit(void) -{ - platform_driver_unregister(&mpcore_wdt_driver); -} - -module_init(mpcore_wdt_init); -module_exit(mpcore_wdt_exit); - -MODULE_AUTHOR("ARM Limited"); -MODULE_DESCRIPTION("MPcore Watchdog Device Driver"); -MODULE_LICENSE("GPL"); -MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR); From 87f1369d6e2e820c77cf9eac542eed4dcf036f64 Mon Sep 17 00:00:00 2001 From: Paolo Valente Date: Wed, 10 Jul 2013 15:46:08 +0200 Subject: [PATCH 0819/1048] pkt_sched: sch_qfq: improve efficiency of make_eligible In make_eligible, a mask is used to decide which groups must become eligible: the i-th group becomes eligible only if the i-th bit of the mask (from the right) is set. The mask is computed by left-shifting a 1 by a given number of places, and decrementing the result. The shift is performed on a ULL to avoid problems in case the number of places to shift is higher than 31. On a 32-bit machine, this is more costly than working on an UL. This patch replaces such a costly operation with two cheaper branches. The trick is based on the following fact: in case of a shift of at least 32 places, the resulting mask has at least the 32 less significant bits set, whereas the total number of groups is lower than 32. As a consequence, in this case it is enough to just set the 32 less significant bits of the mask with a cheaper ~0UL. In the other case, the shift can be safely performed on a UL. Reported-by: David S. Miller Reported-by: David Laight Signed-off-by: Paolo Valente Signed-off-by: David S. Miller --- net/sched/sch_qfq.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/net/sched/sch_qfq.c b/net/sched/sch_qfq.c index 7c195d972bf0..8d86a8b5522a 100644 --- a/net/sched/sch_qfq.c +++ b/net/sched/sch_qfq.c @@ -821,7 +821,14 @@ static void qfq_make_eligible(struct qfq_sched *q) unsigned long old_vslot = q->oldV >> q->min_slot_shift; if (vslot != old_vslot) { - unsigned long mask = (1ULL << fls(vslot ^ old_vslot)) - 1; + unsigned long mask; + int last_flip_pos = fls(vslot ^ old_vslot); + + if (last_flip_pos > 31) /* higher than the number of groups */ + mask = ~0UL; /* make all groups eligible */ + else + mask = (1UL << last_flip_pos) - 1; + qfq_move_groups(q, mask, IR, ER); qfq_move_groups(q, mask, IB, EB); } From 88d4f419a43b474a4524f41f55c36bee13416bdd Mon Sep 17 00:00:00 2001 From: Paolo Valente Date: Wed, 10 Jul 2013 15:46:09 +0200 Subject: [PATCH 0820/1048] pkt_sched: sch_qfq: remove forward declaration of qfq_update_agg_ts This patch removes the forward declaration of qfq_update_agg_ts, by moving the definition of the function above its first call. This patch also removes a useless forward declaration of qfq_schedule_agg. Reported-by: David S. Miller Signed-off-by: Paolo Valente Signed-off-by: David S. Miller --- net/sched/sch_qfq.c | 118 +++++++++++++++++++++----------------------- 1 file changed, 55 insertions(+), 63 deletions(-) diff --git a/net/sched/sch_qfq.c b/net/sched/sch_qfq.c index 8d86a8b5522a..a7ab323849b6 100644 --- a/net/sched/sch_qfq.c +++ b/net/sched/sch_qfq.c @@ -1010,9 +1010,61 @@ static inline void charge_actual_service(struct qfq_aggregate *agg) agg->F = agg->S + (u64)service_received * agg->inv_w; } -static inline void qfq_update_agg_ts(struct qfq_sched *q, - struct qfq_aggregate *agg, - enum update_reason reason); +/* Assign a reasonable start time for a new aggregate in group i. + * Admissible values for \hat(F) are multiples of \sigma_i + * no greater than V+\sigma_i . Larger values mean that + * we had a wraparound so we consider the timestamp to be stale. + * + * If F is not stale and F >= V then we set S = F. + * Otherwise we should assign S = V, but this may violate + * the ordering in EB (see [2]). So, if we have groups in ER, + * set S to the F_j of the first group j which would be blocking us. + * We are guaranteed not to move S backward because + * otherwise our group i would still be blocked. + */ +static void qfq_update_start(struct qfq_sched *q, struct qfq_aggregate *agg) +{ + unsigned long mask; + u64 limit, roundedF; + int slot_shift = agg->grp->slot_shift; + + roundedF = qfq_round_down(agg->F, slot_shift); + limit = qfq_round_down(q->V, slot_shift) + (1ULL << slot_shift); + + if (!qfq_gt(agg->F, q->V) || qfq_gt(roundedF, limit)) { + /* timestamp was stale */ + mask = mask_from(q->bitmaps[ER], agg->grp->index); + if (mask) { + struct qfq_group *next = qfq_ffs(q, mask); + if (qfq_gt(roundedF, next->F)) { + if (qfq_gt(limit, next->F)) + agg->S = next->F; + else /* preserve timestamp correctness */ + agg->S = limit; + return; + } + } + agg->S = q->V; + } else /* timestamp is not stale */ + agg->S = agg->F; +} + +/* Update the timestamps of agg before scheduling/rescheduling it for + * service. In particular, assign to agg->F its maximum possible + * value, i.e., the virtual finish time with which the aggregate + * should be labeled if it used all its budget once in service. + */ +static inline void +qfq_update_agg_ts(struct qfq_sched *q, + struct qfq_aggregate *agg, enum update_reason reason) +{ + if (reason != requeue) + qfq_update_start(q, agg); + else /* just charge agg for the service received */ + agg->S = agg->F; + + agg->F = agg->S + (u64)agg->budgetmax * agg->inv_w; +} static void qfq_schedule_agg(struct qfq_sched *q, struct qfq_aggregate *agg); @@ -1135,66 +1187,6 @@ static struct qfq_aggregate *qfq_choose_next_agg(struct qfq_sched *q) return agg; } -/* - * Assign a reasonable start time for a new aggregate in group i. - * Admissible values for \hat(F) are multiples of \sigma_i - * no greater than V+\sigma_i . Larger values mean that - * we had a wraparound so we consider the timestamp to be stale. - * - * If F is not stale and F >= V then we set S = F. - * Otherwise we should assign S = V, but this may violate - * the ordering in EB (see [2]). So, if we have groups in ER, - * set S to the F_j of the first group j which would be blocking us. - * We are guaranteed not to move S backward because - * otherwise our group i would still be blocked. - */ -static void qfq_update_start(struct qfq_sched *q, struct qfq_aggregate *agg) -{ - unsigned long mask; - u64 limit, roundedF; - int slot_shift = agg->grp->slot_shift; - - roundedF = qfq_round_down(agg->F, slot_shift); - limit = qfq_round_down(q->V, slot_shift) + (1ULL << slot_shift); - - if (!qfq_gt(agg->F, q->V) || qfq_gt(roundedF, limit)) { - /* timestamp was stale */ - mask = mask_from(q->bitmaps[ER], agg->grp->index); - if (mask) { - struct qfq_group *next = qfq_ffs(q, mask); - if (qfq_gt(roundedF, next->F)) { - if (qfq_gt(limit, next->F)) - agg->S = next->F; - else /* preserve timestamp correctness */ - agg->S = limit; - return; - } - } - agg->S = q->V; - } else /* timestamp is not stale */ - agg->S = agg->F; -} - -/* - * Update the timestamps of agg before scheduling/rescheduling it for - * service. In particular, assign to agg->F its maximum possible - * value, i.e., the virtual finish time with which the aggregate - * should be labeled if it used all its budget once in service. - */ -static inline void -qfq_update_agg_ts(struct qfq_sched *q, - struct qfq_aggregate *agg, enum update_reason reason) -{ - if (reason != requeue) - qfq_update_start(q, agg); - else /* just charge agg for the service received */ - agg->S = agg->F; - - agg->F = agg->S + (u64)agg->budgetmax * agg->inv_w; -} - -static void qfq_schedule_agg(struct qfq_sched *, struct qfq_aggregate *); - static int qfq_enqueue(struct sk_buff *skb, struct Qdisc *sch) { struct qfq_sched *q = qdisc_priv(sch); From 938d0a840d0f97b627111fd038a735f3924fd987 Mon Sep 17 00:00:00 2001 From: Lubomir Rintel Date: Tue, 18 Jun 2013 19:44:48 +0200 Subject: [PATCH 0821/1048] watchdog: Add Broadcom BCM2835 watchdog timer driver This adds a driver for watchdog timer hardware present on Broadcom BCM2835 SoC, used in Raspberry Pi and Roku 2 devices. Signed-off-by: Lubomir Rintel Tested-by: Stephen Warren Reviewed-by: Guenter Roeck Signed-off-by: Wim Van Sebroeck Cc: linux-rpi-kernel@lists.infradead.org Cc: linux-watchdog@vger.kernel.org Cc: devicetree-discuss@lists.ozlabs.org --- .../watchdog/brcm,bcm2835-pm-wdog.txt | 5 + drivers/watchdog/Kconfig | 11 + drivers/watchdog/Makefile | 1 + drivers/watchdog/bcm2835_wdt.c | 189 ++++++++++++++++++ 4 files changed, 206 insertions(+) create mode 100644 drivers/watchdog/bcm2835_wdt.c diff --git a/Documentation/devicetree/bindings/watchdog/brcm,bcm2835-pm-wdog.txt b/Documentation/devicetree/bindings/watchdog/brcm,bcm2835-pm-wdog.txt index d209366b4a69..f801d71de1cd 100644 --- a/Documentation/devicetree/bindings/watchdog/brcm,bcm2835-pm-wdog.txt +++ b/Documentation/devicetree/bindings/watchdog/brcm,bcm2835-pm-wdog.txt @@ -5,9 +5,14 @@ Required properties: - compatible : should be "brcm,bcm2835-pm-wdt" - reg : Specifies base physical address and size of the registers. +Optional properties: + +- timeout-sec : Contains the watchdog timeout in seconds + Example: watchdog { compatible = "brcm,bcm2835-pm-wdt"; reg = <0x7e100000 0x28>; + timeout-sec = <10>; }; diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig index 6042e9ed542c..f17ffdb75bb0 100644 --- a/drivers/watchdog/Kconfig +++ b/drivers/watchdog/Kconfig @@ -1100,6 +1100,17 @@ config BCM63XX_WDT To compile this driver as a loadable module, choose M here. The module will be called bcm63xx_wdt. +config BCM2835_WDT + tristate "Broadcom BCM2835 hardware watchdog" + depends on ARCH_BCM2835 + select WATCHDOG_CORE + help + Watchdog driver for the built in watchdog hardware in Broadcom + BCM2835 SoC. + + To compile this driver as a loadable module, choose M here. + The module will be called bcm2835_wdt. + config LANTIQ_WDT tristate "Lantiq SoC watchdog" depends on LANTIQ diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile index 291828b356c5..c443f6247fa6 100644 --- a/drivers/watchdog/Makefile +++ b/drivers/watchdog/Makefile @@ -53,6 +53,7 @@ obj-$(CONFIG_TS72XX_WATCHDOG) += ts72xx_wdt.o obj-$(CONFIG_IMX2_WDT) += imx2_wdt.o obj-$(CONFIG_UX500_WATCHDOG) += ux500_wdt.o obj-$(CONFIG_RETU_WATCHDOG) += retu_wdt.o +obj-$(CONFIG_BCM2835_WDT) += bcm2835_wdt.o # AVR32 Architecture obj-$(CONFIG_AT32AP700X_WDT) += at32ap700x_wdt.o diff --git a/drivers/watchdog/bcm2835_wdt.c b/drivers/watchdog/bcm2835_wdt.c new file mode 100644 index 000000000000..61566fc47f84 --- /dev/null +++ b/drivers/watchdog/bcm2835_wdt.c @@ -0,0 +1,189 @@ +/* + * Watchdog driver for Broadcom BCM2835 + * + * "bcm2708_wdog" driver written by Luke Diamand that was obtained from + * branch "rpi-3.6.y" of git://github.com/raspberrypi/linux.git was used + * as a hardware reference for the Broadcom BCM2835 watchdog timer. + * + * Copyright (C) 2013 Lubomir Rintel + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + */ + +#include +#include +#include +#include +#include +#include +#include + +#define PM_RSTC 0x1c +#define PM_WDOG 0x24 + +#define PM_PASSWORD 0x5a000000 + +#define PM_WDOG_TIME_SET 0x000fffff +#define PM_RSTC_WRCFG_CLR 0xffffffcf +#define PM_RSTC_WRCFG_SET 0x00000030 +#define PM_RSTC_WRCFG_FULL_RESET 0x00000020 +#define PM_RSTC_RESET 0x00000102 + +#define SECS_TO_WDOG_TICKS(x) ((x) << 16) +#define WDOG_TICKS_TO_SECS(x) ((x) >> 16) + +struct bcm2835_wdt { + void __iomem *base; + spinlock_t lock; +}; + +static unsigned int heartbeat; +static bool nowayout = WATCHDOG_NOWAYOUT; + +static int bcm2835_wdt_start(struct watchdog_device *wdog) +{ + struct bcm2835_wdt *wdt = watchdog_get_drvdata(wdog); + uint32_t cur; + unsigned long flags; + + spin_lock_irqsave(&wdt->lock, flags); + + writel_relaxed(PM_PASSWORD | (SECS_TO_WDOG_TICKS(wdog->timeout) & + PM_WDOG_TIME_SET), wdt->base + PM_WDOG); + cur = readl_relaxed(wdt->base + PM_RSTC); + writel_relaxed(PM_PASSWORD | (cur & PM_RSTC_WRCFG_CLR) | + PM_RSTC_WRCFG_FULL_RESET, wdt->base + PM_RSTC); + + spin_unlock_irqrestore(&wdt->lock, flags); + + return 0; +} + +static int bcm2835_wdt_stop(struct watchdog_device *wdog) +{ + struct bcm2835_wdt *wdt = watchdog_get_drvdata(wdog); + + writel_relaxed(PM_PASSWORD | PM_RSTC_RESET, wdt->base + PM_RSTC); + dev_info(wdog->dev, "Watchdog timer stopped"); + return 0; +} + +static int bcm2835_wdt_set_timeout(struct watchdog_device *wdog, unsigned int t) +{ + wdog->timeout = t; + return 0; +} + +static unsigned int bcm2835_wdt_get_timeleft(struct watchdog_device *wdog) +{ + struct bcm2835_wdt *wdt = watchdog_get_drvdata(wdog); + + uint32_t ret = readl_relaxed(wdt->base + PM_WDOG); + return WDOG_TICKS_TO_SECS(ret & PM_WDOG_TIME_SET); +} + +static struct watchdog_ops bcm2835_wdt_ops = { + .owner = THIS_MODULE, + .start = bcm2835_wdt_start, + .stop = bcm2835_wdt_stop, + .set_timeout = bcm2835_wdt_set_timeout, + .get_timeleft = bcm2835_wdt_get_timeleft, +}; + +static struct watchdog_info bcm2835_wdt_info = { + .options = WDIOF_SETTIMEOUT | WDIOF_MAGICCLOSE | + WDIOF_KEEPALIVEPING, + .identity = "Broadcom BCM2835 Watchdog timer", +}; + +static struct watchdog_device bcm2835_wdt_wdd = { + .info = &bcm2835_wdt_info, + .ops = &bcm2835_wdt_ops, + .min_timeout = 1, + .max_timeout = WDOG_TICKS_TO_SECS(PM_WDOG_TIME_SET), + .timeout = WDOG_TICKS_TO_SECS(PM_WDOG_TIME_SET), +}; + +static int bcm2835_wdt_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct device_node *np = dev->of_node; + struct bcm2835_wdt *wdt; + int err; + + wdt = devm_kzalloc(dev, sizeof(struct bcm2835_wdt), GFP_KERNEL); + if (!wdt) { + dev_err(dev, "Failed to allocate memory for watchdog device"); + return -ENOMEM; + } + platform_set_drvdata(pdev, wdt); + + spin_lock_init(&wdt->lock); + + wdt->base = of_iomap(np, 0); + if (!wdt->base) { + dev_err(dev, "Failed to remap watchdog regs"); + return -ENODEV; + } + + watchdog_set_drvdata(&bcm2835_wdt_wdd, wdt); + watchdog_init_timeout(&bcm2835_wdt_wdd, heartbeat, dev); + watchdog_set_nowayout(&bcm2835_wdt_wdd, nowayout); + err = watchdog_register_device(&bcm2835_wdt_wdd); + if (err) { + dev_err(dev, "Failed to register watchdog device"); + iounmap(wdt->base); + return err; + } + + dev_info(dev, "Broadcom BCM2835 watchdog timer"); + return 0; +} + +static int bcm2835_wdt_remove(struct platform_device *pdev) +{ + struct bcm2835_wdt *wdt = platform_get_drvdata(pdev); + + watchdog_unregister_device(&bcm2835_wdt_wdd); + iounmap(wdt->base); + + return 0; +} + +static void bcm2835_wdt_shutdown(struct platform_device *pdev) +{ + bcm2835_wdt_stop(&bcm2835_wdt_wdd); +} + +static const struct of_device_id bcm2835_wdt_of_match[] = { + { .compatible = "brcm,bcm2835-pm-wdt", }, + {}, +}; +MODULE_DEVICE_TABLE(of, bcm2835_wdt_of_match); + +static struct platform_driver bcm2835_wdt_driver = { + .probe = bcm2835_wdt_probe, + .remove = bcm2835_wdt_remove, + .shutdown = bcm2835_wdt_shutdown, + .driver = { + .name = "bcm2835-wdt", + .owner = THIS_MODULE, + .of_match_table = bcm2835_wdt_of_match, + }, +}; +module_platform_driver(bcm2835_wdt_driver); + +module_param(heartbeat, uint, 0); +MODULE_PARM_DESC(heartbeat, "Initial watchdog heartbeat in seconds"); + +module_param(nowayout, bool, 0); +MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" + __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); + +MODULE_AUTHOR("Lubomir Rintel "); +MODULE_DESCRIPTION("Driver for Broadcom BCM2835 watchdog timer"); +MODULE_LICENSE("GPL"); +MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR); From fa142ff5b3f67fab01f3d02a501b041b4266afdd Mon Sep 17 00:00:00 2001 From: Russell King Date: Tue, 18 Jun 2013 17:19:32 +0100 Subject: [PATCH 0822/1048] Watchdog: allow orion_wdt to be built for Dove The watchdog infrastructure in Dove is no different from that in Orion5x or Kirkwood, so let's enable it for Dove. The only things missing are a few register settings in Dove's bridge-regs.h. Rather than duplicating the same register bit masks for the RSTOUTn_MASK and BRIDGE_CAUSE registers, move the definitions into the watchdog driver itself. Signed-off-by: Russell King Acked-by: Jason Cooper Tested-by: Andrew Lunn Signed-off-by: Wim Van Sebroeck --- arch/arm/mach-dove/include/mach/bridge-regs.h | 1 + arch/arm/mach-kirkwood/include/mach/bridge-regs.h | 2 -- arch/arm/mach-orion5x/include/mach/bridge-regs.h | 3 --- drivers/watchdog/Kconfig | 2 +- drivers/watchdog/orion_wdt.c | 3 +++ 5 files changed, 5 insertions(+), 6 deletions(-) diff --git a/arch/arm/mach-dove/include/mach/bridge-regs.h b/arch/arm/mach-dove/include/mach/bridge-regs.h index 99f259e8cf33..5362df3df89f 100644 --- a/arch/arm/mach-dove/include/mach/bridge-regs.h +++ b/arch/arm/mach-dove/include/mach/bridge-regs.h @@ -26,6 +26,7 @@ #define SYSTEM_SOFT_RESET (BRIDGE_VIRT_BASE + 0x010c) #define SOFT_RESET 0x00000001 +#define BRIDGE_CAUSE (BRIDGE_VIRT_BASE + 0x0110) #define BRIDGE_INT_TIMER1_CLR (~0x0004) #define IRQ_VIRT_BASE (BRIDGE_VIRT_BASE + 0x0200) diff --git a/arch/arm/mach-kirkwood/include/mach/bridge-regs.h b/arch/arm/mach-kirkwood/include/mach/bridge-regs.h index d4cbe5e81bb4..91242c944d7a 100644 --- a/arch/arm/mach-kirkwood/include/mach/bridge-regs.h +++ b/arch/arm/mach-kirkwood/include/mach/bridge-regs.h @@ -21,14 +21,12 @@ #define CPU_RESET 0x00000002 #define RSTOUTn_MASK (BRIDGE_VIRT_BASE + 0x0108) -#define WDT_RESET_OUT_EN 0x00000002 #define SOFT_RESET_OUT_EN 0x00000004 #define SYSTEM_SOFT_RESET (BRIDGE_VIRT_BASE + 0x010c) #define SOFT_RESET 0x00000001 #define BRIDGE_CAUSE (BRIDGE_VIRT_BASE + 0x0110) -#define WDT_INT_REQ 0x0008 #define BRIDGE_INT_TIMER1_CLR (~0x0004) diff --git a/arch/arm/mach-orion5x/include/mach/bridge-regs.h b/arch/arm/mach-orion5x/include/mach/bridge-regs.h index 461fd69a10ae..f727d03f1688 100644 --- a/arch/arm/mach-orion5x/include/mach/bridge-regs.h +++ b/arch/arm/mach-orion5x/include/mach/bridge-regs.h @@ -18,7 +18,6 @@ #define CPU_CTRL (ORION5X_BRIDGE_VIRT_BASE + 0x104) #define RSTOUTn_MASK (ORION5X_BRIDGE_VIRT_BASE + 0x108) -#define WDT_RESET_OUT_EN 0x0002 #define CPU_SOFT_RESET (ORION5X_BRIDGE_VIRT_BASE + 0x10c) @@ -26,8 +25,6 @@ #define POWER_MNG_CTRL_REG (ORION5X_BRIDGE_VIRT_BASE + 0x11C) -#define WDT_INT_REQ 0x0008 - #define BRIDGE_INT_TIMER1_CLR (~0x0004) #define MAIN_IRQ_CAUSE (ORION5X_BRIDGE_VIRT_BASE + 0x200) diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig index f17ffdb75bb0..b69e4821d668 100644 --- a/drivers/watchdog/Kconfig +++ b/drivers/watchdog/Kconfig @@ -282,7 +282,7 @@ config DAVINCI_WATCHDOG config ORION_WATCHDOG tristate "Orion watchdog" - depends on ARCH_ORION5X || ARCH_KIRKWOOD + depends on ARCH_ORION5X || ARCH_KIRKWOOD || ARCH_DOVE select WATCHDOG_CORE help Say Y here if to include support for the watchdog timer diff --git a/drivers/watchdog/orion_wdt.c b/drivers/watchdog/orion_wdt.c index da577980d390..4074244c7183 100644 --- a/drivers/watchdog/orion_wdt.c +++ b/drivers/watchdog/orion_wdt.c @@ -38,6 +38,9 @@ #define WDT_IN_USE 0 #define WDT_OK_TO_CLOSE 1 +#define WDT_RESET_OUT_EN BIT(1) +#define WDT_INT_REQ BIT(3) + static bool nowayout = WATCHDOG_NOWAYOUT; static int heartbeat = -1; /* module parameter (seconds) */ static unsigned int wdt_max_duration; /* (seconds) */ From 6910ceb5cababfefffc4ddc58a085a71c0ab9f22 Mon Sep 17 00:00:00 2001 From: Russell King Date: Tue, 18 Jun 2013 17:20:32 +0100 Subject: [PATCH 0823/1048] Watchdog: fix clearing of the watchdog interrupt The bits in BRIDGE_CAUSE are documented as RW0C - read, write 0 to clear. If we read the register, mask off the watchdog bit, and write it back, we're actually clearing every interrupt which wasn't pending at the time we read the register - and that is racy. Fix this to only write ~WATCHDOG_BIT to the register, which means we write as zero only the watchdog bit. Signed-off-by: Russell King Acked-by: Jason Cooper Tested-by: Andrew Lunn Signed-off-by: Wim Van Sebroeck --- drivers/watchdog/orion_wdt.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/watchdog/orion_wdt.c b/drivers/watchdog/orion_wdt.c index 4074244c7183..4ea5fcccac02 100644 --- a/drivers/watchdog/orion_wdt.c +++ b/drivers/watchdog/orion_wdt.c @@ -70,9 +70,7 @@ static int orion_wdt_start(struct watchdog_device *wdt_dev) writel(wdt_tclk * wdt_dev->timeout, wdt_reg + WDT_VAL); /* Clear watchdog timer interrupt */ - reg = readl(BRIDGE_CAUSE); - reg &= ~WDT_INT_REQ; - writel(reg, BRIDGE_CAUSE); + writel(~WDT_INT_REQ, BRIDGE_CAUSE); /* Enable watchdog timer */ reg = readl(wdt_reg + TIMER_CTRL); From 26c57ef1ea35f2e7b73db5fad3c81c388d6d056a Mon Sep 17 00:00:00 2001 From: Johannes Thumshirn Date: Tue, 18 Jun 2013 17:19:45 +0200 Subject: [PATCH 0824/1048] watchdog: New watchdog driver for MEN A21 watchdogs This patch adds the driver for the watchdog devices found on MEN Mikro Elektronik A21 VMEbus CPU Carrier Boards. It has DT-support and uses the watchdog framework. Signed-off-by: Johannes Thumshirn Reviewed-by: Guenter Roeck Signed-off-by: Wim Van Sebroeck --- .../devicetree/bindings/gpio/men-a021-wdt.txt | 25 ++ MAINTAINERS | 6 + drivers/watchdog/Kconfig | 12 + drivers/watchdog/Makefile | 1 + drivers/watchdog/mena21_wdt.c | 270 ++++++++++++++++++ 5 files changed, 314 insertions(+) create mode 100644 Documentation/devicetree/bindings/gpio/men-a021-wdt.txt create mode 100644 drivers/watchdog/mena21_wdt.c diff --git a/Documentation/devicetree/bindings/gpio/men-a021-wdt.txt b/Documentation/devicetree/bindings/gpio/men-a021-wdt.txt new file mode 100644 index 000000000000..370dee3226d9 --- /dev/null +++ b/Documentation/devicetree/bindings/gpio/men-a021-wdt.txt @@ -0,0 +1,25 @@ +Bindings for MEN A21 Watchdog device connected to GPIO lines + +Required properties: +- compatible: "men,a021-wdt" +- gpios: Specifies the pins that control the Watchdog, order: + 1: Watchdog enable + 2: Watchdog fast-mode + 3: Watchdog trigger + 4: Watchdog reset cause bit 0 + 5: Watchdog reset cause bit 1 + 6: Watchdog reset cause bit 2 + +Optional properties: +- None + +Example: + watchdog { + compatible ="men,a021-wdt"; + gpios = <&gpio3 9 1 /* WD_EN */ + &gpio3 10 1 /* WD_FAST */ + &gpio3 11 1 /* WD_TRIG */ + &gpio3 6 1 /* RST_CAUSE[0] */ + &gpio3 7 1 /* RST_CAUSE[1] */ + &gpio3 8 1>; /* RST_CAUSE[2] */ + }; diff --git a/MAINTAINERS b/MAINTAINERS index cbd4f66bc677..c66b165ab5a0 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -5394,6 +5394,12 @@ F: drivers/mtd/ F: include/linux/mtd/ F: include/uapi/mtd/ +MEN A21 WATCHDOG DRIVER +M: Johannes Thumshirn +L: linux-watchdog@vger.kernel.org +S: Supported +F: drivers/watchdog/mena21_wdt.c + METAG ARCHITECTURE M: James Hogan S: Supported diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig index b69e4821d668..8519bc696a6f 100644 --- a/drivers/watchdog/Kconfig +++ b/drivers/watchdog/Kconfig @@ -1185,6 +1185,18 @@ config BOOKE_WDT_DEFAULT_TIMEOUT The value can be overridden by the wdt_period command-line parameter. +config MEN_A21_WDT + tristate "MEN A21 VME CPU Carrier Board Watchdog Timer" + select WATCHDOG_CORE + depends on GPIOLIB + help + Watchdog driver for MEN A21 VMEbus CPU Carrier Boards. + + The driver can also be built as a module. If so, the module will be + called mena21_wdt. + + If unsure select N here. + # PPC64 Architecture config WATCHDOG_RTAS diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile index c443f6247fa6..2f26a0b47ddc 100644 --- a/drivers/watchdog/Makefile +++ b/drivers/watchdog/Makefile @@ -144,6 +144,7 @@ obj-$(CONFIG_8xxx_WDT) += mpc8xxx_wdt.o obj-$(CONFIG_MV64X60_WDT) += mv64x60_wdt.o obj-$(CONFIG_PIKA_WDT) += pika_wdt.o obj-$(CONFIG_BOOKE_WDT) += booke_wdt.o +obj-$(CONFIG_MEN_A21_WDT) += mena21_wdt.o # PPC64 Architecture obj-$(CONFIG_WATCHDOG_RTAS) += wdrtas.o diff --git a/drivers/watchdog/mena21_wdt.c b/drivers/watchdog/mena21_wdt.c new file mode 100644 index 000000000000..96dbba980579 --- /dev/null +++ b/drivers/watchdog/mena21_wdt.c @@ -0,0 +1,270 @@ +/* + * Watchdog driver for the A21 VME CPU Boards + * + * Copyright (C) 2013 MEN Mikro Elektronik Nuernberg GmbH + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define NUM_GPIOS 6 + +enum a21_wdt_gpios { + GPIO_WD_ENAB, + GPIO_WD_FAST, + GPIO_WD_TRIG, + GPIO_WD_RST0, + GPIO_WD_RST1, + GPIO_WD_RST2, +}; + +struct a21_wdt_drv { + struct watchdog_device wdt; + struct mutex lock; + unsigned gpios[NUM_GPIOS]; +}; + +static bool nowayout = WATCHDOG_NOWAYOUT; +module_param(nowayout, bool, 0); +MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" + __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); + +static unsigned int a21_wdt_get_bootstatus(struct a21_wdt_drv *drv) +{ + int reset = 0; + + reset |= gpio_get_value(drv->gpios[GPIO_WD_RST0]) ? (1 << 0) : 0; + reset |= gpio_get_value(drv->gpios[GPIO_WD_RST1]) ? (1 << 1) : 0; + reset |= gpio_get_value(drv->gpios[GPIO_WD_RST2]) ? (1 << 2) : 0; + + return reset; +} + +static int a21_wdt_start(struct watchdog_device *wdt) +{ + struct a21_wdt_drv *drv = watchdog_get_drvdata(wdt); + + mutex_lock(&drv->lock); + + gpio_set_value(drv->gpios[GPIO_WD_ENAB], 1); + + mutex_unlock(&drv->lock); + + return 0; +} + +static int a21_wdt_stop(struct watchdog_device *wdt) +{ + struct a21_wdt_drv *drv = watchdog_get_drvdata(wdt); + + mutex_lock(&drv->lock); + + gpio_set_value(drv->gpios[GPIO_WD_ENAB], 0); + + mutex_unlock(&drv->lock); + + return 0; +} + +static int a21_wdt_ping(struct watchdog_device *wdt) +{ + struct a21_wdt_drv *drv = watchdog_get_drvdata(wdt); + + mutex_lock(&drv->lock); + + gpio_set_value(drv->gpios[GPIO_WD_TRIG], 0); + ndelay(10); + gpio_set_value(drv->gpios[GPIO_WD_TRIG], 1); + + mutex_unlock(&drv->lock); + + return 0; +} + +static int a21_wdt_set_timeout(struct watchdog_device *wdt, + unsigned int timeout) +{ + struct a21_wdt_drv *drv = watchdog_get_drvdata(wdt); + + if (timeout != 1 && timeout != 30) { + dev_err(wdt->dev, "Only 1 and 30 allowed as timeout\n"); + return -EINVAL; + } + + if (timeout == 30 && wdt->timeout == 1) { + dev_err(wdt->dev, + "Transition from fast to slow mode not allowed\n"); + return -EINVAL; + } + + mutex_lock(&drv->lock); + + if (timeout == 1) + gpio_set_value(drv->gpios[GPIO_WD_FAST], 1); + else + gpio_set_value(drv->gpios[GPIO_WD_FAST], 0); + + wdt->timeout = timeout; + + mutex_unlock(&drv->lock); + + return 0; +} + +static const struct watchdog_info a21_wdt_info = { + .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE, + .identity = "MEN A21 Watchdog", +}; + +static const struct watchdog_ops a21_wdt_ops = { + .owner = THIS_MODULE, + .start = a21_wdt_start, + .stop = a21_wdt_stop, + .ping = a21_wdt_ping, + .set_timeout = a21_wdt_set_timeout, +}; + +static struct watchdog_device a21_wdt = { + .info = &a21_wdt_info, + .ops = &a21_wdt_ops, + .min_timeout = 1, + .max_timeout = 30, +}; + +static int a21_wdt_probe(struct platform_device *pdev) +{ + struct device_node *node; + struct a21_wdt_drv *drv; + unsigned int reset = 0; + int num_gpios; + int ret; + int i; + + drv = devm_kzalloc(&pdev->dev, sizeof(struct a21_wdt_drv), GFP_KERNEL); + if (!drv) + return -ENOMEM; + + /* Fill GPIO pin array */ + node = pdev->dev.of_node; + + num_gpios = of_gpio_count(node); + if (num_gpios != NUM_GPIOS) { + dev_err(&pdev->dev, "gpios DT property wrong, got %d want %d", + num_gpios, NUM_GPIOS); + return -ENODEV; + } + + for (i = 0; i < num_gpios; i++) { + int val; + + val = of_get_gpio(node, i); + if (val < 0) + return val; + + drv->gpios[i] = val; + } + + /* Request the used GPIOs */ + for (i = 0; i < num_gpios; i++) { + ret = devm_gpio_request(&pdev->dev, drv->gpios[i], + "MEN A21 Watchdog"); + if (ret) + return ret; + + if (i < GPIO_WD_RST0) + ret = gpio_direction_output(drv->gpios[i], + gpio_get_value(drv->gpios[i])); + else /* GPIO_WD_RST[0..2] are inputs */ + ret = gpio_direction_input(drv->gpios[i]); + if (ret) + return ret; + } + + mutex_init(&drv->lock); + watchdog_init_timeout(&a21_wdt, 30, &pdev->dev); + watchdog_set_nowayout(&a21_wdt, nowayout); + watchdog_set_drvdata(&a21_wdt, drv); + + reset = a21_wdt_get_bootstatus(drv); + if (reset == 2) + a21_wdt.bootstatus |= WDIOF_EXTERN1; + else if (reset == 4) + a21_wdt.bootstatus |= WDIOF_CARDRESET; + else if (reset == 5) + a21_wdt.bootstatus |= WDIOF_POWERUNDER; + else if (reset == 7) + a21_wdt.bootstatus |= WDIOF_EXTERN2; + + ret = watchdog_register_device(&a21_wdt); + if (ret) { + dev_err(&pdev->dev, "Cannot register watchdog device\n"); + goto err_register_wd; + } + + dev_set_drvdata(&pdev->dev, drv); + + dev_info(&pdev->dev, "MEN A21 watchdog timer driver enabled\n"); + + return 0; + +err_register_wd: + mutex_destroy(&drv->lock); + + return ret; +} + +static int a21_wdt_remove(struct platform_device *pdev) +{ + struct a21_wdt_drv *drv = dev_get_drvdata(&pdev->dev); + + dev_warn(&pdev->dev, + "Unregistering A21 watchdog driver, board may reboot\n"); + + watchdog_unregister_device(&drv->wdt); + + mutex_destroy(&drv->lock); + + return 0; +} + +static void a21_wdt_shutdown(struct platform_device *pdev) +{ + struct a21_wdt_drv *drv = dev_get_drvdata(&pdev->dev); + + gpio_set_value(drv->gpios[GPIO_WD_ENAB], 0); +} + +static const struct of_device_id a21_wdt_ids[] = { + { .compatible = "men,a021-wdt" }, + { }, +}; + +static struct platform_driver a21_wdt_driver = { + .probe = a21_wdt_probe, + .remove = a21_wdt_remove, + .shutdown = a21_wdt_shutdown, + .driver = { + .name = "a21-watchdog", + .of_match_table = a21_wdt_ids, + }, +}; + +module_platform_driver(a21_wdt_driver); + +MODULE_AUTHOR("MEN Mikro Elektronik"); +MODULE_DESCRIPTION("MEN A21 Watchdog"); +MODULE_LICENSE("GPL"); +MODULE_ALIAS("platform:a21-watchdog"); From 086f3ec187a18e29f8f36ebd4ae9eb8d48d9fd03 Mon Sep 17 00:00:00 2001 From: "Kim, Milo" Date: Tue, 26 Mar 2013 07:26:49 +0000 Subject: [PATCH 0825/1048] watchdog: softdog: remove replaceable ping operation In watchdog_ping(), 'start' is called automatically when 'ping' function call is not configured. Softdog driver has same handling in both cases - start and ping, so 'ping' OPS can be removed. Signed-off-by: Milo(Woogyom) Kim Signed-off-by: Wim Van Sebroeck --- drivers/watchdog/softdog.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/watchdog/softdog.c b/drivers/watchdog/softdog.c index fe83beb8f1b7..b68b1e519d53 100644 --- a/drivers/watchdog/softdog.c +++ b/drivers/watchdog/softdog.c @@ -152,7 +152,6 @@ static struct watchdog_ops softdog_ops = { .owner = THIS_MODULE, .start = softdog_ping, .stop = softdog_stop, - .ping = softdog_ping, .set_timeout = softdog_set_timeout, }; From cce78da76601b64305c050f602767bf58cebcf5d Mon Sep 17 00:00:00 2001 From: "Mingarelli, Thomas" Date: Tue, 9 Jul 2013 23:04:55 +0000 Subject: [PATCH 0826/1048] watchdog: hpwdt: Add check for UEFI bits This patch is being created to use the UEFI bits in the type 219 SMBIOS record in order to decide whether or not to execute BIOS code. This is a better solution than to depend on the iCRU bit since not all future servers will use iCRU. Signed-off-by: Thomas Mingarelli Signed-off-by: Wim Van Sebroeck ---- drivers/watchdog/hpwdt.c | 9 ++++++--- 1 files changed, 6 insertions(+), 3 deletions(-) --- drivers/watchdog/hpwdt.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/watchdog/hpwdt.c b/drivers/watchdog/hpwdt.c index 11796b9b864e..de7e4f497222 100644 --- a/drivers/watchdog/hpwdt.c +++ b/drivers/watchdog/hpwdt.c @@ -39,7 +39,7 @@ #endif /* CONFIG_HPWDT_NMI_DECODING */ #include -#define HPWDT_VERSION "1.3.1" +#define HPWDT_VERSION "1.3.2" #define SECS_TO_TICKS(secs) ((secs) * 1000 / 128) #define TICKS_TO_SECS(ticks) ((ticks) * 128 / 1000) #define HPWDT_MAX_TIMER TICKS_TO_SECS(65535) @@ -148,6 +148,7 @@ struct cmn_registers { static unsigned int hpwdt_nmi_decoding; static unsigned int allow_kdump = 1; static unsigned int is_icru; +static unsigned int is_uefi; static DEFINE_SPINLOCK(rom_lock); static void *cru_rom_addr; static struct cmn_registers cmn_regs; @@ -484,7 +485,7 @@ static int hpwdt_pretimeout(unsigned int ulReason, struct pt_regs *regs) goto out; spin_lock_irqsave(&rom_lock, rom_pl); - if (!die_nmi_called && !is_icru) + if (!die_nmi_called && !is_icru && !is_uefi) asminline_call(&cmn_regs, cru_rom_addr); die_nmi_called = 1; spin_unlock_irqrestore(&rom_lock, rom_pl); @@ -492,7 +493,7 @@ static int hpwdt_pretimeout(unsigned int ulReason, struct pt_regs *regs) if (allow_kdump) hpwdt_stop(); - if (!is_icru) { + if (!is_icru && !is_uefi) { if (cmn_regs.u1.ral == 0) { panic("An NMI occurred, " "but unable to determine source.\n"); @@ -679,6 +680,8 @@ static void dmi_find_icru(const struct dmi_header *dm, void *dummy) smbios_proliant_ptr = (struct smbios_proliant_info *) dm; if (smbios_proliant_ptr->misc_features & 0x01) is_icru = 1; + if (smbios_proliant_ptr->misc_features & 0x408) + is_uefi = 1; } } @@ -697,7 +700,7 @@ static int hpwdt_init_nmi_decoding(struct pci_dev *dev) * the old cru detect code. */ dmi_walk(dmi_find_icru, NULL); - if (!is_icru) { + if (!is_icru && !is_uefi) { /* * We need to map the ROM to get the CRU service. From 1c327d962fc420aea046c16215a552710bde8231 Mon Sep 17 00:00:00 2001 From: David Jeffery Date: Wed, 10 Jul 2013 13:19:50 -0400 Subject: [PATCH 0827/1048] lockd: protect nlm_blocked access in nlmsvc_retry_blocked In nlmsvc_retry_blocked, the check that the list is non-empty and acquiring the pointer of the first entry is unprotected by any lock. This allows a rare race condition when there is only one entry on the list. A function such as nlmsvc_grant_callback() can be called, which will temporarily remove the entry from the list. Between the list_empty() and list_entry(),the list may become empty, causing an invalid pointer to be used as an nlm_block, leading to a possible crash. This patch adds the nlm_block_lock around these calls to prevent concurrent use of the nlm_blocked list. This was a regression introduced by f904be9cc77f361d37d71468b13ff3d1a1823dea "lockd: Mostly remove BKL from the server". Cc: Bryan Schumaker Cc: stable@vger.kernel.org Signed-off-by: David Jeffery Signed-off-by: J. Bruce Fields --- fs/lockd/svclock.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fs/lockd/svclock.c b/fs/lockd/svclock.c index e703318c41df..8ebd3f551e0c 100644 --- a/fs/lockd/svclock.c +++ b/fs/lockd/svclock.c @@ -939,6 +939,7 @@ nlmsvc_retry_blocked(void) unsigned long timeout = MAX_SCHEDULE_TIMEOUT; struct nlm_block *block; + spin_lock(&nlm_blocked_lock); while (!list_empty(&nlm_blocked) && !kthread_should_stop()) { block = list_entry(nlm_blocked.next, struct nlm_block, b_list); @@ -948,6 +949,7 @@ nlmsvc_retry_blocked(void) timeout = block->b_when - jiffies; break; } + spin_unlock(&nlm_blocked_lock); dprintk("nlmsvc_retry_blocked(%p, when=%ld)\n", block, block->b_when); @@ -957,7 +959,9 @@ nlmsvc_retry_blocked(void) retry_deferred_block(block); } else nlmsvc_grant_blocked(block); + spin_lock(&nlm_blocked_lock); } + spin_unlock(&nlm_blocked_lock); return timeout; } From c31ad439e8d111bf911c9cc80619cebde411a44d Mon Sep 17 00:00:00 2001 From: Chandra Seetharaman Date: Wed, 10 Jul 2013 18:00:36 -0500 Subject: [PATCH 0828/1048] xfs: Fix the logic check for all quotas being turned off During the review of seperate pquota inode patches, David noticed that the test to detect all quotas being turned off was incorrect, and hence the block was not freeing all the quota information. The check made sense in Irix, but in Linux, quota is turned off one at a time, which makes the test invalid for Linux. This problem existed since XFS was ported to Linux. David suggested to fix the problem by detecting when all quotas are turned off by checking m_qflags. Signed-off-by: Chandra Seetharaman Reviewed-by: Ben Myers Signed-off-by: Ben Myers --- fs/xfs/xfs_qm_syscalls.c | 5 ++--- fs/xfs/xfs_quota.h | 8 -------- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/fs/xfs/xfs_qm_syscalls.c b/fs/xfs/xfs_qm_syscalls.c index b9363838b42b..e4f8b2d6f38b 100644 --- a/fs/xfs/xfs_qm_syscalls.c +++ b/fs/xfs/xfs_qm_syscalls.c @@ -199,10 +199,9 @@ xfs_qm_scall_quotaoff( } /* - * If quotas is completely disabled, close shop. + * If all quotas are completely turned off, close shop. */ - if (((flags & XFS_MOUNT_QUOTA_ALL) == XFS_MOUNT_QUOTA_SET1) || - ((flags & XFS_MOUNT_QUOTA_ALL) == XFS_MOUNT_QUOTA_SET2)) { + if (mp->m_qflags == 0) { mutex_unlock(&q->qi_quotaofflock); xfs_qm_destroy_quotainfo(mp); return (0); diff --git a/fs/xfs/xfs_quota.h b/fs/xfs/xfs_quota.h index 09777c41d5b7..b14f42c714b6 100644 --- a/fs/xfs/xfs_quota.h +++ b/fs/xfs/xfs_quota.h @@ -301,14 +301,6 @@ typedef struct xfs_qoff_logformat { (XFS_IS_PQUOTA_ON(mp) && \ (mp->m_sb.sb_qflags & XFS_PQUOTA_CHKD) == 0)) -#define XFS_MOUNT_QUOTA_SET1 (XFS_UQUOTA_ACCT|XFS_UQUOTA_ENFD|\ - XFS_UQUOTA_CHKD|XFS_GQUOTA_ACCT|\ - XFS_GQUOTA_ENFD|XFS_GQUOTA_CHKD) - -#define XFS_MOUNT_QUOTA_SET2 (XFS_UQUOTA_ACCT|XFS_UQUOTA_ENFD|\ - XFS_UQUOTA_CHKD|XFS_PQUOTA_ACCT|\ - XFS_PQUOTA_ENFD|XFS_PQUOTA_CHKD) - #define XFS_MOUNT_QUOTA_ALL (XFS_UQUOTA_ACCT|XFS_UQUOTA_ENFD|\ XFS_UQUOTA_CHKD|XFS_GQUOTA_ACCT|\ XFS_GQUOTA_ENFD|XFS_GQUOTA_CHKD|\ From ad065dd01662ae22138899e6b1c8eeb3a529964f Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Thu, 11 Jul 2013 18:54:37 -0400 Subject: [PATCH 0829/1048] ext4: don't show usrquota/grpquota twice in /proc/mounts We now print mount options in a generic fashion in ext4_show_options(), so we shouldn't be explicitly printing the {usr,grp}quota options in ext4_show_quota_options(). Without this patch, /proc/mounts can look like this: /dev/vdb /vdb ext4 rw,relatime,quota,usrquota,data=ordered,usrquota 0 0 ^^^^^^^^ ^^^^^^^^ Signed-off-by: "Theodore Ts'o" Cc: stable@vger.kernel.org --- fs/ext4/super.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 8862d4ddf71f..bca26f34edf4 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -1702,12 +1702,6 @@ static inline void ext4_show_quota_options(struct seq_file *seq, if (sbi->s_qf_names[GRPQUOTA]) seq_printf(seq, ",grpjquota=%s", sbi->s_qf_names[GRPQUOTA]); - - if (test_opt(sb, USRQUOTA)) - seq_puts(seq, ",usrquota"); - - if (test_opt(sb, GRPQUOTA)) - seq_puts(seq, ",grpquota"); #endif } From b33fcf1c9d359374ef6e8e7ec1e0b6f7a8717e16 Mon Sep 17 00:00:00 2001 From: Pavel Shilovsky Date: Thu, 11 Jul 2013 10:58:30 +0400 Subject: [PATCH 0830/1048] CIFS: Reopen the file if reconnect durable handle failed This is a follow-on patch for 8/8 patch from the durable handles series. It fixes the problem when durable file handle timeout expired on the server and reopen returns -ENOENT for such files. Signed-off-by: Pavel Shilovsky Signed-off-by: Steve French --- fs/cifs/file.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/fs/cifs/file.c b/fs/cifs/file.c index ba7eed2ee662..1dc9dea2ae70 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c @@ -681,6 +681,13 @@ cifs_reopen_file(struct cifsFileInfo *cfile, bool can_flush) * not dirty locally we could do this. */ rc = server->ops->open(xid, &oparms, &oplock, NULL); + if (rc == -ENOENT && oparms.reconnect == false) { + /* durable handle timeout is expired - open the file again */ + rc = server->ops->open(xid, &oparms, &oplock, NULL); + /* indicate that we need to relock the file */ + oparms.reconnect = true; + } + if (rc) { mutex_unlock(&cfile->fh_mutex); cifs_dbg(FYI, "cifs_reopen returned 0x%x\n", rc); @@ -1510,7 +1517,6 @@ cifs_setlk(struct file *file, struct file_lock *flock, __u32 type, if (!rc) goto out; - /* * Windows 7 server can delay breaking lease from read to None * if we set a byte-range lock on a file - break it explicitly From 689c3db4d57a73bee6c5ad7797fce7b54d32a87c Mon Sep 17 00:00:00 2001 From: Pavel Shilovsky Date: Thu, 11 Jul 2013 11:17:45 +0400 Subject: [PATCH 0831/1048] CIFS: Fix a deadlock when a file is reopened If we request reading or writing on a file that needs to be reopened, it causes the deadlock: we are already holding rw semaphore for reading and then we try to acquire it for writing in cifs_relock_file. Fix this by acquiring the semaphore for reading in cifs_relock_file due to we don't make any changes in locks and don't need a write access. CC: Signed-off-by: Pavel Shilovsky Acked-by: Jeff Layton Signed-off-by: Steve French --- fs/cifs/file.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/fs/cifs/file.c b/fs/cifs/file.c index 1dc9dea2ae70..1e57f36ea1b2 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c @@ -561,11 +561,10 @@ cifs_relock_file(struct cifsFileInfo *cfile) struct cifs_tcon *tcon = tlink_tcon(cfile->tlink); int rc = 0; - /* we are going to update can_cache_brlcks here - need a write access */ - down_write(&cinode->lock_sem); + down_read(&cinode->lock_sem); if (cinode->can_cache_brlcks) { - /* can cache locks - no need to push them */ - up_write(&cinode->lock_sem); + /* can cache locks - no need to relock */ + up_read(&cinode->lock_sem); return rc; } @@ -576,7 +575,7 @@ cifs_relock_file(struct cifsFileInfo *cfile) else rc = tcon->ses->server->ops->push_mand_locks(cfile); - up_write(&cinode->lock_sem); + up_read(&cinode->lock_sem); return rc; } From 8c91e162e058bb91b7766f26f4d5823a21941026 Mon Sep 17 00:00:00 2001 From: Alexander Duyck Date: Thu, 11 Jul 2013 13:12:22 -0700 Subject: [PATCH 0832/1048] gre: Fix MTU sizing check for gretap tunnels This change fixes an MTU sizing issue seen with gretap tunnels when non-gso packets are sent from the interface. In my case I was able to reproduce the issue by simply sending a ping of 1421 bytes with the gretap interface created on a device with a standard 1500 mtu. This fix is based on the fact that the tunnel mtu is already adjusted by dev->hard_header_len so it would make sense that any packets being compared against that mtu should also be adjusted by hard_header_len and the tunnel header instead of just the tunnel header. Signed-off-by: Alexander Duyck Reported-by: Cong Wang Acked-by: Eric Dumazet Signed-off-by: David S. Miller --- net/ipv4/ip_tunnel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/ipv4/ip_tunnel.c b/net/ipv4/ip_tunnel.c index 945734b2f209..ca1cb2d5f6e2 100644 --- a/net/ipv4/ip_tunnel.c +++ b/net/ipv4/ip_tunnel.c @@ -476,7 +476,7 @@ static int tnl_update_pmtu(struct net_device *dev, struct sk_buff *skb, struct rtable *rt, __be16 df) { struct ip_tunnel *tunnel = netdev_priv(dev); - int pkt_size = skb->len - tunnel->hlen; + int pkt_size = skb->len - tunnel->hlen - dev->hard_header_len; int mtu; if (df) From 7ad031ee468e4ed9196215394d7e18a78a66a7da Mon Sep 17 00:00:00 2001 From: Jitendra Kalsaria Date: Wed, 10 Jul 2013 14:00:22 -0400 Subject: [PATCH 0833/1048] qlcnic: Adding Maintainers. Signed-off-by: Jitendra Kalsaria Signed-off-by: David S. Miller --- MAINTAINERS | 2 ++ 1 file changed, 2 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 37f9a71c744f..6a904d30d6a2 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -6651,10 +6651,12 @@ F: Documentation/networking/LICENSE.qla3xxx F: drivers/net/ethernet/qlogic/qla3xxx.* QLOGIC QLCNIC (1/10)Gb ETHERNET DRIVER +M: Himanshu Madhani M: Rajesh Borundia M: Shahed Shaikh M: Jitendra Kalsaria M: Sony Chacko +M: Sucheta Chakraborty M: linux-driver@qlogic.com L: netdev@vger.kernel.org S: Supported From 80d5e8a235624cd3c0e24be7c070fd6f445e590d Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Wed, 10 Jul 2013 17:36:35 +0200 Subject: [PATCH 0834/1048] IB/srp: Let srp_abort() return FAST_IO_FAIL if TL offline If the transport layer is offline it is more appropriate to let srp_abort() return FAST_IO_FAIL instead of SUCCESS. Reported-by: Sebastian Riemer Acked-by: David Dillow Signed-off-by: Bart Van Assche Signed-off-by: Roland Dreier --- drivers/infiniband/ulp/srp/ib_srp.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c index 9d8b46eafdb2..f93baf8254c4 100644 --- a/drivers/infiniband/ulp/srp/ib_srp.c +++ b/drivers/infiniband/ulp/srp/ib_srp.c @@ -1753,8 +1753,7 @@ static int srp_abort(struct scsi_cmnd *scmnd) if (!req || !srp_claim_req(target, req, scmnd)) return FAILED; if (srp_send_tsk_mgmt(target, req->index, scmnd->device->lun, - SRP_TSK_ABORT_TASK) == 0 || - target->transport_offline) + SRP_TSK_ABORT_TASK) == 0) ret = SUCCESS; else if (target->transport_offline) ret = FAST_IO_FAIL; From 288dde9f23b6726c1e8147bf635721372bf77b16 Mon Sep 17 00:00:00 2001 From: Moshe Lazer Date: Wed, 10 Jul 2013 14:31:03 +0300 Subject: [PATCH 0835/1048] mlx5_core: Adjust hca_cap.uar_page_sz to conform to Connect-IB spec Sparse reported an endianness bug in the assignment to hca_cap.uar_page_sz. Fix the declaration of this field to be __be16 (which is what is in the firmware spec), renaming the field to log_uar_pg_size to conform to the spec, which fixes the endianness bug reported by sparse. Reported-by: Fengguang Wu Signed-off-by: Moshe Lazer Signed-off-by: Or Gerlitz Signed-off-by: Roland Dreier --- drivers/net/ethernet/mellanox/mlx5/core/main.c | 2 +- include/linux/mlx5/device.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/main.c b/drivers/net/ethernet/mellanox/mlx5/core/main.c index f21cc397d1bc..12242de2b0e3 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/main.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/main.c @@ -212,7 +212,7 @@ static int handle_hca_cap(struct mlx5_core_dev *dev) set_ctx->hca_cap.log_max_qp = dev->profile->log_max_qp; memset(&set_out, 0, sizeof(set_out)); - set_ctx->hca_cap.uar_page_sz = cpu_to_be16(PAGE_SHIFT - 12); + set_ctx->hca_cap.log_uar_page_sz = cpu_to_be16(PAGE_SHIFT - 12); set_ctx->hdr.opcode = cpu_to_be16(MLX5_CMD_OP_SET_HCA_CAP); err = mlx5_cmd_exec(dev, set_ctx, sizeof(*set_ctx), &set_out, sizeof(set_out)); diff --git a/include/linux/mlx5/device.h b/include/linux/mlx5/device.h index 51390915e538..8de8d8f22384 100644 --- a/include/linux/mlx5/device.h +++ b/include/linux/mlx5/device.h @@ -317,8 +317,8 @@ struct mlx5_hca_cap { u8 log_max_pd; u8 rsvd25; u8 log_max_xrcd; - u8 rsvd26[40]; - __be32 uar_page_sz; + u8 rsvd26[42]; + __be16 log_uar_page_sz; u8 rsvd27[28]; u8 log_msx_atomic_size_qp; u8 rsvd28[2]; From 308c813b19cb676df7e5e70b5f014fa56e918677 Mon Sep 17 00:00:00 2001 From: Mike Marciniszyn Date: Wed, 3 Jul 2013 13:50:28 -0400 Subject: [PATCH 0836/1048] IB/qib: Fix module-level leak The vzalloc()'ed field physshadow is leaked on module unload. This patch adds vfree after the sibling page shadow is freed. Reported-by: Dean Luick Reviewed-by: Dean Luick Signed-off-by: Mike Marciniszyn Signed-off-by: Roland Dreier --- drivers/infiniband/hw/qib/qib_init.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/infiniband/hw/qib/qib_init.c b/drivers/infiniband/hw/qib/qib_init.c index fdae42973056..36e048e0e1d9 100644 --- a/drivers/infiniband/hw/qib/qib_init.c +++ b/drivers/infiniband/hw/qib/qib_init.c @@ -1350,7 +1350,7 @@ static void cleanup_device_data(struct qib_devdata *dd) if (dd->pageshadow) { struct page **tmpp = dd->pageshadow; dma_addr_t *tmpd = dd->physshadow; - int i, cnt = 0; + int i; for (ctxt = 0; ctxt < dd->cfgctxts; ctxt++) { int ctxt_tidbase = ctxt * dd->rcvtidcnt; @@ -1363,13 +1363,13 @@ static void cleanup_device_data(struct qib_devdata *dd) PAGE_SIZE, PCI_DMA_FROMDEVICE); qib_release_user_pages(&tmpp[i], 1); tmpp[i] = NULL; - cnt++; } } - tmpp = dd->pageshadow; dd->pageshadow = NULL; vfree(tmpp); + dd->physshadow = NULL; + vfree(tmpd); } /* From 0b3ddf380ca7aa6a009cc3e1944933fff8113b6a Mon Sep 17 00:00:00 2001 From: Dean Luick Date: Thu, 11 Jul 2013 15:32:14 -0400 Subject: [PATCH 0837/1048] IB/qib: Log all SDMA errors unconditionally This patch adds code to log SDMA errors for supportability purposes. Signed-off-by: Dean Luick Signed-off-by: Mike Marciniszyn Signed-off-by: Roland Dreier --- drivers/infiniband/hw/qib/qib.h | 2 +- drivers/infiniband/hw/qib/qib_iba7322.c | 114 ++++++++++++++++++++++++ drivers/infiniband/hw/qib/qib_sdma.c | 56 ++++++++++++ 3 files changed, 171 insertions(+), 1 deletion(-) diff --git a/drivers/infiniband/hw/qib/qib.h b/drivers/infiniband/hw/qib/qib.h index 5453e2b36567..4a9af795b88f 100644 --- a/drivers/infiniband/hw/qib/qib.h +++ b/drivers/infiniband/hw/qib/qib.h @@ -1348,7 +1348,7 @@ static inline int __qib_sdma_running(struct qib_pportdata *ppd) return ppd->sdma_state.current_state == qib_sdma_state_s99_running; } int qib_sdma_running(struct qib_pportdata *); - +void dump_sdma_state(struct qib_pportdata *ppd); void __qib_sdma_process_event(struct qib_pportdata *, enum qib_sdma_events); void qib_sdma_process_event(struct qib_pportdata *, enum qib_sdma_events); diff --git a/drivers/infiniband/hw/qib/qib_iba7322.c b/drivers/infiniband/hw/qib/qib_iba7322.c index f7c4b44b1f93..21e8b09d4bf8 100644 --- a/drivers/infiniband/hw/qib/qib_iba7322.c +++ b/drivers/infiniband/hw/qib/qib_iba7322.c @@ -83,6 +83,7 @@ static void ibsd_wr_allchans(struct qib_pportdata *, int, unsigned, unsigned); static void serdes_7322_los_enable(struct qib_pportdata *, int); static int serdes_7322_init_old(struct qib_pportdata *); static int serdes_7322_init_new(struct qib_pportdata *); +static void dump_sdma_7322_state(struct qib_pportdata *); #define BMASK(msb, lsb) (((1 << ((msb) + 1 - (lsb))) - 1) << (lsb)) @@ -652,6 +653,7 @@ struct qib_chippport_specific { u8 ibmalfusesnap; struct qib_qsfp_data qsfp_data; char epmsgbuf[192]; /* for port error interrupt msg buffer */ + char sdmamsgbuf[192]; /* for per-port sdma error messages */ }; static struct { @@ -1601,6 +1603,15 @@ static void sdma_7322_p_errors(struct qib_pportdata *ppd, u64 errs) spin_lock_irqsave(&ppd->sdma_lock, flags); + if (errs != QIB_E_P_SDMAHALT) { + /* SDMA errors have QIB_E_P_SDMAHALT and another bit set */ + qib_dev_porterr(dd, ppd->port, + "SDMA %s 0x%016llx %s\n", + qib_sdma_state_names[ppd->sdma_state.current_state], + errs, ppd->cpspec->sdmamsgbuf); + dump_sdma_7322_state(ppd); + } + switch (ppd->sdma_state.current_state) { case qib_sdma_state_s00_hw_down: break; @@ -2156,6 +2167,29 @@ static void qib_7322_handle_hwerrors(struct qib_devdata *dd, char *msg, qib_dev_err(dd, "%s hardware error\n", msg); + if (hwerrs & + (SYM_MASK(HwErrMask, SDmaMemReadErrMask_0) | + SYM_MASK(HwErrMask, SDmaMemReadErrMask_1))) { + int pidx = 0; + int err; + unsigned long flags; + struct qib_pportdata *ppd = dd->pport; + for (; pidx < dd->num_pports; ++pidx, ppd++) { + err = 0; + if (pidx == 0 && (hwerrs & + SYM_MASK(HwErrMask, SDmaMemReadErrMask_0))) + err++; + if (pidx == 1 && (hwerrs & + SYM_MASK(HwErrMask, SDmaMemReadErrMask_1))) + err++; + if (err) { + spin_lock_irqsave(&ppd->sdma_lock, flags); + dump_sdma_7322_state(ppd); + spin_unlock_irqrestore(&ppd->sdma_lock, flags); + } + } + } + if (isfatal && !dd->diag_client) { qib_dev_err(dd, "Fatal Hardware Error, no longer usable, SN %.16s\n", @@ -6753,6 +6787,86 @@ static void qib_sdma_set_7322_desc_cnt(struct qib_pportdata *ppd, unsigned cnt) qib_write_kreg_port(ppd, krp_senddmadesccnt, cnt); } +/* + * sdma_lock should be acquired before calling this routine + */ +static void dump_sdma_7322_state(struct qib_pportdata *ppd) +{ + u64 reg, reg1, reg2; + + reg = qib_read_kreg_port(ppd, krp_senddmastatus); + qib_dev_porterr(ppd->dd, ppd->port, + "SDMA senddmastatus: 0x%016llx\n", reg); + + reg = qib_read_kreg_port(ppd, krp_sendctrl); + qib_dev_porterr(ppd->dd, ppd->port, + "SDMA sendctrl: 0x%016llx\n", reg); + + reg = qib_read_kreg_port(ppd, krp_senddmabase); + qib_dev_porterr(ppd->dd, ppd->port, + "SDMA senddmabase: 0x%016llx\n", reg); + + reg = qib_read_kreg_port(ppd, krp_senddmabufmask0); + reg1 = qib_read_kreg_port(ppd, krp_senddmabufmask1); + reg2 = qib_read_kreg_port(ppd, krp_senddmabufmask2); + qib_dev_porterr(ppd->dd, ppd->port, + "SDMA senddmabufmask 0:%llx 1:%llx 2:%llx\n", + reg, reg1, reg2); + + /* get bufuse bits, clear them, and print them again if non-zero */ + reg = qib_read_kreg_port(ppd, krp_senddmabuf_use0); + qib_write_kreg_port(ppd, krp_senddmabuf_use0, reg); + reg1 = qib_read_kreg_port(ppd, krp_senddmabuf_use1); + qib_write_kreg_port(ppd, krp_senddmabuf_use0, reg1); + reg2 = qib_read_kreg_port(ppd, krp_senddmabuf_use2); + qib_write_kreg_port(ppd, krp_senddmabuf_use0, reg2); + /* 0 and 1 should always be zero, so print as short form */ + qib_dev_porterr(ppd->dd, ppd->port, + "SDMA current senddmabuf_use 0:%llx 1:%llx 2:%llx\n", + reg, reg1, reg2); + reg = qib_read_kreg_port(ppd, krp_senddmabuf_use0); + reg1 = qib_read_kreg_port(ppd, krp_senddmabuf_use1); + reg2 = qib_read_kreg_port(ppd, krp_senddmabuf_use2); + /* 0 and 1 should always be zero, so print as short form */ + qib_dev_porterr(ppd->dd, ppd->port, + "SDMA cleared senddmabuf_use 0:%llx 1:%llx 2:%llx\n", + reg, reg1, reg2); + + reg = qib_read_kreg_port(ppd, krp_senddmatail); + qib_dev_porterr(ppd->dd, ppd->port, + "SDMA senddmatail: 0x%016llx\n", reg); + + reg = qib_read_kreg_port(ppd, krp_senddmahead); + qib_dev_porterr(ppd->dd, ppd->port, + "SDMA senddmahead: 0x%016llx\n", reg); + + reg = qib_read_kreg_port(ppd, krp_senddmaheadaddr); + qib_dev_porterr(ppd->dd, ppd->port, + "SDMA senddmaheadaddr: 0x%016llx\n", reg); + + reg = qib_read_kreg_port(ppd, krp_senddmalengen); + qib_dev_porterr(ppd->dd, ppd->port, + "SDMA senddmalengen: 0x%016llx\n", reg); + + reg = qib_read_kreg_port(ppd, krp_senddmadesccnt); + qib_dev_porterr(ppd->dd, ppd->port, + "SDMA senddmadesccnt: 0x%016llx\n", reg); + + reg = qib_read_kreg_port(ppd, krp_senddmaidlecnt); + qib_dev_porterr(ppd->dd, ppd->port, + "SDMA senddmaidlecnt: 0x%016llx\n", reg); + + reg = qib_read_kreg_port(ppd, krp_senddmaprioritythld); + qib_dev_porterr(ppd->dd, ppd->port, + "SDMA senddmapriorityhld: 0x%016llx\n", reg); + + reg = qib_read_kreg_port(ppd, krp_senddmareloadcnt); + qib_dev_porterr(ppd->dd, ppd->port, + "SDMA senddmareloadcnt: 0x%016llx\n", reg); + + dump_sdma_state(ppd); +} + static struct sdma_set_state_action sdma_7322_action_table[] = { [qib_sdma_state_s00_hw_down] = { .go_s99_running_tofalse = 1, diff --git a/drivers/infiniband/hw/qib/qib_sdma.c b/drivers/infiniband/hw/qib/qib_sdma.c index 3fc514431212..32162d355370 100644 --- a/drivers/infiniband/hw/qib/qib_sdma.c +++ b/drivers/infiniband/hw/qib/qib_sdma.c @@ -708,6 +708,62 @@ unlock: return ret; } +/* + * sdma_lock should be acquired before calling this routine + */ +void dump_sdma_state(struct qib_pportdata *ppd) +{ + struct qib_sdma_desc *descq; + struct qib_sdma_txreq *txp, *txpnext; + __le64 *descqp; + u64 desc[2]; + dma_addr_t addr; + u16 gen, dwlen, dwoffset; + u16 head, tail, cnt; + + head = ppd->sdma_descq_head; + tail = ppd->sdma_descq_tail; + cnt = qib_sdma_descq_freecnt(ppd); + descq = ppd->sdma_descq; + + qib_dev_porterr(ppd->dd, ppd->port, + "SDMA ppd->sdma_descq_head: %u\n", head); + qib_dev_porterr(ppd->dd, ppd->port, + "SDMA ppd->sdma_descq_tail: %u\n", tail); + qib_dev_porterr(ppd->dd, ppd->port, + "SDMA sdma_descq_freecnt: %u\n", cnt); + + /* print info for each entry in the descriptor queue */ + while (head != tail) { + char flags[6] = { 'x', 'x', 'x', 'x', 'x', 0 }; + + descqp = &descq[head].qw[0]; + desc[0] = le64_to_cpu(descqp[0]); + desc[1] = le64_to_cpu(descqp[1]); + flags[0] = (desc[0] & 1<<15) ? 'I' : '-'; + flags[1] = (desc[0] & 1<<14) ? 'L' : 'S'; + flags[2] = (desc[0] & 1<<13) ? 'H' : '-'; + flags[3] = (desc[0] & 1<<12) ? 'F' : '-'; + flags[4] = (desc[0] & 1<<11) ? 'L' : '-'; + addr = (desc[1] << 32) | ((desc[0] >> 32) & 0xfffffffcULL); + gen = (desc[0] >> 30) & 3ULL; + dwlen = (desc[0] >> 14) & (0x7ffULL << 2); + dwoffset = (desc[0] & 0x7ffULL) << 2; + qib_dev_porterr(ppd->dd, ppd->port, + "SDMA sdmadesc[%u]: flags:%s addr:0x%016llx gen:%u len:%u bytes offset:%u bytes\n", + head, flags, addr, gen, dwlen, dwoffset); + if (++head == ppd->sdma_descq_cnt) + head = 0; + } + + /* print dma descriptor indices from the TX requests */ + list_for_each_entry_safe(txp, txpnext, &ppd->sdma_activelist, + list) + qib_dev_porterr(ppd->dd, ppd->port, + "SDMA txp->start_idx: %u txp->next_descq_idx: %u\n", + txp->start_idx, txp->next_descq_idx); +} + void qib_sdma_process_event(struct qib_pportdata *ppd, enum qib_sdma_events event) { From 5e631a03af7eaa55b9ef7fa7611144c2c698c6c6 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Wed, 10 Jul 2013 13:58:59 +0300 Subject: [PATCH 0838/1048] mlx5: Return -EFAULT instead of -EPERM For copy_to/from_user() failure, the correct error code is -EFAULT not -EPERM. Signed-off-by: Dan Carpenter Acked-by: Or Gerlitz Signed-off-by: Roland Dreier --- drivers/infiniband/hw/mlx5/mr.c | 8 ++++---- drivers/net/ethernet/mellanox/mlx5/core/cmd.c | 10 +++++----- drivers/net/ethernet/mellanox/mlx5/core/debugfs.c | 12 ++++-------- 3 files changed, 13 insertions(+), 17 deletions(-) diff --git a/drivers/infiniband/hw/mlx5/mr.c b/drivers/infiniband/hw/mlx5/mr.c index e2daa8f02476..bd41df95b6f0 100644 --- a/drivers/infiniband/hw/mlx5/mr.c +++ b/drivers/infiniband/hw/mlx5/mr.c @@ -171,7 +171,7 @@ static ssize_t size_write(struct file *filp, const char __user *buf, int c; if (copy_from_user(lbuf, buf, sizeof(lbuf))) - return -EPERM; + return -EFAULT; c = order2idx(dev, ent->order); lbuf[sizeof(lbuf) - 1] = 0; @@ -208,7 +208,7 @@ static ssize_t size_read(struct file *filp, char __user *buf, size_t count, return err; if (copy_to_user(buf, lbuf, err)) - return -EPERM; + return -EFAULT; *pos += err; @@ -233,7 +233,7 @@ static ssize_t limit_write(struct file *filp, const char __user *buf, int c; if (copy_from_user(lbuf, buf, sizeof(lbuf))) - return -EPERM; + return -EFAULT; c = order2idx(dev, ent->order); lbuf[sizeof(lbuf) - 1] = 0; @@ -270,7 +270,7 @@ static ssize_t limit_read(struct file *filp, char __user *buf, size_t count, return err; if (copy_to_user(buf, lbuf, err)) - return -EPERM; + return -EFAULT; *pos += err; diff --git a/drivers/net/ethernet/mellanox/mlx5/core/cmd.c b/drivers/net/ethernet/mellanox/mlx5/core/cmd.c index c1c0eef89694..205753a04cfc 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/cmd.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/cmd.c @@ -693,7 +693,7 @@ static ssize_t dbg_write(struct file *filp, const char __user *buf, return -ENOMEM; if (copy_from_user(lbuf, buf, sizeof(lbuf))) - return -EPERM; + return -EFAULT; lbuf[sizeof(lbuf) - 1] = 0; @@ -889,7 +889,7 @@ static ssize_t data_write(struct file *filp, const char __user *buf, return -ENOMEM; if (copy_from_user(ptr, buf, count)) { - err = -EPERM; + err = -EFAULT; goto out; } dbg->in_msg = ptr; @@ -919,7 +919,7 @@ static ssize_t data_read(struct file *filp, char __user *buf, size_t count, copy = min_t(int, count, dbg->outlen); if (copy_to_user(buf, dbg->out_msg, copy)) - return -EPERM; + return -EFAULT; *pos += copy; @@ -949,7 +949,7 @@ static ssize_t outlen_read(struct file *filp, char __user *buf, size_t count, return err; if (copy_to_user(buf, &outlen, err)) - return -EPERM; + return -EFAULT; *pos += err; @@ -974,7 +974,7 @@ static ssize_t outlen_write(struct file *filp, const char __user *buf, dbg->outlen = 0; if (copy_from_user(outlen_str, buf, count)) - return -EPERM; + return -EFAULT; outlen_str[7] = 0; diff --git a/drivers/net/ethernet/mellanox/mlx5/core/debugfs.c b/drivers/net/ethernet/mellanox/mlx5/core/debugfs.c index a550a8ef94a1..4273c06e2e96 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/debugfs.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/debugfs.c @@ -148,7 +148,6 @@ static ssize_t average_read(struct file *filp, char __user *buf, size_t count, struct mlx5_cmd_stats *stats; u64 field = 0; int ret; - int err; char tbuf[22]; if (*pos) @@ -161,9 +160,8 @@ static ssize_t average_read(struct file *filp, char __user *buf, size_t count, spin_unlock(&stats->lock); ret = snprintf(tbuf, sizeof(tbuf), "%llu\n", field); if (ret > 0) { - err = copy_to_user(buf, tbuf, ret); - if (err) - return err; + if (copy_to_user(buf, tbuf, ret)) + return -EFAULT; } *pos += ret; @@ -418,7 +416,6 @@ static ssize_t dbg_read(struct file *filp, char __user *buf, size_t count, char tbuf[18]; u64 field; int ret; - int err; if (*pos) return 0; @@ -445,9 +442,8 @@ static ssize_t dbg_read(struct file *filp, char __user *buf, size_t count, ret = snprintf(tbuf, sizeof(tbuf), "0x%llx\n", field); if (ret > 0) { - err = copy_to_user(buf, tbuf, ret); - if (err) - return err; + if (copy_to_user(buf, tbuf, ret)) + return -EFAULT; } *pos += ret; From d77e41e12744e53ca7f98f920350998b5f00c93a Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Wed, 10 Jul 2013 17:30:34 +0300 Subject: [PATCH 0839/1048] net/tipc: use %*phC to dump small buffers in hex form Instead of passing each byte by stack let's use nice specifier for that. Signed-off-by: Andy Shevchenko Signed-off-by: David S. Miller --- net/tipc/ib_media.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/net/tipc/ib_media.c b/net/tipc/ib_media.c index ad2e1ec4117e..9934a32bfa87 100644 --- a/net/tipc/ib_media.c +++ b/net/tipc/ib_media.c @@ -292,13 +292,7 @@ static int ib_addr2str(struct tipc_media_addr *a, char *str_buf, int str_size) if (str_size < 60) /* 60 = 19 * strlen("xx:") + strlen("xx\0") */ return 1; - sprintf(str_buf, "%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:" - "%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x", - a->value[0], a->value[1], a->value[2], a->value[3], - a->value[4], a->value[5], a->value[6], a->value[7], - a->value[8], a->value[9], a->value[10], a->value[11], - a->value[12], a->value[13], a->value[14], a->value[15], - a->value[16], a->value[17], a->value[18], a->value[19]); + sprintf(str_buf, "%20phC", a->value); return 0; } From c073f666ff5c38477849c5109f2c430df1a60e82 Mon Sep 17 00:00:00 2001 From: hayeswang Date: Mon, 8 Jul 2013 10:41:21 +0800 Subject: [PATCH 0840/1048] net/usb: add relative mii functions for r815x Base on cdc_ether, add the mii functions for RTL8152 and RTL8153. The RTL8152 and RTL8153 support ECM mode which use the driver of cdc_ether. Add the mii functions. Then, the basic PHY access is possible. Signed-off-by: Hayes Wang Signed-off-by: David S. Miller --- drivers/net/usb/Makefile | 2 +- drivers/net/usb/cdc_ether.c | 9 +- drivers/net/usb/r815x.c | 231 ++++++++++++++++++++++++++++++++++++ 3 files changed, 239 insertions(+), 3 deletions(-) create mode 100644 drivers/net/usb/r815x.c diff --git a/drivers/net/usb/Makefile b/drivers/net/usb/Makefile index 9ab5c9d4b45a..e8171784529d 100644 --- a/drivers/net/usb/Makefile +++ b/drivers/net/usb/Makefile @@ -11,7 +11,7 @@ obj-$(CONFIG_USB_HSO) += hso.o obj-$(CONFIG_USB_NET_AX8817X) += asix.o asix-y := asix_devices.o asix_common.o ax88172a.o obj-$(CONFIG_USB_NET_AX88179_178A) += ax88179_178a.o -obj-$(CONFIG_USB_NET_CDCETHER) += cdc_ether.o +obj-$(CONFIG_USB_NET_CDCETHER) += cdc_ether.o r815x.o obj-$(CONFIG_USB_NET_CDC_EEM) += cdc_eem.o obj-$(CONFIG_USB_NET_DM9601) += dm9601.o obj-$(CONFIG_USB_NET_SMSC75XX) += smsc75xx.o diff --git a/drivers/net/usb/cdc_ether.c b/drivers/net/usb/cdc_ether.c index 4393f1483126..03ad4dc293aa 100644 --- a/drivers/net/usb/cdc_ether.c +++ b/drivers/net/usb/cdc_ether.c @@ -646,13 +646,18 @@ static const struct usb_device_id products [] = { }, /* Realtek RTL8152 Based USB 2.0 Ethernet Adapters */ -#if defined(CONFIG_USB_RTL8152) || defined(CONFIG_USB_RTL8152_MODULE) { USB_DEVICE_AND_INTERFACE_INFO(REALTEK_VENDOR_ID, 0x8152, USB_CLASS_COMM, USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE), .driver_info = 0, }, -#endif + +/* Realtek RTL8153 Based USB 3.0 Ethernet Adapters */ +{ + USB_DEVICE_AND_INTERFACE_INFO(REALTEK_VENDOR_ID, 0x8153, USB_CLASS_COMM, + USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE), + .driver_info = 0, +}, /* * WHITELIST!!! diff --git a/drivers/net/usb/r815x.c b/drivers/net/usb/r815x.c new file mode 100644 index 000000000000..65167377ff09 --- /dev/null +++ b/drivers/net/usb/r815x.c @@ -0,0 +1,231 @@ +#include +#include +#include +#include +#include +#include + +#define RTL815x_REQT_READ 0xc0 +#define RTL815x_REQT_WRITE 0x40 +#define RTL815x_REQ_GET_REGS 0x05 +#define RTL815x_REQ_SET_REGS 0x05 + +#define MCU_TYPE_PLA 0x0100 +#define OCP_BASE 0xe86c +#define BASE_MII 0xa400 + +#define BYTE_EN_DWORD 0xff +#define BYTE_EN_WORD 0x33 +#define BYTE_EN_BYTE 0x11 + +#define R815x_PHY_ID 32 +#define REALTEK_VENDOR_ID 0x0bda + + +static int pla_read_word(struct usb_device *udev, u16 index) +{ + int data, ret; + u8 shift = index & 2; + + index &= ~3; + + ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), + RTL815x_REQ_GET_REGS, RTL815x_REQT_READ, + index, MCU_TYPE_PLA, &data, sizeof(data), 500); + if (ret < 0) + return ret; + + data = __le32_to_cpu(data); + data >>= (shift * 8); + data &= 0xffff; + + return data; +} + +static int pla_write_word(struct usb_device *udev, u16 index, u32 data) +{ + u32 tmp, mask = 0xffff; + u16 byen = BYTE_EN_WORD; + u8 shift = index & 2; + int ret; + + data &= mask; + + if (shift) { + byen <<= shift; + mask <<= (shift * 8); + data <<= (shift * 8); + index &= ~3; + } + + ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), + RTL815x_REQ_GET_REGS, RTL815x_REQT_READ, + index, MCU_TYPE_PLA, &tmp, sizeof(tmp), 500); + if (ret < 0) + return ret; + + tmp = __le32_to_cpu(tmp) & ~mask; + tmp |= data; + tmp = __cpu_to_le32(tmp); + + ret = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), + RTL815x_REQ_SET_REGS, RTL815x_REQT_WRITE, + index, MCU_TYPE_PLA | byen, &tmp, + sizeof(tmp), 500); + + return ret; +} + +static int ocp_reg_read(struct usbnet *dev, u16 addr) +{ + u16 ocp_base, ocp_index; + int ret; + + ocp_base = addr & 0xf000; + ret = pla_write_word(dev->udev, OCP_BASE, ocp_base); + if (ret < 0) + goto out; + + ocp_index = (addr & 0x0fff) | 0xb000; + ret = pla_read_word(dev->udev, ocp_index); + +out: + return ret; +} + +static int ocp_reg_write(struct usbnet *dev, u16 addr, u16 data) +{ + u16 ocp_base, ocp_index; + int ret; + + ocp_base = addr & 0xf000; + ret = pla_write_word(dev->udev, OCP_BASE, ocp_base); + if (ret < 0) + goto out1; + + ocp_index = (addr & 0x0fff) | 0xb000; + ret = pla_write_word(dev->udev, ocp_index, data); + +out1: + return ret; +} + +static int r815x_mdio_read(struct net_device *netdev, int phy_id, int reg) +{ + struct usbnet *dev = netdev_priv(netdev); + + if (phy_id != R815x_PHY_ID) + return -EINVAL; + + return ocp_reg_read(dev, BASE_MII + reg * 2); +} + +static +void r815x_mdio_write(struct net_device *netdev, int phy_id, int reg, int val) +{ + struct usbnet *dev = netdev_priv(netdev); + + if (phy_id != R815x_PHY_ID) + return; + + ocp_reg_write(dev, BASE_MII + reg * 2, val); +} + +static int r8153_bind(struct usbnet *dev, struct usb_interface *intf) +{ + int status; + + status = usbnet_cdc_bind(dev, intf); + if (status < 0) + return status; + + dev->mii.dev = dev->net; + dev->mii.mdio_read = r815x_mdio_read; + dev->mii.mdio_write = r815x_mdio_write; + dev->mii.phy_id_mask = 0x3f; + dev->mii.reg_num_mask = 0x1f; + dev->mii.phy_id = R815x_PHY_ID; + dev->mii.supports_gmii = 1; + + return 0; +} + +static int r8152_bind(struct usbnet *dev, struct usb_interface *intf) +{ + int status; + + status = usbnet_cdc_bind(dev, intf); + if (status < 0) + return status; + + dev->mii.dev = dev->net; + dev->mii.mdio_read = r815x_mdio_read; + dev->mii.mdio_write = r815x_mdio_write; + dev->mii.phy_id_mask = 0x3f; + dev->mii.reg_num_mask = 0x1f; + dev->mii.phy_id = R815x_PHY_ID; + dev->mii.supports_gmii = 0; + + return 0; +} + +static const struct driver_info r8152_info = { + .description = "RTL8152 ECM Device", + .flags = FLAG_ETHER | FLAG_POINTTOPOINT, + .bind = r8152_bind, + .unbind = usbnet_cdc_unbind, + .status = usbnet_cdc_status, + .manage_power = usbnet_manage_power, +}; + +static const struct driver_info r8153_info = { + .description = "RTL8153 ECM Device", + .flags = FLAG_ETHER | FLAG_POINTTOPOINT, + .bind = r8153_bind, + .unbind = usbnet_cdc_unbind, + .status = usbnet_cdc_status, + .manage_power = usbnet_manage_power, +}; + +static const struct usb_device_id products[] = { +{ + USB_DEVICE_AND_INTERFACE_INFO(REALTEK_VENDOR_ID, 0x8152, USB_CLASS_COMM, + USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE), +#if defined(CONFIG_USB_RTL8152) || defined(CONFIG_USB_RTL8152_MODULE) + .driver_info = 0, +#else + .driver_info = (unsigned long) &r8152_info, +#endif +}, + +{ + USB_DEVICE_AND_INTERFACE_INFO(REALTEK_VENDOR_ID, 0x8153, USB_CLASS_COMM, + USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE), +#if defined(CONFIG_USB_RTL8153) || defined(CONFIG_USB_RTL8153_MODULE) + .driver_info = 0, +#else + .driver_info = (unsigned long) &r8153_info, +#endif +}, + + { }, /* END */ +}; +MODULE_DEVICE_TABLE(usb, products); + +static struct usb_driver r815x_driver = { + .name = "r815x", + .id_table = products, + .probe = usbnet_probe, + .disconnect = usbnet_disconnect, + .suspend = usbnet_suspend, + .resume = usbnet_resume, + .reset_resume = usbnet_resume, + .supports_autosuspend = 1, + .disable_hub_initiated_lpm = 1, +}; + +module_usb_driver(r815x_driver); + +MODULE_AUTHOR("Hayes Wang"); +MODULE_DESCRIPTION("Realtek USB ECM device"); +MODULE_LICENSE("GPL"); From d25903f894849fa799141e774c4ad34199e3e6a1 Mon Sep 17 00:00:00 2001 From: Wolfram Sang Date: Wed, 10 Jul 2013 16:57:42 +0100 Subject: [PATCH 0841/1048] drivers/net/can/c_can: don't use devm_pinctrl_get_select_default() in probe Since commit ab78029 (drivers/pinctrl: grab default handles from device core), we can rely on device core for setting the default pins. Compile tested only. Acked-by: Linus Walleij (personally at LCE13) Signed-off-by: Wolfram Sang Acked-by: Marc Kleine-Budde Signed-off-by: David S. Miller --- drivers/net/can/c_can/c_can_platform.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/drivers/net/can/c_can/c_can_platform.c b/drivers/net/can/c_can/c_can_platform.c index b918c7329426..c6f838d922a5 100644 --- a/drivers/net/can/c_can/c_can_platform.c +++ b/drivers/net/can/c_can/c_can_platform.c @@ -32,7 +32,6 @@ #include #include #include -#include #include @@ -114,7 +113,6 @@ static int c_can_plat_probe(struct platform_device *pdev) struct c_can_priv *priv; const struct of_device_id *match; const struct platform_device_id *id; - struct pinctrl *pinctrl; struct resource *mem, *res; int irq; struct clk *clk; @@ -131,11 +129,6 @@ static int c_can_plat_probe(struct platform_device *pdev) id = platform_get_device_id(pdev); } - pinctrl = devm_pinctrl_get_select_default(&pdev->dev); - if (IS_ERR(pinctrl)) - dev_warn(&pdev->dev, - "failed to configure pins from driver\n"); - /* get the appropriate clk */ clk = clk_get(&pdev->dev, NULL); if (IS_ERR(clk)) { From 54842ec2b0644b3e04c6fcfb52bc94dfcf918a43 Mon Sep 17 00:00:00 2001 From: Wolfram Sang Date: Wed, 10 Jul 2013 16:57:43 +0100 Subject: [PATCH 0842/1048] drivers/net/ethernet/cadence: don't use devm_pinctrl_get_select_default() in probe Since commit ab78029 (drivers/pinctrl: grab default handles from device core), we can rely on device core for setting the default pins. Compile tested only. Acked-by: Linus Walleij (personally at LCE13) Signed-off-by: Wolfram Sang Acked-by: Nicolas Ferre Signed-off-by: David S. Miller --- drivers/net/ethernet/cadence/at91_ether.c | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/drivers/net/ethernet/cadence/at91_ether.c b/drivers/net/ethernet/cadence/at91_ether.c index 3f1957158a3b..bb5d63fb2e6d 100644 --- a/drivers/net/ethernet/cadence/at91_ether.c +++ b/drivers/net/ethernet/cadence/at91_ether.c @@ -29,7 +29,6 @@ #include #include #include -#include #include "macb.h" @@ -309,7 +308,6 @@ static int __init at91ether_probe(struct platform_device *pdev) struct resource *regs; struct net_device *dev; struct phy_device *phydev; - struct pinctrl *pinctrl; struct macb *lp; int res; u32 reg; @@ -319,15 +317,6 @@ static int __init at91ether_probe(struct platform_device *pdev) if (!regs) return -ENOENT; - pinctrl = devm_pinctrl_get_select_default(&pdev->dev); - if (IS_ERR(pinctrl)) { - res = PTR_ERR(pinctrl); - if (res == -EPROBE_DEFER) - return res; - - dev_warn(&pdev->dev, "No pinctrl provided\n"); - } - dev = alloc_etherdev(sizeof(struct macb)); if (!dev) return -ENOMEM; From fdb70270015466076846a0525f195f59849c1966 Mon Sep 17 00:00:00 2001 From: Wolfram Sang Date: Wed, 10 Jul 2013 16:57:44 +0100 Subject: [PATCH 0843/1048] drivers/net/ieee802154: don't use devm_pinctrl_get_select_default() in probe Since commit ab78029 (drivers/pinctrl: grab default handles from device core), we can rely on device core for setting the default pins. Compile tested only. Acked-by: Linus Walleij (personally at LCE13) Signed-off-by: Wolfram Sang Signed-off-by: David S. Miller --- drivers/net/ieee802154/mrf24j40.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/drivers/net/ieee802154/mrf24j40.c b/drivers/net/ieee802154/mrf24j40.c index ede3ce4912f9..42e6deee6db5 100644 --- a/drivers/net/ieee802154/mrf24j40.c +++ b/drivers/net/ieee802154/mrf24j40.c @@ -22,7 +22,6 @@ #include #include #include -#include #include #include #include @@ -627,7 +626,6 @@ static int mrf24j40_probe(struct spi_device *spi) int ret = -ENOMEM; u8 val; struct mrf24j40 *devrec; - struct pinctrl *pinctrl; printk(KERN_INFO "mrf24j40: probe(). IRQ: %d\n", spi->irq); @@ -638,11 +636,6 @@ static int mrf24j40_probe(struct spi_device *spi) if (!devrec->buf) goto err_buf; - pinctrl = devm_pinctrl_get_select_default(&spi->dev); - if (IS_ERR(pinctrl)) - dev_warn(&spi->dev, - "pinctrl pins are not configured from the driver"); - spi->mode = SPI_MODE_0; /* TODO: Is this appropriate for right here? */ if (spi->max_speed_hz > MAX_SPI_SPEED_HZ) spi->max_speed_hz = MAX_SPI_SPEED_HZ; From e8974c3930ae9692bb4f77380961421e9a2f76ab Mon Sep 17 00:00:00 2001 From: Anatol Pomozov Date: Thu, 11 Jul 2013 22:42:42 -0400 Subject: [PATCH 0844/1048] ext4: rate limit printk in buffer_io_error() If there are a lot of outstanding buffered IOs when a device is taken offline (due to hardware errors etc), ext4_end_bio prints out a message for each failed logical block. While this is desirable, we see thousands of such lines being printed out before the serial console gets overwhelmed, causing ext4_end_bio() wait for the printk to complete. This in itself isn't a disaster, except for the detail that this function is being called with the queue lock held. This causes any other function in the block layer to spin on its spin_lock_irqsave while the serial console is draining. If NMI watchdog is enabled on this machine then it eventually comes along and shoots the machine in the head. The end result is that losing any one disk causes the machine to go down. This patch rate limits the printk to bandaid around the problem. Tested: xfstests Change-Id: I8ab5690dcf4f3a67e78be147d45e489fdf4a88d8 Signed-off-by: Anatol Pomozov Signed-off-by: "Theodore Ts'o" --- fs/ext4/page-io.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/ext4/page-io.c b/fs/ext4/page-io.c index d63cc5e9d3b5..6625d210fb45 100644 --- a/fs/ext4/page-io.c +++ b/fs/ext4/page-io.c @@ -25,6 +25,7 @@ #include #include #include +#include #include "ext4_jbd2.h" #include "xattr.h" @@ -55,7 +56,7 @@ void ext4_exit_pageio(void) static void buffer_io_error(struct buffer_head *bh) { char b[BDEVNAME_SIZE]; - printk(KERN_ERR "Buffer I/O error on device %s, logical block %llu\n", + printk_ratelimited(KERN_ERR "Buffer I/O error on device %s, logical block %llu\n", bdevname(bh->b_bdev, b), (unsigned long long)bh->b_blocknr); } From 5f17482a3244c07646279d16c0e5b8c0b2b76d0e Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Thu, 11 Jul 2013 20:09:43 -0700 Subject: [PATCH 0845/1048] ASoC: wm8978: enable symmetric rates wm8978 needs .symmetric_rates = 1. The playback/capture will be strange without this patch when it used asymmetric rate in same time Tested-by: Yusuke Goda Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/wm8978.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sound/soc/codecs/wm8978.c b/sound/soc/codecs/wm8978.c index 029f31c8e703..d8fc531c0e59 100644 --- a/sound/soc/codecs/wm8978.c +++ b/sound/soc/codecs/wm8978.c @@ -921,6 +921,7 @@ static struct snd_soc_dai_driver wm8978_dai = { .formats = WM8978_FORMATS, }, .ops = &wm8978_dai_ops, + .symmetric_rates = 1, }; static int wm8978_suspend(struct snd_soc_codec *codec) From 734df5ab549ca44f40de0f07af1c8803856dfb18 Mon Sep 17 00:00:00 2001 From: Jiri Olsa Date: Tue, 9 Jul 2013 17:44:10 +0200 Subject: [PATCH 0846/1048] perf: Clone child context from parent context pmu Currently when the child context for inherited events is created, it's based on the pmu object of the first event of the parent context. This is wrong for the following scenario: - HW context having HW and SW event - HW event got removed (closed) - SW event stays in HW context as the only event and its pmu is used to clone the child context The issue starts when the cpu context object is touched based on the pmu context object (__get_cpu_context). In this case the HW context will work with SW cpu context ending up with following WARN below. Fixing this by using parent context pmu object to clone from child context. Addresses the following warning reported by Vince Weaver: [ 2716.472065] ------------[ cut here ]------------ [ 2716.476035] WARNING: at kernel/events/core.c:2122 task_ctx_sched_out+0x3c/0x) [ 2716.476035] Modules linked in: nfsd auth_rpcgss oid_registry nfs_acl nfs locn [ 2716.476035] CPU: 0 PID: 3164 Comm: perf_fuzzer Not tainted 3.10.0-rc4 #2 [ 2716.476035] Hardware name: AOpen DE7000/nMCP7ALPx-DE R1.06 Oct.19.2012, BI2 [ 2716.476035] 0000000000000000 ffffffff8102e215 0000000000000000 ffff88011fc18 [ 2716.476035] ffff8801175557f0 0000000000000000 ffff880119fda88c ffffffff810ad [ 2716.476035] ffff880119fda880 ffffffff810af02a 0000000000000009 ffff880117550 [ 2716.476035] Call Trace: [ 2716.476035] [] ? warn_slowpath_common+0x5b/0x70 [ 2716.476035] [] ? task_ctx_sched_out+0x3c/0x5f [ 2716.476035] [] ? perf_event_exit_task+0xbf/0x194 [ 2716.476035] [] ? do_exit+0x3e7/0x90c [ 2716.476035] [] ? __do_fault+0x359/0x394 [ 2716.476035] [] ? do_group_exit+0x66/0x98 [ 2716.476035] [] ? get_signal_to_deliver+0x479/0x4ad [ 2716.476035] [] ? __perf_event_task_sched_out+0x230/0x2d1 [ 2716.476035] [] ? do_signal+0x3c/0x432 [ 2716.476035] [] ? ctx_sched_in+0x43/0x141 [ 2716.476035] [] ? perf_event_context_sched_in+0x7a/0x90 [ 2716.476035] [] ? __perf_event_task_sched_in+0x31/0x118 [ 2716.476035] [] ? mmdrop+0xd/0x1c [ 2716.476035] [] ? finish_task_switch+0x7d/0xa6 [ 2716.476035] [] ? do_notify_resume+0x20/0x5d [ 2716.476035] [] ? retint_signal+0x3d/0x78 [ 2716.476035] ---[ end trace 827178d8a5966c3d ]--- Reported-by: Vince Weaver Signed-off-by: Jiri Olsa Cc: Corey Ashford Cc: Frederic Weisbecker Cc: Ingo Molnar Cc: Namhyung Kim Cc: Paul Mackerras Cc: Arnaldo Carvalho de Melo Cc: Signed-off-by: Peter Zijlstra Link: http://lkml.kernel.org/r/1373384651-6109-1-git-send-email-jolsa@redhat.com Signed-off-by: Ingo Molnar --- kernel/events/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/events/core.c b/kernel/events/core.c index 1833bc5a84a7..1d1f030e2f1e 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -7465,7 +7465,7 @@ inherit_task_group(struct perf_event *event, struct task_struct *parent, * child. */ - child_ctx = alloc_perf_context(event->pmu, child); + child_ctx = alloc_perf_context(parent_ctx->pmu, child); if (!child_ctx) return -ENOMEM; From 06f417968beac6e6b614e17b37d347aa6a6b1d30 Mon Sep 17 00:00:00 2001 From: Jiri Olsa Date: Tue, 9 Jul 2013 17:44:11 +0200 Subject: [PATCH 0847/1048] perf: Remove WARN_ON_ONCE() check in __perf_event_enable() for valid scenario The '!ctx->is_active' check has a valid scenario, so there's no need for the warning. The reason is that there's a time window between the 'ctx->is_active' check in the perf_event_enable() function and the __perf_event_enable() function having: - IRQs on - ctx->lock unlocked where the task could be killed and 'ctx' deactivated by perf_event_exit_task(), ending up with the warning below. So remove the WARN_ON_ONCE() check and add comments to explain it all. This addresses the following warning reported by Vince Weaver: [ 324.983534] ------------[ cut here ]------------ [ 324.984420] WARNING: at kernel/events/core.c:1953 __perf_event_enable+0x187/0x190() [ 324.984420] Modules linked in: [ 324.984420] CPU: 19 PID: 2715 Comm: nmi_bug_snb Not tainted 3.10.0+ #246 [ 324.984420] Hardware name: Supermicro X8DTN/X8DTN, BIOS 4.6.3 01/08/2010 [ 324.984420] 0000000000000009 ffff88043fce3ec8 ffffffff8160ea0b ffff88043fce3f00 [ 324.984420] ffffffff81080ff0 ffff8802314fdc00 ffff880231a8f800 ffff88043fcf7860 [ 324.984420] 0000000000000286 ffff880231a8f800 ffff88043fce3f10 ffffffff8108103a [ 324.984420] Call Trace: [ 324.984420] [] dump_stack+0x19/0x1b [ 324.984420] [] warn_slowpath_common+0x70/0xa0 [ 324.984420] [] warn_slowpath_null+0x1a/0x20 [ 324.984420] [] __perf_event_enable+0x187/0x190 [ 324.984420] [] remote_function+0x40/0x50 [ 324.984420] [] generic_smp_call_function_single_interrupt+0xbe/0x130 [ 324.984420] [] smp_call_function_single_interrupt+0x27/0x40 [ 324.984420] [] call_function_single_interrupt+0x6f/0x80 [ 324.984420] [] ? _raw_spin_unlock_irqrestore+0x41/0x70 [ 324.984420] [] perf_event_exit_task+0x14d/0x210 [ 324.984420] [] ? switch_task_namespaces+0x24/0x60 [ 324.984420] [] do_exit+0x2b6/0xa40 [ 324.984420] [] ? _raw_spin_unlock_irq+0x2c/0x30 [ 324.984420] [] do_group_exit+0x49/0xc0 [ 324.984420] [] get_signal_to_deliver+0x254/0x620 [ 324.984420] [] do_signal+0x57/0x5a0 [ 324.984420] [] ? __do_page_fault+0x2a4/0x4e0 [ 324.984420] [] ? retint_restore_args+0xe/0xe [ 324.984420] [] ? retint_signal+0x11/0x84 [ 324.984420] [] do_notify_resume+0x65/0x80 [ 324.984420] [] retint_signal+0x46/0x84 [ 324.984420] ---[ end trace 442ec2f04db3771a ]--- Reported-by: Vince Weaver Signed-off-by: Jiri Olsa Suggested-by: Peter Zijlstra Cc: Corey Ashford Cc: Frederic Weisbecker Cc: Ingo Molnar Cc: Namhyung Kim Cc: Paul Mackerras Cc: Arnaldo Carvalho de Melo Cc: Signed-off-by: Peter Zijlstra Link: http://lkml.kernel.org/r/1373384651-6109-2-git-send-email-jolsa@redhat.com Signed-off-by: Ingo Molnar --- kernel/events/core.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/kernel/events/core.c b/kernel/events/core.c index 1d1f030e2f1e..ef5e7cc686e3 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -1950,7 +1950,16 @@ static int __perf_event_enable(void *info) struct perf_cpu_context *cpuctx = __get_cpu_context(ctx); int err; - if (WARN_ON_ONCE(!ctx->is_active)) + /* + * There's a time window between 'ctx->is_active' check + * in perf_event_enable function and this place having: + * - IRQs on + * - ctx->lock unlocked + * + * where the task could be killed and 'ctx' deactivated + * by perf_event_exit_task. + */ + if (!ctx->is_active) return -EINVAL; raw_spin_lock(&ctx->lock); From 058ebd0eba3aff16b144eabf4510ed9510e1416e Mon Sep 17 00:00:00 2001 From: Peter Zijlstra Date: Fri, 12 Jul 2013 11:08:33 +0200 Subject: [PATCH 0848/1048] perf: Fix perf_lock_task_context() vs RCU Jiri managed to trigger this warning: [] ====================================================== [] [ INFO: possible circular locking dependency detected ] [] 3.10.0+ #228 Tainted: G W [] ------------------------------------------------------- [] p/6613 is trying to acquire lock: [] (rcu_node_0){..-...}, at: [] rcu_read_unlock_special+0xa7/0x250 [] [] but task is already holding lock: [] (&ctx->lock){-.-...}, at: [] perf_lock_task_context+0xd9/0x2c0 [] [] which lock already depends on the new lock. [] [] the existing dependency chain (in reverse order) is: [] [] -> #4 (&ctx->lock){-.-...}: [] -> #3 (&rq->lock){-.-.-.}: [] -> #2 (&p->pi_lock){-.-.-.}: [] -> #1 (&rnp->nocb_gp_wq[1]){......}: [] -> #0 (rcu_node_0){..-...}: Paul was quick to explain that due to preemptible RCU we cannot call rcu_read_unlock() while holding scheduler (or nested) locks when part of the read side critical section was preemptible. Therefore solve it by making the entire RCU read side non-preemptible. Also pull out the retry from under the non-preempt to play nice with RT. Reported-by: Jiri Olsa Helped-out-by: Paul E. McKenney Cc: Signed-off-by: Peter Zijlstra Signed-off-by: Ingo Molnar --- kernel/events/core.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/kernel/events/core.c b/kernel/events/core.c index ef5e7cc686e3..eba8fb5834ae 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -947,8 +947,18 @@ perf_lock_task_context(struct task_struct *task, int ctxn, unsigned long *flags) { struct perf_event_context *ctx; - rcu_read_lock(); retry: + /* + * One of the few rules of preemptible RCU is that one cannot do + * rcu_read_unlock() while holding a scheduler (or nested) lock when + * part of the read side critical section was preemptible -- see + * rcu_read_unlock_special(). + * + * Since ctx->lock nests under rq->lock we must ensure the entire read + * side critical section is non-preemptible. + */ + preempt_disable(); + rcu_read_lock(); ctx = rcu_dereference(task->perf_event_ctxp[ctxn]); if (ctx) { /* @@ -964,6 +974,8 @@ retry: raw_spin_lock_irqsave(&ctx->lock, *flags); if (ctx != rcu_dereference(task->perf_event_ctxp[ctxn])) { raw_spin_unlock_irqrestore(&ctx->lock, *flags); + rcu_read_unlock(); + preempt_enable(); goto retry; } @@ -973,6 +985,7 @@ retry: } } rcu_read_unlock(); + preempt_enable(); return ctx; } From 1b375dc30710180c4b88cc59caba6e3481ec5c8b Mon Sep 17 00:00:00 2001 From: Maarten Lankhorst Date: Fri, 5 Jul 2013 09:29:32 +0200 Subject: [PATCH 0849/1048] mutex: Move ww_mutex definitions to ww_mutex.h Move the definitions for wound/wait mutexes out to a separate header, ww_mutex.h. This reduces clutter in mutex.h, and increases readability. Suggested-by: Linus Torvalds Signed-off-by: Maarten Lankhorst Acked-by: Peter Zijlstra Acked-by: Rik van Riel Acked-by: Maarten Lankhorst Cc: Dave Airlie Link: http://lkml.kernel.org/r/51D675DC.3000907@canonical.com [ Tidied up the code a bit. ] Signed-off-by: Ingo Molnar --- include/linux/mutex.h | 358 ---------------------------------- include/linux/reservation.h | 2 +- include/linux/ww_mutex.h | 378 ++++++++++++++++++++++++++++++++++++ kernel/mutex.c | 1 + lib/locking-selftest.c | 1 + 5 files changed, 381 insertions(+), 359 deletions(-) create mode 100644 include/linux/ww_mutex.h diff --git a/include/linux/mutex.h b/include/linux/mutex.h index 3793ed7feeeb..ccd4260834c5 100644 --- a/include/linux/mutex.h +++ b/include/linux/mutex.h @@ -78,40 +78,6 @@ struct mutex_waiter { #endif }; -struct ww_class { - atomic_long_t stamp; - struct lock_class_key acquire_key; - struct lock_class_key mutex_key; - const char *acquire_name; - const char *mutex_name; -}; - -struct ww_acquire_ctx { - struct task_struct *task; - unsigned long stamp; - unsigned acquired; -#ifdef CONFIG_DEBUG_MUTEXES - unsigned done_acquire; - struct ww_class *ww_class; - struct ww_mutex *contending_lock; -#endif -#ifdef CONFIG_DEBUG_LOCK_ALLOC - struct lockdep_map dep_map; -#endif -#ifdef CONFIG_DEBUG_WW_MUTEX_SLOWPATH - unsigned deadlock_inject_interval; - unsigned deadlock_inject_countdown; -#endif -}; - -struct ww_mutex { - struct mutex base; - struct ww_acquire_ctx *ctx; -#ifdef CONFIG_DEBUG_MUTEXES - struct ww_class *ww_class; -#endif -}; - #ifdef CONFIG_DEBUG_MUTEXES # include #else @@ -136,11 +102,8 @@ static inline void mutex_destroy(struct mutex *lock) {} #ifdef CONFIG_DEBUG_LOCK_ALLOC # define __DEP_MAP_MUTEX_INITIALIZER(lockname) \ , .dep_map = { .name = #lockname } -# define __WW_CLASS_MUTEX_INITIALIZER(lockname, ww_class) \ - , .ww_class = &ww_class #else # define __DEP_MAP_MUTEX_INITIALIZER(lockname) -# define __WW_CLASS_MUTEX_INITIALIZER(lockname, ww_class) #endif #define __MUTEX_INITIALIZER(lockname) \ @@ -150,48 +113,12 @@ static inline void mutex_destroy(struct mutex *lock) {} __DEBUG_MUTEX_INITIALIZER(lockname) \ __DEP_MAP_MUTEX_INITIALIZER(lockname) } -#define __WW_CLASS_INITIALIZER(ww_class) \ - { .stamp = ATOMIC_LONG_INIT(0) \ - , .acquire_name = #ww_class "_acquire" \ - , .mutex_name = #ww_class "_mutex" } - -#define __WW_MUTEX_INITIALIZER(lockname, class) \ - { .base = { \__MUTEX_INITIALIZER(lockname) } \ - __WW_CLASS_MUTEX_INITIALIZER(lockname, class) } - #define DEFINE_MUTEX(mutexname) \ struct mutex mutexname = __MUTEX_INITIALIZER(mutexname) -#define DEFINE_WW_CLASS(classname) \ - struct ww_class classname = __WW_CLASS_INITIALIZER(classname) - -#define DEFINE_WW_MUTEX(mutexname, ww_class) \ - struct ww_mutex mutexname = __WW_MUTEX_INITIALIZER(mutexname, ww_class) - - extern void __mutex_init(struct mutex *lock, const char *name, struct lock_class_key *key); -/** - * ww_mutex_init - initialize the w/w mutex - * @lock: the mutex to be initialized - * @ww_class: the w/w class the mutex should belong to - * - * Initialize the w/w mutex to unlocked state and associate it with the given - * class. - * - * It is not allowed to initialize an already locked mutex. - */ -static inline void ww_mutex_init(struct ww_mutex *lock, - struct ww_class *ww_class) -{ - __mutex_init(&lock->base, ww_class->mutex_name, &ww_class->mutex_key); - lock->ctx = NULL; -#ifdef CONFIG_DEBUG_MUTEXES - lock->ww_class = ww_class; -#endif -} - /** * mutex_is_locked - is the mutex locked * @lock: the mutex to be queried @@ -246,291 +173,6 @@ extern int __must_check mutex_lock_killable(struct mutex *lock); extern int mutex_trylock(struct mutex *lock); extern void mutex_unlock(struct mutex *lock); -/** - * ww_acquire_init - initialize a w/w acquire context - * @ctx: w/w acquire context to initialize - * @ww_class: w/w class of the context - * - * Initializes an context to acquire multiple mutexes of the given w/w class. - * - * Context-based w/w mutex acquiring can be done in any order whatsoever within - * a given lock class. Deadlocks will be detected and handled with the - * wait/wound logic. - * - * Mixing of context-based w/w mutex acquiring and single w/w mutex locking can - * result in undetected deadlocks and is so forbidden. Mixing different contexts - * for the same w/w class when acquiring mutexes can also result in undetected - * deadlocks, and is hence also forbidden. Both types of abuse will be caught by - * enabling CONFIG_PROVE_LOCKING. - * - * Nesting of acquire contexts for _different_ w/w classes is possible, subject - * to the usual locking rules between different lock classes. - * - * An acquire context must be released with ww_acquire_fini by the same task - * before the memory is freed. It is recommended to allocate the context itself - * on the stack. - */ -static inline void ww_acquire_init(struct ww_acquire_ctx *ctx, - struct ww_class *ww_class) -{ - ctx->task = current; - ctx->stamp = atomic_long_inc_return(&ww_class->stamp); - ctx->acquired = 0; -#ifdef CONFIG_DEBUG_MUTEXES - ctx->ww_class = ww_class; - ctx->done_acquire = 0; - ctx->contending_lock = NULL; -#endif -#ifdef CONFIG_DEBUG_LOCK_ALLOC - debug_check_no_locks_freed((void *)ctx, sizeof(*ctx)); - lockdep_init_map(&ctx->dep_map, ww_class->acquire_name, - &ww_class->acquire_key, 0); - mutex_acquire(&ctx->dep_map, 0, 0, _RET_IP_); -#endif -#ifdef CONFIG_DEBUG_WW_MUTEX_SLOWPATH - ctx->deadlock_inject_interval = 1; - ctx->deadlock_inject_countdown = ctx->stamp & 0xf; -#endif -} - -/** - * ww_acquire_done - marks the end of the acquire phase - * @ctx: the acquire context - * - * Marks the end of the acquire phase, any further w/w mutex lock calls using - * this context are forbidden. - * - * Calling this function is optional, it is just useful to document w/w mutex - * code and clearly designated the acquire phase from actually using the locked - * data structures. - */ -static inline void ww_acquire_done(struct ww_acquire_ctx *ctx) -{ -#ifdef CONFIG_DEBUG_MUTEXES - lockdep_assert_held(ctx); - - DEBUG_LOCKS_WARN_ON(ctx->done_acquire); - ctx->done_acquire = 1; -#endif -} - -/** - * ww_acquire_fini - releases a w/w acquire context - * @ctx: the acquire context to free - * - * Releases a w/w acquire context. This must be called _after_ all acquired w/w - * mutexes have been released with ww_mutex_unlock. - */ -static inline void ww_acquire_fini(struct ww_acquire_ctx *ctx) -{ -#ifdef CONFIG_DEBUG_MUTEXES - mutex_release(&ctx->dep_map, 0, _THIS_IP_); - - DEBUG_LOCKS_WARN_ON(ctx->acquired); - if (!config_enabled(CONFIG_PROVE_LOCKING)) - /* - * lockdep will normally handle this, - * but fail without anyway - */ - ctx->done_acquire = 1; - - if (!config_enabled(CONFIG_DEBUG_LOCK_ALLOC)) - /* ensure ww_acquire_fini will still fail if called twice */ - ctx->acquired = ~0U; -#endif -} - -extern int __must_check __ww_mutex_lock(struct ww_mutex *lock, - struct ww_acquire_ctx *ctx); -extern int __must_check __ww_mutex_lock_interruptible(struct ww_mutex *lock, - struct ww_acquire_ctx *ctx); - -/** - * ww_mutex_lock - acquire the w/w mutex - * @lock: the mutex to be acquired - * @ctx: w/w acquire context, or NULL to acquire only a single lock. - * - * Lock the w/w mutex exclusively for this task. - * - * Deadlocks within a given w/w class of locks are detected and handled with the - * wait/wound algorithm. If the lock isn't immediately avaiable this function - * will either sleep until it is (wait case). Or it selects the current context - * for backing off by returning -EDEADLK (wound case). Trying to acquire the - * same lock with the same context twice is also detected and signalled by - * returning -EALREADY. Returns 0 if the mutex was successfully acquired. - * - * In the wound case the caller must release all currently held w/w mutexes for - * the given context and then wait for this contending lock to be available by - * calling ww_mutex_lock_slow. Alternatively callers can opt to not acquire this - * lock and proceed with trying to acquire further w/w mutexes (e.g. when - * scanning through lru lists trying to free resources). - * - * The mutex must later on be released by the same task that - * acquired it. The task may not exit without first unlocking the mutex. Also, - * kernel memory where the mutex resides must not be freed with the mutex still - * locked. The mutex must first be initialized (or statically defined) before it - * can be locked. memset()-ing the mutex to 0 is not allowed. The mutex must be - * of the same w/w lock class as was used to initialize the acquire context. - * - * A mutex acquired with this function must be released with ww_mutex_unlock. - */ -static inline int ww_mutex_lock(struct ww_mutex *lock, struct ww_acquire_ctx *ctx) -{ - if (ctx) - return __ww_mutex_lock(lock, ctx); - else { - mutex_lock(&lock->base); - return 0; - } -} - -/** - * ww_mutex_lock_interruptible - acquire the w/w mutex, interruptible - * @lock: the mutex to be acquired - * @ctx: w/w acquire context - * - * Lock the w/w mutex exclusively for this task. - * - * Deadlocks within a given w/w class of locks are detected and handled with the - * wait/wound algorithm. If the lock isn't immediately avaiable this function - * will either sleep until it is (wait case). Or it selects the current context - * for backing off by returning -EDEADLK (wound case). Trying to acquire the - * same lock with the same context twice is also detected and signalled by - * returning -EALREADY. Returns 0 if the mutex was successfully acquired. If a - * signal arrives while waiting for the lock then this function returns -EINTR. - * - * In the wound case the caller must release all currently held w/w mutexes for - * the given context and then wait for this contending lock to be available by - * calling ww_mutex_lock_slow_interruptible. Alternatively callers can opt to - * not acquire this lock and proceed with trying to acquire further w/w mutexes - * (e.g. when scanning through lru lists trying to free resources). - * - * The mutex must later on be released by the same task that - * acquired it. The task may not exit without first unlocking the mutex. Also, - * kernel memory where the mutex resides must not be freed with the mutex still - * locked. The mutex must first be initialized (or statically defined) before it - * can be locked. memset()-ing the mutex to 0 is not allowed. The mutex must be - * of the same w/w lock class as was used to initialize the acquire context. - * - * A mutex acquired with this function must be released with ww_mutex_unlock. - */ -static inline int __must_check ww_mutex_lock_interruptible(struct ww_mutex *lock, - struct ww_acquire_ctx *ctx) -{ - if (ctx) - return __ww_mutex_lock_interruptible(lock, ctx); - else - return mutex_lock_interruptible(&lock->base); -} - -/** - * ww_mutex_lock_slow - slowpath acquiring of the w/w mutex - * @lock: the mutex to be acquired - * @ctx: w/w acquire context - * - * Acquires a w/w mutex with the given context after a wound case. This function - * will sleep until the lock becomes available. - * - * The caller must have released all w/w mutexes already acquired with the - * context and then call this function on the contended lock. - * - * Afterwards the caller may continue to (re)acquire the other w/w mutexes it - * needs with ww_mutex_lock. Note that the -EALREADY return code from - * ww_mutex_lock can be used to avoid locking this contended mutex twice. - * - * It is forbidden to call this function with any other w/w mutexes associated - * with the context held. It is forbidden to call this on anything else than the - * contending mutex. - * - * Note that the slowpath lock acquiring can also be done by calling - * ww_mutex_lock directly. This function here is simply to help w/w mutex - * locking code readability by clearly denoting the slowpath. - */ -static inline void -ww_mutex_lock_slow(struct ww_mutex *lock, struct ww_acquire_ctx *ctx) -{ - int ret; -#ifdef CONFIG_DEBUG_MUTEXES - DEBUG_LOCKS_WARN_ON(!ctx->contending_lock); -#endif - ret = ww_mutex_lock(lock, ctx); - (void)ret; -} - -/** - * ww_mutex_lock_slow_interruptible - slowpath acquiring of the w/w mutex, - * interruptible - * @lock: the mutex to be acquired - * @ctx: w/w acquire context - * - * Acquires a w/w mutex with the given context after a wound case. This function - * will sleep until the lock becomes available and returns 0 when the lock has - * been acquired. If a signal arrives while waiting for the lock then this - * function returns -EINTR. - * - * The caller must have released all w/w mutexes already acquired with the - * context and then call this function on the contended lock. - * - * Afterwards the caller may continue to (re)acquire the other w/w mutexes it - * needs with ww_mutex_lock. Note that the -EALREADY return code from - * ww_mutex_lock can be used to avoid locking this contended mutex twice. - * - * It is forbidden to call this function with any other w/w mutexes associated - * with the given context held. It is forbidden to call this on anything else - * than the contending mutex. - * - * Note that the slowpath lock acquiring can also be done by calling - * ww_mutex_lock_interruptible directly. This function here is simply to help - * w/w mutex locking code readability by clearly denoting the slowpath. - */ -static inline int __must_check -ww_mutex_lock_slow_interruptible(struct ww_mutex *lock, - struct ww_acquire_ctx *ctx) -{ -#ifdef CONFIG_DEBUG_MUTEXES - DEBUG_LOCKS_WARN_ON(!ctx->contending_lock); -#endif - return ww_mutex_lock_interruptible(lock, ctx); -} - -extern void ww_mutex_unlock(struct ww_mutex *lock); - -/** - * ww_mutex_trylock - tries to acquire the w/w mutex without acquire context - * @lock: mutex to lock - * - * Trylocks a mutex without acquire context, so no deadlock detection is - * possible. Returns 1 if the mutex has been acquired successfully, 0 otherwise. - */ -static inline int __must_check ww_mutex_trylock(struct ww_mutex *lock) -{ - return mutex_trylock(&lock->base); -} - -/*** - * ww_mutex_destroy - mark a w/w mutex unusable - * @lock: the mutex to be destroyed - * - * This function marks the mutex uninitialized, and any subsequent - * use of the mutex is forbidden. The mutex must not be locked when - * this function is called. - */ -static inline void ww_mutex_destroy(struct ww_mutex *lock) -{ - mutex_destroy(&lock->base); -} - -/** - * ww_mutex_is_locked - is the w/w mutex locked - * @lock: the mutex to be queried - * - * Returns 1 if the mutex is locked, 0 if unlocked. - */ -static inline bool ww_mutex_is_locked(struct ww_mutex *lock) -{ - return mutex_is_locked(&lock->base); -} - extern int atomic_dec_and_mutex_lock(atomic_t *cnt, struct mutex *lock); #ifndef CONFIG_HAVE_ARCH_MUTEX_CPU_RELAX diff --git a/include/linux/reservation.h b/include/linux/reservation.h index e9ee806a9d72..813dae960ebd 100644 --- a/include/linux/reservation.h +++ b/include/linux/reservation.h @@ -39,7 +39,7 @@ #ifndef _LINUX_RESERVATION_H #define _LINUX_RESERVATION_H -#include +#include extern struct ww_class reservation_ww_class; diff --git a/include/linux/ww_mutex.h b/include/linux/ww_mutex.h new file mode 100644 index 000000000000..760399a470bd --- /dev/null +++ b/include/linux/ww_mutex.h @@ -0,0 +1,378 @@ +/* + * Wound/Wait Mutexes: blocking mutual exclusion locks with deadlock avoidance + * + * Original mutex implementation started by Ingo Molnar: + * + * Copyright (C) 2004, 2005, 2006 Red Hat, Inc., Ingo Molnar + * + * Wound/wait implementation: + * Copyright (C) 2013 Canonical Ltd. + * + * This file contains the main data structure and API definitions. + */ + +#ifndef __LINUX_WW_MUTEX_H +#define __LINUX_WW_MUTEX_H + +#include + +struct ww_class { + atomic_long_t stamp; + struct lock_class_key acquire_key; + struct lock_class_key mutex_key; + const char *acquire_name; + const char *mutex_name; +}; + +struct ww_acquire_ctx { + struct task_struct *task; + unsigned long stamp; + unsigned acquired; +#ifdef CONFIG_DEBUG_MUTEXES + unsigned done_acquire; + struct ww_class *ww_class; + struct ww_mutex *contending_lock; +#endif +#ifdef CONFIG_DEBUG_LOCK_ALLOC + struct lockdep_map dep_map; +#endif +#ifdef CONFIG_DEBUG_WW_MUTEX_SLOWPATH + unsigned deadlock_inject_interval; + unsigned deadlock_inject_countdown; +#endif +}; + +struct ww_mutex { + struct mutex base; + struct ww_acquire_ctx *ctx; +#ifdef CONFIG_DEBUG_MUTEXES + struct ww_class *ww_class; +#endif +}; + +#ifdef CONFIG_DEBUG_LOCK_ALLOC +# define __WW_CLASS_MUTEX_INITIALIZER(lockname, ww_class) \ + , .ww_class = &ww_class +#else +# define __WW_CLASS_MUTEX_INITIALIZER(lockname, ww_class) +#endif + +#define __WW_CLASS_INITIALIZER(ww_class) \ + { .stamp = ATOMIC_LONG_INIT(0) \ + , .acquire_name = #ww_class "_acquire" \ + , .mutex_name = #ww_class "_mutex" } + +#define __WW_MUTEX_INITIALIZER(lockname, class) \ + { .base = { \__MUTEX_INITIALIZER(lockname) } \ + __WW_CLASS_MUTEX_INITIALIZER(lockname, class) } + +#define DEFINE_WW_CLASS(classname) \ + struct ww_class classname = __WW_CLASS_INITIALIZER(classname) + +#define DEFINE_WW_MUTEX(mutexname, ww_class) \ + struct ww_mutex mutexname = __WW_MUTEX_INITIALIZER(mutexname, ww_class) + +/** + * ww_mutex_init - initialize the w/w mutex + * @lock: the mutex to be initialized + * @ww_class: the w/w class the mutex should belong to + * + * Initialize the w/w mutex to unlocked state and associate it with the given + * class. + * + * It is not allowed to initialize an already locked mutex. + */ +static inline void ww_mutex_init(struct ww_mutex *lock, + struct ww_class *ww_class) +{ + __mutex_init(&lock->base, ww_class->mutex_name, &ww_class->mutex_key); + lock->ctx = NULL; +#ifdef CONFIG_DEBUG_MUTEXES + lock->ww_class = ww_class; +#endif +} + +/** + * ww_acquire_init - initialize a w/w acquire context + * @ctx: w/w acquire context to initialize + * @ww_class: w/w class of the context + * + * Initializes an context to acquire multiple mutexes of the given w/w class. + * + * Context-based w/w mutex acquiring can be done in any order whatsoever within + * a given lock class. Deadlocks will be detected and handled with the + * wait/wound logic. + * + * Mixing of context-based w/w mutex acquiring and single w/w mutex locking can + * result in undetected deadlocks and is so forbidden. Mixing different contexts + * for the same w/w class when acquiring mutexes can also result in undetected + * deadlocks, and is hence also forbidden. Both types of abuse will be caught by + * enabling CONFIG_PROVE_LOCKING. + * + * Nesting of acquire contexts for _different_ w/w classes is possible, subject + * to the usual locking rules between different lock classes. + * + * An acquire context must be released with ww_acquire_fini by the same task + * before the memory is freed. It is recommended to allocate the context itself + * on the stack. + */ +static inline void ww_acquire_init(struct ww_acquire_ctx *ctx, + struct ww_class *ww_class) +{ + ctx->task = current; + ctx->stamp = atomic_long_inc_return(&ww_class->stamp); + ctx->acquired = 0; +#ifdef CONFIG_DEBUG_MUTEXES + ctx->ww_class = ww_class; + ctx->done_acquire = 0; + ctx->contending_lock = NULL; +#endif +#ifdef CONFIG_DEBUG_LOCK_ALLOC + debug_check_no_locks_freed((void *)ctx, sizeof(*ctx)); + lockdep_init_map(&ctx->dep_map, ww_class->acquire_name, + &ww_class->acquire_key, 0); + mutex_acquire(&ctx->dep_map, 0, 0, _RET_IP_); +#endif +#ifdef CONFIG_DEBUG_WW_MUTEX_SLOWPATH + ctx->deadlock_inject_interval = 1; + ctx->deadlock_inject_countdown = ctx->stamp & 0xf; +#endif +} + +/** + * ww_acquire_done - marks the end of the acquire phase + * @ctx: the acquire context + * + * Marks the end of the acquire phase, any further w/w mutex lock calls using + * this context are forbidden. + * + * Calling this function is optional, it is just useful to document w/w mutex + * code and clearly designated the acquire phase from actually using the locked + * data structures. + */ +static inline void ww_acquire_done(struct ww_acquire_ctx *ctx) +{ +#ifdef CONFIG_DEBUG_MUTEXES + lockdep_assert_held(ctx); + + DEBUG_LOCKS_WARN_ON(ctx->done_acquire); + ctx->done_acquire = 1; +#endif +} + +/** + * ww_acquire_fini - releases a w/w acquire context + * @ctx: the acquire context to free + * + * Releases a w/w acquire context. This must be called _after_ all acquired w/w + * mutexes have been released with ww_mutex_unlock. + */ +static inline void ww_acquire_fini(struct ww_acquire_ctx *ctx) +{ +#ifdef CONFIG_DEBUG_MUTEXES + mutex_release(&ctx->dep_map, 0, _THIS_IP_); + + DEBUG_LOCKS_WARN_ON(ctx->acquired); + if (!config_enabled(CONFIG_PROVE_LOCKING)) + /* + * lockdep will normally handle this, + * but fail without anyway + */ + ctx->done_acquire = 1; + + if (!config_enabled(CONFIG_DEBUG_LOCK_ALLOC)) + /* ensure ww_acquire_fini will still fail if called twice */ + ctx->acquired = ~0U; +#endif +} + +extern int __must_check __ww_mutex_lock(struct ww_mutex *lock, + struct ww_acquire_ctx *ctx); +extern int __must_check __ww_mutex_lock_interruptible(struct ww_mutex *lock, + struct ww_acquire_ctx *ctx); + +/** + * ww_mutex_lock - acquire the w/w mutex + * @lock: the mutex to be acquired + * @ctx: w/w acquire context, or NULL to acquire only a single lock. + * + * Lock the w/w mutex exclusively for this task. + * + * Deadlocks within a given w/w class of locks are detected and handled with the + * wait/wound algorithm. If the lock isn't immediately avaiable this function + * will either sleep until it is (wait case). Or it selects the current context + * for backing off by returning -EDEADLK (wound case). Trying to acquire the + * same lock with the same context twice is also detected and signalled by + * returning -EALREADY. Returns 0 if the mutex was successfully acquired. + * + * In the wound case the caller must release all currently held w/w mutexes for + * the given context and then wait for this contending lock to be available by + * calling ww_mutex_lock_slow. Alternatively callers can opt to not acquire this + * lock and proceed with trying to acquire further w/w mutexes (e.g. when + * scanning through lru lists trying to free resources). + * + * The mutex must later on be released by the same task that + * acquired it. The task may not exit without first unlocking the mutex. Also, + * kernel memory where the mutex resides must not be freed with the mutex still + * locked. The mutex must first be initialized (or statically defined) before it + * can be locked. memset()-ing the mutex to 0 is not allowed. The mutex must be + * of the same w/w lock class as was used to initialize the acquire context. + * + * A mutex acquired with this function must be released with ww_mutex_unlock. + */ +static inline int ww_mutex_lock(struct ww_mutex *lock, struct ww_acquire_ctx *ctx) +{ + if (ctx) + return __ww_mutex_lock(lock, ctx); + + mutex_lock(&lock->base); + return 0; +} + +/** + * ww_mutex_lock_interruptible - acquire the w/w mutex, interruptible + * @lock: the mutex to be acquired + * @ctx: w/w acquire context + * + * Lock the w/w mutex exclusively for this task. + * + * Deadlocks within a given w/w class of locks are detected and handled with the + * wait/wound algorithm. If the lock isn't immediately avaiable this function + * will either sleep until it is (wait case). Or it selects the current context + * for backing off by returning -EDEADLK (wound case). Trying to acquire the + * same lock with the same context twice is also detected and signalled by + * returning -EALREADY. Returns 0 if the mutex was successfully acquired. If a + * signal arrives while waiting for the lock then this function returns -EINTR. + * + * In the wound case the caller must release all currently held w/w mutexes for + * the given context and then wait for this contending lock to be available by + * calling ww_mutex_lock_slow_interruptible. Alternatively callers can opt to + * not acquire this lock and proceed with trying to acquire further w/w mutexes + * (e.g. when scanning through lru lists trying to free resources). + * + * The mutex must later on be released by the same task that + * acquired it. The task may not exit without first unlocking the mutex. Also, + * kernel memory where the mutex resides must not be freed with the mutex still + * locked. The mutex must first be initialized (or statically defined) before it + * can be locked. memset()-ing the mutex to 0 is not allowed. The mutex must be + * of the same w/w lock class as was used to initialize the acquire context. + * + * A mutex acquired with this function must be released with ww_mutex_unlock. + */ +static inline int __must_check ww_mutex_lock_interruptible(struct ww_mutex *lock, + struct ww_acquire_ctx *ctx) +{ + if (ctx) + return __ww_mutex_lock_interruptible(lock, ctx); + else + return mutex_lock_interruptible(&lock->base); +} + +/** + * ww_mutex_lock_slow - slowpath acquiring of the w/w mutex + * @lock: the mutex to be acquired + * @ctx: w/w acquire context + * + * Acquires a w/w mutex with the given context after a wound case. This function + * will sleep until the lock becomes available. + * + * The caller must have released all w/w mutexes already acquired with the + * context and then call this function on the contended lock. + * + * Afterwards the caller may continue to (re)acquire the other w/w mutexes it + * needs with ww_mutex_lock. Note that the -EALREADY return code from + * ww_mutex_lock can be used to avoid locking this contended mutex twice. + * + * It is forbidden to call this function with any other w/w mutexes associated + * with the context held. It is forbidden to call this on anything else than the + * contending mutex. + * + * Note that the slowpath lock acquiring can also be done by calling + * ww_mutex_lock directly. This function here is simply to help w/w mutex + * locking code readability by clearly denoting the slowpath. + */ +static inline void +ww_mutex_lock_slow(struct ww_mutex *lock, struct ww_acquire_ctx *ctx) +{ + int ret; +#ifdef CONFIG_DEBUG_MUTEXES + DEBUG_LOCKS_WARN_ON(!ctx->contending_lock); +#endif + ret = ww_mutex_lock(lock, ctx); + (void)ret; +} + +/** + * ww_mutex_lock_slow_interruptible - slowpath acquiring of the w/w mutex, interruptible + * @lock: the mutex to be acquired + * @ctx: w/w acquire context + * + * Acquires a w/w mutex with the given context after a wound case. This function + * will sleep until the lock becomes available and returns 0 when the lock has + * been acquired. If a signal arrives while waiting for the lock then this + * function returns -EINTR. + * + * The caller must have released all w/w mutexes already acquired with the + * context and then call this function on the contended lock. + * + * Afterwards the caller may continue to (re)acquire the other w/w mutexes it + * needs with ww_mutex_lock. Note that the -EALREADY return code from + * ww_mutex_lock can be used to avoid locking this contended mutex twice. + * + * It is forbidden to call this function with any other w/w mutexes associated + * with the given context held. It is forbidden to call this on anything else + * than the contending mutex. + * + * Note that the slowpath lock acquiring can also be done by calling + * ww_mutex_lock_interruptible directly. This function here is simply to help + * w/w mutex locking code readability by clearly denoting the slowpath. + */ +static inline int __must_check +ww_mutex_lock_slow_interruptible(struct ww_mutex *lock, + struct ww_acquire_ctx *ctx) +{ +#ifdef CONFIG_DEBUG_MUTEXES + DEBUG_LOCKS_WARN_ON(!ctx->contending_lock); +#endif + return ww_mutex_lock_interruptible(lock, ctx); +} + +extern void ww_mutex_unlock(struct ww_mutex *lock); + +/** + * ww_mutex_trylock - tries to acquire the w/w mutex without acquire context + * @lock: mutex to lock + * + * Trylocks a mutex without acquire context, so no deadlock detection is + * possible. Returns 1 if the mutex has been acquired successfully, 0 otherwise. + */ +static inline int __must_check ww_mutex_trylock(struct ww_mutex *lock) +{ + return mutex_trylock(&lock->base); +} + +/*** + * ww_mutex_destroy - mark a w/w mutex unusable + * @lock: the mutex to be destroyed + * + * This function marks the mutex uninitialized, and any subsequent + * use of the mutex is forbidden. The mutex must not be locked when + * this function is called. + */ +static inline void ww_mutex_destroy(struct ww_mutex *lock) +{ + mutex_destroy(&lock->base); +} + +/** + * ww_mutex_is_locked - is the w/w mutex locked + * @lock: the mutex to be queried + * + * Returns 1 if the mutex is locked, 0 if unlocked. + */ +static inline bool ww_mutex_is_locked(struct ww_mutex *lock) +{ + return mutex_is_locked(&lock->base); +} + +#endif diff --git a/kernel/mutex.c b/kernel/mutex.c index e581ada5faf4..ff05f4bd86eb 100644 --- a/kernel/mutex.c +++ b/kernel/mutex.c @@ -18,6 +18,7 @@ * Also see Documentation/mutex-design.txt. */ #include +#include #include #include #include diff --git a/lib/locking-selftest.c b/lib/locking-selftest.c index aad024dde3c4..6dc09d8f4c24 100644 --- a/lib/locking-selftest.c +++ b/lib/locking-selftest.c @@ -12,6 +12,7 @@ */ #include #include +#include #include #include #include From ff5599816711d2e67da2d7561fd36ac48debd433 Mon Sep 17 00:00:00 2001 From: Xiong Zhou Date: Tue, 9 Jul 2013 11:06:27 +0800 Subject: [PATCH 0850/1048] x86/platform/ce4100: Add header file for reboot type Add header file for reboot type to fix this build failure: error: 'reboot_type' undeclared (first use in this function) error: 'BOOT_KBD' undeclared (first use in this function) Signed-off-by: Xiong Zhou Cc: rui.zhang@intel.com Cc: alan@linux.intel.com Cc: ffainelli@freebox.fr Cc: mbizon@freebox.fr Cc: matthew.garrett@nebula.com Link: http://lkml.kernel.org/r/alpine.DEB.2.02.1307091053280.28371@M2420 Signed-off-by: Ingo Molnar --- arch/x86/platform/ce4100/ce4100.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/x86/platform/ce4100/ce4100.c b/arch/x86/platform/ce4100/ce4100.c index f8ab4945892e..9962015a3d55 100644 --- a/arch/x86/platform/ce4100/ce4100.c +++ b/arch/x86/platform/ce4100/ce4100.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include From a272dcca1802a7e265a56e60b0d0a6715b0a8ac2 Mon Sep 17 00:00:00 2001 From: Stephen Boyd Date: Thu, 11 Jul 2013 07:00:59 -0700 Subject: [PATCH 0851/1048] tick: broadcast: Check broadcast mode on CPU hotplug On ARM systems the dummy clockevent is registered with the cpu hotplug notifier chain before any other per-cpu clockevent. This has the side-effect of causing the dummy clockevent to be registered first in every hotplug sequence. Because the dummy is first, we'll try to turn the broadcast source on but the code in tick_device_uses_broadcast() assumes the broadcast source is in periodic mode and calls tick_broadcast_start_periodic() unconditionally. On boot this isn't a problem because we typically haven't switched into oneshot mode yet (if at all). During hotplug, if the broadcast source isn't in periodic mode we'll replace the broadcast oneshot handler with the broadcast periodic handler and start emulating oneshot mode when we shouldn't. Due to the way the broadcast oneshot handler programs the next_event it's possible for it to contain KTIME_MAX and cause us to hang the system when the periodic handler tries to program the next tick. Fix this by using the appropriate function to start the broadcast source. Reported-by: Stephen Warren Tested-by: Stephen Warren Signed-off-by: Stephen Boyd Cc: Mark Rutland Cc: Marc Zyngier Cc: ARM kernel mailing list Cc: John Stultz Cc: Joseph Lo Link: http://lkml.kernel.org/r/20130711140059.GA27430@codeaurora.org Signed-off-by: Thomas Gleixner --- kernel/time/tick-broadcast.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/kernel/time/tick-broadcast.c b/kernel/time/tick-broadcast.c index 6d3f91631de6..218bcb565fed 100644 --- a/kernel/time/tick-broadcast.c +++ b/kernel/time/tick-broadcast.c @@ -157,7 +157,10 @@ int tick_device_uses_broadcast(struct clock_event_device *dev, int cpu) dev->event_handler = tick_handle_periodic; tick_device_setup_broadcast_func(dev); cpumask_set_cpu(cpu, tick_broadcast_mask); - tick_broadcast_start_periodic(bc); + if (tick_broadcast_device.mode == TICKDEV_MODE_PERIODIC) + tick_broadcast_start_periodic(bc); + else + tick_broadcast_setup_oneshot(bc); ret = 1; } else { /* From baf64b85445546a38b44052d71782dfe7531e350 Mon Sep 17 00:00:00 2001 From: Dave Hansen Date: Mon, 8 Jul 2013 14:44:04 -0700 Subject: [PATCH 0852/1048] perf/x86: Fix incorrect use of do_div() in NMI warning I completely botched understanding the calling conventions of do_div(). I assumed that do_div() returned the result instead of realizing that it modifies its argument and returns a remainder. The side-effect from this would be bogus numbers for the "msecs" value in the warning messages: INFO: NMI handler (perf_event_nmi_handler) took too long to run: 0.114 msecs Note, there was a second fix posted by Stephane Eranian for a separate patch which I also botched: http://lkml.kernel.org/r/20130704223010.GA30625@quad Signed-off-by: Dave Hansen Cc: Dave Hansen Link: http://lkml.kernel.org/r/20130708214404.B0B6EA66@viggo.jf.intel.com Signed-off-by: Ingo Molnar --- arch/x86/kernel/nmi.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/arch/x86/kernel/nmi.c b/arch/x86/kernel/nmi.c index 0920212e6159..ba77ebc2c353 100644 --- a/arch/x86/kernel/nmi.c +++ b/arch/x86/kernel/nmi.c @@ -111,7 +111,7 @@ static int __kprobes nmi_handle(unsigned int type, struct pt_regs *regs, bool b2 */ list_for_each_entry_rcu(a, &desc->head, list) { u64 before, delta, whole_msecs; - int decimal_msecs, thishandled; + int remainder_ns, decimal_msecs, thishandled; before = local_clock(); thishandled = a->handler(type, regs); @@ -123,8 +123,9 @@ static int __kprobes nmi_handle(unsigned int type, struct pt_regs *regs, bool b2 continue; nmi_longest_ns = delta; - whole_msecs = do_div(delta, (1000 * 1000)); - decimal_msecs = do_div(delta, 1000) % 1000; + whole_msecs = delta; + remainder_ns = do_div(whole_msecs, (1000 * 1000)); + decimal_msecs = remainder_ns / 1000; printk_ratelimited(KERN_INFO "INFO: NMI handler (%ps) took too long to run: " "%lld.%03d msecs\n", a->handler, whole_msecs, From 1157d73d07b6143cbe49145ef917d52abbe531f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vincent=20Stehl=C3=A9?= Date: Wed, 3 Jul 2013 10:12:58 +0200 Subject: [PATCH 0853/1048] arm: multi_v7_defconfig: add i.MX options and NFS root MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add i.MX serial console support. This gives us the boot messages on UART on e.g. the i.MX6Q sabre sd platform. - Add the necessary config options, to allow booting with NFS root on an i.MX6 sabre sd. - Add Freescale LPUART serial console support. This gives us the boot messages on UART on e.g. the Vybrid VF610 Tower board. Signed-off-by: Vincent Stehlé Cc: Russell King [olof: squashed three commits down to one] Signed-off-by: Olof Johansson --- arch/arm/configs/multi_v7_defconfig | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/arch/arm/configs/multi_v7_defconfig b/arch/arm/configs/multi_v7_defconfig index 6d8d3c456b5f..80aacc6d3b48 100644 --- a/arch/arm/configs/multi_v7_defconfig +++ b/arch/arm/configs/multi_v7_defconfig @@ -47,6 +47,8 @@ CONFIG_ARM_APPENDED_DTB=y CONFIG_NET=y CONFIG_UNIX=y CONFIG_INET=y +CONFIG_IP_PNP=y +CONFIG_IP_PNP_DHCP=y CONFIG_DEVTMPFS=y CONFIG_DEVTMPFS_MOUNT=y CONFIG_BLK_DEV_SD=y @@ -75,6 +77,10 @@ CONFIG_SERIAL_OMAP=y CONFIG_SERIAL_OMAP_CONSOLE=y CONFIG_SERIAL_XILINX_PS_UART=y CONFIG_SERIAL_XILINX_PS_UART_CONSOLE=y +CONFIG_SERIAL_IMX=y +CONFIG_SERIAL_IMX_CONSOLE=y +CONFIG_SERIAL_FSL_LPUART=y +CONFIG_SERIAL_FSL_LPUART_CONSOLE=y CONFIG_I2C_DESIGNWARE_PLATFORM=y CONFIG_I2C_SIRF=y CONFIG_I2C_TEGRA=y @@ -147,6 +153,10 @@ CONFIG_PWM=y CONFIG_PWM_VT8500=y CONFIG_EXT4_FS=y CONFIG_TMPFS=y +CONFIG_NFS_FS=y +CONFIG_NFS_V3_ACL=y +CONFIG_NFS_V4=y +CONFIG_ROOT_NFS=y CONFIG_PRINTK_TIME=y CONFIG_DEBUG_FS=y CONFIG_DEBUG_KERNEL=y From 35f7a14fc1180164d6358a5885031fc187ef1bfa Mon Sep 17 00:00:00 2001 From: "J. Bruce Fields" Date: Mon, 8 Jul 2013 19:51:44 -0400 Subject: [PATCH 0854/1048] nfsd4: fix minorversion support interface You can turn on or off support for minorversions using e.g. echo "-4.2" >/proc/fs/nfsd/versions However, the current implementation is a little wonky. For example, the above will turn off 4.2 support, but it will also turn *on* 4.1 support. This didn't matter as long as we only had 2 minorversions, which was true till very recently. And do a little cleanup here. Signed-off-by: J. Bruce Fields --- fs/nfsd/nfs4proc.c | 2 +- fs/nfsd/nfsd.h | 1 - fs/nfsd/nfssvc.c | 13 +++++++------ 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c index a7cee864e7b2..0d4c410e4589 100644 --- a/fs/nfsd/nfs4proc.c +++ b/fs/nfsd/nfs4proc.c @@ -1293,7 +1293,7 @@ nfsd4_proc_compound(struct svc_rqst *rqstp, * According to RFC3010, this takes precedence over all other errors. */ status = nfserr_minor_vers_mismatch; - if (args->minorversion > nfsd_supported_minorversion) + if (nfsd_minorversion(args->minorversion, NFSD_TEST) <= 0) goto out; status = nfs41_check_op_ordering(args); diff --git a/fs/nfsd/nfsd.h b/fs/nfsd/nfsd.h index 2bbd94e51efc..30f34ab02137 100644 --- a/fs/nfsd/nfsd.h +++ b/fs/nfsd/nfsd.h @@ -53,7 +53,6 @@ struct readdir_cd { extern struct svc_program nfsd_program; extern struct svc_version nfsd_version2, nfsd_version3, nfsd_version4; -extern u32 nfsd_supported_minorversion; extern struct mutex nfsd_mutex; extern spinlock_t nfsd_drc_lock; extern unsigned long nfsd_drc_max_mem; diff --git a/fs/nfsd/nfssvc.c b/fs/nfsd/nfssvc.c index 6b9f48ca4c25..760c85a6f534 100644 --- a/fs/nfsd/nfssvc.c +++ b/fs/nfsd/nfssvc.c @@ -116,7 +116,10 @@ struct svc_program nfsd_program = { }; -u32 nfsd_supported_minorversion = 1; +static bool nfsd_supported_minorversions[NFSD_SUPPORTED_MINOR_VERSION + 1] = { + [0] = 1, + [1] = 1, +}; int nfsd_vers(int vers, enum vers_op change) { @@ -151,15 +154,13 @@ int nfsd_minorversion(u32 minorversion, enum vers_op change) return -1; switch(change) { case NFSD_SET: - nfsd_supported_minorversion = minorversion; + nfsd_supported_minorversions[minorversion] = true; break; case NFSD_CLEAR: - if (minorversion == 0) - return -1; - nfsd_supported_minorversion = minorversion - 1; + nfsd_supported_minorversions[minorversion] = false; break; case NFSD_TEST: - return minorversion <= nfsd_supported_minorversion; + return nfsd_supported_minorversions[minorversion]; case NFSD_AVAIL: return minorversion <= NFSD_SUPPORTED_MINOR_VERSION; } From 92338dc2fb33c8526256a458a520af73d9ab2d14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CCosmin?= Date: Fri, 12 Jul 2013 09:33:33 +0300 Subject: [PATCH 0855/1048] net: strict_strtoul is obsolete, use kstrtoul instead patch found using checkpatch.pl Signed-off-by: Cosmin Stanescu Signed-off-by: David S. Miller --- net/dns_resolver/dns_key.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/dns_resolver/dns_key.c b/net/dns_resolver/dns_key.c index 0a69d0757795..f347a2ca7d7e 100644 --- a/net/dns_resolver/dns_key.c +++ b/net/dns_resolver/dns_key.c @@ -118,7 +118,7 @@ dns_resolver_instantiate(struct key *key, struct key_preparsed_payload *prep) if (opt_vlen <= 0) goto bad_option_value; - ret = strict_strtoul(eq, 10, &derrno); + ret = kstrtoul(eq, 10, &derrno); if (ret < 0) goto bad_option_value; From 40dadff26539d1695d2a37b44f66c53158439ae9 Mon Sep 17 00:00:00 2001 From: Sunghan Suh Date: Fri, 12 Jul 2013 16:17:23 +0900 Subject: [PATCH 0856/1048] net: access page->private by using page_private Signed-off-by: Sunghan Suh Signed-off-by: David S. Miller --- net/core/skbuff.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/net/core/skbuff.c b/net/core/skbuff.c index 724bb7cb173f..20e02d2605ec 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -824,7 +824,7 @@ int skb_copy_ubufs(struct sk_buff *skb, gfp_t gfp_mask) page = alloc_page(gfp_mask); if (!page) { while (head) { - struct page *next = (struct page *)head->private; + struct page *next = (struct page *)page_private(head); put_page(head); head = next; } @@ -834,7 +834,7 @@ int skb_copy_ubufs(struct sk_buff *skb, gfp_t gfp_mask) memcpy(page_address(page), vaddr + f->page_offset, skb_frag_size(f)); kunmap_atomic(vaddr); - page->private = (unsigned long)head; + set_page_private(page, (unsigned long)head); head = page; } @@ -848,7 +848,7 @@ int skb_copy_ubufs(struct sk_buff *skb, gfp_t gfp_mask) for (i = num_frags - 1; i >= 0; i--) { __skb_fill_page_desc(skb, i, head, 0, skb_shinfo(skb)->frags[i].size); - head = (struct page *)head->private; + head = (struct page *)page_private(head); } skb_shinfo(skb)->tx_flags &= ~SKBTX_DEV_ZEROCOPY; From 3ff25e3c4531aff5b1a96e2ea6e1a2d355263019 Mon Sep 17 00:00:00 2001 From: hayeswang Date: Fri, 12 Jul 2013 16:26:15 +0800 Subject: [PATCH 0857/1048] usb/net/r8152: fix integer overflow in expression config: make ARCH=avr32 allyesconfig drivers/net/usb/r8152.c: In function 'rtl8152_start_xmit': drivers/net/usb/r8152.c:956: warning: integer overflow in expression 955 memset(tx_desc, 0, sizeof(*tx_desc)); > 956 tx_desc->opts1 = cpu_to_le32((len & TX_LEN_MASK) | TX_FS | TX_LS); 957 tp->tx_skb = skb; Signed-off-by: Hayes Wang Spotted-by: kbuild test robot Signed-off-by: David S. Miller --- drivers/net/usb/r8152.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c index d02bac82fc57..ee13f9eb740c 100644 --- a/drivers/net/usb/r8152.c +++ b/drivers/net/usb/r8152.c @@ -934,7 +934,8 @@ static netdev_tx_t rtl8152_start_xmit(struct sk_buff *skb, struct r8152 *tp = netdev_priv(netdev); struct net_device_stats *stats = rtl8152_get_stats(netdev); struct tx_desc *tx_desc; - int len, res; + unsigned int len; + int res; netif_stop_queue(netdev); len = skb->len; From e76385240ee5c812267319c9084e5a0d62bfbf90 Mon Sep 17 00:00:00 2001 From: hayeswang Date: Fri, 12 Jul 2013 16:26:16 +0800 Subject: [PATCH 0858/1048] usb/net/r815x: fix cast to restricted __le32 >> drivers/net/usb/r815x.c:38:16: sparse: cast to restricted __le32 >> drivers/net/usb/r815x.c:67:15: sparse: cast to restricted __le32 >> drivers/net/usb/r815x.c:69:13: sparse: incorrect type in assignment (different base types) drivers/net/usb/r815x.c:69:13: expected unsigned int [unsigned] [addressable] [assigned] [usertype] tmp drivers/net/usb/r815x.c:69:13: got restricted __le32 [usertype] Signed-off-by: Hayes Wang Spotted-by: kbuild test robot Signed-off-by: David S. Miller --- drivers/net/usb/r815x.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/drivers/net/usb/r815x.c b/drivers/net/usb/r815x.c index 65167377ff09..852392269718 100644 --- a/drivers/net/usb/r815x.c +++ b/drivers/net/usb/r815x.c @@ -26,16 +26,18 @@ static int pla_read_word(struct usb_device *udev, u16 index) { int data, ret; u8 shift = index & 2; + __le32 ocp_data; index &= ~3; ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), RTL815x_REQ_GET_REGS, RTL815x_REQT_READ, - index, MCU_TYPE_PLA, &data, sizeof(data), 500); + index, MCU_TYPE_PLA, &ocp_data, sizeof(ocp_data), + 500); if (ret < 0) return ret; - data = __le32_to_cpu(data); + data = __le32_to_cpu(ocp_data); data >>= (shift * 8); data &= 0xffff; @@ -44,7 +46,8 @@ static int pla_read_word(struct usb_device *udev, u16 index) static int pla_write_word(struct usb_device *udev, u16 index, u32 data) { - u32 tmp, mask = 0xffff; + __le32 ocp_data; + u32 mask = 0xffff; u16 byen = BYTE_EN_WORD; u8 shift = index & 2; int ret; @@ -60,18 +63,18 @@ static int pla_write_word(struct usb_device *udev, u16 index, u32 data) ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), RTL815x_REQ_GET_REGS, RTL815x_REQT_READ, - index, MCU_TYPE_PLA, &tmp, sizeof(tmp), 500); + index, MCU_TYPE_PLA, &ocp_data, sizeof(ocp_data), + 500); if (ret < 0) return ret; - tmp = __le32_to_cpu(tmp) & ~mask; - tmp |= data; - tmp = __cpu_to_le32(tmp); + data |= __le32_to_cpu(ocp_data) & ~mask; + ocp_data = __cpu_to_le32(data); ret = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), RTL815x_REQ_SET_REGS, RTL815x_REQT_WRITE, - index, MCU_TYPE_PLA | byen, &tmp, - sizeof(tmp), 500); + index, MCU_TYPE_PLA | byen, &ocp_data, + sizeof(ocp_data), 500); return ret; } From 24ab6bec80861d0c55263047e8bf97e460a32e7b Mon Sep 17 00:00:00 2001 From: Yuchung Cheng Date: Fri, 12 Jul 2013 11:33:04 -0700 Subject: [PATCH 0859/1048] tcp: account all retransmit failures Change snmp RETRANSFAILS stat to include timeout retransmit failures in addition to other loss recoveries. Signed-off-by: Yuchung Cheng Acked-by: Neal Cardwell Acked-by: Eric Dumazet Signed-off-by: David S. Miller --- net/ipv4/tcp_output.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index 3d609490f118..92fde8d1aa82 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c @@ -2407,6 +2407,8 @@ int tcp_retransmit_skb(struct sock *sk, struct sk_buff *skb) * see tcp_input.c tcp_sacktag_write_queue(). */ TCP_SKB_CB(skb)->ack_seq = tp->snd_nxt; + } else { + NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_TCPRETRANSFAIL); } return err; } @@ -2528,10 +2530,9 @@ begin_fwd: if (sacked & (TCPCB_SACKED_ACKED|TCPCB_SACKED_RETRANS)) continue; - if (tcp_retransmit_skb(sk, skb)) { - NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_TCPRETRANSFAIL); + if (tcp_retransmit_skb(sk, skb)) return; - } + NET_INC_STATS_BH(sock_net(sk), mib_idx); if (tcp_in_cwnd_reduction(sk)) From 352900b583b2852152a1e05ea0e8b579292e731e Mon Sep 17 00:00:00 2001 From: Neil Horman Date: Fri, 12 Jul 2013 10:58:48 -0400 Subject: [PATCH 0860/1048] atl1e: fix dma mapping warnings Recently had this backtrace reported: WARNING: at lib/dma-debug.c:937 check_unmap+0x47d/0x930() Hardware name: System Product Name ATL1E 0000:02:00.0: DMA-API: device driver failed to check map error[device address=0x00000000cbfd1000] [size=90 bytes] [mapped as single] Modules linked in: xt_conntrack nf_conntrack ebtable_filter ebtables ip6table_filter ip6_tables snd_hda_codec_hdmi snd_hda_codec_realtek iTCO_wdt iTCO_vendor_support snd_hda_intel acpi_cpufreq mperf coretemp btrfs zlib_deflate snd_hda_codec snd_hwdep microcode raid6_pq libcrc32c snd_seq usblp serio_raw xor snd_seq_device joydev snd_pcm snd_page_alloc snd_timer snd lpc_ich i2c_i801 soundcore mfd_core atl1e asus_atk0110 ata_generic pata_acpi radeon i2c_algo_bit drm_kms_helper ttm drm i2c_core pata_marvell uinput Pid: 314, comm: systemd-journal Not tainted 3.9.0-0.rc6.git2.3.fc19.x86_64 #1 Call Trace: [] warn_slowpath_common+0x66/0x80 [] warn_slowpath_fmt+0x4c/0x50 [] check_unmap+0x47d/0x930 [] ? sched_clock_cpu+0xa8/0x100 [] debug_dma_unmap_page+0x5f/0x70 [] ? unmap_single+0x20/0x30 [] atl1e_intr+0x3a1/0x5b0 [atl1e] [] ? trace_hardirqs_off+0xd/0x10 [] handle_irq_event_percpu+0x56/0x390 [] handle_irq_event+0x3d/0x60 [] handle_fasteoi_irq+0x5a/0x100 [] handle_irq+0xbf/0x150 [] ? file_sb_list_del+0x3f/0x50 [] ? irq_enter+0x50/0xa0 [] do_IRQ+0x4d/0xc0 [] ? file_sb_list_del+0x3f/0x50 [] common_interrupt+0x72/0x72 [] ? lock_release+0xc2/0x310 [] lg_local_unlock_cpu+0x24/0x50 [] file_sb_list_del+0x3f/0x50 [] fput+0x2d/0xc0 [] filp_close+0x61/0x90 [] __close_fd+0x8d/0x150 [] sys_close+0x20/0x50 [] system_call_fastpath+0x16/0x1b The usual straighforward failure to check for dma_mapping_error after a map operation is completed. This patch should fix it, the reporter wandered off after filing this bz: https://bugzilla.redhat.com/show_bug.cgi?id=954170 and I don't have hardware to test, but the fix is pretty straightforward, so I figured I'd post it for review. Signed-off-by: Neil Horman CC: Jay Cliburn CC: Chris Snook CC: "David S. Miller" Signed-off-by: David S. Miller --- .../net/ethernet/atheros/atl1e/atl1e_main.c | 28 +++++++++++++++++-- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/atheros/atl1e/atl1e_main.c b/drivers/net/ethernet/atheros/atl1e/atl1e_main.c index 895f5377ad1b..6d1a62a84c9d 100644 --- a/drivers/net/ethernet/atheros/atl1e/atl1e_main.c +++ b/drivers/net/ethernet/atheros/atl1e/atl1e_main.c @@ -1665,8 +1665,8 @@ check_sum: return 0; } -static void atl1e_tx_map(struct atl1e_adapter *adapter, - struct sk_buff *skb, struct atl1e_tpd_desc *tpd) +static int atl1e_tx_map(struct atl1e_adapter *adapter, + struct sk_buff *skb, struct atl1e_tpd_desc *tpd) { struct atl1e_tpd_desc *use_tpd = NULL; struct atl1e_tx_buffer *tx_buffer = NULL; @@ -1677,6 +1677,7 @@ static void atl1e_tx_map(struct atl1e_adapter *adapter, u16 nr_frags; u16 f; int segment; + int ring_start = adapter->tx_ring.next_to_use; nr_frags = skb_shinfo(skb)->nr_frags; segment = (tpd->word3 >> TPD_SEGMENT_EN_SHIFT) & TPD_SEGMENT_EN_MASK; @@ -1689,6 +1690,9 @@ static void atl1e_tx_map(struct atl1e_adapter *adapter, tx_buffer->length = map_len; tx_buffer->dma = pci_map_single(adapter->pdev, skb->data, hdr_len, PCI_DMA_TODEVICE); + if (dma_mapping_error(&adapter->pdev->dev, tx_buffer->dma)) + return -ENOSPC; + ATL1E_SET_PCIMAP_TYPE(tx_buffer, ATL1E_TX_PCIMAP_SINGLE); mapped_len += map_len; use_tpd->buffer_addr = cpu_to_le64(tx_buffer->dma); @@ -1715,6 +1719,13 @@ static void atl1e_tx_map(struct atl1e_adapter *adapter, tx_buffer->dma = pci_map_single(adapter->pdev, skb->data + mapped_len, map_len, PCI_DMA_TODEVICE); + + if (dma_mapping_error(&adapter->pdev->dev, tx_buffer->dma)) { + /* Reset the tx rings next pointer */ + adapter->tx_ring.next_to_use = ring_start; + return -ENOSPC; + } + ATL1E_SET_PCIMAP_TYPE(tx_buffer, ATL1E_TX_PCIMAP_SINGLE); mapped_len += map_len; use_tpd->buffer_addr = cpu_to_le64(tx_buffer->dma); @@ -1750,6 +1761,13 @@ static void atl1e_tx_map(struct atl1e_adapter *adapter, (i * MAX_TX_BUF_LEN), tx_buffer->length, DMA_TO_DEVICE); + + if (dma_mapping_error(&adapter->pdev->dev, tx_buffer->dma)) { + /* Reset the ring next to use pointer */ + adapter->tx_ring.next_to_use = ring_start; + return -ENOSPC; + } + ATL1E_SET_PCIMAP_TYPE(tx_buffer, ATL1E_TX_PCIMAP_PAGE); use_tpd->buffer_addr = cpu_to_le64(tx_buffer->dma); use_tpd->word2 = (use_tpd->word2 & (~TPD_BUFLEN_MASK)) | @@ -1767,6 +1785,7 @@ static void atl1e_tx_map(struct atl1e_adapter *adapter, /* The last buffer info contain the skb address, so it will be free after unmap */ tx_buffer->skb = skb; + return 0; } static void atl1e_tx_queue(struct atl1e_adapter *adapter, u16 count, @@ -1834,10 +1853,13 @@ static netdev_tx_t atl1e_xmit_frame(struct sk_buff *skb, return NETDEV_TX_OK; } - atl1e_tx_map(adapter, skb, tpd); + if (atl1e_tx_map(adapter, skb, tpd)) + goto out; + atl1e_tx_queue(adapter, tpd_req, tpd); netdev->trans_start = jiffies; /* NETIF_F_LLTX driver :( */ +out: spin_unlock_irqrestore(&adapter->tx_lock, flags); return NETDEV_TX_OK; } From 9b4fe5fb0bdd8f31f24cbfe77e38ec8155c250c5 Mon Sep 17 00:00:00 2001 From: Neil Horman Date: Fri, 12 Jul 2013 13:35:33 -0400 Subject: [PATCH 0861/1048] via-rhine: fix dma mapping errors this bug: https://bugzilla.redhat.com/show_bug.cgi?id=951695 Reported a dma debug backtrace: WARNING: at lib/dma-debug.c:937 check_unmap+0x47d/0x930() Hardware name: To Be Filled By O.E.M. via-rhine 0000:00:12.0: DMA-API: device driver failed to check map error[device address=0x0000000075a837b2] [size=90 bytes] [mapped as single] Modules linked in: ip6_tables gspca_spca561 gspca_main videodev media snd_hda_codec_realtek snd_hda_intel i2c_viapro snd_hda_codec snd_hwdep snd_seq ppdev mperf via_rhine coretemp snd_pcm mii microcode snd_page_alloc snd_timer snd_mpu401 snd_mpu401_uart snd_rawmidi snd_seq_device snd soundcore parport_pc parport shpchp ata_generic pata_acpi radeon i2c_algo_bit drm_kms_helper ttm drm pata_via sata_via i2c_core uinput Pid: 295, comm: systemd-journal Not tainted 3.9.0-0.rc6.git2.1.fc20.x86_64 #1 Call Trace: [] warn_slowpath_common+0x70/0xa0 [] warn_slowpath_fmt+0x4c/0x50 [] check_unmap+0x47d/0x930 [] ? local_clock+0x5f/0x70 [] debug_dma_unmap_page+0x5f/0x70 [] ? rhine_ack_events.isra.14+0x3c/0x50 [via_rhine] [] rhine_napipoll+0x1d8/0xd80 [via_rhine] [] ? net_rx_action+0xa1/0x380 [] net_rx_action+0x172/0x380 [] __do_softirq+0xff/0x400 [] irq_exit+0xb5/0xc0 [] do_IRQ+0x56/0xc0 [] common_interrupt+0x72/0x72 [] ? __slab_alloc+0x4c2/0x526 [] ? mmap_region+0x2b0/0x5a0 [] ? __lock_is_held+0x57/0x80 [] ? mmap_region+0x2b0/0x5a0 [] kmem_cache_alloc+0x2df/0x360 [] mmap_region+0x2b0/0x5a0 [] do_mmap_pgoff+0x316/0x3d0 [] vm_mmap_pgoff+0x90/0xc0 [] sys_mmap_pgoff+0x4c/0x190 [] ? trace_hardirqs_on_thunk+0x3a/0x3f [] sys_mmap+0x22/0x30 [] system_call_fastpath+0x16/0x1b Usual problem with the usual fix, add the appropriate calls to dma_mapping_error where appropriate Untested, as I don't have hardware, but its pretty straightforward Signed-off-by: Neil Horman CC: David S. Miller CC: Roger Luethi Signed-off-by: David S. Miller --- drivers/net/ethernet/via/via-rhine.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/via/via-rhine.c b/drivers/net/ethernet/via/via-rhine.c index ca98acabf1b4..b75eb9e0e867 100644 --- a/drivers/net/ethernet/via/via-rhine.c +++ b/drivers/net/ethernet/via/via-rhine.c @@ -1171,7 +1171,11 @@ static void alloc_rbufs(struct net_device *dev) rp->rx_skbuff_dma[i] = pci_map_single(rp->pdev, skb->data, rp->rx_buf_sz, PCI_DMA_FROMDEVICE); - + if (dma_mapping_error(&rp->pdev->dev, rp->rx_skbuff_dma[i])) { + rp->rx_skbuff_dma[i] = 0; + dev_kfree_skb(skb); + break; + } rp->rx_ring[i].addr = cpu_to_le32(rp->rx_skbuff_dma[i]); rp->rx_ring[i].rx_status = cpu_to_le32(DescOwn); } @@ -1687,6 +1691,12 @@ static netdev_tx_t rhine_start_tx(struct sk_buff *skb, rp->tx_skbuff_dma[entry] = pci_map_single(rp->pdev, skb->data, skb->len, PCI_DMA_TODEVICE); + if (dma_mapping_error(&rp->pdev->dev, rp->tx_skbuff_dma[entry])) { + dev_kfree_skb(skb); + rp->tx_skbuff_dma[entry] = 0; + dev->stats.tx_dropped++; + return NETDEV_TX_OK; + } rp->tx_ring[entry].addr = cpu_to_le32(rp->tx_skbuff_dma[entry]); } @@ -1961,6 +1971,11 @@ static int rhine_rx(struct net_device *dev, int limit) pci_map_single(rp->pdev, skb->data, rp->rx_buf_sz, PCI_DMA_FROMDEVICE); + if (dma_mapping_error(&rp->pdev->dev, rp->rx_skbuff_dma[entry])) { + dev_kfree_skb(skb); + rp->rx_skbuff_dma[entry] = 0; + break; + } rp->rx_ring[entry].addr = cpu_to_le32(rp->rx_skbuff_dma[entry]); } rp->rx_ring[entry].rx_status = cpu_to_le32(DescOwn); From 307f2fb95e9b96b3577916e73d92e104f8f26494 Mon Sep 17 00:00:00 2001 From: Hannes Frederic Sowa Date: Fri, 12 Jul 2013 23:46:33 +0200 Subject: [PATCH 0862/1048] ipv6: only static routes qualify for equal cost multipathing Static routes in this case are non-expiring routes which did not get configured by autoconf or by icmpv6 redirects. To make sure we actually get an ecmp route while searching for the first one in this fib6_node's leafs, also make sure it matches the ecmp route assumptions. v2: a) Removed RTF_EXPIRE check in dst.from chain. The check of RTF_ADDRCONF already ensures that this route, even if added again without RTF_EXPIRES (in case of a RA announcement with infinite timeout), does not cause the rt6i_nsiblings logic to go wrong if a later RA updates the expiration time later. v3: a) Allow RTF_EXPIRES routes to enter the ecmp route set. We have to do so, because an pmtu event could update the RTF_EXPIRES flag and we would not count this route, if another route joins this set. We now filter only for RTF_GATEWAY|RTF_ADDRCONF|RTF_DYNAMIC, which are flags that don't get changed after rt6_info construction. Cc: Nicolas Dichtel Signed-off-by: Hannes Frederic Sowa Signed-off-by: David S. Miller --- net/ipv6/ip6_fib.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c index 192dd1a0e188..5fc9c7a68d8d 100644 --- a/net/ipv6/ip6_fib.c +++ b/net/ipv6/ip6_fib.c @@ -632,6 +632,12 @@ insert_above: return ln; } +static inline bool rt6_qualify_for_ecmp(struct rt6_info *rt) +{ + return (rt->rt6i_flags & (RTF_GATEWAY|RTF_ADDRCONF|RTF_DYNAMIC)) == + RTF_GATEWAY; +} + /* * Insert routing information in a node. */ @@ -646,6 +652,7 @@ static int fib6_add_rt2node(struct fib6_node *fn, struct rt6_info *rt, int add = (!info->nlh || (info->nlh->nlmsg_flags & NLM_F_CREATE)); int found = 0; + bool rt_can_ecmp = rt6_qualify_for_ecmp(rt); ins = &fn->leaf; @@ -691,9 +698,8 @@ static int fib6_add_rt2node(struct fib6_node *fn, struct rt6_info *rt, * To avoid long list, we only had siblings if the * route have a gateway. */ - if (rt->rt6i_flags & RTF_GATEWAY && - !(rt->rt6i_flags & RTF_EXPIRES) && - !(iter->rt6i_flags & RTF_EXPIRES)) + if (rt_can_ecmp && + rt6_qualify_for_ecmp(iter)) rt->rt6i_nsiblings++; } @@ -715,7 +721,8 @@ static int fib6_add_rt2node(struct fib6_node *fn, struct rt6_info *rt, /* Find the first route that have the same metric */ sibling = fn->leaf; while (sibling) { - if (sibling->rt6i_metric == rt->rt6i_metric) { + if (sibling->rt6i_metric == rt->rt6i_metric && + rt6_qualify_for_ecmp(sibling)) { list_add_tail(&rt->rt6i_siblings, &sibling->rt6i_siblings); break; From bdafe42aaf72859166f784f0fad3e6b4a815fa6d Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Sat, 13 Jul 2013 00:40:31 -0400 Subject: [PATCH 0863/1048] ext4: fix spelling errors and a comment in extent_status tree Replace "assertation" with "assertion" in lots and lots of debugging messages. Correct the comment stating when ext4_es_insert_extent() is used. It was no doubt tree at one point, but it is no longer true... Signed-off-by: "Theodore Ts'o" Cc: Zheng Liu --- fs/ext4/extents_status.c | 22 ++++++++++------------ fs/ext4/inode.c | 8 ++++---- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/fs/ext4/extents_status.c b/fs/ext4/extents_status.c index ee018d5f397e..4b8df7fbb10a 100644 --- a/fs/ext4/extents_status.c +++ b/fs/ext4/extents_status.c @@ -439,7 +439,7 @@ static void ext4_es_insert_extent_ext_check(struct inode *inode, */ if (!ext4_es_is_written(es) && !ext4_es_is_unwritten(es)) { if (in_range(es->es_lblk, ee_block, ee_len)) { - pr_warn("ES insert assertation failed for " + pr_warn("ES insert assertion failed for " "inode: %lu we can find an extent " "at block [%d/%d/%llu/%c], but we " "want to add an delayed/hole extent " @@ -458,7 +458,7 @@ static void ext4_es_insert_extent_ext_check(struct inode *inode, */ if (es->es_lblk < ee_block || ext4_es_pblock(es) != ee_start + es->es_lblk - ee_block) { - pr_warn("ES insert assertation failed for inode: %lu " + pr_warn("ES insert assertion failed for inode: %lu " "ex_status [%d/%d/%llu/%c] != " "es_status [%d/%d/%llu/%c]\n", inode->i_ino, ee_block, ee_len, ee_start, @@ -468,7 +468,7 @@ static void ext4_es_insert_extent_ext_check(struct inode *inode, } if (ee_status ^ es_status) { - pr_warn("ES insert assertation failed for inode: %lu " + pr_warn("ES insert assertion failed for inode: %lu " "ex_status [%d/%d/%llu/%c] != " "es_status [%d/%d/%llu/%c]\n", inode->i_ino, ee_block, ee_len, ee_start, @@ -481,7 +481,7 @@ static void ext4_es_insert_extent_ext_check(struct inode *inode, * that we don't want to add an written/unwritten extent. */ if (!ext4_es_is_delayed(es) && !ext4_es_is_hole(es)) { - pr_warn("ES insert assertation failed for inode: %lu " + pr_warn("ES insert assertion failed for inode: %lu " "can't find an extent at block %d but we want " "to add an written/unwritten extent " "[%d/%d/%llu/%llx]\n", inode->i_ino, @@ -519,7 +519,7 @@ static void ext4_es_insert_extent_ind_check(struct inode *inode, * We want to add a delayed/hole extent but this * block has been allocated. */ - pr_warn("ES insert assertation failed for inode: %lu " + pr_warn("ES insert assertion failed for inode: %lu " "We can find blocks but we want to add a " "delayed/hole extent [%d/%d/%llu/%llx]\n", inode->i_ino, es->es_lblk, es->es_len, @@ -527,13 +527,13 @@ static void ext4_es_insert_extent_ind_check(struct inode *inode, return; } else if (ext4_es_is_written(es)) { if (retval != es->es_len) { - pr_warn("ES insert assertation failed for " + pr_warn("ES insert assertion failed for " "inode: %lu retval %d != es_len %d\n", inode->i_ino, retval, es->es_len); return; } if (map.m_pblk != ext4_es_pblock(es)) { - pr_warn("ES insert assertation failed for " + pr_warn("ES insert assertion failed for " "inode: %lu m_pblk %llu != " "es_pblk %llu\n", inode->i_ino, map.m_pblk, @@ -549,7 +549,7 @@ static void ext4_es_insert_extent_ind_check(struct inode *inode, } } else if (retval == 0) { if (ext4_es_is_written(es)) { - pr_warn("ES insert assertation failed for inode: %lu " + pr_warn("ES insert assertion failed for inode: %lu " "We can't find the block but we want to add " "an written extent [%d/%d/%llu/%llx]\n", inode->i_ino, es->es_lblk, es->es_len, @@ -632,10 +632,8 @@ out: } /* - * ext4_es_insert_extent() adds a space to a extent status tree. - * - * ext4_es_insert_extent is called by ext4_da_write_begin and - * ext4_es_remove_extent. + * ext4_es_insert_extent() adds information to an inode's extent + * status tree. * * Return 0 on success, error code on failure. */ diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 19a1643cbdfa..98b9bff92a8a 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -465,7 +465,7 @@ static void ext4_map_blocks_es_recheck(handle_t *handle, if (es_map->m_lblk != map->m_lblk || es_map->m_flags != map->m_flags || es_map->m_pblk != map->m_pblk) { - printk("ES cache assertation failed for inode: %lu " + printk("ES cache assertion failed for inode: %lu " "es_cached ex [%d/%d/%llu/%x] != " "found ex [%d/%d/%llu/%x] retval %d flags %x\n", inode->i_ino, es_map->m_lblk, es_map->m_len, @@ -558,7 +558,7 @@ int ext4_map_blocks(handle_t *handle, struct inode *inode, #ifdef ES_AGGRESSIVE_TEST if (retval != map->m_len) { - printk("ES len assertation failed for inode: %lu " + printk("ES len assertion failed for inode: %lu " "retval %d != map->m_len %d " "in %s (lookup)\n", inode->i_ino, retval, map->m_len, __func__); @@ -659,7 +659,7 @@ found: #ifdef ES_AGGRESSIVE_TEST if (retval != map->m_len) { - printk("ES len assertation failed for inode: %lu " + printk("ES len assertion failed for inode: %lu " "retval %d != map->m_len %d " "in %s (allocation)\n", inode->i_ino, retval, map->m_len, __func__); @@ -1642,7 +1642,7 @@ add_delayed: #ifdef ES_AGGRESSIVE_TEST if (retval != map->m_len) { - printk("ES len assertation failed for inode: %lu " + printk("ES len assertion failed for inode: %lu " "retval %d != map->m_len %d " "in %s (lookup)\n", inode->i_ino, retval, map->m_len, __func__); From e7676a704ee0a1ef71a6b23760b5a8f6896cb1a1 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Sat, 13 Jul 2013 00:40:35 -0400 Subject: [PATCH 0864/1048] ext4: don't allow ext4_free_blocks() to fail due to ENOMEM The filesystem should not be marked inconsistent if ext4_free_blocks() is not able to allocate memory. Unfortunately some callers (most notably ext4_truncate) don't have a way to reflect an error back up to the VFS. And even if we did, most userspace applications won't deal with most system calls returning ENOMEM anyway. Reported-by: Nagachandra P Signed-off-by: "Theodore Ts'o" Cc: stable@vger.kernel.org --- fs/ext4/mballoc.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c index a9ff5e5137ca..4bbbf13bd743 100644 --- a/fs/ext4/mballoc.c +++ b/fs/ext4/mballoc.c @@ -4740,11 +4740,16 @@ do_more: * blocks being freed are metadata. these blocks shouldn't * be used until this transaction is committed */ + retry: new_entry = kmem_cache_alloc(ext4_free_data_cachep, GFP_NOFS); if (!new_entry) { - ext4_mb_unload_buddy(&e4b); - err = -ENOMEM; - goto error_return; + /* + * We use a retry loop because + * ext4_free_blocks() is not allowed to fail. + */ + cond_resched(); + congestion_wait(BLK_RW_ASYNC, HZ/50); + goto retry; } new_entry->efd_start_cluster = bit; new_entry->efd_group = block_group; From d4e1c7ef46e9b02dbf691da0c84d653f88670213 Mon Sep 17 00:00:00 2001 From: Olof Johansson Date: Fri, 12 Jul 2013 20:00:20 -0700 Subject: [PATCH 0865/1048] arm: multi_v7_defconfig: Tweaks for omap and sunxi OMAP recently changed how the platforms are configured, so OMAP2/3/4 SoC support is no longer enabled by default. Add them back. Enable new ethernet driver for sunxi. The i.MX console options moved due to resorting, no functional change. Signed-off-by: Olof Johansson --- arch/arm/configs/multi_v7_defconfig | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/arch/arm/configs/multi_v7_defconfig b/arch/arm/configs/multi_v7_defconfig index 80aacc6d3b48..fe0bdc361d2c 100644 --- a/arch/arm/configs/multi_v7_defconfig +++ b/arch/arm/configs/multi_v7_defconfig @@ -15,8 +15,10 @@ CONFIG_SOC_IMX53=y CONFIG_SOC_IMX6Q=y CONFIG_SOC_IMX6SL=y CONFIG_SOC_VF610=y -CONFIG_ARCH_OMAP2PLUS=y +CONFIG_ARCH_OMAP3=y +CONFIG_ARCH_OMAP4=y CONFIG_SOC_OMAP5=y +CONFIG_SOC_AM33XX=y CONFIG_SOC_AM43XX=y CONFIG_ARCH_ROCKCHIP=y CONFIG_ARCH_SOCFPGA=y @@ -57,9 +59,11 @@ CONFIG_SATA_AHCI_PLATFORM=y CONFIG_SATA_HIGHBANK=y CONFIG_SATA_MV=y CONFIG_NETDEVICES=y +CONFIG_SUN4I_EMAC=y CONFIG_NET_CALXEDA_XGMAC=y CONFIG_SMSC911X=y CONFIG_STMMAC_ETH=y +CONFIG_MDIO_SUN4I=y CONFIG_KEYBOARD_SPEAR=y CONFIG_SERIO_AMBAKMI=y CONFIG_SERIAL_8250=y @@ -70,6 +74,8 @@ CONFIG_SERIAL_AMBA_PL011_CONSOLE=y CONFIG_SERIAL_SIRFSOC=y CONFIG_SERIAL_SIRFSOC_CONSOLE=y CONFIG_SERIAL_TEGRA=y +CONFIG_SERIAL_IMX=y +CONFIG_SERIAL_IMX_CONSOLE=y CONFIG_SERIAL_VT8500=y CONFIG_SERIAL_VT8500_CONSOLE=y CONFIG_SERIAL_OF_PLATFORM=y @@ -77,8 +83,6 @@ CONFIG_SERIAL_OMAP=y CONFIG_SERIAL_OMAP_CONSOLE=y CONFIG_SERIAL_XILINX_PS_UART=y CONFIG_SERIAL_XILINX_PS_UART_CONSOLE=y -CONFIG_SERIAL_IMX=y -CONFIG_SERIAL_IMX_CONSOLE=y CONFIG_SERIAL_FSL_LPUART=y CONFIG_SERIAL_FSL_LPUART_CONSOLE=y CONFIG_I2C_DESIGNWARE_PLATFORM=y From bb458c644a59dbba3a1fe59b27106c5e68e1c4bd Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sat, 13 Jul 2013 13:26:37 +0400 Subject: [PATCH 0866/1048] Safer ABI for O_TMPFILE [suggested by Rasmus Villemoes] make O_DIRECTORY | O_RDWR part of O_TMPFILE; that will fail on old kernels in a lot more cases than what I came up with. And make sure O_CREAT doesn't get there... Signed-off-by: Al Viro --- arch/alpha/include/uapi/asm/fcntl.h | 2 +- arch/parisc/include/uapi/asm/fcntl.h | 2 +- arch/sparc/include/uapi/asm/fcntl.h | 2 +- fs/namei.c | 2 +- fs/open.c | 4 ++-- include/uapi/asm-generic/fcntl.h | 8 ++++++-- 6 files changed, 12 insertions(+), 8 deletions(-) diff --git a/arch/alpha/include/uapi/asm/fcntl.h b/arch/alpha/include/uapi/asm/fcntl.h index dfdadb0b4bef..09f49a6b87d1 100644 --- a/arch/alpha/include/uapi/asm/fcntl.h +++ b/arch/alpha/include/uapi/asm/fcntl.h @@ -32,7 +32,7 @@ #define O_SYNC (__O_SYNC|O_DSYNC) #define O_PATH 040000000 -#define O_TMPFILE 0100000000 +#define __O_TMPFILE 0100000000 #define F_GETLK 7 #define F_SETLK 8 diff --git a/arch/parisc/include/uapi/asm/fcntl.h b/arch/parisc/include/uapi/asm/fcntl.h index cc61c475f277..34a46cbc76ed 100644 --- a/arch/parisc/include/uapi/asm/fcntl.h +++ b/arch/parisc/include/uapi/asm/fcntl.h @@ -20,7 +20,7 @@ #define O_INVISIBLE 004000000 /* invisible I/O, for DMAPI/XDSM */ #define O_PATH 020000000 -#define O_TMPFILE 040000000 +#define __O_TMPFILE 040000000 #define F_GETLK64 8 #define F_SETLK64 9 diff --git a/arch/sparc/include/uapi/asm/fcntl.h b/arch/sparc/include/uapi/asm/fcntl.h index d73e5e008b0d..7e8ace5bf760 100644 --- a/arch/sparc/include/uapi/asm/fcntl.h +++ b/arch/sparc/include/uapi/asm/fcntl.h @@ -35,7 +35,7 @@ #define O_SYNC (__O_SYNC|O_DSYNC) #define O_PATH 0x1000000 -#define O_TMPFILE 0x2000000 +#define __O_TMPFILE 0x2000000 #define F_GETOWN 5 /* for sockets. */ #define F_SETOWN 6 /* for sockets. */ diff --git a/fs/namei.c b/fs/namei.c index b2beee7a733f..8b61d103a8a7 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -2977,7 +2977,7 @@ static struct file *path_openat(int dfd, struct filename *pathname, file->f_flags = op->open_flag; - if (unlikely(file->f_flags & O_TMPFILE)) { + if (unlikely(file->f_flags & __O_TMPFILE)) { error = do_tmpfile(dfd, pathname, nd, flags, op, file, &opened); goto out; } diff --git a/fs/open.c b/fs/open.c index fca72c4d3f17..9156cb050d08 100644 --- a/fs/open.c +++ b/fs/open.c @@ -840,8 +840,8 @@ static inline int build_open_flags(int flags, umode_t mode, struct open_flags *o if (flags & __O_SYNC) flags |= O_DSYNC; - if (flags & O_TMPFILE) { - if (!(flags & O_CREAT)) + if (flags & __O_TMPFILE) { + if ((flags & O_TMPFILE_MASK) != O_TMPFILE) return -EINVAL; acc_mode = MAY_OPEN | ACC_MODE(flags); } else if (flags & O_PATH) { diff --git a/include/uapi/asm-generic/fcntl.h b/include/uapi/asm-generic/fcntl.h index 06632beaa6d5..05ac354e124d 100644 --- a/include/uapi/asm-generic/fcntl.h +++ b/include/uapi/asm-generic/fcntl.h @@ -84,10 +84,14 @@ #define O_PATH 010000000 #endif -#ifndef O_TMPFILE -#define O_TMPFILE 020000000 +#ifndef __O_TMPFILE +#define __O_TMPFILE 020000000 #endif +/* a horrid kludge trying to make sure that this will fail on old kernels */ +#define O_TMPFILE (__O_TMPFILE | O_DIRECTORY | O_RDWR) +#define O_TMPFILE_MASK (__O_TMPFILE | O_DIRECTORY | O_CREAT | O_ACCMODE) + #ifndef O_NDELAY #define O_NDELAY O_NONBLOCK #endif From 64372501e2af9b11e2ffd1ff79345dc4b1abe539 Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Mon, 8 Jul 2013 14:24:15 -0700 Subject: [PATCH 0867/1048] fs/file_table.c:fput(): add comment A missed update to "fput: task_work_add() can fail if the caller has passed exit_task_work()". Cc: "Eric W. Biederman" Cc: Al Viro Cc: Andrey Vagin Cc: David Howells Cc: Oleg Nesterov Signed-off-by: Andrew Morton Signed-off-by: Al Viro --- fs/file_table.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/fs/file_table.c b/fs/file_table.c index 08e719b884ca..b9a77ad08b4d 100644 --- a/fs/file_table.c +++ b/fs/file_table.c @@ -313,6 +313,12 @@ void fput(struct file *file) init_task_work(&file->f_u.fu_rcuhead, ____fput); if (!task_work_add(task, &file->f_u.fu_rcuhead, true)) return; + /* + * After this task has run exit_task_work(), + * task_work_add() will fail. free_ipc_ns()-> + * shm_destroy() can do this. Fall through to delayed + * fput to avoid leaking *file. + */ } spin_lock_irqsave(&delayed_fput_lock, flags); list_add(&file->f_u.fu_list, &delayed_fput_list); From 4f5e65a1cc90bbb15b9f6cdc362922af1bcc155a Mon Sep 17 00:00:00 2001 From: Oleg Nesterov Date: Mon, 8 Jul 2013 14:24:16 -0700 Subject: [PATCH 0868/1048] fput: turn "list_head delayed_fput_list" into llist_head fput() and delayed_fput() can use llist and avoid the locking. This is unlikely path, it is not that this change can improve the performance, but this way the code looks simpler. Signed-off-by: Oleg Nesterov Suggested-by: Andrew Morton Cc: Al Viro Cc: Andrey Vagin Cc: "Eric W. Biederman" Cc: David Howells Cc: Huang Ying Cc: Peter Zijlstra Signed-off-by: Andrew Morton Signed-off-by: Al Viro --- fs/file_table.c | 25 ++++++++++--------------- include/linux/fs.h | 2 ++ 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/fs/file_table.c b/fs/file_table.c index b9a77ad08b4d..b44e4c559786 100644 --- a/fs/file_table.c +++ b/fs/file_table.c @@ -265,18 +265,15 @@ static void __fput(struct file *file) mntput(mnt); } -static DEFINE_SPINLOCK(delayed_fput_lock); -static LIST_HEAD(delayed_fput_list); +static LLIST_HEAD(delayed_fput_list); static void delayed_fput(struct work_struct *unused) { - LIST_HEAD(head); - spin_lock_irq(&delayed_fput_lock); - list_splice_init(&delayed_fput_list, &head); - spin_unlock_irq(&delayed_fput_lock); - while (!list_empty(&head)) { - struct file *f = list_first_entry(&head, struct file, f_u.fu_list); - list_del_init(&f->f_u.fu_list); - __fput(f); + struct llist_node *node = llist_del_all(&delayed_fput_list); + struct llist_node *next; + + for (; node; node = next) { + next = llist_next(node); + __fput(llist_entry(node, struct file, f_u.fu_llist)); } } @@ -306,7 +303,6 @@ void fput(struct file *file) { if (atomic_long_dec_and_test(&file->f_count)) { struct task_struct *task = current; - unsigned long flags; file_sb_list_del(file); if (likely(!in_interrupt() && !(task->flags & PF_KTHREAD))) { @@ -320,10 +316,9 @@ void fput(struct file *file) * fput to avoid leaking *file. */ } - spin_lock_irqsave(&delayed_fput_lock, flags); - list_add(&file->f_u.fu_list, &delayed_fput_list); - schedule_work(&delayed_fput_work); - spin_unlock_irqrestore(&delayed_fput_lock, flags); + + if (llist_add(&file->f_u.fu_llist, &delayed_fput_list)) + schedule_work(&delayed_fput_work); } } diff --git a/include/linux/fs.h b/include/linux/fs.h index 834c9e5113d9..d40e8e78bbd1 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -768,6 +769,7 @@ struct file { */ union { struct list_head fu_list; + struct llist_node fu_llist; struct rcu_head fu_rcuhead; } f_u; struct path f_path; From fb4214db50b00558cc6e274c88b3f7325068e942 Mon Sep 17 00:00:00 2001 From: Oleg Nesterov Date: Mon, 8 Jul 2013 14:24:18 -0700 Subject: [PATCH 0869/1048] llist: fix/simplify llist_add() and llist_add_batch() 1. This is mostly theoretical, but llist_add*() need ACCESS_ONCE(). Otherwise it is not guaranteed that the first cmpxchg() uses the same value for old_entry and new_last->next. 2. These helpers cache the result of cmpxchg() and read the initial value of head->first before the main loop. I do not think this makes sense. In the likely case cmpxchg() succeeds, otherwise it doesn't hurt to reload head->first. I think it would be better to simplify the code and simply read ->first before cmpxchg(). Signed-off-by: Oleg Nesterov Cc: Al Viro Cc: Andrey Vagin Cc: "Eric W. Biederman" Cc: David Howells Cc: Huang Ying Cc: Peter Zijlstra Signed-off-by: Andrew Morton Signed-off-by: Al Viro --- include/linux/llist.h | 15 +++++---------- lib/llist.c | 15 +++++---------- 2 files changed, 10 insertions(+), 20 deletions(-) diff --git a/include/linux/llist.h b/include/linux/llist.h index a5199f6d0e82..3e2b969d68f6 100644 --- a/include/linux/llist.h +++ b/include/linux/llist.h @@ -151,18 +151,13 @@ static inline struct llist_node *llist_next(struct llist_node *node) */ static inline bool llist_add(struct llist_node *new, struct llist_head *head) { - struct llist_node *entry, *old_entry; + struct llist_node *first; - entry = head->first; - for (;;) { - old_entry = entry; - new->next = entry; - entry = cmpxchg(&head->first, old_entry, new); - if (entry == old_entry) - break; - } + do { + new->next = first = ACCESS_ONCE(head->first); + } while (cmpxchg(&head->first, first, new) != first); - return old_entry == NULL; + return !first; } /** diff --git a/lib/llist.c b/lib/llist.c index 4a15115e90f8..4a70d120138c 100644 --- a/lib/llist.c +++ b/lib/llist.c @@ -39,18 +39,13 @@ bool llist_add_batch(struct llist_node *new_first, struct llist_node *new_last, struct llist_head *head) { - struct llist_node *entry, *old_entry; + struct llist_node *first; - entry = head->first; - for (;;) { - old_entry = entry; - new_last->next = entry; - entry = cmpxchg(&head->first, old_entry, new_first); - if (entry == old_entry) - break; - } + do { + new_last->next = first = ACCESS_ONCE(head->first); + } while (cmpxchg(&head->first, first, new_first) != first); - return old_entry == NULL; + return !first; } EXPORT_SYMBOL_GPL(llist_add_batch); From e9a17bd73a29e5323c37ec5ffe50fc0e825d3d03 Mon Sep 17 00:00:00 2001 From: Oleg Nesterov Date: Mon, 8 Jul 2013 14:24:19 -0700 Subject: [PATCH 0870/1048] llist: llist_add() can use llist_add_batch() llist_add(new, head) can simply use llist_add_batch(new, new, head), no need to duplicate the code. This obviously uninlines llist_add() and to me this is a win. But we can make llist_add_batch() inline if this is desirable, in this case gcc can notice that new_first == new_last if the caller is llist_add(). Signed-off-by: Oleg Nesterov Cc: Al Viro Cc: Andrey Vagin Cc: "Eric W. Biederman" Cc: David Howells Cc: Huang Ying Cc: Peter Zijlstra Signed-off-by: Andrew Morton Signed-off-by: Al Viro --- include/linux/llist.h | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/include/linux/llist.h b/include/linux/llist.h index 3e2b969d68f6..cdaa7f023899 100644 --- a/include/linux/llist.h +++ b/include/linux/llist.h @@ -142,6 +142,9 @@ static inline struct llist_node *llist_next(struct llist_node *node) return node->next; } +extern bool llist_add_batch(struct llist_node *new_first, + struct llist_node *new_last, + struct llist_head *head); /** * llist_add - add a new entry * @new: new entry to be added @@ -151,13 +154,7 @@ static inline struct llist_node *llist_next(struct llist_node *node) */ static inline bool llist_add(struct llist_node *new, struct llist_head *head) { - struct llist_node *first; - - do { - new->next = first = ACCESS_ONCE(head->first); - } while (cmpxchg(&head->first, first, new) != first); - - return !first; + return llist_add_batch(new, new, head); } /** @@ -173,9 +170,6 @@ static inline struct llist_node *llist_del_all(struct llist_head *head) return xchg(&head->first, NULL); } -extern bool llist_add_batch(struct llist_node *new_first, - struct llist_node *new_last, - struct llist_head *head); extern struct llist_node *llist_del_first(struct llist_head *head); #endif /* LLIST_H */ From a95e691f9c4a6e24fdeab6d7feae6d5411fe8a69 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sun, 14 Jul 2013 16:43:54 +0400 Subject: [PATCH 0871/1048] rpc_create_*_dir: don't bother with qstr just pass the name Signed-off-by: Al Viro --- include/linux/sunrpc/rpc_pipe_fs.h | 4 ++-- net/sunrpc/cache.c | 18 +++++------------- net/sunrpc/clnt.c | 20 ++++++++------------ net/sunrpc/rpc_pipe.c | 14 ++++++++------ 4 files changed, 23 insertions(+), 33 deletions(-) diff --git a/include/linux/sunrpc/rpc_pipe_fs.h b/include/linux/sunrpc/rpc_pipe_fs.h index a7b422b33eda..aa5b582cc471 100644 --- a/include/linux/sunrpc/rpc_pipe_fs.h +++ b/include/linux/sunrpc/rpc_pipe_fs.h @@ -73,12 +73,12 @@ extern ssize_t rpc_pipe_generic_upcall(struct file *, struct rpc_pipe_msg *, extern int rpc_queue_upcall(struct rpc_pipe *, struct rpc_pipe_msg *); struct rpc_clnt; -extern struct dentry *rpc_create_client_dir(struct dentry *, struct qstr *, struct rpc_clnt *); +extern struct dentry *rpc_create_client_dir(struct dentry *, const char *, struct rpc_clnt *); extern int rpc_remove_client_dir(struct dentry *); struct cache_detail; extern struct dentry *rpc_create_cache_dir(struct dentry *, - struct qstr *, + const char *, umode_t umode, struct cache_detail *); extern void rpc_remove_cache_dir(struct dentry *); diff --git a/net/sunrpc/cache.c b/net/sunrpc/cache.c index 80fe5c86efd1..b40f9567e628 100644 --- a/net/sunrpc/cache.c +++ b/net/sunrpc/cache.c @@ -1812,19 +1812,11 @@ int sunrpc_cache_register_pipefs(struct dentry *parent, const char *name, umode_t umode, struct cache_detail *cd) { - struct qstr q; - struct dentry *dir; - int ret = 0; - - q.name = name; - q.len = strlen(name); - q.hash = full_name_hash(q.name, q.len); - dir = rpc_create_cache_dir(parent, &q, umode, cd); - if (!IS_ERR(dir)) - cd->u.pipefs.dir = dir; - else - ret = PTR_ERR(dir); - return ret; + struct dentry *dir = rpc_create_cache_dir(parent, name, umode, cd); + if (IS_ERR(dir)) + return PTR_ERR(dir); + cd->u.pipefs.dir = dir; + return 0; } EXPORT_SYMBOL_GPL(sunrpc_cache_register_pipefs); diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c index 5a750b9c3640..26456274b24e 100644 --- a/net/sunrpc/clnt.c +++ b/net/sunrpc/clnt.c @@ -128,9 +128,7 @@ static struct dentry *rpc_setup_pipedir_sb(struct super_block *sb, { static uint32_t clntid; char name[15]; - struct qstr q = { .name = name }; struct dentry *dir, *dentry; - int error; dir = rpc_d_lookup_sb(sb, dir_name); if (dir == NULL) { @@ -138,19 +136,17 @@ static struct dentry *rpc_setup_pipedir_sb(struct super_block *sb, return dir; } for (;;) { - q.len = snprintf(name, sizeof(name), "clnt%x", (unsigned int)clntid++); + snprintf(name, sizeof(name), "clnt%x", (unsigned int)clntid++); name[sizeof(name) - 1] = '\0'; - q.hash = full_name_hash(q.name, q.len); - dentry = rpc_create_client_dir(dir, &q, clnt); + dentry = rpc_create_client_dir(dir, name, clnt); if (!IS_ERR(dentry)) break; - error = PTR_ERR(dentry); - if (error != -EEXIST) { - printk(KERN_INFO "RPC: Couldn't create pipefs entry" - " %s/%s, error %d\n", - dir_name, name, error); - break; - } + if (dentry == ERR_PTR(-EEXIST)) + continue; + printk(KERN_INFO "RPC: Couldn't create pipefs entry" + " %s/%s, error %ld\n", + dir_name, name, PTR_ERR(dentry)); + break; } dput(dir); return dentry; diff --git a/net/sunrpc/rpc_pipe.c b/net/sunrpc/rpc_pipe.c index e7ce4b3eb0bd..63364cb5d11a 100644 --- a/net/sunrpc/rpc_pipe.c +++ b/net/sunrpc/rpc_pipe.c @@ -770,15 +770,17 @@ out_bad: } static struct dentry *rpc_mkdir_populate(struct dentry *parent, - struct qstr *name, umode_t mode, void *private, + const char *name, umode_t mode, void *private, int (*populate)(struct dentry *, void *), void *args_populate) { struct dentry *dentry; + struct qstr q = QSTR_INIT(name, strlen(name)); struct inode *dir = parent->d_inode; int error; + q.hash = full_name_hash(q.name, q.len); mutex_lock_nested(&dir->i_mutex, I_MUTEX_PARENT); - dentry = __rpc_lookup_create_exclusive(parent, name); + dentry = __rpc_lookup_create_exclusive(parent, &q); if (IS_ERR(dentry)) goto out; error = __rpc_mkdir(dir, dentry, mode, NULL, private); @@ -925,8 +927,8 @@ static void rpc_clntdir_depopulate(struct dentry *dentry) /** * rpc_create_client_dir - Create a new rpc_client directory in rpc_pipefs - * @dentry: dentry from the rpc_pipefs root to the new directory - * @name: &struct qstr for the name + * @dentry: the parent of new directory + * @name: the name of new directory * @rpc_client: rpc client to associate with this directory * * This creates a directory at the given @path associated with @@ -935,7 +937,7 @@ static void rpc_clntdir_depopulate(struct dentry *dentry) * later be created using rpc_mkpipe(). */ struct dentry *rpc_create_client_dir(struct dentry *dentry, - struct qstr *name, + const char *name, struct rpc_clnt *rpc_client) { return rpc_mkdir_populate(dentry, name, S_IRUGO | S_IXUGO, NULL, @@ -981,7 +983,7 @@ static void rpc_cachedir_depopulate(struct dentry *dentry) rpc_depopulate(dentry, cache_pipefs_files, 0, 3); } -struct dentry *rpc_create_cache_dir(struct dentry *parent, struct qstr *name, +struct dentry *rpc_create_cache_dir(struct dentry *parent, const char *name, umode_t umode, struct cache_detail *cd) { return rpc_mkdir_populate(parent, name, umode, NULL, From d3db90b0a448bfdf77ab3d887c9579fead656cc5 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sun, 14 Jul 2013 17:09:57 +0400 Subject: [PATCH 0872/1048] __rpc_lookup_create_exclusive: pass string instead of qstr ... and use d_hash_and_lookup() instead of open-coding it, for fsck sake... Signed-off-by: Al Viro --- net/sunrpc/rpc_pipe.c | 34 +++++++++------------------------- 1 file changed, 9 insertions(+), 25 deletions(-) diff --git a/net/sunrpc/rpc_pipe.c b/net/sunrpc/rpc_pipe.c index 63364cb5d11a..27e54d265705 100644 --- a/net/sunrpc/rpc_pipe.c +++ b/net/sunrpc/rpc_pipe.c @@ -656,13 +656,12 @@ static int __rpc_rmpipe(struct inode *dir, struct dentry *dentry) } static struct dentry *__rpc_lookup_create_exclusive(struct dentry *parent, - struct qstr *name) + const char *name) { - struct dentry *dentry; - - dentry = d_lookup(parent, name); + struct qstr q = QSTR_INIT(name, strlen(name)); + struct dentry *dentry = d_hash_and_lookup(parent, &q); if (!dentry) { - dentry = d_alloc(parent, name); + dentry = d_alloc(parent, &q); if (!dentry) return ERR_PTR(-ENOMEM); } @@ -689,8 +688,7 @@ static void __rpc_depopulate(struct dentry *parent, for (i = start; i < eof; i++) { name.name = files[i].name; name.len = strlen(files[i].name); - name.hash = full_name_hash(name.name, name.len); - dentry = d_lookup(parent, &name); + dentry = d_hash_and_lookup(parent, &name); if (dentry == NULL) continue; @@ -732,12 +730,7 @@ static int rpc_populate(struct dentry *parent, mutex_lock(&dir->i_mutex); for (i = start; i < eof; i++) { - struct qstr q; - - q.name = files[i].name; - q.len = strlen(files[i].name); - q.hash = full_name_hash(q.name, q.len); - dentry = __rpc_lookup_create_exclusive(parent, &q); + dentry = __rpc_lookup_create_exclusive(parent, files[i].name); err = PTR_ERR(dentry); if (IS_ERR(dentry)) goto out_bad; @@ -774,13 +767,11 @@ static struct dentry *rpc_mkdir_populate(struct dentry *parent, int (*populate)(struct dentry *, void *), void *args_populate) { struct dentry *dentry; - struct qstr q = QSTR_INIT(name, strlen(name)); struct inode *dir = parent->d_inode; int error; - q.hash = full_name_hash(q.name, q.len); mutex_lock_nested(&dir->i_mutex, I_MUTEX_PARENT); - dentry = __rpc_lookup_create_exclusive(parent, &q); + dentry = __rpc_lookup_create_exclusive(parent, name); if (IS_ERR(dentry)) goto out; error = __rpc_mkdir(dir, dentry, mode, NULL, private); @@ -843,7 +834,6 @@ struct dentry *rpc_mkpipe_dentry(struct dentry *parent, const char *name, struct dentry *dentry; struct inode *dir = parent->d_inode; umode_t umode = S_IFIFO | S_IRUSR | S_IWUSR; - struct qstr q; int err; if (pipe->ops->upcall == NULL) @@ -851,12 +841,8 @@ struct dentry *rpc_mkpipe_dentry(struct dentry *parent, const char *name, if (pipe->ops->downcall == NULL) umode &= ~S_IWUGO; - q.name = name; - q.len = strlen(name); - q.hash = full_name_hash(q.name, q.len), - mutex_lock_nested(&dir->i_mutex, I_MUTEX_PARENT); - dentry = __rpc_lookup_create_exclusive(parent, &q); + dentry = __rpc_lookup_create_exclusive(parent, name); if (IS_ERR(dentry)) goto out; err = __rpc_mkpipe_dentry(dir, dentry, umode, &rpc_pipe_fops, @@ -1063,9 +1049,7 @@ struct dentry *rpc_d_lookup_sb(const struct super_block *sb, const unsigned char *dir_name) { struct qstr dir = QSTR_INIT(dir_name, strlen(dir_name)); - - dir.hash = full_name_hash(dir.name, dir.len); - return d_lookup(sb->s_root, &dir); + return d_hash_and_lookup(sb->s_root, &dir); } EXPORT_SYMBOL_GPL(rpc_d_lookup_sb); From ec193cf5af0a8dc35c3975ca0aca8e7b7f3e3464 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sun, 14 Jul 2013 17:16:52 +0400 Subject: [PATCH 0873/1048] configfs: don't open-code d_alloc_name() Signed-off-by: Al Viro --- fs/configfs/dir.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c index 64e5323cbbb0..437b0d535b33 100644 --- a/fs/configfs/dir.c +++ b/fs/configfs/dir.c @@ -660,19 +660,15 @@ static int create_default_group(struct config_group *parent_group, struct config_group *group) { int ret; - struct qstr name; struct configfs_dirent *sd; /* We trust the caller holds a reference to parent */ struct dentry *child, *parent = parent_group->cg_item.ci_dentry; if (!group->cg_item.ci_name) group->cg_item.ci_name = group->cg_item.ci_namebuf; - name.name = group->cg_item.ci_name; - name.len = strlen(name.name); - name.hash = full_name_hash(name.name, name.len); ret = -ENOMEM; - child = d_alloc(parent, &name); + child = d_alloc_name(parent, group->cg_item.ci_name); if (child) { d_add(child, NULL); @@ -1650,7 +1646,6 @@ int configfs_register_subsystem(struct configfs_subsystem *subsys) { int err; struct config_group *group = &subsys->su_group; - struct qstr name; struct dentry *dentry; struct dentry *root; struct configfs_dirent *sd; @@ -1667,12 +1662,8 @@ int configfs_register_subsystem(struct configfs_subsystem *subsys) mutex_lock_nested(&root->d_inode->i_mutex, I_MUTEX_PARENT); - name.name = group->cg_item.ci_name; - name.len = strlen(name.name); - name.hash = full_name_hash(name.name, name.len); - err = -ENOMEM; - dentry = d_alloc(root, &name); + dentry = d_alloc_name(root, group->cg_item.ci_name); if (dentry) { d_add(dentry, NULL); From 74931da7a6d341c137f1564a47f36fda68ad21e6 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sun, 14 Jul 2013 17:43:25 +0400 Subject: [PATCH 0874/1048] make simple_lookup() usable for filesystems that set ->s_d_op Signed-off-by: Al Viro --- fs/libfs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/libfs.c b/fs/libfs.c index c3a0837fb861..3a3a9b53bf5a 100644 --- a/fs/libfs.c +++ b/fs/libfs.c @@ -61,7 +61,8 @@ struct dentry *simple_lookup(struct inode *dir, struct dentry *dentry, unsigned if (dentry->d_name.len > NAME_MAX) return ERR_PTR(-ENAMETOOLONG); - d_set_d_op(dentry, &simple_dentry_operations); + if (!dentry->d_sb->s_d_op) + d_set_d_op(dentry, &simple_dentry_operations); d_add(dentry, NULL); return NULL; } From 6e8cd2cb46e3c772871c86de2ffb718f911f9b59 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sun, 14 Jul 2013 17:48:35 +0400 Subject: [PATCH 0875/1048] efivarfs: we can use simple_lookup() now Signed-off-by: Al Viro --- fs/efivarfs/inode.c | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/fs/efivarfs/inode.c b/fs/efivarfs/inode.c index 7e787fb90293..07ab49745e31 100644 --- a/fs/efivarfs/inode.c +++ b/fs/efivarfs/inode.c @@ -155,20 +155,8 @@ static int efivarfs_unlink(struct inode *dir, struct dentry *dentry) return 0; }; -/* - * Handle negative dentry. - */ -static struct dentry *efivarfs_lookup(struct inode *dir, struct dentry *dentry, - unsigned int flags) -{ - if (dentry->d_name.len > NAME_MAX) - return ERR_PTR(-ENAMETOOLONG); - d_add(dentry, NULL); - return NULL; -} - const struct inode_operations efivarfs_dir_inode_operations = { - .lookup = efivarfs_lookup, + .lookup = simple_lookup, .unlink = efivarfs_unlink, .create = efivarfs_create, }; From 786e1448d9c5d2a469bcc9d2aecacd418ee1aca0 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sun, 14 Jul 2013 17:50:23 +0400 Subject: [PATCH 0876/1048] cgroup: we can use simple_lookup() now Signed-off-by: Al Viro --- kernel/cgroup.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/kernel/cgroup.c b/kernel/cgroup.c index e5583d10a325..0e0b20b8c5db 100644 --- a/kernel/cgroup.c +++ b/kernel/cgroup.c @@ -802,7 +802,6 @@ static struct cgroup *task_cgroup_from_root(struct task_struct *task, */ static int cgroup_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode); -static struct dentry *cgroup_lookup(struct inode *, struct dentry *, unsigned int); static int cgroup_rmdir(struct inode *unused_dir, struct dentry *dentry); static int cgroup_populate_dir(struct cgroup *cgrp, bool base_files, unsigned long subsys_mask); @@ -2642,7 +2641,7 @@ static const struct inode_operations cgroup_file_inode_operations = { }; static const struct inode_operations cgroup_dir_inode_operations = { - .lookup = cgroup_lookup, + .lookup = simple_lookup, .mkdir = cgroup_mkdir, .rmdir = cgroup_rmdir, .rename = cgroup_rename, @@ -2652,14 +2651,6 @@ static const struct inode_operations cgroup_dir_inode_operations = { .removexattr = cgroup_removexattr, }; -static struct dentry *cgroup_lookup(struct inode *dir, struct dentry *dentry, unsigned int flags) -{ - if (dentry->d_name.len > NAME_MAX) - return ERR_PTR(-ENAMETOOLONG); - d_add(dentry, NULL); - return NULL; -} - /* * Check if a file is a control file */ From dae3794fd603b92dcbac2859fe0bc7fe129a5188 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sun, 14 Jul 2013 17:55:39 +0400 Subject: [PATCH 0877/1048] sunrpc: now we can just set ->s_d_op Signed-off-by: Al Viro --- net/sunrpc/rpc_pipe.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/net/sunrpc/rpc_pipe.c b/net/sunrpc/rpc_pipe.c index 27e54d265705..260fe72656a1 100644 --- a/net/sunrpc/rpc_pipe.c +++ b/net/sunrpc/rpc_pipe.c @@ -665,10 +665,8 @@ static struct dentry *__rpc_lookup_create_exclusive(struct dentry *parent, if (!dentry) return ERR_PTR(-ENOMEM); } - if (dentry->d_inode == NULL) { - d_set_d_op(dentry, &rpc_dentry_operations); + if (dentry->d_inode == NULL) return dentry; - } dput(dentry); return ERR_PTR(-EEXIST); } @@ -1102,6 +1100,7 @@ rpc_fill_super(struct super_block *sb, void *data, int silent) sb->s_blocksize_bits = PAGE_CACHE_SHIFT; sb->s_magic = RPCAUTH_GSSMAGIC; sb->s_op = &s_ops; + sb->s_d_op = &rpc_dentry_operations; sb->s_time_gran = 1; inode = rpc_get_inode(sb, S_IFDIR | S_IRUGO | S_IXUGO); From c2b4cacfe9816c1fe378c785ce8a678cf0635ec6 Mon Sep 17 00:00:00 2001 From: Alex Deucher Date: Mon, 8 Jul 2013 18:16:56 -0400 Subject: [PATCH 0878/1048] drm/radeon/hdmi: make sure we have an afmt block assigned Prevents a segfault if an afmt block is not assigned to the encoder such as in the LVDS or eDP case. Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=66714 Signed-off-by: Alex Deucher Cc: stable@vger.kernel.org --- drivers/gpu/drm/radeon/evergreen_hdmi.c | 6 ++++++ drivers/gpu/drm/radeon/r600_hdmi.c | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/drivers/gpu/drm/radeon/evergreen_hdmi.c b/drivers/gpu/drm/radeon/evergreen_hdmi.c index b9c6f7675e59..b0d3fb341417 100644 --- a/drivers/gpu/drm/radeon/evergreen_hdmi.c +++ b/drivers/gpu/drm/radeon/evergreen_hdmi.c @@ -177,6 +177,9 @@ void evergreen_hdmi_setmode(struct drm_encoder *encoder, struct drm_display_mode uint32_t offset; ssize_t err; + if (!dig || !dig->afmt) + return; + /* Silent, r600_hdmi_enable will raise WARN for us */ if (!dig->afmt->enabled) return; @@ -280,6 +283,9 @@ void evergreen_hdmi_enable(struct drm_encoder *encoder, bool enable) struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv; + if (!dig || !dig->afmt) + return; + /* Silent, r600_hdmi_enable will raise WARN for us */ if (enable && dig->afmt->enabled) return; diff --git a/drivers/gpu/drm/radeon/r600_hdmi.c b/drivers/gpu/drm/radeon/r600_hdmi.c index e73b2a73494a..f48240bb8c56 100644 --- a/drivers/gpu/drm/radeon/r600_hdmi.c +++ b/drivers/gpu/drm/radeon/r600_hdmi.c @@ -266,6 +266,9 @@ void r600_hdmi_setmode(struct drm_encoder *encoder, struct drm_display_mode *mod uint32_t offset; ssize_t err; + if (!dig || !dig->afmt) + return; + /* Silent, r600_hdmi_enable will raise WARN for us */ if (!dig->afmt->enabled) return; @@ -448,6 +451,9 @@ void r600_hdmi_enable(struct drm_encoder *encoder, bool enable) struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv; u32 hdmi = HDMI0_ERROR_ACK; + if (!dig || !dig->afmt) + return; + /* Silent, r600_hdmi_enable will raise WARN for us */ if (enable && dig->afmt->enabled) return; From 9847b36af413f32528fc929a0b11d32c2872a05c Mon Sep 17 00:00:00 2001 From: Alex Deucher Date: Thu, 11 Jul 2013 15:00:14 -0400 Subject: [PATCH 0879/1048] drm/radeon/dpm: disable gfx PG on PALM Gfx PG doesn't seem to work properly when UVD is initialized on certain PALM boards. Disable gfx PG for now until we sort out a proper fix. Signed-off-by: Alex Deucher --- drivers/gpu/drm/radeon/sumo_dpm.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/radeon/sumo_dpm.c b/drivers/gpu/drm/radeon/sumo_dpm.c index 11b6b9924f1b..ca381028bd7b 100644 --- a/drivers/gpu/drm/radeon/sumo_dpm.c +++ b/drivers/gpu/drm/radeon/sumo_dpm.c @@ -1732,7 +1732,13 @@ int sumo_dpm_init(struct radeon_device *rdev) pi->enable_sclk_ds = true; pi->enable_dynamic_m3_arbiter = false; pi->enable_dynamic_patch_ps = true; - pi->enable_gfx_power_gating = true; + /* Some PALM chips don't seem to properly ungate gfx when UVD is in use; + * for now just disable gfx PG. + */ + if (rdev->family == CHIP_PALM) + pi->enable_gfx_power_gating = false; + else + pi->enable_gfx_power_gating = true; pi->enable_gfx_clock_gating = true; pi->enable_mg_clock_gating = true; pi->enable_auto_thermal_throttling = true; From aeea40cbf9388fc829e66fa049f64d97fd72e118 Mon Sep 17 00:00:00 2001 From: Alex Deucher Date: Thu, 11 Jul 2013 14:20:11 -0400 Subject: [PATCH 0880/1048] drm/radeon: Disable dma rings for bo moves on r6xx MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit They still seem to cause instability on some r6xx parts. As a follow up, we can switch to using CP DMA for bo moves on r6xx as a lighter weight alternative to using the 3D engine. A version of this patch should also go to stable kernels. Tested-by: J.N. Reviewed-by: Christian König Signed-off-by: Alex Deucher --- drivers/gpu/drm/radeon/radeon_asic.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/radeon/radeon_asic.c b/drivers/gpu/drm/radeon/radeon_asic.c index 097077499cc6..ea5c52b1f445 100644 --- a/drivers/gpu/drm/radeon/radeon_asic.c +++ b/drivers/gpu/drm/radeon/radeon_asic.c @@ -1026,8 +1026,8 @@ static struct radeon_asic r600_asic = { .blit_ring_index = RADEON_RING_TYPE_GFX_INDEX, .dma = &r600_copy_dma, .dma_ring_index = R600_RING_TYPE_DMA_INDEX, - .copy = &r600_copy_dma, - .copy_ring_index = R600_RING_TYPE_DMA_INDEX, + .copy = &r600_copy_blit, + .copy_ring_index = RADEON_RING_TYPE_GFX_INDEX, }, .surface = { .set_reg = r600_set_surface_reg, @@ -1119,8 +1119,8 @@ static struct radeon_asic rv6xx_asic = { .blit_ring_index = RADEON_RING_TYPE_GFX_INDEX, .dma = &r600_copy_dma, .dma_ring_index = R600_RING_TYPE_DMA_INDEX, - .copy = &r600_copy_dma, - .copy_ring_index = R600_RING_TYPE_DMA_INDEX, + .copy = &r600_copy_blit, + .copy_ring_index = RADEON_RING_TYPE_GFX_INDEX, }, .surface = { .set_reg = r600_set_surface_reg, @@ -1229,8 +1229,8 @@ static struct radeon_asic rs780_asic = { .blit_ring_index = RADEON_RING_TYPE_GFX_INDEX, .dma = &r600_copy_dma, .dma_ring_index = R600_RING_TYPE_DMA_INDEX, - .copy = &r600_copy_dma, - .copy_ring_index = R600_RING_TYPE_DMA_INDEX, + .copy = &r600_copy_blit, + .copy_ring_index = RADEON_RING_TYPE_GFX_INDEX, }, .surface = { .set_reg = r600_set_surface_reg, From 072b5acc7edec1530acc0497b48616bf8dd93313 Mon Sep 17 00:00:00 2001 From: Alex Deucher Date: Thu, 11 Jul 2013 14:48:05 -0400 Subject: [PATCH 0881/1048] drm/radeon: implement bo copy callback using CP DMA (v2) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Lighter weight than using the 3D engine. v2: fix ring count Reviewed-by: Christian König Signed-off-by: Alex Deucher --- drivers/gpu/drm/radeon/r600.c | 81 ++++++++++++++++++++++++++++ drivers/gpu/drm/radeon/r600d.h | 1 + drivers/gpu/drm/radeon/radeon_asic.h | 3 ++ 3 files changed, 85 insertions(+) diff --git a/drivers/gpu/drm/radeon/r600.c b/drivers/gpu/drm/radeon/r600.c index 2d3655f7f41e..f7d494f264a5 100644 --- a/drivers/gpu/drm/radeon/r600.c +++ b/drivers/gpu/drm/radeon/r600.c @@ -3144,6 +3144,87 @@ int r600_copy_blit(struct radeon_device *rdev, return 0; } +/** + * r600_copy_cpdma - copy pages using the CP DMA engine + * + * @rdev: radeon_device pointer + * @src_offset: src GPU address + * @dst_offset: dst GPU address + * @num_gpu_pages: number of GPU pages to xfer + * @fence: radeon fence object + * + * Copy GPU paging using the CP DMA engine (r6xx+). + * Used by the radeon ttm implementation to move pages if + * registered as the asic copy callback. + */ +int r600_copy_cpdma(struct radeon_device *rdev, + uint64_t src_offset, uint64_t dst_offset, + unsigned num_gpu_pages, + struct radeon_fence **fence) +{ + struct radeon_semaphore *sem = NULL; + int ring_index = rdev->asic->copy.blit_ring_index; + struct radeon_ring *ring = &rdev->ring[ring_index]; + u32 size_in_bytes, cur_size_in_bytes, tmp; + int i, num_loops; + int r = 0; + + r = radeon_semaphore_create(rdev, &sem); + if (r) { + DRM_ERROR("radeon: moving bo (%d).\n", r); + return r; + } + + size_in_bytes = (num_gpu_pages << RADEON_GPU_PAGE_SHIFT); + num_loops = DIV_ROUND_UP(size_in_bytes, 0x1fffff); + r = radeon_ring_lock(rdev, ring, num_loops * 6 + 21); + if (r) { + DRM_ERROR("radeon: moving bo (%d).\n", r); + radeon_semaphore_free(rdev, &sem, NULL); + return r; + } + + if (radeon_fence_need_sync(*fence, ring->idx)) { + radeon_semaphore_sync_rings(rdev, sem, (*fence)->ring, + ring->idx); + radeon_fence_note_sync(*fence, ring->idx); + } else { + radeon_semaphore_free(rdev, &sem, NULL); + } + + for (i = 0; i < num_loops; i++) { + cur_size_in_bytes = size_in_bytes; + if (cur_size_in_bytes > 0x1fffff) + cur_size_in_bytes = 0x1fffff; + size_in_bytes -= cur_size_in_bytes; + tmp = upper_32_bits(src_offset) & 0xff; + if (size_in_bytes == 0) + tmp |= PACKET3_CP_DMA_CP_SYNC; + radeon_ring_write(ring, PACKET3(PACKET3_CP_DMA, 4)); + radeon_ring_write(ring, src_offset & 0xffffffff); + radeon_ring_write(ring, tmp); + radeon_ring_write(ring, dst_offset & 0xffffffff); + radeon_ring_write(ring, upper_32_bits(dst_offset) & 0xff); + radeon_ring_write(ring, cur_size_in_bytes); + src_offset += cur_size_in_bytes; + dst_offset += cur_size_in_bytes; + } + radeon_ring_write(ring, PACKET3(PACKET3_SET_CONFIG_REG, 1)); + radeon_ring_write(ring, (WAIT_UNTIL - PACKET3_SET_CONFIG_REG_OFFSET) >> 2); + radeon_ring_write(ring, WAIT_CP_DMA_IDLE_bit); + + r = radeon_fence_emit(rdev, fence, ring->idx); + if (r) { + radeon_ring_unlock_undo(rdev, ring); + return r; + } + + radeon_ring_unlock_commit(rdev, ring); + radeon_semaphore_free(rdev, &sem, *fence); + + return r; +} + /** * r600_copy_dma - copy pages using the DMA engine * diff --git a/drivers/gpu/drm/radeon/r600d.h b/drivers/gpu/drm/radeon/r600d.h index f1b3084d8f51..8e3fe815edab 100644 --- a/drivers/gpu/drm/radeon/r600d.h +++ b/drivers/gpu/drm/radeon/r600d.h @@ -602,6 +602,7 @@ #define L2_BUSY (1 << 0) #define WAIT_UNTIL 0x8040 +#define WAIT_CP_DMA_IDLE_bit (1 << 8) #define WAIT_2D_IDLE_bit (1 << 14) #define WAIT_3D_IDLE_bit (1 << 15) #define WAIT_2D_IDLECLEAN_bit (1 << 16) diff --git a/drivers/gpu/drm/radeon/radeon_asic.h b/drivers/gpu/drm/radeon/radeon_asic.h index 45d0693cddd5..b04b5789f4a8 100644 --- a/drivers/gpu/drm/radeon/radeon_asic.h +++ b/drivers/gpu/drm/radeon/radeon_asic.h @@ -340,6 +340,9 @@ int r600_uvd_ring_test(struct radeon_device *rdev, struct radeon_ring *ring); int r600_copy_blit(struct radeon_device *rdev, uint64_t src_offset, uint64_t dst_offset, unsigned num_gpu_pages, struct radeon_fence **fence); +int r600_copy_cpdma(struct radeon_device *rdev, + uint64_t src_offset, uint64_t dst_offset, + unsigned num_gpu_pages, struct radeon_fence **fence); int r600_copy_dma(struct radeon_device *rdev, uint64_t src_offset, uint64_t dst_offset, unsigned num_gpu_pages, struct radeon_fence **fence); From bfea6a6803396c6b2240bff59c0dc80420a840f3 Mon Sep 17 00:00:00 2001 From: Alex Deucher Date: Thu, 11 Jul 2013 14:53:34 -0400 Subject: [PATCH 0882/1048] drm/radeon: use CP DMA on r6xx for bo moves MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Lighter weight than using the 3D engine. Reviewed-by: Christian König Signed-off-by: Alex Deucher --- drivers/gpu/drm/radeon/radeon_asic.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/radeon/radeon_asic.c b/drivers/gpu/drm/radeon/radeon_asic.c index ea5c52b1f445..fea997e247ba 100644 --- a/drivers/gpu/drm/radeon/radeon_asic.c +++ b/drivers/gpu/drm/radeon/radeon_asic.c @@ -1026,7 +1026,7 @@ static struct radeon_asic r600_asic = { .blit_ring_index = RADEON_RING_TYPE_GFX_INDEX, .dma = &r600_copy_dma, .dma_ring_index = R600_RING_TYPE_DMA_INDEX, - .copy = &r600_copy_blit, + .copy = &r600_copy_cpdma, .copy_ring_index = RADEON_RING_TYPE_GFX_INDEX, }, .surface = { @@ -1119,7 +1119,7 @@ static struct radeon_asic rv6xx_asic = { .blit_ring_index = RADEON_RING_TYPE_GFX_INDEX, .dma = &r600_copy_dma, .dma_ring_index = R600_RING_TYPE_DMA_INDEX, - .copy = &r600_copy_blit, + .copy = &r600_copy_cpdma, .copy_ring_index = RADEON_RING_TYPE_GFX_INDEX, }, .surface = { @@ -1229,7 +1229,7 @@ static struct radeon_asic rs780_asic = { .blit_ring_index = RADEON_RING_TYPE_GFX_INDEX, .dma = &r600_copy_dma, .dma_ring_index = R600_RING_TYPE_DMA_INDEX, - .copy = &r600_copy_blit, + .copy = &r600_copy_cpdma, .copy_ring_index = RADEON_RING_TYPE_GFX_INDEX, }, .surface = { From 1b6e5fd5f4fc152064f4f71cea0bcfeb49e29b8b Mon Sep 17 00:00:00 2001 From: Maarten Lankhorst Date: Wed, 10 Jul 2013 12:26:56 +0200 Subject: [PATCH 0883/1048] drm/radeon: add missing ttm_eu_backoff_reservation to radeon_bo_list_validate Op 10-07-13 12:03, Markus Trippelsdorf schreef: > On 2013.07.10 at 11:56 +0200, Maarten Lankhorst wrote: >> Op 10-07-13 11:46, Markus Trippelsdorf schreef: >>> On 2013.07.10 at 11:29 +0200, Maarten Lankhorst wrote: >>>> Op 10-07-13 11:22, Markus Trippelsdorf schreef: >>>>> By simply copy/pasting a big document under LibreOffice my system hangs >>>>> itself up. Only a hard reset gets it working again. >>>>> see also: https://bugs.freedesktop.org/show_bug.cgi?id=66551 >>>>> >>>>> I've bisected the issue to: >>>>> >>>>> commit ecff665f5e3f1c6909353e00b9420e45ae23d995 >>>>> Author: Maarten Lankhorst >>>>> Date: Thu Jun 27 13:48:17 2013 +0200 >>>>> >>>>> drm/ttm: make ttm reservation calls behave like reservation calls >>>>> >>>>> This commit converts the source of the val_seq counter to >>>>> the ww_mutex api. The reservation objects are converted later, >>>>> because there is still a lockdep splat in nouveau that has to >>>>> resolved first. >>>>> >>>>> Signed-off-by: Maarten Lankhorst >>>>> Reviewed-by: Jerome Glisse >>>>> Signed-off-by: Dave Airlie >>>> Hey, >>>> >>>> Can you try current head with CONFIG_PROVE_LOCKING set and post the >>>> lockdep splat from dmesg, if any? If there is any locking issue >>>> lockdep should warn about it. Lockdep will turn itself off after the >>>> first splat, so if the lockdep splat happens before running the >>>> affected parts those will have to be fixed first. >>> There was an unrelated EDAC lockdep splat, so I simply disabled it. >>> >>> This is what I get: >>> >>> Jul 10 11:40:44 x4 kernel: ================================================ >>> Jul 10 11:40:44 x4 kernel: [ BUG: lock held when returning to user space! ] >>> Jul 10 11:40:44 x4 kernel: 3.10.0-08587-g496322b #35 Not tainted >>> Jul 10 11:40:44 x4 kernel: ------------------------------------------------ >>> Jul 10 11:40:44 x4 kernel: X/211 is leaving the kernel with locks still held! >>> Jul 10 11:40:44 x4 kernel: 2 locks held by X/211: >>> Jul 10 11:40:44 x4 kernel: #0: (reservation_ww_class_acquire){+.+.+.}, at: [] radeon_bo_list_validate+0x20/0xd0 >>> Jul 10 11:40:44 x4 kernel: #1: (reservation_ww_class_mutex){+.+.+.}, at: [] ttm_eu_reserve_buffers+0x126/0x4b0 >>> Jul 10 11:40:52 x4 kernel: SysRq : Emergency Sync >>> Jul 10 11:40:53 x4 kernel: Emergency Sync complete >>> >> Thanks, exactly what I thought. I missed a backoff somewhere.. >> >> Does the below patch fix it? > Yes. Thank you for your quick reply. 8<------ If radeon_cs_parser_relocs fails ttm_eu_backoff_reservation doesn't get called. This left open a bug where ttm_eu_reserve_buffers succeeded but the bo's were not unlocked afterwards: Jul 10 11:40:44 x4 kernel: ================================================ Jul 10 11:40:44 x4 kernel: [ BUG: lock held when returning to user space! ] Jul 10 11:40:44 x4 kernel: 3.10.0-08587-g496322b #35 Not tainted Jul 10 11:40:44 x4 kernel: ------------------------------------------------ Jul 10 11:40:44 x4 kernel: X/211 is leaving the kernel with locks still held! Jul 10 11:40:44 x4 kernel: 2 locks held by X/211: Jul 10 11:40:44 x4 kernel: #0: (reservation_ww_class_acquire){+.+.+.}, at: [] radeon_bo_list_validate+0x20/0xd0 Jul 10 11:40:44 x4 kernel: #1: (reservation_ww_class_mutex){+.+.+.}, at: [] ttm_eu_reserve_buffers+0x126/0x4b0 Jul 10 11:40:52 x4 kernel: SysRq : Emergency Sync Jul 10 11:40:53 x4 kernel: Emergency Sync complete This is a regression caused by commit ecff665f5e. "drm/ttm: make ttm reservation calls behave like reservation calls" Reported-by: Markus Trippelsdorf Tested-by: Markus Trippelsdorf Signed-off-by: Maarten Lankhorst Signed-off-by: Alex Deucher --- drivers/gpu/drm/radeon/radeon_object.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/gpu/drm/radeon/radeon_object.c b/drivers/gpu/drm/radeon/radeon_object.c index 0219d263e2df..2020bf4a3830 100644 --- a/drivers/gpu/drm/radeon/radeon_object.c +++ b/drivers/gpu/drm/radeon/radeon_object.c @@ -377,6 +377,7 @@ int radeon_bo_list_validate(struct ww_acquire_ctx *ticket, domain = lobj->alt_domain; goto retry; } + ttm_eu_backoff_reservation(ticket, head); return r; } } From 0a168933976eb483da91161316bbbbcb74d00486 Mon Sep 17 00:00:00 2001 From: Jerome Glisse Date: Thu, 11 Jul 2013 15:53:01 -0400 Subject: [PATCH 0884/1048] drm/radeon: use radeon device for request firmware MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Avoid creating temporary platform device that will lead to issue when several radeon gpu are in same computer. Instead directly use the radeon device for requesting firmware. Reviewed-by: Christian König Signed-off-by: Jerome Glisse Signed-off-by: Alex Deucher --- drivers/gpu/drm/radeon/cik.c | 25 +++++++------------------ drivers/gpu/drm/radeon/ni.c | 21 +++++---------------- drivers/gpu/drm/radeon/r100.c | 11 +---------- drivers/gpu/drm/radeon/r600.c | 19 ++++--------------- drivers/gpu/drm/radeon/radeon_uvd.c | 13 +------------ drivers/gpu/drm/radeon/si.c | 23 ++++++----------------- 6 files changed, 24 insertions(+), 88 deletions(-) diff --git a/drivers/gpu/drm/radeon/cik.c b/drivers/gpu/drm/radeon/cik.c index ed1d91025928..27891d87c1d3 100644 --- a/drivers/gpu/drm/radeon/cik.c +++ b/drivers/gpu/drm/radeon/cik.c @@ -22,7 +22,6 @@ * Authors: Alex Deucher */ #include -#include #include #include #include "drmP.h" @@ -742,7 +741,6 @@ static int ci_mc_load_microcode(struct radeon_device *rdev) */ static int cik_init_microcode(struct radeon_device *rdev) { - struct platform_device *pdev; const char *chip_name; size_t pfp_req_size, me_req_size, ce_req_size, mec_req_size, rlc_req_size, mc_req_size, @@ -752,13 +750,6 @@ static int cik_init_microcode(struct radeon_device *rdev) DRM_DEBUG("\n"); - pdev = platform_device_register_simple("radeon_cp", 0, NULL, 0); - err = IS_ERR(pdev); - if (err) { - printk(KERN_ERR "radeon_cp: Failed to register firmware\n"); - return -EINVAL; - } - switch (rdev->family) { case CHIP_BONAIRE: chip_name = "BONAIRE"; @@ -794,7 +785,7 @@ static int cik_init_microcode(struct radeon_device *rdev) DRM_INFO("Loading %s Microcode\n", chip_name); snprintf(fw_name, sizeof(fw_name), "radeon/%s_pfp.bin", chip_name); - err = request_firmware(&rdev->pfp_fw, fw_name, &pdev->dev); + err = request_firmware(&rdev->pfp_fw, fw_name, rdev->dev); if (err) goto out; if (rdev->pfp_fw->size != pfp_req_size) { @@ -806,7 +797,7 @@ static int cik_init_microcode(struct radeon_device *rdev) } snprintf(fw_name, sizeof(fw_name), "radeon/%s_me.bin", chip_name); - err = request_firmware(&rdev->me_fw, fw_name, &pdev->dev); + err = request_firmware(&rdev->me_fw, fw_name, rdev->dev); if (err) goto out; if (rdev->me_fw->size != me_req_size) { @@ -817,7 +808,7 @@ static int cik_init_microcode(struct radeon_device *rdev) } snprintf(fw_name, sizeof(fw_name), "radeon/%s_ce.bin", chip_name); - err = request_firmware(&rdev->ce_fw, fw_name, &pdev->dev); + err = request_firmware(&rdev->ce_fw, fw_name, rdev->dev); if (err) goto out; if (rdev->ce_fw->size != ce_req_size) { @@ -828,7 +819,7 @@ static int cik_init_microcode(struct radeon_device *rdev) } snprintf(fw_name, sizeof(fw_name), "radeon/%s_mec.bin", chip_name); - err = request_firmware(&rdev->mec_fw, fw_name, &pdev->dev); + err = request_firmware(&rdev->mec_fw, fw_name, rdev->dev); if (err) goto out; if (rdev->mec_fw->size != mec_req_size) { @@ -839,7 +830,7 @@ static int cik_init_microcode(struct radeon_device *rdev) } snprintf(fw_name, sizeof(fw_name), "radeon/%s_rlc.bin", chip_name); - err = request_firmware(&rdev->rlc_fw, fw_name, &pdev->dev); + err = request_firmware(&rdev->rlc_fw, fw_name, rdev->dev); if (err) goto out; if (rdev->rlc_fw->size != rlc_req_size) { @@ -850,7 +841,7 @@ static int cik_init_microcode(struct radeon_device *rdev) } snprintf(fw_name, sizeof(fw_name), "radeon/%s_sdma.bin", chip_name); - err = request_firmware(&rdev->sdma_fw, fw_name, &pdev->dev); + err = request_firmware(&rdev->sdma_fw, fw_name, rdev->dev); if (err) goto out; if (rdev->sdma_fw->size != sdma_req_size) { @@ -863,7 +854,7 @@ static int cik_init_microcode(struct radeon_device *rdev) /* No MC ucode on APUs */ if (!(rdev->flags & RADEON_IS_IGP)) { snprintf(fw_name, sizeof(fw_name), "radeon/%s_mc.bin", chip_name); - err = request_firmware(&rdev->mc_fw, fw_name, &pdev->dev); + err = request_firmware(&rdev->mc_fw, fw_name, rdev->dev); if (err) goto out; if (rdev->mc_fw->size != mc_req_size) { @@ -875,8 +866,6 @@ static int cik_init_microcode(struct radeon_device *rdev) } out: - platform_device_unregister(pdev); - if (err) { if (err != -EINVAL) printk(KERN_ERR diff --git a/drivers/gpu/drm/radeon/ni.c b/drivers/gpu/drm/radeon/ni.c index f30127cb30ef..465b17e1fa4e 100644 --- a/drivers/gpu/drm/radeon/ni.c +++ b/drivers/gpu/drm/radeon/ni.c @@ -22,7 +22,6 @@ * Authors: Alex Deucher */ #include -#include #include #include #include @@ -684,7 +683,6 @@ int ni_mc_load_microcode(struct radeon_device *rdev) int ni_init_microcode(struct radeon_device *rdev) { - struct platform_device *pdev; const char *chip_name; const char *rlc_chip_name; size_t pfp_req_size, me_req_size, rlc_req_size, mc_req_size; @@ -694,13 +692,6 @@ int ni_init_microcode(struct radeon_device *rdev) DRM_DEBUG("\n"); - pdev = platform_device_register_simple("radeon_cp", 0, NULL, 0); - err = IS_ERR(pdev); - if (err) { - printk(KERN_ERR "radeon_cp: Failed to register firmware\n"); - return -EINVAL; - } - switch (rdev->family) { case CHIP_BARTS: chip_name = "BARTS"; @@ -753,7 +744,7 @@ int ni_init_microcode(struct radeon_device *rdev) DRM_INFO("Loading %s Microcode\n", chip_name); snprintf(fw_name, sizeof(fw_name), "radeon/%s_pfp.bin", chip_name); - err = request_firmware(&rdev->pfp_fw, fw_name, &pdev->dev); + err = request_firmware(&rdev->pfp_fw, fw_name, rdev->dev); if (err) goto out; if (rdev->pfp_fw->size != pfp_req_size) { @@ -765,7 +756,7 @@ int ni_init_microcode(struct radeon_device *rdev) } snprintf(fw_name, sizeof(fw_name), "radeon/%s_me.bin", chip_name); - err = request_firmware(&rdev->me_fw, fw_name, &pdev->dev); + err = request_firmware(&rdev->me_fw, fw_name, rdev->dev); if (err) goto out; if (rdev->me_fw->size != me_req_size) { @@ -776,7 +767,7 @@ int ni_init_microcode(struct radeon_device *rdev) } snprintf(fw_name, sizeof(fw_name), "radeon/%s_rlc.bin", rlc_chip_name); - err = request_firmware(&rdev->rlc_fw, fw_name, &pdev->dev); + err = request_firmware(&rdev->rlc_fw, fw_name, rdev->dev); if (err) goto out; if (rdev->rlc_fw->size != rlc_req_size) { @@ -789,7 +780,7 @@ int ni_init_microcode(struct radeon_device *rdev) /* no MC ucode on TN */ if (!(rdev->flags & RADEON_IS_IGP)) { snprintf(fw_name, sizeof(fw_name), "radeon/%s_mc.bin", chip_name); - err = request_firmware(&rdev->mc_fw, fw_name, &pdev->dev); + err = request_firmware(&rdev->mc_fw, fw_name, rdev->dev); if (err) goto out; if (rdev->mc_fw->size != mc_req_size) { @@ -802,7 +793,7 @@ int ni_init_microcode(struct radeon_device *rdev) if ((rdev->family >= CHIP_BARTS) && (rdev->family <= CHIP_CAYMAN)) { snprintf(fw_name, sizeof(fw_name), "radeon/%s_smc.bin", chip_name); - err = request_firmware(&rdev->smc_fw, fw_name, &pdev->dev); + err = request_firmware(&rdev->smc_fw, fw_name, rdev->dev); if (err) goto out; if (rdev->smc_fw->size != smc_req_size) { @@ -814,8 +805,6 @@ int ni_init_microcode(struct radeon_device *rdev) } out: - platform_device_unregister(pdev); - if (err) { if (err != -EINVAL) printk(KERN_ERR diff --git a/drivers/gpu/drm/radeon/r100.c b/drivers/gpu/drm/radeon/r100.c index c9affefd79f6..75349cdaa84b 100644 --- a/drivers/gpu/drm/radeon/r100.c +++ b/drivers/gpu/drm/radeon/r100.c @@ -39,7 +39,6 @@ #include "atom.h" #include -#include #include #include "r100_reg_safe.h" @@ -989,18 +988,11 @@ void r100_ring_start(struct radeon_device *rdev, struct radeon_ring *ring) /* Load the microcode for the CP */ static int r100_cp_init_microcode(struct radeon_device *rdev) { - struct platform_device *pdev; const char *fw_name = NULL; int err; DRM_DEBUG_KMS("\n"); - pdev = platform_device_register_simple("radeon_cp", 0, NULL, 0); - err = IS_ERR(pdev); - if (err) { - printk(KERN_ERR "radeon_cp: Failed to register firmware\n"); - return -EINVAL; - } if ((rdev->family == CHIP_R100) || (rdev->family == CHIP_RV100) || (rdev->family == CHIP_RV200) || (rdev->family == CHIP_RS100) || (rdev->family == CHIP_RS200)) { @@ -1042,8 +1034,7 @@ static int r100_cp_init_microcode(struct radeon_device *rdev) fw_name = FIRMWARE_R520; } - err = request_firmware(&rdev->me_fw, fw_name, &pdev->dev); - platform_device_unregister(pdev); + err = request_firmware(&rdev->me_fw, fw_name, rdev->dev); if (err) { printk(KERN_ERR "radeon_cp: Failed to load firmware \"%s\"\n", fw_name); diff --git a/drivers/gpu/drm/radeon/r600.c b/drivers/gpu/drm/radeon/r600.c index f7d494f264a5..4982cd8ce8b7 100644 --- a/drivers/gpu/drm/radeon/r600.c +++ b/drivers/gpu/drm/radeon/r600.c @@ -28,7 +28,6 @@ #include #include #include -#include #include #include #include @@ -2144,7 +2143,6 @@ void r600_cp_stop(struct radeon_device *rdev) int r600_init_microcode(struct radeon_device *rdev) { - struct platform_device *pdev; const char *chip_name; const char *rlc_chip_name; const char *smc_chip_name = "RV770"; @@ -2154,13 +2152,6 @@ int r600_init_microcode(struct radeon_device *rdev) DRM_DEBUG("\n"); - pdev = platform_device_register_simple("radeon_cp", 0, NULL, 0); - err = IS_ERR(pdev); - if (err) { - printk(KERN_ERR "radeon_cp: Failed to register firmware\n"); - return -EINVAL; - } - switch (rdev->family) { case CHIP_R600: chip_name = "R600"; @@ -2272,7 +2263,7 @@ int r600_init_microcode(struct radeon_device *rdev) DRM_INFO("Loading %s Microcode\n", chip_name); snprintf(fw_name, sizeof(fw_name), "radeon/%s_pfp.bin", chip_name); - err = request_firmware(&rdev->pfp_fw, fw_name, &pdev->dev); + err = request_firmware(&rdev->pfp_fw, fw_name, rdev->dev); if (err) goto out; if (rdev->pfp_fw->size != pfp_req_size) { @@ -2284,7 +2275,7 @@ int r600_init_microcode(struct radeon_device *rdev) } snprintf(fw_name, sizeof(fw_name), "radeon/%s_me.bin", chip_name); - err = request_firmware(&rdev->me_fw, fw_name, &pdev->dev); + err = request_firmware(&rdev->me_fw, fw_name, rdev->dev); if (err) goto out; if (rdev->me_fw->size != me_req_size) { @@ -2295,7 +2286,7 @@ int r600_init_microcode(struct radeon_device *rdev) } snprintf(fw_name, sizeof(fw_name), "radeon/%s_rlc.bin", rlc_chip_name); - err = request_firmware(&rdev->rlc_fw, fw_name, &pdev->dev); + err = request_firmware(&rdev->rlc_fw, fw_name, rdev->dev); if (err) goto out; if (rdev->rlc_fw->size != rlc_req_size) { @@ -2307,7 +2298,7 @@ int r600_init_microcode(struct radeon_device *rdev) if ((rdev->family >= CHIP_RV770) && (rdev->family <= CHIP_HEMLOCK)) { snprintf(fw_name, sizeof(fw_name), "radeon/%s_smc.bin", smc_chip_name); - err = request_firmware(&rdev->smc_fw, fw_name, &pdev->dev); + err = request_firmware(&rdev->smc_fw, fw_name, rdev->dev); if (err) goto out; if (rdev->smc_fw->size != smc_req_size) { @@ -2319,8 +2310,6 @@ int r600_init_microcode(struct radeon_device *rdev) } out: - platform_device_unregister(pdev); - if (err) { if (err != -EINVAL) printk(KERN_ERR diff --git a/drivers/gpu/drm/radeon/radeon_uvd.c b/drivers/gpu/drm/radeon/radeon_uvd.c index 41efcec28cd8..34444f62803f 100644 --- a/drivers/gpu/drm/radeon/radeon_uvd.c +++ b/drivers/gpu/drm/radeon/radeon_uvd.c @@ -56,20 +56,12 @@ static void radeon_uvd_idle_work_handler(struct work_struct *work); int radeon_uvd_init(struct radeon_device *rdev) { - struct platform_device *pdev; unsigned long bo_size; const char *fw_name; int i, r; INIT_DELAYED_WORK(&rdev->uvd.idle_work, radeon_uvd_idle_work_handler); - pdev = platform_device_register_simple("radeon_uvd", 0, NULL, 0); - r = IS_ERR(pdev); - if (r) { - dev_err(rdev->dev, "radeon_uvd: Failed to register firmware\n"); - return -EINVAL; - } - switch (rdev->family) { case CHIP_RV710: case CHIP_RV730: @@ -112,16 +104,13 @@ int radeon_uvd_init(struct radeon_device *rdev) return -EINVAL; } - r = request_firmware(&rdev->uvd_fw, fw_name, &pdev->dev); + r = request_firmware(&rdev->uvd_fw, fw_name, rdev->dev); if (r) { dev_err(rdev->dev, "radeon_uvd: Can't load firmware \"%s\"\n", fw_name); - platform_device_unregister(pdev); return r; } - platform_device_unregister(pdev); - bo_size = RADEON_GPU_PAGE_ALIGN(rdev->uvd_fw->size + 8) + RADEON_UVD_STACK_SIZE + RADEON_UVD_HEAP_SIZE; r = radeon_bo_create(rdev, bo_size, PAGE_SIZE, true, diff --git a/drivers/gpu/drm/radeon/si.c b/drivers/gpu/drm/radeon/si.c index 234906709067..f305768c3dfa 100644 --- a/drivers/gpu/drm/radeon/si.c +++ b/drivers/gpu/drm/radeon/si.c @@ -22,7 +22,6 @@ * Authors: Alex Deucher */ #include -#include #include #include #include @@ -1541,7 +1540,6 @@ static int si_mc_load_microcode(struct radeon_device *rdev) static int si_init_microcode(struct radeon_device *rdev) { - struct platform_device *pdev; const char *chip_name; const char *rlc_chip_name; size_t pfp_req_size, me_req_size, ce_req_size, rlc_req_size, mc_req_size; @@ -1551,13 +1549,6 @@ static int si_init_microcode(struct radeon_device *rdev) DRM_DEBUG("\n"); - pdev = platform_device_register_simple("radeon_cp", 0, NULL, 0); - err = IS_ERR(pdev); - if (err) { - printk(KERN_ERR "radeon_cp: Failed to register firmware\n"); - return -EINVAL; - } - switch (rdev->family) { case CHIP_TAHITI: chip_name = "TAHITI"; @@ -1615,7 +1606,7 @@ static int si_init_microcode(struct radeon_device *rdev) DRM_INFO("Loading %s Microcode\n", chip_name); snprintf(fw_name, sizeof(fw_name), "radeon/%s_pfp.bin", chip_name); - err = request_firmware(&rdev->pfp_fw, fw_name, &pdev->dev); + err = request_firmware(&rdev->pfp_fw, fw_name, rdev->dev); if (err) goto out; if (rdev->pfp_fw->size != pfp_req_size) { @@ -1627,7 +1618,7 @@ static int si_init_microcode(struct radeon_device *rdev) } snprintf(fw_name, sizeof(fw_name), "radeon/%s_me.bin", chip_name); - err = request_firmware(&rdev->me_fw, fw_name, &pdev->dev); + err = request_firmware(&rdev->me_fw, fw_name, rdev->dev); if (err) goto out; if (rdev->me_fw->size != me_req_size) { @@ -1638,7 +1629,7 @@ static int si_init_microcode(struct radeon_device *rdev) } snprintf(fw_name, sizeof(fw_name), "radeon/%s_ce.bin", chip_name); - err = request_firmware(&rdev->ce_fw, fw_name, &pdev->dev); + err = request_firmware(&rdev->ce_fw, fw_name, rdev->dev); if (err) goto out; if (rdev->ce_fw->size != ce_req_size) { @@ -1649,7 +1640,7 @@ static int si_init_microcode(struct radeon_device *rdev) } snprintf(fw_name, sizeof(fw_name), "radeon/%s_rlc.bin", rlc_chip_name); - err = request_firmware(&rdev->rlc_fw, fw_name, &pdev->dev); + err = request_firmware(&rdev->rlc_fw, fw_name, rdev->dev); if (err) goto out; if (rdev->rlc_fw->size != rlc_req_size) { @@ -1660,7 +1651,7 @@ static int si_init_microcode(struct radeon_device *rdev) } snprintf(fw_name, sizeof(fw_name), "radeon/%s_mc.bin", chip_name); - err = request_firmware(&rdev->mc_fw, fw_name, &pdev->dev); + err = request_firmware(&rdev->mc_fw, fw_name, rdev->dev); if (err) goto out; if (rdev->mc_fw->size != mc_req_size) { @@ -1671,7 +1662,7 @@ static int si_init_microcode(struct radeon_device *rdev) } snprintf(fw_name, sizeof(fw_name), "radeon/%s_smc.bin", chip_name); - err = request_firmware(&rdev->smc_fw, fw_name, &pdev->dev); + err = request_firmware(&rdev->smc_fw, fw_name, rdev->dev); if (err) goto out; if (rdev->smc_fw->size != smc_req_size) { @@ -1682,8 +1673,6 @@ static int si_init_microcode(struct radeon_device *rdev) } out: - platform_device_unregister(pdev); - if (err) { if (err != -EINVAL) printk(KERN_ERR From 54e2e49ce28ff7ac67b93e7e9e44702552b04a69 Mon Sep 17 00:00:00 2001 From: Alex Deucher Date: Thu, 13 Jun 2013 18:26:25 -0400 Subject: [PATCH 0885/1048] drm/radeon: add fault decode function for cayman/TN (v2) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Helpful for debugging GPUVM errors as we can see what hw block and page generated the fault in the log. v2: simplify fault decoding Signed-off-by: Alex Deucher Reviewed-by: Christian König --- drivers/gpu/drm/radeon/evergreen.c | 10 +- drivers/gpu/drm/radeon/ni.c | 161 +++++++++++++++++++++++++++++ drivers/gpu/drm/radeon/nid.h | 16 +++ 3 files changed, 185 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/radeon/evergreen.c b/drivers/gpu/drm/radeon/evergreen.c index e49059dc9b8f..526e428cb4d0 100644 --- a/drivers/gpu/drm/radeon/evergreen.c +++ b/drivers/gpu/drm/radeon/evergreen.c @@ -139,6 +139,8 @@ void evergreen_pcie_gen2_enable(struct radeon_device *rdev); void evergreen_program_aspm(struct radeon_device *rdev); extern void cayman_cp_int_cntl_setup(struct radeon_device *rdev, int ring, u32 cp_int_cntl); +extern void cayman_vm_decode_fault(struct radeon_device *rdev, + u32 status, u32 addr); static const u32 evergreen_golden_registers[] = { @@ -4586,6 +4588,7 @@ int evergreen_irq_process(struct radeon_device *rdev) bool queue_hotplug = false; bool queue_hdmi = false; bool queue_thermal = false; + u32 status, addr; if (!rdev->ih.enabled || rdev->shutdown) return IRQ_NONE; @@ -4872,11 +4875,14 @@ restart_ih: break; case 146: case 147: + addr = RREG32(VM_CONTEXT1_PROTECTION_FAULT_ADDR); + status = RREG32(VM_CONTEXT1_PROTECTION_FAULT_STATUS); dev_err(rdev->dev, "GPU fault detected: %d 0x%08x\n", src_id, src_data); dev_err(rdev->dev, " VM_CONTEXT1_PROTECTION_FAULT_ADDR 0x%08X\n", - RREG32(VM_CONTEXT1_PROTECTION_FAULT_ADDR)); + addr); dev_err(rdev->dev, " VM_CONTEXT1_PROTECTION_FAULT_STATUS 0x%08X\n", - RREG32(VM_CONTEXT1_PROTECTION_FAULT_STATUS)); + status); + cayman_vm_decode_fault(rdev, status, addr); /* reset addr and status */ WREG32_P(VM_CONTEXT1_CNTL2, 1, ~1); break; diff --git a/drivers/gpu/drm/radeon/ni.c b/drivers/gpu/drm/radeon/ni.c index 465b17e1fa4e..56bd4f3be4fe 100644 --- a/drivers/gpu/drm/radeon/ni.c +++ b/drivers/gpu/drm/radeon/ni.c @@ -2450,6 +2450,167 @@ void cayman_vm_fini(struct radeon_device *rdev) { } +/** + * cayman_vm_decode_fault - print human readable fault info + * + * @rdev: radeon_device pointer + * @status: VM_CONTEXT1_PROTECTION_FAULT_STATUS register value + * @addr: VM_CONTEXT1_PROTECTION_FAULT_ADDR register value + * + * Print human readable fault information (cayman/TN). + */ +void cayman_vm_decode_fault(struct radeon_device *rdev, + u32 status, u32 addr) +{ + u32 mc_id = (status & MEMORY_CLIENT_ID_MASK) >> MEMORY_CLIENT_ID_SHIFT; + u32 vmid = (status & FAULT_VMID_MASK) >> FAULT_VMID_SHIFT; + u32 protections = (status & PROTECTIONS_MASK) >> PROTECTIONS_SHIFT; + char *block; + + switch (mc_id) { + case 32: + case 16: + case 96: + case 80: + case 160: + case 144: + case 224: + case 208: + block = "CB"; + break; + case 33: + case 17: + case 97: + case 81: + case 161: + case 145: + case 225: + case 209: + block = "CB_FMASK"; + break; + case 34: + case 18: + case 98: + case 82: + case 162: + case 146: + case 226: + case 210: + block = "CB_CMASK"; + break; + case 35: + case 19: + case 99: + case 83: + case 163: + case 147: + case 227: + case 211: + block = "CB_IMMED"; + break; + case 36: + case 20: + case 100: + case 84: + case 164: + case 148: + case 228: + case 212: + block = "DB"; + break; + case 37: + case 21: + case 101: + case 85: + case 165: + case 149: + case 229: + case 213: + block = "DB_HTILE"; + break; + case 38: + case 22: + case 102: + case 86: + case 166: + case 150: + case 230: + case 214: + block = "SX"; + break; + case 39: + case 23: + case 103: + case 87: + case 167: + case 151: + case 231: + case 215: + block = "DB_STEN"; + break; + case 40: + case 24: + case 104: + case 88: + case 232: + case 216: + case 168: + case 152: + block = "TC_TFETCH"; + break; + case 41: + case 25: + case 105: + case 89: + case 233: + case 217: + case 169: + case 153: + block = "TC_VFETCH"; + break; + case 42: + case 26: + case 106: + case 90: + case 234: + case 218: + case 170: + case 154: + block = "VC"; + break; + case 112: + block = "CP"; + break; + case 113: + case 114: + block = "SH"; + break; + case 115: + block = "VGT"; + break; + case 178: + block = "IH"; + break; + case 51: + block = "RLC"; + break; + case 55: + block = "DMA"; + break; + case 56: + block = "HDP"; + break; + default: + block = "unknown"; + break; + } + + printk("VM fault (0x%02x, vmid %d) at page %u, %s from %s (%d)\n", + protections, vmid, addr, + (status & MEMORY_CLIENT_RW_MASK) ? "write" : "read", + block, mc_id); +} + #define R600_ENTRY_VALID (1 << 0) #define R600_PTE_SYSTEM (1 << 1) #define R600_PTE_SNOOPED (1 << 2) diff --git a/drivers/gpu/drm/radeon/nid.h b/drivers/gpu/drm/radeon/nid.h index fe24a93542ec..22421bc80c0d 100644 --- a/drivers/gpu/drm/radeon/nid.h +++ b/drivers/gpu/drm/radeon/nid.h @@ -133,6 +133,22 @@ #define VM_CONTEXT1_CNTL2 0x1434 #define VM_INVALIDATE_REQUEST 0x1478 #define VM_INVALIDATE_RESPONSE 0x147c +#define VM_CONTEXT1_PROTECTION_FAULT_ADDR 0x14FC +#define VM_CONTEXT1_PROTECTION_FAULT_STATUS 0x14DC +#define PROTECTIONS_MASK (0xf << 0) +#define PROTECTIONS_SHIFT 0 + /* bit 0: range + * bit 2: pde0 + * bit 3: valid + * bit 4: read + * bit 5: write + */ +#define MEMORY_CLIENT_ID_MASK (0xff << 12) +#define MEMORY_CLIENT_ID_SHIFT 12 +#define MEMORY_CLIENT_RW_MASK (1 << 24) +#define MEMORY_CLIENT_RW_SHIFT 24 +#define FAULT_VMID_MASK (0x7 << 25) +#define FAULT_VMID_SHIFT 25 #define VM_CONTEXT0_PROTECTION_FAULT_DEFAULT_ADDR 0x1518 #define VM_CONTEXT1_PROTECTION_FAULT_DEFAULT_ADDR 0x151c #define VM_CONTEXT0_PAGE_TABLE_BASE_ADDR 0x153C From fbf6dc7ac7291841f53367d461a01a8e8bad0369 Mon Sep 17 00:00:00 2001 From: Alex Deucher Date: Thu, 13 Jun 2013 18:47:58 -0400 Subject: [PATCH 0886/1048] drm/radeon: add fault decode function for SI (v2) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Helpful for debugging GPUVM errors as we can see what hw block and page generated the fault in the log. v2: simplify fault decoding Signed-off-by: Alex Deucher Reviewed-by: Christian König --- drivers/gpu/drm/radeon/si.c | 272 ++++++++++++++++++++++++++++++++++- drivers/gpu/drm/radeon/sid.h | 14 ++ 2 files changed, 284 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/radeon/si.c b/drivers/gpu/drm/radeon/si.c index f305768c3dfa..d3f05076f385 100644 --- a/drivers/gpu/drm/radeon/si.c +++ b/drivers/gpu/drm/radeon/si.c @@ -4389,6 +4389,270 @@ void si_vm_fini(struct radeon_device *rdev) { } +/** + * si_vm_decode_fault - print human readable fault info + * + * @rdev: radeon_device pointer + * @status: VM_CONTEXT1_PROTECTION_FAULT_STATUS register value + * @addr: VM_CONTEXT1_PROTECTION_FAULT_ADDR register value + * + * Print human readable fault information (SI). + */ +static void si_vm_decode_fault(struct radeon_device *rdev, + u32 status, u32 addr) +{ + u32 mc_id = (status & MEMORY_CLIENT_ID_MASK) >> MEMORY_CLIENT_ID_SHIFT; + u32 vmid = (status & FAULT_VMID_MASK) >> FAULT_VMID_SHIFT; + u32 protections = (status & PROTECTIONS_MASK) >> PROTECTIONS_SHIFT; + char *block; + + if (rdev->family == CHIP_TAHITI) { + switch (mc_id) { + case 160: + case 144: + case 96: + case 80: + case 224: + case 208: + case 32: + case 16: + block = "CB"; + break; + case 161: + case 145: + case 97: + case 81: + case 225: + case 209: + case 33: + case 17: + block = "CB_FMASK"; + break; + case 162: + case 146: + case 98: + case 82: + case 226: + case 210: + case 34: + case 18: + block = "CB_CMASK"; + break; + case 163: + case 147: + case 99: + case 83: + case 227: + case 211: + case 35: + case 19: + block = "CB_IMMED"; + break; + case 164: + case 148: + case 100: + case 84: + case 228: + case 212: + case 36: + case 20: + block = "DB"; + break; + case 165: + case 149: + case 101: + case 85: + case 229: + case 213: + case 37: + case 21: + block = "DB_HTILE"; + break; + case 167: + case 151: + case 103: + case 87: + case 231: + case 215: + case 39: + case 23: + block = "DB_STEN"; + break; + case 72: + case 68: + case 64: + case 8: + case 4: + case 0: + case 136: + case 132: + case 128: + case 200: + case 196: + case 192: + block = "TC"; + break; + case 112: + case 48: + block = "CP"; + break; + case 49: + case 177: + case 50: + case 178: + block = "SH"; + break; + case 53: + case 190: + block = "VGT"; + break; + case 117: + block = "IH"; + break; + case 51: + case 115: + block = "RLC"; + break; + case 119: + case 183: + block = "DMA0"; + break; + case 61: + block = "DMA1"; + break; + case 248: + case 120: + block = "HDP"; + break; + default: + block = "unknown"; + break; + } + } else { + switch (mc_id) { + case 32: + case 16: + case 96: + case 80: + case 160: + case 144: + case 224: + case 208: + block = "CB"; + break; + case 33: + case 17: + case 97: + case 81: + case 161: + case 145: + case 225: + case 209: + block = "CB_FMASK"; + break; + case 34: + case 18: + case 98: + case 82: + case 162: + case 146: + case 226: + case 210: + block = "CB_CMASK"; + break; + case 35: + case 19: + case 99: + case 83: + case 163: + case 147: + case 227: + case 211: + block = "CB_IMMED"; + break; + case 36: + case 20: + case 100: + case 84: + case 164: + case 148: + case 228: + case 212: + block = "DB"; + break; + case 37: + case 21: + case 101: + case 85: + case 165: + case 149: + case 229: + case 213: + block = "DB_HTILE"; + break; + case 39: + case 23: + case 103: + case 87: + case 167: + case 151: + case 231: + case 215: + block = "DB_STEN"; + break; + case 72: + case 68: + case 8: + case 4: + case 136: + case 132: + case 200: + case 196: + block = "TC"; + break; + case 112: + case 48: + block = "CP"; + break; + case 49: + case 177: + case 50: + case 178: + block = "SH"; + break; + case 53: + block = "VGT"; + break; + case 117: + block = "IH"; + break; + case 51: + case 115: + block = "RLC"; + break; + case 119: + case 183: + block = "DMA0"; + break; + case 61: + block = "DMA1"; + break; + case 248: + case 120: + block = "HDP"; + break; + default: + block = "unknown"; + break; + } + } + + printk("VM fault (0x%02x, vmid %d) at page %u, %s from %s (%d)\n", + protections, vmid, addr, + (status & MEMORY_CLIENT_RW_MASK) ? "write" : "read", + block, mc_id); +} + /** * si_vm_set_page - update the page tables using the CP * @@ -5755,6 +6019,7 @@ int si_irq_process(struct radeon_device *rdev) u32 ring_index; bool queue_hotplug = false; bool queue_thermal = false; + u32 status, addr; if (!rdev->ih.enabled || rdev->shutdown) return IRQ_NONE; @@ -5990,11 +6255,14 @@ restart_ih: break; case 146: case 147: + addr = RREG32(VM_CONTEXT1_PROTECTION_FAULT_ADDR); + status = RREG32(VM_CONTEXT1_PROTECTION_FAULT_STATUS); dev_err(rdev->dev, "GPU fault detected: %d 0x%08x\n", src_id, src_data); dev_err(rdev->dev, " VM_CONTEXT1_PROTECTION_FAULT_ADDR 0x%08X\n", - RREG32(VM_CONTEXT1_PROTECTION_FAULT_ADDR)); + addr); dev_err(rdev->dev, " VM_CONTEXT1_PROTECTION_FAULT_STATUS 0x%08X\n", - RREG32(VM_CONTEXT1_PROTECTION_FAULT_STATUS)); + status); + si_vm_decode_fault(rdev, status, addr); /* reset addr and status */ WREG32_P(VM_CONTEXT1_CNTL2, 1, ~1); break; diff --git a/drivers/gpu/drm/radeon/sid.h b/drivers/gpu/drm/radeon/sid.h index 12a20eb77d0c..2c8da27a929f 100644 --- a/drivers/gpu/drm/radeon/sid.h +++ b/drivers/gpu/drm/radeon/sid.h @@ -367,6 +367,20 @@ #define VM_CONTEXT1_PROTECTION_FAULT_ADDR 0x14FC #define VM_CONTEXT1_PROTECTION_FAULT_STATUS 0x14DC +#define PROTECTIONS_MASK (0xf << 0) +#define PROTECTIONS_SHIFT 0 + /* bit 0: range + * bit 1: pde0 + * bit 2: valid + * bit 3: read + * bit 4: write + */ +#define MEMORY_CLIENT_ID_MASK (0xff << 12) +#define MEMORY_CLIENT_ID_SHIFT 12 +#define MEMORY_CLIENT_RW_MASK (1 << 24) +#define MEMORY_CLIENT_RW_SHIFT 24 +#define FAULT_VMID_MASK (0xf << 25) +#define FAULT_VMID_SHIFT 25 #define VM_INVALIDATE_REQUEST 0x1478 #define VM_INVALIDATE_RESPONSE 0x147c From 3ec7d11b9a8f280cd68e53d4a7877624cc002e43 Mon Sep 17 00:00:00 2001 From: Alex Deucher Date: Fri, 14 Jun 2013 10:42:22 -0400 Subject: [PATCH 0887/1048] drm/radeon: add fault decode function for CIK Helpful for debugging GPUVM errors as we can see what hw block and page generated the fault in the log. Signed-off-by: Alex Deucher --- drivers/gpu/drm/radeon/cik.c | 32 ++++++++++++++++++++++++++++++-- drivers/gpu/drm/radeon/cikd.h | 16 ++++++++++++++++ 2 files changed, 46 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/radeon/cik.c b/drivers/gpu/drm/radeon/cik.c index 27891d87c1d3..68b4fc599e03 100644 --- a/drivers/gpu/drm/radeon/cik.c +++ b/drivers/gpu/drm/radeon/cik.c @@ -4441,6 +4441,29 @@ void cik_vm_fini(struct radeon_device *rdev) { } +/** + * cik_vm_decode_fault - print human readable fault info + * + * @rdev: radeon_device pointer + * @status: VM_CONTEXT1_PROTECTION_FAULT_STATUS register value + * @addr: VM_CONTEXT1_PROTECTION_FAULT_ADDR register value + * + * Print human readable fault information (CIK). + */ +static void cik_vm_decode_fault(struct radeon_device *rdev, + u32 status, u32 addr, u32 mc_client) +{ + u32 mc_id = (status & MEMORY_CLIENT_ID_MASK) >> MEMORY_CLIENT_ID_SHIFT; + u32 vmid = (status & FAULT_VMID_MASK) >> FAULT_VMID_SHIFT; + u32 protections = (status & PROTECTIONS_MASK) >> PROTECTIONS_SHIFT; + char *block = (char *)&mc_client; + + printk("VM fault (0x%02x, vmid %d) at page %u, %s from %s (%d)\n", + protections, vmid, addr, + (status & MEMORY_CLIENT_RW_MASK) ? "write" : "read", + block, mc_id); +} + /** * cik_vm_flush - cik vm flush using the CP * @@ -5496,6 +5519,7 @@ int cik_irq_process(struct radeon_device *rdev) u32 ring_index; bool queue_hotplug = false; bool queue_reset = false; + u32 addr, status, mc_client; if (!rdev->ih.enabled || rdev->shutdown) return IRQ_NONE; @@ -5731,11 +5755,15 @@ restart_ih: break; case 146: case 147: + addr = RREG32(VM_CONTEXT1_PROTECTION_FAULT_ADDR); + status = RREG32(VM_CONTEXT1_PROTECTION_FAULT_STATUS); + mc_client = RREG32(VM_CONTEXT1_PROTECTION_FAULT_MCCLIENT); dev_err(rdev->dev, "GPU fault detected: %d 0x%08x\n", src_id, src_data); dev_err(rdev->dev, " VM_CONTEXT1_PROTECTION_FAULT_ADDR 0x%08X\n", - RREG32(VM_CONTEXT1_PROTECTION_FAULT_ADDR)); + addr); dev_err(rdev->dev, " VM_CONTEXT1_PROTECTION_FAULT_STATUS 0x%08X\n", - RREG32(VM_CONTEXT1_PROTECTION_FAULT_STATUS)); + status); + cik_vm_decode_fault(rdev, status, addr, mc_client); /* reset addr and status */ WREG32_P(VM_CONTEXT1_CNTL2, 1, ~1); break; diff --git a/drivers/gpu/drm/radeon/cikd.h b/drivers/gpu/drm/radeon/cikd.h index 63514b95889a..7e9275eaef80 100644 --- a/drivers/gpu/drm/radeon/cikd.h +++ b/drivers/gpu/drm/radeon/cikd.h @@ -136,6 +136,22 @@ #define VM_INVALIDATE_RESPONSE 0x147c #define VM_CONTEXT1_PROTECTION_FAULT_STATUS 0x14DC +#define PROTECTIONS_MASK (0xf << 0) +#define PROTECTIONS_SHIFT 0 + /* bit 0: range + * bit 1: pde0 + * bit 2: valid + * bit 3: read + * bit 4: write + */ +#define MEMORY_CLIENT_ID_MASK (0xff << 12) +#define MEMORY_CLIENT_ID_SHIFT 12 +#define MEMORY_CLIENT_RW_MASK (1 << 24) +#define MEMORY_CLIENT_RW_SHIFT 24 +#define FAULT_VMID_MASK (0xf << 25) +#define FAULT_VMID_SHIFT 25 + +#define VM_CONTEXT1_PROTECTION_FAULT_MCCLIENT 0x14E4 #define VM_CONTEXT1_PROTECTION_FAULT_ADDR 0x14FC From c9a6ca4abd5f1978ef15b3ece3474f4372ae5fe7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20K=C3=B6nig?= Date: Fri, 12 Jul 2013 10:05:47 +0200 Subject: [PATCH 0888/1048] drm/radeon: fix UVD fence emit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Currently doesn't matter cause we allocate the fence in the lower 265MB anyway. Reported-by: Frank Huang Signed-off-by: Christian König Signed-off-by: Alex Deucher Cc: stable@vger.kernel.org --- drivers/gpu/drm/radeon/r600.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/radeon/r600.c b/drivers/gpu/drm/radeon/r600.c index 4982cd8ce8b7..393880a09412 100644 --- a/drivers/gpu/drm/radeon/r600.c +++ b/drivers/gpu/drm/radeon/r600.c @@ -3008,7 +3008,7 @@ void r600_uvd_fence_emit(struct radeon_device *rdev, struct radeon_fence *fence) { struct radeon_ring *ring = &rdev->ring[fence->ring]; - uint32_t addr = rdev->fence_drv[fence->ring].gpu_addr; + uint64_t addr = rdev->fence_drv[fence->ring].gpu_addr; radeon_ring_write(ring, PACKET0(UVD_CONTEXT_ID, 0)); radeon_ring_write(ring, fence->seq); From 9cc2e0e9f13315559c85c9f99f141e420967c955 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20K=C3=B6nig?= Date: Fri, 12 Jul 2013 10:18:09 -0400 Subject: [PATCH 0889/1048] drm/radeon: never unpin UVD bo v3 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Changing the UVD BOs offset on suspend/resume doesn't work because the VCPU internally keeps pointers to it. Just keep it always pinned and save the content manually. Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=66425 v2: fix compiler warning v3: fix CIK support Note: a version of this patch needs to go to stable. Signed-off-by: Christian König Signed-off-by: Alex Deucher --- drivers/gpu/drm/radeon/cik.c | 2 +- drivers/gpu/drm/radeon/radeon.h | 3 +- drivers/gpu/drm/radeon/radeon_fence.c | 2 +- drivers/gpu/drm/radeon/radeon_uvd.c | 124 +++++++++++++------------- drivers/gpu/drm/radeon/rv770.c | 2 +- 5 files changed, 65 insertions(+), 68 deletions(-) diff --git a/drivers/gpu/drm/radeon/cik.c b/drivers/gpu/drm/radeon/cik.c index 68b4fc599e03..6dacec4e2090 100644 --- a/drivers/gpu/drm/radeon/cik.c +++ b/drivers/gpu/drm/radeon/cik.c @@ -6978,7 +6978,7 @@ int cik_uvd_resume(struct radeon_device *rdev) /* programm the VCPU memory controller bits 0-27 */ addr = rdev->uvd.gpu_addr >> 3; - size = RADEON_GPU_PAGE_ALIGN(rdev->uvd_fw->size + 4) >> 3; + size = RADEON_GPU_PAGE_ALIGN(rdev->uvd.fw_size + 4) >> 3; WREG32(UVD_VCPU_CACHE_OFFSET0, addr); WREG32(UVD_VCPU_CACHE_SIZE0, size); diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h index 9b7025d02cd0..7b7d23ae3f27 100644 --- a/drivers/gpu/drm/radeon/radeon.h +++ b/drivers/gpu/drm/radeon/radeon.h @@ -1460,6 +1460,8 @@ struct radeon_uvd { struct radeon_bo *vcpu_bo; void *cpu_addr; uint64_t gpu_addr; + void *saved_bo; + unsigned fw_size; atomic_t handles[RADEON_MAX_UVD_HANDLES]; struct drm_file *filp[RADEON_MAX_UVD_HANDLES]; struct delayed_work idle_work; @@ -2054,7 +2056,6 @@ struct radeon_device { const struct firmware *rlc_fw; /* r6/700 RLC firmware */ const struct firmware *mc_fw; /* NI MC firmware */ const struct firmware *ce_fw; /* SI CE firmware */ - const struct firmware *uvd_fw; /* UVD firmware */ const struct firmware *mec_fw; /* CIK MEC firmware */ const struct firmware *sdma_fw; /* CIK SDMA firmware */ const struct firmware *smc_fw; /* SMC firmware */ diff --git a/drivers/gpu/drm/radeon/radeon_fence.c b/drivers/gpu/drm/radeon/radeon_fence.c index ddb8f8e04eb5..7ddb0efe2408 100644 --- a/drivers/gpu/drm/radeon/radeon_fence.c +++ b/drivers/gpu/drm/radeon/radeon_fence.c @@ -782,7 +782,7 @@ int radeon_fence_driver_start_ring(struct radeon_device *rdev, int ring) } else { /* put fence directly behind firmware */ - index = ALIGN(rdev->uvd_fw->size, 8); + index = ALIGN(rdev->uvd.fw_size, 8); rdev->fence_drv[ring].cpu_addr = rdev->uvd.cpu_addr + index; rdev->fence_drv[ring].gpu_addr = rdev->uvd.gpu_addr + index; } diff --git a/drivers/gpu/drm/radeon/radeon_uvd.c b/drivers/gpu/drm/radeon/radeon_uvd.c index 34444f62803f..414fd145d20e 100644 --- a/drivers/gpu/drm/radeon/radeon_uvd.c +++ b/drivers/gpu/drm/radeon/radeon_uvd.c @@ -56,6 +56,7 @@ static void radeon_uvd_idle_work_handler(struct work_struct *work); int radeon_uvd_init(struct radeon_device *rdev) { + const struct firmware *fw; unsigned long bo_size; const char *fw_name; int i, r; @@ -104,14 +105,14 @@ int radeon_uvd_init(struct radeon_device *rdev) return -EINVAL; } - r = request_firmware(&rdev->uvd_fw, fw_name, rdev->dev); + r = request_firmware(&fw, fw_name, rdev->dev); if (r) { dev_err(rdev->dev, "radeon_uvd: Can't load firmware \"%s\"\n", fw_name); return r; } - bo_size = RADEON_GPU_PAGE_ALIGN(rdev->uvd_fw->size + 8) + + bo_size = RADEON_GPU_PAGE_ALIGN(fw->size + 8) + RADEON_UVD_STACK_SIZE + RADEON_UVD_HEAP_SIZE; r = radeon_bo_create(rdev, bo_size, PAGE_SIZE, true, RADEON_GEM_DOMAIN_VRAM, NULL, &rdev->uvd.vcpu_bo); @@ -120,64 +121,6 @@ int radeon_uvd_init(struct radeon_device *rdev) return r; } - r = radeon_uvd_resume(rdev); - if (r) - return r; - - memset(rdev->uvd.cpu_addr, 0, bo_size); - memcpy(rdev->uvd.cpu_addr, rdev->uvd_fw->data, rdev->uvd_fw->size); - - r = radeon_uvd_suspend(rdev); - if (r) - return r; - - for (i = 0; i < RADEON_MAX_UVD_HANDLES; ++i) { - atomic_set(&rdev->uvd.handles[i], 0); - rdev->uvd.filp[i] = NULL; - } - - return 0; -} - -void radeon_uvd_fini(struct radeon_device *rdev) -{ - radeon_uvd_suspend(rdev); - radeon_bo_unref(&rdev->uvd.vcpu_bo); -} - -int radeon_uvd_suspend(struct radeon_device *rdev) -{ - int r; - - if (rdev->uvd.vcpu_bo == NULL) - return 0; - - r = radeon_bo_reserve(rdev->uvd.vcpu_bo, false); - if (!r) { - radeon_bo_kunmap(rdev->uvd.vcpu_bo); - radeon_bo_unpin(rdev->uvd.vcpu_bo); - rdev->uvd.cpu_addr = NULL; - if (!radeon_bo_pin(rdev->uvd.vcpu_bo, RADEON_GEM_DOMAIN_CPU, NULL)) { - radeon_bo_kmap(rdev->uvd.vcpu_bo, &rdev->uvd.cpu_addr); - } - radeon_bo_unreserve(rdev->uvd.vcpu_bo); - - if (rdev->uvd.cpu_addr) { - radeon_fence_driver_start_ring(rdev, R600_RING_TYPE_UVD_INDEX); - } else { - rdev->fence_drv[R600_RING_TYPE_UVD_INDEX].cpu_addr = NULL; - } - } - return r; -} - -int radeon_uvd_resume(struct radeon_device *rdev) -{ - int r; - - if (rdev->uvd.vcpu_bo == NULL) - return -EINVAL; - r = radeon_bo_reserve(rdev->uvd.vcpu_bo, false); if (r) { radeon_bo_unref(&rdev->uvd.vcpu_bo); @@ -185,10 +128,6 @@ int radeon_uvd_resume(struct radeon_device *rdev) return r; } - /* Have been pin in cpu unmap unpin */ - radeon_bo_kunmap(rdev->uvd.vcpu_bo); - radeon_bo_unpin(rdev->uvd.vcpu_bo); - r = radeon_bo_pin(rdev->uvd.vcpu_bo, RADEON_GEM_DOMAIN_VRAM, &rdev->uvd.gpu_addr); if (r) { @@ -206,6 +145,63 @@ int radeon_uvd_resume(struct radeon_device *rdev) radeon_bo_unreserve(rdev->uvd.vcpu_bo); + rdev->uvd.fw_size = fw->size; + memset(rdev->uvd.cpu_addr, 0, bo_size); + memcpy(rdev->uvd.cpu_addr, fw->data, fw->size); + + release_firmware(fw); + + for (i = 0; i < RADEON_MAX_UVD_HANDLES; ++i) { + atomic_set(&rdev->uvd.handles[i], 0); + rdev->uvd.filp[i] = NULL; + } + + return 0; +} + +void radeon_uvd_fini(struct radeon_device *rdev) +{ + int r; + + if (rdev->uvd.vcpu_bo == NULL) + return; + + r = radeon_bo_reserve(rdev->uvd.vcpu_bo, false); + if (!r) { + radeon_bo_kunmap(rdev->uvd.vcpu_bo); + radeon_bo_unpin(rdev->uvd.vcpu_bo); + radeon_bo_unreserve(rdev->uvd.vcpu_bo); + } + + radeon_bo_unref(&rdev->uvd.vcpu_bo); +} + +int radeon_uvd_suspend(struct radeon_device *rdev) +{ + unsigned size; + + if (rdev->uvd.vcpu_bo == NULL) + return 0; + + size = radeon_bo_size(rdev->uvd.vcpu_bo); + rdev->uvd.saved_bo = kmalloc(size, GFP_KERNEL); + memcpy(rdev->uvd.saved_bo, rdev->uvd.cpu_addr, size); + + return 0; +} + +int radeon_uvd_resume(struct radeon_device *rdev) +{ + if (rdev->uvd.vcpu_bo == NULL) + return -EINVAL; + + if (rdev->uvd.saved_bo != NULL) { + unsigned size = radeon_bo_size(rdev->uvd.vcpu_bo); + memcpy(rdev->uvd.cpu_addr, rdev->uvd.saved_bo, size); + kfree(rdev->uvd.saved_bo); + rdev->uvd.saved_bo = NULL; + } + return 0; } diff --git a/drivers/gpu/drm/radeon/rv770.c b/drivers/gpu/drm/radeon/rv770.c index 4a62ad2e5399..30ea14e8854c 100644 --- a/drivers/gpu/drm/radeon/rv770.c +++ b/drivers/gpu/drm/radeon/rv770.c @@ -813,7 +813,7 @@ int rv770_uvd_resume(struct radeon_device *rdev) /* programm the VCPU memory controller bits 0-27 */ addr = rdev->uvd.gpu_addr >> 3; - size = RADEON_GPU_PAGE_ALIGN(rdev->uvd_fw->size + 4) >> 3; + size = RADEON_GPU_PAGE_ALIGN(rdev->uvd.fw_size + 4) >> 3; WREG32(UVD_VCPU_CACHE_OFFSET0, addr); WREG32(UVD_VCPU_CACHE_SIZE0, size); From 6c4f978b357bc779c703fda1f200e9179623d3e9 Mon Sep 17 00:00:00 2001 From: Alex Deucher Date: Fri, 12 Jul 2013 15:46:09 -0400 Subject: [PATCH 0890/1048] drm/radeon: allow selection of alignment in the sub-allocator There are cases where we need more than 4k alignment. No functional change with this commit. Signed-off-by: Alex Deucher Cc: stable@vger.kernel.org --- drivers/gpu/drm/radeon/radeon.h | 1 + drivers/gpu/drm/radeon/radeon_gart.c | 1 + drivers/gpu/drm/radeon/radeon_object.h | 2 +- drivers/gpu/drm/radeon/radeon_ring.c | 1 + drivers/gpu/drm/radeon/radeon_sa.c | 7 ++++--- 5 files changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h index 7b7d23ae3f27..82e8e36064e3 100644 --- a/drivers/gpu/drm/radeon/radeon.h +++ b/drivers/gpu/drm/radeon/radeon.h @@ -455,6 +455,7 @@ struct radeon_sa_manager { uint64_t gpu_addr; void *cpu_ptr; uint32_t domain; + uint32_t align; }; struct radeon_sa_bo; diff --git a/drivers/gpu/drm/radeon/radeon_gart.c b/drivers/gpu/drm/radeon/radeon_gart.c index 43ec4a401f07..5ce190b8bd1f 100644 --- a/drivers/gpu/drm/radeon/radeon_gart.c +++ b/drivers/gpu/drm/radeon/radeon_gart.c @@ -467,6 +467,7 @@ int radeon_vm_manager_init(struct radeon_device *rdev) size *= 2; r = radeon_sa_bo_manager_init(rdev, &rdev->vm_manager.sa_manager, RADEON_GPU_PAGE_ALIGN(size), + RADEON_GPU_PAGE_SIZE, RADEON_GEM_DOMAIN_VRAM); if (r) { dev_err(rdev->dev, "failed to allocate vm bo (%dKB)\n", diff --git a/drivers/gpu/drm/radeon/radeon_object.h b/drivers/gpu/drm/radeon/radeon_object.h index 91519a5622b4..49c82c480013 100644 --- a/drivers/gpu/drm/radeon/radeon_object.h +++ b/drivers/gpu/drm/radeon/radeon_object.h @@ -174,7 +174,7 @@ static inline void * radeon_sa_bo_cpu_addr(struct radeon_sa_bo *sa_bo) extern int radeon_sa_bo_manager_init(struct radeon_device *rdev, struct radeon_sa_manager *sa_manager, - unsigned size, u32 domain); + unsigned size, u32 align, u32 domain); extern void radeon_sa_bo_manager_fini(struct radeon_device *rdev, struct radeon_sa_manager *sa_manager); extern int radeon_sa_bo_manager_start(struct radeon_device *rdev, diff --git a/drivers/gpu/drm/radeon/radeon_ring.c b/drivers/gpu/drm/radeon/radeon_ring.c index 5f1c51a776ed..fb5ea6208970 100644 --- a/drivers/gpu/drm/radeon/radeon_ring.c +++ b/drivers/gpu/drm/radeon/radeon_ring.c @@ -224,6 +224,7 @@ int radeon_ib_pool_init(struct radeon_device *rdev) } r = radeon_sa_bo_manager_init(rdev, &rdev->ring_tmp_bo, RADEON_IB_POOL_SIZE*64*1024, + RADEON_GPU_PAGE_SIZE, RADEON_GEM_DOMAIN_GTT); if (r) { return r; diff --git a/drivers/gpu/drm/radeon/radeon_sa.c b/drivers/gpu/drm/radeon/radeon_sa.c index 0abe5a9431bb..f0bac68254b7 100644 --- a/drivers/gpu/drm/radeon/radeon_sa.c +++ b/drivers/gpu/drm/radeon/radeon_sa.c @@ -49,7 +49,7 @@ static void radeon_sa_bo_try_free(struct radeon_sa_manager *sa_manager); int radeon_sa_bo_manager_init(struct radeon_device *rdev, struct radeon_sa_manager *sa_manager, - unsigned size, u32 domain) + unsigned size, u32 align, u32 domain) { int i, r; @@ -57,13 +57,14 @@ int radeon_sa_bo_manager_init(struct radeon_device *rdev, sa_manager->bo = NULL; sa_manager->size = size; sa_manager->domain = domain; + sa_manager->align = align; sa_manager->hole = &sa_manager->olist; INIT_LIST_HEAD(&sa_manager->olist); for (i = 0; i < RADEON_NUM_RINGS; ++i) { INIT_LIST_HEAD(&sa_manager->flist[i]); } - r = radeon_bo_create(rdev, size, RADEON_GPU_PAGE_SIZE, true, + r = radeon_bo_create(rdev, size, align, true, domain, NULL, &sa_manager->bo); if (r) { dev_err(rdev->dev, "(%d) failed to allocate bo for manager\n", r); @@ -317,7 +318,7 @@ int radeon_sa_bo_new(struct radeon_device *rdev, unsigned tries[RADEON_NUM_RINGS]; int i, r; - BUG_ON(align > RADEON_GPU_PAGE_SIZE); + BUG_ON(align > sa_manager->align); BUG_ON(size > sa_manager->size); *sa_bo = kmalloc(sizeof(struct radeon_sa_bo), GFP_KERNEL); From c25f195e828f847735c7626b5693ddc3b853d245 Mon Sep 17 00:00:00 2001 From: Steven Rostedt Date: Thu, 17 Jan 2013 13:10:58 -0500 Subject: [PATCH 0891/1048] slub: Check for page NULL before doing the node_match check In the -rt kernel (mrg), we hit the following dump: BUG: unable to handle kernel NULL pointer dereference at (null) IP: [] kmem_cache_alloc_node+0x51/0x180 PGD a2d39067 PUD b1641067 PMD 0 Oops: 0000 [#1] PREEMPT SMP Modules linked in: sunrpc cpufreq_ondemand ipv6 tg3 joydev sg serio_raw pcspkr k8temp amd64_edac_mod edac_core i2c_piix4 e100 mii shpchp ext4 mbcache jbd2 sd_mod crc_t10dif sr_mod cdrom sata_svw ata_generic pata_acpi pata_serverworks radeon ttm drm_kms_helper drm hwmon i2c_algo_bit i2c_core dm_mirror dm_region_hash dm_log dm_mod CPU 3 Pid: 20878, comm: hackbench Not tainted 3.6.11-rt25.14.el6rt.x86_64 #1 empty empty/Tyan Transport GT24-B3992 RIP: 0010:[] [] kmem_cache_alloc_node+0x51/0x180 RSP: 0018:ffff8800a9b17d70 EFLAGS: 00010213 RAX: 0000000000000000 RBX: 0000000001200011 RCX: ffff8800a06d8000 RDX: 0000000004d92a03 RSI: 00000000000000d0 RDI: ffff88013b805500 RBP: ffff8800a9b17dc0 R08: ffff88023fd14d10 R09: ffffffff81041cbd R10: 00007f4e3f06e9d0 R11: 0000000000000246 R12: ffff88013b805500 R13: ffff8801ff46af40 R14: 0000000000000001 R15: 0000000000000000 FS: 00007f4e3f06e700(0000) GS:ffff88023fd00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 000000008005003b CR2: 0000000000000000 CR3: 00000000a2d3a000 CR4: 00000000000007e0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400 Process hackbench (pid: 20878, threadinfo ffff8800a9b16000, task ffff8800a06d8000) Stack: ffff8800a9b17da0 ffffffff81202e08 ffff8800a9b17de0 000000d001200011 0000000001200011 0000000001200011 0000000000000000 0000000000000000 00007f4e3f06e9d0 0000000000000000 ffff8800a9b17e60 ffffffff81041cbd Call Trace: [] ? current_has_perm+0x68/0x80 [] copy_process+0xdd/0x15b0 [] ? rt_up_read+0x25/0x30 [] do_fork+0x5a/0x360 [] ? migrate_enable+0xeb/0x220 [] sys_clone+0x28/0x30 [] stub_clone+0x13/0x20 [] ? system_call_fastpath+0x16/0x1b Code: 89 fc 89 75 cc 41 89 d6 4d 8b 04 24 65 4c 03 04 25 48 ae 00 00 49 8b 50 08 4d 8b 28 49 8b 40 10 4d 85 ed 74 12 41 83 fe ff 74 27 <48> 8b 00 48 c1 e8 3a 41 39 c6 74 1b 8b 75 cc 4c 89 c9 44 89 f2 RIP [] kmem_cache_alloc_node+0x51/0x180 RSP CR2: 0000000000000000 ---[ end trace 0000000000000002 ]--- Now, this uses SLUB pretty much unmodified, but as it is the -rt kernel with CONFIG_PREEMPT_RT set, spinlocks are mutexes, although they do disable migration. But the SLUB code is relatively lockless, and the spin_locks there are raw_spin_locks (not converted to mutexes), thus I believe this bug can happen in mainline without -rt features. The -rt patch is just good at triggering mainline bugs ;-) Anyway, looking at where this crashed, it seems that the page variable can be NULL when passed to the node_match() function (which does not check if it is NULL). When this happens we get the above panic. As page is only used in slab_alloc() to check if the node matches, if it's NULL I'm assuming that we can say it doesn't and call the __slab_alloc() code. Is this a correct assumption? Acked-by: Christoph Lameter Signed-off-by: Steven Rostedt Signed-off-by: Pekka Enberg Signed-off-by: Linus Torvalds --- mm/slub.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/slub.c b/mm/slub.c index ef60536c5d69..33f71330e713 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -2374,7 +2374,7 @@ redo: object = c->freelist; page = c->page; - if (unlikely(!object || !node_match(page, node))) + if (unlikely(!object || !page || !node_match(page, node))) object = __slab_alloc(s, gfpflags, node, addr, c); else { From ad81f0545ef01ea651886dddac4bef6cec930092 Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Sun, 14 Jul 2013 15:18:27 -0700 Subject: [PATCH 0892/1048] Linux 3.11-rc1 --- Makefile | 6 +- drivers/video/logo/logo_linux_clut224.ppm | 2481 ++++++++------------- 2 files changed, 883 insertions(+), 1604 deletions(-) diff --git a/Makefile b/Makefile index 4e3575c7ec35..9262ba8da4f9 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,8 @@ VERSION = 3 -PATCHLEVEL = 10 +PATCHLEVEL = 11 SUBLEVEL = 0 -EXTRAVERSION = -NAME = Unicycling Gorilla +EXTRAVERSION = -rc1 +NAME = Linux for Workgroups # *DOCUMENTATION* # To see a list of typical targets execute "make help" diff --git a/drivers/video/logo/logo_linux_clut224.ppm b/drivers/video/logo/logo_linux_clut224.ppm index 3c14e43b82fe..285d552089f2 100644 --- a/drivers/video/logo/logo_linux_clut224.ppm +++ b/drivers/video/logo/logo_linux_clut224.ppm @@ -1,1604 +1,883 @@ P3 -# Standard 224-color Linux logo 80 80 255 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 6 6 6 6 6 6 10 10 10 10 10 10 - 10 10 10 6 6 6 6 6 6 6 6 6 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 6 6 6 10 10 10 14 14 14 - 22 22 22 26 26 26 30 30 30 34 34 34 - 30 30 30 30 30 30 26 26 26 18 18 18 - 14 14 14 10 10 10 6 6 6 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 1 0 0 1 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 6 6 6 14 14 14 26 26 26 42 42 42 - 54 54 54 66 66 66 78 78 78 78 78 78 - 78 78 78 74 74 74 66 66 66 54 54 54 - 42 42 42 26 26 26 18 18 18 10 10 10 - 6 6 6 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 1 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 10 10 10 - 22 22 22 42 42 42 66 66 66 86 86 86 - 66 66 66 38 38 38 38 38 38 22 22 22 - 26 26 26 34 34 34 54 54 54 66 66 66 - 86 86 86 70 70 70 46 46 46 26 26 26 - 14 14 14 6 6 6 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 1 0 0 1 0 0 1 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 10 10 10 26 26 26 - 50 50 50 82 82 82 58 58 58 6 6 6 - 2 2 6 2 2 6 2 2 6 2 2 6 - 2 2 6 2 2 6 2 2 6 2 2 6 - 6 6 6 54 54 54 86 86 86 66 66 66 - 38 38 38 18 18 18 6 6 6 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 6 6 6 22 22 22 50 50 50 - 78 78 78 34 34 34 2 2 6 2 2 6 - 2 2 6 2 2 6 2 2 6 2 2 6 - 2 2 6 2 2 6 2 2 6 2 2 6 - 2 2 6 2 2 6 6 6 6 70 70 70 - 78 78 78 46 46 46 22 22 22 6 6 6 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 1 0 0 1 0 0 1 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 6 6 6 18 18 18 42 42 42 82 82 82 - 26 26 26 2 2 6 2 2 6 2 2 6 - 2 2 6 2 2 6 2 2 6 2 2 6 - 2 2 6 2 2 6 2 2 6 14 14 14 - 46 46 46 34 34 34 6 6 6 2 2 6 - 42 42 42 78 78 78 42 42 42 18 18 18 - 6 6 6 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 1 0 0 0 0 0 1 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 10 10 10 30 30 30 66 66 66 58 58 58 - 2 2 6 2 2 6 2 2 6 2 2 6 - 2 2 6 2 2 6 2 2 6 2 2 6 - 2 2 6 2 2 6 2 2 6 26 26 26 - 86 86 86 101 101 101 46 46 46 10 10 10 - 2 2 6 58 58 58 70 70 70 34 34 34 - 10 10 10 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 1 0 0 1 0 0 1 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 14 14 14 42 42 42 86 86 86 10 10 10 - 2 2 6 2 2 6 2 2 6 2 2 6 - 2 2 6 2 2 6 2 2 6 2 2 6 - 2 2 6 2 2 6 2 2 6 30 30 30 - 94 94 94 94 94 94 58 58 58 26 26 26 - 2 2 6 6 6 6 78 78 78 54 54 54 - 22 22 22 6 6 6 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 6 6 6 - 22 22 22 62 62 62 62 62 62 2 2 6 - 2 2 6 2 2 6 2 2 6 2 2 6 - 2 2 6 2 2 6 2 2 6 2 2 6 - 2 2 6 2 2 6 2 2 6 26 26 26 - 54 54 54 38 38 38 18 18 18 10 10 10 - 2 2 6 2 2 6 34 34 34 82 82 82 - 38 38 38 14 14 14 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 1 0 0 1 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 6 6 6 - 30 30 30 78 78 78 30 30 30 2 2 6 - 2 2 6 2 2 6 2 2 6 2 2 6 - 2 2 6 2 2 6 2 2 6 2 2 6 - 2 2 6 2 2 6 2 2 6 10 10 10 - 10 10 10 2 2 6 2 2 6 2 2 6 - 2 2 6 2 2 6 2 2 6 78 78 78 - 50 50 50 18 18 18 6 6 6 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 1 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 10 10 10 - 38 38 38 86 86 86 14 14 14 2 2 6 - 2 2 6 2 2 6 2 2 6 2 2 6 - 2 2 6 2 2 6 2 2 6 2 2 6 - 2 2 6 2 2 6 2 2 6 2 2 6 - 2 2 6 2 2 6 2 2 6 2 2 6 - 2 2 6 2 2 6 2 2 6 54 54 54 - 66 66 66 26 26 26 6 6 6 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 1 0 0 1 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 14 14 14 - 42 42 42 82 82 82 2 2 6 2 2 6 - 2 2 6 6 6 6 10 10 10 2 2 6 - 2 2 6 2 2 6 2 2 6 2 2 6 - 2 2 6 2 2 6 2 2 6 6 6 6 - 14 14 14 10 10 10 2 2 6 2 2 6 - 2 2 6 2 2 6 2 2 6 18 18 18 - 82 82 82 34 34 34 10 10 10 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 1 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 14 14 14 - 46 46 46 86 86 86 2 2 6 2 2 6 - 6 6 6 6 6 6 22 22 22 34 34 34 - 6 6 6 2 2 6 2 2 6 2 2 6 - 2 2 6 2 2 6 18 18 18 34 34 34 - 10 10 10 50 50 50 22 22 22 2 2 6 - 2 2 6 2 2 6 2 2 6 10 10 10 - 86 86 86 42 42 42 14 14 14 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 1 0 0 1 0 0 1 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 14 14 14 - 46 46 46 86 86 86 2 2 6 2 2 6 - 38 38 38 116 116 116 94 94 94 22 22 22 - 22 22 22 2 2 6 2 2 6 2 2 6 - 14 14 14 86 86 86 138 138 138 162 162 162 -154 154 154 38 38 38 26 26 26 6 6 6 - 2 2 6 2 2 6 2 2 6 2 2 6 - 86 86 86 46 46 46 14 14 14 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 14 14 14 - 46 46 46 86 86 86 2 2 6 14 14 14 -134 134 134 198 198 198 195 195 195 116 116 116 - 10 10 10 2 2 6 2 2 6 6 6 6 -101 98 89 187 187 187 210 210 210 218 218 218 -214 214 214 134 134 134 14 14 14 6 6 6 - 2 2 6 2 2 6 2 2 6 2 2 6 - 86 86 86 50 50 50 18 18 18 6 6 6 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 1 0 0 0 - 0 0 1 0 0 1 0 0 1 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 14 14 14 - 46 46 46 86 86 86 2 2 6 54 54 54 -218 218 218 195 195 195 226 226 226 246 246 246 - 58 58 58 2 2 6 2 2 6 30 30 30 -210 210 210 253 253 253 174 174 174 123 123 123 -221 221 221 234 234 234 74 74 74 2 2 6 - 2 2 6 2 2 6 2 2 6 2 2 6 - 70 70 70 58 58 58 22 22 22 6 6 6 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 14 14 14 - 46 46 46 82 82 82 2 2 6 106 106 106 -170 170 170 26 26 26 86 86 86 226 226 226 -123 123 123 10 10 10 14 14 14 46 46 46 -231 231 231 190 190 190 6 6 6 70 70 70 - 90 90 90 238 238 238 158 158 158 2 2 6 - 2 2 6 2 2 6 2 2 6 2 2 6 - 70 70 70 58 58 58 22 22 22 6 6 6 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 1 0 0 0 - 0 0 1 0 0 1 0 0 1 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 14 14 14 - 42 42 42 86 86 86 6 6 6 116 116 116 -106 106 106 6 6 6 70 70 70 149 149 149 -128 128 128 18 18 18 38 38 38 54 54 54 -221 221 221 106 106 106 2 2 6 14 14 14 - 46 46 46 190 190 190 198 198 198 2 2 6 - 2 2 6 2 2 6 2 2 6 2 2 6 - 74 74 74 62 62 62 22 22 22 6 6 6 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 1 0 0 0 - 0 0 1 0 0 0 0 0 1 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 14 14 14 - 42 42 42 94 94 94 14 14 14 101 101 101 -128 128 128 2 2 6 18 18 18 116 116 116 -118 98 46 121 92 8 121 92 8 98 78 10 -162 162 162 106 106 106 2 2 6 2 2 6 - 2 2 6 195 195 195 195 195 195 6 6 6 - 2 2 6 2 2 6 2 2 6 2 2 6 - 74 74 74 62 62 62 22 22 22 6 6 6 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 1 0 0 1 - 0 0 1 0 0 0 0 0 1 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 10 10 10 - 38 38 38 90 90 90 14 14 14 58 58 58 -210 210 210 26 26 26 54 38 6 154 114 10 -226 170 11 236 186 11 225 175 15 184 144 12 -215 174 15 175 146 61 37 26 9 2 2 6 - 70 70 70 246 246 246 138 138 138 2 2 6 - 2 2 6 2 2 6 2 2 6 2 2 6 - 70 70 70 66 66 66 26 26 26 6 6 6 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 10 10 10 - 38 38 38 86 86 86 14 14 14 10 10 10 -195 195 195 188 164 115 192 133 9 225 175 15 -239 182 13 234 190 10 232 195 16 232 200 30 -245 207 45 241 208 19 232 195 16 184 144 12 -218 194 134 211 206 186 42 42 42 2 2 6 - 2 2 6 2 2 6 2 2 6 2 2 6 - 50 50 50 74 74 74 30 30 30 6 6 6 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 10 10 10 - 34 34 34 86 86 86 14 14 14 2 2 6 -121 87 25 192 133 9 219 162 10 239 182 13 -236 186 11 232 195 16 241 208 19 244 214 54 -246 218 60 246 218 38 246 215 20 241 208 19 -241 208 19 226 184 13 121 87 25 2 2 6 - 2 2 6 2 2 6 2 2 6 2 2 6 - 50 50 50 82 82 82 34 34 34 10 10 10 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 10 10 10 - 34 34 34 82 82 82 30 30 30 61 42 6 -180 123 7 206 145 10 230 174 11 239 182 13 -234 190 10 238 202 15 241 208 19 246 218 74 -246 218 38 246 215 20 246 215 20 246 215 20 -226 184 13 215 174 15 184 144 12 6 6 6 - 2 2 6 2 2 6 2 2 6 2 2 6 - 26 26 26 94 94 94 42 42 42 14 14 14 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 10 10 10 - 30 30 30 78 78 78 50 50 50 104 69 6 -192 133 9 216 158 10 236 178 12 236 186 11 -232 195 16 241 208 19 244 214 54 245 215 43 -246 215 20 246 215 20 241 208 19 198 155 10 -200 144 11 216 158 10 156 118 10 2 2 6 - 2 2 6 2 2 6 2 2 6 2 2 6 - 6 6 6 90 90 90 54 54 54 18 18 18 - 6 6 6 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 10 10 10 - 30 30 30 78 78 78 46 46 46 22 22 22 -137 92 6 210 162 10 239 182 13 238 190 10 -238 202 15 241 208 19 246 215 20 246 215 20 -241 208 19 203 166 17 185 133 11 210 150 10 -216 158 10 210 150 10 102 78 10 2 2 6 - 6 6 6 54 54 54 14 14 14 2 2 6 - 2 2 6 62 62 62 74 74 74 30 30 30 - 10 10 10 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 10 10 10 - 34 34 34 78 78 78 50 50 50 6 6 6 - 94 70 30 139 102 15 190 146 13 226 184 13 -232 200 30 232 195 16 215 174 15 190 146 13 -168 122 10 192 133 9 210 150 10 213 154 11 -202 150 34 182 157 106 101 98 89 2 2 6 - 2 2 6 78 78 78 116 116 116 58 58 58 - 2 2 6 22 22 22 90 90 90 46 46 46 - 18 18 18 6 6 6 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 10 10 10 - 38 38 38 86 86 86 50 50 50 6 6 6 -128 128 128 174 154 114 156 107 11 168 122 10 -198 155 10 184 144 12 197 138 11 200 144 11 -206 145 10 206 145 10 197 138 11 188 164 115 -195 195 195 198 198 198 174 174 174 14 14 14 - 2 2 6 22 22 22 116 116 116 116 116 116 - 22 22 22 2 2 6 74 74 74 70 70 70 - 30 30 30 10 10 10 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 6 6 6 18 18 18 - 50 50 50 101 101 101 26 26 26 10 10 10 -138 138 138 190 190 190 174 154 114 156 107 11 -197 138 11 200 144 11 197 138 11 192 133 9 -180 123 7 190 142 34 190 178 144 187 187 187 -202 202 202 221 221 221 214 214 214 66 66 66 - 2 2 6 2 2 6 50 50 50 62 62 62 - 6 6 6 2 2 6 10 10 10 90 90 90 - 50 50 50 18 18 18 6 6 6 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 10 10 10 34 34 34 - 74 74 74 74 74 74 2 2 6 6 6 6 -144 144 144 198 198 198 190 190 190 178 166 146 -154 121 60 156 107 11 156 107 11 168 124 44 -174 154 114 187 187 187 190 190 190 210 210 210 -246 246 246 253 253 253 253 253 253 182 182 182 - 6 6 6 2 2 6 2 2 6 2 2 6 - 2 2 6 2 2 6 2 2 6 62 62 62 - 74 74 74 34 34 34 14 14 14 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 10 10 10 22 22 22 54 54 54 - 94 94 94 18 18 18 2 2 6 46 46 46 -234 234 234 221 221 221 190 190 190 190 190 190 -190 190 190 187 187 187 187 187 187 190 190 190 -190 190 190 195 195 195 214 214 214 242 242 242 -253 253 253 253 253 253 253 253 253 253 253 253 - 82 82 82 2 2 6 2 2 6 2 2 6 - 2 2 6 2 2 6 2 2 6 14 14 14 - 86 86 86 54 54 54 22 22 22 6 6 6 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 6 6 6 18 18 18 46 46 46 90 90 90 - 46 46 46 18 18 18 6 6 6 182 182 182 -253 253 253 246 246 246 206 206 206 190 190 190 -190 190 190 190 190 190 190 190 190 190 190 190 -206 206 206 231 231 231 250 250 250 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -202 202 202 14 14 14 2 2 6 2 2 6 - 2 2 6 2 2 6 2 2 6 2 2 6 - 42 42 42 86 86 86 42 42 42 18 18 18 - 6 6 6 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 6 6 6 - 14 14 14 38 38 38 74 74 74 66 66 66 - 2 2 6 6 6 6 90 90 90 250 250 250 -253 253 253 253 253 253 238 238 238 198 198 198 -190 190 190 190 190 190 195 195 195 221 221 221 -246 246 246 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 82 82 82 2 2 6 2 2 6 - 2 2 6 2 2 6 2 2 6 2 2 6 - 2 2 6 78 78 78 70 70 70 34 34 34 - 14 14 14 6 6 6 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 14 14 14 - 34 34 34 66 66 66 78 78 78 6 6 6 - 2 2 6 18 18 18 218 218 218 253 253 253 -253 253 253 253 253 253 253 253 253 246 246 246 -226 226 226 231 231 231 246 246 246 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 178 178 178 2 2 6 2 2 6 - 2 2 6 2 2 6 2 2 6 2 2 6 - 2 2 6 18 18 18 90 90 90 62 62 62 - 30 30 30 10 10 10 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 10 10 10 26 26 26 - 58 58 58 90 90 90 18 18 18 2 2 6 - 2 2 6 110 110 110 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -250 250 250 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 231 231 231 18 18 18 2 2 6 - 2 2 6 2 2 6 2 2 6 2 2 6 - 2 2 6 2 2 6 18 18 18 94 94 94 - 54 54 54 26 26 26 10 10 10 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 6 6 6 22 22 22 50 50 50 - 90 90 90 26 26 26 2 2 6 2 2 6 - 14 14 14 195 195 195 250 250 250 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -250 250 250 242 242 242 54 54 54 2 2 6 - 2 2 6 2 2 6 2 2 6 2 2 6 - 2 2 6 2 2 6 2 2 6 38 38 38 - 86 86 86 50 50 50 22 22 22 6 6 6 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 6 6 6 14 14 14 38 38 38 82 82 82 - 34 34 34 2 2 6 2 2 6 2 2 6 - 42 42 42 195 195 195 246 246 246 253 253 253 -253 253 253 253 253 253 253 253 253 250 250 250 -242 242 242 242 242 242 250 250 250 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 250 250 250 246 246 246 238 238 238 -226 226 226 231 231 231 101 101 101 6 6 6 - 2 2 6 2 2 6 2 2 6 2 2 6 - 2 2 6 2 2 6 2 2 6 2 2 6 - 38 38 38 82 82 82 42 42 42 14 14 14 - 6 6 6 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 10 10 10 26 26 26 62 62 62 66 66 66 - 2 2 6 2 2 6 2 2 6 6 6 6 - 70 70 70 170 170 170 206 206 206 234 234 234 -246 246 246 250 250 250 250 250 250 238 238 238 -226 226 226 231 231 231 238 238 238 250 250 250 -250 250 250 250 250 250 246 246 246 231 231 231 -214 214 214 206 206 206 202 202 202 202 202 202 -198 198 198 202 202 202 182 182 182 18 18 18 - 2 2 6 2 2 6 2 2 6 2 2 6 - 2 2 6 2 2 6 2 2 6 2 2 6 - 2 2 6 62 62 62 66 66 66 30 30 30 - 10 10 10 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 14 14 14 42 42 42 82 82 82 18 18 18 - 2 2 6 2 2 6 2 2 6 10 10 10 - 94 94 94 182 182 182 218 218 218 242 242 242 -250 250 250 253 253 253 253 253 253 250 250 250 -234 234 234 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 246 246 246 -238 238 238 226 226 226 210 210 210 202 202 202 -195 195 195 195 195 195 210 210 210 158 158 158 - 6 6 6 14 14 14 50 50 50 14 14 14 - 2 2 6 2 2 6 2 2 6 2 2 6 - 2 2 6 6 6 6 86 86 86 46 46 46 - 18 18 18 6 6 6 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 6 6 6 - 22 22 22 54 54 54 70 70 70 2 2 6 - 2 2 6 10 10 10 2 2 6 22 22 22 -166 166 166 231 231 231 250 250 250 253 253 253 -253 253 253 253 253 253 253 253 253 250 250 250 -242 242 242 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 246 246 246 -231 231 231 206 206 206 198 198 198 226 226 226 - 94 94 94 2 2 6 6 6 6 38 38 38 - 30 30 30 2 2 6 2 2 6 2 2 6 - 2 2 6 2 2 6 62 62 62 66 66 66 - 26 26 26 10 10 10 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 10 10 10 - 30 30 30 74 74 74 50 50 50 2 2 6 - 26 26 26 26 26 26 2 2 6 106 106 106 -238 238 238 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 246 246 246 218 218 218 202 202 202 -210 210 210 14 14 14 2 2 6 2 2 6 - 30 30 30 22 22 22 2 2 6 2 2 6 - 2 2 6 2 2 6 18 18 18 86 86 86 - 42 42 42 14 14 14 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 14 14 14 - 42 42 42 90 90 90 22 22 22 2 2 6 - 42 42 42 2 2 6 18 18 18 218 218 218 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 250 250 250 221 221 221 -218 218 218 101 101 101 2 2 6 14 14 14 - 18 18 18 38 38 38 10 10 10 2 2 6 - 2 2 6 2 2 6 2 2 6 78 78 78 - 58 58 58 22 22 22 6 6 6 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 6 6 6 18 18 18 - 54 54 54 82 82 82 2 2 6 26 26 26 - 22 22 22 2 2 6 123 123 123 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 250 250 250 -238 238 238 198 198 198 6 6 6 38 38 38 - 58 58 58 26 26 26 38 38 38 2 2 6 - 2 2 6 2 2 6 2 2 6 46 46 46 - 78 78 78 30 30 30 10 10 10 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 10 10 10 30 30 30 - 74 74 74 58 58 58 2 2 6 42 42 42 - 2 2 6 22 22 22 231 231 231 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 250 250 250 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 246 246 246 46 46 46 38 38 38 - 42 42 42 14 14 14 38 38 38 14 14 14 - 2 2 6 2 2 6 2 2 6 6 6 6 - 86 86 86 46 46 46 14 14 14 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 6 6 6 14 14 14 42 42 42 - 90 90 90 18 18 18 18 18 18 26 26 26 - 2 2 6 116 116 116 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 250 250 250 238 238 238 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 94 94 94 6 6 6 - 2 2 6 2 2 6 10 10 10 34 34 34 - 2 2 6 2 2 6 2 2 6 2 2 6 - 74 74 74 58 58 58 22 22 22 6 6 6 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 10 10 10 26 26 26 66 66 66 - 82 82 82 2 2 6 38 38 38 6 6 6 - 14 14 14 210 210 210 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 246 246 246 242 242 242 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 144 144 144 2 2 6 - 2 2 6 2 2 6 2 2 6 46 46 46 - 2 2 6 2 2 6 2 2 6 2 2 6 - 42 42 42 74 74 74 30 30 30 10 10 10 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 6 6 6 14 14 14 42 42 42 90 90 90 - 26 26 26 6 6 6 42 42 42 2 2 6 - 74 74 74 250 250 250 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 242 242 242 242 242 242 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 182 182 182 2 2 6 - 2 2 6 2 2 6 2 2 6 46 46 46 - 2 2 6 2 2 6 2 2 6 2 2 6 - 10 10 10 86 86 86 38 38 38 10 10 10 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 10 10 10 26 26 26 66 66 66 82 82 82 - 2 2 6 22 22 22 18 18 18 2 2 6 -149 149 149 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 234 234 234 242 242 242 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 206 206 206 2 2 6 - 2 2 6 2 2 6 2 2 6 38 38 38 - 2 2 6 2 2 6 2 2 6 2 2 6 - 6 6 6 86 86 86 46 46 46 14 14 14 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 6 6 6 - 18 18 18 46 46 46 86 86 86 18 18 18 - 2 2 6 34 34 34 10 10 10 6 6 6 -210 210 210 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 234 234 234 242 242 242 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 221 221 221 6 6 6 - 2 2 6 2 2 6 6 6 6 30 30 30 - 2 2 6 2 2 6 2 2 6 2 2 6 - 2 2 6 82 82 82 54 54 54 18 18 18 - 6 6 6 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 10 10 10 - 26 26 26 66 66 66 62 62 62 2 2 6 - 2 2 6 38 38 38 10 10 10 26 26 26 -238 238 238 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 231 231 231 238 238 238 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 231 231 231 6 6 6 - 2 2 6 2 2 6 10 10 10 30 30 30 - 2 2 6 2 2 6 2 2 6 2 2 6 - 2 2 6 66 66 66 58 58 58 22 22 22 - 6 6 6 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 10 10 10 - 38 38 38 78 78 78 6 6 6 2 2 6 - 2 2 6 46 46 46 14 14 14 42 42 42 -246 246 246 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 231 231 231 242 242 242 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 234 234 234 10 10 10 - 2 2 6 2 2 6 22 22 22 14 14 14 - 2 2 6 2 2 6 2 2 6 2 2 6 - 2 2 6 66 66 66 62 62 62 22 22 22 - 6 6 6 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 6 6 6 18 18 18 - 50 50 50 74 74 74 2 2 6 2 2 6 - 14 14 14 70 70 70 34 34 34 62 62 62 -250 250 250 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 231 231 231 246 246 246 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 234 234 234 14 14 14 - 2 2 6 2 2 6 30 30 30 2 2 6 - 2 2 6 2 2 6 2 2 6 2 2 6 - 2 2 6 66 66 66 62 62 62 22 22 22 - 6 6 6 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 6 6 6 18 18 18 - 54 54 54 62 62 62 2 2 6 2 2 6 - 2 2 6 30 30 30 46 46 46 70 70 70 -250 250 250 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 231 231 231 246 246 246 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 226 226 226 10 10 10 - 2 2 6 6 6 6 30 30 30 2 2 6 - 2 2 6 2 2 6 2 2 6 2 2 6 - 2 2 6 66 66 66 58 58 58 22 22 22 - 6 6 6 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 6 6 6 22 22 22 - 58 58 58 62 62 62 2 2 6 2 2 6 - 2 2 6 2 2 6 30 30 30 78 78 78 -250 250 250 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 231 231 231 246 246 246 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 206 206 206 2 2 6 - 22 22 22 34 34 34 18 14 6 22 22 22 - 26 26 26 18 18 18 6 6 6 2 2 6 - 2 2 6 82 82 82 54 54 54 18 18 18 - 6 6 6 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 6 6 6 26 26 26 - 62 62 62 106 106 106 74 54 14 185 133 11 -210 162 10 121 92 8 6 6 6 62 62 62 -238 238 238 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 231 231 231 246 246 246 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 158 158 158 18 18 18 - 14 14 14 2 2 6 2 2 6 2 2 6 - 6 6 6 18 18 18 66 66 66 38 38 38 - 6 6 6 94 94 94 50 50 50 18 18 18 - 6 6 6 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 6 6 6 - 10 10 10 10 10 10 18 18 18 38 38 38 - 78 78 78 142 134 106 216 158 10 242 186 14 -246 190 14 246 190 14 156 118 10 10 10 10 - 90 90 90 238 238 238 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 231 231 231 250 250 250 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 246 230 190 -238 204 91 238 204 91 181 142 44 37 26 9 - 2 2 6 2 2 6 2 2 6 2 2 6 - 2 2 6 2 2 6 38 38 38 46 46 46 - 26 26 26 106 106 106 54 54 54 18 18 18 - 6 6 6 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 6 6 6 14 14 14 22 22 22 - 30 30 30 38 38 38 50 50 50 70 70 70 -106 106 106 190 142 34 226 170 11 242 186 14 -246 190 14 246 190 14 246 190 14 154 114 10 - 6 6 6 74 74 74 226 226 226 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 231 231 231 250 250 250 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 228 184 62 -241 196 14 241 208 19 232 195 16 38 30 10 - 2 2 6 2 2 6 2 2 6 2 2 6 - 2 2 6 6 6 6 30 30 30 26 26 26 -203 166 17 154 142 90 66 66 66 26 26 26 - 6 6 6 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 6 6 6 18 18 18 38 38 38 58 58 58 - 78 78 78 86 86 86 101 101 101 123 123 123 -175 146 61 210 150 10 234 174 13 246 186 14 -246 190 14 246 190 14 246 190 14 238 190 10 -102 78 10 2 2 6 46 46 46 198 198 198 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 234 234 234 242 242 242 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 224 178 62 -242 186 14 241 196 14 210 166 10 22 18 6 - 2 2 6 2 2 6 2 2 6 2 2 6 - 2 2 6 2 2 6 6 6 6 121 92 8 -238 202 15 232 195 16 82 82 82 34 34 34 - 10 10 10 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 14 14 14 38 38 38 70 70 70 154 122 46 -190 142 34 200 144 11 197 138 11 197 138 11 -213 154 11 226 170 11 242 186 14 246 190 14 -246 190 14 246 190 14 246 190 14 246 190 14 -225 175 15 46 32 6 2 2 6 22 22 22 -158 158 158 250 250 250 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 250 250 250 242 242 242 224 178 62 -239 182 13 236 186 11 213 154 11 46 32 6 - 2 2 6 2 2 6 2 2 6 2 2 6 - 2 2 6 2 2 6 61 42 6 225 175 15 -238 190 10 236 186 11 112 100 78 42 42 42 - 14 14 14 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 6 6 6 - 22 22 22 54 54 54 154 122 46 213 154 11 -226 170 11 230 174 11 226 170 11 226 170 11 -236 178 12 242 186 14 246 190 14 246 190 14 -246 190 14 246 190 14 246 190 14 246 190 14 -241 196 14 184 144 12 10 10 10 2 2 6 - 6 6 6 116 116 116 242 242 242 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 231 231 231 198 198 198 214 170 54 -236 178 12 236 178 12 210 150 10 137 92 6 - 18 14 6 2 2 6 2 2 6 2 2 6 - 6 6 6 70 47 6 200 144 11 236 178 12 -239 182 13 239 182 13 124 112 88 58 58 58 - 22 22 22 6 6 6 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 10 10 10 - 30 30 30 70 70 70 180 133 36 226 170 11 -239 182 13 242 186 14 242 186 14 246 186 14 -246 190 14 246 190 14 246 190 14 246 190 14 -246 190 14 246 190 14 246 190 14 246 190 14 -246 190 14 232 195 16 98 70 6 2 2 6 - 2 2 6 2 2 6 66 66 66 221 221 221 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 206 206 206 198 198 198 214 166 58 -230 174 11 230 174 11 216 158 10 192 133 9 -163 110 8 116 81 8 102 78 10 116 81 8 -167 114 7 197 138 11 226 170 11 239 182 13 -242 186 14 242 186 14 162 146 94 78 78 78 - 34 34 34 14 14 14 6 6 6 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 6 6 6 - 30 30 30 78 78 78 190 142 34 226 170 11 -239 182 13 246 190 14 246 190 14 246 190 14 -246 190 14 246 190 14 246 190 14 246 190 14 -246 190 14 246 190 14 246 190 14 246 190 14 -246 190 14 241 196 14 203 166 17 22 18 6 - 2 2 6 2 2 6 2 2 6 38 38 38 -218 218 218 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -250 250 250 206 206 206 198 198 198 202 162 69 -226 170 11 236 178 12 224 166 10 210 150 10 -200 144 11 197 138 11 192 133 9 197 138 11 -210 150 10 226 170 11 242 186 14 246 190 14 -246 190 14 246 186 14 225 175 15 124 112 88 - 62 62 62 30 30 30 14 14 14 6 6 6 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 10 10 10 - 30 30 30 78 78 78 174 135 50 224 166 10 -239 182 13 246 190 14 246 190 14 246 190 14 -246 190 14 246 190 14 246 190 14 246 190 14 -246 190 14 246 190 14 246 190 14 246 190 14 -246 190 14 246 190 14 241 196 14 139 102 15 - 2 2 6 2 2 6 2 2 6 2 2 6 - 78 78 78 250 250 250 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -250 250 250 214 214 214 198 198 198 190 150 46 -219 162 10 236 178 12 234 174 13 224 166 10 -216 158 10 213 154 11 213 154 11 216 158 10 -226 170 11 239 182 13 246 190 14 246 190 14 -246 190 14 246 190 14 242 186 14 206 162 42 -101 101 101 58 58 58 30 30 30 14 14 14 - 6 6 6 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 10 10 10 - 30 30 30 74 74 74 174 135 50 216 158 10 -236 178 12 246 190 14 246 190 14 246 190 14 -246 190 14 246 190 14 246 190 14 246 190 14 -246 190 14 246 190 14 246 190 14 246 190 14 -246 190 14 246 190 14 241 196 14 226 184 13 - 61 42 6 2 2 6 2 2 6 2 2 6 - 22 22 22 238 238 238 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 226 226 226 187 187 187 180 133 36 -216 158 10 236 178 12 239 182 13 236 178 12 -230 174 11 226 170 11 226 170 11 230 174 11 -236 178 12 242 186 14 246 190 14 246 190 14 -246 190 14 246 190 14 246 186 14 239 182 13 -206 162 42 106 106 106 66 66 66 34 34 34 - 14 14 14 6 6 6 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 6 6 6 - 26 26 26 70 70 70 163 133 67 213 154 11 -236 178 12 246 190 14 246 190 14 246 190 14 -246 190 14 246 190 14 246 190 14 246 190 14 -246 190 14 246 190 14 246 190 14 246 190 14 -246 190 14 246 190 14 246 190 14 241 196 14 -190 146 13 18 14 6 2 2 6 2 2 6 - 46 46 46 246 246 246 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 221 221 221 86 86 86 156 107 11 -216 158 10 236 178 12 242 186 14 246 186 14 -242 186 14 239 182 13 239 182 13 242 186 14 -242 186 14 246 186 14 246 190 14 246 190 14 -246 190 14 246 190 14 246 190 14 246 190 14 -242 186 14 225 175 15 142 122 72 66 66 66 - 30 30 30 10 10 10 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 6 6 6 - 26 26 26 70 70 70 163 133 67 210 150 10 -236 178 12 246 190 14 246 190 14 246 190 14 -246 190 14 246 190 14 246 190 14 246 190 14 -246 190 14 246 190 14 246 190 14 246 190 14 -246 190 14 246 190 14 246 190 14 246 190 14 -232 195 16 121 92 8 34 34 34 106 106 106 -221 221 221 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -242 242 242 82 82 82 18 14 6 163 110 8 -216 158 10 236 178 12 242 186 14 246 190 14 -246 190 14 246 190 14 246 190 14 246 190 14 -246 190 14 246 190 14 246 190 14 246 190 14 -246 190 14 246 190 14 246 190 14 246 190 14 -246 190 14 246 190 14 242 186 14 163 133 67 - 46 46 46 18 18 18 6 6 6 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 10 10 10 - 30 30 30 78 78 78 163 133 67 210 150 10 -236 178 12 246 186 14 246 190 14 246 190 14 -246 190 14 246 190 14 246 190 14 246 190 14 -246 190 14 246 190 14 246 190 14 246 190 14 -246 190 14 246 190 14 246 190 14 246 190 14 -241 196 14 215 174 15 190 178 144 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 218 218 218 - 58 58 58 2 2 6 22 18 6 167 114 7 -216 158 10 236 178 12 246 186 14 246 190 14 -246 190 14 246 190 14 246 190 14 246 190 14 -246 190 14 246 190 14 246 190 14 246 190 14 -246 190 14 246 190 14 246 190 14 246 190 14 -246 190 14 246 186 14 242 186 14 190 150 46 - 54 54 54 22 22 22 6 6 6 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 14 14 14 - 38 38 38 86 86 86 180 133 36 213 154 11 -236 178 12 246 186 14 246 190 14 246 190 14 -246 190 14 246 190 14 246 190 14 246 190 14 -246 190 14 246 190 14 246 190 14 246 190 14 -246 190 14 246 190 14 246 190 14 246 190 14 -246 190 14 232 195 16 190 146 13 214 214 214 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 250 250 250 170 170 170 26 26 26 - 2 2 6 2 2 6 37 26 9 163 110 8 -219 162 10 239 182 13 246 186 14 246 190 14 -246 190 14 246 190 14 246 190 14 246 190 14 -246 190 14 246 190 14 246 190 14 246 190 14 -246 190 14 246 190 14 246 190 14 246 190 14 -246 186 14 236 178 12 224 166 10 142 122 72 - 46 46 46 18 18 18 6 6 6 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 6 6 6 18 18 18 - 50 50 50 109 106 95 192 133 9 224 166 10 -242 186 14 246 190 14 246 190 14 246 190 14 -246 190 14 246 190 14 246 190 14 246 190 14 -246 190 14 246 190 14 246 190 14 246 190 14 -246 190 14 246 190 14 246 190 14 246 190 14 -242 186 14 226 184 13 210 162 10 142 110 46 -226 226 226 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -253 253 253 253 253 253 253 253 253 253 253 253 -198 198 198 66 66 66 2 2 6 2 2 6 - 2 2 6 2 2 6 50 34 6 156 107 11 -219 162 10 239 182 13 246 186 14 246 190 14 -246 190 14 246 190 14 246 190 14 246 190 14 -246 190 14 246 190 14 246 190 14 246 190 14 -246 190 14 246 190 14 246 190 14 242 186 14 -234 174 13 213 154 11 154 122 46 66 66 66 - 30 30 30 10 10 10 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 6 6 6 22 22 22 - 58 58 58 154 121 60 206 145 10 234 174 13 -242 186 14 246 186 14 246 190 14 246 190 14 -246 190 14 246 190 14 246 190 14 246 190 14 -246 190 14 246 190 14 246 190 14 246 190 14 -246 190 14 246 190 14 246 190 14 246 190 14 -246 186 14 236 178 12 210 162 10 163 110 8 - 61 42 6 138 138 138 218 218 218 250 250 250 -253 253 253 253 253 253 253 253 253 250 250 250 -242 242 242 210 210 210 144 144 144 66 66 66 - 6 6 6 2 2 6 2 2 6 2 2 6 - 2 2 6 2 2 6 61 42 6 163 110 8 -216 158 10 236 178 12 246 190 14 246 190 14 -246 190 14 246 190 14 246 190 14 246 190 14 -246 190 14 246 190 14 246 190 14 246 190 14 -246 190 14 239 182 13 230 174 11 216 158 10 -190 142 34 124 112 88 70 70 70 38 38 38 - 18 18 18 6 6 6 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 6 6 6 22 22 22 - 62 62 62 168 124 44 206 145 10 224 166 10 -236 178 12 239 182 13 242 186 14 242 186 14 -246 186 14 246 190 14 246 190 14 246 190 14 -246 190 14 246 190 14 246 190 14 246 190 14 -246 190 14 246 190 14 246 190 14 246 190 14 -246 190 14 236 178 12 216 158 10 175 118 6 - 80 54 7 2 2 6 6 6 6 30 30 30 - 54 54 54 62 62 62 50 50 50 38 38 38 - 14 14 14 2 2 6 2 2 6 2 2 6 - 2 2 6 2 2 6 2 2 6 2 2 6 - 2 2 6 6 6 6 80 54 7 167 114 7 -213 154 11 236 178 12 246 190 14 246 190 14 -246 190 14 246 190 14 246 190 14 246 190 14 -246 190 14 242 186 14 239 182 13 239 182 13 -230 174 11 210 150 10 174 135 50 124 112 88 - 82 82 82 54 54 54 34 34 34 18 18 18 - 6 6 6 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 6 6 6 18 18 18 - 50 50 50 158 118 36 192 133 9 200 144 11 -216 158 10 219 162 10 224 166 10 226 170 11 -230 174 11 236 178 12 239 182 13 239 182 13 -242 186 14 246 186 14 246 190 14 246 190 14 -246 190 14 246 190 14 246 190 14 246 190 14 -246 186 14 230 174 11 210 150 10 163 110 8 -104 69 6 10 10 10 2 2 6 2 2 6 - 2 2 6 2 2 6 2 2 6 2 2 6 - 2 2 6 2 2 6 2 2 6 2 2 6 - 2 2 6 2 2 6 2 2 6 2 2 6 - 2 2 6 6 6 6 91 60 6 167 114 7 -206 145 10 230 174 11 242 186 14 246 190 14 -246 190 14 246 190 14 246 186 14 242 186 14 -239 182 13 230 174 11 224 166 10 213 154 11 -180 133 36 124 112 88 86 86 86 58 58 58 - 38 38 38 22 22 22 10 10 10 6 6 6 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 14 14 14 - 34 34 34 70 70 70 138 110 50 158 118 36 -167 114 7 180 123 7 192 133 9 197 138 11 -200 144 11 206 145 10 213 154 11 219 162 10 -224 166 10 230 174 11 239 182 13 242 186 14 -246 186 14 246 186 14 246 186 14 246 186 14 -239 182 13 216 158 10 185 133 11 152 99 6 -104 69 6 18 14 6 2 2 6 2 2 6 - 2 2 6 2 2 6 2 2 6 2 2 6 - 2 2 6 2 2 6 2 2 6 2 2 6 - 2 2 6 2 2 6 2 2 6 2 2 6 - 2 2 6 6 6 6 80 54 7 152 99 6 -192 133 9 219 162 10 236 178 12 239 182 13 -246 186 14 242 186 14 239 182 13 236 178 12 -224 166 10 206 145 10 192 133 9 154 121 60 - 94 94 94 62 62 62 42 42 42 22 22 22 - 14 14 14 6 6 6 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 6 6 6 - 18 18 18 34 34 34 58 58 58 78 78 78 -101 98 89 124 112 88 142 110 46 156 107 11 -163 110 8 167 114 7 175 118 6 180 123 7 -185 133 11 197 138 11 210 150 10 219 162 10 -226 170 11 236 178 12 236 178 12 234 174 13 -219 162 10 197 138 11 163 110 8 130 83 6 - 91 60 6 10 10 10 2 2 6 2 2 6 - 18 18 18 38 38 38 38 38 38 38 38 38 - 38 38 38 38 38 38 38 38 38 38 38 38 - 38 38 38 38 38 38 26 26 26 2 2 6 - 2 2 6 6 6 6 70 47 6 137 92 6 -175 118 6 200 144 11 219 162 10 230 174 11 -234 174 13 230 174 11 219 162 10 210 150 10 -192 133 9 163 110 8 124 112 88 82 82 82 - 50 50 50 30 30 30 14 14 14 6 6 6 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 6 6 6 14 14 14 22 22 22 34 34 34 - 42 42 42 58 58 58 74 74 74 86 86 86 -101 98 89 122 102 70 130 98 46 121 87 25 -137 92 6 152 99 6 163 110 8 180 123 7 -185 133 11 197 138 11 206 145 10 200 144 11 -180 123 7 156 107 11 130 83 6 104 69 6 - 50 34 6 54 54 54 110 110 110 101 98 89 - 86 86 86 82 82 82 78 78 78 78 78 78 - 78 78 78 78 78 78 78 78 78 78 78 78 - 78 78 78 82 82 82 86 86 86 94 94 94 -106 106 106 101 101 101 86 66 34 124 80 6 -156 107 11 180 123 7 192 133 9 200 144 11 -206 145 10 200 144 11 192 133 9 175 118 6 -139 102 15 109 106 95 70 70 70 42 42 42 - 22 22 22 10 10 10 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 6 6 6 10 10 10 - 14 14 14 22 22 22 30 30 30 38 38 38 - 50 50 50 62 62 62 74 74 74 90 90 90 -101 98 89 112 100 78 121 87 25 124 80 6 -137 92 6 152 99 6 152 99 6 152 99 6 -138 86 6 124 80 6 98 70 6 86 66 30 -101 98 89 82 82 82 58 58 58 46 46 46 - 38 38 38 34 34 34 34 34 34 34 34 34 - 34 34 34 34 34 34 34 34 34 34 34 34 - 34 34 34 34 34 34 38 38 38 42 42 42 - 54 54 54 82 82 82 94 86 76 91 60 6 -134 86 6 156 107 11 167 114 7 175 118 6 -175 118 6 167 114 7 152 99 6 121 87 25 -101 98 89 62 62 62 34 34 34 18 18 18 - 6 6 6 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 6 6 6 6 6 6 10 10 10 - 18 18 18 22 22 22 30 30 30 42 42 42 - 50 50 50 66 66 66 86 86 86 101 98 89 -106 86 58 98 70 6 104 69 6 104 69 6 -104 69 6 91 60 6 82 62 34 90 90 90 - 62 62 62 38 38 38 22 22 22 14 14 14 - 10 10 10 10 10 10 10 10 10 10 10 10 - 10 10 10 10 10 10 6 6 6 10 10 10 - 10 10 10 10 10 10 10 10 10 14 14 14 - 22 22 22 42 42 42 70 70 70 89 81 66 - 80 54 7 104 69 6 124 80 6 137 92 6 -134 86 6 116 81 8 100 82 52 86 86 86 - 58 58 58 30 30 30 14 14 14 6 6 6 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 6 6 6 10 10 10 14 14 14 - 18 18 18 26 26 26 38 38 38 54 54 54 - 70 70 70 86 86 86 94 86 76 89 81 66 - 89 81 66 86 86 86 74 74 74 50 50 50 - 30 30 30 14 14 14 6 6 6 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 6 6 6 18 18 18 34 34 34 58 58 58 - 82 82 82 89 81 66 89 81 66 89 81 66 - 94 86 66 94 86 76 74 74 74 50 50 50 - 26 26 26 14 14 14 6 6 6 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 6 6 6 6 6 6 14 14 14 18 18 18 - 30 30 30 38 38 38 46 46 46 54 54 54 - 50 50 50 42 42 42 30 30 30 18 18 18 - 10 10 10 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 6 6 6 14 14 14 26 26 26 - 38 38 38 50 50 50 58 58 58 58 58 58 - 54 54 54 42 42 42 30 30 30 18 18 18 - 10 10 10 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 6 6 6 - 6 6 6 10 10 10 14 14 14 18 18 18 - 18 18 18 14 14 14 10 10 10 6 6 6 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 6 6 6 - 14 14 14 18 18 18 22 22 22 22 22 22 - 18 18 18 14 14 14 10 10 10 6 6 6 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 11 15 17 33 49 54 59 85 92 73 97 106 +83 116 129 105 131 142 115 114 122 74 88 93 20 29 31 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 6 6 6 10 10 10 10 10 10 +10 10 10 6 6 6 6 6 6 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 2 3 3 17 23 26 50 67 72 73 97 106 59 85 92 73 97 106 +105 131 142 124 127 131 105 131 142 105 131 142 53 75 83 6 8 8 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 6 6 6 10 10 10 14 14 14 22 22 22 26 26 26 30 30 30 34 34 34 +30 30 30 30 30 30 26 26 26 18 18 18 14 14 14 10 10 10 6 6 6 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 0 0 0 +0 0 0 1 1 1 26 35 39 59 85 92 59 85 92 59 85 92 29 43 47 53 75 83 +108 122 132 132 98 104 108 122 132 105 131 142 101 101 101 43 45 48 6 8 8 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +6 6 6 14 14 14 26 26 26 42 42 42 54 54 54 66 66 66 78 78 78 78 78 78 +78 78 78 74 74 74 66 66 66 54 54 54 42 42 42 26 26 26 18 18 18 10 10 10 +6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + +0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 0 0 0 +11 15 17 27 40 45 59 85 92 59 85 92 27 40 45 31 45 49 73 97 106 93 121 133 +108 122 132 108 122 132 105 131 142 108 122 132 105 131 142 73 97 106 26 35 39 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 10 10 +22 22 22 42 42 42 66 66 66 86 86 86 66 66 66 38 38 38 38 38 38 22 22 22 +26 26 26 34 34 34 54 54 54 66 66 66 86 86 86 70 70 70 46 46 46 26 26 26 +14 14 14 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + +0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 7 12 13 21 31 35 42 59 64 +53 75 83 53 75 83 50 67 72 42 59 64 32 40 45 42 59 64 73 97 106 116 116 116 +132 98 104 116 116 116 108 122 132 117 104 110 105 131 142 83 116 129 50 67 72 7 12 13 +1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 10 10 26 26 26 +50 50 50 82 82 82 58 58 58 6 6 6 2 2 6 2 2 6 2 2 6 2 2 6 +2 2 6 2 2 6 2 2 6 2 2 6 6 6 6 54 54 54 86 86 86 66 66 66 +38 38 38 18 18 18 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + +0 0 0 1 1 1 6 8 8 15 22 25 26 35 39 36 54 60 53 75 83 59 85 92 +59 85 92 48 63 69 15 22 25 12 17 20 52 67 79 94 94 94 132 98 104 132 98 104 +117 104 110 108 122 132 108 122 132 115 114 122 105 131 142 77 105 114 59 85 92 36 54 60 +7 12 13 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 22 22 22 50 50 50 +78 78 78 34 34 34 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 +2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 6 6 6 70 70 70 +78 78 78 46 46 46 22 22 22 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + +0 0 0 15 22 25 29 43 47 36 54 60 42 59 64 42 59 64 48 63 69 21 31 35 +6 8 8 29 43 47 36 50 56 43 45 48 79 78 84 132 98 104 165 78 79 132 98 104 +108 122 132 117 104 110 117 104 110 108 122 132 77 105 114 73 97 106 95 131 149 78 102 129 +36 50 56 0 0 0 0 0 0 0 0 0 6 6 6 18 18 18 42 42 42 82 82 82 +26 26 26 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 +2 2 6 2 2 6 2 2 6 14 14 14 46 46 46 34 34 34 6 6 6 2 2 6 +42 42 42 78 78 78 42 42 42 18 18 18 6 6 6 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + +27 40 45 53 75 83 48 63 69 24 31 37 6 8 12 0 0 0 18 25 28 26 35 39 +12 17 20 26 35 39 65 78 84 112 81 86 152 81 83 137 83 86 132 98 104 117 104 110 +117 104 110 132 98 104 132 98 104 115 114 122 73 97 106 53 75 83 95 131 149 93 124 152 +68 78 128 15 22 25 0 0 0 0 0 0 10 10 10 30 30 30 66 66 66 58 58 58 +2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 +2 2 6 2 2 6 2 2 6 26 26 26 86 86 86 101 101 101 46 46 46 10 10 10 +2 2 6 58 58 58 70 70 70 34 34 34 10 10 10 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + +36 50 56 21 30 33 4 7 7 0 0 0 1 1 1 17 12 12 69 31 31 68 59 64 +57 59 63 21 31 35 32 40 45 86 73 69 152 81 83 152 81 83 117 104 110 132 98 104 +152 81 83 132 98 104 108 122 132 77 105 114 77 105 114 93 121 133 95 131 149 93 124 152 +95 131 149 53 75 83 11 15 17 0 0 0 14 14 14 42 42 42 86 86 86 10 10 10 +2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 +2 2 6 2 2 6 2 2 6 30 30 30 94 94 94 94 94 94 58 58 58 26 26 26 +2 2 6 6 6 6 78 78 78 54 54 54 22 22 22 6 6 6 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + +17 23 26 2 3 3 0 0 0 17 12 12 69 31 31 123 55 55 123 55 55 152 81 83 +86 73 69 17 23 26 7 12 13 45 54 57 101 101 101 137 83 86 132 98 104 132 98 104 +137 83 86 117 104 110 77 105 114 42 59 64 50 67 72 78 102 129 91 117 157 91 117 157 +95 131 149 83 116 129 40 48 73 6 6 6 22 22 22 62 62 62 62 62 62 2 2 6 +2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 +2 2 6 2 2 6 2 2 6 26 26 26 54 54 54 38 38 38 18 18 18 10 10 10 +2 2 6 2 2 6 34 34 34 82 82 82 38 38 38 14 14 14 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + +1 1 1 1 2 2 2 3 3 28 12 12 123 55 55 174 79 79 174 79 79 174 79 79 +152 81 83 68 59 64 26 35 39 27 40 45 79 78 84 137 83 86 165 78 79 137 83 86 +94 94 94 48 63 69 36 50 56 50 67 72 73 97 106 93 121 133 93 124 152 93 124 152 +95 131 149 91 118 149 78 102 129 27 40 45 30 30 30 78 78 78 30 30 30 2 2 6 +2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 +2 2 6 2 2 6 2 2 6 10 10 10 10 10 10 2 2 6 2 2 6 2 2 6 +2 2 6 2 2 6 2 2 6 78 78 78 50 50 50 18 18 18 6 6 6 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + +4 5 3 24 53 24 19 31 15 8 7 3 90 61 47 165 78 79 174 79 79 174 79 79 +174 79 79 137 83 86 60 52 57 7 12 13 17 23 26 70 70 70 132 98 104 112 81 86 +79 78 84 31 45 49 15 22 25 53 75 83 91 118 149 86 106 160 91 117 157 93 124 152 +91 117 157 93 124 152 95 131 149 53 75 83 50 50 50 86 86 86 14 14 14 2 2 6 +2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 +2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 +2 2 6 2 2 6 2 2 6 54 54 54 66 66 66 26 26 26 6 6 6 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + +19 31 15 34 76 34 34 76 34 19 31 15 28 12 12 123 55 55 174 79 79 174 79 79 +174 79 79 165 78 79 112 81 86 32 40 45 15 22 25 38 53 58 65 78 84 29 31 32 +21 30 33 42 59 64 60 80 103 78 102 129 87 112 149 84 96 162 91 117 157 93 124 152 +91 117 157 93 124 152 93 121 133 59 85 92 57 68 71 82 85 86 2 2 6 2 2 6 +2 2 6 6 6 6 10 10 10 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 +2 2 6 2 2 6 2 2 6 6 6 6 14 14 14 10 10 10 2 2 6 2 2 6 +2 2 6 2 2 6 2 2 6 18 18 18 82 82 82 34 34 34 10 10 10 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + +34 76 34 40 89 40 40 89 40 34 76 34 8 15 6 48 26 18 123 55 55 174 79 79 +174 79 79 174 79 79 137 83 86 68 59 64 32 40 45 21 30 33 31 45 49 21 31 35 +12 17 20 48 63 69 78 102 129 81 88 166 84 96 162 91 117 157 93 124 152 91 117 157 +93 124 152 95 131 149 83 116 129 59 85 92 57 68 71 86 86 86 2 2 6 2 2 6 +6 6 6 6 6 6 22 22 22 34 34 34 6 6 6 2 2 6 2 2 6 2 2 6 +2 2 6 2 2 6 18 18 18 34 34 34 10 10 10 50 50 50 22 22 22 2 2 6 +2 2 6 2 2 6 2 2 6 10 10 10 86 86 86 42 42 42 14 14 14 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + +40 89 40 40 89 40 40 89 40 40 89 40 24 53 24 6 6 6 69 31 31 123 55 55 +123 55 55 90 61 47 69 31 31 36 32 33 21 31 35 7 12 13 18 25 28 48 63 69 +60 80 103 68 78 128 84 101 153 84 96 162 84 96 162 91 117 157 91 117 157 84 96 162 +91 117 157 73 97 106 48 63 69 50 67 72 57 59 63 86 86 86 2 2 6 2 2 6 +38 38 38 116 116 116 94 94 94 22 22 22 22 22 22 2 2 6 2 2 6 2 2 6 +14 14 14 86 86 86 124 131 137 170 170 170 151 151 151 38 38 38 26 26 26 6 6 6 +2 2 6 2 2 6 2 2 6 2 2 6 86 86 86 46 46 46 14 14 14 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + +34 76 34 40 89 40 40 89 40 40 89 40 34 76 34 19 31 15 17 12 12 48 26 18 +48 26 18 8 7 3 10 10 22 23 29 47 51 61 92 42 59 64 21 30 33 34 45 54 +68 78 128 81 88 166 81 82 173 86 106 160 86 106 160 84 96 162 86 106 160 87 112 149 +91 118 149 77 105 114 52 67 79 32 40 45 50 50 50 86 86 86 2 2 6 14 14 14 +124 131 137 198 198 198 195 195 195 116 116 116 10 10 10 2 2 6 2 2 6 6 6 6 +101 98 89 187 187 187 210 210 210 218 218 218 214 214 214 124 131 137 14 14 14 6 6 6 +2 2 6 2 2 6 2 2 6 2 2 6 86 86 86 50 50 50 18 18 18 6 6 6 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + +19 31 15 34 76 34 40 89 40 40 89 40 40 89 40 24 53 24 8 7 3 0 0 0 +6 8 12 28 32 52 51 61 92 54 54 122 74 77 160 68 78 128 26 35 39 6 8 8 +34 45 54 68 78 128 84 96 162 86 106 160 86 106 160 81 88 166 84 96 162 87 112 149 +73 97 106 36 50 56 33 49 54 18 18 18 46 46 46 86 86 86 2 2 6 54 54 54 +218 218 218 195 195 195 226 226 226 246 246 246 58 58 58 2 2 6 2 2 6 30 30 30 +210 210 210 253 253 253 170 170 170 124 127 131 221 221 221 234 234 234 74 74 74 2 2 6 +2 2 6 2 2 6 2 2 6 2 2 6 70 70 70 58 58 58 22 22 22 6 6 6 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + +4 5 3 24 53 24 40 89 40 40 89 40 34 76 34 12 22 15 4 5 3 4 5 3 +13 17 26 54 54 122 78 78 174 78 78 174 78 78 174 74 77 160 51 61 92 21 31 35 +26 35 39 53 75 83 84 101 153 81 82 173 81 88 166 84 101 153 60 80 103 60 80 103 +53 75 83 38 53 58 42 59 64 22 22 22 46 46 46 82 82 82 2 2 6 106 106 106 +170 170 170 26 26 26 86 86 86 226 226 226 124 127 131 10 10 10 14 14 14 46 46 46 +231 231 231 190 190 190 6 6 6 70 70 70 90 90 90 238 238 238 151 151 151 2 2 6 +2 2 6 2 2 6 2 2 6 2 2 6 70 70 70 58 58 58 22 22 22 6 6 6 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + +1 2 2 8 15 6 24 53 24 34 76 34 19 31 15 8 15 6 63 55 20 63 55 20 +18 18 18 40 48 73 74 77 160 78 78 174 78 78 174 81 82 173 74 77 160 52 67 79 +17 23 26 21 31 35 60 80 103 81 88 166 74 77 160 78 102 129 36 54 60 12 17 20 +42 59 64 48 63 69 21 31 35 18 18 18 42 42 42 86 86 86 6 6 6 116 116 116 +106 106 106 6 6 6 70 70 70 151 151 151 124 127 131 18 18 18 38 38 38 54 54 54 +221 221 221 106 106 106 2 2 6 14 14 14 46 46 46 190 190 190 198 198 198 2 2 6 +2 2 6 2 2 6 2 2 6 2 2 6 74 74 74 62 62 62 22 22 22 6 6 6 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + +11 15 17 0 0 0 12 22 15 19 31 15 8 15 6 63 55 20 149 139 69 149 139 69 +63 55 20 10 10 22 54 54 122 78 78 174 78 78 174 78 78 174 81 82 173 68 78 128 +24 31 37 6 6 6 36 50 56 60 80 103 51 61 92 42 59 64 36 50 56 31 45 49 +29 43 47 27 40 45 6 8 8 14 14 14 42 42 42 94 94 94 14 14 14 101 101 101 +124 127 131 2 2 6 18 18 18 116 116 116 106 107 48 121 92 8 121 92 8 98 70 6 +170 170 170 106 106 106 2 2 6 2 2 6 2 2 6 195 195 195 195 195 195 6 6 6 +2 2 6 2 2 6 2 2 6 2 2 6 74 74 74 62 62 62 22 22 22 6 6 6 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + +26 35 39 3 5 6 1 1 1 2 3 3 35 31 12 133 118 54 175 176 80 175 176 80 +133 118 54 35 31 12 23 29 47 54 54 122 78 78 174 78 78 174 74 77 160 68 78 128 +51 61 92 31 45 49 26 35 39 36 50 56 29 43 47 7 12 13 21 30 33 42 59 64 +18 25 28 7 12 13 1 1 1 10 10 10 38 38 38 90 90 90 14 14 14 58 58 58 +210 210 210 26 26 26 62 42 6 154 114 10 226 170 11 237 188 10 220 174 15 184 138 11 +220 174 15 174 140 55 35 31 12 2 2 6 70 70 70 246 246 246 124 131 137 2 2 6 +2 2 6 2 2 6 2 2 6 2 2 6 70 70 70 66 66 66 26 26 26 6 6 6 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + +27 40 45 17 23 26 2 3 3 1 1 1 56 77 35 165 152 80 175 176 80 175 176 80 +175 176 80 106 107 48 22 22 22 28 32 52 54 54 122 54 54 122 51 61 92 28 32 52 +20 27 34 31 45 49 11 15 17 7 12 13 36 50 56 31 45 49 29 43 47 36 50 56 +6 8 8 0 0 0 0 0 0 10 10 10 38 38 38 86 86 86 14 14 14 10 10 10 +195 195 195 198 179 130 192 133 9 220 174 15 239 182 13 237 188 10 232 195 16 239 207 25 +237 201 50 241 208 19 232 195 16 184 138 11 198 179 130 208 206 196 42 42 42 2 2 6 +2 2 6 2 2 6 2 2 6 2 2 6 50 50 50 74 74 74 30 30 30 6 6 6 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + +15 22 25 26 35 39 15 22 25 0 0 0 35 31 12 133 118 54 175 176 80 175 176 80 +175 176 80 165 152 80 56 77 35 6 8 12 23 29 47 13 17 26 2 2 6 0 0 0 +1 2 2 26 35 39 26 35 39 26 35 39 42 59 64 42 59 64 20 29 31 6 8 8 +0 0 0 0 0 0 0 0 0 10 10 10 34 34 34 86 86 86 14 14 14 2 2 6 +121 92 8 192 133 9 219 162 10 239 182 13 237 188 10 232 195 16 241 208 19 237 201 50 +237 201 50 239 207 25 241 208 19 241 208 19 241 208 19 230 187 11 121 92 8 2 2 6 +2 2 6 2 2 6 2 2 6 2 2 6 50 50 50 82 82 82 34 34 34 10 10 10 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + +1 2 2 15 22 25 31 45 49 6 8 12 4 5 3 63 55 20 149 139 69 175 176 80 +175 176 80 175 176 80 106 107 48 20 16 6 1 1 1 0 0 0 2 3 3 11 15 17 +21 30 33 36 50 56 36 50 56 24 31 37 15 22 25 6 8 8 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 10 10 10 34 34 34 82 82 82 30 30 30 62 42 6 +180 123 7 206 145 10 230 174 11 239 182 13 237 188 10 238 202 15 241 208 19 237 201 50 +239 207 25 241 208 19 241 208 19 241 208 19 230 187 11 220 174 15 184 138 11 6 6 6 +2 2 6 2 2 6 2 2 6 2 2 6 26 26 26 94 94 94 42 42 42 14 14 14 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + +0 0 0 1 2 2 29 43 47 26 35 39 3 5 6 8 7 3 106 107 48 165 152 80 +175 176 80 149 139 69 63 55 20 4 5 3 2 3 3 12 17 20 26 35 39 26 35 39 +17 23 26 7 12 13 6 8 8 3 5 6 1 2 2 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 10 10 10 30 30 30 78 78 78 50 50 50 104 69 6 +192 133 9 216 158 10 236 178 12 237 188 10 232 195 16 241 208 19 237 201 50 237 201 50 +241 208 19 241 208 19 241 208 19 204 160 10 200 144 11 216 158 10 156 118 10 2 2 6 +2 2 6 2 2 6 2 2 6 2 2 6 6 6 6 90 90 90 54 54 54 18 18 18 +6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + +0 0 0 0 0 0 12 17 20 27 40 45 18 25 28 1 1 1 35 31 12 106 107 48 +149 139 69 56 77 35 8 7 3 1 2 2 12 17 20 26 35 39 21 31 35 11 15 17 +3 5 6 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 10 10 10 30 30 30 78 78 78 46 46 46 22 22 22 +137 92 6 204 160 10 239 182 13 237 188 10 238 202 15 241 208 19 241 208 19 241 208 19 +241 208 19 204 160 10 184 138 11 210 150 10 216 158 10 210 150 10 98 70 6 2 2 6 +6 6 6 54 54 54 14 14 14 2 2 6 2 2 6 62 62 62 74 74 74 30 30 30 +10 10 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + +0 0 0 0 0 0 1 1 1 15 22 25 33 49 54 12 17 20 2 3 3 35 31 12 +56 77 35 20 16 6 1 1 1 18 25 28 21 31 35 11 15 17 1 1 1 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 10 10 10 34 34 34 78 78 78 50 50 50 6 6 6 +88 55 22 139 102 15 190 146 13 230 187 11 239 207 25 232 195 16 220 174 15 190 146 13 +171 120 8 192 133 9 210 150 10 213 154 11 185 146 40 165 152 80 101 98 89 2 2 6 +2 2 6 78 78 78 116 116 116 58 58 58 2 2 6 22 22 22 90 90 90 46 46 46 +18 18 18 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + +0 0 0 0 0 0 0 0 0 1 1 1 27 40 45 29 43 47 3 5 6 2 3 3 +8 7 3 1 1 1 17 23 26 31 45 49 15 22 25 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 10 10 10 38 38 38 86 86 86 50 50 50 6 6 6 +124 127 131 168 158 138 156 107 11 171 120 8 204 160 10 184 138 11 197 138 11 200 144 11 +206 145 10 206 145 10 197 138 11 198 179 130 195 195 195 198 198 198 170 170 170 14 14 14 +2 2 6 22 22 22 116 116 116 116 116 116 22 22 22 2 2 6 74 74 74 70 70 70 +30 30 30 10 10 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + +0 0 0 0 0 0 0 0 0 0 0 0 11 15 17 31 45 49 26 35 39 3 5 6 +0 0 0 7 12 13 27 40 45 18 25 28 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 6 6 6 18 18 18 50 50 50 101 101 101 26 26 26 10 10 10 +124 131 137 190 190 190 168 158 138 156 107 11 197 138 11 200 144 11 197 138 11 192 133 9 +180 123 7 185 146 40 198 179 130 187 187 187 202 202 202 221 221 221 214 214 214 66 66 66 +2 2 6 2 2 6 50 50 50 62 62 62 6 6 6 2 2 6 10 10 10 90 90 90 +50 50 50 18 18 18 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + +0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 15 22 25 36 54 60 18 25 28 +0 0 0 21 30 33 27 40 45 2 3 3 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 10 10 10 34 34 34 74 74 74 74 74 74 2 2 6 6 6 6 +151 151 151 198 198 198 190 190 190 168 158 138 148 132 55 156 107 11 156 107 11 169 125 40 +168 158 138 187 187 187 190 190 190 210 210 210 246 246 246 253 253 253 253 253 253 180 180 180 +6 6 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 62 62 62 +74 74 74 34 34 34 14 14 14 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 27 40 45 35 52 58 +18 25 28 35 52 58 17 23 26 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 10 10 10 22 22 22 54 54 54 94 94 94 18 18 18 2 2 6 46 46 46 +234 234 234 221 221 221 190 190 190 190 190 190 190 190 190 187 187 187 187 187 187 190 190 190 +190 190 190 195 195 195 214 214 214 242 242 242 253 253 253 253 253 253 253 253 253 253 253 253 +82 82 82 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 14 14 14 +86 86 86 54 54 54 22 22 22 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 7 12 13 33 49 54 +52 72 81 36 54 60 6 8 8 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +6 6 6 18 18 18 46 46 46 90 90 90 46 46 46 18 18 18 6 6 6 180 180 180 +253 253 253 246 246 246 202 202 202 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 +202 202 202 231 231 231 250 250 250 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 +202 202 202 14 14 14 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 +42 42 42 86 86 86 42 42 42 18 18 18 6 6 6 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 12 17 20 +36 54 60 29 43 47 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 +14 14 14 38 38 38 74 74 74 66 66 66 2 2 6 6 6 6 90 90 90 250 250 250 +253 253 253 253 253 253 238 238 238 198 198 198 190 190 190 190 190 190 195 195 195 221 221 221 +246 246 246 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 +253 253 253 82 82 82 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 +2 2 6 78 78 78 70 70 70 34 34 34 14 14 14 6 6 6 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +21 30 33 35 52 58 6 8 12 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 14 14 14 +34 34 34 66 66 66 78 78 78 6 6 6 2 2 6 18 18 18 218 218 218 253 253 253 +253 253 253 253 253 253 253 253 253 246 246 246 226 226 226 231 231 231 246 246 246 253 253 253 +253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 +253 253 253 180 180 180 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 +2 2 6 18 18 18 90 90 90 62 62 62 30 30 30 10 10 10 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +12 17 20 36 54 60 29 43 47 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 10 10 26 26 26 +58 58 58 90 90 90 18 18 18 2 2 6 2 2 6 106 106 106 253 253 253 253 253 253 +253 253 253 253 253 253 253 253 253 253 253 253 250 250 250 253 253 253 253 253 253 253 253 253 +253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 +253 253 253 231 231 231 18 18 18 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 +2 2 6 2 2 6 18 18 18 94 94 94 54 54 54 26 26 26 10 10 10 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 21 30 33 35 52 58 6 8 12 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 22 22 22 50 50 50 +90 90 90 26 26 26 2 2 6 2 2 6 14 14 14 195 195 195 250 250 250 253 253 253 +253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 +253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 +250 250 250 242 242 242 54 54 54 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 +2 2 6 2 2 6 2 2 6 38 38 38 86 86 86 50 50 50 22 22 22 6 6 6 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 12 17 20 36 54 60 29 43 47 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 14 14 14 38 38 38 82 82 82 +34 34 34 2 2 6 2 2 6 2 2 6 42 42 42 195 195 195 246 246 246 253 253 253 +253 253 253 253 253 253 253 253 253 250 250 250 242 242 242 242 242 242 250 250 250 253 253 253 +253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 250 250 250 246 246 246 238 238 238 +226 226 226 231 231 231 101 101 101 6 6 6 2 2 6 2 2 6 2 2 6 2 2 6 +2 2 6 2 2 6 2 2 6 2 2 6 38 38 38 82 82 82 42 42 42 14 14 14 +6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 21 30 33 35 52 58 6 8 12 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 10 10 10 26 26 26 62 62 62 66 66 66 +2 2 6 2 2 6 2 2 6 6 6 6 70 70 70 170 170 170 202 202 202 234 234 234 +246 246 246 250 250 250 250 250 250 238 238 238 226 226 226 231 231 231 238 238 238 250 250 250 +250 250 250 250 250 250 246 246 246 231 231 231 214 214 214 202 202 202 202 202 202 202 202 202 +198 198 198 202 202 202 180 180 180 18 18 18 2 2 6 2 2 6 2 2 6 2 2 6 +2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 62 62 62 66 66 66 30 30 30 +10 10 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 12 17 20 36 54 60 29 43 47 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 14 14 14 42 42 42 82 82 82 18 18 18 +2 2 6 2 2 6 2 2 6 10 10 10 94 94 94 180 180 180 218 218 218 242 242 242 +250 250 250 253 253 253 253 253 253 250 250 250 234 234 234 253 253 253 253 253 253 253 253 253 +253 253 253 253 253 253 253 253 253 246 246 246 238 238 238 226 226 226 210 210 210 202 202 202 +195 195 195 195 195 195 210 210 210 151 151 151 6 6 6 14 14 14 50 50 50 14 14 14 +2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 6 6 6 86 86 86 46 46 46 +18 18 18 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 21 30 33 35 52 58 6 8 12 0 0 0 +0 0 0 0 0 0 0 0 0 6 6 6 22 22 22 54 54 54 70 70 70 2 2 6 +2 2 6 10 10 10 2 2 6 22 22 22 170 170 170 231 231 231 250 250 250 253 253 253 +253 253 253 253 253 253 253 253 253 250 250 250 242 242 242 253 253 253 253 253 253 253 253 253 +253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 246 246 246 +231 231 231 202 202 202 198 198 198 226 226 226 94 94 94 2 2 6 6 6 6 38 38 38 +30 30 30 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 62 62 62 66 66 66 +26 26 26 10 10 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 6 8 8 33 49 54 29 43 47 6 8 12 +0 0 0 0 0 0 0 0 0 10 10 10 30 30 30 74 74 74 50 50 50 2 2 6 +26 26 26 26 26 26 2 2 6 106 106 106 238 238 238 253 253 253 253 253 253 253 253 253 +253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 +253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 +253 253 253 246 246 246 218 218 218 202 202 202 210 210 210 14 14 14 2 2 6 2 2 6 +30 30 30 22 22 22 2 2 6 2 2 6 2 2 6 2 2 6 18 18 18 86 86 86 +42 42 42 14 14 14 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 12 17 20 33 49 54 17 23 26 +0 0 0 0 0 0 0 0 0 14 14 14 42 42 42 90 90 90 22 22 22 2 2 6 +42 42 42 2 2 6 18 18 18 218 218 218 253 253 253 253 253 253 253 253 253 253 253 253 +253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 +253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 +253 253 253 253 253 253 250 250 250 221 221 221 218 218 218 101 101 101 2 2 6 14 14 14 +18 18 18 38 38 38 10 10 10 2 2 6 2 2 6 2 2 6 2 2 6 78 78 78 +58 58 58 22 22 22 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 15 22 25 36 54 60 +0 0 0 0 0 0 0 0 0 18 18 18 54 54 54 82 82 82 2 2 6 26 26 26 +22 22 22 2 2 6 124 127 131 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 +253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 +253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 +253 253 253 253 253 253 253 253 253 250 250 250 238 238 238 198 198 198 6 6 6 38 38 38 +58 58 58 26 26 26 38 38 38 2 2 6 2 2 6 2 2 6 2 2 6 46 46 46 +78 78 78 30 30 30 10 10 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 21 30 33 +36 54 60 0 0 0 0 0 0 30 30 30 74 74 74 58 58 58 2 2 6 42 42 42 +2 2 6 22 22 22 231 231 231 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 +253 253 253 253 253 253 253 253 253 250 250 250 253 253 253 253 253 253 253 253 253 253 253 253 +253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 +253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 246 246 246 46 46 46 38 38 38 +42 42 42 14 14 14 38 38 38 14 14 14 2 2 6 2 2 6 2 2 6 6 6 6 +86 86 86 46 46 46 14 14 14 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +36 54 60 0 0 0 0 0 0 42 42 42 90 90 90 18 18 18 18 18 18 26 26 26 +2 2 6 116 116 116 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 +253 253 253 253 253 253 250 250 250 238 238 238 253 253 253 253 253 253 253 253 253 253 253 253 +253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 +253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 94 94 94 6 6 6 +2 2 6 2 2 6 10 10 10 34 34 34 2 2 6 2 2 6 2 2 6 2 2 6 +74 74 74 58 58 58 22 22 22 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 36 54 60 26 26 26 66 66 66 82 82 82 2 2 6 38 38 38 6 6 6 +14 14 14 210 210 210 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 +253 253 253 253 253 253 246 246 246 242 242 242 253 253 253 253 253 253 253 253 253 253 253 253 +253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 +253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 151 151 151 2 2 6 +2 2 6 2 2 6 2 2 6 46 46 46 2 2 6 2 2 6 2 2 6 2 2 6 +42 42 42 74 74 74 30 30 30 10 10 10 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +6 6 6 36 54 60 21 30 33 90 90 90 26 26 26 6 6 6 42 42 42 2 2 6 +74 74 74 250 250 250 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 +253 253 253 253 253 253 242 242 242 242 242 242 253 253 253 253 253 253 253 253 253 253 253 253 +253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 +253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 180 180 180 2 2 6 +2 2 6 2 2 6 2 2 6 46 46 46 2 2 6 2 2 6 2 2 6 2 2 6 +10 10 10 86 86 86 38 38 38 10 10 10 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +10 10 10 26 26 26 36 54 60 82 82 82 2 2 6 22 22 22 18 18 18 2 2 6 +151 151 151 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 +253 253 253 253 253 253 234 234 234 242 242 242 253 253 253 253 253 253 253 253 253 253 253 253 +253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 +253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 202 202 202 2 2 6 +2 2 6 2 2 6 2 2 6 38 38 38 2 2 6 2 2 6 2 2 6 2 2 6 +6 6 6 86 86 86 46 46 46 14 14 14 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 +18 18 18 46 46 46 86 86 86 36 54 60 2 2 6 34 34 34 10 10 10 6 6 6 +210 210 210 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 +253 253 253 253 253 253 234 234 234 242 242 242 253 253 253 253 253 253 253 253 253 253 253 253 +253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 +253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 221 221 221 6 6 6 +2 2 6 2 2 6 6 6 6 30 30 30 2 2 6 2 2 6 2 2 6 2 2 6 +2 2 6 82 82 82 54 54 54 18 18 18 6 6 6 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 10 10 +26 26 26 66 66 66 62 62 62 2 2 6 2 2 6 38 38 38 10 10 10 26 26 26 +238 238 238 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 +253 253 253 253 253 253 231 231 231 238 238 238 253 253 253 253 253 253 253 253 253 253 253 253 +253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 +253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 231 231 231 6 6 6 +2 2 6 2 2 6 10 10 10 30 30 30 2 2 6 2 2 6 2 2 6 2 2 6 +2 2 6 66 66 66 58 58 58 22 22 22 6 6 6 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 10 10 +38 38 38 78 78 78 6 6 6 2 2 6 2 2 6 46 46 46 14 14 14 42 42 42 +246 246 246 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 +253 253 253 253 253 253 231 231 231 242 242 242 253 253 253 253 253 253 253 253 253 253 253 253 +253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 +253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 234 234 234 10 10 10 +2 2 6 2 2 6 22 22 22 14 14 14 2 2 6 2 2 6 2 2 6 2 2 6 +2 2 6 66 66 66 62 62 62 22 22 22 6 6 6 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 18 18 18 +50 50 50 74 74 74 2 2 6 2 2 6 14 14 14 70 70 70 34 34 34 62 62 62 +250 250 250 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 +253 253 253 253 253 253 231 231 231 246 246 246 253 253 253 253 253 253 253 253 253 253 253 253 +253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 +253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 234 234 234 14 14 14 +2 2 6 2 2 6 30 30 30 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 +2 2 6 66 66 66 62 62 62 22 22 22 6 6 6 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 18 18 18 +54 54 54 62 62 62 2 2 6 2 2 6 2 2 6 30 30 30 46 46 46 70 70 70 +250 250 250 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 +253 253 253 253 253 253 231 231 231 246 246 246 253 253 253 253 253 253 253 253 253 253 253 253 +253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 +253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 226 226 226 10 10 10 +2 2 6 6 6 6 30 30 30 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 +2 2 6 66 66 66 58 58 58 22 22 22 6 6 6 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 22 22 22 +58 58 58 62 62 62 2 2 6 2 2 6 2 2 6 2 2 6 30 30 30 78 78 78 +250 250 250 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 +253 253 253 253 253 253 231 231 231 246 246 246 253 253 253 253 253 253 253 253 253 253 253 253 +253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 +253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 202 202 202 2 2 6 +22 22 22 34 34 34 20 16 6 22 22 22 26 26 26 18 18 18 6 6 6 2 2 6 +2 2 6 82 82 82 54 54 54 18 18 18 6 6 6 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 26 26 26 +62 62 62 106 106 106 63 55 20 184 138 11 204 160 10 121 92 8 6 6 6 62 62 62 +238 238 238 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 +253 253 253 253 253 253 231 231 231 246 246 246 253 253 253 253 253 253 253 253 253 253 253 253 +253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 +253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 151 151 151 18 18 18 +14 14 14 2 2 6 2 2 6 2 2 6 6 6 6 18 18 18 66 66 66 38 38 38 +6 6 6 94 94 94 50 50 50 18 18 18 6 6 6 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 6 6 6 10 10 10 10 10 10 18 18 18 38 38 38 +78 78 78 138 132 106 216 158 10 242 186 14 246 190 14 246 190 14 156 118 10 10 10 10 +90 90 90 238 238 238 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 +253 253 253 253 253 253 231 231 231 250 250 250 253 253 253 253 253 253 253 253 253 253 253 253 +253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 +253 253 253 253 253 253 253 253 253 246 230 190 214 187 87 214 187 87 185 146 40 35 31 12 +2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 38 38 38 46 46 46 +26 26 26 106 106 106 54 54 54 18 18 18 6 6 6 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 6 6 6 14 14 14 22 22 22 30 30 30 38 38 38 50 50 50 70 70 70 +106 106 106 185 146 40 226 170 11 242 186 14 246 190 14 246 190 14 246 190 14 154 114 10 +6 6 6 74 74 74 226 226 226 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 +253 253 253 253 253 253 231 231 231 250 250 250 253 253 253 253 253 253 253 253 253 253 253 253 +253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 +253 253 253 253 253 253 253 253 253 237 201 50 241 196 14 241 208 19 232 195 16 35 31 12 +2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 6 6 6 30 30 30 26 26 26 +204 160 10 165 152 80 66 66 66 26 26 26 6 6 6 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +6 6 6 18 18 18 38 38 38 58 58 58 78 78 78 86 86 86 101 101 101 124 127 131 +174 140 55 210 150 10 234 174 13 246 186 14 246 190 14 246 190 14 246 190 14 237 188 10 +98 70 6 2 2 6 46 46 46 198 198 198 253 253 253 253 253 253 253 253 253 253 253 253 +253 253 253 253 253 253 234 234 234 242 242 242 253 253 253 253 253 253 253 253 253 253 253 253 +253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 +253 253 253 253 253 253 253 253 253 214 187 87 242 186 14 241 196 14 204 160 10 20 16 6 +2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 6 6 6 121 92 8 +238 202 15 232 195 16 82 82 82 34 34 34 10 10 10 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +14 14 14 38 38 38 70 70 70 148 132 55 185 146 40 200 144 11 197 138 11 197 138 11 +213 154 11 226 170 11 242 186 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 +220 174 15 35 31 12 2 2 6 22 22 22 151 151 151 250 250 250 253 253 253 253 253 253 +253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 +253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 +253 253 253 250 250 250 242 242 242 214 187 87 239 182 13 237 188 10 213 154 11 35 31 12 +2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 62 42 6 220 174 15 +237 188 10 237 188 10 113 101 86 42 42 42 14 14 14 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 +22 22 22 54 54 54 148 132 55 213 154 11 226 170 11 230 174 11 226 170 11 226 170 11 +236 178 12 242 186 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 +241 196 14 184 138 11 10 10 10 2 2 6 6 6 6 116 116 116 242 242 242 253 253 253 +253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 +253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 +253 253 253 231 231 231 198 198 198 213 164 39 236 178 12 236 178 12 210 150 10 137 92 6 +20 16 6 2 2 6 2 2 6 2 2 6 6 6 6 62 42 6 200 144 11 236 178 12 +239 182 13 239 182 13 124 112 88 58 58 58 22 22 22 6 6 6 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 10 10 +30 30 30 70 70 70 169 125 40 226 170 11 239 182 13 242 186 14 242 186 14 246 186 14 +246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 +246 190 14 232 195 16 98 70 6 2 2 6 2 2 6 2 2 6 66 66 66 221 221 221 +253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 +253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 +253 253 253 202 202 202 198 198 198 213 164 39 230 174 11 230 174 11 216 158 10 192 133 9 +163 110 8 120 80 7 98 70 6 120 80 7 167 114 7 197 138 11 226 170 11 239 182 13 +242 186 14 242 186 14 165 152 80 78 78 78 34 34 34 14 14 14 6 6 6 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 +30 30 30 78 78 78 185 146 40 226 170 11 239 182 13 246 190 14 246 190 14 246 190 14 +246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 +246 190 14 241 196 14 204 160 10 20 16 6 2 2 6 2 2 6 2 2 6 38 38 38 +218 218 218 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 +253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 +250 250 250 202 202 202 198 198 198 213 164 39 226 170 11 236 178 12 224 166 10 210 150 10 +200 144 11 197 138 11 192 133 9 197 138 11 210 150 10 226 170 11 242 186 14 246 190 14 +246 190 14 246 186 14 220 174 15 124 112 88 62 62 62 30 30 30 14 14 14 6 6 6 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 10 10 +30 30 30 78 78 78 174 140 55 224 166 10 239 182 13 246 190 14 246 190 14 246 190 14 +246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 +246 190 14 246 190 14 241 196 14 139 102 15 2 2 6 2 2 6 2 2 6 2 2 6 +78 78 78 250 250 250 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 +253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 +250 250 250 214 214 214 198 198 198 185 146 40 219 162 10 236 178 12 234 174 13 224 166 10 +216 158 10 213 154 11 213 154 11 216 158 10 226 170 11 239 182 13 246 190 14 246 190 14 +246 190 14 246 190 14 242 186 14 213 164 39 101 101 101 58 58 58 30 30 30 14 14 14 +6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 10 10 +30 30 30 74 74 74 174 140 55 216 158 10 236 178 12 246 190 14 246 190 14 246 190 14 +246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 +246 190 14 246 190 14 241 196 14 230 187 11 62 42 6 2 2 6 2 2 6 2 2 6 +22 22 22 238 238 238 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 +253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 +253 253 253 226 226 226 187 187 187 169 125 40 216 158 10 236 178 12 239 182 13 236 178 12 +230 174 11 226 170 11 226 170 11 230 174 11 236 178 12 242 186 14 246 190 14 246 190 14 +246 190 14 246 190 14 246 186 14 239 182 13 213 164 39 106 106 106 66 66 66 34 34 34 +14 14 14 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 +26 26 26 70 70 70 149 139 69 213 154 11 236 178 12 246 190 14 246 190 14 246 190 14 +246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 +246 190 14 246 190 14 246 190 14 241 196 14 190 146 13 20 16 6 2 2 6 2 2 6 +46 46 46 246 246 246 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 +253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 +253 253 253 221 221 221 86 86 86 156 107 11 216 158 10 236 178 12 242 186 14 246 186 14 +242 186 14 239 182 13 239 182 13 242 186 14 242 186 14 246 186 14 246 190 14 246 190 14 +246 190 14 246 190 14 246 190 14 246 190 14 242 186 14 220 174 15 149 139 69 66 66 66 +30 30 30 10 10 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 +26 26 26 70 70 70 149 139 69 210 150 10 236 178 12 246 190 14 246 190 14 246 190 14 +246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 +246 190 14 246 190 14 246 190 14 246 190 14 232 195 16 121 92 8 34 34 34 106 106 106 +221 221 221 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 +253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 +242 242 242 82 82 82 20 16 6 163 110 8 216 158 10 236 178 12 242 186 14 246 190 14 +246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 +246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 242 186 14 149 139 69 +46 46 46 18 18 18 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 10 10 +30 30 30 78 78 78 149 139 69 210 150 10 236 178 12 246 186 14 246 190 14 246 190 14 +246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 +246 190 14 246 190 14 246 190 14 246 190 14 241 196 14 220 174 15 198 179 130 253 253 253 +253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 +253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 218 218 218 +58 58 58 2 2 6 20 16 6 167 114 7 216 158 10 236 178 12 246 186 14 246 190 14 +246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 +246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 186 14 242 186 14 185 146 40 +54 54 54 22 22 22 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 14 14 14 +38 38 38 86 86 86 169 125 40 213 154 11 236 178 12 246 186 14 246 190 14 246 190 14 +246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 +246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 232 195 16 190 146 13 214 214 214 +253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 +253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 250 250 250 170 170 170 26 26 26 +2 2 6 2 2 6 35 31 12 163 110 8 219 162 10 239 182 13 246 186 14 246 190 14 +246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 +246 190 14 246 190 14 246 190 14 246 190 14 246 186 14 236 178 12 224 166 10 149 139 69 +46 46 46 18 18 18 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 18 18 18 +50 50 50 113 101 86 192 133 9 224 166 10 242 186 14 246 190 14 246 190 14 246 190 14 +246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 +246 190 14 246 190 14 246 190 14 246 190 14 242 186 14 230 187 11 204 160 10 133 118 54 +226 226 226 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 +253 253 253 253 253 253 253 253 253 253 253 253 198 198 198 66 66 66 2 2 6 2 2 6 +2 2 6 2 2 6 62 42 6 156 107 11 219 162 10 239 182 13 246 186 14 246 190 14 +246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 +246 190 14 246 190 14 246 190 14 242 186 14 234 174 13 213 154 11 148 132 55 66 66 66 +30 30 30 10 10 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 22 22 22 +58 58 58 148 132 55 206 145 10 234 174 13 242 186 14 246 186 14 246 190 14 246 190 14 +246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 +246 190 14 246 190 14 246 190 14 246 190 14 246 186 14 236 178 12 204 160 10 163 110 8 +62 42 6 124 131 137 218 218 218 250 250 250 253 253 253 253 253 253 253 253 253 250 250 250 +242 242 242 210 210 210 151 151 151 66 66 66 6 6 6 2 2 6 2 2 6 2 2 6 +2 2 6 2 2 6 62 42 6 163 110 8 216 158 10 236 178 12 246 190 14 246 190 14 +246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 +246 190 14 239 182 13 230 174 11 216 158 10 185 146 40 124 112 88 70 70 70 38 38 38 +18 18 18 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 22 22 22 +62 62 62 169 125 40 206 145 10 224 166 10 236 178 12 239 182 13 242 186 14 242 186 14 +246 186 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 +246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 236 178 12 216 158 10 171 120 8 +85 57 6 2 2 6 6 6 6 30 30 30 54 54 54 62 62 62 50 50 50 38 38 38 +14 14 14 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 +2 2 6 6 6 6 85 57 6 167 114 7 213 154 11 236 178 12 246 190 14 246 190 14 +246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 242 186 14 239 182 13 239 182 13 +230 174 11 210 150 10 174 140 55 124 112 88 82 82 82 54 54 54 34 34 34 18 18 18 +6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 18 18 18 +50 50 50 169 125 40 192 133 9 200 144 11 216 158 10 219 162 10 224 166 10 226 170 11 +230 174 11 236 178 12 239 182 13 239 182 13 242 186 14 246 186 14 246 190 14 246 190 14 +246 190 14 246 190 14 246 190 14 246 190 14 246 186 14 230 174 11 210 150 10 163 110 8 +104 69 6 10 10 10 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 +2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 +2 2 6 6 6 6 85 57 6 167 114 7 206 145 10 230 174 11 242 186 14 246 190 14 +246 190 14 246 190 14 246 186 14 242 186 14 239 182 13 230 174 11 224 166 10 213 154 11 +169 125 40 124 112 88 86 86 86 58 58 58 38 38 38 22 22 22 10 10 10 6 6 6 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 14 14 14 +34 34 34 70 70 70 133 118 54 169 125 40 167 114 7 180 123 7 192 133 9 197 138 11 +200 144 11 206 145 10 213 154 11 219 162 10 224 166 10 230 174 11 239 182 13 242 186 14 +246 186 14 246 186 14 246 186 14 246 186 14 239 182 13 216 158 10 184 138 11 152 99 6 +104 69 6 20 16 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 +2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 +2 2 6 6 6 6 85 57 6 152 99 6 192 133 9 219 162 10 236 178 12 239 182 13 +246 186 14 242 186 14 239 182 13 236 178 12 224 166 10 206 145 10 192 133 9 148 132 55 +94 94 94 62 62 62 42 42 42 22 22 22 14 14 14 6 6 6 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 +18 18 18 34 34 34 58 58 58 78 78 78 101 98 89 124 112 88 133 118 54 156 107 11 +163 110 8 167 114 7 171 120 8 180 123 7 184 138 11 197 138 11 210 150 10 219 162 10 +226 170 11 236 178 12 236 178 12 234 174 13 219 162 10 197 138 11 163 110 8 134 84 6 +85 57 6 10 10 10 2 2 6 2 2 6 18 18 18 38 38 38 38 38 38 38 38 38 +38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 26 26 26 2 2 6 +2 2 6 6 6 6 62 42 6 137 92 6 171 120 8 200 144 11 219 162 10 230 174 11 +234 174 13 230 174 11 219 162 10 210 150 10 192 133 9 163 110 8 124 112 88 82 82 82 +50 50 50 30 30 30 14 14 14 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +6 6 6 14 14 14 22 22 22 34 34 34 42 42 42 58 58 58 74 74 74 86 86 86 +101 98 89 113 101 86 133 118 54 121 92 8 137 92 6 152 99 6 163 110 8 180 123 7 +184 138 11 197 138 11 206 145 10 200 144 11 180 123 7 156 107 11 134 84 6 104 69 6 +62 42 6 54 54 54 106 106 106 101 98 89 86 86 86 82 82 82 78 78 78 78 78 78 +78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 82 82 82 86 86 86 94 94 94 +106 106 106 101 101 101 90 61 47 120 80 7 156 107 11 180 123 7 192 133 9 200 144 11 +206 145 10 200 144 11 192 133 9 171 120 8 139 102 15 113 101 86 70 70 70 42 42 42 +22 22 22 10 10 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 6 6 6 10 10 10 14 14 14 22 22 22 30 30 30 38 38 38 +50 50 50 62 62 62 74 74 74 90 90 90 101 98 89 113 101 86 121 92 8 120 80 7 +137 92 6 152 99 6 152 99 6 152 99 6 134 84 6 120 80 7 98 70 6 88 55 22 +101 98 89 82 82 82 58 58 58 46 46 46 38 38 38 34 34 34 34 34 34 34 34 34 +34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 38 38 38 42 42 42 +54 54 54 82 82 82 94 86 71 85 57 6 134 84 6 156 107 11 167 114 7 171 120 8 +171 120 8 167 114 7 152 99 6 121 92 8 101 98 89 62 62 62 34 34 34 18 18 18 +6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 6 6 6 10 10 10 +18 18 18 22 22 22 30 30 30 42 42 42 50 50 50 66 66 66 86 86 86 101 98 89 +94 86 71 98 70 6 104 69 6 104 69 6 104 69 6 85 57 6 88 55 22 90 90 90 +62 62 62 38 38 38 22 22 22 14 14 14 10 10 10 10 10 10 10 10 10 10 10 10 +10 10 10 10 10 10 6 6 6 10 10 10 10 10 10 10 10 10 10 10 10 14 14 14 +22 22 22 42 42 42 70 70 70 94 86 71 85 57 6 104 69 6 120 80 7 137 92 6 +134 84 6 120 80 7 94 86 71 86 86 86 58 58 58 30 30 30 14 14 14 6 6 6 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 6 6 6 10 10 10 14 14 14 18 18 18 26 26 26 38 38 38 54 54 54 +70 70 70 86 86 86 94 86 71 94 86 71 94 86 71 86 86 86 74 74 74 50 50 50 +30 30 30 14 14 14 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +6 6 6 18 18 18 34 34 34 58 58 58 82 82 82 94 86 71 94 86 71 94 86 71 +94 86 71 94 86 71 74 74 74 50 50 50 26 26 26 14 14 14 6 6 6 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 6 6 6 14 14 14 18 18 18 +30 30 30 38 38 38 46 46 46 54 54 54 50 50 50 42 42 42 30 30 30 18 18 18 +10 10 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 6 6 6 14 14 14 26 26 26 38 38 38 50 50 50 58 58 58 58 58 58 +54 54 54 42 42 42 30 30 30 18 18 18 10 10 10 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 +6 6 6 10 10 10 14 14 14 18 18 18 18 18 18 14 14 14 10 10 10 6 6 6 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 6 6 6 14 14 14 18 18 18 22 22 22 22 22 22 +18 18 18 14 14 14 10 10 10 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + From 0b905d83c4db7ae98718c44d79c717836a2ecaa7 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Thu, 11 Jul 2013 10:21:00 +0530 Subject: [PATCH 0893/1048] hwmon: (abx500) Staticize abx500_temp_attributes abx500_temp_attributes is used only in this file. Make it static. Signed-off-by: Sachin Kamat Signed-off-by: Guenter Roeck --- drivers/hwmon/abx500.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwmon/abx500.c b/drivers/hwmon/abx500.c index eee1134274c8..769fe20ec938 100644 --- a/drivers/hwmon/abx500.c +++ b/drivers/hwmon/abx500.c @@ -315,7 +315,7 @@ static SENSOR_DEVICE_ATTR(temp4_max_hyst, S_IWUSR | S_IRUGO, static SENSOR_DEVICE_ATTR(temp4_min_alarm, S_IRUGO, show_min_alarm, NULL, 3); static SENSOR_DEVICE_ATTR(temp4_max_alarm, S_IRUGO, show_max_alarm, NULL, 3); -struct attribute *abx500_temp_attributes[] = { +static struct attribute *abx500_temp_attributes[] = { &sensor_dev_attr_name.dev_attr.attr, &sensor_dev_attr_temp1_label.dev_attr.attr, From 3a391a39593b48341f0908511590a6c0e55cc069 Mon Sep 17 00:00:00 2001 From: "Rafael J. Wysocki" Date: Fri, 12 Jul 2013 13:45:59 +0200 Subject: [PATCH 0894/1048] ACPI / scan: Do not try to attach scan handlers to devices having them In acpi_bus_device_attach(), if there is an ACPI device object for the given handle and that device object has a scan handler attached to it already, there's nothing more to do for that handle. Moreover, if acpi_scan_attach_handler() is called then, it may execute the .attach() callback of the ACPI scan handler already attached to the device object and that may lead to interesting breakage. For this reason, make acpi_bus_device_attach() return success immediately when the handle's device object has a scan handler attached to it. Reported-by: Toshi Kani Signed-off-by: Rafael J. Wysocki Acked-by: Toshi Kani Cc: 3.10+ --- drivers/acpi/scan.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index 10985573aaa7..080d75962c57 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c @@ -1981,6 +1981,9 @@ static acpi_status acpi_bus_device_attach(acpi_handle handle, u32 lvl_not_used, if (acpi_bus_get_device(handle, &device)) return AE_CTRL_DEPTH; + if (device->handler) + return AE_OK; + ret = acpi_scan_attach_handler(device); if (ret) return ret > 0 ? AE_OK : AE_CTRL_DEPTH; From 8832f7e43fa7f0f19bd54e13766a825dd1ed4d6f Mon Sep 17 00:00:00 2001 From: "Rafael J. Wysocki" Date: Mon, 8 Jul 2013 02:01:53 +0200 Subject: [PATCH 0895/1048] ACPI / scan: Always call acpi_bus_scan() for bus check notifications An ACPI_NOTIFY_BUS_CHECK notification means that we should scan the entire namespace starting from the given handle even if the device represented by that handle is present (other devices below it may just have appeared). For this reason, modify acpi_scan_bus_device_check() to always run acpi_bus_scan() if the notification being handled is of type ACPI_NOTIFY_BUS_CHECK. Signed-off-by: Rafael J. Wysocki Acked-by: Toshi Kani Cc: 3.10+ --- drivers/acpi/scan.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index 080d75962c57..8a46c924effd 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c @@ -352,10 +352,12 @@ static void acpi_scan_bus_device_check(acpi_handle handle, u32 ost_source) mutex_lock(&acpi_scan_lock); lock_device_hotplug(); - acpi_bus_get_device(handle, &device); - if (device) { - dev_warn(&device->dev, "Attempt to re-insert\n"); - goto out; + if (ost_source != ACPI_NOTIFY_BUS_CHECK) { + acpi_bus_get_device(handle, &device); + if (device) { + dev_warn(&device->dev, "Attempt to re-insert\n"); + goto out; + } } acpi_evaluate_hotplug_ost(handle, ost_source, ACPI_OST_SC_INSERT_IN_PROGRESS, NULL); From d19f503e22316a84c39bc19445e0e4fdd49b3532 Mon Sep 17 00:00:00 2001 From: Toshi Kani Date: Wed, 10 Jul 2013 10:47:13 -0600 Subject: [PATCH 0896/1048] ACPI / memhotplug: Fix a stale pointer in error path device->driver_data needs to be cleared when releasing its data, mem_device, in an error path of acpi_memory_device_add(). The function evaluates the _CRS of memory device objects, and fails when it gets an unexpected resource or cannot allocate memory. A kernel crash or data corruption may occur when the kernel accesses the stale pointer. Signed-off-by: Toshi Kani Reviewed-by: Yasuaki Ishimatsu Cc: 2.6.32+ Signed-off-by: Rafael J. Wysocki --- drivers/acpi/acpi_memhotplug.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/acpi/acpi_memhotplug.c b/drivers/acpi/acpi_memhotplug.c index c711d1144044..999adb5499c7 100644 --- a/drivers/acpi/acpi_memhotplug.c +++ b/drivers/acpi/acpi_memhotplug.c @@ -323,6 +323,7 @@ static int acpi_memory_device_add(struct acpi_device *device, /* Get the range from the _CRS */ result = acpi_memory_get_device_resources(mem_device); if (result) { + device->driver_data = NULL; kfree(mem_device); return result; } From aae760ed21cd690fe8a6db9f3a177ad55d7e12ab Mon Sep 17 00:00:00 2001 From: "Srivatsa S. Bhat" Date: Fri, 12 Jul 2013 03:45:37 +0530 Subject: [PATCH 0897/1048] cpufreq: Revert commit a66b2e to fix suspend/resume regression commit a66b2e (cpufreq: Preserve sysfs files across suspend/resume) has unfortunately caused several things in the cpufreq subsystem to break subtly after a suspend/resume cycle. The intention of that patch was to retain the file permissions of the cpufreq related sysfs files across suspend/resume. To achieve that, the commit completely removed the calls to cpufreq_add_dev() and __cpufreq_remove_dev() during suspend/resume transitions. But the problem is that those functions do 2 kinds of things: 1. Low-level initialization/tear-down that are critical to the correct functioning of cpufreq-core. 2. Kobject and sysfs related initialization/teardown. Ideally we should have reorganized the code to cleanly separate these two responsibilities, and skipped only the sysfs related parts during suspend/resume. Since we skipped the entire callbacks instead (which also included some CPU and cpufreq-specific critical components), cpufreq subsystem started behaving erratically after suspend/resume. So revert the commit to fix the regression. We'll revisit and address the original goal of that commit separately, since it involves quite a bit of careful code reorganization and appears to be non-trivial. (While reverting the commit, note that another commit f51e1eb (cpufreq: Fix cpufreq regression after suspend/resume) already reverted part of the original set of changes. So revert only the remaining ones). Signed-off-by: Srivatsa S. Bhat Acked-by: Viresh Kumar Tested-by: Paul Bolle Cc: 3.10+ Signed-off-by: Rafael J. Wysocki --- drivers/cpufreq/cpufreq.c | 4 +++- drivers/cpufreq/cpufreq_stats.c | 6 ++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 0937b8d6c2a4..7dcfa6854833 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -1942,13 +1942,15 @@ static int __cpuinit cpufreq_cpu_callback(struct notifier_block *nfb, if (dev) { switch (action) { case CPU_ONLINE: + case CPU_ONLINE_FROZEN: cpufreq_add_dev(dev, NULL); break; case CPU_DOWN_PREPARE: - case CPU_UP_CANCELED_FROZEN: + case CPU_DOWN_PREPARE_FROZEN: __cpufreq_remove_dev(dev, NULL); break; case CPU_DOWN_FAILED: + case CPU_DOWN_FAILED_FROZEN: cpufreq_add_dev(dev, NULL); break; } diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c index cd9e81713a71..12225d19ffcb 100644 --- a/drivers/cpufreq/cpufreq_stats.c +++ b/drivers/cpufreq/cpufreq_stats.c @@ -353,13 +353,11 @@ static int __cpuinit cpufreq_stat_cpu_callback(struct notifier_block *nfb, cpufreq_update_policy(cpu); break; case CPU_DOWN_PREPARE: + case CPU_DOWN_PREPARE_FROZEN: cpufreq_stats_free_sysfs(cpu); break; case CPU_DEAD: - cpufreq_stats_free_table(cpu); - break; - case CPU_UP_CANCELED_FROZEN: - cpufreq_stats_free_sysfs(cpu); + case CPU_DEAD_FROZEN: cpufreq_stats_free_table(cpu); break; } From e5248a111bf4048a9f3fab1a9c94c4630a10592a Mon Sep 17 00:00:00 2001 From: Liu ShuoX Date: Thu, 11 Jul 2013 16:03:45 +0800 Subject: [PATCH 0898/1048] PM / Sleep: avoid 'autosleep' in shutdown progress Prevent automatic system suspend from happening during system shutdown by making try_to_suspend() check system_state and return immediately if it is not SYSTEM_RUNNING. This prevents the following breakage from happening (scenario from Zhang Yanmin): Kernel starts shutdown and calls all device driver's shutdown callback. When a driver's shutdown is called, the last wakelock is released and suspend-to-ram starts. However, as some driver's shut down callbacks already shut down devices and disabled runtime pm, the suspend-to-ram calls driver's suspend callback without noticing that device is already off and causes crash. [rjw: Changelog] Signed-off-by: Liu ShuoX Cc: 3.5+ Signed-off-by: Rafael J. Wysocki --- kernel/power/autosleep.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kernel/power/autosleep.c b/kernel/power/autosleep.c index c6422ffeda9a..9012ecf7b814 100644 --- a/kernel/power/autosleep.c +++ b/kernel/power/autosleep.c @@ -32,7 +32,8 @@ static void try_to_suspend(struct work_struct *work) mutex_lock(&autosleep_lock); - if (!pm_save_wakeup_count(initial_count)) { + if (!pm_save_wakeup_count(initial_count) || + system_state != SYSTEM_RUNNING) { mutex_unlock(&autosleep_lock); goto out; } From 1258ca805f613025ec079d959d4a78acfb1f79d3 Mon Sep 17 00:00:00 2001 From: Chanwoo Choi Date: Thu, 11 Jul 2013 13:55:58 +0900 Subject: [PATCH 0899/1048] PM / Sleep: Fix comment typo in pm_wakeup.h Fix a comment typo (sorce -> source) in pm_wakeup.h. [rjw: Changelog] Signed-off-by: Chanwoo Choi Signed-off-by: Rafael J. Wysocki --- include/linux/pm_wakeup.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/linux/pm_wakeup.h b/include/linux/pm_wakeup.h index 569781faa504..a0f70808d7f4 100644 --- a/include/linux/pm_wakeup.h +++ b/include/linux/pm_wakeup.h @@ -36,8 +36,8 @@ * @last_time: Monotonic clock when the wakeup source's was touched last time. * @prevent_sleep_time: Total time this source has been preventing autosleep. * @event_count: Number of signaled wakeup events. - * @active_count: Number of times the wakeup sorce was activated. - * @relax_count: Number of times the wakeup sorce was deactivated. + * @active_count: Number of times the wakeup source was activated. + * @relax_count: Number of times the wakeup source was deactivated. * @expire_count: Number of times the wakeup source's timeout has expired. * @wakeup_count: Number of times the wakeup source might abort suspend. * @active: Status of the wakeup source. From 4a6c41083df3bf4ad828c45e5f8ee1a224d537c6 Mon Sep 17 00:00:00 2001 From: Paul Bolle Date: Sun, 14 Jul 2013 20:29:56 +0200 Subject: [PATCH 0900/1048] cpufreq: s3c24xx: rename CONFIG_CPU_FREQ_S3C24XX_DEBUGFS The Kconfig symbol CPU_FREQ_S3C24XX_DEBUGFS was renamed to ARM_S3C24XX_CPUFREQ_DEBUGFS in commit f023f8dd59 ("cpufreq: s3c24xx: move cpufreq driver to drivers/cpufreq"). But that commit missed one instance of its macro CONFIG_CPU_FREQ_S3C24XX_DEBUGFS. Rename it too. Signed-off-by: Paul Bolle Signed-off-by: Rafael J. Wysocki --- drivers/cpufreq/s3c24xx-cpufreq.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/cpufreq/s3c24xx-cpufreq.c b/drivers/cpufreq/s3c24xx-cpufreq.c index 3513e7477160..87781eb20d6d 100644 --- a/drivers/cpufreq/s3c24xx-cpufreq.c +++ b/drivers/cpufreq/s3c24xx-cpufreq.c @@ -49,7 +49,7 @@ static struct clk *clk_hclk; static struct clk *clk_pclk; static struct clk *clk_arm; -#ifdef CONFIG_CPU_FREQ_S3C24XX_DEBUGFS +#ifdef CONFIG_ARM_S3C24XX_CPUFREQ_DEBUGFS struct s3c_cpufreq_config *s3c_cpufreq_getconfig(void) { return &cpu_cur; @@ -59,7 +59,7 @@ struct s3c_iotimings *s3c_cpufreq_getiotimings(void) { return &s3c24xx_iotiming; } -#endif /* CONFIG_CPU_FREQ_S3C24XX_DEBUGFS */ +#endif /* CONFIG_ARM_S3C24XX_CPUFREQ_DEBUGFS */ static void s3c_cpufreq_getcur(struct s3c_cpufreq_config *cfg) { From ab39c77c3246f8462663fb1b07fa193f3e31e255 Mon Sep 17 00:00:00 2001 From: Paul Gortmaker Date: Mon, 17 Jun 2013 15:43:14 -0400 Subject: [PATCH 0901/1048] alpha: delete __cpuinit usage from all users The __cpuinit type of throwaway sections might have made sense some time ago when RAM was more constrained, but now the savings do not offset the cost and complications. For example, the fix in commit 5e427ec2d0 ("x86: Fix bit corruption at CPU resume time") is a good example of the nasty type of bugs that can be created with improper use of the various __init prefixes. After a discussion on LKML[1] it was decided that cpuinit should go the way of devinit and be phased out. Once all the users are gone, we can then finally remove the macros themselves from linux/init.h. This removes all the alpha uses of the __cpuinit macros. [1] https://lkml.org/lkml/2013/5/20/589 Cc: Richard Henderson Cc: Ivan Kokshaysky Cc: Matt Turner Signed-off-by: Paul Gortmaker --- arch/alpha/kernel/smp.c | 10 +++++----- arch/alpha/kernel/traps.c | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/arch/alpha/kernel/smp.c b/arch/alpha/kernel/smp.c index 7b60834fb4b2..53b18a620e1c 100644 --- a/arch/alpha/kernel/smp.c +++ b/arch/alpha/kernel/smp.c @@ -116,7 +116,7 @@ wait_boot_cpu_to_stop(int cpuid) /* * Where secondaries begin a life of C. */ -void __cpuinit +void smp_callin(void) { int cpuid = hard_smp_processor_id(); @@ -194,7 +194,7 @@ wait_for_txrdy (unsigned long cpumask) * Send a message to a secondary's console. "START" is one such * interesting message. ;-) */ -static void __cpuinit +static void send_secondary_console_msg(char *str, int cpuid) { struct percpu_struct *cpu; @@ -285,7 +285,7 @@ recv_secondary_console_msg(void) /* * Convince the console to have a secondary cpu begin execution. */ -static int __cpuinit +static int secondary_cpu_start(int cpuid, struct task_struct *idle) { struct percpu_struct *cpu; @@ -356,7 +356,7 @@ secondary_cpu_start(int cpuid, struct task_struct *idle) /* * Bring one cpu online. */ -static int __cpuinit +static int smp_boot_one_cpu(int cpuid, struct task_struct *idle) { unsigned long timeout; @@ -472,7 +472,7 @@ smp_prepare_boot_cpu(void) { } -int __cpuinit +int __cpu_up(unsigned int cpu, struct task_struct *tidle) { smp_boot_one_cpu(cpu, tidle); diff --git a/arch/alpha/kernel/traps.c b/arch/alpha/kernel/traps.c index affccb959a9e..be1fba334bd0 100644 --- a/arch/alpha/kernel/traps.c +++ b/arch/alpha/kernel/traps.c @@ -32,7 +32,7 @@ static int opDEC_fix; -static void __cpuinit +static void opDEC_check(void) { __asm__ __volatile__ ( @@ -1059,7 +1059,7 @@ give_sigbus: return; } -void __cpuinit +void trap_init(void) { /* Tell PAL-code what global pointer we want in the kernel. */ From 60ffef065dd40b91f6f76af6c7510ddf23102f54 Mon Sep 17 00:00:00 2001 From: Paul Gortmaker Date: Mon, 17 Jun 2013 15:43:14 -0400 Subject: [PATCH 0902/1048] parisc: delete __cpuinit usage from all users The __cpuinit type of throwaway sections might have made sense some time ago when RAM was more constrained, but now the savings do not offset the cost and complications. For example, the fix in commit 5e427ec2d0 ("x86: Fix bit corruption at CPU resume time") is a good example of the nasty type of bugs that can be created with improper use of the various __init prefixes. After a discussion on LKML[1] it was decided that cpuinit should go the way of devinit and be phased out. Once all the users are gone, we can then finally remove the macros themselves from linux/init.h. This removes all the parisc uses of the __cpuinit macros. [1] https://lkml.org/lkml/2013/5/20/589 Acked-by: James Bottomley Cc: Helge Deller Cc: linux-parisc@vger.kernel.org Signed-off-by: Paul Gortmaker --- arch/parisc/kernel/firmware.c | 14 ++++++++------ arch/parisc/kernel/hardware.c | 2 +- arch/parisc/kernel/processor.c | 6 +++--- arch/parisc/kernel/smp.c | 8 ++++---- 4 files changed, 16 insertions(+), 14 deletions(-) diff --git a/arch/parisc/kernel/firmware.c b/arch/parisc/kernel/firmware.c index f65fa480c905..22395901d47b 100644 --- a/arch/parisc/kernel/firmware.c +++ b/arch/parisc/kernel/firmware.c @@ -150,7 +150,7 @@ static void convert_to_wide(unsigned long *addr) } #ifdef CONFIG_64BIT -void __cpuinit set_firmware_width_unlocked(void) +void set_firmware_width_unlocked(void) { int ret; @@ -167,7 +167,7 @@ void __cpuinit set_firmware_width_unlocked(void) * This function must be called before any pdc_* function that uses the * convert_to_wide function. */ -void __cpuinit set_firmware_width(void) +void set_firmware_width(void) { unsigned long flags; spin_lock_irqsave(&pdc_lock, flags); @@ -175,11 +175,13 @@ void __cpuinit set_firmware_width(void) spin_unlock_irqrestore(&pdc_lock, flags); } #else -void __cpuinit set_firmware_width_unlocked(void) { +void set_firmware_width_unlocked(void) +{ return; } -void __cpuinit set_firmware_width(void) { +void set_firmware_width(void) +{ return; } #endif /*CONFIG_64BIT*/ @@ -301,7 +303,7 @@ int pdc_chassis_warn(unsigned long *warn) return retval; } -int __cpuinit pdc_coproc_cfg_unlocked(struct pdc_coproc_cfg *pdc_coproc_info) +int pdc_coproc_cfg_unlocked(struct pdc_coproc_cfg *pdc_coproc_info) { int ret; @@ -322,7 +324,7 @@ int __cpuinit pdc_coproc_cfg_unlocked(struct pdc_coproc_cfg *pdc_coproc_info) * This PDC call returns the presence and status of all the coprocessors * attached to the processor. */ -int __cpuinit pdc_coproc_cfg(struct pdc_coproc_cfg *pdc_coproc_info) +int pdc_coproc_cfg(struct pdc_coproc_cfg *pdc_coproc_info) { int ret; unsigned long flags; diff --git a/arch/parisc/kernel/hardware.c b/arch/parisc/kernel/hardware.c index 872275659d98..06cb3992907e 100644 --- a/arch/parisc/kernel/hardware.c +++ b/arch/parisc/kernel/hardware.c @@ -1367,7 +1367,7 @@ const char *parisc_hardware_description(struct parisc_device_id *id) /* Interpret hversion (ret[0]) from PDC_MODEL(4)/PDC_MODEL_INFO(0) */ -enum cpu_type __cpuinit +enum cpu_type parisc_get_cpu_type(unsigned long hversion) { struct hp_cpu_type_mask *ptr; diff --git a/arch/parisc/kernel/processor.c b/arch/parisc/kernel/processor.c index 8a96c8ab9fe6..b68d977ce30f 100644 --- a/arch/parisc/kernel/processor.c +++ b/arch/parisc/kernel/processor.c @@ -73,7 +73,7 @@ extern int update_cr16_clocksource(void); /* from time.c */ * * FIXME: doesn't do much yet... */ -static void __cpuinit +static void init_percpu_prof(unsigned long cpunum) { struct cpuinfo_parisc *p; @@ -92,7 +92,7 @@ init_percpu_prof(unsigned long cpunum) * (return 1). If so, initialize the chip and tell other partners in crime * they have work to do. */ -static int __cpuinit processor_probe(struct parisc_device *dev) +static int processor_probe(struct parisc_device *dev) { unsigned long txn_addr; unsigned long cpuid; @@ -299,7 +299,7 @@ void __init collect_boot_cpu_data(void) * * o Enable CPU profiling hooks. */ -int __cpuinit init_per_cpu(int cpunum) +int init_per_cpu(int cpunum) { int ret; struct pdc_coproc_cfg coproc_cfg; diff --git a/arch/parisc/kernel/smp.c b/arch/parisc/kernel/smp.c index e3614fb343e5..8a252f2d6c08 100644 --- a/arch/parisc/kernel/smp.c +++ b/arch/parisc/kernel/smp.c @@ -62,9 +62,9 @@ static int smp_debug_lvl = 0; volatile struct task_struct *smp_init_current_idle_task; /* track which CPU is booting */ -static volatile int cpu_now_booting __cpuinitdata; +static volatile int cpu_now_booting; -static int parisc_max_cpus __cpuinitdata = 1; +static int parisc_max_cpus = 1; static DEFINE_PER_CPU(spinlock_t, ipi_lock); @@ -328,7 +328,7 @@ void __init smp_callin(void) /* * Bring one cpu online. */ -int __cpuinit smp_boot_one_cpu(int cpuid, struct task_struct *idle) +int smp_boot_one_cpu(int cpuid, struct task_struct *idle) { const struct cpuinfo_parisc *p = &per_cpu(cpu_data, cpuid); long timeout; @@ -424,7 +424,7 @@ void smp_cpus_done(unsigned int cpu_max) } -int __cpuinit __cpu_up(unsigned int cpu, struct task_struct *tidle) +int __cpu_up(unsigned int cpu, struct task_struct *tidle) { if (cpu != 0 && cpu < parisc_max_cpus) smp_boot_one_cpu(cpu, tidle); From 078a55fc824c1633b3a507e4ad48b4637c1dfc18 Mon Sep 17 00:00:00 2001 From: Paul Gortmaker Date: Tue, 18 Jun 2013 13:38:59 +0000 Subject: [PATCH 0903/1048] MIPS: Delete __cpuinit/__CPUINIT usage from MIPS code commit 3747069b25e419f6b51395f48127e9812abc3596 upstream. The __cpuinit type of throwaway sections might have made sense some time ago when RAM was more constrained, but now the savings do not offset the cost and complications. For example, the fix in commit 5e427ec2d0 ("x86: Fix bit corruption at CPU resume time") is a good example of the nasty type of bugs that can be created with improper use of the various __init prefixes. After a discussion on LKML[1] it was decided that cpuinit should go the way of devinit and be phased out. Once all the users are gone, we can then finally remove the macros themselves from linux/init.h. Note that some harmless section mismatch warnings may result, since notify_cpu_starting() and cpu_up() are arch independent (kernel/cpu.c) and are flagged as __cpuinit -- so if we remove the __cpuinit from the arch specific callers, we will also get section mismatch warnings. As an intermediate step, we intend to turn the linux/init.h cpuinit related content into no-ops as early as possible, since that will get rid of these warnings. In any case, they are temporary and harmless. Here, we remove all the MIPS __cpuinit from C code and __CPUINIT from asm files. MIPS is interesting in this respect, because there are also uasm users hiding behind their own renamed versions of the __cpuinit macros. [1] https://lkml.org/lkml/2013/5/20/589 [ralf@linux-mips.org: Folded in Paul's followup fix.] Signed-off-by: Paul Gortmaker Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/5494/ Patchwork: https://patchwork.linux-mips.org/patch/5495/ Patchwork: https://patchwork.linux-mips.org/patch/5509/ Signed-off-by: Ralf Baechle --- arch/mips/ath79/setup.c | 2 +- arch/mips/cavium-octeon/octeon-irq.c | 12 +-- arch/mips/cavium-octeon/smp.c | 6 +- arch/mips/include/asm/uasm.h | 37 +++---- arch/mips/kernel/bmips_vec.S | 4 - arch/mips/kernel/cevt-bcm1480.c | 2 +- arch/mips/kernel/cevt-gic.c | 2 +- arch/mips/kernel/cevt-r4k.c | 2 +- arch/mips/kernel/cevt-sb1250.c | 2 +- arch/mips/kernel/cevt-smtc.c | 2 +- arch/mips/kernel/cpu-bugs64.c | 2 +- arch/mips/kernel/cpu-probe.c | 14 +-- arch/mips/kernel/head.S | 4 - arch/mips/kernel/smp-bmips.c | 6 +- arch/mips/kernel/smp-mt.c | 6 +- arch/mips/kernel/smp-up.c | 6 +- arch/mips/kernel/smp.c | 6 +- arch/mips/kernel/smtc.c | 2 +- arch/mips/kernel/spram.c | 14 +-- arch/mips/kernel/sync-r4k.c | 12 +-- arch/mips/kernel/traps.c | 12 +-- arch/mips/kernel/watch.c | 2 +- arch/mips/lantiq/irq.c | 2 +- arch/mips/lib/uncached.c | 2 +- arch/mips/mm/c-octeon.c | 6 +- arch/mips/mm/c-r3k.c | 8 +- arch/mips/mm/c-r4k.c | 34 +++--- arch/mips/mm/c-tx39.c | 2 +- arch/mips/mm/cache.c | 2 +- arch/mips/mm/cex-sb1.S | 4 - arch/mips/mm/page.c | 40 +++---- arch/mips/mm/sc-ip22.c | 2 +- arch/mips/mm/sc-mips.c | 2 +- arch/mips/mm/sc-r5k.c | 2 +- arch/mips/mm/sc-rm7k.c | 12 +-- arch/mips/mm/tlb-r3k.c | 2 +- arch/mips/mm/tlb-r4k.c | 4 +- arch/mips/mm/tlb-r8k.c | 4 +- arch/mips/mm/tlbex.c | 144 ++++++++++++-------------- arch/mips/mm/uasm-micromips.c | 10 +- arch/mips/mm/uasm-mips.c | 10 +- arch/mips/mm/uasm.c | 106 +++++++++---------- arch/mips/mti-malta/malta-smtc.c | 6 +- arch/mips/mti-malta/malta-time.c | 2 +- arch/mips/mti-sead3/sead3-time.c | 2 +- arch/mips/netlogic/common/smp.c | 4 +- arch/mips/netlogic/common/smpboot.S | 4 - arch/mips/netlogic/common/time.c | 2 +- arch/mips/netlogic/xlr/wakeup.c | 2 +- arch/mips/pci/pci-ip27.c | 2 +- arch/mips/pmcs-msp71xx/msp_smtc.c | 7 +- arch/mips/pmcs-msp71xx/msp_time.c | 2 +- arch/mips/pnx833x/common/interrupts.c | 2 +- arch/mips/powertv/time.c | 2 +- arch/mips/ralink/irq.c | 2 +- arch/mips/sgi-ip27/ip27-init.c | 4 +- arch/mips/sgi-ip27/ip27-smp.c | 6 +- arch/mips/sgi-ip27/ip27-timer.c | 6 +- arch/mips/sgi-ip27/ip27-xtalk.c | 6 +- arch/mips/sibyte/bcm1480/smp.c | 8 +- arch/mips/sibyte/sb1250/smp.c | 8 +- 61 files changed, 294 insertions(+), 338 deletions(-) diff --git a/arch/mips/ath79/setup.c b/arch/mips/ath79/setup.c index 8be4e856b8b8..80f4ecd42b0d 100644 --- a/arch/mips/ath79/setup.c +++ b/arch/mips/ath79/setup.c @@ -182,7 +182,7 @@ const char *get_system_type(void) return ath79_sys_type; } -unsigned int __cpuinit get_c0_compare_int(void) +unsigned int get_c0_compare_int(void) { return CP0_LEGACY_COMPARE_IRQ; } diff --git a/arch/mips/cavium-octeon/octeon-irq.c b/arch/mips/cavium-octeon/octeon-irq.c index 7181def6037a..9d36774bded1 100644 --- a/arch/mips/cavium-octeon/octeon-irq.c +++ b/arch/mips/cavium-octeon/octeon-irq.c @@ -1095,7 +1095,7 @@ static void octeon_irq_ip3_ciu(void) static bool octeon_irq_use_ip4; -static void __cpuinit octeon_irq_local_enable_ip4(void *arg) +static void octeon_irq_local_enable_ip4(void *arg) { set_c0_status(STATUSF_IP4); } @@ -1110,21 +1110,21 @@ static void (*octeon_irq_ip2)(void); static void (*octeon_irq_ip3)(void); static void (*octeon_irq_ip4)(void); -void __cpuinitdata (*octeon_irq_setup_secondary)(void); +void (*octeon_irq_setup_secondary)(void); -void __cpuinit octeon_irq_set_ip4_handler(octeon_irq_ip4_handler_t h) +void octeon_irq_set_ip4_handler(octeon_irq_ip4_handler_t h) { octeon_irq_ip4 = h; octeon_irq_use_ip4 = true; on_each_cpu(octeon_irq_local_enable_ip4, NULL, 1); } -static void __cpuinit octeon_irq_percpu_enable(void) +static void octeon_irq_percpu_enable(void) { irq_cpu_online(); } -static void __cpuinit octeon_irq_init_ciu_percpu(void) +static void octeon_irq_init_ciu_percpu(void) { int coreid = cvmx_get_core_num(); @@ -1167,7 +1167,7 @@ static void octeon_irq_init_ciu2_percpu(void) cvmx_read_csr(CVMX_CIU2_SUM_PPX_IP2(coreid)); } -static void __cpuinit octeon_irq_setup_secondary_ciu(void) +static void octeon_irq_setup_secondary_ciu(void) { octeon_irq_init_ciu_percpu(); octeon_irq_percpu_enable(); diff --git a/arch/mips/cavium-octeon/smp.c b/arch/mips/cavium-octeon/smp.c index 295137dfdc37..138cc80c5928 100644 --- a/arch/mips/cavium-octeon/smp.c +++ b/arch/mips/cavium-octeon/smp.c @@ -173,7 +173,7 @@ static void octeon_boot_secondary(int cpu, struct task_struct *idle) * After we've done initial boot, this function is called to allow the * board code to clean up state, if needed */ -static void __cpuinit octeon_init_secondary(void) +static void octeon_init_secondary(void) { unsigned int sr; @@ -375,7 +375,7 @@ static int octeon_update_boot_vector(unsigned int cpu) return 0; } -static int __cpuinit octeon_cpu_callback(struct notifier_block *nfb, +static int octeon_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu) { unsigned int cpu = (unsigned long)hcpu; @@ -394,7 +394,7 @@ static int __cpuinit octeon_cpu_callback(struct notifier_block *nfb, return NOTIFY_OK; } -static int __cpuinit register_cavium_notifier(void) +static int register_cavium_notifier(void) { hotcpu_notifier(octeon_cpu_callback, 0); return 0; diff --git a/arch/mips/include/asm/uasm.h b/arch/mips/include/asm/uasm.h index 370d967725c2..c33a9564fb41 100644 --- a/arch/mips/include/asm/uasm.h +++ b/arch/mips/include/asm/uasm.h @@ -13,12 +13,8 @@ #ifdef CONFIG_EXPORT_UASM #include -#define __uasminit -#define __uasminitdata #define UASM_EXPORT_SYMBOL(sym) EXPORT_SYMBOL(sym) #else -#define __uasminit __cpuinit -#define __uasminitdata __cpuinitdata #define UASM_EXPORT_SYMBOL(sym) #endif @@ -54,43 +50,36 @@ #endif #define Ip_u1u2u3(op) \ -void __uasminit \ -ISAOPC(op)(u32 **buf, unsigned int a, unsigned int b, unsigned int c) +void ISAOPC(op)(u32 **buf, unsigned int a, unsigned int b, unsigned int c) #define Ip_u2u1u3(op) \ -void __uasminit \ -ISAOPC(op)(u32 **buf, unsigned int a, unsigned int b, unsigned int c) +void ISAOPC(op)(u32 **buf, unsigned int a, unsigned int b, unsigned int c) #define Ip_u3u1u2(op) \ -void __uasminit \ -ISAOPC(op)(u32 **buf, unsigned int a, unsigned int b, unsigned int c) +void ISAOPC(op)(u32 **buf, unsigned int a, unsigned int b, unsigned int c) #define Ip_u1u2s3(op) \ -void __uasminit \ -ISAOPC(op)(u32 **buf, unsigned int a, unsigned int b, signed int c) +void ISAOPC(op)(u32 **buf, unsigned int a, unsigned int b, signed int c) #define Ip_u2s3u1(op) \ -void __uasminit \ -ISAOPC(op)(u32 **buf, unsigned int a, signed int b, unsigned int c) +void ISAOPC(op)(u32 **buf, unsigned int a, signed int b, unsigned int c) #define Ip_u2u1s3(op) \ -void __uasminit \ -ISAOPC(op)(u32 **buf, unsigned int a, unsigned int b, signed int c) +void ISAOPC(op)(u32 **buf, unsigned int a, unsigned int b, signed int c) #define Ip_u2u1msbu3(op) \ -void __uasminit \ -ISAOPC(op)(u32 **buf, unsigned int a, unsigned int b, unsigned int c, \ +void ISAOPC(op)(u32 **buf, unsigned int a, unsigned int b, unsigned int c, \ unsigned int d) #define Ip_u1u2(op) \ -void __uasminit ISAOPC(op)(u32 **buf, unsigned int a, unsigned int b) +void ISAOPC(op)(u32 **buf, unsigned int a, unsigned int b) #define Ip_u1s2(op) \ -void __uasminit ISAOPC(op)(u32 **buf, unsigned int a, signed int b) +void ISAOPC(op)(u32 **buf, unsigned int a, signed int b) -#define Ip_u1(op) void __uasminit ISAOPC(op)(u32 **buf, unsigned int a) +#define Ip_u1(op) void ISAOPC(op)(u32 **buf, unsigned int a) -#define Ip_0(op) void __uasminit ISAOPC(op)(u32 **buf) +#define Ip_0(op) void ISAOPC(op)(u32 **buf) Ip_u2u1s3(_addiu); Ip_u3u1u2(_addu); @@ -163,7 +152,7 @@ struct uasm_label { int lab; }; -void __uasminit ISAFUNC(uasm_build_label)(struct uasm_label **lab, u32 *addr, +void ISAFUNC(uasm_build_label)(struct uasm_label **lab, u32 *addr, int lid); #ifdef CONFIG_64BIT int ISAFUNC(uasm_in_compat_space_p)(long addr); @@ -174,7 +163,7 @@ void ISAFUNC(UASM_i_LA_mostly)(u32 **buf, unsigned int rs, long addr); void ISAFUNC(UASM_i_LA)(u32 **buf, unsigned int rs, long addr); #define UASM_L_LA(lb) \ -static inline void __uasminit ISAFUNC(uasm_l##lb)(struct uasm_label **lab, u32 *addr) \ +static inline void ISAFUNC(uasm_l##lb)(struct uasm_label **lab, u32 *addr) \ { \ ISAFUNC(uasm_build_label)(lab, addr, label##lb); \ } diff --git a/arch/mips/kernel/bmips_vec.S b/arch/mips/kernel/bmips_vec.S index 64c4fd62cf08..f739aedcb509 100644 --- a/arch/mips/kernel/bmips_vec.S +++ b/arch/mips/kernel/bmips_vec.S @@ -28,8 +28,6 @@ .set mips0 .endm - __CPUINIT - /*********************************************************************** * Alternate CPU1 startup vector for BMIPS4350 * @@ -216,8 +214,6 @@ END(bmips_smp_int_vec) * Certain CPUs support extending kseg0 to 1024MB. ***********************************************************************/ - __CPUINIT - LEAF(bmips_enable_xks01) #if defined(CONFIG_XKS01) diff --git a/arch/mips/kernel/cevt-bcm1480.c b/arch/mips/kernel/cevt-bcm1480.c index 15f618b40cf6..7976457184b1 100644 --- a/arch/mips/kernel/cevt-bcm1480.c +++ b/arch/mips/kernel/cevt-bcm1480.c @@ -109,7 +109,7 @@ static DEFINE_PER_CPU(struct clock_event_device, sibyte_hpt_clockevent); static DEFINE_PER_CPU(struct irqaction, sibyte_hpt_irqaction); static DEFINE_PER_CPU(char [18], sibyte_hpt_name); -void __cpuinit sb1480_clockevent_init(void) +void sb1480_clockevent_init(void) { unsigned int cpu = smp_processor_id(); unsigned int irq = K_BCM1480_INT_TIMER_0 + cpu; diff --git a/arch/mips/kernel/cevt-gic.c b/arch/mips/kernel/cevt-gic.c index 730eaf92c018..594cbbf16d62 100644 --- a/arch/mips/kernel/cevt-gic.c +++ b/arch/mips/kernel/cevt-gic.c @@ -59,7 +59,7 @@ void gic_event_handler(struct clock_event_device *dev) { } -int __cpuinit gic_clockevent_init(void) +int gic_clockevent_init(void) { unsigned int cpu = smp_processor_id(); struct clock_event_device *cd; diff --git a/arch/mips/kernel/cevt-r4k.c b/arch/mips/kernel/cevt-r4k.c index 02033eaf8825..50d3f5a8d6bb 100644 --- a/arch/mips/kernel/cevt-r4k.c +++ b/arch/mips/kernel/cevt-r4k.c @@ -171,7 +171,7 @@ int c0_compare_int_usable(void) } #ifndef CONFIG_MIPS_MT_SMTC -int __cpuinit r4k_clockevent_init(void) +int r4k_clockevent_init(void) { unsigned int cpu = smp_processor_id(); struct clock_event_device *cd; diff --git a/arch/mips/kernel/cevt-sb1250.c b/arch/mips/kernel/cevt-sb1250.c index 200f2778bf36..5ea6d6b1de15 100644 --- a/arch/mips/kernel/cevt-sb1250.c +++ b/arch/mips/kernel/cevt-sb1250.c @@ -107,7 +107,7 @@ static DEFINE_PER_CPU(struct clock_event_device, sibyte_hpt_clockevent); static DEFINE_PER_CPU(struct irqaction, sibyte_hpt_irqaction); static DEFINE_PER_CPU(char [18], sibyte_hpt_name); -void __cpuinit sb1250_clockevent_init(void) +void sb1250_clockevent_init(void) { unsigned int cpu = smp_processor_id(); unsigned int irq = K_INT_TIMER_0 + cpu; diff --git a/arch/mips/kernel/cevt-smtc.c b/arch/mips/kernel/cevt-smtc.c index 9de5ed7ef1a3..b6cf0a60d896 100644 --- a/arch/mips/kernel/cevt-smtc.c +++ b/arch/mips/kernel/cevt-smtc.c @@ -248,7 +248,7 @@ irqreturn_t c0_compare_interrupt(int irq, void *dev_id) } -int __cpuinit smtc_clockevent_init(void) +int smtc_clockevent_init(void) { uint64_t mips_freq = mips_hpt_frequency; unsigned int cpu = smp_processor_id(); diff --git a/arch/mips/kernel/cpu-bugs64.c b/arch/mips/kernel/cpu-bugs64.c index 0c61df281ce6..2d80b5f1aeae 100644 --- a/arch/mips/kernel/cpu-bugs64.c +++ b/arch/mips/kernel/cpu-bugs64.c @@ -168,7 +168,7 @@ static inline void check_mult_sh(void) panic(bug64hit, !R4000_WAR ? r4kwar : nowar); } -static volatile int daddi_ov __cpuinitdata; +static volatile int daddi_ov; asmlinkage void __init do_daddi_ov(struct pt_regs *regs) { diff --git a/arch/mips/kernel/cpu-probe.c b/arch/mips/kernel/cpu-probe.c index c7b1b3c5a761..4c6167a17875 100644 --- a/arch/mips/kernel/cpu-probe.c +++ b/arch/mips/kernel/cpu-probe.c @@ -27,7 +27,7 @@ #include #include -static int __cpuinitdata mips_fpu_disabled; +static int mips_fpu_disabled; static int __init fpu_disable(char *s) { @@ -39,7 +39,7 @@ static int __init fpu_disable(char *s) __setup("nofpu", fpu_disable); -int __cpuinitdata mips_dsp_disabled; +int mips_dsp_disabled; static int __init dsp_disable(char *s) { @@ -134,7 +134,7 @@ static inline void cpu_probe_vmbits(struct cpuinfo_mips *c) #endif } -static void __cpuinit set_isa(struct cpuinfo_mips *c, unsigned int isa) +static void set_isa(struct cpuinfo_mips *c, unsigned int isa) { switch (isa) { case MIPS_CPU_ISA_M64R2: @@ -159,7 +159,7 @@ static void __cpuinit set_isa(struct cpuinfo_mips *c, unsigned int isa) } } -static char unknown_isa[] __cpuinitdata = KERN_ERR \ +static char unknown_isa[] = KERN_ERR \ "Unsupported ISA type, c0.config0: %d."; static inline unsigned int decode_config0(struct cpuinfo_mips *c) @@ -290,7 +290,7 @@ static inline unsigned int decode_config4(struct cpuinfo_mips *c) return config4 & MIPS_CONF_M; } -static void __cpuinit decode_configs(struct cpuinfo_mips *c) +static void decode_configs(struct cpuinfo_mips *c) { int ok; @@ -962,7 +962,7 @@ EXPORT_SYMBOL(__ua_limit); const char *__cpu_name[NR_CPUS]; const char *__elf_platform; -__cpuinit void cpu_probe(void) +void cpu_probe(void) { struct cpuinfo_mips *c = ¤t_cpu_data; unsigned int cpu = smp_processor_id(); @@ -1047,7 +1047,7 @@ __cpuinit void cpu_probe(void) #endif } -__cpuinit void cpu_report(void) +void cpu_report(void) { struct cpuinfo_mips *c = ¤t_cpu_data; diff --git a/arch/mips/kernel/head.S b/arch/mips/kernel/head.S index 099912324423..7b6a5b3e3acf 100644 --- a/arch/mips/kernel/head.S +++ b/arch/mips/kernel/head.S @@ -158,8 +158,6 @@ NESTED(kernel_entry, 16, sp) # kernel entry point j start_kernel END(kernel_entry) - __CPUINIT - #ifdef CONFIG_SMP /* * SMP slave cpus entry point. Board specific code for bootstrap calls this @@ -188,5 +186,3 @@ NESTED(smp_bootstrap, 16, sp) j start_secondary END(smp_bootstrap) #endif /* CONFIG_SMP */ - - __FINIT diff --git a/arch/mips/kernel/smp-bmips.c b/arch/mips/kernel/smp-bmips.c index aea6c0885838..76f31353e718 100644 --- a/arch/mips/kernel/smp-bmips.c +++ b/arch/mips/kernel/smp-bmips.c @@ -398,7 +398,7 @@ struct plat_smp_ops bmips_smp_ops = { * UP BMIPS systems as well. ***********************************************************************/ -static void __cpuinit bmips_wr_vec(unsigned long dst, char *start, char *end) +static void bmips_wr_vec(unsigned long dst, char *start, char *end) { memcpy((void *)dst, start, end - start); dma_cache_wback((unsigned long)start, end - start); @@ -406,7 +406,7 @@ static void __cpuinit bmips_wr_vec(unsigned long dst, char *start, char *end) instruction_hazard(); } -static inline void __cpuinit bmips_nmi_handler_setup(void) +static inline void bmips_nmi_handler_setup(void) { bmips_wr_vec(BMIPS_NMI_RESET_VEC, &bmips_reset_nmi_vec, &bmips_reset_nmi_vec_end); @@ -414,7 +414,7 @@ static inline void __cpuinit bmips_nmi_handler_setup(void) &bmips_smp_int_vec_end); } -void __cpuinit bmips_ebase_setup(void) +void bmips_ebase_setup(void) { unsigned long new_ebase = ebase; void __iomem __maybe_unused *cbr; diff --git a/arch/mips/kernel/smp-mt.c b/arch/mips/kernel/smp-mt.c index 3e5164c11cac..57a3f7a2b370 100644 --- a/arch/mips/kernel/smp-mt.c +++ b/arch/mips/kernel/smp-mt.c @@ -149,7 +149,7 @@ static void vsmp_send_ipi_mask(const struct cpumask *mask, unsigned int action) vsmp_send_ipi_single(i, action); } -static void __cpuinit vsmp_init_secondary(void) +static void vsmp_init_secondary(void) { #ifdef CONFIG_IRQ_GIC /* This is Malta specific: IPI,performance and timer interrupts */ @@ -162,7 +162,7 @@ static void __cpuinit vsmp_init_secondary(void) STATUSF_IP6 | STATUSF_IP7); } -static void __cpuinit vsmp_smp_finish(void) +static void vsmp_smp_finish(void) { /* CDFIXME: remove this? */ write_c0_compare(read_c0_count() + (8* mips_hpt_frequency/HZ)); @@ -188,7 +188,7 @@ static void vsmp_cpus_done(void) * (unsigned long)idle->thread_info the gp * assumes a 1:1 mapping of TC => VPE */ -static void __cpuinit vsmp_boot_secondary(int cpu, struct task_struct *idle) +static void vsmp_boot_secondary(int cpu, struct task_struct *idle) { struct thread_info *gp = task_thread_info(idle); dvpe(); diff --git a/arch/mips/kernel/smp-up.c b/arch/mips/kernel/smp-up.c index 00500fea2750..7fde3e4d978f 100644 --- a/arch/mips/kernel/smp-up.c +++ b/arch/mips/kernel/smp-up.c @@ -28,11 +28,11 @@ static inline void up_send_ipi_mask(const struct cpumask *mask, * After we've done initial boot, this function is called to allow the * board code to clean up state, if needed */ -static void __cpuinit up_init_secondary(void) +static void up_init_secondary(void) { } -static void __cpuinit up_smp_finish(void) +static void up_smp_finish(void) { } @@ -44,7 +44,7 @@ static void up_cpus_done(void) /* * Firmware CPU startup hook */ -static void __cpuinit up_boot_secondary(int cpu, struct task_struct *idle) +static void up_boot_secondary(int cpu, struct task_struct *idle) { } diff --git a/arch/mips/kernel/smp.c b/arch/mips/kernel/smp.c index 6e7862ab46cc..5c208ed8f856 100644 --- a/arch/mips/kernel/smp.c +++ b/arch/mips/kernel/smp.c @@ -86,7 +86,7 @@ static inline void set_cpu_sibling_map(int cpu) struct plat_smp_ops *mp_ops; EXPORT_SYMBOL(mp_ops); -__cpuinit void register_smp_ops(struct plat_smp_ops *ops) +void register_smp_ops(struct plat_smp_ops *ops) { if (mp_ops) printk(KERN_WARNING "Overriding previously set SMP ops\n"); @@ -98,7 +98,7 @@ __cpuinit void register_smp_ops(struct plat_smp_ops *ops) * First C code run on the secondary CPUs after being started up by * the master. */ -asmlinkage __cpuinit void start_secondary(void) +asmlinkage void start_secondary(void) { unsigned int cpu; @@ -197,7 +197,7 @@ void smp_prepare_boot_cpu(void) cpu_set(0, cpu_callin_map); } -int __cpuinit __cpu_up(unsigned int cpu, struct task_struct *tidle) +int __cpu_up(unsigned int cpu, struct task_struct *tidle) { mp_ops->boot_secondary(cpu, tidle); diff --git a/arch/mips/kernel/smtc.c b/arch/mips/kernel/smtc.c index 75a4fd709841..dfc1b911be04 100644 --- a/arch/mips/kernel/smtc.c +++ b/arch/mips/kernel/smtc.c @@ -645,7 +645,7 @@ void smtc_prepare_cpus(int cpus) * (unsigned long)idle->thread_info the gp * */ -void __cpuinit smtc_boot_secondary(int cpu, struct task_struct *idle) +void smtc_boot_secondary(int cpu, struct task_struct *idle) { extern u32 kernelsp[NR_CPUS]; unsigned long flags; diff --git a/arch/mips/kernel/spram.c b/arch/mips/kernel/spram.c index 6af08d896e20..93f86817f20a 100644 --- a/arch/mips/kernel/spram.c +++ b/arch/mips/kernel/spram.c @@ -37,7 +37,7 @@ /* * Different semantics to the set_c0_* function built by __BUILD_SET_C0 */ -static __cpuinit unsigned int bis_c0_errctl(unsigned int set) +static unsigned int bis_c0_errctl(unsigned int set) { unsigned int res; res = read_c0_errctl(); @@ -45,7 +45,7 @@ static __cpuinit unsigned int bis_c0_errctl(unsigned int set) return res; } -static __cpuinit void ispram_store_tag(unsigned int offset, unsigned int data) +static void ispram_store_tag(unsigned int offset, unsigned int data) { unsigned int errctl; @@ -64,7 +64,7 @@ static __cpuinit void ispram_store_tag(unsigned int offset, unsigned int data) } -static __cpuinit unsigned int ispram_load_tag(unsigned int offset) +static unsigned int ispram_load_tag(unsigned int offset) { unsigned int data; unsigned int errctl; @@ -82,7 +82,7 @@ static __cpuinit unsigned int ispram_load_tag(unsigned int offset) return data; } -static __cpuinit void dspram_store_tag(unsigned int offset, unsigned int data) +static void dspram_store_tag(unsigned int offset, unsigned int data) { unsigned int errctl; @@ -98,7 +98,7 @@ static __cpuinit void dspram_store_tag(unsigned int offset, unsigned int data) } -static __cpuinit unsigned int dspram_load_tag(unsigned int offset) +static unsigned int dspram_load_tag(unsigned int offset) { unsigned int data; unsigned int errctl; @@ -115,7 +115,7 @@ static __cpuinit unsigned int dspram_load_tag(unsigned int offset) return data; } -static __cpuinit void probe_spram(char *type, +static void probe_spram(char *type, unsigned int base, unsigned int (*read)(unsigned int), void (*write)(unsigned int, unsigned int)) @@ -196,7 +196,7 @@ static __cpuinit void probe_spram(char *type, offset += 2 * SPRAM_TAG_STRIDE; } } -void __cpuinit spram_config(void) +void spram_config(void) { struct cpuinfo_mips *c = ¤t_cpu_data; unsigned int config0; diff --git a/arch/mips/kernel/sync-r4k.c b/arch/mips/kernel/sync-r4k.c index 1ff43d5ac2c4..84536bf4a154 100644 --- a/arch/mips/kernel/sync-r4k.c +++ b/arch/mips/kernel/sync-r4k.c @@ -20,15 +20,15 @@ #include #include -static atomic_t __cpuinitdata count_start_flag = ATOMIC_INIT(0); -static atomic_t __cpuinitdata count_count_start = ATOMIC_INIT(0); -static atomic_t __cpuinitdata count_count_stop = ATOMIC_INIT(0); -static atomic_t __cpuinitdata count_reference = ATOMIC_INIT(0); +static atomic_t count_start_flag = ATOMIC_INIT(0); +static atomic_t count_count_start = ATOMIC_INIT(0); +static atomic_t count_count_stop = ATOMIC_INIT(0); +static atomic_t count_reference = ATOMIC_INIT(0); #define COUNTON 100 #define NR_LOOPS 5 -void __cpuinit synchronise_count_master(int cpu) +void synchronise_count_master(int cpu) { int i; unsigned long flags; @@ -106,7 +106,7 @@ void __cpuinit synchronise_count_master(int cpu) printk("done.\n"); } -void __cpuinit synchronise_count_slave(int cpu) +void synchronise_count_slave(int cpu) { int i; unsigned int initcount; diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c index 0903d70b2cfe..c89568f88bfd 100644 --- a/arch/mips/kernel/traps.c +++ b/arch/mips/kernel/traps.c @@ -90,7 +90,7 @@ void (*board_nmi_handler_setup)(void); void (*board_ejtag_handler_setup)(void); void (*board_bind_eic_interrupt)(int irq, int regset); void (*board_ebase_setup)(void); -void __cpuinitdata(*board_cache_error_setup)(void); +void(*board_cache_error_setup)(void); static void show_raw_backtrace(unsigned long reg29) { @@ -1682,7 +1682,7 @@ int cp0_compare_irq_shift; int cp0_perfcount_irq; EXPORT_SYMBOL_GPL(cp0_perfcount_irq); -static int __cpuinitdata noulri; +static int noulri; static int __init ulri_disable(char *s) { @@ -1693,7 +1693,7 @@ static int __init ulri_disable(char *s) } __setup("noulri", ulri_disable); -void __cpuinit per_cpu_trap_init(bool is_boot_cpu) +void per_cpu_trap_init(bool is_boot_cpu) { unsigned int cpu = smp_processor_id(); unsigned int status_set = ST0_CU0; @@ -1810,7 +1810,7 @@ void __cpuinit per_cpu_trap_init(bool is_boot_cpu) } /* Install CPU exception handler */ -void __cpuinit set_handler(unsigned long offset, void *addr, unsigned long size) +void set_handler(unsigned long offset, void *addr, unsigned long size) { #ifdef CONFIG_CPU_MICROMIPS memcpy((void *)(ebase + offset), ((unsigned char *)addr - 1), size); @@ -1820,7 +1820,7 @@ void __cpuinit set_handler(unsigned long offset, void *addr, unsigned long size) local_flush_icache_range(ebase + offset, ebase + offset + size); } -static char panic_null_cerr[] __cpuinitdata = +static char panic_null_cerr[] = "Trying to set NULL cache error exception handler"; /* @@ -1828,7 +1828,7 @@ static char panic_null_cerr[] __cpuinitdata = * This is suitable only for the cache error exception which is the only * exception handler that is being run uncached. */ -void __cpuinit set_uncached_handler(unsigned long offset, void *addr, +void set_uncached_handler(unsigned long offset, void *addr, unsigned long size) { unsigned long uncached_ebase = CKSEG1ADDR(ebase); diff --git a/arch/mips/kernel/watch.c b/arch/mips/kernel/watch.c index cbdc4de85bb4..2a03abb5bd2c 100644 --- a/arch/mips/kernel/watch.c +++ b/arch/mips/kernel/watch.c @@ -100,7 +100,7 @@ void mips_clear_watch_registers(void) } } -__cpuinit void mips_probe_watch_registers(struct cpuinfo_mips *c) +void mips_probe_watch_registers(struct cpuinfo_mips *c) { unsigned int t; diff --git a/arch/mips/lantiq/irq.c b/arch/mips/lantiq/irq.c index 51194875f158..eb3e18659630 100644 --- a/arch/mips/lantiq/irq.c +++ b/arch/mips/lantiq/irq.c @@ -461,7 +461,7 @@ int __init icu_of_init(struct device_node *node, struct device_node *parent) return 0; } -unsigned int __cpuinit get_c0_compare_int(void) +unsigned int get_c0_compare_int(void) { return MIPS_CPU_TIMER_IRQ; } diff --git a/arch/mips/lib/uncached.c b/arch/mips/lib/uncached.c index 65e3dfc4e585..d8522f8e842a 100644 --- a/arch/mips/lib/uncached.c +++ b/arch/mips/lib/uncached.c @@ -36,7 +36,7 @@ * values, so we can avoid sharing the same stack area between a cached * and the uncached mode. */ -unsigned long __cpuinit run_uncached(void *func) +unsigned long run_uncached(void *func) { register long sp __asm__("$sp"); register long ret __asm__("$2"); diff --git a/arch/mips/mm/c-octeon.c b/arch/mips/mm/c-octeon.c index 8557fb552863..a0bcdbb81d41 100644 --- a/arch/mips/mm/c-octeon.c +++ b/arch/mips/mm/c-octeon.c @@ -180,7 +180,7 @@ static void octeon_flush_kernel_vmap_range(unsigned long vaddr, int size) * Probe Octeon's caches * */ -static void __cpuinit probe_octeon(void) +static void probe_octeon(void) { unsigned long icache_size; unsigned long dcache_size; @@ -251,7 +251,7 @@ static void __cpuinit probe_octeon(void) } } -static void __cpuinit octeon_cache_error_setup(void) +static void octeon_cache_error_setup(void) { extern char except_vec2_octeon; set_handler(0x100, &except_vec2_octeon, 0x80); @@ -261,7 +261,7 @@ static void __cpuinit octeon_cache_error_setup(void) * Setup the Octeon cache flush routines * */ -void __cpuinit octeon_cache_init(void) +void octeon_cache_init(void) { probe_octeon(); diff --git a/arch/mips/mm/c-r3k.c b/arch/mips/mm/c-r3k.c index 704dc735a59d..2fcde0c8ea02 100644 --- a/arch/mips/mm/c-r3k.c +++ b/arch/mips/mm/c-r3k.c @@ -26,7 +26,7 @@ static unsigned long icache_size, dcache_size; /* Size in bytes */ static unsigned long icache_lsize, dcache_lsize; /* Size in bytes */ -unsigned long __cpuinit r3k_cache_size(unsigned long ca_flags) +unsigned long r3k_cache_size(unsigned long ca_flags) { unsigned long flags, status, dummy, size; volatile unsigned long *p; @@ -61,7 +61,7 @@ unsigned long __cpuinit r3k_cache_size(unsigned long ca_flags) return size * sizeof(*p); } -unsigned long __cpuinit r3k_cache_lsize(unsigned long ca_flags) +unsigned long r3k_cache_lsize(unsigned long ca_flags) { unsigned long flags, status, lsize, i; volatile unsigned long *p; @@ -90,7 +90,7 @@ unsigned long __cpuinit r3k_cache_lsize(unsigned long ca_flags) return lsize * sizeof(*p); } -static void __cpuinit r3k_probe_cache(void) +static void r3k_probe_cache(void) { dcache_size = r3k_cache_size(ST0_ISC); if (dcache_size) @@ -312,7 +312,7 @@ static void r3k_dma_cache_wback_inv(unsigned long start, unsigned long size) r3k_flush_dcache_range(start, start + size); } -void __cpuinit r3k_cache_init(void) +void r3k_cache_init(void) { extern void build_clear_page(void); extern void build_copy_page(void); diff --git a/arch/mips/mm/c-r4k.c b/arch/mips/mm/c-r4k.c index 21813beec7a5..f749f687ee87 100644 --- a/arch/mips/mm/c-r4k.c +++ b/arch/mips/mm/c-r4k.c @@ -107,7 +107,7 @@ static inline void r4k_blast_dcache_page_dc64(unsigned long addr) blast_dcache64_page(addr); } -static void __cpuinit r4k_blast_dcache_page_setup(void) +static void r4k_blast_dcache_page_setup(void) { unsigned long dc_lsize = cpu_dcache_line_size(); @@ -123,7 +123,7 @@ static void __cpuinit r4k_blast_dcache_page_setup(void) static void (* r4k_blast_dcache_page_indexed)(unsigned long addr); -static void __cpuinit r4k_blast_dcache_page_indexed_setup(void) +static void r4k_blast_dcache_page_indexed_setup(void) { unsigned long dc_lsize = cpu_dcache_line_size(); @@ -140,7 +140,7 @@ static void __cpuinit r4k_blast_dcache_page_indexed_setup(void) void (* r4k_blast_dcache)(void); EXPORT_SYMBOL(r4k_blast_dcache); -static void __cpuinit r4k_blast_dcache_setup(void) +static void r4k_blast_dcache_setup(void) { unsigned long dc_lsize = cpu_dcache_line_size(); @@ -227,7 +227,7 @@ static inline void tx49_blast_icache32_page_indexed(unsigned long page) static void (* r4k_blast_icache_page)(unsigned long addr); -static void __cpuinit r4k_blast_icache_page_setup(void) +static void r4k_blast_icache_page_setup(void) { unsigned long ic_lsize = cpu_icache_line_size(); @@ -244,7 +244,7 @@ static void __cpuinit r4k_blast_icache_page_setup(void) static void (* r4k_blast_icache_page_indexed)(unsigned long addr); -static void __cpuinit r4k_blast_icache_page_indexed_setup(void) +static void r4k_blast_icache_page_indexed_setup(void) { unsigned long ic_lsize = cpu_icache_line_size(); @@ -269,7 +269,7 @@ static void __cpuinit r4k_blast_icache_page_indexed_setup(void) void (* r4k_blast_icache)(void); EXPORT_SYMBOL(r4k_blast_icache); -static void __cpuinit r4k_blast_icache_setup(void) +static void r4k_blast_icache_setup(void) { unsigned long ic_lsize = cpu_icache_line_size(); @@ -290,7 +290,7 @@ static void __cpuinit r4k_blast_icache_setup(void) static void (* r4k_blast_scache_page)(unsigned long addr); -static void __cpuinit r4k_blast_scache_page_setup(void) +static void r4k_blast_scache_page_setup(void) { unsigned long sc_lsize = cpu_scache_line_size(); @@ -308,7 +308,7 @@ static void __cpuinit r4k_blast_scache_page_setup(void) static void (* r4k_blast_scache_page_indexed)(unsigned long addr); -static void __cpuinit r4k_blast_scache_page_indexed_setup(void) +static void r4k_blast_scache_page_indexed_setup(void) { unsigned long sc_lsize = cpu_scache_line_size(); @@ -326,7 +326,7 @@ static void __cpuinit r4k_blast_scache_page_indexed_setup(void) static void (* r4k_blast_scache)(void); -static void __cpuinit r4k_blast_scache_setup(void) +static void r4k_blast_scache_setup(void) { unsigned long sc_lsize = cpu_scache_line_size(); @@ -797,11 +797,11 @@ static inline void alias_74k_erratum(struct cpuinfo_mips *c) } } -static char *way_string[] __cpuinitdata = { NULL, "direct mapped", "2-way", +static char *way_string[] = { NULL, "direct mapped", "2-way", "3-way", "4-way", "5-way", "6-way", "7-way", "8-way" }; -static void __cpuinit probe_pcache(void) +static void probe_pcache(void) { struct cpuinfo_mips *c = ¤t_cpu_data; unsigned int config = read_c0_config(); @@ -1119,7 +1119,7 @@ static void __cpuinit probe_pcache(void) * executes in KSEG1 space or else you will crash and burn badly. You have * been warned. */ -static int __cpuinit probe_scache(void) +static int probe_scache(void) { unsigned long flags, addr, begin, end, pow2; unsigned int config = read_c0_config(); @@ -1196,7 +1196,7 @@ extern int r5k_sc_init(void); extern int rm7k_sc_init(void); extern int mips_sc_init(void); -static void __cpuinit setup_scache(void) +static void setup_scache(void) { struct cpuinfo_mips *c = ¤t_cpu_data; unsigned int config = read_c0_config(); @@ -1329,7 +1329,7 @@ static void nxp_pr4450_fixup_config(void) NXP_BARRIER(); } -static int __cpuinitdata cca = -1; +static int cca = -1; static int __init cca_setup(char *str) { @@ -1340,7 +1340,7 @@ static int __init cca_setup(char *str) early_param("cca", cca_setup); -static void __cpuinit coherency_setup(void) +static void coherency_setup(void) { if (cca < 0 || cca > 7) cca = read_c0_config() & CONF_CM_CMASK; @@ -1380,7 +1380,7 @@ static void __cpuinit coherency_setup(void) } } -static void __cpuinit r4k_cache_error_setup(void) +static void r4k_cache_error_setup(void) { extern char __weak except_vec2_generic; extern char __weak except_vec2_sb1; @@ -1398,7 +1398,7 @@ static void __cpuinit r4k_cache_error_setup(void) } } -void __cpuinit r4k_cache_init(void) +void r4k_cache_init(void) { extern void build_clear_page(void); extern void build_copy_page(void); diff --git a/arch/mips/mm/c-tx39.c b/arch/mips/mm/c-tx39.c index ba9da270289f..8d909dbbf37f 100644 --- a/arch/mips/mm/c-tx39.c +++ b/arch/mips/mm/c-tx39.c @@ -344,7 +344,7 @@ static __init void tx39_probe_cache(void) } } -void __cpuinit tx39_cache_init(void) +void tx39_cache_init(void) { extern void build_clear_page(void); extern void build_copy_page(void); diff --git a/arch/mips/mm/cache.c b/arch/mips/mm/cache.c index 5aeb3eb0b72f..15f813c303b4 100644 --- a/arch/mips/mm/cache.c +++ b/arch/mips/mm/cache.c @@ -182,7 +182,7 @@ static inline void setup_protection_map(void) } } -void __cpuinit cpu_cache_init(void) +void cpu_cache_init(void) { if (cpu_has_3k_cache) { extern void __weak r3k_cache_init(void); diff --git a/arch/mips/mm/cex-sb1.S b/arch/mips/mm/cex-sb1.S index fe1d887e8d70..191cf6e0c725 100644 --- a/arch/mips/mm/cex-sb1.S +++ b/arch/mips/mm/cex-sb1.S @@ -49,8 +49,6 @@ * (0x170-0x17f) are used to preserve k0, k1, and ra. */ - __CPUINIT - LEAF(except_vec2_sb1) /* * If this error is recoverable, we need to exit the handler @@ -142,8 +140,6 @@ unrecoverable: END(except_vec2_sb1) - __FINIT - LEAF(handle_vec2_sb1) mfc0 k0,CP0_CONFIG li k1,~CONF_CM_CMASK diff --git a/arch/mips/mm/page.c b/arch/mips/mm/page.c index 2c0bd580b9da..218c2109a55d 100644 --- a/arch/mips/mm/page.c +++ b/arch/mips/mm/page.c @@ -66,29 +66,29 @@ UASM_L_LA(_copy_pref_both) UASM_L_LA(_copy_pref_store) /* We need one branch and therefore one relocation per target label. */ -static struct uasm_label __cpuinitdata labels[5]; -static struct uasm_reloc __cpuinitdata relocs[5]; +static struct uasm_label labels[5]; +static struct uasm_reloc relocs[5]; #define cpu_is_r4600_v1_x() ((read_c0_prid() & 0xfffffff0) == 0x00002010) #define cpu_is_r4600_v2_x() ((read_c0_prid() & 0xfffffff0) == 0x00002020) -static int pref_bias_clear_store __cpuinitdata; -static int pref_bias_copy_load __cpuinitdata; -static int pref_bias_copy_store __cpuinitdata; +static int pref_bias_clear_store; +static int pref_bias_copy_load; +static int pref_bias_copy_store; -static u32 pref_src_mode __cpuinitdata; -static u32 pref_dst_mode __cpuinitdata; +static u32 pref_src_mode; +static u32 pref_dst_mode; -static int clear_word_size __cpuinitdata; -static int copy_word_size __cpuinitdata; +static int clear_word_size; +static int copy_word_size; -static int half_clear_loop_size __cpuinitdata; -static int half_copy_loop_size __cpuinitdata; +static int half_clear_loop_size; +static int half_copy_loop_size; -static int cache_line_size __cpuinitdata; +static int cache_line_size; #define cache_line_mask() (cache_line_size - 1) -static inline void __cpuinit +static inline void pg_addiu(u32 **buf, unsigned int reg1, unsigned int reg2, unsigned int off) { if (cpu_has_64bit_gp_regs && DADDI_WAR && r4k_daddiu_bug()) { @@ -108,7 +108,7 @@ pg_addiu(u32 **buf, unsigned int reg1, unsigned int reg2, unsigned int off) } } -static void __cpuinit set_prefetch_parameters(void) +static void set_prefetch_parameters(void) { if (cpu_has_64bit_gp_regs || cpu_has_64bit_zero_reg) clear_word_size = 8; @@ -199,7 +199,7 @@ static void __cpuinit set_prefetch_parameters(void) 4 * copy_word_size)); } -static void __cpuinit build_clear_store(u32 **buf, int off) +static void build_clear_store(u32 **buf, int off) { if (cpu_has_64bit_gp_regs || cpu_has_64bit_zero_reg) { uasm_i_sd(buf, ZERO, off, A0); @@ -208,7 +208,7 @@ static void __cpuinit build_clear_store(u32 **buf, int off) } } -static inline void __cpuinit build_clear_pref(u32 **buf, int off) +static inline void build_clear_pref(u32 **buf, int off) { if (off & cache_line_mask()) return; @@ -240,7 +240,7 @@ extern u32 __clear_page_end; extern u32 __copy_page_start; extern u32 __copy_page_end; -void __cpuinit build_clear_page(void) +void build_clear_page(void) { int off; u32 *buf = &__clear_page_start; @@ -333,7 +333,7 @@ void __cpuinit build_clear_page(void) pr_debug("\t.set pop\n"); } -static void __cpuinit build_copy_load(u32 **buf, int reg, int off) +static void build_copy_load(u32 **buf, int reg, int off) { if (cpu_has_64bit_gp_regs) { uasm_i_ld(buf, reg, off, A1); @@ -342,7 +342,7 @@ static void __cpuinit build_copy_load(u32 **buf, int reg, int off) } } -static void __cpuinit build_copy_store(u32 **buf, int reg, int off) +static void build_copy_store(u32 **buf, int reg, int off) { if (cpu_has_64bit_gp_regs) { uasm_i_sd(buf, reg, off, A0); @@ -387,7 +387,7 @@ static inline void build_copy_store_pref(u32 **buf, int off) } } -void __cpuinit build_copy_page(void) +void build_copy_page(void) { int off; u32 *buf = &__copy_page_start; diff --git a/arch/mips/mm/sc-ip22.c b/arch/mips/mm/sc-ip22.c index c6aaed934d53..dc7c5a5214a9 100644 --- a/arch/mips/mm/sc-ip22.c +++ b/arch/mips/mm/sc-ip22.c @@ -167,7 +167,7 @@ static struct bcache_ops indy_sc_ops = { .bc_inv = indy_sc_wback_invalidate }; -void __cpuinit indy_sc_init(void) +void indy_sc_init(void) { if (indy_sc_probe()) { indy_sc_enable(); diff --git a/arch/mips/mm/sc-mips.c b/arch/mips/mm/sc-mips.c index df96da7e939b..5d01392e3518 100644 --- a/arch/mips/mm/sc-mips.c +++ b/arch/mips/mm/sc-mips.c @@ -132,7 +132,7 @@ static inline int __init mips_sc_probe(void) return 1; } -int __cpuinit mips_sc_init(void) +int mips_sc_init(void) { int found = mips_sc_probe(); if (found) { diff --git a/arch/mips/mm/sc-r5k.c b/arch/mips/mm/sc-r5k.c index 8bc67720e145..0216ed6eaa2a 100644 --- a/arch/mips/mm/sc-r5k.c +++ b/arch/mips/mm/sc-r5k.c @@ -98,7 +98,7 @@ static struct bcache_ops r5k_sc_ops = { .bc_inv = r5k_dma_cache_inv_sc }; -void __cpuinit r5k_sc_init(void) +void r5k_sc_init(void) { if (r5k_sc_probe()) { r5k_sc_enable(); diff --git a/arch/mips/mm/sc-rm7k.c b/arch/mips/mm/sc-rm7k.c index 274af3be1442..aaffbba33706 100644 --- a/arch/mips/mm/sc-rm7k.c +++ b/arch/mips/mm/sc-rm7k.c @@ -104,7 +104,7 @@ static void blast_rm7k_tcache(void) /* * This function is executed in uncached address space. */ -static __cpuinit void __rm7k_tc_enable(void) +static void __rm7k_tc_enable(void) { int i; @@ -117,7 +117,7 @@ static __cpuinit void __rm7k_tc_enable(void) cache_op(Index_Store_Tag_T, CKSEG0ADDR(i)); } -static __cpuinit void rm7k_tc_enable(void) +static void rm7k_tc_enable(void) { if (read_c0_config() & RM7K_CONF_TE) return; @@ -130,7 +130,7 @@ static __cpuinit void rm7k_tc_enable(void) /* * This function is executed in uncached address space. */ -static __cpuinit void __rm7k_sc_enable(void) +static void __rm7k_sc_enable(void) { int i; @@ -143,7 +143,7 @@ static __cpuinit void __rm7k_sc_enable(void) cache_op(Index_Store_Tag_SD, CKSEG0ADDR(i)); } -static __cpuinit void rm7k_sc_enable(void) +static void rm7k_sc_enable(void) { if (read_c0_config() & RM7K_CONF_SE) return; @@ -184,7 +184,7 @@ static struct bcache_ops rm7k_sc_ops = { * This is a probing function like the one found in c-r4k.c, we look for the * wrap around point with different addresses. */ -static __cpuinit void __probe_tcache(void) +static void __probe_tcache(void) { unsigned long flags, addr, begin, end, pow2; @@ -226,7 +226,7 @@ static __cpuinit void __probe_tcache(void) local_irq_restore(flags); } -void __cpuinit rm7k_sc_init(void) +void rm7k_sc_init(void) { struct cpuinfo_mips *c = ¤t_cpu_data; unsigned int config = read_c0_config(); diff --git a/arch/mips/mm/tlb-r3k.c b/arch/mips/mm/tlb-r3k.c index a63d1ed0827f..9aca10994cd2 100644 --- a/arch/mips/mm/tlb-r3k.c +++ b/arch/mips/mm/tlb-r3k.c @@ -276,7 +276,7 @@ void add_wired_entry(unsigned long entrylo0, unsigned long entrylo1, } } -void __cpuinit tlb_init(void) +void tlb_init(void) { local_flush_tlb_all(); diff --git a/arch/mips/mm/tlb-r4k.c b/arch/mips/mm/tlb-r4k.c index c643de4c473a..00b26a67a06d 100644 --- a/arch/mips/mm/tlb-r4k.c +++ b/arch/mips/mm/tlb-r4k.c @@ -389,7 +389,7 @@ int __init has_transparent_hugepage(void) #endif /* CONFIG_TRANSPARENT_HUGEPAGE */ -static int __cpuinitdata ntlb; +static int ntlb; static int __init set_ntlb(char *str) { get_option(&str, &ntlb); @@ -398,7 +398,7 @@ static int __init set_ntlb(char *str) __setup("ntlb=", set_ntlb); -void __cpuinit tlb_init(void) +void tlb_init(void) { /* * You should never change this register: diff --git a/arch/mips/mm/tlb-r8k.c b/arch/mips/mm/tlb-r8k.c index 91c2499f806a..6a99733a4440 100644 --- a/arch/mips/mm/tlb-r8k.c +++ b/arch/mips/mm/tlb-r8k.c @@ -213,14 +213,14 @@ void __update_tlb(struct vm_area_struct * vma, unsigned long address, pte_t pte) local_irq_restore(flags); } -static void __cpuinit probe_tlb(unsigned long config) +static void probe_tlb(unsigned long config) { struct cpuinfo_mips *c = ¤t_cpu_data; c->tlbsize = 3 * 128; /* 3 sets each 128 entries */ } -void __cpuinit tlb_init(void) +void tlb_init(void) { unsigned int config = read_c0_config(); unsigned long status; diff --git a/arch/mips/mm/tlbex.c b/arch/mips/mm/tlbex.c index 9ab0f907a52c..34fce2b2095b 100644 --- a/arch/mips/mm/tlbex.c +++ b/arch/mips/mm/tlbex.c @@ -136,7 +136,7 @@ static int scratchpad_offset(int i) * why; it's not an issue caused by the core RTL. * */ -static int __cpuinit m4kc_tlbp_war(void) +static int m4kc_tlbp_war(void) { return (current_cpu_data.processor_id & 0xffff00) == (PRID_COMP_MIPS | PRID_IMP_4KC); @@ -181,11 +181,9 @@ UASM_L_LA(_large_segbits_fault) UASM_L_LA(_tlb_huge_update) #endif -static int __cpuinitdata hazard_instance; +static int hazard_instance; -static void __cpuinit uasm_bgezl_hazard(u32 **p, - struct uasm_reloc **r, - int instance) +static void uasm_bgezl_hazard(u32 **p, struct uasm_reloc **r, int instance) { switch (instance) { case 0 ... 7: @@ -196,9 +194,7 @@ static void __cpuinit uasm_bgezl_hazard(u32 **p, } } -static void __cpuinit uasm_bgezl_label(struct uasm_label **l, - u32 **p, - int instance) +static void uasm_bgezl_label(struct uasm_label **l, u32 **p, int instance) { switch (instance) { case 0 ... 7: @@ -295,15 +291,15 @@ static inline void dump_handler(const char *symbol, const u32 *handler, int coun * We deliberately chose a buffer size of 128, so we won't scribble * over anything important on overflow before we panic. */ -static u32 tlb_handler[128] __cpuinitdata; +static u32 tlb_handler[128]; /* simply assume worst case size for labels and relocs */ -static struct uasm_label labels[128] __cpuinitdata; -static struct uasm_reloc relocs[128] __cpuinitdata; +static struct uasm_label labels[128]; +static struct uasm_reloc relocs[128]; -static int check_for_high_segbits __cpuinitdata; +static int check_for_high_segbits; -static unsigned int kscratch_used_mask __cpuinitdata; +static unsigned int kscratch_used_mask; static inline int __maybe_unused c0_kscratch(void) { @@ -316,7 +312,7 @@ static inline int __maybe_unused c0_kscratch(void) } } -static int __cpuinit allocate_kscratch(void) +static int allocate_kscratch(void) { int r; unsigned int a = cpu_data[0].kscratch_mask & ~kscratch_used_mask; @@ -333,11 +329,11 @@ static int __cpuinit allocate_kscratch(void) return r; } -static int scratch_reg __cpuinitdata; -static int pgd_reg __cpuinitdata; +static int scratch_reg; +static int pgd_reg; enum vmalloc64_mode {not_refill, refill_scratch, refill_noscratch}; -static struct work_registers __cpuinit build_get_work_registers(u32 **p) +static struct work_registers build_get_work_registers(u32 **p) { struct work_registers r; @@ -393,7 +389,7 @@ static struct work_registers __cpuinit build_get_work_registers(u32 **p) return r; } -static void __cpuinit build_restore_work_registers(u32 **p) +static void build_restore_work_registers(u32 **p) { if (scratch_reg >= 0) { UASM_i_MFC0(p, 1, c0_kscratch(), scratch_reg); @@ -418,7 +414,7 @@ extern unsigned long pgd_current[]; /* * The R3000 TLB handler is simple. */ -static void __cpuinit build_r3000_tlb_refill_handler(void) +static void build_r3000_tlb_refill_handler(void) { long pgdc = (long)pgd_current; u32 *p; @@ -463,7 +459,7 @@ static void __cpuinit build_r3000_tlb_refill_handler(void) * other one.To keep things simple, we first assume linear space, * then we relocate it to the final handler layout as needed. */ -static u32 final_handler[64] __cpuinitdata; +static u32 final_handler[64]; /* * Hazards @@ -487,7 +483,7 @@ static u32 final_handler[64] __cpuinitdata; * * As if we MIPS hackers wouldn't know how to nop pipelines happy ... */ -static void __cpuinit __maybe_unused build_tlb_probe_entry(u32 **p) +static void __maybe_unused build_tlb_probe_entry(u32 **p) { switch (current_cpu_type()) { /* Found by experiment: R4600 v2.0/R4700 needs this, too. */ @@ -511,9 +507,9 @@ static void __cpuinit __maybe_unused build_tlb_probe_entry(u32 **p) */ enum tlb_write_entry { tlb_random, tlb_indexed }; -static void __cpuinit build_tlb_write_entry(u32 **p, struct uasm_label **l, - struct uasm_reloc **r, - enum tlb_write_entry wmode) +static void build_tlb_write_entry(u32 **p, struct uasm_label **l, + struct uasm_reloc **r, + enum tlb_write_entry wmode) { void(*tlbw)(u32 **) = NULL; @@ -647,8 +643,8 @@ static void __cpuinit build_tlb_write_entry(u32 **p, struct uasm_label **l, } } -static __cpuinit __maybe_unused void build_convert_pte_to_entrylo(u32 **p, - unsigned int reg) +static __maybe_unused void build_convert_pte_to_entrylo(u32 **p, + unsigned int reg) { if (cpu_has_rixi) { UASM_i_ROTR(p, reg, reg, ilog2(_PAGE_GLOBAL)); @@ -663,11 +659,9 @@ static __cpuinit __maybe_unused void build_convert_pte_to_entrylo(u32 **p, #ifdef CONFIG_MIPS_HUGE_TLB_SUPPORT -static __cpuinit void build_restore_pagemask(u32 **p, - struct uasm_reloc **r, - unsigned int tmp, - enum label_id lid, - int restore_scratch) +static void build_restore_pagemask(u32 **p, struct uasm_reloc **r, + unsigned int tmp, enum label_id lid, + int restore_scratch) { if (restore_scratch) { /* Reset default page size */ @@ -706,12 +700,11 @@ static __cpuinit void build_restore_pagemask(u32 **p, } } -static __cpuinit void build_huge_tlb_write_entry(u32 **p, - struct uasm_label **l, - struct uasm_reloc **r, - unsigned int tmp, - enum tlb_write_entry wmode, - int restore_scratch) +static void build_huge_tlb_write_entry(u32 **p, struct uasm_label **l, + struct uasm_reloc **r, + unsigned int tmp, + enum tlb_write_entry wmode, + int restore_scratch) { /* Set huge page tlb entry size */ uasm_i_lui(p, tmp, PM_HUGE_MASK >> 16); @@ -726,9 +719,9 @@ static __cpuinit void build_huge_tlb_write_entry(u32 **p, /* * Check if Huge PTE is present, if so then jump to LABEL. */ -static void __cpuinit +static void build_is_huge_pte(u32 **p, struct uasm_reloc **r, unsigned int tmp, - unsigned int pmd, int lid) + unsigned int pmd, int lid) { UASM_i_LW(p, tmp, 0, pmd); if (use_bbit_insns()) { @@ -739,9 +732,8 @@ build_is_huge_pte(u32 **p, struct uasm_reloc **r, unsigned int tmp, } } -static __cpuinit void build_huge_update_entries(u32 **p, - unsigned int pte, - unsigned int tmp) +static void build_huge_update_entries(u32 **p, unsigned int pte, + unsigned int tmp) { int small_sequence; @@ -771,11 +763,10 @@ static __cpuinit void build_huge_update_entries(u32 **p, UASM_i_MTC0(p, pte, C0_ENTRYLO1); /* load it */ } -static __cpuinit void build_huge_handler_tail(u32 **p, - struct uasm_reloc **r, - struct uasm_label **l, - unsigned int pte, - unsigned int ptr) +static void build_huge_handler_tail(u32 **p, struct uasm_reloc **r, + struct uasm_label **l, + unsigned int pte, + unsigned int ptr) { #ifdef CONFIG_SMP UASM_i_SC(p, pte, 0, ptr); @@ -794,7 +785,7 @@ static __cpuinit void build_huge_handler_tail(u32 **p, * TMP and PTR are scratch. * TMP will be clobbered, PTR will hold the pmd entry. */ -static void __cpuinit +static void build_get_pmde64(u32 **p, struct uasm_label **l, struct uasm_reloc **r, unsigned int tmp, unsigned int ptr) { @@ -886,7 +877,7 @@ build_get_pmde64(u32 **p, struct uasm_label **l, struct uasm_reloc **r, * BVADDR is the faulting address, PTR is scratch. * PTR will hold the pgd for vmalloc. */ -static void __cpuinit +static void build_get_pgd_vmalloc64(u32 **p, struct uasm_label **l, struct uasm_reloc **r, unsigned int bvaddr, unsigned int ptr, enum vmalloc64_mode mode) @@ -956,7 +947,7 @@ build_get_pgd_vmalloc64(u32 **p, struct uasm_label **l, struct uasm_reloc **r, * TMP and PTR are scratch. * TMP will be clobbered, PTR will hold the pgd entry. */ -static void __cpuinit __maybe_unused +static void __maybe_unused build_get_pgde32(u32 **p, unsigned int tmp, unsigned int ptr) { long pgdc = (long)pgd_current; @@ -991,7 +982,7 @@ build_get_pgde32(u32 **p, unsigned int tmp, unsigned int ptr) #endif /* !CONFIG_64BIT */ -static void __cpuinit build_adjust_context(u32 **p, unsigned int ctx) +static void build_adjust_context(u32 **p, unsigned int ctx) { unsigned int shift = 4 - (PTE_T_LOG2 + 1) + PAGE_SHIFT - 12; unsigned int mask = (PTRS_PER_PTE / 2 - 1) << (PTE_T_LOG2 + 1); @@ -1017,7 +1008,7 @@ static void __cpuinit build_adjust_context(u32 **p, unsigned int ctx) uasm_i_andi(p, ctx, ctx, mask); } -static void __cpuinit build_get_ptep(u32 **p, unsigned int tmp, unsigned int ptr) +static void build_get_ptep(u32 **p, unsigned int tmp, unsigned int ptr) { /* * Bug workaround for the Nevada. It seems as if under certain @@ -1042,8 +1033,7 @@ static void __cpuinit build_get_ptep(u32 **p, unsigned int tmp, unsigned int ptr UASM_i_ADDU(p, ptr, ptr, tmp); /* add in offset */ } -static void __cpuinit build_update_entries(u32 **p, unsigned int tmp, - unsigned int ptep) +static void build_update_entries(u32 **p, unsigned int tmp, unsigned int ptep) { /* * 64bit address support (36bit on a 32bit CPU) in a 32bit @@ -1104,7 +1094,7 @@ struct mips_huge_tlb_info { int restore_scratch; }; -static struct mips_huge_tlb_info __cpuinit +static struct mips_huge_tlb_info build_fast_tlb_refill_handler (u32 **p, struct uasm_label **l, struct uasm_reloc **r, unsigned int tmp, unsigned int ptr, int c0_scratch_reg) @@ -1282,7 +1272,7 @@ build_fast_tlb_refill_handler (u32 **p, struct uasm_label **l, */ #define MIPS64_REFILL_INSNS 32 -static void __cpuinit build_r4000_tlb_refill_handler(void) +static void build_r4000_tlb_refill_handler(void) { u32 *p = tlb_handler; struct uasm_label *l = labels; @@ -1462,7 +1452,7 @@ extern u32 handle_tlbm[], handle_tlbm_end[]; #ifdef CONFIG_MIPS_PGD_C0_CONTEXT extern u32 tlbmiss_handler_setup_pgd[], tlbmiss_handler_setup_pgd_end[]; -static void __cpuinit build_r4000_setup_pgd(void) +static void build_r4000_setup_pgd(void) { const int a0 = 4; const int a1 = 5; @@ -1513,7 +1503,7 @@ static void __cpuinit build_r4000_setup_pgd(void) } #endif -static void __cpuinit +static void iPTE_LW(u32 **p, unsigned int pte, unsigned int ptr) { #ifdef CONFIG_SMP @@ -1533,7 +1523,7 @@ iPTE_LW(u32 **p, unsigned int pte, unsigned int ptr) #endif } -static void __cpuinit +static void iPTE_SW(u32 **p, struct uasm_reloc **r, unsigned int pte, unsigned int ptr, unsigned int mode) { @@ -1593,7 +1583,7 @@ iPTE_SW(u32 **p, struct uasm_reloc **r, unsigned int pte, unsigned int ptr, * the page table where this PTE is located, PTE will be re-loaded * with it's original value. */ -static void __cpuinit +static void build_pte_present(u32 **p, struct uasm_reloc **r, int pte, int ptr, int scratch, enum label_id lid) { @@ -1621,7 +1611,7 @@ build_pte_present(u32 **p, struct uasm_reloc **r, } /* Make PTE valid, store result in PTR. */ -static void __cpuinit +static void build_make_valid(u32 **p, struct uasm_reloc **r, unsigned int pte, unsigned int ptr) { @@ -1634,7 +1624,7 @@ build_make_valid(u32 **p, struct uasm_reloc **r, unsigned int pte, * Check if PTE can be written to, if not branch to LABEL. Regardless * restore PTE with value from PTR when done. */ -static void __cpuinit +static void build_pte_writable(u32 **p, struct uasm_reloc **r, unsigned int pte, unsigned int ptr, int scratch, enum label_id lid) @@ -1654,7 +1644,7 @@ build_pte_writable(u32 **p, struct uasm_reloc **r, /* Make PTE writable, update software status bits as well, then store * at PTR. */ -static void __cpuinit +static void build_make_write(u32 **p, struct uasm_reloc **r, unsigned int pte, unsigned int ptr) { @@ -1668,7 +1658,7 @@ build_make_write(u32 **p, struct uasm_reloc **r, unsigned int pte, * Check if PTE can be modified, if not branch to LABEL. Regardless * restore PTE with value from PTR when done. */ -static void __cpuinit +static void build_pte_modifiable(u32 **p, struct uasm_reloc **r, unsigned int pte, unsigned int ptr, int scratch, enum label_id lid) @@ -1697,7 +1687,7 @@ build_pte_modifiable(u32 **p, struct uasm_reloc **r, * This places the pte into ENTRYLO0 and writes it with tlbwi. * Then it returns. */ -static void __cpuinit +static void build_r3000_pte_reload_tlbwi(u32 **p, unsigned int pte, unsigned int tmp) { uasm_i_mtc0(p, pte, C0_ENTRYLO0); /* cp0 delay */ @@ -1713,7 +1703,7 @@ build_r3000_pte_reload_tlbwi(u32 **p, unsigned int pte, unsigned int tmp) * may have the probe fail bit set as a result of a trap on a * kseg2 access, i.e. without refill. Then it returns. */ -static void __cpuinit +static void build_r3000_tlb_reload_write(u32 **p, struct uasm_label **l, struct uasm_reloc **r, unsigned int pte, unsigned int tmp) @@ -1731,7 +1721,7 @@ build_r3000_tlb_reload_write(u32 **p, struct uasm_label **l, uasm_i_rfe(p); /* branch delay */ } -static void __cpuinit +static void build_r3000_tlbchange_handler_head(u32 **p, unsigned int pte, unsigned int ptr) { @@ -1751,7 +1741,7 @@ build_r3000_tlbchange_handler_head(u32 **p, unsigned int pte, uasm_i_tlbp(p); /* load delay */ } -static void __cpuinit build_r3000_tlb_load_handler(void) +static void build_r3000_tlb_load_handler(void) { u32 *p = handle_tlbl; const int handle_tlbl_size = handle_tlbl_end - handle_tlbl; @@ -1782,7 +1772,7 @@ static void __cpuinit build_r3000_tlb_load_handler(void) dump_handler("r3000_tlb_load", handle_tlbl, handle_tlbl_size); } -static void __cpuinit build_r3000_tlb_store_handler(void) +static void build_r3000_tlb_store_handler(void) { u32 *p = handle_tlbs; const int handle_tlbs_size = handle_tlbs_end - handle_tlbs; @@ -1813,7 +1803,7 @@ static void __cpuinit build_r3000_tlb_store_handler(void) dump_handler("r3000_tlb_store", handle_tlbs, handle_tlbs_size); } -static void __cpuinit build_r3000_tlb_modify_handler(void) +static void build_r3000_tlb_modify_handler(void) { u32 *p = handle_tlbm; const int handle_tlbm_size = handle_tlbm_end - handle_tlbm; @@ -1848,7 +1838,7 @@ static void __cpuinit build_r3000_tlb_modify_handler(void) /* * R4000 style TLB load/store/modify handlers. */ -static struct work_registers __cpuinit +static struct work_registers build_r4000_tlbchange_handler_head(u32 **p, struct uasm_label **l, struct uasm_reloc **r) { @@ -1884,7 +1874,7 @@ build_r4000_tlbchange_handler_head(u32 **p, struct uasm_label **l, return wr; } -static void __cpuinit +static void build_r4000_tlbchange_handler_tail(u32 **p, struct uasm_label **l, struct uasm_reloc **r, unsigned int tmp, unsigned int ptr) @@ -1902,7 +1892,7 @@ build_r4000_tlbchange_handler_tail(u32 **p, struct uasm_label **l, #endif } -static void __cpuinit build_r4000_tlb_load_handler(void) +static void build_r4000_tlb_load_handler(void) { u32 *p = handle_tlbl; const int handle_tlbl_size = handle_tlbl_end - handle_tlbl; @@ -2085,7 +2075,7 @@ static void __cpuinit build_r4000_tlb_load_handler(void) dump_handler("r4000_tlb_load", handle_tlbl, handle_tlbl_size); } -static void __cpuinit build_r4000_tlb_store_handler(void) +static void build_r4000_tlb_store_handler(void) { u32 *p = handle_tlbs; const int handle_tlbs_size = handle_tlbs_end - handle_tlbs; @@ -2140,7 +2130,7 @@ static void __cpuinit build_r4000_tlb_store_handler(void) dump_handler("r4000_tlb_store", handle_tlbs, handle_tlbs_size); } -static void __cpuinit build_r4000_tlb_modify_handler(void) +static void build_r4000_tlb_modify_handler(void) { u32 *p = handle_tlbm; const int handle_tlbm_size = handle_tlbm_end - handle_tlbm; @@ -2196,7 +2186,7 @@ static void __cpuinit build_r4000_tlb_modify_handler(void) dump_handler("r4000_tlb_modify", handle_tlbm, handle_tlbm_size); } -static void __cpuinit flush_tlb_handlers(void) +static void flush_tlb_handlers(void) { local_flush_icache_range((unsigned long)handle_tlbl, (unsigned long)handle_tlbl_end); @@ -2210,7 +2200,7 @@ static void __cpuinit flush_tlb_handlers(void) #endif } -void __cpuinit build_tlb_refill_handler(void) +void build_tlb_refill_handler(void) { /* * The refill handler is generated per-CPU, multi-node systems diff --git a/arch/mips/mm/uasm-micromips.c b/arch/mips/mm/uasm-micromips.c index 162ee6d62788..060000fa653c 100644 --- a/arch/mips/mm/uasm-micromips.c +++ b/arch/mips/mm/uasm-micromips.c @@ -49,7 +49,7 @@ #include "uasm.c" -static struct insn insn_table_MM[] __uasminitdata = { +static struct insn insn_table_MM[] = { { insn_addu, M(mm_pool32a_op, 0, 0, 0, 0, mm_addu32_op), RT | RS | RD }, { insn_addiu, M(mm_addiu32_op, 0, 0, 0, 0, 0), RT | RS | SIMM }, { insn_and, M(mm_pool32a_op, 0, 0, 0, 0, mm_and_op), RT | RS | RD }, @@ -118,7 +118,7 @@ static struct insn insn_table_MM[] __uasminitdata = { #undef M -static inline __uasminit u32 build_bimm(s32 arg) +static inline u32 build_bimm(s32 arg) { WARN(arg > 0xffff || arg < -0x10000, KERN_WARNING "Micro-assembler field overflow\n"); @@ -128,7 +128,7 @@ static inline __uasminit u32 build_bimm(s32 arg) return ((arg < 0) ? (1 << 15) : 0) | ((arg >> 1) & 0x7fff); } -static inline __uasminit u32 build_jimm(u32 arg) +static inline u32 build_jimm(u32 arg) { WARN(arg & ~((JIMM_MASK << 2) | 1), @@ -141,7 +141,7 @@ static inline __uasminit u32 build_jimm(u32 arg) * The order of opcode arguments is implicitly left to right, * starting with RS and ending with FUNC or IMM. */ -static void __uasminit build_insn(u32 **buf, enum opcode opc, ...) +static void build_insn(u32 **buf, enum opcode opc, ...) { struct insn *ip = NULL; unsigned int i; @@ -199,7 +199,7 @@ static void __uasminit build_insn(u32 **buf, enum opcode opc, ...) (*buf)++; } -static inline void __uasminit +static inline void __resolve_relocs(struct uasm_reloc *rel, struct uasm_label *lab) { long laddr = (long)lab->addr; diff --git a/arch/mips/mm/uasm-mips.c b/arch/mips/mm/uasm-mips.c index 5fcdd8fe3e83..0c724589854e 100644 --- a/arch/mips/mm/uasm-mips.c +++ b/arch/mips/mm/uasm-mips.c @@ -49,7 +49,7 @@ #include "uasm.c" -static struct insn insn_table[] __uasminitdata = { +static struct insn insn_table[] = { { insn_addiu, M(addiu_op, 0, 0, 0, 0, 0), RS | RT | SIMM }, { insn_addu, M(spec_op, 0, 0, 0, 0, addu_op), RS | RT | RD }, { insn_andi, M(andi_op, 0, 0, 0, 0, 0), RS | RT | UIMM }, @@ -119,7 +119,7 @@ static struct insn insn_table[] __uasminitdata = { #undef M -static inline __uasminit u32 build_bimm(s32 arg) +static inline u32 build_bimm(s32 arg) { WARN(arg > 0x1ffff || arg < -0x20000, KERN_WARNING "Micro-assembler field overflow\n"); @@ -129,7 +129,7 @@ static inline __uasminit u32 build_bimm(s32 arg) return ((arg < 0) ? (1 << 15) : 0) | ((arg >> 2) & 0x7fff); } -static inline __uasminit u32 build_jimm(u32 arg) +static inline u32 build_jimm(u32 arg) { WARN(arg & ~(JIMM_MASK << 2), KERN_WARNING "Micro-assembler field overflow\n"); @@ -141,7 +141,7 @@ static inline __uasminit u32 build_jimm(u32 arg) * The order of opcode arguments is implicitly left to right, * starting with RS and ending with FUNC or IMM. */ -static void __uasminit build_insn(u32 **buf, enum opcode opc, ...) +static void build_insn(u32 **buf, enum opcode opc, ...) { struct insn *ip = NULL; unsigned int i; @@ -187,7 +187,7 @@ static void __uasminit build_insn(u32 **buf, enum opcode opc, ...) (*buf)++; } -static inline void __uasminit +static inline void __resolve_relocs(struct uasm_reloc *rel, struct uasm_label *lab) { long laddr = (long)lab->addr; diff --git a/arch/mips/mm/uasm.c b/arch/mips/mm/uasm.c index 7eb5e4355d25..b9d14b6c7f58 100644 --- a/arch/mips/mm/uasm.c +++ b/arch/mips/mm/uasm.c @@ -63,35 +63,35 @@ struct insn { enum fields fields; }; -static inline __uasminit u32 build_rs(u32 arg) +static inline u32 build_rs(u32 arg) { WARN(arg & ~RS_MASK, KERN_WARNING "Micro-assembler field overflow\n"); return (arg & RS_MASK) << RS_SH; } -static inline __uasminit u32 build_rt(u32 arg) +static inline u32 build_rt(u32 arg) { WARN(arg & ~RT_MASK, KERN_WARNING "Micro-assembler field overflow\n"); return (arg & RT_MASK) << RT_SH; } -static inline __uasminit u32 build_rd(u32 arg) +static inline u32 build_rd(u32 arg) { WARN(arg & ~RD_MASK, KERN_WARNING "Micro-assembler field overflow\n"); return (arg & RD_MASK) << RD_SH; } -static inline __uasminit u32 build_re(u32 arg) +static inline u32 build_re(u32 arg) { WARN(arg & ~RE_MASK, KERN_WARNING "Micro-assembler field overflow\n"); return (arg & RE_MASK) << RE_SH; } -static inline __uasminit u32 build_simm(s32 arg) +static inline u32 build_simm(s32 arg) { WARN(arg > 0x7fff || arg < -0x8000, KERN_WARNING "Micro-assembler field overflow\n"); @@ -99,14 +99,14 @@ static inline __uasminit u32 build_simm(s32 arg) return arg & 0xffff; } -static inline __uasminit u32 build_uimm(u32 arg) +static inline u32 build_uimm(u32 arg) { WARN(arg & ~IMM_MASK, KERN_WARNING "Micro-assembler field overflow\n"); return arg & IMM_MASK; } -static inline __uasminit u32 build_scimm(u32 arg) +static inline u32 build_scimm(u32 arg) { WARN(arg & ~SCIMM_MASK, KERN_WARNING "Micro-assembler field overflow\n"); @@ -114,21 +114,21 @@ static inline __uasminit u32 build_scimm(u32 arg) return (arg & SCIMM_MASK) << SCIMM_SH; } -static inline __uasminit u32 build_func(u32 arg) +static inline u32 build_func(u32 arg) { WARN(arg & ~FUNC_MASK, KERN_WARNING "Micro-assembler field overflow\n"); return arg & FUNC_MASK; } -static inline __uasminit u32 build_set(u32 arg) +static inline u32 build_set(u32 arg) { WARN(arg & ~SET_MASK, KERN_WARNING "Micro-assembler field overflow\n"); return arg & SET_MASK; } -static void __uasminit build_insn(u32 **buf, enum opcode opc, ...); +static void build_insn(u32 **buf, enum opcode opc, ...); #define I_u1u2u3(op) \ Ip_u1u2u3(op) \ @@ -286,7 +286,7 @@ I_u3u1u2(_ldx) #ifdef CONFIG_CPU_CAVIUM_OCTEON #include -void __uasminit ISAFUNC(uasm_i_pref)(u32 **buf, unsigned int a, signed int b, +void ISAFUNC(uasm_i_pref)(u32 **buf, unsigned int a, signed int b, unsigned int c) { if (OCTEON_IS_MODEL(OCTEON_CN63XX_PASS1_X) && a <= 24 && a != 5) @@ -304,7 +304,7 @@ I_u2s3u1(_pref) #endif /* Handle labels. */ -void __uasminit ISAFUNC(uasm_build_label)(struct uasm_label **lab, u32 *addr, int lid) +void ISAFUNC(uasm_build_label)(struct uasm_label **lab, u32 *addr, int lid) { (*lab)->addr = addr; (*lab)->lab = lid; @@ -312,7 +312,7 @@ void __uasminit ISAFUNC(uasm_build_label)(struct uasm_label **lab, u32 *addr, in } UASM_EXPORT_SYMBOL(ISAFUNC(uasm_build_label)); -int __uasminit ISAFUNC(uasm_in_compat_space_p)(long addr) +int ISAFUNC(uasm_in_compat_space_p)(long addr) { /* Is this address in 32bit compat space? */ #ifdef CONFIG_64BIT @@ -323,7 +323,7 @@ int __uasminit ISAFUNC(uasm_in_compat_space_p)(long addr) } UASM_EXPORT_SYMBOL(ISAFUNC(uasm_in_compat_space_p)); -static int __uasminit uasm_rel_highest(long val) +static int uasm_rel_highest(long val) { #ifdef CONFIG_64BIT return ((((val + 0x800080008000L) >> 48) & 0xffff) ^ 0x8000) - 0x8000; @@ -332,7 +332,7 @@ static int __uasminit uasm_rel_highest(long val) #endif } -static int __uasminit uasm_rel_higher(long val) +static int uasm_rel_higher(long val) { #ifdef CONFIG_64BIT return ((((val + 0x80008000L) >> 32) & 0xffff) ^ 0x8000) - 0x8000; @@ -341,19 +341,19 @@ static int __uasminit uasm_rel_higher(long val) #endif } -int __uasminit ISAFUNC(uasm_rel_hi)(long val) +int ISAFUNC(uasm_rel_hi)(long val) { return ((((val + 0x8000L) >> 16) & 0xffff) ^ 0x8000) - 0x8000; } UASM_EXPORT_SYMBOL(ISAFUNC(uasm_rel_hi)); -int __uasminit ISAFUNC(uasm_rel_lo)(long val) +int ISAFUNC(uasm_rel_lo)(long val) { return ((val & 0xffff) ^ 0x8000) - 0x8000; } UASM_EXPORT_SYMBOL(ISAFUNC(uasm_rel_lo)); -void __uasminit ISAFUNC(UASM_i_LA_mostly)(u32 **buf, unsigned int rs, long addr) +void ISAFUNC(UASM_i_LA_mostly)(u32 **buf, unsigned int rs, long addr) { if (!ISAFUNC(uasm_in_compat_space_p)(addr)) { ISAFUNC(uasm_i_lui)(buf, rs, uasm_rel_highest(addr)); @@ -371,7 +371,7 @@ void __uasminit ISAFUNC(UASM_i_LA_mostly)(u32 **buf, unsigned int rs, long addr) } UASM_EXPORT_SYMBOL(ISAFUNC(UASM_i_LA_mostly)); -void __uasminit ISAFUNC(UASM_i_LA)(u32 **buf, unsigned int rs, long addr) +void ISAFUNC(UASM_i_LA)(u32 **buf, unsigned int rs, long addr) { ISAFUNC(UASM_i_LA_mostly)(buf, rs, addr); if (ISAFUNC(uasm_rel_lo(addr))) { @@ -386,8 +386,7 @@ void __uasminit ISAFUNC(UASM_i_LA)(u32 **buf, unsigned int rs, long addr) UASM_EXPORT_SYMBOL(ISAFUNC(UASM_i_LA)); /* Handle relocations. */ -void __uasminit -ISAFUNC(uasm_r_mips_pc16)(struct uasm_reloc **rel, u32 *addr, int lid) +void ISAFUNC(uasm_r_mips_pc16)(struct uasm_reloc **rel, u32 *addr, int lid) { (*rel)->addr = addr; (*rel)->type = R_MIPS_PC16; @@ -396,11 +395,11 @@ ISAFUNC(uasm_r_mips_pc16)(struct uasm_reloc **rel, u32 *addr, int lid) } UASM_EXPORT_SYMBOL(ISAFUNC(uasm_r_mips_pc16)); -static inline void __uasminit -__resolve_relocs(struct uasm_reloc *rel, struct uasm_label *lab); +static inline void __resolve_relocs(struct uasm_reloc *rel, + struct uasm_label *lab); -void __uasminit -ISAFUNC(uasm_resolve_relocs)(struct uasm_reloc *rel, struct uasm_label *lab) +void ISAFUNC(uasm_resolve_relocs)(struct uasm_reloc *rel, + struct uasm_label *lab) { struct uasm_label *l; @@ -411,8 +410,8 @@ ISAFUNC(uasm_resolve_relocs)(struct uasm_reloc *rel, struct uasm_label *lab) } UASM_EXPORT_SYMBOL(ISAFUNC(uasm_resolve_relocs)); -void __uasminit -ISAFUNC(uasm_move_relocs)(struct uasm_reloc *rel, u32 *first, u32 *end, long off) +void ISAFUNC(uasm_move_relocs)(struct uasm_reloc *rel, u32 *first, u32 *end, + long off) { for (; rel->lab != UASM_LABEL_INVALID; rel++) if (rel->addr >= first && rel->addr < end) @@ -420,8 +419,8 @@ ISAFUNC(uasm_move_relocs)(struct uasm_reloc *rel, u32 *first, u32 *end, long off } UASM_EXPORT_SYMBOL(ISAFUNC(uasm_move_relocs)); -void __uasminit -ISAFUNC(uasm_move_labels)(struct uasm_label *lab, u32 *first, u32 *end, long off) +void ISAFUNC(uasm_move_labels)(struct uasm_label *lab, u32 *first, u32 *end, + long off) { for (; lab->lab != UASM_LABEL_INVALID; lab++) if (lab->addr >= first && lab->addr < end) @@ -429,9 +428,8 @@ ISAFUNC(uasm_move_labels)(struct uasm_label *lab, u32 *first, u32 *end, long off } UASM_EXPORT_SYMBOL(ISAFUNC(uasm_move_labels)); -void __uasminit -ISAFUNC(uasm_copy_handler)(struct uasm_reloc *rel, struct uasm_label *lab, u32 *first, - u32 *end, u32 *target) +void ISAFUNC(uasm_copy_handler)(struct uasm_reloc *rel, struct uasm_label *lab, + u32 *first, u32 *end, u32 *target) { long off = (long)(target - first); @@ -442,7 +440,7 @@ ISAFUNC(uasm_copy_handler)(struct uasm_reloc *rel, struct uasm_label *lab, u32 * } UASM_EXPORT_SYMBOL(ISAFUNC(uasm_copy_handler)); -int __uasminit ISAFUNC(uasm_insn_has_bdelay)(struct uasm_reloc *rel, u32 *addr) +int ISAFUNC(uasm_insn_has_bdelay)(struct uasm_reloc *rel, u32 *addr) { for (; rel->lab != UASM_LABEL_INVALID; rel++) { if (rel->addr == addr @@ -456,83 +454,79 @@ int __uasminit ISAFUNC(uasm_insn_has_bdelay)(struct uasm_reloc *rel, u32 *addr) UASM_EXPORT_SYMBOL(ISAFUNC(uasm_insn_has_bdelay)); /* Convenience functions for labeled branches. */ -void __uasminit -ISAFUNC(uasm_il_bltz)(u32 **p, struct uasm_reloc **r, unsigned int reg, int lid) +void ISAFUNC(uasm_il_bltz)(u32 **p, struct uasm_reloc **r, unsigned int reg, + int lid) { uasm_r_mips_pc16(r, *p, lid); ISAFUNC(uasm_i_bltz)(p, reg, 0); } UASM_EXPORT_SYMBOL(ISAFUNC(uasm_il_bltz)); -void __uasminit -ISAFUNC(uasm_il_b)(u32 **p, struct uasm_reloc **r, int lid) +void ISAFUNC(uasm_il_b)(u32 **p, struct uasm_reloc **r, int lid) { uasm_r_mips_pc16(r, *p, lid); ISAFUNC(uasm_i_b)(p, 0); } UASM_EXPORT_SYMBOL(ISAFUNC(uasm_il_b)); -void __uasminit -ISAFUNC(uasm_il_beqz)(u32 **p, struct uasm_reloc **r, unsigned int reg, int lid) +void ISAFUNC(uasm_il_beqz)(u32 **p, struct uasm_reloc **r, unsigned int reg, + int lid) { uasm_r_mips_pc16(r, *p, lid); ISAFUNC(uasm_i_beqz)(p, reg, 0); } UASM_EXPORT_SYMBOL(ISAFUNC(uasm_il_beqz)); -void __uasminit -ISAFUNC(uasm_il_beqzl)(u32 **p, struct uasm_reloc **r, unsigned int reg, int lid) +void ISAFUNC(uasm_il_beqzl)(u32 **p, struct uasm_reloc **r, unsigned int reg, + int lid) { uasm_r_mips_pc16(r, *p, lid); ISAFUNC(uasm_i_beqzl)(p, reg, 0); } UASM_EXPORT_SYMBOL(ISAFUNC(uasm_il_beqzl)); -void __uasminit -ISAFUNC(uasm_il_bne)(u32 **p, struct uasm_reloc **r, unsigned int reg1, - unsigned int reg2, int lid) +void ISAFUNC(uasm_il_bne)(u32 **p, struct uasm_reloc **r, unsigned int reg1, + unsigned int reg2, int lid) { uasm_r_mips_pc16(r, *p, lid); ISAFUNC(uasm_i_bne)(p, reg1, reg2, 0); } UASM_EXPORT_SYMBOL(ISAFUNC(uasm_il_bne)); -void __uasminit -ISAFUNC(uasm_il_bnez)(u32 **p, struct uasm_reloc **r, unsigned int reg, int lid) +void ISAFUNC(uasm_il_bnez)(u32 **p, struct uasm_reloc **r, unsigned int reg, + int lid) { uasm_r_mips_pc16(r, *p, lid); ISAFUNC(uasm_i_bnez)(p, reg, 0); } UASM_EXPORT_SYMBOL(ISAFUNC(uasm_il_bnez)); -void __uasminit -ISAFUNC(uasm_il_bgezl)(u32 **p, struct uasm_reloc **r, unsigned int reg, int lid) +void ISAFUNC(uasm_il_bgezl)(u32 **p, struct uasm_reloc **r, unsigned int reg, + int lid) { uasm_r_mips_pc16(r, *p, lid); ISAFUNC(uasm_i_bgezl)(p, reg, 0); } UASM_EXPORT_SYMBOL(ISAFUNC(uasm_il_bgezl)); -void __uasminit -ISAFUNC(uasm_il_bgez)(u32 **p, struct uasm_reloc **r, unsigned int reg, int lid) +void ISAFUNC(uasm_il_bgez)(u32 **p, struct uasm_reloc **r, unsigned int reg, + int lid) { uasm_r_mips_pc16(r, *p, lid); ISAFUNC(uasm_i_bgez)(p, reg, 0); } UASM_EXPORT_SYMBOL(ISAFUNC(uasm_il_bgez)); -void __uasminit -ISAFUNC(uasm_il_bbit0)(u32 **p, struct uasm_reloc **r, unsigned int reg, - unsigned int bit, int lid) +void ISAFUNC(uasm_il_bbit0)(u32 **p, struct uasm_reloc **r, unsigned int reg, + unsigned int bit, int lid) { uasm_r_mips_pc16(r, *p, lid); ISAFUNC(uasm_i_bbit0)(p, reg, bit, 0); } UASM_EXPORT_SYMBOL(ISAFUNC(uasm_il_bbit0)); -void __uasminit -ISAFUNC(uasm_il_bbit1)(u32 **p, struct uasm_reloc **r, unsigned int reg, - unsigned int bit, int lid) +void ISAFUNC(uasm_il_bbit1)(u32 **p, struct uasm_reloc **r, unsigned int reg, + unsigned int bit, int lid) { uasm_r_mips_pc16(r, *p, lid); ISAFUNC(uasm_i_bbit1)(p, reg, bit, 0); diff --git a/arch/mips/mti-malta/malta-smtc.c b/arch/mips/mti-malta/malta-smtc.c index becbf47506a5..c4849904f013 100644 --- a/arch/mips/mti-malta/malta-smtc.c +++ b/arch/mips/mti-malta/malta-smtc.c @@ -32,7 +32,7 @@ static void msmtc_send_ipi_mask(const struct cpumask *mask, unsigned int action) /* * Post-config but pre-boot cleanup entry point */ -static void __cpuinit msmtc_init_secondary(void) +static void msmtc_init_secondary(void) { int myvpe; @@ -53,7 +53,7 @@ static void __cpuinit msmtc_init_secondary(void) /* * Platform "CPU" startup hook */ -static void __cpuinit msmtc_boot_secondary(int cpu, struct task_struct *idle) +static void msmtc_boot_secondary(int cpu, struct task_struct *idle) { smtc_boot_secondary(cpu, idle); } @@ -61,7 +61,7 @@ static void __cpuinit msmtc_boot_secondary(int cpu, struct task_struct *idle) /* * SMP initialization finalization entry point */ -static void __cpuinit msmtc_smp_finish(void) +static void msmtc_smp_finish(void) { smtc_smp_finish(); } diff --git a/arch/mips/mti-malta/malta-time.c b/arch/mips/mti-malta/malta-time.c index 0ad305f75802..53aad4a35375 100644 --- a/arch/mips/mti-malta/malta-time.c +++ b/arch/mips/mti-malta/malta-time.c @@ -150,7 +150,7 @@ static void __init plat_perf_setup(void) } } -unsigned int __cpuinit get_c0_compare_int(void) +unsigned int get_c0_compare_int(void) { #ifdef MSC01E_INT_BASE if (cpu_has_veic) { diff --git a/arch/mips/mti-sead3/sead3-time.c b/arch/mips/mti-sead3/sead3-time.c index 96b42eb9b5e2..a43ea3cc0a3b 100644 --- a/arch/mips/mti-sead3/sead3-time.c +++ b/arch/mips/mti-sead3/sead3-time.c @@ -91,7 +91,7 @@ static void __init plat_perf_setup(void) } } -unsigned int __cpuinit get_c0_compare_int(void) +unsigned int get_c0_compare_int(void) { if (cpu_has_vint) set_vi_handler(cp0_compare_irq, mips_timer_dispatch); diff --git a/arch/mips/netlogic/common/smp.c b/arch/mips/netlogic/common/smp.c index 885d293b61da..4e35d9c453e2 100644 --- a/arch/mips/netlogic/common/smp.c +++ b/arch/mips/netlogic/common/smp.c @@ -116,7 +116,7 @@ void nlm_early_init_secondary(int cpu) /* * Code to run on secondary just after probing the CPU */ -static void __cpuinit nlm_init_secondary(void) +static void nlm_init_secondary(void) { int hwtid; @@ -252,7 +252,7 @@ unsupp: return 0; } -int __cpuinit nlm_wakeup_secondary_cpus(void) +int nlm_wakeup_secondary_cpus(void) { u32 *reset_data; int threadmode; diff --git a/arch/mips/netlogic/common/smpboot.S b/arch/mips/netlogic/common/smpboot.S index 528c46c5a170..aa6cff0a229b 100644 --- a/arch/mips/netlogic/common/smpboot.S +++ b/arch/mips/netlogic/common/smpboot.S @@ -70,7 +70,6 @@ FEXPORT(xlp_boot_core0_siblings) /* "Master" cpu starts from here */ nop /* not reached */ - __CPUINIT NESTED(nlm_boot_secondary_cpus, 16, sp) /* Initialize CP0 Status */ move t1, zero @@ -94,7 +93,6 @@ NESTED(nlm_boot_secondary_cpus, 16, sp) jr t0 nop END(nlm_boot_secondary_cpus) - __FINIT /* * In case of RMIboot bootloader which is used on XLR boards, the CPUs @@ -102,7 +100,6 @@ END(nlm_boot_secondary_cpus) * This will get them out of the bootloader code and into linux. Needed * because the bootloader area will be taken and initialized by linux. */ - __CPUINIT NESTED(nlm_rmiboot_preboot, 16, sp) mfc0 t0, $15, 1 /* read ebase */ andi t0, 0x1f /* t0 has the processor_id() */ @@ -140,4 +137,3 @@ NESTED(nlm_rmiboot_preboot, 16, sp) b 1b nop END(nlm_rmiboot_preboot) - __FINIT diff --git a/arch/mips/netlogic/common/time.c b/arch/mips/netlogic/common/time.c index 5c56555380bb..045a396c57ce 100644 --- a/arch/mips/netlogic/common/time.c +++ b/arch/mips/netlogic/common/time.c @@ -54,7 +54,7 @@ #error "Unknown CPU" #endif -unsigned int __cpuinit get_c0_compare_int(void) +unsigned int get_c0_compare_int(void) { return IRQ_TIMER; } diff --git a/arch/mips/netlogic/xlr/wakeup.c b/arch/mips/netlogic/xlr/wakeup.c index c06e4c9f0478..9fb81fa6272a 100644 --- a/arch/mips/netlogic/xlr/wakeup.c +++ b/arch/mips/netlogic/xlr/wakeup.c @@ -49,7 +49,7 @@ #include #include -int __cpuinit xlr_wakeup_secondary_cpus(void) +int xlr_wakeup_secondary_cpus(void) { struct nlm_soc_info *nodep; unsigned int i, j, boot_cpu; diff --git a/arch/mips/pci/pci-ip27.c b/arch/mips/pci/pci-ip27.c index 7b2ac81e1f59..162b4cb29dba 100644 --- a/arch/mips/pci/pci-ip27.c +++ b/arch/mips/pci/pci-ip27.c @@ -42,7 +42,7 @@ int irq_to_slot[MAX_PCI_BUSSES * MAX_DEVICES_PER_PCIBUS]; extern struct pci_ops bridge_pci_ops; -int __cpuinit bridge_probe(nasid_t nasid, int widget_id, int masterwid) +int bridge_probe(nasid_t nasid, int widget_id, int masterwid) { unsigned long offset = NODE_OFFSET(nasid); struct bridge_controller *bc; diff --git a/arch/mips/pmcs-msp71xx/msp_smtc.c b/arch/mips/pmcs-msp71xx/msp_smtc.c index c8dcc1c01e18..6b5607fce279 100644 --- a/arch/mips/pmcs-msp71xx/msp_smtc.c +++ b/arch/mips/pmcs-msp71xx/msp_smtc.c @@ -33,7 +33,7 @@ static void msp_smtc_send_ipi_mask(const struct cpumask *mask, /* * Post-config but pre-boot cleanup entry point */ -static void __cpuinit msp_smtc_init_secondary(void) +static void msp_smtc_init_secondary(void) { int myvpe; @@ -48,8 +48,7 @@ static void __cpuinit msp_smtc_init_secondary(void) /* * Platform "CPU" startup hook */ -static void __cpuinit msp_smtc_boot_secondary(int cpu, - struct task_struct *idle) +static void msp_smtc_boot_secondary(int cpu, struct task_struct *idle) { smtc_boot_secondary(cpu, idle); } @@ -57,7 +56,7 @@ static void __cpuinit msp_smtc_boot_secondary(int cpu, /* * SMP initialization finalization entry point */ -static void __cpuinit msp_smtc_smp_finish(void) +static void msp_smtc_smp_finish(void) { smtc_smp_finish(); } diff --git a/arch/mips/pmcs-msp71xx/msp_time.c b/arch/mips/pmcs-msp71xx/msp_time.c index 8f12ecc55ace..fea917be0ff1 100644 --- a/arch/mips/pmcs-msp71xx/msp_time.c +++ b/arch/mips/pmcs-msp71xx/msp_time.c @@ -88,7 +88,7 @@ void __init plat_time_init(void) mips_hpt_frequency = cpu_rate/2; } -unsigned int __cpuinit get_c0_compare_int(void) +unsigned int get_c0_compare_int(void) { /* MIPS_MT modes may want timer for second VPE */ if ((get_current_vpe()) && !tim_installed) { diff --git a/arch/mips/pnx833x/common/interrupts.c b/arch/mips/pnx833x/common/interrupts.c index a4a90596c0ad..e460865873c1 100644 --- a/arch/mips/pnx833x/common/interrupts.c +++ b/arch/mips/pnx833x/common/interrupts.c @@ -281,7 +281,7 @@ void __init arch_init_irq(void) write_c0_status(read_c0_status() | IE_IRQ2); } -unsigned int __cpuinit get_c0_compare_int(void) +unsigned int get_c0_compare_int(void) { if (cpu_has_vint) set_vi_handler(cp0_compare_irq, pnx833x_timer_dispatch); diff --git a/arch/mips/powertv/time.c b/arch/mips/powertv/time.c index 9fd7b67f2af7..f38b0d45eca9 100644 --- a/arch/mips/powertv/time.c +++ b/arch/mips/powertv/time.c @@ -25,7 +25,7 @@ #include "powertv-clock.h" -unsigned int __cpuinit get_c0_compare_int(void) +unsigned int get_c0_compare_int(void) { return irq_mips_timer; } diff --git a/arch/mips/ralink/irq.c b/arch/mips/ralink/irq.c index 320b1f1043ff..781b3d14a489 100644 --- a/arch/mips/ralink/irq.c +++ b/arch/mips/ralink/irq.c @@ -73,7 +73,7 @@ static struct irq_chip ralink_intc_irq_chip = { .irq_mask_ack = ralink_intc_irq_mask, }; -unsigned int __cpuinit get_c0_compare_int(void) +unsigned int get_c0_compare_int(void) { return CP0_LEGACY_COMPARE_IRQ; } diff --git a/arch/mips/sgi-ip27/ip27-init.c b/arch/mips/sgi-ip27/ip27-init.c index d41b1c6fb032..ee736bd103f8 100644 --- a/arch/mips/sgi-ip27/ip27-init.c +++ b/arch/mips/sgi-ip27/ip27-init.c @@ -54,7 +54,7 @@ extern void pcibr_setup(cnodeid_t); extern void xtalk_probe_node(cnodeid_t nid); -static void __cpuinit per_hub_init(cnodeid_t cnode) +static void per_hub_init(cnodeid_t cnode) { struct hub_data *hub = hub_data(cnode); nasid_t nasid = COMPACT_TO_NASID_NODEID(cnode); @@ -110,7 +110,7 @@ static void __cpuinit per_hub_init(cnodeid_t cnode) } } -void __cpuinit per_cpu_init(void) +void per_cpu_init(void) { int cpu = smp_processor_id(); int slice = LOCAL_HUB_L(PI_CPU_NUM); diff --git a/arch/mips/sgi-ip27/ip27-smp.c b/arch/mips/sgi-ip27/ip27-smp.c index f94638141b20..f4ea8aa79ba2 100644 --- a/arch/mips/sgi-ip27/ip27-smp.c +++ b/arch/mips/sgi-ip27/ip27-smp.c @@ -173,12 +173,12 @@ static void ip27_send_ipi_mask(const struct cpumask *mask, unsigned int action) ip27_send_ipi_single(i, action); } -static void __cpuinit ip27_init_secondary(void) +static void ip27_init_secondary(void) { per_cpu_init(); } -static void __cpuinit ip27_smp_finish(void) +static void ip27_smp_finish(void) { extern void hub_rt_clock_event_init(void); @@ -195,7 +195,7 @@ static void __init ip27_cpus_done(void) * set sp to the kernel stack of the newly created idle process, gp to the proc * struct so that current_thread_info() will work. */ -static void __cpuinit ip27_boot_secondary(int cpu, struct task_struct *idle) +static void ip27_boot_secondary(int cpu, struct task_struct *idle) { unsigned long gp = (unsigned long)task_thread_info(idle); unsigned long sp = __KSTK_TOS(idle); diff --git a/arch/mips/sgi-ip27/ip27-timer.c b/arch/mips/sgi-ip27/ip27-timer.c index 2e21b761cb9c..1d97eaba0c5f 100644 --- a/arch/mips/sgi-ip27/ip27-timer.c +++ b/arch/mips/sgi-ip27/ip27-timer.c @@ -106,7 +106,7 @@ struct irqaction hub_rt_irqaction = { #define NSEC_PER_CYCLE 800 #define CYCLES_PER_SEC (NSEC_PER_SEC / NSEC_PER_CYCLE) -void __cpuinit hub_rt_clock_event_init(void) +void hub_rt_clock_event_init(void) { unsigned int cpu = smp_processor_id(); struct clock_event_device *cd = &per_cpu(hub_rt_clockevent, cpu); @@ -173,7 +173,7 @@ void __init plat_time_init(void) hub_rt_clock_event_init(); } -void __cpuinit cpu_time_init(void) +void cpu_time_init(void) { lboard_t *board; klcpu_t *cpu; @@ -194,7 +194,7 @@ void __cpuinit cpu_time_init(void) set_c0_status(SRB_TIMOCLK); } -void __cpuinit hub_rtc_init(cnodeid_t cnode) +void hub_rtc_init(cnodeid_t cnode) { /* diff --git a/arch/mips/sgi-ip27/ip27-xtalk.c b/arch/mips/sgi-ip27/ip27-xtalk.c index a4df7d0f6f12..d59b820f528d 100644 --- a/arch/mips/sgi-ip27/ip27-xtalk.c +++ b/arch/mips/sgi-ip27/ip27-xtalk.c @@ -23,7 +23,7 @@ extern int bridge_probe(nasid_t nasid, int widget, int masterwid); -static int __cpuinit probe_one_port(nasid_t nasid, int widget, int masterwid) +static int probe_one_port(nasid_t nasid, int widget, int masterwid) { widgetreg_t widget_id; xwidget_part_num_t partnum; @@ -47,7 +47,7 @@ static int __cpuinit probe_one_port(nasid_t nasid, int widget, int masterwid) return 0; } -static int __cpuinit xbow_probe(nasid_t nasid) +static int xbow_probe(nasid_t nasid) { lboard_t *brd; klxbow_t *xbow_p; @@ -100,7 +100,7 @@ static int __cpuinit xbow_probe(nasid_t nasid) return 0; } -void __cpuinit xtalk_probe_node(cnodeid_t nid) +void xtalk_probe_node(cnodeid_t nid) { volatile u64 hubreg; nasid_t nasid; diff --git a/arch/mips/sibyte/bcm1480/smp.c b/arch/mips/sibyte/bcm1480/smp.c index de88e22694a0..54e2c4de15c1 100644 --- a/arch/mips/sibyte/bcm1480/smp.c +++ b/arch/mips/sibyte/bcm1480/smp.c @@ -60,7 +60,7 @@ static void *mailbox_0_regs[] = { /* * SMP init and finish on secondary CPUs */ -void __cpuinit bcm1480_smp_init(void) +void bcm1480_smp_init(void) { unsigned int imask = STATUSF_IP4 | STATUSF_IP3 | STATUSF_IP2 | STATUSF_IP1 | STATUSF_IP0; @@ -95,7 +95,7 @@ static void bcm1480_send_ipi_mask(const struct cpumask *mask, /* * Code to run on secondary just after probing the CPU */ -static void __cpuinit bcm1480_init_secondary(void) +static void bcm1480_init_secondary(void) { extern void bcm1480_smp_init(void); @@ -106,7 +106,7 @@ static void __cpuinit bcm1480_init_secondary(void) * Do any tidying up before marking online and running the idle * loop */ -static void __cpuinit bcm1480_smp_finish(void) +static void bcm1480_smp_finish(void) { extern void sb1480_clockevent_init(void); @@ -125,7 +125,7 @@ static void bcm1480_cpus_done(void) * Setup the PC, SP, and GP of a secondary processor and start it * running! */ -static void __cpuinit bcm1480_boot_secondary(int cpu, struct task_struct *idle) +static void bcm1480_boot_secondary(int cpu, struct task_struct *idle) { int retval; diff --git a/arch/mips/sibyte/sb1250/smp.c b/arch/mips/sibyte/sb1250/smp.c index 285cfef4ebc0..d7b942db0ea5 100644 --- a/arch/mips/sibyte/sb1250/smp.c +++ b/arch/mips/sibyte/sb1250/smp.c @@ -48,7 +48,7 @@ static void *mailbox_regs[] = { /* * SMP init and finish on secondary CPUs */ -void __cpuinit sb1250_smp_init(void) +void sb1250_smp_init(void) { unsigned int imask = STATUSF_IP4 | STATUSF_IP3 | STATUSF_IP2 | STATUSF_IP1 | STATUSF_IP0; @@ -83,7 +83,7 @@ static inline void sb1250_send_ipi_mask(const struct cpumask *mask, /* * Code to run on secondary just after probing the CPU */ -static void __cpuinit sb1250_init_secondary(void) +static void sb1250_init_secondary(void) { extern void sb1250_smp_init(void); @@ -94,7 +94,7 @@ static void __cpuinit sb1250_init_secondary(void) * Do any tidying up before marking online and running the idle * loop */ -static void __cpuinit sb1250_smp_finish(void) +static void sb1250_smp_finish(void) { extern void sb1250_clockevent_init(void); @@ -113,7 +113,7 @@ static void sb1250_cpus_done(void) * Setup the PC, SP, and GP of a secondary processor and start it * running! */ -static void __cpuinit sb1250_boot_secondary(int cpu, struct task_struct *idle) +static void sb1250_boot_secondary(int cpu, struct task_struct *idle) { int retval; From 8bd26e3a7e49af2697449bbcb7187a39dc85d672 Mon Sep 17 00:00:00 2001 From: Paul Gortmaker Date: Mon, 17 Jun 2013 15:43:14 -0400 Subject: [PATCH 0904/1048] arm: delete __cpuinit/__CPUINIT usage from all ARM users The __cpuinit type of throwaway sections might have made sense some time ago when RAM was more constrained, but now the savings do not offset the cost and complications. For example, the fix in commit 5e427ec2d0 ("x86: Fix bit corruption at CPU resume time") is a good example of the nasty type of bugs that can be created with improper use of the various __init prefixes. After a discussion on LKML[1] it was decided that cpuinit should go the way of devinit and be phased out. Once all the users are gone, we can then finally remove the macros themselves from linux/init.h. Note that some harmless section mismatch warnings may result, since notify_cpu_starting() and cpu_up() are arch independent (kernel/cpu.c) and are flagged as __cpuinit -- so if we remove the __cpuinit from the arch specific callers, we will also get section mismatch warnings. As an intermediate step, we intend to turn the linux/init.h cpuinit related content into no-ops as early as possible, since that will get rid of these warnings. In any case, they are temporary and harmless. This removes all the ARM uses of the __cpuinit macros from C code, and all __CPUINIT from assembly code. It also had two ".previous" section statements that were paired off against __CPUINIT (aka .section ".cpuinit.text") that also get removed here. [1] https://lkml.org/lkml/2013/5/20/589 Cc: Russell King Cc: Will Deacon Cc: linux-arm-kernel@lists.infradead.org Signed-off-by: Paul Gortmaker --- arch/arm/common/mcpm_platsmp.c | 4 ++-- arch/arm/include/asm/arch_timer.h | 2 +- arch/arm/kernel/head-common.S | 1 - arch/arm/kernel/head-nommu.S | 1 - arch/arm/kernel/head.S | 1 - arch/arm/kernel/hw_breakpoint.c | 4 ++-- arch/arm/kernel/perf_event_cpu.c | 6 +++--- arch/arm/kernel/psci_smp.c | 3 +-- arch/arm/kernel/smp.c | 18 +++++++++--------- arch/arm/kernel/smp_twd.c | 6 +++--- arch/arm/lib/delay.c | 2 +- arch/arm/mach-exynos/headsmp.S | 2 -- arch/arm/mach-exynos/platsmp.c | 4 ++-- arch/arm/mach-highbank/platsmp.c | 2 +- arch/arm/mach-imx/platsmp.c | 2 +- arch/arm/mach-keystone/platsmp.c | 2 +- arch/arm/mach-msm/headsmp.S | 2 -- arch/arm/mach-msm/platsmp.c | 6 +++--- arch/arm/mach-msm/timer.c | 4 ++-- arch/arm/mach-mvebu/coherency.c | 2 +- arch/arm/mach-mvebu/headsmp.S | 2 -- arch/arm/mach-mvebu/platsmp.c | 5 ++--- arch/arm/mach-omap2/omap-headsmp.S | 2 -- arch/arm/mach-omap2/omap-mpuss-lowpower.c | 2 +- arch/arm/mach-omap2/omap-smp.c | 4 ++-- arch/arm/mach-omap2/omap-wakeupgen.c | 4 ++-- arch/arm/mach-prima2/headsmp.S | 2 -- arch/arm/mach-prima2/platsmp.c | 4 ++-- arch/arm/mach-shmobile/headsmp-scu.S | 1 - arch/arm/mach-shmobile/headsmp.S | 2 -- arch/arm/mach-shmobile/smp-emev2.c | 2 +- arch/arm/mach-shmobile/smp-r8a7779.c | 2 +- arch/arm/mach-shmobile/smp-sh73a0.c | 2 +- arch/arm/mach-socfpga/headsmp.S | 1 - arch/arm/mach-socfpga/platsmp.c | 2 +- arch/arm/mach-spear/generic.h | 2 +- arch/arm/mach-spear/platsmp.c | 4 ++-- arch/arm/mach-sti/platsmp.c | 6 +++--- arch/arm/mach-tegra/platsmp.c | 4 ++-- arch/arm/mach-tegra/pm.c | 2 +- arch/arm/mach-ux500/platsmp.c | 4 ++-- arch/arm/mach-zynq/common.h | 2 +- arch/arm/mach-zynq/headsmp.S | 2 -- arch/arm/mach-zynq/platsmp.c | 6 +++--- arch/arm/mm/proc-arm1020.S | 2 -- arch/arm/mm/proc-arm1020e.S | 2 -- arch/arm/mm/proc-arm1022.S | 2 -- arch/arm/mm/proc-arm1026.S | 3 --- arch/arm/mm/proc-arm720.S | 2 -- arch/arm/mm/proc-arm740.S | 2 -- arch/arm/mm/proc-arm7tdmi.S | 2 -- arch/arm/mm/proc-arm920.S | 2 -- arch/arm/mm/proc-arm922.S | 2 -- arch/arm/mm/proc-arm925.S | 2 -- arch/arm/mm/proc-arm926.S | 2 -- arch/arm/mm/proc-arm940.S | 2 -- arch/arm/mm/proc-arm946.S | 2 -- arch/arm/mm/proc-arm9tdmi.S | 2 -- arch/arm/mm/proc-fa526.S | 2 -- arch/arm/mm/proc-feroceon.S | 2 -- arch/arm/mm/proc-mohawk.S | 2 -- arch/arm/mm/proc-sa110.S | 2 -- arch/arm/mm/proc-sa1100.S | 2 -- arch/arm/mm/proc-v6.S | 2 -- arch/arm/mm/proc-v7-2level.S | 4 ---- arch/arm/mm/proc-v7-3level.S | 4 ---- arch/arm/mm/proc-v7.S | 2 -- arch/arm/mm/proc-xsc3.S | 2 -- arch/arm/mm/proc-xscale.S | 2 -- arch/arm/plat-versatile/platsmp.c | 6 +++--- 70 files changed, 64 insertions(+), 140 deletions(-) diff --git a/arch/arm/common/mcpm_platsmp.c b/arch/arm/common/mcpm_platsmp.c index 510e5b13aa2e..1bc34c7567fd 100644 --- a/arch/arm/common/mcpm_platsmp.c +++ b/arch/arm/common/mcpm_platsmp.c @@ -19,7 +19,7 @@ #include #include -static int __cpuinit mcpm_boot_secondary(unsigned int cpu, struct task_struct *idle) +static int mcpm_boot_secondary(unsigned int cpu, struct task_struct *idle) { unsigned int mpidr, pcpu, pcluster, ret; extern void secondary_startup(void); @@ -40,7 +40,7 @@ static int __cpuinit mcpm_boot_secondary(unsigned int cpu, struct task_struct *i return 0; } -static void __cpuinit mcpm_secondary_init(unsigned int cpu) +static void mcpm_secondary_init(unsigned int cpu) { mcpm_cpu_powered_up(); } diff --git a/arch/arm/include/asm/arch_timer.h b/arch/arm/include/asm/arch_timer.h index accefe099182..e406d575c94f 100644 --- a/arch/arm/include/asm/arch_timer.h +++ b/arch/arm/include/asm/arch_timer.h @@ -89,7 +89,7 @@ static inline u64 arch_counter_get_cntvct(void) return cval; } -static inline void __cpuinit arch_counter_set_user_access(void) +static inline void arch_counter_set_user_access(void) { u32 cntkctl; diff --git a/arch/arm/kernel/head-common.S b/arch/arm/kernel/head-common.S index 76ab5ca50610..47cd974e57ea 100644 --- a/arch/arm/kernel/head-common.S +++ b/arch/arm/kernel/head-common.S @@ -149,7 +149,6 @@ ENDPROC(lookup_processor_type) * r5 = proc_info pointer in physical address space * r9 = cpuid (preserved) */ - __CPUINIT __lookup_processor_type: adr r3, __lookup_processor_type_data ldmia r3, {r4 - r6} diff --git a/arch/arm/kernel/head-nommu.S b/arch/arm/kernel/head-nommu.S index 75f14cc3e073..b361de143756 100644 --- a/arch/arm/kernel/head-nommu.S +++ b/arch/arm/kernel/head-nommu.S @@ -87,7 +87,6 @@ ENTRY(stext) ENDPROC(stext) #ifdef CONFIG_SMP - __CPUINIT ENTRY(secondary_startup) /* * Common entry point for secondary CPUs. diff --git a/arch/arm/kernel/head.S b/arch/arm/kernel/head.S index 45e8935cae4e..9cf6063020ae 100644 --- a/arch/arm/kernel/head.S +++ b/arch/arm/kernel/head.S @@ -343,7 +343,6 @@ __turn_mmu_on_loc: .long __turn_mmu_on_end #if defined(CONFIG_SMP) - __CPUINIT ENTRY(secondary_startup) /* * Common entry point for secondary CPUs. diff --git a/arch/arm/kernel/hw_breakpoint.c b/arch/arm/kernel/hw_breakpoint.c index 1fd749ee4a1b..7b95de601357 100644 --- a/arch/arm/kernel/hw_breakpoint.c +++ b/arch/arm/kernel/hw_breakpoint.c @@ -1020,7 +1020,7 @@ out_mdbgen: cpumask_or(&debug_err_mask, &debug_err_mask, cpumask_of(cpu)); } -static int __cpuinit dbg_reset_notify(struct notifier_block *self, +static int dbg_reset_notify(struct notifier_block *self, unsigned long action, void *cpu) { if ((action & ~CPU_TASKS_FROZEN) == CPU_ONLINE) @@ -1029,7 +1029,7 @@ static int __cpuinit dbg_reset_notify(struct notifier_block *self, return NOTIFY_OK; } -static struct notifier_block __cpuinitdata dbg_reset_nb = { +static struct notifier_block dbg_reset_nb = { .notifier_call = dbg_reset_notify, }; diff --git a/arch/arm/kernel/perf_event_cpu.c b/arch/arm/kernel/perf_event_cpu.c index 1f2740e3dbc0..aebe0e99c153 100644 --- a/arch/arm/kernel/perf_event_cpu.c +++ b/arch/arm/kernel/perf_event_cpu.c @@ -157,8 +157,8 @@ static void cpu_pmu_init(struct arm_pmu *cpu_pmu) * UNKNOWN at reset, the PMU must be explicitly reset to avoid reading * junk values out of them. */ -static int __cpuinit cpu_pmu_notify(struct notifier_block *b, - unsigned long action, void *hcpu) +static int cpu_pmu_notify(struct notifier_block *b, unsigned long action, + void *hcpu) { if ((action & ~CPU_TASKS_FROZEN) != CPU_STARTING) return NOTIFY_DONE; @@ -171,7 +171,7 @@ static int __cpuinit cpu_pmu_notify(struct notifier_block *b, return NOTIFY_OK; } -static struct notifier_block __cpuinitdata cpu_pmu_hotplug_notifier = { +static struct notifier_block cpu_pmu_hotplug_notifier = { .notifier_call = cpu_pmu_notify, }; diff --git a/arch/arm/kernel/psci_smp.c b/arch/arm/kernel/psci_smp.c index 219f1d73572a..70ded3fb42d9 100644 --- a/arch/arm/kernel/psci_smp.c +++ b/arch/arm/kernel/psci_smp.c @@ -46,8 +46,7 @@ extern void secondary_startup(void); -static int __cpuinit psci_boot_secondary(unsigned int cpu, - struct task_struct *idle) +static int psci_boot_secondary(unsigned int cpu, struct task_struct *idle) { if (psci_ops.cpu_on) return psci_ops.cpu_on(cpu_logical_map(cpu), diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c index c5fb5469054b..c2b4f8f0be9a 100644 --- a/arch/arm/kernel/smp.c +++ b/arch/arm/kernel/smp.c @@ -58,7 +58,7 @@ struct secondary_data secondary_data; * control for which core is the next to come out of the secondary * boot "holding pen" */ -volatile int __cpuinitdata pen_release = -1; +volatile int pen_release = -1; enum ipi_msg_type { IPI_WAKEUP, @@ -86,7 +86,7 @@ static unsigned long get_arch_pgd(pgd_t *pgd) return pgdir >> ARCH_PGD_SHIFT; } -int __cpuinit __cpu_up(unsigned int cpu, struct task_struct *idle) +int __cpu_up(unsigned int cpu, struct task_struct *idle) { int ret; @@ -138,7 +138,7 @@ void __init smp_init_cpus(void) smp_ops.smp_init_cpus(); } -int __cpuinit boot_secondary(unsigned int cpu, struct task_struct *idle) +int boot_secondary(unsigned int cpu, struct task_struct *idle) { if (smp_ops.smp_boot_secondary) return smp_ops.smp_boot_secondary(cpu, idle); @@ -170,7 +170,7 @@ static int platform_cpu_disable(unsigned int cpu) /* * __cpu_disable runs on the processor to be shutdown. */ -int __cpuinit __cpu_disable(void) +int __cpu_disable(void) { unsigned int cpu = smp_processor_id(); int ret; @@ -216,7 +216,7 @@ static DECLARE_COMPLETION(cpu_died); * called on the thread which is asking for a CPU to be shutdown - * waits until shutdown has completed, or it is timed out. */ -void __cpuinit __cpu_die(unsigned int cpu) +void __cpu_die(unsigned int cpu) { if (!wait_for_completion_timeout(&cpu_died, msecs_to_jiffies(5000))) { pr_err("CPU%u: cpu didn't die\n", cpu); @@ -306,7 +306,7 @@ void __ref cpu_die(void) * Called by both boot and secondaries to move global data into * per-processor storage. */ -static void __cpuinit smp_store_cpu_info(unsigned int cpuid) +static void smp_store_cpu_info(unsigned int cpuid) { struct cpuinfo_arm *cpu_info = &per_cpu(cpu_data, cpuid); @@ -322,7 +322,7 @@ static void percpu_timer_setup(void); * This is the secondary CPU boot entry. We're using this CPUs * idle thread stack, but a set of temporary page tables. */ -asmlinkage void __cpuinit secondary_start_kernel(void) +asmlinkage void secondary_start_kernel(void) { struct mm_struct *mm = &init_mm; unsigned int cpu; @@ -521,7 +521,7 @@ static void broadcast_timer_set_mode(enum clock_event_mode mode, { } -static void __cpuinit broadcast_timer_setup(struct clock_event_device *evt) +static void broadcast_timer_setup(struct clock_event_device *evt) { evt->name = "dummy_timer"; evt->features = CLOCK_EVT_FEAT_ONESHOT | @@ -550,7 +550,7 @@ int local_timer_register(struct local_timer_ops *ops) } #endif -static void __cpuinit percpu_timer_setup(void) +static void percpu_timer_setup(void) { unsigned int cpu = smp_processor_id(); struct clock_event_device *evt = &per_cpu(percpu_clockevent, cpu); diff --git a/arch/arm/kernel/smp_twd.c b/arch/arm/kernel/smp_twd.c index f6fd1d4398c6..25956204ef23 100644 --- a/arch/arm/kernel/smp_twd.c +++ b/arch/arm/kernel/smp_twd.c @@ -187,7 +187,7 @@ core_initcall(twd_cpufreq_init); #endif -static void __cpuinit twd_calibrate_rate(void) +static void twd_calibrate_rate(void) { unsigned long count; u64 waitjiffies; @@ -265,7 +265,7 @@ static void twd_get_clock(struct device_node *np) /* * Setup the local clock events for a CPU. */ -static int __cpuinit twd_timer_setup(struct clock_event_device *clk) +static int twd_timer_setup(struct clock_event_device *clk) { struct clock_event_device **this_cpu_clk; int cpu = smp_processor_id(); @@ -308,7 +308,7 @@ static int __cpuinit twd_timer_setup(struct clock_event_device *clk) return 0; } -static struct local_timer_ops twd_lt_ops __cpuinitdata = { +static struct local_timer_ops twd_lt_ops = { .setup = twd_timer_setup, .stop = twd_timer_stop, }; diff --git a/arch/arm/lib/delay.c b/arch/arm/lib/delay.c index 64dbfa57204a..5306de350133 100644 --- a/arch/arm/lib/delay.c +++ b/arch/arm/lib/delay.c @@ -86,7 +86,7 @@ void __init register_current_timer_delay(const struct delay_timer *timer) } } -unsigned long __cpuinit calibrate_delay_is_known(void) +unsigned long calibrate_delay_is_known(void) { delay_calibrated = true; return lpj_fine; diff --git a/arch/arm/mach-exynos/headsmp.S b/arch/arm/mach-exynos/headsmp.S index 5364d4bfa8bc..cdd9d91e9933 100644 --- a/arch/arm/mach-exynos/headsmp.S +++ b/arch/arm/mach-exynos/headsmp.S @@ -13,8 +13,6 @@ #include #include - __CPUINIT - /* * exynos4 specific entry point for secondary CPUs. This provides * a "holding pen" into which all secondary cores are held until we're diff --git a/arch/arm/mach-exynos/platsmp.c b/arch/arm/mach-exynos/platsmp.c index deba1308ff16..58b43e6f9262 100644 --- a/arch/arm/mach-exynos/platsmp.c +++ b/arch/arm/mach-exynos/platsmp.c @@ -75,7 +75,7 @@ static void __iomem *scu_base_addr(void) static DEFINE_SPINLOCK(boot_lock); -static void __cpuinit exynos_secondary_init(unsigned int cpu) +static void exynos_secondary_init(unsigned int cpu) { /* * let the primary processor know we're out of the @@ -90,7 +90,7 @@ static void __cpuinit exynos_secondary_init(unsigned int cpu) spin_unlock(&boot_lock); } -static int __cpuinit exynos_boot_secondary(unsigned int cpu, struct task_struct *idle) +static int exynos_boot_secondary(unsigned int cpu, struct task_struct *idle) { unsigned long timeout; unsigned long phys_cpu = cpu_logical_map(cpu); diff --git a/arch/arm/mach-highbank/platsmp.c b/arch/arm/mach-highbank/platsmp.c index a984573e0d02..32d75cf55cbc 100644 --- a/arch/arm/mach-highbank/platsmp.c +++ b/arch/arm/mach-highbank/platsmp.c @@ -24,7 +24,7 @@ extern void secondary_startup(void); -static int __cpuinit highbank_boot_secondary(unsigned int cpu, struct task_struct *idle) +static int highbank_boot_secondary(unsigned int cpu, struct task_struct *idle) { highbank_set_cpu_jump(cpu, secondary_startup); arch_send_wakeup_ipi_mask(cpumask_of(cpu)); diff --git a/arch/arm/mach-imx/platsmp.c b/arch/arm/mach-imx/platsmp.c index c6e1ab544882..1f24c1fdfea4 100644 --- a/arch/arm/mach-imx/platsmp.c +++ b/arch/arm/mach-imx/platsmp.c @@ -53,7 +53,7 @@ void imx_scu_standby_enable(void) writel_relaxed(val, scu_base); } -static int __cpuinit imx_boot_secondary(unsigned int cpu, struct task_struct *idle) +static int imx_boot_secondary(unsigned int cpu, struct task_struct *idle) { imx_set_cpu_jump(cpu, v7_secondary_startup); imx_enable_cpu(cpu, true); diff --git a/arch/arm/mach-keystone/platsmp.c b/arch/arm/mach-keystone/platsmp.c index 1d4181e1daf2..14378e3fef16 100644 --- a/arch/arm/mach-keystone/platsmp.c +++ b/arch/arm/mach-keystone/platsmp.c @@ -21,7 +21,7 @@ #include "keystone.h" -static int __cpuinit keystone_smp_boot_secondary(unsigned int cpu, +static int keystone_smp_boot_secondary(unsigned int cpu, struct task_struct *idle) { unsigned long start = virt_to_phys(&secondary_startup); diff --git a/arch/arm/mach-msm/headsmp.S b/arch/arm/mach-msm/headsmp.S index bcd5af223dea..6c62c3f82fe6 100644 --- a/arch/arm/mach-msm/headsmp.S +++ b/arch/arm/mach-msm/headsmp.S @@ -11,8 +11,6 @@ #include #include - __CPUINIT - /* * MSM specific entry point for secondary CPUs. This provides * a "holding pen" into which all secondary cores are held until we're diff --git a/arch/arm/mach-msm/platsmp.c b/arch/arm/mach-msm/platsmp.c index 00cdb0a5dac8..3f06edcdd0ce 100644 --- a/arch/arm/mach-msm/platsmp.c +++ b/arch/arm/mach-msm/platsmp.c @@ -38,7 +38,7 @@ static inline int get_core_count(void) return ((read_cpuid_id() >> 4) & 3) + 1; } -static void __cpuinit msm_secondary_init(unsigned int cpu) +static void msm_secondary_init(unsigned int cpu) { /* * let the primary processor know we're out of the @@ -54,7 +54,7 @@ static void __cpuinit msm_secondary_init(unsigned int cpu) spin_unlock(&boot_lock); } -static __cpuinit void prepare_cold_cpu(unsigned int cpu) +static void prepare_cold_cpu(unsigned int cpu) { int ret; ret = scm_set_boot_addr(virt_to_phys(msm_secondary_startup), @@ -73,7 +73,7 @@ static __cpuinit void prepare_cold_cpu(unsigned int cpu) "address\n"); } -static int __cpuinit msm_boot_secondary(unsigned int cpu, struct task_struct *idle) +static int msm_boot_secondary(unsigned int cpu, struct task_struct *idle) { unsigned long timeout; static int cold_boot_done; diff --git a/arch/arm/mach-msm/timer.c b/arch/arm/mach-msm/timer.c index b6418fd5fe0d..8697cfc0d0b6 100644 --- a/arch/arm/mach-msm/timer.c +++ b/arch/arm/mach-msm/timer.c @@ -139,7 +139,7 @@ static struct clocksource msm_clocksource = { }; #ifdef CONFIG_LOCAL_TIMERS -static int __cpuinit msm_local_timer_setup(struct clock_event_device *evt) +static int msm_local_timer_setup(struct clock_event_device *evt) { /* Use existing clock_event for cpu 0 */ if (!smp_processor_id()) @@ -164,7 +164,7 @@ static void msm_local_timer_stop(struct clock_event_device *evt) disable_percpu_irq(evt->irq); } -static struct local_timer_ops msm_local_timer_ops __cpuinitdata = { +static struct local_timer_ops msm_local_timer_ops = { .setup = msm_local_timer_setup, .stop = msm_local_timer_stop, }; diff --git a/arch/arm/mach-mvebu/coherency.c b/arch/arm/mach-mvebu/coherency.c index be117591f7f2..4c24303ec481 100644 --- a/arch/arm/mach-mvebu/coherency.c +++ b/arch/arm/mach-mvebu/coherency.c @@ -28,7 +28,7 @@ #include #include "armada-370-xp.h" -unsigned long __cpuinitdata coherency_phys_base; +unsigned long coherency_phys_base; static void __iomem *coherency_base; static void __iomem *coherency_cpu_base; diff --git a/arch/arm/mach-mvebu/headsmp.S b/arch/arm/mach-mvebu/headsmp.S index 7147300c8af2..8a1b0c96e9ec 100644 --- a/arch/arm/mach-mvebu/headsmp.S +++ b/arch/arm/mach-mvebu/headsmp.S @@ -21,8 +21,6 @@ #include #include - __CPUINIT - /* * Armada XP specific entry point for secondary CPUs. * We add the CPU to the coherency fabric and then jump to secondary diff --git a/arch/arm/mach-mvebu/platsmp.c b/arch/arm/mach-mvebu/platsmp.c index 93f2f3ab45f1..ce81d3031405 100644 --- a/arch/arm/mach-mvebu/platsmp.c +++ b/arch/arm/mach-mvebu/platsmp.c @@ -71,13 +71,12 @@ void __init set_secondary_cpus_clock(void) } } -static void __cpuinit armada_xp_secondary_init(unsigned int cpu) +static void armada_xp_secondary_init(unsigned int cpu) { armada_xp_mpic_smp_cpu_init(); } -static int __cpuinit armada_xp_boot_secondary(unsigned int cpu, - struct task_struct *idle) +static int armada_xp_boot_secondary(unsigned int cpu, struct task_struct *idle) { pr_info("Booting CPU %d\n", cpu); diff --git a/arch/arm/mach-omap2/omap-headsmp.S b/arch/arm/mach-omap2/omap-headsmp.S index 4ea308114165..75e92952c18e 100644 --- a/arch/arm/mach-omap2/omap-headsmp.S +++ b/arch/arm/mach-omap2/omap-headsmp.S @@ -20,8 +20,6 @@ #include "omap44xx.h" - __CPUINIT - /* Physical address needed since MMU not enabled yet on secondary core */ #define AUX_CORE_BOOT0_PA 0x48281800 diff --git a/arch/arm/mach-omap2/omap-mpuss-lowpower.c b/arch/arm/mach-omap2/omap-mpuss-lowpower.c index f993a4188701..f991016e2a6a 100644 --- a/arch/arm/mach-omap2/omap-mpuss-lowpower.c +++ b/arch/arm/mach-omap2/omap-mpuss-lowpower.c @@ -291,7 +291,7 @@ int omap4_enter_lowpower(unsigned int cpu, unsigned int power_state) * @cpu : CPU ID * @power_state: CPU low power state. */ -int __cpuinit omap4_hotplug_cpu(unsigned int cpu, unsigned int power_state) +int omap4_hotplug_cpu(unsigned int cpu, unsigned int power_state) { struct omap4_cpu_pm_info *pm_info = &per_cpu(omap4_pm_info, cpu); unsigned int cpu_state = 0; diff --git a/arch/arm/mach-omap2/omap-smp.c b/arch/arm/mach-omap2/omap-smp.c index 98a11463a843..8708b2a9da45 100644 --- a/arch/arm/mach-omap2/omap-smp.c +++ b/arch/arm/mach-omap2/omap-smp.c @@ -51,7 +51,7 @@ void __iomem *omap4_get_scu_base(void) return scu_base; } -static void __cpuinit omap4_secondary_init(unsigned int cpu) +static void omap4_secondary_init(unsigned int cpu) { /* * Configure ACTRL and enable NS SMP bit access on CPU1 on HS device. @@ -72,7 +72,7 @@ static void __cpuinit omap4_secondary_init(unsigned int cpu) spin_unlock(&boot_lock); } -static int __cpuinit omap4_boot_secondary(unsigned int cpu, struct task_struct *idle) +static int omap4_boot_secondary(unsigned int cpu, struct task_struct *idle) { static struct clockdomain *cpu1_clkdm; static bool booted; diff --git a/arch/arm/mach-omap2/omap-wakeupgen.c b/arch/arm/mach-omap2/omap-wakeupgen.c index f8bb3b9b6a76..813c61558a5f 100644 --- a/arch/arm/mach-omap2/omap-wakeupgen.c +++ b/arch/arm/mach-omap2/omap-wakeupgen.c @@ -323,8 +323,8 @@ static void irq_save_secure_context(void) #endif #ifdef CONFIG_HOTPLUG_CPU -static int __cpuinit irq_cpu_hotplug_notify(struct notifier_block *self, - unsigned long action, void *hcpu) +static int irq_cpu_hotplug_notify(struct notifier_block *self, + unsigned long action, void *hcpu) { unsigned int cpu = (unsigned int)hcpu; diff --git a/arch/arm/mach-prima2/headsmp.S b/arch/arm/mach-prima2/headsmp.S index 5b8a408d8921..d86fe33c5f53 100644 --- a/arch/arm/mach-prima2/headsmp.S +++ b/arch/arm/mach-prima2/headsmp.S @@ -9,8 +9,6 @@ #include #include - __CPUINIT - /* * SIRFSOC specific entry point for secondary CPUs. This provides * a "holding pen" into which all secondary cores are held until we're diff --git a/arch/arm/mach-prima2/platsmp.c b/arch/arm/mach-prima2/platsmp.c index 1c3de7bed841..3dbcb1ab6e37 100644 --- a/arch/arm/mach-prima2/platsmp.c +++ b/arch/arm/mach-prima2/platsmp.c @@ -44,7 +44,7 @@ void __init sirfsoc_map_scu(void) scu_base = (void __iomem *)SIRFSOC_VA(base); } -static void __cpuinit sirfsoc_secondary_init(unsigned int cpu) +static void sirfsoc_secondary_init(unsigned int cpu) { /* * let the primary processor know we're out of the @@ -65,7 +65,7 @@ static struct of_device_id rsc_ids[] = { {}, }; -static int __cpuinit sirfsoc_boot_secondary(unsigned int cpu, struct task_struct *idle) +static int sirfsoc_boot_secondary(unsigned int cpu, struct task_struct *idle) { unsigned long timeout; struct device_node *np; diff --git a/arch/arm/mach-shmobile/headsmp-scu.S b/arch/arm/mach-shmobile/headsmp-scu.S index 6f9865467258..bfd920083a3b 100644 --- a/arch/arm/mach-shmobile/headsmp-scu.S +++ b/arch/arm/mach-shmobile/headsmp-scu.S @@ -23,7 +23,6 @@ #include #include - __CPUINIT /* * Boot code for secondary CPUs. * diff --git a/arch/arm/mach-shmobile/headsmp.S b/arch/arm/mach-shmobile/headsmp.S index 559d1ce5f57e..a9d212498987 100644 --- a/arch/arm/mach-shmobile/headsmp.S +++ b/arch/arm/mach-shmobile/headsmp.S @@ -14,8 +14,6 @@ #include #include - __CPUINIT - ENTRY(shmobile_invalidate_start) bl v7_invalidate_l1 b secondary_startup diff --git a/arch/arm/mach-shmobile/smp-emev2.c b/arch/arm/mach-shmobile/smp-emev2.c index 80991b35f4ac..22a05a869d25 100644 --- a/arch/arm/mach-shmobile/smp-emev2.c +++ b/arch/arm/mach-shmobile/smp-emev2.c @@ -30,7 +30,7 @@ #define EMEV2_SCU_BASE 0x1e000000 -static int __cpuinit emev2_boot_secondary(unsigned int cpu, struct task_struct *idle) +static int emev2_boot_secondary(unsigned int cpu, struct task_struct *idle) { arch_send_wakeup_ipi_mask(cpumask_of(cpu_logical_map(cpu))); return 0; diff --git a/arch/arm/mach-shmobile/smp-r8a7779.c b/arch/arm/mach-shmobile/smp-r8a7779.c index 526cfaae81c1..9bdf810f2a87 100644 --- a/arch/arm/mach-shmobile/smp-r8a7779.c +++ b/arch/arm/mach-shmobile/smp-r8a7779.c @@ -81,7 +81,7 @@ static int r8a7779_platform_cpu_kill(unsigned int cpu) return ret ? ret : 1; } -static int __cpuinit r8a7779_boot_secondary(unsigned int cpu, struct task_struct *idle) +static int r8a7779_boot_secondary(unsigned int cpu, struct task_struct *idle) { struct r8a7779_pm_ch *ch = NULL; int ret = -EIO; diff --git a/arch/arm/mach-shmobile/smp-sh73a0.c b/arch/arm/mach-shmobile/smp-sh73a0.c index d613113a04bd..d5fc3ed4e315 100644 --- a/arch/arm/mach-shmobile/smp-sh73a0.c +++ b/arch/arm/mach-shmobile/smp-sh73a0.c @@ -48,7 +48,7 @@ void __init sh73a0_register_twd(void) } #endif -static int __cpuinit sh73a0_boot_secondary(unsigned int cpu, struct task_struct *idle) +static int sh73a0_boot_secondary(unsigned int cpu, struct task_struct *idle) { cpu = cpu_logical_map(cpu); diff --git a/arch/arm/mach-socfpga/headsmp.S b/arch/arm/mach-socfpga/headsmp.S index 9004bfb1756e..95c115d8b5ee 100644 --- a/arch/arm/mach-socfpga/headsmp.S +++ b/arch/arm/mach-socfpga/headsmp.S @@ -10,7 +10,6 @@ #include #include - __CPUINIT .arch armv7-a ENTRY(secondary_trampoline) diff --git a/arch/arm/mach-socfpga/platsmp.c b/arch/arm/mach-socfpga/platsmp.c index b51ce8c7929d..5356a72bc8ce 100644 --- a/arch/arm/mach-socfpga/platsmp.c +++ b/arch/arm/mach-socfpga/platsmp.c @@ -29,7 +29,7 @@ #include "core.h" -static int __cpuinit socfpga_boot_secondary(unsigned int cpu, struct task_struct *idle) +static int socfpga_boot_secondary(unsigned int cpu, struct task_struct *idle) { int trampoline_size = &secondary_trampoline_end - &secondary_trampoline; diff --git a/arch/arm/mach-spear/generic.h b/arch/arm/mach-spear/generic.h index 904f2c907b46..a99d90a4d09c 100644 --- a/arch/arm/mach-spear/generic.h +++ b/arch/arm/mach-spear/generic.h @@ -37,7 +37,7 @@ void __init spear13xx_l2x0_init(void); void spear_restart(enum reboot_mode, const char *); void spear13xx_secondary_startup(void); -void __cpuinit spear13xx_cpu_die(unsigned int cpu); +void spear13xx_cpu_die(unsigned int cpu); extern struct smp_operations spear13xx_smp_ops; diff --git a/arch/arm/mach-spear/platsmp.c b/arch/arm/mach-spear/platsmp.c index 9c4c722c954e..5c4a19887b2b 100644 --- a/arch/arm/mach-spear/platsmp.c +++ b/arch/arm/mach-spear/platsmp.c @@ -24,7 +24,7 @@ static DEFINE_SPINLOCK(boot_lock); static void __iomem *scu_base = IOMEM(VA_SCU_BASE); -static void __cpuinit spear13xx_secondary_init(unsigned int cpu) +static void spear13xx_secondary_init(unsigned int cpu) { /* * let the primary processor know we're out of the @@ -40,7 +40,7 @@ static void __cpuinit spear13xx_secondary_init(unsigned int cpu) spin_unlock(&boot_lock); } -static int __cpuinit spear13xx_boot_secondary(unsigned int cpu, struct task_struct *idle) +static int spear13xx_boot_secondary(unsigned int cpu, struct task_struct *idle) { unsigned long timeout; diff --git a/arch/arm/mach-sti/platsmp.c b/arch/arm/mach-sti/platsmp.c index 977a863468fc..dce50d983a8e 100644 --- a/arch/arm/mach-sti/platsmp.c +++ b/arch/arm/mach-sti/platsmp.c @@ -27,7 +27,7 @@ #include "smp.h" -static void __cpuinit write_pen_release(int val) +static void write_pen_release(int val) { pen_release = val; smp_wmb(); @@ -37,7 +37,7 @@ static void __cpuinit write_pen_release(int val) static DEFINE_SPINLOCK(boot_lock); -void __cpuinit sti_secondary_init(unsigned int cpu) +void sti_secondary_init(unsigned int cpu) { trace_hardirqs_off(); @@ -54,7 +54,7 @@ void __cpuinit sti_secondary_init(unsigned int cpu) spin_unlock(&boot_lock); } -int __cpuinit sti_boot_secondary(unsigned int cpu, struct task_struct *idle) +int sti_boot_secondary(unsigned int cpu, struct task_struct *idle) { unsigned long timeout; diff --git a/arch/arm/mach-tegra/platsmp.c b/arch/arm/mach-tegra/platsmp.c index 24db4ac428ae..97b33a2a2d75 100644 --- a/arch/arm/mach-tegra/platsmp.c +++ b/arch/arm/mach-tegra/platsmp.c @@ -35,7 +35,7 @@ static cpumask_t tegra_cpu_init_mask; -static void __cpuinit tegra_secondary_init(unsigned int cpu) +static void tegra_secondary_init(unsigned int cpu) { cpumask_set_cpu(cpu, &tegra_cpu_init_mask); } @@ -167,7 +167,7 @@ static int tegra114_boot_secondary(unsigned int cpu, struct task_struct *idle) return ret; } -static int __cpuinit tegra_boot_secondary(unsigned int cpu, +static int tegra_boot_secondary(unsigned int cpu, struct task_struct *idle) { if (IS_ENABLED(CONFIG_ARCH_TEGRA_2x_SOC) && tegra_chip_id == TEGRA20) diff --git a/arch/arm/mach-tegra/pm.c b/arch/arm/mach-tegra/pm.c index 94e69bee3da5..261fec140c06 100644 --- a/arch/arm/mach-tegra/pm.c +++ b/arch/arm/mach-tegra/pm.c @@ -191,7 +191,7 @@ static const char *lp_state[TEGRA_MAX_SUSPEND_MODE] = { [TEGRA_SUSPEND_LP0] = "LP0", }; -static int __cpuinit tegra_suspend_enter(suspend_state_t state) +static int tegra_suspend_enter(suspend_state_t state) { enum tegra_suspend_mode mode = tegra_pmc_get_suspend_mode(); diff --git a/arch/arm/mach-ux500/platsmp.c b/arch/arm/mach-ux500/platsmp.c index 14d90469392f..1f296e796a4f 100644 --- a/arch/arm/mach-ux500/platsmp.c +++ b/arch/arm/mach-ux500/platsmp.c @@ -54,7 +54,7 @@ static void __iomem *scu_base_addr(void) static DEFINE_SPINLOCK(boot_lock); -static void __cpuinit ux500_secondary_init(unsigned int cpu) +static void ux500_secondary_init(unsigned int cpu) { /* * let the primary processor know we're out of the @@ -69,7 +69,7 @@ static void __cpuinit ux500_secondary_init(unsigned int cpu) spin_unlock(&boot_lock); } -static int __cpuinit ux500_boot_secondary(unsigned int cpu, struct task_struct *idle) +static int ux500_boot_secondary(unsigned int cpu, struct task_struct *idle) { unsigned long timeout; diff --git a/arch/arm/mach-zynq/common.h b/arch/arm/mach-zynq/common.h index fbbd0e21c404..3040d219570f 100644 --- a/arch/arm/mach-zynq/common.h +++ b/arch/arm/mach-zynq/common.h @@ -27,7 +27,7 @@ extern void secondary_startup(void); extern char zynq_secondary_trampoline; extern char zynq_secondary_trampoline_jump; extern char zynq_secondary_trampoline_end; -extern int __cpuinit zynq_cpun_start(u32 address, int cpu); +extern int zynq_cpun_start(u32 address, int cpu); extern struct smp_operations zynq_smp_ops __initdata; #endif diff --git a/arch/arm/mach-zynq/headsmp.S b/arch/arm/mach-zynq/headsmp.S index d183cd234a9b..d4cd5f34fe5c 100644 --- a/arch/arm/mach-zynq/headsmp.S +++ b/arch/arm/mach-zynq/headsmp.S @@ -9,8 +9,6 @@ #include #include - __CPUINIT - ENTRY(zynq_secondary_trampoline) ldr r0, [pc] bx r0 diff --git a/arch/arm/mach-zynq/platsmp.c b/arch/arm/mach-zynq/platsmp.c index 023f225493f2..689fbbc3d9c8 100644 --- a/arch/arm/mach-zynq/platsmp.c +++ b/arch/arm/mach-zynq/platsmp.c @@ -30,11 +30,11 @@ /* * Store number of cores in the system * Because of scu_get_core_count() must be in __init section and can't - * be called from zynq_cpun_start() because it is in __cpuinit section. + * be called from zynq_cpun_start() because it is not in __init section. */ static int ncores; -int __cpuinit zynq_cpun_start(u32 address, int cpu) +int zynq_cpun_start(u32 address, int cpu) { u32 trampoline_code_size = &zynq_secondary_trampoline_end - &zynq_secondary_trampoline; @@ -92,7 +92,7 @@ int __cpuinit zynq_cpun_start(u32 address, int cpu) } EXPORT_SYMBOL(zynq_cpun_start); -static int __cpuinit zynq_boot_secondary(unsigned int cpu, +static int zynq_boot_secondary(unsigned int cpu, struct task_struct *idle) { return zynq_cpun_start(virt_to_phys(secondary_startup), cpu); diff --git a/arch/arm/mm/proc-arm1020.S b/arch/arm/mm/proc-arm1020.S index 2bb61e703d6c..d1a2d05971e0 100644 --- a/arch/arm/mm/proc-arm1020.S +++ b/arch/arm/mm/proc-arm1020.S @@ -443,8 +443,6 @@ ENTRY(cpu_arm1020_set_pte_ext) #endif /* CONFIG_MMU */ mov pc, lr - __CPUINIT - .type __arm1020_setup, #function __arm1020_setup: mov r0, #0 diff --git a/arch/arm/mm/proc-arm1020e.S b/arch/arm/mm/proc-arm1020e.S index 8f96aa40f510..9d89405c3d03 100644 --- a/arch/arm/mm/proc-arm1020e.S +++ b/arch/arm/mm/proc-arm1020e.S @@ -425,8 +425,6 @@ ENTRY(cpu_arm1020e_set_pte_ext) #endif /* CONFIG_MMU */ mov pc, lr - __CPUINIT - .type __arm1020e_setup, #function __arm1020e_setup: mov r0, #0 diff --git a/arch/arm/mm/proc-arm1022.S b/arch/arm/mm/proc-arm1022.S index 8ebe4a469a22..6f01a0ae3b30 100644 --- a/arch/arm/mm/proc-arm1022.S +++ b/arch/arm/mm/proc-arm1022.S @@ -407,8 +407,6 @@ ENTRY(cpu_arm1022_set_pte_ext) #endif /* CONFIG_MMU */ mov pc, lr - __CPUINIT - .type __arm1022_setup, #function __arm1022_setup: mov r0, #0 diff --git a/arch/arm/mm/proc-arm1026.S b/arch/arm/mm/proc-arm1026.S index 093fc7e520c3..4799a24b43e6 100644 --- a/arch/arm/mm/proc-arm1026.S +++ b/arch/arm/mm/proc-arm1026.S @@ -396,9 +396,6 @@ ENTRY(cpu_arm1026_set_pte_ext) #endif /* CONFIG_MMU */ mov pc, lr - - __CPUINIT - .type __arm1026_setup, #function __arm1026_setup: mov r0, #0 diff --git a/arch/arm/mm/proc-arm720.S b/arch/arm/mm/proc-arm720.S index 0ac908c7ade1..d42c37f9f5bc 100644 --- a/arch/arm/mm/proc-arm720.S +++ b/arch/arm/mm/proc-arm720.S @@ -116,8 +116,6 @@ ENTRY(cpu_arm720_reset) ENDPROC(cpu_arm720_reset) .popsection - __CPUINIT - .type __arm710_setup, #function __arm710_setup: mov r0, #0 diff --git a/arch/arm/mm/proc-arm740.S b/arch/arm/mm/proc-arm740.S index fde2d2a794cf..9b0ae90cbf17 100644 --- a/arch/arm/mm/proc-arm740.S +++ b/arch/arm/mm/proc-arm740.S @@ -60,8 +60,6 @@ ENTRY(cpu_arm740_reset) ENDPROC(cpu_arm740_reset) .popsection - __CPUINIT - .type __arm740_setup, #function __arm740_setup: mov r0, #0 diff --git a/arch/arm/mm/proc-arm7tdmi.S b/arch/arm/mm/proc-arm7tdmi.S index 6ddea3e464bd..f6cc3f63ce39 100644 --- a/arch/arm/mm/proc-arm7tdmi.S +++ b/arch/arm/mm/proc-arm7tdmi.S @@ -51,8 +51,6 @@ ENTRY(cpu_arm7tdmi_reset) ENDPROC(cpu_arm7tdmi_reset) .popsection - __CPUINIT - .type __arm7tdmi_setup, #function __arm7tdmi_setup: mov pc, lr diff --git a/arch/arm/mm/proc-arm920.S b/arch/arm/mm/proc-arm920.S index 2556cf1c2da1..549557df6d57 100644 --- a/arch/arm/mm/proc-arm920.S +++ b/arch/arm/mm/proc-arm920.S @@ -410,8 +410,6 @@ ENTRY(cpu_arm920_do_resume) ENDPROC(cpu_arm920_do_resume) #endif - __CPUINIT - .type __arm920_setup, #function __arm920_setup: mov r0, #0 diff --git a/arch/arm/mm/proc-arm922.S b/arch/arm/mm/proc-arm922.S index 4464c49d7449..2a758b06c6f6 100644 --- a/arch/arm/mm/proc-arm922.S +++ b/arch/arm/mm/proc-arm922.S @@ -388,8 +388,6 @@ ENTRY(cpu_arm922_set_pte_ext) #endif /* CONFIG_MMU */ mov pc, lr - __CPUINIT - .type __arm922_setup, #function __arm922_setup: mov r0, #0 diff --git a/arch/arm/mm/proc-arm925.S b/arch/arm/mm/proc-arm925.S index 281eb9b9c1d6..97448c3acf38 100644 --- a/arch/arm/mm/proc-arm925.S +++ b/arch/arm/mm/proc-arm925.S @@ -438,8 +438,6 @@ ENTRY(cpu_arm925_set_pte_ext) #endif /* CONFIG_MMU */ mov pc, lr - __CPUINIT - .type __arm925_setup, #function __arm925_setup: mov r0, #0 diff --git a/arch/arm/mm/proc-arm926.S b/arch/arm/mm/proc-arm926.S index 344c8a548cc0..0f098f407c9f 100644 --- a/arch/arm/mm/proc-arm926.S +++ b/arch/arm/mm/proc-arm926.S @@ -425,8 +425,6 @@ ENTRY(cpu_arm926_do_resume) ENDPROC(cpu_arm926_do_resume) #endif - __CPUINIT - .type __arm926_setup, #function __arm926_setup: mov r0, #0 diff --git a/arch/arm/mm/proc-arm940.S b/arch/arm/mm/proc-arm940.S index 8da189d4a402..1c39a704ff6e 100644 --- a/arch/arm/mm/proc-arm940.S +++ b/arch/arm/mm/proc-arm940.S @@ -273,8 +273,6 @@ ENDPROC(arm940_dma_unmap_area) @ define struct cpu_cache_fns (see and proc-macros.S) define_cache_functions arm940 - __CPUINIT - .type __arm940_setup, #function __arm940_setup: mov r0, #0 diff --git a/arch/arm/mm/proc-arm946.S b/arch/arm/mm/proc-arm946.S index f666cf34075a..0289cd905e73 100644 --- a/arch/arm/mm/proc-arm946.S +++ b/arch/arm/mm/proc-arm946.S @@ -326,8 +326,6 @@ ENTRY(cpu_arm946_dcache_clean_area) mcr p15, 0, r0, c7, c10, 4 @ drain WB mov pc, lr - __CPUINIT - .type __arm946_setup, #function __arm946_setup: mov r0, #0 diff --git a/arch/arm/mm/proc-arm9tdmi.S b/arch/arm/mm/proc-arm9tdmi.S index 8881391dfb9e..f51197ba754a 100644 --- a/arch/arm/mm/proc-arm9tdmi.S +++ b/arch/arm/mm/proc-arm9tdmi.S @@ -51,8 +51,6 @@ ENTRY(cpu_arm9tdmi_reset) ENDPROC(cpu_arm9tdmi_reset) .popsection - __CPUINIT - .type __arm9tdmi_setup, #function __arm9tdmi_setup: mov pc, lr diff --git a/arch/arm/mm/proc-fa526.S b/arch/arm/mm/proc-fa526.S index aaeb6c127c7a..2dfc0f1d3bfd 100644 --- a/arch/arm/mm/proc-fa526.S +++ b/arch/arm/mm/proc-fa526.S @@ -135,8 +135,6 @@ ENTRY(cpu_fa526_set_pte_ext) #endif mov pc, lr - __CPUINIT - .type __fa526_setup, #function __fa526_setup: /* On return of this routine, r0 must carry correct flags for CFG register */ diff --git a/arch/arm/mm/proc-feroceon.S b/arch/arm/mm/proc-feroceon.S index 4106b09e0c29..d5146b98c8d1 100644 --- a/arch/arm/mm/proc-feroceon.S +++ b/arch/arm/mm/proc-feroceon.S @@ -514,8 +514,6 @@ ENTRY(cpu_feroceon_set_pte_ext) #endif mov pc, lr - __CPUINIT - .type __feroceon_setup, #function __feroceon_setup: mov r0, #0 diff --git a/arch/arm/mm/proc-mohawk.S b/arch/arm/mm/proc-mohawk.S index 0b60dd3d742a..40acba595731 100644 --- a/arch/arm/mm/proc-mohawk.S +++ b/arch/arm/mm/proc-mohawk.S @@ -383,8 +383,6 @@ ENTRY(cpu_mohawk_do_resume) ENDPROC(cpu_mohawk_do_resume) #endif - __CPUINIT - .type __mohawk_setup, #function __mohawk_setup: mov r0, #0 diff --git a/arch/arm/mm/proc-sa110.S b/arch/arm/mm/proc-sa110.S index 775d70fba937..c45319c8f1d9 100644 --- a/arch/arm/mm/proc-sa110.S +++ b/arch/arm/mm/proc-sa110.S @@ -159,8 +159,6 @@ ENTRY(cpu_sa110_set_pte_ext) #endif mov pc, lr - __CPUINIT - .type __sa110_setup, #function __sa110_setup: mov r10, #0 diff --git a/arch/arm/mm/proc-sa1100.S b/arch/arm/mm/proc-sa1100.S index d92dfd081429..09d241ae2dbe 100644 --- a/arch/arm/mm/proc-sa1100.S +++ b/arch/arm/mm/proc-sa1100.S @@ -198,8 +198,6 @@ ENTRY(cpu_sa1100_do_resume) ENDPROC(cpu_sa1100_do_resume) #endif - __CPUINIT - .type __sa1100_setup, #function __sa1100_setup: mov r0, #0 diff --git a/arch/arm/mm/proc-v6.S b/arch/arm/mm/proc-v6.S index 2d1ef87328a1..1128064fddcb 100644 --- a/arch/arm/mm/proc-v6.S +++ b/arch/arm/mm/proc-v6.S @@ -180,8 +180,6 @@ ENDPROC(cpu_v6_do_resume) .align - __CPUINIT - /* * __v6_setup * diff --git a/arch/arm/mm/proc-v7-2level.S b/arch/arm/mm/proc-v7-2level.S index 9704097c450e..f64afb9f1bd5 100644 --- a/arch/arm/mm/proc-v7-2level.S +++ b/arch/arm/mm/proc-v7-2level.S @@ -160,8 +160,6 @@ ENDPROC(cpu_v7_set_pte_ext) mcr p15, 0, \ttbr1, c2, c0, 1 @ load TTB1 .endm - __CPUINIT - /* AT * TFR EV X F I D LR S * .EEE ..EE PUI. .T.T 4RVI ZWRS BLDP WCAM @@ -172,5 +170,3 @@ ENDPROC(cpu_v7_set_pte_ext) .type v7_crval, #object v7_crval: crval clear=0x2120c302, mmuset=0x10c03c7d, ucset=0x00c01c7c - - .previous diff --git a/arch/arm/mm/proc-v7-3level.S b/arch/arm/mm/proc-v7-3level.S index 5ffe1956c6d9..c36ac69488c8 100644 --- a/arch/arm/mm/proc-v7-3level.S +++ b/arch/arm/mm/proc-v7-3level.S @@ -140,8 +140,6 @@ ENDPROC(cpu_v7_set_pte_ext) mcrr p15, 0, \ttbr0, \zero, c2 @ load TTBR0 .endm - __CPUINIT - /* * AT * TFR EV X F IHD LR S @@ -153,5 +151,3 @@ ENDPROC(cpu_v7_set_pte_ext) .type v7_crval, #object v7_crval: crval clear=0x0120c302, mmuset=0x30c23c7d, ucset=0x00c01c7c - - .previous diff --git a/arch/arm/mm/proc-v7.S b/arch/arm/mm/proc-v7.S index 7ef3ad05df39..5c6d5a3050ea 100644 --- a/arch/arm/mm/proc-v7.S +++ b/arch/arm/mm/proc-v7.S @@ -167,8 +167,6 @@ ENDPROC(cpu_pj4b_do_idle) #endif - __CPUINIT - /* * __v7_setup * diff --git a/arch/arm/mm/proc-xsc3.S b/arch/arm/mm/proc-xsc3.S index e8efd83b6f25..dc1645890042 100644 --- a/arch/arm/mm/proc-xsc3.S +++ b/arch/arm/mm/proc-xsc3.S @@ -446,8 +446,6 @@ ENTRY(cpu_xsc3_do_resume) ENDPROC(cpu_xsc3_do_resume) #endif - __CPUINIT - .type __xsc3_setup, #function __xsc3_setup: mov r0, #PSR_F_BIT|PSR_I_BIT|SVC_MODE diff --git a/arch/arm/mm/proc-xscale.S b/arch/arm/mm/proc-xscale.S index e766f889bfd6..d19b1cfcad91 100644 --- a/arch/arm/mm/proc-xscale.S +++ b/arch/arm/mm/proc-xscale.S @@ -558,8 +558,6 @@ ENTRY(cpu_xscale_do_resume) ENDPROC(cpu_xscale_do_resume) #endif - __CPUINIT - .type __xscale_setup, #function __xscale_setup: mcr p15, 0, ip, c7, c7, 0 @ invalidate I, D caches & BTB diff --git a/arch/arm/plat-versatile/platsmp.c b/arch/arm/plat-versatile/platsmp.c index 1e1b2d769748..39895d892c3b 100644 --- a/arch/arm/plat-versatile/platsmp.c +++ b/arch/arm/plat-versatile/platsmp.c @@ -23,7 +23,7 @@ * observers, irrespective of whether they're taking part in coherency * or not. This is necessary for the hotplug code to work reliably. */ -static void __cpuinit write_pen_release(int val) +static void write_pen_release(int val) { pen_release = val; smp_wmb(); @@ -33,7 +33,7 @@ static void __cpuinit write_pen_release(int val) static DEFINE_SPINLOCK(boot_lock); -void __cpuinit versatile_secondary_init(unsigned int cpu) +void versatile_secondary_init(unsigned int cpu) { /* * let the primary processor know we're out of the @@ -48,7 +48,7 @@ void __cpuinit versatile_secondary_init(unsigned int cpu) spin_unlock(&boot_lock); } -int __cpuinit versatile_boot_secondary(unsigned int cpu, struct task_struct *idle) +int versatile_boot_secondary(unsigned int cpu, struct task_struct *idle) { unsigned long timeout; From 2066aadd53c563445039d6490b685783816270ec Mon Sep 17 00:00:00 2001 From: Paul Gortmaker Date: Mon, 17 Jun 2013 15:43:14 -0400 Subject: [PATCH 0905/1048] sparc: delete __cpuinit/__CPUINIT usage from all users The __cpuinit type of throwaway sections might have made sense some time ago when RAM was more constrained, but now the savings do not offset the cost and complications. For example, the fix in commit 5e427ec2d0 ("x86: Fix bit corruption at CPU resume time") is a good example of the nasty type of bugs that can be created with improper use of the various __init prefixes. After a discussion on LKML[1] it was decided that cpuinit should go the way of devinit and be phased out. Once all the users are gone, we can then finally remove the macros themselves from linux/init.h. Note that some harmless section mismatch warnings may result, since notify_cpu_starting() and cpu_up() are arch independent (kernel/cpu.c) are flagged as __cpuinit -- so if we remove the __cpuinit from arch specific callers, we will also get section mismatch warnings. As an intermediate step, we intend to turn the linux/init.h cpuinit content into no-ops as early as possible, since that will get rid of these warnings. In any case, they are temporary and harmless. This removes all the arch/sparc uses of the __cpuinit macros from C files and removes __CPUINIT from assembly files. Note that even though arch/sparc/kernel/trampoline_64.S has instances of ".previous" in it, they are all paired off against explicit ".section" directives, and not implicitly paired with __CPUINIT (unlike mips and arm were). [1] https://lkml.org/lkml/2013/5/20/589 Cc: "David S. Miller" Cc: sparclinux@vger.kernel.org Signed-off-by: Paul Gortmaker --- arch/sparc/kernel/ds.c | 11 ++++------ arch/sparc/kernel/entry.h | 2 +- arch/sparc/kernel/hvtramp.S | 1 - arch/sparc/kernel/irq_64.c | 5 +++-- arch/sparc/kernel/leon_smp.c | 10 ++++----- arch/sparc/kernel/mdesc.c | 34 +++++++++++++++---------------- arch/sparc/kernel/smp_32.c | 20 +++++++++--------- arch/sparc/kernel/smp_64.c | 9 ++++---- arch/sparc/kernel/sun4d_smp.c | 6 +++--- arch/sparc/kernel/sun4m_smp.c | 6 +++--- arch/sparc/kernel/sysfs.c | 4 ++-- arch/sparc/kernel/trampoline_32.S | 3 --- arch/sparc/kernel/trampoline_64.S | 2 -- arch/sparc/mm/init_64.c | 2 +- arch/sparc/mm/srmmu.c | 12 +++++------ 15 files changed, 60 insertions(+), 67 deletions(-) diff --git a/arch/sparc/kernel/ds.c b/arch/sparc/kernel/ds.c index 11d460f6f9cc..62d6b153ffa2 100644 --- a/arch/sparc/kernel/ds.c +++ b/arch/sparc/kernel/ds.c @@ -528,10 +528,8 @@ static void dr_cpu_mark(struct ds_data *resp, int cpu, int ncpus, } } -static int __cpuinit dr_cpu_configure(struct ds_info *dp, - struct ds_cap_state *cp, - u64 req_num, - cpumask_t *mask) +static int dr_cpu_configure(struct ds_info *dp, struct ds_cap_state *cp, + u64 req_num, cpumask_t *mask) { struct ds_data *resp; int resp_len, ncpus, cpu; @@ -627,9 +625,8 @@ static int dr_cpu_unconfigure(struct ds_info *dp, return 0; } -static void __cpuinit dr_cpu_data(struct ds_info *dp, - struct ds_cap_state *cp, - void *buf, int len) +static void dr_cpu_data(struct ds_info *dp, struct ds_cap_state *cp, void *buf, + int len) { struct ds_data *data = buf; struct dr_cpu_tag *tag = (struct dr_cpu_tag *) (data + 1); diff --git a/arch/sparc/kernel/entry.h b/arch/sparc/kernel/entry.h index cc3c5cb47cda..9c179fbfb219 100644 --- a/arch/sparc/kernel/entry.h +++ b/arch/sparc/kernel/entry.h @@ -250,7 +250,7 @@ extern struct ino_bucket *ivector_table; extern unsigned long ivector_table_pa; extern void init_irqwork_curcpu(void); -extern void __cpuinit sun4v_register_mondo_queues(int this_cpu); +extern void sun4v_register_mondo_queues(int this_cpu); #endif /* CONFIG_SPARC32 */ #endif /* _ENTRY_H */ diff --git a/arch/sparc/kernel/hvtramp.S b/arch/sparc/kernel/hvtramp.S index 605c960b2fa6..4eb1a5a1d544 100644 --- a/arch/sparc/kernel/hvtramp.S +++ b/arch/sparc/kernel/hvtramp.S @@ -16,7 +16,6 @@ #include #include - __CPUINIT .align 8 .globl hv_cpu_startup, hv_cpu_startup_end diff --git a/arch/sparc/kernel/irq_64.c b/arch/sparc/kernel/irq_64.c index 9bcbbe2c4e7e..d4840cec2c55 100644 --- a/arch/sparc/kernel/irq_64.c +++ b/arch/sparc/kernel/irq_64.c @@ -835,7 +835,8 @@ void notrace init_irqwork_curcpu(void) * Therefore you cannot make any OBP calls, not even prom_printf, * from these two routines. */ -static void __cpuinit notrace register_one_mondo(unsigned long paddr, unsigned long type, unsigned long qmask) +static void notrace register_one_mondo(unsigned long paddr, unsigned long type, + unsigned long qmask) { unsigned long num_entries = (qmask + 1) / 64; unsigned long status; @@ -848,7 +849,7 @@ static void __cpuinit notrace register_one_mondo(unsigned long paddr, unsigned l } } -void __cpuinit notrace sun4v_register_mondo_queues(int this_cpu) +void notrace sun4v_register_mondo_queues(int this_cpu) { struct trap_per_cpu *tb = &trap_block[this_cpu]; diff --git a/arch/sparc/kernel/leon_smp.c b/arch/sparc/kernel/leon_smp.c index d7aa524b7283..6edf955f987c 100644 --- a/arch/sparc/kernel/leon_smp.c +++ b/arch/sparc/kernel/leon_smp.c @@ -54,7 +54,7 @@ extern ctxd_t *srmmu_ctx_table_phys; static int smp_processors_ready; extern volatile unsigned long cpu_callin_map[NR_CPUS]; extern cpumask_t smp_commenced_mask; -void __cpuinit leon_configure_cache_smp(void); +void leon_configure_cache_smp(void); static void leon_ipi_init(void); /* IRQ number of LEON IPIs */ @@ -69,12 +69,12 @@ static inline unsigned long do_swap(volatile unsigned long *ptr, return val; } -void __cpuinit leon_cpu_pre_starting(void *arg) +void leon_cpu_pre_starting(void *arg) { leon_configure_cache_smp(); } -void __cpuinit leon_cpu_pre_online(void *arg) +void leon_cpu_pre_online(void *arg) { int cpuid = hard_smp_processor_id(); @@ -106,7 +106,7 @@ void __cpuinit leon_cpu_pre_online(void *arg) extern struct linux_prom_registers smp_penguin_ctable; -void __cpuinit leon_configure_cache_smp(void) +void leon_configure_cache_smp(void) { unsigned long cfg = sparc_leon3_get_dcachecfg(); int me = smp_processor_id(); @@ -186,7 +186,7 @@ void __init leon_boot_cpus(void) } -int __cpuinit leon_boot_one_cpu(int i, struct task_struct *idle) +int leon_boot_one_cpu(int i, struct task_struct *idle) { int timeout; diff --git a/arch/sparc/kernel/mdesc.c b/arch/sparc/kernel/mdesc.c index 831c001604e8..b90bf23e3aab 100644 --- a/arch/sparc/kernel/mdesc.c +++ b/arch/sparc/kernel/mdesc.c @@ -571,9 +571,7 @@ static void __init report_platform_properties(void) mdesc_release(hp); } -static void __cpuinit fill_in_one_cache(cpuinfo_sparc *c, - struct mdesc_handle *hp, - u64 mp) +static void fill_in_one_cache(cpuinfo_sparc *c, struct mdesc_handle *hp, u64 mp) { const u64 *level = mdesc_get_property(hp, mp, "level", NULL); const u64 *size = mdesc_get_property(hp, mp, "size", NULL); @@ -616,7 +614,7 @@ static void __cpuinit fill_in_one_cache(cpuinfo_sparc *c, } } -static void __cpuinit mark_core_ids(struct mdesc_handle *hp, u64 mp, int core_id) +static void mark_core_ids(struct mdesc_handle *hp, u64 mp, int core_id) { u64 a; @@ -649,7 +647,7 @@ static void __cpuinit mark_core_ids(struct mdesc_handle *hp, u64 mp, int core_id } } -static void __cpuinit set_core_ids(struct mdesc_handle *hp) +static void set_core_ids(struct mdesc_handle *hp) { int idx; u64 mp; @@ -674,7 +672,7 @@ static void __cpuinit set_core_ids(struct mdesc_handle *hp) } } -static void __cpuinit mark_proc_ids(struct mdesc_handle *hp, u64 mp, int proc_id) +static void mark_proc_ids(struct mdesc_handle *hp, u64 mp, int proc_id) { u64 a; @@ -693,7 +691,7 @@ static void __cpuinit mark_proc_ids(struct mdesc_handle *hp, u64 mp, int proc_id } } -static void __cpuinit __set_proc_ids(struct mdesc_handle *hp, const char *exec_unit_name) +static void __set_proc_ids(struct mdesc_handle *hp, const char *exec_unit_name) { int idx; u64 mp; @@ -714,14 +712,14 @@ static void __cpuinit __set_proc_ids(struct mdesc_handle *hp, const char *exec_u } } -static void __cpuinit set_proc_ids(struct mdesc_handle *hp) +static void set_proc_ids(struct mdesc_handle *hp) { __set_proc_ids(hp, "exec_unit"); __set_proc_ids(hp, "exec-unit"); } -static void __cpuinit get_one_mondo_bits(const u64 *p, unsigned int *mask, - unsigned long def, unsigned long max) +static void get_one_mondo_bits(const u64 *p, unsigned int *mask, + unsigned long def, unsigned long max) { u64 val; @@ -742,8 +740,8 @@ use_default: *mask = ((1U << def) * 64U) - 1U; } -static void __cpuinit get_mondo_data(struct mdesc_handle *hp, u64 mp, - struct trap_per_cpu *tb) +static void get_mondo_data(struct mdesc_handle *hp, u64 mp, + struct trap_per_cpu *tb) { static int printed; const u64 *val; @@ -769,7 +767,7 @@ static void __cpuinit get_mondo_data(struct mdesc_handle *hp, u64 mp, } } -static void * __cpuinit mdesc_iterate_over_cpus(void *(*func)(struct mdesc_handle *, u64, int, void *), void *arg, cpumask_t *mask) +static void *mdesc_iterate_over_cpus(void *(*func)(struct mdesc_handle *, u64, int, void *), void *arg, cpumask_t *mask) { struct mdesc_handle *hp = mdesc_grab(); void *ret = NULL; @@ -799,7 +797,8 @@ out: return ret; } -static void * __cpuinit record_one_cpu(struct mdesc_handle *hp, u64 mp, int cpuid, void *arg) +static void *record_one_cpu(struct mdesc_handle *hp, u64 mp, int cpuid, + void *arg) { ncpus_probed++; #ifdef CONFIG_SMP @@ -808,7 +807,7 @@ static void * __cpuinit record_one_cpu(struct mdesc_handle *hp, u64 mp, int cpui return NULL; } -void __cpuinit mdesc_populate_present_mask(cpumask_t *mask) +void mdesc_populate_present_mask(cpumask_t *mask) { if (tlb_type != hypervisor) return; @@ -841,7 +840,8 @@ void __init mdesc_get_page_sizes(cpumask_t *mask, unsigned long *pgsz_mask) mdesc_iterate_over_cpus(check_one_pgsz, pgsz_mask, mask); } -static void * __cpuinit fill_in_one_cpu(struct mdesc_handle *hp, u64 mp, int cpuid, void *arg) +static void *fill_in_one_cpu(struct mdesc_handle *hp, u64 mp, int cpuid, + void *arg) { const u64 *cfreq = mdesc_get_property(hp, mp, "clock-frequency", NULL); struct trap_per_cpu *tb; @@ -890,7 +890,7 @@ static void * __cpuinit fill_in_one_cpu(struct mdesc_handle *hp, u64 mp, int cpu return NULL; } -void __cpuinit mdesc_fill_in_cpu_data(cpumask_t *mask) +void mdesc_fill_in_cpu_data(cpumask_t *mask) { struct mdesc_handle *hp; diff --git a/arch/sparc/kernel/smp_32.c b/arch/sparc/kernel/smp_32.c index e3f2b81c23f1..a102bfba6ea8 100644 --- a/arch/sparc/kernel/smp_32.c +++ b/arch/sparc/kernel/smp_32.c @@ -39,7 +39,7 @@ #include "kernel.h" #include "irq.h" -volatile unsigned long cpu_callin_map[NR_CPUS] __cpuinitdata = {0,}; +volatile unsigned long cpu_callin_map[NR_CPUS] = {0,}; cpumask_t smp_commenced_mask = CPU_MASK_NONE; @@ -53,7 +53,7 @@ const struct sparc32_ipi_ops *sparc32_ipi_ops; * instruction which is much better... */ -void __cpuinit smp_store_cpu_info(int id) +void smp_store_cpu_info(int id) { int cpu_node; int mid; @@ -120,7 +120,7 @@ void cpu_panic(void) panic("SMP bolixed\n"); } -struct linux_prom_registers smp_penguin_ctable __cpuinitdata = { 0 }; +struct linux_prom_registers smp_penguin_ctable = { 0 }; void smp_send_reschedule(int cpu) { @@ -259,10 +259,10 @@ void __init smp_prepare_boot_cpu(void) set_cpu_possible(cpuid, true); } -int __cpuinit __cpu_up(unsigned int cpu, struct task_struct *tidle) +int __cpu_up(unsigned int cpu, struct task_struct *tidle) { - extern int __cpuinit smp4m_boot_one_cpu(int, struct task_struct *); - extern int __cpuinit smp4d_boot_one_cpu(int, struct task_struct *); + extern int smp4m_boot_one_cpu(int, struct task_struct *); + extern int smp4d_boot_one_cpu(int, struct task_struct *); int ret=0; switch(sparc_cpu_model) { @@ -297,7 +297,7 @@ int __cpuinit __cpu_up(unsigned int cpu, struct task_struct *tidle) return ret; } -void __cpuinit arch_cpu_pre_starting(void *arg) +void arch_cpu_pre_starting(void *arg) { local_ops->cache_all(); local_ops->tlb_all(); @@ -317,7 +317,7 @@ void __cpuinit arch_cpu_pre_starting(void *arg) } } -void __cpuinit arch_cpu_pre_online(void *arg) +void arch_cpu_pre_online(void *arg) { unsigned int cpuid = hard_smp_processor_id(); @@ -344,7 +344,7 @@ void __cpuinit arch_cpu_pre_online(void *arg) } } -void __cpuinit sparc_start_secondary(void *arg) +void sparc_start_secondary(void *arg) { unsigned int cpu; @@ -375,7 +375,7 @@ void __cpuinit sparc_start_secondary(void *arg) BUG(); } -void __cpuinit smp_callin(void) +void smp_callin(void) { sparc_start_secondary(NULL); } diff --git a/arch/sparc/kernel/smp_64.c b/arch/sparc/kernel/smp_64.c index 77539eda928c..e142545244f2 100644 --- a/arch/sparc/kernel/smp_64.c +++ b/arch/sparc/kernel/smp_64.c @@ -87,7 +87,7 @@ extern void setup_sparc64_timer(void); static volatile unsigned long callin_flag = 0; -void __cpuinit smp_callin(void) +void smp_callin(void) { int cpuid = hard_smp_processor_id(); @@ -281,7 +281,8 @@ static unsigned long kimage_addr_to_ra(void *p) return kern_base + (val - KERNBASE); } -static void __cpuinit ldom_startcpu_cpuid(unsigned int cpu, unsigned long thread_reg, void **descrp) +static void ldom_startcpu_cpuid(unsigned int cpu, unsigned long thread_reg, + void **descrp) { extern unsigned long sparc64_ttable_tl0; extern unsigned long kern_locked_tte_data; @@ -342,7 +343,7 @@ extern unsigned long sparc64_cpu_startup; */ static struct thread_info *cpu_new_thread = NULL; -static int __cpuinit smp_boot_one_cpu(unsigned int cpu, struct task_struct *idle) +static int smp_boot_one_cpu(unsigned int cpu, struct task_struct *idle) { unsigned long entry = (unsigned long)(&sparc64_cpu_startup); @@ -1266,7 +1267,7 @@ void smp_fill_in_sib_core_maps(void) } } -int __cpuinit __cpu_up(unsigned int cpu, struct task_struct *tidle) +int __cpu_up(unsigned int cpu, struct task_struct *tidle) { int ret = smp_boot_one_cpu(cpu, tidle); diff --git a/arch/sparc/kernel/sun4d_smp.c b/arch/sparc/kernel/sun4d_smp.c index c9eb82f23d92..d5c319553fd0 100644 --- a/arch/sparc/kernel/sun4d_smp.c +++ b/arch/sparc/kernel/sun4d_smp.c @@ -50,7 +50,7 @@ static inline void show_leds(int cpuid) "i" (ASI_M_CTL)); } -void __cpuinit sun4d_cpu_pre_starting(void *arg) +void sun4d_cpu_pre_starting(void *arg) { int cpuid = hard_smp_processor_id(); @@ -62,7 +62,7 @@ void __cpuinit sun4d_cpu_pre_starting(void *arg) cc_set_imsk((cc_get_imsk() & ~0x8000) | 0x4000); } -void __cpuinit sun4d_cpu_pre_online(void *arg) +void sun4d_cpu_pre_online(void *arg) { unsigned long flags; int cpuid; @@ -118,7 +118,7 @@ void __init smp4d_boot_cpus(void) local_ops->cache_all(); } -int __cpuinit smp4d_boot_one_cpu(int i, struct task_struct *idle) +int smp4d_boot_one_cpu(int i, struct task_struct *idle) { unsigned long *entry = &sun4d_cpu_startup; int timeout; diff --git a/arch/sparc/kernel/sun4m_smp.c b/arch/sparc/kernel/sun4m_smp.c index 8a65f158153d..d3408e72d20c 100644 --- a/arch/sparc/kernel/sun4m_smp.c +++ b/arch/sparc/kernel/sun4m_smp.c @@ -34,11 +34,11 @@ swap_ulong(volatile unsigned long *ptr, unsigned long val) return val; } -void __cpuinit sun4m_cpu_pre_starting(void *arg) +void sun4m_cpu_pre_starting(void *arg) { } -void __cpuinit sun4m_cpu_pre_online(void *arg) +void sun4m_cpu_pre_online(void *arg) { int cpuid = hard_smp_processor_id(); @@ -75,7 +75,7 @@ void __init smp4m_boot_cpus(void) local_ops->cache_all(); } -int __cpuinit smp4m_boot_one_cpu(int i, struct task_struct *idle) +int smp4m_boot_one_cpu(int i, struct task_struct *idle) { unsigned long *entry = &sun4m_cpu_startup; int timeout; diff --git a/arch/sparc/kernel/sysfs.c b/arch/sparc/kernel/sysfs.c index 654e8aad3bbe..c21c673e5f7c 100644 --- a/arch/sparc/kernel/sysfs.c +++ b/arch/sparc/kernel/sysfs.c @@ -246,7 +246,7 @@ static void unregister_cpu_online(unsigned int cpu) } #endif -static int __cpuinit sysfs_cpu_notify(struct notifier_block *self, +static int sysfs_cpu_notify(struct notifier_block *self, unsigned long action, void *hcpu) { unsigned int cpu = (unsigned int)(long)hcpu; @@ -266,7 +266,7 @@ static int __cpuinit sysfs_cpu_notify(struct notifier_block *self, return NOTIFY_OK; } -static struct notifier_block __cpuinitdata sysfs_cpu_nb = { +static struct notifier_block sysfs_cpu_nb = { .notifier_call = sysfs_cpu_notify, }; diff --git a/arch/sparc/kernel/trampoline_32.S b/arch/sparc/kernel/trampoline_32.S index 6cdb08cdabf0..76dcbd3c988a 100644 --- a/arch/sparc/kernel/trampoline_32.S +++ b/arch/sparc/kernel/trampoline_32.S @@ -18,7 +18,6 @@ .globl sun4m_cpu_startup .globl sun4d_cpu_startup - __CPUINIT .align 4 /* When we start up a cpu for the first time it enters this routine. @@ -94,7 +93,6 @@ smp_panic: /* CPUID in bootbus can be found at PA 0xff0140000 */ #define SUN4D_BOOTBUS_CPUID 0xf0140000 - __CPUINIT .align 4 sun4d_cpu_startup: @@ -146,7 +144,6 @@ sun4d_cpu_startup: b,a smp_panic - __CPUINIT .align 4 .global leon_smp_cpu_startup, smp_penguin_ctable diff --git a/arch/sparc/kernel/trampoline_64.S b/arch/sparc/kernel/trampoline_64.S index 2e973a26fbda..e0b1e13a0736 100644 --- a/arch/sparc/kernel/trampoline_64.S +++ b/arch/sparc/kernel/trampoline_64.S @@ -32,13 +32,11 @@ itlb_load: dtlb_load: .asciz "SUNW,dtlb-load" - /* XXX __cpuinit this thing XXX */ #define TRAMP_STACK_SIZE 1024 .align 16 tramp_stack: .skip TRAMP_STACK_SIZE - __CPUINIT .align 8 .globl sparc64_cpu_startup, sparc64_cpu_startup_end sparc64_cpu_startup: diff --git a/arch/sparc/mm/init_64.c b/arch/sparc/mm/init_64.c index a9c42a7ffb6a..ed82edad1a39 100644 --- a/arch/sparc/mm/init_64.c +++ b/arch/sparc/mm/init_64.c @@ -1694,7 +1694,7 @@ static void __init sun4v_ktsb_init(void) #endif } -void __cpuinit sun4v_ktsb_register(void) +void sun4v_ktsb_register(void) { unsigned long pa, ret; diff --git a/arch/sparc/mm/srmmu.c b/arch/sparc/mm/srmmu.c index 036c2797dece..5d721df48a72 100644 --- a/arch/sparc/mm/srmmu.c +++ b/arch/sparc/mm/srmmu.c @@ -858,7 +858,7 @@ static void __init map_kernel(void) } } -void (*poke_srmmu)(void) __cpuinitdata = NULL; +void (*poke_srmmu)(void) = NULL; extern unsigned long bootmem_init(unsigned long *pages_avail); @@ -1055,7 +1055,7 @@ static void __init init_vac_layout(void) (int)vac_cache_size, (int)vac_line_size); } -static void __cpuinit poke_hypersparc(void) +static void poke_hypersparc(void) { volatile unsigned long clear; unsigned long mreg = srmmu_get_mmureg(); @@ -1107,7 +1107,7 @@ static void __init init_hypersparc(void) hypersparc_setup_blockops(); } -static void __cpuinit poke_swift(void) +static void poke_swift(void) { unsigned long mreg; @@ -1287,7 +1287,7 @@ static void turbosparc_flush_tlb_page(struct vm_area_struct *vma, unsigned long } -static void __cpuinit poke_turbosparc(void) +static void poke_turbosparc(void) { unsigned long mreg = srmmu_get_mmureg(); unsigned long ccreg; @@ -1350,7 +1350,7 @@ static void __init init_turbosparc(void) poke_srmmu = poke_turbosparc; } -static void __cpuinit poke_tsunami(void) +static void poke_tsunami(void) { unsigned long mreg = srmmu_get_mmureg(); @@ -1391,7 +1391,7 @@ static void __init init_tsunami(void) tsunami_setup_blockops(); } -static void __cpuinit poke_viking(void) +static void poke_viking(void) { unsigned long mreg = srmmu_get_mmureg(); static int smp_catch; From b8c6453aaf142620c2e1a4c2da24bbb10cb424bf Mon Sep 17 00:00:00 2001 From: Paul Gortmaker Date: Tue, 18 Jun 2013 10:18:31 -0400 Subject: [PATCH 0906/1048] arm64: delete __cpuinit usage from all users The __cpuinit type of throwaway sections might have made sense some time ago when RAM was more constrained, but now the savings do not offset the cost and complications. For example, the fix in commit 5e427ec2d0 ("x86: Fix bit corruption at CPU resume time") is a good example of the nasty type of bugs that can be created with improper use of the various __init prefixes. After a discussion on LKML[1] it was decided that cpuinit should go the way of devinit and be phased out. Once all the users are gone, we can then finally remove the macros themselves from linux/init.h. Note that some harmless section mismatch warnings may result, since notify_cpu_starting() and cpu_up() are arch independent (kernel/cpu.c) are flagged as __cpuinit -- so if we remove the __cpuinit from arch specific callers, we will also get section mismatch warnings. As an intermediate step, we intend to turn the linux/init.h cpuinit content into no-ops as early as possible, since that will get rid of these warnings. In any case, they are temporary and harmless. This removes all the arch/arm64 uses of the __cpuinit macros from all C files. Currently arm64 does not have any __CPUINIT used in assembly files. [1] https://lkml.org/lkml/2013/5/20/589 Cc: Catalin Marinas Cc: Will Deacon Acked-by: Catalin Marinas Signed-off-by: Paul Gortmaker --- arch/arm64/include/asm/arch_timer.h | 2 +- arch/arm64/kernel/debug-monitors.c | 6 +++--- arch/arm64/kernel/hw_breakpoint.c | 4 ++-- arch/arm64/kernel/smp.c | 8 ++++---- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/arch/arm64/include/asm/arch_timer.h b/arch/arm64/include/asm/arch_timer.h index d56ed11ba9a3..98abd476992d 100644 --- a/arch/arm64/include/asm/arch_timer.h +++ b/arch/arm64/include/asm/arch_timer.h @@ -97,7 +97,7 @@ static inline u32 arch_timer_get_cntfrq(void) return val; } -static inline void __cpuinit arch_counter_set_user_access(void) +static inline void arch_counter_set_user_access(void) { u32 cntkctl; diff --git a/arch/arm64/kernel/debug-monitors.c b/arch/arm64/kernel/debug-monitors.c index 08018e3df580..cbfacf7fb438 100644 --- a/arch/arm64/kernel/debug-monitors.c +++ b/arch/arm64/kernel/debug-monitors.c @@ -141,7 +141,7 @@ static void clear_os_lock(void *unused) isb(); } -static int __cpuinit os_lock_notify(struct notifier_block *self, +static int os_lock_notify(struct notifier_block *self, unsigned long action, void *data) { int cpu = (unsigned long)data; @@ -150,11 +150,11 @@ static int __cpuinit os_lock_notify(struct notifier_block *self, return NOTIFY_OK; } -static struct notifier_block __cpuinitdata os_lock_nb = { +static struct notifier_block os_lock_nb = { .notifier_call = os_lock_notify, }; -static int __cpuinit debug_monitors_init(void) +static int debug_monitors_init(void) { /* Clear the OS lock. */ smp_call_function(clear_os_lock, NULL, 1); diff --git a/arch/arm64/kernel/hw_breakpoint.c b/arch/arm64/kernel/hw_breakpoint.c index 5ab825c59db9..329218ca9ffb 100644 --- a/arch/arm64/kernel/hw_breakpoint.c +++ b/arch/arm64/kernel/hw_breakpoint.c @@ -821,7 +821,7 @@ static void reset_ctrl_regs(void *unused) } } -static int __cpuinit hw_breakpoint_reset_notify(struct notifier_block *self, +static int hw_breakpoint_reset_notify(struct notifier_block *self, unsigned long action, void *hcpu) { @@ -831,7 +831,7 @@ static int __cpuinit hw_breakpoint_reset_notify(struct notifier_block *self, return NOTIFY_OK; } -static struct notifier_block __cpuinitdata hw_breakpoint_reset_nb = { +static struct notifier_block hw_breakpoint_reset_nb = { .notifier_call = hw_breakpoint_reset_notify, }; diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c index 5d54e3717bf8..4a053b3d1728 100644 --- a/arch/arm64/kernel/smp.c +++ b/arch/arm64/kernel/smp.c @@ -71,7 +71,7 @@ static DEFINE_RAW_SPINLOCK(boot_lock); * in coherency or not. This is necessary for the hotplug code to work * reliably. */ -static void __cpuinit write_pen_release(u64 val) +static void write_pen_release(u64 val) { void *start = (void *)&secondary_holding_pen_release; unsigned long size = sizeof(secondary_holding_pen_release); @@ -84,7 +84,7 @@ static void __cpuinit write_pen_release(u64 val) * Boot a secondary CPU, and assign it the specified idle task. * This also gives us the initial stack to use for this CPU. */ -static int __cpuinit boot_secondary(unsigned int cpu, struct task_struct *idle) +static int boot_secondary(unsigned int cpu, struct task_struct *idle) { unsigned long timeout; @@ -122,7 +122,7 @@ static int __cpuinit boot_secondary(unsigned int cpu, struct task_struct *idle) static DECLARE_COMPLETION(cpu_running); -int __cpuinit __cpu_up(unsigned int cpu, struct task_struct *idle) +int __cpu_up(unsigned int cpu, struct task_struct *idle) { int ret; @@ -162,7 +162,7 @@ int __cpuinit __cpu_up(unsigned int cpu, struct task_struct *idle) * This is the secondary CPU boot entry. We're using this CPUs * idle thread stack, but a set of temporary page tables. */ -asmlinkage void __cpuinit secondary_start_kernel(void) +asmlinkage void secondary_start_kernel(void) { struct mm_struct *mm = &init_mm; unsigned int cpu = smp_processor_id(); From 13dff62d80e93f1cc65b4ad2dddedd12de720272 Mon Sep 17 00:00:00 2001 From: Paul Gortmaker Date: Tue, 18 Jun 2013 16:56:21 -0400 Subject: [PATCH 0907/1048] blackfin: delete __cpuinit usage from all blackfin files The __cpuinit type of throwaway sections might have made sense some time ago when RAM was more constrained, but now the savings do not offset the cost and complications. For example, the fix in commit 5e427ec2d0 ("x86: Fix bit corruption at CPU resume time") is a good example of the nasty type of bugs that can be created with improper use of the various __init prefixes. After a discussion on LKML[1] it was decided that cpuinit should go the way of devinit and be phased out. Once all the users are gone, we can then finally remove the macros themselves from linux/init.h. Note that some harmless section mismatch warnings may result, since notify_cpu_starting() and cpu_up() are arch independent (kernel/cpu.c) are flagged as __cpuinit -- so if we remove the __cpuinit from arch specific callers, we will also get section mismatch warnings. As an intermediate step, we intend to turn the linux/init.h cpuinit content into no-ops as early as possible, since that will get rid of these warnings. In any case, they are temporary and harmless. This removes all the arch/blackfin uses of the __cpuinit macros from all C files. Currently blackfin does not have any __CPUINIT used in assembly files. [1] https://lkml.org/lkml/2013/5/20/589 Cc: Mike Frysinger Cc: Bob Liu Cc: Sonic Zhang Cc: uclinux-dist-devel@blackfin.uclinux.org Acked-by: Mike Frysinger Signed-off-by: Paul Gortmaker --- arch/blackfin/kernel/perf_event.c | 2 +- arch/blackfin/kernel/setup.c | 4 ++-- arch/blackfin/mach-bf561/smp.c | 6 +++--- arch/blackfin/mach-common/cache-c.c | 4 ++-- arch/blackfin/mach-common/ints-priority.c | 2 +- arch/blackfin/mach-common/smp.c | 12 ++++++------ 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/arch/blackfin/kernel/perf_event.c b/arch/blackfin/kernel/perf_event.c index e47d19ae3e06..974e55496db3 100644 --- a/arch/blackfin/kernel/perf_event.c +++ b/arch/blackfin/kernel/perf_event.c @@ -468,7 +468,7 @@ static void bfin_pmu_setup(int cpu) memset(cpuhw, 0, sizeof(struct cpu_hw_events)); } -static int __cpuinit +static int bfin_pmu_notifier(struct notifier_block *self, unsigned long action, void *hcpu) { unsigned int cpu = (long)hcpu; diff --git a/arch/blackfin/kernel/setup.c b/arch/blackfin/kernel/setup.c index 107b306b06f1..19ad0637e8ff 100644 --- a/arch/blackfin/kernel/setup.c +++ b/arch/blackfin/kernel/setup.c @@ -99,7 +99,7 @@ void __init generate_cplb_tables(void) } #endif -void __cpuinit bfin_setup_caches(unsigned int cpu) +void bfin_setup_caches(unsigned int cpu) { #ifdef CONFIG_BFIN_ICACHE bfin_icache_init(icplb_tbl[cpu]); @@ -165,7 +165,7 @@ void __cpuinit bfin_setup_caches(unsigned int cpu) #endif } -void __cpuinit bfin_setup_cpudata(unsigned int cpu) +void bfin_setup_cpudata(unsigned int cpu) { struct blackfin_cpudata *cpudata = &per_cpu(cpu_data, cpu); diff --git a/arch/blackfin/mach-bf561/smp.c b/arch/blackfin/mach-bf561/smp.c index c77a23bc9de3..11789beca75a 100644 --- a/arch/blackfin/mach-bf561/smp.c +++ b/arch/blackfin/mach-bf561/smp.c @@ -48,7 +48,7 @@ int __init setup_profiling_timer(unsigned int multiplier) /* not supported */ return -EINVAL; } -void __cpuinit platform_secondary_init(unsigned int cpu) +void platform_secondary_init(unsigned int cpu) { /* Clone setup for peripheral interrupt sources from CoreA. */ bfin_write_SICB_IMASK0(bfin_read_SIC_IMASK0()); @@ -73,7 +73,7 @@ void __cpuinit platform_secondary_init(unsigned int cpu) spin_unlock(&boot_lock); } -int __cpuinit platform_boot_secondary(unsigned int cpu, struct task_struct *idle) +int platform_boot_secondary(unsigned int cpu, struct task_struct *idle) { unsigned long timeout; @@ -154,7 +154,7 @@ void platform_clear_ipi(unsigned int cpu, int irq) * Setup core B's local core timer. * In SMP, core timer is used for clock event device. */ -void __cpuinit bfin_local_timer_setup(void) +void bfin_local_timer_setup(void) { #if defined(CONFIG_TICKSOURCE_CORETMR) struct irq_data *data = irq_get_irq_data(IRQ_CORETMR); diff --git a/arch/blackfin/mach-common/cache-c.c b/arch/blackfin/mach-common/cache-c.c index a60a24f5035d..0e1e451fd7d8 100644 --- a/arch/blackfin/mach-common/cache-c.c +++ b/arch/blackfin/mach-common/cache-c.c @@ -52,7 +52,7 @@ bfin_cache_init(struct cplb_entry *cplb_tbl, unsigned long cplb_addr, } #ifdef CONFIG_BFIN_ICACHE -void __cpuinit bfin_icache_init(struct cplb_entry *icplb_tbl) +void bfin_icache_init(struct cplb_entry *icplb_tbl) { bfin_cache_init(icplb_tbl, ICPLB_ADDR0, ICPLB_DATA0, IMEM_CONTROL, (IMC | ENICPLB)); @@ -60,7 +60,7 @@ void __cpuinit bfin_icache_init(struct cplb_entry *icplb_tbl) #endif #ifdef CONFIG_BFIN_DCACHE -void __cpuinit bfin_dcache_init(struct cplb_entry *dcplb_tbl) +void bfin_dcache_init(struct cplb_entry *dcplb_tbl) { /* * Anomaly notes: diff --git a/arch/blackfin/mach-common/ints-priority.c b/arch/blackfin/mach-common/ints-priority.c index 6c0c6816a51a..d143fd8d2bc5 100644 --- a/arch/blackfin/mach-common/ints-priority.c +++ b/arch/blackfin/mach-common/ints-priority.c @@ -1281,7 +1281,7 @@ static struct irq_chip bfin_gpio_irqchip = { .irq_set_wake = bfin_gpio_set_wake, }; -void __cpuinit init_exception_vectors(void) +void init_exception_vectors(void) { /* cannot program in software: * evt0 - emulation (jtag) diff --git a/arch/blackfin/mach-common/smp.c b/arch/blackfin/mach-common/smp.c index 961d8392e5e3..e546db2f4bc8 100644 --- a/arch/blackfin/mach-common/smp.c +++ b/arch/blackfin/mach-common/smp.c @@ -46,7 +46,7 @@ struct corelock_slot corelock __attribute__ ((__section__(".l2.bss"))); unsigned long blackfin_iflush_l1_entry[NR_CPUS]; #endif -struct blackfin_initial_pda __cpuinitdata initial_pda_coreb; +struct blackfin_initial_pda initial_pda_coreb; enum ipi_message_type { BFIN_IPI_NONE, @@ -246,7 +246,7 @@ void smp_send_stop(void) return; } -int __cpuinit __cpu_up(unsigned int cpu, struct task_struct *idle) +int __cpu_up(unsigned int cpu, struct task_struct *idle) { int ret; @@ -259,7 +259,7 @@ int __cpuinit __cpu_up(unsigned int cpu, struct task_struct *idle) return ret; } -static void __cpuinit setup_secondary(unsigned int cpu) +static void setup_secondary(unsigned int cpu) { unsigned long ilat; @@ -277,7 +277,7 @@ static void __cpuinit setup_secondary(unsigned int cpu) IMASK_IVG10 | IMASK_IVG9 | IMASK_IVG8 | IMASK_IVG7 | IMASK_IVGHW; } -void __cpuinit secondary_start_kernel(void) +void secondary_start_kernel(void) { unsigned int cpu = smp_processor_id(); struct mm_struct *mm = &init_mm; @@ -402,7 +402,7 @@ EXPORT_SYMBOL(resync_core_dcache); #endif #ifdef CONFIG_HOTPLUG_CPU -int __cpuexit __cpu_disable(void) +int __cpu_disable(void) { unsigned int cpu = smp_processor_id(); @@ -415,7 +415,7 @@ int __cpuexit __cpu_disable(void) static DECLARE_COMPLETION(cpu_killed); -int __cpuexit __cpu_die(unsigned int cpu) +int __cpu_die(unsigned int cpu) { return wait_for_completion_timeout(&cpu_killed, 5000); } From e2741f17584f9f5a6e9034b1357ac2152c800087 Mon Sep 17 00:00:00 2001 From: Paul Gortmaker Date: Tue, 18 Jun 2013 17:04:52 -0400 Subject: [PATCH 0908/1048] s390: delete __cpuinit usage from all s390 files The __cpuinit type of throwaway sections might have made sense some time ago when RAM was more constrained, but now the savings do not offset the cost and complications. For example, the fix in commit 5e427ec2d0 ("x86: Fix bit corruption at CPU resume time") is a good example of the nasty type of bugs that can be created with improper use of the various __init prefixes. After a discussion on LKML[1] it was decided that cpuinit should go the way of devinit and be phased out. Once all the users are gone, we can then finally remove the macros themselves from linux/init.h. Note that some harmless section mismatch warnings may result, since notify_cpu_starting() and cpu_up() are arch independent (kernel/cpu.c) are flagged as __cpuinit -- so if we remove the __cpuinit from arch specific callers, we will also get section mismatch warnings. As an intermediate step, we intend to turn the linux/init.h cpuinit content into no-ops as early as possible, since that will get rid of these warnings. In any case, they are temporary and harmless. This removes all the arch/s390 uses of the __cpuinit macros from all C files. Currently s390 does not have any __CPUINIT used in assembly files. [1] https://lkml.org/lkml/2013/5/20/589 Cc: Martin Schwidefsky Cc: Heiko Carstens Cc: linux390@de.ibm.com Cc: linux-s390@vger.kernel.org Signed-off-by: Paul Gortmaker --- arch/s390/kernel/cache.c | 15 +++++++-------- arch/s390/kernel/perf_cpum_cf.c | 4 ++-- arch/s390/kernel/processor.c | 2 +- arch/s390/kernel/smp.c | 17 ++++++++--------- arch/s390/kernel/sysinfo.c | 2 +- arch/s390/kernel/vtime.c | 6 +++--- arch/s390/mm/fault.c | 4 ++-- 7 files changed, 24 insertions(+), 26 deletions(-) diff --git a/arch/s390/kernel/cache.c b/arch/s390/kernel/cache.c index 64b24650e4f8..dd62071624be 100644 --- a/arch/s390/kernel/cache.c +++ b/arch/s390/kernel/cache.c @@ -173,7 +173,7 @@ error: } } -static struct cache_dir *__cpuinit cache_create_cache_dir(int cpu) +static struct cache_dir *cache_create_cache_dir(int cpu) { struct cache_dir *cache_dir; struct kobject *kobj = NULL; @@ -289,9 +289,8 @@ static struct kobj_type cache_index_type = { .default_attrs = cache_index_default_attrs, }; -static int __cpuinit cache_create_index_dir(struct cache_dir *cache_dir, - struct cache *cache, int index, - int cpu) +static int cache_create_index_dir(struct cache_dir *cache_dir, + struct cache *cache, int index, int cpu) { struct cache_index_dir *index_dir; int rc; @@ -313,7 +312,7 @@ out: return rc; } -static int __cpuinit cache_add_cpu(int cpu) +static int cache_add_cpu(int cpu) { struct cache_dir *cache_dir; struct cache *cache; @@ -335,7 +334,7 @@ static int __cpuinit cache_add_cpu(int cpu) return 0; } -static void __cpuinit cache_remove_cpu(int cpu) +static void cache_remove_cpu(int cpu) { struct cache_index_dir *index, *next; struct cache_dir *cache_dir; @@ -354,8 +353,8 @@ static void __cpuinit cache_remove_cpu(int cpu) cache_dir_cpu[cpu] = NULL; } -static int __cpuinit cache_hotplug(struct notifier_block *nfb, - unsigned long action, void *hcpu) +static int cache_hotplug(struct notifier_block *nfb, unsigned long action, + void *hcpu) { int cpu = (long)hcpu; int rc = 0; diff --git a/arch/s390/kernel/perf_cpum_cf.c b/arch/s390/kernel/perf_cpum_cf.c index 390d9ae57bb2..fb99c2057b85 100644 --- a/arch/s390/kernel/perf_cpum_cf.c +++ b/arch/s390/kernel/perf_cpum_cf.c @@ -639,8 +639,8 @@ static struct pmu cpumf_pmu = { .cancel_txn = cpumf_pmu_cancel_txn, }; -static int __cpuinit cpumf_pmu_notifier(struct notifier_block *self, - unsigned long action, void *hcpu) +static int cpumf_pmu_notifier(struct notifier_block *self, unsigned long action, + void *hcpu) { unsigned int cpu = (long) hcpu; int flags; diff --git a/arch/s390/kernel/processor.c b/arch/s390/kernel/processor.c index 753c41d0ffd3..24612029f450 100644 --- a/arch/s390/kernel/processor.c +++ b/arch/s390/kernel/processor.c @@ -21,7 +21,7 @@ static DEFINE_PER_CPU(struct cpuid, cpu_id); /* * cpu_init - initializes state that is per-CPU. */ -void __cpuinit cpu_init(void) +void cpu_init(void) { struct s390_idle_data *idle = &__get_cpu_var(s390_idle); struct cpuid *id = &__get_cpu_var(cpu_id); diff --git a/arch/s390/kernel/smp.c b/arch/s390/kernel/smp.c index 15a016c10563..d386c4e9d2e5 100644 --- a/arch/s390/kernel/smp.c +++ b/arch/s390/kernel/smp.c @@ -165,7 +165,7 @@ static void pcpu_ec_call(struct pcpu *pcpu, int ec_bit) pcpu_sigp_retry(pcpu, order, 0); } -static int __cpuinit pcpu_alloc_lowcore(struct pcpu *pcpu, int cpu) +static int pcpu_alloc_lowcore(struct pcpu *pcpu, int cpu) { struct _lowcore *lc; @@ -616,10 +616,9 @@ static struct sclp_cpu_info *smp_get_cpu_info(void) return info; } -static int __cpuinit smp_add_present_cpu(int cpu); +static int smp_add_present_cpu(int cpu); -static int __cpuinit __smp_rescan_cpus(struct sclp_cpu_info *info, - int sysfs_add) +static int __smp_rescan_cpus(struct sclp_cpu_info *info, int sysfs_add) { struct pcpu *pcpu; cpumask_t avail; @@ -685,7 +684,7 @@ static void __init smp_detect_cpus(void) /* * Activate a secondary processor. */ -static void __cpuinit smp_start_secondary(void *cpuvoid) +static void smp_start_secondary(void *cpuvoid) { S390_lowcore.last_update_clock = get_tod_clock(); S390_lowcore.restart_stack = (unsigned long) restart_stack; @@ -708,7 +707,7 @@ static void __cpuinit smp_start_secondary(void *cpuvoid) } /* Upping and downing of CPUs */ -int __cpuinit __cpu_up(unsigned int cpu, struct task_struct *tidle) +int __cpu_up(unsigned int cpu, struct task_struct *tidle) { struct pcpu *pcpu; int rc; @@ -964,8 +963,8 @@ static struct attribute_group cpu_online_attr_group = { .attrs = cpu_online_attrs, }; -static int __cpuinit smp_cpu_notify(struct notifier_block *self, - unsigned long action, void *hcpu) +static int smp_cpu_notify(struct notifier_block *self, unsigned long action, + void *hcpu) { unsigned int cpu = (unsigned int)(long)hcpu; struct cpu *c = &pcpu_devices[cpu].cpu; @@ -983,7 +982,7 @@ static int __cpuinit smp_cpu_notify(struct notifier_block *self, return notifier_from_errno(err); } -static int __cpuinit smp_add_present_cpu(int cpu) +static int smp_add_present_cpu(int cpu) { struct cpu *c = &pcpu_devices[cpu].cpu; struct device *s = &c->dev; diff --git a/arch/s390/kernel/sysinfo.c b/arch/s390/kernel/sysinfo.c index 62f89d98e880..811f542b8ed4 100644 --- a/arch/s390/kernel/sysinfo.c +++ b/arch/s390/kernel/sysinfo.c @@ -418,7 +418,7 @@ void s390_adjust_jiffies(void) /* * calibrate the delay loop */ -void __cpuinit calibrate_delay(void) +void calibrate_delay(void) { s390_adjust_jiffies(); /* Print the good old Bogomips line .. */ diff --git a/arch/s390/kernel/vtime.c b/arch/s390/kernel/vtime.c index 3fb09359eda6..9b9c1b78ec67 100644 --- a/arch/s390/kernel/vtime.c +++ b/arch/s390/kernel/vtime.c @@ -371,14 +371,14 @@ EXPORT_SYMBOL(del_virt_timer); /* * Start the virtual CPU timer on the current CPU. */ -void __cpuinit init_cpu_vtimer(void) +void init_cpu_vtimer(void) { /* set initial cpu timer */ set_vtimer(VTIMER_MAX_SLICE); } -static int __cpuinit s390_nohz_notify(struct notifier_block *self, - unsigned long action, void *hcpu) +static int s390_nohz_notify(struct notifier_block *self, unsigned long action, + void *hcpu) { struct s390_idle_data *idle; long cpu = (long) hcpu; diff --git a/arch/s390/mm/fault.c b/arch/s390/mm/fault.c index 047c3e4c59a2..f00aefb66a4e 100644 --- a/arch/s390/mm/fault.c +++ b/arch/s390/mm/fault.c @@ -639,8 +639,8 @@ out: put_task_struct(tsk); } -static int __cpuinit pfault_cpu_notify(struct notifier_block *self, - unsigned long action, void *hcpu) +static int pfault_cpu_notify(struct notifier_block *self, unsigned long action, + void *hcpu) { struct thread_struct *thread, *next; struct task_struct *tsk; From 4603f53a1dc3c76dfba841d123db9fa6204934f5 Mon Sep 17 00:00:00 2001 From: Paul Gortmaker Date: Tue, 18 Jun 2013 17:10:12 -0400 Subject: [PATCH 0909/1048] sh: delete __cpuinit usage from all sh files The __cpuinit type of throwaway sections might have made sense some time ago when RAM was more constrained, but now the savings do not offset the cost and complications. For example, the fix in commit 5e427ec2d0 ("x86: Fix bit corruption at CPU resume time") is a good example of the nasty type of bugs that can be created with improper use of the various __init prefixes. After a discussion on LKML[1] it was decided that cpuinit should go the way of devinit and be phased out. Once all the users are gone, we can then finally remove the macros themselves from linux/init.h. Note that some harmless section mismatch warnings may result, since notify_cpu_starting() and cpu_up() are arch independent (kernel/cpu.c) are flagged as __cpuinit -- so if we remove the __cpuinit from arch specific callers, we will also get section mismatch warnings. As an intermediate step, we intend to turn the linux/init.h cpuinit content into no-ops as early as possible, since that will get rid of these warnings. In any case, they are temporary and harmless. This removes all the arch/sh uses of the __cpuinit macros from all C files. Currently sh does not have any __CPUINIT used in assembly files. [1] https://lkml.org/lkml/2013/5/20/589 Cc: Paul Mundt Cc: linux-sh@vger.kernel.org Signed-off-by: Paul Gortmaker --- arch/sh/kernel/cpu/init.c | 18 +++++++++--------- arch/sh/kernel/cpu/sh2/probe.c | 2 +- arch/sh/kernel/cpu/sh2a/probe.c | 2 +- arch/sh/kernel/cpu/sh3/probe.c | 2 +- arch/sh/kernel/cpu/sh4/probe.c | 2 +- arch/sh/kernel/cpu/sh4a/smp-shx3.c | 6 +++--- arch/sh/kernel/cpu/sh5/probe.c | 2 +- arch/sh/kernel/perf_event.c | 4 ++-- arch/sh/kernel/process.c | 2 +- arch/sh/kernel/setup.c | 2 +- arch/sh/kernel/smp.c | 8 ++++---- arch/sh/kernel/traps_32.c | 2 +- arch/sh/kernel/traps_64.c | 2 +- arch/sh/mm/tlb-sh5.c | 2 +- 14 files changed, 28 insertions(+), 28 deletions(-) diff --git a/arch/sh/kernel/cpu/init.c b/arch/sh/kernel/cpu/init.c index 61a07dafcd46..ecf83cd158dc 100644 --- a/arch/sh/kernel/cpu/init.c +++ b/arch/sh/kernel/cpu/init.c @@ -43,9 +43,9 @@ * peripherals (nofpu, nodsp, and so forth). */ #define onchip_setup(x) \ -static int x##_disabled __cpuinitdata = !cpu_has_##x; \ +static int x##_disabled = !cpu_has_##x; \ \ -static int __cpuinit x##_setup(char *opts) \ +static int x##_setup(char *opts) \ { \ x##_disabled = 1; \ return 1; \ @@ -59,7 +59,7 @@ onchip_setup(dsp); #define CPUOPM 0xff2f0000 #define CPUOPM_RABD (1 << 5) -static void __cpuinit speculative_execution_init(void) +static void speculative_execution_init(void) { /* Clear RABD */ __raw_writel(__raw_readl(CPUOPM) & ~CPUOPM_RABD, CPUOPM); @@ -78,7 +78,7 @@ static void __cpuinit speculative_execution_init(void) #define EXPMASK_BRDSSLP (1 << 1) #define EXPMASK_MMCAW (1 << 4) -static void __cpuinit expmask_init(void) +static void expmask_init(void) { unsigned long expmask = __raw_readl(EXPMASK); @@ -217,7 +217,7 @@ static void detect_cache_shape(void) l2_cache_shape = -1; /* No S-cache */ } -static void __cpuinit fpu_init(void) +static void fpu_init(void) { /* Disable the FPU */ if (fpu_disabled && (current_cpu_data.flags & CPU_HAS_FPU)) { @@ -230,7 +230,7 @@ static void __cpuinit fpu_init(void) } #ifdef CONFIG_SH_DSP -static void __cpuinit release_dsp(void) +static void release_dsp(void) { unsigned long sr; @@ -244,7 +244,7 @@ static void __cpuinit release_dsp(void) ); } -static void __cpuinit dsp_init(void) +static void dsp_init(void) { unsigned long sr; @@ -276,7 +276,7 @@ static void __cpuinit dsp_init(void) release_dsp(); } #else -static inline void __cpuinit dsp_init(void) { } +static inline void dsp_init(void) { } #endif /* CONFIG_SH_DSP */ /** @@ -295,7 +295,7 @@ static inline void __cpuinit dsp_init(void) { } * Each processor family is still responsible for doing its own probing * and cache configuration in cpu_probe(). */ -asmlinkage void __cpuinit cpu_init(void) +asmlinkage void cpu_init(void) { current_thread_info()->cpu = hard_smp_processor_id(); diff --git a/arch/sh/kernel/cpu/sh2/probe.c b/arch/sh/kernel/cpu/sh2/probe.c index bab8e75958ae..6c687ae812ef 100644 --- a/arch/sh/kernel/cpu/sh2/probe.c +++ b/arch/sh/kernel/cpu/sh2/probe.c @@ -13,7 +13,7 @@ #include #include -void __cpuinit cpu_probe(void) +void cpu_probe(void) { #if defined(CONFIG_CPU_SUBTYPE_SH7619) boot_cpu_data.type = CPU_SH7619; diff --git a/arch/sh/kernel/cpu/sh2a/probe.c b/arch/sh/kernel/cpu/sh2a/probe.c index 5170b6aa4129..3f87971082f1 100644 --- a/arch/sh/kernel/cpu/sh2a/probe.c +++ b/arch/sh/kernel/cpu/sh2a/probe.c @@ -13,7 +13,7 @@ #include #include -void __cpuinit cpu_probe(void) +void cpu_probe(void) { boot_cpu_data.family = CPU_FAMILY_SH2A; diff --git a/arch/sh/kernel/cpu/sh3/probe.c b/arch/sh/kernel/cpu/sh3/probe.c index bf23c322e164..426e1e1dcedc 100644 --- a/arch/sh/kernel/cpu/sh3/probe.c +++ b/arch/sh/kernel/cpu/sh3/probe.c @@ -16,7 +16,7 @@ #include #include -void __cpuinit cpu_probe(void) +void cpu_probe(void) { unsigned long addr0, addr1, data0, data1, data2, data3; diff --git a/arch/sh/kernel/cpu/sh4/probe.c b/arch/sh/kernel/cpu/sh4/probe.c index 0fbbd50bc8ad..a521bcf50695 100644 --- a/arch/sh/kernel/cpu/sh4/probe.c +++ b/arch/sh/kernel/cpu/sh4/probe.c @@ -15,7 +15,7 @@ #include #include -void __cpuinit cpu_probe(void) +void cpu_probe(void) { unsigned long pvr, prr, cvr; unsigned long size; diff --git a/arch/sh/kernel/cpu/sh4a/smp-shx3.c b/arch/sh/kernel/cpu/sh4a/smp-shx3.c index 03f2b55757cf..4a298808789c 100644 --- a/arch/sh/kernel/cpu/sh4a/smp-shx3.c +++ b/arch/sh/kernel/cpu/sh4a/smp-shx3.c @@ -124,7 +124,7 @@ static void shx3_update_boot_vector(unsigned int cpu) __raw_writel(STBCR_RESET, STBCR_REG(cpu)); } -static int __cpuinit +static int shx3_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu) { unsigned int cpu = (unsigned int)hcpu; @@ -143,11 +143,11 @@ shx3_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu) return NOTIFY_OK; } -static struct notifier_block __cpuinitdata shx3_cpu_notifier = { +static struct notifier_block shx3_cpu_notifier = { .notifier_call = shx3_cpu_callback, }; -static int __cpuinit register_shx3_cpu_notifier(void) +static int register_shx3_cpu_notifier(void) { register_hotcpu_notifier(&shx3_cpu_notifier); return 0; diff --git a/arch/sh/kernel/cpu/sh5/probe.c b/arch/sh/kernel/cpu/sh5/probe.c index 9e882409e4e9..eca427c2f2f3 100644 --- a/arch/sh/kernel/cpu/sh5/probe.c +++ b/arch/sh/kernel/cpu/sh5/probe.c @@ -17,7 +17,7 @@ #include #include -void __cpuinit cpu_probe(void) +void cpu_probe(void) { unsigned long long cir; diff --git a/arch/sh/kernel/perf_event.c b/arch/sh/kernel/perf_event.c index 068b8a2759b5..b9cefebda55c 100644 --- a/arch/sh/kernel/perf_event.c +++ b/arch/sh/kernel/perf_event.c @@ -367,7 +367,7 @@ static void sh_pmu_setup(int cpu) memset(cpuhw, 0, sizeof(struct cpu_hw_events)); } -static int __cpuinit +static int sh_pmu_notifier(struct notifier_block *self, unsigned long action, void *hcpu) { unsigned int cpu = (long)hcpu; @@ -384,7 +384,7 @@ sh_pmu_notifier(struct notifier_block *self, unsigned long action, void *hcpu) return NOTIFY_OK; } -int __cpuinit register_sh_pmu(struct sh_pmu *_pmu) +int register_sh_pmu(struct sh_pmu *_pmu) { if (sh_pmu) return -EBUSY; diff --git a/arch/sh/kernel/process.c b/arch/sh/kernel/process.c index 055d91b70305..53bc6c4c84ec 100644 --- a/arch/sh/kernel/process.c +++ b/arch/sh/kernel/process.c @@ -65,7 +65,7 @@ void arch_task_cache_init(void) # define HAVE_SOFTFP 0 #endif -void __cpuinit init_thread_xstate(void) +void init_thread_xstate(void) { if (boot_cpu_data.flags & CPU_HAS_FPU) xstate_size = sizeof(struct sh_fpu_hard_struct); diff --git a/arch/sh/kernel/setup.c b/arch/sh/kernel/setup.c index ebe7a7d97215..1cf90e947dbf 100644 --- a/arch/sh/kernel/setup.c +++ b/arch/sh/kernel/setup.c @@ -172,7 +172,7 @@ disable: #endif } -void __cpuinit calibrate_delay(void) +void calibrate_delay(void) { struct clk *clk = clk_get(NULL, "cpu_clk"); diff --git a/arch/sh/kernel/smp.c b/arch/sh/kernel/smp.c index 45696451f0ea..86a7936a980b 100644 --- a/arch/sh/kernel/smp.c +++ b/arch/sh/kernel/smp.c @@ -37,7 +37,7 @@ struct plat_smp_ops *mp_ops = NULL; /* State of each CPU */ DEFINE_PER_CPU(int, cpu_state) = { 0 }; -void __cpuinit register_smp_ops(struct plat_smp_ops *ops) +void register_smp_ops(struct plat_smp_ops *ops) { if (mp_ops) printk(KERN_WARNING "Overriding previously set SMP ops\n"); @@ -45,7 +45,7 @@ void __cpuinit register_smp_ops(struct plat_smp_ops *ops) mp_ops = ops; } -static inline void __cpuinit smp_store_cpu_info(unsigned int cpu) +static inline void smp_store_cpu_info(unsigned int cpu) { struct sh_cpuinfo *c = cpu_data + cpu; @@ -174,7 +174,7 @@ void native_play_dead(void) } #endif -asmlinkage void __cpuinit start_secondary(void) +asmlinkage void start_secondary(void) { unsigned int cpu = smp_processor_id(); struct mm_struct *mm = &init_mm; @@ -215,7 +215,7 @@ extern struct { void *thread_info; } stack_start; -int __cpuinit __cpu_up(unsigned int cpu, struct task_struct *tsk) +int __cpu_up(unsigned int cpu, struct task_struct *tsk) { unsigned long timeout; diff --git a/arch/sh/kernel/traps_32.c b/arch/sh/kernel/traps_32.c index 5f513a64dedf..68e99f09171d 100644 --- a/arch/sh/kernel/traps_32.c +++ b/arch/sh/kernel/traps_32.c @@ -741,7 +741,7 @@ asmlinkage void do_exception_error(unsigned long r4, unsigned long r5, die_if_kernel("exception", regs, ex); } -void __cpuinit per_cpu_trap_init(void) +void per_cpu_trap_init(void) { extern void *vbr_base; diff --git a/arch/sh/kernel/traps_64.c b/arch/sh/kernel/traps_64.c index f87d20da1791..112ea11c030d 100644 --- a/arch/sh/kernel/traps_64.c +++ b/arch/sh/kernel/traps_64.c @@ -810,7 +810,7 @@ asmlinkage void do_debug_interrupt(unsigned long code, struct pt_regs *regs) poke_real_address_q(DM_EXP_CAUSE_PHY, 0x0); } -void __cpuinit per_cpu_trap_init(void) +void per_cpu_trap_init(void) { /* Nothing to do for now, VBR initialization later. */ } diff --git a/arch/sh/mm/tlb-sh5.c b/arch/sh/mm/tlb-sh5.c index ff1c40a31cbc..e4bb2a8e0a69 100644 --- a/arch/sh/mm/tlb-sh5.c +++ b/arch/sh/mm/tlb-sh5.c @@ -17,7 +17,7 @@ /** * sh64_tlb_init - Perform initial setup for the DTLB and ITLB. */ -int __cpuinit sh64_tlb_init(void) +int sh64_tlb_init(void) { /* Assign some sane DTLB defaults */ cpu_data->dtlb.entries = 64; From 18f894c145e8515c26da09dd95e06d6b1158775c Mon Sep 17 00:00:00 2001 From: Paul Gortmaker Date: Tue, 18 Jun 2013 17:28:07 -0400 Subject: [PATCH 0910/1048] tile: delete __cpuinit usage from all tile files The __cpuinit type of throwaway sections might have made sense some time ago when RAM was more constrained, but now the savings do not offset the cost and complications. For example, the fix in commit 5e427ec2d0 ("x86: Fix bit corruption at CPU resume time") is a good example of the nasty type of bugs that can be created with improper use of the various __init prefixes. After a discussion on LKML[1] it was decided that cpuinit should go the way of devinit and be phased out. Once all the users are gone, we can then finally remove the macros themselves from linux/init.h. Note that some harmless section mismatch warnings may result, since notify_cpu_starting() and cpu_up() are arch independent (kernel/cpu.c) are flagged as __cpuinit -- so if we remove the __cpuinit from arch specific callers, we will also get section mismatch warnings. As an intermediate step, we intend to turn the linux/init.h cpuinit content into no-ops as early as possible, since that will get rid of these warnings. In any case, they are temporary and harmless. This removes all the arch/tile uses of the __cpuinit macros from all C files. Currently tile does not have any __CPUINIT used in assembly files. [1] https://lkml.org/lkml/2013/5/20/589 Cc: Chris Metcalf Signed-off-by: Paul Gortmaker --- arch/tile/kernel/irq.c | 2 +- arch/tile/kernel/messaging.c | 2 +- arch/tile/kernel/setup.c | 12 ++++++------ arch/tile/kernel/smpboot.c | 8 ++++---- arch/tile/kernel/time.c | 2 +- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/arch/tile/kernel/irq.c b/arch/tile/kernel/irq.c index 02e628065012..3ccf2cd7182e 100644 --- a/arch/tile/kernel/irq.c +++ b/arch/tile/kernel/irq.c @@ -220,7 +220,7 @@ void __init init_IRQ(void) ipi_init(); } -void __cpuinit setup_irq_regs(void) +void setup_irq_regs(void) { /* Enable interrupt delivery. */ unmask_irqs(~0UL); diff --git a/arch/tile/kernel/messaging.c b/arch/tile/kernel/messaging.c index 0858ee6b520f..00331af9525d 100644 --- a/arch/tile/kernel/messaging.c +++ b/arch/tile/kernel/messaging.c @@ -25,7 +25,7 @@ /* All messages are stored here */ static DEFINE_PER_CPU(HV_MsgState, msg_state); -void __cpuinit init_messaging(void) +void init_messaging(void) { /* Allocate storage for messages in kernel space */ HV_MsgState *state = &__get_cpu_var(msg_state); diff --git a/arch/tile/kernel/setup.c b/arch/tile/kernel/setup.c index 68b542677f6a..eceb8344280f 100644 --- a/arch/tile/kernel/setup.c +++ b/arch/tile/kernel/setup.c @@ -58,8 +58,8 @@ struct pglist_data node_data[MAX_NUMNODES] __read_mostly; EXPORT_SYMBOL(node_data); /* Information on the NUMA nodes that we compute early */ -unsigned long __cpuinitdata node_start_pfn[MAX_NUMNODES]; -unsigned long __cpuinitdata node_end_pfn[MAX_NUMNODES]; +unsigned long node_start_pfn[MAX_NUMNODES]; +unsigned long node_end_pfn[MAX_NUMNODES]; unsigned long __initdata node_memmap_pfn[MAX_NUMNODES]; unsigned long __initdata node_percpu_pfn[MAX_NUMNODES]; unsigned long __initdata node_free_pfn[MAX_NUMNODES]; @@ -84,7 +84,7 @@ unsigned long __initdata boot_pc = (unsigned long)start_kernel; #ifdef CONFIG_HIGHMEM /* Page frame index of end of lowmem on each controller. */ -unsigned long __cpuinitdata node_lowmem_end_pfn[MAX_NUMNODES]; +unsigned long node_lowmem_end_pfn[MAX_NUMNODES]; /* Number of pages that can be mapped into lowmem. */ static unsigned long __initdata mappable_physpages; @@ -290,7 +290,7 @@ static void *__init setup_pa_va_mapping(void) * This is up to 4 mappings for lowmem, one mapping per memory * controller, plus one for our text segment. */ -static void __cpuinit store_permanent_mappings(void) +static void store_permanent_mappings(void) { int i; @@ -935,7 +935,7 @@ subsys_initcall(topology_init); * So the values we set up here in the hypervisor may be overridden on * the boot cpu as arguments are parsed. */ -static __cpuinit void init_super_pages(void) +static void init_super_pages(void) { #ifdef CONFIG_HUGETLB_SUPER_PAGES int i; @@ -950,7 +950,7 @@ static __cpuinit void init_super_pages(void) * * Called from setup_arch() on the boot cpu, or online_secondary(). */ -void __cpuinit setup_cpu(int boot) +void setup_cpu(int boot) { /* The boot cpu sets up its permanent mappings much earlier. */ if (!boot) diff --git a/arch/tile/kernel/smpboot.c b/arch/tile/kernel/smpboot.c index 44bab29bf2f3..a535655b7089 100644 --- a/arch/tile/kernel/smpboot.c +++ b/arch/tile/kernel/smpboot.c @@ -133,14 +133,14 @@ static __init int reset_init_affinity(void) } late_initcall(reset_init_affinity); -static struct cpumask cpu_started __cpuinitdata; +static struct cpumask cpu_started; /* * Activate a secondary processor. Very minimal; don't add anything * to this path without knowing what you're doing, since SMP booting * is pretty fragile. */ -static void __cpuinit start_secondary(void) +static void start_secondary(void) { int cpuid = smp_processor_id(); @@ -183,7 +183,7 @@ static void __cpuinit start_secondary(void) /* * Bring a secondary processor online. */ -void __cpuinit online_secondary(void) +void online_secondary(void) { /* * low-memory mappings have been cleared, flush them from @@ -210,7 +210,7 @@ void __cpuinit online_secondary(void) cpu_startup_entry(CPUHP_ONLINE); } -int __cpuinit __cpu_up(unsigned int cpu, struct task_struct *tidle) +int __cpu_up(unsigned int cpu, struct task_struct *tidle) { /* Wait 5s total for all CPUs for them to come online */ static int timeout; diff --git a/arch/tile/kernel/time.c b/arch/tile/kernel/time.c index 5ac397ec6986..7c353d8c2da9 100644 --- a/arch/tile/kernel/time.c +++ b/arch/tile/kernel/time.c @@ -159,7 +159,7 @@ static DEFINE_PER_CPU(struct clock_event_device, tile_timer) = { .set_mode = tile_timer_set_mode, }; -void __cpuinit setup_tile_timer(void) +void setup_tile_timer(void) { struct clock_event_device *evt = &__get_cpu_var(tile_timer); From 54be16e7b2c96793bee4bf472409e9d31bc77c78 Mon Sep 17 00:00:00 2001 From: Paul Gortmaker Date: Tue, 18 Jun 2013 17:40:47 -0400 Subject: [PATCH 0911/1048] metag: delete __cpuinit usage from all metag files The __cpuinit type of throwaway sections might have made sense some time ago when RAM was more constrained, but now the savings do not offset the cost and complications. For example, the fix in commit 5e427ec2d0 ("x86: Fix bit corruption at CPU resume time") is a good example of the nasty type of bugs that can be created with improper use of the various __init prefixes. After a discussion on LKML[1] it was decided that cpuinit should go the way of devinit and be phased out. Once all the users are gone, we can then finally remove the macros themselves from linux/init.h. Note that some harmless section mismatch warnings may result, since notify_cpu_starting() and cpu_up() are arch independent (kernel/cpu.c) are flagged as __cpuinit -- so if we remove the __cpuinit from arch specific callers, we will also get section mismatch warnings. As an intermediate step, we intend to turn the linux/init.h cpuinit content into no-ops as early as possible, since that will get rid of these warnings. In any case, they are temporary and harmless. This removes all the arch/metag uses of the __cpuinit macros from all C files. Currently metag does not have any __CPUINIT used in assembly files. [1] https://lkml.org/lkml/2013/5/20/589 Cc: James Hogan Acked-by: James Hogan Signed-off-by: Paul Gortmaker --- arch/metag/kernel/perf/perf_event.c | 6 +++--- arch/metag/kernel/smp.c | 22 ++++++++++------------ arch/metag/kernel/traps.c | 2 +- 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/arch/metag/kernel/perf/perf_event.c b/arch/metag/kernel/perf/perf_event.c index 5b18888ee364..5cc4d4dcf3cf 100644 --- a/arch/metag/kernel/perf/perf_event.c +++ b/arch/metag/kernel/perf/perf_event.c @@ -813,8 +813,8 @@ static struct metag_pmu _metag_pmu = { }; /* PMU CPU hotplug notifier */ -static int __cpuinit metag_pmu_cpu_notify(struct notifier_block *b, - unsigned long action, void *hcpu) +static int metag_pmu_cpu_notify(struct notifier_block *b, unsigned long action, + void *hcpu) { unsigned int cpu = (unsigned int)hcpu; struct cpu_hw_events *cpuc = &per_cpu(cpu_hw_events, cpu); @@ -828,7 +828,7 @@ static int __cpuinit metag_pmu_cpu_notify(struct notifier_block *b, return NOTIFY_OK; } -static struct notifier_block __cpuinitdata metag_pmu_notifier = { +static struct notifier_block metag_pmu_notifier = { .notifier_call = metag_pmu_cpu_notify, }; diff --git a/arch/metag/kernel/smp.c b/arch/metag/kernel/smp.c index e413875cf6d2..7c0113142981 100644 --- a/arch/metag/kernel/smp.c +++ b/arch/metag/kernel/smp.c @@ -68,7 +68,7 @@ static DECLARE_COMPLETION(cpu_running); /* * "thread" is assumed to be a valid Meta hardware thread ID. */ -int __cpuinit boot_secondary(unsigned int thread, struct task_struct *idle) +int boot_secondary(unsigned int thread, struct task_struct *idle) { u32 val; @@ -118,11 +118,9 @@ int __cpuinit boot_secondary(unsigned int thread, struct task_struct *idle) * If the cache partition has changed, prints a message to the log describing * those changes. */ -static __cpuinit void describe_cachepart_change(unsigned int thread, - const char *label, - unsigned int sz, - unsigned int old, - unsigned int new) +static void describe_cachepart_change(unsigned int thread, const char *label, + unsigned int sz, unsigned int old, + unsigned int new) { unsigned int lor1, land1, gor1, gand1; unsigned int lor2, land2, gor2, gand2; @@ -170,7 +168,7 @@ static __cpuinit void describe_cachepart_change(unsigned int thread, * Ensures that coherency is enabled and that the threads share the same cache * partitions. */ -static __cpuinit void setup_smp_cache(unsigned int thread) +static void setup_smp_cache(unsigned int thread) { unsigned int this_thread, lflags; unsigned int dcsz, dcpart_this, dcpart_old, dcpart_new; @@ -215,7 +213,7 @@ static __cpuinit void setup_smp_cache(unsigned int thread) icpart_old, icpart_new); } -int __cpuinit __cpu_up(unsigned int cpu, struct task_struct *idle) +int __cpu_up(unsigned int cpu, struct task_struct *idle) { unsigned int thread = cpu_2_hwthread_id[cpu]; int ret; @@ -268,7 +266,7 @@ static DECLARE_COMPLETION(cpu_killed); /* * __cpu_disable runs on the processor to be shutdown. */ -int __cpuexit __cpu_disable(void) +int __cpu_disable(void) { unsigned int cpu = smp_processor_id(); @@ -299,7 +297,7 @@ int __cpuexit __cpu_disable(void) * called on the thread which is asking for a CPU to be shutdown - * waits until shutdown has completed, or it is timed out. */ -void __cpuexit __cpu_die(unsigned int cpu) +void __cpu_die(unsigned int cpu) { if (!wait_for_completion_timeout(&cpu_killed, msecs_to_jiffies(1))) pr_err("CPU%u: unable to kill\n", cpu); @@ -311,7 +309,7 @@ void __cpuexit __cpu_die(unsigned int cpu) * Note that we do not return from this function. If this cpu is * brought online again it will need to run secondary_startup(). */ -void __cpuexit cpu_die(void) +void cpu_die(void) { local_irq_disable(); idle_task_exit(); @@ -326,7 +324,7 @@ void __cpuexit cpu_die(void) * Called by both boot and secondaries to move global data into * per-processor storage. */ -void __cpuinit smp_store_cpu_info(unsigned int cpuid) +void smp_store_cpu_info(unsigned int cpuid) { struct cpuinfo_metag *cpu_info = &per_cpu(cpu_data, cpuid); diff --git a/arch/metag/kernel/traps.c b/arch/metag/kernel/traps.c index c00ade0228ef..25f9d1c2ffec 100644 --- a/arch/metag/kernel/traps.c +++ b/arch/metag/kernel/traps.c @@ -812,7 +812,7 @@ static void set_trigger_mask(unsigned int mask) } #endif -void __cpuinit per_cpu_trap_init(unsigned long cpu) +void per_cpu_trap_init(unsigned long cpu) { TBIRES int_context; unsigned int thread = cpu_2_hwthread_id[cpu]; From 2de6c0bd689bdb5d6d8e4d20c5032a7f397487a8 Mon Sep 17 00:00:00 2001 From: Paul Gortmaker Date: Tue, 18 Jun 2013 17:54:48 -0400 Subject: [PATCH 0912/1048] cris: delete __cpuinit usage from all cris files The __cpuinit type of throwaway sections might have made sense some time ago when RAM was more constrained, but now the savings do not offset the cost and complications. For example, the fix in commit 5e427ec2d0 ("x86: Fix bit corruption at CPU resume time") is a good example of the nasty type of bugs that can be created with improper use of the various __init prefixes. After a discussion on LKML[1] it was decided that cpuinit should go the way of devinit and be phased out. Once all the users are gone, we can then finally remove the macros themselves from linux/init.h. Note that some harmless section mismatch warnings may result, since notify_cpu_starting() and cpu_up() are arch independent (kernel/cpu.c) are flagged as __cpuinit -- so if we remove the __cpuinit from arch specific callers, we will also get section mismatch warnings. As an intermediate step, we intend to turn the linux/init.h cpuinit content into no-ops as early as possible, since that will get rid of these warnings. In any case, they are temporary and harmless. This removes all the arch/cris uses of the __cpuinit macros from all C files. Currently cris does not have any __CPUINIT used in assembly files. [1] https://lkml.org/lkml/2013/5/20/589 Cc: Mikael Starvik Cc: Jesper Nilsson Cc: linux-cris-kernel@axis.com Acked-by: Jesper Nilsson Signed-off-by: Paul Gortmaker --- arch/cris/arch-v32/kernel/smp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/cris/arch-v32/kernel/smp.c b/arch/cris/arch-v32/kernel/smp.c index cdd12028de0c..fe8e6039db2a 100644 --- a/arch/cris/arch-v32/kernel/smp.c +++ b/arch/cris/arch-v32/kernel/smp.c @@ -197,7 +197,7 @@ int setup_profiling_timer(unsigned int multiplier) */ unsigned long cache_decay_ticks = 1; -int __cpuinit __cpu_up(unsigned int cpu, struct task_struct *tidle) +int __cpu_up(unsigned int cpu, struct task_struct *tidle) { smp_boot_one_cpu(cpu, tidle); return cpu_online(cpu) ? 0 : -ENOSYS; From ec460ae52ef51eb329e08deda6beb97b1cc37d99 Mon Sep 17 00:00:00 2001 From: Paul Gortmaker Date: Tue, 18 Jun 2013 17:54:48 -0400 Subject: [PATCH 0913/1048] frv: delete __cpuinit usage from all frv files The __cpuinit type of throwaway sections might have made sense some time ago when RAM was more constrained, but now the savings do not offset the cost and complications. For example, the fix in commit 5e427ec2d0 ("x86: Fix bit corruption at CPU resume time") is a good example of the nasty type of bugs that can be created with improper use of the various __init prefixes. After a discussion on LKML[1] it was decided that cpuinit should go the way of devinit and be phased out. Once all the users are gone, we can then finally remove the macros themselves from linux/init.h. Note that some harmless section mismatch warnings may result, since notify_cpu_starting() and cpu_up() are arch independent (kernel/cpu.c) are flagged as __cpuinit -- so if we remove the __cpuinit from arch specific callers, we will also get section mismatch warnings. As an intermediate step, we intend to turn the linux/init.h cpuinit content into no-ops as early as possible, since that will get rid of these warnings. In any case, they are temporary and harmless. This removes all the arch/frv uses of the __cpuinit macros from all C files. Currently frv does not have any __CPUINIT used in assembly files. [1] https://lkml.org/lkml/2013/5/20/589 Cc: David Howells Signed-off-by: Paul Gortmaker --- arch/frv/kernel/setup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/frv/kernel/setup.c b/arch/frv/kernel/setup.c index ae3a6706419b..9f3a7a62d787 100644 --- a/arch/frv/kernel/setup.c +++ b/arch/frv/kernel/setup.c @@ -709,7 +709,7 @@ static void __init reserve_dma_coherent(void) /* * calibrate the delay loop */ -void __cpuinit calibrate_delay(void) +void calibrate_delay(void) { loops_per_jiffy = __delay_loops_MHz * (1000000 / HZ); From 7ddc839977cf4aa2c643a2f0405aa79daa72dc07 Mon Sep 17 00:00:00 2001 From: Paul Gortmaker Date: Tue, 18 Jun 2013 17:54:48 -0400 Subject: [PATCH 0914/1048] hexagon: delete __cpuinit usage from all hexagon files The __cpuinit type of throwaway sections might have made sense some time ago when RAM was more constrained, but now the savings do not offset the cost and complications. For example, the fix in commit 5e427ec2d0 ("x86: Fix bit corruption at CPU resume time") is a good example of the nasty type of bugs that can be created with improper use of the various __init prefixes. After a discussion on LKML[1] it was decided that cpuinit should go the way of devinit and be phased out. Once all the users are gone, we can then finally remove the macros themselves from linux/init.h. Note that some harmless section mismatch warnings may result, since notify_cpu_starting() and cpu_up() are arch independent (kernel/cpu.c) are flagged as __cpuinit -- so if we remove the __cpuinit from arch specific callers, we will also get section mismatch warnings. As an intermediate step, we intend to turn the linux/init.h cpuinit content into no-ops as early as possible, since that will get rid of these warnings. In any case, they are temporary and harmless. This removes all the arch/hexagon uses of the __cpuinit macros from all C files. Currently hexagon does not have any __CPUINIT used in assembly files. [1] https://lkml.org/lkml/2013/5/20/589 Cc: Richard Kuo Acked-by: Richard Kuo Cc: linux-hexagon@vger.kernel.org Signed-off-by: Paul Gortmaker --- arch/hexagon/kernel/setup.c | 2 +- arch/hexagon/kernel/smp.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/hexagon/kernel/setup.c b/arch/hexagon/kernel/setup.c index bfe13311d70d..29d1f1b00016 100644 --- a/arch/hexagon/kernel/setup.c +++ b/arch/hexagon/kernel/setup.c @@ -41,7 +41,7 @@ static char default_command_line[COMMAND_LINE_SIZE] __initdata = CONFIG_CMDLINE; int on_simulator; -void __cpuinit calibrate_delay(void) +void calibrate_delay(void) { loops_per_jiffy = thread_freq_mhz * 1000000 / HZ; } diff --git a/arch/hexagon/kernel/smp.c b/arch/hexagon/kernel/smp.c index 0e364ca43198..9faaa940452b 100644 --- a/arch/hexagon/kernel/smp.c +++ b/arch/hexagon/kernel/smp.c @@ -146,7 +146,7 @@ void __init smp_prepare_boot_cpu(void) * to point to current thread info */ -void __cpuinit start_secondary(void) +void start_secondary(void) { unsigned int cpu; unsigned long thread_ptr; @@ -194,7 +194,7 @@ void __cpuinit start_secondary(void) * maintains control until "cpu_online(cpu)" is set. */ -int __cpuinit __cpu_up(unsigned int cpu, struct task_struct *idle) +int __cpu_up(unsigned int cpu, struct task_struct *idle) { struct thread_info *thread = (struct thread_info *)idle->stack; void *stack_start; From d1407fde791285d1ffd4c7af6b666987d1213f6a Mon Sep 17 00:00:00 2001 From: Paul Gortmaker Date: Tue, 18 Jun 2013 17:54:49 -0400 Subject: [PATCH 0915/1048] m32r: delete __cpuinit usage from all m32r files The __cpuinit type of throwaway sections might have made sense some time ago when RAM was more constrained, but now the savings do not offset the cost and complications. For example, the fix in commit 5e427ec2d0 ("x86: Fix bit corruption at CPU resume time") is a good example of the nasty type of bugs that can be created with improper use of the various __init prefixes. After a discussion on LKML[1] it was decided that cpuinit should go the way of devinit and be phased out. Once all the users are gone, we can then finally remove the macros themselves from linux/init.h. Note that some harmless section mismatch warnings may result, since notify_cpu_starting() and cpu_up() are arch independent (kernel/cpu.c) are flagged as __cpuinit -- so if we remove the __cpuinit from arch specific callers, we will also get section mismatch warnings. As an intermediate step, we intend to turn the linux/init.h cpuinit content into no-ops as early as possible, since that will get rid of these warnings. In any case, they are temporary and harmless. This removes all the arch/m32r uses of the __cpuinit macros from all C files. Currently m32r does not have any __CPUINIT used in assembly files. [1] https://lkml.org/lkml/2013/5/20/589 Cc: Hirokazu Takata Cc: linux-m32r@ml.linux-m32r.org Cc: linux-m32r-ja@ml.linux-m32r.org Signed-off-by: Paul Gortmaker --- arch/m32r/kernel/smpboot.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/m32r/kernel/smpboot.c b/arch/m32r/kernel/smpboot.c index 0ac558adc605..bb21f4f63170 100644 --- a/arch/m32r/kernel/smpboot.c +++ b/arch/m32r/kernel/smpboot.c @@ -343,7 +343,7 @@ static void __init do_boot_cpu(int phys_id) } } -int __cpuinit __cpu_up(unsigned int cpu_id, struct task_struct *tidle) +int __cpu_up(unsigned int cpu_id, struct task_struct *tidle) { int timeout; From 8e8550ef01676829f4d4b175a1ce4fee30f7a778 Mon Sep 17 00:00:00 2001 From: Paul Gortmaker Date: Tue, 18 Jun 2013 17:54:49 -0400 Subject: [PATCH 0916/1048] openrisc: delete __cpuinit usage from all openrisc files The __cpuinit type of throwaway sections might have made sense some time ago when RAM was more constrained, but now the savings do not offset the cost and complications. For example, the fix in commit 5e427ec2d0 ("x86: Fix bit corruption at CPU resume time") is a good example of the nasty type of bugs that can be created with improper use of the various __init prefixes. After a discussion on LKML[1] it was decided that cpuinit should go the way of devinit and be phased out. Once all the users are gone, we can then finally remove the macros themselves from linux/init.h. Note that some harmless section mismatch warnings may result, since notify_cpu_starting() and cpu_up() are arch independent (kernel/cpu.c) are flagged as __cpuinit -- so if we remove the __cpuinit from arch specific callers, we will also get section mismatch warnings. As an intermediate step, we intend to turn the linux/init.h cpuinit content into no-ops as early as possible, since that will get rid of these warnings. In any case, they are temporary and harmless. This removes all the arch/openrisc uses of the __cpuinit macros from all C files. Currently openrisc does not have any __CPUINIT used in assembly files. [1] https://lkml.org/lkml/2013/5/20/589 Cc: Jonas Bonn Cc: linux@lists.openrisc.net Signed-off-by: Paul Gortmaker --- arch/openrisc/kernel/setup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/openrisc/kernel/setup.c b/arch/openrisc/kernel/setup.c index f4d5bedc3b4f..d7359ffbcbdd 100644 --- a/arch/openrisc/kernel/setup.c +++ b/arch/openrisc/kernel/setup.c @@ -267,7 +267,7 @@ void __init detect_unit_config(unsigned long upr, unsigned long mask, * */ -void __cpuinit calibrate_delay(void) +void calibrate_delay(void) { const int *val; struct device_node *cpu = NULL; From 6cb4c159b0b8825ea8ea8ae4d6e72c9970af3993 Mon Sep 17 00:00:00 2001 From: Paul Gortmaker Date: Tue, 18 Jun 2013 17:54:49 -0400 Subject: [PATCH 0917/1048] xtensa: delete __cpuinit usage from all xtensa files The __cpuinit type of throwaway sections might have made sense some time ago when RAM was more constrained, but now the savings do not offset the cost and complications. For example, the fix in commit 5e427ec2d0 ("x86: Fix bit corruption at CPU resume time") is a good example of the nasty type of bugs that can be created with improper use of the various __init prefixes. After a discussion on LKML[1] it was decided that cpuinit should go the way of devinit and be phased out. Once all the users are gone, we can then finally remove the macros themselves from linux/init.h. Note that some harmless section mismatch warnings may result, since notify_cpu_starting() and cpu_up() are arch independent (kernel/cpu.c) are flagged as __cpuinit -- so if we remove the __cpuinit from arch specific callers, we will also get section mismatch warnings. As an intermediate step, we intend to turn the linux/init.h cpuinit content into no-ops as early as possible, since that will get rid of these warnings. In any case, they are temporary and harmless. This removes all the arch/xtensa uses of the __cpuinit macros from all C files. Currently xtensa does not have any __CPUINIT used in assembly files. [1] https://lkml.org/lkml/2013/5/20/589 Cc: Chris Zankel Cc: Max Filippov Cc: linux-xtensa@linux-xtensa.org Signed-off-by: Paul Gortmaker --- arch/xtensa/kernel/time.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/xtensa/kernel/time.c b/arch/xtensa/kernel/time.c index bdbb17312526..24bb0c1776ba 100644 --- a/arch/xtensa/kernel/time.c +++ b/arch/xtensa/kernel/time.c @@ -162,7 +162,7 @@ irqreturn_t timer_interrupt (int irq, void *dev_id) } #ifndef CONFIG_GENERIC_CALIBRATE_DELAY -void __cpuinit calibrate_delay(void) +void calibrate_delay(void) { loops_per_jiffy = CCOUNT_PER_JIFFY; printk("Calibrating delay loop (skipped)... " From 70e2a7bf23a0c412b908ba260e790a4f51c9f2b0 Mon Sep 17 00:00:00 2001 From: Paul Gortmaker Date: Tue, 18 Jun 2013 18:09:02 -0400 Subject: [PATCH 0918/1048] score: delete __cpuinit usage from all score files The __cpuinit type of throwaway sections might have made sense some time ago when RAM was more constrained, but now the savings do not offset the cost and complications. For example, the fix in commit 5e427ec2d0 ("x86: Fix bit corruption at CPU resume time") is a good example of the nasty type of bugs that can be created with improper use of the various __init prefixes. After a discussion on LKML[1] it was decided that cpuinit should go the way of devinit and be phased out. Once all the users are gone, we can then finally remove the macros themselves from linux/init.h. Note that some harmless section mismatch warnings may result, since notify_cpu_starting() and cpu_up() are arch independent (kernel/cpu.c) are flagged as __cpuinit -- so if we remove the __cpuinit from arch specific callers, we will also get section mismatch warnings. As an intermediate step, we intend to turn the linux/init.h cpuinit content into no-ops as early as possible, since that will get rid of these warnings. In any case, they are temporary and harmless. This removes all the arch/score uses of the __cpuinit macros from all C files. Currently score does not have any __CPUINIT used in assembly files. [1] https://lkml.org/lkml/2013/5/20/589 Cc: Chen Liqin Cc: Lennox Wu Signed-off-by: Paul Gortmaker --- arch/score/mm/tlb-score.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/score/mm/tlb-score.c b/arch/score/mm/tlb-score.c index 6fdb100244c8..004073717de0 100644 --- a/arch/score/mm/tlb-score.c +++ b/arch/score/mm/tlb-score.c @@ -240,7 +240,7 @@ void __update_tlb(struct vm_area_struct *vma, unsigned long address, pte_t pte) local_irq_restore(flags); } -void __cpuinit tlb_init(void) +void tlb_init(void) { tlblock_set(0); local_flush_tlb_all(); From 148f9bb87745ed45f7a11b2cbd3bc0f017d5d257 Mon Sep 17 00:00:00 2001 From: Paul Gortmaker Date: Tue, 18 Jun 2013 18:23:59 -0400 Subject: [PATCH 0919/1048] x86: delete __cpuinit usage from all x86 files The __cpuinit type of throwaway sections might have made sense some time ago when RAM was more constrained, but now the savings do not offset the cost and complications. For example, the fix in commit 5e427ec2d0 ("x86: Fix bit corruption at CPU resume time") is a good example of the nasty type of bugs that can be created with improper use of the various __init prefixes. After a discussion on LKML[1] it was decided that cpuinit should go the way of devinit and be phased out. Once all the users are gone, we can then finally remove the macros themselves from linux/init.h. Note that some harmless section mismatch warnings may result, since notify_cpu_starting() and cpu_up() are arch independent (kernel/cpu.c) are flagged as __cpuinit -- so if we remove the __cpuinit from arch specific callers, we will also get section mismatch warnings. As an intermediate step, we intend to turn the linux/init.h cpuinit content into no-ops as early as possible, since that will get rid of these warnings. In any case, they are temporary and harmless. This removes all the arch/x86 uses of the __cpuinit macros from all C files. x86 only had the one __CPUINIT used in assembly files, and it wasn't paired off with a .previous or a __FINIT, so we can delete it directly w/o any corresponding additional change there. [1] https://lkml.org/lkml/2013/5/20/589 Cc: Thomas Gleixner Cc: Ingo Molnar Cc: "H. Peter Anvin" Cc: x86@kernel.org Acked-by: Ingo Molnar Acked-by: Thomas Gleixner Acked-by: H. Peter Anvin Signed-off-by: Paul Gortmaker --- arch/x86/include/asm/cpu.h | 2 +- arch/x86/include/asm/microcode.h | 4 +- arch/x86/include/asm/microcode_amd.h | 4 +- arch/x86/include/asm/microcode_intel.h | 4 +- arch/x86/include/asm/mmconfig.h | 4 +- arch/x86/include/asm/mpspec.h | 2 +- arch/x86/include/asm/numa.h | 6 +- arch/x86/include/asm/processor.h | 2 +- arch/x86/include/asm/prom.h | 2 +- arch/x86/include/asm/smp.h | 2 +- arch/x86/kernel/acpi/boot.c | 6 +- arch/x86/kernel/apic/apic.c | 30 ++++----- arch/x86/kernel/apic/apic_numachip.c | 2 +- arch/x86/kernel/apic/es7000_32.c | 2 +- arch/x86/kernel/apic/numaq_32.c | 2 +- arch/x86/kernel/apic/x2apic_cluster.c | 2 +- arch/x86/kernel/apic/x2apic_uv_x.c | 14 ++-- arch/x86/kernel/cpu/amd.c | 33 +++++----- arch/x86/kernel/cpu/centaur.c | 26 ++++---- arch/x86/kernel/cpu/common.c | 64 +++++++++---------- arch/x86/kernel/cpu/cyrix.c | 40 ++++++------ arch/x86/kernel/cpu/hypervisor.c | 2 +- arch/x86/kernel/cpu/intel.c | 30 ++++----- arch/x86/kernel/cpu/intel_cacheinfo.c | 55 ++++++++-------- arch/x86/kernel/cpu/mcheck/mce.c | 23 ++++--- arch/x86/kernel/cpu/mcheck/mce_amd.c | 14 ++-- arch/x86/kernel/cpu/mcheck/therm_throt.c | 9 ++- arch/x86/kernel/cpu/perf_event.c | 2 +- arch/x86/kernel/cpu/perf_event_amd_ibs.c | 2 +- arch/x86/kernel/cpu/perf_event_amd_uncore.c | 31 +++++---- arch/x86/kernel/cpu/perf_event_intel_uncore.c | 20 +++--- arch/x86/kernel/cpu/rdrand.c | 2 +- arch/x86/kernel/cpu/scattered.c | 4 +- arch/x86/kernel/cpu/topology.c | 2 +- arch/x86/kernel/cpu/transmeta.c | 6 +- arch/x86/kernel/cpu/umc.c | 2 +- arch/x86/kernel/cpu/vmware.c | 2 +- arch/x86/kernel/cpuid.c | 7 +- arch/x86/kernel/devicetree.c | 2 +- arch/x86/kernel/head_32.S | 1 - arch/x86/kernel/i387.c | 10 +-- arch/x86/kernel/irq_32.c | 2 +- arch/x86/kernel/kvm.c | 10 +-- arch/x86/kernel/kvmclock.c | 2 +- arch/x86/kernel/microcode_amd_early.c | 8 +-- arch/x86/kernel/microcode_core.c | 2 +- arch/x86/kernel/microcode_core_early.c | 6 +- arch/x86/kernel/microcode_intel_early.c | 26 ++++---- arch/x86/kernel/mmconf-fam10h_64.c | 12 ++-- arch/x86/kernel/msr.c | 6 +- arch/x86/kernel/process.c | 2 +- arch/x86/kernel/setup.c | 2 +- arch/x86/kernel/smpboot.c | 28 ++++---- arch/x86/kernel/tboot.c | 6 +- arch/x86/kernel/tsc.c | 4 +- arch/x86/kernel/tsc_sync.c | 18 +++--- arch/x86/kernel/vsyscall_64.c | 6 +- arch/x86/kernel/x86_init.c | 4 +- arch/x86/kernel/xsave.c | 4 +- arch/x86/mm/mmio-mod.c | 4 +- arch/x86/mm/numa.c | 12 ++-- arch/x86/mm/numa_emulation.c | 12 ++-- arch/x86/mm/setup_nx.c | 4 +- arch/x86/pci/amd_bus.c | 8 +-- arch/x86/platform/ce4100/ce4100.c | 2 +- arch/x86/platform/mrst/mrst.c | 4 +- arch/x86/xen/enlighten.c | 6 +- arch/x86/xen/setup.c | 6 +- arch/x86/xen/smp.c | 12 ++-- arch/x86/xen/spinlock.c | 2 +- arch/x86/xen/xen-ops.h | 2 +- 71 files changed, 345 insertions(+), 356 deletions(-) diff --git a/arch/x86/include/asm/cpu.h b/arch/x86/include/asm/cpu.h index 5f9a1243190e..d2b12988d2ed 100644 --- a/arch/x86/include/asm/cpu.h +++ b/arch/x86/include/asm/cpu.h @@ -28,7 +28,7 @@ struct x86_cpu { #ifdef CONFIG_HOTPLUG_CPU extern int arch_register_cpu(int num); extern void arch_unregister_cpu(int); -extern void __cpuinit start_cpu0(void); +extern void start_cpu0(void); #ifdef CONFIG_DEBUG_HOTPLUG_CPU0 extern int _debug_hotplug_cpu(int cpu, int action); #endif diff --git a/arch/x86/include/asm/microcode.h b/arch/x86/include/asm/microcode.h index 6bc3985ee473..f98bd6625318 100644 --- a/arch/x86/include/asm/microcode.h +++ b/arch/x86/include/asm/microcode.h @@ -60,11 +60,11 @@ static inline void __exit exit_amd_microcode(void) {} #ifdef CONFIG_MICROCODE_EARLY #define MAX_UCODE_COUNT 128 extern void __init load_ucode_bsp(void); -extern void __cpuinit load_ucode_ap(void); +extern void load_ucode_ap(void); extern int __init save_microcode_in_initrd(void); #else static inline void __init load_ucode_bsp(void) {} -static inline void __cpuinit load_ucode_ap(void) {} +static inline void load_ucode_ap(void) {} static inline int __init save_microcode_in_initrd(void) { return 0; diff --git a/arch/x86/include/asm/microcode_amd.h b/arch/x86/include/asm/microcode_amd.h index c6b043f40271..50e5c58ced23 100644 --- a/arch/x86/include/asm/microcode_amd.h +++ b/arch/x86/include/asm/microcode_amd.h @@ -67,11 +67,11 @@ extern enum ucode_state load_microcode_amd(int cpu, const u8 *data, size_t size) extern u8 amd_bsp_mpb[MPB_MAX_SIZE]; #endif extern void __init load_ucode_amd_bsp(void); -extern void __cpuinit load_ucode_amd_ap(void); +extern void load_ucode_amd_ap(void); extern int __init save_microcode_in_initrd_amd(void); #else static inline void __init load_ucode_amd_bsp(void) {} -static inline void __cpuinit load_ucode_amd_ap(void) {} +static inline void load_ucode_amd_ap(void) {} static inline int __init save_microcode_in_initrd_amd(void) { return -EINVAL; } #endif diff --git a/arch/x86/include/asm/microcode_intel.h b/arch/x86/include/asm/microcode_intel.h index 87a085333cbf..9067166409bf 100644 --- a/arch/x86/include/asm/microcode_intel.h +++ b/arch/x86/include/asm/microcode_intel.h @@ -65,12 +65,12 @@ update_match_revision(struct microcode_header_intel *mc_header, int rev); #ifdef CONFIG_MICROCODE_INTEL_EARLY extern void __init load_ucode_intel_bsp(void); -extern void __cpuinit load_ucode_intel_ap(void); +extern void load_ucode_intel_ap(void); extern void show_ucode_info_early(void); extern int __init save_microcode_in_initrd_intel(void); #else static inline __init void load_ucode_intel_bsp(void) {} -static inline __cpuinit void load_ucode_intel_ap(void) {} +static inline void load_ucode_intel_ap(void) {} static inline void show_ucode_info_early(void) {} static inline int __init save_microcode_in_initrd_intel(void) { return -EINVAL; } #endif diff --git a/arch/x86/include/asm/mmconfig.h b/arch/x86/include/asm/mmconfig.h index 9b119da1d105..04a3fed22cfe 100644 --- a/arch/x86/include/asm/mmconfig.h +++ b/arch/x86/include/asm/mmconfig.h @@ -2,8 +2,8 @@ #define _ASM_X86_MMCONFIG_H #ifdef CONFIG_PCI_MMCONFIG -extern void __cpuinit fam10h_check_enable_mmcfg(void); -extern void __cpuinit check_enable_amd_mmconf_dmi(void); +extern void fam10h_check_enable_mmcfg(void); +extern void check_enable_amd_mmconf_dmi(void); #else static inline void fam10h_check_enable_mmcfg(void) { } static inline void check_enable_amd_mmconf_dmi(void) { } diff --git a/arch/x86/include/asm/mpspec.h b/arch/x86/include/asm/mpspec.h index 3e2f42a4b872..626cf70082d7 100644 --- a/arch/x86/include/asm/mpspec.h +++ b/arch/x86/include/asm/mpspec.h @@ -94,7 +94,7 @@ static inline void early_reserve_e820_mpc_new(void) { } #define default_get_smp_config x86_init_uint_noop #endif -void __cpuinit generic_processor_info(int apicid, int version); +void generic_processor_info(int apicid, int version); #ifdef CONFIG_ACPI extern void mp_register_ioapic(int id, u32 address, u32 gsi_base); extern void mp_override_legacy_irq(u8 bus_irq, u8 polarity, u8 trigger, diff --git a/arch/x86/include/asm/numa.h b/arch/x86/include/asm/numa.h index 1b99ee5c9f00..4064acae625d 100644 --- a/arch/x86/include/asm/numa.h +++ b/arch/x86/include/asm/numa.h @@ -39,7 +39,7 @@ static inline void set_apicid_to_node(int apicid, s16 node) __apicid_to_node[apicid] = node; } -extern int __cpuinit numa_cpu_node(int cpu); +extern int numa_cpu_node(int cpu); #else /* CONFIG_NUMA */ static inline void set_apicid_to_node(int apicid, s16 node) @@ -60,8 +60,8 @@ static inline int numa_cpu_node(int cpu) extern void numa_set_node(int cpu, int node); extern void numa_clear_node(int cpu); extern void __init init_cpu_to_node(void); -extern void __cpuinit numa_add_cpu(int cpu); -extern void __cpuinit numa_remove_cpu(int cpu); +extern void numa_add_cpu(int cpu); +extern void numa_remove_cpu(int cpu); #else /* CONFIG_NUMA */ static inline void numa_set_node(int cpu, int node) { } static inline void numa_clear_node(int cpu) { } diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h index 29937c4f6ff8..24cf5aefb704 100644 --- a/arch/x86/include/asm/processor.h +++ b/arch/x86/include/asm/processor.h @@ -164,7 +164,7 @@ extern const struct seq_operations cpuinfo_op; #define cache_line_size() (boot_cpu_data.x86_cache_alignment) extern void cpu_detect(struct cpuinfo_x86 *c); -extern void __cpuinit fpu_detect(struct cpuinfo_x86 *c); +extern void fpu_detect(struct cpuinfo_x86 *c); extern void early_cpu_init(void); extern void identify_boot_cpu(void); diff --git a/arch/x86/include/asm/prom.h b/arch/x86/include/asm/prom.h index 60bef663609a..bade6ac3b14f 100644 --- a/arch/x86/include/asm/prom.h +++ b/arch/x86/include/asm/prom.h @@ -27,7 +27,7 @@ extern int of_ioapic; extern u64 initial_dtb; extern void add_dtb(u64 data); extern void x86_add_irq_domains(void); -void __cpuinit x86_of_pci_init(void); +void x86_of_pci_init(void); void x86_dtb_init(void); #else static inline void add_dtb(u64 data) { } diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h index b073aaea747c..4137890e88e3 100644 --- a/arch/x86/include/asm/smp.h +++ b/arch/x86/include/asm/smp.h @@ -179,7 +179,7 @@ static inline int wbinvd_on_all_cpus(void) } #endif /* CONFIG_SMP */ -extern unsigned disabled_cpus __cpuinitdata; +extern unsigned disabled_cpus; #ifdef CONFIG_X86_32_SMP /* diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c index d81a972dd506..2627a81253ee 100644 --- a/arch/x86/kernel/acpi/boot.c +++ b/arch/x86/kernel/acpi/boot.c @@ -195,7 +195,7 @@ static int __init acpi_parse_madt(struct acpi_table_header *table) return 0; } -static void __cpuinit acpi_register_lapic(int id, u8 enabled) +static void acpi_register_lapic(int id, u8 enabled) { unsigned int ver = 0; @@ -607,7 +607,7 @@ void __init acpi_set_irq_model_ioapic(void) #ifdef CONFIG_ACPI_HOTPLUG_CPU #include -static void __cpuinit acpi_map_cpu2node(acpi_handle handle, int cpu, int physid) +static void acpi_map_cpu2node(acpi_handle handle, int cpu, int physid) { #ifdef CONFIG_ACPI_NUMA int nid; @@ -620,7 +620,7 @@ static void __cpuinit acpi_map_cpu2node(acpi_handle handle, int cpu, int physid) #endif } -static int __cpuinit _acpi_map_lsapic(acpi_handle handle, int *pcpu) +static int _acpi_map_lsapic(acpi_handle handle, int *pcpu) { struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; union acpi_object *obj; diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c index 99663b59123a..eca89c53a7f5 100644 --- a/arch/x86/kernel/apic/apic.c +++ b/arch/x86/kernel/apic/apic.c @@ -58,7 +58,7 @@ unsigned int num_processors; -unsigned disabled_cpus __cpuinitdata; +unsigned disabled_cpus; /* Processor that is doing the boot up */ unsigned int boot_cpu_physical_apicid = -1U; @@ -544,7 +544,7 @@ static DEFINE_PER_CPU(struct clock_event_device, lapic_events); * Setup the local APIC timer for this CPU. Copy the initialized values * of the boot CPU and register the clock event in the framework. */ -static void __cpuinit setup_APIC_timer(void) +static void setup_APIC_timer(void) { struct clock_event_device *levt = &__get_cpu_var(lapic_events); @@ -866,7 +866,7 @@ void __init setup_boot_APIC_clock(void) setup_APIC_timer(); } -void __cpuinit setup_secondary_APIC_clock(void) +void setup_secondary_APIC_clock(void) { setup_APIC_timer(); } @@ -1229,7 +1229,7 @@ void __init init_bsp_APIC(void) apic_write(APIC_LVT1, value); } -static void __cpuinit lapic_setup_esr(void) +static void lapic_setup_esr(void) { unsigned int oldvalue, value, maxlvt; @@ -1276,7 +1276,7 @@ static void __cpuinit lapic_setup_esr(void) * Used to setup local APIC while initializing BSP or bringin up APs. * Always called with preemption disabled. */ -void __cpuinit setup_local_APIC(void) +void setup_local_APIC(void) { int cpu = smp_processor_id(); unsigned int value, queued; @@ -1471,7 +1471,7 @@ void __cpuinit setup_local_APIC(void) #endif } -void __cpuinit end_local_APIC_setup(void) +void end_local_APIC_setup(void) { lapic_setup_esr(); @@ -2107,7 +2107,7 @@ void disconnect_bsp_APIC(int virt_wire_setup) apic_write(APIC_LVT1, value); } -void __cpuinit generic_processor_info(int apicid, int version) +void generic_processor_info(int apicid, int version) { int cpu, max = nr_cpu_ids; bool boot_cpu_detected = physid_isset(boot_cpu_physical_apicid, @@ -2377,7 +2377,7 @@ static struct syscore_ops lapic_syscore_ops = { .suspend = lapic_suspend, }; -static void __cpuinit apic_pm_activate(void) +static void apic_pm_activate(void) { apic_pm_state.active = 1; } @@ -2402,7 +2402,7 @@ static void apic_pm_activate(void) { } #ifdef CONFIG_X86_64 -static int __cpuinit apic_cluster_num(void) +static int apic_cluster_num(void) { int i, clusters, zeros; unsigned id; @@ -2447,10 +2447,10 @@ static int __cpuinit apic_cluster_num(void) return clusters; } -static int __cpuinitdata multi_checked; -static int __cpuinitdata multi; +static int multi_checked; +static int multi; -static int __cpuinit set_multi(const struct dmi_system_id *d) +static int set_multi(const struct dmi_system_id *d) { if (multi) return 0; @@ -2459,7 +2459,7 @@ static int __cpuinit set_multi(const struct dmi_system_id *d) return 0; } -static const __cpuinitconst struct dmi_system_id multi_dmi_table[] = { +static const struct dmi_system_id multi_dmi_table[] = { { .callback = set_multi, .ident = "IBM System Summit2", @@ -2471,7 +2471,7 @@ static const __cpuinitconst struct dmi_system_id multi_dmi_table[] = { {} }; -static void __cpuinit dmi_check_multi(void) +static void dmi_check_multi(void) { if (multi_checked) return; @@ -2488,7 +2488,7 @@ static void __cpuinit dmi_check_multi(void) * multi-chassis. * Use DMI to check them */ -__cpuinit int apic_is_clustered_box(void) +int apic_is_clustered_box(void) { dmi_check_multi(); if (multi) diff --git a/arch/x86/kernel/apic/apic_numachip.c b/arch/x86/kernel/apic/apic_numachip.c index 9a9110918ca7..3e67f9e3d7ef 100644 --- a/arch/x86/kernel/apic/apic_numachip.c +++ b/arch/x86/kernel/apic/apic_numachip.c @@ -74,7 +74,7 @@ static int numachip_phys_pkg_id(int initial_apic_id, int index_msb) return initial_apic_id >> index_msb; } -static int __cpuinit numachip_wakeup_secondary(int phys_apicid, unsigned long start_rip) +static int numachip_wakeup_secondary(int phys_apicid, unsigned long start_rip) { union numachip_csr_g3_ext_irq_gen int_gen; diff --git a/arch/x86/kernel/apic/es7000_32.c b/arch/x86/kernel/apic/es7000_32.c index 0874799a98c6..c55224731b2d 100644 --- a/arch/x86/kernel/apic/es7000_32.c +++ b/arch/x86/kernel/apic/es7000_32.c @@ -130,7 +130,7 @@ int es7000_plat; */ -static int __cpuinit wakeup_secondary_cpu_via_mip(int cpu, unsigned long eip) +static int wakeup_secondary_cpu_via_mip(int cpu, unsigned long eip) { unsigned long vect = 0, psaival = 0; diff --git a/arch/x86/kernel/apic/numaq_32.c b/arch/x86/kernel/apic/numaq_32.c index d661ee95cabf..1e42e8f305ee 100644 --- a/arch/x86/kernel/apic/numaq_32.c +++ b/arch/x86/kernel/apic/numaq_32.c @@ -105,7 +105,7 @@ static void __init smp_dump_qct(void) } } -void __cpuinit numaq_tsc_disable(void) +void numaq_tsc_disable(void) { if (!found_numaq) return; diff --git a/arch/x86/kernel/apic/x2apic_cluster.c b/arch/x86/kernel/apic/x2apic_cluster.c index c88baa4ff0e5..140e29db478d 100644 --- a/arch/x86/kernel/apic/x2apic_cluster.c +++ b/arch/x86/kernel/apic/x2apic_cluster.c @@ -148,7 +148,7 @@ static void init_x2apic_ldr(void) /* * At CPU state changes, update the x2apic cluster sibling info. */ -static int __cpuinit +static int update_clusterinfo(struct notifier_block *nfb, unsigned long action, void *hcpu) { unsigned int this_cpu = (unsigned long)hcpu; diff --git a/arch/x86/kernel/apic/x2apic_uv_x.c b/arch/x86/kernel/apic/x2apic_uv_x.c index 63092afb142e..1191ac1c9d25 100644 --- a/arch/x86/kernel/apic/x2apic_uv_x.c +++ b/arch/x86/kernel/apic/x2apic_uv_x.c @@ -209,7 +209,7 @@ EXPORT_SYMBOL_GPL(uv_possible_blades); unsigned long sn_rtc_cycles_per_second; EXPORT_SYMBOL(sn_rtc_cycles_per_second); -static int __cpuinit uv_wakeup_secondary(int phys_apicid, unsigned long start_rip) +static int uv_wakeup_secondary(int phys_apicid, unsigned long start_rip) { #ifdef CONFIG_SMP unsigned long val; @@ -416,7 +416,7 @@ static struct apic __refdata apic_x2apic_uv_x = { .safe_wait_icr_idle = native_safe_x2apic_wait_icr_idle, }; -static __cpuinit void set_x2apic_extra_bits(int pnode) +static void set_x2apic_extra_bits(int pnode) { __this_cpu_write(x2apic_extra_bits, pnode << uvh_apicid.s.pnode_shift); } @@ -735,7 +735,7 @@ static void uv_heartbeat(unsigned long ignored) mod_timer_pinned(timer, jiffies + SCIR_CPU_HB_INTERVAL); } -static void __cpuinit uv_heartbeat_enable(int cpu) +static void uv_heartbeat_enable(int cpu) { while (!uv_cpu_hub_info(cpu)->scir.enabled) { struct timer_list *timer = &uv_cpu_hub_info(cpu)->scir.timer; @@ -752,7 +752,7 @@ static void __cpuinit uv_heartbeat_enable(int cpu) } #ifdef CONFIG_HOTPLUG_CPU -static void __cpuinit uv_heartbeat_disable(int cpu) +static void uv_heartbeat_disable(int cpu) { if (uv_cpu_hub_info(cpu)->scir.enabled) { uv_cpu_hub_info(cpu)->scir.enabled = 0; @@ -764,8 +764,8 @@ static void __cpuinit uv_heartbeat_disable(int cpu) /* * cpu hotplug notifier */ -static __cpuinit int uv_scir_cpu_notify(struct notifier_block *self, - unsigned long action, void *hcpu) +static int uv_scir_cpu_notify(struct notifier_block *self, unsigned long action, + void *hcpu) { long cpu = (long)hcpu; @@ -835,7 +835,7 @@ int uv_set_vga_state(struct pci_dev *pdev, bool decode, * Called on each cpu to initialize the per_cpu UV data area. * FIXME: hotplug not supported yet */ -void __cpuinit uv_cpu_init(void) +void uv_cpu_init(void) { /* CPU 0 initilization will be done via uv_system_init. */ if (!uv_blade_info) diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c index c587a8757227..f654ecefea5b 100644 --- a/arch/x86/kernel/cpu/amd.c +++ b/arch/x86/kernel/cpu/amd.c @@ -69,7 +69,7 @@ static inline int wrmsrl_amd_safe(unsigned msr, unsigned long long val) extern void vide(void); __asm__(".align 4\nvide: ret"); -static void __cpuinit init_amd_k5(struct cpuinfo_x86 *c) +static void init_amd_k5(struct cpuinfo_x86 *c) { /* * General Systems BIOSen alias the cpu frequency registers @@ -87,7 +87,7 @@ static void __cpuinit init_amd_k5(struct cpuinfo_x86 *c) } -static void __cpuinit init_amd_k6(struct cpuinfo_x86 *c) +static void init_amd_k6(struct cpuinfo_x86 *c) { u32 l, h; int mbytes = get_num_physpages() >> (20-PAGE_SHIFT); @@ -179,7 +179,7 @@ static void __cpuinit init_amd_k6(struct cpuinfo_x86 *c) } } -static void __cpuinit amd_k7_smp_check(struct cpuinfo_x86 *c) +static void amd_k7_smp_check(struct cpuinfo_x86 *c) { /* calling is from identify_secondary_cpu() ? */ if (!c->cpu_index) @@ -222,7 +222,7 @@ static void __cpuinit amd_k7_smp_check(struct cpuinfo_x86 *c) add_taint(TAINT_UNSAFE_SMP, LOCKDEP_NOW_UNRELIABLE); } -static void __cpuinit init_amd_k7(struct cpuinfo_x86 *c) +static void init_amd_k7(struct cpuinfo_x86 *c) { u32 l, h; @@ -267,7 +267,7 @@ static void __cpuinit init_amd_k7(struct cpuinfo_x86 *c) * To workaround broken NUMA config. Read the comment in * srat_detect_node(). */ -static int __cpuinit nearby_node(int apicid) +static int nearby_node(int apicid) { int i, node; @@ -292,7 +292,7 @@ static int __cpuinit nearby_node(int apicid) * (2) AMD processors supporting compute units */ #ifdef CONFIG_X86_HT -static void __cpuinit amd_get_topology(struct cpuinfo_x86 *c) +static void amd_get_topology(struct cpuinfo_x86 *c) { u32 nodes, cores_per_cu = 1; u8 node_id; @@ -342,7 +342,7 @@ static void __cpuinit amd_get_topology(struct cpuinfo_x86 *c) * On a AMD dual core setup the lower bits of the APIC id distingush the cores. * Assumes number of cores is a power of two. */ -static void __cpuinit amd_detect_cmp(struct cpuinfo_x86 *c) +static void amd_detect_cmp(struct cpuinfo_x86 *c) { #ifdef CONFIG_X86_HT unsigned bits; @@ -369,7 +369,7 @@ u16 amd_get_nb_id(int cpu) } EXPORT_SYMBOL_GPL(amd_get_nb_id); -static void __cpuinit srat_detect_node(struct cpuinfo_x86 *c) +static void srat_detect_node(struct cpuinfo_x86 *c) { #ifdef CONFIG_NUMA int cpu = smp_processor_id(); @@ -421,7 +421,7 @@ static void __cpuinit srat_detect_node(struct cpuinfo_x86 *c) #endif } -static void __cpuinit early_init_amd_mc(struct cpuinfo_x86 *c) +static void early_init_amd_mc(struct cpuinfo_x86 *c) { #ifdef CONFIG_X86_HT unsigned bits, ecx; @@ -447,7 +447,7 @@ static void __cpuinit early_init_amd_mc(struct cpuinfo_x86 *c) #endif } -static void __cpuinit bsp_init_amd(struct cpuinfo_x86 *c) +static void bsp_init_amd(struct cpuinfo_x86 *c) { if (cpu_has(c, X86_FEATURE_CONSTANT_TSC)) { @@ -475,7 +475,7 @@ static void __cpuinit bsp_init_amd(struct cpuinfo_x86 *c) } } -static void __cpuinit early_init_amd(struct cpuinfo_x86 *c) +static void early_init_amd(struct cpuinfo_x86 *c) { early_init_amd_mc(c); @@ -514,7 +514,7 @@ static const int amd_erratum_383[]; static const int amd_erratum_400[]; static bool cpu_has_amd_erratum(const int *erratum); -static void __cpuinit init_amd(struct cpuinfo_x86 *c) +static void init_amd(struct cpuinfo_x86 *c) { u32 dummy; unsigned long long value; @@ -740,8 +740,7 @@ static void __cpuinit init_amd(struct cpuinfo_x86 *c) } #ifdef CONFIG_X86_32 -static unsigned int __cpuinit amd_size_cache(struct cpuinfo_x86 *c, - unsigned int size) +static unsigned int amd_size_cache(struct cpuinfo_x86 *c, unsigned int size) { /* AMD errata T13 (order #21922) */ if ((c->x86 == 6)) { @@ -757,7 +756,7 @@ static unsigned int __cpuinit amd_size_cache(struct cpuinfo_x86 *c, } #endif -static void __cpuinit cpu_set_tlb_flushall_shift(struct cpuinfo_x86 *c) +static void cpu_set_tlb_flushall_shift(struct cpuinfo_x86 *c) { tlb_flushall_shift = 5; @@ -765,7 +764,7 @@ static void __cpuinit cpu_set_tlb_flushall_shift(struct cpuinfo_x86 *c) tlb_flushall_shift = 4; } -static void __cpuinit cpu_detect_tlb_amd(struct cpuinfo_x86 *c) +static void cpu_detect_tlb_amd(struct cpuinfo_x86 *c) { u32 ebx, eax, ecx, edx; u16 mask = 0xfff; @@ -820,7 +819,7 @@ static void __cpuinit cpu_detect_tlb_amd(struct cpuinfo_x86 *c) cpu_set_tlb_flushall_shift(c); } -static const struct cpu_dev __cpuinitconst amd_cpu_dev = { +static const struct cpu_dev amd_cpu_dev = { .c_vendor = "AMD", .c_ident = { "AuthenticAMD" }, #ifdef CONFIG_X86_32 diff --git a/arch/x86/kernel/cpu/centaur.c b/arch/x86/kernel/cpu/centaur.c index 159103c0b1f4..fbf6c3bc2400 100644 --- a/arch/x86/kernel/cpu/centaur.c +++ b/arch/x86/kernel/cpu/centaur.c @@ -11,7 +11,7 @@ #ifdef CONFIG_X86_OOSTORE -static u32 __cpuinit power2(u32 x) +static u32 power2(u32 x) { u32 s = 1; @@ -25,7 +25,7 @@ static u32 __cpuinit power2(u32 x) /* * Set up an actual MCR */ -static void __cpuinit centaur_mcr_insert(int reg, u32 base, u32 size, int key) +static void centaur_mcr_insert(int reg, u32 base, u32 size, int key) { u32 lo, hi; @@ -42,7 +42,7 @@ static void __cpuinit centaur_mcr_insert(int reg, u32 base, u32 size, int key) * * Shortcut: We know you can't put 4Gig of RAM on a winchip */ -static u32 __cpuinit ramtop(void) +static u32 ramtop(void) { u32 clip = 0xFFFFFFFFUL; u32 top = 0; @@ -91,7 +91,7 @@ static u32 __cpuinit ramtop(void) /* * Compute a set of MCR's to give maximum coverage */ -static int __cpuinit centaur_mcr_compute(int nr, int key) +static int centaur_mcr_compute(int nr, int key) { u32 mem = ramtop(); u32 root = power2(mem); @@ -157,7 +157,7 @@ static int __cpuinit centaur_mcr_compute(int nr, int key) return ct; } -static void __cpuinit centaur_create_optimal_mcr(void) +static void centaur_create_optimal_mcr(void) { int used; int i; @@ -181,7 +181,7 @@ static void __cpuinit centaur_create_optimal_mcr(void) wrmsr(MSR_IDT_MCR0+i, 0, 0); } -static void __cpuinit winchip2_create_optimal_mcr(void) +static void winchip2_create_optimal_mcr(void) { u32 lo, hi; int used; @@ -217,7 +217,7 @@ static void __cpuinit winchip2_create_optimal_mcr(void) /* * Handle the MCR key on the Winchip 2. */ -static void __cpuinit winchip2_unprotect_mcr(void) +static void winchip2_unprotect_mcr(void) { u32 lo, hi; u32 key; @@ -229,7 +229,7 @@ static void __cpuinit winchip2_unprotect_mcr(void) wrmsr(MSR_IDT_MCR_CTRL, lo, hi); } -static void __cpuinit winchip2_protect_mcr(void) +static void winchip2_protect_mcr(void) { u32 lo, hi; @@ -247,7 +247,7 @@ static void __cpuinit winchip2_protect_mcr(void) #define RNG_ENABLED (1 << 3) #define RNG_ENABLE (1 << 6) /* MSR_VIA_RNG */ -static void __cpuinit init_c3(struct cpuinfo_x86 *c) +static void init_c3(struct cpuinfo_x86 *c) { u32 lo, hi; @@ -318,7 +318,7 @@ enum { EAMD3D = 1<<20, }; -static void __cpuinit early_init_centaur(struct cpuinfo_x86 *c) +static void early_init_centaur(struct cpuinfo_x86 *c) { switch (c->x86) { #ifdef CONFIG_X86_32 @@ -337,7 +337,7 @@ static void __cpuinit early_init_centaur(struct cpuinfo_x86 *c) #endif } -static void __cpuinit init_centaur(struct cpuinfo_x86 *c) +static void init_centaur(struct cpuinfo_x86 *c) { #ifdef CONFIG_X86_32 char *name; @@ -468,7 +468,7 @@ static void __cpuinit init_centaur(struct cpuinfo_x86 *c) #endif } -static unsigned int __cpuinit +static unsigned int centaur_size_cache(struct cpuinfo_x86 *c, unsigned int size) { #ifdef CONFIG_X86_32 @@ -488,7 +488,7 @@ centaur_size_cache(struct cpuinfo_x86 *c, unsigned int size) return size; } -static const struct cpu_dev __cpuinitconst centaur_cpu_dev = { +static const struct cpu_dev centaur_cpu_dev = { .c_vendor = "Centaur", .c_ident = { "CentaurHauls" }, .c_early_init = early_init_centaur, diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c index 548bd039784e..25eb2747b063 100644 --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c @@ -63,7 +63,7 @@ void __init setup_cpu_local_masks(void) alloc_bootmem_cpumask_var(&cpu_sibling_setup_mask); } -static void __cpuinit default_init(struct cpuinfo_x86 *c) +static void default_init(struct cpuinfo_x86 *c) { #ifdef CONFIG_X86_64 cpu_detect_cache_sizes(c); @@ -80,13 +80,13 @@ static void __cpuinit default_init(struct cpuinfo_x86 *c) #endif } -static const struct cpu_dev __cpuinitconst default_cpu = { +static const struct cpu_dev default_cpu = { .c_init = default_init, .c_vendor = "Unknown", .c_x86_vendor = X86_VENDOR_UNKNOWN, }; -static const struct cpu_dev *this_cpu __cpuinitdata = &default_cpu; +static const struct cpu_dev *this_cpu = &default_cpu; DEFINE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page) = { .gdt = { #ifdef CONFIG_X86_64 @@ -160,8 +160,8 @@ static int __init x86_xsaveopt_setup(char *s) __setup("noxsaveopt", x86_xsaveopt_setup); #ifdef CONFIG_X86_32 -static int cachesize_override __cpuinitdata = -1; -static int disable_x86_serial_nr __cpuinitdata = 1; +static int cachesize_override = -1; +static int disable_x86_serial_nr = 1; static int __init cachesize_setup(char *str) { @@ -215,12 +215,12 @@ static inline int flag_is_changeable_p(u32 flag) } /* Probe for the CPUID instruction */ -int __cpuinit have_cpuid_p(void) +int have_cpuid_p(void) { return flag_is_changeable_p(X86_EFLAGS_ID); } -static void __cpuinit squash_the_stupid_serial_number(struct cpuinfo_x86 *c) +static void squash_the_stupid_serial_number(struct cpuinfo_x86 *c) { unsigned long lo, hi; @@ -298,7 +298,7 @@ struct cpuid_dependent_feature { u32 level; }; -static const struct cpuid_dependent_feature __cpuinitconst +static const struct cpuid_dependent_feature cpuid_dependent_features[] = { { X86_FEATURE_MWAIT, 0x00000005 }, { X86_FEATURE_DCA, 0x00000009 }, @@ -306,7 +306,7 @@ cpuid_dependent_features[] = { { 0, 0 } }; -static void __cpuinit filter_cpuid_features(struct cpuinfo_x86 *c, bool warn) +static void filter_cpuid_features(struct cpuinfo_x86 *c, bool warn) { const struct cpuid_dependent_feature *df; @@ -344,7 +344,7 @@ static void __cpuinit filter_cpuid_features(struct cpuinfo_x86 *c, bool warn) */ /* Look up CPU names by table lookup. */ -static const char *__cpuinit table_lookup_model(struct cpuinfo_x86 *c) +static const char *table_lookup_model(struct cpuinfo_x86 *c) { const struct cpu_model_info *info; @@ -364,8 +364,8 @@ static const char *__cpuinit table_lookup_model(struct cpuinfo_x86 *c) return NULL; /* Not found */ } -__u32 cpu_caps_cleared[NCAPINTS] __cpuinitdata; -__u32 cpu_caps_set[NCAPINTS] __cpuinitdata; +__u32 cpu_caps_cleared[NCAPINTS]; +__u32 cpu_caps_set[NCAPINTS]; void load_percpu_segment(int cpu) { @@ -394,9 +394,9 @@ void switch_to_new_gdt(int cpu) load_percpu_segment(cpu); } -static const struct cpu_dev *__cpuinitdata cpu_devs[X86_VENDOR_NUM] = {}; +static const struct cpu_dev *cpu_devs[X86_VENDOR_NUM] = {}; -static void __cpuinit get_model_name(struct cpuinfo_x86 *c) +static void get_model_name(struct cpuinfo_x86 *c) { unsigned int *v; char *p, *q; @@ -425,7 +425,7 @@ static void __cpuinit get_model_name(struct cpuinfo_x86 *c) } } -void __cpuinit cpu_detect_cache_sizes(struct cpuinfo_x86 *c) +void cpu_detect_cache_sizes(struct cpuinfo_x86 *c) { unsigned int n, dummy, ebx, ecx, edx, l2size; @@ -479,7 +479,7 @@ u16 __read_mostly tlb_lld_4m[NR_INFO]; */ s8 __read_mostly tlb_flushall_shift = -1; -void __cpuinit cpu_detect_tlb(struct cpuinfo_x86 *c) +void cpu_detect_tlb(struct cpuinfo_x86 *c) { if (this_cpu->c_detect_tlb) this_cpu->c_detect_tlb(c); @@ -493,7 +493,7 @@ void __cpuinit cpu_detect_tlb(struct cpuinfo_x86 *c) tlb_flushall_shift); } -void __cpuinit detect_ht(struct cpuinfo_x86 *c) +void detect_ht(struct cpuinfo_x86 *c) { #ifdef CONFIG_X86_HT u32 eax, ebx, ecx, edx; @@ -544,7 +544,7 @@ out: #endif } -static void __cpuinit get_cpu_vendor(struct cpuinfo_x86 *c) +static void get_cpu_vendor(struct cpuinfo_x86 *c) { char *v = c->x86_vendor_id; int i; @@ -571,7 +571,7 @@ static void __cpuinit get_cpu_vendor(struct cpuinfo_x86 *c) this_cpu = &default_cpu; } -void __cpuinit cpu_detect(struct cpuinfo_x86 *c) +void cpu_detect(struct cpuinfo_x86 *c) { /* Get vendor name */ cpuid(0x00000000, (unsigned int *)&c->cpuid_level, @@ -601,7 +601,7 @@ void __cpuinit cpu_detect(struct cpuinfo_x86 *c) } } -void __cpuinit get_cpu_cap(struct cpuinfo_x86 *c) +void get_cpu_cap(struct cpuinfo_x86 *c) { u32 tfms, xlvl; u32 ebx; @@ -652,7 +652,7 @@ void __cpuinit get_cpu_cap(struct cpuinfo_x86 *c) init_scattered_cpuid_features(c); } -static void __cpuinit identify_cpu_without_cpuid(struct cpuinfo_x86 *c) +static void identify_cpu_without_cpuid(struct cpuinfo_x86 *c) { #ifdef CONFIG_X86_32 int i; @@ -769,7 +769,7 @@ void __init early_cpu_init(void) * unless we can find a reliable way to detect all the broken cases. * Enable it explicitly on 64-bit for non-constant inputs of cpu_has(). */ -static void __cpuinit detect_nopl(struct cpuinfo_x86 *c) +static void detect_nopl(struct cpuinfo_x86 *c) { #ifdef CONFIG_X86_32 clear_cpu_cap(c, X86_FEATURE_NOPL); @@ -778,7 +778,7 @@ static void __cpuinit detect_nopl(struct cpuinfo_x86 *c) #endif } -static void __cpuinit generic_identify(struct cpuinfo_x86 *c) +static void generic_identify(struct cpuinfo_x86 *c) { c->extended_cpuid_level = 0; @@ -815,7 +815,7 @@ static void __cpuinit generic_identify(struct cpuinfo_x86 *c) /* * This does the hard work of actually picking apart the CPU stuff... */ -static void __cpuinit identify_cpu(struct cpuinfo_x86 *c) +static void identify_cpu(struct cpuinfo_x86 *c) { int i; @@ -960,7 +960,7 @@ void __init identify_boot_cpu(void) cpu_detect_tlb(&boot_cpu_data); } -void __cpuinit identify_secondary_cpu(struct cpuinfo_x86 *c) +void identify_secondary_cpu(struct cpuinfo_x86 *c) { BUG_ON(c == &boot_cpu_data); identify_cpu(c); @@ -975,14 +975,14 @@ struct msr_range { unsigned max; }; -static const struct msr_range msr_range_array[] __cpuinitconst = { +static const struct msr_range msr_range_array[] = { { 0x00000000, 0x00000418}, { 0xc0000000, 0xc000040b}, { 0xc0010000, 0xc0010142}, { 0xc0011000, 0xc001103b}, }; -static void __cpuinit __print_cpu_msr(void) +static void __print_cpu_msr(void) { unsigned index_min, index_max; unsigned index; @@ -1001,7 +1001,7 @@ static void __cpuinit __print_cpu_msr(void) } } -static int show_msr __cpuinitdata; +static int show_msr; static __init int setup_show_msr(char *arg) { @@ -1022,7 +1022,7 @@ static __init int setup_noclflush(char *arg) } __setup("noclflush", setup_noclflush); -void __cpuinit print_cpu_info(struct cpuinfo_x86 *c) +void print_cpu_info(struct cpuinfo_x86 *c) { const char *vendor = NULL; @@ -1051,7 +1051,7 @@ void __cpuinit print_cpu_info(struct cpuinfo_x86 *c) print_cpu_msr(c); } -void __cpuinit print_cpu_msr(struct cpuinfo_x86 *c) +void print_cpu_msr(struct cpuinfo_x86 *c) { if (c->cpu_index < show_msr) __print_cpu_msr(); @@ -1216,7 +1216,7 @@ static void dbg_restore_debug_regs(void) */ #ifdef CONFIG_X86_64 -void __cpuinit cpu_init(void) +void cpu_init(void) { struct orig_ist *oist; struct task_struct *me; @@ -1315,7 +1315,7 @@ void __cpuinit cpu_init(void) #else -void __cpuinit cpu_init(void) +void cpu_init(void) { int cpu = smp_processor_id(); struct task_struct *curr = current; diff --git a/arch/x86/kernel/cpu/cyrix.c b/arch/x86/kernel/cpu/cyrix.c index 7582f475b163..d0969c75ab54 100644 --- a/arch/x86/kernel/cpu/cyrix.c +++ b/arch/x86/kernel/cpu/cyrix.c @@ -15,7 +15,7 @@ /* * Read NSC/Cyrix DEVID registers (DIR) to get more detailed info. about the CPU */ -static void __cpuinit __do_cyrix_devid(unsigned char *dir0, unsigned char *dir1) +static void __do_cyrix_devid(unsigned char *dir0, unsigned char *dir1) { unsigned char ccr2, ccr3; @@ -44,7 +44,7 @@ static void __cpuinit __do_cyrix_devid(unsigned char *dir0, unsigned char *dir1) } } -static void __cpuinit do_cyrix_devid(unsigned char *dir0, unsigned char *dir1) +static void do_cyrix_devid(unsigned char *dir0, unsigned char *dir1) { unsigned long flags; @@ -59,25 +59,25 @@ static void __cpuinit do_cyrix_devid(unsigned char *dir0, unsigned char *dir1) * Actually since bugs.h doesn't even reference this perhaps someone should * fix the documentation ??? */ -static unsigned char Cx86_dir0_msb __cpuinitdata = 0; +static unsigned char Cx86_dir0_msb = 0; -static const char __cpuinitconst Cx86_model[][9] = { +static const char Cx86_model[][9] = { "Cx486", "Cx486", "5x86 ", "6x86", "MediaGX ", "6x86MX ", "M II ", "Unknown" }; -static const char __cpuinitconst Cx486_name[][5] = { +static const char Cx486_name[][5] = { "SLC", "DLC", "SLC2", "DLC2", "SRx", "DRx", "SRx2", "DRx2" }; -static const char __cpuinitconst Cx486S_name[][4] = { +static const char Cx486S_name[][4] = { "S", "S2", "Se", "S2e" }; -static const char __cpuinitconst Cx486D_name[][4] = { +static const char Cx486D_name[][4] = { "DX", "DX2", "?", "?", "?", "DX4" }; -static char Cx86_cb[] __cpuinitdata = "?.5x Core/Bus Clock"; -static const char __cpuinitconst cyrix_model_mult1[] = "12??43"; -static const char __cpuinitconst cyrix_model_mult2[] = "12233445"; +static char Cx86_cb[] = "?.5x Core/Bus Clock"; +static const char cyrix_model_mult1[] = "12??43"; +static const char cyrix_model_mult2[] = "12233445"; /* * Reset the slow-loop (SLOP) bit on the 686(L) which is set by some old @@ -87,7 +87,7 @@ static const char __cpuinitconst cyrix_model_mult2[] = "12233445"; * FIXME: our newer udelay uses the tsc. We don't need to frob with SLOP */ -static void __cpuinit check_cx686_slop(struct cpuinfo_x86 *c) +static void check_cx686_slop(struct cpuinfo_x86 *c) { unsigned long flags; @@ -112,7 +112,7 @@ static void __cpuinit check_cx686_slop(struct cpuinfo_x86 *c) } -static void __cpuinit set_cx86_reorder(void) +static void set_cx86_reorder(void) { u8 ccr3; @@ -127,7 +127,7 @@ static void __cpuinit set_cx86_reorder(void) setCx86(CX86_CCR3, ccr3); } -static void __cpuinit set_cx86_memwb(void) +static void set_cx86_memwb(void) { printk(KERN_INFO "Enable Memory-Write-back mode on Cyrix/NSC processor.\n"); @@ -143,7 +143,7 @@ static void __cpuinit set_cx86_memwb(void) * Configure later MediaGX and/or Geode processor. */ -static void __cpuinit geode_configure(void) +static void geode_configure(void) { unsigned long flags; u8 ccr3; @@ -166,7 +166,7 @@ static void __cpuinit geode_configure(void) local_irq_restore(flags); } -static void __cpuinit early_init_cyrix(struct cpuinfo_x86 *c) +static void early_init_cyrix(struct cpuinfo_x86 *c) { unsigned char dir0, dir0_msn, dir1 = 0; @@ -185,7 +185,7 @@ static void __cpuinit early_init_cyrix(struct cpuinfo_x86 *c) } } -static void __cpuinit init_cyrix(struct cpuinfo_x86 *c) +static void init_cyrix(struct cpuinfo_x86 *c) { unsigned char dir0, dir0_msn, dir0_lsn, dir1 = 0; char *buf = c->x86_model_id; @@ -356,7 +356,7 @@ static void __cpuinit init_cyrix(struct cpuinfo_x86 *c) /* * Handle National Semiconductor branded processors */ -static void __cpuinit init_nsc(struct cpuinfo_x86 *c) +static void init_nsc(struct cpuinfo_x86 *c) { /* * There may be GX1 processors in the wild that are branded @@ -405,7 +405,7 @@ static inline int test_cyrix_52div(void) return (unsigned char) (test >> 8) == 0x02; } -static void __cpuinit cyrix_identify(struct cpuinfo_x86 *c) +static void cyrix_identify(struct cpuinfo_x86 *c) { /* Detect Cyrix with disabled CPUID */ if (c->x86 == 4 && test_cyrix_52div()) { @@ -441,7 +441,7 @@ static void __cpuinit cyrix_identify(struct cpuinfo_x86 *c) } } -static const struct cpu_dev __cpuinitconst cyrix_cpu_dev = { +static const struct cpu_dev cyrix_cpu_dev = { .c_vendor = "Cyrix", .c_ident = { "CyrixInstead" }, .c_early_init = early_init_cyrix, @@ -452,7 +452,7 @@ static const struct cpu_dev __cpuinitconst cyrix_cpu_dev = { cpu_dev_register(cyrix_cpu_dev); -static const struct cpu_dev __cpuinitconst nsc_cpu_dev = { +static const struct cpu_dev nsc_cpu_dev = { .c_vendor = "NSC", .c_ident = { "Geode by NSC" }, .c_init = init_nsc, diff --git a/arch/x86/kernel/cpu/hypervisor.c b/arch/x86/kernel/cpu/hypervisor.c index 1e7e84a02eba..87279212d318 100644 --- a/arch/x86/kernel/cpu/hypervisor.c +++ b/arch/x86/kernel/cpu/hypervisor.c @@ -60,7 +60,7 @@ detect_hypervisor_vendor(void) } } -void __cpuinit init_hypervisor(struct cpuinfo_x86 *c) +void init_hypervisor(struct cpuinfo_x86 *c) { if (x86_hyper && x86_hyper->set_cpu_features) x86_hyper->set_cpu_features(c); diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c index 9b0c441c03f5..ec7299566f79 100644 --- a/arch/x86/kernel/cpu/intel.c +++ b/arch/x86/kernel/cpu/intel.c @@ -26,7 +26,7 @@ #include #endif -static void __cpuinit early_init_intel(struct cpuinfo_x86 *c) +static void early_init_intel(struct cpuinfo_x86 *c) { u64 misc_enable; @@ -163,7 +163,7 @@ static void __cpuinit early_init_intel(struct cpuinfo_x86 *c) * This is called before we do cpu ident work */ -int __cpuinit ppro_with_ram_bug(void) +int ppro_with_ram_bug(void) { /* Uses data from early_cpu_detect now */ if (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL && @@ -176,7 +176,7 @@ int __cpuinit ppro_with_ram_bug(void) return 0; } -static void __cpuinit intel_smp_check(struct cpuinfo_x86 *c) +static void intel_smp_check(struct cpuinfo_x86 *c) { /* calling is from identify_secondary_cpu() ? */ if (!c->cpu_index) @@ -196,7 +196,7 @@ static void __cpuinit intel_smp_check(struct cpuinfo_x86 *c) } } -static void __cpuinit intel_workarounds(struct cpuinfo_x86 *c) +static void intel_workarounds(struct cpuinfo_x86 *c) { unsigned long lo, hi; @@ -275,12 +275,12 @@ static void __cpuinit intel_workarounds(struct cpuinfo_x86 *c) intel_smp_check(c); } #else -static void __cpuinit intel_workarounds(struct cpuinfo_x86 *c) +static void intel_workarounds(struct cpuinfo_x86 *c) { } #endif -static void __cpuinit srat_detect_node(struct cpuinfo_x86 *c) +static void srat_detect_node(struct cpuinfo_x86 *c) { #ifdef CONFIG_NUMA unsigned node; @@ -300,7 +300,7 @@ static void __cpuinit srat_detect_node(struct cpuinfo_x86 *c) /* * find out the number of processor cores on the die */ -static int __cpuinit intel_num_cpu_cores(struct cpuinfo_x86 *c) +static int intel_num_cpu_cores(struct cpuinfo_x86 *c) { unsigned int eax, ebx, ecx, edx; @@ -315,7 +315,7 @@ static int __cpuinit intel_num_cpu_cores(struct cpuinfo_x86 *c) return 1; } -static void __cpuinit detect_vmx_virtcap(struct cpuinfo_x86 *c) +static void detect_vmx_virtcap(struct cpuinfo_x86 *c) { /* Intel VMX MSR indicated features */ #define X86_VMX_FEATURE_PROC_CTLS_TPR_SHADOW 0x00200000 @@ -353,7 +353,7 @@ static void __cpuinit detect_vmx_virtcap(struct cpuinfo_x86 *c) } } -static void __cpuinit init_intel(struct cpuinfo_x86 *c) +static void init_intel(struct cpuinfo_x86 *c) { unsigned int l2 = 0; @@ -472,7 +472,7 @@ static void __cpuinit init_intel(struct cpuinfo_x86 *c) } #ifdef CONFIG_X86_32 -static unsigned int __cpuinit intel_size_cache(struct cpuinfo_x86 *c, unsigned int size) +static unsigned int intel_size_cache(struct cpuinfo_x86 *c, unsigned int size) { /* * Intel PIII Tualatin. This comes in two flavours. @@ -506,7 +506,7 @@ static unsigned int __cpuinit intel_size_cache(struct cpuinfo_x86 *c, unsigned i #define STLB_4K 0x41 -static const struct _tlb_table intel_tlb_table[] __cpuinitconst = { +static const struct _tlb_table intel_tlb_table[] = { { 0x01, TLB_INST_4K, 32, " TLB_INST 4 KByte pages, 4-way set associative" }, { 0x02, TLB_INST_4M, 2, " TLB_INST 4 MByte pages, full associative" }, { 0x03, TLB_DATA_4K, 64, " TLB_DATA 4 KByte pages, 4-way set associative" }, @@ -536,7 +536,7 @@ static const struct _tlb_table intel_tlb_table[] __cpuinitconst = { { 0x00, 0, 0 } }; -static void __cpuinit intel_tlb_lookup(const unsigned char desc) +static void intel_tlb_lookup(const unsigned char desc) { unsigned char k; if (desc == 0) @@ -605,7 +605,7 @@ static void __cpuinit intel_tlb_lookup(const unsigned char desc) } } -static void __cpuinit intel_tlb_flushall_shift_set(struct cpuinfo_x86 *c) +static void intel_tlb_flushall_shift_set(struct cpuinfo_x86 *c) { switch ((c->x86 << 8) + c->x86_model) { case 0x60f: /* original 65 nm celeron/pentium/core2/xeon, "Merom"/"Conroe" */ @@ -634,7 +634,7 @@ static void __cpuinit intel_tlb_flushall_shift_set(struct cpuinfo_x86 *c) } } -static void __cpuinit intel_detect_tlb(struct cpuinfo_x86 *c) +static void intel_detect_tlb(struct cpuinfo_x86 *c) { int i, j, n; unsigned int regs[4]; @@ -661,7 +661,7 @@ static void __cpuinit intel_detect_tlb(struct cpuinfo_x86 *c) intel_tlb_flushall_shift_set(c); } -static const struct cpu_dev __cpuinitconst intel_cpu_dev = { +static const struct cpu_dev intel_cpu_dev = { .c_vendor = "Intel", .c_ident = { "GenuineIntel" }, #ifdef CONFIG_X86_32 diff --git a/arch/x86/kernel/cpu/intel_cacheinfo.c b/arch/x86/kernel/cpu/intel_cacheinfo.c index 8dc72dda66fe..1414c90feaba 100644 --- a/arch/x86/kernel/cpu/intel_cacheinfo.c +++ b/arch/x86/kernel/cpu/intel_cacheinfo.c @@ -37,7 +37,7 @@ struct _cache_table { /* All the cache descriptor types we care about (no TLB or trace cache entries) */ -static const struct _cache_table __cpuinitconst cache_table[] = +static const struct _cache_table cache_table[] = { { 0x06, LVL_1_INST, 8 }, /* 4-way set assoc, 32 byte line size */ { 0x08, LVL_1_INST, 16 }, /* 4-way set assoc, 32 byte line size */ @@ -203,7 +203,7 @@ union l3_cache { unsigned val; }; -static const unsigned short __cpuinitconst assocs[] = { +static const unsigned short assocs[] = { [1] = 1, [2] = 2, [4] = 4, @@ -217,10 +217,10 @@ static const unsigned short __cpuinitconst assocs[] = { [0xf] = 0xffff /* fully associative - no way to show this currently */ }; -static const unsigned char __cpuinitconst levels[] = { 1, 1, 2, 3 }; -static const unsigned char __cpuinitconst types[] = { 1, 2, 3, 3 }; +static const unsigned char levels[] = { 1, 1, 2, 3 }; +static const unsigned char types[] = { 1, 2, 3, 3 }; -static void __cpuinit +static void amd_cpuid4(int leaf, union _cpuid4_leaf_eax *eax, union _cpuid4_leaf_ebx *ebx, union _cpuid4_leaf_ecx *ecx) @@ -302,7 +302,7 @@ struct _cache_attr { /* * L3 cache descriptors */ -static void __cpuinit amd_calc_l3_indices(struct amd_northbridge *nb) +static void amd_calc_l3_indices(struct amd_northbridge *nb) { struct amd_l3_cache *l3 = &nb->l3_cache; unsigned int sc0, sc1, sc2, sc3; @@ -325,7 +325,7 @@ static void __cpuinit amd_calc_l3_indices(struct amd_northbridge *nb) l3->indices = (max(max3(sc0, sc1, sc2), sc3) << 10) - 1; } -static void __cpuinit amd_init_l3_cache(struct _cpuid4_info_regs *this_leaf, int index) +static void amd_init_l3_cache(struct _cpuid4_info_regs *this_leaf, int index) { int node; @@ -528,8 +528,7 @@ static struct _cache_attr subcaches = #endif /* CONFIG_AMD_NB && CONFIG_SYSFS */ static int -__cpuinit cpuid4_cache_lookup_regs(int index, - struct _cpuid4_info_regs *this_leaf) +cpuid4_cache_lookup_regs(int index, struct _cpuid4_info_regs *this_leaf) { union _cpuid4_leaf_eax eax; union _cpuid4_leaf_ebx ebx; @@ -560,7 +559,7 @@ __cpuinit cpuid4_cache_lookup_regs(int index, return 0; } -static int __cpuinit find_num_cache_leaves(struct cpuinfo_x86 *c) +static int find_num_cache_leaves(struct cpuinfo_x86 *c) { unsigned int eax, ebx, ecx, edx, op; union _cpuid4_leaf_eax cache_eax; @@ -580,7 +579,7 @@ static int __cpuinit find_num_cache_leaves(struct cpuinfo_x86 *c) return i; } -void __cpuinit init_amd_cacheinfo(struct cpuinfo_x86 *c) +void init_amd_cacheinfo(struct cpuinfo_x86 *c) { if (cpu_has_topoext) { @@ -593,7 +592,7 @@ void __cpuinit init_amd_cacheinfo(struct cpuinfo_x86 *c) } } -unsigned int __cpuinit init_intel_cacheinfo(struct cpuinfo_x86 *c) +unsigned int init_intel_cacheinfo(struct cpuinfo_x86 *c) { /* Cache sizes */ unsigned int trace = 0, l1i = 0, l1d = 0, l2 = 0, l3 = 0; @@ -744,7 +743,7 @@ static DEFINE_PER_CPU(struct _cpuid4_info *, ici_cpuid4_info); #ifdef CONFIG_SMP -static int __cpuinit cache_shared_amd_cpu_map_setup(unsigned int cpu, int index) +static int cache_shared_amd_cpu_map_setup(unsigned int cpu, int index) { struct _cpuid4_info *this_leaf; int i, sibling; @@ -793,7 +792,7 @@ static int __cpuinit cache_shared_amd_cpu_map_setup(unsigned int cpu, int index) return 1; } -static void __cpuinit cache_shared_cpu_map_setup(unsigned int cpu, int index) +static void cache_shared_cpu_map_setup(unsigned int cpu, int index) { struct _cpuid4_info *this_leaf, *sibling_leaf; unsigned long num_threads_sharing; @@ -828,7 +827,7 @@ static void __cpuinit cache_shared_cpu_map_setup(unsigned int cpu, int index) } } } -static void __cpuinit cache_remove_shared_cpu_map(unsigned int cpu, int index) +static void cache_remove_shared_cpu_map(unsigned int cpu, int index) { struct _cpuid4_info *this_leaf, *sibling_leaf; int sibling; @@ -841,16 +840,16 @@ static void __cpuinit cache_remove_shared_cpu_map(unsigned int cpu, int index) } } #else -static void __cpuinit cache_shared_cpu_map_setup(unsigned int cpu, int index) +static void cache_shared_cpu_map_setup(unsigned int cpu, int index) { } -static void __cpuinit cache_remove_shared_cpu_map(unsigned int cpu, int index) +static void cache_remove_shared_cpu_map(unsigned int cpu, int index) { } #endif -static void __cpuinit free_cache_attributes(unsigned int cpu) +static void free_cache_attributes(unsigned int cpu) { int i; @@ -861,7 +860,7 @@ static void __cpuinit free_cache_attributes(unsigned int cpu) per_cpu(ici_cpuid4_info, cpu) = NULL; } -static void __cpuinit get_cpu_leaves(void *_retval) +static void get_cpu_leaves(void *_retval) { int j, *retval = _retval, cpu = smp_processor_id(); @@ -881,7 +880,7 @@ static void __cpuinit get_cpu_leaves(void *_retval) } } -static int __cpuinit detect_cache_attributes(unsigned int cpu) +static int detect_cache_attributes(unsigned int cpu) { int retval; @@ -1015,7 +1014,7 @@ static struct attribute *default_attrs[] = { }; #ifdef CONFIG_AMD_NB -static struct attribute ** __cpuinit amd_l3_attrs(void) +static struct attribute **amd_l3_attrs(void) { static struct attribute **attrs; int n; @@ -1091,7 +1090,7 @@ static struct kobj_type ktype_percpu_entry = { .sysfs_ops = &sysfs_ops, }; -static void __cpuinit cpuid4_cache_sysfs_exit(unsigned int cpu) +static void cpuid4_cache_sysfs_exit(unsigned int cpu) { kfree(per_cpu(ici_cache_kobject, cpu)); kfree(per_cpu(ici_index_kobject, cpu)); @@ -1100,7 +1099,7 @@ static void __cpuinit cpuid4_cache_sysfs_exit(unsigned int cpu) free_cache_attributes(cpu); } -static int __cpuinit cpuid4_cache_sysfs_init(unsigned int cpu) +static int cpuid4_cache_sysfs_init(unsigned int cpu) { int err; @@ -1132,7 +1131,7 @@ err_out: static DECLARE_BITMAP(cache_dev_map, NR_CPUS); /* Add/Remove cache interface for CPU device */ -static int __cpuinit cache_add_dev(struct device *dev) +static int cache_add_dev(struct device *dev) { unsigned int cpu = dev->id; unsigned long i, j; @@ -1183,7 +1182,7 @@ static int __cpuinit cache_add_dev(struct device *dev) return 0; } -static void __cpuinit cache_remove_dev(struct device *dev) +static void cache_remove_dev(struct device *dev) { unsigned int cpu = dev->id; unsigned long i; @@ -1200,8 +1199,8 @@ static void __cpuinit cache_remove_dev(struct device *dev) cpuid4_cache_sysfs_exit(cpu); } -static int __cpuinit cacheinfo_cpu_callback(struct notifier_block *nfb, - unsigned long action, void *hcpu) +static int cacheinfo_cpu_callback(struct notifier_block *nfb, + unsigned long action, void *hcpu) { unsigned int cpu = (unsigned long)hcpu; struct device *dev; @@ -1220,7 +1219,7 @@ static int __cpuinit cacheinfo_cpu_callback(struct notifier_block *nfb, return NOTIFY_OK; } -static struct notifier_block __cpuinitdata cacheinfo_cpu_notifier = { +static struct notifier_block cacheinfo_cpu_notifier = { .notifier_call = cacheinfo_cpu_callback, }; diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c index bf49cdbb010f..87a65c939bcd 100644 --- a/arch/x86/kernel/cpu/mcheck/mce.c +++ b/arch/x86/kernel/cpu/mcheck/mce.c @@ -1363,7 +1363,7 @@ int mce_notify_irq(void) } EXPORT_SYMBOL_GPL(mce_notify_irq); -static int __cpuinit __mcheck_cpu_mce_banks_init(void) +static int __mcheck_cpu_mce_banks_init(void) { int i; u8 num_banks = mca_cfg.banks; @@ -1384,7 +1384,7 @@ static int __cpuinit __mcheck_cpu_mce_banks_init(void) /* * Initialize Machine Checks for a CPU. */ -static int __cpuinit __mcheck_cpu_cap_init(void) +static int __mcheck_cpu_cap_init(void) { unsigned b; u64 cap; @@ -1483,7 +1483,7 @@ static void quirk_sandybridge_ifu(int bank, struct mce *m, struct pt_regs *regs) } /* Add per CPU specific workarounds here */ -static int __cpuinit __mcheck_cpu_apply_quirks(struct cpuinfo_x86 *c) +static int __mcheck_cpu_apply_quirks(struct cpuinfo_x86 *c) { struct mca_config *cfg = &mca_cfg; @@ -1593,7 +1593,7 @@ static int __cpuinit __mcheck_cpu_apply_quirks(struct cpuinfo_x86 *c) return 0; } -static int __cpuinit __mcheck_cpu_ancient_init(struct cpuinfo_x86 *c) +static int __mcheck_cpu_ancient_init(struct cpuinfo_x86 *c) { if (c->x86 != 5) return 0; @@ -1664,7 +1664,7 @@ void (*machine_check_vector)(struct pt_regs *, long error_code) = * Called for each booted CPU to set up machine checks. * Must be called with preempt off: */ -void __cpuinit mcheck_cpu_init(struct cpuinfo_x86 *c) +void mcheck_cpu_init(struct cpuinfo_x86 *c) { if (mca_cfg.disabled) return; @@ -2082,7 +2082,6 @@ static struct bus_type mce_subsys = { DEFINE_PER_CPU(struct device *, mce_device); -__cpuinitdata void (*threshold_cpu_callback)(unsigned long action, unsigned int cpu); static inline struct mce_bank *attr_to_bank(struct device_attribute *attr) @@ -2228,7 +2227,7 @@ static void mce_device_release(struct device *dev) } /* Per cpu device init. All of the cpus still share the same ctrl bank: */ -static __cpuinit int mce_device_create(unsigned int cpu) +static int mce_device_create(unsigned int cpu) { struct device *dev; int err; @@ -2274,7 +2273,7 @@ error: return err; } -static __cpuinit void mce_device_remove(unsigned int cpu) +static void mce_device_remove(unsigned int cpu) { struct device *dev = per_cpu(mce_device, cpu); int i; @@ -2294,7 +2293,7 @@ static __cpuinit void mce_device_remove(unsigned int cpu) } /* Make sure there are no machine checks on offlined CPUs. */ -static void __cpuinit mce_disable_cpu(void *h) +static void mce_disable_cpu(void *h) { unsigned long action = *(unsigned long *)h; int i; @@ -2312,7 +2311,7 @@ static void __cpuinit mce_disable_cpu(void *h) } } -static void __cpuinit mce_reenable_cpu(void *h) +static void mce_reenable_cpu(void *h) { unsigned long action = *(unsigned long *)h; int i; @@ -2331,7 +2330,7 @@ static void __cpuinit mce_reenable_cpu(void *h) } /* Get notified when a cpu comes on/off. Be hotplug friendly. */ -static int __cpuinit +static int mce_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu) { unsigned int cpu = (unsigned long)hcpu; @@ -2367,7 +2366,7 @@ mce_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu) return NOTIFY_OK; } -static struct notifier_block mce_cpu_notifier __cpuinitdata = { +static struct notifier_block mce_cpu_notifier = { .notifier_call = mce_cpu_callback, }; diff --git a/arch/x86/kernel/cpu/mcheck/mce_amd.c b/arch/x86/kernel/cpu/mcheck/mce_amd.c index 9cb52767999a..603df4f74640 100644 --- a/arch/x86/kernel/cpu/mcheck/mce_amd.c +++ b/arch/x86/kernel/cpu/mcheck/mce_amd.c @@ -458,10 +458,8 @@ static struct kobj_type threshold_ktype = { .default_attrs = default_attrs, }; -static __cpuinit int allocate_threshold_blocks(unsigned int cpu, - unsigned int bank, - unsigned int block, - u32 address) +static int allocate_threshold_blocks(unsigned int cpu, unsigned int bank, + unsigned int block, u32 address) { struct threshold_block *b = NULL; u32 low, high; @@ -543,7 +541,7 @@ out_free: return err; } -static __cpuinit int __threshold_add_blocks(struct threshold_bank *b) +static int __threshold_add_blocks(struct threshold_bank *b) { struct list_head *head = &b->blocks->miscj; struct threshold_block *pos = NULL; @@ -567,7 +565,7 @@ static __cpuinit int __threshold_add_blocks(struct threshold_bank *b) return err; } -static __cpuinit int threshold_create_bank(unsigned int cpu, unsigned int bank) +static int threshold_create_bank(unsigned int cpu, unsigned int bank) { struct device *dev = per_cpu(mce_device, cpu); struct amd_northbridge *nb = NULL; @@ -632,7 +630,7 @@ static __cpuinit int threshold_create_bank(unsigned int cpu, unsigned int bank) } /* create dir/files for all valid threshold banks */ -static __cpuinit int threshold_create_device(unsigned int cpu) +static int threshold_create_device(unsigned int cpu) { unsigned int bank; struct threshold_bank **bp; @@ -736,7 +734,7 @@ static void threshold_remove_device(unsigned int cpu) } /* get notified when a cpu comes on/off */ -static void __cpuinit +static void amd_64_threshold_cpu_callback(unsigned long action, unsigned int cpu) { switch (action) { diff --git a/arch/x86/kernel/cpu/mcheck/therm_throt.c b/arch/x86/kernel/cpu/mcheck/therm_throt.c index 41e8e00a6637..3eec7de76efb 100644 --- a/arch/x86/kernel/cpu/mcheck/therm_throt.c +++ b/arch/x86/kernel/cpu/mcheck/therm_throt.c @@ -240,8 +240,7 @@ __setup("int_pln_enable", int_pln_enable_setup); #ifdef CONFIG_SYSFS /* Add/Remove thermal_throttle interface for CPU device: */ -static __cpuinit int thermal_throttle_add_dev(struct device *dev, - unsigned int cpu) +static int thermal_throttle_add_dev(struct device *dev, unsigned int cpu) { int err; struct cpuinfo_x86 *c = &cpu_data(cpu); @@ -267,7 +266,7 @@ static __cpuinit int thermal_throttle_add_dev(struct device *dev, return err; } -static __cpuinit void thermal_throttle_remove_dev(struct device *dev) +static void thermal_throttle_remove_dev(struct device *dev) { sysfs_remove_group(&dev->kobj, &thermal_attr_group); } @@ -276,7 +275,7 @@ static __cpuinit void thermal_throttle_remove_dev(struct device *dev) static DEFINE_MUTEX(therm_cpu_lock); /* Get notified when a cpu comes on/off. Be hotplug friendly. */ -static __cpuinit int +static int thermal_throttle_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu) @@ -307,7 +306,7 @@ thermal_throttle_cpu_callback(struct notifier_block *nfb, return notifier_from_errno(err); } -static struct notifier_block thermal_throttle_cpu_notifier __cpuinitdata = +static struct notifier_block thermal_throttle_cpu_notifier = { .notifier_call = thermal_throttle_cpu_callback, }; diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c index 9e581c5cf6d0..a7c7305030cc 100644 --- a/arch/x86/kernel/cpu/perf_event.c +++ b/arch/x86/kernel/cpu/perf_event.c @@ -1295,7 +1295,7 @@ perf_event_nmi_handler(unsigned int cmd, struct pt_regs *regs) struct event_constraint emptyconstraint; struct event_constraint unconstrained; -static int __cpuinit +static int x86_pmu_notifier(struct notifier_block *self, unsigned long action, void *hcpu) { unsigned int cpu = (long)hcpu; diff --git a/arch/x86/kernel/cpu/perf_event_amd_ibs.c b/arch/x86/kernel/cpu/perf_event_amd_ibs.c index 5f0581e713c2..e09f0bfb7b8f 100644 --- a/arch/x86/kernel/cpu/perf_event_amd_ibs.c +++ b/arch/x86/kernel/cpu/perf_event_amd_ibs.c @@ -851,7 +851,7 @@ static void clear_APIC_ibs(void *dummy) setup_APIC_eilvt(offset, 0, APIC_EILVT_MSG_FIX, 1); } -static int __cpuinit +static int perf_ibs_cpu_notifier(struct notifier_block *self, unsigned long action, void *hcpu) { switch (action & ~CPU_TASKS_FROZEN) { diff --git a/arch/x86/kernel/cpu/perf_event_amd_uncore.c b/arch/x86/kernel/cpu/perf_event_amd_uncore.c index c0c661adf03e..754291adec33 100644 --- a/arch/x86/kernel/cpu/perf_event_amd_uncore.c +++ b/arch/x86/kernel/cpu/perf_event_amd_uncore.c @@ -288,13 +288,13 @@ static struct pmu amd_l2_pmu = { .read = amd_uncore_read, }; -static struct amd_uncore * __cpuinit amd_uncore_alloc(unsigned int cpu) +static struct amd_uncore *amd_uncore_alloc(unsigned int cpu) { return kzalloc_node(sizeof(struct amd_uncore), GFP_KERNEL, cpu_to_node(cpu)); } -static void __cpuinit amd_uncore_cpu_up_prepare(unsigned int cpu) +static void amd_uncore_cpu_up_prepare(unsigned int cpu) { struct amd_uncore *uncore; @@ -322,8 +322,8 @@ static void __cpuinit amd_uncore_cpu_up_prepare(unsigned int cpu) } static struct amd_uncore * -__cpuinit amd_uncore_find_online_sibling(struct amd_uncore *this, - struct amd_uncore * __percpu *uncores) +amd_uncore_find_online_sibling(struct amd_uncore *this, + struct amd_uncore * __percpu *uncores) { unsigned int cpu; struct amd_uncore *that; @@ -348,7 +348,7 @@ __cpuinit amd_uncore_find_online_sibling(struct amd_uncore *this, return this; } -static void __cpuinit amd_uncore_cpu_starting(unsigned int cpu) +static void amd_uncore_cpu_starting(unsigned int cpu) { unsigned int eax, ebx, ecx, edx; struct amd_uncore *uncore; @@ -376,8 +376,8 @@ static void __cpuinit amd_uncore_cpu_starting(unsigned int cpu) } } -static void __cpuinit uncore_online(unsigned int cpu, - struct amd_uncore * __percpu *uncores) +static void uncore_online(unsigned int cpu, + struct amd_uncore * __percpu *uncores) { struct amd_uncore *uncore = *per_cpu_ptr(uncores, cpu); @@ -388,7 +388,7 @@ static void __cpuinit uncore_online(unsigned int cpu, cpumask_set_cpu(cpu, uncore->active_mask); } -static void __cpuinit amd_uncore_cpu_online(unsigned int cpu) +static void amd_uncore_cpu_online(unsigned int cpu) { if (amd_uncore_nb) uncore_online(cpu, amd_uncore_nb); @@ -397,8 +397,8 @@ static void __cpuinit amd_uncore_cpu_online(unsigned int cpu) uncore_online(cpu, amd_uncore_l2); } -static void __cpuinit uncore_down_prepare(unsigned int cpu, - struct amd_uncore * __percpu *uncores) +static void uncore_down_prepare(unsigned int cpu, + struct amd_uncore * __percpu *uncores) { unsigned int i; struct amd_uncore *this = *per_cpu_ptr(uncores, cpu); @@ -423,7 +423,7 @@ static void __cpuinit uncore_down_prepare(unsigned int cpu, } } -static void __cpuinit amd_uncore_cpu_down_prepare(unsigned int cpu) +static void amd_uncore_cpu_down_prepare(unsigned int cpu) { if (amd_uncore_nb) uncore_down_prepare(cpu, amd_uncore_nb); @@ -432,8 +432,7 @@ static void __cpuinit amd_uncore_cpu_down_prepare(unsigned int cpu) uncore_down_prepare(cpu, amd_uncore_l2); } -static void __cpuinit uncore_dead(unsigned int cpu, - struct amd_uncore * __percpu *uncores) +static void uncore_dead(unsigned int cpu, struct amd_uncore * __percpu *uncores) { struct amd_uncore *uncore = *per_cpu_ptr(uncores, cpu); @@ -445,7 +444,7 @@ static void __cpuinit uncore_dead(unsigned int cpu, *per_cpu_ptr(amd_uncore_nb, cpu) = NULL; } -static void __cpuinit amd_uncore_cpu_dead(unsigned int cpu) +static void amd_uncore_cpu_dead(unsigned int cpu) { if (amd_uncore_nb) uncore_dead(cpu, amd_uncore_nb); @@ -454,7 +453,7 @@ static void __cpuinit amd_uncore_cpu_dead(unsigned int cpu) uncore_dead(cpu, amd_uncore_l2); } -static int __cpuinit +static int amd_uncore_cpu_notifier(struct notifier_block *self, unsigned long action, void *hcpu) { @@ -489,7 +488,7 @@ amd_uncore_cpu_notifier(struct notifier_block *self, unsigned long action, return NOTIFY_OK; } -static struct notifier_block amd_uncore_cpu_notifier_block __cpuinitdata = { +static struct notifier_block amd_uncore_cpu_notifier_block = { .notifier_call = amd_uncore_cpu_notifier, .priority = CPU_PRI_PERF + 1, }; diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.c b/arch/x86/kernel/cpu/perf_event_intel_uncore.c index 9dd99751ccf9..cad791dbde95 100644 --- a/arch/x86/kernel/cpu/perf_event_intel_uncore.c +++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.c @@ -3297,7 +3297,7 @@ static void __init uncore_pci_exit(void) /* CPU hot plug/unplug are serialized by cpu_add_remove_lock mutex */ static LIST_HEAD(boxes_to_free); -static void __cpuinit uncore_kfree_boxes(void) +static void uncore_kfree_boxes(void) { struct intel_uncore_box *box; @@ -3309,7 +3309,7 @@ static void __cpuinit uncore_kfree_boxes(void) } } -static void __cpuinit uncore_cpu_dying(int cpu) +static void uncore_cpu_dying(int cpu) { struct intel_uncore_type *type; struct intel_uncore_pmu *pmu; @@ -3328,7 +3328,7 @@ static void __cpuinit uncore_cpu_dying(int cpu) } } -static int __cpuinit uncore_cpu_starting(int cpu) +static int uncore_cpu_starting(int cpu) { struct intel_uncore_type *type; struct intel_uncore_pmu *pmu; @@ -3371,7 +3371,7 @@ static int __cpuinit uncore_cpu_starting(int cpu) return 0; } -static int __cpuinit uncore_cpu_prepare(int cpu, int phys_id) +static int uncore_cpu_prepare(int cpu, int phys_id) { struct intel_uncore_type *type; struct intel_uncore_pmu *pmu; @@ -3397,7 +3397,7 @@ static int __cpuinit uncore_cpu_prepare(int cpu, int phys_id) return 0; } -static void __cpuinit +static void uncore_change_context(struct intel_uncore_type **uncores, int old_cpu, int new_cpu) { struct intel_uncore_type *type; @@ -3435,7 +3435,7 @@ uncore_change_context(struct intel_uncore_type **uncores, int old_cpu, int new_c } } -static void __cpuinit uncore_event_exit_cpu(int cpu) +static void uncore_event_exit_cpu(int cpu) { int i, phys_id, target; @@ -3463,7 +3463,7 @@ static void __cpuinit uncore_event_exit_cpu(int cpu) uncore_change_context(pci_uncores, cpu, target); } -static void __cpuinit uncore_event_init_cpu(int cpu) +static void uncore_event_init_cpu(int cpu) { int i, phys_id; @@ -3479,8 +3479,8 @@ static void __cpuinit uncore_event_init_cpu(int cpu) uncore_change_context(pci_uncores, -1, cpu); } -static int - __cpuinit uncore_cpu_notifier(struct notifier_block *self, unsigned long action, void *hcpu) +static int uncore_cpu_notifier(struct notifier_block *self, + unsigned long action, void *hcpu) { unsigned int cpu = (long)hcpu; @@ -3520,7 +3520,7 @@ static int return NOTIFY_OK; } -static struct notifier_block uncore_cpu_nb __cpuinitdata = { +static struct notifier_block uncore_cpu_nb = { .notifier_call = uncore_cpu_notifier, /* * to migrate uncore events, our notifier should be executed diff --git a/arch/x86/kernel/cpu/rdrand.c b/arch/x86/kernel/cpu/rdrand.c index feca286c2bb4..88db010845cb 100644 --- a/arch/x86/kernel/cpu/rdrand.c +++ b/arch/x86/kernel/cpu/rdrand.c @@ -52,7 +52,7 @@ static inline int rdrand_long(unsigned long *v) */ #define RESEED_LOOP ((512*128)/sizeof(unsigned long)) -void __cpuinit x86_init_rdrand(struct cpuinfo_x86 *c) +void x86_init_rdrand(struct cpuinfo_x86 *c) { #ifdef CONFIG_ARCH_RANDOM unsigned long tmp; diff --git a/arch/x86/kernel/cpu/scattered.c b/arch/x86/kernel/cpu/scattered.c index d92b5dad15dd..f2cc63e9cf08 100644 --- a/arch/x86/kernel/cpu/scattered.c +++ b/arch/x86/kernel/cpu/scattered.c @@ -24,13 +24,13 @@ enum cpuid_regs { CR_EBX }; -void __cpuinit init_scattered_cpuid_features(struct cpuinfo_x86 *c) +void init_scattered_cpuid_features(struct cpuinfo_x86 *c) { u32 max_level; u32 regs[4]; const struct cpuid_bit *cb; - static const struct cpuid_bit __cpuinitconst cpuid_bits[] = { + static const struct cpuid_bit cpuid_bits[] = { { X86_FEATURE_DTHERM, CR_EAX, 0, 0x00000006, 0 }, { X86_FEATURE_IDA, CR_EAX, 1, 0x00000006, 0 }, { X86_FEATURE_ARAT, CR_EAX, 2, 0x00000006, 0 }, diff --git a/arch/x86/kernel/cpu/topology.c b/arch/x86/kernel/cpu/topology.c index 4397e987a1cf..4c60eaf0571c 100644 --- a/arch/x86/kernel/cpu/topology.c +++ b/arch/x86/kernel/cpu/topology.c @@ -26,7 +26,7 @@ * exists, use it for populating initial_apicid and cpu topology * detection. */ -void __cpuinit detect_extended_topology(struct cpuinfo_x86 *c) +void detect_extended_topology(struct cpuinfo_x86 *c) { #ifdef CONFIG_SMP unsigned int eax, ebx, ecx, edx, sub_index; diff --git a/arch/x86/kernel/cpu/transmeta.c b/arch/x86/kernel/cpu/transmeta.c index 28000743bbb0..aa0430d69b90 100644 --- a/arch/x86/kernel/cpu/transmeta.c +++ b/arch/x86/kernel/cpu/transmeta.c @@ -5,7 +5,7 @@ #include #include "cpu.h" -static void __cpuinit early_init_transmeta(struct cpuinfo_x86 *c) +static void early_init_transmeta(struct cpuinfo_x86 *c) { u32 xlvl; @@ -17,7 +17,7 @@ static void __cpuinit early_init_transmeta(struct cpuinfo_x86 *c) } } -static void __cpuinit init_transmeta(struct cpuinfo_x86 *c) +static void init_transmeta(struct cpuinfo_x86 *c) { unsigned int cap_mask, uk, max, dummy; unsigned int cms_rev1, cms_rev2; @@ -98,7 +98,7 @@ static void __cpuinit init_transmeta(struct cpuinfo_x86 *c) #endif } -static const struct cpu_dev __cpuinitconst transmeta_cpu_dev = { +static const struct cpu_dev transmeta_cpu_dev = { .c_vendor = "Transmeta", .c_ident = { "GenuineTMx86", "TransmetaCPU" }, .c_early_init = early_init_transmeta, diff --git a/arch/x86/kernel/cpu/umc.c b/arch/x86/kernel/cpu/umc.c index fd2c37bf7acb..202759a14121 100644 --- a/arch/x86/kernel/cpu/umc.c +++ b/arch/x86/kernel/cpu/umc.c @@ -8,7 +8,7 @@ * so no special init takes place. */ -static const struct cpu_dev __cpuinitconst umc_cpu_dev = { +static const struct cpu_dev umc_cpu_dev = { .c_vendor = "UMC", .c_ident = { "UMC UMC UMC" }, .c_models = { diff --git a/arch/x86/kernel/cpu/vmware.c b/arch/x86/kernel/cpu/vmware.c index 03a36321ec54..7076878404ec 100644 --- a/arch/x86/kernel/cpu/vmware.c +++ b/arch/x86/kernel/cpu/vmware.c @@ -122,7 +122,7 @@ static bool __init vmware_platform(void) * so that the kernel could just trust the hypervisor with providing a * reliable virtual TSC that is suitable for timekeeping. */ -static void __cpuinit vmware_set_cpu_features(struct cpuinfo_x86 *c) +static void vmware_set_cpu_features(struct cpuinfo_x86 *c) { set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC); set_cpu_cap(c, X86_FEATURE_TSC_RELIABLE); diff --git a/arch/x86/kernel/cpuid.c b/arch/x86/kernel/cpuid.c index 1e4dbcfe6d31..7d9481c743f8 100644 --- a/arch/x86/kernel/cpuid.c +++ b/arch/x86/kernel/cpuid.c @@ -137,7 +137,7 @@ static const struct file_operations cpuid_fops = { .open = cpuid_open, }; -static __cpuinit int cpuid_device_create(int cpu) +static int cpuid_device_create(int cpu) { struct device *dev; @@ -151,9 +151,8 @@ static void cpuid_device_destroy(int cpu) device_destroy(cpuid_class, MKDEV(CPUID_MAJOR, cpu)); } -static int __cpuinit cpuid_class_cpu_callback(struct notifier_block *nfb, - unsigned long action, - void *hcpu) +static int cpuid_class_cpu_callback(struct notifier_block *nfb, + unsigned long action, void *hcpu) { unsigned int cpu = (unsigned long)hcpu; int err = 0; diff --git a/arch/x86/kernel/devicetree.c b/arch/x86/kernel/devicetree.c index 4934890e4db2..69eb2fa25494 100644 --- a/arch/x86/kernel/devicetree.c +++ b/arch/x86/kernel/devicetree.c @@ -133,7 +133,7 @@ static void x86_of_pci_irq_disable(struct pci_dev *dev) { } -void __cpuinit x86_of_pci_init(void) +void x86_of_pci_init(void) { pcibios_enable_irq = x86_of_pci_irq_enable; pcibios_disable_irq = x86_of_pci_irq_disable; diff --git a/arch/x86/kernel/head_32.S b/arch/x86/kernel/head_32.S index e65ddc62e113..5dd87a89f011 100644 --- a/arch/x86/kernel/head_32.S +++ b/arch/x86/kernel/head_32.S @@ -292,7 +292,6 @@ ENDPROC(start_cpu0) * If cpu hotplug is not supported then this code can go in init section * which will be freed later */ -__CPUINIT ENTRY(startup_32_smp) cld movl $(__BOOT_DS),%eax diff --git a/arch/x86/kernel/i387.c b/arch/x86/kernel/i387.c index b627746f6b1a..202d24f0f7e7 100644 --- a/arch/x86/kernel/i387.c +++ b/arch/x86/kernel/i387.c @@ -108,9 +108,9 @@ EXPORT_SYMBOL(unlazy_fpu); unsigned int mxcsr_feature_mask __read_mostly = 0xffffffffu; unsigned int xstate_size; EXPORT_SYMBOL_GPL(xstate_size); -static struct i387_fxsave_struct fx_scratch __cpuinitdata; +static struct i387_fxsave_struct fx_scratch; -static void __cpuinit mxcsr_feature_mask_init(void) +static void mxcsr_feature_mask_init(void) { unsigned long mask = 0; @@ -124,7 +124,7 @@ static void __cpuinit mxcsr_feature_mask_init(void) mxcsr_feature_mask &= mask; } -static void __cpuinit init_thread_xstate(void) +static void init_thread_xstate(void) { /* * Note that xstate_size might be overwriten later during @@ -153,7 +153,7 @@ static void __cpuinit init_thread_xstate(void) * into all processes. */ -void __cpuinit fpu_init(void) +void fpu_init(void) { unsigned long cr0; unsigned long cr4_mask = 0; @@ -608,7 +608,7 @@ static int __init no_387(char *s) __setup("no387", no_387); -void __cpuinit fpu_detect(struct cpuinfo_x86 *c) +void fpu_detect(struct cpuinfo_x86 *c) { unsigned long cr0; u16 fsw, fcw; diff --git a/arch/x86/kernel/irq_32.c b/arch/x86/kernel/irq_32.c index 344faf8d0d62..4186755f1d7c 100644 --- a/arch/x86/kernel/irq_32.c +++ b/arch/x86/kernel/irq_32.c @@ -119,7 +119,7 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq) /* * allocate per-cpu stacks for hardirq and for softirq processing */ -void __cpuinit irq_ctx_init(int cpu) +void irq_ctx_init(int cpu) { union irq_ctx *irqctx; diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c index cd6d9a5a42f6..a96d32cc55b8 100644 --- a/arch/x86/kernel/kvm.c +++ b/arch/x86/kernel/kvm.c @@ -320,7 +320,7 @@ static void kvm_guest_apic_eoi_write(u32 reg, u32 val) apic_write(APIC_EOI, APIC_EOI_ACK); } -void __cpuinit kvm_guest_cpu_init(void) +void kvm_guest_cpu_init(void) { if (!kvm_para_available()) return; @@ -421,7 +421,7 @@ static void __init kvm_smp_prepare_boot_cpu(void) native_smp_prepare_boot_cpu(); } -static void __cpuinit kvm_guest_cpu_online(void *dummy) +static void kvm_guest_cpu_online(void *dummy) { kvm_guest_cpu_init(); } @@ -435,8 +435,8 @@ static void kvm_guest_cpu_offline(void *dummy) apf_task_wake_all(); } -static int __cpuinit kvm_cpu_notify(struct notifier_block *self, - unsigned long action, void *hcpu) +static int kvm_cpu_notify(struct notifier_block *self, unsigned long action, + void *hcpu) { int cpu = (unsigned long)hcpu; switch (action) { @@ -455,7 +455,7 @@ static int __cpuinit kvm_cpu_notify(struct notifier_block *self, return NOTIFY_OK; } -static struct notifier_block __cpuinitdata kvm_cpu_notifier = { +static struct notifier_block kvm_cpu_notifier = { .notifier_call = kvm_cpu_notify, }; #endif diff --git a/arch/x86/kernel/kvmclock.c b/arch/x86/kernel/kvmclock.c index 1f354f4b602b..1570e0741344 100644 --- a/arch/x86/kernel/kvmclock.c +++ b/arch/x86/kernel/kvmclock.c @@ -182,7 +182,7 @@ static void kvm_restore_sched_clock_state(void) } #ifdef CONFIG_X86_LOCAL_APIC -static void __cpuinit kvm_setup_secondary_clock(void) +static void kvm_setup_secondary_clock(void) { /* * Now that the first cpu already had this clocksource initialized, diff --git a/arch/x86/kernel/microcode_amd_early.c b/arch/x86/kernel/microcode_amd_early.c index 1ac6e9aee766..1d14ffee5749 100644 --- a/arch/x86/kernel/microcode_amd_early.c +++ b/arch/x86/kernel/microcode_amd_early.c @@ -82,7 +82,7 @@ static struct cpio_data __init find_ucode_in_initrd(void) * load_microcode_amd() to save equivalent cpu table and microcode patches in * kernel heap memory. */ -static void __cpuinit apply_ucode_in_initrd(void *ucode, size_t size) +static void apply_ucode_in_initrd(void *ucode, size_t size) { struct equiv_cpu_entry *eq; u32 *header; @@ -206,7 +206,7 @@ u8 amd_bsp_mpb[MPB_MAX_SIZE]; * save_microcode_in_initrd_amd() BSP's patch is copied to amd_bsp_mpb, which * is used upon resume from suspend. */ -void __cpuinit load_ucode_amd_ap(void) +void load_ucode_amd_ap(void) { struct microcode_amd *mc; unsigned long *initrd; @@ -238,7 +238,7 @@ static void __init collect_cpu_sig_on_bsp(void *arg) uci->cpu_sig.sig = cpuid_eax(0x00000001); } #else -static void __cpuinit collect_cpu_info_amd_early(struct cpuinfo_x86 *c, +static void collect_cpu_info_amd_early(struct cpuinfo_x86 *c, struct ucode_cpu_info *uci) { u32 rev, eax; @@ -252,7 +252,7 @@ static void __cpuinit collect_cpu_info_amd_early(struct cpuinfo_x86 *c, c->x86 = ((eax >> 8) & 0xf) + ((eax >> 20) & 0xff); } -void __cpuinit load_ucode_amd_ap(void) +void load_ucode_amd_ap(void) { unsigned int cpu = smp_processor_id(); diff --git a/arch/x86/kernel/microcode_core.c b/arch/x86/kernel/microcode_core.c index 22db92bbdf1a..15c987698b0f 100644 --- a/arch/x86/kernel/microcode_core.c +++ b/arch/x86/kernel/microcode_core.c @@ -468,7 +468,7 @@ static struct syscore_ops mc_syscore_ops = { .resume = mc_bp_resume, }; -static __cpuinit int +static int mc_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu) { unsigned int cpu = (unsigned long)hcpu; diff --git a/arch/x86/kernel/microcode_core_early.c b/arch/x86/kernel/microcode_core_early.c index 86119f63db0c..be7f8514f577 100644 --- a/arch/x86/kernel/microcode_core_early.c +++ b/arch/x86/kernel/microcode_core_early.c @@ -41,7 +41,7 @@ * * x86_vendor() gets vendor information directly through cpuid. */ -static int __cpuinit x86_vendor(void) +static int x86_vendor(void) { u32 eax = 0x00000000; u32 ebx, ecx = 0, edx; @@ -57,7 +57,7 @@ static int __cpuinit x86_vendor(void) return X86_VENDOR_UNKNOWN; } -static int __cpuinit x86_family(void) +static int x86_family(void) { u32 eax = 0x00000001; u32 ebx, ecx = 0, edx; @@ -96,7 +96,7 @@ void __init load_ucode_bsp(void) } } -void __cpuinit load_ucode_ap(void) +void load_ucode_ap(void) { int vendor, x86; diff --git a/arch/x86/kernel/microcode_intel_early.c b/arch/x86/kernel/microcode_intel_early.c index dabef95506f3..1575deb2e636 100644 --- a/arch/x86/kernel/microcode_intel_early.c +++ b/arch/x86/kernel/microcode_intel_early.c @@ -34,7 +34,7 @@ struct mc_saved_data { struct microcode_intel **mc_saved; } mc_saved_data; -static enum ucode_state __cpuinit +static enum ucode_state generic_load_microcode_early(struct microcode_intel **mc_saved_p, unsigned int mc_saved_count, struct ucode_cpu_info *uci) @@ -69,7 +69,7 @@ out: return state; } -static void __cpuinit +static void microcode_pointer(struct microcode_intel **mc_saved, unsigned long *mc_saved_in_initrd, unsigned long initrd_start, int mc_saved_count) @@ -82,7 +82,7 @@ microcode_pointer(struct microcode_intel **mc_saved, } #ifdef CONFIG_X86_32 -static void __cpuinit +static void microcode_phys(struct microcode_intel **mc_saved_tmp, struct mc_saved_data *mc_saved_data) { @@ -101,7 +101,7 @@ microcode_phys(struct microcode_intel **mc_saved_tmp, } #endif -static enum ucode_state __cpuinit +static enum ucode_state load_microcode(struct mc_saved_data *mc_saved_data, unsigned long *mc_saved_in_initrd, unsigned long initrd_start, @@ -375,7 +375,7 @@ do { \ #define native_wrmsr(msr, low, high) \ native_write_msr(msr, low, high); -static int __cpuinit collect_cpu_info_early(struct ucode_cpu_info *uci) +static int collect_cpu_info_early(struct ucode_cpu_info *uci) { unsigned int val[2]; u8 x86, x86_model; @@ -584,7 +584,7 @@ scan_microcode(unsigned long start, unsigned long end, /* * Print ucode update info. */ -static void __cpuinit +static void print_ucode_info(struct ucode_cpu_info *uci, unsigned int date) { int cpu = smp_processor_id(); @@ -605,7 +605,7 @@ static int current_mc_date; /* * Print early updated ucode info after printk works. This is delayed info dump. */ -void __cpuinit show_ucode_info_early(void) +void show_ucode_info_early(void) { struct ucode_cpu_info uci; @@ -621,7 +621,7 @@ void __cpuinit show_ucode_info_early(void) * mc_saved_data.mc_saved and delay printing microcode info in * show_ucode_info_early() until printk() works. */ -static void __cpuinit print_ucode(struct ucode_cpu_info *uci) +static void print_ucode(struct ucode_cpu_info *uci) { struct microcode_intel *mc_intel; int *delay_ucode_info_p; @@ -643,12 +643,12 @@ static void __cpuinit print_ucode(struct ucode_cpu_info *uci) * Flush global tlb. We only do this in x86_64 where paging has been enabled * already and PGE should be enabled as well. */ -static inline void __cpuinit flush_tlb_early(void) +static inline void flush_tlb_early(void) { __native_flush_tlb_global_irq_disabled(); } -static inline void __cpuinit print_ucode(struct ucode_cpu_info *uci) +static inline void print_ucode(struct ucode_cpu_info *uci) { struct microcode_intel *mc_intel; @@ -660,8 +660,8 @@ static inline void __cpuinit print_ucode(struct ucode_cpu_info *uci) } #endif -static int __cpuinit apply_microcode_early(struct mc_saved_data *mc_saved_data, - struct ucode_cpu_info *uci) +static int apply_microcode_early(struct mc_saved_data *mc_saved_data, + struct ucode_cpu_info *uci) { struct microcode_intel *mc_intel; unsigned int val[2]; @@ -763,7 +763,7 @@ load_ucode_intel_bsp(void) #endif } -void __cpuinit load_ucode_intel_ap(void) +void load_ucode_intel_ap(void) { struct mc_saved_data *mc_saved_data_p; struct ucode_cpu_info uci; diff --git a/arch/x86/kernel/mmconf-fam10h_64.c b/arch/x86/kernel/mmconf-fam10h_64.c index ac861b8348e2..f4c886d9165c 100644 --- a/arch/x86/kernel/mmconf-fam10h_64.c +++ b/arch/x86/kernel/mmconf-fam10h_64.c @@ -24,14 +24,14 @@ struct pci_hostbridge_probe { u32 device; }; -static u64 __cpuinitdata fam10h_pci_mmconf_base; +static u64 fam10h_pci_mmconf_base; -static struct pci_hostbridge_probe pci_probes[] __cpuinitdata = { +static struct pci_hostbridge_probe pci_probes[] = { { 0, 0x18, PCI_VENDOR_ID_AMD, 0x1200 }, { 0xff, 0, PCI_VENDOR_ID_AMD, 0x1200 }, }; -static int __cpuinit cmp_range(const void *x1, const void *x2) +static int cmp_range(const void *x1, const void *x2) { const struct range *r1 = x1; const struct range *r2 = x2; @@ -49,7 +49,7 @@ static int __cpuinit cmp_range(const void *x1, const void *x2) /* need to avoid (0xfd<<32), (0xfe<<32), and (0xff<<32), ht used space */ #define FAM10H_PCI_MMCONF_BASE (0xfcULL<<32) #define BASE_VALID(b) ((b) + MMCONF_SIZE <= (0xfdULL<<32) || (b) >= (1ULL<<40)) -static void __cpuinit get_fam10h_pci_mmconf_base(void) +static void get_fam10h_pci_mmconf_base(void) { int i; unsigned bus; @@ -166,7 +166,7 @@ out: fam10h_pci_mmconf_base = base; } -void __cpuinit fam10h_check_enable_mmcfg(void) +void fam10h_check_enable_mmcfg(void) { u64 val; u32 address; @@ -230,7 +230,7 @@ static const struct dmi_system_id __initconst mmconf_dmi_table[] = { {} }; -/* Called from a __cpuinit function, but only on the BSP. */ +/* Called from a non __init function, but only on the BSP. */ void __ref check_enable_amd_mmconf_dmi(void) { dmi_check_system(mmconf_dmi_table); diff --git a/arch/x86/kernel/msr.c b/arch/x86/kernel/msr.c index ce130493b802..88458faea2f8 100644 --- a/arch/x86/kernel/msr.c +++ b/arch/x86/kernel/msr.c @@ -200,7 +200,7 @@ static const struct file_operations msr_fops = { .compat_ioctl = msr_ioctl, }; -static int __cpuinit msr_device_create(int cpu) +static int msr_device_create(int cpu) { struct device *dev; @@ -214,8 +214,8 @@ static void msr_device_destroy(int cpu) device_destroy(msr_class, MKDEV(MSR_MAJOR, cpu)); } -static int __cpuinit msr_class_cpu_callback(struct notifier_block *nfb, - unsigned long action, void *hcpu) +static int msr_class_cpu_callback(struct notifier_block *nfb, + unsigned long action, void *hcpu) { unsigned int cpu = (unsigned long)hcpu; int err = 0; diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c index 81a5f5e8f142..83369e5a1d27 100644 --- a/arch/x86/kernel/process.c +++ b/arch/x86/kernel/process.c @@ -398,7 +398,7 @@ static void amd_e400_idle(void) default_idle(); } -void __cpuinit select_idle_routine(const struct cpuinfo_x86 *c) +void select_idle_routine(const struct cpuinfo_x86 *c) { #ifdef CONFIG_SMP if (boot_option_idle_override == IDLE_POLL && smp_num_siblings > 1) diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c index e68709da8251..f8ec57815c05 100644 --- a/arch/x86/kernel/setup.c +++ b/arch/x86/kernel/setup.c @@ -170,7 +170,7 @@ static struct resource bss_resource = { #ifdef CONFIG_X86_32 /* cpu data as detected by the assembly code in head.S */ -struct cpuinfo_x86 new_cpu_data __cpuinitdata = { +struct cpuinfo_x86 new_cpu_data = { .wp_works_ok = -1, }; /* common cpu data for all cpus */ diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c index bfd348e99369..aecc98a93d1b 100644 --- a/arch/x86/kernel/smpboot.c +++ b/arch/x86/kernel/smpboot.c @@ -130,7 +130,7 @@ atomic_t init_deasserted; * Report back to the Boot Processor during boot time or to the caller processor * during CPU online. */ -static void __cpuinit smp_callin(void) +static void smp_callin(void) { int cpuid, phys_id; unsigned long timeout; @@ -237,7 +237,7 @@ static int enable_start_cpu0; /* * Activate a secondary processor. */ -notrace static void __cpuinit start_secondary(void *unused) +static void notrace start_secondary(void *unused) { /* * Don't put *anything* before cpu_init(), SMP booting is too @@ -300,7 +300,7 @@ void __init smp_store_boot_cpu_info(void) * The bootstrap kernel entry code has set these up. Save them for * a given CPU */ -void __cpuinit smp_store_cpu_info(int id) +void smp_store_cpu_info(int id) { struct cpuinfo_x86 *c = &cpu_data(id); @@ -313,7 +313,7 @@ void __cpuinit smp_store_cpu_info(int id) identify_secondary_cpu(c); } -static bool __cpuinit +static bool topology_sane(struct cpuinfo_x86 *c, struct cpuinfo_x86 *o, const char *name) { int cpu1 = c->cpu_index, cpu2 = o->cpu_index; @@ -330,7 +330,7 @@ do { \ cpumask_set_cpu((c2), cpu_##_m##_mask(c1)); \ } while (0) -static bool __cpuinit match_smt(struct cpuinfo_x86 *c, struct cpuinfo_x86 *o) +static bool match_smt(struct cpuinfo_x86 *c, struct cpuinfo_x86 *o) { if (cpu_has_topoext) { int cpu1 = c->cpu_index, cpu2 = o->cpu_index; @@ -348,7 +348,7 @@ static bool __cpuinit match_smt(struct cpuinfo_x86 *c, struct cpuinfo_x86 *o) return false; } -static bool __cpuinit match_llc(struct cpuinfo_x86 *c, struct cpuinfo_x86 *o) +static bool match_llc(struct cpuinfo_x86 *c, struct cpuinfo_x86 *o) { int cpu1 = c->cpu_index, cpu2 = o->cpu_index; @@ -359,7 +359,7 @@ static bool __cpuinit match_llc(struct cpuinfo_x86 *c, struct cpuinfo_x86 *o) return false; } -static bool __cpuinit match_mc(struct cpuinfo_x86 *c, struct cpuinfo_x86 *o) +static bool match_mc(struct cpuinfo_x86 *c, struct cpuinfo_x86 *o) { if (c->phys_proc_id == o->phys_proc_id) { if (cpu_has(c, X86_FEATURE_AMD_DCM)) @@ -370,7 +370,7 @@ static bool __cpuinit match_mc(struct cpuinfo_x86 *c, struct cpuinfo_x86 *o) return false; } -void __cpuinit set_cpu_sibling_map(int cpu) +void set_cpu_sibling_map(int cpu) { bool has_smt = smp_num_siblings > 1; bool has_mp = has_smt || boot_cpu_data.x86_max_cores > 1; @@ -499,7 +499,7 @@ void __inquire_remote_apic(int apicid) * INIT, INIT, STARTUP sequence will reset the chip hard for us, and this * won't ... remember to clear down the APIC, etc later. */ -int __cpuinit +int wakeup_secondary_cpu_via_nmi(int apicid, unsigned long start_eip) { unsigned long send_status, accept_status = 0; @@ -533,7 +533,7 @@ wakeup_secondary_cpu_via_nmi(int apicid, unsigned long start_eip) return (send_status | accept_status); } -static int __cpuinit +static int wakeup_secondary_cpu_via_init(int phys_apicid, unsigned long start_eip) { unsigned long send_status, accept_status = 0; @@ -649,7 +649,7 @@ wakeup_secondary_cpu_via_init(int phys_apicid, unsigned long start_eip) } /* reduce the number of lines printed when booting a large cpu count system */ -static void __cpuinit announce_cpu(int cpu, int apicid) +static void announce_cpu(int cpu, int apicid) { static int current_node = -1; int node = early_cpu_to_node(cpu); @@ -691,7 +691,7 @@ static int wakeup_cpu0_nmi(unsigned int cmd, struct pt_regs *regs) * We'll change this code in the future to wake up hard offlined CPU0 if * real platform and request are available. */ -static int __cpuinit +static int wakeup_cpu_via_init_nmi(int cpu, unsigned long start_ip, int apicid, int *cpu0_nmi_registered) { @@ -731,7 +731,7 @@ wakeup_cpu_via_init_nmi(int cpu, unsigned long start_ip, int apicid, * Returns zero if CPU booted OK, else error code from * ->wakeup_secondary_cpu. */ -static int __cpuinit do_boot_cpu(int apicid, int cpu, struct task_struct *idle) +static int do_boot_cpu(int apicid, int cpu, struct task_struct *idle) { volatile u32 *trampoline_status = (volatile u32 *) __va(real_mode_header->trampoline_status); @@ -872,7 +872,7 @@ static int __cpuinit do_boot_cpu(int apicid, int cpu, struct task_struct *idle) return boot_error; } -int __cpuinit native_cpu_up(unsigned int cpu, struct task_struct *tidle) +int native_cpu_up(unsigned int cpu, struct task_struct *tidle) { int apicid = apic->cpu_present_to_apicid(cpu); unsigned long flags; diff --git a/arch/x86/kernel/tboot.c b/arch/x86/kernel/tboot.c index 3ff42d2f046d..addf7b58f4e8 100644 --- a/arch/x86/kernel/tboot.c +++ b/arch/x86/kernel/tboot.c @@ -320,8 +320,8 @@ static int tboot_wait_for_aps(int num_aps) return !(atomic_read((atomic_t *)&tboot->num_in_wfs) == num_aps); } -static int __cpuinit tboot_cpu_callback(struct notifier_block *nfb, - unsigned long action, void *hcpu) +static int tboot_cpu_callback(struct notifier_block *nfb, unsigned long action, + void *hcpu) { switch (action) { case CPU_DYING: @@ -334,7 +334,7 @@ static int __cpuinit tboot_cpu_callback(struct notifier_block *nfb, return NOTIFY_OK; } -static struct notifier_block tboot_cpu_notifier __cpuinitdata = +static struct notifier_block tboot_cpu_notifier = { .notifier_call = tboot_cpu_callback, }; diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c index 098b3cfda72e..6ff49247edf8 100644 --- a/arch/x86/kernel/tsc.c +++ b/arch/x86/kernel/tsc.c @@ -824,7 +824,7 @@ static void __init check_system_tsc_reliable(void) * Make an educated guess if the TSC is trustworthy and synchronized * over all CPUs. */ -__cpuinit int unsynchronized_tsc(void) +int unsynchronized_tsc(void) { if (!cpu_has_tsc || tsc_unstable) return 1; @@ -1020,7 +1020,7 @@ void __init tsc_init(void) * been calibrated. This assumes that CONSTANT_TSC applies to all * cpus in the socket - this should be a safe assumption. */ -unsigned long __cpuinit calibrate_delay_is_known(void) +unsigned long calibrate_delay_is_known(void) { int i, cpu = smp_processor_id(); diff --git a/arch/x86/kernel/tsc_sync.c b/arch/x86/kernel/tsc_sync.c index fc25e60a5884..adfdf56a3714 100644 --- a/arch/x86/kernel/tsc_sync.c +++ b/arch/x86/kernel/tsc_sync.c @@ -25,24 +25,24 @@ * Entry/exit counters that make sure that both CPUs * run the measurement code at once: */ -static __cpuinitdata atomic_t start_count; -static __cpuinitdata atomic_t stop_count; +static atomic_t start_count; +static atomic_t stop_count; /* * We use a raw spinlock in this exceptional case, because * we want to have the fastest, inlined, non-debug version * of a critical section, to be able to prove TSC time-warps: */ -static __cpuinitdata arch_spinlock_t sync_lock = __ARCH_SPIN_LOCK_UNLOCKED; +static arch_spinlock_t sync_lock = __ARCH_SPIN_LOCK_UNLOCKED; -static __cpuinitdata cycles_t last_tsc; -static __cpuinitdata cycles_t max_warp; -static __cpuinitdata int nr_warps; +static cycles_t last_tsc; +static cycles_t max_warp; +static int nr_warps; /* * TSC-warp measurement loop running on both CPUs: */ -static __cpuinit void check_tsc_warp(unsigned int timeout) +static void check_tsc_warp(unsigned int timeout) { cycles_t start, now, prev, end; int i; @@ -121,7 +121,7 @@ static inline unsigned int loop_timeout(int cpu) * Source CPU calls into this - it waits for the freshly booted * target CPU to arrive and then starts the measurement: */ -void __cpuinit check_tsc_sync_source(int cpu) +void check_tsc_sync_source(int cpu) { int cpus = 2; @@ -187,7 +187,7 @@ void __cpuinit check_tsc_sync_source(int cpu) /* * Freshly booted CPUs call into this: */ -void __cpuinit check_tsc_sync_target(void) +void check_tsc_sync_target(void) { int cpus = 2; diff --git a/arch/x86/kernel/vsyscall_64.c b/arch/x86/kernel/vsyscall_64.c index 9a907a67be8f..1f96f9347ed9 100644 --- a/arch/x86/kernel/vsyscall_64.c +++ b/arch/x86/kernel/vsyscall_64.c @@ -331,7 +331,7 @@ sigsegv: * Assume __initcall executes before all user space. Hopefully kmod * doesn't violate that. We'll find out if it does. */ -static void __cpuinit vsyscall_set_cpu(int cpu) +static void vsyscall_set_cpu(int cpu) { unsigned long d; unsigned long node = 0; @@ -353,13 +353,13 @@ static void __cpuinit vsyscall_set_cpu(int cpu) write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_PER_CPU, &d, DESCTYPE_S); } -static void __cpuinit cpu_vsyscall_init(void *arg) +static void cpu_vsyscall_init(void *arg) { /* preemption should be already off */ vsyscall_set_cpu(raw_smp_processor_id()); } -static int __cpuinit +static int cpu_vsyscall_notifier(struct notifier_block *n, unsigned long action, void *arg) { long cpu = (long)arg; diff --git a/arch/x86/kernel/x86_init.c b/arch/x86/kernel/x86_init.c index 45a14dbbddaf..5f24c71accaa 100644 --- a/arch/x86/kernel/x86_init.c +++ b/arch/x86/kernel/x86_init.c @@ -25,7 +25,7 @@ #include #include -void __cpuinit x86_init_noop(void) { } +void x86_init_noop(void) { } void __init x86_init_uint_noop(unsigned int unused) { } int __init iommu_init_noop(void) { return 0; } void iommu_shutdown_noop(void) { } @@ -85,7 +85,7 @@ struct x86_init_ops x86_init __initdata = { }, }; -struct x86_cpuinit_ops x86_cpuinit __cpuinitdata = { +struct x86_cpuinit_ops x86_cpuinit = { .early_percpu_clock_init = x86_init_noop, .setup_percpu_clockev = setup_secondary_APIC_clock, }; diff --git a/arch/x86/kernel/xsave.c b/arch/x86/kernel/xsave.c index d6c28acdf99c..422fd8223470 100644 --- a/arch/x86/kernel/xsave.c +++ b/arch/x86/kernel/xsave.c @@ -573,7 +573,7 @@ static void __init xstate_enable_boot_cpu(void) * This is somewhat obfuscated due to the lack of powerful enough * overrides for the section checks. */ -void __cpuinit xsave_init(void) +void xsave_init(void) { static __refdata void (*next_func)(void) = xstate_enable_boot_cpu; void (*this_func)(void); @@ -594,7 +594,7 @@ static inline void __init eager_fpu_init_bp(void) setup_init_fpu_buf(); } -void __cpuinit eager_fpu_init(void) +void eager_fpu_init(void) { static __refdata void (*boot_func)(void) = eager_fpu_init_bp; diff --git a/arch/x86/mm/mmio-mod.c b/arch/x86/mm/mmio-mod.c index dc0b727742f4..0057a7accfb1 100644 --- a/arch/x86/mm/mmio-mod.c +++ b/arch/x86/mm/mmio-mod.c @@ -410,9 +410,7 @@ out: pr_warning("multiple CPUs still online, may miss events.\n"); } -/* __ref because leave_uniprocessor calls cpu_up which is __cpuinit, - but this whole function is ifdefed CONFIG_HOTPLUG_CPU */ -static void __ref leave_uniprocessor(void) +static void leave_uniprocessor(void) { int cpu; int err; diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c index a71c4e207679..8bf93bae1f13 100644 --- a/arch/x86/mm/numa.c +++ b/arch/x86/mm/numa.c @@ -60,7 +60,7 @@ s16 __apicid_to_node[MAX_LOCAL_APIC] = { [0 ... MAX_LOCAL_APIC-1] = NUMA_NO_NODE }; -int __cpuinit numa_cpu_node(int cpu) +int numa_cpu_node(int cpu) { int apicid = early_per_cpu(x86_cpu_to_apicid, cpu); @@ -691,12 +691,12 @@ void __init init_cpu_to_node(void) #ifndef CONFIG_DEBUG_PER_CPU_MAPS # ifndef CONFIG_NUMA_EMU -void __cpuinit numa_add_cpu(int cpu) +void numa_add_cpu(int cpu) { cpumask_set_cpu(cpu, node_to_cpumask_map[early_cpu_to_node(cpu)]); } -void __cpuinit numa_remove_cpu(int cpu) +void numa_remove_cpu(int cpu) { cpumask_clear_cpu(cpu, node_to_cpumask_map[early_cpu_to_node(cpu)]); } @@ -763,17 +763,17 @@ void debug_cpumask_set_cpu(int cpu, int node, bool enable) } # ifndef CONFIG_NUMA_EMU -static void __cpuinit numa_set_cpumask(int cpu, bool enable) +static void numa_set_cpumask(int cpu, bool enable) { debug_cpumask_set_cpu(cpu, early_cpu_to_node(cpu), enable); } -void __cpuinit numa_add_cpu(int cpu) +void numa_add_cpu(int cpu) { numa_set_cpumask(cpu, true); } -void __cpuinit numa_remove_cpu(int cpu) +void numa_remove_cpu(int cpu) { numa_set_cpumask(cpu, false); } diff --git a/arch/x86/mm/numa_emulation.c b/arch/x86/mm/numa_emulation.c index dbbbb47260cc..a8f90ce3dedf 100644 --- a/arch/x86/mm/numa_emulation.c +++ b/arch/x86/mm/numa_emulation.c @@ -10,7 +10,7 @@ #include "numa_internal.h" -static int emu_nid_to_phys[MAX_NUMNODES] __cpuinitdata; +static int emu_nid_to_phys[MAX_NUMNODES]; static char *emu_cmdline __initdata; void __init numa_emu_cmdline(char *str) @@ -444,7 +444,7 @@ no_emu: } #ifndef CONFIG_DEBUG_PER_CPU_MAPS -void __cpuinit numa_add_cpu(int cpu) +void numa_add_cpu(int cpu) { int physnid, nid; @@ -462,7 +462,7 @@ void __cpuinit numa_add_cpu(int cpu) cpumask_set_cpu(cpu, node_to_cpumask_map[nid]); } -void __cpuinit numa_remove_cpu(int cpu) +void numa_remove_cpu(int cpu) { int i; @@ -470,7 +470,7 @@ void __cpuinit numa_remove_cpu(int cpu) cpumask_clear_cpu(cpu, node_to_cpumask_map[i]); } #else /* !CONFIG_DEBUG_PER_CPU_MAPS */ -static void __cpuinit numa_set_cpumask(int cpu, bool enable) +static void numa_set_cpumask(int cpu, bool enable) { int nid, physnid; @@ -490,12 +490,12 @@ static void __cpuinit numa_set_cpumask(int cpu, bool enable) } } -void __cpuinit numa_add_cpu(int cpu) +void numa_add_cpu(int cpu) { numa_set_cpumask(cpu, true); } -void __cpuinit numa_remove_cpu(int cpu) +void numa_remove_cpu(int cpu) { numa_set_cpumask(cpu, false); } diff --git a/arch/x86/mm/setup_nx.c b/arch/x86/mm/setup_nx.c index 410531d3c292..90555bf60aa4 100644 --- a/arch/x86/mm/setup_nx.c +++ b/arch/x86/mm/setup_nx.c @@ -5,7 +5,7 @@ #include #include -static int disable_nx __cpuinitdata; +static int disable_nx; /* * noexec = on|off @@ -29,7 +29,7 @@ static int __init noexec_setup(char *str) } early_param("noexec", noexec_setup); -void __cpuinit x86_configure_nx(void) +void x86_configure_nx(void) { if (cpu_has_nx && !disable_nx) __supported_pte_mask |= _PAGE_NX; diff --git a/arch/x86/pci/amd_bus.c b/arch/x86/pci/amd_bus.c index e9e6ed5cdf94..a48be98e9ded 100644 --- a/arch/x86/pci/amd_bus.c +++ b/arch/x86/pci/amd_bus.c @@ -312,7 +312,7 @@ static int __init early_fill_mp_bus_info(void) #define ENABLE_CF8_EXT_CFG (1ULL << 46) -static void __cpuinit enable_pci_io_ecs(void *unused) +static void enable_pci_io_ecs(void *unused) { u64 reg; rdmsrl(MSR_AMD64_NB_CFG, reg); @@ -322,8 +322,8 @@ static void __cpuinit enable_pci_io_ecs(void *unused) } } -static int __cpuinit amd_cpu_notify(struct notifier_block *self, - unsigned long action, void *hcpu) +static int amd_cpu_notify(struct notifier_block *self, unsigned long action, + void *hcpu) { int cpu = (long)hcpu; switch (action) { @@ -337,7 +337,7 @@ static int __cpuinit amd_cpu_notify(struct notifier_block *self, return NOTIFY_OK; } -static struct notifier_block __cpuinitdata amd_cpu_notifier = { +static struct notifier_block amd_cpu_notifier = { .notifier_call = amd_cpu_notify, }; diff --git a/arch/x86/platform/ce4100/ce4100.c b/arch/x86/platform/ce4100/ce4100.c index f8ab4945892e..baec704231b3 100644 --- a/arch/x86/platform/ce4100/ce4100.c +++ b/arch/x86/platform/ce4100/ce4100.c @@ -134,7 +134,7 @@ static void __init sdv_arch_setup(void) } #ifdef CONFIG_X86_IO_APIC -static void __cpuinit sdv_pci_init(void) +static void sdv_pci_init(void) { x86_of_pci_init(); /* We can't set this earlier, because we need to calibrate the timer */ diff --git a/arch/x86/platform/mrst/mrst.c b/arch/x86/platform/mrst/mrst.c index a0a0a4389bbd..47fe66fe61f1 100644 --- a/arch/x86/platform/mrst/mrst.c +++ b/arch/x86/platform/mrst/mrst.c @@ -65,7 +65,7 @@ * lapic (always-on,ARAT) ------ 150 */ -__cpuinitdata enum mrst_timer_options mrst_timer_options; +enum mrst_timer_options mrst_timer_options; static u32 sfi_mtimer_usage[SFI_MTMR_MAX_NUM]; static struct sfi_timer_table_entry sfi_mtimer_array[SFI_MTMR_MAX_NUM]; @@ -248,7 +248,7 @@ static void __init mrst_time_init(void) apbt_time_init(); } -static void __cpuinit mrst_arch_setup(void) +static void mrst_arch_setup(void) { if (boot_cpu_data.x86 == 6 && boot_cpu_data.x86_model == 0x27) __mrst_cpu_chip = MRST_CPU_CHIP_PENWELL; diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c index 2fa02bc50034..193097ef3d7d 100644 --- a/arch/x86/xen/enlighten.c +++ b/arch/x86/xen/enlighten.c @@ -1681,8 +1681,8 @@ static void __init init_hvm_pv_info(void) xen_domain_type = XEN_HVM_DOMAIN; } -static int __cpuinit xen_hvm_cpu_notify(struct notifier_block *self, - unsigned long action, void *hcpu) +static int xen_hvm_cpu_notify(struct notifier_block *self, unsigned long action, + void *hcpu) { int cpu = (long)hcpu; switch (action) { @@ -1700,7 +1700,7 @@ static int __cpuinit xen_hvm_cpu_notify(struct notifier_block *self, return NOTIFY_OK; } -static struct notifier_block xen_hvm_cpu_notifier __cpuinitdata = { +static struct notifier_block xen_hvm_cpu_notifier = { .notifier_call = xen_hvm_cpu_notify, }; diff --git a/arch/x86/xen/setup.c b/arch/x86/xen/setup.c index 94eac5c85cdc..056d11faef21 100644 --- a/arch/x86/xen/setup.c +++ b/arch/x86/xen/setup.c @@ -475,7 +475,7 @@ static void __init fiddle_vdso(void) #endif } -static int __cpuinit register_callback(unsigned type, const void *func) +static int register_callback(unsigned type, const void *func) { struct callback_register callback = { .type = type, @@ -486,7 +486,7 @@ static int __cpuinit register_callback(unsigned type, const void *func) return HYPERVISOR_callback_op(CALLBACKOP_register, &callback); } -void __cpuinit xen_enable_sysenter(void) +void xen_enable_sysenter(void) { int ret; unsigned sysenter_feature; @@ -505,7 +505,7 @@ void __cpuinit xen_enable_sysenter(void) setup_clear_cpu_cap(sysenter_feature); } -void __cpuinit xen_enable_syscall(void) +void xen_enable_syscall(void) { #ifdef CONFIG_X86_64 int ret; diff --git a/arch/x86/xen/smp.c b/arch/x86/xen/smp.c index c1367b29c3b1..ca92754eb846 100644 --- a/arch/x86/xen/smp.c +++ b/arch/x86/xen/smp.c @@ -65,7 +65,7 @@ static irqreturn_t xen_reschedule_interrupt(int irq, void *dev_id) return IRQ_HANDLED; } -static void __cpuinit cpu_bringup(void) +static void cpu_bringup(void) { int cpu; @@ -97,7 +97,7 @@ static void __cpuinit cpu_bringup(void) wmb(); /* make sure everything is out */ } -static void __cpuinit cpu_bringup_and_idle(void) +static void cpu_bringup_and_idle(void) { cpu_bringup(); cpu_startup_entry(CPUHP_ONLINE); @@ -326,7 +326,7 @@ static void __init xen_smp_prepare_cpus(unsigned int max_cpus) set_cpu_present(cpu, true); } -static int __cpuinit +static int cpu_initialize_context(unsigned int cpu, struct task_struct *idle) { struct vcpu_guest_context *ctxt; @@ -397,7 +397,7 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle) return 0; } -static int __cpuinit xen_cpu_up(unsigned int cpu, struct task_struct *idle) +static int xen_cpu_up(unsigned int cpu, struct task_struct *idle) { int rc; @@ -470,7 +470,7 @@ static void xen_cpu_die(unsigned int cpu) xen_teardown_timer(cpu); } -static void __cpuinit xen_play_dead(void) /* used only with HOTPLUG_CPU */ +static void xen_play_dead(void) /* used only with HOTPLUG_CPU */ { play_dead_common(); HYPERVISOR_vcpu_op(VCPUOP_down, smp_processor_id(), NULL); @@ -691,7 +691,7 @@ static void __init xen_hvm_smp_prepare_cpus(unsigned int max_cpus) xen_init_lock_cpu(0); } -static int __cpuinit xen_hvm_cpu_up(unsigned int cpu, struct task_struct *tidle) +static int xen_hvm_cpu_up(unsigned int cpu, struct task_struct *tidle) { int rc; rc = native_cpu_up(cpu, tidle); diff --git a/arch/x86/xen/spinlock.c b/arch/x86/xen/spinlock.c index a40f8508e760..cf3caee356b3 100644 --- a/arch/x86/xen/spinlock.c +++ b/arch/x86/xen/spinlock.c @@ -361,7 +361,7 @@ static irqreturn_t dummy_handler(int irq, void *dev_id) return IRQ_HANDLED; } -void __cpuinit xen_init_lock_cpu(int cpu) +void xen_init_lock_cpu(int cpu) { int irq; char *name; diff --git a/arch/x86/xen/xen-ops.h b/arch/x86/xen/xen-ops.h index a95b41744ad0..86782c5d7e2a 100644 --- a/arch/x86/xen/xen-ops.h +++ b/arch/x86/xen/xen-ops.h @@ -73,7 +73,7 @@ static inline void xen_hvm_smp_init(void) {} #ifdef CONFIG_PARAVIRT_SPINLOCKS void __init xen_init_spinlocks(void); -void __cpuinit xen_init_lock_cpu(int cpu); +void xen_init_lock_cpu(int cpu); void xen_uninit_lock_cpu(int cpu); #else static inline void xen_init_spinlocks(void) From 8c37bb3ac95b8ff953bd3c8bc8dd0a393d5ae989 Mon Sep 17 00:00:00 2001 From: Paul Gortmaker Date: Wed, 19 Jun 2013 11:32:08 -0400 Subject: [PATCH 0920/1048] clocksource+irqchip: delete __cpuinit usage from all related files The __cpuinit type of throwaway sections might have made sense some time ago when RAM was more constrained, but now the savings do not offset the cost and complications. For example, the fix in commit 5e427ec2d0 ("x86: Fix bit corruption at CPU resume time") is a good example of the nasty type of bugs that can be created with improper use of the various __init prefixes. After a discussion on LKML[1] it was decided that cpuinit should go the way of devinit and be phased out. Once all the users are gone, we can then finally remove the macros themselves from linux/init.h. This removes all the drivers/clocksource and drivers/irqchip uses of the __cpuinit macros from all C files. [1] https://lkml.org/lkml/2013/5/20/589 Cc: John Stultz Cc: Thomas Gleixner Acked-by: Thomas Gleixner Signed-off-by: Paul Gortmaker --- drivers/clocksource/arm_arch_timer.c | 8 ++++---- drivers/clocksource/arm_global_timer.c | 8 ++++---- drivers/clocksource/dummy_timer.c | 6 +++--- drivers/clocksource/exynos_mct.c | 4 ++-- drivers/clocksource/metag_generic.c | 6 +++--- drivers/clocksource/time-armada-370-xp.c | 4 ++-- drivers/clocksource/timer-marco.c | 4 ++-- drivers/irqchip/irq-gic.c | 8 ++++---- 8 files changed, 24 insertions(+), 24 deletions(-) diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_arch_timer.c index 053d846ab5b1..ffadd836e0b5 100644 --- a/drivers/clocksource/arm_arch_timer.c +++ b/drivers/clocksource/arm_arch_timer.c @@ -123,7 +123,7 @@ static int arch_timer_set_next_event_phys(unsigned long evt, return 0; } -static int __cpuinit arch_timer_setup(struct clock_event_device *clk) +static int arch_timer_setup(struct clock_event_device *clk) { clk->features = CLOCK_EVT_FEAT_ONESHOT | CLOCK_EVT_FEAT_C3STOP; clk->name = "arch_sys_timer"; @@ -221,7 +221,7 @@ struct timecounter *arch_timer_get_timecounter(void) return &timecounter; } -static void __cpuinit arch_timer_stop(struct clock_event_device *clk) +static void arch_timer_stop(struct clock_event_device *clk) { pr_debug("arch_timer_teardown disable IRQ%d cpu #%d\n", clk->irq, smp_processor_id()); @@ -237,7 +237,7 @@ static void __cpuinit arch_timer_stop(struct clock_event_device *clk) clk->set_mode(CLOCK_EVT_MODE_UNUSED, clk); } -static int __cpuinit arch_timer_cpu_notify(struct notifier_block *self, +static int arch_timer_cpu_notify(struct notifier_block *self, unsigned long action, void *hcpu) { /* @@ -256,7 +256,7 @@ static int __cpuinit arch_timer_cpu_notify(struct notifier_block *self, return NOTIFY_OK; } -static struct notifier_block arch_timer_cpu_nb __cpuinitdata = { +static struct notifier_block arch_timer_cpu_nb = { .notifier_call = arch_timer_cpu_notify, }; diff --git a/drivers/clocksource/arm_global_timer.c b/drivers/clocksource/arm_global_timer.c index db8afc7427a6..b66c1f36066c 100644 --- a/drivers/clocksource/arm_global_timer.c +++ b/drivers/clocksource/arm_global_timer.c @@ -164,7 +164,7 @@ static irqreturn_t gt_clockevent_interrupt(int irq, void *dev_id) return IRQ_HANDLED; } -static int __cpuinit gt_clockevents_init(struct clock_event_device *clk) +static int gt_clockevents_init(struct clock_event_device *clk) { int cpu = smp_processor_id(); @@ -221,8 +221,8 @@ static void __init gt_clocksource_init(void) clocksource_register_hz(>_clocksource, gt_clk_rate); } -static int __cpuinit gt_cpu_notify(struct notifier_block *self, - unsigned long action, void *hcpu) +static int gt_cpu_notify(struct notifier_block *self, unsigned long action, + void *hcpu) { switch (action & ~CPU_TASKS_FROZEN) { case CPU_STARTING: @@ -235,7 +235,7 @@ static int __cpuinit gt_cpu_notify(struct notifier_block *self, return NOTIFY_OK; } -static struct notifier_block gt_cpu_nb __cpuinitdata = { +static struct notifier_block gt_cpu_nb = { .notifier_call = gt_cpu_notify, }; diff --git a/drivers/clocksource/dummy_timer.c b/drivers/clocksource/dummy_timer.c index 1f55f9620338..b3eb582d6a6f 100644 --- a/drivers/clocksource/dummy_timer.c +++ b/drivers/clocksource/dummy_timer.c @@ -25,7 +25,7 @@ static void dummy_timer_set_mode(enum clock_event_mode mode, */ } -static void __cpuinit dummy_timer_setup(void) +static void dummy_timer_setup(void) { int cpu = smp_processor_id(); struct clock_event_device *evt = __this_cpu_ptr(&dummy_timer_evt); @@ -41,7 +41,7 @@ static void __cpuinit dummy_timer_setup(void) clockevents_register_device(evt); } -static int __cpuinit dummy_timer_cpu_notify(struct notifier_block *self, +static int dummy_timer_cpu_notify(struct notifier_block *self, unsigned long action, void *hcpu) { if ((action & ~CPU_TASKS_FROZEN) == CPU_STARTING) @@ -50,7 +50,7 @@ static int __cpuinit dummy_timer_cpu_notify(struct notifier_block *self, return NOTIFY_OK; } -static struct notifier_block dummy_timer_cpu_nb __cpuinitdata = { +static struct notifier_block dummy_timer_cpu_nb = { .notifier_call = dummy_timer_cpu_notify, }; diff --git a/drivers/clocksource/exynos_mct.c b/drivers/clocksource/exynos_mct.c index a70480409ea5..b2bbc415f120 100644 --- a/drivers/clocksource/exynos_mct.c +++ b/drivers/clocksource/exynos_mct.c @@ -400,7 +400,7 @@ static irqreturn_t exynos4_mct_tick_isr(int irq, void *dev_id) return IRQ_HANDLED; } -static int __cpuinit exynos4_local_timer_setup(struct clock_event_device *evt) +static int exynos4_local_timer_setup(struct clock_event_device *evt) { struct mct_clock_event_device *mevt; unsigned int cpu = smp_processor_id(); @@ -448,7 +448,7 @@ static void exynos4_local_timer_stop(struct clock_event_device *evt) disable_percpu_irq(mct_irqs[MCT_L0_IRQ]); } -static struct local_timer_ops exynos4_mct_tick_ops __cpuinitdata = { +static struct local_timer_ops exynos4_mct_tick_ops = { .setup = exynos4_local_timer_setup, .stop = exynos4_local_timer_stop, }; diff --git a/drivers/clocksource/metag_generic.c b/drivers/clocksource/metag_generic.c index 6722f0e2fe40..9e4db41abe3c 100644 --- a/drivers/clocksource/metag_generic.c +++ b/drivers/clocksource/metag_generic.c @@ -109,7 +109,7 @@ unsigned long long sched_clock(void) return ticks << HARDWARE_TO_NS_SHIFT; } -static void __cpuinit arch_timer_setup(unsigned int cpu) +static void arch_timer_setup(unsigned int cpu) { unsigned int txdivtime; struct clock_event_device *clk = &per_cpu(local_clockevent, cpu); @@ -154,7 +154,7 @@ static void __cpuinit arch_timer_setup(unsigned int cpu) } } -static int __cpuinit arch_timer_cpu_notify(struct notifier_block *self, +static int arch_timer_cpu_notify(struct notifier_block *self, unsigned long action, void *hcpu) { int cpu = (long)hcpu; @@ -169,7 +169,7 @@ static int __cpuinit arch_timer_cpu_notify(struct notifier_block *self, return NOTIFY_OK; } -static struct notifier_block __cpuinitdata arch_timer_cpu_nb = { +static struct notifier_block arch_timer_cpu_nb = { .notifier_call = arch_timer_cpu_notify, }; diff --git a/drivers/clocksource/time-armada-370-xp.c b/drivers/clocksource/time-armada-370-xp.c index efdca3263afe..1b04b7e1d39b 100644 --- a/drivers/clocksource/time-armada-370-xp.c +++ b/drivers/clocksource/time-armada-370-xp.c @@ -167,7 +167,7 @@ static irqreturn_t armada_370_xp_timer_interrupt(int irq, void *dev_id) /* * Setup the local clock events for a CPU. */ -static int __cpuinit armada_370_xp_timer_setup(struct clock_event_device *evt) +static int armada_370_xp_timer_setup(struct clock_event_device *evt) { u32 u; int cpu = smp_processor_id(); @@ -205,7 +205,7 @@ static void armada_370_xp_timer_stop(struct clock_event_device *evt) disable_percpu_irq(evt->irq); } -static struct local_timer_ops armada_370_xp_local_timer_ops __cpuinitdata = { +static struct local_timer_ops armada_370_xp_local_timer_ops = { .setup = armada_370_xp_timer_setup, .stop = armada_370_xp_timer_stop, }; diff --git a/drivers/clocksource/timer-marco.c b/drivers/clocksource/timer-marco.c index e5dc9129ca26..62876baa3ab9 100644 --- a/drivers/clocksource/timer-marco.c +++ b/drivers/clocksource/timer-marco.c @@ -184,7 +184,7 @@ static struct irqaction sirfsoc_timer1_irq = { .handler = sirfsoc_timer_interrupt, }; -static int __cpuinit sirfsoc_local_timer_setup(struct clock_event_device *ce) +static int sirfsoc_local_timer_setup(struct clock_event_device *ce) { /* Use existing clock_event for cpu 0 */ if (!smp_processor_id()) @@ -216,7 +216,7 @@ static void sirfsoc_local_timer_stop(struct clock_event_device *ce) remove_irq(sirfsoc_timer1_irq.irq, &sirfsoc_timer1_irq); } -static struct local_timer_ops sirfsoc_local_timer_ops __cpuinitdata = { +static struct local_timer_ops sirfsoc_local_timer_ops = { .setup = sirfsoc_local_timer_setup, .stop = sirfsoc_local_timer_stop, }; diff --git a/drivers/irqchip/irq-gic.c b/drivers/irqchip/irq-gic.c index 19ceaa60e0f4..ee7c50312066 100644 --- a/drivers/irqchip/irq-gic.c +++ b/drivers/irqchip/irq-gic.c @@ -414,7 +414,7 @@ static void __init gic_dist_init(struct gic_chip_data *gic) writel_relaxed(1, base + GIC_DIST_CTRL); } -static void __cpuinit gic_cpu_init(struct gic_chip_data *gic) +static void gic_cpu_init(struct gic_chip_data *gic) { void __iomem *dist_base = gic_data_dist_base(gic); void __iomem *base = gic_data_cpu_base(gic); @@ -702,8 +702,8 @@ static int gic_irq_domain_xlate(struct irq_domain *d, } #ifdef CONFIG_SMP -static int __cpuinit gic_secondary_init(struct notifier_block *nfb, - unsigned long action, void *hcpu) +static int gic_secondary_init(struct notifier_block *nfb, unsigned long action, + void *hcpu) { if (action == CPU_STARTING || action == CPU_STARTING_FROZEN) gic_cpu_init(&gic_data[0]); @@ -714,7 +714,7 @@ static int __cpuinit gic_secondary_init(struct notifier_block *nfb, * Notifier for enabling the GIC CPU interface. Set an arbitrarily high * priority because the GIC needs to be up before the ARM generic timers. */ -static struct notifier_block __cpuinitdata gic_cpu_notifier = { +static struct notifier_block gic_cpu_notifier = { .notifier_call = gic_secondary_init, .priority = 100, }; From 2760984f6578d5a462155bb4727766d0c8b68387 Mon Sep 17 00:00:00 2001 From: Paul Gortmaker Date: Wed, 19 Jun 2013 13:54:04 -0400 Subject: [PATCH 0921/1048] cpufreq: delete __cpuinit usage from all cpufreq files The __cpuinit type of throwaway sections might have made sense some time ago when RAM was more constrained, but now the savings do not offset the cost and complications. For example, the fix in commit 5e427ec2d0 ("x86: Fix bit corruption at CPU resume time") is a good example of the nasty type of bugs that can be created with improper use of the various __init prefixes. After a discussion on LKML[1] it was decided that cpuinit should go the way of devinit and be phased out. Once all the users are gone, we can then finally remove the macros themselves from linux/init.h. This removes all the drivers/cpufreq uses of the __cpuinit macros from all C files. [1] https://lkml.org/lkml/2013/5/20/589 [v2: leave 2nd lines of args misaligned as requested by Viresh] Cc: "Rafael J. Wysocki" Cc: Viresh Kumar Cc: cpufreq@vger.kernel.org Cc: linux-pm@vger.kernel.org Acked-by: Dirk Brandewie Acked-by: Viresh Kumar Signed-off-by: Paul Gortmaker --- drivers/cpufreq/cpufreq.c | 2 +- drivers/cpufreq/cpufreq_stats.c | 2 +- drivers/cpufreq/dbx500-cpufreq.c | 2 +- drivers/cpufreq/intel_pstate.c | 4 ++-- drivers/cpufreq/longhaul.c | 6 +++--- drivers/cpufreq/longhaul.h | 26 +++++++++++++------------- drivers/cpufreq/longrun.c | 6 +++--- drivers/cpufreq/omap-cpufreq.c | 2 +- drivers/cpufreq/powernow-k7.c | 8 ++++---- drivers/cpufreq/powernow-k8.c | 6 +++--- 10 files changed, 32 insertions(+), 32 deletions(-) diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 0937b8d6c2a4..b7bda8d9f081 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -1932,7 +1932,7 @@ no_policy: } EXPORT_SYMBOL(cpufreq_update_policy); -static int __cpuinit cpufreq_cpu_callback(struct notifier_block *nfb, +static int cpufreq_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu) { unsigned int cpu = (unsigned long)hcpu; diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c index cd9e81713a71..c1ec11c513c1 100644 --- a/drivers/cpufreq/cpufreq_stats.c +++ b/drivers/cpufreq/cpufreq_stats.c @@ -341,7 +341,7 @@ static int cpufreq_stat_notifier_trans(struct notifier_block *nb, return 0; } -static int __cpuinit cpufreq_stat_cpu_callback(struct notifier_block *nfb, +static int cpufreq_stat_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu) { diff --git a/drivers/cpufreq/dbx500-cpufreq.c b/drivers/cpufreq/dbx500-cpufreq.c index 1fdb02b9f1ec..26321cdc1946 100644 --- a/drivers/cpufreq/dbx500-cpufreq.c +++ b/drivers/cpufreq/dbx500-cpufreq.c @@ -82,7 +82,7 @@ static unsigned int dbx500_cpufreq_getspeed(unsigned int cpu) return freq_table[i].frequency; } -static int __cpuinit dbx500_cpufreq_init(struct cpufreq_policy *policy) +static int dbx500_cpufreq_init(struct cpufreq_policy *policy) { int res; diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c index 07f2840ad805..b012d7600e1a 100644 --- a/drivers/cpufreq/intel_pstate.c +++ b/drivers/cpufreq/intel_pstate.c @@ -617,7 +617,7 @@ static int intel_pstate_verify_policy(struct cpufreq_policy *policy) return 0; } -static int __cpuinit intel_pstate_cpu_exit(struct cpufreq_policy *policy) +static int intel_pstate_cpu_exit(struct cpufreq_policy *policy) { int cpu = policy->cpu; @@ -627,7 +627,7 @@ static int __cpuinit intel_pstate_cpu_exit(struct cpufreq_policy *policy) return 0; } -static int __cpuinit intel_pstate_cpu_init(struct cpufreq_policy *policy) +static int intel_pstate_cpu_init(struct cpufreq_policy *policy) { int rc, min_pstate, max_pstate; struct cpudata *cpu; diff --git a/drivers/cpufreq/longhaul.c b/drivers/cpufreq/longhaul.c index b6a0a7a406b0..8c49261df57d 100644 --- a/drivers/cpufreq/longhaul.c +++ b/drivers/cpufreq/longhaul.c @@ -422,7 +422,7 @@ static int guess_fsb(int mult) } -static int __cpuinit longhaul_get_ranges(void) +static int longhaul_get_ranges(void) { unsigned int i, j, k = 0; unsigned int ratio; @@ -526,7 +526,7 @@ static int __cpuinit longhaul_get_ranges(void) } -static void __cpuinit longhaul_setup_voltagescaling(void) +static void longhaul_setup_voltagescaling(void) { union msr_longhaul longhaul; struct mV_pos minvid, maxvid, vid; @@ -780,7 +780,7 @@ static int longhaul_setup_southbridge(void) return 0; } -static int __cpuinit longhaul_cpu_init(struct cpufreq_policy *policy) +static int longhaul_cpu_init(struct cpufreq_policy *policy) { struct cpuinfo_x86 *c = &cpu_data(0); char *cpuname = NULL; diff --git a/drivers/cpufreq/longhaul.h b/drivers/cpufreq/longhaul.h index e2dc436099d1..1928b923a57b 100644 --- a/drivers/cpufreq/longhaul.h +++ b/drivers/cpufreq/longhaul.h @@ -56,7 +56,7 @@ union msr_longhaul { /* * VIA C3 Samuel 1 & Samuel 2 (stepping 0) */ -static const int __cpuinitconst samuel1_mults[16] = { +static const int samuel1_mults[16] = { -1, /* 0000 -> RESERVED */ 30, /* 0001 -> 3.0x */ 40, /* 0010 -> 4.0x */ @@ -75,7 +75,7 @@ static const int __cpuinitconst samuel1_mults[16] = { -1, /* 1111 -> RESERVED */ }; -static const int __cpuinitconst samuel1_eblcr[16] = { +static const int samuel1_eblcr[16] = { 50, /* 0000 -> RESERVED */ 30, /* 0001 -> 3.0x */ 40, /* 0010 -> 4.0x */ @@ -97,7 +97,7 @@ static const int __cpuinitconst samuel1_eblcr[16] = { /* * VIA C3 Samuel2 Stepping 1->15 */ -static const int __cpuinitconst samuel2_eblcr[16] = { +static const int samuel2_eblcr[16] = { 50, /* 0000 -> 5.0x */ 30, /* 0001 -> 3.0x */ 40, /* 0010 -> 4.0x */ @@ -119,7 +119,7 @@ static const int __cpuinitconst samuel2_eblcr[16] = { /* * VIA C3 Ezra */ -static const int __cpuinitconst ezra_mults[16] = { +static const int ezra_mults[16] = { 100, /* 0000 -> 10.0x */ 30, /* 0001 -> 3.0x */ 40, /* 0010 -> 4.0x */ @@ -138,7 +138,7 @@ static const int __cpuinitconst ezra_mults[16] = { 120, /* 1111 -> 12.0x */ }; -static const int __cpuinitconst ezra_eblcr[16] = { +static const int ezra_eblcr[16] = { 50, /* 0000 -> 5.0x */ 30, /* 0001 -> 3.0x */ 40, /* 0010 -> 4.0x */ @@ -160,7 +160,7 @@ static const int __cpuinitconst ezra_eblcr[16] = { /* * VIA C3 (Ezra-T) [C5M]. */ -static const int __cpuinitconst ezrat_mults[32] = { +static const int ezrat_mults[32] = { 100, /* 0000 -> 10.0x */ 30, /* 0001 -> 3.0x */ 40, /* 0010 -> 4.0x */ @@ -196,7 +196,7 @@ static const int __cpuinitconst ezrat_mults[32] = { -1, /* 1111 -> RESERVED (12.0x) */ }; -static const int __cpuinitconst ezrat_eblcr[32] = { +static const int ezrat_eblcr[32] = { 50, /* 0000 -> 5.0x */ 30, /* 0001 -> 3.0x */ 40, /* 0010 -> 4.0x */ @@ -235,7 +235,7 @@ static const int __cpuinitconst ezrat_eblcr[32] = { /* * VIA C3 Nehemiah */ -static const int __cpuinitconst nehemiah_mults[32] = { +static const int nehemiah_mults[32] = { 100, /* 0000 -> 10.0x */ -1, /* 0001 -> 16.0x */ 40, /* 0010 -> 4.0x */ @@ -270,7 +270,7 @@ static const int __cpuinitconst nehemiah_mults[32] = { -1, /* 1111 -> 12.0x */ }; -static const int __cpuinitconst nehemiah_eblcr[32] = { +static const int nehemiah_eblcr[32] = { 50, /* 0000 -> 5.0x */ 160, /* 0001 -> 16.0x */ 40, /* 0010 -> 4.0x */ @@ -315,7 +315,7 @@ struct mV_pos { unsigned short pos; }; -static const struct mV_pos __cpuinitconst vrm85_mV[32] = { +static const struct mV_pos vrm85_mV[32] = { {1250, 8}, {1200, 6}, {1150, 4}, {1100, 2}, {1050, 0}, {1800, 30}, {1750, 28}, {1700, 26}, {1650, 24}, {1600, 22}, {1550, 20}, {1500, 18}, @@ -326,14 +326,14 @@ static const struct mV_pos __cpuinitconst vrm85_mV[32] = { {1475, 17}, {1425, 15}, {1375, 13}, {1325, 11} }; -static const unsigned char __cpuinitconst mV_vrm85[32] = { +static const unsigned char mV_vrm85[32] = { 0x04, 0x14, 0x03, 0x13, 0x02, 0x12, 0x01, 0x11, 0x00, 0x10, 0x0f, 0x1f, 0x0e, 0x1e, 0x0d, 0x1d, 0x0c, 0x1c, 0x0b, 0x1b, 0x0a, 0x1a, 0x09, 0x19, 0x08, 0x18, 0x07, 0x17, 0x06, 0x16, 0x05, 0x15 }; -static const struct mV_pos __cpuinitconst mobilevrm_mV[32] = { +static const struct mV_pos mobilevrm_mV[32] = { {1750, 31}, {1700, 30}, {1650, 29}, {1600, 28}, {1550, 27}, {1500, 26}, {1450, 25}, {1400, 24}, {1350, 23}, {1300, 22}, {1250, 21}, {1200, 20}, @@ -344,7 +344,7 @@ static const struct mV_pos __cpuinitconst mobilevrm_mV[32] = { {675, 3}, {650, 2}, {625, 1}, {600, 0} }; -static const unsigned char __cpuinitconst mV_mobilevrm[32] = { +static const unsigned char mV_mobilevrm[32] = { 0x1f, 0x1e, 0x1d, 0x1c, 0x1b, 0x1a, 0x19, 0x18, 0x17, 0x16, 0x15, 0x14, 0x13, 0x12, 0x11, 0x10, 0x0f, 0x0e, 0x0d, 0x0c, 0x0b, 0x0a, 0x09, 0x08, diff --git a/drivers/cpufreq/longrun.c b/drivers/cpufreq/longrun.c index 8bc9f5fbbaeb..0fe041d1f77f 100644 --- a/drivers/cpufreq/longrun.c +++ b/drivers/cpufreq/longrun.c @@ -33,7 +33,7 @@ static unsigned int longrun_low_freq, longrun_high_freq; * Reads the current LongRun policy by access to MSR_TMTA_LONGRUN_FLAGS * and MSR_TMTA_LONGRUN_CTRL */ -static void __cpuinit longrun_get_policy(struct cpufreq_policy *policy) +static void longrun_get_policy(struct cpufreq_policy *policy) { u32 msr_lo, msr_hi; @@ -163,7 +163,7 @@ static unsigned int longrun_get(unsigned int cpu) * TMTA rules: * performance_pctg = (target_freq - low_freq)/(high_freq - low_freq) */ -static int __cpuinit longrun_determine_freqs(unsigned int *low_freq, +static int longrun_determine_freqs(unsigned int *low_freq, unsigned int *high_freq) { u32 msr_lo, msr_hi; @@ -256,7 +256,7 @@ static int __cpuinit longrun_determine_freqs(unsigned int *low_freq, } -static int __cpuinit longrun_cpu_init(struct cpufreq_policy *policy) +static int longrun_cpu_init(struct cpufreq_policy *policy) { int result = 0; diff --git a/drivers/cpufreq/omap-cpufreq.c b/drivers/cpufreq/omap-cpufreq.c index 29468a522ee9..f31fcfcad514 100644 --- a/drivers/cpufreq/omap-cpufreq.c +++ b/drivers/cpufreq/omap-cpufreq.c @@ -165,7 +165,7 @@ static inline void freq_table_free(void) opp_free_cpufreq_table(mpu_dev, &freq_table); } -static int __cpuinit omap_cpu_init(struct cpufreq_policy *policy) +static int omap_cpu_init(struct cpufreq_policy *policy) { int result = 0; diff --git a/drivers/cpufreq/powernow-k7.c b/drivers/cpufreq/powernow-k7.c index b9f80b713fda..955870877935 100644 --- a/drivers/cpufreq/powernow-k7.c +++ b/drivers/cpufreq/powernow-k7.c @@ -563,7 +563,7 @@ static int powernow_verify(struct cpufreq_policy *policy) * We will then get the same kind of behaviour already tested under * the "well-known" other OS. */ -static int __cpuinit fixup_sgtc(void) +static int fixup_sgtc(void) { unsigned int sgtc; unsigned int m; @@ -597,7 +597,7 @@ static unsigned int powernow_get(unsigned int cpu) } -static int __cpuinit acer_cpufreq_pst(const struct dmi_system_id *d) +static int acer_cpufreq_pst(const struct dmi_system_id *d) { printk(KERN_WARNING PFX "%s laptop with broken PST tables in BIOS detected.\n", @@ -615,7 +615,7 @@ static int __cpuinit acer_cpufreq_pst(const struct dmi_system_id *d) * A BIOS update is all that can save them. * Mention this, and disable cpufreq. */ -static struct dmi_system_id __cpuinitdata powernow_dmi_table[] = { +static struct dmi_system_id powernow_dmi_table[] = { { .callback = acer_cpufreq_pst, .ident = "Acer Aspire", @@ -627,7 +627,7 @@ static struct dmi_system_id __cpuinitdata powernow_dmi_table[] = { { } }; -static int __cpuinit powernow_cpu_init(struct cpufreq_policy *policy) +static int powernow_cpu_init(struct cpufreq_policy *policy) { union msr_fidvidstatus fidvidstatus; int result; diff --git a/drivers/cpufreq/powernow-k8.c b/drivers/cpufreq/powernow-k8.c index 78f018f2a5de..c39d189217cb 100644 --- a/drivers/cpufreq/powernow-k8.c +++ b/drivers/cpufreq/powernow-k8.c @@ -1069,7 +1069,7 @@ struct init_on_cpu { int rc; }; -static void __cpuinit powernowk8_cpu_init_on_cpu(void *_init_on_cpu) +static void powernowk8_cpu_init_on_cpu(void *_init_on_cpu) { struct init_on_cpu *init_on_cpu = _init_on_cpu; @@ -1096,7 +1096,7 @@ static const char missing_pss_msg[] = FW_BUG PFX "If that doesn't help, try upgrading your BIOS.\n"; /* per CPU init entry point to the driver */ -static int __cpuinit powernowk8_cpu_init(struct cpufreq_policy *pol) +static int powernowk8_cpu_init(struct cpufreq_policy *pol) { struct powernow_k8_data *data; struct init_on_cpu init_on_cpu; @@ -1263,7 +1263,7 @@ static void __request_acpi_cpufreq(void) } /* driver entry point for init */ -static int __cpuinit powernowk8_init(void) +static int powernowk8_init(void) { unsigned int i, supported_cpus = 0; int ret; From d23e2ae1aae52bb80bd90525179375817db99809 Mon Sep 17 00:00:00 2001 From: Paul Gortmaker Date: Wed, 19 Jun 2013 14:02:20 -0400 Subject: [PATCH 0922/1048] hwmon: delete __cpuinit usage from all hwmon files The __cpuinit type of throwaway sections might have made sense some time ago when RAM was more constrained, but now the savings do not offset the cost and complications. For example, the fix in commit 5e427ec2d0 ("x86: Fix bit corruption at CPU resume time") is a good example of the nasty type of bugs that can be created with improper use of the various __init prefixes. After a discussion on LKML[1] it was decided that cpuinit should go the way of devinit and be phased out. Once all the users are gone, we can then finally remove the macros themselves from linux/init.h. This removes all the drivers/hwmon uses of the __cpuinit macros from all C files. [1] https://lkml.org/lkml/2013/5/20/589 Cc: Fenghua Yu Cc: lm-sensors@lm-sensors.org Acked-by: Guenter Roeck Signed-off-by: Paul Gortmaker --- drivers/hwmon/coretemp.c | 39 +++++++++++++++++-------------------- drivers/hwmon/via-cputemp.c | 8 ++++---- 2 files changed, 22 insertions(+), 25 deletions(-) diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c index ade35cf3f488..2e5e2dc47eaf 100644 --- a/drivers/hwmon/coretemp.c +++ b/drivers/hwmon/coretemp.c @@ -195,7 +195,7 @@ struct tjmax { int tjmax; }; -static const struct tjmax __cpuinitconst tjmax_table[] = { +static const struct tjmax tjmax_table[] = { { "CPU 230", 100000 }, /* Model 0x1c, stepping 2 */ { "CPU 330", 125000 }, /* Model 0x1c, stepping 2 */ { "CPU CE4110", 110000 }, /* Model 0x1c, stepping 10 Sodaville */ @@ -211,7 +211,7 @@ struct tjmax_model { #define ANY 0xff -static const struct tjmax_model __cpuinitconst tjmax_model_table[] = { +static const struct tjmax_model tjmax_model_table[] = { { 0x1c, 10, 100000 }, /* D4xx, K4xx, N4xx, D5xx, K5xx, N5xx */ { 0x1c, ANY, 90000 }, /* Z5xx, N2xx, possibly others * Note: Also matches 230 and 330, @@ -226,8 +226,7 @@ static const struct tjmax_model __cpuinitconst tjmax_model_table[] = { { 0x36, ANY, 100000 }, /* Atom Cedar Trail/Cedarview (N2xxx, D2xxx) */ }; -static int __cpuinit adjust_tjmax(struct cpuinfo_x86 *c, u32 id, - struct device *dev) +static int adjust_tjmax(struct cpuinfo_x86 *c, u32 id, struct device *dev) { /* The 100C is default for both mobile and non mobile CPUs */ @@ -317,8 +316,7 @@ static int __cpuinit adjust_tjmax(struct cpuinfo_x86 *c, u32 id, return tjmax; } -static int __cpuinit get_tjmax(struct cpuinfo_x86 *c, u32 id, - struct device *dev) +static int get_tjmax(struct cpuinfo_x86 *c, u32 id, struct device *dev) { int err; u32 eax, edx; @@ -367,8 +365,8 @@ static int create_name_attr(struct platform_data *pdata, return device_create_file(dev, &pdata->name_attr); } -static int __cpuinit create_core_attrs(struct temp_data *tdata, - struct device *dev, int attr_no) +static int create_core_attrs(struct temp_data *tdata, struct device *dev, + int attr_no) { int err, i; static ssize_t (*const rd_ptr[TOTAL_ATTRS]) (struct device *dev, @@ -401,7 +399,7 @@ exit_free: } -static int __cpuinit chk_ucode_version(unsigned int cpu) +static int chk_ucode_version(unsigned int cpu) { struct cpuinfo_x86 *c = &cpu_data(cpu); @@ -417,7 +415,7 @@ static int __cpuinit chk_ucode_version(unsigned int cpu) return 0; } -static struct platform_device __cpuinit *coretemp_get_pdev(unsigned int cpu) +static struct platform_device *coretemp_get_pdev(unsigned int cpu) { u16 phys_proc_id = TO_PHYS_ID(cpu); struct pdev_entry *p; @@ -434,8 +432,7 @@ static struct platform_device __cpuinit *coretemp_get_pdev(unsigned int cpu) return NULL; } -static struct temp_data __cpuinit *init_temp_data(unsigned int cpu, - int pkg_flag) +static struct temp_data *init_temp_data(unsigned int cpu, int pkg_flag) { struct temp_data *tdata; @@ -453,8 +450,8 @@ static struct temp_data __cpuinit *init_temp_data(unsigned int cpu, return tdata; } -static int __cpuinit create_core_data(struct platform_device *pdev, - unsigned int cpu, int pkg_flag) +static int create_core_data(struct platform_device *pdev, unsigned int cpu, + int pkg_flag) { struct temp_data *tdata; struct platform_data *pdata = platform_get_drvdata(pdev); @@ -524,7 +521,7 @@ exit_free: return err; } -static void __cpuinit coretemp_add_core(unsigned int cpu, int pkg_flag) +static void coretemp_add_core(unsigned int cpu, int pkg_flag) { struct platform_device *pdev = coretemp_get_pdev(cpu); int err; @@ -607,7 +604,7 @@ static struct platform_driver coretemp_driver = { .remove = coretemp_remove, }; -static int __cpuinit coretemp_device_add(unsigned int cpu) +static int coretemp_device_add(unsigned int cpu) { int err; struct platform_device *pdev; @@ -651,7 +648,7 @@ exit: return err; } -static void __cpuinit coretemp_device_remove(unsigned int cpu) +static void coretemp_device_remove(unsigned int cpu) { struct pdev_entry *p, *n; u16 phys_proc_id = TO_PHYS_ID(cpu); @@ -667,7 +664,7 @@ static void __cpuinit coretemp_device_remove(unsigned int cpu) mutex_unlock(&pdev_list_mutex); } -static bool __cpuinit is_any_core_online(struct platform_data *pdata) +static bool is_any_core_online(struct platform_data *pdata) { int i; @@ -681,7 +678,7 @@ static bool __cpuinit is_any_core_online(struct platform_data *pdata) return false; } -static void __cpuinit get_core_online(unsigned int cpu) +static void get_core_online(unsigned int cpu) { struct cpuinfo_x86 *c = &cpu_data(cpu); struct platform_device *pdev = coretemp_get_pdev(cpu); @@ -723,7 +720,7 @@ static void __cpuinit get_core_online(unsigned int cpu) coretemp_add_core(cpu, 0); } -static void __cpuinit put_core_offline(unsigned int cpu) +static void put_core_offline(unsigned int cpu) { int i, indx; struct platform_data *pdata; @@ -771,7 +768,7 @@ static void __cpuinit put_core_offline(unsigned int cpu) coretemp_device_remove(cpu); } -static int __cpuinit coretemp_cpu_callback(struct notifier_block *nfb, +static int coretemp_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu) { unsigned int cpu = (unsigned long) hcpu; diff --git a/drivers/hwmon/via-cputemp.c b/drivers/hwmon/via-cputemp.c index 76f157b568ed..38944e94f65f 100644 --- a/drivers/hwmon/via-cputemp.c +++ b/drivers/hwmon/via-cputemp.c @@ -221,7 +221,7 @@ struct pdev_entry { static LIST_HEAD(pdev_list); static DEFINE_MUTEX(pdev_list_mutex); -static int __cpuinit via_cputemp_device_add(unsigned int cpu) +static int via_cputemp_device_add(unsigned int cpu) { int err; struct platform_device *pdev; @@ -262,7 +262,7 @@ exit: return err; } -static void __cpuinit via_cputemp_device_remove(unsigned int cpu) +static void via_cputemp_device_remove(unsigned int cpu) { struct pdev_entry *p; @@ -279,8 +279,8 @@ static void __cpuinit via_cputemp_device_remove(unsigned int cpu) mutex_unlock(&pdev_list_mutex); } -static int __cpuinit via_cputemp_cpu_callback(struct notifier_block *nfb, - unsigned long action, void *hcpu) +static int via_cputemp_cpu_callback(struct notifier_block *nfb, + unsigned long action, void *hcpu) { unsigned int cpu = (unsigned long) hcpu; From fe7bf106ebc22730797ba9b51308b166d68b77f9 Mon Sep 17 00:00:00 2001 From: Paul Gortmaker Date: Wed, 19 Jun 2013 14:30:58 -0400 Subject: [PATCH 0923/1048] acpi: delete __cpuinit usage from all acpi files The __cpuinit type of throwaway sections might have made sense some time ago when RAM was more constrained, but now the savings do not offset the cost and complications. For example, the fix in commit 5e427ec2d0 ("x86: Fix bit corruption at CPU resume time") is a good example of the nasty type of bugs that can be created with improper use of the various __init prefixes. After a discussion on LKML[1] it was decided that cpuinit should go the way of devinit and be phased out. Once all the users are gone, we can then finally remove the macros themselves from linux/init.h. This removes all the drivers/acpi uses of the __cpuinit macros from all C files. [1] https://lkml.org/lkml/2013/5/20/589 Cc: Len Brown Cc: "Rafael J. Wysocki" Cc: linux-acpi@vger.kernel.org Signed-off-by: Paul Gortmaker --- drivers/acpi/acpi_processor.c | 2 +- drivers/acpi/processor_core.c | 8 ++++---- drivers/acpi/processor_driver.c | 8 ++++---- drivers/acpi/processor_idle.c | 6 ++---- 4 files changed, 11 insertions(+), 13 deletions(-) diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c index e9b01e35ac37..fd6c51cc3acb 100644 --- a/drivers/acpi/acpi_processor.c +++ b/drivers/acpi/acpi_processor.c @@ -340,7 +340,7 @@ static int acpi_processor_get_info(struct acpi_device *device) */ static DEFINE_PER_CPU(void *, processor_device_array); -static int __cpuinit acpi_processor_add(struct acpi_device *device, +static int acpi_processor_add(struct acpi_device *device, const struct acpi_device_id *id) { struct acpi_processor *pr; diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c index 164d49569aeb..a5e9f4a5b281 100644 --- a/drivers/acpi/processor_core.c +++ b/drivers/acpi/processor_core.c @@ -253,7 +253,7 @@ static bool __init processor_physically_present(acpi_handle handle) return true; } -static void __cpuinit acpi_set_pdc_bits(u32 *buf) +static void acpi_set_pdc_bits(u32 *buf) { buf[0] = ACPI_PDC_REVISION_ID; buf[1] = 1; @@ -265,7 +265,7 @@ static void __cpuinit acpi_set_pdc_bits(u32 *buf) arch_acpi_set_pdc_bits(buf); } -static struct acpi_object_list *__cpuinit acpi_processor_alloc_pdc(void) +static struct acpi_object_list *acpi_processor_alloc_pdc(void) { struct acpi_object_list *obj_list; union acpi_object *obj; @@ -308,7 +308,7 @@ static struct acpi_object_list *__cpuinit acpi_processor_alloc_pdc(void) * _PDC is required for a BIOS-OS handshake for most of the newer * ACPI processor features. */ -static int __cpuinit +static int acpi_processor_eval_pdc(acpi_handle handle, struct acpi_object_list *pdc_in) { acpi_status status = AE_OK; @@ -336,7 +336,7 @@ acpi_processor_eval_pdc(acpi_handle handle, struct acpi_object_list *pdc_in) return status; } -void __cpuinit acpi_processor_set_pdc(acpi_handle handle) +void acpi_processor_set_pdc(acpi_handle handle) { struct acpi_object_list *obj_list; diff --git a/drivers/acpi/processor_driver.c b/drivers/acpi/processor_driver.c index 823be116619e..870eaf5fa547 100644 --- a/drivers/acpi/processor_driver.c +++ b/drivers/acpi/processor_driver.c @@ -118,9 +118,9 @@ static void acpi_processor_notify(acpi_handle handle, u32 event, void *data) return; } -static __cpuinit int __acpi_processor_start(struct acpi_device *device); +static int __acpi_processor_start(struct acpi_device *device); -static int __cpuinit acpi_cpu_soft_notify(struct notifier_block *nfb, +static int acpi_cpu_soft_notify(struct notifier_block *nfb, unsigned long action, void *hcpu) { unsigned int cpu = (unsigned long)hcpu; @@ -162,7 +162,7 @@ static struct notifier_block __refdata acpi_cpu_notifier = .notifier_call = acpi_cpu_soft_notify, }; -static __cpuinit int __acpi_processor_start(struct acpi_device *device) +static int __acpi_processor_start(struct acpi_device *device) { struct acpi_processor *pr = acpi_driver_data(device); acpi_status status; @@ -226,7 +226,7 @@ static __cpuinit int __acpi_processor_start(struct acpi_device *device) return result; } -static int __cpuinit acpi_processor_start(struct device *dev) +static int acpi_processor_start(struct device *dev) { struct acpi_device *device; diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c index 0461ccc92c54..f98dd00b51a9 100644 --- a/drivers/acpi/processor_idle.c +++ b/drivers/acpi/processor_idle.c @@ -96,9 +96,7 @@ static int set_max_cstate(const struct dmi_system_id *id) return 0; } -/* Actually this shouldn't be __cpuinitdata, would be better to fix the - callers to only run once -AK */ -static struct dmi_system_id __cpuinitdata processor_power_dmi_table[] = { +static struct dmi_system_id processor_power_dmi_table[] = { { set_max_cstate, "Clevo 5600D", { DMI_MATCH(DMI_BIOS_VENDOR,"Phoenix Technologies LTD"), DMI_MATCH(DMI_BIOS_VERSION,"SHE845M0.86C.0013.D.0302131307")}, @@ -1165,7 +1163,7 @@ int acpi_processor_cst_has_changed(struct acpi_processor *pr) static int acpi_processor_registered; -int __cpuinit acpi_processor_power_init(struct acpi_processor *pr) +int acpi_processor_power_init(struct acpi_processor *pr) { acpi_status status = 0; int retval; From 013dbb325be702d777118d5e4ffefff3dad2b153 Mon Sep 17 00:00:00 2001 From: Paul Gortmaker Date: Wed, 19 Jun 2013 14:32:33 -0400 Subject: [PATCH 0924/1048] net: delete __cpuinit usage from all net files The __cpuinit type of throwaway sections might have made sense some time ago when RAM was more constrained, but now the savings do not offset the cost and complications. For example, the fix in commit 5e427ec2d0 ("x86: Fix bit corruption at CPU resume time") is a good example of the nasty type of bugs that can be created with improper use of the various __init prefixes. After a discussion on LKML[1] it was decided that cpuinit should go the way of devinit and be phased out. Once all the users are gone, we can then finally remove the macros themselves from linux/init.h. This removes all the net/* uses of the __cpuinit macros from all C files. [1] https://lkml.org/lkml/2013/5/20/589 Cc: "David S. Miller" Cc: netdev@vger.kernel.org Signed-off-by: Paul Gortmaker --- net/core/flow.c | 4 ++-- net/iucv/iucv.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/net/core/flow.c b/net/core/flow.c index 7102f166482d..dfa602ceb8cd 100644 --- a/net/core/flow.c +++ b/net/core/flow.c @@ -403,7 +403,7 @@ void flow_cache_flush_deferred(void) schedule_work(&flow_cache_flush_work); } -static int __cpuinit flow_cache_cpu_prepare(struct flow_cache *fc, int cpu) +static int flow_cache_cpu_prepare(struct flow_cache *fc, int cpu) { struct flow_cache_percpu *fcp = per_cpu_ptr(fc->percpu, cpu); size_t sz = sizeof(struct hlist_head) * flow_cache_hash_size(fc); @@ -421,7 +421,7 @@ static int __cpuinit flow_cache_cpu_prepare(struct flow_cache *fc, int cpu) return 0; } -static int __cpuinit flow_cache_cpu(struct notifier_block *nfb, +static int flow_cache_cpu(struct notifier_block *nfb, unsigned long action, void *hcpu) { diff --git a/net/iucv/iucv.c b/net/iucv/iucv.c index 4fe76ff214c2..cd5b8ec9be04 100644 --- a/net/iucv/iucv.c +++ b/net/iucv/iucv.c @@ -621,7 +621,7 @@ static void iucv_disable(void) put_online_cpus(); } -static int __cpuinit iucv_cpu_notify(struct notifier_block *self, +static int iucv_cpu_notify(struct notifier_block *self, unsigned long action, void *hcpu) { cpumask_t cpumask; From 49fb4c6290c70c418a5c25eee996d6b55ea132d6 Mon Sep 17 00:00:00 2001 From: Paul Gortmaker Date: Wed, 19 Jun 2013 14:52:21 -0400 Subject: [PATCH 0925/1048] rcu: delete __cpuinit usage from all rcu files The __cpuinit type of throwaway sections might have made sense some time ago when RAM was more constrained, but now the savings do not offset the cost and complications. For example, the fix in commit 5e427ec2d0 ("x86: Fix bit corruption at CPU resume time") is a good example of the nasty type of bugs that can be created with improper use of the various __init prefixes. After a discussion on LKML[1] it was decided that cpuinit should go the way of devinit and be phased out. Once all the users are gone, we can then finally remove the macros themselves from linux/init.h. This removes all the drivers/rcu uses of the __cpuinit macros from all C files. [1] https://lkml.org/lkml/2013/5/20/589 Cc: "Paul E. McKenney" Cc: Josh Triplett Cc: Dipankar Sarma Reviewed-by: Josh Triplett Signed-off-by: Paul Gortmaker --- kernel/rcutorture.c | 6 +++--- kernel/rcutree.c | 6 +++--- kernel/rcutree.h | 4 ++-- kernel/rcutree_plugin.h | 6 +++--- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/kernel/rcutorture.c b/kernel/rcutorture.c index b1fa5510388d..f4871e52c546 100644 --- a/kernel/rcutorture.c +++ b/kernel/rcutorture.c @@ -1476,7 +1476,7 @@ rcu_torture_shutdown(void *arg) * Execute random CPU-hotplug operations at the interval specified * by the onoff_interval. */ -static int __cpuinit +static int rcu_torture_onoff(void *arg) { int cpu; @@ -1558,7 +1558,7 @@ rcu_torture_onoff(void *arg) return 0; } -static int __cpuinit +static int rcu_torture_onoff_init(void) { int ret; @@ -1601,7 +1601,7 @@ static void rcu_torture_onoff_cleanup(void) * CPU-stall kthread. It waits as specified by stall_cpu_holdoff, then * induces a CPU stall for the time specified by stall_cpu. */ -static int __cpuinit rcu_torture_stall(void *args) +static int rcu_torture_stall(void *args) { unsigned long stop_at; diff --git a/kernel/rcutree.c b/kernel/rcutree.c index e08abb9461ac..068de3a93606 100644 --- a/kernel/rcutree.c +++ b/kernel/rcutree.c @@ -2910,7 +2910,7 @@ rcu_boot_init_percpu_data(int cpu, struct rcu_state *rsp) * can accept some slop in the rsp->completed access due to the fact * that this CPU cannot possibly have any RCU callbacks in flight yet. */ -static void __cpuinit +static void rcu_init_percpu_data(int cpu, struct rcu_state *rsp, int preemptible) { unsigned long flags; @@ -2962,7 +2962,7 @@ rcu_init_percpu_data(int cpu, struct rcu_state *rsp, int preemptible) mutex_unlock(&rsp->onoff_mutex); } -static void __cpuinit rcu_prepare_cpu(int cpu) +static void rcu_prepare_cpu(int cpu) { struct rcu_state *rsp; @@ -2974,7 +2974,7 @@ static void __cpuinit rcu_prepare_cpu(int cpu) /* * Handle CPU online/offline notification events. */ -static int __cpuinit rcu_cpu_notify(struct notifier_block *self, +static int rcu_cpu_notify(struct notifier_block *self, unsigned long action, void *hcpu) { long cpu = (long)hcpu; diff --git a/kernel/rcutree.h b/kernel/rcutree.h index 4a39d364493c..b3832581043c 100644 --- a/kernel/rcutree.h +++ b/kernel/rcutree.h @@ -521,10 +521,10 @@ static void invoke_rcu_callbacks_kthread(void); static bool rcu_is_callbacks_kthread(void); #ifdef CONFIG_RCU_BOOST static void rcu_preempt_do_callbacks(void); -static int __cpuinit rcu_spawn_one_boost_kthread(struct rcu_state *rsp, +static int rcu_spawn_one_boost_kthread(struct rcu_state *rsp, struct rcu_node *rnp); #endif /* #ifdef CONFIG_RCU_BOOST */ -static void __cpuinit rcu_prepare_kthreads(int cpu); +static void rcu_prepare_kthreads(int cpu); static void rcu_cleanup_after_idle(int cpu); static void rcu_prepare_for_idle(int cpu); static void rcu_idle_count_callbacks_posted(void); diff --git a/kernel/rcutree_plugin.h b/kernel/rcutree_plugin.h index 63098a59216e..769e12e3151b 100644 --- a/kernel/rcutree_plugin.h +++ b/kernel/rcutree_plugin.h @@ -1352,7 +1352,7 @@ static void rcu_preempt_boost_start_gp(struct rcu_node *rnp) * already exist. We only create this kthread for preemptible RCU. * Returns zero if all is well, a negated errno otherwise. */ -static int __cpuinit rcu_spawn_one_boost_kthread(struct rcu_state *rsp, +static int rcu_spawn_one_boost_kthread(struct rcu_state *rsp, struct rcu_node *rnp) { int rnp_index = rnp - &rsp->node[0]; @@ -1507,7 +1507,7 @@ static int __init rcu_spawn_kthreads(void) } early_initcall(rcu_spawn_kthreads); -static void __cpuinit rcu_prepare_kthreads(int cpu) +static void rcu_prepare_kthreads(int cpu) { struct rcu_data *rdp = per_cpu_ptr(rcu_state->rda, cpu); struct rcu_node *rnp = rdp->mynode; @@ -1549,7 +1549,7 @@ static int __init rcu_scheduler_really_started(void) } early_initcall(rcu_scheduler_really_started); -static void __cpuinit rcu_prepare_kthreads(int cpu) +static void rcu_prepare_kthreads(int cpu) { } From 0db0628d90125193280eabb501c94feaf48fa9ab Mon Sep 17 00:00:00 2001 From: Paul Gortmaker Date: Wed, 19 Jun 2013 14:53:51 -0400 Subject: [PATCH 0926/1048] kernel: delete __cpuinit usage from all core kernel files The __cpuinit type of throwaway sections might have made sense some time ago when RAM was more constrained, but now the savings do not offset the cost and complications. For example, the fix in commit 5e427ec2d0 ("x86: Fix bit corruption at CPU resume time") is a good example of the nasty type of bugs that can be created with improper use of the various __init prefixes. After a discussion on LKML[1] it was decided that cpuinit should go the way of devinit and be phased out. Once all the users are gone, we can then finally remove the macros themselves from linux/init.h. This removes all the uses of the __cpuinit macros from C files in the core kernel directories (kernel, init, lib, mm, and include) that don't really have a specific maintainer. [1] https://lkml.org/lkml/2013/5/20/589 Signed-off-by: Paul Gortmaker --- Documentation/cpu-hotplug.txt | 6 +++--- include/linux/cpu.h | 2 +- include/linux/perf_event.h | 2 +- init/calibrate.c | 13 ++++++++----- kernel/cpu.c | 6 +++--- kernel/events/core.c | 4 ++-- kernel/fork.c | 2 +- kernel/hrtimer.c | 6 +++--- kernel/printk.c | 2 +- kernel/profile.c | 2 +- kernel/relay.c | 2 +- kernel/sched/core.c | 12 ++++++------ kernel/sched/fair.c | 2 +- kernel/smp.c | 2 +- kernel/smpboot.c | 2 +- kernel/softirq.c | 8 ++++---- kernel/time/tick-sched.c | 2 +- kernel/timer.c | 10 +++++----- kernel/workqueue.c | 4 ++-- lib/Kconfig.debug | 2 +- lib/earlycpio.c | 2 +- lib/percpu_counter.c | 2 +- mm/memcontrol.c | 2 +- mm/page-writeback.c | 4 ++-- mm/slab.c | 10 +++++----- mm/slub.c | 4 ++-- mm/vmstat.c | 6 +++--- 27 files changed, 62 insertions(+), 59 deletions(-) diff --git a/Documentation/cpu-hotplug.txt b/Documentation/cpu-hotplug.txt index edd4b4df3932..786dc82f98ce 100644 --- a/Documentation/cpu-hotplug.txt +++ b/Documentation/cpu-hotplug.txt @@ -267,8 +267,8 @@ Q: If i have some kernel code that needs to be aware of CPU arrival and A: This is what you would need in your kernel code to receive notifications. #include - static int __cpuinit foobar_cpu_callback(struct notifier_block *nfb, - unsigned long action, void *hcpu) + static int foobar_cpu_callback(struct notifier_block *nfb, + unsigned long action, void *hcpu) { unsigned int cpu = (unsigned long)hcpu; @@ -285,7 +285,7 @@ A: This is what you would need in your kernel code to receive notifications. return NOTIFY_OK; } - static struct notifier_block __cpuinitdata foobar_cpu_notifer = + static struct notifier_block foobar_cpu_notifer = { .notifier_call = foobar_cpu_callback, }; diff --git a/include/linux/cpu.h b/include/linux/cpu.h index 944f283f01c4..ab0eade73039 100644 --- a/include/linux/cpu.h +++ b/include/linux/cpu.h @@ -114,7 +114,7 @@ enum { /* Need to know about CPUs going up/down? */ #if defined(CONFIG_HOTPLUG_CPU) || !defined(MODULE) #define cpu_notifier(fn, pri) { \ - static struct notifier_block fn##_nb __cpuinitdata = \ + static struct notifier_block fn##_nb = \ { .notifier_call = fn, .priority = pri }; \ register_cpu_notifier(&fn##_nb); \ } diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h index 8873f82c7baa..c43f6eabad5b 100644 --- a/include/linux/perf_event.h +++ b/include/linux/perf_event.h @@ -826,7 +826,7 @@ static inline void perf_restore_debug_store(void) { } */ #define perf_cpu_notifier(fn) \ do { \ - static struct notifier_block fn##_nb __cpuinitdata = \ + static struct notifier_block fn##_nb = \ { .notifier_call = fn, .priority = CPU_PRI_PERF }; \ unsigned long cpu = smp_processor_id(); \ unsigned long flags; \ diff --git a/init/calibrate.c b/init/calibrate.c index fda0a7b0f06c..520702db9acc 100644 --- a/init/calibrate.c +++ b/init/calibrate.c @@ -31,7 +31,7 @@ __setup("lpj=", lpj_setup); #define DELAY_CALIBRATION_TICKS ((HZ < 100) ? 1 : (HZ/100)) #define MAX_DIRECT_CALIBRATION_RETRIES 5 -static unsigned long __cpuinit calibrate_delay_direct(void) +static unsigned long calibrate_delay_direct(void) { unsigned long pre_start, start, post_start; unsigned long pre_end, end, post_end; @@ -166,7 +166,10 @@ static unsigned long __cpuinit calibrate_delay_direct(void) return 0; } #else -static unsigned long __cpuinit calibrate_delay_direct(void) {return 0;} +static unsigned long calibrate_delay_direct(void) +{ + return 0; +} #endif /* @@ -180,7 +183,7 @@ static unsigned long __cpuinit calibrate_delay_direct(void) {return 0;} */ #define LPS_PREC 8 -static unsigned long __cpuinit calibrate_delay_converge(void) +static unsigned long calibrate_delay_converge(void) { /* First stage - slowly accelerate to find initial bounds */ unsigned long lpj, lpj_base, ticks, loopadd, loopadd_base, chop_limit; @@ -254,12 +257,12 @@ static DEFINE_PER_CPU(unsigned long, cpu_loops_per_jiffy) = { 0 }; * Architectures should override this function if a faster calibration * method is available. */ -unsigned long __attribute__((weak)) __cpuinit calibrate_delay_is_known(void) +unsigned long __attribute__((weak)) calibrate_delay_is_known(void) { return 0; } -void __cpuinit calibrate_delay(void) +void calibrate_delay(void) { unsigned long lpj; static bool printed; diff --git a/kernel/cpu.c b/kernel/cpu.c index 198a38883e64..b2b227b82123 100644 --- a/kernel/cpu.c +++ b/kernel/cpu.c @@ -366,7 +366,7 @@ EXPORT_SYMBOL(cpu_down); #endif /*CONFIG_HOTPLUG_CPU*/ /* Requires cpu_add_remove_lock to be held */ -static int __cpuinit _cpu_up(unsigned int cpu, int tasks_frozen) +static int _cpu_up(unsigned int cpu, int tasks_frozen) { int ret, nr_calls = 0; void *hcpu = (void *)(long)cpu; @@ -419,7 +419,7 @@ out: return ret; } -int __cpuinit cpu_up(unsigned int cpu) +int cpu_up(unsigned int cpu) { int err = 0; @@ -618,7 +618,7 @@ core_initcall(cpu_hotplug_pm_sync_init); * It must be called by the arch code on the new cpu, before the new cpu * enables interrupts and before the "boot" cpu returns from __cpu_up(). */ -void __cpuinit notify_cpu_starting(unsigned int cpu) +void notify_cpu_starting(unsigned int cpu) { unsigned long val = CPU_STARTING; diff --git a/kernel/events/core.c b/kernel/events/core.c index eba8fb5834ae..f3e9dce39bc9 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -7630,7 +7630,7 @@ static void __init perf_event_init_all_cpus(void) } } -static void __cpuinit perf_event_init_cpu(int cpu) +static void perf_event_init_cpu(int cpu) { struct swevent_htable *swhash = &per_cpu(swevent_htable, cpu); @@ -7719,7 +7719,7 @@ static struct notifier_block perf_reboot_notifier = { .priority = INT_MIN, }; -static int __cpuinit +static int perf_cpu_notify(struct notifier_block *self, unsigned long action, void *hcpu) { unsigned int cpu = (long)hcpu; diff --git a/kernel/fork.c b/kernel/fork.c index 66635c80a813..403d2bb8a968 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -1546,7 +1546,7 @@ static inline void init_idle_pids(struct pid_link *links) } } -struct task_struct * __cpuinit fork_idle(int cpu) +struct task_struct *fork_idle(int cpu) { struct task_struct *task; task = copy_process(CLONE_VM, 0, 0, NULL, &init_struct_pid, 0); diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c index f0f4fe29cd21..383319bae3f7 100644 --- a/kernel/hrtimer.c +++ b/kernel/hrtimer.c @@ -1659,7 +1659,7 @@ SYSCALL_DEFINE2(nanosleep, struct timespec __user *, rqtp, /* * Functions related to boot-time initialization: */ -static void __cpuinit init_hrtimers_cpu(int cpu) +static void init_hrtimers_cpu(int cpu) { struct hrtimer_cpu_base *cpu_base = &per_cpu(hrtimer_bases, cpu); int i; @@ -1740,7 +1740,7 @@ static void migrate_hrtimers(int scpu) #endif /* CONFIG_HOTPLUG_CPU */ -static int __cpuinit hrtimer_cpu_notify(struct notifier_block *self, +static int hrtimer_cpu_notify(struct notifier_block *self, unsigned long action, void *hcpu) { int scpu = (long)hcpu; @@ -1773,7 +1773,7 @@ static int __cpuinit hrtimer_cpu_notify(struct notifier_block *self, return NOTIFY_OK; } -static struct notifier_block __cpuinitdata hrtimers_nb = { +static struct notifier_block hrtimers_nb = { .notifier_call = hrtimer_cpu_notify, }; diff --git a/kernel/printk.c b/kernel/printk.c index d37d45c90ae6..69b0890ed7e5 100644 --- a/kernel/printk.c +++ b/kernel/printk.c @@ -1921,7 +1921,7 @@ void resume_console(void) * called when a new CPU comes online (or fails to come up), and ensures * that any such output gets printed. */ -static int __cpuinit console_cpu_notify(struct notifier_block *self, +static int console_cpu_notify(struct notifier_block *self, unsigned long action, void *hcpu) { switch (action) { diff --git a/kernel/profile.c b/kernel/profile.c index 0bf400737660..6631e1ef55ab 100644 --- a/kernel/profile.c +++ b/kernel/profile.c @@ -331,7 +331,7 @@ out: put_cpu(); } -static int __cpuinit profile_cpu_callback(struct notifier_block *info, +static int profile_cpu_callback(struct notifier_block *info, unsigned long action, void *__cpu) { int node, cpu = (unsigned long)__cpu; diff --git a/kernel/relay.c b/kernel/relay.c index b91488ba2e5a..5001c9887db1 100644 --- a/kernel/relay.c +++ b/kernel/relay.c @@ -516,7 +516,7 @@ static void setup_callbacks(struct rchan *chan, * * Returns the success/failure of the operation. (%NOTIFY_OK, %NOTIFY_BAD) */ -static int __cpuinit relay_hotcpu_callback(struct notifier_block *nb, +static int relay_hotcpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu) { diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 0d8eb4525e76..b7c32cb7bfeb 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -4133,7 +4133,7 @@ void show_state_filter(unsigned long state_filter) debug_show_all_locks(); } -void __cpuinit init_idle_bootup_task(struct task_struct *idle) +void init_idle_bootup_task(struct task_struct *idle) { idle->sched_class = &idle_sched_class; } @@ -4146,7 +4146,7 @@ void __cpuinit init_idle_bootup_task(struct task_struct *idle) * NOTE: this function does not set the idle thread's NEED_RESCHED * flag, to make booting more robust. */ -void __cpuinit init_idle(struct task_struct *idle, int cpu) +void init_idle(struct task_struct *idle, int cpu) { struct rq *rq = cpu_rq(cpu); unsigned long flags; @@ -4630,7 +4630,7 @@ static void set_rq_offline(struct rq *rq) * migration_call - callback that gets triggered when a CPU is added. * Here we can start up the necessary migration thread for the new CPU. */ -static int __cpuinit +static int migration_call(struct notifier_block *nfb, unsigned long action, void *hcpu) { int cpu = (long)hcpu; @@ -4684,12 +4684,12 @@ migration_call(struct notifier_block *nfb, unsigned long action, void *hcpu) * happens before everything else. This has to be lower priority than * the notifier in the perf_event subsystem, though. */ -static struct notifier_block __cpuinitdata migration_notifier = { +static struct notifier_block migration_notifier = { .notifier_call = migration_call, .priority = CPU_PRI_MIGRATION, }; -static int __cpuinit sched_cpu_active(struct notifier_block *nfb, +static int sched_cpu_active(struct notifier_block *nfb, unsigned long action, void *hcpu) { switch (action & ~CPU_TASKS_FROZEN) { @@ -4702,7 +4702,7 @@ static int __cpuinit sched_cpu_active(struct notifier_block *nfb, } } -static int __cpuinit sched_cpu_inactive(struct notifier_block *nfb, +static int sched_cpu_inactive(struct notifier_block *nfb, unsigned long action, void *hcpu) { switch (action & ~CPU_TASKS_FROZEN) { diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index f77f9c527449..bb456f44b7b1 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -5506,7 +5506,7 @@ void nohz_balance_enter_idle(int cpu) set_bit(NOHZ_TICK_STOPPED, nohz_flags(cpu)); } -static int __cpuinit sched_ilb_notifier(struct notifier_block *nfb, +static int sched_ilb_notifier(struct notifier_block *nfb, unsigned long action, void *hcpu) { switch (action & ~CPU_TASKS_FROZEN) { diff --git a/kernel/smp.c b/kernel/smp.c index 4dba0f7b72ad..fe9f773d7114 100644 --- a/kernel/smp.c +++ b/kernel/smp.c @@ -73,7 +73,7 @@ hotplug_cfd(struct notifier_block *nfb, unsigned long action, void *hcpu) return NOTIFY_OK; } -static struct notifier_block __cpuinitdata hotplug_cfd_notifier = { +static struct notifier_block hotplug_cfd_notifier = { .notifier_call = hotplug_cfd, }; diff --git a/kernel/smpboot.c b/kernel/smpboot.c index 02fc5c933673..eb89e1807408 100644 --- a/kernel/smpboot.c +++ b/kernel/smpboot.c @@ -24,7 +24,7 @@ */ static DEFINE_PER_CPU(struct task_struct *, idle_threads); -struct task_struct * __cpuinit idle_thread_get(unsigned int cpu) +struct task_struct *idle_thread_get(unsigned int cpu) { struct task_struct *tsk = per_cpu(idle_threads, cpu); diff --git a/kernel/softirq.c b/kernel/softirq.c index ca25e6e704a2..be3d3514c325 100644 --- a/kernel/softirq.c +++ b/kernel/softirq.c @@ -699,7 +699,7 @@ void send_remote_softirq(struct call_single_data *cp, int cpu, int softirq) } EXPORT_SYMBOL(send_remote_softirq); -static int __cpuinit remote_softirq_cpu_notify(struct notifier_block *self, +static int remote_softirq_cpu_notify(struct notifier_block *self, unsigned long action, void *hcpu) { /* @@ -728,7 +728,7 @@ static int __cpuinit remote_softirq_cpu_notify(struct notifier_block *self, return NOTIFY_OK; } -static struct notifier_block __cpuinitdata remote_softirq_cpu_notifier = { +static struct notifier_block remote_softirq_cpu_notifier = { .notifier_call = remote_softirq_cpu_notify, }; @@ -830,7 +830,7 @@ static void takeover_tasklets(unsigned int cpu) } #endif /* CONFIG_HOTPLUG_CPU */ -static int __cpuinit cpu_callback(struct notifier_block *nfb, +static int cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu) { @@ -845,7 +845,7 @@ static int __cpuinit cpu_callback(struct notifier_block *nfb, return NOTIFY_OK; } -static struct notifier_block __cpuinitdata cpu_nfb = { +static struct notifier_block cpu_nfb = { .notifier_call = cpu_callback }; diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c index 69601726a745..e80183f4a6c4 100644 --- a/kernel/time/tick-sched.c +++ b/kernel/time/tick-sched.c @@ -298,7 +298,7 @@ static int __init tick_nohz_full_setup(char *str) } __setup("nohz_full=", tick_nohz_full_setup); -static int __cpuinit tick_nohz_cpu_down_callback(struct notifier_block *nfb, +static int tick_nohz_cpu_down_callback(struct notifier_block *nfb, unsigned long action, void *hcpu) { diff --git a/kernel/timer.c b/kernel/timer.c index 15bc1b41021d..4296d13db3d1 100644 --- a/kernel/timer.c +++ b/kernel/timer.c @@ -1505,11 +1505,11 @@ signed long __sched schedule_timeout_uninterruptible(signed long timeout) } EXPORT_SYMBOL(schedule_timeout_uninterruptible); -static int __cpuinit init_timers_cpu(int cpu) +static int init_timers_cpu(int cpu) { int j; struct tvec_base *base; - static char __cpuinitdata tvec_base_done[NR_CPUS]; + static char tvec_base_done[NR_CPUS]; if (!tvec_base_done[cpu]) { static char boot_done; @@ -1577,7 +1577,7 @@ static void migrate_timer_list(struct tvec_base *new_base, struct list_head *hea } } -static void __cpuinit migrate_timers(int cpu) +static void migrate_timers(int cpu) { struct tvec_base *old_base; struct tvec_base *new_base; @@ -1610,7 +1610,7 @@ static void __cpuinit migrate_timers(int cpu) } #endif /* CONFIG_HOTPLUG_CPU */ -static int __cpuinit timer_cpu_notify(struct notifier_block *self, +static int timer_cpu_notify(struct notifier_block *self, unsigned long action, void *hcpu) { long cpu = (long)hcpu; @@ -1635,7 +1635,7 @@ static int __cpuinit timer_cpu_notify(struct notifier_block *self, return NOTIFY_OK; } -static struct notifier_block __cpuinitdata timers_nb = { +static struct notifier_block timers_nb = { .notifier_call = timer_cpu_notify, }; diff --git a/kernel/workqueue.c b/kernel/workqueue.c index f02c4a4a0c3c..0b72e816b8d0 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -4644,7 +4644,7 @@ static void restore_unbound_workers_cpumask(struct worker_pool *pool, int cpu) * Workqueues should be brought up before normal priority CPU notifiers. * This will be registered high priority CPU notifier. */ -static int __cpuinit workqueue_cpu_up_callback(struct notifier_block *nfb, +static int workqueue_cpu_up_callback(struct notifier_block *nfb, unsigned long action, void *hcpu) { @@ -4697,7 +4697,7 @@ static int __cpuinit workqueue_cpu_up_callback(struct notifier_block *nfb, * Workqueues should be brought down after normal priority CPU notifiers. * This will be registered as low priority CPU notifier. */ -static int __cpuinit workqueue_cpu_down_callback(struct notifier_block *nfb, +static int workqueue_cpu_down_callback(struct notifier_block *nfb, unsigned long action, void *hcpu) { diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index 98ac17ed6222..1501aa553221 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -238,7 +238,7 @@ config DEBUG_SECTION_MISMATCH any use of code/data previously in these sections would most likely result in an oops. In the code, functions and variables are annotated with - __init, __cpuinit, etc. (see the full list in include/linux/init.h), + __init,, etc. (see the full list in include/linux/init.h), which results in the code/data being placed in specific sections. The section mismatch analysis is always performed after a full kernel build, and enabling this option causes the following diff --git a/lib/earlycpio.c b/lib/earlycpio.c index 8078ef49cb79..7aa7ce250c94 100644 --- a/lib/earlycpio.c +++ b/lib/earlycpio.c @@ -63,7 +63,7 @@ enum cpio_fields { * the match returned an empty filename string. */ -struct cpio_data __cpuinit find_cpio_data(const char *path, void *data, +struct cpio_data find_cpio_data(const char *path, void *data, size_t len, long *offset) { const size_t cpio_header_len = 8*C_NFIELDS - 2; diff --git a/lib/percpu_counter.c b/lib/percpu_counter.c index 1fc23a3277e1..93c5d5ecff4e 100644 --- a/lib/percpu_counter.c +++ b/lib/percpu_counter.c @@ -158,7 +158,7 @@ static void compute_batch_value(void) percpu_counter_batch = max(32, nr*2); } -static int __cpuinit percpu_counter_hotcpu_callback(struct notifier_block *nb, +static int percpu_counter_hotcpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu) { #ifdef CONFIG_HOTPLUG_CPU diff --git a/mm/memcontrol.c b/mm/memcontrol.c index d12ca6f3c293..00a7a664b9c1 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -2522,7 +2522,7 @@ static void mem_cgroup_drain_pcp_counter(struct mem_cgroup *memcg, int cpu) spin_unlock(&memcg->pcp_counter_lock); } -static int __cpuinit memcg_cpu_hotplug_callback(struct notifier_block *nb, +static int memcg_cpu_hotplug_callback(struct notifier_block *nb, unsigned long action, void *hcpu) { diff --git a/mm/page-writeback.c b/mm/page-writeback.c index 4514ad7415c3..3f0c895c71fe 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -1619,7 +1619,7 @@ void writeback_set_ratelimit(void) ratelimit_pages = 16; } -static int __cpuinit +static int ratelimit_handler(struct notifier_block *self, unsigned long action, void *hcpu) { @@ -1634,7 +1634,7 @@ ratelimit_handler(struct notifier_block *self, unsigned long action, } } -static struct notifier_block __cpuinitdata ratelimit_nb = { +static struct notifier_block ratelimit_nb = { .notifier_call = ratelimit_handler, .next = NULL, }; diff --git a/mm/slab.c b/mm/slab.c index 35cb0c861508..2580db062df9 100644 --- a/mm/slab.c +++ b/mm/slab.c @@ -787,7 +787,7 @@ static void next_reap_node(void) * the CPUs getting into lockstep and contending for the global cache chain * lock. */ -static void __cpuinit start_cpu_timer(int cpu) +static void start_cpu_timer(int cpu) { struct delayed_work *reap_work = &per_cpu(slab_reap_work, cpu); @@ -1186,7 +1186,7 @@ static inline int slabs_tofree(struct kmem_cache *cachep, return (n->free_objects + cachep->num - 1) / cachep->num; } -static void __cpuinit cpuup_canceled(long cpu) +static void cpuup_canceled(long cpu) { struct kmem_cache *cachep; struct kmem_cache_node *n = NULL; @@ -1251,7 +1251,7 @@ free_array_cache: } } -static int __cpuinit cpuup_prepare(long cpu) +static int cpuup_prepare(long cpu) { struct kmem_cache *cachep; struct kmem_cache_node *n = NULL; @@ -1334,7 +1334,7 @@ bad: return -ENOMEM; } -static int __cpuinit cpuup_callback(struct notifier_block *nfb, +static int cpuup_callback(struct notifier_block *nfb, unsigned long action, void *hcpu) { long cpu = (long)hcpu; @@ -1390,7 +1390,7 @@ static int __cpuinit cpuup_callback(struct notifier_block *nfb, return notifier_from_errno(err); } -static struct notifier_block __cpuinitdata cpucache_notifier = { +static struct notifier_block cpucache_notifier = { &cpuup_callback, NULL, 0 }; diff --git a/mm/slub.c b/mm/slub.c index 3b482c863002..2b02d666bf63 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -3773,7 +3773,7 @@ int __kmem_cache_create(struct kmem_cache *s, unsigned long flags) * Use the cpu notifier to insure that the cpu slabs are flushed when * necessary. */ -static int __cpuinit slab_cpuup_callback(struct notifier_block *nfb, +static int slab_cpuup_callback(struct notifier_block *nfb, unsigned long action, void *hcpu) { long cpu = (long)hcpu; @@ -3799,7 +3799,7 @@ static int __cpuinit slab_cpuup_callback(struct notifier_block *nfb, return NOTIFY_OK; } -static struct notifier_block __cpuinitdata slab_notifier = { +static struct notifier_block slab_notifier = { .notifier_call = slab_cpuup_callback }; diff --git a/mm/vmstat.c b/mm/vmstat.c index f42745e65780..20c2ef4458fa 100644 --- a/mm/vmstat.c +++ b/mm/vmstat.c @@ -1182,7 +1182,7 @@ static void vmstat_update(struct work_struct *w) round_jiffies_relative(sysctl_stat_interval)); } -static void __cpuinit start_cpu_timer(int cpu) +static void start_cpu_timer(int cpu) { struct delayed_work *work = &per_cpu(vmstat_work, cpu); @@ -1194,7 +1194,7 @@ static void __cpuinit start_cpu_timer(int cpu) * Use the cpu notifier to insure that the thresholds are recalculated * when necessary. */ -static int __cpuinit vmstat_cpuup_callback(struct notifier_block *nfb, +static int vmstat_cpuup_callback(struct notifier_block *nfb, unsigned long action, void *hcpu) { @@ -1226,7 +1226,7 @@ static int __cpuinit vmstat_cpuup_callback(struct notifier_block *nfb, return NOTIFY_OK; } -static struct notifier_block __cpuinitdata vmstat_notifier = +static struct notifier_block vmstat_notifier = { &vmstat_cpuup_callback, NULL, 0 }; #endif From a83048ebd449a441fdbd3fa854e6b1a71552cc99 Mon Sep 17 00:00:00 2001 From: Paul Gortmaker Date: Wed, 19 Jun 2013 15:22:41 -0400 Subject: [PATCH 0927/1048] drivers: delete __cpuinit usage from all remaining drivers files The __cpuinit type of throwaway sections might have made sense some time ago when RAM was more constrained, but now the savings do not offset the cost and complications. For example, the fix in commit 5e427ec2d0 ("x86: Fix bit corruption at CPU resume time") is a good example of the nasty type of bugs that can be created with improper use of the various __init prefixes. After a discussion on LKML[1] it was decided that cpuinit should go the way of devinit and be phased out. Once all the users are gone, we can then finally remove the macros themselves from linux/init.h. This removes all the remaining one-off uses of the __cpuinit macros from all C files in the drivers/* directory. [1] https://lkml.org/lkml/2013/5/20/589 Cc: Greg Kroah-Hartman Acked-by: Greg Kroah-Hartman Signed-off-by: Paul Gortmaker --- drivers/base/cpu.c | 2 +- drivers/base/topology.c | 10 +++++----- drivers/oprofile/timer_int.c | 4 ++-- drivers/xen/xen-acpi-cpuhotplug.c | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c index a16d20e389f0..4c358bc44c72 100644 --- a/drivers/base/cpu.c +++ b/drivers/base/cpu.c @@ -278,7 +278,7 @@ static void cpu_device_release(struct device *dev) * * Initialize and register the CPU device. */ -int __cpuinit register_cpu(struct cpu *cpu, int num) +int register_cpu(struct cpu *cpu, int num) { int error; diff --git a/drivers/base/topology.c b/drivers/base/topology.c index ae989c57cd5e..2f5919ed91ab 100644 --- a/drivers/base/topology.c +++ b/drivers/base/topology.c @@ -143,22 +143,22 @@ static struct attribute_group topology_attr_group = { }; /* Add/Remove cpu_topology interface for CPU device */ -static int __cpuinit topology_add_dev(unsigned int cpu) +static int topology_add_dev(unsigned int cpu) { struct device *dev = get_cpu_device(cpu); return sysfs_create_group(&dev->kobj, &topology_attr_group); } -static void __cpuinit topology_remove_dev(unsigned int cpu) +static void topology_remove_dev(unsigned int cpu) { struct device *dev = get_cpu_device(cpu); sysfs_remove_group(&dev->kobj, &topology_attr_group); } -static int __cpuinit topology_cpu_callback(struct notifier_block *nfb, - unsigned long action, void *hcpu) +static int topology_cpu_callback(struct notifier_block *nfb, + unsigned long action, void *hcpu) { unsigned int cpu = (unsigned long)hcpu; int rc = 0; @@ -178,7 +178,7 @@ static int __cpuinit topology_cpu_callback(struct notifier_block *nfb, return notifier_from_errno(rc); } -static int __cpuinit topology_sysfs_init(void) +static int topology_sysfs_init(void) { int cpu; int rc; diff --git a/drivers/oprofile/timer_int.c b/drivers/oprofile/timer_int.c index 93404f72dfa8..61be1d9c16c8 100644 --- a/drivers/oprofile/timer_int.c +++ b/drivers/oprofile/timer_int.c @@ -74,8 +74,8 @@ static void oprofile_hrtimer_stop(void) put_online_cpus(); } -static int __cpuinit oprofile_cpu_notify(struct notifier_block *self, - unsigned long action, void *hcpu) +static int oprofile_cpu_notify(struct notifier_block *self, + unsigned long action, void *hcpu) { long cpu = (long) hcpu; diff --git a/drivers/xen/xen-acpi-cpuhotplug.c b/drivers/xen/xen-acpi-cpuhotplug.c index 0caf4863be8c..8dae6c13063a 100644 --- a/drivers/xen/xen-acpi-cpuhotplug.c +++ b/drivers/xen/xen-acpi-cpuhotplug.c @@ -91,7 +91,7 @@ static int xen_acpi_processor_enable(struct acpi_device *device) return 0; } -static int __cpuinit xen_acpi_processor_add(struct acpi_device *device) +static int xen_acpi_processor_add(struct acpi_device *device) { int ret; struct acpi_processor *pr; From 0b776b062843b63cb4c9acdfc092b2581be3c2f6 Mon Sep 17 00:00:00 2001 From: Paul Gortmaker Date: Wed, 19 Jun 2013 15:26:23 -0400 Subject: [PATCH 0928/1048] block: delete __cpuinit usage from all block files The __cpuinit type of throwaway sections might have made sense some time ago when RAM was more constrained, but now the savings do not offset the cost and complications. For example, the fix in commit 5e427ec2d0 ("x86: Fix bit corruption at CPU resume time") is a good example of the nasty type of bugs that can be created with improper use of the various __init prefixes. After a discussion on LKML[1] it was decided that cpuinit should go the way of devinit and be phased out. Once all the users are gone, we can then finally remove the macros themselves from linux/init.h. This removes all the drivers/block uses of the __cpuinit macros from all C files. [1] https://lkml.org/lkml/2013/5/20/589 Cc: Jens Axboe Signed-off-by: Paul Gortmaker --- block/blk-iopoll.c | 6 +++--- block/blk-softirq.c | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/block/blk-iopoll.c b/block/blk-iopoll.c index 58916afbbda5..4b8d9b541112 100644 --- a/block/blk-iopoll.c +++ b/block/blk-iopoll.c @@ -189,8 +189,8 @@ void blk_iopoll_init(struct blk_iopoll *iop, int weight, blk_iopoll_fn *poll_fn) } EXPORT_SYMBOL(blk_iopoll_init); -static int __cpuinit blk_iopoll_cpu_notify(struct notifier_block *self, - unsigned long action, void *hcpu) +static int blk_iopoll_cpu_notify(struct notifier_block *self, + unsigned long action, void *hcpu) { /* * If a CPU goes away, splice its entries to the current CPU @@ -209,7 +209,7 @@ static int __cpuinit blk_iopoll_cpu_notify(struct notifier_block *self, return NOTIFY_OK; } -static struct notifier_block __cpuinitdata blk_iopoll_cpu_notifier = { +static struct notifier_block blk_iopoll_cpu_notifier = { .notifier_call = blk_iopoll_cpu_notify, }; diff --git a/block/blk-softirq.c b/block/blk-softirq.c index 467c8de88642..ec9e60636f43 100644 --- a/block/blk-softirq.c +++ b/block/blk-softirq.c @@ -78,8 +78,8 @@ static int raise_blk_irq(int cpu, struct request *rq) } #endif -static int __cpuinit blk_cpu_notify(struct notifier_block *self, - unsigned long action, void *hcpu) +static int blk_cpu_notify(struct notifier_block *self, unsigned long action, + void *hcpu) { /* * If a CPU goes away, splice its entries to the current CPU @@ -98,7 +98,7 @@ static int __cpuinit blk_cpu_notify(struct notifier_block *self, return NOTIFY_OK; } -static struct notifier_block __cpuinitdata blk_cpu_notifier = { +static struct notifier_block blk_cpu_notifier = { .notifier_call = blk_cpu_notify, }; From 8acd5e9b1217e58a57124d9e225afa12efeae20d Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Mon, 15 Jul 2013 00:09:19 -0400 Subject: [PATCH 0929/1048] ext4: fix error handling in ext4_ext_truncate() Previously ext4_ext_truncate() was ignoring potential error returns from ext4_es_remove_extent() and ext4_ext_remove_space(). This can lead to the on-diks extent tree and the extent status tree cache getting out of sync, which is particuarlly bad, and can lead to file system corruption and potential data loss. Signed-off-by: "Theodore Ts'o" Cc: stable@vger.kernel.org --- fs/ext4/extents.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c index 7097b0f680e6..f57cc0e7f1bc 100644 --- a/fs/ext4/extents.c +++ b/fs/ext4/extents.c @@ -4405,9 +4405,20 @@ void ext4_ext_truncate(handle_t *handle, struct inode *inode) last_block = (inode->i_size + sb->s_blocksize - 1) >> EXT4_BLOCK_SIZE_BITS(sb); +retry: err = ext4_es_remove_extent(inode, last_block, EXT_MAX_BLOCKS - last_block); + if (err == ENOMEM) { + cond_resched(); + congestion_wait(BLK_RW_ASYNC, HZ/50); + goto retry; + } + if (err) { + ext4_std_error(inode->i_sb, err); + return; + } err = ext4_ext_remove_space(inode, last_block, EXT_MAX_BLOCKS - 1); + ext4_std_error(inode->i_sb, err); } static void ext4_falloc_update_inode(struct inode *inode, From c8e15130e1636f68d5165aa2605b8e9cba0f644c Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Mon, 15 Jul 2013 00:09:37 -0400 Subject: [PATCH 0930/1048] ext4: simplify calculation of blocks to free on error In ext4_ext_map_blocks(), if we have successfully allocated the data blocks, but then run into trouble inserting the extent into the extent tree, most likely due to an ENOSPC condition, determine the arguments to ext4_free_blocks() in a simpler way which is easier to prove to be correct. Signed-off-by: "Theodore Ts'o" --- fs/ext4/extents.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c index f57cc0e7f1bc..593091537e76 100644 --- a/fs/ext4/extents.c +++ b/fs/ext4/extents.c @@ -4261,8 +4261,8 @@ got_allocated_blocks: /* not a good idea to call discard here directly, * but otherwise we'd need to call it every free() */ ext4_discard_preallocations(inode); - ext4_free_blocks(handle, inode, NULL, ext4_ext_pblock(&newex), - ext4_ext_get_actual_len(&newex), fb_flags); + ext4_free_blocks(handle, inode, NULL, newblock, + EXT4_C2B(sbi, allocated_clusters), fb_flags); goto out2; } From e15f742ce816076497549b955fbec3254820db85 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Mon, 15 Jul 2013 00:12:14 -0400 Subject: [PATCH 0931/1048] ext4: make the extent_status code more robust against ENOMEM failures Some callers of ext4_es_remove_extent() and ext4_es_insert_extent() may not be completely robust against ENOMEM failures (or the consequences of reflecting ENOMEM back up to userspace may lead to xfstest or user application failure). To mitigate against this, when trying to insert an entry in the extent status tree, try to shrink the inode's extent status tree before returning ENOMEM. If there are entries which don't record information about extents under delayed allocations, freeing one of them is preferable to returning ENOMEM. Signed-off-by: "Theodore Ts'o" Reviewed-by: Zheng Liu --- fs/ext4/extents_status.c | 51 ++++++++++++++++++++++++++++++---------- 1 file changed, 39 insertions(+), 12 deletions(-) diff --git a/fs/ext4/extents_status.c b/fs/ext4/extents_status.c index 4b8df7fbb10a..91cb110da1b4 100644 --- a/fs/ext4/extents_status.c +++ b/fs/ext4/extents_status.c @@ -148,6 +148,8 @@ static int __es_remove_extent(struct inode *inode, ext4_lblk_t lblk, ext4_lblk_t end); static int __es_try_to_reclaim_extents(struct ext4_inode_info *ei, int nr_to_scan); +static int __ext4_es_shrink(struct ext4_sb_info *sbi, int nr_to_scan, + struct ext4_inode_info *locked_ei); int __init ext4_init_es(void) { @@ -665,7 +667,13 @@ int ext4_es_insert_extent(struct inode *inode, ext4_lblk_t lblk, err = __es_remove_extent(inode, lblk, end); if (err != 0) goto error; +retry: err = __es_insert_extent(inode, &newes); + if (err == -ENOMEM && __ext4_es_shrink(EXT4_SB(inode->i_sb), 1, + EXT4_I(inode))) + goto retry; + if (err == -ENOMEM && !ext4_es_is_delayed(&newes)) + err = 0; error: write_unlock(&EXT4_I(inode)->i_es_lock); @@ -744,8 +752,10 @@ static int __es_remove_extent(struct inode *inode, ext4_lblk_t lblk, struct extent_status orig_es; ext4_lblk_t len1, len2; ext4_fsblk_t block; - int err = 0; + int err; +retry: + err = 0; es = __es_tree_search(&tree->root, lblk); if (!es) goto out; @@ -780,6 +790,10 @@ static int __es_remove_extent(struct inode *inode, ext4_lblk_t lblk, if (err) { es->es_lblk = orig_es.es_lblk; es->es_len = orig_es.es_len; + if ((err == -ENOMEM) && + __ext4_es_shrink(EXT4_SB(inode->i_sb), 1, + EXT4_I(inode))) + goto retry; goto out; } } else { @@ -889,22 +903,14 @@ static int ext4_inode_touch_time_cmp(void *priv, struct list_head *a, return -1; } -static int ext4_es_shrink(struct shrinker *shrink, struct shrink_control *sc) +static int __ext4_es_shrink(struct ext4_sb_info *sbi, int nr_to_scan, + struct ext4_inode_info *locked_ei) { - struct ext4_sb_info *sbi = container_of(shrink, - struct ext4_sb_info, s_es_shrinker); struct ext4_inode_info *ei; struct list_head *cur, *tmp; LIST_HEAD(skiped); - int nr_to_scan = sc->nr_to_scan; int ret, nr_shrunk = 0; - ret = percpu_counter_read_positive(&sbi->s_extent_cache_cnt); - trace_ext4_es_shrink_enter(sbi->s_sb, nr_to_scan, ret); - - if (!nr_to_scan) - return ret; - spin_lock(&sbi->s_es_lru_lock); /* @@ -933,7 +939,7 @@ static int ext4_es_shrink(struct shrinker *shrink, struct shrink_control *sc) continue; } - if (ei->i_es_lru_nr == 0) + if (ei->i_es_lru_nr == 0 || ei == locked_ei) continue; write_lock(&ei->i_es_lock); @@ -952,6 +958,27 @@ static int ext4_es_shrink(struct shrinker *shrink, struct shrink_control *sc) list_splice_tail(&skiped, &sbi->s_es_lru); spin_unlock(&sbi->s_es_lru_lock); + if (locked_ei && nr_shrunk == 0) + nr_shrunk = __es_try_to_reclaim_extents(ei, nr_to_scan); + + return nr_shrunk; +} + +static int ext4_es_shrink(struct shrinker *shrink, struct shrink_control *sc) +{ + struct ext4_sb_info *sbi = container_of(shrink, + struct ext4_sb_info, s_es_shrinker); + int nr_to_scan = sc->nr_to_scan; + int ret, nr_shrunk; + + ret = percpu_counter_read_positive(&sbi->s_extent_cache_cnt); + trace_ext4_es_shrink_enter(sbi->s_sb, nr_to_scan, ret); + + if (!nr_to_scan) + return ret; + + nr_shrunk = __ext4_es_shrink(sbi, nr_to_scan, NULL); + ret = percpu_counter_read_positive(&sbi->s_extent_cache_cnt); trace_ext4_es_shrink_exit(sbi->s_sb, nr_shrunk, ret); return ret; From 8331b9e332a6e72d5285b05f56a7b66b692cb67a Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 15 Jul 2013 11:58:55 +0200 Subject: [PATCH 0932/1048] sound: oss/vwsnd: Add missing inclusion of linux/delay.h Reported-by: Fengguang Wu Signed-off-by: Takashi Iwai --- sound/oss/vwsnd.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sound/oss/vwsnd.c b/sound/oss/vwsnd.c index 7e814a5c3677..d8db9023bc55 100644 --- a/sound/oss/vwsnd.c +++ b/sound/oss/vwsnd.c @@ -149,6 +149,7 @@ #include #include #include +#include #include From 4b8846062faac4e5c3f08e2e06bbb33c949aa51f Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 15 Jul 2013 12:00:24 +0200 Subject: [PATCH 0933/1048] sound: oss/vwsnd: Always define vwsnd_mutex While the conversion of BKL to mutex in commit 645ef9ef, the mutex definition was put in a wrong place inside #ifdef WSND_DEBUG, which leads to the build error. Just move it outside the ifdef. Reported-by: Fengguang Wu Signed-off-by: Takashi Iwai --- sound/oss/vwsnd.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sound/oss/vwsnd.c b/sound/oss/vwsnd.c index d8db9023bc55..4bbcc0fcd4eb 100644 --- a/sound/oss/vwsnd.c +++ b/sound/oss/vwsnd.c @@ -155,12 +155,13 @@ #include "sound_config.h" +static DEFINE_MUTEX(vwsnd_mutex); + /*****************************************************************************/ /* debug stuff */ #ifdef VWSND_DEBUG -static DEFINE_MUTEX(vwsnd_mutex); static int shut_up = 1; /* From 1c01103cb90197900beb534911de558d7a43d0b3 Mon Sep 17 00:00:00 2001 From: Alex Deucher Date: Fri, 12 Jul 2013 15:56:02 -0400 Subject: [PATCH 0934/1048] drm/radeon: align VM PTBs (Page Table Blocks) to 32K MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Covers requirements of all current asics. Reviewed-by: Christian König Signed-off-by: Alex Deucher Cc: stable@vger.kernel.org --- drivers/gpu/drm/radeon/radeon.h | 5 +++++ drivers/gpu/drm/radeon/radeon_gart.c | 12 ++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h index 82e8e36064e3..001081757895 100644 --- a/drivers/gpu/drm/radeon/radeon.h +++ b/drivers/gpu/drm/radeon/radeon.h @@ -784,6 +784,11 @@ struct radeon_mec { /* number of entries in page table */ #define RADEON_VM_PTE_COUNT (1 << RADEON_VM_BLOCK_SIZE) +/* PTBs (Page Table Blocks) need to be aligned to 32K */ +#define RADEON_VM_PTB_ALIGN_SIZE 32768 +#define RADEON_VM_PTB_ALIGN_MASK (RADEON_VM_PTB_ALIGN_SIZE - 1) +#define RADEON_VM_PTB_ALIGN(a) (((a) + RADEON_VM_PTB_ALIGN_MASK) & ~RADEON_VM_PTB_ALIGN_MASK) + struct radeon_vm { struct list_head list; struct list_head va; diff --git a/drivers/gpu/drm/radeon/radeon_gart.c b/drivers/gpu/drm/radeon/radeon_gart.c index 5ce190b8bd1f..d9d31a383276 100644 --- a/drivers/gpu/drm/radeon/radeon_gart.c +++ b/drivers/gpu/drm/radeon/radeon_gart.c @@ -466,8 +466,8 @@ int radeon_vm_manager_init(struct radeon_device *rdev) size += rdev->vm_manager.max_pfn * 8; size *= 2; r = radeon_sa_bo_manager_init(rdev, &rdev->vm_manager.sa_manager, - RADEON_GPU_PAGE_ALIGN(size), - RADEON_GPU_PAGE_SIZE, + RADEON_VM_PTB_ALIGN(size), + RADEON_VM_PTB_ALIGN_SIZE, RADEON_GEM_DOMAIN_VRAM); if (r) { dev_err(rdev->dev, "failed to allocate vm bo (%dKB)\n", @@ -621,10 +621,10 @@ int radeon_vm_alloc_pt(struct radeon_device *rdev, struct radeon_vm *vm) } retry: - pd_size = RADEON_GPU_PAGE_ALIGN(radeon_vm_directory_size(rdev)); + pd_size = RADEON_VM_PTB_ALIGN(radeon_vm_directory_size(rdev)); r = radeon_sa_bo_new(rdev, &rdev->vm_manager.sa_manager, &vm->page_directory, pd_size, - RADEON_GPU_PAGE_SIZE, false); + RADEON_VM_PTB_ALIGN_SIZE, false); if (r == -ENOMEM) { r = radeon_vm_evict(rdev, vm); if (r) @@ -953,8 +953,8 @@ static int radeon_vm_update_pdes(struct radeon_device *rdev, retry: r = radeon_sa_bo_new(rdev, &rdev->vm_manager.sa_manager, &vm->page_tables[pt_idx], - RADEON_VM_PTE_COUNT * 8, - RADEON_GPU_PAGE_SIZE, false); + RADEON_VM_PTB_ALIGN(RADEON_VM_PTE_COUNT * 8), + RADEON_VM_PTB_ALIGN_SIZE, false); if (r == -ENOMEM) { r = radeon_vm_evict(rdev, vm); From 13f69c2c9ce151773b30e0d7df2f1b66cc696f67 Mon Sep 17 00:00:00 2001 From: Alex Deucher Date: Fri, 12 Jul 2013 18:40:40 -0400 Subject: [PATCH 0935/1048] drm/radeon/dpm/sumo: handle boost states properly when forcing a perf level MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Need to properly enable/disable boost states when forcing a performance level. Reviewed-by: Christian König Signed-off-by: Alex Deucher --- drivers/gpu/drm/radeon/sumo_dpm.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/gpu/drm/radeon/sumo_dpm.c b/drivers/gpu/drm/radeon/sumo_dpm.c index ca381028bd7b..c0a850319908 100644 --- a/drivers/gpu/drm/radeon/sumo_dpm.c +++ b/drivers/gpu/drm/radeon/sumo_dpm.c @@ -1851,6 +1851,8 @@ int sumo_dpm_force_performance_level(struct radeon_device *rdev, return 0; if (level == RADEON_DPM_FORCED_LEVEL_HIGH) { + if (pi->enable_boost) + sumo_enable_boost(rdev, rps, false); sumo_power_level_enable(rdev, ps->num_levels - 1, true); sumo_set_forced_level(rdev, ps->num_levels - 1); sumo_set_forced_mode_enabled(rdev); @@ -1861,6 +1863,8 @@ int sumo_dpm_force_performance_level(struct radeon_device *rdev, sumo_set_forced_mode_enabled(rdev); sumo_set_forced_mode(rdev, false); } else if (level == RADEON_DPM_FORCED_LEVEL_LOW) { + if (pi->enable_boost) + sumo_enable_boost(rdev, rps, false); sumo_power_level_enable(rdev, 0, true); sumo_set_forced_level(rdev, 0); sumo_set_forced_mode_enabled(rdev); @@ -1874,6 +1878,8 @@ int sumo_dpm_force_performance_level(struct radeon_device *rdev, for (i = 0; i < ps->num_levels; i++) { sumo_power_level_enable(rdev, i, true); } + if (pi->enable_boost) + sumo_enable_boost(rdev, rps, true); } rdev->pm.dpm.forced_level = level; From a01c34f72e7cd2624570818f579b5ab464f93de2 Mon Sep 17 00:00:00 2001 From: Sergey Senozhatsky Date: Sun, 14 Jul 2013 14:03:27 +0300 Subject: [PATCH 0936/1048] radeon kms: do not flush uninitialized hotplug work Fix a warning from lockdep caused by calling flush_work() for uninitialized hotplug work. Initialize hotplug_work, audio_work and reset_work upon successful radeon_irq_kms_init() completion and thus perform hotplug flush_work only when rdev->irq.installed is true. [ 4.790019] [drm] Loading CEDAR Microcode [ 4.790943] r600_cp: Failed to load firmware "radeon/CEDAR_smc.bin" [ 4.791152] [drm:evergreen_startup] *ERROR* Failed to load firmware! [ 4.791330] radeon 0000:01:00.0: disabling GPU acceleration [ 4.792633] INFO: trying to register non-static key. [ 4.792792] the code is fine but needs lockdep annotation. [ 4.792953] turning off the locking correctness validator. [ 4.793114] CPU: 2 PID: 1 Comm: swapper/0 Not tainted 3.11.0-rc0-dbg-10676-gfe56456-dirty #1816 [ 4.793314] Hardware name: Acer Aspire 5741G /Aspire 5741G , BIOS V1.20 02/08/2011 [ 4.793507] ffffffff821fd810 ffff8801530b9a18 ffffffff8160434e 0000000000000002 [ 4.794155] ffff8801530b9ad8 ffffffff810b8404 ffff8801530b0798 ffff8801530b0000 [ 4.794789] ffff8801530b9b00 0000000000000046 00000000000004c0 ffffffff00000000 [ 4.795418] Call Trace: [ 4.795573] [] dump_stack+0x4e/0x82 [ 4.795731] [] __lock_acquire+0x1a64/0x1d30 [ 4.795893] [] ? dev_vprintk_emit+0x50/0x60 [ 4.796034] [] lock_acquire+0xa4/0x200 [ 4.796216] [] ? flush_work+0x5/0x280 [ 4.796375] [] flush_work+0x3d/0x280 [ 4.796520] [] ? flush_work+0x5/0x280 [ 4.796682] [] ? trace_hardirqs_on_caller+0xfd/0x1c0 [ 4.796862] [] ? delay_tsc+0x95/0xf0 [ 4.797024] [] radeon_irq_kms_fini+0x2b/0x70 [ 4.797186] [] evergreen_init+0x2a9/0x2e0 [ 4.797347] [] radeon_device_init+0x5ef/0x700 [ 4.797511] [] ? pci_find_capability+0x47/0x50 [ 4.797672] [] radeon_driver_load_kms+0x8d/0x150 [ 4.797843] [] drm_get_pci_dev+0x166/0x280 [ 4.798007] [] ? kfree+0xf5/0x2e0 [ 4.798168] [] ? radeon_pci_probe+0x98/0xd0 [ 4.798329] [] radeon_pci_probe+0xaa/0xd0 [ 4.798489] [] pci_device_probe+0x84/0xe0 [ 4.798644] [] driver_probe_device+0x76/0x240 [ 4.798805] [] __driver_attach+0x93/0xa0 [ 4.798948] [] ? __device_attach+0x40/0x40 [ 4.799126] [] bus_for_each_dev+0x6b/0xb0 [ 4.799272] [] driver_attach+0x1e/0x20 [ 4.799434] [] bus_add_driver+0x1f0/0x280 [ 4.799596] [] driver_register+0x74/0x150 [ 4.799758] [] __pci_register_driver+0x5d/0x60 [ 4.799936] [] ? ttm_init+0x67/0x67 [ 4.800081] [] drm_pci_init+0x115/0x130 [ 4.800243] [] ? ttm_init+0x67/0x67 [ 4.800405] [] radeon_init+0x9c/0xba [ 4.800586] [] do_one_initcall+0xfa/0x150 [ 4.800746] [] ? parse_args+0x120/0x330 [ 4.800909] [] kernel_init_freeable+0x111/0x191 [ 4.801052] [] ? do_early_param+0x88/0x88 [ 4.801233] [] ? rest_init+0x140/0x140 [ 4.801393] [] kernel_init+0xe/0x180 [ 4.801556] [] ret_from_fork+0x7c/0xb0 [ 4.801718] [] ? rest_init+0x140/0x140 Signed-off-by: Sergey Senozhatsky Signed-off-by: Alex Deucher Cc: stable@vger.kernel.org --- drivers/gpu/drm/radeon/radeon_irq_kms.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/radeon/radeon_irq_kms.c b/drivers/gpu/drm/radeon/radeon_irq_kms.c index bcdefd1dcd43..081886b0642d 100644 --- a/drivers/gpu/drm/radeon/radeon_irq_kms.c +++ b/drivers/gpu/drm/radeon/radeon_irq_kms.c @@ -260,10 +260,6 @@ int radeon_irq_kms_init(struct radeon_device *rdev) { int r = 0; - INIT_WORK(&rdev->hotplug_work, radeon_hotplug_work_func); - INIT_WORK(&rdev->audio_work, r600_audio_update_hdmi); - INIT_WORK(&rdev->reset_work, radeon_irq_reset_work_func); - spin_lock_init(&rdev->irq.lock); r = drm_vblank_init(rdev->ddev, rdev->num_crtc); if (r) { @@ -285,6 +281,11 @@ int radeon_irq_kms_init(struct radeon_device *rdev) rdev->irq.installed = false; return r; } + + INIT_WORK(&rdev->hotplug_work, radeon_hotplug_work_func); + INIT_WORK(&rdev->audio_work, r600_audio_update_hdmi); + INIT_WORK(&rdev->reset_work, radeon_irq_reset_work_func); + DRM_INFO("radeon: irq initialized.\n"); return 0; } @@ -304,8 +305,8 @@ void radeon_irq_kms_fini(struct radeon_device *rdev) rdev->irq.installed = false; if (rdev->msi_enabled) pci_disable_msi(rdev->pdev); + flush_work(&rdev->hotplug_work); } - flush_work(&rdev->hotplug_work); } /** From 1540c5d3cbf7670eb68a0d02611ec73e5604a91a Mon Sep 17 00:00:00 2001 From: Trond Myklebust Date: Sun, 14 Jul 2013 22:57:50 -0400 Subject: [PATCH 0937/1048] SUNRPC: Fix another issue with rpc_client_register() Fix the error pathway if rpcauth_create() fails. Signed-off-by: Trond Myklebust --- net/sunrpc/clnt.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c index 9963584605c0..74f6a704e374 100644 --- a/net/sunrpc/clnt.c +++ b/net/sunrpc/clnt.c @@ -309,6 +309,7 @@ static int rpc_client_register(const struct rpc_create_args *args, return 0; err_auth: pipefs_sb = rpc_get_sb_net(net); + rpc_unregister_client(clnt); __rpc_clnt_remove_pipedir(clnt); out: if (pipefs_sb) From b2781e1021525649c0b33fffd005ef219da33926 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Fri, 12 Jul 2013 09:39:03 +0300 Subject: [PATCH 0938/1048] svcrdma: underflow issue in decode_write_list() My static checker marks everything from ntohl() as untrusted and it complains we could have an underflow problem doing: return (u32 *)&ary->wc_array[nchunks]; Also on 32 bit systems the upper bound check could overflow. Cc: stable@vger.kernel.org Signed-off-by: Dan Carpenter Signed-off-by: J. Bruce Fields --- net/sunrpc/xprtrdma/svc_rdma_marshal.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/net/sunrpc/xprtrdma/svc_rdma_marshal.c b/net/sunrpc/xprtrdma/svc_rdma_marshal.c index 8d2edddf48cf..65b146297f5a 100644 --- a/net/sunrpc/xprtrdma/svc_rdma_marshal.c +++ b/net/sunrpc/xprtrdma/svc_rdma_marshal.c @@ -98,6 +98,7 @@ void svc_rdma_rcl_chunk_counts(struct rpcrdma_read_chunk *ch, */ static u32 *decode_write_list(u32 *va, u32 *vaend) { + unsigned long start, end; int nchunks; struct rpcrdma_write_array *ary = @@ -113,9 +114,12 @@ static u32 *decode_write_list(u32 *va, u32 *vaend) return NULL; } nchunks = ntohl(ary->wc_nchunks); - if (((unsigned long)&ary->wc_array[0] + - (sizeof(struct rpcrdma_write_chunk) * nchunks)) > - (unsigned long)vaend) { + + start = (unsigned long)&ary->wc_array[0]; + end = (unsigned long)vaend; + if (nchunks < 0 || + nchunks > (SIZE_MAX - start) / sizeof(struct rpcrdma_write_chunk) || + (start + (sizeof(struct rpcrdma_write_chunk) * nchunks)) > end) { dprintk("svcrdma: ary=%p, wc_nchunks=%d, vaend=%p\n", ary, nchunks, vaend); return NULL; @@ -129,6 +133,7 @@ static u32 *decode_write_list(u32 *va, u32 *vaend) static u32 *decode_reply_array(u32 *va, u32 *vaend) { + unsigned long start, end; int nchunks; struct rpcrdma_write_array *ary = (struct rpcrdma_write_array *)va; @@ -143,9 +148,12 @@ static u32 *decode_reply_array(u32 *va, u32 *vaend) return NULL; } nchunks = ntohl(ary->wc_nchunks); - if (((unsigned long)&ary->wc_array[0] + - (sizeof(struct rpcrdma_write_chunk) * nchunks)) > - (unsigned long)vaend) { + + start = (unsigned long)&ary->wc_array[0]; + end = (unsigned long)vaend; + if (nchunks < 0 || + nchunks > (SIZE_MAX - start) / sizeof(struct rpcrdma_write_chunk) || + (start + (sizeof(struct rpcrdma_write_chunk) * nchunks)) > end) { dprintk("svcrdma: ary=%p, wc_nchunks=%d, vaend=%p\n", ary, nchunks, vaend); return NULL; From 60478295d6876619f8f47f6d1a5c25eaade69ee3 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 11 Jul 2013 17:55:57 +0200 Subject: [PATCH 0939/1048] ALSA: asihpi: Fix unlocked snd_pcm_stop() call snd_pcm_stop() must be called in the PCM substream lock context. Cc: Signed-off-by: Takashi Iwai --- sound/pci/asihpi/asihpi.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sound/pci/asihpi/asihpi.c b/sound/pci/asihpi/asihpi.c index 185d54a5cb1a..dc632cdc3870 100644 --- a/sound/pci/asihpi/asihpi.c +++ b/sound/pci/asihpi/asihpi.c @@ -769,7 +769,10 @@ static void snd_card_asihpi_timer_function(unsigned long data) s->number); ds->drained_count++; if (ds->drained_count > 20) { + unsigned long flags; + snd_pcm_stream_lock_irqsave(s, flags); snd_pcm_stop(s, SNDRV_PCM_STATE_XRUN); + snd_pcm_stream_unlock_irqrestore(s, flags); continue; } } else { From cc7282b8d5abbd48c81d1465925d464d9e3eaa8f Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 11 Jul 2013 17:56:56 +0200 Subject: [PATCH 0940/1048] ALSA: atiixp: Fix unlocked snd_pcm_stop() call snd_pcm_stop() must be called in the PCM substream lock context. Cc: Signed-off-by: Takashi Iwai --- sound/pci/atiixp.c | 2 ++ sound/pci/atiixp_modem.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/sound/pci/atiixp.c b/sound/pci/atiixp.c index fe4c61bdb8ba..f6dec3ea371f 100644 --- a/sound/pci/atiixp.c +++ b/sound/pci/atiixp.c @@ -689,7 +689,9 @@ static void snd_atiixp_xrun_dma(struct atiixp *chip, struct atiixp_dma *dma) if (! dma->substream || ! dma->running) return; snd_printdd("atiixp: XRUN detected (DMA %d)\n", dma->ops->type); + snd_pcm_stream_lock(dma->substream); snd_pcm_stop(dma->substream, SNDRV_PCM_STATE_XRUN); + snd_pcm_stream_unlock(dma->substream); } /* diff --git a/sound/pci/atiixp_modem.c b/sound/pci/atiixp_modem.c index cf29b9a1d65d..289563ecb6dd 100644 --- a/sound/pci/atiixp_modem.c +++ b/sound/pci/atiixp_modem.c @@ -638,7 +638,9 @@ static void snd_atiixp_xrun_dma(struct atiixp_modem *chip, if (! dma->substream || ! dma->running) return; snd_printdd("atiixp-modem: XRUN detected (DMA %d)\n", dma->ops->type); + snd_pcm_stream_lock(dma->substream); snd_pcm_stop(dma->substream, SNDRV_PCM_STATE_XRUN); + snd_pcm_stream_unlock(dma->substream); } /* From 5b9ab3f7324a1b94a5a5a76d44cf92dfeb3b5e80 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 11 Jul 2013 17:57:55 +0200 Subject: [PATCH 0941/1048] ALSA: 6fire: Fix unlocked snd_pcm_stop() call snd_pcm_stop() must be called in the PCM substream lock context. Cc: Signed-off-by: Takashi Iwai --- sound/usb/6fire/pcm.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/sound/usb/6fire/pcm.c b/sound/usb/6fire/pcm.c index c5b9cac37dc4..2aa4e13063a8 100644 --- a/sound/usb/6fire/pcm.c +++ b/sound/usb/6fire/pcm.c @@ -639,17 +639,25 @@ int usb6fire_pcm_init(struct sfire_chip *chip) void usb6fire_pcm_abort(struct sfire_chip *chip) { struct pcm_runtime *rt = chip->pcm; + unsigned long flags; int i; if (rt) { rt->panic = true; - if (rt->playback.instance) + if (rt->playback.instance) { + snd_pcm_stream_lock_irqsave(rt->playback.instance, flags); snd_pcm_stop(rt->playback.instance, SNDRV_PCM_STATE_XRUN); - if (rt->capture.instance) + snd_pcm_stream_unlock_irqrestore(rt->playback.instance, flags); + } + + if (rt->capture.instance) { + snd_pcm_stream_lock_irqsave(rt->capture.instance, flags); snd_pcm_stop(rt->capture.instance, SNDRV_PCM_STATE_XRUN); + snd_pcm_stream_unlock_irqrestore(rt->capture.instance, flags); + } for (i = 0; i < PCM_N_URBS; i++) { usb_poison_urb(&rt->in_urbs[i].instance); From 76828c882630ced08b5ddce22cc0095b05de9bc5 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Mon, 15 Jul 2013 12:27:47 -0400 Subject: [PATCH 0942/1048] ext4: yield during large unlinks During large unlink operations on files with extents, we can use a lot of CPU time. This adds a cond_resched() call when starting to examine the next level of a multi-level extent tree. Multi-level extent trees are rare in the first place, and this should rarely be executed. Signed-off-by: "Theodore Ts'o" --- fs/ext4/extents.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c index 593091537e76..cfdc51e30257 100644 --- a/fs/ext4/extents.c +++ b/fs/ext4/extents.c @@ -2835,6 +2835,9 @@ again: err = -EIO; break; } + /* Yield here to deal with large extent trees. + * Should be a no-op if we did IO above. */ + cond_resched(); if (WARN_ON(i + 1 > depth)) { err = -EIO; break; From 9538aa46c2427d6782aa10036c4da4c541605e0e Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 11 Jul 2013 17:58:25 +0200 Subject: [PATCH 0943/1048] ALSA: ua101: Fix unlocked snd_pcm_stop() call snd_pcm_stop() must be called in the PCM substream lock context. Cc: Acked-by: Clemens Ladisch Signed-off-by: Takashi Iwai --- sound/usb/misc/ua101.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/sound/usb/misc/ua101.c b/sound/usb/misc/ua101.c index 8b5d2c564e04..509315937f25 100644 --- a/sound/usb/misc/ua101.c +++ b/sound/usb/misc/ua101.c @@ -613,14 +613,24 @@ static int start_usb_playback(struct ua101 *ua) static void abort_alsa_capture(struct ua101 *ua) { - if (test_bit(ALSA_CAPTURE_RUNNING, &ua->states)) + unsigned long flags; + + if (test_bit(ALSA_CAPTURE_RUNNING, &ua->states)) { + snd_pcm_stream_lock_irqsave(ua->capture.substream, flags); snd_pcm_stop(ua->capture.substream, SNDRV_PCM_STATE_XRUN); + snd_pcm_stream_unlock_irqrestore(ua->capture.substream, flags); + } } static void abort_alsa_playback(struct ua101 *ua) { - if (test_bit(ALSA_PLAYBACK_RUNNING, &ua->states)) + unsigned long flags; + + if (test_bit(ALSA_PLAYBACK_RUNNING, &ua->states)) { + snd_pcm_stream_lock_irqsave(ua->playback.substream, flags); snd_pcm_stop(ua->playback.substream, SNDRV_PCM_STATE_XRUN); + snd_pcm_stream_unlock_irqrestore(ua->playback.substream, flags); + } } static int set_stream_hw(struct ua101 *ua, struct snd_pcm_substream *substream, From 5be1efb4c2ed79c3d7c0cbcbecae768377666e84 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 11 Jul 2013 17:58:47 +0200 Subject: [PATCH 0944/1048] ALSA: usx2y: Fix unlocked snd_pcm_stop() call snd_pcm_stop() must be called in the PCM substream lock context. Cc: Signed-off-by: Takashi Iwai --- sound/usb/usx2y/usbusx2yaudio.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sound/usb/usx2y/usbusx2yaudio.c b/sound/usb/usx2y/usbusx2yaudio.c index 4967fe9c938d..63fb5219f0f8 100644 --- a/sound/usb/usx2y/usbusx2yaudio.c +++ b/sound/usb/usx2y/usbusx2yaudio.c @@ -273,7 +273,11 @@ static void usX2Y_clients_stop(struct usX2Ydev *usX2Y) struct snd_usX2Y_substream *subs = usX2Y->subs[s]; if (subs) { if (atomic_read(&subs->state) >= state_PRERUNNING) { + unsigned long flags; + + snd_pcm_stream_lock_irqsave(subs->pcm_substream, flags); snd_pcm_stop(subs->pcm_substream, SNDRV_PCM_STATE_XRUN); + snd_pcm_stream_unlock_irqrestore(subs->pcm_substream, flags); } for (u = 0; u < NRURBS; u++) { struct urb *urb = subs->urb[u]; From 46f6c1aaf790be9ea3c8ddfc8f235a5f677d08e2 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 11 Jul 2013 17:59:33 +0200 Subject: [PATCH 0945/1048] ALSA: pxa2xx: Fix unlocked snd_pcm_stop() call snd_pcm_stop() must be called in the PCM substream lock context. Cc: Acked-by: Mark Brown Signed-off-by: Takashi Iwai --- sound/arm/pxa2xx-pcm-lib.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sound/arm/pxa2xx-pcm-lib.c b/sound/arm/pxa2xx-pcm-lib.c index 76e0d5695075..823359ed95e1 100644 --- a/sound/arm/pxa2xx-pcm-lib.c +++ b/sound/arm/pxa2xx-pcm-lib.c @@ -166,7 +166,9 @@ void pxa2xx_pcm_dma_irq(int dma_ch, void *dev_id) } else { printk(KERN_ERR "%s: DMA error on channel %d (DCSR=%#x)\n", rtd->params->name, dma_ch, dcsr); + snd_pcm_stream_lock(substream); snd_pcm_stop(substream, SNDRV_PCM_STATE_XRUN); + snd_pcm_stream_unlock(substream); } } EXPORT_SYMBOL(pxa2xx_pcm_dma_irq); From 571185717f8d7f2a088a7ac38d94a9ad5fd9da5c Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 11 Jul 2013 18:00:01 +0200 Subject: [PATCH 0946/1048] ASoC: atmel: Fix unlocked snd_pcm_stop() call snd_pcm_stop() must be called in the PCM substream lock context. Cc: Acked-by: Mark Brown Signed-off-by: Takashi Iwai --- sound/soc/atmel/atmel-pcm-dma.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sound/soc/atmel/atmel-pcm-dma.c b/sound/soc/atmel/atmel-pcm-dma.c index 1d38fd0bc4e2..d12826526798 100644 --- a/sound/soc/atmel/atmel-pcm-dma.c +++ b/sound/soc/atmel/atmel-pcm-dma.c @@ -81,7 +81,9 @@ static void atmel_pcm_dma_irq(u32 ssc_sr, /* stop RX and capture: will be enabled again at restart */ ssc_writex(prtd->ssc->regs, SSC_CR, prtd->mask->ssc_disable); + snd_pcm_stream_lock(substream); snd_pcm_stop(substream, SNDRV_PCM_STATE_XRUN); + snd_pcm_stream_unlock(substream); /* now drain RHR and read status to remove xrun condition */ ssc_readx(prtd->ssc->regs, SSC_RHR); From 61be2b9a18ec70f3cbe3deef7a5f77869c71b5ae Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 11 Jul 2013 18:00:25 +0200 Subject: [PATCH 0947/1048] ASoC: s6000: Fix unlocked snd_pcm_stop() call snd_pcm_stop() must be called in the PCM substream lock context. Cc: Acked-by: Mark Brown Signed-off-by: Takashi Iwai --- sound/soc/s6000/s6000-pcm.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sound/soc/s6000/s6000-pcm.c b/sound/soc/s6000/s6000-pcm.c index 1358c7de2521..d0740a762963 100644 --- a/sound/soc/s6000/s6000-pcm.c +++ b/sound/soc/s6000/s6000-pcm.c @@ -128,7 +128,9 @@ static irqreturn_t s6000_pcm_irq(int irq, void *data) substream->runtime && snd_pcm_running(substream)) { dev_dbg(pcm->dev, "xrun\n"); + snd_pcm_stream_lock(substream); snd_pcm_stop(substream, SNDRV_PCM_STATE_XRUN); + snd_pcm_stream_unlock(substream); ret = IRQ_HANDLED; } From e6355ad7b1c6f70e2f48ae159f5658b441ccff95 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 11 Jul 2013 18:00:59 +0200 Subject: [PATCH 0948/1048] [media] saa7134: Fix unlocked snd_pcm_stop() call snd_pcm_stop() must be called in the PCM substream lock context. Cc: Signed-off-by: Takashi Iwai --- drivers/media/pci/saa7134/saa7134-alsa.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/media/pci/saa7134/saa7134-alsa.c b/drivers/media/pci/saa7134/saa7134-alsa.c index 10460fd3ce39..dbcdfbf8aed0 100644 --- a/drivers/media/pci/saa7134/saa7134-alsa.c +++ b/drivers/media/pci/saa7134/saa7134-alsa.c @@ -172,7 +172,9 @@ static void saa7134_irq_alsa_done(struct saa7134_dev *dev, dprintk("irq: overrun [full=%d/%d] - Blocks in %d\n",dev->dmasound.read_count, dev->dmasound.bufsize, dev->dmasound.blocks); spin_unlock(&dev->slock); + snd_pcm_stream_lock(dev->dmasound.substream); snd_pcm_stop(dev->dmasound.substream,SNDRV_PCM_STATE_XRUN); + snd_pcm_stream_unlock(dev->dmasound.substream); return; } From 86f0b5b86d142b9323432fef078a6cf0fb5dda74 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 11 Jul 2013 18:02:38 +0200 Subject: [PATCH 0949/1048] staging: line6: Fix unlocked snd_pcm_stop() call snd_pcm_stop() must be called in the PCM substream lock context. Cc: Signed-off-by: Takashi Iwai --- drivers/staging/line6/pcm.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/staging/line6/pcm.c b/drivers/staging/line6/pcm.c index 4795f1284906..0dd08ef51398 100644 --- a/drivers/staging/line6/pcm.c +++ b/drivers/staging/line6/pcm.c @@ -392,8 +392,11 @@ static int snd_line6_pcm_free(struct snd_device *device) */ static void pcm_disconnect_substream(struct snd_pcm_substream *substream) { - if (substream->runtime && snd_pcm_running(substream)) + if (substream->runtime && snd_pcm_running(substream)) { + snd_pcm_stream_lock_irq(substream); snd_pcm_stop(substream, SNDRV_PCM_STATE_DISCONNECTED); + snd_pcm_stream_unlock_irq(substream); + } } /* From 5ff560fd48d5b3d82fa0c3aff625c9da1a301911 Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Fri, 12 Jul 2013 16:48:12 -0700 Subject: [PATCH 0950/1048] x86, suspend: Handle CPUs which fail to #GP on RDMSR MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There are CPUs which have errata causing RDMSR of a nonexistent MSR to not fault. We would then try to WRMSR to restore the value of that MSR, causing a crash. Specifically, some Pentium M variants would have this problem trying to save and restore the non-existent EFER, causing a crash on resume. Work around this by making sure we can write back the result at suspend time. Huge thanks to Christian Sünkenberg for finding the offending erratum that finally deciphered the mystery. Reported-and-tested-by: Johan Heinrich Debugged-by: Christian Sünkenberg Acked-by: Rafael J. Wysocki Link: http://lkml.kernel.org/r/51DDC972.3010005@student.kit.edu Cc: # v3.7+ --- arch/x86/kernel/acpi/sleep.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/arch/x86/kernel/acpi/sleep.c b/arch/x86/kernel/acpi/sleep.c index 2a34aaf3c8f1..33120100ff5e 100644 --- a/arch/x86/kernel/acpi/sleep.c +++ b/arch/x86/kernel/acpi/sleep.c @@ -48,9 +48,20 @@ int x86_acpi_suspend_lowlevel(void) #ifndef CONFIG_64BIT native_store_gdt((struct desc_ptr *)&header->pmode_gdt); + /* + * We have to check that we can write back the value, and not + * just read it. At least on 90 nm Pentium M (Family 6, Model + * 13), reading an invalid MSR is not guaranteed to trap, see + * Erratum X4 in "Intel Pentium M Processor on 90 nm Process + * with 2-MB L2 Cache and Intel® Processor A100 and A110 on 90 + * nm process with 512-KB L2 Cache Specification Update". + */ if (!rdmsr_safe(MSR_EFER, &header->pmode_efer_low, - &header->pmode_efer_high)) + &header->pmode_efer_high) && + !wrmsr_safe(MSR_EFER, + header->pmode_efer_low, + header->pmode_efer_high)) header->pmode_behavior |= (1 << WAKEUP_BEHAVIOR_RESTORE_EFER); #endif /* !CONFIG_64BIT */ @@ -61,7 +72,10 @@ int x86_acpi_suspend_lowlevel(void) } if (!rdmsr_safe(MSR_IA32_MISC_ENABLE, &header->pmode_misc_en_low, - &header->pmode_misc_en_high)) + &header->pmode_misc_en_high) && + !wrmsr_safe(MSR_IA32_MISC_ENABLE, + header->pmode_misc_en_low, + header->pmode_misc_en_high)) header->pmode_behavior |= (1 << WAKEUP_BEHAVIOR_RESTORE_MISC_ENABLE); header->realmode_flags = acpi_realmode_flags; From d1ce3d5496f2a7c90dd00a9133572f931d2acdcc Mon Sep 17 00:00:00 2001 From: Sylvain 'ythier' Hitier Date: Fri, 12 Jul 2013 18:25:54 +0200 Subject: [PATCH 0951/1048] uvesafb: Really allow mtrr being 0, as documented and warn()ed Fixup for commit "uvesafb: Clean up MTRR code" (63e28a7a5ffce59b645ca9cbcc01e1e8be56bd75) Signed-off-by: Sylvain "ythier" Hitier Acked-by: Andy Lutomirski Also-spotted-by: Torsten Kaiser Signed-off-by: Dave Airlie --- drivers/video/uvesafb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/video/uvesafb.c b/drivers/video/uvesafb.c index b963ea12d175..7aec6f39fdd5 100644 --- a/drivers/video/uvesafb.c +++ b/drivers/video/uvesafb.c @@ -1891,7 +1891,7 @@ static int uvesafb_setup(char *options) } } - if (mtrr != 3 && mtrr != 1) + if (mtrr != 3 && mtrr != 0) pr_warn("uvesafb: mtrr should be set to 0 or 3; %d is unsupported", mtrr); return 0; From d52392b1a80458c0510810789c7db4a39b88022a Mon Sep 17 00:00:00 2001 From: Aaron Plattner Date: Fri, 12 Jul 2013 11:01:37 -0700 Subject: [PATCH 0952/1048] ALSA: hda - Add new GPU codec ID to snd-hda Vendor ID 0x10de0060 is used by a yet-to-be-named GPU chip. Reviewed-by: Andy Ritger Signed-off-by: Aaron Plattner Cc: Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_hdmi.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c index 540bdef2f904..030ca8652a1c 100644 --- a/sound/pci/hda/patch_hdmi.c +++ b/sound/pci/hda/patch_hdmi.c @@ -2622,6 +2622,7 @@ static const struct hda_codec_preset snd_hda_preset_hdmi[] = { { .id = 0x10de0043, .name = "GPU 43 HDMI/DP", .patch = patch_generic_hdmi }, { .id = 0x10de0044, .name = "GPU 44 HDMI/DP", .patch = patch_generic_hdmi }, { .id = 0x10de0051, .name = "GPU 51 HDMI/DP", .patch = patch_generic_hdmi }, +{ .id = 0x10de0060, .name = "GPU 60 HDMI/DP", .patch = patch_generic_hdmi }, { .id = 0x10de0067, .name = "MCP67 HDMI", .patch = patch_nvhdmi_2ch }, { .id = 0x10de8001, .name = "MCP73 HDMI", .patch = patch_nvhdmi_2ch }, { .id = 0x11069f80, .name = "VX900 HDMI/DP", .patch = patch_via_hdmi }, @@ -2674,6 +2675,7 @@ MODULE_ALIAS("snd-hda-codec-id:10de0042"); MODULE_ALIAS("snd-hda-codec-id:10de0043"); MODULE_ALIAS("snd-hda-codec-id:10de0044"); MODULE_ALIAS("snd-hda-codec-id:10de0051"); +MODULE_ALIAS("snd-hda-codec-id:10de0060"); MODULE_ALIAS("snd-hda-codec-id:10de0067"); MODULE_ALIAS("snd-hda-codec-id:10de8001"); MODULE_ALIAS("snd-hda-codec-id:11069f80"); From 67dbf54a3b03881c7b683801fa49ca1f2c4c3bcf Mon Sep 17 00:00:00 2001 From: Jacek Anaszewski Date: Tue, 2 Jul 2013 11:13:00 +0100 Subject: [PATCH 0953/1048] iio: lps331ap: Fix wrong in_pressure_scale output value This patch fixes improper in_pressure_scale output that is returned by the lps331ap barometer sensor driver. According to the documentation the pressure after applying the scale has to be expressed in kilopascal units. With erroneous implementation the scale value larger by two orders of magnitude is returned - 2441410 instead of 24414. Signed-off-by: Jacek Anaszewski Signed-off-by: Kyungmin Park Acked-by: Denis Ciocca Signed-off-by: Jonathan Cameron --- drivers/iio/pressure/st_pressure_core.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/iio/pressure/st_pressure_core.c b/drivers/iio/pressure/st_pressure_core.c index 9c343b40665e..3ffbc56917b4 100644 --- a/drivers/iio/pressure/st_pressure_core.c +++ b/drivers/iio/pressure/st_pressure_core.c @@ -28,7 +28,9 @@ #include #include "st_pressure.h" -#define ST_PRESS_MBAR_TO_KPASCAL(x) (x * 10) +#define ST_PRESS_LSB_PER_MBAR 4096UL +#define ST_PRESS_KPASCAL_NANO_SCALE (100000000UL / \ + ST_PRESS_LSB_PER_MBAR) #define ST_PRESS_NUMBER_DATA_CHANNELS 1 /* DEFAULT VALUE FOR SENSORS */ @@ -51,8 +53,8 @@ #define ST_PRESS_1_FS_ADDR 0x23 #define ST_PRESS_1_FS_MASK 0x30 #define ST_PRESS_1_FS_AVL_1260_VAL 0x00 -#define ST_PRESS_1_FS_AVL_1260_GAIN ST_PRESS_MBAR_TO_KPASCAL(244141) #define ST_PRESS_1_FS_AVL_TEMP_GAIN 2083000 +#define ST_PRESS_1_FS_AVL_1260_GAIN ST_PRESS_KPASCAL_NANO_SCALE #define ST_PRESS_1_BDU_ADDR 0x20 #define ST_PRESS_1_BDU_MASK 0x04 #define ST_PRESS_1_DRDY_IRQ_ADDR 0x22 From 64597f9dae1850e0360ae2e9b5485d4b5d1fdf4c Mon Sep 17 00:00:00 2001 From: Michael Mueller Date: Tue, 2 Jul 2013 22:58:26 +0200 Subject: [PATCH 0954/1048] s390/ptrace: PTRACE_TE_ABORT_RAND The patch implements a s390 specific ptrace request PTRACE_TE_ABORT_RAND to modify the randomness of spontaneous aborts of memory transactions of the transaction execution facility. The data argument of the ptrace request is used to specify the levels of randomness, 0 for normal operation, 1 to abort every transaction at a random instruction, and 2 to abort a random transaction at a random instruction. The default is 0 for normal operation. Acked-by: Heiko Carstens Signed-off-by: Michael Mueller Signed-off-by: Martin Schwidefsky --- arch/s390/include/asm/processor.h | 10 +++++- arch/s390/include/asm/switch_to.h | 4 +-- arch/s390/include/uapi/asm/ptrace.h | 1 + arch/s390/kernel/ptrace.c | 50 ++++++++++++++++++++++------- 4 files changed, 51 insertions(+), 14 deletions(-) diff --git a/arch/s390/include/asm/processor.h b/arch/s390/include/asm/processor.h index 6b499870662f..b0e6435b2f02 100644 --- a/arch/s390/include/asm/processor.h +++ b/arch/s390/include/asm/processor.h @@ -91,7 +91,15 @@ struct thread_struct { #endif }; -#define PER_FLAG_NO_TE 1UL /* Flag to disable transactions. */ +/* Flag to disable transactions. */ +#define PER_FLAG_NO_TE 1UL +/* Flag to enable random transaction aborts. */ +#define PER_FLAG_TE_ABORT_RAND 2UL +/* Flag to specify random transaction abort mode: + * - abort each transaction at a random instruction before TEND if set. + * - abort random transactions at a random instruction if cleared. + */ +#define PER_FLAG_TE_ABORT_RAND_TEND 4UL typedef struct thread_struct thread_struct; diff --git a/arch/s390/include/asm/switch_to.h b/arch/s390/include/asm/switch_to.h index f3a9e0f92704..80b6f11263c4 100644 --- a/arch/s390/include/asm/switch_to.h +++ b/arch/s390/include/asm/switch_to.h @@ -10,7 +10,7 @@ #include extern struct task_struct *__switch_to(void *, void *); -extern void update_per_regs(struct task_struct *task); +extern void update_cr_regs(struct task_struct *task); static inline void save_fp_regs(s390_fp_regs *fpregs) { @@ -86,7 +86,7 @@ static inline void restore_access_regs(unsigned int *acrs) restore_fp_regs(&next->thread.fp_regs); \ restore_access_regs(&next->thread.acrs[0]); \ restore_ri_cb(next->thread.ri_cb, prev->thread.ri_cb); \ - update_per_regs(next); \ + update_cr_regs(next); \ } \ prev = __switch_to(prev,next); \ } while (0) diff --git a/arch/s390/include/uapi/asm/ptrace.h b/arch/s390/include/uapi/asm/ptrace.h index 3aa9f1ec5b29..7a84619e315e 100644 --- a/arch/s390/include/uapi/asm/ptrace.h +++ b/arch/s390/include/uapi/asm/ptrace.h @@ -400,6 +400,7 @@ typedef struct #define PTRACE_POKE_SYSTEM_CALL 0x5008 #define PTRACE_ENABLE_TE 0x5009 #define PTRACE_DISABLE_TE 0x5010 +#define PTRACE_TE_ABORT_RAND 0x5011 /* * PT_PROT definition is loosely based on hppa bsd definition in diff --git a/arch/s390/kernel/ptrace.c b/arch/s390/kernel/ptrace.c index a314c57f4e94..e9fadb04e3c6 100644 --- a/arch/s390/kernel/ptrace.c +++ b/arch/s390/kernel/ptrace.c @@ -47,7 +47,7 @@ enum s390_regset { REGSET_GENERAL_EXTENDED, }; -void update_per_regs(struct task_struct *task) +void update_cr_regs(struct task_struct *task) { struct pt_regs *regs = task_pt_regs(task); struct thread_struct *thread = &task->thread; @@ -56,17 +56,25 @@ void update_per_regs(struct task_struct *task) #ifdef CONFIG_64BIT /* Take care of the enable/disable of transactional execution. */ if (MACHINE_HAS_TE) { - unsigned long cr0, cr0_new; + unsigned long cr[3], cr_new[3]; - __ctl_store(cr0, 0, 0); - /* set or clear transaction execution bits 8 and 9. */ + __ctl_store(cr, 0, 2); + cr_new[1] = cr[1]; + /* Set or clear transaction execution TXC/PIFO bits 8 and 9. */ if (task->thread.per_flags & PER_FLAG_NO_TE) - cr0_new = cr0 & ~(3UL << 54); + cr_new[0] = cr[0] & ~(3UL << 54); else - cr0_new = cr0 | (3UL << 54); - /* Only load control register 0 if necessary. */ - if (cr0 != cr0_new) - __ctl_load(cr0_new, 0, 0); + cr_new[0] = cr[0] | (3UL << 54); + /* Set or clear transaction execution TDC bits 62 and 63. */ + cr_new[2] = cr[2] & ~3UL; + if (task->thread.per_flags & PER_FLAG_TE_ABORT_RAND) { + if (task->thread.per_flags & PER_FLAG_TE_ABORT_RAND_TEND) + cr_new[2] |= 1UL; + else + cr_new[2] |= 2UL; + } + if (memcmp(&cr_new, &cr, sizeof(cr))) + __ctl_load(cr_new, 0, 2); } #endif /* Copy user specified PER registers */ @@ -100,14 +108,14 @@ void user_enable_single_step(struct task_struct *task) { set_tsk_thread_flag(task, TIF_SINGLE_STEP); if (task == current) - update_per_regs(task); + update_cr_regs(task); } void user_disable_single_step(struct task_struct *task) { clear_tsk_thread_flag(task, TIF_SINGLE_STEP); if (task == current) - update_per_regs(task); + update_cr_regs(task); } /* @@ -447,6 +455,26 @@ long arch_ptrace(struct task_struct *child, long request, if (!MACHINE_HAS_TE) return -EIO; child->thread.per_flags |= PER_FLAG_NO_TE; + child->thread.per_flags &= ~PER_FLAG_TE_ABORT_RAND; + return 0; + case PTRACE_TE_ABORT_RAND: + if (!MACHINE_HAS_TE || (child->thread.per_flags & PER_FLAG_NO_TE)) + return -EIO; + switch (data) { + case 0UL: + child->thread.per_flags &= ~PER_FLAG_TE_ABORT_RAND; + break; + case 1UL: + child->thread.per_flags |= PER_FLAG_TE_ABORT_RAND; + child->thread.per_flags |= PER_FLAG_TE_ABORT_RAND_TEND; + break; + case 2UL: + child->thread.per_flags |= PER_FLAG_TE_ABORT_RAND; + child->thread.per_flags &= ~PER_FLAG_TE_ABORT_RAND_TEND; + break; + default: + return -EINVAL; + } return 0; default: /* Removing high order bit from addr (only for 31 bit). */ From dae7fd42961e9ae9386f527b6d0e14f6e3da2317 Mon Sep 17 00:00:00 2001 From: Sebastian Ott Date: Fri, 5 Jul 2013 09:22:11 +0200 Subject: [PATCH 0955/1048] s390/qdio: remove unused variable Fix a "set but not used" warning found via make W=1. Signed-off-by: Sebastian Ott Signed-off-by: Martin Schwidefsky --- drivers/s390/cio/qdio_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/s390/cio/qdio_main.c b/drivers/s390/cio/qdio_main.c index fb1c1e0483ed..8ed52aa49122 100644 --- a/drivers/s390/cio/qdio_main.c +++ b/drivers/s390/cio/qdio_main.c @@ -1497,7 +1497,7 @@ static inline int buf_in_between(int bufnr, int start, int count) static int handle_inbound(struct qdio_q *q, unsigned int callflags, int bufnr, int count) { - int used, diff; + int diff; qperf_inc(q, inbound_call); @@ -1530,7 +1530,7 @@ static int handle_inbound(struct qdio_q *q, unsigned int callflags, set: count = set_buf_states(q, bufnr, SLSB_CU_INPUT_EMPTY, count); - used = atomic_add_return(count, &q->nr_buf_used) - count; + atomic_add(count, &q->nr_buf_used); if (need_siga_in(q)) return qdio_siga_input(q); From 63b999685cb372e24eb73f255cd73547026370fd Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Tue, 16 Jul 2013 10:28:47 -0400 Subject: [PATCH 0956/1048] ext4: call ext4_es_lru_add() after handling cache miss If there are no items in the extent status tree, ext4_es_lru_add() is a no-op. So it is not sufficient to call ext4_es_lru_add() before we try to lookup an entry in the extent status tree. We also need to call it at the end of ext4_ext_map_blocks(), after items have been added to the extent status tree. This could lead to inodes with that have extent status trees but which are not in the LRU list, which means they won't get considered for eviction by the es_shrinker. Signed-off-by: "Theodore Ts'o" Cc: Zheng Liu Cc: stable@vger.kernel.org --- fs/ext4/extents.c | 5 +++-- fs/ext4/inode.c | 7 ++----- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c index cfdc51e30257..a61873808f76 100644 --- a/fs/ext4/extents.c +++ b/fs/ext4/extents.c @@ -4385,8 +4385,9 @@ out2: } out3: - trace_ext4_ext_map_blocks_exit(inode, flags, map, err ? err : allocated); - + trace_ext4_ext_map_blocks_exit(inode, flags, map, + err ? err : allocated); + ext4_es_lru_add(inode); return err ? err : allocated; } diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 98b9bff92a8a..ba33c67d6e48 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -514,10 +514,9 @@ int ext4_map_blocks(handle_t *handle, struct inode *inode, "logical block %lu\n", inode->i_ino, flags, map->m_len, (unsigned long) map->m_lblk); - ext4_es_lru_add(inode); - /* Lookup extent status tree firstly */ if (ext4_es_lookup_extent(inode, map->m_lblk, &es)) { + ext4_es_lru_add(inode); if (ext4_es_is_written(&es) || ext4_es_is_unwritten(&es)) { map->m_pblk = ext4_es_pblock(&es) + map->m_lblk - es.es_lblk; @@ -1529,11 +1528,9 @@ static int ext4_da_map_blocks(struct inode *inode, sector_t iblock, "logical block %lu\n", inode->i_ino, map->m_len, (unsigned long) map->m_lblk); - ext4_es_lru_add(inode); - /* Lookup extent status tree firstly */ if (ext4_es_lookup_extent(inode, iblock, &es)) { - + ext4_es_lru_add(inode); if (ext4_es_is_hole(&es)) { retval = 0; down_read((&EXT4_I(inode)->i_data_sem)); From 16fc5bc4c76b9ac335c2b39943f29c5d047a822d Mon Sep 17 00:00:00 2001 From: Steven Miao Date: Tue, 16 Jul 2013 13:25:21 +0800 Subject: [PATCH 0957/1048] smp: blackfin: fix check error, using atomic_ops to handle atomic_t type Signed-off-by: Geert Uytterhoeven Signed-off-by: Steven Miao Signed-off-by: Linus Torvalds --- arch/blackfin/mach-common/smp.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/blackfin/mach-common/smp.c b/arch/blackfin/mach-common/smp.c index 961d8392e5e3..b5f9ed7d4856 100644 --- a/arch/blackfin/mach-common/smp.c +++ b/arch/blackfin/mach-common/smp.c @@ -147,7 +147,7 @@ static irqreturn_t ipi_handler_int1(int irq, void *dev_instance) platform_clear_ipi(cpu, IRQ_SUPPLE_1); bfin_ipi_data = &__get_cpu_var(bfin_ipi); - while ((pending = xchg(&bfin_ipi_data->bits, 0)) != 0) { + while ((pending = atomic_xchg(&bfin_ipi_data->bits, 0)) != 0) { msg = 0; do { msg = find_next_bit(&pending, BITS_PER_LONG, msg + 1); @@ -182,8 +182,8 @@ static void bfin_ipi_init(void) struct ipi_data *bfin_ipi_data; for_each_possible_cpu(cpu) { bfin_ipi_data = &per_cpu(bfin_ipi, cpu); - bfin_ipi_data->bits = 0; - bfin_ipi_data->count = 0; + atomic_set(&bfin_ipi_data->bits, 0); + atomic_set(&bfin_ipi_data->count, 0); } } From b9b3259746d77f4fcb786e2a43c25bcc40773755 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Sun, 14 Jul 2013 16:05:51 -0700 Subject: [PATCH 0958/1048] sysfs.h: add __ATTR_RW() macro A number of parts of the kernel created their own version of this, might as well have the sysfs core provide it instead. Reviewed-by: Guenter Roeck Tested-by: Guenter Roeck Signed-off-by: Greg Kroah-Hartman --- include/linux/sysfs.h | 2 ++ kernel/events/core.c | 2 -- mm/backing-dev.c | 2 -- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h index e2cee22f578a..9cd20c8404e5 100644 --- a/include/linux/sysfs.h +++ b/include/linux/sysfs.h @@ -79,6 +79,8 @@ struct attribute_group { .show = _name##_show, \ } +#define __ATTR_RW(_name) __ATTR(_name, 0644, _name##_show, _name##_store) + #define __ATTR_NULL { .attr = { .name = NULL } } #ifdef CONFIG_DEBUG_LOCK_ALLOC diff --git a/kernel/events/core.c b/kernel/events/core.c index eba8fb5834ae..dd9878029d1f 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -6234,8 +6234,6 @@ perf_event_mux_interval_ms_store(struct device *dev, return count; } -#define __ATTR_RW(attr) __ATTR(attr, 0644, attr##_show, attr##_store) - static struct device_attribute pmu_dev_attrs[] = { __ATTR_RO(type), __ATTR_RW(perf_event_mux_interval_ms), diff --git a/mm/backing-dev.c b/mm/backing-dev.c index d014ee5fcbbd..e04454cdb33f 100644 --- a/mm/backing-dev.c +++ b/mm/backing-dev.c @@ -232,8 +232,6 @@ static ssize_t stable_pages_required_show(struct device *dev, bdi_cap_stable_pages_required(bdi) ? 1 : 0); } -#define __ATTR_RW(attr) __ATTR(attr, 0644, attr##_show, attr##_store) - static struct device_attribute bdi_dev_attrs[] = { __ATTR_RW(read_ahead_kb), __ATTR_RW(min_ratio), From f2f37f58b1b933b06d6d84e80a31a1b500fb0db2 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Sun, 14 Jul 2013 16:05:52 -0700 Subject: [PATCH 0959/1048] sysfs.h: add ATTRIBUTE_GROUPS() macro To make it easier for driver subsystems to work with attribute groups, create the ATTRIBUTE_GROUPS macro to remove some of the repetitive typing for the most common use for attribute groups. Reviewed-by: Guenter Roeck Tested-by: Guenter Roeck Signed-off-by: Greg Kroah-Hartman --- include/linux/sysfs.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h index 9cd20c8404e5..f62ff01e5f59 100644 --- a/include/linux/sysfs.h +++ b/include/linux/sysfs.h @@ -94,6 +94,15 @@ struct attribute_group { #define __ATTR_IGNORE_LOCKDEP __ATTR #endif +#define ATTRIBUTE_GROUPS(name) \ +static const struct attribute_group name##_group = { \ + .attrs = name##_attrs, \ +}; \ +static const struct attribute_group *name##_groups[] = { \ + &name##_group, \ + NULL, \ +} + #define attr_name(_attr) (_attr).attr.name struct file; From e4b63603c2a1e2c4db3de11b0f2b17360a7695bb Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Sun, 14 Jul 2013 16:05:53 -0700 Subject: [PATCH 0960/1048] sysfs.h: add BIN_ATTR macro This makes it easier to create static binary attributes, which is needed in a number of drivers, instead of "open coding" them. Reviewed-by: Guenter Roeck Tested-by: Guenter Roeck Signed-off-by: Greg Kroah-Hartman --- include/linux/sysfs.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h index f62ff01e5f59..d50a96b9bb6d 100644 --- a/include/linux/sysfs.h +++ b/include/linux/sysfs.h @@ -132,6 +132,15 @@ struct bin_attribute { */ #define sysfs_bin_attr_init(bin_attr) sysfs_attr_init(&(bin_attr)->attr) +/* macro to create static binary attributes easier */ +#define BIN_ATTR(_name, _mode, _read, _write, _size) \ +struct bin_attribute bin_attr_##_name = { \ + .attr = {.name = __stringify(_name), .mode = _mode }, \ + .read = _read, \ + .write = _write, \ + .size = _size, \ +} + struct sysfs_ops { ssize_t (*show)(struct kobject *, struct attribute *,char *); ssize_t (*store)(struct kobject *,struct attribute *,const char *, size_t); From ced321bf9151535f85779b0004c93529f860b2a4 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Sun, 14 Jul 2013 16:05:54 -0700 Subject: [PATCH 0961/1048] driver core: device.h: add RW and RO attribute macros Make it easier to create attributes without having to always audit the mode settings. Reviewed-by: Guenter Roeck Tested-by: Guenter Roeck Signed-off-by: Greg Kroah-Hartman --- include/linux/device.h | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/include/linux/device.h b/include/linux/device.h index bcf8c0d4cd98..f207a8f49f80 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -47,7 +47,11 @@ struct bus_attribute { }; #define BUS_ATTR(_name, _mode, _show, _store) \ -struct bus_attribute bus_attr_##_name = __ATTR(_name, _mode, _show, _store) + struct bus_attribute bus_attr_##_name = __ATTR(_name, _mode, _show, _store) +#define BUS_ATTR_RW(_name) \ + struct bus_attribute bus_attr_##_name = __ATTR_RW(_name) +#define BUS_ATTR_RO(_name) \ + struct bus_attribute bus_attr_##_name = __ATTR_RO(_name) extern int __must_check bus_create_file(struct bus_type *, struct bus_attribute *); @@ -261,9 +265,12 @@ struct driver_attribute { size_t count); }; -#define DRIVER_ATTR(_name, _mode, _show, _store) \ -struct driver_attribute driver_attr_##_name = \ - __ATTR(_name, _mode, _show, _store) +#define DRIVER_ATTR(_name, _mode, _show, _store) \ + struct driver_attribute driver_attr_##_name = __ATTR(_name, _mode, _show, _store) +#define DRIVER_ATTR_RW(_name) \ + struct driver_attribute driver_attr_##_name = __ATTR_RW(_name) +#define DRIVER_ATTR_RO(_name) \ + struct driver_attribute driver_attr_##_name = __ATTR_RO(_name) extern int __must_check driver_create_file(struct device_driver *driver, const struct driver_attribute *attr); @@ -414,8 +421,12 @@ struct class_attribute { const struct class_attribute *attr); }; -#define CLASS_ATTR(_name, _mode, _show, _store) \ -struct class_attribute class_attr_##_name = __ATTR(_name, _mode, _show, _store) +#define CLASS_ATTR(_name, _mode, _show, _store) \ + struct class_attribute class_attr_##_name = __ATTR(_name, _mode, _show, _store) +#define CLASS_ATTR_RW(_name) \ + struct class_attribute class_attr_##_name = __ATTR_RW(_name) +#define CLASS_ATTR_RO(_name) \ + struct class_attribute class_attr_##_name = __ATTR_RO(_name) extern int __must_check class_create_file(struct class *class, const struct class_attribute *attr); @@ -423,7 +434,6 @@ extern void class_remove_file(struct class *class, const struct class_attribute *attr); /* Simple class attribute that is just a static string */ - struct class_attribute_string { struct class_attribute attr; char *str; @@ -512,6 +522,10 @@ ssize_t device_store_bool(struct device *dev, struct device_attribute *attr, #define DEVICE_ATTR(_name, _mode, _show, _store) \ struct device_attribute dev_attr_##_name = __ATTR(_name, _mode, _show, _store) +#define DEVICE_ATTR_RW(_name) \ + struct device_attribute dev_attr_##_name = __ATTR_RW(_name) +#define DEVICE_ATTR_RO(_name) \ + struct device_attribute dev_attr_##_name = __ATTR_RO(_name) #define DEVICE_ULONG_ATTR(_name, _mode, _var) \ struct dev_ext_attribute dev_attr_##_name = \ { __ATTR(_name, _mode, device_show_ulong, device_store_ulong), &(_var) } From 6ab9cea16075ea707022753395f340b67f64304c Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Sun, 14 Jul 2013 16:05:55 -0700 Subject: [PATCH 0962/1048] sysfs: add support for binary attributes in groups groups should be able to support binary attributes, just like it supports "normal" attributes. This lets us only handle one type of structure, groups, throughout the driver core and subsystems, making binary attributes a "full fledged" part of the driver model, and not something just "tacked on". Reported-by: Oliver Schinagl Reviewed-by: Guenter Roeck Tested-by: Guenter Roeck Signed-off-by: Greg Kroah-Hartman --- fs/sysfs/group.c | 66 ++++++++++++++++++++++++++++++------------- include/linux/sysfs.h | 4 +-- 2 files changed, 48 insertions(+), 22 deletions(-) diff --git a/fs/sysfs/group.c b/fs/sysfs/group.c index aec3d5c98c94..e5719c6095c3 100644 --- a/fs/sysfs/group.c +++ b/fs/sysfs/group.c @@ -20,38 +20,64 @@ static void remove_files(struct sysfs_dirent *dir_sd, struct kobject *kobj, const struct attribute_group *grp) { struct attribute *const* attr; - int i; + struct bin_attribute *const* bin_attr; - for (i = 0, attr = grp->attrs; *attr; i++, attr++) - sysfs_hash_and_remove(dir_sd, NULL, (*attr)->name); + if (grp->attrs) + for (attr = grp->attrs; *attr; attr++) + sysfs_hash_and_remove(dir_sd, NULL, (*attr)->name); + if (grp->bin_attrs) + for (bin_attr = grp->bin_attrs; *bin_attr; bin_attr++) + sysfs_remove_bin_file(kobj, *bin_attr); } static int create_files(struct sysfs_dirent *dir_sd, struct kobject *kobj, const struct attribute_group *grp, int update) { struct attribute *const* attr; + struct bin_attribute *const* bin_attr; int error = 0, i; - for (i = 0, attr = grp->attrs; *attr && !error; i++, attr++) { - umode_t mode = 0; + if (grp->attrs) { + for (i = 0, attr = grp->attrs; *attr && !error; i++, attr++) { + umode_t mode = 0; - /* in update mode, we're changing the permissions or - * visibility. Do this by first removing then - * re-adding (if required) the file */ - if (update) - sysfs_hash_and_remove(dir_sd, NULL, (*attr)->name); - if (grp->is_visible) { - mode = grp->is_visible(kobj, *attr, i); - if (!mode) - continue; + /* + * In update mode, we're changing the permissions or + * visibility. Do this by first removing then + * re-adding (if required) the file. + */ + if (update) + sysfs_hash_and_remove(dir_sd, NULL, + (*attr)->name); + if (grp->is_visible) { + mode = grp->is_visible(kobj, *attr, i); + if (!mode) + continue; + } + error = sysfs_add_file_mode(dir_sd, *attr, + SYSFS_KOBJ_ATTR, + (*attr)->mode | mode); + if (unlikely(error)) + break; + } + if (error) { + remove_files(dir_sd, kobj, grp); + goto exit; } - error = sysfs_add_file_mode(dir_sd, *attr, SYSFS_KOBJ_ATTR, - (*attr)->mode | mode); - if (unlikely(error)) - break; } - if (error) - remove_files(dir_sd, kobj, grp); + + if (grp->bin_attrs) { + for (bin_attr = grp->bin_attrs; *bin_attr; bin_attr++) { + if (update) + sysfs_remove_bin_file(kobj, *bin_attr); + error = sysfs_create_bin_file(kobj, *bin_attr); + if (error) + break; + } + if (error) + remove_files(dir_sd, kobj, grp); + } +exit: return error; } diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h index d50a96b9bb6d..2c3b6a30697d 100644 --- a/include/linux/sysfs.h +++ b/include/linux/sysfs.h @@ -21,6 +21,7 @@ struct kobject; struct module; +struct bin_attribute; enum kobj_ns_type; struct attribute { @@ -59,10 +60,9 @@ struct attribute_group { umode_t (*is_visible)(struct kobject *, struct attribute *, int); struct attribute **attrs; + struct bin_attribute **bin_attrs; }; - - /** * Use these macros to make defining attributes easier. See include/linux/device.h * for examples.. From 388a8c353d671d4ea2f638be84cfcbb912afdcf2 Mon Sep 17 00:00:00 2001 From: Oliver Schinagl Date: Sun, 14 Jul 2013 16:05:56 -0700 Subject: [PATCH 0963/1048] sysfs: prevent warning when only using binary attributes When only using bin_attrs instead of attrs the kernel prints a warning and refuses to create the sysfs entry. This fixes that. Signed-off-by: Oliver Schinagl Signed-off-by: Greg Kroah-Hartman --- fs/sysfs/group.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/sysfs/group.c b/fs/sysfs/group.c index e5719c6095c3..09a1a25cd145 100644 --- a/fs/sysfs/group.c +++ b/fs/sysfs/group.c @@ -93,8 +93,8 @@ static int internal_create_group(struct kobject *kobj, int update, /* Updates may happen before the object has been instantiated */ if (unlikely(update && !kobj->sd)) return -EINVAL; - if (!grp->attrs) { - WARN(1, "sysfs: attrs not set by subsystem for group: %s/%s\n", + if (!grp->attrs && !grp->bin_attrs) { + WARN(1, "sysfs: (bin_)attrs not set by subsystem for group: %s/%s\n", kobj->name, grp->name ? "" : grp->name); return -EINVAL; } From 39ef311204941ddd01ea2950d6220c8ccc710d15 Mon Sep 17 00:00:00 2001 From: Guenter Roeck Date: Sun, 14 Jul 2013 16:05:57 -0700 Subject: [PATCH 0964/1048] driver core: Introduce device_create_groups device_create_groups lets callers create devices as well as associated sysfs attributes with a single call. This avoids race conditions seen if sysfs attributes on new devices are created later. [fixed up comment block placement and add checks for printk buffer formats - gregkh] Signed-off-by: Guenter Roeck Cc: Jean Delvare Signed-off-by: Greg Kroah-Hartman --- drivers/base/core.c | 117 ++++++++++++++++++++++++++++++----------- include/linux/device.h | 5 ++ 2 files changed, 91 insertions(+), 31 deletions(-) diff --git a/drivers/base/core.c b/drivers/base/core.c index dc3ea237f086..a8aae1823f73 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -1667,6 +1667,46 @@ static void device_create_release(struct device *dev) kfree(dev); } +static struct device * +device_create_groups_vargs(struct class *class, struct device *parent, + dev_t devt, void *drvdata, + const struct attribute_group **groups, + const char *fmt, va_list args) +{ + struct device *dev = NULL; + int retval = -ENODEV; + + if (class == NULL || IS_ERR(class)) + goto error; + + dev = kzalloc(sizeof(*dev), GFP_KERNEL); + if (!dev) { + retval = -ENOMEM; + goto error; + } + + dev->devt = devt; + dev->class = class; + dev->parent = parent; + dev->groups = groups; + dev->release = device_create_release; + dev_set_drvdata(dev, drvdata); + + retval = kobject_set_name_vargs(&dev->kobj, fmt, args); + if (retval) + goto error; + + retval = device_register(dev); + if (retval) + goto error; + + return dev; + +error: + put_device(dev); + return ERR_PTR(retval); +} + /** * device_create_vargs - creates a device and registers it with sysfs * @class: pointer to the struct class that this device should be registered to @@ -1696,37 +1736,8 @@ struct device *device_create_vargs(struct class *class, struct device *parent, dev_t devt, void *drvdata, const char *fmt, va_list args) { - struct device *dev = NULL; - int retval = -ENODEV; - - if (class == NULL || IS_ERR(class)) - goto error; - - dev = kzalloc(sizeof(*dev), GFP_KERNEL); - if (!dev) { - retval = -ENOMEM; - goto error; - } - - dev->devt = devt; - dev->class = class; - dev->parent = parent; - dev->release = device_create_release; - dev_set_drvdata(dev, drvdata); - - retval = kobject_set_name_vargs(&dev->kobj, fmt, args); - if (retval) - goto error; - - retval = device_register(dev); - if (retval) - goto error; - - return dev; - -error: - put_device(dev); - return ERR_PTR(retval); + return device_create_groups_vargs(class, parent, devt, drvdata, NULL, + fmt, args); } EXPORT_SYMBOL_GPL(device_create_vargs); @@ -1767,6 +1778,50 @@ struct device *device_create(struct class *class, struct device *parent, } EXPORT_SYMBOL_GPL(device_create); +/** + * device_create_with_groups - creates a device and registers it with sysfs + * @class: pointer to the struct class that this device should be registered to + * @parent: pointer to the parent struct device of this new device, if any + * @devt: the dev_t for the char device to be added + * @drvdata: the data to be added to the device for callbacks + * @groups: NULL-terminated list of attribute groups to be created + * @fmt: string for the device's name + * + * This function can be used by char device classes. A struct device + * will be created in sysfs, registered to the specified class. + * Additional attributes specified in the groups parameter will also + * be created automatically. + * + * A "dev" file will be created, showing the dev_t for the device, if + * the dev_t is not 0,0. + * If a pointer to a parent struct device is passed in, the newly created + * struct device will be a child of that device in sysfs. + * The pointer to the struct device will be returned from the call. + * Any further sysfs files that might be required can be created using this + * pointer. + * + * Returns &struct device pointer on success, or ERR_PTR() on error. + * + * Note: the struct class passed to this function must have previously + * been created with a call to class_create(). + */ +struct device *device_create_with_groups(struct class *class, + struct device *parent, dev_t devt, + void *drvdata, + const struct attribute_group **groups, + const char *fmt, ...) +{ + va_list vargs; + struct device *dev; + + va_start(vargs, fmt); + dev = device_create_groups_vargs(class, parent, devt, drvdata, groups, + fmt, vargs); + va_end(vargs); + return dev; +} +EXPORT_SYMBOL_GPL(device_create_with_groups); + static int __match_devt(struct device *dev, const void *data) { const dev_t *devt = data; diff --git a/include/linux/device.h b/include/linux/device.h index f207a8f49f80..bd5931e89f74 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -938,6 +938,11 @@ extern __printf(5, 6) struct device *device_create(struct class *cls, struct device *parent, dev_t devt, void *drvdata, const char *fmt, ...); +extern __printf(6, 7) +struct device *device_create_with_groups(struct class *cls, + struct device *parent, dev_t devt, void *drvdata, + const struct attribute_group **groups, + const char *fmt, ...); extern void device_destroy(struct class *cls, dev_t devt); /* From d05a6f96c76062b5f25858ac02cf677602076f7e Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Sun, 14 Jul 2013 16:05:58 -0700 Subject: [PATCH 0965/1048] driver core: add default groups to struct class We should be using groups, not attribute lists, for classes to allow subdirectories, and soon, binary files. Groups are just more flexible overall, so add them. The dev_attrs list will go away after all in-kernel users are converted to use dev_groups. Reviewed-by: Guenter Roeck Tested-by: Guenter Roeck Signed-off-by: Greg Kroah-Hartman --- drivers/base/core.c | 9 ++++++++- include/linux/device.h | 4 +++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/base/core.c b/drivers/base/core.c index a8aae1823f73..8856d74545d9 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -528,9 +528,12 @@ static int device_add_attrs(struct device *dev) int error; if (class) { - error = device_add_attributes(dev, class->dev_attrs); + error = device_add_groups(dev, class->dev_groups); if (error) return error; + error = device_add_attributes(dev, class->dev_attrs); + if (error) + goto err_remove_class_groups; error = device_add_bin_attributes(dev, class->dev_bin_attrs); if (error) goto err_remove_class_attrs; @@ -563,6 +566,9 @@ static int device_add_attrs(struct device *dev) err_remove_class_attrs: if (class) device_remove_attributes(dev, class->dev_attrs); + err_remove_class_groups: + if (class) + device_remove_groups(dev, class->dev_groups); return error; } @@ -581,6 +587,7 @@ static void device_remove_attrs(struct device *dev) if (class) { device_remove_attributes(dev, class->dev_attrs); device_remove_bin_attributes(dev, class->dev_bin_attrs); + device_remove_groups(dev, class->dev_groups); } } diff --git a/include/linux/device.h b/include/linux/device.h index bd5931e89f74..22b546a58591 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -320,6 +320,7 @@ int subsys_virtual_register(struct bus_type *subsys, * @name: Name of the class. * @owner: The module owner. * @class_attrs: Default attributes of this class. + * @dev_groups: Default attributes of the devices that belong to the class. * @dev_attrs: Default attributes of the devices belong to the class. * @dev_bin_attrs: Default binary attributes of the devices belong to the class. * @dev_kobj: The kobject that represents this class and links it into the hierarchy. @@ -349,7 +350,8 @@ struct class { struct module *owner; struct class_attribute *class_attrs; - struct device_attribute *dev_attrs; + struct device_attribute *dev_attrs; /* use dev_groups instead */ + const struct attribute_group **dev_groups; struct bin_attribute *dev_bin_attrs; struct kobject *dev_kobj; From 3493f69f4c4e8703961919a9a56c2d2e6a25b46f Mon Sep 17 00:00:00 2001 From: Oliver Schinagl Date: Sun, 14 Jul 2013 16:05:59 -0700 Subject: [PATCH 0966/1048] sysfs: add more helper macro's for (bin_)attribute(_groups) With the recent changes to sysfs there's various helper macro's. However there's no RW, RO BIN_ helper macro's. This patch adds them. Signed-off-by: Oliver Schinagl Signed-off-by: Greg Kroah-Hartman --- include/linux/sysfs.h | 51 ++++++++++++++++++++++++++++++++----------- 1 file changed, 38 insertions(+), 13 deletions(-) diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h index 2c3b6a30697d..d907a7328025 100644 --- a/include/linux/sysfs.h +++ b/include/linux/sysfs.h @@ -17,6 +17,7 @@ #include #include #include +#include #include struct kobject; @@ -94,15 +95,18 @@ struct attribute_group { #define __ATTR_IGNORE_LOCKDEP __ATTR #endif -#define ATTRIBUTE_GROUPS(name) \ -static const struct attribute_group name##_group = { \ - .attrs = name##_attrs, \ -}; \ -static const struct attribute_group *name##_groups[] = { \ - &name##_group, \ +#define __ATTRIBUTE_GROUPS(_name) \ +static const struct attribute_group *_name##_groups[] = { \ + &_name##_group, \ NULL, \ } +#define ATTRIBUTE_GROUPS(_name) \ +static const struct attribute_group _name##_group = { \ + .attrs = _name##_attrs, \ +}; \ +__ATTRIBUTE_GROUPS(_name) + #define attr_name(_attr) (_attr).attr.name struct file; @@ -132,15 +136,36 @@ struct bin_attribute { */ #define sysfs_bin_attr_init(bin_attr) sysfs_attr_init(&(bin_attr)->attr) -/* macro to create static binary attributes easier */ -#define BIN_ATTR(_name, _mode, _read, _write, _size) \ -struct bin_attribute bin_attr_##_name = { \ - .attr = {.name = __stringify(_name), .mode = _mode }, \ - .read = _read, \ - .write = _write, \ - .size = _size, \ +/* macros to create static binary attributes easier */ +#define __BIN_ATTR(_name, _mode, _read, _write, _size) { \ + .attr = { .name = __stringify(_name), .mode = _mode }, \ + .read = _read, \ + .write = _write, \ + .size = _size, \ } +#define __BIN_ATTR_RO(_name, _size) { \ + .attr = { .name = __stringify(_name), .mode = S_IRUGO }, \ + .read = _name##_read, \ + .size = _size, \ +} + +#define __BIN_ATTR_RW(_name, _size) __BIN_ATTR(_name, \ + (S_IWUSR | S_IRUGO), _name##_read, \ + _name##_write) + +#define __BIN_ATTR_NULL __ATTR_NULL + +#define BIN_ATTR(_name, _mode, _read, _write, _size) \ +struct bin_attribute bin_attr_##_name = __BIN_ATTR(_name, _mode, _read, \ + _write, _size) + +#define BIN_ATTR_RO(_name, _size) \ +struct bin_attribute bin_attr_##_name = __BIN_ATTR_RO(_name, _size) + +#define BIN_ATTR_RW(_name, _size) \ +struct bin_attribute bin_attr_##_name = __BIN_ATTR_RW(_name, _size) + struct sysfs_ops { ssize_t (*show)(struct kobject *, struct attribute *,char *); ssize_t (*store)(struct kobject *,struct attribute *,const char *, size_t); From aa01aa3ca205ea04f44423a58bae38aec886fb96 Mon Sep 17 00:00:00 2001 From: Oliver Schinagl Date: Sun, 14 Jul 2013 16:06:00 -0700 Subject: [PATCH 0967/1048] sysfs: use file mode defines from stat.h With the last patches stat.h was included to the header, and thus those permission defines should be used. Signed-off-by: Oliver Schinagl Signed-off-by: Greg Kroah-Hartman --- include/linux/sysfs.h | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h index d907a7328025..9e8a9b555ad6 100644 --- a/include/linux/sysfs.h +++ b/include/linux/sysfs.h @@ -69,18 +69,19 @@ struct attribute_group { * for examples.. */ -#define __ATTR(_name,_mode,_show,_store) { \ - .attr = {.name = __stringify(_name), .mode = _mode }, \ - .show = _show, \ - .store = _store, \ +#define __ATTR(_name,_mode,_show,_store) { \ + .attr = {.name = __stringify(_name), .mode = _mode }, \ + .show = _show, \ + .store = _store, \ } -#define __ATTR_RO(_name) { \ - .attr = { .name = __stringify(_name), .mode = 0444 }, \ - .show = _name##_show, \ +#define __ATTR_RO(_name) { \ + .attr = { .name = __stringify(_name), .mode = S_IRUGO }, \ + .show = _name##_show, \ } -#define __ATTR_RW(_name) __ATTR(_name, 0644, _name##_show, _name##_store) +#define __ATTR_RW(_name) __ATTR(_name, (S_IWUSR | S_IRUGO), \ + _name##_show, _name##_store) #define __ATTR_NULL { .attr = { .name = NULL } } From 584ec4355355ffac43571b02a314d43eb2f7fcbf Mon Sep 17 00:00:00 2001 From: Neil Horman Date: Tue, 16 Jul 2013 10:49:41 -0400 Subject: [PATCH 0968/1048] atl1e: unmap partially mapped skb on dma error and free skb Ben Hutchings pointed out that my recent update to atl1e in commit 352900b583b2852152a1e05ea0e8b579292e731e ("atl1e: fix dma mapping warnings") was missing a bit of code. Specifically it reset the hardware tx ring to its origional state when we hit a dma error, but didn't unmap any exiting mappings from the operation. This patch fixes that up. It also remembers to free the skb in the event that an error occurs, so we don't leak. Untested, as I don't have hardware. I think its pretty straightforward, but please review closely. Signed-off-by: Neil Horman CC: Ben Hutchings CC: Jay Cliburn CC: Chris Snook CC: "David S. Miller" Signed-off-by: David S. Miller --- .../net/ethernet/atheros/atl1e/atl1e_main.c | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/atheros/atl1e/atl1e_main.c b/drivers/net/ethernet/atheros/atl1e/atl1e_main.c index 6d1a62a84c9d..1966444590f6 100644 --- a/drivers/net/ethernet/atheros/atl1e/atl1e_main.c +++ b/drivers/net/ethernet/atheros/atl1e/atl1e_main.c @@ -1678,6 +1678,7 @@ static int atl1e_tx_map(struct atl1e_adapter *adapter, u16 f; int segment; int ring_start = adapter->tx_ring.next_to_use; + int ring_end; nr_frags = skb_shinfo(skb)->nr_frags; segment = (tpd->word3 >> TPD_SEGMENT_EN_SHIFT) & TPD_SEGMENT_EN_MASK; @@ -1721,6 +1722,15 @@ static int atl1e_tx_map(struct atl1e_adapter *adapter, map_len, PCI_DMA_TODEVICE); if (dma_mapping_error(&adapter->pdev->dev, tx_buffer->dma)) { + /* We need to unwind the mappings we've done */ + ring_end = adapter->tx_ring.next_to_use; + adapter->tx_ring.next_to_use = ring_start; + while (adapter->tx_ring.next_to_use != ring_end) { + tpd = atl1e_get_tpd(adapter); + tx_buffer = atl1e_get_tx_buffer(adapter, tpd); + pci_unmap_single(adapter->pdev, tx_buffer->dma, + tx_buffer->length, PCI_DMA_TODEVICE); + } /* Reset the tx rings next pointer */ adapter->tx_ring.next_to_use = ring_start; return -ENOSPC; @@ -1763,6 +1773,16 @@ static int atl1e_tx_map(struct atl1e_adapter *adapter, DMA_TO_DEVICE); if (dma_mapping_error(&adapter->pdev->dev, tx_buffer->dma)) { + /* We need to unwind the mappings we've done */ + ring_end = adapter->tx_ring.next_to_use; + adapter->tx_ring.next_to_use = ring_start; + while (adapter->tx_ring.next_to_use != ring_end) { + tpd = atl1e_get_tpd(adapter); + tx_buffer = atl1e_get_tx_buffer(adapter, tpd); + dma_unmap_page(&adapter->pdev->dev, tx_buffer->dma, + tx_buffer->length, DMA_TO_DEVICE); + } + /* Reset the ring next to use pointer */ adapter->tx_ring.next_to_use = ring_start; return -ENOSPC; @@ -1853,8 +1873,10 @@ static netdev_tx_t atl1e_xmit_frame(struct sk_buff *skb, return NETDEV_TX_OK; } - if (atl1e_tx_map(adapter, skb, tpd)) + if (atl1e_tx_map(adapter, skb, tpd)) { + dev_kfree_skb_any(skb); goto out; + } atl1e_tx_queue(adapter, tpd_req, tpd); From f2f79cca13e36972978ffd1fb6483c8a1141b510 Mon Sep 17 00:00:00 2001 From: Daniel Baluta Date: Sat, 13 Jul 2013 11:26:51 +0300 Subject: [PATCH 0969/1048] ndisc: bool initializations should use true and false Signed-off-by: Daniel Baluta Signed-off-by: David S. Miller --- net/ipv6/ndisc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c index b3b5730b48c5..24c03396e008 100644 --- a/net/ipv6/ndisc.c +++ b/net/ipv6/ndisc.c @@ -479,7 +479,7 @@ static void ndisc_send_na(struct net_device *dev, struct neighbour *neigh, if (ifp) { src_addr = solicited_addr; if (ifp->flags & IFA_F_OPTIMISTIC) - override = 0; + override = false; inc_opt |= ifp->idev->cnf.force_tllao; in6_ifa_put(ifp); } else { @@ -557,7 +557,7 @@ void ndisc_send_ns(struct net_device *dev, struct neighbour *neigh, } if (ipv6_addr_any(saddr)) - inc_opt = 0; + inc_opt = false; if (inc_opt) optlen += ndisc_opt_addr_space(dev); @@ -790,7 +790,7 @@ static void ndisc_recv_ns(struct sk_buff *skb) (is_router = pndisc_is_router(&msg->target, dev)) >= 0)) { if (!(NEIGH_CB(skb)->flags & LOCALLY_ENQUEUED) && skb->pkt_type != PACKET_HOST && - inc != 0 && + inc && idev->nd_parms->proxy_delay != 0) { /* * for anycast or proxy, From 8a73125c36809527236e1d8d367a09a3f0e9f9e1 Mon Sep 17 00:00:00 2001 From: Dragos Foianu Date: Sat, 13 Jul 2013 14:43:00 +0100 Subject: [PATCH 0970/1048] ethtool: fixed trailing statements in ethtool Applied fixes suggested by checkpatch.pl. Signed-off-by: Dragos Foianu Signed-off-by: David S. Miller --- net/core/ethtool.c | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/net/core/ethtool.c b/net/core/ethtool.c index ab5fa6336c84..78e9d9223e40 100644 --- a/net/core/ethtool.c +++ b/net/core/ethtool.c @@ -279,11 +279,16 @@ static u32 __ethtool_get_flags(struct net_device *dev) { u32 flags = 0; - if (dev->features & NETIF_F_LRO) flags |= ETH_FLAG_LRO; - if (dev->features & NETIF_F_HW_VLAN_CTAG_RX) flags |= ETH_FLAG_RXVLAN; - if (dev->features & NETIF_F_HW_VLAN_CTAG_TX) flags |= ETH_FLAG_TXVLAN; - if (dev->features & NETIF_F_NTUPLE) flags |= ETH_FLAG_NTUPLE; - if (dev->features & NETIF_F_RXHASH) flags |= ETH_FLAG_RXHASH; + if (dev->features & NETIF_F_LRO) + flags |= ETH_FLAG_LRO; + if (dev->features & NETIF_F_HW_VLAN_CTAG_RX) + flags |= ETH_FLAG_RXVLAN; + if (dev->features & NETIF_F_HW_VLAN_CTAG_TX) + flags |= ETH_FLAG_TXVLAN; + if (dev->features & NETIF_F_NTUPLE) + flags |= ETH_FLAG_NTUPLE; + if (dev->features & NETIF_F_RXHASH) + flags |= ETH_FLAG_RXHASH; return flags; } @@ -295,11 +300,16 @@ static int __ethtool_set_flags(struct net_device *dev, u32 data) if (data & ~ETH_ALL_FLAGS) return -EINVAL; - if (data & ETH_FLAG_LRO) features |= NETIF_F_LRO; - if (data & ETH_FLAG_RXVLAN) features |= NETIF_F_HW_VLAN_CTAG_RX; - if (data & ETH_FLAG_TXVLAN) features |= NETIF_F_HW_VLAN_CTAG_TX; - if (data & ETH_FLAG_NTUPLE) features |= NETIF_F_NTUPLE; - if (data & ETH_FLAG_RXHASH) features |= NETIF_F_RXHASH; + if (data & ETH_FLAG_LRO) + features |= NETIF_F_LRO; + if (data & ETH_FLAG_RXVLAN) + features |= NETIF_F_HW_VLAN_CTAG_RX; + if (data & ETH_FLAG_TXVLAN) + features |= NETIF_F_HW_VLAN_CTAG_TX; + if (data & ETH_FLAG_NTUPLE) + features |= NETIF_F_NTUPLE; + if (data & ETH_FLAG_RXHASH) + features |= NETIF_F_RXHASH; /* allow changing only bits set in hw_features */ changed = (features ^ dev->features) & ETH_ALL_FEATURES; From b6a82dd233cabcc1517c0744d7a8f0b61f559caf Mon Sep 17 00:00:00 2001 From: Dragos Foianu Date: Sat, 13 Jul 2013 15:03:55 +0100 Subject: [PATCH 0971/1048] net/irda: fixed style issues in irlan_eth Applied fixes suggested by checkpatch.pl Signed-off-by: Dragos Foianu Signed-off-by: David S. Miller --- net/irda/irlan/irlan_eth.c | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/net/irda/irlan/irlan_eth.c b/net/irda/irlan/irlan_eth.c index d14152e866d9..ffcec225b5d9 100644 --- a/net/irda/irlan/irlan_eth.c +++ b/net/irda/irlan/irlan_eth.c @@ -44,12 +44,12 @@ static int irlan_eth_open(struct net_device *dev); static int irlan_eth_close(struct net_device *dev); static netdev_tx_t irlan_eth_xmit(struct sk_buff *skb, struct net_device *dev); -static void irlan_eth_set_multicast_list( struct net_device *dev); +static void irlan_eth_set_multicast_list(struct net_device *dev); static const struct net_device_ops irlan_eth_netdev_ops = { - .ndo_open = irlan_eth_open, - .ndo_stop = irlan_eth_close, - .ndo_start_xmit = irlan_eth_xmit, + .ndo_open = irlan_eth_open, + .ndo_stop = irlan_eth_close, + .ndo_start_xmit = irlan_eth_xmit, .ndo_set_rx_mode = irlan_eth_set_multicast_list, .ndo_change_mtu = eth_change_mtu, .ndo_validate_addr = eth_validate_addr, @@ -110,7 +110,7 @@ static int irlan_eth_open(struct net_device *dev) { struct irlan_cb *self = netdev_priv(dev); - IRDA_DEBUG(2, "%s()\n", __func__ ); + IRDA_DEBUG(2, "%s()\n", __func__); /* Ready to play! */ netif_stop_queue(dev); /* Wait until data link is ready */ @@ -137,7 +137,7 @@ static int irlan_eth_close(struct net_device *dev) { struct irlan_cb *self = netdev_priv(dev); - IRDA_DEBUG(2, "%s()\n", __func__ ); + IRDA_DEBUG(2, "%s()\n", __func__); /* Stop device */ netif_stop_queue(dev); @@ -310,35 +310,32 @@ static void irlan_eth_set_multicast_list(struct net_device *dev) { struct irlan_cb *self = netdev_priv(dev); - IRDA_DEBUG(2, "%s()\n", __func__ ); + IRDA_DEBUG(2, "%s()\n", __func__); /* Check if data channel has been connected yet */ if (self->client.state != IRLAN_DATA) { - IRDA_DEBUG(1, "%s(), delaying!\n", __func__ ); + IRDA_DEBUG(1, "%s(), delaying!\n", __func__); return; } if (dev->flags & IFF_PROMISC) { /* Enable promiscuous mode */ IRDA_WARNING("Promiscuous mode not implemented by IrLAN!\n"); - } - else if ((dev->flags & IFF_ALLMULTI) || + } else if ((dev->flags & IFF_ALLMULTI) || netdev_mc_count(dev) > HW_MAX_ADDRS) { /* Disable promiscuous mode, use normal mode. */ - IRDA_DEBUG(4, "%s(), Setting multicast filter\n", __func__ ); + IRDA_DEBUG(4, "%s(), Setting multicast filter\n", __func__); /* hardware_set_filter(NULL); */ irlan_set_multicast_filter(self, TRUE); - } - else if (!netdev_mc_empty(dev)) { - IRDA_DEBUG(4, "%s(), Setting multicast filter\n", __func__ ); + } else if (!netdev_mc_empty(dev)) { + IRDA_DEBUG(4, "%s(), Setting multicast filter\n", __func__); /* Walk the address list, and load the filter */ /* hardware_set_filter(dev->mc_list); */ irlan_set_multicast_filter(self, TRUE); - } - else { - IRDA_DEBUG(4, "%s(), Clearing multicast filter\n", __func__ ); + } else { + IRDA_DEBUG(4, "%s(), Clearing multicast filter\n", __func__); irlan_set_multicast_filter(self, FALSE); } From 31bd29776b8575b8cf7c25bbf7496a460278dc83 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Mon, 15 Jul 2013 13:26:27 +0200 Subject: [PATCH 0972/1048] bgmac: add dependency to phylib bgmac is using functions from phylib, add the dependency. Signed-off-by: Hauke Mehrtens Signed-off-by: David S. Miller --- drivers/net/ethernet/broadcom/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/ethernet/broadcom/Kconfig b/drivers/net/ethernet/broadcom/Kconfig index 1d680baf43d6..52c96036dcc4 100644 --- a/drivers/net/ethernet/broadcom/Kconfig +++ b/drivers/net/ethernet/broadcom/Kconfig @@ -131,6 +131,7 @@ config BNX2X_SRIOV config BGMAC tristate "BCMA bus GBit core support" depends on BCMA_HOST_SOC && HAS_DMA + select PHYLIB ---help--- This driver supports GBit MAC and BCM4706 GBit MAC cores on BCMA bus. They can be found on BCM47xx SoCs and provide gigabit ethernet. From 9a0f06fee1f453370e87b6568dc1d39d676f53fc Mon Sep 17 00:00:00 2001 From: Tim Gardner Date: Mon, 15 Jul 2013 08:56:45 -0600 Subject: [PATCH 0973/1048] mlx5 core: Fix __udivdi3 when compiling for 32 bit arches Cc: Eli Cohen Signed-off-by: Tim Gardner Acked-by: Randy Dunlap Reported-by: Randy Dunlap Signed-off-by: David S. Miller --- drivers/net/ethernet/mellanox/mlx5/core/debugfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/debugfs.c b/drivers/net/ethernet/mellanox/mlx5/core/debugfs.c index 4273c06e2e96..9c7194b26ee2 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/debugfs.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/debugfs.c @@ -156,7 +156,7 @@ static ssize_t average_read(struct file *filp, char __user *buf, size_t count, stats = filp->private_data; spin_lock(&stats->lock); if (stats->n) - field = stats->sum / stats->n; + field = div64_u64(stats->sum, stats->n); spin_unlock(&stats->lock); ret = snprintf(tbuf, sizeof(tbuf), "%llu\n", field); if (ret > 0) { From 3715534adf899bfc842868865f13a001b8aa4692 Mon Sep 17 00:00:00 2001 From: Paul Bolle Date: Sun, 14 Jul 2013 14:02:19 +0200 Subject: [PATCH 0974/1048] cpufreq: s3c24xx: fix "depends on ARM_S3C24XX" in Kconfig Kconfig symbol S3C24XX_PLL depends on ARM_S3C24XX. But that symbol doesn't exist. Commit f023f8dd59bf ("cpufreq: s3c24xx: move cpufreq driver to drivers/cpufreq"), which added this issue, makes it clear that ARM_S3C24XX_CPUFREQ was intended here. Signed-off-by: Paul Bolle Acked-by: Viresh Kumar Signed-off-by: Rafael J. Wysocki --- arch/arm/mach-s3c24xx/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/mach-s3c24xx/Kconfig b/arch/arm/mach-s3c24xx/Kconfig index 6d9252e081ce..7791ac76f945 100644 --- a/arch/arm/mach-s3c24xx/Kconfig +++ b/arch/arm/mach-s3c24xx/Kconfig @@ -208,7 +208,7 @@ config S3C24XX_GPIO_EXTRA128 config S3C24XX_PLL bool "Support CPUfreq changing of PLL frequency (EXPERIMENTAL)" - depends on ARM_S3C24XX + depends on ARM_S3C24XX_CPUFREQ help Compile in support for changing the PLL frequency from the S3C24XX series CPUfreq driver. The PLL takes time to settle From 21d1196a35f5686c4323e42a62fdb4b23b0ab4a3 Mon Sep 17 00:00:00 2001 From: Eric Dumazet Date: Mon, 15 Jul 2013 20:03:19 -0700 Subject: [PATCH 0975/1048] ipv4: set transport header earlier commit 45f00f99d6e ("ipv4: tcp: clean up tcp_v4_early_demux()") added a performance regression for non GRO traffic, basically disabling IP early demux. IPv6 stack resets transport header in ip6_rcv() before calling IP early demux in ip6_rcv_finish(), while IPv4 does this only in ip_local_deliver_finish(), _after_ IP early demux. GRO traffic happened to enable IP early demux because transport header is also set in inet_gro_receive() Instead of reverting the faulty commit, we can make IPv4/IPv6 behave the same : transport_header should be set in ip_rcv() instead of ip_local_deliver_finish() ip_local_deliver_finish() can also use skb_network_header_len() which is faster than ip_hdrlen() Signed-off-by: Eric Dumazet Cc: Neal Cardwell Cc: Tom Herbert Signed-off-by: David S. Miller --- net/ipv4/ip_input.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/net/ipv4/ip_input.c b/net/ipv4/ip_input.c index 3da817b89e9b..15e3e683adec 100644 --- a/net/ipv4/ip_input.c +++ b/net/ipv4/ip_input.c @@ -190,10 +190,7 @@ static int ip_local_deliver_finish(struct sk_buff *skb) { struct net *net = dev_net(skb->dev); - __skb_pull(skb, ip_hdrlen(skb)); - - /* Point into the IP datagram, just past the header. */ - skb_reset_transport_header(skb); + __skb_pull(skb, skb_network_header_len(skb)); rcu_read_lock(); { @@ -437,6 +434,8 @@ int ip_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt, goto drop; } + skb->transport_header = skb->network_header + iph->ihl*4; + /* Remove any debris in the socket control block */ memset(IPCB(skb), 0, sizeof(struct inet_skb_parm)); From 82a19eb8c02ab98bfe0bf6fa4915de370acb2858 Mon Sep 17 00:00:00 2001 From: Jason Wang Date: Tue, 16 Jul 2013 13:36:33 +0800 Subject: [PATCH 0976/1048] macvtap: fix the missing ret value of TUNSETQUEUE Commit 441ac0fcaadc76ad09771812382345001dd2b813 (macvtap: Convert to using rtnl lock) forget to return what macvtap_ioctl_set_queue() returns to its caller. This may break multiqueue API by always falling through to TUNGETFEATURES. Cc: Vlad Yasevich Signed-off-by: Jason Wang Signed-off-by: David S. Miller --- drivers/net/macvtap.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c index 876c72246ae9..0e5492ec753a 100644 --- a/drivers/net/macvtap.c +++ b/drivers/net/macvtap.c @@ -1107,6 +1107,7 @@ static long macvtap_ioctl(struct file *file, unsigned int cmd, rtnl_lock(); ret = macvtap_ioctl_set_queue(file, u); rtnl_unlock(); + return ret; case TUNGETFEATURES: if (put_user(IFF_TAP | IFF_NO_PI | IFF_VNET_HDR | From 0fbe0d47b1ee2015c288abd4e7b32224f8bfa212 Mon Sep 17 00:00:00 2001 From: Jason Wang Date: Tue, 16 Jul 2013 13:36:34 +0800 Subject: [PATCH 0977/1048] macvtap: do not assume 802.1Q when send vlan packets The hard-coded 8021.q proto will break 802.1ad traffic. So switch to use vlan->proto. Cc: Basil Gor Signed-off-by: Jason Wang Signed-off-by: David S. Miller --- drivers/net/macvtap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c index 0e5492ec753a..a7c5654a2e5c 100644 --- a/drivers/net/macvtap.c +++ b/drivers/net/macvtap.c @@ -873,7 +873,7 @@ static ssize_t macvtap_put_user(struct macvtap_queue *q, __be16 h_vlan_proto; __be16 h_vlan_TCI; } veth; - veth.h_vlan_proto = htons(ETH_P_8021Q); + veth.h_vlan_proto = skb->vlan_proto; veth.h_vlan_TCI = htons(vlan_tx_tag_get(skb)); vlan_offset = offsetof(struct vlan_ethhdr, h_vlan_proto); From 52fe29e4bb614367c108b717c6d7fe5953eb7af3 Mon Sep 17 00:00:00 2001 From: Sarveshwar Bandi Date: Tue, 16 Jul 2013 12:44:02 +0530 Subject: [PATCH 0978/1048] be2net: Fix to avoid hardware workaround when not needed Hardware workaround requesting hardware to skip vlan insertion is necessary only when umc or qnq is enabled. Enabling this workaround in other scenarios could cause controller to stall. Signed-off-by: Sarveshwar Bandi Signed-off-by: David S. Miller --- drivers/net/ethernet/emulex/benet/be_main.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c index 2df48bb0f1ca..181edb522450 100644 --- a/drivers/net/ethernet/emulex/benet/be_main.c +++ b/drivers/net/ethernet/emulex/benet/be_main.c @@ -782,16 +782,22 @@ static struct sk_buff *be_insert_vlan_in_pkt(struct be_adapter *adapter, if (vlan_tx_tag_present(skb)) vlan_tag = be_get_tx_vlan_tag(adapter, skb); - else if (qnq_async_evt_rcvd(adapter) && adapter->pvid) - vlan_tag = adapter->pvid; + + if (qnq_async_evt_rcvd(adapter) && adapter->pvid) { + if (!vlan_tag) + vlan_tag = adapter->pvid; + /* f/w workaround to set skip_hw_vlan = 1, informs the F/W to + * skip VLAN insertion + */ + if (skip_hw_vlan) + *skip_hw_vlan = true; + } if (vlan_tag) { skb = __vlan_put_tag(skb, htons(ETH_P_8021Q), vlan_tag); if (unlikely(!skb)) return skb; skb->vlan_tci = 0; - if (skip_hw_vlan) - *skip_hw_vlan = true; } /* Insert the outer VLAN, if any */ From e8d05276f236ee6435e78411f62be9714e0b9377 Mon Sep 17 00:00:00 2001 From: "Srivatsa S. Bhat" Date: Tue, 16 Jul 2013 22:46:48 +0200 Subject: [PATCH 0979/1048] cpufreq: Revert commit 2f7021a8 to fix CPU hotplug regression commit 2f7021a8 "cpufreq: protect 'policy->cpus' from offlining during __gov_queue_work()" caused a regression in CPU hotplug, because it lead to a deadlock between cpufreq governor worker thread and the CPU hotplug writer task. Lockdep splat corresponding to this deadlock is shown below: [ 60.277396] ====================================================== [ 60.277400] [ INFO: possible circular locking dependency detected ] [ 60.277407] 3.10.0-rc7-dbg-01385-g241fd04-dirty #1744 Not tainted [ 60.277411] ------------------------------------------------------- [ 60.277417] bash/2225 is trying to acquire lock: [ 60.277422] ((&(&j_cdbs->work)->work)){+.+...}, at: [] flush_work+0x5/0x280 [ 60.277444] but task is already holding lock: [ 60.277449] (cpu_hotplug.lock){+.+.+.}, at: [] cpu_hotplug_begin+0x2b/0x60 [ 60.277465] which lock already depends on the new lock. [ 60.277472] the existing dependency chain (in reverse order) is: [ 60.277477] -> #2 (cpu_hotplug.lock){+.+.+.}: [ 60.277490] [] lock_acquire+0xa4/0x200 [ 60.277503] [] mutex_lock_nested+0x67/0x410 [ 60.277514] [] get_online_cpus+0x3c/0x60 [ 60.277522] [] gov_queue_work+0x2a/0xb0 [ 60.277532] [] cs_dbs_timer+0xc1/0xe0 [ 60.277543] [] process_one_work+0x1cd/0x6a0 [ 60.277552] [] worker_thread+0x121/0x3a0 [ 60.277560] [] kthread+0xdb/0xe0 [ 60.277569] [] ret_from_fork+0x7c/0xb0 [ 60.277580] -> #1 (&j_cdbs->timer_mutex){+.+...}: [ 60.277592] [] lock_acquire+0xa4/0x200 [ 60.277600] [] mutex_lock_nested+0x67/0x410 [ 60.277608] [] cs_dbs_timer+0x8d/0xe0 [ 60.277616] [] process_one_work+0x1cd/0x6a0 [ 60.277624] [] worker_thread+0x121/0x3a0 [ 60.277633] [] kthread+0xdb/0xe0 [ 60.277640] [] ret_from_fork+0x7c/0xb0 [ 60.277649] -> #0 ((&(&j_cdbs->work)->work)){+.+...}: [ 60.277661] [] __lock_acquire+0x1766/0x1d30 [ 60.277669] [] lock_acquire+0xa4/0x200 [ 60.277677] [] flush_work+0x3d/0x280 [ 60.277685] [] __cancel_work_timer+0x8a/0x120 [ 60.277693] [] cancel_delayed_work_sync+0x13/0x20 [ 60.277701] [] cpufreq_governor_dbs+0x529/0x6f0 [ 60.277709] [] cs_cpufreq_governor_dbs+0x17/0x20 [ 60.277719] [] __cpufreq_governor+0x48/0x100 [ 60.277728] [] __cpufreq_remove_dev.isra.14+0x80/0x3c0 [ 60.277737] [] cpufreq_cpu_callback+0x38/0x4c [ 60.277747] [] notifier_call_chain+0x5d/0x110 [ 60.277759] [] __raw_notifier_call_chain+0xe/0x10 [ 60.277768] [] _cpu_down+0x88/0x330 [ 60.277779] [] cpu_down+0x36/0x50 [ 60.277788] [] store_online+0x98/0xd0 [ 60.277796] [] dev_attr_store+0x18/0x30 [ 60.277806] [] sysfs_write_file+0xdb/0x150 [ 60.277818] [] vfs_write+0xbd/0x1f0 [ 60.277826] [] SyS_write+0x4c/0xa0 [ 60.277834] [] tracesys+0xd0/0xd5 [ 60.277842] other info that might help us debug this: [ 60.277848] Chain exists of: (&(&j_cdbs->work)->work) --> &j_cdbs->timer_mutex --> cpu_hotplug.lock [ 60.277864] Possible unsafe locking scenario: [ 60.277869] CPU0 CPU1 [ 60.277873] ---- ---- [ 60.277877] lock(cpu_hotplug.lock); [ 60.277885] lock(&j_cdbs->timer_mutex); [ 60.277892] lock(cpu_hotplug.lock); [ 60.277900] lock((&(&j_cdbs->work)->work)); [ 60.277907] *** DEADLOCK *** [ 60.277915] 6 locks held by bash/2225: [ 60.277919] #0: (sb_writers#6){.+.+.+}, at: [] vfs_write+0x1c3/0x1f0 [ 60.277937] #1: (&buffer->mutex){+.+.+.}, at: [] sysfs_write_file+0x3c/0x150 [ 60.277954] #2: (s_active#61){.+.+.+}, at: [] sysfs_write_file+0xc3/0x150 [ 60.277972] #3: (x86_cpu_hotplug_driver_mutex){+.+...}, at: [] cpu_hotplug_driver_lock+0x17/0x20 [ 60.277990] #4: (cpu_add_remove_lock){+.+.+.}, at: [] cpu_down+0x22/0x50 [ 60.278007] #5: (cpu_hotplug.lock){+.+.+.}, at: [] cpu_hotplug_begin+0x2b/0x60 [ 60.278023] stack backtrace: [ 60.278031] CPU: 3 PID: 2225 Comm: bash Not tainted 3.10.0-rc7-dbg-01385-g241fd04-dirty #1744 [ 60.278037] Hardware name: Acer Aspire 5741G /Aspire 5741G , BIOS V1.20 02/08/2011 [ 60.278042] ffffffff8204e110 ffff88014df6b9f8 ffffffff815b3d90 ffff88014df6ba38 [ 60.278055] ffffffff815b0a8d ffff880150ed3f60 ffff880150ed4770 3871c4002c8980b2 [ 60.278068] ffff880150ed4748 ffff880150ed4770 ffff880150ed3f60 ffff88014df6bb00 [ 60.278081] Call Trace: [ 60.278091] [] dump_stack+0x19/0x1b [ 60.278101] [] print_circular_bug+0x2b6/0x2c5 [ 60.278111] [] __lock_acquire+0x1766/0x1d30 [ 60.278123] [] ? __kernel_text_address+0x58/0x80 [ 60.278134] [] lock_acquire+0xa4/0x200 [ 60.278142] [] ? flush_work+0x5/0x280 [ 60.278151] [] flush_work+0x3d/0x280 [ 60.278159] [] ? flush_work+0x5/0x280 [ 60.278169] [] ? mark_held_locks+0x94/0x140 [ 60.278178] [] ? __cancel_work_timer+0x77/0x120 [ 60.278188] [] ? trace_hardirqs_on_caller+0xfd/0x1c0 [ 60.278196] [] __cancel_work_timer+0x8a/0x120 [ 60.278206] [] cancel_delayed_work_sync+0x13/0x20 [ 60.278214] [] cpufreq_governor_dbs+0x529/0x6f0 [ 60.278225] [] cs_cpufreq_governor_dbs+0x17/0x20 [ 60.278234] [] __cpufreq_governor+0x48/0x100 [ 60.278244] [] __cpufreq_remove_dev.isra.14+0x80/0x3c0 [ 60.278255] [] cpufreq_cpu_callback+0x38/0x4c [ 60.278265] [] notifier_call_chain+0x5d/0x110 [ 60.278275] [] __raw_notifier_call_chain+0xe/0x10 [ 60.278284] [] _cpu_down+0x88/0x330 [ 60.278292] [] ? cpu_hotplug_driver_lock+0x17/0x20 [ 60.278302] [] cpu_down+0x36/0x50 [ 60.278311] [] store_online+0x98/0xd0 [ 60.278320] [] dev_attr_store+0x18/0x30 [ 60.278329] [] sysfs_write_file+0xdb/0x150 [ 60.278337] [] vfs_write+0xbd/0x1f0 [ 60.278347] [] ? fget_light+0x320/0x4b0 [ 60.278355] [] SyS_write+0x4c/0xa0 [ 60.278364] [] tracesys+0xd0/0xd5 [ 60.280582] smpboot: CPU 1 is now offline The intention of that commit was to avoid warnings during CPU hotplug, which indicated that offline CPUs were getting IPIs from the cpufreq governor's work items. But the real root-cause of that problem was commit a66b2e5 (cpufreq: Preserve sysfs files across suspend/resume) because it totally skipped all the cpufreq callbacks during CPU hotplug in the suspend/resume path, and hence it never actually shut down the cpufreq governor's worker threads during CPU offline in the suspend/resume path. Reflecting back, the reason why we never suspected that commit as the root-cause earlier, was that the original issue was reported with just the halt command and nobody had brought in suspend/resume to the equation. The reason for _that_ in turn, as it turns out, is that earlier halt/shutdown was being done by disabling non-boot CPUs while tasks were frozen, just like suspend/resume.... but commit cf7df378a (reboot: migrate shutdown/reboot to boot cpu) which came somewhere along that very same time changed that logic: shutdown/halt no longer takes CPUs offline. Thus, the test-cases for reproducing the bug were vastly different and thus we went totally off the trail. Overall, it was one hell of a confusion with so many commits affecting each other and also affecting the symptoms of the problems in subtle ways. Finally, now since the original problematic commit (a66b2e5) has been completely reverted, revert this intermediate fix too (2f7021a8), to fix the CPU hotplug deadlock. Phew! Reported-by: Sergey Senozhatsky Reported-by: Bartlomiej Zolnierkiewicz Signed-off-by: Srivatsa S. Bhat Tested-by: Peter Wu Cc: 3.10+ Signed-off-by: Rafael J. Wysocki --- drivers/cpufreq/cpufreq_governor.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c index 464587697561..7b839a8db2a7 100644 --- a/drivers/cpufreq/cpufreq_governor.c +++ b/drivers/cpufreq/cpufreq_governor.c @@ -25,7 +25,6 @@ #include #include #include -#include #include "cpufreq_governor.h" @@ -137,10 +136,8 @@ void gov_queue_work(struct dbs_data *dbs_data, struct cpufreq_policy *policy, if (!all_cpus) { __gov_queue_work(smp_processor_id(), dbs_data, delay); } else { - get_online_cpus(); for_each_cpu(i, policy->cpus) __gov_queue_work(i, dbs_data, delay); - put_online_cpus(); } } EXPORT_SYMBOL_GPL(gov_queue_work); From 4df05f361937ee86e5a8c9ead8aeb6a19ea9b7d7 Mon Sep 17 00:00:00 2001 From: Kees Cook Date: Tue, 16 Jul 2013 11:34:41 -0700 Subject: [PATCH 0980/1048] x86: Make sure IDT is page aligned Since the IDT is referenced from a fixmap, make sure it is page aligned. Merge with 32-bit one, since it was already aligned to deal with F00F bug. Since bss is cleared before IDT setup, it can live there. This also moves the other *_idt_table variables into common locations. This avoids the risk of the IDT ever being moved in the bss and having the mapping be offset, resulting in calling incorrect handlers. In the current upstream kernel this is not a manifested bug, but heavily patched kernels (such as those using the PaX patch series) did encounter this bug. The tables other than idt_table technically do not need to be page aligned, at least not at the current time, but using a common declaration avoids mistakes. On 64 bits the table is exactly one page long, anyway. Signed-off-by: Kees Cook Link: http://lkml.kernel.org/r/20130716183441.GA14232@www.outflux.net Reported-by: PaX Team Signed-off-by: H. Peter Anvin --- arch/x86/kernel/head_64.S | 15 --------------- arch/x86/kernel/tracepoint.c | 6 ++---- arch/x86/kernel/traps.c | 12 ++++++------ 3 files changed, 8 insertions(+), 25 deletions(-) diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S index 5e4d8a8a5c40..e1aabdb314c8 100644 --- a/arch/x86/kernel/head_64.S +++ b/arch/x86/kernel/head_64.S @@ -512,21 +512,6 @@ ENTRY(phys_base) #include "../../x86/xen/xen-head.S" - .section .bss, "aw", @nobits - .align L1_CACHE_BYTES -ENTRY(idt_table) - .skip IDT_ENTRIES * 16 - - .align L1_CACHE_BYTES -ENTRY(debug_idt_table) - .skip IDT_ENTRIES * 16 - -#ifdef CONFIG_TRACING - .align L1_CACHE_BYTES -ENTRY(trace_idt_table) - .skip IDT_ENTRIES * 16 -#endif - __PAGE_ALIGNED_BSS NEXT_PAGE(empty_zero_page) .skip PAGE_SIZE diff --git a/arch/x86/kernel/tracepoint.c b/arch/x86/kernel/tracepoint.c index 4e584a8d6edd..1c113db9ed57 100644 --- a/arch/x86/kernel/tracepoint.c +++ b/arch/x86/kernel/tracepoint.c @@ -12,10 +12,8 @@ atomic_t trace_idt_ctr = ATOMIC_INIT(0); struct desc_ptr trace_idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) trace_idt_table }; -#ifndef CONFIG_X86_64 -gate_desc trace_idt_table[NR_VECTORS] __page_aligned_data - = { { { { 0, 0 } } }, }; -#endif +/* No need to be aligned, but done to keep all IDTs defined the same way. */ +gate_desc trace_idt_table[NR_VECTORS] __page_aligned_bss; static int trace_irq_vector_refcount; static DEFINE_MUTEX(irq_vector_mutex); diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c index b0865e88d3cc..1b23a1c92746 100644 --- a/arch/x86/kernel/traps.c +++ b/arch/x86/kernel/traps.c @@ -63,19 +63,19 @@ #include #include #include + +/* No need to be aligned, but done to keep all IDTs defined the same way. */ +gate_desc debug_idt_table[NR_VECTORS] __page_aligned_bss; #else #include #include asmlinkage int system_call(void); - -/* - * The IDT has to be page-aligned to simplify the Pentium - * F0 0F bug workaround. - */ -gate_desc idt_table[NR_VECTORS] __page_aligned_data = { { { { 0, 0 } } }, }; #endif +/* Must be page-aligned because the real IDT is used in a fixmap. */ +gate_desc idt_table[NR_VECTORS] __page_aligned_bss; + DECLARE_BITMAP(used_vectors, NR_VECTORS); EXPORT_SYMBOL_GPL(used_vectors); From ae8e9c5a1a7889315229a741fd48a5dd0bc2964c Mon Sep 17 00:00:00 2001 From: "David S. Miller" Date: Tue, 16 Jul 2013 17:09:15 -0700 Subject: [PATCH 0981/1048] net: Fix sysfs_format_mac() code duplication. It's just a duplicate implementation of "%*phC". Thanks to Joe Perches for showing that we had exactly this support in the lib/vsprintf.c code already. Signed-off-by: David S. Miller --- net/ethernet/eth.c | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/net/ethernet/eth.c b/net/ethernet/eth.c index 5359560926bc..be1f64d35358 100644 --- a/net/ethernet/eth.c +++ b/net/ethernet/eth.c @@ -401,27 +401,8 @@ struct net_device *alloc_etherdev_mqs(int sizeof_priv, unsigned int txqs, } EXPORT_SYMBOL(alloc_etherdev_mqs); -static size_t _format_mac_addr(char *buf, int buflen, - const unsigned char *addr, int len) -{ - int i; - char *cp = buf; - - for (i = 0; i < len; i++) { - cp += scnprintf(cp, buflen - (cp - buf), "%02x", addr[i]); - if (i == len - 1) - break; - cp += scnprintf(cp, buflen - (cp - buf), ":"); - } - return cp - buf; -} - ssize_t sysfs_format_mac(char *buf, const unsigned char *addr, int len) { - size_t l; - - l = _format_mac_addr(buf, PAGE_SIZE, addr, len); - l += scnprintf(buf + l, PAGE_SIZE - l, "\n"); - return (ssize_t)l; + return scnprintf(buf, PAGE_SIZE, "%*phC\n", len, addr); } EXPORT_SYMBOL(sysfs_format_mac); From c0d15cc7ee8c0d1970197d9eb1727503bcdd2471 Mon Sep 17 00:00:00 2001 From: Dave Jones Date: Tue, 16 Jul 2013 22:44:08 -0400 Subject: [PATCH 0982/1048] linked-list: Remove __list_for_each __list_for_each used to be the non prefetch() aware list walking primitive. When we removed the prefetch macros from the list routines, it became redundant. Given it does exactly the same thing as list_for_each now, we might as well remove it and call list_for_each directly. All users of __list_for_each have been converted to list_for_each calls in the current merge window. Signed-off-by: Dave Jones Signed-off-by: Linus Torvalds --- include/linux/list.h | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/include/linux/list.h b/include/linux/list.h index b83e5657365a..f4d8a2f12a33 100644 --- a/include/linux/list.h +++ b/include/linux/list.h @@ -380,17 +380,6 @@ static inline void list_splice_tail_init(struct list_head *list, #define list_for_each(pos, head) \ for (pos = (head)->next; pos != (head); pos = pos->next) -/** - * __list_for_each - iterate over a list - * @pos: the &struct list_head to use as a loop cursor. - * @head: the head for your list. - * - * This variant doesn't differ from list_for_each() any more. - * We don't do prefetching in either case. - */ -#define __list_for_each(pos, head) \ - for (pos = (head)->next; pos != (head); pos = pos->next) - /** * list_for_each_prev - iterate over a list backwards * @pos: the &struct list_head to use as a loop cursor. From ade7615de0643a9da628688e661e08148cd7c463 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Tue, 16 Jul 2013 22:37:09 -0700 Subject: [PATCH 0983/1048] staging: csr: remove driver MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This driver is not being updated as the specifications are not able to be gotten from CSR or anyone else. Without those, getting this driver into proper mergable shape is going to be impossible. So remove the driver from the tree. If the specifications ever become available, this patch can be reverted and the driver fixed up properly. Reported-by: Lidza Louina Cc: Veli-Pekka Peltola Cc: Mikko Virkkilä Cc: Lauri Hintsala Cc: Riku Mettälä Signed-off-by: Greg Kroah-Hartman --- drivers/staging/Kconfig | 2 - drivers/staging/Makefile | 1 - drivers/staging/csr/Kconfig | 9 - drivers/staging/csr/LICENSE.txt | 39 - drivers/staging/csr/Makefile | 73 - drivers/staging/csr/bh.c | 404 - drivers/staging/csr/csr_framework_ext.c | 40 - drivers/staging/csr/csr_framework_ext.h | 35 - drivers/staging/csr/csr_framework_ext_types.h | 30 - drivers/staging/csr/csr_log.h | 223 - drivers/staging/csr/csr_log_configure.h | 39 - drivers/staging/csr/csr_log_text.h | 124 - drivers/staging/csr/csr_macro.h | 39 - drivers/staging/csr/csr_msg_transport.h | 17 - drivers/staging/csr/csr_msgconv.c | 291 - drivers/staging/csr/csr_msgconv.h | 78 - drivers/staging/csr/csr_prim_defs.h | 55 - drivers/staging/csr/csr_result.h | 17 - drivers/staging/csr/csr_sched.h | 85 - drivers/staging/csr/csr_sdio.h | 723 -- .../csr/csr_serialize_primitive_types.c | 100 - drivers/staging/csr/csr_time.c | 33 - drivers/staging/csr/csr_time.h | 76 - drivers/staging/csr/csr_util.c | 15 - drivers/staging/csr/csr_wifi_common.h | 101 - drivers/staging/csr/csr_wifi_fsm.h | 240 - drivers/staging/csr/csr_wifi_fsm_event.h | 42 - drivers/staging/csr/csr_wifi_fsm_types.h | 430 -- drivers/staging/csr/csr_wifi_hip_card.h | 114 - drivers/staging/csr/csr_wifi_hip_card_sdio.c | 4001 ---------- drivers/staging/csr/csr_wifi_hip_card_sdio.h | 694 -- .../staging/csr/csr_wifi_hip_card_sdio_intr.c | 2595 ------- .../staging/csr/csr_wifi_hip_card_sdio_mem.c | 1713 ----- drivers/staging/csr/csr_wifi_hip_chiphelper.c | 793 -- drivers/staging/csr/csr_wifi_hip_chiphelper.h | 407 -- .../csr/csr_wifi_hip_chiphelper_private.h | 200 - .../staging/csr/csr_wifi_hip_conversions.h | 73 - drivers/staging/csr/csr_wifi_hip_download.c | 819 --- drivers/staging/csr/csr_wifi_hip_dump.c | 837 --- drivers/staging/csr/csr_wifi_hip_packing.c | 4804 ------------ drivers/staging/csr/csr_wifi_hip_send.c | 415 -- drivers/staging/csr/csr_wifi_hip_signals.c | 1313 ---- drivers/staging/csr/csr_wifi_hip_signals.h | 128 - drivers/staging/csr/csr_wifi_hip_sigs.h | 1417 ---- .../staging/csr/csr_wifi_hip_ta_sampling.c | 541 -- .../staging/csr/csr_wifi_hip_ta_sampling.h | 66 - drivers/staging/csr/csr_wifi_hip_udi.c | 173 - drivers/staging/csr/csr_wifi_hip_unifi.h | 871 --- .../csr/csr_wifi_hip_unifi_signal_names.c | 41 - drivers/staging/csr/csr_wifi_hip_unifi_udi.h | 52 - drivers/staging/csr/csr_wifi_hip_unifihw.h | 59 - .../staging/csr/csr_wifi_hip_unifiversion.h | 30 - drivers/staging/csr/csr_wifi_hip_xbv.c | 1076 --- drivers/staging/csr/csr_wifi_hip_xbv.h | 119 - drivers/staging/csr/csr_wifi_hostio_prim.h | 18 - drivers/staging/csr/csr_wifi_lib.h | 103 - drivers/staging/csr/csr_wifi_msgconv.h | 49 - .../csr/csr_wifi_nme_ap_converter_init.c | 90 - .../csr/csr_wifi_nme_ap_converter_init.h | 41 - ...csr_wifi_nme_ap_free_downstream_contents.c | 84 - .../csr_wifi_nme_ap_free_upstream_contents.c | 39 - drivers/staging/csr/csr_wifi_nme_ap_lib.h | 495 -- drivers/staging/csr/csr_wifi_nme_ap_prim.h | 494 -- drivers/staging/csr/csr_wifi_nme_ap_sef.c | 30 - drivers/staging/csr/csr_wifi_nme_ap_sef.h | 21 - .../staging/csr/csr_wifi_nme_ap_serialize.c | 909 --- .../staging/csr/csr_wifi_nme_ap_serialize.h | 94 - .../staging/csr/csr_wifi_nme_converter_init.h | 38 - drivers/staging/csr/csr_wifi_nme_lib.h | 991 --- drivers/staging/csr/csr_wifi_nme_prim.h | 1657 ----- drivers/staging/csr/csr_wifi_nme_serialize.h | 166 - drivers/staging/csr/csr_wifi_nme_task.h | 27 - drivers/staging/csr/csr_wifi_private_common.h | 81 - drivers/staging/csr/csr_wifi_result.h | 27 - .../csr/csr_wifi_router_converter_init.c | 82 - .../csr/csr_wifi_router_converter_init.h | 34 - .../csr/csr_wifi_router_ctrl_converter_init.c | 134 - .../csr/csr_wifi_router_ctrl_converter_init.h | 34 - ...ifi_router_ctrl_free_downstream_contents.c | 108 - ..._wifi_router_ctrl_free_upstream_contents.c | 87 - .../staging/csr/csr_wifi_router_ctrl_lib.h | 2082 ------ .../staging/csr/csr_wifi_router_ctrl_prim.h | 2113 ------ .../staging/csr/csr_wifi_router_ctrl_sef.c | 46 - .../staging/csr/csr_wifi_router_ctrl_sef.h | 51 - .../csr/csr_wifi_router_ctrl_serialize.c | 2591 ------- .../csr/csr_wifi_router_ctrl_serialize.h | 333 - ...csr_wifi_router_free_downstream_contents.c | 53 - .../csr_wifi_router_free_upstream_contents.c | 47 - drivers/staging/csr/csr_wifi_router_lib.h | 417 -- drivers/staging/csr/csr_wifi_router_prim.h | 421 -- drivers/staging/csr/csr_wifi_router_sef.c | 19 - drivers/staging/csr/csr_wifi_router_sef.h | 25 - .../staging/csr/csr_wifi_router_serialize.c | 418 -- .../staging/csr/csr_wifi_router_serialize.h | 67 - drivers/staging/csr/csr_wifi_router_task.h | 25 - .../staging/csr/csr_wifi_router_transport.c | 199 - .../csr/csr_wifi_serialize_primitive_types.c | 256 - drivers/staging/csr/csr_wifi_sme_ap_lib.h | 774 -- drivers/staging/csr/csr_wifi_sme_ap_prim.h | 1030 --- .../staging/csr/csr_wifi_sme_converter_init.c | 201 - .../staging/csr/csr_wifi_sme_converter_init.h | 34 - .../csr_wifi_sme_free_downstream_contents.c | 187 - .../csr/csr_wifi_sme_free_upstream_contents.c | 275 - drivers/staging/csr/csr_wifi_sme_lib.h | 4303 ----------- drivers/staging/csr/csr_wifi_sme_prim.h | 6510 ----------------- drivers/staging/csr/csr_wifi_sme_sef.c | 85 - drivers/staging/csr/csr_wifi_sme_sef.h | 142 - drivers/staging/csr/csr_wifi_sme_serialize.c | 5809 --------------- drivers/staging/csr/csr_wifi_sme_serialize.h | 666 -- drivers/staging/csr/csr_wifi_sme_task.h | 25 - drivers/staging/csr/csr_wifi_vif_utils.h | 27 - drivers/staging/csr/data_tx.c | 54 - drivers/staging/csr/drv.c | 2193 ------ drivers/staging/csr/firmware.c | 396 - drivers/staging/csr/inet.c | 104 - drivers/staging/csr/init_hw.c | 108 - drivers/staging/csr/io.c | 1098 --- drivers/staging/csr/mlme.c | 433 -- drivers/staging/csr/monitor.c | 384 - drivers/staging/csr/netdev.c | 3307 --------- drivers/staging/csr/os.c | 477 -- drivers/staging/csr/putest.c | 685 -- drivers/staging/csr/sdio_events.c | 134 - drivers/staging/csr/sdio_mmc.c | 1288 ---- drivers/staging/csr/sdio_stubs.c | 82 - drivers/staging/csr/sme_blocking.c | 1466 ---- drivers/staging/csr/sme_mgt.c | 1012 --- drivers/staging/csr/sme_native.c | 566 -- drivers/staging/csr/sme_sys.c | 3260 --------- drivers/staging/csr/sme_userspace.c | 315 - drivers/staging/csr/sme_userspace.h | 38 - drivers/staging/csr/sme_wext.c | 3327 --------- drivers/staging/csr/ul_int.c | 528 -- drivers/staging/csr/unifi_clients.h | 129 - drivers/staging/csr/unifi_config.h | 34 - drivers/staging/csr/unifi_dbg.c | 110 - drivers/staging/csr/unifi_event.c | 692 -- drivers/staging/csr/unifi_native.h | 257 - drivers/staging/csr/unifi_os.h | 122 - drivers/staging/csr/unifi_pdu_processing.c | 3729 ---------- drivers/staging/csr/unifi_priv.h | 1136 --- drivers/staging/csr/unifi_sme.c | 1225 ---- drivers/staging/csr/unifi_sme.h | 245 - drivers/staging/csr/unifi_wext.h | 108 - drivers/staging/csr/unifiio.h | 398 - drivers/staging/csr/wext_events.c | 283 - 146 files changed, 91599 deletions(-) delete mode 100644 drivers/staging/csr/Kconfig delete mode 100644 drivers/staging/csr/LICENSE.txt delete mode 100644 drivers/staging/csr/Makefile delete mode 100644 drivers/staging/csr/bh.c delete mode 100644 drivers/staging/csr/csr_framework_ext.c delete mode 100644 drivers/staging/csr/csr_framework_ext.h delete mode 100644 drivers/staging/csr/csr_framework_ext_types.h delete mode 100644 drivers/staging/csr/csr_log.h delete mode 100644 drivers/staging/csr/csr_log_configure.h delete mode 100644 drivers/staging/csr/csr_log_text.h delete mode 100644 drivers/staging/csr/csr_macro.h delete mode 100644 drivers/staging/csr/csr_msg_transport.h delete mode 100644 drivers/staging/csr/csr_msgconv.c delete mode 100644 drivers/staging/csr/csr_msgconv.h delete mode 100644 drivers/staging/csr/csr_prim_defs.h delete mode 100644 drivers/staging/csr/csr_result.h delete mode 100644 drivers/staging/csr/csr_sched.h delete mode 100644 drivers/staging/csr/csr_sdio.h delete mode 100644 drivers/staging/csr/csr_serialize_primitive_types.c delete mode 100644 drivers/staging/csr/csr_time.c delete mode 100644 drivers/staging/csr/csr_time.h delete mode 100644 drivers/staging/csr/csr_util.c delete mode 100644 drivers/staging/csr/csr_wifi_common.h delete mode 100644 drivers/staging/csr/csr_wifi_fsm.h delete mode 100644 drivers/staging/csr/csr_wifi_fsm_event.h delete mode 100644 drivers/staging/csr/csr_wifi_fsm_types.h delete mode 100644 drivers/staging/csr/csr_wifi_hip_card.h delete mode 100644 drivers/staging/csr/csr_wifi_hip_card_sdio.c delete mode 100644 drivers/staging/csr/csr_wifi_hip_card_sdio.h delete mode 100644 drivers/staging/csr/csr_wifi_hip_card_sdio_intr.c delete mode 100644 drivers/staging/csr/csr_wifi_hip_card_sdio_mem.c delete mode 100644 drivers/staging/csr/csr_wifi_hip_chiphelper.c delete mode 100644 drivers/staging/csr/csr_wifi_hip_chiphelper.h delete mode 100644 drivers/staging/csr/csr_wifi_hip_chiphelper_private.h delete mode 100644 drivers/staging/csr/csr_wifi_hip_conversions.h delete mode 100644 drivers/staging/csr/csr_wifi_hip_download.c delete mode 100644 drivers/staging/csr/csr_wifi_hip_dump.c delete mode 100644 drivers/staging/csr/csr_wifi_hip_packing.c delete mode 100644 drivers/staging/csr/csr_wifi_hip_send.c delete mode 100644 drivers/staging/csr/csr_wifi_hip_signals.c delete mode 100644 drivers/staging/csr/csr_wifi_hip_signals.h delete mode 100644 drivers/staging/csr/csr_wifi_hip_sigs.h delete mode 100644 drivers/staging/csr/csr_wifi_hip_ta_sampling.c delete mode 100644 drivers/staging/csr/csr_wifi_hip_ta_sampling.h delete mode 100644 drivers/staging/csr/csr_wifi_hip_udi.c delete mode 100644 drivers/staging/csr/csr_wifi_hip_unifi.h delete mode 100644 drivers/staging/csr/csr_wifi_hip_unifi_signal_names.c delete mode 100644 drivers/staging/csr/csr_wifi_hip_unifi_udi.h delete mode 100644 drivers/staging/csr/csr_wifi_hip_unifihw.h delete mode 100644 drivers/staging/csr/csr_wifi_hip_unifiversion.h delete mode 100644 drivers/staging/csr/csr_wifi_hip_xbv.c delete mode 100644 drivers/staging/csr/csr_wifi_hip_xbv.h delete mode 100644 drivers/staging/csr/csr_wifi_hostio_prim.h delete mode 100644 drivers/staging/csr/csr_wifi_lib.h delete mode 100644 drivers/staging/csr/csr_wifi_msgconv.h delete mode 100644 drivers/staging/csr/csr_wifi_nme_ap_converter_init.c delete mode 100644 drivers/staging/csr/csr_wifi_nme_ap_converter_init.h delete mode 100644 drivers/staging/csr/csr_wifi_nme_ap_free_downstream_contents.c delete mode 100644 drivers/staging/csr/csr_wifi_nme_ap_free_upstream_contents.c delete mode 100644 drivers/staging/csr/csr_wifi_nme_ap_lib.h delete mode 100644 drivers/staging/csr/csr_wifi_nme_ap_prim.h delete mode 100644 drivers/staging/csr/csr_wifi_nme_ap_sef.c delete mode 100644 drivers/staging/csr/csr_wifi_nme_ap_sef.h delete mode 100644 drivers/staging/csr/csr_wifi_nme_ap_serialize.c delete mode 100644 drivers/staging/csr/csr_wifi_nme_ap_serialize.h delete mode 100644 drivers/staging/csr/csr_wifi_nme_converter_init.h delete mode 100644 drivers/staging/csr/csr_wifi_nme_lib.h delete mode 100644 drivers/staging/csr/csr_wifi_nme_prim.h delete mode 100644 drivers/staging/csr/csr_wifi_nme_serialize.h delete mode 100644 drivers/staging/csr/csr_wifi_nme_task.h delete mode 100644 drivers/staging/csr/csr_wifi_private_common.h delete mode 100644 drivers/staging/csr/csr_wifi_result.h delete mode 100644 drivers/staging/csr/csr_wifi_router_converter_init.c delete mode 100644 drivers/staging/csr/csr_wifi_router_converter_init.h delete mode 100644 drivers/staging/csr/csr_wifi_router_ctrl_converter_init.c delete mode 100644 drivers/staging/csr/csr_wifi_router_ctrl_converter_init.h delete mode 100644 drivers/staging/csr/csr_wifi_router_ctrl_free_downstream_contents.c delete mode 100644 drivers/staging/csr/csr_wifi_router_ctrl_free_upstream_contents.c delete mode 100644 drivers/staging/csr/csr_wifi_router_ctrl_lib.h delete mode 100644 drivers/staging/csr/csr_wifi_router_ctrl_prim.h delete mode 100644 drivers/staging/csr/csr_wifi_router_ctrl_sef.c delete mode 100644 drivers/staging/csr/csr_wifi_router_ctrl_sef.h delete mode 100644 drivers/staging/csr/csr_wifi_router_ctrl_serialize.c delete mode 100644 drivers/staging/csr/csr_wifi_router_ctrl_serialize.h delete mode 100644 drivers/staging/csr/csr_wifi_router_free_downstream_contents.c delete mode 100644 drivers/staging/csr/csr_wifi_router_free_upstream_contents.c delete mode 100644 drivers/staging/csr/csr_wifi_router_lib.h delete mode 100644 drivers/staging/csr/csr_wifi_router_prim.h delete mode 100644 drivers/staging/csr/csr_wifi_router_sef.c delete mode 100644 drivers/staging/csr/csr_wifi_router_sef.h delete mode 100644 drivers/staging/csr/csr_wifi_router_serialize.c delete mode 100644 drivers/staging/csr/csr_wifi_router_serialize.h delete mode 100644 drivers/staging/csr/csr_wifi_router_task.h delete mode 100644 drivers/staging/csr/csr_wifi_router_transport.c delete mode 100644 drivers/staging/csr/csr_wifi_serialize_primitive_types.c delete mode 100644 drivers/staging/csr/csr_wifi_sme_ap_lib.h delete mode 100644 drivers/staging/csr/csr_wifi_sme_ap_prim.h delete mode 100644 drivers/staging/csr/csr_wifi_sme_converter_init.c delete mode 100644 drivers/staging/csr/csr_wifi_sme_converter_init.h delete mode 100644 drivers/staging/csr/csr_wifi_sme_free_downstream_contents.c delete mode 100644 drivers/staging/csr/csr_wifi_sme_free_upstream_contents.c delete mode 100644 drivers/staging/csr/csr_wifi_sme_lib.h delete mode 100644 drivers/staging/csr/csr_wifi_sme_prim.h delete mode 100644 drivers/staging/csr/csr_wifi_sme_sef.c delete mode 100644 drivers/staging/csr/csr_wifi_sme_sef.h delete mode 100644 drivers/staging/csr/csr_wifi_sme_serialize.c delete mode 100644 drivers/staging/csr/csr_wifi_sme_serialize.h delete mode 100644 drivers/staging/csr/csr_wifi_sme_task.h delete mode 100644 drivers/staging/csr/csr_wifi_vif_utils.h delete mode 100644 drivers/staging/csr/data_tx.c delete mode 100644 drivers/staging/csr/drv.c delete mode 100644 drivers/staging/csr/firmware.c delete mode 100644 drivers/staging/csr/inet.c delete mode 100644 drivers/staging/csr/init_hw.c delete mode 100644 drivers/staging/csr/io.c delete mode 100644 drivers/staging/csr/mlme.c delete mode 100644 drivers/staging/csr/monitor.c delete mode 100644 drivers/staging/csr/netdev.c delete mode 100644 drivers/staging/csr/os.c delete mode 100644 drivers/staging/csr/putest.c delete mode 100644 drivers/staging/csr/sdio_events.c delete mode 100644 drivers/staging/csr/sdio_mmc.c delete mode 100644 drivers/staging/csr/sdio_stubs.c delete mode 100644 drivers/staging/csr/sme_blocking.c delete mode 100644 drivers/staging/csr/sme_mgt.c delete mode 100644 drivers/staging/csr/sme_native.c delete mode 100644 drivers/staging/csr/sme_sys.c delete mode 100644 drivers/staging/csr/sme_userspace.c delete mode 100644 drivers/staging/csr/sme_userspace.h delete mode 100644 drivers/staging/csr/sme_wext.c delete mode 100644 drivers/staging/csr/ul_int.c delete mode 100644 drivers/staging/csr/unifi_clients.h delete mode 100644 drivers/staging/csr/unifi_config.h delete mode 100644 drivers/staging/csr/unifi_dbg.c delete mode 100644 drivers/staging/csr/unifi_event.c delete mode 100644 drivers/staging/csr/unifi_native.h delete mode 100644 drivers/staging/csr/unifi_os.h delete mode 100644 drivers/staging/csr/unifi_pdu_processing.c delete mode 100644 drivers/staging/csr/unifi_priv.h delete mode 100644 drivers/staging/csr/unifi_sme.c delete mode 100644 drivers/staging/csr/unifi_sme.h delete mode 100644 drivers/staging/csr/unifi_wext.h delete mode 100644 drivers/staging/csr/unifiio.h delete mode 100644 drivers/staging/csr/wext_events.c diff --git a/drivers/staging/Kconfig b/drivers/staging/Kconfig index 3227ebeae3f1..57d8b3444600 100644 --- a/drivers/staging/Kconfig +++ b/drivers/staging/Kconfig @@ -118,8 +118,6 @@ source "drivers/staging/ozwpan/Kconfig" source "drivers/staging/gdm72xx/Kconfig" -source "drivers/staging/csr/Kconfig" - source "drivers/staging/silicom/Kconfig" source "drivers/staging/ced1401/Kconfig" diff --git a/drivers/staging/Makefile b/drivers/staging/Makefile index 4d79ebe2de06..429321f15105 100644 --- a/drivers/staging/Makefile +++ b/drivers/staging/Makefile @@ -52,7 +52,6 @@ obj-$(CONFIG_MFD_NVEC) += nvec/ obj-$(CONFIG_ANDROID) += android/ obj-$(CONFIG_USB_WPAN_HCD) += ozwpan/ obj-$(CONFIG_WIMAX_GDM72XX) += gdm72xx/ -obj-$(CONFIG_CSR_WIFI) += csr/ obj-$(CONFIG_NET_VENDOR_SILICOM) += silicom/ obj-$(CONFIG_CED1401) += ced1401/ obj-$(CONFIG_DRM_IMX) += imx-drm/ diff --git a/drivers/staging/csr/Kconfig b/drivers/staging/csr/Kconfig deleted file mode 100644 index ad2a1096e920..000000000000 --- a/drivers/staging/csr/Kconfig +++ /dev/null @@ -1,9 +0,0 @@ -config CSR_WIFI - tristate "CSR wireless driver" - depends on MMC && CFG80211_WEXT && INET - select WIRELESS_EXT - select WEXT_PRIV - help - Driver for the CSR wireless SDIO device. - - If unsure, select N. diff --git a/drivers/staging/csr/LICENSE.txt b/drivers/staging/csr/LICENSE.txt deleted file mode 100644 index 364853e5fedc..000000000000 --- a/drivers/staging/csr/LICENSE.txt +++ /dev/null @@ -1,39 +0,0 @@ -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -Except as contained in this notice, the names of above-listed -copyright holders and the names of any contributors shall not be used -in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR -CONTRIBUTORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT -OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. - -Alternatively, this software may be distributed under the terms of the -GNU General Public License ("GPL") version 2 as published -by the Free Software Foundation. - -As a special exception, if other files instantiate templates or use -macros or inline functions from this file, or you compile this file -and link it with other works to produce a work based on this file, -this file does not by itself cause the resulting work to be covered by -the GNU General Public License. However the source code for this file -must still be made available in accordance with section (3) of the GNU -General Public License. - -This exception does not invalidate any other reasons why a work based -on this file might be covered by the GNU General Public License. diff --git a/drivers/staging/csr/Makefile b/drivers/staging/csr/Makefile deleted file mode 100644 index dbd135a8b177..000000000000 --- a/drivers/staging/csr/Makefile +++ /dev/null @@ -1,73 +0,0 @@ -ccflags-y := -DCSR_SME_USERSPACE -DCSR_SUPPORT_SME -DREMOTE_SYS_SAP -DCSR_WIFI_SECURITY_WAPI_ENABLE -DENABLE_SHUTDOWN -DUNIFI_DEBUG -ccflags-y += -DSDIO_EXPORTS_STRUCT_DEVICE -DCSR_WIFI_SUPPORT_MMC_DRIVER -DCSR_WIFI_SINGLE_FUNCTION -DCSR_WIFI_SPLIT_PATCH -ccflags-y += -DCSR_SUPPORT_WEXT -DREMOTE_SYS_SAP -DREMOTE_MGT_SAP -DCSR_WIFI_SECURITY_WAPI_ENABLE -DCSR_WIFI_SECURITY_WAPI_QOSCTRL_MIC_WORKAROUND -DENABLE_SHUTDOWN -DCSR_WIFI_NME_ENABLE -DCSR_WIFI_AP_ENABLE -DCSR_SUPPORT_WEXT_AP -DCSR_WIFI_REQUEUE_PACKET_TO_HAL - -obj-$(CONFIG_CSR_WIFI) += csr_wifi.o -obj-$(CONFIG_CSR_WIFI) += csr_helper.o - -csr_wifi-y := bh.o \ - data_tx.o \ - drv.o \ - firmware.o \ - inet.o \ - init_hw.o \ - io.o \ - monitor.o \ - netdev.o \ - os.o \ - putest.o \ - sdio_events.o \ - sdio_mmc.o \ - sdio_stubs.o \ - sme_blocking.o \ - ul_int.o \ - unifi_dbg.o \ - unifi_event.o \ - unifi_pdu_processing.o \ - unifi_sme.o \ - csr_wifi_hip_card_sdio.o \ - csr_wifi_hip_card_sdio_intr.o \ - csr_wifi_hip_card_sdio_mem.o \ - csr_wifi_hip_chiphelper.o \ - csr_wifi_hip_download.o \ - csr_wifi_hip_dump.o \ - csr_wifi_hip_packing.o \ - csr_wifi_hip_send.o \ - csr_wifi_hip_signals.o \ - csr_wifi_hip_ta_sampling.o \ - csr_wifi_hip_udi.o \ - csr_wifi_hip_unifi_signal_names.o \ - csr_wifi_hip_xbv.o \ - csr_wifi_nme_ap_converter_init.o \ - csr_wifi_nme_ap_free_downstream_contents.o \ - csr_wifi_nme_ap_free_upstream_contents.o \ - csr_wifi_nme_ap_serialize.o \ - csr_wifi_nme_ap_sef.o \ - csr_wifi_router_ctrl_sef.o \ - csr_wifi_router_sef.o \ - csr_wifi_router_transport.o \ - csr_wifi_sme_sef.o \ - csr_wifi_sme_converter_init.o \ - csr_wifi_sme_free_downstream_contents.o \ - csr_wifi_sme_free_upstream_contents.o \ - csr_wifi_sme_serialize.o \ - csr_wifi_router_ctrl_converter_init.o \ - csr_wifi_router_ctrl_free_downstream_contents.o \ - csr_wifi_router_ctrl_free_upstream_contents.o \ - csr_wifi_router_ctrl_serialize.o \ - csr_wifi_router_converter_init.o \ - csr_wifi_router_free_downstream_contents.o \ - csr_wifi_router_free_upstream_contents.o \ - csr_wifi_router_serialize.o \ - sme_mgt.o \ - sme_sys.o \ - sme_userspace.o \ - sme_wext.o \ - wext_events.o - -csr_helper-y := csr_time.o \ - csr_util.o \ - csr_framework_ext.o \ - csr_wifi_serialize_primitive_types.o \ - csr_serialize_primitive_types.o \ - csr_msgconv.o diff --git a/drivers/staging/csr/bh.c b/drivers/staging/csr/bh.c deleted file mode 100644 index d795852ccb1c..000000000000 --- a/drivers/staging/csr/bh.c +++ /dev/null @@ -1,404 +0,0 @@ -/* - * --------------------------------------------------------------------------- - * FILE: bh.c - * - * PURPOSE: - * Provides an implementation for the driver bottom-half. - * It is part of the porting exercise in Linux. - * - * Copyright (C) 2005-2009 by Cambridge Silicon Radio Ltd. - * - * Refer to LICENSE.txt included with this source code for details on - * the license terms. - * - * --------------------------------------------------------------------------- - */ -#include "csr_wifi_hip_unifi.h" -#include "unifi_priv.h" -#include - -/* - * --------------------------------------------------------------------------- - * uf_start_thread - * - * Helper function to start a new thread. - * - * Arguments: - * priv Pointer to OS driver structure for the device. - * thread Pointer to the thread object - * func The thread function - * - * Returns: - * 0 on success or else a Linux error code. - * --------------------------------------------------------------------------- - */ -int uf_start_thread(unifi_priv_t *priv, - struct uf_thread *thread, int (*func)(void *)) -{ - if (thread->thread_task != NULL) { - unifi_error(priv, "%s thread already started\n", thread->name); - return 0; - } - - /* Start the kernel thread that handles all h/w accesses. */ - thread->thread_task = kthread_run(func, priv, "%s", thread->name); - if (IS_ERR(thread->thread_task)) - return PTR_ERR(thread->thread_task); - - /* Module parameter overides the thread priority */ - if (bh_priority != -1) { - if (bh_priority >= 0 && bh_priority <= MAX_RT_PRIO) { - struct sched_param param; - priv->bh_thread.prio = bh_priority; - unifi_trace(priv, UDBG1, - "%s thread (RT) priority = %d\n", - thread->name, bh_priority); - param.sched_priority = bh_priority; - sched_setscheduler(thread->thread_task, - SCHED_FIFO, ¶m); - } else if (bh_priority > MAX_RT_PRIO && - bh_priority <= MAX_PRIO) { - priv->bh_thread.prio = bh_priority; - unifi_trace(priv, UDBG1, "%s thread priority = %d\n", - thread->name, - PRIO_TO_NICE(bh_priority)); - set_user_nice(thread->thread_task, - PRIO_TO_NICE(bh_priority)); - } else { - priv->bh_thread.prio = DEFAULT_PRIO; - unifi_warning(priv, - "%s thread unsupported (%d) priority\n", - thread->name, bh_priority); - } - } else - priv->bh_thread.prio = DEFAULT_PRIO; - unifi_trace(priv, UDBG2, "Started %s thread\n", thread->name); - - return 0; -} /* uf_start_thread() */ - - -/* - * --------------------------------------------------------------------------- - * uf_stop_thread - * - * Helper function to stop a thread. - * - * Arguments: - * priv Pointer to OS driver structure for the device. - * thread Pointer to the thread object - * - * Returns: - * - * --------------------------------------------------------------------------- - */ -void uf_stop_thread(unifi_priv_t *priv, struct uf_thread *thread) -{ - if (!thread->thread_task) { - unifi_notice(priv, "%s thread is already stopped\n", - thread->name); - return; - } - - unifi_trace(priv, UDBG2, "Stopping %s thread\n", thread->name); - - kthread_stop(thread->thread_task); - thread->thread_task = NULL; - -} /* uf_stop_thread() */ - - - -/* - * --------------------------------------------------------------------------- - * uf_wait_for_thread_to_stop - * - * Helper function to wait until a thread is stopped. - * - * Arguments: - * priv Pointer to OS driver structure for the device. - * - * Returns: - * - * --------------------------------------------------------------------------- - */ -void -uf_wait_for_thread_to_stop(unifi_priv_t *priv, struct uf_thread *thread) -{ - /* - * kthread_stop() cannot handle the thread exiting while - * kthread_should_stop() is false, so sleep until kthread_stop() - * wakes us up - */ - unifi_trace(priv, UDBG2, "%s waiting for the stop signal.\n", - thread->name); - set_current_state(TASK_INTERRUPTIBLE); - if (!kthread_should_stop()) { - unifi_trace(priv, UDBG2, "%s schedule....\n", thread->name); - schedule(); - } - - thread->thread_task = NULL; - unifi_trace(priv, UDBG2, "%s exiting....\n", thread->name); -} /* uf_wait_for_thread_to_stop() */ - - -/* - * --------------------------------------------------------------------------- - * handle_bh_error - * - * This function reports an error returned from the HIP core bottom-half. - * Normally, implemented during the porting exercise, passing the error - * to the SME using unifi_sys_wifi_off_ind(). - * The SME will try to reset the device and go through - * the initialisation of the UniFi. - * - * Arguments: - * priv Pointer to OS driver structure for the device. - * - * Returns: - * None. - * --------------------------------------------------------------------------- - */ -static void -handle_bh_error(unifi_priv_t *priv) -{ - netInterface_priv_t *interfacePriv; - u8 conf_param = CONFIG_IND_ERROR; - u8 interfaceTag; - - - /* Block unifi_run_bh() until the error has been handled. */ - priv->bh_thread.block_thread = 1; - - /* Consider UniFi to be uninitialised */ - priv->init_progress = UNIFI_INIT_NONE; - - /* Stop the network traffic */ - for (interfaceTag = 0; - interfaceTag < CSR_WIFI_NUM_INTERFACES; interfaceTag++) { - interfacePriv = priv->interfacePriv[interfaceTag]; - if (interfacePriv->netdev_registered) - netif_carrier_off(priv->netdev[interfaceTag]); - } - -#ifdef CSR_NATIVE_LINUX - /* Force any client waiting on an mlme_wait_for_reply() to abort. */ - uf_abort_mlme(priv); - - /* Cancel any pending workqueue tasks */ - flush_workqueue(priv->unifi_workqueue); - -#endif /* CSR_NATIVE_LINUX */ - - unifi_error(priv, - "handle_bh_error: fatal error is reported to the SME.\n"); - /* Notify the clients (SME or unifi_manager) for the error. */ - ul_log_config_ind(priv, &conf_param, sizeof(u8)); - -} /* handle_bh_error() */ - - - -/* - * --------------------------------------------------------------------------- - * bh_thread_function - * - * All hardware access happens in this thread. - * This means there is no need for locks on the hardware and we don't need - * to worry about reentrancy with the SDIO library. - * Provides and example implementation on how to call unifi_bh(), which - * is part of the HIP core API. - * - * It processes the events generated by unifi_run_bh() to serialise calls - * to unifi_bh(). It also demonstrates how the timeout parameter passed in - * and returned from unifi_bh() needs to be handled. - * - * Arguments: - * arg Pointer to OS driver structure for the device. - * - * Returns: - * None. - * - * Notes: - * When the bottom half of the driver needs to process signals, events, - * or simply the host status (i.e sleep mode), it invokes unifi_run_bh(). - * Since we need all SDIO transaction to be in a single thread, the - * unifi_run_bh() will wake up this thread to process it. - * - * --------------------------------------------------------------------------- - */ -static int bh_thread_function(void *arg) -{ - unifi_priv_t *priv = (unifi_priv_t *)arg; - CsrResult csrResult; - long ret; - u32 timeout, t; - struct uf_thread *this_thread; - - unifi_trace(priv, UDBG2, "bh_thread_function starting\n"); - - this_thread = &priv->bh_thread; - - t = timeout = 0; - while (!kthread_should_stop()) { - /* - * wait until an error occurs, - * or we need to process something. - */ - unifi_trace(priv, UDBG3, "bh_thread goes to sleep.\n"); - - if (timeout > 0) { - /* Convert t in ms to jiffies */ - t = msecs_to_jiffies(timeout); - ret = wait_event_interruptible_timeout( - this_thread->wakeup_q, - (this_thread->wakeup_flag && !this_thread->block_thread) || - kthread_should_stop(), - t); - timeout = (ret > 0) ? jiffies_to_msecs(ret) : 0; - } else { - ret = wait_event_interruptible(this_thread->wakeup_q, - (this_thread->wakeup_flag && !this_thread->block_thread) || - kthread_should_stop()); - } - - if (kthread_should_stop()) { - unifi_trace(priv, UDBG2, - "bh_thread: signalled to exit\n"); - break; - } - - if (ret < 0) { - unifi_notice(priv, - "bh_thread: wait_event returned %d, thread will exit\n", - ret); - uf_wait_for_thread_to_stop(priv, this_thread); - break; - } - - this_thread->wakeup_flag = 0; - - unifi_trace(priv, UDBG3, "bh_thread calls unifi_bh().\n"); - - CsrSdioClaim(priv->sdio); - csrResult = unifi_bh(priv->card, &timeout); - if (csrResult != CSR_RESULT_SUCCESS) { - if (csrResult == CSR_WIFI_HIP_RESULT_NO_DEVICE) { - CsrSdioRelease(priv->sdio); - uf_wait_for_thread_to_stop(priv, this_thread); - break; - } - /* Errors must be delivered to the error task */ - handle_bh_error(priv); - } - CsrSdioRelease(priv->sdio); - } - - /* - * I would normally try to call csr_sdio_remove_irq() here to make sure - * that we do not get any interrupts while this thread is not running. - * However, the MMC/SDIO driver tries to kill its' interrupt thread. - * The kernel threads implementation does not allow to kill threads - * from a signalled to stop thread. - * So, instead call csr_sdio_linux_remove_irq() always after calling - * uf_stop_thread() to kill this thread. - */ - - unifi_trace(priv, UDBG2, "bh_thread exiting....\n"); - return 0; -} /* bh_thread_function() */ - - -/* - * --------------------------------------------------------------------------- - * uf_init_bh - * - * Helper function to start the bottom half of the driver. - * All we need to do here is start the I/O bh thread. - * - * Arguments: - * priv Pointer to OS driver structure for the device. - * - * Returns: - * 0 on success or else a Linux error code. - * --------------------------------------------------------------------------- - */ -int -uf_init_bh(unifi_priv_t *priv) -{ - int r; - - /* Enable mlme interface. */ - priv->io_aborted = 0; - - - /* Start the BH thread */ - r = uf_start_thread(priv, &priv->bh_thread, bh_thread_function); - if (r) { - unifi_error(priv, - "uf_init_bh: failed to start the BH thread.\n"); - return r; - } - - /* Allow interrupts */ - r = csr_sdio_linux_install_irq(priv->sdio); - if (r) { - unifi_error(priv, - "uf_init_bh: failed to install the IRQ.\n"); - - uf_stop_thread(priv, &priv->bh_thread); - } - - return r; -} /* uf_init_bh() */ - - -/* - * --------------------------------------------------------------------------- - * unifi_run_bh - * - * Part of the HIP core lib API, implemented in the porting exercise. - * The bottom half of the driver calls this function when - * it wants to process anything that requires access to unifi. - * We need to call unifi_bh() which in this implementation is done - * by waking up the I/O thread. - * - * Arguments: - * ospriv Pointer to OS driver structure for the device. - * - * Returns: - * 0 on success or else a Linux error code. - * - * Notes: - * --------------------------------------------------------------------------- - */ -CsrResult unifi_run_bh(void *ospriv) -{ - unifi_priv_t *priv = ospriv; - - /* - * If an error has occurred, we discard silently all messages from the bh - * until the error has been processed and the unifi has been - * reinitialised. - */ - if (priv->bh_thread.block_thread == 1) { - unifi_trace(priv, UDBG3, "unifi_run_bh: discard message.\n"); - /* - * Do not try to acknowledge a pending interrupt here. - * This function is called by unifi_send_signal() - * which in turn can be running in an atomic or 'disabled irq' - * level if a signal is sent from a workqueue task - * (i.e multicass addresses set). We can not hold the SDIO lock - * because it might sleep. - */ - return CSR_RESULT_FAILURE; - } - - priv->bh_thread.wakeup_flag = 1; - /* wake up I/O thread */ - wake_up_interruptible(&priv->bh_thread.wakeup_q); - - return CSR_RESULT_SUCCESS; -} /* unifi_run_bh() */ - diff --git a/drivers/staging/csr/csr_framework_ext.c b/drivers/staging/csr/csr_framework_ext.c deleted file mode 100644 index 98122bce1427..000000000000 --- a/drivers/staging/csr/csr_framework_ext.c +++ /dev/null @@ -1,40 +0,0 @@ -/***************************************************************************** - - (c) Cambridge Silicon Radio Limited 2010 - All rights reserved and confidential information of CSR - - Refer to LICENSE.txt included with this source for details - on the license terms. - -*****************************************************************************/ - -#include -#include -#include -#include -#include -#include -#include - -#include "csr_framework_ext.h" - -/*----------------------------------------------------------------------------* - * NAME - * CsrThreadSleep - * - * DESCRIPTION - * Sleep for a given period. - * - * RETURNS - * void - * - *----------------------------------------------------------------------------*/ -void CsrThreadSleep(u16 sleepTimeInMs) -{ - unsigned long t; - - /* Convert t in ms to jiffies and round up */ - t = ((sleepTimeInMs * HZ) + 999) / 1000; - schedule_timeout_uninterruptible(t); -} -EXPORT_SYMBOL_GPL(CsrThreadSleep); diff --git a/drivers/staging/csr/csr_framework_ext.h b/drivers/staging/csr/csr_framework_ext.h deleted file mode 100644 index 6d26ac6173b0..000000000000 --- a/drivers/staging/csr/csr_framework_ext.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef CSR_FRAMEWORK_EXT_H__ -#define CSR_FRAMEWORK_EXT_H__ -/***************************************************************************** - - (c) Cambridge Silicon Radio Limited 2010 - All rights reserved and confidential information of CSR - - Refer to LICENSE.txt included with this source for details - on the license terms. - -*****************************************************************************/ - -#include "csr_result.h" -#include "csr_framework_ext_types.h" - -/* Result codes */ -#define CSR_FE_RESULT_NO_MORE_EVENTS ((CsrResult) 0x0001) -#define CSR_FE_RESULT_INVALID_POINTER ((CsrResult) 0x0002) -#define CSR_FE_RESULT_INVALID_HANDLE ((CsrResult) 0x0003) -#define CSR_FE_RESULT_NO_MORE_MUTEXES ((CsrResult) 0x0004) -#define CSR_FE_RESULT_TIMEOUT ((CsrResult) 0x0005) -#define CSR_FE_RESULT_NO_MORE_THREADS ((CsrResult) 0x0006) - -/* Thread priorities */ -#define CSR_THREAD_PRIORITY_HIGHEST ((u16) 0) -#define CSR_THREAD_PRIORITY_HIGH ((u16) 1) -#define CSR_THREAD_PRIORITY_NORMAL ((u16) 2) -#define CSR_THREAD_PRIORITY_LOW ((u16) 3) -#define CSR_THREAD_PRIORITY_LOWEST ((u16) 4) - -#define CSR_EVENT_WAIT_INFINITE ((u16) 0xFFFF) - -void CsrThreadSleep(u16 sleepTimeInMs); - -#endif diff --git a/drivers/staging/csr/csr_framework_ext_types.h b/drivers/staging/csr/csr_framework_ext_types.h deleted file mode 100644 index 575598cf69b2..000000000000 --- a/drivers/staging/csr/csr_framework_ext_types.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef CSR_FRAMEWORK_EXT_TYPES_H__ -#define CSR_FRAMEWORK_EXT_TYPES_H__ -/***************************************************************************** - - (c) Cambridge Silicon Radio Limited 2010 - All rights reserved and confidential information of CSR - - Refer to LICENSE.txt included with this source for details - on the license terms. - -*****************************************************************************/ - -#ifdef __KERNEL__ -#include -#include -#else -#include -#endif - -#ifdef __KERNEL__ - -typedef struct semaphore CsrMutexHandle; - -#else /* __KERNEL __ */ - -typedef pthread_mutex_t CsrMutexHandle; - -#endif /* __KERNEL__ */ - -#endif diff --git a/drivers/staging/csr/csr_log.h b/drivers/staging/csr/csr_log.h deleted file mode 100644 index 982941043ddc..000000000000 --- a/drivers/staging/csr/csr_log.h +++ /dev/null @@ -1,223 +0,0 @@ -#ifndef CSR_LOG_H__ -#define CSR_LOG_H__ -/***************************************************************************** - - (c) Cambridge Silicon Radio Limited 2010 - All rights reserved and confidential information of CSR - - Refer to LICENSE.txt included with this source for details - on the license terms. - -*****************************************************************************/ - -#include "csr_sched.h" -#include "csr_prim_defs.h" -#include "csr_msgconv.h" - -/* - * Log filtering - */ - -/*----------------------------------------------------*/ -/* Filtering on environment specific log levels */ -/*----------------------------------------------------*/ -typedef u32 CsrLogLevelEnvironment; -#define CSR_LOG_LEVEL_ENVIRONMENT_OFF ((CsrLogLevelEnvironment) 0x00000000) /* No environment data/events are logged */ -#define CSR_LOG_LEVEL_ENVIRONMENT_BCI_ACL ((CsrLogLevelEnvironment) 0x00000001) /* BlueCore Channel Interface HCI Acl data are logged */ -#define CSR_LOG_LEVEL_ENVIRONMENT_BCI_HCI ((CsrLogLevelEnvironment) 0x00000002) /* BlueCore Channel Interface HCI Cmd/Evt data are logged */ -#define CSR_LOG_LEVEL_ENVIRONMENT_BCI_SCO ((CsrLogLevelEnvironment) 0x00000004) /* BlueCore Channel Interface HCI Sco data are logged */ -#define CSR_LOG_LEVEL_ENVIRONMENT_BCI_VENDOR ((CsrLogLevelEnvironment) 0x00000008) /* BlueCore Channel Interface HCI Vendor specific data are logged (This includes BCCMD, HQ, VM etc) */ -#define CSR_LOG_LEVEL_ENVIRONMENT_TRANSPORTS ((CsrLogLevelEnvironment) 0x00000010) /* Transport protocol data is logged (This includes transport protocols like BCSP, H4 etc.) */ -#define CSR_LOG_LEVEL_ENVIRONMENT_BGINT_REG ((CsrLogLevelEnvironment) 0x00000020) /* Background Interrupt registration events are logged */ -#define CSR_LOG_LEVEL_ENVIRONMENT_BGINT_UNREG ((CsrLogLevelEnvironment) 0x00000040) /* Background Interrupt unregistration events are logged */ -#define CSR_LOG_LEVEL_ENVIRONMENT_BGINT_SET ((CsrLogLevelEnvironment) 0x00000080) /* Background Interrupt set events are logged */ -#define CSR_LOG_LEVEL_ENVIRONMENT_BGINT_START ((CsrLogLevelEnvironment) 0x00000100) /* Background Interrupt start events are logged */ -#define CSR_LOG_LEVEL_ENVIRONMENT_BGINT_DONE ((CsrLogLevelEnvironment) 0x00000200) /* Background Interrupt done events are logged */ -#define CSR_LOG_LEVEL_ENVIRONMENT_PROTO ((CsrLogLevelEnvironment) 0x00000400) /* Transport protocol events are logged */ -#define CSR_LOG_LEVEL_ENVIRONMENT_PROTO_LOC ((CsrLogLevelEnvironment) 0x00000800) /* The Location where the transport protocol event occurred are logged NB: This is a supplement to CSR_LOG_LEVEL_ENVIRONMENT_PROTO, it has no effect without it */ -/* The bit masks between here are reserved for future usage */ -#define CSR_LOG_LEVEL_ENVIRONMENT_ALL ((CsrLogLevelEnvironment) 0xFFFFFFFF) /* All possible environment data/events are logged WARNING: By using this define the application also accepts future possible environment data/events in the logs */ - -/*----------------------------------------------------*/ -/* Filtering on task specific log levels */ -/*----------------------------------------------------*/ -typedef u32 CsrLogLevelTask; -#define CSR_LOG_LEVEL_TASK_OFF ((CsrLogLevelTask) 0x00000000) /* No events are logged for this task */ -#define CSR_LOG_LEVEL_TASK_TEXT ((CsrLogLevelTask) 0x00000001) /* Text strings printed by a task are logged NB: This bit does not affect the CSR_LOG_TEXT_LEVEL interface. This has to be configured separately */ -#define CSR_LOG_LEVEL_TASK_TEXT_LOC ((CsrLogLevelTask) 0x00000002) /* The locaction where the text string call occurred are logged. NB: This is a supplement to CSR_LOG_LEVEL_TASK_TEXT, it has no effect without it */ -#define CSR_LOG_LEVEL_TASK_STATE ((CsrLogLevelTask) 0x00000004) /* FSM state transitions in a task are logged */ -#define CSR_LOG_LEVEL_TASK_STATE_NAME ((CsrLogLevelTask) 0x00000008) /* The name of each state in a FSM state transition are logged. NB: This is a supplement to CSR_LOG_LEVEL_TASK_STATE, it has no effect without it */ -#define CSR_LOG_LEVEL_TASK_STATE_LOC ((CsrLogLevelTask) 0x00000010) /* The location where the FSM state transition occurred are logged. NB: This is a supplement to CSR_LOG_LEVEL_TASK_STATE, it has no effect without it */ -#define CSR_LOG_LEVEL_TASK_TASK_SWITCH ((CsrLogLevelTask) 0x00000020) /* Activation and deactiation of a task are logged */ -#define CSR_LOG_LEVEL_TASK_MESSAGE_PUT ((CsrLogLevelTask) 0x00000080) /* Message put operations are logged */ -#define CSR_LOG_LEVEL_TASK_MESSAGE_PUT_LOC ((CsrLogLevelTask) 0x00000100) /* The location where a message was sent are logged. NB: This is a supplement to CSR_LOG_LEVEL_TASK_MESSAGE_PUT, it has no effect without it */ -#define CSR_LOG_LEVEL_TASK_MESSAGE_GET ((CsrLogLevelTask) 0x00000200) /* Message get operations are logged */ -#define CSR_LOG_LEVEL_TASK_MESSAGE_QUEUE_PUSH ((CsrLogLevelTask) 0x00000400) /* Message push operations are logged */ -#define CSR_LOG_LEVEL_TASK_MESSAGE_QUEUE_POP ((CsrLogLevelTask) 0x00000800) /* Message pop operations are logged */ -#define CSR_LOG_LEVEL_TASK_PRIM_ONLY_TYPE ((CsrLogLevelTask) 0x00001000) /* Only the type of primitives in messages are logged. By default the entire primitive is serialized and logged */ -#define CSR_LOG_LEVEL_TASK_PRIM_APPLY_LIMIT ((CsrLogLevelTask) 0x00002000) /* An upper limit (defined by CSR_LOG_PRIM_SIZE_UPPER_LIMIT) is applied to how much of a primitive in a message are logged. NB: This limit is only applied if CSR_LOG_LEVEL_TASK_PRIM_ONLY_TYPE is _not_ defined */ -#define CSR_LOG_LEVEL_TASK_TIMER_IN ((CsrLogLevelTask) 0x00004000) /* TimedEventIn events are logged */ -#define CSR_LOG_LEVEL_TASK_TIMER_IN_LOC ((CsrLogLevelTask) 0x00008000) /* The location where a timer was started are logged. NB: This is a supplement to CSR_LOG_LEVEL_TASK_TIMER_IN, it has no effect without it */ -#define CSR_LOG_LEVEL_TASK_TIMER_CANCEL ((CsrLogLevelTask) 0x00010000) /* TimedEventCancel events are logged */ -#define CSR_LOG_LEVEL_TASK_TIMER_CANCEL_LOC ((CsrLogLevelTask) 0x00020000) /* The location where a timer was cancelled are logged. NB: This is a supplement to CSR_LOG_LEVEL_TASK_TIMER_CANCEL, it has no effect without it */ -#define CSR_LOG_LEVEL_TASK_TIMER_FIRE ((CsrLogLevelTask) 0x00040000) /* TimedEventFire events are logged */ -#define CSR_LOG_LEVEL_TASK_TIMER_DONE ((CsrLogLevelTask) 0x00080000) /* TimedEventDone events are logged */ -/* The bit masks between here are reserved for future usage */ -#define CSR_LOG_LEVEL_TASK_ALL ((CsrLogLevelTask) 0xFFFFFFFF & ~(CSR_LOG_LEVEL_TASK_PRIM_ONLY_TYPE | CSR_LOG_LEVEL_TASK_PRIM_APPLY_LIMIT)) /* All info possible to log for a task are logged. WARNING: By using this define the application also accepts future possible task data/events in the logs */ - -u8 CsrLogEnvironmentIsFiltered(CsrLogLevelEnvironment level); -CsrLogLevelTask CsrLogTaskFilterGet(CsrSchedQid taskId); -u8 CsrLogTaskIsFiltered(CsrSchedQid taskId, CsrLogLevelTask level); - -/* - * Logging stuff - */ -#define CSR_LOG_STRINGIFY_REAL(a) (#a) -#define CSR_LOG_STRINGIFY(a) CSR_LOG_STRINGIFY_REAL(a) - -typedef struct { - u16 primitiveType; - const char *primitiveName; - CsrMsgConvMsgEntry *messageConv; /* Private - do not use */ -} CsrLogPrimitiveInformation; - -typedef struct { - const char *techVer; - u32 primitiveInfoCount; - CsrLogPrimitiveInformation *primitiveInfo; -} CsrLogTechInformation; - -/*---------------------------------*/ -/* Tech logging */ -/*---------------------------------*/ -typedef u8 bitmask8_t; -typedef u16 bitmask16_t; -typedef u32 bitmask32_t; - -#ifdef CSR_LOG_ENABLE -#ifdef CSR_LOG_INCLUDE_FILE_NAME_AND_LINE_NUMBER -/* DEPRECATED - replaced by csr_log_text.h */ -#define CSR_LOG_TEXT(text) \ - do { \ - if (!CsrLogTaskIsFiltered(CsrSchedTaskQueueGet(), CSR_LOG_LEVEL_TASK_TEXT)) { \ - CsrLogTaskText(text, __LINE__, __FILE__); \ - } \ - } while (0) -#else -/* DEPRECATED - replaced by csr_log_text.h */ -#define CSR_LOG_TEXT(text) \ - do { \ - if (!CsrLogTaskIsFiltered(CsrSchedTaskQueueGet(), CSR_LOG_LEVEL_TASK_TEXT)) { \ - CsrLogTaskText(text, 0, NULL); \ - } \ - } while (0) -#endif -#else -#define CSR_LOG_TEXT(text) -#endif - -/* DEPRECATED - replaced by csr_log_text.h */ -void CsrLogTaskText(const char *text, - u32 line, - const char *file); - -#define CSR_LOG_STATE_TRANSITION_MASK_FSM_NAME (0x001) -#define CSR_LOG_STATE_TRANSITION_MASK_NEXT_STATE (0x002) -#define CSR_LOG_STATE_TRANSITION_MASK_NEXT_STATE_STR (0x004) -#define CSR_LOG_STATE_TRANSITION_MASK_PREV_STATE (0x008) -#define CSR_LOG_STATE_TRANSITION_MASK_PREV_STATE_STR (0x010) -#define CSR_LOG_STATE_TRANSITION_MASK_EVENT (0x020) -#define CSR_LOG_STATE_TRANSITION_MASK_EVENT_STR (0x040) - -/* DEPRECATED - replaced by csr_log_text.h */ -void CsrLogStateTransition(bitmask16_t mask, - u32 identifier, - const char *fsm_name, - u32 prev_state, - const char *prev_state_str, - u32 in_event, - const char *in_event_str, - u32 next_state, - const char *next_state_str, - u32 line, - const char *file); - -/*---------------------------------*/ -/* BSP logging */ -/*---------------------------------*/ -void CsrLogSchedInit(u8 thread_id); -void CsrLogSchedDeinit(u8 thread_id); - -void CsrLogSchedStart(u8 thread_id); -void CsrLogSchedStop(u8 thread_id); - -void CsrLogInitTask(u8 thread_id, CsrSchedQid tskid, const char *tskName); -void CsrLogDeinitTask(u16 task_id); - -void CsrLogActivate(CsrSchedQid tskid); -void CsrLogDeactivate(CsrSchedQid tskid); - -#define SYNERGY_SERIALIZER_TYPE_DUMP (0x000) -#define SYNERGY_SERIALIZER_TYPE_SER (0x001) - -void CsrLogMessagePut(u32 line, - const char *file, - CsrSchedQid src_task_id, - CsrSchedQid dst_taskid, - CsrSchedMsgId msg_id, - u16 prim_type, - const void *msg); - -void CsrLogMessageGet(CsrSchedQid src_task_id, - CsrSchedQid dst_taskid, - u8 get_res, - CsrSchedMsgId msg_id, - u16 prim_type, - const void *msg); - -void CsrLogTimedEventIn(u32 line, - const char *file, - CsrSchedQid task_id, - CsrSchedTid tid, - u32 requested_delay, - u16 fniarg, - const void *fnvarg); - -void CsrLogTimedEventFire(CsrSchedQid task_id, - CsrSchedTid tid); - -void CsrLogTimedEventDone(CsrSchedQid task_id, - CsrSchedTid tid); - -void CsrLogTimedEventCancel(u32 line, - const char *file, - CsrSchedQid task_id, - CsrSchedTid tid, - u8 cancel_res); - -void CsrLogBgintRegister(u8 thread_id, - CsrSchedBgint irq, - const char *callback, - const void *ptr); -void CsrLogBgintUnregister(CsrSchedBgint irq); -void CsrLogBgintSet(CsrSchedBgint irq); -void CsrLogBgintServiceStart(CsrSchedBgint irq); -void CsrLogBgintServiceDone(CsrSchedBgint irq); - -void CsrLogExceptionStateEvent(u16 prim_type, - CsrPrim msg_type, - u16 state, - u32 line, - const char *file); -void CsrLogExceptionGeneral(u16 prim_type, - u16 state, - const char *text, - u32 line, - const char *file); -void CsrLogExceptionWarning(u16 prim_type, - u16 state, - const char *text, - u32 line, - const char *file); - -#endif diff --git a/drivers/staging/csr/csr_log_configure.h b/drivers/staging/csr/csr_log_configure.h deleted file mode 100644 index 283647cf9702..000000000000 --- a/drivers/staging/csr/csr_log_configure.h +++ /dev/null @@ -1,39 +0,0 @@ -#ifndef CSR_LOG_CONFIGURE_H__ -#define CSR_LOG_CONFIGURE_H__ -/***************************************************************************** - - (c) Cambridge Silicon Radio Limited 2010 - All rights reserved and confidential information of CSR - - Refer to LICENSE.txt included with this source for details - on the license terms. - - *****************************************************************************/ - -#include "csr_log.h" - -/*--------------------------------------------*/ -/* Filtering on log text warning levels */ -/*--------------------------------------------*/ -typedef u32 CsrLogLevelText; -#define CSR_LOG_LEVEL_TEXT_OFF ((CsrLogLevelText) 0x0000) - -#define CSR_LOG_LEVEL_TEXT_CRITICAL ((CsrLogLevelText) 0x0001) -#define CSR_LOG_LEVEL_TEXT_ERROR ((CsrLogLevelText) 0x0002) -#define CSR_LOG_LEVEL_TEXT_WARNING ((CsrLogLevelText) 0x0004) -#define CSR_LOG_LEVEL_TEXT_INFO ((CsrLogLevelText) 0x0008) -#define CSR_LOG_LEVEL_TEXT_DEBUG ((CsrLogLevelText) 0x0010) - -#define CSR_LOG_LEVEL_TEXT_ALL ((CsrLogLevelText) 0xFFFF) - -/* The log text interface is used by both scheduler tasks and components outside the scheduler context. - * Therefore a CsrLogTextTaskId is introduced. It is effectively considered as two u16's. The lower - * 16 bits corresponds one2one with the scheduler queueId's (CsrSchedQid) and as such these bits can not be used - * by components outside scheduler tasks. The upper 16 bits are allocated for use of components outside the - * scheduler like drivers etc. Components in this range is defined independently by each technology. To avoid - * clashes the technologies are only allowed to assign values within the same restrictive range as allies to - * primitive identifiers. eg. for the framework components outside the scheduler is only allowed to assign - * taskId's in the range 0x0600xxxx to 0x06FFxxxx. And so on for other technologies. */ -typedef u32 CsrLogTextTaskId; - -#endif diff --git a/drivers/staging/csr/csr_log_text.h b/drivers/staging/csr/csr_log_text.h deleted file mode 100644 index cfcf64aa6225..000000000000 --- a/drivers/staging/csr/csr_log_text.h +++ /dev/null @@ -1,124 +0,0 @@ -#ifndef CSR_LOG_TEXT_H__ -#define CSR_LOG_TEXT_H__ -/***************************************************************************** - - (c) Cambridge Silicon Radio Limited 2010 - All rights reserved and confidential information of CSR - - Refer to LICENSE.txt included with this source for details - on the license terms. - -*****************************************************************************/ - -#include "csr_log_configure.h" - -typedef struct CsrLogSubOrigin -{ - u16 subOriginNumber; /* Id of the given SubOrigin */ - const char *subOriginName; /* Prefix Text for this SubOrigin */ -} CsrLogSubOrigin; - -/* Register a task which is going to use the CSR_LOG_TEXT_XXX interface */ -#ifdef CSR_LOG_ENABLE -void CsrLogTextRegister(CsrLogTextTaskId taskId, const char *taskName, u16 subOriginsLength, const CsrLogSubOrigin *subOrigins); -#else -#define CsrLogTextRegister(taskId, taskName, subOriginsLength, subOrigins) -#endif - -/* CRITICAL: Conditions that are threatening to the integrity/stability of the - system as a whole. */ -#if defined(CSR_LOG_ENABLE) && !defined(CSR_LOG_LEVEL_TEXT_CRITICAL_DISABLE) -void CsrLogTextCritical(CsrLogTextTaskId taskId, u16 subOrigin, const char *formatString, ...); -void CsrLogTextBufferCritical(CsrLogTextTaskId taskId, u16 subOrigin, size_t bufferLength, const void *buffer, const char *formatString, ...); -#define CSR_LOG_TEXT_CRITICAL(taskId_subOrigin_formatString_varargs) CsrLogTextCritical taskId_subOrigin_formatString_varargs -#define CSR_LOG_TEXT_CONDITIONAL_CRITICAL(condition, logtextargs) {if (condition) {CSR_LOG_TEXT_CRITICAL(logtextargs);}} -#define CSR_LOG_TEXT_BUFFER_CRITICAL(taskId_subOrigin_length_buffer_formatString_varargs) CsrLogTextBufferCritical taskId_subOrigin_length_buffer_formatString_varargs -#define CSR_LOG_TEXT_BUFFER_CONDITIONAL_CRITICAL(condition, logtextbufferargs) {if (condition) {CSR_LOG_TEXT_BUFFER_CRITICAL(logtextbufferargs);}} -#else -#define CSR_LOG_TEXT_CRITICAL(taskId_subOrigin_formatString_varargs) -#define CSR_LOG_TEXT_CONDITIONAL_CRITICAL(condition, logtextargs) -#define CSR_LOG_TEXT_BUFFER_CRITICAL(taskId_subOrigin_length_buffer_formatString_varargs) -#define CSR_LOG_TEXT_BUFFER_CONDITIONAL_CRITICAL(condition, logtextbufferargs) -#endif - -/* ERROR: Malfunction of a component rendering it unable to operate correctly, - causing lack of functionality but not loss of system integrity/stability. */ -#if defined(CSR_LOG_ENABLE) && !defined(CSR_LOG_LEVEL_TEXT_ERROR_DISABLE) -void CsrLogTextError(CsrLogTextTaskId taskId, u16 subOrigin, const char *formatString, ...); -void CsrLogTextBufferError(CsrLogTextTaskId taskId, u16 subOrigin, size_t bufferLength, const void *buffer, const char *formatString, ...); -#define CSR_LOG_TEXT_ERROR(taskId_subOrigin_formatString_varargs) CsrLogTextError taskId_subOrigin_formatString_varargs -#define CSR_LOG_TEXT_CONDITIONAL_ERROR(condition, logtextargs) {if (condition) {CSR_LOG_TEXT_ERROR(logtextargs);}} -#define CSR_LOG_TEXT_BUFFER_ERROR(taskId_subOrigin_length_buffer_formatString_varargs) CsrLogTextBufferError taskId_subOrigin_length_buffer_formatString_varargs -#define CSR_LOG_TEXT_BUFFER_CONDITIONAL_ERROR(condition, logtextbufferargs) {if (condition) {CSR_LOG_TEXT_BUFFER_ERROR(logtextbufferargs);}} -#else -#define CSR_LOG_TEXT_ERROR(taskId_subOrigin_formatString_varargs) -#define CSR_LOG_TEXT_CONDITIONAL_ERROR(condition, logtextargs) -#define CSR_LOG_TEXT_BUFFER_ERROR(taskId_subOrigin_length_buffer_formatString_varargs) -#define CSR_LOG_TEXT_BUFFER_CONDITIONAL_ERROR(condition, logtextbufferargs) -#endif - -/* WARNING: Conditions that are unexpected and indicative of possible problems - or violations of specifications, where the result of such deviations does not - lead to malfunction of the component. */ -#if defined(CSR_LOG_ENABLE) && !defined(CSR_LOG_LEVEL_TEXT_WARNING_DISABLE) -void CsrLogTextWarning(CsrLogTextTaskId taskId, u16 subOrigin, const char *formatString, ...); -void CsrLogTextBufferWarning(CsrLogTextTaskId taskId, u16 subOrigin, size_t bufferLength, const void *buffer, const char *formatString, ...); -#define CSR_LOG_TEXT_WARNING(taskId_subOrigin_formatString_varargs) CsrLogTextWarning taskId_subOrigin_formatString_varargs -#define CSR_LOG_TEXT_CONDITIONAL_WARNING(condition, logtextargs) {if (condition) {CSR_LOG_TEXT_WARNING(logtextargs);}} -#define CSR_LOG_TEXT_BUFFER_WARNING(taskId_subOrigin_length_buffer_formatString_varargs) CsrLogTextBufferWarning taskId_subOrigin_length_buffer_formatString_varargs -#define CSR_LOG_TEXT_BUFFER_CONDITIONAL_WARNING(condition, logtextbufferargs) {if (condition) {CSR_LOG_TEXT_BUFFER_WARNING(logtextbufferargs);}} -#else -#define CSR_LOG_TEXT_WARNING(taskId_subOrigin_formatString_varargs) -#define CSR_LOG_TEXT_CONDITIONAL_WARNING(condition, logtextargs) -#define CSR_LOG_TEXT_BUFFER_WARNING(taskId_subOrigin_length_buffer_formatString_varargs) -#define CSR_LOG_TEXT_BUFFER_CONDITIONAL_WARNING(condition, logtextbufferargs) -#endif - -/* INFO: Important events that may aid in determining the conditions under which - the more severe conditions are encountered. */ -#if defined(CSR_LOG_ENABLE) && !defined(CSR_LOG_LEVEL_TEXT_INFO_DISABLE) -void CsrLogTextInfo(CsrLogTextTaskId taskId, u16 subOrigin, const char *formatString, ...); -void CsrLogTextBufferInfo(CsrLogTextTaskId taskId, u16 subOrigin, size_t bufferLength, const void *buffer, const char *formatString, ...); -#define CSR_LOG_TEXT_INFO(taskId_subOrigin_formatString_varargs) CsrLogTextInfo taskId_subOrigin_formatString_varargs -#define CSR_LOG_TEXT_CONDITIONAL_INFO(condition, logtextargs) {if (condition) {CSR_LOG_TEXT_INFO(logtextargs);}} -#define CSR_LOG_TEXT_BUFFER_INFO(taskId_subOrigin_length_buffer_formatString_varargs) CsrLogTextBufferInfo taskId_subOrigin_length_buffer_formatString_varargs -#define CSR_LOG_TEXT_BUFFER_CONDITIONAL_INFO(condition, logtextbufferargs) {if (condition) {CSR_LOG_TEXT_BUFFER_INFO(logtextbufferargs);}} -#else -#define CSR_LOG_TEXT_INFO(taskId_subOrigin_formatString_varargs) -#define CSR_LOG_TEXT_CONDITIONAL_INFO(condition, logtextargs) -#define CSR_LOG_TEXT_BUFFER_INFO(taskId_subOrigin_length_buffer_formatString_varargs) -#define CSR_LOG_TEXT_BUFFER_CONDITIONAL_INFO(condition, logtextbufferargs) -#endif - -/* DEBUG: Similar to INFO, but dedicated to events that occur more frequently. */ -#if defined(CSR_LOG_ENABLE) && !defined(CSR_LOG_LEVEL_TEXT_DEBUG_DISABLE) -void CsrLogTextDebug(CsrLogTextTaskId taskId, u16 subOrigin, const char *formatString, ...); -void CsrLogTextBufferDebug(CsrLogTextTaskId taskId, u16 subOrigin, size_t bufferLength, const void *buffer, const char *formatString, ...); -#define CSR_LOG_TEXT_DEBUG(taskId_subOrigin_formatString_varargs) CsrLogTextDebug taskId_subOrigin_formatString_varargs -#define CSR_LOG_TEXT_CONDITIONAL_DEBUG(condition, logtextargs) {if (condition) {CSR_LOG_TEXT_DEBUG(logtextargs);}} -#define CSR_LOG_TEXT_BUFFER_DEBUG(taskId_subOrigin_length_buffer_formatString_varargs) CsrLogTextBufferDebug taskId_subOrigin_length_buffer_formatString_varargs -#define CSR_LOG_TEXT_BUFFER_CONDITIONAL_DEBUG(condition, logtextbufferargs) {if (condition) {CSR_LOG_TEXT_BUFFER_DEBUG(logtextbufferargs);}} -#else -#define CSR_LOG_TEXT_DEBUG(taskId_subOrigin_formatString_varargs) -#define CSR_LOG_TEXT_CONDITIONAL_DEBUG(condition, logtextargs) -#define CSR_LOG_TEXT_BUFFER_DEBUG(taskId_subOrigin_length_buffer_formatString_varargs) -#define CSR_LOG_TEXT_BUFFER_CONDITIONAL_DEBUG(condition, logtextbufferargs) -#endif - -/* CSR_LOG_TEXT_ASSERT (CRITICAL) */ -#ifdef CSR_LOG_ENABLE -#define CSR_LOG_TEXT_ASSERT(origin, suborigin, condition) \ - {if (!(condition)) {CSR_LOG_TEXT_CRITICAL((origin, suborigin, "Assertion \"%s\" failed at %s:%u", #condition, __FILE__, __LINE__));}} -#else -#define CSR_LOG_TEXT_ASSERT(origin, suborigin, condition) -#endif - -/* CSR_LOG_TEXT_UNHANDLED_PRIM (CRITICAL) */ -#ifdef CSR_LOG_ENABLE -#define CSR_LOG_TEXT_UNHANDLED_PRIMITIVE(origin, suborigin, primClass, primType) \ - CSR_LOG_TEXT_CRITICAL((origin, suborigin, "Unhandled primitive 0x%04X:0x%04X at %s:%u", primClass, primType, __FILE__, __LINE__)) -#else -#define CSR_LOG_TEXT_UNHANDLED_PRIMITIVE(origin, suborigin, primClass, primType) -#endif - -#endif diff --git a/drivers/staging/csr/csr_macro.h b/drivers/staging/csr/csr_macro.h deleted file mode 100644 index c47f1d91b6fa..000000000000 --- a/drivers/staging/csr/csr_macro.h +++ /dev/null @@ -1,39 +0,0 @@ -#ifndef CSR_MACRO_H__ -#define CSR_MACRO_H__ -/***************************************************************************** - - (c) Cambridge Silicon Radio Limited 2010 - All rights reserved and confidential information of CSR - - Refer to LICENSE.txt included with this source for details - on the license terms. - -*****************************************************************************/ - -#include - -#define FALSE (0) -#define TRUE (1) - -/*------------------------------------------------------------------*/ -/* Endian conversion */ -/*------------------------------------------------------------------*/ -#define CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr) (((u16) ((u8 *) (ptr))[0]) | ((u16) ((u8 *) (ptr))[1]) << 8) -#define CSR_GET_UINT32_FROM_LITTLE_ENDIAN(ptr) (((u32) ((u8 *) (ptr))[0]) | ((u32) ((u8 *) (ptr))[1]) << 8 | \ - ((u32) ((u8 *) (ptr))[2]) << 16 | ((u32) ((u8 *) (ptr))[3]) << 24) -#define CSR_COPY_UINT16_TO_LITTLE_ENDIAN(uint, ptr) ((u8 *) (ptr))[0] = ((u8) ((uint) & 0x00FF)); \ - ((u8 *) (ptr))[1] = ((u8) ((uint) >> 8)) -#define CSR_COPY_UINT32_TO_LITTLE_ENDIAN(uint, ptr) ((u8 *) (ptr))[0] = ((u8) ((uint) & 0x000000FF)); \ - ((u8 *) (ptr))[1] = ((u8) (((uint) >> 8) & 0x000000FF)); \ - ((u8 *) (ptr))[2] = ((u8) (((uint) >> 16) & 0x000000FF)); \ - ((u8 *) (ptr))[3] = ((u8) (((uint) >> 24) & 0x000000FF)) - -/*------------------------------------------------------------------*/ -/* Misc */ -/*------------------------------------------------------------------*/ -/* Use this macro on unused local variables that cannot be removed (such as - unused function parameters). This will quell warnings from certain compilers - and static code analysis tools like Lint and Valgrind. */ -#define CSR_UNUSED(x) ((void) (x)) - -#endif diff --git a/drivers/staging/csr/csr_msg_transport.h b/drivers/staging/csr/csr_msg_transport.h deleted file mode 100644 index 8d88e7836567..000000000000 --- a/drivers/staging/csr/csr_msg_transport.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef CSR_MSG_TRANSPORT_H__ -#define CSR_MSG_TRANSPORT_H__ -/***************************************************************************** - - (c) Cambridge Silicon Radio Limited 2010 - All rights reserved and confidential information of CSR - - Refer to LICENSE.txt included with this source for details - on the license terms. - -*****************************************************************************/ - -#ifndef CsrMsgTransport -#define CsrMsgTransport CsrSchedMessagePut -#endif - -#endif /* CSR_MSG_TRANSPORT */ diff --git a/drivers/staging/csr/csr_msgconv.c b/drivers/staging/csr/csr_msgconv.c deleted file mode 100644 index db5e845e60f5..000000000000 --- a/drivers/staging/csr/csr_msgconv.c +++ /dev/null @@ -1,291 +0,0 @@ -/***************************************************************************** - - (c) Cambridge Silicon Radio Limited 2010 - All rights reserved and confidential information of CSR - - Refer to LICENSE.txt included with this source for details - on the license terms. - -*****************************************************************************/ - -#include -#include -#include -#include "csr_sched.h" -#include "csr_msgconv.h" -#include "csr_macro.h" - -static CsrMsgConvEntry *converter; - -CsrMsgConvPrimEntry *CsrMsgConvFind(u16 primType) -{ - CsrMsgConvPrimEntry *ptr = NULL; - - if (converter) - { - ptr = converter->profile_converters; - while (ptr) - { - if (ptr->primType == primType) - { - break; - } - else - { - ptr = ptr->next; - } - } - } - - return ptr; -} - -static const CsrMsgConvMsgEntry *find_msg_converter(CsrMsgConvPrimEntry *ptr, u16 msgType) -{ - const CsrMsgConvMsgEntry *cv = ptr->conv; - if (ptr->lookupFunc) - { - return (const CsrMsgConvMsgEntry *) ptr->lookupFunc((CsrMsgConvMsgEntry *) cv, msgType); - } - - while (cv) - { - if (cv->serFunc == NULL) - { - /* We've reached the end of the chain */ - cv = NULL; - break; - } - - if (cv->msgType == msgType) - { - break; - } - else - { - cv++; - } - } - - return cv; -} - -static void *deserialize_data(u16 primType, - size_t length, - u8 *data) -{ - CsrMsgConvPrimEntry *ptr; - u8 *ret; - - ptr = CsrMsgConvFind(primType); - - if (ptr) - { - const CsrMsgConvMsgEntry *cv; - u16 msgId = 0; - size_t offset = 0; - CsrUint16Des(&msgId, data, &offset); - - cv = find_msg_converter(ptr, msgId); - if (cv) - { - ret = cv->deserFunc(data, length); - } - else - { - ret = NULL; - } - } - else - { - ret = NULL; - } - - return ret; -} - -static size_t sizeof_message(u16 primType, void *msg) -{ - CsrMsgConvPrimEntry *ptr = CsrMsgConvFind(primType); - size_t ret; - - if (ptr) - { - const CsrMsgConvMsgEntry *cv; - u16 msgId = *(u16 *) msg; - - cv = find_msg_converter(ptr, msgId); - if (cv) - { - ret = cv->sizeofFunc(msg); - } - else - { - ret = 0; - } - } - else - { - ret = 0; - } - - return ret; -} - -static u8 free_message(u16 primType, u8 *data) -{ - CsrMsgConvPrimEntry *ptr; - u8 ret; - - ptr = CsrMsgConvFind(primType); - - if (ptr) - { - const CsrMsgConvMsgEntry *cv; - u16 msgId = *(u16 *) data; - - cv = find_msg_converter(ptr, msgId); - if (cv) - { - cv->freeFunc(data); - ret = TRUE; - } - else - { - ret = FALSE; - } - } - else - { - ret = FALSE; - } - - return ret; -} - -static u8 *serialize_message(u16 primType, - void *msg, - size_t *length, - u8 *buffer) -{ - CsrMsgConvPrimEntry *ptr; - u8 *ret; - - ptr = CsrMsgConvFind(primType); - - *length = 0; - - if (ptr) - { - const CsrMsgConvMsgEntry *cv; - - cv = find_msg_converter(ptr, *(u16 *) msg); - if (cv) - { - ret = cv->serFunc(buffer, length, msg); - } - else - { - ret = NULL; - } - } - else - { - ret = NULL; - } - - return ret; -} - -size_t CsrMsgConvSizeof(u16 primType, void *msg) -{ - return sizeof_message(primType, msg); -} - -u8 *CsrMsgConvSerialize(u8 *buffer, size_t maxBufferOffset, size_t *offset, u16 primType, void *msg) -{ - if (converter) - { - size_t serializedLength; - u8 *bufSerialized; - u8 *bufOffset = &buffer[*offset]; - bufSerialized = converter->serialize_message(primType, msg, &serializedLength, bufOffset); - *offset += serializedLength; - return bufSerialized; - } - else - { - return NULL; - } -} - -/* Insert profile converter at head of converter list. */ -void CsrMsgConvInsert(u16 primType, const CsrMsgConvMsgEntry *ce) -{ - CsrMsgConvPrimEntry *pc; - pc = CsrMsgConvFind(primType); - - if (pc) - { - /* Already registered. Do nothing */ - } - else - { - pc = kmalloc(sizeof(*pc), GFP_KERNEL); - pc->primType = primType; - pc->conv = ce; - pc->lookupFunc = NULL; - pc->next = converter->profile_converters; - converter->profile_converters = pc; - } -} -EXPORT_SYMBOL_GPL(CsrMsgConvInsert); - -CsrMsgConvMsgEntry *CsrMsgConvFindEntry(u16 primType, u16 msgType) -{ - CsrMsgConvPrimEntry *ptr = CsrMsgConvFind(primType); - if (ptr) - { - return (CsrMsgConvMsgEntry *) find_msg_converter(ptr, msgType); - } - return NULL; -} -EXPORT_SYMBOL_GPL(CsrMsgConvFindEntry); - -CsrMsgConvMsgEntry *CsrMsgConvFindEntryByMsg(u16 primType, const void *msg) -{ - CsrMsgConvPrimEntry *ptr = CsrMsgConvFind(primType); - if (ptr && msg) - { - u16 msgType = *((u16 *) msg); - return (CsrMsgConvMsgEntry *) find_msg_converter(ptr, msgType); - } - return NULL; -} - -void CsrMsgConvCustomLookupRegister(u16 primType, CsrMsgCustomLookupFunc *lookupFunc) -{ - CsrMsgConvPrimEntry *ptr = CsrMsgConvFind(primType); - if (ptr) - { - ptr->lookupFunc = lookupFunc; - } -} -EXPORT_SYMBOL_GPL(CsrMsgConvCustomLookupRegister); - -CsrMsgConvEntry *CsrMsgConvInit(void) -{ - if (!converter) - { - converter = kmalloc(sizeof(CsrMsgConvEntry), GFP_KERNEL); - - converter->profile_converters = NULL; - converter->free_message = free_message; - converter->sizeof_message = sizeof_message; - converter->serialize_message = serialize_message; - converter->deserialize_data = deserialize_data; - } - - return converter; -} -EXPORT_SYMBOL_GPL(CsrMsgConvInit); diff --git a/drivers/staging/csr/csr_msgconv.h b/drivers/staging/csr/csr_msgconv.h deleted file mode 100644 index 7e4dd388ae37..000000000000 --- a/drivers/staging/csr/csr_msgconv.h +++ /dev/null @@ -1,78 +0,0 @@ -#ifndef CSR_MSGCONV_H__ -#define CSR_MSGCONV_H__ - -/***************************************************************************** - - (c) Cambridge Silicon Radio Limited 2010 - All rights reserved and confidential information of CSR - - Refer to LICENSE.txt included with this source for details - on the license terms. - -*****************************************************************************/ - -#include -#include "csr_prim_defs.h" -#include "csr_sched.h" - -typedef size_t (CsrMsgSizeofFunc)(void *msg); -typedef u8 *(CsrMsgSerializeFunc)(u8 *buffer, size_t *length, void *msg); -typedef void (CsrMsgFreeFunc)(void *msg); -typedef void *(CsrMsgDeserializeFunc)(u8 *buffer, size_t length); - -/* Converter entry for one message type */ -typedef struct CsrMsgConvMsgEntry -{ - u16 msgType; - CsrMsgSizeofFunc *sizeofFunc; - CsrMsgSerializeFunc *serFunc; - CsrMsgDeserializeFunc *deserFunc; - CsrMsgFreeFunc *freeFunc; -} CsrMsgConvMsgEntry; - -/* Optional lookup function */ -typedef CsrMsgConvMsgEntry *(CsrMsgCustomLookupFunc)(CsrMsgConvMsgEntry *ce, u16 msgType); - -/* All converter entries for one specific primitive */ -typedef struct CsrMsgConvPrimEntry -{ - u16 primType; - const CsrMsgConvMsgEntry *conv; - CsrMsgCustomLookupFunc *lookupFunc; - struct CsrMsgConvPrimEntry *next; -} CsrMsgConvPrimEntry; - -typedef struct -{ - CsrMsgConvPrimEntry *profile_converters; - void *(*deserialize_data)(u16 primType, size_t length, u8 * data); - u8 (*free_message)(u16 primType, u8 *data); - size_t (*sizeof_message)(u16 primType, void *msg); - u8 *(*serialize_message)(u16 primType, void *msg, - size_t * length, - u8 * buffer); -} CsrMsgConvEntry; - -size_t CsrMsgConvSizeof(u16 primType, void *msg); -u8 *CsrMsgConvSerialize(u8 *buffer, size_t maxBufferOffset, size_t *offset, u16 primType, void *msg); -void CsrMsgConvCustomLookupRegister(u16 primType, CsrMsgCustomLookupFunc *lookupFunc); -void CsrMsgConvInsert(u16 primType, const CsrMsgConvMsgEntry *ce); -CsrMsgConvPrimEntry *CsrMsgConvFind(u16 primType); -CsrMsgConvMsgEntry *CsrMsgConvFindEntry(u16 primType, u16 msgType); -CsrMsgConvMsgEntry *CsrMsgConvFindEntryByMsg(u16 primType, const void *msg); -CsrMsgConvEntry *CsrMsgConvInit(void); - -/* Prototypes for primitive type serializers */ -void CsrUint8Ser(u8 *buffer, size_t *offset, u8 value); -void CsrUint16Ser(u8 *buffer, size_t *offset, u16 value); -void CsrUint32Ser(u8 *buffer, size_t *offset, u32 value); -void CsrMemCpySer(u8 *buffer, size_t *offset, const void *value, size_t length); -void CsrCharStringSer(u8 *buffer, size_t *offset, const char *value); - -void CsrUint8Des(u8 *value, u8 *buffer, size_t *offset); -void CsrUint16Des(u16 *value, u8 *buffer, size_t *offset); -void CsrUint32Des(u32 *value, u8 *buffer, size_t *offset); -void CsrMemCpyDes(void *value, u8 *buffer, size_t *offset, size_t length); -void CsrCharStringDes(char **value, u8 *buffer, size_t *offset); - -#endif diff --git a/drivers/staging/csr/csr_prim_defs.h b/drivers/staging/csr/csr_prim_defs.h deleted file mode 100644 index 81a1eaac30d9..000000000000 --- a/drivers/staging/csr/csr_prim_defs.h +++ /dev/null @@ -1,55 +0,0 @@ -#ifndef CSR_PRIM_DEFS_H__ -#define CSR_PRIM_DEFS_H__ -/***************************************************************************** - - (c) Cambridge Silicon Radio Limited 2010 - All rights reserved and confidential information of CSR - - Refer to LICENSE.txt included with this source for details - on the license terms. - -*****************************************************************************/ - -/************************************************************************************ - * Segmentation of primitives in upstream and downstream segment - ************************************************************************************/ -typedef u16 CsrPrim; -#define CSR_PRIM_UPSTREAM ((CsrPrim) (0x8000)) - -/************************************************************************************ - * Primitive definitions for Synergy framework - ************************************************************************************/ -#define CSR_SYNERGY_EVENT_CLASS_BASE ((u16) (0x0600)) - -#define CSR_HCI_PRIM ((u16) (0x0000 | CSR_SYNERGY_EVENT_CLASS_BASE)) -#define CSR_BCCMD_PRIM ((u16) (0x0001 | CSR_SYNERGY_EVENT_CLASS_BASE)) -#define CSR_HQ_PRIM ((u16) (0x0002 | CSR_SYNERGY_EVENT_CLASS_BASE)) -#define CSR_VM_PRIM ((u16) (0x0003 | CSR_SYNERGY_EVENT_CLASS_BASE)) -#define CSR_TM_BLUECORE_PRIM ((u16) (0x0004 | CSR_SYNERGY_EVENT_CLASS_BASE)) -#define CSR_FP_PRIM ((u16) (0x0005 | CSR_SYNERGY_EVENT_CLASS_BASE)) -#define CSR_IP_SOCKET_PRIM ((u16) (0x0006 | CSR_SYNERGY_EVENT_CLASS_BASE)) -#define CSR_IP_ETHER_PRIM ((u16) (0x0007 | CSR_SYNERGY_EVENT_CLASS_BASE)) -#define CSR_IP_IFCONFIG_PRIM ((u16) (0x0008 | CSR_SYNERGY_EVENT_CLASS_BASE)) -#define CSR_IP_INTERNAL_PRIM ((u16) (0x0009 | CSR_SYNERGY_EVENT_CLASS_BASE)) -#define CSR_FSAL_PRIM ((u16) (0x000A | CSR_SYNERGY_EVENT_CLASS_BASE)) -#define CSR_DATA_STORE_PRIM ((u16) (0x000B | CSR_SYNERGY_EVENT_CLASS_BASE)) -#define CSR_AM_PRIM ((u16) (0x000C | CSR_SYNERGY_EVENT_CLASS_BASE)) -#define CSR_TLS_PRIM ((u16) (0x000D | CSR_SYNERGY_EVENT_CLASS_BASE)) -#define CSR_DHCP_SERVER_PRIM ((u16) (0x000E | CSR_SYNERGY_EVENT_CLASS_BASE)) -#define CSR_TFTP_PRIM ((u16) (0x000F | CSR_SYNERGY_EVENT_CLASS_BASE)) -#define CSR_DSPM_PRIM ((u16) (0x0010 | CSR_SYNERGY_EVENT_CLASS_BASE)) -#define CSR_TLS_INTERNAL_PRIM ((u16) (0x0011 | CSR_SYNERGY_EVENT_CLASS_BASE)) - -#define NUMBER_OF_CSR_FW_EVENTS (CSR_DSPM_PRIM - CSR_SYNERGY_EVENT_CLASS_BASE + 1) - -#define CSR_SYNERGY_EVENT_CLASS_MISC_BASE ((u16) (0x06A0)) - -#define CSR_UI_PRIM ((u16) (0x0000 | CSR_SYNERGY_EVENT_CLASS_MISC_BASE)) -#define CSR_APP_PRIM ((u16) (0x0001 | CSR_SYNERGY_EVENT_CLASS_MISC_BASE)) -#define CSR_SDIO_PROBE_PRIM ((u16) (0x0002 | CSR_SYNERGY_EVENT_CLASS_MISC_BASE)) - -#define NUMBER_OF_CSR_FW_MISC_EVENTS (CSR_SDIO_PROBE_PRIM - CSR_SYNERGY_EVENT_CLASS_MISC_BASE + 1) - -#define CSR_ENV_PRIM ((u16) (0x00FF | CSR_SYNERGY_EVENT_CLASS_MISC_BASE)) - -#endif /* CSR_PRIM_DEFS_H__ */ diff --git a/drivers/staging/csr/csr_result.h b/drivers/staging/csr/csr_result.h deleted file mode 100644 index cbb607d943c7..000000000000 --- a/drivers/staging/csr/csr_result.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef CSR_RESULT_H__ -#define CSR_RESULT_H__ -/***************************************************************************** - - (c) Cambridge Silicon Radio Limited 2010 - All rights reserved and confidential information of CSR - - Refer to LICENSE.txt included with this source for details - on the license terms. - -*****************************************************************************/ - -typedef u16 CsrResult; -#define CSR_RESULT_SUCCESS ((CsrResult) 0x0000) -#define CSR_RESULT_FAILURE ((CsrResult) 0xFFFF) - -#endif diff --git a/drivers/staging/csr/csr_sched.h b/drivers/staging/csr/csr_sched.h deleted file mode 100644 index c7d672c59f5b..000000000000 --- a/drivers/staging/csr/csr_sched.h +++ /dev/null @@ -1,85 +0,0 @@ -#ifndef CSR_SCHED_H__ -#define CSR_SCHED_H__ -/***************************************************************************** - - (c) Cambridge Silicon Radio Limited 2010 - All rights reserved and confidential information of CSR - - Refer to LICENSE.txt included with this source for details - on the license terms. - -*****************************************************************************/ -#include -#include "csr_time.h" - -/* An identifier issued by the scheduler. */ -typedef u32 CsrSchedIdentifier; - -/* A task identifier */ -typedef u16 CsrSchedTaskId; - -/* A queue identifier */ -typedef u16 CsrSchedQid; - -/* A message identifier */ -typedef CsrSchedIdentifier CsrSchedMsgId; - -/* A timer event identifier */ -typedef CsrSchedIdentifier CsrSchedTid; -#define CSR_SCHED_TID_INVALID ((CsrSchedTid) 0) - -/* Time constants. */ -#define CSR_SCHED_TIME_MAX (0xFFFFFFFF) -#define CSR_SCHED_MILLISECOND (1000) -#define CSR_SCHED_SECOND (1000 * CSR_SCHED_MILLISECOND) -#define CSR_SCHED_MINUTE (60 * CSR_SCHED_SECOND) - -/* Queue and primitive that identifies the environment */ -#define CSR_SCHED_TASK_ID 0xFFFF -#define CSR_SCHED_PRIM (CSR_SCHED_TASK_ID) -#define CSR_SCHED_EXCLUDED_MODULE_QUEUE 0xFFFF - -/* - * Background interrupt definitions - */ -typedef u16 CsrSchedBgint; -#define CSR_SCHED_BGINT_INVALID ((CsrSchedBgint) 0xFFFF) - -/*----------------------------------------------------------------------------* - * NAME - * CsrSchedMessagePut - * - * DESCRIPTION - * Sends a message consisting of the integer "mi" and the void * pointer - * "mv" to the message queue "q". - * - * "mi" and "mv" are neither inspected nor changed by the scheduler - the - * task that owns "q" is expected to make sense of the values. "mv" may - * be null. - * - * NOTE - * If "mv" is not null then it will typically be a chunk of kmalloc()ed - * memory, though there is no need for it to be so. Tasks should normally - * obey the convention that when a message built with kmalloc()ed memory - * is given to CsrSchedMessagePut() then ownership of the memory is ceded to the - * scheduler - and eventually to the recipient task. I.e., the receiver of - * the message will be expected to kfree() the message storage. - * - * RETURNS - * void. - * - *----------------------------------------------------------------------------*/ -#if defined(CSR_LOG_ENABLE) && defined(CSR_LOG_INCLUDE_FILE_NAME_AND_LINE_NUMBER) -void CsrSchedMessagePutStringLog(CsrSchedQid q, - u16 mi, - void *mv, - u32 line, - const char *file); -#define CsrSchedMessagePut(q, mi, mv) CsrSchedMessagePutStringLog((q), (mi), (mv), __LINE__, __FILE__) -#else -void CsrSchedMessagePut(CsrSchedQid q, - u16 mi, - void *mv); -#endif - -#endif diff --git a/drivers/staging/csr/csr_sdio.h b/drivers/staging/csr/csr_sdio.h deleted file mode 100644 index 0971d135abf6..000000000000 --- a/drivers/staging/csr/csr_sdio.h +++ /dev/null @@ -1,723 +0,0 @@ -#ifndef CSR_SDIO_H__ -#define CSR_SDIO_H__ -/***************************************************************************** - - (c) Cambridge Silicon Radio Limited 2010 - All rights reserved and confidential information of CSR - - Refer to LICENSE.txt included with this source for details - on the license terms. - -*****************************************************************************/ - -#include "csr_result.h" - -/* Result Codes */ -#define CSR_SDIO_RESULT_INVALID_VALUE ((CsrResult) 1) /* Invalid argument value */ -#define CSR_SDIO_RESULT_NO_DEVICE ((CsrResult) 2) /* The specified device is no longer present */ -#define CSR_SDIO_RESULT_CRC_ERROR ((CsrResult) 3) /* The transmitted/received data or command response contained a CRC error */ -#define CSR_SDIO_RESULT_TIMEOUT ((CsrResult) 4) /* No command response or data received from device, or function enable/disable did not succeed within timeout period */ -#define CSR_SDIO_RESULT_NOT_RESET ((CsrResult) 5) /* The device was not reset */ - -/* Features (for use in features member of CsrSdioFunction) */ -#define CSR_SDIO_FEATURE_BYTE_MODE 0x00000001 /* Transfer sizes do not have to be a multiple of block size */ -#define CSR_SDIO_FEATURE_DMA_CAPABLE_MEM_REQUIRED 0x00000002 /* Bulk operations require DMA friendly memory */ - -/* CsrSdioFunctionId wildcards (for use in CsrSdioFunctionId members) */ -#define CSR_SDIO_ANY_MANF_ID 0xFFFF -#define CSR_SDIO_ANY_CARD_ID 0xFFFF -#define CSR_SDIO_ANY_SDIO_FUNCTION 0xFF -#define CSR_SDIO_ANY_SDIO_INTERFACE 0xFF - -/*----------------------------------------------------------------------------* - * NAME - * CsrSdioFunctionId - * - * DESCRIPTION - * This structure describes one or more functions of a device, based on - * four qualitative measures. The CsrSdioFunctionId wildcard defines can be - * used for making the CsrSdioFunctionId match more than one function. - * - * MEMBERS - * manfId - Vendor ID (or CSR_SDIO_ANY_MANF_ID). - * cardId - Device ID (or CSR_SDIO_ANY_CARD_ID). - * sdioFunction - SDIO Function number (or CSR_SDIO_ANY_SDIO_FUNCTION). - * sdioInterface - SDIO Standard Interface Code (or CSR_SDIO_ANY_SDIO_INTERFACE) - * - *----------------------------------------------------------------------------*/ -typedef struct -{ - u16 manfId; /* Vendor ID to match or CSR_SDIO_ANY_MANF_ID */ - u16 cardId; /* Device ID to match or CSR_SDIO_ANY_CARD_ID */ - u8 sdioFunction; /* SDIO Function number to match or CSR_SDIO_ANY_SDIO_FUNCTION */ - u8 sdioInterface; /* SDIO Standard Interface Code to match or CSR_SDIO_ANY_SDIO_INTERFACE */ -} CsrSdioFunctionId; - -/*----------------------------------------------------------------------------* - * NAME - * CsrSdioFunction - * - * DESCRIPTION - * This structure represents a single function on a device. - * - * MEMBERS - * sdioId - A CsrSdioFunctionId describing this particular function. The - * subfield shall not contain any CsrSdioFunctionId wildcards. The - * subfields shall describe the specific single function - * represented by this structure. - * blockSize - Actual configured block size, or 0 if unconfigured. - * features - Bit mask with any of CSR_SDIO_FEATURE_* set. - * device - Handle of device containing the function. If two functions have - * the same device handle, they reside on the same device. - * driverData - For use by the Function Driver. The SDIO Driver shall not - * attempt to dereference the pointer. - * priv - For use by the SDIO Driver. The Function Driver shall not attempt - * to dereference the pointer. - * - * - *----------------------------------------------------------------------------*/ -typedef struct -{ - CsrSdioFunctionId sdioId; - u16 blockSize; /* Actual configured block size, or 0 if unconfigured */ - u32 features; /* Bit mask with any of CSR_SDIO_FEATURE_* set */ - void *device; /* Handle of device containing the function */ - void *driverData; /* For use by the Function Driver */ - void *priv; /* For use by the SDIO Driver */ -} CsrSdioFunction; - -/*----------------------------------------------------------------------------* - * NAME - * CsrSdioInsertedCallback, CsrSdioRemovedCallback - * - * DESCRIPTION - * CsrSdioInsertedCallback is called when a function becomes available to - * a registered Function Driver that supports the function. - * CsrSdioRemovedCallback is called when a function is no longer available - * to a Function Driver, either because the device has been removed, or the - * Function Driver has been unregistered. - * - * NOTE: These functions are implemented by the Function Driver, and are - * passed as function pointers in the CsrSdioFunctionDriver struct. - * - * PARAMETERS - * function - Pointer to struct representing the function. - * - *----------------------------------------------------------------------------*/ -typedef void (*CsrSdioInsertedCallback)(CsrSdioFunction *function); -typedef void (*CsrSdioRemovedCallback)(CsrSdioFunction *function); - -/*----------------------------------------------------------------------------* - * NAME - * CsrSdioInterruptDsrCallback, CsrSdioInterruptCallback - * - * DESCRIPTION - * CsrSdioInterruptCallback is called when an interrupt occurs on the - * the device associated with the specified function. - * - * NOTE: These functions are implemented by the Function Driver, and are - * passed as function pointers in the CsrSdioFunctionDriver struct. - * - * PARAMETERS - * function - Pointer to struct representing the function. - * - * RETURNS (only CsrSdioInterruptCallback) - * A pointer to a CsrSdioInterruptDsrCallback function. - * - *----------------------------------------------------------------------------*/ -typedef void (*CsrSdioInterruptDsrCallback)(CsrSdioFunction *function); -typedef CsrSdioInterruptDsrCallback (*CsrSdioInterruptCallback)(CsrSdioFunction *function); - -/*----------------------------------------------------------------------------* - * NAME - * CsrSdioSuspendCallback, CsrSdioResumeCallback - * - * DESCRIPTION - * CsrSdioSuspendCallback is called when the system is preparing to go - * into a suspended state. CsrSdioResumeCallback is called when the system - * has entered an active state again. - * - * NOTE: These functions are implemented by the Function Driver, and are - * passed as function pointers in the CsrSdioFunctionDriver struct. - * - * PARAMETERS - * function - Pointer to struct representing the function. - * - *----------------------------------------------------------------------------*/ -typedef void (*CsrSdioSuspendCallback)(CsrSdioFunction *function); -typedef void (*CsrSdioResumeCallback)(CsrSdioFunction *function); - -/*----------------------------------------------------------------------------* - * NAME - * CsrSdioAsyncCallback, CsrSdioAsyncDsrCallback - * - * DESCRIPTION - * CsrSdioAsyncCallback is called when an asynchronous operation completes. - * - * NOTE: These functions are implemented by the Function Driver, and are - * passed as function pointers in the function calls that initiate - * the operation. - * - * PARAMETERS - * function - Pointer to struct representing the function. - * result - The result of the operation that completed. See the description - * of the initiating function for possible result values. - * - * RETURNS (only CsrSdioAsyncCallback) - * A pointer to a CsrSdioAsyncDsrCallback function. - * - *----------------------------------------------------------------------------*/ -typedef void (*CsrSdioAsyncDsrCallback)(CsrSdioFunction *function, CsrResult result); -typedef CsrSdioAsyncDsrCallback (*CsrSdioAsyncCallback)(CsrSdioFunction *function, CsrResult result); - -/*----------------------------------------------------------------------------* - * NAME - * CsrSdioFunctionDriver - * - * DESCRIPTION - * Structure representing a Function Driver. - * - * MEMBERS - * inserted - Callback, see description of CsrSdioInsertedCallback. - * removed - Callback, see description of CsrSdioRemovedCallback. - * intr - Callback, see description of CsrSdioInterruptCallback. - * suspend - Callback, see description of CsrSdioSuspendCallback. - * resume - Callback, see description of CsrSdioResumeCallback. - * ids - Array of CsrSdioFunctionId describing one or more functions that - * are supported by the Function Driver. - * idsCount - Length of the ids array. - * priv - For use by the SDIO Driver. The Function Driver may initialise - * it to NULL, but shall otherwise not access the pointer or attempt - * to dereference it. - * - *----------------------------------------------------------------------------*/ -typedef struct -{ - CsrSdioInsertedCallback inserted; - CsrSdioRemovedCallback removed; - CsrSdioInterruptCallback intr; - CsrSdioSuspendCallback suspend; - CsrSdioResumeCallback resume; - CsrSdioFunctionId *ids; - u8 idsCount; - void *priv; /* For use by the SDIO Driver */ -} CsrSdioFunctionDriver; - -/*----------------------------------------------------------------------------* - * NAME - * CsrSdioFunctionDriverRegister - * - * DESCRIPTION - * Register a Function Driver. - * - * PARAMETERS - * functionDriver - Pointer to struct describing the Function Driver. - * - * RETURNS - * CSR_RESULT_SUCCESS - The Function Driver was successfully - * registered. - * CSR_RESULT_FAILURE - Unable to register the function driver, - * because of an unspecified/unknown error. The - * Function Driver has not been registered. - * CSR_SDIO_RESULT_INVALID_VALUE - The specified Function Driver pointer - * does not point at a valid Function - * Driver structure, or some of the members - * contain invalid entries. - * - *----------------------------------------------------------------------------*/ -CsrResult CsrSdioFunctionDriverRegister(CsrSdioFunctionDriver *functionDriver); - -/*----------------------------------------------------------------------------* - * NAME - * CsrSdioFunctionDriverUnregister - * - * DESCRIPTION - * Unregister a previously registered Function Driver. - * - * PARAMETERS - * functionDriver - pointer to struct describing the Function Driver. - * - *----------------------------------------------------------------------------*/ -void CsrSdioFunctionDriverUnregister(CsrSdioFunctionDriver *functionDriver); - -/*----------------------------------------------------------------------------* - * NAME - * CsrSdioFunctionEnable, CsrSdioFunctionDisable - * - * DESCRIPTION - * Enable/disable the specified function by setting/clearing the - * corresponding bit in the I/O Enable register in function 0, and then - * periodically reading the related bit in the I/O Ready register until it - * is set/clear, limited by an implementation defined timeout. - * - * PARAMETERS - * function - Pointer to struct representing the function. - * - * RETURNS - * CSR_RESULT_SUCCESS - The specified function was enabled/disabled. - * CSR_RESULT_FAILURE - Unspecified/unknown error. - * CSR_SDIO_RESULT_NO_DEVICE - The device does not exist anymore. - * CSR_SDIO_RESULT_CRC_ERROR - A CRC error occurred. The state of the - * related bit in the I/O Enable register is - * undefined. - * CSR_SDIO_RESULT_TIMEOUT - No response from the device, or the related - * bit in the I/O ready register was not - * set/cleared within the timeout period. - * - * NOTE: If the SDIO R5 response is available, and either of the - * FUNCTION_NUMBER or OUT_OF_RANGE bits are set, - * CSR_SDIO_RESULT_INVALID_VALUE shall be returned. If the ERROR bit - * is set (but none of FUNCTION_NUMBER or OUT_OF_RANGE), - * CSR_RESULT_FAILURE shall be returned. The ILLEGAL_COMMAND and - * COM_CRC_ERROR bits shall be ignored. - * - * If the CSPI response is available, and any of the - * FUNCTION_DISABLED or CLOCK_DISABLED bits are set, - * CSR_SDIO_RESULT_INVALID_VALUE will be returned. - * - *----------------------------------------------------------------------------*/ -CsrResult CsrSdioFunctionEnable(CsrSdioFunction *function); -CsrResult CsrSdioFunctionDisable(CsrSdioFunction *function); - -/*----------------------------------------------------------------------------* - * NAME - * CsrSdioInterruptEnable, CsrSdioInterruptDisable - * - * DESCRIPTION - * Enable/disable the interrupt for the specified function by - * setting/clearing the corresponding bit in the INT Enable register in - * function 0. - * - * PARAMETERS - * function - Pointer to struct representing the function. - * - * RETURNS - * CSR_RESULT_SUCCESS - The specified function was enabled/disabled. - * CSR_RESULT_FAILURE - Unspecified/unknown error. - * CSR_SDIO_RESULT_NO_DEVICE - The device does not exist anymore. - * CSR_SDIO_RESULT_CRC_ERROR - A CRC error occurred. The state of the - * related bit in the INT Enable register is - * unchanged. - * CSR_SDIO_RESULT_INVALID_VALUE - The specified function cannot be - * enabled/disabled, because it either - * does not exist or it is not possible to - * individually enable/disable functions. - * CSR_SDIO_RESULT_TIMEOUT - No response from the device. - * - * NOTE: If the SDIO R5 response is available, and either of the - * FUNCTION_NUMBER or OUT_OF_RANGE bits are set, - * CSR_SDIO_RESULT_INVALID_VALUE shall be returned. If the ERROR bit - * is set (but none of FUNCTION_NUMBER or OUT_OF_RANGE), - * CSR_RESULT_FAILURE shall be returned. The ILLEGAL_COMMAND and - * COM_CRC_ERROR bits shall be ignored. - * - * If the CSPI response is available, and any of the - * FUNCTION_DISABLED or CLOCK_DISABLED bits are set, - * CSR_SDIO_RESULT_INVALID_VALUE will be returned. - * - *----------------------------------------------------------------------------*/ -CsrResult CsrSdioInterruptEnable(CsrSdioFunction *function); -CsrResult CsrSdioInterruptDisable(CsrSdioFunction *function); - -/*----------------------------------------------------------------------------* - * NAME - * CsrSdioInterruptAcknowledge - * - * DESCRIPTION - * Acknowledge that a signalled interrupt has been handled. Shall only - * be called once, and exactly once for each signalled interrupt to the - * corresponding function. - * - * PARAMETERS - * function - Pointer to struct representing the function to which the - * event was signalled. - * - *----------------------------------------------------------------------------*/ -void CsrSdioInterruptAcknowledge(CsrSdioFunction *function); - -/*----------------------------------------------------------------------------* - * NAME - * CsrSdioInsertedAcknowledge, CsrSdioRemovedAcknowledge - * - * DESCRIPTION - * Acknowledge that a signalled inserted/removed event has been handled. - * Shall only be called once, and exactly once for each signalled event to - * the corresponding function. - * - * PARAMETERS - * function - Pointer to struct representing the function to which the - * inserted was signalled. - * result (CsrSdioInsertedAcknowledge only) - * CSR_RESULT_SUCCESS - The Function Driver has accepted the - * function, and the function is attached to - * the Function Driver until the - * CsrSdioRemovedCallback is called and - * acknowledged. - * CSR_RESULT_FAILURE - Unable to accept the function. The - * function is not attached to the Function - * Driver, and it may be passed to another - * Function Driver which supports the - * function. - * - *----------------------------------------------------------------------------*/ -void CsrSdioInsertedAcknowledge(CsrSdioFunction *function, CsrResult result); -void CsrSdioRemovedAcknowledge(CsrSdioFunction *function); - -/*----------------------------------------------------------------------------* - * NAME - * CsrSdioSuspendAcknowledge, CsrSdioResumeAcknowledge - * - * DESCRIPTION - * Acknowledge that a signalled suspend event has been handled. Shall only - * be called once, and exactly once for each signalled event to the - * corresponding function. - * - * PARAMETERS - * function - Pointer to struct representing the function to which the - * event was signalled. - * result - * CSR_RESULT_SUCCESS - Successfully suspended/resumed. - * CSR_RESULT_FAILURE - Unspecified/unknown error. - * - *----------------------------------------------------------------------------*/ -void CsrSdioSuspendAcknowledge(CsrSdioFunction *function, CsrResult result); -void CsrSdioResumeAcknowledge(CsrSdioFunction *function, CsrResult result); - -/*----------------------------------------------------------------------------* - * NAME - * CsrSdioBlockSizeSet - * - * DESCRIPTION - * Set the block size to use for the function. The actual configured block - * size shall be the minimum of: - * 1) Maximum block size supported by the function. - * 2) Maximum block size supported by the host controller. - * 3) The block size specified by the blockSize argument. - * - * When this function returns, the actual configured block size is - * available in the blockSize member of the function struct. - * - * PARAMETERS - * function - Pointer to struct representing the function. - * blockSize - Block size to use for the function. Valid range is 1 to - * 2048. - * - * RETURNS - * CSR_RESULT_SUCCESS - The block size register on the chip - * was updated. - * CSR_RESULT_FAILURE - Unspecified/unknown error. - * CSR_SDIO_RESULT_INVALID_VALUE - One or more arguments were invalid. - * CSR_SDIO_RESULT_NO_DEVICE - The device does not exist anymore. - * CSR_SDIO_RESULT_CRC_ERROR - A CRC error occurred. The configured block - * size is undefined. - * CSR_SDIO_RESULT_TIMEOUT - No response from the device. - * - * NOTE: If the SDIO R5 response is available, and the FUNCTION_NUMBER - * bits is set, CSR_SDIO_RESULT_INVALID_VALUE shall be returned. - * If the ERROR bit is set (but not FUNCTION_NUMBER), - * CSR_RESULT_FAILURE shall be returned. The ILLEGAL_COMMAND and - * COM_CRC_ERROR bits shall be ignored. - * - * If the CSPI response is available, and any of the - * FUNCTION_DISABLED or CLOCK_DISABLED bits are set, - * CSR_SDIO_RESULT_INVALID_VALUE will be returned. - * - * NOTE: Setting the block size requires two individual operations. The - * implementation shall ignore the OUT_OF_RANGE bit of the SDIO R5 - * response for the first operation, as the partially configured - * block size may be out of range, even if the final block size - * (after the second operation) is in the valid range. - * - *----------------------------------------------------------------------------*/ -CsrResult CsrSdioBlockSizeSet(CsrSdioFunction *function, u16 blockSize); - -/*----------------------------------------------------------------------------* - * NAME - * CsrSdioMaxBusClockFrequencySet - * - * DESCRIPTION - * Set the maximum clock frequency to use for the device associated with - * the specified function. The actual configured clock frequency for the - * device shall be the minimum of: - * 1) Maximum clock frequency supported by the device. - * 2) Maximum clock frequency supported by the host controller. - * 3) Maximum clock frequency specified for any function on the same - * device. - * - * If the clock frequency exceeds 25MHz, it is the responsibility of the - * SDIO driver to enable high speed mode on the device, using the standard - * defined procedure, before increasing the frequency beyond the limit. - * - * Note that the clock frequency configured affects all functions on the - * same device. - * - * PARAMETERS - * function - Pointer to struct representing the function. - * maxFrequency - The maximum clock frequency for the function in Hertz. - * - * RETURNS - * CSR_RESULT_SUCCESS - The maximum clock frequency was successfully - * set for the function. - * CSR_RESULT_FAILURE - Unspecified/unknown error. - * CSR_SDIO_RESULT_INVALID_VALUE - One or more arguments were invalid. - * CSR_SDIO_RESULT_NO_DEVICE - The device does not exist anymore. - * - * NOTE: If the SDIO R5 response is available, and the FUNCTION_NUMBER - * bits is set, CSR_SDIO_RESULT_INVALID_VALUE shall be returned. - * If the ERROR bit is set (but not FUNCTION_NUMBER), - * CSR_RESULT_FAILURE shall be returned. The ILLEGAL_COMMAND and - * COM_CRC_ERROR bits shall be ignored. - * - * If the CSPI response is available, and any of the - * FUNCTION_DISABLED or CLOCK_DISABLED bits are set, - * CSR_SDIO_RESULT_INVALID_VALUE will be returned. - * - * - *----------------------------------------------------------------------------*/ -CsrResult CsrSdioMaxBusClockFrequencySet(CsrSdioFunction *function, u32 maxFrequency); - -/*----------------------------------------------------------------------------* - * NAME - * CsrSdioRead8, CsrSdioWrite8, CsrSdioRead8Async, CsrSdioWrite8Async - * - * DESCRIPTION - * Read/write an 8bit value from/to the specified register address. - * - * PARAMETERS - * function - Pointer to struct representing the function. - * address - Register address within the function. - * data - The data to read/write. - * callback - The function to call on operation completion. - * - * RETURNS - * CSR_RESULT_SUCCESS - The data was successfully read/written. - * CSR_RESULT_FAILURE - Unspecified/unknown error. - * CSR_SDIO_RESULT_INVALID_VALUE - One or more arguments were invalid. - * CSR_SDIO_RESULT_NO_DEVICE - The device does not exist anymore. - * CSR_SDIO_RESULT_CRC_ERROR - A CRC error occurred. No data read/written. - * CSR_SDIO_RESULT_TIMEOUT - No response from the device. - * - * NOTE: If the SDIO R5 response is available, and either of the - * FUNCTION_NUMBER or OUT_OF_RANGE bits are set, - * CSR_SDIO_RESULT_INVALID_VALUE shall be returned. If the ERROR bit - * is set (but none of FUNCTION_NUMBER or OUT_OF_RANGE), - * CSR_RESULT_FAILURE shall be returned. The ILLEGAL_COMMAND and - * COM_CRC_ERROR bits shall be ignored. - * - * If the CSPI response is available, and any of the - * FUNCTION_DISABLED or CLOCK_DISABLED bits are set, - * CSR_SDIO_RESULT_INVALID_VALUE will be returned. - * - * NOTE: The CsrSdioRead8Async and CsrSdioWrite8Async functions return - * immediately, and the supplied callback function is called when the - * operation is complete. The result value is given as an argument to - * the callback function. - * - *----------------------------------------------------------------------------*/ -CsrResult CsrSdioRead8(CsrSdioFunction *function, u32 address, u8 *data); -CsrResult CsrSdioWrite8(CsrSdioFunction *function, u32 address, u8 data); -void CsrSdioRead8Async(CsrSdioFunction *function, u32 address, u8 *data, CsrSdioAsyncCallback callback); -void CsrSdioWrite8Async(CsrSdioFunction *function, u32 address, u8 data, CsrSdioAsyncCallback callback); - -/*----------------------------------------------------------------------------* - * NAME - * CsrSdioRead16, CsrSdioWrite16, CsrSdioRead16Async, CsrSdioWrite16Async - * - * DESCRIPTION - * Read/write a 16bit value from/to the specified register address. - * - * PARAMETERS - * function - Pointer to struct representing the function. - * address - Register address within the function. - * data - The data to read/write. - * callback - The function to call on operation completion. - * - * RETURNS - * CSR_RESULT_SUCCESS - The data was successfully read/written. - * CSR_RESULT_FAILURE - Unspecified/unknown error. - * CSR_SDIO_RESULT_INVALID_VALUE - One or more arguments were invalid. - * CSR_SDIO_RESULT_NO_DEVICE - The device does not exist anymore. - * CSR_SDIO_RESULT_CRC_ERROR - A CRC error occurred. Data may have been - * partially read/written. - * CSR_SDIO_RESULT_TIMEOUT - No response from the device. - * - * NOTE: If the SDIO R5 response is available, and either of the - * FUNCTION_NUMBER or OUT_OF_RANGE bits are set, - * CSR_SDIO_RESULT_INVALID_VALUE shall be returned. If the ERROR bit - * is set (but none of FUNCTION_NUMBER or OUT_OF_RANGE), - * CSR_RESULT_FAILURE shall be returned. The ILLEGAL_COMMAND and - * COM_CRC_ERROR bits shall be ignored. - * - * If the CSPI response is available, and any of the - * FUNCTION_DISABLED or CLOCK_DISABLED bits are set, - * CSR_SDIO_RESULT_INVALID_VALUE will be returned. - * - * NOTE: The CsrSdioRead16Async and CsrSdioWrite16Async functions return - * immediately, and the supplied callback function is called when the - * operation is complete. The result value is given as an argument to - * the callback function. - * - *----------------------------------------------------------------------------*/ -CsrResult CsrSdioRead16(CsrSdioFunction *function, u32 address, u16 *data); -CsrResult CsrSdioWrite16(CsrSdioFunction *function, u32 address, u16 data); -void CsrSdioRead16Async(CsrSdioFunction *function, u32 address, u16 *data, CsrSdioAsyncCallback callback); -void CsrSdioWrite16Async(CsrSdioFunction *function, u32 address, u16 data, CsrSdioAsyncCallback callback); - -/*----------------------------------------------------------------------------* - * NAME - * CsrSdioF0Read8, CsrSdioF0Write8, CsrSdioF0Read8Async, - * CsrSdioF0Write8Async - * - * DESCRIPTION - * Read/write an 8bit value from/to the specified register address in - * function 0. - * - * PARAMETERS - * function - Pointer to struct representing the function. - * address - Register address within the function. - * data - The data to read/write. - * callback - The function to call on operation completion. - * - * RETURNS - * CSR_RESULT_SUCCESS - The data was successfully read/written. - * CSR_RESULT_FAILURE - Unspecified/unknown error. - * CSR_SDIO_RESULT_INVALID_VALUE - One or more arguments were invalid. - * CSR_SDIO_RESULT_NO_DEVICE - The device does not exist anymore. - * CSR_SDIO_RESULT_CRC_ERROR - A CRC error occurred. No data read/written. - * CSR_SDIO_RESULT_TIMEOUT - No response from the device. - * - * NOTE: If the SDIO R5 response is available, and either of the - * FUNCTION_NUMBER or OUT_OF_RANGE bits are set, - * CSR_SDIO_RESULT_INVALID_VALUE shall be returned. If the ERROR bit - * is set (but none of FUNCTION_NUMBER or OUT_OF_RANGE), - * CSR_RESULT_FAILURE shall be returned. The ILLEGAL_COMMAND and - * COM_CRC_ERROR bits shall be ignored. - * - * If the CSPI response is available, and any of the - * FUNCTION_DISABLED or CLOCK_DISABLED bits are set, - * CSR_SDIO_RESULT_INVALID_VALUE will be returned. - * - * NOTE: The CsrSdioF0Read8Async and CsrSdioF0Write8Async functions return - * immediately, and the supplied callback function is called when the - * operation is complete. The result value is given as an argument to - * the callback function. - * - *----------------------------------------------------------------------------*/ -CsrResult CsrSdioF0Read8(CsrSdioFunction *function, u32 address, u8 *data); -CsrResult CsrSdioF0Write8(CsrSdioFunction *function, u32 address, u8 data); -void CsrSdioF0Read8Async(CsrSdioFunction *function, u32 address, u8 *data, CsrSdioAsyncCallback callback); -void CsrSdioF0Write8Async(CsrSdioFunction *function, u32 address, u8 data, CsrSdioAsyncCallback callback); - -/*----------------------------------------------------------------------------* - * NAME - * CsrSdioRead, CsrSdioWrite, CsrSdioReadAsync, CsrSdioWriteAsync - * - * DESCRIPTION - * Read/write a specified number of bytes from/to the specified register - * address. - * - * PARAMETERS - * function - Pointer to struct representing the function. - * address - Register address within the function. - * data - The data to read/write. - * length - Number of byte to read/write. - * callback - The function to call on operation completion. - * - * RETURNS - * CSR_RESULT_SUCCESS - The data was successfully read/written. - * CSR_RESULT_FAILURE - Unspecified/unknown error. - * CSR_SDIO_RESULT_INVALID_VALUE - One or more arguments were invalid. - * CSR_SDIO_RESULT_NO_DEVICE - The device does not exist anymore. - * CSR_SDIO_RESULT_CRC_ERROR - A CRC error occurred. Data may have been - * partially read/written. - * CSR_SDIO_RESULT_TIMEOUT - No response from the device. - * - * NOTE: If the SDIO R5 response is available, and either of the - * FUNCTION_NUMBER or OUT_OF_RANGE bits are set, - * CSR_SDIO_RESULT_INVALID_VALUE shall be returned. If the ERROR bit - * is set (but none of FUNCTION_NUMBER or OUT_OF_RANGE), - * CSR_RESULT_FAILURE shall be returned. The ILLEGAL_COMMAND and - * COM_CRC_ERROR bits shall be ignored. - * - * If the CSPI response is available, and any of the - * FUNCTION_DISABLED or CLOCK_DISABLED bits are set, - * CSR_SDIO_RESULT_INVALID_VALUE will be returned. - * - * NOTE: The CsrSdioF0Read8Async and CsrSdioF0Write8Async functions return - * immediately, and the supplied callback function is called when the - * operation is complete. The result value is given as an argument to - * the callback function. - * - *----------------------------------------------------------------------------*/ -CsrResult CsrSdioRead(CsrSdioFunction *function, u32 address, void *data, u32 length); -CsrResult CsrSdioWrite(CsrSdioFunction *function, u32 address, const void *data, u32 length); -void CsrSdioReadAsync(CsrSdioFunction *function, u32 address, void *data, u32 length, CsrSdioAsyncCallback callback); -void CsrSdioWriteAsync(CsrSdioFunction *function, u32 address, const void *data, u32 length, CsrSdioAsyncCallback callback); - -/*----------------------------------------------------------------------------* - * NAME - * CsrSdioPowerOn, CsrSdioPowerOff - * - * DESCRIPTION - * Power on/off the device. - * - * PARAMETERS - * function - Pointer to struct representing the function that resides on - * the device to power on/off. - * - * RETURNS (only CsrSdioPowerOn) - * CSR_RESULT_SUCCESS - Power was successfully reapplied and the device - * has been reinitialised. - * CSR_RESULT_FAILURE - Unspecified/unknown error. - * CSR_SDIO_RESULT_NO_DEVICE - The device does not exist anymore. - * CSR_SDIO_RESULT_CRC_ERROR - A CRC error occurred during reinitialisation. - * CSR_SDIO_RESULT_TIMEOUT - No response from the device during - * reinitialisation. - * CSR_SDIO_RESULT_NOT_RESET - The power was not removed by the - * CsrSdioPowerOff call. The state of the - * device is unchanged. - * - *----------------------------------------------------------------------------*/ -CsrResult CsrSdioPowerOn(CsrSdioFunction *function); -void CsrSdioPowerOff(CsrSdioFunction *function); - -/*----------------------------------------------------------------------------* - * NAME - * CsrSdioHardReset - * - * DESCRIPTION - * Perform a hardware reset of the device. - * - * PARAMETERS - * function - Pointer to struct representing the function that resides on - * the device to hard reset. - * - * RETURNS - * CSR_RESULT_SUCCESS - Reset was successfully performed and the device - * has been reinitialised. - * CSR_RESULT_FAILURE - Unspecified/unknown error. - * CSR_SDIO_RESULT_NO_DEVICE - The device does not exist anymore. - * CSR_SDIO_RESULT_CRC_ERROR - A CRC error occurred during reinitialisation. - * CSR_SDIO_RESULT_TIMEOUT - No response from the device during - * reinitialisation. - * CSR_SDIO_RESULT_NOT_RESET - The reset was not applied because it is not - * supported. The state of the device is - * unchanged. - * - *----------------------------------------------------------------------------*/ -CsrResult CsrSdioHardReset(CsrSdioFunction *function); - -/*----------------------------------------------------------------------------* - * NAME - * CsrSdioFunctionActive, CsrSdioFunctionIdle - * - * DESCRIPTION - * - * PARAMETERS - * function - Pointer to struct representing the function. - * - *----------------------------------------------------------------------------*/ -void CsrSdioFunctionActive(CsrSdioFunction *function); -void CsrSdioFunctionIdle(CsrSdioFunction *function); - -#endif diff --git a/drivers/staging/csr/csr_serialize_primitive_types.c b/drivers/staging/csr/csr_serialize_primitive_types.c deleted file mode 100644 index 9713b9afef64..000000000000 --- a/drivers/staging/csr/csr_serialize_primitive_types.c +++ /dev/null @@ -1,100 +0,0 @@ -/***************************************************************************** - - (c) Cambridge Silicon Radio Limited 2010 - All rights reserved and confidential information of CSR - - Refer to LICENSE.txt included with this source for details - on the license terms. - -*****************************************************************************/ - -#include -#include -#include "csr_prim_defs.h" -#include "csr_msgconv.h" -#include "csr_macro.h" - -void CsrUint8Des(u8 *value, u8 *buffer, size_t *offset) -{ - *value = buffer[*offset]; - *offset += sizeof(*value); -} -EXPORT_SYMBOL_GPL(CsrUint8Des); - -void CsrUint16Des(u16 *value, u8 *buffer, size_t *offset) -{ - *value = (buffer[*offset + 0] << 0) | - (buffer[*offset + 1] << 8); - *offset += sizeof(*value); -} -EXPORT_SYMBOL_GPL(CsrUint16Des); - -void CsrUint32Des(u32 *value, u8 *buffer, size_t *offset) -{ - *value = (buffer[*offset + 0] << 0) | - (buffer[*offset + 1] << 8) | - (buffer[*offset + 2] << 16) | - (buffer[*offset + 3] << 24); - *offset += sizeof(*value); -} -EXPORT_SYMBOL_GPL(CsrUint32Des); - -void CsrMemCpyDes(void *value, u8 *buffer, size_t *offset, size_t length) -{ - memcpy(value, &buffer[*offset], length); - *offset += length; -} -EXPORT_SYMBOL_GPL(CsrMemCpyDes); - -void CsrCharStringDes(char **value, u8 *buffer, size_t *offset) -{ - *value = kstrdup((char *) &buffer[*offset], GFP_KERNEL); - *offset += strlen(*value) + 1; -} -EXPORT_SYMBOL_GPL(CsrCharStringDes); - -void CsrUint8Ser(u8 *buffer, size_t *offset, u8 value) -{ - buffer[*offset] = value; - *offset += sizeof(value); -} -EXPORT_SYMBOL_GPL(CsrUint8Ser); - -void CsrUint16Ser(u8 *buffer, size_t *offset, u16 value) -{ - buffer[*offset + 0] = (u8) ((value >> 0) & 0xFF); - buffer[*offset + 1] = (u8) ((value >> 8) & 0xFF); - *offset += sizeof(value); -} -EXPORT_SYMBOL_GPL(CsrUint16Ser); - -void CsrUint32Ser(u8 *buffer, size_t *offset, u32 value) -{ - buffer[*offset + 0] = (u8) ((value >> 0) & 0xFF); - buffer[*offset + 1] = (u8) ((value >> 8) & 0xFF); - buffer[*offset + 2] = (u8) ((value >> 16) & 0xFF); - buffer[*offset + 3] = (u8) ((value >> 24) & 0xFF); - *offset += sizeof(value); -} -EXPORT_SYMBOL_GPL(CsrUint32Ser); - -void CsrMemCpySer(u8 *buffer, size_t *offset, const void *value, size_t length) -{ - memcpy(&buffer[*offset], value, length); - *offset += length; -} -EXPORT_SYMBOL_GPL(CsrMemCpySer); - -void CsrCharStringSer(u8 *buffer, size_t *offset, const char *value) -{ - if (value) - { - strcpy(((char *) &buffer[*offset]), value); - *offset += strlen(value) + 1; - } - else - { - CsrUint8Ser(buffer, offset, 0); - } -} -EXPORT_SYMBOL_GPL(CsrCharStringSer); diff --git a/drivers/staging/csr/csr_time.c b/drivers/staging/csr/csr_time.c deleted file mode 100644 index 01179e46f47d..000000000000 --- a/drivers/staging/csr/csr_time.c +++ /dev/null @@ -1,33 +0,0 @@ -/***************************************************************************** - - (c) Cambridge Silicon Radio Limited 2010 - All rights reserved and confidential information of CSR - - Refer to LICENSE.txt included with this source for details - on the license terms. - -*****************************************************************************/ - -#include -#include -#include - -#include "csr_time.h" - -u32 CsrTimeGet(u32 *high) -{ - struct timespec ts; - u64 time; - u32 low; - - ts = current_kernel_time(); - time = (u64) ts.tv_sec * 1000000 + ts.tv_nsec / 1000; - - if (high != NULL) - *high = (u32) ((time >> 32) & 0xFFFFFFFF); - - low = (u32) (time & 0xFFFFFFFF); - - return low; -} -EXPORT_SYMBOL_GPL(CsrTimeGet); diff --git a/drivers/staging/csr/csr_time.h b/drivers/staging/csr/csr_time.h deleted file mode 100644 index fc29e8e5e478..000000000000 --- a/drivers/staging/csr/csr_time.h +++ /dev/null @@ -1,76 +0,0 @@ -#ifndef CSR_TIME_H__ -#define CSR_TIME_H__ -/***************************************************************************** - -(c) Cambridge Silicon Radio Limited 2010 -All rights reserved and confidential information of CSR - -Refer to LICENSE.txt included with this source for details -on the license terms. - -*****************************************************************************/ - -#include - -/******************************************************************************* - -NAME - CsrTimeGet - -DESCRIPTION - Returns the current system time in a low and a high part. The low part - is expressed in microseconds. The high part is incremented when the low - part wraps to provide an extended range. - - The caller may provide a NULL pointer as the high parameter. - In this case the function just returns the low part and ignores the - high parameter. - - Although the time is expressed in microseconds the actual resolution is - platform dependent and can be less. It is recommended that the - resolution is at least 10 milliseconds. - -PARAMETERS - high - Pointer to variable that will receive the high part of the - current system time. Passing NULL is valid. - -RETURNS - Low part of current system time in microseconds. - -*******************************************************************************/ -u32 CsrTimeGet(u32 *high); - - -/*------------------------------------------------------------------*/ -/* CsrTime Macros */ -/*------------------------------------------------------------------*/ - -/*----------------------------------------------------------------------------* - * NAME - * CsrTimeAdd - * - * DESCRIPTION - * Add two time values. Adding the numbers can overflow the range of a - * CsrTime, so the user must be cautious. - * - * RETURNS - * CsrTime - the sum of "t1" and "t2". - * - *----------------------------------------------------------------------------*/ -#define CsrTimeAdd(t1, t2) ((t1) + (t2)) - -/*----------------------------------------------------------------------------* - * NAME - * CsrTimeSub - * - * DESCRIPTION - * Subtract two time values. Subtracting the numbers can provoke an - * underflow, so the user must be cautious. - * - * RETURNS - * CsrTime - "t1" - "t2". - * - *----------------------------------------------------------------------------*/ -#define CsrTimeSub(t1, t2) ((s32) (t1) - (s32) (t2)) - -#endif diff --git a/drivers/staging/csr/csr_util.c b/drivers/staging/csr/csr_util.c deleted file mode 100644 index c3aa9d509e5c..000000000000 --- a/drivers/staging/csr/csr_util.c +++ /dev/null @@ -1,15 +0,0 @@ -/***************************************************************************** - - (c) Cambridge Silicon Radio Limited 2010 - All rights reserved and confidential information of CSR - - Refer to LICENSE.txt included with this source for details - on the license terms. - -*****************************************************************************/ - -#include - -MODULE_DESCRIPTION("CSR Operating System Kernel Abstraction"); -MODULE_AUTHOR("Cambridge Silicon Radio Ltd."); -MODULE_LICENSE("GPL and additional rights"); diff --git a/drivers/staging/csr/csr_wifi_common.h b/drivers/staging/csr/csr_wifi_common.h deleted file mode 100644 index efc43a525a3d..000000000000 --- a/drivers/staging/csr/csr_wifi_common.h +++ /dev/null @@ -1,101 +0,0 @@ -/***************************************************************************** - - (c) Cambridge Silicon Radio Limited 2011 - All rights reserved and confidential information of CSR - - Refer to LICENSE.txt included with this source for details - on the license terms. - -*****************************************************************************/ - -#ifndef CSR_WIFI_COMMON_H__ -#define CSR_WIFI_COMMON_H__ - -#include -#include "csr_result.h" - -/* MAC address */ -typedef struct -{ - u8 a[6]; -} CsrWifiMacAddress; - -/* IPv4 address */ -typedef struct -{ - u8 a[4]; -} CsrWifiIp4Address; - -/* IPv6 address */ -typedef struct -{ - u8 a[16]; -} CsrWifiIp6Address; - -typedef struct -{ - u8 ssid[32]; - u8 length; -} CsrWifiSsid; - -/******************************************************************************* - - DESCRIPTION - Result values used on the Wifi Interfaces - - VALUES - CSR_RESULT_SUCCESS - - The request/procedure succeeded - CSR_RESULT_FAILURE - - The request/procedure did not succeed because of an error - CSR_WIFI_RESULT_NOT_FOUND - - The request did not succeed because some resource was not - found. - CSR_WIFI_RESULT_TIMED_OUT - - The request/procedure did not succeed because of a time out - CSR_WIFI_RESULT_CANCELLED - - The request was canceled due to another conflicting - request that was issued before this one was completed - CSR_WIFI_RESULT_INVALID_PARAMETER - - The request/procedure did not succeed because it had an - invalid parameter - CSR_WIFI_RESULT_NO_ROOM - - The request did not succeed due to a lack of resources, - e.g. out of memory problem. - CSR_WIFI_RESULT_UNSUPPORTED - - The request/procedure did not succeed because the feature - is not supported yet - CSR_WIFI_RESULT_UNAVAILABLE - - The request cannot be processed at this time - CSR_WIFI_RESULT_WIFI_OFF - - The requested action is not available because Wi-Fi is - currently off - CSR_WIFI_RESULT_SECURITY_ERROR - - The request/procedure did not succeed because of a security - error - CSR_WIFI_RESULT_MIB_SET_FAILURE - - MIB Set Failure: either the MIB OID to be written to does - not exist or the MIB Value is invalid. - CSR_WIFI_RESULT_INVALID_INTERFACE_TAG - - The supplied Interface Tag is not valid. - CSR_WIFI_RESULT_P2P_NOA_CONFIG_CONFLICT - - The new NOA configuration conflicts with the existing NOA configuration - hence not accepted" -*******************************************************************************/ -#define CSR_WIFI_RESULT_NOT_FOUND ((CsrResult) 0x0001) -#define CSR_WIFI_RESULT_TIMED_OUT ((CsrResult) 0x0002) -#define CSR_WIFI_RESULT_CANCELLED ((CsrResult) 0x0003) -#define CSR_WIFI_RESULT_INVALID_PARAMETER ((CsrResult) 0x0004) -#define CSR_WIFI_RESULT_NO_ROOM ((CsrResult) 0x0005) -#define CSR_WIFI_RESULT_UNSUPPORTED ((CsrResult) 0x0006) -#define CSR_WIFI_RESULT_UNAVAILABLE ((CsrResult) 0x0007) -#define CSR_WIFI_RESULT_WIFI_OFF ((CsrResult) 0x0008) -#define CSR_WIFI_RESULT_SECURITY_ERROR ((CsrResult) 0x0009) -#define CSR_WIFI_RESULT_MIB_SET_FAILURE ((CsrResult) 0x000A) -#define CSR_WIFI_RESULT_INVALID_INTERFACE_TAG ((CsrResult) 0x000B) -#define CSR_WIFI_RESULT_P2P_NOA_CONFIG_CONFLICT ((CsrResult) 0x000C) - -#define CSR_WIFI_VERSION "5.1.0.0" - -#endif - diff --git a/drivers/staging/csr/csr_wifi_fsm.h b/drivers/staging/csr/csr_wifi_fsm.h deleted file mode 100644 index fc5c5aa6a3c4..000000000000 --- a/drivers/staging/csr/csr_wifi_fsm.h +++ /dev/null @@ -1,240 +0,0 @@ -/***************************************************************************** - - (c) Cambridge Silicon Radio Limited 2011 - All rights reserved and confidential information of CSR - - Refer to LICENSE.txt included with this source for details - on the license terms. - -*****************************************************************************/ - -#ifndef CSR_WIFI_FSM_H -#define CSR_WIFI_FSM_H - -#include "csr_prim_defs.h" -#include "csr_log_text.h" -#include "csr_wifi_fsm_event.h" - -/* including this file for CsrWifiInterfaceMode*/ -#include "csr_wifi_common.h" - -#define CSR_WIFI_FSM_ENV (0xFFFF) - -/** - * @brief - * Toplevel FSM context data - * - * @par Description - * Holds ALL FSM static and dynamic data for a FSM - */ -typedef struct CsrWifiFsmContext CsrWifiFsmContext; - -/** - * @brief - * FSM External Wakeup CallbackFunction Pointer - * - * @par Description - * Defines the external wakeup function for the FSM - * to call when an external event is injected into the systen - * - * @param[in] context : External context - * - * @return - * void - */ -typedef void (*CsrWifiFsmExternalWakupCallbackPtr)(void *context); - -/** - * @brief - * Initialises a top level FSM context - * - * @par Description - * Initialises the FSM Context to an initial state and allocates - * space for "maxProcesses" number of instances - * - * @param[in] osaContext : OSA context - * @param[in] applicationContext : Internal fsm application context - * @param[in] externalContext : External context - * @param[in] maxProcesses : Max processes to allocate room for - * - * @return - * CsrWifiFsmContext* fsm context - */ -extern CsrWifiFsmContext* CsrWifiFsmInit(void *applicationContext, void *externalContext, u16 maxProcesses, CsrLogTextTaskId loggingTaskId); - -/** - * @brief - * Resets the FSM's back to first conditions - * - * @par Description - * This function is used to free any dynamic resources allocated for the - * given context by CsrWifiFsmInit(). - * The FSM's reset function is called to cleanup any fsm specific memory - * The reset function does NOT need to free the fsm data pointer as - * CsrWifiFsmShutdown() will do it. - * the FSM's init function is call again to reinitialise the FSM context. - * CsrWifiFsmReset() should NEVER be called when CsrWifiFsmExecute() is running. - * - * @param[in] context : FSM context - * - * @return - * void - */ -extern void CsrWifiFsmReset(CsrWifiFsmContext *context); - -/** - * @brief - * Frees resources allocated by CsrWifiFsmInit - * - * @par Description - * This function is used to free any dynamic resources allocated for the - * given context by CsrWifiFsmInit(), prior to complete termination of - * the program. - * The FSM's reset function is called to cleanup any fsm specific memory. - * The reset function does NOT need to free the fsm data pointer as - * CsrWifiFsmShutdown() will do it. - * CsrWifiFsmShutdown() should NEVER be called when CsrWifiFsmExecute() is running. - * - * @param[in] context : FSM context - * - * @return - * void - */ -extern void CsrWifiFsmShutdown(CsrWifiFsmContext *context); - -/** - * @brief - * Executes the fsm context - * - * @par Description - * Executes the FSM context and runs until ALL events in the context are processed. - * When no more events are left to process then CsrWifiFsmExecute() returns to a time - * specifying when to next call the CsrWifiFsmExecute() - * Scheduling, threading, blocking and external event notification are outside - * the scope of the FSM and CsrWifiFsmExecute(). - * - * @param[in] context : FSM context - * - * @return - * u32 Time in ms until next timeout or 0xFFFFFFFF for no timer set - */ -extern u32 CsrWifiFsmExecute(CsrWifiFsmContext *context); - -/** - * @brief - * Adds an event to the FSM context's external event queue for processing - * - * @par Description - * Adds an event to the contexts external queue - * This is thread safe and adds an event to the fsm's external event queue. - * - * @param[in] context : FSM context - * @param[in] event : event to add to the event queue - * @param[in] source : source of the event (this can be a synergy task queue or an fsm instance id) - * @param[in] destination : destination of the event (This can be a fsm instance id or CSR_WIFI_FSM_ENV) - * @param[in] id : event id - * - * @return - * void - */ -extern void CsrWifiFsmSendEventExternal(CsrWifiFsmContext *context, CsrWifiFsmEvent *event, u16 source, u16 destination, CsrPrim primtype, u16 id); - -/** - * @brief - * Adds an Alien event to the FSM context's external event queue for processing - * - * @par Description - * Adds an event to the contexts external queue - * This is thread safe and adds an event to the fsm's external event queue. - * - * @param[in] context : FSM context - * @param[in] event : event to add to the event queue - * @param[in] source : source of the event (this can be a synergy task queue or an fsm instance id) - * @param[in] destination : destination of the event (This can be a fsm instance id or CSR_WIFI_FSM_ENV) - * @param[in] id : event id - */ -#define CsrWifiFsmSendAlienEventExternal(_context, _alienEvent, _source, _destination, _primtype, _id) \ - { \ - CsrWifiFsmAlienEvent *_evt = kmalloc(sizeof(CsrWifiFsmAlienEvent), GFP_KERNEL); \ - _evt->alienEvent = _alienEvent; \ - CsrWifiFsmSendEventExternal(_context, (CsrWifiFsmEvent *)_evt, _source, _destination, _primtype, _id); \ - } - - -/** - * @brief - * Current time of day in ms - * - * @param[in] context : FSM context - * - * @return - * u32 32 bit ms tick - */ -extern u32 CsrWifiFsmGetTimeOfDayMs(CsrWifiFsmContext *context); - -/** - * @brief - * Gets the time until the next FSM timer expiry - * - * @par Description - * Returns the next timeout time or 0 if no timers are set. - * - * @param[in] context : FSM context - * - * @return - * u32 Time in ms until next timeout or 0xFFFFFFFF for no timer set - */ -extern u32 CsrWifiFsmGetNextTimeout(CsrWifiFsmContext *context); - -/** - * @brief - * Fast forwards the fsm timers by ms Milliseconds - * - * @param[in] context : FSM context - * @param[in] ms : Milliseconds to fast forward by - * - * @return - * void - */ -extern void CsrWifiFsmFastForward(CsrWifiFsmContext *context, u16 ms); - -/** - * @brief - * shift the current time of day by ms amount - * - * @par Description - * useful to speed up tests where time needs to pass - * - * @param[in] context : FSM context - * @param[in] ms : ms to adjust time by - * - * @return - * void - */ -extern void CsrWifiFsmTestAdvanceTime(CsrWifiFsmContext *context, u32 ms); - -/** - * @brief - * Check if the fsm has events to process - * - * @param[in] context : FSM context - * - * @return - * u8 returns TRUE if there are events for the FSM to process - */ -extern u8 CsrWifiFsmHasEvents(CsrWifiFsmContext *context); - -/** - * @brief - * function that installs the contexts wakeup function - * - * @param[in] context : FSM context - * @param[in] callback : Callback function pointer - * - * @return - * void - */ -extern void CsrWifiFsmInstallWakeupCallback(CsrWifiFsmContext *context, CsrWifiFsmExternalWakupCallbackPtr callback); - -#endif /* CSR_WIFI_FSM_H */ - diff --git a/drivers/staging/csr/csr_wifi_fsm_event.h b/drivers/staging/csr/csr_wifi_fsm_event.h deleted file mode 100644 index 0690ca955ef5..000000000000 --- a/drivers/staging/csr/csr_wifi_fsm_event.h +++ /dev/null @@ -1,42 +0,0 @@ -/***************************************************************************** - - (c) Cambridge Silicon Radio Limited 2011 - All rights reserved and confidential information of CSR - - Refer to LICENSE.txt included with this source for details - on the license terms. - -*****************************************************************************/ - -#ifndef CSR_WIFI_FSM_EVENT_H -#define CSR_WIFI_FSM_EVENT_H - -#include "csr_prim_defs.h" -#include "csr_sched.h" - -/** - * @brief - * FSM event header. - * - * @par Description - * All events MUST have this struct as the FIRST member. - * The next member is used internally for linked lists - */ -typedef struct CsrWifiFsmEvent -{ - CsrPrim type; - u16 primtype; - CsrSchedQid destination; - CsrSchedQid source; - - /* Private pointer to allow an optimal Event list */ - /* NOTE: Ignore this pointer. - * Do not waste code initializing OR freeing it. - * The pointer is used internally in the CsrWifiFsm code - * to avoid a second malloc when queuing events. - */ - struct CsrWifiFsmEvent *next; -} CsrWifiFsmEvent; - -#endif /* CSR_WIFI_FSM_EVENT_H */ - diff --git a/drivers/staging/csr/csr_wifi_fsm_types.h b/drivers/staging/csr/csr_wifi_fsm_types.h deleted file mode 100644 index d21c60a81fcf..000000000000 --- a/drivers/staging/csr/csr_wifi_fsm_types.h +++ /dev/null @@ -1,430 +0,0 @@ -/***************************************************************************** - - (c) Cambridge Silicon Radio Limited 2011 - All rights reserved and confidential information of CSR - - Refer to LICENSE.txt included with this source for details - on the license terms. - -*****************************************************************************/ - -#ifndef CSR_WIFI_FSM_TYPES_H -#define CSR_WIFI_FSM_TYPES_H - -#include -#include "csr_macro.h" -#include "csr_sched.h" - -#ifdef CSR_WIFI_FSM_MUTEX_ENABLE -#include "csr_framework_ext.h" -#endif - -#include "csr_wifi_fsm.h" - -#define CSR_WIFI_FSM_MAX_TRANSITION_HISTORY 10 - -/** - * @brief - * FSM event list header. - * - * @par Description - * Singly linked list of events. - */ -typedef struct CsrWifiFsmEventList -{ - CsrWifiFsmEvent *first; - CsrWifiFsmEvent *last; -} CsrWifiFsmEventList; - - -/** - * @brief - * FSM timer id. - * - * @par Description - * Composite Id made up of the type, dest and a unique id so - * CsrWifiFsmRemoveTimer knows where to look when removing the timer - */ -typedef struct CsrWifiFsmTimerId -{ - CsrPrim type; - u16 primtype; - CsrSchedQid destination; - u16 uniqueid; -} CsrWifiFsmTimerId; - -/** - * @brief - * FSM timer header. - * - * @par Description - * All timer MUST have this struct as the FIRST member. - * The first members of the structure MUST remain compatable - * with the CsrWifiFsmEvent so that timers are just specialised events - */ -typedef struct CsrWifiFsmTimer -{ - CsrPrim type; - u16 primtype; - CsrSchedQid destination; - CsrSchedQid source; - - /* Private pointer to allow an optimal Event list */ - struct CsrWifiFsmTimer *next; - - CsrWifiFsmTimerId timerid; - u32 timeoutTimeMs; -} CsrWifiFsmTimer; - - -/** - * @brief - * Fsm Alien Event - * - * @par Description - * Allows the wrapping of alien events that do not use CsrWifiFsmEvent - * as the first member of the Event struct - */ -typedef struct -{ - CsrWifiFsmEvent event; - void *alienEvent; -} CsrWifiFsmAlienEvent; - - -/** - * @brief - * FSM timer list header. - * - * @par Description - * Singly linked list of timers. - */ -typedef struct CsrWifiFsmTimerList -{ - CsrWifiFsmTimer *first; - CsrWifiFsmTimer *last; - u16 nexttimerid; -} CsrWifiFsmTimerList; - -/** - * @brief - * Process Entry Function Pointer - * - * @par Description - * Defines the entry function for a processes. - * Called at process initialisation. - * - * @param[in] context : FSM context - * - * @return - * void - */ -typedef void (*CsrWifiFsmProcEntryFnPtr)(CsrWifiFsmContext *context); - -/** - * @brief - * Process Transition Function Pointer - * - * @par Description - * Defines a transition function for a processes. - * Called when an event causes a transition on a process - * - * @param[in] CsrWifiFsmContext* : FSM context - * @param[in] void* : FSM data (can be NULL) - * @param[in] const CsrWifiFsmEvent* : event to process - * - * @return - * void - */ -typedef void (*CsrWifiFsmTransitionFnPtr)(CsrWifiFsmContext *context, void *fsmData, const CsrWifiFsmEvent *event); - -/** - * @brief - * Process reset/shutdown Function Pointer - * - * @par Description - * Defines the reset/shutdown function for a processes. - * Called to reset or shutdown an fsm. - * - * @param[in] context : FSM context - * - * @return - * void - */ -typedef void (*CsrWifiFsmProcResetFnPtr)(CsrWifiFsmContext *context); - -/** - * @brief - * FSM Default Destination CallbackFunction Pointer - * - * @par Description - * Defines the default destination function for the FSM - * to call when an event does not have a valid destination. - * This - * - * @param[in] context : External context - * - * @return - * u16 a valid destination OR CSR_WIFI_FSM_ENV - */ -typedef u16 (*CsrWifiFsmDestLookupCallbackPtr)(void *context, const CsrWifiFsmEvent *event); - - -#ifdef CSR_WIFI_FSM_DUMP_ENABLE -/** - * @brief - * Trace Dump Function Pointer - * - * @par Description - * Called when we want to trace the FSM - * - * @param[in] context : FSM context - * @param[in] id : fsm id - * - * @return - * void - */ -typedef void (*CsrWifiFsmDumpFnPtr)(CsrWifiFsmContext *context, void *fsmData); -#endif - -/** - * @brief - * Event ID to transition function entry - * - * @par Description - * Event ID to Transition Entry in a state table. - */ -typedef struct -{ - u32 eventid; - CsrWifiFsmTransitionFnPtr transition; -#ifdef CSR_LOG_ENABLE - const char *transitionName; -#endif -} CsrWifiFsmEventEntry; - -/** - * @brief - * Single State's Transition Table - * - * @par Description - * Stores Data for a single State's event to - * transition functions mapping - */ -typedef struct -{ - const u8 numEntries; - const u8 saveAll; - const CsrWifiFsmEventEntry *eventEntryArray; /* array of transition function pointers for state */ -#ifdef CSR_LOG_ENABLE - u16 stateNumber; - const char *stateName; -#endif -} CsrWifiFsmTableEntry; - -/** - * @brief - * Process State Transtion table - * - * @par Description - * Stores Data for a processes State to transition table - */ -typedef struct -{ - u16 numStates; /* number of states */ - const CsrWifiFsmTableEntry *aStateEventMatrix; /* state event matrix */ -} CsrWifiFsmTransitionFunctionTable; - -/** - * @brief - * Const Process definition - * - * @par Description - * Constant process specification. - * This is ALL the non dynamic data that defines - * a process. - */ -typedef struct -{ - const char *processName; - const u32 processId; - const CsrWifiFsmTransitionFunctionTable transitionTable; - const CsrWifiFsmTableEntry unhandledTransitions; - const CsrWifiFsmTableEntry ignoreFunctions; - const CsrWifiFsmProcEntryFnPtr entryFn; - const CsrWifiFsmProcResetFnPtr resetFn; -#ifdef CSR_WIFI_FSM_DUMP_ENABLE - const CsrWifiFsmDumpFnPtr dumpFn; /* Called to dump fsm specific trace if not NULL */ -#endif -} CsrWifiFsmProcessStateMachine; - -#ifdef CSR_WIFI_FSM_DUMP_ENABLE -/** - * @brief - * Storage for state transition info - */ -typedef struct -{ - u16 transitionNumber; - CsrWifiFsmEvent event; - u16 fromState; - u16 toState; - CsrWifiFsmTransitionFnPtr transitionFn; - u16 transitionCount; /* number consecutive of times this transition was seen */ -#ifdef CSR_LOG_ENABLE - const char *transitionName; -#endif -} CsrWifiFsmTransitionRecord; - -/** - * @brief - * Storage for the last state X transitions - */ -typedef struct -{ - u16 numTransitions; - CsrWifiFsmTransitionRecord records[CSR_WIFI_FSM_MAX_TRANSITION_HISTORY]; -} CsrWifiFsmTransitionRecords; -#endif - -/** - * @brief - * Dynamic Process data - * - * @par Description - * Dynamic process data that is used to keep track of the - * state and data for a process instance - */ -typedef struct -{ - const CsrWifiFsmProcessStateMachine *fsmInfo; /* state machine info that is constant regardless of context */ - u16 instanceId; /* Runtime process id */ - u16 state; /* Current state */ - void *params; /* Instance user data */ - CsrWifiFsmEventList savedEventQueue; /* The saved event queue */ - struct CsrWifiFsmInstanceEntry *subFsm; /* Sub Fsm instance data */ - struct CsrWifiFsmInstanceEntry *subFsmCaller; /* The Fsm instance that created the SubFsm and should be used for callbacks*/ -#ifdef CSR_WIFI_FSM_DUMP_ENABLE - CsrWifiFsmTransitionRecords transitionRecords; /* Last X transitions in the FSM */ -#endif -} CsrWifiFsmInstanceEntry; - -/** - * @brief - * OnCreate Callback Function Pointer - * - * @par Description - * Called when an fsm is created. - * - * @param[in] extContext : External context - * @param[in] instance : FSM instance - * - * @return - * void - */ -typedef void (*CsrWifiFsmOnCreateFnPtr)(void *extContext, const CsrWifiFsmInstanceEntry *instance); - -/** - * @brief - * OnTransition Callback Function Pointer - * - * @par Description - * Called when an event is processed by a fsm - * - * @param[in] extContext : External context - * @param[in] eventEntryArray : Entry data - * @param[in] event : Event - * - * @return - * void - */ -typedef void (*CsrWifiFsmOnTransitionFnPtr)(void *extContext, const CsrWifiFsmEventEntry *eventEntryArray, const CsrWifiFsmEvent *event); - -/** - * @brief - * OnStateChange Callback Function Pointer - * - * @par Description - * Called when CsrWifiFsmNextState is called - * - * @param[in] extContext : External context - * - * @return - * void - */ -typedef void (*CsrWifiFsmOnStateChangeFnPtr)(void *extContext, u16 nextstate); - -/** - * @brief - * OnIgnore,OnError or OnInvalid Callback Function Pointer - * - * @par Description - * Called when an event is processed by a fsm - * - * @param[in] extContext : External context - * @param[in] event : Event - * - * @return - * void - */ -typedef void (*CsrWifiFsmOnEventFnPtr)(void *extContext, const CsrWifiFsmEvent *event); - -/** - * @brief - * Toplevel FSM context data - * - * @par Description - * Holds ALL FSM static and dynamic data for a FSM - */ -struct CsrWifiFsmContext -{ - CsrWifiFsmEventList eventQueue; /* The internal event queue */ - CsrWifiFsmEventList externalEventQueue; /* The external event queue */ -#ifdef CSR_WIFI_FSM_MUTEX_ENABLE - CsrMutexHandle externalEventQueueLock; /* The external event queue mutex */ -#endif - u32 timeOffset; /* Amount to adjust the TimeOfDayMs by */ - CsrWifiFsmTimerList timerQueue; /* The internal timer queue */ - u8 useTempSaveList; /* Should the temp save list be used */ - CsrWifiFsmEventList tempSaveList; /* The temp save event queue */ - CsrWifiFsmEvent *eventForwardedOrSaved; /* The event that was forwarded or Saved */ - u16 maxProcesses; /* Size of instanceArray */ - u16 numProcesses; /* Current number allocated in instanceArray */ - CsrWifiFsmInstanceEntry *instanceArray; /* Array of processes for this component */ - CsrWifiFsmInstanceEntry *ownerInstance; /* The Process that owns currentInstance (SubFsm support) */ - CsrWifiFsmInstanceEntry *currentInstance; /* Current Process that is executing */ - CsrWifiFsmExternalWakupCallbackPtr externalEventFn; /* External event Callback */ - CsrWifiFsmOnEventFnPtr appIgnoreCallback; /* Application Ignore event Callback */ - CsrWifiFsmDestLookupCallbackPtr appEvtDstCallback; /* Application Lookup event Destination Function*/ - - void *applicationContext; /* Internal fsm application context */ - void *externalContext; /* External context (set by the user of the fsm)*/ - CsrLogTextTaskId loggingTaskId; /* Task Id to use in any logging output */ - -#ifndef CSR_WIFI_FSM_SCHEDULER_DISABLED - CsrSchedTid schedTimerId; /* Scheduler TimerId for use in Scheduler Tasks */ - u32 schedTimerNexttimeoutMs; /* Next timeout time for the current timer */ -#endif - -#ifdef CSR_WIFI_FSM_MUTEX_ENABLE -#ifdef CSR_WIFI_FSM_TRANSITION_LOCK - CsrMutexHandle transitionLock; /* Lock when calling transition functions */ -#endif -#endif - -#ifdef CSR_LOG_ENABLE - CsrWifiFsmOnCreateFnPtr onCreate; /* Debug Transition Callback */ - CsrWifiFsmOnTransitionFnPtr onTransition; /* Debug Transition Callback */ - CsrWifiFsmOnTransitionFnPtr onUnhandedCallback; /* Unhanded event Callback */ - CsrWifiFsmOnStateChangeFnPtr onStateChange; /* Debug State Change Callback */ - CsrWifiFsmOnEventFnPtr onIgnoreCallback; /* Ignore event Callback */ - CsrWifiFsmOnEventFnPtr onSaveCallback; /* Save event Callback */ - CsrWifiFsmOnEventFnPtr onErrorCallback; /* Error event Callback */ - CsrWifiFsmOnEventFnPtr onInvalidCallback; /* Invalid event Callback */ -#endif -#ifdef CSR_WIFI_FSM_DUMP_ENABLE - u16 masterTransitionNumber; /* Increments on every transition */ -#endif -}; - -#endif /* CSR_WIFI_FSM_TYPES_H */ diff --git a/drivers/staging/csr/csr_wifi_hip_card.h b/drivers/staging/csr/csr_wifi_hip_card.h deleted file mode 100644 index bd47f606e0de..000000000000 --- a/drivers/staging/csr/csr_wifi_hip_card.h +++ /dev/null @@ -1,114 +0,0 @@ -/***************************************************************************** - - (c) Cambridge Silicon Radio Limited 2012 - All rights reserved and confidential information of CSR - - Refer to LICENSE.txt included with this source for details - on the license terms. - -*****************************************************************************/ - -/* - ****************************************************************************** - * FILE : csr_wifi_hip_card.h - * - * PURPOSE : Defines abstract interface for hardware specific functions. - * Note, this is a different file from one of the same name in the - * Windows driver. - * - ***************************************************************************** - */ -#ifndef __CARD_H__ -#define __CARD_H__ - -#include "csr_wifi_hip_card_sdio.h" -#include "csr_wifi_hip_signals.h" -#include "csr_wifi_hip_unifi_udi.h" - - -/***************************************************************************** - * CardEnableInt - - */ -CsrResult CardEnableInt(card_t *card); - -/***************************************************************************** - * CardGenInt - - */ -CsrResult CardGenInt(card_t *card); - -/***************************************************************************** - * CardPendingInt - - */ -CsrResult CardPendingInt(card_t *card, u8 *pintr); - -/***************************************************************************** - * CardDisableInt - - */ -CsrResult CardDisableInt(card_t *card); - -/***************************************************************************** - * CardClearInt - - */ -CsrResult CardClearInt(card_t *card); - -/***************************************************************************** - * CardDisable - - */ -void CardDisable(card_t *card); - -/***************************************************************************** - * CardIntEnabled - - */ -CsrResult CardIntEnabled(card_t *card, u8 *enabled); - -/***************************************************************************** - * CardGetDataSlotSize - */ -u16 CardGetDataSlotSize(card_t *card); - -/***************************************************************************** - * CardWriteBulkData - - */ -CsrResult CardWriteBulkData(card_t *card, card_signal_t *csptr, unifi_TrafficQueue queue); - - -/***************************************************************************** - * CardClearFromHostDataSlot - - */ -void CardClearFromHostDataSlot(card_t *card, const s16 aSlotNum); - -#ifdef CSR_WIFI_REQUEUE_PACKET_TO_HAL -/***************************************************************************** - * CardClearFromHostDataSlotWithoutFreeingBulkData - Clear the data stot - * without freeing the bulk data - */ - -void CardClearFromHostDataSlotWithoutFreeingBulkData(card_t *card, const s16 aSlotNum); -#endif - -/***************************************************************************** - * CardGetFreeFromHostDataSlots - - */ -u16 CardGetFreeFromHostDataSlots(card_t *card); - -u16 CardAreAllFromHostDataSlotsEmpty(card_t *card); - -CsrResult card_start_processor(card_t *card, enum unifi_dbg_processors_select which); - -CsrResult card_wait_for_firmware_to_start(card_t *card, u32 *paddr); - -CsrResult unifi_dl_firmware(card_t *card, void *arg); -CsrResult unifi_dl_patch(card_t *card, void *arg, u32 boot_ctrl); -CsrResult unifi_do_loader_op(card_t *card, u32 op_addr, u8 opcode); -void* unifi_dl_fw_read_start(card_t *card, s8 is_fw); - -CsrResult unifi_coredump_handle_request(card_t *card); - -CsrResult ConvertCsrSdioToCsrHipResult(card_t *card, CsrResult csrResult); -#ifdef CSR_WIFI_HIP_DEBUG_OFFLINE -void unifi_debug_log_to_buf(const char *fmt, ...); -void unifi_debug_string_to_buf(const char *str); -void unifi_debug_hex_to_buf(const char *buff, u16 length); -#endif - -#endif /* __CARD_H__ */ diff --git a/drivers/staging/csr/csr_wifi_hip_card_sdio.c b/drivers/staging/csr/csr_wifi_hip_card_sdio.c deleted file mode 100644 index d5425325894c..000000000000 --- a/drivers/staging/csr/csr_wifi_hip_card_sdio.c +++ /dev/null @@ -1,4001 +0,0 @@ -/***************************************************************************** - - (c) Cambridge Silicon Radio Limited 2012 - All rights reserved and confidential information of CSR - - Refer to LICENSE.txt included with this source for details - on the license terms. - -*****************************************************************************/ - -/* - * --------------------------------------------------------------------------- - * FILE: csr_wifi_hip_card_sdio.c - * - * PURPOSE: Implementation of the Card API for SDIO. - * - * NOTES: - * CardInit() is called from the SDIO probe callback when a card is - * inserted. This performs the basic SDIO initialisation, enabling i/o - * etc. - * - * --------------------------------------------------------------------------- - */ -#include -#include "csr_wifi_hip_unifi.h" -#include "csr_wifi_hip_conversions.h" -#include "csr_wifi_hip_unifiversion.h" -#include "csr_wifi_hip_card.h" -#include "csr_wifi_hip_card_sdio.h" -#include "csr_wifi_hip_chiphelper.h" - - -/* Time to wait between attempts to read MAILBOX0 */ -#define MAILBOX1_TIMEOUT 10 /* in millisecs */ -#define MAILBOX1_ATTEMPTS 200 /* 2 seconds */ - -#define MAILBOX2_TIMEOUT 5 /* in millisecs */ -#define MAILBOX2_ATTEMPTS 10 /* 50ms */ - -#define RESET_SETTLE_DELAY 25 /* in millisecs */ - -static CsrResult card_init_slots(card_t *card); -static CsrResult card_hw_init(card_t *card); -static CsrResult firmware_present_in_flash(card_t *card); -static void bootstrap_chip_hw(card_t *card); -static CsrResult unifi_reset_hardware(card_t *card); -static CsrResult unifi_hip_init(card_t *card); -static CsrResult card_access_panic(card_t *card); -static CsrResult unifi_read_chip_version(card_t *card); - -/* - * --------------------------------------------------------------------------- - * unifi_alloc_card - * - * Allocate and initialise the card context structure. - * - * Arguments: - * sdio Pointer to SDIO context pointer to pass to low - * level i/o functions. - * ospriv Pointer to O/S private struct to pass when calling - * callbacks to the higher level system. - * - * Returns: - * Pointer to card struct, which represents the driver context or - * NULL if the allocation failed. - * --------------------------------------------------------------------------- - */ -card_t* unifi_alloc_card(CsrSdioFunction *sdio, void *ospriv) -{ - card_t *card; - u32 i; - - - card = kzalloc(sizeof(card_t), GFP_KERNEL); - if (card == NULL) - { - return NULL; - } - - card->sdio_if = sdio; - card->ospriv = ospriv; - - card->unifi_interrupt_seq = 1; - - /* Make these invalid. */ - card->proc_select = (u32)(-1); - card->dmem_page = (u32)(-1); - card->pmem_page = (u32)(-1); - - card->bh_reason_host = 0; - card->bh_reason_unifi = 0; - - for (i = 0; i < sizeof(card->tx_q_paused_flag) / sizeof(card->tx_q_paused_flag[0]); i++) - { - card->tx_q_paused_flag[i] = 0; - } - card->memory_resources_allocated = 0; - - card->low_power_mode = UNIFI_LOW_POWER_DISABLED; - card->periodic_wake_mode = UNIFI_PERIODIC_WAKE_HOST_DISABLED; - - card->host_state = UNIFI_HOST_STATE_AWAKE; - card->intmode = CSR_WIFI_INTMODE_DEFAULT; - - /* - * Memory resources for buffers are allocated when the chip is initialised - * because we need configuration information from the firmware. - */ - - /* - * Initialise wait queues and lists - */ - card->fh_command_queue.q_body = card->fh_command_q_body; - card->fh_command_queue.q_length = UNIFI_SOFT_COMMAND_Q_LENGTH; - - for (i = 0; i < UNIFI_NO_OF_TX_QS; i++) - { - card->fh_traffic_queue[i].q_body = card->fh_traffic_q_body[i]; - card->fh_traffic_queue[i].q_length = UNIFI_SOFT_TRAFFIC_Q_LENGTH; - } - - - /* Initialise mini-coredump pointers in case no coredump buffers - * are requested by the OS layer. - */ - card->request_coredump_on_reset = 0; - card->dump_next_write = NULL; - card->dump_cur_read = NULL; - card->dump_buf = NULL; - -#ifdef UNIFI_DEBUG - /* Determine offset of LSB in pointer for later alignment sanity check. - * Synergy integer types have specific widths, which cause compiler - * warnings when casting pointer types, e.g. on 64-bit systems. - */ - { - u32 val = 0x01234567; - - if (*((u8 *)&val) == 0x01) - { - card->lsb = sizeof(void *) - 1; /* BE */ - } - else - { - card->lsb = 0; /* LE */ - } - } -#endif - return card; -} /* unifi_alloc_card() */ - - -/* - * --------------------------------------------------------------------------- - * unifi_init_card - * - * Reset the hardware and perform HIP initialization - * - * Arguments: - * card Pointer to card struct - * - * Returns: - * CsrResult code - * CSR_RESULT_SUCCESS if successful - * --------------------------------------------------------------------------- - */ -CsrResult unifi_init_card(card_t *card, s32 led_mask) -{ - CsrResult r; - - - if (card == NULL) - { - return CSR_WIFI_HIP_RESULT_INVALID_VALUE; - } - - r = unifi_init(card); - if (r != CSR_RESULT_SUCCESS) - { - return r; - } - - r = unifi_hip_init(card); - if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE) - { - return r; - } - if (r != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, "Failed to start host protocol.\n"); - return r; - } - - return CSR_RESULT_SUCCESS; -} - - -/* - * --------------------------------------------------------------------------- - * unifi_init - * - * Init the hardware. - * - * Arguments: - * card Pointer to card struct - * - * Returns: - * CsrResult code - * CSR_RESULT_SUCCESS if successful - * --------------------------------------------------------------------------- - */ -CsrResult unifi_init(card_t *card) -{ - CsrResult r; - CsrResult csrResult; - - if (card == NULL) - { - return CSR_WIFI_HIP_RESULT_INVALID_VALUE; - } - - /* - * Disable the SDIO interrupts while initialising UniFi. - * Re-enable them when f/w is running. - */ - csrResult = CsrSdioInterruptDisable(card->sdio_if); - if (csrResult == CSR_SDIO_RESULT_NO_DEVICE) - { - return CSR_WIFI_HIP_RESULT_NO_DEVICE; - } - - /* - * UniFi's PLL may start with a slow clock (~ 1 MHz) so initially - * set the SDIO bus clock to a similar value or SDIO accesses may - * fail. - */ - csrResult = CsrSdioMaxBusClockFrequencySet(card->sdio_if, UNIFI_SDIO_CLOCK_SAFE_HZ); - if (csrResult != CSR_RESULT_SUCCESS) - { - r = ConvertCsrSdioToCsrHipResult(card, csrResult); - return r; - } - card->sdio_clock_speed = UNIFI_SDIO_CLOCK_SAFE_HZ; - - /* - * Reset UniFi. Note, this only resets the WLAN function part of the chip, - * the SDIO interface is not reset. - */ - unifi_trace(card->ospriv, UDBG1, "Resetting UniFi\n"); - r = unifi_reset_hardware(card); - if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE) - { - return r; - } - if (r != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, "Failed to reset UniFi\n"); - return r; - } - - /* Reset the power save mode, to be active until the MLME-reset is complete */ - r = unifi_configure_low_power_mode(card, - UNIFI_LOW_POWER_DISABLED, UNIFI_PERIODIC_WAKE_HOST_DISABLED); - if (r != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, "Failed to set power save mode\n"); - return r; - } - - /* - * Set initial value of page registers. - * The page registers will be maintained by unifi_read...() and - * unifi_write...(). - */ - card->proc_select = (u32)(-1); - card->dmem_page = (u32)(-1); - card->pmem_page = (u32)(-1); - r = unifi_write_direct16(card, ChipHelper_HOST_WINDOW3_PAGE(card->helper) * 2, 0); - if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE) - { - return r; - } - if (r != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, "Failed to write SHARED_DMEM_PAGE\n"); - return r; - } - r = unifi_write_direct16(card, ChipHelper_HOST_WINDOW2_PAGE(card->helper) * 2, 0); - if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE) - { - return r; - } - if (r != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, "Failed to write PROG_MEM2_PAGE\n"); - return r; - } - - /* - * If the driver has reset UniFi due to previous SDIO failure, this may - * have been due to a chip watchdog reset. In this case, the driver may - * have requested a mini-coredump which needs to be captured now the - * SDIO interface is alive. - */ - (void)unifi_coredump_handle_request(card); - - /* - * Probe to see if the UniFi has ROM/flash to boot from. CSR6xxx should do. - */ - r = firmware_present_in_flash(card); - if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE) - { - return r; - } - if (r == CSR_WIFI_HIP_RESULT_NOT_FOUND) - { - unifi_error(card->ospriv, "No firmware found\n"); - } - else if (r != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, "Probe for Flash failed\n"); - } - - return r; -} /* unifi_init() */ - - -/* - * --------------------------------------------------------------------------- - * unifi_download - * - * Load the firmware. - * - * Arguments: - * card Pointer to card struct - * led_mask Loader LED mask - * - * Returns: - * CSR_RESULT_SUCCESS on success - * CsrResult error code on failure. - * --------------------------------------------------------------------------- - */ -CsrResult unifi_download(card_t *card, s32 led_mask) -{ - CsrResult r; - void *dlpriv; - - if (card == NULL) - { - return CSR_WIFI_HIP_RESULT_INVALID_VALUE; - } - - /* Set the loader led mask */ - card->loader_led_mask = led_mask; - - /* Get the firmware file information */ - unifi_trace(card->ospriv, UDBG1, "downloading firmware...\n"); - - dlpriv = unifi_dl_fw_read_start(card, UNIFI_FW_STA); - if (dlpriv == NULL) - { - return CSR_WIFI_HIP_RESULT_NOT_FOUND; - } - - /* Download the firmware. */ - r = unifi_dl_firmware(card, dlpriv); - if (r != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, "Failed to download firmware\n"); - return r; - } - - /* Free the firmware file information. */ - unifi_fw_read_stop(card->ospriv, dlpriv); - - return CSR_RESULT_SUCCESS; -} /* unifi_download() */ - - -/* - * --------------------------------------------------------------------------- - * unifi_hip_init - * - * This function performs the f/w initialisation sequence as described - * in the Unifi Host Interface Protocol Specification. - * It allocates memory for host-side slot data and signal queues. - * - * Arguments: - * card Pointer to card struct - * - * Returns: - * CSR_RESULT_SUCCESS on success or else a CSR error code - * - * Notes: - * The firmware must have been downloaded. - * --------------------------------------------------------------------------- - */ -static CsrResult unifi_hip_init(card_t *card) -{ - CsrResult r; - CsrResult csrResult; - - r = card_hw_init(card); - if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE) - { - return r; - } - if (r != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, "Failed to establish communication with UniFi\n"); - return r; - } -#ifdef CSR_PRE_ALLOC_NET_DATA - /* if there is any preallocated netdata left from the prev session free it now */ - prealloc_netdata_free(card); -#endif - /* - * Allocate memory for host-side slot data and signal queues. - * We need the config info read from the firmware to know how much - * memory to allocate. - */ - r = card_init_slots(card); - if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE) - { - return r; - } - if (r != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, "Init slots failed: %d\n", r); - return r; - } - - unifi_trace(card->ospriv, UDBG2, "Sending first UniFi interrupt\n"); - - r = unifi_set_host_state(card, UNIFI_HOST_STATE_AWAKE); - if (r != CSR_RESULT_SUCCESS) - { - return r; - } - - /* Enable the SDIO interrupts now that the f/w is running. */ - csrResult = CsrSdioInterruptEnable(card->sdio_if); - if (csrResult == CSR_SDIO_RESULT_NO_DEVICE) - { - return CSR_WIFI_HIP_RESULT_NO_DEVICE; - } - - /* Signal the UniFi to start handling messages */ - r = CardGenInt(card); - if (r != CSR_RESULT_SUCCESS) - { - return r; - } - - return CSR_RESULT_SUCCESS; -} /* unifi_hip_init() */ - - -/* - * --------------------------------------------------------------------------- - * _build_sdio_config_data - * - * Unpack the SDIO configuration information from a buffer read from - * UniFi into a host structure. - * The data is byte-swapped for a big-endian host if necessary by the - * UNPACK... macros. - * - * Arguments: - * card Pointer to card struct - * cfg_data Destination structure to unpack into. - * cfg_data_buf Source buffer to read from. This should be the raw - * data read from UniFi. - * - * Returns: - * None. - * --------------------------------------------------------------------------- - */ -static void _build_sdio_config_data(sdio_config_data_t *cfg_data, - const u8 *cfg_data_buf) -{ - s16 offset = 0; - - cfg_data->version = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(cfg_data_buf + offset); - offset += SIZEOF_UINT16; - - cfg_data->sdio_ctrl_offset = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(cfg_data_buf + offset); - offset += SIZEOF_UINT16; - - cfg_data->fromhost_sigbuf_handle = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(cfg_data_buf + offset); - offset += SIZEOF_UINT16; - - cfg_data->tohost_sigbuf_handle = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(cfg_data_buf + offset); - offset += SIZEOF_UINT16; - - cfg_data->num_fromhost_sig_frags = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(cfg_data_buf + offset); - offset += SIZEOF_UINT16; - - cfg_data->num_tohost_sig_frags = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(cfg_data_buf + offset); - offset += SIZEOF_UINT16; - - cfg_data->num_fromhost_data_slots = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(cfg_data_buf + offset); - offset += SIZEOF_UINT16; - - cfg_data->num_tohost_data_slots = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(cfg_data_buf + offset); - offset += SIZEOF_UINT16; - - cfg_data->data_slot_size = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(cfg_data_buf + offset); - offset += SIZEOF_UINT16; - - cfg_data->initialised = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(cfg_data_buf + offset); - offset += SIZEOF_UINT16; - - cfg_data->overlay_size = CSR_GET_UINT32_FROM_LITTLE_ENDIAN(cfg_data_buf + offset); - offset += SIZEOF_UINT32; - - cfg_data->data_slot_round = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(cfg_data_buf + offset); - offset += SIZEOF_UINT16; - - cfg_data->sig_frag_size = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(cfg_data_buf + offset); - offset += SIZEOF_UINT16; - - cfg_data->tohost_signal_padding = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(cfg_data_buf + offset); -} /* _build_sdio_config_data() */ - - -/* - * - Function ---------------------------------------------------------------- - * card_hw_init() - * - * Perform the initialisation procedure described in the UniFi Host - * Interface Protocol document (section 3.3.8) and read the run-time - * configuration information from the UniFi. This is stuff like number - * of bulk data slots etc. - * - * The card enumeration and SD initialisation has already been done by - * the SDIO library, see card_sdio_init(). - * - * The initialisation is done when firmware is ready, i.e. this may need - * to be called after a f/w download operation. - * - * The initialisation procedure goes like this: - * - Wait for UniFi to start-up by polling SHARED_MAILBOX1 - * - Find the symbol table and look up SLT_SDIO_SLOT_CONFIG - * - Read the config structure - * - Check the "SDIO initialised" flag, if not zero do a h/w reset and - * start again - * - Decide the number of bulk data slots to allocate, allocate them and - * set "SDIO initialised" flag (and generate an interrupt) to say so. - * - * Arguments: - * card Pointer to card struct - * - * Returns: - * CSR_RESULT_SUCEESS on success, - * a CSR error code on failure - * - * Notes: - * All data in the f/w is stored in a little endian format, without any - * padding bytes. Every read from this memory has to be transformed in - * host (cpu specific) format, before it is stored in driver's parameters - * or/and structures. Athough unifi_card_read16() and unifi_read32() do perform - * the conversion internally, unifi_readn() does not. - * --------------------------------------------------------------------------- - */ -static CsrResult card_hw_init(card_t *card) -{ - u32 slut_address; - u16 initialised; - u16 finger_print; - symbol_t slut; - sdio_config_data_t *cfg_data; - u8 cfg_data_buf[SDIO_CONFIG_DATA_SIZE]; - CsrResult r; - void *dlpriv; - s16 major, minor; - s16 search_4slut_again; - CsrResult csrResult; - - /* - * The device revision from the TPLMID_MANF and TPLMID_CARD fields - * of the CIS are available as - * card->sdio_if->pDevice->ManfID - * card->sdio_if->pDevice->AppID - */ - - /* - * Run in a loop so we can patch. - */ - do - { - /* Reset these each time around the loop. */ - search_4slut_again = 0; - cfg_data = NULL; - - r = card_wait_for_firmware_to_start(card, &slut_address); - if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE) - { - return r; - } - if (r != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, "Firmware hasn't started\n"); - return r; - } - unifi_trace(card->ospriv, UDBG4, "SLUT addr 0x%lX\n", slut_address); - - /* - * Firmware has started, but doesn't know full clock configuration yet - * as some of the information may be in the MIB. Therefore we set an - * initial SDIO clock speed, faster than UNIFI_SDIO_CLOCK_SAFE_HZ, for - * the patch download and subsequent firmware initialisation, and - * full speed UNIFI_SDIO_CLOCK_MAX_HZ will be set once the f/w tells us - * that it is ready. - */ - csrResult = CsrSdioMaxBusClockFrequencySet(card->sdio_if, UNIFI_SDIO_CLOCK_INIT_HZ); - if (csrResult != CSR_RESULT_SUCCESS) - { - r = ConvertCsrSdioToCsrHipResult(card, csrResult); - return r; - } - card->sdio_clock_speed = UNIFI_SDIO_CLOCK_INIT_HZ; - - /* - * Check the SLUT fingerprint. - * The slut_address is a generic pointer so we must use unifi_card_read16(). - */ - unifi_trace(card->ospriv, UDBG4, "Looking for SLUT finger print\n"); - finger_print = 0; - r = unifi_card_read16(card, slut_address, &finger_print); - if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE) - { - return r; - } - if (r != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, "Failed to read SLUT finger print\n"); - return r; - } - - if (finger_print != SLUT_FINGERPRINT) - { - unifi_error(card->ospriv, "Failed to find Symbol lookup table fingerprint\n"); - return CSR_RESULT_FAILURE; - } - - /* Symbol table starts imedately after the fingerprint */ - slut_address += 2; - - /* Search the table until either the end marker is found, or the - * loading of patch firmware invalidates the current table. - */ - while (!search_4slut_again) - { - u16 s; - u32 l; - - r = unifi_card_read16(card, slut_address, &s); - if (r != CSR_RESULT_SUCCESS) - { - return r; - } - slut_address += 2; - - if (s == CSR_SLT_END) - { - unifi_trace(card->ospriv, UDBG3, " found CSR_SLT_END\n"); - break; - } - - r = unifi_read32(card, slut_address, &l); - if (r != CSR_RESULT_SUCCESS) - { - return r; - } - slut_address += 4; - - slut.id = s; - slut.obj = l; - - unifi_trace(card->ospriv, UDBG3, " found SLUT id %02d.%08lx\n", slut.id, slut.obj); - switch (slut.id) - { - case CSR_SLT_SDIO_SLOT_CONFIG: - cfg_data = &card->config_data; - /* - * unifi_card_readn reads n bytes from the card, where data is stored - * in a little endian format, without any padding bytes. So, we - * can not just pass the cfg_data pointer or use the - * sizeof(sdio_config_data_t) since the structure in the host can - * be big endian formatted or have padding bytes for alignment. - * We use a char buffer to read the data from the card. - */ - r = unifi_card_readn(card, slut.obj, cfg_data_buf, SDIO_CONFIG_DATA_SIZE); - if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE) - { - return r; - } - if (r != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, "Failed to read config data\n"); - return r; - } - /* .. and then we copy the data to the host structure */ - _build_sdio_config_data(cfg_data, cfg_data_buf); - - /* Make sure the from host data slots are what we expect - we reserve 2 for commands and there should be at least - 1 left for each access category */ - if ((cfg_data->num_fromhost_data_slots < UNIFI_RESERVED_COMMAND_SLOTS) - || (cfg_data->num_fromhost_data_slots - UNIFI_RESERVED_COMMAND_SLOTS) / UNIFI_NO_OF_TX_QS == 0) - { - unifi_error(card->ospriv, "From host data slots %d\n", cfg_data->num_fromhost_data_slots); - unifi_error(card->ospriv, "need to be (queues * x + 2) (UNIFI_RESERVED_COMMAND_SLOTS for commands)\n"); - return CSR_RESULT_FAILURE; - } - - /* Configure SDIO to-block-size padding */ - if (card->sdio_io_block_pad) - { - /* - * Firmware limits the maximum padding size via data_slot_round. - * Therefore when padding to whole block sizes, the block size - * must be configured correctly by adjusting CSR_WIFI_HIP_SDIO_BLOCK_SIZE. - */ - if (cfg_data->data_slot_round < card->sdio_io_block_size) - { - unifi_error(card->ospriv, - "Configuration error: Block size of %d exceeds f/w data_slot_round of %d\n", - card->sdio_io_block_size, cfg_data->data_slot_round); - return CSR_WIFI_HIP_RESULT_INVALID_VALUE; - } - - /* - * To force the To-Host signals to be rounded up to the SDIO block - * size, we need to write the To-Host Signal Padding Fragments - * field of the SDIO configuration in UniFi. - */ - if ((card->sdio_io_block_size % cfg_data->sig_frag_size) != 0) - { - unifi_error(card->ospriv, "Configuration error: Can not pad to-host signals.\n"); - return CSR_WIFI_HIP_RESULT_INVALID_VALUE; - } - cfg_data->tohost_signal_padding = (u16) (card->sdio_io_block_size / cfg_data->sig_frag_size); - unifi_info(card->ospriv, "SDIO block size %d requires %d padding chunks\n", - card->sdio_io_block_size, cfg_data->tohost_signal_padding); - r = unifi_card_write16(card, slut.obj + SDIO_TO_HOST_SIG_PADDING_OFFSET, cfg_data->tohost_signal_padding); - if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE) - { - return r; - } - if (r != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, "Failed to write To-Host Signal Padding Fragments\n"); - return r; - } - } - - /* Reconstruct the Generic Pointer address of the - * SDIO Control Data Struct. - */ - card->sdio_ctrl_addr = cfg_data->sdio_ctrl_offset | (UNIFI_SH_DMEM << 24); - card->init_flag_addr = slut.obj + SDIO_INIT_FLAG_OFFSET; - break; - - case CSR_SLT_BUILD_ID_NUMBER: - { - u32 n; - r = unifi_read32(card, slut.obj, &n); - if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE) - { - return r; - } - if (r != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, "Failed to read build id\n"); - return r; - } - card->build_id = n; - } - break; - - case CSR_SLT_BUILD_ID_STRING: - r = unifi_readnz(card, slut.obj, card->build_id_string, - sizeof(card->build_id_string)); - if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE) - { - return r; - } - if (r != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, "Failed to read build string\n"); - return r; - } - break; - - case CSR_SLT_PERSISTENT_STORE_DB: - break; - - case CSR_SLT_BOOT_LOADER_CONTROL: - - /* This command copies most of the station firmware - * image from ROM into program RAM. It also clears - * out the zerod data and sets up the initialised - * data. */ - r = unifi_do_loader_op(card, slut.obj + 6, UNIFI_BOOT_LOADER_LOAD_STA); - if (r != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, "Failed to write loader load image command\n"); - return r; - } - - dlpriv = unifi_dl_fw_read_start(card, UNIFI_FW_STA); - - /* dlpriv might be NULL, we still need to do the do_loader_op step. */ - if (dlpriv != NULL) - { - /* Download the firmware. */ - r = unifi_dl_patch(card, dlpriv, slut.obj); - - /* Free the firmware file information. */ - unifi_fw_read_stop(card->ospriv, dlpriv); - - if (r != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, "Failed to patch firmware\n"); - return r; - } - } - - /* This command starts the firmware image that we want (the - * station by default) with any patches required applied. */ - r = unifi_do_loader_op(card, slut.obj + 6, UNIFI_BOOT_LOADER_RESTART); - if (r != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, "Failed to write loader restart command\n"); - return r; - } - - /* The now running patch f/w defines a new SLUT data structure - - * the current one is no longer valid. We must drop out of the - * processing loop and enumerate the new SLUT (which may appear - * at a different offset). - */ - search_4slut_again = 1; - break; - - case CSR_SLT_PANIC_DATA_PHY: - card->panic_data_phy_addr = slut.obj; - break; - - case CSR_SLT_PANIC_DATA_MAC: - card->panic_data_mac_addr = slut.obj; - break; - - default: - /* do nothing */ - break; - } - } /* while */ - } while (search_4slut_again); - - /* Did we find the Config Data ? */ - if (cfg_data == NULL) - { - unifi_error(card->ospriv, "Failed to find SDIO_SLOT_CONFIG Symbol\n"); - return CSR_RESULT_FAILURE; - } - - /* - * Has ths card already been initialised? - * If so, return an error so we do a h/w reset and start again. - */ - r = unifi_card_read16(card, card->init_flag_addr, &initialised); - if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE) - { - return r; - } - if (r != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, "Failed to read init flag at %08lx\n", - card->init_flag_addr); - return r; - } - if (initialised != 0) - { - return CSR_RESULT_FAILURE; - } - - - /* - * Now check the UniFi firmware version - */ - major = (cfg_data->version >> 8) & 0xFF; - minor = cfg_data->version & 0xFF; - unifi_info(card->ospriv, "UniFi f/w protocol version %d.%d (driver %d.%d)\n", - major, minor, - UNIFI_HIP_MAJOR_VERSION, UNIFI_HIP_MINOR_VERSION); - - unifi_info(card->ospriv, "Firmware build %u: %s\n", - card->build_id, card->build_id_string); - - if (major != UNIFI_HIP_MAJOR_VERSION) - { - unifi_error(card->ospriv, "UniFi f/w protocol major version (%d) is different from driver (v%d.%d)\n", - major, UNIFI_HIP_MAJOR_VERSION, UNIFI_HIP_MINOR_VERSION); -#ifndef CSR_WIFI_DISABLE_HIP_VERSION_CHECK - return CSR_RESULT_FAILURE; -#endif - } - if (minor < UNIFI_HIP_MINOR_VERSION) - { - unifi_error(card->ospriv, "UniFi f/w protocol version (v%d.%d) is older than minimum required by driver (v%d.%d).\n", - major, minor, - UNIFI_HIP_MAJOR_VERSION, UNIFI_HIP_MINOR_VERSION); -#ifndef CSR_WIFI_DISABLE_HIP_VERSION_CHECK - return CSR_RESULT_FAILURE; -#endif - } - - /* Read panic codes from a previous firmware panic. If the firmware has - * not panicked since power was applied (e.g. power-off hard reset) - * the stored panic codes will not be updated. - */ - unifi_read_panic(card); - - return CSR_RESULT_SUCCESS; -} /* card_hw_init() */ - - -/* - * --------------------------------------------------------------------------- - * card_wait_for_unifi_to_reset - * - * Waits for a reset to complete by polling the WLAN function enable - * bit (which is cleared on reset). - * - * Arguments: - * card Pointer to card struct - * - * Returns: - * CSR_RESULT_SUCCESS on success, CSR error code on failure. - * --------------------------------------------------------------------------- - */ -static CsrResult card_wait_for_unifi_to_reset(card_t *card) -{ - s16 i; - CsrResult r; - u8 io_enable; - CsrResult csrResult; - - r = CSR_RESULT_SUCCESS; - for (i = 0; i < MAILBOX2_ATTEMPTS; i++) - { - unifi_trace(card->ospriv, UDBG1, "waiting for reset to complete, attempt %d\n", i); - if (card->chip_id > SDIO_CARD_ID_UNIFI_2) - { - /* It's quite likely that this read will timeout for the - * first few tries - especially if we have reset via - * DBG_RESET. - */ -#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_SDIO_TRACE) - unifi_debug_log_to_buf("m0@%02X=", SDIO_IO_READY); -#endif - csrResult = CsrSdioF0Read8(card->sdio_if, SDIO_IO_READY, &io_enable); -#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_SDIO_TRACE) - if (csrResult != CSR_RESULT_SUCCESS) - { - unifi_debug_log_to_buf("error=%X\n", csrResult); - } - else - { - unifi_debug_log_to_buf("%X\n", io_enable); - } -#endif - if (csrResult == CSR_SDIO_RESULT_NO_DEVICE) - { - return CSR_WIFI_HIP_RESULT_NO_DEVICE; - } - r = CSR_RESULT_SUCCESS; - if (csrResult != CSR_RESULT_SUCCESS) - { - r = ConvertCsrSdioToCsrHipResult(card, csrResult); - } - } - else - { - r = sdio_read_f0(card, SDIO_IO_ENABLE, &io_enable); - } - if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE) - { - return r; - } - if (r == CSR_RESULT_SUCCESS) - { - u16 mbox2; - s16 enabled = io_enable & (1 << card->function); - - if (!enabled) - { - unifi_trace(card->ospriv, UDBG1, - "Reset complete (function %d is disabled) in ~ %u msecs\n", - card->function, i * MAILBOX2_TIMEOUT); - - /* Enable WLAN function and verify MAILBOX2 is zero'd */ - csrResult = CsrSdioFunctionEnable(card->sdio_if); - if (csrResult != CSR_RESULT_SUCCESS) - { - r = ConvertCsrSdioToCsrHipResult(card, csrResult); - unifi_error(card->ospriv, "CsrSdioFunctionEnable failed %d\n", r); - break; - } - } - - r = unifi_read_direct16(card, ChipHelper_SDIO_HIP_HANDSHAKE(card->helper) * 2, &mbox2); - if (r != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, "read HIP_HANDSHAKE failed %d\n", r); - break; - } - if (mbox2 != 0) - { - unifi_error(card->ospriv, "MAILBOX2 non-zero after reset (mbox2 = %04x)\n", mbox2); - r = CSR_RESULT_FAILURE; - } - break; - } - else - { - if (card->chip_id > SDIO_CARD_ID_UNIFI_2) - { - /* We ignore read failures for the first few reads, - * they are probably benign. */ - if (i > MAILBOX2_ATTEMPTS / 4) - { - unifi_trace(card->ospriv, UDBG1, "Failed to read CCCR IO Ready register while polling for reset\n"); - } - } - else - { - unifi_trace(card->ospriv, UDBG1, "Failed to read CCCR IO Enable register while polling for reset\n"); - } - } - CsrThreadSleep(MAILBOX2_TIMEOUT); - } - - if (r == CSR_RESULT_SUCCESS && i == MAILBOX2_ATTEMPTS) - { - unifi_trace(card->ospriv, UDBG1, "Timeout waiting for UniFi to complete reset\n"); - r = CSR_RESULT_FAILURE; - } - - return r; -} /* card_wait_for_unifi_to_reset() */ - - -/* - * --------------------------------------------------------------------------- - * card_wait_for_unifi_to_disable - * - * Waits for the function to become disabled by polling the - * IO_READY bit. - * - * Arguments: - * card Pointer to card struct - * - * Returns: - * CSR_RESULT_SUCCESS on success, CSR error code on failure. - * - * Notes: This function can only be used with - * card->chip_id > SDIO_CARD_ID_UNIFI_2 - * --------------------------------------------------------------------------- - */ -static CsrResult card_wait_for_unifi_to_disable(card_t *card) -{ - s16 i; - CsrResult r; - u8 io_enable; - CsrResult csrResult; - - if (card->chip_id <= SDIO_CARD_ID_UNIFI_2) - { - unifi_error(card->ospriv, - "Function reset method not supported for chip_id=%d\n", - card->chip_id); - return CSR_RESULT_FAILURE; - } - - r = CSR_RESULT_SUCCESS; - for (i = 0; i < MAILBOX2_ATTEMPTS; i++) - { - unifi_trace(card->ospriv, UDBG1, "waiting for disable to complete, attempt %d\n", i); - - /* - * It's quite likely that this read will timeout for the - * first few tries - especially if we have reset via - * DBG_RESET. - */ -#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_SDIO_TRACE) - unifi_debug_log_to_buf("r0@%02X=", SDIO_IO_READY); -#endif - csrResult = CsrSdioF0Read8(card->sdio_if, SDIO_IO_READY, &io_enable); -#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_SDIO_TRACE) - if (csrResult != CSR_RESULT_SUCCESS) - { - unifi_debug_log_to_buf("error=%X\n", csrResult); - } - else - { - unifi_debug_log_to_buf("%X\n", io_enable); - } -#endif - if (csrResult == CSR_SDIO_RESULT_NO_DEVICE) - { - return CSR_WIFI_HIP_RESULT_NO_DEVICE; - } - if (csrResult == CSR_RESULT_SUCCESS) - { - s16 enabled = io_enable & (1 << card->function); - r = CSR_RESULT_SUCCESS; - if (!enabled) - { - unifi_trace(card->ospriv, UDBG1, - "Disable complete (function %d is disabled) in ~ %u msecs\n", - card->function, i * MAILBOX2_TIMEOUT); - - break; - } - } - else - { - /* - * We ignore read failures for the first few reads, - * they are probably benign. - */ - r = ConvertCsrSdioToCsrHipResult(card, csrResult); - if (i > (MAILBOX2_ATTEMPTS / 4)) - { - unifi_trace(card->ospriv, UDBG1, - "Failed to read CCCR IO Ready register while polling for disable\n"); - } - } - CsrThreadSleep(MAILBOX2_TIMEOUT); - } - - if ((r == CSR_RESULT_SUCCESS) && (i == MAILBOX2_ATTEMPTS)) - { - unifi_trace(card->ospriv, UDBG1, "Timeout waiting for UniFi to complete disable\n"); - r = CSR_RESULT_FAILURE; - } - - return r; -} /* card_wait_for_unifi_to_reset() */ - - -/* - * --------------------------------------------------------------------------- - * card_wait_for_firmware_to_start - * - * Polls the MAILBOX1 register for a non-zero value. - * Then reads MAILBOX0 and forms the two values into a 32-bit address - * which is returned to the caller. - * - * Arguments: - * card Pointer to card struct - * paddr Pointer to receive the UniFi address formed - * by concatenating MAILBOX1 and MAILBOX0. - * - * Returns: - * CSR_RESULT_SUCCESS on success, CSR error code on failure. - * --------------------------------------------------------------------------- - */ -CsrResult card_wait_for_firmware_to_start(card_t *card, u32 *paddr) -{ - s32 i; - u16 mbox0, mbox1; - CsrResult r; - - /* - * Wait for UniFi to initialise its data structures by polling - * the SHARED_MAILBOX1 register. - * Experience shows this is typically 120ms. - */ - CsrThreadSleep(MAILBOX1_TIMEOUT); - - mbox1 = 0; - unifi_trace(card->ospriv, UDBG1, "waiting for MAILBOX1 to be non-zero...\n"); - for (i = 0; i < MAILBOX1_ATTEMPTS; i++) - { - r = unifi_read_direct16(card, ChipHelper_MAILBOX1(card->helper) * 2, &mbox1); - if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE) - { - return r; - } - if (r != CSR_RESULT_SUCCESS) - { - /* These reads can fail if UniFi isn't up yet, so try again */ - unifi_warning(card->ospriv, "Failed to read UniFi Mailbox1 register\n"); - } - - if ((r == CSR_RESULT_SUCCESS) && (mbox1 != 0)) - { - unifi_trace(card->ospriv, UDBG1, "MAILBOX1 ready (0x%04X) in %u millisecs\n", - mbox1, i * MAILBOX1_TIMEOUT); - - /* Read the MAILBOX1 again in case we caught the value as it - * changed. */ - r = unifi_read_direct16(card, ChipHelper_MAILBOX1(card->helper) * 2, &mbox1); - if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE) - { - return r; - } - if (r != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, "Failed to read UniFi Mailbox1 register for second time\n"); - return r; - } - unifi_trace(card->ospriv, UDBG1, "MAILBOX1 value=0x%04X\n", mbox1); - - break; - } - - CsrThreadSleep(MAILBOX1_TIMEOUT); - if ((i % 100) == 99) - { - unifi_trace(card->ospriv, UDBG2, "MAILBOX1 not ready (0x%X), still trying...\n", mbox1); - } - } - - if ((r == CSR_RESULT_SUCCESS) && (mbox1 == 0)) - { - unifi_trace(card->ospriv, UDBG1, "Timeout waiting for firmware to start, Mailbox1 still 0 after %d ms\n", - MAILBOX1_ATTEMPTS * MAILBOX1_TIMEOUT); - return CSR_RESULT_FAILURE; - } - - - /* - * Complete the reset handshake by setting MAILBOX2 to 0xFFFF - */ - r = unifi_write_direct16(card, ChipHelper_SDIO_HIP_HANDSHAKE(card->helper) * 2, 0xFFFF); - if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE) - { - return r; - } - if (r != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, "Failed to write f/w startup handshake to MAILBOX2\n"); - return r; - } - - - /* - * Read the Symbol Look Up Table (SLUT) offset. - * Top 16 bits are in mbox1, read the lower 16 bits from mbox0. - */ - mbox0 = 0; - r = unifi_read_direct16(card, ChipHelper_MAILBOX0(card->helper) * 2, &mbox0); - if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE) - { - return r; - } - if (r != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, "Failed to read UniFi Mailbox0 register\n"); - return r; - } - - *paddr = (((u32)mbox1 << 16) | mbox0); - - return CSR_RESULT_SUCCESS; -} /* card_wait_for_firmware_to_start() */ - - -/* - * --------------------------------------------------------------------------- - * unifi_capture_panic - * - * Attempt to capture panic codes from the firmware. This may involve - * warm reset of the chip to regain access following a watchdog reset. - * - * Arguments: - * card Pointer to card struct - * - * Returns: - * CSR_RESULT_SUCCESS if panic codes were captured, or none available - * CSR_RESULT_FAILURE if the driver could not access function 1 - * --------------------------------------------------------------------------- - */ -CsrResult unifi_capture_panic(card_t *card) -{ - - /* The firmware must have previously initialised to read the panic addresses - * from the SLUT - */ - if (!card->panic_data_phy_addr || !card->panic_data_mac_addr) - { - return CSR_RESULT_SUCCESS; - } - - /* Ensure we can access function 1 following a panic/watchdog reset */ - if (card_access_panic(card) == CSR_RESULT_SUCCESS) - { - /* Read the panic codes */ - unifi_read_panic(card); - } - else - { - unifi_info(card->ospriv, "Unable to read panic codes"); - } - - return CSR_RESULT_SUCCESS; -} - - -/* - * --------------------------------------------------------------------------- - * card_access_panic - * Attempt to read the WLAN SDIO function in order to read panic codes - * and perform various reset steps to regain access if the read fails. - * - * Arguments: - * card Pointer to card struct - * - * Returns: - * CSR_RESULT_SUCCESS if panic codes can be read - * CSR error code if panic codes can not be read - * --------------------------------------------------------------------------- - */ -static CsrResult card_access_panic(card_t *card) -{ - u16 data_u16 = 0; - s32 i; - CsrResult r, sr; - - /* A chip version of zero means that the version never got successfully read - * during reset. In this case give up because it will not be possible to - * verify the chip version. - */ - if (!card->chip_version) - { - unifi_info(card->ospriv, "Unknown chip version\n"); - return CSR_RESULT_FAILURE; - } - - /* Ensure chip is awake or access to function 1 will fail */ - r = unifi_set_host_state(card, UNIFI_HOST_STATE_AWAKE); - if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE) - { - return r; - } - if (r != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, "unifi_set_host_state() failed %d\n", r); - return CSR_RESULT_FAILURE; /* Card is probably unpowered */ - } - CsrThreadSleep(20); - - for (i = 0; i < 3; i++) - { - sr = CsrSdioRead16(card->sdio_if, CHIP_HELPER_UNIFI_GBL_CHIP_VERSION * 2, &data_u16); - if (sr != CSR_RESULT_SUCCESS || data_u16 != card->chip_version) - { - unifi_info(card->ospriv, "Failed to read valid chip version sr=%d (0x%04x want 0x%04x) try %d\n", - sr, data_u16, card->chip_version, i); - - /* Set clock speed low */ - sr = CsrSdioMaxBusClockFrequencySet(card->sdio_if, UNIFI_SDIO_CLOCK_SAFE_HZ); - if (sr != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, "CsrSdioMaxBusClockFrequencySet() failed1 %d\n", sr); - r = ConvertCsrSdioToCsrHipResult(card, sr); - } - card->sdio_clock_speed = UNIFI_SDIO_CLOCK_SAFE_HZ; - - /* First try re-enabling function in case a f/w watchdog reset disabled it */ - if (i == 0) - { - unifi_info(card->ospriv, "Try function enable\n"); - sr = CsrSdioFunctionEnable(card->sdio_if); - if (sr != CSR_RESULT_SUCCESS) - { - r = ConvertCsrSdioToCsrHipResult(card, sr); - unifi_error(card->ospriv, "CsrSdioFunctionEnable failed %d (HIP %d)\n", sr, r); - } - continue; - } - - /* Second try, set awake */ - unifi_info(card->ospriv, "Try set awake\n"); - - /* Ensure chip is awake */ - r = unifi_set_host_state(card, UNIFI_HOST_STATE_AWAKE); - if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE) - { - return r; - } - if (r != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, "unifi_set_host_state() failed2 %d\n", r); - } - - /* Set clock speed low in case setting the host state raised it, which - * would only happen if host state was previously TORPID - */ - sr = CsrSdioMaxBusClockFrequencySet(card->sdio_if, UNIFI_SDIO_CLOCK_SAFE_HZ); - if (sr != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, "CsrSdioMaxBusClockFrequencySet() failed2 %d\n", sr); - } - card->sdio_clock_speed = UNIFI_SDIO_CLOCK_SAFE_HZ; - - if (i == 1) - { - continue; - } - - /* Perform a s/w reset to preserve as much as the card state as possible, - * (mainly the preserve RAM). The context will be lost for coredump - but as we - * were unable to access the WLAN function for panic, the coredump would have - * also failed without a reset. - */ - unifi_info(card->ospriv, "Try s/w reset\n"); - - r = unifi_card_hard_reset(card); - if (r != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, "unifi_card_hard_reset() failed %d\n", r); - } - } - else - { - if (i > 0) - { - unifi_info(card->ospriv, "Read chip version 0x%x after %d retries\n", data_u16, i); - } - break; - } - } - - r = ConvertCsrSdioToCsrHipResult(card, sr); - return r; -} - - -/* - * --------------------------------------------------------------------------- - * unifi_read_panic - * Reads, saves and prints panic codes stored by the firmware in UniFi's - * preserve RAM by the last panic that occurred since chip was powered. - * Nothing is saved if the panic codes are read as zero. - * - * Arguments: - * card Pointer to card struct - * - * Returns: - * --------------------------------------------------------------------------- - */ -void unifi_read_panic(card_t *card) -{ - CsrResult r; - u16 p_code, p_arg; - - /* The firmware must have previously initialised to read the panic addresses - * from the SLUT - */ - if (!card->panic_data_phy_addr || !card->panic_data_mac_addr) - { - return; - } - - /* Get the panic data from PHY */ - r = unifi_card_read16(card, card->panic_data_phy_addr, &p_code); - if (r != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, "capture_panic: unifi_read16 %08x failed %d\n", card->panic_data_phy_addr, r); - p_code = 0; - } - if (p_code) - { - r = unifi_card_read16(card, card->panic_data_phy_addr + 2, &p_arg); - if (r != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, "capture_panic: unifi_read16 %08x failed %d\n", card->panic_data_phy_addr + 2, r); - } - unifi_error(card->ospriv, "Last UniFi PHY PANIC %04x arg %04x\n", p_code, p_arg); - card->last_phy_panic_code = p_code; - card->last_phy_panic_arg = p_arg; - } - - /* Get the panic data from MAC */ - r = unifi_card_read16(card, card->panic_data_mac_addr, &p_code); - if (r != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, "capture_panic: unifi_read16 %08x failed %d\n", card->panic_data_mac_addr, r); - p_code = 0; - } - if (p_code) - { - r = unifi_card_read16(card, card->panic_data_mac_addr + 2, &p_arg); - if (r != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, "capture_panic: unifi_read16 %08x failed %d\n", card->panic_data_mac_addr + 2, r); - } - unifi_error(card->ospriv, "Last UniFi MAC PANIC %04x arg %04x\n", p_code, p_arg); - card->last_mac_panic_code = p_code; - card->last_mac_panic_arg = p_arg; - } - -} - - -/* - * --------------------------------------------------------------------------- - * card_allocate_memory_resources - * - * Allocates memory for the from-host, to-host bulk data slots, - * soft queue buffers and bulk data buffers. - * - * Arguments: - * card Pointer to card struct - * - * Returns: - * CSR_RESULT_SUCCESS on success, CSR error code on failure. - * --------------------------------------------------------------------------- - */ -static CsrResult card_allocate_memory_resources(card_t *card) -{ - s16 n, i, k, r; - sdio_config_data_t *cfg_data; - - /* Reset any state carried forward from a previous life */ - card->fh_command_queue.q_rd_ptr = 0; - card->fh_command_queue.q_wr_ptr = 0; - (void)scnprintf(card->fh_command_queue.name, UNIFI_QUEUE_NAME_MAX_LENGTH, - "fh_cmd_q"); - for (i = 0; i < UNIFI_NO_OF_TX_QS; i++) - { - card->fh_traffic_queue[i].q_rd_ptr = 0; - card->fh_traffic_queue[i].q_wr_ptr = 0; - (void)scnprintf(card->fh_traffic_queue[i].name, - UNIFI_QUEUE_NAME_MAX_LENGTH, "fh_data_q%d", i); - } -#ifndef CSR_WIFI_HIP_TA_DISABLE - unifi_ta_sampling_init(card); -#endif - /* Convenience short-cut */ - cfg_data = &card->config_data; - - /* - * Allocate memory for the from-host and to-host signal buffers. - */ - card->fh_buffer.buf = kmalloc(UNIFI_FH_BUF_SIZE, GFP_KERNEL); - if (card->fh_buffer.buf == NULL) - { - unifi_error(card->ospriv, "Failed to allocate memory for F-H signals\n"); - return CSR_WIFI_HIP_RESULT_NO_MEMORY; - } - card->fh_buffer.bufsize = UNIFI_FH_BUF_SIZE; - card->fh_buffer.ptr = card->fh_buffer.buf; - card->fh_buffer.count = 0; - - card->th_buffer.buf = kmalloc(UNIFI_FH_BUF_SIZE, GFP_KERNEL); - if (card->th_buffer.buf == NULL) - { - unifi_error(card->ospriv, "Failed to allocate memory for T-H signals\n"); - return CSR_WIFI_HIP_RESULT_NO_MEMORY; - } - card->th_buffer.bufsize = UNIFI_FH_BUF_SIZE; - card->th_buffer.ptr = card->th_buffer.buf; - card->th_buffer.count = 0; - - - /* - * Allocate memory for the from-host and to-host bulk data slots. - * This is done as separate kmallocs because lots of smaller - * allocations are more likely to succeed than one huge one. - */ - - /* Allocate memory for the array of pointers */ - n = cfg_data->num_fromhost_data_slots; - - unifi_trace(card->ospriv, UDBG3, "Alloc from-host resources, %d slots.\n", n); - card->from_host_data = kmalloc(n * sizeof(slot_desc_t), GFP_KERNEL); - if (card->from_host_data == NULL) - { - unifi_error(card->ospriv, "Failed to allocate memory for F-H bulk data array\n"); - return CSR_WIFI_HIP_RESULT_NO_MEMORY; - } - - /* Initialise from-host bulk data slots */ - for (i = 0; i < n; i++) - { - UNIFI_INIT_BULK_DATA(&card->from_host_data[i].bd); - } - - /* Allocate memory for the array used for slot host tag mapping */ - card->fh_slot_host_tag_record = kmalloc(n * sizeof(u32), GFP_KERNEL); - - if (card->fh_slot_host_tag_record == NULL) - { - unifi_error(card->ospriv, "Failed to allocate memory for F-H slot host tag mapping array\n"); - return CSR_WIFI_HIP_RESULT_NO_MEMORY; - } - - /* Initialise host tag entries for from-host bulk data slots */ - for (i = 0; i < n; i++) - { - card->fh_slot_host_tag_record[i] = CSR_WIFI_HIP_RESERVED_HOST_TAG; - } - - - /* Allocate memory for the array of pointers */ - n = cfg_data->num_tohost_data_slots; - - unifi_trace(card->ospriv, UDBG3, "Alloc to-host resources, %d slots.\n", n); - card->to_host_data = kmalloc(n * sizeof(bulk_data_desc_t), GFP_KERNEL); - if (card->to_host_data == NULL) - { - unifi_error(card->ospriv, "Failed to allocate memory for T-H bulk data array\n"); - return CSR_WIFI_HIP_RESULT_NO_MEMORY; - } - - /* Initialise to-host bulk data slots */ - for (i = 0; i < n; i++) - { - UNIFI_INIT_BULK_DATA(&card->to_host_data[i]); - } - - /* - * Initialise buffers for soft Q - */ - for (i = 0; i < UNIFI_SOFT_COMMAND_Q_LENGTH; i++) - { - for (r = 0; r < UNIFI_MAX_DATA_REFERENCES; r++) - { - UNIFI_INIT_BULK_DATA(&card->fh_command_q_body[i].bulkdata[r]); - } - } - - for (k = 0; k < UNIFI_NO_OF_TX_QS; k++) - { - for (i = 0; i < UNIFI_SOFT_TRAFFIC_Q_LENGTH; i++) - { - for (r = 0; r < UNIFI_MAX_DATA_REFERENCES; r++) - { - UNIFI_INIT_BULK_DATA(&card->fh_traffic_q_body[k][i].bulkdata[r]); - } - } - } - - card->memory_resources_allocated = 1; - - return CSR_RESULT_SUCCESS; -} /* card_allocate_memory_resources() */ - - -/* - * --------------------------------------------------------------------------- - * unifi_free_bulk_data - * - * Free the data associated to a bulk data structure. - * - * Arguments: - * card Pointer to card struct - * bulk_data_slot Pointer to bulk data structure - * - * Returns: - * None. - * - * --------------------------------------------------------------------------- - */ -static void unifi_free_bulk_data(card_t *card, bulk_data_desc_t *bulk_data_slot) -{ - if (bulk_data_slot->data_length != 0) - { - unifi_net_data_free(card->ospriv, bulk_data_slot); - } -} /* unifi_free_bulk_data() */ - - -/* - * --------------------------------------------------------------------------- - * card_free_memory_resources - * - * Frees memory allocated for the from-host, to-host bulk data slots, - * soft queue buffers and bulk data buffers. - * - * Arguments: - * card Pointer to card struct - * - * Returns: - * None. - * --------------------------------------------------------------------------- - */ -static void card_free_memory_resources(card_t *card) -{ - - unifi_trace(card->ospriv, UDBG1, "Freeing card memory resources.\n"); - - /* Clear our internal queues */ - unifi_cancel_pending_signals(card); - - - kfree(card->to_host_data); - card->to_host_data = NULL; - - kfree(card->from_host_data); - card->from_host_data = NULL; - - /* free the memory for slot host tag mapping array */ - kfree(card->fh_slot_host_tag_record); - card->fh_slot_host_tag_record = NULL; - - kfree(card->fh_buffer.buf); - card->fh_buffer.ptr = card->fh_buffer.buf = NULL; - card->fh_buffer.bufsize = 0; - card->fh_buffer.count = 0; - - kfree(card->th_buffer.buf); - card->th_buffer.ptr = card->th_buffer.buf = NULL; - card->th_buffer.bufsize = 0; - card->th_buffer.count = 0; - - - card->memory_resources_allocated = 0; - -} /* card_free_memory_resources() */ - - -static void card_init_soft_queues(card_t *card) -{ - s16 i; - - unifi_trace(card->ospriv, UDBG1, "Initialising internal signal queues.\n"); - /* Reset any state carried forward from a previous life */ - card->fh_command_queue.q_rd_ptr = 0; - card->fh_command_queue.q_wr_ptr = 0; - (void)scnprintf(card->fh_command_queue.name, UNIFI_QUEUE_NAME_MAX_LENGTH, - "fh_cmd_q"); - for (i = 0; i < UNIFI_NO_OF_TX_QS; i++) - { - card->fh_traffic_queue[i].q_rd_ptr = 0; - card->fh_traffic_queue[i].q_wr_ptr = 0; - (void)scnprintf(card->fh_traffic_queue[i].name, - UNIFI_QUEUE_NAME_MAX_LENGTH, "fh_data_q%d", i); - } -#ifndef CSR_WIFI_HIP_TA_DISABLE - unifi_ta_sampling_init(card); -#endif -} - - -/* - * --------------------------------------------------------------------------- - * unifi_cancel_pending_signals - * - * Free the signals and associated bulk data, pending in the core. - * - * Arguments: - * card Pointer to card struct - * - * Returns: - * None. - * --------------------------------------------------------------------------- - */ -void unifi_cancel_pending_signals(card_t *card) -{ - s16 i, n, r; - - unifi_trace(card->ospriv, UDBG1, "Canceling pending signals.\n"); - - if (card->to_host_data) - { - /* - * Free any bulk data buffers allocated for the t-h slots - * This will clear all buffers that did not make it to - * unifi_receive_event() before cancel was request. - */ - n = card->config_data.num_tohost_data_slots; - unifi_trace(card->ospriv, UDBG3, "Freeing to-host resources, %d slots.\n", n); - for (i = 0; i < n; i++) - { - unifi_free_bulk_data(card, &card->to_host_data[i]); - } - } - - /* - * If any of the from-host bulk data has reached the card->from_host_data - * but not UniFi, we need to free the buffers here. - */ - if (card->from_host_data) - { - /* Free any bulk data buffers allocated for the f-h slots */ - n = card->config_data.num_fromhost_data_slots; - unifi_trace(card->ospriv, UDBG3, "Freeing from-host resources, %d slots.\n", n); - for (i = 0; i < n; i++) - { - unifi_free_bulk_data(card, &card->from_host_data[i].bd); - } - - for (i = 0; i < UNIFI_NO_OF_TX_QS; i++) - { - card->dynamic_slot_data.from_host_used_slots[i] = 0; - card->dynamic_slot_data.from_host_max_slots[i] = 0; - card->dynamic_slot_data.from_host_reserved_slots[i] = 0; - } - } - - /* - * Free any bulk data buffers allocated in the soft queues. - * This covers the case where a bulk data pointer has reached the soft queue - * but not the card->from_host_data. - */ - unifi_trace(card->ospriv, UDBG3, "Freeing cmd q resources.\n"); - for (i = 0; i < UNIFI_SOFT_COMMAND_Q_LENGTH; i++) - { - for (r = 0; r < UNIFI_MAX_DATA_REFERENCES; r++) - { - unifi_free_bulk_data(card, &card->fh_command_q_body[i].bulkdata[r]); - } - } - - unifi_trace(card->ospriv, UDBG3, "Freeing traffic q resources.\n"); - for (n = 0; n < UNIFI_NO_OF_TX_QS; n++) - { - for (i = 0; i < UNIFI_SOFT_TRAFFIC_Q_LENGTH; i++) - { - for (r = 0; r < UNIFI_MAX_DATA_REFERENCES; r++) - { - unifi_free_bulk_data(card, &card->fh_traffic_q_body[n][i].bulkdata[r]); - } - } - } - - card_init_soft_queues(card); - -} /* unifi_cancel_pending_signals() */ - - -/* - * --------------------------------------------------------------------------- - * unifi_free_card - * - * Free the memory allocated for the card structure and buffers. - * - * Notes: - * The porting layer is responsible for freeing any mini-coredump buffers - * allocated when it called unifi_coredump_init(), by calling - * unifi_coredump_free() before calling this function. - * - * Arguments: - * card Pointer to card struct - * - * Returns: - * None. - * --------------------------------------------------------------------------- - */ -void unifi_free_card(card_t *card) -{ -#ifdef CSR_PRE_ALLOC_NET_DATA - prealloc_netdata_free(card); -#endif - /* Free any memory allocated. */ - card_free_memory_resources(card); - - /* Warn if caller didn't free coredump buffers */ - if (card->dump_buf) - { - unifi_error(card->ospriv, "Caller should call unifi_coredump_free()\n"); - unifi_coredump_free(card); /* free anyway to prevent memory leak */ - } - - kfree(card); - -} /* unifi_free_card() */ - - -/* - * --------------------------------------------------------------------------- - * card_init_slots - * - * Allocate memory for host-side slot data and signal queues. - * - * Arguments: - * card Pointer to card object - * - * Returns: - * CSR error code. - * --------------------------------------------------------------------------- - */ -static CsrResult card_init_slots(card_t *card) -{ - CsrResult r; - u8 i; - - /* Allocate the buffers we need, only once. */ - if (card->memory_resources_allocated == 1) - { - card_free_memory_resources(card); - } - else - { - /* Initialise our internal command and traffic queues */ - card_init_soft_queues(card); - } - - r = card_allocate_memory_resources(card); - if (r != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, "Failed to allocate card memory resources.\n"); - card_free_memory_resources(card); - return r; - } - - if (card->sdio_ctrl_addr == 0) - { - unifi_error(card->ospriv, "Failed to find config struct!\n"); - return CSR_WIFI_HIP_RESULT_INVALID_VALUE; - } - - /* - * Set initial counts. - */ - - card->from_host_data_head = 0; - - /* Get initial signal counts from UniFi, in case it has not been reset. */ - { - u16 s; - - /* Get the from-host-signals-written count */ - r = unifi_card_read16(card, card->sdio_ctrl_addr + 0, &s); - if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE) - { - return r; - } - if (r != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, "Failed to read from-host sig written count\n"); - return r; - } - card->from_host_signals_w = (s16)s; - - /* Get the to-host-signals-written count */ - r = unifi_card_read16(card, card->sdio_ctrl_addr + 6, &s); - if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE) - { - return r; - } - if (r != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, "Failed to read to-host sig read count\n"); - return r; - } - card->to_host_signals_r = (s16)s; - } - - /* Set Initialised flag. */ - r = unifi_card_write16(card, card->init_flag_addr, 0x0001); - if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE) - { - return r; - } - if (r != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, "Failed to write initialised flag\n"); - return r; - } - - /* Dynamic queue reservation */ - memset(&card->dynamic_slot_data, 0, sizeof(card_dynamic_slot_t)); - - for (i = 0; i < UNIFI_NO_OF_TX_QS; i++) - { - card->dynamic_slot_data.from_host_max_slots[i] = card->config_data.num_fromhost_data_slots - - UNIFI_RESERVED_COMMAND_SLOTS; - card->dynamic_slot_data.queue_stable[i] = FALSE; - } - - card->dynamic_slot_data.packets_interval = UNIFI_PACKETS_INTERVAL; - - return CSR_RESULT_SUCCESS; -} /* card_init_slots() */ - - -/* - * --------------------------------------------------------------------------- - * unifi_set_udi_hook - * - * Registers the udi hook that reports the sent signals to the core. - * - * Arguments: - * card Pointer to the card context struct - * udi_fn Pointer to the callback function. - * - * Returns: - * CSR_WIFI_HIP_RESULT_INVALID_VALUE if the card pointer is invalid, - * CSR_RESULT_SUCCESS on success. - * --------------------------------------------------------------------------- - */ -CsrResult unifi_set_udi_hook(card_t *card, udi_func_t udi_fn) -{ - if (card == NULL) - { - return CSR_WIFI_HIP_RESULT_INVALID_VALUE; - } - - if (card->udi_hook == NULL) - { - card->udi_hook = udi_fn; - } - - return CSR_RESULT_SUCCESS; -} /* unifi_set_udi_hook() */ - - -/* - * --------------------------------------------------------------------------- - * unifi_remove_udi_hook - * - * Removes the udi hook that reports the sent signals from the core. - * - * Arguments: - * card Pointer to the card context struct - * udi_fn Pointer to the callback function. - * - * Returns: - * CSR_WIFI_HIP_RESULT_INVALID_VALUE if the card pointer is invalid, - * CSR_RESULT_SUCCESS on success. - * --------------------------------------------------------------------------- - */ -CsrResult unifi_remove_udi_hook(card_t *card, udi_func_t udi_fn) -{ - if (card == NULL) - { - return CSR_WIFI_HIP_RESULT_INVALID_VALUE; - } - - if (card->udi_hook == udi_fn) - { - card->udi_hook = NULL; - } - - return CSR_RESULT_SUCCESS; -} /* unifi_remove_udi_hook() */ - - -static void CardReassignDynamicReservation(card_t *card) -{ - u8 i; - - unifi_trace(card->ospriv, UDBG5, "Packets Txed %d %d %d %d\n", - card->dynamic_slot_data.packets_txed[0], - card->dynamic_slot_data.packets_txed[1], - card->dynamic_slot_data.packets_txed[2], - card->dynamic_slot_data.packets_txed[3]); - - /* Clear reservation and recalculate max slots */ - for (i = 0; i < UNIFI_NO_OF_TX_QS; i++) - { - card->dynamic_slot_data.queue_stable[i] = FALSE; - card->dynamic_slot_data.from_host_reserved_slots[i] = 0; - card->dynamic_slot_data.from_host_max_slots[i] = card->config_data.num_fromhost_data_slots - - UNIFI_RESERVED_COMMAND_SLOTS; - card->dynamic_slot_data.packets_txed[i] = 0; - - unifi_trace(card->ospriv, UDBG5, "CardReassignDynamicReservation: queue %d reserved %d Max %d\n", i, - card->dynamic_slot_data.from_host_reserved_slots[i], - card->dynamic_slot_data.from_host_max_slots[i]); - } - - card->dynamic_slot_data.total_packets_txed = 0; -} - - -/* Algorithm to dynamically reserve slots. The logic is based mainly on the outstanding queue - * length. Slots are reserved for particular queues during an interval and cleared after the interval. - * Each queue has three associated variables.. a) used slots - the number of slots currently occupied - * by the queue b) reserved slots - number of slots reserved specifically for the queue c) max slots - total - * slots that this queue can actually use (may be higher than reserved slots and is dependent on reserved slots - * for other queues). - * This function is called when there are no slots available for a queue. It checks to see if there are enough - * unreserved slots sufficient for this request. If available these slots are reserved for the queue. - * If there are not enough unreserved slots, a fair share for each queue is calculated based on the total slots - * and the number of active queues (any queue with existing reservation is considered active). Queues needing - * less than their fair share are allowed to have the previously reserved slots. The remaining slots are - * distributed evenly among queues that need more than the fair share - * - * A better scheme would take current bandwidth per AC into consideration when reserving slots. An - * implementation scheme could consider the relative time/service period for slots in an AC. If the firmware - * services other ACs faster than a particular AC (packets wait in the slots longer) then it is fair to reserve - * less slots for the AC - */ -static void CardCheckDynamicReservation(card_t *card, unifi_TrafficQueue queue) -{ - u16 q_len, active_queues = 0, excess_queue_slots, div_extra_slots, - queue_fair_share, reserved_slots = 0, q, excess_need_queues = 0, unmovable_slots = 0; - s32 i; - q_t *sigq; - u16 num_data_slots = card->config_data.num_fromhost_data_slots - UNIFI_RESERVED_COMMAND_SLOTS; - - /* Calculate the pending queue length */ - sigq = &card->fh_traffic_queue[queue]; - q_len = CSR_WIFI_HIP_Q_SLOTS_USED(sigq); - - if (q_len <= card->dynamic_slot_data.from_host_reserved_slots[queue]) - { - unifi_trace(card->ospriv, UDBG5, "queue %d q_len %d already has that many reserved slots, exiting\n", queue, q_len); - return; - } - - /* Upper limit */ - if (q_len > num_data_slots) - { - q_len = num_data_slots; - } - - for (i = 0; i < UNIFI_NO_OF_TX_QS; i++) - { - if (i != (s32)queue) - { - reserved_slots += card->dynamic_slot_data.from_host_reserved_slots[i]; - } - if ((i == (s32)queue) || (card->dynamic_slot_data.from_host_reserved_slots[i] > 0)) - { - active_queues++; - } - } - - unifi_trace(card->ospriv, UDBG5, "CardCheckDynamicReservation: queue %d q_len %d\n", queue, q_len); - unifi_trace(card->ospriv, UDBG5, "Active queues %d reserved slots on other queues %d\n", - active_queues, reserved_slots); - - if (reserved_slots + q_len <= num_data_slots) - { - card->dynamic_slot_data.from_host_reserved_slots[queue] = q_len; - if (q_len == num_data_slots) - { - /* This is the common case when just 1 stream is going */ - card->dynamic_slot_data.queue_stable[queue] = TRUE; - } - } - else - { - queue_fair_share = num_data_slots / active_queues; - unifi_trace(card->ospriv, UDBG5, "queue fair share %d\n", queue_fair_share); - - /* Evenly distribute slots among active queues */ - /* Find out the queues that need excess of fair share. Also find slots allocated - * to queues less than their fair share, these slots cannot be reallocated (unmovable slots) */ - - card->dynamic_slot_data.from_host_reserved_slots[queue] = q_len; - - for (i = 0; i < UNIFI_NO_OF_TX_QS; i++) - { - if (card->dynamic_slot_data.from_host_reserved_slots[i] > queue_fair_share) - { - excess_need_queues++; - } - else - { - unmovable_slots += card->dynamic_slot_data.from_host_reserved_slots[i]; - } - } - - unifi_trace(card->ospriv, UDBG5, "Excess need queues %d\n", excess_need_queues); - - /* Now find the slots per excess demand queue */ - excess_queue_slots = (num_data_slots - unmovable_slots) / excess_need_queues; - div_extra_slots = (num_data_slots - unmovable_slots) - excess_queue_slots * excess_need_queues; - for (i = UNIFI_NO_OF_TX_QS - 1; i >= 0; i--) - { - if (card->dynamic_slot_data.from_host_reserved_slots[i] > excess_queue_slots) - { - card->dynamic_slot_data.from_host_reserved_slots[i] = excess_queue_slots; - if (div_extra_slots > 0) - { - card->dynamic_slot_data.from_host_reserved_slots[i]++; - div_extra_slots--; - } - /* No more slots will be allocated to this queue during the current interval */ - card->dynamic_slot_data.queue_stable[i] = TRUE; - unifi_trace(card->ospriv, UDBG5, "queue stable %d\n", i); - } - } - } - - /* Redistribute max slots */ - for (i = 0; i < UNIFI_NO_OF_TX_QS; i++) - { - reserved_slots = 0; - for (q = 0; q < UNIFI_NO_OF_TX_QS; q++) - { - if (i != q) - { - reserved_slots += card->dynamic_slot_data.from_host_reserved_slots[q]; - } - } - - card->dynamic_slot_data.from_host_max_slots[i] = num_data_slots - reserved_slots; - unifi_trace(card->ospriv, UDBG5, "queue %d reserved %d Max %d\n", i, - card->dynamic_slot_data.from_host_reserved_slots[i], - card->dynamic_slot_data.from_host_max_slots[i]); - } - -} - - -/* - * --------------------------------------------------------------------------- - * CardClearFromHostDataSlot - * - * Clear a the given data slot, making it available again. - * - * Arguments: - * card Pointer to Card object - * slot Index of the signal slot to clear. - * - * Returns: - * None. - * --------------------------------------------------------------------------- - */ -void CardClearFromHostDataSlot(card_t *card, const s16 slot) -{ - u8 queue = card->from_host_data[slot].queue; - const void *os_data_ptr = card->from_host_data[slot].bd.os_data_ptr; - - if (card->from_host_data[slot].bd.data_length == 0) - { - unifi_warning(card->ospriv, - "Surprise: request to clear an already free FH data slot: %d\n", - slot); - return; - } - - if (os_data_ptr == NULL) - { - unifi_warning(card->ospriv, - "Clearing FH data slot %d: has null payload, len=%d\n", - slot, card->from_host_data[slot].bd.data_length); - } - - /* Free card->from_host_data[slot].bd.os_net_ptr here. */ - /* Mark slot as free by setting length to 0. */ - unifi_free_bulk_data(card, &card->from_host_data[slot].bd); - if (queue < UNIFI_NO_OF_TX_QS) - { - if (card->dynamic_slot_data.from_host_used_slots[queue] == 0) - { - unifi_error(card->ospriv, "Goofed up used slots q = %d used slots = %d\n", - queue, - card->dynamic_slot_data.from_host_used_slots[queue]); - } - else - { - card->dynamic_slot_data.from_host_used_slots[queue]--; - } - card->dynamic_slot_data.packets_txed[queue]++; - card->dynamic_slot_data.total_packets_txed++; - if (card->dynamic_slot_data.total_packets_txed >= card->dynamic_slot_data.packets_interval) - { - CardReassignDynamicReservation(card); - } - } - - unifi_trace(card->ospriv, UDBG4, "CardClearFromHostDataSlot: slot %d recycled %p\n", slot, os_data_ptr); - -} /* CardClearFromHostDataSlot() */ - - -#ifdef CSR_WIFI_REQUEUE_PACKET_TO_HAL -/* - * --------------------------------------------------------------------------- - * CardClearFromHostDataSlotWithoutFreeingBulkData - * - * Clear the given data slot with out freeing the bulk data. - * - * Arguments: - * card Pointer to Card object - * slot Index of the signal slot to clear. - * - * Returns: - * None. - * --------------------------------------------------------------------------- - */ -void CardClearFromHostDataSlotWithoutFreeingBulkData(card_t *card, const s16 slot) -{ - u8 queue = card->from_host_data[slot].queue; - - /* Initialise the from_host data slot so it can be re-used, - * Set length field in from_host_data array to 0. - */ - UNIFI_INIT_BULK_DATA(&card->from_host_data[slot].bd); - - queue = card->from_host_data[slot].queue; - - if (queue < UNIFI_NO_OF_TX_QS) - { - if (card->dynamic_slot_data.from_host_used_slots[queue] == 0) - { - unifi_error(card->ospriv, "Goofed up used slots q = %d used slots = %d\n", - queue, - card->dynamic_slot_data.from_host_used_slots[queue]); - } - else - { - card->dynamic_slot_data.from_host_used_slots[queue]--; - } - card->dynamic_slot_data.packets_txed[queue]++; - card->dynamic_slot_data.total_packets_txed++; - if (card->dynamic_slot_data.total_packets_txed >= - card->dynamic_slot_data.packets_interval) - { - CardReassignDynamicReservation(card); - } - } -} /* CardClearFromHostDataSlotWithoutFreeingBulkData() */ - - -#endif - -u16 CardGetDataSlotSize(card_t *card) -{ - return card->config_data.data_slot_size; -} /* CardGetDataSlotSize() */ - - -/* - * --------------------------------------------------------------------------- - * CardGetFreeFromHostDataSlots - * - * Retrieve the number of from-host bulk data slots available. - * - * Arguments: - * card Pointer to the card context struct - * - * Returns: - * Number of free from-host bulk data slots. - * --------------------------------------------------------------------------- - */ -u16 CardGetFreeFromHostDataSlots(card_t *card) -{ - u16 i, n = 0; - - /* First two slots reserved for MLME */ - for (i = 0; i < card->config_data.num_fromhost_data_slots; i++) - { - if (card->from_host_data[i].bd.data_length == 0) - { - /* Free slot */ - n++; - } - } - - return n; -} /* CardGetFreeFromHostDataSlots() */ - - -/* - * --------------------------------------------------------------------------- - * CardAreAllFromHostDataSlotsEmpty - * - * Returns the state of from-host bulk data slots. - * - * Arguments: - * card Pointer to the card context struct - * - * Returns: - * 1 The from-host bulk data slots are all empty (available). - * 0 Some or all the from-host bulk data slots are in use. - * --------------------------------------------------------------------------- - */ -u16 CardAreAllFromHostDataSlotsEmpty(card_t *card) -{ - u16 i; - - for (i = 0; i < card->config_data.num_fromhost_data_slots; i++) - { - if (card->from_host_data[i].bd.data_length != 0) - { - return 0; - } - } - - return 1; -} /* CardGetFreeFromHostDataSlots() */ - - -static CsrResult unifi_identify_hw(card_t *card) -{ - - card->chip_id = card->sdio_if->sdioId.cardId; - card->function = card->sdio_if->sdioId.sdioFunction; - card->sdio_io_block_size = card->sdio_if->blockSize; - - /* If SDIO controller doesn't support byte mode CMD53, pad transfers to block sizes */ - card->sdio_io_block_pad = (card->sdio_if->features & CSR_SDIO_FEATURE_BYTE_MODE)?FALSE : TRUE; - - /* - * Setup the chip helper so that we can access the registers (and - * also tell what sub-type of HIP we should use). - */ - card->helper = ChipHelper_GetVersionSdio((u8)card->chip_id); - if (!card->helper) - { - unifi_error(card->ospriv, "Null ChipHelper\n"); - } - - unifi_info(card->ospriv, "Chip ID 0x%02X Function %u Block Size %u Name %s(%s)\n", - card->chip_id, card->function, card->sdio_io_block_size, - ChipHelper_MarketingName(card->helper), - ChipHelper_FriendlyName(card->helper)); - - return CSR_RESULT_SUCCESS; -} /* unifi_identify_hw() */ - - -static CsrResult unifi_prepare_hw(card_t *card) -{ - CsrResult r; - CsrResult csrResult; - enum unifi_host_state old_state = card->host_state; - - r = unifi_identify_hw(card); - if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE) - { - return r; - } - if (r != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, "Failed to identify hw\n"); - return r; - } - - unifi_trace(card->ospriv, UDBG1, - "%s mode SDIO\n", card->sdio_io_block_pad?"Block" : "Byte"); - /* - * Chip must be a awake or blocks that are asleep may not get - * reset. We can only do this after we have read the chip_id. - */ - r = unifi_set_host_state(card, UNIFI_HOST_STATE_AWAKE); - if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE) - { - return r; - } - - if (old_state == UNIFI_HOST_STATE_TORPID) - { - /* Ensure the initial clock rate is set; if a reset occurred when the chip was - * TORPID, unifi_set_host_state() may have raised it to MAX. - */ - csrResult = CsrSdioMaxBusClockFrequencySet(card->sdio_if, UNIFI_SDIO_CLOCK_INIT_HZ); - if (csrResult != CSR_RESULT_SUCCESS) - { - r = ConvertCsrSdioToCsrHipResult(card, csrResult); - return r; - } - card->sdio_clock_speed = UNIFI_SDIO_CLOCK_INIT_HZ; - } - - /* - * The WLAN function must be enabled to access MAILBOX2 and DEBUG_RST - * registers. - */ - csrResult = CsrSdioFunctionEnable(card->sdio_if); - if (csrResult == CSR_SDIO_RESULT_NO_DEVICE) - { - return CSR_WIFI_HIP_RESULT_NO_DEVICE; - } - if (csrResult != CSR_RESULT_SUCCESS) - { - r = ConvertCsrSdioToCsrHipResult(card, csrResult); - /* Can't enable WLAN function. Try resetting the SDIO block. */ - unifi_error(card->ospriv, "Failed to re-enable function %d.\n", card->function); - return r; - } - - /* - * Poke some registers to make sure the PLL has started, - * otherwise memory accesses are likely to fail. - */ - bootstrap_chip_hw(card); - - /* Try to read the chip version from register. */ - r = unifi_read_chip_version(card); - if (r != CSR_RESULT_SUCCESS) - { - return r; - } - - return CSR_RESULT_SUCCESS; -} /* unifi_prepare_hw() */ - - -static CsrResult unifi_read_chip_version(card_t *card) -{ - u32 gbl_chip_version; - CsrResult r; - u16 ver; - - gbl_chip_version = ChipHelper_GBL_CHIP_VERSION(card->helper); - - /* Try to read the chip version from register. */ - if (gbl_chip_version != 0) - { - r = unifi_read_direct16(card, gbl_chip_version * 2, &ver); - if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE) - { - return r; - } - if (r != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, "Failed to read GBL_CHIP_VERSION\n"); - return r; - } - card->chip_version = ver; - } - else - { - unifi_info(card->ospriv, "Unknown Chip ID, cannot locate GBL_CHIP_VERSION\n"); - r = CSR_RESULT_FAILURE; - } - - unifi_info(card->ospriv, "Chip Version 0x%04X\n", card->chip_version); - - return r; -} /* unifi_read_chip_version() */ - - -/* - * --------------------------------------------------------------------------- - * unifi_reset_hardware - * - * Execute the UniFi reset sequence. - * - * Note: This may fail if the chip is going TORPID so retry at - * least once. - * - * Arguments: - * card - pointer to card context structure - * - * Returns: - * CSR_RESULT_SUCCESS on success, CSR error otherwise. - * - * Notes: - * Some platforms (e.g. Windows Vista) do not allow access to registers - * that are necessary for a software soft reset. - * --------------------------------------------------------------------------- - */ -static CsrResult unifi_reset_hardware(card_t *card) -{ - CsrResult r; - u16 new_block_size = UNIFI_IO_BLOCK_SIZE; - CsrResult csrResult; - - /* Errors returned by unifi_prepare_hw() are not critical at this point */ - r = unifi_prepare_hw(card); - if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE) - { - return r; - } - - /* First try SDIO controller reset, which may power cycle the UniFi, assert - * its reset line, or not be implemented depending on the platform. - */ - unifi_info(card->ospriv, "Calling CsrSdioHardReset\n"); - csrResult = CsrSdioHardReset(card->sdio_if); - if (csrResult == CSR_RESULT_SUCCESS) - { - unifi_info(card->ospriv, "CsrSdioHardReset succeeded on resetting UniFi\n"); - r = unifi_prepare_hw(card); - if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE) - { - return r; - } - if (r != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, "unifi_prepare_hw failed after hard reset\n"); - return r; - } - } - else if (csrResult == CSR_SDIO_RESULT_NO_DEVICE) - { - return CSR_WIFI_HIP_RESULT_NO_DEVICE; - } - else - { - /* Falling back to software hard reset methods */ - unifi_info(card->ospriv, "Falling back to software hard reset\n"); - r = unifi_card_hard_reset(card); - if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE) - { - return r; - } - if (r != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, "software hard reset failed\n"); - return r; - } - - /* If we fell back to unifi_card_hard_reset() methods, chip version may - * not have been read. (Note in the unlikely event that it is zero, - * it will be harmlessly read again) - */ - if (card->chip_version == 0) - { - r = unifi_read_chip_version(card); - if (r != CSR_RESULT_SUCCESS) - { - return r; - } - } - } - -#ifdef CSR_WIFI_HIP_SDIO_BLOCK_SIZE - new_block_size = CSR_WIFI_HIP_SDIO_BLOCK_SIZE; -#endif - - /* After hard reset, we need to restore the SDIO block size */ - csrResult = CsrSdioBlockSizeSet(card->sdio_if, new_block_size); - r = ConvertCsrSdioToCsrHipResult(card, csrResult); - - /* Warn if a different block size was achieved by the transport */ - if (card->sdio_if->blockSize != new_block_size) - { - unifi_info(card->ospriv, - "Actually got block size %d\n", card->sdio_if->blockSize); - } - - /* sdio_io_block_size always needs be updated from the achieved block size, - * as it is used by the OS layer to allocate memory in unifi_net_malloc(). - * Controllers which don't support block mode (e.g. CSPI) will report a - * block size of zero. - */ - if (card->sdio_if->blockSize == 0) - { - unifi_info(card->ospriv, "Block size 0, block mode not available\n"); - - /* Set sdio_io_block_size to 1 so that unifi_net_data_malloc() has a - * sensible rounding value. Elsewhere padding will already be - * disabled because the controller supports byte mode. - */ - card->sdio_io_block_size = 1; - - /* Controller features must declare support for byte mode */ - if (!(card->sdio_if->features & CSR_SDIO_FEATURE_BYTE_MODE)) - { - unifi_error(card->ospriv, "Requires byte mode\n"); - r = CSR_WIFI_HIP_RESULT_INVALID_VALUE; - } - } - else - { - /* Padding will be enabled if CSR_SDIO_FEATURE_BYTE_MODE isn't set */ - card->sdio_io_block_size = card->sdio_if->blockSize; - } - - - return r; -} /* unifi_reset_hardware() */ - - -/* - * --------------------------------------------------------------------------- - * card_reset_method_io_enable - * - * Issue a hard reset to the hw writing the IO_ENABLE. - * - * Arguments: - * card Pointer to Card object - * - * Returns: - * 0 on success, - * CSR_WIFI_HIP_RESULT_NO_DEVICE if the card was ejected - * CSR_RESULT_FAILURE if an SDIO error occurred or if a response - * was not seen in the expected time - * --------------------------------------------------------------------------- - */ -static CsrResult card_reset_method_io_enable(card_t *card) -{ - CsrResult r; - CsrResult csrResult; - - /* - * This resets only function 1, so should be used in - * preference to the method below (CSR_FUNC_EN) - */ - unifi_trace(card->ospriv, UDBG1, "Hard reset (IO_ENABLE)\n"); - - csrResult = CsrSdioFunctionDisable(card->sdio_if); - if (csrResult == CSR_SDIO_RESULT_NO_DEVICE) - { - return CSR_WIFI_HIP_RESULT_NO_DEVICE; - } - if (csrResult != CSR_RESULT_SUCCESS) - { - r = ConvertCsrSdioToCsrHipResult(card, csrResult); - unifi_warning(card->ospriv, "SDIO error writing IO_ENABLE: %d\n", r); - } - else - { - /* Delay here to let the reset take affect. */ - CsrThreadSleep(RESET_SETTLE_DELAY); - - r = card_wait_for_unifi_to_disable(card); - if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE) - { - return r; - } - - if (r == CSR_RESULT_SUCCESS) - { - r = card_wait_for_unifi_to_reset(card); - if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE) - { - return r; - } - } - } - - if (r != CSR_RESULT_SUCCESS) - { - unifi_trace(card->ospriv, UDBG1, "Hard reset (CSR_FUNC_EN)\n"); - - r = sdio_write_f0(card, SDIO_CSR_FUNC_EN, 0); - if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE) - { - return r; - } - if (r != CSR_RESULT_SUCCESS) - { - unifi_warning(card->ospriv, "SDIO error writing SDIO_CSR_FUNC_EN: %d\n", r); - return r; - } - else - { - /* Delay here to let the reset take affect. */ - CsrThreadSleep(RESET_SETTLE_DELAY); - - r = card_wait_for_unifi_to_reset(card); - if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE) - { - return r; - } - } - } - - if (r != CSR_RESULT_SUCCESS) - { - unifi_warning(card->ospriv, "card_reset_method_io_enable failed to reset UniFi\n"); - } - - return r; -} /* card_reset_method_io_enable() */ - - -/* - * --------------------------------------------------------------------------- - * card_reset_method_dbg_reset - * - * Issue a hard reset to the hw writing the DBG_RESET. - * - * Arguments: - * card Pointer to Card object - * - * Returns: - * CSR_RESULT_SUCCESS on success, - * CSR_WIFI_HIP_RESULT_NO_DEVICE if the card was ejected - * CSR_RESULT_FAILURE if an SDIO error occurred or if a response - * was not seen in the expected time - * --------------------------------------------------------------------------- - */ -static CsrResult card_reset_method_dbg_reset(card_t *card) -{ - CsrResult r; - - /* - * Prepare UniFi for h/w reset - */ - if (card->host_state == UNIFI_HOST_STATE_TORPID) - { - r = unifi_set_host_state(card, UNIFI_HOST_STATE_DROWSY); - if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE) - { - return r; - } - if (r != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, "Failed to set UNIFI_HOST_STATE_DROWSY\n"); - return r; - } - CsrThreadSleep(5); - } - - r = unifi_card_stop_processor(card, UNIFI_PROC_BOTH); - if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE) - { - return r; - } - if (r != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, "Can't stop processors\n"); - return r; - } - - unifi_trace(card->ospriv, UDBG1, "Hard reset (DBG_RESET)\n"); - - /* - * This register write may fail. The debug reset resets - * parts of the Function 0 sections of the chip, and - * therefore the response cannot be sent back to the host. - */ - r = unifi_write_direct_8_or_16(card, ChipHelper_DBG_RESET(card->helper) * 2, 1); - if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE) - { - return r; - } - if (r != CSR_RESULT_SUCCESS) - { - unifi_warning(card->ospriv, "SDIO error writing DBG_RESET: %d\n", r); - return r; - } - - /* Delay here to let the reset take affect. */ - CsrThreadSleep(RESET_SETTLE_DELAY); - - r = card_wait_for_unifi_to_reset(card); - if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE) - { - return r; - } - if (r != CSR_RESULT_SUCCESS) - { - unifi_warning(card->ospriv, "card_reset_method_dbg_reset failed to reset UniFi\n"); - } - - return r; -} /* card_reset_method_dbg_reset() */ - - -/* - * --------------------------------------------------------------------------- - * unifi_card_hard_reset - * - * Issue reset to hardware, by writing to registers on the card. - * Power to the card is preserved. - * - * Arguments: - * card Pointer to Card object - * - * Returns: - * CSR_RESULT_SUCCESS on success, - * CSR_WIFI_HIP_RESULT_NO_DEVICE if the card was ejected - * CSR_RESULT_FAILURE if an SDIO error occurred or if a response - * was not seen in the expected time - * --------------------------------------------------------------------------- - */ -CsrResult unifi_card_hard_reset(card_t *card) -{ - CsrResult r; - const struct chip_helper_reset_values *init_data; - u32 chunks; - - /* Clear cache of page registers */ - card->proc_select = (u32)(-1); - card->dmem_page = (u32)(-1); - card->pmem_page = (u32)(-1); - - /* - * We need to have a valid card->helper before we use software hard reset. - * If unifi_identify_hw() fails to get the card ID, it probably means - * that there is no way to talk to the h/w. - */ - r = unifi_identify_hw(card); - if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE) - { - return r; - } - if (r != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, "unifi_card_hard_reset failed to identify h/w\n"); - return r; - } - - /* Search for some reset code. */ - chunks = ChipHelper_HostResetSequence(card->helper, &init_data); - if (chunks != 0) - { - unifi_error(card->ospriv, - "Hard reset (Code download) is unsupported\n"); - - return CSR_RESULT_FAILURE; - } - - if (card->chip_id > SDIO_CARD_ID_UNIFI_2) - { - /* The HIP spec considers this a bus-specific reset. - * This resets only function 1, so should be used in - * preference to the method below (CSR_FUNC_EN) - * If this method fails, it means that the f/w is probably - * not running. In this case, try the DBG_RESET method. - */ - r = card_reset_method_io_enable(card); - if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE) - { - return r; - } - if (r == CSR_RESULT_SUCCESS) - { - return r; - } - } - - /* Software hard reset */ - r = card_reset_method_dbg_reset(card); - - return r; -} /* unifi_card_hard_reset() */ - - -/* - * --------------------------------------------------------------------------- - * - * CardGenInt - * - * Prod the card. - * This function causes an internal interrupt to be raised in the - * UniFi chip. It is used to signal the firmware that some action has - * been completed. - * The UniFi Host Interface asks that the value used increments for - * debugging purposes. - * - * Arguments: - * card Pointer to Card object - * - * Returns: - * CSR_RESULT_SUCCESS on success, - * CSR_WIFI_HIP_RESULT_NO_DEVICE if the card was ejected - * CSR_RESULT_FAILURE if an SDIO error occurred or if a response - * was not seen in the expected time - * --------------------------------------------------------------------------- - */ -CsrResult CardGenInt(card_t *card) -{ - CsrResult r; - - if (card->chip_id > SDIO_CARD_ID_UNIFI_2) - { - r = sdio_write_f0(card, SDIO_CSR_FROM_HOST_SCRATCH0, - (u8)card->unifi_interrupt_seq); - } - else - { - r = unifi_write_direct_8_or_16(card, - ChipHelper_SHARED_IO_INTERRUPT(card->helper) * 2, - (u8)card->unifi_interrupt_seq); - } - if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE) - { - return r; - } - if (r != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, "SDIO error writing UNIFI_SHARED_IO_INTERRUPT: %d\n", r); - return r; - } - - card->unifi_interrupt_seq++; - - return CSR_RESULT_SUCCESS; -} /* CardGenInt() */ - - -/* - * --------------------------------------------------------------------------- - * CardEnableInt - * - * Enable the outgoing SDIO interrupt from UniFi to the host. - * - * Arguments: - * card Pointer to Card object - * - * Returns: - * CSR_RESULT_SUCCESS on success, - * CSR_WIFI_HIP_RESULT_NO_DEVICE if the card was ejected - * CSR_RESULT_FAILURE if an SDIO error occurred, - * --------------------------------------------------------------------------- - */ -CsrResult CardEnableInt(card_t *card) -{ - CsrResult r; - u8 int_enable; - - r = sdio_read_f0(card, SDIO_INT_ENABLE, &int_enable); - if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE) - { - return r; - } - if (r != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, "SDIO error reading SDIO_INT_ENABLE\n"); - return r; - } - - int_enable |= (1 << card->function) | UNIFI_SD_INT_ENABLE_IENM; - - r = sdio_write_f0(card, SDIO_INT_ENABLE, int_enable); - if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE) - { - return r; - } - if (r != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, "SDIO error writing SDIO_INT_ENABLE\n"); - return r; - } - - return CSR_RESULT_SUCCESS; -} /* CardEnableInt() */ - - -/* - * --------------------------------------------------------------------------- - * CardDisableInt - * - * Disable the outgoing SDIO interrupt from UniFi to the host. - * - * Arguments: - * card Pointer to Card object - * - * Returns: - * CSR_RESULT_SUCCESS on success, - * CSR_WIFI_HIP_RESULT_NO_DEVICE if the card was ejected - * CSR_RESULT_FAILURE if an SDIO error occurred, - * --------------------------------------------------------------------------- - */ -CsrResult CardDisableInt(card_t *card) -{ - CsrResult r; - u8 int_enable; - - r = sdio_read_f0(card, SDIO_INT_ENABLE, &int_enable); - if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE) - { - return r; - } - if (r != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, "SDIO error reading SDIO_INT_ENABLE\n"); - return r; - } - - int_enable &= ~(1 << card->function); - - r = sdio_write_f0(card, SDIO_INT_ENABLE, int_enable); - if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE) - { - return r; - } - if (r != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, "SDIO error writing SDIO_INT_ENABLE\n"); - return r; - } - - return CSR_RESULT_SUCCESS; -} /* CardDisableInt() */ - - -/* - * --------------------------------------------------------------------------- - * CardPendingInt - * - * Determine whether UniFi is currently asserting the SDIO interrupt - * request. - * - * Arguments: - * card Pointer to Card object - * pintr Pointer to location to write interrupt status, - * TRUE if interrupt pending, - * FALSE if no interrupt pending. - * Returns: - * CSR_RESULT_SUCCESS interrupt status read successfully - * CSR_WIFI_HIP_RESULT_NO_DEVICE if the card was ejected - * CSR_RESULT_FAILURE if an SDIO error occurred, - * --------------------------------------------------------------------------- - */ -CsrResult CardPendingInt(card_t *card, u8 *pintr) -{ - CsrResult r; - u8 pending; - - *pintr = FALSE; - - r = sdio_read_f0(card, SDIO_INT_PENDING, &pending); - if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE) - { - return r; - } - if (r != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, "SDIO error reading SDIO_INT_PENDING\n"); - return r; - } - - *pintr = (pending & (1 << card->function))?TRUE : FALSE; - - return CSR_RESULT_SUCCESS; -} /* CardPendingInt() */ - - -/* - * --------------------------------------------------------------------------- - * CardClearInt - * - * Clear the UniFi SDIO interrupt request. - * - * Arguments: - * card Pointer to Card object - * - * Returns: - * CSR_RESULT_SUCCESS if pending interrupt was cleared, or no pending interrupt. - * CSR_WIFI_HIP_RESULT_NO_DEVICE if the card was ejected - * CSR_RESULT_FAILURE if an SDIO error occurred, - * --------------------------------------------------------------------------- - */ -CsrResult CardClearInt(card_t *card) -{ - CsrResult r; - u8 intr; - - if (card->chip_id > SDIO_CARD_ID_UNIFI_2) - { - /* CardPendingInt() sets intr, if there is a pending interrupt */ - r = CardPendingInt(card, &intr); - if (intr == FALSE) - { - return r; - } - - r = sdio_write_f0(card, SDIO_CSR_HOST_INT_CLEAR, 1); - if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE) - { - return r; - } - if (r != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, "SDIO error writing SDIO_CSR_HOST_INT_CLEAR\n"); - } - } - else - { - r = unifi_write_direct_8_or_16(card, - ChipHelper_SDIO_HOST_INT(card->helper) * 2, - 0); - if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE) - { - return r; - } - if (r != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, "SDIO error writing UNIFI_SDIO_HOST_INT\n"); - } - } - - return r; -} /* CardClearInt() */ - - -/* - * --------------------------------------------------------------------------- - * CardIntEnabled - * - * Determine whether UniFi is currently asserting the SDIO interrupt - * request. - * - * Arguments: - * card Pointer to Card object - * enabled Pointer to location to write interrupt enable status, - * TRUE if interrupts enabled, - * FALSE if interupts disabled. - * - * Returns: - * CSR_WIFI_HIP_RESULT_NO_DEVICE if the card was ejected - * CSR_RESULT_FAILURE if an SDIO error occurred, - * --------------------------------------------------------------------------- - */ -CsrResult CardIntEnabled(card_t *card, u8 *enabled) -{ - CsrResult r; - u8 int_enable; - - r = sdio_read_f0(card, SDIO_INT_ENABLE, &int_enable); - if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE) - { - return r; - } - if (r != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, "SDIO error reading SDIO_INT_ENABLE\n"); - return r; - } - - *enabled = (int_enable & (1 << card->function))?TRUE : FALSE; - - return CSR_RESULT_SUCCESS; -} /* CardIntEnabled() */ - - -/* - * --------------------------------------------------------------------------- - * CardWriteBulkData - * Allocate slot in the pending bulkdata arrays and assign it to a signal's - * bulkdata reference. The slot is then ready for UniFi's bulkdata commands - * to transfer the data to/from the host. - * - * Arguments: - * card Pointer to Card object - * csptr Pending signal pointer, including bulkdata ref - * queue Traffic queue that this signal is using - * - * Returns: - * CSR_RESULT_SUCCESS if a free slot was assigned - * CSR_RESULT_FAILURE if no slot was available - * --------------------------------------------------------------------------- - */ -CsrResult CardWriteBulkData(card_t *card, card_signal_t *csptr, unifi_TrafficQueue queue) -{ - u16 i, slots[UNIFI_MAX_DATA_REFERENCES], j = 0; - u8 *packed_sigptr, num_slots_required = 0; - bulk_data_desc_t *bulkdata = csptr->bulkdata; - s16 h, nslots; - - /* Count the number of slots required */ - for (i = 0; i < UNIFI_MAX_DATA_REFERENCES; i++) - { - if (bulkdata[i].data_length != 0) - { - num_slots_required++; - } - } - - /* Get the slot numbers */ - if (num_slots_required != 0) - { - /* Last 2 slots for MLME */ - if (queue == UNIFI_TRAFFIC_Q_MLME) - { - h = card->config_data.num_fromhost_data_slots - UNIFI_RESERVED_COMMAND_SLOTS; - for (i = 0; i < card->config_data.num_fromhost_data_slots; i++) - { - if (card->from_host_data[h].bd.data_length == 0) - { - /* Free data slot, claim it */ - slots[j++] = h; - if (j == num_slots_required) - { - break; - } - } - - if (++h >= card->config_data.num_fromhost_data_slots) - { - h = 0; - } - } - } - else - { - if (card->dynamic_slot_data.from_host_used_slots[queue] - < card->dynamic_slot_data.from_host_max_slots[queue]) - { - /* Data commands get a free slot only after a few checks */ - nslots = card->config_data.num_fromhost_data_slots - UNIFI_RESERVED_COMMAND_SLOTS; - - h = card->from_host_data_head; - - for (i = 0; i < nslots; i++) - { - if (card->from_host_data[h].bd.data_length == 0) - { - /* Free data slot, claim it */ - slots[j++] = h; - if (j == num_slots_required) - { - break; - } - } - - if (++h >= nslots) - { - h = 0; - } - } - card->from_host_data_head = h; - } - } - - /* Required number of slots are not available, bail out */ - if (j != num_slots_required) - { - unifi_trace(card->ospriv, UDBG5, "CardWriteBulkData: didn't find free slot/s\n"); - - /* If we haven't already reached the stable state we can ask for reservation */ - if ((queue != UNIFI_TRAFFIC_Q_MLME) && (card->dynamic_slot_data.queue_stable[queue] == FALSE)) - { - CardCheckDynamicReservation(card, queue); - } - - for (i = 0; i < card->config_data.num_fromhost_data_slots; i++) - { - unifi_trace(card->ospriv, UDBG5, "fh data slot %d: %d\n", i, card->from_host_data[i].bd.data_length); - } - return CSR_RESULT_FAILURE; - } - } - - packed_sigptr = csptr->sigbuf; - - /* Fill in the slots with data */ - j = 0; - for (i = 0; i < UNIFI_MAX_DATA_REFERENCES; i++) - { - if (bulkdata[i].data_length == 0) - { - /* Zero-out the DATAREF in the signal */ - SET_PACKED_DATAREF_SLOT(packed_sigptr, i, 0); - SET_PACKED_DATAREF_LEN(packed_sigptr, i, 0); - } - else - { - /* - * Fill in the slot number in the SIGNAL structure but - * preserve the offset already in there - */ - SET_PACKED_DATAREF_SLOT(packed_sigptr, i, slots[j] | (((u16)packed_sigptr[SIZEOF_SIGNAL_HEADER + (i * SIZEOF_DATAREF) + 1]) << 8)); - SET_PACKED_DATAREF_LEN(packed_sigptr, i, bulkdata[i].data_length); - - /* Do not copy the data, just store the information to them */ - card->from_host_data[slots[j]].bd.os_data_ptr = bulkdata[i].os_data_ptr; - card->from_host_data[slots[j]].bd.os_net_buf_ptr = bulkdata[i].os_net_buf_ptr; - card->from_host_data[slots[j]].bd.data_length = bulkdata[i].data_length; - card->from_host_data[slots[j]].bd.net_buf_length = bulkdata[i].net_buf_length; - card->from_host_data[slots[j]].queue = queue; - - unifi_trace(card->ospriv, UDBG4, "CardWriteBulkData sig=0x%x, fh slot %d = %p\n", - GET_SIGNAL_ID(packed_sigptr), i, bulkdata[i].os_data_ptr); - - /* Sanity-check that the bulk data desc being assigned to the slot - * actually has a payload. - */ - if (!bulkdata[i].os_data_ptr) - { - unifi_error(card->ospriv, "Assign null os_data_ptr (len=%d) fh slot %d, i=%d, q=%d, sig=0x%x", - bulkdata[i].data_length, slots[j], i, queue, GET_SIGNAL_ID(packed_sigptr)); - } - - j++; - if (queue < UNIFI_NO_OF_TX_QS) - { - card->dynamic_slot_data.from_host_used_slots[queue]++; - } - } - } - - return CSR_RESULT_SUCCESS; -} /* CardWriteBulkData() */ - - -/* - * --------------------------------------------------------------------------- - * card_find_data_slot - * - * Dereference references to bulk data slots into pointers to real data. - * - * Arguments: - * card Pointer to the card struct. - * slot Slot number from a signal structure - * - * Returns: - * Pointer to entry in bulk_data_slot array. - * --------------------------------------------------------------------------- - */ -bulk_data_desc_t* card_find_data_slot(card_t *card, s16 slot) -{ - s16 sn; - bulk_data_desc_t *bd; - - sn = slot & 0x7FFF; - - /* ?? check sanity of slot number ?? */ - - if (slot & SLOT_DIR_TO_HOST) - { - bd = &card->to_host_data[sn]; - } - else - { - bd = &card->from_host_data[sn].bd; - } - - return bd; -} /* card_find_data_slot() */ - - -/* - * --------------------------------------------------------------------------- - * firmware_present_in_flash - * - * Probe for external Flash that looks like it might contain firmware. - * - * If Flash is not present, reads always return 0x0008. - * If Flash is present, but empty, reads return 0xFFFF. - * Anything else is considered to be firmware. - * - * Arguments: - * card Pointer to card struct - * - * Returns: - * CSR_RESULT_SUCCESS firmware is present in ROM or flash - * CSR_WIFI_HIP_RESULT_NOT_FOUND firmware is not present in ROM or flash - * CSR_WIFI_HIP_RESULT_NO_DEVICE if the card was ejected - * CSR_RESULT_FAILURE if an SDIO error occurred - * --------------------------------------------------------------------------- - */ -static CsrResult firmware_present_in_flash(card_t *card) -{ - CsrResult r; - u16 m1, m5; - - if (ChipHelper_HasRom(card->helper)) - { - return CSR_RESULT_SUCCESS; - } - if (!ChipHelper_HasFlash(card->helper)) - { - return CSR_WIFI_HIP_RESULT_NOT_FOUND; - } - - /* - * Examine the Flash locations that are the power-on default reset - * vectors of the XAP processors. - * These are words 1 and 5 in Flash. - */ - r = unifi_card_read16(card, UNIFI_MAKE_GP(EXT_FLASH, 2), &m1); - if (r != CSR_RESULT_SUCCESS) - { - return r; - } - - r = unifi_card_read16(card, UNIFI_MAKE_GP(EXT_FLASH, 10), &m5); - if (r != CSR_RESULT_SUCCESS) - { - return r; - } - - /* Check for uninitialised/missing flash */ - if ((m1 == 0x0008) || (m1 == 0xFFFF) || - (m1 == 0x0004) || (m5 == 0x0004) || - (m5 == 0x0008) || (m5 == 0xFFFF)) - { - return CSR_WIFI_HIP_RESULT_NOT_FOUND; - } - - return CSR_RESULT_SUCCESS; -} /* firmware_present_in_flash() */ - - -/* - * --------------------------------------------------------------------------- - * bootstrap_chip_hw - * - * Perform chip specific magic to "Get It Working" TM. This will - * increase speed of PLLs in analogue and maybe enable some - * on-chip regulators. - * - * Arguments: - * card Pointer to card struct - * - * Returns: - * None. - * --------------------------------------------------------------------------- - */ -static void bootstrap_chip_hw(card_t *card) -{ - const struct chip_helper_init_values *vals; - u32 i, len; - void *sdio = card->sdio_if; - CsrResult csrResult; - - len = ChipHelper_ClockStartupSequence(card->helper, &vals); - if (len != 0) - { - for (i = 0; i < len; i++) - { - csrResult = CsrSdioWrite16(sdio, vals[i].addr * 2, vals[i].value); - if (csrResult != CSR_RESULT_SUCCESS) - { - unifi_warning(card->ospriv, "Failed to write bootstrap value %d\n", i); - /* Might not be fatal */ - } - - CsrThreadSleep(1); - } - } -} /* bootstrap_chip_hw() */ - - -/* - * --------------------------------------------------------------------------- - * unifi_card_stop_processor - * - * Stop the UniFi XAP processors. - * - * Arguments: - * card Pointer to card struct - * which One of UNIFI_PROC_MAC, UNIFI_PROC_PHY, UNIFI_PROC_BOTH - * - * Returns: - * CSR_RESULT_SUCCESS if successful, or CSR error code - * --------------------------------------------------------------------------- - */ -CsrResult unifi_card_stop_processor(card_t *card, enum unifi_dbg_processors_select which) -{ - CsrResult r = CSR_RESULT_SUCCESS; - u8 status; - s16 retry = 100; - - while (retry--) - { - /* Select both XAPs */ - r = unifi_set_proc_select(card, which); - if (r != CSR_RESULT_SUCCESS) - { - break; - } - - /* Stop processors */ - r = unifi_write_direct16(card, ChipHelper_DBG_EMU_CMD(card->helper) * 2, 2); - if (r != CSR_RESULT_SUCCESS) - { - break; - } - - /* Read status */ - r = unifi_read_direct_8_or_16(card, - ChipHelper_DBG_HOST_STOP_STATUS(card->helper) * 2, - &status); - if (r != CSR_RESULT_SUCCESS) - { - break; - } - - if ((status & 1) == 1) - { - /* Success! */ - return CSR_RESULT_SUCCESS; - } - - /* Processors didn't stop, try again */ - } - - if (r != CSR_RESULT_SUCCESS) - { - /* An SDIO error occurred */ - unifi_error(card->ospriv, "Failed to stop processors: SDIO error\n"); - } - else - { - /* If we reach here, we didn't the status in time. */ - unifi_error(card->ospriv, "Failed to stop processors: timeout waiting for stopped status\n"); - r = CSR_RESULT_FAILURE; - } - - return r; -} /* unifi_card_stop_processor() */ - - -/* - * --------------------------------------------------------------------------- - * card_start_processor - * - * Start the UniFi XAP processors. - * - * Arguments: - * card Pointer to card struct - * which One of UNIFI_PROC_MAC, UNIFI_PROC_PHY, UNIFI_PROC_BOTH - * - * Returns: - * CSR_RESULT_SUCCESS or CSR error code - * --------------------------------------------------------------------------- - */ -CsrResult card_start_processor(card_t *card, enum unifi_dbg_processors_select which) -{ - CsrResult r; - - /* Select both XAPs */ - r = unifi_set_proc_select(card, which); - if (r != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, "unifi_set_proc_select failed: %d.\n", r); - return r; - } - - - r = unifi_write_direct_8_or_16(card, - ChipHelper_DBG_EMU_CMD(card->helper) * 2, 8); - if (r != CSR_RESULT_SUCCESS) - { - return r; - } - - r = unifi_write_direct_8_or_16(card, - ChipHelper_DBG_EMU_CMD(card->helper) * 2, 0); - if (r != CSR_RESULT_SUCCESS) - { - return r; - } - - return CSR_RESULT_SUCCESS; -} /* card_start_processor() */ - - -/* - * --------------------------------------------------------------------------- - * unifi_set_interrupt_mode - * - * Configure the interrupt processing mode used by the HIP - * - * Arguments: - * card Pointer to card struct - * mode Interrupt mode to apply - * - * Returns: - * None - * --------------------------------------------------------------------------- - */ -void unifi_set_interrupt_mode(card_t *card, u32 mode) -{ - if (mode == CSR_WIFI_INTMODE_RUN_BH_ONCE) - { - unifi_info(card->ospriv, "Scheduled interrupt mode"); - } - card->intmode = mode; -} /* unifi_set_interrupt_mode() */ - - -/* - * --------------------------------------------------------------------------- - * unifi_start_processors - * - * Start all UniFi XAP processors. - * - * Arguments: - * card Pointer to card struct - * - * Returns: - * CSR_RESULT_SUCCESS on success, CSR error code on error - * --------------------------------------------------------------------------- - */ -CsrResult unifi_start_processors(card_t *card) -{ - return card_start_processor(card, UNIFI_PROC_BOTH); -} /* unifi_start_processors() */ - - -/* - * --------------------------------------------------------------------------- - * unifi_request_max_sdio_clock - * - * Requests that the maximum SDIO clock rate is set at the next suitable - * opportunity (e.g. when the BH next runs, so as not to interfere with - * any current operation). - * - * Arguments: - * card Pointer to card struct - * - * Returns: - * None - * --------------------------------------------------------------------------- - */ -void unifi_request_max_sdio_clock(card_t *card) -{ - card->request_max_clock = 1; -} /* unifi_request_max_sdio_clock() */ - - -/* - * --------------------------------------------------------------------------- - * unifi_set_host_state - * - * Set the host deep-sleep state. - * - * If transitioning to TORPID, the SDIO driver will be notified - * that the SD bus will be unused (idle) and conversely, when - * transitioning from TORPID that the bus will be used (active). - * - * Arguments: - * card Pointer to card struct - * state New deep-sleep state. - * - * Returns: - * CSR_RESULT_SUCCESS on success - * CSR_WIFI_HIP_RESULT_NO_DEVICE if the card was ejected - * CSR_RESULT_FAILURE if an SDIO error occurred - * - * Notes: - * We need to reduce the SDIO clock speed before trying to wake up the - * chip. Actually, in the implementation below we reduce the clock speed - * not just before we try to wake up the chip, but when we put the chip to - * deep sleep. This means that if the f/w wakes up on its' own, we waste - * a reduce/increace cycle. However, trying to eliminate this overhead is - * proved difficult, as the current state machine in the HIP lib does at - * least a CMD52 to disable the interrupts before we configure the host - * state. - * --------------------------------------------------------------------------- - */ -CsrResult unifi_set_host_state(card_t *card, enum unifi_host_state state) -{ - CsrResult r = CSR_RESULT_SUCCESS; - CsrResult csrResult; - static const char *const states[] = { - "AWAKE", "DROWSY", "TORPID" - }; - static const u8 state_csr_host_wakeup[] = { - 1, 3, 0 - }; - static const u8 state_io_abort[] = { - 0, 2, 3 - }; - - unifi_trace(card->ospriv, UDBG4, "State %s to %s\n", - states[card->host_state], states[state]); - - if (card->host_state == UNIFI_HOST_STATE_TORPID) - { - CsrSdioFunctionActive(card->sdio_if); - } - - /* Write the new state to UniFi. */ - if (card->chip_id > SDIO_CARD_ID_UNIFI_2) - { - r = sdio_write_f0(card, SDIO_CSR_HOST_WAKEUP, - (u8)((card->function << 4) | state_csr_host_wakeup[state])); - } - else - { - r = sdio_write_f0(card, SDIO_IO_ABORT, state_io_abort[state]); - } - - if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE) - { - return r; - } - if (r != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, "Failed to write UniFi deep sleep state\n"); - } - else - { - /* - * If the chip was in state TORPID then we can now increase - * the maximum bus clock speed. - */ - if (card->host_state == UNIFI_HOST_STATE_TORPID) - { - csrResult = CsrSdioMaxBusClockFrequencySet(card->sdio_if, - UNIFI_SDIO_CLOCK_MAX_HZ); - r = ConvertCsrSdioToCsrHipResult(card, csrResult); - /* Non-fatal error */ - if (r != CSR_RESULT_SUCCESS && r != CSR_WIFI_HIP_RESULT_NO_DEVICE) - { - unifi_warning(card->ospriv, - "Failed to increase the SDIO clock speed\n"); - } - else - { - card->sdio_clock_speed = UNIFI_SDIO_CLOCK_MAX_HZ; - } - } - - /* - * Cache the current state in the card structure to avoid - * unnecessary SDIO reads. - */ - card->host_state = state; - - if (state == UNIFI_HOST_STATE_TORPID) - { - /* - * If the chip is now in state TORPID then we must now decrease - * the maximum bus clock speed. - */ - csrResult = CsrSdioMaxBusClockFrequencySet(card->sdio_if, - UNIFI_SDIO_CLOCK_SAFE_HZ); - r = ConvertCsrSdioToCsrHipResult(card, csrResult); - if (r != CSR_RESULT_SUCCESS && r != CSR_WIFI_HIP_RESULT_NO_DEVICE) - { - unifi_warning(card->ospriv, - "Failed to decrease the SDIO clock speed\n"); - } - else - { - card->sdio_clock_speed = UNIFI_SDIO_CLOCK_SAFE_HZ; - } - CsrSdioFunctionIdle(card->sdio_if); - } - } - - return r; -} /* unifi_set_host_state() */ - - -/* - * --------------------------------------------------------------------------- - * unifi_card_info - * - * Update the card information data structure - * - * Arguments: - * card Pointer to card struct - * card_info Pointer to info structure to update - * - * Returns: - * None - * --------------------------------------------------------------------------- - */ -void unifi_card_info(card_t *card, card_info_t *card_info) -{ - card_info->chip_id = card->chip_id; - card_info->chip_version = card->chip_version; - card_info->fw_build = card->build_id; - card_info->fw_hip_version = card->config_data.version; - card_info->sdio_block_size = card->sdio_io_block_size; -} /* unifi_card_info() */ - - -/* - * --------------------------------------------------------------------------- - * unifi_check_io_status - * - * Check UniFi for spontaneous reset and pending interrupt. - * - * Arguments: - * card Pointer to card struct - * status Pointer to location to write chip status: - * 0 if UniFi is running, and no interrupt pending - * 1 if UniFi has spontaneously reset - * 2 if there is a pending interrupt - * Returns: - * CSR_RESULT_SUCCESS if OK, or CSR error - * --------------------------------------------------------------------------- - */ -CsrResult unifi_check_io_status(card_t *card, s32 *status) -{ - u8 io_en; - CsrResult r; - u8 pending; - - *status = 0; - - r = sdio_read_f0(card, SDIO_IO_ENABLE, &io_en); - if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE) - { - return r; - } - if (r != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, "Failed to read SDIO_IO_ENABLE to check for spontaneous reset\n"); - return r; - } - - if ((io_en & (1 << card->function)) == 0) - { - s32 fw_count; - *status = 1; - unifi_error(card->ospriv, "UniFi has spontaneously reset.\n"); - - /* - * These reads are very likely to fail. We want to know if the function is really - * disabled or the SDIO driver just returns rubbish. - */ - fw_count = unifi_read_shared_count(card, card->sdio_ctrl_addr + 4); - if (fw_count < 0) - { - unifi_error(card->ospriv, "Failed to read to-host sig written count\n"); - } - else - { - unifi_error(card->ospriv, "thsw: %u (driver thinks is %u)\n", - fw_count, card->to_host_signals_w); - } - fw_count = unifi_read_shared_count(card, card->sdio_ctrl_addr + 2); - if (fw_count < 0) - { - unifi_error(card->ospriv, "Failed to read from-host sig read count\n"); - } - else - { - unifi_error(card->ospriv, "fhsr: %u (driver thinks is %u)\n", - fw_count, card->from_host_signals_r); - } - - return r; - } - - unifi_info(card->ospriv, "UniFi function %d is enabled.\n", card->function); - - /* See if we missed an SDIO interrupt */ - r = CardPendingInt(card, &pending); - if (pending) - { - unifi_error(card->ospriv, "There is an unhandled pending interrupt.\n"); - *status = 2; - return r; - } - - return r; -} /* unifi_check_io_status() */ - - -void unifi_get_hip_qos_info(card_t *card, unifi_HipQosInfo *hipqosinfo) -{ - s32 count_fhr; - s16 t; - u32 occupied_fh; - - q_t *sigq; - u16 nslots, i; - - memset(hipqosinfo, 0, sizeof(unifi_HipQosInfo)); - - nslots = card->config_data.num_fromhost_data_slots; - - for (i = 0; i < nslots; i++) - { - if (card->from_host_data[i].bd.data_length == 0) - { - hipqosinfo->free_fh_bulkdata_slots++; - } - } - - for (i = 0; i < UNIFI_NO_OF_TX_QS; i++) - { - sigq = &card->fh_traffic_queue[i]; - t = sigq->q_wr_ptr - sigq->q_rd_ptr; - if (t < 0) - { - t += sigq->q_length; - } - hipqosinfo->free_fh_sig_queue_slots[i] = (sigq->q_length - t) - 1; - } - - count_fhr = unifi_read_shared_count(card, card->sdio_ctrl_addr + 2); - if (count_fhr < 0) - { - unifi_error(card->ospriv, "Failed to read from-host sig read count - %d\n", count_fhr); - hipqosinfo->free_fh_fw_slots = 0xfa; - return; - } - - occupied_fh = (card->from_host_signals_w - count_fhr) % 128; - - hipqosinfo->free_fh_fw_slots = (u16)(card->config_data.num_fromhost_sig_frags - occupied_fh); -} - - - -CsrResult ConvertCsrSdioToCsrHipResult(card_t *card, CsrResult csrResult) -{ - CsrResult r = CSR_RESULT_FAILURE; - - switch (csrResult) - { - case CSR_RESULT_SUCCESS: - r = CSR_RESULT_SUCCESS; - break; - /* Timeout errors */ - case CSR_SDIO_RESULT_TIMEOUT: - /* Integrity errors */ - case CSR_SDIO_RESULT_CRC_ERROR: - r = CSR_RESULT_FAILURE; - break; - case CSR_SDIO_RESULT_NO_DEVICE: - r = CSR_WIFI_HIP_RESULT_NO_DEVICE; - break; - case CSR_SDIO_RESULT_INVALID_VALUE: - r = CSR_WIFI_HIP_RESULT_INVALID_VALUE; - break; - case CSR_RESULT_FAILURE: - r = CSR_RESULT_FAILURE; - break; - default: - unifi_warning(card->ospriv, "Unrecognised csrResult error code: %d\n", csrResult); - break; - } - - return r; -} /* ConvertCsrSdioToCsrHipResult() */ - - diff --git a/drivers/staging/csr/csr_wifi_hip_card_sdio.h b/drivers/staging/csr/csr_wifi_hip_card_sdio.h deleted file mode 100644 index a9b9ec427320..000000000000 --- a/drivers/staging/csr/csr_wifi_hip_card_sdio.h +++ /dev/null @@ -1,694 +0,0 @@ -/***************************************************************************** - - (c) Cambridge Silicon Radio Limited 2011 - All rights reserved and confidential information of CSR - - Refer to LICENSE.txt included with this source for details - on the license terms. - -*****************************************************************************/ - -/* - * --------------------------------------------------------------------------- - * - * FILE: csr_wifi_hip_card_sdio.h - * - * PURPOSE: - * Internal header for Card API for SDIO. - * --------------------------------------------------------------------------- - */ -#ifndef __CARD_SDIO_H__ -#define __CARD_SDIO_H__ - -#include "csr_wifi_hip_unifi.h" -#include "csr_wifi_hip_unifi_udi.h" -#include "csr_wifi_hip_unifihw.h" -#include "csr_wifi_hip_unifiversion.h" -#ifndef CSR_WIFI_HIP_TA_DISABLE -#include "csr_wifi_hip_ta_sampling.h" -#endif -#include "csr_wifi_hip_xbv.h" -#include "csr_wifi_hip_chiphelper.h" - - -/* - * - * Configuration items. - * Which of these should go in a platform unifi_config.h file? - * - */ - -/* - * When the traffic queues contain more signals than there is space for on - * UniFi, a limiting algorithm comes into play. - * If a traffic queue has enough slots free to buffer more traffic from the - * network stack, then the following check is applied. The number of free - * slots is RESUME_XMIT_THRESHOLD. - */ -#define RESUME_XMIT_THRESHOLD 4 - - -/* - * When reading signals from UniFi, the host processes pending all signals - * and then acknowledges them together in a single write to update the - * to-host-chunks-read location. - * When there is more than one bulk data transfer (e.g. one received data - * packet and a request for the payload data of a transmitted packet), the - * update can be delayed significantly. This ties up resources on chip. - * - * To remedy this problem, to-host-chunks-read is updated after processing - * a signal if TO_HOST_FLUSH_THRESHOLD bytes of bulk data have been - * transferred since the last update. - */ -#define TO_HOST_FLUSH_THRESHOLD (500 * 5) - - -/* SDIO Card Common Control Registers */ -#define SDIO_CCCR_SDIO_REVISION (0x00) -#define SDIO_SD_SPEC_REVISION (0x01) -#define SDIO_IO_ENABLE (0x02) -#define SDIO_IO_READY (0x03) -#define SDIO_INT_ENABLE (0x04) -#define SDIO_INT_PENDING (0x05) -#define SDIO_IO_ABORT (0x06) -#define SDIO_BUS_IFACE_CONTROL (0x07) -#define SDIO_CARD_CAPABILOTY (0x08) -#define SDIO_COMMON_CIS_POINTER (0x09) -#define SDIO_BUS_SUSPEND (0x0C) -#define SDIO_FUNCTION_SELECT (0x0D) -#define SDIO_EXEC_FLAGS (0x0E) -#define SDIO_READY_FLAGS (0x0F) -#define SDIO_FN0_BLOCK_SIZE (0x10) -#define SDIO_POWER_CONTROL (0x12) -#define SDIO_VENDOR_START (0xF0) - -#define SDIO_CSR_HOST_WAKEUP (0xf0) -#define SDIO_CSR_HOST_INT_CLEAR (0xf1) -#define SDIO_CSR_FROM_HOST_SCRATCH0 (0xf2) -#define SDIO_CSR_FROM_HOST_SCRATCH1 (0xf3) -#define SDIO_CSR_TO_HOST_SCRATCH0 (0xf4) -#define SDIO_CSR_TO_HOST_SCRATCH1 (0xf5) -#define SDIO_CSR_FUNC_EN (0xf6) -#define SDIO_CSR_CSPI_MODE (0xf7) -#define SDIO_CSR_CSPI_STATUS (0xf8) -#define SDIO_CSR_CSPI_PADDING (0xf9) - - -#define UNIFI_SD_INT_ENABLE_IENM 0x0001 /* Master INT Enable */ - -#ifdef CSR_PRE_ALLOC_NET_DATA -#define BULK_DATA_PRE_ALLOC_NUM 16 -#endif - -/* - * Structure to hold configuration information read from UniFi. - */ -typedef struct -{ - /* - * The version of the SDIO signal queues and bulk data pools - * configuration structure. The MSB is the major version number, used to - * indicate incompatible changes. The LSB gives the minor revision number, - * used to indicate changes that maintain backwards compatibility. - */ - u16 version; - - /* - * offset from the start of the shared data memory to the SD IO - * control structure. - */ - u16 sdio_ctrl_offset; - - /* Buffer handle of the from-host signal queue */ - u16 fromhost_sigbuf_handle; - - /* Buffer handle of the to-host signal queue */ - u16 tohost_sigbuf_handle; - - /* - * Maximum number of signal primitive or bulk data command fragments that may be - * pending in the to-hw signal queue. - */ - u16 num_fromhost_sig_frags; - - /* - * Number of signal primitive or bulk data command fragments that must be pending - * in the to-host signal queue before the host will generate an interrupt - * to indicate that it has read a signal. This will usually be the total - * capacity of the to-host signal buffer less the size of the largest signal - * primitive divided by the signal primitive fragment size, but may be set - * to 1 to request interrupts every time that the host read a signal. - * Note that the hw may place more signals in the to-host signal queue - * than indicated by this field. - */ - u16 num_tohost_sig_frags; - - /* - * Number of to-hw bulk data slots. Slots are numbered from 0 (zero) to - * one less than the value in this field - */ - u16 num_fromhost_data_slots; - - /* - * Number of frm-hw bulk data slots. Slots are numbered from 0 (zero) to - * one less than the value in this field - */ - u16 num_tohost_data_slots; - - /* - * Size of the bulk data slots (2 octets) - * The size of the bulk data slots in octets. This will usually be - * the size of the largest MSDU. The value should always be even. - */ - u16 data_slot_size; - - /* - * Indicates that the host has finished the initialisation sequence. - * Initialised to 0x0000 by the firmware, and set to 0x0001 by us. - */ - u16 initialised; - - /* Added by protocol version 0x0001 */ - u32 overlay_size; - - /* Added by protocol version 0x0300 */ - u16 data_slot_round; - u16 sig_frag_size; - - /* Added by protocol version 0x0500 */ - u16 tohost_signal_padding; -} sdio_config_data_t; - -/* - * These values may change with versions of the Host Interface Protocol. - */ -/* - * Size of config info block pointed to by the CSR_SLT_SDIO_SLOT_CONFIG - * entry in the f/w symbol table - */ -#define SDIO_CONFIG_DATA_SIZE 30 - -/* Offset of the INIT flag in the config info block. */ -#define SDIO_INIT_FLAG_OFFSET 0x12 -#define SDIO_TO_HOST_SIG_PADDING_OFFSET 0x1C - - -/* Structure for a bulk data transfer command */ -typedef struct -{ - u16 cmd_and_len; /* bits 12-15 cmd, bits 0-11 len */ - u16 data_slot; /* slot number, perhaps OR'd with SLOT_DIR_TO_HOST */ - u16 offset; - u16 buffer_handle; -} bulk_data_cmd_t; - - -/* Bulk Data signal command values */ -#define SDIO_CMD_SIGNAL 0x00 -#define SDIO_CMD_TO_HOST_TRANSFER 0x01 -#define SDIO_CMD_TO_HOST_TRANSFER_ACK 0x02 /*deprecated*/ -#define SDIO_CMD_FROM_HOST_TRANSFER 0x03 -#define SDIO_CMD_FROM_HOST_TRANSFER_ACK 0x04 /*deprecated*/ -#define SDIO_CMD_CLEAR_SLOT 0x05 -#define SDIO_CMD_OVERLAY_TRANSFER 0x06 -#define SDIO_CMD_OVERLAY_TRANSFER_ACK 0x07 /*deprecated*/ -#define SDIO_CMD_FROM_HOST_AND_CLEAR 0x08 -#define SDIO_CMD_PADDING 0x0f - -#define SLOT_DIR_TO_HOST 0x8000 - - -/* Initialise bulkdata slot - * params: - * bulk_data_desc_t *bulk_data_slot - */ -#define UNIFI_INIT_BULK_DATA(bulk_data_slot) \ - { \ - (bulk_data_slot)->os_data_ptr = NULL; \ - (bulk_data_slot)->data_length = 0; \ - (bulk_data_slot)->os_net_buf_ptr = NULL; \ - (bulk_data_slot)->net_buf_length = 0; \ - } - -/* - * Structure to contain a SIGNAL datagram. - * This is used to build signal queues between the main driver and the - * i/o thread. - * The fields are: - * sigbuf Contains the HIP signal is wire-format (i.e. packed, - * little-endian) - * bulkdata Contains a copy of any associated bulk data - * signal_length The size of the signal in the sigbuf - */ -typedef struct card_signal -{ - u8 sigbuf[UNIFI_PACKED_SIGBUF_SIZE]; - - /* Length of the SIGNAL inside sigbuf */ - u16 signal_length; - - bulk_data_desc_t bulkdata[UNIFI_MAX_DATA_REFERENCES]; -} card_signal_t; - - -/* - * Control structure for a generic ring buffer. - */ -#define UNIFI_QUEUE_NAME_MAX_LENGTH 16 -typedef struct -{ - card_signal_t *q_body; - - /* Num elements in queue (capacity is one less than this!) */ - u16 q_length; - - u16 q_wr_ptr; - u16 q_rd_ptr; - - char name[UNIFI_QUEUE_NAME_MAX_LENGTH]; -} q_t; - - -#define UNIFI_RESERVED_COMMAND_SLOTS 2 - -/* Considering approx 500 us per packet giving 0.5 secs */ -#define UNIFI_PACKETS_INTERVAL 1000 - -/* - * Dynamic slot reservation for QoS - */ -typedef struct -{ - u16 from_host_used_slots[UNIFI_NO_OF_TX_QS]; - u16 from_host_max_slots[UNIFI_NO_OF_TX_QS]; - u16 from_host_reserved_slots[UNIFI_NO_OF_TX_QS]; - - /* Parameters to determine if a queue was active. - If number of packets sent is greater than the threshold - for the queue, the queue is considered active and no - re reservation is done, it is important not to keep this - value too low */ - /* Packets sent during this interval */ - u16 packets_txed[UNIFI_NO_OF_TX_QS]; - u16 total_packets_txed; - - /* Number of packets to see if slots need to be reassigned */ - u16 packets_interval; - - /* Once a queue reaches a stable state, avoid processing */ - u8 queue_stable[UNIFI_NO_OF_TX_QS]; -} card_dynamic_slot_t; - - -/* These are type-safe and don't write incorrect values to the - * structure. */ - -/* Return queue slots used count - * params: - * const q_t *q - * returns: - * u16 - */ -#define CSR_WIFI_HIP_Q_SLOTS_USED(q) \ - (((q)->q_wr_ptr - (q)->q_rd_ptr < 0)? \ - ((q)->q_wr_ptr - (q)->q_rd_ptr + (q)->q_length) : ((q)->q_wr_ptr - (q)->q_rd_ptr)) - -/* Return queue slots free count - * params: - * const q_t *q - * returns: - * u16 - */ -#define CSR_WIFI_HIP_Q_SLOTS_FREE(q) \ - ((q)->q_length - CSR_WIFI_HIP_Q_SLOTS_USED((q)) - 1) - -/* Return slot signal data pointer - * params: - * const q_t *q - * u16 slot - * returns: - * card_signal_t * - */ -#define CSR_WIFI_HIP_Q_SLOT_DATA(q, slot) \ - ((q)->q_body + slot) - -/* Return queue next read slot - * params: - * const q_t *q - * returns: - * u16 slot offset - */ -#define CSR_WIFI_HIP_Q_NEXT_R_SLOT(q) \ - ((q)->q_rd_ptr) - -/* Return queue next write slot - * params: - * const q_t *q - * returns: - * u16 slot offset - */ -#define CSR_WIFI_HIP_Q_NEXT_W_SLOT(q) \ - ((q)->q_wr_ptr) - -/* Return updated queue pointer wrapped around its length - * params: - * const q_t *q - * u16 x amount to add to queue pointer - * returns: - * u16 wrapped queue pointer - */ -#define CSR_WIFI_HIP_Q_WRAP(q, x) \ - ((((x) >= (q)->q_length)?((x) % (q)->q_length) : (x))) - -/* Advance queue read pointer - * params: - * const q_t *q - */ -#define CSR_WIFI_HIP_Q_INC_R(q) \ - ((q)->q_rd_ptr = CSR_WIFI_HIP_Q_WRAP((q), (q)->q_rd_ptr + 1)) - -/* Advance queue write pointer - * params: - * const q_t *q - */ -#define CSR_WIFI_HIP_Q_INC_W(q) \ - ((q)->q_wr_ptr = CSR_WIFI_HIP_Q_WRAP((q), (q)->q_wr_ptr + 1)) - -enum unifi_host_state -{ - UNIFI_HOST_STATE_AWAKE = 0, - UNIFI_HOST_STATE_DROWSY = 1, - UNIFI_HOST_STATE_TORPID = 2 -}; - -typedef struct -{ - bulk_data_desc_t bd; - unifi_TrafficQueue queue; /* Used for dynamic slot reservation */ -} slot_desc_t; - -/* - * Structure describing a UniFi SDIO card. - */ -struct card -{ - /* - * Back pointer for the higher level OS code. This is passed as - * an argument to callbacks (e.g. for received data and indications). - */ - void *ospriv; - - /* - * mapping of HIP slot to MA-PACKET.req host tag, the - * array is indexed by slot numbers and each index stores - * information of the last host tag it was used for - */ - u32 *fh_slot_host_tag_record; - - - /* Info read from Symbol Table during probe */ - u32 build_id; - char build_id_string[128]; - - /* Retrieve from SDIO driver. */ - u16 chip_id; - - /* Read from GBL_CHIP_VERSION. */ - u16 chip_version; - - /* From the SDIO driver (probably 1) */ - u8 function; - - /* This is sused to get the register addresses and things. */ - ChipDescript *helper; - - /* - * Bit mask of PIOs for the loader to waggle during download. - * We assume these are connected to LEDs. The main firmware gets - * the mask from a MIB entry. - */ - s32 loader_led_mask; - - /* - * Support for flow control. When the from-host queue of signals - * is full, we ask the host upper layer to stop sending packets. When - * the queue drains we tell it that it can send packets again. - * We use this flag to remember the current state. - */ -#define card_is_tx_q_paused(card, q) (card->tx_q_paused_flag[q]) -#define card_tx_q_unpause(card, q) (card->tx_q_paused_flag[q] = 0) -#define card_tx_q_pause(card, q) (card->tx_q_paused_flag[q] = 1) - - u16 tx_q_paused_flag[UNIFI_TRAFFIC_Q_MAX + 1 + UNIFI_NO_OF_TX_QS]; /* defensive more than big enough */ - - /* UDI callback for logging UniFi interactions */ - udi_func_t udi_hook; - - u8 bh_reason_host; - u8 bh_reason_unifi; - - /* SDIO clock speed request from OS layer */ - u8 request_max_clock; - - /* Last SDIO clock frequency set */ - u32 sdio_clock_speed; - - /* - * Current host state (copy of value in IOABORT register and - * spinlock to protect it. - */ - enum unifi_host_state host_state; - - enum unifi_low_power_mode low_power_mode; - enum unifi_periodic_wake_mode periodic_wake_mode; - - /* - * Ring buffer of signal structs for a queue of data packets from - * the host. - * The queue is empty when fh_data_q_num_rd == fh_data_q_num_wr. - * To add a packet to the queue, copy it to index given by - * (fh_data_q_num_wr%UNIFI_SOFT_Q_LENGTH) and advance fh_data_q_num_wr. - * To take a packet from the queue, copy data from index given by - * (fh_data_q_num_rd%UNIFI_SOFT_Q_LENGTH) and advance fh_data_q_num_rd. - * fh_data_q_num_rd and fh_data_q_num_rd are both modulo 256. - */ - card_signal_t fh_command_q_body[UNIFI_SOFT_COMMAND_Q_LENGTH]; - q_t fh_command_queue; - - card_signal_t fh_traffic_q_body[UNIFI_NO_OF_TX_QS][UNIFI_SOFT_TRAFFIC_Q_LENGTH]; - q_t fh_traffic_queue[UNIFI_NO_OF_TX_QS]; - - /* - * Signal counts from UniFi SDIO Control Data Structure. - * These are cached and synchronised with the UniFi before and after - * a batch of operations. - * - * These are the modulo-256 count of signals written to or read from UniFi - * The value is incremented for every signal. - */ - s32 from_host_signals_w; - s32 from_host_signals_r; - s32 to_host_signals_r; - s32 to_host_signals_w; - - - /* Should specify buffer size as a number of signals */ - /* - * Enough for 10 th and 10 fh data slots: - * 1 * 10 * 8 = 80 - * 2 * 10 * 8 = 160 - */ -#define UNIFI_FH_BUF_SIZE 1024 - struct sigbuf - { - u8 *buf; /* buffer area */ - u8 *ptr; /* current pos */ - u16 count; /* signal count */ - u16 bufsize; - } fh_buffer; - struct sigbuf th_buffer; - - - /* - * Field to use for the incrementing value to write to the UniFi - * SHARED_IO_INTERRUPT register. - * Flag to say we need to generate an interrupt at end of processing. - */ - u32 unifi_interrupt_seq; - u8 generate_interrupt; - - - /* Pointers to the bulk data slots */ - slot_desc_t *from_host_data; - bulk_data_desc_t *to_host_data; - - - /* - * Index of the next (hopefully) free data slot. - * This is an optimisation that starts searching at a more likely point - * than the beginning. - */ - s16 from_host_data_head; - - /* Dynamic slot allocation for queues */ - card_dynamic_slot_t dynamic_slot_data; - - /* - * SDIO specific fields - */ - - /* Interface pointer for the SDIO library */ - CsrSdioFunction *sdio_if; - - /* Copy of config_data struct from the card */ - sdio_config_data_t config_data; - - /* SDIO address of the Initialised flag and Control Data struct */ - u32 init_flag_addr; - u32 sdio_ctrl_addr; - - /* The last value written to the Shared Data Memory Page register */ - u32 proc_select; - u32 dmem_page; - u32 pmem_page; - - /* SDIO traffic counters limited to 32 bits for Synergy compatibility */ - u32 sdio_bytes_read; - u32 sdio_bytes_written; - - u8 memory_resources_allocated; - - /* UniFi SDIO I/O Block size. */ - u16 sdio_io_block_size; - - /* Pad transfer sizes to SDIO block boundaries */ - u8 sdio_io_block_pad; - - /* Read from the XBV */ - struct FWOV fwov; - -#ifndef CSR_WIFI_HIP_TA_DISABLE - /* TA sampling */ - ta_data_t ta_sampling; -#endif - - /* Auto-coredump */ - s16 request_coredump_on_reset; /* request coredump on next reset */ - struct coredump_buf *dump_buf; /* root node */ - struct coredump_buf *dump_next_write; /* node to fill at next dump */ - struct coredump_buf *dump_cur_read; /* valid node to read, or NULL */ - -#ifdef CSR_WIFI_HIP_DATA_PLANE_PROFILE - struct cmd_profile - { - u32 cmd52_count; - u32 cmd53_count; - u32 tx_count; - u32 tx_cfm_count; - u32 rx_count; - u32 bh_count; - u32 process_count; - u32 protocol_count; - - u32 cmd52_f0_r_count; - u32 cmd52_f0_w_count; - u32 cmd52_r8or16_count; - u32 cmd52_w8or16_count; - u32 cmd52_r16_count; - u32 cmd52_w16_count; - u32 cmd52_r32_count; - - u32 sdio_cmd_signal; - u32 sdio_cmd_clear_slot; - u32 sdio_cmd_to_host; - u32 sdio_cmd_from_host; - u32 sdio_cmd_from_host_and_clear; - } hip_prof; - struct cmd_profile cmd_prof; -#endif - - /* Interrupt processing mode flags */ - u32 intmode; - -#ifdef UNIFI_DEBUG - u8 lsb; -#endif - - /* Historic firmware panic codes */ - u32 panic_data_phy_addr; - u32 panic_data_mac_addr; - u16 last_phy_panic_code; - u16 last_phy_panic_arg; - u16 last_mac_panic_code; - u16 last_mac_panic_arg; -#ifdef CSR_PRE_ALLOC_NET_DATA - bulk_data_desc_t bulk_data_desc_list[BULK_DATA_PRE_ALLOC_NUM]; - u16 prealloc_netdata_r; - u16 prealloc_netdata_w; -#endif -}; /* struct card */ - - -/* Reset types */ -enum unifi_reset_type -{ - UNIFI_COLD_RESET = 1, - UNIFI_WARM_RESET = 2 -}; - -/* - * unifi_set_host_state() implements signalling for waking UniFi from - * deep sleep. The host indicates to UniFi that it is in one of three states: - * Torpid - host has nothing to send, UniFi can go to sleep. - * Drowsy - host has data to send to UniFi. UniFi will respond with an - * SDIO interrupt. When hosts responds it moves to Awake. - * Awake - host has data to transfer, UniFi must stay awake. - * When host has finished, it moves to Torpid. - */ -CsrResult unifi_set_host_state(card_t *card, enum unifi_host_state state); - - -CsrResult unifi_set_proc_select(card_t *card, enum unifi_dbg_processors_select select); -s32 card_read_signal_counts(card_t *card); -bulk_data_desc_t* card_find_data_slot(card_t *card, s16 slot); - - -CsrResult unifi_read32(card_t *card, u32 unifi_addr, u32 *pdata); -CsrResult unifi_readnz(card_t *card, u32 unifi_addr, - void *pdata, u16 len); -s32 unifi_read_shared_count(card_t *card, u32 addr); - -CsrResult unifi_writen(card_t *card, u32 unifi_addr, void *pdata, u16 len); - -CsrResult unifi_bulk_rw(card_t *card, u32 handle, - void *pdata, u32 len, s16 direction); -CsrResult unifi_bulk_rw_noretry(card_t *card, u32 handle, - void *pdata, u32 len, s16 direction); -#define UNIFI_SDIO_READ 0 -#define UNIFI_SDIO_WRITE 1 - -CsrResult unifi_read_8_or_16(card_t *card, u32 unifi_addr, u8 *pdata); -CsrResult unifi_write_8_or_16(card_t *card, u32 unifi_addr, u8 data); -CsrResult unifi_read_direct_8_or_16(card_t *card, u32 addr, u8 *pdata); -CsrResult unifi_write_direct_8_or_16(card_t *card, u32 addr, u8 data); - -CsrResult unifi_read_direct16(card_t *card, u32 addr, u16 *pdata); -CsrResult unifi_read_direct32(card_t *card, u32 addr, u32 *pdata); -CsrResult unifi_read_directn(card_t *card, u32 addr, void *pdata, u16 len); - -CsrResult unifi_write_direct16(card_t *card, u32 addr, u16 data); -CsrResult unifi_write_directn(card_t *card, u32 addr, void *pdata, u16 len); - -CsrResult sdio_read_f0(card_t *card, u32 addr, u8 *pdata); -CsrResult sdio_write_f0(card_t *card, u32 addr, u8 data); - -void unifi_read_panic(card_t *card); -#ifdef CSR_PRE_ALLOC_NET_DATA -void prealloc_netdata_free(card_t *card); -CsrResult prealloc_netdata_alloc(card_t *card); -#endif -/* For diagnostic use */ -void dump(void *mem, u16 len); -void dump16(void *mem, u16 len); - -#endif /* __CARD_SDIO_H__ */ diff --git a/drivers/staging/csr/csr_wifi_hip_card_sdio_intr.c b/drivers/staging/csr/csr_wifi_hip_card_sdio_intr.c deleted file mode 100644 index cfe186e07071..000000000000 --- a/drivers/staging/csr/csr_wifi_hip_card_sdio_intr.c +++ /dev/null @@ -1,2595 +0,0 @@ -/***************************************************************************** - - (c) Cambridge Silicon Radio Limited 2012 - All rights reserved and confidential information of CSR - - Refer to LICENSE.txt included with this source for details - on the license terms. - -*****************************************************************************/ - -/* - * --------------------------------------------------------------------------- - * FILE: csr_wifi_hip_card_sdio_intr.c - * - * PURPOSE: - * Interrupt processing for the UniFi SDIO driver. - * - * We may need another signal queue of responses to UniFi to hold - * bulk data commands generated by read_to_host_signals(). - * - * --------------------------------------------------------------------------- - */ -#undef CSR_WIFI_HIP_NOISY - -#include "csr_wifi_hip_unifi.h" -#include "csr_wifi_hip_conversions.h" -#include "csr_wifi_hip_card.h" -#include "csr_wifi_hip_xbv.h" - - -/* - * If the SDIO link is idle for this time (in milliseconds), - * signal UniFi to go into Deep Sleep. - * Valid return value of unifi_bh(). - */ -#define UNIFI_DEFAULT_HOST_IDLE_TIMEOUT 5 -/* - * If the UniFi has not woken up for this time (in milliseconds), - * signal the bottom half to take action. - * Valid return value of unifi_bh(). - */ -#define UNIFI_DEFAULT_WAKE_TIMEOUT 1000 - - -static CsrResult process_bh(card_t *card); -static CsrResult handle_host_protocol(card_t *card, u8 *processed_something); - -static CsrResult flush_fh_buffer(card_t *card); - -static CsrResult check_fh_sig_slots(card_t *card, u16 needed, s32 *space); - -static CsrResult read_to_host_signals(card_t *card, s32 *processed); -static CsrResult process_to_host_signals(card_t *card, s32 *processed); - -static CsrResult process_bulk_data_command(card_t *card, - const u8 *cmdptr, - s16 cmd, u16 len); -static CsrResult process_clear_slot_command(card_t *card, - const u8 *cmdptr); -static CsrResult process_fh_cmd_queue(card_t *card, s32 *processed); -static CsrResult process_fh_traffic_queue(card_t *card, s32 *processed); -static void restart_packet_flow(card_t *card); -static CsrResult process_clock_request(card_t *card); - -#ifdef CSR_WIFI_HIP_NOISY -s16 dump_fh_buf = 0; -#endif /* CSR_WIFI_HIP_NOISY */ - -#ifdef CSR_WIFI_HIP_DEBUG_OFFLINE - -/* - * The unifi_debug_output buffer can be used to debug the HIP behaviour offline - * i.e. without using the tracing functions that change the timing. - * - * Call unifi_debug_log_to_buf() with printf arguments to store a string into - * unifi_debug_output. When unifi_debug_buf_dump() is called, the contents of the - * buffer are dumped with dump_str() which has to be implemented in the - * OS layer, during the porting exercise. The offset printed, holds the - * offset where the last character is (always a zero). - * - */ - -#define UNIFI_DEBUG_GBUFFER_SIZE 8192 -static char unifi_debug_output[UNIFI_DEBUG_GBUFFER_SIZE]; -static char *unifi_dbgbuf_ptr = unifi_debug_output; -static char *unifi_dbgbuf_start = unifi_debug_output; - -static void append_char(char c) -{ - /* write char and advance pointer */ - *unifi_dbgbuf_ptr++ = c; - /* wrap pointer at end of buffer */ - if ((unifi_dbgbuf_ptr - unifi_debug_output) >= UNIFI_DEBUG_GBUFFER_SIZE) - { - unifi_dbgbuf_ptr = unifi_debug_output; - } -} /* append_char() */ - - -void unifi_debug_string_to_buf(const char *str) -{ - const char *p = str; - while (*p) - { - append_char(*p); - p++; - } - /* Update start-of-buffer pointer */ - unifi_dbgbuf_start = unifi_dbgbuf_ptr + 1; - if ((unifi_dbgbuf_start - unifi_debug_output) >= UNIFI_DEBUG_GBUFFER_SIZE) - { - unifi_dbgbuf_start = unifi_debug_output; - } -} - - -void unifi_debug_log_to_buf(const char *fmt, ...) -{ -#define DEBUG_BUFFER_SIZE 80 - static char s[DEBUG_BUFFER_SIZE]; - va_list args; - - va_start(args, fmt); - vsnprintf(s, DEBUG_BUFFER_SIZE, fmt, args); - va_end(args); - - unifi_debug_string_to_buf(s); -} /* unifi_debug_log_to_buf() */ - - -/* Convert signed 32 bit (or less) integer to string */ -static void CsrUInt16ToHex(u16 number, char *str) -{ - u16 index; - u16 currentValue; - - for (index = 0; index < 4; index++) - { - currentValue = (u16) (number & 0x000F); - number >>= 4; - str[3 - index] = (char) (currentValue > 9 ? currentValue + 55 : currentValue + '0'); - } - str[4] = '\0'; -} - - -/* - * --------------------------------------------------------------------------- - * unifi_debug_hex_to_buf - * - * puts the contents of the passed buffer into the debug buffer as a hex string - * - * Arguments: - * buff buffer to print as hex - * length number of chars to print - * - * Returns: - * None. - * - * --------------------------------------------------------------------------- - */ -void unifi_debug_hex_to_buf(const char *buff, u16 length) -{ - char s[5]; - u16 i; - - for (i = 0; i < length; i = i + 2) - { - CsrUInt16ToHex(*((u16 *)(buff + i)), s); - unifi_debug_string_to_buf(s); - } -} - - -void unifi_debug_buf_dump(void) -{ - s32 offset = unifi_dbgbuf_ptr - unifi_debug_output; - - unifi_error(NULL, "HIP debug buffer offset=%d\n", offset); - dump_str(unifi_debug_output + offset, UNIFI_DEBUG_GBUFFER_SIZE - offset); - dump_str(unifi_debug_output, offset); -} /* unifi_debug_buf_dump() */ - - -#endif /* CSR_WIFI_HIP_DEBUG_OFFLINE */ - -#ifdef CSR_PRE_ALLOC_NET_DATA -#define NETDATA_PRE_ALLOC_BUF_SIZE 8000 - -void prealloc_netdata_free(card_t *card) -{ - unifi_warning(card->ospriv, "prealloc_netdata_free: IN: w=%d r=%d\n", card->prealloc_netdata_w, card->prealloc_netdata_r); - - while (card->bulk_data_desc_list[card->prealloc_netdata_r].data_length != 0) - { - unifi_warning(card->ospriv, "prealloc_netdata_free: r=%d\n", card->prealloc_netdata_r); - - unifi_net_data_free(card->ospriv, &card->bulk_data_desc_list[card->prealloc_netdata_r]); - card->prealloc_netdata_r++; - card->prealloc_netdata_r %= BULK_DATA_PRE_ALLOC_NUM; - } - card->prealloc_netdata_r = card->prealloc_netdata_w = 0; - - unifi_warning(card->ospriv, "prealloc_netdata_free: OUT: w=%d r=%d\n", card->prealloc_netdata_w, card->prealloc_netdata_r); -} - - -CsrResult prealloc_netdata_alloc(card_t *card) -{ - CsrResult r; - - unifi_trace(card->ospriv, UDBG5, "prealloc_netdata_alloc: IN: w=%d r=%d\n", card->prealloc_netdata_w, card->prealloc_netdata_r); - - while (card->bulk_data_desc_list[card->prealloc_netdata_w].data_length == 0) - { - r = unifi_net_data_malloc(card->ospriv, &card->bulk_data_desc_list[card->prealloc_netdata_w], NETDATA_PRE_ALLOC_BUF_SIZE); - if (r != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, "prealloc_netdata_alloc: Failed to allocate t-h bulk data\n"); - return CSR_RESULT_FAILURE; - } - card->prealloc_netdata_w++; - card->prealloc_netdata_w %= BULK_DATA_PRE_ALLOC_NUM; - } - unifi_trace(card->ospriv, UDBG5, "prealloc_netdata_alloc: OUT: w=%d r=%d\n", card->prealloc_netdata_w, card->prealloc_netdata_r); - - return CSR_RESULT_SUCCESS; -} - - -static CsrResult prealloc_netdata_get(card_t *card, bulk_data_desc_t *bulk_data_slot, u32 size) -{ - CsrResult r; - - unifi_trace(card->ospriv, UDBG5, "prealloc_netdata_get: IN: w=%d r=%d\n", card->prealloc_netdata_w, card->prealloc_netdata_r); - - if (card->bulk_data_desc_list[card->prealloc_netdata_r].data_length == 0) - { - unifi_error(card->ospriv, "prealloc_netdata_get: data_length = 0\n"); - } - - if ((size > NETDATA_PRE_ALLOC_BUF_SIZE) || (card->bulk_data_desc_list[card->prealloc_netdata_r].data_length == 0)) - { - unifi_warning(card->ospriv, "prealloc_netdata_get: Calling net_data_malloc\n"); - - r = unifi_net_data_malloc(card->ospriv, bulk_data_slot, size); - if (r != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, "prealloc_netdata_get: Failed to allocate t-h bulk data\n"); - return CSR_RESULT_FAILURE; - } - return CSR_RESULT_SUCCESS; - } - - *bulk_data_slot = card->bulk_data_desc_list[card->prealloc_netdata_r]; - card->bulk_data_desc_list[card->prealloc_netdata_r].os_data_ptr = NULL; - card->bulk_data_desc_list[card->prealloc_netdata_r].os_net_buf_ptr = NULL; - card->bulk_data_desc_list[card->prealloc_netdata_r].net_buf_length = 0; - card->bulk_data_desc_list[card->prealloc_netdata_r].data_length = 0; - - card->prealloc_netdata_r++; - card->prealloc_netdata_r %= BULK_DATA_PRE_ALLOC_NUM; - - unifi_trace(card->ospriv, UDBG5, "prealloc_netdata_get: OUT: w=%d r=%d\n", card->prealloc_netdata_w, card->prealloc_netdata_r); - - return CSR_RESULT_SUCCESS; -} - - -#endif - -/* - * --------------------------------------------------------------------------- - * unifi_sdio_interrupt_handler - * - * This function should be called by the OS-dependent code to handle - * an SDIO interrupt from the UniFi. - * - * Arguments: - * card Pointer to card context structure. - * - * Returns: - * None. - * - * Notes: This function may be called in DRS context. In this case, - * tracing with the unifi_trace(), etc, is not allowed. - * --------------------------------------------------------------------------- - */ -void unifi_sdio_interrupt_handler(card_t *card) -{ - /* - * Set the flag to say reason for waking was SDIO interrupt. - * Then ask the OS layer to run the unifi_bh to give attention to the UniFi. - */ - card->bh_reason_unifi = 1; - (void)unifi_run_bh(card->ospriv); -} /* sdio_interrupt_handler() */ - - -/* - * --------------------------------------------------------------------------- - * unifi_configure_low_power_mode - * - * This function should be called by the OS-dependent when - * the deep sleep signaling needs to be enabled or disabled. - * - * Arguments: - * card Pointer to card context structure. - * low_power_mode Disable/Enable the deep sleep signaling - * periodic_wake_mode UniFi wakes host periodically. - * - * Returns: - * CSR_RESULT_SUCCESS on success or a CSR error code. - * --------------------------------------------------------------------------- - */ -CsrResult unifi_configure_low_power_mode(card_t *card, - enum unifi_low_power_mode low_power_mode, - enum unifi_periodic_wake_mode periodic_wake_mode) -{ - card->low_power_mode = low_power_mode; - card->periodic_wake_mode = periodic_wake_mode; - - unifi_trace(card->ospriv, UDBG1, - "unifi_configure_low_power_mode: new mode = %s, wake_host = %s\n", - (low_power_mode == UNIFI_LOW_POWER_DISABLED)?"disabled" : "enabled", - (periodic_wake_mode == UNIFI_PERIODIC_WAKE_HOST_DISABLED)?"FALSE" : "TRUE"); - - (void)unifi_run_bh(card->ospriv); - return CSR_RESULT_SUCCESS; -} /* unifi_configure_low_power_mode() */ - - -/* - * --------------------------------------------------------------------------- - * unifi_force_low_power_mode - * - * This function should be called by the OS-dependent when - * UniFi needs to be set to the low power mode (e.g. on suspend) - * - * Arguments: - * card Pointer to card context structure. - * - * Returns: - * CSR_RESULT_SUCCESS on success or a CSR error code. - * --------------------------------------------------------------------------- - */ -CsrResult unifi_force_low_power_mode(card_t *card) -{ - if (card->low_power_mode == UNIFI_LOW_POWER_DISABLED) - { - unifi_error(card->ospriv, "Attempt to set mode to TORPID when lower power mode is disabled\n"); - return CSR_WIFI_HIP_RESULT_INVALID_VALUE; - } - - return unifi_set_host_state(card, UNIFI_HOST_STATE_TORPID); -} /* unifi_force_low_power_mode() */ - - -/* - * --------------------------------------------------------------------------- - * unifi_bh - * - * This function should be called by the OS-dependent code when - * host and/or UniFi has requested an exchange of messages. - * - * Arguments: - * card Pointer to card context structure. - * - * Returns: - * CSR_RESULT_SUCCESS on success or a CSR error code. - * --------------------------------------------------------------------------- - */ -CsrResult unifi_bh(card_t *card, u32 *remaining) -{ - CsrResult r; - CsrResult csrResult; - u8 pending; - s32 iostate, j; - const enum unifi_low_power_mode low_power_mode = card->low_power_mode; - u16 data_slots_used = 0; - - - /* Process request to raise the maximum SDIO clock */ - r = process_clock_request(card); - if (r != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, "Error setting maximum SDIO clock\n"); - goto exit; - } - - /* - * Why was the BH thread woken? - * If it was an SDIO interrupt, UniFi is awake and we need to process it. - * If it was a host process queueing data, then we need to awaken UniFi. - * - * Priority of flags is top down. - * - * ----------------------------------------------------------+ - * \state| AWAKE | DROWSY | TORPID | - * flag\ | | | | - * ---------+--------------+----------------+----------------| - * | do the host | go to AWAKE and| go to AWAKE and| - * unifi | protocol | do the host | do the host | - * | | protocol | protocol | - * ---------+--------------+----------------+----------------| - * | do the host | | | - * host | protocol | do nothing | go to DROWSY | - * | | | | - * ---------+--------------+----------------+----------------| - * | | | should not | - * timeout | go to TORPID | error, unifi | occur | - * | | didn't wake up | do nothing | - * ----------------------------------------------------------+ - * - * Note that if we end up in the AWAKE state we always do the host protocol. - */ - - do - { - /* - * When the host state is set to DROWSY, then we can not disable the - * interrupts as UniFi can generate an interrupt even when the INT_ENABLE - * register has the interrupts disabled. This interrupt will be lost. - */ - if (card->host_state == UNIFI_HOST_STATE_DROWSY || card->host_state == UNIFI_HOST_STATE_TORPID) - { - u8 reason_unifi; - - /* - * An interrupt may occur while or after we cache the reason. - * This interrupt will cause the unifi_bh() to be scheduled again. - * Any interrupt that has happened before the register is read - * and is considered spurious has to acknowledged. - */ - reason_unifi = card->bh_reason_unifi; - - /* - * If an interrupt is received, check if it was a real one, - * set the host state to AWAKE and run the BH. - */ - r = CardPendingInt(card, &pending); - if (r != CSR_RESULT_SUCCESS) - { - goto exit; - } - - if (pending) - { - unifi_trace(card->ospriv, UDBG5, - "UNIFI_HOST_STATE_%s: Set state to AWAKE.\n", - (card->host_state == UNIFI_HOST_STATE_TORPID)?"TORPID" : "DROWSY"); - - r = unifi_set_host_state(card, UNIFI_HOST_STATE_AWAKE); - if (r == CSR_RESULT_SUCCESS) - { - (*remaining) = 0; - break; - } - } - else if (reason_unifi) - { - CsrSdioInterruptAcknowledge(card->sdio_if); - } - - /* - * If an chip is in TORPID, and the host wants to wake it up, - * set the host state to DROWSY and wait for the wake-up interrupt. - */ - if ((card->host_state == UNIFI_HOST_STATE_TORPID) && card->bh_reason_host) - { - r = unifi_set_host_state(card, UNIFI_HOST_STATE_DROWSY); - if (r == CSR_RESULT_SUCCESS) - { - /* - * set the timeout value to UNIFI_DEFAULT_WAKE_TIMEOUT - * to capture a wake error. - */ - card->bh_reason_host = 0; - (*remaining) = UNIFI_DEFAULT_WAKE_TIMEOUT; - return CSR_RESULT_SUCCESS; - } - - goto exit; - } - - /* - * If the chip is in DROWSY, and the timeout expires, - * we need to reset the chip. This should never occur. - * (If it does, check that the calling thread set "remaining" - * according to the time remaining when unifi_bh() was called). - */ - if ((card->host_state == UNIFI_HOST_STATE_DROWSY) && ((*remaining) == 0)) - { - unifi_error(card->ospriv, "UniFi did not wake up on time...\n"); - - /* - * Check if Function1 has gone away or - * if we missed an SDIO interrupt. - */ - r = unifi_check_io_status(card, &iostate); - if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE) - { - goto exit; - } - /* Need to reset and reboot */ - return CSR_RESULT_FAILURE; - } - } - else - { - if (card->bh_reason_unifi || card->bh_reason_host) - { - break; - } - - if (((*remaining) == 0) && (low_power_mode == UNIFI_LOW_POWER_ENABLED)) - { - r = unifi_set_host_state(card, UNIFI_HOST_STATE_TORPID); - if (r == CSR_RESULT_SUCCESS) - { - (*remaining) = 0; - return CSR_RESULT_SUCCESS; - } - - goto exit; - } - } - - /* No need to run the host protocol */ - return CSR_RESULT_SUCCESS; - } while (0); - - - /* Disable the SDIO interrupts while doing SDIO ops */ - csrResult = CsrSdioInterruptDisable(card->sdio_if); - if (csrResult == CSR_SDIO_RESULT_NO_DEVICE) - { - r = CSR_WIFI_HIP_RESULT_NO_DEVICE; - goto exit; - } - if (csrResult != CSR_RESULT_SUCCESS) - { - r = ConvertCsrSdioToCsrHipResult(card, csrResult); - unifi_error(card->ospriv, "Failed to disable SDIO interrupts. unifi_bh queues error.\n"); - goto exit; - } - - /* Now that the interrupts are disabled, ack the interrupt */ - CsrSdioInterruptAcknowledge(card->sdio_if); - - /* Run the HIP */ - r = process_bh(card); - if (r != CSR_RESULT_SUCCESS) - { - goto exit; - } - - /* - * If host is now idle, schedule a timer for the delay before we - * let UniFi go into deep sleep. - * If the timer goes off, we will move to TORPID state. - * If UniFi raises an interrupt in the meantime, we will cancel - * the timer and start a new one when we become idle. - */ - for (j = 0; j < UNIFI_NO_OF_TX_QS; j++) - { - data_slots_used += CSR_WIFI_HIP_Q_SLOTS_USED(&card->fh_traffic_queue[j]); - } - - if ((low_power_mode == UNIFI_LOW_POWER_ENABLED) && (data_slots_used == 0)) - { -#ifndef CSR_WIFI_HIP_TA_DISABLE - if (card->ta_sampling.traffic_type != CSR_WIFI_ROUTER_CTRL_TRAFFIC_TYPE_PERIODIC) - { -#endif - /* return the UNIFI_DEFAULT_HOST_IDLE_TIMEOUT, so we can go to sleep. */ - unifi_trace(card->ospriv, UDBG5, - "Traffic is not periodic, set timer for TORPID.\n"); - (*remaining) = UNIFI_DEFAULT_HOST_IDLE_TIMEOUT; -#ifndef CSR_WIFI_HIP_TA_DISABLE - } - else - { - unifi_trace(card->ospriv, UDBG5, - "Traffic is periodic, set unifi to TORPID immediately.\n"); - if (CardAreAllFromHostDataSlotsEmpty(card) == 1) - { - r = unifi_set_host_state(card, UNIFI_HOST_STATE_TORPID); - if (r != CSR_RESULT_SUCCESS) - { - goto exit; - } - } - } -#endif - } - - csrResult = CsrSdioInterruptEnable(card->sdio_if); - if (csrResult == CSR_SDIO_RESULT_NO_DEVICE) - { - r = CSR_WIFI_HIP_RESULT_NO_DEVICE; - } - if (csrResult != CSR_RESULT_SUCCESS) - { - r = ConvertCsrSdioToCsrHipResult(card, csrResult); - unifi_error(card->ospriv, "Failed to enable SDIO interrupt\n"); - } - -exit: - - unifi_trace(card->ospriv, UDBG4, "New state=%d\n", card->host_state); - - if (r != CSR_RESULT_SUCCESS) - { -#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_SDIO_TRACE) - unifi_debug_buf_dump(); -#endif - /* If an interrupt has been raised, ack it here */ - if (card->bh_reason_unifi) - { - CsrSdioInterruptAcknowledge(card->sdio_if); - } - - unifi_error(card->ospriv, - "unifi_bh: state=%d %c, clock=%dkHz, interrupt=%d host=%d, power_save=%s\n", - card->host_state, - (card->host_state == UNIFI_HOST_STATE_AWAKE)?'A' : (card->host_state == UNIFI_HOST_STATE_DROWSY)?'D' : 'T', - card->sdio_clock_speed / 1000, - card->bh_reason_unifi, card->bh_reason_host, - (low_power_mode == UNIFI_LOW_POWER_DISABLED)?"disabled" : "enabled"); - - /* Try to capture firmware panic codes */ - (void)unifi_capture_panic(card); - - /* Ask for a mini-coredump when the driver has reset UniFi */ - (void)unifi_coredump_request_at_next_reset(card, 1); - } - - return r; -} /* unifi_bh() */ - - -/* - * --------------------------------------------------------------------------- - * process_clock_request - * - * Handle request from the OS layer to increase the SDIO clock speed. - * The fast clock is limited until the firmware has indicated that it has - * completed initialisation to the OS layer. - * - * Arguments: - * card Pointer to card context structure. - * - * Returns: - * CSR_RESULT_SUCCESS on success or CSR error code. - * --------------------------------------------------------------------------- - */ -static CsrResult process_clock_request(card_t *card) -{ - CsrResult r = CSR_RESULT_SUCCESS; - CsrResult csrResult; - - if (!card->request_max_clock) - { - return CSR_RESULT_SUCCESS; /* No pending request */ - } - - /* - * The SDIO clock speed request from the OS layer is only acted upon if - * the UniFi is awake. If it was in any other state, the clock speed will - * transition through SAFE to MAX while the host wakes it up, and the - * final speed reached will be UNIFI_SDIO_CLOCK_MAX_HZ. - * This assumes that the SME never requests low power mode while the f/w - * initialisation takes place. - */ - if (card->host_state == UNIFI_HOST_STATE_AWAKE) - { - unifi_trace(card->ospriv, UDBG1, "Set SDIO max clock\n"); - csrResult = CsrSdioMaxBusClockFrequencySet(card->sdio_if, UNIFI_SDIO_CLOCK_MAX_HZ); - if (csrResult != CSR_RESULT_SUCCESS) - { - r = ConvertCsrSdioToCsrHipResult(card, csrResult); - } - else - { - card->sdio_clock_speed = UNIFI_SDIO_CLOCK_MAX_HZ; /* log the new freq */ - } - } - else - { - unifi_trace(card->ospriv, UDBG1, "Will set SDIO max clock after wakeup\n"); - } - - /* Cancel the request now that it has been acted upon, or is about to be - * by the wakeup mechanism - */ - card->request_max_clock = 0; - - return r; -} - - -/* - * --------------------------------------------------------------------------- - * process_bh - * - * Exchange messages with UniFi - * - * Arguments: - * card Pointer to card context structure. - * - * Returns: - * CSR_RESULT_SUCCESS on success or CSR error code. - * --------------------------------------------------------------------------- - */ -static CsrResult process_bh(card_t *card) -{ - CsrResult r; - u8 more; - more = FALSE; - - /* Process the reasons (interrupt, signals) */ - do - { - /* - * Run in a while loop, to save clearing the interrupts - * every time around the outside loop. - */ - do - { - /* If configured to run the HIP just once, skip first loop */ - if (card->intmode & CSR_WIFI_INTMODE_RUN_BH_ONCE) - { - break; - } - - r = handle_host_protocol(card, &more); - if (r != CSR_RESULT_SUCCESS) - { - return r; - } - -#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_DATA_PLANE_PROFILE) - unifi_debug_log_to_buf("c52=%d c53=%d tx=%d txc=%d rx=%d s=%d t=%d fc=%d\n", - card->cmd_prof.cmd52_count, - card->cmd_prof.cmd53_count, - card->cmd_prof.tx_count, - card->cmd_prof.tx_cfm_count, - card->cmd_prof.rx_count, - card->cmd_prof.sdio_cmd_signal, - card->cmd_prof.sdio_cmd_to_host, - card->cmd_prof.sdio_cmd_from_host_and_clear - ); - - card->cmd_prof.cmd52_count = card->cmd_prof.cmd53_count = 0; - card->cmd_prof.tx_count = card->cmd_prof.tx_cfm_count = card->cmd_prof.rx_count = 0; - - card->cmd_prof.cmd52_f0_r_count = 0; - card->cmd_prof.cmd52_f0_w_count = 0; - card->cmd_prof.cmd52_r8or16_count = 0; - card->cmd_prof.cmd52_w8or16_count = 0; - card->cmd_prof.cmd52_r16_count = 0; - card->cmd_prof.cmd52_w16_count = 0; - card->cmd_prof.cmd52_r32_count = 0; - - card->cmd_prof.sdio_cmd_signal = 0; - card->cmd_prof.sdio_cmd_clear_slot = 0; - card->cmd_prof.sdio_cmd_to_host = 0; - card->cmd_prof.sdio_cmd_from_host = 0; - card->cmd_prof.sdio_cmd_from_host_and_clear = 0; -#endif - - - } while (more || card->bh_reason_unifi || card->bh_reason_host); - - /* Acknowledge the h/w interrupt */ - r = CardClearInt(card); - if (r != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, "Failed to acknowledge interrupt.\n"); - return r; - } - - /* - * UniFi may have tried to generate an interrupt during the - * CardClearInt() was running. So, we need to run the host - * protocol again, to check if there are any pending requests. - */ - r = handle_host_protocol(card, &more); - if (r != CSR_RESULT_SUCCESS) - { - return r; - } - -#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_DATA_PLANE_PROFILE) - unifi_debug_log_to_buf("c52=%d c53=%d tx=%d txc=%d rx=%d s=%d t=%d fc=%d\n", - card->cmd_prof.cmd52_count, - card->cmd_prof.cmd53_count, - card->cmd_prof.tx_count, - card->cmd_prof.tx_cfm_count, - card->cmd_prof.rx_count, - card->cmd_prof.sdio_cmd_signal, - card->cmd_prof.sdio_cmd_to_host, - card->cmd_prof.sdio_cmd_from_host_and_clear - ); - - card->cmd_prof.cmd52_count = card->cmd_prof.cmd53_count = 0; - card->cmd_prof.tx_count = card->cmd_prof.tx_cfm_count = card->cmd_prof.rx_count = 0; - - card->cmd_prof.cmd52_f0_r_count = 0; - card->cmd_prof.cmd52_f0_w_count = 0; - card->cmd_prof.cmd52_r8or16_count = 0; - card->cmd_prof.cmd52_w8or16_count = 0; - card->cmd_prof.cmd52_r16_count = 0; - card->cmd_prof.cmd52_w16_count = 0; - card->cmd_prof.cmd52_r32_count = 0; - - card->cmd_prof.sdio_cmd_signal = 0; - card->cmd_prof.sdio_cmd_clear_slot = 0; - card->cmd_prof.sdio_cmd_to_host = 0; - card->cmd_prof.sdio_cmd_from_host = 0; - card->cmd_prof.sdio_cmd_from_host_and_clear = 0; -#endif - /* If configured to run the HIP just once, work is now done */ - if (card->intmode & CSR_WIFI_INTMODE_RUN_BH_ONCE) - { - break; - } - - } while (more || card->bh_reason_unifi || card->bh_reason_host); - -#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_DATA_PLANE_PROFILE) - if ((card->intmode & CSR_WIFI_INTMODE_RUN_BH_ONCE) == 0) - { - unifi_debug_log_to_buf("proc=%d\n", - card->cmd_prof.process_count); - } -#endif - - return CSR_RESULT_SUCCESS; -} /* process_bh() */ - - -/* - * --------------------------------------------------------------------------- - * handle_host_protocol - * - * This function implements the Host Interface Protocol (HIP) as - * described in the Host Interface Protocol Specification. - * - * Arguments: - * card Pointer to card context structure. - * processed_something Pointer to location to update processing status: - * TRUE when data was transferred - * FALSE when no data was transferred (queues empty) - * - * Returns: - * CSR_RESULT_SUCCESS on success or CSR error code. - * --------------------------------------------------------------------------- - */ -static CsrResult handle_host_protocol(card_t *card, u8 *processed_something) -{ - CsrResult r; - s32 done; - - *processed_something = FALSE; - -#ifdef CSR_WIFI_HIP_NOISY - unifi_error(card->ospriv, " ======================== \n"); -#endif /* CSR_WIFI_HIP_NOISY */ - -#ifdef CSR_WIFI_HIP_DATA_PLANE_PROFILE - card->cmd_prof.process_count++; -#endif - - card->bh_reason_unifi = card->bh_reason_host = 0; - card->generate_interrupt = 0; - - - /* - * (Re)fill the T-H signal buffer - */ - r = read_to_host_signals(card, &done); - if (r != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, "Error occurred reading to-host signals\n"); - return r; - } - if (done > 0) - { - *processed_something = TRUE; - } - - /* - * Process any to-host signals. - * Perform any requested CMD53 transfers here, but just queue any - * bulk data command responses. - */ - r = process_to_host_signals(card, &done); - if (r != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, "Error occurred processing to-host signals\n"); - return r; - } - - /* Now send any signals in the F-H queues */ - /* Give precedence to the command queue */ - r = process_fh_cmd_queue(card, &done); - if (r != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, "Error occurred processing from-host signals\n"); - return r; - } - if (done > 0) - { - *processed_something = TRUE; - } - - r = process_fh_traffic_queue(card, &done); - if (r != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, "Error occurred processing from-host data signals\n"); - return r; - } - if (done > 0) - { - *processed_something = TRUE; - } - - /* Flush out the batch of signals to the UniFi. */ - r = flush_fh_buffer(card); - if (r != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, "Failed to copy from-host signals to UniFi\n"); - return r; - } - - - /* - * Send the host interrupt to say the queues have been modified. - */ - if (card->generate_interrupt) - { - r = CardGenInt(card); - if (r != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, "Failed to notify UniFi that queues have been modified.\n"); - return r; - } - } - -#ifdef CSR_WIFI_RX_PATH_SPLIT -#ifdef CSR_WIFI_RX_PATH_SPLIT_DONT_USE_WQ - unifi_rx_queue_flush(card->ospriv); -#endif -#endif - - /* See if we can re-enable transmission now */ - restart_packet_flow(card); - -#ifdef CSR_PRE_ALLOC_NET_DATA - r = prealloc_netdata_alloc(card); - if (r != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, "prealloc_netdata failed\n"); - return r; - } -#endif - - /* - * Don't put the thread sleep if we just interacted with the chip, - * there might be more to do if we look again. - */ - return r; -} /* handle_host_protocol() */ - - -/* - * Rounds the given signal length in bytes to a whole number - * of sig_frag_size. - */ -#define GET_CHUNKS_FOR(SIG_FRAG_SIZE, LENGTH) (((LENGTH) + ((SIG_FRAG_SIZE)-1)) / (SIG_FRAG_SIZE)) - - -/* - * --------------------------------------------------------------------------- - * read_to_host_signals - * - * Read everything pending in the UniFi TH signal buffer. - * Only do it if the local buffer is empty. - * - * Arguments: - * card Pointer to card context struct - * processed Number of signals read: - * 0 if there were no signals pending, - * 1 if we read at least one signal - * Returns: - * CSR error code if an error occurred. - * --------------------------------------------------------------------------- - */ -static CsrResult read_to_host_signals(card_t *card, s32 *processed) -{ - s32 count_thw, count_thr; - s32 unread_chunks, unread_bytes; - CsrResult r; - - *processed = 0; - - /* Read any pending signals or bulk data commands */ - count_thw = unifi_read_shared_count(card, card->sdio_ctrl_addr + 4); - if (count_thw < 0) - { - unifi_error(card->ospriv, "Failed to read to-host sig written count\n"); - return CSR_RESULT_FAILURE; - } - card->to_host_signals_w = count_thw; /* diag */ - - count_thr = card->to_host_signals_r; - - if (count_thw == count_thr) - { - return CSR_RESULT_SUCCESS; - } - - unread_chunks = - (((count_thw - count_thr) + 128) % 128) - card->th_buffer.count; - - if (unread_chunks == 0) - { - return CSR_RESULT_SUCCESS; - } - - unread_bytes = card->config_data.sig_frag_size * unread_chunks; - - - r = unifi_bulk_rw(card, - card->config_data.tohost_sigbuf_handle, - card->th_buffer.ptr, - unread_bytes, - UNIFI_SDIO_READ); - if (r != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, "Failed to read ToHost signal\n"); - return r; - } - - card->th_buffer.ptr += unread_bytes; - card->th_buffer.count += (u16)unread_chunks; - - *processed = 1; - - return CSR_RESULT_SUCCESS; -} /* read_to_host_signals() */ - - -/* - * --------------------------------------------------------------------------- - * update_to_host_signals_r - * - * Advance the shared-memory count of chunks read from the to-host - * signal buffer. - * Raise a UniFi internal interrupt to tell the firmware that the - * count has changed. - * - * Arguments: - * card Pointer to card context struct - * pending Number of chunks remaining - * - * Returns: - * CSR_RESULT_SUCCESS on success or CSR error code - * --------------------------------------------------------------------------- - */ -static CsrResult update_to_host_signals_r(card_t *card, s16 pending) -{ - CsrResult r; - - card->to_host_signals_r = - (card->to_host_signals_r + (card->th_buffer.count - pending)) % 128; - card->th_buffer.count = pending; - - /* Update the count of signals read */ - r = unifi_write_8_or_16(card, card->sdio_ctrl_addr + 6, - (u8)card->to_host_signals_r); - if (r != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, "Failed to update to-host signals read\n"); - return r; - } - - r = CardGenInt(card); - if (r != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, "Failed to notify UniFi that we processed to-host signals.\n"); - return r; - } - - card->generate_interrupt = 0; - - return CSR_RESULT_SUCCESS; -} /* update_to_host_signals_r() */ - - -/* - * --------------------------------------------------------------------------- - * read_unpack_cmd - * - * Converts a wire-formatted command to the host bulk_data_cmd_t structure. - * - * Arguments: - * ptr Pointer to the command - * bulk_data_cmd Pointer to the host structure - * - * Returns: - * None. - * --------------------------------------------------------------------------- - */ -static void read_unpack_cmd(const u8 *ptr, bulk_data_cmd_t *bulk_data_cmd) -{ - s16 index = 0; - bulk_data_cmd->cmd_and_len = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - bulk_data_cmd->data_slot = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - bulk_data_cmd->offset = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - bulk_data_cmd->buffer_handle = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; -} /* read_unpack_cmd */ - - -/* - * --------------------------------------------------------------------------- - * process_to_host_signals - * - * Read and dispatch signals from the UniFi - * - * Arguments: - * card Pointer to card context struct - * processed Pointer to location to write processing result: - * 0 if there were no signals pending, - * 1 if we read at least one signal - * - * Returns: - * CSR error code if there was an error - * - * Notes: - * Since bulk data transfers can take a long time, if we wait until - * all are done before we acknowledge the signals, the UniFi runs out - * of buffer space. Therefore we keep a count of the bytes transferred - * in bulk data commands, and update the to-host-signals-read count - * if we've done a large transfer. - * - * All data in the f/w is stored in a little endian format, without any - * padding bytes. Every read from the memory has to be transformed in - * host (cpu specific) format, before we can process it. Therefore we - * use read_unpack_cmd() and read_unpack_signal() to convert the raw data - * contained in the card->th_buffer.buf to host structures. - * Important: UDI clients use wire-formatted structures, so we need to - * indicate all data, as we have read it from the device. - * --------------------------------------------------------------------------- - */ -static CsrResult process_to_host_signals(card_t *card, s32 *processed) -{ - s16 pending; - s16 remaining; - u8 *bufptr; - bulk_data_param_t data_ptrs; - s16 cmd; - u16 sig_len; - s16 i; - u16 chunks_in_buf; - u16 bytes_transferred = 0; - CsrResult r = CSR_RESULT_SUCCESS; - - *processed = 0; - - pending = card->th_buffer.count; - - /* Are there new to-host signals? */ - unifi_trace(card->ospriv, UDBG4, "handling %d to-host chunks\n", pending); - - if (!pending) - { - return CSR_RESULT_SUCCESS; - } - - /* - * This is a pointer to the raw data we have read from the f/w. - * Can be a signal or a command. Note that we need to convert - * it to a host structure before we process it. - */ - bufptr = card->th_buffer.buf; - - while (pending > 0) - { - s16 f_flush_count = 0; - - /* - * Command and length are common to signal and bulk data msgs. - * If command == 0 (i.e. a signal), len is number of bytes - * *following* the 2-byte header. - */ - cmd = bufptr[1] >> 4; - sig_len = bufptr[0] + ((bufptr[1] & 0x0F) << 8); - -#ifdef CSR_WIFI_HIP_NOISY - unifi_error(card->ospriv, "Received UniFi msg cmd=%d, len=%d\n", - cmd, sig_len); -#endif /* CSR_WIFI_HIP_NOISY */ - - if ((sig_len == 0) && - ((cmd != SDIO_CMD_CLEAR_SLOT) && (cmd != SDIO_CMD_PADDING))) - { - unifi_error(card->ospriv, "incomplete signal or command: has size zero\n"); - return CSR_RESULT_FAILURE; - } - /* - * Make sure the buffer contains a complete message. - * Signals may occupy multiple chunks, bulk-data commands occupy - * one chunk. - */ - if (cmd == SDIO_CMD_SIGNAL) - { - chunks_in_buf = GET_CHUNKS_FOR(card->config_data.sig_frag_size, (u16)(sig_len + 2)); - } - else - { - chunks_in_buf = 1; - } - - if (chunks_in_buf > (u16)pending) - { - unifi_error(card->ospriv, "incomplete signal (0x%x?): need %d chunks, got %d\n", - GET_SIGNAL_ID(bufptr + 2), - chunks_in_buf, pending); - unifi_error(card->ospriv, " thsw=%d, thsr=%d\n", - card->to_host_signals_w, - card->to_host_signals_r); - return CSR_RESULT_FAILURE; - } - - - switch (cmd) - { - case SDIO_CMD_SIGNAL: - /* This is a signal. Read the rest of it and then handle it. */ -#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_DATA_PLANE_PROFILE) - card->cmd_prof.sdio_cmd_signal++; -#endif - - for (i = 0; i < UNIFI_MAX_DATA_REFERENCES; i++) - { - /* Retrieve dataRefs[i].DataLength */ - u16 data_len = GET_PACKED_DATAREF_LEN(bufptr + 2, i); - - /* - * The bulk data length in the signal can not be greater than - * the maximun length allowed by the SDIO config structure. - */ - if (data_len > card->config_data.data_slot_size) - { - unifi_error(card->ospriv, - "Bulk Data length (%d) exceeds Maximum Bulk Data length (%d)\n", - data_len, card->config_data.data_slot_size); - return CSR_RESULT_FAILURE; - } - - /* - * Len here might not be the same as the length in the - * bulk data slot. The slot length will always be even, - * but len could be odd. - */ - if (data_len != 0) - { - /* Retrieve dataRefs[i].SlotNumber */ - s16 slot = GET_PACKED_DATAREF_SLOT(bufptr + 2, i); - - if (slot >= card->config_data.num_tohost_data_slots) - { - unifi_error(card->ospriv, "!!!bad slot number in to-host signal: %d, sig 0x%X\n", - slot, cmd); - return CSR_RESULT_FAILURE; - } - - data_ptrs.d[i].os_data_ptr = card->to_host_data[slot].os_data_ptr; - data_ptrs.d[i].os_net_buf_ptr = card->to_host_data[slot].os_net_buf_ptr; - data_ptrs.d[i].net_buf_length = card->to_host_data[slot].net_buf_length; - data_ptrs.d[i].data_length = data_len; - } - else - { - UNIFI_INIT_BULK_DATA(&data_ptrs.d[i]); - } - } - - /* - * Log the signal to the UDI, before call unifi_receive_event() as - * it can modify the bulk data. - */ - if (card->udi_hook) - { - (*card->udi_hook)(card->ospriv, bufptr + 2, sig_len, - &data_ptrs, UDI_LOG_TO_HOST); - } - -#ifdef CSR_WIFI_HIP_DATA_PLANE_PROFILE - if (GET_SIGNAL_ID(bufptr + 2) == CSR_MA_PACKET_CONFIRM_ID) - { - card->cmd_prof.tx_cfm_count++; - } - else if (GET_SIGNAL_ID(bufptr + 2) == CSR_MA_PACKET_INDICATION_ID) - { - if (data_ptrs.d[0].os_data_ptr) - { - if ((*data_ptrs.d[0].os_data_ptr) & 0x08) - { - card->cmd_prof.rx_count++; - } - } - } -#endif - /* - * Check if the signal is MA-PACKET.cfm and if so check the status. - * If the status is failure, search through the slot records to find - * if any slots are occupied for this host tag. This can happen if - * f/w has not downloaded the bulkdata and before that itself it has - * signalled the confirm with failure. If it finds a slot with that - * host tag then, it clears the corresponding slot - */ - - if (GET_SIGNAL_ID(bufptr + 2) == CSR_MA_PACKET_CONFIRM_ID) - { - /* Get host tag and transmission status */ - u32 host_tag = GET_PACKED_MA_PACKET_CONFIRM_HOST_TAG(bufptr + 2); - u16 status = GET_PACKED_MA_PACKET_CONFIRM_TRANSMISSION_STATUS(bufptr + 2); - - unifi_trace(card->ospriv, UDBG4, "process_to_host_signals signal ID=%x host Tag=%x status=%x\n", - GET_SIGNAL_ID(bufptr + 2), host_tag, status); - - /* If transmission status is failure then search through the slot records - * and if for any slot records the clear slot is not done then do it now - */ - - if (status && (card->fh_slot_host_tag_record)) - { - u16 num_fh_slots = card->config_data.num_fromhost_data_slots; - - /* search through the list of slot records and match with host tag - * If a slot is not yet cleared then clear the slot from here - */ - for (i = 0; i < num_fh_slots; i++) - { - if (card->fh_slot_host_tag_record[i] == host_tag) - { -#ifdef CSR_WIFI_REQUEUE_PACKET_TO_HAL - /* Invoke the HAL module function to requeue it back to HAL Queues */ - r = unifi_reque_ma_packet_request(card->ospriv, host_tag, status, &card->from_host_data[i].bd); - card->fh_slot_host_tag_record[i] = CSR_WIFI_HIP_RESERVED_HOST_TAG; - if (CSR_RESULT_SUCCESS != r) - { - unifi_trace(card->ospriv, UDBG5, "process_to_host_signals: Failed to requeue Packet(hTag:%x) back to HAL \n", host_tag); - CardClearFromHostDataSlot(card, i); - } - else - { - CardClearFromHostDataSlotWithoutFreeingBulkData(card, i); - } - -#else - unifi_trace(card->ospriv, UDBG4, "process_to_host_signals Clear slot=%x host tag=%x\n", i, host_tag); - card->fh_slot_host_tag_record[i] = CSR_WIFI_HIP_RESERVED_HOST_TAG; - - /* Set length field in from_host_data array to 0 */ - CardClearFromHostDataSlot(card, i); -#endif - break; - } - } - } - } - - /* Pass event to OS layer */ - unifi_receive_event(card->ospriv, bufptr + 2, sig_len, &data_ptrs); - - /* Initialise the to_host data, so it can be re-used. */ - for (i = 0; i < UNIFI_MAX_DATA_REFERENCES; i++) - { - /* The slot is only valid if the length is non-zero. */ - if (GET_PACKED_DATAREF_LEN(bufptr + 2, i) != 0) - { - s16 slot = GET_PACKED_DATAREF_SLOT(bufptr + 2, i); - if (slot < card->config_data.num_tohost_data_slots) - { - UNIFI_INIT_BULK_DATA(&card->to_host_data[slot]); - } - } - } - -#ifndef CSR_WIFI_DEFER_TH_FLUSH - /* - * If we have previously transferred a lot of data, ack - * the signals read so far, so f/w can reclaim the buffer - * memory sooner. - */ - if (bytes_transferred >= TO_HOST_FLUSH_THRESHOLD) - { - f_flush_count = 1; - } -#endif - break; - - - case SDIO_CMD_CLEAR_SLOT: -#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_DATA_PLANE_PROFILE) - card->cmd_prof.sdio_cmd_clear_slot++; -#endif - /* This is a clear slot command. */ - if (sig_len != 0) - { - unifi_error(card->ospriv, "process_to_host_signals: clear slot, bad data len: 0x%X at offset %d\n", - sig_len, bufptr - card->th_buffer.buf); - return CSR_RESULT_FAILURE; - } - - r = process_clear_slot_command(card, bufptr); - if (r != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, "Failed to process clear slot\n"); - return r; - } - break; - - case SDIO_CMD_TO_HOST_TRANSFER: - case SDIO_CMD_FROM_HOST_TRANSFER: - case SDIO_CMD_FROM_HOST_AND_CLEAR: - case SDIO_CMD_OVERLAY_TRANSFER: - /* This is a bulk data command. */ - if (sig_len & 1) - { - unifi_error(card->ospriv, "process_to_host_signals: bulk data, bad data len: 0x%X at offset %d\n", - sig_len, bufptr - card->th_buffer.buf); - return CSR_RESULT_FAILURE; - } - - r = process_bulk_data_command(card, bufptr, cmd, sig_len); - if (r != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, "Failed to process bulk cmd\n"); - return r; - } - /* Count the bytes transferred */ - bytes_transferred += sig_len; - - if (cmd == SDIO_CMD_FROM_HOST_AND_CLEAR) - { -#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_DATA_PLANE_PROFILE) - card->cmd_prof.sdio_cmd_from_host_and_clear++; -#endif -#ifndef CSR_WIFI_DEFER_TH_FLUSH - f_flush_count = 1; -#endif - } -#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_DATA_PLANE_PROFILE) - else if (cmd == SDIO_CMD_FROM_HOST_TRANSFER) - { - card->cmd_prof.sdio_cmd_from_host++; - } - else if (cmd == SDIO_CMD_TO_HOST_TRANSFER) - { - card->cmd_prof.sdio_cmd_to_host++; - } -#endif - break; - - case SDIO_CMD_PADDING: - break; - - default: - unifi_error(card->ospriv, "Unrecognised to-host command: %d\n", cmd); - break; - } - - bufptr += chunks_in_buf * card->config_data.sig_frag_size; - pending -= chunks_in_buf; - - /* - * Write out the host signal count when a significant - * number of bytes of bulk data have been transferred or - * when we have performed a CopyFromHostAndClear. - */ - if (f_flush_count) - { - r = update_to_host_signals_r(card, pending); - if (r != CSR_RESULT_SUCCESS) - { - return r; - } - bytes_transferred = 0; - } - } - - if (pending) - { - unifi_warning(card->ospriv, "proc_th_sigs: %d unprocessed\n", pending); - } - - /* If we processed any signals, write the updated count to UniFi */ - if (card->th_buffer.count != pending) - { - r = update_to_host_signals_r(card, pending); - if (r != CSR_RESULT_SUCCESS) - { - return r; - } - } - - /* - * Reset the buffer pointer, copying down any un-processed signals. - * This can happen if we enable the optimisation in read_to_host_signals() - * that limits the length to whole blocks. - */ - remaining = card->th_buffer.ptr - bufptr; - if (remaining < 0) - { - unifi_error(card->ospriv, "Processing TH signals overran the buffer\n"); - return CSR_RESULT_FAILURE; - } - if (remaining > 0) - { - /* Use a safe copy because source and destination may overlap */ - u8 *d = card->th_buffer.buf; - u8 *s = bufptr; - s32 n = remaining; - while (n--) - { - *d++ = *s++; - } - } - card->th_buffer.ptr = card->th_buffer.buf + remaining; - - - /* If we reach here then we processed something */ - *processed = 1; - return CSR_RESULT_SUCCESS; -} /* process_to_host_signals() */ - - -/* - * --------------------------------------------------------------------------- - * process_clear_slot_command - * - * Process a clear slot command fom the UniFi. - * - * Arguments: - * card Pointer to card context struct - * bdcmd Pointer to bulk-data command msg from UniFi - * - * Returns: - * 0 on success, CSR error code on error - * --------------------------------------------------------------------------- - */ -static CsrResult process_clear_slot_command(card_t *card, const u8 *cmdptr) -{ - u16 data_slot; - s16 slot; - - data_slot = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(cmdptr + SIZEOF_UINT16); - - unifi_trace(card->ospriv, UDBG4, "Processing clear slot cmd, slot=0x%X\n", - data_slot); - - slot = data_slot & 0x7FFF; - -#ifdef CSR_WIFI_HIP_NOISY - unifi_error(card->ospriv, "CMD clear data slot 0x%04x\n", data_slot); -#endif /* CSR_WIFI_HIP_NOISY */ - - if (data_slot & SLOT_DIR_TO_HOST) - { - if (slot >= card->config_data.num_tohost_data_slots) - { - unifi_error(card->ospriv, - "Invalid to-host data slot in SDIO_CMD_CLEAR_SLOT: %d\n", - slot); - return CSR_RESULT_FAILURE; - } - /* clear to-host data slot */ - unifi_warning(card->ospriv, "Unexpected clear to-host data slot cmd: 0x%04x\n", - data_slot); - } - else - { - if (slot >= card->config_data.num_fromhost_data_slots) - { - unifi_error(card->ospriv, - "Invalid from-host data slot in SDIO_CMD_CLEAR_SLOT: %d\n", - slot); - return CSR_RESULT_FAILURE; - } - - /* - * The driver is the owner to clear all slots now - * Ref - comment in process_fh_traffic_queue - * so it will just ignore the clear slot command from firmware - * and return success - */ - return CSR_RESULT_SUCCESS; - - /* Set length field in from_host_data array to 0 */ - /* CardClearFromHostDataSlot(card, slot); */ - } - - return CSR_RESULT_SUCCESS; -} /* process_clear_slot_command() */ - - -/* - * --------------------------------------------------------------------------- - * process_bulk_data_command - * - * Process a bulk data request from the UniFi. - * - * Arguments: - * card Pointer to card context struct - * bdcmd Pointer to bulk-data command msg from UniFi - * cmd, len Decoded values of command and length from the msg header - * Cmd will only be one of: - * SDIO_CMD_TO_HOST_TRANSFER - * SDIO_CMD_FROM_HOST_TRANSFER - * SDIO_CMD_FROM_HOST_AND_CLEAR - * SDIO_CMD_OVERLAY_TRANSFER - * - * Returns: - * CSR_RESULT_SUCCESS on success, CSR error code on error - * --------------------------------------------------------------------------- - */ -static CsrResult process_bulk_data_command(card_t *card, const u8 *cmdptr, - s16 cmd, u16 len) -{ - bulk_data_desc_t *bdslot; -#ifdef CSR_WIFI_ALIGNMENT_WORKAROUND - u8 *host_bulk_data_slot; -#endif - bulk_data_cmd_t bdcmd; - s16 offset; - s16 slot; - s16 dir; - CsrResult r; - - read_unpack_cmd(cmdptr, &bdcmd); - - unifi_trace(card->ospriv, UDBG4, "Processing bulk data cmd %d %s, len=%d, slot=0x%X\n", - cmd, lookup_bulkcmd_name(cmd), len, bdcmd.data_slot); - - /* - * Round up the transfer length if required. - * This is useful to force all transfers to be a multiple of the SDIO block - * size, so the SDIO driver won't try to use a byte-mode CMD53. These are - * broken on some hardware platforms. - */ - if (card->sdio_io_block_pad) - { - len = (len + card->sdio_io_block_size - 1) & ~(card->sdio_io_block_size - 1); - unifi_trace(card->ospriv, UDBG4, "Rounded bulk data length up to %d\n", len); - } - - slot = bdcmd.data_slot & 0x7FFF; - - if (cmd == SDIO_CMD_OVERLAY_TRANSFER) - { - return CSR_WIFI_HIP_RESULT_INVALID_VALUE; /* Not used on CSR6xxx */ - } - else - { - if (bdcmd.data_slot & SLOT_DIR_TO_HOST) - { - /* Request is for to-host bulk data */ - - /* Check sanity of slot number */ - if (slot >= card->config_data.num_tohost_data_slots) - { - unifi_error(card->ospriv, - "Invalid to-host data slot in SDIO bulk xfr req: %d\n", - slot); - return CSR_RESULT_FAILURE; - } - - /* Allocate memory for card->to_host_data[slot] bulk data here. */ -#ifdef CSR_PRE_ALLOC_NET_DATA - r = prealloc_netdata_get(card, &card->to_host_data[slot], len); -#else - r = unifi_net_data_malloc(card->ospriv, &card->to_host_data[slot], len); -#endif - if (r != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, "Failed to allocate t-h bulk data\n"); - return CSR_RESULT_FAILURE; - } - - bdslot = &card->to_host_data[slot]; - - /* Make sure that the buffer is 4-bytes aligned */ - r = unifi_net_dma_align(card->ospriv, bdslot); - if (r != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, "Failed to align t-h bulk data buffer for DMA\n"); - return CSR_RESULT_FAILURE; - } - } - else - { - /* Request is for from-host bulk data */ - - if (slot >= card->config_data.num_fromhost_data_slots) - { - unifi_error(card->ospriv, - "Invalid from-host data slot in SDIO bulk xfr req: %d\n", - slot); - return CSR_RESULT_FAILURE; - } - bdslot = &card->from_host_data[slot].bd; - } - offset = bdcmd.offset; - } - /* Do the transfer */ - dir = (cmd == SDIO_CMD_TO_HOST_TRANSFER)? - UNIFI_SDIO_READ : UNIFI_SDIO_WRITE; - - unifi_trace(card->ospriv, UDBG4, - "Bulk %c %s len=%d, handle %d - slot=%d %p+(%d)\n", - (dir == UNIFI_SDIO_READ)?'R' : 'W', - lookup_bulkcmd_name(cmd), - len, - bdcmd.buffer_handle, - slot, bdslot->os_data_ptr, offset); -#ifdef CSR_WIFI_HIP_NOISY - unifi_error(card->ospriv, "Bulk %s len=%d, handle %d - slot=%d %p+(%d)\n", - lookup_bulkcmd_name(cmd), - len, - bdcmd.buffer_handle, - slot, bdslot->os_data_ptr, offset); -#endif /* CSR_WIFI_HIP_NOISY */ - - - if (bdslot->os_data_ptr == NULL) - { - unifi_error(card->ospriv, "Null os_data_ptr - Bulk %s handle %d - slot=%d o=(%d)\n", - lookup_bulkcmd_name(cmd), - bdcmd.buffer_handle, - slot, - offset); - return CSR_WIFI_HIP_RESULT_INVALID_VALUE; - } - -#ifdef CSR_WIFI_ALIGNMENT_WORKAROUND - /* if os_data_ptr is not 4-byte aligned, then allocate a new buffer and copy data - to new buffer to ensure the address passed to unifi_bulk_rw is 4-byte aligned */ - - if (len != 0 && (dir == UNIFI_SDIO_WRITE) && (((ptrdiff_t)bdslot->os_data_ptr + offset) & 3)) - { - host_bulk_data_slot = kmalloc(len, GFP_KERNEL); - - if (!host_bulk_data_slot) - { - unifi_error(card->ospriv, " failed to allocate request_data before unifi_bulk_rw\n"); - return -1; - } - - memcpy((void *)host_bulk_data_slot, - (void *)(bdslot->os_data_ptr + offset), len); - - r = unifi_bulk_rw(card, - bdcmd.buffer_handle, - (void *)host_bulk_data_slot, - len, - dir); - } - else -#endif - { - r = unifi_bulk_rw(card, - bdcmd.buffer_handle, - (void *)(bdslot->os_data_ptr + offset), - len, - dir); - } - - if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE) - { - return r; - } - if (r != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, - "Failed: %s hlen=%d, slen=%d, handle %d - slot=%d %p+0x%X\n", - lookup_bulkcmd_name(cmd), - len, /* Header length */ - bdslot->data_length, /* Length stored in slot */ - bdcmd.buffer_handle, - slot, bdslot->os_data_ptr, offset); - return r; - } - - bdslot->data_length = len; - - if (cmd == SDIO_CMD_FROM_HOST_AND_CLEAR) - { - if (slot >= card->config_data.num_fromhost_data_slots) - { - unifi_error(card->ospriv, - "Invalid from-host data slot in SDIO_CMD_FROM_HOST_AND_CLEAR: %d\n", - slot); - return CSR_RESULT_FAILURE; - } - -#ifdef CSR_WIFI_ALIGNMENT_WORKAROUND - /* moving this check before we clear host data slot */ - if ((len != 0) && (dir == UNIFI_SDIO_WRITE) && (((ptrdiff_t)bdslot->os_data_ptr + offset) & 3)) - { - kfree(host_bulk_data_slot); - } -#endif - - if (card->fh_slot_host_tag_record) - { - unifi_trace(card->ospriv, UDBG5, "CopyFromHostAndClearSlot Reset entry for slot=%d\n", slot); - - /* reset the host tag entry for the corresponding slot */ - card->fh_slot_host_tag_record[slot] = CSR_WIFI_HIP_RESERVED_HOST_TAG; - } - - - /* Set length field in from_host_data array to 0 */ - CardClearFromHostDataSlot(card, slot); - } - - return CSR_RESULT_SUCCESS; -} /* process_bulk_data_command() */ - - -/* - * --------------------------------------------------------------------------- - * check_fh_sig_slots - * - * Check whether there are free signal slots available on UniFi. - * This takes into account the signals already batched since the - * from_host_signal counts were last read. - * If the from_host_signal counts indicate not enough space, we read - * the latest count from UniFi to see if some more have been freed. - * - * Arguments: - * None. - * - * Returns: - * CSR_RESULT_SUCCESS, otherwise CSR error code on error. - * --------------------------------------------------------------------------- - */ -static CsrResult check_fh_sig_slots(card_t *card, u16 needed, s32 *space_fh) -{ - u32 count_fhw; - u32 occupied_fh, slots_fh; - s32 count_fhr; - - count_fhw = card->from_host_signals_w; - count_fhr = card->from_host_signals_r; - slots_fh = card->config_data.num_fromhost_sig_frags; - - /* Only read the space in from-host queue if necessary */ - occupied_fh = (count_fhw - count_fhr) % 128; - - if (slots_fh < occupied_fh) - { - *space_fh = 0; - } - else - { - *space_fh = slots_fh - occupied_fh; - } - - if ((occupied_fh != 0) && (*space_fh < needed)) - { - count_fhr = unifi_read_shared_count(card, card->sdio_ctrl_addr + 2); - if (count_fhr < 0) - { - unifi_error(card->ospriv, "Failed to read from-host sig read count\n"); - return CSR_RESULT_FAILURE; - } - card->from_host_signals_r = count_fhr; /* diag */ - - occupied_fh = (count_fhw - count_fhr) % 128; - *space_fh = slots_fh - occupied_fh; - } - - return CSR_RESULT_SUCCESS; -} /* check_fh_sig_slots() */ - - -/* -* If we are padding the From-Host signals to the SDIO block size, -* we need to round up the needed_chunks to the SDIO block size. -*/ -#define ROUND_UP_NEEDED_CHUNKS(_card, _needed_chunks) \ - { \ - u16 _chunks_per_block; \ - u16 _chunks_in_last_block; \ - \ - if (_card->sdio_io_block_pad) \ - { \ - _chunks_per_block = _card->sdio_io_block_size / _card->config_data.sig_frag_size; \ - _chunks_in_last_block = _needed_chunks % _chunks_per_block; \ - if (_chunks_in_last_block != 0) \ - { \ - _needed_chunks = _needed_chunks + (_chunks_per_block - _chunks_in_last_block); \ - } \ - } \ - } - - -#define ROUND_UP_SPACE_CHUNKS(_card, _space_chunks) \ - { \ - u16 _chunks_per_block; \ - \ - if (_card->sdio_io_block_pad) \ - { \ - _chunks_per_block = _card->sdio_io_block_size / _card->config_data.sig_frag_size; \ - _space_chunks = ((_space_chunks / _chunks_per_block) * _chunks_per_block); \ - } \ - } - - - - - -/* - * --------------------------------------------------------------------------- - * process_fh_cmd_queue - * - * Take one signal off the from-host queue and copy it to the UniFi. - * Does nothing if the UniFi has no slots free. - * - * Arguments: - * card Pointer to card context struct - * processed Location to write: - * 0 if there is nothing on the queue to process - * 1 if a signal was successfully processed - * - * Returns: - * CSR error code if an error occurred. - * - * Notes: - * The from-host queue contains signal requests from the network driver - * and any UDI clients interspersed. UDI clients' requests have been stored - * in the from-host queue using the wire-format structures, as they arrive. - * All other requests are stored in the from-host queue using the host - * (cpu specific) structures. We use the is_packed member of the card_signal_t - * structure that describes the queue to make the distinction. - * --------------------------------------------------------------------------- - */ -static CsrResult process_fh_cmd_queue(card_t *card, s32 *processed) -{ - q_t *sigq = &card->fh_command_queue; - - CsrResult r; - u16 pending_sigs; - u16 pending_chunks; - u16 needed_chunks; - s32 space_chunks; - u16 q_index; - - *processed = 0; - - /* Get the number of pending signals. */ - pending_sigs = CSR_WIFI_HIP_Q_SLOTS_USED(sigq); - unifi_trace(card->ospriv, UDBG5, "proc_fh: %d pending\n", pending_sigs); - if (pending_sigs == 0) - { - /* Nothing to do */ - return CSR_RESULT_SUCCESS; - } - - /* Work out how many chunks we have waiting to send */ - for (pending_chunks = 0, q_index = CSR_WIFI_HIP_Q_NEXT_R_SLOT(sigq); - q_index != CSR_WIFI_HIP_Q_NEXT_W_SLOT(sigq); - q_index = CSR_WIFI_HIP_Q_WRAP(sigq, q_index + 1)) - { - card_signal_t *csptr = CSR_WIFI_HIP_Q_SLOT_DATA(sigq, q_index); - - /* - * Note that GET_CHUNKS_FOR() needs the size of the packed - * (wire-formatted) structure - */ - pending_chunks += GET_CHUNKS_FOR(card->config_data.sig_frag_size, (u16)(csptr->signal_length + 2)); - } - - /* - * Check whether UniFi has space for all the buffered bulk-data - * commands and signals as well. - */ - needed_chunks = pending_chunks + card->fh_buffer.count; - - /* Round up to the block size if necessary */ - ROUND_UP_NEEDED_CHUNKS(card, needed_chunks); - - r = check_fh_sig_slots(card, needed_chunks, &space_chunks); - if (r != CSR_RESULT_SUCCESS) - { - /* Error */ - unifi_error(card->ospriv, "Failed to read fh sig count\n"); - return r; - } - -#ifdef CSR_WIFI_HIP_NOISY - unifi_error(card->ospriv, "proc_fh: %d chunks free, need %d\n", - space_chunks, needed_chunks); -#endif /* CSR_WIFI_HIP_NOISY */ - - - /* - * Coalesce as many from-host signals as possible - * into a single block and write using a single CMD53 - */ - if (needed_chunks > (u16)space_chunks) - { - /* Round up to the block size if necessary */ - ROUND_UP_SPACE_CHUNKS(card, space_chunks); - - /* - * If the f/w has less free chunks than those already pending - * return immediately. - */ - if ((u16)space_chunks <= card->fh_buffer.count) - { - /* - * No room in UniFi for any signals after the buffered bulk - * data commands have been sent. - */ - unifi_error(card->ospriv, "not enough room to send signals, need %d chunks, %d free\n", - card->fh_buffer.count, space_chunks); - card->generate_interrupt = 1; - return CSR_RESULT_SUCCESS; - } - pending_chunks = (u16)(space_chunks - card->fh_buffer.count); - } - - while (pending_sigs-- && pending_chunks > 0) - { - card_signal_t *csptr; - s16 i; - u16 sig_chunks, total_length, free_chunks_in_fh_buffer; - bulk_data_param_t bulkdata; - u8 *packed_sigptr; - u16 signal_length = 0; - - /* Retrieve the entry at the head of the queue */ - q_index = CSR_WIFI_HIP_Q_NEXT_R_SLOT(sigq); - - /* Get a pointer to the containing card_signal_t struct */ - csptr = CSR_WIFI_HIP_Q_SLOT_DATA(sigq, q_index); - - /* Get the new length of the packed signal */ - signal_length = csptr->signal_length; - - if ((signal_length & 1) || (signal_length > UNIFI_PACKED_SIGBUF_SIZE)) - { - unifi_error(card->ospriv, "process_fh_queue: Bad len: %d\n", signal_length); - return CSR_RESULT_FAILURE; - } - - /* Need space for 2-byte SDIO protocol header + signal */ - sig_chunks = GET_CHUNKS_FOR(card->config_data.sig_frag_size, (u16)(signal_length + 2)); - - free_chunks_in_fh_buffer = GET_CHUNKS_FOR(card->config_data.sig_frag_size, - (u16)((card->fh_buffer.buf + UNIFI_FH_BUF_SIZE) - card->fh_buffer.ptr)); - if (free_chunks_in_fh_buffer < sig_chunks) - { - /* No more room */ - unifi_notice(card->ospriv, "proc_fh_cmd_q: no room in fh buffer for 0x%.4X, deferring\n", - (u16)(GET_SIGNAL_ID(csptr->sigbuf))); - break; - } - - packed_sigptr = csptr->sigbuf; - - /* Claim and set up a from-host data slot */ - if (CSR_RESULT_FAILURE == CardWriteBulkData(card, csptr, UNIFI_TRAFFIC_Q_MLME)) - { - unifi_notice(card->ospriv, "proc_fh_cmd_q: no fh data slots for 0x%.4X, deferring\n", - (u16)(GET_SIGNAL_ID(csptr->sigbuf))); - break; - } - - for (i = 0; i < UNIFI_MAX_DATA_REFERENCES; i++) - { - if (csptr->bulkdata[i].data_length == 0) - { - UNIFI_INIT_BULK_DATA(&bulkdata.d[i]); - } - else - { - bulkdata.d[i].os_data_ptr = csptr->bulkdata[i].os_data_ptr; - bulkdata.d[i].data_length = csptr->bulkdata[i].data_length; - } - - /* Pass the free responsibility to the lower layer. */ - UNIFI_INIT_BULK_DATA(&csptr->bulkdata[i]); - } - - unifi_trace(card->ospriv, UDBG2, "Sending signal 0x%.4X\n", - GET_SIGNAL_ID(packed_sigptr)); -#ifdef CSR_WIFI_HIP_NOISY - unifi_error(card->ospriv, "Sending signal 0x%.4X\n", - GET_SIGNAL_ID(packed_sigptr)); -#endif /* CSR_WIFI_HIP_NOISY */ - - - /* Append packed signal to F-H buffer */ - total_length = sig_chunks * card->config_data.sig_frag_size; - - card->fh_buffer.ptr[0] = (u8)(signal_length & 0xff); - card->fh_buffer.ptr[1] = - (u8)(((signal_length >> 8) & 0xf) | (SDIO_CMD_SIGNAL << 4)); - - memcpy(card->fh_buffer.ptr + 2, packed_sigptr, signal_length); - memset(card->fh_buffer.ptr + 2 + signal_length, 0, - total_length - (2 + signal_length)); - -#ifdef CSR_WIFI_HIP_NOISY - unifi_error(card->ospriv, "proc_fh: fh_buffer %d bytes \n", - signal_length + 2); - dump(card->fh_buffer.ptr, signal_length + 2); - unifi_trace(card->ospriv, UDBG1, " \n"); -#endif /* CSR_WIFI_HIP_NOISY */ - - card->fh_buffer.ptr += total_length; - card->fh_buffer.count += sig_chunks; - -#ifdef CSR_WIFI_HIP_NOISY - unifi_error(card->ospriv, "Added %d to fh buf, len now %d, count %d\n", - signal_length, - card->fh_buffer.ptr - card->fh_buffer.buf, - card->fh_buffer.count); -#endif /* CSR_WIFI_HIP_NOISY */ - - (*processed)++; - pending_chunks -= sig_chunks; - - /* Log the signal to the UDI. */ - /* UDI will get the packed structure */ - /* Can not log the unpacked signal, unless we reconstruct it! */ - if (card->udi_hook) - { - (*card->udi_hook)(card->ospriv, packed_sigptr, signal_length, - &bulkdata, UDI_LOG_FROM_HOST); - } - - /* Remove entry from q */ - csptr->signal_length = 0; - CSR_WIFI_HIP_Q_INC_R(sigq); - } - - return CSR_RESULT_SUCCESS; -} /* process_fh_cmd_queue() */ - - -/* - * --------------------------------------------------------------------------- - * process_fh_traffic_queue - * - * Take signals off the from-host queue and copy them to the UniFi. - * Does nothing if the UniFi has no slots free. - * - * Arguments: - * card Pointer to card context struct - * sigq Pointer to the traffic queue - * processed Pointer to location to write: - * 0 if there is nothing on the queue to process - * 1 if a signal was successfully processed - * - * Returns: - * CSR error code if an error occurred. - * - * Notes: - * The from-host queue contains signal requests from the network driver - * and any UDI clients interspersed. - * --------------------------------------------------------------------------- - */ -static CsrResult process_fh_traffic_queue(card_t *card, s32 *processed) -{ - q_t *sigq = card->fh_traffic_queue; - - CsrResult r; - s16 n = 0; - s32 q_no; - u16 pending_sigs = 0; - u16 pending_chunks = 0; - u16 needed_chunks; - s32 space_chunks; - u16 q_index; - u32 host_tag = 0; - u16 slot_num = 0; - - *processed = 0; - - /* calculate how many signals are in queues and how many chunks are needed. */ - for (n = UNIFI_NO_OF_TX_QS - 1; n >= 0; n--) - { - /* Get the number of pending signals. */ - pending_sigs += CSR_WIFI_HIP_Q_SLOTS_USED(&sigq[n]); - unifi_trace(card->ospriv, UDBG5, "proc_fh%d: %d pending\n", n, pending_sigs); - - /* Work out how many chunks we have waiting to send */ - for (q_index = CSR_WIFI_HIP_Q_NEXT_R_SLOT(&sigq[n]); - q_index != CSR_WIFI_HIP_Q_NEXT_W_SLOT(&sigq[n]); - q_index = CSR_WIFI_HIP_Q_WRAP(&sigq[n], q_index + 1)) - { - card_signal_t *csptr = CSR_WIFI_HIP_Q_SLOT_DATA(&sigq[n], q_index); - - /* - * Note that GET_CHUNKS_FOR() needs the size of the packed - * (wire-formatted) structure - */ - pending_chunks += GET_CHUNKS_FOR(card->config_data.sig_frag_size, (u16)(csptr->signal_length + 2)); - } - } - - /* If there are no pending signals, just return */ - if (pending_sigs == 0) - { - /* Nothing to do */ - return CSR_RESULT_SUCCESS; - } - - /* - * Check whether UniFi has space for all the buffered bulk-data - * commands and signals as well. - */ - needed_chunks = pending_chunks + card->fh_buffer.count; - - /* Round up to the block size if necessary */ - ROUND_UP_NEEDED_CHUNKS(card, needed_chunks); - - r = check_fh_sig_slots(card, needed_chunks, &space_chunks); - if (r != CSR_RESULT_SUCCESS) - { - /* Error */ - unifi_error(card->ospriv, "Failed to read fh sig count\n"); - return r; - } - -#ifdef CSR_WIFI_HIP_NOISY - unifi_error(card->ospriv, - "process_fh_traffic_queue: %d chunks free, need %d\n", - space_chunks, needed_chunks); - read_fhsr(card); /* debugging only */ -#endif /* CSR_WIFI_HIP_NOISY */ - - /* Coalesce as many from-host signals as possible - into a single block and write using a single CMD53 */ - if (needed_chunks > (u16)space_chunks) - { - /* Round up to the block size if necessary */ - ROUND_UP_SPACE_CHUNKS(card, space_chunks); - - if ((u16)space_chunks <= card->fh_buffer.count) - { - /* - * No room in UniFi for any signals after the buffered bulk - * data commands have been sent. - */ - unifi_error(card->ospriv, "not enough room to send signals, need %d chunks, %d free\n", - card->fh_buffer.count, space_chunks); - card->generate_interrupt = 1; - return 0; - } - - pending_chunks = (u16)space_chunks - card->fh_buffer.count; - } - - q_no = UNIFI_NO_OF_TX_QS - 1; - - /* - * pending_sigs will be exhausted if there are is no restriction to the pending - * signals per queue. pending_chunks may be exhausted if there is a restriction. - * q_no check will be exhausted if there is a restriction and our round-robin - * algorith fails to fill all chunks. - */ - do - { - card_signal_t *csptr; - u16 sig_chunks, total_length, free_chunks_in_fh_buffer; - bulk_data_param_t bulkdata; - u8 *packed_sigptr; - u16 signal_length = 0; - - /* if this queue is empty go to next one. */ - if (CSR_WIFI_HIP_Q_SLOTS_USED(&sigq[q_no]) == 0) - { - q_no--; - continue; - } - - /* Retrieve the entry at the head of the queue */ - q_index = CSR_WIFI_HIP_Q_NEXT_R_SLOT(&sigq[q_no]); - - /* Get a pointer to the containing card_signal_t struct */ - csptr = CSR_WIFI_HIP_Q_SLOT_DATA(&sigq[q_no], q_index); - - /* Get the new length of the packed signal */ - signal_length = csptr->signal_length; - - if ((signal_length & 1) || (signal_length > UNIFI_PACKED_SIGBUF_SIZE)) - { - unifi_error(card->ospriv, "process_fh_traffic_queue: Bad len: %d\n", signal_length); - return CSR_RESULT_FAILURE; - } - - /* Need space for 2-byte SDIO protocol header + signal */ - sig_chunks = GET_CHUNKS_FOR(card->config_data.sig_frag_size, (u16)(signal_length + 2)); - free_chunks_in_fh_buffer = GET_CHUNKS_FOR(card->config_data.sig_frag_size, - (u16)((card->fh_buffer.buf + UNIFI_FH_BUF_SIZE) - card->fh_buffer.ptr)); - if (free_chunks_in_fh_buffer < sig_chunks) - { - /* No more room */ - unifi_notice(card->ospriv, "process_fh_traffic_queue: no more chunks.\n"); - break; - } - - packed_sigptr = csptr->sigbuf; - /* Claim and set up a from-host data slot */ - if (CSR_RESULT_FAILURE == CardWriteBulkData(card, csptr, (unifi_TrafficQueue)q_no)) - { - q_no--; - continue; - } - - /* Sanity check: MA-PACKET.req must have a valid bulk data */ - if ((csptr->bulkdata[0].data_length == 0) || (csptr->bulkdata[0].os_data_ptr == NULL)) - { - unifi_error(card->ospriv, "MA-PACKET.req with empty bulk data (%d bytes in %p)\n", - csptr->bulkdata[0].data_length, csptr->bulkdata[0].os_data_ptr); - dump(packed_sigptr, signal_length); - return CSR_RESULT_FAILURE; - } - - bulkdata.d[0].os_data_ptr = csptr->bulkdata[0].os_data_ptr; - bulkdata.d[0].data_length = csptr->bulkdata[0].data_length; - bulkdata.d[0].os_net_buf_ptr = csptr->bulkdata[0].os_net_buf_ptr; - bulkdata.d[0].net_buf_length = csptr->bulkdata[0].net_buf_length; - - /* The driver owns clearing of HIP slots for following scenario - * - driver has requested a MA-PACKET.req signal - * - The f/w after receiving the signal decides it can't send it out due to various reasons - * - So the f/w without downloading the bulk data decides to just send a confirmation with fail - * - and then sends a clear slot signal to HIP - * - * But in some cases the clear slot signal never comes and the slot remains --NOT-- freed for ever - * - * To handle this, HIP will keep the record of host tag for each occupied slot - * and then based on status of that Host tag and slot the driver will decide if the slot is - * cleared by f/w signal or the slot has to be freed by driver - */ - - if (card->fh_slot_host_tag_record) - { - /* Update the f-h slot record for the corresponding host tag */ - host_tag = GET_PACKED_MA_PACKET_REQUEST_HOST_TAG(packed_sigptr); - slot_num = GET_PACKED_DATAREF_SLOT(packed_sigptr, 0) & 0x00FF; - - unifi_trace(card->ospriv, UDBG5, - "process_fh_traffic_queue signal ID =%x fh slot=%x Host tag =%x\n", - GET_SIGNAL_ID(packed_sigptr), slot_num, host_tag); - card->fh_slot_host_tag_record[slot_num] = host_tag; - } - UNIFI_INIT_BULK_DATA(&bulkdata.d[1]); - UNIFI_INIT_BULK_DATA(&csptr->bulkdata[0]); - UNIFI_INIT_BULK_DATA(&csptr->bulkdata[1]); - -#ifdef CSR_WIFI_HIP_DATA_PLANE_PROFILE - if (bulkdata.d[0].os_data_ptr) - { - if ((*bulkdata.d[0].os_data_ptr) & 0x08) - { - card->cmd_prof.tx_count++; - } - } -#endif - unifi_trace(card->ospriv, UDBG3, "Sending signal 0x%.4X\n", - GET_SIGNAL_ID(packed_sigptr)); -#ifdef CSR_WIFI_HIP_NOISY - unifi_error(card->ospriv, "Sending signal 0x%.4X\n", - GET_SIGNAL_ID(packed_sigptr)); -#endif /* CSR_WIFI_HIP_NOISY */ - - /* Append packed signal to F-H buffer */ - total_length = sig_chunks * card->config_data.sig_frag_size; - - card->fh_buffer.ptr[0] = (u8)(signal_length & 0xff); - card->fh_buffer.ptr[1] = - (u8)(((signal_length >> 8) & 0xf) | (SDIO_CMD_SIGNAL << 4)); - - memcpy(card->fh_buffer.ptr + 2, packed_sigptr, signal_length); - memset(card->fh_buffer.ptr + 2 + signal_length, 0, - total_length - (2 + signal_length)); - -#ifdef CSR_WIFI_HIP_NOISY - unifi_error(card->ospriv, "proc_fh: fh_buffer %d bytes \n", - signal_length + 2); - dump(card->fh_buffer.ptr, signal_length + 2); - unifi_trace(card->ospriv, UDBG1, " \n"); -#endif /* CSR_WIFI_HIP_NOISY */ - - card->fh_buffer.ptr += total_length; - card->fh_buffer.count += sig_chunks; - -#ifdef CSR_WIFI_HIP_NOISY - unifi_error(card->ospriv, "Added %d to fh buf, len now %d, count %d\n", - signal_length, - card->fh_buffer.ptr - card->fh_buffer.buf, - card->fh_buffer.count); -#endif /* CSR_WIFI_HIP_NOISY */ - - (*processed)++; - pending_sigs--; - pending_chunks -= sig_chunks; - - /* Log the signal to the UDI. */ - /* UDI will get the packed structure */ - /* Can not log the unpacked signal, unless we reconstruct it! */ - if (card->udi_hook) - { - (*card->udi_hook)(card->ospriv, packed_sigptr, signal_length, - &bulkdata, UDI_LOG_FROM_HOST); - } - - /* Remove entry from q */ - csptr->signal_length = 0; - /* Note that the traffic queue has only one valid bulk data buffer. */ - csptr->bulkdata[0].data_length = 0; - - CSR_WIFI_HIP_Q_INC_R(&sigq[q_no]); - } while ((pending_sigs > 0) && (pending_chunks > 0) && (q_no >= 0)); - - return CSR_RESULT_SUCCESS; -} /* process_fh_traffic_queue() */ - - -/* - * --------------------------------------------------------------------------- - * flush_fh_buffer - * - * Write out the cache from-hosts signals to the UniFi. - * - * Arguments: - * card Pointer to card context struct - * - * Returns: - * CSR error code if an SDIO error occurred. - * --------------------------------------------------------------------------- - */ -static CsrResult flush_fh_buffer(card_t *card) -{ - CsrResult r; - u16 len; - u16 sig_units; - u16 data_round; - u16 chunks_in_last_block; - u16 padding_chunks; - u16 i; - - len = card->fh_buffer.ptr - card->fh_buffer.buf; - -#ifdef CSR_WIFI_HIP_NOISY - unifi_error(card->ospriv, "fh_buffer is at %p, ptr= %p\n", - card->fh_buffer.buf, card->fh_buffer.ptr); -#endif /* CSR_WIFI_HIP_NOISY */ - - if (len == 0) - { - return CSR_RESULT_SUCCESS; - } - -#ifdef CSR_WIFI_HIP_NOISY - if (dump_fh_buf) - { - dump(card->fh_buffer.buf, len); - dump_fh_buf = 0; - } -#endif /* CSR_WIFI_HIP_NOISY */ - - if (card->sdio_io_block_pad) - { - /* Both of these are powers of 2 */ - sig_units = card->config_data.sig_frag_size; - data_round = card->sdio_io_block_size; - - if (data_round > sig_units) - { - chunks_in_last_block = (len % data_round) / sig_units; - - if (chunks_in_last_block != 0) - { - padding_chunks = (data_round / sig_units) - chunks_in_last_block; - - memset(card->fh_buffer.ptr, 0, padding_chunks * sig_units); - for (i = 0; i < padding_chunks; i++) - { - card->fh_buffer.ptr[1] = SDIO_CMD_PADDING << 4; - card->fh_buffer.ptr += sig_units; - } - - card->fh_buffer.count += padding_chunks; - len += padding_chunks * sig_units; - } - } - } - - r = unifi_bulk_rw(card, - card->config_data.fromhost_sigbuf_handle, - card->fh_buffer.buf, - len, UNIFI_SDIO_WRITE); - if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE) - { - return r; - } - if (r != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, "Failed to write fh signals: %u bytes, error %d\n", len, r); - return r; - } - - /* Update from-host-signals-written signal count */ - card->from_host_signals_w = - (card->from_host_signals_w + card->fh_buffer.count) % 128u; - r = unifi_write_8_or_16(card, card->sdio_ctrl_addr + 0, - (u8)card->from_host_signals_w); - if (r != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, "Failed to write fh signal count %u with error %d\n", - card->from_host_signals_w, r); - return r; - } - card->generate_interrupt = 1; - - /* Reset the fh buffer pointer */ - card->fh_buffer.ptr = card->fh_buffer.buf; - card->fh_buffer.count = 0; - -#ifdef CSR_WIFI_HIP_NOISY - unifi_error(card->ospriv, "END flush: fh len %d, count %d\n", - card->fh_buffer.ptr - card->fh_buffer.buf, - card->fh_buffer.count); -#endif /* CSR_WIFI_HIP_NOISY */ - - return CSR_RESULT_SUCCESS; -} /* flush_fh_buffer() */ - - -/* - * --------------------------------------------------------------------------- - * restart_packet_flow - * - * This function is called before the bottom-half thread sleeps. - * It checks whether both data and signal resources are available and - * then calls the OS-layer function to re-enable packet transmission. - * - * Arguments: - * card Pointer to card context struct - * - * Returns: - * None. - * --------------------------------------------------------------------------- - */ -static void restart_packet_flow(card_t *card) -{ - u8 q; - - /* - * We only look at the fh_traffic_queue, because that is where packets from - * the network stack are placed. - */ - for (q = 0; q <= UNIFI_TRAFFIC_Q_VO; q++) - { - if (card_is_tx_q_paused(card, q) && - CSR_WIFI_HIP_Q_SLOTS_FREE(&card->fh_traffic_queue[q]) >= RESUME_XMIT_THRESHOLD) - { -#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_DATA_PLANE_PROFILE) - unifi_debug_log_to_buf("U"); -#endif - card_tx_q_unpause(card, q); - unifi_restart_xmit(card->ospriv, (unifi_TrafficQueue)q); - } - } -} /* restart_packet_flow() */ - - diff --git a/drivers/staging/csr/csr_wifi_hip_card_sdio_mem.c b/drivers/staging/csr/csr_wifi_hip_card_sdio_mem.c deleted file mode 100644 index 17867f60df16..000000000000 --- a/drivers/staging/csr/csr_wifi_hip_card_sdio_mem.c +++ /dev/null @@ -1,1713 +0,0 @@ -/***************************************************************************** - - (c) Cambridge Silicon Radio Limited 2012 - All rights reserved and confidential information of CSR - - Refer to LICENSE.txt included with this source for details - on the license terms. - -*****************************************************************************/ - -/* - * --------------------------------------------------------------------------- - * FILE: csr_wifi_hip_card_sdio_mem.c - * - * PURPOSE: Implementation of the Card API for SDIO. - * - * --------------------------------------------------------------------------- - */ -#include "csr_wifi_hip_unifi.h" -#include "csr_wifi_hip_card.h" - -#define SDIO_RETRIES 3 -#define CSR_WIFI_HIP_SDIO_TRACE_DATA_LENGTH 16 - - -#define retryable_sdio_error(_csrResult) (((_csrResult) == CSR_SDIO_RESULT_CRC_ERROR) || ((_csrResult) == CSR_SDIO_RESULT_TIMEOUT)) - - -/* - * --------------------------------------------------------------------------- - * retrying_read8 - * retrying_write8 - * - * These functions provide the first level of retry for SDIO operations. - * If an SDIO command fails for reason of a response timeout or CRC - * error, it is retried immediately. If three attempts fail we report a - * failure. - * If the command failed for any other reason, the failure is reported - * immediately. - * - * Arguments: - * card Pointer to card structure. - * funcnum The SDIO function to access. - * Function 0 is the Card Configuration Register space, - * function 1/2 is the UniFi register space. - * addr Address to access - * pdata Pointer in which to return the value read. - * data Value to write. - * - * Returns: - * CSR_RESULT_SUCCESS on success, non-zero error code on error: - * CSR_WIFI_HIP_RESULT_NO_DEVICE card was ejected - * CSR_RESULT_FAILURE an SDIO error occurred - * --------------------------------------------------------------------------- - */ -static CsrResult retrying_read8(card_t *card, s16 funcnum, u32 addr, u8 *pdata) -{ - CsrSdioFunction *sdio = card->sdio_if; - CsrResult r = CSR_RESULT_SUCCESS; - s16 retries; - CsrResult csrResult = CSR_RESULT_SUCCESS; - - retries = 0; - while (retries++ < SDIO_RETRIES) - { - if (funcnum == 0) - { -#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_SDIO_TRACE) - unifi_debug_log_to_buf("r0@%02X", addr); -#endif - csrResult = CsrSdioF0Read8(sdio, addr, pdata); - } - else - { -#ifdef CSR_WIFI_TRANSPORT_CSPI - unifi_error(card->ospriv, - "retrying_read_f0_8: F1 8-bit reads are not allowed.\n"); - return CSR_RESULT_FAILURE; -#else -#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_SDIO_TRACE) - unifi_debug_log_to_buf("r@%02X", addr); -#endif - csrResult = CsrSdioRead8(sdio, addr, pdata); -#endif - } -#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_SDIO_TRACE) - if (csrResult != CSR_RESULT_SUCCESS) - { - unifi_debug_log_to_buf("error=%X\n", csrResult); - } - else - { - unifi_debug_log_to_buf("=%X\n", *pdata); - } -#endif - if (csrResult == CSR_SDIO_RESULT_NO_DEVICE) - { - return CSR_WIFI_HIP_RESULT_NO_DEVICE; - } - /* - * Try again for retryable (CRC or TIMEOUT) errors, - * break on success or fatal error - */ - if (!retryable_sdio_error(csrResult)) - { -#ifdef CSR_WIFI_HIP_DATA_PLANE_PROFILE - card->cmd_prof.cmd52_count++; -#endif - break; - } - unifi_trace(card->ospriv, UDBG2, "retryable SDIO error reading F%d 0x%lX\n", funcnum, addr); - } - - if ((csrResult == CSR_RESULT_SUCCESS) && (retries > 1)) - { - unifi_warning(card->ospriv, "Read succeeded after %d attempts\n", retries); - } - - if (csrResult != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, "Failed to read from UniFi (addr 0x%lX) after %d tries\n", - addr, retries - 1); - /* Report any SDIO error as a general i/o error */ - r = CSR_RESULT_FAILURE; - } - - return r; -} /* retrying_read8() */ - - -static CsrResult retrying_write8(card_t *card, s16 funcnum, u32 addr, u8 data) -{ - CsrSdioFunction *sdio = card->sdio_if; - CsrResult r = CSR_RESULT_SUCCESS; - s16 retries; - CsrResult csrResult = CSR_RESULT_SUCCESS; - - retries = 0; - while (retries++ < SDIO_RETRIES) - { - if (funcnum == 0) - { -#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_SDIO_TRACE) - unifi_debug_log_to_buf("w0@%02X=%X", addr, data); -#endif - csrResult = CsrSdioF0Write8(sdio, addr, data); - } - else - { -#ifdef CSR_WIFI_TRANSPORT_CSPI - unifi_error(card->ospriv, - "retrying_write_f0_8: F1 8-bit writes are not allowed.\n"); - return CSR_RESULT_FAILURE; -#else -#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_SDIO_TRACE) - unifi_debug_log_to_buf("w@%02X=%X", addr, data); -#endif - csrResult = CsrSdioWrite8(sdio, addr, data); -#endif - } -#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_SDIO_TRACE) - if (csrResult != CSR_RESULT_SUCCESS) - { - unifi_debug_log_to_buf(",error=%X", csrResult); - } - unifi_debug_string_to_buf("\n"); -#endif - if (csrResult == CSR_SDIO_RESULT_NO_DEVICE) - { - return CSR_WIFI_HIP_RESULT_NO_DEVICE; - } - /* - * Try again for retryable (CRC or TIMEOUT) errors, - * break on success or fatal error - */ - if (!retryable_sdio_error(csrResult)) - { -#ifdef CSR_WIFI_HIP_DATA_PLANE_PROFILE - card->cmd_prof.cmd52_count++; -#endif - break; - } - unifi_trace(card->ospriv, UDBG2, "retryable SDIO error writing %02X to F%d 0x%lX\n", - data, funcnum, addr); - } - - if ((csrResult == CSR_RESULT_SUCCESS) && (retries > 1)) - { - unifi_warning(card->ospriv, "Write succeeded after %d attempts\n", retries); - } - - if (csrResult != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, "Failed to write to UniFi (addr 0x%lX) after %d tries\n", - addr, retries - 1); - /* Report any SDIO error as a general i/o error */ - r = CSR_RESULT_FAILURE; - } - - return r; -} /* retrying_write8() */ - - -static CsrResult retrying_read16(card_t *card, s16 funcnum, - u32 addr, u16 *pdata) -{ - CsrSdioFunction *sdio = card->sdio_if; - CsrResult r = CSR_RESULT_SUCCESS; - s16 retries; - CsrResult csrResult = CSR_RESULT_SUCCESS; - - retries = 0; - while (retries++ < SDIO_RETRIES) - { -#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_SDIO_TRACE) - unifi_debug_log_to_buf("r@%02X", addr); -#endif - csrResult = CsrSdioRead16(sdio, addr, pdata); -#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_SDIO_TRACE) - if (csrResult != CSR_RESULT_SUCCESS) - { - unifi_debug_log_to_buf("error=%X\n", csrResult); - } - else - { - unifi_debug_log_to_buf("=%X\n", *pdata); - } -#endif - if (csrResult == CSR_SDIO_RESULT_NO_DEVICE) - { - return CSR_WIFI_HIP_RESULT_NO_DEVICE; - } - - /* - * Try again for retryable (CRC or TIMEOUT) errors, - * break on success or fatal error - */ - if (!retryable_sdio_error(csrResult)) - { -#ifdef CSR_WIFI_HIP_DATA_PLANE_PROFILE - card->cmd_prof.cmd52_count++; -#endif - break; - } - unifi_trace(card->ospriv, UDBG2, "retryable SDIO error reading F%d 0x%lX\n", funcnum, addr); - } - - if ((csrResult == CSR_RESULT_SUCCESS) && (retries > 1)) - { - unifi_warning(card->ospriv, "Read succeeded after %d attempts\n", retries); - } - - if (csrResult != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, "Failed to read from UniFi (addr 0x%lX) after %d tries\n", - addr, retries - 1); - /* Report any SDIO error as a general i/o error */ - r = CSR_RESULT_FAILURE; - } - - return r; -} /* retrying_read16() */ - - -static CsrResult retrying_write16(card_t *card, s16 funcnum, - u32 addr, u16 data) -{ - CsrSdioFunction *sdio = card->sdio_if; - CsrResult r = CSR_RESULT_SUCCESS; - s16 retries; - CsrResult csrResult = CSR_RESULT_SUCCESS; - - retries = 0; - while (retries++ < SDIO_RETRIES) - { -#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_SDIO_TRACE) - unifi_debug_log_to_buf("w@%02X=%X", addr, data); -#endif - csrResult = CsrSdioWrite16(sdio, addr, data); -#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_SDIO_TRACE) - if (csrResult != CSR_RESULT_SUCCESS) - { - unifi_debug_log_to_buf(",error=%X", csrResult); - } - unifi_debug_string_to_buf("\n"); -#endif - if (csrResult == CSR_SDIO_RESULT_NO_DEVICE) - { - return CSR_WIFI_HIP_RESULT_NO_DEVICE; - } - - /* - * Try again for retryable (CRC or TIMEOUT) errors, - * break on success or fatal error - */ - if (!retryable_sdio_error(csrResult)) - { -#ifdef CSR_WIFI_HIP_DATA_PLANE_PROFILE - card->cmd_prof.cmd52_count++; -#endif - break; - } - unifi_trace(card->ospriv, UDBG2, "retryable SDIO error writing %02X to F%d 0x%lX\n", - data, funcnum, addr); - } - - if ((csrResult == CSR_RESULT_SUCCESS) && (retries > 1)) - { - unifi_warning(card->ospriv, "Write succeeded after %d attempts\n", retries); - } - - if (csrResult != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, "Failed to write to UniFi (addr 0x%lX) after %d tries\n", - addr, retries - 1); - /* Report any SDIO error as a general i/o error */ - r = CSR_RESULT_FAILURE; - } - - return r; -} /* retrying_write16() */ - - -/* - * --------------------------------------------------------------------------- - * sdio_read_f0 - * - * Reads a byte value from the CCCR (func 0) area of UniFi. - * - * Arguments: - * card Pointer to card structure. - * addr Address to read from - * pdata Pointer in which to store the read value. - * - * Returns: - * CSR_RESULT_SUCCESS on success, non-zero error code on error: - * CSR_WIFI_HIP_RESULT_NO_DEVICE card was ejected - * CSR_RESULT_FAILURE an SDIO error occurred - * --------------------------------------------------------------------------- - */ -CsrResult sdio_read_f0(card_t *card, u32 addr, u8 *pdata) -{ -#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_DATA_PLANE_PROFILE) - card->cmd_prof.cmd52_f0_r_count++; -#endif - return retrying_read8(card, 0, addr, pdata); -} /* sdio_read_f0() */ - - -/* - * --------------------------------------------------------------------------- - * sdio_write_f0 - * - * Writes a byte value to the CCCR (func 0) area of UniFi. - * - * Arguments: - * card Pointer to card structure. - * addr Address to read from - * data Data value to write. - * - * Returns: - * CSR_RESULT_SUCCESS on success, non-zero error code on error: - * CSR_WIFI_HIP_RESULT_NO_DEVICE card was ejected - * CSR_RESULT_FAILURE an SDIO error occurred - * --------------------------------------------------------------------------- - */ -CsrResult sdio_write_f0(card_t *card, u32 addr, u8 data) -{ -#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_DATA_PLANE_PROFILE) - card->cmd_prof.cmd52_f0_w_count++; -#endif - return retrying_write8(card, 0, addr, data); -} /* sdio_write_f0() */ - - -/* - * --------------------------------------------------------------------------- - * unifi_read_direct_8_or_16 - * - * Read a 8-bit value from the UniFi SDIO interface. - * - * Arguments: - * card Pointer to card structure. - * addr Address to read from - * pdata Pointer in which to return data. - * - * Returns: - * CSR_RESULT_SUCCESS on success, non-zero error code on error: - * --------------------------------------------------------------------------- - */ -CsrResult unifi_read_direct_8_or_16(card_t *card, u32 addr, u8 *pdata) -{ -#ifdef CSR_WIFI_TRANSPORT_CSPI - u16 w; - CsrResult r; - - r = retrying_read16(card, card->function, addr, &w); - *pdata = (u8)(w & 0xFF); - return r; -#else - return retrying_read8(card, card->function, addr, pdata); -#endif -} /* unifi_read_direct_8_or_16() */ - - -/* - * --------------------------------------------------------------------------- - * unifi_write_direct_8_or_16 - * - * Write a byte value to the UniFi SDIO interface. - * - * Arguments: - * card Pointer to card structure. - * addr Address to write to - * data Value to write. - * - * Returns: - * CSR_RESULT_SUCCESS on success, non-zero error code on error - * - * Notes: - * If 8-bit write is used, the even address *must* be written second. - * This is because writes to odd bytes are cached and not committed - * to memory until the preceding even address is written. - * --------------------------------------------------------------------------- - */ -CsrResult unifi_write_direct_8_or_16(card_t *card, u32 addr, u8 data) -{ - if (addr & 1) - { - unifi_warning(card->ospriv, - "Warning: Byte write to an odd address (0x%lX) is dangerous\n", - addr); - } - -#ifdef CSR_WIFI_TRANSPORT_CSPI - return retrying_write16(card, card->function, addr, (u16)data); -#else - return retrying_write8(card, card->function, addr, data); -#endif -} /* unifi_write_direct_8_or_16() */ - - -/* - * --------------------------------------------------------------------------- - * unifi_read_direct16 - * - * Read a 16-bit value from the UniFi SDIO interface. - * - * Arguments: - * card Pointer to card structure. - * addr Address to read from - * pdata Pointer in which to return data. - * - * Returns: - * CSR_RESULT_SUCCESS on success, non-zero error code on error: - * CSR_WIFI_HIP_RESULT_NO_DEVICE card was ejected - * CSR_RESULT_FAILURE an SDIO error occurred - * - * Notes: - * The even address *must* be read first. This is because reads from - * odd bytes are cached and read from memory when the preceding - * even address is read. - * --------------------------------------------------------------------------- - */ -CsrResult unifi_read_direct16(card_t *card, u32 addr, u16 *pdata) -{ - return retrying_read16(card, card->function, addr, pdata); -} /* unifi_read_direct16() */ - - -/* - * --------------------------------------------------------------------------- - * unifi_write_direct16 - * - * Write a 16-bit value to the UniFi SDIO interface. - * - * Arguments: - * card Pointer to card structure. - * addr Address to write to - * data Value to write. - * - * Returns: - * CSR_RESULT_SUCCESS on success, non-zero error code on error: - * CSR_WIFI_HIP_RESULT_NO_DEVICE card was ejected - * CSR_RESULT_FAILURE an SDIO error occurred - * - * Notes: - * The even address *must* be written second. This is because writes to - * odd bytes are cached and not committed to memory until the preceding - * even address is written. - * --------------------------------------------------------------------------- - */ -CsrResult unifi_write_direct16(card_t *card, u32 addr, u16 data) -{ - return retrying_write16(card, card->function, addr, data); -} /* unifi_write_direct16() */ - - -/* - * --------------------------------------------------------------------------- - * unifi_read_direct32 - * - * Read a 32-bit value from the UniFi SDIO interface. - * - * Arguments: - * card Pointer to card structure. - * addr Address to read from - * pdata Pointer in which to return data. - * - * Returns: - * CSR_RESULT_SUCCESS on success, non-zero error code on error: - * CSR_WIFI_HIP_RESULT_NO_DEVICE card was ejected - * CSR_RESULT_FAILURE an SDIO error occurred - * --------------------------------------------------------------------------- - */ -CsrResult unifi_read_direct32(card_t *card, u32 addr, u32 *pdata) -{ - CsrResult r; - u16 w0, w1; - - r = retrying_read16(card, card->function, addr, &w0); - if (r != CSR_RESULT_SUCCESS) - { - return r; - } - - r = retrying_read16(card, card->function, addr + 2, &w1); - if (r != CSR_RESULT_SUCCESS) - { - return r; - } - - *pdata = ((u32)w1 << 16) | (u32)w0; - - return CSR_RESULT_SUCCESS; -} /* unifi_read_direct32() */ - - -/* - * --------------------------------------------------------------------------- - * unifi_read_directn_match - * - * Read multiple 8-bit values from the UniFi SDIO interface, - * stopping when either we have read 'len' bytes or we have read - * a octet equal to 'match'. If 'match' is not a valid octet - * then this function is the same as 'unifi_read_directn'. - * - * Arguments: - * card Pointer to card structure. - * addr Start address to read from. - * pdata Pointer to which to write data. - * len Maximum umber of bytes to read - * match The value to stop reading at. - * num Pointer to buffer to write number of bytes read - * - * Returns: - * number of octets read on success, negative error code on error: - * CSR_WIFI_HIP_RESULT_NO_DEVICE card was ejected - * CSR_RESULT_FAILURE an SDIO error occurred - * - * Notes: - * The even address *must* be read first. This is because reads from - * odd bytes are cached and read from memory when the preceding - * even address is read. - * --------------------------------------------------------------------------- - */ -static CsrResult unifi_read_directn_match(card_t *card, u32 addr, void *pdata, u16 len, s8 m, u32 *num) -{ - CsrResult r; - u32 i; - u8 *cptr; - u16 w; - - *num = 0; - - cptr = (u8 *)pdata; - for (i = 0; i < len; i += 2) - { - r = retrying_read16(card, card->function, addr, &w); - if (r != CSR_RESULT_SUCCESS) - { - return r; - } - - *cptr++ = ((u8)w & 0xFF); - if ((m >= 0) && (((s8)w & 0xFF) == m)) - { - break; - } - - if (i + 1 == len) - { - /* The len is odd. Ignore the last high byte */ - break; - } - - *cptr++ = ((u8)(w >> 8) & 0xFF); - if ((m >= 0) && (((s8)(w >> 8) & 0xFF) == m)) - { - break; - } - - addr += 2; - } - - *num = (s32)(cptr - (u8 *)pdata); - return CSR_RESULT_SUCCESS; -} - - -/* - * --------------------------------------------------------------------------- - * unifi_read_directn - * - * Read multiple 8-bit values from the UniFi SDIO interface. - * - * Arguments: - * card Pointer to card structure. - * addr Start address to read from. - * pdata Pointer to which to write data. - * len Number of bytes to read - * - * Returns: - * 0 on success, non-zero error code on error: - * CSR_WIFI_HIP_RESULT_NO_DEVICE card was ejected - * CSR_RESULT_FAILURE an SDIO error occurred - * - * Notes: - * The even address *must* be read first. This is because reads from - * odd bytes are cached and read from memory when the preceding - * even address is read. - * --------------------------------------------------------------------------- - */ -CsrResult unifi_read_directn(card_t *card, u32 addr, void *pdata, u16 len) -{ - u32 num; - - return unifi_read_directn_match(card, addr, pdata, len, -1, &num); -} /* unifi_read_directn() */ - - -/* - * --------------------------------------------------------------------------- - * unifi_write_directn - * - * Write multiple 8-bit values to the UniFi SDIO interface. - * - * Arguments: - * card Pointer to card structure. - * addr Start address to write to. - * pdata Source data pointer. - * len Number of bytes to write, must be even. - * - * Returns: - * 0 on success, non-zero error code on error: - * CSR_WIFI_HIP_RESULT_NO_DEVICE card was ejected - * CSR_RESULT_FAILURE an SDIO error occurred - * - * Notes: - * The UniFi has a peculiar 16-bit bus architecture. Writes are only - * committed to memory when an even address is accessed. Writes to - * odd addresses are cached and only committed if the next write is - * to the preceding address. - * This means we must write data as pairs of bytes in reverse order. - * --------------------------------------------------------------------------- - */ -CsrResult unifi_write_directn(card_t *card, u32 addr, void *pdata, u16 len) -{ - CsrResult r; - u8 *cptr; - s16 signed_len; - - cptr = (u8 *)pdata; - signed_len = (s16)len; - while (signed_len > 0) - { - /* This is UniFi-1 specific code. CSPI not supported so 8-bit write allowed */ - r = retrying_write16(card, card->function, addr, *cptr); - if (r != CSR_RESULT_SUCCESS) - { - return r; - } - - cptr += 2; - addr += 2; - signed_len -= 2; - } - - return CSR_RESULT_SUCCESS; -} /* unifi_write_directn() */ - - -/* - * --------------------------------------------------------------------------- - * set_dmem_page - * set_pmem_page - * - * Set up the page register for the shared data memory window or program - * memory window. - * - * Arguments: - * card Pointer to card structure. - * dmem_addr UniFi shared-data-memory address to access. - * pmem_addr UniFi program memory address to access. This includes - * External FLASH memory at 0x000000 - * Processor program memory at 0x200000 - * External SRAM at memory 0x400000 - * paddr Location to write an SDIO address (24-bit) for - * use in a unifi_read_direct or unifi_write_direct call. - * - * Returns: - * CSR_RESULT_SUCCESS on success - * CSR_WIFI_HIP_RESULT_NO_DEVICE card was ejected - * CSR_RESULT_FAILURE an SDIO error occurred - * --------------------------------------------------------------------------- - */ -static CsrResult set_dmem_page(card_t *card, u32 dmem_addr, u32 *paddr) -{ - u16 page, addr; - u32 len; - CsrResult r; - - *paddr = 0; - - if (!ChipHelper_DecodeWindow(card->helper, - CHIP_HELPER_WINDOW_3, - CHIP_HELPER_WT_SHARED, - dmem_addr / 2, - &page, &addr, &len)) - { - unifi_error(card->ospriv, "Failed to decode SHARED_DMEM_PAGE %08lx\n", dmem_addr); - return CSR_WIFI_HIP_RESULT_INVALID_VALUE; - } - - if (page != card->dmem_page) - { - unifi_trace(card->ospriv, UDBG6, "setting dmem page=0x%X, addr=0x%lX\n", page, addr); - - /* change page register */ - r = unifi_write_direct16(card, ChipHelper_HOST_WINDOW3_PAGE(card->helper) * 2, page); - if (r != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, "Failed to write SHARED_DMEM_PAGE\n"); - return r; - } - - card->dmem_page = page; - } - - *paddr = ((s32)addr * 2) + (dmem_addr & 1); - - return CSR_RESULT_SUCCESS; -} /* set_dmem_page() */ - - -static CsrResult set_pmem_page(card_t *card, u32 pmem_addr, - enum chip_helper_window_type mem_type, u32 *paddr) -{ - u16 page, addr; - u32 len; - CsrResult r; - - *paddr = 0; - - if (!ChipHelper_DecodeWindow(card->helper, - CHIP_HELPER_WINDOW_2, - mem_type, - pmem_addr / 2, - &page, &addr, &len)) - { - unifi_error(card->ospriv, "Failed to decode PROG MEM PAGE %08lx %d\n", pmem_addr, mem_type); - return CSR_WIFI_HIP_RESULT_INVALID_VALUE; - } - - if (page != card->pmem_page) - { - unifi_trace(card->ospriv, UDBG6, "setting pmem page=0x%X, addr=0x%lX\n", page, addr); - - /* change page register */ - r = unifi_write_direct16(card, ChipHelper_HOST_WINDOW2_PAGE(card->helper) * 2, page); - if (r != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, "Failed to write PROG MEM PAGE\n"); - return r; - } - - card->pmem_page = page; - } - - *paddr = ((s32)addr * 2) + (pmem_addr & 1); - - return CSR_RESULT_SUCCESS; -} /* set_pmem_page() */ - - -/* - * --------------------------------------------------------------------------- - * set_page - * - * Sets up the appropriate page register to access the given address. - * Returns the sdio address at which the unifi address can be accessed. - * - * Arguments: - * card Pointer to card structure. - * generic_addr UniFi internal address to access, in Generic Pointer - * format, i.e. top byte is space indicator. - * paddr Location to write page address - * SDIO address (24-bit) for use in a unifi_read_direct or - * unifi_write_direct call - * - * Returns: - * CSR_WIFI_HIP_RESULT_NO_DEVICE card was ejected - * CSR_RESULT_FAILURE an SDIO error occurred - * CSR_WIFI_HIP_RESULT_INVALID_VALUE the address is invalid - * --------------------------------------------------------------------------- - */ -static CsrResult set_page(card_t *card, u32 generic_addr, u32 *paddr) -{ - s32 space; - u32 addr; - CsrResult r = CSR_RESULT_SUCCESS; - - if (!paddr) - { - return CSR_WIFI_HIP_RESULT_INVALID_VALUE; - } - *paddr = 0; - space = UNIFI_GP_SPACE(generic_addr); - addr = UNIFI_GP_OFFSET(generic_addr); - switch (space) - { - case UNIFI_SH_DMEM: - /* Shared Data Memory is accessed via the Shared Data Memory window */ - r = set_dmem_page(card, addr, paddr); - if (r != CSR_RESULT_SUCCESS) - { - return r; - } - break; - - case UNIFI_EXT_FLASH: - if (!ChipHelper_HasFlash(card->helper)) - { - unifi_error(card->ospriv, "Bad address space for chip in generic pointer 0x%08lX (helper=0x%x)\n", - generic_addr, card->helper); - return CSR_WIFI_HIP_RESULT_INVALID_VALUE; - } - /* External FLASH is accessed via the Program Memory window */ - r = set_pmem_page(card, addr, CHIP_HELPER_WT_FLASH, paddr); - break; - - case UNIFI_EXT_SRAM: - if (!ChipHelper_HasExtSram(card->helper)) - { - unifi_error(card->ospriv, "Bad address space for chip in generic pointer 0x%08l (helper=0x%x)\n", - generic_addr, card->helper); - return CSR_WIFI_HIP_RESULT_INVALID_VALUE; - } - /* External SRAM is accessed via the Program Memory window */ - r = set_pmem_page(card, addr, CHIP_HELPER_WT_EXT_SRAM, paddr); - break; - - case UNIFI_REGISTERS: - /* Registers are accessed directly */ - *paddr = addr; - break; - - case UNIFI_PHY_DMEM: - r = unifi_set_proc_select(card, UNIFI_PROC_PHY); - if (r != CSR_RESULT_SUCCESS) - { - return r; - } - *paddr = ChipHelper_DATA_MEMORY_RAM_OFFSET(card->helper) * 2 + addr; - break; - - case UNIFI_MAC_DMEM: - r = unifi_set_proc_select(card, UNIFI_PROC_MAC); - if (r != CSR_RESULT_SUCCESS) - { - return r; - } - *paddr = ChipHelper_DATA_MEMORY_RAM_OFFSET(card->helper) * 2 + addr; - break; - - case UNIFI_BT_DMEM: - if (!ChipHelper_HasBt(card->helper)) - { - unifi_error(card->ospriv, "Bad address space for chip in generic pointer 0x%08lX (helper=0x%x)\n", - generic_addr, card->helper); - return CSR_WIFI_HIP_RESULT_INVALID_VALUE; - } - r = unifi_set_proc_select(card, UNIFI_PROC_BT); - if (r != CSR_RESULT_SUCCESS) - { - return r; - } - *paddr = ChipHelper_DATA_MEMORY_RAM_OFFSET(card->helper) * 2 + addr; - break; - - case UNIFI_PHY_PMEM: - r = unifi_set_proc_select(card, UNIFI_PROC_PHY); - if (r != CSR_RESULT_SUCCESS) - { - return r; - } - r = set_pmem_page(card, addr, CHIP_HELPER_WT_CODE_RAM, paddr); - break; - - case UNIFI_MAC_PMEM: - r = unifi_set_proc_select(card, UNIFI_PROC_MAC); - if (r != CSR_RESULT_SUCCESS) - { - return r; - } - r = set_pmem_page(card, addr, CHIP_HELPER_WT_CODE_RAM, paddr); - break; - - case UNIFI_BT_PMEM: - if (!ChipHelper_HasBt(card->helper)) - { - unifi_error(card->ospriv, "Bad address space for chip in generic pointer 0x%08lX (helper=0x%x)\n", - generic_addr, card->helper); - return CSR_WIFI_HIP_RESULT_INVALID_VALUE; - } - r = unifi_set_proc_select(card, UNIFI_PROC_BT); - if (r != CSR_RESULT_SUCCESS) - { - return r; - } - r = set_pmem_page(card, addr, CHIP_HELPER_WT_CODE_RAM, paddr); - break; - - case UNIFI_PHY_ROM: - if (!ChipHelper_HasRom(card->helper)) - { - unifi_error(card->ospriv, "Bad address space for chip in generic pointer 0x%08lX (helper=0x%x)\n", - generic_addr, card->helper); - return CSR_WIFI_HIP_RESULT_INVALID_VALUE; - } - r = unifi_set_proc_select(card, UNIFI_PROC_PHY); - if (r != CSR_RESULT_SUCCESS) - { - return r; - } - r = set_pmem_page(card, addr, CHIP_HELPER_WT_ROM, paddr); - break; - - case UNIFI_MAC_ROM: - if (!ChipHelper_HasRom(card->helper)) - { - unifi_error(card->ospriv, "Bad address space for chip in generic pointer 0x%08lX (helper=0x%x)\n", - generic_addr, card->helper); - return CSR_WIFI_HIP_RESULT_INVALID_VALUE; - } - r = unifi_set_proc_select(card, UNIFI_PROC_MAC); - if (r != CSR_RESULT_SUCCESS) - { - return r; - } - r = set_pmem_page(card, addr, CHIP_HELPER_WT_ROM, paddr); - break; - - case UNIFI_BT_ROM: - if (!ChipHelper_HasRom(card->helper) || !ChipHelper_HasBt(card->helper)) - { - unifi_error(card->ospriv, "Bad address space for chip in generic pointer 0x%08lX (helper=0x%x)\n", - generic_addr, card->helper); - return CSR_WIFI_HIP_RESULT_INVALID_VALUE; - } - r = unifi_set_proc_select(card, UNIFI_PROC_BT); - if (r != CSR_RESULT_SUCCESS) - { - return r; - } - r = set_pmem_page(card, addr, CHIP_HELPER_WT_ROM, paddr); - break; - - default: - unifi_error(card->ospriv, "Bad address space %d in generic pointer 0x%08lX (helper=0x%x)\n", - space, generic_addr, card->helper); - return CSR_WIFI_HIP_RESULT_INVALID_VALUE; - } - - return r; -} /* set_page() */ - - -/* - * --------------------------------------------------------------------------- - * unifi_set_proc_select - * - * - * Arguments: - * card Pointer to card structure. - * select Which XAP core to select - * - * Returns: - * 0 on success, non-zero error code on error: - * CSR_WIFI_HIP_RESULT_NO_DEVICE card was ejected - * CSR_RESULT_FAILURE an SDIO error occurred - * --------------------------------------------------------------------------- - */ -CsrResult unifi_set_proc_select(card_t *card, enum unifi_dbg_processors_select select) -{ - CsrResult r; - - /* Verify the the select value is allowed. */ - switch (select) - { - case UNIFI_PROC_MAC: - case UNIFI_PROC_PHY: - case UNIFI_PROC_BOTH: - break; - - - default: - return CSR_WIFI_HIP_RESULT_INVALID_VALUE; - } - - if (card->proc_select != (u32)select) - { - r = unifi_write_direct16(card, - ChipHelper_DBG_HOST_PROC_SELECT(card->helper) * 2, - (u8)select); - if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE) - { - return r; - } - if (r != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, "Failed to write to Proc Select register\n"); - return r; - } - - card->proc_select = (u32)select; - } - - return CSR_RESULT_SUCCESS; -} - - -/* - * --------------------------------------------------------------------------- - * unifi_read_8_or_16 - * - * Performs a byte read of the given address in shared data memory. - * Set up the shared data memory page register as required. - * - * Arguments: - * card Pointer to card structure. - * unifi_addr UniFi shared-data-memory address to access. - * pdata Pointer to a byte variable for the value read. - * - * Returns: - * CSR_RESULT_SUCCESS on success, non-zero error code on error: - * CSR_WIFI_HIP_RESULT_NO_DEVICE card was ejected - * CSR_RESULT_FAILURE an SDIO error occurred - * CSR_WIFI_HIP_RESULT_INVALID_VALUE a bad generic pointer was specified - * --------------------------------------------------------------------------- - */ -CsrResult unifi_read_8_or_16(card_t *card, u32 unifi_addr, u8 *pdata) -{ - u32 sdio_addr; - CsrResult r; -#ifdef CSR_WIFI_TRANSPORT_CSPI - u16 w; -#endif - - r = set_page(card, unifi_addr, &sdio_addr); - if (r != CSR_RESULT_SUCCESS) - { - return r; - } - -#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_DATA_PLANE_PROFILE) - card->cmd_prof.cmd52_r8or16_count++; -#endif -#ifdef CSR_WIFI_TRANSPORT_CSPI - r = retrying_read16(card, card->function, sdio_addr, &w); - *pdata = (u8)(w & 0xFF); - return r; -#else - return retrying_read8(card, card->function, sdio_addr, pdata); -#endif -} /* unifi_read_8_or_16() */ - - -/* - * --------------------------------------------------------------------------- - * unifi_write_8_or_16 - * - * Performs a byte write of the given address in shared data memory. - * Set up the shared data memory page register as required. - * - * Arguments: - * card Pointer to card context struct. - * unifi_addr UniFi shared-data-memory address to access. - * data Value to write. - * - * Returns: - * CSR_RESULT_SUCCESS on success, non-zero error code on error: - * CSR_WIFI_HIP_RESULT_NO_DEVICE card was ejected - * CSR_RESULT_FAILURE an SDIO error occurred - * CSR_WIFI_HIP_RESULT_INVALID_VALUE a bad generic pointer was specified - * - * Notes: - * Beware using unifi_write8() because byte writes are not safe on UniFi. - * Writes to odd bytes are cached, writes to even bytes perform a 16-bit - * write with the previously cached odd byte. - * --------------------------------------------------------------------------- - */ -CsrResult unifi_write_8_or_16(card_t *card, u32 unifi_addr, u8 data) -{ - u32 sdio_addr; - CsrResult r; -#ifdef CSR_WIFI_TRANSPORT_CSPI - u16 w; -#endif - - r = set_page(card, unifi_addr, &sdio_addr); - if (r != CSR_RESULT_SUCCESS) - { - return r; - } - - if (sdio_addr & 1) - { - unifi_warning(card->ospriv, - "Warning: Byte write to an odd address (0x%lX) is dangerous\n", - sdio_addr); - } - -#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_DATA_PLANE_PROFILE) - card->cmd_prof.cmd52_w8or16_count++; -#endif -#ifdef CSR_WIFI_TRANSPORT_CSPI - w = data; - return retrying_write16(card, card->function, sdio_addr, w); -#else - return retrying_write8(card, card->function, sdio_addr, data); -#endif -} /* unifi_write_8_or_16() */ - - -/* - * --------------------------------------------------------------------------- - * unifi_card_read16 - * - * Performs a 16-bit read of the given address in shared data memory. - * Set up the shared data memory page register as required. - * - * Arguments: - * card Pointer to card structure. - * unifi_addr UniFi shared-data-memory address to access. - * pdata Pointer to a 16-bit int variable for the value read. - * - * Returns: - * CSR_RESULT_SUCCESS on success, non-zero error code on error: - * CSR_WIFI_HIP_RESULT_NO_DEVICE card was ejected - * CSR_RESULT_FAILURE an SDIO error occurred - * CSR_WIFI_HIP_RESULT_INVALID_VALUE a bad generic pointer was specified - * --------------------------------------------------------------------------- - */ -CsrResult unifi_card_read16(card_t *card, u32 unifi_addr, u16 *pdata) -{ - u32 sdio_addr; - CsrResult r; - - r = set_page(card, unifi_addr, &sdio_addr); - if (r != CSR_RESULT_SUCCESS) - { - return r; - } - -#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_DATA_PLANE_PROFILE) - card->cmd_prof.cmd52_r16_count++; -#endif - return unifi_read_direct16(card, sdio_addr, pdata); -} /* unifi_card_read16() */ - - -/* - * --------------------------------------------------------------------------- - * unifi_card_write16 - * - * Performs a 16-bit write of the given address in shared data memory. - * Set up the shared data memory page register as required. - * - * Arguments: - * card Pointer to card structure. - * unifi_addr UniFi shared-data-memory address to access. - * pdata Pointer to a byte variable for the value write. - * - * Returns: - * CSR_RESULT_SUCCESS on success, non-zero error code on error: - * CSR_WIFI_HIP_RESULT_NO_DEVICE card was ejected - * CSR_RESULT_FAILURE an SDIO error occurred - * CSR_WIFI_HIP_RESULT_INVALID_VALUE a bad generic pointer was specified - * --------------------------------------------------------------------------- - */ -CsrResult unifi_card_write16(card_t *card, u32 unifi_addr, u16 data) -{ - u32 sdio_addr; - CsrResult r; - - r = set_page(card, unifi_addr, &sdio_addr); - if (r != CSR_RESULT_SUCCESS) - { - return r; - } - -#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_DATA_PLANE_PROFILE) - card->cmd_prof.cmd52_w16_count++; -#endif - return unifi_write_direct16(card, sdio_addr, data); -} /* unifi_card_write16() */ - - -/* - * --------------------------------------------------------------------------- - * unifi_read32 - * - * Performs a 32-bit read of the given address in shared data memory. - * Set up the shared data memory page register as required. - * - * Arguments: - * card Pointer to card structure. - * unifi_addr UniFi shared-data-memory address to access. - * pdata Pointer to a int variable for the value read. - * - * Returns: - * CSR_RESULT_SUCCESS on success, non-zero error code on error: - * CSR_WIFI_HIP_RESULT_NO_DEVICE card was ejected - * CSR_RESULT_FAILURE an SDIO error occurred - * CSR_WIFI_HIP_RESULT_INVALID_VALUE a bad generic pointer was specified - * --------------------------------------------------------------------------- - */ -CsrResult unifi_read32(card_t *card, u32 unifi_addr, u32 *pdata) -{ - u32 sdio_addr; - CsrResult r; - - r = set_page(card, unifi_addr, &sdio_addr); - if (r != CSR_RESULT_SUCCESS) - { - return r; - } - -#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_DATA_PLANE_PROFILE) - card->cmd_prof.cmd52_r32_count++; -#endif - return unifi_read_direct32(card, sdio_addr, pdata); -} /* unifi_read32() */ - - -/* - * --------------------------------------------------------------------------- - * unifi_card_readn - * unifi_readnz - * - * Read multiple 8-bit values from the UniFi SDIO interface. - * This function interprets the address as a GenericPointer as - * defined in the UniFi Host Interface Protocol Specification. - * The readnz version of this function will stop when it reads a - * zero octet. - * - * Arguments: - * card Pointer to card structure. - * unifi_addr UniFi shared-data-memory address to access. - * pdata Pointer to which to write data. - * len Number of bytes to read - * - * Returns: - * CSR_RESULT_SUCCESS on success, non-zero error code on error: - * CSR_WIFI_HIP_RESULT_NO_DEVICE card was ejected - * CSR_RESULT_FAILURE an SDIO error occurred - * CSR_WIFI_HIP_RESULT_INVALID_VALUE a bad generic pointer was specified - * --------------------------------------------------------------------------- - */ -CsrResult unifi_readn_match(card_t *card, u32 unifi_addr, void *pdata, u16 len, s8 match) -{ - u32 sdio_addr; - CsrResult r; - u32 num; - - r = set_page(card, unifi_addr, &sdio_addr); - if (r != CSR_RESULT_SUCCESS) - { - return r; - } - - r = unifi_read_directn_match(card, sdio_addr, pdata, len, match, &num); - return r; -} /* unifi_readn_match() */ - - -CsrResult unifi_card_readn(card_t *card, u32 unifi_addr, void *pdata, u16 len) -{ - return unifi_readn_match(card, unifi_addr, pdata, len, -1); -} /* unifi_card_readn() */ - - -CsrResult unifi_readnz(card_t *card, u32 unifi_addr, void *pdata, u16 len) -{ - return unifi_readn_match(card, unifi_addr, pdata, len, 0); -} /* unifi_readnz() */ - - -/* - * --------------------------------------------------------------------------- - * unifi_read_shared_count - * - * Read signal count locations, checking for an SDIO error. The - * signal count locations only contain a valid number if the - * highest bit isn't set. - * - * Arguments: - * card Pointer to card context structure. - * addr Shared-memory address to read. - * - * Returns: - * Value read from memory (0-127) or -1 on error - * --------------------------------------------------------------------------- - */ -s32 unifi_read_shared_count(card_t *card, u32 addr) -{ - u8 b; - /* I've increased this count, because I have seen cases where - * there were three reads in a row with the top bit set. I'm not - * sure why this might have happened, but I can't see a problem - * with increasing this limit. It's better to take a while to - * recover than to fail. */ -#define SHARED_READ_RETRY_LIMIT 10 - s32 i; - - /* - * Get the to-host-signals-written count. - * The top-bit will be set if the firmware was in the process of - * changing the value, in which case we read again. - */ - /* Limit the number of repeats so we don't freeze */ - for (i = 0; i < SHARED_READ_RETRY_LIMIT; i++) - { - CsrResult r; - r = unifi_read_8_or_16(card, addr, &b); - if (r != CSR_RESULT_SUCCESS) - { - return -1; - } - if (!(b & 0x80)) - { - /* There is a chance that the MSB may have contained invalid data - * (overflow) at the time it was read. Therefore mask off the MSB. - * This avoids a race between driver read and firmware write of the - * word, the value we need is in the lower 8 bits anway. - */ - return (s32)(b & 0xff); - } - } - - return -1; /* this function has changed in WMM mods */ -} /* unifi_read_shared_count() */ - - -/* - * --------------------------------------------------------------------------- - * unifi_writen - * - * Write multiple 8-bit values to the UniFi SDIO interface using CMD52 - * This function interprets the address as a GenericPointer as - * defined in the UniFi Host Interface Protocol Specification. - * - * Arguments: - * card Pointer to card structure. - * unifi_addr UniFi shared-data-memory address to access. - * pdata Pointer to which to write data. - * len Number of bytes to write - * - * Returns: - * 0 on success, non-zero error code on error: - * CSR_WIFI_HIP_RESULT_NO_DEVICE card was ejected - * CSR_RESULT_FAILURE an SDIO error occurred - * CSR_WIFI_HIP_RESULT_INVALID_VALUE an odd length or length too big. - * --------------------------------------------------------------------------- - */ -CsrResult unifi_writen(card_t *card, u32 unifi_addr, void *pdata, u16 len) -{ - u32 sdio_addr; - CsrResult r; - - r = set_page(card, unifi_addr, &sdio_addr); - if (r != CSR_RESULT_SUCCESS) - { - return r; - } - - return unifi_write_directn(card, sdio_addr, pdata, len); -} /* unifi_writen() */ - - -static CsrResult csr_sdio_block_rw(card_t *card, s16 funcnum, - u32 addr, u8 *pdata, - u16 count, s16 dir_is_write) -{ - CsrResult csrResult; - - if (dir_is_write == UNIFI_SDIO_READ) - { -#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_SDIO_TRACE) - unifi_debug_log_to_buf("r@%02X#%X=", addr, count); -#endif -#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_DATA_PLANE_PROFILE) - unifi_debug_log_to_buf("R"); -#endif - csrResult = CsrSdioRead(card->sdio_if, addr, pdata, count); -#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_DATA_PLANE_PROFILE) - unifi_debug_log_to_buf("<"); -#endif - } - else - { -#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_SDIO_TRACE) - unifi_debug_log_to_buf("w@%02X#%X=", addr, count); - unifi_debug_hex_to_buf(pdata, count > CSR_WIFI_HIP_SDIO_TRACE_DATA_LENGTH?CSR_WIFI_HIP_SDIO_TRACE_DATA_LENGTH : count); -#endif -#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_DATA_PLANE_PROFILE) - unifi_debug_log_to_buf("W"); -#endif - csrResult = CsrSdioWrite(card->sdio_if, addr, pdata, count); -#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_DATA_PLANE_PROFILE) - unifi_debug_log_to_buf(">"); -#endif - } -#ifdef CSR_WIFI_HIP_DATA_PLANE_PROFILE - card->cmd_prof.cmd53_count++; -#endif -#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_SDIO_TRACE) - if (csrResult != CSR_RESULT_SUCCESS) - { - unifi_debug_log_to_buf("error=%X", csrResult); - } - else if (dir_is_write == UNIFI_SDIO_READ) - { - unifi_debug_hex_to_buf(pdata, count > CSR_WIFI_HIP_SDIO_TRACE_DATA_LENGTH?CSR_WIFI_HIP_SDIO_TRACE_DATA_LENGTH : count); - } - unifi_debug_string_to_buf("\n"); -#endif - return csrResult; /* CSR SDIO (not HIP) error code */ -} - - -/* - * --------------------------------------------------------------------------- - * unifi_bulk_rw - * - * Transfer bulk data to or from the UniFi SDIO interface. - * This function is used to read or write signals and bulk data. - * - * Arguments: - * card Pointer to card structure. - * handle Value to put in the Register Address field of the CMD53 req. - * data Pointer to data to write. - * direction One of UNIFI_SDIO_READ or UNIFI_SDIO_WRITE - * - * Returns: - * CSR_RESULT_SUCCESS on success, non-zero error code on error: - * CSR_WIFI_HIP_RESULT_NO_DEVICE card was ejected - * CSR_RESULT_FAILURE an SDIO error occurred - * - * Notes: - * This function uses SDIO CMD53, which is the block transfer mode. - * --------------------------------------------------------------------------- - */ -CsrResult unifi_bulk_rw(card_t *card, u32 handle, void *pdata, - u32 len, s16 direction) -{ -#define CMD53_RETRIES 3 - /* - * Ideally instead of sleeping, we want to busy wait. - * Currently there is no framework API to do this. When it becomes available, - * we can use it to busy wait using usecs - */ -#define REWIND_RETRIES 15 /* when REWIND_DELAY==1msec, or 250 when REWIND_DELAY==50usecs */ -#define REWIND_POLLING_RETRIES 5 -#define REWIND_DELAY 1 /* msec or 50usecs */ - CsrResult csrResult; /* SDIO error code */ - CsrResult r = CSR_RESULT_SUCCESS; /* HIP error code */ - s16 retries = CMD53_RETRIES; - s16 stat_retries; - u8 stat; - s16 dump_read; -#ifdef UNIFI_DEBUG - u8 *pdata_lsb = ((u8 *)&pdata) + card->lsb; -#endif -#ifdef CSR_WIFI_MAKE_FAKE_CMD53_ERRORS - static s16 fake_error; -#endif - - dump_read = 0; -#ifdef UNIFI_DEBUG - if (*pdata_lsb & 1) - { - unifi_notice(card->ospriv, "CD53 request on a unaligned buffer (addr: 0x%X) dir %s-Host\n", - pdata, (direction == UNIFI_SDIO_READ)?"To" : "From"); - if (direction == UNIFI_SDIO_WRITE) - { - dump(pdata, (u16)len); - } - else - { - dump_read = 1; - } - } -#endif - - /* Defensive checks */ - if (!pdata) - { - unifi_error(card->ospriv, "Null pdata for unifi_bulk_rw() len: %d\n", len); - return CSR_WIFI_HIP_RESULT_INVALID_VALUE; - } - if ((len & 1) || (len > 0xffff)) - { - unifi_error(card->ospriv, "Impossible CMD53 length requested: %d\n", len); - return CSR_WIFI_HIP_RESULT_INVALID_VALUE; - } - - while (1) - { - csrResult = csr_sdio_block_rw(card, card->function, handle, - (u8 *)pdata, (u16)len, - direction); - if (csrResult == CSR_SDIO_RESULT_NO_DEVICE) - { - return CSR_WIFI_HIP_RESULT_NO_DEVICE; - } -#ifdef CSR_WIFI_MAKE_FAKE_CMD53_ERRORS - if (++fake_error > 100) - { - fake_error = 90; - unifi_warning(card->ospriv, "Faking a CMD53 error,\n"); - if (csrResult == CSR_RESULT_SUCCESS) - { - csrResult = CSR_RESULT_FAILURE; - } - } -#endif - if (csrResult == CSR_RESULT_SUCCESS) - { - if (dump_read) - { - dump(pdata, (u16)len); - } - break; - } - - /* - * At this point the SDIO driver should have written the I/O Abort - * register to notify UniFi that the command has failed. - * UniFi-1 and UniFi-2 (not UF6xxx) use the same register to store the - * Deep Sleep State. This means we have to restore the Deep Sleep - * State (AWAKE in any case since we can not perform a CD53 in any other - * state) by rewriting the I/O Abort register to its previous value. - */ - if (card->chip_id <= SDIO_CARD_ID_UNIFI_2) - { - (void)unifi_set_host_state(card, UNIFI_HOST_STATE_AWAKE); - } - - /* If csr_sdio_block_rw() failed in a non-retryable way, or retries exhausted - * then stop retrying - */ - if (!retryable_sdio_error(csrResult)) - { - unifi_error(card->ospriv, "Fatal error in a CMD53 transfer\n"); - break; - } - - /* - * These happen from time to time, try again - */ - if (--retries == 0) - { - break; - } - - unifi_trace(card->ospriv, UDBG4, - "Error in a CMD53 transfer, retrying (h:%d,l:%u)...\n", - (s16)handle & 0xff, len); - - /* The transfer failed, rewind and try again */ - r = unifi_write_8_or_16(card, card->sdio_ctrl_addr + 8, - (u8)(handle & 0xff)); - if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE) - { - return r; - } - if (r != CSR_RESULT_SUCCESS) - { - /* - * If we can't even do CMD52 (register read/write) then - * stop here. - */ - unifi_error(card->ospriv, "Failed to write REWIND cmd\n"); - return r; - } - - /* Signal the UniFi to look for the rewind request. */ - r = CardGenInt(card); - if (r != CSR_RESULT_SUCCESS) - { - return r; - } - - /* Wait for UniFi to acknowledge the rewind */ - stat_retries = REWIND_RETRIES; - while (1) - { - r = unifi_read_8_or_16(card, card->sdio_ctrl_addr + 8, &stat); - if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE) - { - return r; - } - if (r != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, "Failed to read REWIND status\n"); - return CSR_RESULT_FAILURE; - } - - if (stat == 0) - { - break; - } - if (--stat_retries == 0) - { - unifi_error(card->ospriv, "Timeout waiting for REWIND ready\n"); - return CSR_RESULT_FAILURE; - } - - /* Poll for the ack a few times */ - if (stat_retries < REWIND_RETRIES - REWIND_POLLING_RETRIES) - { - CsrThreadSleep(REWIND_DELAY); - } - } - } - - /* The call to csr_sdio_block_rw() still failed after retrying */ - if (csrResult != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, "Block %s failed after %d retries\n", - (direction == UNIFI_SDIO_READ)?"read" : "write", - CMD53_RETRIES - retries); - /* Report any SDIO error as a general i/o error */ - return CSR_RESULT_FAILURE; - } - - /* Collect some stats */ - if (direction == UNIFI_SDIO_READ) - { - card->sdio_bytes_read += len; - } - else - { - card->sdio_bytes_written += len; - } - - return CSR_RESULT_SUCCESS; -} /* unifi_bulk_rw() */ - - -/* - * --------------------------------------------------------------------------- - * unifi_bulk_rw_noretry - * - * Transfer bulk data to or from the UniFi SDIO interface. - * This function is used to read or write signals and bulk data. - * - * Arguments: - * card Pointer to card structure. - * handle Value to put in the Register Address field of - * the CMD53 req. - * data Pointer to data to write. - * direction One of UNIFI_SDIO_READ or UNIFI_SDIO_WRITE - * - * Returns: - * 0 on success, non-zero error code on error: - * CSR_WIFI_HIP_RESULT_NO_DEVICE card was ejected - * CSR_RESULT_FAILURE an SDIO error occurred - * - * Notes: - * This function uses SDIO CMD53, which is the block transfer mode. - * --------------------------------------------------------------------------- - */ -CsrResult unifi_bulk_rw_noretry(card_t *card, u32 handle, void *pdata, - u32 len, s16 direction) -{ - CsrResult csrResult; - - csrResult = csr_sdio_block_rw(card, card->function, handle, - (u8 *)pdata, (u16)len, direction); - if (csrResult != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, "Block %s failed\n", - (direction == UNIFI_SDIO_READ)?"read" : "write"); - return csrResult; - } - - return CSR_RESULT_SUCCESS; -} /* unifi_bulk_rw_noretry() */ - - diff --git a/drivers/staging/csr/csr_wifi_hip_chiphelper.c b/drivers/staging/csr/csr_wifi_hip_chiphelper.c deleted file mode 100644 index 5cf5b8a5a1e1..000000000000 --- a/drivers/staging/csr/csr_wifi_hip_chiphelper.c +++ /dev/null @@ -1,793 +0,0 @@ -/***************************************************************************** - - (c) Cambridge Silicon Radio Limited 2011 - All rights reserved and confidential information of CSR - - Refer to LICENSE.txt included with this source for details - on the license terms. - -*****************************************************************************/ - -#include "csr_macro.h" -#include "csr_wifi_hip_chiphelper_private.h" - -#ifndef nelem -#define nelem(a) (sizeof(a) / sizeof(a[0])) -#endif - -#define counted(foo) { nelem(foo), foo } -#define null_counted() { 0, NULL } - -/* The init values are a set of register writes that we must - perform when we first connect to the chip to get it working. - They swicth on the correct clocks and possibly set the host - interface as a wkaeup source. They should not be used if - proper HIP opperation is required, but are useful before we - do a code download. */ -static const struct chip_helper_init_values init_vals_v1[] = { - { 0xFDBB, 0xFFFF }, - { 0xFDB6, 0x03FF }, - { 0xFDB1, 0x01E3 }, - { 0xFDB3, 0x0FFF }, - { 0xFEE3, 0x08F0 }, - { 0xFEE7, 0x3C3F }, - { 0xFEE6, 0x0050 }, - { 0xFDBA, 0x0000 } -}; - -static const struct chip_helper_init_values init_vals_v2[] = { - { 0xFDB6, 0x0FFF }, - { 0xF023, 0x3F3F }, - { 0xFDB1, 0x01E3 }, - { 0xFDB3, 0x0FFF }, - { 0xF003, 0x08F0 }, - { 0xF007, 0x3C3F }, - { 0xF006, 0x0050 } -}; - - -static const struct chip_helper_init_values init_vals_v22_v23[] = { - { 0xF81C, 0x00FF }, - /*{ 0x????, 0x???? }, */ - { 0xF80C, 0x1FFF }, - { 0xFA25, 0x001F }, - { 0xF804, 0x00FF }, - { 0xF802, 0x0FFF }, - /*{ 0x????, 0x???? }, - { 0x????, 0x???? }, - { 0x????, 0x???? }*/ -}; - -static const u16 reset_program_a_v1_or_v2[] = { - 0x0000 -}; -static const u16 reset_program_b_v1_or_v2[] = { - 0x0010, 0xFE00, 0xA021, 0xFF00, 0x8111, 0x0009, 0x0CA4, 0x0114, - 0x0280, 0x04F8, 0xFE00, 0x6F25, 0x06E0, 0x0010, 0xFC00, 0x0121, - 0xFC00, 0x0225, 0xFE00, 0x7125, 0xFE00, 0x6D11, 0x03F0, 0xFE00, - 0x6E25, 0x0008, 0x00E0 -}; - -static const struct chip_helper_reset_values reset_program_v1_or_v2[] = -{ - { - MAKE_GP(REGISTERS, 0x000C), - nelem(reset_program_a_v1_or_v2), - reset_program_a_v1_or_v2 - }, - { - MAKE_GP(MAC_PMEM, 0x000000), - nelem(reset_program_b_v1_or_v2), - reset_program_b_v1_or_v2 - } -}; - -static const struct chip_map_address_t unifi_map_address_v1_v2[] = -{ - { 0xFE9F, 0xFE7B }, /* PM1_BANK_SELECT */ - { 0xFE9E, 0xFE78 }, /* PM2_BANK_SELECT */ - { 0xFE9D, 0xFE7E }, /* SHARED_DMEM_PAGE */ - { 0xFE91, 0xFE90 }, /* PROC_SELECT */ - { 0xFE8D, 0xFE8C }, /* STOP_STATUS */ -}; - -static const struct chip_map_address_t unifi_map_address_v22_v23[] = -{ - { 0xF8F9, 0xF8AC }, /* GW1_CONFIG */ - { 0xF8FA, 0xF8AD }, /* GW2_CONFIG */ - { 0xF8FB, 0xF8AE }, /* GW3_CONFIG */ - { 0xF830, 0xF81E }, /* PROC_SELECT */ - { 0xF831, 0xF81F }, /* STOP_STATUS */ - { 0xF8FC, 0xF8AF }, /* IO_LOG_ADDRESS */ -}; - -static const struct chip_device_regs_t unifi_device_regs_null = -{ - 0xFE81, /* GBL_CHIP_VERSION */ - 0x0000, /* GBL_MISC_ENABLES */ - 0x0000, /* DBG_EMU_CMD */ - { - 0x0000, /* HOST.DBG_PROC_SELECT */ - 0x0000, /* HOST.DBG_STOP_STATUS */ - 0x0000, /* HOST.WINDOW1_PAGE */ - 0x0000, /* HOST.WINDOW2_PAGE */ - 0x0000, /* HOST.WINDOW3_PAGE */ - 0x0000 /* HOST.IO_LOG_ADDR */ - }, - { - 0x0000, /* SPI.DBG_PROC_SELECT */ - 0x0000, /* SPI.DBG_STOP_STATUS */ - 0x0000, /* SPI.WINDOW1_PAGE */ - 0x0000, /* SPI.WINDOW2_PAGE */ - 0x0000, /* SPI.WINDOW3_PAGE */ - 0x0000 /* SPI.IO_LOG_ADDR */ - }, - 0x0000, /* DBG_RESET */ - 0x0000, /* > DBG_RESET_VALUE */ - 0x0000, /* DBG_RESET_WARN */ - 0x0000, /* DBG_RESET_WARN_VALUE */ - 0x0000, /* DBG_RESET_RESULT */ - 0xFFE9, /* XAP_PCH */ - 0xFFEA, /* XAP_PCL */ - 0x0000, /* PROC_PC_SNOOP */ - 0x0000, /* WATCHDOG_DISABLE */ - 0x0000, /* MAILBOX0 */ - 0x0000, /* MAILBOX1 */ - 0x0000, /* MAILBOX2 */ - 0x0000, /* MAILBOX3 */ - 0x0000, /* SDIO_HOST_INT */ - 0x0000, /* SHARED_IO_INTERRUPT */ - 0x0000, /* SDIO HIP HANDSHAKE */ - 0x0000 /* COEX_STATUS */ -}; - -/* UF105x */ -static const struct chip_device_regs_t unifi_device_regs_v1 = -{ - 0xFE81, /* GBL_CHIP_VERSION */ - 0xFE87, /* GBL_MISC_ENABLES */ - 0xFE9C, /* DBG_EMU_CMD */ - { - 0xFE90, /* HOST.DBG_PROC_SELECT */ - 0xFE8C, /* HOST.DBG_STOP_STATUS */ - 0xFE7B, /* HOST.WINDOW1_PAGE */ - 0xFE78, /* HOST.WINDOW2_PAGE */ - 0xFE7E, /* HOST.WINDOW3_PAGE */ - 0x0000 /* HOST.IO_LOG_ADDR */ - }, - { - 0xFE91, /* SPI.DBG_PROC_SELECT */ - 0xFE8D, /* SPI.DBG_STOP_STATUS */ - 0xFE9F, /* SPI.WINDOW1_PAGE */ - 0xFE9E, /* SPI.WINDOW2_PAGE */ - 0xFE9D, /* SPI.WINDOW3_PAGE */ - 0x0000 /* SPI.IO_LOG_ADDR */ - }, - 0xFE92, /* DBG_RESET */ - 0x0001, /* > DBG_RESET_VALUE */ - 0xFDA0, /* DBG_RESET_WARN (HOST_SELECT) */ - 0x0000, /* DBG_RESET_WARN_VALUE */ - 0xFE92, /* DBG_RESET_RESULT */ - 0xFFE9, /* XAP_PCH */ - 0xFFEA, /* XAP_PCL */ - 0x0051, /* PROC_PC_SNOOP */ - 0xFE70, /* WATCHDOG_DISABLE */ - 0xFE6B, /* MAILBOX0 */ - 0xFE6A, /* MAILBOX1 */ - 0xFE69, /* MAILBOX2 */ - 0xFE68, /* MAILBOX3 */ - 0xFE67, /* SDIO_HOST_INT */ - 0xFE65, /* SHARED_IO_INTERRUPT */ - 0xFDE9, /* SDIO HIP HANDSHAKE */ - 0x0000 /* COEX_STATUS */ -}; - -/* UF2... */ -static const struct chip_device_regs_t unifi_device_regs_v2 = -{ - 0xFE81, /* GBL_CHIP_VERSION */ - 0xFE87, /* GBL_MISC_ENABLES */ - 0xFE9C, /* DBG_EMU_CMD */ - { - 0xFE90, /* HOST.DBG_PROC_SELECT */ - 0xFE8C, /* HOST.DBG_STOP_STATUS */ - 0xFE7B, /* HOST.WINDOW1_PAGE */ - 0xFE78, /* HOST.WINDOW2_PAGE */ - 0xFE7E, /* HOST.WINDOW3_PAGE */ - 0x0000 /* HOST.IO_LOG_ADDR */ - }, - { - 0xFE91, /* SPI.DBG_PROC_SELECT */ - 0xFE8D, /* SPI.DBG_STOP_STATUS */ - 0xFE9F, /* SPI.WINDOW1_PAGE */ - 0xFE9E, /* SPI.WINDOW2_PAGE */ - 0xFE9D, /* SPI.WINDOW3_PAGE */ - 0x0000 /* SPI.IO_LOG_ADDR */ - }, - 0xFE92, /* DBG_RESET */ - 0x0000, /* > DBG_RESET_VALUE */ - 0xFDE9, /* DBG_RESET_WARN (TEST_FLASH_DATA - SHARED_MAILBOX2B) */ - 0xFFFF, /* DBG_RESET_WARN_VALUE */ - 0xFDE9, /* DBG_RESET_RESULT (TEST_FLASH_DATA) */ - 0xFFE9, /* XAP_PCH */ - 0xFFEA, /* XAP_PCL */ - 0x0051, /* PROC_PC_SNOOP */ - 0xFE70, /* WATCHDOG_DISABLE */ - 0xFE6B, /* MAILBOX0 */ - 0xFE6A, /* MAILBOX1 */ - 0xFE69, /* MAILBOX2 */ - 0xFE68, /* MAILBOX3 */ - 0xFE67, /* SDIO_HOST_INT */ - 0xFE65, /* SHARED_IO_INTERRUPT */ - 0xFE69, /* SDIO HIP HANDSHAKE */ - 0x0000 /* COEX_STATUS */ -}; - -/* UF60xx */ -static const struct chip_device_regs_t unifi_device_regs_v22_v23 = -{ - 0xFE81, /* GBL_CHIP_VERSION */ - 0xF84F, /* GBL_MISC_ENABLES */ - 0xF81D, /* DBG_EMU_CMD */ - { - 0xF81E, /* HOST.DBG_PROC_SELECT */ - 0xF81F, /* HOST.DBG_STOP_STATUS */ - 0xF8AC, /* HOST.WINDOW1_PAGE */ - 0xF8AD, /* HOST.WINDOW2_PAGE */ - 0xF8AE, /* HOST.WINDOW3_PAGE */ - 0xF8AF /* HOST.IO_LOG_ADDR */ - }, - { - 0xF830, /* SPI.DBG_PROC_SELECT */ - 0xF831, /* SPI.DBG_STOP_STATUS */ - 0xF8F9, /* SPI.WINDOW1_PAGE */ - 0xF8FA, /* SPI.WINDOW2_PAGE */ - 0xF8FB, /* SPI.WINDOW3_PAGE */ - 0xF8FC /* SPI.IO_LOG_ADDR */ - }, - 0xF82F, /* DBG_RESET */ - 0x0001, /* > DBG_RESET_VALUE */ - 0x0000, /* DBG_RESET_WARN */ - 0x0000, /* DBG_RESET_WARN_VALUE */ - 0xF82F, /* DBG_RESET_RESULT */ - 0xFFE9, /* XAP_PCH */ - 0xFFEA, /* XAP_PCL */ - 0x001B, /* PROC_PC_SNOOP */ - 0x0055, /* WATCHDOG_DISABLE */ - 0xF84B, /* MAILBOX0 */ - 0xF84C, /* MAILBOX1 */ - 0xF84D, /* MAILBOX2 */ - 0xF84E, /* MAILBOX3 */ - 0xF92F, /* SDIO_HOST_INT */ - 0xF92B, /* SDIO_FROMHOST_SCRTACH0 / SHARED_IO_INTERRUPT */ - 0xF84D, /* SDIO HIP HANDSHAKE (MAILBOX2) */ - 0xF9FB /* COEX_STATUS */ -}; - -/* Program memory window on UF105x. */ -static const struct window_shift_info_t prog_window_array_unifi_v1_v2[CHIP_HELPER_WT_COUNT] = -{ - { TRUE, 11, 0x0200 }, /* CODE RAM */ - { TRUE, 11, 0x0000 }, /* FLASH */ - { TRUE, 11, 0x0400 }, /* External SRAM */ - { FALSE, 0, 0 }, /* ROM */ - { FALSE, 0, 0 } /* SHARED */ -}; - -/* Shared memory window on UF105x. */ -static const struct window_shift_info_t shared_window_array_unifi_v1_v2[CHIP_HELPER_WT_COUNT] = -{ - { FALSE, 0, 0 }, /* CODE RAM */ - { FALSE, 0, 0 }, /* FLASH */ - { FALSE, 0, 0 }, /* External SRAM */ - { FALSE, 0, 0 }, /* ROM */ - { TRUE, 11, 0x0000 } /* SHARED */ -}; - -/* One of the Generic Windows on UF60xx and later. */ -static const struct window_shift_info_t generic_window_array_unifi_v22_v23[CHIP_HELPER_WT_COUNT] = -{ - { TRUE, 11, 0x3800 }, /* CODE RAM */ - { FALSE, 0, 0 }, /* FLASH */ - { FALSE, 0, 0 }, /* External SRAM */ - { TRUE, 11, 0x2000 }, /* ROM */ - { TRUE, 11, 0x0000 } /* SHARED */ -}; - -/* The three windows on UF105x. */ -static const struct window_info_t prog1_window_unifi_v1_v2 = { 0x0000, 0x2000, 0x0080, prog_window_array_unifi_v1_v2 }; -static const struct window_info_t prog2_window_unifi_v1_v2 = { 0x2000, 0x2000, 0x0000, prog_window_array_unifi_v1_v2 }; -static const struct window_info_t shared_window_unifi_v1_v2 = { 0x4000, 0x2000, 0x0000, shared_window_array_unifi_v1_v2 }; - -/* The three windows on UF60xx and later. */ -static const struct window_info_t generic1_window_unifi_v22_v23 = { 0x0000, 0x2000, 0x0080, generic_window_array_unifi_v22_v23 }; -static const struct window_info_t generic2_window_unifi_v22_v23 = { 0x2000, 0x2000, 0x0000, generic_window_array_unifi_v22_v23 }; -static const struct window_info_t generic3_window_unifi_v22_v23 = { 0x4000, 0x2000, 0x0000, generic_window_array_unifi_v22_v23 }; - -static const struct chip_device_desc_t chip_device_desc_null = -{ - { FALSE, 0x0000, 0x0000, 0x00 }, - "", - "", - null_counted(), /* init */ - null_counted(), /* reset_prog */ - &unifi_device_regs_null, /* regs */ - { - FALSE, /* has_flash */ - FALSE, /* has_ext_sram */ - FALSE, /* has_rom */ - FALSE, /* has_bt */ - FALSE, /* has_wlan */ - }, - null_counted(), - /* prog_offset */ - { - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000 - }, - /* data_offset */ - { - 0x0000 /* ram */ - }, - /* windows */ - { - NULL, - NULL, - NULL - } -}; - -static const struct chip_device_desc_t unifi_device_desc_v1 = -{ - { FALSE, 0xf0ff, 0x1001, 0x01 }, /* UF105x R01 */ - "UF105x", - "UniFi-1", - counted(init_vals_v1), /* init */ - counted(reset_program_v1_or_v2), /* reset_prog */ - &unifi_device_regs_v1, /* regs */ - { - TRUE, /* has_flash */ - TRUE, /* has_ext_sram */ - FALSE, /* has_rom */ - FALSE, /* has_bt */ - TRUE, /* has_wlan */ - }, - counted(unifi_map_address_v1_v2), /* map */ - /* prog_offset */ - { - 0x00100000, /* ram */ - 0x00000000, /* rom (invalid) */ - 0x00000000, /* flash */ - 0x00200000, /* ext_ram */ - }, - /* data_offset */ - { - 0x8000 /* ram */ - }, - /* windows */ - { - &prog1_window_unifi_v1_v2, - &prog2_window_unifi_v1_v2, - &shared_window_unifi_v1_v2 - } -}; - -static const struct chip_device_desc_t unifi_device_desc_v2 = -{ - { FALSE, 0xf0ff, 0x2001, 0x02 }, /* UF2... R02 */ - "UF2...", - "UniFi-2", - counted(init_vals_v2), /* init */ - counted(reset_program_v1_or_v2), /* reset_prog */ - &unifi_device_regs_v2, /* regs */ - { - TRUE, /* has_flash */ - TRUE, /* has_ext_sram */ - FALSE, /* has_rom */ - FALSE, /* has_bt */ - TRUE, /* has_wlan */ - }, - counted(unifi_map_address_v1_v2), /* map */ - /* prog_offset */ - { - 0x00100000, /* ram */ - 0x00000000, /* rom (invalid) */ - 0x00000000, /* flash */ - 0x00200000, /* ext_ram */ - }, - /* data_offset */ - { - 0x8000 /* ram */ - }, - /* windows */ - { - &prog1_window_unifi_v1_v2, - &prog2_window_unifi_v1_v2, - &shared_window_unifi_v1_v2 - } -}; - -static const struct chip_device_desc_t unifi_device_desc_v3 = -{ - { FALSE, 0xf0ff, 0x3001, 0x02 }, /* UF2... R03 */ - "UF2...", - "UniFi-3", - counted(init_vals_v2), /* init */ - counted(reset_program_v1_or_v2), /* reset_prog */ - &unifi_device_regs_v2, /* regs */ - { - TRUE, /* has_flash */ - TRUE, /* has_ext_sram */ - FALSE, /* has_rom */ - FALSE, /* has_bt */ - TRUE, /* has_wlan */ - }, - counted(unifi_map_address_v1_v2), /* map */ - /* prog_offset */ - { - 0x00100000, /* ram */ - 0x00000000, /* rom (invalid) */ - 0x00000000, /* flash */ - 0x00200000, /* ext_ram */ - }, - /* data_offset */ - { - 0x8000 /* ram */ - }, - /* windows */ - { - &prog1_window_unifi_v1_v2, - &prog2_window_unifi_v1_v2, - &shared_window_unifi_v1_v2 - } -}; - -static const struct chip_device_desc_t unifi_device_desc_v22 = -{ - { FALSE, 0x00ff, 0x0022, 0x07 }, /* UF60xx */ - "UF60xx", - "UniFi-4", - counted(init_vals_v22_v23), /* init */ - null_counted(), /* reset_prog */ - &unifi_device_regs_v22_v23, /* regs */ - { - FALSE, /* has_flash */ - FALSE, /* has_ext_sram */ - TRUE, /* has_rom */ - FALSE, /* has_bt */ - TRUE, /* has_wlan */ - }, - counted(unifi_map_address_v22_v23), /* map */ - /* prog_offset */ - { - 0x00C00000, /* ram */ - 0x00000000, /* rom */ - 0x00000000, /* flash (invalid) */ - 0x00000000, /* ext_ram (invalid) */ - }, - /* data_offset */ - { - 0x8000 /* ram */ - }, - /* windows */ - { - &generic1_window_unifi_v22_v23, - &generic2_window_unifi_v22_v23, - &generic3_window_unifi_v22_v23 - } -}; - -static const struct chip_device_desc_t unifi_device_desc_v23 = -{ - { FALSE, 0x00ff, 0x0023, 0x08 }, /* UF.... */ - "UF....", - "UF.... (5)", - counted(init_vals_v22_v23), /* init */ - null_counted(), /* reset_prog */ - &unifi_device_regs_v22_v23, /* regs */ - { - FALSE, /* has_flash */ - FALSE, /* has_ext_sram */ - TRUE, /* has_rom */ - TRUE, /* has_bt */ - TRUE, /* has_wlan */ - }, - counted(unifi_map_address_v22_v23), - /* prog_offset */ - { - 0x00C00000, /* ram */ - 0x00000000, /* rom */ - 0x00000000, /* flash (invalid) */ - 0x00000000, /* ext_sram (invalid) */ - }, - /* data_offset */ - { - 0x8000 /* ram */ - }, - /* windows */ - { - &generic1_window_unifi_v22_v23, - &generic2_window_unifi_v22_v23, - &generic3_window_unifi_v22_v23 - } -}; - -static const struct chip_device_desc_t hyd_wlan_subsys_desc_v1 = -{ - { FALSE, 0x00ff, 0x0044, 0x00 }, /* UF.... */ - "HYD...", - "HYD... ", - counted(init_vals_v22_v23), /* init */ - null_counted(), /* reset_prog */ - &unifi_device_regs_v22_v23, /* regs */ - { - FALSE, /* has_flash */ - FALSE, /* has_ext_sram */ - TRUE, /* has_rom */ - FALSE, /* has_bt */ - TRUE, /* has_wlan */ - }, - counted(unifi_map_address_v22_v23), - /* prog_offset */ - { - 0x00C00000, /* ram */ - 0x00000000, /* rom */ - 0x00000000, /* flash (invalid) */ - 0x00000000, /* ext_sram (invalid) */ - }, - /* data_offset */ - { - 0x8000 /* ram */ - }, - /* windows */ - { - &generic1_window_unifi_v22_v23, - &generic2_window_unifi_v22_v23, - &generic3_window_unifi_v22_v23 - } -}; - - -/* This is the list of all chips that we know about. I'm - assuming that the order here will be important - we - might have multiple entries witrh the same SDIO id for - instance. The first one in this list will be the one - that is returned if a search is done on only that id. - The client will then have to call GetVersionXXX again - but with more detailed info. - - I don't know if we need to signal this up to the client - in some way? - - (We get the SDIO id before we know anything else about - the chip. We might not be able to read any of the other - registers at first, but we still need to know about the - chip). */ -static const struct chip_device_desc_t *chip_ver_to_desc[] = -{ - &unifi_device_desc_v1, /* UF105x R01 */ - &unifi_device_desc_v2, /* UF2... R02 */ - &unifi_device_desc_v3, /* UF2... R03 */ - &unifi_device_desc_v22, /* UF60xx */ - &unifi_device_desc_v23, /* UF.... */ - &hyd_wlan_subsys_desc_v1 -}; - -ChipDescript* ChipHelper_GetVersionSdio(u8 sdio_ver) -{ - u32 i; - - for (i = 0; i < nelem(chip_ver_to_desc); i++) - { - if (chip_ver_to_desc[i]->chip_version.sdio == sdio_ver) - { - return chip_ver_to_desc[i]; - } - } - - return &chip_device_desc_null; -} - - -ChipDescript* ChipHelper_GetVersionAny(u16 from_FF9A, u16 from_FE81) -{ - u32 i; - - if ((from_FF9A & 0xFF00) != 0) - { - for (i = 0; i < nelem(chip_ver_to_desc); i++) - { - if (chip_ver_to_desc[i]->chip_version.pre_bc7 && - ((from_FF9A & chip_ver_to_desc[i]->chip_version.mask) == - chip_ver_to_desc[i]->chip_version.result)) - { - return chip_ver_to_desc[i]; - } - } - } - else - { - for (i = 0; i < nelem(chip_ver_to_desc); i++) - { - if (!chip_ver_to_desc[i]->chip_version.pre_bc7 && - ((from_FE81 & chip_ver_to_desc[i]->chip_version.mask) == - chip_ver_to_desc[i]->chip_version.result)) - { - return chip_ver_to_desc[i]; - } - } - } - - return &chip_device_desc_null; -} - - -ChipDescript* ChipHelper_GetVersionUniFi(u16 ver) -{ - return ChipHelper_GetVersionAny(0x0000, ver); -} - - -ChipDescript *ChipHelper_Null(void) -{ - return &chip_device_desc_null; -} - - -ChipDescript* ChipHelper_GetVersionBlueCore(enum chip_helper_bluecore_age bc_age, u16 version) -{ - if (bc_age == chip_helper_bluecore_pre_bc7) - { - return ChipHelper_GetVersionAny(version, 0x0000); - } - else - { - return ChipHelper_GetVersionAny(0x0000, version); - } -} - - -/* Expand the DEF0 functions into simple code to return the - correct thing. The DEF1 functions expand to nothing in - this X macro expansion. */ -#define CHIP_HELPER_DEF0_C_DEF(ret_type, name, info) \ - ret_type ChipHelper_ ## name(ChipDescript * chip_help) \ - { \ - return chip_help->info; \ - } -#define CHIP_HELPER_DEF1_C_DEF(ret_type, name, type1, name1) - -CHIP_HELPER_LIST(C_DEF) - -/* - * Map register addresses between HOST and SPI access. - */ -u16 ChipHelper_MapAddress_SPI2HOST(ChipDescript *chip_help, u16 addr) -{ - u32 i; - for (i = 0; i < chip_help->map.len; i++) - { - if (chip_help->map.vals[i].spi == addr) - { - return chip_help->map.vals[i].host; - } - } - return addr; -} - - -u16 ChipHelper_MapAddress_HOST2SPI(ChipDescript *chip_help, u16 addr) -{ - u32 i; - for (i = 0; i < chip_help->map.len; i++) - { - if (chip_help->map.vals[i].host == addr) - { - return chip_help->map.vals[i].spi; - } - } - return addr; -} - - -/* The address returned by this function is the start of the - window in the address space, that is where we can start - accessing data from. If a section of the window at the - start is unusable because something else is cluttering up - the address map then that is taken into account and this - function returns that address justt past that. */ -u16 ChipHelper_WINDOW_ADDRESS(ChipDescript *chip_help, - enum chip_helper_window_index window) -{ - if (window < CHIP_HELPER_WINDOW_COUNT && - chip_help->windows[window] != NULL) - { - return chip_help->windows[window]->address + chip_help->windows[window]->blocked; - } - return 0; -} - - -/* This returns the size of the window minus any blocked section */ -u16 ChipHelper_WINDOW_SIZE(ChipDescript *chip_help, - enum chip_helper_window_index window) -{ - if (window < CHIP_HELPER_WINDOW_COUNT && - chip_help->windows[window] != NULL) - { - return chip_help->windows[window]->size - chip_help->windows[window]->blocked; - } - return 0; -} - - -/* Get the register writes we should do to make sure that - the chip is running with most clocks on. */ -u32 ChipHelper_ClockStartupSequence(ChipDescript *chip_help, - const struct chip_helper_init_values **val) -{ - *val = chip_help->init.vals; - return chip_help->init.len; -} - - -/* Get the set of values tat we should write to the chip to perform a reset. */ -u32 ChipHelper_HostResetSequence(ChipDescript *chip_help, - const struct chip_helper_reset_values **val) -{ - *val = chip_help->reset_prog.vals; - return chip_help->reset_prog.len; -} - - -/* Decode a windowed access to the chip. */ -s32 ChipHelper_DecodeWindow(ChipDescript *chip_help, - enum chip_helper_window_index window, - enum chip_helper_window_type type, - u32 offset, - u16 *page, u16 *addr, u32 *len) -{ - const struct window_info_t *win; - const struct window_shift_info_t *mode; - u16 of, pg; - - if (window >= CHIP_HELPER_WINDOW_COUNT) - { - return FALSE; - } - if ((win = chip_help->windows[window]) == NULL) - { - return FALSE; - } - if (type >= CHIP_HELPER_WT_COUNT) - { - return FALSE; - } - if ((mode = &win->mode[type]) == NULL) - { - return FALSE; - } - if (!mode->allowed) - { - return FALSE; - } - - pg = (u16)(offset >> mode->page_shift) + mode->page_offset; - of = (u16)(offset & ((1 << mode->page_shift) - 1)); - /* If 'blocked' is zero this does nothing, else decrease - the page register and increase the offset until we aren't - in the blocked region of the window. */ - while (of < win->blocked) - { - of += 1 << mode->page_shift; - pg--; - } - *page = pg; - *addr = win->address + of; - *len = win->size - of; - return TRUE; -} - - diff --git a/drivers/staging/csr/csr_wifi_hip_chiphelper.h b/drivers/staging/csr/csr_wifi_hip_chiphelper.h deleted file mode 100644 index 09b3aefcbced..000000000000 --- a/drivers/staging/csr/csr_wifi_hip_chiphelper.h +++ /dev/null @@ -1,407 +0,0 @@ -/***************************************************************************** - - (c) Cambridge Silicon Radio Limited 2011 - All rights reserved and confidential information of CSR - - Refer to LICENSE.txt included with this source for details - on the license terms. - -*****************************************************************************/ - -#ifndef CSR_WIFI_HIP_CHIPHELPER_H__ -#define CSR_WIFI_HIP_CHIPHELPER_H__ - - -#include - -/* The age of the BlueCore chip. This is probably not useful, if - you know the age then you can probably work out the version directly. */ -enum chip_helper_bluecore_age -{ - chip_helper_bluecore_pre_bc7, - chip_helper_bluecore_bc7_or_later -}; - -/* We support up to three windowed regions at the moment. - Don't reorder these - they're used to index into an array. */ -enum chip_helper_window_index -{ - CHIP_HELPER_WINDOW_1 = 0, - CHIP_HELPER_WINDOW_2 = 1, - CHIP_HELPER_WINDOW_3 = 2, - CHIP_HELPER_WINDOW_COUNT = 3 -}; - -/* These are the things that we can access through a window. - Don't reorder these - they're used to index into an array. */ -enum chip_helper_window_type -{ - CHIP_HELPER_WT_CODE_RAM = 0, - CHIP_HELPER_WT_FLASH = 1, - CHIP_HELPER_WT_EXT_SRAM = 2, - CHIP_HELPER_WT_ROM = 3, - CHIP_HELPER_WT_SHARED = 4, - CHIP_HELPER_WT_COUNT = 5 -}; - -/* Commands to stop and start the XAP */ -enum chip_helper_dbg_emu_cmd_enum -{ - CHIP_HELPER_DBG_EMU_CMD_XAP_STEP_MASK = 0x0001, - CHIP_HELPER_DBG_EMU_CMD_XAP_RUN_B_MASK = 0x0002, - CHIP_HELPER_DBG_EMU_CMD_XAP_BRK_MASK = 0x0004, - CHIP_HELPER_DBG_EMU_CMD_XAP_WAKEUP_MASK = 0x0008 -}; - -/* Bitmasks for Stop and sleep status: DBG_SPI_STOP_STATUS & DBG_HOST_STOP_STATUS */ -enum chip_helper_dbg_stop_status_enum -{ - CHIP_HELPER_DBG_STOP_STATUS_NONE_MASK = 0x0000, - CHIP_HELPER_DBG_STOP_STATUS_P0_MASK = 0x0001, - CHIP_HELPER_DBG_STOP_STATUS_P1_MASK = 0x0002, - CHIP_HELPER_DBG_STOP_STATUS_P2_MASK = 0x0004, - CHIP_HELPER_DBG_STOP_STATUS_SLEEP_STATUS_P0_MASK = 0x0008, - CHIP_HELPER_DBG_STOP_STATUS_SLEEP_STATUS_P1_MASK = 0x0010, - CHIP_HELPER_DBG_STOP_STATUS_SLEEP_STATUS_P2_MASK = 0x0020, - /* Legacy names/alias */ - CHIP_HELPER_DBG_STOP_STATUS_MAC_MASK = 0x0001, - CHIP_HELPER_DBG_STOP_STATUS_PHY_MASK = 0x0002, - CHIP_HELPER_DBG_STOP_STATUS_BT_MASK = 0x0004, - CHIP_HELPER_DBG_STOP_STATUS_SLEEP_STATUS_MAC_MASK = 0x0008, - CHIP_HELPER_DBG_STOP_STATUS_SLEEP_STATUS_PHY_MASK = 0x0010, - CHIP_HELPER_DBG_STOP_STATUS_SLEEP_STATUS_BT_MASK = 0x0020 -}; - -/* Codes to disable the watchdog */ -enum chip_helper_watchdog_disable_enum -{ - CHIP_HELPER_WATCHDOG_DISABLE_CODE1 = 0x6734, - CHIP_HELPER_WATCHDOG_DISABLE_CODE2 = 0xD6BF, - CHIP_HELPER_WATCHDOG_DISABLE_CODE3 = 0xC31E -}; - -/* Other bits have changed between versions */ -enum chip_helper_gbl_misc_enum -{ - CHIP_HELPER_GBL_MISC_SPI_STOP_OUT_EN_MASK = 0x0001, - CHIP_HELPER_GBL_MISC_MMU_INIT_DONE_MASK = 0x0004 -}; - -/* Coex status register, contains interrupt status and reset pullup status. - * CHIP_HELPER_COEX_STATUS_RST_PULLS_MSB_MASK can be used to check - * for WAPI on R03 chips and later. */ -enum chip_helper_coex_status_mask_enum -{ - CHIP_HELPER_COEX_STATUS_RST_PULLS_LSB_MASK = 0x0001, - CHIP_HELPER_COEX_STATUS_RST_PULLS_MSB_MASK = 0x0008, - CHIP_HELPER_COEX_STATUS_WL_FEC_PINS_LSB_MASK = 0x0010, - CHIP_HELPER_COEX_STATUS_WL_FEC_PINS_MSB_MASK = 0x0080, - CHIP_HELPER_COEX_STATUS_INT_UART_MASK = 0x0100, - CHIP_HELPER_COEX_STATUS_INT_BT_LEG_MASK = 0x0200 -}; - -/* How to select the different CPUs */ -enum chip_helper_dbg_proc_sel_enum -{ - CHIP_HELPER_DBG_PROC_SEL_MAC = 0, - CHIP_HELPER_DBG_PROC_SEL_PHY = 1, - CHIP_HELPER_DBG_PROC_SEL_BT = 2, - CHIP_HELPER_DBG_PROC_SEL_NONE = 2, - CHIP_HELPER_DBG_PROC_SEL_BOTH = 3 -}; - -/* These are the only registers that we have to know the - address of before we know the chip version. */ -enum chip_helper_fixed_registers -{ - /* This is the address of GBL_CHIP_VERISON on BC7, - UF105x, UF60xx and - anything later than that. */ - CHIP_HELPER_UNIFI_GBL_CHIP_VERSION = 0xFE81, - - CHIP_HELPER_OLD_BLUECORE_GBL_CHIP_VERSION = 0xFF9A - - /* This isn't used at the moment (but might be needed - to distinguish the BlueCore sub version?) */ - /* CHIP_HELPER_OLD_BLUECORE_ANA_VERSION_ID = 0xFF7D */ -}; - -/* Address-value pairs for defining initialisation values */ -struct chip_helper_init_values -{ - u16 addr; - u16 value; -}; - -/* A block of data that should be written to the device */ -struct chip_helper_reset_values -{ - u32 gp_address; - u32 len; - const u16 *data; -}; - -/* - * This is the C API. - */ - -/* opaque type */ -typedef const struct chip_device_desc_t ChipDescript; - -/* Return a NULL descriptor */ -ChipDescript* ChipHelper_Null(void); - -/* This should get the correct version for any CSR chip. - The two parameters are what is read from addresses - 0xFF9A and 0xFE81 (OLD_BLUECORE_GBL_CHIP_VERSION and - UNIFI_GBL_CHIP_VERSION). These should give a unique identity - for most (all?) chips. - - FF9A is the old GBL_CHIP_VERSION register. If the high - eight bits are zero then the chip is a new (BC7 +) one - and FE81 is the _new_ GBL_CHIP_VERSION register. */ -ChipDescript* ChipHelper_GetVersionAny(u16 from_FF9A, u16 from_FE81); - -/* The chip is a UniFi, but we don't know which type - The parameter is the value of UNIFI_GBL_CHIP_VERSION (0xFE81) */ -ChipDescript* ChipHelper_GetVersionUniFi(u16 version); - -/* This gets the version from the SDIO device id. This only - gives quite a coarse grained version, so we should update once - we hav access to the function N registers. */ -ChipDescript* ChipHelper_GetVersionSdio(u8 sdio_version); - -/* The chip is some sort of BlueCore. If "age" is "pre_bc7" then - "version" is what was read from FF9A. If "age" is bc7_or_later - then "version" is read from FE81. If we don't know if we're pre - or post BC7 then we should use "GetVersionAny". */ -ChipDescript* ChipHelper_GetVersionBlueCore(enum chip_helper_bluecore_age age, - u16 version); - -/* The main functions of this class are built with an X macro. This - means we can generate the C and C++ versions from the same source - without the two diverging. - - The DEF0 functions are simple and take no parameters. The first - parameter to the macro is the return type. The second parameter - is the function name and the third parameter is where to get the - info from (this is hidden from the user). - - The DEF1 functions take one parameter. This time the third macro - parameter is the type of this parameter, and the fourth macro - parameter is the name of the parameter. The bodies of these - functions are hand written. */ -#define CHIP_HELPER_LIST(m) \ - CHIP_HELPER_DEF0(m, (const char *, FriendlyName, friendly_name)) \ - CHIP_HELPER_DEF0(m, (const char *, MarketingName, marketing_name)) \ - CHIP_HELPER_DEF0(m, (u16, DBG_EMU_CMD, regs->dbg_emu_cmd)) \ - CHIP_HELPER_DEF0(m, (u16, DBG_HOST_PROC_SELECT, regs->host.dbg_proc_select)) \ - CHIP_HELPER_DEF0(m, (u16, DBG_HOST_STOP_STATUS, regs->host.dbg_stop_status)) \ - CHIP_HELPER_DEF0(m, (u16, HOST_WINDOW1_PAGE, regs->host.window1_page)) \ - CHIP_HELPER_DEF0(m, (u16, HOST_WINDOW2_PAGE, regs->host.window2_page)) \ - CHIP_HELPER_DEF0(m, (u16, HOST_WINDOW3_PAGE, regs->host.window3_page)) \ - CHIP_HELPER_DEF0(m, (u16, HOST_IO_LOG_ADDR, regs->host.io_log_addr)) \ - CHIP_HELPER_DEF0(m, (u16, DBG_SPI_PROC_SELECT, regs->spi.dbg_proc_select)) \ - CHIP_HELPER_DEF0(m, (u16, DBG_SPI_STOP_STATUS, regs->spi.dbg_stop_status)) \ - CHIP_HELPER_DEF0(m, (u16, SPI_WINDOW1_PAGE, regs->spi.window1_page)) \ - CHIP_HELPER_DEF0(m, (u16, SPI_WINDOW2_PAGE, regs->spi.window2_page)) \ - CHIP_HELPER_DEF0(m, (u16, SPI_WINDOW3_PAGE, regs->spi.window3_page)) \ - CHIP_HELPER_DEF0(m, (u16, SPI_IO_LOG_ADDR, regs->spi.io_log_addr)) \ - CHIP_HELPER_DEF0(m, (u16, DBG_RESET, regs->dbg_reset)) \ - CHIP_HELPER_DEF0(m, (u16, DBG_RESET_VALUE, regs->dbg_reset_value)) \ - CHIP_HELPER_DEF0(m, (u16, DBG_RESET_WARN, regs->dbg_reset_warn)) \ - CHIP_HELPER_DEF0(m, (u16, DBG_RESET_WARN_VALUE, regs->dbg_reset_warn_value)) \ - CHIP_HELPER_DEF0(m, (u16, DBG_RESET_RESULT, regs->dbg_reset_result)) \ - CHIP_HELPER_DEF0(m, (u16, WATCHDOG_DISABLE, regs->watchdog_disable)) \ - CHIP_HELPER_DEF0(m, (u16, PROC_PC_SNOOP, regs->proc_pc_snoop)) \ - CHIP_HELPER_DEF0(m, (u16, GBL_CHIP_VERSION, regs->gbl_chip_version)) \ - CHIP_HELPER_DEF0(m, (u16, GBL_MISC_ENABLES, regs->gbl_misc_enables)) \ - CHIP_HELPER_DEF0(m, (u16, XAP_PCH, regs->xap_pch)) \ - CHIP_HELPER_DEF0(m, (u16, XAP_PCL, regs->xap_pcl)) \ - CHIP_HELPER_DEF0(m, (u16, MAILBOX0, regs->mailbox0)) \ - CHIP_HELPER_DEF0(m, (u16, MAILBOX1, regs->mailbox1)) \ - CHIP_HELPER_DEF0(m, (u16, MAILBOX2, regs->mailbox2)) \ - CHIP_HELPER_DEF0(m, (u16, MAILBOX3, regs->mailbox3)) \ - CHIP_HELPER_DEF0(m, (u16, SDIO_HIP_HANDSHAKE, regs->sdio_hip_handshake)) \ - CHIP_HELPER_DEF0(m, (u16, SDIO_HOST_INT, regs->sdio_host_int)) \ - CHIP_HELPER_DEF0(m, (u16, COEX_STATUS, regs->coex_status)) \ - CHIP_HELPER_DEF0(m, (u16, SHARED_IO_INTERRUPT, regs->shared_io_interrupt)) \ - CHIP_HELPER_DEF0(m, (u32, PROGRAM_MEMORY_RAM_OFFSET, prog_offset.ram)) \ - CHIP_HELPER_DEF0(m, (u32, PROGRAM_MEMORY_ROM_OFFSET, prog_offset.rom)) \ - CHIP_HELPER_DEF0(m, (u32, PROGRAM_MEMORY_FLASH_OFFSET, prog_offset.flash)) \ - CHIP_HELPER_DEF0(m, (u32, PROGRAM_MEMORY_EXT_SRAM_OFFSET, prog_offset.ext_sram)) \ - CHIP_HELPER_DEF0(m, (u16, DATA_MEMORY_RAM_OFFSET, data_offset.ram)) \ - CHIP_HELPER_DEF0(m, (s32, HasFlash, bools.has_flash)) \ - CHIP_HELPER_DEF0(m, (s32, HasExtSram, bools.has_ext_sram)) \ - CHIP_HELPER_DEF0(m, (s32, HasRom, bools.has_rom)) \ - CHIP_HELPER_DEF0(m, (s32, HasBt, bools.has_bt)) \ - CHIP_HELPER_DEF0(m, (s32, HasWLan, bools.has_wlan)) \ - CHIP_HELPER_DEF1(m, (u16, WINDOW_ADDRESS, enum chip_helper_window_index, window)) \ - CHIP_HELPER_DEF1(m, (u16, WINDOW_SIZE, enum chip_helper_window_index, window)) \ - CHIP_HELPER_DEF1(m, (u16, MapAddress_SPI2HOST, u16, addr)) \ - CHIP_HELPER_DEF1(m, (u16, MapAddress_HOST2SPI, u16, addr)) \ - CHIP_HELPER_DEF1(m, (u32, ClockStartupSequence, const struct chip_helper_init_values **, val)) \ - CHIP_HELPER_DEF1(m, (u32, HostResetSequence, const struct chip_helper_reset_values **, val)) - -/* Some magic to help the expansion */ -#define CHIP_HELPER_DEF0(a, b) \ - CHIP_HELPER_DEF0_ ## a b -#define CHIP_HELPER_DEF1(a, b) \ - CHIP_HELPER_DEF1_ ## a b - -/* Macros so that when we expand the list we get "C" function prototypes. */ -#define CHIP_HELPER_DEF0_C_DEC(ret_type, name, info) \ - ret_type ChipHelper_ ## name(ChipDescript * chip_help); -#define CHIP_HELPER_DEF1_C_DEC(ret_type, name, type1, name1) \ - ret_type ChipHelper_ ## name(ChipDescript * chip_help, type1 name1); - -CHIP_HELPER_LIST(C_DEC) - -/* FriendlyName - MarketingName - - These two functions return human readable strings that describe - the chip. FriendlyName returns something that a software engineer - at CSR might understand. MarketingName returns something more like - an external name for a CSR chip. -*/ -/* DBG_EMU_CMD - WATCHDOG_DISABLE - PROC_PC_SNOOP - GBL_CHIP_VERSION - XAP_PCH - XAP_PCL - - These registers are used to control the XAPs. -*/ -/* DBG_HOST_PROC_SELECT DBG_HOST_STOP_STATUS - HOST_WINDOW1_PAGE HOST_WINDOW2_PAGE HOST_WINDOW3_PAGE - HOST_IO_LOG_ADDR - DBG_SPI_PROC_SELECT DBG_SPI_STOP_STATUS - SPI_WINDOW1_PAGE SPI_WINDOW2_PAGE SPI_WINDOW3_PAGE - SPI_IO_LOG_ADDR - - These register are used to control the XAPs and the memory - windows, normally while debugging the code on chip. There - are two versons of these registers, one for access via SPI - and another for access via the host interface. -*/ -/* DBG_RESET - DBG_RESET_VALUE - DBG_RESET_WARN - DBG_RESET_WARN_VALUE - DBG_RESET_RESULT - - These registers are used to reset the XAP. This can be - quite complex for some chips. If DBG_RESET_WARN is non - zero the DBG_RESET_WARN_VALUE should be written to address - DBG_RESET_WARN before the reset is perfeormed. DBG_RESET_VALUE - should then be written to DBG_RESET to make the reset happen. - The DBG_RESET_RESULT register should contain 0 if the reset - was successful. -*/ -/* GBL_MISC_ENABLES - - This register controls some special chip features. It - should be used with care is it changes quite a lot between - chip versions. -*/ -/* MAILBOX0 - MAILBOX1 - MAILBOX2 - MAILBOX3 - - The mailbox registers are for communication between the host - and the firmware. There use is described in part by the host - interface protcol specifcation. -*/ -/* SDIO_HIP_HANDSHAKE - - This is one of the more important SDIO HIP registers. On some - chips it has the same value as one of the mailbox registers - and on other chips it is different. -*/ -/* SDIO_HOST_INT - SHARED_IO_INTERRUPT - - These registers are used by some versions of the host interface - protocol specification. Their names should probably be changed - to hide the registers and to expose the functions more. -*/ -/* COEX_STATUS - - Coex status register, contains interrupt status and reset - pullup status. The latter is used to detect WAPI. -*/ -/* PROGRAM_MEMORY_RAM_OFFSET - PROGRAM_MEMORY_ROM_OFFSET - PROGRAM_MEMORY_FLASH_OFFSET - PROGRAM_MEMORY_EXT_SRAM_OFFSET - DATA_MEMORY_RAM_OFFSET - - These are constants that describe the offset of the different - memory types in the two different address spaces. -*/ -/* HasFlash HasExtSram HasRom - HasBt HasWLan - - These are a set of bools describing the chip. -*/ -/* WINDOW_ADDRESS WINDOW_SIZE - - These two functions return the size and address of the windows. - The address is the address of the lowest value in the address - map that is part of the window and the size is the number of - visible words. - - Some of the windows have their lowest portion covered by - registers. For these windows address is the first address - after the registers and size is the siave excluding the part - covered by registers. -*/ -/* MapAddress_SPI2HOST - MapAddress_HOST2SPI - - The debugging interface is duplicated on UniFi and later chips - so that there are two versions - one over the SPI interaface and - the other over the SDIO interface. These functions map the - registers between these two interfaces. -*/ -/* ClockStartupSequence - - This function returns the list of register value pairs that - should be forced into UniFi to enable SPI communication. This - set of registers is not needed if the firmware is running, but - will be needed if the device is being booted from cold. These - register writes enable the clocks and setup the PLL to a basic - working state. SPI access might be unreliable until these writes - have occurred (And they may take mulitple goes). -*/ -/* HostResetSequence - - This returns a number of chunks of data and generic pointers. - All of the XAPs should be stopped. The data should be written - to the generic pointers. The instruction pointer for the MAC - should then be set to the start of program memory and then the - MAC should be "go"d. This will reset the chip in a reliable - and orderly manner without resetting the SDIO interface. It - is therefore not needed if the chip is being accessed by the - SPI interface (the DBG_RESET_ mechanism can be used instead). -*/ - -/* The Decode Window function is more complex. For the window - 'window' it tries to return the address and page register - value needed to see offset 'offset' of memory type 'type'. - - It return 1 on success and 0 on failure. 'page' is what - should be written to the page register. 'addr' is the - address in the XAPs 16 address map to read from. 'len' - is the length that we can read without having to change - the page registers. */ -s32 ChipHelper_DecodeWindow(ChipDescript *chip_help, - enum chip_helper_window_index window, - enum chip_helper_window_type type, - u32 offset, - u16 *page, u16 *addr, u32 *len); - -#endif diff --git a/drivers/staging/csr/csr_wifi_hip_chiphelper_private.h b/drivers/staging/csr/csr_wifi_hip_chiphelper_private.h deleted file mode 100644 index e5e579912550..000000000000 --- a/drivers/staging/csr/csr_wifi_hip_chiphelper_private.h +++ /dev/null @@ -1,200 +0,0 @@ -/***************************************************************************** - - (c) Cambridge Silicon Radio Limited 2011 - All rights reserved and confidential information of CSR - - Refer to LICENSE.txt included with this source for details - on the license terms. - -*****************************************************************************/ - -#ifndef CSR_WIFI_HIP_CHIPHELPER_PRIVATE_H__ -#define CSR_WIFI_HIP_CHIPHELPER_PRIVATE_H__ - - -#include "csr_wifi_hip_chiphelper.h" - -/* This GP stuff should be somewhere else? */ - -/* Memory spaces encoded in top byte of Generic Pointer type */ -#define UNIFI_SH_DMEM 0x01 /* Shared Data Memory */ -#define UNIFI_EXT_FLASH 0x02 /* External FLASH */ -#define UNIFI_EXT_SRAM 0x03 /* External SRAM */ -#define UNIFI_REGISTERS 0x04 /* Registers */ -#define UNIFI_PHY_DMEM 0x10 /* PHY Data Memory */ -#define UNIFI_PHY_PMEM 0x11 /* PHY Program Memory */ -#define UNIFI_PHY_ROM 0x12 /* PHY ROM */ -#define UNIFI_MAC_DMEM 0x20 /* MAC Data Memory */ -#define UNIFI_MAC_PMEM 0x21 /* MAC Program Memory */ -#define UNIFI_MAC_ROM 0x22 /* MAC ROM */ -#define UNIFI_BT_DMEM 0x30 /* BT Data Memory */ -#define UNIFI_BT_PMEM 0x31 /* BT Program Memory */ -#define UNIFI_BT_ROM 0x32 /* BT ROM */ - -#define MAKE_GP(R, O) (((UNIFI_ ## R) << 24) | (O)) -#define GP_OFFSET(GP) ((GP) & 0xFFFFFF) -#define GP_SPACE(GP) (((GP) >> 24) & 0xFF) - - -/* Address value pairs */ -struct val_array_t -{ - u32 len; - const struct chip_helper_init_values *vals; -}; - -/* Just a (counted) u16 array */ -struct data_array_t -{ - u32 len; - const u16 *vals; -}; - -struct reset_prog_t -{ - u32 len; - const struct chip_helper_reset_values *vals; -}; - -/* The addresses of registers that are equivalent but on - different host transports. */ -struct chip_map_address_t -{ - u16 spi, host; -}; - -struct map_array_t -{ - u32 len; - const struct chip_map_address_t *vals; -}; - -struct chip_device_regs_per_transport_t -{ - u16 dbg_proc_select; - u16 dbg_stop_status; - u16 window1_page; /* PROG_PMEM1 or GW1 */ - u16 window2_page; /* PROG_PMEM2 or GW2 */ - u16 window3_page; /* SHARED or GW3 */ - u16 io_log_addr; -}; - -struct chip_device_regs_t -{ - u16 gbl_chip_version; - u16 gbl_misc_enables; - u16 dbg_emu_cmd; - struct chip_device_regs_per_transport_t host; - struct chip_device_regs_per_transport_t spi; - u16 dbg_reset; - u16 dbg_reset_value; - u16 dbg_reset_warn; - u16 dbg_reset_warn_value; - u16 dbg_reset_result; - u16 xap_pch; - u16 xap_pcl; - u16 proc_pc_snoop; - u16 watchdog_disable; - u16 mailbox0; - u16 mailbox1; - u16 mailbox2; - u16 mailbox3; - u16 sdio_host_int; - u16 shared_io_interrupt; - u16 sdio_hip_handshake; - u16 coex_status; /* Allows WAPI detection */ -}; - -/* If allowed is false then this window does not provide this - type of access. - This describes how addresses should be shifted to make the - "page" address. The address is shifted left by 'page_shift' - and then has 'page_offset' added. This value should then be - written to the page register. */ -struct window_shift_info_t -{ - s32 allowed; - u32 page_shift; - u16 page_offset; -}; - -/* Each window has an address and size. These are obvious. It then - has a description for each type of memory that might be accessed - through it. There might also be a start to the offset of the window. - This means that that number of addresses at the start of the window - are unusable. */ -struct window_info_t -{ - u16 address; - u16 size; - u16 blocked; - const struct window_shift_info_t *mode; -}; - -/* If GBL_CHIP_VERSION and'ed with 'mask' and is equal to 'result' - then this is the correct set of info. If pre_bc7 is true then the - address of GBL_CHIP_VERSION is FF9A, else its FE81. */ -struct chip_version_t -{ - s32 pre_bc7; - u16 mask; - u16 result; - u8 sdio; -}; - -struct chip_device_desc_t -{ - struct chip_version_t chip_version; - - /* This is a text string that a human might find useful (BC02, UF105x) */ - const char *friendly_name; - /* This is what we show to customers */ - const char *marketing_name; - - /* Initialisation values to write following a reset */ - struct val_array_t init; - - /* Binary sequence for hard reset */ - struct reset_prog_t reset_prog; - - /* The register map */ - const struct chip_device_regs_t *regs; - - /* Some misc. info on the chip */ - struct - { - u32 has_flash : 1; - u32 has_ext_sram : 1; - u32 has_rom : 1; - u32 has_bt : 1; - u32 has_wlan : 1; - } bools; - - /* This table is used to remap register addresses depending on what - host interface is used. On the BC7 and later chips there are - multiple sets of memory window registers, on for each host - interafce (SDIO / SPI). The correct one is needed. */ - struct map_array_t map; - - /* The offsets into the program address space of the different types of memory. - The RAM offset is probably the most useful. */ - struct - { - u32 ram; - u32 rom; - u32 flash; - u32 ext_sram; - } prog_offset; - - /* The offsets into the data address space of interesting things. */ - struct - { - u16 ram; - /* maybe add shared / page tables? */ - } data_offset; - - /* Information on the different windows */ - const struct window_info_t *windows[CHIP_HELPER_WINDOW_COUNT]; -}; - -#endif /* CSR_WIFI_HIP_CHIPHELPER_PRIVATE_H__ */ diff --git a/drivers/staging/csr/csr_wifi_hip_conversions.h b/drivers/staging/csr/csr_wifi_hip_conversions.h deleted file mode 100644 index bf7a52e82995..000000000000 --- a/drivers/staging/csr/csr_wifi_hip_conversions.h +++ /dev/null @@ -1,73 +0,0 @@ -/***************************************************************************** - - (c) Cambridge Silicon Radio Limited 2011 - All rights reserved and confidential information of CSR - - Refer to LICENSE.txt included with this source for details - on the license terms. - -*****************************************************************************/ - -/* - * --------------------------------------------------------------------------- - * - * FILE: csr_wifi_hip_conversions.h - * - * PURPOSE: - * This header file provides the macros for converting to and from - * wire format. - * These macros *MUST* work for little-endian AND big-endian hosts. - * - * --------------------------------------------------------------------------- - */ -#ifndef __CSR_WIFI_HIP_CONVERSIONS_H__ -#define __CSR_WIFI_HIP_CONVERSIONS_H__ - -#define SIZEOF_UINT16 2 -#define SIZEOF_UINT32 4 -#define SIZEOF_UINT64 8 - -#define SIZEOF_SIGNAL_HEADER 6 -#define SIZEOF_DATAREF 4 - - -/* - * Macro to retrieve the signal ID from a wire-format signal. - */ -#define GET_SIGNAL_ID(_buf) CSR_GET_UINT16_FROM_LITTLE_ENDIAN((_buf)) - -/* - * Macros to retrieve and set the DATAREF fields in a packed (i.e. wire-format) - * HIP signal. - */ -#define GET_PACKED_DATAREF_SLOT(_buf, _ref) \ - CSR_GET_UINT16_FROM_LITTLE_ENDIAN(((_buf) + SIZEOF_SIGNAL_HEADER + ((_ref) * SIZEOF_DATAREF) + 0)) - -#define GET_PACKED_DATAREF_LEN(_buf, _ref) \ - CSR_GET_UINT16_FROM_LITTLE_ENDIAN(((_buf) + SIZEOF_SIGNAL_HEADER + ((_ref) * SIZEOF_DATAREF) + 2)) - -#define SET_PACKED_DATAREF_SLOT(_buf, _ref, _slot) \ - CSR_COPY_UINT16_TO_LITTLE_ENDIAN((_slot), ((_buf) + SIZEOF_SIGNAL_HEADER + ((_ref) * SIZEOF_DATAREF) + 0)) - -#define SET_PACKED_DATAREF_LEN(_buf, _ref, _len) \ - CSR_COPY_UINT16_TO_LITTLE_ENDIAN((_len), ((_buf) + SIZEOF_SIGNAL_HEADER + ((_ref) * SIZEOF_DATAREF) + 2)) - -#define GET_PACKED_MA_PACKET_REQUEST_FRAME_PRIORITY(_buf) \ - CSR_GET_UINT16_FROM_LITTLE_ENDIAN(((_buf) + SIZEOF_SIGNAL_HEADER + UNIFI_MAX_DATA_REFERENCES * SIZEOF_DATAREF + 8)) - -#define GET_PACKED_MA_PACKET_REQUEST_HOST_TAG(_buf) \ - CSR_GET_UINT32_FROM_LITTLE_ENDIAN(((_buf) + SIZEOF_SIGNAL_HEADER + UNIFI_MAX_DATA_REFERENCES * SIZEOF_DATAREF + 4)) - -#define GET_PACKED_MA_PACKET_CONFIRM_HOST_TAG(_buf) \ - CSR_GET_UINT32_FROM_LITTLE_ENDIAN(((_buf) + SIZEOF_SIGNAL_HEADER + UNIFI_MAX_DATA_REFERENCES * SIZEOF_DATAREF + 8)) - -#define GET_PACKED_MA_PACKET_CONFIRM_TRANSMISSION_STATUS(_buf) \ - CSR_GET_UINT16_FROM_LITTLE_ENDIAN(((_buf) + SIZEOF_SIGNAL_HEADER + UNIFI_MAX_DATA_REFERENCES * SIZEOF_DATAREF + 2)) - - -s32 get_packed_struct_size(const u8 *buf); -CsrResult read_unpack_signal(const u8 *ptr, CSR_SIGNAL *sig); -CsrResult write_pack(const CSR_SIGNAL *sig, u8 *ptr, u16 *sig_len); - -#endif /* __CSR_WIFI_HIP_CONVERSIONS_H__ */ - diff --git a/drivers/staging/csr/csr_wifi_hip_download.c b/drivers/staging/csr/csr_wifi_hip_download.c deleted file mode 100644 index 2f44a383d2cf..000000000000 --- a/drivers/staging/csr/csr_wifi_hip_download.c +++ /dev/null @@ -1,819 +0,0 @@ -/***************************************************************************** - - (c) Cambridge Silicon Radio Limited 2012 - All rights reserved and confidential information of CSR - - Refer to LICENSE.txt included with this source for details - on the license terms. - -*****************************************************************************/ - -/* - * --------------------------------------------------------------------------- - * FILE: csr_wifi_hip_download.c - * - * PURPOSE: - * Routines for downloading firmware to UniFi. - * - * --------------------------------------------------------------------------- - */ -#include -#include "csr_wifi_hip_unifi.h" -#include "csr_wifi_hip_unifiversion.h" -#include "csr_wifi_hip_card.h" -#include "csr_wifi_hip_xbv.h" - -#undef CSR_WIFI_IGNORE_PATCH_VERSION_MISMATCH - -static CsrResult do_patch_download(card_t *card, void *dlpriv, - xbv1_t *pfwinfo, u32 boot_ctrl_addr); - -static CsrResult do_patch_convert_download(card_t *card, - void *dlpriv, xbv1_t *pfwinfo); - -/* - * --------------------------------------------------------------------------- - * _find_in_slut - * - * Find the offset of the appropriate object in the SLUT of a card - * - * Arguments: - * card Pointer to card struct - * psym Pointer to symbol object. - * id set up by caller - * obj will be set up by this function - * pslut Pointer to SLUT address, if 0xffffffff then it must be - * read from the chip. - * Returns: - * CSR_RESULT_SUCCESS on success - * Non-zero on error, - * CSR_WIFI_HIP_RESULT_NOT_FOUND if not found - * --------------------------------------------------------------------------- - */ -static CsrResult _find_in_slut(card_t *card, symbol_t *psym, u32 *pslut) -{ - u32 slut_address; - u16 finger_print; - CsrResult r; - CsrResult csrResult; - - /* Get SLUT address */ - if (*pslut == 0xffffffff) - { - r = card_wait_for_firmware_to_start(card, &slut_address); - if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE) - { - return r; - } - if (r != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, "Firmware hasn't started\n"); - return r; - } - *pslut = slut_address; - - /* - * Firmware has started so set the SDIO bus clock to the initial speed, - * faster than UNIFI_SDIO_CLOCK_SAFE_HZ, to speed up the f/w download. - */ - csrResult = CsrSdioMaxBusClockFrequencySet(card->sdio_if, UNIFI_SDIO_CLOCK_INIT_HZ); - if (csrResult != CSR_RESULT_SUCCESS) - { - r = ConvertCsrSdioToCsrHipResult(card, csrResult); - return r; - } - card->sdio_clock_speed = UNIFI_SDIO_CLOCK_INIT_HZ; - } - else - { - slut_address = *pslut; /* Use previously discovered address */ - } - unifi_trace(card->ospriv, UDBG4, "SLUT addr: 0x%lX\n", slut_address); - - /* - * Check the SLUT fingerprint. - * The slut_address is a generic pointer so we must use unifi_card_read16(). - */ - unifi_trace(card->ospriv, UDBG4, "Looking for SLUT finger print\n"); - finger_print = 0; - r = unifi_card_read16(card, slut_address, &finger_print); - if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE) - { - return r; - } - if (r != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, "Failed to read SLUT finger print\n"); - return r; - } - - if (finger_print != SLUT_FINGERPRINT) - { - unifi_error(card->ospriv, "Failed to find SLUT fingerprint\n"); - return CSR_RESULT_FAILURE; - } - - /* Symbol table starts imedately after the fingerprint */ - slut_address += 2; - - while (1) - { - u16 id; - u32 obj; - - r = unifi_card_read16(card, slut_address, &id); - if (r != CSR_RESULT_SUCCESS) - { - return r; - } - slut_address += 2; - - if (id == CSR_SLT_END) - { - /* End of table reached: not found */ - r = CSR_WIFI_HIP_RESULT_RANGE; - break; - } - - r = unifi_read32(card, slut_address, &obj); - if (r != CSR_RESULT_SUCCESS) - { - return r; - } - slut_address += 4; - - unifi_trace(card->ospriv, UDBG3, " found SLUT id %02d.%08lx\n", id, obj); - - r = CSR_WIFI_HIP_RESULT_NOT_FOUND; - /* Found search term? */ - if (id == psym->id) - { - unifi_trace(card->ospriv, UDBG1, " matched SLUT id %02d.%08lx\n", id, obj); - psym->obj = obj; - r = CSR_RESULT_SUCCESS; - break; - } - } - - return r; -} - - -/* - * --------------------------------------------------------------------------- - * do_patch_convert_download - * - * Download the given firmware image to the UniFi, converting from FWDL - * to PTDL XBV format. - * - * Arguments: - * card Pointer to card struct - * dlpriv Pointer to source firmware image - * fwinfo Pointer to source firmware info struct - * - * Returns: - * CSR_RESULT_SUCCESS on success, CSR error code on error - * - * Notes: - * --------------------------------------------------------------------------- - */ -static CsrResult do_patch_convert_download(card_t *card, void *dlpriv, xbv1_t *pfwinfo) -{ - CsrResult r; - u32 slut_base = 0xffffffff; - void *pfw; - u32 psize; - symbol_t sym; - - /* Reset the chip to guarantee that the ROM loader is running */ - r = unifi_init(card); - if (r != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, - "do_patch_convert_download: failed to re-init UniFi\n"); - return r; - } - - /* If no unifi_helper is running, the firmware version must be read */ - if (card->build_id == 0) - { - u32 ver = 0; - sym.id = CSR_SLT_BUILD_ID_NUMBER; - sym.obj = 0; /* To be updated by _find_in_slut() */ - - unifi_trace(card->ospriv, UDBG1, "Need f/w version\n"); - - /* Find chip build id entry in SLUT */ - r = _find_in_slut(card, &sym, &slut_base); - if (r != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, "Failed to find CSR_SLT_BUILD_ID_NUMBER\n"); - return CSR_RESULT_FAILURE; - } - - /* Read running f/w version */ - r = unifi_read32(card, sym.obj, &ver); - if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE) - { - return r; - } - if (r != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, "Failed to read f/w id\n"); - return CSR_RESULT_FAILURE; - } - card->build_id = ver; - } - - /* Convert the ptest firmware to a patch against the running firmware */ - pfw = xbv_to_patch(card, unifi_fw_read, dlpriv, pfwinfo, &psize); - if (!pfw) - { - unifi_error(card->ospriv, "Failed to convert f/w to patch"); - return CSR_WIFI_HIP_RESULT_NO_MEMORY; - } - else - { - void *desc; - sym.id = CSR_SLT_BOOT_LOADER_CONTROL; - sym.obj = 0; /* To be updated by _find_in_slut() */ - - /* Find boot loader control entry in SLUT */ - r = _find_in_slut(card, &sym, &slut_base); - if (r != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, "Failed to find BOOT_LOADER_CONTROL\n"); - kfree(pfw); - return CSR_RESULT_FAILURE; - } - - r = unifi_set_host_state(card, UNIFI_HOST_STATE_AWAKE); - if (r != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, "Failed to wake UniFi\n"); - } - - /* Get a dlpriv for the patch buffer so that unifi_fw_read() can - * access it. - */ - desc = unifi_fw_open_buffer(card->ospriv, pfw, psize); - if (!desc) - { - kfree(pfw); - return CSR_WIFI_HIP_RESULT_NO_MEMORY; - } - - /* Download the patch */ - unifi_info(card->ospriv, "Downloading converted f/w as patch\n"); - r = unifi_dl_patch(card, desc, sym.obj); - kfree(pfw); - unifi_fw_close_buffer(card->ospriv, desc); - - if (r != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, "Converted patch download failed\n"); - return r; - } - else - { - unifi_trace(card->ospriv, UDBG1, "Converted patch downloaded\n"); - } - - /* This command starts the firmware */ - r = unifi_do_loader_op(card, sym.obj + 6, UNIFI_BOOT_LOADER_RESTART); - if (r != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, "Failed to write loader restart cmd\n"); - } - - return r; - } -} - - -/* - * --------------------------------------------------------------------------- - * unifi_dl_firmware - * - * Download the given firmware image to the UniFi. - * - * Arguments: - * card Pointer to card struct - * dlpriv A context pointer from the calling function to be - * passed when calling unifi_fw_read(). - * - * Returns: - * CSR_RESULT_SUCCESS on success, - * CSR_WIFI_HIP_RESULT_NO_MEMORY memory allocation failed - * CSR_WIFI_HIP_RESULT_INVALID_VALUE error in XBV file - * CSR_RESULT_FAILURE SDIO error - * - * Notes: - * Stops and resets the chip, does the download and runs the new - * firmware. - * --------------------------------------------------------------------------- - */ -CsrResult unifi_dl_firmware(card_t *card, void *dlpriv) -{ - xbv1_t *fwinfo; - CsrResult r; - - fwinfo = kmalloc(sizeof(xbv1_t), GFP_KERNEL); - if (fwinfo == NULL) - { - unifi_error(card->ospriv, "Failed to allocate memory for firmware\n"); - return CSR_WIFI_HIP_RESULT_NO_MEMORY; - } - - /* - * Scan the firmware file to find the TLVs we are interested in. - * These are: - * - check we support the file format version in VERF - * - SLTP Symbol Lookup Table Pointer - * - FWDL firmware download segments - * - FWOV firmware overlay segment - * - VMEQ Register probe tests to verify matching h/w - */ - r = xbv1_parse(card, unifi_fw_read, dlpriv, fwinfo); - if (r != CSR_RESULT_SUCCESS || fwinfo->mode != xbv_firmware) - { - unifi_error(card->ospriv, "File type is %s, expected firmware.\n", - fwinfo->mode == xbv_patch?"patch" : "unknown"); - kfree(fwinfo); - return CSR_WIFI_HIP_RESULT_INVALID_VALUE; - } - - /* UF6xxx doesn't accept firmware, only patches. Therefore we convert - * the file to patch format with version numbers matching the current - * running firmware, and then download via the patch mechanism. - * The sole purpose of this is to support production test firmware across - * different ROM releases, the test firmware being provided in non-patch - * format. - */ - if (card->chip_id > SDIO_CARD_ID_UNIFI_2) - { - unifi_info(card->ospriv, "Must convert f/w to patch format\n"); - r = do_patch_convert_download(card, dlpriv, fwinfo); - } - else - { - /* Older UniFi chips allowed firmware to be directly loaded onto the - * chip, which is no longer supported. - */ - unifi_error(card->ospriv, "Only patch downloading supported\n"); - r = CSR_WIFI_HIP_RESULT_INVALID_VALUE; - } - - kfree(fwinfo); - return r; -} /* unifi_dl_firmware() */ - - -/* - * --------------------------------------------------------------------------- - * unifi_dl_patch - * - * Load the given patch set into UniFi. - * - * Arguments: - * card Pointer to card struct - * dlpriv The os specific handle to the firmware file. - * boot_ctrl The address of the boot loader control structure. - * - * Returns: - * CSR_RESULT_SUCCESS on success, - * CSR_WIFI_HIP_RESULT_NO_MEMORY memory allocation failed - * CSR_WIFI_HIP_RESULT_INVALID_VALUE error in XBV file - * CSR_RESULT_FAILURE SDIO error - * - * Notes: - * This ends up telling UniFi to restart. - * --------------------------------------------------------------------------- - */ -CsrResult unifi_dl_patch(card_t *card, void *dlpriv, u32 boot_ctrl) -{ - xbv1_t *fwinfo; - CsrResult r; - - unifi_info(card->ospriv, "unifi_dl_patch %p %08x\n", dlpriv, boot_ctrl); - - fwinfo = kmalloc(sizeof(xbv1_t), GFP_KERNEL); - if (fwinfo == NULL) - { - unifi_error(card->ospriv, "Failed to allocate memory for patches\n"); - return CSR_WIFI_HIP_RESULT_NO_MEMORY; - } - - /* - * Scan the firmware file to find the TLVs we are interested in. - * These are: - * - check we support the file format version in VERF - * - FWID The build ID of the ROM that we can patch - * - PTDL patch download segments - */ - r = xbv1_parse(card, unifi_fw_read, dlpriv, fwinfo); - if (r != CSR_RESULT_SUCCESS || fwinfo->mode != xbv_patch) - { - kfree(fwinfo); - unifi_error(card->ospriv, "Failed to read in patch file\n"); - return CSR_WIFI_HIP_RESULT_INVALID_VALUE; - } - - /* - * We have to check the build id read from the SLUT against that - * for the patch file. They have to match exactly. - * "card->build_id" == XBV1.PTCH.FWID - */ - if (card->build_id != fwinfo->build_id) - { - unifi_error(card->ospriv, "Wrong patch file for chip (chip = %lu, file = %lu)\n", - card->build_id, fwinfo->build_id); - kfree(fwinfo); -#ifndef CSR_WIFI_IGNORE_PATCH_VERSION_MISMATCH - return CSR_WIFI_HIP_RESULT_INVALID_VALUE; -#else - fwinfo = NULL; - dlpriv = NULL; - return CSR_RESULT_SUCCESS; -#endif - } - - r = do_patch_download(card, dlpriv, fwinfo, boot_ctrl); - if (r != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, "Failed to patch image\n"); - } - - kfree(fwinfo); - - return r; -} /* unifi_dl_patch() */ - - -void* unifi_dl_fw_read_start(card_t *card, s8 is_fw) -{ - card_info_t card_info; - - unifi_card_info(card, &card_info); - unifi_trace(card->ospriv, UDBG5, - "id=%d, ver=0x%x, fw_build=%u, fw_hip=0x%x, block_size=%d\n", - card_info.chip_id, card_info.chip_version, - card_info.fw_build, card_info.fw_hip_version, - card_info.sdio_block_size); - - return unifi_fw_read_start(card->ospriv, is_fw, &card_info); -} - - -/* - * --------------------------------------------------------------------------- - * safe_read_shared_location - * - * Read a shared memory location repeatedly until we get two readings - * the same. - * - * Arguments: - * card Pointer to card context struct. - * unifi_addr UniFi shared-data-memory address to access. - * pdata Pointer to a byte variable for the value read. - * - * - * Returns: - * CSR_RESULT_SUCCESS on success, CSR error code on failure - * --------------------------------------------------------------------------- - */ -static CsrResult safe_read_shared_location(card_t *card, u32 address, u8 *pdata) -{ - CsrResult r; - u16 limit = 1000; - u8 b, b2; - - *pdata = 0; - - r = unifi_read_8_or_16(card, address, &b); - if (r != CSR_RESULT_SUCCESS) - { - return r; - } - - while (limit--) - { - r = unifi_read_8_or_16(card, address, &b2); - if (r != CSR_RESULT_SUCCESS) - { - return r; - } - - /* When we have a stable value, return it */ - if (b == b2) - { - *pdata = b; - return CSR_RESULT_SUCCESS; - } - - b = b2; - } - - return CSR_RESULT_FAILURE; -} /* safe_read_shared_location() */ - - -/* - * --------------------------------------------------------------------------- - * unifi_do_loader_op - * - * Send a loader / boot_loader command to the UniFi and wait for - * it to complete. - * - * Arguments: - * card Pointer to card context struct. - * op_addr The address of the loader operation control word. - * opcode The operation to perform. - * - * Returns: - * CSR_RESULT_SUCCESS on success - * CSR_RESULT_FAILURE SDIO error or SDIO/XAP timeout - * --------------------------------------------------------------------------- - */ - -/* - * Ideally instead of sleeping, we want to busy wait. - * Currently there is no framework API to do this. When it becomes available, - * we can use it to busy wait using usecs - */ -#define OPERATION_TIMEOUT_LOOPS (100) /* when OPERATION_TIMEOUT_DELAY==1, (500) otherwise */ -#define OPERATION_TIMEOUT_DELAY 1 /* msec, or 200usecs */ - -CsrResult unifi_do_loader_op(card_t *card, u32 op_addr, u8 opcode) -{ - CsrResult r; - s16 op_retries; - - unifi_trace(card->ospriv, UDBG4, "Loader cmd 0x%0x -> 0x%08x\n", opcode, op_addr); - - /* Set the Operation command byte to the opcode */ - r = unifi_write_8_or_16(card, op_addr, opcode); - if (r != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, "Failed to write loader copy command\n"); - return r; - } - - /* Wait for Operation command byte to be Idle */ - /* Typically takes ~100us */ - op_retries = 0; - r = CSR_RESULT_SUCCESS; - while (1) - { - u8 op; - - /* - * Read the memory location until two successive reads give - * the same value. - * Then handle it. - */ - r = safe_read_shared_location(card, op_addr, &op); - if (r != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, "Failed to read loader status\n"); - break; - } - - if (op == UNIFI_LOADER_IDLE) - { - /* Success */ - break; - } - - if (op != opcode) - { - unifi_error(card->ospriv, "Error reported by loader: 0x%X\n", op); - r = CSR_RESULT_FAILURE; - break; - } - - /* Allow 500us timeout */ - if (++op_retries >= OPERATION_TIMEOUT_LOOPS) - { - unifi_error(card->ospriv, "Timeout waiting for loader to ack transfer\n"); - /* Stop XAPs to aid post-mortem */ - r = unifi_card_stop_processor(card, UNIFI_PROC_BOTH); - if (r != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, "Failed to stop UniFi processors\n"); - } - else - { - r = CSR_RESULT_FAILURE; - } - break; - } - CsrThreadSleep(OPERATION_TIMEOUT_DELAY); - } /* Loop exits with r != CSR_RESULT_SUCCESS on error */ - - return r; -} /* unifi_do_loader_op() */ - - -/* - * --------------------------------------------------------------------------- - * send_ptdl_to_unifi - * - * Copy a patch block from userland to the UniFi. - * This function reads data, 2K at a time, from userland and writes - * it to the UniFi. - * - * Arguments: - * card A pointer to the card structure - * dlpriv The os specific handle for the firmware file - * ptdl A pointer ot the PTDL block - * handle The buffer handle to use for the xfer - * op_addr The address of the loader operation control word - * - * Returns: - * Number of bytes sent (Positive) or negative value indicating - * error code: - * CSR_WIFI_HIP_RESULT_NO_MEMORY memory allocation failed - * CSR_WIFI_HIP_RESULT_INVALID_VALUE error in XBV file - * CSR_RESULT_FAILURE SDIO error - * --------------------------------------------------------------------------- - */ -static CsrResult send_ptdl_to_unifi(card_t *card, void *dlpriv, - const struct PTDL *ptdl, u32 handle, - u32 op_addr) -{ - u32 offset; - u8 *buf; - s32 data_len; - u32 write_len; - CsrResult r; - const u16 buf_size = 2 * 1024; - - offset = ptdl->dl_offset; - data_len = ptdl->dl_size; - - if (data_len > buf_size) - { - unifi_error(card->ospriv, "PTDL block is too large (%u)\n", - ptdl->dl_size); - return CSR_WIFI_HIP_RESULT_INVALID_VALUE; - } - - buf = kmalloc(buf_size, GFP_KERNEL); - if (buf == NULL) - { - unifi_error(card->ospriv, "Failed to allocate transfer buffer for firmware download\n"); - return CSR_WIFI_HIP_RESULT_NO_MEMORY; - } - - r = CSR_RESULT_SUCCESS; - - if (unifi_fw_read(card->ospriv, dlpriv, offset, buf, data_len) != data_len) - { - unifi_error(card->ospriv, "Failed to read from file\n"); - } - else - { - /* We can always round these if the host wants to */ - if (card->sdio_io_block_pad) - { - write_len = (data_len + (card->sdio_io_block_size - 1)) & - ~(card->sdio_io_block_size - 1); - - /* Zero out the rest of the buffer (This isn't needed, but it - * makes debugging things later much easier). */ - memset(buf + data_len, 0, write_len - data_len); - } - else - { - write_len = data_len; - } - - r = unifi_bulk_rw_noretry(card, handle, buf, write_len, UNIFI_SDIO_WRITE); - if (r != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, "CMD53 failed writing %d bytes to handle %ld\n", - data_len, handle); - } - else - { - /* - * Can change the order of things to overlap read from file - * with copy to unifi - */ - r = unifi_do_loader_op(card, op_addr, UNIFI_BOOT_LOADER_PATCH); - } - } - - kfree(buf); - - if (r != CSR_RESULT_SUCCESS && r != CSR_WIFI_HIP_RESULT_NO_DEVICE) - { - unifi_error(card->ospriv, "Failed to copy block of %u bytes to UniFi\n", - ptdl->dl_size); - } - - return r; -} /* send_ptdl_to_unifi() */ - - -/* - * --------------------------------------------------------------------------- - * do_patch_download - * - * This function downloads a set of patches to UniFi and then - * causes it to restart. - * - * Arguments: - * card Pointer to card struct. - * dlpriv A context pointer from the calling function to be - * used when reading the XBV file. This can be NULL - * in which case not patches are applied. - * pfwinfo Pointer to a fwinfo struct describing the f/w - * XBV file. - * boot_ctrl_addr The address of the boot loader control structure. - * - * Returns: - * 0 on success, or an error code - * CSR_WIFI_HIP_RESULT_INVALID_VALUE for a bad laoader version number - * --------------------------------------------------------------------------- - */ -static CsrResult do_patch_download(card_t *card, void *dlpriv, xbv1_t *pfwinfo, u32 boot_ctrl_addr) -{ - CsrResult r; - s32 i; - u16 loader_version; - u16 handle; - u32 total_bytes; - - /* - * Read info from the SDIO Loader Control Data Structure - */ - /* Check the loader version */ - r = unifi_card_read16(card, boot_ctrl_addr, &loader_version); - if (r != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, "Patch download: Failed to read loader version\n"); - return r; - } - unifi_trace(card->ospriv, UDBG2, "Patch download: boot loader version 0x%04X\n", loader_version); - switch (loader_version) - { - case 0x0000: - break; - - default: - unifi_error(card->ospriv, "Patch loader version (0x%04X) is not supported by this driver\n", - loader_version); - return CSR_WIFI_HIP_RESULT_INVALID_VALUE; - } - - /* Retrieve the handle to use with CMD53 */ - r = unifi_card_read16(card, boot_ctrl_addr + 4, &handle); - if (r != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, "Patch download: Failed to read loader handle\n"); - return r; - } - - /* Set the mask of LEDs to flash */ - if (card->loader_led_mask) - { - r = unifi_card_write16(card, boot_ctrl_addr + 2, - (u16)card->loader_led_mask); - if (r != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, "Patch download: Failed to write LED mask\n"); - return r; - } - } - - total_bytes = 0; - - /* Copy download data to UniFi memory */ - for (i = 0; i < pfwinfo->num_ptdl; i++) - { - unifi_trace(card->ospriv, UDBG3, "Patch download: %d Downloading for %d from offset %d\n", - i, - pfwinfo->ptdl[i].dl_size, - pfwinfo->ptdl[i].dl_offset); - - r = send_ptdl_to_unifi(card, dlpriv, &pfwinfo->ptdl[i], - handle, boot_ctrl_addr + 6); - if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE) - { - return r; - } - if (r != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, "Patch failed after %u bytes\n", - total_bytes); - return r; - } - total_bytes += pfwinfo->ptdl[i].dl_size; - } - - return CSR_RESULT_SUCCESS; -} /* do_patch_download() */ - - diff --git a/drivers/staging/csr/csr_wifi_hip_dump.c b/drivers/staging/csr/csr_wifi_hip_dump.c deleted file mode 100644 index 7b7eec49d028..000000000000 --- a/drivers/staging/csr/csr_wifi_hip_dump.c +++ /dev/null @@ -1,837 +0,0 @@ -/***************************************************************************** - - (c) Cambridge Silicon Radio Limited 2012 - All rights reserved and confidential information of CSR - - Refer to LICENSE.txt included with this source for details - on the license terms. - -*****************************************************************************/ - -/* - * --------------------------------------------------------------------------- - * FILE: csr_wifi_hip_dump.c - * - * PURPOSE: - * Routines for retrieving and buffering core status from the UniFi - * - * --------------------------------------------------------------------------- - */ -#include -#include "csr_wifi_hip_unifi.h" -#include "csr_wifi_hip_unifiversion.h" -#include "csr_wifi_hip_card.h" - -/* Locations to capture in dump (XAP words) */ -#define HIP_CDUMP_FIRST_CPUREG (0xFFE0) /* First CPU register */ -#define HIP_CDUMP_FIRST_LO (0) /* Start of low address range */ -#define HIP_CDUMP_FIRST_HI_MAC (0x3C00) /* Start of MAC high area */ -#define HIP_CDUMP_FIRST_HI_PHY (0x1C00) /* Start of PHY high area */ -#define HIP_CDUMP_FIRST_SH (0) /* Start of shared memory area */ - -#define HIP_CDUMP_NCPUREGS (10) /* No. of 16-bit XAP registers */ -#define HIP_CDUMP_NWORDS_LO (0x0100) /* Low area size in 16-bit words */ -#define HIP_CDUMP_NWORDS_HI (0x0400) /* High area size in 16-bit words */ -#define HIP_CDUMP_NWORDS_SH (0x0500) /* Shared memory area size, 16-bit words */ - -#define HIP_CDUMP_NUM_ZONES 7 /* Number of UniFi memory areas to capture */ - -/* Mini-coredump state */ -typedef struct coredump_buf -{ - u16 count; /* serial number of dump */ - u32 timestamp; /* host's system time at capture */ - s16 requestor; /* request: 0=auto dump, 1=manual */ - u16 chip_ver; - u32 fw_ver; - u16 *zone[HIP_CDUMP_NUM_ZONES]; - - struct coredump_buf *next; /* circular list */ - struct coredump_buf *prev; /* circular list */ -} coredump_buffer; - -/* Structure used to describe a zone of chip memory captured by mini-coredump */ -struct coredump_zone -{ - unifi_coredump_space_t space; /* XAP memory space this zone covers */ - enum unifi_dbg_processors_select cpu; /* XAP CPU core selector */ - u32 gp; /* Generic Pointer to memory zone on XAP */ - u16 offset; /* 16-bit XAP word offset of zone in memory space */ - u16 length; /* Length of zone in XAP words */ -}; - -static CsrResult unifi_coredump_from_sdio(card_t *card, coredump_buffer *dump_buf); -static CsrResult unifi_coredump_read_zones(card_t *card, coredump_buffer *dump_buf); -static CsrResult unifi_coredump_read_zone(card_t *card, u16 *zone, - const struct coredump_zone *def); -static s32 get_value_from_coredump(const coredump_buffer *dump, - const unifi_coredump_space_t space, const u16 offset); - -/* Table of chip memory zones we capture on mini-coredump */ -static const struct coredump_zone zonedef_table[HIP_CDUMP_NUM_ZONES] = { - { UNIFI_COREDUMP_MAC_REG, UNIFI_PROC_MAC, UNIFI_MAKE_GP(REGISTERS, HIP_CDUMP_FIRST_CPUREG * 2), HIP_CDUMP_FIRST_CPUREG, HIP_CDUMP_NCPUREGS }, - { UNIFI_COREDUMP_PHY_REG, UNIFI_PROC_PHY, UNIFI_MAKE_GP(REGISTERS, HIP_CDUMP_FIRST_CPUREG * 2), HIP_CDUMP_FIRST_CPUREG, HIP_CDUMP_NCPUREGS }, - { UNIFI_COREDUMP_SH_DMEM, UNIFI_PROC_INVALID, UNIFI_MAKE_GP(SH_DMEM, HIP_CDUMP_FIRST_SH * 2), HIP_CDUMP_FIRST_SH, HIP_CDUMP_NWORDS_SH }, - { UNIFI_COREDUMP_MAC_DMEM, UNIFI_PROC_MAC, UNIFI_MAKE_GP(MAC_DMEM, HIP_CDUMP_FIRST_LO * 2), HIP_CDUMP_FIRST_LO, HIP_CDUMP_NWORDS_LO }, - { UNIFI_COREDUMP_MAC_DMEM, UNIFI_PROC_MAC, UNIFI_MAKE_GP(MAC_DMEM, HIP_CDUMP_FIRST_HI_MAC * 2), HIP_CDUMP_FIRST_HI_MAC, HIP_CDUMP_NWORDS_HI }, - { UNIFI_COREDUMP_PHY_DMEM, UNIFI_PROC_PHY, UNIFI_MAKE_GP(PHY_DMEM, HIP_CDUMP_FIRST_LO * 2), HIP_CDUMP_FIRST_LO, HIP_CDUMP_NWORDS_LO }, - { UNIFI_COREDUMP_PHY_DMEM, UNIFI_PROC_PHY, UNIFI_MAKE_GP(PHY_DMEM, HIP_CDUMP_FIRST_HI_PHY * 2), HIP_CDUMP_FIRST_HI_PHY, HIP_CDUMP_NWORDS_HI }, -}; - -/* - * --------------------------------------------------------------------------- - * unifi_coredump_request_at_next_reset - * - * Request that a mini-coredump is performed when the driver has - * completed resetting the UniFi device. - * - * Arguments: - * card Pointer to card struct - * enable If non-zero, sets the request. - * If zero, cancels any pending request. - * - * Returns: - * CSR_RESULT_SUCCESS or CSR HIP error code - * - * Notes: - * This function is typically called once the driver has detected that - * the UniFi device has become unresponsive due to crash, or internal - * watchdog reset. The driver must reset it to regain communication and, - * immediately after that, the mini-coredump can be captured. - * --------------------------------------------------------------------------- - */ -CsrResult unifi_coredump_request_at_next_reset(card_t *card, s8 enable) -{ - CsrResult r; - - if (enable) - { - unifi_trace(card->ospriv, UDBG2, "Mini-coredump requested after reset\n"); - } - - if (card == NULL) - { - r = CSR_WIFI_HIP_RESULT_INVALID_VALUE; - } - else - { - card->request_coredump_on_reset = enable?1 : 0; - r = CSR_RESULT_SUCCESS; - } - - return r; -} - - -/* - * --------------------------------------------------------------------------- - * unifi_coredump_handle_request - * - * Performs a coredump now, if one was requested, and clears the request. - * - * Arguments: - * card Pointer to card struct - * - * Returns: - * CSR_RESULT_SUCCESS or CSR HIP error code - * - * Notes: - * --------------------------------------------------------------------------- - */ -CsrResult unifi_coredump_handle_request(card_t *card) -{ - CsrResult r = CSR_RESULT_SUCCESS; - - if (card == NULL) - { - r = CSR_WIFI_HIP_RESULT_INVALID_VALUE; - } - else - { - if (card->request_coredump_on_reset == 1) - { - card->request_coredump_on_reset = 0; - r = unifi_coredump_capture(card, NULL); - } - } - - return r; -} - - -/* - * --------------------------------------------------------------------------- - * unifi_coredump_capture - * - * Capture the current status of the UniFi device. - * Various registers are buffered for future offline inspection. - * - * Arguments: - * card Pointer to card struct - * req Pointer to request struct, or NULL: - * A coredump requested manually by the user app - * will have a request struct pointer, an automatic - * coredump will have a NULL pointer. - * Returns: - * CSR_RESULT_SUCCESS on success, - * CSR_RESULT_FAILURE SDIO error - * CSR_WIFI_HIP_RESULT_INVALID_VALUE Initialisation not complete - * - * Notes: - * The result is a filled entry in the circular buffer of core dumps, - * values from which can be extracted to userland via an ioctl. - * --------------------------------------------------------------------------- - */ -CsrResult unifi_coredump_capture(card_t *card, struct unifi_coredump_req *req) -{ - CsrResult r = CSR_RESULT_SUCCESS; - static u16 dump_seq_no = 1; - u32 time_of_capture; - - if (card->dump_next_write == NULL) - { - r = CSR_RESULT_SUCCESS; - goto done; - } - - /* Reject forced capture before initialisation has happened */ - if (card->helper == NULL) - { - r = CSR_WIFI_HIP_RESULT_INVALID_VALUE; - goto done; - } - - - /* - * Force a mini-coredump capture right now - */ - time_of_capture = CsrTimeGet(NULL); - unifi_info(card->ospriv, "Mini-coredump capture at t=%u\n", time_of_capture); - - /* Wake up the processors so we can talk to them */ - r = unifi_set_host_state(card, UNIFI_HOST_STATE_AWAKE); - if (r != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, "Failed to wake UniFi\n"); - goto done; - } - CsrThreadSleep(20); - - /* Stop both XAPs */ - unifi_trace(card->ospriv, UDBG4, "Stopping XAPs for coredump capture\n"); - r = unifi_card_stop_processor(card, UNIFI_PROC_BOTH); - if (r != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, "Failed to stop UniFi XAPs\n"); - goto done; - } - - /* Dump core into the next available slot in the circular list */ - r = unifi_coredump_from_sdio(card, card->dump_next_write); - if (r == CSR_RESULT_SUCCESS) - { - /* Record whether the dump was manual or automatic */ - card->dump_next_write->requestor = (req?1 : 0); - card->dump_next_write->timestamp = time_of_capture; - /* Advance to the next buffer */ - card->dump_next_write->count = dump_seq_no++; - card->dump_cur_read = card->dump_next_write; - card->dump_next_write = card->dump_next_write->next; - - /* Sequence no. of zero indicates slot not in use, so handle wrap */ - if (dump_seq_no == 0) - { - dump_seq_no = 1; - } - - unifi_trace(card->ospriv, UDBG3, - "Coredump (%p), SeqNo=%d, cur_read=%p, next_write=%p\n", - req, - card->dump_cur_read->count, - card->dump_cur_read, card->dump_next_write); - } - - /* Start both XAPs */ - unifi_trace(card->ospriv, UDBG4, "Restart XAPs after coredump\n"); - r = card_start_processor(card, UNIFI_PROC_BOTH); - if (r != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, "Failed to start UniFi XAPs\n"); - goto done; - } - -done: - return r; -} /* unifi_coredump_capture() */ - - -/* - * --------------------------------------------------------------------------- - * get_value_from_coredump - * - * - * - * Arguments: - * dump Pointer to buffered coredump data - * offset_in_space XAP memory space to retrieve from the buffer (there - * may be more than one zone covering the same memory - * space, but starting from different offsets). - * offset Offset within the XAP memory space to be retrieved - * - * Returns: - * >=0 Register value on success - * <0 Register out of range of any captured zones - * - * Notes: - * --------------------------------------------------------------------------- - */ -static s32 get_value_from_coredump(const coredump_buffer *coreDump, - const unifi_coredump_space_t space, - const u16 offset_in_space) -{ - s32 r = -1; - u16 offset_in_zone; - u32 zone_end_offset; - s32 i; - const struct coredump_zone *def = &zonedef_table[0]; - - /* Search zone def table for a match with the requested memory space */ - for (i = 0; i < HIP_CDUMP_NUM_ZONES; i++, def++) - { - if (space == def->space) - { - zone_end_offset = def->offset + def->length; - - /* Is the space offset contained in this zone? */ - if (offset_in_space < zone_end_offset && - offset_in_space >= def->offset) - { - /* Calculate the offset of data within the zone buffer */ - offset_in_zone = offset_in_space - def->offset; - r = (s32) * (coreDump->zone[i] + offset_in_zone); - - unifi_trace(NULL, UDBG6, - "sp %d, offs 0x%04x = 0x%04x (in z%d 0x%04x->0x%04x)\n", - space, offset_in_space, r, - i, def->offset, zone_end_offset - 1); - break; - } - } - } - return r; -} - - -/* - * --------------------------------------------------------------------------- - * unifi_coredump_get_value - * - * Retrieve the value of a register buffered from a previous core dump, - * so that it may be reported back to application code. - * - * Arguments: - * card Pointer to card struct - * req_reg Pointer to request parameter partially filled. This - * function puts in the values retrieved from the dump. - * - * Returns: - * CSR_RESULT_SUCCESS on success, or: - * CSR_WIFI_HIP_RESULT_INVALID_VALUE Null parameter error - * CSR_WIFI_HIP_RESULT_RANGE Register out of range - * CSR_WIFI_HIP_RESULT_NOT_FOUND Dump index not (yet) captured - * - * Notes: - * --------------------------------------------------------------------------- - */ -CsrResult unifi_coredump_get_value(card_t *card, struct unifi_coredump_req *req) -{ - CsrResult r; - s32 i = 0; - coredump_buffer *find_dump = NULL; - - if (req == NULL || card == NULL) - { - r = CSR_WIFI_HIP_RESULT_INVALID_VALUE; - goto done; - } - req->value = -1; - if (card->dump_buf == NULL) - { - unifi_trace(card->ospriv, UDBG2, "No coredump buffers\n"); - r = CSR_WIFI_HIP_RESULT_NOT_FOUND; /* Coredumping disabled */ - goto done; - } - if (card->dump_cur_read == NULL) - { - unifi_trace(card->ospriv, UDBG4, "No coredumps captured\n"); - r = CSR_WIFI_HIP_RESULT_NOT_FOUND; /* No coredump yet captured */ - goto done; - } - - /* Find the requested dump buffer */ - switch (req->index) - { - case 0: /* Newest */ - find_dump = card->dump_cur_read; - break; - case -1: /* Oldest: The next used slot forward */ - for (find_dump = card->dump_cur_read->next; - (find_dump->count == 0) && (find_dump != card->dump_cur_read); - find_dump = card->dump_cur_read->next) - { - } - break; - default: /* Number of steps back from current read position */ - for (i = 0, find_dump = card->dump_cur_read; - i < req->index; - i++, find_dump = find_dump->prev) - { - /* Walk the list for the index'th entry, but - * stop when about to wrap. */ - unifi_trace(card->ospriv, UDBG6, - "%d: %d, @%p, p=%p, n=%p, cr=%p, h=%p\n", - i, find_dump->count, find_dump, find_dump->prev, - find_dump->next, card->dump_cur_read, card->dump_buf); - if (find_dump->prev == card->dump_cur_read) - { - /* Wrapped but still not found, index out of range */ - if (i != req->index) - { - unifi_trace(card->ospriv, UDBG6, - "Dump index %d not found %d\n", req->index, i); - r = CSR_WIFI_HIP_RESULT_NOT_FOUND; - goto done; - } - break; - } - } - break; - } - - /* Check if the slot is actually filled with a core dump */ - if (find_dump->count == 0) - { - unifi_trace(card->ospriv, UDBG4, "Not captured %d\n", req->index); - r = CSR_WIFI_HIP_RESULT_NOT_FOUND; - goto done; - } - - unifi_trace(card->ospriv, UDBG6, "Req index %d, found seq %d at step %d\n", - req->index, find_dump->count, i); - - /* Find the appropriate entry in the buffer */ - req->value = get_value_from_coredump(find_dump, req->space, (u16)req->offset); - if (req->value < 0) - { - r = CSR_WIFI_HIP_RESULT_RANGE; /* Un-captured register */ - unifi_trace(card->ospriv, UDBG4, - "Can't read space %d, reg 0x%x from coredump buffer %d\n", - req->space, req->offset, req->index); - } - else - { - r = CSR_RESULT_SUCCESS; - } - - /* Update the private request structure with the found values */ - req->chip_ver = find_dump->chip_ver; - req->fw_ver = find_dump->fw_ver; - req->timestamp = find_dump->timestamp; - req->requestor = find_dump->requestor; - req->serial = find_dump->count; - -done: - return r; -} /* unifi_coredump_get_value() */ - - -/* - * --------------------------------------------------------------------------- - * unifi_coredump_read_zone - * - * Captures a UniFi memory zone into a buffer on the host - * - * Arguments: - * card Pointer to card struct - * zonebuf Pointer to on-host buffer to dump the memory zone into - * def Pointer to description of the memory zone to read from UniFi. - * - * Returns: - * CSR_RESULT_SUCCESS on success, or: - * CSR_RESULT_FAILURE SDIO error - * CSR_WIFI_HIP_RESULT_INVALID_VALUE Parameter error - * - * Notes: - * It is assumed that the caller has already stopped the XAPs - * --------------------------------------------------------------------------- - */ -static CsrResult unifi_coredump_read_zone(card_t *card, u16 *zonebuf, const struct coredump_zone *def) -{ - CsrResult r; - - if (zonebuf == NULL || def == NULL) - { - r = CSR_WIFI_HIP_RESULT_INVALID_VALUE; - goto done; - } - - /* Select XAP CPU if necessary */ - if (def->cpu != UNIFI_PROC_INVALID) - { - if (def->cpu != UNIFI_PROC_MAC && def->cpu != UNIFI_PROC_PHY) - { - r = CSR_WIFI_HIP_RESULT_INVALID_VALUE; - goto done; - } - r = unifi_set_proc_select(card, def->cpu); - if (r != CSR_RESULT_SUCCESS) - { - goto done; - } - } - - unifi_trace(card->ospriv, UDBG4, - "Dump sp %d, offs 0x%04x, 0x%04x words @GP=%08x CPU %d\n", - def->space, def->offset, def->length, def->gp, def->cpu); - - /* Read on-chip RAM (byte-wise) */ - r = unifi_card_readn(card, def->gp, zonebuf, (u16)(def->length * 2)); - if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE) - { - goto done; - } - if (r != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, "Can't read UniFi shared data area\n"); - goto done; - } - -done: - return r; -} - - -/* - * --------------------------------------------------------------------------- - * unifi_coredump_read_zones - * - * Walks through the table of on-chip memory zones defined in zonedef_table, - * and reads each of them from the UniFi chip - * - * Arguments: - * card Pointer to card struct - * dump_buf Buffer into which register values will be dumped - * - * Returns: - * CSR_RESULT_SUCCESS on success, or: - * CSR_RESULT_FAILURE SDIO error - * CSR_WIFI_HIP_RESULT_INVALID_VALUE Parameter error - * - * Notes: - * It is assumed that the caller has already stopped the XAPs - * --------------------------------------------------------------------------- - */ -static CsrResult unifi_coredump_read_zones(card_t *card, coredump_buffer *dump_buf) -{ - CsrResult r = CSR_RESULT_SUCCESS; - s32 i; - - /* Walk the table of coredump zone definitions and read them from the chip */ - for (i = 0; - (i < HIP_CDUMP_NUM_ZONES) && (r == 0); - i++) - { - r = unifi_coredump_read_zone(card, dump_buf->zone[i], &zonedef_table[i]); - } - - return r; -} - - -/* - * --------------------------------------------------------------------------- - * unifi_coredump_from_sdio - * - * Capture the status of the UniFi processors, over SDIO - * - * Arguments: - * card Pointer to card struct - * reg_buffer Buffer into which register values will be dumped - * - * Returns: - * CSR_RESULT_SUCCESS on success, or: - * CSR_RESULT_FAILURE SDIO error - * CSR_WIFI_HIP_RESULT_INVALID_VALUE Parameter error - * - * Notes: - * --------------------------------------------------------------------------- - */ -static CsrResult unifi_coredump_from_sdio(card_t *card, coredump_buffer *dump_buf) -{ - u16 val; - CsrResult r; - u32 sdio_addr; - - if (dump_buf == NULL) - { - r = CSR_WIFI_HIP_RESULT_INVALID_VALUE; - goto done; - } - - - /* Chip and firmware version */ - unifi_trace(card->ospriv, UDBG4, "Get chip version\n"); - sdio_addr = 2 * ChipHelper_GBL_CHIP_VERSION(card->helper); - if (sdio_addr != 0) - { - r = unifi_read_direct16(card, sdio_addr, &val); - if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE) - { - goto done; - } - if (r != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, "Can't read GBL_CHIP_VERSION\n"); - goto done; - } - } - dump_buf->chip_ver = val; - dump_buf->fw_ver = card->build_id; - - unifi_trace(card->ospriv, UDBG4, "chip_ver 0x%04x, fw_ver %u\n", - dump_buf->chip_ver, dump_buf->fw_ver); - - /* Capture the memory zones required from UniFi */ - r = unifi_coredump_read_zones(card, dump_buf); - if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE) - { - goto done; - } - if (r != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, "Can't read UniFi memory areas\n"); - goto done; - } - -done: - return r; -} /* unifi_coredump_from_sdio() */ - - -#ifndef UNIFI_DISABLE_COREDUMP -/* - * --------------------------------------------------------------------------- - * new_coredump_node - * - * Allocates a coredump linked-list node, and links it to the previous. - * - * Arguments: - * ospriv OS context - * prevnode Previous node to link into - * - * Returns: - * Pointer to valid coredump_buffer on success - * NULL on memory allocation failure - * - * Notes: - * Allocates "all or nothing" - * --------------------------------------------------------------------------- - */ -static -coredump_buffer* new_coredump_node(void *ospriv, coredump_buffer *prevnode) -{ - coredump_buffer *newnode = NULL; - u16 *newzone = NULL; - s32 i; - u32 zone_size; - - /* Allocate node header */ - newnode = kzalloc(sizeof(coredump_buffer), GFP_KERNEL); - if (newnode == NULL) - { - return NULL; - } - - /* Allocate chip memory zone capture buffers */ - for (i = 0; i < HIP_CDUMP_NUM_ZONES; i++) - { - zone_size = sizeof(u16) * zonedef_table[i].length; - newzone = kzalloc(zone_size, GFP_KERNEL); - newnode->zone[i] = newzone; - if (newzone == NULL) - { - unifi_error(ospriv, "Out of memory on coredump zone %d (%d words)\n", - i, zonedef_table[i].length); - break; - } - } - - /* Clean up if any zone alloc failed */ - if (newzone == NULL) - { - for (i = 0; newnode->zone[i] != NULL; i++) - { - kfree(newnode->zone[i]); - newnode->zone[i] = NULL; - } - } - - /* Link to previous node */ - newnode->prev = prevnode; - if (prevnode) - { - prevnode->next = newnode; - } - newnode->next = NULL; - - return newnode; -} - - -#endif /* UNIFI_DISABLE_COREDUMP */ - -/* - * --------------------------------------------------------------------------- - * unifi_coredump_init - * - * Allocates buffers for the automatic SDIO core dump - * - * Arguments: - * card Pointer to card struct - * num_dump_buffers Number of buffers to reserve for coredumps - * - * Returns: - * CSR_RESULT_SUCCESS on success, or: - * CSR_WIFI_HIP_RESULT_NO_MEMORY memory allocation failed - * - * Notes: - * Allocates space in advance, to be used for the last n coredump buffers - * the intention being that the size is sufficient for at least one dump, - * probably several. - * It's probably advisable to have at least 2 coredump buffers to allow - * one to be enquired with the unifi_coredump tool, while leaving another - * free for capturing. - * --------------------------------------------------------------------------- - */ -CsrResult unifi_coredump_init(card_t *card, u16 num_dump_buffers) -{ -#ifndef UNIFI_DISABLE_COREDUMP - void *ospriv = card->ospriv; - coredump_buffer *prev = NULL; - coredump_buffer *newnode = NULL; - u32 i = 0; -#endif - - card->request_coredump_on_reset = 0; - card->dump_next_write = NULL; - card->dump_cur_read = NULL; - card->dump_buf = NULL; - -#ifndef UNIFI_DISABLE_COREDUMP - unifi_trace(ospriv, UDBG1, - "Allocate buffers for %d core dumps\n", num_dump_buffers); - if (num_dump_buffers == 0) - { - goto done; - } - - /* Root node */ - card->dump_buf = new_coredump_node(ospriv, NULL); - if (card->dump_buf == NULL) - { - goto fail; - } - prev = card->dump_buf; - newnode = card->dump_buf; - - /* Add each subsequent node at tail */ - for (i = 1; i < num_dump_buffers; i++) - { - newnode = new_coredump_node(ospriv, prev); - if (newnode == NULL) - { - goto fail; - } - prev = newnode; - } - - /* Link the first and last nodes to make the list circular */ - card->dump_buf->prev = newnode; - newnode->next = card->dump_buf; - - /* Set initial r/w access pointers */ - card->dump_next_write = card->dump_buf; - card->dump_cur_read = NULL; - - unifi_trace(ospriv, UDBG2, "Core dump configured (%d dumps max)\n", i); - -done: -#endif - return CSR_RESULT_SUCCESS; - -#ifndef UNIFI_DISABLE_COREDUMP -fail: - /* Unwind what we allocated so far */ - unifi_error(ospriv, "Out of memory allocating core dump node %d\n", i); - unifi_coredump_free(card); - return CSR_WIFI_HIP_RESULT_NO_MEMORY; -#endif -} /* unifi_coreump_init() */ - - -/* - * --------------------------------------------------------------------------- - * unifi_coredump_free - * - * Free all memory dynamically allocated for core dump - * - * Arguments: - * card Pointer to card struct - * - * Returns: - * None - * - * Notes: - * --------------------------------------------------------------------------- - */ -void unifi_coredump_free(card_t *card) -{ - void *ospriv = card->ospriv; - coredump_buffer *node, *del_node; - s16 i = 0; - s16 j; - - unifi_trace(ospriv, UDBG2, "Core dump de-configured\n"); - - if (card->dump_buf == NULL) - { - return; - } - - node = card->dump_buf; - do - { - /* Free payload zones */ - for (j = 0; j < HIP_CDUMP_NUM_ZONES; j++) - { - kfree(node->zone[j]); - node->zone[j] = NULL; - } - - /* Detach */ - del_node = node; - node = node->next; - - /* Free header */ - kfree(del_node); - i++; - } while ((node != NULL) && (node != card->dump_buf)); - - unifi_trace(ospriv, UDBG3, "Freed %d coredump buffers\n", i); - - card->dump_buf = NULL; - card->dump_next_write = NULL; - card->dump_cur_read = NULL; -} /* unifi_coredump_free() */ - - diff --git a/drivers/staging/csr/csr_wifi_hip_packing.c b/drivers/staging/csr/csr_wifi_hip_packing.c deleted file mode 100644 index 0768aefc6d1f..000000000000 --- a/drivers/staging/csr/csr_wifi_hip_packing.c +++ /dev/null @@ -1,4804 +0,0 @@ -/***************************************************************************** - - (c) Cambridge Silicon Radio Limited 2011 - All rights reserved and confidential information of CSR - - Refer to LICENSE.txt included with this source for details - on the license terms. - -*****************************************************************************/ - -/* Note: this is an auto-generated file. */ - -#include "csr_wifi_hip_signals.h" -#include "csr_wifi_hip_unifi.h" -#include "csr_wifi_hip_conversions.h" - - -/* - * --------------------------------------------------------------------------- - * get_packed_struct_size - * - * Examine a buffer containing a UniFi signal in wire-format. - * The first two bytes contain the signal ID, decode the signal ID and - * return the size, in bytes, of the signal, not including any bulk - * data. - * - * WARNING: This function is auto-generated, DO NOT EDIT! - * - * Arguments: - * buf Pointer to buffer to decode. - * - * Returns: - * 0 if the signal ID is not recognised (i.e. zero length), - * otherwise the number of bytes occupied by the signal in the buffer. - * This is useful for stepping past the signal to the object in the buffer. - * --------------------------------------------------------------------------- - */ -s32 get_packed_struct_size(const u8 *buf) -{ - s32 size = 0; - u16 sig_id; - - sig_id = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(buf); - - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - switch (sig_id) - { -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_SET_PACKET_FILTER_CONFIRM_ID: - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_SETKEYS_CONFIRM_ID: - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_CONFIG_QUEUE_CONFIRM_ID: - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_ADD_AUTONOMOUS_SCAN_CONFIRM_ID: - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_ADD_BLACKOUT_CONFIRM_ID: - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_DEL_BLACKOUT_REQUEST_ID: - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_GET_KEY_SEQUENCE_CONFIRM_ID: - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_SM_START_CONFIRM_ID: - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_STOP_AGGREGATION_CONFIRM_ID: - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += 48 / 8; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_DEL_TSPEC_REQUEST_ID: - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - break; -#endif - case CSR_DEBUG_WORD16_INDICATION_ID: - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - break; - case CSR_DEBUG_GENERIC_CONFIRM_ID: - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - break; - case CSR_MA_PACKET_INDICATION_ID: - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT64; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - break; - case CSR_MLME_SET_TIM_REQUEST_ID: - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - break; -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_CONNECTED_INDICATION_ID: - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += 48 / 8; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_DEL_RX_TRIGGER_REQUEST_ID: - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_TRIGGERED_GET_INDICATION_ID: - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_SCAN_REQUEST_ID: - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT32; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_DELETEKEYS_CONFIRM_ID: - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_GET_NEXT_REQUEST_ID: - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_SET_CHANNEL_CONFIRM_ID: - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_START_AGGREGATION_REQUEST_ID: - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += 48 / 8; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_HL_SYNC_REQUEST_ID: - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += 48 / 8; - break; -#endif - case CSR_DEBUG_GENERIC_REQUEST_ID: - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - break; -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_LEAVE_CONFIRM_ID: - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_DEL_TRIGGERED_GET_REQUEST_ID: - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_ADD_MULTICAST_ADDRESS_REQUEST_ID: - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_RESET_REQUEST_ID: - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += 48 / 8; - size += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_SCAN_CANCEL_REQUEST_ID: - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_ADD_TRIGGERED_GET_CONFIRM_ID: - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_SET_PACKET_FILTER_REQUEST_ID: - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT32; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_DEL_RX_TRIGGER_CONFIRM_ID: - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_CONNECT_STATUS_REQUEST_ID: - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += 48 / 8; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_LEAVE_REQUEST_ID: - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_CONFIG_QUEUE_REQUEST_ID: - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_DEL_TSPEC_CONFIRM_ID: - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - break; -#endif - case CSR_MLME_SET_TIM_CONFIRM_ID: - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - break; -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_MEASURE_INDICATION_ID: - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_DEL_BLACKOUT_CONFIRM_ID: - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_DEL_TRIGGERED_GET_CONFIRM_ID: - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - break; -#endif - case CSR_DEBUG_GENERIC_INDICATION_ID: - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - break; - case CSR_MA_PACKET_CANCEL_REQUEST_ID: - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT32; - break; -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_MODIFY_BSS_PARAMETER_CONFIRM_ID: - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_PAUSE_AUTONOMOUS_SCAN_CONFIRM_ID: - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - break; -#endif - case CSR_MA_PACKET_REQUEST_ID: - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT32; - size += SIZEOF_UINT16; - size += 48 / 8; - size += SIZEOF_UINT16; - break; -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_MODIFY_BSS_PARAMETER_REQUEST_ID: - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += 48 / 8; - size += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_ADD_RX_TRIGGER_REQUEST_ID: - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - break; -#endif - case CSR_MA_VIF_AVAILABILITY_INDICATION_ID: - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - break; -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_HL_SYNC_CANCEL_REQUEST_ID: - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += 48 / 8; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_DEL_AUTONOMOUS_SCAN_REQUEST_ID: - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_BLACKOUT_ENDED_INDICATION_ID: - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_AUTONOMOUS_SCAN_DONE_INDICATION_ID: - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_GET_KEY_SEQUENCE_REQUEST_ID: - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += 48 / 8; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_SET_CHANNEL_REQUEST_ID: - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += 48 / 8; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_MEASURE_CONFIRM_ID: - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_ADD_TRIGGERED_GET_REQUEST_ID: - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_AUTONOMOUS_SCAN_LOSS_INDICATION_ID: - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += 48 / 8; - break; -#endif - case CSR_MA_VIF_AVAILABILITY_RESPONSE_ID: - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - break; -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_ADD_TEMPLATE_REQUEST_ID: - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_POWERMGT_CONFIRM_ID: - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_ADD_PERIODIC_CONFIRM_ID: - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_GET_CONFIRM_ID: - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_GET_NEXT_CONFIRM_ID: - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_STOP_AGGREGATION_REQUEST_ID: - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += 48 / 8; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_ADD_RX_TRIGGER_CONFIRM_ID: - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_ADD_BLACKOUT_REQUEST_ID: - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT32; - size += SIZEOF_UINT32; - size += SIZEOF_UINT32; - size += 48 / 8; - size += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_DELETEKEYS_REQUEST_ID: - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += 48 / 8; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_RESET_CONFIRM_ID: - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_HL_SYNC_CONFIRM_ID: - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += 48 / 8; - size += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_ADD_AUTONOMOUS_SCAN_REQUEST_ID: - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT32; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_SET_REQUEST_ID: - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_SM_START_REQUEST_ID: - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += 48 / 8; - size += 48 / 8; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_CONNECT_STATUS_CONFIRM_ID: - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_DEL_AUTONOMOUS_SCAN_CONFIRM_ID: - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_DEL_PERIODIC_REQUEST_ID: - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_SETKEYS_REQUEST_ID: - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += 48 / 8; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += 32 / 8; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_PAUSE_AUTONOMOUS_SCAN_REQUEST_ID: - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_GET_REQUEST_ID: - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_POWERMGT_REQUEST_ID: - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - break; -#endif - case CSR_MA_PACKET_ERROR_INDICATION_ID: - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += 48 / 8; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - break; -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_ADD_PERIODIC_REQUEST_ID: - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT32; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_ADD_TSPEC_REQUEST_ID: - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT32; - size += SIZEOF_UINT32; - size += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_ADD_MULTICAST_ADDRESS_CONFIRM_ID: - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_ADD_TSPEC_CONFIRM_ID: - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_HL_SYNC_CANCEL_CONFIRM_ID: - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_SCAN_CONFIRM_ID: - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - break; -#endif - case CSR_DEBUG_STRING_INDICATION_ID: - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - break; -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_ADD_TEMPLATE_CONFIRM_ID: - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_BLOCKACK_ERROR_INDICATION_ID: - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += 48 / 8; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_SET_CONFIRM_ID: - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_MEASURE_REQUEST_ID: - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_START_AGGREGATION_CONFIRM_ID: - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += 48 / 8; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_STOP_MEASURE_CONFIRM_ID: - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - break; -#endif - case CSR_MA_PACKET_CONFIRM_ID: - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT32; - break; -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_DEL_PERIODIC_CONFIRM_ID: - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_STOP_MEASURE_REQUEST_ID: - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - size += SIZEOF_UINT16; - break; -#endif - default: - size = 0; - } - return size; -} /* get_packed_struct_size() */ - - -/* - * --------------------------------------------------------------------------- - * read_unpack_signal - * - * Unpack a wire-format signal into a host-native structure. - * This function handles any necessary conversions for endianness and - * places no restrictions on packing or alignment for the structure - * definition. - * - * WARNING: This function is auto-generated, DO NOT EDIT! - * - * Arguments: - * ptr Signal buffer to unpack. - * sig Pointer to destination structure to populate. - * - * Returns: - * CSR_RESULT_SUCCESS on success, - * CSR_WIFI_HIP_RESULT_INVALID_VALUE if the ID of signal was not recognised. - * --------------------------------------------------------------------------- - */ -CsrResult read_unpack_signal(const u8 *ptr, CSR_SIGNAL *sig) -{ - s32 index = 0; - - sig->SignalPrimitiveHeader.SignalId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - - sig->SignalPrimitiveHeader.ReceiverProcessId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - - sig->SignalPrimitiveHeader.SenderProcessId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - - switch (sig->SignalPrimitiveHeader.SignalId) - { -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_SET_PACKET_FILTER_CONFIRM_ID: - sig->u.MlmeSetPacketFilterConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeSetPacketFilterConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeSetPacketFilterConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeSetPacketFilterConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeSetPacketFilterConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeSetPacketFilterConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_SETKEYS_CONFIRM_ID: - sig->u.MlmeSetkeysConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeSetkeysConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeSetkeysConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeSetkeysConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeSetkeysConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeSetkeysConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_CONFIG_QUEUE_CONFIRM_ID: - sig->u.MlmeConfigQueueConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeConfigQueueConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeConfigQueueConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeConfigQueueConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeConfigQueueConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_ADD_AUTONOMOUS_SCAN_CONFIRM_ID: - sig->u.MlmeAddAutonomousScanConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAddAutonomousScanConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAddAutonomousScanConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAddAutonomousScanConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAddAutonomousScanConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAddAutonomousScanConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAddAutonomousScanConfirm.AutonomousScanId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_ADD_BLACKOUT_CONFIRM_ID: - sig->u.MlmeAddBlackoutConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAddBlackoutConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAddBlackoutConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAddBlackoutConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAddBlackoutConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAddBlackoutConfirm.BlackoutId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAddBlackoutConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_DEL_BLACKOUT_REQUEST_ID: - sig->u.MlmeDelBlackoutRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeDelBlackoutRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeDelBlackoutRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeDelBlackoutRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeDelBlackoutRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeDelBlackoutRequest.BlackoutId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_GET_KEY_SEQUENCE_CONFIRM_ID: - sig->u.MlmeGetKeySequenceConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeGetKeySequenceConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeGetKeySequenceConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeGetKeySequenceConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeGetKeySequenceConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeGetKeySequenceConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeGetKeySequenceConfirm.SequenceNumber[0] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeGetKeySequenceConfirm.SequenceNumber[1] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeGetKeySequenceConfirm.SequenceNumber[2] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeGetKeySequenceConfirm.SequenceNumber[3] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeGetKeySequenceConfirm.SequenceNumber[4] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeGetKeySequenceConfirm.SequenceNumber[5] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeGetKeySequenceConfirm.SequenceNumber[6] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeGetKeySequenceConfirm.SequenceNumber[7] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_SM_START_CONFIRM_ID: - sig->u.MlmeSmStartConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeSmStartConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeSmStartConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeSmStartConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeSmStartConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeSmStartConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_STOP_AGGREGATION_CONFIRM_ID: - sig->u.MlmeStopAggregationConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeStopAggregationConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeStopAggregationConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeStopAggregationConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeStopAggregationConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - memcpy(sig->u.MlmeStopAggregationConfirm.PeerQstaAddress.x, &ptr[index], 48 / 8); - index += 48 / 8; - sig->u.MlmeStopAggregationConfirm.UserPriority = (CSR_PRIORITY) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeStopAggregationConfirm.Direction = (CSR_DIRECTION) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeStopAggregationConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_DEL_TSPEC_REQUEST_ID: - sig->u.MlmeDelTspecRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeDelTspecRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeDelTspecRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeDelTspecRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeDelTspecRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeDelTspecRequest.UserPriority = (CSR_PRIORITY) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeDelTspecRequest.Direction = (CSR_DIRECTION) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - break; -#endif - case CSR_DEBUG_WORD16_INDICATION_ID: - sig->u.DebugWord16Indication.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.DebugWord16Indication.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.DebugWord16Indication.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.DebugWord16Indication.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.DebugWord16Indication.DebugWords[0] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.DebugWord16Indication.DebugWords[1] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.DebugWord16Indication.DebugWords[2] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.DebugWord16Indication.DebugWords[3] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.DebugWord16Indication.DebugWords[4] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.DebugWord16Indication.DebugWords[5] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.DebugWord16Indication.DebugWords[6] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.DebugWord16Indication.DebugWords[7] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.DebugWord16Indication.DebugWords[8] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.DebugWord16Indication.DebugWords[9] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.DebugWord16Indication.DebugWords[10] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.DebugWord16Indication.DebugWords[11] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.DebugWord16Indication.DebugWords[12] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.DebugWord16Indication.DebugWords[13] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.DebugWord16Indication.DebugWords[14] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.DebugWord16Indication.DebugWords[15] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - break; - case CSR_DEBUG_GENERIC_CONFIRM_ID: - sig->u.DebugGenericConfirm.DebugVariable.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.DebugGenericConfirm.DebugVariable.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.DebugGenericConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.DebugGenericConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.DebugGenericConfirm.DebugWords[0] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.DebugGenericConfirm.DebugWords[1] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.DebugGenericConfirm.DebugWords[2] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.DebugGenericConfirm.DebugWords[3] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.DebugGenericConfirm.DebugWords[4] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.DebugGenericConfirm.DebugWords[5] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.DebugGenericConfirm.DebugWords[6] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.DebugGenericConfirm.DebugWords[7] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - break; - case CSR_MA_PACKET_INDICATION_ID: - sig->u.MaPacketIndication.Data.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MaPacketIndication.Data.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MaPacketIndication.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MaPacketIndication.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MaPacketIndication.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - memcpy(sig->u.MaPacketIndication.LocalTime.x, &ptr[index], 64 / 8); - index += 64 / 8; - sig->u.MaPacketIndication.Ifindex = (CSR_IFINTERFACE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MaPacketIndication.Channel = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MaPacketIndication.ReceptionStatus = (CSR_RECEPTION_STATUS) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MaPacketIndication.Rssi = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MaPacketIndication.Snr = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MaPacketIndication.ReceivedRate = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - break; - case CSR_MLME_SET_TIM_REQUEST_ID: - sig->u.MlmeSetTimRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeSetTimRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeSetTimRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeSetTimRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeSetTimRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeSetTimRequest.AssociationId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeSetTimRequest.TimValue = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - break; -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_CONNECTED_INDICATION_ID: - sig->u.MlmeConnectedIndication.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeConnectedIndication.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeConnectedIndication.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeConnectedIndication.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeConnectedIndication.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeConnectedIndication.ConnectionStatus = (CSR_CONNECTION_STATUS) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - memcpy(sig->u.MlmeConnectedIndication.PeerMacAddress.x, &ptr[index], 48 / 8); - index += 48 / 8; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_DEL_RX_TRIGGER_REQUEST_ID: - sig->u.MlmeDelRxTriggerRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeDelRxTriggerRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeDelRxTriggerRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeDelRxTriggerRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeDelRxTriggerRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeDelRxTriggerRequest.TriggerId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_TRIGGERED_GET_INDICATION_ID: - sig->u.MlmeTriggeredGetIndication.MibAttributeValue.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeTriggeredGetIndication.MibAttributeValue.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeTriggeredGetIndication.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeTriggeredGetIndication.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeTriggeredGetIndication.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeTriggeredGetIndication.Status = (CSR_MIB_STATUS) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeTriggeredGetIndication.ErrorIndex = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeTriggeredGetIndication.TriggeredId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_SCAN_REQUEST_ID: - sig->u.MlmeScanRequest.ChannelList.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeScanRequest.ChannelList.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeScanRequest.InformationElements.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeScanRequest.InformationElements.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeScanRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeScanRequest.Ifindex = (CSR_IFINTERFACE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeScanRequest.ScanType = (CSR_SCAN_TYPE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeScanRequest.ProbeDelay = CSR_GET_UINT32_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT32; - sig->u.MlmeScanRequest.MinChannelTime = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeScanRequest.MaxChannelTime = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_DELETEKEYS_CONFIRM_ID: - sig->u.MlmeDeletekeysConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeDeletekeysConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeDeletekeysConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeDeletekeysConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeDeletekeysConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeDeletekeysConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_GET_NEXT_REQUEST_ID: - sig->u.MlmeGetNextRequest.MibAttribute.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeGetNextRequest.MibAttribute.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeGetNextRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeGetNextRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_SET_CHANNEL_CONFIRM_ID: - sig->u.MlmeSetChannelConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeSetChannelConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeSetChannelConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeSetChannelConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeSetChannelConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeSetChannelConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_START_AGGREGATION_REQUEST_ID: - sig->u.MlmeStartAggregationRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeStartAggregationRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeStartAggregationRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeStartAggregationRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeStartAggregationRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - memcpy(sig->u.MlmeStartAggregationRequest.PeerQstaAddress.x, &ptr[index], 48 / 8); - index += 48 / 8; - sig->u.MlmeStartAggregationRequest.UserPriority = (CSR_PRIORITY) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeStartAggregationRequest.Direction = (CSR_DIRECTION) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeStartAggregationRequest.StartingSequenceNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeStartAggregationRequest.BufferSize = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeStartAggregationRequest.BlockAckTimeout = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_HL_SYNC_REQUEST_ID: - sig->u.MlmeHlSyncRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeHlSyncRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeHlSyncRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeHlSyncRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - memcpy(sig->u.MlmeHlSyncRequest.GroupAddress.x, &ptr[index], 48 / 8); - index += 48 / 8; - break; -#endif - case CSR_DEBUG_GENERIC_REQUEST_ID: - sig->u.DebugGenericRequest.DebugVariable.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.DebugGenericRequest.DebugVariable.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.DebugGenericRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.DebugGenericRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.DebugGenericRequest.DebugWords[0] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.DebugGenericRequest.DebugWords[1] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.DebugGenericRequest.DebugWords[2] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.DebugGenericRequest.DebugWords[3] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.DebugGenericRequest.DebugWords[4] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.DebugGenericRequest.DebugWords[5] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.DebugGenericRequest.DebugWords[6] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.DebugGenericRequest.DebugWords[7] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - break; -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_LEAVE_CONFIRM_ID: - sig->u.MlmeLeaveConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeLeaveConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeLeaveConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeLeaveConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeLeaveConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeLeaveConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_DEL_TRIGGERED_GET_REQUEST_ID: - sig->u.MlmeDelTriggeredGetRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeDelTriggeredGetRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeDelTriggeredGetRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeDelTriggeredGetRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeDelTriggeredGetRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeDelTriggeredGetRequest.TriggeredId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_ADD_MULTICAST_ADDRESS_REQUEST_ID: - sig->u.MlmeAddMulticastAddressRequest.Data.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAddMulticastAddressRequest.Data.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAddMulticastAddressRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAddMulticastAddressRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAddMulticastAddressRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAddMulticastAddressRequest.NumberOfMulticastGroupAddresses = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_RESET_REQUEST_ID: - sig->u.MlmeResetRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeResetRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeResetRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeResetRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - memcpy(sig->u.MlmeResetRequest.StaAddress.x, &ptr[index], 48 / 8); - index += 48 / 8; - sig->u.MlmeResetRequest.SetDefaultMib = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_SCAN_CANCEL_REQUEST_ID: - sig->u.MlmeScanCancelRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeScanCancelRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeScanCancelRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeScanCancelRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeScanCancelRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_ADD_TRIGGERED_GET_CONFIRM_ID: - sig->u.MlmeAddTriggeredGetConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAddTriggeredGetConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAddTriggeredGetConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAddTriggeredGetConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAddTriggeredGetConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAddTriggeredGetConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAddTriggeredGetConfirm.TriggeredId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_SET_PACKET_FILTER_REQUEST_ID: - sig->u.MlmeSetPacketFilterRequest.InformationElements.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeSetPacketFilterRequest.InformationElements.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeSetPacketFilterRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeSetPacketFilterRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeSetPacketFilterRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeSetPacketFilterRequest.PacketFilterMode = (CSR_PACKET_FILTER_MODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeSetPacketFilterRequest.ArpFilterAddress = CSR_GET_UINT32_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT32; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_DEL_RX_TRIGGER_CONFIRM_ID: - sig->u.MlmeDelRxTriggerConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeDelRxTriggerConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeDelRxTriggerConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeDelRxTriggerConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeDelRxTriggerConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeDelRxTriggerConfirm.TriggerId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeDelRxTriggerConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_CONNECT_STATUS_REQUEST_ID: - sig->u.MlmeConnectStatusRequest.InformationElements.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeConnectStatusRequest.InformationElements.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeConnectStatusRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeConnectStatusRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeConnectStatusRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeConnectStatusRequest.ConnectionStatus = (CSR_CONNECTION_STATUS) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - memcpy(sig->u.MlmeConnectStatusRequest.StaAddress.x, &ptr[index], 48 / 8); - index += 48 / 8; - sig->u.MlmeConnectStatusRequest.AssociationId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeConnectStatusRequest.AssociationCapabilityInformation = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_LEAVE_REQUEST_ID: - sig->u.MlmeLeaveRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeLeaveRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeLeaveRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeLeaveRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeLeaveRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_CONFIG_QUEUE_REQUEST_ID: - sig->u.MlmeConfigQueueRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeConfigQueueRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeConfigQueueRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeConfigQueueRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeConfigQueueRequest.QueueIndex = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeConfigQueueRequest.Aifs = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeConfigQueueRequest.Cwmin = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeConfigQueueRequest.Cwmax = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeConfigQueueRequest.TxopLimit = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_DEL_TSPEC_CONFIRM_ID: - sig->u.MlmeDelTspecConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeDelTspecConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeDelTspecConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeDelTspecConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeDelTspecConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeDelTspecConfirm.UserPriority = (CSR_PRIORITY) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeDelTspecConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - break; -#endif - case CSR_MLME_SET_TIM_CONFIRM_ID: - sig->u.MlmeSetTimConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeSetTimConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeSetTimConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeSetTimConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeSetTimConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeSetTimConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - break; -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_MEASURE_INDICATION_ID: - sig->u.MlmeMeasureIndication.MeasurementReportSet.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeMeasureIndication.MeasurementReportSet.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeMeasureIndication.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeMeasureIndication.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeMeasureIndication.DialogToken = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_DEL_BLACKOUT_CONFIRM_ID: - sig->u.MlmeDelBlackoutConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeDelBlackoutConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeDelBlackoutConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeDelBlackoutConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeDelBlackoutConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeDelBlackoutConfirm.BlackoutId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeDelBlackoutConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_DEL_TRIGGERED_GET_CONFIRM_ID: - sig->u.MlmeDelTriggeredGetConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeDelTriggeredGetConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeDelTriggeredGetConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeDelTriggeredGetConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeDelTriggeredGetConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeDelTriggeredGetConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeDelTriggeredGetConfirm.TriggeredId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - break; -#endif - case CSR_DEBUG_GENERIC_INDICATION_ID: - sig->u.DebugGenericIndication.DebugVariable.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.DebugGenericIndication.DebugVariable.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.DebugGenericIndication.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.DebugGenericIndication.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.DebugGenericIndication.DebugWords[0] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.DebugGenericIndication.DebugWords[1] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.DebugGenericIndication.DebugWords[2] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.DebugGenericIndication.DebugWords[3] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.DebugGenericIndication.DebugWords[4] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.DebugGenericIndication.DebugWords[5] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.DebugGenericIndication.DebugWords[6] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.DebugGenericIndication.DebugWords[7] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - break; - case CSR_MA_PACKET_CANCEL_REQUEST_ID: - sig->u.MaPacketCancelRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MaPacketCancelRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MaPacketCancelRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MaPacketCancelRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MaPacketCancelRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MaPacketCancelRequest.HostTag = CSR_GET_UINT32_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT32; - break; -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_MODIFY_BSS_PARAMETER_CONFIRM_ID: - sig->u.MlmeModifyBssParameterConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeModifyBssParameterConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeModifyBssParameterConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeModifyBssParameterConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeModifyBssParameterConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeModifyBssParameterConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_PAUSE_AUTONOMOUS_SCAN_CONFIRM_ID: - sig->u.MlmePauseAutonomousScanConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmePauseAutonomousScanConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmePauseAutonomousScanConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmePauseAutonomousScanConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmePauseAutonomousScanConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmePauseAutonomousScanConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmePauseAutonomousScanConfirm.AutonomousScanId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - break; -#endif - case CSR_MA_PACKET_REQUEST_ID: - sig->u.MaPacketRequest.Data.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MaPacketRequest.Data.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MaPacketRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MaPacketRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MaPacketRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MaPacketRequest.TransmitRate = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MaPacketRequest.HostTag = CSR_GET_UINT32_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT32; - sig->u.MaPacketRequest.Priority = (CSR_PRIORITY) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - memcpy(sig->u.MaPacketRequest.Ra.x, &ptr[index], 48 / 8); - index += 48 / 8; - sig->u.MaPacketRequest.TransmissionControl = (CSR_TRANSMISSION_CONTROL) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - break; -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_MODIFY_BSS_PARAMETER_REQUEST_ID: - sig->u.MlmeModifyBssParameterRequest.Data.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeModifyBssParameterRequest.Data.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeModifyBssParameterRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeModifyBssParameterRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeModifyBssParameterRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeModifyBssParameterRequest.BeaconPeriod = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeModifyBssParameterRequest.DtimPeriod = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeModifyBssParameterRequest.CapabilityInformation = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - memcpy(sig->u.MlmeModifyBssParameterRequest.Bssid.x, &ptr[index], 48 / 8); - index += 48 / 8; - sig->u.MlmeModifyBssParameterRequest.RtsThreshold = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_ADD_RX_TRIGGER_REQUEST_ID: - sig->u.MlmeAddRxTriggerRequest.InformationElements.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAddRxTriggerRequest.InformationElements.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAddRxTriggerRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAddRxTriggerRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAddRxTriggerRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAddRxTriggerRequest.TriggerId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAddRxTriggerRequest.Priority = (CSR_PRIORITY) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - break; -#endif - case CSR_MA_VIF_AVAILABILITY_INDICATION_ID: - sig->u.MaVifAvailabilityIndication.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MaVifAvailabilityIndication.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MaVifAvailabilityIndication.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MaVifAvailabilityIndication.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MaVifAvailabilityIndication.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MaVifAvailabilityIndication.Multicast = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - break; -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_HL_SYNC_CANCEL_REQUEST_ID: - sig->u.MlmeHlSyncCancelRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeHlSyncCancelRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeHlSyncCancelRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeHlSyncCancelRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - memcpy(sig->u.MlmeHlSyncCancelRequest.GroupAddress.x, &ptr[index], 48 / 8); - index += 48 / 8; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_DEL_AUTONOMOUS_SCAN_REQUEST_ID: - sig->u.MlmeDelAutonomousScanRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeDelAutonomousScanRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeDelAutonomousScanRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeDelAutonomousScanRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeDelAutonomousScanRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeDelAutonomousScanRequest.AutonomousScanId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_BLACKOUT_ENDED_INDICATION_ID: - sig->u.MlmeBlackoutEndedIndication.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeBlackoutEndedIndication.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeBlackoutEndedIndication.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeBlackoutEndedIndication.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeBlackoutEndedIndication.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeBlackoutEndedIndication.BlackoutId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_AUTONOMOUS_SCAN_DONE_INDICATION_ID: - sig->u.MlmeAutonomousScanDoneIndication.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAutonomousScanDoneIndication.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAutonomousScanDoneIndication.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAutonomousScanDoneIndication.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAutonomousScanDoneIndication.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAutonomousScanDoneIndication.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAutonomousScanDoneIndication.AutonomousScanId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_GET_KEY_SEQUENCE_REQUEST_ID: - sig->u.MlmeGetKeySequenceRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeGetKeySequenceRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeGetKeySequenceRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeGetKeySequenceRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeGetKeySequenceRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeGetKeySequenceRequest.KeyId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeGetKeySequenceRequest.KeyType = (CSR_KEY_TYPE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - memcpy(sig->u.MlmeGetKeySequenceRequest.Address.x, &ptr[index], 48 / 8); - index += 48 / 8; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_SET_CHANNEL_REQUEST_ID: - sig->u.MlmeSetChannelRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeSetChannelRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeSetChannelRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeSetChannelRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeSetChannelRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeSetChannelRequest.Ifindex = (CSR_IFINTERFACE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeSetChannelRequest.Channel = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - memcpy(sig->u.MlmeSetChannelRequest.Address.x, &ptr[index], 48 / 8); - index += 48 / 8; - sig->u.MlmeSetChannelRequest.AvailabilityDuration = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeSetChannelRequest.AvailabilityInterval = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_MEASURE_CONFIRM_ID: - sig->u.MlmeMeasureConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeMeasureConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeMeasureConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeMeasureConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeMeasureConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeMeasureConfirm.DialogToken = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_ADD_TRIGGERED_GET_REQUEST_ID: - sig->u.MlmeAddTriggeredGetRequest.MibAttribute.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAddTriggeredGetRequest.MibAttribute.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAddTriggeredGetRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAddTriggeredGetRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAddTriggeredGetRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAddTriggeredGetRequest.TriggeredId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_AUTONOMOUS_SCAN_LOSS_INDICATION_ID: - sig->u.MlmeAutonomousScanLossIndication.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAutonomousScanLossIndication.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAutonomousScanLossIndication.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAutonomousScanLossIndication.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAutonomousScanLossIndication.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - memcpy(sig->u.MlmeAutonomousScanLossIndication.Bssid.x, &ptr[index], 48 / 8); - index += 48 / 8; - break; -#endif - case CSR_MA_VIF_AVAILABILITY_RESPONSE_ID: - sig->u.MaVifAvailabilityResponse.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MaVifAvailabilityResponse.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MaVifAvailabilityResponse.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MaVifAvailabilityResponse.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MaVifAvailabilityResponse.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MaVifAvailabilityResponse.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - break; -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_ADD_TEMPLATE_REQUEST_ID: - sig->u.MlmeAddTemplateRequest.Data1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAddTemplateRequest.Data1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAddTemplateRequest.Data2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAddTemplateRequest.Data2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAddTemplateRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAddTemplateRequest.FrameType = (CSR_FRAME_TYPE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAddTemplateRequest.MinTransmitRate = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_POWERMGT_CONFIRM_ID: - sig->u.MlmePowermgtConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmePowermgtConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmePowermgtConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmePowermgtConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmePowermgtConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmePowermgtConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_ADD_PERIODIC_CONFIRM_ID: - sig->u.MlmeAddPeriodicConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAddPeriodicConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAddPeriodicConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAddPeriodicConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAddPeriodicConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAddPeriodicConfirm.PeriodicId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAddPeriodicConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_GET_CONFIRM_ID: - sig->u.MlmeGetConfirm.MibAttributeValue.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeGetConfirm.MibAttributeValue.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeGetConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeGetConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeGetConfirm.Status = (CSR_MIB_STATUS) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeGetConfirm.ErrorIndex = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_GET_NEXT_CONFIRM_ID: - sig->u.MlmeGetNextConfirm.MibAttributeValue.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeGetNextConfirm.MibAttributeValue.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeGetNextConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeGetNextConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeGetNextConfirm.Status = (CSR_MIB_STATUS) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeGetNextConfirm.ErrorIndex = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_STOP_AGGREGATION_REQUEST_ID: - sig->u.MlmeStopAggregationRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeStopAggregationRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeStopAggregationRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeStopAggregationRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeStopAggregationRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - memcpy(sig->u.MlmeStopAggregationRequest.PeerQstaAddress.x, &ptr[index], 48 / 8); - index += 48 / 8; - sig->u.MlmeStopAggregationRequest.UserPriority = (CSR_PRIORITY) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeStopAggregationRequest.Direction = (CSR_DIRECTION) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_ADD_RX_TRIGGER_CONFIRM_ID: - sig->u.MlmeAddRxTriggerConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAddRxTriggerConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAddRxTriggerConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAddRxTriggerConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAddRxTriggerConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAddRxTriggerConfirm.TriggerId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAddRxTriggerConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_ADD_BLACKOUT_REQUEST_ID: - sig->u.MlmeAddBlackoutRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAddBlackoutRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAddBlackoutRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAddBlackoutRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAddBlackoutRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAddBlackoutRequest.BlackoutId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAddBlackoutRequest.BlackoutType = (CSR_BLACKOUT_TYPE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAddBlackoutRequest.BlackoutSource = (CSR_BLACKOUT_SOURCE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAddBlackoutRequest.BlackoutStartReference = CSR_GET_UINT32_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT32; - sig->u.MlmeAddBlackoutRequest.BlackoutPeriod = CSR_GET_UINT32_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT32; - sig->u.MlmeAddBlackoutRequest.BlackoutDuration = CSR_GET_UINT32_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT32; - memcpy(sig->u.MlmeAddBlackoutRequest.PeerStaAddress.x, &ptr[index], 48 / 8); - index += 48 / 8; - sig->u.MlmeAddBlackoutRequest.BlackoutCount = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_DELETEKEYS_REQUEST_ID: - sig->u.MlmeDeletekeysRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeDeletekeysRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeDeletekeysRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeDeletekeysRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeDeletekeysRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeDeletekeysRequest.KeyId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeDeletekeysRequest.KeyType = (CSR_KEY_TYPE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - memcpy(sig->u.MlmeDeletekeysRequest.Address.x, &ptr[index], 48 / 8); - index += 48 / 8; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_RESET_CONFIRM_ID: - sig->u.MlmeResetConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeResetConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeResetConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeResetConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeResetConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_HL_SYNC_CONFIRM_ID: - sig->u.MlmeHlSyncConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeHlSyncConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeHlSyncConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeHlSyncConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - memcpy(sig->u.MlmeHlSyncConfirm.GroupAddress.x, &ptr[index], 48 / 8); - index += 48 / 8; - sig->u.MlmeHlSyncConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_ADD_AUTONOMOUS_SCAN_REQUEST_ID: - sig->u.MlmeAddAutonomousScanRequest.ChannelList.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAddAutonomousScanRequest.ChannelList.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAddAutonomousScanRequest.InformationElements.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAddAutonomousScanRequest.InformationElements.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAddAutonomousScanRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAddAutonomousScanRequest.AutonomousScanId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAddAutonomousScanRequest.Ifindex = (CSR_IFINTERFACE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAddAutonomousScanRequest.ChannelStartingFactor = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAddAutonomousScanRequest.ScanType = (CSR_SCAN_TYPE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAddAutonomousScanRequest.ProbeDelay = CSR_GET_UINT32_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT32; - sig->u.MlmeAddAutonomousScanRequest.MinChannelTime = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAddAutonomousScanRequest.MaxChannelTime = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_SET_REQUEST_ID: - sig->u.MlmeSetRequest.MibAttributeValue.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeSetRequest.MibAttributeValue.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeSetRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeSetRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_SM_START_REQUEST_ID: - sig->u.MlmeSmStartRequest.Beacon.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeSmStartRequest.Beacon.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeSmStartRequest.BssParameters.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeSmStartRequest.BssParameters.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeSmStartRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeSmStartRequest.Ifindex = (CSR_IFINTERFACE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeSmStartRequest.Channel = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - memcpy(sig->u.MlmeSmStartRequest.InterfaceAddress.x, &ptr[index], 48 / 8); - index += 48 / 8; - memcpy(sig->u.MlmeSmStartRequest.Bssid.x, &ptr[index], 48 / 8); - index += 48 / 8; - sig->u.MlmeSmStartRequest.BeaconPeriod = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeSmStartRequest.DtimPeriod = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeSmStartRequest.CapabilityInformation = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_CONNECT_STATUS_CONFIRM_ID: - sig->u.MlmeConnectStatusConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeConnectStatusConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeConnectStatusConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeConnectStatusConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeConnectStatusConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeConnectStatusConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_DEL_AUTONOMOUS_SCAN_CONFIRM_ID: - sig->u.MlmeDelAutonomousScanConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeDelAutonomousScanConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeDelAutonomousScanConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeDelAutonomousScanConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeDelAutonomousScanConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeDelAutonomousScanConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeDelAutonomousScanConfirm.AutonomousScanId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_DEL_PERIODIC_REQUEST_ID: - sig->u.MlmeDelPeriodicRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeDelPeriodicRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeDelPeriodicRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeDelPeriodicRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeDelPeriodicRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeDelPeriodicRequest.PeriodicId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_SETKEYS_REQUEST_ID: - sig->u.MlmeSetkeysRequest.Key.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeSetkeysRequest.Key.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeSetkeysRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeSetkeysRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeSetkeysRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeSetkeysRequest.Length = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeSetkeysRequest.KeyId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeSetkeysRequest.KeyType = (CSR_KEY_TYPE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - memcpy(sig->u.MlmeSetkeysRequest.Address.x, &ptr[index], 48 / 8); - index += 48 / 8; - sig->u.MlmeSetkeysRequest.SequenceNumber[0] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeSetkeysRequest.SequenceNumber[1] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeSetkeysRequest.SequenceNumber[2] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeSetkeysRequest.SequenceNumber[3] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeSetkeysRequest.SequenceNumber[4] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeSetkeysRequest.SequenceNumber[5] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeSetkeysRequest.SequenceNumber[6] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeSetkeysRequest.SequenceNumber[7] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - memcpy(&sig->u.MlmeSetkeysRequest.CipherSuiteSelector, &ptr[index], 32 / 8); - index += 32 / 8; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_PAUSE_AUTONOMOUS_SCAN_REQUEST_ID: - sig->u.MlmePauseAutonomousScanRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmePauseAutonomousScanRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmePauseAutonomousScanRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmePauseAutonomousScanRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmePauseAutonomousScanRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmePauseAutonomousScanRequest.AutonomousScanId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmePauseAutonomousScanRequest.Pause = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_GET_REQUEST_ID: - sig->u.MlmeGetRequest.MibAttribute.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeGetRequest.MibAttribute.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeGetRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeGetRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_POWERMGT_REQUEST_ID: - sig->u.MlmePowermgtRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmePowermgtRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmePowermgtRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmePowermgtRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmePowermgtRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmePowermgtRequest.PowerManagementMode = (CSR_POWER_MANAGEMENT_MODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmePowermgtRequest.ReceiveDtims = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmePowermgtRequest.ListenInterval = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmePowermgtRequest.TrafficWindow = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - break; -#endif - case CSR_MA_PACKET_ERROR_INDICATION_ID: - sig->u.MaPacketErrorIndication.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MaPacketErrorIndication.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MaPacketErrorIndication.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MaPacketErrorIndication.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MaPacketErrorIndication.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - memcpy(sig->u.MaPacketErrorIndication.PeerQstaAddress.x, &ptr[index], 48 / 8); - index += 48 / 8; - sig->u.MaPacketErrorIndication.UserPriority = (CSR_PRIORITY) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MaPacketErrorIndication.SequenceNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - break; -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_ADD_PERIODIC_REQUEST_ID: - sig->u.MlmeAddPeriodicRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAddPeriodicRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAddPeriodicRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAddPeriodicRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAddPeriodicRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAddPeriodicRequest.PeriodicId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAddPeriodicRequest.MaximumLatency = CSR_GET_UINT32_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT32; - sig->u.MlmeAddPeriodicRequest.PeriodicSchedulingMode = (CSR_PERIODIC_SCHEDULING_MODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAddPeriodicRequest.WakeHost = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAddPeriodicRequest.UserPriority = (CSR_PRIORITY) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_ADD_TSPEC_REQUEST_ID: - sig->u.MlmeAddTspecRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAddTspecRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAddTspecRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAddTspecRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAddTspecRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAddTspecRequest.UserPriority = (CSR_PRIORITY) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAddTspecRequest.Direction = (CSR_DIRECTION) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAddTspecRequest.PsScheme = (CSR_PS_SCHEME) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAddTspecRequest.MediumTime = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAddTspecRequest.ServiceStartTime = CSR_GET_UINT32_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT32; - sig->u.MlmeAddTspecRequest.ServiceInterval = CSR_GET_UINT32_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT32; - sig->u.MlmeAddTspecRequest.MinimumDataRate = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_ADD_MULTICAST_ADDRESS_CONFIRM_ID: - sig->u.MlmeAddMulticastAddressConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAddMulticastAddressConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAddMulticastAddressConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAddMulticastAddressConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAddMulticastAddressConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAddMulticastAddressConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_ADD_TSPEC_CONFIRM_ID: - sig->u.MlmeAddTspecConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAddTspecConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAddTspecConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAddTspecConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAddTspecConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAddTspecConfirm.UserPriority = (CSR_PRIORITY) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAddTspecConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_HL_SYNC_CANCEL_CONFIRM_ID: - sig->u.MlmeHlSyncCancelConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeHlSyncCancelConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeHlSyncCancelConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeHlSyncCancelConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeHlSyncCancelConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_SCAN_CONFIRM_ID: - sig->u.MlmeScanConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeScanConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeScanConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeScanConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeScanConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeScanConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - break; -#endif - case CSR_DEBUG_STRING_INDICATION_ID: - sig->u.DebugStringIndication.DebugMessage.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.DebugStringIndication.DebugMessage.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.DebugStringIndication.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.DebugStringIndication.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - break; -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_ADD_TEMPLATE_CONFIRM_ID: - sig->u.MlmeAddTemplateConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAddTemplateConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAddTemplateConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAddTemplateConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAddTemplateConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAddTemplateConfirm.FrameType = (CSR_FRAME_TYPE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeAddTemplateConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_BLOCKACK_ERROR_INDICATION_ID: - sig->u.MlmeBlockackErrorIndication.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeBlockackErrorIndication.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeBlockackErrorIndication.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeBlockackErrorIndication.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeBlockackErrorIndication.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeBlockackErrorIndication.ResultCode = (CSR_REASON_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - memcpy(sig->u.MlmeBlockackErrorIndication.PeerQstaAddress.x, &ptr[index], 48 / 8); - index += 48 / 8; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_SET_CONFIRM_ID: - sig->u.MlmeSetConfirm.MibAttributeValue.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeSetConfirm.MibAttributeValue.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeSetConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeSetConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeSetConfirm.Status = (CSR_MIB_STATUS) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeSetConfirm.ErrorIndex = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_MEASURE_REQUEST_ID: - sig->u.MlmeMeasureRequest.MeasurementRequestSet.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeMeasureRequest.MeasurementRequestSet.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeMeasureRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeMeasureRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeMeasureRequest.DialogToken = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_START_AGGREGATION_CONFIRM_ID: - sig->u.MlmeStartAggregationConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeStartAggregationConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeStartAggregationConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeStartAggregationConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeStartAggregationConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - memcpy(sig->u.MlmeStartAggregationConfirm.PeerQstaAddress.x, &ptr[index], 48 / 8); - index += 48 / 8; - sig->u.MlmeStartAggregationConfirm.UserPriority = (CSR_PRIORITY) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeStartAggregationConfirm.Direction = (CSR_DIRECTION) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeStartAggregationConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeStartAggregationConfirm.SequenceNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_STOP_MEASURE_CONFIRM_ID: - sig->u.MlmeStopMeasureConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeStopMeasureConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeStopMeasureConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeStopMeasureConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeStopMeasureConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeStopMeasureConfirm.DialogToken = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - break; -#endif - case CSR_MA_PACKET_CONFIRM_ID: - sig->u.MaPacketConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MaPacketConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MaPacketConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MaPacketConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MaPacketConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MaPacketConfirm.TransmissionStatus = (CSR_TRANSMISSION_STATUS) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MaPacketConfirm.RetryCount = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MaPacketConfirm.Rate = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MaPacketConfirm.HostTag = CSR_GET_UINT32_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT32; - break; -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_DEL_PERIODIC_CONFIRM_ID: - sig->u.MlmeDelPeriodicConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeDelPeriodicConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeDelPeriodicConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeDelPeriodicConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeDelPeriodicConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeDelPeriodicConfirm.PeriodicId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeDelPeriodicConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_STOP_MEASURE_REQUEST_ID: - sig->u.MlmeStopMeasureRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeStopMeasureRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeStopMeasureRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeStopMeasureRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - sig->u.MlmeStopMeasureRequest.DialogToken = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index); - index += SIZEOF_UINT16; - break; -#endif - - default: - return CSR_WIFI_HIP_RESULT_INVALID_VALUE; - } - return CSR_RESULT_SUCCESS; -} /* read_unpack_signal() */ - - -/* - * --------------------------------------------------------------------------- - * write_pack - * - * Convert a signal structure, in host-native format, to the - * little-endian wire format specified in the UniFi Host Interface - * Protocol Specification. - * - * WARNING: This function is auto-generated, DO NOT EDIT! - * - * Arguments: - * sig Pointer to signal structure to pack. - * ptr Destination buffer to pack into. - * sig_len Returns the length of the packed signal, i.e. the - * number of bytes written to ptr. - * - * Returns: - * CSR_RESULT_SUCCESS on success, - * CSR_WIFI_HIP_RESULT_INVALID_VALUE if the ID of signal was not recognised. - * --------------------------------------------------------------------------- - */ -CsrResult write_pack(const CSR_SIGNAL *sig, u8 *ptr, u16 *sig_len) -{ - s16 index = 0; - - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->SignalPrimitiveHeader.SignalId, ptr + index); - index += SIZEOF_UINT16; - - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->SignalPrimitiveHeader.ReceiverProcessId, ptr + index); - index += SIZEOF_UINT16; - - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->SignalPrimitiveHeader.SenderProcessId, ptr + index); - index += SIZEOF_UINT16; - - switch (sig->SignalPrimitiveHeader.SignalId) - { -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_SET_PACKET_FILTER_CONFIRM_ID: - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetPacketFilterConfirm.Dummydataref1.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetPacketFilterConfirm.Dummydataref1.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetPacketFilterConfirm.Dummydataref2.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetPacketFilterConfirm.Dummydataref2.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetPacketFilterConfirm.VirtualInterfaceIdentifier, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetPacketFilterConfirm.ResultCode, ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_SETKEYS_CONFIRM_ID: - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetkeysConfirm.Dummydataref1.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetkeysConfirm.Dummydataref1.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetkeysConfirm.Dummydataref2.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetkeysConfirm.Dummydataref2.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetkeysConfirm.VirtualInterfaceIdentifier, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetkeysConfirm.ResultCode, ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_CONFIG_QUEUE_CONFIRM_ID: - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConfigQueueConfirm.Dummydataref1.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConfigQueueConfirm.Dummydataref1.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConfigQueueConfirm.Dummydataref2.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConfigQueueConfirm.Dummydataref2.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConfigQueueConfirm.ResultCode, ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_ADD_AUTONOMOUS_SCAN_CONFIRM_ID: - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddAutonomousScanConfirm.Dummydataref1.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddAutonomousScanConfirm.Dummydataref1.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddAutonomousScanConfirm.Dummydataref2.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddAutonomousScanConfirm.Dummydataref2.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddAutonomousScanConfirm.VirtualInterfaceIdentifier, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddAutonomousScanConfirm.ResultCode, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddAutonomousScanConfirm.AutonomousScanId, ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_ADD_BLACKOUT_CONFIRM_ID: - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddBlackoutConfirm.Dummydataref1.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddBlackoutConfirm.Dummydataref1.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddBlackoutConfirm.Dummydataref2.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddBlackoutConfirm.Dummydataref2.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddBlackoutConfirm.VirtualInterfaceIdentifier, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddBlackoutConfirm.BlackoutId, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddBlackoutConfirm.ResultCode, ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_DEL_BLACKOUT_REQUEST_ID: - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelBlackoutRequest.Dummydataref1.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelBlackoutRequest.Dummydataref1.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelBlackoutRequest.Dummydataref2.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelBlackoutRequest.Dummydataref2.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelBlackoutRequest.VirtualInterfaceIdentifier, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelBlackoutRequest.BlackoutId, ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_GET_KEY_SEQUENCE_CONFIRM_ID: - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetKeySequenceConfirm.Dummydataref1.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetKeySequenceConfirm.Dummydataref1.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetKeySequenceConfirm.Dummydataref2.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetKeySequenceConfirm.Dummydataref2.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetKeySequenceConfirm.VirtualInterfaceIdentifier, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetKeySequenceConfirm.ResultCode, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetKeySequenceConfirm.SequenceNumber[0], ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetKeySequenceConfirm.SequenceNumber[1], ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetKeySequenceConfirm.SequenceNumber[2], ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetKeySequenceConfirm.SequenceNumber[3], ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetKeySequenceConfirm.SequenceNumber[4], ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetKeySequenceConfirm.SequenceNumber[5], ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetKeySequenceConfirm.SequenceNumber[6], ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetKeySequenceConfirm.SequenceNumber[7], ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_SM_START_CONFIRM_ID: - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSmStartConfirm.Dummydataref1.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSmStartConfirm.Dummydataref1.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSmStartConfirm.Dummydataref2.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSmStartConfirm.Dummydataref2.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSmStartConfirm.VirtualInterfaceIdentifier, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSmStartConfirm.ResultCode, ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_STOP_AGGREGATION_CONFIRM_ID: - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopAggregationConfirm.Dummydataref1.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopAggregationConfirm.Dummydataref1.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopAggregationConfirm.Dummydataref2.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopAggregationConfirm.Dummydataref2.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopAggregationConfirm.VirtualInterfaceIdentifier, ptr + index); - index += SIZEOF_UINT16; - memcpy(ptr + index, sig->u.MlmeStopAggregationConfirm.PeerQstaAddress.x, 48 / 8); - index += 48 / 8; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopAggregationConfirm.UserPriority, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopAggregationConfirm.Direction, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopAggregationConfirm.ResultCode, ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_DEL_TSPEC_REQUEST_ID: - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTspecRequest.Dummydataref1.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTspecRequest.Dummydataref1.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTspecRequest.Dummydataref2.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTspecRequest.Dummydataref2.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTspecRequest.VirtualInterfaceIdentifier, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTspecRequest.UserPriority, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTspecRequest.Direction, ptr + index); - index += SIZEOF_UINT16; - break; -#endif - case CSR_DEBUG_WORD16_INDICATION_ID: - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugWord16Indication.Dummydataref1.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugWord16Indication.Dummydataref1.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugWord16Indication.Dummydataref2.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugWord16Indication.Dummydataref2.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugWord16Indication.DebugWords[0], ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugWord16Indication.DebugWords[1], ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugWord16Indication.DebugWords[2], ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugWord16Indication.DebugWords[3], ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugWord16Indication.DebugWords[4], ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugWord16Indication.DebugWords[5], ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugWord16Indication.DebugWords[6], ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugWord16Indication.DebugWords[7], ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugWord16Indication.DebugWords[8], ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugWord16Indication.DebugWords[9], ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugWord16Indication.DebugWords[10], ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugWord16Indication.DebugWords[11], ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugWord16Indication.DebugWords[12], ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugWord16Indication.DebugWords[13], ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugWord16Indication.DebugWords[14], ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugWord16Indication.DebugWords[15], ptr + index); - index += SIZEOF_UINT16; - break; - case CSR_DEBUG_GENERIC_CONFIRM_ID: - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericConfirm.DebugVariable.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericConfirm.DebugVariable.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericConfirm.Dummydataref2.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericConfirm.Dummydataref2.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericConfirm.DebugWords[0], ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericConfirm.DebugWords[1], ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericConfirm.DebugWords[2], ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericConfirm.DebugWords[3], ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericConfirm.DebugWords[4], ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericConfirm.DebugWords[5], ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericConfirm.DebugWords[6], ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericConfirm.DebugWords[7], ptr + index); - index += SIZEOF_UINT16; - break; - case CSR_MA_PACKET_INDICATION_ID: - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketIndication.Data.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketIndication.Data.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketIndication.Dummydataref2.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketIndication.Dummydataref2.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketIndication.VirtualInterfaceIdentifier, ptr + index); - index += SIZEOF_UINT16; - memcpy(ptr + index, sig->u.MaPacketIndication.LocalTime.x, 64 / 8); - index += 64 / 8; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketIndication.Ifindex, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketIndication.Channel, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketIndication.ReceptionStatus, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketIndication.Rssi, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketIndication.Snr, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketIndication.ReceivedRate, ptr + index); - index += SIZEOF_UINT16; - break; - case CSR_MLME_SET_TIM_REQUEST_ID: - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetTimRequest.Dummydataref1.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetTimRequest.Dummydataref1.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetTimRequest.Dummydataref2.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetTimRequest.Dummydataref2.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetTimRequest.VirtualInterfaceIdentifier, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetTimRequest.AssociationId, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetTimRequest.TimValue, ptr + index); - index += SIZEOF_UINT16; - break; -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_CONNECTED_INDICATION_ID: - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConnectedIndication.Dummydataref1.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConnectedIndication.Dummydataref1.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConnectedIndication.Dummydataref2.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConnectedIndication.Dummydataref2.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConnectedIndication.VirtualInterfaceIdentifier, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConnectedIndication.ConnectionStatus, ptr + index); - index += SIZEOF_UINT16; - memcpy(ptr + index, sig->u.MlmeConnectedIndication.PeerMacAddress.x, 48 / 8); - index += 48 / 8; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_DEL_RX_TRIGGER_REQUEST_ID: - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelRxTriggerRequest.Dummydataref1.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelRxTriggerRequest.Dummydataref1.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelRxTriggerRequest.Dummydataref2.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelRxTriggerRequest.Dummydataref2.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelRxTriggerRequest.VirtualInterfaceIdentifier, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelRxTriggerRequest.TriggerId, ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_TRIGGERED_GET_INDICATION_ID: - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeTriggeredGetIndication.MibAttributeValue.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeTriggeredGetIndication.MibAttributeValue.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeTriggeredGetIndication.Dummydataref2.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeTriggeredGetIndication.Dummydataref2.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeTriggeredGetIndication.VirtualInterfaceIdentifier, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeTriggeredGetIndication.Status, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeTriggeredGetIndication.ErrorIndex, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeTriggeredGetIndication.TriggeredId, ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_SCAN_REQUEST_ID: - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeScanRequest.ChannelList.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeScanRequest.ChannelList.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeScanRequest.InformationElements.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeScanRequest.InformationElements.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeScanRequest.VirtualInterfaceIdentifier, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeScanRequest.Ifindex, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeScanRequest.ScanType, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT32_TO_LITTLE_ENDIAN(sig->u.MlmeScanRequest.ProbeDelay, ptr + index); - index += SIZEOF_UINT32; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeScanRequest.MinChannelTime, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeScanRequest.MaxChannelTime, ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_DELETEKEYS_CONFIRM_ID: - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDeletekeysConfirm.Dummydataref1.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDeletekeysConfirm.Dummydataref1.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDeletekeysConfirm.Dummydataref2.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDeletekeysConfirm.Dummydataref2.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDeletekeysConfirm.VirtualInterfaceIdentifier, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDeletekeysConfirm.ResultCode, ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_GET_NEXT_REQUEST_ID: - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetNextRequest.MibAttribute.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetNextRequest.MibAttribute.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetNextRequest.Dummydataref2.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetNextRequest.Dummydataref2.DataLength, ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_SET_CHANNEL_CONFIRM_ID: - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetChannelConfirm.Dummydataref1.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetChannelConfirm.Dummydataref1.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetChannelConfirm.Dummydataref2.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetChannelConfirm.Dummydataref2.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetChannelConfirm.VirtualInterfaceIdentifier, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetChannelConfirm.ResultCode, ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_START_AGGREGATION_REQUEST_ID: - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStartAggregationRequest.Dummydataref1.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStartAggregationRequest.Dummydataref1.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStartAggregationRequest.Dummydataref2.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStartAggregationRequest.Dummydataref2.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStartAggregationRequest.VirtualInterfaceIdentifier, ptr + index); - index += SIZEOF_UINT16; - memcpy(ptr + index, sig->u.MlmeStartAggregationRequest.PeerQstaAddress.x, 48 / 8); - index += 48 / 8; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStartAggregationRequest.UserPriority, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStartAggregationRequest.Direction, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStartAggregationRequest.StartingSequenceNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStartAggregationRequest.BufferSize, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStartAggregationRequest.BlockAckTimeout, ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_HL_SYNC_REQUEST_ID: - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeHlSyncRequest.Dummydataref1.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeHlSyncRequest.Dummydataref1.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeHlSyncRequest.Dummydataref2.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeHlSyncRequest.Dummydataref2.DataLength, ptr + index); - index += SIZEOF_UINT16; - memcpy(ptr + index, sig->u.MlmeHlSyncRequest.GroupAddress.x, 48 / 8); - index += 48 / 8; - break; -#endif - case CSR_DEBUG_GENERIC_REQUEST_ID: - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericRequest.DebugVariable.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericRequest.DebugVariable.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericRequest.Dummydataref2.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericRequest.Dummydataref2.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericRequest.DebugWords[0], ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericRequest.DebugWords[1], ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericRequest.DebugWords[2], ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericRequest.DebugWords[3], ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericRequest.DebugWords[4], ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericRequest.DebugWords[5], ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericRequest.DebugWords[6], ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericRequest.DebugWords[7], ptr + index); - index += SIZEOF_UINT16; - break; -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_LEAVE_CONFIRM_ID: - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeLeaveConfirm.Dummydataref1.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeLeaveConfirm.Dummydataref1.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeLeaveConfirm.Dummydataref2.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeLeaveConfirm.Dummydataref2.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeLeaveConfirm.VirtualInterfaceIdentifier, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeLeaveConfirm.ResultCode, ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_DEL_TRIGGERED_GET_REQUEST_ID: - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTriggeredGetRequest.Dummydataref1.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTriggeredGetRequest.Dummydataref1.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTriggeredGetRequest.Dummydataref2.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTriggeredGetRequest.Dummydataref2.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTriggeredGetRequest.VirtualInterfaceIdentifier, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTriggeredGetRequest.TriggeredId, ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_ADD_MULTICAST_ADDRESS_REQUEST_ID: - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddMulticastAddressRequest.Data.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddMulticastAddressRequest.Data.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddMulticastAddressRequest.Dummydataref2.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddMulticastAddressRequest.Dummydataref2.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddMulticastAddressRequest.VirtualInterfaceIdentifier, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddMulticastAddressRequest.NumberOfMulticastGroupAddresses, ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_RESET_REQUEST_ID: - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeResetRequest.Dummydataref1.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeResetRequest.Dummydataref1.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeResetRequest.Dummydataref2.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeResetRequest.Dummydataref2.DataLength, ptr + index); - index += SIZEOF_UINT16; - memcpy(ptr + index, sig->u.MlmeResetRequest.StaAddress.x, 48 / 8); - index += 48 / 8; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeResetRequest.SetDefaultMib, ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_SCAN_CANCEL_REQUEST_ID: - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeScanCancelRequest.Dummydataref1.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeScanCancelRequest.Dummydataref1.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeScanCancelRequest.Dummydataref2.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeScanCancelRequest.Dummydataref2.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeScanCancelRequest.VirtualInterfaceIdentifier, ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_ADD_TRIGGERED_GET_CONFIRM_ID: - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTriggeredGetConfirm.Dummydataref1.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTriggeredGetConfirm.Dummydataref1.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTriggeredGetConfirm.Dummydataref2.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTriggeredGetConfirm.Dummydataref2.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTriggeredGetConfirm.VirtualInterfaceIdentifier, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTriggeredGetConfirm.ResultCode, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTriggeredGetConfirm.TriggeredId, ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_SET_PACKET_FILTER_REQUEST_ID: - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetPacketFilterRequest.InformationElements.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetPacketFilterRequest.InformationElements.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetPacketFilterRequest.Dummydataref2.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetPacketFilterRequest.Dummydataref2.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetPacketFilterRequest.VirtualInterfaceIdentifier, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetPacketFilterRequest.PacketFilterMode, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT32_TO_LITTLE_ENDIAN(sig->u.MlmeSetPacketFilterRequest.ArpFilterAddress, ptr + index); - index += SIZEOF_UINT32; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_DEL_RX_TRIGGER_CONFIRM_ID: - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelRxTriggerConfirm.Dummydataref1.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelRxTriggerConfirm.Dummydataref1.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelRxTriggerConfirm.Dummydataref2.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelRxTriggerConfirm.Dummydataref2.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelRxTriggerConfirm.VirtualInterfaceIdentifier, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelRxTriggerConfirm.TriggerId, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelRxTriggerConfirm.ResultCode, ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_CONNECT_STATUS_REQUEST_ID: - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConnectStatusRequest.InformationElements.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConnectStatusRequest.InformationElements.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConnectStatusRequest.Dummydataref2.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConnectStatusRequest.Dummydataref2.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConnectStatusRequest.VirtualInterfaceIdentifier, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConnectStatusRequest.ConnectionStatus, ptr + index); - index += SIZEOF_UINT16; - memcpy(ptr + index, sig->u.MlmeConnectStatusRequest.StaAddress.x, 48 / 8); - index += 48 / 8; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConnectStatusRequest.AssociationId, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConnectStatusRequest.AssociationCapabilityInformation, ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_LEAVE_REQUEST_ID: - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeLeaveRequest.Dummydataref1.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeLeaveRequest.Dummydataref1.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeLeaveRequest.Dummydataref2.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeLeaveRequest.Dummydataref2.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeLeaveRequest.VirtualInterfaceIdentifier, ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_CONFIG_QUEUE_REQUEST_ID: - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConfigQueueRequest.Dummydataref1.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConfigQueueRequest.Dummydataref1.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConfigQueueRequest.Dummydataref2.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConfigQueueRequest.Dummydataref2.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConfigQueueRequest.QueueIndex, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConfigQueueRequest.Aifs, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConfigQueueRequest.Cwmin, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConfigQueueRequest.Cwmax, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConfigQueueRequest.TxopLimit, ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_DEL_TSPEC_CONFIRM_ID: - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTspecConfirm.Dummydataref1.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTspecConfirm.Dummydataref1.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTspecConfirm.Dummydataref2.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTspecConfirm.Dummydataref2.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTspecConfirm.VirtualInterfaceIdentifier, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTspecConfirm.UserPriority, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTspecConfirm.ResultCode, ptr + index); - index += SIZEOF_UINT16; - break; -#endif - case CSR_MLME_SET_TIM_CONFIRM_ID: - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetTimConfirm.Dummydataref1.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetTimConfirm.Dummydataref1.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetTimConfirm.Dummydataref2.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetTimConfirm.Dummydataref2.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetTimConfirm.VirtualInterfaceIdentifier, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetTimConfirm.ResultCode, ptr + index); - index += SIZEOF_UINT16; - break; -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_MEASURE_INDICATION_ID: - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeMeasureIndication.MeasurementReportSet.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeMeasureIndication.MeasurementReportSet.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeMeasureIndication.Dummydataref2.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeMeasureIndication.Dummydataref2.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeMeasureIndication.DialogToken, ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_DEL_BLACKOUT_CONFIRM_ID: - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelBlackoutConfirm.Dummydataref1.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelBlackoutConfirm.Dummydataref1.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelBlackoutConfirm.Dummydataref2.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelBlackoutConfirm.Dummydataref2.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelBlackoutConfirm.VirtualInterfaceIdentifier, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelBlackoutConfirm.BlackoutId, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelBlackoutConfirm.ResultCode, ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_DEL_TRIGGERED_GET_CONFIRM_ID: - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTriggeredGetConfirm.Dummydataref1.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTriggeredGetConfirm.Dummydataref1.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTriggeredGetConfirm.Dummydataref2.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTriggeredGetConfirm.Dummydataref2.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTriggeredGetConfirm.VirtualInterfaceIdentifier, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTriggeredGetConfirm.ResultCode, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTriggeredGetConfirm.TriggeredId, ptr + index); - index += SIZEOF_UINT16; - break; -#endif - case CSR_DEBUG_GENERIC_INDICATION_ID: - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericIndication.DebugVariable.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericIndication.DebugVariable.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericIndication.Dummydataref2.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericIndication.Dummydataref2.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericIndication.DebugWords[0], ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericIndication.DebugWords[1], ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericIndication.DebugWords[2], ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericIndication.DebugWords[3], ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericIndication.DebugWords[4], ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericIndication.DebugWords[5], ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericIndication.DebugWords[6], ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericIndication.DebugWords[7], ptr + index); - index += SIZEOF_UINT16; - break; - case CSR_MA_PACKET_CANCEL_REQUEST_ID: - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketCancelRequest.Dummydataref1.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketCancelRequest.Dummydataref1.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketCancelRequest.Dummydataref2.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketCancelRequest.Dummydataref2.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketCancelRequest.VirtualInterfaceIdentifier, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT32_TO_LITTLE_ENDIAN(sig->u.MaPacketCancelRequest.HostTag, ptr + index); - index += SIZEOF_UINT32; - break; -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_MODIFY_BSS_PARAMETER_CONFIRM_ID: - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeModifyBssParameterConfirm.Dummydataref1.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeModifyBssParameterConfirm.Dummydataref1.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeModifyBssParameterConfirm.Dummydataref2.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeModifyBssParameterConfirm.Dummydataref2.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeModifyBssParameterConfirm.VirtualInterfaceIdentifier, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeModifyBssParameterConfirm.ResultCode, ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_PAUSE_AUTONOMOUS_SCAN_CONFIRM_ID: - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePauseAutonomousScanConfirm.Dummydataref1.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePauseAutonomousScanConfirm.Dummydataref1.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePauseAutonomousScanConfirm.Dummydataref2.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePauseAutonomousScanConfirm.Dummydataref2.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePauseAutonomousScanConfirm.VirtualInterfaceIdentifier, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePauseAutonomousScanConfirm.ResultCode, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePauseAutonomousScanConfirm.AutonomousScanId, ptr + index); - index += SIZEOF_UINT16; - break; -#endif - case CSR_MA_PACKET_REQUEST_ID: - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketRequest.Data.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketRequest.Data.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketRequest.Dummydataref2.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketRequest.Dummydataref2.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketRequest.VirtualInterfaceIdentifier, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketRequest.TransmitRate, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT32_TO_LITTLE_ENDIAN(sig->u.MaPacketRequest.HostTag, ptr + index); - index += SIZEOF_UINT32; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketRequest.Priority, ptr + index); - index += SIZEOF_UINT16; - memcpy(ptr + index, sig->u.MaPacketRequest.Ra.x, 48 / 8); - index += 48 / 8; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketRequest.TransmissionControl, ptr + index); - index += SIZEOF_UINT16; - break; -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_MODIFY_BSS_PARAMETER_REQUEST_ID: - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeModifyBssParameterRequest.Data.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeModifyBssParameterRequest.Data.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeModifyBssParameterRequest.Dummydataref2.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeModifyBssParameterRequest.Dummydataref2.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeModifyBssParameterRequest.VirtualInterfaceIdentifier, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeModifyBssParameterRequest.BeaconPeriod, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeModifyBssParameterRequest.DtimPeriod, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeModifyBssParameterRequest.CapabilityInformation, ptr + index); - index += SIZEOF_UINT16; - memcpy(ptr + index, sig->u.MlmeModifyBssParameterRequest.Bssid.x, 48 / 8); - index += 48 / 8; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeModifyBssParameterRequest.RtsThreshold, ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_ADD_RX_TRIGGER_REQUEST_ID: - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddRxTriggerRequest.InformationElements.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddRxTriggerRequest.InformationElements.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddRxTriggerRequest.Dummydataref2.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddRxTriggerRequest.Dummydataref2.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddRxTriggerRequest.VirtualInterfaceIdentifier, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddRxTriggerRequest.TriggerId, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddRxTriggerRequest.Priority, ptr + index); - index += SIZEOF_UINT16; - break; -#endif - case CSR_MA_VIF_AVAILABILITY_INDICATION_ID: - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaVifAvailabilityIndication.Dummydataref1.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaVifAvailabilityIndication.Dummydataref1.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaVifAvailabilityIndication.Dummydataref2.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaVifAvailabilityIndication.Dummydataref2.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaVifAvailabilityIndication.VirtualInterfaceIdentifier, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaVifAvailabilityIndication.Multicast, ptr + index); - index += SIZEOF_UINT16; - break; -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_HL_SYNC_CANCEL_REQUEST_ID: - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeHlSyncCancelRequest.Dummydataref1.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeHlSyncCancelRequest.Dummydataref1.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeHlSyncCancelRequest.Dummydataref2.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeHlSyncCancelRequest.Dummydataref2.DataLength, ptr + index); - index += SIZEOF_UINT16; - memcpy(ptr + index, sig->u.MlmeHlSyncCancelRequest.GroupAddress.x, 48 / 8); - index += 48 / 8; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_DEL_AUTONOMOUS_SCAN_REQUEST_ID: - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelAutonomousScanRequest.Dummydataref1.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelAutonomousScanRequest.Dummydataref1.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelAutonomousScanRequest.Dummydataref2.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelAutonomousScanRequest.Dummydataref2.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelAutonomousScanRequest.VirtualInterfaceIdentifier, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelAutonomousScanRequest.AutonomousScanId, ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_BLACKOUT_ENDED_INDICATION_ID: - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeBlackoutEndedIndication.Dummydataref1.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeBlackoutEndedIndication.Dummydataref1.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeBlackoutEndedIndication.Dummydataref2.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeBlackoutEndedIndication.Dummydataref2.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeBlackoutEndedIndication.VirtualInterfaceIdentifier, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeBlackoutEndedIndication.BlackoutId, ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_AUTONOMOUS_SCAN_DONE_INDICATION_ID: - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAutonomousScanDoneIndication.Dummydataref1.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAutonomousScanDoneIndication.Dummydataref1.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAutonomousScanDoneIndication.Dummydataref2.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAutonomousScanDoneIndication.Dummydataref2.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAutonomousScanDoneIndication.VirtualInterfaceIdentifier, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAutonomousScanDoneIndication.ResultCode, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAutonomousScanDoneIndication.AutonomousScanId, ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_GET_KEY_SEQUENCE_REQUEST_ID: - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetKeySequenceRequest.Dummydataref1.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetKeySequenceRequest.Dummydataref1.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetKeySequenceRequest.Dummydataref2.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetKeySequenceRequest.Dummydataref2.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetKeySequenceRequest.VirtualInterfaceIdentifier, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetKeySequenceRequest.KeyId, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetKeySequenceRequest.KeyType, ptr + index); - index += SIZEOF_UINT16; - memcpy(ptr + index, sig->u.MlmeGetKeySequenceRequest.Address.x, 48 / 8); - index += 48 / 8; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_SET_CHANNEL_REQUEST_ID: - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetChannelRequest.Dummydataref1.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetChannelRequest.Dummydataref1.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetChannelRequest.Dummydataref2.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetChannelRequest.Dummydataref2.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetChannelRequest.VirtualInterfaceIdentifier, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetChannelRequest.Ifindex, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetChannelRequest.Channel, ptr + index); - index += SIZEOF_UINT16; - memcpy(ptr + index, sig->u.MlmeSetChannelRequest.Address.x, 48 / 8); - index += 48 / 8; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetChannelRequest.AvailabilityDuration, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetChannelRequest.AvailabilityInterval, ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_MEASURE_CONFIRM_ID: - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeMeasureConfirm.Dummydataref1.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeMeasureConfirm.Dummydataref1.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeMeasureConfirm.Dummydataref2.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeMeasureConfirm.Dummydataref2.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeMeasureConfirm.ResultCode, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeMeasureConfirm.DialogToken, ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_ADD_TRIGGERED_GET_REQUEST_ID: - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTriggeredGetRequest.MibAttribute.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTriggeredGetRequest.MibAttribute.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTriggeredGetRequest.Dummydataref2.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTriggeredGetRequest.Dummydataref2.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTriggeredGetRequest.VirtualInterfaceIdentifier, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTriggeredGetRequest.TriggeredId, ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_AUTONOMOUS_SCAN_LOSS_INDICATION_ID: - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAutonomousScanLossIndication.Dummydataref1.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAutonomousScanLossIndication.Dummydataref1.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAutonomousScanLossIndication.Dummydataref2.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAutonomousScanLossIndication.Dummydataref2.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAutonomousScanLossIndication.VirtualInterfaceIdentifier, ptr + index); - index += SIZEOF_UINT16; - memcpy(ptr + index, sig->u.MlmeAutonomousScanLossIndication.Bssid.x, 48 / 8); - index += 48 / 8; - break; -#endif - case CSR_MA_VIF_AVAILABILITY_RESPONSE_ID: - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaVifAvailabilityResponse.Dummydataref1.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaVifAvailabilityResponse.Dummydataref1.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaVifAvailabilityResponse.Dummydataref2.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaVifAvailabilityResponse.Dummydataref2.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaVifAvailabilityResponse.VirtualInterfaceIdentifier, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaVifAvailabilityResponse.ResultCode, ptr + index); - index += SIZEOF_UINT16; - break; -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_ADD_TEMPLATE_REQUEST_ID: - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTemplateRequest.Data1.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTemplateRequest.Data1.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTemplateRequest.Data2.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTemplateRequest.Data2.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTemplateRequest.VirtualInterfaceIdentifier, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTemplateRequest.FrameType, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTemplateRequest.MinTransmitRate, ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_POWERMGT_CONFIRM_ID: - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePowermgtConfirm.Dummydataref1.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePowermgtConfirm.Dummydataref1.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePowermgtConfirm.Dummydataref2.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePowermgtConfirm.Dummydataref2.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePowermgtConfirm.VirtualInterfaceIdentifier, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePowermgtConfirm.ResultCode, ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_ADD_PERIODIC_CONFIRM_ID: - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddPeriodicConfirm.Dummydataref1.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddPeriodicConfirm.Dummydataref1.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddPeriodicConfirm.Dummydataref2.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddPeriodicConfirm.Dummydataref2.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddPeriodicConfirm.VirtualInterfaceIdentifier, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddPeriodicConfirm.PeriodicId, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddPeriodicConfirm.ResultCode, ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_GET_CONFIRM_ID: - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetConfirm.MibAttributeValue.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetConfirm.MibAttributeValue.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetConfirm.Dummydataref2.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetConfirm.Dummydataref2.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetConfirm.Status, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetConfirm.ErrorIndex, ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_GET_NEXT_CONFIRM_ID: - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetNextConfirm.MibAttributeValue.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetNextConfirm.MibAttributeValue.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetNextConfirm.Dummydataref2.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetNextConfirm.Dummydataref2.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetNextConfirm.Status, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetNextConfirm.ErrorIndex, ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_STOP_AGGREGATION_REQUEST_ID: - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopAggregationRequest.Dummydataref1.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopAggregationRequest.Dummydataref1.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopAggregationRequest.Dummydataref2.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopAggregationRequest.Dummydataref2.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopAggregationRequest.VirtualInterfaceIdentifier, ptr + index); - index += SIZEOF_UINT16; - memcpy(ptr + index, sig->u.MlmeStopAggregationRequest.PeerQstaAddress.x, 48 / 8); - index += 48 / 8; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopAggregationRequest.UserPriority, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopAggregationRequest.Direction, ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_ADD_RX_TRIGGER_CONFIRM_ID: - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddRxTriggerConfirm.Dummydataref1.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddRxTriggerConfirm.Dummydataref1.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddRxTriggerConfirm.Dummydataref2.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddRxTriggerConfirm.Dummydataref2.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddRxTriggerConfirm.VirtualInterfaceIdentifier, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddRxTriggerConfirm.TriggerId, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddRxTriggerConfirm.ResultCode, ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_ADD_BLACKOUT_REQUEST_ID: - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddBlackoutRequest.Dummydataref1.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddBlackoutRequest.Dummydataref1.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddBlackoutRequest.Dummydataref2.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddBlackoutRequest.Dummydataref2.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddBlackoutRequest.VirtualInterfaceIdentifier, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddBlackoutRequest.BlackoutId, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddBlackoutRequest.BlackoutType, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddBlackoutRequest.BlackoutSource, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT32_TO_LITTLE_ENDIAN(sig->u.MlmeAddBlackoutRequest.BlackoutStartReference, ptr + index); - index += SIZEOF_UINT32; - CSR_COPY_UINT32_TO_LITTLE_ENDIAN(sig->u.MlmeAddBlackoutRequest.BlackoutPeriod, ptr + index); - index += SIZEOF_UINT32; - CSR_COPY_UINT32_TO_LITTLE_ENDIAN(sig->u.MlmeAddBlackoutRequest.BlackoutDuration, ptr + index); - index += SIZEOF_UINT32; - memcpy(ptr + index, sig->u.MlmeAddBlackoutRequest.PeerStaAddress.x, 48 / 8); - index += 48 / 8; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddBlackoutRequest.BlackoutCount, ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_DELETEKEYS_REQUEST_ID: - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDeletekeysRequest.Dummydataref1.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDeletekeysRequest.Dummydataref1.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDeletekeysRequest.Dummydataref2.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDeletekeysRequest.Dummydataref2.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDeletekeysRequest.VirtualInterfaceIdentifier, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDeletekeysRequest.KeyId, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDeletekeysRequest.KeyType, ptr + index); - index += SIZEOF_UINT16; - memcpy(ptr + index, sig->u.MlmeDeletekeysRequest.Address.x, 48 / 8); - index += 48 / 8; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_RESET_CONFIRM_ID: - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeResetConfirm.Dummydataref1.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeResetConfirm.Dummydataref1.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeResetConfirm.Dummydataref2.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeResetConfirm.Dummydataref2.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeResetConfirm.ResultCode, ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_HL_SYNC_CONFIRM_ID: - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeHlSyncConfirm.Dummydataref1.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeHlSyncConfirm.Dummydataref1.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeHlSyncConfirm.Dummydataref2.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeHlSyncConfirm.Dummydataref2.DataLength, ptr + index); - index += SIZEOF_UINT16; - memcpy(ptr + index, sig->u.MlmeHlSyncConfirm.GroupAddress.x, 48 / 8); - index += 48 / 8; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeHlSyncConfirm.ResultCode, ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_ADD_AUTONOMOUS_SCAN_REQUEST_ID: - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddAutonomousScanRequest.ChannelList.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddAutonomousScanRequest.ChannelList.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddAutonomousScanRequest.InformationElements.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddAutonomousScanRequest.InformationElements.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddAutonomousScanRequest.VirtualInterfaceIdentifier, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddAutonomousScanRequest.AutonomousScanId, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddAutonomousScanRequest.Ifindex, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddAutonomousScanRequest.ChannelStartingFactor, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddAutonomousScanRequest.ScanType, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT32_TO_LITTLE_ENDIAN(sig->u.MlmeAddAutonomousScanRequest.ProbeDelay, ptr + index); - index += SIZEOF_UINT32; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddAutonomousScanRequest.MinChannelTime, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddAutonomousScanRequest.MaxChannelTime, ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_SET_REQUEST_ID: - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetRequest.MibAttributeValue.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetRequest.MibAttributeValue.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetRequest.Dummydataref2.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetRequest.Dummydataref2.DataLength, ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_SM_START_REQUEST_ID: - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSmStartRequest.Beacon.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSmStartRequest.Beacon.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSmStartRequest.BssParameters.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSmStartRequest.BssParameters.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSmStartRequest.VirtualInterfaceIdentifier, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSmStartRequest.Ifindex, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSmStartRequest.Channel, ptr + index); - index += SIZEOF_UINT16; - memcpy(ptr + index, sig->u.MlmeSmStartRequest.InterfaceAddress.x, 48 / 8); - index += 48 / 8; - memcpy(ptr + index, sig->u.MlmeSmStartRequest.Bssid.x, 48 / 8); - index += 48 / 8; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSmStartRequest.BeaconPeriod, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSmStartRequest.DtimPeriod, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSmStartRequest.CapabilityInformation, ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_CONNECT_STATUS_CONFIRM_ID: - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConnectStatusConfirm.Dummydataref1.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConnectStatusConfirm.Dummydataref1.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConnectStatusConfirm.Dummydataref2.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConnectStatusConfirm.Dummydataref2.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConnectStatusConfirm.VirtualInterfaceIdentifier, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConnectStatusConfirm.ResultCode, ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_DEL_AUTONOMOUS_SCAN_CONFIRM_ID: - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelAutonomousScanConfirm.Dummydataref1.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelAutonomousScanConfirm.Dummydataref1.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelAutonomousScanConfirm.Dummydataref2.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelAutonomousScanConfirm.Dummydataref2.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelAutonomousScanConfirm.VirtualInterfaceIdentifier, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelAutonomousScanConfirm.ResultCode, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelAutonomousScanConfirm.AutonomousScanId, ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_DEL_PERIODIC_REQUEST_ID: - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelPeriodicRequest.Dummydataref1.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelPeriodicRequest.Dummydataref1.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelPeriodicRequest.Dummydataref2.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelPeriodicRequest.Dummydataref2.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelPeriodicRequest.VirtualInterfaceIdentifier, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelPeriodicRequest.PeriodicId, ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_SETKEYS_REQUEST_ID: - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetkeysRequest.Key.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetkeysRequest.Key.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetkeysRequest.Dummydataref2.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetkeysRequest.Dummydataref2.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetkeysRequest.VirtualInterfaceIdentifier, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetkeysRequest.Length, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetkeysRequest.KeyId, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetkeysRequest.KeyType, ptr + index); - index += SIZEOF_UINT16; - memcpy(ptr + index, sig->u.MlmeSetkeysRequest.Address.x, 48 / 8); - index += 48 / 8; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetkeysRequest.SequenceNumber[0], ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetkeysRequest.SequenceNumber[1], ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetkeysRequest.SequenceNumber[2], ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetkeysRequest.SequenceNumber[3], ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetkeysRequest.SequenceNumber[4], ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetkeysRequest.SequenceNumber[5], ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetkeysRequest.SequenceNumber[6], ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetkeysRequest.SequenceNumber[7], ptr + index); - index += SIZEOF_UINT16; - memcpy(ptr + index, &sig->u.MlmeSetkeysRequest.CipherSuiteSelector, 32 / 8); - index += 32 / 8; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_PAUSE_AUTONOMOUS_SCAN_REQUEST_ID: - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePauseAutonomousScanRequest.Dummydataref1.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePauseAutonomousScanRequest.Dummydataref1.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePauseAutonomousScanRequest.Dummydataref2.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePauseAutonomousScanRequest.Dummydataref2.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePauseAutonomousScanRequest.VirtualInterfaceIdentifier, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePauseAutonomousScanRequest.AutonomousScanId, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePauseAutonomousScanRequest.Pause, ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_GET_REQUEST_ID: - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetRequest.MibAttribute.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetRequest.MibAttribute.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetRequest.Dummydataref2.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetRequest.Dummydataref2.DataLength, ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_POWERMGT_REQUEST_ID: - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePowermgtRequest.Dummydataref1.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePowermgtRequest.Dummydataref1.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePowermgtRequest.Dummydataref2.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePowermgtRequest.Dummydataref2.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePowermgtRequest.VirtualInterfaceIdentifier, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePowermgtRequest.PowerManagementMode, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePowermgtRequest.ReceiveDtims, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePowermgtRequest.ListenInterval, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePowermgtRequest.TrafficWindow, ptr + index); - index += SIZEOF_UINT16; - break; -#endif - case CSR_MA_PACKET_ERROR_INDICATION_ID: - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketErrorIndication.Dummydataref1.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketErrorIndication.Dummydataref1.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketErrorIndication.Dummydataref2.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketErrorIndication.Dummydataref2.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketErrorIndication.VirtualInterfaceIdentifier, ptr + index); - index += SIZEOF_UINT16; - memcpy(ptr + index, sig->u.MaPacketErrorIndication.PeerQstaAddress.x, 48 / 8); - index += 48 / 8; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketErrorIndication.UserPriority, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketErrorIndication.SequenceNumber, ptr + index); - index += SIZEOF_UINT16; - break; -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_ADD_PERIODIC_REQUEST_ID: - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddPeriodicRequest.Dummydataref1.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddPeriodicRequest.Dummydataref1.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddPeriodicRequest.Dummydataref2.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddPeriodicRequest.Dummydataref2.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddPeriodicRequest.VirtualInterfaceIdentifier, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddPeriodicRequest.PeriodicId, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT32_TO_LITTLE_ENDIAN(sig->u.MlmeAddPeriodicRequest.MaximumLatency, ptr + index); - index += SIZEOF_UINT32; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddPeriodicRequest.PeriodicSchedulingMode, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddPeriodicRequest.WakeHost, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddPeriodicRequest.UserPriority, ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_ADD_TSPEC_REQUEST_ID: - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTspecRequest.Dummydataref1.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTspecRequest.Dummydataref1.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTspecRequest.Dummydataref2.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTspecRequest.Dummydataref2.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTspecRequest.VirtualInterfaceIdentifier, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTspecRequest.UserPriority, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTspecRequest.Direction, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTspecRequest.PsScheme, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTspecRequest.MediumTime, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT32_TO_LITTLE_ENDIAN(sig->u.MlmeAddTspecRequest.ServiceStartTime, ptr + index); - index += SIZEOF_UINT32; - CSR_COPY_UINT32_TO_LITTLE_ENDIAN(sig->u.MlmeAddTspecRequest.ServiceInterval, ptr + index); - index += SIZEOF_UINT32; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTspecRequest.MinimumDataRate, ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_ADD_MULTICAST_ADDRESS_CONFIRM_ID: - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddMulticastAddressConfirm.Dummydataref1.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddMulticastAddressConfirm.Dummydataref1.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddMulticastAddressConfirm.Dummydataref2.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddMulticastAddressConfirm.Dummydataref2.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddMulticastAddressConfirm.VirtualInterfaceIdentifier, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddMulticastAddressConfirm.ResultCode, ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_ADD_TSPEC_CONFIRM_ID: - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTspecConfirm.Dummydataref1.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTspecConfirm.Dummydataref1.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTspecConfirm.Dummydataref2.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTspecConfirm.Dummydataref2.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTspecConfirm.VirtualInterfaceIdentifier, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTspecConfirm.UserPriority, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTspecConfirm.ResultCode, ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_HL_SYNC_CANCEL_CONFIRM_ID: - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeHlSyncCancelConfirm.Dummydataref1.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeHlSyncCancelConfirm.Dummydataref1.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeHlSyncCancelConfirm.Dummydataref2.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeHlSyncCancelConfirm.Dummydataref2.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeHlSyncCancelConfirm.ResultCode, ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_SCAN_CONFIRM_ID: - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeScanConfirm.Dummydataref1.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeScanConfirm.Dummydataref1.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeScanConfirm.Dummydataref2.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeScanConfirm.Dummydataref2.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeScanConfirm.VirtualInterfaceIdentifier, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeScanConfirm.ResultCode, ptr + index); - index += SIZEOF_UINT16; - break; -#endif - case CSR_DEBUG_STRING_INDICATION_ID: - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugStringIndication.DebugMessage.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugStringIndication.DebugMessage.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugStringIndication.Dummydataref2.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugStringIndication.Dummydataref2.DataLength, ptr + index); - index += SIZEOF_UINT16; - break; -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_ADD_TEMPLATE_CONFIRM_ID: - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTemplateConfirm.Dummydataref1.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTemplateConfirm.Dummydataref1.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTemplateConfirm.Dummydataref2.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTemplateConfirm.Dummydataref2.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTemplateConfirm.VirtualInterfaceIdentifier, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTemplateConfirm.FrameType, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTemplateConfirm.ResultCode, ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_BLOCKACK_ERROR_INDICATION_ID: - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeBlockackErrorIndication.Dummydataref1.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeBlockackErrorIndication.Dummydataref1.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeBlockackErrorIndication.Dummydataref2.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeBlockackErrorIndication.Dummydataref2.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeBlockackErrorIndication.VirtualInterfaceIdentifier, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeBlockackErrorIndication.ResultCode, ptr + index); - index += SIZEOF_UINT16; - memcpy(ptr + index, sig->u.MlmeBlockackErrorIndication.PeerQstaAddress.x, 48 / 8); - index += 48 / 8; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_SET_CONFIRM_ID: - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetConfirm.MibAttributeValue.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetConfirm.MibAttributeValue.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetConfirm.Dummydataref2.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetConfirm.Dummydataref2.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetConfirm.Status, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetConfirm.ErrorIndex, ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_MEASURE_REQUEST_ID: - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeMeasureRequest.MeasurementRequestSet.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeMeasureRequest.MeasurementRequestSet.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeMeasureRequest.Dummydataref2.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeMeasureRequest.Dummydataref2.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeMeasureRequest.DialogToken, ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_START_AGGREGATION_CONFIRM_ID: - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStartAggregationConfirm.Dummydataref1.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStartAggregationConfirm.Dummydataref1.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStartAggregationConfirm.Dummydataref2.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStartAggregationConfirm.Dummydataref2.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStartAggregationConfirm.VirtualInterfaceIdentifier, ptr + index); - index += SIZEOF_UINT16; - memcpy(ptr + index, sig->u.MlmeStartAggregationConfirm.PeerQstaAddress.x, 48 / 8); - index += 48 / 8; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStartAggregationConfirm.UserPriority, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStartAggregationConfirm.Direction, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStartAggregationConfirm.ResultCode, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStartAggregationConfirm.SequenceNumber, ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_STOP_MEASURE_CONFIRM_ID: - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopMeasureConfirm.Dummydataref1.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopMeasureConfirm.Dummydataref1.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopMeasureConfirm.Dummydataref2.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopMeasureConfirm.Dummydataref2.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopMeasureConfirm.ResultCode, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopMeasureConfirm.DialogToken, ptr + index); - index += SIZEOF_UINT16; - break; -#endif - case CSR_MA_PACKET_CONFIRM_ID: - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketConfirm.Dummydataref1.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketConfirm.Dummydataref1.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketConfirm.Dummydataref2.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketConfirm.Dummydataref2.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketConfirm.VirtualInterfaceIdentifier, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketConfirm.TransmissionStatus, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketConfirm.RetryCount, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketConfirm.Rate, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT32_TO_LITTLE_ENDIAN(sig->u.MaPacketConfirm.HostTag, ptr + index); - index += SIZEOF_UINT32; - break; -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_DEL_PERIODIC_CONFIRM_ID: - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelPeriodicConfirm.Dummydataref1.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelPeriodicConfirm.Dummydataref1.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelPeriodicConfirm.Dummydataref2.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelPeriodicConfirm.Dummydataref2.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelPeriodicConfirm.VirtualInterfaceIdentifier, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelPeriodicConfirm.PeriodicId, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelPeriodicConfirm.ResultCode, ptr + index); - index += SIZEOF_UINT16; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_STOP_MEASURE_REQUEST_ID: - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopMeasureRequest.Dummydataref1.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopMeasureRequest.Dummydataref1.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopMeasureRequest.Dummydataref2.SlotNumber, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopMeasureRequest.Dummydataref2.DataLength, ptr + index); - index += SIZEOF_UINT16; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopMeasureRequest.DialogToken, ptr + index); - index += SIZEOF_UINT16; - break; -#endif - - default: - return CSR_WIFI_HIP_RESULT_INVALID_VALUE; - } - - *sig_len = index; - - return CSR_RESULT_SUCCESS; -} /* write_pack() */ - - diff --git a/drivers/staging/csr/csr_wifi_hip_send.c b/drivers/staging/csr/csr_wifi_hip_send.c deleted file mode 100644 index 76429e5e77cf..000000000000 --- a/drivers/staging/csr/csr_wifi_hip_send.c +++ /dev/null @@ -1,415 +0,0 @@ -/***************************************************************************** - - (c) Cambridge Silicon Radio Limited 2011 - All rights reserved and confidential information of CSR - - Refer to LICENSE.txt included with this source for details - on the license terms. - -*****************************************************************************/ - -/* - * *************************************************************************** - * - * FILE: csr_wifi_hip_send.c - * - * PURPOSE: - * Code for adding a signal request to the from-host queue. - * When the driver bottom-half is run, it will take requests from the - * queue and pass them to the UniFi. - * - * *************************************************************************** - */ -#include "csr_wifi_hip_unifi.h" -#include "csr_wifi_hip_conversions.h" -#include "csr_wifi_hip_sigs.h" -#include "csr_wifi_hip_card.h" - -unifi_TrafficQueue unifi_frame_priority_to_queue(CSR_PRIORITY priority) -{ - switch (priority) - { - case CSR_QOS_UP0: - case CSR_QOS_UP3: - return UNIFI_TRAFFIC_Q_BE; - case CSR_QOS_UP1: - case CSR_QOS_UP2: - return UNIFI_TRAFFIC_Q_BK; - case CSR_QOS_UP4: - case CSR_QOS_UP5: - return UNIFI_TRAFFIC_Q_VI; - case CSR_QOS_UP6: - case CSR_QOS_UP7: - case CSR_MANAGEMENT: - return UNIFI_TRAFFIC_Q_VO; - default: - return UNIFI_TRAFFIC_Q_BE; - } -} - - -CSR_PRIORITY unifi_get_default_downgrade_priority(unifi_TrafficQueue queue) -{ - switch (queue) - { - case UNIFI_TRAFFIC_Q_BE: - return CSR_QOS_UP0; - case UNIFI_TRAFFIC_Q_BK: - return CSR_QOS_UP1; - case UNIFI_TRAFFIC_Q_VI: - return CSR_QOS_UP5; - case UNIFI_TRAFFIC_Q_VO: - return CSR_QOS_UP6; - default: - return CSR_QOS_UP0; - } -} - - -/* - * --------------------------------------------------------------------------- - * send_signal - * - * This function queues a signal for sending to UniFi. It first checks - * that there is space on the fh_signal_queue for another entry, then - * claims any bulk data slots required and copies data into them. Then - * increments the fh_signal_queue write count. - * - * The fh_signal_queue is later processed by the driver bottom half - * (in unifi_bh()). - * - * This function call unifi_pause_xmit() to pause the flow of data plane - * packets when: - * - the fh_signal_queue ring buffer is full - * - there are less than UNIFI_MAX_DATA_REFERENCES (2) bulk data - * slots available. - * - * Arguments: - * card Pointer to card context structure - * sigptr Pointer to the signal to write to UniFi. - * siglen Number of bytes pointer to by sigptr. - * bulkdata Array of pointers to an associated bulk data. - * sigq To which from-host queue to add the signal. - * - * Returns: - * CSR_RESULT_SUCCESS on success - * CSR_WIFI_HIP_RESULT_NO_SPACE if there were insufficient data slots or - * no free signal queue entry - * - * Notes: - * Calls unifi_pause_xmit() when the last slots are used. - * --------------------------------------------------------------------------- - */ -static CsrResult send_signal(card_t *card, const u8 *sigptr, u32 siglen, - const bulk_data_param_t *bulkdata, - q_t *sigq, u32 priority_q, u32 run_bh) -{ - u16 i, data_slot_size; - card_signal_t *csptr; - s16 qe; - CsrResult r; - s16 debug_print = 0; - - data_slot_size = CardGetDataSlotSize(card); - - /* Check that the fh_data_queue has a free slot */ - if (!CSR_WIFI_HIP_Q_SLOTS_FREE(sigq)) - { - unifi_trace(card->ospriv, UDBG3, "send_signal: %s full\n", sigq->name); - - return CSR_WIFI_HIP_RESULT_NO_SPACE; - } - - /* - * Now add the signal to the From Host signal queue - */ - /* Get next slot on queue */ - qe = CSR_WIFI_HIP_Q_NEXT_W_SLOT(sigq); - csptr = CSR_WIFI_HIP_Q_SLOT_DATA(sigq, qe); - - /* Make up the card_signal struct */ - csptr->signal_length = (u16)siglen; - memcpy((void *)csptr->sigbuf, (void *)sigptr, siglen); - - for (i = 0; i < UNIFI_MAX_DATA_REFERENCES; ++i) - { - if ((bulkdata != NULL) && (bulkdata->d[i].data_length != 0)) - { - u32 datalen = bulkdata->d[i].data_length; - - /* Make sure data will fit in a bulk data slot */ - if (bulkdata->d[i].os_data_ptr == NULL) - { - unifi_error(card->ospriv, "send_signal - NULL bulkdata[%d]\n", i); - debug_print++; - csptr->bulkdata[i].data_length = 0; - } - else - { - if (datalen > data_slot_size) - { - unifi_error(card->ospriv, - "send_signal - Invalid data length %u (@%p), " - "truncating\n", - datalen, bulkdata->d[i].os_data_ptr); - datalen = data_slot_size; - debug_print++; - } - /* Store the bulk data info in the soft queue. */ - csptr->bulkdata[i].os_data_ptr = (u8 *)bulkdata->d[i].os_data_ptr; - csptr->bulkdata[i].os_net_buf_ptr = (u8 *)bulkdata->d[i].os_net_buf_ptr; - csptr->bulkdata[i].net_buf_length = bulkdata->d[i].net_buf_length; - csptr->bulkdata[i].data_length = datalen; - } - } - else - { - UNIFI_INIT_BULK_DATA(&csptr->bulkdata[i]); - } - } - - if (debug_print) - { - const u8 *sig = sigptr; - - unifi_error(card->ospriv, "Signal(%d): %*ph\n", siglen, - 16, sig); - unifi_error(card->ospriv, "Bulkdata pointer %p(%d), %p(%d)\n", - bulkdata != NULL?bulkdata->d[0].os_data_ptr : NULL, - bulkdata != NULL?bulkdata->d[0].data_length : 0, - bulkdata != NULL?bulkdata->d[1].os_data_ptr : NULL, - bulkdata != NULL?bulkdata->d[1].data_length : 0); - } - - /* Advance the written count to say there is a new entry */ - CSR_WIFI_HIP_Q_INC_W(sigq); - - /* - * Set the flag to say reason for waking was a host request. - * Then ask the OS layer to run the unifi_bh. - */ - if (run_bh == 1) - { - card->bh_reason_host = 1; - r = unifi_run_bh(card->ospriv); - if (r != CSR_RESULT_SUCCESS) - { - unifi_error(card->ospriv, "failed to run bh.\n"); - card->bh_reason_host = 0; - - /* - * The bulk data buffer will be freed by the caller. - * We need to invalidate the description of the bulk data in our - * soft queue, to prevent the core freeing the bulk data again later. - */ - for (i = 0; i < UNIFI_MAX_DATA_REFERENCES; ++i) - { - if (csptr->bulkdata[i].data_length != 0) - { - csptr->bulkdata[i].os_data_ptr = csptr->bulkdata[i].os_net_buf_ptr = NULL; - csptr->bulkdata[i].net_buf_length = csptr->bulkdata[i].data_length = 0; - } - } - return r; - } - } - else - { - unifi_error(card->ospriv, "run_bh=%d, bh not called.\n", run_bh); - } - - /* - * Have we used up all the fh signal list entries? - */ - if (CSR_WIFI_HIP_Q_SLOTS_FREE(sigq) == 0) - { - /* We have filled the queue, so stop the upper layer. The command queue - * is an exception, as suspending due to that being full could delay - * resume/retry until new commands or data are received. - */ - if (sigq != &card->fh_command_queue) - { - /* - * Must call unifi_pause_xmit() *before* setting the paused flag. - * (the unifi_pause_xmit call should not be after setting the flag because of the possibility of being interrupted - * by the bh thread between our setting the flag and the call to unifi_pause_xmit() - * If bh thread then cleared the flag, we would end up paused, but without the flag set) - * Instead, setting it afterwards means that if this thread is interrupted by the bh thread - * the pause flag is still guaranteed to end up set - * However the potential deadlock now is that if bh thread emptied the queue and cleared the flag before this thread's - * call to unifi_pause_xmit(), then bh thread may not run again because it will be waiting for - * a packet to appear in the queue but nothing ever will because xmit is paused. - * So we will end up with the queue paused, and the flag set to say it is paused, but bh never runs to unpause it. - * (Note even this bad situation would not persist long in practice, because something else (eg rx, or tx in different queue) - * is likely to wake bh thread quite soon) - * But to avoid this deadlock completely, after setting the flag we check that there is something left in the queue. - * If there is, we know that bh thread has not emptied the queue yet. - * Since bh thread checks to unpause the queue *after* taking packets from the queue, we know that it is still going to make at - * least one more check to see whether it needs to unpause the queue. So all is well. - * If there are no packets in the queue, then the deadlock described above might happen. To make sure it does not, we - * unpause the queue here. A possible side effect is that unifi_restart_xmit() may (rarely) be called for second time - * unnecessarily, which is harmless - */ - -#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_DATA_PLANE_PROFILE) - unifi_debug_log_to_buf("P"); -#endif - unifi_pause_xmit(card->ospriv, (unifi_TrafficQueue)priority_q); - card_tx_q_pause(card, priority_q); - if (CSR_WIFI_HIP_Q_SLOTS_USED(sigq) == 0) - { - card_tx_q_unpause(card, priority_q); - unifi_restart_xmit(card->ospriv, (unifi_TrafficQueue) priority_q); - } - } - else - { - unifi_warning(card->ospriv, - "send_signal: fh_cmd_q full, not pausing (run_bh=%d)\n", - run_bh); - } - } - - return CSR_RESULT_SUCCESS; -} /* send_signal() */ - - -/* - * --------------------------------------------------------------------------- - * unifi_send_signal - * - * Invokes send_signal() to queue a signal in the command or traffic queue - * If sigptr pointer is NULL, it pokes the bh to check if UniFi is responsive. - * - * Arguments: - * card Pointer to card context struct - * sigptr Pointer to signal from card. - * siglen Size of the signal - * bulkdata Pointer to the bulk data of the signal - * - * Returns: - * CSR_RESULT_SUCCESS on success - * CSR_WIFI_HIP_RESULT_NO_SPACE if there were insufficient data slots or no free signal queue entry - * - * Notes: - * unifi_send_signal() is used to queue signals, created by the driver, - * to the device. Signals are constructed using the UniFi packed structures. - * --------------------------------------------------------------------------- - */ -CsrResult unifi_send_signal(card_t *card, const u8 *sigptr, u32 siglen, - const bulk_data_param_t *bulkdata) -{ - q_t *sig_soft_q; - u16 signal_id; - CsrResult r; - u32 run_bh; - u32 priority_q; - - /* A NULL signal pointer is a request to check if UniFi is responsive */ - if (sigptr == NULL) - { - card->bh_reason_host = 1; - return unifi_run_bh(card->ospriv); - } - - priority_q = 0; - run_bh = 1; - signal_id = GET_SIGNAL_ID(sigptr); - /* - * If the signal is a CSR_MA_PACKET_REQUEST , - * we send it using the traffic soft queue. Else we use the command soft queue. - */ - if (signal_id == CSR_MA_PACKET_REQUEST_ID) - { - u16 frame_priority; - - if (card->periodic_wake_mode == UNIFI_PERIODIC_WAKE_HOST_ENABLED) - { - run_bh = 0; - } - -#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_DATA_PLANE_PROFILE) - unifi_debug_log_to_buf("D"); -#endif - /* Sanity check: MA-PACKET.req must have a valid bulk data */ - if ((bulkdata->d[0].data_length == 0) || (bulkdata->d[0].os_data_ptr == NULL)) - { - unifi_error(card->ospriv, "MA-PACKET.req with empty bulk data (%d bytes in %p)\n", - bulkdata->d[0].data_length, bulkdata->d[0].os_data_ptr); - dump((void *)sigptr, siglen); - return CSR_RESULT_FAILURE; - } - - /* Map the frame priority to a traffic queue index. */ - frame_priority = GET_PACKED_MA_PACKET_REQUEST_FRAME_PRIORITY(sigptr); - priority_q = unifi_frame_priority_to_queue((CSR_PRIORITY)frame_priority); - - sig_soft_q = &card->fh_traffic_queue[priority_q]; - } - else - { - sig_soft_q = &card->fh_command_queue; - } - - r = send_signal(card, sigptr, siglen, bulkdata, sig_soft_q, priority_q, run_bh); - /* On error, the caller must free or requeue bulkdata buffers */ - - return r; -} /* unifi_send_signal() */ - - -/* - * --------------------------------------------------------------------------- - * unifi_send_resources_available - * - * Examines whether there is available space to queue - * a signal in the command or traffic queue - * - * Arguments: - * card Pointer to card context struct - * sigptr Pointer to signal. - * - * Returns: - * CSR_RESULT_SUCCESS if resources available - * CSR_WIFI_HIP_RESULT_NO_SPACE if there was no free signal queue entry - * - * Notes: - * --------------------------------------------------------------------------- - */ -CsrResult unifi_send_resources_available(card_t *card, const u8 *sigptr) -{ - q_t *sig_soft_q; - u16 signal_id = GET_SIGNAL_ID(sigptr); - - /* - * If the signal is a CSR_MA_PACKET_REQUEST , - * we send it using the traffic soft queue. Else we use the command soft queue. - */ - if (signal_id == CSR_MA_PACKET_REQUEST_ID) - { - u16 frame_priority; - u32 priority_q; - - /* Map the frame priority to a traffic queue index. */ - frame_priority = GET_PACKED_MA_PACKET_REQUEST_FRAME_PRIORITY(sigptr); - priority_q = unifi_frame_priority_to_queue((CSR_PRIORITY)frame_priority); - - sig_soft_q = &card->fh_traffic_queue[priority_q]; - } - else - { - sig_soft_q = &card->fh_command_queue; - } - - /* Check that the fh_data_queue has a free slot */ - if (!CSR_WIFI_HIP_Q_SLOTS_FREE(sig_soft_q)) - { - unifi_notice(card->ospriv, "unifi_send_resources_available: %s full\n", - sig_soft_q->name); - return CSR_WIFI_HIP_RESULT_NO_SPACE; - } - - return CSR_RESULT_SUCCESS; -} /* unifi_send_resources_available() */ - - diff --git a/drivers/staging/csr/csr_wifi_hip_signals.c b/drivers/staging/csr/csr_wifi_hip_signals.c deleted file mode 100644 index 3c821320df00..000000000000 --- a/drivers/staging/csr/csr_wifi_hip_signals.c +++ /dev/null @@ -1,1313 +0,0 @@ -/***************************************************************************** - - (c) Cambridge Silicon Radio Limited 2011 - All rights reserved and confidential information of CSR - - Refer to LICENSE.txt included with this source for details - on the license terms. - -*****************************************************************************/ - -/* Note: this is an auto-generated file. */ - - -/* Generated by hip_dd_l_c_gen.pl */ - -#include "csr_wifi_hip_signals.h" - -#include "csr_wifi_hip_unifi.h" - -s32 SigGetSize(const CSR_SIGNAL *aSignal) -{ - switch (aSignal->SignalPrimitiveHeader.SignalId) - { - case CSR_MA_PACKET_REQUEST_ID: - return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MA_PACKET_REQUEST); - case CSR_MA_PACKET_CONFIRM_ID: - return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MA_PACKET_CONFIRM); - case CSR_MA_PACKET_INDICATION_ID: - return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MA_PACKET_INDICATION); - case CSR_MA_PACKET_CANCEL_REQUEST_ID: - return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MA_PACKET_CANCEL_REQUEST); - case CSR_MA_VIF_AVAILABILITY_RESPONSE_ID: - return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MA_VIF_AVAILABILITY_RESPONSE); - case CSR_MA_VIF_AVAILABILITY_INDICATION_ID: - return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MA_VIF_AVAILABILITY_INDICATION); - case CSR_MA_PACKET_ERROR_INDICATION_ID: - return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MA_PACKET_ERROR_INDICATION); -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_RESET_REQUEST_ID: - return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_RESET_REQUEST); -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_RESET_CONFIRM_ID: - return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_RESET_CONFIRM); -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_GET_REQUEST_ID: - return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_GET_REQUEST); -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_GET_CONFIRM_ID: - return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_GET_CONFIRM); -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_SET_REQUEST_ID: - return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_SET_REQUEST); -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_SET_CONFIRM_ID: - return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_SET_CONFIRM); -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_GET_NEXT_REQUEST_ID: - return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_GET_NEXT_REQUEST); -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_GET_NEXT_CONFIRM_ID: - return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_GET_NEXT_CONFIRM); -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_POWERMGT_REQUEST_ID: - return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_POWERMGT_REQUEST); -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_POWERMGT_CONFIRM_ID: - return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_POWERMGT_CONFIRM); -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_SCAN_REQUEST_ID: - return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_SCAN_REQUEST); -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_SCAN_CONFIRM_ID: - return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_SCAN_CONFIRM); -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_HL_SYNC_REQUEST_ID: - return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_HL_SYNC_REQUEST); -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_HL_SYNC_CONFIRM_ID: - return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_HL_SYNC_CONFIRM); -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_MEASURE_REQUEST_ID: - return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_MEASURE_REQUEST); -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_MEASURE_CONFIRM_ID: - return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_MEASURE_CONFIRM); -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_MEASURE_INDICATION_ID: - return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_MEASURE_INDICATION); -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_SETKEYS_REQUEST_ID: - return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_SETKEYS_REQUEST); -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_SETKEYS_CONFIRM_ID: - return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_SETKEYS_CONFIRM); -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_DELETEKEYS_REQUEST_ID: - return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_DELETEKEYS_REQUEST); -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_DELETEKEYS_CONFIRM_ID: - return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_DELETEKEYS_CONFIRM); -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_AUTONOMOUS_SCAN_LOSS_INDICATION_ID: - return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_AUTONOMOUS_SCAN_LOSS_INDICATION); -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_CONNECTED_INDICATION_ID: - return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_CONNECTED_INDICATION); -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_SCAN_CANCEL_REQUEST_ID: - return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_SCAN_CANCEL_REQUEST); -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_HL_SYNC_CANCEL_REQUEST_ID: - return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_HL_SYNC_CANCEL_REQUEST); -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_HL_SYNC_CANCEL_CONFIRM_ID: - return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_HL_SYNC_CANCEL_CONFIRM); -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_ADD_PERIODIC_REQUEST_ID: - return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_ADD_PERIODIC_REQUEST); -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_ADD_PERIODIC_CONFIRM_ID: - return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_ADD_PERIODIC_CONFIRM); -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_DEL_PERIODIC_REQUEST_ID: - return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_DEL_PERIODIC_REQUEST); -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_DEL_PERIODIC_CONFIRM_ID: - return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_DEL_PERIODIC_CONFIRM); -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_ADD_AUTONOMOUS_SCAN_REQUEST_ID: - return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_ADD_AUTONOMOUS_SCAN_REQUEST); -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_ADD_AUTONOMOUS_SCAN_CONFIRM_ID: - return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_ADD_AUTONOMOUS_SCAN_CONFIRM); -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_DEL_AUTONOMOUS_SCAN_REQUEST_ID: - return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_DEL_AUTONOMOUS_SCAN_REQUEST); -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_DEL_AUTONOMOUS_SCAN_CONFIRM_ID: - return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_DEL_AUTONOMOUS_SCAN_CONFIRM); -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_SET_PACKET_FILTER_REQUEST_ID: - return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_SET_PACKET_FILTER_REQUEST); -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_SET_PACKET_FILTER_CONFIRM_ID: - return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_SET_PACKET_FILTER_CONFIRM); -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_STOP_MEASURE_REQUEST_ID: - return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_STOP_MEASURE_REQUEST); -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_STOP_MEASURE_CONFIRM_ID: - return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_STOP_MEASURE_CONFIRM); -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_PAUSE_AUTONOMOUS_SCAN_REQUEST_ID: - return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_PAUSE_AUTONOMOUS_SCAN_REQUEST); -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_PAUSE_AUTONOMOUS_SCAN_CONFIRM_ID: - return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_PAUSE_AUTONOMOUS_SCAN_CONFIRM); -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_AUTONOMOUS_SCAN_DONE_INDICATION_ID: - return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_AUTONOMOUS_SCAN_DONE_INDICATION); -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_ADD_TRIGGERED_GET_REQUEST_ID: - return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_ADD_TRIGGERED_GET_REQUEST); -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_ADD_TRIGGERED_GET_CONFIRM_ID: - return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_ADD_TRIGGERED_GET_CONFIRM); -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_DEL_TRIGGERED_GET_REQUEST_ID: - return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_DEL_TRIGGERED_GET_REQUEST); -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_DEL_TRIGGERED_GET_CONFIRM_ID: - return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_DEL_TRIGGERED_GET_CONFIRM); -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_TRIGGERED_GET_INDICATION_ID: - return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_TRIGGERED_GET_INDICATION); -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_ADD_BLACKOUT_REQUEST_ID: - return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_ADD_BLACKOUT_REQUEST); -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_ADD_BLACKOUT_CONFIRM_ID: - return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_ADD_BLACKOUT_CONFIRM); -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_BLACKOUT_ENDED_INDICATION_ID: - return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_BLACKOUT_ENDED_INDICATION); -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_DEL_BLACKOUT_REQUEST_ID: - return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_DEL_BLACKOUT_REQUEST); -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_DEL_BLACKOUT_CONFIRM_ID: - return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_DEL_BLACKOUT_CONFIRM); -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_ADD_RX_TRIGGER_REQUEST_ID: - return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_ADD_RX_TRIGGER_REQUEST); -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_ADD_RX_TRIGGER_CONFIRM_ID: - return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_ADD_RX_TRIGGER_CONFIRM); -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_DEL_RX_TRIGGER_REQUEST_ID: - return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_DEL_RX_TRIGGER_REQUEST); -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_DEL_RX_TRIGGER_CONFIRM_ID: - return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_DEL_RX_TRIGGER_CONFIRM); -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_CONNECT_STATUS_REQUEST_ID: - return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_CONNECT_STATUS_REQUEST); -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_CONNECT_STATUS_CONFIRM_ID: - return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_CONNECT_STATUS_CONFIRM); -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_MODIFY_BSS_PARAMETER_REQUEST_ID: - return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_MODIFY_BSS_PARAMETER_REQUEST); -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_MODIFY_BSS_PARAMETER_CONFIRM_ID: - return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_MODIFY_BSS_PARAMETER_CONFIRM); -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_ADD_TEMPLATE_REQUEST_ID: - return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_ADD_TEMPLATE_REQUEST); -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_ADD_TEMPLATE_CONFIRM_ID: - return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_ADD_TEMPLATE_CONFIRM); -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_CONFIG_QUEUE_REQUEST_ID: - return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_CONFIG_QUEUE_REQUEST); -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_CONFIG_QUEUE_CONFIRM_ID: - return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_CONFIG_QUEUE_CONFIRM); -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_ADD_TSPEC_REQUEST_ID: - return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_ADD_TSPEC_REQUEST); -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_ADD_TSPEC_CONFIRM_ID: - return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_ADD_TSPEC_CONFIRM); -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_DEL_TSPEC_REQUEST_ID: - return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_DEL_TSPEC_REQUEST); -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_DEL_TSPEC_CONFIRM_ID: - return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_DEL_TSPEC_CONFIRM); -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_START_AGGREGATION_REQUEST_ID: - return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_START_AGGREGATION_REQUEST); -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_START_AGGREGATION_CONFIRM_ID: - return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_START_AGGREGATION_CONFIRM); -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_BLOCKACK_ERROR_INDICATION_ID: - return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_BLOCKACK_ERROR_INDICATION); -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_STOP_AGGREGATION_REQUEST_ID: - return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_STOP_AGGREGATION_REQUEST); -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_STOP_AGGREGATION_CONFIRM_ID: - return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_STOP_AGGREGATION_CONFIRM); -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_SM_START_REQUEST_ID: - return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_SM_START_REQUEST); -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_SM_START_CONFIRM_ID: - return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_SM_START_CONFIRM); -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_LEAVE_REQUEST_ID: - return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_LEAVE_REQUEST); -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_LEAVE_CONFIRM_ID: - return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_LEAVE_CONFIRM); -#endif - case CSR_MLME_SET_TIM_REQUEST_ID: - return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_SET_TIM_REQUEST); - case CSR_MLME_SET_TIM_CONFIRM_ID: - return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_SET_TIM_CONFIRM); -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_GET_KEY_SEQUENCE_REQUEST_ID: - return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_GET_KEY_SEQUENCE_REQUEST); -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_GET_KEY_SEQUENCE_CONFIRM_ID: - return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_GET_KEY_SEQUENCE_CONFIRM); -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_SET_CHANNEL_REQUEST_ID: - return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_SET_CHANNEL_REQUEST); -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_SET_CHANNEL_CONFIRM_ID: - return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_SET_CHANNEL_CONFIRM); -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_ADD_MULTICAST_ADDRESS_REQUEST_ID: - return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_ADD_MULTICAST_ADDRESS_REQUEST); -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_ADD_MULTICAST_ADDRESS_CONFIRM_ID: - return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_ADD_MULTICAST_ADDRESS_CONFIRM); -#endif - case CSR_DEBUG_STRING_INDICATION_ID: - return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_DEBUG_STRING_INDICATION); - case CSR_DEBUG_WORD16_INDICATION_ID: - return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_DEBUG_WORD16_INDICATION); - case CSR_DEBUG_GENERIC_REQUEST_ID: - return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_DEBUG_GENERIC_REQUEST); - case CSR_DEBUG_GENERIC_CONFIRM_ID: - return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_DEBUG_GENERIC_CONFIRM); - case CSR_DEBUG_GENERIC_INDICATION_ID: - return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_DEBUG_GENERIC_INDICATION); - default: - return 0; - } -} - - -s32 SigGetDataRefs(CSR_SIGNAL *aSignal, CSR_DATAREF **aDataRef) -{ - s32 numRefs = 0; - - switch (aSignal->SignalPrimitiveHeader.SignalId) - { - case CSR_MA_PACKET_REQUEST_ID: - aDataRef[numRefs++] = &aSignal->u.MaPacketRequest.Data; - aDataRef[numRefs++] = &aSignal->u.MaPacketRequest.Dummydataref2; - break; - case CSR_MA_PACKET_CONFIRM_ID: - aDataRef[numRefs++] = &aSignal->u.MaPacketConfirm.Dummydataref1; - aDataRef[numRefs++] = &aSignal->u.MaPacketConfirm.Dummydataref2; - break; - case CSR_MA_PACKET_INDICATION_ID: - aDataRef[numRefs++] = &aSignal->u.MaPacketIndication.Data; - aDataRef[numRefs++] = &aSignal->u.MaPacketIndication.Dummydataref2; - break; - case CSR_MA_PACKET_CANCEL_REQUEST_ID: - aDataRef[numRefs++] = &aSignal->u.MaPacketCancelRequest.Dummydataref1; - aDataRef[numRefs++] = &aSignal->u.MaPacketCancelRequest.Dummydataref2; - break; - case CSR_MA_VIF_AVAILABILITY_RESPONSE_ID: - aDataRef[numRefs++] = &aSignal->u.MaVifAvailabilityResponse.Dummydataref1; - aDataRef[numRefs++] = &aSignal->u.MaVifAvailabilityResponse.Dummydataref2; - break; - case CSR_MA_VIF_AVAILABILITY_INDICATION_ID: - aDataRef[numRefs++] = &aSignal->u.MaVifAvailabilityIndication.Dummydataref1; - aDataRef[numRefs++] = &aSignal->u.MaVifAvailabilityIndication.Dummydataref2; - break; - case CSR_MA_PACKET_ERROR_INDICATION_ID: - aDataRef[numRefs++] = &aSignal->u.MaPacketErrorIndication.Dummydataref1; - aDataRef[numRefs++] = &aSignal->u.MaPacketErrorIndication.Dummydataref2; - break; -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_RESET_REQUEST_ID: - aDataRef[numRefs++] = &aSignal->u.MlmeResetRequest.Dummydataref1; - aDataRef[numRefs++] = &aSignal->u.MlmeResetRequest.Dummydataref2; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_RESET_CONFIRM_ID: - aDataRef[numRefs++] = &aSignal->u.MlmeResetConfirm.Dummydataref1; - aDataRef[numRefs++] = &aSignal->u.MlmeResetConfirm.Dummydataref2; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_GET_REQUEST_ID: - aDataRef[numRefs++] = &aSignal->u.MlmeGetRequest.MibAttribute; - aDataRef[numRefs++] = &aSignal->u.MlmeGetRequest.Dummydataref2; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_GET_CONFIRM_ID: - aDataRef[numRefs++] = &aSignal->u.MlmeGetConfirm.MibAttributeValue; - aDataRef[numRefs++] = &aSignal->u.MlmeGetConfirm.Dummydataref2; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_SET_REQUEST_ID: - aDataRef[numRefs++] = &aSignal->u.MlmeSetRequest.MibAttributeValue; - aDataRef[numRefs++] = &aSignal->u.MlmeSetRequest.Dummydataref2; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_SET_CONFIRM_ID: - aDataRef[numRefs++] = &aSignal->u.MlmeSetConfirm.MibAttributeValue; - aDataRef[numRefs++] = &aSignal->u.MlmeSetConfirm.Dummydataref2; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_GET_NEXT_REQUEST_ID: - aDataRef[numRefs++] = &aSignal->u.MlmeGetNextRequest.MibAttribute; - aDataRef[numRefs++] = &aSignal->u.MlmeGetNextRequest.Dummydataref2; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_GET_NEXT_CONFIRM_ID: - aDataRef[numRefs++] = &aSignal->u.MlmeGetNextConfirm.MibAttributeValue; - aDataRef[numRefs++] = &aSignal->u.MlmeGetNextConfirm.Dummydataref2; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_POWERMGT_REQUEST_ID: - aDataRef[numRefs++] = &aSignal->u.MlmePowermgtRequest.Dummydataref1; - aDataRef[numRefs++] = &aSignal->u.MlmePowermgtRequest.Dummydataref2; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_POWERMGT_CONFIRM_ID: - aDataRef[numRefs++] = &aSignal->u.MlmePowermgtConfirm.Dummydataref1; - aDataRef[numRefs++] = &aSignal->u.MlmePowermgtConfirm.Dummydataref2; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_SCAN_REQUEST_ID: - aDataRef[numRefs++] = &aSignal->u.MlmeScanRequest.ChannelList; - aDataRef[numRefs++] = &aSignal->u.MlmeScanRequest.InformationElements; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_SCAN_CONFIRM_ID: - aDataRef[numRefs++] = &aSignal->u.MlmeScanConfirm.Dummydataref1; - aDataRef[numRefs++] = &aSignal->u.MlmeScanConfirm.Dummydataref2; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_HL_SYNC_REQUEST_ID: - aDataRef[numRefs++] = &aSignal->u.MlmeHlSyncRequest.Dummydataref1; - aDataRef[numRefs++] = &aSignal->u.MlmeHlSyncRequest.Dummydataref2; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_HL_SYNC_CONFIRM_ID: - aDataRef[numRefs++] = &aSignal->u.MlmeHlSyncConfirm.Dummydataref1; - aDataRef[numRefs++] = &aSignal->u.MlmeHlSyncConfirm.Dummydataref2; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_MEASURE_REQUEST_ID: - aDataRef[numRefs++] = &aSignal->u.MlmeMeasureRequest.MeasurementRequestSet; - aDataRef[numRefs++] = &aSignal->u.MlmeMeasureRequest.Dummydataref2; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_MEASURE_CONFIRM_ID: - aDataRef[numRefs++] = &aSignal->u.MlmeMeasureConfirm.Dummydataref1; - aDataRef[numRefs++] = &aSignal->u.MlmeMeasureConfirm.Dummydataref2; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_MEASURE_INDICATION_ID: - aDataRef[numRefs++] = &aSignal->u.MlmeMeasureIndication.MeasurementReportSet; - aDataRef[numRefs++] = &aSignal->u.MlmeMeasureIndication.Dummydataref2; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_SETKEYS_REQUEST_ID: - aDataRef[numRefs++] = &aSignal->u.MlmeSetkeysRequest.Key; - aDataRef[numRefs++] = &aSignal->u.MlmeSetkeysRequest.Dummydataref2; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_SETKEYS_CONFIRM_ID: - aDataRef[numRefs++] = &aSignal->u.MlmeSetkeysConfirm.Dummydataref1; - aDataRef[numRefs++] = &aSignal->u.MlmeSetkeysConfirm.Dummydataref2; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_DELETEKEYS_REQUEST_ID: - aDataRef[numRefs++] = &aSignal->u.MlmeDeletekeysRequest.Dummydataref1; - aDataRef[numRefs++] = &aSignal->u.MlmeDeletekeysRequest.Dummydataref2; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_DELETEKEYS_CONFIRM_ID: - aDataRef[numRefs++] = &aSignal->u.MlmeDeletekeysConfirm.Dummydataref1; - aDataRef[numRefs++] = &aSignal->u.MlmeDeletekeysConfirm.Dummydataref2; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_AUTONOMOUS_SCAN_LOSS_INDICATION_ID: - aDataRef[numRefs++] = &aSignal->u.MlmeAutonomousScanLossIndication.Dummydataref1; - aDataRef[numRefs++] = &aSignal->u.MlmeAutonomousScanLossIndication.Dummydataref2; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_CONNECTED_INDICATION_ID: - aDataRef[numRefs++] = &aSignal->u.MlmeConnectedIndication.Dummydataref1; - aDataRef[numRefs++] = &aSignal->u.MlmeConnectedIndication.Dummydataref2; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_SCAN_CANCEL_REQUEST_ID: - aDataRef[numRefs++] = &aSignal->u.MlmeScanCancelRequest.Dummydataref1; - aDataRef[numRefs++] = &aSignal->u.MlmeScanCancelRequest.Dummydataref2; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_HL_SYNC_CANCEL_REQUEST_ID: - aDataRef[numRefs++] = &aSignal->u.MlmeHlSyncCancelRequest.Dummydataref1; - aDataRef[numRefs++] = &aSignal->u.MlmeHlSyncCancelRequest.Dummydataref2; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_HL_SYNC_CANCEL_CONFIRM_ID: - aDataRef[numRefs++] = &aSignal->u.MlmeHlSyncCancelConfirm.Dummydataref1; - aDataRef[numRefs++] = &aSignal->u.MlmeHlSyncCancelConfirm.Dummydataref2; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_ADD_PERIODIC_REQUEST_ID: - aDataRef[numRefs++] = &aSignal->u.MlmeAddPeriodicRequest.Dummydataref1; - aDataRef[numRefs++] = &aSignal->u.MlmeAddPeriodicRequest.Dummydataref2; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_ADD_PERIODIC_CONFIRM_ID: - aDataRef[numRefs++] = &aSignal->u.MlmeAddPeriodicConfirm.Dummydataref1; - aDataRef[numRefs++] = &aSignal->u.MlmeAddPeriodicConfirm.Dummydataref2; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_DEL_PERIODIC_REQUEST_ID: - aDataRef[numRefs++] = &aSignal->u.MlmeDelPeriodicRequest.Dummydataref1; - aDataRef[numRefs++] = &aSignal->u.MlmeDelPeriodicRequest.Dummydataref2; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_DEL_PERIODIC_CONFIRM_ID: - aDataRef[numRefs++] = &aSignal->u.MlmeDelPeriodicConfirm.Dummydataref1; - aDataRef[numRefs++] = &aSignal->u.MlmeDelPeriodicConfirm.Dummydataref2; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_ADD_AUTONOMOUS_SCAN_REQUEST_ID: - aDataRef[numRefs++] = &aSignal->u.MlmeAddAutonomousScanRequest.ChannelList; - aDataRef[numRefs++] = &aSignal->u.MlmeAddAutonomousScanRequest.InformationElements; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_ADD_AUTONOMOUS_SCAN_CONFIRM_ID: - aDataRef[numRefs++] = &aSignal->u.MlmeAddAutonomousScanConfirm.Dummydataref1; - aDataRef[numRefs++] = &aSignal->u.MlmeAddAutonomousScanConfirm.Dummydataref2; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_DEL_AUTONOMOUS_SCAN_REQUEST_ID: - aDataRef[numRefs++] = &aSignal->u.MlmeDelAutonomousScanRequest.Dummydataref1; - aDataRef[numRefs++] = &aSignal->u.MlmeDelAutonomousScanRequest.Dummydataref2; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_DEL_AUTONOMOUS_SCAN_CONFIRM_ID: - aDataRef[numRefs++] = &aSignal->u.MlmeDelAutonomousScanConfirm.Dummydataref1; - aDataRef[numRefs++] = &aSignal->u.MlmeDelAutonomousScanConfirm.Dummydataref2; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_SET_PACKET_FILTER_REQUEST_ID: - aDataRef[numRefs++] = &aSignal->u.MlmeSetPacketFilterRequest.InformationElements; - aDataRef[numRefs++] = &aSignal->u.MlmeSetPacketFilterRequest.Dummydataref2; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_SET_PACKET_FILTER_CONFIRM_ID: - aDataRef[numRefs++] = &aSignal->u.MlmeSetPacketFilterConfirm.Dummydataref1; - aDataRef[numRefs++] = &aSignal->u.MlmeSetPacketFilterConfirm.Dummydataref2; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_STOP_MEASURE_REQUEST_ID: - aDataRef[numRefs++] = &aSignal->u.MlmeStopMeasureRequest.Dummydataref1; - aDataRef[numRefs++] = &aSignal->u.MlmeStopMeasureRequest.Dummydataref2; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_STOP_MEASURE_CONFIRM_ID: - aDataRef[numRefs++] = &aSignal->u.MlmeStopMeasureConfirm.Dummydataref1; - aDataRef[numRefs++] = &aSignal->u.MlmeStopMeasureConfirm.Dummydataref2; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_PAUSE_AUTONOMOUS_SCAN_REQUEST_ID: - aDataRef[numRefs++] = &aSignal->u.MlmePauseAutonomousScanRequest.Dummydataref1; - aDataRef[numRefs++] = &aSignal->u.MlmePauseAutonomousScanRequest.Dummydataref2; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_PAUSE_AUTONOMOUS_SCAN_CONFIRM_ID: - aDataRef[numRefs++] = &aSignal->u.MlmePauseAutonomousScanConfirm.Dummydataref1; - aDataRef[numRefs++] = &aSignal->u.MlmePauseAutonomousScanConfirm.Dummydataref2; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_AUTONOMOUS_SCAN_DONE_INDICATION_ID: - aDataRef[numRefs++] = &aSignal->u.MlmeAutonomousScanDoneIndication.Dummydataref1; - aDataRef[numRefs++] = &aSignal->u.MlmeAutonomousScanDoneIndication.Dummydataref2; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_ADD_TRIGGERED_GET_REQUEST_ID: - aDataRef[numRefs++] = &aSignal->u.MlmeAddTriggeredGetRequest.MibAttribute; - aDataRef[numRefs++] = &aSignal->u.MlmeAddTriggeredGetRequest.Dummydataref2; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_ADD_TRIGGERED_GET_CONFIRM_ID: - aDataRef[numRefs++] = &aSignal->u.MlmeAddTriggeredGetConfirm.Dummydataref1; - aDataRef[numRefs++] = &aSignal->u.MlmeAddTriggeredGetConfirm.Dummydataref2; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_DEL_TRIGGERED_GET_REQUEST_ID: - aDataRef[numRefs++] = &aSignal->u.MlmeDelTriggeredGetRequest.Dummydataref1; - aDataRef[numRefs++] = &aSignal->u.MlmeDelTriggeredGetRequest.Dummydataref2; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_DEL_TRIGGERED_GET_CONFIRM_ID: - aDataRef[numRefs++] = &aSignal->u.MlmeDelTriggeredGetConfirm.Dummydataref1; - aDataRef[numRefs++] = &aSignal->u.MlmeDelTriggeredGetConfirm.Dummydataref2; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_TRIGGERED_GET_INDICATION_ID: - aDataRef[numRefs++] = &aSignal->u.MlmeTriggeredGetIndication.MibAttributeValue; - aDataRef[numRefs++] = &aSignal->u.MlmeTriggeredGetIndication.Dummydataref2; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_ADD_BLACKOUT_REQUEST_ID: - aDataRef[numRefs++] = &aSignal->u.MlmeAddBlackoutRequest.Dummydataref1; - aDataRef[numRefs++] = &aSignal->u.MlmeAddBlackoutRequest.Dummydataref2; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_ADD_BLACKOUT_CONFIRM_ID: - aDataRef[numRefs++] = &aSignal->u.MlmeAddBlackoutConfirm.Dummydataref1; - aDataRef[numRefs++] = &aSignal->u.MlmeAddBlackoutConfirm.Dummydataref2; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_BLACKOUT_ENDED_INDICATION_ID: - aDataRef[numRefs++] = &aSignal->u.MlmeBlackoutEndedIndication.Dummydataref1; - aDataRef[numRefs++] = &aSignal->u.MlmeBlackoutEndedIndication.Dummydataref2; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_DEL_BLACKOUT_REQUEST_ID: - aDataRef[numRefs++] = &aSignal->u.MlmeDelBlackoutRequest.Dummydataref1; - aDataRef[numRefs++] = &aSignal->u.MlmeDelBlackoutRequest.Dummydataref2; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_DEL_BLACKOUT_CONFIRM_ID: - aDataRef[numRefs++] = &aSignal->u.MlmeDelBlackoutConfirm.Dummydataref1; - aDataRef[numRefs++] = &aSignal->u.MlmeDelBlackoutConfirm.Dummydataref2; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_ADD_RX_TRIGGER_REQUEST_ID: - aDataRef[numRefs++] = &aSignal->u.MlmeAddRxTriggerRequest.InformationElements; - aDataRef[numRefs++] = &aSignal->u.MlmeAddRxTriggerRequest.Dummydataref2; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_ADD_RX_TRIGGER_CONFIRM_ID: - aDataRef[numRefs++] = &aSignal->u.MlmeAddRxTriggerConfirm.Dummydataref1; - aDataRef[numRefs++] = &aSignal->u.MlmeAddRxTriggerConfirm.Dummydataref2; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_DEL_RX_TRIGGER_REQUEST_ID: - aDataRef[numRefs++] = &aSignal->u.MlmeDelRxTriggerRequest.Dummydataref1; - aDataRef[numRefs++] = &aSignal->u.MlmeDelRxTriggerRequest.Dummydataref2; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_DEL_RX_TRIGGER_CONFIRM_ID: - aDataRef[numRefs++] = &aSignal->u.MlmeDelRxTriggerConfirm.Dummydataref1; - aDataRef[numRefs++] = &aSignal->u.MlmeDelRxTriggerConfirm.Dummydataref2; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_CONNECT_STATUS_REQUEST_ID: - aDataRef[numRefs++] = &aSignal->u.MlmeConnectStatusRequest.InformationElements; - aDataRef[numRefs++] = &aSignal->u.MlmeConnectStatusRequest.Dummydataref2; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_CONNECT_STATUS_CONFIRM_ID: - aDataRef[numRefs++] = &aSignal->u.MlmeConnectStatusConfirm.Dummydataref1; - aDataRef[numRefs++] = &aSignal->u.MlmeConnectStatusConfirm.Dummydataref2; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_MODIFY_BSS_PARAMETER_REQUEST_ID: - aDataRef[numRefs++] = &aSignal->u.MlmeModifyBssParameterRequest.Data; - aDataRef[numRefs++] = &aSignal->u.MlmeModifyBssParameterRequest.Dummydataref2; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_MODIFY_BSS_PARAMETER_CONFIRM_ID: - aDataRef[numRefs++] = &aSignal->u.MlmeModifyBssParameterConfirm.Dummydataref1; - aDataRef[numRefs++] = &aSignal->u.MlmeModifyBssParameterConfirm.Dummydataref2; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_ADD_TEMPLATE_REQUEST_ID: - aDataRef[numRefs++] = &aSignal->u.MlmeAddTemplateRequest.Data1; - aDataRef[numRefs++] = &aSignal->u.MlmeAddTemplateRequest.Data2; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_ADD_TEMPLATE_CONFIRM_ID: - aDataRef[numRefs++] = &aSignal->u.MlmeAddTemplateConfirm.Dummydataref1; - aDataRef[numRefs++] = &aSignal->u.MlmeAddTemplateConfirm.Dummydataref2; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_CONFIG_QUEUE_REQUEST_ID: - aDataRef[numRefs++] = &aSignal->u.MlmeConfigQueueRequest.Dummydataref1; - aDataRef[numRefs++] = &aSignal->u.MlmeConfigQueueRequest.Dummydataref2; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_CONFIG_QUEUE_CONFIRM_ID: - aDataRef[numRefs++] = &aSignal->u.MlmeConfigQueueConfirm.Dummydataref1; - aDataRef[numRefs++] = &aSignal->u.MlmeConfigQueueConfirm.Dummydataref2; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_ADD_TSPEC_REQUEST_ID: - aDataRef[numRefs++] = &aSignal->u.MlmeAddTspecRequest.Dummydataref1; - aDataRef[numRefs++] = &aSignal->u.MlmeAddTspecRequest.Dummydataref2; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_ADD_TSPEC_CONFIRM_ID: - aDataRef[numRefs++] = &aSignal->u.MlmeAddTspecConfirm.Dummydataref1; - aDataRef[numRefs++] = &aSignal->u.MlmeAddTspecConfirm.Dummydataref2; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_DEL_TSPEC_REQUEST_ID: - aDataRef[numRefs++] = &aSignal->u.MlmeDelTspecRequest.Dummydataref1; - aDataRef[numRefs++] = &aSignal->u.MlmeDelTspecRequest.Dummydataref2; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_DEL_TSPEC_CONFIRM_ID: - aDataRef[numRefs++] = &aSignal->u.MlmeDelTspecConfirm.Dummydataref1; - aDataRef[numRefs++] = &aSignal->u.MlmeDelTspecConfirm.Dummydataref2; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_START_AGGREGATION_REQUEST_ID: - aDataRef[numRefs++] = &aSignal->u.MlmeStartAggregationRequest.Dummydataref1; - aDataRef[numRefs++] = &aSignal->u.MlmeStartAggregationRequest.Dummydataref2; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_START_AGGREGATION_CONFIRM_ID: - aDataRef[numRefs++] = &aSignal->u.MlmeStartAggregationConfirm.Dummydataref1; - aDataRef[numRefs++] = &aSignal->u.MlmeStartAggregationConfirm.Dummydataref2; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_BLOCKACK_ERROR_INDICATION_ID: - aDataRef[numRefs++] = &aSignal->u.MlmeBlockackErrorIndication.Dummydataref1; - aDataRef[numRefs++] = &aSignal->u.MlmeBlockackErrorIndication.Dummydataref2; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_STOP_AGGREGATION_REQUEST_ID: - aDataRef[numRefs++] = &aSignal->u.MlmeStopAggregationRequest.Dummydataref1; - aDataRef[numRefs++] = &aSignal->u.MlmeStopAggregationRequest.Dummydataref2; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_STOP_AGGREGATION_CONFIRM_ID: - aDataRef[numRefs++] = &aSignal->u.MlmeStopAggregationConfirm.Dummydataref1; - aDataRef[numRefs++] = &aSignal->u.MlmeStopAggregationConfirm.Dummydataref2; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_SM_START_REQUEST_ID: - aDataRef[numRefs++] = &aSignal->u.MlmeSmStartRequest.Beacon; - aDataRef[numRefs++] = &aSignal->u.MlmeSmStartRequest.BssParameters; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_SM_START_CONFIRM_ID: - aDataRef[numRefs++] = &aSignal->u.MlmeSmStartConfirm.Dummydataref1; - aDataRef[numRefs++] = &aSignal->u.MlmeSmStartConfirm.Dummydataref2; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_LEAVE_REQUEST_ID: - aDataRef[numRefs++] = &aSignal->u.MlmeLeaveRequest.Dummydataref1; - aDataRef[numRefs++] = &aSignal->u.MlmeLeaveRequest.Dummydataref2; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_LEAVE_CONFIRM_ID: - aDataRef[numRefs++] = &aSignal->u.MlmeLeaveConfirm.Dummydataref1; - aDataRef[numRefs++] = &aSignal->u.MlmeLeaveConfirm.Dummydataref2; - break; -#endif - case CSR_MLME_SET_TIM_REQUEST_ID: - aDataRef[numRefs++] = &aSignal->u.MlmeSetTimRequest.Dummydataref1; - aDataRef[numRefs++] = &aSignal->u.MlmeSetTimRequest.Dummydataref2; - break; - case CSR_MLME_SET_TIM_CONFIRM_ID: - aDataRef[numRefs++] = &aSignal->u.MlmeSetTimConfirm.Dummydataref1; - aDataRef[numRefs++] = &aSignal->u.MlmeSetTimConfirm.Dummydataref2; - break; -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_GET_KEY_SEQUENCE_REQUEST_ID: - aDataRef[numRefs++] = &aSignal->u.MlmeGetKeySequenceRequest.Dummydataref1; - aDataRef[numRefs++] = &aSignal->u.MlmeGetKeySequenceRequest.Dummydataref2; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_GET_KEY_SEQUENCE_CONFIRM_ID: - aDataRef[numRefs++] = &aSignal->u.MlmeGetKeySequenceConfirm.Dummydataref1; - aDataRef[numRefs++] = &aSignal->u.MlmeGetKeySequenceConfirm.Dummydataref2; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_SET_CHANNEL_REQUEST_ID: - aDataRef[numRefs++] = &aSignal->u.MlmeSetChannelRequest.Dummydataref1; - aDataRef[numRefs++] = &aSignal->u.MlmeSetChannelRequest.Dummydataref2; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_SET_CHANNEL_CONFIRM_ID: - aDataRef[numRefs++] = &aSignal->u.MlmeSetChannelConfirm.Dummydataref1; - aDataRef[numRefs++] = &aSignal->u.MlmeSetChannelConfirm.Dummydataref2; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_ADD_MULTICAST_ADDRESS_REQUEST_ID: - aDataRef[numRefs++] = &aSignal->u.MlmeAddMulticastAddressRequest.Data; - aDataRef[numRefs++] = &aSignal->u.MlmeAddMulticastAddressRequest.Dummydataref2; - break; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_ADD_MULTICAST_ADDRESS_CONFIRM_ID: - aDataRef[numRefs++] = &aSignal->u.MlmeAddMulticastAddressConfirm.Dummydataref1; - aDataRef[numRefs++] = &aSignal->u.MlmeAddMulticastAddressConfirm.Dummydataref2; - break; -#endif - case CSR_DEBUG_STRING_INDICATION_ID: - aDataRef[numRefs++] = &aSignal->u.DebugStringIndication.DebugMessage; - aDataRef[numRefs++] = &aSignal->u.DebugStringIndication.Dummydataref2; - break; - case CSR_DEBUG_WORD16_INDICATION_ID: - aDataRef[numRefs++] = &aSignal->u.DebugWord16Indication.Dummydataref1; - aDataRef[numRefs++] = &aSignal->u.DebugWord16Indication.Dummydataref2; - break; - case CSR_DEBUG_GENERIC_REQUEST_ID: - aDataRef[numRefs++] = &aSignal->u.DebugGenericRequest.DebugVariable; - aDataRef[numRefs++] = &aSignal->u.DebugGenericRequest.Dummydataref2; - break; - case CSR_DEBUG_GENERIC_CONFIRM_ID: - aDataRef[numRefs++] = &aSignal->u.DebugGenericConfirm.DebugVariable; - aDataRef[numRefs++] = &aSignal->u.DebugGenericConfirm.Dummydataref2; - break; - case CSR_DEBUG_GENERIC_INDICATION_ID: - aDataRef[numRefs++] = &aSignal->u.DebugGenericIndication.DebugVariable; - aDataRef[numRefs++] = &aSignal->u.DebugGenericIndication.Dummydataref2; - break; - default: - return 0; - } - return numRefs; -} - - -u32 SigGetFilterPos(u16 aSigID) -{ - switch (aSigID) - { - case CSR_MA_PACKET_REQUEST_ID: - return 0x00000001; - case CSR_MA_PACKET_CONFIRM_ID: - return 0x00000002; - case CSR_MA_PACKET_INDICATION_ID: - return 0x00000004; - case CSR_MA_PACKET_CANCEL_REQUEST_ID: - return 0x00000008; - case CSR_MA_VIF_AVAILABILITY_RESPONSE_ID: - return 0x00000010; - case CSR_MA_VIF_AVAILABILITY_INDICATION_ID: - return 0x00000020; - case CSR_MA_PACKET_ERROR_INDICATION_ID: - return 0x00000040; -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_RESET_REQUEST_ID: - return 0x00000080; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_RESET_CONFIRM_ID: - return 0x00000100; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_GET_REQUEST_ID: - return 0x00000200; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_GET_CONFIRM_ID: - return 0x00000400; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_SET_REQUEST_ID: - return 0x00000800; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_SET_CONFIRM_ID: - return 0x00001000; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_GET_NEXT_REQUEST_ID: - return 0x00002000; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_GET_NEXT_CONFIRM_ID: - return 0x00004000; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_POWERMGT_REQUEST_ID: - return 0x00008000; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_POWERMGT_CONFIRM_ID: - return 0x00010001; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_SCAN_REQUEST_ID: - return 0x00010002; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_SCAN_CONFIRM_ID: - return 0x00010004; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_HL_SYNC_REQUEST_ID: - return 0x00010008; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_HL_SYNC_CONFIRM_ID: - return 0x00010010; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_MEASURE_REQUEST_ID: - return 0x00010020; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_MEASURE_CONFIRM_ID: - return 0x00010040; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_MEASURE_INDICATION_ID: - return 0x00010080; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_SETKEYS_REQUEST_ID: - return 0x00010100; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_SETKEYS_CONFIRM_ID: - return 0x00010200; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_DELETEKEYS_REQUEST_ID: - return 0x00010400; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_DELETEKEYS_CONFIRM_ID: - return 0x00010800; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_AUTONOMOUS_SCAN_LOSS_INDICATION_ID: - return 0x00011000; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_CONNECTED_INDICATION_ID: - return 0x00012000; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_SCAN_CANCEL_REQUEST_ID: - return 0x00014000; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_HL_SYNC_CANCEL_REQUEST_ID: - return 0x00018000; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_HL_SYNC_CANCEL_CONFIRM_ID: - return 0x00020001; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_ADD_PERIODIC_REQUEST_ID: - return 0x00020002; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_ADD_PERIODIC_CONFIRM_ID: - return 0x00020004; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_DEL_PERIODIC_REQUEST_ID: - return 0x00020008; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_DEL_PERIODIC_CONFIRM_ID: - return 0x00020010; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_ADD_AUTONOMOUS_SCAN_REQUEST_ID: - return 0x00020020; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_ADD_AUTONOMOUS_SCAN_CONFIRM_ID: - return 0x00020040; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_DEL_AUTONOMOUS_SCAN_REQUEST_ID: - return 0x00020080; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_DEL_AUTONOMOUS_SCAN_CONFIRM_ID: - return 0x00020100; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_SET_PACKET_FILTER_REQUEST_ID: - return 0x00020200; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_SET_PACKET_FILTER_CONFIRM_ID: - return 0x00020400; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_STOP_MEASURE_REQUEST_ID: - return 0x00020800; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_STOP_MEASURE_CONFIRM_ID: - return 0x00021000; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_PAUSE_AUTONOMOUS_SCAN_REQUEST_ID: - return 0x00022000; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_PAUSE_AUTONOMOUS_SCAN_CONFIRM_ID: - return 0x00024000; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_AUTONOMOUS_SCAN_DONE_INDICATION_ID: - return 0x00028000; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_ADD_TRIGGERED_GET_REQUEST_ID: - return 0x00030001; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_ADD_TRIGGERED_GET_CONFIRM_ID: - return 0x00030002; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_DEL_TRIGGERED_GET_REQUEST_ID: - return 0x00030004; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_DEL_TRIGGERED_GET_CONFIRM_ID: - return 0x00030008; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_TRIGGERED_GET_INDICATION_ID: - return 0x00030010; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_ADD_BLACKOUT_REQUEST_ID: - return 0x00030020; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_ADD_BLACKOUT_CONFIRM_ID: - return 0x00030040; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_BLACKOUT_ENDED_INDICATION_ID: - return 0x00030080; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_DEL_BLACKOUT_REQUEST_ID: - return 0x00030100; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_DEL_BLACKOUT_CONFIRM_ID: - return 0x00030200; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_ADD_RX_TRIGGER_REQUEST_ID: - return 0x00030400; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_ADD_RX_TRIGGER_CONFIRM_ID: - return 0x00030800; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_DEL_RX_TRIGGER_REQUEST_ID: - return 0x00031000; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_DEL_RX_TRIGGER_CONFIRM_ID: - return 0x00032000; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_CONNECT_STATUS_REQUEST_ID: - return 0x00034000; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_CONNECT_STATUS_CONFIRM_ID: - return 0x00038000; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_MODIFY_BSS_PARAMETER_REQUEST_ID: - return 0x00040001; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_MODIFY_BSS_PARAMETER_CONFIRM_ID: - return 0x00040002; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_ADD_TEMPLATE_REQUEST_ID: - return 0x00040004; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_ADD_TEMPLATE_CONFIRM_ID: - return 0x00040008; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_CONFIG_QUEUE_REQUEST_ID: - return 0x00040010; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_CONFIG_QUEUE_CONFIRM_ID: - return 0x00040020; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_ADD_TSPEC_REQUEST_ID: - return 0x00040040; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_ADD_TSPEC_CONFIRM_ID: - return 0x00040080; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_DEL_TSPEC_REQUEST_ID: - return 0x00040100; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_DEL_TSPEC_CONFIRM_ID: - return 0x00040200; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_START_AGGREGATION_REQUEST_ID: - return 0x00040400; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_START_AGGREGATION_CONFIRM_ID: - return 0x00040800; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_BLOCKACK_ERROR_INDICATION_ID: - return 0x00041000; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_STOP_AGGREGATION_REQUEST_ID: - return 0x00042000; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_STOP_AGGREGATION_CONFIRM_ID: - return 0x00044000; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_SM_START_REQUEST_ID: - return 0x00048000; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_SM_START_CONFIRM_ID: - return 0x00050001; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_LEAVE_REQUEST_ID: - return 0x00050002; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_LEAVE_CONFIRM_ID: - return 0x00050004; -#endif - case CSR_MLME_SET_TIM_REQUEST_ID: - return 0x00050008; - case CSR_MLME_SET_TIM_CONFIRM_ID: - return 0x00050010; -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_GET_KEY_SEQUENCE_REQUEST_ID: - return 0x00050020; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_GET_KEY_SEQUENCE_CONFIRM_ID: - return 0x00050040; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_SET_CHANNEL_REQUEST_ID: - return 0x00050080; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_SET_CHANNEL_CONFIRM_ID: - return 0x00050100; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_ADD_MULTICAST_ADDRESS_REQUEST_ID: - return 0x00050200; -#endif -#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET - case CSR_MLME_ADD_MULTICAST_ADDRESS_CONFIRM_ID: - return 0x00050400; -#endif - case CSR_DEBUG_STRING_INDICATION_ID: - return 0x00050800; - case CSR_DEBUG_WORD16_INDICATION_ID: - return 0x00051000; - case CSR_DEBUG_GENERIC_REQUEST_ID: - return 0x00052000; - case CSR_DEBUG_GENERIC_CONFIRM_ID: - return 0x00054000; - case CSR_DEBUG_GENERIC_INDICATION_ID: - return 0x00058000; - default: - break; - } - return 0xffffffff; -} - - diff --git a/drivers/staging/csr/csr_wifi_hip_signals.h b/drivers/staging/csr/csr_wifi_hip_signals.h deleted file mode 100644 index ca4d0774195c..000000000000 --- a/drivers/staging/csr/csr_wifi_hip_signals.h +++ /dev/null @@ -1,128 +0,0 @@ -/***************************************************************************** - - (c) Cambridge Silicon Radio Limited 2011 - All rights reserved and confidential information of CSR - - Refer to LICENSE.txt included with this source for details - on the license terms. - -*****************************************************************************/ - -/* - ***************************************************************************** - * - * FILE: csr_wifi_hip_signals.h - * - * PURPOSE: - * Header file wrapping the auto-generated code in csr_wifi_hip_sigs.h - * and csr_wifi_hip_signals.c - - * csr_wifi_hip_sigs.h provides structures defining UniFi signals and - * csr_wifi_hip_signals.c provides SigGetSize() and SigGetDataRefs(). - * - ***************************************************************************** - */ -#ifndef __CSR_WIFI_HIP_SIGNALS_H__ -#define __CSR_WIFI_HIP_SIGNALS_H__ - -#include -#include "csr_wifi_hip_sigs.h" - - -/****************************************************************************/ -/* INFORMATION ELEMENTS */ -/****************************************************************************/ - -/* Information Element ID's - shouldn't be in here, but nowhere better yet */ -#define IE_SSID_ID 0 -#define IE_SUPPORTED_RATES_ID 1 -#define IE_FH_PARAM_SET_ID 2 -#define IE_DS_PARAM_SET_ID 3 -#define IE_CF_PARAM_SET_ID 4 -#define IE_TIM_ID 5 -#define IE_IBSS_PARAM_SET_ID 6 -#define IE_COUNTRY_ID 7 -#define IE_HOPPING_PATTERN_PARAMS_ID 8 -#define IE_HOPPING_PATTERN_TABLE_ID 9 -#define IE_REQUEST_ID 10 -#define IE_QBSS_LOAD_ID 11 -#define IE_EDCA_PARAM_SET_ID 12 -#define IE_TRAFFIC_SPEC_ID 13 -#define IE_TRAFFIC_CLASS_ID 14 -#define IE_SCHEDULE_ID 15 -#define IE_CHALLENGE_TEXT_ID 16 -#define IE_POWER_CONSTRAINT_ID 32 -#define IE_POWER_CAPABILITY_ID 33 -#define IE_TPC_REQUEST_ID 34 -#define IE_TPC_REPORT_ID 35 -#define IE_SUPPORTED_CHANNELS_ID 36 -#define IE_CHANNEL_SWITCH_ANNOUNCE_ID 37 -#define IE_MEASUREMENT_REQUEST_ID 38 -#define IE_MEASUREMENT_REPORT_ID 39 -#define IE_QUIET_ID 40 -#define IE_IBSS_DFS_ID 41 -#define IE_ERP_INFO_ID 42 -#define IE_TS_DELAY_ID 43 -#define IE_TCLAS_PROCESSING_ID 44 -#define IE_QOS_CAPABILITY_ID 46 -#define IE_RSN_ID 48 -#define IE_EXTENDED_SUPPORTED_RATES_ID 50 -#define IE_AP_CHANNEL_REPORT_ID 52 -#define IE_RCPI_ID 53 -#define IE_WPA_ID 221 - - -/* The maximum number of data references in a signal structure */ -#define UNIFI_MAX_DATA_REFERENCES 2 - -/* The space to allow for a wire-format signal structure */ -#define UNIFI_PACKED_SIGBUF_SIZE 64 - - -/******************************************************************************/ -/* SIGNAL PARAMETER VALUES */ -/******************************************************************************/ - -/* ifIndex */ -#define UNIFI_IF_2G4 1 -#define UNIFI_IF_5G 2 - -/* SendProcessId */ -#define HOST_PROC_ID 0xc000 - -#define SIG_CAP_ESS 0x0001 -#define SIG_CAP_IBSS 0x0002 -#define SIG_CAP_CF_POLLABLE 0x0004 -#define SIG_CAP_CF_POLL_REQUEST 0x0008 -#define SIG_CAP_PRIVACY 0x0010 -#define SIG_CAP_SHORT_PREAMBLE 0x0020 -#define SIG_CAP_DSSSOFDM 0x2000 - -/******************************************************************************/ -/* FUNCTION DECLARATIONS */ -/******************************************************************************/ - -/****************************************************************************** - * SigGetNumDataRefs - Retrieve pointers to data-refs from a signal. - * - * PARAMETERS: - * aSignal - Pointer to signal to retrieve the data refs of. - * aDataRef - Address of a pointer to the structure that the data refs - * pointers will be stored. - * - * RETURNS: - * The number of data-refs in the signal. - */ -s32 SigGetDataRefs(CSR_SIGNAL *aSignal, CSR_DATAREF **aDataRef); - -/****************************************************************************** - * SigGetSize - Retrieve the size (in bytes) of a given signal. - * - * PARAMETERS: - * aSignal - Pointer to signal to retrieve size of. - * - * RETURNS: - * The size (in bytes) of the given signal. - */ -s32 SigGetSize(const CSR_SIGNAL *aSignal); - -#endif /* __CSR_WIFI_HIP_SIGNALS_H__ */ diff --git a/drivers/staging/csr/csr_wifi_hip_sigs.h b/drivers/staging/csr/csr_wifi_hip_sigs.h deleted file mode 100644 index 6112cc3e87fa..000000000000 --- a/drivers/staging/csr/csr_wifi_hip_sigs.h +++ /dev/null @@ -1,1417 +0,0 @@ -/***************************************************************************** - - (c) Cambridge Silicon Radio Limited 2011 - All rights reserved and confidential information of CSR - - Refer to LICENSE.txt included with this source for details - on the license terms. - -*****************************************************************************/ - -/* Note: this is an auto-generated file. */ - - -/* Generated by hip_dd_l_h_gen.pl */ - -#ifndef CSR_WIFI_HIP_SIGS_H -#define CSR_WIFI_HIP_SIGS_H - -typedef s16 csr_place_holding_type; - -typedef u16 CSR_ASSOCIATION_ID; - -typedef u16 CSR_AUTONOMOUS_SCAN_ID; - -typedef u16 CSR_BEACON_PERIODS; - -typedef u16 CSR_BLACKOUT_ID; - -typedef enum CSR_BLACKOUT_SOURCE -{ - CSR_DOT11_LOCAL = 0x0000, - CSR_DOT11_REMOTE = 0x0001, - CSR_OTHER_RADIO = 0x0002, - CSR_NOT_LINKED = 0x0004 -} CSR_BLACKOUT_SOURCE; - -typedef enum CSR_BLACKOUT_TYPE -{ - CSR_LOCAL_DEVICE_ONLY = 0x0001, - CSR_SPECIFIED_PEER = 0x0002, - CSR_CURRENT_CHANNEL = 0x0004, - CSR_P2P = 0x0008 -} CSR_BLACKOUT_TYPE; - -typedef enum CSR_BOOT_LOADER_OPERATION -{ - CSR_BOOT_LOADER_IDLE = 0x00, - CSR_BOOT_LOADER_RESTART = 0x01, - CSR_BOOT_LOADER_PATCH = 0x02, - CSR_BOOT_LOADER_IMAGE_0 = 0x10, - CSR_BOOT_LOADER_IMAGE_1 = 0x11, - CSR_BOOT_LOADER_IMAGE_2 = 0x12, - CSR_BOOT_LOADER_IMAGE_3 = 0x13 -} CSR_BOOT_LOADER_OPERATION; - -typedef u16 CSR_CAPABILITY_INFORMATION; - -typedef u16 CSR_CHANNEL_STARTING_FACTOR; - -typedef u32 CSR_CIPHER_SUITE_SELECTOR; - -typedef u32 CSR_CLIENT_TAG; - -typedef enum CSR_CONNECTION_STATUS -{ - CSR_DISCONNECTED = 0x0000, - CSR_CONNECTED_AWAKE = 0x0001 -} CSR_CONNECTION_STATUS; - -typedef s16 CSR_DECIBELS; - -typedef enum CSR_DIRECTION -{ - CSR_TRANSMIT = 0x0000, - CSR_RECEIVE = 0x0001, - CSR_BIDIRECTIONAL = 0x0003 -} CSR_DIRECTION; - -typedef enum CSR_FRAME_TYPE -{ - CSR_RESERVED = 0x0000, - CSR_BEACON = 0x0001, - CSR_PROBE_RESPONSE = 0x0002, - CSR_BEACON_AND_PROBE_RESPONSE = 0x0003, - CSR_PROBE_REQUEST = 0x0004 -} CSR_FRAME_TYPE; - -typedef u32 CSR_IPV4_ADDRESS; - -typedef enum CSR_IFINTERFACE -{ - CSR_INDEX_2G4 = 0x0001, - CSR_INDEX_5G = 0x0002 -} CSR_IFINTERFACE; - -typedef enum CSR_KEY_TYPE -{ - CSR_GROUP = 0x0000, - CSR_PAIRWISE = 0x0001, - CSR_PEER_KEY = 0x0002, - CSR_IGTK = 0x0003 -} CSR_KEY_TYPE; - -typedef enum CSR_LOADER_OPERATION -{ - CSR_LOADER_IDLE = 0x0000, - CSR_LOADER_COPY = 0x0001 -} CSR_LOADER_OPERATION; - -typedef struct CSR_MAC_ADDRESS -{ - u8 x[6]; -} CSR_MACADDRESS; - -typedef enum CSR_MIB_STATUS -{ - CSR_MIB_SUCCESSFUL = 0x0000, - CSR_MIB_INVALID_PARAMETERS = 0x0001, - CSR_MIB_WRITE_ONLY = 0x0002, - CSR_MIB_READ_ONLY = 0x0003 -} CSR_MIB_STATUS; - -typedef enum CSR_MEMORY_SPACE -{ - CSR_NONE = 0x00, - CSR_SHARED_DATA_MEMORY = 0x01, - CSR_EXTERNAL_FLASH_MEMORY = 0x02, - CSR_EXTERNAL_SRAM = 0x03, - CSR_REGISTERS = 0x04, - CSR_PHY_PROCESSOR_DATA_MEMORY = 0x10, - CSR_PHY_PROCESSOR_PROGRAM_MEMORY = 0x11, - CSR_PHY_PROCESSOR_ROM = 0x12, - CSR_MAC_PROCESSOR_DATA_MEMORY = 0x20, - CSR_MAC_PROCESSOR_PROGRAM_MEMORY = 0x21, - CSR_MAC_PROCESSOR_ROM = 0x22, - CSR_BT_PROCESSOR_DATA_MEMORY = 0x30, - CSR_BT_PROCESSOR_PROGRAM_MEMORY = 0x31, - CSR_BT_PROCESSOR_ROM = 0x32 -} CSR_MEMORY_SPACE; - -typedef u16 CSR_MICROSECONDS16; - -typedef u32 CSR_MICROSECONDS32; - -typedef u16 CSR_NATURAL16; - -typedef enum CSR_PS_SCHEME -{ - CSR_LEGACY_PS = 0x0001, - CSR_U_APSD = 0x0002, - CSR_S_APSD = 0x0004 -} CSR_PS_SCHEME; - -typedef enum CSR_PACKET_FILTER_MODE -{ - CSR_PFM_OPT_OUT = 0x0000, - CSR_PFM_OPT_IN = 0x0003 -} CSR_PACKET_FILTER_MODE; - -typedef u16 CSR_PERIODIC_ID; - -typedef enum CSR_PERIODIC_SCHEDULING_MODE -{ - CSR_PSM_PERIODIC_SCHEDULE_PS_POLL = 0x0001, - CSR_PSM_PERIODIC_SCHEDULE_PM_BIT = 0x0002, - CSR_PSM_PERIODIC_SCHEDULE_UAPSD = 0x0004, - CSR_PSM_PERIODIC_SCHEDULE_SAPSD = 0x0008 -} CSR_PERIODIC_SCHEDULING_MODE; - -typedef enum CSR_POWER_MANAGEMENT_MODE -{ - CSR_PMM_ACTIVE_MODE = 0x0000, - CSR_PMM_POWER_SAVE = 0x0001, - CSR_PMM_FAST_POWER_SAVE = 0x0002 -} CSR_POWER_MANAGEMENT_MODE; - -typedef enum CSR_PRIORITY -{ - CSR_QOS_UP0 = 0x0000, - CSR_QOS_UP1 = 0x0001, - CSR_QOS_UP2 = 0x0002, - CSR_QOS_UP3 = 0x0003, - CSR_QOS_UP4 = 0x0004, - CSR_QOS_UP5 = 0x0005, - CSR_QOS_UP6 = 0x0006, - CSR_QOS_UP7 = 0x0007, - CSR_CONTENTION = 0x8000, - CSR_MANAGEMENT = 0x8010 -} CSR_PRIORITY; - -typedef enum CSR_REASON_CODE -{ - CSR_UNSPECIFIED_REASON = 0x0001, - CSR_INVALID_INFORMATION_ELEMENT = 0x000d, - CSR_QOS_UNSPECIFIED_REASON = 0x0020, - CSR_QOS_EXCESSIVE_NOT_ACK = 0x0022, - CSR_QOS_TXOP_LIMIT_EXCEEDED = 0x0023, - CSR_QSTA_LEAVING = 0x0024, - CSR_UNKNOWN_BA = 0x0026, - CSR_UNKNOWN_TS = 0x0026, - CSR_TIMEOUT = 0x0027 -} CSR_REASON_CODE; - -typedef enum CSR_RECEPTION_STATUS -{ - CSR_RX_SUCCESS = 0x0000, - CSR_RX_FAILURE_UNSPECIFIED = 0x0001, - CSR_MICHAEL_MIC_ERROR = 0x0002, - CSR_DECRYPTION_ERROR = 0x0003, - CSR_NO_TEMPORAL_KEY_AVAILABLE = 0x0004, - CSR_UNSUPPORTED_MODULATION = 0x0011, - CSR_BAD_FCS = 0x0012, - CSR_BAD_SIGNAL = 0x0013 -} CSR_RECEPTION_STATUS; - -typedef enum CSR_RESULT_CODE -{ - CSR_RC_SUCCESS = 0x0000, - CSR_RC_UNSPECIFIED_FAILURE = 0x0001, - CSR_RC_REFUSED = 0x0003, - CSR_RC_INVALID_PARAMETERS = 0x0026, - CSR_RC_REJECTED_INVALID_IE = 0x0028, - CSR_RC_REJECTED_INVALID_GROUP_CIPHER = 0x0029, - CSR_RC_REJECTED_INVALID_PAIRWISE_CIPHER = 0x002a, - CSR_RC_TIMEOUT = 0x8000, - CSR_RC_TOO_MANY_SIMULTANEOUS_REQUESTS = 0x8001, - CSR_RC_BSS_ALREADY_STARTED_OR_JOINED = 0x8002, - CSR_RC_NOT_SUPPORTED = 0x8003, - CSR_RC_TRANSMISSION_FAILURE = 0x8004, - CSR_RC_RESET_REQUIRED_BEFORE_START = 0x8006, - CSR_RC_INSUFFICIENT_RESOURCE = 0x8007, - CSR_RC_NO_BUFFERED_BROADCAST_MULTICAST_FRAMES = 0x8008, - CSR_RC_INVALID_UNICAST_CIPHER = 0xf02f, - CSR_RC_INVALID_MULTICAST_CIPHER = 0xf030 -} CSR_RESULT_CODE; - -typedef enum CSR_SCAN_TYPE -{ - CSR_SC_ACTIVE_SCAN = 0x0000, - CSR_SC_PASSIVE_SCAN = 0x0001 -} CSR_SCAN_TYPE; - -typedef enum CSR_SIGNAL_ID -{ - CSR_MA_PACKET_REQUEST_ID = 0x0110, - CSR_MA_PACKET_CONFIRM_ID = 0x0111, - CSR_MA_PACKET_INDICATION_ID = 0x0113, - CSR_MA_PACKET_CANCEL_REQUEST_ID = 0x0114, - CSR_MA_VIF_AVAILABILITY_RESPONSE_ID = 0x0116, - CSR_MA_VIF_AVAILABILITY_INDICATION_ID = 0x0117, - CSR_MA_PACKET_ERROR_INDICATION_ID = 0x011b, - CSR_MLME_RESET_REQUEST_ID = 0x0200, - CSR_MLME_RESET_CONFIRM_ID = 0x0201, - CSR_MLME_GET_REQUEST_ID = 0x0204, - CSR_MLME_GET_CONFIRM_ID = 0x0205, - CSR_MLME_SET_REQUEST_ID = 0x0208, - CSR_MLME_SET_CONFIRM_ID = 0x0209, - CSR_MLME_GET_NEXT_REQUEST_ID = 0x020c, - CSR_MLME_GET_NEXT_CONFIRM_ID = 0x020d, - CSR_MLME_POWERMGT_REQUEST_ID = 0x0210, - CSR_MLME_POWERMGT_CONFIRM_ID = 0x0211, - CSR_MLME_SCAN_REQUEST_ID = 0x0214, - CSR_MLME_SCAN_CONFIRM_ID = 0x0215, - CSR_MLME_HL_SYNC_REQUEST_ID = 0x0244, - CSR_MLME_HL_SYNC_CONFIRM_ID = 0x0245, - CSR_MLME_MEASURE_REQUEST_ID = 0x0258, - CSR_MLME_MEASURE_CONFIRM_ID = 0x0259, - CSR_MLME_MEASURE_INDICATION_ID = 0x025b, - CSR_MLME_SETKEYS_REQUEST_ID = 0x0268, - CSR_MLME_SETKEYS_CONFIRM_ID = 0x0269, - CSR_MLME_DELETEKEYS_REQUEST_ID = 0x026c, - CSR_MLME_DELETEKEYS_CONFIRM_ID = 0x026d, - CSR_MLME_AUTONOMOUS_SCAN_LOSS_INDICATION_ID = 0x0287, - CSR_MLME_CONNECTED_INDICATION_ID = 0x028b, - CSR_MLME_SCAN_CANCEL_REQUEST_ID = 0x028c, - CSR_MLME_HL_SYNC_CANCEL_REQUEST_ID = 0x0298, - CSR_MLME_HL_SYNC_CANCEL_CONFIRM_ID = 0x0299, - CSR_MLME_ADD_PERIODIC_REQUEST_ID = 0x02a0, - CSR_MLME_ADD_PERIODIC_CONFIRM_ID = 0x02a1, - CSR_MLME_DEL_PERIODIC_REQUEST_ID = 0x02a4, - CSR_MLME_DEL_PERIODIC_CONFIRM_ID = 0x02a5, - CSR_MLME_ADD_AUTONOMOUS_SCAN_REQUEST_ID = 0x02a8, - CSR_MLME_ADD_AUTONOMOUS_SCAN_CONFIRM_ID = 0x02a9, - CSR_MLME_DEL_AUTONOMOUS_SCAN_REQUEST_ID = 0x02ac, - CSR_MLME_DEL_AUTONOMOUS_SCAN_CONFIRM_ID = 0x02ad, - CSR_MLME_SET_PACKET_FILTER_REQUEST_ID = 0x02b8, - CSR_MLME_SET_PACKET_FILTER_CONFIRM_ID = 0x02b9, - CSR_MLME_STOP_MEASURE_REQUEST_ID = 0x02bc, - CSR_MLME_STOP_MEASURE_CONFIRM_ID = 0x02bd, - CSR_MLME_PAUSE_AUTONOMOUS_SCAN_REQUEST_ID = 0x02cc, - CSR_MLME_PAUSE_AUTONOMOUS_SCAN_CONFIRM_ID = 0x02cd, - CSR_MLME_AUTONOMOUS_SCAN_DONE_INDICATION_ID = 0x02db, - CSR_MLME_ADD_TRIGGERED_GET_REQUEST_ID = 0x02dc, - CSR_MLME_ADD_TRIGGERED_GET_CONFIRM_ID = 0x02dd, - CSR_MLME_DEL_TRIGGERED_GET_REQUEST_ID = 0x02e0, - CSR_MLME_DEL_TRIGGERED_GET_CONFIRM_ID = 0x02e1, - CSR_MLME_TRIGGERED_GET_INDICATION_ID = 0x02e7, - CSR_MLME_ADD_BLACKOUT_REQUEST_ID = 0x02f8, - CSR_MLME_ADD_BLACKOUT_CONFIRM_ID = 0x02f9, - CSR_MLME_BLACKOUT_ENDED_INDICATION_ID = 0x02fb, - CSR_MLME_DEL_BLACKOUT_REQUEST_ID = 0x02fc, - CSR_MLME_DEL_BLACKOUT_CONFIRM_ID = 0x02fd, - CSR_MLME_ADD_RX_TRIGGER_REQUEST_ID = 0x0304, - CSR_MLME_ADD_RX_TRIGGER_CONFIRM_ID = 0x0305, - CSR_MLME_DEL_RX_TRIGGER_REQUEST_ID = 0x0308, - CSR_MLME_DEL_RX_TRIGGER_CONFIRM_ID = 0x0309, - CSR_MLME_CONNECT_STATUS_REQUEST_ID = 0x0310, - CSR_MLME_CONNECT_STATUS_CONFIRM_ID = 0x0311, - CSR_MLME_MODIFY_BSS_PARAMETER_REQUEST_ID = 0x0314, - CSR_MLME_MODIFY_BSS_PARAMETER_CONFIRM_ID = 0x0315, - CSR_MLME_ADD_TEMPLATE_REQUEST_ID = 0x0318, - CSR_MLME_ADD_TEMPLATE_CONFIRM_ID = 0x0319, - CSR_MLME_CONFIG_QUEUE_REQUEST_ID = 0x031c, - CSR_MLME_CONFIG_QUEUE_CONFIRM_ID = 0x031d, - CSR_MLME_ADD_TSPEC_REQUEST_ID = 0x0320, - CSR_MLME_ADD_TSPEC_CONFIRM_ID = 0x0321, - CSR_MLME_DEL_TSPEC_REQUEST_ID = 0x0324, - CSR_MLME_DEL_TSPEC_CONFIRM_ID = 0x0325, - CSR_MLME_START_AGGREGATION_REQUEST_ID = 0x0328, - CSR_MLME_START_AGGREGATION_CONFIRM_ID = 0x0329, - CSR_MLME_BLOCKACK_ERROR_INDICATION_ID = 0x032b, - CSR_MLME_STOP_AGGREGATION_REQUEST_ID = 0x032c, - CSR_MLME_STOP_AGGREGATION_CONFIRM_ID = 0x032d, - CSR_MLME_SM_START_REQUEST_ID = 0x0334, - CSR_MLME_SM_START_CONFIRM_ID = 0x0335, - CSR_MLME_LEAVE_REQUEST_ID = 0x0338, - CSR_MLME_LEAVE_CONFIRM_ID = 0x0339, - CSR_MLME_SET_TIM_REQUEST_ID = 0x033c, - CSR_MLME_SET_TIM_CONFIRM_ID = 0x033d, - CSR_MLME_GET_KEY_SEQUENCE_REQUEST_ID = 0x0340, - CSR_MLME_GET_KEY_SEQUENCE_CONFIRM_ID = 0x0341, - CSR_MLME_SET_CHANNEL_REQUEST_ID = 0x034c, - CSR_MLME_SET_CHANNEL_CONFIRM_ID = 0x034d, - CSR_MLME_ADD_MULTICAST_ADDRESS_REQUEST_ID = 0x040c, - CSR_MLME_ADD_MULTICAST_ADDRESS_CONFIRM_ID = 0x040d, - CSR_DEBUG_STRING_INDICATION_ID = 0x0803, - CSR_DEBUG_WORD16_INDICATION_ID = 0x0807, - CSR_DEBUG_GENERIC_REQUEST_ID = 0x0808, - CSR_DEBUG_GENERIC_CONFIRM_ID = 0x0809, - CSR_DEBUG_GENERIC_INDICATION_ID = 0x080b -} CSR_SIGNAL_ID; - -typedef u16 CSR_SIMPLE_POINTER; - -typedef u16 CSR_STARTING_SEQUENCE_NUMBER; - -typedef enum CSR_SYMBOL_ID -{ - CSR_SLT_END = 0x0000, - CSR_SLT_PCI_SLOT_CONFIG = 0x0001, - CSR_SLT_SDIO_SLOT_CONFIG = 0x0002, - CSR_SLT_BUILD_ID_NUMBER = 0x0003, - CSR_SLT_BUILD_ID_STRING = 0x0004, - CSR_SLT_PERSISTENT_STORE_DB = 0x0005, - CSR_SLT_RESET_VECTOR_PHY = 0x0006, - CSR_SLT_RESET_VECTOR_MAC = 0x0007, - CSR_SLT_SDIO_LOADER_CONTROL = 0x0008, - CSR_SLT_TEST_CMD = 0x0009, - CSR_SLT_TEST_ALIVE_COUNTER = 0x000a, - CSR_SLT_TEST_PARAMETERS = 0x000b, - CSR_SLT_TEST_RESULTS = 0x000c, - CSR_SLT_TEST_VERSION = 0x000d, - CSR_SLT_MIB_PSID_RANGES = 0x000e, - CSR_SLT_KIP_TABLE = 0x000f, - CSR_SLT_PANIC_DATA_PHY = 0x0010, - CSR_SLT_PANIC_DATA_MAC = 0x0011, - CSR_SLT_BOOT_LOADER_CONTROL = 0x0012, - CSR_SLT_SOFT_MAC = 0x0013 -} CSR_SYMBOL_ID; - -typedef struct CSR_TSF_TIME -{ - u8 x[8]; -} CSR_TSF_TIME; - -typedef u16 CSR_TIME_UNITS; - -typedef enum CSR_TRANSMISSION_CONTROL -{ - CSR_TRIGGERED = 0x0001, - CSR_END_OF_SERVICE = 0x0002, - CSR_NO_CONFIRM_REQUIRED = 0x0004, - CSR_ALLOW_BA = 0x0008 -} CSR_TRANSMISSION_CONTROL; - -typedef enum CSR_TRANSMISSION_STATUS -{ - CSR_TX_SUCCESSFUL = 0x0000, - CSR_TX_RETRY_LIMIT = 0x0001, - CSR_TX_LIFETIME = 0x0002, - CSR_TX_NO_BSS = 0x0003, - CSR_TX_EXCESSIVE_DATA_LENGTH = 0x0004, - CSR_TX_UNSUPPORTED_PRIORITY = 0x0006, - CSR_TX_UNAVAILABLE_PRIORITY = 0x0007, - CSR_TX_UNAVAILABLE_KEY_MAPPING = 0x000a, - CSR_TX_EDCA_TIMEOUT = 0x000b, - CSR_TX_BLOCK_ACK_TIMEOUT = 0x000c, - CSR_TX_FAIL_TRANSMISSION_VIF_INTERRUPTED = 0x000d, - CSR_TX_REJECTED_PEER_STATION_SLEEPING = 0x000e, - CSR_TX_REJECTED_DTIM_ENDED = 0x000f, - CSR_TX_REJECTED_DTIM_STARTED = 0x0010 -} CSR_TRANSMISSION_STATUS; - -typedef u16 CSR_TRIGGER_ID; - -typedef u16 CSR_TRIGGERED_ID; - -typedef enum CSR_HIP_VERSIONS -{ - CSR_HIP_ENG_VERSION = 0x0001, - CSR_HIP_VERSION = 0x0900 -} CSR_HIP_VERSIONS; - -typedef u16 CSR_BUFFER_HANDLE; - -typedef u16 CSR_CHANNEL_NUMBER; - -typedef struct CSR_DATA_REFERENCE -{ - u16 SlotNumber; - u16 DataLength; -} CSR_DATAREF; - -typedef u16 CSR_DIALOG_TOKEN; - -typedef struct CSR_GENERIC_POINTER -{ - u32 MemoryOffset; - CSR_MEMORY_SPACE MemorySpace; -} CSR_GENERIC_POINTER; - -typedef struct CSR_MLME_CONFIG_QUEUE_CONFIRM -{ - CSR_DATAREF Dummydataref1; - CSR_DATAREF Dummydataref2; - CSR_RESULT_CODE ResultCode; -} CSR_MLME_CONFIG_QUEUE_CONFIRM; - -typedef struct CSR_MLME_CONFIG_QUEUE_REQUEST -{ - CSR_DATAREF Dummydataref1; - CSR_DATAREF Dummydataref2; - CSR_NATURAL16 QueueIndex; - CSR_NATURAL16 Aifs; - CSR_NATURAL16 Cwmin; - CSR_NATURAL16 Cwmax; - CSR_NATURAL16 TxopLimit; -} CSR_MLME_CONFIG_QUEUE_REQUEST; - -typedef struct CSR_MLME_GET_CONFIRM -{ - CSR_DATAREF MibAttributeValue; - CSR_DATAREF Dummydataref2; - CSR_MIB_STATUS Status; - CSR_NATURAL16 ErrorIndex; -} CSR_MLME_GET_CONFIRM; - -typedef struct CSR_MLME_GET_REQUEST -{ - CSR_DATAREF MibAttribute; - CSR_DATAREF Dummydataref2; -} CSR_MLME_GET_REQUEST; - -typedef struct CSR_MLME_GET_NEXT_CONFIRM -{ - CSR_DATAREF MibAttributeValue; - CSR_DATAREF Dummydataref2; - CSR_MIB_STATUS Status; - CSR_NATURAL16 ErrorIndex; -} CSR_MLME_GET_NEXT_CONFIRM; - -typedef struct CSR_MLME_GET_NEXT_REQUEST -{ - CSR_DATAREF MibAttribute; - CSR_DATAREF Dummydataref2; -} CSR_MLME_GET_NEXT_REQUEST; - -typedef struct CSR_MLME_HL_SYNC_CONFIRM -{ - CSR_DATAREF Dummydataref1; - CSR_DATAREF Dummydataref2; - CSR_MACADDRESS GroupAddress; - CSR_RESULT_CODE ResultCode; -} CSR_MLME_HL_SYNC_CONFIRM; - -typedef struct CSR_MLME_HL_SYNC_REQUEST -{ - CSR_DATAREF Dummydataref1; - CSR_DATAREF Dummydataref2; - CSR_MACADDRESS GroupAddress; -} CSR_MLME_HL_SYNC_REQUEST; - -typedef struct CSR_MLME_HL_SYNC_CANCEL_CONFIRM -{ - CSR_DATAREF Dummydataref1; - CSR_DATAREF Dummydataref2; - CSR_RESULT_CODE ResultCode; -} CSR_MLME_HL_SYNC_CANCEL_CONFIRM; - -typedef struct CSR_MLME_HL_SYNC_CANCEL_REQUEST -{ - CSR_DATAREF Dummydataref1; - CSR_DATAREF Dummydataref2; - CSR_MACADDRESS GroupAddress; -} CSR_MLME_HL_SYNC_CANCEL_REQUEST; - -typedef struct CSR_MLME_MEASURE_CONFIRM -{ - CSR_DATAREF Dummydataref1; - CSR_DATAREF Dummydataref2; - CSR_RESULT_CODE ResultCode; - CSR_DIALOG_TOKEN DialogToken; -} CSR_MLME_MEASURE_CONFIRM; - -typedef struct CSR_MLME_MEASURE_INDICATION -{ - CSR_DATAREF MeasurementReportSet; - CSR_DATAREF Dummydataref2; - CSR_DIALOG_TOKEN DialogToken; -} CSR_MLME_MEASURE_INDICATION; - -typedef struct CSR_MLME_MEASURE_REQUEST -{ - CSR_DATAREF MeasurementRequestSet; - CSR_DATAREF Dummydataref2; - CSR_DIALOG_TOKEN DialogToken; -} CSR_MLME_MEASURE_REQUEST; - -typedef struct CSR_MLME_RESET_CONFIRM -{ - CSR_DATAREF Dummydataref1; - CSR_DATAREF Dummydataref2; - CSR_RESULT_CODE ResultCode; -} CSR_MLME_RESET_CONFIRM; - -typedef struct CSR_MLME_RESET_REQUEST -{ - CSR_DATAREF Dummydataref1; - CSR_DATAREF Dummydataref2; - CSR_MACADDRESS StaAddress; - s16 SetDefaultMib; -} CSR_MLME_RESET_REQUEST; - -typedef struct CSR_MLME_SET_CONFIRM -{ - CSR_DATAREF MibAttributeValue; - CSR_DATAREF Dummydataref2; - CSR_MIB_STATUS Status; - CSR_NATURAL16 ErrorIndex; -} CSR_MLME_SET_CONFIRM; - -typedef struct CSR_MLME_SET_REQUEST -{ - CSR_DATAREF MibAttributeValue; - CSR_DATAREF Dummydataref2; -} CSR_MLME_SET_REQUEST; - -typedef struct CSR_MLME_STOP_MEASURE_CONFIRM -{ - CSR_DATAREF Dummydataref1; - CSR_DATAREF Dummydataref2; - CSR_RESULT_CODE ResultCode; - CSR_DIALOG_TOKEN DialogToken; -} CSR_MLME_STOP_MEASURE_CONFIRM; - -typedef struct CSR_MLME_STOP_MEASURE_REQUEST -{ - CSR_DATAREF Dummydataref1; - CSR_DATAREF Dummydataref2; - CSR_DIALOG_TOKEN DialogToken; -} CSR_MLME_STOP_MEASURE_REQUEST; - -typedef u16 CSR_PROCESS_ID; - -typedef u16 CSR_RATE; - -typedef u16 CSR_SEQUENCE_NUMBER; - -typedef struct CSR_SIGNAL_PRIMITIVE_HEADER -{ - s16 SignalId; - CSR_PROCESS_ID ReceiverProcessId; - CSR_PROCESS_ID SenderProcessId; -} CSR_SIGNAL_PRIMITIVE_HEADER; - -typedef u16 CSR_TRAFFIC_WINDOW; - -typedef u16 CSR_VIF_IDENTIFIER; - -typedef struct CSR_DEBUG_GENERIC_CONFIRM -{ - CSR_DATAREF DebugVariable; - CSR_DATAREF Dummydataref2; - CSR_NATURAL16 DebugWords[8]; -} CSR_DEBUG_GENERIC_CONFIRM; - -typedef struct CSR_DEBUG_GENERIC_INDICATION -{ - CSR_DATAREF DebugVariable; - CSR_DATAREF Dummydataref2; - CSR_NATURAL16 DebugWords[8]; -} CSR_DEBUG_GENERIC_INDICATION; - -typedef struct CSR_DEBUG_GENERIC_REQUEST -{ - CSR_DATAREF DebugVariable; - CSR_DATAREF Dummydataref2; - CSR_NATURAL16 DebugWords[8]; -} CSR_DEBUG_GENERIC_REQUEST; - -typedef struct CSR_DEBUG_STRING_INDICATION -{ - CSR_DATAREF DebugMessage; - CSR_DATAREF Dummydataref2; -} CSR_DEBUG_STRING_INDICATION; - -typedef struct CSR_DEBUG_WORD16_INDICATION -{ - CSR_DATAREF Dummydataref1; - CSR_DATAREF Dummydataref2; - CSR_NATURAL16 DebugWords[16]; -} CSR_DEBUG_WORD16_INDICATION; - -typedef struct CSR_MA_PACKET_CONFIRM -{ - CSR_DATAREF Dummydataref1; - CSR_DATAREF Dummydataref2; - CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier; - CSR_TRANSMISSION_STATUS TransmissionStatus; - CSR_NATURAL16 RetryCount; - CSR_RATE Rate; - CSR_CLIENT_TAG HostTag; -} CSR_MA_PACKET_CONFIRM; - -typedef struct CSR_MA_PACKET_INDICATION -{ - CSR_DATAREF Data; - CSR_DATAREF Dummydataref2; - CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier; - CSR_TSF_TIME LocalTime; - CSR_IFINTERFACE Ifindex; - CSR_CHANNEL_NUMBER Channel; - CSR_RECEPTION_STATUS ReceptionStatus; - CSR_DECIBELS Rssi; - CSR_DECIBELS Snr; - CSR_RATE ReceivedRate; -} CSR_MA_PACKET_INDICATION; - -typedef struct CSR_MA_PACKET_REQUEST -{ - CSR_DATAREF Data; - CSR_DATAREF Dummydataref2; - CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier; - CSR_RATE TransmitRate; - CSR_CLIENT_TAG HostTag; - CSR_PRIORITY Priority; - CSR_MACADDRESS Ra; - CSR_TRANSMISSION_CONTROL TransmissionControl; -} CSR_MA_PACKET_REQUEST; - -typedef struct CSR_MA_PACKET_CANCEL_REQUEST -{ - CSR_DATAREF Dummydataref1; - CSR_DATAREF Dummydataref2; - CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier; - CSR_CLIENT_TAG HostTag; -} CSR_MA_PACKET_CANCEL_REQUEST; - -typedef struct CSR_MA_PACKET_ERROR_INDICATION -{ - CSR_DATAREF Dummydataref1; - CSR_DATAREF Dummydataref2; - CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier; - CSR_MACADDRESS PeerQstaAddress; - CSR_PRIORITY UserPriority; - CSR_SEQUENCE_NUMBER SequenceNumber; -} CSR_MA_PACKET_ERROR_INDICATION; - -typedef struct CSR_MA_VIF_AVAILABILITY_INDICATION -{ - CSR_DATAREF Dummydataref1; - CSR_DATAREF Dummydataref2; - CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier; - s16 Multicast; -} CSR_MA_VIF_AVAILABILITY_INDICATION; - -typedef struct CSR_MA_VIF_AVAILABILITY_RESPONSE -{ - CSR_DATAREF Dummydataref1; - CSR_DATAREF Dummydataref2; - CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier; - CSR_RESULT_CODE ResultCode; -} CSR_MA_VIF_AVAILABILITY_RESPONSE; - -typedef struct CSR_MLME_ADD_AUTONOMOUS_SCAN_CONFIRM -{ - CSR_DATAREF Dummydataref1; - CSR_DATAREF Dummydataref2; - CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier; - CSR_RESULT_CODE ResultCode; - CSR_AUTONOMOUS_SCAN_ID AutonomousScanId; -} CSR_MLME_ADD_AUTONOMOUS_SCAN_CONFIRM; - -typedef struct CSR_MLME_ADD_AUTONOMOUS_SCAN_REQUEST -{ - CSR_DATAREF ChannelList; - CSR_DATAREF InformationElements; - CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier; - CSR_AUTONOMOUS_SCAN_ID AutonomousScanId; - CSR_IFINTERFACE Ifindex; - CSR_CHANNEL_STARTING_FACTOR ChannelStartingFactor; - CSR_SCAN_TYPE ScanType; - CSR_MICROSECONDS32 ProbeDelay; - CSR_TIME_UNITS MinChannelTime; - CSR_TIME_UNITS MaxChannelTime; -} CSR_MLME_ADD_AUTONOMOUS_SCAN_REQUEST; - -typedef struct CSR_MLME_ADD_BLACKOUT_CONFIRM -{ - CSR_DATAREF Dummydataref1; - CSR_DATAREF Dummydataref2; - CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier; - CSR_BLACKOUT_ID BlackoutId; - CSR_RESULT_CODE ResultCode; -} CSR_MLME_ADD_BLACKOUT_CONFIRM; - -typedef struct CSR_MLME_ADD_BLACKOUT_REQUEST -{ - CSR_DATAREF Dummydataref1; - CSR_DATAREF Dummydataref2; - CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier; - CSR_BLACKOUT_ID BlackoutId; - CSR_BLACKOUT_TYPE BlackoutType; - CSR_BLACKOUT_SOURCE BlackoutSource; - CSR_MICROSECONDS32 BlackoutStartReference; - CSR_MICROSECONDS32 BlackoutPeriod; - CSR_MICROSECONDS32 BlackoutDuration; - CSR_MACADDRESS PeerStaAddress; - CSR_NATURAL16 BlackoutCount; -} CSR_MLME_ADD_BLACKOUT_REQUEST; - -typedef struct CSR_MLME_ADD_MULTICAST_ADDRESS_CONFIRM -{ - CSR_DATAREF Dummydataref1; - CSR_DATAREF Dummydataref2; - CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier; - CSR_RESULT_CODE ResultCode; -} CSR_MLME_ADD_MULTICAST_ADDRESS_CONFIRM; - -typedef struct CSR_MLME_ADD_MULTICAST_ADDRESS_REQUEST -{ - CSR_DATAREF Data; - CSR_DATAREF Dummydataref2; - CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier; - CSR_NATURAL16 NumberOfMulticastGroupAddresses; -} CSR_MLME_ADD_MULTICAST_ADDRESS_REQUEST; - -typedef struct CSR_MLME_ADD_PERIODIC_CONFIRM -{ - CSR_DATAREF Dummydataref1; - CSR_DATAREF Dummydataref2; - CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier; - CSR_PERIODIC_ID PeriodicId; - CSR_RESULT_CODE ResultCode; -} CSR_MLME_ADD_PERIODIC_CONFIRM; - -typedef struct CSR_MLME_ADD_PERIODIC_REQUEST -{ - CSR_DATAREF Dummydataref1; - CSR_DATAREF Dummydataref2; - CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier; - CSR_PERIODIC_ID PeriodicId; - CSR_MICROSECONDS32 MaximumLatency; - CSR_PERIODIC_SCHEDULING_MODE PeriodicSchedulingMode; - s16 WakeHost; - CSR_PRIORITY UserPriority; -} CSR_MLME_ADD_PERIODIC_REQUEST; - -typedef struct CSR_MLME_ADD_RX_TRIGGER_CONFIRM -{ - CSR_DATAREF Dummydataref1; - CSR_DATAREF Dummydataref2; - CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier; - CSR_TRIGGER_ID TriggerId; - CSR_RESULT_CODE ResultCode; -} CSR_MLME_ADD_RX_TRIGGER_CONFIRM; - -typedef struct CSR_MLME_ADD_RX_TRIGGER_REQUEST -{ - CSR_DATAREF InformationElements; - CSR_DATAREF Dummydataref2; - CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier; - CSR_TRIGGER_ID TriggerId; - CSR_PRIORITY Priority; -} CSR_MLME_ADD_RX_TRIGGER_REQUEST; - -typedef struct CSR_MLME_ADD_TEMPLATE_CONFIRM -{ - CSR_DATAREF Dummydataref1; - CSR_DATAREF Dummydataref2; - CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier; - CSR_FRAME_TYPE FrameType; - CSR_RESULT_CODE ResultCode; -} CSR_MLME_ADD_TEMPLATE_CONFIRM; - -typedef struct CSR_MLME_ADD_TEMPLATE_REQUEST -{ - CSR_DATAREF Data1; - CSR_DATAREF Data2; - CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier; - CSR_FRAME_TYPE FrameType; - CSR_RATE MinTransmitRate; -} CSR_MLME_ADD_TEMPLATE_REQUEST; - -typedef struct CSR_MLME_ADD_TRIGGERED_GET_CONFIRM -{ - CSR_DATAREF Dummydataref1; - CSR_DATAREF Dummydataref2; - CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier; - CSR_RESULT_CODE ResultCode; - CSR_TRIGGERED_ID TriggeredId; -} CSR_MLME_ADD_TRIGGERED_GET_CONFIRM; - -typedef struct CSR_MLME_ADD_TRIGGERED_GET_REQUEST -{ - CSR_DATAREF MibAttribute; - CSR_DATAREF Dummydataref2; - CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier; - CSR_TRIGGERED_ID TriggeredId; -} CSR_MLME_ADD_TRIGGERED_GET_REQUEST; - -typedef struct CSR_MLME_ADD_TSPEC_CONFIRM -{ - CSR_DATAREF Dummydataref1; - CSR_DATAREF Dummydataref2; - CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier; - CSR_PRIORITY UserPriority; - CSR_RESULT_CODE ResultCode; -} CSR_MLME_ADD_TSPEC_CONFIRM; - -typedef struct CSR_MLME_ADD_TSPEC_REQUEST -{ - CSR_DATAREF Dummydataref1; - CSR_DATAREF Dummydataref2; - CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier; - CSR_PRIORITY UserPriority; - CSR_DIRECTION Direction; - CSR_PS_SCHEME PsScheme; - CSR_NATURAL16 MediumTime; - CSR_MICROSECONDS32 ServiceStartTime; - CSR_MICROSECONDS32 ServiceInterval; - CSR_RATE MinimumDataRate; -} CSR_MLME_ADD_TSPEC_REQUEST; - -typedef struct CSR_MLME_AUTONOMOUS_SCAN_DONE_INDICATION -{ - CSR_DATAREF Dummydataref1; - CSR_DATAREF Dummydataref2; - CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier; - CSR_RESULT_CODE ResultCode; - CSR_AUTONOMOUS_SCAN_ID AutonomousScanId; -} CSR_MLME_AUTONOMOUS_SCAN_DONE_INDICATION; - -typedef struct CSR_MLME_AUTONOMOUS_SCAN_LOSS_INDICATION -{ - CSR_DATAREF Dummydataref1; - CSR_DATAREF Dummydataref2; - CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier; - CSR_MACADDRESS Bssid; -} CSR_MLME_AUTONOMOUS_SCAN_LOSS_INDICATION; - -typedef struct CSR_MLME_BLACKOUT_ENDED_INDICATION -{ - CSR_DATAREF Dummydataref1; - CSR_DATAREF Dummydataref2; - CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier; - CSR_BLACKOUT_ID BlackoutId; -} CSR_MLME_BLACKOUT_ENDED_INDICATION; - -typedef struct CSR_MLME_BLOCKACK_ERROR_INDICATION -{ - CSR_DATAREF Dummydataref1; - CSR_DATAREF Dummydataref2; - CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier; - CSR_REASON_CODE ResultCode; - CSR_MACADDRESS PeerQstaAddress; -} CSR_MLME_BLOCKACK_ERROR_INDICATION; - -typedef struct CSR_MLME_CONNECTED_INDICATION -{ - CSR_DATAREF Dummydataref1; - CSR_DATAREF Dummydataref2; - CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier; - CSR_CONNECTION_STATUS ConnectionStatus; - CSR_MACADDRESS PeerMacAddress; -} CSR_MLME_CONNECTED_INDICATION; - -typedef struct CSR_MLME_CONNECT_STATUS_CONFIRM -{ - CSR_DATAREF Dummydataref1; - CSR_DATAREF Dummydataref2; - CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier; - CSR_RESULT_CODE ResultCode; -} CSR_MLME_CONNECT_STATUS_CONFIRM; - -typedef struct CSR_MLME_CONNECT_STATUS_REQUEST -{ - CSR_DATAREF InformationElements; - CSR_DATAREF Dummydataref2; - CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier; - CSR_CONNECTION_STATUS ConnectionStatus; - CSR_MACADDRESS StaAddress; - CSR_ASSOCIATION_ID AssociationId; - CSR_CAPABILITY_INFORMATION AssociationCapabilityInformation; -} CSR_MLME_CONNECT_STATUS_REQUEST; - -typedef struct CSR_MLME_DELETEKEYS_CONFIRM -{ - CSR_DATAREF Dummydataref1; - CSR_DATAREF Dummydataref2; - CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier; - CSR_RESULT_CODE ResultCode; -} CSR_MLME_DELETEKEYS_CONFIRM; - -typedef struct CSR_MLME_DELETEKEYS_REQUEST -{ - CSR_DATAREF Dummydataref1; - CSR_DATAREF Dummydataref2; - CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier; - CSR_NATURAL16 KeyId; - CSR_KEY_TYPE KeyType; - CSR_MACADDRESS Address; -} CSR_MLME_DELETEKEYS_REQUEST; - -typedef struct CSR_MLME_DEL_AUTONOMOUS_SCAN_CONFIRM -{ - CSR_DATAREF Dummydataref1; - CSR_DATAREF Dummydataref2; - CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier; - CSR_RESULT_CODE ResultCode; - CSR_AUTONOMOUS_SCAN_ID AutonomousScanId; -} CSR_MLME_DEL_AUTONOMOUS_SCAN_CONFIRM; - -typedef struct CSR_MLME_DEL_AUTONOMOUS_SCAN_REQUEST -{ - CSR_DATAREF Dummydataref1; - CSR_DATAREF Dummydataref2; - CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier; - CSR_AUTONOMOUS_SCAN_ID AutonomousScanId; -} CSR_MLME_DEL_AUTONOMOUS_SCAN_REQUEST; - -typedef struct CSR_MLME_DEL_BLACKOUT_CONFIRM -{ - CSR_DATAREF Dummydataref1; - CSR_DATAREF Dummydataref2; - CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier; - CSR_BLACKOUT_ID BlackoutId; - CSR_RESULT_CODE ResultCode; -} CSR_MLME_DEL_BLACKOUT_CONFIRM; - -typedef struct CSR_MLME_DEL_BLACKOUT_REQUEST -{ - CSR_DATAREF Dummydataref1; - CSR_DATAREF Dummydataref2; - CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier; - CSR_BLACKOUT_ID BlackoutId; -} CSR_MLME_DEL_BLACKOUT_REQUEST; - -typedef struct CSR_MLME_DEL_PERIODIC_CONFIRM -{ - CSR_DATAREF Dummydataref1; - CSR_DATAREF Dummydataref2; - CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier; - CSR_PERIODIC_ID PeriodicId; - CSR_RESULT_CODE ResultCode; -} CSR_MLME_DEL_PERIODIC_CONFIRM; - -typedef struct CSR_MLME_DEL_PERIODIC_REQUEST -{ - CSR_DATAREF Dummydataref1; - CSR_DATAREF Dummydataref2; - CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier; - CSR_PERIODIC_ID PeriodicId; -} CSR_MLME_DEL_PERIODIC_REQUEST; - -typedef struct CSR_MLME_DEL_RX_TRIGGER_CONFIRM -{ - CSR_DATAREF Dummydataref1; - CSR_DATAREF Dummydataref2; - CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier; - CSR_TRIGGER_ID TriggerId; - CSR_RESULT_CODE ResultCode; -} CSR_MLME_DEL_RX_TRIGGER_CONFIRM; - -typedef struct CSR_MLME_DEL_RX_TRIGGER_REQUEST -{ - CSR_DATAREF Dummydataref1; - CSR_DATAREF Dummydataref2; - CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier; - CSR_TRIGGER_ID TriggerId; -} CSR_MLME_DEL_RX_TRIGGER_REQUEST; - -typedef struct CSR_MLME_DEL_TRIGGERED_GET_CONFIRM -{ - CSR_DATAREF Dummydataref1; - CSR_DATAREF Dummydataref2; - CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier; - CSR_RESULT_CODE ResultCode; - CSR_TRIGGERED_ID TriggeredId; -} CSR_MLME_DEL_TRIGGERED_GET_CONFIRM; - -typedef struct CSR_MLME_DEL_TRIGGERED_GET_REQUEST -{ - CSR_DATAREF Dummydataref1; - CSR_DATAREF Dummydataref2; - CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier; - CSR_TRIGGERED_ID TriggeredId; -} CSR_MLME_DEL_TRIGGERED_GET_REQUEST; - -typedef struct CSR_MLME_DEL_TSPEC_CONFIRM -{ - CSR_DATAREF Dummydataref1; - CSR_DATAREF Dummydataref2; - CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier; - CSR_PRIORITY UserPriority; - CSR_RESULT_CODE ResultCode; -} CSR_MLME_DEL_TSPEC_CONFIRM; - -typedef struct CSR_MLME_DEL_TSPEC_REQUEST -{ - CSR_DATAREF Dummydataref1; - CSR_DATAREF Dummydataref2; - CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier; - CSR_PRIORITY UserPriority; - CSR_DIRECTION Direction; -} CSR_MLME_DEL_TSPEC_REQUEST; - -typedef struct CSR_MLME_GET_KEY_SEQUENCE_CONFIRM -{ - CSR_DATAREF Dummydataref1; - CSR_DATAREF Dummydataref2; - CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier; - CSR_RESULT_CODE ResultCode; - CSR_NATURAL16 SequenceNumber[8]; -} CSR_MLME_GET_KEY_SEQUENCE_CONFIRM; - -typedef struct CSR_MLME_GET_KEY_SEQUENCE_REQUEST -{ - CSR_DATAREF Dummydataref1; - CSR_DATAREF Dummydataref2; - CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier; - CSR_NATURAL16 KeyId; - CSR_KEY_TYPE KeyType; - CSR_MACADDRESS Address; -} CSR_MLME_GET_KEY_SEQUENCE_REQUEST; - -typedef struct CSR_MLME_LEAVE_CONFIRM -{ - CSR_DATAREF Dummydataref1; - CSR_DATAREF Dummydataref2; - CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier; - CSR_RESULT_CODE ResultCode; -} CSR_MLME_LEAVE_CONFIRM; - -typedef struct CSR_MLME_LEAVE_REQUEST -{ - CSR_DATAREF Dummydataref1; - CSR_DATAREF Dummydataref2; - CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier; -} CSR_MLME_LEAVE_REQUEST; - -typedef struct CSR_MLME_MODIFY_BSS_PARAMETER_CONFIRM -{ - CSR_DATAREF Dummydataref1; - CSR_DATAREF Dummydataref2; - CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier; - CSR_RESULT_CODE ResultCode; -} CSR_MLME_MODIFY_BSS_PARAMETER_CONFIRM; - -typedef struct CSR_MLME_MODIFY_BSS_PARAMETER_REQUEST -{ - CSR_DATAREF Data; - CSR_DATAREF Dummydataref2; - CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier; - CSR_TIME_UNITS BeaconPeriod; - CSR_BEACON_PERIODS DtimPeriod; - CSR_CAPABILITY_INFORMATION CapabilityInformation; - CSR_MACADDRESS Bssid; - CSR_NATURAL16 RtsThreshold; -} CSR_MLME_MODIFY_BSS_PARAMETER_REQUEST; - -typedef struct CSR_MLME_PAUSE_AUTONOMOUS_SCAN_CONFIRM -{ - CSR_DATAREF Dummydataref1; - CSR_DATAREF Dummydataref2; - CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier; - CSR_RESULT_CODE ResultCode; - CSR_AUTONOMOUS_SCAN_ID AutonomousScanId; -} CSR_MLME_PAUSE_AUTONOMOUS_SCAN_CONFIRM; - -typedef struct CSR_MLME_PAUSE_AUTONOMOUS_SCAN_REQUEST -{ - CSR_DATAREF Dummydataref1; - CSR_DATAREF Dummydataref2; - CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier; - CSR_AUTONOMOUS_SCAN_ID AutonomousScanId; - s16 Pause; -} CSR_MLME_PAUSE_AUTONOMOUS_SCAN_REQUEST; - -typedef struct CSR_MLME_POWERMGT_CONFIRM -{ - CSR_DATAREF Dummydataref1; - CSR_DATAREF Dummydataref2; - CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier; - CSR_RESULT_CODE ResultCode; -} CSR_MLME_POWERMGT_CONFIRM; - -typedef struct CSR_MLME_POWERMGT_REQUEST -{ - CSR_DATAREF Dummydataref1; - CSR_DATAREF Dummydataref2; - CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier; - CSR_POWER_MANAGEMENT_MODE PowerManagementMode; - s16 ReceiveDtims; - CSR_BEACON_PERIODS ListenInterval; - CSR_TRAFFIC_WINDOW TrafficWindow; -} CSR_MLME_POWERMGT_REQUEST; - -typedef struct CSR_MLME_SCAN_CONFIRM -{ - CSR_DATAREF Dummydataref1; - CSR_DATAREF Dummydataref2; - CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier; - CSR_RESULT_CODE ResultCode; -} CSR_MLME_SCAN_CONFIRM; - -typedef struct CSR_MLME_SCAN_REQUEST -{ - CSR_DATAREF ChannelList; - CSR_DATAREF InformationElements; - CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier; - CSR_IFINTERFACE Ifindex; - CSR_SCAN_TYPE ScanType; - CSR_MICROSECONDS32 ProbeDelay; - CSR_TIME_UNITS MinChannelTime; - CSR_TIME_UNITS MaxChannelTime; -} CSR_MLME_SCAN_REQUEST; - -typedef struct CSR_MLME_SCAN_CANCEL_REQUEST -{ - CSR_DATAREF Dummydataref1; - CSR_DATAREF Dummydataref2; - CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier; -} CSR_MLME_SCAN_CANCEL_REQUEST; - -typedef struct CSR_MLME_SETKEYS_CONFIRM -{ - CSR_DATAREF Dummydataref1; - CSR_DATAREF Dummydataref2; - CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier; - CSR_RESULT_CODE ResultCode; -} CSR_MLME_SETKEYS_CONFIRM; - -typedef struct CSR_MLME_SETKEYS_REQUEST -{ - CSR_DATAREF Key; - CSR_DATAREF Dummydataref2; - CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier; - CSR_NATURAL16 Length; - CSR_NATURAL16 KeyId; - CSR_KEY_TYPE KeyType; - CSR_MACADDRESS Address; - CSR_NATURAL16 SequenceNumber[8]; - CSR_CIPHER_SUITE_SELECTOR CipherSuiteSelector; -} CSR_MLME_SETKEYS_REQUEST; - -typedef struct CSR_MLME_SET_CHANNEL_CONFIRM -{ - CSR_DATAREF Dummydataref1; - CSR_DATAREF Dummydataref2; - CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier; - CSR_RESULT_CODE ResultCode; -} CSR_MLME_SET_CHANNEL_CONFIRM; - -typedef struct CSR_MLME_SET_CHANNEL_REQUEST -{ - CSR_DATAREF Dummydataref1; - CSR_DATAREF Dummydataref2; - CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier; - CSR_IFINTERFACE Ifindex; - CSR_CHANNEL_NUMBER Channel; - CSR_MACADDRESS Address; - CSR_TIME_UNITS AvailabilityDuration; - CSR_TIME_UNITS AvailabilityInterval; -} CSR_MLME_SET_CHANNEL_REQUEST; - -typedef struct CSR_MLME_SET_PACKET_FILTER_CONFIRM -{ - CSR_DATAREF Dummydataref1; - CSR_DATAREF Dummydataref2; - CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier; - CSR_RESULT_CODE ResultCode; -} CSR_MLME_SET_PACKET_FILTER_CONFIRM; - -typedef struct CSR_MLME_SET_PACKET_FILTER_REQUEST -{ - CSR_DATAREF InformationElements; - CSR_DATAREF Dummydataref2; - CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier; - CSR_PACKET_FILTER_MODE PacketFilterMode; - CSR_IPV4_ADDRESS ArpFilterAddress; -} CSR_MLME_SET_PACKET_FILTER_REQUEST; - -typedef struct CSR_MLME_SET_TIM_CONFIRM -{ - CSR_DATAREF Dummydataref1; - CSR_DATAREF Dummydataref2; - CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier; - CSR_RESULT_CODE ResultCode; -} CSR_MLME_SET_TIM_CONFIRM; - -typedef struct CSR_MLME_SET_TIM_REQUEST -{ - CSR_DATAREF Dummydataref1; - CSR_DATAREF Dummydataref2; - CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier; - CSR_ASSOCIATION_ID AssociationId; - s16 TimValue; -} CSR_MLME_SET_TIM_REQUEST; - -typedef struct CSR_MLME_SM_START_CONFIRM -{ - CSR_DATAREF Dummydataref1; - CSR_DATAREF Dummydataref2; - CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier; - CSR_RESULT_CODE ResultCode; -} CSR_MLME_SM_START_CONFIRM; - -typedef struct CSR_MLME_SM_START_REQUEST -{ - CSR_DATAREF Beacon; - CSR_DATAREF BssParameters; - CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier; - CSR_IFINTERFACE Ifindex; - CSR_CHANNEL_NUMBER Channel; - CSR_MACADDRESS InterfaceAddress; - CSR_MACADDRESS Bssid; - CSR_TIME_UNITS BeaconPeriod; - CSR_BEACON_PERIODS DtimPeriod; - CSR_CAPABILITY_INFORMATION CapabilityInformation; -} CSR_MLME_SM_START_REQUEST; - -typedef struct CSR_MLME_START_AGGREGATION_CONFIRM -{ - CSR_DATAREF Dummydataref1; - CSR_DATAREF Dummydataref2; - CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier; - CSR_MACADDRESS PeerQstaAddress; - CSR_PRIORITY UserPriority; - CSR_DIRECTION Direction; - CSR_RESULT_CODE ResultCode; - CSR_SEQUENCE_NUMBER SequenceNumber; -} CSR_MLME_START_AGGREGATION_CONFIRM; - -typedef struct CSR_MLME_START_AGGREGATION_REQUEST -{ - CSR_DATAREF Dummydataref1; - CSR_DATAREF Dummydataref2; - CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier; - CSR_MACADDRESS PeerQstaAddress; - CSR_PRIORITY UserPriority; - CSR_DIRECTION Direction; - CSR_STARTING_SEQUENCE_NUMBER StartingSequenceNumber; - CSR_NATURAL16 BufferSize; - CSR_TIME_UNITS BlockAckTimeout; -} CSR_MLME_START_AGGREGATION_REQUEST; - -typedef struct CSR_MLME_STOP_AGGREGATION_CONFIRM -{ - CSR_DATAREF Dummydataref1; - CSR_DATAREF Dummydataref2; - CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier; - CSR_MACADDRESS PeerQstaAddress; - CSR_PRIORITY UserPriority; - CSR_DIRECTION Direction; - CSR_RESULT_CODE ResultCode; -} CSR_MLME_STOP_AGGREGATION_CONFIRM; - -typedef struct CSR_MLME_STOP_AGGREGATION_REQUEST -{ - CSR_DATAREF Dummydataref1; - CSR_DATAREF Dummydataref2; - CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier; - CSR_MACADDRESS PeerQstaAddress; - CSR_PRIORITY UserPriority; - CSR_DIRECTION Direction; -} CSR_MLME_STOP_AGGREGATION_REQUEST; - -typedef struct CSR_MLME_TRIGGERED_GET_INDICATION -{ - CSR_DATAREF MibAttributeValue; - CSR_DATAREF Dummydataref2; - CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier; - CSR_MIB_STATUS Status; - CSR_NATURAL16 ErrorIndex; - CSR_TRIGGERED_ID TriggeredId; -} CSR_MLME_TRIGGERED_GET_INDICATION; - -typedef struct CSR_SIGNAL_PRIMITIVE -{ - CSR_SIGNAL_PRIMITIVE_HEADER SignalPrimitiveHeader; - union - { - CSR_MA_PACKET_REQUEST MaPacketRequest; - CSR_MA_PACKET_CONFIRM MaPacketConfirm; - CSR_MA_PACKET_INDICATION MaPacketIndication; - CSR_MA_PACKET_CANCEL_REQUEST MaPacketCancelRequest; - CSR_MA_VIF_AVAILABILITY_RESPONSE MaVifAvailabilityResponse; - CSR_MA_VIF_AVAILABILITY_INDICATION MaVifAvailabilityIndication; - CSR_MA_PACKET_ERROR_INDICATION MaPacketErrorIndication; - CSR_MLME_RESET_REQUEST MlmeResetRequest; - CSR_MLME_RESET_CONFIRM MlmeResetConfirm; - CSR_MLME_GET_REQUEST MlmeGetRequest; - CSR_MLME_GET_CONFIRM MlmeGetConfirm; - CSR_MLME_SET_REQUEST MlmeSetRequest; - CSR_MLME_SET_CONFIRM MlmeSetConfirm; - CSR_MLME_GET_NEXT_REQUEST MlmeGetNextRequest; - CSR_MLME_GET_NEXT_CONFIRM MlmeGetNextConfirm; - CSR_MLME_POWERMGT_REQUEST MlmePowermgtRequest; - CSR_MLME_POWERMGT_CONFIRM MlmePowermgtConfirm; - CSR_MLME_SCAN_REQUEST MlmeScanRequest; - CSR_MLME_SCAN_CONFIRM MlmeScanConfirm; - CSR_MLME_HL_SYNC_REQUEST MlmeHlSyncRequest; - CSR_MLME_HL_SYNC_CONFIRM MlmeHlSyncConfirm; - CSR_MLME_MEASURE_REQUEST MlmeMeasureRequest; - CSR_MLME_MEASURE_CONFIRM MlmeMeasureConfirm; - CSR_MLME_MEASURE_INDICATION MlmeMeasureIndication; - CSR_MLME_SETKEYS_REQUEST MlmeSetkeysRequest; - CSR_MLME_SETKEYS_CONFIRM MlmeSetkeysConfirm; - CSR_MLME_DELETEKEYS_REQUEST MlmeDeletekeysRequest; - CSR_MLME_DELETEKEYS_CONFIRM MlmeDeletekeysConfirm; - CSR_MLME_AUTONOMOUS_SCAN_LOSS_INDICATION MlmeAutonomousScanLossIndication; - CSR_MLME_CONNECTED_INDICATION MlmeConnectedIndication; - CSR_MLME_SCAN_CANCEL_REQUEST MlmeScanCancelRequest; - CSR_MLME_HL_SYNC_CANCEL_REQUEST MlmeHlSyncCancelRequest; - CSR_MLME_HL_SYNC_CANCEL_CONFIRM MlmeHlSyncCancelConfirm; - CSR_MLME_ADD_PERIODIC_REQUEST MlmeAddPeriodicRequest; - CSR_MLME_ADD_PERIODIC_CONFIRM MlmeAddPeriodicConfirm; - CSR_MLME_DEL_PERIODIC_REQUEST MlmeDelPeriodicRequest; - CSR_MLME_DEL_PERIODIC_CONFIRM MlmeDelPeriodicConfirm; - CSR_MLME_ADD_AUTONOMOUS_SCAN_REQUEST MlmeAddAutonomousScanRequest; - CSR_MLME_ADD_AUTONOMOUS_SCAN_CONFIRM MlmeAddAutonomousScanConfirm; - CSR_MLME_DEL_AUTONOMOUS_SCAN_REQUEST MlmeDelAutonomousScanRequest; - CSR_MLME_DEL_AUTONOMOUS_SCAN_CONFIRM MlmeDelAutonomousScanConfirm; - CSR_MLME_SET_PACKET_FILTER_REQUEST MlmeSetPacketFilterRequest; - CSR_MLME_SET_PACKET_FILTER_CONFIRM MlmeSetPacketFilterConfirm; - CSR_MLME_STOP_MEASURE_REQUEST MlmeStopMeasureRequest; - CSR_MLME_STOP_MEASURE_CONFIRM MlmeStopMeasureConfirm; - CSR_MLME_PAUSE_AUTONOMOUS_SCAN_REQUEST MlmePauseAutonomousScanRequest; - CSR_MLME_PAUSE_AUTONOMOUS_SCAN_CONFIRM MlmePauseAutonomousScanConfirm; - CSR_MLME_AUTONOMOUS_SCAN_DONE_INDICATION MlmeAutonomousScanDoneIndication; - CSR_MLME_ADD_TRIGGERED_GET_REQUEST MlmeAddTriggeredGetRequest; - CSR_MLME_ADD_TRIGGERED_GET_CONFIRM MlmeAddTriggeredGetConfirm; - CSR_MLME_DEL_TRIGGERED_GET_REQUEST MlmeDelTriggeredGetRequest; - CSR_MLME_DEL_TRIGGERED_GET_CONFIRM MlmeDelTriggeredGetConfirm; - CSR_MLME_TRIGGERED_GET_INDICATION MlmeTriggeredGetIndication; - CSR_MLME_ADD_BLACKOUT_REQUEST MlmeAddBlackoutRequest; - CSR_MLME_ADD_BLACKOUT_CONFIRM MlmeAddBlackoutConfirm; - CSR_MLME_BLACKOUT_ENDED_INDICATION MlmeBlackoutEndedIndication; - CSR_MLME_DEL_BLACKOUT_REQUEST MlmeDelBlackoutRequest; - CSR_MLME_DEL_BLACKOUT_CONFIRM MlmeDelBlackoutConfirm; - CSR_MLME_ADD_RX_TRIGGER_REQUEST MlmeAddRxTriggerRequest; - CSR_MLME_ADD_RX_TRIGGER_CONFIRM MlmeAddRxTriggerConfirm; - CSR_MLME_DEL_RX_TRIGGER_REQUEST MlmeDelRxTriggerRequest; - CSR_MLME_DEL_RX_TRIGGER_CONFIRM MlmeDelRxTriggerConfirm; - CSR_MLME_CONNECT_STATUS_REQUEST MlmeConnectStatusRequest; - CSR_MLME_CONNECT_STATUS_CONFIRM MlmeConnectStatusConfirm; - CSR_MLME_MODIFY_BSS_PARAMETER_REQUEST MlmeModifyBssParameterRequest; - CSR_MLME_MODIFY_BSS_PARAMETER_CONFIRM MlmeModifyBssParameterConfirm; - CSR_MLME_ADD_TEMPLATE_REQUEST MlmeAddTemplateRequest; - CSR_MLME_ADD_TEMPLATE_CONFIRM MlmeAddTemplateConfirm; - CSR_MLME_CONFIG_QUEUE_REQUEST MlmeConfigQueueRequest; - CSR_MLME_CONFIG_QUEUE_CONFIRM MlmeConfigQueueConfirm; - CSR_MLME_ADD_TSPEC_REQUEST MlmeAddTspecRequest; - CSR_MLME_ADD_TSPEC_CONFIRM MlmeAddTspecConfirm; - CSR_MLME_DEL_TSPEC_REQUEST MlmeDelTspecRequest; - CSR_MLME_DEL_TSPEC_CONFIRM MlmeDelTspecConfirm; - CSR_MLME_START_AGGREGATION_REQUEST MlmeStartAggregationRequest; - CSR_MLME_START_AGGREGATION_CONFIRM MlmeStartAggregationConfirm; - CSR_MLME_BLOCKACK_ERROR_INDICATION MlmeBlockackErrorIndication; - CSR_MLME_STOP_AGGREGATION_REQUEST MlmeStopAggregationRequest; - CSR_MLME_STOP_AGGREGATION_CONFIRM MlmeStopAggregationConfirm; - CSR_MLME_SM_START_REQUEST MlmeSmStartRequest; - CSR_MLME_SM_START_CONFIRM MlmeSmStartConfirm; - CSR_MLME_LEAVE_REQUEST MlmeLeaveRequest; - CSR_MLME_LEAVE_CONFIRM MlmeLeaveConfirm; - CSR_MLME_SET_TIM_REQUEST MlmeSetTimRequest; - CSR_MLME_SET_TIM_CONFIRM MlmeSetTimConfirm; - CSR_MLME_GET_KEY_SEQUENCE_REQUEST MlmeGetKeySequenceRequest; - CSR_MLME_GET_KEY_SEQUENCE_CONFIRM MlmeGetKeySequenceConfirm; - CSR_MLME_SET_CHANNEL_REQUEST MlmeSetChannelRequest; - CSR_MLME_SET_CHANNEL_CONFIRM MlmeSetChannelConfirm; - CSR_MLME_ADD_MULTICAST_ADDRESS_REQUEST MlmeAddMulticastAddressRequest; - CSR_MLME_ADD_MULTICAST_ADDRESS_CONFIRM MlmeAddMulticastAddressConfirm; - CSR_DEBUG_STRING_INDICATION DebugStringIndication; - CSR_DEBUG_WORD16_INDICATION DebugWord16Indication; - CSR_DEBUG_GENERIC_REQUEST DebugGenericRequest; - CSR_DEBUG_GENERIC_CONFIRM DebugGenericConfirm; - CSR_DEBUG_GENERIC_INDICATION DebugGenericIndication; - } u; -} CSR_SIGNAL; - -#define SIG_FILTER_SIZE 6 - -u32 SigGetFilterPos(u16 aSigID); - -#endif diff --git a/drivers/staging/csr/csr_wifi_hip_ta_sampling.c b/drivers/staging/csr/csr_wifi_hip_ta_sampling.c deleted file mode 100644 index f1df36aa87e7..000000000000 --- a/drivers/staging/csr/csr_wifi_hip_ta_sampling.c +++ /dev/null @@ -1,541 +0,0 @@ -/***************************************************************************** - - (c) Cambridge Silicon Radio Limited 2012 - All rights reserved and confidential information of CSR - - Refer to LICENSE.txt included with this source for details - on the license terms. - -*****************************************************************************/ - -/* - * --------------------------------------------------------------------------- - * FILE: csr_wifi_hip_ta_sampling.c - * - * PURPOSE: - * The traffic analysis sampling module. - * This gathers data which is sent to the SME and used to analyse - * the traffic behaviour. - * - * Provides: - * unifi_ta_sampling_init - Initialise the internal state - * unifi_ta_sample - Sampling function, call this for every data packet - * - * Calls these external functions which must be provided: - * unifi_ta_indicate_sampling - Pass sample data to the SME. - * unifi_ta_indicate_protocol - Report certain data packet types to the SME. - * --------------------------------------------------------------------------- - */ - -#include "csr_wifi_hip_card_sdio.h" - -/* Maximum number of Tx frames we store each CYCLE_1, for detecting period */ -#define TA_MAX_INTERVALS_IN_C1 100 - -/* Number of intervals in CYCLE_1 (one second), for detecting periodic */ -/* Must match size of unifi_TrafficStats.intervals - 1 */ -#define TA_INTERVALS_NUM 10 - -/* Step (in msecs) between intervals, for detecting periodic */ -/* We are only interested in periods up to 100ms, i.e. between beacons */ -/* This is correct for TA_INTERVALS_NUM=10 */ -#define TA_INTERVALS_STEP 10 - - -enum ta_frame_identity -{ - TA_FRAME_UNKNOWN, - TA_FRAME_ETHERNET_UNINTERESTING, - TA_FRAME_ETHERNET_INTERESTING -}; - - -#define TA_ETHERNET_TYPE_OFFSET 6 -#define TA_LLC_HEADER_SIZE 8 -#define TA_IP_TYPE_OFFSET 17 -#define TA_UDP_SOURCE_PORT_OFFSET 28 -#define TA_UDP_DEST_PORT_OFFSET (TA_UDP_SOURCE_PORT_OFFSET + 2) -#define TA_BOOTP_CLIENT_MAC_ADDR_OFFSET 64 -#define TA_DHCP_MESSAGE_TYPE_OFFSET 278 -#define TA_DHCP_MESSAGE_TYPE_ACK 0x05 -#define TA_PROTO_TYPE_IP 0x0800 -#define TA_PROTO_TYPE_EAP 0x888E -#define TA_PROTO_TYPE_WAI 0x8864 -#define TA_PROTO_TYPE_ARP 0x0806 -#define TA_IP_TYPE_TCP 0x06 -#define TA_IP_TYPE_UDP 0x11 -#define TA_UDP_PORT_BOOTPC 0x0044 -#define TA_UDP_PORT_BOOTPS 0x0043 -#define TA_EAPOL_TYPE_OFFSET 9 -#define TA_EAPOL_TYPE_START 0x01 - -#define snap_802_2 0xAAAA0300 -#define oui_rfc1042 0x00000000 -#define oui_8021h 0x0000f800 -static const u8 aironet_snap[5] = { 0x00, 0x40, 0x96, 0x00, 0x00 }; - - -/* - * --------------------------------------------------------------------------- - * ta_detect_protocol - * - * Internal only. - * Detects a specific protocol in a frame and indicates a TA event. - * - * Arguments: - * ta The pointer to the TA module. - * direction The direction of the frame (tx or rx). - * data Pointer to the structure that contains the data. - * - * Returns: - * None - * --------------------------------------------------------------------------- - */ -static enum ta_frame_identity ta_detect_protocol(card_t *card, CsrWifiRouterCtrlProtocolDirection direction, - const bulk_data_desc_t *data, - const u8 *saddr, - const u8 *sta_macaddr) -{ - ta_data_t *tad = &card->ta_sampling; - u16 proto; - u16 source_port, dest_port; - CsrWifiMacAddress srcAddress; - u32 snap_hdr, oui_hdr; - - if (data->data_length < TA_LLC_HEADER_SIZE) - { - return TA_FRAME_UNKNOWN; - } - - snap_hdr = (((u32)data->os_data_ptr[0]) << 24) | - (((u32)data->os_data_ptr[1]) << 16) | - (((u32)data->os_data_ptr[2]) << 8); - if (snap_hdr != snap_802_2) - { - return TA_FRAME_UNKNOWN; - } - - if (tad->packet_filter & CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_CUSTOM) - { - /* - * Here we would use the custom filter to detect interesting frames. - */ - } - - oui_hdr = (((u32)data->os_data_ptr[3]) << 24) | - (((u32)data->os_data_ptr[4]) << 16) | - (((u32)data->os_data_ptr[5]) << 8); - if ((oui_hdr == oui_rfc1042) || (oui_hdr == oui_8021h)) - { - proto = (data->os_data_ptr[TA_ETHERNET_TYPE_OFFSET] * 256) + - data->os_data_ptr[TA_ETHERNET_TYPE_OFFSET + 1]; - - /* The only interesting IP frames are the DHCP */ - if (proto == TA_PROTO_TYPE_IP) - { - if (data->data_length > TA_IP_TYPE_OFFSET) - { - if (tad->packet_filter & CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_CUSTOM) - { - ta_l4stats_t *ta_l4stats = &tad->ta_l4stats; - u8 l4proto = data->os_data_ptr[TA_IP_TYPE_OFFSET]; - - if (l4proto == TA_IP_TYPE_TCP) - { - if (direction == CSR_WIFI_ROUTER_CTRL_PROTOCOL_DIRECTION_TX) - { - ta_l4stats->txTcpBytesCount += data->data_length; - } - else - { - ta_l4stats->rxTcpBytesCount += data->data_length; - } - } - else if (l4proto == TA_IP_TYPE_UDP) - { - if (direction == CSR_WIFI_ROUTER_CTRL_PROTOCOL_DIRECTION_TX) - { - ta_l4stats->txUdpBytesCount += data->data_length; - } - else - { - ta_l4stats->rxUdpBytesCount += data->data_length; - } - } - } - - /* detect DHCP frames */ - if (tad->packet_filter & CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_DHCP) - { - /* DHCP frames are UDP frames with BOOTP ports */ - if (data->os_data_ptr[TA_IP_TYPE_OFFSET] == TA_IP_TYPE_UDP) - { - if (data->data_length > TA_UDP_DEST_PORT_OFFSET) - { - source_port = (data->os_data_ptr[TA_UDP_SOURCE_PORT_OFFSET] * 256) + - data->os_data_ptr[TA_UDP_SOURCE_PORT_OFFSET + 1]; - dest_port = (data->os_data_ptr[TA_UDP_DEST_PORT_OFFSET] * 256) + - data->os_data_ptr[TA_UDP_DEST_PORT_OFFSET + 1]; - - if (((source_port == TA_UDP_PORT_BOOTPC) && (dest_port == TA_UDP_PORT_BOOTPS)) || - ((source_port == TA_UDP_PORT_BOOTPS) && (dest_port == TA_UDP_PORT_BOOTPC))) - { - /* The DHCP should have at least a message type (request, ack, nack, etc) */ - if (data->data_length > TA_DHCP_MESSAGE_TYPE_OFFSET + 6) - { - UNIFI_MAC_ADDRESS_COPY(srcAddress.a, saddr); - - if (direction == CSR_WIFI_ROUTER_CTRL_PROTOCOL_DIRECTION_TX) - { - unifi_ta_indicate_protocol(card->ospriv, - CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_DHCP, - direction, - &srcAddress); - return TA_FRAME_ETHERNET_UNINTERESTING; - } - - /* DHCPACK is a special indication */ - if (UNIFI_MAC_ADDRESS_CMP(data->os_data_ptr + TA_BOOTP_CLIENT_MAC_ADDR_OFFSET, sta_macaddr) == TRUE) - { - if (data->os_data_ptr[TA_DHCP_MESSAGE_TYPE_OFFSET] == TA_DHCP_MESSAGE_TYPE_ACK) - { - unifi_ta_indicate_protocol(card->ospriv, - CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_DHCP_ACK, - direction, - &srcAddress); - } - else - { - unifi_ta_indicate_protocol(card->ospriv, - CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_DHCP, - direction, - &srcAddress); - } - } - } - } - } - } - } - } - - return TA_FRAME_ETHERNET_INTERESTING; - } - - /* detect protocol type EAPOL or WAI (treated as equivalent here) */ - if (tad->packet_filter & CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_EAPOL) - { - if (TA_PROTO_TYPE_EAP == proto || TA_PROTO_TYPE_WAI == proto) - { - if ((TA_PROTO_TYPE_WAI == proto) || (direction != CSR_WIFI_ROUTER_CTRL_PROTOCOL_DIRECTION_TX) || - (data->os_data_ptr[TA_EAPOL_TYPE_OFFSET] == TA_EAPOL_TYPE_START)) - { - UNIFI_MAC_ADDRESS_COPY(srcAddress.a, saddr); - unifi_ta_indicate_protocol(card->ospriv, - CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_EAPOL, - direction, &srcAddress); - } - return TA_FRAME_ETHERNET_UNINTERESTING; - } - } - - /* detect protocol type 0x0806 (ARP) */ - if (tad->packet_filter & CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_ARP) - { - if (proto == TA_PROTO_TYPE_ARP) - { - UNIFI_MAC_ADDRESS_COPY(srcAddress.a, saddr); - unifi_ta_indicate_protocol(card->ospriv, - CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_ARP, - direction, &srcAddress); - return TA_FRAME_ETHERNET_UNINTERESTING; - } - } - - return TA_FRAME_ETHERNET_INTERESTING; - } - else if (tad->packet_filter & CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_AIRONET) - { - /* detect Aironet frames */ - if (!memcmp(data->os_data_ptr + 3, aironet_snap, 5)) - { - UNIFI_MAC_ADDRESS_COPY(srcAddress.a, saddr); - unifi_ta_indicate_protocol(card->ospriv, CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_AIRONET, - direction, &srcAddress); - } - } - - return TA_FRAME_ETHERNET_UNINTERESTING; -} /* ta_detect_protocol() */ - - -static void tas_reset_data(ta_data_t *tad) -{ - s16 i; - - for (i = 0; i < (TA_INTERVALS_NUM + 1); i++) - { - tad->stats.intervals[i] = 0; - } - - tad->stats.rxFramesNum = 0; - tad->stats.txFramesNum = 0; - tad->stats.rxBytesCount = 0; - tad->stats.txBytesCount = 0; - tad->stats.rxMeanRate = 0; - - tad->rx_sum_rate = 0; - - tad->ta_l4stats.rxTcpBytesCount = 0; - tad->ta_l4stats.txTcpBytesCount = 0; - tad->ta_l4stats.rxUdpBytesCount = 0; - tad->ta_l4stats.txUdpBytesCount = 0; -} /* tas_reset_data() */ - - -/* - * --------------------------------------------------------------------------- - * API. - * unifi_ta_sampling_init - * - * (Re)Initialise the Traffic Analysis sampling module. - * Resets the counters and timestamps. - * - * Arguments: - * tad Pointer to a ta_data_t structure containing the - * context for this device instance. - * drv_priv An opaque pointer that the TA sampling module will - * pass in call-outs. - * - * Returns: - * None. - * --------------------------------------------------------------------------- - */ -void unifi_ta_sampling_init(card_t *card) -{ - (void)unifi_ta_configure(card, CSR_WIFI_ROUTER_CTRL_TRAFFIC_CONFIG_TYPE_RESET, NULL); - - card->ta_sampling.packet_filter = CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_NONE; - card->ta_sampling.traffic_type = CSR_WIFI_ROUTER_CTRL_TRAFFIC_TYPE_OCCASIONAL; -} /* unifi_ta_sampling_init() */ - - -/* - * --------------------------------------------------------------------------- - * API. - * unifi_ta_sample - * - * Sample a data frame for the TA module. - * This function stores all the useful information it can extract from - * the frame and detects any specific protocols. - * - * Arguments: - * tad The pointer to the TA sampling context struct. - * direction The direction of the frame (rx, tx) - * data Pointer to the frame data - * saddr Source MAC address of frame. - * timestamp Time (in msecs) that the frame was received. - * rate Reported data rate for the rx frame (0 for tx frames) - * - * Returns: - * None - * --------------------------------------------------------------------------- - */ -void unifi_ta_sample(card_t *card, - CsrWifiRouterCtrlProtocolDirection direction, - const bulk_data_desc_t *data, - const u8 *saddr, - const u8 *sta_macaddr, - u32 timestamp, - u16 rate) -{ - ta_data_t *tad = &card->ta_sampling; - enum ta_frame_identity identity; - u32 time_delta; - - - - /* Step1: Check for specific frames */ - if (tad->packet_filter != CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_NONE) - { - identity = ta_detect_protocol(card, direction, data, saddr, sta_macaddr); - } - else - { - identity = TA_FRAME_ETHERNET_INTERESTING; - } - - - /* Step2: Update the information in the current record */ - if (direction == CSR_WIFI_ROUTER_CTRL_PROTOCOL_DIRECTION_RX) - { - /* Update the Rx packet count and the throughput count */ - tad->stats.rxFramesNum++; - tad->stats.rxBytesCount += data->data_length; - - /* Accumulate packet Rx rates for later averaging */ - tad->rx_sum_rate += rate; - } - else - { - if (identity == TA_FRAME_ETHERNET_INTERESTING) - { - /* - * Store the period between the last and the current frame. - * There is not point storing more than TA_MAX_INTERVALS_IN_C1 periods, - * the traffic will be bursty or continuous. - */ - if (tad->stats.txFramesNum < TA_MAX_INTERVALS_IN_C1) - { - u32 interval; - u32 index_in_intervals; - - interval = timestamp - tad->tx_last_ts; - tad->tx_last_ts = timestamp; - index_in_intervals = (interval + TA_INTERVALS_STEP / 2 - 1) / TA_INTERVALS_STEP; - - /* If the interval is interesting, update the t1_intervals count */ - if (index_in_intervals <= TA_INTERVALS_NUM) - { - unifi_trace(card->ospriv, UDBG5, - "unifi_ta_sample: TX interval=%d index=%d\n", - interval, index_in_intervals); - tad->stats.intervals[index_in_intervals]++; - } - } - } - - /* Update the Tx packet count... */ - tad->stats.txFramesNum++; - /* ... and the number of bytes for throughput. */ - tad->stats.txBytesCount += data->data_length; - } - - /* - * If more than one second has elapsed since the last report, send - * another one. - */ - /* Unsigned subtraction handles wrap-around from 0xFFFFFFFF to 0 */ - time_delta = timestamp - tad->last_indication_time; - if (time_delta >= 1000) - { - /* - * rxFramesNum can be flashed in tas_reset_data() by another thread. - * Use a temp to avoid division by zero. - */ - u32 temp_rxFramesNum; - temp_rxFramesNum = tad->stats.rxFramesNum; - - /* Calculate this interval's mean frame Rx rate from the sum */ - if (temp_rxFramesNum) - { - tad->stats.rxMeanRate = tad->rx_sum_rate / temp_rxFramesNum; - } - unifi_trace(card->ospriv, UDBG5, - "unifi_ta_sample: RX fr=%lu, r=%u, sum=%lu, av=%lu\n", - tad->stats.rxFramesNum, rate, - tad->rx_sum_rate, tad->stats.rxMeanRate); - - /* - * Send the information collected in the stats struct - * to the SME and reset the counters. - */ - if (tad->packet_filter & CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_CUSTOM) - { - u32 rxTcpThroughput = tad->ta_l4stats.rxTcpBytesCount / time_delta; - u32 txTcpThroughput = tad->ta_l4stats.txTcpBytesCount / time_delta; - u32 rxUdpThroughput = tad->ta_l4stats.rxUdpBytesCount / time_delta; - u32 txUdpThroughput = tad->ta_l4stats.txUdpBytesCount / time_delta; - - unifi_ta_indicate_l4stats(card->ospriv, - rxTcpThroughput, - txTcpThroughput, - rxUdpThroughput, - txUdpThroughput - ); - } - unifi_ta_indicate_sampling(card->ospriv, &tad->stats); - tas_reset_data(tad); - tad->last_indication_time = timestamp; - } -} /* unifi_ta_sample() */ - - -/* - * --------------------------------------------------------------------------- - * External API. - * unifi_ta_configure - * - * Configures the TA module parameters. - * - * Arguments: - * ta The pointer to the TA module. - * config_type The type of the configuration request - * config Pointer to the configuration parameters. - * - * Returns: - * CSR_RESULT_SUCCESS on success, CSR error code otherwise - * --------------------------------------------------------------------------- - */ -CsrResult unifi_ta_configure(card_t *card, - CsrWifiRouterCtrlTrafficConfigType config_type, - const CsrWifiRouterCtrlTrafficConfig *config) -{ - ta_data_t *tad = &card->ta_sampling; - - /* Reinitialise our data when we are reset */ - if (config_type == CSR_WIFI_ROUTER_CTRL_TRAFFIC_CONFIG_TYPE_RESET) - { - /* Reset the stats to zero */ - tas_reset_data(tad); - - /* Reset the timer variables */ - tad->tx_last_ts = 0; - tad->last_indication_time = 0; - - return CSR_RESULT_SUCCESS; - } - - if (config_type == CSR_WIFI_ROUTER_CTRL_TRAFFIC_CONFIG_TYPE_FILTER) - { - tad->packet_filter = config->packetFilter; - - if (tad->packet_filter & CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_CUSTOM) - { - tad->custom_filter = config->customFilter; - } - - return CSR_RESULT_SUCCESS; - } - - return CSR_RESULT_SUCCESS; -} /* unifi_ta_configure() */ - - -/* - * --------------------------------------------------------------------------- - * External API. - * unifi_ta_classification - * - * Configures the current TA classification. - * - * Arguments: - * ta The pointer to the TA module. - * traffic_type The classification type - * period The traffic period if the type is periodic - * - * Returns: - * None - * --------------------------------------------------------------------------- - */ -void unifi_ta_classification(card_t *card, - CsrWifiRouterCtrlTrafficType traffic_type, - u16 period) -{ - unifi_trace(card->ospriv, UDBG3, - "Changed current ta classification to: %d\n", traffic_type); - - card->ta_sampling.traffic_type = traffic_type; -} - - diff --git a/drivers/staging/csr/csr_wifi_hip_ta_sampling.h b/drivers/staging/csr/csr_wifi_hip_ta_sampling.h deleted file mode 100644 index aa684c654d06..000000000000 --- a/drivers/staging/csr/csr_wifi_hip_ta_sampling.h +++ /dev/null @@ -1,66 +0,0 @@ -/***************************************************************************** - - (c) Cambridge Silicon Radio Limited 2011 - All rights reserved and confidential information of CSR - - Refer to LICENSE.txt included with this source for details - on the license terms. - -*****************************************************************************/ - -/* - * --------------------------------------------------------------------------- - * FILE: csr_wifi_hip_ta_sampling.h - * - * PURPOSE: - * This file contains Traffic Analysis definitions common to the - * sampling and analysis modules. - * - * --------------------------------------------------------------------------- - */ -#ifndef __TA_SAMPLING_H__ -#define __TA_SAMPLING_H__ - -#include "csr_wifi_hip_unifi.h" - -typedef struct ta_l4stats -{ - u32 rxTcpBytesCount; - u32 txTcpBytesCount; - u32 rxUdpBytesCount; - u32 txUdpBytesCount; -} ta_l4stats_t; - -/* - * Context structure to preserve state between calls. - */ - -typedef struct ta_data -{ - /* Current packet filter configuration */ - u16 packet_filter; - - /* Current packet custom filter configuration */ - CsrWifiRouterCtrlTrafficFilter custom_filter; - - /* The timestamp of the last tx packet processed. */ - u32 tx_last_ts; - - /* The timestamp of the last packet processed. */ - u32 last_indication_time; - - /* Statistics */ - CsrWifiRouterCtrlTrafficStats stats; - - /* Current traffic classification */ - CsrWifiRouterCtrlTrafficType traffic_type; - - /* Sum of packet rx rates for this interval used to calculate mean */ - u32 rx_sum_rate; - ta_l4stats_t ta_l4stats; -} ta_data_t; - - -void unifi_ta_sampling_init(card_t *card); - -#endif /* __TA_SAMPLING_H__ */ diff --git a/drivers/staging/csr/csr_wifi_hip_udi.c b/drivers/staging/csr/csr_wifi_hip_udi.c deleted file mode 100644 index a6b006b0e983..000000000000 --- a/drivers/staging/csr/csr_wifi_hip_udi.c +++ /dev/null @@ -1,173 +0,0 @@ -/***************************************************************************** - - (c) Cambridge Silicon Radio Limited 2011 - All rights reserved and confidential information of CSR - - Refer to LICENSE.txt included with this source for details - on the license terms. - -*****************************************************************************/ - -/* - * --------------------------------------------------------------------------- - * FILE: csr_wifi_hip_card_udi.c - * - * PURPOSE: - * Maintain a list of callbacks to log UniFi exchanges to one or more - * debug/monitoring client applications. - * - * NOTES: - * Just call the UDI driver log fn directly for now. - * When done properly, each open() on the UDI device will install - * a log function. We will call all log fns whenever a signal is written - * to or read form the UniFi. - * - * --------------------------------------------------------------------------- - */ -#include -#include "csr_wifi_hip_unifi.h" -#include "csr_wifi_hip_card.h" - - -static void unifi_print_unsafe_sdio_status(card_t *card, struct seq_file *m) -{ -#ifdef CSR_UNSAFE_SDIO_ACCESS - s32 iostate; - CsrResult r; - static const char *const states[] = { - "AWAKE", "DROWSY", "TORPID" - }; -#define SHARED_READ_RETRY_LIMIT 10 - u8 b; - - seq_printf(m, "Host State: %s\n", states[card->host_state]); - - r = unifi_check_io_status(card, &iostate); - if (iostate == 1) { - seq_puts(m, remaining, "I/O Check: F1 disabled\n"); - } else { - if (iostate == 1) { - seq_puts(m, "I/O Check: pending interrupt\n"); - - seq_printf(m, "BH reason interrupt = %d\n", card->bh_reason_unifi); - seq_printf(m, "BH reason host = %d\n", card->bh_reason_host); - - for (i = 0; i < SHARED_READ_RETRY_LIMIT; i++) { - r = unifi_read_8_or_16(card, card->sdio_ctrl_addr + 2, &b); - if (r == CSR_RESULT_SUCCESS && !(b & 0x80)) { - seq_printf(m, "fhsr: %u (driver thinks is %u)\n", - b, card->from_host_signals_r); - break; - } - } - - iostate = unifi_read_shared_count(card, card->sdio_ctrl_addr + 4); - seq_printf(m, "thsw: %u (driver thinks is %u)\n", - iostate, card->to_host_signals_w); - } -#endif -} - -/* - * --------------------------------------------------------------------------- - * unifi_print_status - * - * Print status info to given character buffer. - * - * Arguments: - * None. - * - * Returns: - * None. - * --------------------------------------------------------------------------- - */ -s32 unifi_print_status(card_t *card, struct seq_file *m) -{ - sdio_config_data_t *cfg; - u16 i, n; - - i = n = 0; - seq_printf(m, "Chip ID %u\n", card->chip_id); - seq_printf(m, "Chip Version %04X\n", card->chip_version); - seq_printf(m, "HIP v%u.%u\n", - (card->config_data.version >> 8) & 0xFF, - card->config_data.version & 0xFF); - seq_printf(m, "Build %u: %s\n", card->build_id, card->build_id_string); - - cfg = &card->config_data; - - seq_printf(m, "sdio ctrl offset %u\n", cfg->sdio_ctrl_offset); - seq_printf(m, "fromhost sigbuf handle %u\n", cfg->fromhost_sigbuf_handle); - seq_printf(m, "tohost_sigbuf_handle %u\n", cfg->tohost_sigbuf_handle); - seq_printf(m, "num_fromhost_sig_frags %u\n", cfg->num_fromhost_sig_frags); - seq_printf(m, "num_tohost_sig_frags %u\n", cfg->num_tohost_sig_frags); - seq_printf(m, "num_fromhost_data_slots %u\n", cfg->num_fromhost_data_slots); - seq_printf(m, "num_tohost_data_slots %u\n", cfg->num_tohost_data_slots); - seq_printf(m, "data_slot_size %u\n", cfg->data_slot_size); - - /* Added by protocol version 0x0001 */ - seq_printf(m, "overlay_size %u\n", cfg->overlay_size); - - /* Added by protocol version 0x0300 */ - seq_printf(m, "data_slot_round %u\n", cfg->data_slot_round); - seq_printf(m, "sig_frag_size %u\n", cfg->sig_frag_size); - - /* Added by protocol version 0x0300 */ - seq_printf(m, "tohost_sig_pad %u\n", cfg->tohost_signal_padding); - - seq_puts(m, "\nInternal state:\n"); - - seq_printf(m, "Last PHY PANIC: %04x:%04x\n", - card->last_phy_panic_code, card->last_phy_panic_arg); - seq_printf(m, "Last MAC PANIC: %04x:%04x\n", - card->last_mac_panic_code, card->last_mac_panic_arg); - - seq_printf(m, "fhsr: %hu\n", (u16)card->from_host_signals_r); - seq_printf(m, "fhsw: %hu\n", (u16)card->from_host_signals_w); - seq_printf(m, "thsr: %hu\n", (u16)card->to_host_signals_r); - seq_printf(m, "thsw: %hu\n", (u16)card->to_host_signals_w); - seq_printf(m, "fh buffer contains: %d signals, %td bytes\n", - card->fh_buffer.count, - card->fh_buffer.ptr - card->fh_buffer.buf); - - seq_puts(m, "paused: "); - for (i = 0; i < ARRAY_SIZE(card->tx_q_paused_flag); i++) - seq_printf(m, card->tx_q_paused_flag[i] ? "1" : "0"); - seq_putc(m, '\n'); - - seq_printf(m, "fh command q: %u waiting, %u free of %u:\n", - CSR_WIFI_HIP_Q_SLOTS_USED(&card->fh_command_queue), - CSR_WIFI_HIP_Q_SLOTS_FREE(&card->fh_command_queue), - UNIFI_SOFT_COMMAND_Q_LENGTH); - - for (i = 0; i < UNIFI_NO_OF_TX_QS; i++) - seq_printf(m, "fh traffic q[%u]: %u waiting, %u free of %u:\n", - i, - CSR_WIFI_HIP_Q_SLOTS_USED(&card->fh_traffic_queue[i]), - CSR_WIFI_HIP_Q_SLOTS_FREE(&card->fh_traffic_queue[i]), - UNIFI_SOFT_TRAFFIC_Q_LENGTH); - - seq_printf(m, "fh data slots free: %u\n", - card->from_host_data ? CardGetFreeFromHostDataSlots(card) : 0); - - seq_puts(m, "From host data slots:"); - n = card->config_data.num_fromhost_data_slots; - for (i = 0; i < n && card->from_host_data; i++) - seq_printf(m, " %hu", (u16)card->from_host_data[i].bd.data_length); - seq_putc(m, '\n'); - - seq_puts(m, "To host data slots:"); - n = card->config_data.num_tohost_data_slots; - for (i = 0; i < n && card->to_host_data; i++) - seq_printf(m, " %hu", (u16)card->to_host_data[i].data_length); - seq_putc(m, '\n'); - - unifi_print_unsafe_sdio_status(card, m); - - seq_puts(m, "\nStats:\n"); - seq_printf(m, "Total SDIO bytes: R=%u W=%u\n", - card->sdio_bytes_read, card->sdio_bytes_written); - - seq_printf(m, "Interrupts generated on card: %u\n", card->unifi_interrupt_seq); - return 0; -} diff --git a/drivers/staging/csr/csr_wifi_hip_unifi.h b/drivers/staging/csr/csr_wifi_hip_unifi.h deleted file mode 100644 index 1160a0e25c7d..000000000000 --- a/drivers/staging/csr/csr_wifi_hip_unifi.h +++ /dev/null @@ -1,871 +0,0 @@ -/***************************************************************************** - - (c) Cambridge Silicon Radio Limited 2012 - All rights reserved and confidential information of CSR - - Refer to LICENSE.txt included with this source for details - on the license terms. - -*****************************************************************************/ - -/* - * --------------------------------------------------------------------------- - * - * FILE : csr_wifi_hip_unifi.h - * - * PURPOSE : Public API for the UniFi HIP core library. - * - * --------------------------------------------------------------------------- - */ -#ifndef __CSR_WIFI_HIP_UNIFI_H__ -#define __CSR_WIFI_HIP_UNIFI_H__ 1 - -#ifndef CSR_WIFI_HIP_TA_DISABLE -#include "csr_wifi_router_ctrl_prim.h" -#include "csr_wifi_router_prim.h" -#else -#include "csr_time.h" -#endif - -/* SDIO chip ID numbers */ - -/* Manufacturer id */ -#define SDIO_MANF_ID_CSR 0x032a - -/* Device id */ -#define SDIO_CARD_ID_UNIFI_1 0x0001 -#define SDIO_CARD_ID_UNIFI_2 0x0002 -#define SDIO_CARD_ID_UNIFI_3 0x0007 -#define SDIO_CARD_ID_UNIFI_4 0x0008 - -/* Function number for WLAN */ -#define SDIO_WLAN_FUNC_ID_UNIFI_1 0x0001 -#define SDIO_WLAN_FUNC_ID_UNIFI_2 0x0001 -#define SDIO_WLAN_FUNC_ID_UNIFI_3 0x0001 -#define SDIO_WLAN_FUNC_ID_UNIFI_4 0x0002 - -/* Maximum SDIO bus clock supported. */ -#define UNIFI_SDIO_CLOCK_MAX_HZ 50000000 /* Hz */ - -/* - * Initialisation SDIO bus clock. - * - * The initialisation clock speed should be used from when the chip has been - * reset until the first MLME-reset has been received (i.e. during firmware - * initialisation), unless UNIFI_SDIO_CLOCK_SAFE_HZ applies. - */ -#define UNIFI_SDIO_CLOCK_INIT_HZ 12500000 /* Hz */ - -/* - * Safe SDIO bus clock. - * - * The safe speed should be used when the chip is in deep sleep or - * it's state is unknown (just after reset / power on). - */ -#define UNIFI_SDIO_CLOCK_SAFE_HZ 1000000 /* Hz */ - -/* I/O default block size to use for UniFi. */ -#define UNIFI_IO_BLOCK_SIZE 64 - -#define UNIFI_WOL_OFF 0 -#define UNIFI_WOL_SDIO 1 -#define UNIFI_WOL_PIO 2 - -/* The number of Tx traffic queues */ -#define UNIFI_NO_OF_TX_QS 4 - -#define CSR_WIFI_HIP_RESERVED_HOST_TAG 0xFFFFFFFF - -/* - * The number of slots in the from-host queues. - * - * UNIFI_SOFT_TRAFFIC_Q_LENGTH is the number of slots in the traffic queues - * and there will be UNIFI_NO_OF_TX_QS of them. - * Traffic queues are used for data packets. - * - * UNIFI_SOFT_COMMAND_Q_LENGTH is the number of slots in the command queue. - * The command queue is used for MLME management requests. - * - * Queues are ring buffers and so must always have 1 unused slot. - */ -#define UNIFI_SOFT_TRAFFIC_Q_LENGTH (20 + 1) -#define UNIFI_SOFT_COMMAND_Q_LENGTH (16 + 1) - -#include "csr_framework_ext.h" /* from the synergy porting folder */ -#include "csr_sdio.h" /* from the synergy porting folder */ -#include "csr_macro.h" /* from the synergy porting folder */ -#include "csr_wifi_result.h" - -/* Utility MACROS. Note that UNIFI_MAC_ADDRESS_CMP returns TRUE on success */ -#define UNIFI_MAC_ADDRESS_COPY(dst, src) \ - do { (dst)[0] = (src)[0]; (dst)[1] = (src)[1]; \ - (dst)[2] = (src)[2]; (dst)[3] = (src)[3]; \ - (dst)[4] = (src)[4]; (dst)[5] = (src)[5]; \ - } while (0) - -#define UNIFI_MAC_ADDRESS_CMP(addr1, addr2) \ - (((addr1)[0] == (addr2)[0]) && ((addr1)[1] == (addr2)[1]) && \ - ((addr1)[2] == (addr2)[2]) && ((addr1)[3] == (addr2)[3]) && \ - ((addr1)[4] == (addr2)[4]) && ((addr1)[5] == (addr2)[5])) - -/* Traffic queue ordered according to priority - * EAPOL/Uncontrolled port Queue should be the last - */ -typedef enum -{ - UNIFI_TRAFFIC_Q_BK = 0, - UNIFI_TRAFFIC_Q_BE, - UNIFI_TRAFFIC_Q_VI, - UNIFI_TRAFFIC_Q_VO, - UNIFI_TRAFFIC_Q_EAPOL, /* Non existent in HIP */ - UNIFI_TRAFFIC_Q_MAX, /* Non existent */ - UNIFI_TRAFFIC_Q_MLME /* Non existent */ -} unifi_TrafficQueue; - -/* - * Structure describing a bulk data slot. - * This structure is shared between the HIP core library and the OS - * layer. See the definition of unifi_net_data_malloc() for more details. - * - * The data_length field is used to indicate empty/occupied state. - * Needs to be defined before #include "unifi_os.h". - */ -typedef struct _bulk_data_desc -{ - const u8 *os_data_ptr; - u32 data_length; - const void *os_net_buf_ptr; - u32 net_buf_length; -} bulk_data_desc_t; - -/* Structure of an entry in the Symbol Look Up Table (SLUT). */ -typedef struct _symbol -{ - u16 id; - u32 obj; -} symbol_t; - -/* - * Header files need to be included from the current directory, - * the SME library, the synergy framework and the OS layer. - * A thin OS layer needs to be implemented in the porting exercise. - * - * Note that unifi_os.h should be included only in unifi.h - */ - -#include "unifi_os.h" - -/* - * Contains the HIP core definitions selected in the porting exercise, such as - * UNIFI_PAD_BULK_DATA_TO_BLOCK_SIZE and UNIFI_PAD_SIGNALS_TO_BLOCK_SIZE. - * Implemented in the OS layer, as part of the porting exersice. - */ -#include "unifi_config.h" - -#include "csr_wifi_hip_signals.h" /* from this dir */ - -/* - * The card structure is an opaque pointer that is used to pass context - * to the upper-edge API functions. - */ -typedef struct card card_t; - - -/* - * This structure describes all of the bulk data that 'might' be - * associated with a signal. - */ -typedef struct _bulk_data_param -{ - bulk_data_desc_t d[UNIFI_MAX_DATA_REFERENCES]; -} bulk_data_param_t; - - -/* - * This structure describes the chip and HIP core lib - * information that exposed to the OS layer. - */ -typedef struct _card_info -{ - u16 chip_id; - u16 chip_version; - u32 fw_build; - u16 fw_hip_version; - u32 sdio_block_size; -} card_info_t; - - -/* - * Mini-coredump definitions - */ -/* Definition of XAP memory ranges used by the mini-coredump system. - * Note that, these values are NOT the same as UNIFI_REGISTERS, etc - * in unifihw.h which don't allow selection of register areas for each XAP. - */ -typedef enum unifi_coredump_space -{ - UNIFI_COREDUMP_MAC_REG, - UNIFI_COREDUMP_PHY_REG, - UNIFI_COREDUMP_SH_DMEM, - UNIFI_COREDUMP_MAC_DMEM, - UNIFI_COREDUMP_PHY_DMEM, - UNIFI_COREDUMP_TRIGGER_MAGIC = 0xFEED -} unifi_coredump_space_t; - -/* Structure used to request a register value from a mini-coredump buffer */ -typedef struct unifi_coredump_req -{ - /* From user */ - s32 index; /* 0=newest, -1=oldest */ - unifi_coredump_space_t space; /* memory space */ - u32 offset; /* register offset in space */ - /* From driver */ - u32 drv_build; /* Driver build id */ - u32 chip_ver; /* Chip version */ - u32 fw_ver; /* Firmware version */ - s32 requestor; /* Requestor: 0=auto dump, 1=manual */ - u32 timestamp; /* time of capture by driver */ - u32 serial; /* capture serial number */ - s32 value; /* register value */ -} unifi_coredump_req_t; /* mini-coredumped reg value request */ - - -/** - * @defgroup upperedge Upper edge API - * - * The following functions are implemented in the HIP core lib. - */ - -/** - * - * Initialise the HIP core lib. - * Note that the OS layer must initialise the SDIO glue layer and obtain - * an SDIO function context, prior to this call. - * - * @param sdiopriv the SDIO function context. - * - * @param ospriv the OS layer context. - * - * @return \p card_t the HIP core lib API context. - * - * @ingroup upperedge - */ -card_t* unifi_alloc_card(CsrSdioFunction *sdiopriv, void *ospriv); - - -/** - * - * Initialise the UniFi chip. - * - * @param card the HIP core lib API context. - * - * @param led_mask the led mask to apply to UniFi. - * - * @return \b 0 if UniFi is initialized. - * - * @return \b -CSR_EIO if an I/O error occurred while initializing UniFi - * - * @return \b -CSR_ENODEV if the card is no longer present. - * - * @ingroup upperedge - */ -CsrResult unifi_init_card(card_t *card, s32 led_mask); - -/** - * - * De-Initialise the HIP core lib. - * - * @param card the HIP core lib API context. - * - * @ingroup upperedge - */ -void unifi_free_card(card_t *card); - -/** - * - * Cancel all the signals pending in the HIP core lib. - * Normally used during a system suspend when the power is retained on UniFi. - * - * @param card the HIP core lib API context. - * - * @ingroup upperedge - */ -void unifi_cancel_pending_signals(card_t *card); - -/** - * - * Send a signal to UniFi. - * Normally it is called from unifi_sys_hip_req() and the OS layer - * Tx data plane. - * - * Note that the bulkdata buffers ownership is passed to the HIP core lib. - * These buffers must be allocated using unifi_net_data_malloc(). - * - * @param card the HIP core lib API context. - * - * @param sigptr pointer to the signal. - * - * @param siglen size of the signal. - * - * @param bulkdata pointer to the bulk data associated with the signal. - * - * @return \b 0 signal is sent. - * - * @return \b -CSR_EIO if an error occurred while sending the signal - * - * @return \b -CSR_ENODEV if the card is no longer present. - * - * @ingroup upperedge - */ -CsrResult unifi_send_signal(card_t *card, const u8 *sigptr, - u32 siglen, - const bulk_data_param_t *bulkdata); - -/** - * - * Check if the HIP core lib has resources to send a signal. - * Normally there no need to use this function. - * - * @param card the HIP core lib API context. - * - * @param sigptr pointer to the signal. - * - * @return \b 0 if there are resources for the signal. - * - * @return \b -CSR_ENOSPC if there are not enough resources - * - * @ingroup upperedge - */ -CsrResult unifi_send_resources_available(card_t *card, const u8 *sigptr); - -/** - * - * Read the UniFi chip and the HIP core lib information. - * - * @param card the HIP core lib API context. - * - * @param card_info pointer to save the information. - * - * @ingroup upperedge - */ -void unifi_card_info(card_t *card, card_info_t *card_info); - -/** - * - * Print the UniFi I/O and Interrupt status. - * Normally it is used for debug purposes only. - * - * @param card the HIP core lib API context. - - * @param status buffer for the chip status - * - * @return \b 0 if the check was performed. - * - * @return \b -CSR_EIO if an error occurred while checking the status. - * - * @return \b -CSR_ENODEV if the card is no longer present. - * - * @ingroup upperedge - */ -CsrResult unifi_check_io_status(card_t *card, s32 *status); - - -/** - * - * Run the HIP core lib Botton-Half. - * Whenever the HIP core lib want this function to be called - * by the OS layer, it calls unifi_run_bh(). - * - * @param card the HIP core lib API context. - * - * @param remaining pointer to return the time (in msecs) that this function - * should be re-scheduled. A return value of 0 means that no re-scheduling - * is required. If unifi_bh() is called before the timeout expires, - * the caller must pass in the remaining time. - * - * @return \b 0 if no error occurred. - * - * @return \b -CSR_ENODEV if the card is no longer present. - * - * @return \b -CSR_E* if an error occurred while running the bottom half. - * - * @ingroup upperedge - */ -CsrResult unifi_bh(card_t *card, u32 *remaining); - - -/** - * UniFi Low Power Mode (Deep Sleep Signaling) - * - * unifi_low_power_mode defines the UniFi Deep Sleep Signaling status. - * Use with unifi_configure_low_power_mode() to enable/disable - * the Deep Sleep Signaling. - */ -enum unifi_low_power_mode -{ - UNIFI_LOW_POWER_DISABLED, - UNIFI_LOW_POWER_ENABLED -}; - -/** - * Periodic Wake Host Mode - * - * unifi_periodic_wake_mode defines the Periodic Wake Host Mode. - * It can only be set to UNIFI_PERIODIC_WAKE_HOST_ENABLED if - * low_power_mode == UNIFI_LOW_POWER_ENABLED. - */ -enum unifi_periodic_wake_mode -{ - UNIFI_PERIODIC_WAKE_HOST_DISABLED, - UNIFI_PERIODIC_WAKE_HOST_ENABLED -}; - -/** - * - * Run the HIP core lib Botton-Half. - * Whenever the HIP core lib want this function to be called - * by the OS layer, it calls unifi_run_bh(). - * - * Typically, the SME is responsible for configuring these parameters, - * so unifi_sys_configure_power_mode_req() is usually implemented - * as a direct call to unifi_configure_low_power_mode(). - * - * Note: When polling mode is used instead of interrupts, - * low_power_mode must never be set to UNIFI_LOW_POWER_ENABLED. - * - * @param card the HIP core lib API context. - * - * @param low_power_mode the Low Power Mode. - * - * @param periodic_wake_mode the Periodic Wake Mode. - * - * @return \b 0 if no error occurred. - * - * @return \b -CSR_E* if the request failed. - * - * @ingroup upperedge - */ -CsrResult unifi_configure_low_power_mode(card_t *card, - enum unifi_low_power_mode low_power_mode, - enum unifi_periodic_wake_mode periodic_wake_mode); - -/** - * - * Forces the UniFi chip to enter a Deep Sleep state. - * This is normally called by the OS layer when the platform suspends. - * - * Note that if the UniFi Low Power Mode is disabled this call fails. - * - * @param card the HIP core lib API context. - * - * @return \b 0 if no error occurred. - * - * @return \b -CSR_ENODEV if the card is no longer present. - * - * @return \b -CSR_E* if the request failed. - * - * @ingroup upperedge - */ -CsrResult unifi_force_low_power_mode(card_t *card); - -#ifndef CSR_WIFI_HIP_TA_DISABLE -/** - * Configure the Traffic Analysis sampling - * - * Enable or disable statistics gathering. - * Enable or disable particular packet detection. - * - * @param card the HIP core context - * @param config_type the item to configure - * @param config pointer to struct containing config info - * - * @return \b 0 if configuration was successful - * - * @return \b -CSR_EINVAL if a parameter had an invalid value - * - * @ingroup upperedge - */ -CsrResult unifi_ta_configure(card_t *card, - CsrWifiRouterCtrlTrafficConfigType config_type, - const CsrWifiRouterCtrlTrafficConfig *config); - -/** - * Pass a packet for Traffic Analysis sampling - * - * @param card the HIP core context - * @param direction the direction (Rx or Tx) of the frame. - * @param data pointer to bulkdata struct containing the packet - * @param saddr the source address of the packet - * @param sta_macaddr the MAC address of the UniFi chip - * @param timestamp the current time in msecs - * - * @ingroup upperedge - */ -void unifi_ta_sample(card_t *card, - CsrWifiRouterCtrlProtocolDirection direction, - const bulk_data_desc_t *data, - const u8 *saddr, - const u8 *sta_macaddr, - u32 timestamp, - u16 rate); - -/** - * Notify the HIP core lib for a detected Traffic Classification. - * Typically, the SME is responsible for configuring these parameters, - * so unifi_sys_traffic_classification_req() is usually implemented - * as a direct call to unifi_ta_classification(). - * - * @param card the HIP core context. - * @param traffic_type the detected traffic type. - * @param period The detected period of the traffic. - * - * @ingroup upperedge - */ -void unifi_ta_classification(card_t *card, - CsrWifiRouterCtrlTrafficType traffic_type, - u16 period); - -#endif -/** - * Use software to hard reset the chip. - * This is a subset of the unifi_init_card() functionality and should - * only be used only to reset a paniced chip before a coredump is taken. - * - * @param card the HIP core context. - * - * @ingroup upperedge - */ -CsrResult unifi_card_hard_reset(card_t *card); - - -CsrResult unifi_card_readn(card_t *card, u32 unifi_addr, void *pdata, u16 len); -CsrResult unifi_card_read16(card_t *card, u32 unifi_addr, u16 *pdata); -CsrResult unifi_card_write16(card_t *card, u32 unifi_addr, u16 data); - - -enum unifi_dbg_processors_select -{ - UNIFI_PROC_MAC, - UNIFI_PROC_PHY, - UNIFI_PROC_BT, - UNIFI_PROC_BOTH, - UNIFI_PROC_INVALID -}; - -CsrResult unifi_card_stop_processor(card_t *card, enum unifi_dbg_processors_select which); - -/** - * Call-outs from the HIP core lib to the OS layer. - * The following functions need to be implemented during the porting exercise. - */ - -/** - * Selects appropriate queue according to priority - * Helps maintain uniformity in queue selection between the HIP - * and the OS layers. - * - * @param priority priority of the packet - * - * @return \b Traffic queue to which a packet of this priority belongs - * - * @ingroup upperedge - */ -unifi_TrafficQueue -unifi_frame_priority_to_queue(CSR_PRIORITY priority); - -/** - * Returns the priority corresponding to a particular Queue when that is used - * when downgrading a packet to a lower AC. - * Helps maintain uniformity in queue - priority mapping between the HIP - * and the OS layers. - * - * @param queue - * - * @return \b Highest priority corresponding to this queue - * - * @ingroup upperedge - */ -CSR_PRIORITY unifi_get_default_downgrade_priority(unifi_TrafficQueue queue); - -/** - * - * Flow control callbacks. - * unifi_pause_xmit() is called when the HIP core lib does not have any - * resources to store data packets. The OS layer needs to pause - * the Tx data plane until unifi_restart_xmit() is called. - * - * @param ospriv the OS layer context. - * - * @ingroup upperedge - */ -void unifi_pause_xmit(void *ospriv, unifi_TrafficQueue queue); -void unifi_restart_xmit(void *ospriv, unifi_TrafficQueue queue); - -/** - * - * Request to run the Bottom-Half. - * The HIP core lib calls this function to request that unifi_bh() - * needs to be run by the OS layer. It can be called anytime, i.e. - * when the unifi_bh() is running. - * Since unifi_bh() is not re-entrant, usually unifi_run_bh() sets - * an event to a thread that schedules a call to unifi_bh(). - * - * @param ospriv the OS layer context. - * - * @ingroup upperedge - */ -CsrResult unifi_run_bh(void *ospriv); - -/** - * - * Delivers a signal received from UniFi to the OS layer. - * Normally, the data signals should be delivered to the data plane - * and all the rest to the SME (unifi_sys_hip_ind()). - * - * Note that the OS layer is responsible for freeing the bulkdata - * buffers, using unifi_net_data_free(). - * - * @param ospriv the OS layer context. - * - * @param sigptr pointer to the signal. - * - * @param siglen size of the signal. - * - * @param bulkdata pointer to the bulk data associated with the signal. - * - * @ingroup upperedge - */ -void unifi_receive_event(void *ospriv, - u8 *sigdata, u32 siglen, - const bulk_data_param_t *bulkdata); - -#ifdef CSR_WIFI_REQUEUE_PACKET_TO_HAL -/** - * - * Used to reque the failed ma packet request back to hal queues - * - * @param ospriv the OS layer context. - * - * @param host_tag host tag for the packet to requeue. - * - * @param bulkDataDesc pointer to the bulk data. - * - * @ingroup upperedge - */ -CsrResult unifi_reque_ma_packet_request(void *ospriv, u32 host_tag, - u16 status, - bulk_data_desc_t *bulkDataDesc); - -#endif -typedef struct -{ - u16 free_fh_sig_queue_slots[UNIFI_NO_OF_TX_QS]; - u16 free_fh_bulkdata_slots; - u16 free_fh_fw_slots; -} unifi_HipQosInfo; - -void unifi_get_hip_qos_info(card_t *card, unifi_HipQosInfo *hipqosinfo); - - -/** - * Functions that read a portion of a firmware file. - * - * Note: If the UniFi chip runs the f/w from ROM, the HIP core may never - * call these functions. Also, the HIP core may call these functions even if - * a f/w file is not available. In this case, it is safe to fail the request. - */ -#define UNIFI_FW_STA 1 /* Identify STA firmware file */ - -/** - * - * Ask the OS layer to initialise a read from a f/w file. - * - * @param ospriv the OS layer context. - * - * @param is_fw if 0 the request if for the loader file, if 1 the request - * is for a f/w file. - * - * @param info a card_info_t structure containing versions information. - * Note that some members of the structure may not be initialised. - * - * @return \p NULL if the file is not available, or a pointer which contains - * OS specific information for the file (typically the contents of the file) - * that the HIP core uses when calling unifi_fw_read() and unifi_fw_read_stop() - * - * @ingroup upperedge - */ -void* unifi_fw_read_start(void *ospriv, s8 is_fw, const card_info_t *info); - -/** - * - * Ask the OS layer to return a portion from a f/w file. - * - * @param ospriv the OS layer context. - * - * @param arg the OS pointer returned by unifi_fw_read_start(). - * - * @param offset the offset in the f/w file to read the read from. - * - * @param buf the buffer to store the returned data. - * - * @param len the size in bytes of the requested read. - * - * @ingroup upperedge - */ -s32 unifi_fw_read(void *ospriv, void *arg, u32 offset, void *buf, u32 len); - -/** - * - * Ask the OS layer to finish reading from a f/w file. - * - * @param ospriv the OS layer context. - * - * @param dlpriv the OS pointer returned by unifi_fw_read_start(). - * - * @ingroup upperedge - */ -void unifi_fw_read_stop(void *ospriv, void *dlpriv); - -/** - * - * Ask OS layer for a handle to a dynamically allocated firmware buffer - * (primarily intended for production test images which may need conversion) - * - * @param ospriv the OS layer context. - * - * @param fwbuf pointer to dynamically allocated buffer - * - * @param len length of provided buffer in bytes - * - * @ingroup upperedge - */ -void* unifi_fw_open_buffer(void *ospriv, void *fwbuf, u32 len); - -/** - * - * Release a handle to a dynamically allocated firmware buffer - * (primarily intended for production test images which may need conversion) - * - * @param ospriv the OS layer context. - * - * @param fwbuf pointer to dynamically allocated buffer - * - * @ingroup upperedge - */ -void unifi_fw_close_buffer(void *ospriv, void *fwbuf); - -#ifndef CSR_WIFI_HIP_TA_DISABLE -/* - * Driver must provide these. - * - * A simple implementation will just call - * unifi_sys_traffic_protocol_ind() or unifi_sys_traffic_classification_ind() - * respectively. See sme_csr_userspace/sme_userspace.c. - */ -/** - * - * Indicates a detected packet of type packet_type. - * Typically, this information is processed by the SME so - * unifi_ta_indicate_protocol() needs to schedule a call to - * unifi_sys_traffic_protocol_ind(). - * - * @param ospriv the OS layer context. - * - * @param packet_type the detected packet type. - * - * @param direction the direction of the packet (Rx, Tx). - * - * @param src_addr the source address of the packet. - * - * @ingroup upperedge - */ -void unifi_ta_indicate_protocol(void *ospriv, - CsrWifiRouterCtrlTrafficPacketType packet_type, - CsrWifiRouterCtrlProtocolDirection direction, - const CsrWifiMacAddress *src_addr); - -/** - * - * Indicates statistics for the sample data over a period. - * Typically, this information is processed by the SME so - * unifi_ta_indicate_sampling() needs to schedule a call to - * unifi_sys_traffic_sample_ind(). - * - * @param ospriv the OS layer context. - * - * @param stats the pointer to the structure that contains the statistics. - * - * @ingroup upperedge - */ -void unifi_ta_indicate_sampling(void *ospriv, CsrWifiRouterCtrlTrafficStats *stats); -void unifi_ta_indicate_l4stats(void *ospriv, - u32 rxTcpThroughput, - u32 txTcpThroughput, - u32 rxUdpThroughput, - u32 txUdpThroughput); -#endif - -void unifi_rx_queue_flush(void *ospriv); - -/** - * Call-out from the SDIO glue layer. - * - * The glue layer needs to call unifi_sdio_interrupt_handler() every time - * an interrupts occurs. - * - * @param card the HIP core context. - * - * @ingroup bottomedge - */ -void unifi_sdio_interrupt_handler(card_t *card); - - -/* HELPER FUNCTIONS */ - -/* - * unifi_init() and unifi_download() implement a subset of unifi_init_card functionality - * that excludes HIP initialization. - */ -CsrResult unifi_init(card_t *card); -CsrResult unifi_download(card_t *card, s32 led_mask); - -/* - * unifi_start_processors() ensures both on-chip processors are running - */ -CsrResult unifi_start_processors(card_t *card); - -CsrResult unifi_capture_panic(card_t *card); - -/* - * Configure HIP interrupt processing mode - */ -#define CSR_WIFI_INTMODE_DEFAULT 0 -#define CSR_WIFI_INTMODE_RUN_BH_ONCE 1 /* Run BH once per interrupt */ - -void unifi_set_interrupt_mode(card_t *card, u32 mode); - -/* - * unifi_request_max_clock() requests that max SDIO clock speed is set at the - * next suitable opportunity. - */ -void unifi_request_max_sdio_clock(card_t *card); - - -/* Functions to lookup bulk data command names. */ -const char* lookup_bulkcmd_name(u16 id); - -/* Function to log HIP's global debug buffer */ -#ifdef CSR_WIFI_HIP_DEBUG_OFFLINE -void unifi_debug_buf_dump(void); -void unifi_debug_log_to_buf(const char *fmt, ...); -void unifi_debug_hex_to_buf(const char *buff, u16 length); -#endif - -/* Mini-coredump utility functions */ -CsrResult unifi_coredump_get_value(card_t *card, struct unifi_coredump_req *req); -CsrResult unifi_coredump_capture(card_t *card, struct unifi_coredump_req *req); -CsrResult unifi_coredump_request_at_next_reset(card_t *card, s8 enable); -CsrResult unifi_coredump_init(card_t *card, u16 num_dump_buffers); -void unifi_coredump_free(card_t *card); - -#endif /* __CSR_WIFI_HIP_UNIFI_H__ */ diff --git a/drivers/staging/csr/csr_wifi_hip_unifi_signal_names.c b/drivers/staging/csr/csr_wifi_hip_unifi_signal_names.c deleted file mode 100644 index 9a3528599f3c..000000000000 --- a/drivers/staging/csr/csr_wifi_hip_unifi_signal_names.c +++ /dev/null @@ -1,41 +0,0 @@ -/***************************************************************************** - - (c) Cambridge Silicon Radio Limited 2011 - All rights reserved and confidential information of CSR - - Refer to LICENSE.txt included with this source for details - on the license terms. - -*****************************************************************************/ - -#include "csr_wifi_hip_unifi.h" - -struct sig_name { - s16 id; - const char *name; -}; - -static const struct sig_name Unifi_bulkcmd_names[] = { - { 0, "SignalCmd" }, - { 1, "CopyToHost" }, - { 2, "CopyToHostAck" }, - { 3, "CopyFromHost" }, - { 4, "CopyFromHostAck" }, - { 5, "ClearSlot" }, - { 6, "CopyOverlay" }, - { 7, "CopyOverlayAck" }, - { 8, "CopyFromHostAndClearSlot" }, - { 15, "Padding" } -}; - -const char *lookup_bulkcmd_name(u16 id) -{ - if (id < 9) - return Unifi_bulkcmd_names[id].name; - if (id == 15) - return "Padding"; - - return "UNKNOWN"; -} - - diff --git a/drivers/staging/csr/csr_wifi_hip_unifi_udi.h b/drivers/staging/csr/csr_wifi_hip_unifi_udi.h deleted file mode 100644 index 4126e85bfe9b..000000000000 --- a/drivers/staging/csr/csr_wifi_hip_unifi_udi.h +++ /dev/null @@ -1,52 +0,0 @@ -/***************************************************************************** - - (c) Cambridge Silicon Radio Limited 2011 - All rights reserved and confidential information of CSR - - Refer to LICENSE.txt included with this source for details - on the license terms. - -*****************************************************************************/ - -/* - * --------------------------------------------------------------------------- - * FILE: csr_wifi_hip_unifi_udi.h - * - * PURPOSE: - * Declarations and definitions for the UniFi Debug Interface. - * - * --------------------------------------------------------------------------- - */ -#ifndef __CSR_WIFI_HIP_UNIFI_UDI_H__ -#define __CSR_WIFI_HIP_UNIFI_UDI_H__ - -#include "csr_wifi_hip_unifi.h" -#include "csr_wifi_hip_signals.h" - - -/* - * Support for tracing the wire protocol. - */ -enum udi_log_direction -{ - UDI_LOG_FROM_HOST = 0x0000, - UDI_LOG_TO_HOST = 0x0001 -}; - -typedef void (*udi_func_t)(void *ospriv, u8 *sigdata, - u32 signal_len, - const bulk_data_param_t *bulkdata, - enum udi_log_direction dir); - -CsrResult unifi_set_udi_hook(card_t *card, udi_func_t udi_fn); -CsrResult unifi_remove_udi_hook(card_t *card, udi_func_t udi_fn); - - -/* - * Function to print current status info to a string. - * This is used in the linux /proc interface and might be useful - * in other systems. - */ -s32 unifi_print_status(card_t *card, struct seq_file *m); - -#endif /* __CSR_WIFI_HIP_UNIFI_UDI_H__ */ diff --git a/drivers/staging/csr/csr_wifi_hip_unifihw.h b/drivers/staging/csr/csr_wifi_hip_unifihw.h deleted file mode 100644 index 3f9fcbd55b55..000000000000 --- a/drivers/staging/csr/csr_wifi_hip_unifihw.h +++ /dev/null @@ -1,59 +0,0 @@ -/***************************************************************************** - - (c) Cambridge Silicon Radio Limited 2011 - All rights reserved and confidential information of CSR - - Refer to LICENSE.txt included with this source for details - on the license terms. - -*****************************************************************************/ - -/* - * --------------------------------------------------------------------------- - * - * File: csr_wifi_hip_unifihw.h - * - * Definitions of various chip registers, addresses, values etc. - * - * --------------------------------------------------------------------------- - */ -#ifndef __UNIFIHW_H__ -#define __UNIFIHW_H__ 1 - -/* Symbol Look Up Table fingerprint. IDs are in sigs.h */ -#define SLUT_FINGERPRINT 0xD397 - - -/* Values of LoaderOperation */ -#define UNIFI_LOADER_IDLE 0x00 -#define UNIFI_LOADER_COPY 0x01 -#define UNIFI_LOADER_ERROR_MASK 0xF0 - -/* Values of BootLoaderOperation */ -#define UNIFI_BOOT_LOADER_IDLE 0x00 -#define UNIFI_BOOT_LOADER_RESTART 0x01 -#define UNIFI_BOOT_LOADER_PATCH 0x02 -#define UNIFI_BOOT_LOADER_LOAD_STA 0x10 -#define UNIFI_BOOT_LOADER_LOAD_PTEST 0x11 - - -/* Memory spaces encoded in top byte of Generic Pointer type */ -#define UNIFI_SH_DMEM 0x01 /* Shared Data Memory */ -#define UNIFI_EXT_FLASH 0x02 /* External FLASH */ -#define UNIFI_EXT_SRAM 0x03 /* External SRAM */ -#define UNIFI_REGISTERS 0x04 /* Registers */ -#define UNIFI_PHY_DMEM 0x10 /* PHY Data Memory */ -#define UNIFI_PHY_PMEM 0x11 /* PHY Program Memory */ -#define UNIFI_PHY_ROM 0x12 /* PHY ROM */ -#define UNIFI_MAC_DMEM 0x20 /* MAC Data Memory */ -#define UNIFI_MAC_PMEM 0x21 /* MAC Program Memory */ -#define UNIFI_MAC_ROM 0x22 /* MAC ROM */ -#define UNIFI_BT_DMEM 0x30 /* BT Data Memory */ -#define UNIFI_BT_PMEM 0x31 /* BT Program Memory */ -#define UNIFI_BT_ROM 0x32 /* BT ROM */ - -#define UNIFI_MAKE_GP(R, O) (((UNIFI_ ## R) << 24) | (O)) -#define UNIFI_GP_OFFSET(GP) ((GP) & 0xFFFFFF) -#define UNIFI_GP_SPACE(GP) (((GP) >> 24) & 0xFF) - -#endif /* __UNIFIHW_H__ */ diff --git a/drivers/staging/csr/csr_wifi_hip_unifiversion.h b/drivers/staging/csr/csr_wifi_hip_unifiversion.h deleted file mode 100644 index d1c66783f32c..000000000000 --- a/drivers/staging/csr/csr_wifi_hip_unifiversion.h +++ /dev/null @@ -1,30 +0,0 @@ -/***************************************************************************** - - (c) Cambridge Silicon Radio Limited 2011 - All rights reserved and confidential information of CSR - - Refer to LICENSE.txt included with this source for details - on the license terms. - -*****************************************************************************/ - -/* - * --------------------------------------------------------------------------- - * FILE: unifiversion.h - * - * PURPOSE: - * Version information for the portable UniFi driver. - * - * --------------------------------------------------------------------------- - */ - -#ifndef __UNIFIVERSION_H__ -#define __UNIFIVERSION_H__ - -/* - * The minimum version of Host Interface Protocol required by the driver. - */ -#define UNIFI_HIP_MAJOR_VERSION 9 -#define UNIFI_HIP_MINOR_VERSION 1 - -#endif /* __UNIFIVERSION_H__ */ diff --git a/drivers/staging/csr/csr_wifi_hip_xbv.c b/drivers/staging/csr/csr_wifi_hip_xbv.c deleted file mode 100644 index 050a15fbadf9..000000000000 --- a/drivers/staging/csr/csr_wifi_hip_xbv.c +++ /dev/null @@ -1,1076 +0,0 @@ -/***************************************************************************** - - (c) Cambridge Silicon Radio Limited 2012 - All rights reserved and confidential information of CSR - - Refer to LICENSE.txt included with this source for details - on the license terms. - -*****************************************************************************/ - -/* - * --------------------------------------------------------------------------- - * FILE: csr_wifi_hip_xbv.c - * - * PURPOSE: - * Routines for downloading firmware to UniFi. - * - * UniFi firmware files use a nested TLV (Tag-Length-Value) format. - * - * --------------------------------------------------------------------------- - */ -#include - -#ifdef CSR_WIFI_XBV_TEST -/* Standalone test harness */ -#include "unifi_xbv.h" -#include "csr_wifi_hip_unifihw.h" -#else -/* Normal driver build */ -#include "csr_wifi_hip_unifiversion.h" -#include "csr_wifi_hip_card.h" -#define DBG_TAG(t) -#endif - -#include "csr_wifi_hip_xbv.h" - -#define STREAM_CHECKSUM 0x6d34 /* Sum of uint16s in each patch stream */ - -/* XBV sizes used in patch conversion - */ -#define PTDL_MAX_SIZE 2048 /* Max bytes allowed per PTDL */ -#define PTDL_HDR_SIZE (4 + 2 + 6 + 2) /* sizeof(fw_id, sec_len, patch_cmd, csum) */ - -/* Struct to represent a buffer for reading firmware file */ - -typedef struct -{ - void *dlpriv; - s32 ioffset; - fwreadfn_t iread; -} ct_t; - -/* Struct to represent a TLV field */ -typedef struct -{ - char t_name[4]; - u32 t_len; -} tag_t; - - -#define TAG_EQ(i, v) (((i)[0] == (v)[0]) && \ - ((i)[1] == (v)[1]) && \ - ((i)[2] == (v)[2]) && \ - ((i)[3] == (v)[3])) - -/* We create a small stack on the stack that contains an enum - * indicating the containing list segments, and the offset at which - * those lists end. This enables a lot more error checking. */ -typedef enum -{ - xbv_xbv1, - /*xbv_info,*/ - xbv_fw, - xbv_vers, - xbv_vand, - xbv_ptch, - xbv_other -} xbv_container; - -#define XBV_STACK_SIZE 6 -#define XBV_MAX_OFFS 0x7fffffff - -typedef struct -{ - struct - { - xbv_container container; - s32 ioffset_end; - } s[XBV_STACK_SIZE]; - u32 ptr; -} xbv_stack_t; - -static s32 read_tag(card_t *card, ct_t *ct, tag_t *tag); -static s32 read_bytes(card_t *card, ct_t *ct, void *buf, u32 len); -static s32 read_uint(card_t *card, ct_t *ct, u32 *u, u32 len); -static s32 xbv_check(xbv1_t *fwinfo, const xbv_stack_t *stack, - xbv_mode new_mode, xbv_container old_cont); -static s32 xbv_push(xbv1_t *fwinfo, xbv_stack_t *stack, - xbv_mode new_mode, xbv_container old_cont, - xbv_container new_cont, u32 ioff); - -static u32 write_uint16(void *buf, const u32 offset, - const u16 val); -static u32 write_uint32(void *buf, const u32 offset, - const u32 val); -static u32 write_bytes(void *buf, const u32 offset, - const u8 *data, const u32 len); -static u32 write_tag(void *buf, const u32 offset, - const char *tag_str); -static u32 write_chunk(void *buf, const u32 offset, - const char *tag_str, - const u32 payload_len); -static u16 calc_checksum(void *buf, const u32 offset, - const u32 bytes_len); -static u32 calc_patch_size(const xbv1_t *fwinfo); - -static u32 write_xbv_header(void *buf, const u32 offset, - const u32 file_payload_length); -static u32 write_ptch_header(void *buf, const u32 offset, - const u32 fw_id); -static u32 write_patchcmd(void *buf, const u32 offset, - const u32 dst_genaddr, const u16 len); -static u32 write_reset_ptdl(void *buf, const u32 offset, - const xbv1_t *fwinfo, u32 fw_id); -static u32 write_fwdl_to_ptdl(void *buf, const u32 offset, - fwreadfn_t readfn, const struct FWDL *fwdl, - const void *fw_buf, const u32 fw_id, - void *rdbuf); - -/* - * --------------------------------------------------------------------------- - * parse_xbv1 - * - * Scan the firmware file to find the TLVs we are interested in. - * Actions performed: - * - check we support the file format version in VERF - * Store these TLVs if we have a firmware image: - * - SLTP Symbol Lookup Table Pointer - * - FWDL firmware download segments - * - FWOL firmware overlay segment - * - VMEQ Register probe tests to verify matching h/w - * Store these TLVs if we have a patch file: - * - FWID the firmware build ID that this file patches - * - PTDL The actual patches - * - * The structure pointed to by fwinfo is cleared and - * 'fwinfo->mode' is set to 'unknown'. The 'fwinfo->mode' - * variable is set to 'firmware' or 'patch' once we know which - * sort of XBV file we have. - * - * Arguments: - * readfn Pointer to function to call to read from the file. - * dlpriv Opaque pointer arg to pass to readfn. - * fwinfo Pointer to fwinfo struct to fill in. - * - * Returns: - * CSR_RESULT_SUCCESS on success, CSR error code on failure - * --------------------------------------------------------------------------- - */ -CsrResult xbv1_parse(card_t *card, fwreadfn_t readfn, void *dlpriv, xbv1_t *fwinfo) -{ - ct_t ct; - tag_t tag; - xbv_stack_t stack; - - ct.dlpriv = dlpriv; - ct.ioffset = 0; - ct.iread = readfn; - - memset(fwinfo, 0, sizeof(xbv1_t)); - fwinfo->mode = xbv_unknown; - - /* File must start with XBV1 triplet */ - if (read_tag(card, &ct, &tag) <= 0) - { - unifi_error(NULL, "File is not UniFi firmware\n"); - return CSR_WIFI_HIP_RESULT_INVALID_VALUE; - } - - DBG_TAG(tag.t_name); - - if (!TAG_EQ(tag.t_name, "XBV1")) - { - unifi_error(NULL, "File is not UniFi firmware (%s)\n", tag.t_name); - return CSR_WIFI_HIP_RESULT_INVALID_VALUE; - } - - stack.ptr = 0; - stack.s[stack.ptr].container = xbv_xbv1; - stack.s[stack.ptr].ioffset_end = XBV_MAX_OFFS; - - /* Now scan the file */ - while (1) - { - s32 n; - - n = read_tag(card, &ct, &tag); - if (n < 0) - { - unifi_error(NULL, "No tag\n"); - return CSR_WIFI_HIP_RESULT_INVALID_VALUE; - } - if (n == 0) - { - /* End of file */ - break; - } - - DBG_TAG(tag.t_name); - - /* File format version */ - if (TAG_EQ(tag.t_name, "VERF")) - { - u32 version; - - if (xbv_check(fwinfo, &stack, xbv_unknown, xbv_xbv1) || - (tag.t_len != 2) || - read_uint(card, &ct, &version, 2)) - { - return CSR_WIFI_HIP_RESULT_INVALID_VALUE; - } - if (version != 0) - { - unifi_error(NULL, "Unsupported firmware file version: %d.%d\n", - version >> 8, version & 0xFF); - return CSR_WIFI_HIP_RESULT_INVALID_VALUE; - } - } - else if (TAG_EQ(tag.t_name, "LIST")) - { - char name[4]; - u32 list_end; - - list_end = ct.ioffset + tag.t_len; - - if (read_bytes(card, &ct, name, 4)) - { - return CSR_WIFI_HIP_RESULT_INVALID_VALUE; - } - - DBG_TAG(name); - if (TAG_EQ(name, "FW ")) - { - if (xbv_push(fwinfo, &stack, xbv_firmware, xbv_xbv1, xbv_fw, list_end)) - { - return CSR_WIFI_HIP_RESULT_INVALID_VALUE; - } - } - else if (TAG_EQ(name, "VERS")) - { - if (xbv_push(fwinfo, &stack, xbv_firmware, xbv_fw, xbv_vers, list_end) || - (fwinfo->vers.num_vand != 0)) - { - return CSR_WIFI_HIP_RESULT_INVALID_VALUE; - } - } - else if (TAG_EQ(name, "VAND")) - { - struct VAND *vand; - - if (xbv_push(fwinfo, &stack, xbv_firmware, xbv_vers, xbv_vand, list_end) || - (fwinfo->vers.num_vand >= MAX_VAND)) - { - return CSR_WIFI_HIP_RESULT_INVALID_VALUE; - } - - /* Get a new VAND */ - vand = fwinfo->vand + fwinfo->vers.num_vand++; - - /* Fill it in */ - vand->first = fwinfo->num_vmeq; - vand->count = 0; - } - else if (TAG_EQ(name, "PTCH")) - { - if (xbv_push(fwinfo, &stack, xbv_patch, xbv_xbv1, xbv_ptch, list_end)) - { - return CSR_WIFI_HIP_RESULT_INVALID_VALUE; - } - } - else - { - /* Skip over any other lists. We dont bother to push - * the new list type now as we would only pop it at - * the end of the outer loop. */ - ct.ioffset += tag.t_len - 4; - } - } - else if (TAG_EQ(tag.t_name, "SLTP")) - { - u32 addr; - - if (xbv_check(fwinfo, &stack, xbv_firmware, xbv_fw) || - (tag.t_len != 4) || - (fwinfo->slut_addr != 0) || - read_uint(card, &ct, &addr, 4)) - { - return CSR_WIFI_HIP_RESULT_INVALID_VALUE; - } - - fwinfo->slut_addr = addr; - } - else if (TAG_EQ(tag.t_name, "FWDL")) - { - u32 addr; - struct FWDL *fwdl; - - if (xbv_check(fwinfo, &stack, xbv_firmware, xbv_fw) || - (fwinfo->num_fwdl >= MAX_FWDL) || - (read_uint(card, &ct, &addr, 4))) - { - return CSR_WIFI_HIP_RESULT_INVALID_VALUE; - } - - fwdl = fwinfo->fwdl + fwinfo->num_fwdl++; - - fwdl->dl_size = tag.t_len - 4; - fwdl->dl_addr = addr; - fwdl->dl_offset = ct.ioffset; - - ct.ioffset += tag.t_len - 4; - } - else if (TAG_EQ(tag.t_name, "FWOV")) - { - if (xbv_check(fwinfo, &stack, xbv_firmware, xbv_fw) || - (fwinfo->fwov.dl_size != 0) || - (fwinfo->fwov.dl_offset != 0)) - { - return CSR_WIFI_HIP_RESULT_INVALID_VALUE; - } - - fwinfo->fwov.dl_size = tag.t_len; - fwinfo->fwov.dl_offset = ct.ioffset; - - ct.ioffset += tag.t_len; - } - else if (TAG_EQ(tag.t_name, "VMEQ")) - { - u32 temp[3]; - struct VAND *vand; - struct VMEQ *vmeq; - - if (xbv_check(fwinfo, &stack, xbv_firmware, xbv_vand) || - (fwinfo->num_vmeq >= MAX_VMEQ) || - (fwinfo->vers.num_vand == 0) || - (tag.t_len != 8) || - read_uint(card, &ct, &temp[0], 4) || - read_uint(card, &ct, &temp[1], 2) || - read_uint(card, &ct, &temp[2], 2)) - { - return CSR_WIFI_HIP_RESULT_INVALID_VALUE; - } - - /* Get the last VAND */ - vand = fwinfo->vand + (fwinfo->vers.num_vand - 1); - - /* Get a new VMEQ */ - vmeq = fwinfo->vmeq + fwinfo->num_vmeq++; - - /* Note that this VAND contains another VMEQ */ - vand->count++; - - /* Fill in the VMEQ */ - vmeq->addr = temp[0]; - vmeq->mask = (u16)temp[1]; - vmeq->value = (u16)temp[2]; - } - else if (TAG_EQ(tag.t_name, "FWID")) - { - u32 build_id; - - if (xbv_check(fwinfo, &stack, xbv_patch, xbv_ptch) || - (tag.t_len != 4) || - (fwinfo->build_id != 0) || - read_uint(card, &ct, &build_id, 4)) - { - return CSR_WIFI_HIP_RESULT_INVALID_VALUE; - } - - fwinfo->build_id = build_id; - } - else if (TAG_EQ(tag.t_name, "PTDL")) - { - struct PTDL *ptdl; - - if (xbv_check(fwinfo, &stack, xbv_patch, xbv_ptch) || - (fwinfo->num_ptdl >= MAX_PTDL)) - { - return CSR_WIFI_HIP_RESULT_INVALID_VALUE; - } - - /* Allocate a new PTDL */ - ptdl = fwinfo->ptdl + fwinfo->num_ptdl++; - - ptdl->dl_size = tag.t_len; - ptdl->dl_offset = ct.ioffset; - - ct.ioffset += tag.t_len; - } - else - { - /* - * If we get here it is a tag we are not interested in, - * just skip over it. - */ - ct.ioffset += tag.t_len; - } - - /* Check to see if we are at the end of the currently stacked - * segment. We could finish more than one list at a time. */ - while (ct.ioffset >= stack.s[stack.ptr].ioffset_end) - { - if (ct.ioffset > stack.s[stack.ptr].ioffset_end) - { - unifi_error(NULL, - "XBV file has overrun stack'd segment %d (%d > %d)\n", - stack.ptr, ct.ioffset, stack.s[stack.ptr].ioffset_end); - return CSR_WIFI_HIP_RESULT_INVALID_VALUE; - } - if (stack.ptr <= 0) - { - unifi_error(NULL, "XBV file has underrun stack pointer\n"); - return CSR_WIFI_HIP_RESULT_INVALID_VALUE; - } - stack.ptr--; - } - } - - if (stack.ptr != 0) - { - unifi_error(NULL, "Last list of XBV is not complete.\n"); - return CSR_WIFI_HIP_RESULT_INVALID_VALUE; - } - - return CSR_RESULT_SUCCESS; -} /* xbv1_parse() */ - - -/* Check the the XBV file is of a consistant sort (either firmware or - * patch) and that we are in the correct containing list type. */ -static s32 xbv_check(xbv1_t *fwinfo, const xbv_stack_t *stack, - xbv_mode new_mode, xbv_container old_cont) -{ - /* If the new file mode is unknown the current packet could be in - * either (any) type of XBV file, and we cant make a decission at - * this time. */ - if (new_mode != xbv_unknown) - { - if (fwinfo->mode == xbv_unknown) - { - fwinfo->mode = new_mode; - } - else if (fwinfo->mode != new_mode) - { - return -1; - } - } - /* If the current stack top doesn't match what we expect then the - * file is corrupt. */ - if (stack->s[stack->ptr].container != old_cont) - { - return -1; - } - return 0; -} - - -/* Make checks as above and then enter a new list */ -static s32 xbv_push(xbv1_t *fwinfo, xbv_stack_t *stack, - xbv_mode new_mode, xbv_container old_cont, - xbv_container new_cont, u32 new_ioff) -{ - if (xbv_check(fwinfo, stack, new_mode, old_cont)) - { - return -1; - } - - /* Check that our stack won't overflow. */ - if (stack->ptr >= (XBV_STACK_SIZE - 1)) - { - return -1; - } - - /* Add the new list element to the top of the stack. */ - stack->ptr++; - stack->s[stack->ptr].container = new_cont; - stack->s[stack->ptr].ioffset_end = new_ioff; - - return 0; -} - - -static u32 xbv2uint(u8 *ptr, s32 len) -{ - u32 u = 0; - s16 i; - - for (i = 0; i < len; i++) - { - u32 b; - b = ptr[i]; - u += b << (i * 8); - } - return u; -} - - -static s32 read_tag(card_t *card, ct_t *ct, tag_t *tag) -{ - u8 buf[8]; - s32 n; - - n = (*ct->iread)(card->ospriv, ct->dlpriv, ct->ioffset, buf, 8); - if (n <= 0) - { - return n; - } - - /* read the tag and length */ - if (n != 8) - { - return -1; - } - - /* get section tag */ - memcpy(tag->t_name, buf, 4); - - /* get section length */ - tag->t_len = xbv2uint(buf + 4, 4); - - ct->ioffset += 8; - - return 8; -} /* read_tag() */ - - -static s32 read_bytes(card_t *card, ct_t *ct, void *buf, u32 len) -{ - /* read the tag value */ - if ((*ct->iread)(card->ospriv, ct->dlpriv, ct->ioffset, buf, len) != (s32)len) - { - return -1; - } - - ct->ioffset += len; - - return 0; -} /* read_bytes() */ - - -static s32 read_uint(card_t *card, ct_t *ct, u32 *u, u32 len) -{ - u8 buf[4]; - - /* Integer cannot be more than 4 bytes */ - if (len > 4) - { - return -1; - } - - if (read_bytes(card, ct, buf, len)) - { - return -1; - } - - *u = xbv2uint(buf, len); - - return 0; -} /* read_uint() */ - - -static u32 write_uint16(void *buf, const u32 offset, const u16 val) -{ - u8 *dst = (u8 *)buf + offset; - *dst++ = (u8)(val & 0xff); /* LSB first */ - *dst = (u8)(val >> 8); - return sizeof(u16); -} - - -static u32 write_uint32(void *buf, const u32 offset, const u32 val) -{ - (void)write_uint16(buf, offset + 0, (u16)(val & 0xffff)); - (void)write_uint16(buf, offset + 2, (u16)(val >> 16)); - return sizeof(u32); -} - - -static u32 write_bytes(void *buf, const u32 offset, const u8 *data, const u32 len) -{ - u32 i; - u8 *dst = (u8 *)buf + offset; - - for (i = 0; i < len; i++) - { - *dst++ = *((u8 *)data + i); - } - return len; -} - - -static u32 write_tag(void *buf, const u32 offset, const char *tag_str) -{ - u8 *dst = (u8 *)buf + offset; - memcpy(dst, tag_str, 4); - return 4; -} - - -static u32 write_chunk(void *buf, const u32 offset, const char *tag_str, const u32 payload_len) -{ - u32 written = 0; - written += write_tag(buf, offset, tag_str); - written += write_uint32(buf, written + offset, (u32)payload_len); - - return written; -} - - -static u16 calc_checksum(void *buf, const u32 offset, const u32 bytes_len) -{ - u32 i; - u8 *src = (u8 *)buf + offset; - u16 sum = 0; - u16 val; - - for (i = 0; i < bytes_len / 2; i++) - { - /* Contents copied to file is LE, host might not be */ - val = (u16) * src++; /* LSB */ - val += (u16)(*src++) << 8; /* MSB */ - sum += val; - } - - /* Total of uint16s in the stream plus the stored check value - * should equal STREAM_CHECKSUM when decoded. - */ - return (STREAM_CHECKSUM - sum); -} - - -#define PTDL_RESET_DATA_SIZE 20 /* Size of reset vectors PTDL */ - -static u32 calc_patch_size(const xbv1_t *fwinfo) -{ - s16 i; - u32 size = 0; - - /* - * Work out how big an equivalent patch format file must be for this image. - * This only needs to be approximate, so long as it's large enough. - */ - if (fwinfo->mode != xbv_firmware) - { - return 0; - } - - /* Payload (which will get put into a series of PTDLs) */ - for (i = 0; i < fwinfo->num_fwdl; i++) - { - size += fwinfo->fwdl[i].dl_size; - } - - /* Another PTDL at the end containing reset vectors */ - size += PTDL_RESET_DATA_SIZE; - - /* PTDL headers. Add one for remainder, one for reset vectors */ - size += ((fwinfo->num_fwdl / PTDL_MAX_SIZE) + 2) * PTDL_HDR_SIZE; - - /* Another 1K sufficient to cover miscellaneous headers */ - size += 1024; - - return size; -} - - -static u32 write_xbv_header(void *buf, const u32 offset, const u32 file_payload_length) -{ - u32 written = 0; - - /* The length value given to the XBV chunk is the length of all subsequent - * contents of the file, excluding the 8 byte size of the XBV1 header itself - * (The added 6 bytes thus accounts for the size of the VERF) - */ - written += write_chunk(buf, offset + written, (char *)"XBV1", file_payload_length + 6); - - written += write_chunk(buf, offset + written, (char *)"VERF", 2); - written += write_uint16(buf, offset + written, 0); /* File version */ - - return written; -} - - -static u32 write_ptch_header(void *buf, const u32 offset, const u32 fw_id) -{ - u32 written = 0; - - /* LIST is written with a zero length, to be updated later */ - written += write_chunk(buf, offset + written, (char *)"LIST", 0); - written += write_tag(buf, offset + written, (char *)"PTCH"); /* List type */ - - written += write_chunk(buf, offset + written, (char *)"FWID", 4); - written += write_uint32(buf, offset + written, fw_id); - - - return written; -} - - -#define UF_REGION_PHY 1 -#define UF_REGION_MAC 2 -#define UF_MEMPUT_MAC 0x0000 -#define UF_MEMPUT_PHY 0x1000 - -static u32 write_patchcmd(void *buf, const u32 offset, const u32 dst_genaddr, const u16 len) -{ - u32 written = 0; - u32 region = (dst_genaddr >> 28); - u16 cmd_and_len = UF_MEMPUT_MAC; - - if (region == UF_REGION_PHY) - { - cmd_and_len = UF_MEMPUT_PHY; - } - else if (region != UF_REGION_MAC) - { - return 0; /* invalid */ - } - - /* Write the command and data length */ - cmd_and_len |= len; - written += write_uint16(buf, offset + written, cmd_and_len); - - /* Write the destination generic address */ - written += write_uint16(buf, offset + written, (u16)(dst_genaddr >> 16)); - written += write_uint16(buf, offset + written, (u16)(dst_genaddr & 0xffff)); - - /* The data payload should be appended to the command */ - return written; -} - - -static u32 write_fwdl_to_ptdl(void *buf, const u32 offset, fwreadfn_t readfn, - const struct FWDL *fwdl, const void *dlpriv, - const u32 fw_id, void *fw_buf) -{ - u32 written = 0; - s16 chunks = 0; - u32 left = fwdl->dl_size; /* Bytes left in this fwdl */ - u32 dl_addr = fwdl->dl_addr; /* Target address of fwdl image on XAP */ - u32 dl_offs = fwdl->dl_offset; /* Offset of fwdl image data in source */ - u16 csum; - u32 csum_start_offs; /* first offset to include in checksum */ - u32 sec_data_len; /* section data byte count */ - u32 sec_len; /* section data + header byte count */ - - /* FWDL maps to one or more PTDLs, as max size for a PTDL is 1K words */ - while (left) - { - /* Calculate amount to be transferred */ - sec_data_len = min_t(u32, left, PTDL_MAX_SIZE - PTDL_HDR_SIZE); - sec_len = sec_data_len + PTDL_HDR_SIZE; - - /* Write PTDL header + entire PTDL size */ - written += write_chunk(buf, offset + written, (char *)"PTDL", sec_len); - /* bug digest implies 4 bytes of padding here, but that seems wrong */ - - /* Checksum starts here */ - csum_start_offs = offset + written; - - /* Patch-chunk header: fw_id. Note that this is in XAP word order */ - written += write_uint16(buf, offset + written, (u16)(fw_id >> 16)); - written += write_uint16(buf, offset + written, (u16)(fw_id & 0xffff)); - - /* Patch-chunk header: section length in uint16s */ - written += write_uint16(buf, offset + written, (u16)(sec_len / 2)); - - - /* Write the appropriate patch command for the data's destination ptr */ - written += write_patchcmd(buf, offset + written, dl_addr, (u16)(sec_data_len / 2)); - - /* Write the data itself (limited to the max chunk length) */ - if (readfn(NULL, (void *)dlpriv, dl_offs, fw_buf, sec_data_len) < 0) - { - return 0; - } - - written += write_bytes(buf, - offset + written, - fw_buf, - sec_data_len); - - /* u16 checksum calculated over data written */ - csum = calc_checksum(buf, csum_start_offs, written - (csum_start_offs - offset)); - written += write_uint16(buf, offset + written, csum); - - left -= sec_data_len; - dl_addr += sec_data_len; - dl_offs += sec_data_len; - chunks++; - } - - return written; -} - - -#define SEC_CMD_LEN ((4 + 2) * 2) /* sizeof(cmd, vector) per XAP */ -#define PTDL_VEC_HDR_SIZE (4 + 2 + 2) /* sizeof(fw_id, sec_len, csum) */ -#define UF_MAC_START_VEC 0x00c00000 /* Start address of image on MAC */ -#define UF_PHY_START_VEC 0x00c00000 /* Start address of image on PHY */ -#define UF_MAC_START_CMD 0x6000 /* MAC "Set start address" command */ -#define UF_PHY_START_CMD 0x7000 /* PHY "Set start address" command */ - -static u32 write_reset_ptdl(void *buf, const u32 offset, const xbv1_t *fwinfo, u32 fw_id) -{ - u32 written = 0; - u16 csum; - u32 csum_start_offs; /* first offset to include in checksum */ - u32 sec_len; /* section data + header byte count */ - - sec_len = SEC_CMD_LEN + PTDL_VEC_HDR_SIZE; /* Total section byte length */ - - /* Write PTDL header + entire PTDL size */ - written += write_chunk(buf, offset + written, (char *)"PTDL", sec_len); - - /* Checksum starts here */ - csum_start_offs = offset + written; - - /* Patch-chunk header: fw_id. Note that this is in XAP word order */ - written += write_uint16(buf, offset + written, (u16)(fw_id >> 16)); - written += write_uint16(buf, offset + written, (u16)(fw_id & 0xffff)); - - /* Patch-chunk header: section length in uint16s */ - written += write_uint16(buf, offset + written, (u16)(sec_len / 2)); - - /* - * Restart addresses to be executed on subsequent loader restart command. - */ - - /* Setup the MAC start address, note word ordering */ - written += write_uint16(buf, offset + written, UF_MAC_START_CMD); - written += write_uint16(buf, offset + written, (UF_MAC_START_VEC >> 16)); - written += write_uint16(buf, offset + written, (UF_MAC_START_VEC & 0xffff)); - - /* Setup the PHY start address, note word ordering */ - written += write_uint16(buf, offset + written, UF_PHY_START_CMD); - written += write_uint16(buf, offset + written, (UF_PHY_START_VEC >> 16)); - written += write_uint16(buf, offset + written, (UF_PHY_START_VEC & 0xffff)); - - /* u16 checksum calculated over data written */ - csum = calc_checksum(buf, csum_start_offs, written - (csum_start_offs - offset)); - written += write_uint16(buf, offset + written, csum); - - return written; -} - - -/* - * --------------------------------------------------------------------------- - * read_slut - * - * desc - * - * Arguments: - * readfn Pointer to function to call to read from the file. - * dlpriv Opaque pointer arg to pass to readfn. - * addr Offset into firmware image of SLUT. - * fwinfo Pointer to fwinfo struct to fill in. - * - * Returns: - * Number of SLUT entries in the f/w, or -1 if the image was corrupt. - * --------------------------------------------------------------------------- - */ -s32 xbv1_read_slut(card_t *card, fwreadfn_t readfn, void *dlpriv, xbv1_t *fwinfo, - symbol_t *slut, u32 slut_len) -{ - s16 i; - s32 offset; - u32 magic; - u32 count = 0; - ct_t ct; - - if (fwinfo->mode != xbv_firmware) - { - return -1; - } - - /* Find the d/l segment containing the SLUT */ - /* This relies on the SLUT being entirely contained in one segment */ - offset = -1; - for (i = 0; i < fwinfo->num_fwdl; i++) - { - if ((fwinfo->slut_addr >= fwinfo->fwdl[i].dl_addr) && - (fwinfo->slut_addr < (fwinfo->fwdl[i].dl_addr + fwinfo->fwdl[i].dl_size))) - { - offset = fwinfo->fwdl[i].dl_offset + - (fwinfo->slut_addr - fwinfo->fwdl[i].dl_addr); - } - } - if (offset < 0) - { - return -1; - } - - ct.dlpriv = dlpriv; - ct.ioffset = offset; - ct.iread = readfn; - - if (read_uint(card, &ct, &magic, 2)) - { - return -1; - } - if (magic != SLUT_FINGERPRINT) - { - return -1; - } - - while (count < slut_len) - { - u32 id, obj; - - /* Read Symbol Id */ - if (read_uint(card, &ct, &id, 2)) - { - return -1; - } - - /* Check for end of table marker */ - if (id == CSR_SLT_END) - { - break; - } - - /* Read Symbol Value */ - if (read_uint(card, &ct, &obj, 4)) - { - return -1; - } - - slut[count].id = (u16)id; - slut[count].obj = obj; - count++; - } - - return count; -} /* read_slut() */ - - -/* - * --------------------------------------------------------------------------- - * xbv_to_patch - * - * Convert (the relevant parts of) a firmware xbv file into a patch xbv - * - * Arguments: - * card - * fw_buf - pointer to xbv firmware image - * fwinfo - structure describing the firmware image - * size - pointer to location into which size of f/w is written. - * - * Returns: - * Pointer to firmware image, or NULL on error. Caller must free this - * buffer via kfree() once it's finished with. - * - * Notes: - * The input fw_buf should have been checked via xbv1_parse prior to - * calling this function, so the input image is assumed valid. - * --------------------------------------------------------------------------- - */ -#define PTCH_LIST_SIZE 16 /* sizeof PTCH+FWID chunk in LIST header */ - -void* xbv_to_patch(card_t *card, fwreadfn_t readfn, - const void *fw_buf, const xbv1_t *fwinfo, u32 *size) -{ - void *patch_buf = NULL; - u32 patch_buf_size; - u32 payload_offs = 0; /* Start of XBV payload */ - s16 i; - u32 patch_offs = 0; - u32 list_len_offs = 0; /* Offset of PTDL LIST length parameter */ - u32 ptdl_start_offs = 0; /* Offset of first PTDL chunk */ - u32 fw_id; - void *rdbuf; - - if (!fw_buf || !fwinfo || !card) - { - return NULL; - } - - if (fwinfo->mode != xbv_firmware) - { - unifi_error(NULL, "Not a firmware file\n"); - return NULL; - } - - /* Pre-allocate read buffer for chunk conversion */ - rdbuf = kmalloc(PTDL_MAX_SIZE, GFP_KERNEL); - if (!rdbuf) - { - unifi_error(card, "Couldn't alloc conversion buffer\n"); - return NULL; - } - - /* Loader requires patch file's build ID to match the running firmware's */ - fw_id = card->build_id; - - /* Firmware XBV1 contains VERF, optional INFO, SLUT(s), FWDL(s) */ - /* Other chunks should get skipped. */ - /* VERF should be sanity-checked against chip version */ - - /* Patch XBV1 contains VERF, optional INFO, PTCH */ - /* PTCH contains FWID, optional INFO, PTDL(s), PTDL(start_vec) */ - /* Each FWDL is split into PTDLs (each is 1024 XAP words max) */ - /* Each PTDL contains running ROM f/w version, and checksum */ - /* MAC/PHY reset addresses (known) are added into a final PTDL */ - - /* The input image has already been parsed, and loaded into fwinfo, so we - * can use that to build the output image - */ - patch_buf_size = calc_patch_size(fwinfo); - - patch_buf = kmalloc(patch_buf_size, GFP_KERNEL); - if (!patch_buf) - { - kfree(rdbuf); - unifi_error(NULL, "Can't malloc buffer for patch conversion\n"); - return NULL; - } - - memset(patch_buf, 0xdd, patch_buf_size); - - /* Write XBV + VERF headers */ - patch_offs += write_xbv_header(patch_buf, patch_offs, 0); - payload_offs = patch_offs; - - /* Write patch (LIST) header */ - list_len_offs = patch_offs + 4; /* Save LIST.length offset for later update */ - patch_offs += write_ptch_header(patch_buf, patch_offs, fw_id); - - /* Save start offset of the PTDL chunks */ - ptdl_start_offs = patch_offs; - - /* Write LIST of firmware PTDL blocks */ - for (i = 0; i < fwinfo->num_fwdl; i++) - { - patch_offs += write_fwdl_to_ptdl(patch_buf, - patch_offs, - readfn, - &fwinfo->fwdl[i], - fw_buf, - fw_id, - rdbuf); - } - - /* Write restart-vector PTDL last */ - patch_offs += write_reset_ptdl(patch_buf, patch_offs, fwinfo, fw_id); - - /* Now the length is known, update the LIST.length */ - (void)write_uint32(patch_buf, list_len_offs, - (patch_offs - ptdl_start_offs) + PTCH_LIST_SIZE); - - /* Re write XBV headers just to fill in the correct file size */ - (void)write_xbv_header(patch_buf, 0, (patch_offs - payload_offs)); - - unifi_trace(card->ospriv, UDBG1, "XBV:PTCH size %u, fw_id %u\n", - patch_offs, fw_id); - if (size) - { - *size = patch_offs; - } - kfree(rdbuf); - - return patch_buf; -} - - diff --git a/drivers/staging/csr/csr_wifi_hip_xbv.h b/drivers/staging/csr/csr_wifi_hip_xbv.h deleted file mode 100644 index 3c507235323d..000000000000 --- a/drivers/staging/csr/csr_wifi_hip_xbv.h +++ /dev/null @@ -1,119 +0,0 @@ -/***************************************************************************** - - (c) Cambridge Silicon Radio Limited 2011 - All rights reserved and confidential information of CSR - - Refer to LICENSE.txt included with this source for details - on the license terms. - -*****************************************************************************/ - -/* - * --------------------------------------------------------------------------- - * FILE: csr_wifi_hip_xbv.h - * - * PURPOSE: - * Definitions and declarations for code to read XBV files - the UniFi - * firmware download file format. - * - * --------------------------------------------------------------------------- - */ -#ifndef __XBV_H__ -#define __XBV_H__ - -#ifndef CSR_WIFI_XBV_TEST -/* Driver includes */ -#include "csr_wifi_hip_unifi.h" -#endif - - -struct VMEQ -{ - u32 addr; - u16 mask; - u16 value; -}; - -struct VAND -{ - u32 first; - u32 count; -}; - -struct VERS -{ - u32 num_vand; -}; - -struct FWDL -{ - u32 dl_addr; - u32 dl_size; - u32 dl_offset; -}; - -struct FWOV -{ - u32 dl_size; - u32 dl_offset; -}; - -struct PTDL -{ - u32 dl_size; - u32 dl_offset; -}; - -#define MAX_VMEQ 64 -#define MAX_VAND 64 -#define MAX_FWDL 256 -#define MAX_PTDL 256 - -/* An XBV1 file can either contain firmware or patches (at the - * moment). The 'mode' member of the xbv1_t structure tells us which - * one is the case. */ -typedef enum -{ - xbv_unknown, - xbv_firmware, - xbv_patch -} xbv_mode; - -typedef struct -{ - xbv_mode mode; - - /* Parts of a Firmware XBV1 */ - - struct VMEQ vmeq[MAX_VMEQ]; - u32 num_vmeq; - struct VAND vand[MAX_VAND]; - struct VERS vers; - - u32 slut_addr; - - /* F/W download image, possibly more than one part */ - struct FWDL fwdl[MAX_FWDL]; - s16 num_fwdl; - - /* F/W overlay image, add r not used */ - struct FWOV fwov; - - /* Parts of a Patch XBV1 */ - - u32 build_id; - - struct PTDL ptdl[MAX_PTDL]; - s16 num_ptdl; -} xbv1_t; - - -typedef s32 (*fwreadfn_t)(void *ospriv, void *dlpriv, u32 offset, void *buf, u32 len); - -CsrResult xbv1_parse(card_t *card, fwreadfn_t readfn, void *dlpriv, xbv1_t *fwinfo); -s32 xbv1_read_slut(card_t *card, fwreadfn_t readfn, void *dlpriv, xbv1_t *fwinfo, - symbol_t *slut, u32 slut_len); -void* xbv_to_patch(card_t *card, fwreadfn_t readfn, const void *fw_buf, const xbv1_t *fwinfo, - u32 *size); - -#endif /* __XBV_H__ */ diff --git a/drivers/staging/csr/csr_wifi_hostio_prim.h b/drivers/staging/csr/csr_wifi_hostio_prim.h deleted file mode 100644 index cfb3e272e359..000000000000 --- a/drivers/staging/csr/csr_wifi_hostio_prim.h +++ /dev/null @@ -1,18 +0,0 @@ -/***************************************************************************** - - (c) Cambridge Silicon Radio Limited 2011 - All rights reserved and confidential information of CSR - - Refer to LICENSE.txt included with this source for details - on the license terms. - -*****************************************************************************/ - - -#ifndef CSR_WIFI_HOSTIO_H -#define CSR_WIFI_HOSTIO_H - -#define CSR_WIFI_HOSTIO_PRIM 0x0453 - -#endif /* CSR_WIFI_HOSTIO_H */ - diff --git a/drivers/staging/csr/csr_wifi_lib.h b/drivers/staging/csr/csr_wifi_lib.h deleted file mode 100644 index 5fde0efb5dca..000000000000 --- a/drivers/staging/csr/csr_wifi_lib.h +++ /dev/null @@ -1,103 +0,0 @@ -/***************************************************************************** - - (c) Cambridge Silicon Radio Limited 2011 - All rights reserved and confidential information of CSR - - Refer to LICENSE.txt included with this source for details - on the license terms. - -*****************************************************************************/ -#ifndef CSR_WIFI_LIB_H__ -#define CSR_WIFI_LIB_H__ - -#include "csr_wifi_fsm_event.h" - -/*----------------------------------------------------------------------------* - * CsrWifiFsmEventInit - * - * DESCRIPTION - * Macro to initialise the members of a CsrWifiFsmEvent. - *----------------------------------------------------------------------------*/ -#define CsrWifiFsmEventInit(evt, p_primtype, p_msgtype, p_dst, p_src) \ - (evt)->primtype = p_primtype; \ - (evt)->type = p_msgtype; \ - (evt)->destination = p_dst; \ - (evt)->source = p_src - - -/*----------------------------------------------------------------------------* - * CsrWifiEvent_struct - * - * DESCRIPTION - * Generic message creator. - * Allocates and fills in a message with the signature CsrWifiEvent - * - *----------------------------------------------------------------------------*/ -CsrWifiFsmEvent* CsrWifiEvent_struct(u16 primtype, u16 msgtype, CsrSchedQid dst, CsrSchedQid src); - -typedef struct -{ - CsrWifiFsmEvent common; - u8 value; -} CsrWifiEventCsrUint8; - -/*----------------------------------------------------------------------------* - * CsrWifiEventCsrUint8_struct - * - * DESCRIPTION - * Generic message creator. - * Allocates and fills in a message with the signature CsrWifiEventCsrUint8 - * - *----------------------------------------------------------------------------*/ -CsrWifiEventCsrUint8* CsrWifiEventCsrUint8_struct(u16 primtype, u16 msgtype, CsrSchedQid dst, CsrSchedQid src, u8 value); - -typedef struct -{ - CsrWifiFsmEvent common; - u16 value; -} CsrWifiEventCsrUint16; - -/*----------------------------------------------------------------------------* - * CsrWifiEventCsrUint16_struct - * - * DESCRIPTION - * Generic message creator. - * Allocates and fills in a message with the signature CsrWifiEventCsrUint16 - * - *----------------------------------------------------------------------------*/ -CsrWifiEventCsrUint16* CsrWifiEventCsrUint16_struct(u16 primtype, u16 msgtype, CsrSchedQid dst, CsrSchedQid src, u16 value); - -typedef struct -{ - CsrWifiFsmEvent common; - u32 value; -} CsrWifiEventCsrUint32; - -/*----------------------------------------------------------------------------* - * CsrWifiEventCsrUint32_struct - * - * DESCRIPTION - * Generic message creator. - * Allocates and fills in a message with the signature CsrWifiEventCsrUint32 - * - *----------------------------------------------------------------------------*/ -CsrWifiEventCsrUint32* CsrWifiEventCsrUint32_struct(u16 primtype, u16 msgtype, CsrSchedQid dst, CsrSchedQid src, u32 value); - -typedef struct -{ - CsrWifiFsmEvent common; - u16 value16; - u8 value8; -} CsrWifiEventCsrUint16CsrUint8; - -/*----------------------------------------------------------------------------* - * CsrWifiEventCsrUint16CsrUint8_struct - * - * DESCRIPTION - * Generic message creator. - * Allocates and fills in a message with the signature CsrWifiEventCsrUint16CsrUint8 - * - *----------------------------------------------------------------------------*/ -CsrWifiEventCsrUint16CsrUint8* CsrWifiEventCsrUint16CsrUint8_struct(u16 primtype, u16 msgtype, CsrSchedQid dst, CsrSchedQid src, u16 value16, u8 value8); - -#endif /* CSR_WIFI_LIB_H__ */ diff --git a/drivers/staging/csr/csr_wifi_msgconv.h b/drivers/staging/csr/csr_wifi_msgconv.h deleted file mode 100644 index f8b402947a09..000000000000 --- a/drivers/staging/csr/csr_wifi_msgconv.h +++ /dev/null @@ -1,49 +0,0 @@ -/***************************************************************************** - - (c) Cambridge Silicon Radio Limited 2011 - All rights reserved and confidential information of CSR - - Refer to LICENSE.txt included with this source for details - on the license terms. - -*****************************************************************************/ - -#ifndef CSR_WIFI_MSGCONV_H__ -#define CSR_WIFI_MSGCONV_H__ - -#include "csr_prim_defs.h" -#include "csr_sched.h" - -void CsrUint16SerBigEndian(u8 *ptr, size_t *len, u16 v); -void CsrUint24SerBigEndian(u8 *ptr, size_t *len, u32 v); -void CsrUint32SerBigEndian(u8 *ptr, size_t *len, u32 v); - -void CsrUint16DesBigEndian(u16 *v, u8 *buffer, size_t *offset); -void CsrUint24DesBigEndian(u32 *v, u8 *buffer, size_t *offset); -void CsrUint32DesBigEndian(u32 *v, u8 *buffer, size_t *offset); - -void CsrUint24Ser(u8 *ptr, size_t *len, u32 v); -void CsrUint24Des(u32 *v, u8 *buffer, size_t *offset); - - -size_t CsrWifiEventSizeof(void *msg); -u8* CsrWifiEventSer(u8 *ptr, size_t *len, void *msg); -void* CsrWifiEventDes(u8 *buffer, size_t length); - -size_t CsrWifiEventCsrUint8Sizeof(void *msg); -u8* CsrWifiEventCsrUint8Ser(u8 *ptr, size_t *len, void *msg); -void* CsrWifiEventCsrUint8Des(u8 *buffer, size_t length); - -size_t CsrWifiEventCsrUint16Sizeof(void *msg); -u8* CsrWifiEventCsrUint16Ser(u8 *ptr, size_t *len, void *msg); -void* CsrWifiEventCsrUint16Des(u8 *buffer, size_t length); - -size_t CsrWifiEventCsrUint32Sizeof(void *msg); -u8* CsrWifiEventCsrUint32Ser(u8 *ptr, size_t *len, void *msg); -void* CsrWifiEventCsrUint32Des(u8 *buffer, size_t length); - -size_t CsrWifiEventCsrUint16CsrUint8Sizeof(void *msg); -u8* CsrWifiEventCsrUint16CsrUint8Ser(u8 *ptr, size_t *len, void *msg); -void* CsrWifiEventCsrUint16CsrUint8Des(u8 *buffer, size_t length); - -#endif /* CSR_WIFI_MSGCONV_H__ */ diff --git a/drivers/staging/csr/csr_wifi_nme_ap_converter_init.c b/drivers/staging/csr/csr_wifi_nme_ap_converter_init.c deleted file mode 100644 index 0689d6f1cab1..000000000000 --- a/drivers/staging/csr/csr_wifi_nme_ap_converter_init.c +++ /dev/null @@ -1,90 +0,0 @@ -/***************************************************************************** - - (c) Cambridge Silicon Radio Limited 2012 - All rights reserved and confidential information of CSR - - Refer to LICENSE.txt included with this source for details - on the license terms. - -*****************************************************************************/ - -/* Note: this is an auto-generated file. */ - -#include "csr_msgconv.h" -#include "csr_macro.h" - -#ifdef CSR_WIFI_NME_ENABLE -#ifdef CSR_WIFI_AP_ENABLE - -#ifdef CSR_LOG_ENABLE -#include "csr_log.h" -#endif - -#ifndef EXCLUDE_CSR_WIFI_NME_AP_MODULE -#include "csr_wifi_nme_ap_serialize.h" -#include "csr_wifi_nme_ap_prim.h" - -static CsrMsgConvMsgEntry csrwifinmeap_conv_lut[] = { - { CSR_WIFI_NME_AP_CONFIG_SET_REQ, CsrWifiNmeApConfigSetReqSizeof, CsrWifiNmeApConfigSetReqSer, CsrWifiNmeApConfigSetReqDes, CsrWifiNmeApConfigSetReqSerFree }, - { CSR_WIFI_NME_AP_WPS_REGISTER_REQ, CsrWifiNmeApWpsRegisterReqSizeof, CsrWifiNmeApWpsRegisterReqSer, CsrWifiNmeApWpsRegisterReqDes, CsrWifiNmeApWpsRegisterReqSerFree }, - { CSR_WIFI_NME_AP_START_REQ, CsrWifiNmeApStartReqSizeof, CsrWifiNmeApStartReqSer, CsrWifiNmeApStartReqDes, CsrWifiNmeApStartReqSerFree }, - { CSR_WIFI_NME_AP_STOP_REQ, CsrWifiNmeApStopReqSizeof, CsrWifiNmeApStopReqSer, CsrWifiNmeApStopReqDes, CsrWifiNmeApStopReqSerFree }, - { CSR_WIFI_NME_AP_WMM_PARAM_UPDATE_REQ, CsrWifiNmeApWmmParamUpdateReqSizeof, CsrWifiNmeApWmmParamUpdateReqSer, CsrWifiNmeApWmmParamUpdateReqDes, CsrWifiNmeApWmmParamUpdateReqSerFree }, - { CSR_WIFI_NME_AP_STA_REMOVE_REQ, CsrWifiNmeApStaRemoveReqSizeof, CsrWifiNmeApStaRemoveReqSer, CsrWifiNmeApStaRemoveReqDes, CsrWifiNmeApStaRemoveReqSerFree }, - { CSR_WIFI_NME_AP_CONFIG_SET_CFM, CsrWifiNmeApConfigSetCfmSizeof, CsrWifiNmeApConfigSetCfmSer, CsrWifiNmeApConfigSetCfmDes, CsrWifiNmeApConfigSetCfmSerFree }, - { CSR_WIFI_NME_AP_WPS_REGISTER_CFM, CsrWifiNmeApWpsRegisterCfmSizeof, CsrWifiNmeApWpsRegisterCfmSer, CsrWifiNmeApWpsRegisterCfmDes, CsrWifiNmeApWpsRegisterCfmSerFree }, - { CSR_WIFI_NME_AP_START_CFM, CsrWifiNmeApStartCfmSizeof, CsrWifiNmeApStartCfmSer, CsrWifiNmeApStartCfmDes, CsrWifiNmeApStartCfmSerFree }, - { CSR_WIFI_NME_AP_STOP_CFM, CsrWifiNmeApStopCfmSizeof, CsrWifiNmeApStopCfmSer, CsrWifiNmeApStopCfmDes, CsrWifiNmeApStopCfmSerFree }, - { CSR_WIFI_NME_AP_STOP_IND, CsrWifiNmeApStopIndSizeof, CsrWifiNmeApStopIndSer, CsrWifiNmeApStopIndDes, CsrWifiNmeApStopIndSerFree }, - { CSR_WIFI_NME_AP_WMM_PARAM_UPDATE_CFM, CsrWifiNmeApWmmParamUpdateCfmSizeof, CsrWifiNmeApWmmParamUpdateCfmSer, CsrWifiNmeApWmmParamUpdateCfmDes, CsrWifiNmeApWmmParamUpdateCfmSerFree }, - { CSR_WIFI_NME_AP_STATION_IND, CsrWifiNmeApStationIndSizeof, CsrWifiNmeApStationIndSer, CsrWifiNmeApStationIndDes, CsrWifiNmeApStationIndSerFree }, - - { 0, NULL, NULL, NULL, NULL }, -}; - -CsrMsgConvMsgEntry* CsrWifiNmeApConverterLookup(CsrMsgConvMsgEntry *ce, u16 msgType) -{ - if (msgType & CSR_PRIM_UPSTREAM) - { - u16 idx = (msgType & ~CSR_PRIM_UPSTREAM) + CSR_WIFI_NME_AP_PRIM_DOWNSTREAM_COUNT; - if (idx < (CSR_WIFI_NME_AP_PRIM_UPSTREAM_COUNT + CSR_WIFI_NME_AP_PRIM_DOWNSTREAM_COUNT) && - csrwifinmeap_conv_lut[idx].msgType == msgType) - { - return &csrwifinmeap_conv_lut[idx]; - } - } - else - { - if (msgType < CSR_WIFI_NME_AP_PRIM_DOWNSTREAM_COUNT && - csrwifinmeap_conv_lut[msgType].msgType == msgType) - { - return &csrwifinmeap_conv_lut[msgType]; - } - } - return NULL; -} - - -void CsrWifiNmeApConverterInit(void) -{ - CsrMsgConvInsert(CSR_WIFI_NME_AP_PRIM, csrwifinmeap_conv_lut); - CsrMsgConvCustomLookupRegister(CSR_WIFI_NME_AP_PRIM, CsrWifiNmeApConverterLookup); -} - - -#ifdef CSR_LOG_ENABLE -static const CsrLogPrimitiveInformation csrwifinmeap_conv_info = { - CSR_WIFI_NME_AP_PRIM, - (char *)"CSR_WIFI_NME_AP_PRIM", - csrwifinmeap_conv_lut -}; -const CsrLogPrimitiveInformation* CsrWifiNmeApTechInfoGet(void) -{ - return &csrwifinmeap_conv_info; -} - - -#endif /* CSR_LOG_ENABLE */ -#endif /* EXCLUDE_CSR_WIFI_NME_AP_MODULE */ -#endif /* CSR_WIFI_NME_ENABLE */ -#endif /* CSR_WIFI_AP_ENABLE */ diff --git a/drivers/staging/csr/csr_wifi_nme_ap_converter_init.h b/drivers/staging/csr/csr_wifi_nme_ap_converter_init.h deleted file mode 100644 index b89d7c7f8e21..000000000000 --- a/drivers/staging/csr/csr_wifi_nme_ap_converter_init.h +++ /dev/null @@ -1,41 +0,0 @@ -/***************************************************************************** - - (c) Cambridge Silicon Radio Limited 2011 - All rights reserved and confidential information of CSR - - Refer to LICENSE.txt included with this source for details - on the license terms. - -*****************************************************************************/ - -/* Note: this is an auto-generated file. */ - -#ifndef CSR_WIFI_NME_AP_CONVERTER_INIT_H__ -#define CSR_WIFI_NME_AP_CONVERTER_INIT_H__ - -#ifndef CSR_WIFI_NME_ENABLE -#error CSR_WIFI_NME_ENABLE MUST be defined inorder to use csr_wifi_nme_ap_converter_init.h -#endif -#ifndef CSR_WIFI_AP_ENABLE -#error CSR_WIFI_AP_ENABLE MUST be defined inorder to use csr_wifi_nme_ap_converter_init.h -#endif - -#ifndef EXCLUDE_CSR_WIFI_NME_AP_MODULE - -#include "csr_msgconv.h" - -#ifdef CSR_LOG_ENABLE -#include "csr_log.h" - -extern const CsrLogPrimitiveInformation* CsrWifiNmeApTechInfoGet(void); -#endif /* CSR_LOG_ENABLE */ - -extern void CsrWifiNmeApConverterInit(void); - -#else /* EXCLUDE_CSR_WIFI_NME_AP_MODULE */ - -#define CsrWifiNmeApConverterInit() - -#endif /* EXCLUDE_CSR_WIFI_NME_AP_MODULE */ - -#endif /* CSR_WIFI_NME_AP_CONVERTER_INIT_H__ */ diff --git a/drivers/staging/csr/csr_wifi_nme_ap_free_downstream_contents.c b/drivers/staging/csr/csr_wifi_nme_ap_free_downstream_contents.c deleted file mode 100644 index ab9358873ec3..000000000000 --- a/drivers/staging/csr/csr_wifi_nme_ap_free_downstream_contents.c +++ /dev/null @@ -1,84 +0,0 @@ -/***************************************************************************** - - (c) Cambridge Silicon Radio Limited 2012 - All rights reserved and confidential information of CSR - - Refer to LICENSE.txt included with this source for details - on the license terms. - -*****************************************************************************/ - -/* Note: this is an auto-generated file. */ -#include -#include "csr_wifi_nme_ap_prim.h" -#include "csr_wifi_nme_ap_lib.h" - -/*----------------------------------------------------------------------------* - * NAME - * CsrWifiNmeApFreeDownstreamMessageContents - * - * DESCRIPTION - * - * - * PARAMETERS - * eventClass: only the value CSR_WIFI_NME_AP_PRIM will be handled - * message: the message to free - *----------------------------------------------------------------------------*/ -void CsrWifiNmeApFreeDownstreamMessageContents(u16 eventClass, void *message) -{ - if (eventClass != CSR_WIFI_NME_AP_PRIM) - { - return; - } - if (NULL == message) - { - return; - } - - switch (*((CsrWifiNmeApPrim *) message)) - { - case CSR_WIFI_NME_AP_CONFIG_SET_REQ: - { - CsrWifiNmeApConfigSetReq *p = (CsrWifiNmeApConfigSetReq *)message; - kfree(p->apMacConfig.macAddressList); - p->apMacConfig.macAddressList = NULL; - break; - } - case CSR_WIFI_NME_AP_START_REQ: - { - CsrWifiNmeApStartReq *p = (CsrWifiNmeApStartReq *)message; - switch (p->apCredentials.authType) - { - case CSR_WIFI_SME_AP_AUTH_TYPE_PERSONAL: - switch (p->apCredentials.nmeAuthType.authTypePersonal.pskOrPassphrase) - { - case CSR_WIFI_NME_AP_CREDENTIAL_TYPE_PASSPHRASE: - kfree(p->apCredentials.nmeAuthType.authTypePersonal.authPers_credentials.passphrase.passphrase); - p->apCredentials.nmeAuthType.authTypePersonal.authPers_credentials.passphrase.passphrase = NULL; - break; - default: - break; - } - break; - default: - break; - } - { - u16 i3; - for (i3 = 0; i3 < p->p2pGoParam.operatingChanList.channelEntryListCount; i3++) - { - kfree(p->p2pGoParam.operatingChanList.channelEntryList[i3].operatingChannel); - p->p2pGoParam.operatingChanList.channelEntryList[i3].operatingChannel = NULL; - } - } - kfree(p->p2pGoParam.operatingChanList.channelEntryList); - p->p2pGoParam.operatingChanList.channelEntryList = NULL; - break; - } - - default: - break; - } -} - - diff --git a/drivers/staging/csr/csr_wifi_nme_ap_free_upstream_contents.c b/drivers/staging/csr/csr_wifi_nme_ap_free_upstream_contents.c deleted file mode 100644 index 2786a6bbff97..000000000000 --- a/drivers/staging/csr/csr_wifi_nme_ap_free_upstream_contents.c +++ /dev/null @@ -1,39 +0,0 @@ -/***************************************************************************** - - (c) Cambridge Silicon Radio Limited 2012 - All rights reserved and confidential information of CSR - - Refer to LICENSE.txt included with this source for details - on the license terms. - -*****************************************************************************/ - -/* Note: this is an auto-generated file. */ - -#include "csr_wifi_nme_ap_prim.h" -#include "csr_wifi_nme_ap_lib.h" - -/*----------------------------------------------------------------------------* - * NAME - * CsrWifiNmeApFreeUpstreamMessageContents - * - * DESCRIPTION - * - * - * PARAMETERS - * eventClass: only the value CSR_WIFI_NME_AP_PRIM will be handled - * message: the message to free - *----------------------------------------------------------------------------*/ -void CsrWifiNmeApFreeUpstreamMessageContents(u16 eventClass, void *message) -{ - if (eventClass != CSR_WIFI_NME_AP_PRIM) - { - return; - } - if (NULL == message) - { - return; - } -} - - diff --git a/drivers/staging/csr/csr_wifi_nme_ap_lib.h b/drivers/staging/csr/csr_wifi_nme_ap_lib.h deleted file mode 100644 index 6d8df8366817..000000000000 --- a/drivers/staging/csr/csr_wifi_nme_ap_lib.h +++ /dev/null @@ -1,495 +0,0 @@ -/***************************************************************************** - - (c) Cambridge Silicon Radio Limited 2012 - All rights reserved and confidential information of CSR - - Refer to LICENSE.txt included with this source for details - on the license terms. - -*****************************************************************************/ - -/* Note: this is an auto-generated file. */ - -#ifndef CSR_WIFI_NME_AP_LIB_H__ -#define CSR_WIFI_NME_AP_LIB_H__ - -#include "csr_sched.h" -#include "csr_macro.h" -#include "csr_msg_transport.h" - -#include "csr_wifi_lib.h" - -#include "csr_wifi_nme_ap_prim.h" -#include "csr_wifi_nme_task.h" - -#ifndef CSR_WIFI_NME_ENABLE -#error CSR_WIFI_NME_ENABLE MUST be defined inorder to use csr_wifi_nme_ap_lib.h -#endif -#ifndef CSR_WIFI_AP_ENABLE -#error CSR_WIFI_AP_ENABLE MUST be defined inorder to use csr_wifi_nme_ap_lib.h -#endif - -/*----------------------------------------------------------------------------* - * CsrWifiNmeApFreeUpstreamMessageContents - * - * DESCRIPTION - * Free the allocated memory in a CSR_WIFI_NME_AP upstream message. Does not - * free the message itself, and can only be used for upstream messages. - * - * PARAMETERS - * Deallocates the resources in a CSR_WIFI_NME_AP upstream message - *----------------------------------------------------------------------------*/ -void CsrWifiNmeApFreeUpstreamMessageContents(u16 eventClass, void *message); - -/*----------------------------------------------------------------------------* - * CsrWifiNmeApFreeDownstreamMessageContents - * - * DESCRIPTION - * Free the allocated memory in a CSR_WIFI_NME_AP downstream message. Does not - * free the message itself, and can only be used for downstream messages. - * - * PARAMETERS - * Deallocates the resources in a CSR_WIFI_NME_AP downstream message - *----------------------------------------------------------------------------*/ -void CsrWifiNmeApFreeDownstreamMessageContents(u16 eventClass, void *message); - -/******************************************************************************* - - NAME - CsrWifiNmeApConfigSetReqSend - - DESCRIPTION - This primitive passes AP configuration info for NME. This can be sent at - any time but will be acted upon when the AP is started again. This - information is common to both P2P GO and AP - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - apConfig - AP configuration for the NME. - apMacConfig - MAC configuration to be acted on when - CSR_WIFI_NME_AP_START.request is sent. - -*******************************************************************************/ -#define CsrWifiNmeApConfigSetReqCreate(msg__, dst__, src__, apConfig__, apMacConfig__) \ - msg__ = kmalloc(sizeof(CsrWifiNmeApConfigSetReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_AP_PRIM, CSR_WIFI_NME_AP_CONFIG_SET_REQ, dst__, src__); \ - msg__->apConfig = (apConfig__); \ - msg__->apMacConfig = (apMacConfig__); - -#define CsrWifiNmeApConfigSetReqSendTo(dst__, src__, apConfig__, apMacConfig__) \ - { \ - CsrWifiNmeApConfigSetReq *msg__; \ - CsrWifiNmeApConfigSetReqCreate(msg__, dst__, src__, apConfig__, apMacConfig__); \ - CsrMsgTransport(dst__, CSR_WIFI_NME_AP_PRIM, msg__); \ - } - -#define CsrWifiNmeApConfigSetReqSend(src__, apConfig__, apMacConfig__) \ - CsrWifiNmeApConfigSetReqSendTo(CSR_WIFI_NME_IFACEQUEUE, src__, apConfig__, apMacConfig__) - -/******************************************************************************* - - NAME - CsrWifiNmeApConfigSetCfmSend - - DESCRIPTION - This primitive reports the result of the request. - - PARAMETERS - queue - Destination Task Queue - status - Status of the request. - -*******************************************************************************/ -#define CsrWifiNmeApConfigSetCfmCreate(msg__, dst__, src__, status__) \ - msg__ = kmalloc(sizeof(CsrWifiNmeApConfigSetCfm), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_AP_PRIM, CSR_WIFI_NME_AP_CONFIG_SET_CFM, dst__, src__); \ - msg__->status = (status__); - -#define CsrWifiNmeApConfigSetCfmSendTo(dst__, src__, status__) \ - { \ - CsrWifiNmeApConfigSetCfm *msg__; \ - CsrWifiNmeApConfigSetCfmCreate(msg__, dst__, src__, status__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_NME_AP_PRIM, msg__); \ - } - -#define CsrWifiNmeApConfigSetCfmSend(dst__, status__) \ - CsrWifiNmeApConfigSetCfmSendTo(dst__, CSR_WIFI_NME_IFACEQUEUE, status__) - -/******************************************************************************* - - NAME - CsrWifiNmeApStaRemoveReqSend - - DESCRIPTION - This primitive disconnects a connected station. If keepBlocking is set to - TRUE, the station with the specified MAC address is not allowed to - connect. If the requested station is not already connected,it may be - blocked based on keepBlocking parameter. - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - interfaceTag - Interface Identifier; unique identifier of an interface - staMacAddress - Mac Address of the station to be disconnected or blocked - keepBlocking - If TRUE, the station is blocked. If FALSE and the station is - connected, disconnect the station. If FALSE and the station - is not connected, no action is taken. - -*******************************************************************************/ -#define CsrWifiNmeApStaRemoveReqCreate(msg__, dst__, src__, interfaceTag__, staMacAddress__, keepBlocking__) \ - msg__ = kmalloc(sizeof(CsrWifiNmeApStaRemoveReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_AP_PRIM, CSR_WIFI_NME_AP_STA_REMOVE_REQ, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->staMacAddress = (staMacAddress__); \ - msg__->keepBlocking = (keepBlocking__); - -#define CsrWifiNmeApStaRemoveReqSendTo(dst__, src__, interfaceTag__, staMacAddress__, keepBlocking__) \ - { \ - CsrWifiNmeApStaRemoveReq *msg__; \ - CsrWifiNmeApStaRemoveReqCreate(msg__, dst__, src__, interfaceTag__, staMacAddress__, keepBlocking__); \ - CsrMsgTransport(dst__, CSR_WIFI_NME_AP_PRIM, msg__); \ - } - -#define CsrWifiNmeApStaRemoveReqSend(src__, interfaceTag__, staMacAddress__, keepBlocking__) \ - CsrWifiNmeApStaRemoveReqSendTo(CSR_WIFI_NME_IFACEQUEUE, src__, interfaceTag__, staMacAddress__, keepBlocking__) - -/******************************************************************************* - - NAME - CsrWifiNmeApStartReqSend - - DESCRIPTION - This primitive requests NME to started the AP operation. - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - interfaceTag - Interface identifier; unique identifier of an interface - apType - AP Type specifies the Legacy AP or P2P GO operation - cloakSsid - Indicates whether the SSID should be cloaked (hidden and - not broadcast in beacon) or not - ssid - Service Set Identifier - ifIndex - Radio interface - channel - Channel number of the channel to use - apCredentials - Security credential configuration. - maxConnections - Maximum number of stations/P2P clients allowed - p2pGoParam - P2P specific GO parameters. - wpsEnabled - Indicates whether WPS should be enabled or not - -*******************************************************************************/ -#define CsrWifiNmeApStartReqCreate(msg__, dst__, src__, interfaceTag__, apType__, cloakSsid__, ssid__, ifIndex__, channel__, apCredentials__, maxConnections__, p2pGoParam__, wpsEnabled__) \ - msg__ = kmalloc(sizeof(CsrWifiNmeApStartReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_AP_PRIM, CSR_WIFI_NME_AP_START_REQ, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->apType = (apType__); \ - msg__->cloakSsid = (cloakSsid__); \ - msg__->ssid = (ssid__); \ - msg__->ifIndex = (ifIndex__); \ - msg__->channel = (channel__); \ - msg__->apCredentials = (apCredentials__); \ - msg__->maxConnections = (maxConnections__); \ - msg__->p2pGoParam = (p2pGoParam__); \ - msg__->wpsEnabled = (wpsEnabled__); - -#define CsrWifiNmeApStartReqSendTo(dst__, src__, interfaceTag__, apType__, cloakSsid__, ssid__, ifIndex__, channel__, apCredentials__, maxConnections__, p2pGoParam__, wpsEnabled__) \ - { \ - CsrWifiNmeApStartReq *msg__; \ - CsrWifiNmeApStartReqCreate(msg__, dst__, src__, interfaceTag__, apType__, cloakSsid__, ssid__, ifIndex__, channel__, apCredentials__, maxConnections__, p2pGoParam__, wpsEnabled__); \ - CsrMsgTransport(dst__, CSR_WIFI_NME_AP_PRIM, msg__); \ - } - -#define CsrWifiNmeApStartReqSend(src__, interfaceTag__, apType__, cloakSsid__, ssid__, ifIndex__, channel__, apCredentials__, maxConnections__, p2pGoParam__, wpsEnabled__) \ - CsrWifiNmeApStartReqSendTo(CSR_WIFI_NME_IFACEQUEUE, src__, interfaceTag__, apType__, cloakSsid__, ssid__, ifIndex__, channel__, apCredentials__, maxConnections__, p2pGoParam__, wpsEnabled__) - -/******************************************************************************* - - NAME - CsrWifiNmeApStartCfmSend - - DESCRIPTION - This primitive reports the result of CSR_WIFI_NME_AP_START.request. - - PARAMETERS - queue - Destination Task Queue - interfaceTag - Interface identifier; unique identifier of an interface - status - Status of the request. - ssid - Service Set Identifier - -*******************************************************************************/ -#define CsrWifiNmeApStartCfmCreate(msg__, dst__, src__, interfaceTag__, status__, ssid__) \ - msg__ = kmalloc(sizeof(CsrWifiNmeApStartCfm), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_AP_PRIM, CSR_WIFI_NME_AP_START_CFM, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->status = (status__); \ - msg__->ssid = (ssid__); - -#define CsrWifiNmeApStartCfmSendTo(dst__, src__, interfaceTag__, status__, ssid__) \ - { \ - CsrWifiNmeApStartCfm *msg__; \ - CsrWifiNmeApStartCfmCreate(msg__, dst__, src__, interfaceTag__, status__, ssid__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_NME_AP_PRIM, msg__); \ - } - -#define CsrWifiNmeApStartCfmSend(dst__, interfaceTag__, status__, ssid__) \ - CsrWifiNmeApStartCfmSendTo(dst__, CSR_WIFI_NME_IFACEQUEUE, interfaceTag__, status__, ssid__) - -/******************************************************************************* - - NAME - CsrWifiNmeApStationIndSend - - DESCRIPTION - This primitive indicates that a station has joined or a previously joined - station has left the BSS/group - - PARAMETERS - queue - Destination Task Queue - interfaceTag - Interface Identifier; unique identifier of an interface - mediaStatus - Indicates whether the station is connected or - disconnected - peerMacAddress - MAC address of the station - peerDeviceAddress - P2P Device Address - -*******************************************************************************/ -#define CsrWifiNmeApStationIndCreate(msg__, dst__, src__, interfaceTag__, mediaStatus__, peerMacAddress__, peerDeviceAddress__) \ - msg__ = kmalloc(sizeof(CsrWifiNmeApStationInd), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_AP_PRIM, CSR_WIFI_NME_AP_STATION_IND, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->mediaStatus = (mediaStatus__); \ - msg__->peerMacAddress = (peerMacAddress__); \ - msg__->peerDeviceAddress = (peerDeviceAddress__); - -#define CsrWifiNmeApStationIndSendTo(dst__, src__, interfaceTag__, mediaStatus__, peerMacAddress__, peerDeviceAddress__) \ - { \ - CsrWifiNmeApStationInd *msg__; \ - CsrWifiNmeApStationIndCreate(msg__, dst__, src__, interfaceTag__, mediaStatus__, peerMacAddress__, peerDeviceAddress__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_NME_AP_PRIM, msg__); \ - } - -#define CsrWifiNmeApStationIndSend(dst__, interfaceTag__, mediaStatus__, peerMacAddress__, peerDeviceAddress__) \ - CsrWifiNmeApStationIndSendTo(dst__, CSR_WIFI_NME_IFACEQUEUE, interfaceTag__, mediaStatus__, peerMacAddress__, peerDeviceAddress__) - -/******************************************************************************* - - NAME - CsrWifiNmeApStopReqSend - - DESCRIPTION - This primitive requests NME to stop the AP operation. - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - interfaceTag - Interface identifier; unique identifier of an interface - -*******************************************************************************/ -#define CsrWifiNmeApStopReqCreate(msg__, dst__, src__, interfaceTag__) \ - msg__ = kmalloc(sizeof(CsrWifiNmeApStopReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_AP_PRIM, CSR_WIFI_NME_AP_STOP_REQ, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); - -#define CsrWifiNmeApStopReqSendTo(dst__, src__, interfaceTag__) \ - { \ - CsrWifiNmeApStopReq *msg__; \ - CsrWifiNmeApStopReqCreate(msg__, dst__, src__, interfaceTag__); \ - CsrMsgTransport(dst__, CSR_WIFI_NME_AP_PRIM, msg__); \ - } - -#define CsrWifiNmeApStopReqSend(src__, interfaceTag__) \ - CsrWifiNmeApStopReqSendTo(CSR_WIFI_NME_IFACEQUEUE, src__, interfaceTag__) - -/******************************************************************************* - - NAME - CsrWifiNmeApStopIndSend - - DESCRIPTION - Indicates that AP operation had stopped because of some unrecoverable - error after AP operation was started successfully. NME sends this signal - after failing to restart the AP operation internally following an error - - PARAMETERS - queue - Destination Task Queue - interfaceTag - Interface Identifier; unique identifier of an interface - apType - Reports AP Type (P2PGO or AP) - status - Error Status - -*******************************************************************************/ -#define CsrWifiNmeApStopIndCreate(msg__, dst__, src__, interfaceTag__, apType__, status__) \ - msg__ = kmalloc(sizeof(CsrWifiNmeApStopInd), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_AP_PRIM, CSR_WIFI_NME_AP_STOP_IND, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->apType = (apType__); \ - msg__->status = (status__); - -#define CsrWifiNmeApStopIndSendTo(dst__, src__, interfaceTag__, apType__, status__) \ - { \ - CsrWifiNmeApStopInd *msg__; \ - CsrWifiNmeApStopIndCreate(msg__, dst__, src__, interfaceTag__, apType__, status__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_NME_AP_PRIM, msg__); \ - } - -#define CsrWifiNmeApStopIndSend(dst__, interfaceTag__, apType__, status__) \ - CsrWifiNmeApStopIndSendTo(dst__, CSR_WIFI_NME_IFACEQUEUE, interfaceTag__, apType__, status__) - -/******************************************************************************* - - NAME - CsrWifiNmeApStopCfmSend - - DESCRIPTION - This primitive confirms that the AP operation is stopped. NME shall send - this primitive in response to the request even if AP operation has - already been stopped - - PARAMETERS - queue - Destination Task Queue - interfaceTag - Interface identifier; unique identifier of an interface - status - Status of the request. - -*******************************************************************************/ -#define CsrWifiNmeApStopCfmCreate(msg__, dst__, src__, interfaceTag__, status__) \ - msg__ = kmalloc(sizeof(CsrWifiNmeApStopCfm), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_AP_PRIM, CSR_WIFI_NME_AP_STOP_CFM, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->status = (status__); - -#define CsrWifiNmeApStopCfmSendTo(dst__, src__, interfaceTag__, status__) \ - { \ - CsrWifiNmeApStopCfm *msg__; \ - CsrWifiNmeApStopCfmCreate(msg__, dst__, src__, interfaceTag__, status__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_NME_AP_PRIM, msg__); \ - } - -#define CsrWifiNmeApStopCfmSend(dst__, interfaceTag__, status__) \ - CsrWifiNmeApStopCfmSendTo(dst__, CSR_WIFI_NME_IFACEQUEUE, interfaceTag__, status__) - -/******************************************************************************* - - NAME - CsrWifiNmeApWmmParamUpdateReqSend - - DESCRIPTION - Application uses this primitive to update the WMM parameters - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - wmmApParams - WMM Access point parameters per access category. The array - index corresponds to the ACI - wmmApBcParams - WMM station parameters per access category to be advertised - in the beacons and probe response The array index - corresponds to the ACI - -*******************************************************************************/ -#define CsrWifiNmeApWmmParamUpdateReqCreate(msg__, dst__, src__, wmmApParams__, wmmApBcParams__) \ - msg__ = kmalloc(sizeof(CsrWifiNmeApWmmParamUpdateReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_AP_PRIM, CSR_WIFI_NME_AP_WMM_PARAM_UPDATE_REQ, dst__, src__); \ - memcpy(msg__->wmmApParams, (wmmApParams__), sizeof(CsrWifiSmeWmmAcParams) * 4); \ - memcpy(msg__->wmmApBcParams, (wmmApBcParams__), sizeof(CsrWifiSmeWmmAcParams) * 4); - -#define CsrWifiNmeApWmmParamUpdateReqSendTo(dst__, src__, wmmApParams__, wmmApBcParams__) \ - { \ - CsrWifiNmeApWmmParamUpdateReq *msg__; \ - CsrWifiNmeApWmmParamUpdateReqCreate(msg__, dst__, src__, wmmApParams__, wmmApBcParams__); \ - CsrMsgTransport(dst__, CSR_WIFI_NME_AP_PRIM, msg__); \ - } - -#define CsrWifiNmeApWmmParamUpdateReqSend(src__, wmmApParams__, wmmApBcParams__) \ - CsrWifiNmeApWmmParamUpdateReqSendTo(CSR_WIFI_NME_IFACEQUEUE, src__, wmmApParams__, wmmApBcParams__) - -/******************************************************************************* - - NAME - CsrWifiNmeApWmmParamUpdateCfmSend - - DESCRIPTION - A confirm for for the WMM parameters update - - PARAMETERS - queue - Destination Task Queue - status - Status of the request. - -*******************************************************************************/ -#define CsrWifiNmeApWmmParamUpdateCfmCreate(msg__, dst__, src__, status__) \ - msg__ = kmalloc(sizeof(CsrWifiNmeApWmmParamUpdateCfm), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_AP_PRIM, CSR_WIFI_NME_AP_WMM_PARAM_UPDATE_CFM, dst__, src__); \ - msg__->status = (status__); - -#define CsrWifiNmeApWmmParamUpdateCfmSendTo(dst__, src__, status__) \ - { \ - CsrWifiNmeApWmmParamUpdateCfm *msg__; \ - CsrWifiNmeApWmmParamUpdateCfmCreate(msg__, dst__, src__, status__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_NME_AP_PRIM, msg__); \ - } - -#define CsrWifiNmeApWmmParamUpdateCfmSend(dst__, status__) \ - CsrWifiNmeApWmmParamUpdateCfmSendTo(dst__, CSR_WIFI_NME_IFACEQUEUE, status__) - -/******************************************************************************* - - NAME - CsrWifiNmeApWpsRegisterReqSend - - DESCRIPTION - This primitive allows the NME to accept the WPS registration from an - enrollee. Such registration procedure can be cancelled by sending - CSR_WIFI_NME_WPS_CANCEL.request. - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - interfaceTag - Interface Identifier; unique identifier of an - interface - selectedDevicePasswordId - Selected password type - selectedConfigMethod - Selected WPS configuration method type - pin - PIN value. - Relevant if selected device password ID is PIN.4 - digit pin is passed by sending the pin digits in - pin[0]..pin[3] and rest of the contents filled - with '-'. - -*******************************************************************************/ -#define CsrWifiNmeApWpsRegisterReqCreate(msg__, dst__, src__, interfaceTag__, selectedDevicePasswordId__, selectedConfigMethod__, pin__) \ - msg__ = kmalloc(sizeof(CsrWifiNmeApWpsRegisterReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_AP_PRIM, CSR_WIFI_NME_AP_WPS_REGISTER_REQ, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->selectedDevicePasswordId = (selectedDevicePasswordId__); \ - msg__->selectedConfigMethod = (selectedConfigMethod__); \ - memcpy(msg__->pin, (pin__), sizeof(u8) * 8); - -#define CsrWifiNmeApWpsRegisterReqSendTo(dst__, src__, interfaceTag__, selectedDevicePasswordId__, selectedConfigMethod__, pin__) \ - { \ - CsrWifiNmeApWpsRegisterReq *msg__; \ - CsrWifiNmeApWpsRegisterReqCreate(msg__, dst__, src__, interfaceTag__, selectedDevicePasswordId__, selectedConfigMethod__, pin__); \ - CsrMsgTransport(dst__, CSR_WIFI_NME_AP_PRIM, msg__); \ - } - -#define CsrWifiNmeApWpsRegisterReqSend(src__, interfaceTag__, selectedDevicePasswordId__, selectedConfigMethod__, pin__) \ - CsrWifiNmeApWpsRegisterReqSendTo(CSR_WIFI_NME_IFACEQUEUE, src__, interfaceTag__, selectedDevicePasswordId__, selectedConfigMethod__, pin__) - -/******************************************************************************* - - NAME - CsrWifiNmeApWpsRegisterCfmSend - - DESCRIPTION - This primitive reports the result of WPS procedure. - - PARAMETERS - queue - Destination Task Queue - interfaceTag - Interface identifier; unique identifier of an interface - status - Status of the request. - -*******************************************************************************/ -#define CsrWifiNmeApWpsRegisterCfmCreate(msg__, dst__, src__, interfaceTag__, status__) \ - msg__ = kmalloc(sizeof(CsrWifiNmeApWpsRegisterCfm), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_AP_PRIM, CSR_WIFI_NME_AP_WPS_REGISTER_CFM, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->status = (status__); - -#define CsrWifiNmeApWpsRegisterCfmSendTo(dst__, src__, interfaceTag__, status__) \ - { \ - CsrWifiNmeApWpsRegisterCfm *msg__; \ - CsrWifiNmeApWpsRegisterCfmCreate(msg__, dst__, src__, interfaceTag__, status__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_NME_AP_PRIM, msg__); \ - } - -#define CsrWifiNmeApWpsRegisterCfmSend(dst__, interfaceTag__, status__) \ - CsrWifiNmeApWpsRegisterCfmSendTo(dst__, CSR_WIFI_NME_IFACEQUEUE, interfaceTag__, status__) - -#endif /* CSR_WIFI_NME_AP_LIB_H__ */ diff --git a/drivers/staging/csr/csr_wifi_nme_ap_prim.h b/drivers/staging/csr/csr_wifi_nme_ap_prim.h deleted file mode 100644 index b32bdbc7e22f..000000000000 --- a/drivers/staging/csr/csr_wifi_nme_ap_prim.h +++ /dev/null @@ -1,494 +0,0 @@ -/***************************************************************************** - - (c) Cambridge Silicon Radio Limited 2012 - All rights reserved and confidential information of CSR - - Refer to LICENSE.txt included with this source for details - on the license terms. - -*****************************************************************************/ - -/* Note: this is an auto-generated file. */ - -#ifndef CSR_WIFI_NME_AP_PRIM_H__ -#define CSR_WIFI_NME_AP_PRIM_H__ - -#include -#include "csr_prim_defs.h" -#include "csr_sched.h" -#include "csr_wifi_common.h" -#include "csr_result.h" -#include "csr_wifi_fsm_event.h" -#include "csr_wifi_sme_ap_prim.h" -#include "csr_wifi_nme_prim.h" - -#ifndef CSR_WIFI_NME_ENABLE -#error CSR_WIFI_NME_ENABLE MUST be defined inorder to use csr_wifi_nme_ap_prim.h -#endif -#ifndef CSR_WIFI_AP_ENABLE -#error CSR_WIFI_AP_ENABLE MUST be defined inorder to use csr_wifi_nme_ap_prim.h -#endif - -#define CSR_WIFI_NME_AP_PRIM (0x0426) - -typedef CsrPrim CsrWifiNmeApPrim; - - -/******************************************************************************* - - NAME - CsrWifiNmeApPersCredentialType - - DESCRIPTION - NME Credential Types - - VALUES - CSR_WIFI_NME_AP_CREDENTIAL_TYPE_PSK - - Use PSK as credential. - CSR_WIFI_NME_AP_CREDENTIAL_TYPE_PASSPHRASE - - Use the specified passphrase as credential - -*******************************************************************************/ -typedef u8 CsrWifiNmeApPersCredentialType; -#define CSR_WIFI_NME_AP_CREDENTIAL_TYPE_PSK ((CsrWifiNmeApPersCredentialType) 0x00) -#define CSR_WIFI_NME_AP_CREDENTIAL_TYPE_PASSPHRASE ((CsrWifiNmeApPersCredentialType) 0x01) - - -/******************************************************************************* - - NAME - CsrWifiNmeApConfig - - DESCRIPTION - Structure holding AP config data. - - MEMBERS - apGroupkeyTimeout - Access point group key timeout. - apStrictGtkRekey - Access point strict GTK rekey flag. If set TRUE, the AP - shall rekey GTK every time a connected STA leaves BSS. - apGmkTimeout - Access point GMK timeout - apResponseTimeout - Response timeout - apRetransLimit - Max allowed retransmissions - -*******************************************************************************/ -typedef struct -{ - u16 apGroupkeyTimeout; - u8 apStrictGtkRekey; - u16 apGmkTimeout; - u16 apResponseTimeout; - u8 apRetransLimit; -} CsrWifiNmeApConfig; - -/******************************************************************************* - - NAME - CsrWifiNmeApAuthPers - - DESCRIPTION - - MEMBERS - authSupport - Credential type value (as defined in the - enumeration type). - rsnCapabilities - RSN capabilities mask - wapiCapabilities - WAPI capabilities mask - pskOrPassphrase - Credential type value (as defined in the - enumeration type). - authPers_credentials - Union containing credentials which depends - on credentialType parameter. - authPers_credentialspsk - - authPers_credentialspassphrase - - -*******************************************************************************/ -typedef struct -{ - CsrWifiSmeApAuthSupportMask authSupport; - CsrWifiSmeApRsnCapabilitiesMask rsnCapabilities; - CsrWifiSmeApWapiCapabilitiesMask wapiCapabilities; - CsrWifiNmeApPersCredentialType pskOrPassphrase; - union { - CsrWifiNmePsk psk; - CsrWifiNmePassphrase passphrase; - } authPers_credentials; -} CsrWifiNmeApAuthPers; - -/******************************************************************************* - - NAME - CsrWifiNmeApCredentials - - DESCRIPTION - Structure containing the Credentials data. - - MEMBERS - authType - Authentication type - nmeAuthType - Authentication parameters - nmeAuthTypeopenSystemEmpty - - nmeAuthTypeauthwep - - nmeAuthTypeauthTypePersonal - - -*******************************************************************************/ -typedef struct -{ - CsrWifiSmeApAuthType authType; - union { - CsrWifiSmeEmpty openSystemEmpty; - CsrWifiSmeWepAuth authwep; - CsrWifiNmeApAuthPers authTypePersonal; - } nmeAuthType; -} CsrWifiNmeApCredentials; - - -/* Downstream */ -#define CSR_WIFI_NME_AP_PRIM_DOWNSTREAM_LOWEST (0x0000) - -#define CSR_WIFI_NME_AP_CONFIG_SET_REQ ((CsrWifiNmeApPrim) (0x0000 + CSR_WIFI_NME_AP_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_NME_AP_WPS_REGISTER_REQ ((CsrWifiNmeApPrim) (0x0001 + CSR_WIFI_NME_AP_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_NME_AP_START_REQ ((CsrWifiNmeApPrim) (0x0002 + CSR_WIFI_NME_AP_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_NME_AP_STOP_REQ ((CsrWifiNmeApPrim) (0x0003 + CSR_WIFI_NME_AP_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_NME_AP_WMM_PARAM_UPDATE_REQ ((CsrWifiNmeApPrim) (0x0004 + CSR_WIFI_NME_AP_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_NME_AP_STA_REMOVE_REQ ((CsrWifiNmeApPrim) (0x0005 + CSR_WIFI_NME_AP_PRIM_DOWNSTREAM_LOWEST)) - - -#define CSR_WIFI_NME_AP_PRIM_DOWNSTREAM_HIGHEST (0x0005 + CSR_WIFI_NME_AP_PRIM_DOWNSTREAM_LOWEST) - -/* Upstream */ -#define CSR_WIFI_NME_AP_PRIM_UPSTREAM_LOWEST (0x0000 + CSR_PRIM_UPSTREAM) - -#define CSR_WIFI_NME_AP_CONFIG_SET_CFM ((CsrWifiNmeApPrim)(0x0000 + CSR_WIFI_NME_AP_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_NME_AP_WPS_REGISTER_CFM ((CsrWifiNmeApPrim)(0x0001 + CSR_WIFI_NME_AP_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_NME_AP_START_CFM ((CsrWifiNmeApPrim)(0x0002 + CSR_WIFI_NME_AP_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_NME_AP_STOP_CFM ((CsrWifiNmeApPrim)(0x0003 + CSR_WIFI_NME_AP_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_NME_AP_STOP_IND ((CsrWifiNmeApPrim)(0x0004 + CSR_WIFI_NME_AP_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_NME_AP_WMM_PARAM_UPDATE_CFM ((CsrWifiNmeApPrim)(0x0005 + CSR_WIFI_NME_AP_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_NME_AP_STATION_IND ((CsrWifiNmeApPrim)(0x0006 + CSR_WIFI_NME_AP_PRIM_UPSTREAM_LOWEST)) - -#define CSR_WIFI_NME_AP_PRIM_UPSTREAM_HIGHEST (0x0006 + CSR_WIFI_NME_AP_PRIM_UPSTREAM_LOWEST) - -#define CSR_WIFI_NME_AP_PRIM_DOWNSTREAM_COUNT (CSR_WIFI_NME_AP_PRIM_DOWNSTREAM_HIGHEST + 1 - CSR_WIFI_NME_AP_PRIM_DOWNSTREAM_LOWEST) -#define CSR_WIFI_NME_AP_PRIM_UPSTREAM_COUNT (CSR_WIFI_NME_AP_PRIM_UPSTREAM_HIGHEST + 1 - CSR_WIFI_NME_AP_PRIM_UPSTREAM_LOWEST) - -/******************************************************************************* - - NAME - CsrWifiNmeApConfigSetReq - - DESCRIPTION - This primitive passes AP configuration info for NME. This can be sent at - any time but will be acted upon when the AP is started again. This - information is common to both P2P GO and AP - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - apConfig - AP configuration for the NME. - apMacConfig - MAC configuration to be acted on when - CSR_WIFI_NME_AP_START.request is sent. - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - CsrWifiNmeApConfig apConfig; - CsrWifiSmeApMacConfig apMacConfig; -} CsrWifiNmeApConfigSetReq; - -/******************************************************************************* - - NAME - CsrWifiNmeApWpsRegisterReq - - DESCRIPTION - This primitive allows the NME to accept the WPS registration from an - enrollee. Such registration procedure can be cancelled by sending - CSR_WIFI_NME_WPS_CANCEL.request. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - Interface Identifier; unique identifier of an - interface - selectedDevicePasswordId - Selected password type - selectedConfigMethod - Selected WPS configuration method type - pin - PIN value. - Relevant if selected device password ID is PIN.4 - digit pin is passed by sending the pin digits in - pin[0]..pin[3] and rest of the contents filled - with '-'. - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; - CsrWifiSmeWpsDpid selectedDevicePasswordId; - CsrWifiSmeWpsConfigType selectedConfigMethod; - u8 pin[8]; -} CsrWifiNmeApWpsRegisterReq; - -/******************************************************************************* - - NAME - CsrWifiNmeApStartReq - - DESCRIPTION - This primitive requests NME to started the AP operation. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - Interface identifier; unique identifier of an interface - apType - AP Type specifies the Legacy AP or P2P GO operation - cloakSsid - Indicates whether the SSID should be cloaked (hidden and - not broadcast in beacon) or not - ssid - Service Set Identifier - ifIndex - Radio interface - channel - Channel number of the channel to use - apCredentials - Security credential configuration. - maxConnections - Maximum number of stations/P2P clients allowed - p2pGoParam - P2P specific GO parameters. - wpsEnabled - Indicates whether WPS should be enabled or not - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; - CsrWifiSmeApType apType; - u8 cloakSsid; - CsrWifiSsid ssid; - CsrWifiSmeRadioIF ifIndex; - u8 channel; - CsrWifiNmeApCredentials apCredentials; - u8 maxConnections; - CsrWifiSmeApP2pGoConfig p2pGoParam; - u8 wpsEnabled; -} CsrWifiNmeApStartReq; - -/******************************************************************************* - - NAME - CsrWifiNmeApStopReq - - DESCRIPTION - This primitive requests NME to stop the AP operation. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - Interface identifier; unique identifier of an interface - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; -} CsrWifiNmeApStopReq; - -/******************************************************************************* - - NAME - CsrWifiNmeApWmmParamUpdateReq - - DESCRIPTION - Application uses this primitive to update the WMM parameters - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - wmmApParams - WMM Access point parameters per access category. The array - index corresponds to the ACI - wmmApBcParams - WMM station parameters per access category to be advertised - in the beacons and probe response The array index - corresponds to the ACI - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - CsrWifiSmeWmmAcParams wmmApParams[4]; - CsrWifiSmeWmmAcParams wmmApBcParams[4]; -} CsrWifiNmeApWmmParamUpdateReq; - -/******************************************************************************* - - NAME - CsrWifiNmeApStaRemoveReq - - DESCRIPTION - This primitive disconnects a connected station. If keepBlocking is set to - TRUE, the station with the specified MAC address is not allowed to - connect. If the requested station is not already connected,it may be - blocked based on keepBlocking parameter. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - Interface Identifier; unique identifier of an interface - staMacAddress - Mac Address of the station to be disconnected or blocked - keepBlocking - If TRUE, the station is blocked. If FALSE and the station is - connected, disconnect the station. If FALSE and the station - is not connected, no action is taken. - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; - CsrWifiMacAddress staMacAddress; - u8 keepBlocking; -} CsrWifiNmeApStaRemoveReq; - -/******************************************************************************* - - NAME - CsrWifiNmeApConfigSetCfm - - DESCRIPTION - This primitive reports the result of the request. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - status - Status of the request. - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - CsrResult status; -} CsrWifiNmeApConfigSetCfm; - -/******************************************************************************* - - NAME - CsrWifiNmeApWpsRegisterCfm - - DESCRIPTION - This primitive reports the result of WPS procedure. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - Interface identifier; unique identifier of an interface - status - Status of the request. - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; - CsrResult status; -} CsrWifiNmeApWpsRegisterCfm; - -/******************************************************************************* - - NAME - CsrWifiNmeApStartCfm - - DESCRIPTION - This primitive reports the result of CSR_WIFI_NME_AP_START.request. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - Interface identifier; unique identifier of an interface - status - Status of the request. - ssid - Service Set Identifier - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; - CsrResult status; - CsrWifiSsid ssid; -} CsrWifiNmeApStartCfm; - -/******************************************************************************* - - NAME - CsrWifiNmeApStopCfm - - DESCRIPTION - This primitive confirms that the AP operation is stopped. NME shall send - this primitive in response to the request even if AP operation has - already been stopped - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - Interface identifier; unique identifier of an interface - status - Status of the request. - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; - CsrResult status; -} CsrWifiNmeApStopCfm; - -/******************************************************************************* - - NAME - CsrWifiNmeApStopInd - - DESCRIPTION - Indicates that AP operation had stopped because of some unrecoverable - error after AP operation was started successfully. NME sends this signal - after failing to restart the AP operation internally following an error - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - Interface Identifier; unique identifier of an interface - apType - Reports AP Type (P2PGO or AP) - status - Error Status - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; - CsrWifiSmeApType apType; - CsrResult status; -} CsrWifiNmeApStopInd; - -/******************************************************************************* - - NAME - CsrWifiNmeApWmmParamUpdateCfm - - DESCRIPTION - A confirm for for the WMM parameters update - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - status - Status of the request. - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - CsrResult status; -} CsrWifiNmeApWmmParamUpdateCfm; - -/******************************************************************************* - - NAME - CsrWifiNmeApStationInd - - DESCRIPTION - This primitive indicates that a station has joined or a previously joined - station has left the BSS/group - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - Interface Identifier; unique identifier of an interface - mediaStatus - Indicates whether the station is connected or - disconnected - peerMacAddress - MAC address of the station - peerDeviceAddress - P2P Device Address - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; - CsrWifiSmeMediaStatus mediaStatus; - CsrWifiMacAddress peerMacAddress; - CsrWifiMacAddress peerDeviceAddress; -} CsrWifiNmeApStationInd; - -#endif /* CSR_WIFI_NME_AP_PRIM_H__ */ - diff --git a/drivers/staging/csr/csr_wifi_nme_ap_sef.c b/drivers/staging/csr/csr_wifi_nme_ap_sef.c deleted file mode 100644 index bfebb1529779..000000000000 --- a/drivers/staging/csr/csr_wifi_nme_ap_sef.c +++ /dev/null @@ -1,30 +0,0 @@ -/***************************************************************************** - - FILE: csr_wifi_nme_sef.c - - (c) Cambridge Silicon Radio Limited 2010 - - Refer to LICENSE.txt included with this source for details - on the license terms. - - *****************************************************************************/ -#include "csr_wifi_nme_ap_sef.h" -#include "unifi_priv.h" - -void CsrWifiNmeApUpstreamStateHandlers(void* drvpriv, CsrWifiFsmEvent* msg) -{ - switch(msg->type) { - case CSR_WIFI_NME_AP_START_CFM: - CsrWifiNmeApStartCfmHandler(drvpriv, msg); - break; - case CSR_WIFI_NME_AP_STOP_CFM: - CsrWifiNmeApStopCfmHandler(drvpriv, msg); - break; - case CSR_WIFI_NME_AP_CONFIG_SET_CFM: - CsrWifiNmeApConfigSetCfmHandler(drvpriv, msg); - break; - default: - unifi_error(drvpriv, "CsrWifiNmeApUpstreamStateHandlers: unhandled NME_AP message type 0x%.4X\n", msg->type); - break; - } -} diff --git a/drivers/staging/csr/csr_wifi_nme_ap_sef.h b/drivers/staging/csr/csr_wifi_nme_ap_sef.h deleted file mode 100644 index 3daaa0944dba..000000000000 --- a/drivers/staging/csr/csr_wifi_nme_ap_sef.h +++ /dev/null @@ -1,21 +0,0 @@ -/***************************************************************************** - FILE: csr_wifi_nme_sef.h - (c) Cambridge Silicon Radio Limited 2010 - - Refer to LICENSE.txt included with this source for details - on the license terms. - -*****************************************************************************/ -#ifndef CSR_WIFI_ROUTER_SEF_CSR_WIFI_NME_H__ -#define CSR_WIFI_ROUTER_SEF_CSR_WIFI_NME_H__ - -#include "csr_wifi_nme_prim.h" - -void CsrWifiNmeApUpstreamStateHandlers(void* drvpriv, CsrWifiFsmEvent* msg); - - -extern void CsrWifiNmeApConfigSetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg); -extern void CsrWifiNmeApStartCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg); -extern void CsrWifiNmeApStopCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg); - -#endif /* CSR_WIFI_ROUTER_SEF_CSR_WIFI_NME_H__ */ diff --git a/drivers/staging/csr/csr_wifi_nme_ap_serialize.c b/drivers/staging/csr/csr_wifi_nme_ap_serialize.c deleted file mode 100644 index 1a901a70d195..000000000000 --- a/drivers/staging/csr/csr_wifi_nme_ap_serialize.c +++ /dev/null @@ -1,909 +0,0 @@ -/***************************************************************************** - - (c) Cambridge Silicon Radio Limited 2012 - All rights reserved and confidential information of CSR - - Refer to LICENSE.txt included with this source for details - on the license terms. - -*****************************************************************************/ - -/* Note: this is an auto-generated file. */ -#include -#include -#include "csr_msgconv.h" - -#ifdef CSR_WIFI_NME_ENABLE -#ifdef CSR_WIFI_AP_ENABLE - -#include "csr_wifi_nme_ap_prim.h" -#include "csr_wifi_nme_ap_serialize.h" - -void CsrWifiNmeApPfree(void *ptr) -{ - kfree(ptr); -} - - -size_t CsrWifiNmeApConfigSetReqSizeof(void *msg) -{ - CsrWifiNmeApConfigSetReq *primitive = (CsrWifiNmeApConfigSetReq *) msg; - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 104) */ - bufferSize += 2; /* u16 primitive->apConfig.apGroupkeyTimeout */ - bufferSize += 1; /* u8 primitive->apConfig.apStrictGtkRekey */ - bufferSize += 2; /* u16 primitive->apConfig.apGmkTimeout */ - bufferSize += 2; /* u16 primitive->apConfig.apResponseTimeout */ - bufferSize += 1; /* u8 primitive->apConfig.apRetransLimit */ - bufferSize += 1; /* CsrWifiSmeApPhySupportMask primitive->apMacConfig.phySupportedBitmap */ - bufferSize += 2; /* u16 primitive->apMacConfig.beaconInterval */ - bufferSize += 1; /* u8 primitive->apMacConfig.dtimPeriod */ - bufferSize += 2; /* u16 primitive->apMacConfig.maxListenInterval */ - bufferSize += 1; /* u8 primitive->apMacConfig.supportedRatesCount */ - bufferSize += 20; /* u8 primitive->apMacConfig.supportedRates[20] */ - bufferSize += 1; /* CsrWifiSmePreambleType primitive->apMacConfig.preamble */ - bufferSize += 1; /* u8 primitive->apMacConfig.shortSlotTimeEnabled */ - bufferSize += 1; /* CsrWifiSmeCtsProtectionType primitive->apMacConfig.ctsProtectionType */ - bufferSize += 1; /* u8 primitive->apMacConfig.wmmEnabled */ - { - u16 i2; - for (i2 = 0; i2 < 4; i2++) - { - bufferSize += 1; /* u8 primitive->apMacConfig.wmmApParams[i2].cwMin */ - bufferSize += 1; /* u8 primitive->apMacConfig.wmmApParams[i2].cwMax */ - bufferSize += 1; /* u8 primitive->apMacConfig.wmmApParams[i2].aifs */ - bufferSize += 2; /* u16 primitive->apMacConfig.wmmApParams[i2].txopLimit */ - bufferSize += 1; /* u8 primitive->apMacConfig.wmmApParams[i2].admissionControlMandatory */ - } - } - { - u16 i2; - for (i2 = 0; i2 < 4; i2++) - { - bufferSize += 1; /* u8 primitive->apMacConfig.wmmApBcParams[i2].cwMin */ - bufferSize += 1; /* u8 primitive->apMacConfig.wmmApBcParams[i2].cwMax */ - bufferSize += 1; /* u8 primitive->apMacConfig.wmmApBcParams[i2].aifs */ - bufferSize += 2; /* u16 primitive->apMacConfig.wmmApBcParams[i2].txopLimit */ - bufferSize += 1; /* u8 primitive->apMacConfig.wmmApBcParams[i2].admissionControlMandatory */ - } - } - bufferSize += 1; /* CsrWifiSmeApAccessType primitive->apMacConfig.accessType */ - bufferSize += 1; /* u8 primitive->apMacConfig.macAddressListCount */ - { - u16 i2; - for (i2 = 0; i2 < primitive->apMacConfig.macAddressListCount; i2++) - { - bufferSize += 6; /* u8 primitive->apMacConfig.macAddressList[i2].a[6] */ - } - } - bufferSize += 1; /* u8 primitive->apMacConfig.apHtParams.greenfieldSupported */ - bufferSize += 1; /* u8 primitive->apMacConfig.apHtParams.shortGi20MHz */ - bufferSize += 1; /* u8 primitive->apMacConfig.apHtParams.rxStbc */ - bufferSize += 1; /* u8 primitive->apMacConfig.apHtParams.rifsModeAllowed */ - bufferSize += 1; /* u8 primitive->apMacConfig.apHtParams.htProtection */ - bufferSize += 1; /* u8 primitive->apMacConfig.apHtParams.dualCtsProtection */ - return bufferSize; -} - - -u8* CsrWifiNmeApConfigSetReqSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiNmeApConfigSetReq *primitive = (CsrWifiNmeApConfigSetReq *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->apConfig.apGroupkeyTimeout); - CsrUint8Ser(ptr, len, (u8) primitive->apConfig.apStrictGtkRekey); - CsrUint16Ser(ptr, len, (u16) primitive->apConfig.apGmkTimeout); - CsrUint16Ser(ptr, len, (u16) primitive->apConfig.apResponseTimeout); - CsrUint8Ser(ptr, len, (u8) primitive->apConfig.apRetransLimit); - CsrUint8Ser(ptr, len, (u8) primitive->apMacConfig.phySupportedBitmap); - CsrUint16Ser(ptr, len, (u16) primitive->apMacConfig.beaconInterval); - CsrUint8Ser(ptr, len, (u8) primitive->apMacConfig.dtimPeriod); - CsrUint16Ser(ptr, len, (u16) primitive->apMacConfig.maxListenInterval); - CsrUint8Ser(ptr, len, (u8) primitive->apMacConfig.supportedRatesCount); - CsrMemCpySer(ptr, len, (const void *) primitive->apMacConfig.supportedRates, ((u16) (20))); - CsrUint8Ser(ptr, len, (u8) primitive->apMacConfig.preamble); - CsrUint8Ser(ptr, len, (u8) primitive->apMacConfig.shortSlotTimeEnabled); - CsrUint8Ser(ptr, len, (u8) primitive->apMacConfig.ctsProtectionType); - CsrUint8Ser(ptr, len, (u8) primitive->apMacConfig.wmmEnabled); - { - u16 i2; - for (i2 = 0; i2 < 4; i2++) - { - CsrUint8Ser(ptr, len, (u8) primitive->apMacConfig.wmmApParams[i2].cwMin); - CsrUint8Ser(ptr, len, (u8) primitive->apMacConfig.wmmApParams[i2].cwMax); - CsrUint8Ser(ptr, len, (u8) primitive->apMacConfig.wmmApParams[i2].aifs); - CsrUint16Ser(ptr, len, (u16) primitive->apMacConfig.wmmApParams[i2].txopLimit); - CsrUint8Ser(ptr, len, (u8) primitive->apMacConfig.wmmApParams[i2].admissionControlMandatory); - } - } - { - u16 i2; - for (i2 = 0; i2 < 4; i2++) - { - CsrUint8Ser(ptr, len, (u8) primitive->apMacConfig.wmmApBcParams[i2].cwMin); - CsrUint8Ser(ptr, len, (u8) primitive->apMacConfig.wmmApBcParams[i2].cwMax); - CsrUint8Ser(ptr, len, (u8) primitive->apMacConfig.wmmApBcParams[i2].aifs); - CsrUint16Ser(ptr, len, (u16) primitive->apMacConfig.wmmApBcParams[i2].txopLimit); - CsrUint8Ser(ptr, len, (u8) primitive->apMacConfig.wmmApBcParams[i2].admissionControlMandatory); - } - } - CsrUint8Ser(ptr, len, (u8) primitive->apMacConfig.accessType); - CsrUint8Ser(ptr, len, (u8) primitive->apMacConfig.macAddressListCount); - { - u16 i2; - for (i2 = 0; i2 < primitive->apMacConfig.macAddressListCount; i2++) - { - CsrMemCpySer(ptr, len, (const void *) primitive->apMacConfig.macAddressList[i2].a, ((u16) (6))); - } - } - CsrUint8Ser(ptr, len, (u8) primitive->apMacConfig.apHtParams.greenfieldSupported); - CsrUint8Ser(ptr, len, (u8) primitive->apMacConfig.apHtParams.shortGi20MHz); - CsrUint8Ser(ptr, len, (u8) primitive->apMacConfig.apHtParams.rxStbc); - CsrUint8Ser(ptr, len, (u8) primitive->apMacConfig.apHtParams.rifsModeAllowed); - CsrUint8Ser(ptr, len, (u8) primitive->apMacConfig.apHtParams.htProtection); - CsrUint8Ser(ptr, len, (u8) primitive->apMacConfig.apHtParams.dualCtsProtection); - return(ptr); -} - - -void* CsrWifiNmeApConfigSetReqDes(u8 *buffer, size_t length) -{ - CsrWifiNmeApConfigSetReq *primitive = kmalloc(sizeof(CsrWifiNmeApConfigSetReq), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->apConfig.apGroupkeyTimeout, buffer, &offset); - CsrUint8Des((u8 *) &primitive->apConfig.apStrictGtkRekey, buffer, &offset); - CsrUint16Des((u16 *) &primitive->apConfig.apGmkTimeout, buffer, &offset); - CsrUint16Des((u16 *) &primitive->apConfig.apResponseTimeout, buffer, &offset); - CsrUint8Des((u8 *) &primitive->apConfig.apRetransLimit, buffer, &offset); - CsrUint8Des((u8 *) &primitive->apMacConfig.phySupportedBitmap, buffer, &offset); - CsrUint16Des((u16 *) &primitive->apMacConfig.beaconInterval, buffer, &offset); - CsrUint8Des((u8 *) &primitive->apMacConfig.dtimPeriod, buffer, &offset); - CsrUint16Des((u16 *) &primitive->apMacConfig.maxListenInterval, buffer, &offset); - CsrUint8Des((u8 *) &primitive->apMacConfig.supportedRatesCount, buffer, &offset); - CsrMemCpyDes(primitive->apMacConfig.supportedRates, buffer, &offset, ((u16) (20))); - CsrUint8Des((u8 *) &primitive->apMacConfig.preamble, buffer, &offset); - CsrUint8Des((u8 *) &primitive->apMacConfig.shortSlotTimeEnabled, buffer, &offset); - CsrUint8Des((u8 *) &primitive->apMacConfig.ctsProtectionType, buffer, &offset); - CsrUint8Des((u8 *) &primitive->apMacConfig.wmmEnabled, buffer, &offset); - { - u16 i2; - for (i2 = 0; i2 < 4; i2++) - { - CsrUint8Des((u8 *) &primitive->apMacConfig.wmmApParams[i2].cwMin, buffer, &offset); - CsrUint8Des((u8 *) &primitive->apMacConfig.wmmApParams[i2].cwMax, buffer, &offset); - CsrUint8Des((u8 *) &primitive->apMacConfig.wmmApParams[i2].aifs, buffer, &offset); - CsrUint16Des((u16 *) &primitive->apMacConfig.wmmApParams[i2].txopLimit, buffer, &offset); - CsrUint8Des((u8 *) &primitive->apMacConfig.wmmApParams[i2].admissionControlMandatory, buffer, &offset); - } - } - { - u16 i2; - for (i2 = 0; i2 < 4; i2++) - { - CsrUint8Des((u8 *) &primitive->apMacConfig.wmmApBcParams[i2].cwMin, buffer, &offset); - CsrUint8Des((u8 *) &primitive->apMacConfig.wmmApBcParams[i2].cwMax, buffer, &offset); - CsrUint8Des((u8 *) &primitive->apMacConfig.wmmApBcParams[i2].aifs, buffer, &offset); - CsrUint16Des((u16 *) &primitive->apMacConfig.wmmApBcParams[i2].txopLimit, buffer, &offset); - CsrUint8Des((u8 *) &primitive->apMacConfig.wmmApBcParams[i2].admissionControlMandatory, buffer, &offset); - } - } - CsrUint8Des((u8 *) &primitive->apMacConfig.accessType, buffer, &offset); - CsrUint8Des((u8 *) &primitive->apMacConfig.macAddressListCount, buffer, &offset); - primitive->apMacConfig.macAddressList = NULL; - if (primitive->apMacConfig.macAddressListCount) - { - primitive->apMacConfig.macAddressList = kmalloc(sizeof(CsrWifiMacAddress) * primitive->apMacConfig.macAddressListCount, GFP_KERNEL); - } - { - u16 i2; - for (i2 = 0; i2 < primitive->apMacConfig.macAddressListCount; i2++) - { - CsrMemCpyDes(primitive->apMacConfig.macAddressList[i2].a, buffer, &offset, ((u16) (6))); - } - } - CsrUint8Des((u8 *) &primitive->apMacConfig.apHtParams.greenfieldSupported, buffer, &offset); - CsrUint8Des((u8 *) &primitive->apMacConfig.apHtParams.shortGi20MHz, buffer, &offset); - CsrUint8Des((u8 *) &primitive->apMacConfig.apHtParams.rxStbc, buffer, &offset); - CsrUint8Des((u8 *) &primitive->apMacConfig.apHtParams.rifsModeAllowed, buffer, &offset); - CsrUint8Des((u8 *) &primitive->apMacConfig.apHtParams.htProtection, buffer, &offset); - CsrUint8Des((u8 *) &primitive->apMacConfig.apHtParams.dualCtsProtection, buffer, &offset); - - return primitive; -} - - -void CsrWifiNmeApConfigSetReqSerFree(void *voidPrimitivePointer) -{ - CsrWifiNmeApConfigSetReq *primitive = (CsrWifiNmeApConfigSetReq *) voidPrimitivePointer; - kfree(primitive->apMacConfig.macAddressList); - kfree(primitive); -} - - -size_t CsrWifiNmeApWpsRegisterReqSizeof(void *msg) -{ - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 17) */ - bufferSize += 2; /* u16 primitive->interfaceTag */ - bufferSize += 2; /* CsrWifiSmeWpsDpid primitive->selectedDevicePasswordId */ - bufferSize += 2; /* CsrWifiSmeWpsConfigType primitive->selectedConfigMethod */ - bufferSize += 8; /* u8 primitive->pin[8] */ - return bufferSize; -} - - -u8* CsrWifiNmeApWpsRegisterReqSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiNmeApWpsRegisterReq *primitive = (CsrWifiNmeApWpsRegisterReq *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag); - CsrUint16Ser(ptr, len, (u16) primitive->selectedDevicePasswordId); - CsrUint16Ser(ptr, len, (u16) primitive->selectedConfigMethod); - CsrMemCpySer(ptr, len, (const void *) primitive->pin, ((u16) (8))); - return(ptr); -} - - -void* CsrWifiNmeApWpsRegisterReqDes(u8 *buffer, size_t length) -{ - CsrWifiNmeApWpsRegisterReq *primitive = kmalloc(sizeof(CsrWifiNmeApWpsRegisterReq), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset); - CsrUint16Des((u16 *) &primitive->selectedDevicePasswordId, buffer, &offset); - CsrUint16Des((u16 *) &primitive->selectedConfigMethod, buffer, &offset); - CsrMemCpyDes(primitive->pin, buffer, &offset, ((u16) (8))); - - return primitive; -} - - -size_t CsrWifiNmeApStartReqSizeof(void *msg) -{ - CsrWifiNmeApStartReq *primitive = (CsrWifiNmeApStartReq *) msg; - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 112) */ - bufferSize += 2; /* u16 primitive->interfaceTag */ - bufferSize += 1; /* CsrWifiSmeApType primitive->apType */ - bufferSize += 1; /* u8 primitive->cloakSsid */ - bufferSize += 32; /* u8 primitive->ssid.ssid[32] */ - bufferSize += 1; /* u8 primitive->ssid.length */ - bufferSize += 1; /* CsrWifiSmeRadioIF primitive->ifIndex */ - bufferSize += 1; /* u8 primitive->channel */ - bufferSize += 1; /* CsrWifiSmeApAuthType primitive->apCredentials.authType */ - switch (primitive->apCredentials.authType) - { - case CSR_WIFI_SME_AP_AUTH_TYPE_OPEN_SYSTEM: - bufferSize += 1; /* u8 primitive->apCredentials.nmeAuthType.openSystemEmpty.empty */ - break; - case CSR_WIFI_SME_AP_AUTH_TYPE_WEP: - bufferSize += 1; /* CsrWifiSmeWepCredentialType primitive->apCredentials.nmeAuthType.authwep.wepKeyType */ - switch (primitive->apCredentials.nmeAuthType.authwep.wepKeyType) - { - case CSR_WIFI_SME_CREDENTIAL_TYPE_WEP128: - bufferSize += 1; /* CsrWifiSmeWepAuthMode primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep128Key.wepAuthType */ - bufferSize += 1; /* u8 primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep128Key.selectedWepKey */ - bufferSize += 13; /* u8 primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep128Key.key1[13] */ - bufferSize += 13; /* u8 primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep128Key.key2[13] */ - bufferSize += 13; /* u8 primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep128Key.key3[13] */ - bufferSize += 13; /* u8 primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep128Key.key4[13] */ - break; - case CSR_WIFI_SME_CREDENTIAL_TYPE_WEP64: - bufferSize += 1; /* CsrWifiSmeWepAuthMode primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep64Key.wepAuthType */ - bufferSize += 1; /* u8 primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep64Key.selectedWepKey */ - bufferSize += 5; /* u8 primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep64Key.key1[5] */ - bufferSize += 5; /* u8 primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep64Key.key2[5] */ - bufferSize += 5; /* u8 primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep64Key.key3[5] */ - bufferSize += 5; /* u8 primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep64Key.key4[5] */ - break; - default: - break; - } - break; - case CSR_WIFI_SME_AP_AUTH_TYPE_PERSONAL: - bufferSize += 1; /* CsrWifiSmeApAuthSupportMask primitive->apCredentials.nmeAuthType.authTypePersonal.authSupport */ - bufferSize += 2; /* CsrWifiSmeApRsnCapabilitiesMask primitive->apCredentials.nmeAuthType.authTypePersonal.rsnCapabilities */ - bufferSize += 2; /* CsrWifiSmeApWapiCapabilitiesMask primitive->apCredentials.nmeAuthType.authTypePersonal.wapiCapabilities */ - bufferSize += 1; /* CsrWifiNmeApPersCredentialType primitive->apCredentials.nmeAuthType.authTypePersonal.pskOrPassphrase */ - switch (primitive->apCredentials.nmeAuthType.authTypePersonal.pskOrPassphrase) - { - case CSR_WIFI_NME_AP_CREDENTIAL_TYPE_PSK: - bufferSize += 2; /* u16 primitive->apCredentials.nmeAuthType.authTypePersonal.authPers_credentials.psk.encryptionMode */ - bufferSize += 32; /* u8 primitive->apCredentials.nmeAuthType.authTypePersonal.authPers_credentials.psk.psk[32] */ - break; - case CSR_WIFI_NME_AP_CREDENTIAL_TYPE_PASSPHRASE: - bufferSize += 2; /* u16 primitive->apCredentials.nmeAuthType.authTypePersonal.authPers_credentials.passphrase.encryptionMode */ - bufferSize += (primitive->apCredentials.nmeAuthType.authTypePersonal.authPers_credentials.passphrase.passphrase ? strlen(primitive->apCredentials.nmeAuthType.authTypePersonal.authPers_credentials.passphrase.passphrase) : 0) + 1; /* char* primitive->apCredentials.nmeAuthType.authTypePersonal.authPers_credentials.passphrase.passphrase (0 byte len + 1 for NULL Term) */ - break; - default: - break; - } - break; - default: - break; - } - bufferSize += 1; /* u8 primitive->maxConnections */ - bufferSize += 1; /* CsrWifiSmeP2pGroupCapabilityMask primitive->p2pGoParam.groupCapability */ - bufferSize += 3; /* u8 primitive->p2pGoParam.operatingChanList.country[3] */ - bufferSize += 1; /* u8 primitive->p2pGoParam.operatingChanList.channelEntryListCount */ - { - u16 i3; - for (i3 = 0; i3 < primitive->p2pGoParam.operatingChanList.channelEntryListCount; i3++) - { - bufferSize += 1; /* u8 primitive->p2pGoParam.operatingChanList.channelEntryList[i3].operatingClass */ - bufferSize += 1; /* u8 primitive->p2pGoParam.operatingChanList.channelEntryList[i3].operatingChannelCount */ - bufferSize += primitive->p2pGoParam.operatingChanList.channelEntryList[i3].operatingChannelCount; /* u8 primitive->p2pGoParam.operatingChanList.channelEntryList[i3].operatingChannel */ - } - } - bufferSize += 1; /* u8 primitive->p2pGoParam.opPsEnabled */ - bufferSize += 1; /* u8 primitive->p2pGoParam.ctWindow */ - bufferSize += 1; /* CsrWifiSmeP2pNoaConfigMethod primitive->p2pGoParam.noaConfigMethod */ - bufferSize += 1; /* u8 primitive->p2pGoParam.allowNoaWithNonP2pDevices */ - bufferSize += 1; /* u8 primitive->wpsEnabled */ - return bufferSize; -} - - -u8* CsrWifiNmeApStartReqSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiNmeApStartReq *primitive = (CsrWifiNmeApStartReq *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag); - CsrUint8Ser(ptr, len, (u8) primitive->apType); - CsrUint8Ser(ptr, len, (u8) primitive->cloakSsid); - CsrMemCpySer(ptr, len, (const void *) primitive->ssid.ssid, ((u16) (32))); - CsrUint8Ser(ptr, len, (u8) primitive->ssid.length); - CsrUint8Ser(ptr, len, (u8) primitive->ifIndex); - CsrUint8Ser(ptr, len, (u8) primitive->channel); - CsrUint8Ser(ptr, len, (u8) primitive->apCredentials.authType); - switch (primitive->apCredentials.authType) - { - case CSR_WIFI_SME_AP_AUTH_TYPE_OPEN_SYSTEM: - CsrUint8Ser(ptr, len, (u8) primitive->apCredentials.nmeAuthType.openSystemEmpty.empty); - break; - case CSR_WIFI_SME_AP_AUTH_TYPE_WEP: - CsrUint8Ser(ptr, len, (u8) primitive->apCredentials.nmeAuthType.authwep.wepKeyType); - switch (primitive->apCredentials.nmeAuthType.authwep.wepKeyType) - { - case CSR_WIFI_SME_CREDENTIAL_TYPE_WEP128: - CsrUint8Ser(ptr, len, (u8) primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep128Key.wepAuthType); - CsrUint8Ser(ptr, len, (u8) primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep128Key.selectedWepKey); - CsrMemCpySer(ptr, len, (const void *) primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep128Key.key1, ((u16) (13))); - CsrMemCpySer(ptr, len, (const void *) primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep128Key.key2, ((u16) (13))); - CsrMemCpySer(ptr, len, (const void *) primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep128Key.key3, ((u16) (13))); - CsrMemCpySer(ptr, len, (const void *) primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep128Key.key4, ((u16) (13))); - break; - case CSR_WIFI_SME_CREDENTIAL_TYPE_WEP64: - CsrUint8Ser(ptr, len, (u8) primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep64Key.wepAuthType); - CsrUint8Ser(ptr, len, (u8) primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep64Key.selectedWepKey); - CsrMemCpySer(ptr, len, (const void *) primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep64Key.key1, ((u16) (5))); - CsrMemCpySer(ptr, len, (const void *) primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep64Key.key2, ((u16) (5))); - CsrMemCpySer(ptr, len, (const void *) primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep64Key.key3, ((u16) (5))); - CsrMemCpySer(ptr, len, (const void *) primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep64Key.key4, ((u16) (5))); - break; - default: - break; - } - break; - case CSR_WIFI_SME_AP_AUTH_TYPE_PERSONAL: - CsrUint8Ser(ptr, len, (u8) primitive->apCredentials.nmeAuthType.authTypePersonal.authSupport); - CsrUint16Ser(ptr, len, (u16) primitive->apCredentials.nmeAuthType.authTypePersonal.rsnCapabilities); - CsrUint16Ser(ptr, len, (u16) primitive->apCredentials.nmeAuthType.authTypePersonal.wapiCapabilities); - CsrUint8Ser(ptr, len, (u8) primitive->apCredentials.nmeAuthType.authTypePersonal.pskOrPassphrase); - switch (primitive->apCredentials.nmeAuthType.authTypePersonal.pskOrPassphrase) - { - case CSR_WIFI_NME_AP_CREDENTIAL_TYPE_PSK: - CsrUint16Ser(ptr, len, (u16) primitive->apCredentials.nmeAuthType.authTypePersonal.authPers_credentials.psk.encryptionMode); - CsrMemCpySer(ptr, len, (const void *) primitive->apCredentials.nmeAuthType.authTypePersonal.authPers_credentials.psk.psk, ((u16) (32))); - break; - case CSR_WIFI_NME_AP_CREDENTIAL_TYPE_PASSPHRASE: - CsrUint16Ser(ptr, len, (u16) primitive->apCredentials.nmeAuthType.authTypePersonal.authPers_credentials.passphrase.encryptionMode); - CsrCharStringSer(ptr, len, primitive->apCredentials.nmeAuthType.authTypePersonal.authPers_credentials.passphrase.passphrase); - break; - default: - break; - } - break; - default: - break; - } - CsrUint8Ser(ptr, len, (u8) primitive->maxConnections); - CsrUint8Ser(ptr, len, (u8) primitive->p2pGoParam.groupCapability); - CsrMemCpySer(ptr, len, (const void *) primitive->p2pGoParam.operatingChanList.country, ((u16) (3))); - CsrUint8Ser(ptr, len, (u8) primitive->p2pGoParam.operatingChanList.channelEntryListCount); - { - u16 i3; - for (i3 = 0; i3 < primitive->p2pGoParam.operatingChanList.channelEntryListCount; i3++) - { - CsrUint8Ser(ptr, len, (u8) primitive->p2pGoParam.operatingChanList.channelEntryList[i3].operatingClass); - CsrUint8Ser(ptr, len, (u8) primitive->p2pGoParam.operatingChanList.channelEntryList[i3].operatingChannelCount); - if (primitive->p2pGoParam.operatingChanList.channelEntryList[i3].operatingChannelCount) - { - CsrMemCpySer(ptr, len, (const void *) primitive->p2pGoParam.operatingChanList.channelEntryList[i3].operatingChannel, ((u16) (primitive->p2pGoParam.operatingChanList.channelEntryList[i3].operatingChannelCount))); - } - } - } - CsrUint8Ser(ptr, len, (u8) primitive->p2pGoParam.opPsEnabled); - CsrUint8Ser(ptr, len, (u8) primitive->p2pGoParam.ctWindow); - CsrUint8Ser(ptr, len, (u8) primitive->p2pGoParam.noaConfigMethod); - CsrUint8Ser(ptr, len, (u8) primitive->p2pGoParam.allowNoaWithNonP2pDevices); - CsrUint8Ser(ptr, len, (u8) primitive->wpsEnabled); - return(ptr); -} - - -void* CsrWifiNmeApStartReqDes(u8 *buffer, size_t length) -{ - CsrWifiNmeApStartReq *primitive = kmalloc(sizeof(CsrWifiNmeApStartReq), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset); - CsrUint8Des((u8 *) &primitive->apType, buffer, &offset); - CsrUint8Des((u8 *) &primitive->cloakSsid, buffer, &offset); - CsrMemCpyDes(primitive->ssid.ssid, buffer, &offset, ((u16) (32))); - CsrUint8Des((u8 *) &primitive->ssid.length, buffer, &offset); - CsrUint8Des((u8 *) &primitive->ifIndex, buffer, &offset); - CsrUint8Des((u8 *) &primitive->channel, buffer, &offset); - CsrUint8Des((u8 *) &primitive->apCredentials.authType, buffer, &offset); - switch (primitive->apCredentials.authType) - { - case CSR_WIFI_SME_AP_AUTH_TYPE_OPEN_SYSTEM: - CsrUint8Des((u8 *) &primitive->apCredentials.nmeAuthType.openSystemEmpty.empty, buffer, &offset); - break; - case CSR_WIFI_SME_AP_AUTH_TYPE_WEP: - CsrUint8Des((u8 *) &primitive->apCredentials.nmeAuthType.authwep.wepKeyType, buffer, &offset); - switch (primitive->apCredentials.nmeAuthType.authwep.wepKeyType) - { - case CSR_WIFI_SME_CREDENTIAL_TYPE_WEP128: - CsrUint8Des((u8 *) &primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep128Key.wepAuthType, buffer, &offset); - CsrUint8Des((u8 *) &primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep128Key.selectedWepKey, buffer, &offset); - CsrMemCpyDes(primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep128Key.key1, buffer, &offset, ((u16) (13))); - CsrMemCpyDes(primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep128Key.key2, buffer, &offset, ((u16) (13))); - CsrMemCpyDes(primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep128Key.key3, buffer, &offset, ((u16) (13))); - CsrMemCpyDes(primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep128Key.key4, buffer, &offset, ((u16) (13))); - break; - case CSR_WIFI_SME_CREDENTIAL_TYPE_WEP64: - CsrUint8Des((u8 *) &primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep64Key.wepAuthType, buffer, &offset); - CsrUint8Des((u8 *) &primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep64Key.selectedWepKey, buffer, &offset); - CsrMemCpyDes(primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep64Key.key1, buffer, &offset, ((u16) (5))); - CsrMemCpyDes(primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep64Key.key2, buffer, &offset, ((u16) (5))); - CsrMemCpyDes(primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep64Key.key3, buffer, &offset, ((u16) (5))); - CsrMemCpyDes(primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep64Key.key4, buffer, &offset, ((u16) (5))); - break; - default: - break; - } - break; - case CSR_WIFI_SME_AP_AUTH_TYPE_PERSONAL: - CsrUint8Des((u8 *) &primitive->apCredentials.nmeAuthType.authTypePersonal.authSupport, buffer, &offset); - CsrUint16Des((u16 *) &primitive->apCredentials.nmeAuthType.authTypePersonal.rsnCapabilities, buffer, &offset); - CsrUint16Des((u16 *) &primitive->apCredentials.nmeAuthType.authTypePersonal.wapiCapabilities, buffer, &offset); - CsrUint8Des((u8 *) &primitive->apCredentials.nmeAuthType.authTypePersonal.pskOrPassphrase, buffer, &offset); - switch (primitive->apCredentials.nmeAuthType.authTypePersonal.pskOrPassphrase) - { - case CSR_WIFI_NME_AP_CREDENTIAL_TYPE_PSK: - CsrUint16Des((u16 *) &primitive->apCredentials.nmeAuthType.authTypePersonal.authPers_credentials.psk.encryptionMode, buffer, &offset); - CsrMemCpyDes(primitive->apCredentials.nmeAuthType.authTypePersonal.authPers_credentials.psk.psk, buffer, &offset, ((u16) (32))); - break; - case CSR_WIFI_NME_AP_CREDENTIAL_TYPE_PASSPHRASE: - CsrUint16Des((u16 *) &primitive->apCredentials.nmeAuthType.authTypePersonal.authPers_credentials.passphrase.encryptionMode, buffer, &offset); - CsrCharStringDes(&primitive->apCredentials.nmeAuthType.authTypePersonal.authPers_credentials.passphrase.passphrase, buffer, &offset); - break; - default: - break; - } - break; - default: - break; - } - CsrUint8Des((u8 *) &primitive->maxConnections, buffer, &offset); - CsrUint8Des((u8 *) &primitive->p2pGoParam.groupCapability, buffer, &offset); - CsrMemCpyDes(primitive->p2pGoParam.operatingChanList.country, buffer, &offset, ((u16) (3))); - CsrUint8Des((u8 *) &primitive->p2pGoParam.operatingChanList.channelEntryListCount, buffer, &offset); - primitive->p2pGoParam.operatingChanList.channelEntryList = NULL; - if (primitive->p2pGoParam.operatingChanList.channelEntryListCount) - { - primitive->p2pGoParam.operatingChanList.channelEntryList = kmalloc(sizeof(CsrWifiSmeApP2pOperatingChanEntry) * primitive->p2pGoParam.operatingChanList.channelEntryListCount, GFP_KERNEL); - } - { - u16 i3; - for (i3 = 0; i3 < primitive->p2pGoParam.operatingChanList.channelEntryListCount; i3++) - { - CsrUint8Des((u8 *) &primitive->p2pGoParam.operatingChanList.channelEntryList[i3].operatingClass, buffer, &offset); - CsrUint8Des((u8 *) &primitive->p2pGoParam.operatingChanList.channelEntryList[i3].operatingChannelCount, buffer, &offset); - if (primitive->p2pGoParam.operatingChanList.channelEntryList[i3].operatingChannelCount) - { - primitive->p2pGoParam.operatingChanList.channelEntryList[i3].operatingChannel = kmalloc(primitive->p2pGoParam.operatingChanList.channelEntryList[i3].operatingChannelCount, GFP_KERNEL); - CsrMemCpyDes(primitive->p2pGoParam.operatingChanList.channelEntryList[i3].operatingChannel, buffer, &offset, ((u16) (primitive->p2pGoParam.operatingChanList.channelEntryList[i3].operatingChannelCount))); - } - else - { - primitive->p2pGoParam.operatingChanList.channelEntryList[i3].operatingChannel = NULL; - } - } - } - CsrUint8Des((u8 *) &primitive->p2pGoParam.opPsEnabled, buffer, &offset); - CsrUint8Des((u8 *) &primitive->p2pGoParam.ctWindow, buffer, &offset); - CsrUint8Des((u8 *) &primitive->p2pGoParam.noaConfigMethod, buffer, &offset); - CsrUint8Des((u8 *) &primitive->p2pGoParam.allowNoaWithNonP2pDevices, buffer, &offset); - CsrUint8Des((u8 *) &primitive->wpsEnabled, buffer, &offset); - - return primitive; -} - - -void CsrWifiNmeApStartReqSerFree(void *voidPrimitivePointer) -{ - CsrWifiNmeApStartReq *primitive = (CsrWifiNmeApStartReq *) voidPrimitivePointer; - switch (primitive->apCredentials.authType) - { - case CSR_WIFI_SME_AP_AUTH_TYPE_PERSONAL: - switch (primitive->apCredentials.nmeAuthType.authTypePersonal.pskOrPassphrase) - { - case CSR_WIFI_NME_AP_CREDENTIAL_TYPE_PASSPHRASE: - kfree(primitive->apCredentials.nmeAuthType.authTypePersonal.authPers_credentials.passphrase.passphrase); - break; - default: - break; - } - break; - default: - break; - } - { - u16 i3; - for (i3 = 0; i3 < primitive->p2pGoParam.operatingChanList.channelEntryListCount; i3++) - { - kfree(primitive->p2pGoParam.operatingChanList.channelEntryList[i3].operatingChannel); - } - } - kfree(primitive->p2pGoParam.operatingChanList.channelEntryList); - kfree(primitive); -} - - -size_t CsrWifiNmeApWmmParamUpdateReqSizeof(void *msg) -{ - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 51) */ - { - u16 i1; - for (i1 = 0; i1 < 4; i1++) - { - bufferSize += 1; /* u8 primitive->wmmApParams[i1].cwMin */ - bufferSize += 1; /* u8 primitive->wmmApParams[i1].cwMax */ - bufferSize += 1; /* u8 primitive->wmmApParams[i1].aifs */ - bufferSize += 2; /* u16 primitive->wmmApParams[i1].txopLimit */ - bufferSize += 1; /* u8 primitive->wmmApParams[i1].admissionControlMandatory */ - } - } - { - u16 i1; - for (i1 = 0; i1 < 4; i1++) - { - bufferSize += 1; /* u8 primitive->wmmApBcParams[i1].cwMin */ - bufferSize += 1; /* u8 primitive->wmmApBcParams[i1].cwMax */ - bufferSize += 1; /* u8 primitive->wmmApBcParams[i1].aifs */ - bufferSize += 2; /* u16 primitive->wmmApBcParams[i1].txopLimit */ - bufferSize += 1; /* u8 primitive->wmmApBcParams[i1].admissionControlMandatory */ - } - } - return bufferSize; -} - - -u8* CsrWifiNmeApWmmParamUpdateReqSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiNmeApWmmParamUpdateReq *primitive = (CsrWifiNmeApWmmParamUpdateReq *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - { - u16 i1; - for (i1 = 0; i1 < 4; i1++) - { - CsrUint8Ser(ptr, len, (u8) primitive->wmmApParams[i1].cwMin); - CsrUint8Ser(ptr, len, (u8) primitive->wmmApParams[i1].cwMax); - CsrUint8Ser(ptr, len, (u8) primitive->wmmApParams[i1].aifs); - CsrUint16Ser(ptr, len, (u16) primitive->wmmApParams[i1].txopLimit); - CsrUint8Ser(ptr, len, (u8) primitive->wmmApParams[i1].admissionControlMandatory); - } - } - { - u16 i1; - for (i1 = 0; i1 < 4; i1++) - { - CsrUint8Ser(ptr, len, (u8) primitive->wmmApBcParams[i1].cwMin); - CsrUint8Ser(ptr, len, (u8) primitive->wmmApBcParams[i1].cwMax); - CsrUint8Ser(ptr, len, (u8) primitive->wmmApBcParams[i1].aifs); - CsrUint16Ser(ptr, len, (u16) primitive->wmmApBcParams[i1].txopLimit); - CsrUint8Ser(ptr, len, (u8) primitive->wmmApBcParams[i1].admissionControlMandatory); - } - } - return(ptr); -} - - -void* CsrWifiNmeApWmmParamUpdateReqDes(u8 *buffer, size_t length) -{ - CsrWifiNmeApWmmParamUpdateReq *primitive = kmalloc(sizeof(CsrWifiNmeApWmmParamUpdateReq), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - { - u16 i1; - for (i1 = 0; i1 < 4; i1++) - { - CsrUint8Des((u8 *) &primitive->wmmApParams[i1].cwMin, buffer, &offset); - CsrUint8Des((u8 *) &primitive->wmmApParams[i1].cwMax, buffer, &offset); - CsrUint8Des((u8 *) &primitive->wmmApParams[i1].aifs, buffer, &offset); - CsrUint16Des((u16 *) &primitive->wmmApParams[i1].txopLimit, buffer, &offset); - CsrUint8Des((u8 *) &primitive->wmmApParams[i1].admissionControlMandatory, buffer, &offset); - } - } - { - u16 i1; - for (i1 = 0; i1 < 4; i1++) - { - CsrUint8Des((u8 *) &primitive->wmmApBcParams[i1].cwMin, buffer, &offset); - CsrUint8Des((u8 *) &primitive->wmmApBcParams[i1].cwMax, buffer, &offset); - CsrUint8Des((u8 *) &primitive->wmmApBcParams[i1].aifs, buffer, &offset); - CsrUint16Des((u16 *) &primitive->wmmApBcParams[i1].txopLimit, buffer, &offset); - CsrUint8Des((u8 *) &primitive->wmmApBcParams[i1].admissionControlMandatory, buffer, &offset); - } - } - - return primitive; -} - - -size_t CsrWifiNmeApStaRemoveReqSizeof(void *msg) -{ - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 12) */ - bufferSize += 2; /* u16 primitive->interfaceTag */ - bufferSize += 6; /* u8 primitive->staMacAddress.a[6] */ - bufferSize += 1; /* u8 primitive->keepBlocking */ - return bufferSize; -} - - -u8* CsrWifiNmeApStaRemoveReqSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiNmeApStaRemoveReq *primitive = (CsrWifiNmeApStaRemoveReq *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag); - CsrMemCpySer(ptr, len, (const void *) primitive->staMacAddress.a, ((u16) (6))); - CsrUint8Ser(ptr, len, (u8) primitive->keepBlocking); - return(ptr); -} - - -void* CsrWifiNmeApStaRemoveReqDes(u8 *buffer, size_t length) -{ - CsrWifiNmeApStaRemoveReq *primitive = kmalloc(sizeof(CsrWifiNmeApStaRemoveReq), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset); - CsrMemCpyDes(primitive->staMacAddress.a, buffer, &offset, ((u16) (6))); - CsrUint8Des((u8 *) &primitive->keepBlocking, buffer, &offset); - - return primitive; -} - - -size_t CsrWifiNmeApWpsRegisterCfmSizeof(void *msg) -{ - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 7) */ - bufferSize += 2; /* u16 primitive->interfaceTag */ - bufferSize += 2; /* CsrResult primitive->status */ - return bufferSize; -} - - -u8* CsrWifiNmeApWpsRegisterCfmSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiNmeApWpsRegisterCfm *primitive = (CsrWifiNmeApWpsRegisterCfm *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag); - CsrUint16Ser(ptr, len, (u16) primitive->status); - return(ptr); -} - - -void* CsrWifiNmeApWpsRegisterCfmDes(u8 *buffer, size_t length) -{ - CsrWifiNmeApWpsRegisterCfm *primitive = kmalloc(sizeof(CsrWifiNmeApWpsRegisterCfm), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset); - CsrUint16Des((u16 *) &primitive->status, buffer, &offset); - - return primitive; -} - - -size_t CsrWifiNmeApStartCfmSizeof(void *msg) -{ - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 40) */ - bufferSize += 2; /* u16 primitive->interfaceTag */ - bufferSize += 2; /* CsrResult primitive->status */ - bufferSize += 32; /* u8 primitive->ssid.ssid[32] */ - bufferSize += 1; /* u8 primitive->ssid.length */ - return bufferSize; -} - - -u8* CsrWifiNmeApStartCfmSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiNmeApStartCfm *primitive = (CsrWifiNmeApStartCfm *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag); - CsrUint16Ser(ptr, len, (u16) primitive->status); - CsrMemCpySer(ptr, len, (const void *) primitive->ssid.ssid, ((u16) (32))); - CsrUint8Ser(ptr, len, (u8) primitive->ssid.length); - return(ptr); -} - - -void* CsrWifiNmeApStartCfmDes(u8 *buffer, size_t length) -{ - CsrWifiNmeApStartCfm *primitive = kmalloc(sizeof(CsrWifiNmeApStartCfm), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset); - CsrUint16Des((u16 *) &primitive->status, buffer, &offset); - CsrMemCpyDes(primitive->ssid.ssid, buffer, &offset, ((u16) (32))); - CsrUint8Des((u8 *) &primitive->ssid.length, buffer, &offset); - - return primitive; -} - - -size_t CsrWifiNmeApStopCfmSizeof(void *msg) -{ - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 7) */ - bufferSize += 2; /* u16 primitive->interfaceTag */ - bufferSize += 2; /* CsrResult primitive->status */ - return bufferSize; -} - - -u8* CsrWifiNmeApStopCfmSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiNmeApStopCfm *primitive = (CsrWifiNmeApStopCfm *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag); - CsrUint16Ser(ptr, len, (u16) primitive->status); - return(ptr); -} - - -void* CsrWifiNmeApStopCfmDes(u8 *buffer, size_t length) -{ - CsrWifiNmeApStopCfm *primitive = kmalloc(sizeof(CsrWifiNmeApStopCfm), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset); - CsrUint16Des((u16 *) &primitive->status, buffer, &offset); - - return primitive; -} - - -size_t CsrWifiNmeApStopIndSizeof(void *msg) -{ - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 8) */ - bufferSize += 2; /* u16 primitive->interfaceTag */ - bufferSize += 1; /* CsrWifiSmeApType primitive->apType */ - bufferSize += 2; /* CsrResult primitive->status */ - return bufferSize; -} - - -u8* CsrWifiNmeApStopIndSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiNmeApStopInd *primitive = (CsrWifiNmeApStopInd *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag); - CsrUint8Ser(ptr, len, (u8) primitive->apType); - CsrUint16Ser(ptr, len, (u16) primitive->status); - return(ptr); -} - - -void* CsrWifiNmeApStopIndDes(u8 *buffer, size_t length) -{ - CsrWifiNmeApStopInd *primitive = kmalloc(sizeof(CsrWifiNmeApStopInd), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset); - CsrUint8Des((u8 *) &primitive->apType, buffer, &offset); - CsrUint16Des((u16 *) &primitive->status, buffer, &offset); - - return primitive; -} - - -size_t CsrWifiNmeApStationIndSizeof(void *msg) -{ - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 18) */ - bufferSize += 2; /* u16 primitive->interfaceTag */ - bufferSize += 1; /* CsrWifiSmeMediaStatus primitive->mediaStatus */ - bufferSize += 6; /* u8 primitive->peerMacAddress.a[6] */ - bufferSize += 6; /* u8 primitive->peerDeviceAddress.a[6] */ - return bufferSize; -} - - -u8* CsrWifiNmeApStationIndSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiNmeApStationInd *primitive = (CsrWifiNmeApStationInd *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag); - CsrUint8Ser(ptr, len, (u8) primitive->mediaStatus); - CsrMemCpySer(ptr, len, (const void *) primitive->peerMacAddress.a, ((u16) (6))); - CsrMemCpySer(ptr, len, (const void *) primitive->peerDeviceAddress.a, ((u16) (6))); - return(ptr); -} - - -void* CsrWifiNmeApStationIndDes(u8 *buffer, size_t length) -{ - CsrWifiNmeApStationInd *primitive = kmalloc(sizeof(CsrWifiNmeApStationInd), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset); - CsrUint8Des((u8 *) &primitive->mediaStatus, buffer, &offset); - CsrMemCpyDes(primitive->peerMacAddress.a, buffer, &offset, ((u16) (6))); - CsrMemCpyDes(primitive->peerDeviceAddress.a, buffer, &offset, ((u16) (6))); - - return primitive; -} - - -#endif /* CSR_WIFI_NME_ENABLE */ -#endif /* CSR_WIFI_AP_ENABLE */ diff --git a/drivers/staging/csr/csr_wifi_nme_ap_serialize.h b/drivers/staging/csr/csr_wifi_nme_ap_serialize.h deleted file mode 100644 index c04585e72460..000000000000 --- a/drivers/staging/csr/csr_wifi_nme_ap_serialize.h +++ /dev/null @@ -1,94 +0,0 @@ -/***************************************************************************** - - (c) Cambridge Silicon Radio Limited 2011 - All rights reserved and confidential information of CSR - - Refer to LICENSE.txt included with this source for details - on the license terms. - -*****************************************************************************/ - -/* Note: this is an auto-generated file. */ - -#ifndef CSR_WIFI_NME_AP_SERIALIZE_H__ -#define CSR_WIFI_NME_AP_SERIALIZE_H__ - -#include "csr_wifi_msgconv.h" - -#include "csr_wifi_nme_ap_prim.h" - -#ifndef CSR_WIFI_NME_ENABLE -#error CSR_WIFI_NME_ENABLE MUST be defined inorder to use csr_wifi_nme_ap_serialize.h -#endif -#ifndef CSR_WIFI_AP_ENABLE -#error CSR_WIFI_AP_ENABLE MUST be defined inorder to use csr_wifi_nme_ap_serialize.h -#endif - -extern void CsrWifiNmeApPfree(void *ptr); - -extern u8* CsrWifiNmeApConfigSetReqSer(u8 *ptr, size_t *len, void *msg); -extern void* CsrWifiNmeApConfigSetReqDes(u8 *buffer, size_t len); -extern size_t CsrWifiNmeApConfigSetReqSizeof(void *msg); -extern void CsrWifiNmeApConfigSetReqSerFree(void *msg); - -extern u8* CsrWifiNmeApWpsRegisterReqSer(u8 *ptr, size_t *len, void *msg); -extern void* CsrWifiNmeApWpsRegisterReqDes(u8 *buffer, size_t len); -extern size_t CsrWifiNmeApWpsRegisterReqSizeof(void *msg); -#define CsrWifiNmeApWpsRegisterReqSerFree CsrWifiNmeApPfree - -extern u8* CsrWifiNmeApStartReqSer(u8 *ptr, size_t *len, void *msg); -extern void* CsrWifiNmeApStartReqDes(u8 *buffer, size_t len); -extern size_t CsrWifiNmeApStartReqSizeof(void *msg); -extern void CsrWifiNmeApStartReqSerFree(void *msg); - -#define CsrWifiNmeApStopReqSer CsrWifiEventCsrUint16Ser -#define CsrWifiNmeApStopReqDes CsrWifiEventCsrUint16Des -#define CsrWifiNmeApStopReqSizeof CsrWifiEventCsrUint16Sizeof -#define CsrWifiNmeApStopReqSerFree CsrWifiNmeApPfree - -extern u8* CsrWifiNmeApWmmParamUpdateReqSer(u8 *ptr, size_t *len, void *msg); -extern void* CsrWifiNmeApWmmParamUpdateReqDes(u8 *buffer, size_t len); -extern size_t CsrWifiNmeApWmmParamUpdateReqSizeof(void *msg); -#define CsrWifiNmeApWmmParamUpdateReqSerFree CsrWifiNmeApPfree - -extern u8* CsrWifiNmeApStaRemoveReqSer(u8 *ptr, size_t *len, void *msg); -extern void* CsrWifiNmeApStaRemoveReqDes(u8 *buffer, size_t len); -extern size_t CsrWifiNmeApStaRemoveReqSizeof(void *msg); -#define CsrWifiNmeApStaRemoveReqSerFree CsrWifiNmeApPfree - -#define CsrWifiNmeApConfigSetCfmSer CsrWifiEventCsrUint16Ser -#define CsrWifiNmeApConfigSetCfmDes CsrWifiEventCsrUint16Des -#define CsrWifiNmeApConfigSetCfmSizeof CsrWifiEventCsrUint16Sizeof -#define CsrWifiNmeApConfigSetCfmSerFree CsrWifiNmeApPfree - -extern u8* CsrWifiNmeApWpsRegisterCfmSer(u8 *ptr, size_t *len, void *msg); -extern void* CsrWifiNmeApWpsRegisterCfmDes(u8 *buffer, size_t len); -extern size_t CsrWifiNmeApWpsRegisterCfmSizeof(void *msg); -#define CsrWifiNmeApWpsRegisterCfmSerFree CsrWifiNmeApPfree - -extern u8* CsrWifiNmeApStartCfmSer(u8 *ptr, size_t *len, void *msg); -extern void* CsrWifiNmeApStartCfmDes(u8 *buffer, size_t len); -extern size_t CsrWifiNmeApStartCfmSizeof(void *msg); -#define CsrWifiNmeApStartCfmSerFree CsrWifiNmeApPfree - -extern u8* CsrWifiNmeApStopCfmSer(u8 *ptr, size_t *len, void *msg); -extern void* CsrWifiNmeApStopCfmDes(u8 *buffer, size_t len); -extern size_t CsrWifiNmeApStopCfmSizeof(void *msg); -#define CsrWifiNmeApStopCfmSerFree CsrWifiNmeApPfree - -extern u8* CsrWifiNmeApStopIndSer(u8 *ptr, size_t *len, void *msg); -extern void* CsrWifiNmeApStopIndDes(u8 *buffer, size_t len); -extern size_t CsrWifiNmeApStopIndSizeof(void *msg); -#define CsrWifiNmeApStopIndSerFree CsrWifiNmeApPfree - -#define CsrWifiNmeApWmmParamUpdateCfmSer CsrWifiEventCsrUint16Ser -#define CsrWifiNmeApWmmParamUpdateCfmDes CsrWifiEventCsrUint16Des -#define CsrWifiNmeApWmmParamUpdateCfmSizeof CsrWifiEventCsrUint16Sizeof -#define CsrWifiNmeApWmmParamUpdateCfmSerFree CsrWifiNmeApPfree - -extern u8* CsrWifiNmeApStationIndSer(u8 *ptr, size_t *len, void *msg); -extern void* CsrWifiNmeApStationIndDes(u8 *buffer, size_t len); -extern size_t CsrWifiNmeApStationIndSizeof(void *msg); -#define CsrWifiNmeApStationIndSerFree CsrWifiNmeApPfree - -#endif /* CSR_WIFI_NME_AP_SERIALIZE_H__ */ diff --git a/drivers/staging/csr/csr_wifi_nme_converter_init.h b/drivers/staging/csr/csr_wifi_nme_converter_init.h deleted file mode 100644 index 85e6f5f57130..000000000000 --- a/drivers/staging/csr/csr_wifi_nme_converter_init.h +++ /dev/null @@ -1,38 +0,0 @@ -/***************************************************************************** - - (c) Cambridge Silicon Radio Limited 2011 - All rights reserved and confidential information of CSR - - Refer to LICENSE.txt included with this source for details - on the license terms. - -*****************************************************************************/ - -/* Note: this is an auto-generated file. */ - -#ifndef CSR_WIFI_NME_CONVERTER_INIT_H__ -#define CSR_WIFI_NME_CONVERTER_INIT_H__ - -#ifndef CSR_WIFI_NME_ENABLE -#error CSR_WIFI_NME_ENABLE MUST be defined inorder to use csr_wifi_nme_converter_init.h -#endif - -#ifndef EXCLUDE_CSR_WIFI_NME_MODULE - -#include "csr_msgconv.h" - -#ifdef CSR_LOG_ENABLE -#include "csr_log.h" - -extern const CsrLogPrimitiveInformation* CsrWifiNmeTechInfoGet(void); -#endif /* CSR_LOG_ENABLE */ - -extern void CsrWifiNmeConverterInit(void); - -#else /* EXCLUDE_CSR_WIFI_NME_MODULE */ - -#define CsrWifiNmeConverterInit() - -#endif /* EXCLUDE_CSR_WIFI_NME_MODULE */ - -#endif /* CSR_WIFI_NME_CONVERTER_INIT_H__ */ diff --git a/drivers/staging/csr/csr_wifi_nme_lib.h b/drivers/staging/csr/csr_wifi_nme_lib.h deleted file mode 100644 index 5a1f132009bf..000000000000 --- a/drivers/staging/csr/csr_wifi_nme_lib.h +++ /dev/null @@ -1,991 +0,0 @@ -/***************************************************************************** - - (c) Cambridge Silicon Radio Limited 2011 - All rights reserved and confidential information of CSR - - Refer to LICENSE.txt included with this source for details - on the license terms. - -*****************************************************************************/ - -/* Note: this is an auto-generated file. */ - -#ifndef CSR_WIFI_NME_LIB_H__ -#define CSR_WIFI_NME_LIB_H__ - -#include "csr_sched.h" -#include "csr_macro.h" -#include "csr_msg_transport.h" - -#include "csr_wifi_lib.h" - -#include "csr_wifi_nme_prim.h" -#include "csr_wifi_nme_task.h" - - -#ifndef CSR_WIFI_NME_ENABLE -#error CSR_WIFI_NME_ENABLE MUST be defined inorder to use csr_wifi_nme_lib.h -#endif - -/******************************************************************************* - - NAME - CsrWifiNmeConnectionStatusGetReqSend - - DESCRIPTION - Requests the current connection status of the NME. - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - interfaceTag - Interface Identifier; unique identifier of an interface - -*******************************************************************************/ -#define CsrWifiNmeConnectionStatusGetReqCreate(msg__, dst__, src__, interfaceTag__) \ - msg__ = kmalloc(sizeof(CsrWifiNmeConnectionStatusGetReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_CONNECTION_STATUS_GET_REQ, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); - -#define CsrWifiNmeConnectionStatusGetReqSendTo(dst__, src__, interfaceTag__) \ - { \ - CsrWifiNmeConnectionStatusGetReq *msg__; \ - CsrWifiNmeConnectionStatusGetReqCreate(msg__, dst__, src__, interfaceTag__); \ - CsrMsgTransport(dst__, CSR_WIFI_NME_PRIM, msg__); \ - } - -#define CsrWifiNmeConnectionStatusGetReqSend(src__, interfaceTag__) \ - CsrWifiNmeConnectionStatusGetReqSendTo(CSR_WIFI_NME_IFACEQUEUE, src__, interfaceTag__) - -/******************************************************************************* - - NAME - CsrWifiNmeConnectionStatusGetCfmSend - - DESCRIPTION - Reports the connection status of the NME. - - PARAMETERS - queue - Destination Task Queue - interfaceTag - Interface Identifier; unique identifier of an interface - status - Indicates the success or otherwise of the requested - operation. - connectionStatus - NME current connection status - -*******************************************************************************/ -#define CsrWifiNmeConnectionStatusGetCfmCreate(msg__, dst__, src__, interfaceTag__, status__, connectionStatus__) \ - msg__ = kmalloc(sizeof(CsrWifiNmeConnectionStatusGetCfm), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_CONNECTION_STATUS_GET_CFM, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->status = (status__); \ - msg__->connectionStatus = (connectionStatus__); - -#define CsrWifiNmeConnectionStatusGetCfmSendTo(dst__, src__, interfaceTag__, status__, connectionStatus__) \ - { \ - CsrWifiNmeConnectionStatusGetCfm *msg__; \ - CsrWifiNmeConnectionStatusGetCfmCreate(msg__, dst__, src__, interfaceTag__, status__, connectionStatus__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_NME_PRIM, msg__); \ - } - -#define CsrWifiNmeConnectionStatusGetCfmSend(dst__, interfaceTag__, status__, connectionStatus__) \ - CsrWifiNmeConnectionStatusGetCfmSendTo(dst__, CSR_WIFI_NME_IFACEQUEUE, interfaceTag__, status__, connectionStatus__) - -/******************************************************************************* - - NAME - CsrWifiNmeEventMaskSetReqSend - - DESCRIPTION - The wireless manager application may register with the NME to receive - notification of interesting events. Indications will be sent only if the - wireless manager explicitly registers to be notified of that event. - indMask is a bit mask of values defined in CsrWifiNmeIndicationsMask. - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - indMask - Set mask with values from CsrWifiNmeIndications - -*******************************************************************************/ -#define CsrWifiNmeEventMaskSetReqCreate(msg__, dst__, src__, indMask__) \ - msg__ = kmalloc(sizeof(CsrWifiNmeEventMaskSetReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_EVENT_MASK_SET_REQ, dst__, src__); \ - msg__->indMask = (indMask__); - -#define CsrWifiNmeEventMaskSetReqSendTo(dst__, src__, indMask__) \ - { \ - CsrWifiNmeEventMaskSetReq *msg__; \ - CsrWifiNmeEventMaskSetReqCreate(msg__, dst__, src__, indMask__); \ - CsrMsgTransport(dst__, CSR_WIFI_NME_PRIM, msg__); \ - } - -#define CsrWifiNmeEventMaskSetReqSend(src__, indMask__) \ - CsrWifiNmeEventMaskSetReqSendTo(CSR_WIFI_NME_IFACEQUEUE, src__, indMask__) - -/******************************************************************************* - - NAME - CsrWifiNmeEventMaskSetCfmSend - - DESCRIPTION - The NME calls the primitive to report the result of the request - primitive. - - PARAMETERS - queue - Destination Task Queue - status - Reports the result of the request - -*******************************************************************************/ -#define CsrWifiNmeEventMaskSetCfmCreate(msg__, dst__, src__, status__) \ - msg__ = kmalloc(sizeof(CsrWifiNmeEventMaskSetCfm), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_EVENT_MASK_SET_CFM, dst__, src__); \ - msg__->status = (status__); - -#define CsrWifiNmeEventMaskSetCfmSendTo(dst__, src__, status__) \ - { \ - CsrWifiNmeEventMaskSetCfm *msg__; \ - CsrWifiNmeEventMaskSetCfmCreate(msg__, dst__, src__, status__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_NME_PRIM, msg__); \ - } - -#define CsrWifiNmeEventMaskSetCfmSend(dst__, status__) \ - CsrWifiNmeEventMaskSetCfmSendTo(dst__, CSR_WIFI_NME_IFACEQUEUE, status__) - -/******************************************************************************* - - NAME - CsrWifiNmeProfileConnectReqSend - - DESCRIPTION - Requests the NME to attempt to connect to the specified profile. - Overrides any current connection attempt. - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - interfaceTag - Interface Identifier; unique identifier of an interface - profileIdentity - Identity (BSSID, SSID) of profile to be connected to. - It must match an existing profile in the NME. - -*******************************************************************************/ -#define CsrWifiNmeProfileConnectReqCreate(msg__, dst__, src__, interfaceTag__, profileIdentity__) \ - msg__ = kmalloc(sizeof(CsrWifiNmeProfileConnectReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_PROFILE_CONNECT_REQ, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->profileIdentity = (profileIdentity__); - -#define CsrWifiNmeProfileConnectReqSendTo(dst__, src__, interfaceTag__, profileIdentity__) \ - { \ - CsrWifiNmeProfileConnectReq *msg__; \ - CsrWifiNmeProfileConnectReqCreate(msg__, dst__, src__, interfaceTag__, profileIdentity__); \ - CsrMsgTransport(dst__, CSR_WIFI_NME_PRIM, msg__); \ - } - -#define CsrWifiNmeProfileConnectReqSend(src__, interfaceTag__, profileIdentity__) \ - CsrWifiNmeProfileConnectReqSendTo(CSR_WIFI_NME_IFACEQUEUE, src__, interfaceTag__, profileIdentity__) - -/******************************************************************************* - - NAME - CsrWifiNmeProfileConnectCfmSend - - DESCRIPTION - Reports the status of the NME PROFILE CONNECT REQ. If unsuccessful the - connectAttempt parameters contain details of the APs that the NME - attempted to connect to before reporting the failure of the request. - - PARAMETERS - queue - Destination Task Queue - interfaceTag - Interface Identifier; unique identifier of an - interface - status - Indicates the success or otherwise of the requested - operation. - connectAttemptsCount - This parameter is relevant only if - status!=CSR_WIFI_NME_STATUS_SUCCESS. - Number of connection attempt elements provided with - this primitive - connectAttempts - This parameter is relevant only if - status!=CSR_WIFI_NME_STATUS_SUCCESS. - Points to the list of connection attempt elements - provided with this primitive - Each element of the list provides information about - an AP on which the connection attempt was made and - the error that occurred during the attempt. - -*******************************************************************************/ -#define CsrWifiNmeProfileConnectCfmCreate(msg__, dst__, src__, interfaceTag__, status__, connectAttemptsCount__, connectAttempts__) \ - msg__ = kmalloc(sizeof(CsrWifiNmeProfileConnectCfm), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_PROFILE_CONNECT_CFM, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->status = (status__); \ - msg__->connectAttemptsCount = (connectAttemptsCount__); \ - msg__->connectAttempts = (connectAttempts__); - -#define CsrWifiNmeProfileConnectCfmSendTo(dst__, src__, interfaceTag__, status__, connectAttemptsCount__, connectAttempts__) \ - { \ - CsrWifiNmeProfileConnectCfm *msg__; \ - CsrWifiNmeProfileConnectCfmCreate(msg__, dst__, src__, interfaceTag__, status__, connectAttemptsCount__, connectAttempts__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_NME_PRIM, msg__); \ - } - -#define CsrWifiNmeProfileConnectCfmSend(dst__, interfaceTag__, status__, connectAttemptsCount__, connectAttempts__) \ - CsrWifiNmeProfileConnectCfmSendTo(dst__, CSR_WIFI_NME_IFACEQUEUE, interfaceTag__, status__, connectAttemptsCount__, connectAttempts__) - -/******************************************************************************* - - NAME - CsrWifiNmeProfileDeleteAllReqSend - - DESCRIPTION - Deletes all profiles present in the NME, but does NOT modify the - preferred profile list. - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - -*******************************************************************************/ -#define CsrWifiNmeProfileDeleteAllReqCreate(msg__, dst__, src__) \ - msg__ = kmalloc(sizeof(CsrWifiNmeProfileDeleteAllReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_PROFILE_DELETE_ALL_REQ, dst__, src__); - -#define CsrWifiNmeProfileDeleteAllReqSendTo(dst__, src__) \ - { \ - CsrWifiNmeProfileDeleteAllReq *msg__; \ - CsrWifiNmeProfileDeleteAllReqCreate(msg__, dst__, src__); \ - CsrMsgTransport(dst__, CSR_WIFI_NME_PRIM, msg__); \ - } - -#define CsrWifiNmeProfileDeleteAllReqSend(src__) \ - CsrWifiNmeProfileDeleteAllReqSendTo(CSR_WIFI_NME_IFACEQUEUE, src__) - -/******************************************************************************* - - NAME - CsrWifiNmeProfileDeleteAllCfmSend - - DESCRIPTION - Reports the status of the CSR_WIFI_NME_PROFILE_DELETE_ALL_REQ. - Returns always CSR_WIFI_NME_STATUS_SUCCESS. - - PARAMETERS - queue - Destination Task Queue - status - Indicates the success or otherwise of the requested operation, but - in this case it always set to success. - -*******************************************************************************/ -#define CsrWifiNmeProfileDeleteAllCfmCreate(msg__, dst__, src__, status__) \ - msg__ = kmalloc(sizeof(CsrWifiNmeProfileDeleteAllCfm), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_PROFILE_DELETE_ALL_CFM, dst__, src__); \ - msg__->status = (status__); - -#define CsrWifiNmeProfileDeleteAllCfmSendTo(dst__, src__, status__) \ - { \ - CsrWifiNmeProfileDeleteAllCfm *msg__; \ - CsrWifiNmeProfileDeleteAllCfmCreate(msg__, dst__, src__, status__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_NME_PRIM, msg__); \ - } - -#define CsrWifiNmeProfileDeleteAllCfmSend(dst__, status__) \ - CsrWifiNmeProfileDeleteAllCfmSendTo(dst__, CSR_WIFI_NME_IFACEQUEUE, status__) - -/******************************************************************************* - - NAME - CsrWifiNmeProfileDeleteReqSend - - DESCRIPTION - Will delete the profile with a matching identity, but does NOT modify the - preferred profile list. - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - profileIdentity - Identity (BSSID, SSID) of profile to be deleted. - -*******************************************************************************/ -#define CsrWifiNmeProfileDeleteReqCreate(msg__, dst__, src__, profileIdentity__) \ - msg__ = kmalloc(sizeof(CsrWifiNmeProfileDeleteReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_PROFILE_DELETE_REQ, dst__, src__); \ - msg__->profileIdentity = (profileIdentity__); - -#define CsrWifiNmeProfileDeleteReqSendTo(dst__, src__, profileIdentity__) \ - { \ - CsrWifiNmeProfileDeleteReq *msg__; \ - CsrWifiNmeProfileDeleteReqCreate(msg__, dst__, src__, profileIdentity__); \ - CsrMsgTransport(dst__, CSR_WIFI_NME_PRIM, msg__); \ - } - -#define CsrWifiNmeProfileDeleteReqSend(src__, profileIdentity__) \ - CsrWifiNmeProfileDeleteReqSendTo(CSR_WIFI_NME_IFACEQUEUE, src__, profileIdentity__) - -/******************************************************************************* - - NAME - CsrWifiNmeProfileDeleteCfmSend - - DESCRIPTION - Reports the status of the CSR_WIFI_NME_PROFILE_DELETE_REQ. - Returns CSR_WIFI_NME_STATUS_NOT_FOUND if there is no matching profile. - - PARAMETERS - queue - Destination Task Queue - status - Indicates the success or otherwise of the requested operation. - -*******************************************************************************/ -#define CsrWifiNmeProfileDeleteCfmCreate(msg__, dst__, src__, status__) \ - msg__ = kmalloc(sizeof(CsrWifiNmeProfileDeleteCfm), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_PROFILE_DELETE_CFM, dst__, src__); \ - msg__->status = (status__); - -#define CsrWifiNmeProfileDeleteCfmSendTo(dst__, src__, status__) \ - { \ - CsrWifiNmeProfileDeleteCfm *msg__; \ - CsrWifiNmeProfileDeleteCfmCreate(msg__, dst__, src__, status__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_NME_PRIM, msg__); \ - } - -#define CsrWifiNmeProfileDeleteCfmSend(dst__, status__) \ - CsrWifiNmeProfileDeleteCfmSendTo(dst__, CSR_WIFI_NME_IFACEQUEUE, status__) - -/******************************************************************************* - - NAME - CsrWifiNmeProfileDisconnectIndSend - - DESCRIPTION - Indication generated from the NME (if an application subscribes to - receive it) that informs that application that the current profile - connection has disconnected. The indication will contain information - about APs that it attempted to maintain the connection via i.e. in the - case of failed roaming. - - PARAMETERS - queue - Destination Task Queue - interfaceTag - Interface Identifier; unique identifier of an - interface - connectAttemptsCount - Number of connection attempt elements provided with - this primitive - connectAttempts - Points to the list of connection attempt elements - provided with this primitive - Each element of the list provides information about - an AP on which the connection attempt was made and - the error occurred during the attempt. - -*******************************************************************************/ -#define CsrWifiNmeProfileDisconnectIndCreate(msg__, dst__, src__, interfaceTag__, connectAttemptsCount__, connectAttempts__) \ - msg__ = kmalloc(sizeof(CsrWifiNmeProfileDisconnectInd), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_PROFILE_DISCONNECT_IND, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->connectAttemptsCount = (connectAttemptsCount__); \ - msg__->connectAttempts = (connectAttempts__); - -#define CsrWifiNmeProfileDisconnectIndSendTo(dst__, src__, interfaceTag__, connectAttemptsCount__, connectAttempts__) \ - { \ - CsrWifiNmeProfileDisconnectInd *msg__; \ - CsrWifiNmeProfileDisconnectIndCreate(msg__, dst__, src__, interfaceTag__, connectAttemptsCount__, connectAttempts__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_NME_PRIM, msg__); \ - } - -#define CsrWifiNmeProfileDisconnectIndSend(dst__, interfaceTag__, connectAttemptsCount__, connectAttempts__) \ - CsrWifiNmeProfileDisconnectIndSendTo(dst__, CSR_WIFI_NME_IFACEQUEUE, interfaceTag__, connectAttemptsCount__, connectAttempts__) - -/******************************************************************************* - - NAME - CsrWifiNmeProfileOrderSetReqSend - - DESCRIPTION - Defines the preferred order that profiles present in the NME should be - used during the NME auto-connect behaviour. - If profileIdentitysCount == 0, it removes any existing preferred profile - list already present in the NME, effectively disabling the auto-connect - behaviour. - NOTE: Profile identities that do not match any profile stored in the NME - are ignored during the auto-connect procedure. - NOTE: during auto-connect the NME will only attempt to join an existing - adhoc network and it will never attempt to host an adhoc network; for - hosting and adhoc network, use CSR_WIFI_NME_PROFILE_CONNECT_REQ - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - interfaceTag - Interface Identifier; unique identifier of an - interface - profileIdentitysCount - The number of profiles identities in the list. - profileIdentitys - Points to the list of profile identities. - -*******************************************************************************/ -#define CsrWifiNmeProfileOrderSetReqCreate(msg__, dst__, src__, interfaceTag__, profileIdentitysCount__, profileIdentitys__) \ - msg__ = kmalloc(sizeof(CsrWifiNmeProfileOrderSetReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_PROFILE_ORDER_SET_REQ, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->profileIdentitysCount = (profileIdentitysCount__); \ - msg__->profileIdentitys = (profileIdentitys__); - -#define CsrWifiNmeProfileOrderSetReqSendTo(dst__, src__, interfaceTag__, profileIdentitysCount__, profileIdentitys__) \ - { \ - CsrWifiNmeProfileOrderSetReq *msg__; \ - CsrWifiNmeProfileOrderSetReqCreate(msg__, dst__, src__, interfaceTag__, profileIdentitysCount__, profileIdentitys__); \ - CsrMsgTransport(dst__, CSR_WIFI_NME_PRIM, msg__); \ - } - -#define CsrWifiNmeProfileOrderSetReqSend(src__, interfaceTag__, profileIdentitysCount__, profileIdentitys__) \ - CsrWifiNmeProfileOrderSetReqSendTo(CSR_WIFI_NME_IFACEQUEUE, src__, interfaceTag__, profileIdentitysCount__, profileIdentitys__) - -/******************************************************************************* - - NAME - CsrWifiNmeProfileOrderSetCfmSend - - DESCRIPTION - Confirmation to UNIFI_NME_PROFILE_ORDER_SET.request. - - PARAMETERS - queue - Destination Task Queue - interfaceTag - Interface Identifier; unique identifier of an interface - status - Indicates the success or otherwise of the requested - operation. - -*******************************************************************************/ -#define CsrWifiNmeProfileOrderSetCfmCreate(msg__, dst__, src__, interfaceTag__, status__) \ - msg__ = kmalloc(sizeof(CsrWifiNmeProfileOrderSetCfm), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_PROFILE_ORDER_SET_CFM, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->status = (status__); - -#define CsrWifiNmeProfileOrderSetCfmSendTo(dst__, src__, interfaceTag__, status__) \ - { \ - CsrWifiNmeProfileOrderSetCfm *msg__; \ - CsrWifiNmeProfileOrderSetCfmCreate(msg__, dst__, src__, interfaceTag__, status__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_NME_PRIM, msg__); \ - } - -#define CsrWifiNmeProfileOrderSetCfmSend(dst__, interfaceTag__, status__) \ - CsrWifiNmeProfileOrderSetCfmSendTo(dst__, CSR_WIFI_NME_IFACEQUEUE, interfaceTag__, status__) - -/******************************************************************************* - - NAME - CsrWifiNmeProfileSetReqSend - - DESCRIPTION - Creates or updates an existing profile in the NME that matches the unique - identity of the profile. Each profile is identified by the combination of - BSSID and SSID. The profile contains all the required credentials for - attempting to connect to the network. Creating or updating a profile via - the NME PROFILE SET REQ does NOT add the profile to the preferred profile - list within the NME used for the NME auto-connect behaviour. - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - profile - Specifies the identity and credentials of the network. - -*******************************************************************************/ -#define CsrWifiNmeProfileSetReqCreate(msg__, dst__, src__, profile__) \ - msg__ = kmalloc(sizeof(CsrWifiNmeProfileSetReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_PROFILE_SET_REQ, dst__, src__); \ - msg__->profile = (profile__); - -#define CsrWifiNmeProfileSetReqSendTo(dst__, src__, profile__) \ - { \ - CsrWifiNmeProfileSetReq *msg__; \ - CsrWifiNmeProfileSetReqCreate(msg__, dst__, src__, profile__); \ - CsrMsgTransport(dst__, CSR_WIFI_NME_PRIM, msg__); \ - } - -#define CsrWifiNmeProfileSetReqSend(src__, profile__) \ - CsrWifiNmeProfileSetReqSendTo(CSR_WIFI_NME_IFACEQUEUE, src__, profile__) - -/******************************************************************************* - - NAME - CsrWifiNmeProfileSetCfmSend - - DESCRIPTION - Reports the status of the NME PROFILE SET REQ; the request will only fail - if the details specified in the profile contains an invalid combination - of parameters for example specifying the profile as cloaked but not - specifying the SSID. The NME doesn't limit the number of profiles that - may be created. The NME assumes that the entity configuring it is aware - of the appropriate limits. - - PARAMETERS - queue - Destination Task Queue - status - Indicates the success or otherwise of the requested operation. - -*******************************************************************************/ -#define CsrWifiNmeProfileSetCfmCreate(msg__, dst__, src__, status__) \ - msg__ = kmalloc(sizeof(CsrWifiNmeProfileSetCfm), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_PROFILE_SET_CFM, dst__, src__); \ - msg__->status = (status__); - -#define CsrWifiNmeProfileSetCfmSendTo(dst__, src__, status__) \ - { \ - CsrWifiNmeProfileSetCfm *msg__; \ - CsrWifiNmeProfileSetCfmCreate(msg__, dst__, src__, status__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_NME_PRIM, msg__); \ - } - -#define CsrWifiNmeProfileSetCfmSend(dst__, status__) \ - CsrWifiNmeProfileSetCfmSendTo(dst__, CSR_WIFI_NME_IFACEQUEUE, status__) - -/******************************************************************************* - - NAME - CsrWifiNmeProfileUpdateIndSend - - DESCRIPTION - Indication generated from the NME (if an application subscribes to - receive it) that informs that application that the contained profile has - changed. - For example, either the credentials EAP-FAST PAC file or the session data - within the profile has changed. - It is up to the application whether it stores this updated profile or - not. - - PARAMETERS - queue - Destination Task Queue - interfaceTag - Interface Identifier; unique identifier of an interface - profile - The identity and credentials of the network. - -*******************************************************************************/ -#define CsrWifiNmeProfileUpdateIndCreate(msg__, dst__, src__, interfaceTag__, profile__) \ - msg__ = kmalloc(sizeof(CsrWifiNmeProfileUpdateInd), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_PROFILE_UPDATE_IND, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->profile = (profile__); - -#define CsrWifiNmeProfileUpdateIndSendTo(dst__, src__, interfaceTag__, profile__) \ - { \ - CsrWifiNmeProfileUpdateInd *msg__; \ - CsrWifiNmeProfileUpdateIndCreate(msg__, dst__, src__, interfaceTag__, profile__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_NME_PRIM, msg__); \ - } - -#define CsrWifiNmeProfileUpdateIndSend(dst__, interfaceTag__, profile__) \ - CsrWifiNmeProfileUpdateIndSendTo(dst__, CSR_WIFI_NME_IFACEQUEUE, interfaceTag__, profile__) - -/******************************************************************************* - - NAME - CsrWifiNmeSimGsmAuthIndSend - - DESCRIPTION - Indication generated from the NME (if an application subscribes to - receive it) that requests the UICC Manager to perform a GSM - authentication on behalf of the NME. This indication is generated when - the NME is attempting to connect to a profile configured for EAP-SIM. An - application MUST register to receive this indication for the NME to - support the EAP-SIM credential types. Otherwise the NME has no route to - obtain the information from the UICC. EAP-SIM authentication requires 2 - or 3 GSM authentication rounds and therefore 2 or 3 RANDS (GSM Random - Challenges) are included. - - PARAMETERS - queue - Destination Task Queue - randsLength - GSM RAND is 16 bytes long hence valid values are 32 (2 RANDS) - or 48 (3 RANDs). - rands - 2 or 3 RANDs values. - -*******************************************************************************/ -#define CsrWifiNmeSimGsmAuthIndCreate(msg__, dst__, src__, randsLength__, rands__) \ - msg__ = kmalloc(sizeof(CsrWifiNmeSimGsmAuthInd), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_SIM_GSM_AUTH_IND, dst__, src__); \ - msg__->randsLength = (randsLength__); \ - msg__->rands = (rands__); - -#define CsrWifiNmeSimGsmAuthIndSendTo(dst__, src__, randsLength__, rands__) \ - { \ - CsrWifiNmeSimGsmAuthInd *msg__; \ - CsrWifiNmeSimGsmAuthIndCreate(msg__, dst__, src__, randsLength__, rands__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_NME_PRIM, msg__); \ - } - -#define CsrWifiNmeSimGsmAuthIndSend(dst__, randsLength__, rands__) \ - CsrWifiNmeSimGsmAuthIndSendTo(dst__, CSR_WIFI_NME_IFACEQUEUE, randsLength__, rands__) - -/******************************************************************************* - - NAME - CsrWifiNmeSimGsmAuthResSend - - DESCRIPTION - Response from the application that received the NME SIM GSM AUTH IND. For - each GSM authentication round a GSM Ciphering key (Kc) and a signed - response (SRES) are produced. Since 2 or 3 GSM authentication rounds are - used the 2 or 3 Kc's obtained respectively are combined into one buffer - and similarly the 2 or 3 SRES's obtained are combined into another - buffer. The order of Kc values (SRES values respectively) in their buffer - is the same as that of their corresponding RAND values in the incoming - indication. - - PARAMETERS - status - Indicates the outcome of the requested operation: - STATUS_SUCCESS or STATUS_ERROR - kcsLength - Length in Bytes of Kc buffer. Legal values are: 16 or 24. - kcs - Kc buffer holding 2 or 3 Kc values. - sresLength - Length in Bytes of SRES buffer. Legal values are: 8 or 12. - sres - SRES buffer holding 2 or 3 SRES values. - -*******************************************************************************/ -#define CsrWifiNmeSimGsmAuthResCreate(msg__, dst__, src__, status__, kcsLength__, kcs__, sresLength__, sres__) \ - msg__ = kmalloc(sizeof(CsrWifiNmeSimGsmAuthRes), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_SIM_GSM_AUTH_RES, dst__, src__); \ - msg__->status = (status__); \ - msg__->kcsLength = (kcsLength__); \ - msg__->kcs = (kcs__); \ - msg__->sresLength = (sresLength__); \ - msg__->sres = (sres__); - -#define CsrWifiNmeSimGsmAuthResSendTo(dst__, src__, status__, kcsLength__, kcs__, sresLength__, sres__) \ - { \ - CsrWifiNmeSimGsmAuthRes *msg__; \ - CsrWifiNmeSimGsmAuthResCreate(msg__, dst__, src__, status__, kcsLength__, kcs__, sresLength__, sres__); \ - CsrMsgTransport(dst__, CSR_WIFI_NME_PRIM, msg__); \ - } - -#define CsrWifiNmeSimGsmAuthResSend(src__, status__, kcsLength__, kcs__, sresLength__, sres__) \ - CsrWifiNmeSimGsmAuthResSendTo(CSR_WIFI_NME_IFACEQUEUE, src__, status__, kcsLength__, kcs__, sresLength__, sres__) - -/******************************************************************************* - - NAME - CsrWifiNmeSimImsiGetIndSend - - DESCRIPTION - Indication generated from the NME (if an application subscribes to - receive it) that requests the IMSI and UICC type from the UICC Manager. - This indication is generated when the NME is attempting to connect to a - profile configured for EAP-SIM/AKA. An application MUST register to - receive this indication for the NME to support the EAP-SIM/AKA credential - types. Otherwise the NME has no route to obtain the information from the - UICC. - - PARAMETERS - queue - Destination Task Queue - -*******************************************************************************/ -#define CsrWifiNmeSimImsiGetIndCreate(msg__, dst__, src__) \ - msg__ = kmalloc(sizeof(CsrWifiNmeSimImsiGetInd), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_SIM_IMSI_GET_IND, dst__, src__); - -#define CsrWifiNmeSimImsiGetIndSendTo(dst__, src__) \ - { \ - CsrWifiNmeSimImsiGetInd *msg__; \ - CsrWifiNmeSimImsiGetIndCreate(msg__, dst__, src__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_NME_PRIM, msg__); \ - } - -#define CsrWifiNmeSimImsiGetIndSend(dst__) \ - CsrWifiNmeSimImsiGetIndSendTo(dst__, CSR_WIFI_NME_IFACEQUEUE) - -/******************************************************************************* - - NAME - CsrWifiNmeSimImsiGetResSend - - DESCRIPTION - Response from the application that received the NME SIM IMSI GET IND. - - PARAMETERS - status - Indicates the outcome of the requested operation: STATUS_SUCCESS - or STATUS_ERROR. - imsi - The value of the IMSI obtained from the UICC. - cardType - The UICC type (GSM only (SIM), UMTS only (USIM), Both). - -*******************************************************************************/ -#define CsrWifiNmeSimImsiGetResCreate(msg__, dst__, src__, status__, imsi__, cardType__) \ - msg__ = kmalloc(sizeof(CsrWifiNmeSimImsiGetRes), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_SIM_IMSI_GET_RES, dst__, src__); \ - msg__->status = (status__); \ - msg__->imsi = (imsi__); \ - msg__->cardType = (cardType__); - -#define CsrWifiNmeSimImsiGetResSendTo(dst__, src__, status__, imsi__, cardType__) \ - { \ - CsrWifiNmeSimImsiGetRes *msg__; \ - CsrWifiNmeSimImsiGetResCreate(msg__, dst__, src__, status__, imsi__, cardType__); \ - CsrMsgTransport(dst__, CSR_WIFI_NME_PRIM, msg__); \ - } - -#define CsrWifiNmeSimImsiGetResSend(src__, status__, imsi__, cardType__) \ - CsrWifiNmeSimImsiGetResSendTo(CSR_WIFI_NME_IFACEQUEUE, src__, status__, imsi__, cardType__) - -/******************************************************************************* - - NAME - CsrWifiNmeSimUmtsAuthIndSend - - DESCRIPTION - Indication generated from the NME (if an application subscribes to - receive it) that requests the UICC Manager to perform a UMTS - authentication on behalf of the NME. This indication is generated when - the NME is attempting to connect to a profile configured for EAP-AKA. An - application MUST register to receive this indication for the NME to - support the EAP-AKA credential types. Otherwise the NME has no route to - obtain the information from the USIM. EAP-AKA requires one UMTS - authentication round and therefore only one RAND and one AUTN values are - included. - - PARAMETERS - queue - Destination Task Queue - rand - UMTS RAND value. - autn - UMTS AUTN value. - -*******************************************************************************/ -#define CsrWifiNmeSimUmtsAuthIndCreate(msg__, dst__, src__, rand__, autn__) \ - msg__ = kmalloc(sizeof(CsrWifiNmeSimUmtsAuthInd), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_SIM_UMTS_AUTH_IND, dst__, src__); \ - memcpy(msg__->rand, (rand__), sizeof(u8) * 16); \ - memcpy(msg__->autn, (autn__), sizeof(u8) * 16); - -#define CsrWifiNmeSimUmtsAuthIndSendTo(dst__, src__, rand__, autn__) \ - { \ - CsrWifiNmeSimUmtsAuthInd *msg__; \ - CsrWifiNmeSimUmtsAuthIndCreate(msg__, dst__, src__, rand__, autn__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_NME_PRIM, msg__); \ - } - -#define CsrWifiNmeSimUmtsAuthIndSend(dst__, rand__, autn__) \ - CsrWifiNmeSimUmtsAuthIndSendTo(dst__, CSR_WIFI_NME_IFACEQUEUE, rand__, autn__) - -/******************************************************************************* - - NAME - CsrWifiNmeSimUmtsAuthResSend - - DESCRIPTION - Response from the application that received the NME SIM UMTS AUTH IND. - The values of umtsCipherKey, umtsIntegrityKey, resParameterLength and - resParameter are only meanigful when result = UMTS_AUTH_RESULT_SUCCESS. - The value of auts is only meaningful when - result=UMTS_AUTH_RESULT_SYNC_FAIL. - - PARAMETERS - status - Indicates the outcome of the requested operation: - STATUS_SUCCESS or STATUS_ERROR. - result - The result of UMTS authentication as performed by the - UICC which could be: Success, Authentication Reject or - Synchronisation Failure. For all these 3 outcomes the - value of status is success. - umtsCipherKey - The UMTS Cipher Key as calculated and returned by the - UICC. - umtsIntegrityKey - The UMTS Integrity Key as calculated and returned by - the UICC. - resParameterLength - The length (in bytes) of the RES parameter (min=4; max - = 16). - resParameter - The RES parameter as calculated and returned by the - UICC. - auts - The AUTS parameter as calculated and returned by the - UICC. - -*******************************************************************************/ -#define CsrWifiNmeSimUmtsAuthResCreate(msg__, dst__, src__, status__, result__, umtsCipherKey__, umtsIntegrityKey__, resParameterLength__, resParameter__, auts__) \ - msg__ = kmalloc(sizeof(CsrWifiNmeSimUmtsAuthRes), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_SIM_UMTS_AUTH_RES, dst__, src__); \ - msg__->status = (status__); \ - msg__->result = (result__); \ - memcpy(msg__->umtsCipherKey, (umtsCipherKey__), sizeof(u8) * 16); \ - memcpy(msg__->umtsIntegrityKey, (umtsIntegrityKey__), sizeof(u8) * 16); \ - msg__->resParameterLength = (resParameterLength__); \ - msg__->resParameter = (resParameter__); \ - memcpy(msg__->auts, (auts__), sizeof(u8) * 14); - -#define CsrWifiNmeSimUmtsAuthResSendTo(dst__, src__, status__, result__, umtsCipherKey__, umtsIntegrityKey__, resParameterLength__, resParameter__, auts__) \ - { \ - CsrWifiNmeSimUmtsAuthRes *msg__; \ - CsrWifiNmeSimUmtsAuthResCreate(msg__, dst__, src__, status__, result__, umtsCipherKey__, umtsIntegrityKey__, resParameterLength__, resParameter__, auts__); \ - CsrMsgTransport(dst__, CSR_WIFI_NME_PRIM, msg__); \ - } - -#define CsrWifiNmeSimUmtsAuthResSend(src__, status__, result__, umtsCipherKey__, umtsIntegrityKey__, resParameterLength__, resParameter__, auts__) \ - CsrWifiNmeSimUmtsAuthResSendTo(CSR_WIFI_NME_IFACEQUEUE, src__, status__, result__, umtsCipherKey__, umtsIntegrityKey__, resParameterLength__, resParameter__, auts__) - -/******************************************************************************* - - NAME - CsrWifiNmeWpsCancelReqSend - - DESCRIPTION - Requests the NME to cancel any WPS procedure that it is currently - performing. This includes WPS registrar activities started because of - CSR_WIFI_NME_AP_REGISTER.request - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - interfaceTag - Interface Identifier; unique identifier of an interface - -*******************************************************************************/ -#define CsrWifiNmeWpsCancelReqCreate(msg__, dst__, src__, interfaceTag__) \ - msg__ = kmalloc(sizeof(CsrWifiNmeWpsCancelReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_WPS_CANCEL_REQ, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); - -#define CsrWifiNmeWpsCancelReqSendTo(dst__, src__, interfaceTag__) \ - { \ - CsrWifiNmeWpsCancelReq *msg__; \ - CsrWifiNmeWpsCancelReqCreate(msg__, dst__, src__, interfaceTag__); \ - CsrMsgTransport(dst__, CSR_WIFI_NME_PRIM, msg__); \ - } - -#define CsrWifiNmeWpsCancelReqSend(src__, interfaceTag__) \ - CsrWifiNmeWpsCancelReqSendTo(CSR_WIFI_NME_IFACEQUEUE, src__, interfaceTag__) - -/******************************************************************************* - - NAME - CsrWifiNmeWpsCancelCfmSend - - DESCRIPTION - Reports the status of the NME WPS REQ, the request is always SUCCESSFUL. - - PARAMETERS - queue - Destination Task Queue - interfaceTag - Interface Identifier; unique identifier of an interface - status - Only returns CSR_WIFI_NME_STATUS_SUCCESS - -*******************************************************************************/ -#define CsrWifiNmeWpsCancelCfmCreate(msg__, dst__, src__, interfaceTag__, status__) \ - msg__ = kmalloc(sizeof(CsrWifiNmeWpsCancelCfm), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_WPS_CANCEL_CFM, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->status = (status__); - -#define CsrWifiNmeWpsCancelCfmSendTo(dst__, src__, interfaceTag__, status__) \ - { \ - CsrWifiNmeWpsCancelCfm *msg__; \ - CsrWifiNmeWpsCancelCfmCreate(msg__, dst__, src__, interfaceTag__, status__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_NME_PRIM, msg__); \ - } - -#define CsrWifiNmeWpsCancelCfmSend(dst__, interfaceTag__, status__) \ - CsrWifiNmeWpsCancelCfmSendTo(dst__, CSR_WIFI_NME_IFACEQUEUE, interfaceTag__, status__) - -/******************************************************************************* - - NAME - CsrWifiNmeWpsCfmSend - - DESCRIPTION - Reports the status of the NME WPS REQ. - If CSR_WIFI_NME_STATUS_SUCCESS, the profile parameter contains the - identity and credentials of the AP. - - PARAMETERS - queue - Destination Task Queue - interfaceTag - Interface Identifier; unique identifier of an interface - status - Indicates the success or otherwise of the requested - operation. - profile - This parameter is relevant only if - status==CSR_WIFI_NME_STATUS_SUCCESS. - The identity and credentials of the network. - -*******************************************************************************/ -#define CsrWifiNmeWpsCfmCreate(msg__, dst__, src__, interfaceTag__, status__, profile__) \ - msg__ = kmalloc(sizeof(CsrWifiNmeWpsCfm), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_WPS_CFM, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->status = (status__); \ - msg__->profile = (profile__); - -#define CsrWifiNmeWpsCfmSendTo(dst__, src__, interfaceTag__, status__, profile__) \ - { \ - CsrWifiNmeWpsCfm *msg__; \ - CsrWifiNmeWpsCfmCreate(msg__, dst__, src__, interfaceTag__, status__, profile__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_NME_PRIM, msg__); \ - } - -#define CsrWifiNmeWpsCfmSend(dst__, interfaceTag__, status__, profile__) \ - CsrWifiNmeWpsCfmSendTo(dst__, CSR_WIFI_NME_IFACEQUEUE, interfaceTag__, status__, profile__) - -/******************************************************************************* - - NAME - CsrWifiNmeWpsConfigSetReqSend - - DESCRIPTION - This primitive passes the WPS information for the device to NME. This may - be accepted only if no interface is active. - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - wpsConfig - WPS config. - -*******************************************************************************/ -#define CsrWifiNmeWpsConfigSetReqCreate(msg__, dst__, src__, wpsConfig__) \ - msg__ = kmalloc(sizeof(CsrWifiNmeWpsConfigSetReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_WPS_CONFIG_SET_REQ, dst__, src__); \ - msg__->wpsConfig = (wpsConfig__); - -#define CsrWifiNmeWpsConfigSetReqSendTo(dst__, src__, wpsConfig__) \ - { \ - CsrWifiNmeWpsConfigSetReq *msg__; \ - CsrWifiNmeWpsConfigSetReqCreate(msg__, dst__, src__, wpsConfig__); \ - CsrMsgTransport(dst__, CSR_WIFI_NME_PRIM, msg__); \ - } - -#define CsrWifiNmeWpsConfigSetReqSend(src__, wpsConfig__) \ - CsrWifiNmeWpsConfigSetReqSendTo(CSR_WIFI_NME_IFACEQUEUE, src__, wpsConfig__) - -/******************************************************************************* - - NAME - CsrWifiNmeWpsConfigSetCfmSend - - DESCRIPTION - Confirm. - - PARAMETERS - queue - Destination Task Queue - status - Status of the request. - -*******************************************************************************/ -#define CsrWifiNmeWpsConfigSetCfmCreate(msg__, dst__, src__, status__) \ - msg__ = kmalloc(sizeof(CsrWifiNmeWpsConfigSetCfm), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_WPS_CONFIG_SET_CFM, dst__, src__); \ - msg__->status = (status__); - -#define CsrWifiNmeWpsConfigSetCfmSendTo(dst__, src__, status__) \ - { \ - CsrWifiNmeWpsConfigSetCfm *msg__; \ - CsrWifiNmeWpsConfigSetCfmCreate(msg__, dst__, src__, status__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_NME_PRIM, msg__); \ - } - -#define CsrWifiNmeWpsConfigSetCfmSend(dst__, status__) \ - CsrWifiNmeWpsConfigSetCfmSendTo(dst__, CSR_WIFI_NME_IFACEQUEUE, status__) - -/******************************************************************************* - - NAME - CsrWifiNmeWpsReqSend - - DESCRIPTION - Requests the NME to look for WPS enabled APs and attempt to perform WPS - to determine the appropriate security credentials to connect to the AP. - If the PIN == '00000000' then 'push button mode' is indicated, otherwise - the PIN has to match that of the AP. 4 digit pin is passed by sending the - pin digits in pin[0]..pin[3] and rest of the contents filled with '-'. - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - interfaceTag - Interface Identifier; unique identifier of an interface - pin - PIN value. - ssid - Service Set identifier - bssid - ID of Basic Service Set for which a WPS connection attempt is - being made. - -*******************************************************************************/ -#define CsrWifiNmeWpsReqCreate(msg__, dst__, src__, interfaceTag__, pin__, ssid__, bssid__) \ - msg__ = kmalloc(sizeof(CsrWifiNmeWpsReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_WPS_REQ, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); \ - memcpy(msg__->pin, (pin__), sizeof(u8) * 8); \ - msg__->ssid = (ssid__); \ - msg__->bssid = (bssid__); - -#define CsrWifiNmeWpsReqSendTo(dst__, src__, interfaceTag__, pin__, ssid__, bssid__) \ - { \ - CsrWifiNmeWpsReq *msg__; \ - CsrWifiNmeWpsReqCreate(msg__, dst__, src__, interfaceTag__, pin__, ssid__, bssid__); \ - CsrMsgTransport(dst__, CSR_WIFI_NME_PRIM, msg__); \ - } - -#define CsrWifiNmeWpsReqSend(src__, interfaceTag__, pin__, ssid__, bssid__) \ - CsrWifiNmeWpsReqSendTo(CSR_WIFI_NME_IFACEQUEUE, src__, interfaceTag__, pin__, ssid__, bssid__) - -#endif /* CSR_WIFI_NME_LIB_H__ */ diff --git a/drivers/staging/csr/csr_wifi_nme_prim.h b/drivers/staging/csr/csr_wifi_nme_prim.h deleted file mode 100644 index 9a7927a117ea..000000000000 --- a/drivers/staging/csr/csr_wifi_nme_prim.h +++ /dev/null @@ -1,1657 +0,0 @@ -/***************************************************************************** - - (c) Cambridge Silicon Radio Limited 2011 - All rights reserved and confidential information of CSR - - Refer to LICENSE.txt included with this source for details - on the license terms. - -*****************************************************************************/ - -/* Note: this is an auto-generated file. */ - -#ifndef CSR_WIFI_NME_PRIM_H__ -#define CSR_WIFI_NME_PRIM_H__ - -#include -#include "csr_prim_defs.h" -#include "csr_sched.h" -#include "csr_wifi_common.h" -#include "csr_result.h" -#include "csr_wifi_fsm_event.h" -#include "csr_wifi_sme_prim.h" - -#ifndef CSR_WIFI_NME_ENABLE -#error CSR_WIFI_NME_ENABLE MUST be defined inorder to use csr_wifi_nme_prim.h -#endif - -#define CSR_WIFI_NME_PRIM (0x0424) - -typedef CsrPrim CsrWifiNmePrim; - -typedef void (*CsrWifiNmeFrameFreeFunction)(void *frame); - -/******************************************************************************* - - NAME - CsrWifiNmeAuthMode - - DESCRIPTION - WiFi Authentication Mode - - VALUES - CSR_WIFI_NME_AUTH_MODE_80211_OPEN - - Connects to an open system network (i.e. no authentication, - no encryption) or to a WEP enabled network. - CSR_WIFI_NME_AUTH_MODE_80211_SHARED - - Connect to a WEP enabled network. - CSR_WIFI_NME_AUTH_MODE_8021X_WPA - - Connects to a WPA Enterprise enabled network. - CSR_WIFI_NME_AUTH_MODE_8021X_WPAPSK - - Connects to a WPA with Pre-Shared Key enabled network. - CSR_WIFI_NME_AUTH_MODE_8021X_WPA2 - - Connects to a WPA2 Enterprise enabled network. - CSR_WIFI_NME_AUTH_MODE_8021X_WPA2PSK - - Connects to a WPA2 with Pre-Shared Key enabled network. - CSR_WIFI_NME_AUTH_MODE_8021X_CCKM - - Connects to a CCKM enabled network. - CSR_WIFI_NME_AUTH_MODE_WAPI_WAI - - Connects to a WAPI Enterprise enabled network. - CSR_WIFI_NME_AUTH_MODE_WAPI_WAIPSK - - Connects to a WAPI with Pre-Shared Key enabled network. - CSR_WIFI_NME_AUTH_MODE_8021X_OTHER1X - - For future use. - -*******************************************************************************/ -typedef u16 CsrWifiNmeAuthMode; -#define CSR_WIFI_NME_AUTH_MODE_80211_OPEN ((CsrWifiNmeAuthMode) 0x0001) -#define CSR_WIFI_NME_AUTH_MODE_80211_SHARED ((CsrWifiNmeAuthMode) 0x0002) -#define CSR_WIFI_NME_AUTH_MODE_8021X_WPA ((CsrWifiNmeAuthMode) 0x0004) -#define CSR_WIFI_NME_AUTH_MODE_8021X_WPAPSK ((CsrWifiNmeAuthMode) 0x0008) -#define CSR_WIFI_NME_AUTH_MODE_8021X_WPA2 ((CsrWifiNmeAuthMode) 0x0010) -#define CSR_WIFI_NME_AUTH_MODE_8021X_WPA2PSK ((CsrWifiNmeAuthMode) 0x0020) -#define CSR_WIFI_NME_AUTH_MODE_8021X_CCKM ((CsrWifiNmeAuthMode) 0x0040) -#define CSR_WIFI_NME_AUTH_MODE_WAPI_WAI ((CsrWifiNmeAuthMode) 0x0080) -#define CSR_WIFI_NME_AUTH_MODE_WAPI_WAIPSK ((CsrWifiNmeAuthMode) 0x0100) -#define CSR_WIFI_NME_AUTH_MODE_8021X_OTHER1X ((CsrWifiNmeAuthMode) 0x0200) - -/******************************************************************************* - - NAME - CsrWifiNmeBssType - - DESCRIPTION - Type of BSS - - VALUES - CSR_WIFI_NME_BSS_TYPE_INFRASTRUCTURE - - Infrastructure BSS type where access to the network is via - one or several Access Points. - CSR_WIFI_NME_BSS_TYPE_ADHOC - - Adhoc or Independent BSS Type where one Station acts as a - host and future stations can join the adhoc network without - needing an access point. - CSR_WIFI_NME_BSS_TYPE_RESERVED - - To be in sync with SME.This is not used. - CSR_WIFI_NME_BSS_TYPE_P2P - - P2P mode of operation. - -*******************************************************************************/ -typedef u8 CsrWifiNmeBssType; -#define CSR_WIFI_NME_BSS_TYPE_INFRASTRUCTURE ((CsrWifiNmeBssType) 0x00) -#define CSR_WIFI_NME_BSS_TYPE_ADHOC ((CsrWifiNmeBssType) 0x01) -#define CSR_WIFI_NME_BSS_TYPE_RESERVED ((CsrWifiNmeBssType) 0x02) -#define CSR_WIFI_NME_BSS_TYPE_P2P ((CsrWifiNmeBssType) 0x03) - -/******************************************************************************* - - NAME - CsrWifiNmeCcxOptionsMask - - DESCRIPTION - Enumeration type defining possible mask values for setting CCX options. - - VALUES - CSR_WIFI_NME_CCX_OPTION_NONE - No CCX option is set. - CSR_WIFI_NME_CCX_OPTION_CCKM - CCX option cckm is set. - -*******************************************************************************/ -typedef u8 CsrWifiNmeCcxOptionsMask; -#define CSR_WIFI_NME_CCX_OPTION_NONE ((CsrWifiNmeCcxOptionsMask) 0x00) -#define CSR_WIFI_NME_CCX_OPTION_CCKM ((CsrWifiNmeCcxOptionsMask) 0x01) - -/******************************************************************************* - - NAME - CsrWifiNmeConfigAction - - DESCRIPTION - - VALUES - CSR_WIFI_PIN_ENTRY_PUSH_BUTTON - - CSR_WIFI_PIN_ENTRY_DISPLAY_PIN - - CSR_WIFI_PIN_ENTRY_ENTER_PIN - - -*******************************************************************************/ -typedef u8 CsrWifiNmeConfigAction; -#define CSR_WIFI_PIN_ENTRY_PUSH_BUTTON ((CsrWifiNmeConfigAction) 0x00) -#define CSR_WIFI_PIN_ENTRY_DISPLAY_PIN ((CsrWifiNmeConfigAction) 0x01) -#define CSR_WIFI_PIN_ENTRY_ENTER_PIN ((CsrWifiNmeConfigAction) 0x02) - -/******************************************************************************* - - NAME - CsrWifiNmeConnectionStatus - - DESCRIPTION - Indicate the NME Connection Status when connecting or when disconnecting - - VALUES - CSR_WIFI_NME_CONNECTION_STATUS_CONNECTION_STATUS_DISCONNECTED - - NME is disconnected. - CSR_WIFI_NME_CONNECTION_STATUS_CONNECTION_STATUS_CONNECTING - - NME is in the process of connecting. - CSR_WIFI_NME_CONNECTION_STATUS_CONNECTION_STATUS_AUTHENTICATING - - NME is in the authentication stage of a connection attempt. - CSR_WIFI_NME_CONNECTION_STATUS_CONNECTION_STATUS_CONNECTED - - NME is connected. - CSR_WIFI_NME_CONNECTION_STATUS_CONNECTION_STATUS_DISCONNECTING - - NME is in the process of disconnecting. - -*******************************************************************************/ -typedef u8 CsrWifiNmeConnectionStatus; -#define CSR_WIFI_NME_CONNECTION_STATUS_CONNECTION_STATUS_DISCONNECTED ((CsrWifiNmeConnectionStatus) 0x00) -#define CSR_WIFI_NME_CONNECTION_STATUS_CONNECTION_STATUS_CONNECTING ((CsrWifiNmeConnectionStatus) 0x01) -#define CSR_WIFI_NME_CONNECTION_STATUS_CONNECTION_STATUS_AUTHENTICATING ((CsrWifiNmeConnectionStatus) 0x02) -#define CSR_WIFI_NME_CONNECTION_STATUS_CONNECTION_STATUS_CONNECTED ((CsrWifiNmeConnectionStatus) 0x03) -#define CSR_WIFI_NME_CONNECTION_STATUS_CONNECTION_STATUS_DISCONNECTING ((CsrWifiNmeConnectionStatus) 0x04) - -/******************************************************************************* - - NAME - CsrWifiNmeCredentialType - - DESCRIPTION - NME Credential Types - - VALUES - CSR_WIFI_NME_CREDENTIAL_TYPE_OPEN_SYSTEM - - Credential Type Open System. - CSR_WIFI_NME_CREDENTIAL_TYPE_WEP64 - - Credential Type WEP-64 - CSR_WIFI_NME_CREDENTIAL_TYPE_WEP128 - - Credential Type WEP-128 - CSR_WIFI_NME_CREDENTIAL_TYPE_WPA_PSK - - Credential Type WPA Pre-Shared Key - CSR_WIFI_NME_CREDENTIAL_TYPE_WPA_PASSPHRASE - - Credential Type WPA pass phrase - CSR_WIFI_NME_CREDENTIAL_TYPE_WPA2_PSK - - Credential Type WPA2 Pre-Shared Key. - CSR_WIFI_NME_CREDENTIAL_TYPE_WPA2_PASSPHRASE - - Credential Type WPA2 pass phrase - CSR_WIFI_NME_CREDENTIAL_TYPE_WAPI_PSK - - Credential Type WAPI Pre-Shared Key. - CSR_WIFI_NME_CREDENTIAL_TYPE_WAPI_PASSPHRASE - - Credential Type WAPI pass phrase - CSR_WIFI_NME_CREDENTIAL_TYPE_WAPI - - Credential Type WAPI certificates - CSR_WIFI_NME_CREDENTIAL_TYPE_8021X - - Credential Type 802.1X: the associated type supports - FAST/LEAP/TLS/TTLS/PEAP/etc. - -*******************************************************************************/ -typedef u16 CsrWifiNmeCredentialType; -#define CSR_WIFI_NME_CREDENTIAL_TYPE_OPEN_SYSTEM ((CsrWifiNmeCredentialType) 0x0000) -#define CSR_WIFI_NME_CREDENTIAL_TYPE_WEP64 ((CsrWifiNmeCredentialType) 0x0001) -#define CSR_WIFI_NME_CREDENTIAL_TYPE_WEP128 ((CsrWifiNmeCredentialType) 0x0002) -#define CSR_WIFI_NME_CREDENTIAL_TYPE_WPA_PSK ((CsrWifiNmeCredentialType) 0x0003) -#define CSR_WIFI_NME_CREDENTIAL_TYPE_WPA_PASSPHRASE ((CsrWifiNmeCredentialType) 0x0004) -#define CSR_WIFI_NME_CREDENTIAL_TYPE_WPA2_PSK ((CsrWifiNmeCredentialType) 0x0005) -#define CSR_WIFI_NME_CREDENTIAL_TYPE_WPA2_PASSPHRASE ((CsrWifiNmeCredentialType) 0x0006) -#define CSR_WIFI_NME_CREDENTIAL_TYPE_WAPI_PSK ((CsrWifiNmeCredentialType) 0x0007) -#define CSR_WIFI_NME_CREDENTIAL_TYPE_WAPI_PASSPHRASE ((CsrWifiNmeCredentialType) 0x0008) -#define CSR_WIFI_NME_CREDENTIAL_TYPE_WAPI ((CsrWifiNmeCredentialType) 0x0009) -#define CSR_WIFI_NME_CREDENTIAL_TYPE_8021X ((CsrWifiNmeCredentialType) 0x000A) - -/******************************************************************************* - - NAME - CsrWifiNmeEapMethod - - DESCRIPTION - Outer EAP method with possibly inner method. - - VALUES - CSR_WIFI_NME_EAP_METHOD_TLS - - EAP-TLS Method. - CSR_WIFI_NME_EAP_METHOD_TTLS_MSCHAPV2 - - EAP-TTLS Method with MSCHAPV2. - CSR_WIFI_NME_EAP_METHOD_PEAP_GTC - - EAP-PEAP Method with GTC. - CSR_WIFI_NME_EAP_METHOD_PEAP_MSCHAPV2 - - EAP-PEAP Method with MSCHAPV2. - CSR_WIFI_NME_EAP_METHOD_SIM - - EAP-SIM Method. - CSR_WIFI_NME_EAP_METHOD_AKA - - EAP-AKA Method. - CSR_WIFI_NME_EAP_METHOD_FAST_GTC - - EAP-FAST Method with GTC. - CSR_WIFI_NME_EAP_METHOD_FAST_MSCHAPV2 - - EAP-FAST Method with MSCHAPV2. - CSR_WIFI_NME_EAP_METHOD_LEAP - - EAP-LEAP Method. - -*******************************************************************************/ -typedef u16 CsrWifiNmeEapMethod; -#define CSR_WIFI_NME_EAP_METHOD_TLS ((CsrWifiNmeEapMethod) 0x0001) -#define CSR_WIFI_NME_EAP_METHOD_TTLS_MSCHAPV2 ((CsrWifiNmeEapMethod) 0x0002) -#define CSR_WIFI_NME_EAP_METHOD_PEAP_GTC ((CsrWifiNmeEapMethod) 0x0004) -#define CSR_WIFI_NME_EAP_METHOD_PEAP_MSCHAPV2 ((CsrWifiNmeEapMethod) 0x0008) -#define CSR_WIFI_NME_EAP_METHOD_SIM ((CsrWifiNmeEapMethod) 0x0010) -#define CSR_WIFI_NME_EAP_METHOD_AKA ((CsrWifiNmeEapMethod) 0x0020) -#define CSR_WIFI_NME_EAP_METHOD_FAST_GTC ((CsrWifiNmeEapMethod) 0x0040) -#define CSR_WIFI_NME_EAP_METHOD_FAST_MSCHAPV2 ((CsrWifiNmeEapMethod) 0x0080) -#define CSR_WIFI_NME_EAP_METHOD_LEAP ((CsrWifiNmeEapMethod) 0x0100) - -/******************************************************************************* - - NAME - CsrWifiNmeEncryption - - DESCRIPTION - WiFi Encryption method - - VALUES - CSR_WIFI_NME_ENCRYPTION_CIPHER_NONE - - No encryprion set. - CSR_WIFI_NME_ENCRYPTION_CIPHER_PAIRWISE_WEP40 - - 40 bytes WEP key for peer to peer communication. - CSR_WIFI_NME_ENCRYPTION_CIPHER_PAIRWISE_WEP104 - - 104 bytes WEP key for peer to peer communication. - CSR_WIFI_NME_ENCRYPTION_CIPHER_PAIRWISE_TKIP - - TKIP key for peer to peer communication. - CSR_WIFI_NME_ENCRYPTION_CIPHER_PAIRWISE_CCMP - - CCMP key for peer to peer communication. - CSR_WIFI_NME_ENCRYPTION_CIPHER_PAIRWISE_SMS4 - - SMS4 key for peer to peer communication. - CSR_WIFI_NME_ENCRYPTION_CIPHER_GROUP_WEP40 - - 40 bytes WEP key for broadcast messages. - CSR_WIFI_NME_ENCRYPTION_CIPHER_GROUP_WEP104 - - 104 bytes WEP key for broadcast messages. - CSR_WIFI_NME_ENCRYPTION_CIPHER_GROUP_TKIP - - TKIP key for broadcast messages. - CSR_WIFI_NME_ENCRYPTION_CIPHER_GROUP_CCMP - - CCMP key for broadcast messages - CSR_WIFI_NME_ENCRYPTION_CIPHER_GROUP_SMS4 - - SMS4 key for broadcast messages. - -*******************************************************************************/ -typedef u16 CsrWifiNmeEncryption; -#define CSR_WIFI_NME_ENCRYPTION_CIPHER_NONE ((CsrWifiNmeEncryption) 0x0000) -#define CSR_WIFI_NME_ENCRYPTION_CIPHER_PAIRWISE_WEP40 ((CsrWifiNmeEncryption) 0x0001) -#define CSR_WIFI_NME_ENCRYPTION_CIPHER_PAIRWISE_WEP104 ((CsrWifiNmeEncryption) 0x0002) -#define CSR_WIFI_NME_ENCRYPTION_CIPHER_PAIRWISE_TKIP ((CsrWifiNmeEncryption) 0x0004) -#define CSR_WIFI_NME_ENCRYPTION_CIPHER_PAIRWISE_CCMP ((CsrWifiNmeEncryption) 0x0008) -#define CSR_WIFI_NME_ENCRYPTION_CIPHER_PAIRWISE_SMS4 ((CsrWifiNmeEncryption) 0x0010) -#define CSR_WIFI_NME_ENCRYPTION_CIPHER_GROUP_WEP40 ((CsrWifiNmeEncryption) 0x0020) -#define CSR_WIFI_NME_ENCRYPTION_CIPHER_GROUP_WEP104 ((CsrWifiNmeEncryption) 0x0040) -#define CSR_WIFI_NME_ENCRYPTION_CIPHER_GROUP_TKIP ((CsrWifiNmeEncryption) 0x0080) -#define CSR_WIFI_NME_ENCRYPTION_CIPHER_GROUP_CCMP ((CsrWifiNmeEncryption) 0x0100) -#define CSR_WIFI_NME_ENCRYPTION_CIPHER_GROUP_SMS4 ((CsrWifiNmeEncryption) 0x0200) - -/******************************************************************************* - - NAME - CsrWifiNmeIndications - - DESCRIPTION - NME indications - - VALUES - CSR_WIFI_NME_INDICATIONS_IND_AP_STATION - - NME AP Station Indication. - CSR_WIFI_NME_INDICATIONS_IND_AP_STOP - - NME AP Stop Indication. - CSR_WIFI_NME_INDICATIONS_IND_SIM_UMTS_AUTH - - NME UMTS Authentication Indication. - CSR_WIFI_NME_INDICATIONS_IND_P2P_GROUP_START - - NME P2P Group Start Indication. - CSR_WIFI_NME_INDICATIONS_IND_P2P_GROUP_STATUS - - NME P2P Group Status Indication. - CSR_WIFI_NME_INDICATIONS_IND_P2P_GROUP_ROLE - - NME P2P Group Role Indication. - CSR_WIFI_NME_INDICATIONS_IND_PROFILE_DISCONNECT - - NME Profile Disconnect Indication. - CSR_WIFI_NME_INDICATIONS_IND_PROFILE_UPDATE - - NME Profile Update Indication. - CSR_WIFI_NME_INDICATIONS_IND_SIM_IMSI_GET - - NME GET IMSI Indication. - CSR_WIFI_NME_INDICATIONS_IND_SIM_GSM_AUTH - - NME GSM Authentication Indication. - CSR_WIFI_NME_INDICATIONS_ALL - - Used to register for all available indications - -*******************************************************************************/ -typedef u32 CsrWifiNmeIndications; -#define CSR_WIFI_NME_INDICATIONS_IND_AP_STATION ((CsrWifiNmeIndications) 0x00100000) -#define CSR_WIFI_NME_INDICATIONS_IND_AP_STOP ((CsrWifiNmeIndications) 0x00200000) -#define CSR_WIFI_NME_INDICATIONS_IND_SIM_UMTS_AUTH ((CsrWifiNmeIndications) 0x01000000) -#define CSR_WIFI_NME_INDICATIONS_IND_P2P_GROUP_START ((CsrWifiNmeIndications) 0x02000000) -#define CSR_WIFI_NME_INDICATIONS_IND_P2P_GROUP_STATUS ((CsrWifiNmeIndications) 0x04000000) -#define CSR_WIFI_NME_INDICATIONS_IND_P2P_GROUP_ROLE ((CsrWifiNmeIndications) 0x08000000) -#define CSR_WIFI_NME_INDICATIONS_IND_PROFILE_DISCONNECT ((CsrWifiNmeIndications) 0x10000000) -#define CSR_WIFI_NME_INDICATIONS_IND_PROFILE_UPDATE ((CsrWifiNmeIndications) 0x20000000) -#define CSR_WIFI_NME_INDICATIONS_IND_SIM_IMSI_GET ((CsrWifiNmeIndications) 0x40000000) -#define CSR_WIFI_NME_INDICATIONS_IND_SIM_GSM_AUTH ((CsrWifiNmeIndications) 0x80000000) -#define CSR_WIFI_NME_INDICATIONS_ALL ((CsrWifiNmeIndications) 0xFFFFFFFF) - -/******************************************************************************* - - NAME - CsrWifiNmeSecError - - DESCRIPTION - NME Security Errors - place holder for the security library abort reason - - VALUES - CSR_WIFI_NME_SEC_ERROR_SEC_ERROR_UNKNOWN - - Unknown Security Error. - -*******************************************************************************/ -typedef u8 CsrWifiNmeSecError; -#define CSR_WIFI_NME_SEC_ERROR_SEC_ERROR_UNKNOWN ((CsrWifiNmeSecError) 0x00) - -/******************************************************************************* - - NAME - CsrWifiNmeSimCardType - - DESCRIPTION - (U)SIM Card (or UICC) types - - VALUES - CSR_WIFI_NME_SIM_CARD_TYPE_2G - 2G SIM card, capable of performing GSM - authentication only. - CSR_WIFI_NME_SIM_CARD_TYPE_3G - UICC supporting USIM application, capable - of performing UMTS authentication only. - CSR_WIFI_NME_SIM_CARD_TYPE_2G3G - UICC supporting both USIM and SIM - applications, capable of performing both - UMTS and GSM authentications. - -*******************************************************************************/ -typedef u8 CsrWifiNmeSimCardType; -#define CSR_WIFI_NME_SIM_CARD_TYPE_2G ((CsrWifiNmeSimCardType) 0x01) -#define CSR_WIFI_NME_SIM_CARD_TYPE_3G ((CsrWifiNmeSimCardType) 0x02) -#define CSR_WIFI_NME_SIM_CARD_TYPE_2G3G ((CsrWifiNmeSimCardType) 0x03) - -/******************************************************************************* - - NAME - CsrWifiNmeUmtsAuthResult - - DESCRIPTION - Only relevant for UMTS Authentication. It indicates if the UICC has - successfully authenticated the network or otherwise. - - VALUES - CSR_WIFI_NME_UMTS_AUTH_RESULT_SUCCESS - - Successful outcome from USIM indicating that the card has - successfully authenticated the network. - CSR_WIFI_NME_UMTS_AUTH_RESULT_SYNC_FAIL - - Unsuccessful outcome from USIM indicating that the card is - requesting the network to synchronise and re-try again. If - no further request is received an NME timer will expire and - the authentication is aborted. - CSR_WIFI_NME_UMTS_AUTH_RESULT_REJECT - - Unsuccessful outcome from USIM indicating that the card has - rejected the network and that the authentication is - aborted. - -*******************************************************************************/ -typedef u8 CsrWifiNmeUmtsAuthResult; -#define CSR_WIFI_NME_UMTS_AUTH_RESULT_SUCCESS ((CsrWifiNmeUmtsAuthResult) 0x00) -#define CSR_WIFI_NME_UMTS_AUTH_RESULT_SYNC_FAIL ((CsrWifiNmeUmtsAuthResult) 0x01) -#define CSR_WIFI_NME_UMTS_AUTH_RESULT_REJECT ((CsrWifiNmeUmtsAuthResult) 0x02) - -/******************************************************************************* - - NAME - CsrWifiNmeWmmQosInfo - - DESCRIPTION - Defines bits for the QoS Info octect as defined in the WMM specification. - The values of this type are used across the NME/SME/Router API's and they - must be kept consistent with the corresponding types in the .xml of the - other interfaces - - VALUES - CSR_WIFI_NME_WMM_QOS_INFO_AC_MAX_SP_ALL - - WMM AP may deliver all buffered frames. - CSR_WIFI_NME_WMM_QOS_INFO_AC_VO - - To enable the triggering and delivery of QoS Voice. - CSR_WIFI_NME_WMM_QOS_INFO_AC_VI - - To enable the triggering and delivery of QoS Video. - CSR_WIFI_NME_WMM_QOS_INFO_AC_BK - - To enable the triggering and delivery of QoS Background. - CSR_WIFI_NME_WMM_QOS_INFO_AC_BE - - To enable the triggering and delivery of QoS Best Effort. - CSR_WIFI_NME_WMM_QOS_INFO_AC_MAX_SP_TWO - - WMM AP may deliver a maximum of 2 buffered frames per - Unscheduled Service Period (USP). - CSR_WIFI_NME_WMM_QOS_INFO_AC_MAX_SP_FOUR - - WMM AP may deliver a maximum of 4 buffered frames per USP. - CSR_WIFI_NME_WMM_QOS_INFO_AC_MAX_SP_SIX - - WMM AP may deliver a maximum of 6 buffered frames per USP. - -*******************************************************************************/ -typedef u8 CsrWifiNmeWmmQosInfo; -#define CSR_WIFI_NME_WMM_QOS_INFO_AC_MAX_SP_ALL ((CsrWifiNmeWmmQosInfo) 0x00) -#define CSR_WIFI_NME_WMM_QOS_INFO_AC_VO ((CsrWifiNmeWmmQosInfo) 0x01) -#define CSR_WIFI_NME_WMM_QOS_INFO_AC_VI ((CsrWifiNmeWmmQosInfo) 0x02) -#define CSR_WIFI_NME_WMM_QOS_INFO_AC_BK ((CsrWifiNmeWmmQosInfo) 0x04) -#define CSR_WIFI_NME_WMM_QOS_INFO_AC_BE ((CsrWifiNmeWmmQosInfo) 0x08) -#define CSR_WIFI_NME_WMM_QOS_INFO_AC_MAX_SP_TWO ((CsrWifiNmeWmmQosInfo) 0x20) -#define CSR_WIFI_NME_WMM_QOS_INFO_AC_MAX_SP_FOUR ((CsrWifiNmeWmmQosInfo) 0x40) -#define CSR_WIFI_NME_WMM_QOS_INFO_AC_MAX_SP_SIX ((CsrWifiNmeWmmQosInfo) 0x60) - - -/******************************************************************************* - - NAME - CsrWifiNmeEapMethodMask - - DESCRIPTION - Mask type for use with the values defined by CsrWifiNmeEapMethod. - -*******************************************************************************/ -typedef u16 CsrWifiNmeEapMethodMask; -/******************************************************************************* - - NAME - CsrWifiNmeEncryptionMask - - DESCRIPTION - Mask type for use with the values defined by CsrWifiNmeEncryption - -*******************************************************************************/ -typedef u16 CsrWifiNmeEncryptionMask; -/******************************************************************************* - - NAME - CsrWifiNmeIndicationsMask - - DESCRIPTION - Mask type for use with the values defined by CsrWifiNmeIndications - -*******************************************************************************/ -typedef u32 CsrWifiNmeIndicationsMask; -/******************************************************************************* - - NAME - CsrWifiNmeNmeIndicationsMask - - DESCRIPTION - Mask type for use with the values defined by CsrWifiNmeNmeIndications. - Used to overlap the unused portion of the unifi_IndicationsMask For NME - specific indications - -*******************************************************************************/ -typedef u32 CsrWifiNmeNmeIndicationsMask; -/******************************************************************************* - - NAME - CsrWifiNmeWmmQosInfoMask - - DESCRIPTION - Mask type for use with the values defined by CsrWifiNmeWmmQosInfo - -*******************************************************************************/ -typedef u8 CsrWifiNmeWmmQosInfoMask; - - -/******************************************************************************* - - NAME - CsrWifiNmeEmpty - - DESCRIPTION - Empty Structure to indicate that no credentials are available. - - MEMBERS - empty - Only element of the empty structure (always set to 0). - -*******************************************************************************/ -typedef struct -{ - u8 empty; -} CsrWifiNmeEmpty; - -/******************************************************************************* - - NAME - CsrWifiNmePassphrase - - DESCRIPTION - Structure holding the ASCII Pass Phrase data. - - MEMBERS - encryptionMode - Encryption type as defined in CsrWifiSmeEncryption. - passphrase - Pass phrase ASCII value. - -*******************************************************************************/ -typedef struct -{ - u16 encryptionMode; - char *passphrase; -} CsrWifiNmePassphrase; - -/******************************************************************************* - - NAME - CsrWifiNmePsk - - DESCRIPTION - Structure holding the Pre-Shared Key data. - - MEMBERS - encryptionMode - Encryption type as defined in CsrWifiSmeEncryption. - psk - Pre-Shared Key value. - -*******************************************************************************/ -typedef struct -{ - u16 encryptionMode; - u8 psk[32]; -} CsrWifiNmePsk; - -/******************************************************************************* - - NAME - CsrWifiNmeWapiCredentials - - DESCRIPTION - Structure holding WAPI credentials data. - - MEMBERS - certificateLength - Length in bytes of the following client certificate. - certificate - The actual client certificate data (if present). - DER/PEM format supported. - privateKeyLength - Length in bytes of the following private key. - privateKey - The actual private key. DER/PEM format. - caCertificateLength - Length in bytes of the following certificate authority - certificate. - caCertificate - The actual certificate authority certificate data. If - not supplied the received certificate authority - certificate is assumed to be validate, if present the - received certificate is validated against it. DER/PEM - format supported. - -*******************************************************************************/ -typedef struct -{ - u32 certificateLength; - u8 *certificate; - u16 privateKeyLength; - u8 *privateKey; - u32 caCertificateLength; - u8 *caCertificate; -} CsrWifiNmeWapiCredentials; - -/******************************************************************************* - - NAME - CsrWifiNmeConnectAttempt - - DESCRIPTION - Structure holding Connection attempt data. - - MEMBERS - bssid - Id of Basic Service Set connections attempt have been made - to. - status - Status returned to indicate the success or otherwise of the - connection attempt. - securityError - Security error status indicating the nature of the failure - to connect. - -*******************************************************************************/ -typedef struct -{ - CsrWifiMacAddress bssid; - CsrResult status; - CsrWifiNmeSecError securityError; -} CsrWifiNmeConnectAttempt; - -/******************************************************************************* - - NAME - CsrWifiNmeEapCredentials - - DESCRIPTION - Supports the use of multiple EAP methods via a single structure. The - methods required are indicated by the value set in the eapMethodMask - - MEMBERS - eapMethodMask - - Bit mask of supported EAP methods - Currently only supports the setting of one bit. - Required for all the EAP methods. - authMode - - Bit mask representing the authentication types that may be - supported by a suitable AP. An AP must support at least one - of the authentication types specified to be considered for - connection. Required for all EAP methods. - encryptionMode - - Bit mask representing the encryption types that may be - supported by a suitable AP. An AP must support a suitable - mix of the pairwise and group encryption types requested to - be considered for connection. Required for all EAP methods. - userName - - User name. Required for all EAP methods except: SIM or AKA. - userPassword - - User Password. Required for all EAP methods except: TLS, - SIM or AKA. - authServerUserIdentity - - Authentication server user Identity. Required for all EAP - methods except: TLS, SIM, AKA or FAST. - clientCertificateLength - - Length in bytes of the following client certificate (if - present). Only required for TLS. - clientCertificate - - The actual client certificate data (if present). Only - required for TLS. DER/PEM format supported. - certificateAuthorityCertificateLength - - Length in bytes of the following certificate authority - certificate (if present). Optional for TLS, TTLS, PEAP. - certificateAuthorityCertificate - - The actual certificate authority certificate data (if - present). If not supplied the received certificate - authority certificate is assumed to be valid, if present - the received certificate is validated against it. Optional - for TLS, TTLS, PEAP. DER/PEM format supported. - privateKeyLength - - Length in bytes of the following private key (if present). - Only required for TLS. - privateKey - - The actual private key (if present). Only required for TLS. - DER/PEM format, maybe password protected. - privateKeyPassword - - Optional password to protect the private key. - sessionLength - - Length in bytes of the following session field Supported - for all EAP methods except: SIM or AKA. - session - - Session information to support faster re-authentication. - Supported for all EAP methods except: SIM or AKA. - allowPacProvisioning - - If TRUE: PAC provisioning is allowed 'over-the_air'; - If FALSE: a PAC must be supplied. - Only required for FAST. - pacLength - - Length the following PAC field. If allowPacProvisioning is - FALSE then the PAC MUST be supplied (i.e. non-zero). Only - required for FAST. - pac - - The actual PAC data. If allowPacProvisioning is FALSE then - the PAC MUST be supplied. Only required for FAST. - pacPassword - - Optional password to protect the PAC. Only required for - FAST. - -*******************************************************************************/ -typedef struct -{ - CsrWifiNmeEapMethodMask eapMethodMask; - CsrWifiSmeAuthModeMask authMode; - CsrWifiNmeEncryptionMask encryptionMode; - char *userName; - char *userPassword; - char *authServerUserIdentity; - u32 clientCertificateLength; - u8 *clientCertificate; - u32 certificateAuthorityCertificateLength; - u8 *certificateAuthorityCertificate; - u16 privateKeyLength; - u8 *privateKey; - char *privateKeyPassword; - u32 sessionLength; - u8 *session; - u8 allowPacProvisioning; - u32 pacLength; - u8 *pac; - char *pacPassword; -} CsrWifiNmeEapCredentials; - -/******************************************************************************* - - NAME - CsrWifiNmePeerConfig - - DESCRIPTION - Structure holding Peer Config data. - - MEMBERS - p2pDeviceId - - groupCapabilityMask - - groupOwnerIntent - - -*******************************************************************************/ -typedef struct -{ - CsrWifiMacAddress p2pDeviceId; - CsrWifiSmeP2pGroupCapabilityMask groupCapabilityMask; - u8 groupOwnerIntent; -} CsrWifiNmePeerConfig; - -/******************************************************************************* - - NAME - CsrWifiNmeProfileIdentity - - DESCRIPTION - The identity of a profile is defined as the unique combination the BSSID - and SSID. - - MEMBERS - bssid - ID of Basic Service Set for or the P2pDevice address of the GO for - which a connection attempt was made. - ssid - Service Set Id. - -*******************************************************************************/ -typedef struct -{ - CsrWifiMacAddress bssid; - CsrWifiSsid ssid; -} CsrWifiNmeProfileIdentity; - -/******************************************************************************* - - NAME - CsrWifiNmeWep128Keys - - DESCRIPTION - Structure holding WEP Authentication Type and WEP keys that can be used - when using WEP128. - - MEMBERS - wepAuthType - Mask to select the WEP authentication type (Open or Shared) - selectedWepKey - Index to one of the four keys below indicating the - currently used WEP key. - key1 - Value for key number 1. - key2 - Value for key number 2. - key3 - Value for key number 3. - key4 - Value for key number 4. - -*******************************************************************************/ -typedef struct -{ - CsrWifiSmeAuthModeMask wepAuthType; - u8 selectedWepKey; - u8 key1[13]; - u8 key2[13]; - u8 key3[13]; - u8 key4[13]; -} CsrWifiNmeWep128Keys; - -/******************************************************************************* - - NAME - CsrWifiNmeWep64Keys - - DESCRIPTION - Structure for holding WEP Authentication Type and WEP keys that can be - used when using WEP64. - - MEMBERS - wepAuthType - Mask to select the WEP authentication type (Open or Shared) - selectedWepKey - Index to one of the four keys below indicating the - currently used WEP key. - key1 - Value for key number 1. - key2 - Value for key number 2. - key3 - Value for key number 3. - key4 - Value for key number 4. - -*******************************************************************************/ -typedef struct -{ - CsrWifiSmeAuthModeMask wepAuthType; - u8 selectedWepKey; - u8 key1[5]; - u8 key2[5]; - u8 key3[5]; - u8 key4[5]; -} CsrWifiNmeWep64Keys; - -/******************************************************************************* - - NAME - CsrWifiNmeCredentials - - DESCRIPTION - Structure containing the Credentials data. - - MEMBERS - credentialType - Credential type value (as defined in the - enumeration type). - credential - Union containing credentials which depends on - credentialType parameter. - credentialeap - - credentialwapiPassphrase - - credentialwpa2Passphrase - - credentialwpa2Psk - - credentialwapiPsk - - credentialwpaPassphrase - - credentialwapi - - credentialwep128Key - - credentialwpaPsk - - credentialopenSystem - - credentialwep64Key - - -*******************************************************************************/ -typedef struct -{ - CsrWifiNmeCredentialType credentialType; - union { - CsrWifiNmeEapCredentials eap; - CsrWifiNmePassphrase wapiPassphrase; - CsrWifiNmePassphrase wpa2Passphrase; - CsrWifiNmePsk wpa2Psk; - CsrWifiNmePsk wapiPsk; - CsrWifiNmePassphrase wpaPassphrase; - CsrWifiNmeWapiCredentials wapi; - CsrWifiNmeWep128Keys wep128Key; - CsrWifiNmePsk wpaPsk; - CsrWifiNmeEmpty openSystem; - CsrWifiNmeWep64Keys wep64Key; - } credential; -} CsrWifiNmeCredentials; - -/******************************************************************************* - - NAME - CsrWifiNmeProfile - - DESCRIPTION - Structure containing the Profile data. - - MEMBERS - profileIdentity - Profile Identity. - wmmQosInfoMask - Mask for WMM QoS information. - bssType - Type of BSS (Infrastructure or Adhoc). - channelNo - Channel Number. - ccxOptionsMask - Options mask for Cisco Compatible Extentions. - cloakedSsid - Flag to decide whether the SSID is cloaked (not - transmitted) or not. - credentials - Credentials data. - -*******************************************************************************/ -typedef struct -{ - CsrWifiNmeProfileIdentity profileIdentity; - CsrWifiNmeWmmQosInfoMask wmmQosInfoMask; - CsrWifiNmeBssType bssType; - u8 channelNo; - u8 ccxOptionsMask; - u8 cloakedSsid; - CsrWifiNmeCredentials credentials; -} CsrWifiNmeProfile; - - -/* Downstream */ -#define CSR_WIFI_NME_PRIM_DOWNSTREAM_LOWEST (0x0000) - -#define CSR_WIFI_NME_PROFILE_SET_REQ ((CsrWifiNmePrim) (0x0000 + CSR_WIFI_NME_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_NME_PROFILE_DELETE_REQ ((CsrWifiNmePrim) (0x0001 + CSR_WIFI_NME_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_NME_PROFILE_DELETE_ALL_REQ ((CsrWifiNmePrim) (0x0002 + CSR_WIFI_NME_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_NME_PROFILE_ORDER_SET_REQ ((CsrWifiNmePrim) (0x0003 + CSR_WIFI_NME_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_NME_PROFILE_CONNECT_REQ ((CsrWifiNmePrim) (0x0004 + CSR_WIFI_NME_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_NME_WPS_REQ ((CsrWifiNmePrim) (0x0005 + CSR_WIFI_NME_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_NME_WPS_CANCEL_REQ ((CsrWifiNmePrim) (0x0006 + CSR_WIFI_NME_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_NME_CONNECTION_STATUS_GET_REQ ((CsrWifiNmePrim) (0x0007 + CSR_WIFI_NME_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_NME_SIM_IMSI_GET_RES ((CsrWifiNmePrim) (0x0008 + CSR_WIFI_NME_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_NME_SIM_GSM_AUTH_RES ((CsrWifiNmePrim) (0x0009 + CSR_WIFI_NME_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_NME_SIM_UMTS_AUTH_RES ((CsrWifiNmePrim) (0x000A + CSR_WIFI_NME_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_NME_WPS_CONFIG_SET_REQ ((CsrWifiNmePrim) (0x000B + CSR_WIFI_NME_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_NME_EVENT_MASK_SET_REQ ((CsrWifiNmePrim) (0x000C + CSR_WIFI_NME_PRIM_DOWNSTREAM_LOWEST)) - - -#define CSR_WIFI_NME_PRIM_DOWNSTREAM_HIGHEST (0x000C + CSR_WIFI_NME_PRIM_DOWNSTREAM_LOWEST) - -/* Upstream */ -#define CSR_WIFI_NME_PRIM_UPSTREAM_LOWEST (0x0000 + CSR_PRIM_UPSTREAM) - -#define CSR_WIFI_NME_PROFILE_SET_CFM ((CsrWifiNmePrim)(0x0000 + CSR_WIFI_NME_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_NME_PROFILE_DELETE_CFM ((CsrWifiNmePrim)(0x0001 + CSR_WIFI_NME_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_NME_PROFILE_DELETE_ALL_CFM ((CsrWifiNmePrim)(0x0002 + CSR_WIFI_NME_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_NME_PROFILE_ORDER_SET_CFM ((CsrWifiNmePrim)(0x0003 + CSR_WIFI_NME_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_NME_PROFILE_CONNECT_CFM ((CsrWifiNmePrim)(0x0004 + CSR_WIFI_NME_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_NME_WPS_CFM ((CsrWifiNmePrim)(0x0005 + CSR_WIFI_NME_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_NME_WPS_CANCEL_CFM ((CsrWifiNmePrim)(0x0006 + CSR_WIFI_NME_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_NME_CONNECTION_STATUS_GET_CFM ((CsrWifiNmePrim)(0x0007 + CSR_WIFI_NME_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_NME_PROFILE_UPDATE_IND ((CsrWifiNmePrim)(0x0008 + CSR_WIFI_NME_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_NME_PROFILE_DISCONNECT_IND ((CsrWifiNmePrim)(0x0009 + CSR_WIFI_NME_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_NME_SIM_IMSI_GET_IND ((CsrWifiNmePrim)(0x000A + CSR_WIFI_NME_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_NME_SIM_GSM_AUTH_IND ((CsrWifiNmePrim)(0x000B + CSR_WIFI_NME_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_NME_SIM_UMTS_AUTH_IND ((CsrWifiNmePrim)(0x000C + CSR_WIFI_NME_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_NME_WPS_CONFIG_SET_CFM ((CsrWifiNmePrim)(0x000D + CSR_WIFI_NME_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_NME_EVENT_MASK_SET_CFM ((CsrWifiNmePrim)(0x000E + CSR_WIFI_NME_PRIM_UPSTREAM_LOWEST)) - -#define CSR_WIFI_NME_PRIM_UPSTREAM_HIGHEST (0x000E + CSR_WIFI_NME_PRIM_UPSTREAM_LOWEST) - -#define CSR_WIFI_NME_PRIM_DOWNSTREAM_COUNT (CSR_WIFI_NME_PRIM_DOWNSTREAM_HIGHEST + 1 - CSR_WIFI_NME_PRIM_DOWNSTREAM_LOWEST) -#define CSR_WIFI_NME_PRIM_UPSTREAM_COUNT (CSR_WIFI_NME_PRIM_UPSTREAM_HIGHEST + 1 - CSR_WIFI_NME_PRIM_UPSTREAM_LOWEST) - -/******************************************************************************* - - NAME - CsrWifiNmeProfileSetReq - - DESCRIPTION - Creates or updates an existing profile in the NME that matches the unique - identity of the profile. Each profile is identified by the combination of - BSSID and SSID. The profile contains all the required credentials for - attempting to connect to the network. Creating or updating a profile via - the NME PROFILE SET REQ does NOT add the profile to the preferred profile - list within the NME used for the NME auto-connect behaviour. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - profile - Specifies the identity and credentials of the network. - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - CsrWifiNmeProfile profile; -} CsrWifiNmeProfileSetReq; - -/******************************************************************************* - - NAME - CsrWifiNmeProfileDeleteReq - - DESCRIPTION - Will delete the profile with a matching identity, but does NOT modify the - preferred profile list. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - profileIdentity - Identity (BSSID, SSID) of profile to be deleted. - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - CsrWifiNmeProfileIdentity profileIdentity; -} CsrWifiNmeProfileDeleteReq; - -/******************************************************************************* - - NAME - CsrWifiNmeProfileDeleteAllReq - - DESCRIPTION - Deletes all profiles present in the NME, but does NOT modify the - preferred profile list. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; -} CsrWifiNmeProfileDeleteAllReq; - -/******************************************************************************* - - NAME - CsrWifiNmeProfileOrderSetReq - - DESCRIPTION - Defines the preferred order that profiles present in the NME should be - used during the NME auto-connect behaviour. - If profileIdentitysCount == 0, it removes any existing preferred profile - list already present in the NME, effectively disabling the auto-connect - behaviour. - NOTE: Profile identities that do not match any profile stored in the NME - are ignored during the auto-connect procedure. - NOTE: during auto-connect the NME will only attempt to join an existing - adhoc network and it will never attempt to host an adhoc network; for - hosting and adhoc network, use CSR_WIFI_NME_PROFILE_CONNECT_REQ - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - Interface Identifier; unique identifier of an - interface - profileIdentitysCount - The number of profiles identities in the list. - profileIdentitys - Points to the list of profile identities. - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; - u8 profileIdentitysCount; - CsrWifiNmeProfileIdentity *profileIdentitys; -} CsrWifiNmeProfileOrderSetReq; - -/******************************************************************************* - - NAME - CsrWifiNmeProfileConnectReq - - DESCRIPTION - Requests the NME to attempt to connect to the specified profile. - Overrides any current connection attempt. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - Interface Identifier; unique identifier of an interface - profileIdentity - Identity (BSSID, SSID) of profile to be connected to. - It must match an existing profile in the NME. - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; - CsrWifiNmeProfileIdentity profileIdentity; -} CsrWifiNmeProfileConnectReq; - -/******************************************************************************* - - NAME - CsrWifiNmeWpsReq - - DESCRIPTION - Requests the NME to look for WPS enabled APs and attempt to perform WPS - to determine the appropriate security credentials to connect to the AP. - If the PIN == '00000000' then 'push button mode' is indicated, otherwise - the PIN has to match that of the AP. 4 digit pin is passed by sending the - pin digits in pin[0]..pin[3] and rest of the contents filled with '-'. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - Interface Identifier; unique identifier of an interface - pin - PIN value. - ssid - Service Set identifier - bssid - ID of Basic Service Set for which a WPS connection attempt is - being made. - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; - u8 pin[8]; - CsrWifiSsid ssid; - CsrWifiMacAddress bssid; -} CsrWifiNmeWpsReq; - -/******************************************************************************* - - NAME - CsrWifiNmeWpsCancelReq - - DESCRIPTION - Requests the NME to cancel any WPS procedure that it is currently - performing. This includes WPS registrar activities started because of - CSR_WIFI_NME_AP_REGISTER.request - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - Interface Identifier; unique identifier of an interface - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; -} CsrWifiNmeWpsCancelReq; - -/******************************************************************************* - - NAME - CsrWifiNmeConnectionStatusGetReq - - DESCRIPTION - Requests the current connection status of the NME. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - Interface Identifier; unique identifier of an interface - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; -} CsrWifiNmeConnectionStatusGetReq; - -/******************************************************************************* - - NAME - CsrWifiNmeSimImsiGetRes - - DESCRIPTION - Response from the application that received the NME SIM IMSI GET IND. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - status - Indicates the outcome of the requested operation: STATUS_SUCCESS - or STATUS_ERROR. - imsi - The value of the IMSI obtained from the UICC. - cardType - The UICC type (GSM only (SIM), UMTS only (USIM), Both). - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - CsrResult status; - char *imsi; - CsrWifiNmeSimCardType cardType; -} CsrWifiNmeSimImsiGetRes; - -/******************************************************************************* - - NAME - CsrWifiNmeSimGsmAuthRes - - DESCRIPTION - Response from the application that received the NME SIM GSM AUTH IND. For - each GSM authentication round a GSM Ciphering key (Kc) and a signed - response (SRES) are produced. Since 2 or 3 GSM authentication rounds are - used the 2 or 3 Kc's obtained respectively are combined into one buffer - and similarly the 2 or 3 SRES's obtained are combined into another - buffer. The order of Kc values (SRES values respectively) in their buffer - is the same as that of their corresponding RAND values in the incoming - indication. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - status - Indicates the outcome of the requested operation: - STATUS_SUCCESS or STATUS_ERROR - kcsLength - Length in Bytes of Kc buffer. Legal values are: 16 or 24. - kcs - Kc buffer holding 2 or 3 Kc values. - sresLength - Length in Bytes of SRES buffer. Legal values are: 8 or 12. - sres - SRES buffer holding 2 or 3 SRES values. - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - CsrResult status; - u8 kcsLength; - u8 *kcs; - u8 sresLength; - u8 *sres; -} CsrWifiNmeSimGsmAuthRes; - -/******************************************************************************* - - NAME - CsrWifiNmeSimUmtsAuthRes - - DESCRIPTION - Response from the application that received the NME SIM UMTS AUTH IND. - The values of umtsCipherKey, umtsIntegrityKey, resParameterLength and - resParameter are only meanigful when result = UMTS_AUTH_RESULT_SUCCESS. - The value of auts is only meaningful when - result=UMTS_AUTH_RESULT_SYNC_FAIL. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - status - Indicates the outcome of the requested operation: - STATUS_SUCCESS or STATUS_ERROR. - result - The result of UMTS authentication as performed by the - UICC which could be: Success, Authentication Reject or - Synchronisation Failure. For all these 3 outcomes the - value of status is success. - umtsCipherKey - The UMTS Cipher Key as calculated and returned by the - UICC. - umtsIntegrityKey - The UMTS Integrity Key as calculated and returned by - the UICC. - resParameterLength - The length (in bytes) of the RES parameter (min=4; max - = 16). - resParameter - The RES parameter as calculated and returned by the - UICC. - auts - The AUTS parameter as calculated and returned by the - UICC. - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - CsrResult status; - CsrWifiNmeUmtsAuthResult result; - u8 umtsCipherKey[16]; - u8 umtsIntegrityKey[16]; - u8 resParameterLength; - u8 *resParameter; - u8 auts[14]; -} CsrWifiNmeSimUmtsAuthRes; - -/******************************************************************************* - - NAME - CsrWifiNmeWpsConfigSetReq - - DESCRIPTION - This primitive passes the WPS information for the device to NME. This may - be accepted only if no interface is active. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - wpsConfig - WPS config. - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - CsrWifiSmeWpsConfig wpsConfig; -} CsrWifiNmeWpsConfigSetReq; - -/******************************************************************************* - - NAME - CsrWifiNmeEventMaskSetReq - - DESCRIPTION - The wireless manager application may register with the NME to receive - notification of interesting events. Indications will be sent only if the - wireless manager explicitly registers to be notified of that event. - indMask is a bit mask of values defined in CsrWifiNmeIndicationsMask. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - indMask - Set mask with values from CsrWifiNmeIndications - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - CsrWifiNmeIndicationsMask indMask; -} CsrWifiNmeEventMaskSetReq; - -/******************************************************************************* - - NAME - CsrWifiNmeProfileSetCfm - - DESCRIPTION - Reports the status of the NME PROFILE SET REQ; the request will only fail - if the details specified in the profile contains an invalid combination - of parameters for example specifying the profile as cloaked but not - specifying the SSID. The NME doesn't limit the number of profiles that - may be created. The NME assumes that the entity configuring it is aware - of the appropriate limits. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - status - Indicates the success or otherwise of the requested operation. - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - CsrResult status; -} CsrWifiNmeProfileSetCfm; - -/******************************************************************************* - - NAME - CsrWifiNmeProfileDeleteCfm - - DESCRIPTION - Reports the status of the CSR_WIFI_NME_PROFILE_DELETE_REQ. - Returns CSR_WIFI_NME_STATUS_NOT_FOUND if there is no matching profile. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - status - Indicates the success or otherwise of the requested operation. - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - CsrResult status; -} CsrWifiNmeProfileDeleteCfm; - -/******************************************************************************* - - NAME - CsrWifiNmeProfileDeleteAllCfm - - DESCRIPTION - Reports the status of the CSR_WIFI_NME_PROFILE_DELETE_ALL_REQ. - Returns always CSR_WIFI_NME_STATUS_SUCCESS. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - status - Indicates the success or otherwise of the requested operation, but - in this case it always set to success. - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - CsrResult status; -} CsrWifiNmeProfileDeleteAllCfm; - -/******************************************************************************* - - NAME - CsrWifiNmeProfileOrderSetCfm - - DESCRIPTION - Confirmation to UNIFI_NME_PROFILE_ORDER_SET.request. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - Interface Identifier; unique identifier of an interface - status - Indicates the success or otherwise of the requested - operation. - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; - CsrResult status; -} CsrWifiNmeProfileOrderSetCfm; - -/******************************************************************************* - - NAME - CsrWifiNmeProfileConnectCfm - - DESCRIPTION - Reports the status of the NME PROFILE CONNECT REQ. If unsuccessful the - connectAttempt parameters contain details of the APs that the NME - attempted to connect to before reporting the failure of the request. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - Interface Identifier; unique identifier of an - interface - status - Indicates the success or otherwise of the requested - operation. - connectAttemptsCount - This parameter is relevant only if - status!=CSR_WIFI_NME_STATUS_SUCCESS. - Number of connection attempt elements provided with - this primitive - connectAttempts - This parameter is relevant only if - status!=CSR_WIFI_NME_STATUS_SUCCESS. - Points to the list of connection attempt elements - provided with this primitive - Each element of the list provides information about - an AP on which the connection attempt was made and - the error that occurred during the attempt. - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; - CsrResult status; - u8 connectAttemptsCount; - CsrWifiNmeConnectAttempt *connectAttempts; -} CsrWifiNmeProfileConnectCfm; - -/******************************************************************************* - - NAME - CsrWifiNmeWpsCfm - - DESCRIPTION - Reports the status of the NME WPS REQ. - If CSR_WIFI_NME_STATUS_SUCCESS, the profile parameter contains the - identity and credentials of the AP. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - Interface Identifier; unique identifier of an interface - status - Indicates the success or otherwise of the requested - operation. - profile - This parameter is relevant only if - status==CSR_WIFI_NME_STATUS_SUCCESS. - The identity and credentials of the network. - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; - CsrResult status; - CsrWifiNmeProfile profile; -} CsrWifiNmeWpsCfm; - -/******************************************************************************* - - NAME - CsrWifiNmeWpsCancelCfm - - DESCRIPTION - Reports the status of the NME WPS REQ, the request is always SUCCESSFUL. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - Interface Identifier; unique identifier of an interface - status - Only returns CSR_WIFI_NME_STATUS_SUCCESS - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; - CsrResult status; -} CsrWifiNmeWpsCancelCfm; - -/******************************************************************************* - - NAME - CsrWifiNmeConnectionStatusGetCfm - - DESCRIPTION - Reports the connection status of the NME. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - Interface Identifier; unique identifier of an interface - status - Indicates the success or otherwise of the requested - operation. - connectionStatus - NME current connection status - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; - CsrResult status; - CsrWifiNmeConnectionStatus connectionStatus; -} CsrWifiNmeConnectionStatusGetCfm; - -/******************************************************************************* - - NAME - CsrWifiNmeProfileUpdateInd - - DESCRIPTION - Indication generated from the NME (if an application subscribes to - receive it) that informs that application that the contained profile has - changed. - For example, either the credentials EAP-FAST PAC file or the session data - within the profile has changed. - It is up to the application whether it stores this updated profile or - not. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - Interface Identifier; unique identifier of an interface - profile - The identity and credentials of the network. - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; - CsrWifiNmeProfile profile; -} CsrWifiNmeProfileUpdateInd; - -/******************************************************************************* - - NAME - CsrWifiNmeProfileDisconnectInd - - DESCRIPTION - Indication generated from the NME (if an application subscribes to - receive it) that informs that application that the current profile - connection has disconnected. The indication will contain information - about APs that it attempted to maintain the connection via i.e. in the - case of failed roaming. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - Interface Identifier; unique identifier of an - interface - connectAttemptsCount - Number of connection attempt elements provided with - this primitive - connectAttempts - Points to the list of connection attempt elements - provided with this primitive - Each element of the list provides information about - an AP on which the connection attempt was made and - the error occurred during the attempt. - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; - u8 connectAttemptsCount; - CsrWifiNmeConnectAttempt *connectAttempts; -} CsrWifiNmeProfileDisconnectInd; - -/******************************************************************************* - - NAME - CsrWifiNmeSimImsiGetInd - - DESCRIPTION - Indication generated from the NME (if an application subscribes to - receive it) that requests the IMSI and UICC type from the UICC Manager. - This indication is generated when the NME is attempting to connect to a - profile configured for EAP-SIM/AKA. An application MUST register to - receive this indication for the NME to support the EAP-SIM/AKA credential - types. Otherwise the NME has no route to obtain the information from the - UICC. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; -} CsrWifiNmeSimImsiGetInd; - -/******************************************************************************* - - NAME - CsrWifiNmeSimGsmAuthInd - - DESCRIPTION - Indication generated from the NME (if an application subscribes to - receive it) that requests the UICC Manager to perform a GSM - authentication on behalf of the NME. This indication is generated when - the NME is attempting to connect to a profile configured for EAP-SIM. An - application MUST register to receive this indication for the NME to - support the EAP-SIM credential types. Otherwise the NME has no route to - obtain the information from the UICC. EAP-SIM authentication requires 2 - or 3 GSM authentication rounds and therefore 2 or 3 RANDS (GSM Random - Challenges) are included. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - randsLength - GSM RAND is 16 bytes long hence valid values are 32 (2 RANDS) - or 48 (3 RANDs). - rands - 2 or 3 RANDs values. - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u8 randsLength; - u8 *rands; -} CsrWifiNmeSimGsmAuthInd; - -/******************************************************************************* - - NAME - CsrWifiNmeSimUmtsAuthInd - - DESCRIPTION - Indication generated from the NME (if an application subscribes to - receive it) that requests the UICC Manager to perform a UMTS - authentication on behalf of the NME. This indication is generated when - the NME is attempting to connect to a profile configured for EAP-AKA. An - application MUST register to receive this indication for the NME to - support the EAP-AKA credential types. Otherwise the NME has no route to - obtain the information from the USIM. EAP-AKA requires one UMTS - authentication round and therefore only one RAND and one AUTN values are - included. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - rand - UMTS RAND value. - autn - UMTS AUTN value. - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u8 rand[16]; - u8 autn[16]; -} CsrWifiNmeSimUmtsAuthInd; - -/******************************************************************************* - - NAME - CsrWifiNmeWpsConfigSetCfm - - DESCRIPTION - Confirm. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - status - Status of the request. - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - CsrResult status; -} CsrWifiNmeWpsConfigSetCfm; - -/******************************************************************************* - - NAME - CsrWifiNmeEventMaskSetCfm - - DESCRIPTION - The NME calls the primitive to report the result of the request - primitive. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - status - Reports the result of the request - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - CsrResult status; -} CsrWifiNmeEventMaskSetCfm; - -#endif /* CSR_WIFI_NME_PRIM_H__ */ - diff --git a/drivers/staging/csr/csr_wifi_nme_serialize.h b/drivers/staging/csr/csr_wifi_nme_serialize.h deleted file mode 100644 index ebac484419cf..000000000000 --- a/drivers/staging/csr/csr_wifi_nme_serialize.h +++ /dev/null @@ -1,166 +0,0 @@ -/***************************************************************************** - - (c) Cambridge Silicon Radio Limited 2011 - All rights reserved and confidential information of CSR - - Refer to LICENSE.txt included with this source for details - on the license terms. - -*****************************************************************************/ - -/* Note: this is an auto-generated file. */ - -#ifndef CSR_WIFI_NME_SERIALIZE_H__ -#define CSR_WIFI_NME_SERIALIZE_H__ - -#include "csr_wifi_msgconv.h" -#include "csr_wifi_nme_prim.h" - -#ifndef CSR_WIFI_NME_ENABLE -#error CSR_WIFI_NME_ENABLE MUST be defined inorder to use csr_wifi_nme_serialize.h -#endif - -extern void CsrWifiNmePfree(void *ptr); - -extern u8* CsrWifiNmeProfileSetReqSer(u8 *ptr, size_t *len, void *msg); -extern void* CsrWifiNmeProfileSetReqDes(u8 *buffer, size_t len); -extern size_t CsrWifiNmeProfileSetReqSizeof(void *msg); -extern void CsrWifiNmeProfileSetReqSerFree(void *msg); - -extern u8* CsrWifiNmeProfileDeleteReqSer(u8 *ptr, size_t *len, void *msg); -extern void* CsrWifiNmeProfileDeleteReqDes(u8 *buffer, size_t len); -extern size_t CsrWifiNmeProfileDeleteReqSizeof(void *msg); -#define CsrWifiNmeProfileDeleteReqSerFree CsrWifiNmePfree - -#define CsrWifiNmeProfileDeleteAllReqSer CsrWifiEventSer -#define CsrWifiNmeProfileDeleteAllReqDes CsrWifiEventDes -#define CsrWifiNmeProfileDeleteAllReqSizeof CsrWifiEventSizeof -#define CsrWifiNmeProfileDeleteAllReqSerFree CsrWifiNmePfree - -extern u8* CsrWifiNmeProfileOrderSetReqSer(u8 *ptr, size_t *len, void *msg); -extern void* CsrWifiNmeProfileOrderSetReqDes(u8 *buffer, size_t len); -extern size_t CsrWifiNmeProfileOrderSetReqSizeof(void *msg); -extern void CsrWifiNmeProfileOrderSetReqSerFree(void *msg); - -extern u8* CsrWifiNmeProfileConnectReqSer(u8 *ptr, size_t *len, void *msg); -extern void* CsrWifiNmeProfileConnectReqDes(u8 *buffer, size_t len); -extern size_t CsrWifiNmeProfileConnectReqSizeof(void *msg); -#define CsrWifiNmeProfileConnectReqSerFree CsrWifiNmePfree - -extern u8* CsrWifiNmeWpsReqSer(u8 *ptr, size_t *len, void *msg); -extern void* CsrWifiNmeWpsReqDes(u8 *buffer, size_t len); -extern size_t CsrWifiNmeWpsReqSizeof(void *msg); -#define CsrWifiNmeWpsReqSerFree CsrWifiNmePfree - -#define CsrWifiNmeWpsCancelReqSer CsrWifiEventCsrUint16Ser -#define CsrWifiNmeWpsCancelReqDes CsrWifiEventCsrUint16Des -#define CsrWifiNmeWpsCancelReqSizeof CsrWifiEventCsrUint16Sizeof -#define CsrWifiNmeWpsCancelReqSerFree CsrWifiNmePfree - -#define CsrWifiNmeConnectionStatusGetReqSer CsrWifiEventCsrUint16Ser -#define CsrWifiNmeConnectionStatusGetReqDes CsrWifiEventCsrUint16Des -#define CsrWifiNmeConnectionStatusGetReqSizeof CsrWifiEventCsrUint16Sizeof -#define CsrWifiNmeConnectionStatusGetReqSerFree CsrWifiNmePfree - -extern u8* CsrWifiNmeSimImsiGetResSer(u8 *ptr, size_t *len, void *msg); -extern void* CsrWifiNmeSimImsiGetResDes(u8 *buffer, size_t len); -extern size_t CsrWifiNmeSimImsiGetResSizeof(void *msg); -extern void CsrWifiNmeSimImsiGetResSerFree(void *msg); - -extern u8* CsrWifiNmeSimGsmAuthResSer(u8 *ptr, size_t *len, void *msg); -extern void* CsrWifiNmeSimGsmAuthResDes(u8 *buffer, size_t len); -extern size_t CsrWifiNmeSimGsmAuthResSizeof(void *msg); -extern void CsrWifiNmeSimGsmAuthResSerFree(void *msg); - -extern u8* CsrWifiNmeSimUmtsAuthResSer(u8 *ptr, size_t *len, void *msg); -extern void* CsrWifiNmeSimUmtsAuthResDes(u8 *buffer, size_t len); -extern size_t CsrWifiNmeSimUmtsAuthResSizeof(void *msg); -extern void CsrWifiNmeSimUmtsAuthResSerFree(void *msg); - -extern u8* CsrWifiNmeWpsConfigSetReqSer(u8 *ptr, size_t *len, void *msg); -extern void* CsrWifiNmeWpsConfigSetReqDes(u8 *buffer, size_t len); -extern size_t CsrWifiNmeWpsConfigSetReqSizeof(void *msg); -extern void CsrWifiNmeWpsConfigSetReqSerFree(void *msg); - -#define CsrWifiNmeEventMaskSetReqSer CsrWifiEventCsrUint32Ser -#define CsrWifiNmeEventMaskSetReqDes CsrWifiEventCsrUint32Des -#define CsrWifiNmeEventMaskSetReqSizeof CsrWifiEventCsrUint32Sizeof -#define CsrWifiNmeEventMaskSetReqSerFree CsrWifiNmePfree - -#define CsrWifiNmeProfileSetCfmSer CsrWifiEventCsrUint16Ser -#define CsrWifiNmeProfileSetCfmDes CsrWifiEventCsrUint16Des -#define CsrWifiNmeProfileSetCfmSizeof CsrWifiEventCsrUint16Sizeof -#define CsrWifiNmeProfileSetCfmSerFree CsrWifiNmePfree - -#define CsrWifiNmeProfileDeleteCfmSer CsrWifiEventCsrUint16Ser -#define CsrWifiNmeProfileDeleteCfmDes CsrWifiEventCsrUint16Des -#define CsrWifiNmeProfileDeleteCfmSizeof CsrWifiEventCsrUint16Sizeof -#define CsrWifiNmeProfileDeleteCfmSerFree CsrWifiNmePfree - -#define CsrWifiNmeProfileDeleteAllCfmSer CsrWifiEventCsrUint16Ser -#define CsrWifiNmeProfileDeleteAllCfmDes CsrWifiEventCsrUint16Des -#define CsrWifiNmeProfileDeleteAllCfmSizeof CsrWifiEventCsrUint16Sizeof -#define CsrWifiNmeProfileDeleteAllCfmSerFree CsrWifiNmePfree - -extern u8* CsrWifiNmeProfileOrderSetCfmSer(u8 *ptr, size_t *len, void *msg); -extern void* CsrWifiNmeProfileOrderSetCfmDes(u8 *buffer, size_t len); -extern size_t CsrWifiNmeProfileOrderSetCfmSizeof(void *msg); -#define CsrWifiNmeProfileOrderSetCfmSerFree CsrWifiNmePfree - -extern u8* CsrWifiNmeProfileConnectCfmSer(u8 *ptr, size_t *len, void *msg); -extern void* CsrWifiNmeProfileConnectCfmDes(u8 *buffer, size_t len); -extern size_t CsrWifiNmeProfileConnectCfmSizeof(void *msg); -extern void CsrWifiNmeProfileConnectCfmSerFree(void *msg); - -extern u8* CsrWifiNmeWpsCfmSer(u8 *ptr, size_t *len, void *msg); -extern void* CsrWifiNmeWpsCfmDes(u8 *buffer, size_t len); -extern size_t CsrWifiNmeWpsCfmSizeof(void *msg); -extern void CsrWifiNmeWpsCfmSerFree(void *msg); - -extern u8* CsrWifiNmeWpsCancelCfmSer(u8 *ptr, size_t *len, void *msg); -extern void* CsrWifiNmeWpsCancelCfmDes(u8 *buffer, size_t len); -extern size_t CsrWifiNmeWpsCancelCfmSizeof(void *msg); -#define CsrWifiNmeWpsCancelCfmSerFree CsrWifiNmePfree - -extern u8* CsrWifiNmeConnectionStatusGetCfmSer(u8 *ptr, size_t *len, void *msg); -extern void* CsrWifiNmeConnectionStatusGetCfmDes(u8 *buffer, size_t len); -extern size_t CsrWifiNmeConnectionStatusGetCfmSizeof(void *msg); -#define CsrWifiNmeConnectionStatusGetCfmSerFree CsrWifiNmePfree - -extern u8* CsrWifiNmeProfileUpdateIndSer(u8 *ptr, size_t *len, void *msg); -extern void* CsrWifiNmeProfileUpdateIndDes(u8 *buffer, size_t len); -extern size_t CsrWifiNmeProfileUpdateIndSizeof(void *msg); -extern void CsrWifiNmeProfileUpdateIndSerFree(void *msg); - -extern u8* CsrWifiNmeProfileDisconnectIndSer(u8 *ptr, size_t *len, void *msg); -extern void* CsrWifiNmeProfileDisconnectIndDes(u8 *buffer, size_t len); -extern size_t CsrWifiNmeProfileDisconnectIndSizeof(void *msg); -extern void CsrWifiNmeProfileDisconnectIndSerFree(void *msg); - -#define CsrWifiNmeSimImsiGetIndSer CsrWifiEventSer -#define CsrWifiNmeSimImsiGetIndDes CsrWifiEventDes -#define CsrWifiNmeSimImsiGetIndSizeof CsrWifiEventSizeof -#define CsrWifiNmeSimImsiGetIndSerFree CsrWifiNmePfree - -extern u8* CsrWifiNmeSimGsmAuthIndSer(u8 *ptr, size_t *len, void *msg); -extern void* CsrWifiNmeSimGsmAuthIndDes(u8 *buffer, size_t len); -extern size_t CsrWifiNmeSimGsmAuthIndSizeof(void *msg); -extern void CsrWifiNmeSimGsmAuthIndSerFree(void *msg); - -extern u8* CsrWifiNmeSimUmtsAuthIndSer(u8 *ptr, size_t *len, void *msg); -extern void* CsrWifiNmeSimUmtsAuthIndDes(u8 *buffer, size_t len); -extern size_t CsrWifiNmeSimUmtsAuthIndSizeof(void *msg); -#define CsrWifiNmeSimUmtsAuthIndSerFree CsrWifiNmePfree - -#define CsrWifiNmeWpsConfigSetCfmSer CsrWifiEventCsrUint16Ser -#define CsrWifiNmeWpsConfigSetCfmDes CsrWifiEventCsrUint16Des -#define CsrWifiNmeWpsConfigSetCfmSizeof CsrWifiEventCsrUint16Sizeof -#define CsrWifiNmeWpsConfigSetCfmSerFree CsrWifiNmePfree - -#define CsrWifiNmeEventMaskSetCfmSer CsrWifiEventCsrUint16Ser -#define CsrWifiNmeEventMaskSetCfmDes CsrWifiEventCsrUint16Des -#define CsrWifiNmeEventMaskSetCfmSizeof CsrWifiEventCsrUint16Sizeof -#define CsrWifiNmeEventMaskSetCfmSerFree CsrWifiNmePfree - -#endif /* CSR_WIFI_NME_SERIALIZE_H__ */ - diff --git a/drivers/staging/csr/csr_wifi_nme_task.h b/drivers/staging/csr/csr_wifi_nme_task.h deleted file mode 100644 index 84e973a59bb2..000000000000 --- a/drivers/staging/csr/csr_wifi_nme_task.h +++ /dev/null @@ -1,27 +0,0 @@ -/***************************************************************************** - - (c) Cambridge Silicon Radio Limited 2011 - All rights reserved and confidential information of CSR - - Refer to LICENSE.txt included with this source for details - on the license terms. - -*****************************************************************************/ - -/* Note: this is an auto-generated file. */ - -#ifndef CSR_WIFI_NME_TASK_H__ -#define CSR_WIFI_NME_TASK_H__ - -#include -#include "csr_sched.h" - -#ifndef CSR_WIFI_NME_ENABLE -#error CSR_WIFI_NME_ENABLE MUST be defined inorder to use csr_wifi_nme_task.h -#endif - -#define CSR_WIFI_NME_LOG_ID 0x1203FFFF -extern CsrSchedQid CSR_WIFI_NME_IFACEQUEUE; - -#endif /* CSR_WIFI_NME_TASK_H__ */ - diff --git a/drivers/staging/csr/csr_wifi_private_common.h b/drivers/staging/csr/csr_wifi_private_common.h deleted file mode 100644 index ee3bd51b934a..000000000000 --- a/drivers/staging/csr/csr_wifi_private_common.h +++ /dev/null @@ -1,81 +0,0 @@ -/***************************************************************************** - - (c) Cambridge Silicon Radio Limited 2011 - All rights reserved and confidential information of CSR - - Refer to LICENSE.txt included with this source for details - on the license terms. - -*****************************************************************************/ - -#ifndef CSR_WIFI_PRIVATE_COMMON_H__ -#define CSR_WIFI_PRIVATE_COMMON_H__ - -/** - * @brief maximum number of STAs allowed to be connected - * - * @par Description - * min & max Beacon Interval - */ -#define CSR_WIFI_AP_MAX_ASSOC_STA 8 - -/** Number of only b rates */ -#define CSR_WIFI_SME_AP_MAX_ONLY_B_RATES 4 - - -/** Number of mandatory b rates */ -#define CSR_WIFI_SME_AP_MAX_MANDATORY_B_RATES 2 - - -/** Number of mandatory bg rates */ -#define CSR_WIFI_SME_AP_MAX_MANDATORY_BG_RATES 4 - - -/** Number of bg rates */ -#define CSR_WIFI_SME_AP_MAX_BG_RATES 12 - - -/** Number of no b only g rates */ -#define CSR_WIFI_SME_AP_MAX_NO_B_ONLY_G_RATES 8 - - -/** Number of mandatory g rates */ -#define CSR_WIFI_SME_AP_MAX_MANDATORY_G_RATES 7 - - -/* Number of g mandatory rates */ -#define CSR_WIFI_SME_AP_G_MANDATORY_RATES_NUM 7 - - -/* Number of b mandatory rates */ -#define CSR_WIFI_SME_AP_B_MANDATORY_RATES_NUM 2 - - -/* Number of b/g mandatory rates */ -#define CSR_WIFI_SME_AP_BG_MANDATORY_RATES_NUM 4 - - -/* The maximum allowed length of SSID */ -#define CSR_WIFI_SME_AP_SSID_MAX_LENGTH 32 - -/* Refer 8.4.2.27 RSN element - we support TKIP, WPA2, WAPI and PSK only, no pmkid, group cipher suite */ -#define CSR_WIFI_SME_RSN_PACKED_SIZE (1 + 1 + 2 + 4 + 2 + 4 * 2 + 2 + 4 * 1 + 2 + 24) - -/* Refer 7.3.2.9 (ISO/IEC 8802-11:2006) WAPI element - we support WAPI PSK only, no bkid, group cipher suite */ -#define CSR_WIFI_SME_WAPI_PACKED_SIZE (1 + 1 + 2 + 2 + 4 * 1 + 2 + 4 * 1 + 4 + 2 + 24) - - -/* Common structure for NME and SME to maintain Interface mode*/ -typedef u8 CsrWifiInterfaceMode; -#define CSR_WIFI_MODE_NONE ((CsrWifiInterfaceMode) 0xFF) -#define CSR_WIFI_MODE_STA ((CsrWifiInterfaceMode) 0x00) -#define CSR_WIFI_MODE_AP ((CsrWifiInterfaceMode) 0x01) -#define CSR_WIFI_MODE_P2P_DEVICE ((CsrWifiInterfaceMode) 0x02) -#define CSR_WIFI_MODE_P2P_CLI ((CsrWifiInterfaceMode) 0x03) -#define CSR_WIFI_MODE_P2P_GO ((CsrWifiInterfaceMode) 0x04) -#define CSR_WIFI_MODE_AMP ((CsrWifiInterfaceMode) 0x05) -#define CSR_WIFI_MODE_WPS_ENROLLEE ((CsrWifiInterfaceMode) 0x06) -#define CSR_WIFI_MODE_IBSS ((CsrWifiInterfaceMode) 0x07) - -#endif - diff --git a/drivers/staging/csr/csr_wifi_result.h b/drivers/staging/csr/csr_wifi_result.h deleted file mode 100644 index 3c394c7e5fa9..000000000000 --- a/drivers/staging/csr/csr_wifi_result.h +++ /dev/null @@ -1,27 +0,0 @@ -/***************************************************************************** - - (c) Cambridge Silicon Radio Limited 2011 - All rights reserved and confidential information of CSR - - Refer to LICENSE.txt included with this source for details - on the license terms. - -*****************************************************************************/ - -#ifndef CSR_WIFI_RESULT_H__ -#define CSR_WIFI_RESULT_H__ - -#include "csr_result.h" - -/* THIS FILE SHOULD CONTAIN ONLY RESULT CODES */ - -/* Result Codes */ -#define CSR_WIFI_HIP_RESULT_INVALID_VALUE ((CsrResult) 1) /* Invalid argument value */ -#define CSR_WIFI_HIP_RESULT_NO_DEVICE ((CsrResult) 2) /* The specified device is no longer present */ -#define CSR_WIFI_HIP_RESULT_NO_SPACE ((CsrResult) 3) /* A queue or buffer is full */ -#define CSR_WIFI_HIP_RESULT_NO_MEMORY ((CsrResult) 4) /* Fatal error, no memory */ -#define CSR_WIFI_HIP_RESULT_RANGE ((CsrResult) 5) /* Request exceeds the range of a file or a buffer */ -#define CSR_WIFI_HIP_RESULT_NOT_FOUND ((CsrResult) 6) /* A file (typically a f/w patch) is not found */ - -#endif /* CSR_WIFI_RESULT_H__ */ - diff --git a/drivers/staging/csr/csr_wifi_router_converter_init.c b/drivers/staging/csr/csr_wifi_router_converter_init.c deleted file mode 100644 index 775c013d0514..000000000000 --- a/drivers/staging/csr/csr_wifi_router_converter_init.c +++ /dev/null @@ -1,82 +0,0 @@ -/***************************************************************************** - - (c) Cambridge Silicon Radio Limited 2012 - All rights reserved and confidential information of CSR - - Refer to LICENSE.txt included with this source for details - on the license terms. - -*****************************************************************************/ - -/* Note: this is an auto-generated file. */ - -#include "csr_msgconv.h" -#include "csr_macro.h" - - -#ifdef CSR_LOG_ENABLE -#include "csr_log.h" -#endif - -#ifndef EXCLUDE_CSR_WIFI_ROUTER_MODULE -#include "csr_wifi_router_serialize.h" -#include "csr_wifi_router_prim.h" - -static CsrMsgConvMsgEntry csrwifirouter_conv_lut[] = { - { CSR_WIFI_ROUTER_MA_PACKET_SUBSCRIBE_REQ, CsrWifiRouterMaPacketSubscribeReqSizeof, CsrWifiRouterMaPacketSubscribeReqSer, CsrWifiRouterMaPacketSubscribeReqDes, CsrWifiRouterMaPacketSubscribeReqSerFree }, - { CSR_WIFI_ROUTER_MA_PACKET_UNSUBSCRIBE_REQ, CsrWifiRouterMaPacketUnsubscribeReqSizeof, CsrWifiRouterMaPacketUnsubscribeReqSer, CsrWifiRouterMaPacketUnsubscribeReqDes, CsrWifiRouterMaPacketUnsubscribeReqSerFree }, - { CSR_WIFI_ROUTER_MA_PACKET_REQ, CsrWifiRouterMaPacketReqSizeof, CsrWifiRouterMaPacketReqSer, CsrWifiRouterMaPacketReqDes, CsrWifiRouterMaPacketReqSerFree }, - { CSR_WIFI_ROUTER_MA_PACKET_RES, CsrWifiRouterMaPacketResSizeof, CsrWifiRouterMaPacketResSer, CsrWifiRouterMaPacketResDes, CsrWifiRouterMaPacketResSerFree }, - { CSR_WIFI_ROUTER_MA_PACKET_CANCEL_REQ, CsrWifiRouterMaPacketCancelReqSizeof, CsrWifiRouterMaPacketCancelReqSer, CsrWifiRouterMaPacketCancelReqDes, CsrWifiRouterMaPacketCancelReqSerFree }, - { CSR_WIFI_ROUTER_MA_PACKET_SUBSCRIBE_CFM, CsrWifiRouterMaPacketSubscribeCfmSizeof, CsrWifiRouterMaPacketSubscribeCfmSer, CsrWifiRouterMaPacketSubscribeCfmDes, CsrWifiRouterMaPacketSubscribeCfmSerFree }, - { CSR_WIFI_ROUTER_MA_PACKET_UNSUBSCRIBE_CFM, CsrWifiRouterMaPacketUnsubscribeCfmSizeof, CsrWifiRouterMaPacketUnsubscribeCfmSer, CsrWifiRouterMaPacketUnsubscribeCfmDes, CsrWifiRouterMaPacketUnsubscribeCfmSerFree }, - { CSR_WIFI_ROUTER_MA_PACKET_CFM, CsrWifiRouterMaPacketCfmSizeof, CsrWifiRouterMaPacketCfmSer, CsrWifiRouterMaPacketCfmDes, CsrWifiRouterMaPacketCfmSerFree }, - { CSR_WIFI_ROUTER_MA_PACKET_IND, CsrWifiRouterMaPacketIndSizeof, CsrWifiRouterMaPacketIndSer, CsrWifiRouterMaPacketIndDes, CsrWifiRouterMaPacketIndSerFree }, - - { 0, NULL, NULL, NULL, NULL }, -}; - -CsrMsgConvMsgEntry* CsrWifiRouterConverterLookup(CsrMsgConvMsgEntry *ce, u16 msgType) -{ - if (msgType & CSR_PRIM_UPSTREAM) - { - u16 idx = (msgType & ~CSR_PRIM_UPSTREAM) + CSR_WIFI_ROUTER_PRIM_DOWNSTREAM_COUNT; - if (idx < (CSR_WIFI_ROUTER_PRIM_UPSTREAM_COUNT + CSR_WIFI_ROUTER_PRIM_DOWNSTREAM_COUNT) && - csrwifirouter_conv_lut[idx].msgType == msgType) - { - return &csrwifirouter_conv_lut[idx]; - } - } - else - { - if (msgType < CSR_WIFI_ROUTER_PRIM_DOWNSTREAM_COUNT && - csrwifirouter_conv_lut[msgType].msgType == msgType) - { - return &csrwifirouter_conv_lut[msgType]; - } - } - return NULL; -} - - -void CsrWifiRouterConverterInit(void) -{ - CsrMsgConvInsert(CSR_WIFI_ROUTER_PRIM, csrwifirouter_conv_lut); - CsrMsgConvCustomLookupRegister(CSR_WIFI_ROUTER_PRIM, CsrWifiRouterConverterLookup); -} - - -#ifdef CSR_LOG_ENABLE -static const CsrLogPrimitiveInformation csrwifirouter_conv_info = { - CSR_WIFI_ROUTER_PRIM, - (char *)"CSR_WIFI_ROUTER_PRIM", - csrwifirouter_conv_lut -}; -const CsrLogPrimitiveInformation* CsrWifiRouterTechInfoGet(void) -{ - return &csrwifirouter_conv_info; -} - - -#endif /* CSR_LOG_ENABLE */ -#endif /* EXCLUDE_CSR_WIFI_ROUTER_MODULE */ diff --git a/drivers/staging/csr/csr_wifi_router_converter_init.h b/drivers/staging/csr/csr_wifi_router_converter_init.h deleted file mode 100644 index 478327b75c18..000000000000 --- a/drivers/staging/csr/csr_wifi_router_converter_init.h +++ /dev/null @@ -1,34 +0,0 @@ -/***************************************************************************** - - (c) Cambridge Silicon Radio Limited 2011 - All rights reserved and confidential information of CSR - - Refer to LICENSE.txt included with this source for details - on the license terms. - -*****************************************************************************/ - -/* Note: this is an auto-generated file. */ - -#ifndef CSR_WIFI_ROUTER_CONVERTER_INIT_H__ -#define CSR_WIFI_ROUTER_CONVERTER_INIT_H__ - -#ifndef EXCLUDE_CSR_WIFI_ROUTER_MODULE - -#include "csr_msgconv.h" - -#ifdef CSR_LOG_ENABLE -#include "csr_log.h" - -extern const CsrLogPrimitiveInformation* CsrWifiRouterTechInfoGet(void); -#endif /* CSR_LOG_ENABLE */ - -extern void CsrWifiRouterConverterInit(void); - -#else /* EXCLUDE_CSR_WIFI_ROUTER_MODULE */ - -#define CsrWifiRouterConverterInit() - -#endif /* EXCLUDE_CSR_WIFI_ROUTER_MODULE */ - -#endif /* CSR_WIFI_ROUTER_CONVERTER_INIT_H__ */ diff --git a/drivers/staging/csr/csr_wifi_router_ctrl_converter_init.c b/drivers/staging/csr/csr_wifi_router_ctrl_converter_init.c deleted file mode 100644 index a02e307e5a88..000000000000 --- a/drivers/staging/csr/csr_wifi_router_ctrl_converter_init.c +++ /dev/null @@ -1,134 +0,0 @@ -/***************************************************************************** - - (c) Cambridge Silicon Radio Limited 2012 - All rights reserved and confidential information of CSR - - Refer to LICENSE.txt included with this source for details - on the license terms. - -*****************************************************************************/ - -/* Note: this is an auto-generated file. */ - -#include "csr_msgconv.h" -#include "csr_macro.h" - -#ifdef CSR_LOG_ENABLE -#include "csr_log.h" -#endif - -#ifndef EXCLUDE_CSR_WIFI_ROUTER_CTRL_MODULE -#include "csr_wifi_router_ctrl_serialize.h" -#include "csr_wifi_router_ctrl_prim.h" - -static CsrMsgConvMsgEntry csrwifirouterctrl_conv_lut[] = { - { CSR_WIFI_ROUTER_CTRL_CONFIGURE_POWER_MODE_REQ, CsrWifiRouterCtrlConfigurePowerModeReqSizeof, CsrWifiRouterCtrlConfigurePowerModeReqSer, CsrWifiRouterCtrlConfigurePowerModeReqDes, CsrWifiRouterCtrlConfigurePowerModeReqSerFree }, - { CSR_WIFI_ROUTER_CTRL_HIP_REQ, CsrWifiRouterCtrlHipReqSizeof, CsrWifiRouterCtrlHipReqSer, CsrWifiRouterCtrlHipReqDes, CsrWifiRouterCtrlHipReqSerFree }, - { CSR_WIFI_ROUTER_CTRL_MEDIA_STATUS_REQ, CsrWifiRouterCtrlMediaStatusReqSizeof, CsrWifiRouterCtrlMediaStatusReqSer, CsrWifiRouterCtrlMediaStatusReqDes, CsrWifiRouterCtrlMediaStatusReqSerFree }, - { CSR_WIFI_ROUTER_CTRL_MULTICAST_ADDRESS_RES, CsrWifiRouterCtrlMulticastAddressResSizeof, CsrWifiRouterCtrlMulticastAddressResSer, CsrWifiRouterCtrlMulticastAddressResDes, CsrWifiRouterCtrlMulticastAddressResSerFree }, - { CSR_WIFI_ROUTER_CTRL_PORT_CONFIGURE_REQ, CsrWifiRouterCtrlPortConfigureReqSizeof, CsrWifiRouterCtrlPortConfigureReqSer, CsrWifiRouterCtrlPortConfigureReqDes, CsrWifiRouterCtrlPortConfigureReqSerFree }, - { CSR_WIFI_ROUTER_CTRL_QOS_CONTROL_REQ, CsrWifiRouterCtrlQosControlReqSizeof, CsrWifiRouterCtrlQosControlReqSer, CsrWifiRouterCtrlQosControlReqDes, CsrWifiRouterCtrlQosControlReqSerFree }, - { CSR_WIFI_ROUTER_CTRL_SUSPEND_RES, CsrWifiRouterCtrlSuspendResSizeof, CsrWifiRouterCtrlSuspendResSer, CsrWifiRouterCtrlSuspendResDes, CsrWifiRouterCtrlSuspendResSerFree }, - { CSR_WIFI_ROUTER_CTRL_TCLAS_ADD_REQ, CsrWifiRouterCtrlTclasAddReqSizeof, CsrWifiRouterCtrlTclasAddReqSer, CsrWifiRouterCtrlTclasAddReqDes, CsrWifiRouterCtrlTclasAddReqSerFree }, - { CSR_WIFI_ROUTER_CTRL_RESUME_RES, CsrWifiRouterCtrlResumeResSizeof, CsrWifiRouterCtrlResumeResSer, CsrWifiRouterCtrlResumeResDes, CsrWifiRouterCtrlResumeResSerFree }, - { CSR_WIFI_ROUTER_CTRL_RAW_SDIO_DEINITIALISE_REQ, CsrWifiRouterCtrlRawSdioDeinitialiseReqSizeof, CsrWifiRouterCtrlRawSdioDeinitialiseReqSer, CsrWifiRouterCtrlRawSdioDeinitialiseReqDes, CsrWifiRouterCtrlRawSdioDeinitialiseReqSerFree }, - { CSR_WIFI_ROUTER_CTRL_RAW_SDIO_INITIALISE_REQ, CsrWifiRouterCtrlRawSdioInitialiseReqSizeof, CsrWifiRouterCtrlRawSdioInitialiseReqSer, CsrWifiRouterCtrlRawSdioInitialiseReqDes, CsrWifiRouterCtrlRawSdioInitialiseReqSerFree }, - { CSR_WIFI_ROUTER_CTRL_TCLAS_DEL_REQ, CsrWifiRouterCtrlTclasDelReqSizeof, CsrWifiRouterCtrlTclasDelReqSer, CsrWifiRouterCtrlTclasDelReqDes, CsrWifiRouterCtrlTclasDelReqSerFree }, - { CSR_WIFI_ROUTER_CTRL_TRAFFIC_CLASSIFICATION_REQ, CsrWifiRouterCtrlTrafficClassificationReqSizeof, CsrWifiRouterCtrlTrafficClassificationReqSer, CsrWifiRouterCtrlTrafficClassificationReqDes, CsrWifiRouterCtrlTrafficClassificationReqSerFree }, - { CSR_WIFI_ROUTER_CTRL_TRAFFIC_CONFIG_REQ, CsrWifiRouterCtrlTrafficConfigReqSizeof, CsrWifiRouterCtrlTrafficConfigReqSer, CsrWifiRouterCtrlTrafficConfigReqDes, CsrWifiRouterCtrlTrafficConfigReqSerFree }, - { CSR_WIFI_ROUTER_CTRL_WIFI_OFF_REQ, CsrWifiRouterCtrlWifiOffReqSizeof, CsrWifiRouterCtrlWifiOffReqSer, CsrWifiRouterCtrlWifiOffReqDes, CsrWifiRouterCtrlWifiOffReqSerFree }, - { CSR_WIFI_ROUTER_CTRL_WIFI_OFF_RES, CsrWifiRouterCtrlWifiOffResSizeof, CsrWifiRouterCtrlWifiOffResSer, CsrWifiRouterCtrlWifiOffResDes, CsrWifiRouterCtrlWifiOffResSerFree }, - { CSR_WIFI_ROUTER_CTRL_WIFI_ON_REQ, CsrWifiRouterCtrlWifiOnReqSizeof, CsrWifiRouterCtrlWifiOnReqSer, CsrWifiRouterCtrlWifiOnReqDes, CsrWifiRouterCtrlWifiOnReqSerFree }, - { CSR_WIFI_ROUTER_CTRL_WIFI_ON_RES, CsrWifiRouterCtrlWifiOnResSizeof, CsrWifiRouterCtrlWifiOnResSer, CsrWifiRouterCtrlWifiOnResDes, CsrWifiRouterCtrlWifiOnResSerFree }, - { CSR_WIFI_ROUTER_CTRL_M4_TRANSMIT_REQ, CsrWifiRouterCtrlM4TransmitReqSizeof, CsrWifiRouterCtrlM4TransmitReqSer, CsrWifiRouterCtrlM4TransmitReqDes, CsrWifiRouterCtrlM4TransmitReqSerFree }, - { CSR_WIFI_ROUTER_CTRL_MODE_SET_REQ, CsrWifiRouterCtrlModeSetReqSizeof, CsrWifiRouterCtrlModeSetReqSer, CsrWifiRouterCtrlModeSetReqDes, CsrWifiRouterCtrlModeSetReqSerFree }, - { CSR_WIFI_ROUTER_CTRL_PEER_ADD_REQ, CsrWifiRouterCtrlPeerAddReqSizeof, CsrWifiRouterCtrlPeerAddReqSer, CsrWifiRouterCtrlPeerAddReqDes, CsrWifiRouterCtrlPeerAddReqSerFree }, - { CSR_WIFI_ROUTER_CTRL_PEER_DEL_REQ, CsrWifiRouterCtrlPeerDelReqSizeof, CsrWifiRouterCtrlPeerDelReqSer, CsrWifiRouterCtrlPeerDelReqDes, CsrWifiRouterCtrlPeerDelReqSerFree }, - { CSR_WIFI_ROUTER_CTRL_PEER_UPDATE_REQ, CsrWifiRouterCtrlPeerUpdateReqSizeof, CsrWifiRouterCtrlPeerUpdateReqSer, CsrWifiRouterCtrlPeerUpdateReqDes, CsrWifiRouterCtrlPeerUpdateReqSerFree }, - { CSR_WIFI_ROUTER_CTRL_CAPABILITIES_REQ, CsrWifiRouterCtrlCapabilitiesReqSizeof, CsrWifiRouterCtrlCapabilitiesReqSer, CsrWifiRouterCtrlCapabilitiesReqDes, CsrWifiRouterCtrlCapabilitiesReqSerFree }, - { CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_ENABLE_REQ, CsrWifiRouterCtrlBlockAckEnableReqSizeof, CsrWifiRouterCtrlBlockAckEnableReqSer, CsrWifiRouterCtrlBlockAckEnableReqDes, CsrWifiRouterCtrlBlockAckEnableReqSerFree }, - { CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_DISABLE_REQ, CsrWifiRouterCtrlBlockAckDisableReqSizeof, CsrWifiRouterCtrlBlockAckDisableReqSer, CsrWifiRouterCtrlBlockAckDisableReqDes, CsrWifiRouterCtrlBlockAckDisableReqSerFree }, - { CSR_WIFI_ROUTER_CTRL_WAPI_RX_PKT_REQ, CsrWifiRouterCtrlWapiRxPktReqSizeof, CsrWifiRouterCtrlWapiRxPktReqSer, CsrWifiRouterCtrlWapiRxPktReqDes, CsrWifiRouterCtrlWapiRxPktReqSerFree }, - { CSR_WIFI_ROUTER_CTRL_WAPI_MULTICAST_FILTER_REQ, CsrWifiRouterCtrlWapiMulticastFilterReqSizeof, CsrWifiRouterCtrlWapiMulticastFilterReqSer, CsrWifiRouterCtrlWapiMulticastFilterReqDes, CsrWifiRouterCtrlWapiMulticastFilterReqSerFree }, - { CSR_WIFI_ROUTER_CTRL_WAPI_UNICAST_FILTER_REQ, CsrWifiRouterCtrlWapiUnicastFilterReqSizeof, CsrWifiRouterCtrlWapiUnicastFilterReqSer, CsrWifiRouterCtrlWapiUnicastFilterReqDes, CsrWifiRouterCtrlWapiUnicastFilterReqSerFree }, - { CSR_WIFI_ROUTER_CTRL_WAPI_UNICAST_TX_PKT_REQ, CsrWifiRouterCtrlWapiUnicastTxPktReqSizeof, CsrWifiRouterCtrlWapiUnicastTxPktReqSer, CsrWifiRouterCtrlWapiUnicastTxPktReqDes, CsrWifiRouterCtrlWapiUnicastTxPktReqSerFree }, - { CSR_WIFI_ROUTER_CTRL_WAPI_FILTER_REQ, CsrWifiRouterCtrlWapiFilterReqSizeof, CsrWifiRouterCtrlWapiFilterReqSer, CsrWifiRouterCtrlWapiFilterReqDes, CsrWifiRouterCtrlWapiFilterReqSerFree }, - { CSR_WIFI_ROUTER_CTRL_HIP_IND, CsrWifiRouterCtrlHipIndSizeof, CsrWifiRouterCtrlHipIndSer, CsrWifiRouterCtrlHipIndDes, CsrWifiRouterCtrlHipIndSerFree }, - { CSR_WIFI_ROUTER_CTRL_MULTICAST_ADDRESS_IND, CsrWifiRouterCtrlMulticastAddressIndSizeof, CsrWifiRouterCtrlMulticastAddressIndSer, CsrWifiRouterCtrlMulticastAddressIndDes, CsrWifiRouterCtrlMulticastAddressIndSerFree }, - { CSR_WIFI_ROUTER_CTRL_PORT_CONFIGURE_CFM, CsrWifiRouterCtrlPortConfigureCfmSizeof, CsrWifiRouterCtrlPortConfigureCfmSer, CsrWifiRouterCtrlPortConfigureCfmDes, CsrWifiRouterCtrlPortConfigureCfmSerFree }, - { CSR_WIFI_ROUTER_CTRL_RESUME_IND, CsrWifiRouterCtrlResumeIndSizeof, CsrWifiRouterCtrlResumeIndSer, CsrWifiRouterCtrlResumeIndDes, CsrWifiRouterCtrlResumeIndSerFree }, - { CSR_WIFI_ROUTER_CTRL_SUSPEND_IND, CsrWifiRouterCtrlSuspendIndSizeof, CsrWifiRouterCtrlSuspendIndSer, CsrWifiRouterCtrlSuspendIndDes, CsrWifiRouterCtrlSuspendIndSerFree }, - { CSR_WIFI_ROUTER_CTRL_TCLAS_ADD_CFM, CsrWifiRouterCtrlTclasAddCfmSizeof, CsrWifiRouterCtrlTclasAddCfmSer, CsrWifiRouterCtrlTclasAddCfmDes, CsrWifiRouterCtrlTclasAddCfmSerFree }, - { CSR_WIFI_ROUTER_CTRL_RAW_SDIO_DEINITIALISE_CFM, CsrWifiRouterCtrlRawSdioDeinitialiseCfmSizeof, CsrWifiRouterCtrlRawSdioDeinitialiseCfmSer, CsrWifiRouterCtrlRawSdioDeinitialiseCfmDes, CsrWifiRouterCtrlRawSdioDeinitialiseCfmSerFree }, - { CSR_WIFI_ROUTER_CTRL_RAW_SDIO_INITIALISE_CFM, CsrWifiRouterCtrlRawSdioInitialiseCfmSizeof, CsrWifiRouterCtrlRawSdioInitialiseCfmSer, CsrWifiRouterCtrlRawSdioInitialiseCfmDes, CsrWifiRouterCtrlRawSdioInitialiseCfmSerFree }, - { CSR_WIFI_ROUTER_CTRL_TCLAS_DEL_CFM, CsrWifiRouterCtrlTclasDelCfmSizeof, CsrWifiRouterCtrlTclasDelCfmSer, CsrWifiRouterCtrlTclasDelCfmDes, CsrWifiRouterCtrlTclasDelCfmSerFree }, - { CSR_WIFI_ROUTER_CTRL_TRAFFIC_PROTOCOL_IND, CsrWifiRouterCtrlTrafficProtocolIndSizeof, CsrWifiRouterCtrlTrafficProtocolIndSer, CsrWifiRouterCtrlTrafficProtocolIndDes, CsrWifiRouterCtrlTrafficProtocolIndSerFree }, - { CSR_WIFI_ROUTER_CTRL_TRAFFIC_SAMPLE_IND, CsrWifiRouterCtrlTrafficSampleIndSizeof, CsrWifiRouterCtrlTrafficSampleIndSer, CsrWifiRouterCtrlTrafficSampleIndDes, CsrWifiRouterCtrlTrafficSampleIndSerFree }, - { CSR_WIFI_ROUTER_CTRL_WIFI_OFF_IND, CsrWifiRouterCtrlWifiOffIndSizeof, CsrWifiRouterCtrlWifiOffIndSer, CsrWifiRouterCtrlWifiOffIndDes, CsrWifiRouterCtrlWifiOffIndSerFree }, - { CSR_WIFI_ROUTER_CTRL_WIFI_OFF_CFM, CsrWifiRouterCtrlWifiOffCfmSizeof, CsrWifiRouterCtrlWifiOffCfmSer, CsrWifiRouterCtrlWifiOffCfmDes, CsrWifiRouterCtrlWifiOffCfmSerFree }, - { CSR_WIFI_ROUTER_CTRL_WIFI_ON_IND, CsrWifiRouterCtrlWifiOnIndSizeof, CsrWifiRouterCtrlWifiOnIndSer, CsrWifiRouterCtrlWifiOnIndDes, CsrWifiRouterCtrlWifiOnIndSerFree }, - { CSR_WIFI_ROUTER_CTRL_WIFI_ON_CFM, CsrWifiRouterCtrlWifiOnCfmSizeof, CsrWifiRouterCtrlWifiOnCfmSer, CsrWifiRouterCtrlWifiOnCfmDes, CsrWifiRouterCtrlWifiOnCfmSerFree }, - { CSR_WIFI_ROUTER_CTRL_M4_READY_TO_SEND_IND, CsrWifiRouterCtrlM4ReadyToSendIndSizeof, CsrWifiRouterCtrlM4ReadyToSendIndSer, CsrWifiRouterCtrlM4ReadyToSendIndDes, CsrWifiRouterCtrlM4ReadyToSendIndSerFree }, - { CSR_WIFI_ROUTER_CTRL_M4_TRANSMITTED_IND, CsrWifiRouterCtrlM4TransmittedIndSizeof, CsrWifiRouterCtrlM4TransmittedIndSer, CsrWifiRouterCtrlM4TransmittedIndDes, CsrWifiRouterCtrlM4TransmittedIndSerFree }, - { CSR_WIFI_ROUTER_CTRL_MIC_FAILURE_IND, CsrWifiRouterCtrlMicFailureIndSizeof, CsrWifiRouterCtrlMicFailureIndSer, CsrWifiRouterCtrlMicFailureIndDes, CsrWifiRouterCtrlMicFailureIndSerFree }, - { CSR_WIFI_ROUTER_CTRL_CONNECTED_IND, CsrWifiRouterCtrlConnectedIndSizeof, CsrWifiRouterCtrlConnectedIndSer, CsrWifiRouterCtrlConnectedIndDes, CsrWifiRouterCtrlConnectedIndSerFree }, - { CSR_WIFI_ROUTER_CTRL_PEER_ADD_CFM, CsrWifiRouterCtrlPeerAddCfmSizeof, CsrWifiRouterCtrlPeerAddCfmSer, CsrWifiRouterCtrlPeerAddCfmDes, CsrWifiRouterCtrlPeerAddCfmSerFree }, - { CSR_WIFI_ROUTER_CTRL_PEER_DEL_CFM, CsrWifiRouterCtrlPeerDelCfmSizeof, CsrWifiRouterCtrlPeerDelCfmSer, CsrWifiRouterCtrlPeerDelCfmDes, CsrWifiRouterCtrlPeerDelCfmSerFree }, - { CSR_WIFI_ROUTER_CTRL_UNEXPECTED_FRAME_IND, CsrWifiRouterCtrlUnexpectedFrameIndSizeof, CsrWifiRouterCtrlUnexpectedFrameIndSer, CsrWifiRouterCtrlUnexpectedFrameIndDes, CsrWifiRouterCtrlUnexpectedFrameIndSerFree }, - { CSR_WIFI_ROUTER_CTRL_PEER_UPDATE_CFM, CsrWifiRouterCtrlPeerUpdateCfmSizeof, CsrWifiRouterCtrlPeerUpdateCfmSer, CsrWifiRouterCtrlPeerUpdateCfmDes, CsrWifiRouterCtrlPeerUpdateCfmSerFree }, - { CSR_WIFI_ROUTER_CTRL_CAPABILITIES_CFM, CsrWifiRouterCtrlCapabilitiesCfmSizeof, CsrWifiRouterCtrlCapabilitiesCfmSer, CsrWifiRouterCtrlCapabilitiesCfmDes, CsrWifiRouterCtrlCapabilitiesCfmSerFree }, - { CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_ENABLE_CFM, CsrWifiRouterCtrlBlockAckEnableCfmSizeof, CsrWifiRouterCtrlBlockAckEnableCfmSer, CsrWifiRouterCtrlBlockAckEnableCfmDes, CsrWifiRouterCtrlBlockAckEnableCfmSerFree }, - { CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_DISABLE_CFM, CsrWifiRouterCtrlBlockAckDisableCfmSizeof, CsrWifiRouterCtrlBlockAckDisableCfmSer, CsrWifiRouterCtrlBlockAckDisableCfmDes, CsrWifiRouterCtrlBlockAckDisableCfmSerFree }, - { CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_ERROR_IND, CsrWifiRouterCtrlBlockAckErrorIndSizeof, CsrWifiRouterCtrlBlockAckErrorIndSer, CsrWifiRouterCtrlBlockAckErrorIndDes, CsrWifiRouterCtrlBlockAckErrorIndSerFree }, - { CSR_WIFI_ROUTER_CTRL_STA_INACTIVE_IND, CsrWifiRouterCtrlStaInactiveIndSizeof, CsrWifiRouterCtrlStaInactiveIndSer, CsrWifiRouterCtrlStaInactiveIndDes, CsrWifiRouterCtrlStaInactiveIndSerFree }, - { CSR_WIFI_ROUTER_CTRL_WAPI_RX_MIC_CHECK_IND, CsrWifiRouterCtrlWapiRxMicCheckIndSizeof, CsrWifiRouterCtrlWapiRxMicCheckIndSer, CsrWifiRouterCtrlWapiRxMicCheckIndDes, CsrWifiRouterCtrlWapiRxMicCheckIndSerFree }, - { CSR_WIFI_ROUTER_CTRL_MODE_SET_CFM, CsrWifiRouterCtrlModeSetCfmSizeof, CsrWifiRouterCtrlModeSetCfmSer, CsrWifiRouterCtrlModeSetCfmDes, CsrWifiRouterCtrlModeSetCfmSerFree }, - { CSR_WIFI_ROUTER_CTRL_WAPI_UNICAST_TX_ENCRYPT_IND, CsrWifiRouterCtrlWapiUnicastTxEncryptIndSizeof, CsrWifiRouterCtrlWapiUnicastTxEncryptIndSer, CsrWifiRouterCtrlWapiUnicastTxEncryptIndDes, CsrWifiRouterCtrlWapiUnicastTxEncryptIndSerFree }, - - { 0, NULL, NULL, NULL, NULL }, -}; - -CsrMsgConvMsgEntry* CsrWifiRouterCtrlConverterLookup(CsrMsgConvMsgEntry *ce, u16 msgType) -{ - if (msgType & CSR_PRIM_UPSTREAM) - { - u16 idx = (msgType & ~CSR_PRIM_UPSTREAM) + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_COUNT; - if (idx < (CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_COUNT + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_COUNT) && - csrwifirouterctrl_conv_lut[idx].msgType == msgType) - { - return &csrwifirouterctrl_conv_lut[idx]; - } - } - else - { - if (msgType < CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_COUNT && - csrwifirouterctrl_conv_lut[msgType].msgType == msgType) - { - return &csrwifirouterctrl_conv_lut[msgType]; - } - } - return NULL; -} - - -void CsrWifiRouterCtrlConverterInit(void) -{ - CsrMsgConvInsert(CSR_WIFI_ROUTER_CTRL_PRIM, csrwifirouterctrl_conv_lut); - CsrMsgConvCustomLookupRegister(CSR_WIFI_ROUTER_CTRL_PRIM, CsrWifiRouterCtrlConverterLookup); -} - - -#ifdef CSR_LOG_ENABLE -static const CsrLogPrimitiveInformation csrwifirouterctrl_conv_info = { - CSR_WIFI_ROUTER_CTRL_PRIM, - (char *)"CSR_WIFI_ROUTER_CTRL_PRIM", - csrwifirouterctrl_conv_lut -}; -const CsrLogPrimitiveInformation* CsrWifiRouterCtrlTechInfoGet(void) -{ - return &csrwifirouterctrl_conv_info; -} - - -#endif /* CSR_LOG_ENABLE */ -#endif /* EXCLUDE_CSR_WIFI_ROUTER_CTRL_MODULE */ diff --git a/drivers/staging/csr/csr_wifi_router_ctrl_converter_init.h b/drivers/staging/csr/csr_wifi_router_ctrl_converter_init.h deleted file mode 100644 index c98458912825..000000000000 --- a/drivers/staging/csr/csr_wifi_router_ctrl_converter_init.h +++ /dev/null @@ -1,34 +0,0 @@ -/***************************************************************************** - - (c) Cambridge Silicon Radio Limited 2011 - All rights reserved and confidential information of CSR - - Refer to LICENSE.txt included with this source for details - on the license terms. - -*****************************************************************************/ - -/* Note: this is an auto-generated file. */ - -#ifndef CSR_WIFI_ROUTER_CTRL_CONVERTER_INIT_H__ -#define CSR_WIFI_ROUTER_CTRL_CONVERTER_INIT_H__ - -#ifndef EXCLUDE_CSR_WIFI_ROUTER_CTRL_MODULE - -#include "csr_msgconv.h" - -#ifdef CSR_LOG_ENABLE -#include "csr_log.h" - -extern const CsrLogPrimitiveInformation* CsrWifiRouterCtrlTechInfoGet(void); -#endif /* CSR_LOG_ENABLE */ - -extern void CsrWifiRouterCtrlConverterInit(void); - -#else /* EXCLUDE_CSR_WIFI_ROUTER_CTRL_MODULE */ - -#define CsrWifiRouterCtrlConverterInit() - -#endif /* EXCLUDE_CSR_WIFI_ROUTER_CTRL_MODULE */ - -#endif /* CSR_WIFI_ROUTER_CTRL_CONVERTER_INIT_H__ */ diff --git a/drivers/staging/csr/csr_wifi_router_ctrl_free_downstream_contents.c b/drivers/staging/csr/csr_wifi_router_ctrl_free_downstream_contents.c deleted file mode 100644 index 7fa85fb4d6c0..000000000000 --- a/drivers/staging/csr/csr_wifi_router_ctrl_free_downstream_contents.c +++ /dev/null @@ -1,108 +0,0 @@ -/***************************************************************************** - - (c) Cambridge Silicon Radio Limited 2012 - All rights reserved and confidential information of CSR - - Refer to LICENSE.txt included with this source for details - on the license terms. - -*****************************************************************************/ - -/* Note: this is an auto-generated file. */ -#include -#include "csr_wifi_router_ctrl_prim.h" -#include "csr_wifi_router_ctrl_lib.h" - -/*----------------------------------------------------------------------------* - * NAME - * CsrWifiRouterCtrlFreeDownstreamMessageContents - * - * DESCRIPTION - * - * - * PARAMETERS - * eventClass: only the value CSR_WIFI_ROUTER_CTRL_PRIM will be handled - * message: the message to free - *----------------------------------------------------------------------------*/ -void CsrWifiRouterCtrlFreeDownstreamMessageContents(u16 eventClass, void *message) -{ - if (eventClass != CSR_WIFI_ROUTER_CTRL_PRIM) - { - return; - } - if (NULL == message) - { - return; - } - - switch (*((CsrWifiRouterCtrlPrim *) message)) - { - case CSR_WIFI_ROUTER_CTRL_HIP_REQ: - { - CsrWifiRouterCtrlHipReq *p = (CsrWifiRouterCtrlHipReq *)message; - kfree(p->mlmeCommand); - p->mlmeCommand = NULL; - kfree(p->dataRef1); - p->dataRef1 = NULL; - kfree(p->dataRef2); - p->dataRef2 = NULL; - break; - } - case CSR_WIFI_ROUTER_CTRL_MULTICAST_ADDRESS_RES: - { - CsrWifiRouterCtrlMulticastAddressRes *p = (CsrWifiRouterCtrlMulticastAddressRes *)message; - kfree(p->getAddresses); - p->getAddresses = NULL; - break; - } - case CSR_WIFI_ROUTER_CTRL_TCLAS_ADD_REQ: - { - CsrWifiRouterCtrlTclasAddReq *p = (CsrWifiRouterCtrlTclasAddReq *)message; - kfree(p->tclas); - p->tclas = NULL; - break; - } - case CSR_WIFI_ROUTER_CTRL_TCLAS_DEL_REQ: - { - CsrWifiRouterCtrlTclasDelReq *p = (CsrWifiRouterCtrlTclasDelReq *)message; - kfree(p->tclas); - p->tclas = NULL; - break; - } - case CSR_WIFI_ROUTER_CTRL_WIFI_ON_REQ: - { - CsrWifiRouterCtrlWifiOnReq *p = (CsrWifiRouterCtrlWifiOnReq *)message; - kfree(p->data); - p->data = NULL; - break; - } - case CSR_WIFI_ROUTER_CTRL_WIFI_ON_RES: - { - CsrWifiRouterCtrlWifiOnRes *p = (CsrWifiRouterCtrlWifiOnRes *)message; - kfree(p->smeVersions.smeBuild); - p->smeVersions.smeBuild = NULL; - break; - } - case CSR_WIFI_ROUTER_CTRL_WAPI_RX_PKT_REQ: - { - CsrWifiRouterCtrlWapiRxPktReq *p = (CsrWifiRouterCtrlWapiRxPktReq *)message; - kfree(p->signal); - p->signal = NULL; - kfree(p->data); - p->data = NULL; - break; - } - case CSR_WIFI_ROUTER_CTRL_WAPI_UNICAST_TX_PKT_REQ: - { - CsrWifiRouterCtrlWapiUnicastTxPktReq *p = (CsrWifiRouterCtrlWapiUnicastTxPktReq *)message; - kfree(p->data); - p->data = NULL; - break; - } - - default: - break; - } -} - - diff --git a/drivers/staging/csr/csr_wifi_router_ctrl_free_upstream_contents.c b/drivers/staging/csr/csr_wifi_router_ctrl_free_upstream_contents.c deleted file mode 100644 index 954b3defc49c..000000000000 --- a/drivers/staging/csr/csr_wifi_router_ctrl_free_upstream_contents.c +++ /dev/null @@ -1,87 +0,0 @@ -/***************************************************************************** - - (c) Cambridge Silicon Radio Limited 2012 - All rights reserved and confidential information of CSR - - Refer to LICENSE.txt included with this source for details - on the license terms. - -*****************************************************************************/ - -/* Note: this is an auto-generated file. */ -#include -#include "csr_wifi_router_ctrl_prim.h" -#include "csr_wifi_router_ctrl_lib.h" - -/*----------------------------------------------------------------------------* - * NAME - * CsrWifiRouterCtrlFreeUpstreamMessageContents - * - * DESCRIPTION - * - * - * PARAMETERS - * eventClass: only the value CSR_WIFI_ROUTER_CTRL_PRIM will be handled - * message: the message to free - *----------------------------------------------------------------------------*/ -void CsrWifiRouterCtrlFreeUpstreamMessageContents(u16 eventClass, void *message) -{ - if (eventClass != CSR_WIFI_ROUTER_CTRL_PRIM) - { - return; - } - if (NULL == message) - { - return; - } - - switch (*((CsrWifiRouterCtrlPrim *) message)) - { - case CSR_WIFI_ROUTER_CTRL_HIP_IND: - { - CsrWifiRouterCtrlHipInd *p = (CsrWifiRouterCtrlHipInd *)message; - kfree(p->mlmeCommand); - p->mlmeCommand = NULL; - kfree(p->dataRef1); - p->dataRef1 = NULL; - kfree(p->dataRef2); - p->dataRef2 = NULL; - break; - } - case CSR_WIFI_ROUTER_CTRL_MULTICAST_ADDRESS_IND: - { - CsrWifiRouterCtrlMulticastAddressInd *p = (CsrWifiRouterCtrlMulticastAddressInd *)message; - kfree(p->setAddresses); - p->setAddresses = NULL; - break; - } - case CSR_WIFI_ROUTER_CTRL_WIFI_ON_IND: - { - CsrWifiRouterCtrlWifiOnInd *p = (CsrWifiRouterCtrlWifiOnInd *)message; - kfree(p->versions.routerBuild); - p->versions.routerBuild = NULL; - break; - } - case CSR_WIFI_ROUTER_CTRL_WAPI_RX_MIC_CHECK_IND: - { - CsrWifiRouterCtrlWapiRxMicCheckInd *p = (CsrWifiRouterCtrlWapiRxMicCheckInd *)message; - kfree(p->signal); - p->signal = NULL; - kfree(p->data); - p->data = NULL; - break; - } - case CSR_WIFI_ROUTER_CTRL_WAPI_UNICAST_TX_ENCRYPT_IND: - { - CsrWifiRouterCtrlWapiUnicastTxEncryptInd *p = (CsrWifiRouterCtrlWapiUnicastTxEncryptInd *)message; - kfree(p->data); - p->data = NULL; - break; - } - - default: - break; - } -} - - diff --git a/drivers/staging/csr/csr_wifi_router_ctrl_lib.h b/drivers/staging/csr/csr_wifi_router_ctrl_lib.h deleted file mode 100644 index f235153c42af..000000000000 --- a/drivers/staging/csr/csr_wifi_router_ctrl_lib.h +++ /dev/null @@ -1,2082 +0,0 @@ -/***************************************************************************** - - (c) Cambridge Silicon Radio Limited 2012 - All rights reserved and confidential information of CSR - - Refer to LICENSE.txt included with this source for details - on the license terms. - -*****************************************************************************/ - -/* Note: this is an auto-generated file. */ - -#ifndef CSR_WIFI_ROUTER_CTRL_LIB_H__ -#define CSR_WIFI_ROUTER_CTRL_LIB_H__ - -#include "csr_sched.h" -#include "csr_macro.h" -#include "csr_msg_transport.h" - -#include "csr_wifi_lib.h" - -#include "csr_wifi_router_ctrl_prim.h" -#include "csr_wifi_router_task.h" - -/*----------------------------------------------------------------------------* - * CsrWifiRouterCtrlFreeUpstreamMessageContents - * - * DESCRIPTION - * Free the allocated memory in a CSR_WIFI_ROUTER_CTRL upstream message. Does not - * free the message itself, and can only be used for upstream messages. - * - * PARAMETERS - * Deallocates the resources in a CSR_WIFI_ROUTER_CTRL upstream message - *----------------------------------------------------------------------------*/ -void CsrWifiRouterCtrlFreeUpstreamMessageContents(u16 eventClass, void *message); - -/*----------------------------------------------------------------------------* - * CsrWifiRouterCtrlFreeDownstreamMessageContents - * - * DESCRIPTION - * Free the allocated memory in a CSR_WIFI_ROUTER_CTRL downstream message. Does not - * free the message itself, and can only be used for downstream messages. - * - * PARAMETERS - * Deallocates the resources in a CSR_WIFI_ROUTER_CTRL downstream message - *----------------------------------------------------------------------------*/ -void CsrWifiRouterCtrlFreeDownstreamMessageContents(u16 eventClass, void *message); - -/*----------------------------------------------------------------------------* - * Enum to string functions - *----------------------------------------------------------------------------*/ -const char* CsrWifiRouterCtrlBlockAckRoleToString(CsrWifiRouterCtrlBlockAckRole value); -const char* CsrWifiRouterCtrlControlIndicationToString(CsrWifiRouterCtrlControlIndication value); -const char* CsrWifiRouterCtrlListActionToString(CsrWifiRouterCtrlListAction value); -const char* CsrWifiRouterCtrlLowPowerModeToString(CsrWifiRouterCtrlLowPowerMode value); -const char* CsrWifiRouterCtrlMediaStatusToString(CsrWifiRouterCtrlMediaStatus value); -const char* CsrWifiRouterCtrlModeToString(CsrWifiRouterCtrlMode value); -const char* CsrWifiRouterCtrlPeerStatusToString(CsrWifiRouterCtrlPeerStatus value); -const char* CsrWifiRouterCtrlPortActionToString(CsrWifiRouterCtrlPortAction value); -const char* CsrWifiRouterCtrlPowersaveTypeToString(CsrWifiRouterCtrlPowersaveType value); -const char* CsrWifiRouterCtrlProtocolDirectionToString(CsrWifiRouterCtrlProtocolDirection value); -const char* CsrWifiRouterCtrlQoSControlToString(CsrWifiRouterCtrlQoSControl value); -const char* CsrWifiRouterCtrlQueueConfigToString(CsrWifiRouterCtrlQueueConfig value); -const char* CsrWifiRouterCtrlTrafficConfigTypeToString(CsrWifiRouterCtrlTrafficConfigType value); -const char* CsrWifiRouterCtrlTrafficPacketTypeToString(CsrWifiRouterCtrlTrafficPacketType value); -const char* CsrWifiRouterCtrlTrafficTypeToString(CsrWifiRouterCtrlTrafficType value); - - -/*----------------------------------------------------------------------------* - * CsrPrim Type toString function. - * Converts a message type to the String name of the Message - *----------------------------------------------------------------------------*/ -const char* CsrWifiRouterCtrlPrimTypeToString(CsrPrim msgType); - -/*----------------------------------------------------------------------------* - * Lookup arrays for PrimType name Strings - *----------------------------------------------------------------------------*/ -extern const char *CsrWifiRouterCtrlUpstreamPrimNames[CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_COUNT]; -extern const char *CsrWifiRouterCtrlDownstreamPrimNames[CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_COUNT]; - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlBlockAckDisableReqSend - - DESCRIPTION - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - interfaceTag - - clientData - - macAddress - - trafficStreamID - - role - - -*******************************************************************************/ -#define CsrWifiRouterCtrlBlockAckDisableReqCreate(msg__, dst__, src__, interfaceTag__, clientData__, macAddress__, trafficStreamID__, role__) \ - msg__ = kmalloc(sizeof(CsrWifiRouterCtrlBlockAckDisableReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_DISABLE_REQ, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->clientData = (clientData__); \ - msg__->macAddress = (macAddress__); \ - msg__->trafficStreamID = (trafficStreamID__); \ - msg__->role = (role__); - -#define CsrWifiRouterCtrlBlockAckDisableReqSendTo(dst__, src__, interfaceTag__, clientData__, macAddress__, trafficStreamID__, role__) \ - { \ - CsrWifiRouterCtrlBlockAckDisableReq *msg__; \ - CsrWifiRouterCtrlBlockAckDisableReqCreate(msg__, dst__, src__, interfaceTag__, clientData__, macAddress__, trafficStreamID__, role__); \ - CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \ - } - -#define CsrWifiRouterCtrlBlockAckDisableReqSend(src__, interfaceTag__, clientData__, macAddress__, trafficStreamID__, role__) \ - CsrWifiRouterCtrlBlockAckDisableReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, clientData__, macAddress__, trafficStreamID__, role__) - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlBlockAckDisableCfmSend - - DESCRIPTION - - PARAMETERS - queue - Destination Task Queue - clientData - - interfaceTag - - status - - -*******************************************************************************/ -#define CsrWifiRouterCtrlBlockAckDisableCfmCreate(msg__, dst__, src__, clientData__, interfaceTag__, status__) \ - msg__ = kmalloc(sizeof(CsrWifiRouterCtrlBlockAckDisableCfm), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_DISABLE_CFM, dst__, src__); \ - msg__->clientData = (clientData__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->status = (status__); - -#define CsrWifiRouterCtrlBlockAckDisableCfmSendTo(dst__, src__, clientData__, interfaceTag__, status__) \ - { \ - CsrWifiRouterCtrlBlockAckDisableCfm *msg__; \ - CsrWifiRouterCtrlBlockAckDisableCfmCreate(msg__, dst__, src__, clientData__, interfaceTag__, status__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \ - } - -#define CsrWifiRouterCtrlBlockAckDisableCfmSend(dst__, clientData__, interfaceTag__, status__) \ - CsrWifiRouterCtrlBlockAckDisableCfmSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, interfaceTag__, status__) - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlBlockAckEnableReqSend - - DESCRIPTION - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - interfaceTag - - clientData - - macAddress - - trafficStreamID - - role - - bufferSize - - timeout - - ssn - - -*******************************************************************************/ -#define CsrWifiRouterCtrlBlockAckEnableReqCreate(msg__, dst__, src__, interfaceTag__, clientData__, macAddress__, trafficStreamID__, role__, bufferSize__, timeout__, ssn__) \ - msg__ = kmalloc(sizeof(CsrWifiRouterCtrlBlockAckEnableReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_ENABLE_REQ, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->clientData = (clientData__); \ - msg__->macAddress = (macAddress__); \ - msg__->trafficStreamID = (trafficStreamID__); \ - msg__->role = (role__); \ - msg__->bufferSize = (bufferSize__); \ - msg__->timeout = (timeout__); \ - msg__->ssn = (ssn__); - -#define CsrWifiRouterCtrlBlockAckEnableReqSendTo(dst__, src__, interfaceTag__, clientData__, macAddress__, trafficStreamID__, role__, bufferSize__, timeout__, ssn__) \ - { \ - CsrWifiRouterCtrlBlockAckEnableReq *msg__; \ - CsrWifiRouterCtrlBlockAckEnableReqCreate(msg__, dst__, src__, interfaceTag__, clientData__, macAddress__, trafficStreamID__, role__, bufferSize__, timeout__, ssn__); \ - CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \ - } - -#define CsrWifiRouterCtrlBlockAckEnableReqSend(src__, interfaceTag__, clientData__, macAddress__, trafficStreamID__, role__, bufferSize__, timeout__, ssn__) \ - CsrWifiRouterCtrlBlockAckEnableReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, clientData__, macAddress__, trafficStreamID__, role__, bufferSize__, timeout__, ssn__) - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlBlockAckEnableCfmSend - - DESCRIPTION - - PARAMETERS - queue - Destination Task Queue - clientData - - interfaceTag - - status - - -*******************************************************************************/ -#define CsrWifiRouterCtrlBlockAckEnableCfmCreate(msg__, dst__, src__, clientData__, interfaceTag__, status__) \ - msg__ = kmalloc(sizeof(CsrWifiRouterCtrlBlockAckEnableCfm), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_ENABLE_CFM, dst__, src__); \ - msg__->clientData = (clientData__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->status = (status__); - -#define CsrWifiRouterCtrlBlockAckEnableCfmSendTo(dst__, src__, clientData__, interfaceTag__, status__) \ - { \ - CsrWifiRouterCtrlBlockAckEnableCfm *msg__; \ - CsrWifiRouterCtrlBlockAckEnableCfmCreate(msg__, dst__, src__, clientData__, interfaceTag__, status__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \ - } - -#define CsrWifiRouterCtrlBlockAckEnableCfmSend(dst__, clientData__, interfaceTag__, status__) \ - CsrWifiRouterCtrlBlockAckEnableCfmSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, interfaceTag__, status__) - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlBlockAckErrorIndSend - - DESCRIPTION - - PARAMETERS - queue - Destination Task Queue - clientData - - interfaceTag - - trafficStreamID - - peerMacAddress - - status - - -*******************************************************************************/ -#define CsrWifiRouterCtrlBlockAckErrorIndCreate(msg__, dst__, src__, clientData__, interfaceTag__, trafficStreamID__, peerMacAddress__, status__) \ - msg__ = kmalloc(sizeof(CsrWifiRouterCtrlBlockAckErrorInd), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_ERROR_IND, dst__, src__); \ - msg__->clientData = (clientData__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->trafficStreamID = (trafficStreamID__); \ - msg__->peerMacAddress = (peerMacAddress__); \ - msg__->status = (status__); - -#define CsrWifiRouterCtrlBlockAckErrorIndSendTo(dst__, src__, clientData__, interfaceTag__, trafficStreamID__, peerMacAddress__, status__) \ - { \ - CsrWifiRouterCtrlBlockAckErrorInd *msg__; \ - CsrWifiRouterCtrlBlockAckErrorIndCreate(msg__, dst__, src__, clientData__, interfaceTag__, trafficStreamID__, peerMacAddress__, status__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \ - } - -#define CsrWifiRouterCtrlBlockAckErrorIndSend(dst__, clientData__, interfaceTag__, trafficStreamID__, peerMacAddress__, status__) \ - CsrWifiRouterCtrlBlockAckErrorIndSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, interfaceTag__, trafficStreamID__, peerMacAddress__, status__) - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlCapabilitiesReqSend - - DESCRIPTION - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - clientData - - -*******************************************************************************/ -#define CsrWifiRouterCtrlCapabilitiesReqCreate(msg__, dst__, src__, clientData__) \ - msg__ = kmalloc(sizeof(CsrWifiRouterCtrlCapabilitiesReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_CAPABILITIES_REQ, dst__, src__); \ - msg__->clientData = (clientData__); - -#define CsrWifiRouterCtrlCapabilitiesReqSendTo(dst__, src__, clientData__) \ - { \ - CsrWifiRouterCtrlCapabilitiesReq *msg__; \ - CsrWifiRouterCtrlCapabilitiesReqCreate(msg__, dst__, src__, clientData__); \ - CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \ - } - -#define CsrWifiRouterCtrlCapabilitiesReqSend(src__, clientData__) \ - CsrWifiRouterCtrlCapabilitiesReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, clientData__) - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlCapabilitiesCfmSend - - DESCRIPTION - The router sends this primitive to confirm the size of the queues of the - HIP. - - PARAMETERS - queue - Destination Task Queue - clientData - - commandQueueSize - Size of command queue - trafficQueueSize - Size of traffic queue (per AC) - -*******************************************************************************/ -#define CsrWifiRouterCtrlCapabilitiesCfmCreate(msg__, dst__, src__, clientData__, commandQueueSize__, trafficQueueSize__) \ - msg__ = kmalloc(sizeof(CsrWifiRouterCtrlCapabilitiesCfm), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_CAPABILITIES_CFM, dst__, src__); \ - msg__->clientData = (clientData__); \ - msg__->commandQueueSize = (commandQueueSize__); \ - msg__->trafficQueueSize = (trafficQueueSize__); - -#define CsrWifiRouterCtrlCapabilitiesCfmSendTo(dst__, src__, clientData__, commandQueueSize__, trafficQueueSize__) \ - { \ - CsrWifiRouterCtrlCapabilitiesCfm *msg__; \ - CsrWifiRouterCtrlCapabilitiesCfmCreate(msg__, dst__, src__, clientData__, commandQueueSize__, trafficQueueSize__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \ - } - -#define CsrWifiRouterCtrlCapabilitiesCfmSend(dst__, clientData__, commandQueueSize__, trafficQueueSize__) \ - CsrWifiRouterCtrlCapabilitiesCfmSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, commandQueueSize__, trafficQueueSize__) - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlConfigurePowerModeReqSend - - DESCRIPTION - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - clientData - - mode - - wakeHost - - -*******************************************************************************/ -#define CsrWifiRouterCtrlConfigurePowerModeReqCreate(msg__, dst__, src__, clientData__, mode__, wakeHost__) \ - msg__ = kmalloc(sizeof(CsrWifiRouterCtrlConfigurePowerModeReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_CONFIGURE_POWER_MODE_REQ, dst__, src__); \ - msg__->clientData = (clientData__); \ - msg__->mode = (mode__); \ - msg__->wakeHost = (wakeHost__); - -#define CsrWifiRouterCtrlConfigurePowerModeReqSendTo(dst__, src__, clientData__, mode__, wakeHost__) \ - { \ - CsrWifiRouterCtrlConfigurePowerModeReq *msg__; \ - CsrWifiRouterCtrlConfigurePowerModeReqCreate(msg__, dst__, src__, clientData__, mode__, wakeHost__); \ - CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \ - } - -#define CsrWifiRouterCtrlConfigurePowerModeReqSend(src__, clientData__, mode__, wakeHost__) \ - CsrWifiRouterCtrlConfigurePowerModeReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, clientData__, mode__, wakeHost__) - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlConnectedIndSend - - DESCRIPTION - - PARAMETERS - queue - Destination Task Queue - clientData - - interfaceTag - - peerMacAddress - - peerStatus - - -*******************************************************************************/ -#define CsrWifiRouterCtrlConnectedIndCreate(msg__, dst__, src__, clientData__, interfaceTag__, peerMacAddress__, peerStatus__) \ - msg__ = kmalloc(sizeof(CsrWifiRouterCtrlConnectedInd), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_CONNECTED_IND, dst__, src__); \ - msg__->clientData = (clientData__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->peerMacAddress = (peerMacAddress__); \ - msg__->peerStatus = (peerStatus__); - -#define CsrWifiRouterCtrlConnectedIndSendTo(dst__, src__, clientData__, interfaceTag__, peerMacAddress__, peerStatus__) \ - { \ - CsrWifiRouterCtrlConnectedInd *msg__; \ - CsrWifiRouterCtrlConnectedIndCreate(msg__, dst__, src__, clientData__, interfaceTag__, peerMacAddress__, peerStatus__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \ - } - -#define CsrWifiRouterCtrlConnectedIndSend(dst__, clientData__, interfaceTag__, peerMacAddress__, peerStatus__) \ - CsrWifiRouterCtrlConnectedIndSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, interfaceTag__, peerMacAddress__, peerStatus__) - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlHipReqSend - - DESCRIPTION - This primitive is used for transferring MLME messages to the HIP. - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - mlmeCommandLength - Length of the MLME signal - mlmeCommand - Pointer to the MLME signal - dataRef1Length - Length of the dataRef1 bulk data - dataRef1 - Pointer to the bulk data 1 - dataRef2Length - Length of the dataRef2 bulk data - dataRef2 - Pointer to the bulk data 2 - -*******************************************************************************/ -#define CsrWifiRouterCtrlHipReqCreate(msg__, dst__, src__, mlmeCommandLength__, mlmeCommand__, dataRef1Length__, dataRef1__, dataRef2Length__, dataRef2__) \ - msg__ = kmalloc(sizeof(CsrWifiRouterCtrlHipReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_HIP_REQ, dst__, src__); \ - msg__->mlmeCommandLength = (mlmeCommandLength__); \ - msg__->mlmeCommand = (mlmeCommand__); \ - msg__->dataRef1Length = (dataRef1Length__); \ - msg__->dataRef1 = (dataRef1__); \ - msg__->dataRef2Length = (dataRef2Length__); \ - msg__->dataRef2 = (dataRef2__); - -#define CsrWifiRouterCtrlHipReqSendTo(dst__, src__, mlmeCommandLength__, mlmeCommand__, dataRef1Length__, dataRef1__, dataRef2Length__, dataRef2__) \ - { \ - CsrWifiRouterCtrlHipReq *msg__; \ - CsrWifiRouterCtrlHipReqCreate(msg__, dst__, src__, mlmeCommandLength__, mlmeCommand__, dataRef1Length__, dataRef1__, dataRef2Length__, dataRef2__); \ - CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \ - } - -#define CsrWifiRouterCtrlHipReqSend(src__, mlmeCommandLength__, mlmeCommand__, dataRef1Length__, dataRef1__, dataRef2Length__, dataRef2__) \ - CsrWifiRouterCtrlHipReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, mlmeCommandLength__, mlmeCommand__, dataRef1Length__, dataRef1__, dataRef2Length__, dataRef2__) - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlHipIndSend - - DESCRIPTION - This primitive is used for transferring MLME messages from the HIP. - - PARAMETERS - queue - Destination Task Queue - mlmeCommandLength - Length of the MLME signal - mlmeCommand - Pointer to the MLME signal - dataRef1Length - Length of the dataRef1 bulk data - dataRef1 - Pointer to the bulk data 1 - dataRef2Length - Length of the dataRef2 bulk data - dataRef2 - Pointer to the bulk data 2 - -*******************************************************************************/ -#define CsrWifiRouterCtrlHipIndCreate(msg__, dst__, src__, mlmeCommandLength__, mlmeCommand__, dataRef1Length__, dataRef1__, dataRef2Length__, dataRef2__) \ - msg__ = kmalloc(sizeof(CsrWifiRouterCtrlHipInd), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_HIP_IND, dst__, src__); \ - msg__->mlmeCommandLength = (mlmeCommandLength__); \ - msg__->mlmeCommand = (mlmeCommand__); \ - msg__->dataRef1Length = (dataRef1Length__); \ - msg__->dataRef1 = (dataRef1__); \ - msg__->dataRef2Length = (dataRef2Length__); \ - msg__->dataRef2 = (dataRef2__); - -#define CsrWifiRouterCtrlHipIndSendTo(dst__, src__, mlmeCommandLength__, mlmeCommand__, dataRef1Length__, dataRef1__, dataRef2Length__, dataRef2__) \ - { \ - CsrWifiRouterCtrlHipInd *msg__; \ - CsrWifiRouterCtrlHipIndCreate(msg__, dst__, src__, mlmeCommandLength__, mlmeCommand__, dataRef1Length__, dataRef1__, dataRef2Length__, dataRef2__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \ - } - -#define CsrWifiRouterCtrlHipIndSend(dst__, mlmeCommandLength__, mlmeCommand__, dataRef1Length__, dataRef1__, dataRef2Length__, dataRef2__) \ - CsrWifiRouterCtrlHipIndSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, mlmeCommandLength__, mlmeCommand__, dataRef1Length__, dataRef1__, dataRef2Length__, dataRef2__) - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlM4ReadyToSendIndSend - - DESCRIPTION - - PARAMETERS - queue - Destination Task Queue - clientData - - interfaceTag - - peerMacAddress - - -*******************************************************************************/ -#define CsrWifiRouterCtrlM4ReadyToSendIndCreate(msg__, dst__, src__, clientData__, interfaceTag__, peerMacAddress__) \ - msg__ = kmalloc(sizeof(CsrWifiRouterCtrlM4ReadyToSendInd), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_M4_READY_TO_SEND_IND, dst__, src__); \ - msg__->clientData = (clientData__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->peerMacAddress = (peerMacAddress__); - -#define CsrWifiRouterCtrlM4ReadyToSendIndSendTo(dst__, src__, clientData__, interfaceTag__, peerMacAddress__) \ - { \ - CsrWifiRouterCtrlM4ReadyToSendInd *msg__; \ - CsrWifiRouterCtrlM4ReadyToSendIndCreate(msg__, dst__, src__, clientData__, interfaceTag__, peerMacAddress__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \ - } - -#define CsrWifiRouterCtrlM4ReadyToSendIndSend(dst__, clientData__, interfaceTag__, peerMacAddress__) \ - CsrWifiRouterCtrlM4ReadyToSendIndSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, interfaceTag__, peerMacAddress__) - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlM4TransmitReqSend - - DESCRIPTION - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - interfaceTag - - clientData - - -*******************************************************************************/ -#define CsrWifiRouterCtrlM4TransmitReqCreate(msg__, dst__, src__, interfaceTag__, clientData__) \ - msg__ = kmalloc(sizeof(CsrWifiRouterCtrlM4TransmitReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_M4_TRANSMIT_REQ, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->clientData = (clientData__); - -#define CsrWifiRouterCtrlM4TransmitReqSendTo(dst__, src__, interfaceTag__, clientData__) \ - { \ - CsrWifiRouterCtrlM4TransmitReq *msg__; \ - CsrWifiRouterCtrlM4TransmitReqCreate(msg__, dst__, src__, interfaceTag__, clientData__); \ - CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \ - } - -#define CsrWifiRouterCtrlM4TransmitReqSend(src__, interfaceTag__, clientData__) \ - CsrWifiRouterCtrlM4TransmitReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, clientData__) - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlM4TransmittedIndSend - - DESCRIPTION - - PARAMETERS - queue - Destination Task Queue - clientData - - interfaceTag - - peerMacAddress - - status - - -*******************************************************************************/ -#define CsrWifiRouterCtrlM4TransmittedIndCreate(msg__, dst__, src__, clientData__, interfaceTag__, peerMacAddress__, status__) \ - msg__ = kmalloc(sizeof(CsrWifiRouterCtrlM4TransmittedInd), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_M4_TRANSMITTED_IND, dst__, src__); \ - msg__->clientData = (clientData__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->peerMacAddress = (peerMacAddress__); \ - msg__->status = (status__); - -#define CsrWifiRouterCtrlM4TransmittedIndSendTo(dst__, src__, clientData__, interfaceTag__, peerMacAddress__, status__) \ - { \ - CsrWifiRouterCtrlM4TransmittedInd *msg__; \ - CsrWifiRouterCtrlM4TransmittedIndCreate(msg__, dst__, src__, clientData__, interfaceTag__, peerMacAddress__, status__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \ - } - -#define CsrWifiRouterCtrlM4TransmittedIndSend(dst__, clientData__, interfaceTag__, peerMacAddress__, status__) \ - CsrWifiRouterCtrlM4TransmittedIndSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, interfaceTag__, peerMacAddress__, status__) - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlMediaStatusReqSend - - DESCRIPTION - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - interfaceTag - - clientData - - mediaStatus - - -*******************************************************************************/ -#define CsrWifiRouterCtrlMediaStatusReqCreate(msg__, dst__, src__, interfaceTag__, clientData__, mediaStatus__) \ - msg__ = kmalloc(sizeof(CsrWifiRouterCtrlMediaStatusReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_MEDIA_STATUS_REQ, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->clientData = (clientData__); \ - msg__->mediaStatus = (mediaStatus__); - -#define CsrWifiRouterCtrlMediaStatusReqSendTo(dst__, src__, interfaceTag__, clientData__, mediaStatus__) \ - { \ - CsrWifiRouterCtrlMediaStatusReq *msg__; \ - CsrWifiRouterCtrlMediaStatusReqCreate(msg__, dst__, src__, interfaceTag__, clientData__, mediaStatus__); \ - CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \ - } - -#define CsrWifiRouterCtrlMediaStatusReqSend(src__, interfaceTag__, clientData__, mediaStatus__) \ - CsrWifiRouterCtrlMediaStatusReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, clientData__, mediaStatus__) - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlMicFailureIndSend - - DESCRIPTION - - PARAMETERS - queue - Destination Task Queue - clientData - - interfaceTag - - peerMacAddress - - unicastPdu - - -*******************************************************************************/ -#define CsrWifiRouterCtrlMicFailureIndCreate(msg__, dst__, src__, clientData__, interfaceTag__, peerMacAddress__, unicastPdu__) \ - msg__ = kmalloc(sizeof(CsrWifiRouterCtrlMicFailureInd), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_MIC_FAILURE_IND, dst__, src__); \ - msg__->clientData = (clientData__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->peerMacAddress = (peerMacAddress__); \ - msg__->unicastPdu = (unicastPdu__); - -#define CsrWifiRouterCtrlMicFailureIndSendTo(dst__, src__, clientData__, interfaceTag__, peerMacAddress__, unicastPdu__) \ - { \ - CsrWifiRouterCtrlMicFailureInd *msg__; \ - CsrWifiRouterCtrlMicFailureIndCreate(msg__, dst__, src__, clientData__, interfaceTag__, peerMacAddress__, unicastPdu__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \ - } - -#define CsrWifiRouterCtrlMicFailureIndSend(dst__, clientData__, interfaceTag__, peerMacAddress__, unicastPdu__) \ - CsrWifiRouterCtrlMicFailureIndSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, interfaceTag__, peerMacAddress__, unicastPdu__) - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlModeSetReqSend - - DESCRIPTION - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - interfaceTag - - clientData - - mode - - bssid - BSSID of the network the device is going to be a part - of - protection - Set to TRUE if encryption is enabled for the - connection/broadcast frames - intraBssDistEnabled - If set to TRUE, intra BSS destribution will be - enabled. If set to FALSE, any unicast PDU which does - not have the RA as the the local MAC address, shall be - ignored. This field is interpreted by the receive if - mode is set to CSR_WIFI_ROUTER_CTRL_MODE_P2PGO - -*******************************************************************************/ -#define CsrWifiRouterCtrlModeSetReqCreate(msg__, dst__, src__, interfaceTag__, clientData__, mode__, bssid__, protection__, intraBssDistEnabled__) \ - msg__ = kmalloc(sizeof(CsrWifiRouterCtrlModeSetReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_MODE_SET_REQ, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->clientData = (clientData__); \ - msg__->mode = (mode__); \ - msg__->bssid = (bssid__); \ - msg__->protection = (protection__); \ - msg__->intraBssDistEnabled = (intraBssDistEnabled__); - -#define CsrWifiRouterCtrlModeSetReqSendTo(dst__, src__, interfaceTag__, clientData__, mode__, bssid__, protection__, intraBssDistEnabled__) \ - { \ - CsrWifiRouterCtrlModeSetReq *msg__; \ - CsrWifiRouterCtrlModeSetReqCreate(msg__, dst__, src__, interfaceTag__, clientData__, mode__, bssid__, protection__, intraBssDistEnabled__); \ - CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \ - } - -#define CsrWifiRouterCtrlModeSetReqSend(src__, interfaceTag__, clientData__, mode__, bssid__, protection__, intraBssDistEnabled__) \ - CsrWifiRouterCtrlModeSetReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, clientData__, mode__, bssid__, protection__, intraBssDistEnabled__) - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlModeSetCfmSend - - DESCRIPTION - - PARAMETERS - queue - Destination Task Queue - clientData - - interfaceTag - - mode - - status - - -*******************************************************************************/ -#define CsrWifiRouterCtrlModeSetCfmCreate(msg__, dst__, src__, clientData__, interfaceTag__, mode__, status__) \ - msg__ = kmalloc(sizeof(CsrWifiRouterCtrlModeSetCfm), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_MODE_SET_CFM, dst__, src__); \ - msg__->clientData = (clientData__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->mode = (mode__); \ - msg__->status = (status__); - -#define CsrWifiRouterCtrlModeSetCfmSendTo(dst__, src__, clientData__, interfaceTag__, mode__, status__) \ - { \ - CsrWifiRouterCtrlModeSetCfm *msg__; \ - CsrWifiRouterCtrlModeSetCfmCreate(msg__, dst__, src__, clientData__, interfaceTag__, mode__, status__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \ - } - -#define CsrWifiRouterCtrlModeSetCfmSend(dst__, clientData__, interfaceTag__, mode__, status__) \ - CsrWifiRouterCtrlModeSetCfmSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, interfaceTag__, mode__, status__) - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlMulticastAddressIndSend - - DESCRIPTION - - PARAMETERS - queue - Destination Task Queue - clientData - - interfaceTag - - action - - setAddressesCount - - setAddresses - - -*******************************************************************************/ -#define CsrWifiRouterCtrlMulticastAddressIndCreate(msg__, dst__, src__, clientData__, interfaceTag__, action__, setAddressesCount__, setAddresses__) \ - msg__ = kmalloc(sizeof(CsrWifiRouterCtrlMulticastAddressInd), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_MULTICAST_ADDRESS_IND, dst__, src__); \ - msg__->clientData = (clientData__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->action = (action__); \ - msg__->setAddressesCount = (setAddressesCount__); \ - msg__->setAddresses = (setAddresses__); - -#define CsrWifiRouterCtrlMulticastAddressIndSendTo(dst__, src__, clientData__, interfaceTag__, action__, setAddressesCount__, setAddresses__) \ - { \ - CsrWifiRouterCtrlMulticastAddressInd *msg__; \ - CsrWifiRouterCtrlMulticastAddressIndCreate(msg__, dst__, src__, clientData__, interfaceTag__, action__, setAddressesCount__, setAddresses__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \ - } - -#define CsrWifiRouterCtrlMulticastAddressIndSend(dst__, clientData__, interfaceTag__, action__, setAddressesCount__, setAddresses__) \ - CsrWifiRouterCtrlMulticastAddressIndSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, interfaceTag__, action__, setAddressesCount__, setAddresses__) - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlMulticastAddressResSend - - DESCRIPTION - - PARAMETERS - interfaceTag - - clientData - - status - - action - - getAddressesCount - - getAddresses - - -*******************************************************************************/ -#define CsrWifiRouterCtrlMulticastAddressResCreate(msg__, dst__, src__, interfaceTag__, clientData__, status__, action__, getAddressesCount__, getAddresses__) \ - msg__ = kmalloc(sizeof(CsrWifiRouterCtrlMulticastAddressRes), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_MULTICAST_ADDRESS_RES, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->clientData = (clientData__); \ - msg__->status = (status__); \ - msg__->action = (action__); \ - msg__->getAddressesCount = (getAddressesCount__); \ - msg__->getAddresses = (getAddresses__); - -#define CsrWifiRouterCtrlMulticastAddressResSendTo(dst__, src__, interfaceTag__, clientData__, status__, action__, getAddressesCount__, getAddresses__) \ - { \ - CsrWifiRouterCtrlMulticastAddressRes *msg__; \ - CsrWifiRouterCtrlMulticastAddressResCreate(msg__, dst__, src__, interfaceTag__, clientData__, status__, action__, getAddressesCount__, getAddresses__); \ - CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \ - } - -#define CsrWifiRouterCtrlMulticastAddressResSend(src__, interfaceTag__, clientData__, status__, action__, getAddressesCount__, getAddresses__) \ - CsrWifiRouterCtrlMulticastAddressResSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, clientData__, status__, action__, getAddressesCount__, getAddresses__) - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlPeerAddReqSend - - DESCRIPTION - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - interfaceTag - - clientData - - peerMacAddress - - associationId - - staInfo - - -*******************************************************************************/ -#define CsrWifiRouterCtrlPeerAddReqCreate(msg__, dst__, src__, interfaceTag__, clientData__, peerMacAddress__, associationId__, staInfo__) \ - msg__ = kmalloc(sizeof(CsrWifiRouterCtrlPeerAddReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_PEER_ADD_REQ, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->clientData = (clientData__); \ - msg__->peerMacAddress = (peerMacAddress__); \ - msg__->associationId = (associationId__); \ - msg__->staInfo = (staInfo__); - -#define CsrWifiRouterCtrlPeerAddReqSendTo(dst__, src__, interfaceTag__, clientData__, peerMacAddress__, associationId__, staInfo__) \ - { \ - CsrWifiRouterCtrlPeerAddReq *msg__; \ - CsrWifiRouterCtrlPeerAddReqCreate(msg__, dst__, src__, interfaceTag__, clientData__, peerMacAddress__, associationId__, staInfo__); \ - CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \ - } - -#define CsrWifiRouterCtrlPeerAddReqSend(src__, interfaceTag__, clientData__, peerMacAddress__, associationId__, staInfo__) \ - CsrWifiRouterCtrlPeerAddReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, clientData__, peerMacAddress__, associationId__, staInfo__) - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlPeerAddCfmSend - - DESCRIPTION - - PARAMETERS - queue - Destination Task Queue - clientData - - interfaceTag - - peerMacAddress - - peerRecordHandle - - status - - -*******************************************************************************/ -#define CsrWifiRouterCtrlPeerAddCfmCreate(msg__, dst__, src__, clientData__, interfaceTag__, peerMacAddress__, peerRecordHandle__, status__) \ - msg__ = kmalloc(sizeof(CsrWifiRouterCtrlPeerAddCfm), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_PEER_ADD_CFM, dst__, src__); \ - msg__->clientData = (clientData__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->peerMacAddress = (peerMacAddress__); \ - msg__->peerRecordHandle = (peerRecordHandle__); \ - msg__->status = (status__); - -#define CsrWifiRouterCtrlPeerAddCfmSendTo(dst__, src__, clientData__, interfaceTag__, peerMacAddress__, peerRecordHandle__, status__) \ - { \ - CsrWifiRouterCtrlPeerAddCfm *msg__; \ - CsrWifiRouterCtrlPeerAddCfmCreate(msg__, dst__, src__, clientData__, interfaceTag__, peerMacAddress__, peerRecordHandle__, status__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \ - } - -#define CsrWifiRouterCtrlPeerAddCfmSend(dst__, clientData__, interfaceTag__, peerMacAddress__, peerRecordHandle__, status__) \ - CsrWifiRouterCtrlPeerAddCfmSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, interfaceTag__, peerMacAddress__, peerRecordHandle__, status__) - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlPeerDelReqSend - - DESCRIPTION - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - interfaceTag - - clientData - - peerRecordHandle - - -*******************************************************************************/ -#define CsrWifiRouterCtrlPeerDelReqCreate(msg__, dst__, src__, interfaceTag__, clientData__, peerRecordHandle__) \ - msg__ = kmalloc(sizeof(CsrWifiRouterCtrlPeerDelReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_PEER_DEL_REQ, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->clientData = (clientData__); \ - msg__->peerRecordHandle = (peerRecordHandle__); - -#define CsrWifiRouterCtrlPeerDelReqSendTo(dst__, src__, interfaceTag__, clientData__, peerRecordHandle__) \ - { \ - CsrWifiRouterCtrlPeerDelReq *msg__; \ - CsrWifiRouterCtrlPeerDelReqCreate(msg__, dst__, src__, interfaceTag__, clientData__, peerRecordHandle__); \ - CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \ - } - -#define CsrWifiRouterCtrlPeerDelReqSend(src__, interfaceTag__, clientData__, peerRecordHandle__) \ - CsrWifiRouterCtrlPeerDelReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, clientData__, peerRecordHandle__) - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlPeerDelCfmSend - - DESCRIPTION - - PARAMETERS - queue - Destination Task Queue - clientData - - interfaceTag - - status - - -*******************************************************************************/ -#define CsrWifiRouterCtrlPeerDelCfmCreate(msg__, dst__, src__, clientData__, interfaceTag__, status__) \ - msg__ = kmalloc(sizeof(CsrWifiRouterCtrlPeerDelCfm), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_PEER_DEL_CFM, dst__, src__); \ - msg__->clientData = (clientData__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->status = (status__); - -#define CsrWifiRouterCtrlPeerDelCfmSendTo(dst__, src__, clientData__, interfaceTag__, status__) \ - { \ - CsrWifiRouterCtrlPeerDelCfm *msg__; \ - CsrWifiRouterCtrlPeerDelCfmCreate(msg__, dst__, src__, clientData__, interfaceTag__, status__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \ - } - -#define CsrWifiRouterCtrlPeerDelCfmSend(dst__, clientData__, interfaceTag__, status__) \ - CsrWifiRouterCtrlPeerDelCfmSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, interfaceTag__, status__) - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlPeerUpdateReqSend - - DESCRIPTION - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - interfaceTag - - clientData - - peerRecordHandle - - powersaveMode - - -*******************************************************************************/ -#define CsrWifiRouterCtrlPeerUpdateReqCreate(msg__, dst__, src__, interfaceTag__, clientData__, peerRecordHandle__, powersaveMode__) \ - msg__ = kmalloc(sizeof(CsrWifiRouterCtrlPeerUpdateReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_PEER_UPDATE_REQ, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->clientData = (clientData__); \ - msg__->peerRecordHandle = (peerRecordHandle__); \ - msg__->powersaveMode = (powersaveMode__); - -#define CsrWifiRouterCtrlPeerUpdateReqSendTo(dst__, src__, interfaceTag__, clientData__, peerRecordHandle__, powersaveMode__) \ - { \ - CsrWifiRouterCtrlPeerUpdateReq *msg__; \ - CsrWifiRouterCtrlPeerUpdateReqCreate(msg__, dst__, src__, interfaceTag__, clientData__, peerRecordHandle__, powersaveMode__); \ - CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \ - } - -#define CsrWifiRouterCtrlPeerUpdateReqSend(src__, interfaceTag__, clientData__, peerRecordHandle__, powersaveMode__) \ - CsrWifiRouterCtrlPeerUpdateReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, clientData__, peerRecordHandle__, powersaveMode__) - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlPeerUpdateCfmSend - - DESCRIPTION - - PARAMETERS - queue - Destination Task Queue - clientData - - interfaceTag - - status - - -*******************************************************************************/ -#define CsrWifiRouterCtrlPeerUpdateCfmCreate(msg__, dst__, src__, clientData__, interfaceTag__, status__) \ - msg__ = kmalloc(sizeof(CsrWifiRouterCtrlPeerUpdateCfm), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_PEER_UPDATE_CFM, dst__, src__); \ - msg__->clientData = (clientData__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->status = (status__); - -#define CsrWifiRouterCtrlPeerUpdateCfmSendTo(dst__, src__, clientData__, interfaceTag__, status__) \ - { \ - CsrWifiRouterCtrlPeerUpdateCfm *msg__; \ - CsrWifiRouterCtrlPeerUpdateCfmCreate(msg__, dst__, src__, clientData__, interfaceTag__, status__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \ - } - -#define CsrWifiRouterCtrlPeerUpdateCfmSend(dst__, clientData__, interfaceTag__, status__) \ - CsrWifiRouterCtrlPeerUpdateCfmSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, interfaceTag__, status__) - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlPortConfigureReqSend - - DESCRIPTION - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - interfaceTag - - clientData - - uncontrolledPortAction - - controlledPortAction - - macAddress - - setProtection - - -*******************************************************************************/ -#define CsrWifiRouterCtrlPortConfigureReqCreate(msg__, dst__, src__, interfaceTag__, clientData__, uncontrolledPortAction__, controlledPortAction__, macAddress__, setProtection__) \ - msg__ = kmalloc(sizeof(CsrWifiRouterCtrlPortConfigureReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_PORT_CONFIGURE_REQ, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->clientData = (clientData__); \ - msg__->uncontrolledPortAction = (uncontrolledPortAction__); \ - msg__->controlledPortAction = (controlledPortAction__); \ - msg__->macAddress = (macAddress__); \ - msg__->setProtection = (setProtection__); - -#define CsrWifiRouterCtrlPortConfigureReqSendTo(dst__, src__, interfaceTag__, clientData__, uncontrolledPortAction__, controlledPortAction__, macAddress__, setProtection__) \ - { \ - CsrWifiRouterCtrlPortConfigureReq *msg__; \ - CsrWifiRouterCtrlPortConfigureReqCreate(msg__, dst__, src__, interfaceTag__, clientData__, uncontrolledPortAction__, controlledPortAction__, macAddress__, setProtection__); \ - CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \ - } - -#define CsrWifiRouterCtrlPortConfigureReqSend(src__, interfaceTag__, clientData__, uncontrolledPortAction__, controlledPortAction__, macAddress__, setProtection__) \ - CsrWifiRouterCtrlPortConfigureReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, clientData__, uncontrolledPortAction__, controlledPortAction__, macAddress__, setProtection__) - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlPortConfigureCfmSend - - DESCRIPTION - - PARAMETERS - queue - Destination Task Queue - clientData - - interfaceTag - - status - - macAddress - - -*******************************************************************************/ -#define CsrWifiRouterCtrlPortConfigureCfmCreate(msg__, dst__, src__, clientData__, interfaceTag__, status__, macAddress__) \ - msg__ = kmalloc(sizeof(CsrWifiRouterCtrlPortConfigureCfm), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_PORT_CONFIGURE_CFM, dst__, src__); \ - msg__->clientData = (clientData__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->status = (status__); \ - msg__->macAddress = (macAddress__); - -#define CsrWifiRouterCtrlPortConfigureCfmSendTo(dst__, src__, clientData__, interfaceTag__, status__, macAddress__) \ - { \ - CsrWifiRouterCtrlPortConfigureCfm *msg__; \ - CsrWifiRouterCtrlPortConfigureCfmCreate(msg__, dst__, src__, clientData__, interfaceTag__, status__, macAddress__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \ - } - -#define CsrWifiRouterCtrlPortConfigureCfmSend(dst__, clientData__, interfaceTag__, status__, macAddress__) \ - CsrWifiRouterCtrlPortConfigureCfmSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, interfaceTag__, status__, macAddress__) - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlQosControlReqSend - - DESCRIPTION - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - interfaceTag - - clientData - - control - - queueConfig - - -*******************************************************************************/ -#define CsrWifiRouterCtrlQosControlReqCreate(msg__, dst__, src__, interfaceTag__, clientData__, control__, queueConfig__) \ - msg__ = kmalloc(sizeof(CsrWifiRouterCtrlQosControlReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_QOS_CONTROL_REQ, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->clientData = (clientData__); \ - msg__->control = (control__); \ - msg__->queueConfig = (queueConfig__); - -#define CsrWifiRouterCtrlQosControlReqSendTo(dst__, src__, interfaceTag__, clientData__, control__, queueConfig__) \ - { \ - CsrWifiRouterCtrlQosControlReq *msg__; \ - CsrWifiRouterCtrlQosControlReqCreate(msg__, dst__, src__, interfaceTag__, clientData__, control__, queueConfig__); \ - CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \ - } - -#define CsrWifiRouterCtrlQosControlReqSend(src__, interfaceTag__, clientData__, control__, queueConfig__) \ - CsrWifiRouterCtrlQosControlReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, clientData__, control__, queueConfig__) - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlRawSdioDeinitialiseReqSend - - DESCRIPTION - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - clientData - - -*******************************************************************************/ -#define CsrWifiRouterCtrlRawSdioDeinitialiseReqCreate(msg__, dst__, src__, clientData__) \ - msg__ = kmalloc(sizeof(CsrWifiRouterCtrlRawSdioDeinitialiseReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_RAW_SDIO_DEINITIALISE_REQ, dst__, src__); \ - msg__->clientData = (clientData__); - -#define CsrWifiRouterCtrlRawSdioDeinitialiseReqSendTo(dst__, src__, clientData__) \ - { \ - CsrWifiRouterCtrlRawSdioDeinitialiseReq *msg__; \ - CsrWifiRouterCtrlRawSdioDeinitialiseReqCreate(msg__, dst__, src__, clientData__); \ - CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \ - } - -#define CsrWifiRouterCtrlRawSdioDeinitialiseReqSend(src__, clientData__) \ - CsrWifiRouterCtrlRawSdioDeinitialiseReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, clientData__) - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlRawSdioDeinitialiseCfmSend - - DESCRIPTION - - PARAMETERS - queue - Destination Task Queue - clientData - - result - - -*******************************************************************************/ -#define CsrWifiRouterCtrlRawSdioDeinitialiseCfmCreate(msg__, dst__, src__, clientData__, result__) \ - msg__ = kmalloc(sizeof(CsrWifiRouterCtrlRawSdioDeinitialiseCfm), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_RAW_SDIO_DEINITIALISE_CFM, dst__, src__); \ - msg__->clientData = (clientData__); \ - msg__->result = (result__); - -#define CsrWifiRouterCtrlRawSdioDeinitialiseCfmSendTo(dst__, src__, clientData__, result__) \ - { \ - CsrWifiRouterCtrlRawSdioDeinitialiseCfm *msg__; \ - CsrWifiRouterCtrlRawSdioDeinitialiseCfmCreate(msg__, dst__, src__, clientData__, result__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \ - } - -#define CsrWifiRouterCtrlRawSdioDeinitialiseCfmSend(dst__, clientData__, result__) \ - CsrWifiRouterCtrlRawSdioDeinitialiseCfmSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, result__) - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlRawSdioInitialiseReqSend - - DESCRIPTION - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - clientData - - -*******************************************************************************/ -#define CsrWifiRouterCtrlRawSdioInitialiseReqCreate(msg__, dst__, src__, clientData__) \ - msg__ = kmalloc(sizeof(CsrWifiRouterCtrlRawSdioInitialiseReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_RAW_SDIO_INITIALISE_REQ, dst__, src__); \ - msg__->clientData = (clientData__); - -#define CsrWifiRouterCtrlRawSdioInitialiseReqSendTo(dst__, src__, clientData__) \ - { \ - CsrWifiRouterCtrlRawSdioInitialiseReq *msg__; \ - CsrWifiRouterCtrlRawSdioInitialiseReqCreate(msg__, dst__, src__, clientData__); \ - CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \ - } - -#define CsrWifiRouterCtrlRawSdioInitialiseReqSend(src__, clientData__) \ - CsrWifiRouterCtrlRawSdioInitialiseReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, clientData__) - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlRawSdioInitialiseCfmSend - - DESCRIPTION - - PARAMETERS - queue - Destination Task Queue - clientData - - result - - byteRead - - byteWrite - - firmwareDownload - - reset - - coreDumpPrepare - - byteBlockRead - - gpRead16 - - gpWrite16 - - -*******************************************************************************/ -#define CsrWifiRouterCtrlRawSdioInitialiseCfmCreate(msg__, dst__, src__, clientData__, result__, byteRead__, byteWrite__, firmwareDownload__, reset__, coreDumpPrepare__, byteBlockRead__, gpRead16__, gpWrite16__) \ - msg__ = kmalloc(sizeof(CsrWifiRouterCtrlRawSdioInitialiseCfm), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_RAW_SDIO_INITIALISE_CFM, dst__, src__); \ - msg__->clientData = (clientData__); \ - msg__->result = (result__); \ - msg__->byteRead = (byteRead__); \ - msg__->byteWrite = (byteWrite__); \ - msg__->firmwareDownload = (firmwareDownload__); \ - msg__->reset = (reset__); \ - msg__->coreDumpPrepare = (coreDumpPrepare__); \ - msg__->byteBlockRead = (byteBlockRead__); \ - msg__->gpRead16 = (gpRead16__); \ - msg__->gpWrite16 = (gpWrite16__); - -#define CsrWifiRouterCtrlRawSdioInitialiseCfmSendTo(dst__, src__, clientData__, result__, byteRead__, byteWrite__, firmwareDownload__, reset__, coreDumpPrepare__, byteBlockRead__, gpRead16__, gpWrite16__) \ - { \ - CsrWifiRouterCtrlRawSdioInitialiseCfm *msg__; \ - CsrWifiRouterCtrlRawSdioInitialiseCfmCreate(msg__, dst__, src__, clientData__, result__, byteRead__, byteWrite__, firmwareDownload__, reset__, coreDumpPrepare__, byteBlockRead__, gpRead16__, gpWrite16__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \ - } - -#define CsrWifiRouterCtrlRawSdioInitialiseCfmSend(dst__, clientData__, result__, byteRead__, byteWrite__, firmwareDownload__, reset__, coreDumpPrepare__, byteBlockRead__, gpRead16__, gpWrite16__) \ - CsrWifiRouterCtrlRawSdioInitialiseCfmSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, result__, byteRead__, byteWrite__, firmwareDownload__, reset__, coreDumpPrepare__, byteBlockRead__, gpRead16__, gpWrite16__) - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlResumeIndSend - - DESCRIPTION - - PARAMETERS - queue - Destination Task Queue - clientData - - powerMaintained - - -*******************************************************************************/ -#define CsrWifiRouterCtrlResumeIndCreate(msg__, dst__, src__, clientData__, powerMaintained__) \ - msg__ = kmalloc(sizeof(CsrWifiRouterCtrlResumeInd), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_RESUME_IND, dst__, src__); \ - msg__->clientData = (clientData__); \ - msg__->powerMaintained = (powerMaintained__); - -#define CsrWifiRouterCtrlResumeIndSendTo(dst__, src__, clientData__, powerMaintained__) \ - { \ - CsrWifiRouterCtrlResumeInd *msg__; \ - CsrWifiRouterCtrlResumeIndCreate(msg__, dst__, src__, clientData__, powerMaintained__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \ - } - -#define CsrWifiRouterCtrlResumeIndSend(dst__, clientData__, powerMaintained__) \ - CsrWifiRouterCtrlResumeIndSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, powerMaintained__) - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlResumeResSend - - DESCRIPTION - - PARAMETERS - clientData - - status - - -*******************************************************************************/ -#define CsrWifiRouterCtrlResumeResCreate(msg__, dst__, src__, clientData__, status__) \ - msg__ = kmalloc(sizeof(CsrWifiRouterCtrlResumeRes), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_RESUME_RES, dst__, src__); \ - msg__->clientData = (clientData__); \ - msg__->status = (status__); - -#define CsrWifiRouterCtrlResumeResSendTo(dst__, src__, clientData__, status__) \ - { \ - CsrWifiRouterCtrlResumeRes *msg__; \ - CsrWifiRouterCtrlResumeResCreate(msg__, dst__, src__, clientData__, status__); \ - CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \ - } - -#define CsrWifiRouterCtrlResumeResSend(src__, clientData__, status__) \ - CsrWifiRouterCtrlResumeResSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, clientData__, status__) - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlStaInactiveIndSend - - DESCRIPTION - - PARAMETERS - queue - Destination Task Queue - clientData - - interfaceTag - - staAddress - - -*******************************************************************************/ -#define CsrWifiRouterCtrlStaInactiveIndCreate(msg__, dst__, src__, clientData__, interfaceTag__, staAddress__) \ - msg__ = kmalloc(sizeof(CsrWifiRouterCtrlStaInactiveInd), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_STA_INACTIVE_IND, dst__, src__); \ - msg__->clientData = (clientData__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->staAddress = (staAddress__); - -#define CsrWifiRouterCtrlStaInactiveIndSendTo(dst__, src__, clientData__, interfaceTag__, staAddress__) \ - { \ - CsrWifiRouterCtrlStaInactiveInd *msg__; \ - CsrWifiRouterCtrlStaInactiveIndCreate(msg__, dst__, src__, clientData__, interfaceTag__, staAddress__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \ - } - -#define CsrWifiRouterCtrlStaInactiveIndSend(dst__, clientData__, interfaceTag__, staAddress__) \ - CsrWifiRouterCtrlStaInactiveIndSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, interfaceTag__, staAddress__) - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlSuspendIndSend - - DESCRIPTION - - PARAMETERS - queue - Destination Task Queue - clientData - - hardSuspend - - d3Suspend - - -*******************************************************************************/ -#define CsrWifiRouterCtrlSuspendIndCreate(msg__, dst__, src__, clientData__, hardSuspend__, d3Suspend__) \ - msg__ = kmalloc(sizeof(CsrWifiRouterCtrlSuspendInd), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_SUSPEND_IND, dst__, src__); \ - msg__->clientData = (clientData__); \ - msg__->hardSuspend = (hardSuspend__); \ - msg__->d3Suspend = (d3Suspend__); - -#define CsrWifiRouterCtrlSuspendIndSendTo(dst__, src__, clientData__, hardSuspend__, d3Suspend__) \ - { \ - CsrWifiRouterCtrlSuspendInd *msg__; \ - CsrWifiRouterCtrlSuspendIndCreate(msg__, dst__, src__, clientData__, hardSuspend__, d3Suspend__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \ - } - -#define CsrWifiRouterCtrlSuspendIndSend(dst__, clientData__, hardSuspend__, d3Suspend__) \ - CsrWifiRouterCtrlSuspendIndSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, hardSuspend__, d3Suspend__) - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlSuspendResSend - - DESCRIPTION - - PARAMETERS - clientData - - status - - -*******************************************************************************/ -#define CsrWifiRouterCtrlSuspendResCreate(msg__, dst__, src__, clientData__, status__) \ - msg__ = kmalloc(sizeof(CsrWifiRouterCtrlSuspendRes), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_SUSPEND_RES, dst__, src__); \ - msg__->clientData = (clientData__); \ - msg__->status = (status__); - -#define CsrWifiRouterCtrlSuspendResSendTo(dst__, src__, clientData__, status__) \ - { \ - CsrWifiRouterCtrlSuspendRes *msg__; \ - CsrWifiRouterCtrlSuspendResCreate(msg__, dst__, src__, clientData__, status__); \ - CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \ - } - -#define CsrWifiRouterCtrlSuspendResSend(src__, clientData__, status__) \ - CsrWifiRouterCtrlSuspendResSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, clientData__, status__) - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlTclasAddReqSend - - DESCRIPTION - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - interfaceTag - - clientData - - tclasLength - - tclas - - -*******************************************************************************/ -#define CsrWifiRouterCtrlTclasAddReqCreate(msg__, dst__, src__, interfaceTag__, clientData__, tclasLength__, tclas__) \ - msg__ = kmalloc(sizeof(CsrWifiRouterCtrlTclasAddReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_TCLAS_ADD_REQ, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->clientData = (clientData__); \ - msg__->tclasLength = (tclasLength__); \ - msg__->tclas = (tclas__); - -#define CsrWifiRouterCtrlTclasAddReqSendTo(dst__, src__, interfaceTag__, clientData__, tclasLength__, tclas__) \ - { \ - CsrWifiRouterCtrlTclasAddReq *msg__; \ - CsrWifiRouterCtrlTclasAddReqCreate(msg__, dst__, src__, interfaceTag__, clientData__, tclasLength__, tclas__); \ - CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \ - } - -#define CsrWifiRouterCtrlTclasAddReqSend(src__, interfaceTag__, clientData__, tclasLength__, tclas__) \ - CsrWifiRouterCtrlTclasAddReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, clientData__, tclasLength__, tclas__) - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlTclasAddCfmSend - - DESCRIPTION - - PARAMETERS - queue - Destination Task Queue - clientData - - interfaceTag - - status - - -*******************************************************************************/ -#define CsrWifiRouterCtrlTclasAddCfmCreate(msg__, dst__, src__, clientData__, interfaceTag__, status__) \ - msg__ = kmalloc(sizeof(CsrWifiRouterCtrlTclasAddCfm), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_TCLAS_ADD_CFM, dst__, src__); \ - msg__->clientData = (clientData__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->status = (status__); - -#define CsrWifiRouterCtrlTclasAddCfmSendTo(dst__, src__, clientData__, interfaceTag__, status__) \ - { \ - CsrWifiRouterCtrlTclasAddCfm *msg__; \ - CsrWifiRouterCtrlTclasAddCfmCreate(msg__, dst__, src__, clientData__, interfaceTag__, status__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \ - } - -#define CsrWifiRouterCtrlTclasAddCfmSend(dst__, clientData__, interfaceTag__, status__) \ - CsrWifiRouterCtrlTclasAddCfmSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, interfaceTag__, status__) - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlTclasDelReqSend - - DESCRIPTION - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - interfaceTag - - clientData - - tclasLength - - tclas - - -*******************************************************************************/ -#define CsrWifiRouterCtrlTclasDelReqCreate(msg__, dst__, src__, interfaceTag__, clientData__, tclasLength__, tclas__) \ - msg__ = kmalloc(sizeof(CsrWifiRouterCtrlTclasDelReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_TCLAS_DEL_REQ, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->clientData = (clientData__); \ - msg__->tclasLength = (tclasLength__); \ - msg__->tclas = (tclas__); - -#define CsrWifiRouterCtrlTclasDelReqSendTo(dst__, src__, interfaceTag__, clientData__, tclasLength__, tclas__) \ - { \ - CsrWifiRouterCtrlTclasDelReq *msg__; \ - CsrWifiRouterCtrlTclasDelReqCreate(msg__, dst__, src__, interfaceTag__, clientData__, tclasLength__, tclas__); \ - CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \ - } - -#define CsrWifiRouterCtrlTclasDelReqSend(src__, interfaceTag__, clientData__, tclasLength__, tclas__) \ - CsrWifiRouterCtrlTclasDelReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, clientData__, tclasLength__, tclas__) - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlTclasDelCfmSend - - DESCRIPTION - - PARAMETERS - queue - Destination Task Queue - clientData - - interfaceTag - - status - - -*******************************************************************************/ -#define CsrWifiRouterCtrlTclasDelCfmCreate(msg__, dst__, src__, clientData__, interfaceTag__, status__) \ - msg__ = kmalloc(sizeof(CsrWifiRouterCtrlTclasDelCfm), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_TCLAS_DEL_CFM, dst__, src__); \ - msg__->clientData = (clientData__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->status = (status__); - -#define CsrWifiRouterCtrlTclasDelCfmSendTo(dst__, src__, clientData__, interfaceTag__, status__) \ - { \ - CsrWifiRouterCtrlTclasDelCfm *msg__; \ - CsrWifiRouterCtrlTclasDelCfmCreate(msg__, dst__, src__, clientData__, interfaceTag__, status__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \ - } - -#define CsrWifiRouterCtrlTclasDelCfmSend(dst__, clientData__, interfaceTag__, status__) \ - CsrWifiRouterCtrlTclasDelCfmSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, interfaceTag__, status__) - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlTrafficClassificationReqSend - - DESCRIPTION - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - interfaceTag - - clientData - - trafficType - - period - - -*******************************************************************************/ -#define CsrWifiRouterCtrlTrafficClassificationReqCreate(msg__, dst__, src__, interfaceTag__, clientData__, trafficType__, period__) \ - msg__ = kmalloc(sizeof(CsrWifiRouterCtrlTrafficClassificationReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_TRAFFIC_CLASSIFICATION_REQ, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->clientData = (clientData__); \ - msg__->trafficType = (trafficType__); \ - msg__->period = (period__); - -#define CsrWifiRouterCtrlTrafficClassificationReqSendTo(dst__, src__, interfaceTag__, clientData__, trafficType__, period__) \ - { \ - CsrWifiRouterCtrlTrafficClassificationReq *msg__; \ - CsrWifiRouterCtrlTrafficClassificationReqCreate(msg__, dst__, src__, interfaceTag__, clientData__, trafficType__, period__); \ - CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \ - } - -#define CsrWifiRouterCtrlTrafficClassificationReqSend(src__, interfaceTag__, clientData__, trafficType__, period__) \ - CsrWifiRouterCtrlTrafficClassificationReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, clientData__, trafficType__, period__) - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlTrafficConfigReqSend - - DESCRIPTION - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - interfaceTag - - clientData - - trafficConfigType - - config - - -*******************************************************************************/ -#define CsrWifiRouterCtrlTrafficConfigReqCreate(msg__, dst__, src__, interfaceTag__, clientData__, trafficConfigType__, config__) \ - msg__ = kmalloc(sizeof(CsrWifiRouterCtrlTrafficConfigReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_TRAFFIC_CONFIG_REQ, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->clientData = (clientData__); \ - msg__->trafficConfigType = (trafficConfigType__); \ - msg__->config = (config__); - -#define CsrWifiRouterCtrlTrafficConfigReqSendTo(dst__, src__, interfaceTag__, clientData__, trafficConfigType__, config__) \ - { \ - CsrWifiRouterCtrlTrafficConfigReq *msg__; \ - CsrWifiRouterCtrlTrafficConfigReqCreate(msg__, dst__, src__, interfaceTag__, clientData__, trafficConfigType__, config__); \ - CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \ - } - -#define CsrWifiRouterCtrlTrafficConfigReqSend(src__, interfaceTag__, clientData__, trafficConfigType__, config__) \ - CsrWifiRouterCtrlTrafficConfigReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, clientData__, trafficConfigType__, config__) - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlTrafficProtocolIndSend - - DESCRIPTION - - PARAMETERS - queue - Destination Task Queue - clientData - - interfaceTag - - packetType - - direction - - srcAddress - - -*******************************************************************************/ -#define CsrWifiRouterCtrlTrafficProtocolIndCreate(msg__, dst__, src__, clientData__, interfaceTag__, packetType__, direction__, srcAddress__) \ - msg__ = kmalloc(sizeof(CsrWifiRouterCtrlTrafficProtocolInd), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_TRAFFIC_PROTOCOL_IND, dst__, src__); \ - msg__->clientData = (clientData__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->packetType = (packetType__); \ - msg__->direction = (direction__); \ - msg__->srcAddress = (srcAddress__); - -#define CsrWifiRouterCtrlTrafficProtocolIndSendTo(dst__, src__, clientData__, interfaceTag__, packetType__, direction__, srcAddress__) \ - { \ - CsrWifiRouterCtrlTrafficProtocolInd *msg__; \ - CsrWifiRouterCtrlTrafficProtocolIndCreate(msg__, dst__, src__, clientData__, interfaceTag__, packetType__, direction__, srcAddress__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \ - } - -#define CsrWifiRouterCtrlTrafficProtocolIndSend(dst__, clientData__, interfaceTag__, packetType__, direction__, srcAddress__) \ - CsrWifiRouterCtrlTrafficProtocolIndSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, interfaceTag__, packetType__, direction__, srcAddress__) - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlTrafficSampleIndSend - - DESCRIPTION - - PARAMETERS - queue - Destination Task Queue - clientData - - interfaceTag - - stats - - -*******************************************************************************/ -#define CsrWifiRouterCtrlTrafficSampleIndCreate(msg__, dst__, src__, clientData__, interfaceTag__, stats__) \ - msg__ = kmalloc(sizeof(CsrWifiRouterCtrlTrafficSampleInd), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_TRAFFIC_SAMPLE_IND, dst__, src__); \ - msg__->clientData = (clientData__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->stats = (stats__); - -#define CsrWifiRouterCtrlTrafficSampleIndSendTo(dst__, src__, clientData__, interfaceTag__, stats__) \ - { \ - CsrWifiRouterCtrlTrafficSampleInd *msg__; \ - CsrWifiRouterCtrlTrafficSampleIndCreate(msg__, dst__, src__, clientData__, interfaceTag__, stats__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \ - } - -#define CsrWifiRouterCtrlTrafficSampleIndSend(dst__, clientData__, interfaceTag__, stats__) \ - CsrWifiRouterCtrlTrafficSampleIndSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, interfaceTag__, stats__) - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlUnexpectedFrameIndSend - - DESCRIPTION - - PARAMETERS - queue - Destination Task Queue - clientData - - interfaceTag - - peerMacAddress - - -*******************************************************************************/ -#define CsrWifiRouterCtrlUnexpectedFrameIndCreate(msg__, dst__, src__, clientData__, interfaceTag__, peerMacAddress__) \ - msg__ = kmalloc(sizeof(CsrWifiRouterCtrlUnexpectedFrameInd), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_UNEXPECTED_FRAME_IND, dst__, src__); \ - msg__->clientData = (clientData__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->peerMacAddress = (peerMacAddress__); - -#define CsrWifiRouterCtrlUnexpectedFrameIndSendTo(dst__, src__, clientData__, interfaceTag__, peerMacAddress__) \ - { \ - CsrWifiRouterCtrlUnexpectedFrameInd *msg__; \ - CsrWifiRouterCtrlUnexpectedFrameIndCreate(msg__, dst__, src__, clientData__, interfaceTag__, peerMacAddress__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \ - } - -#define CsrWifiRouterCtrlUnexpectedFrameIndSend(dst__, clientData__, interfaceTag__, peerMacAddress__) \ - CsrWifiRouterCtrlUnexpectedFrameIndSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, interfaceTag__, peerMacAddress__) - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlWapiFilterReqSend - - DESCRIPTION - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - interfaceTag - - isWapiConnected - - -*******************************************************************************/ -#define CsrWifiRouterCtrlWapiFilterReqCreate(msg__, dst__, src__, interfaceTag__, isWapiConnected__) \ - msg__ = kmalloc(sizeof(CsrWifiRouterCtrlWapiFilterReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_WAPI_FILTER_REQ, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->isWapiConnected = (isWapiConnected__); - -#define CsrWifiRouterCtrlWapiFilterReqSendTo(dst__, src__, interfaceTag__, isWapiConnected__) \ - { \ - CsrWifiRouterCtrlWapiFilterReq *msg__; \ - CsrWifiRouterCtrlWapiFilterReqCreate(msg__, dst__, src__, interfaceTag__, isWapiConnected__); \ - CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \ - } - -#define CsrWifiRouterCtrlWapiFilterReqSend(src__, interfaceTag__, isWapiConnected__) \ - CsrWifiRouterCtrlWapiFilterReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, isWapiConnected__) - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlWapiMulticastFilterReqSend - - DESCRIPTION - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - interfaceTag - - status - - -*******************************************************************************/ -#define CsrWifiRouterCtrlWapiMulticastFilterReqCreate(msg__, dst__, src__, interfaceTag__, status__) \ - msg__ = kmalloc(sizeof(CsrWifiRouterCtrlWapiMulticastFilterReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_WAPI_MULTICAST_FILTER_REQ, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->status = (status__); - -#define CsrWifiRouterCtrlWapiMulticastFilterReqSendTo(dst__, src__, interfaceTag__, status__) \ - { \ - CsrWifiRouterCtrlWapiMulticastFilterReq *msg__; \ - CsrWifiRouterCtrlWapiMulticastFilterReqCreate(msg__, dst__, src__, interfaceTag__, status__); \ - CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \ - } - -#define CsrWifiRouterCtrlWapiMulticastFilterReqSend(src__, interfaceTag__, status__) \ - CsrWifiRouterCtrlWapiMulticastFilterReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, status__) - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlWapiRxMicCheckIndSend - - DESCRIPTION - - PARAMETERS - queue - Destination Task Queue - clientData - - interfaceTag - - signalLength - - signal - - dataLength - - data - - -*******************************************************************************/ -#define CsrWifiRouterCtrlWapiRxMicCheckIndCreate(msg__, dst__, src__, clientData__, interfaceTag__, signalLength__, signal__, dataLength__, data__) \ - msg__ = kmalloc(sizeof(CsrWifiRouterCtrlWapiRxMicCheckInd), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_WAPI_RX_MIC_CHECK_IND, dst__, src__); \ - msg__->clientData = (clientData__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->signalLength = (signalLength__); \ - msg__->signal = (signal__); \ - msg__->dataLength = (dataLength__); \ - msg__->data = (data__); - -#define CsrWifiRouterCtrlWapiRxMicCheckIndSendTo(dst__, src__, clientData__, interfaceTag__, signalLength__, signal__, dataLength__, data__) \ - { \ - CsrWifiRouterCtrlWapiRxMicCheckInd *msg__; \ - CsrWifiRouterCtrlWapiRxMicCheckIndCreate(msg__, dst__, src__, clientData__, interfaceTag__, signalLength__, signal__, dataLength__, data__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \ - } - -#define CsrWifiRouterCtrlWapiRxMicCheckIndSend(dst__, clientData__, interfaceTag__, signalLength__, signal__, dataLength__, data__) \ - CsrWifiRouterCtrlWapiRxMicCheckIndSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, interfaceTag__, signalLength__, signal__, dataLength__, data__) - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlWapiRxPktReqSend - - DESCRIPTION - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - interfaceTag - - signalLength - - signal - - dataLength - - data - - -*******************************************************************************/ -#define CsrWifiRouterCtrlWapiRxPktReqCreate(msg__, dst__, src__, interfaceTag__, signalLength__, signal__, dataLength__, data__) \ - msg__ = kmalloc(sizeof(CsrWifiRouterCtrlWapiRxPktReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_WAPI_RX_PKT_REQ, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->signalLength = (signalLength__); \ - msg__->signal = (signal__); \ - msg__->dataLength = (dataLength__); \ - msg__->data = (data__); - -#define CsrWifiRouterCtrlWapiRxPktReqSendTo(dst__, src__, interfaceTag__, signalLength__, signal__, dataLength__, data__) \ - { \ - CsrWifiRouterCtrlWapiRxPktReq *msg__; \ - CsrWifiRouterCtrlWapiRxPktReqCreate(msg__, dst__, src__, interfaceTag__, signalLength__, signal__, dataLength__, data__); \ - CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \ - } - -#define CsrWifiRouterCtrlWapiRxPktReqSend(src__, interfaceTag__, signalLength__, signal__, dataLength__, data__) \ - CsrWifiRouterCtrlWapiRxPktReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, signalLength__, signal__, dataLength__, data__) - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlWapiUnicastFilterReqSend - - DESCRIPTION - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - interfaceTag - - status - - -*******************************************************************************/ -#define CsrWifiRouterCtrlWapiUnicastFilterReqCreate(msg__, dst__, src__, interfaceTag__, status__) \ - msg__ = kmalloc(sizeof(CsrWifiRouterCtrlWapiUnicastFilterReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_WAPI_UNICAST_FILTER_REQ, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->status = (status__); - -#define CsrWifiRouterCtrlWapiUnicastFilterReqSendTo(dst__, src__, interfaceTag__, status__) \ - { \ - CsrWifiRouterCtrlWapiUnicastFilterReq *msg__; \ - CsrWifiRouterCtrlWapiUnicastFilterReqCreate(msg__, dst__, src__, interfaceTag__, status__); \ - CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \ - } - -#define CsrWifiRouterCtrlWapiUnicastFilterReqSend(src__, interfaceTag__, status__) \ - CsrWifiRouterCtrlWapiUnicastFilterReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, status__) - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlWapiUnicastTxEncryptIndSend - - DESCRIPTION - - PARAMETERS - queue - Destination Task Queue - clientData - - interfaceTag - - dataLength - - data - - -*******************************************************************************/ -#define CsrWifiRouterCtrlWapiUnicastTxEncryptIndCreate(msg__, dst__, src__, clientData__, interfaceTag__, dataLength__, data__) \ - msg__ = kmalloc(sizeof(CsrWifiRouterCtrlWapiUnicastTxEncryptInd), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_WAPI_UNICAST_TX_ENCRYPT_IND, dst__, src__); \ - msg__->clientData = (clientData__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->dataLength = (dataLength__); \ - msg__->data = (data__); - -#define CsrWifiRouterCtrlWapiUnicastTxEncryptIndSendTo(dst__, src__, clientData__, interfaceTag__, dataLength__, data__) \ - { \ - CsrWifiRouterCtrlWapiUnicastTxEncryptInd *msg__; \ - CsrWifiRouterCtrlWapiUnicastTxEncryptIndCreate(msg__, dst__, src__, clientData__, interfaceTag__, dataLength__, data__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \ - } - -#define CsrWifiRouterCtrlWapiUnicastTxEncryptIndSend(dst__, clientData__, interfaceTag__, dataLength__, data__) \ - CsrWifiRouterCtrlWapiUnicastTxEncryptIndSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, interfaceTag__, dataLength__, data__) - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlWapiUnicastTxPktReqSend - - DESCRIPTION - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - interfaceTag - - dataLength - - data - - -*******************************************************************************/ -#define CsrWifiRouterCtrlWapiUnicastTxPktReqCreate(msg__, dst__, src__, interfaceTag__, dataLength__, data__) \ - msg__ = kmalloc(sizeof(CsrWifiRouterCtrlWapiUnicastTxPktReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_WAPI_UNICAST_TX_PKT_REQ, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->dataLength = (dataLength__); \ - msg__->data = (data__); - -#define CsrWifiRouterCtrlWapiUnicastTxPktReqSendTo(dst__, src__, interfaceTag__, dataLength__, data__) \ - { \ - CsrWifiRouterCtrlWapiUnicastTxPktReq *msg__; \ - CsrWifiRouterCtrlWapiUnicastTxPktReqCreate(msg__, dst__, src__, interfaceTag__, dataLength__, data__); \ - CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \ - } - -#define CsrWifiRouterCtrlWapiUnicastTxPktReqSend(src__, interfaceTag__, dataLength__, data__) \ - CsrWifiRouterCtrlWapiUnicastTxPktReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, dataLength__, data__) - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlWifiOffReqSend - - DESCRIPTION - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - clientData - - -*******************************************************************************/ -#define CsrWifiRouterCtrlWifiOffReqCreate(msg__, dst__, src__, clientData__) \ - msg__ = kmalloc(sizeof(CsrWifiRouterCtrlWifiOffReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_WIFI_OFF_REQ, dst__, src__); \ - msg__->clientData = (clientData__); - -#define CsrWifiRouterCtrlWifiOffReqSendTo(dst__, src__, clientData__) \ - { \ - CsrWifiRouterCtrlWifiOffReq *msg__; \ - CsrWifiRouterCtrlWifiOffReqCreate(msg__, dst__, src__, clientData__); \ - CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \ - } - -#define CsrWifiRouterCtrlWifiOffReqSend(src__, clientData__) \ - CsrWifiRouterCtrlWifiOffReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, clientData__) - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlWifiOffIndSend - - DESCRIPTION - - PARAMETERS - queue - Destination Task Queue - clientData - - controlIndication - - -*******************************************************************************/ -#define CsrWifiRouterCtrlWifiOffIndCreate(msg__, dst__, src__, clientData__, controlIndication__) \ - msg__ = kmalloc(sizeof(CsrWifiRouterCtrlWifiOffInd), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_WIFI_OFF_IND, dst__, src__); \ - msg__->clientData = (clientData__); \ - msg__->controlIndication = (controlIndication__); - -#define CsrWifiRouterCtrlWifiOffIndSendTo(dst__, src__, clientData__, controlIndication__) \ - { \ - CsrWifiRouterCtrlWifiOffInd *msg__; \ - CsrWifiRouterCtrlWifiOffIndCreate(msg__, dst__, src__, clientData__, controlIndication__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \ - } - -#define CsrWifiRouterCtrlWifiOffIndSend(dst__, clientData__, controlIndication__) \ - CsrWifiRouterCtrlWifiOffIndSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, controlIndication__) - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlWifiOffResSend - - DESCRIPTION - - PARAMETERS - clientData - - -*******************************************************************************/ -#define CsrWifiRouterCtrlWifiOffResCreate(msg__, dst__, src__, clientData__) \ - msg__ = kmalloc(sizeof(CsrWifiRouterCtrlWifiOffRes), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_WIFI_OFF_RES, dst__, src__); \ - msg__->clientData = (clientData__); - -#define CsrWifiRouterCtrlWifiOffResSendTo(dst__, src__, clientData__) \ - { \ - CsrWifiRouterCtrlWifiOffRes *msg__; \ - CsrWifiRouterCtrlWifiOffResCreate(msg__, dst__, src__, clientData__); \ - CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \ - } - -#define CsrWifiRouterCtrlWifiOffResSend(src__, clientData__) \ - CsrWifiRouterCtrlWifiOffResSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, clientData__) - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlWifiOffCfmSend - - DESCRIPTION - - PARAMETERS - queue - Destination Task Queue - clientData - - -*******************************************************************************/ -#define CsrWifiRouterCtrlWifiOffCfmCreate(msg__, dst__, src__, clientData__) \ - msg__ = kmalloc(sizeof(CsrWifiRouterCtrlWifiOffCfm), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_WIFI_OFF_CFM, dst__, src__); \ - msg__->clientData = (clientData__); - -#define CsrWifiRouterCtrlWifiOffCfmSendTo(dst__, src__, clientData__) \ - { \ - CsrWifiRouterCtrlWifiOffCfm *msg__; \ - CsrWifiRouterCtrlWifiOffCfmCreate(msg__, dst__, src__, clientData__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \ - } - -#define CsrWifiRouterCtrlWifiOffCfmSend(dst__, clientData__) \ - CsrWifiRouterCtrlWifiOffCfmSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__) - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlWifiOnReqSend - - DESCRIPTION - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - clientData - - dataLength - Number of bytes in the buffer pointed to by 'data' - data - Pointer to the buffer containing 'dataLength' bytes - -*******************************************************************************/ -#define CsrWifiRouterCtrlWifiOnReqCreate(msg__, dst__, src__, clientData__, dataLength__, data__) \ - msg__ = kmalloc(sizeof(CsrWifiRouterCtrlWifiOnReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_WIFI_ON_REQ, dst__, src__); \ - msg__->clientData = (clientData__); \ - msg__->dataLength = (dataLength__); \ - msg__->data = (data__); - -#define CsrWifiRouterCtrlWifiOnReqSendTo(dst__, src__, clientData__, dataLength__, data__) \ - { \ - CsrWifiRouterCtrlWifiOnReq *msg__; \ - CsrWifiRouterCtrlWifiOnReqCreate(msg__, dst__, src__, clientData__, dataLength__, data__); \ - CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \ - } - -#define CsrWifiRouterCtrlWifiOnReqSend(src__, clientData__, dataLength__, data__) \ - CsrWifiRouterCtrlWifiOnReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, clientData__, dataLength__, data__) - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlWifiOnIndSend - - DESCRIPTION - - PARAMETERS - queue - Destination Task Queue - clientData - - status - - versions - - -*******************************************************************************/ -#define CsrWifiRouterCtrlWifiOnIndCreate(msg__, dst__, src__, clientData__, status__, versions__) \ - msg__ = kmalloc(sizeof(CsrWifiRouterCtrlWifiOnInd), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_WIFI_ON_IND, dst__, src__); \ - msg__->clientData = (clientData__); \ - msg__->status = (status__); \ - msg__->versions = (versions__); - -#define CsrWifiRouterCtrlWifiOnIndSendTo(dst__, src__, clientData__, status__, versions__) \ - { \ - CsrWifiRouterCtrlWifiOnInd *msg__; \ - CsrWifiRouterCtrlWifiOnIndCreate(msg__, dst__, src__, clientData__, status__, versions__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \ - } - -#define CsrWifiRouterCtrlWifiOnIndSend(dst__, clientData__, status__, versions__) \ - CsrWifiRouterCtrlWifiOnIndSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, status__, versions__) - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlWifiOnResSend - - DESCRIPTION - - PARAMETERS - clientData - - status - - numInterfaceAddress - - stationMacAddress - array size 1 MUST match CSR_WIFI_NUM_INTERFACES - smeVersions - - scheduledInterrupt - - -*******************************************************************************/ -#define CsrWifiRouterCtrlWifiOnResCreate(msg__, dst__, src__, clientData__, status__, numInterfaceAddress__, stationMacAddress__, smeVersions__, scheduledInterrupt__) \ - msg__ = kmalloc(sizeof(CsrWifiRouterCtrlWifiOnRes), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_WIFI_ON_RES, dst__, src__); \ - msg__->clientData = (clientData__); \ - msg__->status = (status__); \ - msg__->numInterfaceAddress = (numInterfaceAddress__); \ - memcpy(msg__->stationMacAddress, (stationMacAddress__), sizeof(CsrWifiMacAddress) * 2); \ - msg__->smeVersions = (smeVersions__); \ - msg__->scheduledInterrupt = (scheduledInterrupt__); - -#define CsrWifiRouterCtrlWifiOnResSendTo(dst__, src__, clientData__, status__, numInterfaceAddress__, stationMacAddress__, smeVersions__, scheduledInterrupt__) \ - { \ - CsrWifiRouterCtrlWifiOnRes *msg__; \ - CsrWifiRouterCtrlWifiOnResCreate(msg__, dst__, src__, clientData__, status__, numInterfaceAddress__, stationMacAddress__, smeVersions__, scheduledInterrupt__); \ - CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \ - } - -#define CsrWifiRouterCtrlWifiOnResSend(src__, clientData__, status__, numInterfaceAddress__, stationMacAddress__, smeVersions__, scheduledInterrupt__) \ - CsrWifiRouterCtrlWifiOnResSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, clientData__, status__, numInterfaceAddress__, stationMacAddress__, smeVersions__, scheduledInterrupt__) - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlWifiOnCfmSend - - DESCRIPTION - - PARAMETERS - queue - Destination Task Queue - clientData - - status - - -*******************************************************************************/ -#define CsrWifiRouterCtrlWifiOnCfmCreate(msg__, dst__, src__, clientData__, status__) \ - msg__ = kmalloc(sizeof(CsrWifiRouterCtrlWifiOnCfm), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_WIFI_ON_CFM, dst__, src__); \ - msg__->clientData = (clientData__); \ - msg__->status = (status__); - -#define CsrWifiRouterCtrlWifiOnCfmSendTo(dst__, src__, clientData__, status__) \ - { \ - CsrWifiRouterCtrlWifiOnCfm *msg__; \ - CsrWifiRouterCtrlWifiOnCfmCreate(msg__, dst__, src__, clientData__, status__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \ - } - -#define CsrWifiRouterCtrlWifiOnCfmSend(dst__, clientData__, status__) \ - CsrWifiRouterCtrlWifiOnCfmSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, status__) - -#endif /* CSR_WIFI_ROUTER_CTRL_LIB_H__ */ diff --git a/drivers/staging/csr/csr_wifi_router_ctrl_prim.h b/drivers/staging/csr/csr_wifi_router_ctrl_prim.h deleted file mode 100644 index 1312a335dd76..000000000000 --- a/drivers/staging/csr/csr_wifi_router_ctrl_prim.h +++ /dev/null @@ -1,2113 +0,0 @@ -/***************************************************************************** - - (c) Cambridge Silicon Radio Limited 2012 - All rights reserved and confidential information of CSR - - Refer to LICENSE.txt included with this source for details - on the license terms. - -*****************************************************************************/ - -/* Note: this is an auto-generated file. */ - -#ifndef CSR_WIFI_ROUTER_CTRL_PRIM_H__ -#define CSR_WIFI_ROUTER_CTRL_PRIM_H__ - -#include -#include "csr_prim_defs.h" -#include "csr_sched.h" -#include "csr_wifi_common.h" -#include "csr_result.h" -#include "csr_wifi_fsm_event.h" - -#define CSR_WIFI_ROUTER_CTRL_PRIM (0x0401) - -typedef CsrPrim CsrWifiRouterCtrlPrim; - -typedef CsrResult (*CsrWifiRouterCtrlRawSdioByteWrite)(u8 func, u32 address, u8 data); -typedef CsrResult (*CsrWifiRouterCtrlRawSdioByteRead)(u8 func, u32 address, u8 *pdata); -typedef CsrResult (*CsrWifiRouterCtrlRawSdioFirmwareDownload)(u32 length, const u8 *pdata); -typedef CsrResult (*CsrWifiRouterCtrlRawSdioReset)(void); -typedef CsrResult (*CsrWifiRouterCtrlRawSdioCoreDumpPrepare)(u8 suspendSme); -typedef CsrResult (*CsrWifiRouterCtrlRawSdioByteBlockRead)(u8 func, u32 address, u8 *pdata, u32 length); -typedef CsrResult (*CsrWifiRouterCtrlRawSdioGpRead16)(u8 func, u32 address, u16 *pdata); -typedef CsrResult (*CsrWifiRouterCtrlRawSdioGpWrite16)(u8 func, u32 address, u16 data); - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlBlockAckRole - - DESCRIPTION - - VALUES - CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_ORIGINATOR - - - CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_RECIPIENT - - - -*******************************************************************************/ -typedef u8 CsrWifiRouterCtrlBlockAckRole; -#define CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_ORIGINATOR ((CsrWifiRouterCtrlBlockAckRole) 0x00) -#define CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_RECIPIENT ((CsrWifiRouterCtrlBlockAckRole) 0x01) - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlControlIndication - - DESCRIPTION - - VALUES - CSR_WIFI_ROUTER_CTRL_CONTROL_INDICATION_ERROR - - - CSR_WIFI_ROUTER_CTRL_CONTROL_INDICATION_EXIT - - - CSR_WIFI_ROUTER_CTRL_CONTROL_INDICATION_USER_REQUESTED - - - -*******************************************************************************/ -typedef u8 CsrWifiRouterCtrlControlIndication; -#define CSR_WIFI_ROUTER_CTRL_CONTROL_INDICATION_ERROR ((CsrWifiRouterCtrlControlIndication) 0x01) -#define CSR_WIFI_ROUTER_CTRL_CONTROL_INDICATION_EXIT ((CsrWifiRouterCtrlControlIndication) 0x02) -#define CSR_WIFI_ROUTER_CTRL_CONTROL_INDICATION_USER_REQUESTED ((CsrWifiRouterCtrlControlIndication) 0x03) - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlListAction - - DESCRIPTION - - VALUES - CSR_WIFI_ROUTER_CTRL_LIST_ACTION_GET - - - CSR_WIFI_ROUTER_CTRL_LIST_ACTION_ADD - - - CSR_WIFI_ROUTER_CTRL_LIST_ACTION_REMOVE - - - CSR_WIFI_ROUTER_CTRL_LIST_ACTION_FLUSH - - - -*******************************************************************************/ -typedef u8 CsrWifiRouterCtrlListAction; -#define CSR_WIFI_ROUTER_CTRL_LIST_ACTION_GET ((CsrWifiRouterCtrlListAction) 0x00) -#define CSR_WIFI_ROUTER_CTRL_LIST_ACTION_ADD ((CsrWifiRouterCtrlListAction) 0x01) -#define CSR_WIFI_ROUTER_CTRL_LIST_ACTION_REMOVE ((CsrWifiRouterCtrlListAction) 0x02) -#define CSR_WIFI_ROUTER_CTRL_LIST_ACTION_FLUSH ((CsrWifiRouterCtrlListAction) 0x03) - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlLowPowerMode - - DESCRIPTION - - VALUES - CSR_WIFI_ROUTER_CTRL_LOW_POWER_MODE_DISABLED - - - CSR_WIFI_ROUTER_CTRL_LOW_POWER_MODE_ENABLED - - - -*******************************************************************************/ -typedef u16 CsrWifiRouterCtrlLowPowerMode; -#define CSR_WIFI_ROUTER_CTRL_LOW_POWER_MODE_DISABLED ((CsrWifiRouterCtrlLowPowerMode) 0x0000) -#define CSR_WIFI_ROUTER_CTRL_LOW_POWER_MODE_ENABLED ((CsrWifiRouterCtrlLowPowerMode) 0x0001) - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlMediaStatus - - DESCRIPTION - - VALUES - CSR_WIFI_ROUTER_CTRL_MEDIA_STATUS_CONNECTED - - - CSR_WIFI_ROUTER_CTRL_MEDIA_STATUS_DISCONNECTED - - - -*******************************************************************************/ -typedef u8 CsrWifiRouterCtrlMediaStatus; -#define CSR_WIFI_ROUTER_CTRL_MEDIA_STATUS_CONNECTED ((CsrWifiRouterCtrlMediaStatus) 0x00) -#define CSR_WIFI_ROUTER_CTRL_MEDIA_STATUS_DISCONNECTED ((CsrWifiRouterCtrlMediaStatus) 0x01) - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlMode - - DESCRIPTION - - VALUES - CSR_WIFI_ROUTER_CTRL_MODE_NONE - - CSR_WIFI_ROUTER_CTRL_MODE_IBSS - - CSR_WIFI_ROUTER_CTRL_MODE_STA - - CSR_WIFI_ROUTER_CTRL_MODE_AP - - CSR_WIFI_ROUTER_CTRL_MODE_MONITOR - - CSR_WIFI_ROUTER_CTRL_MODE_AMP - - CSR_WIFI_ROUTER_CTRL_MODE_P2P - - CSR_WIFI_ROUTER_CTRL_MODE_P2PGO - - CSR_WIFI_ROUTER_CTRL_MODE_P2PCLI - - -*******************************************************************************/ -typedef u8 CsrWifiRouterCtrlMode; -#define CSR_WIFI_ROUTER_CTRL_MODE_NONE ((CsrWifiRouterCtrlMode) 0x00) -#define CSR_WIFI_ROUTER_CTRL_MODE_IBSS ((CsrWifiRouterCtrlMode) 0x01) -#define CSR_WIFI_ROUTER_CTRL_MODE_STA ((CsrWifiRouterCtrlMode) 0x02) -#define CSR_WIFI_ROUTER_CTRL_MODE_AP ((CsrWifiRouterCtrlMode) 0x03) -#define CSR_WIFI_ROUTER_CTRL_MODE_MONITOR ((CsrWifiRouterCtrlMode) 0x04) -#define CSR_WIFI_ROUTER_CTRL_MODE_AMP ((CsrWifiRouterCtrlMode) 0x05) -#define CSR_WIFI_ROUTER_CTRL_MODE_P2P ((CsrWifiRouterCtrlMode) 0x06) -#define CSR_WIFI_ROUTER_CTRL_MODE_P2PGO ((CsrWifiRouterCtrlMode) 0x07) -#define CSR_WIFI_ROUTER_CTRL_MODE_P2PCLI ((CsrWifiRouterCtrlMode) 0x08) - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlPeerStatus - - DESCRIPTION - - VALUES - CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_ACTIVE - - - CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_POWER_SAVE - - - CSR_WIFI_ROUTER_CTRL_PEER_DISCONNECTED - - - -*******************************************************************************/ -typedef u8 CsrWifiRouterCtrlPeerStatus; -#define CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_ACTIVE ((CsrWifiRouterCtrlPeerStatus) 0x00) -#define CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_POWER_SAVE ((CsrWifiRouterCtrlPeerStatus) 0x01) -#define CSR_WIFI_ROUTER_CTRL_PEER_DISCONNECTED ((CsrWifiRouterCtrlPeerStatus) 0x02) - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlPortAction - - DESCRIPTION - - VALUES - CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_OPEN - - - CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_CLOSED_DISCARD - - - CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_CLOSED_BLOCK - - - -*******************************************************************************/ -typedef u16 CsrWifiRouterCtrlPortAction; -#define CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_OPEN ((CsrWifiRouterCtrlPortAction) 0x0000) -#define CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_CLOSED_DISCARD ((CsrWifiRouterCtrlPortAction) 0x0001) -#define CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_CLOSED_BLOCK ((CsrWifiRouterCtrlPortAction) 0x0002) - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlPowersaveType - - DESCRIPTION - - VALUES - CSR_WIFI_ROUTER_CTRL_AC_BK_PS_INFO_PRESENT - - If set, AC BK PS info is present in b4 and b5 - CSR_WIFI_ROUTER_CTRL_AC_BE_PS_INFO_PRESENT - - If set, AC BE PS info is present in b6 and b7 - CSR_WIFI_ROUTER_CTRL_AC_VI_PS_INFO_PRESENT - - If set, AC VI PS info is present in b8 and b9 - CSR_WIFI_ROUTER_CTRL_AC_VO_PS_INFO_PRESENT - - If set, AC VO PS info is present in b10 and b11 - CSR_WIFI_ROUTER_CTRL_AC_BK_TRIGGER_ENABLED - - - CSR_WIFI_ROUTER_CTRL_AC_BK_DELIVERY_ENABLED - - - CSR_WIFI_ROUTER_CTRL_AC_BE_TRIGGER_ENABLED - - - CSR_WIFI_ROUTER_CTRL_AC_BE_DELIVERY_ENABLED - - - CSR_WIFI_ROUTER_CTRL_AC_VI_TRIGGER_ENABLED - - - CSR_WIFI_ROUTER_CTRL_AC_VI_DELIVERY_ENABLED - - - CSR_WIFI_ROUTER_CTRL_AC_VO_TRIGGER_ENABLED - - - CSR_WIFI_ROUTER_CTRL_AC_VO_DELIVERY_ENABLED - - - -*******************************************************************************/ -typedef u16 CsrWifiRouterCtrlPowersaveType; -#define CSR_WIFI_ROUTER_CTRL_AC_BK_PS_INFO_PRESENT ((CsrWifiRouterCtrlPowersaveType) 0x0001) -#define CSR_WIFI_ROUTER_CTRL_AC_BE_PS_INFO_PRESENT ((CsrWifiRouterCtrlPowersaveType) 0x0002) -#define CSR_WIFI_ROUTER_CTRL_AC_VI_PS_INFO_PRESENT ((CsrWifiRouterCtrlPowersaveType) 0x0004) -#define CSR_WIFI_ROUTER_CTRL_AC_VO_PS_INFO_PRESENT ((CsrWifiRouterCtrlPowersaveType) 0x0008) -#define CSR_WIFI_ROUTER_CTRL_AC_BK_TRIGGER_ENABLED ((CsrWifiRouterCtrlPowersaveType) 0x0010) -#define CSR_WIFI_ROUTER_CTRL_AC_BK_DELIVERY_ENABLED ((CsrWifiRouterCtrlPowersaveType) 0x0020) -#define CSR_WIFI_ROUTER_CTRL_AC_BE_TRIGGER_ENABLED ((CsrWifiRouterCtrlPowersaveType) 0x0040) -#define CSR_WIFI_ROUTER_CTRL_AC_BE_DELIVERY_ENABLED ((CsrWifiRouterCtrlPowersaveType) 0x0080) -#define CSR_WIFI_ROUTER_CTRL_AC_VI_TRIGGER_ENABLED ((CsrWifiRouterCtrlPowersaveType) 0x0100) -#define CSR_WIFI_ROUTER_CTRL_AC_VI_DELIVERY_ENABLED ((CsrWifiRouterCtrlPowersaveType) 0x0200) -#define CSR_WIFI_ROUTER_CTRL_AC_VO_TRIGGER_ENABLED ((CsrWifiRouterCtrlPowersaveType) 0x0400) -#define CSR_WIFI_ROUTER_CTRL_AC_VO_DELIVERY_ENABLED ((CsrWifiRouterCtrlPowersaveType) 0x0800) - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlProtocolDirection - - DESCRIPTION - - VALUES - CSR_WIFI_ROUTER_CTRL_PROTOCOL_DIRECTION_RX - - - CSR_WIFI_ROUTER_CTRL_PROTOCOL_DIRECTION_TX - - - -*******************************************************************************/ -typedef u16 CsrWifiRouterCtrlProtocolDirection; -#define CSR_WIFI_ROUTER_CTRL_PROTOCOL_DIRECTION_RX ((CsrWifiRouterCtrlProtocolDirection) 0x0000) -#define CSR_WIFI_ROUTER_CTRL_PROTOCOL_DIRECTION_TX ((CsrWifiRouterCtrlProtocolDirection) 0x0001) - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlQoSControl - - DESCRIPTION - - VALUES - CSR_WIFI_ROUTER_CTRL_QOS_CONTROL_OFF - - - CSR_WIFI_ROUTER_CTRL_QOS_CONTROL_WMM_ON - - - CSR_WIFI_ROUTER_CTRL_QOS_CONTROL_80211_ON - - - -*******************************************************************************/ -typedef u16 CsrWifiRouterCtrlQoSControl; -#define CSR_WIFI_ROUTER_CTRL_QOS_CONTROL_OFF ((CsrWifiRouterCtrlQoSControl) 0x0000) -#define CSR_WIFI_ROUTER_CTRL_QOS_CONTROL_WMM_ON ((CsrWifiRouterCtrlQoSControl) 0x0001) -#define CSR_WIFI_ROUTER_CTRL_QOS_CONTROL_80211_ON ((CsrWifiRouterCtrlQoSControl) 0x0002) - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlQueueConfig - - DESCRIPTION - Defines which Queues are enabled for use. - - VALUES - CSR_WIFI_ROUTER_CTRL_QUEUE_BE_ENABLE - - - CSR_WIFI_ROUTER_CTRL_QUEUE_BK_ENABLE - - - CSR_WIFI_ROUTER_CTRL_QUEUE_VI_ENABLE - - - CSR_WIFI_ROUTER_CTRL_QUEUE_VO_ENABLE - - - -*******************************************************************************/ -typedef u8 CsrWifiRouterCtrlQueueConfig; -#define CSR_WIFI_ROUTER_CTRL_QUEUE_BE_ENABLE ((CsrWifiRouterCtrlQueueConfig) 0x01) -#define CSR_WIFI_ROUTER_CTRL_QUEUE_BK_ENABLE ((CsrWifiRouterCtrlQueueConfig) 0x02) -#define CSR_WIFI_ROUTER_CTRL_QUEUE_VI_ENABLE ((CsrWifiRouterCtrlQueueConfig) 0x04) -#define CSR_WIFI_ROUTER_CTRL_QUEUE_VO_ENABLE ((CsrWifiRouterCtrlQueueConfig) 0x08) - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlTrafficConfigType - - DESCRIPTION - - VALUES - CSR_WIFI_ROUTER_CTRL_TRAFFIC_CONFIG_TYPE_RESET - - - CSR_WIFI_ROUTER_CTRL_TRAFFIC_CONFIG_TYPE_FILTER - - - CSR_WIFI_ROUTER_CTRL_TRAFFIC_CONFIG_TYPE_CLS - - - -*******************************************************************************/ -typedef u16 CsrWifiRouterCtrlTrafficConfigType; -#define CSR_WIFI_ROUTER_CTRL_TRAFFIC_CONFIG_TYPE_RESET ((CsrWifiRouterCtrlTrafficConfigType) 0x0000) -#define CSR_WIFI_ROUTER_CTRL_TRAFFIC_CONFIG_TYPE_FILTER ((CsrWifiRouterCtrlTrafficConfigType) 0x0001) -#define CSR_WIFI_ROUTER_CTRL_TRAFFIC_CONFIG_TYPE_CLS ((CsrWifiRouterCtrlTrafficConfigType) 0x0002) - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlTrafficPacketType - - DESCRIPTION - - VALUES - CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_NONE - - - CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_EAPOL - - - CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_DHCP - - - CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_DHCP_ACK - - - CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_ARP - - - CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_AIRONET - - - CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_CUSTOM - - - CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_ALL - - - -*******************************************************************************/ -typedef u16 CsrWifiRouterCtrlTrafficPacketType; -#define CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_NONE ((CsrWifiRouterCtrlTrafficPacketType) 0x0000) -#define CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_EAPOL ((CsrWifiRouterCtrlTrafficPacketType) 0x0001) -#define CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_DHCP ((CsrWifiRouterCtrlTrafficPacketType) 0x0002) -#define CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_DHCP_ACK ((CsrWifiRouterCtrlTrafficPacketType) 0x0004) -#define CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_ARP ((CsrWifiRouterCtrlTrafficPacketType) 0x0008) -#define CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_AIRONET ((CsrWifiRouterCtrlTrafficPacketType) 0x0010) -#define CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_CUSTOM ((CsrWifiRouterCtrlTrafficPacketType) 0x0020) -#define CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_ALL ((CsrWifiRouterCtrlTrafficPacketType) 0x00FF) - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlTrafficType - - DESCRIPTION - - VALUES - CSR_WIFI_ROUTER_CTRL_TRAFFIC_TYPE_OCCASIONAL - - - CSR_WIFI_ROUTER_CTRL_TRAFFIC_TYPE_BURSTY - - - CSR_WIFI_ROUTER_CTRL_TRAFFIC_TYPE_PERIODIC - - - CSR_WIFI_ROUTER_CTRL_TRAFFIC_TYPE_CONTINUOUS - - - -*******************************************************************************/ -typedef u8 CsrWifiRouterCtrlTrafficType; -#define CSR_WIFI_ROUTER_CTRL_TRAFFIC_TYPE_OCCASIONAL ((CsrWifiRouterCtrlTrafficType) 0x00) -#define CSR_WIFI_ROUTER_CTRL_TRAFFIC_TYPE_BURSTY ((CsrWifiRouterCtrlTrafficType) 0x01) -#define CSR_WIFI_ROUTER_CTRL_TRAFFIC_TYPE_PERIODIC ((CsrWifiRouterCtrlTrafficType) 0x02) -#define CSR_WIFI_ROUTER_CTRL_TRAFFIC_TYPE_CONTINUOUS ((CsrWifiRouterCtrlTrafficType) 0x03) - - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlPeerRecordHandle - - DESCRIPTION - -*******************************************************************************/ -typedef u32 CsrWifiRouterCtrlPeerRecordHandle; -/******************************************************************************* - - NAME - CsrWifiRouterCtrlPowersaveTypeMask - - DESCRIPTION - Mask type for use with the values defined by - CsrWifiRouterCtrlPowersaveType - -*******************************************************************************/ -typedef u16 CsrWifiRouterCtrlPowersaveTypeMask; -/******************************************************************************* - - NAME - CsrWifiRouterCtrlQueueConfigMask - - DESCRIPTION - Mask type for use with the values defined by CsrWifiRouterCtrlQueueConfig - -*******************************************************************************/ -typedef u8 CsrWifiRouterCtrlQueueConfigMask; -/******************************************************************************* - - NAME - CsrWifiRouterCtrlRequestorInfo - - DESCRIPTION - -*******************************************************************************/ -typedef u16 CsrWifiRouterCtrlRequestorInfo; -/******************************************************************************* - - NAME - CsrWifiRouterCtrlTrafficStreamId - - DESCRIPTION - -*******************************************************************************/ -typedef u8 CsrWifiRouterCtrlTrafficStreamId; - - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlSmeVersions - - DESCRIPTION - - MEMBERS - firmwarePatch - - smeBuild - - smeHip - - -*******************************************************************************/ -typedef struct -{ - u32 firmwarePatch; - char *smeBuild; - u32 smeHip; -} CsrWifiRouterCtrlSmeVersions; - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlStaInfo - - DESCRIPTION - - MEMBERS - wmmOrQosEnabled - - powersaveMode - - maxSpLength - - listenIntervalInTus - - -*******************************************************************************/ -typedef struct -{ - u8 wmmOrQosEnabled; - CsrWifiRouterCtrlPowersaveTypeMask powersaveMode; - u8 maxSpLength; - u16 listenIntervalInTus; -} CsrWifiRouterCtrlStaInfo; - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlTrafficFilter - - DESCRIPTION - - MEMBERS - etherType - - ipType - - udpSourcePort - - udpDestPort - - -*******************************************************************************/ -typedef struct -{ - u32 etherType; - u8 ipType; - u32 udpSourcePort; - u32 udpDestPort; -} CsrWifiRouterCtrlTrafficFilter; - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlTrafficStats - - DESCRIPTION - - MEMBERS - rxMeanRate - Mean rx data rate over the interval - rxFramesNum - Keep number of Rx frames per second, for CYCLE_3. - txFramesNum - Keep number of Tx frames per second, for CYCLE_3. - rxBytesCount - Keep calculated Rx throughput per second, for CYCLE_2. - txBytesCount - Keep calculated Tx throughput per second, for CYCLE_2. - intervals - array size 11 MUST match TA_INTERVALS_NUM - -*******************************************************************************/ -typedef struct -{ - u32 rxMeanRate; - u32 rxFramesNum; - u32 txFramesNum; - u32 rxBytesCount; - u32 txBytesCount; - u8 intervals[11]; -} CsrWifiRouterCtrlTrafficStats; - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlVersions - - DESCRIPTION - - MEMBERS - chipId - - chipVersion - - firmwareBuild - - firmwareHip - - routerBuild - - routerHip - - -*******************************************************************************/ -typedef struct -{ - u32 chipId; - u32 chipVersion; - u32 firmwareBuild; - u32 firmwareHip; - char *routerBuild; - u32 routerHip; -} CsrWifiRouterCtrlVersions; - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlTrafficConfig - - DESCRIPTION - - MEMBERS - packetFilter - - customFilter - - -*******************************************************************************/ -typedef struct -{ - u16 packetFilter; - CsrWifiRouterCtrlTrafficFilter customFilter; -} CsrWifiRouterCtrlTrafficConfig; - - -/* Downstream */ -#define CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST (0x0000) - -#define CSR_WIFI_ROUTER_CTRL_CONFIGURE_POWER_MODE_REQ ((CsrWifiRouterCtrlPrim) (0x0000 + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_ROUTER_CTRL_HIP_REQ ((CsrWifiRouterCtrlPrim) (0x0001 + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_ROUTER_CTRL_MEDIA_STATUS_REQ ((CsrWifiRouterCtrlPrim) (0x0002 + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_ROUTER_CTRL_MULTICAST_ADDRESS_RES ((CsrWifiRouterCtrlPrim) (0x0003 + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_ROUTER_CTRL_PORT_CONFIGURE_REQ ((CsrWifiRouterCtrlPrim) (0x0004 + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_ROUTER_CTRL_QOS_CONTROL_REQ ((CsrWifiRouterCtrlPrim) (0x0005 + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_ROUTER_CTRL_SUSPEND_RES ((CsrWifiRouterCtrlPrim) (0x0006 + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_ROUTER_CTRL_TCLAS_ADD_REQ ((CsrWifiRouterCtrlPrim) (0x0007 + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_ROUTER_CTRL_RESUME_RES ((CsrWifiRouterCtrlPrim) (0x0008 + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_ROUTER_CTRL_RAW_SDIO_DEINITIALISE_REQ ((CsrWifiRouterCtrlPrim) (0x0009 + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_ROUTER_CTRL_RAW_SDIO_INITIALISE_REQ ((CsrWifiRouterCtrlPrim) (0x000A + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_ROUTER_CTRL_TCLAS_DEL_REQ ((CsrWifiRouterCtrlPrim) (0x000B + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_ROUTER_CTRL_TRAFFIC_CLASSIFICATION_REQ ((CsrWifiRouterCtrlPrim) (0x000C + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_ROUTER_CTRL_TRAFFIC_CONFIG_REQ ((CsrWifiRouterCtrlPrim) (0x000D + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_ROUTER_CTRL_WIFI_OFF_REQ ((CsrWifiRouterCtrlPrim) (0x000E + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_ROUTER_CTRL_WIFI_OFF_RES ((CsrWifiRouterCtrlPrim) (0x000F + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_ROUTER_CTRL_WIFI_ON_REQ ((CsrWifiRouterCtrlPrim) (0x0010 + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_ROUTER_CTRL_WIFI_ON_RES ((CsrWifiRouterCtrlPrim) (0x0011 + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_ROUTER_CTRL_M4_TRANSMIT_REQ ((CsrWifiRouterCtrlPrim) (0x0012 + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_ROUTER_CTRL_MODE_SET_REQ ((CsrWifiRouterCtrlPrim) (0x0013 + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_ROUTER_CTRL_PEER_ADD_REQ ((CsrWifiRouterCtrlPrim) (0x0014 + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_ROUTER_CTRL_PEER_DEL_REQ ((CsrWifiRouterCtrlPrim) (0x0015 + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_ROUTER_CTRL_PEER_UPDATE_REQ ((CsrWifiRouterCtrlPrim) (0x0016 + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_ROUTER_CTRL_CAPABILITIES_REQ ((CsrWifiRouterCtrlPrim) (0x0017 + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_ENABLE_REQ ((CsrWifiRouterCtrlPrim) (0x0018 + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_DISABLE_REQ ((CsrWifiRouterCtrlPrim) (0x0019 + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_ROUTER_CTRL_WAPI_RX_PKT_REQ ((CsrWifiRouterCtrlPrim) (0x001A + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_ROUTER_CTRL_WAPI_MULTICAST_FILTER_REQ ((CsrWifiRouterCtrlPrim) (0x001B + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_ROUTER_CTRL_WAPI_UNICAST_FILTER_REQ ((CsrWifiRouterCtrlPrim) (0x001C + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_ROUTER_CTRL_WAPI_UNICAST_TX_PKT_REQ ((CsrWifiRouterCtrlPrim) (0x001D + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_ROUTER_CTRL_WAPI_FILTER_REQ ((CsrWifiRouterCtrlPrim) (0x001E + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST)) - - -#define CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_HIGHEST (0x001E + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST) - -/* Upstream */ -#define CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST (0x0000 + CSR_PRIM_UPSTREAM) - -#define CSR_WIFI_ROUTER_CTRL_HIP_IND ((CsrWifiRouterCtrlPrim)(0x0000 + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_ROUTER_CTRL_MULTICAST_ADDRESS_IND ((CsrWifiRouterCtrlPrim)(0x0001 + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_ROUTER_CTRL_PORT_CONFIGURE_CFM ((CsrWifiRouterCtrlPrim)(0x0002 + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_ROUTER_CTRL_RESUME_IND ((CsrWifiRouterCtrlPrim)(0x0003 + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_ROUTER_CTRL_SUSPEND_IND ((CsrWifiRouterCtrlPrim)(0x0004 + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_ROUTER_CTRL_TCLAS_ADD_CFM ((CsrWifiRouterCtrlPrim)(0x0005 + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_ROUTER_CTRL_RAW_SDIO_DEINITIALISE_CFM ((CsrWifiRouterCtrlPrim)(0x0006 + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_ROUTER_CTRL_RAW_SDIO_INITIALISE_CFM ((CsrWifiRouterCtrlPrim)(0x0007 + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_ROUTER_CTRL_TCLAS_DEL_CFM ((CsrWifiRouterCtrlPrim)(0x0008 + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_ROUTER_CTRL_TRAFFIC_PROTOCOL_IND ((CsrWifiRouterCtrlPrim)(0x0009 + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_ROUTER_CTRL_TRAFFIC_SAMPLE_IND ((CsrWifiRouterCtrlPrim)(0x000A + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_ROUTER_CTRL_WIFI_OFF_IND ((CsrWifiRouterCtrlPrim)(0x000B + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_ROUTER_CTRL_WIFI_OFF_CFM ((CsrWifiRouterCtrlPrim)(0x000C + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_ROUTER_CTRL_WIFI_ON_IND ((CsrWifiRouterCtrlPrim)(0x000D + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_ROUTER_CTRL_WIFI_ON_CFM ((CsrWifiRouterCtrlPrim)(0x000E + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_ROUTER_CTRL_M4_READY_TO_SEND_IND ((CsrWifiRouterCtrlPrim)(0x000F + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_ROUTER_CTRL_M4_TRANSMITTED_IND ((CsrWifiRouterCtrlPrim)(0x0010 + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_ROUTER_CTRL_MIC_FAILURE_IND ((CsrWifiRouterCtrlPrim)(0x0011 + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_ROUTER_CTRL_CONNECTED_IND ((CsrWifiRouterCtrlPrim)(0x0012 + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_ROUTER_CTRL_PEER_ADD_CFM ((CsrWifiRouterCtrlPrim)(0x0013 + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_ROUTER_CTRL_PEER_DEL_CFM ((CsrWifiRouterCtrlPrim)(0x0014 + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_ROUTER_CTRL_UNEXPECTED_FRAME_IND ((CsrWifiRouterCtrlPrim)(0x0015 + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_ROUTER_CTRL_PEER_UPDATE_CFM ((CsrWifiRouterCtrlPrim)(0x0016 + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_ROUTER_CTRL_CAPABILITIES_CFM ((CsrWifiRouterCtrlPrim)(0x0017 + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_ENABLE_CFM ((CsrWifiRouterCtrlPrim)(0x0018 + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_DISABLE_CFM ((CsrWifiRouterCtrlPrim)(0x0019 + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_ERROR_IND ((CsrWifiRouterCtrlPrim)(0x001A + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_ROUTER_CTRL_STA_INACTIVE_IND ((CsrWifiRouterCtrlPrim)(0x001B + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_ROUTER_CTRL_WAPI_RX_MIC_CHECK_IND ((CsrWifiRouterCtrlPrim)(0x001C + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_ROUTER_CTRL_MODE_SET_CFM ((CsrWifiRouterCtrlPrim)(0x001D + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_ROUTER_CTRL_WAPI_UNICAST_TX_ENCRYPT_IND ((CsrWifiRouterCtrlPrim)(0x001E + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST)) - -#define CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_HIGHEST (0x001E + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST) - -#define CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_COUNT (CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_HIGHEST + 1 - CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST) -#define CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_COUNT (CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_HIGHEST + 1 - CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST) - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlConfigurePowerModeReq - - DESCRIPTION - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - clientData - - mode - - wakeHost - - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - CsrWifiRouterCtrlRequestorInfo clientData; - CsrWifiRouterCtrlLowPowerMode mode; - u8 wakeHost; -} CsrWifiRouterCtrlConfigurePowerModeReq; - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlHipReq - - DESCRIPTION - This primitive is used for transferring MLME messages to the HIP. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - mlmeCommandLength - Length of the MLME signal - mlmeCommand - Pointer to the MLME signal - dataRef1Length - Length of the dataRef1 bulk data - dataRef1 - Pointer to the bulk data 1 - dataRef2Length - Length of the dataRef2 bulk data - dataRef2 - Pointer to the bulk data 2 - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 mlmeCommandLength; - u8 *mlmeCommand; - u16 dataRef1Length; - u8 *dataRef1; - u16 dataRef2Length; - u8 *dataRef2; -} CsrWifiRouterCtrlHipReq; - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlMediaStatusReq - - DESCRIPTION - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - - clientData - - mediaStatus - - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; - CsrWifiRouterCtrlRequestorInfo clientData; - CsrWifiRouterCtrlMediaStatus mediaStatus; -} CsrWifiRouterCtrlMediaStatusReq; - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlMulticastAddressRes - - DESCRIPTION - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - - clientData - - status - - action - - getAddressesCount - - getAddresses - - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; - CsrWifiRouterCtrlRequestorInfo clientData; - CsrResult status; - CsrWifiRouterCtrlListAction action; - u8 getAddressesCount; - CsrWifiMacAddress *getAddresses; -} CsrWifiRouterCtrlMulticastAddressRes; - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlPortConfigureReq - - DESCRIPTION - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - - clientData - - uncontrolledPortAction - - controlledPortAction - - macAddress - - setProtection - - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; - CsrWifiRouterCtrlRequestorInfo clientData; - CsrWifiRouterCtrlPortAction uncontrolledPortAction; - CsrWifiRouterCtrlPortAction controlledPortAction; - CsrWifiMacAddress macAddress; - u8 setProtection; -} CsrWifiRouterCtrlPortConfigureReq; - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlQosControlReq - - DESCRIPTION - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - - clientData - - control - - queueConfig - - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; - CsrWifiRouterCtrlRequestorInfo clientData; - CsrWifiRouterCtrlQoSControl control; - CsrWifiRouterCtrlQueueConfigMask queueConfig; -} CsrWifiRouterCtrlQosControlReq; - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlSuspendRes - - DESCRIPTION - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - clientData - - status - - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - CsrWifiRouterCtrlRequestorInfo clientData; - CsrResult status; -} CsrWifiRouterCtrlSuspendRes; - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlTclasAddReq - - DESCRIPTION - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - - clientData - - tclasLength - - tclas - - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; - CsrWifiRouterCtrlRequestorInfo clientData; - u16 tclasLength; - u8 *tclas; -} CsrWifiRouterCtrlTclasAddReq; - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlResumeRes - - DESCRIPTION - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - clientData - - status - - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - CsrWifiRouterCtrlRequestorInfo clientData; - CsrResult status; -} CsrWifiRouterCtrlResumeRes; - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlRawSdioDeinitialiseReq - - DESCRIPTION - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - clientData - - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - CsrWifiRouterCtrlRequestorInfo clientData; -} CsrWifiRouterCtrlRawSdioDeinitialiseReq; - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlRawSdioInitialiseReq - - DESCRIPTION - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - clientData - - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - CsrWifiRouterCtrlRequestorInfo clientData; -} CsrWifiRouterCtrlRawSdioInitialiseReq; - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlTclasDelReq - - DESCRIPTION - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - - clientData - - tclasLength - - tclas - - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; - CsrWifiRouterCtrlRequestorInfo clientData; - u16 tclasLength; - u8 *tclas; -} CsrWifiRouterCtrlTclasDelReq; - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlTrafficClassificationReq - - DESCRIPTION - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - - clientData - - trafficType - - period - - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; - CsrWifiRouterCtrlRequestorInfo clientData; - CsrWifiRouterCtrlTrafficType trafficType; - u16 period; -} CsrWifiRouterCtrlTrafficClassificationReq; - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlTrafficConfigReq - - DESCRIPTION - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - - clientData - - trafficConfigType - - config - - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; - CsrWifiRouterCtrlRequestorInfo clientData; - CsrWifiRouterCtrlTrafficConfigType trafficConfigType; - CsrWifiRouterCtrlTrafficConfig config; -} CsrWifiRouterCtrlTrafficConfigReq; - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlWifiOffReq - - DESCRIPTION - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - clientData - - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - CsrWifiRouterCtrlRequestorInfo clientData; -} CsrWifiRouterCtrlWifiOffReq; - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlWifiOffRes - - DESCRIPTION - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - clientData - - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - CsrWifiRouterCtrlRequestorInfo clientData; -} CsrWifiRouterCtrlWifiOffRes; - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlWifiOnReq - - DESCRIPTION - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - clientData - - dataLength - Number of bytes in the buffer pointed to by 'data' - data - Pointer to the buffer containing 'dataLength' bytes - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - CsrWifiRouterCtrlRequestorInfo clientData; - u32 dataLength; - u8 *data; -} CsrWifiRouterCtrlWifiOnReq; - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlWifiOnRes - - DESCRIPTION - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - clientData - - status - - numInterfaceAddress - - stationMacAddress - array size 1 MUST match CSR_WIFI_NUM_INTERFACES - smeVersions - - scheduledInterrupt - - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - CsrWifiRouterCtrlRequestorInfo clientData; - CsrResult status; - u16 numInterfaceAddress; - CsrWifiMacAddress stationMacAddress[2]; - CsrWifiRouterCtrlSmeVersions smeVersions; - u8 scheduledInterrupt; -} CsrWifiRouterCtrlWifiOnRes; - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlM4TransmitReq - - DESCRIPTION - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - - clientData - - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; - CsrWifiRouterCtrlRequestorInfo clientData; -} CsrWifiRouterCtrlM4TransmitReq; - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlModeSetReq - - DESCRIPTION - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - - clientData - - mode - - bssid - BSSID of the network the device is going to be a part - of - protection - Set to TRUE if encryption is enabled for the - connection/broadcast frames - intraBssDistEnabled - If set to TRUE, intra BSS destribution will be - enabled. If set to FALSE, any unicast PDU which does - not have the RA as the the local MAC address, shall be - ignored. This field is interpreted by the receive if - mode is set to CSR_WIFI_ROUTER_CTRL_MODE_P2PGO - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; - CsrWifiRouterCtrlRequestorInfo clientData; - CsrWifiRouterCtrlMode mode; - CsrWifiMacAddress bssid; - u8 protection; - u8 intraBssDistEnabled; -} CsrWifiRouterCtrlModeSetReq; - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlPeerAddReq - - DESCRIPTION - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - - clientData - - peerMacAddress - - associationId - - staInfo - - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; - CsrWifiRouterCtrlRequestorInfo clientData; - CsrWifiMacAddress peerMacAddress; - u16 associationId; - CsrWifiRouterCtrlStaInfo staInfo; -} CsrWifiRouterCtrlPeerAddReq; - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlPeerDelReq - - DESCRIPTION - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - - clientData - - peerRecordHandle - - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; - CsrWifiRouterCtrlRequestorInfo clientData; - CsrWifiRouterCtrlPeerRecordHandle peerRecordHandle; -} CsrWifiRouterCtrlPeerDelReq; - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlPeerUpdateReq - - DESCRIPTION - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - - clientData - - peerRecordHandle - - powersaveMode - - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; - CsrWifiRouterCtrlRequestorInfo clientData; - CsrWifiRouterCtrlPeerRecordHandle peerRecordHandle; - CsrWifiRouterCtrlPowersaveTypeMask powersaveMode; -} CsrWifiRouterCtrlPeerUpdateReq; - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlCapabilitiesReq - - DESCRIPTION - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - clientData - - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - CsrWifiRouterCtrlRequestorInfo clientData; -} CsrWifiRouterCtrlCapabilitiesReq; - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlBlockAckEnableReq - - DESCRIPTION - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - - clientData - - macAddress - - trafficStreamID - - role - - bufferSize - - timeout - - ssn - - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; - CsrWifiRouterCtrlRequestorInfo clientData; - CsrWifiMacAddress macAddress; - CsrWifiRouterCtrlTrafficStreamId trafficStreamID; - CsrWifiRouterCtrlBlockAckRole role; - u16 bufferSize; - u16 timeout; - u16 ssn; -} CsrWifiRouterCtrlBlockAckEnableReq; - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlBlockAckDisableReq - - DESCRIPTION - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - - clientData - - macAddress - - trafficStreamID - - role - - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; - CsrWifiRouterCtrlRequestorInfo clientData; - CsrWifiMacAddress macAddress; - CsrWifiRouterCtrlTrafficStreamId trafficStreamID; - CsrWifiRouterCtrlBlockAckRole role; -} CsrWifiRouterCtrlBlockAckDisableReq; - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlWapiRxPktReq - - DESCRIPTION - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - - signalLength - - signal - - dataLength - - data - - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; - u16 signalLength; - u8 *signal; - u16 dataLength; - u8 *data; -} CsrWifiRouterCtrlWapiRxPktReq; - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlWapiMulticastFilterReq - - DESCRIPTION - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - - status - - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; - u8 status; -} CsrWifiRouterCtrlWapiMulticastFilterReq; - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlWapiUnicastFilterReq - - DESCRIPTION - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - - status - - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; - u8 status; -} CsrWifiRouterCtrlWapiUnicastFilterReq; - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlWapiUnicastTxPktReq - - DESCRIPTION - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - - dataLength - - data - - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; - u16 dataLength; - u8 *data; -} CsrWifiRouterCtrlWapiUnicastTxPktReq; - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlWapiFilterReq - - DESCRIPTION - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - - isWapiConnected - - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; - u8 isWapiConnected; -} CsrWifiRouterCtrlWapiFilterReq; - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlHipInd - - DESCRIPTION - This primitive is used for transferring MLME messages from the HIP. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - mlmeCommandLength - Length of the MLME signal - mlmeCommand - Pointer to the MLME signal - dataRef1Length - Length of the dataRef1 bulk data - dataRef1 - Pointer to the bulk data 1 - dataRef2Length - Length of the dataRef2 bulk data - dataRef2 - Pointer to the bulk data 2 - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 mlmeCommandLength; - u8 *mlmeCommand; - u16 dataRef1Length; - u8 *dataRef1; - u16 dataRef2Length; - u8 *dataRef2; -} CsrWifiRouterCtrlHipInd; - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlMulticastAddressInd - - DESCRIPTION - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - clientData - - interfaceTag - - action - - setAddressesCount - - setAddresses - - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - CsrWifiRouterCtrlRequestorInfo clientData; - u16 interfaceTag; - CsrWifiRouterCtrlListAction action; - u8 setAddressesCount; - CsrWifiMacAddress *setAddresses; -} CsrWifiRouterCtrlMulticastAddressInd; - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlPortConfigureCfm - - DESCRIPTION - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - clientData - - interfaceTag - - status - - macAddress - - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - CsrWifiRouterCtrlRequestorInfo clientData; - u16 interfaceTag; - CsrResult status; - CsrWifiMacAddress macAddress; -} CsrWifiRouterCtrlPortConfigureCfm; - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlResumeInd - - DESCRIPTION - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - clientData - - powerMaintained - - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - CsrWifiRouterCtrlRequestorInfo clientData; - u8 powerMaintained; -} CsrWifiRouterCtrlResumeInd; - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlSuspendInd - - DESCRIPTION - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - clientData - - hardSuspend - - d3Suspend - - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - CsrWifiRouterCtrlRequestorInfo clientData; - u8 hardSuspend; - u8 d3Suspend; -} CsrWifiRouterCtrlSuspendInd; - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlTclasAddCfm - - DESCRIPTION - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - clientData - - interfaceTag - - status - - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - CsrWifiRouterCtrlRequestorInfo clientData; - u16 interfaceTag; - CsrResult status; -} CsrWifiRouterCtrlTclasAddCfm; - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlRawSdioDeinitialiseCfm - - DESCRIPTION - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - clientData - - result - - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - CsrWifiRouterCtrlRequestorInfo clientData; - CsrResult result; -} CsrWifiRouterCtrlRawSdioDeinitialiseCfm; - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlRawSdioInitialiseCfm - - DESCRIPTION - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - clientData - - result - - byteRead - - byteWrite - - firmwareDownload - - reset - - coreDumpPrepare - - byteBlockRead - - gpRead16 - - gpWrite16 - - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - CsrWifiRouterCtrlRequestorInfo clientData; - CsrResult result; - CsrWifiRouterCtrlRawSdioByteRead byteRead; - CsrWifiRouterCtrlRawSdioByteWrite byteWrite; - CsrWifiRouterCtrlRawSdioFirmwareDownload firmwareDownload; - CsrWifiRouterCtrlRawSdioReset reset; - CsrWifiRouterCtrlRawSdioCoreDumpPrepare coreDumpPrepare; - CsrWifiRouterCtrlRawSdioByteBlockRead byteBlockRead; - CsrWifiRouterCtrlRawSdioGpRead16 gpRead16; - CsrWifiRouterCtrlRawSdioGpWrite16 gpWrite16; -} CsrWifiRouterCtrlRawSdioInitialiseCfm; - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlTclasDelCfm - - DESCRIPTION - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - clientData - - interfaceTag - - status - - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - CsrWifiRouterCtrlRequestorInfo clientData; - u16 interfaceTag; - CsrResult status; -} CsrWifiRouterCtrlTclasDelCfm; - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlTrafficProtocolInd - - DESCRIPTION - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - clientData - - interfaceTag - - packetType - - direction - - srcAddress - - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - CsrWifiRouterCtrlRequestorInfo clientData; - u16 interfaceTag; - CsrWifiRouterCtrlTrafficPacketType packetType; - CsrWifiRouterCtrlProtocolDirection direction; - CsrWifiMacAddress srcAddress; -} CsrWifiRouterCtrlTrafficProtocolInd; - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlTrafficSampleInd - - DESCRIPTION - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - clientData - - interfaceTag - - stats - - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - CsrWifiRouterCtrlRequestorInfo clientData; - u16 interfaceTag; - CsrWifiRouterCtrlTrafficStats stats; -} CsrWifiRouterCtrlTrafficSampleInd; - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlWifiOffInd - - DESCRIPTION - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - clientData - - controlIndication - - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - CsrWifiRouterCtrlRequestorInfo clientData; - CsrWifiRouterCtrlControlIndication controlIndication; -} CsrWifiRouterCtrlWifiOffInd; - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlWifiOffCfm - - DESCRIPTION - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - clientData - - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - CsrWifiRouterCtrlRequestorInfo clientData; -} CsrWifiRouterCtrlWifiOffCfm; - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlWifiOnInd - - DESCRIPTION - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - clientData - - status - - versions - - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - CsrWifiRouterCtrlRequestorInfo clientData; - CsrResult status; - CsrWifiRouterCtrlVersions versions; -} CsrWifiRouterCtrlWifiOnInd; - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlWifiOnCfm - - DESCRIPTION - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - clientData - - status - - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - CsrWifiRouterCtrlRequestorInfo clientData; - CsrResult status; -} CsrWifiRouterCtrlWifiOnCfm; - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlM4ReadyToSendInd - - DESCRIPTION - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - clientData - - interfaceTag - - peerMacAddress - - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - CsrWifiRouterCtrlRequestorInfo clientData; - u16 interfaceTag; - CsrWifiMacAddress peerMacAddress; -} CsrWifiRouterCtrlM4ReadyToSendInd; - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlM4TransmittedInd - - DESCRIPTION - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - clientData - - interfaceTag - - peerMacAddress - - status - - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - CsrWifiRouterCtrlRequestorInfo clientData; - u16 interfaceTag; - CsrWifiMacAddress peerMacAddress; - CsrResult status; -} CsrWifiRouterCtrlM4TransmittedInd; - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlMicFailureInd - - DESCRIPTION - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - clientData - - interfaceTag - - peerMacAddress - - unicastPdu - - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - CsrWifiRouterCtrlRequestorInfo clientData; - u16 interfaceTag; - CsrWifiMacAddress peerMacAddress; - u8 unicastPdu; -} CsrWifiRouterCtrlMicFailureInd; - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlConnectedInd - - DESCRIPTION - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - clientData - - interfaceTag - - peerMacAddress - - peerStatus - - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - CsrWifiRouterCtrlRequestorInfo clientData; - u16 interfaceTag; - CsrWifiMacAddress peerMacAddress; - CsrWifiRouterCtrlPeerStatus peerStatus; -} CsrWifiRouterCtrlConnectedInd; - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlPeerAddCfm - - DESCRIPTION - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - clientData - - interfaceTag - - peerMacAddress - - peerRecordHandle - - status - - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - CsrWifiRouterCtrlRequestorInfo clientData; - u16 interfaceTag; - CsrWifiMacAddress peerMacAddress; - CsrWifiRouterCtrlPeerRecordHandle peerRecordHandle; - CsrResult status; -} CsrWifiRouterCtrlPeerAddCfm; - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlPeerDelCfm - - DESCRIPTION - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - clientData - - interfaceTag - - status - - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - CsrWifiRouterCtrlRequestorInfo clientData; - u16 interfaceTag; - CsrResult status; -} CsrWifiRouterCtrlPeerDelCfm; - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlUnexpectedFrameInd - - DESCRIPTION - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - clientData - - interfaceTag - - peerMacAddress - - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - CsrWifiRouterCtrlRequestorInfo clientData; - u16 interfaceTag; - CsrWifiMacAddress peerMacAddress; -} CsrWifiRouterCtrlUnexpectedFrameInd; - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlPeerUpdateCfm - - DESCRIPTION - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - clientData - - interfaceTag - - status - - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - CsrWifiRouterCtrlRequestorInfo clientData; - u16 interfaceTag; - CsrResult status; -} CsrWifiRouterCtrlPeerUpdateCfm; - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlCapabilitiesCfm - - DESCRIPTION - The router sends this primitive to confirm the size of the queues of the - HIP. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - clientData - - commandQueueSize - Size of command queue - trafficQueueSize - Size of traffic queue (per AC) - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - CsrWifiRouterCtrlRequestorInfo clientData; - u16 commandQueueSize; - u16 trafficQueueSize; -} CsrWifiRouterCtrlCapabilitiesCfm; - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlBlockAckEnableCfm - - DESCRIPTION - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - clientData - - interfaceTag - - status - - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - CsrWifiRouterCtrlRequestorInfo clientData; - u16 interfaceTag; - CsrResult status; -} CsrWifiRouterCtrlBlockAckEnableCfm; - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlBlockAckDisableCfm - - DESCRIPTION - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - clientData - - interfaceTag - - status - - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - CsrWifiRouterCtrlRequestorInfo clientData; - u16 interfaceTag; - CsrResult status; -} CsrWifiRouterCtrlBlockAckDisableCfm; - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlBlockAckErrorInd - - DESCRIPTION - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - clientData - - interfaceTag - - trafficStreamID - - peerMacAddress - - status - - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - CsrWifiRouterCtrlRequestorInfo clientData; - u16 interfaceTag; - CsrWifiRouterCtrlTrafficStreamId trafficStreamID; - CsrWifiMacAddress peerMacAddress; - CsrResult status; -} CsrWifiRouterCtrlBlockAckErrorInd; - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlStaInactiveInd - - DESCRIPTION - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - clientData - - interfaceTag - - staAddress - - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - CsrWifiRouterCtrlRequestorInfo clientData; - u16 interfaceTag; - CsrWifiMacAddress staAddress; -} CsrWifiRouterCtrlStaInactiveInd; - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlWapiRxMicCheckInd - - DESCRIPTION - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - clientData - - interfaceTag - - signalLength - - signal - - dataLength - - data - - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - CsrWifiRouterCtrlRequestorInfo clientData; - u16 interfaceTag; - u16 signalLength; - u8 *signal; - u16 dataLength; - u8 *data; -} CsrWifiRouterCtrlWapiRxMicCheckInd; - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlModeSetCfm - - DESCRIPTION - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - clientData - - interfaceTag - - mode - - status - - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - CsrWifiRouterCtrlRequestorInfo clientData; - u16 interfaceTag; - CsrWifiRouterCtrlMode mode; - CsrResult status; -} CsrWifiRouterCtrlModeSetCfm; - -/******************************************************************************* - - NAME - CsrWifiRouterCtrlWapiUnicastTxEncryptInd - - DESCRIPTION - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - clientData - - interfaceTag - - dataLength - - data - - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - CsrWifiRouterCtrlRequestorInfo clientData; - u16 interfaceTag; - u16 dataLength; - u8 *data; -} CsrWifiRouterCtrlWapiUnicastTxEncryptInd; - -#endif /* CSR_WIFI_ROUTER_CTRL_PRIM_H__ */ - diff --git a/drivers/staging/csr/csr_wifi_router_ctrl_sef.c b/drivers/staging/csr/csr_wifi_router_ctrl_sef.c deleted file mode 100644 index 99cf93061d1b..000000000000 --- a/drivers/staging/csr/csr_wifi_router_ctrl_sef.c +++ /dev/null @@ -1,46 +0,0 @@ -/***************************************************************************** - - (c) Cambridge Silicon Radio Limited 2010 - Confidential information of CSR - - Refer to LICENSE.txt included with this source for details - on the license terms. - - *****************************************************************************/ -#include "csr_wifi_router_ctrl_sef.h" - -const CsrWifiRouterCtrlStateHandlerType - CsrWifiRouterCtrlDownstreamStateHandlers - [CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_COUNT] = { - /* 0x0000 */ CsrWifiRouterCtrlConfigurePowerModeReqHandler, - /* 0x0001 */ CsrWifiRouterCtrlHipReqHandler, - /* 0x0002 */ CsrWifiRouterCtrlMediaStatusReqHandler, - /* 0x0003 */ CsrWifiRouterCtrlMulticastAddressResHandler, - /* 0x0004 */ CsrWifiRouterCtrlPortConfigureReqHandler, - /* 0x0005 */ CsrWifiRouterCtrlQosControlReqHandler, - /* 0x0006 */ CsrWifiRouterCtrlSuspendResHandler, - /* 0x0007 */ CsrWifiRouterCtrlTclasAddReqHandler, - /* 0x0008 */ CsrWifiRouterCtrlResumeResHandler, - /* 0x0009 */ CsrWifiRouterCtrlRawSdioDeinitialiseReqHandler, - /* 0x000A */ CsrWifiRouterCtrlRawSdioInitialiseReqHandler, - /* 0x000B */ CsrWifiRouterCtrlTclasDelReqHandler, - /* 0x000C */ CsrWifiRouterCtrlTrafficClassificationReqHandler, - /* 0x000D */ CsrWifiRouterCtrlTrafficConfigReqHandler, - /* 0x000E */ CsrWifiRouterCtrlWifiOffReqHandler, - /* 0x000F */ CsrWifiRouterCtrlWifiOffResHandler, - /* 0x0010 */ CsrWifiRouterCtrlWifiOnReqHandler, - /* 0x0011 */ CsrWifiRouterCtrlWifiOnResHandler, - /* 0x0012 */ CsrWifiRouterCtrlM4TransmitReqHandler, - /* 0x0013 */ CsrWifiRouterCtrlModeSetReqHandler, - /* 0x0014 */ CsrWifiRouterCtrlPeerAddReqHandler, - /* 0x0015 */ CsrWifiRouterCtrlPeerDelReqHandler, - /* 0x0016 */ CsrWifiRouterCtrlPeerUpdateReqHandler, - /* 0x0017 */ CsrWifiRouterCtrlCapabilitiesReqHandler, - /* 0x0018 */ CsrWifiRouterCtrlBlockAckEnableReqHandler, - /* 0x0019 */ CsrWifiRouterCtrlBlockAckDisableReqHandler, - /* 0x001A */ CsrWifiRouterCtrlWapiRxPktReqHandler, - /* 0x001B */ CsrWifiRouterCtrlWapiMulticastFilterReqHandler, - /* 0x001C */ CsrWifiRouterCtrlWapiUnicastFilterReqHandler, - /* 0x001D */ CsrWifiRouterCtrlWapiUnicastTxPktReqHandler, - /* 0x001E */ CsrWifiRouterCtrlWapiFilterReqHandler, -}; diff --git a/drivers/staging/csr/csr_wifi_router_ctrl_sef.h b/drivers/staging/csr/csr_wifi_router_ctrl_sef.h deleted file mode 100644 index 2fb4937bc909..000000000000 --- a/drivers/staging/csr/csr_wifi_router_ctrl_sef.h +++ /dev/null @@ -1,51 +0,0 @@ -/***************************************************************************** - - (c) Cambridge Silicon Radio Limited 2010 - Confidential information of CSR - - Refer to LICENSE.txt included with this source for details - on the license terms. - - *****************************************************************************/ -#ifndef CSR_WIFI_ROUTER_SEF_CSR_WIFI_ROUTER_CTRL_H__ -#define CSR_WIFI_ROUTER_SEF_CSR_WIFI_ROUTER_CTRL_H__ - -#include "csr_wifi_router_ctrl_prim.h" - - typedef void (*CsrWifiRouterCtrlStateHandlerType)(void* drvpriv, CsrWifiFsmEvent* msg); - - extern const CsrWifiRouterCtrlStateHandlerType CsrWifiRouterCtrlDownstreamStateHandlers[CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_COUNT]; - - extern void CsrWifiRouterCtrlConfigurePowerModeReqHandler(void* drvpriv, CsrWifiFsmEvent* msg); - extern void CsrWifiRouterCtrlHipReqHandler(void* drvpriv, CsrWifiFsmEvent* msg); - extern void CsrWifiRouterCtrlMediaStatusReqHandler(void* drvpriv, CsrWifiFsmEvent* msg); - extern void CsrWifiRouterCtrlMulticastAddressResHandler(void* drvpriv, CsrWifiFsmEvent* msg); - extern void CsrWifiRouterCtrlPortConfigureReqHandler(void* drvpriv, CsrWifiFsmEvent* msg); - extern void CsrWifiRouterCtrlQosControlReqHandler(void* drvpriv, CsrWifiFsmEvent* msg); - extern void CsrWifiRouterCtrlSuspendResHandler(void* drvpriv, CsrWifiFsmEvent* msg); - extern void CsrWifiRouterCtrlTclasAddReqHandler(void* drvpriv, CsrWifiFsmEvent* msg); - extern void CsrWifiRouterCtrlResumeResHandler(void* drvpriv, CsrWifiFsmEvent* msg); - extern void CsrWifiRouterCtrlRawSdioDeinitialiseReqHandler(void* drvpriv, CsrWifiFsmEvent* msg); - extern void CsrWifiRouterCtrlRawSdioInitialiseReqHandler(void* drvpriv, CsrWifiFsmEvent* msg); - extern void CsrWifiRouterCtrlTclasDelReqHandler(void* drvpriv, CsrWifiFsmEvent* msg); - extern void CsrWifiRouterCtrlTrafficClassificationReqHandler(void* drvpriv, CsrWifiFsmEvent* msg); - extern void CsrWifiRouterCtrlTrafficConfigReqHandler(void* drvpriv, CsrWifiFsmEvent* msg); - extern void CsrWifiRouterCtrlWifiOffReqHandler(void* drvpriv, CsrWifiFsmEvent* msg); - extern void CsrWifiRouterCtrlWifiOffResHandler(void* drvpriv, CsrWifiFsmEvent* msg); - extern void CsrWifiRouterCtrlWifiOnReqHandler(void* drvpriv, CsrWifiFsmEvent* msg); - extern void CsrWifiRouterCtrlWifiOnResHandler(void* drvpriv, CsrWifiFsmEvent* msg); - extern void CsrWifiRouterCtrlM4TransmitReqHandler(void* drvpriv, CsrWifiFsmEvent* msg); - extern void CsrWifiRouterCtrlModeSetReqHandler(void* drvpriv, CsrWifiFsmEvent* msg); - extern void CsrWifiRouterCtrlPeerAddReqHandler(void* drvpriv, CsrWifiFsmEvent* msg); - extern void CsrWifiRouterCtrlPeerDelReqHandler(void* drvpriv, CsrWifiFsmEvent* msg); - extern void CsrWifiRouterCtrlPeerUpdateReqHandler(void* drvpriv, CsrWifiFsmEvent* msg); - extern void CsrWifiRouterCtrlCapabilitiesReqHandler(void* drvpriv, CsrWifiFsmEvent* msg); - extern void CsrWifiRouterCtrlBlockAckEnableReqHandler(void* drvpriv, CsrWifiFsmEvent* msg); - extern void CsrWifiRouterCtrlBlockAckDisableReqHandler(void* drvpriv, CsrWifiFsmEvent* msg); - extern void CsrWifiRouterCtrlWapiMulticastFilterReqHandler(void* drvpriv, CsrWifiFsmEvent* msg); - extern void CsrWifiRouterCtrlWapiRxPktReqHandler(void* drvpriv, CsrWifiFsmEvent* msg); - extern void CsrWifiRouterCtrlWapiUnicastTxPktReqHandler(void* drvpriv, CsrWifiFsmEvent* msg); - extern void CsrWifiRouterCtrlWapiUnicastFilterReqHandler(void* drvpriv, CsrWifiFsmEvent* msg); - extern void CsrWifiRouterCtrlWapiFilterReqHandler(void* drvpriv, CsrWifiFsmEvent* msg); - -#endif /* CSR_WIFI_ROUTER_SEF_CSR_WIFI_ROUTER_CTRL_H__ */ diff --git a/drivers/staging/csr/csr_wifi_router_ctrl_serialize.c b/drivers/staging/csr/csr_wifi_router_ctrl_serialize.c deleted file mode 100644 index 3eda1b66b336..000000000000 --- a/drivers/staging/csr/csr_wifi_router_ctrl_serialize.c +++ /dev/null @@ -1,2591 +0,0 @@ -/***************************************************************************** - - (c) Cambridge Silicon Radio Limited 2012 - All rights reserved and confidential information of CSR - - Refer to LICENSE.txt included with this source for details - on the license terms. - -*****************************************************************************/ - -/* Note: this is an auto-generated file. */ -#include -#include -#include "csr_msgconv.h" -#include "csr_wifi_router_ctrl_prim.h" -#include "csr_wifi_router_ctrl_serialize.h" - -void CsrWifiRouterCtrlPfree(void *ptr) -{ - kfree(ptr); -} - - -size_t CsrWifiRouterCtrlConfigurePowerModeReqSizeof(void *msg) -{ - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 8) */ - bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */ - bufferSize += 2; /* CsrWifiRouterCtrlLowPowerMode primitive->mode */ - bufferSize += 1; /* u8 primitive->wakeHost */ - return bufferSize; -} - - -u8* CsrWifiRouterCtrlConfigurePowerModeReqSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiRouterCtrlConfigurePowerModeReq *primitive = (CsrWifiRouterCtrlConfigurePowerModeReq *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->clientData); - CsrUint16Ser(ptr, len, (u16) primitive->mode); - CsrUint8Ser(ptr, len, (u8) primitive->wakeHost); - return(ptr); -} - - -void* CsrWifiRouterCtrlConfigurePowerModeReqDes(u8 *buffer, size_t length) -{ - CsrWifiRouterCtrlConfigurePowerModeReq *primitive = kmalloc(sizeof(CsrWifiRouterCtrlConfigurePowerModeReq), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset); - CsrUint16Des((u16 *) &primitive->mode, buffer, &offset); - CsrUint8Des((u8 *) &primitive->wakeHost, buffer, &offset); - - return primitive; -} - - -size_t CsrWifiRouterCtrlHipReqSizeof(void *msg) -{ - CsrWifiRouterCtrlHipReq *primitive = (CsrWifiRouterCtrlHipReq *) msg; - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 12) */ - bufferSize += 2; /* u16 primitive->mlmeCommandLength */ - bufferSize += primitive->mlmeCommandLength; /* u8 primitive->mlmeCommand */ - bufferSize += 2; /* u16 primitive->dataRef1Length */ - bufferSize += primitive->dataRef1Length; /* u8 primitive->dataRef1 */ - bufferSize += 2; /* u16 primitive->dataRef2Length */ - bufferSize += primitive->dataRef2Length; /* u8 primitive->dataRef2 */ - return bufferSize; -} - - -u8* CsrWifiRouterCtrlHipReqSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiRouterCtrlHipReq *primitive = (CsrWifiRouterCtrlHipReq *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->mlmeCommandLength); - if (primitive->mlmeCommandLength) - { - CsrMemCpySer(ptr, len, (const void *) primitive->mlmeCommand, ((u16) (primitive->mlmeCommandLength))); - } - CsrUint16Ser(ptr, len, (u16) primitive->dataRef1Length); - if (primitive->dataRef1Length) - { - CsrMemCpySer(ptr, len, (const void *) primitive->dataRef1, ((u16) (primitive->dataRef1Length))); - } - CsrUint16Ser(ptr, len, (u16) primitive->dataRef2Length); - if (primitive->dataRef2Length) - { - CsrMemCpySer(ptr, len, (const void *) primitive->dataRef2, ((u16) (primitive->dataRef2Length))); - } - return(ptr); -} - - -void* CsrWifiRouterCtrlHipReqDes(u8 *buffer, size_t length) -{ - CsrWifiRouterCtrlHipReq *primitive = kmalloc(sizeof(CsrWifiRouterCtrlHipReq), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->mlmeCommandLength, buffer, &offset); - if (primitive->mlmeCommandLength) - { - primitive->mlmeCommand = kmalloc(primitive->mlmeCommandLength, GFP_KERNEL); - CsrMemCpyDes(primitive->mlmeCommand, buffer, &offset, ((u16) (primitive->mlmeCommandLength))); - } - else - { - primitive->mlmeCommand = NULL; - } - CsrUint16Des((u16 *) &primitive->dataRef1Length, buffer, &offset); - if (primitive->dataRef1Length) - { - primitive->dataRef1 = kmalloc(primitive->dataRef1Length, GFP_KERNEL); - CsrMemCpyDes(primitive->dataRef1, buffer, &offset, ((u16) (primitive->dataRef1Length))); - } - else - { - primitive->dataRef1 = NULL; - } - CsrUint16Des((u16 *) &primitive->dataRef2Length, buffer, &offset); - if (primitive->dataRef2Length) - { - primitive->dataRef2 = kmalloc(primitive->dataRef2Length, GFP_KERNEL); - CsrMemCpyDes(primitive->dataRef2, buffer, &offset, ((u16) (primitive->dataRef2Length))); - } - else - { - primitive->dataRef2 = NULL; - } - - return primitive; -} - - -void CsrWifiRouterCtrlHipReqSerFree(void *voidPrimitivePointer) -{ - CsrWifiRouterCtrlHipReq *primitive = (CsrWifiRouterCtrlHipReq *) voidPrimitivePointer; - kfree(primitive->mlmeCommand); - kfree(primitive->dataRef1); - kfree(primitive->dataRef2); - kfree(primitive); -} - - -size_t CsrWifiRouterCtrlMediaStatusReqSizeof(void *msg) -{ - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 8) */ - bufferSize += 2; /* u16 primitive->interfaceTag */ - bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */ - bufferSize += 1; /* CsrWifiRouterCtrlMediaStatus primitive->mediaStatus */ - return bufferSize; -} - - -u8* CsrWifiRouterCtrlMediaStatusReqSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiRouterCtrlMediaStatusReq *primitive = (CsrWifiRouterCtrlMediaStatusReq *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag); - CsrUint16Ser(ptr, len, (u16) primitive->clientData); - CsrUint8Ser(ptr, len, (u8) primitive->mediaStatus); - return(ptr); -} - - -void* CsrWifiRouterCtrlMediaStatusReqDes(u8 *buffer, size_t length) -{ - CsrWifiRouterCtrlMediaStatusReq *primitive = kmalloc(sizeof(CsrWifiRouterCtrlMediaStatusReq), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset); - CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset); - CsrUint8Des((u8 *) &primitive->mediaStatus, buffer, &offset); - - return primitive; -} - - -size_t CsrWifiRouterCtrlMulticastAddressResSizeof(void *msg) -{ - CsrWifiRouterCtrlMulticastAddressRes *primitive = (CsrWifiRouterCtrlMulticastAddressRes *) msg; - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 17) */ - bufferSize += 2; /* u16 primitive->interfaceTag */ - bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */ - bufferSize += 2; /* CsrResult primitive->status */ - bufferSize += 1; /* CsrWifiRouterCtrlListAction primitive->action */ - bufferSize += 1; /* u8 primitive->getAddressesCount */ - { - u16 i1; - for (i1 = 0; i1 < primitive->getAddressesCount; i1++) - { - bufferSize += 6; /* u8 primitive->getAddresses[i1].a[6] */ - } - } - return bufferSize; -} - - -u8* CsrWifiRouterCtrlMulticastAddressResSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiRouterCtrlMulticastAddressRes *primitive = (CsrWifiRouterCtrlMulticastAddressRes *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag); - CsrUint16Ser(ptr, len, (u16) primitive->clientData); - CsrUint16Ser(ptr, len, (u16) primitive->status); - CsrUint8Ser(ptr, len, (u8) primitive->action); - CsrUint8Ser(ptr, len, (u8) primitive->getAddressesCount); - { - u16 i1; - for (i1 = 0; i1 < primitive->getAddressesCount; i1++) - { - CsrMemCpySer(ptr, len, (const void *) primitive->getAddresses[i1].a, ((u16) (6))); - } - } - return(ptr); -} - - -void* CsrWifiRouterCtrlMulticastAddressResDes(u8 *buffer, size_t length) -{ - CsrWifiRouterCtrlMulticastAddressRes *primitive = kmalloc(sizeof(CsrWifiRouterCtrlMulticastAddressRes), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset); - CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset); - CsrUint16Des((u16 *) &primitive->status, buffer, &offset); - CsrUint8Des((u8 *) &primitive->action, buffer, &offset); - CsrUint8Des((u8 *) &primitive->getAddressesCount, buffer, &offset); - primitive->getAddresses = NULL; - if (primitive->getAddressesCount) - { - primitive->getAddresses = kmalloc(sizeof(CsrWifiMacAddress) * primitive->getAddressesCount, GFP_KERNEL); - } - { - u16 i1; - for (i1 = 0; i1 < primitive->getAddressesCount; i1++) - { - CsrMemCpyDes(primitive->getAddresses[i1].a, buffer, &offset, ((u16) (6))); - } - } - - return primitive; -} - - -void CsrWifiRouterCtrlMulticastAddressResSerFree(void *voidPrimitivePointer) -{ - CsrWifiRouterCtrlMulticastAddressRes *primitive = (CsrWifiRouterCtrlMulticastAddressRes *) voidPrimitivePointer; - kfree(primitive->getAddresses); - kfree(primitive); -} - - -size_t CsrWifiRouterCtrlPortConfigureReqSizeof(void *msg) -{ - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 18) */ - bufferSize += 2; /* u16 primitive->interfaceTag */ - bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */ - bufferSize += 2; /* CsrWifiRouterCtrlPortAction primitive->uncontrolledPortAction */ - bufferSize += 2; /* CsrWifiRouterCtrlPortAction primitive->controlledPortAction */ - bufferSize += 6; /* u8 primitive->macAddress.a[6] */ - bufferSize += 1; /* u8 primitive->setProtection */ - return bufferSize; -} - - -u8* CsrWifiRouterCtrlPortConfigureReqSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiRouterCtrlPortConfigureReq *primitive = (CsrWifiRouterCtrlPortConfigureReq *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag); - CsrUint16Ser(ptr, len, (u16) primitive->clientData); - CsrUint16Ser(ptr, len, (u16) primitive->uncontrolledPortAction); - CsrUint16Ser(ptr, len, (u16) primitive->controlledPortAction); - CsrMemCpySer(ptr, len, (const void *) primitive->macAddress.a, ((u16) (6))); - CsrUint8Ser(ptr, len, (u8) primitive->setProtection); - return(ptr); -} - - -void* CsrWifiRouterCtrlPortConfigureReqDes(u8 *buffer, size_t length) -{ - CsrWifiRouterCtrlPortConfigureReq *primitive = kmalloc(sizeof(CsrWifiRouterCtrlPortConfigureReq), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset); - CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset); - CsrUint16Des((u16 *) &primitive->uncontrolledPortAction, buffer, &offset); - CsrUint16Des((u16 *) &primitive->controlledPortAction, buffer, &offset); - CsrMemCpyDes(primitive->macAddress.a, buffer, &offset, ((u16) (6))); - CsrUint8Des((u8 *) &primitive->setProtection, buffer, &offset); - - return primitive; -} - - -size_t CsrWifiRouterCtrlQosControlReqSizeof(void *msg) -{ - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 10) */ - bufferSize += 2; /* u16 primitive->interfaceTag */ - bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */ - bufferSize += 2; /* CsrWifiRouterCtrlQoSControl primitive->control */ - bufferSize += 1; /* CsrWifiRouterCtrlQueueConfigMask primitive->queueConfig */ - return bufferSize; -} - - -u8* CsrWifiRouterCtrlQosControlReqSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiRouterCtrlQosControlReq *primitive = (CsrWifiRouterCtrlQosControlReq *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag); - CsrUint16Ser(ptr, len, (u16) primitive->clientData); - CsrUint16Ser(ptr, len, (u16) primitive->control); - CsrUint8Ser(ptr, len, (u8) primitive->queueConfig); - return(ptr); -} - - -void* CsrWifiRouterCtrlQosControlReqDes(u8 *buffer, size_t length) -{ - CsrWifiRouterCtrlQosControlReq *primitive = kmalloc(sizeof(CsrWifiRouterCtrlQosControlReq), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset); - CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset); - CsrUint16Des((u16 *) &primitive->control, buffer, &offset); - CsrUint8Des((u8 *) &primitive->queueConfig, buffer, &offset); - - return primitive; -} - - -size_t CsrWifiRouterCtrlSuspendResSizeof(void *msg) -{ - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 7) */ - bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */ - bufferSize += 2; /* CsrResult primitive->status */ - return bufferSize; -} - - -u8* CsrWifiRouterCtrlSuspendResSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiRouterCtrlSuspendRes *primitive = (CsrWifiRouterCtrlSuspendRes *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->clientData); - CsrUint16Ser(ptr, len, (u16) primitive->status); - return(ptr); -} - - -void* CsrWifiRouterCtrlSuspendResDes(u8 *buffer, size_t length) -{ - CsrWifiRouterCtrlSuspendRes *primitive = kmalloc(sizeof(CsrWifiRouterCtrlSuspendRes), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset); - CsrUint16Des((u16 *) &primitive->status, buffer, &offset); - - return primitive; -} - - -size_t CsrWifiRouterCtrlTclasAddReqSizeof(void *msg) -{ - CsrWifiRouterCtrlTclasAddReq *primitive = (CsrWifiRouterCtrlTclasAddReq *) msg; - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 10) */ - bufferSize += 2; /* u16 primitive->interfaceTag */ - bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */ - bufferSize += 2; /* u16 primitive->tclasLength */ - bufferSize += primitive->tclasLength; /* u8 primitive->tclas */ - return bufferSize; -} - - -u8* CsrWifiRouterCtrlTclasAddReqSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiRouterCtrlTclasAddReq *primitive = (CsrWifiRouterCtrlTclasAddReq *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag); - CsrUint16Ser(ptr, len, (u16) primitive->clientData); - CsrUint16Ser(ptr, len, (u16) primitive->tclasLength); - if (primitive->tclasLength) - { - CsrMemCpySer(ptr, len, (const void *) primitive->tclas, ((u16) (primitive->tclasLength))); - } - return(ptr); -} - - -void* CsrWifiRouterCtrlTclasAddReqDes(u8 *buffer, size_t length) -{ - CsrWifiRouterCtrlTclasAddReq *primitive = kmalloc(sizeof(CsrWifiRouterCtrlTclasAddReq), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset); - CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset); - CsrUint16Des((u16 *) &primitive->tclasLength, buffer, &offset); - if (primitive->tclasLength) - { - primitive->tclas = kmalloc(primitive->tclasLength, GFP_KERNEL); - CsrMemCpyDes(primitive->tclas, buffer, &offset, ((u16) (primitive->tclasLength))); - } - else - { - primitive->tclas = NULL; - } - - return primitive; -} - - -void CsrWifiRouterCtrlTclasAddReqSerFree(void *voidPrimitivePointer) -{ - CsrWifiRouterCtrlTclasAddReq *primitive = (CsrWifiRouterCtrlTclasAddReq *) voidPrimitivePointer; - kfree(primitive->tclas); - kfree(primitive); -} - - -size_t CsrWifiRouterCtrlResumeResSizeof(void *msg) -{ - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 7) */ - bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */ - bufferSize += 2; /* CsrResult primitive->status */ - return bufferSize; -} - - -u8* CsrWifiRouterCtrlResumeResSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiRouterCtrlResumeRes *primitive = (CsrWifiRouterCtrlResumeRes *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->clientData); - CsrUint16Ser(ptr, len, (u16) primitive->status); - return(ptr); -} - - -void* CsrWifiRouterCtrlResumeResDes(u8 *buffer, size_t length) -{ - CsrWifiRouterCtrlResumeRes *primitive = kmalloc(sizeof(CsrWifiRouterCtrlResumeRes), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset); - CsrUint16Des((u16 *) &primitive->status, buffer, &offset); - - return primitive; -} - - -size_t CsrWifiRouterCtrlTclasDelReqSizeof(void *msg) -{ - CsrWifiRouterCtrlTclasDelReq *primitive = (CsrWifiRouterCtrlTclasDelReq *) msg; - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 10) */ - bufferSize += 2; /* u16 primitive->interfaceTag */ - bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */ - bufferSize += 2; /* u16 primitive->tclasLength */ - bufferSize += primitive->tclasLength; /* u8 primitive->tclas */ - return bufferSize; -} - - -u8* CsrWifiRouterCtrlTclasDelReqSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiRouterCtrlTclasDelReq *primitive = (CsrWifiRouterCtrlTclasDelReq *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag); - CsrUint16Ser(ptr, len, (u16) primitive->clientData); - CsrUint16Ser(ptr, len, (u16) primitive->tclasLength); - if (primitive->tclasLength) - { - CsrMemCpySer(ptr, len, (const void *) primitive->tclas, ((u16) (primitive->tclasLength))); - } - return(ptr); -} - - -void* CsrWifiRouterCtrlTclasDelReqDes(u8 *buffer, size_t length) -{ - CsrWifiRouterCtrlTclasDelReq *primitive = kmalloc(sizeof(CsrWifiRouterCtrlTclasDelReq), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset); - CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset); - CsrUint16Des((u16 *) &primitive->tclasLength, buffer, &offset); - if (primitive->tclasLength) - { - primitive->tclas = kmalloc(primitive->tclasLength, GFP_KERNEL); - CsrMemCpyDes(primitive->tclas, buffer, &offset, ((u16) (primitive->tclasLength))); - } - else - { - primitive->tclas = NULL; - } - - return primitive; -} - - -void CsrWifiRouterCtrlTclasDelReqSerFree(void *voidPrimitivePointer) -{ - CsrWifiRouterCtrlTclasDelReq *primitive = (CsrWifiRouterCtrlTclasDelReq *) voidPrimitivePointer; - kfree(primitive->tclas); - kfree(primitive); -} - - -size_t CsrWifiRouterCtrlTrafficClassificationReqSizeof(void *msg) -{ - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 10) */ - bufferSize += 2; /* u16 primitive->interfaceTag */ - bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */ - bufferSize += 1; /* CsrWifiRouterCtrlTrafficType primitive->trafficType */ - bufferSize += 2; /* u16 primitive->period */ - return bufferSize; -} - - -u8* CsrWifiRouterCtrlTrafficClassificationReqSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiRouterCtrlTrafficClassificationReq *primitive = (CsrWifiRouterCtrlTrafficClassificationReq *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag); - CsrUint16Ser(ptr, len, (u16) primitive->clientData); - CsrUint8Ser(ptr, len, (u8) primitive->trafficType); - CsrUint16Ser(ptr, len, (u16) primitive->period); - return(ptr); -} - - -void* CsrWifiRouterCtrlTrafficClassificationReqDes(u8 *buffer, size_t length) -{ - CsrWifiRouterCtrlTrafficClassificationReq *primitive = kmalloc(sizeof(CsrWifiRouterCtrlTrafficClassificationReq), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset); - CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset); - CsrUint8Des((u8 *) &primitive->trafficType, buffer, &offset); - CsrUint16Des((u16 *) &primitive->period, buffer, &offset); - - return primitive; -} - - -size_t CsrWifiRouterCtrlTrafficConfigReqSizeof(void *msg) -{ - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 24) */ - bufferSize += 2; /* u16 primitive->interfaceTag */ - bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */ - bufferSize += 2; /* CsrWifiRouterCtrlTrafficConfigType primitive->trafficConfigType */ - bufferSize += 2; /* u16 primitive->config.packetFilter */ - bufferSize += 4; /* u32 primitive->config.customFilter.etherType */ - bufferSize += 1; /* u8 primitive->config.customFilter.ipType */ - bufferSize += 4; /* u32 primitive->config.customFilter.udpSourcePort */ - bufferSize += 4; /* u32 primitive->config.customFilter.udpDestPort */ - return bufferSize; -} - - -u8* CsrWifiRouterCtrlTrafficConfigReqSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiRouterCtrlTrafficConfigReq *primitive = (CsrWifiRouterCtrlTrafficConfigReq *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag); - CsrUint16Ser(ptr, len, (u16) primitive->clientData); - CsrUint16Ser(ptr, len, (u16) primitive->trafficConfigType); - CsrUint16Ser(ptr, len, (u16) primitive->config.packetFilter); - CsrUint32Ser(ptr, len, (u32) primitive->config.customFilter.etherType); - CsrUint8Ser(ptr, len, (u8) primitive->config.customFilter.ipType); - CsrUint32Ser(ptr, len, (u32) primitive->config.customFilter.udpSourcePort); - CsrUint32Ser(ptr, len, (u32) primitive->config.customFilter.udpDestPort); - return(ptr); -} - - -void* CsrWifiRouterCtrlTrafficConfigReqDes(u8 *buffer, size_t length) -{ - CsrWifiRouterCtrlTrafficConfigReq *primitive = kmalloc(sizeof(CsrWifiRouterCtrlTrafficConfigReq), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset); - CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset); - CsrUint16Des((u16 *) &primitive->trafficConfigType, buffer, &offset); - CsrUint16Des((u16 *) &primitive->config.packetFilter, buffer, &offset); - CsrUint32Des((u32 *) &primitive->config.customFilter.etherType, buffer, &offset); - CsrUint8Des((u8 *) &primitive->config.customFilter.ipType, buffer, &offset); - CsrUint32Des((u32 *) &primitive->config.customFilter.udpSourcePort, buffer, &offset); - CsrUint32Des((u32 *) &primitive->config.customFilter.udpDestPort, buffer, &offset); - - return primitive; -} - - -size_t CsrWifiRouterCtrlWifiOnReqSizeof(void *msg) -{ - CsrWifiRouterCtrlWifiOnReq *primitive = (CsrWifiRouterCtrlWifiOnReq *) msg; - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 10) */ - bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */ - bufferSize += 4; /* u32 primitive->dataLength */ - bufferSize += primitive->dataLength; /* u8 primitive->data */ - return bufferSize; -} - - -u8* CsrWifiRouterCtrlWifiOnReqSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiRouterCtrlWifiOnReq *primitive = (CsrWifiRouterCtrlWifiOnReq *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->clientData); - CsrUint32Ser(ptr, len, (u32) primitive->dataLength); - if (primitive->dataLength) - { - CsrMemCpySer(ptr, len, (const void *) primitive->data, ((u16) (primitive->dataLength))); - } - return(ptr); -} - - -void* CsrWifiRouterCtrlWifiOnReqDes(u8 *buffer, size_t length) -{ - CsrWifiRouterCtrlWifiOnReq *primitive = kmalloc(sizeof(CsrWifiRouterCtrlWifiOnReq), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset); - CsrUint32Des((u32 *) &primitive->dataLength, buffer, &offset); - if (primitive->dataLength) - { - primitive->data = kmalloc(primitive->dataLength, GFP_KERNEL); - CsrMemCpyDes(primitive->data, buffer, &offset, ((u16) (primitive->dataLength))); - } - else - { - primitive->data = NULL; - } - - return primitive; -} - - -void CsrWifiRouterCtrlWifiOnReqSerFree(void *voidPrimitivePointer) -{ - CsrWifiRouterCtrlWifiOnReq *primitive = (CsrWifiRouterCtrlWifiOnReq *) voidPrimitivePointer; - kfree(primitive->data); - kfree(primitive); -} - - -size_t CsrWifiRouterCtrlWifiOnResSizeof(void *msg) -{ - CsrWifiRouterCtrlWifiOnRes *primitive = (CsrWifiRouterCtrlWifiOnRes *) msg; - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 30) */ - bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */ - bufferSize += 2; /* CsrResult primitive->status */ - bufferSize += 2; /* u16 primitive->numInterfaceAddress */ - { - u16 i1; - for (i1 = 0; i1 < 2; i1++) - { - bufferSize += 6; /* u8 primitive->stationMacAddress[i1].a[6] */ - } - } - bufferSize += 4; /* u32 primitive->smeVersions.firmwarePatch */ - bufferSize += (primitive->smeVersions.smeBuild ? strlen(primitive->smeVersions.smeBuild) : 0) + 1; /* char* primitive->smeVersions.smeBuild (0 byte len + 1 for NULL Term) */ - bufferSize += 4; /* u32 primitive->smeVersions.smeHip */ - bufferSize += 1; /* u8 primitive->scheduledInterrupt */ - return bufferSize; -} - - -u8* CsrWifiRouterCtrlWifiOnResSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiRouterCtrlWifiOnRes *primitive = (CsrWifiRouterCtrlWifiOnRes *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->clientData); - CsrUint16Ser(ptr, len, (u16) primitive->status); - CsrUint16Ser(ptr, len, (u16) primitive->numInterfaceAddress); - { - u16 i1; - for (i1 = 0; i1 < 2; i1++) - { - CsrMemCpySer(ptr, len, (const void *) primitive->stationMacAddress[i1].a, ((u16) (6))); - } - } - CsrUint32Ser(ptr, len, (u32) primitive->smeVersions.firmwarePatch); - CsrCharStringSer(ptr, len, primitive->smeVersions.smeBuild); - CsrUint32Ser(ptr, len, (u32) primitive->smeVersions.smeHip); - CsrUint8Ser(ptr, len, (u8) primitive->scheduledInterrupt); - return(ptr); -} - - -void* CsrWifiRouterCtrlWifiOnResDes(u8 *buffer, size_t length) -{ - CsrWifiRouterCtrlWifiOnRes *primitive = kmalloc(sizeof(CsrWifiRouterCtrlWifiOnRes), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset); - CsrUint16Des((u16 *) &primitive->status, buffer, &offset); - CsrUint16Des((u16 *) &primitive->numInterfaceAddress, buffer, &offset); - { - u16 i1; - for (i1 = 0; i1 < 2; i1++) - { - CsrMemCpyDes(primitive->stationMacAddress[i1].a, buffer, &offset, ((u16) (6))); - } - } - CsrUint32Des((u32 *) &primitive->smeVersions.firmwarePatch, buffer, &offset); - CsrCharStringDes(&primitive->smeVersions.smeBuild, buffer, &offset); - CsrUint32Des((u32 *) &primitive->smeVersions.smeHip, buffer, &offset); - CsrUint8Des((u8 *) &primitive->scheduledInterrupt, buffer, &offset); - - return primitive; -} - - -void CsrWifiRouterCtrlWifiOnResSerFree(void *voidPrimitivePointer) -{ - CsrWifiRouterCtrlWifiOnRes *primitive = (CsrWifiRouterCtrlWifiOnRes *) voidPrimitivePointer; - kfree(primitive->smeVersions.smeBuild); - kfree(primitive); -} - - -size_t CsrWifiRouterCtrlM4TransmitReqSizeof(void *msg) -{ - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 7) */ - bufferSize += 2; /* u16 primitive->interfaceTag */ - bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */ - return bufferSize; -} - - -u8* CsrWifiRouterCtrlM4TransmitReqSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiRouterCtrlM4TransmitReq *primitive = (CsrWifiRouterCtrlM4TransmitReq *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag); - CsrUint16Ser(ptr, len, (u16) primitive->clientData); - return(ptr); -} - - -void* CsrWifiRouterCtrlM4TransmitReqDes(u8 *buffer, size_t length) -{ - CsrWifiRouterCtrlM4TransmitReq *primitive = kmalloc(sizeof(CsrWifiRouterCtrlM4TransmitReq), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset); - CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset); - - return primitive; -} - - -size_t CsrWifiRouterCtrlModeSetReqSizeof(void *msg) -{ - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 16) */ - bufferSize += 2; /* u16 primitive->interfaceTag */ - bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */ - bufferSize += 1; /* CsrWifiRouterCtrlMode primitive->mode */ - bufferSize += 6; /* u8 primitive->bssid.a[6] */ - bufferSize += 1; /* u8 primitive->protection */ - bufferSize += 1; /* u8 primitive->intraBssDistEnabled */ - return bufferSize; -} - - -u8* CsrWifiRouterCtrlModeSetReqSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiRouterCtrlModeSetReq *primitive = (CsrWifiRouterCtrlModeSetReq *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag); - CsrUint16Ser(ptr, len, (u16) primitive->clientData); - CsrUint8Ser(ptr, len, (u8) primitive->mode); - CsrMemCpySer(ptr, len, (const void *) primitive->bssid.a, ((u16) (6))); - CsrUint8Ser(ptr, len, (u8) primitive->protection); - CsrUint8Ser(ptr, len, (u8) primitive->intraBssDistEnabled); - return(ptr); -} - - -void* CsrWifiRouterCtrlModeSetReqDes(u8 *buffer, size_t length) -{ - CsrWifiRouterCtrlModeSetReq *primitive = kmalloc(sizeof(CsrWifiRouterCtrlModeSetReq), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset); - CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset); - CsrUint8Des((u8 *) &primitive->mode, buffer, &offset); - CsrMemCpyDes(primitive->bssid.a, buffer, &offset, ((u16) (6))); - CsrUint8Des((u8 *) &primitive->protection, buffer, &offset); - CsrUint8Des((u8 *) &primitive->intraBssDistEnabled, buffer, &offset); - - return primitive; -} - - -size_t CsrWifiRouterCtrlPeerAddReqSizeof(void *msg) -{ - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 21) */ - bufferSize += 2; /* u16 primitive->interfaceTag */ - bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */ - bufferSize += 6; /* u8 primitive->peerMacAddress.a[6] */ - bufferSize += 2; /* u16 primitive->associationId */ - bufferSize += 1; /* u8 primitive->staInfo.wmmOrQosEnabled */ - bufferSize += 2; /* CsrWifiRouterCtrlPowersaveTypeMask primitive->staInfo.powersaveMode */ - bufferSize += 1; /* u8 primitive->staInfo.maxSpLength */ - bufferSize += 2; /* u16 primitive->staInfo.listenIntervalInTus */ - return bufferSize; -} - - -u8* CsrWifiRouterCtrlPeerAddReqSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiRouterCtrlPeerAddReq *primitive = (CsrWifiRouterCtrlPeerAddReq *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag); - CsrUint16Ser(ptr, len, (u16) primitive->clientData); - CsrMemCpySer(ptr, len, (const void *) primitive->peerMacAddress.a, ((u16) (6))); - CsrUint16Ser(ptr, len, (u16) primitive->associationId); - CsrUint8Ser(ptr, len, (u8) primitive->staInfo.wmmOrQosEnabled); - CsrUint16Ser(ptr, len, (u16) primitive->staInfo.powersaveMode); - CsrUint8Ser(ptr, len, (u8) primitive->staInfo.maxSpLength); - CsrUint16Ser(ptr, len, (u16) primitive->staInfo.listenIntervalInTus); - return(ptr); -} - - -void* CsrWifiRouterCtrlPeerAddReqDes(u8 *buffer, size_t length) -{ - CsrWifiRouterCtrlPeerAddReq *primitive = kmalloc(sizeof(CsrWifiRouterCtrlPeerAddReq), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset); - CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset); - CsrMemCpyDes(primitive->peerMacAddress.a, buffer, &offset, ((u16) (6))); - CsrUint16Des((u16 *) &primitive->associationId, buffer, &offset); - CsrUint8Des((u8 *) &primitive->staInfo.wmmOrQosEnabled, buffer, &offset); - CsrUint16Des((u16 *) &primitive->staInfo.powersaveMode, buffer, &offset); - CsrUint8Des((u8 *) &primitive->staInfo.maxSpLength, buffer, &offset); - CsrUint16Des((u16 *) &primitive->staInfo.listenIntervalInTus, buffer, &offset); - - return primitive; -} - - -size_t CsrWifiRouterCtrlPeerDelReqSizeof(void *msg) -{ - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 11) */ - bufferSize += 2; /* u16 primitive->interfaceTag */ - bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */ - bufferSize += 4; /* CsrWifiRouterCtrlPeerRecordHandle primitive->peerRecordHandle */ - return bufferSize; -} - - -u8* CsrWifiRouterCtrlPeerDelReqSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiRouterCtrlPeerDelReq *primitive = (CsrWifiRouterCtrlPeerDelReq *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag); - CsrUint16Ser(ptr, len, (u16) primitive->clientData); - CsrUint32Ser(ptr, len, (u32) primitive->peerRecordHandle); - return(ptr); -} - - -void* CsrWifiRouterCtrlPeerDelReqDes(u8 *buffer, size_t length) -{ - CsrWifiRouterCtrlPeerDelReq *primitive = kmalloc(sizeof(CsrWifiRouterCtrlPeerDelReq), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset); - CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset); - CsrUint32Des((u32 *) &primitive->peerRecordHandle, buffer, &offset); - - return primitive; -} - - -size_t CsrWifiRouterCtrlPeerUpdateReqSizeof(void *msg) -{ - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 13) */ - bufferSize += 2; /* u16 primitive->interfaceTag */ - bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */ - bufferSize += 4; /* CsrWifiRouterCtrlPeerRecordHandle primitive->peerRecordHandle */ - bufferSize += 2; /* CsrWifiRouterCtrlPowersaveTypeMask primitive->powersaveMode */ - return bufferSize; -} - - -u8* CsrWifiRouterCtrlPeerUpdateReqSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiRouterCtrlPeerUpdateReq *primitive = (CsrWifiRouterCtrlPeerUpdateReq *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag); - CsrUint16Ser(ptr, len, (u16) primitive->clientData); - CsrUint32Ser(ptr, len, (u32) primitive->peerRecordHandle); - CsrUint16Ser(ptr, len, (u16) primitive->powersaveMode); - return(ptr); -} - - -void* CsrWifiRouterCtrlPeerUpdateReqDes(u8 *buffer, size_t length) -{ - CsrWifiRouterCtrlPeerUpdateReq *primitive = kmalloc(sizeof(CsrWifiRouterCtrlPeerUpdateReq), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset); - CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset); - CsrUint32Des((u32 *) &primitive->peerRecordHandle, buffer, &offset); - CsrUint16Des((u16 *) &primitive->powersaveMode, buffer, &offset); - - return primitive; -} - - -size_t CsrWifiRouterCtrlBlockAckEnableReqSizeof(void *msg) -{ - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 21) */ - bufferSize += 2; /* u16 primitive->interfaceTag */ - bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */ - bufferSize += 6; /* u8 primitive->macAddress.a[6] */ - bufferSize += 1; /* CsrWifiRouterCtrlTrafficStreamId primitive->trafficStreamID */ - bufferSize += 1; /* CsrWifiRouterCtrlBlockAckRole primitive->role */ - bufferSize += 2; /* u16 primitive->bufferSize */ - bufferSize += 2; /* u16 primitive->timeout */ - bufferSize += 2; /* u16 primitive->ssn */ - return bufferSize; -} - - -u8* CsrWifiRouterCtrlBlockAckEnableReqSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiRouterCtrlBlockAckEnableReq *primitive = (CsrWifiRouterCtrlBlockAckEnableReq *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag); - CsrUint16Ser(ptr, len, (u16) primitive->clientData); - CsrMemCpySer(ptr, len, (const void *) primitive->macAddress.a, ((u16) (6))); - CsrUint8Ser(ptr, len, (u8) primitive->trafficStreamID); - CsrUint8Ser(ptr, len, (u8) primitive->role); - CsrUint16Ser(ptr, len, (u16) primitive->bufferSize); - CsrUint16Ser(ptr, len, (u16) primitive->timeout); - CsrUint16Ser(ptr, len, (u16) primitive->ssn); - return(ptr); -} - - -void* CsrWifiRouterCtrlBlockAckEnableReqDes(u8 *buffer, size_t length) -{ - CsrWifiRouterCtrlBlockAckEnableReq *primitive = kmalloc(sizeof(CsrWifiRouterCtrlBlockAckEnableReq), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset); - CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset); - CsrMemCpyDes(primitive->macAddress.a, buffer, &offset, ((u16) (6))); - CsrUint8Des((u8 *) &primitive->trafficStreamID, buffer, &offset); - CsrUint8Des((u8 *) &primitive->role, buffer, &offset); - CsrUint16Des((u16 *) &primitive->bufferSize, buffer, &offset); - CsrUint16Des((u16 *) &primitive->timeout, buffer, &offset); - CsrUint16Des((u16 *) &primitive->ssn, buffer, &offset); - - return primitive; -} - - -size_t CsrWifiRouterCtrlBlockAckDisableReqSizeof(void *msg) -{ - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 15) */ - bufferSize += 2; /* u16 primitive->interfaceTag */ - bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */ - bufferSize += 6; /* u8 primitive->macAddress.a[6] */ - bufferSize += 1; /* CsrWifiRouterCtrlTrafficStreamId primitive->trafficStreamID */ - bufferSize += 1; /* CsrWifiRouterCtrlBlockAckRole primitive->role */ - return bufferSize; -} - - -u8* CsrWifiRouterCtrlBlockAckDisableReqSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiRouterCtrlBlockAckDisableReq *primitive = (CsrWifiRouterCtrlBlockAckDisableReq *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag); - CsrUint16Ser(ptr, len, (u16) primitive->clientData); - CsrMemCpySer(ptr, len, (const void *) primitive->macAddress.a, ((u16) (6))); - CsrUint8Ser(ptr, len, (u8) primitive->trafficStreamID); - CsrUint8Ser(ptr, len, (u8) primitive->role); - return(ptr); -} - - -void* CsrWifiRouterCtrlBlockAckDisableReqDes(u8 *buffer, size_t length) -{ - CsrWifiRouterCtrlBlockAckDisableReq *primitive = kmalloc(sizeof(CsrWifiRouterCtrlBlockAckDisableReq), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset); - CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset); - CsrMemCpyDes(primitive->macAddress.a, buffer, &offset, ((u16) (6))); - CsrUint8Des((u8 *) &primitive->trafficStreamID, buffer, &offset); - CsrUint8Des((u8 *) &primitive->role, buffer, &offset); - - return primitive; -} - - -size_t CsrWifiRouterCtrlWapiRxPktReqSizeof(void *msg) -{ - CsrWifiRouterCtrlWapiRxPktReq *primitive = (CsrWifiRouterCtrlWapiRxPktReq *) msg; - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 11) */ - bufferSize += 2; /* u16 primitive->interfaceTag */ - bufferSize += 2; /* u16 primitive->signalLength */ - bufferSize += primitive->signalLength; /* u8 primitive->signal */ - bufferSize += 2; /* u16 primitive->dataLength */ - bufferSize += primitive->dataLength; /* u8 primitive->data */ - return bufferSize; -} - - -u8* CsrWifiRouterCtrlWapiRxPktReqSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiRouterCtrlWapiRxPktReq *primitive = (CsrWifiRouterCtrlWapiRxPktReq *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag); - CsrUint16Ser(ptr, len, (u16) primitive->signalLength); - if (primitive->signalLength) - { - CsrMemCpySer(ptr, len, (const void *) primitive->signal, ((u16) (primitive->signalLength))); - } - CsrUint16Ser(ptr, len, (u16) primitive->dataLength); - if (primitive->dataLength) - { - CsrMemCpySer(ptr, len, (const void *) primitive->data, ((u16) (primitive->dataLength))); - } - return(ptr); -} - - -void* CsrWifiRouterCtrlWapiRxPktReqDes(u8 *buffer, size_t length) -{ - CsrWifiRouterCtrlWapiRxPktReq *primitive = kmalloc(sizeof(CsrWifiRouterCtrlWapiRxPktReq), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset); - CsrUint16Des((u16 *) &primitive->signalLength, buffer, &offset); - if (primitive->signalLength) - { - primitive->signal = kmalloc(primitive->signalLength, GFP_KERNEL); - CsrMemCpyDes(primitive->signal, buffer, &offset, ((u16) (primitive->signalLength))); - } - else - { - primitive->signal = NULL; - } - CsrUint16Des((u16 *) &primitive->dataLength, buffer, &offset); - if (primitive->dataLength) - { - primitive->data = kmalloc(primitive->dataLength, GFP_KERNEL); - CsrMemCpyDes(primitive->data, buffer, &offset, ((u16) (primitive->dataLength))); - } - else - { - primitive->data = NULL; - } - - return primitive; -} - - -void CsrWifiRouterCtrlWapiRxPktReqSerFree(void *voidPrimitivePointer) -{ - CsrWifiRouterCtrlWapiRxPktReq *primitive = (CsrWifiRouterCtrlWapiRxPktReq *) voidPrimitivePointer; - kfree(primitive->signal); - kfree(primitive->data); - kfree(primitive); -} - - -size_t CsrWifiRouterCtrlWapiUnicastTxPktReqSizeof(void *msg) -{ - CsrWifiRouterCtrlWapiUnicastTxPktReq *primitive = (CsrWifiRouterCtrlWapiUnicastTxPktReq *) msg; - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 8) */ - bufferSize += 2; /* u16 primitive->interfaceTag */ - bufferSize += 2; /* u16 primitive->dataLength */ - bufferSize += primitive->dataLength; /* u8 primitive->data */ - return bufferSize; -} - - -u8* CsrWifiRouterCtrlWapiUnicastTxPktReqSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiRouterCtrlWapiUnicastTxPktReq *primitive = (CsrWifiRouterCtrlWapiUnicastTxPktReq *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag); - CsrUint16Ser(ptr, len, (u16) primitive->dataLength); - if (primitive->dataLength) - { - CsrMemCpySer(ptr, len, (const void *) primitive->data, ((u16) (primitive->dataLength))); - } - return(ptr); -} - - -void* CsrWifiRouterCtrlWapiUnicastTxPktReqDes(u8 *buffer, size_t length) -{ - CsrWifiRouterCtrlWapiUnicastTxPktReq *primitive = kmalloc(sizeof(CsrWifiRouterCtrlWapiUnicastTxPktReq), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset); - CsrUint16Des((u16 *) &primitive->dataLength, buffer, &offset); - if (primitive->dataLength) - { - primitive->data = kmalloc(primitive->dataLength, GFP_KERNEL); - CsrMemCpyDes(primitive->data, buffer, &offset, ((u16) (primitive->dataLength))); - } - else - { - primitive->data = NULL; - } - - return primitive; -} - - -void CsrWifiRouterCtrlWapiUnicastTxPktReqSerFree(void *voidPrimitivePointer) -{ - CsrWifiRouterCtrlWapiUnicastTxPktReq *primitive = (CsrWifiRouterCtrlWapiUnicastTxPktReq *) voidPrimitivePointer; - kfree(primitive->data); - kfree(primitive); -} - - -size_t CsrWifiRouterCtrlHipIndSizeof(void *msg) -{ - CsrWifiRouterCtrlHipInd *primitive = (CsrWifiRouterCtrlHipInd *) msg; - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 12) */ - bufferSize += 2; /* u16 primitive->mlmeCommandLength */ - bufferSize += primitive->mlmeCommandLength; /* u8 primitive->mlmeCommand */ - bufferSize += 2; /* u16 primitive->dataRef1Length */ - bufferSize += primitive->dataRef1Length; /* u8 primitive->dataRef1 */ - bufferSize += 2; /* u16 primitive->dataRef2Length */ - bufferSize += primitive->dataRef2Length; /* u8 primitive->dataRef2 */ - return bufferSize; -} - - -u8* CsrWifiRouterCtrlHipIndSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiRouterCtrlHipInd *primitive = (CsrWifiRouterCtrlHipInd *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->mlmeCommandLength); - if (primitive->mlmeCommandLength) - { - CsrMemCpySer(ptr, len, (const void *) primitive->mlmeCommand, ((u16) (primitive->mlmeCommandLength))); - } - CsrUint16Ser(ptr, len, (u16) primitive->dataRef1Length); - if (primitive->dataRef1Length) - { - CsrMemCpySer(ptr, len, (const void *) primitive->dataRef1, ((u16) (primitive->dataRef1Length))); - } - CsrUint16Ser(ptr, len, (u16) primitive->dataRef2Length); - if (primitive->dataRef2Length) - { - CsrMemCpySer(ptr, len, (const void *) primitive->dataRef2, ((u16) (primitive->dataRef2Length))); - } - return(ptr); -} - - -void* CsrWifiRouterCtrlHipIndDes(u8 *buffer, size_t length) -{ - CsrWifiRouterCtrlHipInd *primitive = kmalloc(sizeof(CsrWifiRouterCtrlHipInd), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->mlmeCommandLength, buffer, &offset); - if (primitive->mlmeCommandLength) - { - primitive->mlmeCommand = kmalloc(primitive->mlmeCommandLength, GFP_KERNEL); - CsrMemCpyDes(primitive->mlmeCommand, buffer, &offset, ((u16) (primitive->mlmeCommandLength))); - } - else - { - primitive->mlmeCommand = NULL; - } - CsrUint16Des((u16 *) &primitive->dataRef1Length, buffer, &offset); - if (primitive->dataRef1Length) - { - primitive->dataRef1 = kmalloc(primitive->dataRef1Length, GFP_KERNEL); - CsrMemCpyDes(primitive->dataRef1, buffer, &offset, ((u16) (primitive->dataRef1Length))); - } - else - { - primitive->dataRef1 = NULL; - } - CsrUint16Des((u16 *) &primitive->dataRef2Length, buffer, &offset); - if (primitive->dataRef2Length) - { - primitive->dataRef2 = kmalloc(primitive->dataRef2Length, GFP_KERNEL); - CsrMemCpyDes(primitive->dataRef2, buffer, &offset, ((u16) (primitive->dataRef2Length))); - } - else - { - primitive->dataRef2 = NULL; - } - - return primitive; -} - - -void CsrWifiRouterCtrlHipIndSerFree(void *voidPrimitivePointer) -{ - CsrWifiRouterCtrlHipInd *primitive = (CsrWifiRouterCtrlHipInd *) voidPrimitivePointer; - kfree(primitive->mlmeCommand); - kfree(primitive->dataRef1); - kfree(primitive->dataRef2); - kfree(primitive); -} - - -size_t CsrWifiRouterCtrlMulticastAddressIndSizeof(void *msg) -{ - CsrWifiRouterCtrlMulticastAddressInd *primitive = (CsrWifiRouterCtrlMulticastAddressInd *) msg; - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 15) */ - bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */ - bufferSize += 2; /* u16 primitive->interfaceTag */ - bufferSize += 1; /* CsrWifiRouterCtrlListAction primitive->action */ - bufferSize += 1; /* u8 primitive->setAddressesCount */ - { - u16 i1; - for (i1 = 0; i1 < primitive->setAddressesCount; i1++) - { - bufferSize += 6; /* u8 primitive->setAddresses[i1].a[6] */ - } - } - return bufferSize; -} - - -u8* CsrWifiRouterCtrlMulticastAddressIndSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiRouterCtrlMulticastAddressInd *primitive = (CsrWifiRouterCtrlMulticastAddressInd *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->clientData); - CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag); - CsrUint8Ser(ptr, len, (u8) primitive->action); - CsrUint8Ser(ptr, len, (u8) primitive->setAddressesCount); - { - u16 i1; - for (i1 = 0; i1 < primitive->setAddressesCount; i1++) - { - CsrMemCpySer(ptr, len, (const void *) primitive->setAddresses[i1].a, ((u16) (6))); - } - } - return(ptr); -} - - -void* CsrWifiRouterCtrlMulticastAddressIndDes(u8 *buffer, size_t length) -{ - CsrWifiRouterCtrlMulticastAddressInd *primitive = kmalloc(sizeof(CsrWifiRouterCtrlMulticastAddressInd), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset); - CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset); - CsrUint8Des((u8 *) &primitive->action, buffer, &offset); - CsrUint8Des((u8 *) &primitive->setAddressesCount, buffer, &offset); - primitive->setAddresses = NULL; - if (primitive->setAddressesCount) - { - primitive->setAddresses = kmalloc(sizeof(CsrWifiMacAddress) * primitive->setAddressesCount, GFP_KERNEL); - } - { - u16 i1; - for (i1 = 0; i1 < primitive->setAddressesCount; i1++) - { - CsrMemCpyDes(primitive->setAddresses[i1].a, buffer, &offset, ((u16) (6))); - } - } - - return primitive; -} - - -void CsrWifiRouterCtrlMulticastAddressIndSerFree(void *voidPrimitivePointer) -{ - CsrWifiRouterCtrlMulticastAddressInd *primitive = (CsrWifiRouterCtrlMulticastAddressInd *) voidPrimitivePointer; - kfree(primitive->setAddresses); - kfree(primitive); -} - - -size_t CsrWifiRouterCtrlPortConfigureCfmSizeof(void *msg) -{ - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 15) */ - bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */ - bufferSize += 2; /* u16 primitive->interfaceTag */ - bufferSize += 2; /* CsrResult primitive->status */ - bufferSize += 6; /* u8 primitive->macAddress.a[6] */ - return bufferSize; -} - - -u8* CsrWifiRouterCtrlPortConfigureCfmSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiRouterCtrlPortConfigureCfm *primitive = (CsrWifiRouterCtrlPortConfigureCfm *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->clientData); - CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag); - CsrUint16Ser(ptr, len, (u16) primitive->status); - CsrMemCpySer(ptr, len, (const void *) primitive->macAddress.a, ((u16) (6))); - return(ptr); -} - - -void* CsrWifiRouterCtrlPortConfigureCfmDes(u8 *buffer, size_t length) -{ - CsrWifiRouterCtrlPortConfigureCfm *primitive = kmalloc(sizeof(CsrWifiRouterCtrlPortConfigureCfm), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset); - CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset); - CsrUint16Des((u16 *) &primitive->status, buffer, &offset); - CsrMemCpyDes(primitive->macAddress.a, buffer, &offset, ((u16) (6))); - - return primitive; -} - - -size_t CsrWifiRouterCtrlSuspendIndSizeof(void *msg) -{ - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 7) */ - bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */ - bufferSize += 1; /* u8 primitive->hardSuspend */ - bufferSize += 1; /* u8 primitive->d3Suspend */ - return bufferSize; -} - - -u8* CsrWifiRouterCtrlSuspendIndSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiRouterCtrlSuspendInd *primitive = (CsrWifiRouterCtrlSuspendInd *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->clientData); - CsrUint8Ser(ptr, len, (u8) primitive->hardSuspend); - CsrUint8Ser(ptr, len, (u8) primitive->d3Suspend); - return(ptr); -} - - -void* CsrWifiRouterCtrlSuspendIndDes(u8 *buffer, size_t length) -{ - CsrWifiRouterCtrlSuspendInd *primitive = kmalloc(sizeof(CsrWifiRouterCtrlSuspendInd), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset); - CsrUint8Des((u8 *) &primitive->hardSuspend, buffer, &offset); - CsrUint8Des((u8 *) &primitive->d3Suspend, buffer, &offset); - - return primitive; -} - - -size_t CsrWifiRouterCtrlTclasAddCfmSizeof(void *msg) -{ - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 9) */ - bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */ - bufferSize += 2; /* u16 primitive->interfaceTag */ - bufferSize += 2; /* CsrResult primitive->status */ - return bufferSize; -} - - -u8* CsrWifiRouterCtrlTclasAddCfmSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiRouterCtrlTclasAddCfm *primitive = (CsrWifiRouterCtrlTclasAddCfm *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->clientData); - CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag); - CsrUint16Ser(ptr, len, (u16) primitive->status); - return(ptr); -} - - -void* CsrWifiRouterCtrlTclasAddCfmDes(u8 *buffer, size_t length) -{ - CsrWifiRouterCtrlTclasAddCfm *primitive = kmalloc(sizeof(CsrWifiRouterCtrlTclasAddCfm), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset); - CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset); - CsrUint16Des((u16 *) &primitive->status, buffer, &offset); - - return primitive; -} - - -size_t CsrWifiRouterCtrlRawSdioDeinitialiseCfmSizeof(void *msg) -{ - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 7) */ - bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */ - bufferSize += 2; /* CsrResult primitive->result */ - return bufferSize; -} - - -u8* CsrWifiRouterCtrlRawSdioDeinitialiseCfmSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiRouterCtrlRawSdioDeinitialiseCfm *primitive = (CsrWifiRouterCtrlRawSdioDeinitialiseCfm *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->clientData); - CsrUint16Ser(ptr, len, (u16) primitive->result); - return(ptr); -} - - -void* CsrWifiRouterCtrlRawSdioDeinitialiseCfmDes(u8 *buffer, size_t length) -{ - CsrWifiRouterCtrlRawSdioDeinitialiseCfm *primitive = kmalloc(sizeof(CsrWifiRouterCtrlRawSdioDeinitialiseCfm), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset); - CsrUint16Des((u16 *) &primitive->result, buffer, &offset); - - return primitive; -} - - -size_t CsrWifiRouterCtrlRawSdioInitialiseCfmSizeof(void *msg) -{ - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 39) */ - bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */ - bufferSize += 2; /* CsrResult primitive->result */ - bufferSize += 4; /* CsrWifiRouterCtrlRawSdioByteRead primitive->byteRead */ - bufferSize += 4; /* CsrWifiRouterCtrlRawSdioByteWrite primitive->byteWrite */ - bufferSize += 4; /* CsrWifiRouterCtrlRawSdioFirmwareDownload primitive->firmwareDownload */ - bufferSize += 4; /* CsrWifiRouterCtrlRawSdioReset primitive->reset */ - bufferSize += 4; /* CsrWifiRouterCtrlRawSdioCoreDumpPrepare primitive->coreDumpPrepare */ - bufferSize += 4; /* CsrWifiRouterCtrlRawSdioByteBlockRead primitive->byteBlockRead */ - bufferSize += 4; /* CsrWifiRouterCtrlRawSdioGpRead16 primitive->gpRead16 */ - bufferSize += 4; /* CsrWifiRouterCtrlRawSdioGpWrite16 primitive->gpWrite16 */ - return bufferSize; -} - - -u8* CsrWifiRouterCtrlRawSdioInitialiseCfmSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiRouterCtrlRawSdioInitialiseCfm *primitive = (CsrWifiRouterCtrlRawSdioInitialiseCfm *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->clientData); - CsrUint16Ser(ptr, len, (u16) primitive->result); - CsrUint32Ser(ptr, len, 0); /* Special for Function Pointers... primitive->byteRead */ - CsrUint32Ser(ptr, len, 0); /* Special for Function Pointers... primitive->byteWrite */ - CsrUint32Ser(ptr, len, 0); /* Special for Function Pointers... primitive->firmwareDownload */ - CsrUint32Ser(ptr, len, 0); /* Special for Function Pointers... primitive->reset */ - CsrUint32Ser(ptr, len, 0); /* Special for Function Pointers... primitive->coreDumpPrepare */ - CsrUint32Ser(ptr, len, 0); /* Special for Function Pointers... primitive->byteBlockRead */ - CsrUint32Ser(ptr, len, 0); /* Special for Function Pointers... primitive->gpRead16 */ - CsrUint32Ser(ptr, len, 0); /* Special for Function Pointers... primitive->gpWrite16 */ - return(ptr); -} - - -void* CsrWifiRouterCtrlRawSdioInitialiseCfmDes(u8 *buffer, size_t length) -{ - CsrWifiRouterCtrlRawSdioInitialiseCfm *primitive = kmalloc(sizeof(CsrWifiRouterCtrlRawSdioInitialiseCfm), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset); - CsrUint16Des((u16 *) &primitive->result, buffer, &offset); - primitive->byteRead = NULL; /* Special for Function Pointers... */ - offset += 4; - primitive->byteWrite = NULL; /* Special for Function Pointers... */ - offset += 4; - primitive->firmwareDownload = NULL; /* Special for Function Pointers... */ - offset += 4; - primitive->reset = NULL; /* Special for Function Pointers... */ - offset += 4; - primitive->coreDumpPrepare = NULL; /* Special for Function Pointers... */ - offset += 4; - primitive->byteBlockRead = NULL; /* Special for Function Pointers... */ - offset += 4; - primitive->gpRead16 = NULL; /* Special for Function Pointers... */ - offset += 4; - primitive->gpWrite16 = NULL; /* Special for Function Pointers... */ - offset += 4; - - return primitive; -} - - -size_t CsrWifiRouterCtrlTclasDelCfmSizeof(void *msg) -{ - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 9) */ - bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */ - bufferSize += 2; /* u16 primitive->interfaceTag */ - bufferSize += 2; /* CsrResult primitive->status */ - return bufferSize; -} - - -u8* CsrWifiRouterCtrlTclasDelCfmSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiRouterCtrlTclasDelCfm *primitive = (CsrWifiRouterCtrlTclasDelCfm *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->clientData); - CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag); - CsrUint16Ser(ptr, len, (u16) primitive->status); - return(ptr); -} - - -void* CsrWifiRouterCtrlTclasDelCfmDes(u8 *buffer, size_t length) -{ - CsrWifiRouterCtrlTclasDelCfm *primitive = kmalloc(sizeof(CsrWifiRouterCtrlTclasDelCfm), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset); - CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset); - CsrUint16Des((u16 *) &primitive->status, buffer, &offset); - - return primitive; -} - - -size_t CsrWifiRouterCtrlTrafficProtocolIndSizeof(void *msg) -{ - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 17) */ - bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */ - bufferSize += 2; /* u16 primitive->interfaceTag */ - bufferSize += 2; /* CsrWifiRouterCtrlTrafficPacketType primitive->packetType */ - bufferSize += 2; /* CsrWifiRouterCtrlProtocolDirection primitive->direction */ - bufferSize += 6; /* u8 primitive->srcAddress.a[6] */ - return bufferSize; -} - - -u8* CsrWifiRouterCtrlTrafficProtocolIndSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiRouterCtrlTrafficProtocolInd *primitive = (CsrWifiRouterCtrlTrafficProtocolInd *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->clientData); - CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag); - CsrUint16Ser(ptr, len, (u16) primitive->packetType); - CsrUint16Ser(ptr, len, (u16) primitive->direction); - CsrMemCpySer(ptr, len, (const void *) primitive->srcAddress.a, ((u16) (6))); - return(ptr); -} - - -void* CsrWifiRouterCtrlTrafficProtocolIndDes(u8 *buffer, size_t length) -{ - CsrWifiRouterCtrlTrafficProtocolInd *primitive = kmalloc(sizeof(CsrWifiRouterCtrlTrafficProtocolInd), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset); - CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset); - CsrUint16Des((u16 *) &primitive->packetType, buffer, &offset); - CsrUint16Des((u16 *) &primitive->direction, buffer, &offset); - CsrMemCpyDes(primitive->srcAddress.a, buffer, &offset, ((u16) (6))); - - return primitive; -} - - -size_t CsrWifiRouterCtrlTrafficSampleIndSizeof(void *msg) -{ - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 38) */ - bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */ - bufferSize += 2; /* u16 primitive->interfaceTag */ - bufferSize += 4; /* u32 primitive->stats.rxMeanRate */ - bufferSize += 4; /* u32 primitive->stats.rxFramesNum */ - bufferSize += 4; /* u32 primitive->stats.txFramesNum */ - bufferSize += 4; /* u32 primitive->stats.rxBytesCount */ - bufferSize += 4; /* u32 primitive->stats.txBytesCount */ - bufferSize += 11; /* u8 primitive->stats.intervals[11] */ - return bufferSize; -} - - -u8* CsrWifiRouterCtrlTrafficSampleIndSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiRouterCtrlTrafficSampleInd *primitive = (CsrWifiRouterCtrlTrafficSampleInd *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->clientData); - CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag); - CsrUint32Ser(ptr, len, (u32) primitive->stats.rxMeanRate); - CsrUint32Ser(ptr, len, (u32) primitive->stats.rxFramesNum); - CsrUint32Ser(ptr, len, (u32) primitive->stats.txFramesNum); - CsrUint32Ser(ptr, len, (u32) primitive->stats.rxBytesCount); - CsrUint32Ser(ptr, len, (u32) primitive->stats.txBytesCount); - CsrMemCpySer(ptr, len, (const void *) primitive->stats.intervals, ((u16) (11))); - return(ptr); -} - - -void* CsrWifiRouterCtrlTrafficSampleIndDes(u8 *buffer, size_t length) -{ - CsrWifiRouterCtrlTrafficSampleInd *primitive = kmalloc(sizeof(CsrWifiRouterCtrlTrafficSampleInd), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset); - CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset); - CsrUint32Des((u32 *) &primitive->stats.rxMeanRate, buffer, &offset); - CsrUint32Des((u32 *) &primitive->stats.rxFramesNum, buffer, &offset); - CsrUint32Des((u32 *) &primitive->stats.txFramesNum, buffer, &offset); - CsrUint32Des((u32 *) &primitive->stats.rxBytesCount, buffer, &offset); - CsrUint32Des((u32 *) &primitive->stats.txBytesCount, buffer, &offset); - CsrMemCpyDes(primitive->stats.intervals, buffer, &offset, ((u16) (11))); - - return primitive; -} - - -size_t CsrWifiRouterCtrlWifiOnIndSizeof(void *msg) -{ - CsrWifiRouterCtrlWifiOnInd *primitive = (CsrWifiRouterCtrlWifiOnInd *) msg; - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 27) */ - bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */ - bufferSize += 2; /* CsrResult primitive->status */ - bufferSize += 4; /* u32 primitive->versions.chipId */ - bufferSize += 4; /* u32 primitive->versions.chipVersion */ - bufferSize += 4; /* u32 primitive->versions.firmwareBuild */ - bufferSize += 4; /* u32 primitive->versions.firmwareHip */ - bufferSize += (primitive->versions.routerBuild ? strlen(primitive->versions.routerBuild) : 0) + 1; /* char* primitive->versions.routerBuild (0 byte len + 1 for NULL Term) */ - bufferSize += 4; /* u32 primitive->versions.routerHip */ - return bufferSize; -} - - -u8* CsrWifiRouterCtrlWifiOnIndSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiRouterCtrlWifiOnInd *primitive = (CsrWifiRouterCtrlWifiOnInd *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->clientData); - CsrUint16Ser(ptr, len, (u16) primitive->status); - CsrUint32Ser(ptr, len, (u32) primitive->versions.chipId); - CsrUint32Ser(ptr, len, (u32) primitive->versions.chipVersion); - CsrUint32Ser(ptr, len, (u32) primitive->versions.firmwareBuild); - CsrUint32Ser(ptr, len, (u32) primitive->versions.firmwareHip); - CsrCharStringSer(ptr, len, primitive->versions.routerBuild); - CsrUint32Ser(ptr, len, (u32) primitive->versions.routerHip); - return(ptr); -} - - -void* CsrWifiRouterCtrlWifiOnIndDes(u8 *buffer, size_t length) -{ - CsrWifiRouterCtrlWifiOnInd *primitive = kmalloc(sizeof(CsrWifiRouterCtrlWifiOnInd), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset); - CsrUint16Des((u16 *) &primitive->status, buffer, &offset); - CsrUint32Des((u32 *) &primitive->versions.chipId, buffer, &offset); - CsrUint32Des((u32 *) &primitive->versions.chipVersion, buffer, &offset); - CsrUint32Des((u32 *) &primitive->versions.firmwareBuild, buffer, &offset); - CsrUint32Des((u32 *) &primitive->versions.firmwareHip, buffer, &offset); - CsrCharStringDes(&primitive->versions.routerBuild, buffer, &offset); - CsrUint32Des((u32 *) &primitive->versions.routerHip, buffer, &offset); - - return primitive; -} - - -void CsrWifiRouterCtrlWifiOnIndSerFree(void *voidPrimitivePointer) -{ - CsrWifiRouterCtrlWifiOnInd *primitive = (CsrWifiRouterCtrlWifiOnInd *) voidPrimitivePointer; - kfree(primitive->versions.routerBuild); - kfree(primitive); -} - - -size_t CsrWifiRouterCtrlWifiOnCfmSizeof(void *msg) -{ - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 7) */ - bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */ - bufferSize += 2; /* CsrResult primitive->status */ - return bufferSize; -} - - -u8* CsrWifiRouterCtrlWifiOnCfmSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiRouterCtrlWifiOnCfm *primitive = (CsrWifiRouterCtrlWifiOnCfm *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->clientData); - CsrUint16Ser(ptr, len, (u16) primitive->status); - return(ptr); -} - - -void* CsrWifiRouterCtrlWifiOnCfmDes(u8 *buffer, size_t length) -{ - CsrWifiRouterCtrlWifiOnCfm *primitive = kmalloc(sizeof(CsrWifiRouterCtrlWifiOnCfm), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset); - CsrUint16Des((u16 *) &primitive->status, buffer, &offset); - - return primitive; -} - - -size_t CsrWifiRouterCtrlM4ReadyToSendIndSizeof(void *msg) -{ - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 13) */ - bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */ - bufferSize += 2; /* u16 primitive->interfaceTag */ - bufferSize += 6; /* u8 primitive->peerMacAddress.a[6] */ - return bufferSize; -} - - -u8* CsrWifiRouterCtrlM4ReadyToSendIndSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiRouterCtrlM4ReadyToSendInd *primitive = (CsrWifiRouterCtrlM4ReadyToSendInd *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->clientData); - CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag); - CsrMemCpySer(ptr, len, (const void *) primitive->peerMacAddress.a, ((u16) (6))); - return(ptr); -} - - -void* CsrWifiRouterCtrlM4ReadyToSendIndDes(u8 *buffer, size_t length) -{ - CsrWifiRouterCtrlM4ReadyToSendInd *primitive = kmalloc(sizeof(CsrWifiRouterCtrlM4ReadyToSendInd), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset); - CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset); - CsrMemCpyDes(primitive->peerMacAddress.a, buffer, &offset, ((u16) (6))); - - return primitive; -} - - -size_t CsrWifiRouterCtrlM4TransmittedIndSizeof(void *msg) -{ - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 15) */ - bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */ - bufferSize += 2; /* u16 primitive->interfaceTag */ - bufferSize += 6; /* u8 primitive->peerMacAddress.a[6] */ - bufferSize += 2; /* CsrResult primitive->status */ - return bufferSize; -} - - -u8* CsrWifiRouterCtrlM4TransmittedIndSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiRouterCtrlM4TransmittedInd *primitive = (CsrWifiRouterCtrlM4TransmittedInd *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->clientData); - CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag); - CsrMemCpySer(ptr, len, (const void *) primitive->peerMacAddress.a, ((u16) (6))); - CsrUint16Ser(ptr, len, (u16) primitive->status); - return(ptr); -} - - -void* CsrWifiRouterCtrlM4TransmittedIndDes(u8 *buffer, size_t length) -{ - CsrWifiRouterCtrlM4TransmittedInd *primitive = kmalloc(sizeof(CsrWifiRouterCtrlM4TransmittedInd), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset); - CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset); - CsrMemCpyDes(primitive->peerMacAddress.a, buffer, &offset, ((u16) (6))); - CsrUint16Des((u16 *) &primitive->status, buffer, &offset); - - return primitive; -} - - -size_t CsrWifiRouterCtrlMicFailureIndSizeof(void *msg) -{ - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 14) */ - bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */ - bufferSize += 2; /* u16 primitive->interfaceTag */ - bufferSize += 6; /* u8 primitive->peerMacAddress.a[6] */ - bufferSize += 1; /* u8 primitive->unicastPdu */ - return bufferSize; -} - - -u8* CsrWifiRouterCtrlMicFailureIndSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiRouterCtrlMicFailureInd *primitive = (CsrWifiRouterCtrlMicFailureInd *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->clientData); - CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag); - CsrMemCpySer(ptr, len, (const void *) primitive->peerMacAddress.a, ((u16) (6))); - CsrUint8Ser(ptr, len, (u8) primitive->unicastPdu); - return(ptr); -} - - -void* CsrWifiRouterCtrlMicFailureIndDes(u8 *buffer, size_t length) -{ - CsrWifiRouterCtrlMicFailureInd *primitive = kmalloc(sizeof(CsrWifiRouterCtrlMicFailureInd), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset); - CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset); - CsrMemCpyDes(primitive->peerMacAddress.a, buffer, &offset, ((u16) (6))); - CsrUint8Des((u8 *) &primitive->unicastPdu, buffer, &offset); - - return primitive; -} - - -size_t CsrWifiRouterCtrlConnectedIndSizeof(void *msg) -{ - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 14) */ - bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */ - bufferSize += 2; /* u16 primitive->interfaceTag */ - bufferSize += 6; /* u8 primitive->peerMacAddress.a[6] */ - bufferSize += 1; /* CsrWifiRouterCtrlPeerStatus primitive->peerStatus */ - return bufferSize; -} - - -u8* CsrWifiRouterCtrlConnectedIndSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiRouterCtrlConnectedInd *primitive = (CsrWifiRouterCtrlConnectedInd *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->clientData); - CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag); - CsrMemCpySer(ptr, len, (const void *) primitive->peerMacAddress.a, ((u16) (6))); - CsrUint8Ser(ptr, len, (u8) primitive->peerStatus); - return(ptr); -} - - -void* CsrWifiRouterCtrlConnectedIndDes(u8 *buffer, size_t length) -{ - CsrWifiRouterCtrlConnectedInd *primitive = kmalloc(sizeof(CsrWifiRouterCtrlConnectedInd), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset); - CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset); - CsrMemCpyDes(primitive->peerMacAddress.a, buffer, &offset, ((u16) (6))); - CsrUint8Des((u8 *) &primitive->peerStatus, buffer, &offset); - - return primitive; -} - - -size_t CsrWifiRouterCtrlPeerAddCfmSizeof(void *msg) -{ - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 19) */ - bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */ - bufferSize += 2; /* u16 primitive->interfaceTag */ - bufferSize += 6; /* u8 primitive->peerMacAddress.a[6] */ - bufferSize += 4; /* CsrWifiRouterCtrlPeerRecordHandle primitive->peerRecordHandle */ - bufferSize += 2; /* CsrResult primitive->status */ - return bufferSize; -} - - -u8* CsrWifiRouterCtrlPeerAddCfmSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiRouterCtrlPeerAddCfm *primitive = (CsrWifiRouterCtrlPeerAddCfm *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->clientData); - CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag); - CsrMemCpySer(ptr, len, (const void *) primitive->peerMacAddress.a, ((u16) (6))); - CsrUint32Ser(ptr, len, (u32) primitive->peerRecordHandle); - CsrUint16Ser(ptr, len, (u16) primitive->status); - return(ptr); -} - - -void* CsrWifiRouterCtrlPeerAddCfmDes(u8 *buffer, size_t length) -{ - CsrWifiRouterCtrlPeerAddCfm *primitive = kmalloc(sizeof(CsrWifiRouterCtrlPeerAddCfm), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset); - CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset); - CsrMemCpyDes(primitive->peerMacAddress.a, buffer, &offset, ((u16) (6))); - CsrUint32Des((u32 *) &primitive->peerRecordHandle, buffer, &offset); - CsrUint16Des((u16 *) &primitive->status, buffer, &offset); - - return primitive; -} - - -size_t CsrWifiRouterCtrlPeerDelCfmSizeof(void *msg) -{ - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 9) */ - bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */ - bufferSize += 2; /* u16 primitive->interfaceTag */ - bufferSize += 2; /* CsrResult primitive->status */ - return bufferSize; -} - - -u8* CsrWifiRouterCtrlPeerDelCfmSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiRouterCtrlPeerDelCfm *primitive = (CsrWifiRouterCtrlPeerDelCfm *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->clientData); - CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag); - CsrUint16Ser(ptr, len, (u16) primitive->status); - return(ptr); -} - - -void* CsrWifiRouterCtrlPeerDelCfmDes(u8 *buffer, size_t length) -{ - CsrWifiRouterCtrlPeerDelCfm *primitive = kmalloc(sizeof(CsrWifiRouterCtrlPeerDelCfm), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset); - CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset); - CsrUint16Des((u16 *) &primitive->status, buffer, &offset); - - return primitive; -} - - -size_t CsrWifiRouterCtrlUnexpectedFrameIndSizeof(void *msg) -{ - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 13) */ - bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */ - bufferSize += 2; /* u16 primitive->interfaceTag */ - bufferSize += 6; /* u8 primitive->peerMacAddress.a[6] */ - return bufferSize; -} - - -u8* CsrWifiRouterCtrlUnexpectedFrameIndSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiRouterCtrlUnexpectedFrameInd *primitive = (CsrWifiRouterCtrlUnexpectedFrameInd *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->clientData); - CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag); - CsrMemCpySer(ptr, len, (const void *) primitive->peerMacAddress.a, ((u16) (6))); - return(ptr); -} - - -void* CsrWifiRouterCtrlUnexpectedFrameIndDes(u8 *buffer, size_t length) -{ - CsrWifiRouterCtrlUnexpectedFrameInd *primitive = kmalloc(sizeof(CsrWifiRouterCtrlUnexpectedFrameInd), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset); - CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset); - CsrMemCpyDes(primitive->peerMacAddress.a, buffer, &offset, ((u16) (6))); - - return primitive; -} - - -size_t CsrWifiRouterCtrlPeerUpdateCfmSizeof(void *msg) -{ - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 9) */ - bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */ - bufferSize += 2; /* u16 primitive->interfaceTag */ - bufferSize += 2; /* CsrResult primitive->status */ - return bufferSize; -} - - -u8* CsrWifiRouterCtrlPeerUpdateCfmSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiRouterCtrlPeerUpdateCfm *primitive = (CsrWifiRouterCtrlPeerUpdateCfm *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->clientData); - CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag); - CsrUint16Ser(ptr, len, (u16) primitive->status); - return(ptr); -} - - -void* CsrWifiRouterCtrlPeerUpdateCfmDes(u8 *buffer, size_t length) -{ - CsrWifiRouterCtrlPeerUpdateCfm *primitive = kmalloc(sizeof(CsrWifiRouterCtrlPeerUpdateCfm), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset); - CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset); - CsrUint16Des((u16 *) &primitive->status, buffer, &offset); - - return primitive; -} - - -size_t CsrWifiRouterCtrlCapabilitiesCfmSizeof(void *msg) -{ - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 9) */ - bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */ - bufferSize += 2; /* u16 primitive->commandQueueSize */ - bufferSize += 2; /* u16 primitive->trafficQueueSize */ - return bufferSize; -} - - -u8* CsrWifiRouterCtrlCapabilitiesCfmSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiRouterCtrlCapabilitiesCfm *primitive = (CsrWifiRouterCtrlCapabilitiesCfm *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->clientData); - CsrUint16Ser(ptr, len, (u16) primitive->commandQueueSize); - CsrUint16Ser(ptr, len, (u16) primitive->trafficQueueSize); - return(ptr); -} - - -void* CsrWifiRouterCtrlCapabilitiesCfmDes(u8 *buffer, size_t length) -{ - CsrWifiRouterCtrlCapabilitiesCfm *primitive = kmalloc(sizeof(CsrWifiRouterCtrlCapabilitiesCfm), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset); - CsrUint16Des((u16 *) &primitive->commandQueueSize, buffer, &offset); - CsrUint16Des((u16 *) &primitive->trafficQueueSize, buffer, &offset); - - return primitive; -} - - -size_t CsrWifiRouterCtrlBlockAckEnableCfmSizeof(void *msg) -{ - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 9) */ - bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */ - bufferSize += 2; /* u16 primitive->interfaceTag */ - bufferSize += 2; /* CsrResult primitive->status */ - return bufferSize; -} - - -u8* CsrWifiRouterCtrlBlockAckEnableCfmSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiRouterCtrlBlockAckEnableCfm *primitive = (CsrWifiRouterCtrlBlockAckEnableCfm *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->clientData); - CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag); - CsrUint16Ser(ptr, len, (u16) primitive->status); - return(ptr); -} - - -void* CsrWifiRouterCtrlBlockAckEnableCfmDes(u8 *buffer, size_t length) -{ - CsrWifiRouterCtrlBlockAckEnableCfm *primitive = kmalloc(sizeof(CsrWifiRouterCtrlBlockAckEnableCfm), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset); - CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset); - CsrUint16Des((u16 *) &primitive->status, buffer, &offset); - - return primitive; -} - - -size_t CsrWifiRouterCtrlBlockAckDisableCfmSizeof(void *msg) -{ - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 9) */ - bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */ - bufferSize += 2; /* u16 primitive->interfaceTag */ - bufferSize += 2; /* CsrResult primitive->status */ - return bufferSize; -} - - -u8* CsrWifiRouterCtrlBlockAckDisableCfmSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiRouterCtrlBlockAckDisableCfm *primitive = (CsrWifiRouterCtrlBlockAckDisableCfm *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->clientData); - CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag); - CsrUint16Ser(ptr, len, (u16) primitive->status); - return(ptr); -} - - -void* CsrWifiRouterCtrlBlockAckDisableCfmDes(u8 *buffer, size_t length) -{ - CsrWifiRouterCtrlBlockAckDisableCfm *primitive = kmalloc(sizeof(CsrWifiRouterCtrlBlockAckDisableCfm), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset); - CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset); - CsrUint16Des((u16 *) &primitive->status, buffer, &offset); - - return primitive; -} - - -size_t CsrWifiRouterCtrlBlockAckErrorIndSizeof(void *msg) -{ - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 16) */ - bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */ - bufferSize += 2; /* u16 primitive->interfaceTag */ - bufferSize += 1; /* CsrWifiRouterCtrlTrafficStreamId primitive->trafficStreamID */ - bufferSize += 6; /* u8 primitive->peerMacAddress.a[6] */ - bufferSize += 2; /* CsrResult primitive->status */ - return bufferSize; -} - - -u8* CsrWifiRouterCtrlBlockAckErrorIndSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiRouterCtrlBlockAckErrorInd *primitive = (CsrWifiRouterCtrlBlockAckErrorInd *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->clientData); - CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag); - CsrUint8Ser(ptr, len, (u8) primitive->trafficStreamID); - CsrMemCpySer(ptr, len, (const void *) primitive->peerMacAddress.a, ((u16) (6))); - CsrUint16Ser(ptr, len, (u16) primitive->status); - return(ptr); -} - - -void* CsrWifiRouterCtrlBlockAckErrorIndDes(u8 *buffer, size_t length) -{ - CsrWifiRouterCtrlBlockAckErrorInd *primitive = kmalloc(sizeof(CsrWifiRouterCtrlBlockAckErrorInd), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset); - CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset); - CsrUint8Des((u8 *) &primitive->trafficStreamID, buffer, &offset); - CsrMemCpyDes(primitive->peerMacAddress.a, buffer, &offset, ((u16) (6))); - CsrUint16Des((u16 *) &primitive->status, buffer, &offset); - - return primitive; -} - - -size_t CsrWifiRouterCtrlStaInactiveIndSizeof(void *msg) -{ - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 13) */ - bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */ - bufferSize += 2; /* u16 primitive->interfaceTag */ - bufferSize += 6; /* u8 primitive->staAddress.a[6] */ - return bufferSize; -} - - -u8* CsrWifiRouterCtrlStaInactiveIndSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiRouterCtrlStaInactiveInd *primitive = (CsrWifiRouterCtrlStaInactiveInd *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->clientData); - CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag); - CsrMemCpySer(ptr, len, (const void *) primitive->staAddress.a, ((u16) (6))); - return(ptr); -} - - -void* CsrWifiRouterCtrlStaInactiveIndDes(u8 *buffer, size_t length) -{ - CsrWifiRouterCtrlStaInactiveInd *primitive = kmalloc(sizeof(CsrWifiRouterCtrlStaInactiveInd), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset); - CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset); - CsrMemCpyDes(primitive->staAddress.a, buffer, &offset, ((u16) (6))); - - return primitive; -} - - -size_t CsrWifiRouterCtrlWapiRxMicCheckIndSizeof(void *msg) -{ - CsrWifiRouterCtrlWapiRxMicCheckInd *primitive = (CsrWifiRouterCtrlWapiRxMicCheckInd *) msg; - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 13) */ - bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */ - bufferSize += 2; /* u16 primitive->interfaceTag */ - bufferSize += 2; /* u16 primitive->signalLength */ - bufferSize += primitive->signalLength; /* u8 primitive->signal */ - bufferSize += 2; /* u16 primitive->dataLength */ - bufferSize += primitive->dataLength; /* u8 primitive->data */ - return bufferSize; -} - - -u8* CsrWifiRouterCtrlWapiRxMicCheckIndSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiRouterCtrlWapiRxMicCheckInd *primitive = (CsrWifiRouterCtrlWapiRxMicCheckInd *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->clientData); - CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag); - CsrUint16Ser(ptr, len, (u16) primitive->signalLength); - if (primitive->signalLength) - { - CsrMemCpySer(ptr, len, (const void *) primitive->signal, ((u16) (primitive->signalLength))); - } - CsrUint16Ser(ptr, len, (u16) primitive->dataLength); - if (primitive->dataLength) - { - CsrMemCpySer(ptr, len, (const void *) primitive->data, ((u16) (primitive->dataLength))); - } - return(ptr); -} - - -void* CsrWifiRouterCtrlWapiRxMicCheckIndDes(u8 *buffer, size_t length) -{ - CsrWifiRouterCtrlWapiRxMicCheckInd *primitive = kmalloc(sizeof(CsrWifiRouterCtrlWapiRxMicCheckInd), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset); - CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset); - CsrUint16Des((u16 *) &primitive->signalLength, buffer, &offset); - if (primitive->signalLength) - { - primitive->signal = kmalloc(primitive->signalLength, GFP_KERNEL); - CsrMemCpyDes(primitive->signal, buffer, &offset, ((u16) (primitive->signalLength))); - } - else - { - primitive->signal = NULL; - } - CsrUint16Des((u16 *) &primitive->dataLength, buffer, &offset); - if (primitive->dataLength) - { - primitive->data = kmalloc(primitive->dataLength, GFP_KERNEL); - CsrMemCpyDes(primitive->data, buffer, &offset, ((u16) (primitive->dataLength))); - } - else - { - primitive->data = NULL; - } - - return primitive; -} - - -void CsrWifiRouterCtrlWapiRxMicCheckIndSerFree(void *voidPrimitivePointer) -{ - CsrWifiRouterCtrlWapiRxMicCheckInd *primitive = (CsrWifiRouterCtrlWapiRxMicCheckInd *) voidPrimitivePointer; - kfree(primitive->signal); - kfree(primitive->data); - kfree(primitive); -} - - -size_t CsrWifiRouterCtrlModeSetCfmSizeof(void *msg) -{ - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 10) */ - bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */ - bufferSize += 2; /* u16 primitive->interfaceTag */ - bufferSize += 1; /* CsrWifiRouterCtrlMode primitive->mode */ - bufferSize += 2; /* CsrResult primitive->status */ - return bufferSize; -} - - -u8* CsrWifiRouterCtrlModeSetCfmSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiRouterCtrlModeSetCfm *primitive = (CsrWifiRouterCtrlModeSetCfm *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->clientData); - CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag); - CsrUint8Ser(ptr, len, (u8) primitive->mode); - CsrUint16Ser(ptr, len, (u16) primitive->status); - return(ptr); -} - - -void* CsrWifiRouterCtrlModeSetCfmDes(u8 *buffer, size_t length) -{ - CsrWifiRouterCtrlModeSetCfm *primitive = kmalloc(sizeof(CsrWifiRouterCtrlModeSetCfm), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset); - CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset); - CsrUint8Des((u8 *) &primitive->mode, buffer, &offset); - CsrUint16Des((u16 *) &primitive->status, buffer, &offset); - - return primitive; -} - - -size_t CsrWifiRouterCtrlWapiUnicastTxEncryptIndSizeof(void *msg) -{ - CsrWifiRouterCtrlWapiUnicastTxEncryptInd *primitive = (CsrWifiRouterCtrlWapiUnicastTxEncryptInd *) msg; - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 10) */ - bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */ - bufferSize += 2; /* u16 primitive->interfaceTag */ - bufferSize += 2; /* u16 primitive->dataLength */ - bufferSize += primitive->dataLength; /* u8 primitive->data */ - return bufferSize; -} - - -u8* CsrWifiRouterCtrlWapiUnicastTxEncryptIndSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiRouterCtrlWapiUnicastTxEncryptInd *primitive = (CsrWifiRouterCtrlWapiUnicastTxEncryptInd *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->clientData); - CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag); - CsrUint16Ser(ptr, len, (u16) primitive->dataLength); - if (primitive->dataLength) - { - CsrMemCpySer(ptr, len, (const void *) primitive->data, ((u16) (primitive->dataLength))); - } - return(ptr); -} - - -void* CsrWifiRouterCtrlWapiUnicastTxEncryptIndDes(u8 *buffer, size_t length) -{ - CsrWifiRouterCtrlWapiUnicastTxEncryptInd *primitive = kmalloc(sizeof(CsrWifiRouterCtrlWapiUnicastTxEncryptInd), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset); - CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset); - CsrUint16Des((u16 *) &primitive->dataLength, buffer, &offset); - if (primitive->dataLength) - { - primitive->data = kmalloc(primitive->dataLength, GFP_KERNEL); - CsrMemCpyDes(primitive->data, buffer, &offset, ((u16) (primitive->dataLength))); - } - else - { - primitive->data = NULL; - } - - return primitive; -} - - -void CsrWifiRouterCtrlWapiUnicastTxEncryptIndSerFree(void *voidPrimitivePointer) -{ - CsrWifiRouterCtrlWapiUnicastTxEncryptInd *primitive = (CsrWifiRouterCtrlWapiUnicastTxEncryptInd *) voidPrimitivePointer; - kfree(primitive->data); - kfree(primitive); -} - - diff --git a/drivers/staging/csr/csr_wifi_router_ctrl_serialize.h b/drivers/staging/csr/csr_wifi_router_ctrl_serialize.h deleted file mode 100644 index c9048386cfcb..000000000000 --- a/drivers/staging/csr/csr_wifi_router_ctrl_serialize.h +++ /dev/null @@ -1,333 +0,0 @@ -/***************************************************************************** - - (c) Cambridge Silicon Radio Limited 2012 - All rights reserved and confidential information of CSR - - Refer to LICENSE.txt included with this source for details - on the license terms. - -*****************************************************************************/ - -/* Note: this is an auto-generated file. */ - -#ifndef CSR_WIFI_ROUTER_CTRL_SERIALIZE_H__ -#define CSR_WIFI_ROUTER_CTRL_SERIALIZE_H__ - -#include "csr_wifi_msgconv.h" - -#include "csr_wifi_router_ctrl_prim.h" - -extern void CsrWifiRouterCtrlPfree(void *ptr); - -extern u8* CsrWifiRouterCtrlConfigurePowerModeReqSer(u8 *ptr, size_t *len, void *msg); -extern void* CsrWifiRouterCtrlConfigurePowerModeReqDes(u8 *buffer, size_t len); -extern size_t CsrWifiRouterCtrlConfigurePowerModeReqSizeof(void *msg); -#define CsrWifiRouterCtrlConfigurePowerModeReqSerFree CsrWifiRouterCtrlPfree - -extern u8* CsrWifiRouterCtrlHipReqSer(u8 *ptr, size_t *len, void *msg); -extern void* CsrWifiRouterCtrlHipReqDes(u8 *buffer, size_t len); -extern size_t CsrWifiRouterCtrlHipReqSizeof(void *msg); -extern void CsrWifiRouterCtrlHipReqSerFree(void *msg); - -extern u8* CsrWifiRouterCtrlMediaStatusReqSer(u8 *ptr, size_t *len, void *msg); -extern void* CsrWifiRouterCtrlMediaStatusReqDes(u8 *buffer, size_t len); -extern size_t CsrWifiRouterCtrlMediaStatusReqSizeof(void *msg); -#define CsrWifiRouterCtrlMediaStatusReqSerFree CsrWifiRouterCtrlPfree - -extern u8* CsrWifiRouterCtrlMulticastAddressResSer(u8 *ptr, size_t *len, void *msg); -extern void* CsrWifiRouterCtrlMulticastAddressResDes(u8 *buffer, size_t len); -extern size_t CsrWifiRouterCtrlMulticastAddressResSizeof(void *msg); -extern void CsrWifiRouterCtrlMulticastAddressResSerFree(void *msg); - -extern u8* CsrWifiRouterCtrlPortConfigureReqSer(u8 *ptr, size_t *len, void *msg); -extern void* CsrWifiRouterCtrlPortConfigureReqDes(u8 *buffer, size_t len); -extern size_t CsrWifiRouterCtrlPortConfigureReqSizeof(void *msg); -#define CsrWifiRouterCtrlPortConfigureReqSerFree CsrWifiRouterCtrlPfree - -extern u8* CsrWifiRouterCtrlQosControlReqSer(u8 *ptr, size_t *len, void *msg); -extern void* CsrWifiRouterCtrlQosControlReqDes(u8 *buffer, size_t len); -extern size_t CsrWifiRouterCtrlQosControlReqSizeof(void *msg); -#define CsrWifiRouterCtrlQosControlReqSerFree CsrWifiRouterCtrlPfree - -extern u8* CsrWifiRouterCtrlSuspendResSer(u8 *ptr, size_t *len, void *msg); -extern void* CsrWifiRouterCtrlSuspendResDes(u8 *buffer, size_t len); -extern size_t CsrWifiRouterCtrlSuspendResSizeof(void *msg); -#define CsrWifiRouterCtrlSuspendResSerFree CsrWifiRouterCtrlPfree - -extern u8* CsrWifiRouterCtrlTclasAddReqSer(u8 *ptr, size_t *len, void *msg); -extern void* CsrWifiRouterCtrlTclasAddReqDes(u8 *buffer, size_t len); -extern size_t CsrWifiRouterCtrlTclasAddReqSizeof(void *msg); -extern void CsrWifiRouterCtrlTclasAddReqSerFree(void *msg); - -extern u8* CsrWifiRouterCtrlResumeResSer(u8 *ptr, size_t *len, void *msg); -extern void* CsrWifiRouterCtrlResumeResDes(u8 *buffer, size_t len); -extern size_t CsrWifiRouterCtrlResumeResSizeof(void *msg); -#define CsrWifiRouterCtrlResumeResSerFree CsrWifiRouterCtrlPfree - -#define CsrWifiRouterCtrlRawSdioDeinitialiseReqSer CsrWifiEventCsrUint16Ser -#define CsrWifiRouterCtrlRawSdioDeinitialiseReqDes CsrWifiEventCsrUint16Des -#define CsrWifiRouterCtrlRawSdioDeinitialiseReqSizeof CsrWifiEventCsrUint16Sizeof -#define CsrWifiRouterCtrlRawSdioDeinitialiseReqSerFree CsrWifiRouterCtrlPfree - -#define CsrWifiRouterCtrlRawSdioInitialiseReqSer CsrWifiEventCsrUint16Ser -#define CsrWifiRouterCtrlRawSdioInitialiseReqDes CsrWifiEventCsrUint16Des -#define CsrWifiRouterCtrlRawSdioInitialiseReqSizeof CsrWifiEventCsrUint16Sizeof -#define CsrWifiRouterCtrlRawSdioInitialiseReqSerFree CsrWifiRouterCtrlPfree - -extern u8* CsrWifiRouterCtrlTclasDelReqSer(u8 *ptr, size_t *len, void *msg); -extern void* CsrWifiRouterCtrlTclasDelReqDes(u8 *buffer, size_t len); -extern size_t CsrWifiRouterCtrlTclasDelReqSizeof(void *msg); -extern void CsrWifiRouterCtrlTclasDelReqSerFree(void *msg); - -extern u8* CsrWifiRouterCtrlTrafficClassificationReqSer(u8 *ptr, size_t *len, void *msg); -extern void* CsrWifiRouterCtrlTrafficClassificationReqDes(u8 *buffer, size_t len); -extern size_t CsrWifiRouterCtrlTrafficClassificationReqSizeof(void *msg); -#define CsrWifiRouterCtrlTrafficClassificationReqSerFree CsrWifiRouterCtrlPfree - -extern u8* CsrWifiRouterCtrlTrafficConfigReqSer(u8 *ptr, size_t *len, void *msg); -extern void* CsrWifiRouterCtrlTrafficConfigReqDes(u8 *buffer, size_t len); -extern size_t CsrWifiRouterCtrlTrafficConfigReqSizeof(void *msg); -#define CsrWifiRouterCtrlTrafficConfigReqSerFree CsrWifiRouterCtrlPfree - -#define CsrWifiRouterCtrlWifiOffReqSer CsrWifiEventCsrUint16Ser -#define CsrWifiRouterCtrlWifiOffReqDes CsrWifiEventCsrUint16Des -#define CsrWifiRouterCtrlWifiOffReqSizeof CsrWifiEventCsrUint16Sizeof -#define CsrWifiRouterCtrlWifiOffReqSerFree CsrWifiRouterCtrlPfree - -#define CsrWifiRouterCtrlWifiOffResSer CsrWifiEventCsrUint16Ser -#define CsrWifiRouterCtrlWifiOffResDes CsrWifiEventCsrUint16Des -#define CsrWifiRouterCtrlWifiOffResSizeof CsrWifiEventCsrUint16Sizeof -#define CsrWifiRouterCtrlWifiOffResSerFree CsrWifiRouterCtrlPfree - -extern u8* CsrWifiRouterCtrlWifiOnReqSer(u8 *ptr, size_t *len, void *msg); -extern void* CsrWifiRouterCtrlWifiOnReqDes(u8 *buffer, size_t len); -extern size_t CsrWifiRouterCtrlWifiOnReqSizeof(void *msg); -extern void CsrWifiRouterCtrlWifiOnReqSerFree(void *msg); - -extern u8* CsrWifiRouterCtrlWifiOnResSer(u8 *ptr, size_t *len, void *msg); -extern void* CsrWifiRouterCtrlWifiOnResDes(u8 *buffer, size_t len); -extern size_t CsrWifiRouterCtrlWifiOnResSizeof(void *msg); -extern void CsrWifiRouterCtrlWifiOnResSerFree(void *msg); - -extern u8* CsrWifiRouterCtrlM4TransmitReqSer(u8 *ptr, size_t *len, void *msg); -extern void* CsrWifiRouterCtrlM4TransmitReqDes(u8 *buffer, size_t len); -extern size_t CsrWifiRouterCtrlM4TransmitReqSizeof(void *msg); -#define CsrWifiRouterCtrlM4TransmitReqSerFree CsrWifiRouterCtrlPfree - -extern u8* CsrWifiRouterCtrlModeSetReqSer(u8 *ptr, size_t *len, void *msg); -extern void* CsrWifiRouterCtrlModeSetReqDes(u8 *buffer, size_t len); -extern size_t CsrWifiRouterCtrlModeSetReqSizeof(void *msg); -#define CsrWifiRouterCtrlModeSetReqSerFree CsrWifiRouterCtrlPfree - -extern u8* CsrWifiRouterCtrlPeerAddReqSer(u8 *ptr, size_t *len, void *msg); -extern void* CsrWifiRouterCtrlPeerAddReqDes(u8 *buffer, size_t len); -extern size_t CsrWifiRouterCtrlPeerAddReqSizeof(void *msg); -#define CsrWifiRouterCtrlPeerAddReqSerFree CsrWifiRouterCtrlPfree - -extern u8* CsrWifiRouterCtrlPeerDelReqSer(u8 *ptr, size_t *len, void *msg); -extern void* CsrWifiRouterCtrlPeerDelReqDes(u8 *buffer, size_t len); -extern size_t CsrWifiRouterCtrlPeerDelReqSizeof(void *msg); -#define CsrWifiRouterCtrlPeerDelReqSerFree CsrWifiRouterCtrlPfree - -extern u8* CsrWifiRouterCtrlPeerUpdateReqSer(u8 *ptr, size_t *len, void *msg); -extern void* CsrWifiRouterCtrlPeerUpdateReqDes(u8 *buffer, size_t len); -extern size_t CsrWifiRouterCtrlPeerUpdateReqSizeof(void *msg); -#define CsrWifiRouterCtrlPeerUpdateReqSerFree CsrWifiRouterCtrlPfree - -#define CsrWifiRouterCtrlCapabilitiesReqSer CsrWifiEventCsrUint16Ser -#define CsrWifiRouterCtrlCapabilitiesReqDes CsrWifiEventCsrUint16Des -#define CsrWifiRouterCtrlCapabilitiesReqSizeof CsrWifiEventCsrUint16Sizeof -#define CsrWifiRouterCtrlCapabilitiesReqSerFree CsrWifiRouterCtrlPfree - -extern u8* CsrWifiRouterCtrlBlockAckEnableReqSer(u8 *ptr, size_t *len, void *msg); -extern void* CsrWifiRouterCtrlBlockAckEnableReqDes(u8 *buffer, size_t len); -extern size_t CsrWifiRouterCtrlBlockAckEnableReqSizeof(void *msg); -#define CsrWifiRouterCtrlBlockAckEnableReqSerFree CsrWifiRouterCtrlPfree - -extern u8* CsrWifiRouterCtrlBlockAckDisableReqSer(u8 *ptr, size_t *len, void *msg); -extern void* CsrWifiRouterCtrlBlockAckDisableReqDes(u8 *buffer, size_t len); -extern size_t CsrWifiRouterCtrlBlockAckDisableReqSizeof(void *msg); -#define CsrWifiRouterCtrlBlockAckDisableReqSerFree CsrWifiRouterCtrlPfree - -extern u8* CsrWifiRouterCtrlWapiRxPktReqSer(u8 *ptr, size_t *len, void *msg); -extern void* CsrWifiRouterCtrlWapiRxPktReqDes(u8 *buffer, size_t len); -extern size_t CsrWifiRouterCtrlWapiRxPktReqSizeof(void *msg); -extern void CsrWifiRouterCtrlWapiRxPktReqSerFree(void *msg); - -#define CsrWifiRouterCtrlWapiMulticastFilterReqSer CsrWifiEventCsrUint16CsrUint8Ser -#define CsrWifiRouterCtrlWapiMulticastFilterReqDes CsrWifiEventCsrUint16CsrUint8Des -#define CsrWifiRouterCtrlWapiMulticastFilterReqSizeof CsrWifiEventCsrUint16CsrUint8Sizeof -#define CsrWifiRouterCtrlWapiMulticastFilterReqSerFree CsrWifiRouterCtrlPfree - -#define CsrWifiRouterCtrlWapiUnicastFilterReqSer CsrWifiEventCsrUint16CsrUint8Ser -#define CsrWifiRouterCtrlWapiUnicastFilterReqDes CsrWifiEventCsrUint16CsrUint8Des -#define CsrWifiRouterCtrlWapiUnicastFilterReqSizeof CsrWifiEventCsrUint16CsrUint8Sizeof -#define CsrWifiRouterCtrlWapiUnicastFilterReqSerFree CsrWifiRouterCtrlPfree - -extern u8* CsrWifiRouterCtrlWapiUnicastTxPktReqSer(u8 *ptr, size_t *len, void *msg); -extern void* CsrWifiRouterCtrlWapiUnicastTxPktReqDes(u8 *buffer, size_t len); -extern size_t CsrWifiRouterCtrlWapiUnicastTxPktReqSizeof(void *msg); -extern void CsrWifiRouterCtrlWapiUnicastTxPktReqSerFree(void *msg); - -#define CsrWifiRouterCtrlWapiFilterReqSer CsrWifiEventCsrUint16CsrUint8Ser -#define CsrWifiRouterCtrlWapiFilterReqDes CsrWifiEventCsrUint16CsrUint8Des -#define CsrWifiRouterCtrlWapiFilterReqSizeof CsrWifiEventCsrUint16CsrUint8Sizeof -#define CsrWifiRouterCtrlWapiFilterReqSerFree CsrWifiRouterCtrlPfree - -extern u8* CsrWifiRouterCtrlHipIndSer(u8 *ptr, size_t *len, void *msg); -extern void* CsrWifiRouterCtrlHipIndDes(u8 *buffer, size_t len); -extern size_t CsrWifiRouterCtrlHipIndSizeof(void *msg); -extern void CsrWifiRouterCtrlHipIndSerFree(void *msg); - -extern u8* CsrWifiRouterCtrlMulticastAddressIndSer(u8 *ptr, size_t *len, void *msg); -extern void* CsrWifiRouterCtrlMulticastAddressIndDes(u8 *buffer, size_t len); -extern size_t CsrWifiRouterCtrlMulticastAddressIndSizeof(void *msg); -extern void CsrWifiRouterCtrlMulticastAddressIndSerFree(void *msg); - -extern u8* CsrWifiRouterCtrlPortConfigureCfmSer(u8 *ptr, size_t *len, void *msg); -extern void* CsrWifiRouterCtrlPortConfigureCfmDes(u8 *buffer, size_t len); -extern size_t CsrWifiRouterCtrlPortConfigureCfmSizeof(void *msg); -#define CsrWifiRouterCtrlPortConfigureCfmSerFree CsrWifiRouterCtrlPfree - -#define CsrWifiRouterCtrlResumeIndSer CsrWifiEventCsrUint16CsrUint8Ser -#define CsrWifiRouterCtrlResumeIndDes CsrWifiEventCsrUint16CsrUint8Des -#define CsrWifiRouterCtrlResumeIndSizeof CsrWifiEventCsrUint16CsrUint8Sizeof -#define CsrWifiRouterCtrlResumeIndSerFree CsrWifiRouterCtrlPfree - -extern u8* CsrWifiRouterCtrlSuspendIndSer(u8 *ptr, size_t *len, void *msg); -extern void* CsrWifiRouterCtrlSuspendIndDes(u8 *buffer, size_t len); -extern size_t CsrWifiRouterCtrlSuspendIndSizeof(void *msg); -#define CsrWifiRouterCtrlSuspendIndSerFree CsrWifiRouterCtrlPfree - -extern u8* CsrWifiRouterCtrlTclasAddCfmSer(u8 *ptr, size_t *len, void *msg); -extern void* CsrWifiRouterCtrlTclasAddCfmDes(u8 *buffer, size_t len); -extern size_t CsrWifiRouterCtrlTclasAddCfmSizeof(void *msg); -#define CsrWifiRouterCtrlTclasAddCfmSerFree CsrWifiRouterCtrlPfree - -extern u8* CsrWifiRouterCtrlRawSdioDeinitialiseCfmSer(u8 *ptr, size_t *len, void *msg); -extern void* CsrWifiRouterCtrlRawSdioDeinitialiseCfmDes(u8 *buffer, size_t len); -extern size_t CsrWifiRouterCtrlRawSdioDeinitialiseCfmSizeof(void *msg); -#define CsrWifiRouterCtrlRawSdioDeinitialiseCfmSerFree CsrWifiRouterCtrlPfree - -extern u8* CsrWifiRouterCtrlRawSdioInitialiseCfmSer(u8 *ptr, size_t *len, void *msg); -extern void* CsrWifiRouterCtrlRawSdioInitialiseCfmDes(u8 *buffer, size_t len); -extern size_t CsrWifiRouterCtrlRawSdioInitialiseCfmSizeof(void *msg); -#define CsrWifiRouterCtrlRawSdioInitialiseCfmSerFree CsrWifiRouterCtrlPfree - -extern u8* CsrWifiRouterCtrlTclasDelCfmSer(u8 *ptr, size_t *len, void *msg); -extern void* CsrWifiRouterCtrlTclasDelCfmDes(u8 *buffer, size_t len); -extern size_t CsrWifiRouterCtrlTclasDelCfmSizeof(void *msg); -#define CsrWifiRouterCtrlTclasDelCfmSerFree CsrWifiRouterCtrlPfree - -extern u8* CsrWifiRouterCtrlTrafficProtocolIndSer(u8 *ptr, size_t *len, void *msg); -extern void* CsrWifiRouterCtrlTrafficProtocolIndDes(u8 *buffer, size_t len); -extern size_t CsrWifiRouterCtrlTrafficProtocolIndSizeof(void *msg); -#define CsrWifiRouterCtrlTrafficProtocolIndSerFree CsrWifiRouterCtrlPfree - -extern u8* CsrWifiRouterCtrlTrafficSampleIndSer(u8 *ptr, size_t *len, void *msg); -extern void* CsrWifiRouterCtrlTrafficSampleIndDes(u8 *buffer, size_t len); -extern size_t CsrWifiRouterCtrlTrafficSampleIndSizeof(void *msg); -#define CsrWifiRouterCtrlTrafficSampleIndSerFree CsrWifiRouterCtrlPfree - -#define CsrWifiRouterCtrlWifiOffIndSer CsrWifiEventCsrUint16CsrUint8Ser -#define CsrWifiRouterCtrlWifiOffIndDes CsrWifiEventCsrUint16CsrUint8Des -#define CsrWifiRouterCtrlWifiOffIndSizeof CsrWifiEventCsrUint16CsrUint8Sizeof -#define CsrWifiRouterCtrlWifiOffIndSerFree CsrWifiRouterCtrlPfree - -#define CsrWifiRouterCtrlWifiOffCfmSer CsrWifiEventCsrUint16Ser -#define CsrWifiRouterCtrlWifiOffCfmDes CsrWifiEventCsrUint16Des -#define CsrWifiRouterCtrlWifiOffCfmSizeof CsrWifiEventCsrUint16Sizeof -#define CsrWifiRouterCtrlWifiOffCfmSerFree CsrWifiRouterCtrlPfree - -extern u8* CsrWifiRouterCtrlWifiOnIndSer(u8 *ptr, size_t *len, void *msg); -extern void* CsrWifiRouterCtrlWifiOnIndDes(u8 *buffer, size_t len); -extern size_t CsrWifiRouterCtrlWifiOnIndSizeof(void *msg); -extern void CsrWifiRouterCtrlWifiOnIndSerFree(void *msg); - -extern u8* CsrWifiRouterCtrlWifiOnCfmSer(u8 *ptr, size_t *len, void *msg); -extern void* CsrWifiRouterCtrlWifiOnCfmDes(u8 *buffer, size_t len); -extern size_t CsrWifiRouterCtrlWifiOnCfmSizeof(void *msg); -#define CsrWifiRouterCtrlWifiOnCfmSerFree CsrWifiRouterCtrlPfree - -extern u8* CsrWifiRouterCtrlM4ReadyToSendIndSer(u8 *ptr, size_t *len, void *msg); -extern void* CsrWifiRouterCtrlM4ReadyToSendIndDes(u8 *buffer, size_t len); -extern size_t CsrWifiRouterCtrlM4ReadyToSendIndSizeof(void *msg); -#define CsrWifiRouterCtrlM4ReadyToSendIndSerFree CsrWifiRouterCtrlPfree - -extern u8* CsrWifiRouterCtrlM4TransmittedIndSer(u8 *ptr, size_t *len, void *msg); -extern void* CsrWifiRouterCtrlM4TransmittedIndDes(u8 *buffer, size_t len); -extern size_t CsrWifiRouterCtrlM4TransmittedIndSizeof(void *msg); -#define CsrWifiRouterCtrlM4TransmittedIndSerFree CsrWifiRouterCtrlPfree - -extern u8* CsrWifiRouterCtrlMicFailureIndSer(u8 *ptr, size_t *len, void *msg); -extern void* CsrWifiRouterCtrlMicFailureIndDes(u8 *buffer, size_t len); -extern size_t CsrWifiRouterCtrlMicFailureIndSizeof(void *msg); -#define CsrWifiRouterCtrlMicFailureIndSerFree CsrWifiRouterCtrlPfree - -extern u8* CsrWifiRouterCtrlConnectedIndSer(u8 *ptr, size_t *len, void *msg); -extern void* CsrWifiRouterCtrlConnectedIndDes(u8 *buffer, size_t len); -extern size_t CsrWifiRouterCtrlConnectedIndSizeof(void *msg); -#define CsrWifiRouterCtrlConnectedIndSerFree CsrWifiRouterCtrlPfree - -extern u8* CsrWifiRouterCtrlPeerAddCfmSer(u8 *ptr, size_t *len, void *msg); -extern void* CsrWifiRouterCtrlPeerAddCfmDes(u8 *buffer, size_t len); -extern size_t CsrWifiRouterCtrlPeerAddCfmSizeof(void *msg); -#define CsrWifiRouterCtrlPeerAddCfmSerFree CsrWifiRouterCtrlPfree - -extern u8* CsrWifiRouterCtrlPeerDelCfmSer(u8 *ptr, size_t *len, void *msg); -extern void* CsrWifiRouterCtrlPeerDelCfmDes(u8 *buffer, size_t len); -extern size_t CsrWifiRouterCtrlPeerDelCfmSizeof(void *msg); -#define CsrWifiRouterCtrlPeerDelCfmSerFree CsrWifiRouterCtrlPfree - -extern u8* CsrWifiRouterCtrlUnexpectedFrameIndSer(u8 *ptr, size_t *len, void *msg); -extern void* CsrWifiRouterCtrlUnexpectedFrameIndDes(u8 *buffer, size_t len); -extern size_t CsrWifiRouterCtrlUnexpectedFrameIndSizeof(void *msg); -#define CsrWifiRouterCtrlUnexpectedFrameIndSerFree CsrWifiRouterCtrlPfree - -extern u8* CsrWifiRouterCtrlPeerUpdateCfmSer(u8 *ptr, size_t *len, void *msg); -extern void* CsrWifiRouterCtrlPeerUpdateCfmDes(u8 *buffer, size_t len); -extern size_t CsrWifiRouterCtrlPeerUpdateCfmSizeof(void *msg); -#define CsrWifiRouterCtrlPeerUpdateCfmSerFree CsrWifiRouterCtrlPfree - -extern u8* CsrWifiRouterCtrlCapabilitiesCfmSer(u8 *ptr, size_t *len, void *msg); -extern void* CsrWifiRouterCtrlCapabilitiesCfmDes(u8 *buffer, size_t len); -extern size_t CsrWifiRouterCtrlCapabilitiesCfmSizeof(void *msg); -#define CsrWifiRouterCtrlCapabilitiesCfmSerFree CsrWifiRouterCtrlPfree - -extern u8* CsrWifiRouterCtrlBlockAckEnableCfmSer(u8 *ptr, size_t *len, void *msg); -extern void* CsrWifiRouterCtrlBlockAckEnableCfmDes(u8 *buffer, size_t len); -extern size_t CsrWifiRouterCtrlBlockAckEnableCfmSizeof(void *msg); -#define CsrWifiRouterCtrlBlockAckEnableCfmSerFree CsrWifiRouterCtrlPfree - -extern u8* CsrWifiRouterCtrlBlockAckDisableCfmSer(u8 *ptr, size_t *len, void *msg); -extern void* CsrWifiRouterCtrlBlockAckDisableCfmDes(u8 *buffer, size_t len); -extern size_t CsrWifiRouterCtrlBlockAckDisableCfmSizeof(void *msg); -#define CsrWifiRouterCtrlBlockAckDisableCfmSerFree CsrWifiRouterCtrlPfree - -extern u8* CsrWifiRouterCtrlBlockAckErrorIndSer(u8 *ptr, size_t *len, void *msg); -extern void* CsrWifiRouterCtrlBlockAckErrorIndDes(u8 *buffer, size_t len); -extern size_t CsrWifiRouterCtrlBlockAckErrorIndSizeof(void *msg); -#define CsrWifiRouterCtrlBlockAckErrorIndSerFree CsrWifiRouterCtrlPfree - -extern u8* CsrWifiRouterCtrlStaInactiveIndSer(u8 *ptr, size_t *len, void *msg); -extern void* CsrWifiRouterCtrlStaInactiveIndDes(u8 *buffer, size_t len); -extern size_t CsrWifiRouterCtrlStaInactiveIndSizeof(void *msg); -#define CsrWifiRouterCtrlStaInactiveIndSerFree CsrWifiRouterCtrlPfree - -extern u8* CsrWifiRouterCtrlWapiRxMicCheckIndSer(u8 *ptr, size_t *len, void *msg); -extern void* CsrWifiRouterCtrlWapiRxMicCheckIndDes(u8 *buffer, size_t len); -extern size_t CsrWifiRouterCtrlWapiRxMicCheckIndSizeof(void *msg); -extern void CsrWifiRouterCtrlWapiRxMicCheckIndSerFree(void *msg); - -extern u8* CsrWifiRouterCtrlModeSetCfmSer(u8 *ptr, size_t *len, void *msg); -extern void* CsrWifiRouterCtrlModeSetCfmDes(u8 *buffer, size_t len); -extern size_t CsrWifiRouterCtrlModeSetCfmSizeof(void *msg); -#define CsrWifiRouterCtrlModeSetCfmSerFree CsrWifiRouterCtrlPfree - -extern u8* CsrWifiRouterCtrlWapiUnicastTxEncryptIndSer(u8 *ptr, size_t *len, void *msg); -extern void* CsrWifiRouterCtrlWapiUnicastTxEncryptIndDes(u8 *buffer, size_t len); -extern size_t CsrWifiRouterCtrlWapiUnicastTxEncryptIndSizeof(void *msg); -extern void CsrWifiRouterCtrlWapiUnicastTxEncryptIndSerFree(void *msg); - -#endif /* CSR_WIFI_ROUTER_CTRL_SERIALIZE_H__ */ - diff --git a/drivers/staging/csr/csr_wifi_router_free_downstream_contents.c b/drivers/staging/csr/csr_wifi_router_free_downstream_contents.c deleted file mode 100644 index c4badc565a91..000000000000 --- a/drivers/staging/csr/csr_wifi_router_free_downstream_contents.c +++ /dev/null @@ -1,53 +0,0 @@ -/***************************************************************************** - - (c) Cambridge Silicon Radio Limited 2011 - All rights reserved and confidential information of CSR - - Refer to LICENSE.txt included with this source for details - on the license terms. - -*****************************************************************************/ - -/* Note: this is an auto-generated file. */ -#include -#include "csr_wifi_router_prim.h" -#include "csr_wifi_router_lib.h" - -/*----------------------------------------------------------------------------* - * NAME - * CsrWifiRouterFreeDownstreamMessageContents - * - * DESCRIPTION - * - * - * PARAMETERS - * eventClass: only the value CSR_WIFI_ROUTER_PRIM will be handled - * message: the message to free - *----------------------------------------------------------------------------*/ -void CsrWifiRouterFreeDownstreamMessageContents(u16 eventClass, void *message) -{ - if (eventClass != CSR_WIFI_ROUTER_PRIM) - { - return; - } - if (NULL == message) - { - return; - } - - switch (*((CsrWifiRouterPrim *) message)) - { - case CSR_WIFI_ROUTER_MA_PACKET_REQ: - { - CsrWifiRouterMaPacketReq *p = (CsrWifiRouterMaPacketReq *)message; - kfree(p->frame); - p->frame = NULL; - break; - } - - default: - break; - } -} - - diff --git a/drivers/staging/csr/csr_wifi_router_free_upstream_contents.c b/drivers/staging/csr/csr_wifi_router_free_upstream_contents.c deleted file mode 100644 index 4cd126338e27..000000000000 --- a/drivers/staging/csr/csr_wifi_router_free_upstream_contents.c +++ /dev/null @@ -1,47 +0,0 @@ -/***************************************************************************** - - (c) Cambridge Silicon Radio Limited 2011 - All rights reserved and confidential information of CSR - - Refer to LICENSE.txt included with this source for details - on the license terms. - -*****************************************************************************/ - -/* Note: this is an auto-generated file. */ -#include -#include "csr_wifi_router_prim.h" -#include "csr_wifi_router_lib.h" - -/*----------------------------------------------------------------------------* - * NAME - * CsrWifiRouterFreeUpstreamMessageContents - * - * DESCRIPTION - * - * - * PARAMETERS - * eventClass: only the value CSR_WIFI_ROUTER_PRIM will be handled - * message: the message to free - *----------------------------------------------------------------------------*/ -void CsrWifiRouterFreeUpstreamMessageContents(u16 eventClass, void *message) -{ - if (eventClass != CSR_WIFI_ROUTER_PRIM) - return; - if (NULL == message) - return; - switch (*((CsrWifiRouterPrim *) message)) { - case CSR_WIFI_ROUTER_MA_PACKET_IND: - { - CsrWifiRouterMaPacketInd *p = - (CsrWifiRouterMaPacketInd *) message; - kfree(p->frame); - p->frame = NULL; - break; - } - default: - break; - } -} - - diff --git a/drivers/staging/csr/csr_wifi_router_lib.h b/drivers/staging/csr/csr_wifi_router_lib.h deleted file mode 100644 index b0477c413aae..000000000000 --- a/drivers/staging/csr/csr_wifi_router_lib.h +++ /dev/null @@ -1,417 +0,0 @@ -/***************************************************************************** - - (c) Cambridge Silicon Radio Limited 2011 - All rights reserved and confidential information of CSR - - Refer to LICENSE.txt included with this source for details - on the license terms. - -*****************************************************************************/ - -/* Note: this is an auto-generated file. */ - -#ifndef CSR_WIFI_ROUTER_LIB_H__ -#define CSR_WIFI_ROUTER_LIB_H__ - -#include "csr_sched.h" -#include "csr_macro.h" -#include "csr_msg_transport.h" - -#include "csr_wifi_lib.h" - -#include "csr_wifi_router_prim.h" -#include "csr_wifi_router_task.h" - -/*----------------------------------------------------------------------------* - * CsrWifiRouterFreeUpstreamMessageContents - * - * DESCRIPTION - * Free the allocated memory in a CSR_WIFI_ROUTER upstream message. Does not - * free the message itself, and can only be used for upstream messages. - * - * PARAMETERS - * Deallocates the resources in a CSR_WIFI_ROUTER upstream message - *----------------------------------------------------------------------------*/ -void CsrWifiRouterFreeUpstreamMessageContents(u16 eventClass, void *message); - -/*----------------------------------------------------------------------------* - * CsrWifiRouterFreeDownstreamMessageContents - * - * DESCRIPTION - * Free the allocated memory in a CSR_WIFI_ROUTER downstream message. Does not - * free the message itself, and can only be used for downstream messages. - * - * PARAMETERS - * Deallocates the resources in a CSR_WIFI_ROUTER downstream message - *----------------------------------------------------------------------------*/ -void CsrWifiRouterFreeDownstreamMessageContents(u16 eventClass, void *message); - -/*----------------------------------------------------------------------------* - * Enum to string functions - *----------------------------------------------------------------------------*/ -const char* CsrWifiRouterAppTypeToString(CsrWifiRouterAppType value); -const char* CsrWifiRouterEncapsulationToString(CsrWifiRouterEncapsulation value); -const char* CsrWifiRouterOuiToString(CsrWifiRouterOui value); -const char* CsrWifiRouterPriorityToString(CsrWifiRouterPriority value); - - -/*----------------------------------------------------------------------------* - * CsrPrim Type toString function. - * Converts a message type to the String name of the Message - *----------------------------------------------------------------------------*/ -const char* CsrWifiRouterPrimTypeToString(CsrPrim msgType); - -/*----------------------------------------------------------------------------* - * Lookup arrays for PrimType name Strings - *----------------------------------------------------------------------------*/ -extern const char *CsrWifiRouterUpstreamPrimNames[CSR_WIFI_ROUTER_PRIM_UPSTREAM_COUNT]; -extern const char *CsrWifiRouterDownstreamPrimNames[CSR_WIFI_ROUTER_PRIM_DOWNSTREAM_COUNT]; - -/******************************************************************************* - - NAME - CsrWifiRouterMaPacketCancelReqSend - - DESCRIPTION - This primitive is used to request cancellation of a previously send - CsrWifiRouterMaPacketReq. - The frame may already have been transmitted so there is no guarantees - that the CsrWifiRouterMaPacketCancelReq actually cancels the transmission - of the frame in question. - If the cancellation fails, the Router will send, if required, - CsrWifiRouterMaPacketCfm. - If the cancellation succeeds, the Router will not send - CsrWifiRouterMaPacketCfm. - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - interfaceTag - Interface Identifier; unique identifier of an interface - hostTag - The hostTag for the frame, which should be cancelled. - priority - Priority of the frame, which should be cancelled - peerMacAddress - Destination MAC address of the frame, which should be - cancelled - -*******************************************************************************/ -#define CsrWifiRouterMaPacketCancelReqCreate(msg__, dst__, src__, interfaceTag__, hostTag__, priority__, peerMacAddress__) \ - msg__ = kmalloc(sizeof(CsrWifiRouterMaPacketCancelReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_PRIM, CSR_WIFI_ROUTER_MA_PACKET_CANCEL_REQ, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->hostTag = (hostTag__); \ - msg__->priority = (priority__); \ - msg__->peerMacAddress = (peerMacAddress__); - -#define CsrWifiRouterMaPacketCancelReqSendTo(dst__, src__, interfaceTag__, hostTag__, priority__, peerMacAddress__) \ - { \ - CsrWifiRouterMaPacketCancelReq *msg__; \ - CsrWifiRouterMaPacketCancelReqCreate(msg__, dst__, src__, interfaceTag__, hostTag__, priority__, peerMacAddress__); \ - CsrMsgTransport(dst__, CSR_WIFI_ROUTER_PRIM, msg__); \ - } - -#define CsrWifiRouterMaPacketCancelReqSend(src__, interfaceTag__, hostTag__, priority__, peerMacAddress__) \ - CsrWifiRouterMaPacketCancelReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, hostTag__, priority__, peerMacAddress__) - -/******************************************************************************* - - NAME - CsrWifiRouterMaPacketReqSend - - DESCRIPTION - A task sends this primitive to transmit a frame. - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - interfaceTag - Interface Identifier; unique identifier of an interface - subscriptionHandle - The handle of the subscription - frameLength - Length of the frame to be sent in bytes - frame - Pointer to the frame to be sent - freeFunction - Pointer to function to be used to free the frame - priority - Priority of the frame, which should be sent - hostTag - An application shall set the bits b31..b28 using one of - the CSR_WIFI_ROUTER_APP_TYPE_* masks. Bits b0..b27 can - be used by the requestor without any restrictions, but - the hostTag shall be unique so the hostTag for - CSR_WIFI_ROUTER_APP _TYPE_OTHER should be constructured - in the following way [ CSR_WIFI_ROUTER_APP_TYPE_OTHER - (4 bits) | SubscriptionHandle (8 bits) | Sequence no. - (20 bits) ]. If the hostTag is not unique, the - behaviour of the system is unpredicatable with respect - to data/management frame transfer. - cfmRequested - Indicates if the requestor needs a confirm for packet - requests sent under this subscription. If set to TRUE, - the router will send a confirm, else it will not send - any confirm - -*******************************************************************************/ -#define CsrWifiRouterMaPacketReqCreate(msg__, dst__, src__, interfaceTag__, subscriptionHandle__, frameLength__, frame__, freeFunction__, priority__, hostTag__, cfmRequested__) \ - msg__ = kmalloc(sizeof(CsrWifiRouterMaPacketReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_PRIM, CSR_WIFI_ROUTER_MA_PACKET_REQ, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->subscriptionHandle = (subscriptionHandle__); \ - msg__->frameLength = (frameLength__); \ - msg__->frame = (frame__); \ - msg__->freeFunction = (freeFunction__); \ - msg__->priority = (priority__); \ - msg__->hostTag = (hostTag__); \ - msg__->cfmRequested = (cfmRequested__); - -#define CsrWifiRouterMaPacketReqSendTo(dst__, src__, interfaceTag__, subscriptionHandle__, frameLength__, frame__, freeFunction__, priority__, hostTag__, cfmRequested__) \ - { \ - CsrWifiRouterMaPacketReq *msg__; \ - CsrWifiRouterMaPacketReqCreate(msg__, dst__, src__, interfaceTag__, subscriptionHandle__, frameLength__, frame__, freeFunction__, priority__, hostTag__, cfmRequested__); \ - CsrMsgTransport(dst__, CSR_WIFI_ROUTER_PRIM, msg__); \ - } - -#define CsrWifiRouterMaPacketReqSend(src__, interfaceTag__, subscriptionHandle__, frameLength__, frame__, freeFunction__, priority__, hostTag__, cfmRequested__) \ - CsrWifiRouterMaPacketReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, subscriptionHandle__, frameLength__, frame__, freeFunction__, priority__, hostTag__, cfmRequested__) - -/******************************************************************************* - - NAME - CsrWifiRouterMaPacketIndSend - - DESCRIPTION - The router sends the primitive to a subscribed task when it receives a - frame matching the subscription. - - PARAMETERS - queue - Destination Task Queue - interfaceTag - Interface Identifier; unique identifier of an interface - subscriptionHandle - The handle of the subscription - result - Status of the operation - frameLength - Length of the received frame in bytes - frame - Pointer to the received frame - freeFunction - Pointer to function to be used to free the frame - rssi - Received signal strength indication in dBm - snr - Signal to Noise Ratio - rate - Transmission/Reception rate - -*******************************************************************************/ -#define CsrWifiRouterMaPacketIndCreate(msg__, dst__, src__, interfaceTag__, subscriptionHandle__, result__, frameLength__, frame__, freeFunction__, rssi__, snr__, rate__) \ - msg__ = kmalloc(sizeof(CsrWifiRouterMaPacketInd), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_PRIM, CSR_WIFI_ROUTER_MA_PACKET_IND, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->subscriptionHandle = (subscriptionHandle__); \ - msg__->result = (result__); \ - msg__->frameLength = (frameLength__); \ - msg__->frame = (frame__); \ - msg__->freeFunction = (freeFunction__); \ - msg__->rssi = (rssi__); \ - msg__->snr = (snr__); \ - msg__->rate = (rate__); - -#define CsrWifiRouterMaPacketIndSendTo(dst__, src__, interfaceTag__, subscriptionHandle__, result__, frameLength__, frame__, freeFunction__, rssi__, snr__, rate__) \ - { \ - CsrWifiRouterMaPacketInd *msg__; \ - CsrWifiRouterMaPacketIndCreate(msg__, dst__, src__, interfaceTag__, subscriptionHandle__, result__, frameLength__, frame__, freeFunction__, rssi__, snr__, rate__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_PRIM, msg__); \ - } - -#define CsrWifiRouterMaPacketIndSend(dst__, interfaceTag__, subscriptionHandle__, result__, frameLength__, frame__, freeFunction__, rssi__, snr__, rate__) \ - CsrWifiRouterMaPacketIndSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, interfaceTag__, subscriptionHandle__, result__, frameLength__, frame__, freeFunction__, rssi__, snr__, rate__) - -/******************************************************************************* - - NAME - CsrWifiRouterMaPacketResSend - - DESCRIPTION - A task send this primitive to confirm the reception of the received - frame. - - PARAMETERS - interfaceTag - Interface Identifier; unique identifier of an interface - subscriptionHandle - The handle of the subscription - result - Status of the operation - -*******************************************************************************/ -#define CsrWifiRouterMaPacketResCreate(msg__, dst__, src__, interfaceTag__, subscriptionHandle__, result__) \ - msg__ = kmalloc(sizeof(CsrWifiRouterMaPacketRes), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_PRIM, CSR_WIFI_ROUTER_MA_PACKET_RES, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->subscriptionHandle = (subscriptionHandle__); \ - msg__->result = (result__); - -#define CsrWifiRouterMaPacketResSendTo(dst__, src__, interfaceTag__, subscriptionHandle__, result__) \ - { \ - CsrWifiRouterMaPacketRes *msg__; \ - CsrWifiRouterMaPacketResCreate(msg__, dst__, src__, interfaceTag__, subscriptionHandle__, result__); \ - CsrMsgTransport(dst__, CSR_WIFI_ROUTER_PRIM, msg__); \ - } - -#define CsrWifiRouterMaPacketResSend(src__, interfaceTag__, subscriptionHandle__, result__) \ - CsrWifiRouterMaPacketResSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, subscriptionHandle__, result__) - -/******************************************************************************* - - NAME - CsrWifiRouterMaPacketCfmSend - - DESCRIPTION - The router sends the primitive to confirm the result of the transmission - of the packet of the corresponding CSR_WIFI_ROUTER MA_PACKET_REQ request. - - PARAMETERS - queue - Destination Task Queue - interfaceTag - Interface Identifier; unique identifier of an interface - result - Status of the operation - hostTag - The hostTrag will match the hostTag sent in the request. - rate - Transmission/Reception rate - -*******************************************************************************/ -#define CsrWifiRouterMaPacketCfmCreate(msg__, dst__, src__, interfaceTag__, result__, hostTag__, rate__) \ - msg__ = kmalloc(sizeof(CsrWifiRouterMaPacketCfm), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_PRIM, CSR_WIFI_ROUTER_MA_PACKET_CFM, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->result = (result__); \ - msg__->hostTag = (hostTag__); \ - msg__->rate = (rate__); - -#define CsrWifiRouterMaPacketCfmSendTo(dst__, src__, interfaceTag__, result__, hostTag__, rate__) \ - { \ - CsrWifiRouterMaPacketCfm *msg__; \ - CsrWifiRouterMaPacketCfmCreate(msg__, dst__, src__, interfaceTag__, result__, hostTag__, rate__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_PRIM, msg__); \ - } - -#define CsrWifiRouterMaPacketCfmSend(dst__, interfaceTag__, result__, hostTag__, rate__) \ - CsrWifiRouterMaPacketCfmSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, interfaceTag__, result__, hostTag__, rate__) - -/******************************************************************************* - - NAME - CsrWifiRouterMaPacketSubscribeReqSend - - DESCRIPTION - A task can use this primitive to subscribe for a particular OUI/protocol - and transmit and receive frames matching the subscription. - NOTE: Multiple subscriptions for a given protocol and OUI will result in - the first subscription receiving the data and not the subsequent - subscriptions. - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - interfaceTag - Interface Identifier; unique identifier of an interface - encapsulation - Specifies the encapsulation type, which will be used for the - subscription - protocol - Together with the OUI, specifies the protocol, which a task - wants to subscribe to - oui - Specifies the OUI for the protocol, which a task wants to - subscribe to - -*******************************************************************************/ -#define CsrWifiRouterMaPacketSubscribeReqCreate(msg__, dst__, src__, interfaceTag__, encapsulation__, protocol__, oui__) \ - msg__ = kmalloc(sizeof(CsrWifiRouterMaPacketSubscribeReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_PRIM, CSR_WIFI_ROUTER_MA_PACKET_SUBSCRIBE_REQ, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->encapsulation = (encapsulation__); \ - msg__->protocol = (protocol__); \ - msg__->oui = (oui__); - -#define CsrWifiRouterMaPacketSubscribeReqSendTo(dst__, src__, interfaceTag__, encapsulation__, protocol__, oui__) \ - { \ - CsrWifiRouterMaPacketSubscribeReq *msg__; \ - CsrWifiRouterMaPacketSubscribeReqCreate(msg__, dst__, src__, interfaceTag__, encapsulation__, protocol__, oui__); \ - CsrMsgTransport(dst__, CSR_WIFI_ROUTER_PRIM, msg__); \ - } - -#define CsrWifiRouterMaPacketSubscribeReqSend(src__, interfaceTag__, encapsulation__, protocol__, oui__) \ - CsrWifiRouterMaPacketSubscribeReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, encapsulation__, protocol__, oui__) - -/******************************************************************************* - - NAME - CsrWifiRouterMaPacketSubscribeCfmSend - - DESCRIPTION - The router sends this primitive to confirm the result of the - subscription. - - PARAMETERS - queue - Destination Task Queue - interfaceTag - Interface Identifier; unique identifier of an interface - subscriptionHandle - Handle to the subscription - This handle must be used in all subsequent requests - status - Status of the operation - allocOffset - Size of the offset for the frames of the subscription - -*******************************************************************************/ -#define CsrWifiRouterMaPacketSubscribeCfmCreate(msg__, dst__, src__, interfaceTag__, subscriptionHandle__, status__, allocOffset__) \ - msg__ = kmalloc(sizeof(CsrWifiRouterMaPacketSubscribeCfm), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_PRIM, CSR_WIFI_ROUTER_MA_PACKET_SUBSCRIBE_CFM, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->subscriptionHandle = (subscriptionHandle__); \ - msg__->status = (status__); \ - msg__->allocOffset = (allocOffset__); - -#define CsrWifiRouterMaPacketSubscribeCfmSendTo(dst__, src__, interfaceTag__, subscriptionHandle__, status__, allocOffset__) \ - { \ - CsrWifiRouterMaPacketSubscribeCfm *msg__; \ - CsrWifiRouterMaPacketSubscribeCfmCreate(msg__, dst__, src__, interfaceTag__, subscriptionHandle__, status__, allocOffset__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_PRIM, msg__); \ - } - -#define CsrWifiRouterMaPacketSubscribeCfmSend(dst__, interfaceTag__, subscriptionHandle__, status__, allocOffset__) \ - CsrWifiRouterMaPacketSubscribeCfmSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, interfaceTag__, subscriptionHandle__, status__, allocOffset__) - -/******************************************************************************* - - NAME - CsrWifiRouterMaPacketUnsubscribeReqSend - - DESCRIPTION - A task sends this primitive to unsubscribe a subscription - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - interfaceTag - Interface Identifier; unique identifier of an interface - subscriptionHandle - The handle of the subscription - -*******************************************************************************/ -#define CsrWifiRouterMaPacketUnsubscribeReqCreate(msg__, dst__, src__, interfaceTag__, subscriptionHandle__) \ - msg__ = kmalloc(sizeof(CsrWifiRouterMaPacketUnsubscribeReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_PRIM, CSR_WIFI_ROUTER_MA_PACKET_UNSUBSCRIBE_REQ, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->subscriptionHandle = (subscriptionHandle__); - -#define CsrWifiRouterMaPacketUnsubscribeReqSendTo(dst__, src__, interfaceTag__, subscriptionHandle__) \ - { \ - CsrWifiRouterMaPacketUnsubscribeReq *msg__; \ - CsrWifiRouterMaPacketUnsubscribeReqCreate(msg__, dst__, src__, interfaceTag__, subscriptionHandle__); \ - CsrMsgTransport(dst__, CSR_WIFI_ROUTER_PRIM, msg__); \ - } - -#define CsrWifiRouterMaPacketUnsubscribeReqSend(src__, interfaceTag__, subscriptionHandle__) \ - CsrWifiRouterMaPacketUnsubscribeReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, subscriptionHandle__) - -/******************************************************************************* - - NAME - CsrWifiRouterMaPacketUnsubscribeCfmSend - - DESCRIPTION - The router sends this primitive to confirm the result of the - unsubscription. - - PARAMETERS - queue - Destination Task Queue - interfaceTag - Interface Identifier; unique identifier of an interface - status - Status of the operation - -*******************************************************************************/ -#define CsrWifiRouterMaPacketUnsubscribeCfmCreate(msg__, dst__, src__, interfaceTag__, status__) \ - msg__ = kmalloc(sizeof(CsrWifiRouterMaPacketUnsubscribeCfm), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_PRIM, CSR_WIFI_ROUTER_MA_PACKET_UNSUBSCRIBE_CFM, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->status = (status__); - -#define CsrWifiRouterMaPacketUnsubscribeCfmSendTo(dst__, src__, interfaceTag__, status__) \ - { \ - CsrWifiRouterMaPacketUnsubscribeCfm *msg__; \ - CsrWifiRouterMaPacketUnsubscribeCfmCreate(msg__, dst__, src__, interfaceTag__, status__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_PRIM, msg__); \ - } - -#define CsrWifiRouterMaPacketUnsubscribeCfmSend(dst__, interfaceTag__, status__) \ - CsrWifiRouterMaPacketUnsubscribeCfmSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, interfaceTag__, status__) - -#endif /* CSR_WIFI_ROUTER_LIB_H__ */ diff --git a/drivers/staging/csr/csr_wifi_router_prim.h b/drivers/staging/csr/csr_wifi_router_prim.h deleted file mode 100644 index c52344b51f2f..000000000000 --- a/drivers/staging/csr/csr_wifi_router_prim.h +++ /dev/null @@ -1,421 +0,0 @@ -/***************************************************************************** - - (c) Cambridge Silicon Radio Limited 2011 - All rights reserved and confidential information of CSR - - Refer to LICENSE.txt included with this source for details - on the license terms. - -*****************************************************************************/ - -/* Note: this is an auto-generated file. */ - -#ifndef CSR_WIFI_ROUTER_PRIM_H__ -#define CSR_WIFI_ROUTER_PRIM_H__ - -#include -#include "csr_prim_defs.h" -#include "csr_sched.h" -#include "csr_wifi_common.h" -#include "csr_result.h" -#include "csr_wifi_fsm_event.h" - -#define CSR_WIFI_ROUTER_PRIM (0x0400) - -typedef CsrPrim CsrWifiRouterPrim; - -typedef void (*CsrWifiRouterFrameFreeFunction)(void *frame); - -/******************************************************************************* - - NAME - CsrWifiRouterAppType - - DESCRIPTION - - VALUES - CSR_WIFI_ROUTER_APP_TYPE_SME - - CSR_WIFI_ROUTER_APP_TYPE_PAL - - CSR_WIFI_ROUTER_APP_TYPE_NME - - CSR_WIFI_ROUTER_APP_TYPE_OTHER - - -*******************************************************************************/ -typedef u8 CsrWifiRouterAppType; -#define CSR_WIFI_ROUTER_APP_TYPE_SME ((CsrWifiRouterAppType) 0x0) -#define CSR_WIFI_ROUTER_APP_TYPE_PAL ((CsrWifiRouterAppType) 0x1) -#define CSR_WIFI_ROUTER_APP_TYPE_NME ((CsrWifiRouterAppType) 0x2) -#define CSR_WIFI_ROUTER_APP_TYPE_OTHER ((CsrWifiRouterAppType) 0x3) - -/******************************************************************************* - - NAME - CsrWifiRouterEncapsulation - - DESCRIPTION - Indicates the type of encapsulation used for the subscription - - VALUES - CSR_WIFI_ROUTER_ENCAPSULATION_ETHERNET - - Ethernet encapsulation - CSR_WIFI_ROUTER_ENCAPSULATION_LLC_SNAP - - LLC/SNAP encapsulation - -*******************************************************************************/ -typedef u8 CsrWifiRouterEncapsulation; -#define CSR_WIFI_ROUTER_ENCAPSULATION_ETHERNET ((CsrWifiRouterEncapsulation) 0x00) -#define CSR_WIFI_ROUTER_ENCAPSULATION_LLC_SNAP ((CsrWifiRouterEncapsulation) 0x01) - -/******************************************************************************* - - NAME - CsrWifiRouterOui - - DESCRIPTION - - VALUES - CSR_WIFI_ROUTER_OUI_RFC_1042 - - CSR_WIFI_ROUTER_OUI_BT - - -*******************************************************************************/ -typedef u32 CsrWifiRouterOui; -#define CSR_WIFI_ROUTER_OUI_RFC_1042 ((CsrWifiRouterOui) 0x000000) -#define CSR_WIFI_ROUTER_OUI_BT ((CsrWifiRouterOui) 0x001958) - -/******************************************************************************* - - NAME - CsrWifiRouterPriority - - DESCRIPTION - As defined in the IEEE 802.11 standards - - VALUES - CSR_WIFI_ROUTER_PRIORITY_QOS_UP0 - - See IEEE 802.11 Standard - CSR_WIFI_ROUTER_PRIORITY_QOS_UP1 - - See IEEE 802.11 Standard - CSR_WIFI_ROUTER_PRIORITY_QOS_UP2 - - See IEEE 802.11 Standard - CSR_WIFI_ROUTER_PRIORITY_QOS_UP3 - - See IEEE 802.11 Standard - CSR_WIFI_ROUTER_PRIORITY_QOS_UP4 - - See IEEE 802.11 Standard - CSR_WIFI_ROUTER_PRIORITY_QOS_UP5 - - See IEEE 802.11 Standard - CSR_WIFI_ROUTER_PRIORITY_QOS_UP6 - - See IEEE 802.11 Standard - CSR_WIFI_ROUTER_PRIORITY_QOS_UP7 - - See IEEE 802.11 Standard - CSR_WIFI_ROUTER_PRIORITY_CONTENTION - - See IEEE 802.11 Standard - CSR_WIFI_ROUTER_PRIORITY_MANAGEMENT - - See IEEE 802.11 Standard - -*******************************************************************************/ -typedef u16 CsrWifiRouterPriority; -#define CSR_WIFI_ROUTER_PRIORITY_QOS_UP0 ((CsrWifiRouterPriority) 0x0000) -#define CSR_WIFI_ROUTER_PRIORITY_QOS_UP1 ((CsrWifiRouterPriority) 0x0001) -#define CSR_WIFI_ROUTER_PRIORITY_QOS_UP2 ((CsrWifiRouterPriority) 0x0002) -#define CSR_WIFI_ROUTER_PRIORITY_QOS_UP3 ((CsrWifiRouterPriority) 0x0003) -#define CSR_WIFI_ROUTER_PRIORITY_QOS_UP4 ((CsrWifiRouterPriority) 0x0004) -#define CSR_WIFI_ROUTER_PRIORITY_QOS_UP5 ((CsrWifiRouterPriority) 0x0005) -#define CSR_WIFI_ROUTER_PRIORITY_QOS_UP6 ((CsrWifiRouterPriority) 0x0006) -#define CSR_WIFI_ROUTER_PRIORITY_QOS_UP7 ((CsrWifiRouterPriority) 0x0007) -#define CSR_WIFI_ROUTER_PRIORITY_CONTENTION ((CsrWifiRouterPriority) 0x8000) -#define CSR_WIFI_ROUTER_PRIORITY_MANAGEMENT ((CsrWifiRouterPriority) 0x8010) - - -/* Downstream */ -#define CSR_WIFI_ROUTER_PRIM_DOWNSTREAM_LOWEST (0x0000) - -#define CSR_WIFI_ROUTER_MA_PACKET_SUBSCRIBE_REQ ((CsrWifiRouterPrim) (0x0000 + CSR_WIFI_ROUTER_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_ROUTER_MA_PACKET_UNSUBSCRIBE_REQ ((CsrWifiRouterPrim) (0x0001 + CSR_WIFI_ROUTER_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_ROUTER_MA_PACKET_REQ ((CsrWifiRouterPrim) (0x0002 + CSR_WIFI_ROUTER_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_ROUTER_MA_PACKET_RES ((CsrWifiRouterPrim) (0x0003 + CSR_WIFI_ROUTER_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_ROUTER_MA_PACKET_CANCEL_REQ ((CsrWifiRouterPrim) (0x0004 + CSR_WIFI_ROUTER_PRIM_DOWNSTREAM_LOWEST)) - - -#define CSR_WIFI_ROUTER_PRIM_DOWNSTREAM_HIGHEST (0x0004 + CSR_WIFI_ROUTER_PRIM_DOWNSTREAM_LOWEST) - -/* Upstream */ -#define CSR_WIFI_ROUTER_PRIM_UPSTREAM_LOWEST (0x0000 + CSR_PRIM_UPSTREAM) - -#define CSR_WIFI_ROUTER_MA_PACKET_SUBSCRIBE_CFM ((CsrWifiRouterPrim)(0x0000 + CSR_WIFI_ROUTER_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_ROUTER_MA_PACKET_UNSUBSCRIBE_CFM ((CsrWifiRouterPrim)(0x0001 + CSR_WIFI_ROUTER_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_ROUTER_MA_PACKET_CFM ((CsrWifiRouterPrim)(0x0002 + CSR_WIFI_ROUTER_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_ROUTER_MA_PACKET_IND ((CsrWifiRouterPrim)(0x0003 + CSR_WIFI_ROUTER_PRIM_UPSTREAM_LOWEST)) - -#define CSR_WIFI_ROUTER_PRIM_UPSTREAM_HIGHEST (0x0003 + CSR_WIFI_ROUTER_PRIM_UPSTREAM_LOWEST) - -#define CSR_WIFI_ROUTER_PRIM_DOWNSTREAM_COUNT (CSR_WIFI_ROUTER_PRIM_DOWNSTREAM_HIGHEST + 1 - CSR_WIFI_ROUTER_PRIM_DOWNSTREAM_LOWEST) -#define CSR_WIFI_ROUTER_PRIM_UPSTREAM_COUNT (CSR_WIFI_ROUTER_PRIM_UPSTREAM_HIGHEST + 1 - CSR_WIFI_ROUTER_PRIM_UPSTREAM_LOWEST) - -/******************************************************************************* - - NAME - CsrWifiRouterMaPacketSubscribeReq - - DESCRIPTION - A task can use this primitive to subscribe for a particular OUI/protocol - and transmit and receive frames matching the subscription. - NOTE: Multiple subscriptions for a given protocol and OUI will result in - the first subscription receiving the data and not the subsequent - subscriptions. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - Interface Identifier; unique identifier of an interface - encapsulation - Specifies the encapsulation type, which will be used for the - subscription - protocol - Together with the OUI, specifies the protocol, which a task - wants to subscribe to - oui - Specifies the OUI for the protocol, which a task wants to - subscribe to - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; - CsrWifiRouterEncapsulation encapsulation; - u16 protocol; - u32 oui; -} CsrWifiRouterMaPacketSubscribeReq; - -/******************************************************************************* - - NAME - CsrWifiRouterMaPacketUnsubscribeReq - - DESCRIPTION - A task sends this primitive to unsubscribe a subscription - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - Interface Identifier; unique identifier of an interface - subscriptionHandle - The handle of the subscription - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; - u8 subscriptionHandle; -} CsrWifiRouterMaPacketUnsubscribeReq; - -/******************************************************************************* - - NAME - CsrWifiRouterMaPacketReq - - DESCRIPTION - A task sends this primitive to transmit a frame. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - Interface Identifier; unique identifier of an interface - subscriptionHandle - The handle of the subscription - frameLength - Length of the frame to be sent in bytes - frame - Pointer to the frame to be sent - freeFunction - Pointer to function to be used to free the frame - priority - Priority of the frame, which should be sent - hostTag - An application shall set the bits b31..b28 using one of - the CSR_WIFI_ROUTER_APP_TYPE_* masks. Bits b0..b27 can - be used by the requestor without any restrictions, but - the hostTag shall be unique so the hostTag for - CSR_WIFI_ROUTER_APP _TYPE_OTHER should be constructured - in the following way [ CSR_WIFI_ROUTER_APP_TYPE_OTHER - (4 bits) | SubscriptionHandle (8 bits) | Sequence no. - (20 bits) ]. If the hostTag is not unique, the - behaviour of the system is unpredicatable with respect - to data/management frame transfer. - cfmRequested - Indicates if the requestor needs a confirm for packet - requests sent under this subscription. If set to TRUE, - the router will send a confirm, else it will not send - any confirm - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; - u8 subscriptionHandle; - u16 frameLength; - u8 *frame; - CsrWifiRouterFrameFreeFunction freeFunction; - CsrWifiRouterPriority priority; - u32 hostTag; - u8 cfmRequested; -} CsrWifiRouterMaPacketReq; - -/******************************************************************************* - - NAME - CsrWifiRouterMaPacketRes - - DESCRIPTION - A task send this primitive to confirm the reception of the received - frame. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - Interface Identifier; unique identifier of an interface - subscriptionHandle - The handle of the subscription - result - Status of the operation - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; - u8 subscriptionHandle; - CsrResult result; -} CsrWifiRouterMaPacketRes; - -/******************************************************************************* - - NAME - CsrWifiRouterMaPacketCancelReq - - DESCRIPTION - This primitive is used to request cancellation of a previously send - CsrWifiRouterMaPacketReq. - The frame may already have been transmitted so there is no guarantees - that the CsrWifiRouterMaPacketCancelReq actually cancels the transmission - of the frame in question. - If the cancellation fails, the Router will send, if required, - CsrWifiRouterMaPacketCfm. - If the cancellation succeeds, the Router will not send - CsrWifiRouterMaPacketCfm. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - Interface Identifier; unique identifier of an interface - hostTag - The hostTag for the frame, which should be cancelled. - priority - Priority of the frame, which should be cancelled - peerMacAddress - Destination MAC address of the frame, which should be - cancelled - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; - u32 hostTag; - CsrWifiRouterPriority priority; - CsrWifiMacAddress peerMacAddress; -} CsrWifiRouterMaPacketCancelReq; - -/******************************************************************************* - - NAME - CsrWifiRouterMaPacketSubscribeCfm - - DESCRIPTION - The router sends this primitive to confirm the result of the - subscription. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - Interface Identifier; unique identifier of an interface - subscriptionHandle - Handle to the subscription - This handle must be used in all subsequent requests - status - Status of the operation - allocOffset - Size of the offset for the frames of the subscription - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; - u8 subscriptionHandle; - CsrResult status; - u16 allocOffset; -} CsrWifiRouterMaPacketSubscribeCfm; - -/******************************************************************************* - - NAME - CsrWifiRouterMaPacketUnsubscribeCfm - - DESCRIPTION - The router sends this primitive to confirm the result of the - unsubscription. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - Interface Identifier; unique identifier of an interface - status - Status of the operation - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; - CsrResult status; -} CsrWifiRouterMaPacketUnsubscribeCfm; - -/******************************************************************************* - - NAME - CsrWifiRouterMaPacketCfm - - DESCRIPTION - The router sends the primitive to confirm the result of the transmission - of the packet of the corresponding CSR_WIFI_ROUTER MA_PACKET_REQ request. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - Interface Identifier; unique identifier of an interface - result - Status of the operation - hostTag - The hostTrag will match the hostTag sent in the request. - rate - Transmission/Reception rate - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; - CsrResult result; - u32 hostTag; - u16 rate; -} CsrWifiRouterMaPacketCfm; - -/******************************************************************************* - - NAME - CsrWifiRouterMaPacketInd - - DESCRIPTION - The router sends the primitive to a subscribed task when it receives a - frame matching the subscription. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - Interface Identifier; unique identifier of an interface - subscriptionHandle - The handle of the subscription - result - Status of the operation - frameLength - Length of the received frame in bytes - frame - Pointer to the received frame - freeFunction - Pointer to function to be used to free the frame - rssi - Received signal strength indication in dBm - snr - Signal to Noise Ratio - rate - Transmission/Reception rate - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; - u8 subscriptionHandle; - CsrResult result; - u16 frameLength; - u8 *frame; - CsrWifiRouterFrameFreeFunction freeFunction; - s16 rssi; - s16 snr; - u16 rate; -} CsrWifiRouterMaPacketInd; - -#endif /* CSR_WIFI_ROUTER_PRIM_H__ */ - diff --git a/drivers/staging/csr/csr_wifi_router_sef.c b/drivers/staging/csr/csr_wifi_router_sef.c deleted file mode 100644 index 45a10fb77296..000000000000 --- a/drivers/staging/csr/csr_wifi_router_sef.c +++ /dev/null @@ -1,19 +0,0 @@ -/***************************************************************************** - - (c) Cambridge Silicon Radio Limited 2010 - Confidential information of CSR - - Refer to LICENSE.txt included with this source for details - on the license terms. - - *****************************************************************************/ -#include "csr_wifi_router_sef.h" - -const CsrWifiRouterStateHandlerType CsrWifiRouterDownstreamStateHandlers[CSR_WIFI_ROUTER_PRIM_DOWNSTREAM_COUNT] = -{ - /* 0x0000 */ CsrWifiRouterMaPacketSubscribeReqHandler, - /* 0x0001 */ CsrWifiRouterMaPacketUnsubscribeReqHandler, - /* 0x0002 */ CsrWifiRouterMaPacketReqHandler, - /* 0x0003 */ CsrWifiRouterMaPacketResHandler, - /* 0x0004 */ CsrWifiRouterMaPacketCancelReqHandler, -}; diff --git a/drivers/staging/csr/csr_wifi_router_sef.h b/drivers/staging/csr/csr_wifi_router_sef.h deleted file mode 100644 index 86692c7780c9..000000000000 --- a/drivers/staging/csr/csr_wifi_router_sef.h +++ /dev/null @@ -1,25 +0,0 @@ -/***************************************************************************** - - (c) Cambridge Silicon Radio Limited 2010 - Confidential information of CSR - - Refer to LICENSE.txt included with this source for details - on the license terms. - - *****************************************************************************/ -#ifndef CSR_WIFI_ROUTER_SEF_CSR_WIFI_ROUTER_H__ -#define CSR_WIFI_ROUTER_SEF_CSR_WIFI_ROUTER_H__ - -#include "csr_wifi_router_prim.h" - - typedef void (*CsrWifiRouterStateHandlerType)(void* drvpriv, CsrWifiFsmEvent* msg); - - extern const CsrWifiRouterStateHandlerType CsrWifiRouterDownstreamStateHandlers[CSR_WIFI_ROUTER_PRIM_DOWNSTREAM_COUNT]; - - extern void CsrWifiRouterMaPacketSubscribeReqHandler(void* drvpriv, CsrWifiFsmEvent* msg); - extern void CsrWifiRouterMaPacketUnsubscribeReqHandler(void* drvpriv, CsrWifiFsmEvent* msg); - extern void CsrWifiRouterMaPacketReqHandler(void* drvpriv, CsrWifiFsmEvent* msg); - extern void CsrWifiRouterMaPacketResHandler(void* drvpriv, CsrWifiFsmEvent* msg); - extern void CsrWifiRouterMaPacketCancelReqHandler(void* drvpriv, CsrWifiFsmEvent* msg); - -#endif /* CSR_WIFI_ROUTER_SEF_CSR_WIFI_ROUTER_H__ */ diff --git a/drivers/staging/csr/csr_wifi_router_serialize.c b/drivers/staging/csr/csr_wifi_router_serialize.c deleted file mode 100644 index 4eccf5d6c289..000000000000 --- a/drivers/staging/csr/csr_wifi_router_serialize.c +++ /dev/null @@ -1,418 +0,0 @@ -/***************************************************************************** - - (c) Cambridge Silicon Radio Limited 2011 - All rights reserved and confidential information of CSR - - Refer to LICENSE.txt included with this source for details - on the license terms. - -*****************************************************************************/ - -/* Note: this is an auto-generated file. */ -#include -#include "csr_msgconv.h" -#include "csr_wifi_router_prim.h" -#include "csr_wifi_router_serialize.h" - -void CsrWifiRouterPfree(void *ptr) -{ - kfree(ptr); -} - - -size_t CsrWifiRouterMaPacketSubscribeReqSizeof(void *msg) -{ - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 12) */ - bufferSize += 2; /* u16 primitive->interfaceTag */ - bufferSize += 1; /* CsrWifiRouterEncapsulation primitive->encapsulation */ - bufferSize += 2; /* u16 primitive->protocol */ - bufferSize += 4; /* u32 primitive->oui */ - return bufferSize; -} - - -u8* CsrWifiRouterMaPacketSubscribeReqSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiRouterMaPacketSubscribeReq *primitive = (CsrWifiRouterMaPacketSubscribeReq *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag); - CsrUint8Ser(ptr, len, (u8) primitive->encapsulation); - CsrUint16Ser(ptr, len, (u16) primitive->protocol); - CsrUint32Ser(ptr, len, (u32) primitive->oui); - return(ptr); -} - - -void* CsrWifiRouterMaPacketSubscribeReqDes(u8 *buffer, size_t length) -{ - CsrWifiRouterMaPacketSubscribeReq *primitive = kmalloc(sizeof(CsrWifiRouterMaPacketSubscribeReq), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset); - CsrUint8Des((u8 *) &primitive->encapsulation, buffer, &offset); - CsrUint16Des((u16 *) &primitive->protocol, buffer, &offset); - CsrUint32Des((u32 *) &primitive->oui, buffer, &offset); - - return primitive; -} - - -size_t CsrWifiRouterMaPacketReqSizeof(void *msg) -{ - CsrWifiRouterMaPacketReq *primitive = (CsrWifiRouterMaPacketReq *) msg; - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 20) */ - bufferSize += 2; /* u16 primitive->interfaceTag */ - bufferSize += 1; /* u8 primitive->subscriptionHandle */ - bufferSize += 2; /* u16 primitive->frameLength */ - bufferSize += primitive->frameLength; /* u8 primitive->frame */ - bufferSize += 4; /* CsrWifiRouterFrameFreeFunction primitive->freeFunction */ - bufferSize += 2; /* CsrWifiRouterPriority primitive->priority */ - bufferSize += 4; /* u32 primitive->hostTag */ - bufferSize += 1; /* u8 primitive->cfmRequested */ - return bufferSize; -} - - -u8* CsrWifiRouterMaPacketReqSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiRouterMaPacketReq *primitive = (CsrWifiRouterMaPacketReq *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag); - CsrUint8Ser(ptr, len, (u8) primitive->subscriptionHandle); - CsrUint16Ser(ptr, len, (u16) primitive->frameLength); - if (primitive->frameLength) - { - CsrMemCpySer(ptr, len, (const void *) primitive->frame, ((u16) (primitive->frameLength))); - } - CsrUint32Ser(ptr, len, 0); /* Special for Function Pointers... primitive->freeFunction */ - CsrUint16Ser(ptr, len, (u16) primitive->priority); - CsrUint32Ser(ptr, len, (u32) primitive->hostTag); - CsrUint8Ser(ptr, len, (u8) primitive->cfmRequested); - return(ptr); -} - - -void* CsrWifiRouterMaPacketReqDes(u8 *buffer, size_t length) -{ - CsrWifiRouterMaPacketReq *primitive = kmalloc(sizeof(CsrWifiRouterMaPacketReq), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset); - CsrUint8Des((u8 *) &primitive->subscriptionHandle, buffer, &offset); - CsrUint16Des((u16 *) &primitive->frameLength, buffer, &offset); - if (primitive->frameLength) - { - primitive->frame = kmalloc(primitive->frameLength, GFP_KERNEL); - CsrMemCpyDes(primitive->frame, buffer, &offset, ((u16) (primitive->frameLength))); - } - else - { - primitive->frame = NULL; - } - primitive->freeFunction = NULL; /* Special for Function Pointers... */ - offset += 4; - CsrUint16Des((u16 *) &primitive->priority, buffer, &offset); - CsrUint32Des((u32 *) &primitive->hostTag, buffer, &offset); - CsrUint8Des((u8 *) &primitive->cfmRequested, buffer, &offset); - - return primitive; -} - - -void CsrWifiRouterMaPacketReqSerFree(void *voidPrimitivePointer) -{ - CsrWifiRouterMaPacketReq *primitive = (CsrWifiRouterMaPacketReq *) voidPrimitivePointer; - kfree(primitive->frame); - kfree(primitive); -} - - -size_t CsrWifiRouterMaPacketResSizeof(void *msg) -{ - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 8) */ - bufferSize += 2; /* u16 primitive->interfaceTag */ - bufferSize += 1; /* u8 primitive->subscriptionHandle */ - bufferSize += 2; /* CsrResult primitive->result */ - return bufferSize; -} - - -u8* CsrWifiRouterMaPacketResSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiRouterMaPacketRes *primitive = (CsrWifiRouterMaPacketRes *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag); - CsrUint8Ser(ptr, len, (u8) primitive->subscriptionHandle); - CsrUint16Ser(ptr, len, (u16) primitive->result); - return(ptr); -} - - -void* CsrWifiRouterMaPacketResDes(u8 *buffer, size_t length) -{ - CsrWifiRouterMaPacketRes *primitive = kmalloc(sizeof(CsrWifiRouterMaPacketRes), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset); - CsrUint8Des((u8 *) &primitive->subscriptionHandle, buffer, &offset); - CsrUint16Des((u16 *) &primitive->result, buffer, &offset); - - return primitive; -} - - -size_t CsrWifiRouterMaPacketCancelReqSizeof(void *msg) -{ - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 17) */ - bufferSize += 2; /* u16 primitive->interfaceTag */ - bufferSize += 4; /* u32 primitive->hostTag */ - bufferSize += 2; /* CsrWifiRouterPriority primitive->priority */ - bufferSize += 6; /* u8 primitive->peerMacAddress.a[6] */ - return bufferSize; -} - - -u8* CsrWifiRouterMaPacketCancelReqSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiRouterMaPacketCancelReq *primitive = (CsrWifiRouterMaPacketCancelReq *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag); - CsrUint32Ser(ptr, len, (u32) primitive->hostTag); - CsrUint16Ser(ptr, len, (u16) primitive->priority); - CsrMemCpySer(ptr, len, (const void *) primitive->peerMacAddress.a, ((u16) (6))); - return(ptr); -} - - -void* CsrWifiRouterMaPacketCancelReqDes(u8 *buffer, size_t length) -{ - CsrWifiRouterMaPacketCancelReq *primitive = kmalloc(sizeof(CsrWifiRouterMaPacketCancelReq), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset); - CsrUint32Des((u32 *) &primitive->hostTag, buffer, &offset); - CsrUint16Des((u16 *) &primitive->priority, buffer, &offset); - CsrMemCpyDes(primitive->peerMacAddress.a, buffer, &offset, ((u16) (6))); - - return primitive; -} - - -size_t CsrWifiRouterMaPacketSubscribeCfmSizeof(void *msg) -{ - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 10) */ - bufferSize += 2; /* u16 primitive->interfaceTag */ - bufferSize += 1; /* u8 primitive->subscriptionHandle */ - bufferSize += 2; /* CsrResult primitive->status */ - bufferSize += 2; /* u16 primitive->allocOffset */ - return bufferSize; -} - - -u8* CsrWifiRouterMaPacketSubscribeCfmSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiRouterMaPacketSubscribeCfm *primitive = (CsrWifiRouterMaPacketSubscribeCfm *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag); - CsrUint8Ser(ptr, len, (u8) primitive->subscriptionHandle); - CsrUint16Ser(ptr, len, (u16) primitive->status); - CsrUint16Ser(ptr, len, (u16) primitive->allocOffset); - return(ptr); -} - - -void* CsrWifiRouterMaPacketSubscribeCfmDes(u8 *buffer, size_t length) -{ - CsrWifiRouterMaPacketSubscribeCfm *primitive = kmalloc(sizeof(CsrWifiRouterMaPacketSubscribeCfm), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset); - CsrUint8Des((u8 *) &primitive->subscriptionHandle, buffer, &offset); - CsrUint16Des((u16 *) &primitive->status, buffer, &offset); - CsrUint16Des((u16 *) &primitive->allocOffset, buffer, &offset); - - return primitive; -} - - -size_t CsrWifiRouterMaPacketUnsubscribeCfmSizeof(void *msg) -{ - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 7) */ - bufferSize += 2; /* u16 primitive->interfaceTag */ - bufferSize += 2; /* CsrResult primitive->status */ - return bufferSize; -} - - -u8* CsrWifiRouterMaPacketUnsubscribeCfmSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiRouterMaPacketUnsubscribeCfm *primitive = (CsrWifiRouterMaPacketUnsubscribeCfm *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag); - CsrUint16Ser(ptr, len, (u16) primitive->status); - return(ptr); -} - - -void* CsrWifiRouterMaPacketUnsubscribeCfmDes(u8 *buffer, size_t length) -{ - CsrWifiRouterMaPacketUnsubscribeCfm *primitive = kmalloc(sizeof(CsrWifiRouterMaPacketUnsubscribeCfm), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset); - CsrUint16Des((u16 *) &primitive->status, buffer, &offset); - - return primitive; -} - - -size_t CsrWifiRouterMaPacketCfmSizeof(void *msg) -{ - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 13) */ - bufferSize += 2; /* u16 primitive->interfaceTag */ - bufferSize += 2; /* CsrResult primitive->result */ - bufferSize += 4; /* u32 primitive->hostTag */ - bufferSize += 2; /* u16 primitive->rate */ - return bufferSize; -} - - -u8* CsrWifiRouterMaPacketCfmSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiRouterMaPacketCfm *primitive = (CsrWifiRouterMaPacketCfm *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag); - CsrUint16Ser(ptr, len, (u16) primitive->result); - CsrUint32Ser(ptr, len, (u32) primitive->hostTag); - CsrUint16Ser(ptr, len, (u16) primitive->rate); - return(ptr); -} - - -void* CsrWifiRouterMaPacketCfmDes(u8 *buffer, size_t length) -{ - CsrWifiRouterMaPacketCfm *primitive = kmalloc(sizeof(CsrWifiRouterMaPacketCfm), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset); - CsrUint16Des((u16 *) &primitive->result, buffer, &offset); - CsrUint32Des((u32 *) &primitive->hostTag, buffer, &offset); - CsrUint16Des((u16 *) &primitive->rate, buffer, &offset); - - return primitive; -} - - -size_t CsrWifiRouterMaPacketIndSizeof(void *msg) -{ - CsrWifiRouterMaPacketInd *primitive = (CsrWifiRouterMaPacketInd *) msg; - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 21) */ - bufferSize += 2; /* u16 primitive->interfaceTag */ - bufferSize += 1; /* u8 primitive->subscriptionHandle */ - bufferSize += 2; /* CsrResult primitive->result */ - bufferSize += 2; /* u16 primitive->frameLength */ - bufferSize += primitive->frameLength; /* u8 primitive->frame */ - bufferSize += 4; /* CsrWifiRouterFrameFreeFunction primitive->freeFunction */ - bufferSize += 2; /* s16 primitive->rssi */ - bufferSize += 2; /* s16 primitive->snr */ - bufferSize += 2; /* u16 primitive->rate */ - return bufferSize; -} - - -u8* CsrWifiRouterMaPacketIndSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiRouterMaPacketInd *primitive = (CsrWifiRouterMaPacketInd *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag); - CsrUint8Ser(ptr, len, (u8) primitive->subscriptionHandle); - CsrUint16Ser(ptr, len, (u16) primitive->result); - CsrUint16Ser(ptr, len, (u16) primitive->frameLength); - if (primitive->frameLength) - { - CsrMemCpySer(ptr, len, (const void *) primitive->frame, ((u16) (primitive->frameLength))); - } - CsrUint32Ser(ptr, len, 0); /* Special for Function Pointers... primitive->freeFunction */ - CsrUint16Ser(ptr, len, (u16) primitive->rssi); - CsrUint16Ser(ptr, len, (u16) primitive->snr); - CsrUint16Ser(ptr, len, (u16) primitive->rate); - return(ptr); -} - - -void* CsrWifiRouterMaPacketIndDes(u8 *buffer, size_t length) -{ - CsrWifiRouterMaPacketInd *primitive = kmalloc(sizeof(CsrWifiRouterMaPacketInd), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset); - CsrUint8Des((u8 *) &primitive->subscriptionHandle, buffer, &offset); - CsrUint16Des((u16 *) &primitive->result, buffer, &offset); - CsrUint16Des((u16 *) &primitive->frameLength, buffer, &offset); - if (primitive->frameLength) - { - primitive->frame = kmalloc(primitive->frameLength, GFP_KERNEL); - CsrMemCpyDes(primitive->frame, buffer, &offset, ((u16) (primitive->frameLength))); - } - else - { - primitive->frame = NULL; - } - primitive->freeFunction = NULL; /* Special for Function Pointers... */ - offset += 4; - CsrUint16Des((u16 *) &primitive->rssi, buffer, &offset); - CsrUint16Des((u16 *) &primitive->snr, buffer, &offset); - CsrUint16Des((u16 *) &primitive->rate, buffer, &offset); - - return primitive; -} - - -void CsrWifiRouterMaPacketIndSerFree(void *voidPrimitivePointer) -{ - CsrWifiRouterMaPacketInd *primitive = (CsrWifiRouterMaPacketInd *) voidPrimitivePointer; - kfree(primitive->frame); - kfree(primitive); -} - - diff --git a/drivers/staging/csr/csr_wifi_router_serialize.h b/drivers/staging/csr/csr_wifi_router_serialize.h deleted file mode 100644 index 94ccdac5606f..000000000000 --- a/drivers/staging/csr/csr_wifi_router_serialize.h +++ /dev/null @@ -1,67 +0,0 @@ -/***************************************************************************** - - (c) Cambridge Silicon Radio Limited 2011 - All rights reserved and confidential information of CSR - - Refer to LICENSE.txt included with this source for details - on the license terms. - -*****************************************************************************/ - -/* Note: this is an auto-generated file. */ - -#ifndef CSR_WIFI_ROUTER_SERIALIZE_H__ -#define CSR_WIFI_ROUTER_SERIALIZE_H__ - -#include "csr_wifi_msgconv.h" -#include "csr_wifi_router_prim.h" - -extern void CsrWifiRouterPfree(void *ptr); - -extern u8* CsrWifiRouterMaPacketSubscribeReqSer(u8 *ptr, size_t *len, void *msg); -extern void* CsrWifiRouterMaPacketSubscribeReqDes(u8 *buffer, size_t len); -extern size_t CsrWifiRouterMaPacketSubscribeReqSizeof(void *msg); -#define CsrWifiRouterMaPacketSubscribeReqSerFree CsrWifiRouterPfree - -#define CsrWifiRouterMaPacketUnsubscribeReqSer CsrWifiEventCsrUint16CsrUint8Ser -#define CsrWifiRouterMaPacketUnsubscribeReqDes CsrWifiEventCsrUint16CsrUint8Des -#define CsrWifiRouterMaPacketUnsubscribeReqSizeof CsrWifiEventCsrUint16CsrUint8Sizeof -#define CsrWifiRouterMaPacketUnsubscribeReqSerFree CsrWifiRouterPfree - -extern u8* CsrWifiRouterMaPacketReqSer(u8 *ptr, size_t *len, void *msg); -extern void* CsrWifiRouterMaPacketReqDes(u8 *buffer, size_t len); -extern size_t CsrWifiRouterMaPacketReqSizeof(void *msg); -extern void CsrWifiRouterMaPacketReqSerFree(void *msg); - -extern u8* CsrWifiRouterMaPacketResSer(u8 *ptr, size_t *len, void *msg); -extern void* CsrWifiRouterMaPacketResDes(u8 *buffer, size_t len); -extern size_t CsrWifiRouterMaPacketResSizeof(void *msg); -#define CsrWifiRouterMaPacketResSerFree CsrWifiRouterPfree - -extern u8* CsrWifiRouterMaPacketCancelReqSer(u8 *ptr, size_t *len, void *msg); -extern void* CsrWifiRouterMaPacketCancelReqDes(u8 *buffer, size_t len); -extern size_t CsrWifiRouterMaPacketCancelReqSizeof(void *msg); -#define CsrWifiRouterMaPacketCancelReqSerFree CsrWifiRouterPfree - -extern u8* CsrWifiRouterMaPacketSubscribeCfmSer(u8 *ptr, size_t *len, void *msg); -extern void* CsrWifiRouterMaPacketSubscribeCfmDes(u8 *buffer, size_t len); -extern size_t CsrWifiRouterMaPacketSubscribeCfmSizeof(void *msg); -#define CsrWifiRouterMaPacketSubscribeCfmSerFree CsrWifiRouterPfree - -extern u8* CsrWifiRouterMaPacketUnsubscribeCfmSer(u8 *ptr, size_t *len, void *msg); -extern void* CsrWifiRouterMaPacketUnsubscribeCfmDes(u8 *buffer, size_t len); -extern size_t CsrWifiRouterMaPacketUnsubscribeCfmSizeof(void *msg); -#define CsrWifiRouterMaPacketUnsubscribeCfmSerFree CsrWifiRouterPfree - -extern u8* CsrWifiRouterMaPacketCfmSer(u8 *ptr, size_t *len, void *msg); -extern void* CsrWifiRouterMaPacketCfmDes(u8 *buffer, size_t len); -extern size_t CsrWifiRouterMaPacketCfmSizeof(void *msg); -#define CsrWifiRouterMaPacketCfmSerFree CsrWifiRouterPfree - -extern u8* CsrWifiRouterMaPacketIndSer(u8 *ptr, size_t *len, void *msg); -extern void* CsrWifiRouterMaPacketIndDes(u8 *buffer, size_t len); -extern size_t CsrWifiRouterMaPacketIndSizeof(void *msg); -extern void CsrWifiRouterMaPacketIndSerFree(void *msg); - -#endif /* CSR_WIFI_ROUTER_SERIALIZE_H__ */ - diff --git a/drivers/staging/csr/csr_wifi_router_task.h b/drivers/staging/csr/csr_wifi_router_task.h deleted file mode 100644 index 9ba892f34e6d..000000000000 --- a/drivers/staging/csr/csr_wifi_router_task.h +++ /dev/null @@ -1,25 +0,0 @@ -/***************************************************************************** - - (c) Cambridge Silicon Radio Limited 2011 - All rights reserved and confidential information of CSR - - Refer to LICENSE.txt included with this source for details - on the license terms. - -*****************************************************************************/ - -/* Note: this is an auto-generated file. */ - -#ifndef CSR_WIFI_ROUTER_TASK_H__ -#define CSR_WIFI_ROUTER_TASK_H__ - -#include "csr_sched.h" - -#define CSR_WIFI_ROUTER_LOG_ID 0x1201FFFF -extern CsrSchedQid CSR_WIFI_ROUTER_IFACEQUEUE; -void CsrWifiRouterInit(void **gash); -void CsrWifiRouterDeinit(void **gash); -void CsrWifiRouterHandler(void **gash); - -#endif /* CSR_WIFI_ROUTER_TASK_H__ */ - diff --git a/drivers/staging/csr/csr_wifi_router_transport.c b/drivers/staging/csr/csr_wifi_router_transport.c deleted file mode 100644 index e905ead9389b..000000000000 --- a/drivers/staging/csr/csr_wifi_router_transport.c +++ /dev/null @@ -1,199 +0,0 @@ -/** @file router_transport.c - * - * - * Copyright (C) Cambridge Silicon Radio Ltd 2006-2010. All rights reserved. - * - * Refer to LICENSE.txt included with this source code for details on - * the license terms. - * - ****************************************************************************/ - -#include "unifi_priv.h" - -#include "csr_sched.h" -#include "csr_msgconv.h" - -#include "sme_userspace.h" - -#include "csr_wifi_hostio_prim.h" -#include "csr_wifi_router_lib.h" -#include "csr_wifi_router_sef.h" -#include "csr_wifi_router_converter_init.h" -#include "csr_wifi_router_ctrl_lib.h" -#include "csr_wifi_router_ctrl_sef.h" -#include "csr_wifi_router_ctrl_converter_init.h" -#include "csr_wifi_sme_prim.h" -#include "csr_wifi_sme_sef.h" -#include "csr_wifi_sme_converter_init.h" -#ifdef CSR_SUPPORT_WEXT -#ifdef CSR_SUPPORT_WEXT_AP -#include "csr_wifi_nme_ap_prim.h" -#include "csr_wifi_nme_ap_sef.h" -#include "csr_wifi_nme_ap_converter_init.h" -#endif -#endif - -static unifi_priv_t *drvpriv = NULL; -void CsrWifiRouterTransportInit(unifi_priv_t *priv) -{ - unifi_trace(priv, UDBG1, "CsrWifiRouterTransportInit: \n"); - - drvpriv = priv; - (void)CsrMsgConvInit(); - CsrWifiRouterConverterInit(); - CsrWifiRouterCtrlConverterInit(); - CsrWifiSmeConverterInit(); -#ifdef CSR_SUPPORT_WEXT -#ifdef CSR_SUPPORT_WEXT_AP - CsrWifiNmeApConverterInit(); -#endif -#endif -} - -void CsrWifiRouterTransportRecv(unifi_priv_t *priv, u8* buffer, size_t bufferLength) -{ - CsrMsgConvMsgEntry* msgEntry; - u16 primType; - CsrSchedQid src; - CsrSchedQid dest; - u16 msgType; - size_t offset = 0; - CsrWifiFsmEvent* msg; - - /* Decode the prim and message type */ - CsrUint16Des(&primType, buffer, &offset); - CsrUint16Des(&src, buffer, &offset); - CsrUint16Des(&dest, buffer, &offset); - CsrUint16Des(&msgType, buffer, &offset); - offset -= 2; /* Adjust as the Deserialise Function will read this as well */ - - unifi_trace(priv, UDBG4, "CsrWifiRouterTransportRecv: primType=0x%.4X, msgType=0x%.4X, bufferLength=%d\n", - primType, msgType, bufferLength); - - /* Special handling for HOSTIO messages.... */ - if (primType == CSR_WIFI_HOSTIO_PRIM) - { - CsrWifiRouterCtrlHipReq req = {{CSR_WIFI_ROUTER_CTRL_HIP_REQ, CSR_WIFI_ROUTER_CTRL_PRIM, dest, src, NULL}, 0, NULL, 0, NULL, 0, NULL}; - - req.mlmeCommandLength = bufferLength; - req.mlmeCommand = buffer; - - offset += 8;/* Skip the id, src, dest and slot number */ - CsrUint16Des(&req.dataRef1Length, buffer, &offset); - offset += 2; /* Skip the slot number */ - CsrUint16Des(&req.dataRef2Length, buffer, &offset); - - if (req.dataRef1Length) - { - u16 dr1Offset = (bufferLength - req.dataRef2Length) - req.dataRef1Length; - req.dataRef1 = &buffer[dr1Offset]; - } - - if (req.dataRef2Length) - { - u16 dr2Offset = bufferLength - req.dataRef2Length; - req.dataRef2 = &buffer[dr2Offset]; - } - - /* Copy the hip data but strip off the prim type */ - req.mlmeCommandLength -= (req.dataRef1Length + req.dataRef2Length + 6); - req.mlmeCommand = &buffer[6]; - - CsrWifiRouterCtrlHipReqHandler(priv, &req.common); - return; - } - - msgEntry = CsrMsgConvFindEntry(primType, msgType); - if (!msgEntry) - { - unifi_error(priv, "CsrWifiRouterTransportDeserialiseAndSend can not process the message. primType=0x%.4X, msgType=0x%.4X\n", - primType, msgType); - dump(buffer, bufferLength); - return; - } - - msg = (CsrWifiFsmEvent*)(msgEntry->deserFunc)(&buffer[offset], bufferLength - offset); - - msg->primtype = primType; - msg->type = msgType; - msg->source = src; - msg->destination = dest; - - switch(primType) - { - case CSR_WIFI_ROUTER_CTRL_PRIM: - CsrWifiRouterCtrlDownstreamStateHandlers[msg->type - CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST](priv, msg); - CsrWifiRouterCtrlFreeDownstreamMessageContents(CSR_WIFI_ROUTER_CTRL_PRIM, msg); - break; - case CSR_WIFI_ROUTER_PRIM: - CsrWifiRouterDownstreamStateHandlers[msg->type - CSR_WIFI_ROUTER_PRIM_DOWNSTREAM_LOWEST](priv, msg); - CsrWifiRouterFreeDownstreamMessageContents(CSR_WIFI_ROUTER_PRIM, msg); - break; - case CSR_WIFI_SME_PRIM: - CsrWifiSmeUpstreamStateHandlers[msg->type - CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST](priv, msg); - CsrWifiSmeFreeUpstreamMessageContents(CSR_WIFI_SME_PRIM, msg); - break; -#ifdef CSR_SUPPORT_WEXT -#ifdef CSR_SUPPORT_WEXT_AP - case CSR_WIFI_NME_AP_PRIM: - CsrWifiNmeApUpstreamStateHandlers(priv, msg); - CsrWifiNmeApFreeUpstreamMessageContents(CSR_WIFI_NME_AP_PRIM, msg); - break; -#endif -#endif - default: - unifi_error(priv, "CsrWifiRouterTransportDeserialiseAndSend unhandled prim type 0x%.4X\n", primType); - break; - } - kfree(msg); -} - -static void CsrWifiRouterTransportSerialiseAndSend(u16 primType, void* msg) -{ - CsrWifiFsmEvent* evt = (CsrWifiFsmEvent*)msg; - CsrMsgConvMsgEntry* msgEntry; - size_t msgSize; - size_t encodeBufferLen = 0; - size_t offset = 0; - u8* encodeBuffer; - - unifi_trace(drvpriv, UDBG4, "CsrWifiRouterTransportSerialiseAndSend: primType=0x%.4X, msgType=0x%.4X\n", - primType, evt->type); - - msgEntry = CsrMsgConvFindEntry(primType, evt->type); - if (!msgEntry) - { - unifi_error(drvpriv, "CsrWifiRouterTransportSerialiseAndSend can not process the message. primType=0x%.4X, msgType=0x%.4X\n", - primType, evt->type); - return; - } - - msgSize = 6 + (msgEntry->sizeofFunc)((void*)msg); - - encodeBuffer = kmalloc(msgSize, GFP_KERNEL); - - /* Encode PrimType */ - CsrUint16Ser(encodeBuffer, &encodeBufferLen, primType); - CsrUint16Ser(encodeBuffer, &encodeBufferLen, evt->source); - CsrUint16Ser(encodeBuffer, &encodeBufferLen, evt->destination); - - (void)(msgEntry->serFunc)(&encodeBuffer[encodeBufferLen], &offset, msg); - encodeBufferLen += offset; - - uf_sme_queue_message(drvpriv, encodeBuffer, encodeBufferLen); - - /* Do not use msgEntry->freeFunc because the memory is owned by the driver */ - kfree(msg); -} - -#if defined(CSR_LOG_ENABLE) && defined(CSR_LOG_INCLUDE_FILE_NAME_AND_LINE_NUMBER) -void CsrSchedMessagePutStringLog(CsrSchedQid q, u16 mi, void *mv, u32 line, char *file) -#else -void CsrSchedMessagePut(CsrSchedQid q, u16 mi, void *mv) -#endif -{ - CsrWifiFsmEvent* evt = (CsrWifiFsmEvent*)mv; - evt->destination = q; - CsrWifiRouterTransportSerialiseAndSend(mi, mv); -} - diff --git a/drivers/staging/csr/csr_wifi_serialize_primitive_types.c b/drivers/staging/csr/csr_wifi_serialize_primitive_types.c deleted file mode 100644 index dd93d0061190..000000000000 --- a/drivers/staging/csr/csr_wifi_serialize_primitive_types.c +++ /dev/null @@ -1,256 +0,0 @@ -/***************************************************************************** - - (c) Cambridge Silicon Radio Limited 2011 - All rights reserved and confidential information of CSR - - Refer to LICENSE.txt included with this source for details - on the license terms. - -*****************************************************************************/ - -#include -#include -#include "csr_macro.h" -#include "csr_msgconv.h" -#include "csr_wifi_msgconv.h" -#include "csr_wifi_lib.h" - -void CsrUint24Des(u32 *v, u8 *buffer, size_t *offset) -{ - u32 val; - - val = ((buffer[(*offset) + 2] << 16) | - (buffer[(*offset) + 1] << 8) | - (buffer[(*offset)])); - - *offset += 3; - *v = val; -} - - -/* Big endian :e.g WSC, TCLAS */ -void CsrUint16DesBigEndian(u16 *v, u8 *buffer, size_t *offset) -{ - u16 val; - - val = (buffer[(*offset)] << 8) | (buffer[(*offset) + 1]); - *offset += 2; - - *v = val; -} - - -void CsrUint24DesBigEndian(u32 *v, u8 *buffer, size_t *offset) -{ - u32 val; - - val = ((buffer[(*offset)] << 16) | - (buffer[(*offset) + 1] << 8) | - (buffer[(*offset) + 2])); - - *offset += 3; - *v = val; -} - - -void CsrUint32DesBigEndian(u32 *v, u8 *buffer, size_t *offset) -{ - u32 val; - - val = ((buffer[(*offset)] << 24) | - (buffer[(*offset) + 1] << 16) | - (buffer[(*offset) + 2] << 8) | - (buffer[(*offset) + 3])); - - *offset += 4; - *v = val; -} - - -void CsrUint24Ser(u8 *ptr, size_t *len, u32 v) -{ - ptr[(*len) + 2] = (u8)((v & 0x00ff0000) >> 16); - ptr[(*len) + 1] = (u8)((v & 0x0000ff00) >> 8); - ptr[(*len)] = (u8)((v & 0x000000ff)); - - *len += 3; -} - - -/* Big endian :e.g WSC, TCLAS */ -void CsrUint16SerBigEndian(u8 *ptr, size_t *len, u16 v) -{ - ptr[(*len)] = (u8)((v & 0xff00) >> 8); - ptr[(*len) + 1] = (u8)((v & 0x00ff)); - - *len += 2; -} - - -void CsrUint32SerBigEndian(u8 *ptr, size_t *len, u32 v) -{ - ptr[(*len)] = (u8)((v & 0xff000000) >> 24); - ptr[(*len) + 1] = (u8)((v & 0x00ff0000) >> 16); - ptr[(*len) + 2] = (u8)((v & 0x0000ff00) >> 8); - ptr[(*len) + 3] = (u8)((v & 0x000000ff)); - - *len += 4; -} - - -void CsrUint24SerBigEndian(u8 *ptr, size_t *len, u32 v) -{ - ptr[(*len)] = (u8)((v & 0x00ff0000) >> 16); - ptr[(*len) + 1] = (u8)((v & 0x0000ff00) >> 8); - ptr[(*len) + 2] = (u8)((v & 0x000000ff)); - - *len += 3; -} - - -size_t CsrWifiEventSizeof(void *msg) -{ - return 2; -} -EXPORT_SYMBOL_GPL(CsrWifiEventSizeof); - -u8* CsrWifiEventSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiFsmEvent *primitive = (CsrWifiFsmEvent *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->type); - return(ptr); -} -EXPORT_SYMBOL_GPL(CsrWifiEventSer); - -void* CsrWifiEventDes(u8 *buffer, size_t length) -{ - CsrWifiFsmEvent *primitive = kmalloc(sizeof(CsrWifiFsmEvent), GFP_KERNEL); - size_t offset = 0; - CsrUint16Des(&primitive->type, buffer, &offset); - - return primitive; -} -EXPORT_SYMBOL_GPL(CsrWifiEventDes); - -size_t CsrWifiEventCsrUint8Sizeof(void *msg) -{ - return 3; -} -EXPORT_SYMBOL_GPL(CsrWifiEventCsrUint8Sizeof); - -u8* CsrWifiEventCsrUint8Ser(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiEventCsrUint8 *primitive = (CsrWifiEventCsrUint8 *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint8Ser(ptr, len, primitive->value); - return(ptr); -} -EXPORT_SYMBOL_GPL(CsrWifiEventCsrUint8Ser); - - -void* CsrWifiEventCsrUint8Des(u8 *buffer, size_t length) -{ - CsrWifiEventCsrUint8 *primitive = kmalloc(sizeof(CsrWifiEventCsrUint8), GFP_KERNEL); - - size_t offset = 0; - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint8Des(&primitive->value, buffer, &offset); - - return primitive; -} -EXPORT_SYMBOL_GPL(CsrWifiEventCsrUint8Des); - - -size_t CsrWifiEventCsrUint16Sizeof(void *msg) -{ - return 4; -} -EXPORT_SYMBOL_GPL(CsrWifiEventCsrUint16Sizeof); - - -u8* CsrWifiEventCsrUint16Ser(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiEventCsrUint16 *primitive = (CsrWifiEventCsrUint16 *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, primitive->value); - return(ptr); -} -EXPORT_SYMBOL_GPL(CsrWifiEventCsrUint16Ser); - -void* CsrWifiEventCsrUint16Des(u8 *buffer, size_t length) -{ - CsrWifiEventCsrUint16 *primitive = kmalloc(sizeof(CsrWifiEventCsrUint16), GFP_KERNEL); - - size_t offset = 0; - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des(&primitive->value, buffer, &offset); - - return primitive; -} -EXPORT_SYMBOL_GPL(CsrWifiEventCsrUint16Des); - - -size_t CsrWifiEventCsrUint32Sizeof(void *msg) -{ - return 6; -} -EXPORT_SYMBOL_GPL(CsrWifiEventCsrUint32Sizeof); - -u8* CsrWifiEventCsrUint32Ser(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiEventCsrUint32 *primitive = (CsrWifiEventCsrUint32 *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint32Ser(ptr, len, primitive->value); - return(ptr); -} -EXPORT_SYMBOL_GPL(CsrWifiEventCsrUint32Ser); - - -void* CsrWifiEventCsrUint32Des(u8 *buffer, size_t length) -{ - CsrWifiEventCsrUint32 *primitive = kmalloc(sizeof(CsrWifiEventCsrUint32), GFP_KERNEL); - - size_t offset = 0; - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint32Des(&primitive->value, buffer, &offset); - - return primitive; -} -EXPORT_SYMBOL_GPL(CsrWifiEventCsrUint32Des); - -size_t CsrWifiEventCsrUint16CsrUint8Sizeof(void *msg) -{ - return 5; -} -EXPORT_SYMBOL_GPL(CsrWifiEventCsrUint16CsrUint8Sizeof); - -u8* CsrWifiEventCsrUint16CsrUint8Ser(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiEventCsrUint16CsrUint8 *primitive = (CsrWifiEventCsrUint16CsrUint8 *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, primitive->value16); - CsrUint8Ser(ptr, len, primitive->value8); - return(ptr); -} -EXPORT_SYMBOL_GPL(CsrWifiEventCsrUint16CsrUint8Ser); - - -void* CsrWifiEventCsrUint16CsrUint8Des(u8 *buffer, size_t length) -{ - CsrWifiEventCsrUint16CsrUint8 *primitive = kmalloc(sizeof(CsrWifiEventCsrUint16CsrUint8), GFP_KERNEL); - - size_t offset = 0; - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des(&primitive->value16, buffer, &offset); - CsrUint8Des(&primitive->value8, buffer, &offset); - - return primitive; -} -EXPORT_SYMBOL_GPL(CsrWifiEventCsrUint16CsrUint8Des); - - diff --git a/drivers/staging/csr/csr_wifi_sme_ap_lib.h b/drivers/staging/csr/csr_wifi_sme_ap_lib.h deleted file mode 100644 index 48ea9143f591..000000000000 --- a/drivers/staging/csr/csr_wifi_sme_ap_lib.h +++ /dev/null @@ -1,774 +0,0 @@ -/***************************************************************************** - - (c) Cambridge Silicon Radio Limited 2012 - All rights reserved and confidential information of CSR - - Refer to LICENSE.txt included with this source for details - on the license terms. - -*****************************************************************************/ - -/* Note: this is an auto-generated file. */ - -#ifndef CSR_WIFI_SME_AP_LIB_H__ -#define CSR_WIFI_SME_AP_LIB_H__ - -#include "csr_sched.h" -#include "csr_macro.h" -#include "csr_msg_transport.h" - -#include "csr_wifi_lib.h" - -#include "csr_wifi_sme_ap_prim.h" -#include "csr_wifi_sme_task.h" - -#ifndef CSR_WIFI_AP_ENABLE -#error CSR_WIFI_AP_ENABLE MUST be defined inorder to use csr_wifi_sme_ap_lib.h -#endif - -/*----------------------------------------------------------------------------* - * CsrWifiSmeApFreeUpstreamMessageContents - * - * DESCRIPTION - * Free the allocated memory in a CSR_WIFI_SME_AP upstream message. Does not - * free the message itself, and can only be used for upstream messages. - * - * PARAMETERS - * Deallocates the resources in a CSR_WIFI_SME_AP upstream message - *----------------------------------------------------------------------------*/ -void CsrWifiSmeApFreeUpstreamMessageContents(u16 eventClass, void *message); - -/*----------------------------------------------------------------------------* - * CsrWifiSmeApFreeDownstreamMessageContents - * - * DESCRIPTION - * Free the allocated memory in a CSR_WIFI_SME_AP downstream message. Does not - * free the message itself, and can only be used for downstream messages. - * - * PARAMETERS - * Deallocates the resources in a CSR_WIFI_SME_AP downstream message - *----------------------------------------------------------------------------*/ -void CsrWifiSmeApFreeDownstreamMessageContents(u16 eventClass, void *message); - -/*----------------------------------------------------------------------------* - * Enum to string functions - *----------------------------------------------------------------------------*/ -const char* CsrWifiSmeApAccessTypeToString(CsrWifiSmeApAccessType value); -const char* CsrWifiSmeApAuthSupportToString(CsrWifiSmeApAuthSupport value); -const char* CsrWifiSmeApAuthTypeToString(CsrWifiSmeApAuthType value); -const char* CsrWifiSmeApDirectionToString(CsrWifiSmeApDirection value); -const char* CsrWifiSmeApPhySupportToString(CsrWifiSmeApPhySupport value); -const char* CsrWifiSmeApTypeToString(CsrWifiSmeApType value); - - -/*----------------------------------------------------------------------------* - * CsrPrim Type toString function. - * Converts a message type to the String name of the Message - *----------------------------------------------------------------------------*/ -const char* CsrWifiSmeApPrimTypeToString(CsrPrim msgType); - -/*----------------------------------------------------------------------------* - * Lookup arrays for PrimType name Strings - *----------------------------------------------------------------------------*/ -extern const char *CsrWifiSmeApUpstreamPrimNames[CSR_WIFI_SME_AP_PRIM_UPSTREAM_COUNT]; -extern const char *CsrWifiSmeApDownstreamPrimNames[CSR_WIFI_SME_AP_PRIM_DOWNSTREAM_COUNT]; - -/******************************************************************************* - - NAME - CsrWifiSmeApActiveBaGetReqSend - - DESCRIPTION - This primitive used to retrieve information related to the active block - ack sessions - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - interfaceTag - - -*******************************************************************************/ -#define CsrWifiSmeApActiveBaGetReqCreate(msg__, dst__, src__, interfaceTag__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeApActiveBaGetReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_AP_PRIM, CSR_WIFI_SME_AP_ACTIVE_BA_GET_REQ, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); - -#define CsrWifiSmeApActiveBaGetReqSendTo(dst__, src__, interfaceTag__) \ - { \ - CsrWifiSmeApActiveBaGetReq *msg__; \ - CsrWifiSmeApActiveBaGetReqCreate(msg__, dst__, src__, interfaceTag__); \ - CsrMsgTransport(dst__, CSR_WIFI_SME_AP_PRIM, msg__); \ - } - -#define CsrWifiSmeApActiveBaGetReqSend(src__, interfaceTag__) \ - CsrWifiSmeApActiveBaGetReqSendTo(CSR_WIFI_SME_IFACEQUEUE, src__, interfaceTag__) - -/******************************************************************************* - - NAME - CsrWifiSmeApActiveBaGetCfmSend - - DESCRIPTION - This primitive carries the information related to the active ba sessions - - PARAMETERS - queue - Destination Task Queue - interfaceTag - - status - Reports the result of the request - activeBaCount - Number of active block ack session - activeBaSessions - Points to a buffer containing an array of - CsrWifiSmeApBaSession structures. - -*******************************************************************************/ -#define CsrWifiSmeApActiveBaGetCfmCreate(msg__, dst__, src__, interfaceTag__, status__, activeBaCount__, activeBaSessions__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeApActiveBaGetCfm), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_AP_PRIM, CSR_WIFI_SME_AP_ACTIVE_BA_GET_CFM, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->status = (status__); \ - msg__->activeBaCount = (activeBaCount__); \ - msg__->activeBaSessions = (activeBaSessions__); - -#define CsrWifiSmeApActiveBaGetCfmSendTo(dst__, src__, interfaceTag__, status__, activeBaCount__, activeBaSessions__) \ - { \ - CsrWifiSmeApActiveBaGetCfm *msg__; \ - CsrWifiSmeApActiveBaGetCfmCreate(msg__, dst__, src__, interfaceTag__, status__, activeBaCount__, activeBaSessions__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_SME_AP_PRIM, msg__); \ - } - -#define CsrWifiSmeApActiveBaGetCfmSend(dst__, interfaceTag__, status__, activeBaCount__, activeBaSessions__) \ - CsrWifiSmeApActiveBaGetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__, activeBaCount__, activeBaSessions__) - -/******************************************************************************* - - NAME - CsrWifiSmeApBaDeleteReqSend - - DESCRIPTION - This primitive is used to delete an active block ack session - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - interfaceTag - - reason - - baSession - BA session to be deleted - -*******************************************************************************/ -#define CsrWifiSmeApBaDeleteReqCreate(msg__, dst__, src__, interfaceTag__, reason__, baSession__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeApBaDeleteReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_AP_PRIM, CSR_WIFI_SME_AP_BA_DELETE_REQ, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->reason = (reason__); \ - msg__->baSession = (baSession__); - -#define CsrWifiSmeApBaDeleteReqSendTo(dst__, src__, interfaceTag__, reason__, baSession__) \ - { \ - CsrWifiSmeApBaDeleteReq *msg__; \ - CsrWifiSmeApBaDeleteReqCreate(msg__, dst__, src__, interfaceTag__, reason__, baSession__); \ - CsrMsgTransport(dst__, CSR_WIFI_SME_AP_PRIM, msg__); \ - } - -#define CsrWifiSmeApBaDeleteReqSend(src__, interfaceTag__, reason__, baSession__) \ - CsrWifiSmeApBaDeleteReqSendTo(CSR_WIFI_SME_IFACEQUEUE, src__, interfaceTag__, reason__, baSession__) - -/******************************************************************************* - - NAME - CsrWifiSmeApBaDeleteCfmSend - - DESCRIPTION - This primitive confirms the BA is deleted - - PARAMETERS - queue - Destination Task Queue - interfaceTag - - status - Reports the result of the request - baSession - deleted BA session - -*******************************************************************************/ -#define CsrWifiSmeApBaDeleteCfmCreate(msg__, dst__, src__, interfaceTag__, status__, baSession__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeApBaDeleteCfm), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_AP_PRIM, CSR_WIFI_SME_AP_BA_DELETE_CFM, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->status = (status__); \ - msg__->baSession = (baSession__); - -#define CsrWifiSmeApBaDeleteCfmSendTo(dst__, src__, interfaceTag__, status__, baSession__) \ - { \ - CsrWifiSmeApBaDeleteCfm *msg__; \ - CsrWifiSmeApBaDeleteCfmCreate(msg__, dst__, src__, interfaceTag__, status__, baSession__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_SME_AP_PRIM, msg__); \ - } - -#define CsrWifiSmeApBaDeleteCfmSend(dst__, interfaceTag__, status__, baSession__) \ - CsrWifiSmeApBaDeleteCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__, baSession__) - -/******************************************************************************* - - NAME - CsrWifiSmeApBeaconingStartReqSend - - DESCRIPTION - This primitive requests the SME to start AP or GO functionality - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - interfaceTag - - initialPresence - Set to 0, if Not in a group fomration phase, set to 1 , - during group formation phase - apType - apType : Legacy AP or P2PGO - cloakSsid - cloakSsid flag. - ssid - ssid. - ifIndex - Radio Interface - channel - channel. - maxConnections - Maximum Stations + P2PClients allowed - apCredentials - AP security credeitals used to advertise in beacon /probe - response - smeApConfig - AP configuration - p2pGoParam - P2P specific GO parameters. Ignored if it is a leagacy AP - -*******************************************************************************/ -#define CsrWifiSmeApBeaconingStartReqCreate(msg__, dst__, src__, interfaceTag__, initialPresence__, apType__, cloakSsid__, ssid__, ifIndex__, channel__, maxConnections__, apCredentials__, smeApConfig__, p2pGoParam__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeApBeaconingStartReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_AP_PRIM, CSR_WIFI_SME_AP_BEACONING_START_REQ, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->initialPresence = (initialPresence__); \ - msg__->apType = (apType__); \ - msg__->cloakSsid = (cloakSsid__); \ - msg__->ssid = (ssid__); \ - msg__->ifIndex = (ifIndex__); \ - msg__->channel = (channel__); \ - msg__->maxConnections = (maxConnections__); \ - msg__->apCredentials = (apCredentials__); \ - msg__->smeApConfig = (smeApConfig__); \ - msg__->p2pGoParam = (p2pGoParam__); - -#define CsrWifiSmeApBeaconingStartReqSendTo(dst__, src__, interfaceTag__, initialPresence__, apType__, cloakSsid__, ssid__, ifIndex__, channel__, maxConnections__, apCredentials__, smeApConfig__, p2pGoParam__) \ - { \ - CsrWifiSmeApBeaconingStartReq *msg__; \ - CsrWifiSmeApBeaconingStartReqCreate(msg__, dst__, src__, interfaceTag__, initialPresence__, apType__, cloakSsid__, ssid__, ifIndex__, channel__, maxConnections__, apCredentials__, smeApConfig__, p2pGoParam__); \ - CsrMsgTransport(dst__, CSR_WIFI_SME_AP_PRIM, msg__); \ - } - -#define CsrWifiSmeApBeaconingStartReqSend(src__, interfaceTag__, initialPresence__, apType__, cloakSsid__, ssid__, ifIndex__, channel__, maxConnections__, apCredentials__, smeApConfig__, p2pGoParam__) \ - CsrWifiSmeApBeaconingStartReqSendTo(CSR_WIFI_SME_IFACEQUEUE, src__, interfaceTag__, initialPresence__, apType__, cloakSsid__, ssid__, ifIndex__, channel__, maxConnections__, apCredentials__, smeApConfig__, p2pGoParam__) - -/******************************************************************************* - - NAME - CsrWifiSmeApBeaconingStartCfmSend - - DESCRIPTION - This primitive confirms the completion of the request along with the - status - - PARAMETERS - queue - Destination Task Queue - interfaceTag - - status - - secIeLength - - secIe - - -*******************************************************************************/ -#define CsrWifiSmeApBeaconingStartCfmCreate(msg__, dst__, src__, interfaceTag__, status__, secIeLength__, secIe__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeApBeaconingStartCfm), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_AP_PRIM, CSR_WIFI_SME_AP_BEACONING_START_CFM, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->status = (status__); \ - msg__->secIeLength = (secIeLength__); \ - msg__->secIe = (secIe__); - -#define CsrWifiSmeApBeaconingStartCfmSendTo(dst__, src__, interfaceTag__, status__, secIeLength__, secIe__) \ - { \ - CsrWifiSmeApBeaconingStartCfm *msg__; \ - CsrWifiSmeApBeaconingStartCfmCreate(msg__, dst__, src__, interfaceTag__, status__, secIeLength__, secIe__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_SME_AP_PRIM, msg__); \ - } - -#define CsrWifiSmeApBeaconingStartCfmSend(dst__, interfaceTag__, status__, secIeLength__, secIe__) \ - CsrWifiSmeApBeaconingStartCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__, secIeLength__, secIe__) - -/******************************************************************************* - - NAME - CsrWifiSmeApBeaconingStopReqSend - - DESCRIPTION - This primitive requests the SME to STOP AP or P2PGO operation - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - interfaceTag - - -*******************************************************************************/ -#define CsrWifiSmeApBeaconingStopReqCreate(msg__, dst__, src__, interfaceTag__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeApBeaconingStopReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_AP_PRIM, CSR_WIFI_SME_AP_BEACONING_STOP_REQ, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); - -#define CsrWifiSmeApBeaconingStopReqSendTo(dst__, src__, interfaceTag__) \ - { \ - CsrWifiSmeApBeaconingStopReq *msg__; \ - CsrWifiSmeApBeaconingStopReqCreate(msg__, dst__, src__, interfaceTag__); \ - CsrMsgTransport(dst__, CSR_WIFI_SME_AP_PRIM, msg__); \ - } - -#define CsrWifiSmeApBeaconingStopReqSend(src__, interfaceTag__) \ - CsrWifiSmeApBeaconingStopReqSendTo(CSR_WIFI_SME_IFACEQUEUE, src__, interfaceTag__) - -/******************************************************************************* - - NAME - CsrWifiSmeApBeaconingStopCfmSend - - DESCRIPTION - This primitive confirms AP or P2PGO operation is terminated - - PARAMETERS - queue - Destination Task Queue - interfaceTag - - status - - -*******************************************************************************/ -#define CsrWifiSmeApBeaconingStopCfmCreate(msg__, dst__, src__, interfaceTag__, status__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeApBeaconingStopCfm), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_AP_PRIM, CSR_WIFI_SME_AP_BEACONING_STOP_CFM, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->status = (status__); - -#define CsrWifiSmeApBeaconingStopCfmSendTo(dst__, src__, interfaceTag__, status__) \ - { \ - CsrWifiSmeApBeaconingStopCfm *msg__; \ - CsrWifiSmeApBeaconingStopCfmCreate(msg__, dst__, src__, interfaceTag__, status__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_SME_AP_PRIM, msg__); \ - } - -#define CsrWifiSmeApBeaconingStopCfmSend(dst__, interfaceTag__, status__) \ - CsrWifiSmeApBeaconingStopCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__) - -/******************************************************************************* - - NAME - CsrWifiSmeApErrorIndSend - - DESCRIPTION - This primitve is sent by SME to indicate some error in AP operationi - after AP operations were started successfully and continuing the AP - operation may lead to undesired behaviour. It is the responsibility of - the upper layers to stop AP operation if needed - - PARAMETERS - queue - Destination Task Queue - interfaceTag - Range 0-1 - apType - - status - Contains the error status - -*******************************************************************************/ -#define CsrWifiSmeApErrorIndCreate(msg__, dst__, src__, interfaceTag__, apType__, status__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeApErrorInd), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_AP_PRIM, CSR_WIFI_SME_AP_ERROR_IND, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->apType = (apType__); \ - msg__->status = (status__); - -#define CsrWifiSmeApErrorIndSendTo(dst__, src__, interfaceTag__, apType__, status__) \ - { \ - CsrWifiSmeApErrorInd *msg__; \ - CsrWifiSmeApErrorIndCreate(msg__, dst__, src__, interfaceTag__, apType__, status__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_SME_AP_PRIM, msg__); \ - } - -#define CsrWifiSmeApErrorIndSend(dst__, interfaceTag__, apType__, status__) \ - CsrWifiSmeApErrorIndSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, apType__, status__) - -/******************************************************************************* - - NAME - CsrWifiSmeApStaConnectStartIndSend - - DESCRIPTION - This primitive indicates that a stations request to join the group/BSS is - accepted - - PARAMETERS - queue - Destination Task Queue - interfaceTag - - peerMacAddress - - -*******************************************************************************/ -#define CsrWifiSmeApStaConnectStartIndCreate(msg__, dst__, src__, interfaceTag__, peerMacAddress__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeApStaConnectStartInd), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_AP_PRIM, CSR_WIFI_SME_AP_STA_CONNECT_START_IND, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->peerMacAddress = (peerMacAddress__); - -#define CsrWifiSmeApStaConnectStartIndSendTo(dst__, src__, interfaceTag__, peerMacAddress__) \ - { \ - CsrWifiSmeApStaConnectStartInd *msg__; \ - CsrWifiSmeApStaConnectStartIndCreate(msg__, dst__, src__, interfaceTag__, peerMacAddress__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_SME_AP_PRIM, msg__); \ - } - -#define CsrWifiSmeApStaConnectStartIndSend(dst__, interfaceTag__, peerMacAddress__) \ - CsrWifiSmeApStaConnectStartIndSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, peerMacAddress__) - -/******************************************************************************* - - NAME - CsrWifiSmeApStaDisconnectReqSend - - DESCRIPTION - This primitive tells SME to deauth ot disassociate a particular station - within BSS - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - interfaceTag - - deauthReason - - disassocReason - - peerMacaddress - - keepBlocking - If TRUE, the station is blocked. If FALSE and the station - is connected, disconnect the station. If FALSE and the - station is not connected, no action is taken. - -*******************************************************************************/ -#define CsrWifiSmeApStaDisconnectReqCreate(msg__, dst__, src__, interfaceTag__, deauthReason__, disassocReason__, peerMacaddress__, keepBlocking__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeApStaDisconnectReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_AP_PRIM, CSR_WIFI_SME_AP_STA_DISCONNECT_REQ, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->deauthReason = (deauthReason__); \ - msg__->disassocReason = (disassocReason__); \ - msg__->peerMacaddress = (peerMacaddress__); \ - msg__->keepBlocking = (keepBlocking__); - -#define CsrWifiSmeApStaDisconnectReqSendTo(dst__, src__, interfaceTag__, deauthReason__, disassocReason__, peerMacaddress__, keepBlocking__) \ - { \ - CsrWifiSmeApStaDisconnectReq *msg__; \ - CsrWifiSmeApStaDisconnectReqCreate(msg__, dst__, src__, interfaceTag__, deauthReason__, disassocReason__, peerMacaddress__, keepBlocking__); \ - CsrMsgTransport(dst__, CSR_WIFI_SME_AP_PRIM, msg__); \ - } - -#define CsrWifiSmeApStaDisconnectReqSend(src__, interfaceTag__, deauthReason__, disassocReason__, peerMacaddress__, keepBlocking__) \ - CsrWifiSmeApStaDisconnectReqSendTo(CSR_WIFI_SME_IFACEQUEUE, src__, interfaceTag__, deauthReason__, disassocReason__, peerMacaddress__, keepBlocking__) - -/******************************************************************************* - - NAME - CsrWifiSmeApStaDisconnectCfmSend - - DESCRIPTION - This primitive confirms the station is disconnected - - PARAMETERS - queue - Destination Task Queue - interfaceTag - - status - - peerMacaddress - - -*******************************************************************************/ -#define CsrWifiSmeApStaDisconnectCfmCreate(msg__, dst__, src__, interfaceTag__, status__, peerMacaddress__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeApStaDisconnectCfm), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_AP_PRIM, CSR_WIFI_SME_AP_STA_DISCONNECT_CFM, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->status = (status__); \ - msg__->peerMacaddress = (peerMacaddress__); - -#define CsrWifiSmeApStaDisconnectCfmSendTo(dst__, src__, interfaceTag__, status__, peerMacaddress__) \ - { \ - CsrWifiSmeApStaDisconnectCfm *msg__; \ - CsrWifiSmeApStaDisconnectCfmCreate(msg__, dst__, src__, interfaceTag__, status__, peerMacaddress__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_SME_AP_PRIM, msg__); \ - } - -#define CsrWifiSmeApStaDisconnectCfmSend(dst__, interfaceTag__, status__, peerMacaddress__) \ - CsrWifiSmeApStaDisconnectCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__, peerMacaddress__) - -/******************************************************************************* - - NAME - CsrWifiSmeApStaNotifyIndSend - - DESCRIPTION - This primitive indicates that a station has joined or a previously joined - station has left the BSS/group - - PARAMETERS - queue - Destination Task Queue - interfaceTag - - mediaStatus - - peerMacAddress - - peerDeviceAddress - - disassocReason - - deauthReason - - WpsRegistration - - secIeLength - - secIe - - groupKeyId - - seqNumber - - -*******************************************************************************/ -#define CsrWifiSmeApStaNotifyIndCreate(msg__, dst__, src__, interfaceTag__, mediaStatus__, peerMacAddress__, peerDeviceAddress__, disassocReason__, deauthReason__, WpsRegistration__, secIeLength__, secIe__, groupKeyId__, seqNumber__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeApStaNotifyInd), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_AP_PRIM, CSR_WIFI_SME_AP_STA_NOTIFY_IND, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->mediaStatus = (mediaStatus__); \ - msg__->peerMacAddress = (peerMacAddress__); \ - msg__->peerDeviceAddress = (peerDeviceAddress__); \ - msg__->disassocReason = (disassocReason__); \ - msg__->deauthReason = (deauthReason__); \ - msg__->WpsRegistration = (WpsRegistration__); \ - msg__->secIeLength = (secIeLength__); \ - msg__->secIe = (secIe__); \ - msg__->groupKeyId = (groupKeyId__); \ - memcpy(msg__->seqNumber, (seqNumber__), sizeof(u16) * 8); - -#define CsrWifiSmeApStaNotifyIndSendTo(dst__, src__, interfaceTag__, mediaStatus__, peerMacAddress__, peerDeviceAddress__, disassocReason__, deauthReason__, WpsRegistration__, secIeLength__, secIe__, groupKeyId__, seqNumber__) \ - { \ - CsrWifiSmeApStaNotifyInd *msg__; \ - CsrWifiSmeApStaNotifyIndCreate(msg__, dst__, src__, interfaceTag__, mediaStatus__, peerMacAddress__, peerDeviceAddress__, disassocReason__, deauthReason__, WpsRegistration__, secIeLength__, secIe__, groupKeyId__, seqNumber__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_SME_AP_PRIM, msg__); \ - } - -#define CsrWifiSmeApStaNotifyIndSend(dst__, interfaceTag__, mediaStatus__, peerMacAddress__, peerDeviceAddress__, disassocReason__, deauthReason__, WpsRegistration__, secIeLength__, secIe__, groupKeyId__, seqNumber__) \ - CsrWifiSmeApStaNotifyIndSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, mediaStatus__, peerMacAddress__, peerDeviceAddress__, disassocReason__, deauthReason__, WpsRegistration__, secIeLength__, secIe__, groupKeyId__, seqNumber__) - -/******************************************************************************* - - NAME - CsrWifiSmeApWmmParamUpdateReqSend - - DESCRIPTION - Application uses this primitive to update the WMM parameters on the fly - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - interfaceTag - - wmmApParams - WMM parameters to be used for local firmware queue - configuration - wmmApBcParams - WMM parameters to be advertised in beacon/probe response - -*******************************************************************************/ -#define CsrWifiSmeApWmmParamUpdateReqCreate(msg__, dst__, src__, interfaceTag__, wmmApParams__, wmmApBcParams__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeApWmmParamUpdateReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_AP_PRIM, CSR_WIFI_SME_AP_WMM_PARAM_UPDATE_REQ, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); \ - memcpy(msg__->wmmApParams, (wmmApParams__), sizeof(CsrWifiSmeWmmAcParams) * 4); \ - memcpy(msg__->wmmApBcParams, (wmmApBcParams__), sizeof(CsrWifiSmeWmmAcParams) * 4); - -#define CsrWifiSmeApWmmParamUpdateReqSendTo(dst__, src__, interfaceTag__, wmmApParams__, wmmApBcParams__) \ - { \ - CsrWifiSmeApWmmParamUpdateReq *msg__; \ - CsrWifiSmeApWmmParamUpdateReqCreate(msg__, dst__, src__, interfaceTag__, wmmApParams__, wmmApBcParams__); \ - CsrMsgTransport(dst__, CSR_WIFI_SME_AP_PRIM, msg__); \ - } - -#define CsrWifiSmeApWmmParamUpdateReqSend(src__, interfaceTag__, wmmApParams__, wmmApBcParams__) \ - CsrWifiSmeApWmmParamUpdateReqSendTo(CSR_WIFI_SME_IFACEQUEUE, src__, interfaceTag__, wmmApParams__, wmmApBcParams__) - -/******************************************************************************* - - NAME - CsrWifiSmeApWmmParamUpdateCfmSend - - DESCRIPTION - A confirm for CSR_WIFI_SME_AP_WMM_PARAM_UPDATE.request - - PARAMETERS - queue - Destination Task Queue - interfaceTag - - status - - -*******************************************************************************/ -#define CsrWifiSmeApWmmParamUpdateCfmCreate(msg__, dst__, src__, interfaceTag__, status__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeApWmmParamUpdateCfm), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_AP_PRIM, CSR_WIFI_SME_AP_WMM_PARAM_UPDATE_CFM, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->status = (status__); - -#define CsrWifiSmeApWmmParamUpdateCfmSendTo(dst__, src__, interfaceTag__, status__) \ - { \ - CsrWifiSmeApWmmParamUpdateCfm *msg__; \ - CsrWifiSmeApWmmParamUpdateCfmCreate(msg__, dst__, src__, interfaceTag__, status__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_SME_AP_PRIM, msg__); \ - } - -#define CsrWifiSmeApWmmParamUpdateCfmSend(dst__, interfaceTag__, status__) \ - CsrWifiSmeApWmmParamUpdateCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__) - -/******************************************************************************* - - NAME - CsrWifiSmeApWpsConfigurationReqSend - - DESCRIPTION - This primitive passes the WPS information for the device to SME. This may - be accepted only if no interface is active. - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - wpsConfig - WPS config. - -*******************************************************************************/ -#define CsrWifiSmeApWpsConfigurationReqCreate(msg__, dst__, src__, wpsConfig__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeApWpsConfigurationReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_AP_PRIM, CSR_WIFI_SME_AP_WPS_CONFIGURATION_REQ, dst__, src__); \ - msg__->wpsConfig = (wpsConfig__); - -#define CsrWifiSmeApWpsConfigurationReqSendTo(dst__, src__, wpsConfig__) \ - { \ - CsrWifiSmeApWpsConfigurationReq *msg__; \ - CsrWifiSmeApWpsConfigurationReqCreate(msg__, dst__, src__, wpsConfig__); \ - CsrMsgTransport(dst__, CSR_WIFI_SME_AP_PRIM, msg__); \ - } - -#define CsrWifiSmeApWpsConfigurationReqSend(src__, wpsConfig__) \ - CsrWifiSmeApWpsConfigurationReqSendTo(CSR_WIFI_SME_IFACEQUEUE, src__, wpsConfig__) - -/******************************************************************************* - - NAME - CsrWifiSmeApWpsConfigurationCfmSend - - DESCRIPTION - Confirm. - - PARAMETERS - queue - Destination Task Queue - status - Status of the request. - -*******************************************************************************/ -#define CsrWifiSmeApWpsConfigurationCfmCreate(msg__, dst__, src__, status__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeApWpsConfigurationCfm), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_AP_PRIM, CSR_WIFI_SME_AP_WPS_CONFIGURATION_CFM, dst__, src__); \ - msg__->status = (status__); - -#define CsrWifiSmeApWpsConfigurationCfmSendTo(dst__, src__, status__) \ - { \ - CsrWifiSmeApWpsConfigurationCfm *msg__; \ - CsrWifiSmeApWpsConfigurationCfmCreate(msg__, dst__, src__, status__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_SME_AP_PRIM, msg__); \ - } - -#define CsrWifiSmeApWpsConfigurationCfmSend(dst__, status__) \ - CsrWifiSmeApWpsConfigurationCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__) - -/******************************************************************************* - - NAME - CsrWifiSmeApWpsRegistrationFinishedReqSend - - DESCRIPTION - This primitive tells SME that WPS registration procedure has finished - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - interfaceTag - - -*******************************************************************************/ -#define CsrWifiSmeApWpsRegistrationFinishedReqCreate(msg__, dst__, src__, interfaceTag__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeApWpsRegistrationFinishedReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_AP_PRIM, CSR_WIFI_SME_AP_WPS_REGISTRATION_FINISHED_REQ, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); - -#define CsrWifiSmeApWpsRegistrationFinishedReqSendTo(dst__, src__, interfaceTag__) \ - { \ - CsrWifiSmeApWpsRegistrationFinishedReq *msg__; \ - CsrWifiSmeApWpsRegistrationFinishedReqCreate(msg__, dst__, src__, interfaceTag__); \ - CsrMsgTransport(dst__, CSR_WIFI_SME_AP_PRIM, msg__); \ - } - -#define CsrWifiSmeApWpsRegistrationFinishedReqSend(src__, interfaceTag__) \ - CsrWifiSmeApWpsRegistrationFinishedReqSendTo(CSR_WIFI_SME_IFACEQUEUE, src__, interfaceTag__) - -/******************************************************************************* - - NAME - CsrWifiSmeApWpsRegistrationFinishedCfmSend - - DESCRIPTION - A confirm for UNIFI_MGT_AP_WPS_REGISTRATION_FINISHED.request - - PARAMETERS - queue - Destination Task Queue - interfaceTag - - status - - -*******************************************************************************/ -#define CsrWifiSmeApWpsRegistrationFinishedCfmCreate(msg__, dst__, src__, interfaceTag__, status__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeApWpsRegistrationFinishedCfm), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_AP_PRIM, CSR_WIFI_SME_AP_WPS_REGISTRATION_FINISHED_CFM, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->status = (status__); - -#define CsrWifiSmeApWpsRegistrationFinishedCfmSendTo(dst__, src__, interfaceTag__, status__) \ - { \ - CsrWifiSmeApWpsRegistrationFinishedCfm *msg__; \ - CsrWifiSmeApWpsRegistrationFinishedCfmCreate(msg__, dst__, src__, interfaceTag__, status__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_SME_AP_PRIM, msg__); \ - } - -#define CsrWifiSmeApWpsRegistrationFinishedCfmSend(dst__, interfaceTag__, status__) \ - CsrWifiSmeApWpsRegistrationFinishedCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__) - -/******************************************************************************* - - NAME - CsrWifiSmeApWpsRegistrationStartedReqSend - - DESCRIPTION - This primitive tells SME that WPS registration procedure has started - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - interfaceTag - - SelectedDevicePasswordId - - SelectedconfigMethod - - -*******************************************************************************/ -#define CsrWifiSmeApWpsRegistrationStartedReqCreate(msg__, dst__, src__, interfaceTag__, SelectedDevicePasswordId__, SelectedconfigMethod__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeApWpsRegistrationStartedReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_AP_PRIM, CSR_WIFI_SME_AP_WPS_REGISTRATION_STARTED_REQ, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->SelectedDevicePasswordId = (SelectedDevicePasswordId__); \ - msg__->SelectedconfigMethod = (SelectedconfigMethod__); - -#define CsrWifiSmeApWpsRegistrationStartedReqSendTo(dst__, src__, interfaceTag__, SelectedDevicePasswordId__, SelectedconfigMethod__) \ - { \ - CsrWifiSmeApWpsRegistrationStartedReq *msg__; \ - CsrWifiSmeApWpsRegistrationStartedReqCreate(msg__, dst__, src__, interfaceTag__, SelectedDevicePasswordId__, SelectedconfigMethod__); \ - CsrMsgTransport(dst__, CSR_WIFI_SME_AP_PRIM, msg__); \ - } - -#define CsrWifiSmeApWpsRegistrationStartedReqSend(src__, interfaceTag__, SelectedDevicePasswordId__, SelectedconfigMethod__) \ - CsrWifiSmeApWpsRegistrationStartedReqSendTo(CSR_WIFI_SME_IFACEQUEUE, src__, interfaceTag__, SelectedDevicePasswordId__, SelectedconfigMethod__) - -/******************************************************************************* - - NAME - CsrWifiSmeApWpsRegistrationStartedCfmSend - - DESCRIPTION - A confirm for UNIFI_MGT_AP_WPS_REGISTRATION_STARTED.request - - PARAMETERS - queue - Destination Task Queue - interfaceTag - - status - - -*******************************************************************************/ -#define CsrWifiSmeApWpsRegistrationStartedCfmCreate(msg__, dst__, src__, interfaceTag__, status__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeApWpsRegistrationStartedCfm), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_AP_PRIM, CSR_WIFI_SME_AP_WPS_REGISTRATION_STARTED_CFM, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->status = (status__); - -#define CsrWifiSmeApWpsRegistrationStartedCfmSendTo(dst__, src__, interfaceTag__, status__) \ - { \ - CsrWifiSmeApWpsRegistrationStartedCfm *msg__; \ - CsrWifiSmeApWpsRegistrationStartedCfmCreate(msg__, dst__, src__, interfaceTag__, status__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_SME_AP_PRIM, msg__); \ - } - -#define CsrWifiSmeApWpsRegistrationStartedCfmSend(dst__, interfaceTag__, status__) \ - CsrWifiSmeApWpsRegistrationStartedCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__) - - -#endif /* CSR_WIFI_SME_AP_LIB_H__ */ diff --git a/drivers/staging/csr/csr_wifi_sme_ap_prim.h b/drivers/staging/csr/csr_wifi_sme_ap_prim.h deleted file mode 100644 index 3c4bcbc16126..000000000000 --- a/drivers/staging/csr/csr_wifi_sme_ap_prim.h +++ /dev/null @@ -1,1030 +0,0 @@ -/***************************************************************************** - - (c) Cambridge Silicon Radio Limited 2012 - All rights reserved and confidential information of CSR - - Refer to LICENSE.txt included with this source for details - on the license terms. - -*****************************************************************************/ - -/* Note: this is an auto-generated file. */ - -#ifndef CSR_WIFI_SME_AP_PRIM_H__ -#define CSR_WIFI_SME_AP_PRIM_H__ - -#include "csr_prim_defs.h" -#include "csr_sched.h" -#include "csr_wifi_common.h" -#include "csr_result.h" -#include "csr_wifi_fsm_event.h" -#include "csr_wifi_sme_prim.h" - -#ifndef CSR_WIFI_AP_ENABLE -#error CSR_WIFI_AP_ENABLE MUST be defined inorder to use csr_wifi_sme_ap_prim.h -#endif - -#define CSR_WIFI_SME_AP_PRIM (0x0407) - -typedef CsrPrim CsrWifiSmeApPrim; - - -/******************************************************************************* - - NAME - CsrWifiSmeApAccessType - - DESCRIPTION - Allow or deny STAs based on MAC address - - VALUES - CSR_WIFI_AP_ACCESS_TYPE_NONE - None - CSR_WIFI_AP_ACCESS_TYPE_ALLOW - Allow only if MAC address is from the list - CSR_WIFI_AP_ACCESS_TYPE_DENY - Disallow if MAC address is from the list - -*******************************************************************************/ -typedef u8 CsrWifiSmeApAccessType; -#define CSR_WIFI_AP_ACCESS_TYPE_NONE ((CsrWifiSmeApAccessType) 0x00) -#define CSR_WIFI_AP_ACCESS_TYPE_ALLOW ((CsrWifiSmeApAccessType) 0x01) -#define CSR_WIFI_AP_ACCESS_TYPE_DENY ((CsrWifiSmeApAccessType) 0x02) - -/******************************************************************************* - - NAME - CsrWifiSmeApAuthSupport - - DESCRIPTION - Define bits for AP authentication support - - VALUES - CSR_WIFI_SME_RSN_AUTH_WPAPSK - RSN WPA-PSK Support - CSR_WIFI_SME_RSN_AUTH_WPA2PSK - RSN WPA2-PSK Support - CSR_WIFI_SME_AUTH_WAPIPSK - WAPI-PSK Support - -*******************************************************************************/ -typedef u8 CsrWifiSmeApAuthSupport; -#define CSR_WIFI_SME_RSN_AUTH_WPAPSK ((CsrWifiSmeApAuthSupport) 0x01) -#define CSR_WIFI_SME_RSN_AUTH_WPA2PSK ((CsrWifiSmeApAuthSupport) 0x02) -#define CSR_WIFI_SME_AUTH_WAPIPSK ((CsrWifiSmeApAuthSupport) 0x04) - -/******************************************************************************* - - NAME - CsrWifiSmeApAuthType - - DESCRIPTION - Definition of the SME AP Authentication Options - - VALUES - CSR_WIFI_SME_AP_AUTH_TYPE_OPEN_SYSTEM - - Open authentication - CSR_WIFI_SME_AP_AUTH_TYPE_PERSONAL - - Personal authentication using a passphrase or a pre-shared - key. - CSR_WIFI_SME_AP_AUTH_TYPE_WEP - - WEP authentication. This can be either open or shared key - -*******************************************************************************/ -typedef u8 CsrWifiSmeApAuthType; -#define CSR_WIFI_SME_AP_AUTH_TYPE_OPEN_SYSTEM ((CsrWifiSmeApAuthType) 0x00) -#define CSR_WIFI_SME_AP_AUTH_TYPE_PERSONAL ((CsrWifiSmeApAuthType) 0x01) -#define CSR_WIFI_SME_AP_AUTH_TYPE_WEP ((CsrWifiSmeApAuthType) 0x02) - -/******************************************************************************* - - NAME - CsrWifiSmeApDirection - - DESCRIPTION - Definition of Direction - - VALUES - CSR_WIFI_AP_DIRECTION_RECEIPIENT - Receipient - CSR_WIFI_AP_DIRECTION_ORIGINATOR - Originator - -*******************************************************************************/ -typedef u8 CsrWifiSmeApDirection; -#define CSR_WIFI_AP_DIRECTION_RECEIPIENT ((CsrWifiSmeApDirection) 0x00) -#define CSR_WIFI_AP_DIRECTION_ORIGINATOR ((CsrWifiSmeApDirection) 0x01) - -/******************************************************************************* - - NAME - CsrWifiSmeApPhySupport - - DESCRIPTION - Define bits for CsrWifiSmeApPhySupportMask - - VALUES - CSR_WIFI_SME_AP_PHY_SUPPORT_A - 802.11a. It is not supported in the current - release. - CSR_WIFI_SME_AP_PHY_SUPPORT_B - 802.11b - CSR_WIFI_SME_AP_PHY_SUPPORT_G - 802.11g - CSR_WIFI_SME_AP_PHY_SUPPORT_N - 802.11n - -*******************************************************************************/ -typedef u8 CsrWifiSmeApPhySupport; -#define CSR_WIFI_SME_AP_PHY_SUPPORT_A ((CsrWifiSmeApPhySupport) 0x01) -#define CSR_WIFI_SME_AP_PHY_SUPPORT_B ((CsrWifiSmeApPhySupport) 0x02) -#define CSR_WIFI_SME_AP_PHY_SUPPORT_G ((CsrWifiSmeApPhySupport) 0x04) -#define CSR_WIFI_SME_AP_PHY_SUPPORT_N ((CsrWifiSmeApPhySupport) 0x08) - -/******************************************************************************* - - NAME - CsrWifiSmeApType - - DESCRIPTION - Definition of AP types - - VALUES - CSR_WIFI_AP_TYPE_LEGACY - Legacy AP - CSR_WIFI_AP_TYPE_P2P - P2P Group Owner(GO) - -*******************************************************************************/ -typedef u8 CsrWifiSmeApType; -#define CSR_WIFI_AP_TYPE_LEGACY ((CsrWifiSmeApType) 0x00) -#define CSR_WIFI_AP_TYPE_P2P ((CsrWifiSmeApType) 0x01) - - -/******************************************************************************* - - NAME - CsrWifiSmeApAuthSupportMask - - DESCRIPTION - See CsrWifiSmeApAuthSupport for bit definitions - -*******************************************************************************/ -typedef u8 CsrWifiSmeApAuthSupportMask; -/******************************************************************************* - - NAME - CsrWifiSmeApPhySupportMask - - DESCRIPTION - Mask type for use with the values defined by CsrWifiSmeApPhySupport - -*******************************************************************************/ -typedef u8 CsrWifiSmeApPhySupportMask; -/******************************************************************************* - - NAME - CsrWifiSmeApRsnCapabilities - - DESCRIPTION - Set to 0 for the current release - -*******************************************************************************/ -typedef u16 CsrWifiSmeApRsnCapabilities; -/******************************************************************************* - - NAME - CsrWifiSmeApRsnCapabilitiesMask - - DESCRIPTION - Mask type for use with the values defined by CsrWifiSmeApRsnCapabilities - -*******************************************************************************/ -typedef u16 CsrWifiSmeApRsnCapabilitiesMask; -/******************************************************************************* - - NAME - CsrWifiSmeApWapiCapabilities - - DESCRIPTION - Ignored by the stack as WAPI is not supported for AP operations in the - current release - -*******************************************************************************/ -typedef u16 CsrWifiSmeApWapiCapabilities; -/******************************************************************************* - - NAME - CsrWifiSmeApWapiCapabilitiesMask - - DESCRIPTION - Mask type for use with the values defined by CsrWifiSmeApWapiCapabilities - -*******************************************************************************/ -typedef u16 CsrWifiSmeApWapiCapabilitiesMask; - - -/******************************************************************************* - - NAME - CsrWifiSmeApHtParams - - DESCRIPTION - Structure holding HT parameters - - MEMBERS - greenfieldSupported - Indicates if the AP supports Htgreenfield operation - subject to the chip capability. If the chip does not - support Htgreenfield operation, this parameter will be - ignored. - NOTE: if shortGi20MHz is set to TRUE and the chip - supports short GI operation for 20MHz this field will - be be ignored and the AP will not support Htgreenfield - operation. - NOTE: This field is ignored by the Wi-Fi stack for the - current release. It implies that AP does not support - greenfield operation. - shortGi20MHz - Indicates if the AP support short GI operation for - 20MHz subject to the chip capability.If the chip does - not support short GI for 20MHz, this parameter is - ignored - rxStbc - Support for STBC for receive. 0 => No support for STBC - , 1=> Use STBC for Rx - rifsModeAllowed - RIFS Mode is allowed to protect overlapping non-HT BSS - htProtection - Deprecated - dualCtsProtection - Dual CTS Protection enabled - -*******************************************************************************/ -typedef struct -{ - u8 greenfieldSupported; - u8 shortGi20MHz; - u8 rxStbc; - u8 rifsModeAllowed; - u8 htProtection; - u8 dualCtsProtection; -} CsrWifiSmeApHtParams; - -/******************************************************************************* - - NAME - CsrWifiSmeApP2pOperatingChanEntry - - DESCRIPTION - - MEMBERS - operatingClass - Channel operating class - operatingChannelCount - Number of channels in this entry - operatingChannel - List of channels - -*******************************************************************************/ -typedef struct -{ - u8 operatingClass; - u8 operatingChannelCount; - u8 *operatingChannel; -} CsrWifiSmeApP2pOperatingChanEntry; - -/******************************************************************************* - - NAME - CsrWifiSmeApP2pOperatingChanList - - DESCRIPTION - This structure contains the lists of P2P operating channels - - MEMBERS - country - Country - channelEntryListCount - Number of entries - channelEntryList - List of entries - -*******************************************************************************/ -typedef struct -{ - u8 country[3]; - u8 channelEntryListCount; - CsrWifiSmeApP2pOperatingChanEntry *channelEntryList; -} CsrWifiSmeApP2pOperatingChanList; - -/******************************************************************************* - - NAME - CsrWifiSmeApAuthPers - - DESCRIPTION - - MEMBERS - authSupport - - encryptionModeMask - - rsnCapabilities - - wapiCapabilities - - -*******************************************************************************/ -typedef struct -{ - CsrWifiSmeApAuthSupportMask authSupport; - CsrWifiSmeEncryptionMask encryptionModeMask; - CsrWifiSmeApRsnCapabilitiesMask rsnCapabilities; - CsrWifiSmeApWapiCapabilitiesMask wapiCapabilities; -} CsrWifiSmeApAuthPers; - -/******************************************************************************* - - NAME - CsrWifiSmeApBaSession - - DESCRIPTION - - MEMBERS - peerMacAddress - Indicates MAC address of the peer station - tid - Specifies the TID of the MSDUs for which this Block Ack has - been set up. Range: 0-15 - direction - Specifies if the AP is the originator or the recipient of - the data stream that uses the Block Ack. - -*******************************************************************************/ -typedef struct -{ - CsrWifiMacAddress peerMacAddress; - u8 tid; - CsrWifiSmeApDirection direction; -} CsrWifiSmeApBaSession; - -/******************************************************************************* - - NAME - CsrWifiSmeApMacConfig - - DESCRIPTION - Structure holding AP MAC configuration. - - MEMBERS - phySupportedBitmap - Indicates supported physical layers - beaconInterval - Beacon interval in terms of TUs - dtimPeriod - DTIM period in terms of number of beacon intervals - maxListenInterval - Maximum allowed listen interval as number of beacon - intervals - supportedRatesCount - Number of supported rates. Range : 0 to 20 - supportedRates - List of supportedRates. A rate is specied in the - units of 500kbps. An entry for a basic rate shall - have the MSB set to 1. - preamble - Preamble to be advertised in beacons and probe - responses - shortSlotTimeEnabled - TRUE indicates the AP shall use short slot time if - all the stations use short slot operation. - ctsProtectionType - CTS protection to be used - wmmEnabled - Indicate whether WMM is enabled or not. If set to - FALSE,the WMM parameters shall be ignored by the - receiver. - wmmApParams - WMM parameters to be used for local firmware queue - configuration. Array index corresponds to the ACI. - wmmApBcParams - WMM parameters to be advertised in beacon/probe - response. Array index corresponds to the ACI - accessType - Specifies whether the MAC addresses from the list - should be allowed or denied - macAddressListCount - Number of MAC addresses - macAddressList - List of MAC addresses - apHtParams - AP HT parameters. The stack shall use these - parameters only if phySupportedBitmap indicates - support for IEEE 802.11n - -*******************************************************************************/ -typedef struct -{ - CsrWifiSmeApPhySupportMask phySupportedBitmap; - u16 beaconInterval; - u8 dtimPeriod; - u16 maxListenInterval; - u8 supportedRatesCount; - u8 supportedRates[20]; - CsrWifiSmePreambleType preamble; - u8 shortSlotTimeEnabled; - CsrWifiSmeCtsProtectionType ctsProtectionType; - u8 wmmEnabled; - CsrWifiSmeWmmAcParams wmmApParams[4]; - CsrWifiSmeWmmAcParams wmmApBcParams[4]; - CsrWifiSmeApAccessType accessType; - u8 macAddressListCount; - CsrWifiMacAddress *macAddressList; - CsrWifiSmeApHtParams apHtParams; -} CsrWifiSmeApMacConfig; - -/******************************************************************************* - - NAME - CsrWifiSmeApP2pGoConfig - - DESCRIPTION - - MEMBERS - groupCapability - Indicates the P2P group capabilities - operatingChanList - List of operating channels in the order of - decreasing priority. It may contain channel - entry/entries not supported by the wifi stack. - These shall be filtered out by the wifi stack - opPsEnabled - Indicates whether opportunistic power save can - be used. - Note: This parameter is ignored by the WiFi - stack for the current release - ctWindow - Define Client Traffic window to be used in terms - of number of TUs. Range: 0 to 127. - Note: This parameter is ignored by the WiFi - stack for the current release. - noaConfigMethod - Notice of Absence configuration method. - Note: This parameter is ignored by the WiFi - stack for the current release. - allowNoaWithNonP2pDevices - Indicates if NOA should be allowed if non P2P - devices are connected. If allowed the non P2P - devices may suffer in throughput. - Note: This parameter is ignored by the WiFi - stack for the current release. - -*******************************************************************************/ -typedef struct -{ - CsrWifiSmeP2pGroupCapabilityMask groupCapability; - CsrWifiSmeApP2pOperatingChanList operatingChanList; - u8 opPsEnabled; - u8 ctWindow; - CsrWifiSmeP2pNoaConfigMethod noaConfigMethod; - u8 allowNoaWithNonP2pDevices; -} CsrWifiSmeApP2pGoConfig; - -/******************************************************************************* - - NAME - CsrWifiSmeApCredentials - - DESCRIPTION - - MEMBERS - authType - - smeAuthType - - smeAuthTypeopenSystemEmpty - - smeAuthTypeauthwep - - smeAuthTypeauthPers - - -*******************************************************************************/ -typedef struct -{ - CsrWifiSmeApAuthType authType; - union { - CsrWifiSmeEmpty openSystemEmpty; - CsrWifiSmeWepAuth authwep; - CsrWifiSmeApAuthPers authPers; - } smeAuthType; -} CsrWifiSmeApCredentials; - -/******************************************************************************* - - NAME - CsrWifiSmeApSecConfig - - DESCRIPTION - - MEMBERS - apCredentials - - wpsEnabled - - -*******************************************************************************/ -typedef struct -{ - CsrWifiSmeApCredentials apCredentials; - u8 wpsEnabled; -} CsrWifiSmeApSecConfig; - - -/* Downstream */ -#define CSR_WIFI_SME_AP_PRIM_DOWNSTREAM_LOWEST (0x0000) - -#define CSR_WIFI_SME_AP_BEACONING_START_REQ ((CsrWifiSmeApPrim) (0x0000 + CSR_WIFI_SME_AP_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_SME_AP_BEACONING_STOP_REQ ((CsrWifiSmeApPrim) (0x0001 + CSR_WIFI_SME_AP_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_SME_AP_WPS_REGISTRATION_STARTED_REQ ((CsrWifiSmeApPrim) (0x0002 + CSR_WIFI_SME_AP_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_SME_AP_WPS_REGISTRATION_FINISHED_REQ ((CsrWifiSmeApPrim) (0x0003 + CSR_WIFI_SME_AP_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_SME_AP_WMM_PARAM_UPDATE_REQ ((CsrWifiSmeApPrim) (0x0004 + CSR_WIFI_SME_AP_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_SME_AP_STA_DISCONNECT_REQ ((CsrWifiSmeApPrim) (0x0005 + CSR_WIFI_SME_AP_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_SME_AP_WPS_CONFIGURATION_REQ ((CsrWifiSmeApPrim) (0x0006 + CSR_WIFI_SME_AP_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_SME_AP_ACTIVE_BA_GET_REQ ((CsrWifiSmeApPrim) (0x0007 + CSR_WIFI_SME_AP_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_SME_AP_BA_DELETE_REQ ((CsrWifiSmeApPrim) (0x0008 + CSR_WIFI_SME_AP_PRIM_DOWNSTREAM_LOWEST)) - - -#define CSR_WIFI_SME_AP_PRIM_DOWNSTREAM_HIGHEST (0x0008 + CSR_WIFI_SME_AP_PRIM_DOWNSTREAM_LOWEST) - -/* Upstream */ -#define CSR_WIFI_SME_AP_PRIM_UPSTREAM_LOWEST (0x0000 + CSR_PRIM_UPSTREAM) - -#define CSR_WIFI_SME_AP_BEACONING_START_CFM ((CsrWifiSmeApPrim)(0x0000 + CSR_WIFI_SME_AP_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_SME_AP_BEACONING_STOP_CFM ((CsrWifiSmeApPrim)(0x0001 + CSR_WIFI_SME_AP_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_SME_AP_STA_NOTIFY_IND ((CsrWifiSmeApPrim)(0x0002 + CSR_WIFI_SME_AP_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_SME_AP_STA_CONNECT_START_IND ((CsrWifiSmeApPrim)(0x0003 + CSR_WIFI_SME_AP_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_SME_AP_WPS_REGISTRATION_STARTED_CFM ((CsrWifiSmeApPrim)(0x0004 + CSR_WIFI_SME_AP_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_SME_AP_WPS_REGISTRATION_FINISHED_CFM ((CsrWifiSmeApPrim)(0x0005 + CSR_WIFI_SME_AP_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_SME_AP_WMM_PARAM_UPDATE_CFM ((CsrWifiSmeApPrim)(0x0006 + CSR_WIFI_SME_AP_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_SME_AP_STA_DISCONNECT_CFM ((CsrWifiSmeApPrim)(0x0007 + CSR_WIFI_SME_AP_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_SME_AP_WPS_CONFIGURATION_CFM ((CsrWifiSmeApPrim)(0x0008 + CSR_WIFI_SME_AP_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_SME_AP_ERROR_IND ((CsrWifiSmeApPrim)(0x0009 + CSR_WIFI_SME_AP_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_SME_AP_ACTIVE_BA_GET_CFM ((CsrWifiSmeApPrim)(0x000A + CSR_WIFI_SME_AP_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_SME_AP_BA_DELETE_CFM ((CsrWifiSmeApPrim)(0x000B + CSR_WIFI_SME_AP_PRIM_UPSTREAM_LOWEST)) - -#define CSR_WIFI_SME_AP_PRIM_UPSTREAM_HIGHEST (0x000B + CSR_WIFI_SME_AP_PRIM_UPSTREAM_LOWEST) - -#define CSR_WIFI_SME_AP_PRIM_DOWNSTREAM_COUNT (CSR_WIFI_SME_AP_PRIM_DOWNSTREAM_HIGHEST + 1 - CSR_WIFI_SME_AP_PRIM_DOWNSTREAM_LOWEST) -#define CSR_WIFI_SME_AP_PRIM_UPSTREAM_COUNT (CSR_WIFI_SME_AP_PRIM_UPSTREAM_HIGHEST + 1 - CSR_WIFI_SME_AP_PRIM_UPSTREAM_LOWEST) - -/******************************************************************************* - - NAME - CsrWifiSmeApBeaconingStartReq - - DESCRIPTION - This primitive requests the SME to start AP or GO functionality - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - - initialPresence - Set to 0, if Not in a group fomration phase, set to 1 , - during group formation phase - apType - apType : Legacy AP or P2PGO - cloakSsid - cloakSsid flag. - ssid - ssid. - ifIndex - Radio Interface - channel - channel. - maxConnections - Maximum Stations + P2PClients allowed - apCredentials - AP security credeitals used to advertise in beacon /probe - response - smeApConfig - AP configuration - p2pGoParam - P2P specific GO parameters. Ignored if it is a leagacy AP - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; - u8 initialPresence; - CsrWifiSmeApType apType; - u8 cloakSsid; - CsrWifiSsid ssid; - CsrWifiSmeRadioIF ifIndex; - u8 channel; - u8 maxConnections; - CsrWifiSmeApSecConfig apCredentials; - CsrWifiSmeApMacConfig smeApConfig; - CsrWifiSmeApP2pGoConfig p2pGoParam; -} CsrWifiSmeApBeaconingStartReq; - -/******************************************************************************* - - NAME - CsrWifiSmeApBeaconingStopReq - - DESCRIPTION - This primitive requests the SME to STOP AP or P2PGO operation - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; -} CsrWifiSmeApBeaconingStopReq; - -/******************************************************************************* - - NAME - CsrWifiSmeApWpsRegistrationStartedReq - - DESCRIPTION - This primitive tells SME that WPS registration procedure has started - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - - SelectedDevicePasswordId - - SelectedconfigMethod - - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; - CsrWifiSmeWpsDpid SelectedDevicePasswordId; - CsrWifiSmeWpsConfigType SelectedconfigMethod; -} CsrWifiSmeApWpsRegistrationStartedReq; - -/******************************************************************************* - - NAME - CsrWifiSmeApWpsRegistrationFinishedReq - - DESCRIPTION - This primitive tells SME that WPS registration procedure has finished - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; -} CsrWifiSmeApWpsRegistrationFinishedReq; - -/******************************************************************************* - - NAME - CsrWifiSmeApWmmParamUpdateReq - - DESCRIPTION - Application uses this primitive to update the WMM parameters on the fly - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - - wmmApParams - WMM parameters to be used for local firmware queue - configuration - wmmApBcParams - WMM parameters to be advertised in beacon/probe response - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; - CsrWifiSmeWmmAcParams wmmApParams[4]; - CsrWifiSmeWmmAcParams wmmApBcParams[4]; -} CsrWifiSmeApWmmParamUpdateReq; - -/******************************************************************************* - - NAME - CsrWifiSmeApStaDisconnectReq - - DESCRIPTION - This primitive tells SME to deauth ot disassociate a particular station - within BSS - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - - deauthReason - - disassocReason - - peerMacaddress - - keepBlocking - If TRUE, the station is blocked. If FALSE and the station - is connected, disconnect the station. If FALSE and the - station is not connected, no action is taken. - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; - CsrWifiSmeIEEE80211Reason deauthReason; - CsrWifiSmeIEEE80211Reason disassocReason; - CsrWifiMacAddress peerMacaddress; - u8 keepBlocking; -} CsrWifiSmeApStaDisconnectReq; - -/******************************************************************************* - - NAME - CsrWifiSmeApWpsConfigurationReq - - DESCRIPTION - This primitive passes the WPS information for the device to SME. This may - be accepted only if no interface is active. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - wpsConfig - WPS config. - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - CsrWifiSmeWpsConfig wpsConfig; -} CsrWifiSmeApWpsConfigurationReq; - -/******************************************************************************* - - NAME - CsrWifiSmeApActiveBaGetReq - - DESCRIPTION - This primitive used to retrieve information related to the active block - ack sessions - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; -} CsrWifiSmeApActiveBaGetReq; - -/******************************************************************************* - - NAME - CsrWifiSmeApBaDeleteReq - - DESCRIPTION - This primitive is used to delete an active block ack session - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - - reason - - baSession - BA session to be deleted - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; - CsrWifiSmeIEEE80211Reason reason; - CsrWifiSmeApBaSession baSession; -} CsrWifiSmeApBaDeleteReq; - -/******************************************************************************* - - NAME - CsrWifiSmeApBeaconingStartCfm - - DESCRIPTION - This primitive confirms the completion of the request along with the - status - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - - status - - secIeLength - - secIe - - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; - CsrResult status; - u16 secIeLength; - u8 *secIe; -} CsrWifiSmeApBeaconingStartCfm; - -/******************************************************************************* - - NAME - CsrWifiSmeApBeaconingStopCfm - - DESCRIPTION - This primitive confirms AP or P2PGO operation is terminated - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - - status - - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; - CsrResult status; -} CsrWifiSmeApBeaconingStopCfm; - -/******************************************************************************* - - NAME - CsrWifiSmeApStaNotifyInd - - DESCRIPTION - This primitive indicates that a station has joined or a previously joined - station has left the BSS/group - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - - mediaStatus - - peerMacAddress - - peerDeviceAddress - - disassocReason - - deauthReason - - WpsRegistration - - secIeLength - - secIe - - groupKeyId - - seqNumber - - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; - CsrWifiSmeMediaStatus mediaStatus; - CsrWifiMacAddress peerMacAddress; - CsrWifiMacAddress peerDeviceAddress; - CsrWifiSmeIEEE80211Reason disassocReason; - CsrWifiSmeIEEE80211Reason deauthReason; - CsrWifiSmeWpsRegistration WpsRegistration; - u8 secIeLength; - u8 *secIe; - u8 groupKeyId; - u16 seqNumber[8]; -} CsrWifiSmeApStaNotifyInd; - -/******************************************************************************* - - NAME - CsrWifiSmeApStaConnectStartInd - - DESCRIPTION - This primitive indicates that a stations request to join the group/BSS is - accepted - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - - peerMacAddress - - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; - CsrWifiMacAddress peerMacAddress; -} CsrWifiSmeApStaConnectStartInd; - -/******************************************************************************* - - NAME - CsrWifiSmeApWpsRegistrationStartedCfm - - DESCRIPTION - A confirm for UNIFI_MGT_AP_WPS_REGISTRATION_STARTED.request - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - - status - - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; - CsrResult status; -} CsrWifiSmeApWpsRegistrationStartedCfm; - -/******************************************************************************* - - NAME - CsrWifiSmeApWpsRegistrationFinishedCfm - - DESCRIPTION - A confirm for UNIFI_MGT_AP_WPS_REGISTRATION_FINISHED.request - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - - status - - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; - CsrResult status; -} CsrWifiSmeApWpsRegistrationFinishedCfm; - -/******************************************************************************* - - NAME - CsrWifiSmeApWmmParamUpdateCfm - - DESCRIPTION - A confirm for CSR_WIFI_SME_AP_WMM_PARAM_UPDATE.request - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - - status - - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; - CsrResult status; -} CsrWifiSmeApWmmParamUpdateCfm; - -/******************************************************************************* - - NAME - CsrWifiSmeApStaDisconnectCfm - - DESCRIPTION - This primitive confirms the station is disconnected - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - - status - - peerMacaddress - - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; - CsrResult status; - CsrWifiMacAddress peerMacaddress; -} CsrWifiSmeApStaDisconnectCfm; - -/******************************************************************************* - - NAME - CsrWifiSmeApWpsConfigurationCfm - - DESCRIPTION - Confirm. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - status - Status of the request. - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - CsrResult status; -} CsrWifiSmeApWpsConfigurationCfm; - -/******************************************************************************* - - NAME - CsrWifiSmeApErrorInd - - DESCRIPTION - This primitve is sent by SME to indicate some error in AP operationi - after AP operations were started successfully and continuing the AP - operation may lead to undesired behaviour. It is the responsibility of - the upper layers to stop AP operation if needed - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - Range 0-1 - apType - - status - Contains the error status - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; - CsrWifiSmeApType apType; - CsrResult status; -} CsrWifiSmeApErrorInd; - -/******************************************************************************* - - NAME - CsrWifiSmeApActiveBaGetCfm - - DESCRIPTION - This primitive carries the information related to the active ba sessions - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - - status - Reports the result of the request - activeBaCount - Number of active block ack session - activeBaSessions - Points to a buffer containing an array of - CsrWifiSmeApBaSession structures. - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; - CsrResult status; - u16 activeBaCount; - CsrWifiSmeApBaSession *activeBaSessions; -} CsrWifiSmeApActiveBaGetCfm; - -/******************************************************************************* - - NAME - CsrWifiSmeApBaDeleteCfm - - DESCRIPTION - This primitive confirms the BA is deleted - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - - status - Reports the result of the request - baSession - deleted BA session - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; - CsrResult status; - CsrWifiSmeApBaSession baSession; -} CsrWifiSmeApBaDeleteCfm; - - -#endif /* CSR_WIFI_SME_AP_PRIM_H__ */ - diff --git a/drivers/staging/csr/csr_wifi_sme_converter_init.c b/drivers/staging/csr/csr_wifi_sme_converter_init.c deleted file mode 100644 index 31835f06bbc2..000000000000 --- a/drivers/staging/csr/csr_wifi_sme_converter_init.c +++ /dev/null @@ -1,201 +0,0 @@ -/***************************************************************************** - - (c) Cambridge Silicon Radio Limited 2012 - All rights reserved and confidential information of CSR - - Refer to LICENSE.txt included with this source for details - on the license terms. - -*****************************************************************************/ - -/* Note: this is an auto-generated file. */ - -#include "csr_msgconv.h" -#include "csr_macro.h" - - -#ifdef CSR_LOG_ENABLE -#include "csr_log.h" -#endif - -#ifndef EXCLUDE_CSR_WIFI_SME_MODULE -#include "csr_wifi_sme_serialize.h" -#include "csr_wifi_sme_prim.h" - -static CsrMsgConvMsgEntry csrwifisme_conv_lut[] = { - { CSR_WIFI_SME_ACTIVATE_REQ, CsrWifiSmeActivateReqSizeof, CsrWifiSmeActivateReqSer, CsrWifiSmeActivateReqDes, CsrWifiSmeActivateReqSerFree }, - { CSR_WIFI_SME_ADHOC_CONFIG_GET_REQ, CsrWifiSmeAdhocConfigGetReqSizeof, CsrWifiSmeAdhocConfigGetReqSer, CsrWifiSmeAdhocConfigGetReqDes, CsrWifiSmeAdhocConfigGetReqSerFree }, - { CSR_WIFI_SME_ADHOC_CONFIG_SET_REQ, CsrWifiSmeAdhocConfigSetReqSizeof, CsrWifiSmeAdhocConfigSetReqSer, CsrWifiSmeAdhocConfigSetReqDes, CsrWifiSmeAdhocConfigSetReqSerFree }, - { CSR_WIFI_SME_BLACKLIST_REQ, CsrWifiSmeBlacklistReqSizeof, CsrWifiSmeBlacklistReqSer, CsrWifiSmeBlacklistReqDes, CsrWifiSmeBlacklistReqSerFree }, - { CSR_WIFI_SME_CALIBRATION_DATA_GET_REQ, CsrWifiSmeCalibrationDataGetReqSizeof, CsrWifiSmeCalibrationDataGetReqSer, CsrWifiSmeCalibrationDataGetReqDes, CsrWifiSmeCalibrationDataGetReqSerFree }, - { CSR_WIFI_SME_CALIBRATION_DATA_SET_REQ, CsrWifiSmeCalibrationDataSetReqSizeof, CsrWifiSmeCalibrationDataSetReqSer, CsrWifiSmeCalibrationDataSetReqDes, CsrWifiSmeCalibrationDataSetReqSerFree }, - { CSR_WIFI_SME_CCX_CONFIG_GET_REQ, CsrWifiSmeCcxConfigGetReqSizeof, CsrWifiSmeCcxConfigGetReqSer, CsrWifiSmeCcxConfigGetReqDes, CsrWifiSmeCcxConfigGetReqSerFree }, - { CSR_WIFI_SME_CCX_CONFIG_SET_REQ, CsrWifiSmeCcxConfigSetReqSizeof, CsrWifiSmeCcxConfigSetReqSer, CsrWifiSmeCcxConfigSetReqDes, CsrWifiSmeCcxConfigSetReqSerFree }, - { CSR_WIFI_SME_COEX_CONFIG_GET_REQ, CsrWifiSmeCoexConfigGetReqSizeof, CsrWifiSmeCoexConfigGetReqSer, CsrWifiSmeCoexConfigGetReqDes, CsrWifiSmeCoexConfigGetReqSerFree }, - { CSR_WIFI_SME_COEX_CONFIG_SET_REQ, CsrWifiSmeCoexConfigSetReqSizeof, CsrWifiSmeCoexConfigSetReqSer, CsrWifiSmeCoexConfigSetReqDes, CsrWifiSmeCoexConfigSetReqSerFree }, - { CSR_WIFI_SME_COEX_INFO_GET_REQ, CsrWifiSmeCoexInfoGetReqSizeof, CsrWifiSmeCoexInfoGetReqSer, CsrWifiSmeCoexInfoGetReqDes, CsrWifiSmeCoexInfoGetReqSerFree }, - { CSR_WIFI_SME_CONNECT_REQ, CsrWifiSmeConnectReqSizeof, CsrWifiSmeConnectReqSer, CsrWifiSmeConnectReqDes, CsrWifiSmeConnectReqSerFree }, - { CSR_WIFI_SME_CONNECTION_CONFIG_GET_REQ, CsrWifiSmeConnectionConfigGetReqSizeof, CsrWifiSmeConnectionConfigGetReqSer, CsrWifiSmeConnectionConfigGetReqDes, CsrWifiSmeConnectionConfigGetReqSerFree }, - { CSR_WIFI_SME_CONNECTION_INFO_GET_REQ, CsrWifiSmeConnectionInfoGetReqSizeof, CsrWifiSmeConnectionInfoGetReqSer, CsrWifiSmeConnectionInfoGetReqDes, CsrWifiSmeConnectionInfoGetReqSerFree }, - { CSR_WIFI_SME_CONNECTION_STATS_GET_REQ, CsrWifiSmeConnectionStatsGetReqSizeof, CsrWifiSmeConnectionStatsGetReqSer, CsrWifiSmeConnectionStatsGetReqDes, CsrWifiSmeConnectionStatsGetReqSerFree }, - { CSR_WIFI_SME_DEACTIVATE_REQ, CsrWifiSmeDeactivateReqSizeof, CsrWifiSmeDeactivateReqSer, CsrWifiSmeDeactivateReqDes, CsrWifiSmeDeactivateReqSerFree }, - { CSR_WIFI_SME_DISCONNECT_REQ, CsrWifiSmeDisconnectReqSizeof, CsrWifiSmeDisconnectReqSer, CsrWifiSmeDisconnectReqDes, CsrWifiSmeDisconnectReqSerFree }, - { CSR_WIFI_SME_EVENT_MASK_SET_REQ, CsrWifiSmeEventMaskSetReqSizeof, CsrWifiSmeEventMaskSetReqSer, CsrWifiSmeEventMaskSetReqDes, CsrWifiSmeEventMaskSetReqSerFree }, - { CSR_WIFI_SME_HOST_CONFIG_GET_REQ, CsrWifiSmeHostConfigGetReqSizeof, CsrWifiSmeHostConfigGetReqSer, CsrWifiSmeHostConfigGetReqDes, CsrWifiSmeHostConfigGetReqSerFree }, - { CSR_WIFI_SME_HOST_CONFIG_SET_REQ, CsrWifiSmeHostConfigSetReqSizeof, CsrWifiSmeHostConfigSetReqSer, CsrWifiSmeHostConfigSetReqDes, CsrWifiSmeHostConfigSetReqSerFree }, - { CSR_WIFI_SME_KEY_REQ, CsrWifiSmeKeyReqSizeof, CsrWifiSmeKeyReqSer, CsrWifiSmeKeyReqDes, CsrWifiSmeKeyReqSerFree }, - { CSR_WIFI_SME_LINK_QUALITY_GET_REQ, CsrWifiSmeLinkQualityGetReqSizeof, CsrWifiSmeLinkQualityGetReqSer, CsrWifiSmeLinkQualityGetReqDes, CsrWifiSmeLinkQualityGetReqSerFree }, - { CSR_WIFI_SME_MIB_CONFIG_GET_REQ, CsrWifiSmeMibConfigGetReqSizeof, CsrWifiSmeMibConfigGetReqSer, CsrWifiSmeMibConfigGetReqDes, CsrWifiSmeMibConfigGetReqSerFree }, - { CSR_WIFI_SME_MIB_CONFIG_SET_REQ, CsrWifiSmeMibConfigSetReqSizeof, CsrWifiSmeMibConfigSetReqSer, CsrWifiSmeMibConfigSetReqDes, CsrWifiSmeMibConfigSetReqSerFree }, - { CSR_WIFI_SME_MIB_GET_NEXT_REQ, CsrWifiSmeMibGetNextReqSizeof, CsrWifiSmeMibGetNextReqSer, CsrWifiSmeMibGetNextReqDes, CsrWifiSmeMibGetNextReqSerFree }, - { CSR_WIFI_SME_MIB_GET_REQ, CsrWifiSmeMibGetReqSizeof, CsrWifiSmeMibGetReqSer, CsrWifiSmeMibGetReqDes, CsrWifiSmeMibGetReqSerFree }, - { CSR_WIFI_SME_MIB_SET_REQ, CsrWifiSmeMibSetReqSizeof, CsrWifiSmeMibSetReqSer, CsrWifiSmeMibSetReqDes, CsrWifiSmeMibSetReqSerFree }, - { CSR_WIFI_SME_MULTICAST_ADDRESS_REQ, CsrWifiSmeMulticastAddressReqSizeof, CsrWifiSmeMulticastAddressReqSer, CsrWifiSmeMulticastAddressReqDes, CsrWifiSmeMulticastAddressReqSerFree }, - { CSR_WIFI_SME_PACKET_FILTER_SET_REQ, CsrWifiSmePacketFilterSetReqSizeof, CsrWifiSmePacketFilterSetReqSer, CsrWifiSmePacketFilterSetReqDes, CsrWifiSmePacketFilterSetReqSerFree }, - { CSR_WIFI_SME_PERMANENT_MAC_ADDRESS_GET_REQ, CsrWifiSmePermanentMacAddressGetReqSizeof, CsrWifiSmePermanentMacAddressGetReqSer, CsrWifiSmePermanentMacAddressGetReqDes, CsrWifiSmePermanentMacAddressGetReqSerFree }, - { CSR_WIFI_SME_PMKID_REQ, CsrWifiSmePmkidReqSizeof, CsrWifiSmePmkidReqSer, CsrWifiSmePmkidReqDes, CsrWifiSmePmkidReqSerFree }, - { CSR_WIFI_SME_POWER_CONFIG_GET_REQ, CsrWifiSmePowerConfigGetReqSizeof, CsrWifiSmePowerConfigGetReqSer, CsrWifiSmePowerConfigGetReqDes, CsrWifiSmePowerConfigGetReqSerFree }, - { CSR_WIFI_SME_POWER_CONFIG_SET_REQ, CsrWifiSmePowerConfigSetReqSizeof, CsrWifiSmePowerConfigSetReqSer, CsrWifiSmePowerConfigSetReqDes, CsrWifiSmePowerConfigSetReqSerFree }, - { CSR_WIFI_SME_REGULATORY_DOMAIN_INFO_GET_REQ, CsrWifiSmeRegulatoryDomainInfoGetReqSizeof, CsrWifiSmeRegulatoryDomainInfoGetReqSer, CsrWifiSmeRegulatoryDomainInfoGetReqDes, CsrWifiSmeRegulatoryDomainInfoGetReqSerFree }, - { CSR_WIFI_SME_ROAMING_CONFIG_GET_REQ, CsrWifiSmeRoamingConfigGetReqSizeof, CsrWifiSmeRoamingConfigGetReqSer, CsrWifiSmeRoamingConfigGetReqDes, CsrWifiSmeRoamingConfigGetReqSerFree }, - { CSR_WIFI_SME_ROAMING_CONFIG_SET_REQ, CsrWifiSmeRoamingConfigSetReqSizeof, CsrWifiSmeRoamingConfigSetReqSer, CsrWifiSmeRoamingConfigSetReqDes, CsrWifiSmeRoamingConfigSetReqSerFree }, - { CSR_WIFI_SME_SCAN_CONFIG_GET_REQ, CsrWifiSmeScanConfigGetReqSizeof, CsrWifiSmeScanConfigGetReqSer, CsrWifiSmeScanConfigGetReqDes, CsrWifiSmeScanConfigGetReqSerFree }, - { CSR_WIFI_SME_SCAN_CONFIG_SET_REQ, CsrWifiSmeScanConfigSetReqSizeof, CsrWifiSmeScanConfigSetReqSer, CsrWifiSmeScanConfigSetReqDes, CsrWifiSmeScanConfigSetReqSerFree }, - { CSR_WIFI_SME_SCAN_FULL_REQ, CsrWifiSmeScanFullReqSizeof, CsrWifiSmeScanFullReqSer, CsrWifiSmeScanFullReqDes, CsrWifiSmeScanFullReqSerFree }, - { CSR_WIFI_SME_SCAN_RESULTS_FLUSH_REQ, CsrWifiSmeScanResultsFlushReqSizeof, CsrWifiSmeScanResultsFlushReqSer, CsrWifiSmeScanResultsFlushReqDes, CsrWifiSmeScanResultsFlushReqSerFree }, - { CSR_WIFI_SME_SCAN_RESULTS_GET_REQ, CsrWifiSmeScanResultsGetReqSizeof, CsrWifiSmeScanResultsGetReqSer, CsrWifiSmeScanResultsGetReqDes, CsrWifiSmeScanResultsGetReqSerFree }, - { CSR_WIFI_SME_SME_STA_CONFIG_GET_REQ, CsrWifiSmeSmeStaConfigGetReqSizeof, CsrWifiSmeSmeStaConfigGetReqSer, CsrWifiSmeSmeStaConfigGetReqDes, CsrWifiSmeSmeStaConfigGetReqSerFree }, - { CSR_WIFI_SME_SME_STA_CONFIG_SET_REQ, CsrWifiSmeSmeStaConfigSetReqSizeof, CsrWifiSmeSmeStaConfigSetReqSer, CsrWifiSmeSmeStaConfigSetReqDes, CsrWifiSmeSmeStaConfigSetReqSerFree }, - { CSR_WIFI_SME_STATION_MAC_ADDRESS_GET_REQ, CsrWifiSmeStationMacAddressGetReqSizeof, CsrWifiSmeStationMacAddressGetReqSer, CsrWifiSmeStationMacAddressGetReqDes, CsrWifiSmeStationMacAddressGetReqSerFree }, - { CSR_WIFI_SME_TSPEC_REQ, CsrWifiSmeTspecReqSizeof, CsrWifiSmeTspecReqSer, CsrWifiSmeTspecReqDes, CsrWifiSmeTspecReqSerFree }, - { CSR_WIFI_SME_VERSIONS_GET_REQ, CsrWifiSmeVersionsGetReqSizeof, CsrWifiSmeVersionsGetReqSer, CsrWifiSmeVersionsGetReqDes, CsrWifiSmeVersionsGetReqSerFree }, - { CSR_WIFI_SME_WIFI_FLIGHTMODE_REQ, CsrWifiSmeWifiFlightmodeReqSizeof, CsrWifiSmeWifiFlightmodeReqSer, CsrWifiSmeWifiFlightmodeReqDes, CsrWifiSmeWifiFlightmodeReqSerFree }, - { CSR_WIFI_SME_WIFI_OFF_REQ, CsrWifiSmeWifiOffReqSizeof, CsrWifiSmeWifiOffReqSer, CsrWifiSmeWifiOffReqDes, CsrWifiSmeWifiOffReqSerFree }, - { CSR_WIFI_SME_WIFI_ON_REQ, CsrWifiSmeWifiOnReqSizeof, CsrWifiSmeWifiOnReqSer, CsrWifiSmeWifiOnReqDes, CsrWifiSmeWifiOnReqSerFree }, - { CSR_WIFI_SME_CLOAKED_SSIDS_SET_REQ, CsrWifiSmeCloakedSsidsSetReqSizeof, CsrWifiSmeCloakedSsidsSetReqSer, CsrWifiSmeCloakedSsidsSetReqDes, CsrWifiSmeCloakedSsidsSetReqSerFree }, - { CSR_WIFI_SME_CLOAKED_SSIDS_GET_REQ, CsrWifiSmeCloakedSsidsGetReqSizeof, CsrWifiSmeCloakedSsidsGetReqSer, CsrWifiSmeCloakedSsidsGetReqDes, CsrWifiSmeCloakedSsidsGetReqSerFree }, - { CSR_WIFI_SME_SME_COMMON_CONFIG_GET_REQ, CsrWifiSmeSmeCommonConfigGetReqSizeof, CsrWifiSmeSmeCommonConfigGetReqSer, CsrWifiSmeSmeCommonConfigGetReqDes, CsrWifiSmeSmeCommonConfigGetReqSerFree }, - { CSR_WIFI_SME_SME_COMMON_CONFIG_SET_REQ, CsrWifiSmeSmeCommonConfigSetReqSizeof, CsrWifiSmeSmeCommonConfigSetReqSer, CsrWifiSmeSmeCommonConfigSetReqDes, CsrWifiSmeSmeCommonConfigSetReqSerFree }, - { CSR_WIFI_SME_INTERFACE_CAPABILITY_GET_REQ, CsrWifiSmeInterfaceCapabilityGetReqSizeof, CsrWifiSmeInterfaceCapabilityGetReqSer, CsrWifiSmeInterfaceCapabilityGetReqDes, CsrWifiSmeInterfaceCapabilityGetReqSerFree }, - { CSR_WIFI_SME_WPS_CONFIGURATION_REQ, CsrWifiSmeWpsConfigurationReqSizeof, CsrWifiSmeWpsConfigurationReqSer, CsrWifiSmeWpsConfigurationReqDes, CsrWifiSmeWpsConfigurationReqSerFree }, - { CSR_WIFI_SME_SET_REQ, CsrWifiSmeSetReqSizeof, CsrWifiSmeSetReqSer, CsrWifiSmeSetReqDes, CsrWifiSmeSetReqSerFree }, - { CSR_WIFI_SME_ACTIVATE_CFM, CsrWifiSmeActivateCfmSizeof, CsrWifiSmeActivateCfmSer, CsrWifiSmeActivateCfmDes, CsrWifiSmeActivateCfmSerFree }, - { CSR_WIFI_SME_ADHOC_CONFIG_GET_CFM, CsrWifiSmeAdhocConfigGetCfmSizeof, CsrWifiSmeAdhocConfigGetCfmSer, CsrWifiSmeAdhocConfigGetCfmDes, CsrWifiSmeAdhocConfigGetCfmSerFree }, - { CSR_WIFI_SME_ADHOC_CONFIG_SET_CFM, CsrWifiSmeAdhocConfigSetCfmSizeof, CsrWifiSmeAdhocConfigSetCfmSer, CsrWifiSmeAdhocConfigSetCfmDes, CsrWifiSmeAdhocConfigSetCfmSerFree }, - { CSR_WIFI_SME_ASSOCIATION_COMPLETE_IND, CsrWifiSmeAssociationCompleteIndSizeof, CsrWifiSmeAssociationCompleteIndSer, CsrWifiSmeAssociationCompleteIndDes, CsrWifiSmeAssociationCompleteIndSerFree }, - { CSR_WIFI_SME_ASSOCIATION_START_IND, CsrWifiSmeAssociationStartIndSizeof, CsrWifiSmeAssociationStartIndSer, CsrWifiSmeAssociationStartIndDes, CsrWifiSmeAssociationStartIndSerFree }, - { CSR_WIFI_SME_BLACKLIST_CFM, CsrWifiSmeBlacklistCfmSizeof, CsrWifiSmeBlacklistCfmSer, CsrWifiSmeBlacklistCfmDes, CsrWifiSmeBlacklistCfmSerFree }, - { CSR_WIFI_SME_CALIBRATION_DATA_GET_CFM, CsrWifiSmeCalibrationDataGetCfmSizeof, CsrWifiSmeCalibrationDataGetCfmSer, CsrWifiSmeCalibrationDataGetCfmDes, CsrWifiSmeCalibrationDataGetCfmSerFree }, - { CSR_WIFI_SME_CALIBRATION_DATA_SET_CFM, CsrWifiSmeCalibrationDataSetCfmSizeof, CsrWifiSmeCalibrationDataSetCfmSer, CsrWifiSmeCalibrationDataSetCfmDes, CsrWifiSmeCalibrationDataSetCfmSerFree }, - { CSR_WIFI_SME_CCX_CONFIG_GET_CFM, CsrWifiSmeCcxConfigGetCfmSizeof, CsrWifiSmeCcxConfigGetCfmSer, CsrWifiSmeCcxConfigGetCfmDes, CsrWifiSmeCcxConfigGetCfmSerFree }, - { CSR_WIFI_SME_CCX_CONFIG_SET_CFM, CsrWifiSmeCcxConfigSetCfmSizeof, CsrWifiSmeCcxConfigSetCfmSer, CsrWifiSmeCcxConfigSetCfmDes, CsrWifiSmeCcxConfigSetCfmSerFree }, - { CSR_WIFI_SME_COEX_CONFIG_GET_CFM, CsrWifiSmeCoexConfigGetCfmSizeof, CsrWifiSmeCoexConfigGetCfmSer, CsrWifiSmeCoexConfigGetCfmDes, CsrWifiSmeCoexConfigGetCfmSerFree }, - { CSR_WIFI_SME_COEX_CONFIG_SET_CFM, CsrWifiSmeCoexConfigSetCfmSizeof, CsrWifiSmeCoexConfigSetCfmSer, CsrWifiSmeCoexConfigSetCfmDes, CsrWifiSmeCoexConfigSetCfmSerFree }, - { CSR_WIFI_SME_COEX_INFO_GET_CFM, CsrWifiSmeCoexInfoGetCfmSizeof, CsrWifiSmeCoexInfoGetCfmSer, CsrWifiSmeCoexInfoGetCfmDes, CsrWifiSmeCoexInfoGetCfmSerFree }, - { CSR_WIFI_SME_CONNECT_CFM, CsrWifiSmeConnectCfmSizeof, CsrWifiSmeConnectCfmSer, CsrWifiSmeConnectCfmDes, CsrWifiSmeConnectCfmSerFree }, - { CSR_WIFI_SME_CONNECTION_CONFIG_GET_CFM, CsrWifiSmeConnectionConfigGetCfmSizeof, CsrWifiSmeConnectionConfigGetCfmSer, CsrWifiSmeConnectionConfigGetCfmDes, CsrWifiSmeConnectionConfigGetCfmSerFree }, - { CSR_WIFI_SME_CONNECTION_INFO_GET_CFM, CsrWifiSmeConnectionInfoGetCfmSizeof, CsrWifiSmeConnectionInfoGetCfmSer, CsrWifiSmeConnectionInfoGetCfmDes, CsrWifiSmeConnectionInfoGetCfmSerFree }, - { CSR_WIFI_SME_CONNECTION_QUALITY_IND, CsrWifiSmeConnectionQualityIndSizeof, CsrWifiSmeConnectionQualityIndSer, CsrWifiSmeConnectionQualityIndDes, CsrWifiSmeConnectionQualityIndSerFree }, - { CSR_WIFI_SME_CONNECTION_STATS_GET_CFM, CsrWifiSmeConnectionStatsGetCfmSizeof, CsrWifiSmeConnectionStatsGetCfmSer, CsrWifiSmeConnectionStatsGetCfmDes, CsrWifiSmeConnectionStatsGetCfmSerFree }, - { CSR_WIFI_SME_DEACTIVATE_CFM, CsrWifiSmeDeactivateCfmSizeof, CsrWifiSmeDeactivateCfmSer, CsrWifiSmeDeactivateCfmDes, CsrWifiSmeDeactivateCfmSerFree }, - { CSR_WIFI_SME_DISCONNECT_CFM, CsrWifiSmeDisconnectCfmSizeof, CsrWifiSmeDisconnectCfmSer, CsrWifiSmeDisconnectCfmDes, CsrWifiSmeDisconnectCfmSerFree }, - { CSR_WIFI_SME_EVENT_MASK_SET_CFM, CsrWifiSmeEventMaskSetCfmSizeof, CsrWifiSmeEventMaskSetCfmSer, CsrWifiSmeEventMaskSetCfmDes, CsrWifiSmeEventMaskSetCfmSerFree }, - { CSR_WIFI_SME_HOST_CONFIG_GET_CFM, CsrWifiSmeHostConfigGetCfmSizeof, CsrWifiSmeHostConfigGetCfmSer, CsrWifiSmeHostConfigGetCfmDes, CsrWifiSmeHostConfigGetCfmSerFree }, - { CSR_WIFI_SME_HOST_CONFIG_SET_CFM, CsrWifiSmeHostConfigSetCfmSizeof, CsrWifiSmeHostConfigSetCfmSer, CsrWifiSmeHostConfigSetCfmDes, CsrWifiSmeHostConfigSetCfmSerFree }, - { CSR_WIFI_SME_IBSS_STATION_IND, CsrWifiSmeIbssStationIndSizeof, CsrWifiSmeIbssStationIndSer, CsrWifiSmeIbssStationIndDes, CsrWifiSmeIbssStationIndSerFree }, - { CSR_WIFI_SME_KEY_CFM, CsrWifiSmeKeyCfmSizeof, CsrWifiSmeKeyCfmSer, CsrWifiSmeKeyCfmDes, CsrWifiSmeKeyCfmSerFree }, - { CSR_WIFI_SME_LINK_QUALITY_GET_CFM, CsrWifiSmeLinkQualityGetCfmSizeof, CsrWifiSmeLinkQualityGetCfmSer, CsrWifiSmeLinkQualityGetCfmDes, CsrWifiSmeLinkQualityGetCfmSerFree }, - { CSR_WIFI_SME_MEDIA_STATUS_IND, CsrWifiSmeMediaStatusIndSizeof, CsrWifiSmeMediaStatusIndSer, CsrWifiSmeMediaStatusIndDes, CsrWifiSmeMediaStatusIndSerFree }, - { CSR_WIFI_SME_MIB_CONFIG_GET_CFM, CsrWifiSmeMibConfigGetCfmSizeof, CsrWifiSmeMibConfigGetCfmSer, CsrWifiSmeMibConfigGetCfmDes, CsrWifiSmeMibConfigGetCfmSerFree }, - { CSR_WIFI_SME_MIB_CONFIG_SET_CFM, CsrWifiSmeMibConfigSetCfmSizeof, CsrWifiSmeMibConfigSetCfmSer, CsrWifiSmeMibConfigSetCfmDes, CsrWifiSmeMibConfigSetCfmSerFree }, - { CSR_WIFI_SME_MIB_GET_CFM, CsrWifiSmeMibGetCfmSizeof, CsrWifiSmeMibGetCfmSer, CsrWifiSmeMibGetCfmDes, CsrWifiSmeMibGetCfmSerFree }, - { CSR_WIFI_SME_MIB_GET_NEXT_CFM, CsrWifiSmeMibGetNextCfmSizeof, CsrWifiSmeMibGetNextCfmSer, CsrWifiSmeMibGetNextCfmDes, CsrWifiSmeMibGetNextCfmSerFree }, - { CSR_WIFI_SME_MIB_SET_CFM, CsrWifiSmeMibSetCfmSizeof, CsrWifiSmeMibSetCfmSer, CsrWifiSmeMibSetCfmDes, CsrWifiSmeMibSetCfmSerFree }, - { CSR_WIFI_SME_MIC_FAILURE_IND, CsrWifiSmeMicFailureIndSizeof, CsrWifiSmeMicFailureIndSer, CsrWifiSmeMicFailureIndDes, CsrWifiSmeMicFailureIndSerFree }, - { CSR_WIFI_SME_MULTICAST_ADDRESS_CFM, CsrWifiSmeMulticastAddressCfmSizeof, CsrWifiSmeMulticastAddressCfmSer, CsrWifiSmeMulticastAddressCfmDes, CsrWifiSmeMulticastAddressCfmSerFree }, - { CSR_WIFI_SME_PACKET_FILTER_SET_CFM, CsrWifiSmePacketFilterSetCfmSizeof, CsrWifiSmePacketFilterSetCfmSer, CsrWifiSmePacketFilterSetCfmDes, CsrWifiSmePacketFilterSetCfmSerFree }, - { CSR_WIFI_SME_PERMANENT_MAC_ADDRESS_GET_CFM, CsrWifiSmePermanentMacAddressGetCfmSizeof, CsrWifiSmePermanentMacAddressGetCfmSer, CsrWifiSmePermanentMacAddressGetCfmDes, CsrWifiSmePermanentMacAddressGetCfmSerFree }, - { CSR_WIFI_SME_PMKID_CANDIDATE_LIST_IND, CsrWifiSmePmkidCandidateListIndSizeof, CsrWifiSmePmkidCandidateListIndSer, CsrWifiSmePmkidCandidateListIndDes, CsrWifiSmePmkidCandidateListIndSerFree }, - { CSR_WIFI_SME_PMKID_CFM, CsrWifiSmePmkidCfmSizeof, CsrWifiSmePmkidCfmSer, CsrWifiSmePmkidCfmDes, CsrWifiSmePmkidCfmSerFree }, - { CSR_WIFI_SME_POWER_CONFIG_GET_CFM, CsrWifiSmePowerConfigGetCfmSizeof, CsrWifiSmePowerConfigGetCfmSer, CsrWifiSmePowerConfigGetCfmDes, CsrWifiSmePowerConfigGetCfmSerFree }, - { CSR_WIFI_SME_POWER_CONFIG_SET_CFM, CsrWifiSmePowerConfigSetCfmSizeof, CsrWifiSmePowerConfigSetCfmSer, CsrWifiSmePowerConfigSetCfmDes, CsrWifiSmePowerConfigSetCfmSerFree }, - { CSR_WIFI_SME_REGULATORY_DOMAIN_INFO_GET_CFM, CsrWifiSmeRegulatoryDomainInfoGetCfmSizeof, CsrWifiSmeRegulatoryDomainInfoGetCfmSer, CsrWifiSmeRegulatoryDomainInfoGetCfmDes, CsrWifiSmeRegulatoryDomainInfoGetCfmSerFree }, - { CSR_WIFI_SME_ROAM_COMPLETE_IND, CsrWifiSmeRoamCompleteIndSizeof, CsrWifiSmeRoamCompleteIndSer, CsrWifiSmeRoamCompleteIndDes, CsrWifiSmeRoamCompleteIndSerFree }, - { CSR_WIFI_SME_ROAM_START_IND, CsrWifiSmeRoamStartIndSizeof, CsrWifiSmeRoamStartIndSer, CsrWifiSmeRoamStartIndDes, CsrWifiSmeRoamStartIndSerFree }, - { CSR_WIFI_SME_ROAMING_CONFIG_GET_CFM, CsrWifiSmeRoamingConfigGetCfmSizeof, CsrWifiSmeRoamingConfigGetCfmSer, CsrWifiSmeRoamingConfigGetCfmDes, CsrWifiSmeRoamingConfigGetCfmSerFree }, - { CSR_WIFI_SME_ROAMING_CONFIG_SET_CFM, CsrWifiSmeRoamingConfigSetCfmSizeof, CsrWifiSmeRoamingConfigSetCfmSer, CsrWifiSmeRoamingConfigSetCfmDes, CsrWifiSmeRoamingConfigSetCfmSerFree }, - { CSR_WIFI_SME_SCAN_CONFIG_GET_CFM, CsrWifiSmeScanConfigGetCfmSizeof, CsrWifiSmeScanConfigGetCfmSer, CsrWifiSmeScanConfigGetCfmDes, CsrWifiSmeScanConfigGetCfmSerFree }, - { CSR_WIFI_SME_SCAN_CONFIG_SET_CFM, CsrWifiSmeScanConfigSetCfmSizeof, CsrWifiSmeScanConfigSetCfmSer, CsrWifiSmeScanConfigSetCfmDes, CsrWifiSmeScanConfigSetCfmSerFree }, - { CSR_WIFI_SME_SCAN_FULL_CFM, CsrWifiSmeScanFullCfmSizeof, CsrWifiSmeScanFullCfmSer, CsrWifiSmeScanFullCfmDes, CsrWifiSmeScanFullCfmSerFree }, - { CSR_WIFI_SME_SCAN_RESULT_IND, CsrWifiSmeScanResultIndSizeof, CsrWifiSmeScanResultIndSer, CsrWifiSmeScanResultIndDes, CsrWifiSmeScanResultIndSerFree }, - { CSR_WIFI_SME_SCAN_RESULTS_FLUSH_CFM, CsrWifiSmeScanResultsFlushCfmSizeof, CsrWifiSmeScanResultsFlushCfmSer, CsrWifiSmeScanResultsFlushCfmDes, CsrWifiSmeScanResultsFlushCfmSerFree }, - { CSR_WIFI_SME_SCAN_RESULTS_GET_CFM, CsrWifiSmeScanResultsGetCfmSizeof, CsrWifiSmeScanResultsGetCfmSer, CsrWifiSmeScanResultsGetCfmDes, CsrWifiSmeScanResultsGetCfmSerFree }, - { CSR_WIFI_SME_SME_STA_CONFIG_GET_CFM, CsrWifiSmeSmeStaConfigGetCfmSizeof, CsrWifiSmeSmeStaConfigGetCfmSer, CsrWifiSmeSmeStaConfigGetCfmDes, CsrWifiSmeSmeStaConfigGetCfmSerFree }, - { CSR_WIFI_SME_SME_STA_CONFIG_SET_CFM, CsrWifiSmeSmeStaConfigSetCfmSizeof, CsrWifiSmeSmeStaConfigSetCfmSer, CsrWifiSmeSmeStaConfigSetCfmDes, CsrWifiSmeSmeStaConfigSetCfmSerFree }, - { CSR_WIFI_SME_STATION_MAC_ADDRESS_GET_CFM, CsrWifiSmeStationMacAddressGetCfmSizeof, CsrWifiSmeStationMacAddressGetCfmSer, CsrWifiSmeStationMacAddressGetCfmDes, CsrWifiSmeStationMacAddressGetCfmSerFree }, - { CSR_WIFI_SME_TSPEC_IND, CsrWifiSmeTspecIndSizeof, CsrWifiSmeTspecIndSer, CsrWifiSmeTspecIndDes, CsrWifiSmeTspecIndSerFree }, - { CSR_WIFI_SME_TSPEC_CFM, CsrWifiSmeTspecCfmSizeof, CsrWifiSmeTspecCfmSer, CsrWifiSmeTspecCfmDes, CsrWifiSmeTspecCfmSerFree }, - { CSR_WIFI_SME_VERSIONS_GET_CFM, CsrWifiSmeVersionsGetCfmSizeof, CsrWifiSmeVersionsGetCfmSer, CsrWifiSmeVersionsGetCfmDes, CsrWifiSmeVersionsGetCfmSerFree }, - { CSR_WIFI_SME_WIFI_FLIGHTMODE_CFM, CsrWifiSmeWifiFlightmodeCfmSizeof, CsrWifiSmeWifiFlightmodeCfmSer, CsrWifiSmeWifiFlightmodeCfmDes, CsrWifiSmeWifiFlightmodeCfmSerFree }, - { CSR_WIFI_SME_WIFI_OFF_IND, CsrWifiSmeWifiOffIndSizeof, CsrWifiSmeWifiOffIndSer, CsrWifiSmeWifiOffIndDes, CsrWifiSmeWifiOffIndSerFree }, - { CSR_WIFI_SME_WIFI_OFF_CFM, CsrWifiSmeWifiOffCfmSizeof, CsrWifiSmeWifiOffCfmSer, CsrWifiSmeWifiOffCfmDes, CsrWifiSmeWifiOffCfmSerFree }, - { CSR_WIFI_SME_WIFI_ON_CFM, CsrWifiSmeWifiOnCfmSizeof, CsrWifiSmeWifiOnCfmSer, CsrWifiSmeWifiOnCfmDes, CsrWifiSmeWifiOnCfmSerFree }, - { CSR_WIFI_SME_CLOAKED_SSIDS_SET_CFM, CsrWifiSmeCloakedSsidsSetCfmSizeof, CsrWifiSmeCloakedSsidsSetCfmSer, CsrWifiSmeCloakedSsidsSetCfmDes, CsrWifiSmeCloakedSsidsSetCfmSerFree }, - { CSR_WIFI_SME_CLOAKED_SSIDS_GET_CFM, CsrWifiSmeCloakedSsidsGetCfmSizeof, CsrWifiSmeCloakedSsidsGetCfmSer, CsrWifiSmeCloakedSsidsGetCfmDes, CsrWifiSmeCloakedSsidsGetCfmSerFree }, - { CSR_WIFI_SME_WIFI_ON_IND, CsrWifiSmeWifiOnIndSizeof, CsrWifiSmeWifiOnIndSer, CsrWifiSmeWifiOnIndDes, CsrWifiSmeWifiOnIndSerFree }, - { CSR_WIFI_SME_SME_COMMON_CONFIG_GET_CFM, CsrWifiSmeSmeCommonConfigGetCfmSizeof, CsrWifiSmeSmeCommonConfigGetCfmSer, CsrWifiSmeSmeCommonConfigGetCfmDes, CsrWifiSmeSmeCommonConfigGetCfmSerFree }, - { CSR_WIFI_SME_SME_COMMON_CONFIG_SET_CFM, CsrWifiSmeSmeCommonConfigSetCfmSizeof, CsrWifiSmeSmeCommonConfigSetCfmSer, CsrWifiSmeSmeCommonConfigSetCfmDes, CsrWifiSmeSmeCommonConfigSetCfmSerFree }, - { CSR_WIFI_SME_INTERFACE_CAPABILITY_GET_CFM, CsrWifiSmeInterfaceCapabilityGetCfmSizeof, CsrWifiSmeInterfaceCapabilityGetCfmSer, CsrWifiSmeInterfaceCapabilityGetCfmDes, CsrWifiSmeInterfaceCapabilityGetCfmSerFree }, - { CSR_WIFI_SME_ERROR_IND, CsrWifiSmeErrorIndSizeof, CsrWifiSmeErrorIndSer, CsrWifiSmeErrorIndDes, CsrWifiSmeErrorIndSerFree }, - { CSR_WIFI_SME_INFO_IND, CsrWifiSmeInfoIndSizeof, CsrWifiSmeInfoIndSer, CsrWifiSmeInfoIndDes, CsrWifiSmeInfoIndSerFree }, - { CSR_WIFI_SME_CORE_DUMP_IND, CsrWifiSmeCoreDumpIndSizeof, CsrWifiSmeCoreDumpIndSer, CsrWifiSmeCoreDumpIndDes, CsrWifiSmeCoreDumpIndSerFree }, - { CSR_WIFI_SME_AMP_STATUS_CHANGE_IND, CsrWifiSmeAmpStatusChangeIndSizeof, CsrWifiSmeAmpStatusChangeIndSer, CsrWifiSmeAmpStatusChangeIndDes, CsrWifiSmeAmpStatusChangeIndSerFree }, - { CSR_WIFI_SME_WPS_CONFIGURATION_CFM, CsrWifiSmeWpsConfigurationCfmSizeof, CsrWifiSmeWpsConfigurationCfmSer, CsrWifiSmeWpsConfigurationCfmDes, CsrWifiSmeWpsConfigurationCfmSerFree }, - - { 0, NULL, NULL, NULL, NULL }, -}; - -CsrMsgConvMsgEntry* CsrWifiSmeConverterLookup(CsrMsgConvMsgEntry *ce, u16 msgType) -{ - if (msgType & CSR_PRIM_UPSTREAM) - { - u16 idx = (msgType & ~CSR_PRIM_UPSTREAM) + CSR_WIFI_SME_PRIM_DOWNSTREAM_COUNT; - if (idx < (CSR_WIFI_SME_PRIM_UPSTREAM_COUNT + CSR_WIFI_SME_PRIM_DOWNSTREAM_COUNT) && - csrwifisme_conv_lut[idx].msgType == msgType) - { - return &csrwifisme_conv_lut[idx]; - } - } - else - { - if (msgType < CSR_WIFI_SME_PRIM_DOWNSTREAM_COUNT && - csrwifisme_conv_lut[msgType].msgType == msgType) - { - return &csrwifisme_conv_lut[msgType]; - } - } - return NULL; -} - - -void CsrWifiSmeConverterInit(void) -{ - CsrMsgConvInsert(CSR_WIFI_SME_PRIM, csrwifisme_conv_lut); - CsrMsgConvCustomLookupRegister(CSR_WIFI_SME_PRIM, CsrWifiSmeConverterLookup); -} - - -#ifdef CSR_LOG_ENABLE -static const CsrLogPrimitiveInformation csrwifisme_conv_info = { - CSR_WIFI_SME_PRIM, - (char *)"CSR_WIFI_SME_PRIM", - csrwifisme_conv_lut -}; -const CsrLogPrimitiveInformation* CsrWifiSmeTechInfoGet(void) -{ - return &csrwifisme_conv_info; -} - - -#endif /* CSR_LOG_ENABLE */ -#endif /* EXCLUDE_CSR_WIFI_SME_MODULE */ diff --git a/drivers/staging/csr/csr_wifi_sme_converter_init.h b/drivers/staging/csr/csr_wifi_sme_converter_init.h deleted file mode 100644 index ba5e4b44bb6b..000000000000 --- a/drivers/staging/csr/csr_wifi_sme_converter_init.h +++ /dev/null @@ -1,34 +0,0 @@ -/***************************************************************************** - - (c) Cambridge Silicon Radio Limited 2012 - All rights reserved and confidential information of CSR - - Refer to LICENSE.txt included with this source for details - on the license terms. - -*****************************************************************************/ - -/* Note: this is an auto-generated file. */ - -#ifndef CSR_WIFI_SME_CONVERTER_INIT_H__ -#define CSR_WIFI_SME_CONVERTER_INIT_H__ - -#ifndef EXCLUDE_CSR_WIFI_SME_MODULE - -#include "csr_msgconv.h" - -#ifdef CSR_LOG_ENABLE -#include "csr_log.h" - -extern const CsrLogPrimitiveInformation* CsrWifiSmeTechInfoGet(void); -#endif /* CSR_LOG_ENABLE */ - -extern void CsrWifiSmeConverterInit(void); - -#else /* EXCLUDE_CSR_WIFI_SME_MODULE */ - -#define CsrWifiSmeConverterInit() - -#endif /* EXCLUDE_CSR_WIFI_SME_MODULE */ - -#endif /* CSR_WIFI_SME_CONVERTER_INIT_H__ */ diff --git a/drivers/staging/csr/csr_wifi_sme_free_downstream_contents.c b/drivers/staging/csr/csr_wifi_sme_free_downstream_contents.c deleted file mode 100644 index 03b5ddb22cd7..000000000000 --- a/drivers/staging/csr/csr_wifi_sme_free_downstream_contents.c +++ /dev/null @@ -1,187 +0,0 @@ -/***************************************************************************** - - (c) Cambridge Silicon Radio Limited 2012 - All rights reserved and confidential information of CSR - - Refer to LICENSE.txt included with this source for details - on the license terms. - -*****************************************************************************/ - -/* Note: this is an auto-generated file. */ -#include -#include "csr_wifi_sme_prim.h" -#include "csr_wifi_sme_lib.h" - -/*----------------------------------------------------------------------------* - * NAME - * CsrWifiSmeFreeDownstreamMessageContents - * - * DESCRIPTION - * - * - * PARAMETERS - * eventClass: only the value CSR_WIFI_SME_PRIM will be handled - * message: the message to free - *----------------------------------------------------------------------------*/ -void CsrWifiSmeFreeDownstreamMessageContents(u16 eventClass, void *message) -{ - if (eventClass != CSR_WIFI_SME_PRIM) - { - return; - } - if (NULL == message) - { - return; - } - - switch (*((CsrWifiSmePrim *) message)) - { - case CSR_WIFI_SME_BLACKLIST_REQ: - { - CsrWifiSmeBlacklistReq *p = (CsrWifiSmeBlacklistReq *)message; - kfree(p->setAddresses); - p->setAddresses = NULL; - break; - } - case CSR_WIFI_SME_CALIBRATION_DATA_SET_REQ: - { - CsrWifiSmeCalibrationDataSetReq *p = (CsrWifiSmeCalibrationDataSetReq *)message; - kfree(p->calibrationData); - p->calibrationData = NULL; - break; - } - case CSR_WIFI_SME_CONNECT_REQ: - { - CsrWifiSmeConnectReq *p = (CsrWifiSmeConnectReq *)message; - kfree(p->connectionConfig.mlmeAssociateReqInformationElements); - p->connectionConfig.mlmeAssociateReqInformationElements = NULL; - break; - } - case CSR_WIFI_SME_MIB_GET_NEXT_REQ: - { - CsrWifiSmeMibGetNextReq *p = (CsrWifiSmeMibGetNextReq *)message; - kfree(p->mibAttribute); - p->mibAttribute = NULL; - break; - } - case CSR_WIFI_SME_MIB_GET_REQ: - { - CsrWifiSmeMibGetReq *p = (CsrWifiSmeMibGetReq *)message; - kfree(p->mibAttribute); - p->mibAttribute = NULL; - break; - } - case CSR_WIFI_SME_MIB_SET_REQ: - { - CsrWifiSmeMibSetReq *p = (CsrWifiSmeMibSetReq *)message; - kfree(p->mibAttribute); - p->mibAttribute = NULL; - break; - } - case CSR_WIFI_SME_MULTICAST_ADDRESS_REQ: - { - CsrWifiSmeMulticastAddressReq *p = (CsrWifiSmeMulticastAddressReq *)message; - kfree(p->setAddresses); - p->setAddresses = NULL; - break; - } - case CSR_WIFI_SME_PACKET_FILTER_SET_REQ: - { - CsrWifiSmePacketFilterSetReq *p = (CsrWifiSmePacketFilterSetReq *)message; - kfree(p->filter); - p->filter = NULL; - break; - } - case CSR_WIFI_SME_PMKID_REQ: - { - CsrWifiSmePmkidReq *p = (CsrWifiSmePmkidReq *)message; - kfree(p->setPmkids); - p->setPmkids = NULL; - break; - } - case CSR_WIFI_SME_SCAN_CONFIG_SET_REQ: - { - CsrWifiSmeScanConfigSetReq *p = (CsrWifiSmeScanConfigSetReq *)message; - kfree(p->scanConfig.passiveChannelList); - p->scanConfig.passiveChannelList = NULL; - break; - } - case CSR_WIFI_SME_SCAN_FULL_REQ: - { - CsrWifiSmeScanFullReq *p = (CsrWifiSmeScanFullReq *)message; - kfree(p->ssid); - p->ssid = NULL; - kfree(p->channelList); - p->channelList = NULL; - kfree(p->probeIe); - p->probeIe = NULL; - break; - } - case CSR_WIFI_SME_TSPEC_REQ: - { - CsrWifiSmeTspecReq *p = (CsrWifiSmeTspecReq *)message; - kfree(p->tspec); - p->tspec = NULL; - kfree(p->tclas); - p->tclas = NULL; - break; - } - case CSR_WIFI_SME_WIFI_FLIGHTMODE_REQ: - { - CsrWifiSmeWifiFlightmodeReq *p = (CsrWifiSmeWifiFlightmodeReq *)message; - { - u16 i1; - for (i1 = 0; i1 < p->mibFilesCount; i1++) - { - kfree(p->mibFiles[i1].data); - p->mibFiles[i1].data = NULL; - } - } - kfree(p->mibFiles); - p->mibFiles = NULL; - break; - } - case CSR_WIFI_SME_WIFI_ON_REQ: - { - CsrWifiSmeWifiOnReq *p = (CsrWifiSmeWifiOnReq *)message; - { - u16 i1; - for (i1 = 0; i1 < p->mibFilesCount; i1++) - { - kfree(p->mibFiles[i1].data); - p->mibFiles[i1].data = NULL; - } - } - kfree(p->mibFiles); - p->mibFiles = NULL; - break; - } - case CSR_WIFI_SME_CLOAKED_SSIDS_SET_REQ: - { - CsrWifiSmeCloakedSsidsSetReq *p = (CsrWifiSmeCloakedSsidsSetReq *)message; - kfree(p->cloakedSsids.cloakedSsids); - p->cloakedSsids.cloakedSsids = NULL; - break; - } - case CSR_WIFI_SME_WPS_CONFIGURATION_REQ: - { - CsrWifiSmeWpsConfigurationReq *p = (CsrWifiSmeWpsConfigurationReq *)message; - kfree(p->wpsConfig.secondaryDeviceType); - p->wpsConfig.secondaryDeviceType = NULL; - break; - } - case CSR_WIFI_SME_SET_REQ: - { - CsrWifiSmeSetReq *p = (CsrWifiSmeSetReq *)message; - kfree(p->data); - p->data = NULL; - break; - } - - default: - break; - } -} - - diff --git a/drivers/staging/csr/csr_wifi_sme_free_upstream_contents.c b/drivers/staging/csr/csr_wifi_sme_free_upstream_contents.c deleted file mode 100644 index c04767baaa5b..000000000000 --- a/drivers/staging/csr/csr_wifi_sme_free_upstream_contents.c +++ /dev/null @@ -1,275 +0,0 @@ -/***************************************************************************** - - (c) Cambridge Silicon Radio Limited 2011 - All rights reserved and confidential information of CSR - - Refer to LICENSE.txt included with this source for details - on the license terms. - -*****************************************************************************/ - -/* Note: this is an auto-generated file. */ -#include -#include "csr_wifi_sme_prim.h" -#include "csr_wifi_sme_lib.h" - -/*----------------------------------------------------------------------------* - * NAME - * CsrWifiSmeFreeUpstreamMessageContents - * - * DESCRIPTION - * - * - * PARAMETERS - * eventClass: only the value CSR_WIFI_SME_PRIM will be handled - * message: the message to free - *----------------------------------------------------------------------------*/ -void CsrWifiSmeFreeUpstreamMessageContents(u16 eventClass, void *message) -{ - if (eventClass != CSR_WIFI_SME_PRIM) - { - return; - } - if (NULL == message) - { - return; - } - - switch (*((CsrWifiSmePrim *) message)) - { - case CSR_WIFI_SME_ASSOCIATION_COMPLETE_IND: - { - CsrWifiSmeAssociationCompleteInd *p = (CsrWifiSmeAssociationCompleteInd *)message; - kfree(p->connectionInfo.beaconFrame); - p->connectionInfo.beaconFrame = NULL; - kfree(p->connectionInfo.associationReqFrame); - p->connectionInfo.associationReqFrame = NULL; - kfree(p->connectionInfo.associationRspFrame); - p->connectionInfo.associationRspFrame = NULL; - kfree(p->connectionInfo.assocScanInfoElements); - p->connectionInfo.assocScanInfoElements = NULL; - kfree(p->connectionInfo.assocReqInfoElements); - p->connectionInfo.assocReqInfoElements = NULL; - kfree(p->connectionInfo.assocRspInfoElements); - p->connectionInfo.assocRspInfoElements = NULL; - break; - } - case CSR_WIFI_SME_BLACKLIST_CFM: - { - CsrWifiSmeBlacklistCfm *p = (CsrWifiSmeBlacklistCfm *)message; - kfree(p->getAddresses); - p->getAddresses = NULL; - break; - } - case CSR_WIFI_SME_CALIBRATION_DATA_GET_CFM: - { - CsrWifiSmeCalibrationDataGetCfm *p = (CsrWifiSmeCalibrationDataGetCfm *)message; - kfree(p->calibrationData); - p->calibrationData = NULL; - break; - } - case CSR_WIFI_SME_CONNECTION_CONFIG_GET_CFM: - { - CsrWifiSmeConnectionConfigGetCfm *p = (CsrWifiSmeConnectionConfigGetCfm *)message; - kfree(p->connectionConfig.mlmeAssociateReqInformationElements); - p->connectionConfig.mlmeAssociateReqInformationElements = NULL; - break; - } - case CSR_WIFI_SME_CONNECTION_INFO_GET_CFM: - { - CsrWifiSmeConnectionInfoGetCfm *p = (CsrWifiSmeConnectionInfoGetCfm *)message; - kfree(p->connectionInfo.beaconFrame); - p->connectionInfo.beaconFrame = NULL; - kfree(p->connectionInfo.associationReqFrame); - p->connectionInfo.associationReqFrame = NULL; - kfree(p->connectionInfo.associationRspFrame); - p->connectionInfo.associationRspFrame = NULL; - kfree(p->connectionInfo.assocScanInfoElements); - p->connectionInfo.assocScanInfoElements = NULL; - kfree(p->connectionInfo.assocReqInfoElements); - p->connectionInfo.assocReqInfoElements = NULL; - kfree(p->connectionInfo.assocRspInfoElements); - p->connectionInfo.assocRspInfoElements = NULL; - break; - } - case CSR_WIFI_SME_MEDIA_STATUS_IND: - { - CsrWifiSmeMediaStatusInd *p = (CsrWifiSmeMediaStatusInd *)message; - kfree(p->connectionInfo.beaconFrame); - p->connectionInfo.beaconFrame = NULL; - kfree(p->connectionInfo.associationReqFrame); - p->connectionInfo.associationReqFrame = NULL; - kfree(p->connectionInfo.associationRspFrame); - p->connectionInfo.associationRspFrame = NULL; - kfree(p->connectionInfo.assocScanInfoElements); - p->connectionInfo.assocScanInfoElements = NULL; - kfree(p->connectionInfo.assocReqInfoElements); - p->connectionInfo.assocReqInfoElements = NULL; - kfree(p->connectionInfo.assocRspInfoElements); - p->connectionInfo.assocRspInfoElements = NULL; - break; - } - case CSR_WIFI_SME_MIB_GET_CFM: - { - CsrWifiSmeMibGetCfm *p = (CsrWifiSmeMibGetCfm *)message; - kfree(p->mibAttribute); - p->mibAttribute = NULL; - break; - } - case CSR_WIFI_SME_MIB_GET_NEXT_CFM: - { - CsrWifiSmeMibGetNextCfm *p = (CsrWifiSmeMibGetNextCfm *)message; - kfree(p->mibAttribute); - p->mibAttribute = NULL; - break; - } - case CSR_WIFI_SME_MULTICAST_ADDRESS_CFM: - { - CsrWifiSmeMulticastAddressCfm *p = (CsrWifiSmeMulticastAddressCfm *)message; - kfree(p->getAddresses); - p->getAddresses = NULL; - break; - } - case CSR_WIFI_SME_PMKID_CANDIDATE_LIST_IND: - { - CsrWifiSmePmkidCandidateListInd *p = (CsrWifiSmePmkidCandidateListInd *)message; - kfree(p->pmkidCandidates); - p->pmkidCandidates = NULL; - break; - } - case CSR_WIFI_SME_PMKID_CFM: - { - CsrWifiSmePmkidCfm *p = (CsrWifiSmePmkidCfm *)message; - kfree(p->getPmkids); - p->getPmkids = NULL; - break; - } - case CSR_WIFI_SME_SCAN_CONFIG_GET_CFM: - { - CsrWifiSmeScanConfigGetCfm *p = (CsrWifiSmeScanConfigGetCfm *)message; - kfree(p->scanConfig.passiveChannelList); - p->scanConfig.passiveChannelList = NULL; - break; - } - case CSR_WIFI_SME_SCAN_RESULT_IND: - { - CsrWifiSmeScanResultInd *p = (CsrWifiSmeScanResultInd *)message; - kfree(p->result.informationElements); - p->result.informationElements = NULL; - switch (p->result.p2pDeviceRole) - { - case CSR_WIFI_SME_P2P_ROLE_GO: - { - u16 i4; - for (i4 = 0; i4 < p->result.deviceInfo.groupInfo.p2pClientInfoCount; i4++) - { - kfree(p->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secDeviceType); - p->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secDeviceType = NULL; - } - } - kfree(p->result.deviceInfo.groupInfo.p2PClientInfo); - p->result.deviceInfo.groupInfo.p2PClientInfo = NULL; - break; - case CSR_WIFI_SME_P2P_ROLE_STANDALONE: - kfree(p->result.deviceInfo.standalonedevInfo.secDeviceType); - p->result.deviceInfo.standalonedevInfo.secDeviceType = NULL; - break; - default: - break; - } - break; - } - case CSR_WIFI_SME_SCAN_RESULTS_GET_CFM: - { - CsrWifiSmeScanResultsGetCfm *p = (CsrWifiSmeScanResultsGetCfm *)message; - { - u16 i1; - for (i1 = 0; i1 < p->scanResultsCount; i1++) - { - kfree(p->scanResults[i1].informationElements); - p->scanResults[i1].informationElements = NULL; - switch (p->scanResults[i1].p2pDeviceRole) - { - case CSR_WIFI_SME_P2P_ROLE_GO: - { - u16 i4; - for (i4 = 0; i4 < p->scanResults[i1].deviceInfo.groupInfo.p2pClientInfoCount; i4++) - { - kfree(p->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secDeviceType); - p->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secDeviceType = NULL; - } - } - kfree(p->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo); - p->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo = NULL; - break; - case CSR_WIFI_SME_P2P_ROLE_STANDALONE: - kfree(p->scanResults[i1].deviceInfo.standalonedevInfo.secDeviceType); - p->scanResults[i1].deviceInfo.standalonedevInfo.secDeviceType = NULL; - break; - default: - break; - } - } - } - kfree(p->scanResults); - p->scanResults = NULL; - break; - } - case CSR_WIFI_SME_TSPEC_IND: - { - CsrWifiSmeTspecInd *p = (CsrWifiSmeTspecInd *)message; - kfree(p->tspec); - p->tspec = NULL; - break; - } - case CSR_WIFI_SME_TSPEC_CFM: - { - CsrWifiSmeTspecCfm *p = (CsrWifiSmeTspecCfm *)message; - kfree(p->tspec); - p->tspec = NULL; - break; - } - case CSR_WIFI_SME_VERSIONS_GET_CFM: - { - CsrWifiSmeVersionsGetCfm *p = (CsrWifiSmeVersionsGetCfm *)message; - kfree(p->versions.routerBuild); - p->versions.routerBuild = NULL; - kfree(p->versions.smeBuild); - p->versions.smeBuild = NULL; - break; - } - case CSR_WIFI_SME_CLOAKED_SSIDS_GET_CFM: - { - CsrWifiSmeCloakedSsidsGetCfm *p = (CsrWifiSmeCloakedSsidsGetCfm *)message; - kfree(p->cloakedSsids.cloakedSsids); - p->cloakedSsids.cloakedSsids = NULL; - break; - } - case CSR_WIFI_SME_ERROR_IND: - { - CsrWifiSmeErrorInd *p = (CsrWifiSmeErrorInd *)message; - kfree(p->errorMessage); - p->errorMessage = NULL; - break; - } - case CSR_WIFI_SME_INFO_IND: - { - CsrWifiSmeInfoInd *p = (CsrWifiSmeInfoInd *)message; - kfree(p->infoMessage); - p->infoMessage = NULL; - break; - } - case CSR_WIFI_SME_CORE_DUMP_IND: - { - CsrWifiSmeCoreDumpInd *p = (CsrWifiSmeCoreDumpInd *)message; - kfree(p->data); - p->data = NULL; - break; - } - - default: - break; - } -} - - diff --git a/drivers/staging/csr/csr_wifi_sme_lib.h b/drivers/staging/csr/csr_wifi_sme_lib.h deleted file mode 100644 index 53cf1268286e..000000000000 --- a/drivers/staging/csr/csr_wifi_sme_lib.h +++ /dev/null @@ -1,4303 +0,0 @@ -/***************************************************************************** - - (c) Cambridge Silicon Radio Limited 2012 - All rights reserved and confidential information of CSR - - Refer to LICENSE.txt included with this source for details - on the license terms. - -*****************************************************************************/ - -/* Note: this is an auto-generated file. */ - -#ifndef CSR_WIFI_SME_LIB_H__ -#define CSR_WIFI_SME_LIB_H__ - -#include "csr_sched.h" -#include "csr_macro.h" -#include "csr_msg_transport.h" - -#include "csr_wifi_lib.h" - -#include "csr_wifi_sme_prim.h" -#include "csr_wifi_sme_task.h" - - -#ifndef CSR_WIFI_SME_LIB_DESTINATION_QUEUE -# ifdef CSR_WIFI_NME_ENABLE -# include "csr_wifi_nme_task.h" -# define CSR_WIFI_SME_LIB_DESTINATION_QUEUE CSR_WIFI_NME_IFACEQUEUE -# else -# define CSR_WIFI_SME_LIB_DESTINATION_QUEUE CSR_WIFI_SME_IFACEQUEUE -# endif -#endif - -/*----------------------------------------------------------------------------* - * CsrWifiSmeFreeUpstreamMessageContents - * - * DESCRIPTION - * Free the allocated memory in a CSR_WIFI_SME upstream message. Does not - * free the message itself, and can only be used for upstream messages. - * - * PARAMETERS - * Deallocates the resources in a CSR_WIFI_SME upstream message - *----------------------------------------------------------------------------*/ -void CsrWifiSmeFreeUpstreamMessageContents(u16 eventClass, void *message); - -/*----------------------------------------------------------------------------* - * CsrWifiSmeFreeDownstreamMessageContents - * - * DESCRIPTION - * Free the allocated memory in a CSR_WIFI_SME downstream message. Does not - * free the message itself, and can only be used for downstream messages. - * - * PARAMETERS - * Deallocates the resources in a CSR_WIFI_SME downstream message - *----------------------------------------------------------------------------*/ -void CsrWifiSmeFreeDownstreamMessageContents(u16 eventClass, void *message); - -/*----------------------------------------------------------------------------* - * Enum to string functions - *----------------------------------------------------------------------------*/ -const char* CsrWifiSme80211NetworkTypeToString(CsrWifiSme80211NetworkType value); -const char* CsrWifiSme80211PrivacyModeToString(CsrWifiSme80211PrivacyMode value); -const char* CsrWifiSme80211dTrustLevelToString(CsrWifiSme80211dTrustLevel value); -const char* CsrWifiSmeAmpStatusToString(CsrWifiSmeAmpStatus value); -const char* CsrWifiSmeAuthModeToString(CsrWifiSmeAuthMode value); -const char* CsrWifiSmeBasicUsabilityToString(CsrWifiSmeBasicUsability value); -const char* CsrWifiSmeBssTypeToString(CsrWifiSmeBssType value); -const char* CsrWifiSmeCoexSchemeToString(CsrWifiSmeCoexScheme value); -const char* CsrWifiSmeControlIndicationToString(CsrWifiSmeControlIndication value); -const char* CsrWifiSmeCtsProtectionTypeToString(CsrWifiSmeCtsProtectionType value); -const char* CsrWifiSmeD3AutoScanModeToString(CsrWifiSmeD3AutoScanMode value); -const char* CsrWifiSmeEncryptionToString(CsrWifiSmeEncryption value); -const char* CsrWifiSmeFirmwareDriverInterfaceToString(CsrWifiSmeFirmwareDriverInterface value); -const char* CsrWifiSmeHostPowerModeToString(CsrWifiSmeHostPowerMode value); -const char* CsrWifiSmeIEEE80211ReasonToString(CsrWifiSmeIEEE80211Reason value); -const char* CsrWifiSmeIEEE80211ResultToString(CsrWifiSmeIEEE80211Result value); -const char* CsrWifiSmeIndicationsToString(CsrWifiSmeIndications value); -const char* CsrWifiSmeKeyTypeToString(CsrWifiSmeKeyType value); -const char* CsrWifiSmeListActionToString(CsrWifiSmeListAction value); -const char* CsrWifiSmeMediaStatusToString(CsrWifiSmeMediaStatus value); -const char* CsrWifiSmeP2pCapabilityToString(CsrWifiSmeP2pCapability value); -const char* CsrWifiSmeP2pGroupCapabilityToString(CsrWifiSmeP2pGroupCapability value); -const char* CsrWifiSmeP2pNoaConfigMethodToString(CsrWifiSmeP2pNoaConfigMethod value); -const char* CsrWifiSmeP2pRoleToString(CsrWifiSmeP2pRole value); -const char* CsrWifiSmeP2pStatusToString(CsrWifiSmeP2pStatus value); -const char* CsrWifiSmePacketFilterModeToString(CsrWifiSmePacketFilterMode value); -const char* CsrWifiSmePowerSaveLevelToString(CsrWifiSmePowerSaveLevel value); -const char* CsrWifiSmePreambleTypeToString(CsrWifiSmePreambleType value); -const char* CsrWifiSmeRadioIFToString(CsrWifiSmeRadioIF value); -const char* CsrWifiSmeRegulatoryDomainToString(CsrWifiSmeRegulatoryDomain value); -const char* CsrWifiSmeRoamReasonToString(CsrWifiSmeRoamReason value); -const char* CsrWifiSmeScanTypeToString(CsrWifiSmeScanType value); -const char* CsrWifiSmeTrafficTypeToString(CsrWifiSmeTrafficType value); -const char* CsrWifiSmeTspecCtrlToString(CsrWifiSmeTspecCtrl value); -const char* CsrWifiSmeTspecResultCodeToString(CsrWifiSmeTspecResultCode value); -const char* CsrWifiSmeWepAuthModeToString(CsrWifiSmeWepAuthMode value); -const char* CsrWifiSmeWepCredentialTypeToString(CsrWifiSmeWepCredentialType value); -const char* CsrWifiSmeWmmModeToString(CsrWifiSmeWmmMode value); -const char* CsrWifiSmeWmmQosInfoToString(CsrWifiSmeWmmQosInfo value); -const char* CsrWifiSmeWpsConfigTypeToString(CsrWifiSmeWpsConfigType value); -const char* CsrWifiSmeWpsDeviceCategoryToString(CsrWifiSmeWpsDeviceCategory value); -const char* CsrWifiSmeWpsDeviceSubCategoryToString(CsrWifiSmeWpsDeviceSubCategory value); -const char* CsrWifiSmeWpsDpidToString(CsrWifiSmeWpsDpid value); -const char* CsrWifiSmeWpsRegistrationToString(CsrWifiSmeWpsRegistration value); - - -/*----------------------------------------------------------------------------* - * CsrPrim Type toString function. - * Converts a message type to the String name of the Message - *----------------------------------------------------------------------------*/ -const char* CsrWifiSmePrimTypeToString(CsrPrim msgType); - -/*----------------------------------------------------------------------------* - * Lookup arrays for PrimType name Strings - *----------------------------------------------------------------------------*/ -extern const char *CsrWifiSmeUpstreamPrimNames[CSR_WIFI_SME_PRIM_UPSTREAM_COUNT]; -extern const char *CsrWifiSmeDownstreamPrimNames[CSR_WIFI_SME_PRIM_DOWNSTREAM_COUNT]; - -/******************************************************************************* - - NAME - CsrWifiSmeActivateReqSend - - DESCRIPTION - The WMA sends this primitive to activate the SME. - The WMA must activate the SME before it can send any other primitive. - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - -*******************************************************************************/ -#define CsrWifiSmeActivateReqCreate(msg__, dst__, src__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeActivateReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_ACTIVATE_REQ, dst__, src__); - -#define CsrWifiSmeActivateReqSendTo(dst__, src__) \ - { \ - CsrWifiSmeActivateReq *msg__; \ - CsrWifiSmeActivateReqCreate(msg__, dst__, src__); \ - CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeActivateReqSend(src__) \ - CsrWifiSmeActivateReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__) - -/******************************************************************************* - - NAME - CsrWifiSmeActivateCfmSend - - DESCRIPTION - The SME sends this primitive when the activation is complete. - - PARAMETERS - queue - Destination Task Queue - status - Reports the result of the request - -*******************************************************************************/ -#define CsrWifiSmeActivateCfmCreate(msg__, dst__, src__, status__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeActivateCfm), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_ACTIVATE_CFM, dst__, src__); \ - msg__->status = (status__); - -#define CsrWifiSmeActivateCfmSendTo(dst__, src__, status__) \ - { \ - CsrWifiSmeActivateCfm *msg__; \ - CsrWifiSmeActivateCfmCreate(msg__, dst__, src__, status__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeActivateCfmSend(dst__, status__) \ - CsrWifiSmeActivateCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__) - -/******************************************************************************* - - NAME - CsrWifiSmeAdhocConfigGetReqSend - - DESCRIPTION - This primitive gets the value of the adHocConfig parameter. - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - -*******************************************************************************/ -#define CsrWifiSmeAdhocConfigGetReqCreate(msg__, dst__, src__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeAdhocConfigGetReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_ADHOC_CONFIG_GET_REQ, dst__, src__); - -#define CsrWifiSmeAdhocConfigGetReqSendTo(dst__, src__) \ - { \ - CsrWifiSmeAdhocConfigGetReq *msg__; \ - CsrWifiSmeAdhocConfigGetReqCreate(msg__, dst__, src__); \ - CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeAdhocConfigGetReqSend(src__) \ - CsrWifiSmeAdhocConfigGetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__) - -/******************************************************************************* - - NAME - CsrWifiSmeAdhocConfigGetCfmSend - - DESCRIPTION - This primitive reports the result of the request. - - PARAMETERS - queue - Destination Task Queue - status - Reports the result of the request - adHocConfig - Contains the values used when starting an Ad-hoc (IBSS) - connection. - -*******************************************************************************/ -#define CsrWifiSmeAdhocConfigGetCfmCreate(msg__, dst__, src__, status__, adHocConfig__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeAdhocConfigGetCfm), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_ADHOC_CONFIG_GET_CFM, dst__, src__); \ - msg__->status = (status__); \ - msg__->adHocConfig = (adHocConfig__); - -#define CsrWifiSmeAdhocConfigGetCfmSendTo(dst__, src__, status__, adHocConfig__) \ - { \ - CsrWifiSmeAdhocConfigGetCfm *msg__; \ - CsrWifiSmeAdhocConfigGetCfmCreate(msg__, dst__, src__, status__, adHocConfig__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeAdhocConfigGetCfmSend(dst__, status__, adHocConfig__) \ - CsrWifiSmeAdhocConfigGetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__, adHocConfig__) - -/******************************************************************************* - - NAME - CsrWifiSmeAdhocConfigSetReqSend - - DESCRIPTION - This primitive sets the value of the adHocConfig parameter. - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - adHocConfig - Sets the values to use when starting an ad hoc network. - -*******************************************************************************/ -#define CsrWifiSmeAdhocConfigSetReqCreate(msg__, dst__, src__, adHocConfig__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeAdhocConfigSetReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_ADHOC_CONFIG_SET_REQ, dst__, src__); \ - msg__->adHocConfig = (adHocConfig__); - -#define CsrWifiSmeAdhocConfigSetReqSendTo(dst__, src__, adHocConfig__) \ - { \ - CsrWifiSmeAdhocConfigSetReq *msg__; \ - CsrWifiSmeAdhocConfigSetReqCreate(msg__, dst__, src__, adHocConfig__); \ - CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeAdhocConfigSetReqSend(src__, adHocConfig__) \ - CsrWifiSmeAdhocConfigSetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, adHocConfig__) - -/******************************************************************************* - - NAME - CsrWifiSmeAdhocConfigSetCfmSend - - DESCRIPTION - This primitive reports the result of the request. - - PARAMETERS - queue - Destination Task Queue - status - Reports the result of the request - -*******************************************************************************/ -#define CsrWifiSmeAdhocConfigSetCfmCreate(msg__, dst__, src__, status__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeAdhocConfigSetCfm), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_ADHOC_CONFIG_SET_CFM, dst__, src__); \ - msg__->status = (status__); - -#define CsrWifiSmeAdhocConfigSetCfmSendTo(dst__, src__, status__) \ - { \ - CsrWifiSmeAdhocConfigSetCfm *msg__; \ - CsrWifiSmeAdhocConfigSetCfmCreate(msg__, dst__, src__, status__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeAdhocConfigSetCfmSend(dst__, status__) \ - CsrWifiSmeAdhocConfigSetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__) - -/******************************************************************************* - - NAME - CsrWifiSmeAmpStatusChangeIndSend - - DESCRIPTION - Indication of change to AMP activity. - - PARAMETERS - queue - Destination Task Queue - interfaceTag - Interface on which the AMP activity changed. - ampStatus - The new status of AMP activity.Range: {AMP_ACTIVE, - AMP_INACTIVE}. - -*******************************************************************************/ -#define CsrWifiSmeAmpStatusChangeIndCreate(msg__, dst__, src__, interfaceTag__, ampStatus__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeAmpStatusChangeInd), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_AMP_STATUS_CHANGE_IND, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->ampStatus = (ampStatus__); - -#define CsrWifiSmeAmpStatusChangeIndSendTo(dst__, src__, interfaceTag__, ampStatus__) \ - { \ - CsrWifiSmeAmpStatusChangeInd *msg__; \ - CsrWifiSmeAmpStatusChangeIndCreate(msg__, dst__, src__, interfaceTag__, ampStatus__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeAmpStatusChangeIndSend(dst__, interfaceTag__, ampStatus__) \ - CsrWifiSmeAmpStatusChangeIndSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, ampStatus__) - -/******************************************************************************* - - NAME - CsrWifiSmeAssociationCompleteIndSend - - DESCRIPTION - The SME will send this primitive to all the tasks that have registered to - receive it whenever it completes an attempt to associate with an AP. If - the association was successful, status will be set to - CSR_WIFI_SME_STATUS_SUCCESS, otherwise status and deauthReason shall be - set to appropriate error codes. - - PARAMETERS - queue - Destination Task Queue - interfaceTag - Interface Identifier; unique identifier of an interface - status - Reports the result of the association procedure - connectionInfo - This parameter is relevant only if result is - CSR_WIFI_SME_STATUS_SUCCESS: - it points to the connection information for the new network - deauthReason - This parameter is relevant only if result is not - CSR_WIFI_SME_STATUS_SUCCESS: - if the AP deauthorised the station, it gives the reason of - the deauthorization - -*******************************************************************************/ -#define CsrWifiSmeAssociationCompleteIndCreate(msg__, dst__, src__, interfaceTag__, status__, connectionInfo__, deauthReason__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeAssociationCompleteInd), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_ASSOCIATION_COMPLETE_IND, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->status = (status__); \ - msg__->connectionInfo = (connectionInfo__); \ - msg__->deauthReason = (deauthReason__); - -#define CsrWifiSmeAssociationCompleteIndSendTo(dst__, src__, interfaceTag__, status__, connectionInfo__, deauthReason__) \ - { \ - CsrWifiSmeAssociationCompleteInd *msg__; \ - CsrWifiSmeAssociationCompleteIndCreate(msg__, dst__, src__, interfaceTag__, status__, connectionInfo__, deauthReason__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeAssociationCompleteIndSend(dst__, interfaceTag__, status__, connectionInfo__, deauthReason__) \ - CsrWifiSmeAssociationCompleteIndSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__, connectionInfo__, deauthReason__) - -/******************************************************************************* - - NAME - CsrWifiSmeAssociationStartIndSend - - DESCRIPTION - The SME will send this primitive to all the tasks that have registered to - receive it whenever it begins an attempt to associate with an AP. - - PARAMETERS - queue - Destination Task Queue - interfaceTag - Interface Identifier; unique identifier of an interface - address - BSSID of the associating network - ssid - Service Set identifier of the associating network - -*******************************************************************************/ -#define CsrWifiSmeAssociationStartIndCreate(msg__, dst__, src__, interfaceTag__, address__, ssid__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeAssociationStartInd), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_ASSOCIATION_START_IND, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->address = (address__); \ - msg__->ssid = (ssid__); - -#define CsrWifiSmeAssociationStartIndSendTo(dst__, src__, interfaceTag__, address__, ssid__) \ - { \ - CsrWifiSmeAssociationStartInd *msg__; \ - CsrWifiSmeAssociationStartIndCreate(msg__, dst__, src__, interfaceTag__, address__, ssid__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeAssociationStartIndSend(dst__, interfaceTag__, address__, ssid__) \ - CsrWifiSmeAssociationStartIndSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, address__, ssid__) - -/******************************************************************************* - - NAME - CsrWifiSmeBlacklistReqSend - - DESCRIPTION - The wireless manager application should call this primitive to notify the - driver of any networks that should not be connected to. The interface - allows the wireless manager application to query, add, remove, and flush - the BSSIDs that the driver may not connect or roam to. - When this primitive adds to the black list the BSSID to which the SME is - currently connected, the SME will try to roam, if applicable, to another - BSSID in the same ESS; if the roaming procedure fails, the SME will - disconnect. - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - interfaceTag - Interface Identifier; unique identifier of an interface - action - The value of the CsrWifiSmeListAction parameter instructs - the driver to modify or provide the list of blacklisted - networks. - setAddressCount - Number of BSSIDs sent with this primitive - setAddresses - Pointer to the list of BBSIDs sent with the primitive, set - to NULL if none is sent. - -*******************************************************************************/ -#define CsrWifiSmeBlacklistReqCreate(msg__, dst__, src__, interfaceTag__, action__, setAddressCount__, setAddresses__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeBlacklistReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_BLACKLIST_REQ, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->action = (action__); \ - msg__->setAddressCount = (setAddressCount__); \ - msg__->setAddresses = (setAddresses__); - -#define CsrWifiSmeBlacklistReqSendTo(dst__, src__, interfaceTag__, action__, setAddressCount__, setAddresses__) \ - { \ - CsrWifiSmeBlacklistReq *msg__; \ - CsrWifiSmeBlacklistReqCreate(msg__, dst__, src__, interfaceTag__, action__, setAddressCount__, setAddresses__); \ - CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeBlacklistReqSend(src__, interfaceTag__, action__, setAddressCount__, setAddresses__) \ - CsrWifiSmeBlacklistReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, interfaceTag__, action__, setAddressCount__, setAddresses__) - -/******************************************************************************* - - NAME - CsrWifiSmeBlacklistCfmSend - - DESCRIPTION - The SME will call this primitive when the action on the blacklist has - completed. For a GET action, this primitive also reports the list of - BBSIDs in the blacklist. - - PARAMETERS - queue - Destination Task Queue - interfaceTag - Interface Identifier; unique identifier of an interface - status - Reports the result of the request - action - Action in the request - getAddressCount - This parameter is only relevant if action is - CSR_WIFI_SME_LIST_ACTION_GET: - number of BSSIDs sent with this primitive - getAddresses - Pointer to the list of BBSIDs sent with the primitive, set - to NULL if none is sent. - -*******************************************************************************/ -#define CsrWifiSmeBlacklistCfmCreate(msg__, dst__, src__, interfaceTag__, status__, action__, getAddressCount__, getAddresses__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeBlacklistCfm), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_BLACKLIST_CFM, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->status = (status__); \ - msg__->action = (action__); \ - msg__->getAddressCount = (getAddressCount__); \ - msg__->getAddresses = (getAddresses__); - -#define CsrWifiSmeBlacklistCfmSendTo(dst__, src__, interfaceTag__, status__, action__, getAddressCount__, getAddresses__) \ - { \ - CsrWifiSmeBlacklistCfm *msg__; \ - CsrWifiSmeBlacklistCfmCreate(msg__, dst__, src__, interfaceTag__, status__, action__, getAddressCount__, getAddresses__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeBlacklistCfmSend(dst__, interfaceTag__, status__, action__, getAddressCount__, getAddresses__) \ - CsrWifiSmeBlacklistCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__, action__, getAddressCount__, getAddresses__) - -/******************************************************************************* - - NAME - CsrWifiSmeCalibrationDataGetReqSend - - DESCRIPTION - This primitive retrieves the Wi-Fi radio calibration data. - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - -*******************************************************************************/ -#define CsrWifiSmeCalibrationDataGetReqCreate(msg__, dst__, src__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeCalibrationDataGetReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_CALIBRATION_DATA_GET_REQ, dst__, src__); - -#define CsrWifiSmeCalibrationDataGetReqSendTo(dst__, src__) \ - { \ - CsrWifiSmeCalibrationDataGetReq *msg__; \ - CsrWifiSmeCalibrationDataGetReqCreate(msg__, dst__, src__); \ - CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeCalibrationDataGetReqSend(src__) \ - CsrWifiSmeCalibrationDataGetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__) - -/******************************************************************************* - - NAME - CsrWifiSmeCalibrationDataGetCfmSend - - DESCRIPTION - This primitive reports the result of the request. - - PARAMETERS - queue - Destination Task Queue - status - Reports the result of the request - calibrationDataLength - Number of bytes in the buffer pointed by - calibrationData - calibrationData - Pointer to a buffer of length calibrationDataLength - containing the calibration data - -*******************************************************************************/ -#define CsrWifiSmeCalibrationDataGetCfmCreate(msg__, dst__, src__, status__, calibrationDataLength__, calibrationData__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeCalibrationDataGetCfm), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_CALIBRATION_DATA_GET_CFM, dst__, src__); \ - msg__->status = (status__); \ - msg__->calibrationDataLength = (calibrationDataLength__); \ - msg__->calibrationData = (calibrationData__); - -#define CsrWifiSmeCalibrationDataGetCfmSendTo(dst__, src__, status__, calibrationDataLength__, calibrationData__) \ - { \ - CsrWifiSmeCalibrationDataGetCfm *msg__; \ - CsrWifiSmeCalibrationDataGetCfmCreate(msg__, dst__, src__, status__, calibrationDataLength__, calibrationData__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeCalibrationDataGetCfmSend(dst__, status__, calibrationDataLength__, calibrationData__) \ - CsrWifiSmeCalibrationDataGetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__, calibrationDataLength__, calibrationData__) - -/******************************************************************************* - - NAME - CsrWifiSmeCalibrationDataSetReqSend - - DESCRIPTION - This primitive sets the Wi-Fi radio calibration data. - The usage of the primitive with proper calibration data will avoid - time-consuming configuration after power-up. - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - calibrationDataLength - Number of bytes in the buffer pointed by - calibrationData - calibrationData - Pointer to a buffer of length calibrationDataLength - containing the calibration data - -*******************************************************************************/ -#define CsrWifiSmeCalibrationDataSetReqCreate(msg__, dst__, src__, calibrationDataLength__, calibrationData__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeCalibrationDataSetReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_CALIBRATION_DATA_SET_REQ, dst__, src__); \ - msg__->calibrationDataLength = (calibrationDataLength__); \ - msg__->calibrationData = (calibrationData__); - -#define CsrWifiSmeCalibrationDataSetReqSendTo(dst__, src__, calibrationDataLength__, calibrationData__) \ - { \ - CsrWifiSmeCalibrationDataSetReq *msg__; \ - CsrWifiSmeCalibrationDataSetReqCreate(msg__, dst__, src__, calibrationDataLength__, calibrationData__); \ - CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeCalibrationDataSetReqSend(src__, calibrationDataLength__, calibrationData__) \ - CsrWifiSmeCalibrationDataSetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, calibrationDataLength__, calibrationData__) - -/******************************************************************************* - - NAME - CsrWifiSmeCalibrationDataSetCfmSend - - DESCRIPTION - This primitive reports the result of the request. - - PARAMETERS - queue - Destination Task Queue - status - Reports the result of the request - -*******************************************************************************/ -#define CsrWifiSmeCalibrationDataSetCfmCreate(msg__, dst__, src__, status__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeCalibrationDataSetCfm), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_CALIBRATION_DATA_SET_CFM, dst__, src__); \ - msg__->status = (status__); - -#define CsrWifiSmeCalibrationDataSetCfmSendTo(dst__, src__, status__) \ - { \ - CsrWifiSmeCalibrationDataSetCfm *msg__; \ - CsrWifiSmeCalibrationDataSetCfmCreate(msg__, dst__, src__, status__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeCalibrationDataSetCfmSend(dst__, status__) \ - CsrWifiSmeCalibrationDataSetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__) - -/******************************************************************************* - - NAME - CsrWifiSmeCcxConfigGetReqSend - - DESCRIPTION - This primitive gets the value of the CcxConfig parameter. - CURRENTLY NOT SUPPORTED. - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - interfaceTag - Interface Identifier; unique identifier of an interface - -*******************************************************************************/ -#define CsrWifiSmeCcxConfigGetReqCreate(msg__, dst__, src__, interfaceTag__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeCcxConfigGetReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_CCX_CONFIG_GET_REQ, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); - -#define CsrWifiSmeCcxConfigGetReqSendTo(dst__, src__, interfaceTag__) \ - { \ - CsrWifiSmeCcxConfigGetReq *msg__; \ - CsrWifiSmeCcxConfigGetReqCreate(msg__, dst__, src__, interfaceTag__); \ - CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeCcxConfigGetReqSend(src__, interfaceTag__) \ - CsrWifiSmeCcxConfigGetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, interfaceTag__) - -/******************************************************************************* - - NAME - CsrWifiSmeCcxConfigGetCfmSend - - DESCRIPTION - This primitive reports the result of the request. - - PARAMETERS - queue - Destination Task Queue - interfaceTag - Interface Identifier; unique identifier of an interface - status - Reports the result of the request - ccxConfig - Currently not supported - -*******************************************************************************/ -#define CsrWifiSmeCcxConfigGetCfmCreate(msg__, dst__, src__, interfaceTag__, status__, ccxConfig__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeCcxConfigGetCfm), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_CCX_CONFIG_GET_CFM, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->status = (status__); \ - msg__->ccxConfig = (ccxConfig__); - -#define CsrWifiSmeCcxConfigGetCfmSendTo(dst__, src__, interfaceTag__, status__, ccxConfig__) \ - { \ - CsrWifiSmeCcxConfigGetCfm *msg__; \ - CsrWifiSmeCcxConfigGetCfmCreate(msg__, dst__, src__, interfaceTag__, status__, ccxConfig__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeCcxConfigGetCfmSend(dst__, interfaceTag__, status__, ccxConfig__) \ - CsrWifiSmeCcxConfigGetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__, ccxConfig__) - -/******************************************************************************* - - NAME - CsrWifiSmeCcxConfigSetReqSend - - DESCRIPTION - This primitive sets the value of the CcxConfig parameter. - CURRENTLY NOT SUPPORTED. - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - interfaceTag - Interface Identifier; unique identifier of an interface - ccxConfig - Currently not supported - -*******************************************************************************/ -#define CsrWifiSmeCcxConfigSetReqCreate(msg__, dst__, src__, interfaceTag__, ccxConfig__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeCcxConfigSetReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_CCX_CONFIG_SET_REQ, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->ccxConfig = (ccxConfig__); - -#define CsrWifiSmeCcxConfigSetReqSendTo(dst__, src__, interfaceTag__, ccxConfig__) \ - { \ - CsrWifiSmeCcxConfigSetReq *msg__; \ - CsrWifiSmeCcxConfigSetReqCreate(msg__, dst__, src__, interfaceTag__, ccxConfig__); \ - CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeCcxConfigSetReqSend(src__, interfaceTag__, ccxConfig__) \ - CsrWifiSmeCcxConfigSetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, interfaceTag__, ccxConfig__) - -/******************************************************************************* - - NAME - CsrWifiSmeCcxConfigSetCfmSend - - DESCRIPTION - This primitive reports the result of the request. - - PARAMETERS - queue - Destination Task Queue - interfaceTag - Interface Identifier; unique identifier of an interface - status - Reports the result of the request - -*******************************************************************************/ -#define CsrWifiSmeCcxConfigSetCfmCreate(msg__, dst__, src__, interfaceTag__, status__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeCcxConfigSetCfm), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_CCX_CONFIG_SET_CFM, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->status = (status__); - -#define CsrWifiSmeCcxConfigSetCfmSendTo(dst__, src__, interfaceTag__, status__) \ - { \ - CsrWifiSmeCcxConfigSetCfm *msg__; \ - CsrWifiSmeCcxConfigSetCfmCreate(msg__, dst__, src__, interfaceTag__, status__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeCcxConfigSetCfmSend(dst__, interfaceTag__, status__) \ - CsrWifiSmeCcxConfigSetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__) - -/******************************************************************************* - - NAME - CsrWifiSmeCloakedSsidsGetReqSend - - DESCRIPTION - This primitive gets the value of the CloakedSsids parameter. - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - -*******************************************************************************/ -#define CsrWifiSmeCloakedSsidsGetReqCreate(msg__, dst__, src__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeCloakedSsidsGetReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_CLOAKED_SSIDS_GET_REQ, dst__, src__); - -#define CsrWifiSmeCloakedSsidsGetReqSendTo(dst__, src__) \ - { \ - CsrWifiSmeCloakedSsidsGetReq *msg__; \ - CsrWifiSmeCloakedSsidsGetReqCreate(msg__, dst__, src__); \ - CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeCloakedSsidsGetReqSend(src__) \ - CsrWifiSmeCloakedSsidsGetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__) - -/******************************************************************************* - - NAME - CsrWifiSmeCloakedSsidsGetCfmSend - - DESCRIPTION - This primitive reports the result of the request. - - PARAMETERS - queue - Destination Task Queue - status - Reports the result of the request - cloakedSsids - Reports list of cloaked SSIDs that are explicitly scanned for - by the driver - -*******************************************************************************/ -#define CsrWifiSmeCloakedSsidsGetCfmCreate(msg__, dst__, src__, status__, cloakedSsids__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeCloakedSsidsGetCfm), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_CLOAKED_SSIDS_GET_CFM, dst__, src__); \ - msg__->status = (status__); \ - msg__->cloakedSsids = (cloakedSsids__); - -#define CsrWifiSmeCloakedSsidsGetCfmSendTo(dst__, src__, status__, cloakedSsids__) \ - { \ - CsrWifiSmeCloakedSsidsGetCfm *msg__; \ - CsrWifiSmeCloakedSsidsGetCfmCreate(msg__, dst__, src__, status__, cloakedSsids__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeCloakedSsidsGetCfmSend(dst__, status__, cloakedSsids__) \ - CsrWifiSmeCloakedSsidsGetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__, cloakedSsids__) - -/******************************************************************************* - - NAME - CsrWifiSmeCloakedSsidsSetReqSend - - DESCRIPTION - This primitive sets the list of cloaked SSIDs for which the WMA possesses - profiles. - When the driver detects a cloaked AP, the SME will explicitly scan for it - using the list of cloaked SSIDs provided it, and, if the scan succeeds, - it will report the AP to the WMA either via CSR_WIFI_SME_SCAN_RESULT_IND - (if registered) or via CSR_WIFI_SCAN_RESULT_GET_CFM. - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - cloakedSsids - Sets the list of cloaked SSIDs - -*******************************************************************************/ -#define CsrWifiSmeCloakedSsidsSetReqCreate(msg__, dst__, src__, cloakedSsids__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeCloakedSsidsSetReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_CLOAKED_SSIDS_SET_REQ, dst__, src__); \ - msg__->cloakedSsids = (cloakedSsids__); - -#define CsrWifiSmeCloakedSsidsSetReqSendTo(dst__, src__, cloakedSsids__) \ - { \ - CsrWifiSmeCloakedSsidsSetReq *msg__; \ - CsrWifiSmeCloakedSsidsSetReqCreate(msg__, dst__, src__, cloakedSsids__); \ - CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeCloakedSsidsSetReqSend(src__, cloakedSsids__) \ - CsrWifiSmeCloakedSsidsSetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, cloakedSsids__) - -/******************************************************************************* - - NAME - CsrWifiSmeCloakedSsidsSetCfmSend - - DESCRIPTION - This primitive reports the result of the request. - - PARAMETERS - queue - Destination Task Queue - status - Reports the result of the request - -*******************************************************************************/ -#define CsrWifiSmeCloakedSsidsSetCfmCreate(msg__, dst__, src__, status__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeCloakedSsidsSetCfm), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_CLOAKED_SSIDS_SET_CFM, dst__, src__); \ - msg__->status = (status__); - -#define CsrWifiSmeCloakedSsidsSetCfmSendTo(dst__, src__, status__) \ - { \ - CsrWifiSmeCloakedSsidsSetCfm *msg__; \ - CsrWifiSmeCloakedSsidsSetCfmCreate(msg__, dst__, src__, status__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeCloakedSsidsSetCfmSend(dst__, status__) \ - CsrWifiSmeCloakedSsidsSetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__) - -/******************************************************************************* - - NAME - CsrWifiSmeCoexConfigGetReqSend - - DESCRIPTION - This primitive gets the value of the CoexConfig parameter. - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - -*******************************************************************************/ -#define CsrWifiSmeCoexConfigGetReqCreate(msg__, dst__, src__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeCoexConfigGetReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_COEX_CONFIG_GET_REQ, dst__, src__); - -#define CsrWifiSmeCoexConfigGetReqSendTo(dst__, src__) \ - { \ - CsrWifiSmeCoexConfigGetReq *msg__; \ - CsrWifiSmeCoexConfigGetReqCreate(msg__, dst__, src__); \ - CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeCoexConfigGetReqSend(src__) \ - CsrWifiSmeCoexConfigGetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__) - -/******************************************************************************* - - NAME - CsrWifiSmeCoexConfigGetCfmSend - - DESCRIPTION - This primitive reports the result of the request. - - PARAMETERS - queue - Destination Task Queue - status - Reports the result of the request - coexConfig - Reports the parameters used to configure the coexistence - behaviour - -*******************************************************************************/ -#define CsrWifiSmeCoexConfigGetCfmCreate(msg__, dst__, src__, status__, coexConfig__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeCoexConfigGetCfm), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_COEX_CONFIG_GET_CFM, dst__, src__); \ - msg__->status = (status__); \ - msg__->coexConfig = (coexConfig__); - -#define CsrWifiSmeCoexConfigGetCfmSendTo(dst__, src__, status__, coexConfig__) \ - { \ - CsrWifiSmeCoexConfigGetCfm *msg__; \ - CsrWifiSmeCoexConfigGetCfmCreate(msg__, dst__, src__, status__, coexConfig__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeCoexConfigGetCfmSend(dst__, status__, coexConfig__) \ - CsrWifiSmeCoexConfigGetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__, coexConfig__) - -/******************************************************************************* - - NAME - CsrWifiSmeCoexConfigSetReqSend - - DESCRIPTION - This primitive sets the value of the CoexConfig parameter. - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - coexConfig - Configures the coexistence behaviour - -*******************************************************************************/ -#define CsrWifiSmeCoexConfigSetReqCreate(msg__, dst__, src__, coexConfig__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeCoexConfigSetReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_COEX_CONFIG_SET_REQ, dst__, src__); \ - msg__->coexConfig = (coexConfig__); - -#define CsrWifiSmeCoexConfigSetReqSendTo(dst__, src__, coexConfig__) \ - { \ - CsrWifiSmeCoexConfigSetReq *msg__; \ - CsrWifiSmeCoexConfigSetReqCreate(msg__, dst__, src__, coexConfig__); \ - CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeCoexConfigSetReqSend(src__, coexConfig__) \ - CsrWifiSmeCoexConfigSetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, coexConfig__) - -/******************************************************************************* - - NAME - CsrWifiSmeCoexConfigSetCfmSend - - DESCRIPTION - This primitive reports the result of the request. - - PARAMETERS - queue - Destination Task Queue - status - Reports the result of the request - -*******************************************************************************/ -#define CsrWifiSmeCoexConfigSetCfmCreate(msg__, dst__, src__, status__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeCoexConfigSetCfm), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_COEX_CONFIG_SET_CFM, dst__, src__); \ - msg__->status = (status__); - -#define CsrWifiSmeCoexConfigSetCfmSendTo(dst__, src__, status__) \ - { \ - CsrWifiSmeCoexConfigSetCfm *msg__; \ - CsrWifiSmeCoexConfigSetCfmCreate(msg__, dst__, src__, status__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeCoexConfigSetCfmSend(dst__, status__) \ - CsrWifiSmeCoexConfigSetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__) - -/******************************************************************************* - - NAME - CsrWifiSmeCoexInfoGetReqSend - - DESCRIPTION - This primitive gets the value of the CoexInfo parameter. - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - -*******************************************************************************/ -#define CsrWifiSmeCoexInfoGetReqCreate(msg__, dst__, src__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeCoexInfoGetReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_COEX_INFO_GET_REQ, dst__, src__); - -#define CsrWifiSmeCoexInfoGetReqSendTo(dst__, src__) \ - { \ - CsrWifiSmeCoexInfoGetReq *msg__; \ - CsrWifiSmeCoexInfoGetReqCreate(msg__, dst__, src__); \ - CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeCoexInfoGetReqSend(src__) \ - CsrWifiSmeCoexInfoGetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__) - -/******************************************************************************* - - NAME - CsrWifiSmeCoexInfoGetCfmSend - - DESCRIPTION - This primitive reports the result of the request. - - PARAMETERS - queue - Destination Task Queue - status - Reports the result of the request - coexInfo - Reports information and state related to coexistence. - -*******************************************************************************/ -#define CsrWifiSmeCoexInfoGetCfmCreate(msg__, dst__, src__, status__, coexInfo__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeCoexInfoGetCfm), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_COEX_INFO_GET_CFM, dst__, src__); \ - msg__->status = (status__); \ - msg__->coexInfo = (coexInfo__); - -#define CsrWifiSmeCoexInfoGetCfmSendTo(dst__, src__, status__, coexInfo__) \ - { \ - CsrWifiSmeCoexInfoGetCfm *msg__; \ - CsrWifiSmeCoexInfoGetCfmCreate(msg__, dst__, src__, status__, coexInfo__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeCoexInfoGetCfmSend(dst__, status__, coexInfo__) \ - CsrWifiSmeCoexInfoGetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__, coexInfo__) - -/******************************************************************************* - - NAME - CsrWifiSmeConnectReqSend - - DESCRIPTION - The wireless manager application calls this primitive to start the - process of joining an 802.11 wireless network or to start an ad hoc - network. - The structure pointed by connectionConfig contains parameters describing - the network to join or, in case of an ad hoc network, to host or join. - The SME will select a network, perform the IEEE 802.11 Join, Authenticate - and Associate exchanges. - The SME selects the networks from the current scan list that match both - the SSID and BSSID, however either or both of these may be the wildcard - value. Using this rule, the following operations are possible: - * To connect to a network by name, specify the SSID and set the BSSID to - 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF. If there are two or more networks visible, - the SME will select the one with the strongest signal. - * To connect to a specific network, specify the BSSID. The SSID is - optional, but if given it must match the SSID of the network. An empty - SSID may be specified by setting the SSID length to zero. Please note - that if the BSSID is specified (i.e. not equal to 0xFF 0xFF 0xFF 0xFF - 0xFF 0xFF), the SME will not attempt to roam if signal conditions become - poor, even if there is an alternative AP with an SSID that matches the - current network SSID. - * To connect to any network matching the other parameters (i.e. security, - etc), set the SSID length to zero and set the BSSID to 0xFF 0xFF 0xFF - 0xFF 0xFF 0xFF. In this case, the SME will order all available networks - by their signal strengths and will iterate through this list until it - successfully connects. - NOTE: Specifying the BSSID will restrict the selection to one specific - network. If SSID and BSSID are given, they must both match the network - for it to be selected. To select a network based on the SSID only, the - wireless manager application must set the BSSID to 0xFF 0xFF 0xFF 0xFF - 0xFF 0xFF. - The SME will try to connect to each network that matches the provided - parameters, one by one, until it succeeds or has tried unsuccessfully - with all the matching networks. - If there is no network that matches the parameters and the request allows - to host an ad hoc network, the SME will advertise a new ad hoc network - instead. - If the SME cannot connect, it will notify the failure in the confirm. - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - interfaceTag - Interface Identifier; unique identifier of an interface - connectionConfig - Describes the candidate network to join or to host. - -*******************************************************************************/ -#define CsrWifiSmeConnectReqCreate(msg__, dst__, src__, interfaceTag__, connectionConfig__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeConnectReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_CONNECT_REQ, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->connectionConfig = (connectionConfig__); - -#define CsrWifiSmeConnectReqSendTo(dst__, src__, interfaceTag__, connectionConfig__) \ - { \ - CsrWifiSmeConnectReq *msg__; \ - CsrWifiSmeConnectReqCreate(msg__, dst__, src__, interfaceTag__, connectionConfig__); \ - CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeConnectReqSend(src__, interfaceTag__, connectionConfig__) \ - CsrWifiSmeConnectReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, interfaceTag__, connectionConfig__) - -/******************************************************************************* - - NAME - CsrWifiSmeConnectCfmSend - - DESCRIPTION - The SME calls this primitive when the connection exchange is complete or - all connection attempts fail. - - PARAMETERS - queue - Destination Task Queue - interfaceTag - Interface Identifier; unique identifier of an interface - status - Reports the result of the request. - CSR_WIFI_SME_STATUS_NOT_FOUND: all attempts by the SME to - locate the requested AP failed - -*******************************************************************************/ -#define CsrWifiSmeConnectCfmCreate(msg__, dst__, src__, interfaceTag__, status__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeConnectCfm), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_CONNECT_CFM, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->status = (status__); - -#define CsrWifiSmeConnectCfmSendTo(dst__, src__, interfaceTag__, status__) \ - { \ - CsrWifiSmeConnectCfm *msg__; \ - CsrWifiSmeConnectCfmCreate(msg__, dst__, src__, interfaceTag__, status__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeConnectCfmSend(dst__, interfaceTag__, status__) \ - CsrWifiSmeConnectCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__) - -/******************************************************************************* - - NAME - CsrWifiSmeConnectionConfigGetReqSend - - DESCRIPTION - This primitive gets the value of the ConnectionConfig parameter. - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - interfaceTag - Interface Identifier; unique identifier of an interface - -*******************************************************************************/ -#define CsrWifiSmeConnectionConfigGetReqCreate(msg__, dst__, src__, interfaceTag__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeConnectionConfigGetReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_CONNECTION_CONFIG_GET_REQ, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); - -#define CsrWifiSmeConnectionConfigGetReqSendTo(dst__, src__, interfaceTag__) \ - { \ - CsrWifiSmeConnectionConfigGetReq *msg__; \ - CsrWifiSmeConnectionConfigGetReqCreate(msg__, dst__, src__, interfaceTag__); \ - CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeConnectionConfigGetReqSend(src__, interfaceTag__) \ - CsrWifiSmeConnectionConfigGetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, interfaceTag__) - -/******************************************************************************* - - NAME - CsrWifiSmeConnectionConfigGetCfmSend - - DESCRIPTION - This primitive reports the result of the request. - - PARAMETERS - queue - Destination Task Queue - interfaceTag - Interface Identifier; unique identifier of an interface - status - Reports the result of the request - connectionConfig - Parameters used by the SME for selecting a network - -*******************************************************************************/ -#define CsrWifiSmeConnectionConfigGetCfmCreate(msg__, dst__, src__, interfaceTag__, status__, connectionConfig__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeConnectionConfigGetCfm), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_CONNECTION_CONFIG_GET_CFM, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->status = (status__); \ - msg__->connectionConfig = (connectionConfig__); - -#define CsrWifiSmeConnectionConfigGetCfmSendTo(dst__, src__, interfaceTag__, status__, connectionConfig__) \ - { \ - CsrWifiSmeConnectionConfigGetCfm *msg__; \ - CsrWifiSmeConnectionConfigGetCfmCreate(msg__, dst__, src__, interfaceTag__, status__, connectionConfig__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeConnectionConfigGetCfmSend(dst__, interfaceTag__, status__, connectionConfig__) \ - CsrWifiSmeConnectionConfigGetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__, connectionConfig__) - -/******************************************************************************* - - NAME - CsrWifiSmeConnectionInfoGetReqSend - - DESCRIPTION - This primitive gets the value of the ConnectionInfo parameter. - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - interfaceTag - Interface Identifier; unique identifier of an interface - -*******************************************************************************/ -#define CsrWifiSmeConnectionInfoGetReqCreate(msg__, dst__, src__, interfaceTag__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeConnectionInfoGetReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_CONNECTION_INFO_GET_REQ, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); - -#define CsrWifiSmeConnectionInfoGetReqSendTo(dst__, src__, interfaceTag__) \ - { \ - CsrWifiSmeConnectionInfoGetReq *msg__; \ - CsrWifiSmeConnectionInfoGetReqCreate(msg__, dst__, src__, interfaceTag__); \ - CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeConnectionInfoGetReqSend(src__, interfaceTag__) \ - CsrWifiSmeConnectionInfoGetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, interfaceTag__) - -/******************************************************************************* - - NAME - CsrWifiSmeConnectionInfoGetCfmSend - - DESCRIPTION - This primitive reports the result of the request. - - PARAMETERS - queue - Destination Task Queue - interfaceTag - Interface Identifier; unique identifier of an interface - status - Reports the result of the request - connectionInfo - Information about the current connection - -*******************************************************************************/ -#define CsrWifiSmeConnectionInfoGetCfmCreate(msg__, dst__, src__, interfaceTag__, status__, connectionInfo__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeConnectionInfoGetCfm), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_CONNECTION_INFO_GET_CFM, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->status = (status__); \ - msg__->connectionInfo = (connectionInfo__); - -#define CsrWifiSmeConnectionInfoGetCfmSendTo(dst__, src__, interfaceTag__, status__, connectionInfo__) \ - { \ - CsrWifiSmeConnectionInfoGetCfm *msg__; \ - CsrWifiSmeConnectionInfoGetCfmCreate(msg__, dst__, src__, interfaceTag__, status__, connectionInfo__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeConnectionInfoGetCfmSend(dst__, interfaceTag__, status__, connectionInfo__) \ - CsrWifiSmeConnectionInfoGetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__, connectionInfo__) - -/******************************************************************************* - - NAME - CsrWifiSmeConnectionQualityIndSend - - DESCRIPTION - The SME sends this primitive to all the tasks that have registered to - receive it whenever the value of the current connection quality - parameters change by more than a certain configurable amount. - The wireless manager application may configure the trigger thresholds for - this indication using the field in smeConfig parameter of - CSR_WIFI_SME_SME_CONFIG_SET_REQ. - Connection quality messages can be suppressed by setting both thresholds - to zero. - - PARAMETERS - queue - Destination Task Queue - interfaceTag - Interface Identifier; unique identifier of an interface - linkQuality - Indicates the quality of the link - -*******************************************************************************/ -#define CsrWifiSmeConnectionQualityIndCreate(msg__, dst__, src__, interfaceTag__, linkQuality__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeConnectionQualityInd), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_CONNECTION_QUALITY_IND, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->linkQuality = (linkQuality__); - -#define CsrWifiSmeConnectionQualityIndSendTo(dst__, src__, interfaceTag__, linkQuality__) \ - { \ - CsrWifiSmeConnectionQualityInd *msg__; \ - CsrWifiSmeConnectionQualityIndCreate(msg__, dst__, src__, interfaceTag__, linkQuality__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeConnectionQualityIndSend(dst__, interfaceTag__, linkQuality__) \ - CsrWifiSmeConnectionQualityIndSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, linkQuality__) - -/******************************************************************************* - - NAME - CsrWifiSmeConnectionStatsGetReqSend - - DESCRIPTION - This primitive gets the value of the ConnectionStats parameter. - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - interfaceTag - Interface Identifier; unique identifier of an interface - -*******************************************************************************/ -#define CsrWifiSmeConnectionStatsGetReqCreate(msg__, dst__, src__, interfaceTag__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeConnectionStatsGetReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_CONNECTION_STATS_GET_REQ, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); - -#define CsrWifiSmeConnectionStatsGetReqSendTo(dst__, src__, interfaceTag__) \ - { \ - CsrWifiSmeConnectionStatsGetReq *msg__; \ - CsrWifiSmeConnectionStatsGetReqCreate(msg__, dst__, src__, interfaceTag__); \ - CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeConnectionStatsGetReqSend(src__, interfaceTag__) \ - CsrWifiSmeConnectionStatsGetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, interfaceTag__) - -/******************************************************************************* - - NAME - CsrWifiSmeConnectionStatsGetCfmSend - - DESCRIPTION - This primitive reports the result of the request. - - PARAMETERS - queue - Destination Task Queue - interfaceTag - Interface Identifier; unique identifier of an interface - status - Reports the result of the request - connectionStats - Statistics for current connection. - -*******************************************************************************/ -#define CsrWifiSmeConnectionStatsGetCfmCreate(msg__, dst__, src__, interfaceTag__, status__, connectionStats__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeConnectionStatsGetCfm), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_CONNECTION_STATS_GET_CFM, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->status = (status__); \ - msg__->connectionStats = (connectionStats__); - -#define CsrWifiSmeConnectionStatsGetCfmSendTo(dst__, src__, interfaceTag__, status__, connectionStats__) \ - { \ - CsrWifiSmeConnectionStatsGetCfm *msg__; \ - CsrWifiSmeConnectionStatsGetCfmCreate(msg__, dst__, src__, interfaceTag__, status__, connectionStats__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeConnectionStatsGetCfmSend(dst__, interfaceTag__, status__, connectionStats__) \ - CsrWifiSmeConnectionStatsGetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__, connectionStats__) - -/******************************************************************************* - - NAME - CsrWifiSmeCoreDumpIndSend - - DESCRIPTION - The SME will send this primitive to all the tasks that have registered to - receive Wi-Fi Chip core dump data. - The core dump data may be fragmented and sent using more than one - indication. - To indicate that all the data has been sent, the last indication contains - a 'length' of 0 and 'data' of NULL. - - PARAMETERS - queue - Destination Task Queue - dataLength - Number of bytes in the buffer pointed to by 'data' - data - Pointer to the buffer containing 'dataLength' bytes of core - dump data - -*******************************************************************************/ -#define CsrWifiSmeCoreDumpIndCreate(msg__, dst__, src__, dataLength__, data__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeCoreDumpInd), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_CORE_DUMP_IND, dst__, src__); \ - msg__->dataLength = (dataLength__); \ - msg__->data = (data__); - -#define CsrWifiSmeCoreDumpIndSendTo(dst__, src__, dataLength__, data__) \ - { \ - CsrWifiSmeCoreDumpInd *msg__; \ - CsrWifiSmeCoreDumpIndCreate(msg__, dst__, src__, dataLength__, data__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeCoreDumpIndSend(dst__, dataLength__, data__) \ - CsrWifiSmeCoreDumpIndSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, dataLength__, data__) - -/******************************************************************************* - - NAME - CsrWifiSmeDeactivateReqSend - - DESCRIPTION - The WMA sends this primitive to deactivate the SME. - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - -*******************************************************************************/ -#define CsrWifiSmeDeactivateReqCreate(msg__, dst__, src__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeDeactivateReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_DEACTIVATE_REQ, dst__, src__); - -#define CsrWifiSmeDeactivateReqSendTo(dst__, src__) \ - { \ - CsrWifiSmeDeactivateReq *msg__; \ - CsrWifiSmeDeactivateReqCreate(msg__, dst__, src__); \ - CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeDeactivateReqSend(src__) \ - CsrWifiSmeDeactivateReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__) - -/******************************************************************************* - - NAME - CsrWifiSmeDeactivateCfmSend - - DESCRIPTION - The SME sends this primitive when the deactivation is complete. - The WMA cannot send any more primitives until it actives the SME again - sending another CSR_WIFI_SME_ACTIVATE_REQ. - - PARAMETERS - queue - Destination Task Queue - status - Reports the result of the request - -*******************************************************************************/ -#define CsrWifiSmeDeactivateCfmCreate(msg__, dst__, src__, status__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeDeactivateCfm), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_DEACTIVATE_CFM, dst__, src__); \ - msg__->status = (status__); - -#define CsrWifiSmeDeactivateCfmSendTo(dst__, src__, status__) \ - { \ - CsrWifiSmeDeactivateCfm *msg__; \ - CsrWifiSmeDeactivateCfmCreate(msg__, dst__, src__, status__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeDeactivateCfmSend(dst__, status__) \ - CsrWifiSmeDeactivateCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__) - -/******************************************************************************* - - NAME - CsrWifiSmeDisconnectReqSend - - DESCRIPTION - The wireless manager application may disconnect from the current network - by calling this primitive - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - interfaceTag - Interface Identifier; unique identifier of an interface - -*******************************************************************************/ -#define CsrWifiSmeDisconnectReqCreate(msg__, dst__, src__, interfaceTag__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeDisconnectReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_DISCONNECT_REQ, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); - -#define CsrWifiSmeDisconnectReqSendTo(dst__, src__, interfaceTag__) \ - { \ - CsrWifiSmeDisconnectReq *msg__; \ - CsrWifiSmeDisconnectReqCreate(msg__, dst__, src__, interfaceTag__); \ - CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeDisconnectReqSend(src__, interfaceTag__) \ - CsrWifiSmeDisconnectReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, interfaceTag__) - -/******************************************************************************* - - NAME - CsrWifiSmeDisconnectCfmSend - - DESCRIPTION - On reception of CSR_WIFI_SME_DISCONNECT_REQ the SME will perform a - disconnect operation, sending a CsrWifiSmeMediaStatusInd with - CSR_WIFI_SME_MEDIA_STATUS_DISCONNECTED and then call this primitive when - disconnection is complete. - - PARAMETERS - queue - Destination Task Queue - interfaceTag - Interface Identifier; unique identifier of an interface - status - Reports the result of the request - -*******************************************************************************/ -#define CsrWifiSmeDisconnectCfmCreate(msg__, dst__, src__, interfaceTag__, status__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeDisconnectCfm), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_DISCONNECT_CFM, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->status = (status__); - -#define CsrWifiSmeDisconnectCfmSendTo(dst__, src__, interfaceTag__, status__) \ - { \ - CsrWifiSmeDisconnectCfm *msg__; \ - CsrWifiSmeDisconnectCfmCreate(msg__, dst__, src__, interfaceTag__, status__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeDisconnectCfmSend(dst__, interfaceTag__, status__) \ - CsrWifiSmeDisconnectCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__) - -/******************************************************************************* - - NAME - CsrWifiSmeErrorIndSend - - DESCRIPTION - Important error message indicating a error of some importance - - PARAMETERS - queue - Destination Task Queue - errorMessage - Contains the error message. - -*******************************************************************************/ -#define CsrWifiSmeErrorIndCreate(msg__, dst__, src__, errorMessage__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeErrorInd), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_ERROR_IND, dst__, src__); \ - msg__->errorMessage = (errorMessage__); - -#define CsrWifiSmeErrorIndSendTo(dst__, src__, errorMessage__) \ - { \ - CsrWifiSmeErrorInd *msg__; \ - CsrWifiSmeErrorIndCreate(msg__, dst__, src__, errorMessage__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeErrorIndSend(dst__, errorMessage__) \ - CsrWifiSmeErrorIndSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, errorMessage__) - -/******************************************************************************* - - NAME - CsrWifiSmeEventMaskSetReqSend - - DESCRIPTION - The wireless manager application may register with the SME to receive - notification of interesting events. Indications will be sent only if the - wireless manager explicitly registers to be notified of that event. - indMask is a bit mask of values defined in CsrWifiSmeIndicationsMask. - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - indMask - Set mask with values from CsrWifiSmeIndications - -*******************************************************************************/ -#define CsrWifiSmeEventMaskSetReqCreate(msg__, dst__, src__, indMask__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeEventMaskSetReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_EVENT_MASK_SET_REQ, dst__, src__); \ - msg__->indMask = (indMask__); - -#define CsrWifiSmeEventMaskSetReqSendTo(dst__, src__, indMask__) \ - { \ - CsrWifiSmeEventMaskSetReq *msg__; \ - CsrWifiSmeEventMaskSetReqCreate(msg__, dst__, src__, indMask__); \ - CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeEventMaskSetReqSend(src__, indMask__) \ - CsrWifiSmeEventMaskSetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, indMask__) - -/******************************************************************************* - - NAME - CsrWifiSmeEventMaskSetCfmSend - - DESCRIPTION - The SME calls the primitive to report the result of the request - primitive. - - PARAMETERS - queue - Destination Task Queue - status - Reports the result of the request - -*******************************************************************************/ -#define CsrWifiSmeEventMaskSetCfmCreate(msg__, dst__, src__, status__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeEventMaskSetCfm), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_EVENT_MASK_SET_CFM, dst__, src__); \ - msg__->status = (status__); - -#define CsrWifiSmeEventMaskSetCfmSendTo(dst__, src__, status__) \ - { \ - CsrWifiSmeEventMaskSetCfm *msg__; \ - CsrWifiSmeEventMaskSetCfmCreate(msg__, dst__, src__, status__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeEventMaskSetCfmSend(dst__, status__) \ - CsrWifiSmeEventMaskSetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__) - -/******************************************************************************* - - NAME - CsrWifiSmeHostConfigGetReqSend - - DESCRIPTION - This primitive gets the value of the hostConfig parameter. - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - interfaceTag - Interface Identifier; unique identifier of an interface - -*******************************************************************************/ -#define CsrWifiSmeHostConfigGetReqCreate(msg__, dst__, src__, interfaceTag__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeHostConfigGetReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_HOST_CONFIG_GET_REQ, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); - -#define CsrWifiSmeHostConfigGetReqSendTo(dst__, src__, interfaceTag__) \ - { \ - CsrWifiSmeHostConfigGetReq *msg__; \ - CsrWifiSmeHostConfigGetReqCreate(msg__, dst__, src__, interfaceTag__); \ - CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeHostConfigGetReqSend(src__, interfaceTag__) \ - CsrWifiSmeHostConfigGetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, interfaceTag__) - -/******************************************************************************* - - NAME - CsrWifiSmeHostConfigGetCfmSend - - DESCRIPTION - This primitive reports the result of the request. - - PARAMETERS - queue - Destination Task Queue - interfaceTag - Interface Identifier; unique identifier of an interface - status - Reports the result of the request - hostConfig - Current host power state. - -*******************************************************************************/ -#define CsrWifiSmeHostConfigGetCfmCreate(msg__, dst__, src__, interfaceTag__, status__, hostConfig__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeHostConfigGetCfm), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_HOST_CONFIG_GET_CFM, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->status = (status__); \ - msg__->hostConfig = (hostConfig__); - -#define CsrWifiSmeHostConfigGetCfmSendTo(dst__, src__, interfaceTag__, status__, hostConfig__) \ - { \ - CsrWifiSmeHostConfigGetCfm *msg__; \ - CsrWifiSmeHostConfigGetCfmCreate(msg__, dst__, src__, interfaceTag__, status__, hostConfig__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeHostConfigGetCfmSend(dst__, interfaceTag__, status__, hostConfig__) \ - CsrWifiSmeHostConfigGetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__, hostConfig__) - -/******************************************************************************* - - NAME - CsrWifiSmeHostConfigSetReqSend - - DESCRIPTION - This primitive sets the value of the hostConfig parameter. - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - interfaceTag - Interface Identifier; unique identifier of an interface - hostConfig - Communicates a change of host power state (for example, on - mains power, on battery power etc) and of the periodicity of - traffic data - -*******************************************************************************/ -#define CsrWifiSmeHostConfigSetReqCreate(msg__, dst__, src__, interfaceTag__, hostConfig__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeHostConfigSetReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_HOST_CONFIG_SET_REQ, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->hostConfig = (hostConfig__); - -#define CsrWifiSmeHostConfigSetReqSendTo(dst__, src__, interfaceTag__, hostConfig__) \ - { \ - CsrWifiSmeHostConfigSetReq *msg__; \ - CsrWifiSmeHostConfigSetReqCreate(msg__, dst__, src__, interfaceTag__, hostConfig__); \ - CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeHostConfigSetReqSend(src__, interfaceTag__, hostConfig__) \ - CsrWifiSmeHostConfigSetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, interfaceTag__, hostConfig__) - -/******************************************************************************* - - NAME - CsrWifiSmeHostConfigSetCfmSend - - DESCRIPTION - This primitive reports the result of the request. - - PARAMETERS - queue - Destination Task Queue - interfaceTag - Interface Identifier; unique identifier of an interface - status - Reports the result of the request - -*******************************************************************************/ -#define CsrWifiSmeHostConfigSetCfmCreate(msg__, dst__, src__, interfaceTag__, status__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeHostConfigSetCfm), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_HOST_CONFIG_SET_CFM, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->status = (status__); - -#define CsrWifiSmeHostConfigSetCfmSendTo(dst__, src__, interfaceTag__, status__) \ - { \ - CsrWifiSmeHostConfigSetCfm *msg__; \ - CsrWifiSmeHostConfigSetCfmCreate(msg__, dst__, src__, interfaceTag__, status__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeHostConfigSetCfmSend(dst__, interfaceTag__, status__) \ - CsrWifiSmeHostConfigSetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__) - -/******************************************************************************* - - NAME - CsrWifiSmeIbssStationIndSend - - DESCRIPTION - The SME will send this primitive to indicate that a station has joined or - left the ad-hoc network. - - PARAMETERS - queue - Destination Task Queue - address - MAC address of the station that has joined or left - isconnected - TRUE if the station joined, FALSE if the station left - -*******************************************************************************/ -#define CsrWifiSmeIbssStationIndCreate(msg__, dst__, src__, address__, isconnected__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeIbssStationInd), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_IBSS_STATION_IND, dst__, src__); \ - msg__->address = (address__); \ - msg__->isconnected = (isconnected__); - -#define CsrWifiSmeIbssStationIndSendTo(dst__, src__, address__, isconnected__) \ - { \ - CsrWifiSmeIbssStationInd *msg__; \ - CsrWifiSmeIbssStationIndCreate(msg__, dst__, src__, address__, isconnected__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeIbssStationIndSend(dst__, address__, isconnected__) \ - CsrWifiSmeIbssStationIndSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, address__, isconnected__) - -/******************************************************************************* - - NAME - CsrWifiSmeInfoIndSend - - DESCRIPTION - Message indicating a some info about current activity. Mostly of interest - in testing but may be useful in the field. - - PARAMETERS - queue - Destination Task Queue - infoMessage - Contains the message. - -*******************************************************************************/ -#define CsrWifiSmeInfoIndCreate(msg__, dst__, src__, infoMessage__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeInfoInd), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_INFO_IND, dst__, src__); \ - msg__->infoMessage = (infoMessage__); - -#define CsrWifiSmeInfoIndSendTo(dst__, src__, infoMessage__) \ - { \ - CsrWifiSmeInfoInd *msg__; \ - CsrWifiSmeInfoIndCreate(msg__, dst__, src__, infoMessage__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeInfoIndSend(dst__, infoMessage__) \ - CsrWifiSmeInfoIndSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, infoMessage__) - -/******************************************************************************* - - NAME - CsrWifiSmeInterfaceCapabilityGetReqSend - - DESCRIPTION - The Wireless Manager calls this primitive to ask the SME for the - capabilities of the supported interfaces - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - -*******************************************************************************/ -#define CsrWifiSmeInterfaceCapabilityGetReqCreate(msg__, dst__, src__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeInterfaceCapabilityGetReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_INTERFACE_CAPABILITY_GET_REQ, dst__, src__); - -#define CsrWifiSmeInterfaceCapabilityGetReqSendTo(dst__, src__) \ - { \ - CsrWifiSmeInterfaceCapabilityGetReq *msg__; \ - CsrWifiSmeInterfaceCapabilityGetReqCreate(msg__, dst__, src__); \ - CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeInterfaceCapabilityGetReqSend(src__) \ - CsrWifiSmeInterfaceCapabilityGetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__) - -/******************************************************************************* - - NAME - CsrWifiSmeInterfaceCapabilityGetCfmSend - - DESCRIPTION - This primitive reports the result of the request. - - PARAMETERS - queue - Destination Task Queue - status - Result of the request - numInterfaces - Number of the interfaces supported - capBitmap - Points to the list of capabilities bitmaps provided for each - interface. - The bits represent the following capabilities: - -bits 7 to 4-Reserved - -bit 3-AMP - -bit 2-P2P - -bit 1-AP - -bit 0-STA - -*******************************************************************************/ -#define CsrWifiSmeInterfaceCapabilityGetCfmCreate(msg__, dst__, src__, status__, numInterfaces__, capBitmap__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeInterfaceCapabilityGetCfm), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_INTERFACE_CAPABILITY_GET_CFM, dst__, src__); \ - msg__->status = (status__); \ - msg__->numInterfaces = (numInterfaces__); \ - memcpy(msg__->capBitmap, (capBitmap__), sizeof(u8) * 2); - -#define CsrWifiSmeInterfaceCapabilityGetCfmSendTo(dst__, src__, status__, numInterfaces__, capBitmap__) \ - { \ - CsrWifiSmeInterfaceCapabilityGetCfm *msg__; \ - CsrWifiSmeInterfaceCapabilityGetCfmCreate(msg__, dst__, src__, status__, numInterfaces__, capBitmap__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeInterfaceCapabilityGetCfmSend(dst__, status__, numInterfaces__, capBitmap__) \ - CsrWifiSmeInterfaceCapabilityGetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__, numInterfaces__, capBitmap__) - -/******************************************************************************* - - NAME - CsrWifiSmeKeyReqSend - - DESCRIPTION - The wireless manager application calls this primitive to add or remove - keys that the chip should use for encryption of data. - The interface allows the wireless manager application to add and remove - keys according to the specified action. - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - interfaceTag - Interface Identifier; unique identifier of an interface - action - The value of the CsrWifiSmeListAction parameter instructs the - driver to modify or provide the list of keys. - CSR_WIFI_SME_LIST_ACTION_GET is not supported here. - key - Key to be added or removed - -*******************************************************************************/ -#define CsrWifiSmeKeyReqCreate(msg__, dst__, src__, interfaceTag__, action__, key__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeKeyReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_KEY_REQ, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->action = (action__); \ - msg__->key = (key__); - -#define CsrWifiSmeKeyReqSendTo(dst__, src__, interfaceTag__, action__, key__) \ - { \ - CsrWifiSmeKeyReq *msg__; \ - CsrWifiSmeKeyReqCreate(msg__, dst__, src__, interfaceTag__, action__, key__); \ - CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeKeyReqSend(src__, interfaceTag__, action__, key__) \ - CsrWifiSmeKeyReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, interfaceTag__, action__, key__) - -/******************************************************************************* - - NAME - CsrWifiSmeKeyCfmSend - - DESCRIPTION - The SME calls the primitive to report the result of the request - primitive. - - PARAMETERS - queue - Destination Task Queue - interfaceTag - Interface Identifier; unique identifier of an interface - status - Reports the result of the request - action - Action in the request - keyType - Type of the key added/deleted - peerMacAddress - Peer MAC Address of the key added/deleted - -*******************************************************************************/ -#define CsrWifiSmeKeyCfmCreate(msg__, dst__, src__, interfaceTag__, status__, action__, keyType__, peerMacAddress__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeKeyCfm), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_KEY_CFM, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->status = (status__); \ - msg__->action = (action__); \ - msg__->keyType = (keyType__); \ - msg__->peerMacAddress = (peerMacAddress__); - -#define CsrWifiSmeKeyCfmSendTo(dst__, src__, interfaceTag__, status__, action__, keyType__, peerMacAddress__) \ - { \ - CsrWifiSmeKeyCfm *msg__; \ - CsrWifiSmeKeyCfmCreate(msg__, dst__, src__, interfaceTag__, status__, action__, keyType__, peerMacAddress__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeKeyCfmSend(dst__, interfaceTag__, status__, action__, keyType__, peerMacAddress__) \ - CsrWifiSmeKeyCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__, action__, keyType__, peerMacAddress__) - -/******************************************************************************* - - NAME - CsrWifiSmeLinkQualityGetReqSend - - DESCRIPTION - This primitive gets the value of the LinkQuality parameter. - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - interfaceTag - Interface Identifier; unique identifier of an interface - -*******************************************************************************/ -#define CsrWifiSmeLinkQualityGetReqCreate(msg__, dst__, src__, interfaceTag__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeLinkQualityGetReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_LINK_QUALITY_GET_REQ, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); - -#define CsrWifiSmeLinkQualityGetReqSendTo(dst__, src__, interfaceTag__) \ - { \ - CsrWifiSmeLinkQualityGetReq *msg__; \ - CsrWifiSmeLinkQualityGetReqCreate(msg__, dst__, src__, interfaceTag__); \ - CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeLinkQualityGetReqSend(src__, interfaceTag__) \ - CsrWifiSmeLinkQualityGetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, interfaceTag__) - -/******************************************************************************* - - NAME - CsrWifiSmeLinkQualityGetCfmSend - - DESCRIPTION - This primitive reports the result of the request. - - PARAMETERS - queue - Destination Task Queue - interfaceTag - Interface Identifier; unique identifier of an interface - status - Reports the result of the request - linkQuality - Indicates the quality of the link - -*******************************************************************************/ -#define CsrWifiSmeLinkQualityGetCfmCreate(msg__, dst__, src__, interfaceTag__, status__, linkQuality__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeLinkQualityGetCfm), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_LINK_QUALITY_GET_CFM, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->status = (status__); \ - msg__->linkQuality = (linkQuality__); - -#define CsrWifiSmeLinkQualityGetCfmSendTo(dst__, src__, interfaceTag__, status__, linkQuality__) \ - { \ - CsrWifiSmeLinkQualityGetCfm *msg__; \ - CsrWifiSmeLinkQualityGetCfmCreate(msg__, dst__, src__, interfaceTag__, status__, linkQuality__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeLinkQualityGetCfmSend(dst__, interfaceTag__, status__, linkQuality__) \ - CsrWifiSmeLinkQualityGetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__, linkQuality__) - -/******************************************************************************* - - NAME - CsrWifiSmeMediaStatusIndSend - - DESCRIPTION - The SME sends this primitive to all the tasks that have registered to - receive it when a network connection is established, lost or has moved to - another AP. - - PARAMETERS - queue - Destination Task Queue - interfaceTag - Interface Identifier; unique identifier of an interface - mediaStatus - Indicates the media status - connectionInfo - This parameter is relevant only if the mediaStatus is - CSR_WIFI_SME_MEDIA_STATUS_CONNECTED: - it points to the connection information for the new network - disassocReason - This parameter is relevant only if the mediaStatus is - CSR_WIFI_SME_MEDIA_STATUS_DISCONNECTED: - if a disassociation has occurred it gives the reason of the - disassociation - deauthReason - This parameter is relevant only if the mediaStatus is - CSR_WIFI_SME_MEDIA_STATUS_DISCONNECTED: - if a deauthentication has occurred it gives the reason of - the deauthentication - -*******************************************************************************/ -#define CsrWifiSmeMediaStatusIndCreate(msg__, dst__, src__, interfaceTag__, mediaStatus__, connectionInfo__, disassocReason__, deauthReason__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeMediaStatusInd), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_MEDIA_STATUS_IND, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->mediaStatus = (mediaStatus__); \ - msg__->connectionInfo = (connectionInfo__); \ - msg__->disassocReason = (disassocReason__); \ - msg__->deauthReason = (deauthReason__); - -#define CsrWifiSmeMediaStatusIndSendTo(dst__, src__, interfaceTag__, mediaStatus__, connectionInfo__, disassocReason__, deauthReason__) \ - { \ - CsrWifiSmeMediaStatusInd *msg__; \ - CsrWifiSmeMediaStatusIndCreate(msg__, dst__, src__, interfaceTag__, mediaStatus__, connectionInfo__, disassocReason__, deauthReason__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeMediaStatusIndSend(dst__, interfaceTag__, mediaStatus__, connectionInfo__, disassocReason__, deauthReason__) \ - CsrWifiSmeMediaStatusIndSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, mediaStatus__, connectionInfo__, disassocReason__, deauthReason__) - -/******************************************************************************* - - NAME - CsrWifiSmeMibConfigGetReqSend - - DESCRIPTION - This primitive gets the value of the MibConfig parameter. - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - -*******************************************************************************/ -#define CsrWifiSmeMibConfigGetReqCreate(msg__, dst__, src__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeMibConfigGetReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_MIB_CONFIG_GET_REQ, dst__, src__); - -#define CsrWifiSmeMibConfigGetReqSendTo(dst__, src__) \ - { \ - CsrWifiSmeMibConfigGetReq *msg__; \ - CsrWifiSmeMibConfigGetReqCreate(msg__, dst__, src__); \ - CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeMibConfigGetReqSend(src__) \ - CsrWifiSmeMibConfigGetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__) - -/******************************************************************************* - - NAME - CsrWifiSmeMibConfigGetCfmSend - - DESCRIPTION - This primitive reports the result of the request. - - PARAMETERS - queue - Destination Task Queue - status - Reports the result of the request - mibConfig - Reports various IEEE 802.11 attributes as currently configured - -*******************************************************************************/ -#define CsrWifiSmeMibConfigGetCfmCreate(msg__, dst__, src__, status__, mibConfig__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeMibConfigGetCfm), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_MIB_CONFIG_GET_CFM, dst__, src__); \ - msg__->status = (status__); \ - msg__->mibConfig = (mibConfig__); - -#define CsrWifiSmeMibConfigGetCfmSendTo(dst__, src__, status__, mibConfig__) \ - { \ - CsrWifiSmeMibConfigGetCfm *msg__; \ - CsrWifiSmeMibConfigGetCfmCreate(msg__, dst__, src__, status__, mibConfig__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeMibConfigGetCfmSend(dst__, status__, mibConfig__) \ - CsrWifiSmeMibConfigGetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__, mibConfig__) - -/******************************************************************************* - - NAME - CsrWifiSmeMibConfigSetReqSend - - DESCRIPTION - This primitive sets the value of the MibConfig parameter. - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - mibConfig - Conveys the desired value of various IEEE 802.11 attributes as - currently configured - -*******************************************************************************/ -#define CsrWifiSmeMibConfigSetReqCreate(msg__, dst__, src__, mibConfig__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeMibConfigSetReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_MIB_CONFIG_SET_REQ, dst__, src__); \ - msg__->mibConfig = (mibConfig__); - -#define CsrWifiSmeMibConfigSetReqSendTo(dst__, src__, mibConfig__) \ - { \ - CsrWifiSmeMibConfigSetReq *msg__; \ - CsrWifiSmeMibConfigSetReqCreate(msg__, dst__, src__, mibConfig__); \ - CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeMibConfigSetReqSend(src__, mibConfig__) \ - CsrWifiSmeMibConfigSetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, mibConfig__) - -/******************************************************************************* - - NAME - CsrWifiSmeMibConfigSetCfmSend - - DESCRIPTION - This primitive reports the result of the request. - - PARAMETERS - queue - Destination Task Queue - status - Reports the result of the request - -*******************************************************************************/ -#define CsrWifiSmeMibConfigSetCfmCreate(msg__, dst__, src__, status__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeMibConfigSetCfm), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_MIB_CONFIG_SET_CFM, dst__, src__); \ - msg__->status = (status__); - -#define CsrWifiSmeMibConfigSetCfmSendTo(dst__, src__, status__) \ - { \ - CsrWifiSmeMibConfigSetCfm *msg__; \ - CsrWifiSmeMibConfigSetCfmCreate(msg__, dst__, src__, status__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeMibConfigSetCfmSend(dst__, status__) \ - CsrWifiSmeMibConfigSetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__) - -/******************************************************************************* - - NAME - CsrWifiSmeMibGetCfmSend - - DESCRIPTION - The SME calls this primitive to return the requested MIB variable values. - - PARAMETERS - queue - Destination Task Queue - status - Reports the result of the request - mibAttributeLength - Length of mibAttribute - mibAttribute - Points to the VarBind or VarBindList containing the - names and values of the MIB variables requested - -*******************************************************************************/ -#define CsrWifiSmeMibGetCfmCreate(msg__, dst__, src__, status__, mibAttributeLength__, mibAttribute__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeMibGetCfm), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_MIB_GET_CFM, dst__, src__); \ - msg__->status = (status__); \ - msg__->mibAttributeLength = (mibAttributeLength__); \ - msg__->mibAttribute = (mibAttribute__); - -#define CsrWifiSmeMibGetCfmSendTo(dst__, src__, status__, mibAttributeLength__, mibAttribute__) \ - { \ - CsrWifiSmeMibGetCfm *msg__; \ - CsrWifiSmeMibGetCfmCreate(msg__, dst__, src__, status__, mibAttributeLength__, mibAttribute__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeMibGetCfmSend(dst__, status__, mibAttributeLength__, mibAttribute__) \ - CsrWifiSmeMibGetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__, mibAttributeLength__, mibAttribute__) - -/******************************************************************************* - - NAME - CsrWifiSmeMibGetNextReqSend - - DESCRIPTION - To read a sequence of MIB parameters, for example a table, call this - primitive to find the name of the next MIB variable - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - mibAttributeLength - Length of mibAttribute - mibAttribute - Points to a VarBind or VarBindList containing the - name(s) of the MIB variable(s) to search from. - -*******************************************************************************/ -#define CsrWifiSmeMibGetNextReqCreate(msg__, dst__, src__, mibAttributeLength__, mibAttribute__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeMibGetNextReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_MIB_GET_NEXT_REQ, dst__, src__); \ - msg__->mibAttributeLength = (mibAttributeLength__); \ - msg__->mibAttribute = (mibAttribute__); - -#define CsrWifiSmeMibGetNextReqSendTo(dst__, src__, mibAttributeLength__, mibAttribute__) \ - { \ - CsrWifiSmeMibGetNextReq *msg__; \ - CsrWifiSmeMibGetNextReqCreate(msg__, dst__, src__, mibAttributeLength__, mibAttribute__); \ - CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeMibGetNextReqSend(src__, mibAttributeLength__, mibAttribute__) \ - CsrWifiSmeMibGetNextReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, mibAttributeLength__, mibAttribute__) - -/******************************************************************************* - - NAME - CsrWifiSmeMibGetNextCfmSend - - DESCRIPTION - The SME calls this primitive to return the requested MIB name(s). - The wireless manager application can then read the value of the MIB - variable using CSR_WIFI_SME_MIB_GET_REQ, using the names provided. - - PARAMETERS - queue - Destination Task Queue - status - Reports the result of the request - mibAttributeLength - Length of mibAttribute - mibAttribute - Points to a VarBind or VarBindList containing the - name(s) of the MIB variable(s) lexicographically - following the name(s) given in the request - -*******************************************************************************/ -#define CsrWifiSmeMibGetNextCfmCreate(msg__, dst__, src__, status__, mibAttributeLength__, mibAttribute__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeMibGetNextCfm), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_MIB_GET_NEXT_CFM, dst__, src__); \ - msg__->status = (status__); \ - msg__->mibAttributeLength = (mibAttributeLength__); \ - msg__->mibAttribute = (mibAttribute__); - -#define CsrWifiSmeMibGetNextCfmSendTo(dst__, src__, status__, mibAttributeLength__, mibAttribute__) \ - { \ - CsrWifiSmeMibGetNextCfm *msg__; \ - CsrWifiSmeMibGetNextCfmCreate(msg__, dst__, src__, status__, mibAttributeLength__, mibAttribute__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeMibGetNextCfmSend(dst__, status__, mibAttributeLength__, mibAttribute__) \ - CsrWifiSmeMibGetNextCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__, mibAttributeLength__, mibAttribute__) - -/******************************************************************************* - - NAME - CsrWifiSmeMibGetReqSend - - DESCRIPTION - The wireless manager application calls this primitive to retrieve one or - more MIB variables. - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - mibAttributeLength - Length of mibAttribute - mibAttribute - Points to the VarBind or VarBindList containing the - names of the MIB variables to be retrieved - -*******************************************************************************/ -#define CsrWifiSmeMibGetReqCreate(msg__, dst__, src__, mibAttributeLength__, mibAttribute__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeMibGetReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_MIB_GET_REQ, dst__, src__); \ - msg__->mibAttributeLength = (mibAttributeLength__); \ - msg__->mibAttribute = (mibAttribute__); - -#define CsrWifiSmeMibGetReqSendTo(dst__, src__, mibAttributeLength__, mibAttribute__) \ - { \ - CsrWifiSmeMibGetReq *msg__; \ - CsrWifiSmeMibGetReqCreate(msg__, dst__, src__, mibAttributeLength__, mibAttribute__); \ - CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeMibGetReqSend(src__, mibAttributeLength__, mibAttribute__) \ - CsrWifiSmeMibGetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, mibAttributeLength__, mibAttribute__) - -/******************************************************************************* - - NAME - CsrWifiSmeMibSetReqSend - - DESCRIPTION - The SME provides raw access to the MIB on the chip, which may be used by - some configuration or diagnostic utilities, but is not normally needed by - the wireless manager application. - The MIB access functions use BER encoded names (OID) of the MIB - parameters and BER encoded values, as described in the chip Host - Interface Protocol Specification. - The MIB parameters are described in 'Wi-Fi 5.0.0 Management Information - Base Reference Guide'. - The wireless manager application calls this primitive to set one or more - MIB variables - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - mibAttributeLength - Length of mibAttribute - mibAttribute - Points to the VarBind or VarBindList containing the - names and values of the MIB variables to set - -*******************************************************************************/ -#define CsrWifiSmeMibSetReqCreate(msg__, dst__, src__, mibAttributeLength__, mibAttribute__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeMibSetReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_MIB_SET_REQ, dst__, src__); \ - msg__->mibAttributeLength = (mibAttributeLength__); \ - msg__->mibAttribute = (mibAttribute__); - -#define CsrWifiSmeMibSetReqSendTo(dst__, src__, mibAttributeLength__, mibAttribute__) \ - { \ - CsrWifiSmeMibSetReq *msg__; \ - CsrWifiSmeMibSetReqCreate(msg__, dst__, src__, mibAttributeLength__, mibAttribute__); \ - CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeMibSetReqSend(src__, mibAttributeLength__, mibAttribute__) \ - CsrWifiSmeMibSetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, mibAttributeLength__, mibAttribute__) - -/******************************************************************************* - - NAME - CsrWifiSmeMibSetCfmSend - - DESCRIPTION - The SME calls the primitive to report the result of the set primitive. - - PARAMETERS - queue - Destination Task Queue - status - Reports the result of the request - -*******************************************************************************/ -#define CsrWifiSmeMibSetCfmCreate(msg__, dst__, src__, status__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeMibSetCfm), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_MIB_SET_CFM, dst__, src__); \ - msg__->status = (status__); - -#define CsrWifiSmeMibSetCfmSendTo(dst__, src__, status__) \ - { \ - CsrWifiSmeMibSetCfm *msg__; \ - CsrWifiSmeMibSetCfmCreate(msg__, dst__, src__, status__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeMibSetCfmSend(dst__, status__) \ - CsrWifiSmeMibSetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__) - -/******************************************************************************* - - NAME - CsrWifiSmeMicFailureIndSend - - DESCRIPTION - The SME sends this primitive to all the tasks that have registered to - receive it whenever the chip firmware reports a MIC failure. - - PARAMETERS - queue - Destination Task Queue - interfaceTag - Interface Identifier; unique identifier of an interface - secondFailure - TRUE if this indication is for a second failure in 60 - seconds - count - The number of MIC failure events since the connection was - established - address - MAC address of the transmitter that caused the MIC failure - keyType - Type of key for which the failure occurred - -*******************************************************************************/ -#define CsrWifiSmeMicFailureIndCreate(msg__, dst__, src__, interfaceTag__, secondFailure__, count__, address__, keyType__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeMicFailureInd), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_MIC_FAILURE_IND, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->secondFailure = (secondFailure__); \ - msg__->count = (count__); \ - msg__->address = (address__); \ - msg__->keyType = (keyType__); - -#define CsrWifiSmeMicFailureIndSendTo(dst__, src__, interfaceTag__, secondFailure__, count__, address__, keyType__) \ - { \ - CsrWifiSmeMicFailureInd *msg__; \ - CsrWifiSmeMicFailureIndCreate(msg__, dst__, src__, interfaceTag__, secondFailure__, count__, address__, keyType__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeMicFailureIndSend(dst__, interfaceTag__, secondFailure__, count__, address__, keyType__) \ - CsrWifiSmeMicFailureIndSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, secondFailure__, count__, address__, keyType__) - -/******************************************************************************* - - NAME - CsrWifiSmeMulticastAddressReqSend - - DESCRIPTION - The wireless manager application calls this primitive to specify the - multicast addresses which the chip should recognise. The interface allows - the wireless manager application to query, add, remove and flush the - multicast addresses for the network interface according to the specified - action. - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - interfaceTag - Interface Identifier; unique identifier of an interface - action - The value of the CsrWifiSmeListAction parameter - instructs the driver to modify or provide the list of - MAC addresses. - setAddressesCount - Number of MAC addresses sent with the primitive - setAddresses - Pointer to the list of MAC Addresses sent with the - primitive, set to NULL if none is sent. - -*******************************************************************************/ -#define CsrWifiSmeMulticastAddressReqCreate(msg__, dst__, src__, interfaceTag__, action__, setAddressesCount__, setAddresses__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeMulticastAddressReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_MULTICAST_ADDRESS_REQ, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->action = (action__); \ - msg__->setAddressesCount = (setAddressesCount__); \ - msg__->setAddresses = (setAddresses__); - -#define CsrWifiSmeMulticastAddressReqSendTo(dst__, src__, interfaceTag__, action__, setAddressesCount__, setAddresses__) \ - { \ - CsrWifiSmeMulticastAddressReq *msg__; \ - CsrWifiSmeMulticastAddressReqCreate(msg__, dst__, src__, interfaceTag__, action__, setAddressesCount__, setAddresses__); \ - CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeMulticastAddressReqSend(src__, interfaceTag__, action__, setAddressesCount__, setAddresses__) \ - CsrWifiSmeMulticastAddressReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, interfaceTag__, action__, setAddressesCount__, setAddresses__) - -/******************************************************************************* - - NAME - CsrWifiSmeMulticastAddressCfmSend - - DESCRIPTION - The SME will call this primitive when the operation is complete. For a - GET action, this primitive reports the current list of MAC addresses. - - PARAMETERS - queue - Destination Task Queue - interfaceTag - Interface Identifier; unique identifier of an interface - status - Reports the result of the request - action - Action in the request - getAddressesCount - This parameter is only relevant if action is - CSR_WIFI_SME_LIST_ACTION_GET: - number of MAC addresses sent with the primitive - getAddresses - Pointer to the list of MAC Addresses sent with the - primitive, set to NULL if none is sent. - -*******************************************************************************/ -#define CsrWifiSmeMulticastAddressCfmCreate(msg__, dst__, src__, interfaceTag__, status__, action__, getAddressesCount__, getAddresses__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeMulticastAddressCfm), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_MULTICAST_ADDRESS_CFM, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->status = (status__); \ - msg__->action = (action__); \ - msg__->getAddressesCount = (getAddressesCount__); \ - msg__->getAddresses = (getAddresses__); - -#define CsrWifiSmeMulticastAddressCfmSendTo(dst__, src__, interfaceTag__, status__, action__, getAddressesCount__, getAddresses__) \ - { \ - CsrWifiSmeMulticastAddressCfm *msg__; \ - CsrWifiSmeMulticastAddressCfmCreate(msg__, dst__, src__, interfaceTag__, status__, action__, getAddressesCount__, getAddresses__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeMulticastAddressCfmSend(dst__, interfaceTag__, status__, action__, getAddressesCount__, getAddresses__) \ - CsrWifiSmeMulticastAddressCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__, action__, getAddressesCount__, getAddresses__) - -/******************************************************************************* - - NAME - CsrWifiSmePacketFilterSetReqSend - - DESCRIPTION - The wireless manager application should call this primitive to enable or - disable filtering of broadcast packets: uninteresting broadcast packets - will be dropped by the Wi-Fi chip, instead of passing them up to the - host. - This has the advantage of saving power in the host application processor - as it removes the need to process unwanted packets. - All broadcast packets are filtered according to the filter and the filter - mode provided, except ARP packets, which are filtered using - arpFilterAddress. - Filters are not cumulative: only the parameters specified in the most - recent successful request are significant. - For more information, see 'UniFi Firmware API Specification'. - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - interfaceTag - Interface Identifier; unique identifier of an interface - filterLength - Length of the filter in bytes. - filterLength=0 disables the filter previously set - filter - Points to the first byte of the filter provided, if any. - This shall include zero or more instance of the - information elements of one of these types - * Traffic Classification (TCLAS) elements - * WMM-SA TCLAS elements - mode - Specifies whether the filter selects or excludes packets - matching the filter - arpFilterAddress - IPv4 address to be used for filtering the ARP packets. - * If the specified address is the IPv4 broadcast address - (255.255.255.255), all ARP packets are reported to the - host, - * If the specified address is NOT the IPv4 broadcast - address, only ARP packets with the specified address in - the Source or Target Protocol Address fields are reported - to the host - -*******************************************************************************/ -#define CsrWifiSmePacketFilterSetReqCreate(msg__, dst__, src__, interfaceTag__, filterLength__, filter__, mode__, arpFilterAddress__) \ - msg__ = kmalloc(sizeof(CsrWifiSmePacketFilterSetReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_PACKET_FILTER_SET_REQ, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->filterLength = (filterLength__); \ - msg__->filter = (filter__); \ - msg__->mode = (mode__); \ - msg__->arpFilterAddress = (arpFilterAddress__); - -#define CsrWifiSmePacketFilterSetReqSendTo(dst__, src__, interfaceTag__, filterLength__, filter__, mode__, arpFilterAddress__) \ - { \ - CsrWifiSmePacketFilterSetReq *msg__; \ - CsrWifiSmePacketFilterSetReqCreate(msg__, dst__, src__, interfaceTag__, filterLength__, filter__, mode__, arpFilterAddress__); \ - CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmePacketFilterSetReqSend(src__, interfaceTag__, filterLength__, filter__, mode__, arpFilterAddress__) \ - CsrWifiSmePacketFilterSetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, interfaceTag__, filterLength__, filter__, mode__, arpFilterAddress__) - -/******************************************************************************* - - NAME - CsrWifiSmePacketFilterSetCfmSend - - DESCRIPTION - The SME calls the primitive to report the result of the set primitive. - - PARAMETERS - queue - Destination Task Queue - interfaceTag - Interface Identifier; unique identifier of an interface - status - Reports the result of the request - -*******************************************************************************/ -#define CsrWifiSmePacketFilterSetCfmCreate(msg__, dst__, src__, interfaceTag__, status__) \ - msg__ = kmalloc(sizeof(CsrWifiSmePacketFilterSetCfm), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_PACKET_FILTER_SET_CFM, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->status = (status__); - -#define CsrWifiSmePacketFilterSetCfmSendTo(dst__, src__, interfaceTag__, status__) \ - { \ - CsrWifiSmePacketFilterSetCfm *msg__; \ - CsrWifiSmePacketFilterSetCfmCreate(msg__, dst__, src__, interfaceTag__, status__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmePacketFilterSetCfmSend(dst__, interfaceTag__, status__) \ - CsrWifiSmePacketFilterSetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__) - -/******************************************************************************* - - NAME - CsrWifiSmePermanentMacAddressGetReqSend - - DESCRIPTION - This primitive retrieves the MAC address stored in EEPROM - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - -*******************************************************************************/ -#define CsrWifiSmePermanentMacAddressGetReqCreate(msg__, dst__, src__) \ - msg__ = kmalloc(sizeof(CsrWifiSmePermanentMacAddressGetReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_PERMANENT_MAC_ADDRESS_GET_REQ, dst__, src__); - -#define CsrWifiSmePermanentMacAddressGetReqSendTo(dst__, src__) \ - { \ - CsrWifiSmePermanentMacAddressGetReq *msg__; \ - CsrWifiSmePermanentMacAddressGetReqCreate(msg__, dst__, src__); \ - CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmePermanentMacAddressGetReqSend(src__) \ - CsrWifiSmePermanentMacAddressGetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__) - -/******************************************************************************* - - NAME - CsrWifiSmePermanentMacAddressGetCfmSend - - DESCRIPTION - This primitive reports the result of the request. - - PARAMETERS - queue - Destination Task Queue - status - Reports the result of the request - permanentMacAddress - MAC address stored in the EEPROM - -*******************************************************************************/ -#define CsrWifiSmePermanentMacAddressGetCfmCreate(msg__, dst__, src__, status__, permanentMacAddress__) \ - msg__ = kmalloc(sizeof(CsrWifiSmePermanentMacAddressGetCfm), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_PERMANENT_MAC_ADDRESS_GET_CFM, dst__, src__); \ - msg__->status = (status__); \ - msg__->permanentMacAddress = (permanentMacAddress__); - -#define CsrWifiSmePermanentMacAddressGetCfmSendTo(dst__, src__, status__, permanentMacAddress__) \ - { \ - CsrWifiSmePermanentMacAddressGetCfm *msg__; \ - CsrWifiSmePermanentMacAddressGetCfmCreate(msg__, dst__, src__, status__, permanentMacAddress__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmePermanentMacAddressGetCfmSend(dst__, status__, permanentMacAddress__) \ - CsrWifiSmePermanentMacAddressGetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__, permanentMacAddress__) - -/******************************************************************************* - - NAME - CsrWifiSmePmkidCandidateListIndSend - - DESCRIPTION - The SME will send this primitive to all the tasks that have registered to - receive it when a new network supporting preauthentication and/or PMK - caching is seen. - - PARAMETERS - queue - Destination Task Queue - interfaceTag - Interface Identifier; unique identifier of an - interface - pmkidCandidatesCount - Number of PMKID candidates provided - pmkidCandidates - Points to the first PMKID candidate - -*******************************************************************************/ -#define CsrWifiSmePmkidCandidateListIndCreate(msg__, dst__, src__, interfaceTag__, pmkidCandidatesCount__, pmkidCandidates__) \ - msg__ = kmalloc(sizeof(CsrWifiSmePmkidCandidateListInd), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_PMKID_CANDIDATE_LIST_IND, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->pmkidCandidatesCount = (pmkidCandidatesCount__); \ - msg__->pmkidCandidates = (pmkidCandidates__); - -#define CsrWifiSmePmkidCandidateListIndSendTo(dst__, src__, interfaceTag__, pmkidCandidatesCount__, pmkidCandidates__) \ - { \ - CsrWifiSmePmkidCandidateListInd *msg__; \ - CsrWifiSmePmkidCandidateListIndCreate(msg__, dst__, src__, interfaceTag__, pmkidCandidatesCount__, pmkidCandidates__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmePmkidCandidateListIndSend(dst__, interfaceTag__, pmkidCandidatesCount__, pmkidCandidates__) \ - CsrWifiSmePmkidCandidateListIndSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, pmkidCandidatesCount__, pmkidCandidates__) - -/******************************************************************************* - - NAME - CsrWifiSmePmkidReqSend - - DESCRIPTION - The wireless manager application calls this primitive to request an - operation on the SME PMKID list. - The action argument specifies the operation to perform. - When the connection is complete, the wireless manager application may - then send and receive EAPOL packets to complete WPA or WPA2 - authentication if appropriate. - The wireless manager application can then pass the resulting encryption - keys using this primitive. - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - interfaceTag - Interface Identifier; unique identifier of an interface - action - The value of the CsrWifiSmeListAction parameter instructs - the driver to modify or provide the list of PMKIDs. - setPmkidsCount - Number of PMKIDs sent with the primitive - setPmkids - Pointer to the list of PMKIDs sent with the primitive, set - to NULL if none is sent. - -*******************************************************************************/ -#define CsrWifiSmePmkidReqCreate(msg__, dst__, src__, interfaceTag__, action__, setPmkidsCount__, setPmkids__) \ - msg__ = kmalloc(sizeof(CsrWifiSmePmkidReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_PMKID_REQ, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->action = (action__); \ - msg__->setPmkidsCount = (setPmkidsCount__); \ - msg__->setPmkids = (setPmkids__); - -#define CsrWifiSmePmkidReqSendTo(dst__, src__, interfaceTag__, action__, setPmkidsCount__, setPmkids__) \ - { \ - CsrWifiSmePmkidReq *msg__; \ - CsrWifiSmePmkidReqCreate(msg__, dst__, src__, interfaceTag__, action__, setPmkidsCount__, setPmkids__); \ - CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmePmkidReqSend(src__, interfaceTag__, action__, setPmkidsCount__, setPmkids__) \ - CsrWifiSmePmkidReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, interfaceTag__, action__, setPmkidsCount__, setPmkids__) - -/******************************************************************************* - - NAME - CsrWifiSmePmkidCfmSend - - DESCRIPTION - The SME will call this primitive when the operation is complete. For a - GET action, this primitive reports the current list of PMKIDs - - PARAMETERS - queue - Destination Task Queue - interfaceTag - Interface Identifier; unique identifier of an interface - status - Reports the result of the request - action - Action in the request - getPmkidsCount - This parameter is only relevant if action is - CSR_WIFI_SME_LIST_ACTION_GET: - number of PMKIDs sent with the primitive - getPmkids - Pointer to the list of PMKIDs sent with the primitive, set - to NULL if none is sent. - -*******************************************************************************/ -#define CsrWifiSmePmkidCfmCreate(msg__, dst__, src__, interfaceTag__, status__, action__, getPmkidsCount__, getPmkids__) \ - msg__ = kmalloc(sizeof(CsrWifiSmePmkidCfm), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_PMKID_CFM, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->status = (status__); \ - msg__->action = (action__); \ - msg__->getPmkidsCount = (getPmkidsCount__); \ - msg__->getPmkids = (getPmkids__); - -#define CsrWifiSmePmkidCfmSendTo(dst__, src__, interfaceTag__, status__, action__, getPmkidsCount__, getPmkids__) \ - { \ - CsrWifiSmePmkidCfm *msg__; \ - CsrWifiSmePmkidCfmCreate(msg__, dst__, src__, interfaceTag__, status__, action__, getPmkidsCount__, getPmkids__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmePmkidCfmSend(dst__, interfaceTag__, status__, action__, getPmkidsCount__, getPmkids__) \ - CsrWifiSmePmkidCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__, action__, getPmkidsCount__, getPmkids__) - -/******************************************************************************* - - NAME - CsrWifiSmePowerConfigGetReqSend - - DESCRIPTION - This primitive gets the value of the PowerConfig parameter. - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - -*******************************************************************************/ -#define CsrWifiSmePowerConfigGetReqCreate(msg__, dst__, src__) \ - msg__ = kmalloc(sizeof(CsrWifiSmePowerConfigGetReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_POWER_CONFIG_GET_REQ, dst__, src__); - -#define CsrWifiSmePowerConfigGetReqSendTo(dst__, src__) \ - { \ - CsrWifiSmePowerConfigGetReq *msg__; \ - CsrWifiSmePowerConfigGetReqCreate(msg__, dst__, src__); \ - CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmePowerConfigGetReqSend(src__) \ - CsrWifiSmePowerConfigGetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__) - -/******************************************************************************* - - NAME - CsrWifiSmePowerConfigGetCfmSend - - DESCRIPTION - This primitive reports the result of the request. - - PARAMETERS - queue - Destination Task Queue - status - Reports the result of the request - powerConfig - Returns the current parameters for the power configuration of - the firmware - -*******************************************************************************/ -#define CsrWifiSmePowerConfigGetCfmCreate(msg__, dst__, src__, status__, powerConfig__) \ - msg__ = kmalloc(sizeof(CsrWifiSmePowerConfigGetCfm), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_POWER_CONFIG_GET_CFM, dst__, src__); \ - msg__->status = (status__); \ - msg__->powerConfig = (powerConfig__); - -#define CsrWifiSmePowerConfigGetCfmSendTo(dst__, src__, status__, powerConfig__) \ - { \ - CsrWifiSmePowerConfigGetCfm *msg__; \ - CsrWifiSmePowerConfigGetCfmCreate(msg__, dst__, src__, status__, powerConfig__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmePowerConfigGetCfmSend(dst__, status__, powerConfig__) \ - CsrWifiSmePowerConfigGetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__, powerConfig__) - -/******************************************************************************* - - NAME - CsrWifiSmePowerConfigSetReqSend - - DESCRIPTION - This primitive sets the value of the PowerConfig parameter. - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - powerConfig - Power saving configuration - -*******************************************************************************/ -#define CsrWifiSmePowerConfigSetReqCreate(msg__, dst__, src__, powerConfig__) \ - msg__ = kmalloc(sizeof(CsrWifiSmePowerConfigSetReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_POWER_CONFIG_SET_REQ, dst__, src__); \ - msg__->powerConfig = (powerConfig__); - -#define CsrWifiSmePowerConfigSetReqSendTo(dst__, src__, powerConfig__) \ - { \ - CsrWifiSmePowerConfigSetReq *msg__; \ - CsrWifiSmePowerConfigSetReqCreate(msg__, dst__, src__, powerConfig__); \ - CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmePowerConfigSetReqSend(src__, powerConfig__) \ - CsrWifiSmePowerConfigSetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, powerConfig__) - -/******************************************************************************* - - NAME - CsrWifiSmePowerConfigSetCfmSend - - DESCRIPTION - This primitive reports the result of the request. - - PARAMETERS - queue - Destination Task Queue - status - Reports the result of the request - -*******************************************************************************/ -#define CsrWifiSmePowerConfigSetCfmCreate(msg__, dst__, src__, status__) \ - msg__ = kmalloc(sizeof(CsrWifiSmePowerConfigSetCfm), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_POWER_CONFIG_SET_CFM, dst__, src__); \ - msg__->status = (status__); - -#define CsrWifiSmePowerConfigSetCfmSendTo(dst__, src__, status__) \ - { \ - CsrWifiSmePowerConfigSetCfm *msg__; \ - CsrWifiSmePowerConfigSetCfmCreate(msg__, dst__, src__, status__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmePowerConfigSetCfmSend(dst__, status__) \ - CsrWifiSmePowerConfigSetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__) - -/******************************************************************************* - - NAME - CsrWifiSmeRegulatoryDomainInfoGetReqSend - - DESCRIPTION - This primitive gets the value of the RegulatoryDomainInfo parameter. - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - -*******************************************************************************/ -#define CsrWifiSmeRegulatoryDomainInfoGetReqCreate(msg__, dst__, src__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeRegulatoryDomainInfoGetReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_REGULATORY_DOMAIN_INFO_GET_REQ, dst__, src__); - -#define CsrWifiSmeRegulatoryDomainInfoGetReqSendTo(dst__, src__) \ - { \ - CsrWifiSmeRegulatoryDomainInfoGetReq *msg__; \ - CsrWifiSmeRegulatoryDomainInfoGetReqCreate(msg__, dst__, src__); \ - CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeRegulatoryDomainInfoGetReqSend(src__) \ - CsrWifiSmeRegulatoryDomainInfoGetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__) - -/******************************************************************************* - - NAME - CsrWifiSmeRegulatoryDomainInfoGetCfmSend - - DESCRIPTION - This primitive reports the result of the request. - - PARAMETERS - queue - Destination Task Queue - status - Reports the result of the request - regDomInfo - Reports information and state related to regulatory domain - operation. - -*******************************************************************************/ -#define CsrWifiSmeRegulatoryDomainInfoGetCfmCreate(msg__, dst__, src__, status__, regDomInfo__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeRegulatoryDomainInfoGetCfm), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_REGULATORY_DOMAIN_INFO_GET_CFM, dst__, src__); \ - msg__->status = (status__); \ - msg__->regDomInfo = (regDomInfo__); - -#define CsrWifiSmeRegulatoryDomainInfoGetCfmSendTo(dst__, src__, status__, regDomInfo__) \ - { \ - CsrWifiSmeRegulatoryDomainInfoGetCfm *msg__; \ - CsrWifiSmeRegulatoryDomainInfoGetCfmCreate(msg__, dst__, src__, status__, regDomInfo__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeRegulatoryDomainInfoGetCfmSend(dst__, status__, regDomInfo__) \ - CsrWifiSmeRegulatoryDomainInfoGetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__, regDomInfo__) - -/******************************************************************************* - - NAME - CsrWifiSmeRoamCompleteIndSend - - DESCRIPTION - The SME will send this primitive to all the tasks that have registered to - receive it whenever it completes an attempt to roam to an AP. If the roam - attempt was successful, status will be set to CSR_WIFI_SME_SUCCESS, - otherwise it shall be set to the appropriate error code. - - PARAMETERS - queue - Destination Task Queue - interfaceTag - Interface Identifier; unique identifier of an interface - status - Reports the result of the roaming procedure - -*******************************************************************************/ -#define CsrWifiSmeRoamCompleteIndCreate(msg__, dst__, src__, interfaceTag__, status__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeRoamCompleteInd), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_ROAM_COMPLETE_IND, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->status = (status__); - -#define CsrWifiSmeRoamCompleteIndSendTo(dst__, src__, interfaceTag__, status__) \ - { \ - CsrWifiSmeRoamCompleteInd *msg__; \ - CsrWifiSmeRoamCompleteIndCreate(msg__, dst__, src__, interfaceTag__, status__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeRoamCompleteIndSend(dst__, interfaceTag__, status__) \ - CsrWifiSmeRoamCompleteIndSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__) - -/******************************************************************************* - - NAME - CsrWifiSmeRoamStartIndSend - - DESCRIPTION - The SME will send this primitive to all the tasks that have registered to - receive it whenever it begins an attempt to roam to an AP. - If the wireless manager application connect request specified the SSID - and the BSSID was set to the broadcast address (0xFF 0xFF 0xFF 0xFF 0xFF - 0xFF), the SME monitors the signal quality and maintains a list of - candidates to roam to. When the signal quality of the current connection - falls below a threshold, and there is a candidate with better quality, - the SME will attempt to the candidate AP. - If the roaming procedure succeeds, the SME will also issue a Media - Connect indication to inform the wireless manager application of the - change. - NOTE: to prevent the SME from initiating roaming the WMA must specify the - BSSID in the connection request; this forces the SME to connect only to - that AP. - The wireless manager application can obtain statistics for roaming - purposes using CSR_WIFI_SME_CONNECTION_QUALITY_IND and - CSR_WIFI_SME_CONNECTION_STATS_GET_REQ. - When the wireless manager application wishes to roam to another AP, it - must issue a connection request specifying the BSSID of the desired AP. - - PARAMETERS - queue - Destination Task Queue - interfaceTag - Interface Identifier; unique identifier of an interface - roamReason - Indicates the reason for starting the roaming procedure - reason80211 - Indicates the reason for deauthentication or disassociation - -*******************************************************************************/ -#define CsrWifiSmeRoamStartIndCreate(msg__, dst__, src__, interfaceTag__, roamReason__, reason80211__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeRoamStartInd), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_ROAM_START_IND, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->roamReason = (roamReason__); \ - msg__->reason80211 = (reason80211__); - -#define CsrWifiSmeRoamStartIndSendTo(dst__, src__, interfaceTag__, roamReason__, reason80211__) \ - { \ - CsrWifiSmeRoamStartInd *msg__; \ - CsrWifiSmeRoamStartIndCreate(msg__, dst__, src__, interfaceTag__, roamReason__, reason80211__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeRoamStartIndSend(dst__, interfaceTag__, roamReason__, reason80211__) \ - CsrWifiSmeRoamStartIndSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, roamReason__, reason80211__) - -/******************************************************************************* - - NAME - CsrWifiSmeRoamingConfigGetReqSend - - DESCRIPTION - This primitive gets the value of the RoamingConfig parameter. - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - interfaceTag - Interface Identifier; unique identifier of an interface - -*******************************************************************************/ -#define CsrWifiSmeRoamingConfigGetReqCreate(msg__, dst__, src__, interfaceTag__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeRoamingConfigGetReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_ROAMING_CONFIG_GET_REQ, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); - -#define CsrWifiSmeRoamingConfigGetReqSendTo(dst__, src__, interfaceTag__) \ - { \ - CsrWifiSmeRoamingConfigGetReq *msg__; \ - CsrWifiSmeRoamingConfigGetReqCreate(msg__, dst__, src__, interfaceTag__); \ - CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeRoamingConfigGetReqSend(src__, interfaceTag__) \ - CsrWifiSmeRoamingConfigGetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, interfaceTag__) - -/******************************************************************************* - - NAME - CsrWifiSmeRoamingConfigGetCfmSend - - DESCRIPTION - This primitive reports the result of the request. - - PARAMETERS - queue - Destination Task Queue - interfaceTag - Interface Identifier; unique identifier of an interface - status - Reports the result of the request - roamingConfig - Reports the roaming behaviour of the driver and firmware - -*******************************************************************************/ -#define CsrWifiSmeRoamingConfigGetCfmCreate(msg__, dst__, src__, interfaceTag__, status__, roamingConfig__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeRoamingConfigGetCfm), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_ROAMING_CONFIG_GET_CFM, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->status = (status__); \ - msg__->roamingConfig = (roamingConfig__); - -#define CsrWifiSmeRoamingConfigGetCfmSendTo(dst__, src__, interfaceTag__, status__, roamingConfig__) \ - { \ - CsrWifiSmeRoamingConfigGetCfm *msg__; \ - CsrWifiSmeRoamingConfigGetCfmCreate(msg__, dst__, src__, interfaceTag__, status__, roamingConfig__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeRoamingConfigGetCfmSend(dst__, interfaceTag__, status__, roamingConfig__) \ - CsrWifiSmeRoamingConfigGetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__, roamingConfig__) - -/******************************************************************************* - - NAME - CsrWifiSmeRoamingConfigSetReqSend - - DESCRIPTION - This primitive sets the value of the RoamingConfig parameter. - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - interfaceTag - Interface Identifier; unique identifier of an interface - roamingConfig - Desired roaming behaviour values - -*******************************************************************************/ -#define CsrWifiSmeRoamingConfigSetReqCreate(msg__, dst__, src__, interfaceTag__, roamingConfig__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeRoamingConfigSetReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_ROAMING_CONFIG_SET_REQ, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->roamingConfig = (roamingConfig__); - -#define CsrWifiSmeRoamingConfigSetReqSendTo(dst__, src__, interfaceTag__, roamingConfig__) \ - { \ - CsrWifiSmeRoamingConfigSetReq *msg__; \ - CsrWifiSmeRoamingConfigSetReqCreate(msg__, dst__, src__, interfaceTag__, roamingConfig__); \ - CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeRoamingConfigSetReqSend(src__, interfaceTag__, roamingConfig__) \ - CsrWifiSmeRoamingConfigSetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, interfaceTag__, roamingConfig__) - -/******************************************************************************* - - NAME - CsrWifiSmeRoamingConfigSetCfmSend - - DESCRIPTION - This primitive sets the value of the RoamingConfig parameter. - - PARAMETERS - queue - Destination Task Queue - interfaceTag - Interface Identifier; unique identifier of an interface - status - Reports the result of the request - -*******************************************************************************/ -#define CsrWifiSmeRoamingConfigSetCfmCreate(msg__, dst__, src__, interfaceTag__, status__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeRoamingConfigSetCfm), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_ROAMING_CONFIG_SET_CFM, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->status = (status__); - -#define CsrWifiSmeRoamingConfigSetCfmSendTo(dst__, src__, interfaceTag__, status__) \ - { \ - CsrWifiSmeRoamingConfigSetCfm *msg__; \ - CsrWifiSmeRoamingConfigSetCfmCreate(msg__, dst__, src__, interfaceTag__, status__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeRoamingConfigSetCfmSend(dst__, interfaceTag__, status__) \ - CsrWifiSmeRoamingConfigSetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__) - -/******************************************************************************* - - NAME - CsrWifiSmeScanConfigGetReqSend - - DESCRIPTION - This primitive gets the value of the ScanConfig parameter. - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - -*******************************************************************************/ -#define CsrWifiSmeScanConfigGetReqCreate(msg__, dst__, src__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeScanConfigGetReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_SCAN_CONFIG_GET_REQ, dst__, src__); - -#define CsrWifiSmeScanConfigGetReqSendTo(dst__, src__) \ - { \ - CsrWifiSmeScanConfigGetReq *msg__; \ - CsrWifiSmeScanConfigGetReqCreate(msg__, dst__, src__); \ - CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeScanConfigGetReqSend(src__) \ - CsrWifiSmeScanConfigGetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__) - -/******************************************************************************* - - NAME - CsrWifiSmeScanConfigGetCfmSend - - DESCRIPTION - This primitive reports the result of the request. - - PARAMETERS - queue - Destination Task Queue - status - Reports the result of the request - scanConfig - Returns the current parameters for the autonomous scanning - behaviour of the firmware - -*******************************************************************************/ -#define CsrWifiSmeScanConfigGetCfmCreate(msg__, dst__, src__, status__, scanConfig__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeScanConfigGetCfm), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_SCAN_CONFIG_GET_CFM, dst__, src__); \ - msg__->status = (status__); \ - msg__->scanConfig = (scanConfig__); - -#define CsrWifiSmeScanConfigGetCfmSendTo(dst__, src__, status__, scanConfig__) \ - { \ - CsrWifiSmeScanConfigGetCfm *msg__; \ - CsrWifiSmeScanConfigGetCfmCreate(msg__, dst__, src__, status__, scanConfig__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeScanConfigGetCfmSend(dst__, status__, scanConfig__) \ - CsrWifiSmeScanConfigGetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__, scanConfig__) - -/******************************************************************************* - - NAME - CsrWifiSmeScanConfigSetReqSend - - DESCRIPTION - This primitive sets the value of the ScanConfig parameter. - The SME normally configures the firmware to perform autonomous scanning - without involving the host. - The firmware passes beacon / probe response or indicates loss of beacon - on certain changes of state, for example: - * A new AP is seen for the first time - * An AP is no longer visible - * The signal strength of an AP changes by more than a certain amount, as - configured by the thresholds in the scanConfig parameter - In addition to the autonomous scan, the wireless manager application may - request a scan at any time using CSR_WIFI_SME_SCAN_FULL_REQ. - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - scanConfig - Reports the configuration for the autonomous scanning behaviour - of the firmware - -*******************************************************************************/ -#define CsrWifiSmeScanConfigSetReqCreate(msg__, dst__, src__, scanConfig__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeScanConfigSetReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_SCAN_CONFIG_SET_REQ, dst__, src__); \ - msg__->scanConfig = (scanConfig__); - -#define CsrWifiSmeScanConfigSetReqSendTo(dst__, src__, scanConfig__) \ - { \ - CsrWifiSmeScanConfigSetReq *msg__; \ - CsrWifiSmeScanConfigSetReqCreate(msg__, dst__, src__, scanConfig__); \ - CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeScanConfigSetReqSend(src__, scanConfig__) \ - CsrWifiSmeScanConfigSetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, scanConfig__) - -/******************************************************************************* - - NAME - CsrWifiSmeScanConfigSetCfmSend - - DESCRIPTION - This primitive reports the result of the request. - - PARAMETERS - queue - Destination Task Queue - status - Reports the result of the request - -*******************************************************************************/ -#define CsrWifiSmeScanConfigSetCfmCreate(msg__, dst__, src__, status__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeScanConfigSetCfm), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_SCAN_CONFIG_SET_CFM, dst__, src__); \ - msg__->status = (status__); - -#define CsrWifiSmeScanConfigSetCfmSendTo(dst__, src__, status__) \ - { \ - CsrWifiSmeScanConfigSetCfm *msg__; \ - CsrWifiSmeScanConfigSetCfmCreate(msg__, dst__, src__, status__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeScanConfigSetCfmSend(dst__, status__) \ - CsrWifiSmeScanConfigSetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__) - -/******************************************************************************* - - NAME - CsrWifiSmeScanFullReqSend - - DESCRIPTION - The wireless manager application should call this primitive to request a - full scan. - Channels are scanned actively or passively according to the requirement - set by regulatory domain. - If the SME receives this primitive while a full scan is going on, the new - request is buffered and it will be served after the current full scan is - completed. - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - ssidCount - Number of SSIDs provided. - If it is 0, the SME will attempt to detect any network - ssid - Points to the first SSID provided, if any. - bssid - BSS identifier. - If it is equal to FF-FF-FF-FF-FF, the SME will listen for - messages from any BSS. - If it is different from FF-FF-FF-FF-FF and any SSID is - provided, one SSID must match the network of the BSS. - forceScan - Forces the scan even if the SME is in a state which would - normally prevent it (e.g. autonomous scan is running). - bssType - Type of BSS to scan for - scanType - Type of scan to perform - channelListCount - Number of channels provided. - If it is 0, the SME will initiate a scan of all the - supported channels that are permitted by the current - regulatory domain. - channelList - Points to the first channel , or NULL if channelListCount - is zero. - probeIeLength - Length of the information element in bytes to be sent - with the probe message. - probeIe - Points to the first byte of the information element to be - sent with the probe message. - -*******************************************************************************/ -#define CsrWifiSmeScanFullReqCreate(msg__, dst__, src__, ssidCount__, ssid__, bssid__, forceScan__, bssType__, scanType__, channelListCount__, channelList__, probeIeLength__, probeIe__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeScanFullReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_SCAN_FULL_REQ, dst__, src__); \ - msg__->ssidCount = (ssidCount__); \ - msg__->ssid = (ssid__); \ - msg__->bssid = (bssid__); \ - msg__->forceScan = (forceScan__); \ - msg__->bssType = (bssType__); \ - msg__->scanType = (scanType__); \ - msg__->channelListCount = (channelListCount__); \ - msg__->channelList = (channelList__); \ - msg__->probeIeLength = (probeIeLength__); \ - msg__->probeIe = (probeIe__); - -#define CsrWifiSmeScanFullReqSendTo(dst__, src__, ssidCount__, ssid__, bssid__, forceScan__, bssType__, scanType__, channelListCount__, channelList__, probeIeLength__, probeIe__) \ - { \ - CsrWifiSmeScanFullReq *msg__; \ - CsrWifiSmeScanFullReqCreate(msg__, dst__, src__, ssidCount__, ssid__, bssid__, forceScan__, bssType__, scanType__, channelListCount__, channelList__, probeIeLength__, probeIe__); \ - CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeScanFullReqSend(src__, ssidCount__, ssid__, bssid__, forceScan__, bssType__, scanType__, channelListCount__, channelList__, probeIeLength__, probeIe__) \ - CsrWifiSmeScanFullReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, ssidCount__, ssid__, bssid__, forceScan__, bssType__, scanType__, channelListCount__, channelList__, probeIeLength__, probeIe__) - -/******************************************************************************* - - NAME - CsrWifiSmeScanFullCfmSend - - DESCRIPTION - The SME calls this primitive when the results from the scan are - available. - - PARAMETERS - queue - Destination Task Queue - status - Reports the result of the request - -*******************************************************************************/ -#define CsrWifiSmeScanFullCfmCreate(msg__, dst__, src__, status__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeScanFullCfm), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_SCAN_FULL_CFM, dst__, src__); \ - msg__->status = (status__); - -#define CsrWifiSmeScanFullCfmSendTo(dst__, src__, status__) \ - { \ - CsrWifiSmeScanFullCfm *msg__; \ - CsrWifiSmeScanFullCfmCreate(msg__, dst__, src__, status__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeScanFullCfmSend(dst__, status__) \ - CsrWifiSmeScanFullCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__) - -/******************************************************************************* - - NAME - CsrWifiSmeScanResultIndSend - - DESCRIPTION - The SME sends this primitive to all the tasks that have registered to - receive it whenever a scan indication is received from the firmware. - - PARAMETERS - queue - Destination Task Queue - result - Points to a buffer containing a scan result. - -*******************************************************************************/ -#define CsrWifiSmeScanResultIndCreate(msg__, dst__, src__, result__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeScanResultInd), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_SCAN_RESULT_IND, dst__, src__); \ - msg__->result = (result__); - -#define CsrWifiSmeScanResultIndSendTo(dst__, src__, result__) \ - { \ - CsrWifiSmeScanResultInd *msg__; \ - CsrWifiSmeScanResultIndCreate(msg__, dst__, src__, result__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeScanResultIndSend(dst__, result__) \ - CsrWifiSmeScanResultIndSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, result__) - -/******************************************************************************* - - NAME - CsrWifiSmeScanResultsFlushReqSend - - DESCRIPTION - The Wireless Manager calls this primitive to ask the SME to delete all - scan results from its cache, except for the scan result of any currently - connected network. - As scan results are received by the SME from the firmware, they are - cached in the SME memory. - Any time the Wireless Manager requests scan results, they are returned - from the SME internal cache. - For some applications it may be desirable to clear this cache prior to - requesting that a scan be performed; this will ensure that the cache then - only contains the networks detected in the most recent scan. - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - -*******************************************************************************/ -#define CsrWifiSmeScanResultsFlushReqCreate(msg__, dst__, src__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeScanResultsFlushReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_SCAN_RESULTS_FLUSH_REQ, dst__, src__); - -#define CsrWifiSmeScanResultsFlushReqSendTo(dst__, src__) \ - { \ - CsrWifiSmeScanResultsFlushReq *msg__; \ - CsrWifiSmeScanResultsFlushReqCreate(msg__, dst__, src__); \ - CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeScanResultsFlushReqSend(src__) \ - CsrWifiSmeScanResultsFlushReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__) - -/******************************************************************************* - - NAME - CsrWifiSmeScanResultsFlushCfmSend - - DESCRIPTION - The SME will call this primitive when the cache has been cleared. - - PARAMETERS - queue - Destination Task Queue - status - Reports the result of the request - -*******************************************************************************/ -#define CsrWifiSmeScanResultsFlushCfmCreate(msg__, dst__, src__, status__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeScanResultsFlushCfm), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_SCAN_RESULTS_FLUSH_CFM, dst__, src__); \ - msg__->status = (status__); - -#define CsrWifiSmeScanResultsFlushCfmSendTo(dst__, src__, status__) \ - { \ - CsrWifiSmeScanResultsFlushCfm *msg__; \ - CsrWifiSmeScanResultsFlushCfmCreate(msg__, dst__, src__, status__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeScanResultsFlushCfmSend(dst__, status__) \ - CsrWifiSmeScanResultsFlushCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__) - -/******************************************************************************* - - NAME - CsrWifiSmeScanResultsGetReqSend - - DESCRIPTION - The wireless manager application calls this primitive to retrieve the - current set of scan results, either after receiving a successful - CSR_WIFI_SME_SCAN_FULL_CFM, or to get autonomous scan results. - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - -*******************************************************************************/ -#define CsrWifiSmeScanResultsGetReqCreate(msg__, dst__, src__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeScanResultsGetReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_SCAN_RESULTS_GET_REQ, dst__, src__); - -#define CsrWifiSmeScanResultsGetReqSendTo(dst__, src__) \ - { \ - CsrWifiSmeScanResultsGetReq *msg__; \ - CsrWifiSmeScanResultsGetReqCreate(msg__, dst__, src__); \ - CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeScanResultsGetReqSend(src__) \ - CsrWifiSmeScanResultsGetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__) - -/******************************************************************************* - - NAME - CsrWifiSmeScanResultsGetCfmSend - - DESCRIPTION - The SME sends this primitive to provide the current set of scan results. - - PARAMETERS - queue - Destination Task Queue - status - Reports the result of the request - scanResultsCount - Number of scan results - scanResults - Points to a buffer containing an array of - CsrWifiSmeScanResult structures. - -*******************************************************************************/ -#define CsrWifiSmeScanResultsGetCfmCreate(msg__, dst__, src__, status__, scanResultsCount__, scanResults__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeScanResultsGetCfm), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_SCAN_RESULTS_GET_CFM, dst__, src__); \ - msg__->status = (status__); \ - msg__->scanResultsCount = (scanResultsCount__); \ - msg__->scanResults = (scanResults__); - -#define CsrWifiSmeScanResultsGetCfmSendTo(dst__, src__, status__, scanResultsCount__, scanResults__) \ - { \ - CsrWifiSmeScanResultsGetCfm *msg__; \ - CsrWifiSmeScanResultsGetCfmCreate(msg__, dst__, src__, status__, scanResultsCount__, scanResults__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeScanResultsGetCfmSend(dst__, status__, scanResultsCount__, scanResults__) \ - CsrWifiSmeScanResultsGetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__, scanResultsCount__, scanResults__) - -/******************************************************************************* - - NAME - CsrWifiSmeSetReqSend - - DESCRIPTION - Used to pass custom data to the SME. Format is the same as 802.11 Info - Elements => | Id | Length | Data - 1) Cmanr Test Mode "Id:0 Length:1 Data:0x00 = OFF 0x01 = ON" "0x00 0x01 - (0x00|0x01)" - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - dataLength - Number of bytes in the buffer pointed to by 'data' - data - Pointer to the buffer containing 'dataLength' bytes - -*******************************************************************************/ -#define CsrWifiSmeSetReqCreate(msg__, dst__, src__, dataLength__, data__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeSetReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_SET_REQ, dst__, src__); \ - msg__->dataLength = (dataLength__); \ - msg__->data = (data__); - -#define CsrWifiSmeSetReqSendTo(dst__, src__, dataLength__, data__) \ - { \ - CsrWifiSmeSetReq *msg__; \ - CsrWifiSmeSetReqCreate(msg__, dst__, src__, dataLength__, data__); \ - CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeSetReqSend(src__, dataLength__, data__) \ - CsrWifiSmeSetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, dataLength__, data__) - -/******************************************************************************* - - NAME - CsrWifiSmeSmeCommonConfigGetReqSend - - DESCRIPTION - This primitive gets the value of the Sme common parameter. - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - -*******************************************************************************/ -#define CsrWifiSmeSmeCommonConfigGetReqCreate(msg__, dst__, src__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeSmeCommonConfigGetReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_SME_COMMON_CONFIG_GET_REQ, dst__, src__); - -#define CsrWifiSmeSmeCommonConfigGetReqSendTo(dst__, src__) \ - { \ - CsrWifiSmeSmeCommonConfigGetReq *msg__; \ - CsrWifiSmeSmeCommonConfigGetReqCreate(msg__, dst__, src__); \ - CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeSmeCommonConfigGetReqSend(src__) \ - CsrWifiSmeSmeCommonConfigGetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__) - -/******************************************************************************* - - NAME - CsrWifiSmeSmeCommonConfigGetCfmSend - - DESCRIPTION - This primitive reports the result of the request. - - PARAMETERS - queue - Destination Task Queue - status - Reports the result of the request - deviceConfig - Configuration options in the SME - -*******************************************************************************/ -#define CsrWifiSmeSmeCommonConfigGetCfmCreate(msg__, dst__, src__, status__, deviceConfig__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeSmeCommonConfigGetCfm), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_SME_COMMON_CONFIG_GET_CFM, dst__, src__); \ - msg__->status = (status__); \ - msg__->deviceConfig = (deviceConfig__); - -#define CsrWifiSmeSmeCommonConfigGetCfmSendTo(dst__, src__, status__, deviceConfig__) \ - { \ - CsrWifiSmeSmeCommonConfigGetCfm *msg__; \ - CsrWifiSmeSmeCommonConfigGetCfmCreate(msg__, dst__, src__, status__, deviceConfig__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeSmeCommonConfigGetCfmSend(dst__, status__, deviceConfig__) \ - CsrWifiSmeSmeCommonConfigGetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__, deviceConfig__) - -/******************************************************************************* - - NAME - CsrWifiSmeSmeCommonConfigSetReqSend - - DESCRIPTION - This primitive sets the value of the Sme common. - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - deviceConfig - Configuration options in the SME - -*******************************************************************************/ -#define CsrWifiSmeSmeCommonConfigSetReqCreate(msg__, dst__, src__, deviceConfig__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeSmeCommonConfigSetReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_SME_COMMON_CONFIG_SET_REQ, dst__, src__); \ - msg__->deviceConfig = (deviceConfig__); - -#define CsrWifiSmeSmeCommonConfigSetReqSendTo(dst__, src__, deviceConfig__) \ - { \ - CsrWifiSmeSmeCommonConfigSetReq *msg__; \ - CsrWifiSmeSmeCommonConfigSetReqCreate(msg__, dst__, src__, deviceConfig__); \ - CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeSmeCommonConfigSetReqSend(src__, deviceConfig__) \ - CsrWifiSmeSmeCommonConfigSetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, deviceConfig__) - -/******************************************************************************* - - NAME - CsrWifiSmeSmeCommonConfigSetCfmSend - - DESCRIPTION - Reports the result of the request - - PARAMETERS - queue - Destination Task Queue - status - Reports the result of the request - -*******************************************************************************/ -#define CsrWifiSmeSmeCommonConfigSetCfmCreate(msg__, dst__, src__, status__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeSmeCommonConfigSetCfm), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_SME_COMMON_CONFIG_SET_CFM, dst__, src__); \ - msg__->status = (status__); - -#define CsrWifiSmeSmeCommonConfigSetCfmSendTo(dst__, src__, status__) \ - { \ - CsrWifiSmeSmeCommonConfigSetCfm *msg__; \ - CsrWifiSmeSmeCommonConfigSetCfmCreate(msg__, dst__, src__, status__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeSmeCommonConfigSetCfmSend(dst__, status__) \ - CsrWifiSmeSmeCommonConfigSetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__) - -/******************************************************************************* - - NAME - CsrWifiSmeSmeStaConfigGetReqSend - - DESCRIPTION - This primitive gets the value of the SmeStaConfig parameter. - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - interfaceTag - Interface Identifier; unique identifier of an interface - -*******************************************************************************/ -#define CsrWifiSmeSmeStaConfigGetReqCreate(msg__, dst__, src__, interfaceTag__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeSmeStaConfigGetReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_SME_STA_CONFIG_GET_REQ, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); - -#define CsrWifiSmeSmeStaConfigGetReqSendTo(dst__, src__, interfaceTag__) \ - { \ - CsrWifiSmeSmeStaConfigGetReq *msg__; \ - CsrWifiSmeSmeStaConfigGetReqCreate(msg__, dst__, src__, interfaceTag__); \ - CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeSmeStaConfigGetReqSend(src__, interfaceTag__) \ - CsrWifiSmeSmeStaConfigGetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, interfaceTag__) - -/******************************************************************************* - - NAME - CsrWifiSmeSmeStaConfigGetCfmSend - - DESCRIPTION - This primitive reports the result of the request. - - PARAMETERS - queue - Destination Task Queue - interfaceTag - Interface Identifier; unique identifier of an interface - status - Reports the result of the request - smeConfig - Current SME Station Parameters - -*******************************************************************************/ -#define CsrWifiSmeSmeStaConfigGetCfmCreate(msg__, dst__, src__, interfaceTag__, status__, smeConfig__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeSmeStaConfigGetCfm), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_SME_STA_CONFIG_GET_CFM, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->status = (status__); \ - msg__->smeConfig = (smeConfig__); - -#define CsrWifiSmeSmeStaConfigGetCfmSendTo(dst__, src__, interfaceTag__, status__, smeConfig__) \ - { \ - CsrWifiSmeSmeStaConfigGetCfm *msg__; \ - CsrWifiSmeSmeStaConfigGetCfmCreate(msg__, dst__, src__, interfaceTag__, status__, smeConfig__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeSmeStaConfigGetCfmSend(dst__, interfaceTag__, status__, smeConfig__) \ - CsrWifiSmeSmeStaConfigGetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__, smeConfig__) - -/******************************************************************************* - - NAME - CsrWifiSmeSmeStaConfigSetReqSend - - DESCRIPTION - This primitive sets the value of the SmeConfig parameter. - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - interfaceTag - Interface Identifier; unique identifier of an interface - smeConfig - SME Station Parameters to be set - -*******************************************************************************/ -#define CsrWifiSmeSmeStaConfigSetReqCreate(msg__, dst__, src__, interfaceTag__, smeConfig__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeSmeStaConfigSetReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_SME_STA_CONFIG_SET_REQ, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->smeConfig = (smeConfig__); - -#define CsrWifiSmeSmeStaConfigSetReqSendTo(dst__, src__, interfaceTag__, smeConfig__) \ - { \ - CsrWifiSmeSmeStaConfigSetReq *msg__; \ - CsrWifiSmeSmeStaConfigSetReqCreate(msg__, dst__, src__, interfaceTag__, smeConfig__); \ - CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeSmeStaConfigSetReqSend(src__, interfaceTag__, smeConfig__) \ - CsrWifiSmeSmeStaConfigSetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, interfaceTag__, smeConfig__) - -/******************************************************************************* - - NAME - CsrWifiSmeSmeStaConfigSetCfmSend - - DESCRIPTION - This primitive reports the result of the request. - - PARAMETERS - queue - Destination Task Queue - interfaceTag - Interface Identifier; unique identifier of an interface - status - Reports the result of the request - -*******************************************************************************/ -#define CsrWifiSmeSmeStaConfigSetCfmCreate(msg__, dst__, src__, interfaceTag__, status__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeSmeStaConfigSetCfm), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_SME_STA_CONFIG_SET_CFM, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->status = (status__); - -#define CsrWifiSmeSmeStaConfigSetCfmSendTo(dst__, src__, interfaceTag__, status__) \ - { \ - CsrWifiSmeSmeStaConfigSetCfm *msg__; \ - CsrWifiSmeSmeStaConfigSetCfmCreate(msg__, dst__, src__, interfaceTag__, status__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeSmeStaConfigSetCfmSend(dst__, interfaceTag__, status__) \ - CsrWifiSmeSmeStaConfigSetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__) - -/******************************************************************************* - - NAME - CsrWifiSmeStationMacAddressGetReqSend - - DESCRIPTION - This primitives is used to retrieve the current MAC address used by the - station. - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - -*******************************************************************************/ -#define CsrWifiSmeStationMacAddressGetReqCreate(msg__, dst__, src__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeStationMacAddressGetReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_STATION_MAC_ADDRESS_GET_REQ, dst__, src__); - -#define CsrWifiSmeStationMacAddressGetReqSendTo(dst__, src__) \ - { \ - CsrWifiSmeStationMacAddressGetReq *msg__; \ - CsrWifiSmeStationMacAddressGetReqCreate(msg__, dst__, src__); \ - CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeStationMacAddressGetReqSend(src__) \ - CsrWifiSmeStationMacAddressGetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__) - -/******************************************************************************* - - NAME - CsrWifiSmeStationMacAddressGetCfmSend - - DESCRIPTION - This primitive reports the result of the request. - - PARAMETERS - queue - Destination Task Queue - status - Reports the result of the request - stationMacAddress - Current MAC address of the station. - -*******************************************************************************/ -#define CsrWifiSmeStationMacAddressGetCfmCreate(msg__, dst__, src__, status__, stationMacAddress__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeStationMacAddressGetCfm), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_STATION_MAC_ADDRESS_GET_CFM, dst__, src__); \ - msg__->status = (status__); \ - memcpy(msg__->stationMacAddress, (stationMacAddress__), sizeof(CsrWifiMacAddress) * 2); - -#define CsrWifiSmeStationMacAddressGetCfmSendTo(dst__, src__, status__, stationMacAddress__) \ - { \ - CsrWifiSmeStationMacAddressGetCfm *msg__; \ - CsrWifiSmeStationMacAddressGetCfmCreate(msg__, dst__, src__, status__, stationMacAddress__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeStationMacAddressGetCfmSend(dst__, status__, stationMacAddress__) \ - CsrWifiSmeStationMacAddressGetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__, stationMacAddress__) - -/******************************************************************************* - - NAME - CsrWifiSmeTspecReqSend - - DESCRIPTION - The wireless manager application should call this primitive to use the - TSPEC feature. - The chip supports the use of TSPECs and TCLAS for the use of IEEE - 802.11/WMM Quality of Service features. - The API allows the wireless manager application to supply a correctly - formatted TSPEC and TCLAS pair to the driver. - After performing basic validation, the driver negotiates the installation - of the TSPEC with the AP as defined by the 802.11 specification. - The driver retains all TSPEC and TCLAS pairs until they are specifically - removed. - It is not compulsory for a TSPEC to have a TCLAS (NULL is used to - indicate that no TCLAS is supplied), while a TCLASS always require a - TSPEC. - The format of the TSPEC element is specified in 'WMM (including WMM Power - Save) Specification - Version 1.1' and 'ANSI/IEEE Std 802.11-REVmb/D3.0'. - For more information, see 'UniFi Configuring WMM and WMM-PS'. - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - interfaceTag - Interface Identifier; unique identifier of an interface - action - Specifies the action to be carried out on the list of TSPECs. - CSR_WIFI_SME_LIST_ACTION_FLUSH is not applicable here. - transactionId - Unique Transaction ID for the TSPEC, as assigned by the - driver - strict - If it set to false, allows the SME to perform automatic - TSPEC negotiation - ctrlMask - Additional TSPEC configuration for CCX. - Set mask with values from CsrWifiSmeTspecCtrl. - CURRENTLY NOT SUPPORTED - tspecLength - Length of the TSPEC. - tspec - Points to the first byte of the TSPEC - tclasLength - Length of the TCLAS. - If it is equal to 0, no TCLASS is provided for the TSPEC - tclas - Points to the first byte of the TCLAS, if any. - -*******************************************************************************/ -#define CsrWifiSmeTspecReqCreate(msg__, dst__, src__, interfaceTag__, action__, transactionId__, strict__, ctrlMask__, tspecLength__, tspec__, tclasLength__, tclas__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeTspecReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_TSPEC_REQ, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->action = (action__); \ - msg__->transactionId = (transactionId__); \ - msg__->strict = (strict__); \ - msg__->ctrlMask = (ctrlMask__); \ - msg__->tspecLength = (tspecLength__); \ - msg__->tspec = (tspec__); \ - msg__->tclasLength = (tclasLength__); \ - msg__->tclas = (tclas__); - -#define CsrWifiSmeTspecReqSendTo(dst__, src__, interfaceTag__, action__, transactionId__, strict__, ctrlMask__, tspecLength__, tspec__, tclasLength__, tclas__) \ - { \ - CsrWifiSmeTspecReq *msg__; \ - CsrWifiSmeTspecReqCreate(msg__, dst__, src__, interfaceTag__, action__, transactionId__, strict__, ctrlMask__, tspecLength__, tspec__, tclasLength__, tclas__); \ - CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeTspecReqSend(src__, interfaceTag__, action__, transactionId__, strict__, ctrlMask__, tspecLength__, tspec__, tclasLength__, tclas__) \ - CsrWifiSmeTspecReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, interfaceTag__, action__, transactionId__, strict__, ctrlMask__, tspecLength__, tspec__, tclasLength__, tclas__) - -/******************************************************************************* - - NAME - CsrWifiSmeTspecIndSend - - DESCRIPTION - The SME will send this primitive to all the task that have registered to - receive it when a status change in the TSPEC occurs. - - PARAMETERS - queue - Destination Task Queue - interfaceTag - Interface Identifier; unique identifier of an interface - transactionId - Unique Transaction ID for the TSPEC, as assigned by the - driver - tspecResultCode - Specifies the TSPEC operation requested by the peer - station - tspecLength - Length of the TSPEC. - tspec - Points to the first byte of the TSPEC - -*******************************************************************************/ -#define CsrWifiSmeTspecIndCreate(msg__, dst__, src__, interfaceTag__, transactionId__, tspecResultCode__, tspecLength__, tspec__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeTspecInd), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_TSPEC_IND, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->transactionId = (transactionId__); \ - msg__->tspecResultCode = (tspecResultCode__); \ - msg__->tspecLength = (tspecLength__); \ - msg__->tspec = (tspec__); - -#define CsrWifiSmeTspecIndSendTo(dst__, src__, interfaceTag__, transactionId__, tspecResultCode__, tspecLength__, tspec__) \ - { \ - CsrWifiSmeTspecInd *msg__; \ - CsrWifiSmeTspecIndCreate(msg__, dst__, src__, interfaceTag__, transactionId__, tspecResultCode__, tspecLength__, tspec__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeTspecIndSend(dst__, interfaceTag__, transactionId__, tspecResultCode__, tspecLength__, tspec__) \ - CsrWifiSmeTspecIndSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, transactionId__, tspecResultCode__, tspecLength__, tspec__) - -/******************************************************************************* - - NAME - CsrWifiSmeTspecCfmSend - - DESCRIPTION - The SME calls the primitive to report the result of the TSpec primitive - request. - - PARAMETERS - queue - Destination Task Queue - interfaceTag - Interface Identifier; unique identifier of an interface - status - Reports the result of the request - transactionId - Unique Transaction ID for the TSPEC, as assigned by the - driver - tspecResultCode - Specifies the result of the negotiated TSPEC operation - tspecLength - Length of the TSPEC. - tspec - Points to the first byte of the TSPEC - -*******************************************************************************/ -#define CsrWifiSmeTspecCfmCreate(msg__, dst__, src__, interfaceTag__, status__, transactionId__, tspecResultCode__, tspecLength__, tspec__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeTspecCfm), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_TSPEC_CFM, dst__, src__); \ - msg__->interfaceTag = (interfaceTag__); \ - msg__->status = (status__); \ - msg__->transactionId = (transactionId__); \ - msg__->tspecResultCode = (tspecResultCode__); \ - msg__->tspecLength = (tspecLength__); \ - msg__->tspec = (tspec__); - -#define CsrWifiSmeTspecCfmSendTo(dst__, src__, interfaceTag__, status__, transactionId__, tspecResultCode__, tspecLength__, tspec__) \ - { \ - CsrWifiSmeTspecCfm *msg__; \ - CsrWifiSmeTspecCfmCreate(msg__, dst__, src__, interfaceTag__, status__, transactionId__, tspecResultCode__, tspecLength__, tspec__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeTspecCfmSend(dst__, interfaceTag__, status__, transactionId__, tspecResultCode__, tspecLength__, tspec__) \ - CsrWifiSmeTspecCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__, transactionId__, tspecResultCode__, tspecLength__, tspec__) - -/******************************************************************************* - - NAME - CsrWifiSmeVersionsGetReqSend - - DESCRIPTION - This primitive gets the value of the Versions parameter. - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - -*******************************************************************************/ -#define CsrWifiSmeVersionsGetReqCreate(msg__, dst__, src__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeVersionsGetReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_VERSIONS_GET_REQ, dst__, src__); - -#define CsrWifiSmeVersionsGetReqSendTo(dst__, src__) \ - { \ - CsrWifiSmeVersionsGetReq *msg__; \ - CsrWifiSmeVersionsGetReqCreate(msg__, dst__, src__); \ - CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeVersionsGetReqSend(src__) \ - CsrWifiSmeVersionsGetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__) - -/******************************************************************************* - - NAME - CsrWifiSmeVersionsGetCfmSend - - DESCRIPTION - This primitive reports the result of the request. - - PARAMETERS - queue - Destination Task Queue - status - Reports the result of the request - versions - Version IDs of the product - -*******************************************************************************/ -#define CsrWifiSmeVersionsGetCfmCreate(msg__, dst__, src__, status__, versions__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeVersionsGetCfm), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_VERSIONS_GET_CFM, dst__, src__); \ - msg__->status = (status__); \ - msg__->versions = (versions__); - -#define CsrWifiSmeVersionsGetCfmSendTo(dst__, src__, status__, versions__) \ - { \ - CsrWifiSmeVersionsGetCfm *msg__; \ - CsrWifiSmeVersionsGetCfmCreate(msg__, dst__, src__, status__, versions__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeVersionsGetCfmSend(dst__, status__, versions__) \ - CsrWifiSmeVersionsGetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__, versions__) - -/******************************************************************************* - - NAME - CsrWifiSmeWifiFlightmodeReqSend - - DESCRIPTION - The wireless manager application may call this primitive on boot-up of - the platform to ensure that the chip is placed in a mode that prevents - any emission of RF energy. - This primitive is an alternative to CSR_WIFI_SME_WIFI_ON_REQ. - As in CSR_WIFI_SME_WIFI_ON_REQ, it causes the download of the patch file - (if any) and the programming of the initial MIB settings (if supplied by - the WMA), but it also ensures that the chip is left in its lowest - possible power-mode with the radio subsystems disabled. - This feature is useful on platforms where power cannot be removed from - the chip (leaving the chip not initialised will cause it to consume more - power so calling this function ensures that the chip is initialised into - a low power mode but without entering a state where it could emit any RF - energy). - NOTE: this primitive does not cause the Wi-Fi to change state: Wi-Fi - stays conceptually off. Configuration primitives can be sent after - CSR_WIFI_SME_WIFI_FLIGHTMODE_REQ and the configuration will be maintained. - Requests that require the state of the Wi-Fi to be ON will return - CSR_WIFI_SME_STATUS_WIFI_OFF in their confirms. - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - address - Optionally specifies a station MAC address. - In normal use, the manager should set the address to 0xFF - 0xFF 0xFF 0xFF 0xFF 0xFF, which will cause the chip to use - the MAC address in the MIB. - mibFilesCount - Number of provided data blocks with initial MIB values - mibFiles - Points to the first data block with initial MIB values. - These data blocks are typically the contents of the provided - files ufmib.dat and localmib.dat, available from the host - file system, if they exist. - These files typically contain radio tuning and calibration - values. - More values can be created using the Host Tools. - -*******************************************************************************/ -#define CsrWifiSmeWifiFlightmodeReqCreate(msg__, dst__, src__, address__, mibFilesCount__, mibFiles__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeWifiFlightmodeReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_WIFI_FLIGHTMODE_REQ, dst__, src__); \ - msg__->address = (address__); \ - msg__->mibFilesCount = (mibFilesCount__); \ - msg__->mibFiles = (mibFiles__); - -#define CsrWifiSmeWifiFlightmodeReqSendTo(dst__, src__, address__, mibFilesCount__, mibFiles__) \ - { \ - CsrWifiSmeWifiFlightmodeReq *msg__; \ - CsrWifiSmeWifiFlightmodeReqCreate(msg__, dst__, src__, address__, mibFilesCount__, mibFiles__); \ - CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeWifiFlightmodeReqSend(src__, address__, mibFilesCount__, mibFiles__) \ - CsrWifiSmeWifiFlightmodeReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, address__, mibFilesCount__, mibFiles__) - -/******************************************************************************* - - NAME - CsrWifiSmeWifiFlightmodeCfmSend - - DESCRIPTION - The SME calls this primitive when the chip is initialised for low power - mode and with the radio subsystem disabled. To leave flight mode, and - enable Wi-Fi, the wireless manager application should call - CSR_WIFI_SME_WIFI_ON_REQ. - - PARAMETERS - queue - Destination Task Queue - status - Reports the result of the request - -*******************************************************************************/ -#define CsrWifiSmeWifiFlightmodeCfmCreate(msg__, dst__, src__, status__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeWifiFlightmodeCfm), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_WIFI_FLIGHTMODE_CFM, dst__, src__); \ - msg__->status = (status__); - -#define CsrWifiSmeWifiFlightmodeCfmSendTo(dst__, src__, status__) \ - { \ - CsrWifiSmeWifiFlightmodeCfm *msg__; \ - CsrWifiSmeWifiFlightmodeCfmCreate(msg__, dst__, src__, status__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeWifiFlightmodeCfmSend(dst__, status__) \ - CsrWifiSmeWifiFlightmodeCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__) - -/******************************************************************************* - - NAME - CsrWifiSmeWifiOffReqSend - - DESCRIPTION - The wireless manager application calls this primitive to turn off the - chip, thus saving power when Wi-Fi is not in use. - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - -*******************************************************************************/ -#define CsrWifiSmeWifiOffReqCreate(msg__, dst__, src__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeWifiOffReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_WIFI_OFF_REQ, dst__, src__); - -#define CsrWifiSmeWifiOffReqSendTo(dst__, src__) \ - { \ - CsrWifiSmeWifiOffReq *msg__; \ - CsrWifiSmeWifiOffReqCreate(msg__, dst__, src__); \ - CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeWifiOffReqSend(src__) \ - CsrWifiSmeWifiOffReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__) - -/******************************************************************************* - - NAME - CsrWifiSmeWifiOffIndSend - - DESCRIPTION - The SME sends this primitive to all the tasks that have registered to - receive it to report that the chip has been turned off. - - PARAMETERS - queue - Destination Task Queue - reason - Indicates the reason why the Wi-Fi has been switched off. - -*******************************************************************************/ -#define CsrWifiSmeWifiOffIndCreate(msg__, dst__, src__, reason__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeWifiOffInd), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_WIFI_OFF_IND, dst__, src__); \ - msg__->reason = (reason__); - -#define CsrWifiSmeWifiOffIndSendTo(dst__, src__, reason__) \ - { \ - CsrWifiSmeWifiOffInd *msg__; \ - CsrWifiSmeWifiOffIndCreate(msg__, dst__, src__, reason__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeWifiOffIndSend(dst__, reason__) \ - CsrWifiSmeWifiOffIndSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, reason__) - -/******************************************************************************* - - NAME - CsrWifiSmeWifiOffCfmSend - - DESCRIPTION - After receiving CSR_WIFI_SME_WIFI_OFF_REQ, if the chip is connected to a - network, the SME will perform a disconnect operation, will send a - CSR_WIFI_SME_MEDIA_STATUS_IND with - CSR_WIFI_SME_MEDIA_STATUS_DISCONNECTED, and then will call - CSR_WIFI_SME_WIFI_OFF_CFM when the chip is off. - - PARAMETERS - queue - Destination Task Queue - status - Reports the result of the request - -*******************************************************************************/ -#define CsrWifiSmeWifiOffCfmCreate(msg__, dst__, src__, status__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeWifiOffCfm), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_WIFI_OFF_CFM, dst__, src__); \ - msg__->status = (status__); - -#define CsrWifiSmeWifiOffCfmSendTo(dst__, src__, status__) \ - { \ - CsrWifiSmeWifiOffCfm *msg__; \ - CsrWifiSmeWifiOffCfmCreate(msg__, dst__, src__, status__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeWifiOffCfmSend(dst__, status__) \ - CsrWifiSmeWifiOffCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__) - -/******************************************************************************* - - NAME - CsrWifiSmeWifiOnReqSend - - DESCRIPTION - The wireless manager application calls this primitive to turn on the - Wi-Fi chip. - If the Wi-Fi chip is currently off, the SME turns the Wi-Fi chip on, - downloads the patch file (if any), and programs the initial MIB settings - (if supplied by the WMA). - The patch file is not provided with the SME API; its downloading is - automatic and handled internally by the system. - The MIB settings, when provided, override the default values that the - firmware loads from EEPROM. - If the Wi-Fi chip is already on, the SME takes no action and returns a - successful status in the confirm. - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - address - Optionally specifies a station MAC address. - In normal use, the manager should set the address to 0xFF - 0xFF 0xFF 0xFF 0xFF 0xFF, which will cause the chip to use - the MAC address in the MIB - mibFilesCount - Number of provided data blocks with initial MIB values - mibFiles - Points to the first data block with initial MIB values. - These data blocks are typically the contents of the provided - files ufmib.dat and localmib.dat, available from the host - file system, if they exist. - These files typically contain radio tuning and calibration - values. - More values can be created using the Host Tools. - -*******************************************************************************/ -#define CsrWifiSmeWifiOnReqCreate(msg__, dst__, src__, address__, mibFilesCount__, mibFiles__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeWifiOnReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_WIFI_ON_REQ, dst__, src__); \ - msg__->address = (address__); \ - msg__->mibFilesCount = (mibFilesCount__); \ - msg__->mibFiles = (mibFiles__); - -#define CsrWifiSmeWifiOnReqSendTo(dst__, src__, address__, mibFilesCount__, mibFiles__) \ - { \ - CsrWifiSmeWifiOnReq *msg__; \ - CsrWifiSmeWifiOnReqCreate(msg__, dst__, src__, address__, mibFilesCount__, mibFiles__); \ - CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeWifiOnReqSend(src__, address__, mibFilesCount__, mibFiles__) \ - CsrWifiSmeWifiOnReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, address__, mibFilesCount__, mibFiles__) - -/******************************************************************************* - - NAME - CsrWifiSmeWifiOnIndSend - - DESCRIPTION - The SME sends this primitive to all tasks that have registered to receive - it once the chip becomes available and ready to use. - - PARAMETERS - queue - Destination Task Queue - address - Current MAC address - -*******************************************************************************/ -#define CsrWifiSmeWifiOnIndCreate(msg__, dst__, src__, address__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeWifiOnInd), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_WIFI_ON_IND, dst__, src__); \ - msg__->address = (address__); - -#define CsrWifiSmeWifiOnIndSendTo(dst__, src__, address__) \ - { \ - CsrWifiSmeWifiOnInd *msg__; \ - CsrWifiSmeWifiOnIndCreate(msg__, dst__, src__, address__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeWifiOnIndSend(dst__, address__) \ - CsrWifiSmeWifiOnIndSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, address__) - -/******************************************************************************* - - NAME - CsrWifiSmeWifiOnCfmSend - - DESCRIPTION - The SME sends this primitive to the task that has sent the request once - the chip has been initialised and is available for use. - - PARAMETERS - queue - Destination Task Queue - status - Reports the result of the request - -*******************************************************************************/ -#define CsrWifiSmeWifiOnCfmCreate(msg__, dst__, src__, status__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeWifiOnCfm), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_WIFI_ON_CFM, dst__, src__); \ - msg__->status = (status__); - -#define CsrWifiSmeWifiOnCfmSendTo(dst__, src__, status__) \ - { \ - CsrWifiSmeWifiOnCfm *msg__; \ - CsrWifiSmeWifiOnCfmCreate(msg__, dst__, src__, status__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeWifiOnCfmSend(dst__, status__) \ - CsrWifiSmeWifiOnCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__) - -/******************************************************************************* - - NAME - CsrWifiSmeWpsConfigurationReqSend - - DESCRIPTION - This primitive passes the WPS information for the device to SME. This may - be accepted only if no interface is active. - - PARAMETERS - queue - Message Source Task Queue (Cfm's will be sent to this Queue) - wpsConfig - WPS config. - -*******************************************************************************/ -#define CsrWifiSmeWpsConfigurationReqCreate(msg__, dst__, src__, wpsConfig__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeWpsConfigurationReq), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_WPS_CONFIGURATION_REQ, dst__, src__); \ - msg__->wpsConfig = (wpsConfig__); - -#define CsrWifiSmeWpsConfigurationReqSendTo(dst__, src__, wpsConfig__) \ - { \ - CsrWifiSmeWpsConfigurationReq *msg__; \ - CsrWifiSmeWpsConfigurationReqCreate(msg__, dst__, src__, wpsConfig__); \ - CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeWpsConfigurationReqSend(src__, wpsConfig__) \ - CsrWifiSmeWpsConfigurationReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, wpsConfig__) - -/******************************************************************************* - - NAME - CsrWifiSmeWpsConfigurationCfmSend - - DESCRIPTION - Confirm. - - PARAMETERS - queue - Destination Task Queue - status - Status of the request. - -*******************************************************************************/ -#define CsrWifiSmeWpsConfigurationCfmCreate(msg__, dst__, src__, status__) \ - msg__ = kmalloc(sizeof(CsrWifiSmeWpsConfigurationCfm), GFP_KERNEL); \ - CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_WPS_CONFIGURATION_CFM, dst__, src__); \ - msg__->status = (status__); - -#define CsrWifiSmeWpsConfigurationCfmSendTo(dst__, src__, status__) \ - { \ - CsrWifiSmeWpsConfigurationCfm *msg__; \ - CsrWifiSmeWpsConfigurationCfmCreate(msg__, dst__, src__, status__); \ - CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \ - } - -#define CsrWifiSmeWpsConfigurationCfmSend(dst__, status__) \ - CsrWifiSmeWpsConfigurationCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__) - -#endif /* CSR_WIFI_SME_LIB_H__ */ diff --git a/drivers/staging/csr/csr_wifi_sme_prim.h b/drivers/staging/csr/csr_wifi_sme_prim.h deleted file mode 100644 index 17ec79c77e54..000000000000 --- a/drivers/staging/csr/csr_wifi_sme_prim.h +++ /dev/null @@ -1,6510 +0,0 @@ -/***************************************************************************** - - (c) Cambridge Silicon Radio Limited 2012 - All rights reserved and confidential information of CSR - - Refer to LICENSE.txt included with this source for details - on the license terms. - -*****************************************************************************/ - -/* Note: this is an auto-generated file. */ - -#ifndef CSR_WIFI_SME_PRIM_H__ -#define CSR_WIFI_SME_PRIM_H__ - -#include -#include "csr_prim_defs.h" -#include "csr_sched.h" -#include "csr_wifi_common.h" -#include "csr_result.h" -#include "csr_wifi_fsm_event.h" - -#define CSR_WIFI_SME_PRIM (0x0404) - -typedef CsrPrim CsrWifiSmePrim; - - -/******************************************************************************* - - NAME - CsrWifiSme80211NetworkType - - DESCRIPTION - Indicates the physical layer of the network - - VALUES - CSR_WIFI_SME_80211_NETWORK_TYPE_DS - - Direct-sequence spread spectrum - CSR_WIFI_SME_80211_NETWORK_TYPE_OFDM24 - - Orthogonal Frequency Division Multiplexing at 2.4 GHz - CSR_WIFI_SME_80211_NETWORK_TYPE_OFDM5 - - Orthogonal Frequency Division Multiplexing at 5 GHz - CSR_WIFI_SME_80211_NETWORK_TYPE_AUTO - - Automatic - -*******************************************************************************/ -typedef u8 CsrWifiSme80211NetworkType; -#define CSR_WIFI_SME_80211_NETWORK_TYPE_DS ((CsrWifiSme80211NetworkType) 0x00) -#define CSR_WIFI_SME_80211_NETWORK_TYPE_OFDM24 ((CsrWifiSme80211NetworkType) 0x01) -#define CSR_WIFI_SME_80211_NETWORK_TYPE_OFDM5 ((CsrWifiSme80211NetworkType) 0x02) -#define CSR_WIFI_SME_80211_NETWORK_TYPE_AUTO ((CsrWifiSme80211NetworkType) 0x03) - -/******************************************************************************* - - NAME - CsrWifiSme80211PrivacyMode - - DESCRIPTION - Bits to enable or disable the privacy mode - - VALUES - CSR_WIFI_SME_80211_PRIVACY_MODE_DISABLED - - Privacy mode is enabled: use of WEP for confidentiality is - required. - CSR_WIFI_SME_80211_PRIVACY_MODE_ENABLED - - Privacy mode is disabled - -*******************************************************************************/ -typedef u8 CsrWifiSme80211PrivacyMode; -#define CSR_WIFI_SME_80211_PRIVACY_MODE_DISABLED ((CsrWifiSme80211PrivacyMode) 0x00) -#define CSR_WIFI_SME_80211_PRIVACY_MODE_ENABLED ((CsrWifiSme80211PrivacyMode) 0x01) - -/******************************************************************************* - - NAME - CsrWifiSme80211dTrustLevel - - DESCRIPTION - Level of trust for the information coming from the network - - VALUES - CSR_WIFI_SME_80211D_TRUST_LEVEL_STRICT - - Start with passive scanning and only accept country IE for - updating channel lists - CSR_WIFI_SME_80211D_TRUST_LEVEL_ADJUNCT - - As above plus accept adjunct technology location - information - CSR_WIFI_SME_80211D_TRUST_LEVEL_BSS - - As above accept plus receiving channel from infrastructure - networks - CSR_WIFI_SME_80211D_TRUST_LEVEL_IBSS - - As above accept plus receiving channel from the ad hoc - networks - CSR_WIFI_SME_80211D_TRUST_LEVEL_MIB - - Start with active scanning with list of active channels - from the MIB and accept as above - CSR_WIFI_SME_80211D_TRUST_LEVEL_DISABLED - - Start with active scanning with list of active channels - from the MIB and ignore any channel information from the - network - -*******************************************************************************/ -typedef u8 CsrWifiSme80211dTrustLevel; -#define CSR_WIFI_SME_80211D_TRUST_LEVEL_STRICT ((CsrWifiSme80211dTrustLevel) 0x01) -#define CSR_WIFI_SME_80211D_TRUST_LEVEL_ADJUNCT ((CsrWifiSme80211dTrustLevel) 0x02) -#define CSR_WIFI_SME_80211D_TRUST_LEVEL_BSS ((CsrWifiSme80211dTrustLevel) 0x03) -#define CSR_WIFI_SME_80211D_TRUST_LEVEL_IBSS ((CsrWifiSme80211dTrustLevel) 0x04) -#define CSR_WIFI_SME_80211D_TRUST_LEVEL_MIB ((CsrWifiSme80211dTrustLevel) 0x05) -#define CSR_WIFI_SME_80211D_TRUST_LEVEL_DISABLED ((CsrWifiSme80211dTrustLevel) 0x06) - -/******************************************************************************* - - NAME - CsrWifiSmeAmpStatus - - DESCRIPTION - AMP Current Status - - VALUES - CSR_WIFI_SME_AMP_ACTIVE - AMP ACTIVE. - CSR_WIFI_SME_AMP_INACTIVE - AMP INACTIVE - -*******************************************************************************/ -typedef u8 CsrWifiSmeAmpStatus; -#define CSR_WIFI_SME_AMP_ACTIVE ((CsrWifiSmeAmpStatus) 0x00) -#define CSR_WIFI_SME_AMP_INACTIVE ((CsrWifiSmeAmpStatus) 0x01) - -/******************************************************************************* - - NAME - CsrWifiSmeAuthMode - - DESCRIPTION - Define bits for CsrWifiSmeAuthMode - - VALUES - CSR_WIFI_SME_AUTH_MODE_80211_OPEN - - Connects to an open system network (i.e. no authentication, - no encryption) or to a WEP enabled network. - CSR_WIFI_SME_AUTH_MODE_80211_SHARED - - Connect to a WEP enabled network. - CSR_WIFI_SME_AUTH_MODE_8021X_WPA - - Connects to a WPA Enterprise enabled network. - CSR_WIFI_SME_AUTH_MODE_8021X_WPAPSK - - Connects to a WPA with Pre-Shared Key enabled network. - CSR_WIFI_SME_AUTH_MODE_8021X_WPA2 - - Connects to a WPA2 Enterprise enabled network. - CSR_WIFI_SME_AUTH_MODE_8021X_WPA2PSK - - Connects to a WPA2 with Pre-Shared Key enabled network. - CSR_WIFI_SME_AUTH_MODE_8021X_CCKM - - Connects to a CCKM enabled network. - CSR_WIFI_SME_AUTH_MODE_WAPI_WAI - - Connects to a WAPI Enterprise enabled network. - CSR_WIFI_SME_AUTH_MODE_WAPI_WAIPSK - - Connects to a WAPI with Pre-Shared Key enabled network. - CSR_WIFI_SME_AUTH_MODE_8021X_OTHER1X - - For future use. - -*******************************************************************************/ -typedef u16 CsrWifiSmeAuthMode; -#define CSR_WIFI_SME_AUTH_MODE_80211_OPEN ((CsrWifiSmeAuthMode) 0x0001) -#define CSR_WIFI_SME_AUTH_MODE_80211_SHARED ((CsrWifiSmeAuthMode) 0x0002) -#define CSR_WIFI_SME_AUTH_MODE_8021X_WPA ((CsrWifiSmeAuthMode) 0x0004) -#define CSR_WIFI_SME_AUTH_MODE_8021X_WPAPSK ((CsrWifiSmeAuthMode) 0x0008) -#define CSR_WIFI_SME_AUTH_MODE_8021X_WPA2 ((CsrWifiSmeAuthMode) 0x0010) -#define CSR_WIFI_SME_AUTH_MODE_8021X_WPA2PSK ((CsrWifiSmeAuthMode) 0x0020) -#define CSR_WIFI_SME_AUTH_MODE_8021X_CCKM ((CsrWifiSmeAuthMode) 0x0040) -#define CSR_WIFI_SME_AUTH_MODE_WAPI_WAI ((CsrWifiSmeAuthMode) 0x0080) -#define CSR_WIFI_SME_AUTH_MODE_WAPI_WAIPSK ((CsrWifiSmeAuthMode) 0x0100) -#define CSR_WIFI_SME_AUTH_MODE_8021X_OTHER1X ((CsrWifiSmeAuthMode) 0x0200) - -/******************************************************************************* - - NAME - CsrWifiSmeBasicUsability - - DESCRIPTION - Indicates the usability level of a channel - - VALUES - CSR_WIFI_SME_BASIC_USABILITY_UNUSABLE - - Not usable; connection not recommended - CSR_WIFI_SME_BASIC_USABILITY_POOR - - Poor quality; connect only if nothing better is available - CSR_WIFI_SME_BASIC_USABILITY_SATISFACTORY - - Quality is satisfactory - CSR_WIFI_SME_BASIC_USABILITY_NOT_CONNECTED - - Not connected - -*******************************************************************************/ -typedef u8 CsrWifiSmeBasicUsability; -#define CSR_WIFI_SME_BASIC_USABILITY_UNUSABLE ((CsrWifiSmeBasicUsability) 0x00) -#define CSR_WIFI_SME_BASIC_USABILITY_POOR ((CsrWifiSmeBasicUsability) 0x01) -#define CSR_WIFI_SME_BASIC_USABILITY_SATISFACTORY ((CsrWifiSmeBasicUsability) 0x02) -#define CSR_WIFI_SME_BASIC_USABILITY_NOT_CONNECTED ((CsrWifiSmeBasicUsability) 0x03) - -/******************************************************************************* - - NAME - CsrWifiSmeBssType - - DESCRIPTION - Indicates the BSS type - - VALUES - CSR_WIFI_SME_BSS_TYPE_INFRASTRUCTURE - - Infrastructure BSS. - CSR_WIFI_SME_BSS_TYPE_ADHOC - - Ad hoc or Independent BSS. - CSR_WIFI_SME_BSS_TYPE_ANY_BSS - - Specifies any type of BSS - CSR_WIFI_SME_BSS_TYPE_P2P - - Specifies P2P - -*******************************************************************************/ -typedef u8 CsrWifiSmeBssType; -#define CSR_WIFI_SME_BSS_TYPE_INFRASTRUCTURE ((CsrWifiSmeBssType) 0x00) -#define CSR_WIFI_SME_BSS_TYPE_ADHOC ((CsrWifiSmeBssType) 0x01) -#define CSR_WIFI_SME_BSS_TYPE_ANY_BSS ((CsrWifiSmeBssType) 0x02) -#define CSR_WIFI_SME_BSS_TYPE_P2P ((CsrWifiSmeBssType) 0x03) - -/******************************************************************************* - - NAME - CsrWifiSmeCoexScheme - - DESCRIPTION - Options for the coexistence signalling - Same as MibValues - - VALUES - CSR_WIFI_SME_COEX_SCHEME_DISABLED - - The coexistence signalling is disabled - CSR_WIFI_SME_COEX_SCHEME_CSR - - Basic CSR coexistence signalling - CSR_WIFI_SME_COEX_SCHEME_CSR_CHANNEL - - Full CSR coexistence signalling - CSR_WIFI_SME_COEX_SCHEME_PTA - - Packet Traffic Arbitrator coexistence signalling - -*******************************************************************************/ -typedef u8 CsrWifiSmeCoexScheme; -#define CSR_WIFI_SME_COEX_SCHEME_DISABLED ((CsrWifiSmeCoexScheme) 0x00) -#define CSR_WIFI_SME_COEX_SCHEME_CSR ((CsrWifiSmeCoexScheme) 0x01) -#define CSR_WIFI_SME_COEX_SCHEME_CSR_CHANNEL ((CsrWifiSmeCoexScheme) 0x02) -#define CSR_WIFI_SME_COEX_SCHEME_PTA ((CsrWifiSmeCoexScheme) 0x03) - -/******************************************************************************* - - NAME - CsrWifiSmeControlIndication - - DESCRIPTION - Indicates the reason why the Wi-Fi has been switched off. - The values of this type are used across the NME/SME/Router API's and they - must be kept consistent with the corresponding types in the .xml of the - ottherinterfaces - - VALUES - CSR_WIFI_SME_CONTROL_INDICATION_ERROR - - An unrecoverable error (for example, an unrecoverable SDIO - error) has occurred. - The wireless manager application should reinitialise the - chip by calling CSR_WIFI_SME_WIFI_ON_REQ. - CSR_WIFI_SME_CONTROL_INDICATION_EXIT - - The chip became unavailable due to an external action, for - example, when a plug-in card is ejected or the driver is - unloaded. - CSR_WIFI_SME_CONTROL_INDICATION_USER_REQUESTED - - The Wi-Fi has been switched off as the wireless manager - application has sent CSR_WIFI_SME_WIFI_OFF_REQ - -*******************************************************************************/ -typedef u8 CsrWifiSmeControlIndication; -#define CSR_WIFI_SME_CONTROL_INDICATION_ERROR ((CsrWifiSmeControlIndication) 0x01) -#define CSR_WIFI_SME_CONTROL_INDICATION_EXIT ((CsrWifiSmeControlIndication) 0x02) -#define CSR_WIFI_SME_CONTROL_INDICATION_USER_REQUESTED ((CsrWifiSmeControlIndication) 0x03) - -/******************************************************************************* - - NAME - CsrWifiSmeCtsProtectionType - - DESCRIPTION - SME CTS Protection Types - - VALUES - CSR_WIFI_SME_CTS_PROTECTION_AUTOMATIC - - AP CTS Protection automatic based on non-ERP station in own - BSS or neighbouring BSS on the same channel based on OLBC. - This requires monitoring of beacons from other APs. - CSR_WIFI_SME_CTS_PROTECTION_FORCE_ENABLED - - AP CTS Protection Force enabled - CSR_WIFI_SME_CTS_PROTECTION_FORCE_DISABLED - - AP CTS Protection Force disabled. - CSR_WIFI_SME_CTS_PROTECTION_AUTOMATIC_NO_OLBC - - AP CTS Protection automatic without considering OLBC but - considering non-ERP station in the own BSS Valid only if AP - is configured to work in 802.11bg or 802.11g mode otherwise - this option specifies the same behaviour as AUTOMATIC - -*******************************************************************************/ -typedef u8 CsrWifiSmeCtsProtectionType; -#define CSR_WIFI_SME_CTS_PROTECTION_AUTOMATIC ((CsrWifiSmeCtsProtectionType) 0x00) -#define CSR_WIFI_SME_CTS_PROTECTION_FORCE_ENABLED ((CsrWifiSmeCtsProtectionType) 0x01) -#define CSR_WIFI_SME_CTS_PROTECTION_FORCE_DISABLED ((CsrWifiSmeCtsProtectionType) 0x02) -#define CSR_WIFI_SME_CTS_PROTECTION_AUTOMATIC_NO_OLBC ((CsrWifiSmeCtsProtectionType) 0x03) - -/******************************************************************************* - - NAME - CsrWifiSmeD3AutoScanMode - - DESCRIPTION - Autonomous scan status while in D3 suspended period - - VALUES - CSR_WIFI_SME_D3AUTO_SCAN_MODE_PSON - - Autonomous scan stays on - CSR_WIFI_SME_D3AUTO_SCAN_MODE_PSOFF - - Autonomous scan is switched off - CSR_WIFI_SME_D3AUTO_SCAN_MODE_PSAUTO - - Automatically select autoscanning behaviour. - CURRENTLY NOT SUPPORTED - -*******************************************************************************/ -typedef u8 CsrWifiSmeD3AutoScanMode; -#define CSR_WIFI_SME_D3AUTO_SCAN_MODE_PSON ((CsrWifiSmeD3AutoScanMode) 0x00) -#define CSR_WIFI_SME_D3AUTO_SCAN_MODE_PSOFF ((CsrWifiSmeD3AutoScanMode) 0x01) -#define CSR_WIFI_SME_D3AUTO_SCAN_MODE_PSAUTO ((CsrWifiSmeD3AutoScanMode) 0x02) - -/******************************************************************************* - - NAME - CsrWifiSmeEncryption - - DESCRIPTION - Defines bits for CsrWifiSmeEncryption - For a WEP enabled network, the caller must specify the correct - combination of flags in the encryptionModeMask. - - VALUES - CSR_WIFI_SME_ENCRYPTION_CIPHER_NONE - - No encryption set - CSR_WIFI_SME_ENCRYPTION_CIPHER_PAIRWISE_WEP40 - - Selects 40 byte key WEP for unicast communication - CSR_WIFI_SME_ENCRYPTION_CIPHER_PAIRWISE_WEP104 - - Selects 104 byte key WEP for unicast communication - CSR_WIFI_SME_ENCRYPTION_CIPHER_PAIRWISE_TKIP - - Selects TKIP for unicast communication - CSR_WIFI_SME_ENCRYPTION_CIPHER_PAIRWISE_CCMP - - Selects CCMP for unicast communication - CSR_WIFI_SME_ENCRYPTION_CIPHER_PAIRWISE_SMS4 - - Selects SMS4 for unicast communication - CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_WEP40 - - Selects 40 byte key WEP for broadcast messages - CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_WEP104 - - Selects 104 byte key WEP for broadcast messages - CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_TKIP - - Selects a TKIP for broadcast messages - CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_CCMP - - Selects CCMP for broadcast messages - CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_SMS4 - - Selects SMS4 for broadcast messages - -*******************************************************************************/ -typedef u16 CsrWifiSmeEncryption; -#define CSR_WIFI_SME_ENCRYPTION_CIPHER_NONE ((CsrWifiSmeEncryption) 0x0000) -#define CSR_WIFI_SME_ENCRYPTION_CIPHER_PAIRWISE_WEP40 ((CsrWifiSmeEncryption) 0x0001) -#define CSR_WIFI_SME_ENCRYPTION_CIPHER_PAIRWISE_WEP104 ((CsrWifiSmeEncryption) 0x0002) -#define CSR_WIFI_SME_ENCRYPTION_CIPHER_PAIRWISE_TKIP ((CsrWifiSmeEncryption) 0x0004) -#define CSR_WIFI_SME_ENCRYPTION_CIPHER_PAIRWISE_CCMP ((CsrWifiSmeEncryption) 0x0008) -#define CSR_WIFI_SME_ENCRYPTION_CIPHER_PAIRWISE_SMS4 ((CsrWifiSmeEncryption) 0x0010) -#define CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_WEP40 ((CsrWifiSmeEncryption) 0x0020) -#define CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_WEP104 ((CsrWifiSmeEncryption) 0x0040) -#define CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_TKIP ((CsrWifiSmeEncryption) 0x0080) -#define CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_CCMP ((CsrWifiSmeEncryption) 0x0100) -#define CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_SMS4 ((CsrWifiSmeEncryption) 0x0200) - -/******************************************************************************* - - NAME - CsrWifiSmeFirmwareDriverInterface - - DESCRIPTION - Type of communication between Host and Firmware - - VALUES - CSR_WIFI_SME_FIRMWARE_DRIVER_INTERFACE_UNIT_DATA_INTERFACE - - No preformated header. NOT SUPPORTED in the current release - CSR_WIFI_SME_FIRMWARE_DRIVER_INTERFACE_PACKET_INTERFACE - - Preformated IEEE 802.11 header for user plane - -*******************************************************************************/ -typedef u8 CsrWifiSmeFirmwareDriverInterface; -#define CSR_WIFI_SME_FIRMWARE_DRIVER_INTERFACE_UNIT_DATA_INTERFACE ((CsrWifiSmeFirmwareDriverInterface) 0x00) -#define CSR_WIFI_SME_FIRMWARE_DRIVER_INTERFACE_PACKET_INTERFACE ((CsrWifiSmeFirmwareDriverInterface) 0x01) - -/******************************************************************************* - - NAME - CsrWifiSmeHostPowerMode - - DESCRIPTION - Defines the power mode - - VALUES - CSR_WIFI_SME_HOST_POWER_MODE_ACTIVE - - Host device is running on external power. - CSR_WIFI_SME_HOST_POWER_MODE_POWER_SAVE - - Host device is running on (internal) battery power. - CSR_WIFI_SME_HOST_POWER_MODE_FULL_POWER_SAVE - - For future use. - -*******************************************************************************/ -typedef u8 CsrWifiSmeHostPowerMode; -#define CSR_WIFI_SME_HOST_POWER_MODE_ACTIVE ((CsrWifiSmeHostPowerMode) 0x00) -#define CSR_WIFI_SME_HOST_POWER_MODE_POWER_SAVE ((CsrWifiSmeHostPowerMode) 0x01) -#define CSR_WIFI_SME_HOST_POWER_MODE_FULL_POWER_SAVE ((CsrWifiSmeHostPowerMode) 0x02) - -/******************************************************************************* - - NAME - CsrWifiSmeIEEE80211Reason - - DESCRIPTION - As definined in the IEEE 802.11 standards - - VALUES - CSR_WIFI_SME_IEEE80211_REASON_SUCCESS - - See IEEE 802.11 Standard - CSR_WIFI_SME_IEEE80211_REASON_UNSPECIFIED_REASON - - See IEEE 802.11 Standard - CSR_WIFI_SME_IEEE80211_REASON_AUTHENTICATION_NOT_VALID - - See IEEE 802.11 Standard - CSR_WIFI_SME_IEEE80211_REASON_DEAUTHENTICATED_LEAVE_BSS - - See IEEE 802.11 Standard - CSR_WIFI_SME_IEEE80211_REASON_DISASSOCIATED_INACTIVITY - - See IEEE 802.11 Standard - CSR_WIFI_SME_IEEE80211_REASON_AP_OVERLOAD - - See IEEE 802.11 Standard - CSR_WIFI_SME_IEEE80211_REASON_CLASS_2FRAME_ERROR - - See IEEE 802.11 Standard - CSR_WIFI_SME_IEEE80211_REASON_CLASS_3FRAME_ERROR - - See IEEE 802.11 Standard - CSR_WIFI_SME_IEEE80211_REASON_DISASSOCIATED_LEAVE_BSS - - See IEEE 802.11 Standard - CSR_WIFI_SME_IEEE80211_REASON_ASSOCIATION_NOT_AUTHENTICATED - - See IEEE 802.11 Standard - CSR_WIFI_SME_IEEE80211_REASON_DISASSOCIATED_POWER_CAPABILITY - - See IEEE 802.11 Standard - CSR_WIFI_SME_IEEE80211_REASON_DISASSOCIATED_SUPPORTED_CHANNELS - - See IEEE 802.11 Standard - CSR_WIFI_SME_IEEE80211_REASON_INVALID_INFORMATION_ELEMENT - - See IEEE 802.11 Standard - CSR_WIFI_SME_IEEE80211_REASON_MICHAEL_MIC_FAILURE - - See IEEE 802.11 Standard - CSR_WIFI_SME_IEEE80211_REASON_FOURWAY_HANDSHAKE_TIMEOUT - - See IEEE 802.11 Standard - CSR_WIFI_SME_IEEE80211_REASON_GROUP_KEY_UPDATE_TIMEOUT - - See IEEE 802.11 Standard - CSR_WIFI_SME_IEEE80211_REASON_HANDSHAKE_ELEMENT_DIFFERENT - - See IEEE 802.11 Standard - CSR_WIFI_SME_IEEE80211_REASON_INVALID_GROUP_CIPHER - - See IEEE 802.11 Standard - CSR_WIFI_SME_IEEE80211_REASON_INVALID_PAIRWISE_CIPHER - - See IEEE 802.11 Standard - CSR_WIFI_SME_IEEE80211_REASON_INVALID_AKMP - - See IEEE 802.11 Standard - CSR_WIFI_SME_IEEE80211_REASON_UNSUPPORTED_RSN_IEVERSION - - See IEEE 802.11 Standard - CSR_WIFI_SME_IEEE80211_REASON_INVALID_RSN_IECAPABILITIES - - See IEEE 802.11 Standard - CSR_WIFI_SME_IEEE80211_REASON_DOT1X_AUTH_FAILED - - See IEEE 802.11 Standard - CSR_WIFI_SME_IEEE80211_REASON_CIPHER_REJECTED_BY_POLICY - - See IEEE 802.11 Standard - CSR_WIFI_SME_IEEE80211_REASON_SERVICE_CHANGE_PRECLUDES_TS - - See IEEE 802.11 Standard - CSR_WIFI_SME_IEEE80211_REASON_QOS_UNSPECIFIED_REASON - - See IEEE 802.11 Standard - CSR_WIFI_SME_IEEE80211_REASON_QOS_INSUFFICIENT_BANDWIDTH - - See IEEE 802.11 Standard - CSR_WIFI_SME_IEEE80211_REASON_QOS_EXCESSIVE_NOT_ACK - - See IEEE 802.11 Standard - CSR_WIFI_SME_IEEE80211_REASON_QOS_TXOPLIMIT_EXCEEDED - - See IEEE 802.11 Standard - CSR_WIFI_SME_IEEE80211_REASON_QSTA_LEAVING - - See IEEE 802.11 Standard - CSR_WIFI_SME_IEEE80211_REASON_END_TS - - See IEEE 802.11 Standard - CSR_WIFI_SME_IEEE80211_REASON_END_DLS - - See IEEE 802.11 Standard - CSR_WIFI_SME_IEEE80211_REASON_END_BA - - See IEEE 802.11 Standard - CSR_WIFI_SME_IEEE80211_REASON_UNKNOWN_TS - - See IEEE 802.11 Standard - CSR_WIFI_SME_IEEE80211_REASON_UNKNOWN_BA - - See IEEE 802.11 Standard - CSR_WIFI_SME_IEEE80211_REASON_UNKNOWN_DLS - - See IEEE 802.11 Standard - CSR_WIFI_SME_IEEE80211_REASON_TIMEOUT - - See IEEE 802.11 Standard - CSR_WIFI_SME_IEEE80211_REASON_STAKEY_MISMATCH - - See IEEE 802.11 Standard - CSR_WIFI_SME_IEEE80211_REASON_UNICAST_KEY_NEGOTIATION_TIMEOUT - - See IEEE 802.11 Standard - CSR_WIFI_SME_IEEE80211_REASON_MULTICAST_KEY_ANNOUNCEMENT_TIMEOUT - - See IEEE 802.11 Standard - CSR_WIFI_SME_IEEE80211_REASON_INCOMPATIBLE_UNICAST_KEY_NEGOTIATION_IE - - See IEEE 802.11 Standard - CSR_WIFI_SME_IEEE80211_REASON_INVALID_MULTICAST_CIPHER - - See IEEE 802.11 Standard - CSR_WIFI_SME_IEEE80211_REASON_INVALID_UNICAST_CIPHER - - See IEEE 802.11 Standard - CSR_WIFI_SME_IEEE80211_REASON_UNSUPPORTED_WAPI_IE_VERSION - - See IEEE 802.11 Standard - CSR_WIFI_SME_IEEE80211_REASON_INVALID_WAPI_CAPABILITY_IE - - See IEEE 802.11 Standard - CSR_WIFI_SME_IEEE80211_REASON_WAI_CERTIFICATE_AUTHENTICATION_FAILED - - See IEEE 802.11 Standard - -*******************************************************************************/ -typedef u16 CsrWifiSmeIEEE80211Reason; -#define CSR_WIFI_SME_IEEE80211_REASON_SUCCESS ((CsrWifiSmeIEEE80211Reason) 0x0000) -#define CSR_WIFI_SME_IEEE80211_REASON_UNSPECIFIED_REASON ((CsrWifiSmeIEEE80211Reason) 0x0001) -#define CSR_WIFI_SME_IEEE80211_REASON_AUTHENTICATION_NOT_VALID ((CsrWifiSmeIEEE80211Reason) 0x0002) -#define CSR_WIFI_SME_IEEE80211_REASON_DEAUTHENTICATED_LEAVE_BSS ((CsrWifiSmeIEEE80211Reason) 0x0003) -#define CSR_WIFI_SME_IEEE80211_REASON_DISASSOCIATED_INACTIVITY ((CsrWifiSmeIEEE80211Reason) 0x0004) -#define CSR_WIFI_SME_IEEE80211_REASON_AP_OVERLOAD ((CsrWifiSmeIEEE80211Reason) 0x0005) -#define CSR_WIFI_SME_IEEE80211_REASON_CLASS_2FRAME_ERROR ((CsrWifiSmeIEEE80211Reason) 0x0006) -#define CSR_WIFI_SME_IEEE80211_REASON_CLASS_3FRAME_ERROR ((CsrWifiSmeIEEE80211Reason) 0x0007) -#define CSR_WIFI_SME_IEEE80211_REASON_DISASSOCIATED_LEAVE_BSS ((CsrWifiSmeIEEE80211Reason) 0x0008) -#define CSR_WIFI_SME_IEEE80211_REASON_ASSOCIATION_NOT_AUTHENTICATED ((CsrWifiSmeIEEE80211Reason) 0x0009) -#define CSR_WIFI_SME_IEEE80211_REASON_DISASSOCIATED_POWER_CAPABILITY ((CsrWifiSmeIEEE80211Reason) 0x000a) -#define CSR_WIFI_SME_IEEE80211_REASON_DISASSOCIATED_SUPPORTED_CHANNELS ((CsrWifiSmeIEEE80211Reason) 0x000b) -#define CSR_WIFI_SME_IEEE80211_REASON_INVALID_INFORMATION_ELEMENT ((CsrWifiSmeIEEE80211Reason) 0x000d) -#define CSR_WIFI_SME_IEEE80211_REASON_MICHAEL_MIC_FAILURE ((CsrWifiSmeIEEE80211Reason) 0x000e) -#define CSR_WIFI_SME_IEEE80211_REASON_FOURWAY_HANDSHAKE_TIMEOUT ((CsrWifiSmeIEEE80211Reason) 0x000f) -#define CSR_WIFI_SME_IEEE80211_REASON_GROUP_KEY_UPDATE_TIMEOUT ((CsrWifiSmeIEEE80211Reason) 0x0010) -#define CSR_WIFI_SME_IEEE80211_REASON_HANDSHAKE_ELEMENT_DIFFERENT ((CsrWifiSmeIEEE80211Reason) 0x0011) -#define CSR_WIFI_SME_IEEE80211_REASON_INVALID_GROUP_CIPHER ((CsrWifiSmeIEEE80211Reason) 0x0012) -#define CSR_WIFI_SME_IEEE80211_REASON_INVALID_PAIRWISE_CIPHER ((CsrWifiSmeIEEE80211Reason) 0x0013) -#define CSR_WIFI_SME_IEEE80211_REASON_INVALID_AKMP ((CsrWifiSmeIEEE80211Reason) 0x0014) -#define CSR_WIFI_SME_IEEE80211_REASON_UNSUPPORTED_RSN_IEVERSION ((CsrWifiSmeIEEE80211Reason) 0x0015) -#define CSR_WIFI_SME_IEEE80211_REASON_INVALID_RSN_IECAPABILITIES ((CsrWifiSmeIEEE80211Reason) 0x0016) -#define CSR_WIFI_SME_IEEE80211_REASON_DOT1X_AUTH_FAILED ((CsrWifiSmeIEEE80211Reason) 0x0017) -#define CSR_WIFI_SME_IEEE80211_REASON_CIPHER_REJECTED_BY_POLICY ((CsrWifiSmeIEEE80211Reason) 0x0018) -#define CSR_WIFI_SME_IEEE80211_REASON_SERVICE_CHANGE_PRECLUDES_TS ((CsrWifiSmeIEEE80211Reason) 0x001F) -#define CSR_WIFI_SME_IEEE80211_REASON_QOS_UNSPECIFIED_REASON ((CsrWifiSmeIEEE80211Reason) 0x0020) -#define CSR_WIFI_SME_IEEE80211_REASON_QOS_INSUFFICIENT_BANDWIDTH ((CsrWifiSmeIEEE80211Reason) 0x0021) -#define CSR_WIFI_SME_IEEE80211_REASON_QOS_EXCESSIVE_NOT_ACK ((CsrWifiSmeIEEE80211Reason) 0x0022) -#define CSR_WIFI_SME_IEEE80211_REASON_QOS_TXOPLIMIT_EXCEEDED ((CsrWifiSmeIEEE80211Reason) 0x0023) -#define CSR_WIFI_SME_IEEE80211_REASON_QSTA_LEAVING ((CsrWifiSmeIEEE80211Reason) 0x0024) -#define CSR_WIFI_SME_IEEE80211_REASON_END_TS ((CsrWifiSmeIEEE80211Reason) 0x0025) -#define CSR_WIFI_SME_IEEE80211_REASON_END_DLS ((CsrWifiSmeIEEE80211Reason) 0x0025) -#define CSR_WIFI_SME_IEEE80211_REASON_END_BA ((CsrWifiSmeIEEE80211Reason) 0x0025) -#define CSR_WIFI_SME_IEEE80211_REASON_UNKNOWN_TS ((CsrWifiSmeIEEE80211Reason) 0x0026) -#define CSR_WIFI_SME_IEEE80211_REASON_UNKNOWN_BA ((CsrWifiSmeIEEE80211Reason) 0x0026) -#define CSR_WIFI_SME_IEEE80211_REASON_UNKNOWN_DLS ((CsrWifiSmeIEEE80211Reason) 0x0026) -#define CSR_WIFI_SME_IEEE80211_REASON_TIMEOUT ((CsrWifiSmeIEEE80211Reason) 0x0027) -#define CSR_WIFI_SME_IEEE80211_REASON_STAKEY_MISMATCH ((CsrWifiSmeIEEE80211Reason) 0x002d) -#define CSR_WIFI_SME_IEEE80211_REASON_UNICAST_KEY_NEGOTIATION_TIMEOUT ((CsrWifiSmeIEEE80211Reason) 0xf019) -#define CSR_WIFI_SME_IEEE80211_REASON_MULTICAST_KEY_ANNOUNCEMENT_TIMEOUT ((CsrWifiSmeIEEE80211Reason) 0xf01a) -#define CSR_WIFI_SME_IEEE80211_REASON_INCOMPATIBLE_UNICAST_KEY_NEGOTIATION_IE ((CsrWifiSmeIEEE80211Reason) 0xf01b) -#define CSR_WIFI_SME_IEEE80211_REASON_INVALID_MULTICAST_CIPHER ((CsrWifiSmeIEEE80211Reason) 0xf01c) -#define CSR_WIFI_SME_IEEE80211_REASON_INVALID_UNICAST_CIPHER ((CsrWifiSmeIEEE80211Reason) 0xf01d) -#define CSR_WIFI_SME_IEEE80211_REASON_UNSUPPORTED_WAPI_IE_VERSION ((CsrWifiSmeIEEE80211Reason) 0xf01e) -#define CSR_WIFI_SME_IEEE80211_REASON_INVALID_WAPI_CAPABILITY_IE ((CsrWifiSmeIEEE80211Reason) 0xf01f) -#define CSR_WIFI_SME_IEEE80211_REASON_WAI_CERTIFICATE_AUTHENTICATION_FAILED ((CsrWifiSmeIEEE80211Reason) 0xf020) - -/******************************************************************************* - - NAME - CsrWifiSmeIEEE80211Result - - DESCRIPTION - As definined in the IEEE 802.11 standards - - VALUES - CSR_WIFI_SME_IEEE80211_RESULT_SUCCESS - - See IEEE 802.11 Standard - CSR_WIFI_SME_IEEE80211_RESULT_UNSPECIFIED_FAILURE - - See IEEE 802.11 Standard - CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_CAPABILITIES_MISMATCH - - See IEEE 802.11 Standard - CSR_WIFI_SME_IEEE80211_RESULT_REASSOCIATION_DENIED_NO_ASSOCIATION - - See IEEE 802.11 Standard - CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_EXTERNAL_REASON - - See IEEE 802.11 Standard - CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_AUTHENTICATION_MISMATCH - - See IEEE 802.11 Standard - CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_INVALID_AUTHENTICATION_SEQUENCE_NUMBER - - See IEEE 802.11 Standard - CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_CHALLENGE_FAILURE - - See IEEE 802.11 Standard - CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_AUTHENTICATION_TIMEOUT - - See IEEE 802.11 Standard - CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_AP_OUT_OF_MEMORY - - See IEEE 802.11 Standard - CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_BASIC_RATES_MISMATCH - - See IEEE 802.11 Standard - CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_SHORT_PREAMBLE_REQUIRED - - See IEEE 802.11 Standard - CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_PBCC_MODULATION_REQUIRED - - See IEEE 802.11 Standard - CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_CHANNEL_AGILITY_REQUIRED - - See IEEE 802.11 Standard - CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_SPECTRUM_MANAGEMENT_REQUIRED - - See IEEE 802.11 Standard - CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_POWER_CAPABILITY_UNACCEPTABLE - - See IEEE 802.11 Standard - CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_SUPPORTED_CHANNELS_UNACCEPTABLE - - See IEEE 802.11 Standard - CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_SHORT_SLOT_REQUIRED - - See IEEE 802.11 Standard - CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_DSSS_OFDMREQUIRED - - See IEEE 802.11 Standard - CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_NO_HT_SUPPORT - - See IEEE 802.11 Standard - CSR_WIFI_SME_IEEE80211_RESULT_R0KH_UNREACHABLE - - See IEEE 802.11 Standard - CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_PCO_TRANSITION_SUPPORT - - See IEEE 802.11 Standard - CSR_WIFI_SME_IEEE80211_RESULT_ASSOCIATION_REQUEST_REJECTED_TEMPORARILY - - See IEEE 802.11 Standard - CSR_WIFI_SME_IEEE80211_RESULT_ROBUST_MANAGEMENT_FRAME_POLICY_VIOLATION - - See IEEE 802.11 Standard - CSR_WIFI_SME_IEEE80211_RESULT_FAILURE - - See IEEE 802.11 Standard - CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_AP_BANDWIDTH_INSUFFICIENT - - See IEEE 802.11 Standard - CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_POOR_OPERATING_CHANNEL - - See IEEE 802.11 Standard - CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_QOS_REQUIRED - - See IEEE 802.11 Standard - CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_REASON_UNSPECIFIED - - See IEEE 802.11 Standard - CSR_WIFI_SME_IEEE80211_RESULT_REFUSED - - See IEEE 802.11 Standard - CSR_WIFI_SME_IEEE80211_RESULT_INVALID_PARAMETERS - - See IEEE 802.11 Standard - CSR_WIFI_SME_IEEE80211_RESULT_REJECTED_WITH_SUGGESTED_TSPEC_CHANGES - - See IEEE 802.11 Standard - CSR_WIFI_SME_IEEE80211_RESULT_REJECTED_INVALID_IE - - See IEEE 802.11 Standard - CSR_WIFI_SME_IEEE80211_RESULT_REJECTED_INVALID_GROUP_CIPHER - - See IEEE 802.11 Standard - CSR_WIFI_SME_IEEE80211_RESULT_REJECTED_INVALID_PAIRWISE_CIPHER - - See IEEE 802.11 Standard - CSR_WIFI_SME_IEEE80211_RESULT_REJECTED_INVALID_AKMP - - See IEEE 802.11 Standard - CSR_WIFI_SME_IEEE80211_RESULT_REJECTED_UNSUPPORTED_RSN_VERSION - - See IEEE 802.11 Standard - CSR_WIFI_SME_IEEE80211_RESULT_REJECTED_INVALID_RSN_CAPABILITY - - See IEEE 802.11 Standard - CSR_WIFI_SME_IEEE80211_RESULT_REJECTED_SECURITY_POLICY - - See IEEE 802.11 Standard - CSR_WIFI_SME_IEEE80211_RESULT_REJECTED_FOR_DELAY_PERIOD - - See IEEE 802.11 Standard - CSR_WIFI_SME_IEEE80211_RESULT_NOT_ALLOWED - - See IEEE 802.11 Standard - CSR_WIFI_SME_IEEE80211_RESULT_NOT_PRESENT - - See IEEE 802.11 Standard - CSR_WIFI_SME_IEEE80211_RESULT_NOT_QSTA - - See IEEE 802.11 Standard - CSR_WIFI_SME_IEEE80211_RESULT_REJECTED_LISTEN_INTERVAL_TOO_LARGE - - See IEEE 802.11 Standard - CSR_WIFI_SME_IEEE80211_RESULT_INVALID_FT_ACTION_FRAME_COUNT - - See IEEE 802.11 Standard - CSR_WIFI_SME_IEEE80211_RESULT_INVALID_PMKID - - See IEEE 802.11 Standard - CSR_WIFI_SME_IEEE80211_RESULT_INVALID_MDIE - - See IEEE 802.11 Standard - CSR_WIFI_SME_IEEE80211_RESULT_INVALID_FTIE - - See IEEE 802.11 Standard - CSR_WIFI_SME_IEEE80211_RESULT_UNSPECIFIED_QOS_FAILURE - - See IEEE 802.11 Standard - CSR_WIFI_SME_IEEE80211_RESULT_WRONG_POLICY - - See IEEE 802.11 Standard - CSR_WIFI_SME_IEEE80211_RESULT_INSUFFICIENT_BANDWIDTH - - See IEEE 802.11 Standard - CSR_WIFI_SME_IEEE80211_RESULT_INVALID_TSPEC_PARAMETERS - - See IEEE 802.11 Standard - CSR_WIFI_SME_IEEE80211_RESULT_TIMEOUT - - See IEEE 802.11 Standard - CSR_WIFI_SME_IEEE80211_RESULT_TOO_MANY_SIMULTANEOUS_REQUESTS - - See IEEE 802.11 Standard - CSR_WIFI_SME_IEEE80211_RESULT_BSS_ALREADY_STARTED_OR_JOINED - - See IEEE 802.11 Standard - CSR_WIFI_SME_IEEE80211_RESULT_NOT_SUPPORTED - - See IEEE 802.11 Standard - CSR_WIFI_SME_IEEE80211_RESULT_TRANSMISSION_FAILURE - - See IEEE 802.11 Standard - CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_NOT_AUTHENTICATED - - See IEEE 802.11 Standard - CSR_WIFI_SME_IEEE80211_RESULT_RESET_REQUIRED_BEFORE_START - - See IEEE 802.11 Standard - CSR_WIFI_SME_IEEE80211_RESULT_LM_INFO_UNAVAILABLE - - See IEEE 802.11 Standard - CSR_WIFI_SME_IEEE80211_RESULT_INVALID_UNICAST_CIPHER - - See IEEE 802.11 Standard - CSR_WIFI_SME_IEEE80211_RESULT_INVALID_MULTICAST_CIPHER - - See IEEE 802.11 Standard - CSR_WIFI_SME_IEEE80211_RESULT_UNSUPPORTED_WAPI_IE_VERSION - - See IEEE 802.11 Standard - CSR_WIFI_SME_IEEE80211_RESULT_INVALID_WAPI_CAPABILITY_IE - - See IEEE 802.11 Standard - -*******************************************************************************/ -typedef u16 CsrWifiSmeIEEE80211Result; -#define CSR_WIFI_SME_IEEE80211_RESULT_SUCCESS ((CsrWifiSmeIEEE80211Result) 0x0000) -#define CSR_WIFI_SME_IEEE80211_RESULT_UNSPECIFIED_FAILURE ((CsrWifiSmeIEEE80211Result) 0x0001) -#define CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_CAPABILITIES_MISMATCH ((CsrWifiSmeIEEE80211Result) 0x000a) -#define CSR_WIFI_SME_IEEE80211_RESULT_REASSOCIATION_DENIED_NO_ASSOCIATION ((CsrWifiSmeIEEE80211Result) 0x000b) -#define CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_EXTERNAL_REASON ((CsrWifiSmeIEEE80211Result) 0x000c) -#define CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_AUTHENTICATION_MISMATCH ((CsrWifiSmeIEEE80211Result) 0x000d) -#define CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_INVALID_AUTHENTICATION_SEQUENCE_NUMBER ((CsrWifiSmeIEEE80211Result) 0x000e) -#define CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_CHALLENGE_FAILURE ((CsrWifiSmeIEEE80211Result) 0x000f) -#define CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_AUTHENTICATION_TIMEOUT ((CsrWifiSmeIEEE80211Result) 0x0010) -#define CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_AP_OUT_OF_MEMORY ((CsrWifiSmeIEEE80211Result) 0x0011) -#define CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_BASIC_RATES_MISMATCH ((CsrWifiSmeIEEE80211Result) 0x0012) -#define CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_SHORT_PREAMBLE_REQUIRED ((CsrWifiSmeIEEE80211Result) 0x0013) -#define CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_PBCC_MODULATION_REQUIRED ((CsrWifiSmeIEEE80211Result) 0x0014) -#define CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_CHANNEL_AGILITY_REQUIRED ((CsrWifiSmeIEEE80211Result) 0x0015) -#define CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_SPECTRUM_MANAGEMENT_REQUIRED ((CsrWifiSmeIEEE80211Result) 0x0016) -#define CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_POWER_CAPABILITY_UNACCEPTABLE ((CsrWifiSmeIEEE80211Result) 0x0017) -#define CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_SUPPORTED_CHANNELS_UNACCEPTABLE ((CsrWifiSmeIEEE80211Result) 0x0018) -#define CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_SHORT_SLOT_REQUIRED ((CsrWifiSmeIEEE80211Result) 0x0019) -#define CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_DSSS_OFDMREQUIRED ((CsrWifiSmeIEEE80211Result) 0x001a) -#define CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_NO_HT_SUPPORT ((CsrWifiSmeIEEE80211Result) 0x001b) -#define CSR_WIFI_SME_IEEE80211_RESULT_R0KH_UNREACHABLE ((CsrWifiSmeIEEE80211Result) 0x001c) -#define CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_PCO_TRANSITION_SUPPORT ((CsrWifiSmeIEEE80211Result) 0x001d) -#define CSR_WIFI_SME_IEEE80211_RESULT_ASSOCIATION_REQUEST_REJECTED_TEMPORARILY ((CsrWifiSmeIEEE80211Result) 0x001e) -#define CSR_WIFI_SME_IEEE80211_RESULT_ROBUST_MANAGEMENT_FRAME_POLICY_VIOLATION ((CsrWifiSmeIEEE80211Result) 0x001f) -#define CSR_WIFI_SME_IEEE80211_RESULT_FAILURE ((CsrWifiSmeIEEE80211Result) 0x0020) -#define CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_AP_BANDWIDTH_INSUFFICIENT ((CsrWifiSmeIEEE80211Result) 0x0021) -#define CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_POOR_OPERATING_CHANNEL ((CsrWifiSmeIEEE80211Result) 0x0022) -#define CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_QOS_REQUIRED ((CsrWifiSmeIEEE80211Result) 0x0023) -#define CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_REASON_UNSPECIFIED ((CsrWifiSmeIEEE80211Result) 0x0025) -#define CSR_WIFI_SME_IEEE80211_RESULT_REFUSED ((CsrWifiSmeIEEE80211Result) 0x0025) -#define CSR_WIFI_SME_IEEE80211_RESULT_INVALID_PARAMETERS ((CsrWifiSmeIEEE80211Result) 0x0026) -#define CSR_WIFI_SME_IEEE80211_RESULT_REJECTED_WITH_SUGGESTED_TSPEC_CHANGES ((CsrWifiSmeIEEE80211Result) 0x0027) -#define CSR_WIFI_SME_IEEE80211_RESULT_REJECTED_INVALID_IE ((CsrWifiSmeIEEE80211Result) 0x0028) -#define CSR_WIFI_SME_IEEE80211_RESULT_REJECTED_INVALID_GROUP_CIPHER ((CsrWifiSmeIEEE80211Result) 0x0029) -#define CSR_WIFI_SME_IEEE80211_RESULT_REJECTED_INVALID_PAIRWISE_CIPHER ((CsrWifiSmeIEEE80211Result) 0x002a) -#define CSR_WIFI_SME_IEEE80211_RESULT_REJECTED_INVALID_AKMP ((CsrWifiSmeIEEE80211Result) 0x002b) -#define CSR_WIFI_SME_IEEE80211_RESULT_REJECTED_UNSUPPORTED_RSN_VERSION ((CsrWifiSmeIEEE80211Result) 0x002c) -#define CSR_WIFI_SME_IEEE80211_RESULT_REJECTED_INVALID_RSN_CAPABILITY ((CsrWifiSmeIEEE80211Result) 0x002d) -#define CSR_WIFI_SME_IEEE80211_RESULT_REJECTED_SECURITY_POLICY ((CsrWifiSmeIEEE80211Result) 0x002e) -#define CSR_WIFI_SME_IEEE80211_RESULT_REJECTED_FOR_DELAY_PERIOD ((CsrWifiSmeIEEE80211Result) 0x002f) -#define CSR_WIFI_SME_IEEE80211_RESULT_NOT_ALLOWED ((CsrWifiSmeIEEE80211Result) 0x0030) -#define CSR_WIFI_SME_IEEE80211_RESULT_NOT_PRESENT ((CsrWifiSmeIEEE80211Result) 0x0031) -#define CSR_WIFI_SME_IEEE80211_RESULT_NOT_QSTA ((CsrWifiSmeIEEE80211Result) 0x0032) -#define CSR_WIFI_SME_IEEE80211_RESULT_REJECTED_LISTEN_INTERVAL_TOO_LARGE ((CsrWifiSmeIEEE80211Result) 0x0033) -#define CSR_WIFI_SME_IEEE80211_RESULT_INVALID_FT_ACTION_FRAME_COUNT ((CsrWifiSmeIEEE80211Result) 0x0034) -#define CSR_WIFI_SME_IEEE80211_RESULT_INVALID_PMKID ((CsrWifiSmeIEEE80211Result) 0x0035) -#define CSR_WIFI_SME_IEEE80211_RESULT_INVALID_MDIE ((CsrWifiSmeIEEE80211Result) 0x0036) -#define CSR_WIFI_SME_IEEE80211_RESULT_INVALID_FTIE ((CsrWifiSmeIEEE80211Result) 0x0037) -#define CSR_WIFI_SME_IEEE80211_RESULT_UNSPECIFIED_QOS_FAILURE ((CsrWifiSmeIEEE80211Result) 0x00c8) -#define CSR_WIFI_SME_IEEE80211_RESULT_WRONG_POLICY ((CsrWifiSmeIEEE80211Result) 0x00c9) -#define CSR_WIFI_SME_IEEE80211_RESULT_INSUFFICIENT_BANDWIDTH ((CsrWifiSmeIEEE80211Result) 0x00ca) -#define CSR_WIFI_SME_IEEE80211_RESULT_INVALID_TSPEC_PARAMETERS ((CsrWifiSmeIEEE80211Result) 0x00cb) -#define CSR_WIFI_SME_IEEE80211_RESULT_TIMEOUT ((CsrWifiSmeIEEE80211Result) 0x8000) -#define CSR_WIFI_SME_IEEE80211_RESULT_TOO_MANY_SIMULTANEOUS_REQUESTS ((CsrWifiSmeIEEE80211Result) 0x8001) -#define CSR_WIFI_SME_IEEE80211_RESULT_BSS_ALREADY_STARTED_OR_JOINED ((CsrWifiSmeIEEE80211Result) 0x8002) -#define CSR_WIFI_SME_IEEE80211_RESULT_NOT_SUPPORTED ((CsrWifiSmeIEEE80211Result) 0x8003) -#define CSR_WIFI_SME_IEEE80211_RESULT_TRANSMISSION_FAILURE ((CsrWifiSmeIEEE80211Result) 0x8004) -#define CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_NOT_AUTHENTICATED ((CsrWifiSmeIEEE80211Result) 0x8005) -#define CSR_WIFI_SME_IEEE80211_RESULT_RESET_REQUIRED_BEFORE_START ((CsrWifiSmeIEEE80211Result) 0x8006) -#define CSR_WIFI_SME_IEEE80211_RESULT_LM_INFO_UNAVAILABLE ((CsrWifiSmeIEEE80211Result) 0x8007) -#define CSR_WIFI_SME_IEEE80211_RESULT_INVALID_UNICAST_CIPHER ((CsrWifiSmeIEEE80211Result) 0xf02f) -#define CSR_WIFI_SME_IEEE80211_RESULT_INVALID_MULTICAST_CIPHER ((CsrWifiSmeIEEE80211Result) 0xf030) -#define CSR_WIFI_SME_IEEE80211_RESULT_UNSUPPORTED_WAPI_IE_VERSION ((CsrWifiSmeIEEE80211Result) 0xf031) -#define CSR_WIFI_SME_IEEE80211_RESULT_INVALID_WAPI_CAPABILITY_IE ((CsrWifiSmeIEEE80211Result) 0xf032) - -/******************************************************************************* - - NAME - CsrWifiSmeIndications - - DESCRIPTION - Defines bits for CsrWifiSmeIndicationsMask - - VALUES - CSR_WIFI_SME_INDICATIONS_NONE - - Used to cancel the registrations for receiving indications - CSR_WIFI_SME_INDICATIONS_WIFIOFF - - Used to register for CSR_WIFI_SME_WIFI_OFF_IND events - CSR_WIFI_SME_INDICATIONS_SCANRESULT - - Used to register for CSR_WIFI_SME_SCAN_RESULT_IND events - CSR_WIFI_SME_INDICATIONS_CONNECTIONQUALITY - - Used to register for CSR_WIFI_SME_CONNECTION_QUALITY_IND - events - CSR_WIFI_SME_INDICATIONS_MEDIASTATUS - - Used to register for CSR_WIFI_SME_MEDIA_STATUS_IND events - CSR_WIFI_SME_INDICATIONS_MICFAILURE - - Used to register for CSR_WIFI_SME_MICFAILURE_IND events - CSR_WIFI_SME_INDICATIONS_PMKIDCANDIDATELIST - - Used to register for CSR_WIFI_SME_PMKIDCANDIDATE_LIST_IND - events - CSR_WIFI_SME_INDICATIONS_TSPEC - - Used to register for CSR_WIFI_SME_TSPEC_IND events - CSR_WIFI_SME_INDICATIONS_ROAMSTART - - Used to register for CSR_WIFI_SME_ROAM_START_IND events - CSR_WIFI_SME_INDICATIONS_ROAMCOMPLETE - - Used to register for CSR_WIFI_SME_ROAM_COMPLETE_IND events - CSR_WIFI_SME_INDICATIONS_ASSOCIATIONSTART - - Used to register for CSR_WIFI_SME_ASSOCIATION_START_IND - events - CSR_WIFI_SME_INDICATIONS_ASSOCIATIONCOMPLETE - - Used to register for CSR_WIFI_SME_ASSOCIATION_COMPLETE_IND - events - CSR_WIFI_SME_INDICATIONS_IBSSSTATION - - Used to register for CSR_WIFI_SME_IBSS_STATION_IND events - CSR_WIFI_SME_INDICATIONS_WIFION - - Used to register for CSR_WIFI_SME_WIFI_ON_IND events - CSR_WIFI_SME_INDICATIONS_ERROR - - Used to register for CSR_WIFI_SME_ERROR_IND events - CSR_WIFI_SME_INDICATIONS_INFO - - Used to register for CSR_WIFI_SME_INFO_IND events - CSR_WIFI_SME_INDICATIONS_COREDUMP - - Used to register for CSR_WIFI_SME_CORE_DUMP_IND events - CSR_WIFI_SME_INDICATIONS_ALL - - Used to register for all available indications - -*******************************************************************************/ -typedef u32 CsrWifiSmeIndications; -#define CSR_WIFI_SME_INDICATIONS_NONE ((CsrWifiSmeIndications) 0x00000000) -#define CSR_WIFI_SME_INDICATIONS_WIFIOFF ((CsrWifiSmeIndications) 0x00000001) -#define CSR_WIFI_SME_INDICATIONS_SCANRESULT ((CsrWifiSmeIndications) 0x00000002) -#define CSR_WIFI_SME_INDICATIONS_CONNECTIONQUALITY ((CsrWifiSmeIndications) 0x00000004) -#define CSR_WIFI_SME_INDICATIONS_MEDIASTATUS ((CsrWifiSmeIndications) 0x00000008) -#define CSR_WIFI_SME_INDICATIONS_MICFAILURE ((CsrWifiSmeIndications) 0x00000010) -#define CSR_WIFI_SME_INDICATIONS_PMKIDCANDIDATELIST ((CsrWifiSmeIndications) 0x00000020) -#define CSR_WIFI_SME_INDICATIONS_TSPEC ((CsrWifiSmeIndications) 0x00000040) -#define CSR_WIFI_SME_INDICATIONS_ROAMSTART ((CsrWifiSmeIndications) 0x00000080) -#define CSR_WIFI_SME_INDICATIONS_ROAMCOMPLETE ((CsrWifiSmeIndications) 0x00000100) -#define CSR_WIFI_SME_INDICATIONS_ASSOCIATIONSTART ((CsrWifiSmeIndications) 0x00000200) -#define CSR_WIFI_SME_INDICATIONS_ASSOCIATIONCOMPLETE ((CsrWifiSmeIndications) 0x00000400) -#define CSR_WIFI_SME_INDICATIONS_IBSSSTATION ((CsrWifiSmeIndications) 0x00000800) -#define CSR_WIFI_SME_INDICATIONS_WIFION ((CsrWifiSmeIndications) 0x00001000) -#define CSR_WIFI_SME_INDICATIONS_ERROR ((CsrWifiSmeIndications) 0x00002000) -#define CSR_WIFI_SME_INDICATIONS_INFO ((CsrWifiSmeIndications) 0x00004000) -#define CSR_WIFI_SME_INDICATIONS_COREDUMP ((CsrWifiSmeIndications) 0x00008000) -#define CSR_WIFI_SME_INDICATIONS_ALL ((CsrWifiSmeIndications) 0xFFFFFFFF) - -/******************************************************************************* - - NAME - CsrWifiSmeKeyType - - DESCRIPTION - Indicates the type of the key - - VALUES - CSR_WIFI_SME_KEY_TYPE_GROUP - Key for broadcast communication - CSR_WIFI_SME_KEY_TYPE_PAIRWISE - Key for unicast communication - CSR_WIFI_SME_KEY_TYPE_STAKEY - Key for direct link communication to - another station in infrastructure networks - CSR_WIFI_SME_KEY_TYPE_IGTK - Integrity Group Temporal Key - CSR_WIFI_SME_KEY_TYPE_CCKM - Key for Cisco Centralized Key Management - -*******************************************************************************/ -typedef u8 CsrWifiSmeKeyType; -#define CSR_WIFI_SME_KEY_TYPE_GROUP ((CsrWifiSmeKeyType) 0x00) -#define CSR_WIFI_SME_KEY_TYPE_PAIRWISE ((CsrWifiSmeKeyType) 0x01) -#define CSR_WIFI_SME_KEY_TYPE_STAKEY ((CsrWifiSmeKeyType) 0x02) -#define CSR_WIFI_SME_KEY_TYPE_IGTK ((CsrWifiSmeKeyType) 0x03) -#define CSR_WIFI_SME_KEY_TYPE_CCKM ((CsrWifiSmeKeyType) 0x04) - -/******************************************************************************* - - NAME - CsrWifiSmeListAction - - DESCRIPTION - Identifies the type of action to be performed on a list of items - The values of this type are used across the NME/SME/Router API's and they - must be kept consistent with the corresponding types in the .xml of the - ottherinterfaces - - VALUES - CSR_WIFI_SME_LIST_ACTION_GET - Retrieve the current list of items - CSR_WIFI_SME_LIST_ACTION_ADD - Add one or more items - CSR_WIFI_SME_LIST_ACTION_REMOVE - Remove one or more items - CSR_WIFI_SME_LIST_ACTION_FLUSH - Remove all items - -*******************************************************************************/ -typedef u8 CsrWifiSmeListAction; -#define CSR_WIFI_SME_LIST_ACTION_GET ((CsrWifiSmeListAction) 0x00) -#define CSR_WIFI_SME_LIST_ACTION_ADD ((CsrWifiSmeListAction) 0x01) -#define CSR_WIFI_SME_LIST_ACTION_REMOVE ((CsrWifiSmeListAction) 0x02) -#define CSR_WIFI_SME_LIST_ACTION_FLUSH ((CsrWifiSmeListAction) 0x03) - -/******************************************************************************* - - NAME - CsrWifiSmeMediaStatus - - DESCRIPTION - Indicates the connection status - The values of this type are used across the NME/SME/Router API's and they - must be kept consistent with the corresponding types in the .xml of the - ottherinterfaces - - VALUES - CSR_WIFI_SME_MEDIA_STATUS_CONNECTED - - Value CSR_WIFI_SME_MEDIA_STATUS_CONNECTED can happen in two - situations: - * A network connection is established. Specifically, this is - when the MLME_ASSOCIATION completes or the first peer - relationship is established in an IBSS. In a WPA/WPA2 - network, this indicates that the stack is ready to perform - the 4-way handshake or 802.1x authentication if CSR NME - security library is not used. If CSR NME security library - is used this indicates, completion of 4way handshake or - 802.1x authentication - * The SME roams to another AP on the same ESS - During the AP operation, it indicates that the peer station - is connected to the AP and is ready for data transfer. - CSR_WIFI_SME_MEDIA_STATUS_DISCONNECTED - - Value CSR_WIFI_SME_MEDIA_STATUS_DISCONNECTED can happen in - two situations: - * when the connection to a network is lost and there is no - alternative on the same ESS to roam to - * when a CSR_WIFI_SME_DISCONNECT_REQ request is issued - During AP or P2PGO operation, it indicates that the peer - station has disconnected from the AP - -*******************************************************************************/ -typedef u8 CsrWifiSmeMediaStatus; -#define CSR_WIFI_SME_MEDIA_STATUS_CONNECTED ((CsrWifiSmeMediaStatus) 0x00) -#define CSR_WIFI_SME_MEDIA_STATUS_DISCONNECTED ((CsrWifiSmeMediaStatus) 0x01) - -/******************************************************************************* - - NAME - CsrWifiSmeP2pCapability - - DESCRIPTION - Defines P2P Device Capabilities - - VALUES - CSR_WIFI_SME_P2P_SERVICE_DISCOVERY_CAPABILITY - - This field is set to 1 if the P2P Device supports Service - Discovery, and to 0 otherwise - CSR_WIFI_SME_P2P_CLIENT_DISCOVERABILITY_CAPABILITY - - This field is set to 1 when the P2P Device supports P2P - Client Discoverability, and to 0 otherwise. - CSR_WIFI_SME_P2P_CONCURRENT_OPERATION_CAPABILITY - - This field is set to 1 when the P2P Device supports - Concurrent Operation with WLAN, and to 0 otherwise. - CSR_WIFI_SME_P2P_MANAGED_DEVICE_CAPABILITY - - This field is set to 1 when the P2P interface of the P2P - Device is capable of being managed by the WLAN - (infrastructure network) based on P2P coexistence - parameters, and to 0 otherwise - CSR_WIFI_SME_P2P_INVITAION_CAPABILITY - - This field is set to 1 if the P2P Device is capable of - processing P2P Invitation Procedure signaling, and to 0 - otherwise. - -*******************************************************************************/ -typedef u8 CsrWifiSmeP2pCapability; -#define CSR_WIFI_SME_P2P_SERVICE_DISCOVERY_CAPABILITY ((CsrWifiSmeP2pCapability) 0x01) -#define CSR_WIFI_SME_P2P_CLIENT_DISCOVERABILITY_CAPABILITY ((CsrWifiSmeP2pCapability) 0x02) -#define CSR_WIFI_SME_P2P_CONCURRENT_OPERATION_CAPABILITY ((CsrWifiSmeP2pCapability) 0x04) -#define CSR_WIFI_SME_P2P_MANAGED_DEVICE_CAPABILITY ((CsrWifiSmeP2pCapability) 0x08) -#define CSR_WIFI_SME_P2P_INVITAION_CAPABILITY ((CsrWifiSmeP2pCapability) 0x20) - -/******************************************************************************* - - NAME - CsrWifiSmeP2pGroupCapability - - DESCRIPTION - Define bits for P2P Group Capability - - VALUES - CSR_WIFI_P2P_GRP_CAP_GO - - Indicates if the local device has become a GO after GO - negotiation - CSR_WIFI_P2P_GRP_CAP_PERSISTENT - - Persistent group - CSR_WIFI_P2P_GRP_CAP_INTRABSS_DIST - - Intra-BSS data distribution support - CSR_WIFI_P2P_GRP_CAP_CROSS_CONN - - Support of cross connection - CSR_WIFI_P2P_GRP_CAP_PERSISTENT_RECONNECT - - Support of persistent reconnect - -*******************************************************************************/ -typedef u8 CsrWifiSmeP2pGroupCapability; -#define CSR_WIFI_P2P_GRP_CAP_GO ((CsrWifiSmeP2pGroupCapability) 0x01) -#define CSR_WIFI_P2P_GRP_CAP_PERSISTENT ((CsrWifiSmeP2pGroupCapability) 0x02) -#define CSR_WIFI_P2P_GRP_CAP_INTRABSS_DIST ((CsrWifiSmeP2pGroupCapability) 0x08) -#define CSR_WIFI_P2P_GRP_CAP_CROSS_CONN ((CsrWifiSmeP2pGroupCapability) 0x10) -#define CSR_WIFI_P2P_GRP_CAP_PERSISTENT_RECONNECT ((CsrWifiSmeP2pGroupCapability) 0x20) - -/******************************************************************************* - - NAME - CsrWifiSmeP2pNoaConfigMethod - - DESCRIPTION - Notice of Absece Configuration - - VALUES - CSR_WIFI_P2P_NOA_NONE - Do not use NOA - CSR_WIFI_P2P_NOA_AUTONOMOUS - NOA based on the traffic analysis - CSR_WIFI_P2P_NOA_USER_DEFINED - NOA as specified by the user - -*******************************************************************************/ -typedef u8 CsrWifiSmeP2pNoaConfigMethod; -#define CSR_WIFI_P2P_NOA_NONE ((CsrWifiSmeP2pNoaConfigMethod) 0x00) -#define CSR_WIFI_P2P_NOA_AUTONOMOUS ((CsrWifiSmeP2pNoaConfigMethod) 0x01) -#define CSR_WIFI_P2P_NOA_USER_DEFINED ((CsrWifiSmeP2pNoaConfigMethod) 0x02) - -/******************************************************************************* - - NAME - CsrWifiSmeP2pRole - - DESCRIPTION - Definition of roles for a P2P Device - - VALUES - CSR_WIFI_SME_P2P_ROLE_NONE - A non-P2PDevice device - CSR_WIFI_SME_P2P_ROLE_STANDALONE - A Standalone P2P device - CSR_WIFI_SME_P2P_ROLE_GO - Role Assumed is that of a Group Owner - within a P2P Group - CSR_WIFI_SME_P2P_ROLE_CLI - Role Assumed is that of a P2P Client - within a P2P Group - -*******************************************************************************/ -typedef u8 CsrWifiSmeP2pRole; -#define CSR_WIFI_SME_P2P_ROLE_NONE ((CsrWifiSmeP2pRole) 0x00) -#define CSR_WIFI_SME_P2P_ROLE_STANDALONE ((CsrWifiSmeP2pRole) 0x01) -#define CSR_WIFI_SME_P2P_ROLE_GO ((CsrWifiSmeP2pRole) 0x02) -#define CSR_WIFI_SME_P2P_ROLE_CLI ((CsrWifiSmeP2pRole) 0x03) - -/******************************************************************************* - - NAME - CsrWifiSmeP2pStatus - - DESCRIPTION - This data type enumerates the outcome of P2P procedure - - VALUES - CSR_WIFI_SME_P2P_STATUS_SUCCESS - - Success - CSR_WIFI_SME_P2P_STATUS_FAIL_INFO_UNAVAILABLE - - Fail; information is currently unavailable - CSR_WIFI_SME_P2P_STATUS_FAIL_INCOMPATIBLE_PARAM - - Fail; incompatible parameters - CSR_WIFI_SME_P2P_STATUS_FAIL_LIMIT_REACHED - - Fail; limit reached - CSR_WIFI_SME_P2P_STATUS_FAIL_INVALID_PARAM - - Fail; invalid parameters - CSR_WIFI_SME_P2P_STATUS_FAIL_ACCOMODATE - - Fail; unable to accommodate request - CSR_WIFI_SME_P2P_STATUS_FAIL_PREV_ERROR - - Fail; previous protocol error, or disruptive behavior - CSR_WIFI_SME_P2P_STATUS_FAIL_COMMON_CHANNELS - - Fail; no common channels - CSR_WIFI_SME_P2P_STATUS_FAIL_UNKNOWN_GROUP - - Fail; unknown P2P Group - CSR_WIFI_SME_P2P_STATUS_FAIL_GO_INTENT - - Fail: both P2P Devices indicated an Intent of 15 in Group - Owner Negotiation - CSR_WIFI_SME_P2P_STATUS_FAIL_PROVISION_METHOD_INCOMPATIBLE - - Fail; incompatible provisioning method - CSR_WIFI_SME_P2P_STATUS_FAIL_REJECT - - Fail: rejected by user - CSR_WIFI_SME_P2P_STATUS_FAIL_RESERVED - - Fail; Status Reserved - -*******************************************************************************/ -typedef u8 CsrWifiSmeP2pStatus; -#define CSR_WIFI_SME_P2P_STATUS_SUCCESS ((CsrWifiSmeP2pStatus) 0x00) -#define CSR_WIFI_SME_P2P_STATUS_FAIL_INFO_UNAVAILABLE ((CsrWifiSmeP2pStatus) 0x01) -#define CSR_WIFI_SME_P2P_STATUS_FAIL_INCOMPATIBLE_PARAM ((CsrWifiSmeP2pStatus) 0x02) -#define CSR_WIFI_SME_P2P_STATUS_FAIL_LIMIT_REACHED ((CsrWifiSmeP2pStatus) 0x03) -#define CSR_WIFI_SME_P2P_STATUS_FAIL_INVALID_PARAM ((CsrWifiSmeP2pStatus) 0x04) -#define CSR_WIFI_SME_P2P_STATUS_FAIL_ACCOMODATE ((CsrWifiSmeP2pStatus) 0x05) -#define CSR_WIFI_SME_P2P_STATUS_FAIL_PREV_ERROR ((CsrWifiSmeP2pStatus) 0x06) -#define CSR_WIFI_SME_P2P_STATUS_FAIL_COMMON_CHANNELS ((CsrWifiSmeP2pStatus) 0x07) -#define CSR_WIFI_SME_P2P_STATUS_FAIL_UNKNOWN_GROUP ((CsrWifiSmeP2pStatus) 0x08) -#define CSR_WIFI_SME_P2P_STATUS_FAIL_GO_INTENT ((CsrWifiSmeP2pStatus) 0x09) -#define CSR_WIFI_SME_P2P_STATUS_FAIL_PROVISION_METHOD_INCOMPATIBLE ((CsrWifiSmeP2pStatus) 0x0A) -#define CSR_WIFI_SME_P2P_STATUS_FAIL_REJECT ((CsrWifiSmeP2pStatus) 0x0B) -#define CSR_WIFI_SME_P2P_STATUS_FAIL_RESERVED ((CsrWifiSmeP2pStatus) 0xFF) - -/******************************************************************************* - - NAME - CsrWifiSmePacketFilterMode - - DESCRIPTION - Options for the filter mode parameter. - The Values here match the HIP interface - - VALUES - CSR_WIFI_SME_PACKET_FILTER_MODE_OPT_OUT - - Broadcast packets are always reported to the host unless - they match at least one of the specified TCLAS IEs. - CSR_WIFI_SME_PACKET_FILTER_MODE_OPT_IN - - Broadcast packets are reported to the host only if they - match at least one of the specified TCLAS IEs. - -*******************************************************************************/ -typedef u8 CsrWifiSmePacketFilterMode; -#define CSR_WIFI_SME_PACKET_FILTER_MODE_OPT_OUT ((CsrWifiSmePacketFilterMode) 0x00) -#define CSR_WIFI_SME_PACKET_FILTER_MODE_OPT_IN ((CsrWifiSmePacketFilterMode) 0x03) - -/******************************************************************************* - - NAME - CsrWifiSmePowerSaveLevel - - DESCRIPTION - Power Save Level options as defined in the IEEE 802.11 standards - First 3 values are set to match the mlme PowerManagementMode - - VALUES - CSR_WIFI_SME_POWER_SAVE_LEVEL_LOW - No power save: the driver will remain - active at all times - CSR_WIFI_SME_POWER_SAVE_LEVEL_HIGH - Enter power save after all packets in - the queues are transmitted and received - CSR_WIFI_SME_POWER_SAVE_LEVEL_MED - Enter power save after all packets in - the queues are transmitted and received - and a further configurable delay - (default 1s) has elapsed - CSR_WIFI_SME_POWER_SAVE_LEVEL_AUTO - The SME will decide when to enter power - save mode according to the traffic - analysis - -*******************************************************************************/ -typedef u8 CsrWifiSmePowerSaveLevel; -#define CSR_WIFI_SME_POWER_SAVE_LEVEL_LOW ((CsrWifiSmePowerSaveLevel) 0x00) -#define CSR_WIFI_SME_POWER_SAVE_LEVEL_HIGH ((CsrWifiSmePowerSaveLevel) 0x01) -#define CSR_WIFI_SME_POWER_SAVE_LEVEL_MED ((CsrWifiSmePowerSaveLevel) 0x02) -#define CSR_WIFI_SME_POWER_SAVE_LEVEL_AUTO ((CsrWifiSmePowerSaveLevel) 0x03) - -/******************************************************************************* - - NAME - CsrWifiSmePreambleType - - DESCRIPTION - SME Preamble Types - - VALUES - CSR_WIFI_SME_USE_LONG_PREAMBLE - Use legacy (long) preamble - CSR_WIFI_SME_USE_SHORT_PREAMBLE - Use short PPDU format - -*******************************************************************************/ -typedef u8 CsrWifiSmePreambleType; -#define CSR_WIFI_SME_USE_LONG_PREAMBLE ((CsrWifiSmePreambleType) 0x00) -#define CSR_WIFI_SME_USE_SHORT_PREAMBLE ((CsrWifiSmePreambleType) 0x01) - -/******************************************************************************* - - NAME - CsrWifiSmeRadioIF - - DESCRIPTION - Indicates the frequency - - VALUES - CSR_WIFI_SME_RADIO_IF_GHZ_2_4 - Indicates the 2.4 GHZ frequency - CSR_WIFI_SME_RADIO_IF_GHZ_5_0 - Future use: currently not supported - CSR_WIFI_SME_RADIO_IF_BOTH - Future use: currently not supported - -*******************************************************************************/ -typedef u8 CsrWifiSmeRadioIF; -#define CSR_WIFI_SME_RADIO_IF_GHZ_2_4 ((CsrWifiSmeRadioIF) 0x01) -#define CSR_WIFI_SME_RADIO_IF_GHZ_5_0 ((CsrWifiSmeRadioIF) 0x02) -#define CSR_WIFI_SME_RADIO_IF_BOTH ((CsrWifiSmeRadioIF) 0x03) - -/******************************************************************************* - - NAME - CsrWifiSmeRegulatoryDomain - - DESCRIPTION - Indicates the regulatory domain as defined in IEEE 802.11 standards - - VALUES - CSR_WIFI_SME_REGULATORY_DOMAIN_OTHER - - See IEEE 802.11 Standard - CSR_WIFI_SME_REGULATORY_DOMAIN_FCC - - See IEEE 802.11 Standard - CSR_WIFI_SME_REGULATORY_DOMAIN_IC - - See IEEE 802.11 Standard - CSR_WIFI_SME_REGULATORY_DOMAIN_ETSI - - See IEEE 802.11 Standard - CSR_WIFI_SME_REGULATORY_DOMAIN_SPAIN - - See IEEE 802.11 Standard - CSR_WIFI_SME_REGULATORY_DOMAIN_FRANCE - - See IEEE 802.11 Standard - CSR_WIFI_SME_REGULATORY_DOMAIN_JAPAN - - See IEEE 802.11 Standard - CSR_WIFI_SME_REGULATORY_DOMAIN_JAPANBIS - - See IEEE 802.11 Standard - CSR_WIFI_SME_REGULATORY_DOMAIN_CHINA - - See IEEE 802.11 Standard - CSR_WIFI_SME_REGULATORY_DOMAIN_CHINABIS - - See IEEE 802.11 Standard - CSR_WIFI_SME_REGULATORY_DOMAIN_NONE - - See IEEE 802.11 Standard - -*******************************************************************************/ -typedef u8 CsrWifiSmeRegulatoryDomain; -#define CSR_WIFI_SME_REGULATORY_DOMAIN_OTHER ((CsrWifiSmeRegulatoryDomain) 0x00) -#define CSR_WIFI_SME_REGULATORY_DOMAIN_FCC ((CsrWifiSmeRegulatoryDomain) 0x10) -#define CSR_WIFI_SME_REGULATORY_DOMAIN_IC ((CsrWifiSmeRegulatoryDomain) 0x20) -#define CSR_WIFI_SME_REGULATORY_DOMAIN_ETSI ((CsrWifiSmeRegulatoryDomain) 0x30) -#define CSR_WIFI_SME_REGULATORY_DOMAIN_SPAIN ((CsrWifiSmeRegulatoryDomain) 0x31) -#define CSR_WIFI_SME_REGULATORY_DOMAIN_FRANCE ((CsrWifiSmeRegulatoryDomain) 0x32) -#define CSR_WIFI_SME_REGULATORY_DOMAIN_JAPAN ((CsrWifiSmeRegulatoryDomain) 0x40) -#define CSR_WIFI_SME_REGULATORY_DOMAIN_JAPANBIS ((CsrWifiSmeRegulatoryDomain) 0x41) -#define CSR_WIFI_SME_REGULATORY_DOMAIN_CHINA ((CsrWifiSmeRegulatoryDomain) 0x50) -#define CSR_WIFI_SME_REGULATORY_DOMAIN_CHINABIS ((CsrWifiSmeRegulatoryDomain) 0x51) -#define CSR_WIFI_SME_REGULATORY_DOMAIN_NONE ((CsrWifiSmeRegulatoryDomain) 0xFF) - -/******************************************************************************* - - NAME - CsrWifiSmeRoamReason - - DESCRIPTION - Indicates the reason for roaming - - VALUES - CSR_WIFI_SME_ROAM_REASON_BEACONLOST - - The station cannot receive the beacon signal any more - CSR_WIFI_SME_ROAM_REASON_DISASSOCIATED - - The station has been disassociated - CSR_WIFI_SME_ROAM_REASON_DEAUTHENTICATED - - The station has been deauthenticated - CSR_WIFI_SME_ROAM_REASON_BETTERAPFOUND - - A better AP has been found - -*******************************************************************************/ -typedef u8 CsrWifiSmeRoamReason; -#define CSR_WIFI_SME_ROAM_REASON_BEACONLOST ((CsrWifiSmeRoamReason) 0x00) -#define CSR_WIFI_SME_ROAM_REASON_DISASSOCIATED ((CsrWifiSmeRoamReason) 0x01) -#define CSR_WIFI_SME_ROAM_REASON_DEAUTHENTICATED ((CsrWifiSmeRoamReason) 0x02) -#define CSR_WIFI_SME_ROAM_REASON_BETTERAPFOUND ((CsrWifiSmeRoamReason) 0x03) - -/******************************************************************************* - - NAME - CsrWifiSmeScanType - - DESCRIPTION - Identifies the type of scan to be performed - - VALUES - CSR_WIFI_SME_SCAN_TYPE_ALL - Scan actively or passively according to the - regulatory domain restrictions - CSR_WIFI_SME_SCAN_TYPE_ACTIVE - Scan actively only: send probes and listen - for answers - CSR_WIFI_SME_SCAN_TYPE_PASSIVE - Scan passively only: listen for beacon - messages - -*******************************************************************************/ -typedef u8 CsrWifiSmeScanType; -#define CSR_WIFI_SME_SCAN_TYPE_ALL ((CsrWifiSmeScanType) 0x00) -#define CSR_WIFI_SME_SCAN_TYPE_ACTIVE ((CsrWifiSmeScanType) 0x01) -#define CSR_WIFI_SME_SCAN_TYPE_PASSIVE ((CsrWifiSmeScanType) 0x02) - -/******************************************************************************* - - NAME - CsrWifiSmeTrafficType - - DESCRIPTION - Identifies the type of traffic going on on the connection. - The values of this type are used across the NME/SME/Router API's and they - must be kept consistent with the corresponding types in the .xml of the - ottherinterfaces - - VALUES - CSR_WIFI_SME_TRAFFIC_TYPE_OCCASIONAL - - During the last 30 seconds there were fewer than 20 packets - per seconds in each second in both directions - CSR_WIFI_SME_TRAFFIC_TYPE_BURSTY - - During the last 30 seconds there was at least one second - during which more than 20 packets were received in either - direction - CSR_WIFI_SME_TRAFFIC_TYPE_PERIODIC - - During the last 5 seconds there were at least 10 packets - received each second and a defined period for the traffic - can be recognized - CSR_WIFI_SME_TRAFFIC_TYPE_CONTINUOUS - - During the last 5 seconds there were at least 20 packets - received each second in either direction - -*******************************************************************************/ -typedef u8 CsrWifiSmeTrafficType; -#define CSR_WIFI_SME_TRAFFIC_TYPE_OCCASIONAL ((CsrWifiSmeTrafficType) 0x00) -#define CSR_WIFI_SME_TRAFFIC_TYPE_BURSTY ((CsrWifiSmeTrafficType) 0x01) -#define CSR_WIFI_SME_TRAFFIC_TYPE_PERIODIC ((CsrWifiSmeTrafficType) 0x02) -#define CSR_WIFI_SME_TRAFFIC_TYPE_CONTINUOUS ((CsrWifiSmeTrafficType) 0x03) - -/******************************************************************************* - - NAME - CsrWifiSmeTspecCtrl - - DESCRIPTION - Defines bits for CsrWifiSmeTspecCtrlMask for additional CCX configuration. - CURRENTLY NOT SUPPORTED. - - VALUES - CSR_WIFI_SME_TSPEC_CTRL_STRICT - - No automatic negotiation - CSR_WIFI_SME_TSPEC_CTRL_CCX_SIGNALLING - - Signalling TSPEC - CSR_WIFI_SME_TSPEC_CTRL_CCX_VOICE - - Voice traffic TSPEC - -*******************************************************************************/ -typedef u8 CsrWifiSmeTspecCtrl; -#define CSR_WIFI_SME_TSPEC_CTRL_STRICT ((CsrWifiSmeTspecCtrl) 0x01) -#define CSR_WIFI_SME_TSPEC_CTRL_CCX_SIGNALLING ((CsrWifiSmeTspecCtrl) 0x02) -#define CSR_WIFI_SME_TSPEC_CTRL_CCX_VOICE ((CsrWifiSmeTspecCtrl) 0x04) - -/******************************************************************************* - - NAME - CsrWifiSmeTspecResultCode - - DESCRIPTION - Defines the result of the TSPEC exchanges with the AP - - VALUES - CSR_WIFI_SME_TSPEC_RESULT_SUCCESS - - TSPEC command has been processed correctly - CSR_WIFI_SME_TSPEC_RESULT_UNSPECIFIED_QOS_FAILURE - - The Access Point reported a failure - CSR_WIFI_SME_TSPEC_RESULT_FAILURE - - Internal failure in the SME - CSR_WIFI_SME_TSPEC_RESULT_INVALID_TSPEC_PARAMETERS - - The TSPEC parameters are invalid - CSR_WIFI_SME_TSPEC_RESULT_INVALID_TCLAS_PARAMETERS - - The TCLASS parameters are invalid - CSR_WIFI_SME_TSPEC_RESULT_INSUFFICIENT_BANDWIDTH - - As specified by the WMM Spec - CSR_WIFI_SME_TSPEC_RESULT_WRONG_POLICY - - As specified by the WMM Spec - CSR_WIFI_SME_TSPEC_RESULT_REJECTED_WITH_SUGGESTED_CHANGES - - As specified by the WMM Spec - CSR_WIFI_SME_TSPEC_RESULT_TIMEOUT - - The TSPEC negotiation timed out - CSR_WIFI_SME_TSPEC_RESULT_NOT_SUPPORTED - - The Access Point does not support the TSPEC - CSR_WIFI_SME_TSPEC_RESULT_IE_LENGTH_INCORRECT - - The length of the TSPEC is not correct - CSR_WIFI_SME_TSPEC_RESULT_INVALID_TRANSACTION_ID - - The TSPEC transaction id is not in the list - CSR_WIFI_SME_TSPEC_RESULT_INSTALLED - - The TSPEC has been installed and it is now active. - CSR_WIFI_SME_TSPEC_RESULT_TID_ALREADY_INSTALLED - - The Traffic ID has already been installed - CSR_WIFI_SME_TSPEC_RESULT_TSPEC_REMOTELY_DELETED - - The AP has deleted the TSPEC - -*******************************************************************************/ -typedef u8 CsrWifiSmeTspecResultCode; -#define CSR_WIFI_SME_TSPEC_RESULT_SUCCESS ((CsrWifiSmeTspecResultCode) 0x00) -#define CSR_WIFI_SME_TSPEC_RESULT_UNSPECIFIED_QOS_FAILURE ((CsrWifiSmeTspecResultCode) 0x01) -#define CSR_WIFI_SME_TSPEC_RESULT_FAILURE ((CsrWifiSmeTspecResultCode) 0x02) -#define CSR_WIFI_SME_TSPEC_RESULT_INVALID_TSPEC_PARAMETERS ((CsrWifiSmeTspecResultCode) 0x05) -#define CSR_WIFI_SME_TSPEC_RESULT_INVALID_TCLAS_PARAMETERS ((CsrWifiSmeTspecResultCode) 0x06) -#define CSR_WIFI_SME_TSPEC_RESULT_INSUFFICIENT_BANDWIDTH ((CsrWifiSmeTspecResultCode) 0x07) -#define CSR_WIFI_SME_TSPEC_RESULT_WRONG_POLICY ((CsrWifiSmeTspecResultCode) 0x08) -#define CSR_WIFI_SME_TSPEC_RESULT_REJECTED_WITH_SUGGESTED_CHANGES ((CsrWifiSmeTspecResultCode) 0x09) -#define CSR_WIFI_SME_TSPEC_RESULT_TIMEOUT ((CsrWifiSmeTspecResultCode) 0x0D) -#define CSR_WIFI_SME_TSPEC_RESULT_NOT_SUPPORTED ((CsrWifiSmeTspecResultCode) 0x0E) -#define CSR_WIFI_SME_TSPEC_RESULT_IE_LENGTH_INCORRECT ((CsrWifiSmeTspecResultCode) 0x10) -#define CSR_WIFI_SME_TSPEC_RESULT_INVALID_TRANSACTION_ID ((CsrWifiSmeTspecResultCode) 0x11) -#define CSR_WIFI_SME_TSPEC_RESULT_INSTALLED ((CsrWifiSmeTspecResultCode) 0x12) -#define CSR_WIFI_SME_TSPEC_RESULT_TID_ALREADY_INSTALLED ((CsrWifiSmeTspecResultCode) 0x13) -#define CSR_WIFI_SME_TSPEC_RESULT_TSPEC_REMOTELY_DELETED ((CsrWifiSmeTspecResultCode) 0x14) - -/******************************************************************************* - - NAME - CsrWifiSmeWepAuthMode - - DESCRIPTION - Define bits for CsrWifiSmeWepAuthMode - - VALUES - CSR_WIFI_SME_WEP_AUTH_MODE_OPEN - Open-WEP enabled network - CSR_WIFI_SME_WEP_AUTH_MODE_SHARED - Shared-key WEP enabled network. - -*******************************************************************************/ -typedef u8 CsrWifiSmeWepAuthMode; -#define CSR_WIFI_SME_WEP_AUTH_MODE_OPEN ((CsrWifiSmeWepAuthMode) 0x00) -#define CSR_WIFI_SME_WEP_AUTH_MODE_SHARED ((CsrWifiSmeWepAuthMode) 0x01) - -/******************************************************************************* - - NAME - CsrWifiSmeWepCredentialType - - DESCRIPTION - Definition of types of WEP Credentials - - VALUES - CSR_WIFI_SME_CREDENTIAL_TYPE_WEP64 - - WEP 64 credential - CSR_WIFI_SME_CREDENTIAL_TYPE_WEP128 - - WEP 128 credential - -*******************************************************************************/ -typedef u8 CsrWifiSmeWepCredentialType; -#define CSR_WIFI_SME_CREDENTIAL_TYPE_WEP64 ((CsrWifiSmeWepCredentialType) 0x00) -#define CSR_WIFI_SME_CREDENTIAL_TYPE_WEP128 ((CsrWifiSmeWepCredentialType) 0x01) - -/******************************************************************************* - - NAME - CsrWifiSmeWmmMode - - DESCRIPTION - Defines bits for CsrWifiSmeWmmModeMask: enable/disable WMM features. - - VALUES - CSR_WIFI_SME_WMM_MODE_DISABLED - Disables the WMM features. - CSR_WIFI_SME_WMM_MODE_AC_ENABLED - Enables support for WMM-AC. - CSR_WIFI_SME_WMM_MODE_PS_ENABLED - Enables support for WMM Power Save. - CSR_WIFI_SME_WMM_MODE_SA_ENABLED - Currently not supported - CSR_WIFI_SME_WMM_MODE_ENABLED - Enables support for all currently - available WMM features. - -*******************************************************************************/ -typedef u8 CsrWifiSmeWmmMode; -#define CSR_WIFI_SME_WMM_MODE_DISABLED ((CsrWifiSmeWmmMode) 0x00) -#define CSR_WIFI_SME_WMM_MODE_AC_ENABLED ((CsrWifiSmeWmmMode) 0x01) -#define CSR_WIFI_SME_WMM_MODE_PS_ENABLED ((CsrWifiSmeWmmMode) 0x02) -#define CSR_WIFI_SME_WMM_MODE_SA_ENABLED ((CsrWifiSmeWmmMode) 0x04) -#define CSR_WIFI_SME_WMM_MODE_ENABLED ((CsrWifiSmeWmmMode) 0xFF) - -/******************************************************************************* - - NAME - CsrWifiSmeWmmQosInfo - - DESCRIPTION - Defines bits for the QoS Info Octect as defined in the WMM specification. - The first four values define one bit each that can be set or cleared. - Each of the last four values define all the remaining 4 bits and only one - of them at the time shall be used. - For more information, see 'WMM (including WMM Power Save) Specification - - Version 1.1' and 'UniFi Configuring WMM and WMM-PS, Application Note'. - - VALUES - CSR_WIFI_SME_WMM_QOS_INFO_AC_MAX_SP_ALL - - WMM AP may deliver all buffered frames - CSR_WIFI_SME_WMM_QOS_INFO_AC_VO - - Enable UAPSD(both trigger and delivery) for Voice Access - Category - CSR_WIFI_SME_WMM_QOS_INFO_AC_VI - - Enable UAPSD(both trigger and delivery) for Video Access - Category - CSR_WIFI_SME_WMM_QOS_INFO_AC_BK - - Enable UAPSD(both trigger and delivery) for Background - Access Category - CSR_WIFI_SME_WMM_QOS_INFO_AC_BE - - Enable UAPSD(both trigger and delivery) for Best Effort - Access Category - CSR_WIFI_SME_WMM_QOS_INFO_AC_MAX_SP_TWO - - WMM AP may deliver a maximum of 2 buffered frames (MSDUs - and MMPDUs) per USP - CSR_WIFI_SME_WMM_QOS_INFO_AC_MAX_SP_FOUR - - WMM AP may deliver a maximum of 4 buffered frames (MSDUs - and MMPDUs) per USP - CSR_WIFI_SME_WMM_QOS_INFO_AC_MAX_SP_SIX - - WMM AP may deliver a maximum of 6 buffered frames (MSDUs - and MMPDUs) per USP - -*******************************************************************************/ -typedef u8 CsrWifiSmeWmmQosInfo; -#define CSR_WIFI_SME_WMM_QOS_INFO_AC_MAX_SP_ALL ((CsrWifiSmeWmmQosInfo) 0x00) -#define CSR_WIFI_SME_WMM_QOS_INFO_AC_VO ((CsrWifiSmeWmmQosInfo) 0x01) -#define CSR_WIFI_SME_WMM_QOS_INFO_AC_VI ((CsrWifiSmeWmmQosInfo) 0x02) -#define CSR_WIFI_SME_WMM_QOS_INFO_AC_BK ((CsrWifiSmeWmmQosInfo) 0x04) -#define CSR_WIFI_SME_WMM_QOS_INFO_AC_BE ((CsrWifiSmeWmmQosInfo) 0x08) -#define CSR_WIFI_SME_WMM_QOS_INFO_AC_MAX_SP_TWO ((CsrWifiSmeWmmQosInfo) 0x20) -#define CSR_WIFI_SME_WMM_QOS_INFO_AC_MAX_SP_FOUR ((CsrWifiSmeWmmQosInfo) 0x40) -#define CSR_WIFI_SME_WMM_QOS_INFO_AC_MAX_SP_SIX ((CsrWifiSmeWmmQosInfo) 0x60) - -/******************************************************************************* - - NAME - CsrWifiSmeWpsConfigType - - DESCRIPTION - WPS config methods supported/used by a device - - VALUES - CSR_WIFI_WPS_CONFIG_LABEL - - Label - CSR_WIFI_WPS_CONFIG_DISPLAY - - Display - CSR_WIFI_WPS_CONFIG_EXT_NFC - - External NFC : Not supported in this release - CSR_WIFI_WPS_CONFIG_INT_NFC - - Internal NFC : Not supported in this release - CSR_WIFI_WPS_CONFIG_NFC_IFACE - - NFC interface : Not supported in this release - CSR_WIFI_WPS_CONFIG_PBC - - PBC - CSR_WIFI_WPS_CONFIG_KEYPAD - - KeyPad - CSR_WIFI_WPS_CONFIG_VIRTUAL_PBC - - PBC through software user interface - CSR_WIFI_WPS_CONFIG_PHYSICAL_PBC - - Physical PBC - CSR_WIFI_WPS_CONFIG_VIRTUAL_DISPLAY - - Virtual Display : via html config page etc - CSR_WIFI_WPS_CONFIG_PHYSICAL_DISPLAY - - Physical Display : Attached to the device - -*******************************************************************************/ -typedef u16 CsrWifiSmeWpsConfigType; -#define CSR_WIFI_WPS_CONFIG_LABEL ((CsrWifiSmeWpsConfigType) 0x0004) -#define CSR_WIFI_WPS_CONFIG_DISPLAY ((CsrWifiSmeWpsConfigType) 0x0008) -#define CSR_WIFI_WPS_CONFIG_EXT_NFC ((CsrWifiSmeWpsConfigType) 0x0010) -#define CSR_WIFI_WPS_CONFIG_INT_NFC ((CsrWifiSmeWpsConfigType) 0x0020) -#define CSR_WIFI_WPS_CONFIG_NFC_IFACE ((CsrWifiSmeWpsConfigType) 0x0040) -#define CSR_WIFI_WPS_CONFIG_PBC ((CsrWifiSmeWpsConfigType) 0x0080) -#define CSR_WIFI_WPS_CONFIG_KEYPAD ((CsrWifiSmeWpsConfigType) 0x0100) -#define CSR_WIFI_WPS_CONFIG_VIRTUAL_PBC ((CsrWifiSmeWpsConfigType) 0x0280) -#define CSR_WIFI_WPS_CONFIG_PHYSICAL_PBC ((CsrWifiSmeWpsConfigType) 0x0480) -#define CSR_WIFI_WPS_CONFIG_VIRTUAL_DISPLAY ((CsrWifiSmeWpsConfigType) 0x2008) -#define CSR_WIFI_WPS_CONFIG_PHYSICAL_DISPLAY ((CsrWifiSmeWpsConfigType) 0x4008) - -/******************************************************************************* - - NAME - CsrWifiSmeWpsDeviceCategory - - DESCRIPTION - Wps Primary Device Types - - VALUES - CSR_WIFI_SME_WPS_CATEGORY_UNSPECIFIED - - Unspecified. - CSR_WIFI_SME_WPS_CATEGORY_COMPUTER - - Computer. - CSR_WIFI_SME_WPS_CATEGORY_INPUT_DEV - - Input device - CSR_WIFI_SME_WPS_CATEGORY_PRT_SCAN_FX_CP - - Printer Scanner Fax Copier etc - CSR_WIFI_SME_WPS_CATEGORY_CAMERA - - Camera - CSR_WIFI_SME_WPS_CATEGORY_STORAGE - - Storage - CSR_WIFI_SME_WPS_CATEGORY_NET_INFRA - - Net Infra - CSR_WIFI_SME_WPS_CATEGORY_DISPLAY - - Display - CSR_WIFI_SME_WPS_CATEGORY_MULTIMEDIA - - Multimedia - CSR_WIFI_SME_WPS_CATEGORY_GAMING - - Gaming. - CSR_WIFI_SME_WPS_CATEGORY_TELEPHONE - - Telephone. - CSR_WIFI_SME_WPS_CATEGORY_AUDIO - - Audio - CSR_WIFI_SME_WPS_CATEOARY_OTHERS - - Others. - -*******************************************************************************/ -typedef u8 CsrWifiSmeWpsDeviceCategory; -#define CSR_WIFI_SME_WPS_CATEGORY_UNSPECIFIED ((CsrWifiSmeWpsDeviceCategory) 0x00) -#define CSR_WIFI_SME_WPS_CATEGORY_COMPUTER ((CsrWifiSmeWpsDeviceCategory) 0x01) -#define CSR_WIFI_SME_WPS_CATEGORY_INPUT_DEV ((CsrWifiSmeWpsDeviceCategory) 0x02) -#define CSR_WIFI_SME_WPS_CATEGORY_PRT_SCAN_FX_CP ((CsrWifiSmeWpsDeviceCategory) 0x03) -#define CSR_WIFI_SME_WPS_CATEGORY_CAMERA ((CsrWifiSmeWpsDeviceCategory) 0x04) -#define CSR_WIFI_SME_WPS_CATEGORY_STORAGE ((CsrWifiSmeWpsDeviceCategory) 0x05) -#define CSR_WIFI_SME_WPS_CATEGORY_NET_INFRA ((CsrWifiSmeWpsDeviceCategory) 0x06) -#define CSR_WIFI_SME_WPS_CATEGORY_DISPLAY ((CsrWifiSmeWpsDeviceCategory) 0x07) -#define CSR_WIFI_SME_WPS_CATEGORY_MULTIMEDIA ((CsrWifiSmeWpsDeviceCategory) 0x08) -#define CSR_WIFI_SME_WPS_CATEGORY_GAMING ((CsrWifiSmeWpsDeviceCategory) 0x09) -#define CSR_WIFI_SME_WPS_CATEGORY_TELEPHONE ((CsrWifiSmeWpsDeviceCategory) 0x0A) -#define CSR_WIFI_SME_WPS_CATEGORY_AUDIO ((CsrWifiSmeWpsDeviceCategory) 0x0B) -#define CSR_WIFI_SME_WPS_CATEOARY_OTHERS ((CsrWifiSmeWpsDeviceCategory) 0xFF) - -/******************************************************************************* - - NAME - CsrWifiSmeWpsDeviceSubCategory - - DESCRIPTION - Wps Secondary Device Types - - VALUES - CSR_WIFI_SME_WPS_SUB_CATEGORY_UNSPECIFIED - - Unspecied - CSR_WIFI_SME_WPS_STORAGE_SUB_CATEGORY_NAS - - Network Associated Storage - CSR_WIFI_SME_WPS_PSFC_SUB_CATEGORY_PRNTR - - Printer or print server - CSR_WIFI_SME_WPS_TELEPHONE_SUB_CATEGORY_WM - - Windows mobile - CSR_WIFI_SME_WPS_AUDIO_SUB_CATEGORY_TUNER - - Audio tuner/receiver - CSR_WIFI_SME_WPS_CAMERA_SUB_CATEGORY_DIG_STL - - Digital still camera - CSR_WIFI_SME_WPS_NET_INFRA_SUB_CATEGORY_AP - - Access Point - CSR_WIFI_SME_WPS_DISPLAY_SUB_CATEGORY_TV - - TV. - CSR_WIFI_SME_WPS_MM_SUB_CATEGORY_DAR - - DAR. - CSR_WIFI_SME_WPS_INPUT_DEV_SUB_CATEGORY_KEYBD - - Keyboard. - CSR_WIFI_SME_WPS_COMPUTER_SUB_CATEGORY_PC - - PC. - CSR_WIFI_SME_WPS_GAMING_SUB_CATEGORY_XBOX - - Xbox. - CSR_WIFI_SME_WPS_PSFC_SUB_CATEGORY_SCNR - - Scanner - CSR_WIFI_SME_WPS_COMPUTER_SUB_CATEGORY_SERVER - - Server - CSR_WIFI_SME_WPS_NET_INFRA_SUB_CATEGORY_ROUTER - - Router - CSR_WIFI_SME_WPS_MM_SUB_CATEGORY_PVR - - PVR - CSR_WIFI_SME_WPS_AUDIO_SUB_CATEGORY_SPEAKER - - Speaker - CSR_WIFI_SME_WPS_TELEPHONE_SUB_CATEGORY_FP_SM - - Feature phone - Single mode - CSR_WIFI_SME_WPS_CAMERA_SUB_CATEGORY_VIDEO - - Video camera - CSR_WIFI_SME_WPS_DISPLAY_SUB_CATEGORY_PIC_FRM - - Picture frame - CSR_WIFI_SME_WPS_GAMING_SUB_CATEGORY_XBOX_360 - - Xbox360 - CSR_WIFI_SME_WPS_INPUT_DEV_SUB_CATEGORY_MOUSE - - Mouse - CSR_WIFI_SME_WPS_NET_INFRA_SUB_CATEGORY_SWITCH - - Switch - CSR_WIFI_SME_WPS_AUDIO_SUB_CATEGORY_PMP - - Portable music player - CSR_WIFI_SME_WPS_INPUT_DEV_SUB_CATEGORY_JOYSTK - - Joy stick - CSR_WIFI_SME_WPS_GAMING_SUB_CATEGORY_PLAY_STN - - Play-station - CSR_WIFI_SME_WPS_COMPUTER_SUB_CATEGORY_MED_CENT - - Media Center - CSR_WIFI_SME_WPS_MM_SUB_CATEGORY_MCX - - MCX - CSR_WIFI_SME_WPS_TELEPHONE_SUB_CATEGORY_FP_DM - - Feature phone - Dual mode - CSR_WIFI_SME_WPS_CAMERA_SUB_CATEGORY_WEB - - Web camera - CSR_WIFI_SME_WPS_PSFC_SUB_CATEGORY_FAX - - Fax - CSR_WIFI_SME_WPS_DISPLAY_SUB_CATEGORY_PROJECTOR - - Projector - CSR_WIFI_SME_WPS_INPUT_DEV_SUB_CATEGORY_TRKBL - - Track Ball - CSR_WIFI_SME_WPS_MM_SUB_CATEGORY_ST_BOX - - Set-Top-Box - CSR_WIFI_SME_WPS_NET_INFRA_SUB_CATEGORY_GATEWAY - - GateWay. - CSR_WIFI_SME_WPS_CAMERA_SUB_CATEGORY_SECURITY - - Security camera - CSR_WIFI_SME_WPS_COMPUTER_SUB_CATEGORY_ULTRA_MOB_PC - - Ultra mobile PC. - CSR_WIFI_SME_WPS_GAMING_SUB_CATEGORY_CONSOLE - - Game console/Game console adapter - CSR_WIFI_SME_WPS_PSFC_SUB_CATEGORY_CPR - - Copier - CSR_WIFI_SME_WPS_AUDIO_SUB_CATEGORY_HEADSET - - Headset(headphones + microphone) - CSR_WIFI_SME_WPS_TELEPHONE_SUB_CATEGORY_SP_SM - - Smart phone - Single mode - CSR_WIFI_SME_WPS_DISPLAY_SUB_CATEGORY_MONITOR - - Monitor. - CSR_WIFI_SME_WPS_INPUT_DEV_SUB_CATEGORY_GAME_CTRL - - Game control. - CSR_WIFI_SME_WPS_PSFC_SUB_CATEGORY_ALL - - All-in-One - CSR_WIFI_SME_WPS_MM_SUB_CATEGORY_MEDIA - - Media Server/Media Adapter/Media Extender - CSR_WIFI_SME_WPS_TELEPHONE_SUB_CATEGORY_SP_DM - - Smart phone - Dual mode - CSR_WIFI_SME_WPS_GAMING_SUB_CATEGORY_PORT_DEV - - Portable gaming device - CSR_WIFI_SME_WPS_AUDIO_SUB_CATEGORY_HEADPHONE - - Headphone. - CSR_WIFI_SME_WPS_COMPUTER_SUB_CATEGORY_NOTEBOOK - - Notebook. - CSR_WIFI_SME_WPS_INPUT_DEV_SUB_CATEGORY_REMOTE - - Remote control - CSR_WIFI_SME_WPS_AUDIO_SUB_CATEGORY_MIC - - Microphone - CSR_WIFI_SME_WPS_COMPUTER_SUB_CATEGORY_DESKTOP - - Desktop. - CSR_WIFI_SME_WPS_MM_SUB_CATEGORY_VP - - Portable video player - CSR_WIFI_SME_WPS_COMPUTER_SUB_CATEGORY_MID - - Mobile internet device - CSR_WIFI_SME_WPS_INPUT_DEV_SUB_CATEGORY_TOUCH_SCRN - - Touch screen - CSR_WIFI_SME_WPS_INPUT_DEV_SUB_CATEGORY_BIOMET_RDR - - Biometric reader - CSR_WIFI_SME_WPS_COMPUTER_SUB_CATEGORY_NETBOOK - - Netbook - CSR_WIFI_SME_WPS_INPUT_DEV_SUB_CATEGORY_BRCD_RDR - - Bar code reader. - -*******************************************************************************/ -typedef u8 CsrWifiSmeWpsDeviceSubCategory; -#define CSR_WIFI_SME_WPS_SUB_CATEGORY_UNSPECIFIED ((CsrWifiSmeWpsDeviceSubCategory) 0x00) -#define CSR_WIFI_SME_WPS_STORAGE_SUB_CATEGORY_NAS ((CsrWifiSmeWpsDeviceSubCategory) 0x01) -#define CSR_WIFI_SME_WPS_PSFC_SUB_CATEGORY_PRNTR ((CsrWifiSmeWpsDeviceSubCategory) 0x01) -#define CSR_WIFI_SME_WPS_TELEPHONE_SUB_CATEGORY_WM ((CsrWifiSmeWpsDeviceSubCategory) 0x01) -#define CSR_WIFI_SME_WPS_AUDIO_SUB_CATEGORY_TUNER ((CsrWifiSmeWpsDeviceSubCategory) 0x01) -#define CSR_WIFI_SME_WPS_CAMERA_SUB_CATEGORY_DIG_STL ((CsrWifiSmeWpsDeviceSubCategory) 0x01) -#define CSR_WIFI_SME_WPS_NET_INFRA_SUB_CATEGORY_AP ((CsrWifiSmeWpsDeviceSubCategory) 0x01) -#define CSR_WIFI_SME_WPS_DISPLAY_SUB_CATEGORY_TV ((CsrWifiSmeWpsDeviceSubCategory) 0x01) -#define CSR_WIFI_SME_WPS_MM_SUB_CATEGORY_DAR ((CsrWifiSmeWpsDeviceSubCategory) 0x01) -#define CSR_WIFI_SME_WPS_INPUT_DEV_SUB_CATEGORY_KEYBD ((CsrWifiSmeWpsDeviceSubCategory) 0x01) -#define CSR_WIFI_SME_WPS_COMPUTER_SUB_CATEGORY_PC ((CsrWifiSmeWpsDeviceSubCategory) 0x01) -#define CSR_WIFI_SME_WPS_GAMING_SUB_CATEGORY_XBOX ((CsrWifiSmeWpsDeviceSubCategory) 0x01) -#define CSR_WIFI_SME_WPS_PSFC_SUB_CATEGORY_SCNR ((CsrWifiSmeWpsDeviceSubCategory) 0x02) -#define CSR_WIFI_SME_WPS_COMPUTER_SUB_CATEGORY_SERVER ((CsrWifiSmeWpsDeviceSubCategory) 0x02) -#define CSR_WIFI_SME_WPS_NET_INFRA_SUB_CATEGORY_ROUTER ((CsrWifiSmeWpsDeviceSubCategory) 0x02) -#define CSR_WIFI_SME_WPS_MM_SUB_CATEGORY_PVR ((CsrWifiSmeWpsDeviceSubCategory) 0x02) -#define CSR_WIFI_SME_WPS_AUDIO_SUB_CATEGORY_SPEAKER ((CsrWifiSmeWpsDeviceSubCategory) 0x02) -#define CSR_WIFI_SME_WPS_TELEPHONE_SUB_CATEGORY_FP_SM ((CsrWifiSmeWpsDeviceSubCategory) 0x02) -#define CSR_WIFI_SME_WPS_CAMERA_SUB_CATEGORY_VIDEO ((CsrWifiSmeWpsDeviceSubCategory) 0x02) -#define CSR_WIFI_SME_WPS_DISPLAY_SUB_CATEGORY_PIC_FRM ((CsrWifiSmeWpsDeviceSubCategory) 0x02) -#define CSR_WIFI_SME_WPS_GAMING_SUB_CATEGORY_XBOX_360 ((CsrWifiSmeWpsDeviceSubCategory) 0x02) -#define CSR_WIFI_SME_WPS_INPUT_DEV_SUB_CATEGORY_MOUSE ((CsrWifiSmeWpsDeviceSubCategory) 0x02) -#define CSR_WIFI_SME_WPS_NET_INFRA_SUB_CATEGORY_SWITCH ((CsrWifiSmeWpsDeviceSubCategory) 0x03) -#define CSR_WIFI_SME_WPS_AUDIO_SUB_CATEGORY_PMP ((CsrWifiSmeWpsDeviceSubCategory) 0x03) -#define CSR_WIFI_SME_WPS_INPUT_DEV_SUB_CATEGORY_JOYSTK ((CsrWifiSmeWpsDeviceSubCategory) 0x03) -#define CSR_WIFI_SME_WPS_GAMING_SUB_CATEGORY_PLAY_STN ((CsrWifiSmeWpsDeviceSubCategory) 0x03) -#define CSR_WIFI_SME_WPS_COMPUTER_SUB_CATEGORY_MED_CENT ((CsrWifiSmeWpsDeviceSubCategory) 0x03) -#define CSR_WIFI_SME_WPS_MM_SUB_CATEGORY_MCX ((CsrWifiSmeWpsDeviceSubCategory) 0x03) -#define CSR_WIFI_SME_WPS_TELEPHONE_SUB_CATEGORY_FP_DM ((CsrWifiSmeWpsDeviceSubCategory) 0x03) -#define CSR_WIFI_SME_WPS_CAMERA_SUB_CATEGORY_WEB ((CsrWifiSmeWpsDeviceSubCategory) 0x03) -#define CSR_WIFI_SME_WPS_PSFC_SUB_CATEGORY_FAX ((CsrWifiSmeWpsDeviceSubCategory) 0x03) -#define CSR_WIFI_SME_WPS_DISPLAY_SUB_CATEGORY_PROJECTOR ((CsrWifiSmeWpsDeviceSubCategory) 0x03) -#define CSR_WIFI_SME_WPS_INPUT_DEV_SUB_CATEGORY_TRKBL ((CsrWifiSmeWpsDeviceSubCategory) 0x04) -#define CSR_WIFI_SME_WPS_MM_SUB_CATEGORY_ST_BOX ((CsrWifiSmeWpsDeviceSubCategory) 0x04) -#define CSR_WIFI_SME_WPS_NET_INFRA_SUB_CATEGORY_GATEWAY ((CsrWifiSmeWpsDeviceSubCategory) 0x04) -#define CSR_WIFI_SME_WPS_CAMERA_SUB_CATEGORY_SECURITY ((CsrWifiSmeWpsDeviceSubCategory) 0x04) -#define CSR_WIFI_SME_WPS_COMPUTER_SUB_CATEGORY_ULTRA_MOB_PC ((CsrWifiSmeWpsDeviceSubCategory) 0x04) -#define CSR_WIFI_SME_WPS_GAMING_SUB_CATEGORY_CONSOLE ((CsrWifiSmeWpsDeviceSubCategory) 0x04) -#define CSR_WIFI_SME_WPS_PSFC_SUB_CATEGORY_CPR ((CsrWifiSmeWpsDeviceSubCategory) 0x04) -#define CSR_WIFI_SME_WPS_AUDIO_SUB_CATEGORY_HEADSET ((CsrWifiSmeWpsDeviceSubCategory) 0x04) -#define CSR_WIFI_SME_WPS_TELEPHONE_SUB_CATEGORY_SP_SM ((CsrWifiSmeWpsDeviceSubCategory) 0x04) -#define CSR_WIFI_SME_WPS_DISPLAY_SUB_CATEGORY_MONITOR ((CsrWifiSmeWpsDeviceSubCategory) 0x04) -#define CSR_WIFI_SME_WPS_INPUT_DEV_SUB_CATEGORY_GAME_CTRL ((CsrWifiSmeWpsDeviceSubCategory) 0x05) -#define CSR_WIFI_SME_WPS_PSFC_SUB_CATEGORY_ALL ((CsrWifiSmeWpsDeviceSubCategory) 0x05) -#define CSR_WIFI_SME_WPS_MM_SUB_CATEGORY_MEDIA ((CsrWifiSmeWpsDeviceSubCategory) 0x05) -#define CSR_WIFI_SME_WPS_TELEPHONE_SUB_CATEGORY_SP_DM ((CsrWifiSmeWpsDeviceSubCategory) 0x05) -#define CSR_WIFI_SME_WPS_GAMING_SUB_CATEGORY_PORT_DEV ((CsrWifiSmeWpsDeviceSubCategory) 0x05) -#define CSR_WIFI_SME_WPS_AUDIO_SUB_CATEGORY_HEADPHONE ((CsrWifiSmeWpsDeviceSubCategory) 0x05) -#define CSR_WIFI_SME_WPS_COMPUTER_SUB_CATEGORY_NOTEBOOK ((CsrWifiSmeWpsDeviceSubCategory) 0x05) -#define CSR_WIFI_SME_WPS_INPUT_DEV_SUB_CATEGORY_REMOTE ((CsrWifiSmeWpsDeviceSubCategory) 0x06) -#define CSR_WIFI_SME_WPS_AUDIO_SUB_CATEGORY_MIC ((CsrWifiSmeWpsDeviceSubCategory) 0x06) -#define CSR_WIFI_SME_WPS_COMPUTER_SUB_CATEGORY_DESKTOP ((CsrWifiSmeWpsDeviceSubCategory) 0x06) -#define CSR_WIFI_SME_WPS_MM_SUB_CATEGORY_VP ((CsrWifiSmeWpsDeviceSubCategory) 0x06) -#define CSR_WIFI_SME_WPS_COMPUTER_SUB_CATEGORY_MID ((CsrWifiSmeWpsDeviceSubCategory) 0x07) -#define CSR_WIFI_SME_WPS_INPUT_DEV_SUB_CATEGORY_TOUCH_SCRN ((CsrWifiSmeWpsDeviceSubCategory) 0x07) -#define CSR_WIFI_SME_WPS_INPUT_DEV_SUB_CATEGORY_BIOMET_RDR ((CsrWifiSmeWpsDeviceSubCategory) 0x08) -#define CSR_WIFI_SME_WPS_COMPUTER_SUB_CATEGORY_NETBOOK ((CsrWifiSmeWpsDeviceSubCategory) 0x08) -#define CSR_WIFI_SME_WPS_INPUT_DEV_SUB_CATEGORY_BRCD_RDR ((CsrWifiSmeWpsDeviceSubCategory) 0x09) - -/******************************************************************************* - - NAME - CsrWifiSmeWpsDpid - - DESCRIPTION - Device Password ID for the chosen config method - - VALUES - CSR_WIFI_SME_WPS_DPID_PIN - PIN - CSR_WIFI_SME_WPS_DPID_USER - User specified : Used only during P2P GO - negotiation procedure - CSR_WIFI_SME_WPS_DPID_MACHINE - Machine specified i: Not used in this - release - CSR_WIFI_SME_WPS_DPID_REKEY - Rekey : Not used in this release - CSR_WIFI_SME_WPS_DPID_PBC - PBC - CSR_WIFI_SME_WPS_DPID_REGISTRAR - Registrar specified : Used only in P2P Go - negotiation procedure - -*******************************************************************************/ -typedef u16 CsrWifiSmeWpsDpid; -#define CSR_WIFI_SME_WPS_DPID_PIN ((CsrWifiSmeWpsDpid) 0x0000) -#define CSR_WIFI_SME_WPS_DPID_USER ((CsrWifiSmeWpsDpid) 0x0001) -#define CSR_WIFI_SME_WPS_DPID_MACHINE ((CsrWifiSmeWpsDpid) 0x0002) -#define CSR_WIFI_SME_WPS_DPID_REKEY ((CsrWifiSmeWpsDpid) 0x0003) -#define CSR_WIFI_SME_WPS_DPID_PBC ((CsrWifiSmeWpsDpid) 0x0004) -#define CSR_WIFI_SME_WPS_DPID_REGISTRAR ((CsrWifiSmeWpsDpid) 0x0005) - -/******************************************************************************* - - NAME - CsrWifiSmeWpsRegistration - - DESCRIPTION - - VALUES - CSR_WIFI_SME_WPS_REG_NOT_REQUIRED - No encryption set - CSR_WIFI_SME_WPS_REG_REQUIRED - No encryption set - CSR_WIFI_SME_WPS_REG_UNKNOWN - No encryption set - -*******************************************************************************/ -typedef u8 CsrWifiSmeWpsRegistration; -#define CSR_WIFI_SME_WPS_REG_NOT_REQUIRED ((CsrWifiSmeWpsRegistration) 0x00) -#define CSR_WIFI_SME_WPS_REG_REQUIRED ((CsrWifiSmeWpsRegistration) 0x01) -#define CSR_WIFI_SME_WPS_REG_UNKNOWN ((CsrWifiSmeWpsRegistration) 0x02) - - -/******************************************************************************* - - NAME - CsrWifiSmeAuthModeMask - - DESCRIPTION - Mask type for use with the values defined by CsrWifiSmeAuthMode - -*******************************************************************************/ -typedef u16 CsrWifiSmeAuthModeMask; -/******************************************************************************* - - NAME - CsrWifiSmeEncryptionMask - - DESCRIPTION - Mask type for use with the values defined by CsrWifiSmeEncryption - -*******************************************************************************/ -typedef u16 CsrWifiSmeEncryptionMask; -/******************************************************************************* - - NAME - CsrWifiSmeIndicationsMask - - DESCRIPTION - Mask type for use with the values defined by CsrWifiSmeIndications - -*******************************************************************************/ -typedef u32 CsrWifiSmeIndicationsMask; -/******************************************************************************* - - NAME - CsrWifiSmeP2pCapabilityMask - - DESCRIPTION - Mask type for use with the values defined by CsrWifiSmeP2pCapability - -*******************************************************************************/ -typedef u8 CsrWifiSmeP2pCapabilityMask; -/******************************************************************************* - - NAME - CsrWifiSmeP2pGroupCapabilityMask - - DESCRIPTION - Mask type for use with the values defined by CsrWifiSmeP2pGroupCapability - -*******************************************************************************/ -typedef u8 CsrWifiSmeP2pGroupCapabilityMask; -/******************************************************************************* - - NAME - CsrWifiSmeTspecCtrlMask - - DESCRIPTION - Mask type for use with the values defined by CsrWifiSmeTspecCtrl - -*******************************************************************************/ -typedef u8 CsrWifiSmeTspecCtrlMask; -/******************************************************************************* - - NAME - CsrWifiSmeWmmModeMask - - DESCRIPTION - Mask type for use with the values defined by CsrWifiSmeWmmMode - -*******************************************************************************/ -typedef u8 CsrWifiSmeWmmModeMask; -/******************************************************************************* - - NAME - CsrWifiSmeWmmQosInfoMask - - DESCRIPTION - Mask type for use with the values defined by CsrWifiSmeWmmQosInfo - -*******************************************************************************/ -typedef u8 CsrWifiSmeWmmQosInfoMask; -/******************************************************************************* - - NAME - CsrWifiSmeWpsConfigTypeMask - - DESCRIPTION - Mask type for use with the values defined by CsrWifiSmeWpsConfigType - -*******************************************************************************/ -typedef u16 CsrWifiSmeWpsConfigTypeMask; - - -/******************************************************************************* - - NAME - CsrWifiSmeAdHocConfig - - DESCRIPTION - Defines values to use when starting an Ad-hoc (IBSS) network. - - MEMBERS - atimWindowTu - ATIM window specified for IBSS - beaconPeriodTu - Interval between beacon packets - joinOnlyAttempts - Maximum number of attempts to join an ad-hoc network. - The default value is 1. - Set to 0 for infinite attempts. - joinAttemptIntervalMs - Time between scans for joining the requested IBSS. - -*******************************************************************************/ -typedef struct -{ - u16 atimWindowTu; - u16 beaconPeriodTu; - u16 joinOnlyAttempts; - u16 joinAttemptIntervalMs; -} CsrWifiSmeAdHocConfig; - -/******************************************************************************* - - NAME - CsrWifiSmeAvailabilityConfig - - DESCRIPTION - - MEMBERS - listenChannel - - availabilityDuration - - avalabilityPeriod - - -*******************************************************************************/ -typedef struct -{ - u8 listenChannel; - u16 availabilityDuration; - u16 avalabilityPeriod; -} CsrWifiSmeAvailabilityConfig; - -/******************************************************************************* - - NAME - CsrWifiSmeCcxConfig - - DESCRIPTION - This type is reserved for future use and should not be used. - - MEMBERS - keepAliveTimeMs - NOT USED - apRoamingEnabled - NOT USED - measurementsMask - NOT USED - ccxRadioMgtEnabled - NOT USED - -*******************************************************************************/ -typedef struct -{ - u8 keepAliveTimeMs; - u8 apRoamingEnabled; - u8 measurementsMask; - u8 ccxRadioMgtEnabled; -} CsrWifiSmeCcxConfig; - -/******************************************************************************* - - NAME - CsrWifiSmeCoexConfig - - DESCRIPTION - Parameters for the coexistence behaviour. - - MEMBERS - coexEnableSchemeManagement - Enables the Coexistence Management Scheme - coexPeriodicWakeHost - If TRUE the firmware wakes up the host - periodically according to the traffic - period and latency parameters; the host - will then send the data to transmit only - when woken up. - If FALSE, the firmware does not wake up the - host and the host will send the data to - transmit to the firmware whenever there is - data to transmit - coexTrafficBurstyLatencyMs - Period of awakening for the firmware used - when bursty traffic is detected - coexTrafficContinuousLatencyMs - Period of awakening for the firmware used - when continuous traffic is detected - coexObexBlackoutDurationMs - Blackout Duration when a Obex Connection is - used - coexObexBlackoutPeriodMs - Blackout Period when a Obex Connection is - used - coexA2dpBrBlackoutDurationMs - Blackout Duration when a Basic Rate A2DP - Connection streaming data - coexA2dpBrBlackoutPeriodMs - Blackout Period when a Basic Rate A2DP - Connection streaming data - coexA2dpEdrBlackoutDurationMs - Blackout Duration when an Enhanced Data - Rate A2DP Connection streaming data - coexA2dpEdrBlackoutPeriodMs - Blackout Period when an Enhanced Data Rate - A2DP Connection streaming data - coexPagingBlackoutDurationMs - Blackout Duration when a BT page is active - coexPagingBlackoutPeriodMs - Blackout Period when a BT page is active - coexInquiryBlackoutDurationMs - Blackout Duration when a BT inquiry is - active - coexInquiryBlackoutPeriodMs - Blackout Period when a BT inquiry is active - -*******************************************************************************/ -typedef struct -{ - u8 coexEnableSchemeManagement; - u8 coexPeriodicWakeHost; - u16 coexTrafficBurstyLatencyMs; - u16 coexTrafficContinuousLatencyMs; - u16 coexObexBlackoutDurationMs; - u16 coexObexBlackoutPeriodMs; - u16 coexA2dpBrBlackoutDurationMs; - u16 coexA2dpBrBlackoutPeriodMs; - u16 coexA2dpEdrBlackoutDurationMs; - u16 coexA2dpEdrBlackoutPeriodMs; - u16 coexPagingBlackoutDurationMs; - u16 coexPagingBlackoutPeriodMs; - u16 coexInquiryBlackoutDurationMs; - u16 coexInquiryBlackoutPeriodMs; -} CsrWifiSmeCoexConfig; - -/******************************************************************************* - - NAME - CsrWifiSmeConnectionStats - - DESCRIPTION - Indicates the statistics of the connection. - The dot11 fields are defined in the Annex D of the IEEE 802.11 standard. - - MEMBERS - unifiTxDataRate - - The bit rate currently in use for transmissions of unicast - data frames; a data rate in units of 500kbit/s. - On an infrastructure BSS, this is the data rate used in - communicating with the associated access point; if there is - none, an error is returned. - On an IBSS, this is the data rate used for the last - transmission of a unicast data frame to any station in the - IBSS. If no such transmission has been made, an error is - returned. - unifiRxDataRate - - As above for receiving data - dot11RetryCount - - See IEEE 802.11 Standard - dot11MultipleRetryCount - - See IEEE 802.11 Standard - dot11AckFailureCount - - See IEEE 802.11 Standard - dot11FrameDuplicateCount - - See IEEE 802.11 Standard - dot11FcsErrorCount - - See IEEE 802.11 Standard - dot11RtsSuccessCount - - See IEEE 802.11 Standard - dot11RtsFailureCount - - See IEEE 802.11 Standard - dot11FailedCount - - See IEEE 802.11 Standard - dot11TransmittedFragmentCount - - See IEEE 802.11 Standard - dot11TransmittedFrameCount - - See IEEE 802.11 Standard - dot11WepExcludedCount - - See IEEE 802.11 Standard - dot11WepIcvErrorCount - - See IEEE 802.11 Standard - dot11WepUndecryptableCount - - See IEEE 802.11 Standard - dot11MulticastReceivedFrameCount - - See IEEE 802.11 Standard - dot11MulticastTransmittedFrameCount - - See IEEE 802.11 Standard - dot11ReceivedFragmentCount - - See IEEE 802.11 Standard - dot11Rsna4WayHandshakeFailures - - See IEEE 802.11 Standard - dot11RsnaTkipCounterMeasuresInvoked - - See IEEE 802.11 Standard - dot11RsnaStatsTkipLocalMicFailures - - See IEEE 802.11 Standard - dot11RsnaStatsTkipReplays - - See IEEE 802.11 Standard - dot11RsnaStatsTkipIcvErrors - - See IEEE 802.11 Standard - dot11RsnaStatsCcmpReplays - - See IEEE 802.11 Standard - dot11RsnaStatsCcmpDecryptErrors - - See IEEE 802.11 Standard - -*******************************************************************************/ -typedef struct -{ - u8 unifiTxDataRate; - u8 unifiRxDataRate; - u32 dot11RetryCount; - u32 dot11MultipleRetryCount; - u32 dot11AckFailureCount; - u32 dot11FrameDuplicateCount; - u32 dot11FcsErrorCount; - u32 dot11RtsSuccessCount; - u32 dot11RtsFailureCount; - u32 dot11FailedCount; - u32 dot11TransmittedFragmentCount; - u32 dot11TransmittedFrameCount; - u32 dot11WepExcludedCount; - u32 dot11WepIcvErrorCount; - u32 dot11WepUndecryptableCount; - u32 dot11MulticastReceivedFrameCount; - u32 dot11MulticastTransmittedFrameCount; - u32 dot11ReceivedFragmentCount; - u32 dot11Rsna4WayHandshakeFailures; - u32 dot11RsnaTkipCounterMeasuresInvoked; - u32 dot11RsnaStatsTkipLocalMicFailures; - u32 dot11RsnaStatsTkipReplays; - u32 dot11RsnaStatsTkipIcvErrors; - u32 dot11RsnaStatsCcmpReplays; - u32 dot11RsnaStatsCcmpDecryptErrors; -} CsrWifiSmeConnectionStats; - -/******************************************************************************* - - NAME - CsrWifiSmeDataBlock - - DESCRIPTION - Holds a generic data block to be passed through the interface - - MEMBERS - length - Length of the data block - data - Points to the first byte of the data block - -*******************************************************************************/ -typedef struct -{ - u16 length; - u8 *data; -} CsrWifiSmeDataBlock; - -/******************************************************************************* - - NAME - CsrWifiSmeEmpty - - DESCRIPTION - Empty Structure to indicate that no parameters are available. - - MEMBERS - empty - Only element of the empty structure (always set to 0). - -*******************************************************************************/ -typedef struct -{ - u8 empty; -} CsrWifiSmeEmpty; - -/******************************************************************************* - - NAME - CsrWifiSmeLinkQuality - - DESCRIPTION - Indicates the quality of the link - - MEMBERS - unifiRssi - Indicates the received signal strength indication of the link in - dBm - unifiSnr - Indicates the signal to noise ratio of the link in dB - -*******************************************************************************/ -typedef struct -{ - s16 unifiRssi; - s16 unifiSnr; -} CsrWifiSmeLinkQuality; - -/******************************************************************************* - - NAME - CsrWifiSmeMibConfig - - DESCRIPTION - Allows low level configuration in the chip. - - MEMBERS - unifiFixMaxTxDataRate - This attribute is used in combination with - unifiFixTxDataRate. If it is FALSE, then - unifiFixTxDataRate specifies a specific data - rate to use. If it is TRUE, unifiFixTxDataRate - instead specifies a maximum data rate. - unifiFixTxDataRate - Transmit rate for unicast data. - See MIB description for more details - dot11RtsThreshold - See IEEE 802.11 Standard - dot11FragmentationThreshold - See IEEE 802.11 Standard - dot11CurrentTxPowerLevel - See IEEE 802.11 Standard - -*******************************************************************************/ -typedef struct -{ - u8 unifiFixMaxTxDataRate; - u8 unifiFixTxDataRate; - u16 dot11RtsThreshold; - u16 dot11FragmentationThreshold; - u16 dot11CurrentTxPowerLevel; -} CsrWifiSmeMibConfig; - -/******************************************************************************* - - NAME - CsrWifiSmeP2pProfileIdentity - - DESCRIPTION - Details to be filled in - - MEMBERS - listenChannel - - availabilityDuration - - avalabilityPeriod - - -*******************************************************************************/ -typedef struct -{ - u8 listenChannel; - u16 availabilityDuration; - u16 avalabilityPeriod; -} CsrWifiSmeP2pProfileIdentity; - -/******************************************************************************* - - NAME - CsrWifiSmePmkid - - DESCRIPTION - Defines a PMKID association with BSS - - MEMBERS - bssid - BSS identifier - pmkid - PMKID - -*******************************************************************************/ -typedef struct -{ - CsrWifiMacAddress bssid; - u8 pmkid[16]; -} CsrWifiSmePmkid; - -/******************************************************************************* - - NAME - CsrWifiSmePmkidCandidate - - DESCRIPTION - Information for a PMKID candidate - - MEMBERS - bssid - BSS identifier - preAuthAllowed - Indicates whether preauthentication is allowed - -*******************************************************************************/ -typedef struct -{ - CsrWifiMacAddress bssid; - u8 preAuthAllowed; -} CsrWifiSmePmkidCandidate; - -/******************************************************************************* - - NAME - CsrWifiSmePmkidList - - DESCRIPTION - NOT USED - Used in the Sync access API - - MEMBERS - pmkidsCount - Number of PMKIDs in the list - pmkids - Points to the first PMKID in the list - -*******************************************************************************/ -typedef struct -{ - u8 pmkidsCount; - CsrWifiSmePmkid *pmkids; -} CsrWifiSmePmkidList; - -/******************************************************************************* - - NAME - CsrWifiSmeRegulatoryDomainInfo - - DESCRIPTION - Regulatory domain options. - - MEMBERS - dot11MultiDomainCapabilityImplemented - - TRUE is the multi domain capability is implemented - dot11MultiDomainCapabilityEnabled - - TRUE is the multi domain capability is enabled - currentRegulatoryDomain - - Current regulatory domain - currentCountryCode - - Current country code as defined by the IEEE 802.11 - standards - -*******************************************************************************/ -typedef struct -{ - u8 dot11MultiDomainCapabilityImplemented; - u8 dot11MultiDomainCapabilityEnabled; - CsrWifiSmeRegulatoryDomain currentRegulatoryDomain; - u8 currentCountryCode[2]; -} CsrWifiSmeRegulatoryDomainInfo; - -/******************************************************************************* - - NAME - CsrWifiSmeRoamingBandData - - DESCRIPTION - Thresholds to define one usability level category for the received signal - - MEMBERS - rssiHighThreshold - Received Signal Strength Indication upper bound in dBm - for the usability level - rssiLowThreshold - Received Signal Strength Indication lower bound in dBm - for the usability level - snrHighThreshold - Signal to Noise Ratio upper bound in dB for the - usability level - snrLowThreshold - Signal to Noise Ratio lower bound in dB for the - usability level - -*******************************************************************************/ -typedef struct -{ - s16 rssiHighThreshold; - s16 rssiLowThreshold; - s16 snrHighThreshold; - s16 snrLowThreshold; -} CsrWifiSmeRoamingBandData; - -/******************************************************************************* - - NAME - CsrWifiSmeScanConfigData - - DESCRIPTION - Configures the scanning behaviour of the driver and firmware - - MEMBERS - intervalSeconds - All the channels will be scanned once in this time - interval. - If connected, the channel scans are spread across - the interval. - If disconnected, all the channels will be scanned - together - validitySeconds - How long the scan result are cached - minActiveChannelTimeTu - Minimum time of listening on a channel being - actively scanned before leaving if no probe - responses or beacon frames have been received - maxActiveChannelTimeTu - Maximum time of listening on a channel being - actively scanned - minPassiveChannelTimeTu - Minimum time of listening on a channel being - passive scanned before leaving if no beacon frames - have been received - maxPassiveChannelTimeTu - Maximum time of listening on a channel being - passively scanned - -*******************************************************************************/ -typedef struct -{ - u16 intervalSeconds; - u16 validitySeconds; - u16 minActiveChannelTimeTu; - u16 maxActiveChannelTimeTu; - u16 minPassiveChannelTimeTu; - u16 maxPassiveChannelTimeTu; -} CsrWifiSmeScanConfigData; - -/******************************************************************************* - - NAME - CsrWifiSmeTsfTime - - DESCRIPTION - Time stamp representation - - MEMBERS - data - TSF Bytes - -*******************************************************************************/ -typedef struct -{ - u8 data[8]; -} CsrWifiSmeTsfTime; - -/******************************************************************************* - - NAME - CsrWifiSmeVersions - - DESCRIPTION - Reports version information for the chip, the firmware and the driver and - the SME. - - MEMBERS - chipId - Chip ID - chipVersion - Chip version ID - firmwareBuild - Firmware Rom build number - firmwarePatch - Firmware Patch build number (if applicable) - firmwareHip - Firmware HIP protocol version number - routerBuild - Router build number - routerHip - Router HIP protocol version number - smeBuild - SME build number - smeHip - SME HIP protocol version number - -*******************************************************************************/ -typedef struct -{ - u32 chipId; - u32 chipVersion; - u32 firmwareBuild; - u32 firmwarePatch; - u32 firmwareHip; - char *routerBuild; - u32 routerHip; - char *smeBuild; - u32 smeHip; -} CsrWifiSmeVersions; - -/******************************************************************************* - - NAME - CsrWifiSmeWmmAcParams - - DESCRIPTION - Structure holding WMM AC params data. - - MEMBERS - cwMin - Exponent for the calculation of CWmin. Range: 0 - to 15 - cwMax - Exponent for the calculation of CWmax. Range: 0 - to15 - aifs - Arbitration Inter Frame Spacing in terms of - number of timeslots. Range 2 to 15 - txopLimit - TXOP Limit in the units of 32 microseconds - admissionControlMandatory - Indicates whether the admission control is - mandatory or not. Current release does not - support admission control , hence shall be set - to FALSE. - -*******************************************************************************/ -typedef struct -{ - u8 cwMin; - u8 cwMax; - u8 aifs; - u16 txopLimit; - u8 admissionControlMandatory; -} CsrWifiSmeWmmAcParams; - -/******************************************************************************* - - NAME - CsrWifiSmeWpsDeviceType - - DESCRIPTION - Structure holding AP WPS device type data. - - MEMBERS - deviceDetails - category , sub category etc - -*******************************************************************************/ -typedef struct -{ - u8 deviceDetails[8]; -} CsrWifiSmeWpsDeviceType; - -/******************************************************************************* - - NAME - CsrWifiSmeWpsDeviceTypeCommon - - DESCRIPTION - - MEMBERS - spportWps - - deviceType - - -*******************************************************************************/ -typedef struct -{ - u8 spportWps; - u8 deviceType; -} CsrWifiSmeWpsDeviceTypeCommon; - -/******************************************************************************* - - NAME - CsrWifiSmeWpsInfo - - DESCRIPTION - - MEMBERS - version - - configMethods - - devicePassworId - - -*******************************************************************************/ -typedef struct -{ - u16 version; - u16 configMethods; - u16 devicePassworId; -} CsrWifiSmeWpsInfo; - -/******************************************************************************* - - NAME - CsrWifiSmeCloakedSsidConfig - - DESCRIPTION - List of cloaked SSIDs . - - MEMBERS - cloakedSsidsCount - Number of cloaked SSID - cloakedSsids - Points to the first byte of the first SSID provided - -*******************************************************************************/ -typedef struct -{ - u8 cloakedSsidsCount; - CsrWifiSsid *cloakedSsids; -} CsrWifiSmeCloakedSsidConfig; - -/******************************************************************************* - - NAME - CsrWifiSmeCoexInfo - - DESCRIPTION - Information and state related to coexistence. - - MEMBERS - hasTrafficData - TRUE if any Wi-Fi traffic is detected - currentTrafficType - Current type of traffic - currentPeriodMs - Period of the traffic as detected by the traffic - analysis. - If the traffic is not periodic, it is set to 0. - currentPowerSave - Current power save level - currentCoexPeriodMs - Period of awakening for the firmware used when - periodic traffic is detected. - If the traffic is not periodic, it is set to 0. - currentCoexLatencyMs - Period of awakening for the firmware used when - non-periodic traffic is detected - hasBtDevice - TRUE if there is a Bluetooth device connected - currentBlackoutDurationUs - Current blackout duration for protecting - Bluetooth - currentBlackoutPeriodUs - Current blackout period - currentCoexScheme - Defines the scheme for the coexistence - signalling - -*******************************************************************************/ -typedef struct -{ - u8 hasTrafficData; - CsrWifiSmeTrafficType currentTrafficType; - u16 currentPeriodMs; - CsrWifiSmePowerSaveLevel currentPowerSave; - u16 currentCoexPeriodMs; - u16 currentCoexLatencyMs; - u8 hasBtDevice; - u32 currentBlackoutDurationUs; - u32 currentBlackoutPeriodUs; - CsrWifiSmeCoexScheme currentCoexScheme; -} CsrWifiSmeCoexInfo; - -/******************************************************************************* - - NAME - CsrWifiSmeConnectionConfig - - DESCRIPTION - Specifies the parameters that the SME should use in selecting a network. - - MEMBERS - ssid - - Service Set identifier - bssid - - BSS identifier - bssType - - Indicates the type of BSS - ifIndex - - Indicates the radio interface - privacyMode - - Specifies whether the privacy mode is enabled or disabled. - authModeMask - - Sets the authentication options that the SME can use while - associating to the AP - Set mask with values from CsrWifiSmeAuthMode - encryptionModeMask - - Sets the encryption options that the SME can use while - associating to the AP - Set mask with values from CsrWifiSmeEncryption - mlmeAssociateReqInformationElementsLength - - Length in bytes of information elements to be sent in the - Association Request. - mlmeAssociateReqInformationElements - - Points to the first byte of the information elements, if - any. - wmmQosInfo - - This parameter allows the driver's WMM behaviour to be - configured. - To enable support for WMM, use - CSR_WIFI_SME_SME_CONFIG_SET_REQ with the - CSR_WIFI_SME_WMM_MODE_AC_ENABLED bit set in wmmModeMask - field in smeConfig parameter. - Set mask with values from CsrWifiSmeWmmQosInfo - adhocJoinOnly - - This parameter is relevant only if bssType is NOT set to - CSR_WIFI_SME_BSS_TYPE_INFRASTRUCTURE: - if TRUE the SME will only try to join an ad-hoc network if - there is one already established; - if FALSE the SME will try to join an ad-hoc network if - there is one already established or it will try to - establish a new one - adhocChannel - - This parameter is relevant only if bssType is NOT set to - CSR_WIFI_SME_BSS_TYPE_INFRASTRUCTURE: - it indicates the channel to use joining an ad hoc network. - Setting this to 0 causes the SME to select a channel from - those permitted in the regulatory domain. - -*******************************************************************************/ -typedef struct -{ - CsrWifiSsid ssid; - CsrWifiMacAddress bssid; - CsrWifiSmeBssType bssType; - CsrWifiSmeRadioIF ifIndex; - CsrWifiSme80211PrivacyMode privacyMode; - CsrWifiSmeAuthModeMask authModeMask; - CsrWifiSmeEncryptionMask encryptionModeMask; - u16 mlmeAssociateReqInformationElementsLength; - u8 *mlmeAssociateReqInformationElements; - CsrWifiSmeWmmQosInfoMask wmmQosInfo; - u8 adhocJoinOnly; - u8 adhocChannel; -} CsrWifiSmeConnectionConfig; - -/******************************************************************************* - - NAME - CsrWifiSmeConnectionInfo - - DESCRIPTION - Parameters that the SME should use in selecting a network - - MEMBERS - ssid - Service set identifier - bssid - BSS identifier - networkType80211 - Physical layer used for the connection - channelNumber - Channel number - channelFrequency - Channel frequency - authMode - Authentication mode used for the connection - pairwiseCipher - Encryption type for peer to peer communication - groupCipher - Encryption type for broadcast and multicast - communication - ifIndex - Indicates the radio interface - atimWindowTu - ATIM window specified for IBSS - beaconPeriodTu - Interval between beacon packets - reassociation - Indicates whether a reassociation occurred - beaconFrameLength - Indicates the number of bytes of the beacon - frame - beaconFrame - Points at the first byte of the beacon frame - associationReqFrameLength - Indicates the number of bytes of the - association request frame - associationReqFrame - Points at the first byte of the association - request frame - associationRspFrameLength - Indicates the number of bytes of the - association response frame - associationRspFrame - Points at the first byte of the association - response frame - assocScanInfoElementsLength - Indicates the number of bytes in the buffer - pointed by assocScanInfoElements - assocScanInfoElements - Pointer to the buffer containing the - information elements of the probe response - received after the probe requests sent before - attempting to authenticate to the network - assocReqCapabilities - Reports the content of the Capability - information element as specified in the - association request. - assocReqListenIntervalTu - Listen Interval specified in the association - request - assocReqApAddress - AP address to which the association requests - has been sent - assocReqInfoElementsLength - Indicates the number of bytes of the - association request information elements - assocReqInfoElements - Points at the first byte of the association - request information elements - assocRspResult - Result reported in the association response - assocRspCapabilityInfo - Reports the content of the Capability - information element as received in the - association response. - assocRspAssociationId - Reports the association ID received in the - association response. - assocRspInfoElementsLength - Indicates the number of bytes of the - association response information elements - assocRspInfoElements - Points at the first byte of the association - response information elements - -*******************************************************************************/ -typedef struct -{ - CsrWifiSsid ssid; - CsrWifiMacAddress bssid; - CsrWifiSme80211NetworkType networkType80211; - u8 channelNumber; - u16 channelFrequency; - CsrWifiSmeAuthMode authMode; - CsrWifiSmeEncryption pairwiseCipher; - CsrWifiSmeEncryption groupCipher; - CsrWifiSmeRadioIF ifIndex; - u16 atimWindowTu; - u16 beaconPeriodTu; - u8 reassociation; - u16 beaconFrameLength; - u8 *beaconFrame; - u16 associationReqFrameLength; - u8 *associationReqFrame; - u16 associationRspFrameLength; - u8 *associationRspFrame; - u16 assocScanInfoElementsLength; - u8 *assocScanInfoElements; - u16 assocReqCapabilities; - u16 assocReqListenIntervalTu; - CsrWifiMacAddress assocReqApAddress; - u16 assocReqInfoElementsLength; - u8 *assocReqInfoElements; - CsrWifiSmeIEEE80211Result assocRspResult; - u16 assocRspCapabilityInfo; - u16 assocRspAssociationId; - u16 assocRspInfoElementsLength; - u8 *assocRspInfoElements; -} CsrWifiSmeConnectionInfo; - -/******************************************************************************* - - NAME - CsrWifiSmeDeviceConfig - - DESCRIPTION - General configuration options in the SME - - MEMBERS - trustLevel - Level of trust of the information coming from the - network - countryCode - Country code as specified by IEEE 802.11 standard - firmwareDriverInterface - Specifies the type of communication between Host - and Firmware - enableStrictDraftN - If TRUE TKIP is disallowed when connecting to - 802.11n enabled access points - -*******************************************************************************/ -typedef struct -{ - CsrWifiSme80211dTrustLevel trustLevel; - u8 countryCode[2]; - CsrWifiSmeFirmwareDriverInterface firmwareDriverInterface; - u8 enableStrictDraftN; -} CsrWifiSmeDeviceConfig; - -/******************************************************************************* - - NAME - CsrWifiSmeDeviceInfo - - DESCRIPTION - P2P Information for a P2P Device - - MEMBERS - deviceAddress - Device Address of the P2P device - configMethods - Supported WPS configuration methods. - p2PDeviceCap - P2P device capabilities - primDeviceType - Primary WPS device type - secondaryDeviceTypeCount - Number of secondary device types - secDeviceType - list of secondary WPS device types - deviceName - Device name without up to 32 characters'\0'. - deviceNameLength - Number of characters of the device name - -*******************************************************************************/ -typedef struct -{ - CsrWifiMacAddress deviceAddress; - CsrWifiSmeWpsConfigTypeMask configMethods; - CsrWifiSmeP2pCapabilityMask p2PDeviceCap; - CsrWifiSmeWpsDeviceType primDeviceType; - u8 secondaryDeviceTypeCount; - CsrWifiSmeWpsDeviceType *secDeviceType; - u8 deviceName[32]; - u8 deviceNameLength; -} CsrWifiSmeDeviceInfo; - -/******************************************************************************* - - NAME - CsrWifiSmeDeviceInfoCommon - - DESCRIPTION - Structure holding device information. - - MEMBERS - p2pDeviceAddress - - primaryDeviceType - - secondaryDeviceTypesCount - - secondaryDeviceTypes - - deviceNameLength - - deviceName - - -*******************************************************************************/ -typedef struct -{ - CsrWifiMacAddress p2pDeviceAddress; - CsrWifiSmeWpsDeviceTypeCommon primaryDeviceType; - u8 secondaryDeviceTypesCount; - u8 secondaryDeviceTypes[10]; - u8 deviceNameLength; - u8 deviceName[32]; -} CsrWifiSmeDeviceInfoCommon; - -/******************************************************************************* - - NAME - CsrWifiSmeHostConfig - - DESCRIPTION - Defines the host power state (for example, on mains power, on battery - power etc) and the periodicity of the traffic data. - - MEMBERS - powerMode - The wireless manager application should use the - powerMode parameter to inform the SME of the host - power state. - applicationDataPeriodMs - The applicationDataPeriodMs parameter allows a - wireless manager application to inform the SME - that an application is running that generates - periodic network traffic and the period of the - traffic. - An example of such an application is a VoIP client. - The wireless manager application should set - applicationDataPeriodMs to the period in - milliseconds between data packets or zero if no - periodic application is running. - Voip etc 0 = No Periodic Data - -*******************************************************************************/ -typedef struct -{ - CsrWifiSmeHostPowerMode powerMode; - u16 applicationDataPeriodMs; -} CsrWifiSmeHostConfig; - -/******************************************************************************* - - NAME - CsrWifiSmeKey - - DESCRIPTION - Information for a key to be used for encryption - - MEMBERS - keyType - Specifies whether the key is a pairwise or group key; it - should be set to CSR_WIFI_SME_GROUP_KEY or - CSR_WIFI_SME_PAIRWISE_KEY, as required. - keyIndex - Specifies which WEP key (0-3) to set; it should be set to 0 - for a WPA/WPA2 pairwise key and non-zero for a WPA/WPA2 - group key. - wepTxKey - If wepTxKey is TRUE, and the key is a WEP key, the key will - be selected for encrypting transmitted packets. - To select a previously defined key as the transmit - encryption key, set keyIndex to the required key, wepTxKey - to TRUE and the keyLength to 0. - keyRsc - Key Receive Sequence Counter - authenticator - If TRUE the WMA will act as authenticator. - CURRENTLY NOT SUPPORTED - address - BSS identifier of the AP - keyLength - Length of the key in bytes - key - Points to the first byte of the key - -*******************************************************************************/ -typedef struct -{ - CsrWifiSmeKeyType keyType; - u8 keyIndex; - u8 wepTxKey; - u16 keyRsc[8]; - u8 authenticator; - CsrWifiMacAddress address; - u8 keyLength; - u8 key[32]; -} CsrWifiSmeKey; - -/******************************************************************************* - - NAME - CsrWifiSmeP2pClientInfoType - - DESCRIPTION - P2P Information for a P2P Client - - MEMBERS - p2PClientInterfaceAddress - MAC address of the P2P Client - clientDeviceInfo - Device Information - -*******************************************************************************/ -typedef struct -{ - CsrWifiMacAddress p2PClientInterfaceAddress; - CsrWifiSmeDeviceInfo clientDeviceInfo; -} CsrWifiSmeP2pClientInfoType; - -/******************************************************************************* - - NAME - CsrWifiSmeP2pGroupInfo - - DESCRIPTION - P2P Information for a P2P Group - - MEMBERS - groupCapability - P2P group capabilities - p2pDeviceAddress - Device Address of the GO - p2pClientInfoCount - Number of P2P Clients that belong to the group. - p2PClientInfo - Pointer to the list containing client information for - each client in the group - -*******************************************************************************/ -typedef struct -{ - CsrWifiSmeP2pGroupCapabilityMask groupCapability; - CsrWifiMacAddress p2pDeviceAddress; - u8 p2pClientInfoCount; - CsrWifiSmeP2pClientInfoType *p2PClientInfo; -} CsrWifiSmeP2pGroupInfo; - -/******************************************************************************* - - NAME - CsrWifiSmePowerConfig - - DESCRIPTION - Configures the power-save behaviour of the driver and firmware. - - MEMBERS - powerSaveLevel - Power Save Level option - listenIntervalTu - Interval for waking to receive beacon frames - rxDtims - If TRUE, wake for DTIM every beacon period, to - allow the reception broadcast packets - d3AutoScanMode - Defines whether the autonomous scanning will be - turned off or will stay on during a D3 suspended - period - clientTrafficWindow - Deprecated - opportunisticPowerSave - Deprecated - noticeOfAbsence - Deprecated - -*******************************************************************************/ -typedef struct -{ - CsrWifiSmePowerSaveLevel powerSaveLevel; - u16 listenIntervalTu; - u8 rxDtims; - CsrWifiSmeD3AutoScanMode d3AutoScanMode; - u8 clientTrafficWindow; - u8 opportunisticPowerSave; - u8 noticeOfAbsence; -} CsrWifiSmePowerConfig; - -/******************************************************************************* - - NAME - CsrWifiSmeRoamingConfig - - DESCRIPTION - Configures the roaming behaviour of the driver and firmware - - MEMBERS - roamingBands - Defines the thresholds to determine the usability - level of the current connection. - roamingBands is indexed by the first 3 entries of - the CsrWifiSmeBasicUsability enum - disableSmoothRoaming - Disable the RSSI/SNR triggers from the Firmware - that the SME uses to detect the quality of the - connection. - This implicitly disables disableRoamScans - disableRoamScans - Disables the scanning for the roaming operation - reconnectLimit - Maximum number of times SME may reconnect in the - given interval - reconnectLimitIntervalMs - Interval for maximum number of times SME may - reconnect to the same Access Point - roamScanCfg - Scanning behaviour for the specifically aimed at - improving roaming performance. - roamScanCfg is indexed by the first 3 entries of - the CsrWifiSmeBasicUsability enum - -*******************************************************************************/ -typedef struct -{ - CsrWifiSmeRoamingBandData roamingBands[3]; - u8 disableSmoothRoaming; - u8 disableRoamScans; - u8 reconnectLimit; - u16 reconnectLimitIntervalMs; - CsrWifiSmeScanConfigData roamScanCfg[3]; -} CsrWifiSmeRoamingConfig; - -/******************************************************************************* - - NAME - CsrWifiSmeScanConfig - - DESCRIPTION - Parameters for the autonomous scanning behaviour of the system - - MEMBERS - scanCfg - Scan configuration data. - Indexed by the CsrWifiSmeBasicUsability enum - disableAutonomousScans - Enables or disables the autonomous scan - maxResults - Maximum number of results to be cached in the SME - highRssiThreshold - High received signal strength indication threshold - in dBm for an AP above which the system will - report scan indications - lowRssiThreshold - Low received signal strength indication threshold - in dBm for an AP below which the system will - report scan indications - deltaRssiThreshold - Minimum difference for received signal strength - indication in dBm for an AP which trigger a scan - indication to be sent. - highSnrThreshold - High Signal to Noise Ratio threshold in dB for an - AP above which the system will report scan - indications - lowSnrThreshold - Low Signal to Noise Ratio threshold in dB for an - AP below which the system will report scan - indications - deltaSnrThreshold - Minimum difference for Signal to Noise Ratio in dB - for an AP which trigger a scan indication to be - sent. - passiveChannelListCount - Number of channels to be scanned passively. - passiveChannelList - Points to the first channel to be scanned - passively , if any. - -*******************************************************************************/ -typedef struct -{ - CsrWifiSmeScanConfigData scanCfg[4]; - u8 disableAutonomousScans; - u16 maxResults; - s8 highRssiThreshold; - s8 lowRssiThreshold; - s8 deltaRssiThreshold; - s8 highSnrThreshold; - s8 lowSnrThreshold; - s8 deltaSnrThreshold; - u16 passiveChannelListCount; - u8 *passiveChannelList; -} CsrWifiSmeScanConfig; - -/******************************************************************************* - - NAME - CsrWifiSmeScanResult - - DESCRIPTION - This structure defines the scan result for each BSS found - - MEMBERS - ssid - Service set identifier - bssid - BSS identifier - rssi - Received signal strength indication in dBm - snr - Signal to noise ratio in dB - ifIndex - Indicates the radio interface - beaconPeriodTu - Interval between beacon frames - timeStamp - Timestamp in the BSS - localTime - Timestamp in the Access Point - channelFrequency - Channel frequency - capabilityInformation - Capabilities of the BSS. - channelNumber - Channel number - usability - Indicates the usability level. - bssType - Type of BSS. - informationElementsLength - Number of bytes of the information elements - received as part of the beacon or probe - response. - informationElements - Points to the first byte of the IEs received - as part of the beacon or probe response. - The format of the IEs is as specified in the - IEEE 802.11 specification. - p2pDeviceRole - Role of the P2P device. - Relevant only if bssType is - CSR_WIFI_SME_BSS_TYPE_P2P - deviceInfo - Union containing P2P device info which - depends on p2pDeviceRole parameter. - deviceInforeservedCli - - deviceInfogroupInfo - - deviceInforeservedNone - - deviceInfostandalonedevInfo - - -*******************************************************************************/ -typedef struct -{ - CsrWifiSsid ssid; - CsrWifiMacAddress bssid; - s16 rssi; - s16 snr; - CsrWifiSmeRadioIF ifIndex; - u16 beaconPeriodTu; - CsrWifiSmeTsfTime timeStamp; - CsrWifiSmeTsfTime localTime; - u16 channelFrequency; - u16 capabilityInformation; - u8 channelNumber; - CsrWifiSmeBasicUsability usability; - CsrWifiSmeBssType bssType; - u16 informationElementsLength; - u8 *informationElements; - CsrWifiSmeP2pRole p2pDeviceRole; - union { - CsrWifiSmeEmpty reservedCli; - CsrWifiSmeP2pGroupInfo groupInfo; - CsrWifiSmeEmpty reservedNone; - CsrWifiSmeDeviceInfo standalonedevInfo; - } deviceInfo; -} CsrWifiSmeScanResult; - -/******************************************************************************* - - NAME - CsrWifiSmeStaConfig - - DESCRIPTION - Station configuration options in the SME - - MEMBERS - connectionQualityRssiChangeTrigger - Sets the difference of RSSI - measurements which triggers reports - from the Firmware - connectionQualitySnrChangeTrigger - Sets the difference of SNR measurements - which triggers reports from the - Firmware - wmmModeMask - Mask containing one or more values from - CsrWifiSmeWmmMode - ifIndex - Indicates the band of frequencies used - allowUnicastUseGroupCipher - If TRUE, it allows to use groupwise - keys if no pairwise key is specified - enableOpportunisticKeyCaching - If TRUE, enables the Opportunistic Key - Caching feature - -*******************************************************************************/ -typedef struct -{ - u8 connectionQualityRssiChangeTrigger; - u8 connectionQualitySnrChangeTrigger; - CsrWifiSmeWmmModeMask wmmModeMask; - CsrWifiSmeRadioIF ifIndex; - u8 allowUnicastUseGroupCipher; - u8 enableOpportunisticKeyCaching; -} CsrWifiSmeStaConfig; - -/******************************************************************************* - - NAME - CsrWifiSmeWep128Keys - - DESCRIPTION - Structure holding WEP Authentication Type and WEP keys that can be used - when using WEP128. - - MEMBERS - wepAuthType - Mask to select the WEP authentication type (Open or Shared) - selectedWepKey - Index to one of the four keys below indicating the - currently used WEP key. Mapping From SME/User -> firmware. - Key 1 -> Index 0. Key 2 -> Index 1. key 3 -> Index 2. Key - 4-> Index 3. - key1 - Value for key number 1. - key2 - Value for key number 2. - key3 - Value for key number 3. - key4 - Value for key number 4. - -*******************************************************************************/ -typedef struct -{ - CsrWifiSmeWepAuthMode wepAuthType; - u8 selectedWepKey; - u8 key1[13]; - u8 key2[13]; - u8 key3[13]; - u8 key4[13]; -} CsrWifiSmeWep128Keys; - -/******************************************************************************* - - NAME - CsrWifiSmeWep64Keys - - DESCRIPTION - Structure holding WEP Authentication Type and WEP keys that can be used - when using WEP64. - - MEMBERS - wepAuthType - Mask to select the WEP authentication type (Open or Shared) - selectedWepKey - Index to one of the four keys below indicating the - currently used WEP key. Mapping From SME/User -> firmware. - Key 1 -> Index 0. Key 2 -> Index 1. key 3 -> Index 2. Key - 4-> Index 3. - key1 - Value for key number 1. - key2 - Value for key number 2. - key3 - Value for key number 3. - key4 - Value for key number 4. - -*******************************************************************************/ -typedef struct -{ - CsrWifiSmeWepAuthMode wepAuthType; - u8 selectedWepKey; - u8 key1[5]; - u8 key2[5]; - u8 key3[5]; - u8 key4[5]; -} CsrWifiSmeWep64Keys; - -/******************************************************************************* - - NAME - CsrWifiSmeWepAuth - - DESCRIPTION - WEP authentication parameter structure - - MEMBERS - wepKeyType - WEP key try (128 bit or 64 bit) - wepCredentials - Union containing credentials which depends on - wepKeyType parameter. - wepCredentialswep128Key - - wepCredentialswep64Key - - -*******************************************************************************/ -typedef struct -{ - CsrWifiSmeWepCredentialType wepKeyType; - union { - CsrWifiSmeWep128Keys wep128Key; - CsrWifiSmeWep64Keys wep64Key; - } wepCredentials; -} CsrWifiSmeWepAuth; - -/******************************************************************************* - - NAME - CsrWifiSmeWpsConfig - - DESCRIPTION - Structure holding AP WPS Config data. - - MEMBERS - wpsVersion - wpsVersion should be 0x10 for WPS1.0h or 0x20 for - WSC2.0 - uuid - uuid. - deviceName - Device name upto 32 characters without '\0'. - deviceNameLength - deviceNameLen. - manufacturer - manufacturer: CSR - manufacturerLength - manufacturerLen. - modelName - modelName Unifi - modelNameLength - modelNameLen. - modelNumber - modelNumber - modelNumberLength - modelNumberLen. - serialNumber - serialNumber - primDeviceType - Primary WPS device type - secondaryDeviceTypeCount - Number of secondary device types - secondaryDeviceType - list of secondary WPS device types - configMethods - Supported WPS config methods - rfBands - RfBands. - osVersion - Os version on which the device is running - -*******************************************************************************/ -typedef struct -{ - u8 wpsVersion; - u8 uuid[16]; - u8 deviceName[32]; - u8 deviceNameLength; - u8 manufacturer[64]; - u8 manufacturerLength; - u8 modelName[32]; - u8 modelNameLength; - u8 modelNumber[32]; - u8 modelNumberLength; - u8 serialNumber[32]; - CsrWifiSmeWpsDeviceType primDeviceType; - u8 secondaryDeviceTypeCount; - CsrWifiSmeWpsDeviceType *secondaryDeviceType; - CsrWifiSmeWpsConfigTypeMask configMethods; - u8 rfBands; - u8 osVersion[4]; -} CsrWifiSmeWpsConfig; - - -/* Downstream */ -#define CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST (0x0000) - -#define CSR_WIFI_SME_ACTIVATE_REQ ((CsrWifiSmePrim) (0x0000 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_SME_ADHOC_CONFIG_GET_REQ ((CsrWifiSmePrim) (0x0001 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_SME_ADHOC_CONFIG_SET_REQ ((CsrWifiSmePrim) (0x0002 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_SME_BLACKLIST_REQ ((CsrWifiSmePrim) (0x0003 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_SME_CALIBRATION_DATA_GET_REQ ((CsrWifiSmePrim) (0x0004 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_SME_CALIBRATION_DATA_SET_REQ ((CsrWifiSmePrim) (0x0005 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_SME_CCX_CONFIG_GET_REQ ((CsrWifiSmePrim) (0x0006 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_SME_CCX_CONFIG_SET_REQ ((CsrWifiSmePrim) (0x0007 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_SME_COEX_CONFIG_GET_REQ ((CsrWifiSmePrim) (0x0008 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_SME_COEX_CONFIG_SET_REQ ((CsrWifiSmePrim) (0x0009 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_SME_COEX_INFO_GET_REQ ((CsrWifiSmePrim) (0x000A + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_SME_CONNECT_REQ ((CsrWifiSmePrim) (0x000B + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_SME_CONNECTION_CONFIG_GET_REQ ((CsrWifiSmePrim) (0x000C + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_SME_CONNECTION_INFO_GET_REQ ((CsrWifiSmePrim) (0x000D + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_SME_CONNECTION_STATS_GET_REQ ((CsrWifiSmePrim) (0x000E + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_SME_DEACTIVATE_REQ ((CsrWifiSmePrim) (0x000F + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_SME_DISCONNECT_REQ ((CsrWifiSmePrim) (0x0010 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_SME_EVENT_MASK_SET_REQ ((CsrWifiSmePrim) (0x0011 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_SME_HOST_CONFIG_GET_REQ ((CsrWifiSmePrim) (0x0012 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_SME_HOST_CONFIG_SET_REQ ((CsrWifiSmePrim) (0x0013 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_SME_KEY_REQ ((CsrWifiSmePrim) (0x0014 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_SME_LINK_QUALITY_GET_REQ ((CsrWifiSmePrim) (0x0015 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_SME_MIB_CONFIG_GET_REQ ((CsrWifiSmePrim) (0x0016 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_SME_MIB_CONFIG_SET_REQ ((CsrWifiSmePrim) (0x0017 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_SME_MIB_GET_NEXT_REQ ((CsrWifiSmePrim) (0x0018 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_SME_MIB_GET_REQ ((CsrWifiSmePrim) (0x0019 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_SME_MIB_SET_REQ ((CsrWifiSmePrim) (0x001A + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_SME_MULTICAST_ADDRESS_REQ ((CsrWifiSmePrim) (0x001B + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_SME_PACKET_FILTER_SET_REQ ((CsrWifiSmePrim) (0x001C + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_SME_PERMANENT_MAC_ADDRESS_GET_REQ ((CsrWifiSmePrim) (0x001D + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_SME_PMKID_REQ ((CsrWifiSmePrim) (0x001E + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_SME_POWER_CONFIG_GET_REQ ((CsrWifiSmePrim) (0x001F + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_SME_POWER_CONFIG_SET_REQ ((CsrWifiSmePrim) (0x0020 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_SME_REGULATORY_DOMAIN_INFO_GET_REQ ((CsrWifiSmePrim) (0x0021 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_SME_ROAMING_CONFIG_GET_REQ ((CsrWifiSmePrim) (0x0022 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_SME_ROAMING_CONFIG_SET_REQ ((CsrWifiSmePrim) (0x0023 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_SME_SCAN_CONFIG_GET_REQ ((CsrWifiSmePrim) (0x0024 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_SME_SCAN_CONFIG_SET_REQ ((CsrWifiSmePrim) (0x0025 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_SME_SCAN_FULL_REQ ((CsrWifiSmePrim) (0x0026 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_SME_SCAN_RESULTS_FLUSH_REQ ((CsrWifiSmePrim) (0x0027 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_SME_SCAN_RESULTS_GET_REQ ((CsrWifiSmePrim) (0x0028 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_SME_SME_STA_CONFIG_GET_REQ ((CsrWifiSmePrim) (0x0029 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_SME_SME_STA_CONFIG_SET_REQ ((CsrWifiSmePrim) (0x002A + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_SME_STATION_MAC_ADDRESS_GET_REQ ((CsrWifiSmePrim) (0x002B + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_SME_TSPEC_REQ ((CsrWifiSmePrim) (0x002C + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_SME_VERSIONS_GET_REQ ((CsrWifiSmePrim) (0x002D + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_SME_WIFI_FLIGHTMODE_REQ ((CsrWifiSmePrim) (0x002E + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_SME_WIFI_OFF_REQ ((CsrWifiSmePrim) (0x002F + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_SME_WIFI_ON_REQ ((CsrWifiSmePrim) (0x0030 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_SME_CLOAKED_SSIDS_SET_REQ ((CsrWifiSmePrim) (0x0031 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_SME_CLOAKED_SSIDS_GET_REQ ((CsrWifiSmePrim) (0x0032 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_SME_SME_COMMON_CONFIG_GET_REQ ((CsrWifiSmePrim) (0x0033 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_SME_SME_COMMON_CONFIG_SET_REQ ((CsrWifiSmePrim) (0x0034 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_SME_INTERFACE_CAPABILITY_GET_REQ ((CsrWifiSmePrim) (0x0035 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_SME_WPS_CONFIGURATION_REQ ((CsrWifiSmePrim) (0x0036 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST)) -#define CSR_WIFI_SME_SET_REQ ((CsrWifiSmePrim) (0x0037 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST)) - - -#define CSR_WIFI_SME_PRIM_DOWNSTREAM_HIGHEST (0x0037 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST) - -/* Upstream */ -#define CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST (0x0000 + CSR_PRIM_UPSTREAM) - -#define CSR_WIFI_SME_ACTIVATE_CFM ((CsrWifiSmePrim)(0x0000 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_SME_ADHOC_CONFIG_GET_CFM ((CsrWifiSmePrim)(0x0001 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_SME_ADHOC_CONFIG_SET_CFM ((CsrWifiSmePrim)(0x0002 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_SME_ASSOCIATION_COMPLETE_IND ((CsrWifiSmePrim)(0x0003 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_SME_ASSOCIATION_START_IND ((CsrWifiSmePrim)(0x0004 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_SME_BLACKLIST_CFM ((CsrWifiSmePrim)(0x0005 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_SME_CALIBRATION_DATA_GET_CFM ((CsrWifiSmePrim)(0x0006 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_SME_CALIBRATION_DATA_SET_CFM ((CsrWifiSmePrim)(0x0007 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_SME_CCX_CONFIG_GET_CFM ((CsrWifiSmePrim)(0x0008 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_SME_CCX_CONFIG_SET_CFM ((CsrWifiSmePrim)(0x0009 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_SME_COEX_CONFIG_GET_CFM ((CsrWifiSmePrim)(0x000A + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_SME_COEX_CONFIG_SET_CFM ((CsrWifiSmePrim)(0x000B + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_SME_COEX_INFO_GET_CFM ((CsrWifiSmePrim)(0x000C + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_SME_CONNECT_CFM ((CsrWifiSmePrim)(0x000D + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_SME_CONNECTION_CONFIG_GET_CFM ((CsrWifiSmePrim)(0x000E + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_SME_CONNECTION_INFO_GET_CFM ((CsrWifiSmePrim)(0x000F + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_SME_CONNECTION_QUALITY_IND ((CsrWifiSmePrim)(0x0010 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_SME_CONNECTION_STATS_GET_CFM ((CsrWifiSmePrim)(0x0011 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_SME_DEACTIVATE_CFM ((CsrWifiSmePrim)(0x0012 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_SME_DISCONNECT_CFM ((CsrWifiSmePrim)(0x0013 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_SME_EVENT_MASK_SET_CFM ((CsrWifiSmePrim)(0x0014 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_SME_HOST_CONFIG_GET_CFM ((CsrWifiSmePrim)(0x0015 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_SME_HOST_CONFIG_SET_CFM ((CsrWifiSmePrim)(0x0016 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_SME_IBSS_STATION_IND ((CsrWifiSmePrim)(0x0017 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_SME_KEY_CFM ((CsrWifiSmePrim)(0x0018 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_SME_LINK_QUALITY_GET_CFM ((CsrWifiSmePrim)(0x0019 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_SME_MEDIA_STATUS_IND ((CsrWifiSmePrim)(0x001A + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_SME_MIB_CONFIG_GET_CFM ((CsrWifiSmePrim)(0x001B + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_SME_MIB_CONFIG_SET_CFM ((CsrWifiSmePrim)(0x001C + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_SME_MIB_GET_CFM ((CsrWifiSmePrim)(0x001D + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_SME_MIB_GET_NEXT_CFM ((CsrWifiSmePrim)(0x001E + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_SME_MIB_SET_CFM ((CsrWifiSmePrim)(0x001F + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_SME_MIC_FAILURE_IND ((CsrWifiSmePrim)(0x0020 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_SME_MULTICAST_ADDRESS_CFM ((CsrWifiSmePrim)(0x0021 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_SME_PACKET_FILTER_SET_CFM ((CsrWifiSmePrim)(0x0022 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_SME_PERMANENT_MAC_ADDRESS_GET_CFM ((CsrWifiSmePrim)(0x0023 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_SME_PMKID_CANDIDATE_LIST_IND ((CsrWifiSmePrim)(0x0024 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_SME_PMKID_CFM ((CsrWifiSmePrim)(0x0025 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_SME_POWER_CONFIG_GET_CFM ((CsrWifiSmePrim)(0x0026 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_SME_POWER_CONFIG_SET_CFM ((CsrWifiSmePrim)(0x0027 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_SME_REGULATORY_DOMAIN_INFO_GET_CFM ((CsrWifiSmePrim)(0x0028 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_SME_ROAM_COMPLETE_IND ((CsrWifiSmePrim)(0x0029 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_SME_ROAM_START_IND ((CsrWifiSmePrim)(0x002A + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_SME_ROAMING_CONFIG_GET_CFM ((CsrWifiSmePrim)(0x002B + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_SME_ROAMING_CONFIG_SET_CFM ((CsrWifiSmePrim)(0x002C + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_SME_SCAN_CONFIG_GET_CFM ((CsrWifiSmePrim)(0x002D + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_SME_SCAN_CONFIG_SET_CFM ((CsrWifiSmePrim)(0x002E + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_SME_SCAN_FULL_CFM ((CsrWifiSmePrim)(0x002F + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_SME_SCAN_RESULT_IND ((CsrWifiSmePrim)(0x0030 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_SME_SCAN_RESULTS_FLUSH_CFM ((CsrWifiSmePrim)(0x0031 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_SME_SCAN_RESULTS_GET_CFM ((CsrWifiSmePrim)(0x0032 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_SME_SME_STA_CONFIG_GET_CFM ((CsrWifiSmePrim)(0x0033 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_SME_SME_STA_CONFIG_SET_CFM ((CsrWifiSmePrim)(0x0034 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_SME_STATION_MAC_ADDRESS_GET_CFM ((CsrWifiSmePrim)(0x0035 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_SME_TSPEC_IND ((CsrWifiSmePrim)(0x0036 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_SME_TSPEC_CFM ((CsrWifiSmePrim)(0x0037 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_SME_VERSIONS_GET_CFM ((CsrWifiSmePrim)(0x0038 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_SME_WIFI_FLIGHTMODE_CFM ((CsrWifiSmePrim)(0x0039 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_SME_WIFI_OFF_IND ((CsrWifiSmePrim)(0x003A + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_SME_WIFI_OFF_CFM ((CsrWifiSmePrim)(0x003B + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_SME_WIFI_ON_CFM ((CsrWifiSmePrim)(0x003C + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_SME_CLOAKED_SSIDS_SET_CFM ((CsrWifiSmePrim)(0x003D + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_SME_CLOAKED_SSIDS_GET_CFM ((CsrWifiSmePrim)(0x003E + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_SME_WIFI_ON_IND ((CsrWifiSmePrim)(0x003F + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_SME_SME_COMMON_CONFIG_GET_CFM ((CsrWifiSmePrim)(0x0040 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_SME_SME_COMMON_CONFIG_SET_CFM ((CsrWifiSmePrim)(0x0041 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_SME_INTERFACE_CAPABILITY_GET_CFM ((CsrWifiSmePrim)(0x0042 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_SME_ERROR_IND ((CsrWifiSmePrim)(0x0043 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_SME_INFO_IND ((CsrWifiSmePrim)(0x0044 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_SME_CORE_DUMP_IND ((CsrWifiSmePrim)(0x0045 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_SME_AMP_STATUS_CHANGE_IND ((CsrWifiSmePrim)(0x0046 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST)) -#define CSR_WIFI_SME_WPS_CONFIGURATION_CFM ((CsrWifiSmePrim)(0x0047 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST)) - -#define CSR_WIFI_SME_PRIM_UPSTREAM_HIGHEST (0x0047 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST) - -#define CSR_WIFI_SME_PRIM_DOWNSTREAM_COUNT (CSR_WIFI_SME_PRIM_DOWNSTREAM_HIGHEST + 1 - CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST) -#define CSR_WIFI_SME_PRIM_UPSTREAM_COUNT (CSR_WIFI_SME_PRIM_UPSTREAM_HIGHEST + 1 - CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST) - -/******************************************************************************* - - NAME - CsrWifiSmeActivateReq - - DESCRIPTION - The WMA sends this primitive to activate the SME. - The WMA must activate the SME before it can send any other primitive. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; -} CsrWifiSmeActivateReq; - -/******************************************************************************* - - NAME - CsrWifiSmeAdhocConfigGetReq - - DESCRIPTION - This primitive gets the value of the adHocConfig parameter. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; -} CsrWifiSmeAdhocConfigGetReq; - -/******************************************************************************* - - NAME - CsrWifiSmeAdhocConfigSetReq - - DESCRIPTION - This primitive sets the value of the adHocConfig parameter. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - adHocConfig - Sets the values to use when starting an ad hoc network. - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - CsrWifiSmeAdHocConfig adHocConfig; -} CsrWifiSmeAdhocConfigSetReq; - -/******************************************************************************* - - NAME - CsrWifiSmeBlacklistReq - - DESCRIPTION - The wireless manager application should call this primitive to notify the - driver of any networks that should not be connected to. The interface - allows the wireless manager application to query, add, remove, and flush - the BSSIDs that the driver may not connect or roam to. - When this primitive adds to the black list the BSSID to which the SME is - currently connected, the SME will try to roam, if applicable, to another - BSSID in the same ESS; if the roaming procedure fails, the SME will - disconnect. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - Interface Identifier; unique identifier of an interface - action - The value of the CsrWifiSmeListAction parameter instructs - the driver to modify or provide the list of blacklisted - networks. - setAddressCount - Number of BSSIDs sent with this primitive - setAddresses - Pointer to the list of BBSIDs sent with the primitive, set - to NULL if none is sent. - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; - CsrWifiSmeListAction action; - u8 setAddressCount; - CsrWifiMacAddress *setAddresses; -} CsrWifiSmeBlacklistReq; - -/******************************************************************************* - - NAME - CsrWifiSmeCalibrationDataGetReq - - DESCRIPTION - This primitive retrieves the Wi-Fi radio calibration data. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; -} CsrWifiSmeCalibrationDataGetReq; - -/******************************************************************************* - - NAME - CsrWifiSmeCalibrationDataSetReq - - DESCRIPTION - This primitive sets the Wi-Fi radio calibration data. - The usage of the primitive with proper calibration data will avoid - time-consuming configuration after power-up. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - calibrationDataLength - Number of bytes in the buffer pointed by - calibrationData - calibrationData - Pointer to a buffer of length calibrationDataLength - containing the calibration data - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 calibrationDataLength; - u8 *calibrationData; -} CsrWifiSmeCalibrationDataSetReq; - -/******************************************************************************* - - NAME - CsrWifiSmeCcxConfigGetReq - - DESCRIPTION - This primitive gets the value of the CcxConfig parameter. - CURRENTLY NOT SUPPORTED. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - Interface Identifier; unique identifier of an interface - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; -} CsrWifiSmeCcxConfigGetReq; - -/******************************************************************************* - - NAME - CsrWifiSmeCcxConfigSetReq - - DESCRIPTION - This primitive sets the value of the CcxConfig parameter. - CURRENTLY NOT SUPPORTED. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - Interface Identifier; unique identifier of an interface - ccxConfig - Currently not supported - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; - CsrWifiSmeCcxConfig ccxConfig; -} CsrWifiSmeCcxConfigSetReq; - -/******************************************************************************* - - NAME - CsrWifiSmeCoexConfigGetReq - - DESCRIPTION - This primitive gets the value of the CoexConfig parameter. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; -} CsrWifiSmeCoexConfigGetReq; - -/******************************************************************************* - - NAME - CsrWifiSmeCoexConfigSetReq - - DESCRIPTION - This primitive sets the value of the CoexConfig parameter. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - coexConfig - Configures the coexistence behaviour - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - CsrWifiSmeCoexConfig coexConfig; -} CsrWifiSmeCoexConfigSetReq; - -/******************************************************************************* - - NAME - CsrWifiSmeCoexInfoGetReq - - DESCRIPTION - This primitive gets the value of the CoexInfo parameter. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; -} CsrWifiSmeCoexInfoGetReq; - -/******************************************************************************* - - NAME - CsrWifiSmeConnectReq - - DESCRIPTION - The wireless manager application calls this primitive to start the - process of joining an 802.11 wireless network or to start an ad hoc - network. - The structure pointed by connectionConfig contains parameters describing - the network to join or, in case of an ad hoc network, to host or join. - The SME will select a network, perform the IEEE 802.11 Join, Authenticate - and Associate exchanges. - The SME selects the networks from the current scan list that match both - the SSID and BSSID, however either or both of these may be the wildcard - value. Using this rule, the following operations are possible: - * To connect to a network by name, specify the SSID and set the BSSID to - 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF. If there are two or more networks visible, - the SME will select the one with the strongest signal. - * To connect to a specific network, specify the BSSID. The SSID is - optional, but if given it must match the SSID of the network. An empty - SSID may be specified by setting the SSID length to zero. Please note - that if the BSSID is specified (i.e. not equal to 0xFF 0xFF 0xFF 0xFF - 0xFF 0xFF), the SME will not attempt to roam if signal conditions become - poor, even if there is an alternative AP with an SSID that matches the - current network SSID. - * To connect to any network matching the other parameters (i.e. security, - etc), set the SSID length to zero and set the BSSID to 0xFF 0xFF 0xFF - 0xFF 0xFF 0xFF. In this case, the SME will order all available networks - by their signal strengths and will iterate through this list until it - successfully connects. - NOTE: Specifying the BSSID will restrict the selection to one specific - network. If SSID and BSSID are given, they must both match the network - for it to be selected. To select a network based on the SSID only, the - wireless manager application must set the BSSID to 0xFF 0xFF 0xFF 0xFF - 0xFF 0xFF. - The SME will try to connect to each network that matches the provided - parameters, one by one, until it succeeds or has tried unsuccessfully - with all the matching networks. - If there is no network that matches the parameters and the request allows - to host an ad hoc network, the SME will advertise a new ad hoc network - instead. - If the SME cannot connect, it will notify the failure in the confirm. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - Interface Identifier; unique identifier of an interface - connectionConfig - Describes the candidate network to join or to host. - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; - CsrWifiSmeConnectionConfig connectionConfig; -} CsrWifiSmeConnectReq; - -/******************************************************************************* - - NAME - CsrWifiSmeConnectionConfigGetReq - - DESCRIPTION - This primitive gets the value of the ConnectionConfig parameter. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - Interface Identifier; unique identifier of an interface - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; -} CsrWifiSmeConnectionConfigGetReq; - -/******************************************************************************* - - NAME - CsrWifiSmeConnectionInfoGetReq - - DESCRIPTION - This primitive gets the value of the ConnectionInfo parameter. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - Interface Identifier; unique identifier of an interface - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; -} CsrWifiSmeConnectionInfoGetReq; - -/******************************************************************************* - - NAME - CsrWifiSmeConnectionStatsGetReq - - DESCRIPTION - This primitive gets the value of the ConnectionStats parameter. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - Interface Identifier; unique identifier of an interface - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; -} CsrWifiSmeConnectionStatsGetReq; - -/******************************************************************************* - - NAME - CsrWifiSmeDeactivateReq - - DESCRIPTION - The WMA sends this primitive to deactivate the SME. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; -} CsrWifiSmeDeactivateReq; - -/******************************************************************************* - - NAME - CsrWifiSmeDisconnectReq - - DESCRIPTION - The wireless manager application may disconnect from the current network - by calling this primitive - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - Interface Identifier; unique identifier of an interface - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; -} CsrWifiSmeDisconnectReq; - -/******************************************************************************* - - NAME - CsrWifiSmeEventMaskSetReq - - DESCRIPTION - The wireless manager application may register with the SME to receive - notification of interesting events. Indications will be sent only if the - wireless manager explicitly registers to be notified of that event. - indMask is a bit mask of values defined in CsrWifiSmeIndicationsMask. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - indMask - Set mask with values from CsrWifiSmeIndications - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - CsrWifiSmeIndicationsMask indMask; -} CsrWifiSmeEventMaskSetReq; - -/******************************************************************************* - - NAME - CsrWifiSmeHostConfigGetReq - - DESCRIPTION - This primitive gets the value of the hostConfig parameter. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - Interface Identifier; unique identifier of an interface - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; -} CsrWifiSmeHostConfigGetReq; - -/******************************************************************************* - - NAME - CsrWifiSmeHostConfigSetReq - - DESCRIPTION - This primitive sets the value of the hostConfig parameter. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - Interface Identifier; unique identifier of an interface - hostConfig - Communicates a change of host power state (for example, on - mains power, on battery power etc) and of the periodicity of - traffic data - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; - CsrWifiSmeHostConfig hostConfig; -} CsrWifiSmeHostConfigSetReq; - -/******************************************************************************* - - NAME - CsrWifiSmeKeyReq - - DESCRIPTION - The wireless manager application calls this primitive to add or remove - keys that the chip should use for encryption of data. - The interface allows the wireless manager application to add and remove - keys according to the specified action. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - Interface Identifier; unique identifier of an interface - action - The value of the CsrWifiSmeListAction parameter instructs the - driver to modify or provide the list of keys. - CSR_WIFI_SME_LIST_ACTION_GET is not supported here. - key - Key to be added or removed - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; - CsrWifiSmeListAction action; - CsrWifiSmeKey key; -} CsrWifiSmeKeyReq; - -/******************************************************************************* - - NAME - CsrWifiSmeLinkQualityGetReq - - DESCRIPTION - This primitive gets the value of the LinkQuality parameter. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - Interface Identifier; unique identifier of an interface - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; -} CsrWifiSmeLinkQualityGetReq; - -/******************************************************************************* - - NAME - CsrWifiSmeMibConfigGetReq - - DESCRIPTION - This primitive gets the value of the MibConfig parameter. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; -} CsrWifiSmeMibConfigGetReq; - -/******************************************************************************* - - NAME - CsrWifiSmeMibConfigSetReq - - DESCRIPTION - This primitive sets the value of the MibConfig parameter. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - mibConfig - Conveys the desired value of various IEEE 802.11 attributes as - currently configured - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - CsrWifiSmeMibConfig mibConfig; -} CsrWifiSmeMibConfigSetReq; - -/******************************************************************************* - - NAME - CsrWifiSmeMibGetNextReq - - DESCRIPTION - To read a sequence of MIB parameters, for example a table, call this - primitive to find the name of the next MIB variable - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - mibAttributeLength - Length of mibAttribute - mibAttribute - Points to a VarBind or VarBindList containing the - name(s) of the MIB variable(s) to search from. - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 mibAttributeLength; - u8 *mibAttribute; -} CsrWifiSmeMibGetNextReq; - -/******************************************************************************* - - NAME - CsrWifiSmeMibGetReq - - DESCRIPTION - The wireless manager application calls this primitive to retrieve one or - more MIB variables. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - mibAttributeLength - Length of mibAttribute - mibAttribute - Points to the VarBind or VarBindList containing the - names of the MIB variables to be retrieved - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 mibAttributeLength; - u8 *mibAttribute; -} CsrWifiSmeMibGetReq; - -/******************************************************************************* - - NAME - CsrWifiSmeMibSetReq - - DESCRIPTION - The SME provides raw access to the MIB on the chip, which may be used by - some configuration or diagnostic utilities, but is not normally needed by - the wireless manager application. - The MIB access functions use BER encoded names (OID) of the MIB - parameters and BER encoded values, as described in the chip Host - Interface Protocol Specification. - The MIB parameters are described in 'Wi-Fi 5.0.0 Management Information - Base Reference Guide'. - The wireless manager application calls this primitive to set one or more - MIB variables - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - mibAttributeLength - Length of mibAttribute - mibAttribute - Points to the VarBind or VarBindList containing the - names and values of the MIB variables to set - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 mibAttributeLength; - u8 *mibAttribute; -} CsrWifiSmeMibSetReq; - -/******************************************************************************* - - NAME - CsrWifiSmeMulticastAddressReq - - DESCRIPTION - The wireless manager application calls this primitive to specify the - multicast addresses which the chip should recognise. The interface allows - the wireless manager application to query, add, remove and flush the - multicast addresses for the network interface according to the specified - action. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - Interface Identifier; unique identifier of an interface - action - The value of the CsrWifiSmeListAction parameter - instructs the driver to modify or provide the list of - MAC addresses. - setAddressesCount - Number of MAC addresses sent with the primitive - setAddresses - Pointer to the list of MAC Addresses sent with the - primitive, set to NULL if none is sent. - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; - CsrWifiSmeListAction action; - u8 setAddressesCount; - CsrWifiMacAddress *setAddresses; -} CsrWifiSmeMulticastAddressReq; - -/******************************************************************************* - - NAME - CsrWifiSmePacketFilterSetReq - - DESCRIPTION - The wireless manager application should call this primitive to enable or - disable filtering of broadcast packets: uninteresting broadcast packets - will be dropped by the Wi-Fi chip, instead of passing them up to the - host. - This has the advantage of saving power in the host application processor - as it removes the need to process unwanted packets. - All broadcast packets are filtered according to the filter and the filter - mode provided, except ARP packets, which are filtered using - arpFilterAddress. - Filters are not cumulative: only the parameters specified in the most - recent successful request are significant. - For more information, see 'UniFi Firmware API Specification'. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - Interface Identifier; unique identifier of an interface - filterLength - Length of the filter in bytes. - filterLength=0 disables the filter previously set - filter - Points to the first byte of the filter provided, if any. - This shall include zero or more instance of the - information elements of one of these types - * Traffic Classification (TCLAS) elements - * WMM-SA TCLAS elements - mode - Specifies whether the filter selects or excludes packets - matching the filter - arpFilterAddress - IPv4 address to be used for filtering the ARP packets. - * If the specified address is the IPv4 broadcast address - (255.255.255.255), all ARP packets are reported to the - host, - * If the specified address is NOT the IPv4 broadcast - address, only ARP packets with the specified address in - the Source or Target Protocol Address fields are reported - to the host - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; - u16 filterLength; - u8 *filter; - CsrWifiSmePacketFilterMode mode; - CsrWifiIp4Address arpFilterAddress; -} CsrWifiSmePacketFilterSetReq; - -/******************************************************************************* - - NAME - CsrWifiSmePermanentMacAddressGetReq - - DESCRIPTION - This primitive retrieves the MAC address stored in EEPROM - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; -} CsrWifiSmePermanentMacAddressGetReq; - -/******************************************************************************* - - NAME - CsrWifiSmePmkidReq - - DESCRIPTION - The wireless manager application calls this primitive to request an - operation on the SME PMKID list. - The action argument specifies the operation to perform. - When the connection is complete, the wireless manager application may - then send and receive EAPOL packets to complete WPA or WPA2 - authentication if appropriate. - The wireless manager application can then pass the resulting encryption - keys using this primitive. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - Interface Identifier; unique identifier of an interface - action - The value of the CsrWifiSmeListAction parameter instructs - the driver to modify or provide the list of PMKIDs. - setPmkidsCount - Number of PMKIDs sent with the primitive - setPmkids - Pointer to the list of PMKIDs sent with the primitive, set - to NULL if none is sent. - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; - CsrWifiSmeListAction action; - u8 setPmkidsCount; - CsrWifiSmePmkid *setPmkids; -} CsrWifiSmePmkidReq; - -/******************************************************************************* - - NAME - CsrWifiSmePowerConfigGetReq - - DESCRIPTION - This primitive gets the value of the PowerConfig parameter. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; -} CsrWifiSmePowerConfigGetReq; - -/******************************************************************************* - - NAME - CsrWifiSmePowerConfigSetReq - - DESCRIPTION - This primitive sets the value of the PowerConfig parameter. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - powerConfig - Power saving configuration - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - CsrWifiSmePowerConfig powerConfig; -} CsrWifiSmePowerConfigSetReq; - -/******************************************************************************* - - NAME - CsrWifiSmeRegulatoryDomainInfoGetReq - - DESCRIPTION - This primitive gets the value of the RegulatoryDomainInfo parameter. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; -} CsrWifiSmeRegulatoryDomainInfoGetReq; - -/******************************************************************************* - - NAME - CsrWifiSmeRoamingConfigGetReq - - DESCRIPTION - This primitive gets the value of the RoamingConfig parameter. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - Interface Identifier; unique identifier of an interface - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; -} CsrWifiSmeRoamingConfigGetReq; - -/******************************************************************************* - - NAME - CsrWifiSmeRoamingConfigSetReq - - DESCRIPTION - This primitive sets the value of the RoamingConfig parameter. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - Interface Identifier; unique identifier of an interface - roamingConfig - Desired roaming behaviour values - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; - CsrWifiSmeRoamingConfig roamingConfig; -} CsrWifiSmeRoamingConfigSetReq; - -/******************************************************************************* - - NAME - CsrWifiSmeScanConfigGetReq - - DESCRIPTION - This primitive gets the value of the ScanConfig parameter. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; -} CsrWifiSmeScanConfigGetReq; - -/******************************************************************************* - - NAME - CsrWifiSmeScanConfigSetReq - - DESCRIPTION - This primitive sets the value of the ScanConfig parameter. - The SME normally configures the firmware to perform autonomous scanning - without involving the host. - The firmware passes beacon / probe response or indicates loss of beacon - on certain changes of state, for example: - * A new AP is seen for the first time - * An AP is no longer visible - * The signal strength of an AP changes by more than a certain amount, as - configured by the thresholds in the scanConfig parameter - In addition to the autonomous scan, the wireless manager application may - request a scan at any time using CSR_WIFI_SME_SCAN_FULL_REQ. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - scanConfig - Reports the configuration for the autonomous scanning behaviour - of the firmware - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - CsrWifiSmeScanConfig scanConfig; -} CsrWifiSmeScanConfigSetReq; - -/******************************************************************************* - - NAME - CsrWifiSmeScanFullReq - - DESCRIPTION - The wireless manager application should call this primitive to request a - full scan. - Channels are scanned actively or passively according to the requirement - set by regulatory domain. - If the SME receives this primitive while a full scan is going on, the new - request is buffered and it will be served after the current full scan is - completed. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - ssidCount - Number of SSIDs provided. - If it is 0, the SME will attempt to detect any network - ssid - Points to the first SSID provided, if any. - bssid - BSS identifier. - If it is equal to FF-FF-FF-FF-FF, the SME will listen for - messages from any BSS. - If it is different from FF-FF-FF-FF-FF and any SSID is - provided, one SSID must match the network of the BSS. - forceScan - Forces the scan even if the SME is in a state which would - normally prevent it (e.g. autonomous scan is running). - bssType - Type of BSS to scan for - scanType - Type of scan to perform - channelListCount - Number of channels provided. - If it is 0, the SME will initiate a scan of all the - supported channels that are permitted by the current - regulatory domain. - channelList - Points to the first channel , or NULL if channelListCount - is zero. - probeIeLength - Length of the information element in bytes to be sent - with the probe message. - probeIe - Points to the first byte of the information element to be - sent with the probe message. - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u8 ssidCount; - CsrWifiSsid *ssid; - CsrWifiMacAddress bssid; - u8 forceScan; - CsrWifiSmeBssType bssType; - CsrWifiSmeScanType scanType; - u16 channelListCount; - u8 *channelList; - u16 probeIeLength; - u8 *probeIe; -} CsrWifiSmeScanFullReq; - -/******************************************************************************* - - NAME - CsrWifiSmeScanResultsFlushReq - - DESCRIPTION - The Wireless Manager calls this primitive to ask the SME to delete all - scan results from its cache, except for the scan result of any currently - connected network. - As scan results are received by the SME from the firmware, they are - cached in the SME memory. - Any time the Wireless Manager requests scan results, they are returned - from the SME internal cache. - For some applications it may be desirable to clear this cache prior to - requesting that a scan be performed; this will ensure that the cache then - only contains the networks detected in the most recent scan. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; -} CsrWifiSmeScanResultsFlushReq; - -/******************************************************************************* - - NAME - CsrWifiSmeScanResultsGetReq - - DESCRIPTION - The wireless manager application calls this primitive to retrieve the - current set of scan results, either after receiving a successful - CSR_WIFI_SME_SCAN_FULL_CFM, or to get autonomous scan results. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; -} CsrWifiSmeScanResultsGetReq; - -/******************************************************************************* - - NAME - CsrWifiSmeSmeStaConfigGetReq - - DESCRIPTION - This primitive gets the value of the SmeStaConfig parameter. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - Interface Identifier; unique identifier of an interface - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; -} CsrWifiSmeSmeStaConfigGetReq; - -/******************************************************************************* - - NAME - CsrWifiSmeSmeStaConfigSetReq - - DESCRIPTION - This primitive sets the value of the SmeConfig parameter. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - Interface Identifier; unique identifier of an interface - smeConfig - SME Station Parameters to be set - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; - CsrWifiSmeStaConfig smeConfig; -} CsrWifiSmeSmeStaConfigSetReq; - -/******************************************************************************* - - NAME - CsrWifiSmeStationMacAddressGetReq - - DESCRIPTION - This primitives is used to retrieve the current MAC address used by the - station. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; -} CsrWifiSmeStationMacAddressGetReq; - -/******************************************************************************* - - NAME - CsrWifiSmeTspecReq - - DESCRIPTION - The wireless manager application should call this primitive to use the - TSPEC feature. - The chip supports the use of TSPECs and TCLAS for the use of IEEE - 802.11/WMM Quality of Service features. - The API allows the wireless manager application to supply a correctly - formatted TSPEC and TCLAS pair to the driver. - After performing basic validation, the driver negotiates the installation - of the TSPEC with the AP as defined by the 802.11 specification. - The driver retains all TSPEC and TCLAS pairs until they are specifically - removed. - It is not compulsory for a TSPEC to have a TCLAS (NULL is used to - indicate that no TCLAS is supplied), while a TCLASS always require a - TSPEC. - The format of the TSPEC element is specified in 'WMM (including WMM Power - Save) Specification - Version 1.1' and 'ANSI/IEEE Std 802.11-REVmb/D3.0'. - For more information, see 'UniFi Configuring WMM and WMM-PS'. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - Interface Identifier; unique identifier of an interface - action - Specifies the action to be carried out on the list of TSPECs. - CSR_WIFI_SME_LIST_ACTION_FLUSH is not applicable here. - transactionId - Unique Transaction ID for the TSPEC, as assigned by the - driver - strict - If it set to false, allows the SME to perform automatic - TSPEC negotiation - ctrlMask - Additional TSPEC configuration for CCX. - Set mask with values from CsrWifiSmeTspecCtrl. - CURRENTLY NOT SUPPORTED - tspecLength - Length of the TSPEC. - tspec - Points to the first byte of the TSPEC - tclasLength - Length of the TCLAS. - If it is equal to 0, no TCLASS is provided for the TSPEC - tclas - Points to the first byte of the TCLAS, if any. - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; - CsrWifiSmeListAction action; - u32 transactionId; - u8 strict; - CsrWifiSmeTspecCtrlMask ctrlMask; - u16 tspecLength; - u8 *tspec; - u16 tclasLength; - u8 *tclas; -} CsrWifiSmeTspecReq; - -/******************************************************************************* - - NAME - CsrWifiSmeVersionsGetReq - - DESCRIPTION - This primitive gets the value of the Versions parameter. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; -} CsrWifiSmeVersionsGetReq; - -/******************************************************************************* - - NAME - CsrWifiSmeWifiFlightmodeReq - - DESCRIPTION - The wireless manager application may call this primitive on boot-up of - the platform to ensure that the chip is placed in a mode that prevents - any emission of RF energy. - This primitive is an alternative to CSR_WIFI_SME_WIFI_ON_REQ. - As in CSR_WIFI_SME_WIFI_ON_REQ, it causes the download of the patch file - (if any) and the programming of the initial MIB settings (if supplied by - the WMA), but it also ensures that the chip is left in its lowest - possible power-mode with the radio subsystems disabled. - This feature is useful on platforms where power cannot be removed from - the chip (leaving the chip not initialised will cause it to consume more - power so calling this function ensures that the chip is initialised into - a low power mode but without entering a state where it could emit any RF - energy). - NOTE: this primitive does not cause the Wi-Fi to change state: Wi-Fi - stays conceptually off. Configuration primitives can be sent after - CSR_WIFI_SME_WIFI_FLIGHTMODE_REQ and the configuration will be maintained. - Requests that require the state of the Wi-Fi to be ON will return - CSR_WIFI_SME_STATUS_WIFI_OFF in their confirms. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - address - Optionally specifies a station MAC address. - In normal use, the manager should set the address to 0xFF - 0xFF 0xFF 0xFF 0xFF 0xFF, which will cause the chip to use - the MAC address in the MIB. - mibFilesCount - Number of provided data blocks with initial MIB values - mibFiles - Points to the first data block with initial MIB values. - These data blocks are typically the contents of the provided - files ufmib.dat and localmib.dat, available from the host - file system, if they exist. - These files typically contain radio tuning and calibration - values. - More values can be created using the Host Tools. - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - CsrWifiMacAddress address; - u16 mibFilesCount; - CsrWifiSmeDataBlock *mibFiles; -} CsrWifiSmeWifiFlightmodeReq; - -/******************************************************************************* - - NAME - CsrWifiSmeWifiOffReq - - DESCRIPTION - The wireless manager application calls this primitive to turn off the - chip, thus saving power when Wi-Fi is not in use. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; -} CsrWifiSmeWifiOffReq; - -/******************************************************************************* - - NAME - CsrWifiSmeWifiOnReq - - DESCRIPTION - The wireless manager application calls this primitive to turn on the - Wi-Fi chip. - If the Wi-Fi chip is currently off, the SME turns the Wi-Fi chip on, - downloads the patch file (if any), and programs the initial MIB settings - (if supplied by the WMA). - The patch file is not provided with the SME API; its downloading is - automatic and handled internally by the system. - The MIB settings, when provided, override the default values that the - firmware loads from EEPROM. - If the Wi-Fi chip is already on, the SME takes no action and returns a - successful status in the confirm. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - address - Optionally specifies a station MAC address. - In normal use, the manager should set the address to 0xFF - 0xFF 0xFF 0xFF 0xFF 0xFF, which will cause the chip to use - the MAC address in the MIB - mibFilesCount - Number of provided data blocks with initial MIB values - mibFiles - Points to the first data block with initial MIB values. - These data blocks are typically the contents of the provided - files ufmib.dat and localmib.dat, available from the host - file system, if they exist. - These files typically contain radio tuning and calibration - values. - More values can be created using the Host Tools. - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - CsrWifiMacAddress address; - u16 mibFilesCount; - CsrWifiSmeDataBlock *mibFiles; -} CsrWifiSmeWifiOnReq; - -/******************************************************************************* - - NAME - CsrWifiSmeCloakedSsidsSetReq - - DESCRIPTION - This primitive sets the list of cloaked SSIDs for which the WMA possesses - profiles. - When the driver detects a cloaked AP, the SME will explicitly scan for it - using the list of cloaked SSIDs provided it, and, if the scan succeeds, - it will report the AP to the WMA either via CSR_WIFI_SME_SCAN_RESULT_IND - (if registered) or via CSR_WIFI_SCAN_RESULT_GET_CFM. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - cloakedSsids - Sets the list of cloaked SSIDs - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - CsrWifiSmeCloakedSsidConfig cloakedSsids; -} CsrWifiSmeCloakedSsidsSetReq; - -/******************************************************************************* - - NAME - CsrWifiSmeCloakedSsidsGetReq - - DESCRIPTION - This primitive gets the value of the CloakedSsids parameter. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; -} CsrWifiSmeCloakedSsidsGetReq; - -/******************************************************************************* - - NAME - CsrWifiSmeSmeCommonConfigGetReq - - DESCRIPTION - This primitive gets the value of the Sme common parameter. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; -} CsrWifiSmeSmeCommonConfigGetReq; - -/******************************************************************************* - - NAME - CsrWifiSmeSmeCommonConfigSetReq - - DESCRIPTION - This primitive sets the value of the Sme common. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - deviceConfig - Configuration options in the SME - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - CsrWifiSmeDeviceConfig deviceConfig; -} CsrWifiSmeSmeCommonConfigSetReq; - -/******************************************************************************* - - NAME - CsrWifiSmeInterfaceCapabilityGetReq - - DESCRIPTION - The Wireless Manager calls this primitive to ask the SME for the - capabilities of the supported interfaces - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; -} CsrWifiSmeInterfaceCapabilityGetReq; - -/******************************************************************************* - - NAME - CsrWifiSmeWpsConfigurationReq - - DESCRIPTION - This primitive passes the WPS information for the device to SME. This may - be accepted only if no interface is active. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - wpsConfig - WPS config. - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - CsrWifiSmeWpsConfig wpsConfig; -} CsrWifiSmeWpsConfigurationReq; - -/******************************************************************************* - - NAME - CsrWifiSmeSetReq - - DESCRIPTION - Used to pass custom data to the SME. Format is the same as 802.11 Info - Elements => | Id | Length | Data - 1) Cmanr Test Mode "Id:0 Length:1 Data:0x00 = OFF 0x01 = ON" "0x00 0x01 - (0x00|0x01)" - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - dataLength - Number of bytes in the buffer pointed to by 'data' - data - Pointer to the buffer containing 'dataLength' bytes - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u32 dataLength; - u8 *data; -} CsrWifiSmeSetReq; - -/******************************************************************************* - - NAME - CsrWifiSmeActivateCfm - - DESCRIPTION - The SME sends this primitive when the activation is complete. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - status - Reports the result of the request - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - CsrResult status; -} CsrWifiSmeActivateCfm; - -/******************************************************************************* - - NAME - CsrWifiSmeAdhocConfigGetCfm - - DESCRIPTION - This primitive reports the result of the request. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - status - Reports the result of the request - adHocConfig - Contains the values used when starting an Ad-hoc (IBSS) - connection. - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - CsrResult status; - CsrWifiSmeAdHocConfig adHocConfig; -} CsrWifiSmeAdhocConfigGetCfm; - -/******************************************************************************* - - NAME - CsrWifiSmeAdhocConfigSetCfm - - DESCRIPTION - This primitive reports the result of the request. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - status - Reports the result of the request - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - CsrResult status; -} CsrWifiSmeAdhocConfigSetCfm; - -/******************************************************************************* - - NAME - CsrWifiSmeAssociationCompleteInd - - DESCRIPTION - The SME will send this primitive to all the tasks that have registered to - receive it whenever it completes an attempt to associate with an AP. If - the association was successful, status will be set to - CSR_WIFI_SME_STATUS_SUCCESS, otherwise status and deauthReason shall be - set to appropriate error codes. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - Interface Identifier; unique identifier of an interface - status - Reports the result of the association procedure - connectionInfo - This parameter is relevant only if result is - CSR_WIFI_SME_STATUS_SUCCESS: - it points to the connection information for the new network - deauthReason - This parameter is relevant only if result is not - CSR_WIFI_SME_STATUS_SUCCESS: - if the AP deauthorised the station, it gives the reason of - the deauthorization - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; - CsrResult status; - CsrWifiSmeConnectionInfo connectionInfo; - CsrWifiSmeIEEE80211Reason deauthReason; -} CsrWifiSmeAssociationCompleteInd; - -/******************************************************************************* - - NAME - CsrWifiSmeAssociationStartInd - - DESCRIPTION - The SME will send this primitive to all the tasks that have registered to - receive it whenever it begins an attempt to associate with an AP. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - Interface Identifier; unique identifier of an interface - address - BSSID of the associating network - ssid - Service Set identifier of the associating network - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; - CsrWifiMacAddress address; - CsrWifiSsid ssid; -} CsrWifiSmeAssociationStartInd; - -/******************************************************************************* - - NAME - CsrWifiSmeBlacklistCfm - - DESCRIPTION - The SME will call this primitive when the action on the blacklist has - completed. For a GET action, this primitive also reports the list of - BBSIDs in the blacklist. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - Interface Identifier; unique identifier of an interface - status - Reports the result of the request - action - Action in the request - getAddressCount - This parameter is only relevant if action is - CSR_WIFI_SME_LIST_ACTION_GET: - number of BSSIDs sent with this primitive - getAddresses - Pointer to the list of BBSIDs sent with the primitive, set - to NULL if none is sent. - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; - CsrResult status; - CsrWifiSmeListAction action; - u8 getAddressCount; - CsrWifiMacAddress *getAddresses; -} CsrWifiSmeBlacklistCfm; - -/******************************************************************************* - - NAME - CsrWifiSmeCalibrationDataGetCfm - - DESCRIPTION - This primitive reports the result of the request. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - status - Reports the result of the request - calibrationDataLength - Number of bytes in the buffer pointed by - calibrationData - calibrationData - Pointer to a buffer of length calibrationDataLength - containing the calibration data - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - CsrResult status; - u16 calibrationDataLength; - u8 *calibrationData; -} CsrWifiSmeCalibrationDataGetCfm; - -/******************************************************************************* - - NAME - CsrWifiSmeCalibrationDataSetCfm - - DESCRIPTION - This primitive reports the result of the request. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - status - Reports the result of the request - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - CsrResult status; -} CsrWifiSmeCalibrationDataSetCfm; - -/******************************************************************************* - - NAME - CsrWifiSmeCcxConfigGetCfm - - DESCRIPTION - This primitive reports the result of the request. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - Interface Identifier; unique identifier of an interface - status - Reports the result of the request - ccxConfig - Currently not supported - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; - CsrResult status; - CsrWifiSmeCcxConfig ccxConfig; -} CsrWifiSmeCcxConfigGetCfm; - -/******************************************************************************* - - NAME - CsrWifiSmeCcxConfigSetCfm - - DESCRIPTION - This primitive reports the result of the request. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - Interface Identifier; unique identifier of an interface - status - Reports the result of the request - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; - CsrResult status; -} CsrWifiSmeCcxConfigSetCfm; - -/******************************************************************************* - - NAME - CsrWifiSmeCoexConfigGetCfm - - DESCRIPTION - This primitive reports the result of the request. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - status - Reports the result of the request - coexConfig - Reports the parameters used to configure the coexistence - behaviour - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - CsrResult status; - CsrWifiSmeCoexConfig coexConfig; -} CsrWifiSmeCoexConfigGetCfm; - -/******************************************************************************* - - NAME - CsrWifiSmeCoexConfigSetCfm - - DESCRIPTION - This primitive reports the result of the request. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - status - Reports the result of the request - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - CsrResult status; -} CsrWifiSmeCoexConfigSetCfm; - -/******************************************************************************* - - NAME - CsrWifiSmeCoexInfoGetCfm - - DESCRIPTION - This primitive reports the result of the request. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - status - Reports the result of the request - coexInfo - Reports information and state related to coexistence. - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - CsrResult status; - CsrWifiSmeCoexInfo coexInfo; -} CsrWifiSmeCoexInfoGetCfm; - -/******************************************************************************* - - NAME - CsrWifiSmeConnectCfm - - DESCRIPTION - The SME calls this primitive when the connection exchange is complete or - all connection attempts fail. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - Interface Identifier; unique identifier of an interface - status - Reports the result of the request. - CSR_WIFI_SME_STATUS_NOT_FOUND: all attempts by the SME to - locate the requested AP failed - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; - CsrResult status; -} CsrWifiSmeConnectCfm; - -/******************************************************************************* - - NAME - CsrWifiSmeConnectionConfigGetCfm - - DESCRIPTION - This primitive reports the result of the request. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - Interface Identifier; unique identifier of an interface - status - Reports the result of the request - connectionConfig - Parameters used by the SME for selecting a network - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; - CsrResult status; - CsrWifiSmeConnectionConfig connectionConfig; -} CsrWifiSmeConnectionConfigGetCfm; - -/******************************************************************************* - - NAME - CsrWifiSmeConnectionInfoGetCfm - - DESCRIPTION - This primitive reports the result of the request. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - Interface Identifier; unique identifier of an interface - status - Reports the result of the request - connectionInfo - Information about the current connection - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; - CsrResult status; - CsrWifiSmeConnectionInfo connectionInfo; -} CsrWifiSmeConnectionInfoGetCfm; - -/******************************************************************************* - - NAME - CsrWifiSmeConnectionQualityInd - - DESCRIPTION - The SME sends this primitive to all the tasks that have registered to - receive it whenever the value of the current connection quality - parameters change by more than a certain configurable amount. - The wireless manager application may configure the trigger thresholds for - this indication using the field in smeConfig parameter of - CSR_WIFI_SME_SME_CONFIG_SET_REQ. - Connection quality messages can be suppressed by setting both thresholds - to zero. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - Interface Identifier; unique identifier of an interface - linkQuality - Indicates the quality of the link - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; - CsrWifiSmeLinkQuality linkQuality; -} CsrWifiSmeConnectionQualityInd; - -/******************************************************************************* - - NAME - CsrWifiSmeConnectionStatsGetCfm - - DESCRIPTION - This primitive reports the result of the request. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - Interface Identifier; unique identifier of an interface - status - Reports the result of the request - connectionStats - Statistics for current connection. - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; - CsrResult status; - CsrWifiSmeConnectionStats connectionStats; -} CsrWifiSmeConnectionStatsGetCfm; - -/******************************************************************************* - - NAME - CsrWifiSmeDeactivateCfm - - DESCRIPTION - The SME sends this primitive when the deactivation is complete. - The WMA cannot send any more primitives until it actives the SME again - sending another CSR_WIFI_SME_ACTIVATE_REQ. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - status - Reports the result of the request - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - CsrResult status; -} CsrWifiSmeDeactivateCfm; - -/******************************************************************************* - - NAME - CsrWifiSmeDisconnectCfm - - DESCRIPTION - On reception of CSR_WIFI_SME_DISCONNECT_REQ the SME will perform a - disconnect operation, sending a CsrWifiSmeMediaStatusInd with - CSR_WIFI_SME_MEDIA_STATUS_DISCONNECTED and then call this primitive when - disconnection is complete. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - Interface Identifier; unique identifier of an interface - status - Reports the result of the request - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; - CsrResult status; -} CsrWifiSmeDisconnectCfm; - -/******************************************************************************* - - NAME - CsrWifiSmeEventMaskSetCfm - - DESCRIPTION - The SME calls the primitive to report the result of the request - primitive. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - status - Reports the result of the request - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - CsrResult status; -} CsrWifiSmeEventMaskSetCfm; - -/******************************************************************************* - - NAME - CsrWifiSmeHostConfigGetCfm - - DESCRIPTION - This primitive reports the result of the request. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - Interface Identifier; unique identifier of an interface - status - Reports the result of the request - hostConfig - Current host power state. - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; - CsrResult status; - CsrWifiSmeHostConfig hostConfig; -} CsrWifiSmeHostConfigGetCfm; - -/******************************************************************************* - - NAME - CsrWifiSmeHostConfigSetCfm - - DESCRIPTION - This primitive reports the result of the request. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - Interface Identifier; unique identifier of an interface - status - Reports the result of the request - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; - CsrResult status; -} CsrWifiSmeHostConfigSetCfm; - -/******************************************************************************* - - NAME - CsrWifiSmeIbssStationInd - - DESCRIPTION - The SME will send this primitive to indicate that a station has joined or - left the ad-hoc network. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - address - MAC address of the station that has joined or left - isconnected - TRUE if the station joined, FALSE if the station left - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - CsrWifiMacAddress address; - u8 isconnected; -} CsrWifiSmeIbssStationInd; - -/******************************************************************************* - - NAME - CsrWifiSmeKeyCfm - - DESCRIPTION - The SME calls the primitive to report the result of the request - primitive. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - Interface Identifier; unique identifier of an interface - status - Reports the result of the request - action - Action in the request - keyType - Type of the key added/deleted - peerMacAddress - Peer MAC Address of the key added/deleted - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; - CsrResult status; - CsrWifiSmeListAction action; - CsrWifiSmeKeyType keyType; - CsrWifiMacAddress peerMacAddress; -} CsrWifiSmeKeyCfm; - -/******************************************************************************* - - NAME - CsrWifiSmeLinkQualityGetCfm - - DESCRIPTION - This primitive reports the result of the request. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - Interface Identifier; unique identifier of an interface - status - Reports the result of the request - linkQuality - Indicates the quality of the link - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; - CsrResult status; - CsrWifiSmeLinkQuality linkQuality; -} CsrWifiSmeLinkQualityGetCfm; - -/******************************************************************************* - - NAME - CsrWifiSmeMediaStatusInd - - DESCRIPTION - The SME sends this primitive to all the tasks that have registered to - receive it when a network connection is established, lost or has moved to - another AP. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - Interface Identifier; unique identifier of an interface - mediaStatus - Indicates the media status - connectionInfo - This parameter is relevant only if the mediaStatus is - CSR_WIFI_SME_MEDIA_STATUS_CONNECTED: - it points to the connection information for the new network - disassocReason - This parameter is relevant only if the mediaStatus is - CSR_WIFI_SME_MEDIA_STATUS_DISCONNECTED: - if a disassociation has occurred it gives the reason of the - disassociation - deauthReason - This parameter is relevant only if the mediaStatus is - CSR_WIFI_SME_MEDIA_STATUS_DISCONNECTED: - if a deauthentication has occurred it gives the reason of - the deauthentication - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; - CsrWifiSmeMediaStatus mediaStatus; - CsrWifiSmeConnectionInfo connectionInfo; - CsrWifiSmeIEEE80211Reason disassocReason; - CsrWifiSmeIEEE80211Reason deauthReason; -} CsrWifiSmeMediaStatusInd; - -/******************************************************************************* - - NAME - CsrWifiSmeMibConfigGetCfm - - DESCRIPTION - This primitive reports the result of the request. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - status - Reports the result of the request - mibConfig - Reports various IEEE 802.11 attributes as currently configured - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - CsrResult status; - CsrWifiSmeMibConfig mibConfig; -} CsrWifiSmeMibConfigGetCfm; - -/******************************************************************************* - - NAME - CsrWifiSmeMibConfigSetCfm - - DESCRIPTION - This primitive reports the result of the request. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - status - Reports the result of the request - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - CsrResult status; -} CsrWifiSmeMibConfigSetCfm; - -/******************************************************************************* - - NAME - CsrWifiSmeMibGetCfm - - DESCRIPTION - The SME calls this primitive to return the requested MIB variable values. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - status - Reports the result of the request - mibAttributeLength - Length of mibAttribute - mibAttribute - Points to the VarBind or VarBindList containing the - names and values of the MIB variables requested - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - CsrResult status; - u16 mibAttributeLength; - u8 *mibAttribute; -} CsrWifiSmeMibGetCfm; - -/******************************************************************************* - - NAME - CsrWifiSmeMibGetNextCfm - - DESCRIPTION - The SME calls this primitive to return the requested MIB name(s). - The wireless manager application can then read the value of the MIB - variable using CSR_WIFI_SME_MIB_GET_REQ, using the names provided. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - status - Reports the result of the request - mibAttributeLength - Length of mibAttribute - mibAttribute - Points to a VarBind or VarBindList containing the - name(s) of the MIB variable(s) lexicographically - following the name(s) given in the request - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - CsrResult status; - u16 mibAttributeLength; - u8 *mibAttribute; -} CsrWifiSmeMibGetNextCfm; - -/******************************************************************************* - - NAME - CsrWifiSmeMibSetCfm - - DESCRIPTION - The SME calls the primitive to report the result of the set primitive. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - status - Reports the result of the request - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - CsrResult status; -} CsrWifiSmeMibSetCfm; - -/******************************************************************************* - - NAME - CsrWifiSmeMicFailureInd - - DESCRIPTION - The SME sends this primitive to all the tasks that have registered to - receive it whenever the chip firmware reports a MIC failure. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - Interface Identifier; unique identifier of an interface - secondFailure - TRUE if this indication is for a second failure in 60 - seconds - count - The number of MIC failure events since the connection was - established - address - MAC address of the transmitter that caused the MIC failure - keyType - Type of key for which the failure occurred - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; - u8 secondFailure; - u16 count; - CsrWifiMacAddress address; - CsrWifiSmeKeyType keyType; -} CsrWifiSmeMicFailureInd; - -/******************************************************************************* - - NAME - CsrWifiSmeMulticastAddressCfm - - DESCRIPTION - The SME will call this primitive when the operation is complete. For a - GET action, this primitive reports the current list of MAC addresses. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - Interface Identifier; unique identifier of an interface - status - Reports the result of the request - action - Action in the request - getAddressesCount - This parameter is only relevant if action is - CSR_WIFI_SME_LIST_ACTION_GET: - number of MAC addresses sent with the primitive - getAddresses - Pointer to the list of MAC Addresses sent with the - primitive, set to NULL if none is sent. - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; - CsrResult status; - CsrWifiSmeListAction action; - u8 getAddressesCount; - CsrWifiMacAddress *getAddresses; -} CsrWifiSmeMulticastAddressCfm; - -/******************************************************************************* - - NAME - CsrWifiSmePacketFilterSetCfm - - DESCRIPTION - The SME calls the primitive to report the result of the set primitive. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - Interface Identifier; unique identifier of an interface - status - Reports the result of the request - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; - CsrResult status; -} CsrWifiSmePacketFilterSetCfm; - -/******************************************************************************* - - NAME - CsrWifiSmePermanentMacAddressGetCfm - - DESCRIPTION - This primitive reports the result of the request. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - status - Reports the result of the request - permanentMacAddress - MAC address stored in the EEPROM - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - CsrResult status; - CsrWifiMacAddress permanentMacAddress; -} CsrWifiSmePermanentMacAddressGetCfm; - -/******************************************************************************* - - NAME - CsrWifiSmePmkidCandidateListInd - - DESCRIPTION - The SME will send this primitive to all the tasks that have registered to - receive it when a new network supporting preauthentication and/or PMK - caching is seen. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - Interface Identifier; unique identifier of an - interface - pmkidCandidatesCount - Number of PMKID candidates provided - pmkidCandidates - Points to the first PMKID candidate - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; - u8 pmkidCandidatesCount; - CsrWifiSmePmkidCandidate *pmkidCandidates; -} CsrWifiSmePmkidCandidateListInd; - -/******************************************************************************* - - NAME - CsrWifiSmePmkidCfm - - DESCRIPTION - The SME will call this primitive when the operation is complete. For a - GET action, this primitive reports the current list of PMKIDs - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - Interface Identifier; unique identifier of an interface - status - Reports the result of the request - action - Action in the request - getPmkidsCount - This parameter is only relevant if action is - CSR_WIFI_SME_LIST_ACTION_GET: - number of PMKIDs sent with the primitive - getPmkids - Pointer to the list of PMKIDs sent with the primitive, set - to NULL if none is sent. - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; - CsrResult status; - CsrWifiSmeListAction action; - u8 getPmkidsCount; - CsrWifiSmePmkid *getPmkids; -} CsrWifiSmePmkidCfm; - -/******************************************************************************* - - NAME - CsrWifiSmePowerConfigGetCfm - - DESCRIPTION - This primitive reports the result of the request. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - status - Reports the result of the request - powerConfig - Returns the current parameters for the power configuration of - the firmware - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - CsrResult status; - CsrWifiSmePowerConfig powerConfig; -} CsrWifiSmePowerConfigGetCfm; - -/******************************************************************************* - - NAME - CsrWifiSmePowerConfigSetCfm - - DESCRIPTION - This primitive reports the result of the request. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - status - Reports the result of the request - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - CsrResult status; -} CsrWifiSmePowerConfigSetCfm; - -/******************************************************************************* - - NAME - CsrWifiSmeRegulatoryDomainInfoGetCfm - - DESCRIPTION - This primitive reports the result of the request. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - status - Reports the result of the request - regDomInfo - Reports information and state related to regulatory domain - operation. - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - CsrResult status; - CsrWifiSmeRegulatoryDomainInfo regDomInfo; -} CsrWifiSmeRegulatoryDomainInfoGetCfm; - -/******************************************************************************* - - NAME - CsrWifiSmeRoamCompleteInd - - DESCRIPTION - The SME will send this primitive to all the tasks that have registered to - receive it whenever it completes an attempt to roam to an AP. If the roam - attempt was successful, status will be set to CSR_WIFI_SME_SUCCESS, - otherwise it shall be set to the appropriate error code. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - Interface Identifier; unique identifier of an interface - status - Reports the result of the roaming procedure - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; - CsrResult status; -} CsrWifiSmeRoamCompleteInd; - -/******************************************************************************* - - NAME - CsrWifiSmeRoamStartInd - - DESCRIPTION - The SME will send this primitive to all the tasks that have registered to - receive it whenever it begins an attempt to roam to an AP. - If the wireless manager application connect request specified the SSID - and the BSSID was set to the broadcast address (0xFF 0xFF 0xFF 0xFF 0xFF - 0xFF), the SME monitors the signal quality and maintains a list of - candidates to roam to. When the signal quality of the current connection - falls below a threshold, and there is a candidate with better quality, - the SME will attempt to the candidate AP. - If the roaming procedure succeeds, the SME will also issue a Media - Connect indication to inform the wireless manager application of the - change. - NOTE: to prevent the SME from initiating roaming the WMA must specify the - BSSID in the connection request; this forces the SME to connect only to - that AP. - The wireless manager application can obtain statistics for roaming - purposes using CSR_WIFI_SME_CONNECTION_QUALITY_IND and - CSR_WIFI_SME_CONNECTION_STATS_GET_REQ. - When the wireless manager application wishes to roam to another AP, it - must issue a connection request specifying the BSSID of the desired AP. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - Interface Identifier; unique identifier of an interface - roamReason - Indicates the reason for starting the roaming procedure - reason80211 - Indicates the reason for deauthentication or disassociation - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; - CsrWifiSmeRoamReason roamReason; - CsrWifiSmeIEEE80211Reason reason80211; -} CsrWifiSmeRoamStartInd; - -/******************************************************************************* - - NAME - CsrWifiSmeRoamingConfigGetCfm - - DESCRIPTION - This primitive reports the result of the request. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - Interface Identifier; unique identifier of an interface - status - Reports the result of the request - roamingConfig - Reports the roaming behaviour of the driver and firmware - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; - CsrResult status; - CsrWifiSmeRoamingConfig roamingConfig; -} CsrWifiSmeRoamingConfigGetCfm; - -/******************************************************************************* - - NAME - CsrWifiSmeRoamingConfigSetCfm - - DESCRIPTION - This primitive sets the value of the RoamingConfig parameter. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - Interface Identifier; unique identifier of an interface - status - Reports the result of the request - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; - CsrResult status; -} CsrWifiSmeRoamingConfigSetCfm; - -/******************************************************************************* - - NAME - CsrWifiSmeScanConfigGetCfm - - DESCRIPTION - This primitive reports the result of the request. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - status - Reports the result of the request - scanConfig - Returns the current parameters for the autonomous scanning - behaviour of the firmware - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - CsrResult status; - CsrWifiSmeScanConfig scanConfig; -} CsrWifiSmeScanConfigGetCfm; - -/******************************************************************************* - - NAME - CsrWifiSmeScanConfigSetCfm - - DESCRIPTION - This primitive reports the result of the request. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - status - Reports the result of the request - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - CsrResult status; -} CsrWifiSmeScanConfigSetCfm; - -/******************************************************************************* - - NAME - CsrWifiSmeScanFullCfm - - DESCRIPTION - The SME calls this primitive when the results from the scan are - available. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - status - Reports the result of the request - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - CsrResult status; -} CsrWifiSmeScanFullCfm; - -/******************************************************************************* - - NAME - CsrWifiSmeScanResultInd - - DESCRIPTION - The SME sends this primitive to all the tasks that have registered to - receive it whenever a scan indication is received from the firmware. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - result - Points to a buffer containing a scan result. - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - CsrWifiSmeScanResult result; -} CsrWifiSmeScanResultInd; - -/******************************************************************************* - - NAME - CsrWifiSmeScanResultsFlushCfm - - DESCRIPTION - The SME will call this primitive when the cache has been cleared. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - status - Reports the result of the request - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - CsrResult status; -} CsrWifiSmeScanResultsFlushCfm; - -/******************************************************************************* - - NAME - CsrWifiSmeScanResultsGetCfm - - DESCRIPTION - The SME sends this primitive to provide the current set of scan results. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - status - Reports the result of the request - scanResultsCount - Number of scan results - scanResults - Points to a buffer containing an array of - CsrWifiSmeScanResult structures. - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - CsrResult status; - u16 scanResultsCount; - CsrWifiSmeScanResult *scanResults; -} CsrWifiSmeScanResultsGetCfm; - -/******************************************************************************* - - NAME - CsrWifiSmeSmeStaConfigGetCfm - - DESCRIPTION - This primitive reports the result of the request. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - Interface Identifier; unique identifier of an interface - status - Reports the result of the request - smeConfig - Current SME Station Parameters - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; - CsrResult status; - CsrWifiSmeStaConfig smeConfig; -} CsrWifiSmeSmeStaConfigGetCfm; - -/******************************************************************************* - - NAME - CsrWifiSmeSmeStaConfigSetCfm - - DESCRIPTION - This primitive reports the result of the request. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - Interface Identifier; unique identifier of an interface - status - Reports the result of the request - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; - CsrResult status; -} CsrWifiSmeSmeStaConfigSetCfm; - -/******************************************************************************* - - NAME - CsrWifiSmeStationMacAddressGetCfm - - DESCRIPTION - This primitive reports the result of the request. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - status - Reports the result of the request - stationMacAddress - Current MAC address of the station. - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - CsrResult status; - CsrWifiMacAddress stationMacAddress[2]; -} CsrWifiSmeStationMacAddressGetCfm; - -/******************************************************************************* - - NAME - CsrWifiSmeTspecInd - - DESCRIPTION - The SME will send this primitive to all the task that have registered to - receive it when a status change in the TSPEC occurs. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - Interface Identifier; unique identifier of an interface - transactionId - Unique Transaction ID for the TSPEC, as assigned by the - driver - tspecResultCode - Specifies the TSPEC operation requested by the peer - station - tspecLength - Length of the TSPEC. - tspec - Points to the first byte of the TSPEC - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; - u32 transactionId; - CsrWifiSmeTspecResultCode tspecResultCode; - u16 tspecLength; - u8 *tspec; -} CsrWifiSmeTspecInd; - -/******************************************************************************* - - NAME - CsrWifiSmeTspecCfm - - DESCRIPTION - The SME calls the primitive to report the result of the TSpec primitive - request. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - Interface Identifier; unique identifier of an interface - status - Reports the result of the request - transactionId - Unique Transaction ID for the TSPEC, as assigned by the - driver - tspecResultCode - Specifies the result of the negotiated TSPEC operation - tspecLength - Length of the TSPEC. - tspec - Points to the first byte of the TSPEC - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; - CsrResult status; - u32 transactionId; - CsrWifiSmeTspecResultCode tspecResultCode; - u16 tspecLength; - u8 *tspec; -} CsrWifiSmeTspecCfm; - -/******************************************************************************* - - NAME - CsrWifiSmeVersionsGetCfm - - DESCRIPTION - This primitive reports the result of the request. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - status - Reports the result of the request - versions - Version IDs of the product - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - CsrResult status; - CsrWifiSmeVersions versions; -} CsrWifiSmeVersionsGetCfm; - -/******************************************************************************* - - NAME - CsrWifiSmeWifiFlightmodeCfm - - DESCRIPTION - The SME calls this primitive when the chip is initialised for low power - mode and with the radio subsystem disabled. To leave flight mode, and - enable Wi-Fi, the wireless manager application should call - CSR_WIFI_SME_WIFI_ON_REQ. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - status - Reports the result of the request - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - CsrResult status; -} CsrWifiSmeWifiFlightmodeCfm; - -/******************************************************************************* - - NAME - CsrWifiSmeWifiOffInd - - DESCRIPTION - The SME sends this primitive to all the tasks that have registered to - receive it to report that the chip has been turned off. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - reason - Indicates the reason why the Wi-Fi has been switched off. - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - CsrWifiSmeControlIndication reason; -} CsrWifiSmeWifiOffInd; - -/******************************************************************************* - - NAME - CsrWifiSmeWifiOffCfm - - DESCRIPTION - After receiving CSR_WIFI_SME_WIFI_OFF_REQ, if the chip is connected to a - network, the SME will perform a disconnect operation, will send a - CSR_WIFI_SME_MEDIA_STATUS_IND with - CSR_WIFI_SME_MEDIA_STATUS_DISCONNECTED, and then will call - CSR_WIFI_SME_WIFI_OFF_CFM when the chip is off. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - status - Reports the result of the request - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - CsrResult status; -} CsrWifiSmeWifiOffCfm; - -/******************************************************************************* - - NAME - CsrWifiSmeWifiOnCfm - - DESCRIPTION - The SME sends this primitive to the task that has sent the request once - the chip has been initialised and is available for use. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - status - Reports the result of the request - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - CsrResult status; -} CsrWifiSmeWifiOnCfm; - -/******************************************************************************* - - NAME - CsrWifiSmeCloakedSsidsSetCfm - - DESCRIPTION - This primitive reports the result of the request. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - status - Reports the result of the request - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - CsrResult status; -} CsrWifiSmeCloakedSsidsSetCfm; - -/******************************************************************************* - - NAME - CsrWifiSmeCloakedSsidsGetCfm - - DESCRIPTION - This primitive reports the result of the request. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - status - Reports the result of the request - cloakedSsids - Reports list of cloaked SSIDs that are explicitly scanned for - by the driver - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - CsrResult status; - CsrWifiSmeCloakedSsidConfig cloakedSsids; -} CsrWifiSmeCloakedSsidsGetCfm; - -/******************************************************************************* - - NAME - CsrWifiSmeWifiOnInd - - DESCRIPTION - The SME sends this primitive to all tasks that have registered to receive - it once the chip becomes available and ready to use. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - address - Current MAC address - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - CsrWifiMacAddress address; -} CsrWifiSmeWifiOnInd; - -/******************************************************************************* - - NAME - CsrWifiSmeSmeCommonConfigGetCfm - - DESCRIPTION - This primitive reports the result of the request. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - status - Reports the result of the request - deviceConfig - Configuration options in the SME - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - CsrResult status; - CsrWifiSmeDeviceConfig deviceConfig; -} CsrWifiSmeSmeCommonConfigGetCfm; - -/******************************************************************************* - - NAME - CsrWifiSmeSmeCommonConfigSetCfm - - DESCRIPTION - Reports the result of the request - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - status - Reports the result of the request - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - CsrResult status; -} CsrWifiSmeSmeCommonConfigSetCfm; - -/******************************************************************************* - - NAME - CsrWifiSmeInterfaceCapabilityGetCfm - - DESCRIPTION - This primitive reports the result of the request. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - status - Result of the request - numInterfaces - Number of the interfaces supported - capBitmap - Points to the list of capabilities bitmaps provided for each - interface. - The bits represent the following capabilities: - -bits 7 to 4-Reserved - -bit 3-AMP - -bit 2-P2P - -bit 1-AP - -bit 0-STA - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - CsrResult status; - u16 numInterfaces; - u8 capBitmap[2]; -} CsrWifiSmeInterfaceCapabilityGetCfm; - -/******************************************************************************* - - NAME - CsrWifiSmeErrorInd - - DESCRIPTION - Important error message indicating a error of some importance - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - errorMessage - Contains the error message. - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - char *errorMessage; -} CsrWifiSmeErrorInd; - -/******************************************************************************* - - NAME - CsrWifiSmeInfoInd - - DESCRIPTION - Message indicating a some info about current activity. Mostly of interest - in testing but may be useful in the field. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - infoMessage - Contains the message. - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - char *infoMessage; -} CsrWifiSmeInfoInd; - -/******************************************************************************* - - NAME - CsrWifiSmeCoreDumpInd - - DESCRIPTION - The SME will send this primitive to all the tasks that have registered to - receive Wi-Fi Chip core dump data. - The core dump data may be fragmented and sent using more than one - indication. - To indicate that all the data has been sent, the last indication contains - a 'length' of 0 and 'data' of NULL. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - dataLength - Number of bytes in the buffer pointed to by 'data' - data - Pointer to the buffer containing 'dataLength' bytes of core - dump data - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u32 dataLength; - u8 *data; -} CsrWifiSmeCoreDumpInd; - -/******************************************************************************* - - NAME - CsrWifiSmeAmpStatusChangeInd - - DESCRIPTION - Indication of change to AMP activity. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - interfaceTag - Interface on which the AMP activity changed. - ampStatus - The new status of AMP activity.Range: {AMP_ACTIVE, - AMP_INACTIVE}. - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - u16 interfaceTag; - CsrWifiSmeAmpStatus ampStatus; -} CsrWifiSmeAmpStatusChangeInd; - -/******************************************************************************* - - NAME - CsrWifiSmeWpsConfigurationCfm - - DESCRIPTION - Confirm. - - MEMBERS - common - Common header for use with the CsrWifiFsm Module - status - Status of the request. - -*******************************************************************************/ -typedef struct -{ - CsrWifiFsmEvent common; - CsrResult status; -} CsrWifiSmeWpsConfigurationCfm; - -#endif /* CSR_WIFI_SME_PRIM_H__ */ - diff --git a/drivers/staging/csr/csr_wifi_sme_sef.c b/drivers/staging/csr/csr_wifi_sme_sef.c deleted file mode 100644 index cf32254335c4..000000000000 --- a/drivers/staging/csr/csr_wifi_sme_sef.c +++ /dev/null @@ -1,85 +0,0 @@ -/***************************************************************************** - - (c) Cambridge Silicon Radio Limited 2010 - Confidential information of CSR - - Refer to LICENSE.txt included with this source for details - on the license terms. - - *****************************************************************************/ -#include "csr_wifi_sme_sef.h" - -const CsrWifiSmeStateHandlerType CsrWifiSmeUpstreamStateHandlers[CSR_WIFI_SME_PRIM_UPSTREAM_COUNT] = -{ - /* 0x8000 */ CsrWifiSmeActivateCfmHandler, - /* 0x8001 */ CsrWifiSmeAdhocConfigGetCfmHandler, - /* 0x8002 */ CsrWifiSmeAdhocConfigSetCfmHandler, - /* 0x8003 */ CsrWifiSmeAssociationCompleteIndHandler, - /* 0x8004 */ CsrWifiSmeAssociationStartIndHandler, - /* 0x8005 */ CsrWifiSmeBlacklistCfmHandler, - /* 0x8006 */ CsrWifiSmeCalibrationDataGetCfmHandler, - /* 0x8007 */ CsrWifiSmeCalibrationDataSetCfmHandler, - /* 0x8008 */ CsrWifiSmeCcxConfigGetCfmHandler, - /* 0x8009 */ CsrWifiSmeCcxConfigSetCfmHandler, - /* 0x800A */ CsrWifiSmeCoexConfigGetCfmHandler, - /* 0x800B */ CsrWifiSmeCoexConfigSetCfmHandler, - /* 0x800C */ CsrWifiSmeCoexInfoGetCfmHandler, - /* 0x800D */ CsrWifiSmeConnectCfmHandler, - /* 0x800E */ CsrWifiSmeConnectionConfigGetCfmHandler, - /* 0x800F */ CsrWifiSmeConnectionInfoGetCfmHandler, - /* 0x8010 */ CsrWifiSmeConnectionQualityIndHandler, - /* 0x8011 */ CsrWifiSmeConnectionStatsGetCfmHandler, - /* 0x8012 */ CsrWifiSmeDeactivateCfmHandler, - /* 0x8013 */ CsrWifiSmeDisconnectCfmHandler, - /* 0x8014 */ CsrWifiSmeEventMaskSetCfmHandler, - /* 0x8015 */ CsrWifiSmeHostConfigGetCfmHandler, - /* 0x8016 */ CsrWifiSmeHostConfigSetCfmHandler, - /* 0x8017 */ CsrWifiSmeIbssStationIndHandler, - /* 0x8018 */ CsrWifiSmeKeyCfmHandler, - /* 0x8019 */ CsrWifiSmeLinkQualityGetCfmHandler, - /* 0x801A */ CsrWifiSmeMediaStatusIndHandler, - /* 0x801B */ CsrWifiSmeMibConfigGetCfmHandler, - /* 0x801C */ CsrWifiSmeMibConfigSetCfmHandler, - /* 0x801D */ CsrWifiSmeMibGetCfmHandler, - /* 0x801E */ CsrWifiSmeMibGetNextCfmHandler, - /* 0x801F */ CsrWifiSmeMibSetCfmHandler, - /* 0x8020 */ CsrWifiSmeMicFailureIndHandler, - /* 0x8021 */ CsrWifiSmeMulticastAddressCfmHandler, - /* 0x8022 */ CsrWifiSmePacketFilterSetCfmHandler, - /* 0x8023 */ CsrWifiSmePermanentMacAddressGetCfmHandler, - /* 0x8024 */ CsrWifiSmePmkidCandidateListIndHandler, - /* 0x8025 */ CsrWifiSmePmkidCfmHandler, - /* 0x8026 */ CsrWifiSmePowerConfigGetCfmHandler, - /* 0x8027 */ CsrWifiSmePowerConfigSetCfmHandler, - /* 0x8028 */ CsrWifiSmeRegulatoryDomainInfoGetCfmHandler, - /* 0x8029 */ CsrWifiSmeRoamCompleteIndHandler, - /* 0x802A */ CsrWifiSmeRoamStartIndHandler, - /* 0x802B */ CsrWifiSmeRoamingConfigGetCfmHandler, - /* 0x802C */ CsrWifiSmeRoamingConfigSetCfmHandler, - /* 0x802D */ CsrWifiSmeScanConfigGetCfmHandler, - /* 0x802E */ CsrWifiSmeScanConfigSetCfmHandler, - /* 0x802F */ CsrWifiSmeScanFullCfmHandler, - /* 0x8030 */ CsrWifiSmeScanResultIndHandler, - /* 0x8031 */ CsrWifiSmeScanResultsFlushCfmHandler, - /* 0x8032 */ CsrWifiSmeScanResultsGetCfmHandler, - /* 0x8033 */ CsrWifiSmeSmeStaConfigGetCfmHandler, - /* 0x8034 */ CsrWifiSmeSmeStaConfigSetCfmHandler, - /* 0x8035 */ CsrWifiSmeStationMacAddressGetCfmHandler, - /* 0x8036 */ CsrWifiSmeTspecIndHandler, - /* 0x8037 */ CsrWifiSmeTspecCfmHandler, - /* 0x8038 */ CsrWifiSmeVersionsGetCfmHandler, - /* 0x8039 */ CsrWifiSmeWifiFlightmodeCfmHandler, - /* 0x803A */ CsrWifiSmeWifiOffIndHandler, - /* 0x803B */ CsrWifiSmeWifiOffCfmHandler, - /* 0x803C */ CsrWifiSmeWifiOnCfmHandler, - /* 0x803D */ CsrWifiSmeCloakedSsidsSetCfmHandler, - /* 0x803E */ CsrWifiSmeCloakedSsidsGetCfmHandler, - /* 0x803F */ CsrWifiSmeWifiOnIndHandler, - /* 0x8040 */ CsrWifiSmeSmeCommonConfigGetCfmHandler, - /* 0x8041 */ CsrWifiSmeSmeCommonConfigSetCfmHandler, - /* 0x8042 */ CsrWifiSmeGetInterfaceCapabilityCfmHandler, - /* 0x8043 */ CsrWifiSmeErrorIndHandler, - /* 0x8044 */ CsrWifiSmeInfoIndHandler, - /* 0x8045 */ CsrWifiSmeCoreDumpIndHandler, - /* 0x8046 */ CsrWifiSmeAmpStatusChangeIndHandler, -}; diff --git a/drivers/staging/csr/csr_wifi_sme_sef.h b/drivers/staging/csr/csr_wifi_sme_sef.h deleted file mode 100644 index 78b88c067236..000000000000 --- a/drivers/staging/csr/csr_wifi_sme_sef.h +++ /dev/null @@ -1,142 +0,0 @@ -/***************************************************************************** - - (c) Cambridge Silicon Radio Limited 2010 - Confidential information of CSR - - Refer to LICENSE.txt included with this source for details - on the license terms. - -*****************************************************************************/ -#ifndef CSR_WIFI_ROUTER_SEF_CSR_WIFI_SME_H__ -#define CSR_WIFI_ROUTER_SEF_CSR_WIFI_SME_H__ - -#include "csr_wifi_sme_prim.h" - -typedef void (*CsrWifiSmeStateHandlerType)(void *drvpriv, CsrWifiFsmEvent *msg); - -extern const CsrWifiSmeStateHandlerType - CsrWifiSmeUpstreamStateHandlers[CSR_WIFI_SME_PRIM_UPSTREAM_COUNT]; - - -extern void CsrWifiSmeActivateCfmHandler(void *drvpriv, CsrWifiFsmEvent *msg); -extern void CsrWifiSmeAdhocConfigGetCfmHandler(void *drvpriv, - CsrWifiFsmEvent *msg); -extern void CsrWifiSmeAdhocConfigSetCfmHandler(void *drvpriv, - CsrWifiFsmEvent *msg); -extern void CsrWifiSmeAssociationCompleteIndHandler(void *drvpriv, - CsrWifiFsmEvent *msg); -extern void CsrWifiSmeAssociationStartIndHandler(void *drvpriv, - CsrWifiFsmEvent *msg); -extern void CsrWifiSmeBlacklistCfmHandler(void *drvpriv, - CsrWifiFsmEvent *msg); -extern void CsrWifiSmeCalibrationDataGetCfmHandler(void *drvpriv, - CsrWifiFsmEvent *msg); -extern void CsrWifiSmeCalibrationDataSetCfmHandler(void *drvpriv, - CsrWifiFsmEvent *msg); -extern void CsrWifiSmeCcxConfigGetCfmHandler(void *drvpriv, - CsrWifiFsmEvent *msg); -extern void CsrWifiSmeCcxConfigSetCfmHandler(void *drvpriv, - CsrWifiFsmEvent *msg); -extern void CsrWifiSmeCoexConfigGetCfmHandler(void *drvpriv, - CsrWifiFsmEvent *msg); -extern void CsrWifiSmeCoexConfigSetCfmHandler(void *drvpriv, - CsrWifiFsmEvent *msg); -extern void CsrWifiSmeCoexInfoGetCfmHandler(void *drvpriv, - CsrWifiFsmEvent *msg); -extern void CsrWifiSmeConnectCfmHandler(void *drvpriv, CsrWifiFsmEvent *msg); -extern void CsrWifiSmeConnectionConfigGetCfmHandler(void *drvpriv, - CsrWifiFsmEvent *msg); -extern void CsrWifiSmeConnectionInfoGetCfmHandler(void *drvpriv, - CsrWifiFsmEvent *msg); -extern void CsrWifiSmeConnectionQualityIndHandler(void *drvpriv, - CsrWifiFsmEvent *msg); -extern void CsrWifiSmeConnectionStatsGetCfmHandler(void *drvpriv, - CsrWifiFsmEvent *msg); -extern void CsrWifiSmeDeactivateCfmHandler(void *drvpriv, CsrWifiFsmEvent *msg); -extern void CsrWifiSmeDisconnectCfmHandler(void *drvpriv, CsrWifiFsmEvent *msg); -extern void CsrWifiSmeEventMaskSetCfmHandler(void *drvpriv, - CsrWifiFsmEvent *msg); -extern void CsrWifiSmeHostConfigGetCfmHandler(void *drvpriv, - CsrWifiFsmEvent *msg); -extern void CsrWifiSmeHostConfigSetCfmHandler(void *drvpriv, - CsrWifiFsmEvent *msg); -extern void CsrWifiSmeIbssStationIndHandler(void *drvpriv, - CsrWifiFsmEvent *msg); -extern void CsrWifiSmeKeyCfmHandler(void *drvpriv, CsrWifiFsmEvent *msg); -extern void CsrWifiSmeLinkQualityGetCfmHandler(void *drvpriv, - CsrWifiFsmEvent *msg); -extern void CsrWifiSmeMediaStatusIndHandler(void *drvpriv, - CsrWifiFsmEvent *msg); -extern void CsrWifiSmeMibConfigGetCfmHandler(void *drvpriv, - CsrWifiFsmEvent *msg); -extern void CsrWifiSmeMibConfigSetCfmHandler(void *drvpriv, - CsrWifiFsmEvent *msg); -extern void CsrWifiSmeMibGetCfmHandler(void *drvpriv, CsrWifiFsmEvent *msg); -extern void CsrWifiSmeMibGetNextCfmHandler(void *drvpriv, CsrWifiFsmEvent *msg); -extern void CsrWifiSmeMibSetCfmHandler(void *drvpriv, CsrWifiFsmEvent *msg); -extern void CsrWifiSmeMicFailureIndHandler(void *drvpriv, CsrWifiFsmEvent *msg); -extern void CsrWifiSmeMulticastAddressCfmHandler(void *drvpriv, - CsrWifiFsmEvent *msg); -extern void CsrWifiSmePacketFilterSetCfmHandler(void *drvpriv, - CsrWifiFsmEvent *msg); -extern void CsrWifiSmePermanentMacAddressGetCfmHandler(void *drvpriv, - CsrWifiFsmEvent *msg); -extern void CsrWifiSmePmkidCandidateListIndHandler(void *drvpriv, - CsrWifiFsmEvent *msg); -extern void CsrWifiSmePmkidCfmHandler(void *drvpriv, CsrWifiFsmEvent *msg); -extern void CsrWifiSmePowerConfigGetCfmHandler(void *drvpriv, - CsrWifiFsmEvent *msg); -extern void CsrWifiSmePowerConfigSetCfmHandler(void *drvpriv, - CsrWifiFsmEvent *msg); -extern void CsrWifiSmeRegulatoryDomainInfoGetCfmHandler(void *drvpriv, - CsrWifiFsmEvent *msg); -extern void CsrWifiSmeRoamCompleteIndHandler(void *drvpriv, - CsrWifiFsmEvent *msg); -extern void CsrWifiSmeRoamStartIndHandler(void *drvpriv, CsrWifiFsmEvent *msg); -extern void CsrWifiSmeRoamingConfigGetCfmHandler(void *drvpriv, - CsrWifiFsmEvent *msg); -extern void CsrWifiSmeRoamingConfigSetCfmHandler(void *drvpriv, - CsrWifiFsmEvent *msg); -extern void CsrWifiSmeScanConfigGetCfmHandler(void *drvpriv, - CsrWifiFsmEvent *msg); -extern void CsrWifiSmeScanConfigSetCfmHandler(void *drvpriv, - CsrWifiFsmEvent *msg); -extern void CsrWifiSmeScanFullCfmHandler(void *drvpriv, CsrWifiFsmEvent *msg); -extern void CsrWifiSmeScanResultIndHandler(void *drvpriv, CsrWifiFsmEvent *msg); -extern void CsrWifiSmeScanResultsFlushCfmHandler(void *drvpriv, - CsrWifiFsmEvent *msg); -extern void CsrWifiSmeScanResultsGetCfmHandler(void *drvpriv, - CsrWifiFsmEvent *msg); -extern void CsrWifiSmeSmeStaConfigGetCfmHandler(void *drvpriv, - CsrWifiFsmEvent *msg); -extern void CsrWifiSmeSmeStaConfigSetCfmHandler(void *drvpriv, - CsrWifiFsmEvent *msg); -extern void CsrWifiSmeStationMacAddressGetCfmHandler(void *drvpriv, - CsrWifiFsmEvent *msg); -extern void CsrWifiSmeTspecIndHandler(void *drvpriv, CsrWifiFsmEvent *msg); -extern void CsrWifiSmeTspecCfmHandler(void *drvpriv, CsrWifiFsmEvent *msg); -extern void CsrWifiSmeVersionsGetCfmHandler(void *drvpriv, - CsrWifiFsmEvent *msg); -extern void CsrWifiSmeWifiFlightmodeCfmHandler(void *drvpriv, - CsrWifiFsmEvent *msg); -extern void CsrWifiSmeWifiOffIndHandler(void *drvpriv, CsrWifiFsmEvent *msg); -extern void CsrWifiSmeWifiOffCfmHandler(void *drvpriv, CsrWifiFsmEvent *msg); -extern void CsrWifiSmeWifiOnCfmHandler(void *drvpriv, CsrWifiFsmEvent *msg); -extern void CsrWifiSmeCloakedSsidsSetCfmHandler(void *drvpriv, - CsrWifiFsmEvent *msg); -extern void CsrWifiSmeCloakedSsidsGetCfmHandler(void *drvpriv, - CsrWifiFsmEvent *msg); -extern void CsrWifiSmeWifiOnIndHandler(void *drvpriv, CsrWifiFsmEvent *msg); -extern void CsrWifiSmeSmeCommonConfigGetCfmHandler(void *drvpriv, - CsrWifiFsmEvent *msg); -extern void CsrWifiSmeSmeCommonConfigSetCfmHandler(void *drvpriv, - CsrWifiFsmEvent *msg); -extern void CsrWifiSmeGetInterfaceCapabilityCfmHandler(void *drvpriv, - CsrWifiFsmEvent *msg); -extern void CsrWifiSmeErrorIndHandler(void *drvpriv, CsrWifiFsmEvent *msg); -extern void CsrWifiSmeInfoIndHandler(void *drvpriv, CsrWifiFsmEvent *msg); -extern void CsrWifiSmeCoreDumpIndHandler(void *drvpriv, CsrWifiFsmEvent *msg); -extern void CsrWifiSmeAmpStatusChangeIndHandler(void *drvpriv, - CsrWifiFsmEvent *msg); - -#endif /* CSR_WIFI_ROUTER_SEF_CSR_WIFI_SME_H__ */ diff --git a/drivers/staging/csr/csr_wifi_sme_serialize.c b/drivers/staging/csr/csr_wifi_sme_serialize.c deleted file mode 100644 index 7d7e1d8b5ed3..000000000000 --- a/drivers/staging/csr/csr_wifi_sme_serialize.c +++ /dev/null @@ -1,5809 +0,0 @@ -/***************************************************************************** - - (c) Cambridge Silicon Radio Limited 2012 - All rights reserved and confidential information of CSR - - Refer to LICENSE.txt included with this source for details - on the license terms. - -*****************************************************************************/ - -/* Note: this is an auto-generated file. */ -#include -#include -#include "csr_msgconv.h" -#include "csr_wifi_sme_prim.h" -#include "csr_wifi_sme_serialize.h" - -void CsrWifiSmePfree(void *ptr) -{ - kfree(ptr); -} - - -size_t CsrWifiSmeAdhocConfigSetReqSizeof(void *msg) -{ - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 11) */ - bufferSize += 2; /* u16 primitive->adHocConfig.atimWindowTu */ - bufferSize += 2; /* u16 primitive->adHocConfig.beaconPeriodTu */ - bufferSize += 2; /* u16 primitive->adHocConfig.joinOnlyAttempts */ - bufferSize += 2; /* u16 primitive->adHocConfig.joinAttemptIntervalMs */ - return bufferSize; -} - - -u8* CsrWifiSmeAdhocConfigSetReqSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiSmeAdhocConfigSetReq *primitive = (CsrWifiSmeAdhocConfigSetReq *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->adHocConfig.atimWindowTu); - CsrUint16Ser(ptr, len, (u16) primitive->adHocConfig.beaconPeriodTu); - CsrUint16Ser(ptr, len, (u16) primitive->adHocConfig.joinOnlyAttempts); - CsrUint16Ser(ptr, len, (u16) primitive->adHocConfig.joinAttemptIntervalMs); - return(ptr); -} - - -void* CsrWifiSmeAdhocConfigSetReqDes(u8 *buffer, size_t length) -{ - CsrWifiSmeAdhocConfigSetReq *primitive = kmalloc(sizeof(CsrWifiSmeAdhocConfigSetReq), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->adHocConfig.atimWindowTu, buffer, &offset); - CsrUint16Des((u16 *) &primitive->adHocConfig.beaconPeriodTu, buffer, &offset); - CsrUint16Des((u16 *) &primitive->adHocConfig.joinOnlyAttempts, buffer, &offset); - CsrUint16Des((u16 *) &primitive->adHocConfig.joinAttemptIntervalMs, buffer, &offset); - - return primitive; -} - - -size_t CsrWifiSmeBlacklistReqSizeof(void *msg) -{ - CsrWifiSmeBlacklistReq *primitive = (CsrWifiSmeBlacklistReq *) msg; - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 13) */ - bufferSize += 2; /* u16 primitive->interfaceTag */ - bufferSize += 1; /* CsrWifiSmeListAction primitive->action */ - bufferSize += 1; /* u8 primitive->setAddressCount */ - { - u16 i1; - for (i1 = 0; i1 < primitive->setAddressCount; i1++) - { - bufferSize += 6; /* u8 primitive->setAddresses[i1].a[6] */ - } - } - return bufferSize; -} - - -u8* CsrWifiSmeBlacklistReqSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiSmeBlacklistReq *primitive = (CsrWifiSmeBlacklistReq *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag); - CsrUint8Ser(ptr, len, (u8) primitive->action); - CsrUint8Ser(ptr, len, (u8) primitive->setAddressCount); - { - u16 i1; - for (i1 = 0; i1 < primitive->setAddressCount; i1++) - { - CsrMemCpySer(ptr, len, (const void *) primitive->setAddresses[i1].a, ((u16) (6))); - } - } - return(ptr); -} - - -void* CsrWifiSmeBlacklistReqDes(u8 *buffer, size_t length) -{ - CsrWifiSmeBlacklistReq *primitive = kmalloc(sizeof(CsrWifiSmeBlacklistReq), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset); - CsrUint8Des((u8 *) &primitive->action, buffer, &offset); - CsrUint8Des((u8 *) &primitive->setAddressCount, buffer, &offset); - primitive->setAddresses = NULL; - if (primitive->setAddressCount) - { - primitive->setAddresses = kmalloc(sizeof(CsrWifiMacAddress) * primitive->setAddressCount, GFP_KERNEL); - } - { - u16 i1; - for (i1 = 0; i1 < primitive->setAddressCount; i1++) - { - CsrMemCpyDes(primitive->setAddresses[i1].a, buffer, &offset, ((u16) (6))); - } - } - - return primitive; -} - - -void CsrWifiSmeBlacklistReqSerFree(void *voidPrimitivePointer) -{ - CsrWifiSmeBlacklistReq *primitive = (CsrWifiSmeBlacklistReq *) voidPrimitivePointer; - kfree(primitive->setAddresses); - kfree(primitive); -} - - -size_t CsrWifiSmeCalibrationDataSetReqSizeof(void *msg) -{ - CsrWifiSmeCalibrationDataSetReq *primitive = (CsrWifiSmeCalibrationDataSetReq *) msg; - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 6) */ - bufferSize += 2; /* u16 primitive->calibrationDataLength */ - bufferSize += primitive->calibrationDataLength; /* u8 primitive->calibrationData */ - return bufferSize; -} - - -u8* CsrWifiSmeCalibrationDataSetReqSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiSmeCalibrationDataSetReq *primitive = (CsrWifiSmeCalibrationDataSetReq *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->calibrationDataLength); - if (primitive->calibrationDataLength) - { - CsrMemCpySer(ptr, len, (const void *) primitive->calibrationData, ((u16) (primitive->calibrationDataLength))); - } - return(ptr); -} - - -void* CsrWifiSmeCalibrationDataSetReqDes(u8 *buffer, size_t length) -{ - CsrWifiSmeCalibrationDataSetReq *primitive = kmalloc(sizeof(CsrWifiSmeCalibrationDataSetReq), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->calibrationDataLength, buffer, &offset); - if (primitive->calibrationDataLength) - { - primitive->calibrationData = kmalloc(primitive->calibrationDataLength, GFP_KERNEL); - CsrMemCpyDes(primitive->calibrationData, buffer, &offset, ((u16) (primitive->calibrationDataLength))); - } - else - { - primitive->calibrationData = NULL; - } - - return primitive; -} - - -void CsrWifiSmeCalibrationDataSetReqSerFree(void *voidPrimitivePointer) -{ - CsrWifiSmeCalibrationDataSetReq *primitive = (CsrWifiSmeCalibrationDataSetReq *) voidPrimitivePointer; - kfree(primitive->calibrationData); - kfree(primitive); -} - - -size_t CsrWifiSmeCcxConfigSetReqSizeof(void *msg) -{ - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 9) */ - bufferSize += 2; /* u16 primitive->interfaceTag */ - bufferSize += 1; /* u8 primitive->ccxConfig.keepAliveTimeMs */ - bufferSize += 1; /* u8 primitive->ccxConfig.apRoamingEnabled */ - bufferSize += 1; /* u8 primitive->ccxConfig.measurementsMask */ - bufferSize += 1; /* u8 primitive->ccxConfig.ccxRadioMgtEnabled */ - return bufferSize; -} - - -u8* CsrWifiSmeCcxConfigSetReqSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiSmeCcxConfigSetReq *primitive = (CsrWifiSmeCcxConfigSetReq *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag); - CsrUint8Ser(ptr, len, (u8) primitive->ccxConfig.keepAliveTimeMs); - CsrUint8Ser(ptr, len, (u8) primitive->ccxConfig.apRoamingEnabled); - CsrUint8Ser(ptr, len, (u8) primitive->ccxConfig.measurementsMask); - CsrUint8Ser(ptr, len, (u8) primitive->ccxConfig.ccxRadioMgtEnabled); - return(ptr); -} - - -void* CsrWifiSmeCcxConfigSetReqDes(u8 *buffer, size_t length) -{ - CsrWifiSmeCcxConfigSetReq *primitive = kmalloc(sizeof(CsrWifiSmeCcxConfigSetReq), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset); - CsrUint8Des((u8 *) &primitive->ccxConfig.keepAliveTimeMs, buffer, &offset); - CsrUint8Des((u8 *) &primitive->ccxConfig.apRoamingEnabled, buffer, &offset); - CsrUint8Des((u8 *) &primitive->ccxConfig.measurementsMask, buffer, &offset); - CsrUint8Des((u8 *) &primitive->ccxConfig.ccxRadioMgtEnabled, buffer, &offset); - - return primitive; -} - - -size_t CsrWifiSmeCoexConfigSetReqSizeof(void *msg) -{ - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 29) */ - bufferSize += 1; /* u8 primitive->coexConfig.coexEnableSchemeManagement */ - bufferSize += 1; /* u8 primitive->coexConfig.coexPeriodicWakeHost */ - bufferSize += 2; /* u16 primitive->coexConfig.coexTrafficBurstyLatencyMs */ - bufferSize += 2; /* u16 primitive->coexConfig.coexTrafficContinuousLatencyMs */ - bufferSize += 2; /* u16 primitive->coexConfig.coexObexBlackoutDurationMs */ - bufferSize += 2; /* u16 primitive->coexConfig.coexObexBlackoutPeriodMs */ - bufferSize += 2; /* u16 primitive->coexConfig.coexA2dpBrBlackoutDurationMs */ - bufferSize += 2; /* u16 primitive->coexConfig.coexA2dpBrBlackoutPeriodMs */ - bufferSize += 2; /* u16 primitive->coexConfig.coexA2dpEdrBlackoutDurationMs */ - bufferSize += 2; /* u16 primitive->coexConfig.coexA2dpEdrBlackoutPeriodMs */ - bufferSize += 2; /* u16 primitive->coexConfig.coexPagingBlackoutDurationMs */ - bufferSize += 2; /* u16 primitive->coexConfig.coexPagingBlackoutPeriodMs */ - bufferSize += 2; /* u16 primitive->coexConfig.coexInquiryBlackoutDurationMs */ - bufferSize += 2; /* u16 primitive->coexConfig.coexInquiryBlackoutPeriodMs */ - return bufferSize; -} - - -u8* CsrWifiSmeCoexConfigSetReqSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiSmeCoexConfigSetReq *primitive = (CsrWifiSmeCoexConfigSetReq *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint8Ser(ptr, len, (u8) primitive->coexConfig.coexEnableSchemeManagement); - CsrUint8Ser(ptr, len, (u8) primitive->coexConfig.coexPeriodicWakeHost); - CsrUint16Ser(ptr, len, (u16) primitive->coexConfig.coexTrafficBurstyLatencyMs); - CsrUint16Ser(ptr, len, (u16) primitive->coexConfig.coexTrafficContinuousLatencyMs); - CsrUint16Ser(ptr, len, (u16) primitive->coexConfig.coexObexBlackoutDurationMs); - CsrUint16Ser(ptr, len, (u16) primitive->coexConfig.coexObexBlackoutPeriodMs); - CsrUint16Ser(ptr, len, (u16) primitive->coexConfig.coexA2dpBrBlackoutDurationMs); - CsrUint16Ser(ptr, len, (u16) primitive->coexConfig.coexA2dpBrBlackoutPeriodMs); - CsrUint16Ser(ptr, len, (u16) primitive->coexConfig.coexA2dpEdrBlackoutDurationMs); - CsrUint16Ser(ptr, len, (u16) primitive->coexConfig.coexA2dpEdrBlackoutPeriodMs); - CsrUint16Ser(ptr, len, (u16) primitive->coexConfig.coexPagingBlackoutDurationMs); - CsrUint16Ser(ptr, len, (u16) primitive->coexConfig.coexPagingBlackoutPeriodMs); - CsrUint16Ser(ptr, len, (u16) primitive->coexConfig.coexInquiryBlackoutDurationMs); - CsrUint16Ser(ptr, len, (u16) primitive->coexConfig.coexInquiryBlackoutPeriodMs); - return(ptr); -} - - -void* CsrWifiSmeCoexConfigSetReqDes(u8 *buffer, size_t length) -{ - CsrWifiSmeCoexConfigSetReq *primitive = kmalloc(sizeof(CsrWifiSmeCoexConfigSetReq), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint8Des((u8 *) &primitive->coexConfig.coexEnableSchemeManagement, buffer, &offset); - CsrUint8Des((u8 *) &primitive->coexConfig.coexPeriodicWakeHost, buffer, &offset); - CsrUint16Des((u16 *) &primitive->coexConfig.coexTrafficBurstyLatencyMs, buffer, &offset); - CsrUint16Des((u16 *) &primitive->coexConfig.coexTrafficContinuousLatencyMs, buffer, &offset); - CsrUint16Des((u16 *) &primitive->coexConfig.coexObexBlackoutDurationMs, buffer, &offset); - CsrUint16Des((u16 *) &primitive->coexConfig.coexObexBlackoutPeriodMs, buffer, &offset); - CsrUint16Des((u16 *) &primitive->coexConfig.coexA2dpBrBlackoutDurationMs, buffer, &offset); - CsrUint16Des((u16 *) &primitive->coexConfig.coexA2dpBrBlackoutPeriodMs, buffer, &offset); - CsrUint16Des((u16 *) &primitive->coexConfig.coexA2dpEdrBlackoutDurationMs, buffer, &offset); - CsrUint16Des((u16 *) &primitive->coexConfig.coexA2dpEdrBlackoutPeriodMs, buffer, &offset); - CsrUint16Des((u16 *) &primitive->coexConfig.coexPagingBlackoutDurationMs, buffer, &offset); - CsrUint16Des((u16 *) &primitive->coexConfig.coexPagingBlackoutPeriodMs, buffer, &offset); - CsrUint16Des((u16 *) &primitive->coexConfig.coexInquiryBlackoutDurationMs, buffer, &offset); - CsrUint16Des((u16 *) &primitive->coexConfig.coexInquiryBlackoutPeriodMs, buffer, &offset); - - return primitive; -} - - -size_t CsrWifiSmeConnectReqSizeof(void *msg) -{ - CsrWifiSmeConnectReq *primitive = (CsrWifiSmeConnectReq *) msg; - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 57) */ - bufferSize += 2; /* u16 primitive->interfaceTag */ - bufferSize += 32; /* u8 primitive->connectionConfig.ssid.ssid[32] */ - bufferSize += 1; /* u8 primitive->connectionConfig.ssid.length */ - bufferSize += 6; /* u8 primitive->connectionConfig.bssid.a[6] */ - bufferSize += 1; /* CsrWifiSmeBssType primitive->connectionConfig.bssType */ - bufferSize += 1; /* CsrWifiSmeRadioIF primitive->connectionConfig.ifIndex */ - bufferSize += 1; /* CsrWifiSme80211PrivacyMode primitive->connectionConfig.privacyMode */ - bufferSize += 2; /* CsrWifiSmeAuthModeMask primitive->connectionConfig.authModeMask */ - bufferSize += 2; /* CsrWifiSmeEncryptionMask primitive->connectionConfig.encryptionModeMask */ - bufferSize += 2; /* u16 primitive->connectionConfig.mlmeAssociateReqInformationElementsLength */ - bufferSize += primitive->connectionConfig.mlmeAssociateReqInformationElementsLength; /* u8 primitive->connectionConfig.mlmeAssociateReqInformationElements */ - bufferSize += 1; /* CsrWifiSmeWmmQosInfoMask primitive->connectionConfig.wmmQosInfo */ - bufferSize += 1; /* u8 primitive->connectionConfig.adhocJoinOnly */ - bufferSize += 1; /* u8 primitive->connectionConfig.adhocChannel */ - return bufferSize; -} - - -u8* CsrWifiSmeConnectReqSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiSmeConnectReq *primitive = (CsrWifiSmeConnectReq *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag); - CsrMemCpySer(ptr, len, (const void *) primitive->connectionConfig.ssid.ssid, ((u16) (32))); - CsrUint8Ser(ptr, len, (u8) primitive->connectionConfig.ssid.length); - CsrMemCpySer(ptr, len, (const void *) primitive->connectionConfig.bssid.a, ((u16) (6))); - CsrUint8Ser(ptr, len, (u8) primitive->connectionConfig.bssType); - CsrUint8Ser(ptr, len, (u8) primitive->connectionConfig.ifIndex); - CsrUint8Ser(ptr, len, (u8) primitive->connectionConfig.privacyMode); - CsrUint16Ser(ptr, len, (u16) primitive->connectionConfig.authModeMask); - CsrUint16Ser(ptr, len, (u16) primitive->connectionConfig.encryptionModeMask); - CsrUint16Ser(ptr, len, (u16) primitive->connectionConfig.mlmeAssociateReqInformationElementsLength); - if (primitive->connectionConfig.mlmeAssociateReqInformationElementsLength) - { - CsrMemCpySer(ptr, len, (const void *) primitive->connectionConfig.mlmeAssociateReqInformationElements, ((u16) (primitive->connectionConfig.mlmeAssociateReqInformationElementsLength))); - } - CsrUint8Ser(ptr, len, (u8) primitive->connectionConfig.wmmQosInfo); - CsrUint8Ser(ptr, len, (u8) primitive->connectionConfig.adhocJoinOnly); - CsrUint8Ser(ptr, len, (u8) primitive->connectionConfig.adhocChannel); - return(ptr); -} - - -void* CsrWifiSmeConnectReqDes(u8 *buffer, size_t length) -{ - CsrWifiSmeConnectReq *primitive = kmalloc(sizeof(CsrWifiSmeConnectReq), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset); - CsrMemCpyDes(primitive->connectionConfig.ssid.ssid, buffer, &offset, ((u16) (32))); - CsrUint8Des((u8 *) &primitive->connectionConfig.ssid.length, buffer, &offset); - CsrMemCpyDes(primitive->connectionConfig.bssid.a, buffer, &offset, ((u16) (6))); - CsrUint8Des((u8 *) &primitive->connectionConfig.bssType, buffer, &offset); - CsrUint8Des((u8 *) &primitive->connectionConfig.ifIndex, buffer, &offset); - CsrUint8Des((u8 *) &primitive->connectionConfig.privacyMode, buffer, &offset); - CsrUint16Des((u16 *) &primitive->connectionConfig.authModeMask, buffer, &offset); - CsrUint16Des((u16 *) &primitive->connectionConfig.encryptionModeMask, buffer, &offset); - CsrUint16Des((u16 *) &primitive->connectionConfig.mlmeAssociateReqInformationElementsLength, buffer, &offset); - if (primitive->connectionConfig.mlmeAssociateReqInformationElementsLength) - { - primitive->connectionConfig.mlmeAssociateReqInformationElements = kmalloc(primitive->connectionConfig.mlmeAssociateReqInformationElementsLength, GFP_KERNEL); - CsrMemCpyDes(primitive->connectionConfig.mlmeAssociateReqInformationElements, buffer, &offset, ((u16) (primitive->connectionConfig.mlmeAssociateReqInformationElementsLength))); - } - else - { - primitive->connectionConfig.mlmeAssociateReqInformationElements = NULL; - } - CsrUint8Des((u8 *) &primitive->connectionConfig.wmmQosInfo, buffer, &offset); - CsrUint8Des((u8 *) &primitive->connectionConfig.adhocJoinOnly, buffer, &offset); - CsrUint8Des((u8 *) &primitive->connectionConfig.adhocChannel, buffer, &offset); - - return primitive; -} - - -void CsrWifiSmeConnectReqSerFree(void *voidPrimitivePointer) -{ - CsrWifiSmeConnectReq *primitive = (CsrWifiSmeConnectReq *) voidPrimitivePointer; - kfree(primitive->connectionConfig.mlmeAssociateReqInformationElements); - kfree(primitive); -} - - -size_t CsrWifiSmeHostConfigSetReqSizeof(void *msg) -{ - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 8) */ - bufferSize += 2; /* u16 primitive->interfaceTag */ - bufferSize += 1; /* CsrWifiSmeHostPowerMode primitive->hostConfig.powerMode */ - bufferSize += 2; /* u16 primitive->hostConfig.applicationDataPeriodMs */ - return bufferSize; -} - - -u8* CsrWifiSmeHostConfigSetReqSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiSmeHostConfigSetReq *primitive = (CsrWifiSmeHostConfigSetReq *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag); - CsrUint8Ser(ptr, len, (u8) primitive->hostConfig.powerMode); - CsrUint16Ser(ptr, len, (u16) primitive->hostConfig.applicationDataPeriodMs); - return(ptr); -} - - -void* CsrWifiSmeHostConfigSetReqDes(u8 *buffer, size_t length) -{ - CsrWifiSmeHostConfigSetReq *primitive = kmalloc(sizeof(CsrWifiSmeHostConfigSetReq), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset); - CsrUint8Des((u8 *) &primitive->hostConfig.powerMode, buffer, &offset); - CsrUint16Des((u16 *) &primitive->hostConfig.applicationDataPeriodMs, buffer, &offset); - - return primitive; -} - - -size_t CsrWifiSmeKeyReqSizeof(void *msg) -{ - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 65) */ - bufferSize += 2; /* u16 primitive->interfaceTag */ - bufferSize += 1; /* CsrWifiSmeListAction primitive->action */ - bufferSize += 1; /* CsrWifiSmeKeyType primitive->key.keyType */ - bufferSize += 1; /* u8 primitive->key.keyIndex */ - bufferSize += 1; /* u8 primitive->key.wepTxKey */ - { - u16 i2; - for (i2 = 0; i2 < 8; i2++) - { - bufferSize += 2; /* u16 primitive->key.keyRsc[8] */ - } - } - bufferSize += 1; /* u8 primitive->key.authenticator */ - bufferSize += 6; /* u8 primitive->key.address.a[6] */ - bufferSize += 1; /* u8 primitive->key.keyLength */ - bufferSize += 32; /* u8 primitive->key.key[32] */ - return bufferSize; -} - - -u8* CsrWifiSmeKeyReqSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiSmeKeyReq *primitive = (CsrWifiSmeKeyReq *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag); - CsrUint8Ser(ptr, len, (u8) primitive->action); - CsrUint8Ser(ptr, len, (u8) primitive->key.keyType); - CsrUint8Ser(ptr, len, (u8) primitive->key.keyIndex); - CsrUint8Ser(ptr, len, (u8) primitive->key.wepTxKey); - { - u16 i2; - for (i2 = 0; i2 < 8; i2++) - { - CsrUint16Ser(ptr, len, (u16) primitive->key.keyRsc[i2]); - } - } - CsrUint8Ser(ptr, len, (u8) primitive->key.authenticator); - CsrMemCpySer(ptr, len, (const void *) primitive->key.address.a, ((u16) (6))); - CsrUint8Ser(ptr, len, (u8) primitive->key.keyLength); - CsrMemCpySer(ptr, len, (const void *) primitive->key.key, ((u16) (32))); - return(ptr); -} - - -void* CsrWifiSmeKeyReqDes(u8 *buffer, size_t length) -{ - CsrWifiSmeKeyReq *primitive = kmalloc(sizeof(CsrWifiSmeKeyReq), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset); - CsrUint8Des((u8 *) &primitive->action, buffer, &offset); - CsrUint8Des((u8 *) &primitive->key.keyType, buffer, &offset); - CsrUint8Des((u8 *) &primitive->key.keyIndex, buffer, &offset); - CsrUint8Des((u8 *) &primitive->key.wepTxKey, buffer, &offset); - { - u16 i2; - for (i2 = 0; i2 < 8; i2++) - { - CsrUint16Des((u16 *) &primitive->key.keyRsc[i2], buffer, &offset); - } - } - CsrUint8Des((u8 *) &primitive->key.authenticator, buffer, &offset); - CsrMemCpyDes(primitive->key.address.a, buffer, &offset, ((u16) (6))); - CsrUint8Des((u8 *) &primitive->key.keyLength, buffer, &offset); - CsrMemCpyDes(primitive->key.key, buffer, &offset, ((u16) (32))); - - return primitive; -} - - -size_t CsrWifiSmeMibConfigSetReqSizeof(void *msg) -{ - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 11) */ - bufferSize += 1; /* u8 primitive->mibConfig.unifiFixMaxTxDataRate */ - bufferSize += 1; /* u8 primitive->mibConfig.unifiFixTxDataRate */ - bufferSize += 2; /* u16 primitive->mibConfig.dot11RtsThreshold */ - bufferSize += 2; /* u16 primitive->mibConfig.dot11FragmentationThreshold */ - bufferSize += 2; /* u16 primitive->mibConfig.dot11CurrentTxPowerLevel */ - return bufferSize; -} - - -u8* CsrWifiSmeMibConfigSetReqSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiSmeMibConfigSetReq *primitive = (CsrWifiSmeMibConfigSetReq *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint8Ser(ptr, len, (u8) primitive->mibConfig.unifiFixMaxTxDataRate); - CsrUint8Ser(ptr, len, (u8) primitive->mibConfig.unifiFixTxDataRate); - CsrUint16Ser(ptr, len, (u16) primitive->mibConfig.dot11RtsThreshold); - CsrUint16Ser(ptr, len, (u16) primitive->mibConfig.dot11FragmentationThreshold); - CsrUint16Ser(ptr, len, (u16) primitive->mibConfig.dot11CurrentTxPowerLevel); - return(ptr); -} - - -void* CsrWifiSmeMibConfigSetReqDes(u8 *buffer, size_t length) -{ - CsrWifiSmeMibConfigSetReq *primitive = kmalloc(sizeof(CsrWifiSmeMibConfigSetReq), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint8Des((u8 *) &primitive->mibConfig.unifiFixMaxTxDataRate, buffer, &offset); - CsrUint8Des((u8 *) &primitive->mibConfig.unifiFixTxDataRate, buffer, &offset); - CsrUint16Des((u16 *) &primitive->mibConfig.dot11RtsThreshold, buffer, &offset); - CsrUint16Des((u16 *) &primitive->mibConfig.dot11FragmentationThreshold, buffer, &offset); - CsrUint16Des((u16 *) &primitive->mibConfig.dot11CurrentTxPowerLevel, buffer, &offset); - - return primitive; -} - - -size_t CsrWifiSmeMibGetNextReqSizeof(void *msg) -{ - CsrWifiSmeMibGetNextReq *primitive = (CsrWifiSmeMibGetNextReq *) msg; - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 6) */ - bufferSize += 2; /* u16 primitive->mibAttributeLength */ - bufferSize += primitive->mibAttributeLength; /* u8 primitive->mibAttribute */ - return bufferSize; -} - - -u8* CsrWifiSmeMibGetNextReqSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiSmeMibGetNextReq *primitive = (CsrWifiSmeMibGetNextReq *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->mibAttributeLength); - if (primitive->mibAttributeLength) - { - CsrMemCpySer(ptr, len, (const void *) primitive->mibAttribute, ((u16) (primitive->mibAttributeLength))); - } - return(ptr); -} - - -void* CsrWifiSmeMibGetNextReqDes(u8 *buffer, size_t length) -{ - CsrWifiSmeMibGetNextReq *primitive = kmalloc(sizeof(CsrWifiSmeMibGetNextReq), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->mibAttributeLength, buffer, &offset); - if (primitive->mibAttributeLength) - { - primitive->mibAttribute = kmalloc(primitive->mibAttributeLength, GFP_KERNEL); - CsrMemCpyDes(primitive->mibAttribute, buffer, &offset, ((u16) (primitive->mibAttributeLength))); - } - else - { - primitive->mibAttribute = NULL; - } - - return primitive; -} - - -void CsrWifiSmeMibGetNextReqSerFree(void *voidPrimitivePointer) -{ - CsrWifiSmeMibGetNextReq *primitive = (CsrWifiSmeMibGetNextReq *) voidPrimitivePointer; - kfree(primitive->mibAttribute); - kfree(primitive); -} - - -size_t CsrWifiSmeMibGetReqSizeof(void *msg) -{ - CsrWifiSmeMibGetReq *primitive = (CsrWifiSmeMibGetReq *) msg; - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 6) */ - bufferSize += 2; /* u16 primitive->mibAttributeLength */ - bufferSize += primitive->mibAttributeLength; /* u8 primitive->mibAttribute */ - return bufferSize; -} - - -u8* CsrWifiSmeMibGetReqSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiSmeMibGetReq *primitive = (CsrWifiSmeMibGetReq *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->mibAttributeLength); - if (primitive->mibAttributeLength) - { - CsrMemCpySer(ptr, len, (const void *) primitive->mibAttribute, ((u16) (primitive->mibAttributeLength))); - } - return(ptr); -} - - -void* CsrWifiSmeMibGetReqDes(u8 *buffer, size_t length) -{ - CsrWifiSmeMibGetReq *primitive = kmalloc(sizeof(CsrWifiSmeMibGetReq), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->mibAttributeLength, buffer, &offset); - if (primitive->mibAttributeLength) - { - primitive->mibAttribute = kmalloc(primitive->mibAttributeLength, GFP_KERNEL); - CsrMemCpyDes(primitive->mibAttribute, buffer, &offset, ((u16) (primitive->mibAttributeLength))); - } - else - { - primitive->mibAttribute = NULL; - } - - return primitive; -} - - -void CsrWifiSmeMibGetReqSerFree(void *voidPrimitivePointer) -{ - CsrWifiSmeMibGetReq *primitive = (CsrWifiSmeMibGetReq *) voidPrimitivePointer; - kfree(primitive->mibAttribute); - kfree(primitive); -} - - -size_t CsrWifiSmeMibSetReqSizeof(void *msg) -{ - CsrWifiSmeMibSetReq *primitive = (CsrWifiSmeMibSetReq *) msg; - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 6) */ - bufferSize += 2; /* u16 primitive->mibAttributeLength */ - bufferSize += primitive->mibAttributeLength; /* u8 primitive->mibAttribute */ - return bufferSize; -} - - -u8* CsrWifiSmeMibSetReqSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiSmeMibSetReq *primitive = (CsrWifiSmeMibSetReq *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->mibAttributeLength); - if (primitive->mibAttributeLength) - { - CsrMemCpySer(ptr, len, (const void *) primitive->mibAttribute, ((u16) (primitive->mibAttributeLength))); - } - return(ptr); -} - - -void* CsrWifiSmeMibSetReqDes(u8 *buffer, size_t length) -{ - CsrWifiSmeMibSetReq *primitive = kmalloc(sizeof(CsrWifiSmeMibSetReq), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->mibAttributeLength, buffer, &offset); - if (primitive->mibAttributeLength) - { - primitive->mibAttribute = kmalloc(primitive->mibAttributeLength, GFP_KERNEL); - CsrMemCpyDes(primitive->mibAttribute, buffer, &offset, ((u16) (primitive->mibAttributeLength))); - } - else - { - primitive->mibAttribute = NULL; - } - - return primitive; -} - - -void CsrWifiSmeMibSetReqSerFree(void *voidPrimitivePointer) -{ - CsrWifiSmeMibSetReq *primitive = (CsrWifiSmeMibSetReq *) voidPrimitivePointer; - kfree(primitive->mibAttribute); - kfree(primitive); -} - - -size_t CsrWifiSmeMulticastAddressReqSizeof(void *msg) -{ - CsrWifiSmeMulticastAddressReq *primitive = (CsrWifiSmeMulticastAddressReq *) msg; - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 13) */ - bufferSize += 2; /* u16 primitive->interfaceTag */ - bufferSize += 1; /* CsrWifiSmeListAction primitive->action */ - bufferSize += 1; /* u8 primitive->setAddressesCount */ - { - u16 i1; - for (i1 = 0; i1 < primitive->setAddressesCount; i1++) - { - bufferSize += 6; /* u8 primitive->setAddresses[i1].a[6] */ - } - } - return bufferSize; -} - - -u8* CsrWifiSmeMulticastAddressReqSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiSmeMulticastAddressReq *primitive = (CsrWifiSmeMulticastAddressReq *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag); - CsrUint8Ser(ptr, len, (u8) primitive->action); - CsrUint8Ser(ptr, len, (u8) primitive->setAddressesCount); - { - u16 i1; - for (i1 = 0; i1 < primitive->setAddressesCount; i1++) - { - CsrMemCpySer(ptr, len, (const void *) primitive->setAddresses[i1].a, ((u16) (6))); - } - } - return(ptr); -} - - -void* CsrWifiSmeMulticastAddressReqDes(u8 *buffer, size_t length) -{ - CsrWifiSmeMulticastAddressReq *primitive = kmalloc(sizeof(CsrWifiSmeMulticastAddressReq), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset); - CsrUint8Des((u8 *) &primitive->action, buffer, &offset); - CsrUint8Des((u8 *) &primitive->setAddressesCount, buffer, &offset); - primitive->setAddresses = NULL; - if (primitive->setAddressesCount) - { - primitive->setAddresses = kmalloc(sizeof(CsrWifiMacAddress) * primitive->setAddressesCount, GFP_KERNEL); - } - { - u16 i1; - for (i1 = 0; i1 < primitive->setAddressesCount; i1++) - { - CsrMemCpyDes(primitive->setAddresses[i1].a, buffer, &offset, ((u16) (6))); - } - } - - return primitive; -} - - -void CsrWifiSmeMulticastAddressReqSerFree(void *voidPrimitivePointer) -{ - CsrWifiSmeMulticastAddressReq *primitive = (CsrWifiSmeMulticastAddressReq *) voidPrimitivePointer; - kfree(primitive->setAddresses); - kfree(primitive); -} - - -size_t CsrWifiSmePacketFilterSetReqSizeof(void *msg) -{ - CsrWifiSmePacketFilterSetReq *primitive = (CsrWifiSmePacketFilterSetReq *) msg; - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 13) */ - bufferSize += 2; /* u16 primitive->interfaceTag */ - bufferSize += 2; /* u16 primitive->filterLength */ - bufferSize += primitive->filterLength; /* u8 primitive->filter */ - bufferSize += 1; /* CsrWifiSmePacketFilterMode primitive->mode */ - bufferSize += 4; /* u8 primitive->arpFilterAddress.a[4] */ - return bufferSize; -} - - -u8* CsrWifiSmePacketFilterSetReqSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiSmePacketFilterSetReq *primitive = (CsrWifiSmePacketFilterSetReq *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag); - CsrUint16Ser(ptr, len, (u16) primitive->filterLength); - if (primitive->filterLength) - { - CsrMemCpySer(ptr, len, (const void *) primitive->filter, ((u16) (primitive->filterLength))); - } - CsrUint8Ser(ptr, len, (u8) primitive->mode); - CsrMemCpySer(ptr, len, (const void *) primitive->arpFilterAddress.a, ((u16) (4))); - return(ptr); -} - - -void* CsrWifiSmePacketFilterSetReqDes(u8 *buffer, size_t length) -{ - CsrWifiSmePacketFilterSetReq *primitive = kmalloc(sizeof(CsrWifiSmePacketFilterSetReq), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset); - CsrUint16Des((u16 *) &primitive->filterLength, buffer, &offset); - if (primitive->filterLength) - { - primitive->filter = kmalloc(primitive->filterLength, GFP_KERNEL); - CsrMemCpyDes(primitive->filter, buffer, &offset, ((u16) (primitive->filterLength))); - } - else - { - primitive->filter = NULL; - } - CsrUint8Des((u8 *) &primitive->mode, buffer, &offset); - CsrMemCpyDes(primitive->arpFilterAddress.a, buffer, &offset, ((u16) (4))); - - return primitive; -} - - -void CsrWifiSmePacketFilterSetReqSerFree(void *voidPrimitivePointer) -{ - CsrWifiSmePacketFilterSetReq *primitive = (CsrWifiSmePacketFilterSetReq *) voidPrimitivePointer; - kfree(primitive->filter); - kfree(primitive); -} - - -size_t CsrWifiSmePmkidReqSizeof(void *msg) -{ - CsrWifiSmePmkidReq *primitive = (CsrWifiSmePmkidReq *) msg; - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 29) */ - bufferSize += 2; /* u16 primitive->interfaceTag */ - bufferSize += 1; /* CsrWifiSmeListAction primitive->action */ - bufferSize += 1; /* u8 primitive->setPmkidsCount */ - { - u16 i1; - for (i1 = 0; i1 < primitive->setPmkidsCount; i1++) - { - bufferSize += 6; /* u8 primitive->setPmkids[i1].bssid.a[6] */ - bufferSize += 16; /* u8 primitive->setPmkids[i1].pmkid[16] */ - } - } - return bufferSize; -} - - -u8* CsrWifiSmePmkidReqSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiSmePmkidReq *primitive = (CsrWifiSmePmkidReq *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag); - CsrUint8Ser(ptr, len, (u8) primitive->action); - CsrUint8Ser(ptr, len, (u8) primitive->setPmkidsCount); - { - u16 i1; - for (i1 = 0; i1 < primitive->setPmkidsCount; i1++) - { - CsrMemCpySer(ptr, len, (const void *) primitive->setPmkids[i1].bssid.a, ((u16) (6))); - CsrMemCpySer(ptr, len, (const void *) primitive->setPmkids[i1].pmkid, ((u16) (16))); - } - } - return(ptr); -} - - -void* CsrWifiSmePmkidReqDes(u8 *buffer, size_t length) -{ - CsrWifiSmePmkidReq *primitive = kmalloc(sizeof(CsrWifiSmePmkidReq), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset); - CsrUint8Des((u8 *) &primitive->action, buffer, &offset); - CsrUint8Des((u8 *) &primitive->setPmkidsCount, buffer, &offset); - primitive->setPmkids = NULL; - if (primitive->setPmkidsCount) - { - primitive->setPmkids = kmalloc(sizeof(CsrWifiSmePmkid) * primitive->setPmkidsCount, GFP_KERNEL); - } - { - u16 i1; - for (i1 = 0; i1 < primitive->setPmkidsCount; i1++) - { - CsrMemCpyDes(primitive->setPmkids[i1].bssid.a, buffer, &offset, ((u16) (6))); - CsrMemCpyDes(primitive->setPmkids[i1].pmkid, buffer, &offset, ((u16) (16))); - } - } - - return primitive; -} - - -void CsrWifiSmePmkidReqSerFree(void *voidPrimitivePointer) -{ - CsrWifiSmePmkidReq *primitive = (CsrWifiSmePmkidReq *) voidPrimitivePointer; - kfree(primitive->setPmkids); - kfree(primitive); -} - - -size_t CsrWifiSmePowerConfigSetReqSizeof(void *msg) -{ - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 11) */ - bufferSize += 1; /* CsrWifiSmePowerSaveLevel primitive->powerConfig.powerSaveLevel */ - bufferSize += 2; /* u16 primitive->powerConfig.listenIntervalTu */ - bufferSize += 1; /* u8 primitive->powerConfig.rxDtims */ - bufferSize += 1; /* CsrWifiSmeD3AutoScanMode primitive->powerConfig.d3AutoScanMode */ - bufferSize += 1; /* u8 primitive->powerConfig.clientTrafficWindow */ - bufferSize += 1; /* u8 primitive->powerConfig.opportunisticPowerSave */ - bufferSize += 1; /* u8 primitive->powerConfig.noticeOfAbsence */ - return bufferSize; -} - - -u8* CsrWifiSmePowerConfigSetReqSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiSmePowerConfigSetReq *primitive = (CsrWifiSmePowerConfigSetReq *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint8Ser(ptr, len, (u8) primitive->powerConfig.powerSaveLevel); - CsrUint16Ser(ptr, len, (u16) primitive->powerConfig.listenIntervalTu); - CsrUint8Ser(ptr, len, (u8) primitive->powerConfig.rxDtims); - CsrUint8Ser(ptr, len, (u8) primitive->powerConfig.d3AutoScanMode); - CsrUint8Ser(ptr, len, (u8) primitive->powerConfig.clientTrafficWindow); - CsrUint8Ser(ptr, len, (u8) primitive->powerConfig.opportunisticPowerSave); - CsrUint8Ser(ptr, len, (u8) primitive->powerConfig.noticeOfAbsence); - return(ptr); -} - - -void* CsrWifiSmePowerConfigSetReqDes(u8 *buffer, size_t length) -{ - CsrWifiSmePowerConfigSetReq *primitive = kmalloc(sizeof(CsrWifiSmePowerConfigSetReq), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint8Des((u8 *) &primitive->powerConfig.powerSaveLevel, buffer, &offset); - CsrUint16Des((u16 *) &primitive->powerConfig.listenIntervalTu, buffer, &offset); - CsrUint8Des((u8 *) &primitive->powerConfig.rxDtims, buffer, &offset); - CsrUint8Des((u8 *) &primitive->powerConfig.d3AutoScanMode, buffer, &offset); - CsrUint8Des((u8 *) &primitive->powerConfig.clientTrafficWindow, buffer, &offset); - CsrUint8Des((u8 *) &primitive->powerConfig.opportunisticPowerSave, buffer, &offset); - CsrUint8Des((u8 *) &primitive->powerConfig.noticeOfAbsence, buffer, &offset); - - return primitive; -} - - -size_t CsrWifiSmeRoamingConfigSetReqSizeof(void *msg) -{ - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 70) */ - bufferSize += 2; /* u16 primitive->interfaceTag */ - { - u16 i2; - for (i2 = 0; i2 < 3; i2++) - { - bufferSize += 2; /* s16 primitive->roamingConfig.roamingBands[i2].rssiHighThreshold */ - bufferSize += 2; /* s16 primitive->roamingConfig.roamingBands[i2].rssiLowThreshold */ - bufferSize += 2; /* s16 primitive->roamingConfig.roamingBands[i2].snrHighThreshold */ - bufferSize += 2; /* s16 primitive->roamingConfig.roamingBands[i2].snrLowThreshold */ - } - } - bufferSize += 1; /* u8 primitive->roamingConfig.disableSmoothRoaming */ - bufferSize += 1; /* u8 primitive->roamingConfig.disableRoamScans */ - bufferSize += 1; /* u8 primitive->roamingConfig.reconnectLimit */ - bufferSize += 2; /* u16 primitive->roamingConfig.reconnectLimitIntervalMs */ - { - u16 i2; - for (i2 = 0; i2 < 3; i2++) - { - bufferSize += 2; /* u16 primitive->roamingConfig.roamScanCfg[i2].intervalSeconds */ - bufferSize += 2; /* u16 primitive->roamingConfig.roamScanCfg[i2].validitySeconds */ - bufferSize += 2; /* u16 primitive->roamingConfig.roamScanCfg[i2].minActiveChannelTimeTu */ - bufferSize += 2; /* u16 primitive->roamingConfig.roamScanCfg[i2].maxActiveChannelTimeTu */ - bufferSize += 2; /* u16 primitive->roamingConfig.roamScanCfg[i2].minPassiveChannelTimeTu */ - bufferSize += 2; /* u16 primitive->roamingConfig.roamScanCfg[i2].maxPassiveChannelTimeTu */ - } - } - return bufferSize; -} - - -u8* CsrWifiSmeRoamingConfigSetReqSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiSmeRoamingConfigSetReq *primitive = (CsrWifiSmeRoamingConfigSetReq *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag); - { - u16 i2; - for (i2 = 0; i2 < 3; i2++) - { - CsrUint16Ser(ptr, len, (u16) primitive->roamingConfig.roamingBands[i2].rssiHighThreshold); - CsrUint16Ser(ptr, len, (u16) primitive->roamingConfig.roamingBands[i2].rssiLowThreshold); - CsrUint16Ser(ptr, len, (u16) primitive->roamingConfig.roamingBands[i2].snrHighThreshold); - CsrUint16Ser(ptr, len, (u16) primitive->roamingConfig.roamingBands[i2].snrLowThreshold); - } - } - CsrUint8Ser(ptr, len, (u8) primitive->roamingConfig.disableSmoothRoaming); - CsrUint8Ser(ptr, len, (u8) primitive->roamingConfig.disableRoamScans); - CsrUint8Ser(ptr, len, (u8) primitive->roamingConfig.reconnectLimit); - CsrUint16Ser(ptr, len, (u16) primitive->roamingConfig.reconnectLimitIntervalMs); - { - u16 i2; - for (i2 = 0; i2 < 3; i2++) - { - CsrUint16Ser(ptr, len, (u16) primitive->roamingConfig.roamScanCfg[i2].intervalSeconds); - CsrUint16Ser(ptr, len, (u16) primitive->roamingConfig.roamScanCfg[i2].validitySeconds); - CsrUint16Ser(ptr, len, (u16) primitive->roamingConfig.roamScanCfg[i2].minActiveChannelTimeTu); - CsrUint16Ser(ptr, len, (u16) primitive->roamingConfig.roamScanCfg[i2].maxActiveChannelTimeTu); - CsrUint16Ser(ptr, len, (u16) primitive->roamingConfig.roamScanCfg[i2].minPassiveChannelTimeTu); - CsrUint16Ser(ptr, len, (u16) primitive->roamingConfig.roamScanCfg[i2].maxPassiveChannelTimeTu); - } - } - return(ptr); -} - - -void* CsrWifiSmeRoamingConfigSetReqDes(u8 *buffer, size_t length) -{ - CsrWifiSmeRoamingConfigSetReq *primitive = kmalloc(sizeof(CsrWifiSmeRoamingConfigSetReq), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset); - { - u16 i2; - for (i2 = 0; i2 < 3; i2++) - { - CsrUint16Des((u16 *) &primitive->roamingConfig.roamingBands[i2].rssiHighThreshold, buffer, &offset); - CsrUint16Des((u16 *) &primitive->roamingConfig.roamingBands[i2].rssiLowThreshold, buffer, &offset); - CsrUint16Des((u16 *) &primitive->roamingConfig.roamingBands[i2].snrHighThreshold, buffer, &offset); - CsrUint16Des((u16 *) &primitive->roamingConfig.roamingBands[i2].snrLowThreshold, buffer, &offset); - } - } - CsrUint8Des((u8 *) &primitive->roamingConfig.disableSmoothRoaming, buffer, &offset); - CsrUint8Des((u8 *) &primitive->roamingConfig.disableRoamScans, buffer, &offset); - CsrUint8Des((u8 *) &primitive->roamingConfig.reconnectLimit, buffer, &offset); - CsrUint16Des((u16 *) &primitive->roamingConfig.reconnectLimitIntervalMs, buffer, &offset); - { - u16 i2; - for (i2 = 0; i2 < 3; i2++) - { - CsrUint16Des((u16 *) &primitive->roamingConfig.roamScanCfg[i2].intervalSeconds, buffer, &offset); - CsrUint16Des((u16 *) &primitive->roamingConfig.roamScanCfg[i2].validitySeconds, buffer, &offset); - CsrUint16Des((u16 *) &primitive->roamingConfig.roamScanCfg[i2].minActiveChannelTimeTu, buffer, &offset); - CsrUint16Des((u16 *) &primitive->roamingConfig.roamScanCfg[i2].maxActiveChannelTimeTu, buffer, &offset); - CsrUint16Des((u16 *) &primitive->roamingConfig.roamScanCfg[i2].minPassiveChannelTimeTu, buffer, &offset); - CsrUint16Des((u16 *) &primitive->roamingConfig.roamScanCfg[i2].maxPassiveChannelTimeTu, buffer, &offset); - } - } - - return primitive; -} - - -size_t CsrWifiSmeScanConfigSetReqSizeof(void *msg) -{ - CsrWifiSmeScanConfigSetReq *primitive = (CsrWifiSmeScanConfigSetReq *) msg; - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 63) */ - { - u16 i2; - for (i2 = 0; i2 < 4; i2++) - { - bufferSize += 2; /* u16 primitive->scanConfig.scanCfg[i2].intervalSeconds */ - bufferSize += 2; /* u16 primitive->scanConfig.scanCfg[i2].validitySeconds */ - bufferSize += 2; /* u16 primitive->scanConfig.scanCfg[i2].minActiveChannelTimeTu */ - bufferSize += 2; /* u16 primitive->scanConfig.scanCfg[i2].maxActiveChannelTimeTu */ - bufferSize += 2; /* u16 primitive->scanConfig.scanCfg[i2].minPassiveChannelTimeTu */ - bufferSize += 2; /* u16 primitive->scanConfig.scanCfg[i2].maxPassiveChannelTimeTu */ - } - } - bufferSize += 1; /* u8 primitive->scanConfig.disableAutonomousScans */ - bufferSize += 2; /* u16 primitive->scanConfig.maxResults */ - bufferSize += 1; /* s8 primitive->scanConfig.highRssiThreshold */ - bufferSize += 1; /* s8 primitive->scanConfig.lowRssiThreshold */ - bufferSize += 1; /* s8 primitive->scanConfig.deltaRssiThreshold */ - bufferSize += 1; /* s8 primitive->scanConfig.highSnrThreshold */ - bufferSize += 1; /* s8 primitive->scanConfig.lowSnrThreshold */ - bufferSize += 1; /* s8 primitive->scanConfig.deltaSnrThreshold */ - bufferSize += 2; /* u16 primitive->scanConfig.passiveChannelListCount */ - bufferSize += primitive->scanConfig.passiveChannelListCount; /* u8 primitive->scanConfig.passiveChannelList */ - return bufferSize; -} - - -u8* CsrWifiSmeScanConfigSetReqSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiSmeScanConfigSetReq *primitive = (CsrWifiSmeScanConfigSetReq *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - { - u16 i2; - for (i2 = 0; i2 < 4; i2++) - { - CsrUint16Ser(ptr, len, (u16) primitive->scanConfig.scanCfg[i2].intervalSeconds); - CsrUint16Ser(ptr, len, (u16) primitive->scanConfig.scanCfg[i2].validitySeconds); - CsrUint16Ser(ptr, len, (u16) primitive->scanConfig.scanCfg[i2].minActiveChannelTimeTu); - CsrUint16Ser(ptr, len, (u16) primitive->scanConfig.scanCfg[i2].maxActiveChannelTimeTu); - CsrUint16Ser(ptr, len, (u16) primitive->scanConfig.scanCfg[i2].minPassiveChannelTimeTu); - CsrUint16Ser(ptr, len, (u16) primitive->scanConfig.scanCfg[i2].maxPassiveChannelTimeTu); - } - } - CsrUint8Ser(ptr, len, (u8) primitive->scanConfig.disableAutonomousScans); - CsrUint16Ser(ptr, len, (u16) primitive->scanConfig.maxResults); - CsrUint8Ser(ptr, len, (u8) primitive->scanConfig.highRssiThreshold); - CsrUint8Ser(ptr, len, (u8) primitive->scanConfig.lowRssiThreshold); - CsrUint8Ser(ptr, len, (u8) primitive->scanConfig.deltaRssiThreshold); - CsrUint8Ser(ptr, len, (u8) primitive->scanConfig.highSnrThreshold); - CsrUint8Ser(ptr, len, (u8) primitive->scanConfig.lowSnrThreshold); - CsrUint8Ser(ptr, len, (u8) primitive->scanConfig.deltaSnrThreshold); - CsrUint16Ser(ptr, len, (u16) primitive->scanConfig.passiveChannelListCount); - if (primitive->scanConfig.passiveChannelListCount) - { - CsrMemCpySer(ptr, len, (const void *) primitive->scanConfig.passiveChannelList, ((u16) (primitive->scanConfig.passiveChannelListCount))); - } - return(ptr); -} - - -void* CsrWifiSmeScanConfigSetReqDes(u8 *buffer, size_t length) -{ - CsrWifiSmeScanConfigSetReq *primitive = kmalloc(sizeof(CsrWifiSmeScanConfigSetReq), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - { - u16 i2; - for (i2 = 0; i2 < 4; i2++) - { - CsrUint16Des((u16 *) &primitive->scanConfig.scanCfg[i2].intervalSeconds, buffer, &offset); - CsrUint16Des((u16 *) &primitive->scanConfig.scanCfg[i2].validitySeconds, buffer, &offset); - CsrUint16Des((u16 *) &primitive->scanConfig.scanCfg[i2].minActiveChannelTimeTu, buffer, &offset); - CsrUint16Des((u16 *) &primitive->scanConfig.scanCfg[i2].maxActiveChannelTimeTu, buffer, &offset); - CsrUint16Des((u16 *) &primitive->scanConfig.scanCfg[i2].minPassiveChannelTimeTu, buffer, &offset); - CsrUint16Des((u16 *) &primitive->scanConfig.scanCfg[i2].maxPassiveChannelTimeTu, buffer, &offset); - } - } - CsrUint8Des((u8 *) &primitive->scanConfig.disableAutonomousScans, buffer, &offset); - CsrUint16Des((u16 *) &primitive->scanConfig.maxResults, buffer, &offset); - CsrUint8Des((u8 *) &primitive->scanConfig.highRssiThreshold, buffer, &offset); - CsrUint8Des((u8 *) &primitive->scanConfig.lowRssiThreshold, buffer, &offset); - CsrUint8Des((u8 *) &primitive->scanConfig.deltaRssiThreshold, buffer, &offset); - CsrUint8Des((u8 *) &primitive->scanConfig.highSnrThreshold, buffer, &offset); - CsrUint8Des((u8 *) &primitive->scanConfig.lowSnrThreshold, buffer, &offset); - CsrUint8Des((u8 *) &primitive->scanConfig.deltaSnrThreshold, buffer, &offset); - CsrUint16Des((u16 *) &primitive->scanConfig.passiveChannelListCount, buffer, &offset); - if (primitive->scanConfig.passiveChannelListCount) - { - primitive->scanConfig.passiveChannelList = kmalloc(primitive->scanConfig.passiveChannelListCount, GFP_KERNEL); - CsrMemCpyDes(primitive->scanConfig.passiveChannelList, buffer, &offset, ((u16) (primitive->scanConfig.passiveChannelListCount))); - } - else - { - primitive->scanConfig.passiveChannelList = NULL; - } - - return primitive; -} - - -void CsrWifiSmeScanConfigSetReqSerFree(void *voidPrimitivePointer) -{ - CsrWifiSmeScanConfigSetReq *primitive = (CsrWifiSmeScanConfigSetReq *) voidPrimitivePointer; - kfree(primitive->scanConfig.passiveChannelList); - kfree(primitive); -} - - -size_t CsrWifiSmeScanFullReqSizeof(void *msg) -{ - CsrWifiSmeScanFullReq *primitive = (CsrWifiSmeScanFullReq *) msg; - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 52) */ - bufferSize += 1; /* u8 primitive->ssidCount */ - { - u16 i1; - for (i1 = 0; i1 < primitive->ssidCount; i1++) - { - bufferSize += 32; /* u8 primitive->ssid[i1].ssid[32] */ - bufferSize += 1; /* u8 primitive->ssid[i1].length */ - } - } - bufferSize += 6; /* u8 primitive->bssid.a[6] */ - bufferSize += 1; /* u8 primitive->forceScan */ - bufferSize += 1; /* CsrWifiSmeBssType primitive->bssType */ - bufferSize += 1; /* CsrWifiSmeScanType primitive->scanType */ - bufferSize += 2; /* u16 primitive->channelListCount */ - bufferSize += primitive->channelListCount; /* u8 primitive->channelList */ - bufferSize += 2; /* u16 primitive->probeIeLength */ - bufferSize += primitive->probeIeLength; /* u8 primitive->probeIe */ - return bufferSize; -} - - -u8* CsrWifiSmeScanFullReqSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiSmeScanFullReq *primitive = (CsrWifiSmeScanFullReq *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint8Ser(ptr, len, (u8) primitive->ssidCount); - { - u16 i1; - for (i1 = 0; i1 < primitive->ssidCount; i1++) - { - CsrMemCpySer(ptr, len, (const void *) primitive->ssid[i1].ssid, ((u16) (32))); - CsrUint8Ser(ptr, len, (u8) primitive->ssid[i1].length); - } - } - CsrMemCpySer(ptr, len, (const void *) primitive->bssid.a, ((u16) (6))); - CsrUint8Ser(ptr, len, (u8) primitive->forceScan); - CsrUint8Ser(ptr, len, (u8) primitive->bssType); - CsrUint8Ser(ptr, len, (u8) primitive->scanType); - CsrUint16Ser(ptr, len, (u16) primitive->channelListCount); - if (primitive->channelListCount) - { - CsrMemCpySer(ptr, len, (const void *) primitive->channelList, ((u16) (primitive->channelListCount))); - } - CsrUint16Ser(ptr, len, (u16) primitive->probeIeLength); - if (primitive->probeIeLength) - { - CsrMemCpySer(ptr, len, (const void *) primitive->probeIe, ((u16) (primitive->probeIeLength))); - } - return(ptr); -} - - -void* CsrWifiSmeScanFullReqDes(u8 *buffer, size_t length) -{ - CsrWifiSmeScanFullReq *primitive = kmalloc(sizeof(CsrWifiSmeScanFullReq), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint8Des((u8 *) &primitive->ssidCount, buffer, &offset); - primitive->ssid = NULL; - if (primitive->ssidCount) - { - primitive->ssid = kmalloc(sizeof(CsrWifiSsid) * primitive->ssidCount, GFP_KERNEL); - } - { - u16 i1; - for (i1 = 0; i1 < primitive->ssidCount; i1++) - { - CsrMemCpyDes(primitive->ssid[i1].ssid, buffer, &offset, ((u16) (32))); - CsrUint8Des((u8 *) &primitive->ssid[i1].length, buffer, &offset); - } - } - CsrMemCpyDes(primitive->bssid.a, buffer, &offset, ((u16) (6))); - CsrUint8Des((u8 *) &primitive->forceScan, buffer, &offset); - CsrUint8Des((u8 *) &primitive->bssType, buffer, &offset); - CsrUint8Des((u8 *) &primitive->scanType, buffer, &offset); - CsrUint16Des((u16 *) &primitive->channelListCount, buffer, &offset); - if (primitive->channelListCount) - { - primitive->channelList = kmalloc(primitive->channelListCount, GFP_KERNEL); - CsrMemCpyDes(primitive->channelList, buffer, &offset, ((u16) (primitive->channelListCount))); - } - else - { - primitive->channelList = NULL; - } - CsrUint16Des((u16 *) &primitive->probeIeLength, buffer, &offset); - if (primitive->probeIeLength) - { - primitive->probeIe = kmalloc(primitive->probeIeLength, GFP_KERNEL); - CsrMemCpyDes(primitive->probeIe, buffer, &offset, ((u16) (primitive->probeIeLength))); - } - else - { - primitive->probeIe = NULL; - } - - return primitive; -} - - -void CsrWifiSmeScanFullReqSerFree(void *voidPrimitivePointer) -{ - CsrWifiSmeScanFullReq *primitive = (CsrWifiSmeScanFullReq *) voidPrimitivePointer; - kfree(primitive->ssid); - kfree(primitive->channelList); - kfree(primitive->probeIe); - kfree(primitive); -} - - -size_t CsrWifiSmeSmeStaConfigSetReqSizeof(void *msg) -{ - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 11) */ - bufferSize += 2; /* u16 primitive->interfaceTag */ - bufferSize += 1; /* u8 primitive->smeConfig.connectionQualityRssiChangeTrigger */ - bufferSize += 1; /* u8 primitive->smeConfig.connectionQualitySnrChangeTrigger */ - bufferSize += 1; /* CsrWifiSmeWmmModeMask primitive->smeConfig.wmmModeMask */ - bufferSize += 1; /* CsrWifiSmeRadioIF primitive->smeConfig.ifIndex */ - bufferSize += 1; /* u8 primitive->smeConfig.allowUnicastUseGroupCipher */ - bufferSize += 1; /* u8 primitive->smeConfig.enableOpportunisticKeyCaching */ - return bufferSize; -} - - -u8* CsrWifiSmeSmeStaConfigSetReqSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiSmeSmeStaConfigSetReq *primitive = (CsrWifiSmeSmeStaConfigSetReq *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag); - CsrUint8Ser(ptr, len, (u8) primitive->smeConfig.connectionQualityRssiChangeTrigger); - CsrUint8Ser(ptr, len, (u8) primitive->smeConfig.connectionQualitySnrChangeTrigger); - CsrUint8Ser(ptr, len, (u8) primitive->smeConfig.wmmModeMask); - CsrUint8Ser(ptr, len, (u8) primitive->smeConfig.ifIndex); - CsrUint8Ser(ptr, len, (u8) primitive->smeConfig.allowUnicastUseGroupCipher); - CsrUint8Ser(ptr, len, (u8) primitive->smeConfig.enableOpportunisticKeyCaching); - return(ptr); -} - - -void* CsrWifiSmeSmeStaConfigSetReqDes(u8 *buffer, size_t length) -{ - CsrWifiSmeSmeStaConfigSetReq *primitive = kmalloc(sizeof(CsrWifiSmeSmeStaConfigSetReq), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset); - CsrUint8Des((u8 *) &primitive->smeConfig.connectionQualityRssiChangeTrigger, buffer, &offset); - CsrUint8Des((u8 *) &primitive->smeConfig.connectionQualitySnrChangeTrigger, buffer, &offset); - CsrUint8Des((u8 *) &primitive->smeConfig.wmmModeMask, buffer, &offset); - CsrUint8Des((u8 *) &primitive->smeConfig.ifIndex, buffer, &offset); - CsrUint8Des((u8 *) &primitive->smeConfig.allowUnicastUseGroupCipher, buffer, &offset); - CsrUint8Des((u8 *) &primitive->smeConfig.enableOpportunisticKeyCaching, buffer, &offset); - - return primitive; -} - - -size_t CsrWifiSmeTspecReqSizeof(void *msg) -{ - CsrWifiSmeTspecReq *primitive = (CsrWifiSmeTspecReq *) msg; - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 18) */ - bufferSize += 2; /* u16 primitive->interfaceTag */ - bufferSize += 1; /* CsrWifiSmeListAction primitive->action */ - bufferSize += 4; /* u32 primitive->transactionId */ - bufferSize += 1; /* u8 primitive->strict */ - bufferSize += 1; /* CsrWifiSmeTspecCtrlMask primitive->ctrlMask */ - bufferSize += 2; /* u16 primitive->tspecLength */ - bufferSize += primitive->tspecLength; /* u8 primitive->tspec */ - bufferSize += 2; /* u16 primitive->tclasLength */ - bufferSize += primitive->tclasLength; /* u8 primitive->tclas */ - return bufferSize; -} - - -u8* CsrWifiSmeTspecReqSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiSmeTspecReq *primitive = (CsrWifiSmeTspecReq *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag); - CsrUint8Ser(ptr, len, (u8) primitive->action); - CsrUint32Ser(ptr, len, (u32) primitive->transactionId); - CsrUint8Ser(ptr, len, (u8) primitive->strict); - CsrUint8Ser(ptr, len, (u8) primitive->ctrlMask); - CsrUint16Ser(ptr, len, (u16) primitive->tspecLength); - if (primitive->tspecLength) - { - CsrMemCpySer(ptr, len, (const void *) primitive->tspec, ((u16) (primitive->tspecLength))); - } - CsrUint16Ser(ptr, len, (u16) primitive->tclasLength); - if (primitive->tclasLength) - { - CsrMemCpySer(ptr, len, (const void *) primitive->tclas, ((u16) (primitive->tclasLength))); - } - return(ptr); -} - - -void* CsrWifiSmeTspecReqDes(u8 *buffer, size_t length) -{ - CsrWifiSmeTspecReq *primitive = kmalloc(sizeof(CsrWifiSmeTspecReq), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset); - CsrUint8Des((u8 *) &primitive->action, buffer, &offset); - CsrUint32Des((u32 *) &primitive->transactionId, buffer, &offset); - CsrUint8Des((u8 *) &primitive->strict, buffer, &offset); - CsrUint8Des((u8 *) &primitive->ctrlMask, buffer, &offset); - CsrUint16Des((u16 *) &primitive->tspecLength, buffer, &offset); - if (primitive->tspecLength) - { - primitive->tspec = kmalloc(primitive->tspecLength, GFP_KERNEL); - CsrMemCpyDes(primitive->tspec, buffer, &offset, ((u16) (primitive->tspecLength))); - } - else - { - primitive->tspec = NULL; - } - CsrUint16Des((u16 *) &primitive->tclasLength, buffer, &offset); - if (primitive->tclasLength) - { - primitive->tclas = kmalloc(primitive->tclasLength, GFP_KERNEL); - CsrMemCpyDes(primitive->tclas, buffer, &offset, ((u16) (primitive->tclasLength))); - } - else - { - primitive->tclas = NULL; - } - - return primitive; -} - - -void CsrWifiSmeTspecReqSerFree(void *voidPrimitivePointer) -{ - CsrWifiSmeTspecReq *primitive = (CsrWifiSmeTspecReq *) voidPrimitivePointer; - kfree(primitive->tspec); - kfree(primitive->tclas); - kfree(primitive); -} - - -size_t CsrWifiSmeWifiFlightmodeReqSizeof(void *msg) -{ - CsrWifiSmeWifiFlightmodeReq *primitive = (CsrWifiSmeWifiFlightmodeReq *) msg; - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 14) */ - bufferSize += 6; /* u8 primitive->address.a[6] */ - bufferSize += 2; /* u16 primitive->mibFilesCount */ - { - u16 i1; - for (i1 = 0; i1 < primitive->mibFilesCount; i1++) - { - bufferSize += 2; /* u16 primitive->mibFiles[i1].length */ - bufferSize += primitive->mibFiles[i1].length; /* u8 primitive->mibFiles[i1].data */ - } - } - return bufferSize; -} - - -u8* CsrWifiSmeWifiFlightmodeReqSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiSmeWifiFlightmodeReq *primitive = (CsrWifiSmeWifiFlightmodeReq *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrMemCpySer(ptr, len, (const void *) primitive->address.a, ((u16) (6))); - CsrUint16Ser(ptr, len, (u16) primitive->mibFilesCount); - { - u16 i1; - for (i1 = 0; i1 < primitive->mibFilesCount; i1++) - { - CsrUint16Ser(ptr, len, (u16) primitive->mibFiles[i1].length); - if (primitive->mibFiles[i1].length) - { - CsrMemCpySer(ptr, len, (const void *) primitive->mibFiles[i1].data, ((u16) (primitive->mibFiles[i1].length))); - } - } - } - return(ptr); -} - - -void* CsrWifiSmeWifiFlightmodeReqDes(u8 *buffer, size_t length) -{ - CsrWifiSmeWifiFlightmodeReq *primitive = kmalloc(sizeof(CsrWifiSmeWifiFlightmodeReq), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrMemCpyDes(primitive->address.a, buffer, &offset, ((u16) (6))); - CsrUint16Des((u16 *) &primitive->mibFilesCount, buffer, &offset); - primitive->mibFiles = NULL; - if (primitive->mibFilesCount) - { - primitive->mibFiles = kmalloc(sizeof(CsrWifiSmeDataBlock) * primitive->mibFilesCount, GFP_KERNEL); - } - { - u16 i1; - for (i1 = 0; i1 < primitive->mibFilesCount; i1++) - { - CsrUint16Des((u16 *) &primitive->mibFiles[i1].length, buffer, &offset); - if (primitive->mibFiles[i1].length) - { - primitive->mibFiles[i1].data = kmalloc(primitive->mibFiles[i1].length, GFP_KERNEL); - CsrMemCpyDes(primitive->mibFiles[i1].data, buffer, &offset, ((u16) (primitive->mibFiles[i1].length))); - } - else - { - primitive->mibFiles[i1].data = NULL; - } - } - } - - return primitive; -} - - -void CsrWifiSmeWifiFlightmodeReqSerFree(void *voidPrimitivePointer) -{ - CsrWifiSmeWifiFlightmodeReq *primitive = (CsrWifiSmeWifiFlightmodeReq *) voidPrimitivePointer; - { - u16 i1; - for (i1 = 0; i1 < primitive->mibFilesCount; i1++) - { - kfree(primitive->mibFiles[i1].data); - } - } - kfree(primitive->mibFiles); - kfree(primitive); -} - - -size_t CsrWifiSmeWifiOnReqSizeof(void *msg) -{ - CsrWifiSmeWifiOnReq *primitive = (CsrWifiSmeWifiOnReq *) msg; - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 14) */ - bufferSize += 6; /* u8 primitive->address.a[6] */ - bufferSize += 2; /* u16 primitive->mibFilesCount */ - { - u16 i1; - for (i1 = 0; i1 < primitive->mibFilesCount; i1++) - { - bufferSize += 2; /* u16 primitive->mibFiles[i1].length */ - bufferSize += primitive->mibFiles[i1].length; /* u8 primitive->mibFiles[i1].data */ - } - } - return bufferSize; -} - - -u8* CsrWifiSmeWifiOnReqSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiSmeWifiOnReq *primitive = (CsrWifiSmeWifiOnReq *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrMemCpySer(ptr, len, (const void *) primitive->address.a, ((u16) (6))); - CsrUint16Ser(ptr, len, (u16) primitive->mibFilesCount); - { - u16 i1; - for (i1 = 0; i1 < primitive->mibFilesCount; i1++) - { - CsrUint16Ser(ptr, len, (u16) primitive->mibFiles[i1].length); - if (primitive->mibFiles[i1].length) - { - CsrMemCpySer(ptr, len, (const void *) primitive->mibFiles[i1].data, ((u16) (primitive->mibFiles[i1].length))); - } - } - } - return(ptr); -} - - -void* CsrWifiSmeWifiOnReqDes(u8 *buffer, size_t length) -{ - CsrWifiSmeWifiOnReq *primitive = kmalloc(sizeof(CsrWifiSmeWifiOnReq), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrMemCpyDes(primitive->address.a, buffer, &offset, ((u16) (6))); - CsrUint16Des((u16 *) &primitive->mibFilesCount, buffer, &offset); - primitive->mibFiles = NULL; - if (primitive->mibFilesCount) - { - primitive->mibFiles = kmalloc(sizeof(CsrWifiSmeDataBlock) * primitive->mibFilesCount, GFP_KERNEL); - } - { - u16 i1; - for (i1 = 0; i1 < primitive->mibFilesCount; i1++) - { - CsrUint16Des((u16 *) &primitive->mibFiles[i1].length, buffer, &offset); - if (primitive->mibFiles[i1].length) - { - primitive->mibFiles[i1].data = kmalloc(primitive->mibFiles[i1].length, GFP_KERNEL); - CsrMemCpyDes(primitive->mibFiles[i1].data, buffer, &offset, ((u16) (primitive->mibFiles[i1].length))); - } - else - { - primitive->mibFiles[i1].data = NULL; - } - } - } - - return primitive; -} - - -void CsrWifiSmeWifiOnReqSerFree(void *voidPrimitivePointer) -{ - CsrWifiSmeWifiOnReq *primitive = (CsrWifiSmeWifiOnReq *) voidPrimitivePointer; - { - u16 i1; - for (i1 = 0; i1 < primitive->mibFilesCount; i1++) - { - kfree(primitive->mibFiles[i1].data); - } - } - kfree(primitive->mibFiles); - kfree(primitive); -} - - -size_t CsrWifiSmeCloakedSsidsSetReqSizeof(void *msg) -{ - CsrWifiSmeCloakedSsidsSetReq *primitive = (CsrWifiSmeCloakedSsidsSetReq *) msg; - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 37) */ - bufferSize += 1; /* u8 primitive->cloakedSsids.cloakedSsidsCount */ - { - u16 i2; - for (i2 = 0; i2 < primitive->cloakedSsids.cloakedSsidsCount; i2++) - { - bufferSize += 32; /* u8 primitive->cloakedSsids.cloakedSsids[i2].ssid[32] */ - bufferSize += 1; /* u8 primitive->cloakedSsids.cloakedSsids[i2].length */ - } - } - return bufferSize; -} - - -u8* CsrWifiSmeCloakedSsidsSetReqSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiSmeCloakedSsidsSetReq *primitive = (CsrWifiSmeCloakedSsidsSetReq *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint8Ser(ptr, len, (u8) primitive->cloakedSsids.cloakedSsidsCount); - { - u16 i2; - for (i2 = 0; i2 < primitive->cloakedSsids.cloakedSsidsCount; i2++) - { - CsrMemCpySer(ptr, len, (const void *) primitive->cloakedSsids.cloakedSsids[i2].ssid, ((u16) (32))); - CsrUint8Ser(ptr, len, (u8) primitive->cloakedSsids.cloakedSsids[i2].length); - } - } - return(ptr); -} - - -void* CsrWifiSmeCloakedSsidsSetReqDes(u8 *buffer, size_t length) -{ - CsrWifiSmeCloakedSsidsSetReq *primitive = kmalloc(sizeof(CsrWifiSmeCloakedSsidsSetReq), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint8Des((u8 *) &primitive->cloakedSsids.cloakedSsidsCount, buffer, &offset); - primitive->cloakedSsids.cloakedSsids = NULL; - if (primitive->cloakedSsids.cloakedSsidsCount) - { - primitive->cloakedSsids.cloakedSsids = kmalloc(sizeof(CsrWifiSsid) * primitive->cloakedSsids.cloakedSsidsCount, GFP_KERNEL); - } - { - u16 i2; - for (i2 = 0; i2 < primitive->cloakedSsids.cloakedSsidsCount; i2++) - { - CsrMemCpyDes(primitive->cloakedSsids.cloakedSsids[i2].ssid, buffer, &offset, ((u16) (32))); - CsrUint8Des((u8 *) &primitive->cloakedSsids.cloakedSsids[i2].length, buffer, &offset); - } - } - - return primitive; -} - - -void CsrWifiSmeCloakedSsidsSetReqSerFree(void *voidPrimitivePointer) -{ - CsrWifiSmeCloakedSsidsSetReq *primitive = (CsrWifiSmeCloakedSsidsSetReq *) voidPrimitivePointer; - kfree(primitive->cloakedSsids.cloakedSsids); - kfree(primitive); -} - - -size_t CsrWifiSmeSmeCommonConfigSetReqSizeof(void *msg) -{ - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 8) */ - bufferSize += 1; /* CsrWifiSme80211dTrustLevel primitive->deviceConfig.trustLevel */ - bufferSize += 2; /* u8 primitive->deviceConfig.countryCode[2] */ - bufferSize += 1; /* CsrWifiSmeFirmwareDriverInterface primitive->deviceConfig.firmwareDriverInterface */ - bufferSize += 1; /* u8 primitive->deviceConfig.enableStrictDraftN */ - return bufferSize; -} - - -u8* CsrWifiSmeSmeCommonConfigSetReqSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiSmeSmeCommonConfigSetReq *primitive = (CsrWifiSmeSmeCommonConfigSetReq *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint8Ser(ptr, len, (u8) primitive->deviceConfig.trustLevel); - CsrMemCpySer(ptr, len, (const void *) primitive->deviceConfig.countryCode, ((u16) (2))); - CsrUint8Ser(ptr, len, (u8) primitive->deviceConfig.firmwareDriverInterface); - CsrUint8Ser(ptr, len, (u8) primitive->deviceConfig.enableStrictDraftN); - return(ptr); -} - - -void* CsrWifiSmeSmeCommonConfigSetReqDes(u8 *buffer, size_t length) -{ - CsrWifiSmeSmeCommonConfigSetReq *primitive = kmalloc(sizeof(CsrWifiSmeSmeCommonConfigSetReq), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint8Des((u8 *) &primitive->deviceConfig.trustLevel, buffer, &offset); - CsrMemCpyDes(primitive->deviceConfig.countryCode, buffer, &offset, ((u16) (2))); - CsrUint8Des((u8 *) &primitive->deviceConfig.firmwareDriverInterface, buffer, &offset); - CsrUint8Des((u8 *) &primitive->deviceConfig.enableStrictDraftN, buffer, &offset); - - return primitive; -} - - -size_t CsrWifiSmeWpsConfigurationReqSizeof(void *msg) -{ - CsrWifiSmeWpsConfigurationReq *primitive = (CsrWifiSmeWpsConfigurationReq *) msg; - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 240) */ - bufferSize += 1; /* u8 primitive->wpsConfig.wpsVersion */ - bufferSize += 16; /* u8 primitive->wpsConfig.uuid[16] */ - bufferSize += 32; /* u8 primitive->wpsConfig.deviceName[32] */ - bufferSize += 1; /* u8 primitive->wpsConfig.deviceNameLength */ - bufferSize += 64; /* u8 primitive->wpsConfig.manufacturer[64] */ - bufferSize += 1; /* u8 primitive->wpsConfig.manufacturerLength */ - bufferSize += 32; /* u8 primitive->wpsConfig.modelName[32] */ - bufferSize += 1; /* u8 primitive->wpsConfig.modelNameLength */ - bufferSize += 32; /* u8 primitive->wpsConfig.modelNumber[32] */ - bufferSize += 1; /* u8 primitive->wpsConfig.modelNumberLength */ - bufferSize += 32; /* u8 primitive->wpsConfig.serialNumber[32] */ - bufferSize += 8; /* u8 primitive->wpsConfig.primDeviceType.deviceDetails[8] */ - bufferSize += 1; /* u8 primitive->wpsConfig.secondaryDeviceTypeCount */ - { - u16 i2; - for (i2 = 0; i2 < primitive->wpsConfig.secondaryDeviceTypeCount; i2++) - { - bufferSize += 8; /* u8 primitive->wpsConfig.secondaryDeviceType[i2].deviceDetails[8] */ - } - } - bufferSize += 2; /* CsrWifiSmeWpsConfigTypeMask primitive->wpsConfig.configMethods */ - bufferSize += 1; /* u8 primitive->wpsConfig.rfBands */ - bufferSize += 4; /* u8 primitive->wpsConfig.osVersion[4] */ - return bufferSize; -} - - -u8* CsrWifiSmeWpsConfigurationReqSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiSmeWpsConfigurationReq *primitive = (CsrWifiSmeWpsConfigurationReq *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint8Ser(ptr, len, (u8) primitive->wpsConfig.wpsVersion); - CsrMemCpySer(ptr, len, (const void *) primitive->wpsConfig.uuid, ((u16) (16))); - CsrMemCpySer(ptr, len, (const void *) primitive->wpsConfig.deviceName, ((u16) (32))); - CsrUint8Ser(ptr, len, (u8) primitive->wpsConfig.deviceNameLength); - CsrMemCpySer(ptr, len, (const void *) primitive->wpsConfig.manufacturer, ((u16) (64))); - CsrUint8Ser(ptr, len, (u8) primitive->wpsConfig.manufacturerLength); - CsrMemCpySer(ptr, len, (const void *) primitive->wpsConfig.modelName, ((u16) (32))); - CsrUint8Ser(ptr, len, (u8) primitive->wpsConfig.modelNameLength); - CsrMemCpySer(ptr, len, (const void *) primitive->wpsConfig.modelNumber, ((u16) (32))); - CsrUint8Ser(ptr, len, (u8) primitive->wpsConfig.modelNumberLength); - CsrMemCpySer(ptr, len, (const void *) primitive->wpsConfig.serialNumber, ((u16) (32))); - CsrMemCpySer(ptr, len, (const void *) primitive->wpsConfig.primDeviceType.deviceDetails, ((u16) (8))); - CsrUint8Ser(ptr, len, (u8) primitive->wpsConfig.secondaryDeviceTypeCount); - { - u16 i2; - for (i2 = 0; i2 < primitive->wpsConfig.secondaryDeviceTypeCount; i2++) - { - CsrMemCpySer(ptr, len, (const void *) primitive->wpsConfig.secondaryDeviceType[i2].deviceDetails, ((u16) (8))); - } - } - CsrUint16Ser(ptr, len, (u16) primitive->wpsConfig.configMethods); - CsrUint8Ser(ptr, len, (u8) primitive->wpsConfig.rfBands); - CsrMemCpySer(ptr, len, (const void *) primitive->wpsConfig.osVersion, ((u16) (4))); - return(ptr); -} - - -void* CsrWifiSmeWpsConfigurationReqDes(u8 *buffer, size_t length) -{ - CsrWifiSmeWpsConfigurationReq *primitive = kmalloc(sizeof(CsrWifiSmeWpsConfigurationReq), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint8Des((u8 *) &primitive->wpsConfig.wpsVersion, buffer, &offset); - CsrMemCpyDes(primitive->wpsConfig.uuid, buffer, &offset, ((u16) (16))); - CsrMemCpyDes(primitive->wpsConfig.deviceName, buffer, &offset, ((u16) (32))); - CsrUint8Des((u8 *) &primitive->wpsConfig.deviceNameLength, buffer, &offset); - CsrMemCpyDes(primitive->wpsConfig.manufacturer, buffer, &offset, ((u16) (64))); - CsrUint8Des((u8 *) &primitive->wpsConfig.manufacturerLength, buffer, &offset); - CsrMemCpyDes(primitive->wpsConfig.modelName, buffer, &offset, ((u16) (32))); - CsrUint8Des((u8 *) &primitive->wpsConfig.modelNameLength, buffer, &offset); - CsrMemCpyDes(primitive->wpsConfig.modelNumber, buffer, &offset, ((u16) (32))); - CsrUint8Des((u8 *) &primitive->wpsConfig.modelNumberLength, buffer, &offset); - CsrMemCpyDes(primitive->wpsConfig.serialNumber, buffer, &offset, ((u16) (32))); - CsrMemCpyDes(primitive->wpsConfig.primDeviceType.deviceDetails, buffer, &offset, ((u16) (8))); - CsrUint8Des((u8 *) &primitive->wpsConfig.secondaryDeviceTypeCount, buffer, &offset); - primitive->wpsConfig.secondaryDeviceType = NULL; - if (primitive->wpsConfig.secondaryDeviceTypeCount) - { - primitive->wpsConfig.secondaryDeviceType = kmalloc(sizeof(CsrWifiSmeWpsDeviceType) * primitive->wpsConfig.secondaryDeviceTypeCount, GFP_KERNEL); - } - { - u16 i2; - for (i2 = 0; i2 < primitive->wpsConfig.secondaryDeviceTypeCount; i2++) - { - CsrMemCpyDes(primitive->wpsConfig.secondaryDeviceType[i2].deviceDetails, buffer, &offset, ((u16) (8))); - } - } - CsrUint16Des((u16 *) &primitive->wpsConfig.configMethods, buffer, &offset); - CsrUint8Des((u8 *) &primitive->wpsConfig.rfBands, buffer, &offset); - CsrMemCpyDes(primitive->wpsConfig.osVersion, buffer, &offset, ((u16) (4))); - - return primitive; -} - - -void CsrWifiSmeWpsConfigurationReqSerFree(void *voidPrimitivePointer) -{ - CsrWifiSmeWpsConfigurationReq *primitive = (CsrWifiSmeWpsConfigurationReq *) voidPrimitivePointer; - kfree(primitive->wpsConfig.secondaryDeviceType); - kfree(primitive); -} - - -size_t CsrWifiSmeSetReqSizeof(void *msg) -{ - CsrWifiSmeSetReq *primitive = (CsrWifiSmeSetReq *) msg; - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 8) */ - bufferSize += 4; /* u32 primitive->dataLength */ - bufferSize += primitive->dataLength; /* u8 primitive->data */ - return bufferSize; -} - - -u8* CsrWifiSmeSetReqSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiSmeSetReq *primitive = (CsrWifiSmeSetReq *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint32Ser(ptr, len, (u32) primitive->dataLength); - if (primitive->dataLength) - { - CsrMemCpySer(ptr, len, (const void *) primitive->data, ((u16) (primitive->dataLength))); - } - return(ptr); -} - - -void* CsrWifiSmeSetReqDes(u8 *buffer, size_t length) -{ - CsrWifiSmeSetReq *primitive = kmalloc(sizeof(CsrWifiSmeSetReq), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint32Des((u32 *) &primitive->dataLength, buffer, &offset); - if (primitive->dataLength) - { - primitive->data = kmalloc(primitive->dataLength, GFP_KERNEL); - CsrMemCpyDes(primitive->data, buffer, &offset, ((u16) (primitive->dataLength))); - } - else - { - primitive->data = NULL; - } - - return primitive; -} - - -void CsrWifiSmeSetReqSerFree(void *voidPrimitivePointer) -{ - CsrWifiSmeSetReq *primitive = (CsrWifiSmeSetReq *) voidPrimitivePointer; - kfree(primitive->data); - kfree(primitive); -} - - -size_t CsrWifiSmeAdhocConfigGetCfmSizeof(void *msg) -{ - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 13) */ - bufferSize += 2; /* CsrResult primitive->status */ - bufferSize += 2; /* u16 primitive->adHocConfig.atimWindowTu */ - bufferSize += 2; /* u16 primitive->adHocConfig.beaconPeriodTu */ - bufferSize += 2; /* u16 primitive->adHocConfig.joinOnlyAttempts */ - bufferSize += 2; /* u16 primitive->adHocConfig.joinAttemptIntervalMs */ - return bufferSize; -} - - -u8* CsrWifiSmeAdhocConfigGetCfmSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiSmeAdhocConfigGetCfm *primitive = (CsrWifiSmeAdhocConfigGetCfm *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->status); - CsrUint16Ser(ptr, len, (u16) primitive->adHocConfig.atimWindowTu); - CsrUint16Ser(ptr, len, (u16) primitive->adHocConfig.beaconPeriodTu); - CsrUint16Ser(ptr, len, (u16) primitive->adHocConfig.joinOnlyAttempts); - CsrUint16Ser(ptr, len, (u16) primitive->adHocConfig.joinAttemptIntervalMs); - return(ptr); -} - - -void* CsrWifiSmeAdhocConfigGetCfmDes(u8 *buffer, size_t length) -{ - CsrWifiSmeAdhocConfigGetCfm *primitive = kmalloc(sizeof(CsrWifiSmeAdhocConfigGetCfm), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->status, buffer, &offset); - CsrUint16Des((u16 *) &primitive->adHocConfig.atimWindowTu, buffer, &offset); - CsrUint16Des((u16 *) &primitive->adHocConfig.beaconPeriodTu, buffer, &offset); - CsrUint16Des((u16 *) &primitive->adHocConfig.joinOnlyAttempts, buffer, &offset); - CsrUint16Des((u16 *) &primitive->adHocConfig.joinAttemptIntervalMs, buffer, &offset); - - return primitive; -} - - -size_t CsrWifiSmeAssociationCompleteIndSizeof(void *msg) -{ - CsrWifiSmeAssociationCompleteInd *primitive = (CsrWifiSmeAssociationCompleteInd *) msg; - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 98) */ - bufferSize += 2; /* u16 primitive->interfaceTag */ - bufferSize += 2; /* CsrResult primitive->status */ - bufferSize += 32; /* u8 primitive->connectionInfo.ssid.ssid[32] */ - bufferSize += 1; /* u8 primitive->connectionInfo.ssid.length */ - bufferSize += 6; /* u8 primitive->connectionInfo.bssid.a[6] */ - bufferSize += 1; /* CsrWifiSme80211NetworkType primitive->connectionInfo.networkType80211 */ - bufferSize += 1; /* u8 primitive->connectionInfo.channelNumber */ - bufferSize += 2; /* u16 primitive->connectionInfo.channelFrequency */ - bufferSize += 2; /* CsrWifiSmeAuthMode primitive->connectionInfo.authMode */ - bufferSize += 2; /* CsrWifiSmeEncryption primitive->connectionInfo.pairwiseCipher */ - bufferSize += 2; /* CsrWifiSmeEncryption primitive->connectionInfo.groupCipher */ - bufferSize += 1; /* CsrWifiSmeRadioIF primitive->connectionInfo.ifIndex */ - bufferSize += 2; /* u16 primitive->connectionInfo.atimWindowTu */ - bufferSize += 2; /* u16 primitive->connectionInfo.beaconPeriodTu */ - bufferSize += 1; /* u8 primitive->connectionInfo.reassociation */ - bufferSize += 2; /* u16 primitive->connectionInfo.beaconFrameLength */ - bufferSize += primitive->connectionInfo.beaconFrameLength; /* u8 primitive->connectionInfo.beaconFrame */ - bufferSize += 2; /* u16 primitive->connectionInfo.associationReqFrameLength */ - bufferSize += primitive->connectionInfo.associationReqFrameLength; /* u8 primitive->connectionInfo.associationReqFrame */ - bufferSize += 2; /* u16 primitive->connectionInfo.associationRspFrameLength */ - bufferSize += primitive->connectionInfo.associationRspFrameLength; /* u8 primitive->connectionInfo.associationRspFrame */ - bufferSize += 2; /* u16 primitive->connectionInfo.assocScanInfoElementsLength */ - bufferSize += primitive->connectionInfo.assocScanInfoElementsLength; /* u8 primitive->connectionInfo.assocScanInfoElements */ - bufferSize += 2; /* u16 primitive->connectionInfo.assocReqCapabilities */ - bufferSize += 2; /* u16 primitive->connectionInfo.assocReqListenIntervalTu */ - bufferSize += 6; /* u8 primitive->connectionInfo.assocReqApAddress.a[6] */ - bufferSize += 2; /* u16 primitive->connectionInfo.assocReqInfoElementsLength */ - bufferSize += primitive->connectionInfo.assocReqInfoElementsLength; /* u8 primitive->connectionInfo.assocReqInfoElements */ - bufferSize += 2; /* CsrWifiSmeIEEE80211Result primitive->connectionInfo.assocRspResult */ - bufferSize += 2; /* u16 primitive->connectionInfo.assocRspCapabilityInfo */ - bufferSize += 2; /* u16 primitive->connectionInfo.assocRspAssociationId */ - bufferSize += 2; /* u16 primitive->connectionInfo.assocRspInfoElementsLength */ - bufferSize += primitive->connectionInfo.assocRspInfoElementsLength; /* u8 primitive->connectionInfo.assocRspInfoElements */ - bufferSize += 2; /* CsrWifiSmeIEEE80211Reason primitive->deauthReason */ - return bufferSize; -} - - -u8* CsrWifiSmeAssociationCompleteIndSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiSmeAssociationCompleteInd *primitive = (CsrWifiSmeAssociationCompleteInd *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag); - CsrUint16Ser(ptr, len, (u16) primitive->status); - CsrMemCpySer(ptr, len, (const void *) primitive->connectionInfo.ssid.ssid, ((u16) (32))); - CsrUint8Ser(ptr, len, (u8) primitive->connectionInfo.ssid.length); - CsrMemCpySer(ptr, len, (const void *) primitive->connectionInfo.bssid.a, ((u16) (6))); - CsrUint8Ser(ptr, len, (u8) primitive->connectionInfo.networkType80211); - CsrUint8Ser(ptr, len, (u8) primitive->connectionInfo.channelNumber); - CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.channelFrequency); - CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.authMode); - CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.pairwiseCipher); - CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.groupCipher); - CsrUint8Ser(ptr, len, (u8) primitive->connectionInfo.ifIndex); - CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.atimWindowTu); - CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.beaconPeriodTu); - CsrUint8Ser(ptr, len, (u8) primitive->connectionInfo.reassociation); - CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.beaconFrameLength); - if (primitive->connectionInfo.beaconFrameLength) - { - CsrMemCpySer(ptr, len, (const void *) primitive->connectionInfo.beaconFrame, ((u16) (primitive->connectionInfo.beaconFrameLength))); - } - CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.associationReqFrameLength); - if (primitive->connectionInfo.associationReqFrameLength) - { - CsrMemCpySer(ptr, len, (const void *) primitive->connectionInfo.associationReqFrame, ((u16) (primitive->connectionInfo.associationReqFrameLength))); - } - CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.associationRspFrameLength); - if (primitive->connectionInfo.associationRspFrameLength) - { - CsrMemCpySer(ptr, len, (const void *) primitive->connectionInfo.associationRspFrame, ((u16) (primitive->connectionInfo.associationRspFrameLength))); - } - CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.assocScanInfoElementsLength); - if (primitive->connectionInfo.assocScanInfoElementsLength) - { - CsrMemCpySer(ptr, len, (const void *) primitive->connectionInfo.assocScanInfoElements, ((u16) (primitive->connectionInfo.assocScanInfoElementsLength))); - } - CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.assocReqCapabilities); - CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.assocReqListenIntervalTu); - CsrMemCpySer(ptr, len, (const void *) primitive->connectionInfo.assocReqApAddress.a, ((u16) (6))); - CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.assocReqInfoElementsLength); - if (primitive->connectionInfo.assocReqInfoElementsLength) - { - CsrMemCpySer(ptr, len, (const void *) primitive->connectionInfo.assocReqInfoElements, ((u16) (primitive->connectionInfo.assocReqInfoElementsLength))); - } - CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.assocRspResult); - CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.assocRspCapabilityInfo); - CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.assocRspAssociationId); - CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.assocRspInfoElementsLength); - if (primitive->connectionInfo.assocRspInfoElementsLength) - { - CsrMemCpySer(ptr, len, (const void *) primitive->connectionInfo.assocRspInfoElements, ((u16) (primitive->connectionInfo.assocRspInfoElementsLength))); - } - CsrUint16Ser(ptr, len, (u16) primitive->deauthReason); - return(ptr); -} - - -void* CsrWifiSmeAssociationCompleteIndDes(u8 *buffer, size_t length) -{ - CsrWifiSmeAssociationCompleteInd *primitive = kmalloc(sizeof(CsrWifiSmeAssociationCompleteInd), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset); - CsrUint16Des((u16 *) &primitive->status, buffer, &offset); - CsrMemCpyDes(primitive->connectionInfo.ssid.ssid, buffer, &offset, ((u16) (32))); - CsrUint8Des((u8 *) &primitive->connectionInfo.ssid.length, buffer, &offset); - CsrMemCpyDes(primitive->connectionInfo.bssid.a, buffer, &offset, ((u16) (6))); - CsrUint8Des((u8 *) &primitive->connectionInfo.networkType80211, buffer, &offset); - CsrUint8Des((u8 *) &primitive->connectionInfo.channelNumber, buffer, &offset); - CsrUint16Des((u16 *) &primitive->connectionInfo.channelFrequency, buffer, &offset); - CsrUint16Des((u16 *) &primitive->connectionInfo.authMode, buffer, &offset); - CsrUint16Des((u16 *) &primitive->connectionInfo.pairwiseCipher, buffer, &offset); - CsrUint16Des((u16 *) &primitive->connectionInfo.groupCipher, buffer, &offset); - CsrUint8Des((u8 *) &primitive->connectionInfo.ifIndex, buffer, &offset); - CsrUint16Des((u16 *) &primitive->connectionInfo.atimWindowTu, buffer, &offset); - CsrUint16Des((u16 *) &primitive->connectionInfo.beaconPeriodTu, buffer, &offset); - CsrUint8Des((u8 *) &primitive->connectionInfo.reassociation, buffer, &offset); - CsrUint16Des((u16 *) &primitive->connectionInfo.beaconFrameLength, buffer, &offset); - if (primitive->connectionInfo.beaconFrameLength) - { - primitive->connectionInfo.beaconFrame = kmalloc(primitive->connectionInfo.beaconFrameLength, GFP_KERNEL); - CsrMemCpyDes(primitive->connectionInfo.beaconFrame, buffer, &offset, ((u16) (primitive->connectionInfo.beaconFrameLength))); - } - else - { - primitive->connectionInfo.beaconFrame = NULL; - } - CsrUint16Des((u16 *) &primitive->connectionInfo.associationReqFrameLength, buffer, &offset); - if (primitive->connectionInfo.associationReqFrameLength) - { - primitive->connectionInfo.associationReqFrame = kmalloc(primitive->connectionInfo.associationReqFrameLength, GFP_KERNEL); - CsrMemCpyDes(primitive->connectionInfo.associationReqFrame, buffer, &offset, ((u16) (primitive->connectionInfo.associationReqFrameLength))); - } - else - { - primitive->connectionInfo.associationReqFrame = NULL; - } - CsrUint16Des((u16 *) &primitive->connectionInfo.associationRspFrameLength, buffer, &offset); - if (primitive->connectionInfo.associationRspFrameLength) - { - primitive->connectionInfo.associationRspFrame = kmalloc(primitive->connectionInfo.associationRspFrameLength, GFP_KERNEL); - CsrMemCpyDes(primitive->connectionInfo.associationRspFrame, buffer, &offset, ((u16) (primitive->connectionInfo.associationRspFrameLength))); - } - else - { - primitive->connectionInfo.associationRspFrame = NULL; - } - CsrUint16Des((u16 *) &primitive->connectionInfo.assocScanInfoElementsLength, buffer, &offset); - if (primitive->connectionInfo.assocScanInfoElementsLength) - { - primitive->connectionInfo.assocScanInfoElements = kmalloc(primitive->connectionInfo.assocScanInfoElementsLength, GFP_KERNEL); - CsrMemCpyDes(primitive->connectionInfo.assocScanInfoElements, buffer, &offset, ((u16) (primitive->connectionInfo.assocScanInfoElementsLength))); - } - else - { - primitive->connectionInfo.assocScanInfoElements = NULL; - } - CsrUint16Des((u16 *) &primitive->connectionInfo.assocReqCapabilities, buffer, &offset); - CsrUint16Des((u16 *) &primitive->connectionInfo.assocReqListenIntervalTu, buffer, &offset); - CsrMemCpyDes(primitive->connectionInfo.assocReqApAddress.a, buffer, &offset, ((u16) (6))); - CsrUint16Des((u16 *) &primitive->connectionInfo.assocReqInfoElementsLength, buffer, &offset); - if (primitive->connectionInfo.assocReqInfoElementsLength) - { - primitive->connectionInfo.assocReqInfoElements = kmalloc(primitive->connectionInfo.assocReqInfoElementsLength, GFP_KERNEL); - CsrMemCpyDes(primitive->connectionInfo.assocReqInfoElements, buffer, &offset, ((u16) (primitive->connectionInfo.assocReqInfoElementsLength))); - } - else - { - primitive->connectionInfo.assocReqInfoElements = NULL; - } - CsrUint16Des((u16 *) &primitive->connectionInfo.assocRspResult, buffer, &offset); - CsrUint16Des((u16 *) &primitive->connectionInfo.assocRspCapabilityInfo, buffer, &offset); - CsrUint16Des((u16 *) &primitive->connectionInfo.assocRspAssociationId, buffer, &offset); - CsrUint16Des((u16 *) &primitive->connectionInfo.assocRspInfoElementsLength, buffer, &offset); - if (primitive->connectionInfo.assocRspInfoElementsLength) - { - primitive->connectionInfo.assocRspInfoElements = kmalloc(primitive->connectionInfo.assocRspInfoElementsLength, GFP_KERNEL); - CsrMemCpyDes(primitive->connectionInfo.assocRspInfoElements, buffer, &offset, ((u16) (primitive->connectionInfo.assocRspInfoElementsLength))); - } - else - { - primitive->connectionInfo.assocRspInfoElements = NULL; - } - CsrUint16Des((u16 *) &primitive->deauthReason, buffer, &offset); - - return primitive; -} - - -void CsrWifiSmeAssociationCompleteIndSerFree(void *voidPrimitivePointer) -{ - CsrWifiSmeAssociationCompleteInd *primitive = (CsrWifiSmeAssociationCompleteInd *) voidPrimitivePointer; - kfree(primitive->connectionInfo.beaconFrame); - kfree(primitive->connectionInfo.associationReqFrame); - kfree(primitive->connectionInfo.associationRspFrame); - kfree(primitive->connectionInfo.assocScanInfoElements); - kfree(primitive->connectionInfo.assocReqInfoElements); - kfree(primitive->connectionInfo.assocRspInfoElements); - kfree(primitive); -} - - -size_t CsrWifiSmeAssociationStartIndSizeof(void *msg) -{ - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 44) */ - bufferSize += 2; /* u16 primitive->interfaceTag */ - bufferSize += 6; /* u8 primitive->address.a[6] */ - bufferSize += 32; /* u8 primitive->ssid.ssid[32] */ - bufferSize += 1; /* u8 primitive->ssid.length */ - return bufferSize; -} - - -u8* CsrWifiSmeAssociationStartIndSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiSmeAssociationStartInd *primitive = (CsrWifiSmeAssociationStartInd *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag); - CsrMemCpySer(ptr, len, (const void *) primitive->address.a, ((u16) (6))); - CsrMemCpySer(ptr, len, (const void *) primitive->ssid.ssid, ((u16) (32))); - CsrUint8Ser(ptr, len, (u8) primitive->ssid.length); - return(ptr); -} - - -void* CsrWifiSmeAssociationStartIndDes(u8 *buffer, size_t length) -{ - CsrWifiSmeAssociationStartInd *primitive = kmalloc(sizeof(CsrWifiSmeAssociationStartInd), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset); - CsrMemCpyDes(primitive->address.a, buffer, &offset, ((u16) (6))); - CsrMemCpyDes(primitive->ssid.ssid, buffer, &offset, ((u16) (32))); - CsrUint8Des((u8 *) &primitive->ssid.length, buffer, &offset); - - return primitive; -} - - -size_t CsrWifiSmeBlacklistCfmSizeof(void *msg) -{ - CsrWifiSmeBlacklistCfm *primitive = (CsrWifiSmeBlacklistCfm *) msg; - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 15) */ - bufferSize += 2; /* u16 primitive->interfaceTag */ - bufferSize += 2; /* CsrResult primitive->status */ - bufferSize += 1; /* CsrWifiSmeListAction primitive->action */ - bufferSize += 1; /* u8 primitive->getAddressCount */ - { - u16 i1; - for (i1 = 0; i1 < primitive->getAddressCount; i1++) - { - bufferSize += 6; /* u8 primitive->getAddresses[i1].a[6] */ - } - } - return bufferSize; -} - - -u8* CsrWifiSmeBlacklistCfmSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiSmeBlacklistCfm *primitive = (CsrWifiSmeBlacklistCfm *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag); - CsrUint16Ser(ptr, len, (u16) primitive->status); - CsrUint8Ser(ptr, len, (u8) primitive->action); - CsrUint8Ser(ptr, len, (u8) primitive->getAddressCount); - { - u16 i1; - for (i1 = 0; i1 < primitive->getAddressCount; i1++) - { - CsrMemCpySer(ptr, len, (const void *) primitive->getAddresses[i1].a, ((u16) (6))); - } - } - return(ptr); -} - - -void* CsrWifiSmeBlacklistCfmDes(u8 *buffer, size_t length) -{ - CsrWifiSmeBlacklistCfm *primitive = kmalloc(sizeof(CsrWifiSmeBlacklistCfm), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset); - CsrUint16Des((u16 *) &primitive->status, buffer, &offset); - CsrUint8Des((u8 *) &primitive->action, buffer, &offset); - CsrUint8Des((u8 *) &primitive->getAddressCount, buffer, &offset); - primitive->getAddresses = NULL; - if (primitive->getAddressCount) - { - primitive->getAddresses = kmalloc(sizeof(CsrWifiMacAddress) * primitive->getAddressCount, GFP_KERNEL); - } - { - u16 i1; - for (i1 = 0; i1 < primitive->getAddressCount; i1++) - { - CsrMemCpyDes(primitive->getAddresses[i1].a, buffer, &offset, ((u16) (6))); - } - } - - return primitive; -} - - -void CsrWifiSmeBlacklistCfmSerFree(void *voidPrimitivePointer) -{ - CsrWifiSmeBlacklistCfm *primitive = (CsrWifiSmeBlacklistCfm *) voidPrimitivePointer; - kfree(primitive->getAddresses); - kfree(primitive); -} - - -size_t CsrWifiSmeCalibrationDataGetCfmSizeof(void *msg) -{ - CsrWifiSmeCalibrationDataGetCfm *primitive = (CsrWifiSmeCalibrationDataGetCfm *) msg; - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 8) */ - bufferSize += 2; /* CsrResult primitive->status */ - bufferSize += 2; /* u16 primitive->calibrationDataLength */ - bufferSize += primitive->calibrationDataLength; /* u8 primitive->calibrationData */ - return bufferSize; -} - - -u8* CsrWifiSmeCalibrationDataGetCfmSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiSmeCalibrationDataGetCfm *primitive = (CsrWifiSmeCalibrationDataGetCfm *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->status); - CsrUint16Ser(ptr, len, (u16) primitive->calibrationDataLength); - if (primitive->calibrationDataLength) - { - CsrMemCpySer(ptr, len, (const void *) primitive->calibrationData, ((u16) (primitive->calibrationDataLength))); - } - return(ptr); -} - - -void* CsrWifiSmeCalibrationDataGetCfmDes(u8 *buffer, size_t length) -{ - CsrWifiSmeCalibrationDataGetCfm *primitive = kmalloc(sizeof(CsrWifiSmeCalibrationDataGetCfm), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->status, buffer, &offset); - CsrUint16Des((u16 *) &primitive->calibrationDataLength, buffer, &offset); - if (primitive->calibrationDataLength) - { - primitive->calibrationData = kmalloc(primitive->calibrationDataLength, GFP_KERNEL); - CsrMemCpyDes(primitive->calibrationData, buffer, &offset, ((u16) (primitive->calibrationDataLength))); - } - else - { - primitive->calibrationData = NULL; - } - - return primitive; -} - - -void CsrWifiSmeCalibrationDataGetCfmSerFree(void *voidPrimitivePointer) -{ - CsrWifiSmeCalibrationDataGetCfm *primitive = (CsrWifiSmeCalibrationDataGetCfm *) voidPrimitivePointer; - kfree(primitive->calibrationData); - kfree(primitive); -} - - -size_t CsrWifiSmeCcxConfigGetCfmSizeof(void *msg) -{ - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 11) */ - bufferSize += 2; /* u16 primitive->interfaceTag */ - bufferSize += 2; /* CsrResult primitive->status */ - bufferSize += 1; /* u8 primitive->ccxConfig.keepAliveTimeMs */ - bufferSize += 1; /* u8 primitive->ccxConfig.apRoamingEnabled */ - bufferSize += 1; /* u8 primitive->ccxConfig.measurementsMask */ - bufferSize += 1; /* u8 primitive->ccxConfig.ccxRadioMgtEnabled */ - return bufferSize; -} - - -u8* CsrWifiSmeCcxConfigGetCfmSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiSmeCcxConfigGetCfm *primitive = (CsrWifiSmeCcxConfigGetCfm *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag); - CsrUint16Ser(ptr, len, (u16) primitive->status); - CsrUint8Ser(ptr, len, (u8) primitive->ccxConfig.keepAliveTimeMs); - CsrUint8Ser(ptr, len, (u8) primitive->ccxConfig.apRoamingEnabled); - CsrUint8Ser(ptr, len, (u8) primitive->ccxConfig.measurementsMask); - CsrUint8Ser(ptr, len, (u8) primitive->ccxConfig.ccxRadioMgtEnabled); - return(ptr); -} - - -void* CsrWifiSmeCcxConfigGetCfmDes(u8 *buffer, size_t length) -{ - CsrWifiSmeCcxConfigGetCfm *primitive = kmalloc(sizeof(CsrWifiSmeCcxConfigGetCfm), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset); - CsrUint16Des((u16 *) &primitive->status, buffer, &offset); - CsrUint8Des((u8 *) &primitive->ccxConfig.keepAliveTimeMs, buffer, &offset); - CsrUint8Des((u8 *) &primitive->ccxConfig.apRoamingEnabled, buffer, &offset); - CsrUint8Des((u8 *) &primitive->ccxConfig.measurementsMask, buffer, &offset); - CsrUint8Des((u8 *) &primitive->ccxConfig.ccxRadioMgtEnabled, buffer, &offset); - - return primitive; -} - - -size_t CsrWifiSmeCcxConfigSetCfmSizeof(void *msg) -{ - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 7) */ - bufferSize += 2; /* u16 primitive->interfaceTag */ - bufferSize += 2; /* CsrResult primitive->status */ - return bufferSize; -} - - -u8* CsrWifiSmeCcxConfigSetCfmSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiSmeCcxConfigSetCfm *primitive = (CsrWifiSmeCcxConfigSetCfm *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag); - CsrUint16Ser(ptr, len, (u16) primitive->status); - return(ptr); -} - - -void* CsrWifiSmeCcxConfigSetCfmDes(u8 *buffer, size_t length) -{ - CsrWifiSmeCcxConfigSetCfm *primitive = kmalloc(sizeof(CsrWifiSmeCcxConfigSetCfm), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset); - CsrUint16Des((u16 *) &primitive->status, buffer, &offset); - - return primitive; -} - - -size_t CsrWifiSmeCoexConfigGetCfmSizeof(void *msg) -{ - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 31) */ - bufferSize += 2; /* CsrResult primitive->status */ - bufferSize += 1; /* u8 primitive->coexConfig.coexEnableSchemeManagement */ - bufferSize += 1; /* u8 primitive->coexConfig.coexPeriodicWakeHost */ - bufferSize += 2; /* u16 primitive->coexConfig.coexTrafficBurstyLatencyMs */ - bufferSize += 2; /* u16 primitive->coexConfig.coexTrafficContinuousLatencyMs */ - bufferSize += 2; /* u16 primitive->coexConfig.coexObexBlackoutDurationMs */ - bufferSize += 2; /* u16 primitive->coexConfig.coexObexBlackoutPeriodMs */ - bufferSize += 2; /* u16 primitive->coexConfig.coexA2dpBrBlackoutDurationMs */ - bufferSize += 2; /* u16 primitive->coexConfig.coexA2dpBrBlackoutPeriodMs */ - bufferSize += 2; /* u16 primitive->coexConfig.coexA2dpEdrBlackoutDurationMs */ - bufferSize += 2; /* u16 primitive->coexConfig.coexA2dpEdrBlackoutPeriodMs */ - bufferSize += 2; /* u16 primitive->coexConfig.coexPagingBlackoutDurationMs */ - bufferSize += 2; /* u16 primitive->coexConfig.coexPagingBlackoutPeriodMs */ - bufferSize += 2; /* u16 primitive->coexConfig.coexInquiryBlackoutDurationMs */ - bufferSize += 2; /* u16 primitive->coexConfig.coexInquiryBlackoutPeriodMs */ - return bufferSize; -} - - -u8* CsrWifiSmeCoexConfigGetCfmSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiSmeCoexConfigGetCfm *primitive = (CsrWifiSmeCoexConfigGetCfm *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->status); - CsrUint8Ser(ptr, len, (u8) primitive->coexConfig.coexEnableSchemeManagement); - CsrUint8Ser(ptr, len, (u8) primitive->coexConfig.coexPeriodicWakeHost); - CsrUint16Ser(ptr, len, (u16) primitive->coexConfig.coexTrafficBurstyLatencyMs); - CsrUint16Ser(ptr, len, (u16) primitive->coexConfig.coexTrafficContinuousLatencyMs); - CsrUint16Ser(ptr, len, (u16) primitive->coexConfig.coexObexBlackoutDurationMs); - CsrUint16Ser(ptr, len, (u16) primitive->coexConfig.coexObexBlackoutPeriodMs); - CsrUint16Ser(ptr, len, (u16) primitive->coexConfig.coexA2dpBrBlackoutDurationMs); - CsrUint16Ser(ptr, len, (u16) primitive->coexConfig.coexA2dpBrBlackoutPeriodMs); - CsrUint16Ser(ptr, len, (u16) primitive->coexConfig.coexA2dpEdrBlackoutDurationMs); - CsrUint16Ser(ptr, len, (u16) primitive->coexConfig.coexA2dpEdrBlackoutPeriodMs); - CsrUint16Ser(ptr, len, (u16) primitive->coexConfig.coexPagingBlackoutDurationMs); - CsrUint16Ser(ptr, len, (u16) primitive->coexConfig.coexPagingBlackoutPeriodMs); - CsrUint16Ser(ptr, len, (u16) primitive->coexConfig.coexInquiryBlackoutDurationMs); - CsrUint16Ser(ptr, len, (u16) primitive->coexConfig.coexInquiryBlackoutPeriodMs); - return(ptr); -} - - -void* CsrWifiSmeCoexConfigGetCfmDes(u8 *buffer, size_t length) -{ - CsrWifiSmeCoexConfigGetCfm *primitive = kmalloc(sizeof(CsrWifiSmeCoexConfigGetCfm), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->status, buffer, &offset); - CsrUint8Des((u8 *) &primitive->coexConfig.coexEnableSchemeManagement, buffer, &offset); - CsrUint8Des((u8 *) &primitive->coexConfig.coexPeriodicWakeHost, buffer, &offset); - CsrUint16Des((u16 *) &primitive->coexConfig.coexTrafficBurstyLatencyMs, buffer, &offset); - CsrUint16Des((u16 *) &primitive->coexConfig.coexTrafficContinuousLatencyMs, buffer, &offset); - CsrUint16Des((u16 *) &primitive->coexConfig.coexObexBlackoutDurationMs, buffer, &offset); - CsrUint16Des((u16 *) &primitive->coexConfig.coexObexBlackoutPeriodMs, buffer, &offset); - CsrUint16Des((u16 *) &primitive->coexConfig.coexA2dpBrBlackoutDurationMs, buffer, &offset); - CsrUint16Des((u16 *) &primitive->coexConfig.coexA2dpBrBlackoutPeriodMs, buffer, &offset); - CsrUint16Des((u16 *) &primitive->coexConfig.coexA2dpEdrBlackoutDurationMs, buffer, &offset); - CsrUint16Des((u16 *) &primitive->coexConfig.coexA2dpEdrBlackoutPeriodMs, buffer, &offset); - CsrUint16Des((u16 *) &primitive->coexConfig.coexPagingBlackoutDurationMs, buffer, &offset); - CsrUint16Des((u16 *) &primitive->coexConfig.coexPagingBlackoutPeriodMs, buffer, &offset); - CsrUint16Des((u16 *) &primitive->coexConfig.coexInquiryBlackoutDurationMs, buffer, &offset); - CsrUint16Des((u16 *) &primitive->coexConfig.coexInquiryBlackoutPeriodMs, buffer, &offset); - - return primitive; -} - - -size_t CsrWifiSmeCoexInfoGetCfmSizeof(void *msg) -{ - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 24) */ - bufferSize += 2; /* CsrResult primitive->status */ - bufferSize += 1; /* u8 primitive->coexInfo.hasTrafficData */ - bufferSize += 1; /* CsrWifiSmeTrafficType primitive->coexInfo.currentTrafficType */ - bufferSize += 2; /* u16 primitive->coexInfo.currentPeriodMs */ - bufferSize += 1; /* CsrWifiSmePowerSaveLevel primitive->coexInfo.currentPowerSave */ - bufferSize += 2; /* u16 primitive->coexInfo.currentCoexPeriodMs */ - bufferSize += 2; /* u16 primitive->coexInfo.currentCoexLatencyMs */ - bufferSize += 1; /* u8 primitive->coexInfo.hasBtDevice */ - bufferSize += 4; /* u32 primitive->coexInfo.currentBlackoutDurationUs */ - bufferSize += 4; /* u32 primitive->coexInfo.currentBlackoutPeriodUs */ - bufferSize += 1; /* CsrWifiSmeCoexScheme primitive->coexInfo.currentCoexScheme */ - return bufferSize; -} - - -u8* CsrWifiSmeCoexInfoGetCfmSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiSmeCoexInfoGetCfm *primitive = (CsrWifiSmeCoexInfoGetCfm *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->status); - CsrUint8Ser(ptr, len, (u8) primitive->coexInfo.hasTrafficData); - CsrUint8Ser(ptr, len, (u8) primitive->coexInfo.currentTrafficType); - CsrUint16Ser(ptr, len, (u16) primitive->coexInfo.currentPeriodMs); - CsrUint8Ser(ptr, len, (u8) primitive->coexInfo.currentPowerSave); - CsrUint16Ser(ptr, len, (u16) primitive->coexInfo.currentCoexPeriodMs); - CsrUint16Ser(ptr, len, (u16) primitive->coexInfo.currentCoexLatencyMs); - CsrUint8Ser(ptr, len, (u8) primitive->coexInfo.hasBtDevice); - CsrUint32Ser(ptr, len, (u32) primitive->coexInfo.currentBlackoutDurationUs); - CsrUint32Ser(ptr, len, (u32) primitive->coexInfo.currentBlackoutPeriodUs); - CsrUint8Ser(ptr, len, (u8) primitive->coexInfo.currentCoexScheme); - return(ptr); -} - - -void* CsrWifiSmeCoexInfoGetCfmDes(u8 *buffer, size_t length) -{ - CsrWifiSmeCoexInfoGetCfm *primitive = kmalloc(sizeof(CsrWifiSmeCoexInfoGetCfm), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->status, buffer, &offset); - CsrUint8Des((u8 *) &primitive->coexInfo.hasTrafficData, buffer, &offset); - CsrUint8Des((u8 *) &primitive->coexInfo.currentTrafficType, buffer, &offset); - CsrUint16Des((u16 *) &primitive->coexInfo.currentPeriodMs, buffer, &offset); - CsrUint8Des((u8 *) &primitive->coexInfo.currentPowerSave, buffer, &offset); - CsrUint16Des((u16 *) &primitive->coexInfo.currentCoexPeriodMs, buffer, &offset); - CsrUint16Des((u16 *) &primitive->coexInfo.currentCoexLatencyMs, buffer, &offset); - CsrUint8Des((u8 *) &primitive->coexInfo.hasBtDevice, buffer, &offset); - CsrUint32Des((u32 *) &primitive->coexInfo.currentBlackoutDurationUs, buffer, &offset); - CsrUint32Des((u32 *) &primitive->coexInfo.currentBlackoutPeriodUs, buffer, &offset); - CsrUint8Des((u8 *) &primitive->coexInfo.currentCoexScheme, buffer, &offset); - - return primitive; -} - - -size_t CsrWifiSmeConnectCfmSizeof(void *msg) -{ - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 7) */ - bufferSize += 2; /* u16 primitive->interfaceTag */ - bufferSize += 2; /* CsrResult primitive->status */ - return bufferSize; -} - - -u8* CsrWifiSmeConnectCfmSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiSmeConnectCfm *primitive = (CsrWifiSmeConnectCfm *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag); - CsrUint16Ser(ptr, len, (u16) primitive->status); - return(ptr); -} - - -void* CsrWifiSmeConnectCfmDes(u8 *buffer, size_t length) -{ - CsrWifiSmeConnectCfm *primitive = kmalloc(sizeof(CsrWifiSmeConnectCfm), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset); - CsrUint16Des((u16 *) &primitive->status, buffer, &offset); - - return primitive; -} - - -size_t CsrWifiSmeConnectionConfigGetCfmSizeof(void *msg) -{ - CsrWifiSmeConnectionConfigGetCfm *primitive = (CsrWifiSmeConnectionConfigGetCfm *) msg; - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 59) */ - bufferSize += 2; /* u16 primitive->interfaceTag */ - bufferSize += 2; /* CsrResult primitive->status */ - bufferSize += 32; /* u8 primitive->connectionConfig.ssid.ssid[32] */ - bufferSize += 1; /* u8 primitive->connectionConfig.ssid.length */ - bufferSize += 6; /* u8 primitive->connectionConfig.bssid.a[6] */ - bufferSize += 1; /* CsrWifiSmeBssType primitive->connectionConfig.bssType */ - bufferSize += 1; /* CsrWifiSmeRadioIF primitive->connectionConfig.ifIndex */ - bufferSize += 1; /* CsrWifiSme80211PrivacyMode primitive->connectionConfig.privacyMode */ - bufferSize += 2; /* CsrWifiSmeAuthModeMask primitive->connectionConfig.authModeMask */ - bufferSize += 2; /* CsrWifiSmeEncryptionMask primitive->connectionConfig.encryptionModeMask */ - bufferSize += 2; /* u16 primitive->connectionConfig.mlmeAssociateReqInformationElementsLength */ - bufferSize += primitive->connectionConfig.mlmeAssociateReqInformationElementsLength; /* u8 primitive->connectionConfig.mlmeAssociateReqInformationElements */ - bufferSize += 1; /* CsrWifiSmeWmmQosInfoMask primitive->connectionConfig.wmmQosInfo */ - bufferSize += 1; /* u8 primitive->connectionConfig.adhocJoinOnly */ - bufferSize += 1; /* u8 primitive->connectionConfig.adhocChannel */ - return bufferSize; -} - - -u8* CsrWifiSmeConnectionConfigGetCfmSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiSmeConnectionConfigGetCfm *primitive = (CsrWifiSmeConnectionConfigGetCfm *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag); - CsrUint16Ser(ptr, len, (u16) primitive->status); - CsrMemCpySer(ptr, len, (const void *) primitive->connectionConfig.ssid.ssid, ((u16) (32))); - CsrUint8Ser(ptr, len, (u8) primitive->connectionConfig.ssid.length); - CsrMemCpySer(ptr, len, (const void *) primitive->connectionConfig.bssid.a, ((u16) (6))); - CsrUint8Ser(ptr, len, (u8) primitive->connectionConfig.bssType); - CsrUint8Ser(ptr, len, (u8) primitive->connectionConfig.ifIndex); - CsrUint8Ser(ptr, len, (u8) primitive->connectionConfig.privacyMode); - CsrUint16Ser(ptr, len, (u16) primitive->connectionConfig.authModeMask); - CsrUint16Ser(ptr, len, (u16) primitive->connectionConfig.encryptionModeMask); - CsrUint16Ser(ptr, len, (u16) primitive->connectionConfig.mlmeAssociateReqInformationElementsLength); - if (primitive->connectionConfig.mlmeAssociateReqInformationElementsLength) - { - CsrMemCpySer(ptr, len, (const void *) primitive->connectionConfig.mlmeAssociateReqInformationElements, ((u16) (primitive->connectionConfig.mlmeAssociateReqInformationElementsLength))); - } - CsrUint8Ser(ptr, len, (u8) primitive->connectionConfig.wmmQosInfo); - CsrUint8Ser(ptr, len, (u8) primitive->connectionConfig.adhocJoinOnly); - CsrUint8Ser(ptr, len, (u8) primitive->connectionConfig.adhocChannel); - return(ptr); -} - - -void* CsrWifiSmeConnectionConfigGetCfmDes(u8 *buffer, size_t length) -{ - CsrWifiSmeConnectionConfigGetCfm *primitive = kmalloc(sizeof(CsrWifiSmeConnectionConfigGetCfm), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset); - CsrUint16Des((u16 *) &primitive->status, buffer, &offset); - CsrMemCpyDes(primitive->connectionConfig.ssid.ssid, buffer, &offset, ((u16) (32))); - CsrUint8Des((u8 *) &primitive->connectionConfig.ssid.length, buffer, &offset); - CsrMemCpyDes(primitive->connectionConfig.bssid.a, buffer, &offset, ((u16) (6))); - CsrUint8Des((u8 *) &primitive->connectionConfig.bssType, buffer, &offset); - CsrUint8Des((u8 *) &primitive->connectionConfig.ifIndex, buffer, &offset); - CsrUint8Des((u8 *) &primitive->connectionConfig.privacyMode, buffer, &offset); - CsrUint16Des((u16 *) &primitive->connectionConfig.authModeMask, buffer, &offset); - CsrUint16Des((u16 *) &primitive->connectionConfig.encryptionModeMask, buffer, &offset); - CsrUint16Des((u16 *) &primitive->connectionConfig.mlmeAssociateReqInformationElementsLength, buffer, &offset); - if (primitive->connectionConfig.mlmeAssociateReqInformationElementsLength) - { - primitive->connectionConfig.mlmeAssociateReqInformationElements = kmalloc(primitive->connectionConfig.mlmeAssociateReqInformationElementsLength, GFP_KERNEL); - CsrMemCpyDes(primitive->connectionConfig.mlmeAssociateReqInformationElements, buffer, &offset, ((u16) (primitive->connectionConfig.mlmeAssociateReqInformationElementsLength))); - } - else - { - primitive->connectionConfig.mlmeAssociateReqInformationElements = NULL; - } - CsrUint8Des((u8 *) &primitive->connectionConfig.wmmQosInfo, buffer, &offset); - CsrUint8Des((u8 *) &primitive->connectionConfig.adhocJoinOnly, buffer, &offset); - CsrUint8Des((u8 *) &primitive->connectionConfig.adhocChannel, buffer, &offset); - - return primitive; -} - - -void CsrWifiSmeConnectionConfigGetCfmSerFree(void *voidPrimitivePointer) -{ - CsrWifiSmeConnectionConfigGetCfm *primitive = (CsrWifiSmeConnectionConfigGetCfm *) voidPrimitivePointer; - kfree(primitive->connectionConfig.mlmeAssociateReqInformationElements); - kfree(primitive); -} - - -size_t CsrWifiSmeConnectionInfoGetCfmSizeof(void *msg) -{ - CsrWifiSmeConnectionInfoGetCfm *primitive = (CsrWifiSmeConnectionInfoGetCfm *) msg; - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 96) */ - bufferSize += 2; /* u16 primitive->interfaceTag */ - bufferSize += 2; /* CsrResult primitive->status */ - bufferSize += 32; /* u8 primitive->connectionInfo.ssid.ssid[32] */ - bufferSize += 1; /* u8 primitive->connectionInfo.ssid.length */ - bufferSize += 6; /* u8 primitive->connectionInfo.bssid.a[6] */ - bufferSize += 1; /* CsrWifiSme80211NetworkType primitive->connectionInfo.networkType80211 */ - bufferSize += 1; /* u8 primitive->connectionInfo.channelNumber */ - bufferSize += 2; /* u16 primitive->connectionInfo.channelFrequency */ - bufferSize += 2; /* CsrWifiSmeAuthMode primitive->connectionInfo.authMode */ - bufferSize += 2; /* CsrWifiSmeEncryption primitive->connectionInfo.pairwiseCipher */ - bufferSize += 2; /* CsrWifiSmeEncryption primitive->connectionInfo.groupCipher */ - bufferSize += 1; /* CsrWifiSmeRadioIF primitive->connectionInfo.ifIndex */ - bufferSize += 2; /* u16 primitive->connectionInfo.atimWindowTu */ - bufferSize += 2; /* u16 primitive->connectionInfo.beaconPeriodTu */ - bufferSize += 1; /* u8 primitive->connectionInfo.reassociation */ - bufferSize += 2; /* u16 primitive->connectionInfo.beaconFrameLength */ - bufferSize += primitive->connectionInfo.beaconFrameLength; /* u8 primitive->connectionInfo.beaconFrame */ - bufferSize += 2; /* u16 primitive->connectionInfo.associationReqFrameLength */ - bufferSize += primitive->connectionInfo.associationReqFrameLength; /* u8 primitive->connectionInfo.associationReqFrame */ - bufferSize += 2; /* u16 primitive->connectionInfo.associationRspFrameLength */ - bufferSize += primitive->connectionInfo.associationRspFrameLength; /* u8 primitive->connectionInfo.associationRspFrame */ - bufferSize += 2; /* u16 primitive->connectionInfo.assocScanInfoElementsLength */ - bufferSize += primitive->connectionInfo.assocScanInfoElementsLength; /* u8 primitive->connectionInfo.assocScanInfoElements */ - bufferSize += 2; /* u16 primitive->connectionInfo.assocReqCapabilities */ - bufferSize += 2; /* u16 primitive->connectionInfo.assocReqListenIntervalTu */ - bufferSize += 6; /* u8 primitive->connectionInfo.assocReqApAddress.a[6] */ - bufferSize += 2; /* u16 primitive->connectionInfo.assocReqInfoElementsLength */ - bufferSize += primitive->connectionInfo.assocReqInfoElementsLength; /* u8 primitive->connectionInfo.assocReqInfoElements */ - bufferSize += 2; /* CsrWifiSmeIEEE80211Result primitive->connectionInfo.assocRspResult */ - bufferSize += 2; /* u16 primitive->connectionInfo.assocRspCapabilityInfo */ - bufferSize += 2; /* u16 primitive->connectionInfo.assocRspAssociationId */ - bufferSize += 2; /* u16 primitive->connectionInfo.assocRspInfoElementsLength */ - bufferSize += primitive->connectionInfo.assocRspInfoElementsLength; /* u8 primitive->connectionInfo.assocRspInfoElements */ - return bufferSize; -} - - -u8* CsrWifiSmeConnectionInfoGetCfmSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiSmeConnectionInfoGetCfm *primitive = (CsrWifiSmeConnectionInfoGetCfm *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag); - CsrUint16Ser(ptr, len, (u16) primitive->status); - CsrMemCpySer(ptr, len, (const void *) primitive->connectionInfo.ssid.ssid, ((u16) (32))); - CsrUint8Ser(ptr, len, (u8) primitive->connectionInfo.ssid.length); - CsrMemCpySer(ptr, len, (const void *) primitive->connectionInfo.bssid.a, ((u16) (6))); - CsrUint8Ser(ptr, len, (u8) primitive->connectionInfo.networkType80211); - CsrUint8Ser(ptr, len, (u8) primitive->connectionInfo.channelNumber); - CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.channelFrequency); - CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.authMode); - CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.pairwiseCipher); - CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.groupCipher); - CsrUint8Ser(ptr, len, (u8) primitive->connectionInfo.ifIndex); - CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.atimWindowTu); - CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.beaconPeriodTu); - CsrUint8Ser(ptr, len, (u8) primitive->connectionInfo.reassociation); - CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.beaconFrameLength); - if (primitive->connectionInfo.beaconFrameLength) - { - CsrMemCpySer(ptr, len, (const void *) primitive->connectionInfo.beaconFrame, ((u16) (primitive->connectionInfo.beaconFrameLength))); - } - CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.associationReqFrameLength); - if (primitive->connectionInfo.associationReqFrameLength) - { - CsrMemCpySer(ptr, len, (const void *) primitive->connectionInfo.associationReqFrame, ((u16) (primitive->connectionInfo.associationReqFrameLength))); - } - CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.associationRspFrameLength); - if (primitive->connectionInfo.associationRspFrameLength) - { - CsrMemCpySer(ptr, len, (const void *) primitive->connectionInfo.associationRspFrame, ((u16) (primitive->connectionInfo.associationRspFrameLength))); - } - CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.assocScanInfoElementsLength); - if (primitive->connectionInfo.assocScanInfoElementsLength) - { - CsrMemCpySer(ptr, len, (const void *) primitive->connectionInfo.assocScanInfoElements, ((u16) (primitive->connectionInfo.assocScanInfoElementsLength))); - } - CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.assocReqCapabilities); - CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.assocReqListenIntervalTu); - CsrMemCpySer(ptr, len, (const void *) primitive->connectionInfo.assocReqApAddress.a, ((u16) (6))); - CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.assocReqInfoElementsLength); - if (primitive->connectionInfo.assocReqInfoElementsLength) - { - CsrMemCpySer(ptr, len, (const void *) primitive->connectionInfo.assocReqInfoElements, ((u16) (primitive->connectionInfo.assocReqInfoElementsLength))); - } - CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.assocRspResult); - CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.assocRspCapabilityInfo); - CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.assocRspAssociationId); - CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.assocRspInfoElementsLength); - if (primitive->connectionInfo.assocRspInfoElementsLength) - { - CsrMemCpySer(ptr, len, (const void *) primitive->connectionInfo.assocRspInfoElements, ((u16) (primitive->connectionInfo.assocRspInfoElementsLength))); - } - return(ptr); -} - - -void* CsrWifiSmeConnectionInfoGetCfmDes(u8 *buffer, size_t length) -{ - CsrWifiSmeConnectionInfoGetCfm *primitive = kmalloc(sizeof(CsrWifiSmeConnectionInfoGetCfm), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset); - CsrUint16Des((u16 *) &primitive->status, buffer, &offset); - CsrMemCpyDes(primitive->connectionInfo.ssid.ssid, buffer, &offset, ((u16) (32))); - CsrUint8Des((u8 *) &primitive->connectionInfo.ssid.length, buffer, &offset); - CsrMemCpyDes(primitive->connectionInfo.bssid.a, buffer, &offset, ((u16) (6))); - CsrUint8Des((u8 *) &primitive->connectionInfo.networkType80211, buffer, &offset); - CsrUint8Des((u8 *) &primitive->connectionInfo.channelNumber, buffer, &offset); - CsrUint16Des((u16 *) &primitive->connectionInfo.channelFrequency, buffer, &offset); - CsrUint16Des((u16 *) &primitive->connectionInfo.authMode, buffer, &offset); - CsrUint16Des((u16 *) &primitive->connectionInfo.pairwiseCipher, buffer, &offset); - CsrUint16Des((u16 *) &primitive->connectionInfo.groupCipher, buffer, &offset); - CsrUint8Des((u8 *) &primitive->connectionInfo.ifIndex, buffer, &offset); - CsrUint16Des((u16 *) &primitive->connectionInfo.atimWindowTu, buffer, &offset); - CsrUint16Des((u16 *) &primitive->connectionInfo.beaconPeriodTu, buffer, &offset); - CsrUint8Des((u8 *) &primitive->connectionInfo.reassociation, buffer, &offset); - CsrUint16Des((u16 *) &primitive->connectionInfo.beaconFrameLength, buffer, &offset); - if (primitive->connectionInfo.beaconFrameLength) - { - primitive->connectionInfo.beaconFrame = kmalloc(primitive->connectionInfo.beaconFrameLength, GFP_KERNEL); - CsrMemCpyDes(primitive->connectionInfo.beaconFrame, buffer, &offset, ((u16) (primitive->connectionInfo.beaconFrameLength))); - } - else - { - primitive->connectionInfo.beaconFrame = NULL; - } - CsrUint16Des((u16 *) &primitive->connectionInfo.associationReqFrameLength, buffer, &offset); - if (primitive->connectionInfo.associationReqFrameLength) - { - primitive->connectionInfo.associationReqFrame = kmalloc(primitive->connectionInfo.associationReqFrameLength, GFP_KERNEL); - CsrMemCpyDes(primitive->connectionInfo.associationReqFrame, buffer, &offset, ((u16) (primitive->connectionInfo.associationReqFrameLength))); - } - else - { - primitive->connectionInfo.associationReqFrame = NULL; - } - CsrUint16Des((u16 *) &primitive->connectionInfo.associationRspFrameLength, buffer, &offset); - if (primitive->connectionInfo.associationRspFrameLength) - { - primitive->connectionInfo.associationRspFrame = kmalloc(primitive->connectionInfo.associationRspFrameLength, GFP_KERNEL); - CsrMemCpyDes(primitive->connectionInfo.associationRspFrame, buffer, &offset, ((u16) (primitive->connectionInfo.associationRspFrameLength))); - } - else - { - primitive->connectionInfo.associationRspFrame = NULL; - } - CsrUint16Des((u16 *) &primitive->connectionInfo.assocScanInfoElementsLength, buffer, &offset); - if (primitive->connectionInfo.assocScanInfoElementsLength) - { - primitive->connectionInfo.assocScanInfoElements = kmalloc(primitive->connectionInfo.assocScanInfoElementsLength, GFP_KERNEL); - CsrMemCpyDes(primitive->connectionInfo.assocScanInfoElements, buffer, &offset, ((u16) (primitive->connectionInfo.assocScanInfoElementsLength))); - } - else - { - primitive->connectionInfo.assocScanInfoElements = NULL; - } - CsrUint16Des((u16 *) &primitive->connectionInfo.assocReqCapabilities, buffer, &offset); - CsrUint16Des((u16 *) &primitive->connectionInfo.assocReqListenIntervalTu, buffer, &offset); - CsrMemCpyDes(primitive->connectionInfo.assocReqApAddress.a, buffer, &offset, ((u16) (6))); - CsrUint16Des((u16 *) &primitive->connectionInfo.assocReqInfoElementsLength, buffer, &offset); - if (primitive->connectionInfo.assocReqInfoElementsLength) - { - primitive->connectionInfo.assocReqInfoElements = kmalloc(primitive->connectionInfo.assocReqInfoElementsLength, GFP_KERNEL); - CsrMemCpyDes(primitive->connectionInfo.assocReqInfoElements, buffer, &offset, ((u16) (primitive->connectionInfo.assocReqInfoElementsLength))); - } - else - { - primitive->connectionInfo.assocReqInfoElements = NULL; - } - CsrUint16Des((u16 *) &primitive->connectionInfo.assocRspResult, buffer, &offset); - CsrUint16Des((u16 *) &primitive->connectionInfo.assocRspCapabilityInfo, buffer, &offset); - CsrUint16Des((u16 *) &primitive->connectionInfo.assocRspAssociationId, buffer, &offset); - CsrUint16Des((u16 *) &primitive->connectionInfo.assocRspInfoElementsLength, buffer, &offset); - if (primitive->connectionInfo.assocRspInfoElementsLength) - { - primitive->connectionInfo.assocRspInfoElements = kmalloc(primitive->connectionInfo.assocRspInfoElementsLength, GFP_KERNEL); - CsrMemCpyDes(primitive->connectionInfo.assocRspInfoElements, buffer, &offset, ((u16) (primitive->connectionInfo.assocRspInfoElementsLength))); - } - else - { - primitive->connectionInfo.assocRspInfoElements = NULL; - } - - return primitive; -} - - -void CsrWifiSmeConnectionInfoGetCfmSerFree(void *voidPrimitivePointer) -{ - CsrWifiSmeConnectionInfoGetCfm *primitive = (CsrWifiSmeConnectionInfoGetCfm *) voidPrimitivePointer; - kfree(primitive->connectionInfo.beaconFrame); - kfree(primitive->connectionInfo.associationReqFrame); - kfree(primitive->connectionInfo.associationRspFrame); - kfree(primitive->connectionInfo.assocScanInfoElements); - kfree(primitive->connectionInfo.assocReqInfoElements); - kfree(primitive->connectionInfo.assocRspInfoElements); - kfree(primitive); -} - - -size_t CsrWifiSmeConnectionQualityIndSizeof(void *msg) -{ - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 9) */ - bufferSize += 2; /* u16 primitive->interfaceTag */ - bufferSize += 2; /* s16 primitive->linkQuality.unifiRssi */ - bufferSize += 2; /* s16 primitive->linkQuality.unifiSnr */ - return bufferSize; -} - - -u8* CsrWifiSmeConnectionQualityIndSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiSmeConnectionQualityInd *primitive = (CsrWifiSmeConnectionQualityInd *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag); - CsrUint16Ser(ptr, len, (u16) primitive->linkQuality.unifiRssi); - CsrUint16Ser(ptr, len, (u16) primitive->linkQuality.unifiSnr); - return(ptr); -} - - -void* CsrWifiSmeConnectionQualityIndDes(u8 *buffer, size_t length) -{ - CsrWifiSmeConnectionQualityInd *primitive = kmalloc(sizeof(CsrWifiSmeConnectionQualityInd), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset); - CsrUint16Des((u16 *) &primitive->linkQuality.unifiRssi, buffer, &offset); - CsrUint16Des((u16 *) &primitive->linkQuality.unifiSnr, buffer, &offset); - - return primitive; -} - - -size_t CsrWifiSmeConnectionStatsGetCfmSizeof(void *msg) -{ - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 101) */ - bufferSize += 2; /* u16 primitive->interfaceTag */ - bufferSize += 2; /* CsrResult primitive->status */ - bufferSize += 1; /* u8 primitive->connectionStats.unifiTxDataRate */ - bufferSize += 1; /* u8 primitive->connectionStats.unifiRxDataRate */ - bufferSize += 4; /* u32 primitive->connectionStats.dot11RetryCount */ - bufferSize += 4; /* u32 primitive->connectionStats.dot11MultipleRetryCount */ - bufferSize += 4; /* u32 primitive->connectionStats.dot11AckFailureCount */ - bufferSize += 4; /* u32 primitive->connectionStats.dot11FrameDuplicateCount */ - bufferSize += 4; /* u32 primitive->connectionStats.dot11FcsErrorCount */ - bufferSize += 4; /* u32 primitive->connectionStats.dot11RtsSuccessCount */ - bufferSize += 4; /* u32 primitive->connectionStats.dot11RtsFailureCount */ - bufferSize += 4; /* u32 primitive->connectionStats.dot11FailedCount */ - bufferSize += 4; /* u32 primitive->connectionStats.dot11TransmittedFragmentCount */ - bufferSize += 4; /* u32 primitive->connectionStats.dot11TransmittedFrameCount */ - bufferSize += 4; /* u32 primitive->connectionStats.dot11WepExcludedCount */ - bufferSize += 4; /* u32 primitive->connectionStats.dot11WepIcvErrorCount */ - bufferSize += 4; /* u32 primitive->connectionStats.dot11WepUndecryptableCount */ - bufferSize += 4; /* u32 primitive->connectionStats.dot11MulticastReceivedFrameCount */ - bufferSize += 4; /* u32 primitive->connectionStats.dot11MulticastTransmittedFrameCount */ - bufferSize += 4; /* u32 primitive->connectionStats.dot11ReceivedFragmentCount */ - bufferSize += 4; /* u32 primitive->connectionStats.dot11Rsna4WayHandshakeFailures */ - bufferSize += 4; /* u32 primitive->connectionStats.dot11RsnaTkipCounterMeasuresInvoked */ - bufferSize += 4; /* u32 primitive->connectionStats.dot11RsnaStatsTkipLocalMicFailures */ - bufferSize += 4; /* u32 primitive->connectionStats.dot11RsnaStatsTkipReplays */ - bufferSize += 4; /* u32 primitive->connectionStats.dot11RsnaStatsTkipIcvErrors */ - bufferSize += 4; /* u32 primitive->connectionStats.dot11RsnaStatsCcmpReplays */ - bufferSize += 4; /* u32 primitive->connectionStats.dot11RsnaStatsCcmpDecryptErrors */ - return bufferSize; -} - - -u8* CsrWifiSmeConnectionStatsGetCfmSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiSmeConnectionStatsGetCfm *primitive = (CsrWifiSmeConnectionStatsGetCfm *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag); - CsrUint16Ser(ptr, len, (u16) primitive->status); - CsrUint8Ser(ptr, len, (u8) primitive->connectionStats.unifiTxDataRate); - CsrUint8Ser(ptr, len, (u8) primitive->connectionStats.unifiRxDataRate); - CsrUint32Ser(ptr, len, (u32) primitive->connectionStats.dot11RetryCount); - CsrUint32Ser(ptr, len, (u32) primitive->connectionStats.dot11MultipleRetryCount); - CsrUint32Ser(ptr, len, (u32) primitive->connectionStats.dot11AckFailureCount); - CsrUint32Ser(ptr, len, (u32) primitive->connectionStats.dot11FrameDuplicateCount); - CsrUint32Ser(ptr, len, (u32) primitive->connectionStats.dot11FcsErrorCount); - CsrUint32Ser(ptr, len, (u32) primitive->connectionStats.dot11RtsSuccessCount); - CsrUint32Ser(ptr, len, (u32) primitive->connectionStats.dot11RtsFailureCount); - CsrUint32Ser(ptr, len, (u32) primitive->connectionStats.dot11FailedCount); - CsrUint32Ser(ptr, len, (u32) primitive->connectionStats.dot11TransmittedFragmentCount); - CsrUint32Ser(ptr, len, (u32) primitive->connectionStats.dot11TransmittedFrameCount); - CsrUint32Ser(ptr, len, (u32) primitive->connectionStats.dot11WepExcludedCount); - CsrUint32Ser(ptr, len, (u32) primitive->connectionStats.dot11WepIcvErrorCount); - CsrUint32Ser(ptr, len, (u32) primitive->connectionStats.dot11WepUndecryptableCount); - CsrUint32Ser(ptr, len, (u32) primitive->connectionStats.dot11MulticastReceivedFrameCount); - CsrUint32Ser(ptr, len, (u32) primitive->connectionStats.dot11MulticastTransmittedFrameCount); - CsrUint32Ser(ptr, len, (u32) primitive->connectionStats.dot11ReceivedFragmentCount); - CsrUint32Ser(ptr, len, (u32) primitive->connectionStats.dot11Rsna4WayHandshakeFailures); - CsrUint32Ser(ptr, len, (u32) primitive->connectionStats.dot11RsnaTkipCounterMeasuresInvoked); - CsrUint32Ser(ptr, len, (u32) primitive->connectionStats.dot11RsnaStatsTkipLocalMicFailures); - CsrUint32Ser(ptr, len, (u32) primitive->connectionStats.dot11RsnaStatsTkipReplays); - CsrUint32Ser(ptr, len, (u32) primitive->connectionStats.dot11RsnaStatsTkipIcvErrors); - CsrUint32Ser(ptr, len, (u32) primitive->connectionStats.dot11RsnaStatsCcmpReplays); - CsrUint32Ser(ptr, len, (u32) primitive->connectionStats.dot11RsnaStatsCcmpDecryptErrors); - return(ptr); -} - - -void* CsrWifiSmeConnectionStatsGetCfmDes(u8 *buffer, size_t length) -{ - CsrWifiSmeConnectionStatsGetCfm *primitive = kmalloc(sizeof(CsrWifiSmeConnectionStatsGetCfm), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset); - CsrUint16Des((u16 *) &primitive->status, buffer, &offset); - CsrUint8Des((u8 *) &primitive->connectionStats.unifiTxDataRate, buffer, &offset); - CsrUint8Des((u8 *) &primitive->connectionStats.unifiRxDataRate, buffer, &offset); - CsrUint32Des((u32 *) &primitive->connectionStats.dot11RetryCount, buffer, &offset); - CsrUint32Des((u32 *) &primitive->connectionStats.dot11MultipleRetryCount, buffer, &offset); - CsrUint32Des((u32 *) &primitive->connectionStats.dot11AckFailureCount, buffer, &offset); - CsrUint32Des((u32 *) &primitive->connectionStats.dot11FrameDuplicateCount, buffer, &offset); - CsrUint32Des((u32 *) &primitive->connectionStats.dot11FcsErrorCount, buffer, &offset); - CsrUint32Des((u32 *) &primitive->connectionStats.dot11RtsSuccessCount, buffer, &offset); - CsrUint32Des((u32 *) &primitive->connectionStats.dot11RtsFailureCount, buffer, &offset); - CsrUint32Des((u32 *) &primitive->connectionStats.dot11FailedCount, buffer, &offset); - CsrUint32Des((u32 *) &primitive->connectionStats.dot11TransmittedFragmentCount, buffer, &offset); - CsrUint32Des((u32 *) &primitive->connectionStats.dot11TransmittedFrameCount, buffer, &offset); - CsrUint32Des((u32 *) &primitive->connectionStats.dot11WepExcludedCount, buffer, &offset); - CsrUint32Des((u32 *) &primitive->connectionStats.dot11WepIcvErrorCount, buffer, &offset); - CsrUint32Des((u32 *) &primitive->connectionStats.dot11WepUndecryptableCount, buffer, &offset); - CsrUint32Des((u32 *) &primitive->connectionStats.dot11MulticastReceivedFrameCount, buffer, &offset); - CsrUint32Des((u32 *) &primitive->connectionStats.dot11MulticastTransmittedFrameCount, buffer, &offset); - CsrUint32Des((u32 *) &primitive->connectionStats.dot11ReceivedFragmentCount, buffer, &offset); - CsrUint32Des((u32 *) &primitive->connectionStats.dot11Rsna4WayHandshakeFailures, buffer, &offset); - CsrUint32Des((u32 *) &primitive->connectionStats.dot11RsnaTkipCounterMeasuresInvoked, buffer, &offset); - CsrUint32Des((u32 *) &primitive->connectionStats.dot11RsnaStatsTkipLocalMicFailures, buffer, &offset); - CsrUint32Des((u32 *) &primitive->connectionStats.dot11RsnaStatsTkipReplays, buffer, &offset); - CsrUint32Des((u32 *) &primitive->connectionStats.dot11RsnaStatsTkipIcvErrors, buffer, &offset); - CsrUint32Des((u32 *) &primitive->connectionStats.dot11RsnaStatsCcmpReplays, buffer, &offset); - CsrUint32Des((u32 *) &primitive->connectionStats.dot11RsnaStatsCcmpDecryptErrors, buffer, &offset); - - return primitive; -} - - -size_t CsrWifiSmeDisconnectCfmSizeof(void *msg) -{ - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 7) */ - bufferSize += 2; /* u16 primitive->interfaceTag */ - bufferSize += 2; /* CsrResult primitive->status */ - return bufferSize; -} - - -u8* CsrWifiSmeDisconnectCfmSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiSmeDisconnectCfm *primitive = (CsrWifiSmeDisconnectCfm *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag); - CsrUint16Ser(ptr, len, (u16) primitive->status); - return(ptr); -} - - -void* CsrWifiSmeDisconnectCfmDes(u8 *buffer, size_t length) -{ - CsrWifiSmeDisconnectCfm *primitive = kmalloc(sizeof(CsrWifiSmeDisconnectCfm), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset); - CsrUint16Des((u16 *) &primitive->status, buffer, &offset); - - return primitive; -} - - -size_t CsrWifiSmeHostConfigGetCfmSizeof(void *msg) -{ - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 10) */ - bufferSize += 2; /* u16 primitive->interfaceTag */ - bufferSize += 2; /* CsrResult primitive->status */ - bufferSize += 1; /* CsrWifiSmeHostPowerMode primitive->hostConfig.powerMode */ - bufferSize += 2; /* u16 primitive->hostConfig.applicationDataPeriodMs */ - return bufferSize; -} - - -u8* CsrWifiSmeHostConfigGetCfmSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiSmeHostConfigGetCfm *primitive = (CsrWifiSmeHostConfigGetCfm *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag); - CsrUint16Ser(ptr, len, (u16) primitive->status); - CsrUint8Ser(ptr, len, (u8) primitive->hostConfig.powerMode); - CsrUint16Ser(ptr, len, (u16) primitive->hostConfig.applicationDataPeriodMs); - return(ptr); -} - - -void* CsrWifiSmeHostConfigGetCfmDes(u8 *buffer, size_t length) -{ - CsrWifiSmeHostConfigGetCfm *primitive = kmalloc(sizeof(CsrWifiSmeHostConfigGetCfm), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset); - CsrUint16Des((u16 *) &primitive->status, buffer, &offset); - CsrUint8Des((u8 *) &primitive->hostConfig.powerMode, buffer, &offset); - CsrUint16Des((u16 *) &primitive->hostConfig.applicationDataPeriodMs, buffer, &offset); - - return primitive; -} - - -size_t CsrWifiSmeHostConfigSetCfmSizeof(void *msg) -{ - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 7) */ - bufferSize += 2; /* u16 primitive->interfaceTag */ - bufferSize += 2; /* CsrResult primitive->status */ - return bufferSize; -} - - -u8* CsrWifiSmeHostConfigSetCfmSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiSmeHostConfigSetCfm *primitive = (CsrWifiSmeHostConfigSetCfm *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag); - CsrUint16Ser(ptr, len, (u16) primitive->status); - return(ptr); -} - - -void* CsrWifiSmeHostConfigSetCfmDes(u8 *buffer, size_t length) -{ - CsrWifiSmeHostConfigSetCfm *primitive = kmalloc(sizeof(CsrWifiSmeHostConfigSetCfm), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset); - CsrUint16Des((u16 *) &primitive->status, buffer, &offset); - - return primitive; -} - - -size_t CsrWifiSmeIbssStationIndSizeof(void *msg) -{ - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 10) */ - bufferSize += 6; /* u8 primitive->address.a[6] */ - bufferSize += 1; /* u8 primitive->isconnected */ - return bufferSize; -} - - -u8* CsrWifiSmeIbssStationIndSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiSmeIbssStationInd *primitive = (CsrWifiSmeIbssStationInd *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrMemCpySer(ptr, len, (const void *) primitive->address.a, ((u16) (6))); - CsrUint8Ser(ptr, len, (u8) primitive->isconnected); - return(ptr); -} - - -void* CsrWifiSmeIbssStationIndDes(u8 *buffer, size_t length) -{ - CsrWifiSmeIbssStationInd *primitive = kmalloc(sizeof(CsrWifiSmeIbssStationInd), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrMemCpyDes(primitive->address.a, buffer, &offset, ((u16) (6))); - CsrUint8Des((u8 *) &primitive->isconnected, buffer, &offset); - - return primitive; -} - - -size_t CsrWifiSmeKeyCfmSizeof(void *msg) -{ - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 15) */ - bufferSize += 2; /* u16 primitive->interfaceTag */ - bufferSize += 2; /* CsrResult primitive->status */ - bufferSize += 1; /* CsrWifiSmeListAction primitive->action */ - bufferSize += 1; /* CsrWifiSmeKeyType primitive->keyType */ - bufferSize += 6; /* u8 primitive->peerMacAddress.a[6] */ - return bufferSize; -} - - -u8* CsrWifiSmeKeyCfmSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiSmeKeyCfm *primitive = (CsrWifiSmeKeyCfm *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag); - CsrUint16Ser(ptr, len, (u16) primitive->status); - CsrUint8Ser(ptr, len, (u8) primitive->action); - CsrUint8Ser(ptr, len, (u8) primitive->keyType); - CsrMemCpySer(ptr, len, (const void *) primitive->peerMacAddress.a, ((u16) (6))); - return(ptr); -} - - -void* CsrWifiSmeKeyCfmDes(u8 *buffer, size_t length) -{ - CsrWifiSmeKeyCfm *primitive = kmalloc(sizeof(CsrWifiSmeKeyCfm), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset); - CsrUint16Des((u16 *) &primitive->status, buffer, &offset); - CsrUint8Des((u8 *) &primitive->action, buffer, &offset); - CsrUint8Des((u8 *) &primitive->keyType, buffer, &offset); - CsrMemCpyDes(primitive->peerMacAddress.a, buffer, &offset, ((u16) (6))); - - return primitive; -} - - -size_t CsrWifiSmeLinkQualityGetCfmSizeof(void *msg) -{ - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 11) */ - bufferSize += 2; /* u16 primitive->interfaceTag */ - bufferSize += 2; /* CsrResult primitive->status */ - bufferSize += 2; /* s16 primitive->linkQuality.unifiRssi */ - bufferSize += 2; /* s16 primitive->linkQuality.unifiSnr */ - return bufferSize; -} - - -u8* CsrWifiSmeLinkQualityGetCfmSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiSmeLinkQualityGetCfm *primitive = (CsrWifiSmeLinkQualityGetCfm *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag); - CsrUint16Ser(ptr, len, (u16) primitive->status); - CsrUint16Ser(ptr, len, (u16) primitive->linkQuality.unifiRssi); - CsrUint16Ser(ptr, len, (u16) primitive->linkQuality.unifiSnr); - return(ptr); -} - - -void* CsrWifiSmeLinkQualityGetCfmDes(u8 *buffer, size_t length) -{ - CsrWifiSmeLinkQualityGetCfm *primitive = kmalloc(sizeof(CsrWifiSmeLinkQualityGetCfm), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset); - CsrUint16Des((u16 *) &primitive->status, buffer, &offset); - CsrUint16Des((u16 *) &primitive->linkQuality.unifiRssi, buffer, &offset); - CsrUint16Des((u16 *) &primitive->linkQuality.unifiSnr, buffer, &offset); - - return primitive; -} - - -size_t CsrWifiSmeMediaStatusIndSizeof(void *msg) -{ - CsrWifiSmeMediaStatusInd *primitive = (CsrWifiSmeMediaStatusInd *) msg; - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 99) */ - bufferSize += 2; /* u16 primitive->interfaceTag */ - bufferSize += 1; /* CsrWifiSmeMediaStatus primitive->mediaStatus */ - bufferSize += 32; /* u8 primitive->connectionInfo.ssid.ssid[32] */ - bufferSize += 1; /* u8 primitive->connectionInfo.ssid.length */ - bufferSize += 6; /* u8 primitive->connectionInfo.bssid.a[6] */ - bufferSize += 1; /* CsrWifiSme80211NetworkType primitive->connectionInfo.networkType80211 */ - bufferSize += 1; /* u8 primitive->connectionInfo.channelNumber */ - bufferSize += 2; /* u16 primitive->connectionInfo.channelFrequency */ - bufferSize += 2; /* CsrWifiSmeAuthMode primitive->connectionInfo.authMode */ - bufferSize += 2; /* CsrWifiSmeEncryption primitive->connectionInfo.pairwiseCipher */ - bufferSize += 2; /* CsrWifiSmeEncryption primitive->connectionInfo.groupCipher */ - bufferSize += 1; /* CsrWifiSmeRadioIF primitive->connectionInfo.ifIndex */ - bufferSize += 2; /* u16 primitive->connectionInfo.atimWindowTu */ - bufferSize += 2; /* u16 primitive->connectionInfo.beaconPeriodTu */ - bufferSize += 1; /* u8 primitive->connectionInfo.reassociation */ - bufferSize += 2; /* u16 primitive->connectionInfo.beaconFrameLength */ - bufferSize += primitive->connectionInfo.beaconFrameLength; /* u8 primitive->connectionInfo.beaconFrame */ - bufferSize += 2; /* u16 primitive->connectionInfo.associationReqFrameLength */ - bufferSize += primitive->connectionInfo.associationReqFrameLength; /* u8 primitive->connectionInfo.associationReqFrame */ - bufferSize += 2; /* u16 primitive->connectionInfo.associationRspFrameLength */ - bufferSize += primitive->connectionInfo.associationRspFrameLength; /* u8 primitive->connectionInfo.associationRspFrame */ - bufferSize += 2; /* u16 primitive->connectionInfo.assocScanInfoElementsLength */ - bufferSize += primitive->connectionInfo.assocScanInfoElementsLength; /* u8 primitive->connectionInfo.assocScanInfoElements */ - bufferSize += 2; /* u16 primitive->connectionInfo.assocReqCapabilities */ - bufferSize += 2; /* u16 primitive->connectionInfo.assocReqListenIntervalTu */ - bufferSize += 6; /* u8 primitive->connectionInfo.assocReqApAddress.a[6] */ - bufferSize += 2; /* u16 primitive->connectionInfo.assocReqInfoElementsLength */ - bufferSize += primitive->connectionInfo.assocReqInfoElementsLength; /* u8 primitive->connectionInfo.assocReqInfoElements */ - bufferSize += 2; /* CsrWifiSmeIEEE80211Result primitive->connectionInfo.assocRspResult */ - bufferSize += 2; /* u16 primitive->connectionInfo.assocRspCapabilityInfo */ - bufferSize += 2; /* u16 primitive->connectionInfo.assocRspAssociationId */ - bufferSize += 2; /* u16 primitive->connectionInfo.assocRspInfoElementsLength */ - bufferSize += primitive->connectionInfo.assocRspInfoElementsLength; /* u8 primitive->connectionInfo.assocRspInfoElements */ - bufferSize += 2; /* CsrWifiSmeIEEE80211Reason primitive->disassocReason */ - bufferSize += 2; /* CsrWifiSmeIEEE80211Reason primitive->deauthReason */ - return bufferSize; -} - - -u8* CsrWifiSmeMediaStatusIndSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiSmeMediaStatusInd *primitive = (CsrWifiSmeMediaStatusInd *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag); - CsrUint8Ser(ptr, len, (u8) primitive->mediaStatus); - CsrMemCpySer(ptr, len, (const void *) primitive->connectionInfo.ssid.ssid, ((u16) (32))); - CsrUint8Ser(ptr, len, (u8) primitive->connectionInfo.ssid.length); - CsrMemCpySer(ptr, len, (const void *) primitive->connectionInfo.bssid.a, ((u16) (6))); - CsrUint8Ser(ptr, len, (u8) primitive->connectionInfo.networkType80211); - CsrUint8Ser(ptr, len, (u8) primitive->connectionInfo.channelNumber); - CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.channelFrequency); - CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.authMode); - CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.pairwiseCipher); - CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.groupCipher); - CsrUint8Ser(ptr, len, (u8) primitive->connectionInfo.ifIndex); - CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.atimWindowTu); - CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.beaconPeriodTu); - CsrUint8Ser(ptr, len, (u8) primitive->connectionInfo.reassociation); - CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.beaconFrameLength); - if (primitive->connectionInfo.beaconFrameLength) - { - CsrMemCpySer(ptr, len, (const void *) primitive->connectionInfo.beaconFrame, ((u16) (primitive->connectionInfo.beaconFrameLength))); - } - CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.associationReqFrameLength); - if (primitive->connectionInfo.associationReqFrameLength) - { - CsrMemCpySer(ptr, len, (const void *) primitive->connectionInfo.associationReqFrame, ((u16) (primitive->connectionInfo.associationReqFrameLength))); - } - CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.associationRspFrameLength); - if (primitive->connectionInfo.associationRspFrameLength) - { - CsrMemCpySer(ptr, len, (const void *) primitive->connectionInfo.associationRspFrame, ((u16) (primitive->connectionInfo.associationRspFrameLength))); - } - CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.assocScanInfoElementsLength); - if (primitive->connectionInfo.assocScanInfoElementsLength) - { - CsrMemCpySer(ptr, len, (const void *) primitive->connectionInfo.assocScanInfoElements, ((u16) (primitive->connectionInfo.assocScanInfoElementsLength))); - } - CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.assocReqCapabilities); - CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.assocReqListenIntervalTu); - CsrMemCpySer(ptr, len, (const void *) primitive->connectionInfo.assocReqApAddress.a, ((u16) (6))); - CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.assocReqInfoElementsLength); - if (primitive->connectionInfo.assocReqInfoElementsLength) - { - CsrMemCpySer(ptr, len, (const void *) primitive->connectionInfo.assocReqInfoElements, ((u16) (primitive->connectionInfo.assocReqInfoElementsLength))); - } - CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.assocRspResult); - CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.assocRspCapabilityInfo); - CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.assocRspAssociationId); - CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.assocRspInfoElementsLength); - if (primitive->connectionInfo.assocRspInfoElementsLength) - { - CsrMemCpySer(ptr, len, (const void *) primitive->connectionInfo.assocRspInfoElements, ((u16) (primitive->connectionInfo.assocRspInfoElementsLength))); - } - CsrUint16Ser(ptr, len, (u16) primitive->disassocReason); - CsrUint16Ser(ptr, len, (u16) primitive->deauthReason); - return(ptr); -} - - -void* CsrWifiSmeMediaStatusIndDes(u8 *buffer, size_t length) -{ - CsrWifiSmeMediaStatusInd *primitive = kmalloc(sizeof(CsrWifiSmeMediaStatusInd), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset); - CsrUint8Des((u8 *) &primitive->mediaStatus, buffer, &offset); - CsrMemCpyDes(primitive->connectionInfo.ssid.ssid, buffer, &offset, ((u16) (32))); - CsrUint8Des((u8 *) &primitive->connectionInfo.ssid.length, buffer, &offset); - CsrMemCpyDes(primitive->connectionInfo.bssid.a, buffer, &offset, ((u16) (6))); - CsrUint8Des((u8 *) &primitive->connectionInfo.networkType80211, buffer, &offset); - CsrUint8Des((u8 *) &primitive->connectionInfo.channelNumber, buffer, &offset); - CsrUint16Des((u16 *) &primitive->connectionInfo.channelFrequency, buffer, &offset); - CsrUint16Des((u16 *) &primitive->connectionInfo.authMode, buffer, &offset); - CsrUint16Des((u16 *) &primitive->connectionInfo.pairwiseCipher, buffer, &offset); - CsrUint16Des((u16 *) &primitive->connectionInfo.groupCipher, buffer, &offset); - CsrUint8Des((u8 *) &primitive->connectionInfo.ifIndex, buffer, &offset); - CsrUint16Des((u16 *) &primitive->connectionInfo.atimWindowTu, buffer, &offset); - CsrUint16Des((u16 *) &primitive->connectionInfo.beaconPeriodTu, buffer, &offset); - CsrUint8Des((u8 *) &primitive->connectionInfo.reassociation, buffer, &offset); - CsrUint16Des((u16 *) &primitive->connectionInfo.beaconFrameLength, buffer, &offset); - if (primitive->connectionInfo.beaconFrameLength) - { - primitive->connectionInfo.beaconFrame = kmalloc(primitive->connectionInfo.beaconFrameLength, GFP_KERNEL); - CsrMemCpyDes(primitive->connectionInfo.beaconFrame, buffer, &offset, ((u16) (primitive->connectionInfo.beaconFrameLength))); - } - else - { - primitive->connectionInfo.beaconFrame = NULL; - } - CsrUint16Des((u16 *) &primitive->connectionInfo.associationReqFrameLength, buffer, &offset); - if (primitive->connectionInfo.associationReqFrameLength) - { - primitive->connectionInfo.associationReqFrame = kmalloc(primitive->connectionInfo.associationReqFrameLength, GFP_KERNEL); - CsrMemCpyDes(primitive->connectionInfo.associationReqFrame, buffer, &offset, ((u16) (primitive->connectionInfo.associationReqFrameLength))); - } - else - { - primitive->connectionInfo.associationReqFrame = NULL; - } - CsrUint16Des((u16 *) &primitive->connectionInfo.associationRspFrameLength, buffer, &offset); - if (primitive->connectionInfo.associationRspFrameLength) - { - primitive->connectionInfo.associationRspFrame = kmalloc(primitive->connectionInfo.associationRspFrameLength, GFP_KERNEL); - CsrMemCpyDes(primitive->connectionInfo.associationRspFrame, buffer, &offset, ((u16) (primitive->connectionInfo.associationRspFrameLength))); - } - else - { - primitive->connectionInfo.associationRspFrame = NULL; - } - CsrUint16Des((u16 *) &primitive->connectionInfo.assocScanInfoElementsLength, buffer, &offset); - if (primitive->connectionInfo.assocScanInfoElementsLength) - { - primitive->connectionInfo.assocScanInfoElements = kmalloc(primitive->connectionInfo.assocScanInfoElementsLength, GFP_KERNEL); - CsrMemCpyDes(primitive->connectionInfo.assocScanInfoElements, buffer, &offset, ((u16) (primitive->connectionInfo.assocScanInfoElementsLength))); - } - else - { - primitive->connectionInfo.assocScanInfoElements = NULL; - } - CsrUint16Des((u16 *) &primitive->connectionInfo.assocReqCapabilities, buffer, &offset); - CsrUint16Des((u16 *) &primitive->connectionInfo.assocReqListenIntervalTu, buffer, &offset); - CsrMemCpyDes(primitive->connectionInfo.assocReqApAddress.a, buffer, &offset, ((u16) (6))); - CsrUint16Des((u16 *) &primitive->connectionInfo.assocReqInfoElementsLength, buffer, &offset); - if (primitive->connectionInfo.assocReqInfoElementsLength) - { - primitive->connectionInfo.assocReqInfoElements = kmalloc(primitive->connectionInfo.assocReqInfoElementsLength, GFP_KERNEL); - CsrMemCpyDes(primitive->connectionInfo.assocReqInfoElements, buffer, &offset, ((u16) (primitive->connectionInfo.assocReqInfoElementsLength))); - } - else - { - primitive->connectionInfo.assocReqInfoElements = NULL; - } - CsrUint16Des((u16 *) &primitive->connectionInfo.assocRspResult, buffer, &offset); - CsrUint16Des((u16 *) &primitive->connectionInfo.assocRspCapabilityInfo, buffer, &offset); - CsrUint16Des((u16 *) &primitive->connectionInfo.assocRspAssociationId, buffer, &offset); - CsrUint16Des((u16 *) &primitive->connectionInfo.assocRspInfoElementsLength, buffer, &offset); - if (primitive->connectionInfo.assocRspInfoElementsLength) - { - primitive->connectionInfo.assocRspInfoElements = kmalloc(primitive->connectionInfo.assocRspInfoElementsLength, GFP_KERNEL); - CsrMemCpyDes(primitive->connectionInfo.assocRspInfoElements, buffer, &offset, ((u16) (primitive->connectionInfo.assocRspInfoElementsLength))); - } - else - { - primitive->connectionInfo.assocRspInfoElements = NULL; - } - CsrUint16Des((u16 *) &primitive->disassocReason, buffer, &offset); - CsrUint16Des((u16 *) &primitive->deauthReason, buffer, &offset); - - return primitive; -} - - -void CsrWifiSmeMediaStatusIndSerFree(void *voidPrimitivePointer) -{ - CsrWifiSmeMediaStatusInd *primitive = (CsrWifiSmeMediaStatusInd *) voidPrimitivePointer; - kfree(primitive->connectionInfo.beaconFrame); - kfree(primitive->connectionInfo.associationReqFrame); - kfree(primitive->connectionInfo.associationRspFrame); - kfree(primitive->connectionInfo.assocScanInfoElements); - kfree(primitive->connectionInfo.assocReqInfoElements); - kfree(primitive->connectionInfo.assocRspInfoElements); - kfree(primitive); -} - - -size_t CsrWifiSmeMibConfigGetCfmSizeof(void *msg) -{ - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 13) */ - bufferSize += 2; /* CsrResult primitive->status */ - bufferSize += 1; /* u8 primitive->mibConfig.unifiFixMaxTxDataRate */ - bufferSize += 1; /* u8 primitive->mibConfig.unifiFixTxDataRate */ - bufferSize += 2; /* u16 primitive->mibConfig.dot11RtsThreshold */ - bufferSize += 2; /* u16 primitive->mibConfig.dot11FragmentationThreshold */ - bufferSize += 2; /* u16 primitive->mibConfig.dot11CurrentTxPowerLevel */ - return bufferSize; -} - - -u8* CsrWifiSmeMibConfigGetCfmSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiSmeMibConfigGetCfm *primitive = (CsrWifiSmeMibConfigGetCfm *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->status); - CsrUint8Ser(ptr, len, (u8) primitive->mibConfig.unifiFixMaxTxDataRate); - CsrUint8Ser(ptr, len, (u8) primitive->mibConfig.unifiFixTxDataRate); - CsrUint16Ser(ptr, len, (u16) primitive->mibConfig.dot11RtsThreshold); - CsrUint16Ser(ptr, len, (u16) primitive->mibConfig.dot11FragmentationThreshold); - CsrUint16Ser(ptr, len, (u16) primitive->mibConfig.dot11CurrentTxPowerLevel); - return(ptr); -} - - -void* CsrWifiSmeMibConfigGetCfmDes(u8 *buffer, size_t length) -{ - CsrWifiSmeMibConfigGetCfm *primitive = kmalloc(sizeof(CsrWifiSmeMibConfigGetCfm), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->status, buffer, &offset); - CsrUint8Des((u8 *) &primitive->mibConfig.unifiFixMaxTxDataRate, buffer, &offset); - CsrUint8Des((u8 *) &primitive->mibConfig.unifiFixTxDataRate, buffer, &offset); - CsrUint16Des((u16 *) &primitive->mibConfig.dot11RtsThreshold, buffer, &offset); - CsrUint16Des((u16 *) &primitive->mibConfig.dot11FragmentationThreshold, buffer, &offset); - CsrUint16Des((u16 *) &primitive->mibConfig.dot11CurrentTxPowerLevel, buffer, &offset); - - return primitive; -} - - -size_t CsrWifiSmeMibGetCfmSizeof(void *msg) -{ - CsrWifiSmeMibGetCfm *primitive = (CsrWifiSmeMibGetCfm *) msg; - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 8) */ - bufferSize += 2; /* CsrResult primitive->status */ - bufferSize += 2; /* u16 primitive->mibAttributeLength */ - bufferSize += primitive->mibAttributeLength; /* u8 primitive->mibAttribute */ - return bufferSize; -} - - -u8* CsrWifiSmeMibGetCfmSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiSmeMibGetCfm *primitive = (CsrWifiSmeMibGetCfm *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->status); - CsrUint16Ser(ptr, len, (u16) primitive->mibAttributeLength); - if (primitive->mibAttributeLength) - { - CsrMemCpySer(ptr, len, (const void *) primitive->mibAttribute, ((u16) (primitive->mibAttributeLength))); - } - return(ptr); -} - - -void* CsrWifiSmeMibGetCfmDes(u8 *buffer, size_t length) -{ - CsrWifiSmeMibGetCfm *primitive = kmalloc(sizeof(CsrWifiSmeMibGetCfm), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->status, buffer, &offset); - CsrUint16Des((u16 *) &primitive->mibAttributeLength, buffer, &offset); - if (primitive->mibAttributeLength) - { - primitive->mibAttribute = kmalloc(primitive->mibAttributeLength, GFP_KERNEL); - CsrMemCpyDes(primitive->mibAttribute, buffer, &offset, ((u16) (primitive->mibAttributeLength))); - } - else - { - primitive->mibAttribute = NULL; - } - - return primitive; -} - - -void CsrWifiSmeMibGetCfmSerFree(void *voidPrimitivePointer) -{ - CsrWifiSmeMibGetCfm *primitive = (CsrWifiSmeMibGetCfm *) voidPrimitivePointer; - kfree(primitive->mibAttribute); - kfree(primitive); -} - - -size_t CsrWifiSmeMibGetNextCfmSizeof(void *msg) -{ - CsrWifiSmeMibGetNextCfm *primitive = (CsrWifiSmeMibGetNextCfm *) msg; - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 8) */ - bufferSize += 2; /* CsrResult primitive->status */ - bufferSize += 2; /* u16 primitive->mibAttributeLength */ - bufferSize += primitive->mibAttributeLength; /* u8 primitive->mibAttribute */ - return bufferSize; -} - - -u8* CsrWifiSmeMibGetNextCfmSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiSmeMibGetNextCfm *primitive = (CsrWifiSmeMibGetNextCfm *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->status); - CsrUint16Ser(ptr, len, (u16) primitive->mibAttributeLength); - if (primitive->mibAttributeLength) - { - CsrMemCpySer(ptr, len, (const void *) primitive->mibAttribute, ((u16) (primitive->mibAttributeLength))); - } - return(ptr); -} - - -void* CsrWifiSmeMibGetNextCfmDes(u8 *buffer, size_t length) -{ - CsrWifiSmeMibGetNextCfm *primitive = kmalloc(sizeof(CsrWifiSmeMibGetNextCfm), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->status, buffer, &offset); - CsrUint16Des((u16 *) &primitive->mibAttributeLength, buffer, &offset); - if (primitive->mibAttributeLength) - { - primitive->mibAttribute = kmalloc(primitive->mibAttributeLength, GFP_KERNEL); - CsrMemCpyDes(primitive->mibAttribute, buffer, &offset, ((u16) (primitive->mibAttributeLength))); - } - else - { - primitive->mibAttribute = NULL; - } - - return primitive; -} - - -void CsrWifiSmeMibGetNextCfmSerFree(void *voidPrimitivePointer) -{ - CsrWifiSmeMibGetNextCfm *primitive = (CsrWifiSmeMibGetNextCfm *) voidPrimitivePointer; - kfree(primitive->mibAttribute); - kfree(primitive); -} - - -size_t CsrWifiSmeMicFailureIndSizeof(void *msg) -{ - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 15) */ - bufferSize += 2; /* u16 primitive->interfaceTag */ - bufferSize += 1; /* u8 primitive->secondFailure */ - bufferSize += 2; /* u16 primitive->count */ - bufferSize += 6; /* u8 primitive->address.a[6] */ - bufferSize += 1; /* CsrWifiSmeKeyType primitive->keyType */ - return bufferSize; -} - - -u8* CsrWifiSmeMicFailureIndSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiSmeMicFailureInd *primitive = (CsrWifiSmeMicFailureInd *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag); - CsrUint8Ser(ptr, len, (u8) primitive->secondFailure); - CsrUint16Ser(ptr, len, (u16) primitive->count); - CsrMemCpySer(ptr, len, (const void *) primitive->address.a, ((u16) (6))); - CsrUint8Ser(ptr, len, (u8) primitive->keyType); - return(ptr); -} - - -void* CsrWifiSmeMicFailureIndDes(u8 *buffer, size_t length) -{ - CsrWifiSmeMicFailureInd *primitive = kmalloc(sizeof(CsrWifiSmeMicFailureInd), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset); - CsrUint8Des((u8 *) &primitive->secondFailure, buffer, &offset); - CsrUint16Des((u16 *) &primitive->count, buffer, &offset); - CsrMemCpyDes(primitive->address.a, buffer, &offset, ((u16) (6))); - CsrUint8Des((u8 *) &primitive->keyType, buffer, &offset); - - return primitive; -} - - -size_t CsrWifiSmeMulticastAddressCfmSizeof(void *msg) -{ - CsrWifiSmeMulticastAddressCfm *primitive = (CsrWifiSmeMulticastAddressCfm *) msg; - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 15) */ - bufferSize += 2; /* u16 primitive->interfaceTag */ - bufferSize += 2; /* CsrResult primitive->status */ - bufferSize += 1; /* CsrWifiSmeListAction primitive->action */ - bufferSize += 1; /* u8 primitive->getAddressesCount */ - { - u16 i1; - for (i1 = 0; i1 < primitive->getAddressesCount; i1++) - { - bufferSize += 6; /* u8 primitive->getAddresses[i1].a[6] */ - } - } - return bufferSize; -} - - -u8* CsrWifiSmeMulticastAddressCfmSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiSmeMulticastAddressCfm *primitive = (CsrWifiSmeMulticastAddressCfm *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag); - CsrUint16Ser(ptr, len, (u16) primitive->status); - CsrUint8Ser(ptr, len, (u8) primitive->action); - CsrUint8Ser(ptr, len, (u8) primitive->getAddressesCount); - { - u16 i1; - for (i1 = 0; i1 < primitive->getAddressesCount; i1++) - { - CsrMemCpySer(ptr, len, (const void *) primitive->getAddresses[i1].a, ((u16) (6))); - } - } - return(ptr); -} - - -void* CsrWifiSmeMulticastAddressCfmDes(u8 *buffer, size_t length) -{ - CsrWifiSmeMulticastAddressCfm *primitive = kmalloc(sizeof(CsrWifiSmeMulticastAddressCfm), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset); - CsrUint16Des((u16 *) &primitive->status, buffer, &offset); - CsrUint8Des((u8 *) &primitive->action, buffer, &offset); - CsrUint8Des((u8 *) &primitive->getAddressesCount, buffer, &offset); - primitive->getAddresses = NULL; - if (primitive->getAddressesCount) - { - primitive->getAddresses = kmalloc(sizeof(CsrWifiMacAddress) * primitive->getAddressesCount, GFP_KERNEL); - } - { - u16 i1; - for (i1 = 0; i1 < primitive->getAddressesCount; i1++) - { - CsrMemCpyDes(primitive->getAddresses[i1].a, buffer, &offset, ((u16) (6))); - } - } - - return primitive; -} - - -void CsrWifiSmeMulticastAddressCfmSerFree(void *voidPrimitivePointer) -{ - CsrWifiSmeMulticastAddressCfm *primitive = (CsrWifiSmeMulticastAddressCfm *) voidPrimitivePointer; - kfree(primitive->getAddresses); - kfree(primitive); -} - - -size_t CsrWifiSmePacketFilterSetCfmSizeof(void *msg) -{ - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 7) */ - bufferSize += 2; /* u16 primitive->interfaceTag */ - bufferSize += 2; /* CsrResult primitive->status */ - return bufferSize; -} - - -u8* CsrWifiSmePacketFilterSetCfmSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiSmePacketFilterSetCfm *primitive = (CsrWifiSmePacketFilterSetCfm *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag); - CsrUint16Ser(ptr, len, (u16) primitive->status); - return(ptr); -} - - -void* CsrWifiSmePacketFilterSetCfmDes(u8 *buffer, size_t length) -{ - CsrWifiSmePacketFilterSetCfm *primitive = kmalloc(sizeof(CsrWifiSmePacketFilterSetCfm), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset); - CsrUint16Des((u16 *) &primitive->status, buffer, &offset); - - return primitive; -} - - -size_t CsrWifiSmePermanentMacAddressGetCfmSizeof(void *msg) -{ - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 11) */ - bufferSize += 2; /* CsrResult primitive->status */ - bufferSize += 6; /* u8 primitive->permanentMacAddress.a[6] */ - return bufferSize; -} - - -u8* CsrWifiSmePermanentMacAddressGetCfmSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiSmePermanentMacAddressGetCfm *primitive = (CsrWifiSmePermanentMacAddressGetCfm *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->status); - CsrMemCpySer(ptr, len, (const void *) primitive->permanentMacAddress.a, ((u16) (6))); - return(ptr); -} - - -void* CsrWifiSmePermanentMacAddressGetCfmDes(u8 *buffer, size_t length) -{ - CsrWifiSmePermanentMacAddressGetCfm *primitive = kmalloc(sizeof(CsrWifiSmePermanentMacAddressGetCfm), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->status, buffer, &offset); - CsrMemCpyDes(primitive->permanentMacAddress.a, buffer, &offset, ((u16) (6))); - - return primitive; -} - - -size_t CsrWifiSmePmkidCandidateListIndSizeof(void *msg) -{ - CsrWifiSmePmkidCandidateListInd *primitive = (CsrWifiSmePmkidCandidateListInd *) msg; - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 13) */ - bufferSize += 2; /* u16 primitive->interfaceTag */ - bufferSize += 1; /* u8 primitive->pmkidCandidatesCount */ - { - u16 i1; - for (i1 = 0; i1 < primitive->pmkidCandidatesCount; i1++) - { - bufferSize += 6; /* u8 primitive->pmkidCandidates[i1].bssid.a[6] */ - bufferSize += 1; /* u8 primitive->pmkidCandidates[i1].preAuthAllowed */ - } - } - return bufferSize; -} - - -u8* CsrWifiSmePmkidCandidateListIndSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiSmePmkidCandidateListInd *primitive = (CsrWifiSmePmkidCandidateListInd *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag); - CsrUint8Ser(ptr, len, (u8) primitive->pmkidCandidatesCount); - { - u16 i1; - for (i1 = 0; i1 < primitive->pmkidCandidatesCount; i1++) - { - CsrMemCpySer(ptr, len, (const void *) primitive->pmkidCandidates[i1].bssid.a, ((u16) (6))); - CsrUint8Ser(ptr, len, (u8) primitive->pmkidCandidates[i1].preAuthAllowed); - } - } - return(ptr); -} - - -void* CsrWifiSmePmkidCandidateListIndDes(u8 *buffer, size_t length) -{ - CsrWifiSmePmkidCandidateListInd *primitive = kmalloc(sizeof(CsrWifiSmePmkidCandidateListInd), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset); - CsrUint8Des((u8 *) &primitive->pmkidCandidatesCount, buffer, &offset); - primitive->pmkidCandidates = NULL; - if (primitive->pmkidCandidatesCount) - { - primitive->pmkidCandidates = kmalloc(sizeof(CsrWifiSmePmkidCandidate) * primitive->pmkidCandidatesCount, GFP_KERNEL); - } - { - u16 i1; - for (i1 = 0; i1 < primitive->pmkidCandidatesCount; i1++) - { - CsrMemCpyDes(primitive->pmkidCandidates[i1].bssid.a, buffer, &offset, ((u16) (6))); - CsrUint8Des((u8 *) &primitive->pmkidCandidates[i1].preAuthAllowed, buffer, &offset); - } - } - - return primitive; -} - - -void CsrWifiSmePmkidCandidateListIndSerFree(void *voidPrimitivePointer) -{ - CsrWifiSmePmkidCandidateListInd *primitive = (CsrWifiSmePmkidCandidateListInd *) voidPrimitivePointer; - kfree(primitive->pmkidCandidates); - kfree(primitive); -} - - -size_t CsrWifiSmePmkidCfmSizeof(void *msg) -{ - CsrWifiSmePmkidCfm *primitive = (CsrWifiSmePmkidCfm *) msg; - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 31) */ - bufferSize += 2; /* u16 primitive->interfaceTag */ - bufferSize += 2; /* CsrResult primitive->status */ - bufferSize += 1; /* CsrWifiSmeListAction primitive->action */ - bufferSize += 1; /* u8 primitive->getPmkidsCount */ - { - u16 i1; - for (i1 = 0; i1 < primitive->getPmkidsCount; i1++) - { - bufferSize += 6; /* u8 primitive->getPmkids[i1].bssid.a[6] */ - bufferSize += 16; /* u8 primitive->getPmkids[i1].pmkid[16] */ - } - } - return bufferSize; -} - - -u8* CsrWifiSmePmkidCfmSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiSmePmkidCfm *primitive = (CsrWifiSmePmkidCfm *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag); - CsrUint16Ser(ptr, len, (u16) primitive->status); - CsrUint8Ser(ptr, len, (u8) primitive->action); - CsrUint8Ser(ptr, len, (u8) primitive->getPmkidsCount); - { - u16 i1; - for (i1 = 0; i1 < primitive->getPmkidsCount; i1++) - { - CsrMemCpySer(ptr, len, (const void *) primitive->getPmkids[i1].bssid.a, ((u16) (6))); - CsrMemCpySer(ptr, len, (const void *) primitive->getPmkids[i1].pmkid, ((u16) (16))); - } - } - return(ptr); -} - - -void* CsrWifiSmePmkidCfmDes(u8 *buffer, size_t length) -{ - CsrWifiSmePmkidCfm *primitive = kmalloc(sizeof(CsrWifiSmePmkidCfm), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset); - CsrUint16Des((u16 *) &primitive->status, buffer, &offset); - CsrUint8Des((u8 *) &primitive->action, buffer, &offset); - CsrUint8Des((u8 *) &primitive->getPmkidsCount, buffer, &offset); - primitive->getPmkids = NULL; - if (primitive->getPmkidsCount) - { - primitive->getPmkids = kmalloc(sizeof(CsrWifiSmePmkid) * primitive->getPmkidsCount, GFP_KERNEL); - } - { - u16 i1; - for (i1 = 0; i1 < primitive->getPmkidsCount; i1++) - { - CsrMemCpyDes(primitive->getPmkids[i1].bssid.a, buffer, &offset, ((u16) (6))); - CsrMemCpyDes(primitive->getPmkids[i1].pmkid, buffer, &offset, ((u16) (16))); - } - } - - return primitive; -} - - -void CsrWifiSmePmkidCfmSerFree(void *voidPrimitivePointer) -{ - CsrWifiSmePmkidCfm *primitive = (CsrWifiSmePmkidCfm *) voidPrimitivePointer; - kfree(primitive->getPmkids); - kfree(primitive); -} - - -size_t CsrWifiSmePowerConfigGetCfmSizeof(void *msg) -{ - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 13) */ - bufferSize += 2; /* CsrResult primitive->status */ - bufferSize += 1; /* CsrWifiSmePowerSaveLevel primitive->powerConfig.powerSaveLevel */ - bufferSize += 2; /* u16 primitive->powerConfig.listenIntervalTu */ - bufferSize += 1; /* u8 primitive->powerConfig.rxDtims */ - bufferSize += 1; /* CsrWifiSmeD3AutoScanMode primitive->powerConfig.d3AutoScanMode */ - bufferSize += 1; /* u8 primitive->powerConfig.clientTrafficWindow */ - bufferSize += 1; /* u8 primitive->powerConfig.opportunisticPowerSave */ - bufferSize += 1; /* u8 primitive->powerConfig.noticeOfAbsence */ - return bufferSize; -} - - -u8* CsrWifiSmePowerConfigGetCfmSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiSmePowerConfigGetCfm *primitive = (CsrWifiSmePowerConfigGetCfm *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->status); - CsrUint8Ser(ptr, len, (u8) primitive->powerConfig.powerSaveLevel); - CsrUint16Ser(ptr, len, (u16) primitive->powerConfig.listenIntervalTu); - CsrUint8Ser(ptr, len, (u8) primitive->powerConfig.rxDtims); - CsrUint8Ser(ptr, len, (u8) primitive->powerConfig.d3AutoScanMode); - CsrUint8Ser(ptr, len, (u8) primitive->powerConfig.clientTrafficWindow); - CsrUint8Ser(ptr, len, (u8) primitive->powerConfig.opportunisticPowerSave); - CsrUint8Ser(ptr, len, (u8) primitive->powerConfig.noticeOfAbsence); - return(ptr); -} - - -void* CsrWifiSmePowerConfigGetCfmDes(u8 *buffer, size_t length) -{ - CsrWifiSmePowerConfigGetCfm *primitive = kmalloc(sizeof(CsrWifiSmePowerConfigGetCfm), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->status, buffer, &offset); - CsrUint8Des((u8 *) &primitive->powerConfig.powerSaveLevel, buffer, &offset); - CsrUint16Des((u16 *) &primitive->powerConfig.listenIntervalTu, buffer, &offset); - CsrUint8Des((u8 *) &primitive->powerConfig.rxDtims, buffer, &offset); - CsrUint8Des((u8 *) &primitive->powerConfig.d3AutoScanMode, buffer, &offset); - CsrUint8Des((u8 *) &primitive->powerConfig.clientTrafficWindow, buffer, &offset); - CsrUint8Des((u8 *) &primitive->powerConfig.opportunisticPowerSave, buffer, &offset); - CsrUint8Des((u8 *) &primitive->powerConfig.noticeOfAbsence, buffer, &offset); - - return primitive; -} - - -size_t CsrWifiSmeRegulatoryDomainInfoGetCfmSizeof(void *msg) -{ - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 10) */ - bufferSize += 2; /* CsrResult primitive->status */ - bufferSize += 1; /* u8 primitive->regDomInfo.dot11MultiDomainCapabilityImplemented */ - bufferSize += 1; /* u8 primitive->regDomInfo.dot11MultiDomainCapabilityEnabled */ - bufferSize += 1; /* CsrWifiSmeRegulatoryDomain primitive->regDomInfo.currentRegulatoryDomain */ - bufferSize += 2; /* u8 primitive->regDomInfo.currentCountryCode[2] */ - return bufferSize; -} - - -u8* CsrWifiSmeRegulatoryDomainInfoGetCfmSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiSmeRegulatoryDomainInfoGetCfm *primitive = (CsrWifiSmeRegulatoryDomainInfoGetCfm *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->status); - CsrUint8Ser(ptr, len, (u8) primitive->regDomInfo.dot11MultiDomainCapabilityImplemented); - CsrUint8Ser(ptr, len, (u8) primitive->regDomInfo.dot11MultiDomainCapabilityEnabled); - CsrUint8Ser(ptr, len, (u8) primitive->regDomInfo.currentRegulatoryDomain); - CsrMemCpySer(ptr, len, (const void *) primitive->regDomInfo.currentCountryCode, ((u16) (2))); - return(ptr); -} - - -void* CsrWifiSmeRegulatoryDomainInfoGetCfmDes(u8 *buffer, size_t length) -{ - CsrWifiSmeRegulatoryDomainInfoGetCfm *primitive = kmalloc(sizeof(CsrWifiSmeRegulatoryDomainInfoGetCfm), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->status, buffer, &offset); - CsrUint8Des((u8 *) &primitive->regDomInfo.dot11MultiDomainCapabilityImplemented, buffer, &offset); - CsrUint8Des((u8 *) &primitive->regDomInfo.dot11MultiDomainCapabilityEnabled, buffer, &offset); - CsrUint8Des((u8 *) &primitive->regDomInfo.currentRegulatoryDomain, buffer, &offset); - CsrMemCpyDes(primitive->regDomInfo.currentCountryCode, buffer, &offset, ((u16) (2))); - - return primitive; -} - - -size_t CsrWifiSmeRoamCompleteIndSizeof(void *msg) -{ - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 7) */ - bufferSize += 2; /* u16 primitive->interfaceTag */ - bufferSize += 2; /* CsrResult primitive->status */ - return bufferSize; -} - - -u8* CsrWifiSmeRoamCompleteIndSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiSmeRoamCompleteInd *primitive = (CsrWifiSmeRoamCompleteInd *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag); - CsrUint16Ser(ptr, len, (u16) primitive->status); - return(ptr); -} - - -void* CsrWifiSmeRoamCompleteIndDes(u8 *buffer, size_t length) -{ - CsrWifiSmeRoamCompleteInd *primitive = kmalloc(sizeof(CsrWifiSmeRoamCompleteInd), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset); - CsrUint16Des((u16 *) &primitive->status, buffer, &offset); - - return primitive; -} - - -size_t CsrWifiSmeRoamStartIndSizeof(void *msg) -{ - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 8) */ - bufferSize += 2; /* u16 primitive->interfaceTag */ - bufferSize += 1; /* CsrWifiSmeRoamReason primitive->roamReason */ - bufferSize += 2; /* CsrWifiSmeIEEE80211Reason primitive->reason80211 */ - return bufferSize; -} - - -u8* CsrWifiSmeRoamStartIndSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiSmeRoamStartInd *primitive = (CsrWifiSmeRoamStartInd *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag); - CsrUint8Ser(ptr, len, (u8) primitive->roamReason); - CsrUint16Ser(ptr, len, (u16) primitive->reason80211); - return(ptr); -} - - -void* CsrWifiSmeRoamStartIndDes(u8 *buffer, size_t length) -{ - CsrWifiSmeRoamStartInd *primitive = kmalloc(sizeof(CsrWifiSmeRoamStartInd), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset); - CsrUint8Des((u8 *) &primitive->roamReason, buffer, &offset); - CsrUint16Des((u16 *) &primitive->reason80211, buffer, &offset); - - return primitive; -} - - -size_t CsrWifiSmeRoamingConfigGetCfmSizeof(void *msg) -{ - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 72) */ - bufferSize += 2; /* u16 primitive->interfaceTag */ - bufferSize += 2; /* CsrResult primitive->status */ - { - u16 i2; - for (i2 = 0; i2 < 3; i2++) - { - bufferSize += 2; /* s16 primitive->roamingConfig.roamingBands[i2].rssiHighThreshold */ - bufferSize += 2; /* s16 primitive->roamingConfig.roamingBands[i2].rssiLowThreshold */ - bufferSize += 2; /* s16 primitive->roamingConfig.roamingBands[i2].snrHighThreshold */ - bufferSize += 2; /* s16 primitive->roamingConfig.roamingBands[i2].snrLowThreshold */ - } - } - bufferSize += 1; /* u8 primitive->roamingConfig.disableSmoothRoaming */ - bufferSize += 1; /* u8 primitive->roamingConfig.disableRoamScans */ - bufferSize += 1; /* u8 primitive->roamingConfig.reconnectLimit */ - bufferSize += 2; /* u16 primitive->roamingConfig.reconnectLimitIntervalMs */ - { - u16 i2; - for (i2 = 0; i2 < 3; i2++) - { - bufferSize += 2; /* u16 primitive->roamingConfig.roamScanCfg[i2].intervalSeconds */ - bufferSize += 2; /* u16 primitive->roamingConfig.roamScanCfg[i2].validitySeconds */ - bufferSize += 2; /* u16 primitive->roamingConfig.roamScanCfg[i2].minActiveChannelTimeTu */ - bufferSize += 2; /* u16 primitive->roamingConfig.roamScanCfg[i2].maxActiveChannelTimeTu */ - bufferSize += 2; /* u16 primitive->roamingConfig.roamScanCfg[i2].minPassiveChannelTimeTu */ - bufferSize += 2; /* u16 primitive->roamingConfig.roamScanCfg[i2].maxPassiveChannelTimeTu */ - } - } - return bufferSize; -} - - -u8* CsrWifiSmeRoamingConfigGetCfmSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiSmeRoamingConfigGetCfm *primitive = (CsrWifiSmeRoamingConfigGetCfm *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag); - CsrUint16Ser(ptr, len, (u16) primitive->status); - { - u16 i2; - for (i2 = 0; i2 < 3; i2++) - { - CsrUint16Ser(ptr, len, (u16) primitive->roamingConfig.roamingBands[i2].rssiHighThreshold); - CsrUint16Ser(ptr, len, (u16) primitive->roamingConfig.roamingBands[i2].rssiLowThreshold); - CsrUint16Ser(ptr, len, (u16) primitive->roamingConfig.roamingBands[i2].snrHighThreshold); - CsrUint16Ser(ptr, len, (u16) primitive->roamingConfig.roamingBands[i2].snrLowThreshold); - } - } - CsrUint8Ser(ptr, len, (u8) primitive->roamingConfig.disableSmoothRoaming); - CsrUint8Ser(ptr, len, (u8) primitive->roamingConfig.disableRoamScans); - CsrUint8Ser(ptr, len, (u8) primitive->roamingConfig.reconnectLimit); - CsrUint16Ser(ptr, len, (u16) primitive->roamingConfig.reconnectLimitIntervalMs); - { - u16 i2; - for (i2 = 0; i2 < 3; i2++) - { - CsrUint16Ser(ptr, len, (u16) primitive->roamingConfig.roamScanCfg[i2].intervalSeconds); - CsrUint16Ser(ptr, len, (u16) primitive->roamingConfig.roamScanCfg[i2].validitySeconds); - CsrUint16Ser(ptr, len, (u16) primitive->roamingConfig.roamScanCfg[i2].minActiveChannelTimeTu); - CsrUint16Ser(ptr, len, (u16) primitive->roamingConfig.roamScanCfg[i2].maxActiveChannelTimeTu); - CsrUint16Ser(ptr, len, (u16) primitive->roamingConfig.roamScanCfg[i2].minPassiveChannelTimeTu); - CsrUint16Ser(ptr, len, (u16) primitive->roamingConfig.roamScanCfg[i2].maxPassiveChannelTimeTu); - } - } - return(ptr); -} - - -void* CsrWifiSmeRoamingConfigGetCfmDes(u8 *buffer, size_t length) -{ - CsrWifiSmeRoamingConfigGetCfm *primitive = kmalloc(sizeof(CsrWifiSmeRoamingConfigGetCfm), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset); - CsrUint16Des((u16 *) &primitive->status, buffer, &offset); - { - u16 i2; - for (i2 = 0; i2 < 3; i2++) - { - CsrUint16Des((u16 *) &primitive->roamingConfig.roamingBands[i2].rssiHighThreshold, buffer, &offset); - CsrUint16Des((u16 *) &primitive->roamingConfig.roamingBands[i2].rssiLowThreshold, buffer, &offset); - CsrUint16Des((u16 *) &primitive->roamingConfig.roamingBands[i2].snrHighThreshold, buffer, &offset); - CsrUint16Des((u16 *) &primitive->roamingConfig.roamingBands[i2].snrLowThreshold, buffer, &offset); - } - } - CsrUint8Des((u8 *) &primitive->roamingConfig.disableSmoothRoaming, buffer, &offset); - CsrUint8Des((u8 *) &primitive->roamingConfig.disableRoamScans, buffer, &offset); - CsrUint8Des((u8 *) &primitive->roamingConfig.reconnectLimit, buffer, &offset); - CsrUint16Des((u16 *) &primitive->roamingConfig.reconnectLimitIntervalMs, buffer, &offset); - { - u16 i2; - for (i2 = 0; i2 < 3; i2++) - { - CsrUint16Des((u16 *) &primitive->roamingConfig.roamScanCfg[i2].intervalSeconds, buffer, &offset); - CsrUint16Des((u16 *) &primitive->roamingConfig.roamScanCfg[i2].validitySeconds, buffer, &offset); - CsrUint16Des((u16 *) &primitive->roamingConfig.roamScanCfg[i2].minActiveChannelTimeTu, buffer, &offset); - CsrUint16Des((u16 *) &primitive->roamingConfig.roamScanCfg[i2].maxActiveChannelTimeTu, buffer, &offset); - CsrUint16Des((u16 *) &primitive->roamingConfig.roamScanCfg[i2].minPassiveChannelTimeTu, buffer, &offset); - CsrUint16Des((u16 *) &primitive->roamingConfig.roamScanCfg[i2].maxPassiveChannelTimeTu, buffer, &offset); - } - } - - return primitive; -} - - -size_t CsrWifiSmeRoamingConfigSetCfmSizeof(void *msg) -{ - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 7) */ - bufferSize += 2; /* u16 primitive->interfaceTag */ - bufferSize += 2; /* CsrResult primitive->status */ - return bufferSize; -} - - -u8* CsrWifiSmeRoamingConfigSetCfmSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiSmeRoamingConfigSetCfm *primitive = (CsrWifiSmeRoamingConfigSetCfm *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag); - CsrUint16Ser(ptr, len, (u16) primitive->status); - return(ptr); -} - - -void* CsrWifiSmeRoamingConfigSetCfmDes(u8 *buffer, size_t length) -{ - CsrWifiSmeRoamingConfigSetCfm *primitive = kmalloc(sizeof(CsrWifiSmeRoamingConfigSetCfm), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset); - CsrUint16Des((u16 *) &primitive->status, buffer, &offset); - - return primitive; -} - - -size_t CsrWifiSmeScanConfigGetCfmSizeof(void *msg) -{ - CsrWifiSmeScanConfigGetCfm *primitive = (CsrWifiSmeScanConfigGetCfm *) msg; - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 65) */ - bufferSize += 2; /* CsrResult primitive->status */ - { - u16 i2; - for (i2 = 0; i2 < 4; i2++) - { - bufferSize += 2; /* u16 primitive->scanConfig.scanCfg[i2].intervalSeconds */ - bufferSize += 2; /* u16 primitive->scanConfig.scanCfg[i2].validitySeconds */ - bufferSize += 2; /* u16 primitive->scanConfig.scanCfg[i2].minActiveChannelTimeTu */ - bufferSize += 2; /* u16 primitive->scanConfig.scanCfg[i2].maxActiveChannelTimeTu */ - bufferSize += 2; /* u16 primitive->scanConfig.scanCfg[i2].minPassiveChannelTimeTu */ - bufferSize += 2; /* u16 primitive->scanConfig.scanCfg[i2].maxPassiveChannelTimeTu */ - } - } - bufferSize += 1; /* u8 primitive->scanConfig.disableAutonomousScans */ - bufferSize += 2; /* u16 primitive->scanConfig.maxResults */ - bufferSize += 1; /* s8 primitive->scanConfig.highRssiThreshold */ - bufferSize += 1; /* s8 primitive->scanConfig.lowRssiThreshold */ - bufferSize += 1; /* s8 primitive->scanConfig.deltaRssiThreshold */ - bufferSize += 1; /* s8 primitive->scanConfig.highSnrThreshold */ - bufferSize += 1; /* s8 primitive->scanConfig.lowSnrThreshold */ - bufferSize += 1; /* s8 primitive->scanConfig.deltaSnrThreshold */ - bufferSize += 2; /* u16 primitive->scanConfig.passiveChannelListCount */ - bufferSize += primitive->scanConfig.passiveChannelListCount; /* u8 primitive->scanConfig.passiveChannelList */ - return bufferSize; -} - - -u8* CsrWifiSmeScanConfigGetCfmSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiSmeScanConfigGetCfm *primitive = (CsrWifiSmeScanConfigGetCfm *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->status); - { - u16 i2; - for (i2 = 0; i2 < 4; i2++) - { - CsrUint16Ser(ptr, len, (u16) primitive->scanConfig.scanCfg[i2].intervalSeconds); - CsrUint16Ser(ptr, len, (u16) primitive->scanConfig.scanCfg[i2].validitySeconds); - CsrUint16Ser(ptr, len, (u16) primitive->scanConfig.scanCfg[i2].minActiveChannelTimeTu); - CsrUint16Ser(ptr, len, (u16) primitive->scanConfig.scanCfg[i2].maxActiveChannelTimeTu); - CsrUint16Ser(ptr, len, (u16) primitive->scanConfig.scanCfg[i2].minPassiveChannelTimeTu); - CsrUint16Ser(ptr, len, (u16) primitive->scanConfig.scanCfg[i2].maxPassiveChannelTimeTu); - } - } - CsrUint8Ser(ptr, len, (u8) primitive->scanConfig.disableAutonomousScans); - CsrUint16Ser(ptr, len, (u16) primitive->scanConfig.maxResults); - CsrUint8Ser(ptr, len, (u8) primitive->scanConfig.highRssiThreshold); - CsrUint8Ser(ptr, len, (u8) primitive->scanConfig.lowRssiThreshold); - CsrUint8Ser(ptr, len, (u8) primitive->scanConfig.deltaRssiThreshold); - CsrUint8Ser(ptr, len, (u8) primitive->scanConfig.highSnrThreshold); - CsrUint8Ser(ptr, len, (u8) primitive->scanConfig.lowSnrThreshold); - CsrUint8Ser(ptr, len, (u8) primitive->scanConfig.deltaSnrThreshold); - CsrUint16Ser(ptr, len, (u16) primitive->scanConfig.passiveChannelListCount); - if (primitive->scanConfig.passiveChannelListCount) - { - CsrMemCpySer(ptr, len, (const void *) primitive->scanConfig.passiveChannelList, ((u16) (primitive->scanConfig.passiveChannelListCount))); - } - return(ptr); -} - - -void* CsrWifiSmeScanConfigGetCfmDes(u8 *buffer, size_t length) -{ - CsrWifiSmeScanConfigGetCfm *primitive = kmalloc(sizeof(CsrWifiSmeScanConfigGetCfm), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->status, buffer, &offset); - { - u16 i2; - for (i2 = 0; i2 < 4; i2++) - { - CsrUint16Des((u16 *) &primitive->scanConfig.scanCfg[i2].intervalSeconds, buffer, &offset); - CsrUint16Des((u16 *) &primitive->scanConfig.scanCfg[i2].validitySeconds, buffer, &offset); - CsrUint16Des((u16 *) &primitive->scanConfig.scanCfg[i2].minActiveChannelTimeTu, buffer, &offset); - CsrUint16Des((u16 *) &primitive->scanConfig.scanCfg[i2].maxActiveChannelTimeTu, buffer, &offset); - CsrUint16Des((u16 *) &primitive->scanConfig.scanCfg[i2].minPassiveChannelTimeTu, buffer, &offset); - CsrUint16Des((u16 *) &primitive->scanConfig.scanCfg[i2].maxPassiveChannelTimeTu, buffer, &offset); - } - } - CsrUint8Des((u8 *) &primitive->scanConfig.disableAutonomousScans, buffer, &offset); - CsrUint16Des((u16 *) &primitive->scanConfig.maxResults, buffer, &offset); - CsrUint8Des((u8 *) &primitive->scanConfig.highRssiThreshold, buffer, &offset); - CsrUint8Des((u8 *) &primitive->scanConfig.lowRssiThreshold, buffer, &offset); - CsrUint8Des((u8 *) &primitive->scanConfig.deltaRssiThreshold, buffer, &offset); - CsrUint8Des((u8 *) &primitive->scanConfig.highSnrThreshold, buffer, &offset); - CsrUint8Des((u8 *) &primitive->scanConfig.lowSnrThreshold, buffer, &offset); - CsrUint8Des((u8 *) &primitive->scanConfig.deltaSnrThreshold, buffer, &offset); - CsrUint16Des((u16 *) &primitive->scanConfig.passiveChannelListCount, buffer, &offset); - if (primitive->scanConfig.passiveChannelListCount) - { - primitive->scanConfig.passiveChannelList = kmalloc(primitive->scanConfig.passiveChannelListCount, GFP_KERNEL); - CsrMemCpyDes(primitive->scanConfig.passiveChannelList, buffer, &offset, ((u16) (primitive->scanConfig.passiveChannelListCount))); - } - else - { - primitive->scanConfig.passiveChannelList = NULL; - } - - return primitive; -} - - -void CsrWifiSmeScanConfigGetCfmSerFree(void *voidPrimitivePointer) -{ - CsrWifiSmeScanConfigGetCfm *primitive = (CsrWifiSmeScanConfigGetCfm *) voidPrimitivePointer; - kfree(primitive->scanConfig.passiveChannelList); - kfree(primitive); -} - - -size_t CsrWifiSmeScanResultIndSizeof(void *msg) -{ - CsrWifiSmeScanResultInd *primitive = (CsrWifiSmeScanResultInd *) msg; - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 149) */ - bufferSize += 32; /* u8 primitive->result.ssid.ssid[32] */ - bufferSize += 1; /* u8 primitive->result.ssid.length */ - bufferSize += 6; /* u8 primitive->result.bssid.a[6] */ - bufferSize += 2; /* s16 primitive->result.rssi */ - bufferSize += 2; /* s16 primitive->result.snr */ - bufferSize += 1; /* CsrWifiSmeRadioIF primitive->result.ifIndex */ - bufferSize += 2; /* u16 primitive->result.beaconPeriodTu */ - bufferSize += 8; /* u8 primitive->result.timeStamp.data[8] */ - bufferSize += 8; /* u8 primitive->result.localTime.data[8] */ - bufferSize += 2; /* u16 primitive->result.channelFrequency */ - bufferSize += 2; /* u16 primitive->result.capabilityInformation */ - bufferSize += 1; /* u8 primitive->result.channelNumber */ - bufferSize += 1; /* CsrWifiSmeBasicUsability primitive->result.usability */ - bufferSize += 1; /* CsrWifiSmeBssType primitive->result.bssType */ - bufferSize += 2; /* u16 primitive->result.informationElementsLength */ - bufferSize += primitive->result.informationElementsLength; /* u8 primitive->result.informationElements */ - bufferSize += 1; /* CsrWifiSmeP2pRole primitive->result.p2pDeviceRole */ - switch (primitive->result.p2pDeviceRole) - { - case CSR_WIFI_SME_P2P_ROLE_CLI: - bufferSize += 1; /* u8 primitive->result.deviceInfo.reservedCli.empty */ - break; - case CSR_WIFI_SME_P2P_ROLE_GO: - bufferSize += 1; /* CsrWifiSmeP2pGroupCapabilityMask primitive->result.deviceInfo.groupInfo.groupCapability */ - bufferSize += 6; /* u8 primitive->result.deviceInfo.groupInfo.p2pDeviceAddress.a[6] */ - bufferSize += 1; /* u8 primitive->result.deviceInfo.groupInfo.p2pClientInfoCount */ - { - u16 i4; - for (i4 = 0; i4 < primitive->result.deviceInfo.groupInfo.p2pClientInfoCount; i4++) - { - bufferSize += 6; /* u8 primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].p2PClientInterfaceAddress.a[6] */ - bufferSize += 6; /* u8 primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.deviceAddress.a[6] */ - bufferSize += 2; /* CsrWifiSmeWpsConfigTypeMask primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.configMethods */ - bufferSize += 1; /* CsrWifiSmeP2pCapabilityMask primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.p2PDeviceCap */ - bufferSize += 8; /* u8 primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.primDeviceType.deviceDetails[8] */ - bufferSize += 1; /* u8 primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secondaryDeviceTypeCount */ - { - u16 i6; - for (i6 = 0; i6 < primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secondaryDeviceTypeCount; i6++) - { - bufferSize += 8; /* u8 primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secDeviceType[i6].deviceDetails[8] */ - } - } - bufferSize += 32; /* u8 primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.deviceName[32] */ - bufferSize += 1; /* u8 primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.deviceNameLength */ - } - } - break; - case CSR_WIFI_SME_P2P_ROLE_NONE: - bufferSize += 1; /* u8 primitive->result.deviceInfo.reservedNone.empty */ - break; - case CSR_WIFI_SME_P2P_ROLE_STANDALONE: - bufferSize += 6; /* u8 primitive->result.deviceInfo.standalonedevInfo.deviceAddress.a[6] */ - bufferSize += 2; /* CsrWifiSmeWpsConfigTypeMask primitive->result.deviceInfo.standalonedevInfo.configMethods */ - bufferSize += 1; /* CsrWifiSmeP2pCapabilityMask primitive->result.deviceInfo.standalonedevInfo.p2PDeviceCap */ - bufferSize += 8; /* u8 primitive->result.deviceInfo.standalonedevInfo.primDeviceType.deviceDetails[8] */ - bufferSize += 1; /* u8 primitive->result.deviceInfo.standalonedevInfo.secondaryDeviceTypeCount */ - { - u16 i4; - for (i4 = 0; i4 < primitive->result.deviceInfo.standalonedevInfo.secondaryDeviceTypeCount; i4++) - { - bufferSize += 8; /* u8 primitive->result.deviceInfo.standalonedevInfo.secDeviceType[i4].deviceDetails[8] */ - } - } - bufferSize += 32; /* u8 primitive->result.deviceInfo.standalonedevInfo.deviceName[32] */ - bufferSize += 1; /* u8 primitive->result.deviceInfo.standalonedevInfo.deviceNameLength */ - break; - default: - break; - } - return bufferSize; -} - - -u8* CsrWifiSmeScanResultIndSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiSmeScanResultInd *primitive = (CsrWifiSmeScanResultInd *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrMemCpySer(ptr, len, (const void *) primitive->result.ssid.ssid, ((u16) (32))); - CsrUint8Ser(ptr, len, (u8) primitive->result.ssid.length); - CsrMemCpySer(ptr, len, (const void *) primitive->result.bssid.a, ((u16) (6))); - CsrUint16Ser(ptr, len, (u16) primitive->result.rssi); - CsrUint16Ser(ptr, len, (u16) primitive->result.snr); - CsrUint8Ser(ptr, len, (u8) primitive->result.ifIndex); - CsrUint16Ser(ptr, len, (u16) primitive->result.beaconPeriodTu); - CsrMemCpySer(ptr, len, (const void *) primitive->result.timeStamp.data, ((u16) (8))); - CsrMemCpySer(ptr, len, (const void *) primitive->result.localTime.data, ((u16) (8))); - CsrUint16Ser(ptr, len, (u16) primitive->result.channelFrequency); - CsrUint16Ser(ptr, len, (u16) primitive->result.capabilityInformation); - CsrUint8Ser(ptr, len, (u8) primitive->result.channelNumber); - CsrUint8Ser(ptr, len, (u8) primitive->result.usability); - CsrUint8Ser(ptr, len, (u8) primitive->result.bssType); - CsrUint16Ser(ptr, len, (u16) primitive->result.informationElementsLength); - if (primitive->result.informationElementsLength) - { - CsrMemCpySer(ptr, len, (const void *) primitive->result.informationElements, ((u16) (primitive->result.informationElementsLength))); - } - CsrUint8Ser(ptr, len, (u8) primitive->result.p2pDeviceRole); - switch (primitive->result.p2pDeviceRole) - { - case CSR_WIFI_SME_P2P_ROLE_CLI: - CsrUint8Ser(ptr, len, (u8) primitive->result.deviceInfo.reservedCli.empty); - break; - case CSR_WIFI_SME_P2P_ROLE_GO: - CsrUint8Ser(ptr, len, (u8) primitive->result.deviceInfo.groupInfo.groupCapability); - CsrMemCpySer(ptr, len, (const void *) primitive->result.deviceInfo.groupInfo.p2pDeviceAddress.a, ((u16) (6))); - CsrUint8Ser(ptr, len, (u8) primitive->result.deviceInfo.groupInfo.p2pClientInfoCount); - { - u16 i4; - for (i4 = 0; i4 < primitive->result.deviceInfo.groupInfo.p2pClientInfoCount; i4++) - { - CsrMemCpySer(ptr, len, (const void *) primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].p2PClientInterfaceAddress.a, ((u16) (6))); - CsrMemCpySer(ptr, len, (const void *) primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.deviceAddress.a, ((u16) (6))); - CsrUint16Ser(ptr, len, (u16) primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.configMethods); - CsrUint8Ser(ptr, len, (u8) primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.p2PDeviceCap); - CsrMemCpySer(ptr, len, (const void *) primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.primDeviceType.deviceDetails, ((u16) (8))); - CsrUint8Ser(ptr, len, (u8) primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secondaryDeviceTypeCount); - { - u16 i6; - for (i6 = 0; i6 < primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secondaryDeviceTypeCount; i6++) - { - CsrMemCpySer(ptr, len, (const void *) primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secDeviceType[i6].deviceDetails, ((u16) (8))); - } - } - CsrMemCpySer(ptr, len, (const void *) primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.deviceName, ((u16) (32))); - CsrUint8Ser(ptr, len, (u8) primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.deviceNameLength); - } - } - break; - case CSR_WIFI_SME_P2P_ROLE_NONE: - CsrUint8Ser(ptr, len, (u8) primitive->result.deviceInfo.reservedNone.empty); - break; - case CSR_WIFI_SME_P2P_ROLE_STANDALONE: - CsrMemCpySer(ptr, len, (const void *) primitive->result.deviceInfo.standalonedevInfo.deviceAddress.a, ((u16) (6))); - CsrUint16Ser(ptr, len, (u16) primitive->result.deviceInfo.standalonedevInfo.configMethods); - CsrUint8Ser(ptr, len, (u8) primitive->result.deviceInfo.standalonedevInfo.p2PDeviceCap); - CsrMemCpySer(ptr, len, (const void *) primitive->result.deviceInfo.standalonedevInfo.primDeviceType.deviceDetails, ((u16) (8))); - CsrUint8Ser(ptr, len, (u8) primitive->result.deviceInfo.standalonedevInfo.secondaryDeviceTypeCount); - { - u16 i4; - for (i4 = 0; i4 < primitive->result.deviceInfo.standalonedevInfo.secondaryDeviceTypeCount; i4++) - { - CsrMemCpySer(ptr, len, (const void *) primitive->result.deviceInfo.standalonedevInfo.secDeviceType[i4].deviceDetails, ((u16) (8))); - } - } - CsrMemCpySer(ptr, len, (const void *) primitive->result.deviceInfo.standalonedevInfo.deviceName, ((u16) (32))); - CsrUint8Ser(ptr, len, (u8) primitive->result.deviceInfo.standalonedevInfo.deviceNameLength); - break; - default: - break; - } - return(ptr); -} - - -void* CsrWifiSmeScanResultIndDes(u8 *buffer, size_t length) -{ - CsrWifiSmeScanResultInd *primitive = kmalloc(sizeof(CsrWifiSmeScanResultInd), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrMemCpyDes(primitive->result.ssid.ssid, buffer, &offset, ((u16) (32))); - CsrUint8Des((u8 *) &primitive->result.ssid.length, buffer, &offset); - CsrMemCpyDes(primitive->result.bssid.a, buffer, &offset, ((u16) (6))); - CsrUint16Des((u16 *) &primitive->result.rssi, buffer, &offset); - CsrUint16Des((u16 *) &primitive->result.snr, buffer, &offset); - CsrUint8Des((u8 *) &primitive->result.ifIndex, buffer, &offset); - CsrUint16Des((u16 *) &primitive->result.beaconPeriodTu, buffer, &offset); - CsrMemCpyDes(primitive->result.timeStamp.data, buffer, &offset, ((u16) (8))); - CsrMemCpyDes(primitive->result.localTime.data, buffer, &offset, ((u16) (8))); - CsrUint16Des((u16 *) &primitive->result.channelFrequency, buffer, &offset); - CsrUint16Des((u16 *) &primitive->result.capabilityInformation, buffer, &offset); - CsrUint8Des((u8 *) &primitive->result.channelNumber, buffer, &offset); - CsrUint8Des((u8 *) &primitive->result.usability, buffer, &offset); - CsrUint8Des((u8 *) &primitive->result.bssType, buffer, &offset); - CsrUint16Des((u16 *) &primitive->result.informationElementsLength, buffer, &offset); - if (primitive->result.informationElementsLength) - { - primitive->result.informationElements = kmalloc(primitive->result.informationElementsLength, GFP_KERNEL); - CsrMemCpyDes(primitive->result.informationElements, buffer, &offset, ((u16) (primitive->result.informationElementsLength))); - } - else - { - primitive->result.informationElements = NULL; - } - CsrUint8Des((u8 *) &primitive->result.p2pDeviceRole, buffer, &offset); - switch (primitive->result.p2pDeviceRole) - { - case CSR_WIFI_SME_P2P_ROLE_CLI: - CsrUint8Des((u8 *) &primitive->result.deviceInfo.reservedCli.empty, buffer, &offset); - break; - case CSR_WIFI_SME_P2P_ROLE_GO: - CsrUint8Des((u8 *) &primitive->result.deviceInfo.groupInfo.groupCapability, buffer, &offset); - CsrMemCpyDes(primitive->result.deviceInfo.groupInfo.p2pDeviceAddress.a, buffer, &offset, ((u16) (6))); - CsrUint8Des((u8 *) &primitive->result.deviceInfo.groupInfo.p2pClientInfoCount, buffer, &offset); - primitive->result.deviceInfo.groupInfo.p2PClientInfo = NULL; - if (primitive->result.deviceInfo.groupInfo.p2pClientInfoCount) - { - primitive->result.deviceInfo.groupInfo.p2PClientInfo = kmalloc(sizeof(CsrWifiSmeP2pClientInfoType) * primitive->result.deviceInfo.groupInfo.p2pClientInfoCount, GFP_KERNEL); - } - { - u16 i4; - for (i4 = 0; i4 < primitive->result.deviceInfo.groupInfo.p2pClientInfoCount; i4++) - { - CsrMemCpyDes(primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].p2PClientInterfaceAddress.a, buffer, &offset, ((u16) (6))); - CsrMemCpyDes(primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.deviceAddress.a, buffer, &offset, ((u16) (6))); - CsrUint16Des((u16 *) &primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.configMethods, buffer, &offset); - CsrUint8Des((u8 *) &primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.p2PDeviceCap, buffer, &offset); - CsrMemCpyDes(primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.primDeviceType.deviceDetails, buffer, &offset, ((u16) (8))); - CsrUint8Des((u8 *) &primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secondaryDeviceTypeCount, buffer, &offset); - primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secDeviceType = NULL; - if (primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secondaryDeviceTypeCount) - { - primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secDeviceType = kmalloc(sizeof(CsrWifiSmeWpsDeviceType) * primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secondaryDeviceTypeCount, GFP_KERNEL); - } - { - u16 i6; - for (i6 = 0; i6 < primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secondaryDeviceTypeCount; i6++) - { - CsrMemCpyDes(primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secDeviceType[i6].deviceDetails, buffer, &offset, ((u16) (8))); - } - } - CsrMemCpyDes(primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.deviceName, buffer, &offset, ((u16) (32))); - CsrUint8Des((u8 *) &primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.deviceNameLength, buffer, &offset); - } - } - break; - case CSR_WIFI_SME_P2P_ROLE_NONE: - CsrUint8Des((u8 *) &primitive->result.deviceInfo.reservedNone.empty, buffer, &offset); - break; - case CSR_WIFI_SME_P2P_ROLE_STANDALONE: - CsrMemCpyDes(primitive->result.deviceInfo.standalonedevInfo.deviceAddress.a, buffer, &offset, ((u16) (6))); - CsrUint16Des((u16 *) &primitive->result.deviceInfo.standalonedevInfo.configMethods, buffer, &offset); - CsrUint8Des((u8 *) &primitive->result.deviceInfo.standalonedevInfo.p2PDeviceCap, buffer, &offset); - CsrMemCpyDes(primitive->result.deviceInfo.standalonedevInfo.primDeviceType.deviceDetails, buffer, &offset, ((u16) (8))); - CsrUint8Des((u8 *) &primitive->result.deviceInfo.standalonedevInfo.secondaryDeviceTypeCount, buffer, &offset); - primitive->result.deviceInfo.standalonedevInfo.secDeviceType = NULL; - if (primitive->result.deviceInfo.standalonedevInfo.secondaryDeviceTypeCount) - { - primitive->result.deviceInfo.standalonedevInfo.secDeviceType = kmalloc(sizeof(CsrWifiSmeWpsDeviceType) * primitive->result.deviceInfo.standalonedevInfo.secondaryDeviceTypeCount, GFP_KERNEL); - } - { - u16 i4; - for (i4 = 0; i4 < primitive->result.deviceInfo.standalonedevInfo.secondaryDeviceTypeCount; i4++) - { - CsrMemCpyDes(primitive->result.deviceInfo.standalonedevInfo.secDeviceType[i4].deviceDetails, buffer, &offset, ((u16) (8))); - } - } - CsrMemCpyDes(primitive->result.deviceInfo.standalonedevInfo.deviceName, buffer, &offset, ((u16) (32))); - CsrUint8Des((u8 *) &primitive->result.deviceInfo.standalonedevInfo.deviceNameLength, buffer, &offset); - break; - default: - break; - } - - return primitive; -} - - -void CsrWifiSmeScanResultIndSerFree(void *voidPrimitivePointer) -{ - CsrWifiSmeScanResultInd *primitive = (CsrWifiSmeScanResultInd *) voidPrimitivePointer; - kfree(primitive->result.informationElements); - switch (primitive->result.p2pDeviceRole) - { - case CSR_WIFI_SME_P2P_ROLE_GO: - { - u16 i4; - for (i4 = 0; i4 < primitive->result.deviceInfo.groupInfo.p2pClientInfoCount; i4++) - { - kfree(primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secDeviceType); - } - } - kfree(primitive->result.deviceInfo.groupInfo.p2PClientInfo); - break; - case CSR_WIFI_SME_P2P_ROLE_STANDALONE: - kfree(primitive->result.deviceInfo.standalonedevInfo.secDeviceType); - break; - default: - break; - } - kfree(primitive); -} - - -size_t CsrWifiSmeScanResultsGetCfmSizeof(void *msg) -{ - CsrWifiSmeScanResultsGetCfm *primitive = (CsrWifiSmeScanResultsGetCfm *) msg; - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 153) */ - bufferSize += 2; /* CsrResult primitive->status */ - bufferSize += 2; /* u16 primitive->scanResultsCount */ - { - u16 i1; - for (i1 = 0; i1 < primitive->scanResultsCount; i1++) - { - bufferSize += 32; /* u8 primitive->scanResults[i1].ssid.ssid[32] */ - bufferSize += 1; /* u8 primitive->scanResults[i1].ssid.length */ - bufferSize += 6; /* u8 primitive->scanResults[i1].bssid.a[6] */ - bufferSize += 2; /* s16 primitive->scanResults[i1].rssi */ - bufferSize += 2; /* s16 primitive->scanResults[i1].snr */ - bufferSize += 1; /* CsrWifiSmeRadioIF primitive->scanResults[i1].ifIndex */ - bufferSize += 2; /* u16 primitive->scanResults[i1].beaconPeriodTu */ - bufferSize += 8; /* u8 primitive->scanResults[i1].timeStamp.data[8] */ - bufferSize += 8; /* u8 primitive->scanResults[i1].localTime.data[8] */ - bufferSize += 2; /* u16 primitive->scanResults[i1].channelFrequency */ - bufferSize += 2; /* u16 primitive->scanResults[i1].capabilityInformation */ - bufferSize += 1; /* u8 primitive->scanResults[i1].channelNumber */ - bufferSize += 1; /* CsrWifiSmeBasicUsability primitive->scanResults[i1].usability */ - bufferSize += 1; /* CsrWifiSmeBssType primitive->scanResults[i1].bssType */ - bufferSize += 2; /* u16 primitive->scanResults[i1].informationElementsLength */ - bufferSize += primitive->scanResults[i1].informationElementsLength; /* u8 primitive->scanResults[i1].informationElements */ - bufferSize += 1; /* CsrWifiSmeP2pRole primitive->scanResults[i1].p2pDeviceRole */ - switch (primitive->scanResults[i1].p2pDeviceRole) - { - case CSR_WIFI_SME_P2P_ROLE_CLI: - bufferSize += 1; /* u8 primitive->scanResults[i1].deviceInfo.reservedCli.empty */ - break; - case CSR_WIFI_SME_P2P_ROLE_GO: - bufferSize += 1; /* CsrWifiSmeP2pGroupCapabilityMask primitive->scanResults[i1].deviceInfo.groupInfo.groupCapability */ - bufferSize += 6; /* u8 primitive->scanResults[i1].deviceInfo.groupInfo.p2pDeviceAddress.a[6] */ - bufferSize += 1; /* u8 primitive->scanResults[i1].deviceInfo.groupInfo.p2pClientInfoCount */ - { - u16 i4; - for (i4 = 0; i4 < primitive->scanResults[i1].deviceInfo.groupInfo.p2pClientInfoCount; i4++) - { - bufferSize += 6; /* u8 primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].p2PClientInterfaceAddress.a[6] */ - bufferSize += 6; /* u8 primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.deviceAddress.a[6] */ - bufferSize += 2; /* CsrWifiSmeWpsConfigTypeMask primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.configMethods */ - bufferSize += 1; /* CsrWifiSmeP2pCapabilityMask primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.p2PDeviceCap */ - bufferSize += 8; /* u8 primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.primDeviceType.deviceDetails[8] */ - bufferSize += 1; /* u8 primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secondaryDeviceTypeCount */ - { - u16 i6; - for (i6 = 0; i6 < primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secondaryDeviceTypeCount; i6++) - { - bufferSize += 8; /* u8 primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secDeviceType[i6].deviceDetails[8] */ - } - } - bufferSize += 32; /* u8 primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.deviceName[32] */ - bufferSize += 1; /* u8 primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.deviceNameLength */ - } - } - break; - case CSR_WIFI_SME_P2P_ROLE_NONE: - bufferSize += 1; /* u8 primitive->scanResults[i1].deviceInfo.reservedNone.empty */ - break; - case CSR_WIFI_SME_P2P_ROLE_STANDALONE: - bufferSize += 6; /* u8 primitive->scanResults[i1].deviceInfo.standalonedevInfo.deviceAddress.a[6] */ - bufferSize += 2; /* CsrWifiSmeWpsConfigTypeMask primitive->scanResults[i1].deviceInfo.standalonedevInfo.configMethods */ - bufferSize += 1; /* CsrWifiSmeP2pCapabilityMask primitive->scanResults[i1].deviceInfo.standalonedevInfo.p2PDeviceCap */ - bufferSize += 8; /* u8 primitive->scanResults[i1].deviceInfo.standalonedevInfo.primDeviceType.deviceDetails[8] */ - bufferSize += 1; /* u8 primitive->scanResults[i1].deviceInfo.standalonedevInfo.secondaryDeviceTypeCount */ - { - u16 i4; - for (i4 = 0; i4 < primitive->scanResults[i1].deviceInfo.standalonedevInfo.secondaryDeviceTypeCount; i4++) - { - bufferSize += 8; /* u8 primitive->scanResults[i1].deviceInfo.standalonedevInfo.secDeviceType[i4].deviceDetails[8] */ - } - } - bufferSize += 32; /* u8 primitive->scanResults[i1].deviceInfo.standalonedevInfo.deviceName[32] */ - bufferSize += 1; /* u8 primitive->scanResults[i1].deviceInfo.standalonedevInfo.deviceNameLength */ - break; - default: - break; - } - } - } - return bufferSize; -} - - -u8* CsrWifiSmeScanResultsGetCfmSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiSmeScanResultsGetCfm *primitive = (CsrWifiSmeScanResultsGetCfm *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->status); - CsrUint16Ser(ptr, len, (u16) primitive->scanResultsCount); - { - u16 i1; - for (i1 = 0; i1 < primitive->scanResultsCount; i1++) - { - CsrMemCpySer(ptr, len, (const void *) primitive->scanResults[i1].ssid.ssid, ((u16) (32))); - CsrUint8Ser(ptr, len, (u8) primitive->scanResults[i1].ssid.length); - CsrMemCpySer(ptr, len, (const void *) primitive->scanResults[i1].bssid.a, ((u16) (6))); - CsrUint16Ser(ptr, len, (u16) primitive->scanResults[i1].rssi); - CsrUint16Ser(ptr, len, (u16) primitive->scanResults[i1].snr); - CsrUint8Ser(ptr, len, (u8) primitive->scanResults[i1].ifIndex); - CsrUint16Ser(ptr, len, (u16) primitive->scanResults[i1].beaconPeriodTu); - CsrMemCpySer(ptr, len, (const void *) primitive->scanResults[i1].timeStamp.data, ((u16) (8))); - CsrMemCpySer(ptr, len, (const void *) primitive->scanResults[i1].localTime.data, ((u16) (8))); - CsrUint16Ser(ptr, len, (u16) primitive->scanResults[i1].channelFrequency); - CsrUint16Ser(ptr, len, (u16) primitive->scanResults[i1].capabilityInformation); - CsrUint8Ser(ptr, len, (u8) primitive->scanResults[i1].channelNumber); - CsrUint8Ser(ptr, len, (u8) primitive->scanResults[i1].usability); - CsrUint8Ser(ptr, len, (u8) primitive->scanResults[i1].bssType); - CsrUint16Ser(ptr, len, (u16) primitive->scanResults[i1].informationElementsLength); - if (primitive->scanResults[i1].informationElementsLength) - { - CsrMemCpySer(ptr, len, (const void *) primitive->scanResults[i1].informationElements, ((u16) (primitive->scanResults[i1].informationElementsLength))); - } - CsrUint8Ser(ptr, len, (u8) primitive->scanResults[i1].p2pDeviceRole); - switch (primitive->scanResults[i1].p2pDeviceRole) - { - case CSR_WIFI_SME_P2P_ROLE_CLI: - CsrUint8Ser(ptr, len, (u8) primitive->scanResults[i1].deviceInfo.reservedCli.empty); - break; - case CSR_WIFI_SME_P2P_ROLE_GO: - CsrUint8Ser(ptr, len, (u8) primitive->scanResults[i1].deviceInfo.groupInfo.groupCapability); - CsrMemCpySer(ptr, len, (const void *) primitive->scanResults[i1].deviceInfo.groupInfo.p2pDeviceAddress.a, ((u16) (6))); - CsrUint8Ser(ptr, len, (u8) primitive->scanResults[i1].deviceInfo.groupInfo.p2pClientInfoCount); - { - u16 i4; - for (i4 = 0; i4 < primitive->scanResults[i1].deviceInfo.groupInfo.p2pClientInfoCount; i4++) - { - CsrMemCpySer(ptr, len, (const void *) primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].p2PClientInterfaceAddress.a, ((u16) (6))); - CsrMemCpySer(ptr, len, (const void *) primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.deviceAddress.a, ((u16) (6))); - CsrUint16Ser(ptr, len, (u16) primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.configMethods); - CsrUint8Ser(ptr, len, (u8) primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.p2PDeviceCap); - CsrMemCpySer(ptr, len, (const void *) primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.primDeviceType.deviceDetails, ((u16) (8))); - CsrUint8Ser(ptr, len, (u8) primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secondaryDeviceTypeCount); - { - u16 i6; - for (i6 = 0; i6 < primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secondaryDeviceTypeCount; i6++) - { - CsrMemCpySer(ptr, len, (const void *) primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secDeviceType[i6].deviceDetails, ((u16) (8))); - } - } - CsrMemCpySer(ptr, len, (const void *) primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.deviceName, ((u16) (32))); - CsrUint8Ser(ptr, len, (u8) primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.deviceNameLength); - } - } - break; - case CSR_WIFI_SME_P2P_ROLE_NONE: - CsrUint8Ser(ptr, len, (u8) primitive->scanResults[i1].deviceInfo.reservedNone.empty); - break; - case CSR_WIFI_SME_P2P_ROLE_STANDALONE: - CsrMemCpySer(ptr, len, (const void *) primitive->scanResults[i1].deviceInfo.standalonedevInfo.deviceAddress.a, ((u16) (6))); - CsrUint16Ser(ptr, len, (u16) primitive->scanResults[i1].deviceInfo.standalonedevInfo.configMethods); - CsrUint8Ser(ptr, len, (u8) primitive->scanResults[i1].deviceInfo.standalonedevInfo.p2PDeviceCap); - CsrMemCpySer(ptr, len, (const void *) primitive->scanResults[i1].deviceInfo.standalonedevInfo.primDeviceType.deviceDetails, ((u16) (8))); - CsrUint8Ser(ptr, len, (u8) primitive->scanResults[i1].deviceInfo.standalonedevInfo.secondaryDeviceTypeCount); - { - u16 i4; - for (i4 = 0; i4 < primitive->scanResults[i1].deviceInfo.standalonedevInfo.secondaryDeviceTypeCount; i4++) - { - CsrMemCpySer(ptr, len, (const void *) primitive->scanResults[i1].deviceInfo.standalonedevInfo.secDeviceType[i4].deviceDetails, ((u16) (8))); - } - } - CsrMemCpySer(ptr, len, (const void *) primitive->scanResults[i1].deviceInfo.standalonedevInfo.deviceName, ((u16) (32))); - CsrUint8Ser(ptr, len, (u8) primitive->scanResults[i1].deviceInfo.standalonedevInfo.deviceNameLength); - break; - default: - break; - } - } - } - return(ptr); -} - - -void* CsrWifiSmeScanResultsGetCfmDes(u8 *buffer, size_t length) -{ - CsrWifiSmeScanResultsGetCfm *primitive = kmalloc(sizeof(CsrWifiSmeScanResultsGetCfm), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->status, buffer, &offset); - CsrUint16Des((u16 *) &primitive->scanResultsCount, buffer, &offset); - primitive->scanResults = NULL; - if (primitive->scanResultsCount) - { - primitive->scanResults = kmalloc(sizeof(CsrWifiSmeScanResult) * primitive->scanResultsCount, GFP_KERNEL); - } - { - u16 i1; - for (i1 = 0; i1 < primitive->scanResultsCount; i1++) - { - CsrMemCpyDes(primitive->scanResults[i1].ssid.ssid, buffer, &offset, ((u16) (32))); - CsrUint8Des((u8 *) &primitive->scanResults[i1].ssid.length, buffer, &offset); - CsrMemCpyDes(primitive->scanResults[i1].bssid.a, buffer, &offset, ((u16) (6))); - CsrUint16Des((u16 *) &primitive->scanResults[i1].rssi, buffer, &offset); - CsrUint16Des((u16 *) &primitive->scanResults[i1].snr, buffer, &offset); - CsrUint8Des((u8 *) &primitive->scanResults[i1].ifIndex, buffer, &offset); - CsrUint16Des((u16 *) &primitive->scanResults[i1].beaconPeriodTu, buffer, &offset); - CsrMemCpyDes(primitive->scanResults[i1].timeStamp.data, buffer, &offset, ((u16) (8))); - CsrMemCpyDes(primitive->scanResults[i1].localTime.data, buffer, &offset, ((u16) (8))); - CsrUint16Des((u16 *) &primitive->scanResults[i1].channelFrequency, buffer, &offset); - CsrUint16Des((u16 *) &primitive->scanResults[i1].capabilityInformation, buffer, &offset); - CsrUint8Des((u8 *) &primitive->scanResults[i1].channelNumber, buffer, &offset); - CsrUint8Des((u8 *) &primitive->scanResults[i1].usability, buffer, &offset); - CsrUint8Des((u8 *) &primitive->scanResults[i1].bssType, buffer, &offset); - CsrUint16Des((u16 *) &primitive->scanResults[i1].informationElementsLength, buffer, &offset); - if (primitive->scanResults[i1].informationElementsLength) - { - primitive->scanResults[i1].informationElements = kmalloc(primitive->scanResults[i1].informationElementsLength, GFP_KERNEL); - CsrMemCpyDes(primitive->scanResults[i1].informationElements, buffer, &offset, ((u16) (primitive->scanResults[i1].informationElementsLength))); - } - else - { - primitive->scanResults[i1].informationElements = NULL; - } - CsrUint8Des((u8 *) &primitive->scanResults[i1].p2pDeviceRole, buffer, &offset); - switch (primitive->scanResults[i1].p2pDeviceRole) - { - case CSR_WIFI_SME_P2P_ROLE_CLI: - CsrUint8Des((u8 *) &primitive->scanResults[i1].deviceInfo.reservedCli.empty, buffer, &offset); - break; - case CSR_WIFI_SME_P2P_ROLE_GO: - CsrUint8Des((u8 *) &primitive->scanResults[i1].deviceInfo.groupInfo.groupCapability, buffer, &offset); - CsrMemCpyDes(primitive->scanResults[i1].deviceInfo.groupInfo.p2pDeviceAddress.a, buffer, &offset, ((u16) (6))); - CsrUint8Des((u8 *) &primitive->scanResults[i1].deviceInfo.groupInfo.p2pClientInfoCount, buffer, &offset); - primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo = NULL; - if (primitive->scanResults[i1].deviceInfo.groupInfo.p2pClientInfoCount) - { - primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo = kmalloc(sizeof(CsrWifiSmeP2pClientInfoType) * primitive->scanResults[i1].deviceInfo.groupInfo.p2pClientInfoCount, GFP_KERNEL); - } - { - u16 i4; - for (i4 = 0; i4 < primitive->scanResults[i1].deviceInfo.groupInfo.p2pClientInfoCount; i4++) - { - CsrMemCpyDes(primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].p2PClientInterfaceAddress.a, buffer, &offset, ((u16) (6))); - CsrMemCpyDes(primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.deviceAddress.a, buffer, &offset, ((u16) (6))); - CsrUint16Des((u16 *) &primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.configMethods, buffer, &offset); - CsrUint8Des((u8 *) &primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.p2PDeviceCap, buffer, &offset); - CsrMemCpyDes(primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.primDeviceType.deviceDetails, buffer, &offset, ((u16) (8))); - CsrUint8Des((u8 *) &primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secondaryDeviceTypeCount, buffer, &offset); - primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secDeviceType = NULL; - if (primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secondaryDeviceTypeCount) - { - primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secDeviceType = kmalloc(sizeof(CsrWifiSmeWpsDeviceType) * primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secondaryDeviceTypeCount, GFP_KERNEL); - } - { - u16 i6; - for (i6 = 0; i6 < primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secondaryDeviceTypeCount; i6++) - { - CsrMemCpyDes(primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secDeviceType[i6].deviceDetails, buffer, &offset, ((u16) (8))); - } - } - CsrMemCpyDes(primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.deviceName, buffer, &offset, ((u16) (32))); - CsrUint8Des((u8 *) &primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.deviceNameLength, buffer, &offset); - } - } - break; - case CSR_WIFI_SME_P2P_ROLE_NONE: - CsrUint8Des((u8 *) &primitive->scanResults[i1].deviceInfo.reservedNone.empty, buffer, &offset); - break; - case CSR_WIFI_SME_P2P_ROLE_STANDALONE: - CsrMemCpyDes(primitive->scanResults[i1].deviceInfo.standalonedevInfo.deviceAddress.a, buffer, &offset, ((u16) (6))); - CsrUint16Des((u16 *) &primitive->scanResults[i1].deviceInfo.standalonedevInfo.configMethods, buffer, &offset); - CsrUint8Des((u8 *) &primitive->scanResults[i1].deviceInfo.standalonedevInfo.p2PDeviceCap, buffer, &offset); - CsrMemCpyDes(primitive->scanResults[i1].deviceInfo.standalonedevInfo.primDeviceType.deviceDetails, buffer, &offset, ((u16) (8))); - CsrUint8Des((u8 *) &primitive->scanResults[i1].deviceInfo.standalonedevInfo.secondaryDeviceTypeCount, buffer, &offset); - primitive->scanResults[i1].deviceInfo.standalonedevInfo.secDeviceType = NULL; - if (primitive->scanResults[i1].deviceInfo.standalonedevInfo.secondaryDeviceTypeCount) - { - primitive->scanResults[i1].deviceInfo.standalonedevInfo.secDeviceType = kmalloc(sizeof(CsrWifiSmeWpsDeviceType) * primitive->scanResults[i1].deviceInfo.standalonedevInfo.secondaryDeviceTypeCount, GFP_KERNEL); - } - { - u16 i4; - for (i4 = 0; i4 < primitive->scanResults[i1].deviceInfo.standalonedevInfo.secondaryDeviceTypeCount; i4++) - { - CsrMemCpyDes(primitive->scanResults[i1].deviceInfo.standalonedevInfo.secDeviceType[i4].deviceDetails, buffer, &offset, ((u16) (8))); - } - } - CsrMemCpyDes(primitive->scanResults[i1].deviceInfo.standalonedevInfo.deviceName, buffer, &offset, ((u16) (32))); - CsrUint8Des((u8 *) &primitive->scanResults[i1].deviceInfo.standalonedevInfo.deviceNameLength, buffer, &offset); - break; - default: - break; - } - } - } - - return primitive; -} - - -void CsrWifiSmeScanResultsGetCfmSerFree(void *voidPrimitivePointer) -{ - CsrWifiSmeScanResultsGetCfm *primitive = (CsrWifiSmeScanResultsGetCfm *) voidPrimitivePointer; - { - u16 i1; - for (i1 = 0; i1 < primitive->scanResultsCount; i1++) - { - kfree(primitive->scanResults[i1].informationElements); - switch (primitive->scanResults[i1].p2pDeviceRole) - { - case CSR_WIFI_SME_P2P_ROLE_GO: - { - u16 i4; - for (i4 = 0; i4 < primitive->scanResults[i1].deviceInfo.groupInfo.p2pClientInfoCount; i4++) - { - kfree(primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secDeviceType); - } - } - kfree(primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo); - break; - case CSR_WIFI_SME_P2P_ROLE_STANDALONE: - kfree(primitive->scanResults[i1].deviceInfo.standalonedevInfo.secDeviceType); - break; - default: - break; - } - } - } - kfree(primitive->scanResults); - kfree(primitive); -} - - -size_t CsrWifiSmeSmeStaConfigGetCfmSizeof(void *msg) -{ - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 13) */ - bufferSize += 2; /* u16 primitive->interfaceTag */ - bufferSize += 2; /* CsrResult primitive->status */ - bufferSize += 1; /* u8 primitive->smeConfig.connectionQualityRssiChangeTrigger */ - bufferSize += 1; /* u8 primitive->smeConfig.connectionQualitySnrChangeTrigger */ - bufferSize += 1; /* CsrWifiSmeWmmModeMask primitive->smeConfig.wmmModeMask */ - bufferSize += 1; /* CsrWifiSmeRadioIF primitive->smeConfig.ifIndex */ - bufferSize += 1; /* u8 primitive->smeConfig.allowUnicastUseGroupCipher */ - bufferSize += 1; /* u8 primitive->smeConfig.enableOpportunisticKeyCaching */ - return bufferSize; -} - - -u8* CsrWifiSmeSmeStaConfigGetCfmSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiSmeSmeStaConfigGetCfm *primitive = (CsrWifiSmeSmeStaConfigGetCfm *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag); - CsrUint16Ser(ptr, len, (u16) primitive->status); - CsrUint8Ser(ptr, len, (u8) primitive->smeConfig.connectionQualityRssiChangeTrigger); - CsrUint8Ser(ptr, len, (u8) primitive->smeConfig.connectionQualitySnrChangeTrigger); - CsrUint8Ser(ptr, len, (u8) primitive->smeConfig.wmmModeMask); - CsrUint8Ser(ptr, len, (u8) primitive->smeConfig.ifIndex); - CsrUint8Ser(ptr, len, (u8) primitive->smeConfig.allowUnicastUseGroupCipher); - CsrUint8Ser(ptr, len, (u8) primitive->smeConfig.enableOpportunisticKeyCaching); - return(ptr); -} - - -void* CsrWifiSmeSmeStaConfigGetCfmDes(u8 *buffer, size_t length) -{ - CsrWifiSmeSmeStaConfigGetCfm *primitive = kmalloc(sizeof(CsrWifiSmeSmeStaConfigGetCfm), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset); - CsrUint16Des((u16 *) &primitive->status, buffer, &offset); - CsrUint8Des((u8 *) &primitive->smeConfig.connectionQualityRssiChangeTrigger, buffer, &offset); - CsrUint8Des((u8 *) &primitive->smeConfig.connectionQualitySnrChangeTrigger, buffer, &offset); - CsrUint8Des((u8 *) &primitive->smeConfig.wmmModeMask, buffer, &offset); - CsrUint8Des((u8 *) &primitive->smeConfig.ifIndex, buffer, &offset); - CsrUint8Des((u8 *) &primitive->smeConfig.allowUnicastUseGroupCipher, buffer, &offset); - CsrUint8Des((u8 *) &primitive->smeConfig.enableOpportunisticKeyCaching, buffer, &offset); - - return primitive; -} - - -size_t CsrWifiSmeSmeStaConfigSetCfmSizeof(void *msg) -{ - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 7) */ - bufferSize += 2; /* u16 primitive->interfaceTag */ - bufferSize += 2; /* CsrResult primitive->status */ - return bufferSize; -} - - -u8* CsrWifiSmeSmeStaConfigSetCfmSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiSmeSmeStaConfigSetCfm *primitive = (CsrWifiSmeSmeStaConfigSetCfm *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag); - CsrUint16Ser(ptr, len, (u16) primitive->status); - return(ptr); -} - - -void* CsrWifiSmeSmeStaConfigSetCfmDes(u8 *buffer, size_t length) -{ - CsrWifiSmeSmeStaConfigSetCfm *primitive = kmalloc(sizeof(CsrWifiSmeSmeStaConfigSetCfm), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset); - CsrUint16Des((u16 *) &primitive->status, buffer, &offset); - - return primitive; -} - - -size_t CsrWifiSmeStationMacAddressGetCfmSizeof(void *msg) -{ - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 17) */ - bufferSize += 2; /* CsrResult primitive->status */ - { - u16 i1; - for (i1 = 0; i1 < 2; i1++) - { - bufferSize += 6; /* u8 primitive->stationMacAddress[i1].a[6] */ - } - } - return bufferSize; -} - - -u8* CsrWifiSmeStationMacAddressGetCfmSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiSmeStationMacAddressGetCfm *primitive = (CsrWifiSmeStationMacAddressGetCfm *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->status); - { - u16 i1; - for (i1 = 0; i1 < 2; i1++) - { - CsrMemCpySer(ptr, len, (const void *) primitive->stationMacAddress[i1].a, ((u16) (6))); - } - } - return(ptr); -} - - -void* CsrWifiSmeStationMacAddressGetCfmDes(u8 *buffer, size_t length) -{ - CsrWifiSmeStationMacAddressGetCfm *primitive = kmalloc(sizeof(CsrWifiSmeStationMacAddressGetCfm), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->status, buffer, &offset); - { - u16 i1; - for (i1 = 0; i1 < 2; i1++) - { - CsrMemCpyDes(primitive->stationMacAddress[i1].a, buffer, &offset, ((u16) (6))); - } - } - - return primitive; -} - - -size_t CsrWifiSmeTspecIndSizeof(void *msg) -{ - CsrWifiSmeTspecInd *primitive = (CsrWifiSmeTspecInd *) msg; - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 13) */ - bufferSize += 2; /* u16 primitive->interfaceTag */ - bufferSize += 4; /* u32 primitive->transactionId */ - bufferSize += 1; /* CsrWifiSmeTspecResultCode primitive->tspecResultCode */ - bufferSize += 2; /* u16 primitive->tspecLength */ - bufferSize += primitive->tspecLength; /* u8 primitive->tspec */ - return bufferSize; -} - - -u8* CsrWifiSmeTspecIndSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiSmeTspecInd *primitive = (CsrWifiSmeTspecInd *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag); - CsrUint32Ser(ptr, len, (u32) primitive->transactionId); - CsrUint8Ser(ptr, len, (u8) primitive->tspecResultCode); - CsrUint16Ser(ptr, len, (u16) primitive->tspecLength); - if (primitive->tspecLength) - { - CsrMemCpySer(ptr, len, (const void *) primitive->tspec, ((u16) (primitive->tspecLength))); - } - return(ptr); -} - - -void* CsrWifiSmeTspecIndDes(u8 *buffer, size_t length) -{ - CsrWifiSmeTspecInd *primitive = kmalloc(sizeof(CsrWifiSmeTspecInd), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset); - CsrUint32Des((u32 *) &primitive->transactionId, buffer, &offset); - CsrUint8Des((u8 *) &primitive->tspecResultCode, buffer, &offset); - CsrUint16Des((u16 *) &primitive->tspecLength, buffer, &offset); - if (primitive->tspecLength) - { - primitive->tspec = kmalloc(primitive->tspecLength, GFP_KERNEL); - CsrMemCpyDes(primitive->tspec, buffer, &offset, ((u16) (primitive->tspecLength))); - } - else - { - primitive->tspec = NULL; - } - - return primitive; -} - - -void CsrWifiSmeTspecIndSerFree(void *voidPrimitivePointer) -{ - CsrWifiSmeTspecInd *primitive = (CsrWifiSmeTspecInd *) voidPrimitivePointer; - kfree(primitive->tspec); - kfree(primitive); -} - - -size_t CsrWifiSmeTspecCfmSizeof(void *msg) -{ - CsrWifiSmeTspecCfm *primitive = (CsrWifiSmeTspecCfm *) msg; - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 15) */ - bufferSize += 2; /* u16 primitive->interfaceTag */ - bufferSize += 2; /* CsrResult primitive->status */ - bufferSize += 4; /* u32 primitive->transactionId */ - bufferSize += 1; /* CsrWifiSmeTspecResultCode primitive->tspecResultCode */ - bufferSize += 2; /* u16 primitive->tspecLength */ - bufferSize += primitive->tspecLength; /* u8 primitive->tspec */ - return bufferSize; -} - - -u8* CsrWifiSmeTspecCfmSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiSmeTspecCfm *primitive = (CsrWifiSmeTspecCfm *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag); - CsrUint16Ser(ptr, len, (u16) primitive->status); - CsrUint32Ser(ptr, len, (u32) primitive->transactionId); - CsrUint8Ser(ptr, len, (u8) primitive->tspecResultCode); - CsrUint16Ser(ptr, len, (u16) primitive->tspecLength); - if (primitive->tspecLength) - { - CsrMemCpySer(ptr, len, (const void *) primitive->tspec, ((u16) (primitive->tspecLength))); - } - return(ptr); -} - - -void* CsrWifiSmeTspecCfmDes(u8 *buffer, size_t length) -{ - CsrWifiSmeTspecCfm *primitive = kmalloc(sizeof(CsrWifiSmeTspecCfm), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset); - CsrUint16Des((u16 *) &primitive->status, buffer, &offset); - CsrUint32Des((u32 *) &primitive->transactionId, buffer, &offset); - CsrUint8Des((u8 *) &primitive->tspecResultCode, buffer, &offset); - CsrUint16Des((u16 *) &primitive->tspecLength, buffer, &offset); - if (primitive->tspecLength) - { - primitive->tspec = kmalloc(primitive->tspecLength, GFP_KERNEL); - CsrMemCpyDes(primitive->tspec, buffer, &offset, ((u16) (primitive->tspecLength))); - } - else - { - primitive->tspec = NULL; - } - - return primitive; -} - - -void CsrWifiSmeTspecCfmSerFree(void *voidPrimitivePointer) -{ - CsrWifiSmeTspecCfm *primitive = (CsrWifiSmeTspecCfm *) voidPrimitivePointer; - kfree(primitive->tspec); - kfree(primitive); -} - - -size_t CsrWifiSmeVersionsGetCfmSizeof(void *msg) -{ - CsrWifiSmeVersionsGetCfm *primitive = (CsrWifiSmeVersionsGetCfm *) msg; - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 33) */ - bufferSize += 2; /* CsrResult primitive->status */ - bufferSize += 4; /* u32 primitive->versions.chipId */ - bufferSize += 4; /* u32 primitive->versions.chipVersion */ - bufferSize += 4; /* u32 primitive->versions.firmwareBuild */ - bufferSize += 4; /* u32 primitive->versions.firmwarePatch */ - bufferSize += 4; /* u32 primitive->versions.firmwareHip */ - bufferSize += (primitive->versions.routerBuild ? strlen(primitive->versions.routerBuild) : 0) + 1; /* char* primitive->versions.routerBuild (0 byte len + 1 for NULL Term) */ - bufferSize += 4; /* u32 primitive->versions.routerHip */ - bufferSize += (primitive->versions.smeBuild ? strlen(primitive->versions.smeBuild) : 0) + 1; /* char* primitive->versions.smeBuild (0 byte len + 1 for NULL Term) */ - bufferSize += 4; /* u32 primitive->versions.smeHip */ - return bufferSize; -} - - -u8* CsrWifiSmeVersionsGetCfmSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiSmeVersionsGetCfm *primitive = (CsrWifiSmeVersionsGetCfm *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->status); - CsrUint32Ser(ptr, len, (u32) primitive->versions.chipId); - CsrUint32Ser(ptr, len, (u32) primitive->versions.chipVersion); - CsrUint32Ser(ptr, len, (u32) primitive->versions.firmwareBuild); - CsrUint32Ser(ptr, len, (u32) primitive->versions.firmwarePatch); - CsrUint32Ser(ptr, len, (u32) primitive->versions.firmwareHip); - CsrCharStringSer(ptr, len, primitive->versions.routerBuild); - CsrUint32Ser(ptr, len, (u32) primitive->versions.routerHip); - CsrCharStringSer(ptr, len, primitive->versions.smeBuild); - CsrUint32Ser(ptr, len, (u32) primitive->versions.smeHip); - return(ptr); -} - - -void* CsrWifiSmeVersionsGetCfmDes(u8 *buffer, size_t length) -{ - CsrWifiSmeVersionsGetCfm *primitive = kmalloc(sizeof(CsrWifiSmeVersionsGetCfm), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->status, buffer, &offset); - CsrUint32Des((u32 *) &primitive->versions.chipId, buffer, &offset); - CsrUint32Des((u32 *) &primitive->versions.chipVersion, buffer, &offset); - CsrUint32Des((u32 *) &primitive->versions.firmwareBuild, buffer, &offset); - CsrUint32Des((u32 *) &primitive->versions.firmwarePatch, buffer, &offset); - CsrUint32Des((u32 *) &primitive->versions.firmwareHip, buffer, &offset); - CsrCharStringDes(&primitive->versions.routerBuild, buffer, &offset); - CsrUint32Des((u32 *) &primitive->versions.routerHip, buffer, &offset); - CsrCharStringDes(&primitive->versions.smeBuild, buffer, &offset); - CsrUint32Des((u32 *) &primitive->versions.smeHip, buffer, &offset); - - return primitive; -} - - -void CsrWifiSmeVersionsGetCfmSerFree(void *voidPrimitivePointer) -{ - CsrWifiSmeVersionsGetCfm *primitive = (CsrWifiSmeVersionsGetCfm *) voidPrimitivePointer; - kfree(primitive->versions.routerBuild); - kfree(primitive->versions.smeBuild); - kfree(primitive); -} - - -size_t CsrWifiSmeCloakedSsidsGetCfmSizeof(void *msg) -{ - CsrWifiSmeCloakedSsidsGetCfm *primitive = (CsrWifiSmeCloakedSsidsGetCfm *) msg; - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 39) */ - bufferSize += 2; /* CsrResult primitive->status */ - bufferSize += 1; /* u8 primitive->cloakedSsids.cloakedSsidsCount */ - { - u16 i2; - for (i2 = 0; i2 < primitive->cloakedSsids.cloakedSsidsCount; i2++) - { - bufferSize += 32; /* u8 primitive->cloakedSsids.cloakedSsids[i2].ssid[32] */ - bufferSize += 1; /* u8 primitive->cloakedSsids.cloakedSsids[i2].length */ - } - } - return bufferSize; -} - - -u8* CsrWifiSmeCloakedSsidsGetCfmSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiSmeCloakedSsidsGetCfm *primitive = (CsrWifiSmeCloakedSsidsGetCfm *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->status); - CsrUint8Ser(ptr, len, (u8) primitive->cloakedSsids.cloakedSsidsCount); - { - u16 i2; - for (i2 = 0; i2 < primitive->cloakedSsids.cloakedSsidsCount; i2++) - { - CsrMemCpySer(ptr, len, (const void *) primitive->cloakedSsids.cloakedSsids[i2].ssid, ((u16) (32))); - CsrUint8Ser(ptr, len, (u8) primitive->cloakedSsids.cloakedSsids[i2].length); - } - } - return(ptr); -} - - -void* CsrWifiSmeCloakedSsidsGetCfmDes(u8 *buffer, size_t length) -{ - CsrWifiSmeCloakedSsidsGetCfm *primitive = kmalloc(sizeof(CsrWifiSmeCloakedSsidsGetCfm), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->status, buffer, &offset); - CsrUint8Des((u8 *) &primitive->cloakedSsids.cloakedSsidsCount, buffer, &offset); - primitive->cloakedSsids.cloakedSsids = NULL; - if (primitive->cloakedSsids.cloakedSsidsCount) - { - primitive->cloakedSsids.cloakedSsids = kmalloc(sizeof(CsrWifiSsid) * primitive->cloakedSsids.cloakedSsidsCount, GFP_KERNEL); - } - { - u16 i2; - for (i2 = 0; i2 < primitive->cloakedSsids.cloakedSsidsCount; i2++) - { - CsrMemCpyDes(primitive->cloakedSsids.cloakedSsids[i2].ssid, buffer, &offset, ((u16) (32))); - CsrUint8Des((u8 *) &primitive->cloakedSsids.cloakedSsids[i2].length, buffer, &offset); - } - } - - return primitive; -} - - -void CsrWifiSmeCloakedSsidsGetCfmSerFree(void *voidPrimitivePointer) -{ - CsrWifiSmeCloakedSsidsGetCfm *primitive = (CsrWifiSmeCloakedSsidsGetCfm *) voidPrimitivePointer; - kfree(primitive->cloakedSsids.cloakedSsids); - kfree(primitive); -} - - -size_t CsrWifiSmeWifiOnIndSizeof(void *msg) -{ - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 9) */ - bufferSize += 6; /* u8 primitive->address.a[6] */ - return bufferSize; -} - - -u8* CsrWifiSmeWifiOnIndSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiSmeWifiOnInd *primitive = (CsrWifiSmeWifiOnInd *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrMemCpySer(ptr, len, (const void *) primitive->address.a, ((u16) (6))); - return(ptr); -} - - -void* CsrWifiSmeWifiOnIndDes(u8 *buffer, size_t length) -{ - CsrWifiSmeWifiOnInd *primitive = kmalloc(sizeof(CsrWifiSmeWifiOnInd), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrMemCpyDes(primitive->address.a, buffer, &offset, ((u16) (6))); - - return primitive; -} - - -size_t CsrWifiSmeSmeCommonConfigGetCfmSizeof(void *msg) -{ - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 10) */ - bufferSize += 2; /* CsrResult primitive->status */ - bufferSize += 1; /* CsrWifiSme80211dTrustLevel primitive->deviceConfig.trustLevel */ - bufferSize += 2; /* u8 primitive->deviceConfig.countryCode[2] */ - bufferSize += 1; /* CsrWifiSmeFirmwareDriverInterface primitive->deviceConfig.firmwareDriverInterface */ - bufferSize += 1; /* u8 primitive->deviceConfig.enableStrictDraftN */ - return bufferSize; -} - - -u8* CsrWifiSmeSmeCommonConfigGetCfmSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiSmeSmeCommonConfigGetCfm *primitive = (CsrWifiSmeSmeCommonConfigGetCfm *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->status); - CsrUint8Ser(ptr, len, (u8) primitive->deviceConfig.trustLevel); - CsrMemCpySer(ptr, len, (const void *) primitive->deviceConfig.countryCode, ((u16) (2))); - CsrUint8Ser(ptr, len, (u8) primitive->deviceConfig.firmwareDriverInterface); - CsrUint8Ser(ptr, len, (u8) primitive->deviceConfig.enableStrictDraftN); - return(ptr); -} - - -void* CsrWifiSmeSmeCommonConfigGetCfmDes(u8 *buffer, size_t length) -{ - CsrWifiSmeSmeCommonConfigGetCfm *primitive = kmalloc(sizeof(CsrWifiSmeSmeCommonConfigGetCfm), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->status, buffer, &offset); - CsrUint8Des((u8 *) &primitive->deviceConfig.trustLevel, buffer, &offset); - CsrMemCpyDes(primitive->deviceConfig.countryCode, buffer, &offset, ((u16) (2))); - CsrUint8Des((u8 *) &primitive->deviceConfig.firmwareDriverInterface, buffer, &offset); - CsrUint8Des((u8 *) &primitive->deviceConfig.enableStrictDraftN, buffer, &offset); - - return primitive; -} - - -size_t CsrWifiSmeInterfaceCapabilityGetCfmSizeof(void *msg) -{ - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 9) */ - bufferSize += 2; /* CsrResult primitive->status */ - bufferSize += 2; /* u16 primitive->numInterfaces */ - bufferSize += 2; /* u8 primitive->capBitmap[2] */ - return bufferSize; -} - - -u8* CsrWifiSmeInterfaceCapabilityGetCfmSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiSmeInterfaceCapabilityGetCfm *primitive = (CsrWifiSmeInterfaceCapabilityGetCfm *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint16Ser(ptr, len, (u16) primitive->status); - CsrUint16Ser(ptr, len, (u16) primitive->numInterfaces); - CsrMemCpySer(ptr, len, (const void *) primitive->capBitmap, ((u16) (2))); - return(ptr); -} - - -void* CsrWifiSmeInterfaceCapabilityGetCfmDes(u8 *buffer, size_t length) -{ - CsrWifiSmeInterfaceCapabilityGetCfm *primitive = kmalloc(sizeof(CsrWifiSmeInterfaceCapabilityGetCfm), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint16Des((u16 *) &primitive->status, buffer, &offset); - CsrUint16Des((u16 *) &primitive->numInterfaces, buffer, &offset); - CsrMemCpyDes(primitive->capBitmap, buffer, &offset, ((u16) (2))); - - return primitive; -} - - -size_t CsrWifiSmeErrorIndSizeof(void *msg) -{ - CsrWifiSmeErrorInd *primitive = (CsrWifiSmeErrorInd *) msg; - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 3) */ - bufferSize += (primitive->errorMessage ? strlen(primitive->errorMessage) : 0) + 1; /* char* primitive->errorMessage (0 byte len + 1 for NULL Term) */ - return bufferSize; -} - - -u8* CsrWifiSmeErrorIndSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiSmeErrorInd *primitive = (CsrWifiSmeErrorInd *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrCharStringSer(ptr, len, primitive->errorMessage); - return(ptr); -} - - -void* CsrWifiSmeErrorIndDes(u8 *buffer, size_t length) -{ - CsrWifiSmeErrorInd *primitive = kmalloc(sizeof(CsrWifiSmeErrorInd), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrCharStringDes(&primitive->errorMessage, buffer, &offset); - - return primitive; -} - - -void CsrWifiSmeErrorIndSerFree(void *voidPrimitivePointer) -{ - CsrWifiSmeErrorInd *primitive = (CsrWifiSmeErrorInd *) voidPrimitivePointer; - kfree(primitive->errorMessage); - kfree(primitive); -} - - -size_t CsrWifiSmeInfoIndSizeof(void *msg) -{ - CsrWifiSmeInfoInd *primitive = (CsrWifiSmeInfoInd *) msg; - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 3) */ - bufferSize += (primitive->infoMessage ? strlen(primitive->infoMessage) : 0) + 1; /* char* primitive->infoMessage (0 byte len + 1 for NULL Term) */ - return bufferSize; -} - - -u8* CsrWifiSmeInfoIndSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiSmeInfoInd *primitive = (CsrWifiSmeInfoInd *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrCharStringSer(ptr, len, primitive->infoMessage); - return(ptr); -} - - -void* CsrWifiSmeInfoIndDes(u8 *buffer, size_t length) -{ - CsrWifiSmeInfoInd *primitive = kmalloc(sizeof(CsrWifiSmeInfoInd), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrCharStringDes(&primitive->infoMessage, buffer, &offset); - - return primitive; -} - - -void CsrWifiSmeInfoIndSerFree(void *voidPrimitivePointer) -{ - CsrWifiSmeInfoInd *primitive = (CsrWifiSmeInfoInd *) voidPrimitivePointer; - kfree(primitive->infoMessage); - kfree(primitive); -} - - -size_t CsrWifiSmeCoreDumpIndSizeof(void *msg) -{ - CsrWifiSmeCoreDumpInd *primitive = (CsrWifiSmeCoreDumpInd *) msg; - size_t bufferSize = 2; - - /* Calculate the Size of the Serialised Data. Could be more efficient (Try 8) */ - bufferSize += 4; /* u32 primitive->dataLength */ - bufferSize += primitive->dataLength; /* u8 primitive->data */ - return bufferSize; -} - - -u8* CsrWifiSmeCoreDumpIndSer(u8 *ptr, size_t *len, void *msg) -{ - CsrWifiSmeCoreDumpInd *primitive = (CsrWifiSmeCoreDumpInd *)msg; - *len = 0; - CsrUint16Ser(ptr, len, primitive->common.type); - CsrUint32Ser(ptr, len, (u32) primitive->dataLength); - if (primitive->dataLength) - { - CsrMemCpySer(ptr, len, (const void *) primitive->data, ((u16) (primitive->dataLength))); - } - return(ptr); -} - - -void* CsrWifiSmeCoreDumpIndDes(u8 *buffer, size_t length) -{ - CsrWifiSmeCoreDumpInd *primitive = kmalloc(sizeof(CsrWifiSmeCoreDumpInd), GFP_KERNEL); - size_t offset; - offset = 0; - - CsrUint16Des(&primitive->common.type, buffer, &offset); - CsrUint32Des((u32 *) &primitive->dataLength, buffer, &offset); - if (primitive->dataLength) - { - primitive->data = kmalloc(primitive->dataLength, GFP_KERNEL); - CsrMemCpyDes(primitive->data, buffer, &offset, ((u16) (primitive->dataLength))); - } - else - { - primitive->data = NULL; - } - - return primitive; -} - - -void CsrWifiSmeCoreDumpIndSerFree(void *voidPrimitivePointer) -{ - CsrWifiSmeCoreDumpInd *primitive = (CsrWifiSmeCoreDumpInd *) voidPrimitivePointer; - kfree(primitive->data); - kfree(primitive); -} - - diff --git a/drivers/staging/csr/csr_wifi_sme_serialize.h b/drivers/staging/csr/csr_wifi_sme_serialize.h deleted file mode 100644 index f8526269b203..000000000000 --- a/drivers/staging/csr/csr_wifi_sme_serialize.h +++ /dev/null @@ -1,666 +0,0 @@ -/***************************************************************************** - - (c) Cambridge Silicon Radio Limited 2012 - All rights reserved and confidential information of CSR - - Refer to LICENSE.txt included with this source for details - on the license terms. - -*****************************************************************************/ - -/* Note: this is an auto-generated file. */ - -#ifndef CSR_WIFI_SME_SERIALIZE_H__ -#define CSR_WIFI_SME_SERIALIZE_H__ - -#include "csr_wifi_msgconv.h" -#include "csr_wifi_sme_prim.h" - -extern void CsrWifiSmePfree(void *ptr); - -#define CsrWifiSmeActivateReqSer CsrWifiEventSer -#define CsrWifiSmeActivateReqDes CsrWifiEventDes -#define CsrWifiSmeActivateReqSizeof CsrWifiEventSizeof -#define CsrWifiSmeActivateReqSerFree CsrWifiSmePfree - -#define CsrWifiSmeAdhocConfigGetReqSer CsrWifiEventSer -#define CsrWifiSmeAdhocConfigGetReqDes CsrWifiEventDes -#define CsrWifiSmeAdhocConfigGetReqSizeof CsrWifiEventSizeof -#define CsrWifiSmeAdhocConfigGetReqSerFree CsrWifiSmePfree - -extern u8 *CsrWifiSmeAdhocConfigSetReqSer(u8 *ptr, size_t *len, void *msg); -extern void *CsrWifiSmeAdhocConfigSetReqDes(u8 *buffer, size_t len); -extern size_t CsrWifiSmeAdhocConfigSetReqSizeof(void *msg); -#define CsrWifiSmeAdhocConfigSetReqSerFree CsrWifiSmePfree - -extern u8 *CsrWifiSmeBlacklistReqSer(u8 *ptr, size_t *len, void *msg); -extern void *CsrWifiSmeBlacklistReqDes(u8 *buffer, size_t len); -extern size_t CsrWifiSmeBlacklistReqSizeof(void *msg); -extern void CsrWifiSmeBlacklistReqSerFree(void *msg); - -#define CsrWifiSmeCalibrationDataGetReqSer CsrWifiEventSer -#define CsrWifiSmeCalibrationDataGetReqDes CsrWifiEventDes -#define CsrWifiSmeCalibrationDataGetReqSizeof CsrWifiEventSizeof -#define CsrWifiSmeCalibrationDataGetReqSerFree CsrWifiSmePfree - -extern u8 *CsrWifiSmeCalibrationDataSetReqSer(u8 *ptr, size_t *len, void *msg); -extern void *CsrWifiSmeCalibrationDataSetReqDes(u8 *buffer, size_t len); -extern size_t CsrWifiSmeCalibrationDataSetReqSizeof(void *msg); -extern void CsrWifiSmeCalibrationDataSetReqSerFree(void *msg); - -#define CsrWifiSmeCcxConfigGetReqSer CsrWifiEventCsrUint16Ser -#define CsrWifiSmeCcxConfigGetReqDes CsrWifiEventCsrUint16Des -#define CsrWifiSmeCcxConfigGetReqSizeof CsrWifiEventCsrUint16Sizeof -#define CsrWifiSmeCcxConfigGetReqSerFree CsrWifiSmePfree - -extern u8 *CsrWifiSmeCcxConfigSetReqSer(u8 *ptr, size_t *len, void *msg); -extern void *CsrWifiSmeCcxConfigSetReqDes(u8 *buffer, size_t len); -extern size_t CsrWifiSmeCcxConfigSetReqSizeof(void *msg); -#define CsrWifiSmeCcxConfigSetReqSerFree CsrWifiSmePfree - -#define CsrWifiSmeCoexConfigGetReqSer CsrWifiEventSer -#define CsrWifiSmeCoexConfigGetReqDes CsrWifiEventDes -#define CsrWifiSmeCoexConfigGetReqSizeof CsrWifiEventSizeof -#define CsrWifiSmeCoexConfigGetReqSerFree CsrWifiSmePfree - -extern u8 *CsrWifiSmeCoexConfigSetReqSer(u8 *ptr, size_t *len, void *msg); -extern void *CsrWifiSmeCoexConfigSetReqDes(u8 *buffer, size_t len); -extern size_t CsrWifiSmeCoexConfigSetReqSizeof(void *msg); -#define CsrWifiSmeCoexConfigSetReqSerFree CsrWifiSmePfree - -#define CsrWifiSmeCoexInfoGetReqSer CsrWifiEventSer -#define CsrWifiSmeCoexInfoGetReqDes CsrWifiEventDes -#define CsrWifiSmeCoexInfoGetReqSizeof CsrWifiEventSizeof -#define CsrWifiSmeCoexInfoGetReqSerFree CsrWifiSmePfree - -extern u8 *CsrWifiSmeConnectReqSer(u8 *ptr, size_t *len, void *msg); -extern void *CsrWifiSmeConnectReqDes(u8 *buffer, size_t len); -extern size_t CsrWifiSmeConnectReqSizeof(void *msg); -extern void CsrWifiSmeConnectReqSerFree(void *msg); - -#define CsrWifiSmeConnectionConfigGetReqSer CsrWifiEventCsrUint16Ser -#define CsrWifiSmeConnectionConfigGetReqDes CsrWifiEventCsrUint16Des -#define CsrWifiSmeConnectionConfigGetReqSizeof CsrWifiEventCsrUint16Sizeof -#define CsrWifiSmeConnectionConfigGetReqSerFree CsrWifiSmePfree - -#define CsrWifiSmeConnectionInfoGetReqSer CsrWifiEventCsrUint16Ser -#define CsrWifiSmeConnectionInfoGetReqDes CsrWifiEventCsrUint16Des -#define CsrWifiSmeConnectionInfoGetReqSizeof CsrWifiEventCsrUint16Sizeof -#define CsrWifiSmeConnectionInfoGetReqSerFree CsrWifiSmePfree - -#define CsrWifiSmeConnectionStatsGetReqSer CsrWifiEventCsrUint16Ser -#define CsrWifiSmeConnectionStatsGetReqDes CsrWifiEventCsrUint16Des -#define CsrWifiSmeConnectionStatsGetReqSizeof CsrWifiEventCsrUint16Sizeof -#define CsrWifiSmeConnectionStatsGetReqSerFree CsrWifiSmePfree - -#define CsrWifiSmeDeactivateReqSer CsrWifiEventSer -#define CsrWifiSmeDeactivateReqDes CsrWifiEventDes -#define CsrWifiSmeDeactivateReqSizeof CsrWifiEventSizeof -#define CsrWifiSmeDeactivateReqSerFree CsrWifiSmePfree - -#define CsrWifiSmeDisconnectReqSer CsrWifiEventCsrUint16Ser -#define CsrWifiSmeDisconnectReqDes CsrWifiEventCsrUint16Des -#define CsrWifiSmeDisconnectReqSizeof CsrWifiEventCsrUint16Sizeof -#define CsrWifiSmeDisconnectReqSerFree CsrWifiSmePfree - -#define CsrWifiSmeEventMaskSetReqSer CsrWifiEventCsrUint32Ser -#define CsrWifiSmeEventMaskSetReqDes CsrWifiEventCsrUint32Des -#define CsrWifiSmeEventMaskSetReqSizeof CsrWifiEventCsrUint32Sizeof -#define CsrWifiSmeEventMaskSetReqSerFree CsrWifiSmePfree - -#define CsrWifiSmeHostConfigGetReqSer CsrWifiEventCsrUint16Ser -#define CsrWifiSmeHostConfigGetReqDes CsrWifiEventCsrUint16Des -#define CsrWifiSmeHostConfigGetReqSizeof CsrWifiEventCsrUint16Sizeof -#define CsrWifiSmeHostConfigGetReqSerFree CsrWifiSmePfree - -extern u8 *CsrWifiSmeHostConfigSetReqSer(u8 *ptr, size_t *len, void *msg); -extern void *CsrWifiSmeHostConfigSetReqDes(u8 *buffer, size_t len); -extern size_t CsrWifiSmeHostConfigSetReqSizeof(void *msg); -#define CsrWifiSmeHostConfigSetReqSerFree CsrWifiSmePfree - -extern u8 *CsrWifiSmeKeyReqSer(u8 *ptr, size_t *len, void *msg); -extern void *CsrWifiSmeKeyReqDes(u8 *buffer, size_t len); -extern size_t CsrWifiSmeKeyReqSizeof(void *msg); -#define CsrWifiSmeKeyReqSerFree CsrWifiSmePfree - -#define CsrWifiSmeLinkQualityGetReqSer CsrWifiEventCsrUint16Ser -#define CsrWifiSmeLinkQualityGetReqDes CsrWifiEventCsrUint16Des -#define CsrWifiSmeLinkQualityGetReqSizeof CsrWifiEventCsrUint16Sizeof -#define CsrWifiSmeLinkQualityGetReqSerFree CsrWifiSmePfree - -#define CsrWifiSmeMibConfigGetReqSer CsrWifiEventSer -#define CsrWifiSmeMibConfigGetReqDes CsrWifiEventDes -#define CsrWifiSmeMibConfigGetReqSizeof CsrWifiEventSizeof -#define CsrWifiSmeMibConfigGetReqSerFree CsrWifiSmePfree - -extern u8 *CsrWifiSmeMibConfigSetReqSer(u8 *ptr, size_t *len, void *msg); -extern void *CsrWifiSmeMibConfigSetReqDes(u8 *buffer, size_t len); -extern size_t CsrWifiSmeMibConfigSetReqSizeof(void *msg); -#define CsrWifiSmeMibConfigSetReqSerFree CsrWifiSmePfree - -extern u8 *CsrWifiSmeMibGetNextReqSer(u8 *ptr, size_t *len, void *msg); -extern void *CsrWifiSmeMibGetNextReqDes(u8 *buffer, size_t len); -extern size_t CsrWifiSmeMibGetNextReqSizeof(void *msg); -extern void CsrWifiSmeMibGetNextReqSerFree(void *msg); - -extern u8 *CsrWifiSmeMibGetReqSer(u8 *ptr, size_t *len, void *msg); -extern void *CsrWifiSmeMibGetReqDes(u8 *buffer, size_t len); -extern size_t CsrWifiSmeMibGetReqSizeof(void *msg); -extern void CsrWifiSmeMibGetReqSerFree(void *msg); - -extern u8 *CsrWifiSmeMibSetReqSer(u8 *ptr, size_t *len, void *msg); -extern void *CsrWifiSmeMibSetReqDes(u8 *buffer, size_t len); -extern size_t CsrWifiSmeMibSetReqSizeof(void *msg); -extern void CsrWifiSmeMibSetReqSerFree(void *msg); - -extern u8 *CsrWifiSmeMulticastAddressReqSer(u8 *ptr, size_t *len, void *msg); -extern void *CsrWifiSmeMulticastAddressReqDes(u8 *buffer, size_t len); -extern size_t CsrWifiSmeMulticastAddressReqSizeof(void *msg); -extern void CsrWifiSmeMulticastAddressReqSerFree(void *msg); - -extern u8 *CsrWifiSmePacketFilterSetReqSer(u8 *ptr, size_t *len, void *msg); -extern void *CsrWifiSmePacketFilterSetReqDes(u8 *buffer, size_t len); -extern size_t CsrWifiSmePacketFilterSetReqSizeof(void *msg); -extern void CsrWifiSmePacketFilterSetReqSerFree(void *msg); - -#define CsrWifiSmePermanentMacAddressGetReqSer CsrWifiEventSer -#define CsrWifiSmePermanentMacAddressGetReqDes CsrWifiEventDes -#define CsrWifiSmePermanentMacAddressGetReqSizeof CsrWifiEventSizeof -#define CsrWifiSmePermanentMacAddressGetReqSerFree CsrWifiSmePfree - -extern u8 *CsrWifiSmePmkidReqSer(u8 *ptr, size_t *len, void *msg); -extern void *CsrWifiSmePmkidReqDes(u8 *buffer, size_t len); -extern size_t CsrWifiSmePmkidReqSizeof(void *msg); -extern void CsrWifiSmePmkidReqSerFree(void *msg); - -#define CsrWifiSmePowerConfigGetReqSer CsrWifiEventSer -#define CsrWifiSmePowerConfigGetReqDes CsrWifiEventDes -#define CsrWifiSmePowerConfigGetReqSizeof CsrWifiEventSizeof -#define CsrWifiSmePowerConfigGetReqSerFree CsrWifiSmePfree - -extern u8 *CsrWifiSmePowerConfigSetReqSer(u8 *ptr, size_t *len, void *msg); -extern void *CsrWifiSmePowerConfigSetReqDes(u8 *buffer, size_t len); -extern size_t CsrWifiSmePowerConfigSetReqSizeof(void *msg); -#define CsrWifiSmePowerConfigSetReqSerFree CsrWifiSmePfree - -#define CsrWifiSmeRegulatoryDomainInfoGetReqSer CsrWifiEventSer -#define CsrWifiSmeRegulatoryDomainInfoGetReqDes CsrWifiEventDes -#define CsrWifiSmeRegulatoryDomainInfoGetReqSizeof CsrWifiEventSizeof -#define CsrWifiSmeRegulatoryDomainInfoGetReqSerFree CsrWifiSmePfree - -#define CsrWifiSmeRoamingConfigGetReqSer CsrWifiEventCsrUint16Ser -#define CsrWifiSmeRoamingConfigGetReqDes CsrWifiEventCsrUint16Des -#define CsrWifiSmeRoamingConfigGetReqSizeof CsrWifiEventCsrUint16Sizeof -#define CsrWifiSmeRoamingConfigGetReqSerFree CsrWifiSmePfree - -extern u8 *CsrWifiSmeRoamingConfigSetReqSer(u8 *ptr, size_t *len, void *msg); -extern void *CsrWifiSmeRoamingConfigSetReqDes(u8 *buffer, size_t len); -extern size_t CsrWifiSmeRoamingConfigSetReqSizeof(void *msg); -#define CsrWifiSmeRoamingConfigSetReqSerFree CsrWifiSmePfree - -#define CsrWifiSmeScanConfigGetReqSer CsrWifiEventSer -#define CsrWifiSmeScanConfigGetReqDes CsrWifiEventDes -#define CsrWifiSmeScanConfigGetReqSizeof CsrWifiEventSizeof -#define CsrWifiSmeScanConfigGetReqSerFree CsrWifiSmePfree - -extern u8 *CsrWifiSmeScanConfigSetReqSer(u8 *ptr, size_t *len, void *msg); -extern void *CsrWifiSmeScanConfigSetReqDes(u8 *buffer, size_t len); -extern size_t CsrWifiSmeScanConfigSetReqSizeof(void *msg); -extern void CsrWifiSmeScanConfigSetReqSerFree(void *msg); - -extern u8 *CsrWifiSmeScanFullReqSer(u8 *ptr, size_t *len, void *msg); -extern void *CsrWifiSmeScanFullReqDes(u8 *buffer, size_t len); -extern size_t CsrWifiSmeScanFullReqSizeof(void *msg); -extern void CsrWifiSmeScanFullReqSerFree(void *msg); - -#define CsrWifiSmeScanResultsFlushReqSer CsrWifiEventSer -#define CsrWifiSmeScanResultsFlushReqDes CsrWifiEventDes -#define CsrWifiSmeScanResultsFlushReqSizeof CsrWifiEventSizeof -#define CsrWifiSmeScanResultsFlushReqSerFree CsrWifiSmePfree - -#define CsrWifiSmeScanResultsGetReqSer CsrWifiEventSer -#define CsrWifiSmeScanResultsGetReqDes CsrWifiEventDes -#define CsrWifiSmeScanResultsGetReqSizeof CsrWifiEventSizeof -#define CsrWifiSmeScanResultsGetReqSerFree CsrWifiSmePfree - -#define CsrWifiSmeSmeStaConfigGetReqSer CsrWifiEventCsrUint16Ser -#define CsrWifiSmeSmeStaConfigGetReqDes CsrWifiEventCsrUint16Des -#define CsrWifiSmeSmeStaConfigGetReqSizeof CsrWifiEventCsrUint16Sizeof -#define CsrWifiSmeSmeStaConfigGetReqSerFree CsrWifiSmePfree - -extern u8 *CsrWifiSmeSmeStaConfigSetReqSer(u8 *ptr, size_t *len, void *msg); -extern void *CsrWifiSmeSmeStaConfigSetReqDes(u8 *buffer, size_t len); -extern size_t CsrWifiSmeSmeStaConfigSetReqSizeof(void *msg); -#define CsrWifiSmeSmeStaConfigSetReqSerFree CsrWifiSmePfree - -#define CsrWifiSmeStationMacAddressGetReqSer CsrWifiEventSer -#define CsrWifiSmeStationMacAddressGetReqDes CsrWifiEventDes -#define CsrWifiSmeStationMacAddressGetReqSizeof CsrWifiEventSizeof -#define CsrWifiSmeStationMacAddressGetReqSerFree CsrWifiSmePfree - -extern u8 *CsrWifiSmeTspecReqSer(u8 *ptr, size_t *len, void *msg); -extern void *CsrWifiSmeTspecReqDes(u8 *buffer, size_t len); -extern size_t CsrWifiSmeTspecReqSizeof(void *msg); -extern void CsrWifiSmeTspecReqSerFree(void *msg); - -#define CsrWifiSmeVersionsGetReqSer CsrWifiEventSer -#define CsrWifiSmeVersionsGetReqDes CsrWifiEventDes -#define CsrWifiSmeVersionsGetReqSizeof CsrWifiEventSizeof -#define CsrWifiSmeVersionsGetReqSerFree CsrWifiSmePfree - -extern u8 *CsrWifiSmeWifiFlightmodeReqSer(u8 *ptr, size_t *len, void *msg); -extern void *CsrWifiSmeWifiFlightmodeReqDes(u8 *buffer, size_t len); -extern size_t CsrWifiSmeWifiFlightmodeReqSizeof(void *msg); -extern void CsrWifiSmeWifiFlightmodeReqSerFree(void *msg); - -#define CsrWifiSmeWifiOffReqSer CsrWifiEventSer -#define CsrWifiSmeWifiOffReqDes CsrWifiEventDes -#define CsrWifiSmeWifiOffReqSizeof CsrWifiEventSizeof -#define CsrWifiSmeWifiOffReqSerFree CsrWifiSmePfree - -extern u8 *CsrWifiSmeWifiOnReqSer(u8 *ptr, size_t *len, void *msg); -extern void *CsrWifiSmeWifiOnReqDes(u8 *buffer, size_t len); -extern size_t CsrWifiSmeWifiOnReqSizeof(void *msg); -extern void CsrWifiSmeWifiOnReqSerFree(void *msg); - -extern u8 *CsrWifiSmeCloakedSsidsSetReqSer(u8 *ptr, size_t *len, void *msg); -extern void *CsrWifiSmeCloakedSsidsSetReqDes(u8 *buffer, size_t len); -extern size_t CsrWifiSmeCloakedSsidsSetReqSizeof(void *msg); -extern void CsrWifiSmeCloakedSsidsSetReqSerFree(void *msg); - -#define CsrWifiSmeCloakedSsidsGetReqSer CsrWifiEventSer -#define CsrWifiSmeCloakedSsidsGetReqDes CsrWifiEventDes -#define CsrWifiSmeCloakedSsidsGetReqSizeof CsrWifiEventSizeof -#define CsrWifiSmeCloakedSsidsGetReqSerFree CsrWifiSmePfree - -#define CsrWifiSmeSmeCommonConfigGetReqSer CsrWifiEventSer -#define CsrWifiSmeSmeCommonConfigGetReqDes CsrWifiEventDes -#define CsrWifiSmeSmeCommonConfigGetReqSizeof CsrWifiEventSizeof -#define CsrWifiSmeSmeCommonConfigGetReqSerFree CsrWifiSmePfree - -extern u8 *CsrWifiSmeSmeCommonConfigSetReqSer(u8 *ptr, size_t *len, void *msg); -extern void *CsrWifiSmeSmeCommonConfigSetReqDes(u8 *buffer, size_t len); -extern size_t CsrWifiSmeSmeCommonConfigSetReqSizeof(void *msg); -#define CsrWifiSmeSmeCommonConfigSetReqSerFree CsrWifiSmePfree - -#define CsrWifiSmeInterfaceCapabilityGetReqSer CsrWifiEventSer -#define CsrWifiSmeInterfaceCapabilityGetReqDes CsrWifiEventDes -#define CsrWifiSmeInterfaceCapabilityGetReqSizeof CsrWifiEventSizeof -#define CsrWifiSmeInterfaceCapabilityGetReqSerFree CsrWifiSmePfree - -extern u8 *CsrWifiSmeWpsConfigurationReqSer(u8 *ptr, size_t *len, void *msg); -extern void *CsrWifiSmeWpsConfigurationReqDes(u8 *buffer, size_t len); -extern size_t CsrWifiSmeWpsConfigurationReqSizeof(void *msg); -extern void CsrWifiSmeWpsConfigurationReqSerFree(void *msg); - -extern u8 *CsrWifiSmeSetReqSer(u8 *ptr, size_t *len, void *msg); -extern void *CsrWifiSmeSetReqDes(u8 *buffer, size_t len); -extern size_t CsrWifiSmeSetReqSizeof(void *msg); -extern void CsrWifiSmeSetReqSerFree(void *msg); - -#define CsrWifiSmeActivateCfmSer CsrWifiEventCsrUint16Ser -#define CsrWifiSmeActivateCfmDes CsrWifiEventCsrUint16Des -#define CsrWifiSmeActivateCfmSizeof CsrWifiEventCsrUint16Sizeof -#define CsrWifiSmeActivateCfmSerFree CsrWifiSmePfree - -extern u8 *CsrWifiSmeAdhocConfigGetCfmSer(u8 *ptr, size_t *len, void *msg); -extern void *CsrWifiSmeAdhocConfigGetCfmDes(u8 *buffer, size_t len); -extern size_t CsrWifiSmeAdhocConfigGetCfmSizeof(void *msg); -#define CsrWifiSmeAdhocConfigGetCfmSerFree CsrWifiSmePfree - -#define CsrWifiSmeAdhocConfigSetCfmSer CsrWifiEventCsrUint16Ser -#define CsrWifiSmeAdhocConfigSetCfmDes CsrWifiEventCsrUint16Des -#define CsrWifiSmeAdhocConfigSetCfmSizeof CsrWifiEventCsrUint16Sizeof -#define CsrWifiSmeAdhocConfigSetCfmSerFree CsrWifiSmePfree - -extern u8 *CsrWifiSmeAssociationCompleteIndSer(u8 *ptr, size_t *len, void *msg); -extern void *CsrWifiSmeAssociationCompleteIndDes(u8 *buffer, size_t len); -extern size_t CsrWifiSmeAssociationCompleteIndSizeof(void *msg); -extern void CsrWifiSmeAssociationCompleteIndSerFree(void *msg); - -extern u8 *CsrWifiSmeAssociationStartIndSer(u8 *ptr, size_t *len, void *msg); -extern void *CsrWifiSmeAssociationStartIndDes(u8 *buffer, size_t len); -extern size_t CsrWifiSmeAssociationStartIndSizeof(void *msg); -#define CsrWifiSmeAssociationStartIndSerFree CsrWifiSmePfree - -extern u8 *CsrWifiSmeBlacklistCfmSer(u8 *ptr, size_t *len, void *msg); -extern void *CsrWifiSmeBlacklistCfmDes(u8 *buffer, size_t len); -extern size_t CsrWifiSmeBlacklistCfmSizeof(void *msg); -extern void CsrWifiSmeBlacklistCfmSerFree(void *msg); - -extern u8 *CsrWifiSmeCalibrationDataGetCfmSer(u8 *ptr, size_t *len, void *msg); -extern void *CsrWifiSmeCalibrationDataGetCfmDes(u8 *buffer, size_t len); -extern size_t CsrWifiSmeCalibrationDataGetCfmSizeof(void *msg); -extern void CsrWifiSmeCalibrationDataGetCfmSerFree(void *msg); - -#define CsrWifiSmeCalibrationDataSetCfmSer CsrWifiEventCsrUint16Ser -#define CsrWifiSmeCalibrationDataSetCfmDes CsrWifiEventCsrUint16Des -#define CsrWifiSmeCalibrationDataSetCfmSizeof CsrWifiEventCsrUint16Sizeof -#define CsrWifiSmeCalibrationDataSetCfmSerFree CsrWifiSmePfree - -extern u8 *CsrWifiSmeCcxConfigGetCfmSer(u8 *ptr, size_t *len, void *msg); -extern void *CsrWifiSmeCcxConfigGetCfmDes(u8 *buffer, size_t len); -extern size_t CsrWifiSmeCcxConfigGetCfmSizeof(void *msg); -#define CsrWifiSmeCcxConfigGetCfmSerFree CsrWifiSmePfree - -extern u8 *CsrWifiSmeCcxConfigSetCfmSer(u8 *ptr, size_t *len, void *msg); -extern void *CsrWifiSmeCcxConfigSetCfmDes(u8 *buffer, size_t len); -extern size_t CsrWifiSmeCcxConfigSetCfmSizeof(void *msg); -#define CsrWifiSmeCcxConfigSetCfmSerFree CsrWifiSmePfree - -extern u8 *CsrWifiSmeCoexConfigGetCfmSer(u8 *ptr, size_t *len, void *msg); -extern void *CsrWifiSmeCoexConfigGetCfmDes(u8 *buffer, size_t len); -extern size_t CsrWifiSmeCoexConfigGetCfmSizeof(void *msg); -#define CsrWifiSmeCoexConfigGetCfmSerFree CsrWifiSmePfree - -#define CsrWifiSmeCoexConfigSetCfmSer CsrWifiEventCsrUint16Ser -#define CsrWifiSmeCoexConfigSetCfmDes CsrWifiEventCsrUint16Des -#define CsrWifiSmeCoexConfigSetCfmSizeof CsrWifiEventCsrUint16Sizeof -#define CsrWifiSmeCoexConfigSetCfmSerFree CsrWifiSmePfree - -extern u8 *CsrWifiSmeCoexInfoGetCfmSer(u8 *ptr, size_t *len, void *msg); -extern void *CsrWifiSmeCoexInfoGetCfmDes(u8 *buffer, size_t len); -extern size_t CsrWifiSmeCoexInfoGetCfmSizeof(void *msg); -#define CsrWifiSmeCoexInfoGetCfmSerFree CsrWifiSmePfree - -extern u8 *CsrWifiSmeConnectCfmSer(u8 *ptr, size_t *len, void *msg); -extern void *CsrWifiSmeConnectCfmDes(u8 *buffer, size_t len); -extern size_t CsrWifiSmeConnectCfmSizeof(void *msg); -#define CsrWifiSmeConnectCfmSerFree CsrWifiSmePfree - -extern u8 *CsrWifiSmeConnectionConfigGetCfmSer(u8 *ptr, size_t *len, void *msg); -extern void *CsrWifiSmeConnectionConfigGetCfmDes(u8 *buffer, size_t len); -extern size_t CsrWifiSmeConnectionConfigGetCfmSizeof(void *msg); -extern void CsrWifiSmeConnectionConfigGetCfmSerFree(void *msg); - -extern u8 *CsrWifiSmeConnectionInfoGetCfmSer(u8 *ptr, size_t *len, void *msg); -extern void *CsrWifiSmeConnectionInfoGetCfmDes(u8 *buffer, size_t len); -extern size_t CsrWifiSmeConnectionInfoGetCfmSizeof(void *msg); -extern void CsrWifiSmeConnectionInfoGetCfmSerFree(void *msg); - -extern u8 *CsrWifiSmeConnectionQualityIndSer(u8 *ptr, size_t *len, void *msg); -extern void *CsrWifiSmeConnectionQualityIndDes(u8 *buffer, size_t len); -extern size_t CsrWifiSmeConnectionQualityIndSizeof(void *msg); -#define CsrWifiSmeConnectionQualityIndSerFree CsrWifiSmePfree - -extern u8 *CsrWifiSmeConnectionStatsGetCfmSer(u8 *ptr, size_t *len, void *msg); -extern void *CsrWifiSmeConnectionStatsGetCfmDes(u8 *buffer, size_t len); -extern size_t CsrWifiSmeConnectionStatsGetCfmSizeof(void *msg); -#define CsrWifiSmeConnectionStatsGetCfmSerFree CsrWifiSmePfree - -#define CsrWifiSmeDeactivateCfmSer CsrWifiEventCsrUint16Ser -#define CsrWifiSmeDeactivateCfmDes CsrWifiEventCsrUint16Des -#define CsrWifiSmeDeactivateCfmSizeof CsrWifiEventCsrUint16Sizeof -#define CsrWifiSmeDeactivateCfmSerFree CsrWifiSmePfree - -extern u8 *CsrWifiSmeDisconnectCfmSer(u8 *ptr, size_t *len, void *msg); -extern void *CsrWifiSmeDisconnectCfmDes(u8 *buffer, size_t len); -extern size_t CsrWifiSmeDisconnectCfmSizeof(void *msg); -#define CsrWifiSmeDisconnectCfmSerFree CsrWifiSmePfree - -#define CsrWifiSmeEventMaskSetCfmSer CsrWifiEventCsrUint16Ser -#define CsrWifiSmeEventMaskSetCfmDes CsrWifiEventCsrUint16Des -#define CsrWifiSmeEventMaskSetCfmSizeof CsrWifiEventCsrUint16Sizeof -#define CsrWifiSmeEventMaskSetCfmSerFree CsrWifiSmePfree - -extern u8 *CsrWifiSmeHostConfigGetCfmSer(u8 *ptr, size_t *len, void *msg); -extern void *CsrWifiSmeHostConfigGetCfmDes(u8 *buffer, size_t len); -extern size_t CsrWifiSmeHostConfigGetCfmSizeof(void *msg); -#define CsrWifiSmeHostConfigGetCfmSerFree CsrWifiSmePfree - -extern u8 *CsrWifiSmeHostConfigSetCfmSer(u8 *ptr, size_t *len, void *msg); -extern void *CsrWifiSmeHostConfigSetCfmDes(u8 *buffer, size_t len); -extern size_t CsrWifiSmeHostConfigSetCfmSizeof(void *msg); -#define CsrWifiSmeHostConfigSetCfmSerFree CsrWifiSmePfree - -extern u8 *CsrWifiSmeIbssStationIndSer(u8 *ptr, size_t *len, void *msg); -extern void *CsrWifiSmeIbssStationIndDes(u8 *buffer, size_t len); -extern size_t CsrWifiSmeIbssStationIndSizeof(void *msg); -#define CsrWifiSmeIbssStationIndSerFree CsrWifiSmePfree - -extern u8 *CsrWifiSmeKeyCfmSer(u8 *ptr, size_t *len, void *msg); -extern void *CsrWifiSmeKeyCfmDes(u8 *buffer, size_t len); -extern size_t CsrWifiSmeKeyCfmSizeof(void *msg); -#define CsrWifiSmeKeyCfmSerFree CsrWifiSmePfree - -extern u8 *CsrWifiSmeLinkQualityGetCfmSer(u8 *ptr, size_t *len, void *msg); -extern void *CsrWifiSmeLinkQualityGetCfmDes(u8 *buffer, size_t len); -extern size_t CsrWifiSmeLinkQualityGetCfmSizeof(void *msg); -#define CsrWifiSmeLinkQualityGetCfmSerFree CsrWifiSmePfree - -extern u8 *CsrWifiSmeMediaStatusIndSer(u8 *ptr, size_t *len, void *msg); -extern void *CsrWifiSmeMediaStatusIndDes(u8 *buffer, size_t len); -extern size_t CsrWifiSmeMediaStatusIndSizeof(void *msg); -extern void CsrWifiSmeMediaStatusIndSerFree(void *msg); - -extern u8 *CsrWifiSmeMibConfigGetCfmSer(u8 *ptr, size_t *len, void *msg); -extern void *CsrWifiSmeMibConfigGetCfmDes(u8 *buffer, size_t len); -extern size_t CsrWifiSmeMibConfigGetCfmSizeof(void *msg); -#define CsrWifiSmeMibConfigGetCfmSerFree CsrWifiSmePfree - -#define CsrWifiSmeMibConfigSetCfmSer CsrWifiEventCsrUint16Ser -#define CsrWifiSmeMibConfigSetCfmDes CsrWifiEventCsrUint16Des -#define CsrWifiSmeMibConfigSetCfmSizeof CsrWifiEventCsrUint16Sizeof -#define CsrWifiSmeMibConfigSetCfmSerFree CsrWifiSmePfree - -extern u8 *CsrWifiSmeMibGetCfmSer(u8 *ptr, size_t *len, void *msg); -extern void *CsrWifiSmeMibGetCfmDes(u8 *buffer, size_t len); -extern size_t CsrWifiSmeMibGetCfmSizeof(void *msg); -extern void CsrWifiSmeMibGetCfmSerFree(void *msg); - -extern u8 *CsrWifiSmeMibGetNextCfmSer(u8 *ptr, size_t *len, void *msg); -extern void *CsrWifiSmeMibGetNextCfmDes(u8 *buffer, size_t len); -extern size_t CsrWifiSmeMibGetNextCfmSizeof(void *msg); -extern void CsrWifiSmeMibGetNextCfmSerFree(void *msg); - -#define CsrWifiSmeMibSetCfmSer CsrWifiEventCsrUint16Ser -#define CsrWifiSmeMibSetCfmDes CsrWifiEventCsrUint16Des -#define CsrWifiSmeMibSetCfmSizeof CsrWifiEventCsrUint16Sizeof -#define CsrWifiSmeMibSetCfmSerFree CsrWifiSmePfree - -extern u8 *CsrWifiSmeMicFailureIndSer(u8 *ptr, size_t *len, void *msg); -extern void *CsrWifiSmeMicFailureIndDes(u8 *buffer, size_t len); -extern size_t CsrWifiSmeMicFailureIndSizeof(void *msg); -#define CsrWifiSmeMicFailureIndSerFree CsrWifiSmePfree - -extern u8 *CsrWifiSmeMulticastAddressCfmSer(u8 *ptr, size_t *len, void *msg); -extern void *CsrWifiSmeMulticastAddressCfmDes(u8 *buffer, size_t len); -extern size_t CsrWifiSmeMulticastAddressCfmSizeof(void *msg); -extern void CsrWifiSmeMulticastAddressCfmSerFree(void *msg); - -extern u8 *CsrWifiSmePacketFilterSetCfmSer(u8 *ptr, size_t *len, void *msg); -extern void *CsrWifiSmePacketFilterSetCfmDes(u8 *buffer, size_t len); -extern size_t CsrWifiSmePacketFilterSetCfmSizeof(void *msg); -#define CsrWifiSmePacketFilterSetCfmSerFree CsrWifiSmePfree - -extern u8 *CsrWifiSmePermanentMacAddressGetCfmSer(u8 *ptr, size_t *len, - void *msg); -extern void *CsrWifiSmePermanentMacAddressGetCfmDes(u8 *buffer, size_t len); -extern size_t CsrWifiSmePermanentMacAddressGetCfmSizeof(void *msg); -#define CsrWifiSmePermanentMacAddressGetCfmSerFree CsrWifiSmePfree - -extern u8 *CsrWifiSmePmkidCandidateListIndSer(u8 *ptr, size_t *len, void *msg); -extern void *CsrWifiSmePmkidCandidateListIndDes(u8 *buffer, size_t len); -extern size_t CsrWifiSmePmkidCandidateListIndSizeof(void *msg); -extern void CsrWifiSmePmkidCandidateListIndSerFree(void *msg); - -extern u8 *CsrWifiSmePmkidCfmSer(u8 *ptr, size_t *len, void *msg); -extern void *CsrWifiSmePmkidCfmDes(u8 *buffer, size_t len); -extern size_t CsrWifiSmePmkidCfmSizeof(void *msg); -extern void CsrWifiSmePmkidCfmSerFree(void *msg); - -extern u8 *CsrWifiSmePowerConfigGetCfmSer(u8 *ptr, size_t *len, void *msg); -extern void *CsrWifiSmePowerConfigGetCfmDes(u8 *buffer, size_t len); -extern size_t CsrWifiSmePowerConfigGetCfmSizeof(void *msg); -#define CsrWifiSmePowerConfigGetCfmSerFree CsrWifiSmePfree - -#define CsrWifiSmePowerConfigSetCfmSer CsrWifiEventCsrUint16Ser -#define CsrWifiSmePowerConfigSetCfmDes CsrWifiEventCsrUint16Des -#define CsrWifiSmePowerConfigSetCfmSizeof CsrWifiEventCsrUint16Sizeof -#define CsrWifiSmePowerConfigSetCfmSerFree CsrWifiSmePfree - -extern u8 *CsrWifiSmeRegulatoryDomainInfoGetCfmSer(u8 *ptr, size_t *len, - void *msg); -extern void *CsrWifiSmeRegulatoryDomainInfoGetCfmDes(u8 *buffer, size_t len); -extern size_t CsrWifiSmeRegulatoryDomainInfoGetCfmSizeof(void *msg); -#define CsrWifiSmeRegulatoryDomainInfoGetCfmSerFree CsrWifiSmePfree - -extern u8 *CsrWifiSmeRoamCompleteIndSer(u8 *ptr, size_t *len, void *msg); -extern void *CsrWifiSmeRoamCompleteIndDes(u8 *buffer, size_t len); -extern size_t CsrWifiSmeRoamCompleteIndSizeof(void *msg); -#define CsrWifiSmeRoamCompleteIndSerFree CsrWifiSmePfree - -extern u8 *CsrWifiSmeRoamStartIndSer(u8 *ptr, size_t *len, void *msg); -extern void *CsrWifiSmeRoamStartIndDes(u8 *buffer, size_t len); -extern size_t CsrWifiSmeRoamStartIndSizeof(void *msg); -#define CsrWifiSmeRoamStartIndSerFree CsrWifiSmePfree - -extern u8 *CsrWifiSmeRoamingConfigGetCfmSer(u8 *ptr, size_t *len, void *msg); -extern void *CsrWifiSmeRoamingConfigGetCfmDes(u8 *buffer, size_t len); -extern size_t CsrWifiSmeRoamingConfigGetCfmSizeof(void *msg); -#define CsrWifiSmeRoamingConfigGetCfmSerFree CsrWifiSmePfree - -extern u8 *CsrWifiSmeRoamingConfigSetCfmSer(u8 *ptr, size_t *len, void *msg); -extern void *CsrWifiSmeRoamingConfigSetCfmDes(u8 *buffer, size_t len); -extern size_t CsrWifiSmeRoamingConfigSetCfmSizeof(void *msg); -#define CsrWifiSmeRoamingConfigSetCfmSerFree CsrWifiSmePfree - -extern u8 *CsrWifiSmeScanConfigGetCfmSer(u8 *ptr, size_t *len, void *msg); -extern void *CsrWifiSmeScanConfigGetCfmDes(u8 *buffer, size_t len); -extern size_t CsrWifiSmeScanConfigGetCfmSizeof(void *msg); -extern void CsrWifiSmeScanConfigGetCfmSerFree(void *msg); - -#define CsrWifiSmeScanConfigSetCfmSer CsrWifiEventCsrUint16Ser -#define CsrWifiSmeScanConfigSetCfmDes CsrWifiEventCsrUint16Des -#define CsrWifiSmeScanConfigSetCfmSizeof CsrWifiEventCsrUint16Sizeof -#define CsrWifiSmeScanConfigSetCfmSerFree CsrWifiSmePfree - -#define CsrWifiSmeScanFullCfmSer CsrWifiEventCsrUint16Ser -#define CsrWifiSmeScanFullCfmDes CsrWifiEventCsrUint16Des -#define CsrWifiSmeScanFullCfmSizeof CsrWifiEventCsrUint16Sizeof -#define CsrWifiSmeScanFullCfmSerFree CsrWifiSmePfree - -extern u8 *CsrWifiSmeScanResultIndSer(u8 *ptr, size_t *len, void *msg); -extern void *CsrWifiSmeScanResultIndDes(u8 *buffer, size_t len); -extern size_t CsrWifiSmeScanResultIndSizeof(void *msg); -extern void CsrWifiSmeScanResultIndSerFree(void *msg); - -#define CsrWifiSmeScanResultsFlushCfmSer CsrWifiEventCsrUint16Ser -#define CsrWifiSmeScanResultsFlushCfmDes CsrWifiEventCsrUint16Des -#define CsrWifiSmeScanResultsFlushCfmSizeof CsrWifiEventCsrUint16Sizeof -#define CsrWifiSmeScanResultsFlushCfmSerFree CsrWifiSmePfree - -extern u8 *CsrWifiSmeScanResultsGetCfmSer(u8 *ptr, size_t *len, void *msg); -extern void *CsrWifiSmeScanResultsGetCfmDes(u8 *buffer, size_t len); -extern size_t CsrWifiSmeScanResultsGetCfmSizeof(void *msg); -extern void CsrWifiSmeScanResultsGetCfmSerFree(void *msg); - -extern u8 *CsrWifiSmeSmeStaConfigGetCfmSer(u8 *ptr, size_t *len, void *msg); -extern void *CsrWifiSmeSmeStaConfigGetCfmDes(u8 *buffer, size_t len); -extern size_t CsrWifiSmeSmeStaConfigGetCfmSizeof(void *msg); -#define CsrWifiSmeSmeStaConfigGetCfmSerFree CsrWifiSmePfree - -extern u8 *CsrWifiSmeSmeStaConfigSetCfmSer(u8 *ptr, size_t *len, void *msg); -extern void *CsrWifiSmeSmeStaConfigSetCfmDes(u8 *buffer, size_t len); -extern size_t CsrWifiSmeSmeStaConfigSetCfmSizeof(void *msg); -#define CsrWifiSmeSmeStaConfigSetCfmSerFree CsrWifiSmePfree - -extern u8 *CsrWifiSmeStationMacAddressGetCfmSer(u8 *ptr, size_t *len, - void *msg); -extern void *CsrWifiSmeStationMacAddressGetCfmDes(u8 *buffer, size_t len); -extern size_t CsrWifiSmeStationMacAddressGetCfmSizeof(void *msg); -#define CsrWifiSmeStationMacAddressGetCfmSerFree CsrWifiSmePfree - -extern u8 *CsrWifiSmeTspecIndSer(u8 *ptr, size_t *len, void *msg); -extern void *CsrWifiSmeTspecIndDes(u8 *buffer, size_t len); -extern size_t CsrWifiSmeTspecIndSizeof(void *msg); -extern void CsrWifiSmeTspecIndSerFree(void *msg); - -extern u8 *CsrWifiSmeTspecCfmSer(u8 *ptr, size_t *len, void *msg); -extern void *CsrWifiSmeTspecCfmDes(u8 *buffer, size_t len); -extern size_t CsrWifiSmeTspecCfmSizeof(void *msg); -extern void CsrWifiSmeTspecCfmSerFree(void *msg); - -extern u8 *CsrWifiSmeVersionsGetCfmSer(u8 *ptr, size_t *len, void *msg); -extern void *CsrWifiSmeVersionsGetCfmDes(u8 *buffer, size_t len); -extern size_t CsrWifiSmeVersionsGetCfmSizeof(void *msg); -extern void CsrWifiSmeVersionsGetCfmSerFree(void *msg); - -#define CsrWifiSmeWifiFlightmodeCfmSer CsrWifiEventCsrUint16Ser -#define CsrWifiSmeWifiFlightmodeCfmDes CsrWifiEventCsrUint16Des -#define CsrWifiSmeWifiFlightmodeCfmSizeof CsrWifiEventCsrUint16Sizeof -#define CsrWifiSmeWifiFlightmodeCfmSerFree CsrWifiSmePfree - -#define CsrWifiSmeWifiOffIndSer CsrWifiEventCsrUint8Ser -#define CsrWifiSmeWifiOffIndDes CsrWifiEventCsrUint8Des -#define CsrWifiSmeWifiOffIndSizeof CsrWifiEventCsrUint8Sizeof -#define CsrWifiSmeWifiOffIndSerFree CsrWifiSmePfree - -#define CsrWifiSmeWifiOffCfmSer CsrWifiEventCsrUint16Ser -#define CsrWifiSmeWifiOffCfmDes CsrWifiEventCsrUint16Des -#define CsrWifiSmeWifiOffCfmSizeof CsrWifiEventCsrUint16Sizeof -#define CsrWifiSmeWifiOffCfmSerFree CsrWifiSmePfree - -#define CsrWifiSmeWifiOnCfmSer CsrWifiEventCsrUint16Ser -#define CsrWifiSmeWifiOnCfmDes CsrWifiEventCsrUint16Des -#define CsrWifiSmeWifiOnCfmSizeof CsrWifiEventCsrUint16Sizeof -#define CsrWifiSmeWifiOnCfmSerFree CsrWifiSmePfree - -#define CsrWifiSmeCloakedSsidsSetCfmSer CsrWifiEventCsrUint16Ser -#define CsrWifiSmeCloakedSsidsSetCfmDes CsrWifiEventCsrUint16Des -#define CsrWifiSmeCloakedSsidsSetCfmSizeof CsrWifiEventCsrUint16Sizeof -#define CsrWifiSmeCloakedSsidsSetCfmSerFree CsrWifiSmePfree - -extern u8 *CsrWifiSmeCloakedSsidsGetCfmSer(u8 *ptr, size_t *len, void *msg); -extern void *CsrWifiSmeCloakedSsidsGetCfmDes(u8 *buffer, size_t len); -extern size_t CsrWifiSmeCloakedSsidsGetCfmSizeof(void *msg); -extern void CsrWifiSmeCloakedSsidsGetCfmSerFree(void *msg); - -extern u8 *CsrWifiSmeWifiOnIndSer(u8 *ptr, size_t *len, void *msg); -extern void *CsrWifiSmeWifiOnIndDes(u8 *buffer, size_t len); -extern size_t CsrWifiSmeWifiOnIndSizeof(void *msg); -#define CsrWifiSmeWifiOnIndSerFree CsrWifiSmePfree - -extern u8 *CsrWifiSmeSmeCommonConfigGetCfmSer(u8 *ptr, size_t *len, void *msg); -extern void *CsrWifiSmeSmeCommonConfigGetCfmDes(u8 *buffer, size_t len); -extern size_t CsrWifiSmeSmeCommonConfigGetCfmSizeof(void *msg); -#define CsrWifiSmeSmeCommonConfigGetCfmSerFree CsrWifiSmePfree - -#define CsrWifiSmeSmeCommonConfigSetCfmSer CsrWifiEventCsrUint16Ser -#define CsrWifiSmeSmeCommonConfigSetCfmDes CsrWifiEventCsrUint16Des -#define CsrWifiSmeSmeCommonConfigSetCfmSizeof CsrWifiEventCsrUint16Sizeof -#define CsrWifiSmeSmeCommonConfigSetCfmSerFree CsrWifiSmePfree - -extern u8 *CsrWifiSmeInterfaceCapabilityGetCfmSer(u8 *ptr, size_t *len, - void *msg); -extern void *CsrWifiSmeInterfaceCapabilityGetCfmDes(u8 *buffer, size_t len); -extern size_t CsrWifiSmeInterfaceCapabilityGetCfmSizeof(void *msg); -#define CsrWifiSmeInterfaceCapabilityGetCfmSerFree CsrWifiSmePfree - -extern u8 *CsrWifiSmeErrorIndSer(u8 *ptr, size_t *len, void *msg); -extern void *CsrWifiSmeErrorIndDes(u8 *buffer, size_t len); -extern size_t CsrWifiSmeErrorIndSizeof(void *msg); -extern void CsrWifiSmeErrorIndSerFree(void *msg); - -extern u8 *CsrWifiSmeInfoIndSer(u8 *ptr, size_t *len, void *msg); -extern void *CsrWifiSmeInfoIndDes(u8 *buffer, size_t len); -extern size_t CsrWifiSmeInfoIndSizeof(void *msg); -extern void CsrWifiSmeInfoIndSerFree(void *msg); - -extern u8 *CsrWifiSmeCoreDumpIndSer(u8 *ptr, size_t *len, void *msg); -extern void *CsrWifiSmeCoreDumpIndDes(u8 *buffer, size_t len); -extern size_t CsrWifiSmeCoreDumpIndSizeof(void *msg); -extern void CsrWifiSmeCoreDumpIndSerFree(void *msg); - -#define CsrWifiSmeAmpStatusChangeIndSer CsrWifiEventCsrUint16CsrUint8Ser -#define CsrWifiSmeAmpStatusChangeIndDes CsrWifiEventCsrUint16CsrUint8Des -#define CsrWifiSmeAmpStatusChangeIndSizeof CsrWifiEventCsrUint16CsrUint8Sizeof -#define CsrWifiSmeAmpStatusChangeIndSerFree CsrWifiSmePfree - -#define CsrWifiSmeWpsConfigurationCfmSer CsrWifiEventCsrUint16Ser -#define CsrWifiSmeWpsConfigurationCfmDes CsrWifiEventCsrUint16Des -#define CsrWifiSmeWpsConfigurationCfmSizeof CsrWifiEventCsrUint16Sizeof -#define CsrWifiSmeWpsConfigurationCfmSerFree CsrWifiSmePfree - -#endif /* CSR_WIFI_SME_SERIALIZE_H__ */ - diff --git a/drivers/staging/csr/csr_wifi_sme_task.h b/drivers/staging/csr/csr_wifi_sme_task.h deleted file mode 100644 index 1e938c1fa964..000000000000 --- a/drivers/staging/csr/csr_wifi_sme_task.h +++ /dev/null @@ -1,25 +0,0 @@ -/***************************************************************************** - - (c) Cambridge Silicon Radio Limited 2011 - All rights reserved and confidential information of CSR - - Refer to LICENSE.txt included with this source for details - on the license terms. - -*****************************************************************************/ - -/* Note: this is an auto-generated file. */ - -#ifndef CSR_WIFI_SME_TASK_H__ -#define CSR_WIFI_SME_TASK_H__ - -#include "csr_sched.h" - -#define CSR_WIFI_SME_LOG_ID 0x1202FFFF -extern CsrSchedQid CSR_WIFI_SME_IFACEQUEUE; -void CsrWifiSmeInit(void **gash); -void CsrWifiSmeDeinit(void **gash); -void CsrWifiSmeHandler(void **gash); - -#endif /* CSR_WIFI_SME_TASK_H__ */ - diff --git a/drivers/staging/csr/csr_wifi_vif_utils.h b/drivers/staging/csr/csr_wifi_vif_utils.h deleted file mode 100644 index 8ff97888996d..000000000000 --- a/drivers/staging/csr/csr_wifi_vif_utils.h +++ /dev/null @@ -1,27 +0,0 @@ -/***************************************************************************** - - (c) Cambridge Silicon Radio Limited 2011 - All rights reserved and confidential information of CSR - - Refer to LICENSE.txt included with this source for details - on the license terms. - -*****************************************************************************/ - -#ifndef CSR_WIFI_VIF_UTILS_H -#define CSR_WIFI_VIF_UTILS_H - -/* STANDARD INCLUDES ********************************************************/ - -/* PROJECT INCLUDES *********************************************************/ -/* including this file for CsrWifiInterfaceMode*/ -#include "csr_wifi_private_common.h" - -/* MACROS *******************************************************************/ - -/* Common macros for NME and SME to be used temporarily until SoftMAC changes are made */ -#define CSR_WIFI_NUM_INTERFACES (u8)0x1 -#define CSR_WIFI_INTERFACE_IN_USE (u16)0x0 - -#endif /* CSR_WIFI_VIF_UTILS_H */ - diff --git a/drivers/staging/csr/data_tx.c b/drivers/staging/csr/data_tx.c deleted file mode 100644 index 9e3d8b8ab02c..000000000000 --- a/drivers/staging/csr/data_tx.c +++ /dev/null @@ -1,54 +0,0 @@ -/* - * --------------------------------------------------------------------------- - * FILE: data_tx.c - * - * PURPOSE: - * This file provides functions to send data requests to the UniFi. - * - * Copyright (C) 2007-2009 by Cambridge Silicon Radio Ltd. - * - * Refer to LICENSE.txt included with this source code for details on - * the license terms. - * - * --------------------------------------------------------------------------- - */ -#include "csr_wifi_hip_unifi.h" -#include "unifi_priv.h" - -int -uf_verify_m4(unifi_priv_t *priv, const unsigned char *packet, unsigned int length) -{ - const unsigned char *p = packet; - u16 keyinfo; - - - if (length < (4 + 5 + 8 + 32 + 16 + 8 + 8 + 16 + 1 + 8)) - return 1; - - p += 8; - keyinfo = p[5] << 8 | p[6]; /* big-endian */ - if ( - (p[0] == 1 || p[0] == 2) /* protocol version 802.1X-2001 (WPA) or -2004 (WPA2) */ && - p[1] == 3 /* EAPOL-Key */ && - /* don't bother checking p[2] p[3] (hh ll, packet body length) */ - (p[4] == 254 || p[4] == 2) /* descriptor type P802.1i-D3.0 (WPA) or 802.11i-2004 (WPA2) */ && - ((keyinfo & 0x0007) == 1 || (keyinfo & 0x0007) == 2) /* key descriptor version */ && - (keyinfo & ~0x0207U) == 0x0108 && /* key info for 4/4 or 4/2 -- ignore key desc version and sec bit (since varies in WPA 4/4) */ - (p[4 + 5 + 8 + 32 + 16 + 8 + 8 + 16 + 0] == 0 && /* key data length (2 octets) 0 for 4/4 only */ - p[4 + 5 + 8 + 32 + 16 + 8 + 8 + 16 + 1] == 0) - ) { - unifi_trace(priv, UDBG1, "uf_verify_m4: M4 detected\n"); - return 0; - } else { - return 1; - } -} - -/* - * --------------------------------------------------------------------------- - * - * Data transport signals. - * - * --------------------------------------------------------------------------- - */ - diff --git a/drivers/staging/csr/drv.c b/drivers/staging/csr/drv.c deleted file mode 100644 index 92898de921f5..000000000000 --- a/drivers/staging/csr/drv.c +++ /dev/null @@ -1,2193 +0,0 @@ -/* - * --------------------------------------------------------------------------- - * FILE: drv.c - * - * PURPOSE: - * Conventional device interface for debugging/monitoring of the - * driver and h/w using unicli. This interface is also being used - * by the SME linux implementation and the helper apps. - * - * Copyright (C) 2005-2009 by Cambridge Silicon Radio Ltd. - * - * Refer to LICENSE.txt included with this source code for details on - * the license terms. - * - * --------------------------------------------------------------------------- - */ - -/* - * Porting Notes: - * Part of this file contains an example for how to glue the OS layer - * with the HIP core lib, the SDIO glue layer, and the SME. - * - * When the unifi_sdio.ko modules loads, the linux kernel calls unifi_load(). - * unifi_load() calls uf_sdio_load() which is exported by the SDIO glue - * layer. uf_sdio_load() registers this driver with the underlying SDIO driver. - * When a card is detected, the SDIO glue layer calls register_unifi_sdio() - * to pass the SDIO function context and ask the OS layer to initialise - * the card. register_unifi_sdio() allocates all the private data of the OS - * layer and calls uf_run_unifihelper() to start the SME. The SME calls - * unifi_sys_wifi_on_req() which uses the HIP core lib to initialise the card. - */ - -#include -#include -#include -#include -#include -#include - -#include "csr_wifi_hip_unifiversion.h" -#include "unifi_priv.h" -#include "csr_wifi_hip_conversions.h" -#include "unifi_native.h" - -/* Module parameter variables */ -int buswidth = 0; /* 0 means use default, values 1,4 */ -int sdio_clock = 50000; /* kHz */ -int unifi_debug = 0; -/* fw_init prevents f/w initialisation on error. */ -int fw_init[MAX_UNIFI_DEVS] = {-1, -1}; -int use_5g = 0; -int led_mask = 0; /* 0x0c00 for dev-pc-1503c, dev-pc-1528a */ -int disable_hw_reset = 0; -int disable_power_control = 0; -int enable_wol = UNIFI_WOL_OFF; /* 0 for none, 1 for SDIO IRQ, 2 for PIO */ -#if (defined CSR_SUPPORT_SME) && (defined CSR_SUPPORT_WEXT) -int tl_80211d = (int)CSR_WIFI_SME_80211D_TRUST_LEVEL_MIB; -#endif -int sdio_block_size = -1; /* Override SDIO block size */ -int sdio_byte_mode = 0; /* 0 for block mode + padding, 1 for byte mode */ -int coredump_max = CSR_WIFI_HIP_NUM_COREDUMP_BUFFERS; -int run_bh_once = -1; /* Set for scheduled interrupt mode, -1 = default */ -int bh_priority = -1; -#ifdef CSR_WIFI_HIP_DEBUG_OFFLINE -#define UNIFI_LOG_HIP_SIGNALS_FILTER_BULKDATA (1 << 1) -#define UNIFI_LOG_HIP_SIGNALS_FILTER_TIMESTAMP (1 << 2) -int log_hip_signals = 0; -#endif - -MODULE_DESCRIPTION("CSR UniFi (SDIO)"); - -module_param(buswidth, int, S_IRUGO|S_IWUSR); -module_param(sdio_clock, int, S_IRUGO|S_IWUSR); -module_param(unifi_debug, int, S_IRUGO|S_IWUSR); -module_param_array(fw_init, int, NULL, S_IRUGO|S_IWUSR); -module_param(use_5g, int, S_IRUGO|S_IWUSR); -module_param(led_mask, int, S_IRUGO|S_IWUSR); -module_param(disable_hw_reset, int, S_IRUGO|S_IWUSR); -module_param(disable_power_control, int, S_IRUGO|S_IWUSR); -module_param(enable_wol, int, S_IRUGO|S_IWUSR); -#if (defined CSR_SUPPORT_SME) && (defined CSR_SUPPORT_WEXT) -module_param(tl_80211d, int, S_IRUGO|S_IWUSR); -#endif -module_param(sdio_block_size, int, S_IRUGO|S_IWUSR); -module_param(sdio_byte_mode, int, S_IRUGO|S_IWUSR); -module_param(coredump_max, int, S_IRUGO|S_IWUSR); -module_param(run_bh_once, int, S_IRUGO|S_IWUSR); -module_param(bh_priority, int, S_IRUGO|S_IWUSR); -#ifdef CSR_WIFI_HIP_DEBUG_OFFLINE -module_param(log_hip_signals, int, S_IRUGO|S_IWUSR); -#endif - -MODULE_PARM_DESC(buswidth, "SDIO bus width (0=default), set 1 for 1-bit or 4 for 4-bit mode"); -MODULE_PARM_DESC(sdio_clock, "SDIO bus frequency in kHz, (default = 50 MHz)"); -MODULE_PARM_DESC(unifi_debug, "Diagnostic reporting level"); -MODULE_PARM_DESC(fw_init, "Set to 0 to prevent f/w initialization on error"); -MODULE_PARM_DESC(use_5g, "Use the 5G (802.11a) radio band"); -MODULE_PARM_DESC(led_mask, "LED mask flags"); -MODULE_PARM_DESC(disable_hw_reset, "Set to 1 to disable hardware reset"); -MODULE_PARM_DESC(disable_power_control, "Set to 1 to disable SDIO power control"); -MODULE_PARM_DESC(enable_wol, "Enable wake-on-wlan function 0=off, 1=SDIO, 2=PIO"); -#if (defined CSR_SUPPORT_SME) && (defined CSR_SUPPORT_WEXT) -MODULE_PARM_DESC(tl_80211d, "802.11d Trust Level (1-6, default = 5)"); -#endif -MODULE_PARM_DESC(sdio_block_size, "Set to override SDIO block size"); -MODULE_PARM_DESC(sdio_byte_mode, "Set to 1 for byte mode SDIO"); -MODULE_PARM_DESC(coredump_max, "Number of chip mini-coredump buffers to allocate"); -MODULE_PARM_DESC(run_bh_once, "Run BH only when firmware interrupts"); -MODULE_PARM_DESC(bh_priority, "Modify the BH thread priority"); -#ifdef CSR_WIFI_HIP_DEBUG_OFFLINE -MODULE_PARM_DESC(log_hip_signals, "Set to 1 to enable HIP signal offline logging"); -#endif - - -/* Callback for event logging to UDI clients */ -static void udi_log_event(ul_client_t *client, - const u8 *signal, int signal_len, - const bulk_data_param_t *bulkdata, - int dir); - -static void udi_set_log_filter(ul_client_t *pcli, - unifiio_filter_t *udi_filter); - - -/* Mutex to protect access to priv->sme_cli */ -DEFINE_SEMAPHORE(udi_mutex); - -s32 CsrHipResultToStatus(CsrResult csrResult) -{ - s32 r = -EIO; - - switch (csrResult) - { - case CSR_RESULT_SUCCESS: - r = 0; - break; - case CSR_WIFI_HIP_RESULT_RANGE: - r = -ERANGE; - break; - case CSR_WIFI_HIP_RESULT_NO_DEVICE: - r = -ENODEV; - break; - case CSR_WIFI_HIP_RESULT_INVALID_VALUE: - r = -EINVAL; - break; - case CSR_WIFI_HIP_RESULT_NOT_FOUND: - r = -ENOENT; - break; - case CSR_WIFI_HIP_RESULT_NO_SPACE: - r = -ENOSPC; - break; - case CSR_WIFI_HIP_RESULT_NO_MEMORY: - r = -ENOMEM; - break; - case CSR_RESULT_FAILURE: - r = -EIO; - break; - default: - /*unifi_warning(card->ospriv, "CsrHipResultToStatus: Unrecognised csrResult error code: %d\n", csrResult);*/ - r = -EIO; - } - return r; -} - - -static const char* -trace_putest_cmdid(unifi_putest_command_t putest_cmd) -{ - switch (putest_cmd) { - case UNIFI_PUTEST_START: - return "START"; - case UNIFI_PUTEST_STOP: - return "STOP"; - case UNIFI_PUTEST_SET_SDIO_CLOCK: - return "SET CLOCK"; - case UNIFI_PUTEST_CMD52_READ: - return "CMD52R"; - case UNIFI_PUTEST_CMD52_BLOCK_READ: - return "CMD52BR"; - case UNIFI_PUTEST_CMD52_WRITE: - return "CMD52W"; - case UNIFI_PUTEST_DL_FW: - return "D/L FW"; - case UNIFI_PUTEST_DL_FW_BUFF: - return "D/L FW BUFFER"; - case UNIFI_PUTEST_COREDUMP_PREPARE: - return "PREPARE COREDUMP"; - case UNIFI_PUTEST_GP_READ16: - return "GP16R"; - case UNIFI_PUTEST_GP_WRITE16: - return "GP16W"; - default: - return "ERROR: unrecognised command"; - } - } - -#ifdef CSR_WIFI_HIP_DEBUG_OFFLINE -int uf_register_hip_offline_debug(unifi_priv_t *priv) -{ - ul_client_t *udi_cli; - int i; - - udi_cli = ul_register_client(priv, CLI_USING_WIRE_FORMAT, udi_log_event); - if (udi_cli == NULL) { - /* Too many clients already using this device */ - unifi_error(priv, "Too many UDI clients already open\n"); - return -ENOSPC; - } - unifi_trace(priv, UDBG1, "Offline HIP client is registered\n"); - - down(&priv->udi_logging_mutex); - udi_cli->event_hook = udi_log_event; - unifi_set_udi_hook(priv->card, logging_handler); - /* Log all signals by default */ - for (i = 0; i < SIG_FILTER_SIZE; i++) { - udi_cli->signal_filter[i] = 0xFFFF; - } - priv->logging_client = udi_cli; - up(&priv->udi_logging_mutex); - - return 0; -} - -int uf_unregister_hip_offline_debug(unifi_priv_t *priv) -{ - ul_client_t *udi_cli = priv->logging_client; - if (udi_cli == NULL) - { - unifi_error(priv, "Unknown HIP client unregister request\n"); - return -ERANGE; - } - - unifi_trace(priv, UDBG1, "Offline HIP client is unregistered\n"); - - down(&priv->udi_logging_mutex); - priv->logging_client = NULL; - udi_cli->event_hook = NULL; - up(&priv->udi_logging_mutex); - - ul_deregister_client(udi_cli); - - return 0; -} -#endif - - -/* - * --------------------------------------------------------------------------- - * unifi_open - * unifi_release - * - * Open and release entry points for the UniFi debug driver. - * - * Arguments: - * Normal linux driver args. - * - * Returns: - * Linux error code. - * --------------------------------------------------------------------------- - */ -static int -unifi_open(struct inode *inode, struct file *file) -{ - int devno; - unifi_priv_t *priv; - ul_client_t *udi_cli; - - devno = MINOR(inode->i_rdev) >> 1; - - /* - * Increase the ref_count for the char device clients. - * Make sure you call uf_put_instance() to decreace it if - * unifi_open returns an error. - */ - priv = uf_get_instance(devno); - if (priv == NULL) { - unifi_error(NULL, "unifi_open: No device present\n"); - return -ENODEV; - } - - /* Register this instance in the client's list. */ - /* The minor number determines the nature of the client (Unicli or SME). */ - if (MINOR(inode->i_rdev) & 0x1) { - udi_cli = ul_register_client(priv, CLI_USING_WIRE_FORMAT, udi_log_event); - if (udi_cli == NULL) { - /* Too many clients already using this device */ - unifi_error(priv, "Too many clients already open\n"); - uf_put_instance(devno); - return -ENOSPC; - } - unifi_trace(priv, UDBG1, "Client is registered to /dev/unifiudi%d\n", devno); - } else { - /* - * Even-numbered device nodes are the control application. - * This is the userspace helper containing SME or - * unifi_manager. - */ - - down(&udi_mutex); - -#ifdef CSR_SME_USERSPACE - /* Check if a config client is already attached */ - if (priv->sme_cli) { - up(&udi_mutex); - uf_put_instance(devno); - - unifi_info(priv, "There is already a configuration client using the character device\n"); - return -EBUSY; - } -#endif /* CSR_SME_USERSPACE */ - -#ifdef CSR_SUPPORT_SME - udi_cli = ul_register_client(priv, - CLI_USING_WIRE_FORMAT | CLI_SME_USERSPACE, - sme_log_event); -#else - /* Config client for native driver */ - udi_cli = ul_register_client(priv, - 0, - sme_native_log_event); -#endif - if (udi_cli == NULL) { - /* Too many clients already using this device */ - up(&udi_mutex); - uf_put_instance(devno); - - unifi_error(priv, "Too many clients already open\n"); - return -ENOSPC; - } - - /* - * Fill-in the pointer to the configuration client. - * This is the SME userspace helper or unifi_manager. - * Not used in the SME embedded version. - */ - unifi_trace(priv, UDBG1, "SME client (id:%d s:0x%X) is registered\n", - udi_cli->client_id, udi_cli->sender_id); - /* Store the SME UniFi Linux Client */ - if (priv->sme_cli == NULL) { - priv->sme_cli = udi_cli; - } - - up(&udi_mutex); - } - - - /* - * Store the pointer to the client. - * All char driver's entry points will pass this pointer. - */ - file->private_data = udi_cli; - - return 0; -} /* unifi_open() */ - - -static int -unifi_release(struct inode *inode, struct file *filp) -{ - ul_client_t *udi_cli = (void*)filp->private_data; - int devno; - unifi_priv_t *priv; - - priv = uf_find_instance(udi_cli->instance); - if (!priv) { - unifi_error(priv, "unifi_close: instance for device not found\n"); - return -ENODEV; - } - - devno = MINOR(inode->i_rdev) >> 1; - - /* Even device nodes are the config client (i.e. SME or unifi_manager) */ - if ((MINOR(inode->i_rdev) & 0x1) == 0) { - - if (priv->sme_cli != udi_cli) { - unifi_notice(priv, "Surprise closing config device: not the sme client\n"); - } - unifi_notice(priv, "SME client close (unifi%d)\n", devno); - - /* - * Clear sme_cli before calling unifi_sys_... so it doesn't try to - * queue a reply to the (now gone) SME. - */ - down(&udi_mutex); - priv->sme_cli = NULL; - up(&udi_mutex); - -#ifdef CSR_SME_USERSPACE - /* Power-down when config client closes */ - { - CsrWifiRouterCtrlWifiOffReq req = {{CSR_WIFI_ROUTER_CTRL_HIP_REQ, 0, 0, 0, NULL}}; - CsrWifiRouterCtrlWifiOffReqHandler(priv, &req.common); - } - - uf_sme_deinit(priv); - - /* It is possible that a blocking SME request was made from another process - * which did not get read by the SME before the WifiOffReq. - * So check for a pending request which will go unanswered and cancel - * the wait for event. As only one blocking request can be in progress at - * a time, up to one event should be completed. - */ - uf_sme_cancel_request(priv, 0); - -#endif /* CSR_SME_USERSPACE */ - } else { - - unifi_trace(priv, UDBG2, "UDI client close (unifiudi%d)\n", devno); - - /* If the pointer matches the logging client, stop logging. */ - down(&priv->udi_logging_mutex); - if (udi_cli == priv->logging_client) { - priv->logging_client = NULL; - } - up(&priv->udi_logging_mutex); - - if (udi_cli == priv->amp_client) { - priv->amp_client = NULL; - } - } - - /* Deregister this instance from the client's list. */ - ul_deregister_client(udi_cli); - - uf_put_instance(devno); - - return 0; -} /* unifi_release() */ - - - -/* - * --------------------------------------------------------------------------- - * unifi_read - * - * The read() driver entry point. - * - * Arguments: - * filp The file descriptor returned by unifi_open() - * p The user space buffer to copy the read data - * len The size of the p buffer - * poff - * - * Returns: - * number of bytes read or an error code on failure - * --------------------------------------------------------------------------- - */ -static ssize_t -unifi_read(struct file *filp, char *p, size_t len, loff_t *poff) -{ - ul_client_t *pcli = (void*)filp->private_data; - unifi_priv_t *priv; - udi_log_t *logptr = NULL; - udi_msg_t *msgptr; - struct list_head *l; - int msglen; - - priv = uf_find_instance(pcli->instance); - if (!priv) { - unifi_error(priv, "invalid priv\n"); - return -ENODEV; - } - - if (!pcli->udi_enabled) { - unifi_error(priv, "unifi_read: unknown client."); - return -EINVAL; - } - - if (list_empty(&pcli->udi_log)) { - if (filp->f_flags & O_NONBLOCK) { - /* Non-blocking - just return if the udi_log is empty */ - return 0; - } else { - /* Blocking - wait on the UDI wait queue */ - if (wait_event_interruptible(pcli->udi_wq, - !list_empty(&pcli->udi_log))) - { - unifi_error(priv, "unifi_read: wait_event_interruptible failed."); - return -ERESTARTSYS; - } - } - } - - /* Read entry from list head and remove it from the list */ - if (down_interruptible(&pcli->udi_sem)) { - return -ERESTARTSYS; - } - l = pcli->udi_log.next; - list_del(l); - up(&pcli->udi_sem); - - /* Get a pointer to whole struct */ - logptr = list_entry(l, udi_log_t, q); - if (logptr == NULL) { - unifi_error(priv, "unifi_read: failed to get event.\n"); - return -EINVAL; - } - - /* Get the real message */ - msgptr = &logptr->msg; - msglen = msgptr->length; - if (msglen > len) { - printk(KERN_WARNING "truncated read to %d actual msg len is %lu\n", msglen, (long unsigned int)len); - msglen = len; - } - - /* and pass it to the client (SME or Unicli). */ - if (copy_to_user(p, msgptr, msglen)) - { - printk(KERN_ERR "Failed to copy UDI log to user\n"); - kfree(logptr); - return -EFAULT; - } - - /* It is our resposibility to free the message buffer. */ - kfree(logptr); - - return msglen; - -} /* unifi_read() */ - - - -/* - * --------------------------------------------------------------------------- - * udi_send_signal_unpacked - * - * Sends an unpacked signal to UniFi. - * - * Arguments: - * priv Pointer to private context struct - * data Pointer to request structure and data to send - * data_len Length of data in data pointer. - * - * Returns: - * Number of bytes written, error otherwise. - * - * Notes: - * All clients that use this function to send a signal to the unifi - * must use the host formatted structures. - * --------------------------------------------------------------------------- - */ -static int -udi_send_signal_unpacked(unifi_priv_t *priv, unsigned char* data, uint data_len) -{ - CSR_SIGNAL *sigptr = (CSR_SIGNAL*)data; - CSR_DATAREF *datarefptr; - bulk_data_param_t bulk_data; - uint signal_size, i; - uint bulk_data_offset = 0; - int bytecount, r; - CsrResult csrResult; - - /* Number of bytes in the signal */ - signal_size = SigGetSize(sigptr); - if (!signal_size || (signal_size > data_len)) { - unifi_error(priv, "unifi_sme_mlme_req - Invalid signal 0x%x size should be %d bytes\n", - sigptr->SignalPrimitiveHeader.SignalId, - signal_size); - return -EINVAL; - } - bytecount = signal_size; - - /* Get a pointer to the information of the first data reference */ - datarefptr = (CSR_DATAREF*)&sigptr->u; - - /* Initialize the offset in the data buffer, bulk data is right after the signal. */ - bulk_data_offset = signal_size; - - /* store the references and the size of the bulk data to the bulkdata structure */ - for (i = 0; i < UNIFI_MAX_DATA_REFERENCES; i++) { - /* the length of the bulk data is in the signal */ - if ((datarefptr+i)->DataLength) { - void *dest; - - csrResult = unifi_net_data_malloc(priv, &bulk_data.d[i], (datarefptr+i)->DataLength); - if (csrResult != CSR_RESULT_SUCCESS) { - unifi_error(priv, "udi_send_signal_unpacked: failed to allocate request_data.\n"); - return -EIO; - } - - dest = (void*)bulk_data.d[i].os_data_ptr; - memcpy(dest, data + bulk_data_offset, bulk_data.d[i].data_length); - } else { - bulk_data.d[i].data_length = 0; - } - - bytecount += bulk_data.d[i].data_length; - /* advance the offset, to point the next bulk data */ - bulk_data_offset += bulk_data.d[i].data_length; - } - - - unifi_trace(priv, UDBG3, "SME Send: signal 0x%.4X\n", sigptr->SignalPrimitiveHeader.SignalId); - - /* Send the signal. */ - r = ul_send_signal_unpacked(priv, sigptr, &bulk_data); - if (r < 0) { - unifi_error(priv, "udi_send_signal_unpacked: send failed (%d)\n", r); - for(i=0;i buflen)) { - unifi_error(priv, "udi_send_signal_raw - Couldn't find length of signal 0x%x\n", - sig_id); - return -EINVAL; - } - unifi_trace(priv, UDBG2, "udi_send_signal_raw: signal 0x%.4X len:%d\n", - sig_id, signal_size); - /* Zero the data ref arrays */ - memset(&data_ptrs, 0, sizeof(data_ptrs)); - - /* - * Find the number of associated bulk data packets. Scan through - * the data refs to check that we have enough data and pick out - * pointers to appended bulk data. - */ - num_data_refs = 0; - bytecount = signal_size; - - for (i = 0; i < UNIFI_MAX_DATA_REFERENCES; ++i) - { - unsigned int len = GET_PACKED_DATAREF_LEN(buf, i); - unifi_trace(priv, UDBG3, "udi_send_signal_raw: data_ref length = %d\n", len); - - if (len != 0) { - void *dest; - - csrResult = unifi_net_data_malloc(priv, &data_ptrs.d[i], len); - if (csrResult != CSR_RESULT_SUCCESS) { - unifi_error(priv, "udi_send_signal_raw: failed to allocate request_data.\n"); - return -EIO; - } - - dest = (void*)data_ptrs.d[i].os_data_ptr; - memcpy(dest, buf + bytecount, len); - - bytecount += len; - num_data_refs++; - } - data_ptrs.d[i].data_length = len; - } - - unifi_trace(priv, UDBG3, "Queueing signal 0x%.4X from UDI with %u data refs\n", - sig_id, - num_data_refs); - - if (bytecount > buflen) { - unifi_error(priv, "udi_send_signal_raw: Not enough data (%d instead of %d)\n", buflen, bytecount); - return -EINVAL; - } - - /* Send the signal calling the function that uses the wire-formatted signals. */ - r = ul_send_signal_raw(priv, buf, signal_size, &data_ptrs); - if (r < 0) { - unifi_error(priv, "udi_send_signal_raw: send failed (%d)\n", r); - return -EIO; - } - -#ifdef CSR_NATIVE_LINUX - if (sig_id == CSR_MLME_POWERMGT_REQUEST_ID) { - int power_mode = CSR_GET_UINT16_FROM_LITTLE_ENDIAN((buf + - SIZEOF_SIGNAL_HEADER + (UNIFI_MAX_DATA_REFERENCES*SIZEOF_DATAREF))); -#ifdef CSR_SUPPORT_WEXT - /* Overide the wext power mode to the new value */ - priv->wext_conf.power_mode = power_mode; -#endif - /* Configure deep sleep signaling */ - if (power_mode || (priv->interfacePriv[0]->connected == UnifiNotConnected)) { - csrResult = unifi_configure_low_power_mode(priv->card, - UNIFI_LOW_POWER_ENABLED, - UNIFI_PERIODIC_WAKE_HOST_DISABLED); - } else { - csrResult = unifi_configure_low_power_mode(priv->card, - UNIFI_LOW_POWER_DISABLED, - UNIFI_PERIODIC_WAKE_HOST_DISABLED); - } - } -#endif - - return bytecount; -} /* udi_send_signal_raw */ - -/* - * --------------------------------------------------------------------------- - * unifi_write - * - * The write() driver entry point. - * A UniFi Debug Interface client such as unicli can write a signal - * plus bulk data to the driver for sending to the UniFi chip. - * - * Only one signal may be sent per write operation. - * - * Arguments: - * filp The file descriptor returned by unifi_open() - * p The user space buffer to get the data from - * len The size of the p buffer - * poff - * - * Returns: - * number of bytes written or an error code on failure - * --------------------------------------------------------------------------- - */ -static ssize_t -unifi_write(struct file *filp, const char *p, size_t len, loff_t *poff) -{ - ul_client_t *pcli = (ul_client_t*)filp->private_data; - unifi_priv_t *priv; - unsigned char *buf; - unsigned char *bufptr; - int remaining; - int bytes_written; - int r; - bulk_data_param_t bulkdata; - CsrResult csrResult; - - priv = uf_find_instance(pcli->instance); - if (!priv) { - unifi_error(priv, "invalid priv\n"); - return -ENODEV; - } - - unifi_trace(priv, UDBG5, "unifi_write: len = %d\n", len); - - if (!pcli->udi_enabled) { - unifi_error(priv, "udi disabled\n"); - return -EINVAL; - } - - /* - * AMP client sends only one signal at a time, so we can use - * unifi_net_data_malloc to save the extra copy. - */ - if (pcli == priv->amp_client) { - int signal_size; - int sig_id; - unsigned char *signal_buf; - char *user_data_buf; - - csrResult = unifi_net_data_malloc(priv, &bulkdata.d[0], len); - if (csrResult != CSR_RESULT_SUCCESS) { - unifi_error(priv, "unifi_write: failed to allocate request_data.\n"); - return -ENOMEM; - } - - user_data_buf = (char*)bulkdata.d[0].os_data_ptr; - - /* Get the data from the AMP client. */ - if (copy_from_user((void*)user_data_buf, p, len)) { - unifi_error(priv, "unifi_write: copy from user failed\n"); - unifi_net_data_free(priv, &bulkdata.d[0]); - return -EFAULT; - } - - bulkdata.d[1].os_data_ptr = NULL; - bulkdata.d[1].data_length = 0; - - /* Number of bytes in the signal */ - sig_id = GET_SIGNAL_ID(bulkdata.d[0].os_data_ptr); - signal_size = len; - signal_size -= GET_PACKED_DATAREF_LEN(bulkdata.d[0].os_data_ptr, 0); - signal_size -= GET_PACKED_DATAREF_LEN(bulkdata.d[0].os_data_ptr, 1); - if ((signal_size <= 0) || (signal_size > len)) { - unifi_error(priv, "unifi_write - Couldn't find length of signal 0x%x\n", - sig_id); - unifi_net_data_free(priv, &bulkdata.d[0]); - return -EINVAL; - } - - unifi_trace(priv, UDBG2, "unifi_write: signal 0x%.4X len:%d\n", - sig_id, signal_size); - - /* Allocate a buffer for the signal */ - signal_buf = kmemdup(bulkdata.d[0].os_data_ptr, signal_size, - GFP_KERNEL); - if (!signal_buf) { - unifi_net_data_free(priv, &bulkdata.d[0]); - return -ENOMEM; - } - - /* Get the signal from the os_data_ptr */ - signal_buf[5] = (pcli->sender_id >> 8) & 0xff; - - if (signal_size < len) { - /* Remove the signal from the os_data_ptr */ - bulkdata.d[0].data_length -= signal_size; - bulkdata.d[0].os_data_ptr += signal_size; - } else { - bulkdata.d[0].data_length = 0; - bulkdata.d[0].os_data_ptr = NULL; - } - - /* Send the signal calling the function that uses the wire-formatted signals. */ - r = ul_send_signal_raw(priv, signal_buf, signal_size, &bulkdata); - if (r < 0) { - unifi_error(priv, "unifi_write: send failed (%d)\n", r); - if (bulkdata.d[0].os_data_ptr != NULL) { - unifi_net_data_free(priv, &bulkdata.d[0]); - } - } - - /* Free the signal buffer and return */ - kfree(signal_buf); - return len; - } - - buf = kmalloc(len, GFP_KERNEL); - if (!buf) { - return -ENOMEM; - } - - /* Get the data from the client (SME or Unicli). */ - if (copy_from_user((void*)buf, p, len)) { - unifi_error(priv, "copy from user failed\n"); - kfree(buf); - return -EFAULT; - } - - /* - * In SME userspace build read() contains a SYS or MGT message. - * Note that even though the SME sends one signal at a time, we can not - * use unifi_net_data_malloc because in the early stages, before having - * initialised the core, it will fail since the I/O block size is unknown. - */ -#ifdef CSR_SME_USERSPACE - if (pcli->configuration & CLI_SME_USERSPACE) { - CsrWifiRouterTransportRecv(priv, buf, len); - kfree(buf); - return len; - } -#endif - - /* ul_send_signal_raw will do a sanity check of len against signal content */ - - /* - * udi_send_signal_raw() and udi_send_signal_unpacked() return the number of bytes consumed. - * A write call can pass multiple signal concatenated together. - */ - bytes_written = 0; - remaining = len; - bufptr = buf; - while (remaining > 0) - { - int r; - - /* - * Set the SenderProcessId. - * The SignalPrimitiveHeader is the first 3 16-bit words of the signal, - * the SenderProcessId is bytes 4,5. - * The MSB of the sender ID needs to be set to the client ID. - * The LSB is controlled by the SME. - */ - bufptr[5] = (pcli->sender_id >> 8) & 0xff; - - /* use the appropriate interface, depending on the clients' configuration */ - if (pcli->configuration & CLI_USING_WIRE_FORMAT) { - unifi_trace(priv, UDBG1, "unifi_write: call udi_send_signal().\n"); - r = udi_send_signal_raw(priv, bufptr, remaining); - } else { - r = udi_send_signal_unpacked(priv, bufptr, remaining); - } - if (r < 0) { - /* Set the return value to the error code */ - unifi_error(priv, "unifi_write: (udi or sme)_send_signal() returns %d\n", r); - bytes_written = r; - break; - } - bufptr += r; - remaining -= r; - bytes_written += r; - } - - kfree(buf); - - return bytes_written; -} /* unifi_write() */ - - -static const char* build_type_to_string(unsigned char build_type) -{ - switch (build_type) - { - case UNIFI_BUILD_NME: return "NME"; - case UNIFI_BUILD_WEXT: return "WEXT"; - case UNIFI_BUILD_AP: return "AP"; - } - return "unknown"; -} - - -/* - * ---------------------------------------------------------------- - * unifi_ioctl - * - * Ioctl handler for unifi driver. - * - * Arguments: - * inodep Pointer to inode structure. - * filp Pointer to file structure. - * cmd Ioctl cmd passed by user. - * arg Ioctl arg passed by user. - * - * Returns: - * 0 on success, -ve error code on error. - * ---------------------------------------------------------------- - */ -static long -unifi_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) -{ - ul_client_t *pcli = (ul_client_t*)filp->private_data; - unifi_priv_t *priv; - struct net_device *dev; - int r = 0; - int int_param, i; - u8* buf; - CsrResult csrResult; -#if (defined CSR_SUPPORT_SME) - unifi_cfg_command_t cfg_cmd; -#if (defined CSR_SUPPORT_WEXT) - CsrWifiSmeCoexConfig coex_config; - unsigned char uchar_param; - unsigned char varbind[MAX_VARBIND_LENGTH]; - int vblen; -#endif -#endif - unifi_putest_command_t putest_cmd; - - priv = uf_find_instance(pcli->instance); - if (!priv) { - unifi_error(priv, "ioctl error: unknown instance=%d\n", pcli->instance); - r = -ENODEV; - goto out; - } - unifi_trace(priv, UDBG5, "unifi_ioctl: cmd=0x%X, arg=0x%lX\n", cmd, arg); - - switch (cmd) { - - case UNIFI_GET_UDI_ENABLE: - unifi_trace(priv, UDBG4, "UniFi Get UDI Enable\n"); - - down(&priv->udi_logging_mutex); - int_param = (priv->logging_client == NULL) ? 0 : 1; - up(&priv->udi_logging_mutex); - - if (put_user(int_param, (int*)arg)) - { - unifi_error(priv, "UNIFI_GET_UDI_ENABLE: Failed to copy to user\n"); - r = -EFAULT; - goto out; - } - break; - - case UNIFI_SET_UDI_ENABLE: - unifi_trace(priv, UDBG4, "UniFi Set UDI Enable\n"); - if (get_user(int_param, (int*)arg)) - { - unifi_error(priv, "UNIFI_SET_UDI_ENABLE: Failed to copy from user\n"); - r = -EFAULT; - goto out; - } - -#ifdef CSR_WIFI_HIP_DEBUG_OFFLINE - if (log_hip_signals) { - unifi_error(priv, "omnicli cannot be used when log_hip_signals is used\n"); - r = -EFAULT; - goto out; - } -#endif - - down(&priv->udi_logging_mutex); - if (int_param) { - pcli->event_hook = udi_log_event; - unifi_set_udi_hook(priv->card, logging_handler); - /* Log all signals by default */ - for (i = 0; i < SIG_FILTER_SIZE; i++) { - pcli->signal_filter[i] = 0xFFFF; - } - priv->logging_client = pcli; - - } else { - priv->logging_client = NULL; - pcli->event_hook = NULL; - } - up(&priv->udi_logging_mutex); - - break; - - case UNIFI_SET_MIB: - unifi_trace(priv, UDBG4, "UniFi Set MIB\n"); -#if (defined CSR_SUPPORT_SME) && (defined CSR_SUPPORT_WEXT) - /* Read first 2 bytes and check length */ - if (copy_from_user((void*)varbind, (void*)arg, 2)) { - unifi_error(priv, - "UNIFI_SET_MIB: Failed to copy in varbind header\n"); - r = -EFAULT; - goto out; - } - vblen = varbind[1]; - if ((vblen + 2) > MAX_VARBIND_LENGTH) { - unifi_error(priv, - "UNIFI_SET_MIB: Varbind too long (%d, limit %d)\n", - (vblen+2), MAX_VARBIND_LENGTH); - r = -EINVAL; - goto out; - } - /* Read rest of varbind */ - if (copy_from_user((void*)(varbind+2), (void*)(arg+2), vblen)) { - unifi_error(priv, "UNIFI_SET_MIB: Failed to copy in varbind\n"); - r = -EFAULT; - goto out; - } - - /* send to SME */ - vblen += 2; - r = sme_mgt_mib_set(priv, varbind, vblen); - if (r) { - goto out; - } -#else - unifi_notice(priv, "UNIFI_SET_MIB: Unsupported.\n"); -#endif /* CSR_SUPPORT_WEXT */ - break; - - case UNIFI_GET_MIB: - unifi_trace(priv, UDBG4, "UniFi Get MIB\n"); -#if (defined CSR_SUPPORT_SME) && (defined CSR_SUPPORT_WEXT) - /* Read first 2 bytes and check length */ - if (copy_from_user((void*)varbind, (void*)arg, 2)) { - unifi_error(priv, "UNIFI_GET_MIB: Failed to copy in varbind header\n"); - r = -EFAULT; - goto out; - } - vblen = varbind[1]; - if ((vblen+2) > MAX_VARBIND_LENGTH) { - unifi_error(priv, "UNIFI_GET_MIB: Varbind too long (%d, limit %d)\n", - (vblen+2), MAX_VARBIND_LENGTH); - r = -EINVAL; - goto out; - } - /* Read rest of varbind */ - if (copy_from_user((void*)(varbind+2), (void*)(arg+2), vblen)) { - unifi_error(priv, "UNIFI_GET_MIB: Failed to copy in varbind\n"); - r = -EFAULT; - goto out; - } - - vblen += 2; - r = sme_mgt_mib_get(priv, varbind, &vblen); - if (r) { - goto out; - } - /* copy out varbind */ - if (vblen > MAX_VARBIND_LENGTH) { - unifi_error(priv, - "UNIFI_GET_MIB: Varbind result too long (%d, limit %d)\n", - vblen, MAX_VARBIND_LENGTH); - r = -EINVAL; - goto out; - } - if (copy_to_user((void*)arg, varbind, vblen)) { - r = -EFAULT; - goto out; - } -#else - unifi_notice(priv, "UNIFI_GET_MIB: Unsupported.\n"); -#endif /* CSR_SUPPORT_WEXT */ - break; - - case UNIFI_CFG: -#if (defined CSR_SUPPORT_SME) - if (get_user(cfg_cmd, (unifi_cfg_command_t*)arg)) - { - unifi_error(priv, "UNIFI_CFG: Failed to get the command\n"); - r = -EFAULT; - goto out; - } - - unifi_trace(priv, UDBG1, "UNIFI_CFG: Command is %d (t=%u) sz=%d\n", - cfg_cmd, jiffies_to_msecs(jiffies), sizeof(unifi_cfg_command_t)); - switch (cfg_cmd) { - case UNIFI_CFG_POWER: - r = unifi_cfg_power(priv, (unsigned char*)arg); - break; - case UNIFI_CFG_POWERSAVE: - r = unifi_cfg_power_save(priv, (unsigned char*)arg); - break; - case UNIFI_CFG_POWERSUPPLY: - r = unifi_cfg_power_supply(priv, (unsigned char*)arg); - break; - case UNIFI_CFG_FILTER: - r = unifi_cfg_packet_filters(priv, (unsigned char*)arg); - break; - case UNIFI_CFG_GET: - r = unifi_cfg_get_info(priv, (unsigned char*)arg); - break; - case UNIFI_CFG_WMM_QOSINFO: - r = unifi_cfg_wmm_qos_info(priv, (unsigned char*)arg); - break; - case UNIFI_CFG_WMM_ADDTS: - r = unifi_cfg_wmm_addts(priv, (unsigned char*)arg); - break; - case UNIFI_CFG_WMM_DELTS: - r = unifi_cfg_wmm_delts(priv, (unsigned char*)arg); - break; - case UNIFI_CFG_STRICT_DRAFT_N: - r = unifi_cfg_strict_draft_n(priv, (unsigned char*)arg); - break; - case UNIFI_CFG_ENABLE_OKC: - r = unifi_cfg_enable_okc(priv, (unsigned char*)arg); - break; -#ifdef CSR_SUPPORT_SME - case UNIFI_CFG_CORE_DUMP: - CsrWifiRouterCtrlWifiOffIndSend(priv->CSR_WIFI_SME_IFACEQUEUE, 0, CSR_WIFI_SME_CONTROL_INDICATION_ERROR); - unifi_trace(priv, UDBG2, "UNIFI_CFG_CORE_DUMP: sent wifi off indication\n"); - break; -#endif -#ifdef CSR_SUPPORT_WEXT_AP - case UNIFI_CFG_SET_AP_CONFIG: - r= unifi_cfg_set_ap_config(priv, (unsigned char*)arg); - break; -#endif - default: - unifi_error(priv, "UNIFI_CFG: Unknown Command (%d)\n", cfg_cmd); - r = -EINVAL; - goto out; - } -#endif - - break; - - case UNIFI_PUTEST: - if (get_user(putest_cmd, (unifi_putest_command_t*)arg)) - { - unifi_error(priv, "UNIFI_PUTEST: Failed to get the command\n"); - r = -EFAULT; - goto out; - } - - unifi_trace(priv, UDBG1, "UNIFI_PUTEST: Command is %s\n", - trace_putest_cmdid(putest_cmd)); - switch (putest_cmd) { - case UNIFI_PUTEST_START: - r = unifi_putest_start(priv, (unsigned char*)arg); - break; - case UNIFI_PUTEST_STOP: - r = unifi_putest_stop(priv, (unsigned char*)arg); - break; - case UNIFI_PUTEST_SET_SDIO_CLOCK: - r = unifi_putest_set_sdio_clock(priv, (unsigned char*)arg); - break; - case UNIFI_PUTEST_CMD52_READ: - r = unifi_putest_cmd52_read(priv, (unsigned char*)arg); - break; - case UNIFI_PUTEST_CMD52_BLOCK_READ: - r = unifi_putest_cmd52_block_read(priv, (unsigned char*)arg); - break; - case UNIFI_PUTEST_CMD52_WRITE: - r = unifi_putest_cmd52_write(priv, (unsigned char*)arg); - break; - case UNIFI_PUTEST_DL_FW: - r = unifi_putest_dl_fw(priv, (unsigned char*)arg); - break; - case UNIFI_PUTEST_DL_FW_BUFF: - r = unifi_putest_dl_fw_buff(priv, (unsigned char*)arg); - break; - case UNIFI_PUTEST_COREDUMP_PREPARE: - r = unifi_putest_coredump_prepare(priv, (unsigned char*)arg); - break; - case UNIFI_PUTEST_GP_READ16: - r = unifi_putest_gp_read16(priv, (unsigned char*)arg); - break; - case UNIFI_PUTEST_GP_WRITE16: - r = unifi_putest_gp_write16(priv, (unsigned char*)arg); - break; - default: - unifi_error(priv, "UNIFI_PUTEST: Unknown Command (%d)\n", putest_cmd); - r = -EINVAL; - goto out; - } - - break; - case UNIFI_BUILD_TYPE: - unifi_trace(priv, UDBG2, "UNIFI_BUILD_TYPE userspace=%s\n", build_type_to_string(*(unsigned char*)arg)); -#ifndef CSR_SUPPORT_WEXT_AP - if (UNIFI_BUILD_AP == *(unsigned char*)arg) - { - unifi_error(priv, "Userspace has AP support, which is incompatible\n"); - } -#endif - -#ifndef CSR_SUPPORT_WEXT - if (UNIFI_BUILD_WEXT == *(unsigned char*)arg) - { - unifi_error(priv, "Userspace has WEXT support, which is incompatible\n"); - } -#endif - break; - case UNIFI_INIT_HW: - unifi_trace(priv, UDBG2, "UNIFI_INIT_HW.\n"); - priv->init_progress = UNIFI_INIT_NONE; - -#if defined(CSR_SUPPORT_WEXT) || defined (CSR_NATIVE_LINUX) - /* At this point we are ready to start the SME. */ - r = sme_mgt_wifi_on(priv); - if (r) { - goto out; - } -#endif - - break; - - case UNIFI_INIT_NETDEV: - { - /* get the proper interfaceTagId */ - u16 interfaceTag=0; - netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag]; - - dev = priv->netdev[interfaceTag]; - unifi_trace(priv, UDBG2, "UNIFI_INIT_NETDEV.\n"); - - if (copy_from_user((void*)dev->dev_addr, (void*)arg, 6)) { - r = -EFAULT; - goto out; - } - - /* Attach the network device to the stack */ - if (!interfacePriv->netdev_registered) - { - r = uf_register_netdev(priv, interfaceTag); - if (r) { - unifi_error(priv, "Failed to register the network device.\n"); - goto out; - } - } - - /* Apply scheduled interrupt mode, if requested by module param */ - if (run_bh_once != -1) { - unifi_set_interrupt_mode(priv->card, (u32)run_bh_once); - } - - priv->init_progress = UNIFI_INIT_COMPLETED; - - /* Firmware initialisation is complete, so let the SDIO bus - * clock be raised when convienent to the core. - */ - unifi_request_max_sdio_clock(priv->card); - -#ifdef CSR_SUPPORT_WEXT - /* Notify the Android wpa_supplicant that we are ready */ - wext_send_started_event(priv); -#endif - - unifi_info(priv, "UniFi ready\n"); - -#ifdef ANDROID_BUILD - /* Release the wakelock */ - unifi_trace(priv, UDBG1, "netdev_init: release wake lock\n"); - wake_unlock(&unifi_sdio_wake_lock); -#endif -#ifdef CSR_NATIVE_SOFTMAC /* For softmac dev, force-enable the network interface rather than wait for a connected-ind */ - { - struct net_device *dev = priv->netdev[interfaceTag]; -#ifdef CSR_SUPPORT_WEXT - interfacePriv->wait_netdev_change = TRUE; -#endif - netif_carrier_on(dev); - } -#endif - } - break; - case UNIFI_GET_INIT_STATUS: - unifi_trace(priv, UDBG2, "UNIFI_GET_INIT_STATUS.\n"); - if (put_user(priv->init_progress, (int*)arg)) - { - printk(KERN_ERR "UNIFI_GET_INIT_STATUS: Failed to copy to user\n"); - r = -EFAULT; - goto out; - } - break; - - case UNIFI_KICK: - unifi_trace(priv, UDBG4, "Kick UniFi\n"); - unifi_sdio_interrupt_handler(priv->card); - break; - - case UNIFI_SET_DEBUG: - unifi_debug = arg; - unifi_trace(priv, UDBG4, "unifi_debug set to %d\n", unifi_debug); - break; - - case UNIFI_SET_TRACE: - /* no longer supported */ - r = -EINVAL; - break; - - - case UNIFI_SET_UDI_LOG_MASK: - { - unifiio_filter_t udi_filter; - uint16_t *sig_ids_addr; -#define UF_MAX_SIG_IDS 128 /* Impose a sensible limit */ - - if (copy_from_user((void*)(&udi_filter), (void*)arg, sizeof(udi_filter))) { - r = -EFAULT; - goto out; - } - if ((udi_filter.action < UfSigFil_AllOn) || - (udi_filter.action > UfSigFil_SelectOff)) - { - printk(KERN_WARNING - "UNIFI_SET_UDI_LOG_MASK: Bad action value: %d\n", - udi_filter.action); - r = -EINVAL; - goto out; - } - /* No signal list for "All" actions */ - if ((udi_filter.action == UfSigFil_AllOn) || - (udi_filter.action == UfSigFil_AllOff)) - { - udi_filter.num_sig_ids = 0; - } - - if (udi_filter.num_sig_ids > UF_MAX_SIG_IDS) { - printk(KERN_WARNING - "UNIFI_SET_UDI_LOG_MASK: too many signal ids (%d, max %d)\n", - udi_filter.num_sig_ids, UF_MAX_SIG_IDS); - r = -EINVAL; - goto out; - } - - /* Copy in signal id list if given */ - if (udi_filter.num_sig_ids > 0) { - /* Preserve userspace address of sig_ids array */ - sig_ids_addr = udi_filter.sig_ids; - /* Allocate kernel memory for sig_ids and copy to it */ - udi_filter.sig_ids = - kmalloc(udi_filter.num_sig_ids * sizeof(uint16_t), GFP_KERNEL); - if (!udi_filter.sig_ids) { - r = -ENOMEM; - goto out; - } - if (copy_from_user((void*)udi_filter.sig_ids, - (void*)sig_ids_addr, - udi_filter.num_sig_ids * sizeof(uint16_t))) - { - kfree(udi_filter.sig_ids); - r = -EFAULT; - goto out; - } - } - - udi_set_log_filter(pcli, &udi_filter); - - if (udi_filter.num_sig_ids > 0) { - kfree(udi_filter.sig_ids); - } - } - break; - - case UNIFI_SET_AMP_ENABLE: - unifi_trace(priv, UDBG4, "UniFi Set AMP Enable\n"); - if (get_user(int_param, (int*)arg)) - { - unifi_error(priv, "UNIFI_SET_AMP_ENABLE: Failed to copy from user\n"); - r = -EFAULT; - goto out; - } - - if (int_param) { - priv->amp_client = pcli; - } else { - priv->amp_client = NULL; - } - - int_param = 0; - buf = (u8*)&int_param; - buf[0] = UNIFI_SOFT_COMMAND_Q_LENGTH - 1; - buf[1] = UNIFI_SOFT_TRAFFIC_Q_LENGTH - 1; - if (copy_to_user((void*)arg, &int_param, sizeof(int))) { - r = -EFAULT; - goto out; - } - break; - - case UNIFI_SET_UDI_SNAP_MASK: - { - unifiio_snap_filter_t snap_filter; - - if (copy_from_user((void*)(&snap_filter), (void*)arg, sizeof(snap_filter))) { - r = -EFAULT; - goto out; - } - - if (pcli->snap_filter.count) { - pcli->snap_filter.count = 0; - kfree(pcli->snap_filter.protocols); - } - - if (snap_filter.count == 0) { - break; - } - - pcli->snap_filter.protocols = kmalloc(snap_filter.count * sizeof(u16), GFP_KERNEL); - if (!pcli->snap_filter.protocols) { - r = -ENOMEM; - goto out; - } - if (copy_from_user((void*)pcli->snap_filter.protocols, - (void*)snap_filter.protocols, - snap_filter.count * sizeof(u16))) - { - kfree(pcli->snap_filter.protocols); - r = -EFAULT; - goto out; - } - - pcli->snap_filter.count = snap_filter.count; - - } - break; - - case UNIFI_SME_PRESENT: - { - u8 ind; - unifi_trace(priv, UDBG4, "UniFi SME Present IOCTL.\n"); - if (copy_from_user((void*)(&int_param), (void*)arg, sizeof(int))) - { - printk(KERN_ERR "UNIFI_SME_PRESENT: Failed to copy from user\n"); - r = -EFAULT; - goto out; - } - - priv->sme_is_present = int_param; - if (priv->sme_is_present == 1) { - ind = CONFIG_SME_PRESENT; - } else { - ind = CONFIG_SME_NOT_PRESENT; - } - /* Send an indication to the helper app. */ - ul_log_config_ind(priv, &ind, sizeof(u8)); - } - break; - - case UNIFI_CFG_PERIOD_TRAFFIC: - { -#if (defined CSR_SUPPORT_SME) && (defined CSR_SUPPORT_WEXT) - CsrWifiSmeCoexConfig coexConfig; -#endif /* CSR_SUPPORT_SME && CSR_SUPPORT_WEXT */ - unifi_trace(priv, UDBG4, "UniFi Configure Periodic Traffic.\n"); -#if (defined CSR_SUPPORT_SME) && (defined CSR_SUPPORT_WEXT) - if (copy_from_user((void*)(&uchar_param), (void*)arg, sizeof(unsigned char))) { - unifi_error(priv, "UNIFI_CFG_PERIOD_TRAFFIC: Failed to copy from user\n"); - r = -EFAULT; - goto out; - } - - if (uchar_param == 0) { - r = sme_mgt_coex_config_get(priv, &coexConfig); - if (r) { - unifi_error(priv, "UNIFI_CFG_PERIOD_TRAFFIC: Get unifi_CoexInfoValue failed.\n"); - goto out; - } - if (copy_to_user((void*)(arg + 1), - (void*)&coexConfig, - sizeof(CsrWifiSmeCoexConfig))) { - r = -EFAULT; - goto out; - } - goto out; - } - - if (copy_from_user((void*)(&coex_config), (void*)(arg + 1), sizeof(CsrWifiSmeCoexConfig))) - { - unifi_error(priv, "UNIFI_CFG_PERIOD_TRAFFIC: Failed to copy from user\n"); - r = -EFAULT; - goto out; - } - - coexConfig = coex_config; - r = sme_mgt_coex_config_set(priv, &coexConfig); - if (r) { - unifi_error(priv, "UNIFI_CFG_PERIOD_TRAFFIC: Set unifi_CoexInfoValue failed.\n"); - goto out; - } - -#endif /* CSR_SUPPORT_SME && CSR_SUPPORT_WEXT */ - break; - } - case UNIFI_CFG_UAPSD_TRAFFIC: - unifi_trace(priv, UDBG4, "UniFi Configure U-APSD Mask.\n"); -#if (defined CSR_SUPPORT_SME) && (defined CSR_SUPPORT_WEXT) - if (copy_from_user((void*)(&uchar_param), (void*)arg, sizeof(unsigned char))) { - unifi_error(priv, "UNIFI_CFG_UAPSD_TRAFFIC: Failed to copy from user\n"); - r = -EFAULT; - goto out; - } - unifi_trace(priv, UDBG4, "New U-APSD Mask: 0x%x\n", uchar_param); -#endif /* CSR_SUPPORT_SME && CSR_SUPPORT_WEXT */ - break; - -#ifndef UNIFI_DISABLE_COREDUMP - case UNIFI_COREDUMP_GET_REG: - unifi_trace(priv, UDBG4, "Mini-coredump data request\n"); - { - unifiio_coredump_req_t dump_req; /* Public OS layer structure */ - unifi_coredump_req_t priv_req; /* Private HIP structure */ - - if (copy_from_user((void*)(&dump_req), (void*)arg, sizeof(dump_req))) { - r = -EFAULT; - goto out; - } - memset(&priv_req, 0, sizeof(priv_req)); - priv_req.index = dump_req.index; - priv_req.offset = dump_req.offset; - - /* Convert OS-layer's XAP memory space ID to HIP's ID in case they differ */ - switch (dump_req.space) { - case UNIFIIO_COREDUMP_MAC_REG: priv_req.space = UNIFI_COREDUMP_MAC_REG; break; - case UNIFIIO_COREDUMP_PHY_REG: priv_req.space = UNIFI_COREDUMP_PHY_REG; break; - case UNIFIIO_COREDUMP_SH_DMEM: priv_req.space = UNIFI_COREDUMP_SH_DMEM; break; - case UNIFIIO_COREDUMP_MAC_DMEM: priv_req.space = UNIFI_COREDUMP_MAC_DMEM; break; - case UNIFIIO_COREDUMP_PHY_DMEM: priv_req.space = UNIFI_COREDUMP_PHY_DMEM; break; - case UNIFIIO_COREDUMP_TRIGGER_MAGIC: priv_req.space = UNIFI_COREDUMP_TRIGGER_MAGIC; break; - default: - r = -EINVAL; - goto out; - } - - if (priv_req.space == UNIFI_COREDUMP_TRIGGER_MAGIC) { - /* Force a coredump grab now */ - unifi_trace(priv, UDBG2, "UNIFI_COREDUMP_GET_REG: Force capture\n"); - csrResult = unifi_coredump_capture(priv->card, &priv_req); - r = CsrHipResultToStatus(csrResult); - unifi_trace(priv, UDBG5, "UNIFI_COREDUMP_GET_REG: status %d\n", r); - } else { - /* Retrieve the appropriate register entry */ - csrResult = unifi_coredump_get_value(priv->card, &priv_req); - r = CsrHipResultToStatus(csrResult); - if (r) { - unifi_trace(priv, UDBG5, "UNIFI_COREDUMP_GET_REG: Status %d\n", r); - goto out; - } - /* Update the OS-layer structure with values returned in the private */ - dump_req.value = priv_req.value; - dump_req.timestamp = priv_req.timestamp; - dump_req.requestor = priv_req.requestor; - dump_req.serial = priv_req.serial; - dump_req.chip_ver = priv_req.chip_ver; - dump_req.fw_ver = priv_req.fw_ver; - dump_req.drv_build = 0; - - unifi_trace(priv, UDBG6, - "Dump: %d (seq %d): V:0x%04x (%d) @0x%02x:%04x = 0x%04x\n", - dump_req.index, dump_req.serial, - dump_req.chip_ver, dump_req.drv_build, - dump_req.space, dump_req.offset, dump_req.value); - } - if (copy_to_user((void*)arg, (void*)&dump_req, sizeof(dump_req))) { - r = -EFAULT; - goto out; - } - } - break; -#endif - default: - r = -EINVAL; - } - -out: - return (long)r; -} /* unifi_ioctl() */ - - - -static unsigned int -unifi_poll(struct file *filp, poll_table *wait) -{ - ul_client_t *pcli = (ul_client_t*)filp->private_data; - unsigned int mask = 0; - int ready; - - ready = !list_empty(&pcli->udi_log); - - poll_wait(filp, &pcli->udi_wq, wait); - - if (ready) { - mask |= POLLIN | POLLRDNORM; /* readable */ - } - - return mask; -} /* unifi_poll() */ - - - -/* - * --------------------------------------------------------------------------- - * udi_set_log_filter - * - * Configure the bit mask that determines which signal primitives are - * passed to the logging process. - * - * Arguments: - * pcli Pointer to the client to configure. - * udi_filter Pointer to a unifiio_filter_t containing instructions. - * - * Returns: - * None. - * - * Notes: - * SigGetFilterPos() returns a 32-bit value that contains an index and a - * mask for accessing a signal_filter array. The top 16 bits specify an - * index into a signal_filter, the bottom 16 bits specify a mask to - * apply. - * --------------------------------------------------------------------------- - */ -static void -udi_set_log_filter(ul_client_t *pcli, unifiio_filter_t *udi_filter) -{ - u32 filter_pos; - int i; - - if (udi_filter->action == UfSigFil_AllOn) - { - for (i = 0; i < SIG_FILTER_SIZE; i++) { - pcli->signal_filter[i] = 0xFFFF; - } - } - else if (udi_filter->action == UfSigFil_AllOff) - { - for (i = 0; i < SIG_FILTER_SIZE; i++) { - pcli->signal_filter[i] = 0; - } - } - else if (udi_filter->action == UfSigFil_SelectOn) - { - for (i = 0; i < udi_filter->num_sig_ids; i++) { - filter_pos = SigGetFilterPos(udi_filter->sig_ids[i]); - if (filter_pos == 0xFFFFFFFF) - { - printk(KERN_WARNING - "Unrecognised signal id (0x%X) specifed in logging filter\n", - udi_filter->sig_ids[i]); - } else { - pcli->signal_filter[filter_pos >> 16] |= (filter_pos & 0xFFFF); - } - } - } - else if (udi_filter->action == UfSigFil_SelectOff) - { - for (i = 0; i < udi_filter->num_sig_ids; i++) { - filter_pos = SigGetFilterPos(udi_filter->sig_ids[i]); - if (filter_pos == 0xFFFFFFFF) - { - printk(KERN_WARNING - "Unrecognised signal id (0x%X) specifed in logging filter\n", - udi_filter->sig_ids[i]); - } else { - pcli->signal_filter[filter_pos >> 16] &= ~(filter_pos & 0xFFFF); - } - } - } - -} /* udi_set_log_filter() */ - - -/* - * --------------------------------------------------------------------------- - * udi_log_event - * - * Callback function to be registered as the UDI hook callback. - * Copies the signal content into a new udi_log_t struct and adds - * it to the read queue for this UDI client. - * - * Arguments: - * pcli A pointer to the client instance. - * signal Pointer to the received signal. - * signal_len Size of the signal structure in bytes. - * bulkdata Pointers to any associated bulk data. - * dir Direction of the signal. Zero means from host, - * non-zero means to host. - * - * Returns: - * None. - * --------------------------------------------------------------------------- - */ -void -udi_log_event(ul_client_t *pcli, - const u8 *signal, int signal_len, - const bulk_data_param_t *bulkdata, - int dir) -{ - udi_log_t *logptr; - u8 *p; - int i; - int total_len; - udi_msg_t *msgptr; - u32 filter_pos; -#ifdef OMNICLI_LINUX_EXTRA_LOG - static volatile unsigned int printk_cpu = UINT_MAX; - unsigned long long t; - unsigned long nanosec_rem; - unsigned long n_1000; -#endif - - /* Just a sanity check */ - if ((signal == NULL) || (signal_len <= 0)) { - return; - } - -#ifdef CSR_WIFI_HIP_DEBUG_OFFLINE - /* When HIP offline signal logging is enabled, omnicli cannot run */ - if (log_hip_signals) - { - /* Add timestamp */ - if (log_hip_signals & UNIFI_LOG_HIP_SIGNALS_FILTER_TIMESTAMP) - { - int timestamp = jiffies_to_msecs(jiffies); - unifi_debug_log_to_buf("T:"); - unifi_debug_log_to_buf("%04X%04X ", *(((u16*)×tamp) + 1), - *(u16*)×tamp); - } - - /* Add signal */ - unifi_debug_log_to_buf("S%s:%04X R:%04X D:%04X ", - dir ? "T" : "F", - *(u16*)signal, - *(u16*)(signal + 2), - *(u16*)(signal + 4)); - unifi_debug_hex_to_buf(signal + 6, signal_len - 6); - - /* Add bulk data (assume 1 bulk data per signal) */ - if ((log_hip_signals & UNIFI_LOG_HIP_SIGNALS_FILTER_BULKDATA) && - (bulkdata->d[0].data_length > 0)) - { - unifi_debug_log_to_buf("\nD:"); - unifi_debug_hex_to_buf(bulkdata->d[0].os_data_ptr, bulkdata->d[0].data_length); - } - unifi_debug_log_to_buf("\n"); - - return; - } -#endif - -#ifdef CSR_NATIVE_LINUX - uf_native_process_udi_signal(pcli, signal, signal_len, bulkdata, dir); -#endif - - /* - * Apply the logging filter - only report signals that have their - * bit set in the filter mask. - */ - filter_pos = SigGetFilterPos(GET_SIGNAL_ID(signal)); - - if ((filter_pos != 0xFFFFFFFF) && - ((pcli->signal_filter[filter_pos >> 16] & (filter_pos & 0xFFFF)) == 0)) - { - /* Signal is not wanted by client */ - return; - } - - - /* Calculate the buffer we need to store signal plus bulk data */ - total_len = signal_len; - for (i = 0; i < UNIFI_MAX_DATA_REFERENCES; i++) { - total_len += bulkdata->d[i].data_length; - } - - /* Allocate log structure plus actual signal. */ - logptr = kmalloc(sizeof(udi_log_t) + total_len, GFP_KERNEL); - - if (logptr == NULL) { - printk(KERN_ERR - "Failed to allocate %lu bytes for a UDI log record\n", - (long unsigned int)(sizeof(udi_log_t) + total_len)); - return; - } - - /* Fill in udi_log struct */ - INIT_LIST_HEAD(&logptr->q); - msgptr = &logptr->msg; - msgptr->length = sizeof(udi_msg_t) + total_len; -#ifdef OMNICLI_LINUX_EXTRA_LOG - t = cpu_clock(printk_cpu); - nanosec_rem = do_div(t, 1000000000); - n_1000 = nanosec_rem/1000; - msgptr->timestamp = (t <<10 ) | ((unsigned long)(n_1000 >> 10) & 0x3ff); -#else - msgptr->timestamp = jiffies_to_msecs(jiffies); -#endif - msgptr->direction = dir; - msgptr->signal_length = signal_len; - - /* Copy signal and bulk data to the log */ - p = (u8 *)(msgptr + 1); - memcpy(p, signal, signal_len); - p += signal_len; - - /* Append any bulk data */ - for (i = 0; i < UNIFI_MAX_DATA_REFERENCES; i++) { - int len = bulkdata->d[i].data_length; - - /* - * Len here might not be the same as the length in the bulk data slot. - * The slot length will always be even, but len could be odd. - */ - if (len > 0) { - if (bulkdata->d[i].os_data_ptr) { - memcpy(p, bulkdata->d[i].os_data_ptr, len); - } else { - memset(p, 0, len); - } - p += len; - } - } - - /* Add to tail of log queue */ - if (down_interruptible(&pcli->udi_sem)) { - printk(KERN_WARNING "udi_log_event_q: Failed to get udi sem\n"); - kfree(logptr); - return; - } - list_add_tail(&logptr->q, &pcli->udi_log); - up(&pcli->udi_sem); - - /* Wake any waiting user process */ - wake_up_interruptible(&pcli->udi_wq); - -} /* udi_log_event() */ - -#ifdef CSR_SME_USERSPACE -int -uf_sme_queue_message(unifi_priv_t *priv, u8 *buffer, int length) -{ - udi_log_t *logptr; - udi_msg_t *msgptr; - u8 *p; - - /* Just a sanity check */ - if ((buffer == NULL) || (length <= 0)) { - return -EINVAL; - } - - /* Allocate log structure plus actual signal. */ - logptr = kmalloc(sizeof(udi_log_t) + length, GFP_ATOMIC); - if (logptr == NULL) { - unifi_error(priv, "Failed to allocate %d bytes for an SME message\n", - sizeof(udi_log_t) + length); - kfree(buffer); - return -ENOMEM; - } - - /* Fill in udi_log struct */ - INIT_LIST_HEAD(&logptr->q); - msgptr = &logptr->msg; - msgptr->length = sizeof(udi_msg_t) + length; - msgptr->signal_length = length; - - /* Copy signal and bulk data to the log */ - p = (u8 *)(msgptr + 1); - memcpy(p, buffer, length); - - /* Add to tail of log queue */ - down(&udi_mutex); - if (priv->sme_cli == NULL) { - kfree(logptr); - kfree(buffer); - up(&udi_mutex); - unifi_info(priv, "Message for the SME dropped, SME has gone away\n"); - return 0; - } - - down(&priv->sme_cli->udi_sem); - list_add_tail(&logptr->q, &priv->sme_cli->udi_log); - up(&priv->sme_cli->udi_sem); - - /* Wake any waiting user process */ - wake_up_interruptible(&priv->sme_cli->udi_wq); - up(&udi_mutex); - - /* It is our responsibility to free the buffer allocated in build_packed_*() */ - kfree(buffer); - - return 0; - -} /* uf_sme_queue_message() */ -#endif - -/* - **************************************************************************** - * - * Driver instantiation - * - **************************************************************************** - */ -static const struct file_operations unifi_fops = { - .owner = THIS_MODULE, - .open = unifi_open, - .release = unifi_release, - .read = unifi_read, - .write = unifi_write, - .unlocked_ioctl = unifi_ioctl, - .poll = unifi_poll, -}; - -static dev_t unifi_first_devno; -static struct class *unifi_class; - - -int uf_create_device_nodes(unifi_priv_t *priv, int bus_id) -{ - dev_t devno; - int r; - - cdev_init(&priv->unifi_cdev, &unifi_fops); - - /* cdev_init() should set the cdev owner, but it does not */ - priv->unifi_cdev.owner = THIS_MODULE; - - devno = MKDEV(MAJOR(unifi_first_devno), - MINOR(unifi_first_devno) + (bus_id * 2)); - r = cdev_add(&priv->unifi_cdev, devno, 1); - if (r) { - return r; - } - -#ifdef SDIO_EXPORTS_STRUCT_DEVICE - if (!device_create(unifi_class, priv->unifi_device, - devno, priv, "unifi%d", bus_id)) { -#else - priv->unifi_device = device_create(unifi_class, NULL, - devno, priv, "unifi%d", bus_id); - if (priv->unifi_device == NULL) { -#endif /* SDIO_EXPORTS_STRUCT_DEVICE */ - - cdev_del(&priv->unifi_cdev); - return -EINVAL; - } - - cdev_init(&priv->unifiudi_cdev, &unifi_fops); - - /* cdev_init() should set the cdev owner, but it does not */ - priv->unifiudi_cdev.owner = THIS_MODULE; - - devno = MKDEV(MAJOR(unifi_first_devno), - MINOR(unifi_first_devno) + (bus_id * 2) + 1); - r = cdev_add(&priv->unifiudi_cdev, devno, 1); - if (r) { - device_destroy(unifi_class, priv->unifi_cdev.dev); - cdev_del(&priv->unifi_cdev); - return r; - } - - if (!device_create(unifi_class, -#ifdef SDIO_EXPORTS_STRUCT_DEVICE - priv->unifi_device, -#else - NULL, -#endif /* SDIO_EXPORTS_STRUCT_DEVICE */ - devno, priv, "unifiudi%d", bus_id)) { - device_destroy(unifi_class, priv->unifi_cdev.dev); - cdev_del(&priv->unifiudi_cdev); - cdev_del(&priv->unifi_cdev); - return -EINVAL; - } - - return 0; -} - - -void uf_destroy_device_nodes(unifi_priv_t *priv) -{ - device_destroy(unifi_class, priv->unifiudi_cdev.dev); - device_destroy(unifi_class, priv->unifi_cdev.dev); - cdev_del(&priv->unifiudi_cdev); - cdev_del(&priv->unifi_cdev); -} - - - -/* - * ---------------------------------------------------------------- - * uf_create_debug_device - * - * Allocates device numbers for unifi character device nodes - * and creates a unifi class in sysfs - * - * Arguments: - * fops Pointer to the char device operations structure. - * - * Returns: - * 0 on success, -ve error code on error. - * ---------------------------------------------------------------- - */ -static int -uf_create_debug_device(const struct file_operations *fops) -{ - int ret; - - /* Allocate two device numbers for each device. */ - ret = alloc_chrdev_region(&unifi_first_devno, 0, MAX_UNIFI_DEVS*2, UNIFI_NAME); - if (ret) { - unifi_error(NULL, "Failed to add alloc dev numbers: %d\n", ret); - return ret; - } - - /* Create a UniFi class */ - unifi_class = class_create(THIS_MODULE, UNIFI_NAME); - if (IS_ERR(unifi_class)) { - unifi_error(NULL, "Failed to create UniFi class\n"); - - /* Release device numbers */ - unregister_chrdev_region(unifi_first_devno, MAX_UNIFI_DEVS*2); - unifi_first_devno = 0; - return -EINVAL; - } - - return 0; -} /* uf_create_debug_device() */ - - -/* - * ---------------------------------------------------------------- - * uf_remove_debug_device - * - * Destroys the unifi class and releases the allocated - * device numbers for unifi character device nodes. - * - * Arguments: - * - * Returns: - * ---------------------------------------------------------------- - */ -static void -uf_remove_debug_device(void) -{ - /* Destroy the UniFi class */ - class_destroy(unifi_class); - - /* Release device numbers */ - unregister_chrdev_region(unifi_first_devno, MAX_UNIFI_DEVS*2); - unifi_first_devno = 0; - -} /* uf_remove_debug_device() */ - - -/* - * --------------------------------------------------------------------------- - * - * Module loading. - * - * --------------------------------------------------------------------------- - */ -int __init -unifi_load(void) -{ - int r; - - printk("UniFi SDIO Driver: %s %s %s\n", - CSR_WIFI_VERSION, - __DATE__, __TIME__); - -#ifdef CSR_SME_USERSPACE -#ifdef CSR_SUPPORT_WEXT - printk("CSR SME with WEXT support\n"); -#else - printk("CSR SME no WEXT support\n"); -#endif /* CSR_SUPPORT_WEXT */ -#endif /* CSR_SME_USERSPACE */ - -#ifdef CSR_NATIVE_LINUX -#ifdef CSR_SUPPORT_WEXT -#error WEXT unsupported in the native driver -#endif - printk("CSR native no WEXT support\n"); -#endif -#ifdef CSR_WIFI_SPLIT_PATCH - printk("Split patch support\n"); -#endif - printk("Kernel %d.%d.%d\n", - ((LINUX_VERSION_CODE) >> 16) & 0xff, - ((LINUX_VERSION_CODE) >> 8) & 0xff, - (LINUX_VERSION_CODE) & 0xff); - /* - * Instantiate the /dev/unifi* device nodes. - * We must do this before registering with the SDIO driver because it - * will immediately call the "insert" callback if the card is - * already present. - */ - r = uf_create_debug_device(&unifi_fops); - if (r) { - return r; - } - - /* Now register with the SDIO driver */ - r = uf_sdio_load(); - if (r) { - uf_remove_debug_device(); - return r; - } - - if (sdio_block_size > -1) { - unifi_info(NULL, "sdio_block_size %d\n", sdio_block_size); - } - - if (sdio_byte_mode) { - unifi_info(NULL, "sdio_byte_mode\n"); - } - - if (disable_power_control) { - unifi_info(NULL, "disable_power_control\n"); - } - - if (disable_hw_reset) { - unifi_info(NULL, "disable_hw_reset\n"); - } - - if (enable_wol) { - unifi_info(NULL, "enable_wol %d\n", enable_wol); - } - - if (run_bh_once != -1) { - unifi_info(NULL, "run_bh_once %d\n", run_bh_once); - } - - return 0; -} /* unifi_load() */ - - -void __exit -unifi_unload(void) -{ - /* The SDIO remove hook will call unifi_disconnect(). */ - uf_sdio_unload(); - - uf_remove_debug_device(); - -} /* unifi_unload() */ - -module_init(unifi_load); -module_exit(unifi_unload); - -MODULE_DESCRIPTION("UniFi Device driver"); -MODULE_AUTHOR("Cambridge Silicon Radio Ltd."); -MODULE_LICENSE("GPL and additional rights"); diff --git a/drivers/staging/csr/firmware.c b/drivers/staging/csr/firmware.c deleted file mode 100644 index b42a4d6a0c36..000000000000 --- a/drivers/staging/csr/firmware.c +++ /dev/null @@ -1,396 +0,0 @@ -/* - * --------------------------------------------------------------------------- - * FILE: firmware.c - * - * PURPOSE: - * Implements the f/w related HIP core lib API. - * It is part of the porting exercise in Linux. - * - * Also, it contains example code for reading the loader and f/w files - * from the userspace and starting the SME in Linux. - * - * Copyright (C) 2005-2009 by Cambridge Silicon Radio Ltd. - * - * Refer to LICENSE.txt included with this source code for details on - * the license terms. - * - * --------------------------------------------------------------------------- - */ -#include -#include -#include -#include -#include "csr_wifi_hip_unifi.h" -#include "csr_wifi_hip_unifi_udi.h" -#include "unifiio.h" -#include "unifi_priv.h" - -/* - * --------------------------------------------------------------------------- - * - * F/W download. Part of the HIP core API - * - * --------------------------------------------------------------------------- - */ - - -/* - * --------------------------------------------------------------------------- - * unifi_fw_read_start - * - * Returns a structure to be passed in unifi_fw_read(). - * This structure is an OS specific description of the f/w file. - * In the linux implementation it is a buffer with the f/w and its' length. - * The HIP driver calls this functions to request for the loader or - * the firmware file. - * The structure pointer can be freed when unifi_fw_read_stop() is called. - * - * Arguments: - * ospriv Pointer to driver context. - * is_fw Type of firmware to retrieve - * info Versions information. Can be used to determine - * the appropriate f/w file to load. - * - * Returns: - * O on success, non-zero otherwise. - * - * --------------------------------------------------------------------------- - */ -void* -unifi_fw_read_start(void *ospriv, s8 is_fw, const card_info_t *info) -{ - unifi_priv_t *priv = (unifi_priv_t*)ospriv; - CSR_UNUSED(info); - - if (is_fw == UNIFI_FW_STA) { - /* F/w may have been released after a previous successful download. */ - if (priv->fw_sta.dl_data == NULL) { - unifi_trace(priv, UDBG2, "Attempt reload of sta f/w\n"); - uf_request_firmware_files(priv, UNIFI_FW_STA); - } - /* Set up callback struct for readfunc() */ - if (priv->fw_sta.dl_data != NULL) { - return &priv->fw_sta; - } - - } else { - unifi_error(priv, "downloading firmware... unknown request: %d\n", is_fw); - } - - return NULL; -} /* unifi_fw_read_start() */ - - - -/* - * --------------------------------------------------------------------------- - * unifi_fw_read_stop - * - * Called when the HIP driver has finished using the loader or - * the firmware file. - * The firmware buffer may be released now. - * - * Arguments: - * ospriv Pointer to driver context. - * dlpriv The pointer returned by unifi_fw_read_start() - * - * --------------------------------------------------------------------------- - */ -void -unifi_fw_read_stop(void *ospriv, void *dlpriv) -{ - unifi_priv_t *priv = (unifi_priv_t*)ospriv; - struct dlpriv *dl_struct = (struct dlpriv *)dlpriv; - - if (dl_struct != NULL) { - if (dl_struct->dl_data != NULL) { - unifi_trace(priv, UDBG2, "Release f/w buffer %p, %d bytes\n", - dl_struct->dl_data, dl_struct->dl_len); - } - uf_release_firmware(priv, dl_struct); - } - -} /* unifi_fw_read_stop() */ - - -/* - * --------------------------------------------------------------------------- - * unifi_fw_open_buffer - * - * Returns a handle for a buffer dynamically allocated by the driver, - * e.g. into which a firmware file may have been converted from another format - * which is the case with some production test images. - * - * The handle may then be used by unifi_fw_read() to access the contents of - * the buffer. - * - * Arguments: - * ospriv Pointer to driver context. - * fwbuf Buffer containing firmware image - * len Length of buffer in bytes - * - * Returns - * Handle for buffer, or NULL on error - * --------------------------------------------------------------------------- - */ -void * -unifi_fw_open_buffer(void *ospriv, void *fwbuf, u32 len) -{ - unifi_priv_t *priv = (unifi_priv_t*)ospriv; - - if (fwbuf == NULL) { - return NULL; - } - priv->fw_conv.dl_data = fwbuf; - priv->fw_conv.dl_len = len; - priv->fw_conv.fw_desc = NULL; /* No OS f/w resource is associated */ - - return &priv->fw_conv; -} - -/* - * --------------------------------------------------------------------------- - * unifi_fw_close_buffer - * - * Releases any handle for a buffer dynamically allocated by the driver, - * e.g. into which a firmware file may have been converted from another format - * which is the case with some production test images. - * - * - * Arguments: - * ospriv Pointer to driver context. - * fwbuf Buffer containing firmware image - * - * Returns - * Handle for buffer, or NULL on error - * --------------------------------------------------------------------------- - */ -void unifi_fw_close_buffer(void *ospriv, void *fwbuf) -{ -} - -/* - * --------------------------------------------------------------------------- - * unifi_fw_read - * - * The HIP driver calls this function to ask for a part of the loader or - * the firmware file. - * - * Arguments: - * ospriv Pointer to driver context. - * arg The pointer returned by unifi_fw_read_start(). - * offset The offset in the file to return from. - * buf A buffer to store the requested data. - * len The size of the buf and the size of the requested data. - * - * Returns - * The number of bytes read from the firmware image, or -ve on error - * --------------------------------------------------------------------------- - */ -s32 -unifi_fw_read(void *ospriv, void *arg, u32 offset, void *buf, u32 len) -{ - const struct dlpriv *dlpriv = arg; - - if (offset >= dlpriv->dl_len) { - /* at end of file */ - return 0; - } - - if ((offset + len) > dlpriv->dl_len) { - /* attempt to read past end of file */ - return -1; - } - - memcpy(buf, dlpriv->dl_data+offset, len); - - return len; - -} /* unifi_fw_read() */ - - - - -#define UNIFIHELPER_INIT_MODE_SMEUSER 2 -#define UNIFIHELPER_INIT_MODE_NATIVE 1 - -/* - * --------------------------------------------------------------------------- - * uf_run_unifihelper - * - * Ask userspace to send us firmware for download by running - * '/usr/sbin/unififw'. - * The same script starts the SME userspace application. - * Derived from net_run_sbin_hotplug(). - * - * Arguments: - * priv Pointer to OS private struct. - * - * Returns: - * None. - * --------------------------------------------------------------------------- - */ -int -uf_run_unifihelper(unifi_priv_t *priv) -{ -#ifdef ANDROID_BUILD - char *prog = "/system/bin/unififw"; -#else - char *prog = "/usr/sbin/unififw"; -#endif /* ANDROID_BUILD */ - - char *argv[6], *envp[4]; - char inst_str[8]; - char init_mode[8]; - int i, r; - -#if (defined CSR_SME_USERSPACE) && (!defined CSR_SUPPORT_WEXT) - unifi_trace(priv, UDBG1, "SME userspace build: run unifi_helper manually\n"); - return 0; -#endif - - unifi_trace(priv, UDBG1, "starting %s\n", prog); - - snprintf(inst_str, 8, "%d", priv->instance); -#if (defined CSR_SME_USERSPACE) - snprintf(init_mode, 8, "%d", UNIFIHELPER_INIT_MODE_SMEUSER); -#else - snprintf(init_mode, 8, "%d", UNIFIHELPER_INIT_MODE_NATIVE); -#endif /* CSR_SME_USERSPACE */ - - i = 0; - argv[i++] = prog; - argv[i++] = inst_str; - argv[i++] = init_mode; - argv[i++] = 0; - argv[i] = 0; - /* Don't add more args without making argv bigger */ - - /* minimal command environment */ - i = 0; - envp[i++] = "HOME=/"; - envp[i++] = "PATH=/sbin:/bin:/usr/sbin:/usr/bin"; - envp[i] = 0; - /* Don't add more without making envp bigger */ - - unifi_trace(priv, UDBG2, "running %s %s %s\n", argv[0], argv[1], argv[2]); - - r = call_usermodehelper(argv[0], argv, envp, UMH_WAIT_EXEC); - - return r; -} /* uf_run_unifihelper() */ - -#ifdef CSR_WIFI_SPLIT_PATCH -static u8 is_ap_mode(unifi_priv_t *priv) -{ - if (priv == NULL || priv->interfacePriv[0] == NULL) - { - return FALSE; - } - - /* Test for mode requiring AP patch */ - return(CSR_WIFI_HIP_IS_AP_FW(priv->interfacePriv[0]->interfaceMode)); -} -#endif - -/* - * --------------------------------------------------------------------------- - * uf_request_firmware_files - * - * Get the firmware files from userspace. - * - * Arguments: - * priv Pointer to OS private struct. - * is_fw type of firmware to load (UNIFI_FW_STA/LOADER) - * - * Returns: - * None. - * --------------------------------------------------------------------------- - */ -int uf_request_firmware_files(unifi_priv_t *priv, int is_fw) -{ - /* uses the default method to get the firmware */ - const struct firmware *fw_entry; - int postfix; -#define UNIFI_MAX_FW_PATH_LEN 32 - char fw_name[UNIFI_MAX_FW_PATH_LEN]; - int r; - -#if (defined CSR_SUPPORT_SME) && (defined CSR_SUPPORT_WEXT) - if (priv->mib_data.length) { - vfree(priv->mib_data.data); - priv->mib_data.data = NULL; - priv->mib_data.length = 0; - } -#endif /* CSR_SUPPORT_SME && CSR_SUPPORT_WEXT*/ - - postfix = priv->instance; - - if (is_fw == UNIFI_FW_STA) { - /* Free kernel buffer and reload */ - uf_release_firmware(priv, &priv->fw_sta); -#ifdef CSR_WIFI_SPLIT_PATCH - scnprintf(fw_name, UNIFI_MAX_FW_PATH_LEN, "unifi-sdio-%d/%s", - postfix, (is_ap_mode(priv) ? "ap.xbv" : "staonly.xbv") ); -#else - scnprintf(fw_name, UNIFI_MAX_FW_PATH_LEN, "unifi-sdio-%d/%s", - postfix, "sta.xbv" ); -#endif - r = request_firmware(&fw_entry, fw_name, priv->unifi_device); - if (r == 0) { - priv->fw_sta.dl_data = fw_entry->data; - priv->fw_sta.dl_len = fw_entry->size; - priv->fw_sta.fw_desc = (void *)fw_entry; - } else { - unifi_trace(priv, UDBG2, "Firmware file not available\n"); - } - } - - return 0; - -} /* uf_request_firmware_files() */ - -/* - * --------------------------------------------------------------------------- - * uf_release_firmware_files - * - * Release all buffers used to store firmware files - * - * Arguments: - * priv Pointer to OS private struct. - * - * Returns: - * None. - * --------------------------------------------------------------------------- - */ -int uf_release_firmware_files(unifi_priv_t *priv) -{ - uf_release_firmware(priv, &priv->fw_sta); - - return 0; -} - -/* - * --------------------------------------------------------------------------- - * uf_release_firmware - * - * Release specific buffer used to store firmware - * - * Arguments: - * priv Pointer to OS private struct. - * to_free Pointer to specific buffer to release - * - * Returns: - * None. - * --------------------------------------------------------------------------- - */ -int uf_release_firmware(unifi_priv_t *priv, struct dlpriv *to_free) -{ - if (to_free != NULL) { - release_firmware((const struct firmware *)to_free->fw_desc); - to_free->fw_desc = NULL; - to_free->dl_data = NULL; - to_free->dl_len = 0; - } - return 0; -} diff --git a/drivers/staging/csr/inet.c b/drivers/staging/csr/inet.c deleted file mode 100644 index b3ef818fef35..000000000000 --- a/drivers/staging/csr/inet.c +++ /dev/null @@ -1,104 +0,0 @@ -/* - * --------------------------------------------------------------------------- - * FILE: inet.c - * - * PURPOSE: - * Routines related to IP address changes. - * Optional part of the porting exercise. It uses system network - * handlers to obtain the UniFi IP address and pass it to the SME - * using the unifi_sys_ip_configured_ind(). - * - * Copyright (C) 2008-2009 Cambridge Silicon Radio Ltd. - * - * Refer to LICENSE.txt included with this source code for details on - * the license terms. - * - * --------------------------------------------------------------------------- - */ -#include -#include - -#include "unifi_priv.h" -#include "csr_wifi_hip_conversions.h" - -/* - * The inet notifier is global and not per-netdev. To avoid having a - * notifier registered when there are no unifi devices present, it's - * registered after the first unifi network device is registered, and - * unregistered when the last unifi network device is unregistered. - */ - -static atomic_t inet_notif_refs = ATOMIC_INIT(0); - -static int uf_inetaddr_event(struct notifier_block *notif, unsigned long event, void *ifa) -{ - struct net_device *ndev; - unifi_priv_t *priv; - struct in_ifaddr *if_addr; - netInterface_priv_t *InterfacePriv = (netInterface_priv_t *)NULL; - - if (!ifa || !((struct in_ifaddr *)ifa)->ifa_dev) { - unifi_trace(NULL, UDBG1, "uf_inetaddr_event (%lu) ifa=%p\n", event, ifa); - return NOTIFY_DONE; - } - - ndev = ((struct in_ifaddr *)ifa)->ifa_dev->dev; - InterfacePriv = (netInterface_priv_t*) netdev_priv(ndev); - - /* As the notifier is global, the call may be for a non-UniFi netdev. - * Therefore check the netdev_priv to make sure it's a known UniFi one. - */ - if (uf_find_netdev_priv(InterfacePriv) == -1) { - unifi_trace(NULL, UDBG1, "uf_inetaddr_event (%lu) ndev=%p, other netdev_priv=%p\n", - event, ndev, InterfacePriv); - return NOTIFY_DONE; - } - - if (!InterfacePriv->privPtr) { - unifi_error(NULL, "uf_inetaddr_event null priv (%lu) ndev=%p, InterfacePriv=%p\n", - event, ndev, InterfacePriv); - return NOTIFY_DONE; - } - - priv = InterfacePriv->privPtr; - if_addr = (struct in_ifaddr *)ifa; - - /* If this event is for a UniFi device, notify the SME that an IP - * address has been added or removed. */ - if (uf_find_priv(priv) != -1) { - switch (event) { - case NETDEV_UP: - unifi_info(priv, "IP address assigned for %s\n", priv->netdev[InterfacePriv->InterfaceTag]->name); - priv->sta_ip_address = if_addr->ifa_address; -#ifdef CSR_SUPPORT_WEXT - sme_mgt_packet_filter_set(priv); -#endif - break; - case NETDEV_DOWN: - unifi_info(priv, "IP address removed for %s\n", priv->netdev[InterfacePriv->InterfaceTag]->name); - priv->sta_ip_address = 0xFFFFFFFF; -#ifdef CSR_SUPPORT_WEXT - sme_mgt_packet_filter_set(priv); -#endif - break; - } - } - - return NOTIFY_DONE; -} - -static struct notifier_block uf_inetaddr_notifier = { - .notifier_call = uf_inetaddr_event, -}; - -void uf_register_inet_notifier(void) -{ - if (atomic_inc_return(&inet_notif_refs) == 1) - register_inetaddr_notifier(&uf_inetaddr_notifier); -} - -void uf_unregister_inet_notifier(void) -{ - if (atomic_dec_return(&inet_notif_refs) == 0) - unregister_inetaddr_notifier(&uf_inetaddr_notifier); -} diff --git a/drivers/staging/csr/init_hw.c b/drivers/staging/csr/init_hw.c deleted file mode 100644 index 3b8a4babf9a6..000000000000 --- a/drivers/staging/csr/init_hw.c +++ /dev/null @@ -1,108 +0,0 @@ -/* - * --------------------------------------------------------------------------- - * FILE: init_hw.c - * - * PURPOSE: - * Use the HIP core lib to initialise the UniFi chip. - * It is part of the porting exercise in Linux. - * - * Copyright (C) 2009 by Cambridge Silicon Radio Ltd. - * - * Refer to LICENSE.txt included with this source code for details on - * the license terms. - * - * --------------------------------------------------------------------------- - */ -#include "csr_wifi_hip_unifi.h" -#include "unifi_priv.h" - - -#define MAX_INIT_ATTEMPTS 4 - -extern int led_mask; - - -/* - * --------------------------------------------------------------------------- - * uf_init_hw - * - * Resets hardware, downloads and initialises f/w. - * This function demonstrates how to use the HIP core lib API - * to implement the SME unifi_sys_wifi_on_req() part of the SYS API. - * - * In a simple implementation, all this function needs to do is call - * unifi_init_card() and then unifi_card_info(). - * In the Linux implementation, it will retry to initialise UniFi or - * try to debug the reasons if unifi_init_card() returns an error. - * - * Arguments: - * ospriv Pointer to OS driver structure for the device. - * - * Returns: - * O on success, non-zero otherwise. - * - * --------------------------------------------------------------------------- - */ -int -uf_init_hw(unifi_priv_t *priv) -{ - int attempts = 0; - int priv_instance; - CsrResult csrResult = CSR_RESULT_FAILURE; - - priv_instance = uf_find_priv(priv); - if (priv_instance == -1) { - unifi_warning(priv, "uf_init_hw: Unknown priv instance, will use fw_init[0]\n"); - priv_instance = 0; - } - - while (1) { - if (attempts > MAX_INIT_ATTEMPTS) { - unifi_error(priv, "Failed to initialise UniFi after %d attempts, " - "giving up.\n", - attempts); - break; - } - attempts++; - - unifi_info(priv, "Initialising UniFi, attempt %d\n", attempts); - - if (fw_init[priv_instance] > 0) { - unifi_notice(priv, "f/w init prevented by module parameter\n"); - break; - } else if (fw_init[priv_instance] == 0) { - fw_init[priv_instance] ++; - } - - /* - * Initialise driver core. This will perform a reset of UniFi - * internals, but not the SDIO CCCR. - */ - CsrSdioClaim(priv->sdio); - csrResult = unifi_init_card(priv->card, led_mask); - CsrSdioRelease(priv->sdio); - - if (csrResult == CSR_WIFI_HIP_RESULT_NO_DEVICE) { - return CsrHipResultToStatus(csrResult); - } - if (csrResult == CSR_WIFI_HIP_RESULT_NOT_FOUND) { - unifi_error(priv, "Firmware file required, but not found.\n"); - return CsrHipResultToStatus(csrResult); - } - if (csrResult != CSR_RESULT_SUCCESS) { - /* failed. Reset h/w and try again */ - unifi_error(priv, "Failed to initialise UniFi chip.\n"); - continue; - } - - /* Get the version information from the lib_hip */ - unifi_card_info(priv->card, &priv->card_info); - - return CsrHipResultToStatus(csrResult); - } - - return CsrHipResultToStatus(csrResult); - -} /* uf_init_hw */ - - diff --git a/drivers/staging/csr/io.c b/drivers/staging/csr/io.c deleted file mode 100644 index f903022b4079..000000000000 --- a/drivers/staging/csr/io.c +++ /dev/null @@ -1,1098 +0,0 @@ -/* - * --------------------------------------------------------------------------- - * FILE: io.c - * - * PURPOSE: - * This file contains routines that the SDIO driver can call when a - * UniFi card is first inserted (or detected) and removed. - * - * When used with sdioemb, the udev scripts (at least on Ubuntu) don't - * recognise a UniFi being added to the system. This is because sdioemb - * does not register itself as a device_driver, it uses it's own code - * to handle insert and remove. - * To have Ubuntu recognise UniFi, edit /etc/udev/rules.d/85-ifupdown.rules - * to change this line: - * SUBSYSTEM=="net", DRIVERS=="?*", GOTO="net_start" - * to these: - * #SUBSYSTEM=="net", DRIVERS=="?*", GOTO="net_start" - * SUBSYSTEM=="net", GOTO="net_start" - * - * Then you can add a stanza to /etc/network/interfaces like this: - * auto eth1 - * iface eth1 inet dhcp - * wpa-conf /etc/wpa_supplicant.conf - * This will then automatically associate when a car dis inserted. - * - * Copyright (C) 2006-2009 by Cambridge Silicon Radio Ltd. - * - * Refer to LICENSE.txt included with this source code for details on - * the license terms. - * - * --------------------------------------------------------------------------- - */ -#include -#include - -#include "csr_wifi_hip_unifi.h" -#include "csr_wifi_hip_unifiversion.h" -#include "csr_wifi_hip_unifi_udi.h" /* for unifi_print_status() */ -#include "unifiio.h" -#include "unifi_priv.h" - -/* - * Array of pointers to context structs for unifi devices that are present. - * The index in the array corresponds to the wlan interface number - * (if "wlan*" is used). If "eth*" is used, the eth* numbers are allocated - * after any Ethernet cards. - * - * The Arasan PCI-SDIO controller card supported by this driver has 2 slots, - * hence a max of 2 devices. - */ -static unifi_priv_t *Unifi_instances[MAX_UNIFI_DEVS]; - -/* Array of pointers to netdev objects used by the UniFi driver, as there - * are now many per instance. This is used to determine which netdev events - * are for UniFi as opposed to other net interfaces. - */ -static netInterface_priv_t *Unifi_netdev_instances[MAX_UNIFI_DEVS * CSR_WIFI_NUM_INTERFACES]; - -/* - * Array to hold the status of each unifi device in each slot. - * We only process an insert event when In_use[] for the slot is - * UNIFI_DEV_NOT_IN_USE. Otherwise, it means that the slot is in use or - * we are in the middle of a cleanup (the action on unplug). - */ -#define UNIFI_DEV_NOT_IN_USE 0 -#define UNIFI_DEV_IN_USE 1 -#define UNIFI_DEV_CLEANUP 2 -static int In_use[MAX_UNIFI_DEVS]; -/* - * Mutex to prevent UDI clients to open the character device before the priv - * is created and initialised. - */ -DEFINE_SEMAPHORE(Unifi_instance_mutex); -/* - * When the device is removed, unregister waits on Unifi_cleanup_wq - * until all the UDI clients release the character device. - */ -DECLARE_WAIT_QUEUE_HEAD(Unifi_cleanup_wq); - -#ifdef CONFIG_PROC_FS -/* - * seq_file wrappers for procfile show routines. - */ -static int uf_proc_show(struct seq_file *m, void *v); - -#define UNIFI_DEBUG_TXT_BUFFER (8 * 1024) - -static int uf_proc_open(struct inode *inode, struct file *file) -{ - return single_open_size(file, uf_proc_show, PDE_DATA(inode), - UNIFI_DEBUG_TXT_BUFFER); -} - -static const struct file_operations uf_proc_fops = { - .open = uf_proc_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; - -#endif /* CONFIG_PROC_FS */ - -#ifdef CSR_WIFI_RX_PATH_SPLIT - -static CsrResult signal_buffer_init(unifi_priv_t * priv, int size) -{ - int i; - - priv->rxSignalBuffer.writePointer = - priv->rxSignalBuffer.readPointer = 0; - priv->rxSignalBuffer.size = size; - /* Allocating Memory for Signal primitive pointer */ - for(i=0; irxSignalBuffer.rx_buff[i].sig_len=0; - priv->rxSignalBuffer.rx_buff[i].bufptr = kmalloc(UNIFI_PACKED_SIGBUF_SIZE, GFP_KERNEL); - if (priv->rxSignalBuffer.rx_buff[i].bufptr == NULL) - { - int j; - unifi_error(priv, "signal_buffer_init:Failed to Allocate shared memory for T-H signals \n"); - for(j=0;jrxSignalBuffer.rx_buff[j].sig_len=0; - kfree(priv->rxSignalBuffer.rx_buff[j].bufptr); - priv->rxSignalBuffer.rx_buff[j].bufptr = NULL; - } - return -1; - } - } - return 0; -} - - -static void signal_buffer_free(unifi_priv_t * priv, int size) -{ - int i; - - for(i=0; irxSignalBuffer.rx_buff[i].sig_len=0; - kfree(priv->rxSignalBuffer.rx_buff[i].bufptr); - priv->rxSignalBuffer.rx_buff[i].bufptr = NULL; - } -} -#endif -/* - * --------------------------------------------------------------------------- - * uf_register_netdev - * - * Registers the network interface, installes the qdisc, - * and registers the inet handler. - * In the porting exercise, register the driver to the network - * stack if necessary. - * - * Arguments: - * priv Pointer to driver context. - * - * Returns: - * O on success, non-zero otherwise. - * - * Notes: - * We will only unregister when the card is ejected, so we must - * only do it once. - * --------------------------------------------------------------------------- - */ -int -uf_register_netdev(unifi_priv_t *priv, int interfaceTag) -{ - int r; - netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag]; - - if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) { - unifi_error(priv, "uf_register_netdev bad interfaceTag\n"); - return -EINVAL; - } - - /* - * Allocates a device number and registers device with the network - * stack. - */ - unifi_trace(priv, UDBG5, "uf_register_netdev: netdev %d - 0x%p\n", - interfaceTag, priv->netdev[interfaceTag]); - r = register_netdev(priv->netdev[interfaceTag]); - if (r) { - unifi_error(priv, "Failed to register net device\n"); - return -EINVAL; - } - - /* The device is registed */ - interfacePriv->netdev_registered = 1; - -#ifdef CSR_SUPPORT_SME - /* - * Register the inet handler; it notifies us for changes in the IP address. - */ - uf_register_inet_notifier(); -#endif /* CSR_SUPPORT_SME */ - - unifi_notice(priv, "unifi%d is %s\n", - priv->instance, priv->netdev[interfaceTag]->name); - - return 0; -} /* uf_register_netdev */ - - -/* - * --------------------------------------------------------------------------- - * uf_unregister_netdev - * - * Unregisters the network interface and the inet handler. - * - * Arguments: - * priv Pointer to driver context. - * - * Returns: - * None. - * - * --------------------------------------------------------------------------- - */ -void -uf_unregister_netdev(unifi_priv_t *priv) -{ - int i=0; - -#ifdef CSR_SUPPORT_SME - /* Unregister the inet handler... */ - uf_unregister_inet_notifier(); -#endif /* CSR_SUPPORT_SME */ - - for (i=0; iinterfacePriv[i]; - if (interfacePriv->netdev_registered) { - unifi_trace(priv, UDBG5, - "uf_unregister_netdev: netdev %d - 0x%p\n", - i, priv->netdev[i]); - - /* ... and the netdev */ - unregister_netdev(priv->netdev[i]); - interfacePriv->netdev_registered = 0; - } - - interfacePriv->interfaceMode = 0; - - /* Enable all queues by default */ - interfacePriv->queueEnabled[0] = 1; - interfacePriv->queueEnabled[1] = 1; - interfacePriv->queueEnabled[2] = 1; - interfacePriv->queueEnabled[3] = 1; - } - - priv->totalInterfaceCount = 0; -} /* uf_unregister_netdev() */ - - -/* - * --------------------------------------------------------------------------- - * register_unifi_sdio - * - * This function is called from the Probe (or equivalent) method of - * the SDIO driver when a UniFi card is detected. - * We allocate the Linux net_device struct, initialise the HIP core - * lib, create the char device nodes and start the userspace helper - * to initialise the device. - * - * Arguments: - * sdio_dev Pointer to SDIO context handle to use for all - * SDIO ops. - * bus_id A small number indicating the SDIO card position on the - * bus. Typically this is the slot number, e.g. 0, 1 etc. - * Valid values are 0 to MAX_UNIFI_DEVS-1. - * dev Pointer to kernel device manager struct. - * - * Returns: - * Pointer to the unifi instance, or NULL on error. - * --------------------------------------------------------------------------- - */ -static unifi_priv_t * -register_unifi_sdio(CsrSdioFunction *sdio_dev, int bus_id, struct device *dev) -{ - unifi_priv_t *priv = NULL; - int r = -1; - CsrResult csrResult; - - if ((bus_id < 0) || (bus_id >= MAX_UNIFI_DEVS)) { - unifi_error(priv, "register_unifi_sdio: invalid device %d\n", - bus_id); - return NULL; - } - - down(&Unifi_instance_mutex); - - if (In_use[bus_id] != UNIFI_DEV_NOT_IN_USE) { - unifi_error(priv, "register_unifi_sdio: device %d is already in use\n", - bus_id); - goto failed0; - } - - - /* Allocate device private and net_device structs */ - priv = uf_alloc_netdevice(sdio_dev, bus_id); - if (priv == NULL) { - unifi_error(priv, "Failed to allocate driver private\n"); - goto failed0; - } - - priv->unifi_device = dev; - - SET_NETDEV_DEV(priv->netdev[0], dev); - - /* We are not ready to send data yet. */ - netif_carrier_off(priv->netdev[0]); - - /* Allocate driver context. */ - priv->card = unifi_alloc_card(priv->sdio, priv); - if (priv->card == NULL) { - unifi_error(priv, "Failed to allocate UniFi driver card struct.\n"); - goto failed1; - } - - if (Unifi_instances[bus_id]) { - unifi_error(priv, "Internal error: instance for slot %d is already taken\n", - bus_id); - } - Unifi_instances[bus_id] = priv; - In_use[bus_id] = UNIFI_DEV_IN_USE; - - /* Save the netdev_priv for use by the netdev event callback mechanism */ - Unifi_netdev_instances[bus_id * CSR_WIFI_NUM_INTERFACES] = netdev_priv(priv->netdev[0]); - - /* Initialise the mini-coredump capture buffers */ - csrResult = unifi_coredump_init(priv->card, (u16)coredump_max); - if (csrResult != CSR_RESULT_SUCCESS) { - unifi_error(priv, "Couldn't allocate mini-coredump buffers\n"); - } - - /* Create the character device nodes */ - r = uf_create_device_nodes(priv, bus_id); - if (r) { - goto failed1; - } - - /* - * We use the slot number as unifi device index. - */ - scnprintf(priv->proc_entry_name, 64, "driver/unifi%d", priv->instance); - /* - * The following complex casting is in place in order to eliminate 64-bit compilation warning - * "cast to/from pointer from/to integer of different size" - */ - if (!proc_create_data(priv->proc_entry_name, 0, NULL, - &uf_proc_fops, (void *)(long)priv->instance)) - { - unifi_error(priv, "unifi: can't create /proc/driver/unifi\n"); - } - - /* Allocate the net_device for interfaces other than 0. */ - { - int i; - priv->totalInterfaceCount =0; - - for(i=1;inetdev[i], dev); - - /* We are not ready to send data yet. */ - netif_carrier_off(priv->netdev[i]); - - /* Save the netdev_priv for use by the netdev event callback mechanism */ - Unifi_netdev_instances[bus_id * CSR_WIFI_NUM_INTERFACES + i] = netdev_priv(priv->netdev[i]); - } - } - - for(i=0;iinterfacePriv[i]; - interfacePriv->netdev_registered=0; - } - } - -#ifdef CSR_WIFI_RX_PATH_SPLIT - if (signal_buffer_init(priv, CSR_WIFI_RX_SIGNAL_BUFFER_SIZE)) - { - unifi_error(priv, "Failed to allocate shared memory for T-H signals\n"); - goto failed2; - } - priv->rx_workqueue = create_singlethread_workqueue("rx_workq"); - if (priv->rx_workqueue == NULL) { - unifi_error(priv, "create_singlethread_workqueue failed \n"); - goto failed3; - } - INIT_WORK(&priv->rx_work_struct, rx_wq_handler); -#endif - -#ifdef CSR_WIFI_HIP_DEBUG_OFFLINE - if (log_hip_signals) - { - uf_register_hip_offline_debug(priv); - } -#endif - - /* Initialise the SME related threads and parameters */ - r = uf_sme_init(priv); - if (r) { - unifi_error(priv, "SME initialisation failed.\n"); - goto failed4; - } - - /* - * Run the userspace helper program (unififw) to perform - * the device initialisation. - */ - unifi_trace(priv, UDBG1, "run UniFi helper app...\n"); - r = uf_run_unifihelper(priv); - if (r) { - unifi_notice(priv, "unable to run UniFi helper app\n"); - /* Not a fatal error. */ - } - - up(&Unifi_instance_mutex); - - return priv; - -failed4: -#ifdef CSR_WIFI_HIP_DEBUG_OFFLINE -if (log_hip_signals) -{ - uf_unregister_hip_offline_debug(priv); -} -#endif -#ifdef CSR_WIFI_RX_PATH_SPLIT - flush_workqueue(priv->rx_workqueue); - destroy_workqueue(priv->rx_workqueue); -failed3: - signal_buffer_free(priv, CSR_WIFI_RX_SIGNAL_BUFFER_SIZE); -failed2: -#endif - /* Remove the device nodes */ - uf_destroy_device_nodes(priv); -failed1: - /* Deregister priv->netdev_client */ - ul_deregister_client(priv->netdev_client); - -failed0: - if (priv && priv->card) { - unifi_coredump_free(priv->card); - unifi_free_card(priv->card); - } - if (priv) { - uf_free_netdevice(priv); - } - - up(&Unifi_instance_mutex); - - return NULL; -} /* register_unifi_sdio() */ - - -/* - * --------------------------------------------------------------------------- - * ask_unifi_sdio_cleanup - * - * We can not free our private context, until all the char device - * clients have closed the file handles. unregister_unifi_sdio() which - * is called when a card is removed, waits on Unifi_cleanup_wq until - * the reference count becomes zero. It is time to wake it up now. - * - * Arguments: - * priv Pointer to driver context. - * - * Returns: - * None. - * --------------------------------------------------------------------------- - */ -static void -ask_unifi_sdio_cleanup(unifi_priv_t *priv) -{ - - /* - * Now clear the flag that says the old instance is in use. - * This is used to prevent a new instance being started before old - * one has finshed closing down, for example if bounce makes the card - * appear to be ejected and re-inserted quickly. - */ - In_use[priv->instance] = UNIFI_DEV_CLEANUP; - - unifi_trace(NULL, UDBG5, "ask_unifi_sdio_cleanup: wake up cleanup workqueue.\n"); - wake_up(&Unifi_cleanup_wq); - -} /* ask_unifi_sdio_cleanup() */ - - -/* - * --------------------------------------------------------------------------- - * cleanup_unifi_sdio - * - * Release any resources owned by a unifi instance. - * - * Arguments: - * priv Pointer to the instance to free. - * - * Returns: - * None. - * --------------------------------------------------------------------------- - */ -static void -cleanup_unifi_sdio(unifi_priv_t *priv) -{ - int priv_instance; - int i; - static const CsrWifiMacAddress broadcast_address = {{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}}; - - /* Remove the device nodes */ - uf_destroy_device_nodes(priv); - - /* Mark this device as gone away by NULLing the entry in Unifi_instances */ - Unifi_instances[priv->instance] = NULL; - - unifi_trace(priv, UDBG5, "cleanup_unifi_sdio: remove_proc_entry\n"); - /* - * Free the children of priv before unifi_free_netdevice() frees - * the priv struct - */ - remove_proc_entry(priv->proc_entry_name, 0); - - - /* Unregister netdev as a client. */ - if (priv->netdev_client) { - unifi_trace(priv, UDBG2, "Netdev client (id:%d s:0x%X) is unregistered\n", - priv->netdev_client->client_id, priv->netdev_client->sender_id); - ul_deregister_client(priv->netdev_client); - } - - /* Destroy the SME related threads and parameters */ - uf_sme_deinit(priv); - -#ifdef CSR_SME_USERSPACE - priv->smepriv = NULL; -#endif - -#ifdef CSR_WIFI_HIP_DEBUG_OFFLINE - if (log_hip_signals) - { - uf_unregister_hip_offline_debug(priv); - } -#endif - - /* Free any packets left in the Rx queues */ - for(i=0;icard) { - unifi_trace(priv, UDBG5, "cleanup_unifi_sdio: free card\n"); - unifi_coredump_free(priv->card); - unifi_free_card(priv->card); - priv->card = NULL; - } - - /* - * Unregister the network device. - * We can not unregister the netdev before we release - * all pending packets in the core. - */ - uf_unregister_netdev(priv); - priv->totalInterfaceCount = 0; - - /* Clear the table of registered netdev_priv's */ - for (i = 0; i < CSR_WIFI_NUM_INTERFACES; i++) { - Unifi_netdev_instances[priv->instance * CSR_WIFI_NUM_INTERFACES + i] = NULL; - } - - unifi_trace(priv, UDBG5, "cleanup_unifi_sdio: uf_free_netdevice\n"); - /* - * When uf_free_netdevice() returns, the priv is invalid - * so we need to remember the instance to clear the global flag later. - */ - priv_instance = priv->instance; - -#ifdef CSR_WIFI_RX_PATH_SPLIT - flush_workqueue(priv->rx_workqueue); - destroy_workqueue(priv->rx_workqueue); - signal_buffer_free(priv, CSR_WIFI_RX_SIGNAL_BUFFER_SIZE); -#endif - - /* Priv is freed as part of the net_device */ - uf_free_netdevice(priv); - - /* - * Now clear the flag that says the old instance is in use. - * This is used to prevent a new instance being started before old - * one has finshed closing down, for example if bounce makes the card - * appear to be ejected and re-inserted quickly. - */ - In_use[priv_instance] = UNIFI_DEV_NOT_IN_USE; - - unifi_trace(NULL, UDBG5, "cleanup_unifi_sdio: DONE.\n"); - -} /* cleanup_unifi_sdio() */ - - -/* - * --------------------------------------------------------------------------- - * unregister_unifi_sdio - * - * Call from SDIO driver when it detects that UniFi has been removed. - * - * Arguments: - * bus_id Number of the card that was ejected. - * - * Returns: - * None. - * --------------------------------------------------------------------------- - */ -static void -unregister_unifi_sdio(int bus_id) -{ - unifi_priv_t *priv; - int interfaceTag=0; - u8 reason = CONFIG_IND_EXIT; - - if ((bus_id < 0) || (bus_id >= MAX_UNIFI_DEVS)) { - unifi_error(NULL, "unregister_unifi_sdio: invalid device %d\n", - bus_id); - return; - } - - priv = Unifi_instances[bus_id]; - if (priv == NULL) { - unifi_error(priv, "unregister_unifi_sdio: device %d is not registered\n", - bus_id); - return; - } - - /* Stop the network traffic before freeing the core. */ - for(interfaceTag=0;interfaceTagtotalInterfaceCount;interfaceTag++) - { - netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag]; - if(interfacePriv->netdev_registered) - { - netif_carrier_off(priv->netdev[interfaceTag]); - netif_tx_stop_all_queues(priv->netdev[interfaceTag]); - } - } - -#ifdef CSR_NATIVE_LINUX - /* - * If the unifi thread was started, signal it to stop. This - * should cause any userspace processes with open unifi device to - * close them. - */ - uf_stop_thread(priv, &priv->bh_thread); - - /* Unregister the interrupt handler */ - if (csr_sdio_linux_remove_irq(priv->sdio)) { - unifi_notice(priv, - "csr_sdio_linux_remove_irq failed to talk to card.\n"); - } - - /* Ensure no MLME functions are waiting on a the mlme_event semaphore. */ - uf_abort_mlme(priv); -#endif /* CSR_NATIVE_LINUX */ - - ul_log_config_ind(priv, &reason, sizeof(u8)); - - /* Deregister the UDI hook from the core. */ - unifi_remove_udi_hook(priv->card, logging_handler); - - uf_put_instance(bus_id); - - /* - * Wait until the device is cleaned up. i.e., when all userspace - * processes have closed any open unifi devices. - */ - wait_event(Unifi_cleanup_wq, In_use[bus_id] == UNIFI_DEV_CLEANUP); - unifi_trace(NULL, UDBG5, "Received clean up event\n"); - - /* Now we can free the private context and the char device nodes */ - cleanup_unifi_sdio(priv); - -} /* unregister_unifi_sdio() */ - - -/* - * --------------------------------------------------------------------------- - * uf_find_instance - * - * Find the context structure for a given UniFi device instance. - * - * Arguments: - * inst The instance number to look for. - * - * Returns: - * None. - * --------------------------------------------------------------------------- - */ -unifi_priv_t * -uf_find_instance(int inst) -{ - if ((inst < 0) || (inst >= MAX_UNIFI_DEVS)) { - return NULL; - } - return Unifi_instances[inst]; -} /* uf_find_instance() */ - - -/* - * --------------------------------------------------------------------------- - * uf_find_priv - * - * Find the device instance for a given context structure. - * - * Arguments: - * priv The context structure pointer to look for. - * - * Returns: - * index of instance, -1 otherwise. - * --------------------------------------------------------------------------- - */ -int -uf_find_priv(unifi_priv_t *priv) -{ - int inst; - - if (!priv) { - return -1; - } - - for (inst = 0; inst < MAX_UNIFI_DEVS; inst++) { - if (Unifi_instances[inst] == priv) { - return inst; - } - } - - return -1; -} /* uf_find_priv() */ - -/* - * --------------------------------------------------------------------------- - * uf_find_netdev_priv - * - * Find the device instance for a given netdev context structure. - * - * Arguments: - * priv The context structure pointer to look for. - * - * Returns: - * index of instance, -1 otherwise. - * --------------------------------------------------------------------------- - */ -int -uf_find_netdev_priv(netInterface_priv_t *priv) -{ - int inst; - - if (!priv) { - return -1; - } - - for (inst = 0; inst < MAX_UNIFI_DEVS * CSR_WIFI_NUM_INTERFACES; inst++) { - if (Unifi_netdev_instances[inst] == priv) { - return inst; - } - } - - return -1; -} /* uf_find_netdev_priv() */ - -/* - * --------------------------------------------------------------------------- - * uf_get_instance - * - * Find the context structure for a given UniFi device instance - * and increment the reference count. - * - * Arguments: - * inst The instance number to look for. - * - * Returns: - * Pointer to the instance or NULL if no instance exists. - * --------------------------------------------------------------------------- - */ -unifi_priv_t * -uf_get_instance(int inst) -{ - unifi_priv_t *priv; - - down(&Unifi_instance_mutex); - - priv = uf_find_instance(inst); - if (priv) { - priv->ref_count++; - } - - up(&Unifi_instance_mutex); - - return priv; -} - -/* - * --------------------------------------------------------------------------- - * uf_put_instance - * - * Decrement the context reference count, freeing resources and - * shutting down the driver when the count reaches zero. - * - * Arguments: - * inst The instance number to look for. - * - * Returns: - * Pointer to the instance or NULL if no instance exists. - * --------------------------------------------------------------------------- - */ -void -uf_put_instance(int inst) -{ - unifi_priv_t *priv; - - down(&Unifi_instance_mutex); - - priv = uf_find_instance(inst); - if (priv) { - priv->ref_count--; - if (priv->ref_count == 0) { - ask_unifi_sdio_cleanup(priv); - } - } - - up(&Unifi_instance_mutex); -} - - -/* - * --------------------------------------------------------------------------- - * uf_proc_show - * - * Read method for driver node in /proc/driver/unifi0 - * - * Arguments: - * page - * start - * offset - * count - * eof - * data - * - * Returns: - * None. - * --------------------------------------------------------------------------- - */ -#ifdef CONFIG_PROC_FS -static int uf_proc_show(struct seq_file *m, void *v) -{ - unifi_priv_t *priv; - int i; - - /* - * The following complex casting is in place in order to eliminate - * 64-bit compilation warning "cast to/from pointer from/to integer of - * different size" - */ - priv = uf_find_instance((long)m->private); - if (!priv) - return 0; - - seq_printf(m, "UniFi SDIO Driver: %s %s %s\n", - CSR_WIFI_VERSION, __DATE__, __TIME__); -#ifdef CSR_SME_USERSPACE - seq_puts(m, "SME: CSR userspace "); -#ifdef CSR_SUPPORT_WEXT - seq_puts(m, "with WEXT support\n"); -#else - seq_putc(m, '\n'); -#endif /* CSR_SUPPORT_WEXT */ -#endif /* CSR_SME_USERSPACE */ -#ifdef CSR_NATIVE_LINUX - seq_puts(m, "SME: native\n"); -#endif - -#ifdef CSR_SUPPORT_SME - seq_printf(m, "Firmware (ROM) build:%u, Patch:%u\n", - priv->card_info.fw_build, - priv->sme_versions.firmwarePatch); -#endif - - unifi_print_status(priv->card, m); - - seq_printf(m, "Last dbg str: %s\n", priv->last_debug_string); - - seq_puts(m, "Last dbg16:"); - for (i = 0; i < 8; i++) - seq_printf(m, " %04X", priv->last_debug_word16[i]); - seq_putc(m, '\n'); - seq_puts(m, " "); - for (; i < 16; i++) - seq_printf(m, " %04X", priv->last_debug_word16[i]); - seq_putc(m, '\n'); - return 0; -} -#endif - - - - -static void -uf_lx_suspend(CsrSdioFunction *sdio_ctx) -{ - unifi_priv_t *priv = sdio_ctx->driverData; - unifi_suspend(priv); - - CsrSdioSuspendAcknowledge(sdio_ctx, CSR_RESULT_SUCCESS); -} - -static void -uf_lx_resume(CsrSdioFunction *sdio_ctx) -{ - unifi_priv_t *priv = sdio_ctx->driverData; - unifi_resume(priv); - - CsrSdioResumeAcknowledge(sdio_ctx, CSR_RESULT_SUCCESS); -} - -static int active_slot = MAX_UNIFI_DEVS; -static struct device *os_devices[MAX_UNIFI_DEVS]; - -void -uf_add_os_device(int bus_id, struct device *os_device) -{ - if ((bus_id < 0) || (bus_id >= MAX_UNIFI_DEVS)) { - unifi_error(NULL, "uf_add_os_device: invalid device %d\n", - bus_id); - return; - } - - active_slot = bus_id; - os_devices[bus_id] = os_device; -} /* uf_add_os_device() */ - -void -uf_remove_os_device(int bus_id) -{ - if ((bus_id < 0) || (bus_id >= MAX_UNIFI_DEVS)) { - unifi_error(NULL, "uf_remove_os_device: invalid device %d\n", - bus_id); - return; - } - - active_slot = bus_id; - os_devices[bus_id] = NULL; -} /* uf_remove_os_device() */ - -static void -uf_sdio_inserted(CsrSdioFunction *sdio_ctx) -{ - unifi_priv_t *priv; - - unifi_trace(NULL, UDBG5, "uf_sdio_inserted(0x%p), slot_id=%d, dev=%p\n", - sdio_ctx, active_slot, os_devices[active_slot]); - - priv = register_unifi_sdio(sdio_ctx, active_slot, os_devices[active_slot]); - if (priv == NULL) { - CsrSdioInsertedAcknowledge(sdio_ctx, CSR_RESULT_FAILURE); - return; - } - - sdio_ctx->driverData = priv; - - CsrSdioInsertedAcknowledge(sdio_ctx, CSR_RESULT_SUCCESS); -} /* uf_sdio_inserted() */ - - -static void -uf_sdio_removed(CsrSdioFunction *sdio_ctx) -{ - unregister_unifi_sdio(active_slot); - CsrSdioRemovedAcknowledge(sdio_ctx); -} /* uf_sdio_removed() */ - - -static void -uf_sdio_dsr_handler(CsrSdioFunction *sdio_ctx) -{ - unifi_priv_t *priv = sdio_ctx->driverData; - - unifi_sdio_interrupt_handler(priv->card); -} /* uf_sdio_dsr_handler() */ - -/* - * --------------------------------------------------------------------------- - * uf_sdio_int_handler - * - * Interrupt callback function for SDIO interrupts. - * This is called in kernel context (i.e. not interrupt context). - * We retrieve the unifi context pointer and call the main UniFi - * interrupt handler. - * - * Arguments: - * fdev SDIO context pointer - * - * Returns: - * None. - * --------------------------------------------------------------------------- - */ -static CsrSdioInterruptDsrCallback -uf_sdio_int_handler(CsrSdioFunction *sdio_ctx) -{ - return uf_sdio_dsr_handler; -} /* uf_sdio_int_handler() */ - - - - -static CsrSdioFunctionId unifi_ids[] = -{ - { - .manfId = SDIO_MANF_ID_CSR, - .cardId = SDIO_CARD_ID_UNIFI_3, - .sdioFunction = SDIO_WLAN_FUNC_ID_UNIFI_3, - .sdioInterface = CSR_SDIO_ANY_SDIO_INTERFACE, - }, - { - .manfId = SDIO_MANF_ID_CSR, - .cardId = SDIO_CARD_ID_UNIFI_4, - .sdioFunction = SDIO_WLAN_FUNC_ID_UNIFI_4, - .sdioInterface = CSR_SDIO_ANY_SDIO_INTERFACE, - } -}; - - -/* - * Structure to register with the glue layer. - */ -static CsrSdioFunctionDriver unifi_sdioFunction_drv = -{ - .inserted = uf_sdio_inserted, - .removed = uf_sdio_removed, - .intr = uf_sdio_int_handler, - .suspend = uf_lx_suspend, - .resume = uf_lx_resume, - - .ids = unifi_ids, - .idsCount = sizeof(unifi_ids) / sizeof(unifi_ids[0]) -}; - - -/* - * --------------------------------------------------------------------------- - * uf_sdio_load - * uf_sdio_unload - * - * These functions are called from the main module load and unload - * functions. They perform the appropriate operations for the monolithic - * driver. - * - * Arguments: - * None. - * - * Returns: - * None. - * --------------------------------------------------------------------------- - */ -int __init -uf_sdio_load(void) -{ - CsrResult csrResult; - - csrResult = CsrSdioFunctionDriverRegister(&unifi_sdioFunction_drv); - if (csrResult != CSR_RESULT_SUCCESS) { - unifi_error(NULL, "Failed to register UniFi SDIO driver: csrResult=%d\n", csrResult); - return -EIO; - } - - return 0; -} /* uf_sdio_load() */ - - - -void __exit -uf_sdio_unload(void) -{ - CsrSdioFunctionDriverUnregister(&unifi_sdioFunction_drv); -} /* uf_sdio_unload() */ - diff --git a/drivers/staging/csr/mlme.c b/drivers/staging/csr/mlme.c deleted file mode 100644 index 861d6b7687c7..000000000000 --- a/drivers/staging/csr/mlme.c +++ /dev/null @@ -1,433 +0,0 @@ -/* - * --------------------------------------------------------------------------- - * FILE: mlme.c - * - * PURPOSE: - * This file provides functions to send MLME requests to the UniFi. - * - * Copyright (C) 2007-2008 by Cambridge Silicon Radio Ltd. - * - * Refer to LICENSE.txt included with this source code for details on - * the license terms. - * - * --------------------------------------------------------------------------- - */ -#include "csr_wifi_hip_unifi.h" -#include "unifi_priv.h" - -/* - * --------------------------------------------------------------------------- - * unifi_mlme_wait_for_reply - * - * Wait for a reply after sending a signal. - * - * Arguments: - * priv Pointer to device private context struct - * ul_client Pointer to linux client - * sig_reply_id ID of the expected reply (defined in sigs.h). - * timeout timeout in ms - * - * Returns: - * 0 on success, -ve POSIX code on error. - * - * Notes: - * This function waits for a specific (sig_reply_id) signal from UniFi. - * It also match the sequence number of the received (cfm) signal, with - * the latest sequence number of the signal (req) we have sent. - * These two number match be equal. - * Should only be used for waiting xxx.cfm signals and only after - * we have sent the matching xxx.req signal to UniFi. - * If no response is received within the expected time (timeout), we assume - * that the UniFi is busy and return an error. - * If the wait is aborted by a kernel signal arriving, we stop waiting. - * If a response from UniFi is not what we expected, we discard it and - * wait again. This could be a response from an aborted request. If we - * see several bad responses we assume we have lost synchronisation with - * UniFi. - * --------------------------------------------------------------------------- - */ -static int -unifi_mlme_wait_for_reply(unifi_priv_t *priv, ul_client_t *pcli, int sig_reply_id, int timeout) -{ - int retries = 0; - long r; - long t = timeout; - unsigned int sent_seq_no; - - /* Convert t in ms to jiffies */ - t = msecs_to_jiffies(t); - - do { - /* Wait for the confirm or timeout. */ - r = wait_event_interruptible_timeout(pcli->udi_wq, - (pcli->wake_up_wq_id) || (priv->io_aborted == 1), - t); - /* Check for general i/o error */ - if (priv->io_aborted) { - unifi_error(priv, "MLME operation aborted\n"); - return -EIO; - } - - /* - * If r=0 the request has timed-out. - * If r>0 the request has completed successfully. - * If r=-ERESTARTSYS an event (kill signal) has interrupted the wait_event. - */ - if ((r == 0) && (pcli->wake_up_wq_id == 0)) { - unifi_error(priv, "mlme_wait: timed-out waiting for 0x%.4X, after %lu msec.\n", - sig_reply_id, jiffies_to_msecs(t)); - pcli->wake_up_wq_id = 0; - return -ETIMEDOUT; - } else if (r == -ERESTARTSYS) { - unifi_error(priv, "mlme_wait: waiting for 0x%.4X was aborted.\n", sig_reply_id); - pcli->wake_up_wq_id = 0; - return -EINTR; - } else { - /* Get the sequence number of the signal that we previously set. */ - if (pcli->seq_no != 0) { - sent_seq_no = pcli->seq_no - 1; - } else { - sent_seq_no = 0x0F; - } - - unifi_trace(priv, UDBG5, "Received 0x%.4X, seq: (r:%d, s:%d)\n", - pcli->wake_up_wq_id, - pcli->wake_seq_no, sent_seq_no); - - /* The two sequence ids must match. */ - if (pcli->wake_seq_no == sent_seq_no) { - /* and the signal ids must match. */ - if (sig_reply_id == pcli->wake_up_wq_id) { - /* Found the expected signal */ - break; - } else { - /* This should never happen ... */ - unifi_error(priv, "mlme_wait: mismatching signal id (0x%.4X - exp 0x%.4X) (seq %d)\n", - pcli->wake_up_wq_id, - sig_reply_id, - pcli->wake_seq_no); - pcli->wake_up_wq_id = 0; - return -EIO; - } - } - /* Wait for the next signal. */ - pcli->wake_up_wq_id = 0; - - retries ++; - if (retries >= 3) { - unifi_error(priv, "mlme_wait: confirm wait retries exhausted (0x%.4X - exp 0x%.4X)\n", - pcli->wake_up_wq_id, - sig_reply_id); - pcli->wake_up_wq_id = 0; - return -EIO; - } - } - } while (1); - - pcli->wake_up_wq_id = 0; - - return 0; -} /* unifi_mlme_wait_for_reply() */ - - -/* - * --------------------------------------------------------------------------- - * unifi_mlme_blocking_request - * - * Send a MLME request signal to UniFi. - * - * Arguments: - * priv Pointer to device private context struct - * pcli Pointer to context of calling process - * sig Pointer to the signal to send - * data_ptrs Pointer to the bulk data of the signal - * timeout The request's timeout. - * - * Returns: - * 0 on success, 802.11 result code on error. - * --------------------------------------------------------------------------- - */ -int -unifi_mlme_blocking_request(unifi_priv_t *priv, ul_client_t *pcli, - CSR_SIGNAL *sig, bulk_data_param_t *data_ptrs, - int timeout) -{ - int r; - - if (sig->SignalPrimitiveHeader.SignalId == 0) { - unifi_error(priv, "unifi_mlme_blocking_request: Invalid Signal Id (0x%x)\n", - sig->SignalPrimitiveHeader.SignalId); - return -EINVAL; - } - - down(&priv->mlme_blocking_mutex); - - sig->SignalPrimitiveHeader.ReceiverProcessId = 0; - sig->SignalPrimitiveHeader.SenderProcessId = pcli->sender_id | pcli->seq_no; - - unifi_trace(priv, UDBG2, "Send client=%d, S:0x%04X, sig 0x%.4X\n", - pcli->client_id, - sig->SignalPrimitiveHeader.SenderProcessId, - sig->SignalPrimitiveHeader.SignalId); - /* Send the signal to UniFi */ - r = ul_send_signal_unpacked(priv, sig, data_ptrs); - if (r) { - up(&priv->mlme_blocking_mutex); - unifi_error(priv, "Error queueing MLME REQUEST signal\n"); - return r; - } - - unifi_trace(priv, UDBG5, "Send 0x%.4X, seq = %d\n", - sig->SignalPrimitiveHeader.SignalId, pcli->seq_no); - - /* - * Advance the sequence number of the last sent signal, only - * if the signal has been successfully set. - */ - pcli->seq_no++; - if (pcli->seq_no > 0x0F) { - pcli->seq_no = 0; - } - - r = unifi_mlme_wait_for_reply(priv, pcli, (sig->SignalPrimitiveHeader.SignalId + 1), timeout); - up(&priv->mlme_blocking_mutex); - - if (r) { - unifi_error(priv, "Error waiting for MLME CONFIRM signal\n"); - return r; - } - - return 0; -} /* unifi_mlme_blocking_request() */ - - -/* - * --------------------------------------------------------------------------- - * unifi_mlme_copy_reply_and_wakeup_client - * - * Copy the reply signal from UniFi to the client's structure - * and wake up the waiting client. - * - * Arguments: - * None. - * - * Returns: - * None. - * --------------------------------------------------------------------------- - */ -void -unifi_mlme_copy_reply_and_wakeup_client(ul_client_t *pcli, - CSR_SIGNAL *signal, int signal_len, - const bulk_data_param_t *bulkdata) -{ - int i; - - /* Copy the signal to the reply */ - memcpy(pcli->reply_signal, signal, signal_len); - - /* Get the sequence number of the signal that woke us up. */ - pcli->wake_seq_no = pcli->reply_signal->SignalPrimitiveHeader.ReceiverProcessId & 0x0F; - - /* Append any bulk data */ - for (i = 0; i < UNIFI_MAX_DATA_REFERENCES; i++) { - if (bulkdata->d[i].data_length > 0) { - if (bulkdata->d[i].os_data_ptr) { - memcpy(pcli->reply_bulkdata[i]->ptr, bulkdata->d[i].os_data_ptr, bulkdata->d[i].data_length); - pcli->reply_bulkdata[i]->length = bulkdata->d[i].data_length; - } else { - pcli->reply_bulkdata[i]->length = 0; - } - } - } - - /* Wake the requesting MLME function. */ - pcli->wake_up_wq_id = pcli->reply_signal->SignalPrimitiveHeader.SignalId; - wake_up_interruptible(&pcli->udi_wq); - -} /* unifi_mlme_copy_reply_and_wakeup_client() */ - - -/* - * --------------------------------------------------------------------------- - * uf_abort_mlme - * - * Abort any MLME operation in progress. - * This is used in the error recovery mechanism. - * - * Arguments: - * priv Pointer to driver context. - * - * Returns: - * 0 on success. - * --------------------------------------------------------------------------- - */ -int -uf_abort_mlme(unifi_priv_t *priv) -{ - ul_client_t *ul_cli; - - /* Ensure no MLME functions are waiting on a the mlme_event semaphore. */ - priv->io_aborted = 1; - - ul_cli = priv->netdev_client; - if (ul_cli) { - wake_up_interruptible(&ul_cli->udi_wq); - } - - ul_cli = priv->wext_client; - if (ul_cli) { - wake_up_interruptible(&ul_cli->udi_wq); - } - - return 0; -} /* uf_abort_mlme() */ - - - -/* - * --------------------------------------------------------------------------- - * - * Human-readable decoding of Reason and Result codes. - * - * --------------------------------------------------------------------------- - */ - -struct mlme_code { - const char *name; - int id; -}; - -static const struct mlme_code Result_codes[] = { - { "Success", 0x0000 }, - { "Unspecified Failure", 0x0001 }, - /* (Reserved) 0x0002 - 0x0009 */ - { "Refused Capabilities Mismatch", 0x000A }, - /* (Reserved) 0x000B */ - { "Refused External Reason", 0x000C }, - /* (Reserved) 0x000D - 0x0010 */ - { "Refused AP Out Of Memory", 0x0011 }, - { "Refused Basic Rates Mismatch", 0x0012 }, - /* (Reserved) 0x0013 - 0x001F */ - { "Failure", 0x0020 }, - /* (Reserved) 0x0021 - 0x0024 */ - { "Refused Reason Unspecified", 0x0025 }, - { "Invalid Parameters", 0x0026 }, - { "Rejected With Suggested Changes", 0x0027 }, - /* (Reserved) 0x0028 - 0x002E */ - { "Rejected For Delay Period", 0x002F }, - { "Not Allowed", 0x0030 }, - { "Not Present", 0x0031 }, - { "Not QSTA", 0x0032 }, - /* (Reserved) 0x0033 - 0x7FFF */ - { "Timeout", 0x8000 }, - { "Too Many Simultaneous Requests", 0x8001 }, - { "BSS Already Started Or Joined", 0x8002 }, - { "Not Supported", 0x8003 }, - { "Transmission Failure", 0x8004 }, - { "Refused Not Authenticated", 0x8005 }, - { "Reset Required Before Start", 0x8006 }, - { "LM Info Unavailable", 0x8007 }, - { NULL, -1 } -}; - -static const struct mlme_code Reason_codes[] = { - /* (Reserved) 0x0000 */ - { "Unspecified Reason", 0x0001 }, - { "Authentication Not Valid", 0x0002 }, - { "Deauthenticated Leave BSS", 0x0003 }, - { "Disassociated Inactivity", 0x0004 }, - { "AP Overload", 0x0005 }, - { "Class2 Frame Error", 0x0006 }, - { "Class3 Frame Error", 0x0007 }, - { "Disassociated Leave BSS", 0x0008 }, - { "Association Not Authenticated", 0x0009 }, - { "Disassociated Power Capability", 0x000A }, - { "Disassociated Supported Channels", 0x000B }, - /* (Reserved) 0x000C */ - { "Invalid Information Element", 0x000D }, - { "Michael MIC Failure", 0x000E }, - { "Fourway Handshake Timeout", 0x000F }, - { "Group Key Update Timeout", 0x0010 }, - { "Handshake Element Different", 0x0011 }, - { "Invalid Group Cipher", 0x0012 }, - { "Invalid Pairwise Cipher", 0x0013 }, - { "Invalid AKMP", 0x0014 }, - { "Unsupported RSN IE Version", 0x0015 }, - { "Invalid RSN IE Capabilities", 0x0016 }, - { "Dot1X Auth Failed", 0x0017 }, - { "Cipher Rejected By Policy", 0x0018 }, - /* (Reserved) 0x0019 - 0x001F */ - { "QoS Unspecified Reason", 0x0020 }, - { "QoS Insufficient Bandwidth", 0x0021 }, - { "QoS Excessive Not Ack", 0x0022 }, - { "QoS TXOP Limit Exceeded", 0x0023 }, - { "QSTA Leaving", 0x0024 }, - { "End TS, End DLS, End BA", 0x0025 }, - { "Unknown TS, Unknown DLS, Unknown BA", 0x0026 }, - { "Timeout", 0x0027 }, - /* (Reserved) 0x0028 - 0x002C */ - { "STAKey Mismatch", 0x002D }, - { NULL, -1 } -}; - - -static const char * -lookup_something(const struct mlme_code *n, int id) -{ - for (; n->name; n++) { - if (n->id == id) { - return n->name; - } - } - - /* not found */ - return NULL; -} /* lookup_something() */ - - -const char * -lookup_result_code(int result) -{ - static char fallback[16]; - const char *str; - - str = lookup_something(Result_codes, result); - - if (str == NULL) { - snprintf(fallback, 16, "%d", result); - str = fallback; - } - - return str; -} /* lookup_result_code() */ - - -/* - * --------------------------------------------------------------------------- - * lookup_reason - * - * Return a description string for a WiFi MLME ReasonCode. - * - * Arguments: - * reason The ReasonCode to interpret. - * - * Returns: - * Pointer to description string. - * --------------------------------------------------------------------------- - */ -const char * -lookup_reason_code(int reason) -{ - static char fallback[16]; - const char *str; - - str = lookup_something(Reason_codes, reason); - - if (str == NULL) { - snprintf(fallback, 16, "%d", reason); - str = fallback; - } - - return str; -} /* lookup_reason_code() */ - diff --git a/drivers/staging/csr/monitor.c b/drivers/staging/csr/monitor.c deleted file mode 100644 index e11f6cba8266..000000000000 --- a/drivers/staging/csr/monitor.c +++ /dev/null @@ -1,384 +0,0 @@ -/* - * --------------------------------------------------------------------------- - * FILE: monitor.c - * - * Copyright (C) 2006-2008 by Cambridge Silicon Radio Ltd. - * - * Refer to LICENSE.txt included with this source code for details on - * the license terms. - * - * --------------------------------------------------------------------------- - */ - -#include "unifi_priv.h" - -#ifdef UNIFI_SNIFF_ARPHRD - - -#if (UNIFI_SNIFF_ARPHRD == ARPHRD_IEEE80211_RADIOTAP) -#include -#endif - -#ifndef ETH_P_80211_RAW -#define ETH_P_80211_RAW ETH_P_ALL -#endif - -/* - * --------------------------------------------------------------------------- - * uf_start_sniff - * - * Start UniFi capture in SNIFF mode, i.e capture everything it hears. - * - * Arguments: - * priv Pointer to device private context struct - * - * Returns: - * 0 on success or kernel error code - * --------------------------------------------------------------------------- - */ -int -uf_start_sniff(unifi_priv_t *priv) -{ - ul_client_t *pcli = priv->wext_client; - CSR_SIGNAL signal; - CSR_MLME_SNIFFJOIN_REQUEST *req = &signal.u.MlmeSniffjoinRequest; - int timeout = 1000; - int r; - - req->Ifindex = priv->if_index; - req->Channel = priv->wext_conf.channel; - req->ChannelStartingFactor = 0; - - signal.SignalPrimitiveHeader.SignalId = CSR_MLME_SNIFFJOIN_REQUEST_ID; - - r = unifi_mlme_blocking_request(priv, pcli, &signal, NULL, timeout); - if (r < 0) { - unifi_error(priv, "failed to send SNIFFJOIN request, error %d\n", r); - return r; - } - - r = pcli->reply_signal->u.MlmeSniffjoinConfirm.Resultcode; - if (r) { - unifi_notice(priv, "SNIFFJOIN request was rejected with result 0x%X (%s)\n", - r, lookup_result_code(r)); - return -EIO; - } - - return 0; -} /* uf_start_sniff() */ - - - -/* - * --------------------------------------------------------------------------- - * netrx_radiotap - * - * Reformat a UniFi SNIFFDATA signal into a radiotap packet. - * - * Arguments: - * priv OS private context pointer. - * ind Pointer to a MA_UNITDATA_INDICATION or - * DS_UNITDATA_INDICATION indication structure. - * - * Notes: - * Radiotap header values are all little-endian, UniFi signals will have - * been converted to host-endian. - * --------------------------------------------------------------------------- - */ -#if (UNIFI_SNIFF_ARPHRD == ARPHRD_IEEE80211_RADIOTAP) -static void -netrx_radiotap(unifi_priv_t *priv, - const CSR_MA_SNIFFDATA_INDICATION *ind, - struct sk_buff *skb_orig) -{ - struct net_device *dev = priv->netdev; - struct sk_buff *skb = NULL; - unsigned char *ptr; - unsigned char *base; - int ind_data_len = skb_orig->len - 2 - ETH_HLEN; - struct unifi_rx_radiotap_header { - struct ieee80211_radiotap_header rt_hdr; - /* IEEE80211_RADIOTAP_TSFT */ - u64 rt_tsft; - /* IEEE80211_RADIOTAP_FLAGS */ - u8 rt_flags; - /* IEEE80211_RADIOTAP_RATE */ - u8 rt_rate; - /* IEEE80211_RADIOTAP_CHANNEL */ - u16 rt_chan; - u16 rt_chan_flags; - /* IEEE80211_RADIOTAP_DBM_ANTSIGNAL */ - u8 rt_dbm_antsignal; - /* IEEE80211_RADIOTAP_DBM_ANTNOISE */ - u8 rt_dbm_antnoise; - /* IEEE80211_RADIOTAP_ANTENNA */ - u8 rt_antenna; - - /* pad to 4-byte boundary */ - u8 pad[3]; - } __attribute__((__packed__)); - - struct unifi_rx_radiotap_header *unifi_rt; - int signal, noise, snr; - - if (ind_data_len <= 0) { - unifi_error(priv, "Invalid length in CSR_MA_SNIFFDATA_INDICATION.\n"); - return; - } - - /* - * Allocate a SKB for the received data packet, including radiotap - * header. - */ - skb = dev_alloc_skb(ind_data_len + sizeof(struct unifi_rx_radiotap_header) + 4); - if (! skb) { - unifi_error(priv, "alloc_skb failed.\n"); - priv->stats.rx_errors++; - return; - } - - base = skb->data; - - /* Reserve the radiotap header at the front of skb */ - unifi_rt = (struct unifi_rx_radiotap_header *) - skb_put(skb, sizeof(struct unifi_rx_radiotap_header)); - - /* Copy in the 802.11 frame */ - ptr = skb_put(skb, ind_data_len); - memcpy(ptr, skb_orig->data, ind_data_len); - - unifi_rt->rt_hdr.it_version = PKTHDR_RADIOTAP_VERSION; - unifi_rt->rt_hdr.it_pad = 0; /* always good to zero */ - unifi_rt->rt_hdr.it_len = sizeof(struct unifi_rx_radiotap_header); - - /* Big bitfield of all the fields we provide in radiotap */ - unifi_rt->rt_hdr.it_present = 0 - | (1 << IEEE80211_RADIOTAP_TSFT) - | (1 << IEEE80211_RADIOTAP_FLAGS) - | (1 << IEEE80211_RADIOTAP_RATE) - | (1 << IEEE80211_RADIOTAP_CHANNEL) - | (1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL) - | (1 << IEEE80211_RADIOTAP_DBM_ANTNOISE) - | (1 << IEEE80211_RADIOTAP_ANTENNA) - ; - - - /* No flags to set */ - unifi_rt->rt_tsft = (((u64)ind->Timestamp.x[7]) | (((u64)ind->Timestamp.x[6]) << 8) | - (((u64)ind->Timestamp.x[5]) << 16) | (((u64)ind->Timestamp.x[4]) << 24) | - (((u64)ind->Timestamp.x[3]) << 32) | (((u64)ind->Timestamp.x[2]) << 40) | - (((u64)ind->Timestamp.x[1]) << 48) | (((u64)ind->Timestamp.x[0]) << 56)); - - unifi_rt->rt_flags = 0; - - unifi_rt->rt_rate = ind->Rate; - - unifi_rt->rt_chan = cpu_to_le16(ieee80211chan2mhz(priv->wext_conf.channel)); - unifi_rt->rt_chan_flags = 0; - - /* Convert signal to dBm */ - signal = (s16)unifi2host_16(ind->Rssi); /* in dBm */ - snr = (s16)unifi2host_16(ind->Snr); /* in dB */ - noise = signal - snr; - - unifi_rt->rt_dbm_antsignal = signal; - unifi_rt->rt_dbm_antnoise = noise; - - unifi_rt->rt_antenna = ind->AntennaId; - - - skb->dev = dev; - skb_reset_mac_header(skb); - skb->pkt_type = PACKET_OTHERHOST; - skb->protocol = __constant_htons(ETH_P_80211_RAW); - memset(skb->cb, 0, sizeof(skb->cb)); - - /* Pass up to Linux network stack */ - netif_rx_ni(skb); - - dev->last_rx = jiffies; - - /* Bump the rx stats */ - priv->stats.rx_packets++; - priv->stats.rx_bytes += ind_data_len; - -} /* netrx_radiotap() */ -#endif /* RADIOTAP */ - - -/* - * --------------------------------------------------------------------------- - * netrx_prism - * - * Reformat a UniFi SNIFFDATA signal into a Prism format sniff packet. - * - * Arguments: - * priv OS private context pointer. - * ind Pointer to a MA_UNITDATA_INDICATION or - * DS_UNITDATA_INDICATION indication structure. - * - * Notes: - * Radiotap header values are all little-endian, UniFi signals will have - * been converted to host-endian. - * --------------------------------------------------------------------------- - */ -#if (UNIFI_SNIFF_ARPHRD == ARPHRD_IEEE80211_PRISM) -static void -netrx_prism(unifi_priv_t *priv, - const CSR_MA_SNIFFDATA_INDICATION *ind, - struct sk_buff *skb_orig) -{ - struct net_device *dev = priv->netdev; - struct sk_buff *skb = NULL; - unsigned char *ptr; - unsigned char *base; - int ind_data_len = skb_orig->len - 2 - ETH_HLEN; -#define WLANCAP_MAGIC_COOKIE_V1 0x80211001 - struct avs_header_v1 { - uint32 version; - uint32 length; - uint64 mactime; - uint64 hosttime; - uint32 phytype; - uint32 channel; - uint32 datarate; - uint32 antenna; - uint32 priority; - uint32 ssi_type; - int32 ssi_signal; - int32 ssi_noise; - uint32 preamble; - uint32 encoding; - } *avs; - int signal, noise, snr; - - if (ind_data_len <= 0) { - unifi_error(priv, "Invalid length in CSR_MA_SNIFFDATA_INDICATION.\n"); - return; - } - - /* - * Allocate a SKB for the received data packet, including radiotap - * header. - */ - skb = dev_alloc_skb(ind_data_len + sizeof(struct avs_header_v1) + 4); - if (! skb) { - unifi_error(priv, "alloc_skb failed.\n"); - priv->stats.rx_errors++; - return; - } - - base = skb->data; - - /* Reserve the radiotap header at the front of skb */ - avs = (struct avs_header_v1 *)skb_put(skb, sizeof(struct avs_header_v1)); - - /* Copy in the 802.11 frame */ - ptr = skb_put(skb, ind_data_len); - memcpy(ptr, skb_orig->data, ind_data_len); - - /* Convert signal to dBm */ - signal = 0x10000 - ((s16)unifi2host_16(ind->Rssi)); /* in dBm */ - snr = (s16)unifi2host_16(ind->Snr); /* in dB */ - noise = signal - snr; - - avs->version = htonl(WLANCAP_MAGIC_COOKIE_V1); - avs->length = htonl(sizeof(struct avs_header_v1)); - avs->mactime = __cpu_to_be64(ind->Timestamp); - avs->hosttime = __cpu_to_be64(jiffies); - avs->phytype = htonl(9); /* dss_ofdm_dot11_g */ - avs->channel = htonl(priv->wext_conf.channel); - avs->datarate = htonl(ind->Rate * 5); - avs->antenna = htonl(ind->Antenna); - avs->priority = htonl(0); /* unknown */ - avs->ssi_type = htonl(2); /* dBm */ - avs->ssi_signal = htonl(signal); - avs->ssi_noise = htonl(noise); - avs->preamble = htonl(0); /* unknown */ - avs->encoding = htonl(0); /* unknown */ - - - skb->dev = dev; - skb->mac.raw = skb->data; - skb->pkt_type = PACKET_OTHERHOST; - skb->protocol = __constant_htons(ETH_P_80211_RAW); - memset(skb->cb, 0, sizeof(skb->cb)); - - /* Pass up to Linux network stack */ - netif_rx_ni(skb); - - dev->last_rx = jiffies; - - /* Bump the rx stats */ - priv->stats.rx_packets++; - priv->stats.rx_bytes += ind_data_len; - -} /* netrx_prism() */ -#endif /* PRISM */ - - -/* - * --------------------------------------------------------------------------- - * ma_sniffdata_ind - * - * Reformat a UniFi SNIFFDATA signal into a network - * - * Arguments: - * ospriv OS private context pointer. - * ind Pointer to a MA_UNITDATA_INDICATION or - * DS_UNITDATA_INDICATION indication structure. - * bulkdata Pointer to a bulk data structure, describing - * the data received. - * - * Notes: - * Radiotap header values are all little-endian, UniFi signals will have - * been converted to host-endian. - * --------------------------------------------------------------------------- - */ -void -ma_sniffdata_ind(void *ospriv, - const CSR_MA_SNIFFDATA_INDICATION *ind, - const bulk_data_param_t *bulkdata) -{ - unifi_priv_t *priv = ospriv; - struct net_device *dev = priv->netdev; - struct sk_buff *skb = (struct sk_buff*)bulkdata->d[0].os_net_buf_ptr; - - if (bulkdata->d[0].data_length == 0) { - unifi_warning(priv, "rx: MA-SNIFFDATA indication with zero bulk data\n"); - return; - } - - skb->len = bulkdata->d[0].data_length; - - /* We only process data packets if the interface is open */ - if (unlikely(!netif_running(dev))) { - priv->stats.rx_dropped++; - priv->wext_conf.wireless_stats.discard.misc++; - dev_kfree_skb(skb); - return; - } - - if (ind->ReceptionStatus) { - priv->stats.rx_dropped++; - priv->wext_conf.wireless_stats.discard.misc++; - printk(KERN_INFO "unifi: Dropping corrupt sniff packet\n"); - dev_kfree_skb(skb); - return; - } - -#if (UNIFI_SNIFF_ARPHRD == ARPHRD_IEEE80211_PRISM) - netrx_prism(priv, ind, skb); -#endif /* PRISM */ - -#if (UNIFI_SNIFF_ARPHRD == ARPHRD_IEEE80211_RADIOTAP) - netrx_radiotap(priv, ind, skb); -#endif /* RADIOTAP */ - - dev_kfree_skb(skb); - -} /* ma_sniffdata_ind() */ - - -#endif /* UNIFI_SNIFF_ARPHRD */ - diff --git a/drivers/staging/csr/netdev.c b/drivers/staging/csr/netdev.c deleted file mode 100644 index 9c716c162c24..000000000000 --- a/drivers/staging/csr/netdev.c +++ /dev/null @@ -1,3307 +0,0 @@ -/* - * --------------------------------------------------------------------------- - * FILE: netdev.c - * - * PURPOSE: - * This file provides the upper edge interface to the linux netdevice - * and wireless extensions. - * It is part of the porting exercise. - * - * Copyright (C) 2005-2010 by Cambridge Silicon Radio Ltd. - * - * Refer to LICENSE.txt included with this source code for details on - * the license terms. - * - * --------------------------------------------------------------------------- - */ - -/* - * Porting Notes: - * This file implements the data plane of the UniFi linux driver. - * - * All the Tx packets are passed to the HIP core lib, using the - * unifi_send_signal() API. For EAPOL packets use the MLME-EAPOL.req - * signal, for all other use the MLME-UNITDATA.req. The unifi_send_signal() - * expects the wire-formatted (packed) signal. For convenience, in the OS - * layer we only use the native (unpacked) signal structures. The HIP core lib - * provides the write_pack() helper function to convert to the packed signal. - * The packet is stored in the bulk data of the signal. We do not need to - * allocate new memory to store the packet, because unifi_net_data_malloc() - * is implemented to return a skb, which is the format of packet in Linux. - * The HIP core lib frees the bulk data buffers, so we do not need to do - * this in the OS layer. - * - * All the Rx packets are MLME-UNITDATA.ind signals, passed by the HIP core lib - * in unifi_receive_event(). We do not need to allocate an skb and copy the - * received packet because the HIP core lib has stored in memory allocated by - * unifi_net_data_malloc(). Also, we can perform the 802.11 to Ethernet - * translation in-place because we allocate the extra memory allocated in - * unifi_net_data_malloc(). - * - * If possible, the porting exercise should appropriately implement - * unifi_net_data_malloc() and unifi_net_data_free() to save copies between - * network and driver buffers. - */ - -#include -#include -#include -#include -#include -#include "csr_wifi_hip_unifi.h" -#include "csr_wifi_hip_conversions.h" -#include "unifi_priv.h" -#include - - -/* Wext handler is supported only if CSR_SUPPORT_WEXT is defined */ -#ifdef CSR_SUPPORT_WEXT -extern struct iw_handler_def unifi_iw_handler_def; -#endif /* CSR_SUPPORT_WEXT */ -static void check_ba_frame_age_timeout( unifi_priv_t *priv, - netInterface_priv_t *interfacePriv, - ba_session_rx_struct *ba_session); -static void process_ba_frame(unifi_priv_t *priv, - netInterface_priv_t *interfacePriv, - ba_session_rx_struct *ba_session, - frame_desc_struct *frame_desc); -static void process_ba_complete(unifi_priv_t *priv, netInterface_priv_t *interfacePriv); -static void process_ma_packet_error_ind(unifi_priv_t *priv, CSR_SIGNAL *signal, bulk_data_param_t *bulkdata); -static void process_amsdu(unifi_priv_t *priv, CSR_SIGNAL *signal, bulk_data_param_t *bulkdata); -static int uf_net_open(struct net_device *dev); -static int uf_net_ioctl(struct net_device *dev, struct ifreq *rq, int cmd); -static int uf_net_stop(struct net_device *dev); -static struct net_device_stats *uf_net_get_stats(struct net_device *dev); -static u16 uf_net_select_queue(struct net_device *dev, struct sk_buff *skb); -static netdev_tx_t uf_net_xmit(struct sk_buff *skb, struct net_device *dev); -static void uf_set_multicast_list(struct net_device *dev); - - -typedef int (*tx_signal_handler)(unifi_priv_t *priv, struct sk_buff *skb, const struct ethhdr *ehdr, CSR_PRIORITY priority); - -#ifdef CONFIG_NET_SCHED -/* - * Queueing Discipline Interface - * Only used if kernel is configured with CONFIG_NET_SCHED - */ - -/* - * The driver uses the qdisc interface to buffer and control all - * outgoing traffic. We create a root qdisc, register our qdisc operations - * and later we create two subsidiary pfifo queues for the uncontrolled - * and controlled ports. - * - * The network stack delivers all outgoing packets in our enqueue handler. - * There, we classify the packet and decide whether to store it or drop it - * (if the controlled port state is set to "discard"). - * If the packet is enqueued, the network stack call our dequeue handler. - * There, we decide whether we can send the packet, delay it or drop it - * (the controlled port configuration might have changed meanwhile). - * If a packet is dequeued, then the network stack calls our hard_start_xmit - * handler where finally we send the packet. - * - * If the hard_start_xmit handler fails to send the packet, we return - * NETDEV_TX_BUSY and the network stack call our requeue handler where - * we put the packet back in the same queue in came from. - * - */ - -struct uf_sched_data -{ - /* Traffic Classifier TBD */ - struct tcf_proto *filter_list; - /* Our two queues */ - struct Qdisc *queues[UNIFI_TRAFFIC_Q_MAX]; -}; - -struct uf_tx_packet_data { - /* Queue the packet is stored in */ - unifi_TrafficQueue queue; - /* QoS Priority determined when enqueing packet */ - CSR_PRIORITY priority; - /* Debug */ - unsigned long host_tag; -}; - -#endif /* CONFIG_NET_SCHED */ - -static const struct net_device_ops uf_netdev_ops = -{ - .ndo_open = uf_net_open, - .ndo_stop = uf_net_stop, - .ndo_start_xmit = uf_net_xmit, - .ndo_do_ioctl = uf_net_ioctl, - .ndo_get_stats = uf_net_get_stats, /* called by /proc/net/dev */ - .ndo_set_rx_mode = uf_set_multicast_list, - .ndo_select_queue = uf_net_select_queue, -}; - -static u8 oui_rfc1042[P80211_OUI_LEN] = { 0x00, 0x00, 0x00 }; -static u8 oui_8021h[P80211_OUI_LEN] = { 0x00, 0x00, 0xf8 }; - - -/* Callback for event logging to blocking clients */ -static void netdev_mlme_event_handler(ul_client_t *client, - const u8 *sig_packed, int sig_len, - const bulk_data_param_t *bulkdata, - int dir); - -#ifdef CSR_SUPPORT_WEXT -/* Declare netdev_notifier block which will contain the state change - * handler callback function - */ -static struct notifier_block uf_netdev_notifier; -#endif - -/* - * --------------------------------------------------------------------------- - * uf_alloc_netdevice - * - * Allocate memory for the net_device and device private structs - * for this interface. - * Fill in the fields, but don't register the interface yet. - * We need to configure the UniFi first. - * - * Arguments: - * sdio_dev Pointer to SDIO context handle to use for all - * SDIO ops. - * bus_id A small number indicating the SDIO card position on the - * bus. Typically this is the slot number, e.g. 0, 1 etc. - * Valid values are 0 to MAX_UNIFI_DEVS-1. - * - * Returns: - * Pointer to device private struct. - * - * Notes: - * The net_device and device private structs are allocated together - * and should be freed by freeing the net_device pointer. - * --------------------------------------------------------------------------- - */ -unifi_priv_t * -uf_alloc_netdevice(CsrSdioFunction *sdio_dev, int bus_id) -{ - struct net_device *dev; - unifi_priv_t *priv; - netInterface_priv_t *interfacePriv; -#ifdef CSR_SUPPORT_WEXT - int rc; -#endif - unsigned char i; /* loop index */ - - /* - * Allocate netdevice struct, assign name template and - * setup as an ethernet device. - * The net_device and private structs are zeroed. Ether_setup() then - * sets up ethernet handlers and values. - * The RedHat 9 redhat-config-network tool doesn't recognise wlan* devices, - * so use "eth*" (like other wireless extns drivers). - */ - dev = alloc_etherdev_mq(sizeof(unifi_priv_t) + sizeof(netInterface_priv_t), UNIFI_TRAFFIC_Q_MAX); - - if (dev == NULL) { - return NULL; - } - - /* Set up back pointer from priv to netdev */ - interfacePriv = (netInterface_priv_t *)netdev_priv(dev); - priv = (unifi_priv_t *)(interfacePriv + 1); - interfacePriv->privPtr = priv; - interfacePriv->InterfaceTag = 0; - - - /* Initialize all supported netdev interface to be NULL */ - for(i=0; inetdev[i] = NULL; - priv->interfacePriv[i] = NULL; - } - priv->netdev[0] = dev; - priv->interfacePriv[0] = interfacePriv; - - /* Setup / override net_device fields */ - dev->netdev_ops = &uf_netdev_ops; - -#ifdef CSR_SUPPORT_WEXT - dev->wireless_handlers = &unifi_iw_handler_def; -#if IW_HANDLER_VERSION < 6 - dev->get_wireless_stats = unifi_get_wireless_stats; -#endif /* IW_HANDLER_VERSION */ -#endif /* CSR_SUPPORT_WEXT */ - - /* This gives us enough headroom to add the 802.11 header */ - dev->needed_headroom = 32; - - /* Use bus_id as instance number */ - priv->instance = bus_id; - /* Store SDIO pointer to pass in the core */ - priv->sdio = sdio_dev; - - sdio_dev->driverData = (void*)priv; - /* Consider UniFi to be uninitialised */ - priv->init_progress = UNIFI_INIT_NONE; - - priv->prev_queue = 0; - - /* - * Initialise the clients structure array. - * We do not need protection around ul_init_clients() because - * the character device can not be used until uf_alloc_netdevice() - * returns and Unifi_instances[bus_id]=priv is set, since unifi_open() - * will return -ENODEV. - */ - ul_init_clients(priv); - - /* - * Register a new ul client to send the multicast list signals. - * Note: priv->instance must be set before calling this. - */ - priv->netdev_client = ul_register_client(priv, - 0, - netdev_mlme_event_handler); - if (priv->netdev_client == NULL) { - unifi_error(priv, - "Failed to register a unifi client for background netdev processing\n"); - free_netdev(priv->netdev[0]); - return NULL; - } - unifi_trace(priv, UDBG2, "Netdev %p client (id:%d s:0x%X) is registered\n", - dev, priv->netdev_client->client_id, priv->netdev_client->sender_id); - - priv->sta_wmm_capabilities = 0; - -#if (defined(CSR_WIFI_SECURITY_WAPI_ENABLE) && defined(CSR_SUPPORT_SME)) - priv->wapi_multicast_filter = 0; - priv->wapi_unicast_filter = 0; - priv->wapi_unicast_queued_pkt_filter = 0; -#ifdef CSR_WIFI_SECURITY_WAPI_QOSCTRL_MIC_WORKAROUND - priv->isWapiConnection = FALSE; -#endif -#endif - - /* Enable all queues by default */ - interfacePriv->queueEnabled[0] = 1; - interfacePriv->queueEnabled[1] = 1; - interfacePriv->queueEnabled[2] = 1; - interfacePriv->queueEnabled[3] = 1; - -#ifdef CSR_SUPPORT_SME - priv->allPeerDozing = 0; -#endif - /* - * Initialise the OS private struct. - */ - /* - * Instead of deciding in advance to use 11bg or 11a, we could do a more - * clever scan on both radios. - */ - if (use_5g) { - priv->if_index = CSR_INDEX_5G; - unifi_info(priv, "Using the 802.11a radio\n"); - } else { - priv->if_index = CSR_INDEX_2G4; - } - - /* Initialise bh thread structure */ - priv->bh_thread.thread_task = NULL; - priv->bh_thread.block_thread = 1; - init_waitqueue_head(&priv->bh_thread.wakeup_q); - priv->bh_thread.wakeup_flag = 0; - sprintf(priv->bh_thread.name, "uf_bh_thread"); - - /* reset the connected state for the interface */ - interfacePriv->connected = UnifiConnectedUnknown; /* -1 unknown, 0 no, 1 yes */ - -#ifdef USE_DRIVER_LOCK - sema_init(&priv->lock, 1); -#endif /* USE_DRIVER_LOCK */ - - spin_lock_init(&priv->send_signal_lock); - - spin_lock_init(&priv->m4_lock); - sema_init(&priv->ba_mutex, 1); - -#if (defined(CSR_WIFI_SECURITY_WAPI_ENABLE) && defined(CSR_WIFI_SECURITY_WAPI_SW_ENCRYPTION)) - spin_lock_init(&priv->wapi_lock); -#endif - -#ifdef CSR_SUPPORT_SME - spin_lock_init(&priv->staRecord_lock); - spin_lock_init(&priv->tx_q_lock); -#endif - - /* Create the Traffic Analysis workqueue */ - priv->unifi_workqueue = create_singlethread_workqueue("unifi_workq"); - if (priv->unifi_workqueue == NULL) { - /* Deregister priv->netdev_client */ - ul_deregister_client(priv->netdev_client); - free_netdev(priv->netdev[0]); - return NULL; - } - -#ifdef CSR_SUPPORT_SME - /* Create the Multicast Addresses list work structure */ - INIT_WORK(&priv->multicast_list_task, uf_multicast_list_wq); - - /* Create m4 buffering work structure */ - INIT_WORK(&interfacePriv->send_m4_ready_task, uf_send_m4_ready_wq); - -#if (defined(CSR_WIFI_SECURITY_WAPI_ENABLE) && defined(CSR_WIFI_SECURITY_WAPI_SW_ENCRYPTION)) - /* Create work structure to buffer the WAPI data packets to be sent to SME for encryption */ - INIT_WORK(&interfacePriv->send_pkt_to_encrypt, uf_send_pkt_to_encrypt); -#endif -#endif - - priv->ref_count = 1; - - priv->amp_client = NULL; - priv->coredump_mode = 0; - priv->ptest_mode = 0; - priv->wol_suspend = FALSE; - INIT_LIST_HEAD(&interfacePriv->rx_uncontrolled_list); - INIT_LIST_HEAD(&interfacePriv->rx_controlled_list); - sema_init(&priv->rx_q_sem, 1); - -#ifdef CSR_SUPPORT_WEXT - interfacePriv->netdev_callback_registered = FALSE; - interfacePriv->wait_netdev_change = FALSE; - /* Register callback for netdevice state changes */ - if ((rc = register_netdevice_notifier(&uf_netdev_notifier)) == 0) { - interfacePriv->netdev_callback_registered = TRUE; - } - else { - unifi_warning(priv, "Failed to register netdevice notifier : %d %p\n", rc, dev); - } -#endif /* CSR_SUPPORT_WEXT */ - -#ifdef CSR_WIFI_SPLIT_PATCH - /* set it to some invalid value */ - priv->pending_mode_set.common.destination = 0xaaaa; -#endif - - return priv; -} /* uf_alloc_netdevice() */ - -/* - *--------------------------------------------------------------------------- - * uf_alloc_netdevice_for_other_interfaces - * - * Allocate memory for the net_device and device private structs - * for this interface. - * Fill in the fields, but don't register the interface yet. - * We need to configure the UniFi first. - * - * Arguments: - * interfaceTag Interface number. - * sdio_dev Pointer to SDIO context handle to use for all - * SDIO ops. - * bus_id A small number indicating the SDIO card position on the - * bus. Typically this is the slot number, e.g. 0, 1 etc. - * Valid values are 0 to MAX_UNIFI_DEVS-1. - * - * Returns: - * Pointer to device private struct. - * - * Notes: - * The device private structure contains the interfaceTag and pointer to the unifi_priv - * structure created allocated by net_device od interface0. - * The net_device and device private structs are allocated together - * and should be freed by freeing the net_device pointer. - * --------------------------------------------------------------------------- - */ -u8 -uf_alloc_netdevice_for_other_interfaces(unifi_priv_t *priv, u16 interfaceTag) -{ - struct net_device *dev; - netInterface_priv_t *interfacePriv; - - /* - * Allocate netdevice struct, assign name template and - * setup as an ethernet device. - * The net_device and private structs are zeroed. Ether_setup() then - * sets up ethernet handlers and values. - * The RedHat 9 redhat-config-network tool doesn't recognise wlan* devices, - * so use "eth*" (like other wireless extns drivers). - */ - dev = alloc_etherdev_mq(sizeof(netInterface_priv_t), 1); - if (dev == NULL) { - return FALSE; - } - - if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) { - unifi_error(priv, "uf_alloc_netdevice_for_other_interfaces bad interfaceTag\n"); - return FALSE; - } - - /* Set up back pointer from priv to netdev */ - interfacePriv = (netInterface_priv_t *)netdev_priv(dev); - interfacePriv->privPtr = priv; - interfacePriv->InterfaceTag = interfaceTag; - priv->netdev[interfaceTag] = dev; - priv->interfacePriv[interfacePriv->InterfaceTag] = interfacePriv; - - /* reset the connected state for the interface */ - interfacePriv->connected = UnifiConnectedUnknown; /* -1 unknown, 0 no, 1 yes */ - INIT_LIST_HEAD(&interfacePriv->rx_uncontrolled_list); - INIT_LIST_HEAD(&interfacePriv->rx_controlled_list); - - /* Setup / override net_device fields */ - dev->netdev_ops = &uf_netdev_ops; - -#ifdef CSR_SUPPORT_WEXT - dev->wireless_handlers = &unifi_iw_handler_def; -#if IW_HANDLER_VERSION < 6 - dev->get_wireless_stats = unifi_get_wireless_stats; -#endif /* IW_HANDLER_VERSION */ -#endif /* CSR_SUPPORT_WEXT */ - return TRUE; -} /* uf_alloc_netdevice() */ - - - -/* - * --------------------------------------------------------------------------- - * uf_free_netdevice - * - * Unregister the network device and free the memory allocated for it. - * NB This includes the memory for the priv struct. - * - * Arguments: - * priv Device private pointer. - * - * Returns: - * None. - * --------------------------------------------------------------------------- - */ -int -uf_free_netdevice(unifi_priv_t *priv) -{ - int i; - unsigned long flags; - - unifi_trace(priv, UDBG1, "uf_free_netdevice\n"); - - if (!priv) { - return -EINVAL; - } - - /* - * Free any buffers used for holding firmware - */ - uf_release_firmware_files(priv); - -#if (defined CSR_SUPPORT_SME) && (defined CSR_SUPPORT_WEXT) - if (priv->connection_config.mlmeAssociateReqInformationElements) { - kfree(priv->connection_config.mlmeAssociateReqInformationElements); - } - priv->connection_config.mlmeAssociateReqInformationElements = NULL; - priv->connection_config.mlmeAssociateReqInformationElementsLength = 0; - - if (priv->mib_data.length) { - vfree(priv->mib_data.data); - } - priv->mib_data.data = NULL; - priv->mib_data.length = 0; - -#endif /* CSR_SUPPORT_SME && CSR_SUPPORT_WEXT*/ - - /* Free any bulkdata buffers allocated for M4 caching */ - spin_lock_irqsave(&priv->m4_lock, flags); - for (i = 0; i < CSR_WIFI_NUM_INTERFACES; i++) { - netInterface_priv_t *interfacePriv = priv->interfacePriv[i]; - if (interfacePriv->m4_bulk_data.data_length > 0) { - unifi_trace(priv, UDBG5, "uf_free_netdevice: free M4 bulkdata %d\n", i); - unifi_net_data_free(priv, &interfacePriv->m4_bulk_data); - } - } - spin_unlock_irqrestore(&priv->m4_lock, flags); - -#if (defined(CSR_WIFI_SECURITY_WAPI_ENABLE) && defined(CSR_WIFI_SECURITY_WAPI_SW_ENCRYPTION)) - /* Free any bulkdata buffers allocated for M4 caching */ - spin_lock_irqsave(&priv->wapi_lock, flags); - for (i = 0; i < CSR_WIFI_NUM_INTERFACES; i++) { - netInterface_priv_t *interfacePriv = priv->interfacePriv[i]; - if (interfacePriv->wapi_unicast_bulk_data.data_length > 0) { - unifi_trace(priv, UDBG5, "uf_free_netdevice: free WAPI PKT bulk data %d\n", i); - unifi_net_data_free(priv, &interfacePriv->wapi_unicast_bulk_data); - } - } - spin_unlock_irqrestore(&priv->wapi_lock, flags); -#endif - -#ifdef CSR_SUPPORT_WEXT - /* Unregister callback for netdevice state changes */ - unregister_netdevice_notifier(&uf_netdev_notifier); -#endif /* CSR_SUPPORT_WEXT */ - -#ifdef CSR_SUPPORT_SME - /* Cancel work items and destroy the workqueue */ - cancel_work_sync(&priv->multicast_list_task); -#endif -/* Destroy the workqueues. */ - flush_workqueue(priv->unifi_workqueue); - destroy_workqueue(priv->unifi_workqueue); - - /* Free up netdev in reverse order: priv is allocated with netdev[0]. - * So, netdev[0] should be freed after all other netdevs are freed up - */ - for (i=CSR_WIFI_NUM_INTERFACES-1; i>=0; i--) { - /*Free the netdev struct and priv, which are all one lump*/ - if (priv->netdev[i]) { - unifi_error(priv, "uf_free_netdevice: netdev %d %p\n", i, priv->netdev[i]); - free_netdev(priv->netdev[i]); - } - } - - return 0; -} /* uf_free_netdevice() */ - - -/* - * --------------------------------------------------------------------------- - * uf_net_open - * - * Called when userland does "ifconfig wlan0 up". - * - * Arguments: - * dev Device pointer. - * - * Returns: - * None. - * --------------------------------------------------------------------------- - */ -static int -uf_net_open(struct net_device *dev) -{ - netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev); - unifi_priv_t *priv = interfacePriv->privPtr; - - /* If we haven't finished UniFi initialisation, we can't start */ - if (priv->init_progress != UNIFI_INIT_COMPLETED) { - unifi_warning(priv, "%s: unifi not ready, failing net_open\n", __FUNCTION__); - return -EINVAL; - } - -#if (defined CSR_NATIVE_LINUX) && (defined UNIFI_SNIFF_ARPHRD) && defined(CSR_SUPPORT_WEXT) - /* - * To sniff, the user must do "iwconfig mode monitor", which sets - * priv->wext_conf.mode to IW_MODE_MONITOR. - * Then he/she must do "ifconfig ethn up", which calls this fn. - * There is no point in starting the sniff with SNIFFJOIN until - * this point. - */ - if (priv->wext_conf.mode == IW_MODE_MONITOR) { - int err; - err = uf_start_sniff(priv); - if (err) { - return err; - } - netif_carrier_on(dev); - } -#endif - -#ifdef CSR_SUPPORT_WEXT - if (interfacePriv->wait_netdev_change) { - unifi_trace(priv, UDBG1, "%s: Waiting for NETDEV_CHANGE, assume connected\n", - __FUNCTION__); - interfacePriv->connected = UnifiConnected; - interfacePriv->wait_netdev_change = FALSE; - } -#endif - - netif_tx_start_all_queues(dev); - - return 0; -} /* uf_net_open() */ - - -static int -uf_net_stop(struct net_device *dev) -{ -#if defined(CSR_NATIVE_LINUX) && defined(UNIFI_SNIFF_ARPHRD) && defined(CSR_SUPPORT_WEXT) - netInterface_priv_t *interfacePriv = (netInterface_priv_t*)netdev_priv(dev); - unifi_priv_t *priv = interfacePriv->privPtr; - - /* Stop sniffing if in Monitor mode */ - if (priv->wext_conf.mode == IW_MODE_MONITOR) { - if (priv->card) { - int err; - err = unifi_reset_state(priv, dev->dev_addr, 1); - if (err) { - return err; - } - } - } -#endif - - netif_tx_stop_all_queues(dev); - - return 0; -} /* uf_net_stop() */ - - -/* This is called after the WE handlers */ -static int -uf_net_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) -{ - int rc; - - rc = -EOPNOTSUPP; - - return rc; -} /* uf_net_ioctl() */ - - - -static struct net_device_stats * -uf_net_get_stats(struct net_device *dev) -{ - netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev); - - return &interfacePriv->stats; -} /* uf_net_get_stats() */ - -static CSR_PRIORITY uf_get_packet_priority(unifi_priv_t *priv, netInterface_priv_t *interfacePriv, struct sk_buff *skb, const int proto) -{ - CSR_PRIORITY priority = CSR_CONTENTION; - - priority = (CSR_PRIORITY) (skb->priority >> 5); - - if (priority == CSR_QOS_UP0) { /* 0 */ - - unifi_trace(priv, UDBG5, "uf_get_packet_priority: proto = 0x%.4X\n", proto); - - switch (proto) { - case 0x0800: /* IPv4 */ - case 0x814C: /* SNMP */ - case 0x880C: /* GSMP */ - priority = (CSR_PRIORITY) (skb->data[1 + ETH_HLEN] >> 5); - break; - - case 0x8100: /* VLAN */ - priority = (CSR_PRIORITY) (skb->data[0 + ETH_HLEN] >> 5); - break; - - case 0x86DD: /* IPv6 */ - priority = (CSR_PRIORITY) ((skb->data[0 + ETH_HLEN] & 0x0E) >> 1); - break; - - default: - priority = CSR_QOS_UP0; - break; - } - } - - /* Check if we are allowed to transmit on this AC. Because of ACM we may have to downgrade to a lower - * priority */ - if (interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_STA || - interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PCLI) { - unifi_TrafficQueue queue; - - /* Keep trying lower priorities until we find a queue - * Priority to queue mapping is 1,2 - BK, 0,3 - BE, 4,5 - VI, 6,7 - VO */ - queue = unifi_frame_priority_to_queue(priority); - - while (queue > UNIFI_TRAFFIC_Q_BK && !interfacePriv->queueEnabled[queue]) { - queue--; - priority = unifi_get_default_downgrade_priority(queue); - } - } - - unifi_trace(priv, UDBG5, "Packet priority = %d\n", priority); - - return priority; -} - -/* - */ -/* - * --------------------------------------------------------------------------- - * get_packet_priority - * - * Arguments: - * priv private data area of functional driver - * skb socket buffer - * ehdr ethernet header to fetch protocol - * interfacePriv For accessing station record database - * - * - * Returns: - * CSR_PRIORITY. - * --------------------------------------------------------------------------- - */ -CSR_PRIORITY -get_packet_priority(unifi_priv_t *priv, struct sk_buff *skb, const struct ethhdr *ehdr, netInterface_priv_t *interfacePriv) -{ - CSR_PRIORITY priority = CSR_CONTENTION; - const int proto = ntohs(ehdr->h_proto); - - u8 interfaceMode = interfacePriv->interfaceMode; - - /* Priority Mapping for all the Modes */ - switch(interfaceMode) - { - case CSR_WIFI_ROUTER_CTRL_MODE_STA: - case CSR_WIFI_ROUTER_CTRL_MODE_P2PCLI: - unifi_trace(priv, UDBG4, "mode is STA \n"); - if ((priv->sta_wmm_capabilities & QOS_CAPABILITY_WMM_ENABLED) == 1) { - priority = uf_get_packet_priority(priv, interfacePriv, skb, proto); - } else { - priority = CSR_CONTENTION; - } - break; -#ifdef CSR_SUPPORT_SME - case CSR_WIFI_ROUTER_CTRL_MODE_AP: - case CSR_WIFI_ROUTER_CTRL_MODE_P2PGO: - case CSR_WIFI_ROUTER_CTRL_MODE_IBSS: - { - CsrWifiRouterCtrlStaInfo_t * dstStaInfo = - CsrWifiRouterCtrlGetStationRecordFromPeerMacAddress(priv, ehdr->h_dest, interfacePriv->InterfaceTag); - unifi_trace(priv, UDBG4, "mode is AP \n"); - if (!(ehdr->h_dest[0] & 0x01) && dstStaInfo && dstStaInfo->wmmOrQosEnabled) { - /* If packet is not Broadcast/multicast */ - priority = uf_get_packet_priority(priv, interfacePriv, skb, proto); - } else { - /* Since packet destination is not QSTA, set priority to CSR_CONTENTION */ - unifi_trace(priv, UDBG4, "Destination is not QSTA or BroadCast/Multicast\n"); - priority = CSR_CONTENTION; - } - } - break; -#endif - default: - unifi_trace(priv, UDBG3, " mode unknown in %s func, mode=%x\n", __FUNCTION__, interfaceMode); - } - unifi_trace(priv, UDBG5, "priority = %x\n", priority); - - return priority; -} - -/* - * --------------------------------------------------------------------------- - * uf_net_select_queue - * - * Called by the kernel to select which queue to put the packet in - * - * Arguments: - * dev Device pointer - * skb Packet - * - * Returns: - * Queue index - * --------------------------------------------------------------------------- - */ -static u16 -uf_net_select_queue(struct net_device *dev, struct sk_buff *skb) -{ - netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev); - unifi_priv_t *priv = (unifi_priv_t *)interfacePriv->privPtr; - struct ethhdr ehdr; - unifi_TrafficQueue queue; - int proto; - CSR_PRIORITY priority; - - memcpy(&ehdr, skb->data, ETH_HLEN); - proto = ntohs(ehdr.h_proto); - - /* 802.1x - apply controlled/uncontrolled port rules */ - if ((proto != ETH_P_PAE) -#ifdef CSR_WIFI_SECURITY_WAPI_ENABLE - && (proto != ETH_P_WAI) -#endif - ) { - /* queues 0 - 3 */ - priority = get_packet_priority(priv, skb, &ehdr, interfacePriv); - queue = unifi_frame_priority_to_queue(priority); - } else { - /* queue 4 */ - queue = UNIFI_TRAFFIC_Q_EAPOL; - } - - - return (u16)queue; -} /* uf_net_select_queue() */ - -int -skb_add_llc_snap(struct net_device *dev, struct sk_buff *skb, int proto) -{ - llc_snap_hdr_t *snap; - netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev); - unifi_priv_t *priv = interfacePriv->privPtr; - int headroom; - - /* get the headroom available in skb */ - headroom = skb_headroom(skb); - /* step 1: classify ether frame, DIX or 802.3? */ - - if (proto < 0x600) { - /* codes <= 1500 reserved for 802.3 lengths */ - /* it's 802.3, pass ether payload unchanged, */ - unifi_trace(priv, UDBG3, "802.3 len: %d\n", skb->len); - - /* leave off any PAD octets. */ - skb_trim(skb, proto); - } else if (proto == ETH_P_8021Q) { - - /* Store the VLAN SNAP (should be 87-65). */ - u16 vlan_snap = *(u16*)skb->data; - /* check for headroom availability before skb_push 14 = (4 + 10) */ - if (headroom < 14) { - unifi_trace(priv, UDBG3, "cant append vlan snap: debug\n"); - return -1; - } - /* Add AA-AA-03-00-00-00 */ - snap = (llc_snap_hdr_t *)skb_push(skb, 4); - snap->dsap = snap->ssap = 0xAA; - snap->ctrl = 0x03; - memcpy(snap->oui, oui_rfc1042, P80211_OUI_LEN); - - /* Add AA-AA-03-00-00-00 */ - snap = (llc_snap_hdr_t *)skb_push(skb, 10); - snap->dsap = snap->ssap = 0xAA; - snap->ctrl = 0x03; - memcpy(snap->oui, oui_rfc1042, P80211_OUI_LEN); - - /* Add the VLAN specific information */ - snap->protocol = htons(proto); - *(u16*)(snap + 1) = vlan_snap; - - } else - { - /* it's DIXII, time for some conversion */ - unifi_trace(priv, UDBG3, "DIXII len: %d\n", skb->len); - - /* check for headroom availability before skb_push */ - if (headroom < sizeof(llc_snap_hdr_t)) { - unifi_trace(priv, UDBG3, "cant append snap: debug\n"); - return -1; - } - /* tack on SNAP */ - snap = (llc_snap_hdr_t *)skb_push(skb, sizeof(llc_snap_hdr_t)); - snap->dsap = snap->ssap = 0xAA; - snap->ctrl = 0x03; - /* Use the appropriate OUI. */ - if ((proto == ETH_P_AARP) || (proto == ETH_P_IPX)) { - memcpy(snap->oui, oui_8021h, P80211_OUI_LEN); - } else { - memcpy(snap->oui, oui_rfc1042, P80211_OUI_LEN); - } - snap->protocol = htons(proto); - } - - return 0; -} /* skb_add_llc_snap() */ - -#ifdef CSR_SUPPORT_SME -static int -_identify_sme_ma_pkt_ind(unifi_priv_t *priv, - const s8 *oui, u16 protocol, - const CSR_SIGNAL *signal, - bulk_data_param_t *bulkdata, - const unsigned char *daddr, - const unsigned char *saddr) -{ - CSR_MA_PACKET_INDICATION *pkt_ind = (CSR_MA_PACKET_INDICATION*)&signal->u.MaPacketIndication; - int r; - u8 i; - - unifi_trace(priv, UDBG5, - "_identify_sme_ma_pkt_ind -->\n"); - for (i = 0; i < MAX_MA_UNIDATA_IND_FILTERS; i++) { - if (priv->sme_unidata_ind_filters[i].in_use) { - if (!memcmp(oui, priv->sme_unidata_ind_filters[i].oui, 3) && - (protocol == priv->sme_unidata_ind_filters[i].protocol)) { - - /* Send to client */ - if (priv->sme_cli) { - /* - * Pass the packet to the SME, using unifi_sys_ma_unitdata_ind(). - * The frame needs to be converted according to the encapsulation. - */ - unifi_trace(priv, UDBG1, - "_identify_sme_ma_pkt_ind: handle=%d, encap=%d, proto=%x\n", - i, priv->sme_unidata_ind_filters[i].encapsulation, - priv->sme_unidata_ind_filters[i].protocol); - if (priv->sme_unidata_ind_filters[i].encapsulation == CSR_WIFI_ROUTER_ENCAPSULATION_ETHERNET) { - struct sk_buff *skb; - /* The translation is performed on skb... */ - skb = (struct sk_buff*)bulkdata->d[0].os_net_buf_ptr; - skb->len = bulkdata->d[0].data_length; - - unifi_trace(priv, UDBG1, - "_identify_sme_ma_pkt_ind: skb_80211_to_ether -->\n"); - r = skb_80211_to_ether(priv, skb, daddr, saddr, - signal, bulkdata); - unifi_trace(priv, UDBG1, - "_identify_sme_ma_pkt_ind: skb_80211_to_ether <--\n"); - if (r) { - return -EINVAL; - } - - /* ... but we indicate buffer and length */ - bulkdata->d[0].os_data_ptr = skb->data; - bulkdata->d[0].data_length = skb->len; - } else { - /* Add the MAC addresses before the SNAP */ - bulkdata->d[0].os_data_ptr -= 2*ETH_ALEN; - bulkdata->d[0].data_length += 2*ETH_ALEN; - memcpy((void*)bulkdata->d[0].os_data_ptr, daddr, ETH_ALEN); - memcpy((void*)bulkdata->d[0].os_data_ptr + ETH_ALEN, saddr, ETH_ALEN); - } - - unifi_trace(priv, UDBG1, - "_identify_sme_ma_pkt_ind: unifi_sys_ma_pkt_ind -->\n"); - CsrWifiRouterMaPacketIndSend(priv->sme_unidata_ind_filters[i].appHandle, - (pkt_ind->VirtualInterfaceIdentifier & 0xff), - i, - pkt_ind->ReceptionStatus, - bulkdata->d[0].data_length, - (u8*)bulkdata->d[0].os_data_ptr, - NULL, - pkt_ind->Rssi, - pkt_ind->Snr, - pkt_ind->ReceivedRate); - - - unifi_trace(priv, UDBG1, - "_identify_sme_ma_pkt_ind: unifi_sys_ma_pkt_ind <--\n"); - } - - return 1; - } - } - } - - return -1; -} -#endif /* CSR_SUPPORT_SME */ - -/* - * --------------------------------------------------------------------------- - * skb_80211_to_ether - * - * Make sure the received frame is in Ethernet (802.3) form. - * De-encapsulates SNAP if necessary, adds a ethernet header. - * The source buffer should not contain an 802.11 MAC header - * - * Arguments: - * payload Pointer to packet data received from UniFi. - * payload_length Number of bytes of data received from UniFi. - * daddr Destination MAC address. - * saddr Source MAC address. - * - * Returns: - * 0 on success, -1 if the packet is bad and should be dropped, - * 1 if the packet was forwarded to the SME or AMP client. - * --------------------------------------------------------------------------- - */ -int -skb_80211_to_ether(unifi_priv_t *priv, struct sk_buff *skb, - const unsigned char *daddr, const unsigned char *saddr, - const CSR_SIGNAL *signal, - bulk_data_param_t *bulkdata) -{ - unsigned char *payload; - int payload_length; - struct ethhdr *eth; - llc_snap_hdr_t *snap; - int headroom; -#define UF_VLAN_LLC_HEADER_SIZE 18 - static const u8 vlan_inner_snap[] = { 0xAA, 0xAA, 0x03, 0x00, 0x00, 0x00 }; -#if defined(CSR_NATIVE_SOFTMAC) && defined(CSR_SUPPORT_SME) - const CSR_MA_PACKET_INDICATION *pkt_ind = &signal->u.MaPacketIndication; -#endif - - if(skb== NULL || daddr == NULL || saddr == NULL){ - unifi_error(priv, "skb_80211_to_ether: PBC fail\n"); - return 1; - } - - payload = skb->data; - payload_length = skb->len; - - snap = (llc_snap_hdr_t *)payload; - eth = (struct ethhdr *)payload; - - /* get the skb headroom size */ - headroom = skb_headroom(skb); - - /* - * Test for the various encodings - */ - if ((payload_length >= sizeof(llc_snap_hdr_t)) && - (snap->dsap == 0xAA) && - (snap->ssap == 0xAA) && - (snap->ctrl == 0x03) && - (snap->oui[0] == 0) && - (snap->oui[1] == 0) && - ((snap->oui[2] == 0) || (snap->oui[2] == 0xF8))) - { - /* AppleTalk AARP (2) or IPX SNAP */ - if ((snap->oui[2] == 0) && - ((ntohs(snap->protocol) == ETH_P_AARP) || (ntohs(snap->protocol) == ETH_P_IPX))) - { - u16 len; - - unifi_trace(priv, UDBG3, "%s len: %d\n", - (ntohs(snap->protocol) == ETH_P_AARP) ? "ETH_P_AARP" : "ETH_P_IPX", - payload_length); - - /* check for headroom availability before skb_push */ - if (headroom < (2 * ETH_ALEN + 2)) { - unifi_warning(priv, "headroom not available to skb_push ether header\n"); - return -1; - } - - /* Add 802.3 header and leave full payload */ - len = htons(skb->len); - memcpy(skb_push(skb, 2), &len, 2); - memcpy(skb_push(skb, ETH_ALEN), saddr, ETH_ALEN); - memcpy(skb_push(skb, ETH_ALEN), daddr, ETH_ALEN); - - return 0; - } - /* VLAN-tagged IP */ - if ((snap->oui[2] == 0) && (ntohs(snap->protocol) == ETH_P_8021Q)) - { - /* - * The translation doesn't change the packet length, so is done in-place. - * - * Example header (from Std 802.11-2007 Annex M): - * AA-AA-03-00-00-00-81-00-87-65-AA-AA-03-00-00-00-08-06 - * -------SNAP-------p1-p1-ll-ll-------SNAP--------p2-p2 - * dd-dd-dd-dd-dd-dd-aa-aa-aa-aa-aa-aa-p1-p1-ll-ll-p2-p2 - * dd-dd-dd-dd-dd-dd-aa-aa-aa-aa-aa-aa-81-00-87-65-08-06 - */ - u16 vlan_snap; - - if (payload_length < UF_VLAN_LLC_HEADER_SIZE) { - unifi_warning(priv, "VLAN SNAP header too short: %d bytes\n", payload_length); - return -1; - } - - if (memcmp(payload + 10, vlan_inner_snap, 6)) { - unifi_warning(priv, "VLAN malformatted SNAP header.\n"); - return -1; - } - - unifi_trace(priv, UDBG3, "VLAN SNAP: %02x-%02x\n", payload[8], payload[9]); - unifi_trace(priv, UDBG3, "VLAN len: %d\n", payload_length); - - /* Create the 802.3 header */ - - vlan_snap = *((u16*)(payload + 8)); - - /* Create LLC header without byte-swapping */ - eth->h_proto = snap->protocol; - - memcpy(eth->h_dest, daddr, ETH_ALEN); - memcpy(eth->h_source, saddr, ETH_ALEN); - *(u16*)(eth + 1) = vlan_snap; - return 0; - } - - /* it's a SNAP + RFC1042 frame */ - unifi_trace(priv, UDBG3, "SNAP+RFC1042 len: %d\n", payload_length); - - /* chop SNAP+llc header from skb. */ - skb_pull(skb, sizeof(llc_snap_hdr_t)); - - /* Since skb_pull called above to chop snap+llc, no need to check for headroom - * availability before skb_push - */ - /* create 802.3 header at beginning of skb. */ - eth = (struct ethhdr *)skb_push(skb, ETH_HLEN); - memcpy(eth->h_dest, daddr, ETH_ALEN); - memcpy(eth->h_source, saddr, ETH_ALEN); - /* Copy protocol field without byte-swapping */ - eth->h_proto = snap->protocol; - } else { - u16 len; - - /* check for headroom availability before skb_push */ - if (headroom < (2 * ETH_ALEN + 2)) { - unifi_warning(priv, "headroom not available to skb_push ether header\n"); - return -1; - } - /* Add 802.3 header and leave full payload */ - len = htons(skb->len); - memcpy(skb_push(skb, 2), &len, 2); - memcpy(skb_push(skb, ETH_ALEN), saddr, ETH_ALEN); - memcpy(skb_push(skb, ETH_ALEN), daddr, ETH_ALEN); - - return 1; - } - - return 0; -} /* skb_80211_to_ether() */ - - -static CsrWifiRouterCtrlPortAction verify_port(unifi_priv_t *priv, unsigned char *address, int queue, u16 interfaceTag) -{ -#ifdef CSR_NATIVE_LINUX -#ifdef CSR_SUPPORT_WEXT - if (queue == UF_CONTROLLED_PORT_Q) { - return priv->wext_conf.block_controlled_port; - } else { - return CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_OPEN; - } -#else - return CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_OPEN; /* default to open for softmac dev */ -#endif -#else - return uf_sme_port_state(priv, address, queue, interfaceTag); -#endif -} - -/* - * --------------------------------------------------------------------------- - * prepare_and_add_macheader - * - * - * These functions adds mac header for packet from netdev - * to UniFi for transmission. - * EAP protocol packets are also appended with Mac header & - * sent using send_ma_pkt_request(). - * - * Arguments: - * priv Pointer to device private context struct - * skb Socket buffer containing data packet to transmit - * newSkb Socket buffer containing data packet + Mac header if no sufficient headroom in skb - * serviceClass to append QOS control header in Mac header - * bulkdata if newSkb allocated then bulkdata updated to send to unifi - * interfaceTag the interfaceID on which activity going on - * daddr destination address - * saddr source address - * protection protection bit set in framce control of mac header - * - * Returns: - * Zero on success or error code. - * --------------------------------------------------------------------------- - */ - -int prepare_and_add_macheader(unifi_priv_t *priv, struct sk_buff *skb, struct sk_buff *newSkb, - CSR_PRIORITY priority, - bulk_data_param_t *bulkdata, - u16 interfaceTag, - const u8 *daddr, - const u8 *saddr, - u8 protection) -{ - u16 fc = 0; - u8 qc = 0; - u8 macHeaderLengthInBytes = MAC_HEADER_SIZE, *bufPtr = NULL; - bulk_data_param_t data_ptrs; - CsrResult csrResult; - int headroom =0; - u8 direction = 0; - netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag]; - u8 *addressOne; - u8 bQosNull = false; - - if (skb == NULL) { - unifi_error(priv, "prepare_and_add_macheader: Invalid SKB reference\n"); - return -1; - } - - /* add a MAC header refer: 7.1.3.1 Frame Control field in P802.11REVmb.book */ - if (priority != CSR_CONTENTION) { - /* EAPOL packets don't go as QOS_DATA */ - if (priority == CSR_MANAGEMENT) { - fc |= cpu_to_le16(IEEE802_11_FC_TYPE_DATA); - } else { - /* Qos Control Field */ - macHeaderLengthInBytes += QOS_CONTROL_HEADER_SIZE; - - if (skb->len) { - - fc |= cpu_to_le16(IEEE802_11_FC_TYPE_QOS_DATA); - } else { - fc |= cpu_to_le16(IEEE802_11_FC_TYPE_QOS_NULL); - bQosNull = true; - } - } - } else { - if(skb->len == 0) { - fc |= cpu_to_le16(IEEE802_11_FC_TYPE_NULL); - } else { - fc |= cpu_to_le16(IEEE802_11_FC_TYPE_DATA); - } - } - - switch (interfacePriv->interfaceMode) - { - case CSR_WIFI_ROUTER_CTRL_MODE_STA: - case CSR_WIFI_ROUTER_CTRL_MODE_P2PCLI: - direction = 2; - fc |= cpu_to_le16(IEEE802_11_FC_TO_DS_MASK); - break; - case CSR_WIFI_ROUTER_CTRL_MODE_IBSS: - direction = 0; - break; - case CSR_WIFI_ROUTER_CTRL_MODE_AP: - case CSR_WIFI_ROUTER_CTRL_MODE_P2PGO: - direction = 1; - fc |= cpu_to_le16(IEEE802_11_FC_FROM_DS_MASK); - break; - case CSR_WIFI_ROUTER_CTRL_MODE_AMP: - if (priority == CSR_MANAGEMENT ) { - - direction = 2; - fc |= cpu_to_le16(IEEE802_11_FC_TO_DS_MASK); - } else { - /* Data frames have to use WDS 4 address frames */ - direction = 3; - fc |= cpu_to_le16(IEEE802_11_FC_TO_DS_MASK | IEEE802_11_FC_FROM_DS_MASK); - macHeaderLengthInBytes += 6; - } - break; - default: - unifi_warning(priv, "prepare_and_add_macheader: Unknown mode %d\n", - interfacePriv->interfaceMode); - } - - - /* If Sta is QOS & HTC is supported then need to set 'order' bit */ - /* We don't support HT Control for now */ - - if(protection) { - fc |= cpu_to_le16(IEEE802_11_FC_PROTECTED_MASK); - } - - /* check the skb headroom before pushing mac header */ - headroom = skb_headroom(skb); - - if (headroom < macHeaderLengthInBytes) { - unifi_trace(priv, UDBG5, - "prepare_and_add_macheader: Allocate headroom extra %d bytes\n", - macHeaderLengthInBytes); - - csrResult = unifi_net_data_malloc(priv, &data_ptrs.d[0], skb->len + macHeaderLengthInBytes); - - if (csrResult != CSR_RESULT_SUCCESS) { - unifi_error(priv, " failed to allocate request_data. in %s func\n", __FUNCTION__); - return -1; - } - newSkb = (struct sk_buff *)(data_ptrs.d[0].os_net_buf_ptr); - newSkb->len = skb->len + macHeaderLengthInBytes; - - memcpy((void*)data_ptrs.d[0].os_data_ptr + macHeaderLengthInBytes, - skb->data, skb->len); - - bulkdata->d[0].os_data_ptr = newSkb->data; - bulkdata->d[0].os_net_buf_ptr = (unsigned char*)newSkb; - bulkdata->d[0].data_length = newSkb->len; - - bufPtr = (u8*)data_ptrs.d[0].os_data_ptr; - - /* The old skb will not be used again */ - kfree_skb(skb); - } else { - - /* headroom has sufficient size, so will get proper pointer */ - bufPtr = (u8*)skb_push(skb, macHeaderLengthInBytes); - bulkdata->d[0].os_data_ptr = skb->data; - bulkdata->d[0].os_net_buf_ptr = (unsigned char*)skb; - bulkdata->d[0].data_length = skb->len; - } - - /* Frame the actual MAC header */ - - memset(bufPtr, 0, macHeaderLengthInBytes); - - /* copy frameControl field */ - memcpy(bufPtr, &fc, sizeof(fc)); - bufPtr += sizeof(fc); - macHeaderLengthInBytes -= sizeof(fc); - - /* Duration/ID field which is 2 bytes */ - bufPtr += 2; - macHeaderLengthInBytes -= 2; - - switch(direction) - { - case 0: - /* Its an Ad-Hoc no need to route it through AP */ - /* Address1: MAC address of the destination from eth header */ - memcpy(bufPtr, daddr, ETH_ALEN); - bufPtr += ETH_ALEN; - macHeaderLengthInBytes -= ETH_ALEN; - - /* Address2: MAC address of the source */ - memcpy(bufPtr, saddr, ETH_ALEN); - bufPtr += ETH_ALEN; - macHeaderLengthInBytes -= ETH_ALEN; - - /* Address3: the BSSID (locally generated in AdHoc (creators Bssid)) */ - memcpy(bufPtr, &interfacePriv->bssid, ETH_ALEN); - bufPtr += ETH_ALEN; - macHeaderLengthInBytes -= ETH_ALEN; - break; - case 1: - /* Address1: MAC address of the actual destination */ - memcpy(bufPtr, daddr, ETH_ALEN); - bufPtr += ETH_ALEN; - macHeaderLengthInBytes -= ETH_ALEN; - /* Address2: The MAC address of the AP */ - memcpy(bufPtr, &interfacePriv->bssid, ETH_ALEN); - bufPtr += ETH_ALEN; - macHeaderLengthInBytes -= ETH_ALEN; - - /* Address3: MAC address of the source from eth header */ - memcpy(bufPtr, saddr, ETH_ALEN); - bufPtr += ETH_ALEN; - macHeaderLengthInBytes -= ETH_ALEN; - break; - case 2: - /* Address1: To AP is the MAC address of the AP to which its associated */ - memcpy(bufPtr, &interfacePriv->bssid, ETH_ALEN); - bufPtr += ETH_ALEN; - macHeaderLengthInBytes -= ETH_ALEN; - - /* Address2: MAC address of the source from eth header */ - memcpy(bufPtr, saddr, ETH_ALEN); - bufPtr += ETH_ALEN; - macHeaderLengthInBytes -= ETH_ALEN; - - /* Address3: MAC address of the actual destination on the distribution system */ - memcpy(bufPtr, daddr, ETH_ALEN); - bufPtr += ETH_ALEN; - macHeaderLengthInBytes -= ETH_ALEN; - break; - case 3: - memcpy(bufPtr, &interfacePriv->bssid, ETH_ALEN); - bufPtr += ETH_ALEN; - macHeaderLengthInBytes -= ETH_ALEN; - - /* Address2: MAC address of the source from eth header */ - memcpy(bufPtr, saddr, ETH_ALEN); - bufPtr += ETH_ALEN; - macHeaderLengthInBytes -= ETH_ALEN; - - /* Address3: MAC address of the actual destination on the distribution system */ - memcpy(bufPtr, daddr, ETH_ALEN); - bufPtr += ETH_ALEN; - macHeaderLengthInBytes -= ETH_ALEN; - break; - default: - unifi_error(priv, "Unknown direction =%d : Not handled now\n", direction); - return -1; - } - /* 2 bytes of frame control field, appended by firmware */ - bufPtr += 2; - macHeaderLengthInBytes -= 2; - - if (3 == direction) { - /* Address4: MAC address of the source */ - memcpy(bufPtr, saddr, ETH_ALEN); - bufPtr += ETH_ALEN; - macHeaderLengthInBytes -= ETH_ALEN; - } - - /* IF Qos Data or Qos Null Data then set QosControl field */ - if ((priority != CSR_CONTENTION) && (macHeaderLengthInBytes >= QOS_CONTROL_HEADER_SIZE)) { - - if (priority > 7) { - unifi_trace(priv, UDBG1, "data packets priority is more than 7, priority = %x\n", priority); - qc |= 7; - } else { - qc |= priority; - } - /*assigning address1 - * Address1 offset taken fromm bufPtr(currently bufPtr pointing to Qos contorl) variable in reverse direction - * Address4 don't exit - */ - - addressOne = bufPtr- ADDRESS_ONE_OFFSET; - - if (addressOne[0] & 0x1) { - /* multicast/broadcast frames, no acknowledgement needed */ - qc |= 1 << 5; - } - /* non-AP mode only for now */ - if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_STA || - interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_IBSS || - interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PCLI) { - /* In case of STA and IBSS case eosp and txop limit is 0. */ - } else { - if(bQosNull) { - qc |= 1 << 4; - } - } - - /* append Qos control field to mac header */ - bufPtr[0] = qc; - /* txop limit is 0 */ - bufPtr[1] = 0; - macHeaderLengthInBytes -= QOS_CONTROL_HEADER_SIZE; - } - if (macHeaderLengthInBytes) { - unifi_warning(priv, " Mac header not appended properly\n"); - return -1; - } - return 0; -} - -/* - * --------------------------------------------------------------------------- - * send_ma_pkt_request - * - * These functions send a data packet to UniFi for transmission. - * EAP protocol packets are also sent as send_ma_pkt_request(). - * - * Arguments: - * priv Pointer to device private context struct - * skb Socket buffer containing data packet to transmit - * ehdr Pointer to Ethernet header within skb. - * - * Returns: - * Zero on success or error code. - * --------------------------------------------------------------------------- - */ - -static int -send_ma_pkt_request(unifi_priv_t *priv, struct sk_buff *skb, const struct ethhdr *ehdr, CSR_PRIORITY priority) -{ - int r; - u16 i; - u8 eapolStore = FALSE; - struct sk_buff *newSkb = NULL; - bulk_data_param_t bulkdata; - const int proto = ntohs(ehdr->h_proto); - u16 interfaceTag; - CsrWifiMacAddress peerAddress; - CSR_TRANSMISSION_CONTROL transmissionControl = CSR_NO_CONFIRM_REQUIRED; - s8 protection; - netInterface_priv_t *interfacePriv = NULL; - CSR_RATE TransmitRate = (CSR_RATE)0; - - unifi_trace(priv, UDBG5, "entering send_ma_pkt_request\n"); - - /* Get the interface Tag by means of source Mac address */ - for (i = 0; i < CSR_WIFI_NUM_INTERFACES; i++) { - if (!memcmp(priv->netdev[i]->dev_addr, ehdr->h_source, ETH_ALEN)) { - interfaceTag = i; - interfacePriv = priv->interfacePriv[interfaceTag]; - break; - } - } - - if (interfacePriv == NULL) { - /* No match found - error */ - interfaceTag = 0; - interfacePriv = priv->interfacePriv[interfaceTag]; - unifi_warning(priv, "Mac address not matching ... debugging needed\n"); - interfacePriv->stats.tx_dropped++; - kfree_skb(skb); - return -1; - } - - /* Add a SNAP header if necessary */ - if (skb_add_llc_snap(priv->netdev[interfaceTag], skb, proto) != 0) { - /* convert failed */ - unifi_error(priv, "skb_add_llc_snap failed.\n"); - kfree_skb(skb); - return -1; - } - - bulkdata.d[0].os_data_ptr = skb->data; - bulkdata.d[0].os_net_buf_ptr = (unsigned char*)skb; - bulkdata.d[0].net_buf_length = bulkdata.d[0].data_length = skb->len; - bulkdata.d[1].os_data_ptr = NULL; - bulkdata.d[1].os_net_buf_ptr = NULL; - bulkdata.d[1].net_buf_length = bulkdata.d[1].data_length = 0; - -#ifdef CSR_SUPPORT_SME - /* Notify the TA module for the Tx frame for non AP/P2PGO mode*/ - if ((interfacePriv->interfaceMode != CSR_WIFI_ROUTER_CTRL_MODE_AP) && - (interfacePriv->interfaceMode != CSR_WIFI_ROUTER_CTRL_MODE_P2PGO)) { - unifi_ta_sample(priv->card, CSR_WIFI_ROUTER_CTRL_PROTOCOL_DIRECTION_TX, - &bulkdata.d[0], ehdr->h_source, - priv->netdev[interfaceTag]->dev_addr, - jiffies_to_msecs(jiffies), - 0); /* rate is unknown on tx */ - } -#endif /* CSR_SUPPORT_SME */ - - if ((proto == ETH_P_PAE) -#ifdef CSR_WIFI_SECURITY_WAPI_ENABLE - || (proto == ETH_P_WAI) -#endif - ) - { - /* check for m4 detection */ - if (0 == uf_verify_m4(priv, bulkdata.d[0].os_data_ptr, bulkdata.d[0].data_length)) { - eapolStore = TRUE; - } - } - -#ifdef CSR_WIFI_SECURITY_WAPI_ENABLE - if (proto == ETH_P_WAI) - { - protection = 0; /*WAI packets always sent unencrypted*/ - } - else - { -#endif -#ifdef CSR_SUPPORT_SME - if ((protection = uf_get_protection_bit_from_interfacemode(priv, interfaceTag, ehdr->h_dest)) < 0) { - unifi_warning(priv, "unicast address, but destination not in station record database\n"); - unifi_net_data_free(priv, &bulkdata.d[0]); - return -1; - } -#else - protection = 0; -#endif -#ifdef CSR_WIFI_SECURITY_WAPI_ENABLE - } -#endif - - /* append Mac header for Eapol as well as data packet */ - if (prepare_and_add_macheader(priv, skb, newSkb, priority, &bulkdata, interfaceTag, ehdr->h_dest, ehdr->h_source, protection)) { - unifi_error(priv, "failed to create MAC header\n"); - unifi_net_data_free(priv, &bulkdata.d[0]); - return -1; - } - - /* RA address must contain the immediate destination MAC address that is similar to - * the Address 1 field of 802.11 Mac header here 4 is: (sizeof(framecontrol) + sizeof (durationID)) - * which is address 1 field - */ - memcpy(peerAddress.a, ((u8 *) bulkdata.d[0].os_data_ptr) + 4, ETH_ALEN); - - unifi_trace(priv, UDBG5, "RA[0]=%x, RA[1]=%x, RA[2]=%x, RA[3]=%x, RA[4]=%x, RA[5]=%x\n", - peerAddress.a[0], peerAddress.a[1], peerAddress.a[2], peerAddress.a[3], - peerAddress.a[4], peerAddress.a[5]); - - - if ((proto == ETH_P_PAE) -#ifdef CSR_WIFI_SECURITY_WAPI_ENABLE - || (proto == ETH_P_WAI) -#endif - ) - { - CSR_SIGNAL signal; - CSR_MA_PACKET_REQUEST *req = &signal.u.MaPacketRequest; - - /* initialize signal to zero */ - memset(&signal, 0, sizeof(CSR_SIGNAL)); - - /* Frame MA_PACKET request */ - signal.SignalPrimitiveHeader.SignalId = CSR_MA_PACKET_REQUEST_ID; - signal.SignalPrimitiveHeader.ReceiverProcessId = 0; - signal.SignalPrimitiveHeader.SenderProcessId = priv->netdev_client->sender_id; - - transmissionControl = req->TransmissionControl = 0; -#ifdef CSR_SUPPORT_SME - if (eapolStore) - { - netInterface_priv_t *netpriv = (netInterface_priv_t *)netdev_priv(priv->netdev[interfaceTag]); - - /* Fill the MA-PACKET.req */ - - req->Priority = priority; - unifi_trace(priv, UDBG3, "Tx Frame with Priority: %x\n", req->Priority); - - /* rate selected by firmware */ - req->TransmitRate = 0; - req->HostTag = CSR_WIFI_EAPOL_M4_HOST_TAG; - /* RA address matching with address 1 of Mac header */ - memcpy(req->Ra.x, ((u8 *) bulkdata.d[0].os_data_ptr) + 4, ETH_ALEN); - - spin_lock(&priv->m4_lock); - /* Store the M4-PACKET.req for later */ - interfacePriv->m4_signal = signal; - interfacePriv->m4_bulk_data.net_buf_length = bulkdata.d[0].net_buf_length; - interfacePriv->m4_bulk_data.data_length = bulkdata.d[0].data_length; - interfacePriv->m4_bulk_data.os_data_ptr = bulkdata.d[0].os_data_ptr; - interfacePriv->m4_bulk_data.os_net_buf_ptr = bulkdata.d[0].os_net_buf_ptr; - spin_unlock(&priv->m4_lock); - - /* Signal the workqueue to call CsrWifiRouterCtrlM4ReadyToSendIndSend(). - * It cannot be called directly from the tx path because it - * does a non-atomic kmalloc via the framework's CsrPmemAlloc(). - */ - queue_work(priv->unifi_workqueue, &netpriv->send_m4_ready_task); - - return 0; - } -#endif - }/*EAPOL or WAI packet*/ - -#if (defined(CSR_WIFI_SECURITY_WAPI_ENABLE) && defined(CSR_WIFI_SECURITY_WAPI_SW_ENCRYPTION)) - if ((CSR_WIFI_ROUTER_CTRL_MODE_STA == interfacePriv->interfaceMode) && \ - (priv->wapi_unicast_filter) && \ - (proto != ETH_P_PAE) && \ - (proto != ETH_P_WAI) && \ - (skb->len > 0)) - { - CSR_SIGNAL signal; - CSR_MA_PACKET_REQUEST *req = &signal.u.MaPacketRequest; - netInterface_priv_t *netpriv = (netInterface_priv_t *)netdev_priv(priv->netdev[interfaceTag]); - - unifi_trace(priv, UDBG4, "send_ma_pkt_request() - WAPI unicast data packet when USKID = 1 \n"); - - /* initialize signal to zero */ - memset(&signal, 0, sizeof(CSR_SIGNAL)); - /* Frame MA_PACKET request */ - signal.SignalPrimitiveHeader.SignalId = CSR_MA_PACKET_REQUEST_ID; - signal.SignalPrimitiveHeader.ReceiverProcessId = 0; - signal.SignalPrimitiveHeader.SenderProcessId = priv->netdev_client->sender_id; - - /* Fill the MA-PACKET.req */ - req->TransmissionControl = 0; - req->Priority = priority; - unifi_trace(priv, UDBG3, "Tx Frame with Priority: %x\n", req->Priority); - req->TransmitRate = (CSR_RATE) 0; /* rate selected by firmware */ - req->HostTag = 0xffffffff; /* Ask for a new HostTag */ - /* RA address matching with address 1 of Mac header */ - memcpy(req->Ra.x, ((u8 *) bulkdata.d[0].os_data_ptr) + 4, ETH_ALEN); - - /* Store the M4-PACKET.req for later */ - spin_lock(&priv->wapi_lock); - interfacePriv->wapi_unicast_ma_pkt_sig = signal; - interfacePriv->wapi_unicast_bulk_data.net_buf_length = bulkdata.d[0].net_buf_length; - interfacePriv->wapi_unicast_bulk_data.data_length = bulkdata.d[0].data_length; - interfacePriv->wapi_unicast_bulk_data.os_data_ptr = bulkdata.d[0].os_data_ptr; - interfacePriv->wapi_unicast_bulk_data.os_net_buf_ptr = bulkdata.d[0].os_net_buf_ptr; - spin_unlock(&priv->wapi_lock); - - /* Signal the workqueue to call CsrWifiRouterCtrlWapiUnicastTxEncryptIndSend(). - * It cannot be called directly from the tx path because it - * does a non-atomic kmalloc via the framework's CsrPmemAlloc(). - */ - queue_work(priv->unifi_workqueue, &netpriv->send_pkt_to_encrypt); - - return 0; - } -#endif - - if(priv->cmanrTestMode) - { - TransmitRate = priv->cmanrTestModeTransmitRate; - unifi_trace(priv, UDBG2, "send_ma_pkt_request: cmanrTestModeTransmitRate = %d TransmitRate=%d\n", - priv->cmanrTestModeTransmitRate, - TransmitRate - ); - } - - /* Send UniFi msg */ - /* Here hostTag is been sent as 0xffffffff, its been appended properly while framing MA-Packet request in pdu_processing.c file */ - r = uf_process_ma_packet_req(priv, - peerAddress.a, - 0xffffffff, /* Ask for a new HostTag */ - interfaceTag, - transmissionControl, - TransmitRate, - priority, - priv->netdev_client->sender_id, - &bulkdata); - - if (r) { - unifi_trace(priv, UDBG1, "(HIP validation failure) r = %x\n", r); - unifi_net_data_free(priv, &bulkdata.d[0]); - return -1; - } - - unifi_trace(priv, UDBG3, "leaving send_ma_pkt_request, UNITDATA result code = %d\n", r); - - return r; -} /* send_ma_pkt_request() */ - -/* - * --------------------------------------------------------------------------- - * uf_net_xmit - * - * This function is called by the higher level stack to transmit an - * ethernet packet. - * - * Arguments: - * skb Ethernet packet to send. - * dev Pointer to the linux net device. - * - * Returns: - * 0 on success (packet was consumed, not necessarily transmitted) - * 1 if packet was requeued - * -1 on error - * - * - * Notes: - * The controlled port is handled in the qdisc dequeue handler. - * --------------------------------------------------------------------------- - */ -static netdev_tx_t -uf_net_xmit(struct sk_buff *skb, struct net_device *dev) -{ - netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev); - unifi_priv_t *priv = interfacePriv->privPtr; - struct ethhdr ehdr; - int proto, port; - int result; - static tx_signal_handler tx_handler; - CSR_PRIORITY priority; - CsrWifiRouterCtrlPortAction port_action; - - unifi_trace(priv, UDBG5, "unifi_net_xmit: skb = %x\n", skb); - - memcpy(&ehdr, skb->data, ETH_HLEN); - proto = ntohs(ehdr.h_proto); - priority = get_packet_priority(priv, skb, &ehdr, interfacePriv); - - /* All frames are sent as MA-PACKET.req (EAPOL also) */ - tx_handler = send_ma_pkt_request; - - /* 802.1x - apply controlled/uncontrolled port rules */ - if ((proto != ETH_P_PAE) -#ifdef CSR_WIFI_SECURITY_WAPI_ENABLE - && (proto != ETH_P_WAI) -#endif - ) { - port = UF_CONTROLLED_PORT_Q; - } else { - /* queue 4 */ - port = UF_UNCONTROLLED_PORT_Q; - } - - /* Uncontrolled port rules apply */ - port_action = verify_port(priv - , (((CSR_WIFI_ROUTER_CTRL_MODE_STA == interfacePriv->interfaceMode)||(CSR_WIFI_ROUTER_CTRL_MODE_P2PCLI== interfacePriv->interfaceMode))? interfacePriv->bssid.a: ehdr.h_dest) - , port - , interfacePriv->InterfaceTag); - - if (port_action == CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_OPEN) { - unifi_trace(priv, UDBG5, - "uf_net_xmit: %s controlled port open\n", - port ? "" : "un"); - /* Remove the ethernet header */ - skb_pull(skb, ETH_HLEN); - result = tx_handler(priv, skb, &ehdr, priority); - } else { - - /* Discard the packet if necessary */ - unifi_trace(priv, UDBG2, - "uf_net_xmit: %s controlled port %s\n", - port ? "" : "un", port_action==CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_CLOSED_BLOCK ? "blocked" : "closed"); - interfacePriv->stats.tx_dropped++; - kfree_skb(skb); - - return NETDEV_TX_OK; - } - - if (result == NETDEV_TX_OK) { -#if (defined(CSR_WIFI_SECURITY_WAPI_ENABLE) && defined(CSR_WIFI_SECURITY_WAPI_SW_ENCRYPTION)) - /* Don't update the tx stats when the pkt is to be sent for sw encryption*/ - if (!((CSR_WIFI_ROUTER_CTRL_MODE_STA == interfacePriv->interfaceMode) && - (priv->wapi_unicast_filter == 1))) - { - dev->trans_start = jiffies; - /* Should really count tx stats in the UNITDATA.status signal but - * that doesn't have the length. - */ - interfacePriv->stats.tx_packets++; - /* count only the packet payload */ - interfacePriv->stats.tx_bytes += skb->len; - - } -#else - dev->trans_start = jiffies; - - /* - * Should really count tx stats in the UNITDATA.status signal but - * that doesn't have the length. - */ - interfacePriv->stats.tx_packets++; - /* count only the packet payload */ - interfacePriv->stats.tx_bytes += skb->len; -#endif - } else if (result < 0) { - - /* Failed to send: fh queue was full, and the skb was discarded. - * Return OK to indicate that the buffer was consumed, to stop the - * kernel re-transmitting the freed buffer. - */ - interfacePriv->stats.tx_dropped++; - unifi_trace(priv, UDBG1, "unifi_net_xmit: (Packet Drop), dropped count = %x\n", interfacePriv->stats.tx_dropped); - result = NETDEV_TX_OK; - } - - /* The skb will have been freed by send_XXX_request() */ - - return result; -} /* uf_net_xmit() */ - -/* - * --------------------------------------------------------------------------- - * unifi_pause_xmit - * unifi_restart_xmit - * - * These functions are called from the UniFi core to control the flow - * of packets from the upper layers. - * unifi_pause_xmit() is called when the internal queue is full and - * should take action to stop unifi_ma_unitdata() being called. - * When the queue has drained, unifi_restart_xmit() will be called to - * re-enable the flow of packets for transmission. - * - * Arguments: - * ospriv OS private context pointer. - * - * Returns: - * unifi_pause_xmit() is called from interrupt context. - * --------------------------------------------------------------------------- - */ -void -unifi_pause_xmit(void *ospriv, unifi_TrafficQueue queue) -{ - unifi_priv_t *priv = ospriv; - int i; /* used as a loop counter */ - - unifi_trace(priv, UDBG2, "Stopping queue %d\n", queue); - - for(i=0;inetdev[i])) - { - netif_stop_subqueue(priv->netdev[i], (u16)queue); - } - } - -#ifdef CSR_SUPPORT_SME - if(queue<=3) { - routerStartBuffering(priv, queue); - unifi_trace(priv, UDBG2, "Start buffering %d\n", queue); - } else { - routerStartBuffering(priv, 0); - unifi_error(priv, "Start buffering %d defaulting to 0\n", queue); - } -#endif - -} /* unifi_pause_xmit() */ - -void -unifi_restart_xmit(void *ospriv, unifi_TrafficQueue queue) -{ - unifi_priv_t *priv = ospriv; - int i=0; /* used as a loop counter */ - - unifi_trace(priv, UDBG2, "Waking queue %d\n", queue); - - for(i=0;inetdev[i])) - { - netif_wake_subqueue(priv->netdev[i], (u16)queue); - } - } - -#ifdef CSR_SUPPORT_SME - if(queue <=3) { - routerStopBuffering(priv, queue); - uf_send_buffered_frames(priv, queue); - } else { - routerStopBuffering(priv, 0); - uf_send_buffered_frames(priv, 0); - } -#endif -} /* unifi_restart_xmit() */ - - -static void -indicate_rx_skb(unifi_priv_t *priv, u16 ifTag, u8* dst_a, u8* src_a, struct sk_buff *skb, CSR_SIGNAL *signal, - bulk_data_param_t *bulkdata) -{ - int r, sr = 0; - struct net_device *dev; - -#ifdef CSR_SUPPORT_SME - llc_snap_hdr_t *snap; - - snap = (llc_snap_hdr_t *)skb->data; - - sr = _identify_sme_ma_pkt_ind(priv, - snap->oui, ntohs(snap->protocol), - signal, - bulkdata, - dst_a, src_a ); -#endif - - /* - * Decapsulate any SNAP header and - * prepend an ethernet header so that the skb manipulation and ARP - * stuff works. - */ - r = skb_80211_to_ether(priv, skb, dst_a, src_a, - signal, bulkdata); - if (r == -1) { - /* Drop the packet and return */ - priv->interfacePriv[ifTag]->stats.rx_errors++; - priv->interfacePriv[ifTag]->stats.rx_frame_errors++; - unifi_net_data_free(priv, &bulkdata->d[0]); - unifi_notice(priv, "indicate_rx_skb: Discard unknown frame.\n"); - return; - } - - /* Handle the case where packet is sent up through the subscription - * API but should not be given to the network stack (AMP PAL case) - * LLC header is different from WiFi and the packet has been subscribed for - */ - if (r == 1 && sr == 1) { - unifi_net_data_free(priv, &bulkdata->d[0]); - unifi_trace(priv, UDBG5, "indicate_rx_skb: Data given to subscription" - "API, not being given to kernel\n"); - return; - } - - dev = priv->netdev[ifTag]; - /* Now we look like a regular ethernet frame */ - /* Fill in SKB meta data */ - skb->dev = dev; - skb->protocol = eth_type_trans(skb, dev); - skb->ip_summed = CHECKSUM_UNNECESSARY; - - /* Test for an overlength frame */ - if (skb->len > (dev->mtu + ETH_HLEN)) { - /* A bogus length ethfrm has been encap'd. */ - /* Is someone trying an oflow attack? */ - unifi_error(priv, "%s: oversize frame (%d > %d)\n", - dev->name, - skb->len, dev->mtu + ETH_HLEN); - - /* Drop the packet and return */ - priv->interfacePriv[ifTag]->stats.rx_errors++; - priv->interfacePriv[ifTag]->stats.rx_length_errors++; - unifi_net_data_free(priv, &bulkdata->d[0]); - return; - } - - - if(priv->cmanrTestMode) - { - const CSR_MA_PACKET_INDICATION *pkt_ind = &signal->u.MaPacketIndication; - priv->cmanrTestModeTransmitRate = pkt_ind->ReceivedRate; - unifi_trace(priv, UDBG2, "indicate_rx_skb: cmanrTestModeTransmitRate=%d\n", priv->cmanrTestModeTransmitRate); - } - - /* Pass SKB up the stack */ -#ifdef CSR_WIFI_USE_NETIF_RX - netif_rx(skb); -#else - netif_rx_ni(skb); -#endif - - if (dev != NULL) { - dev->last_rx = jiffies; - } - - /* Bump rx stats */ - priv->interfacePriv[ifTag]->stats.rx_packets++; - priv->interfacePriv[ifTag]->stats.rx_bytes += bulkdata->d[0].data_length; - - return; -} - -void -uf_process_rx_pending_queue(unifi_priv_t *priv, int queue, - CsrWifiMacAddress source_address, - int indicate, u16 interfaceTag) -{ - rx_buffered_packets_t *rx_q_item; - struct list_head *rx_list; - struct list_head *n; - struct list_head *l_h; - static const CsrWifiMacAddress broadcast_address = {{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}}; - netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag]; - - if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) { - unifi_error(priv, "uf_process_rx_pending_queue bad interfaceTag\n"); - return; - } - - if (queue == UF_CONTROLLED_PORT_Q) { - rx_list = &interfacePriv->rx_controlled_list; - } else { - rx_list = &interfacePriv->rx_uncontrolled_list; - } - - down(&priv->rx_q_sem); - list_for_each_safe(l_h, n, rx_list) { - rx_q_item = list_entry(l_h, rx_buffered_packets_t, q); - - /* Validate against the source address */ - if (memcmp(broadcast_address.a, source_address.a, ETH_ALEN) && - memcmp(rx_q_item->sa.a, source_address.a, ETH_ALEN)) { - - unifi_trace(priv, UDBG2, - "uf_process_rx_pending_queue: Skipping sa=%02X%02X%02X%02X%02X%02X skb=%p, bulkdata=%p\n", - rx_q_item->sa.a[0], rx_q_item->sa.a[1], - rx_q_item->sa.a[2], rx_q_item->sa.a[3], - rx_q_item->sa.a[4], rx_q_item->sa.a[5], - rx_q_item->skb, &rx_q_item->bulkdata.d[0]); - continue; - } - - list_del(l_h); - - - unifi_trace(priv, UDBG2, - "uf_process_rx_pending_queue: Was Blocked skb=%p, bulkdata=%p\n", - rx_q_item->skb, &rx_q_item->bulkdata); - - if (indicate) { - indicate_rx_skb(priv, interfaceTag, rx_q_item->da.a, rx_q_item->sa.a, rx_q_item->skb, &rx_q_item->signal, &rx_q_item->bulkdata); - } else { - interfacePriv->stats.rx_dropped++; - unifi_net_data_free(priv, &rx_q_item->bulkdata.d[0]); - } - - /* It is our resposibility to free the Rx structure object. */ - kfree(rx_q_item); - } - up(&priv->rx_q_sem); -} - -/* - * --------------------------------------------------------------------------- - * uf_resume_data_plane - * - * Is called when the (un)controlled port is set to open, - * to notify the network stack to schedule for transmission - * any packets queued in the qdisk while port was closed and - * indicated to the stack any packets buffered in the Rx queues. - * - * Arguments: - * priv Pointer to device private struct - * - * Returns: - * --------------------------------------------------------------------------- - */ -void -uf_resume_data_plane(unifi_priv_t *priv, int queue, - CsrWifiMacAddress peer_address, - u16 interfaceTag) -{ -#ifdef CSR_SUPPORT_WEXT - netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag]; -#endif - - if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) { - unifi_error(priv, "uf_resume_data_plane bad interfaceTag\n"); - return; - } - - unifi_trace(priv, UDBG2, "Resuming netif\n"); - - /* - * If we are waiting for the net device to enter the up state, don't - * process the rx queue yet as it will be done by the callback when - * the device is ready. - */ -#ifdef CSR_SUPPORT_WEXT - if (!interfacePriv->wait_netdev_change) -#endif - { -#ifdef CONFIG_NET_SCHED - if (netif_running(priv->netdev[interfaceTag])) { - netif_tx_schedule_all(priv->netdev[interfaceTag]); - } -#endif - uf_process_rx_pending_queue(priv, queue, peer_address, 1, interfaceTag); - } -} /* uf_resume_data_plane() */ - - -void uf_free_pending_rx_packets(unifi_priv_t *priv, int queue, CsrWifiMacAddress peer_address, u16 interfaceTag) -{ - uf_process_rx_pending_queue(priv, queue, peer_address, 0, interfaceTag); - -} /* uf_free_pending_rx_packets() */ - - -/* - * --------------------------------------------------------------------------- - * unifi_rx - * - * Reformat a UniFi data received packet into a p80211 packet and - * pass it up the protocol stack. - * - * Arguments: - * None. - * - * Returns: - * None. - * --------------------------------------------------------------------------- - */ -static void -unifi_rx(unifi_priv_t *priv, CSR_SIGNAL *signal, bulk_data_param_t *bulkdata) -{ - u16 interfaceTag; - bulk_data_desc_t *pData; - const CSR_MA_PACKET_INDICATION *pkt_ind = &signal->u.MaPacketIndication; - struct sk_buff *skb; - CsrWifiRouterCtrlPortAction port_action; - u8 dataFrameType; - int proto; - int queue; - - u8 da[ETH_ALEN], sa[ETH_ALEN]; - u8 toDs, fromDs, frameType, macHeaderLengthInBytes = MAC_HEADER_SIZE; - u16 frameControl; - netInterface_priv_t *interfacePriv; - struct ethhdr ehdr; - - interfaceTag = (pkt_ind->VirtualInterfaceIdentifier & 0xff); - interfacePriv = priv->interfacePriv[interfaceTag]; - - /* Sanity check that the VIF refers to a sensible interface */ - if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) - { - unifi_error(priv, "%s: MA-PACKET indication with bad interfaceTag %d\n", __FUNCTION__, interfaceTag); - unifi_net_data_free(priv, &bulkdata->d[0]); - return; - } - - /* Sanity check that the VIF refers to an allocated netdev */ - if (!interfacePriv->netdev_registered) - { - unifi_error(priv, "%s: MA-PACKET indication with unallocated interfaceTag %d\n", __FUNCTION__, interfaceTag); - unifi_net_data_free(priv, &bulkdata->d[0]); - return; - } - - if (bulkdata->d[0].data_length == 0) { - unifi_warning(priv, "%s: MA-PACKET indication with zero bulk data\n", __FUNCTION__); - unifi_net_data_free(priv, &bulkdata->d[0]); - return; - } - - - skb = (struct sk_buff*)bulkdata->d[0].os_net_buf_ptr; - skb->len = bulkdata->d[0].data_length; - - /* Point to the addresses */ - toDs = (skb->data[1] & 0x01) ? 1 : 0; - fromDs = (skb->data[1] & 0x02) ? 1 : 0; - - memcpy(da, (skb->data+4+toDs*12), ETH_ALEN);/* Address1 or 3 */ - memcpy(sa, (skb->data+10+fromDs*(6+toDs*8)), ETH_ALEN); /* Address2, 3 or 4 */ - - - pData = &bulkdata->d[0]; - frameControl = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(pData->os_data_ptr); - frameType = ((frameControl & 0x000C) >> 2); - - dataFrameType =((frameControl & 0x00f0) >> 4); - unifi_trace(priv, UDBG6, - "%s: Receive Data Frame Type %d \n", __FUNCTION__, dataFrameType); - - switch(dataFrameType) - { - case QOS_DATA: - case QOS_DATA_NULL: - /* If both are set then the Address4 exists (only for AP) */ - if (fromDs && toDs) - { - /* 6 is the size of Address4 field */ - macHeaderLengthInBytes += (QOS_CONTROL_HEADER_SIZE + 6); - } - else - { - macHeaderLengthInBytes += QOS_CONTROL_HEADER_SIZE; - } - - /* If order bit set then HT control field is the part of MAC header */ - if (frameControl & FRAME_CONTROL_ORDER_BIT) - macHeaderLengthInBytes += HT_CONTROL_HEADER_SIZE; - break; - default: - if (fromDs && toDs) - macHeaderLengthInBytes += 6; - } - - /* Prepare the ethernet header from snap header of skb data */ - switch(dataFrameType) - { - case DATA_NULL: - case QOS_DATA_NULL: - /* This is for only queue info fetching, EAPOL wont come as - * null data so the proto is initialized as zero - */ - proto = 0x0; - break; - default: - { - llc_snap_hdr_t *snap; - /* Fetch a snap header to find protocol (for IPV4/IPV6 packets - * the snap header fetching offset is same) - */ - snap = (llc_snap_hdr_t *) (skb->data + macHeaderLengthInBytes); - - /* prepare the ethernet header from the snap header & addresses */ - ehdr.h_proto = snap->protocol; - memcpy(ehdr.h_dest, da, ETH_ALEN); - memcpy(ehdr.h_source, sa, ETH_ALEN); - } - proto = ntohs(ehdr.h_proto); - } - unifi_trace(priv, UDBG3, "in unifi_rx protocol from snap header = 0x%x\n", proto); - - if ((proto != ETH_P_PAE) -#ifdef CSR_WIFI_SECURITY_WAPI_ENABLE - && (proto != ETH_P_WAI) -#endif - ) { - queue = UF_CONTROLLED_PORT_Q; - } else { - queue = UF_UNCONTROLLED_PORT_Q; - } - - port_action = verify_port(priv, (unsigned char*)sa, queue, interfaceTag); - unifi_trace(priv, UDBG3, "in unifi_rx port action is = 0x%x & queue = %x\n", port_action, queue); - -#ifdef CSR_SUPPORT_SME - /* Notify the TA module for the Rx frame for non P2PGO and AP cases*/ - if((interfacePriv->interfaceMode != CSR_WIFI_ROUTER_CTRL_MODE_AP) && - (interfacePriv->interfaceMode != CSR_WIFI_ROUTER_CTRL_MODE_P2PGO)) - { - /* Remove MAC header of length(macHeaderLengthInBytes) before sampling */ - skb_pull(skb, macHeaderLengthInBytes); - pData->os_data_ptr = skb->data; - pData->data_length -= macHeaderLengthInBytes; - - if (pData->data_length) { - unifi_ta_sample(priv->card, CSR_WIFI_ROUTER_CTRL_PROTOCOL_DIRECTION_RX, - &bulkdata->d[0], - sa, priv->netdev[interfaceTag]->dev_addr, - jiffies_to_msecs(jiffies), - pkt_ind->ReceivedRate); - } - } else { - - /* AP/P2PGO specific handling here */ - CsrWifiRouterCtrlStaInfo_t * srcStaInfo = - CsrWifiRouterCtrlGetStationRecordFromPeerMacAddress(priv, sa, interfaceTag); - - /* Defensive check only; Source address is already checked in - process_ma_packet_ind and we should have a valid source address here */ - - if(srcStaInfo == NULL) { - CsrWifiMacAddress peerMacAddress; - /* Unknown data PDU */ - memcpy(peerMacAddress.a, sa, ETH_ALEN); - unifi_trace(priv, UDBG1, "%s: Unexpected frame from peer = %x:%x:%x:%x:%x:%x\n", __FUNCTION__, - sa[0], sa[1], sa[2], sa[3], sa[4], sa[5]); - CsrWifiRouterCtrlUnexpectedFrameIndSend(priv->CSR_WIFI_SME_IFACEQUEUE, 0, interfaceTag, peerMacAddress); - unifi_net_data_free(priv, &bulkdata->d[0]); - return; - } - - /* For AP GO mode, don't store the PDUs */ - if (port_action != CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_OPEN) { - /* Drop the packet and return */ - CsrWifiMacAddress peerMacAddress; - memcpy(peerMacAddress.a, sa, ETH_ALEN); - unifi_trace(priv, UDBG3, "%s: Port is not open: unexpected frame from peer = %x:%x:%x:%x:%x:%x\n", - __FUNCTION__, sa[0], sa[1], sa[2], sa[3], sa[4], sa[5]); - - CsrWifiRouterCtrlUnexpectedFrameIndSend(priv->CSR_WIFI_SME_IFACEQUEUE, 0, interfaceTag, peerMacAddress); - interfacePriv->stats.rx_dropped++; - unifi_net_data_free(priv, &bulkdata->d[0]); - unifi_notice(priv, "%s: Dropping packet, proto=0x%04x, %s port\n", __FUNCTION__, - proto, queue ? "Controlled" : "Un-controlled"); - return; - } - - /* Qos NULL/Data NULL are freed here and not processed further */ - if((dataFrameType == QOS_DATA_NULL) || (dataFrameType == DATA_NULL)){ - unifi_trace(priv, UDBG5, "%s: Null Frame Received and Freed\n", __FUNCTION__); - unifi_net_data_free(priv, &bulkdata->d[0]); - return; - } - - /* Now we have done with MAC header so proceed with the real data part*/ - /* This function takes care of appropriate routing for AP/P2PGO case*/ - /* the function hadnles following things - 2. Routing the PDU to appropriate location - 3. Error case handling - */ - if(!(uf_ap_process_data_pdu(priv, skb, &ehdr, srcStaInfo, - signal, - bulkdata, - macHeaderLengthInBytes))) - { - return; - } - unifi_trace(priv, UDBG5, "unifi_rx: no specific AP handling process as normal frame, MAC Header len %d\n", macHeaderLengthInBytes); - /* Remove the MAC header for subsequent conversion */ - skb_pull(skb, macHeaderLengthInBytes); - pData->os_data_ptr = skb->data; - pData->data_length -= macHeaderLengthInBytes; - pData->os_net_buf_ptr = (unsigned char*)skb; - pData->net_buf_length = skb->len; - } -#endif /* CSR_SUPPORT_SME */ - - - /* Now that the MAC header is removed, null-data frames have zero length - * and can be dropped - */ - if (pData->data_length == 0) { - if (((frameControl & 0x00f0) >> 4) != QOS_DATA_NULL && - ((frameControl & 0x00f0) >> 4) != DATA_NULL) { - unifi_trace(priv, UDBG1, "Zero length frame, but not null-data %04x\n", frameControl); - } - unifi_net_data_free(priv, &bulkdata->d[0]); - return; - } - - if (port_action == CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_CLOSED_DISCARD) { - /* Drop the packet and return */ - interfacePriv->stats.rx_dropped++; - unifi_net_data_free(priv, &bulkdata->d[0]); - unifi_notice(priv, "%s: Dropping packet, proto=0x%04x, %s port\n", - __FUNCTION__, proto, queue ? "controlled" : "uncontrolled"); - return; - } else if ( (port_action == CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_CLOSED_BLOCK) || - (interfacePriv->connected != UnifiConnected) ) { - - /* Buffer the packet into the Rx queues */ - rx_buffered_packets_t *rx_q_item; - struct list_head *rx_list; - - rx_q_item = kmalloc(sizeof(rx_buffered_packets_t), - GFP_KERNEL); - if (rx_q_item == NULL) { - unifi_error(priv, "%s: Failed to allocate %d bytes for rx packet record\n", - __FUNCTION__, sizeof(rx_buffered_packets_t)); - interfacePriv->stats.rx_dropped++; - unifi_net_data_free(priv, &bulkdata->d[0]); - return; - } - - INIT_LIST_HEAD(&rx_q_item->q); - rx_q_item->bulkdata = *bulkdata; - rx_q_item->skb = skb; - rx_q_item->signal = *signal; - memcpy(rx_q_item->sa.a, sa, ETH_ALEN); - memcpy(rx_q_item->da.a, da, ETH_ALEN); - unifi_trace(priv, UDBG2, "%s: Blocked skb=%p, bulkdata=%p\n", - __FUNCTION__, rx_q_item->skb, &rx_q_item->bulkdata); - - if (queue == UF_CONTROLLED_PORT_Q) { - rx_list = &interfacePriv->rx_controlled_list; - } else { - rx_list = &interfacePriv->rx_uncontrolled_list; - } - - /* Add to tail of packets queue */ - down(&priv->rx_q_sem); - list_add_tail(&rx_q_item->q, rx_list); - up(&priv->rx_q_sem); - - return; - - } - - indicate_rx_skb(priv, interfaceTag, da, sa, skb, signal, bulkdata); - -} /* unifi_rx() */ - -static void process_ma_packet_cfm(unifi_priv_t *priv, CSR_SIGNAL *signal, bulk_data_param_t *bulkdata) -{ - u16 interfaceTag; - const CSR_MA_PACKET_CONFIRM *pkt_cfm = &signal->u.MaPacketConfirm; - netInterface_priv_t *interfacePriv; - - interfaceTag = (pkt_cfm->VirtualInterfaceIdentifier & 0xff); - interfacePriv = priv->interfacePriv[interfaceTag]; - - /* Sanity check that the VIF refers to a sensible interface */ - if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) - { - unifi_error(priv, "%s: MA-PACKET confirm with bad interfaceTag %d\n", __FUNCTION__, interfaceTag); - return; - } -#ifdef CSR_SUPPORT_SME - if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP || - interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO) { - - uf_process_ma_pkt_cfm_for_ap(priv, interfaceTag, pkt_cfm); - } else if (interfacePriv->m4_sent && (pkt_cfm->HostTag == interfacePriv->m4_hostTag)) { - /* Check if this is a confirm for EAPOL M4 frame and we need to send transmistted ind*/ - CsrResult result = pkt_cfm->TransmissionStatus == CSR_TX_SUCCESSFUL?CSR_RESULT_SUCCESS:CSR_RESULT_FAILURE; - CsrWifiMacAddress peerMacAddress; - memcpy(peerMacAddress.a, interfacePriv->m4_signal.u.MaPacketRequest.Ra.x, ETH_ALEN); - - unifi_trace(priv, UDBG1, "%s: Sending M4 Transmit CFM\n", __FUNCTION__); - CsrWifiRouterCtrlM4TransmittedIndSend(priv->CSR_WIFI_SME_IFACEQUEUE, 0, - interfaceTag, - peerMacAddress, - result); - interfacePriv->m4_sent = FALSE; - interfacePriv->m4_hostTag = 0xffffffff; - } -#endif - return; -} - - -/* - * --------------------------------------------------------------------------- - * unifi_rx - * - * Reformat a UniFi data received packet into a p80211 packet and - * pass it up the protocol stack. - * - * Arguments: - * None. - * - * Returns: - * None. - * --------------------------------------------------------------------------- - */ -static void process_ma_packet_ind(unifi_priv_t *priv, CSR_SIGNAL *signal, bulk_data_param_t *bulkdata) -{ - u16 interfaceTag; - bulk_data_desc_t *pData; - CSR_MA_PACKET_INDICATION *pkt_ind = (CSR_MA_PACKET_INDICATION*)&signal->u.MaPacketIndication; - struct sk_buff *skb; - u16 frameControl; - netInterface_priv_t *interfacePriv; - u8 da[ETH_ALEN], sa[ETH_ALEN]; - u8 *bssid = NULL, *ba_addr = NULL; - u8 toDs, fromDs, frameType; - u8 i =0; - -#ifdef CSR_SUPPORT_SME - u8 dataFrameType = 0; - u8 powerSaveChanged = FALSE; - u8 pmBit = 0; - CsrWifiRouterCtrlStaInfo_t *srcStaInfo = NULL; - u16 qosControl; - -#endif - - interfaceTag = (pkt_ind->VirtualInterfaceIdentifier & 0xff); - interfacePriv = priv->interfacePriv[interfaceTag]; - - - /* Sanity check that the VIF refers to a sensible interface */ - if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) - { - unifi_error(priv, "%s: MA-PACKET indication with bad interfaceTag %d\n", __FUNCTION__, interfaceTag); - unifi_net_data_free(priv, &bulkdata->d[0]); - return; - } - - /* Sanity check that the VIF refers to an allocated netdev */ - if (!interfacePriv->netdev_registered) - { - unifi_error(priv, "%s: MA-PACKET indication with unallocated interfaceTag %d\n", __FUNCTION__, interfaceTag); - unifi_net_data_free(priv, &bulkdata->d[0]); - return; - } - - if (bulkdata->d[0].data_length == 0) { - unifi_warning(priv, "%s: MA-PACKET indication with zero bulk data\n", __FUNCTION__); - unifi_net_data_free(priv, &bulkdata->d[0]); - return; - } - /* For monitor mode we need to pass this indication to the registered application - handle this separately*/ - /* MIC failure is already taken care of so no need to send the PDUs which are not successfully received in non-monitor mode*/ - if(pkt_ind->ReceptionStatus != CSR_RX_SUCCESS) - { - unifi_warning(priv, "%s: MA-PACKET indication with status = %d\n", __FUNCTION__, pkt_ind->ReceptionStatus); - unifi_net_data_free(priv, &bulkdata->d[0]); - return; - } - - - skb = (struct sk_buff*)bulkdata->d[0].os_net_buf_ptr; - skb->len = bulkdata->d[0].data_length; - - /* Point to the addresses */ - toDs = (skb->data[1] & 0x01) ? 1 : 0; - fromDs = (skb->data[1] & 0x02) ? 1 : 0; - - memcpy(da, (skb->data+4+toDs*12), ETH_ALEN);/* Address1 or 3 */ - memcpy(sa, (skb->data+10+fromDs*(6+toDs*8)), ETH_ALEN); /* Address2, 3 or 4 */ - - /* Find the BSSID, which will be used to match the BA session */ - if (toDs && fromDs) - { - unifi_trace(priv, UDBG6, "4 address frame - don't try to find BSSID\n"); - bssid = NULL; - } - else - { - bssid = (u8 *) (skb->data + 4 + 12 - (fromDs * 6) - (toDs * 12)); - } - - pData = &bulkdata->d[0]; - frameControl = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(pData->os_data_ptr); - frameType = ((frameControl & 0x000C) >> 2); - - unifi_trace(priv, UDBG3, "Rx Frame Type: %d sn: %d\n", frameType, - (le16_to_cpu(*((u16*)(bulkdata->d[0].os_data_ptr + IEEE802_11_SEQUENCE_CONTROL_OFFSET))) >> 4) & 0xfff); - if(frameType == IEEE802_11_FRAMETYPE_CONTROL){ -#ifdef CSR_SUPPORT_SME - unifi_trace(priv, UDBG6, "%s: Received Control Frame\n", __FUNCTION__); - - if((frameControl & 0x00f0) == 0x00A0){ - /* This is a PS-POLL request */ - u8 pmBit = (frameControl & 0x1000)?0x01:0x00; - unifi_trace(priv, UDBG6, "%s: Received PS-POLL Frame\n", __FUNCTION__); - - uf_process_ps_poll(priv, sa, da, pmBit, interfaceTag); - } - else { - unifi_warning(priv, "%s: Non PS-POLL control frame is received\n", __FUNCTION__); - } -#endif - unifi_net_data_free(priv, &bulkdata->d[0]); - return; - } - if(frameType != IEEE802_11_FRAMETYPE_DATA) { - unifi_warning(priv, "%s: Non control Non Data frame is received\n", __FUNCTION__); - unifi_net_data_free(priv, &bulkdata->d[0]); - return; - } - -#ifdef CSR_SUPPORT_SME - if((interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP) || - (interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO)){ - - srcStaInfo = CsrWifiRouterCtrlGetStationRecordFromPeerMacAddress(priv, sa, interfaceTag); - - if(srcStaInfo == NULL) { - CsrWifiMacAddress peerMacAddress; - /* Unknown data PDU */ - memcpy(peerMacAddress.a, sa, ETH_ALEN); - unifi_trace(priv, UDBG1, "%s: Unexpected frame from peer = %x:%x:%x:%x:%x:%x\n", __FUNCTION__, - sa[0], sa[1], sa[2], sa[3], sa[4], sa[5]); - CsrWifiRouterCtrlUnexpectedFrameIndSend(priv->CSR_WIFI_SME_IFACEQUEUE, 0, interfaceTag, peerMacAddress); - unifi_net_data_free(priv, &bulkdata->d[0]); - return; - } - - /* - verify power management bit here so as to ensure host and unifi are always - in sync with power management status of peer. - - If we do it later, it may so happen we have stored the frame in BA re-ordering - buffer and hence host and unifi are out of sync for power management status - */ - - pmBit = (frameControl & 0x1000)?0x01:0x00; - powerSaveChanged = uf_process_pm_bit_for_peer(priv, srcStaInfo, pmBit, interfaceTag); - - /* Update station last activity time */ - srcStaInfo->activity_flag = TRUE; - - /* For Qos Frame if PM bit is toggled to indicate the change in power save state then it shall not be - considered as Trigger Frame. Enter only if WMM STA and peer is in Power save */ - - dataFrameType = ((frameControl & 0x00f0) >> 4); - - if((powerSaveChanged == FALSE)&&(srcStaInfo->wmmOrQosEnabled == TRUE)&& - (srcStaInfo->currentPeerState == CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_POWER_SAVE)){ - - if((dataFrameType == QOS_DATA) || (dataFrameType == QOS_DATA_NULL)){ - - /* - * QoS control field is offset from frame control by 2 (frame control) - * + 2 (duration/ID) + 2 (sequence control) + 3*ETH_ALEN or 4*ETH_ALEN - */ - if((frameControl & IEEE802_11_FC_TO_DS_MASK) && (frameControl & IEEE802_11_FC_FROM_DS_MASK)){ - qosControl= CSR_GET_UINT16_FROM_LITTLE_ENDIAN(pData->os_data_ptr + 30); - } - else{ - qosControl = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(pData->os_data_ptr + 24); - } - unifi_trace(priv, UDBG5, "%s: Check if U-APSD operations are triggered for qosControl: 0x%x\n", __FUNCTION__, qosControl); - uf_process_wmm_deliver_ac_uapsd(priv, srcStaInfo, qosControl, interfaceTag); - } - } - } - -#endif - - if( ((frameControl & 0x00f0) >> 4) == QOS_DATA) { - u8 *qos_control_ptr = (u8*)bulkdata->d[0].os_data_ptr + (((frameControl & IEEE802_11_FC_TO_DS_MASK) && (frameControl & IEEE802_11_FC_FROM_DS_MASK))?30: 24); - int tID = *qos_control_ptr & IEEE802_11_QC_TID_MASK; /* using ls octet of qos control */ - ba_session_rx_struct *ba_session; - u8 ba_session_idx = 0; - /* Get the BA originator address */ - if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP || - interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO){ - ba_addr = sa; - }else{ - ba_addr = bssid; - } - - down(&priv->ba_mutex); - for (ba_session_idx=0; ba_session_idx < MAX_SUPPORTED_BA_SESSIONS_RX; ba_session_idx++){ - ba_session = interfacePriv->ba_session_rx[ba_session_idx]; - if (ba_session){ - unifi_trace(priv, UDBG6, "found ba_session=0x%x ba_session_idx=%d", ba_session, ba_session_idx); - if ((!memcmp(ba_session->macAddress.a, ba_addr, ETH_ALEN)) && (ba_session->tID == tID)){ - frame_desc_struct frame_desc; - frame_desc.bulkdata = *bulkdata; - frame_desc.signal = *signal; - frame_desc.sn = (le16_to_cpu(*((u16*)(bulkdata->d[0].os_data_ptr + IEEE802_11_SEQUENCE_CONTROL_OFFSET))) >> 4) & 0xfff; - frame_desc.active = TRUE; - unifi_trace(priv, UDBG6, "%s: calling process_ba_frame (session=%d)\n", __FUNCTION__, ba_session_idx); - process_ba_frame(priv, interfacePriv, ba_session, &frame_desc); - up(&priv->ba_mutex); - process_ba_complete(priv, interfacePriv); - break; - } - } - } - if (ba_session_idx == MAX_SUPPORTED_BA_SESSIONS_RX){ - up(&priv->ba_mutex); - unifi_trace(priv, UDBG6, "%s: calling process_amsdu()", __FUNCTION__); - process_amsdu(priv, signal, bulkdata); - } - } else { - unifi_trace(priv, UDBG6, "calling unifi_rx()"); - unifi_rx(priv, signal, bulkdata); - } - - /* check if the frames in reorder buffer has aged, the check - * is done after receive processing so that if the missing frame - * has arrived in this receive process, then it is handled cleanly. - * - * And also this code here takes care that timeout check is made for all - * the receive indications - */ - down(&priv->ba_mutex); - for (i=0; i < MAX_SUPPORTED_BA_SESSIONS_RX; i++){ - ba_session_rx_struct *ba_session; - ba_session = interfacePriv->ba_session_rx[i]; - if (ba_session){ - check_ba_frame_age_timeout(priv, interfacePriv, ba_session); - } - } - up(&priv->ba_mutex); - process_ba_complete(priv, interfacePriv); - -} -/* - * --------------------------------------------------------------------------- - * uf_set_multicast_list - * - * This function is called by the higher level stack to set - * a list of multicast rx addresses. - * - * Arguments: - * dev Network Device pointer. - * - * Returns: - * None. - * - * Notes: - * --------------------------------------------------------------------------- - */ - -static void -uf_set_multicast_list(struct net_device *dev) -{ - netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev); - unifi_priv_t *priv = interfacePriv->privPtr; - -#ifdef CSR_NATIVE_LINUX - unifi_trace(priv, UDBG3, "uf_set_multicast_list unsupported\n"); - return; -#else - - u8 *mc_list = interfacePriv->mc_list; - struct netdev_hw_addr *mc_addr; - int mc_addr_count; - - if (priv->init_progress != UNIFI_INIT_COMPLETED) { - return; - } - - mc_addr_count = netdev_mc_count(dev); - - unifi_trace(priv, UDBG3, - "uf_set_multicast_list (count=%d)\n", mc_addr_count); - - - /* Not enough space? */ - if (mc_addr_count > UNIFI_MAX_MULTICAST_ADDRESSES) { - return; - } - - /* Store the list to be processed by the work item. */ - interfacePriv->mc_list_count = mc_addr_count; - netdev_hw_addr_list_for_each(mc_addr, &dev->mc) { - memcpy(mc_list, mc_addr->addr, ETH_ALEN); - mc_list += ETH_ALEN; - } - - /* Send a message to the workqueue */ - queue_work(priv->unifi_workqueue, &priv->multicast_list_task); -#endif - -} /* uf_set_multicast_list() */ - -/* - * --------------------------------------------------------------------------- - * netdev_mlme_event_handler - * - * Callback function to be used as the udi_event_callback when registering - * as a netdev client. - * To use it, a client specifies this function as the udi_event_callback - * to ul_register_client(). The signal dispatcher in - * unifi_receive_event() will call this function to deliver a signal. - * - * Arguments: - * pcli Pointer to the client instance. - * signal Pointer to the received signal. - * signal_len Size of the signal structure in bytes. - * bulkdata Pointer to structure containing any associated bulk data. - * dir Direction of the signal. Zero means from host, - * non-zero means to host. - * - * Returns: - * None. - * --------------------------------------------------------------------------- - */ -static void -netdev_mlme_event_handler(ul_client_t *pcli, const u8 *sig_packed, int sig_len, - const bulk_data_param_t *bulkdata_o, int dir) -{ - CSR_SIGNAL signal; - unifi_priv_t *priv = uf_find_instance(pcli->instance); - int id, r; - bulk_data_param_t bulkdata; - - /* Just a sanity check */ - if (sig_packed == NULL) { - return; - } - - /* - * This copy is to silence a compiler warning about discarding the - * const qualifier. - */ - bulkdata = *bulkdata_o; - - /* Get the unpacked signal */ - r = read_unpack_signal(sig_packed, &signal); - if (r) { - /* - * The CSR_MLME_CONNECTED_INDICATION_ID has a receiverID=0 so will - * fall through this case. It is safe to ignore this signal. - */ - unifi_trace(priv, UDBG1, - "Netdev - Received unknown signal 0x%.4X.\n", - CSR_GET_UINT16_FROM_LITTLE_ENDIAN(sig_packed)); - return; - } - - id = signal.SignalPrimitiveHeader.SignalId; - unifi_trace(priv, UDBG3, "Netdev - Process signal 0x%.4X\n", id); - - /* - * Take the appropriate action for the signal. - */ - switch (id) { - case CSR_MA_PACKET_ERROR_INDICATION_ID: - process_ma_packet_error_ind(priv, &signal, &bulkdata); - break; - case CSR_MA_PACKET_INDICATION_ID: - process_ma_packet_ind(priv, &signal, &bulkdata); - break; - case CSR_MA_PACKET_CONFIRM_ID: - process_ma_packet_cfm(priv, &signal, &bulkdata); - break; -#ifdef CSR_SUPPORT_SME - case CSR_MLME_SET_TIM_CONFIRM_ID: - /* Handle TIM confirms from FW & set the station record's TIM state appropriately, - * In case of failures, tries with max_retransmit limit - */ - uf_handle_tim_cfm(priv, &signal.u.MlmeSetTimConfirm, signal.SignalPrimitiveHeader.ReceiverProcessId); - break; -#endif - case CSR_DEBUG_STRING_INDICATION_ID: - debug_string_indication(priv, bulkdata.d[0].os_data_ptr, bulkdata.d[0].data_length); - break; - - case CSR_DEBUG_WORD16_INDICATION_ID: - debug_word16_indication(priv, &signal); - break; - - case CSR_DEBUG_GENERIC_CONFIRM_ID: - case CSR_DEBUG_GENERIC_INDICATION_ID: - debug_generic_indication(priv, &signal); - break; - default: - break; - } - -} /* netdev_mlme_event_handler() */ - - -/* - * --------------------------------------------------------------------------- - * uf_net_get_name - * - * Retrieve the name (e.g. eth1) associated with this network device - * - * Arguments: - * dev Pointer to the network device. - * name Buffer to write name - * len Size of buffer in bytes - * - * Returns: - * None - * - * Notes: - * --------------------------------------------------------------------------- - */ -void uf_net_get_name(struct net_device *dev, char *name, int len) -{ - *name = '\0'; - if (dev) { - strlcpy(name, dev->name, (len > IFNAMSIZ) ? IFNAMSIZ : len); - } - -} /* uf_net_get_name */ - -#ifdef CSR_SUPPORT_WEXT - -/* - * --------------------------------------------------------------------------- - * uf_netdev_event - * - * Callback function to handle netdev state changes - * - * Arguments: - * notif Pointer to a notifier_block. - * event Event prompting notification - * ptr net_device pointer - * - * Returns: - * None - * - * Notes: - * The event handler is global, and may occur on non-UniFi netdevs. - * --------------------------------------------------------------------------- - */ -static int -uf_netdev_event(struct notifier_block *notif, unsigned long event, void* ptr) { - struct net_device *netdev = netdev_notifier_info_to_dev(ptr); - netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(netdev); - unifi_priv_t *priv = NULL; - static const CsrWifiMacAddress broadcast_address = {{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}}; - - /* Check that the event is for a UniFi netdev. If it's not, the netdev_priv - * structure is not safe to use. - */ - if (uf_find_netdev_priv(interfacePriv) == -1) { - unifi_trace(NULL, UDBG1, "uf_netdev_event: ignore e=%d, ptr=%p, priv=%p %s\n", - event, ptr, interfacePriv, netdev->name); - return 0; - } - - switch(event) { - case NETDEV_CHANGE: - priv = interfacePriv->privPtr; - unifi_trace(priv, UDBG1, "NETDEV_CHANGE: %p %s %s waiting for it\n", - ptr, - netdev->name, - interfacePriv->wait_netdev_change ? "" : "not"); - - if (interfacePriv->wait_netdev_change) { - netif_tx_wake_all_queues(priv->netdev[interfacePriv->InterfaceTag]); - interfacePriv->connected = UnifiConnected; - interfacePriv->wait_netdev_change = FALSE; - /* Note: passing the broadcast address here will allow anyone to attempt to join our adhoc network */ - uf_process_rx_pending_queue(priv, UF_UNCONTROLLED_PORT_Q, broadcast_address, 1, interfacePriv->InterfaceTag); - uf_process_rx_pending_queue(priv, UF_CONTROLLED_PORT_Q, broadcast_address, 1, interfacePriv->InterfaceTag); - } - break; - - default: - break; - } - return 0; -} - -static struct notifier_block uf_netdev_notifier = { - .notifier_call = uf_netdev_event, -}; -#endif /* CSR_SUPPORT_WEXT */ - - -static void - process_amsdu(unifi_priv_t *priv, CSR_SIGNAL *signal, bulk_data_param_t *bulkdata) -{ - u32 offset; - u32 length = bulkdata->d[0].data_length; - u32 subframe_length, subframe_body_length, dot11_hdr_size; - u8 *ptr; - bulk_data_param_t subframe_bulkdata; - u8 *dot11_hdr_ptr = (u8*)bulkdata->d[0].os_data_ptr; - CsrResult csrResult; - u16 frameControl; - u8 *qos_control_ptr; - - frameControl = le16_to_cpu(*((u16*)dot11_hdr_ptr)); - qos_control_ptr = dot11_hdr_ptr + (((frameControl & IEEE802_11_FC_TO_DS_MASK) && (frameControl & IEEE802_11_FC_FROM_DS_MASK))?30: 24); - if(!(*qos_control_ptr & IEEE802_11_QC_A_MSDU_PRESENT)) { - unifi_trace(priv, UDBG6, "%s: calling unifi_rx()", __FUNCTION__); - unifi_rx(priv, signal, bulkdata); - return; - } - *qos_control_ptr &= ~(IEEE802_11_QC_A_MSDU_PRESENT); - - ptr = qos_control_ptr + 2; - offset = dot11_hdr_size = ptr - dot11_hdr_ptr; - - while(length > (offset + sizeof(struct ethhdr) + sizeof(llc_snap_hdr_t))) { - subframe_body_length = ntohs(((struct ethhdr*)ptr)->h_proto); - if(subframe_body_length > IEEE802_11_MAX_DATA_LEN) { - unifi_error(priv, "%s: bad subframe_body_length = %d\n", __FUNCTION__, subframe_body_length); - break; - } - subframe_length = sizeof(struct ethhdr) + subframe_body_length; - memset(&subframe_bulkdata, 0, sizeof(bulk_data_param_t)); - - csrResult = unifi_net_data_malloc(priv, &subframe_bulkdata.d[0], dot11_hdr_size + subframe_body_length); - - if (csrResult != CSR_RESULT_SUCCESS) { - unifi_error(priv, "%s: unifi_net_data_malloc failed\n", __FUNCTION__); - break; - } - - memcpy((u8*)subframe_bulkdata.d[0].os_data_ptr, dot11_hdr_ptr, dot11_hdr_size); - - - /* When to DS=0 and from DS=0, address 3 will already have BSSID so no need to re-program */ - if ((frameControl & IEEE802_11_FC_TO_DS_MASK) && !(frameControl & IEEE802_11_FC_FROM_DS_MASK)){ - memcpy((u8*)subframe_bulkdata.d[0].os_data_ptr + IEEE802_11_ADDR3_OFFSET, ((struct ethhdr*)ptr)->h_dest, ETH_ALEN); - } - else if (!(frameControl & IEEE802_11_FC_TO_DS_MASK) && (frameControl & IEEE802_11_FC_FROM_DS_MASK)){ - memcpy((u8*)subframe_bulkdata.d[0].os_data_ptr + IEEE802_11_ADDR3_OFFSET, - ((struct ethhdr*)ptr)->h_source, - ETH_ALEN); - } - - memcpy((u8*)subframe_bulkdata.d[0].os_data_ptr + dot11_hdr_size, - ptr + sizeof(struct ethhdr), - subframe_body_length); - unifi_trace(priv, UDBG6, "%s: calling unifi_rx. length = %d subframe_length = %d\n", __FUNCTION__, length, subframe_length); - unifi_rx(priv, signal, &subframe_bulkdata); - - subframe_length = (subframe_length + 3)&(~0x3); - ptr += subframe_length; - offset += subframe_length; - } - unifi_net_data_free(priv, &bulkdata->d[0]); -} - - -#define SN_TO_INDEX(__ba_session, __sn) (((__sn - __ba_session->start_sn) & 0xFFF) % __ba_session->wind_size) - - -#define ADVANCE_EXPECTED_SN(__ba_session) \ -{ \ - __ba_session->expected_sn++; \ - __ba_session->expected_sn &= 0xFFF; \ -} - -#define FREE_BUFFER_SLOT(__ba_session, __index) \ -{ \ - __ba_session->occupied_slots--; \ - __ba_session->buffer[__index].active = FALSE; \ - ADVANCE_EXPECTED_SN(__ba_session); \ -} - -static void add_frame_to_ba_complete(unifi_priv_t *priv, - netInterface_priv_t *interfacePriv, - frame_desc_struct *frame_desc) -{ - interfacePriv->ba_complete[interfacePriv->ba_complete_index] = *frame_desc; - interfacePriv->ba_complete_index++; -} - - -static void update_expected_sn(unifi_priv_t *priv, - netInterface_priv_t *interfacePriv, - ba_session_rx_struct *ba_session, - u16 sn) -{ - int i, j; - u16 gap; - - gap = (sn - ba_session->expected_sn) & 0xFFF; - unifi_trace(priv, UDBG6, "%s: process the frames up to new_expected_sn = %d gap = %d\n", __FUNCTION__, sn, gap); - for(j = 0; j < gap && j < ba_session->wind_size; j++) { - i = SN_TO_INDEX(ba_session, ba_session->expected_sn); - unifi_trace(priv, UDBG6, "%s: process the slot index = %d\n", __FUNCTION__, i); - if(ba_session->buffer[i].active) { - add_frame_to_ba_complete(priv, interfacePriv, &ba_session->buffer[i]); - unifi_trace(priv, UDBG6, "%s: process the frame at index = %d expected_sn = %d\n", __FUNCTION__, i, ba_session->expected_sn); - FREE_BUFFER_SLOT(ba_session, i); - } else { - unifi_trace(priv, UDBG6, "%s: empty slot at index = %d\n", __FUNCTION__, i); - ADVANCE_EXPECTED_SN(ba_session); - } - } - ba_session->expected_sn = sn; -} - - -static void complete_ready_sequence(unifi_priv_t *priv, - netInterface_priv_t *interfacePriv, - ba_session_rx_struct *ba_session) -{ - int i; - - i = SN_TO_INDEX(ba_session, ba_session->expected_sn); - while (ba_session->buffer[i].active) { - add_frame_to_ba_complete(priv, interfacePriv, &ba_session->buffer[i]); - unifi_trace(priv, UDBG6, "%s: completed stored frame(expected_sn=%d) at i = %d\n", __FUNCTION__, ba_session->expected_sn, i); - FREE_BUFFER_SLOT(ba_session, i); - i = SN_TO_INDEX(ba_session, ba_session->expected_sn); - } -} - - -void scroll_ba_window(unifi_priv_t *priv, - netInterface_priv_t *interfacePriv, - ba_session_rx_struct *ba_session, - u16 sn) -{ - if(((sn - ba_session->expected_sn) & 0xFFF) <= 2048) { - update_expected_sn(priv, interfacePriv, ba_session, sn); - complete_ready_sequence(priv, interfacePriv, ba_session); - } -} - - -static int consume_frame_or_get_buffer_index(unifi_priv_t *priv, - netInterface_priv_t *interfacePriv, - ba_session_rx_struct *ba_session, - u16 sn, - frame_desc_struct *frame_desc) { - int i; - u16 sn_temp; - - if(((sn - ba_session->expected_sn) & 0xFFF) <= 2048) { - - /* once we are in BA window, set the flag for BA trigger */ - if(!ba_session->trigger_ba_after_ssn){ - ba_session->trigger_ba_after_ssn = TRUE; - } - - sn_temp = ba_session->expected_sn + ba_session->wind_size; - unifi_trace(priv, UDBG6, "%s: new frame: sn=%d\n", __FUNCTION__, sn); - if(!(((sn - sn_temp) & 0xFFF) > 2048)) { - u16 new_expected_sn; - unifi_trace(priv, UDBG6, "%s: frame is out of window\n", __FUNCTION__); - sn_temp = (sn - ba_session->wind_size) & 0xFFF; - new_expected_sn = (sn_temp + 1) & 0xFFF; - update_expected_sn(priv, interfacePriv, ba_session, new_expected_sn); - } - i = -1; - if (sn == ba_session->expected_sn) { - unifi_trace(priv, UDBG6, "%s: sn = ba_session->expected_sn = %d\n", __FUNCTION__, sn); - ADVANCE_EXPECTED_SN(ba_session); - add_frame_to_ba_complete(priv, interfacePriv, frame_desc); - } else { - i = SN_TO_INDEX(ba_session, sn); - unifi_trace(priv, UDBG6, "%s: sn(%d) != ba_session->expected_sn(%d), i = %d\n", __FUNCTION__, sn, ba_session->expected_sn, i); - if (ba_session->buffer[i].active) { - unifi_trace(priv, UDBG6, "%s: free frame at i = %d\n", __FUNCTION__, i); - i = -1; - unifi_net_data_free(priv, &frame_desc->bulkdata.d[0]); - } - } - } else { - i = -1; - if(!ba_session->trigger_ba_after_ssn){ - unifi_trace(priv, UDBG6, "%s: frame before ssn, pass it up: sn=%d\n", __FUNCTION__, sn); - add_frame_to_ba_complete(priv, interfacePriv, frame_desc); - }else{ - unifi_trace(priv, UDBG6, "%s: old frame, drop: sn=%d, expected_sn=%d\n", __FUNCTION__, sn, ba_session->expected_sn); - unifi_net_data_free(priv, &frame_desc->bulkdata.d[0]); - } - } - return i; -} - - - -static void process_ba_frame(unifi_priv_t *priv, - netInterface_priv_t *interfacePriv, - ba_session_rx_struct *ba_session, - frame_desc_struct *frame_desc) -{ - int i; - u16 sn = frame_desc->sn; - - if (ba_session->timeout) { - mod_timer(&ba_session->timer, (jiffies + usecs_to_jiffies((ba_session->timeout) * 1024))); - } - unifi_trace(priv, UDBG6, "%s: got frame(sn=%d)\n", __FUNCTION__, sn); - - i = consume_frame_or_get_buffer_index(priv, interfacePriv, ba_session, sn, frame_desc); - if(i >= 0) { - unifi_trace(priv, UDBG6, "%s: store frame(sn=%d) at i = %d\n", __FUNCTION__, sn, i); - ba_session->buffer[i] = *frame_desc; - ba_session->buffer[i].recv_time = CsrTimeGet(NULL); - ba_session->occupied_slots++; - } else { - unifi_trace(priv, UDBG6, "%s: frame consumed - sn = %d\n", __FUNCTION__, sn); - } - complete_ready_sequence(priv, interfacePriv, ba_session); -} - - -static void process_ba_complete(unifi_priv_t *priv, netInterface_priv_t *interfacePriv) -{ - frame_desc_struct *frame_desc; - u8 i; - - for(i = 0; i < interfacePriv->ba_complete_index; i++) { - frame_desc = &interfacePriv->ba_complete[i]; - unifi_trace(priv, UDBG6, "%s: calling process_amsdu()\n", __FUNCTION__); - process_amsdu(priv, &frame_desc->signal, &frame_desc->bulkdata); - } - interfacePriv->ba_complete_index = 0; - -} - - -/* Check if the frames in BA reoder buffer has aged and - * if so release the frames to upper processes and move - * the window - */ -static void check_ba_frame_age_timeout( unifi_priv_t *priv, - netInterface_priv_t *interfacePriv, - ba_session_rx_struct *ba_session) -{ - u32 now; - u32 age; - u8 i, j; - u16 sn_temp; - - /* gap is started at 1 because we have buffered frames and - * hence a minimum gap of 1 exists - */ - u8 gap=1; - - now = CsrTimeGet(NULL); - - if (ba_session->occupied_slots) - { - /* expected sequence has not arrived so start searching from next - * sequence number until a frame is available and determine the gap. - * Check if the frame available has timedout, if so advance the - * expected sequence number and release the frames - */ - sn_temp = (ba_session->expected_sn + 1) & 0xFFF; - - for(j = 0; j < ba_session->wind_size; j++) - { - i = SN_TO_INDEX(ba_session, sn_temp); - - if(ba_session->buffer[i].active) - { - unifi_trace(priv, UDBG6, "check age at slot index = %d sn = %d recv_time = %u now = %u\n", - i, - ba_session->buffer[i].sn, - ba_session->buffer[i].recv_time, - now); - - if (ba_session->buffer[i].recv_time > now) - { - /* timer wrap */ - age = CsrTimeAdd((u32)CsrTimeSub(CSR_SCHED_TIME_MAX, ba_session->buffer[i].recv_time), now); - } - else - { - age = (u32)CsrTimeSub(now, ba_session->buffer[i].recv_time); - } - - if (age >= CSR_WIFI_BA_MPDU_FRAME_AGE_TIMEOUT) - { - unifi_trace(priv, UDBG2, "release the frame at index = %d gap = %d expected_sn = %d sn = %d\n", - i, - gap, - ba_session->expected_sn, - ba_session->buffer[i].sn); - - /* if it has timedout don't wait for missing frames, move the window */ - while (gap--) - { - ADVANCE_EXPECTED_SN(ba_session); - } - add_frame_to_ba_complete(priv, interfacePriv, &ba_session->buffer[i]); - FREE_BUFFER_SLOT(ba_session, i); - complete_ready_sequence(priv, interfacePriv, ba_session); - } - break; - - } - else - { - /* advance temp sequence number and frame gap */ - sn_temp = (sn_temp + 1) & 0xFFF; - gap++; - } - } - } -} - - -static void process_ma_packet_error_ind(unifi_priv_t *priv, CSR_SIGNAL *signal, bulk_data_param_t *bulkdata) -{ - u16 interfaceTag; - const CSR_MA_PACKET_ERROR_INDICATION *pkt_err_ind = &signal->u.MaPacketErrorIndication; - netInterface_priv_t *interfacePriv; - ba_session_rx_struct *ba_session; - u8 ba_session_idx = 0; - CSR_PRIORITY UserPriority; - CSR_SEQUENCE_NUMBER sn; - - interfaceTag = (pkt_err_ind->VirtualInterfaceIdentifier & 0xff); - - - /* Sanity check that the VIF refers to a sensible interface */ - if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) - { - unifi_error(priv, "%s: MaPacketErrorIndication indication with bad interfaceTag %d\n", __FUNCTION__, interfaceTag); - return; - } - - interfacePriv = priv->interfacePriv[interfaceTag]; - UserPriority = pkt_err_ind->UserPriority; - if(UserPriority > 15) { - unifi_error(priv, "%s: MaPacketErrorIndication indication with bad UserPriority=%d\n", __FUNCTION__, UserPriority); - } - sn = pkt_err_ind->SequenceNumber; - - down(&priv->ba_mutex); - /* To find the right ba_session loop through the BA sessions, compare MAC address and tID */ - for (ba_session_idx=0; ba_session_idx < MAX_SUPPORTED_BA_SESSIONS_RX; ba_session_idx++){ - ba_session = interfacePriv->ba_session_rx[ba_session_idx]; - if (ba_session){ - if ((!memcmp(ba_session->macAddress.a, pkt_err_ind->PeerQstaAddress.x, ETH_ALEN)) && (ba_session->tID == UserPriority)){ - if (ba_session->timeout) { - mod_timer(&ba_session->timer, (jiffies + usecs_to_jiffies((ba_session->timeout) * 1024))); - } - scroll_ba_window(priv, interfacePriv, ba_session, sn); - break; - } - } - } - - up(&priv->ba_mutex); - process_ba_complete(priv, interfacePriv); -} - - diff --git a/drivers/staging/csr/os.c b/drivers/staging/csr/os.c deleted file mode 100644 index 37ec59df3581..000000000000 --- a/drivers/staging/csr/os.c +++ /dev/null @@ -1,477 +0,0 @@ -/* - * --------------------------------------------------------------------------- - * FILE: os.c - * - * PURPOSE: - * Routines to fulfil the OS-abstraction for the HIP lib. - * It is part of the porting exercise. - * - * Copyright (C) 2005-2009 by Cambridge Silicon Radio Ltd. - * - * Refer to LICENSE.txt included with this source code for details on - * the license terms. - * - * --------------------------------------------------------------------------- - */ - -/** - * The HIP lib OS abstraction consists of the implementation - * of the functions in this file. It is part of the porting exercise. - */ - -#include "unifi_priv.h" - - -/* - * --------------------------------------------------------------------------- - * unifi_net_data_malloc - * - * Allocate an OS specific net data buffer of "size" bytes. - * The bulk_data_slot.os_data_ptr must be initialised to point - * to the buffer allocated. The bulk_data_slot.length must be - * initialised to the requested size, zero otherwise. - * The bulk_data_slot.os_net_buf_ptr can be initialised to - * an OS specific pointer to be used in the unifi_net_data_free(). - * - * - * Arguments: - * ospriv Pointer to device private context struct. - * bulk_data_slot Pointer to the bulk data structure to initialise. - * size Size of the buffer to be allocated. - * - * Returns: - * CSR_RESULT_SUCCESS on success, CSR_RESULT_FAILURE otherwise. - * --------------------------------------------------------------------------- - */ -CsrResult -unifi_net_data_malloc(void *ospriv, bulk_data_desc_t *bulk_data_slot, unsigned int size) -{ - struct sk_buff *skb; - unifi_priv_t *priv = (unifi_priv_t*)ospriv; - int rounded_length; - - if (priv->card_info.sdio_block_size == 0) { - unifi_error(priv, "unifi_net_data_malloc: Invalid SDIO block size\n"); - return CSR_RESULT_FAILURE; - } - - rounded_length = (size + priv->card_info.sdio_block_size - 1) & ~(priv->card_info.sdio_block_size - 1); - - /* - * (ETH_HLEN + 2) bytes tailroom for header manipulation - * CSR_WIFI_ALIGN_BYTES bytes headroom for alignment manipulation - */ - skb = dev_alloc_skb(rounded_length + 2 + ETH_HLEN + CSR_WIFI_ALIGN_BYTES); - if (! skb) { - unifi_error(ospriv, "alloc_skb failed.\n"); - bulk_data_slot->os_net_buf_ptr = NULL; - bulk_data_slot->net_buf_length = 0; - bulk_data_slot->os_data_ptr = NULL; - bulk_data_slot->data_length = 0; - return CSR_RESULT_FAILURE; - } - - bulk_data_slot->os_net_buf_ptr = (const unsigned char*)skb; - bulk_data_slot->net_buf_length = rounded_length + 2 + ETH_HLEN + CSR_WIFI_ALIGN_BYTES; - bulk_data_slot->os_data_ptr = (const void*)skb->data; - bulk_data_slot->data_length = size; - - return CSR_RESULT_SUCCESS; -} /* unifi_net_data_malloc() */ - -/* - * --------------------------------------------------------------------------- - * unifi_net_data_free - * - * Free an OS specific net data buffer. - * The bulk_data_slot.length must be initialised to 0. - * - * - * Arguments: - * ospriv Pointer to device private context struct. - * bulk_data_slot Pointer to the bulk data structure that - * holds the data to be freed. - * - * Returns: - * None. - * --------------------------------------------------------------------------- - */ -void -unifi_net_data_free(void *ospriv, bulk_data_desc_t *bulk_data_slot) -{ - struct sk_buff *skb; - CSR_UNUSED(ospriv); - - skb = (struct sk_buff *)bulk_data_slot->os_net_buf_ptr; - dev_kfree_skb(skb); - - bulk_data_slot->net_buf_length = 0; - bulk_data_slot->data_length = 0; - bulk_data_slot->os_data_ptr = bulk_data_slot->os_net_buf_ptr = NULL; - -} /* unifi_net_data_free() */ - - -/* -* --------------------------------------------------------------------------- -* unifi_net_dma_align -* -* DMA align an OS specific net data buffer. -* The buffer must be empty. -* -* -* Arguments: -* ospriv Pointer to device private context struct. -* bulk_data_slot Pointer to the bulk data structure that -* holds the data to be aligned. -* -* Returns: -* None. -* --------------------------------------------------------------------------- -*/ -CsrResult -unifi_net_dma_align(void *ospriv, bulk_data_desc_t *bulk_data_slot) -{ - struct sk_buff *skb; - unsigned long buf_address; - int offset; - unifi_priv_t *priv = (unifi_priv_t*)ospriv; - - if ((bulk_data_slot == NULL) || (CSR_WIFI_ALIGN_BYTES == 0)) { - return CSR_RESULT_SUCCESS; - } - - if ((bulk_data_slot->os_data_ptr == NULL) || (bulk_data_slot->data_length == 0)) { - return CSR_RESULT_SUCCESS; - } - - buf_address = (unsigned long)(bulk_data_slot->os_data_ptr) & (CSR_WIFI_ALIGN_BYTES - 1); - - unifi_trace(priv, UDBG5, - "unifi_net_dma_align: Allign buffer (0x%p) by %d bytes\n", - bulk_data_slot->os_data_ptr, buf_address); - - offset = CSR_WIFI_ALIGN_BYTES - buf_address; - if (offset < 0) { - unifi_error(priv, "unifi_net_dma_align: Failed (offset=%d)\n", offset); - return CSR_RESULT_FAILURE; - } - - skb = (struct sk_buff*)(bulk_data_slot->os_net_buf_ptr); - skb_reserve(skb, offset); - bulk_data_slot->os_net_buf_ptr = (const unsigned char*)skb; - bulk_data_slot->os_data_ptr = (const void*)(skb->data); - - return CSR_RESULT_SUCCESS; - -} /* unifi_net_dma_align() */ - -#ifdef ANDROID_TIMESTAMP -static volatile unsigned int printk_cpu = UINT_MAX; -char tbuf[30]; - -char* print_time(void ) -{ - unsigned long long t; - unsigned long nanosec_rem; - - t = cpu_clock(printk_cpu); - nanosec_rem = do_div(t, 1000000000); - sprintf(tbuf, "[%5lu.%06lu] ", - (unsigned long) t, - nanosec_rem / 1000); - - return tbuf; -} -#endif - - -/* Module parameters */ -extern int unifi_debug; - -#ifdef UNIFI_DEBUG -#define DEBUG_BUFFER_SIZE 120 - -#define FORMAT_TRACE(_s, _len, _args, _fmt) \ - do { \ - va_start(_args, _fmt); \ - _len += vsnprintf(&(_s)[_len], \ - (DEBUG_BUFFER_SIZE - _len), \ - _fmt, _args); \ - va_end(_args); \ - if (_len >= DEBUG_BUFFER_SIZE) { \ - (_s)[DEBUG_BUFFER_SIZE - 2] = '\n'; \ - (_s)[DEBUG_BUFFER_SIZE - 1] = 0; \ - } \ - } while (0) - -void -unifi_error(void* ospriv, const char *fmt, ...) -{ - unifi_priv_t *priv = (unifi_priv_t*) ospriv; - char s[DEBUG_BUFFER_SIZE]; - va_list args; - unsigned int len; -#ifdef ANDROID_TIMESTAMP - if (priv != NULL) { - len = snprintf(s, DEBUG_BUFFER_SIZE, KERN_ERR "%s unifi%d: ", print_time(), priv->instance); - } else { - len = snprintf(s, DEBUG_BUFFER_SIZE, KERN_ERR "%s unifi: ", print_time()); - } -#else - if (priv != NULL) { - len = snprintf(s, DEBUG_BUFFER_SIZE, KERN_ERR "unifi%d: ", priv->instance); - } else { - len = snprintf(s, DEBUG_BUFFER_SIZE, KERN_ERR "unifi: "); - } -#endif /* ANDROID_TIMESTAMP */ - FORMAT_TRACE(s, len, args, fmt); - - printk("%s", s); -} - -void -unifi_warning(void* ospriv, const char *fmt, ...) -{ - unifi_priv_t *priv = (unifi_priv_t*) ospriv; - char s[DEBUG_BUFFER_SIZE]; - va_list args; - unsigned int len; - -#ifdef ANDROID_TIMESTAMP - if (priv != NULL) { - len = snprintf(s, DEBUG_BUFFER_SIZE, KERN_WARNING "%s unifi%d: ", print_time(), priv->instance); - } else { - len = snprintf(s, DEBUG_BUFFER_SIZE, KERN_WARNING "%s unifi: ", print_time()); - } -#else - if (priv != NULL) { - len = snprintf(s, DEBUG_BUFFER_SIZE, KERN_WARNING "unifi%d: ", priv->instance); - } else { - len = snprintf(s, DEBUG_BUFFER_SIZE, KERN_WARNING "unifi: "); - } -#endif /* ANDROID_TIMESTAMP */ - - FORMAT_TRACE(s, len, args, fmt); - - printk("%s", s); -} - - -void -unifi_notice(void* ospriv, const char *fmt, ...) -{ - unifi_priv_t *priv = (unifi_priv_t*) ospriv; - char s[DEBUG_BUFFER_SIZE]; - va_list args; - unsigned int len; - -#ifdef ANDROID_TIMESTAMP - if (priv != NULL) { - len = snprintf(s, DEBUG_BUFFER_SIZE, KERN_NOTICE "%s unifi%d: ", print_time(), priv->instance); - } else { - len = snprintf(s, DEBUG_BUFFER_SIZE, KERN_NOTICE "%s unifi: ", print_time()); - } -#else - if (priv != NULL) { - len = snprintf(s, DEBUG_BUFFER_SIZE, KERN_NOTICE "unifi%d: ", priv->instance); - } else { - len = snprintf(s, DEBUG_BUFFER_SIZE, KERN_NOTICE "unifi: "); - } -#endif /* ANDROID_TIMESTAMP */ - - FORMAT_TRACE(s, len, args, fmt); - - printk("%s", s); -} - - -void -unifi_info(void* ospriv, const char *fmt, ...) -{ - unifi_priv_t *priv = (unifi_priv_t*) ospriv; - char s[DEBUG_BUFFER_SIZE]; - va_list args; - unsigned int len; - -#ifdef ANDROID_TIMESTAMP - if (priv != NULL) { - len = snprintf(s, DEBUG_BUFFER_SIZE, KERN_INFO "%s unifi%d: ", print_time(), priv->instance); - } else { - len = snprintf(s, DEBUG_BUFFER_SIZE, KERN_INFO "%s unifi: ", print_time()); - } -#else - if (priv != NULL) { - len = snprintf(s, DEBUG_BUFFER_SIZE, KERN_INFO "unifi%d: ", priv->instance); - } else { - len = snprintf(s, DEBUG_BUFFER_SIZE, KERN_INFO "unifi: "); - } -#endif /* ANDROID_TIMESTAMP */ - - FORMAT_TRACE(s, len, args, fmt); - - printk("%s", s); -} - -/* debugging */ -void -unifi_trace(void* ospriv, int level, const char *fmt, ...) -{ - unifi_priv_t *priv = (unifi_priv_t*) ospriv; - char s[DEBUG_BUFFER_SIZE]; - va_list args; - unsigned int len; - - if (unifi_debug >= level) { -#ifdef ANDROID_TIMESTAMP - if (priv != NULL) { - len = snprintf(s, DEBUG_BUFFER_SIZE, KERN_ERR "%s unifi%d: ", print_time(), priv->instance); - } else { - len = snprintf(s, DEBUG_BUFFER_SIZE, KERN_ERR "%s unifi: ", print_time()); - } -#else - if (priv != NULL) { - len = snprintf(s, DEBUG_BUFFER_SIZE, KERN_ERR "unifi%d: ", priv->instance); - } else { - len = snprintf(s, DEBUG_BUFFER_SIZE, KERN_ERR "unifi: "); - } -#endif /* ANDROID_TIMESTAMP */ - - FORMAT_TRACE(s, len, args, fmt); - - printk("%s", s); - } -} - -#else - -void -unifi_error_nop(void* ospriv, const char *fmt, ...) -{ -} - -void -unifi_trace_nop(void* ospriv, int level, const char *fmt, ...) -{ -} - -#endif /* UNIFI_DEBUG */ - - -/* - * --------------------------------------------------------------------------- - * - * Debugging support. - * - * --------------------------------------------------------------------------- - */ - -#ifdef UNIFI_DEBUG - -/* Memory dump with level filter controlled by unifi_debug */ -void -unifi_dump(void *ospriv, int level, const char *msg, void *mem, u16 len) -{ - unifi_priv_t *priv = (unifi_priv_t*) ospriv; - - if (unifi_debug >= level) { -#ifdef ANDROID_TIMESTAMP - if (priv != NULL) { - printk(KERN_ERR "%s unifi%d: --- dump: %s ---\n", print_time(), priv->instance, msg ? msg : ""); - } else { - printk(KERN_ERR "%s unifi: --- dump: %s ---\n", print_time(), msg ? msg : ""); - } -#else - if (priv != NULL) { - printk(KERN_ERR "unifi%d: --- dump: %s ---\n", priv->instance, msg ? msg : ""); - } else { - printk(KERN_ERR "unifi: --- dump: %s ---\n", msg ? msg : ""); - } -#endif /* ANDROID_TIMESTAMP */ - dump(mem, len); - - if (priv != NULL) { - printk(KERN_ERR "unifi%d: --- end of dump ---\n", priv->instance); - } else { - printk(KERN_ERR "unifi: --- end of dump ---\n"); - } - } -} - -/* Memory dump that appears all the time, use sparingly */ -void -dump(void *mem, u16 len) -{ - int i, col = 0; - unsigned char *pdata = (unsigned char *)mem; -#ifdef ANDROID_TIMESTAMP - printk("timestamp %s \n", print_time()); -#endif /* ANDROID_TIMESTAMP */ - if (mem == NULL) { - printk("(null dump)\n"); - return; - } - for (i = 0; i < len; i++) { - if (col == 0) - printk("0x%02X: ", i); - - printk(" %02X", pdata[i]); - - if (++col == 16) { - printk("\n"); - col = 0; - } - } - if (col) - printk("\n"); -} /* dump() */ - - -void -dump16(void *mem, u16 len) -{ - int i, col=0; - unsigned short *p = (unsigned short *)mem; -#ifdef ANDROID_TIMESTAMP - printk("timestamp %s \n", print_time()); -#endif /* ANDROID_TIMESTAMP */ - for (i = 0; i < len; i+=2) { - if (col == 0) - printk("0x%02X: ", i); - - printk(" %04X", *p++); - - if (++col == 8) { - printk("\n"); - col = 0; - } - } - if (col) - printk("\n"); -} - - -#ifdef CSR_WIFI_HIP_DEBUG_OFFLINE -void -dump_str(void *mem, u16 len) -{ - int i; - unsigned char *pdata = (unsigned char *)mem; -#ifdef ANDROID_TIMESTAMP - printk("timestamp %s \n", print_time()); -#endif /* ANDROID_TIMESTAMP */ - for (i = 0; i < len; i++) { - printk("%c", pdata[i]); - } - printk("\n"); - -} /* dump_str() */ -#endif /* CSR_ONLY_NOTES */ - - -#endif /* UNIFI_DEBUG */ - - -/* --------------------------------------------------------------------------- - * - End - - * ------------------------------------------------------------------------- */ diff --git a/drivers/staging/csr/putest.c b/drivers/staging/csr/putest.c deleted file mode 100644 index 5613cf0e16b0..000000000000 --- a/drivers/staging/csr/putest.c +++ /dev/null @@ -1,685 +0,0 @@ -/* - * *************************************************************************** - * FILE: putest.c - * - * PURPOSE: putest related functions. - * - * Copyright (C) 2008-2009 by Cambridge Silicon Radio Ltd. - * - * Refer to LICENSE.txt included with this source code for details on - * the license terms. - * - * *************************************************************************** - */ - -#include -#include - -#include "unifi_priv.h" -#include "csr_wifi_hip_chiphelper.h" - -#define UNIFI_PROC_BOTH 3 - - -int unifi_putest_cmd52_read(unifi_priv_t *priv, unsigned char *arg) -{ - struct unifi_putest_cmd52 cmd52_params; - u8 *arg_pos; - unsigned int cmd_param_size; - int r; - CsrResult csrResult; - unsigned char ret_buffer[32]; - u8 *ret_buffer_pos; - u8 retries; - - arg_pos = (u8*)(((unifi_putest_command_t*)arg) + 1); - if (get_user(cmd_param_size, (int*)arg_pos)) { - unifi_error(priv, - "unifi_putest_cmd52_read: Failed to get the argument\n"); - return -EFAULT; - } - - if (cmd_param_size != sizeof(struct unifi_putest_cmd52)) { - unifi_error(priv, - "unifi_putest_cmd52_read: cmd52 struct mismatch\n"); - return -EINVAL; - } - - arg_pos += sizeof(unsigned int); - if (copy_from_user(&cmd52_params, - (void*)arg_pos, - sizeof(struct unifi_putest_cmd52))) { - unifi_error(priv, - "unifi_putest_cmd52_read: Failed to get the cmd52 params\n"); - return -EFAULT; - } - - unifi_trace(priv, UDBG2, "cmd52r: func=%d addr=0x%x ", - cmd52_params.funcnum, cmd52_params.addr); - - retries = 3; - CsrSdioClaim(priv->sdio); - do { - if (cmd52_params.funcnum == 0) { - csrResult = CsrSdioF0Read8(priv->sdio, cmd52_params.addr, &cmd52_params.data); - } else { - csrResult = CsrSdioRead8(priv->sdio, cmd52_params.addr, &cmd52_params.data); - } - } while (--retries && ((csrResult == CSR_SDIO_RESULT_CRC_ERROR) || (csrResult == CSR_SDIO_RESULT_TIMEOUT))); - CsrSdioRelease(priv->sdio); - - if (csrResult != CSR_RESULT_SUCCESS) { - unifi_error(priv, - "\nunifi_putest_cmd52_read: Read8() failed (csrResult=0x%x)\n", csrResult); - return -EFAULT; - } - unifi_trace(priv, UDBG2, "data=%d\n", cmd52_params.data); - - /* Copy the info to the out buffer */ - *(unifi_putest_command_t*)ret_buffer = UNIFI_PUTEST_CMD52_READ; - ret_buffer_pos = (u8*)(((unifi_putest_command_t*)ret_buffer) + 1); - *(unsigned int*)ret_buffer_pos = sizeof(struct unifi_putest_cmd52); - ret_buffer_pos += sizeof(unsigned int); - memcpy(ret_buffer_pos, &cmd52_params, sizeof(struct unifi_putest_cmd52)); - ret_buffer_pos += sizeof(struct unifi_putest_cmd52); - - r = copy_to_user((void*)arg, - ret_buffer, - ret_buffer_pos - ret_buffer); - if (r) { - unifi_error(priv, - "unifi_putest_cmd52_read: Failed to return the data\n"); - return -EFAULT; - } - - return 0; -} - - -int unifi_putest_cmd52_write(unifi_priv_t *priv, unsigned char *arg) -{ - struct unifi_putest_cmd52 cmd52_params; - u8 *arg_pos; - unsigned int cmd_param_size; - CsrResult csrResult; - u8 retries; - - arg_pos = (u8*)(((unifi_putest_command_t*)arg) + 1); - if (get_user(cmd_param_size, (int*)arg_pos)) { - unifi_error(priv, - "unifi_putest_cmd52_write: Failed to get the argument\n"); - return -EFAULT; - } - - if (cmd_param_size != sizeof(struct unifi_putest_cmd52)) { - unifi_error(priv, - "unifi_putest_cmd52_write: cmd52 struct mismatch\n"); - return -EINVAL; - } - - arg_pos += sizeof(unsigned int); - if (copy_from_user(&cmd52_params, - (void*)(arg_pos), - sizeof(struct unifi_putest_cmd52))) { - unifi_error(priv, - "unifi_putest_cmd52_write: Failed to get the cmd52 params\n"); - return -EFAULT; - } - - unifi_trace(priv, UDBG2, "cmd52w: func=%d addr=0x%x data=%d\n", - cmd52_params.funcnum, cmd52_params.addr, cmd52_params.data); - - retries = 3; - CsrSdioClaim(priv->sdio); - do { - if (cmd52_params.funcnum == 0) { - csrResult = CsrSdioF0Write8(priv->sdio, cmd52_params.addr, cmd52_params.data); - } else { - csrResult = CsrSdioWrite8(priv->sdio, cmd52_params.addr, cmd52_params.data); - } - } while (--retries && ((csrResult == CSR_SDIO_RESULT_CRC_ERROR) || (csrResult == CSR_SDIO_RESULT_TIMEOUT))); - CsrSdioRelease(priv->sdio); - - if (csrResult != CSR_RESULT_SUCCESS) { - unifi_error(priv, - "unifi_putest_cmd52_write: Write8() failed (csrResult=0x%x)\n", csrResult); - return -EFAULT; - } - - return 0; -} - -int unifi_putest_gp_read16(unifi_priv_t *priv, unsigned char *arg) -{ - struct unifi_putest_gp_rw16 gp_r16_params; - u8 *arg_pos; - unsigned int cmd_param_size; - int r; - CsrResult csrResult; - unsigned char ret_buffer[32]; - u8 *ret_buffer_pos; - - arg_pos = (u8*)(((unifi_putest_command_t*)arg) + 1); - if (get_user(cmd_param_size, (int*)arg_pos)) { - unifi_error(priv, - "unifi_putest_gp_read16: Failed to get the argument\n"); - return -EFAULT; - } - - if (cmd_param_size != sizeof(struct unifi_putest_gp_rw16)) { - unifi_error(priv, - "unifi_putest_gp_read16: struct mismatch\n"); - return -EINVAL; - } - - arg_pos += sizeof(unsigned int); - if (copy_from_user(&gp_r16_params, - (void*)arg_pos, - sizeof(struct unifi_putest_gp_rw16))) { - unifi_error(priv, - "unifi_putest_gp_read16: Failed to get the params\n"); - return -EFAULT; - } - CsrSdioClaim(priv->sdio); - csrResult = unifi_card_read16(priv->card, gp_r16_params.addr, &gp_r16_params.data); - CsrSdioRelease(priv->sdio); - if (csrResult != CSR_RESULT_SUCCESS) { - unifi_error(priv, - "unifi_putest_gp_read16: unifi_card_read16() GP=0x%x failed (csrResult=0x%x)\n", gp_r16_params.addr, csrResult); - return -EFAULT; - } - - unifi_trace(priv, UDBG2, "gp_r16: GP=0x%08x, data=0x%04x\n", gp_r16_params.addr, gp_r16_params.data); - - /* Copy the info to the out buffer */ - *(unifi_putest_command_t*)ret_buffer = UNIFI_PUTEST_GP_READ16; - ret_buffer_pos = (u8*)(((unifi_putest_command_t*)ret_buffer) + 1); - *(unsigned int*)ret_buffer_pos = sizeof(struct unifi_putest_gp_rw16); - ret_buffer_pos += sizeof(unsigned int); - memcpy(ret_buffer_pos, &gp_r16_params, sizeof(struct unifi_putest_gp_rw16)); - ret_buffer_pos += sizeof(struct unifi_putest_gp_rw16); - - r = copy_to_user((void*)arg, - ret_buffer, - ret_buffer_pos - ret_buffer); - if (r) { - unifi_error(priv, - "unifi_putest_gp_read16: Failed to return the data\n"); - return -EFAULT; - } - - return 0; -} - -int unifi_putest_gp_write16(unifi_priv_t *priv, unsigned char *arg) -{ - struct unifi_putest_gp_rw16 gp_w16_params; - u8 *arg_pos; - unsigned int cmd_param_size; - CsrResult csrResult; - - arg_pos = (u8*)(((unifi_putest_command_t*)arg) + 1); - if (get_user(cmd_param_size, (int*)arg_pos)) { - unifi_error(priv, - "unifi_putest_gp_write16: Failed to get the argument\n"); - return -EFAULT; - } - - if (cmd_param_size != sizeof(struct unifi_putest_gp_rw16)) { - unifi_error(priv, - "unifi_putest_gp_write16: struct mismatch\n"); - return -EINVAL; - } - - arg_pos += sizeof(unsigned int); - if (copy_from_user(&gp_w16_params, - (void*)(arg_pos), - sizeof(struct unifi_putest_gp_rw16))) { - unifi_error(priv, - "unifi_putest_gp_write16: Failed to get the params\n"); - return -EFAULT; - } - - unifi_trace(priv, UDBG2, "gp_w16: GP=0x%08x, data=0x%04x\n", gp_w16_params.addr, gp_w16_params.data); - CsrSdioClaim(priv->sdio); - csrResult = unifi_card_write16(priv->card, gp_w16_params.addr, gp_w16_params.data); - CsrSdioRelease(priv->sdio); - if (csrResult != CSR_RESULT_SUCCESS) { - unifi_error(priv, - "unifi_putest_gp_write16: unifi_card_write16() GP=%x failed (csrResult=0x%x)\n", gp_w16_params.addr, csrResult); - return -EFAULT; - } - - return 0; -} - -int unifi_putest_set_sdio_clock(unifi_priv_t *priv, unsigned char *arg) -{ - int sdio_clock_speed; - CsrResult csrResult; - - if (get_user(sdio_clock_speed, (int*)(((unifi_putest_command_t*)arg) + 1))) { - unifi_error(priv, - "unifi_putest_set_sdio_clock: Failed to get the argument\n"); - return -EFAULT; - } - - unifi_trace(priv, UDBG2, "set sdio clock: %d KHz\n", sdio_clock_speed); - - CsrSdioClaim(priv->sdio); - csrResult = CsrSdioMaxBusClockFrequencySet(priv->sdio, sdio_clock_speed * 1000); - CsrSdioRelease(priv->sdio); - if (csrResult != CSR_RESULT_SUCCESS) { - unifi_error(priv, - "unifi_putest_set_sdio_clock: Set clock failed (csrResult=0x%x)\n", csrResult); - return -EFAULT; - } - - return 0; -} - - -int unifi_putest_start(unifi_priv_t *priv, unsigned char *arg) -{ - int r; - CsrResult csrResult; - int already_in_test = priv->ptest_mode; - - /* Ensure that sme_sys_suspend() doesn't power down the chip because: - * 1) Power is needed anyway for ptest. - * 2) The app code uses the START ioctl as a reset, so it gets called - * multiple times. If the app stops the XAPs, but the power_down/up - * sequence doesn't actually power down the chip, there can be problems - * resetting, because part of the power_up sequence disables function 1 - */ - priv->ptest_mode = 1; - - /* Suspend the SME and UniFi */ - if (priv->sme_cli) { - r = sme_sys_suspend(priv); - if (r) { - unifi_error(priv, - "unifi_putest_start: failed to suspend UniFi\n"); - return r; - } - } - - /* Application may have stopped the XAPs, but they are needed for reset */ - if (already_in_test) { - CsrSdioClaim(priv->sdio); - csrResult = unifi_start_processors(priv->card); - CsrSdioRelease(priv->sdio); - if (csrResult != CSR_RESULT_SUCCESS) { - unifi_error(priv, "Failed to start XAPs. Hard reset required.\n"); - } - } else { - /* Ensure chip is powered for the case where there's no unifi_helper */ - CsrSdioClaim(priv->sdio); - csrResult = CsrSdioPowerOn(priv->sdio); - CsrSdioRelease(priv->sdio); - if (csrResult != CSR_RESULT_SUCCESS) { - unifi_error(priv, "CsrSdioPowerOn csrResult = %d\n", csrResult); - } - } - CsrSdioClaim(priv->sdio); - csrResult = unifi_init(priv->card); - CsrSdioRelease(priv->sdio); - if (csrResult != CSR_RESULT_SUCCESS) { - unifi_error(priv, - "unifi_putest_start: failed to init UniFi\n"); - return CsrHipResultToStatus(csrResult); - } - - return 0; -} - - -int unifi_putest_stop(unifi_priv_t *priv, unsigned char *arg) -{ - int r = 0; - CsrResult csrResult; - - /* Application may have stopped the XAPs, but they are needed for reset */ - CsrSdioClaim(priv->sdio); - csrResult = unifi_start_processors(priv->card); - CsrSdioRelease(priv->sdio); - if (csrResult != CSR_RESULT_SUCCESS) { - unifi_error(priv, "Failed to start XAPs. Hard reset required.\n"); - } - - /* PUTEST_STOP is also used to resume the XAPs after SME coredump. - * Don't power off the chip, leave that to the normal wifi-off which is - * about to carry on. No need to resume the SME either, as it wasn't suspended. - */ - if (priv->coredump_mode) { - priv->coredump_mode = 0; - return 0; - } - - /* At this point function 1 is enabled and the XAPs are running, so it is - * safe to let the card power down. Power is restored later, asynchronously, - * during the wifi_on requested by the SME. - */ - CsrSdioClaim(priv->sdio); - CsrSdioPowerOff(priv->sdio); - CsrSdioRelease(priv->sdio); - - /* Resume the SME and UniFi */ - if (priv->sme_cli) { - r = sme_sys_resume(priv); - if (r) { - unifi_error(priv, - "unifi_putest_stop: failed to resume SME\n"); - } - } - priv->ptest_mode = 0; - - return r; -} - - -int unifi_putest_dl_fw(unifi_priv_t *priv, unsigned char *arg) -{ -#define UF_PUTEST_MAX_FW_FILE_NAME 16 -#define UNIFI_MAX_FW_PATH_LEN 32 - unsigned int fw_name_length; - unsigned char fw_name[UF_PUTEST_MAX_FW_FILE_NAME+1]; - unsigned char *name_buffer; - int postfix; - char fw_path[UNIFI_MAX_FW_PATH_LEN]; - const struct firmware *fw_entry; - struct dlpriv temp_fw_sta; - int r; - CsrResult csrResult; - - /* Get the f/w file name length */ - if (get_user(fw_name_length, (unsigned int*)(((unifi_putest_command_t*)arg) + 1))) { - unifi_error(priv, - "unifi_putest_dl_fw: Failed to get the length argument\n"); - return -EFAULT; - } - - unifi_trace(priv, UDBG2, "unifi_putest_dl_fw: file name size = %d\n", fw_name_length); - - /* Sanity check for the f/w file name length */ - if (fw_name_length > UF_PUTEST_MAX_FW_FILE_NAME) { - unifi_error(priv, - "unifi_putest_dl_fw: F/W file name is too long\n"); - return -EINVAL; - } - - /* Get the f/w file name */ - name_buffer = ((unsigned char*)arg) + sizeof(unifi_putest_command_t) + sizeof(unsigned int); - if (copy_from_user(fw_name, (void*)name_buffer, fw_name_length)) { - unifi_error(priv, "unifi_putest_dl_fw: Failed to get the file name\n"); - return -EFAULT; - } - fw_name[fw_name_length] = '\0'; - unifi_trace(priv, UDBG2, "unifi_putest_dl_fw: file = %s\n", fw_name); - - /* Keep the existing f/w to a temp, we need to restore it later */ - temp_fw_sta = priv->fw_sta; - - /* Get the putest f/w */ - postfix = priv->instance; - scnprintf(fw_path, UNIFI_MAX_FW_PATH_LEN, "unifi-sdio-%d/%s", - postfix, fw_name); - r = request_firmware(&fw_entry, fw_path, priv->unifi_device); - if (r == 0) { - priv->fw_sta.fw_desc = (void *)fw_entry; - priv->fw_sta.dl_data = fw_entry->data; - priv->fw_sta.dl_len = fw_entry->size; - } else { - unifi_error(priv, "Firmware file not available\n"); - return -EINVAL; - } - - /* Application may have stopped the XAPs, but they are needed for reset */ - CsrSdioClaim(priv->sdio); - csrResult = unifi_start_processors(priv->card); - CsrSdioRelease(priv->sdio); - if (csrResult != CSR_RESULT_SUCCESS) { - unifi_error(priv, "Failed to start XAPs. Hard reset required.\n"); - } - - /* Download the f/w. On UF6xxx this will cause the f/w file to convert - * into patch format and download via the ROM boot loader - */ - CsrSdioClaim(priv->sdio); - csrResult = unifi_download(priv->card, 0x0c00); - CsrSdioRelease(priv->sdio); - if (csrResult != CSR_RESULT_SUCCESS) { - unifi_error(priv, - "unifi_putest_dl_fw: failed to download the f/w\n"); - goto free_fw; - } - - /* Free the putest f/w... */ -free_fw: - uf_release_firmware(priv, &priv->fw_sta); - /* ... and restore the original f/w */ - priv->fw_sta = temp_fw_sta; - - return CsrHipResultToStatus(csrResult); -} - - -int unifi_putest_dl_fw_buff(unifi_priv_t *priv, unsigned char *arg) -{ - unsigned int fw_length; - unsigned char *fw_buf = NULL; - unsigned char *fw_user_ptr; - struct dlpriv temp_fw_sta; - CsrResult csrResult; - - /* Get the f/w buffer length */ - if (get_user(fw_length, (unsigned int*)(((unifi_putest_command_t*)arg) + 1))) { - unifi_error(priv, - "unifi_putest_dl_fw_buff: Failed to get the length arg\n"); - return -EFAULT; - } - - unifi_trace(priv, UDBG2, "unifi_putest_dl_fw_buff: size = %d\n", fw_length); - - /* Sanity check for the buffer length */ - if (fw_length == 0 || fw_length > 0xfffffff) { - unifi_error(priv, - "unifi_putest_dl_fw_buff: buffer length bad %u\n", fw_length); - return -EINVAL; - } - - /* Buffer for kernel copy of the f/w image */ - fw_buf = kmalloc(fw_length, GFP_KERNEL); - if (!fw_buf) { - unifi_error(priv, "unifi_putest_dl_fw_buff: malloc fail\n"); - return -ENOMEM; - } - - /* Get the f/w image */ - fw_user_ptr = ((unsigned char*)arg) + sizeof(unifi_putest_command_t) + sizeof(unsigned int); - if (copy_from_user(fw_buf, (void*)fw_user_ptr, fw_length)) { - unifi_error(priv, "unifi_putest_dl_fw_buff: Failed to get the buffer\n"); - kfree(fw_buf); - return -EFAULT; - } - - /* Save the existing f/w to a temp, we need to restore it later */ - temp_fw_sta = priv->fw_sta; - - /* Setting fw_desc NULL indicates to the core that no f/w file was loaded - * via the kernel request_firmware() mechanism. This indicates to the core - * that it shouldn't call release_firmware() after the download is done. - */ - priv->fw_sta.fw_desc = NULL; /* No OS f/w resource */ - priv->fw_sta.dl_data = fw_buf; - priv->fw_sta.dl_len = fw_length; - - /* Application may have stopped the XAPs, but they are needed for reset */ - CsrSdioClaim(priv->sdio); - csrResult = unifi_start_processors(priv->card); - CsrSdioRelease(priv->sdio); - if (csrResult != CSR_RESULT_SUCCESS) { - unifi_error(priv, "Failed to start XAPs. Hard reset required.\n"); - } - - /* Download the f/w. On UF6xxx this will cause the f/w file to convert - * into patch format and download via the ROM boot loader - */ - CsrSdioClaim(priv->sdio); - csrResult = unifi_download(priv->card, 0x0c00); - CsrSdioRelease(priv->sdio); - if (csrResult != CSR_RESULT_SUCCESS) { - unifi_error(priv, - "unifi_putest_dl_fw_buff: failed to download the f/w\n"); - goto free_fw; - } - -free_fw: - /* Finished with the putest f/w, so restore the station f/w */ - priv->fw_sta = temp_fw_sta; - kfree(fw_buf); - - return CsrHipResultToStatus(csrResult); -} - - -int unifi_putest_coredump_prepare(unifi_priv_t *priv, unsigned char *arg) -{ - u16 data_u16; - s32 i; - CsrResult r; - - unifi_info(priv, "Preparing for SDIO coredump\n"); -#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) - unifi_debug_buf_dump(); -#endif - - /* Sanity check that userspace hasn't called a PUTEST_START, because that - * would have reset UniFi, potentially power cycling it and losing context - */ - if (priv->ptest_mode) { - unifi_error(priv, "PUTEST_START shouldn't be used before a coredump\n"); - } - - /* Flag that the userspace has requested coredump. Even if this preparation - * fails, the SME will call PUTEST_STOP to tidy up. - */ - priv->coredump_mode = 1; - - for (i = 0; i < 3; i++) { - CsrSdioClaim(priv->sdio); - r = CsrSdioRead16(priv->sdio, CHIP_HELPER_UNIFI_GBL_CHIP_VERSION*2, &data_u16); - CsrSdioRelease(priv->sdio); - if (r != CSR_RESULT_SUCCESS) { - unifi_info(priv, "Failed to read chip version! Try %d\n", i); - - /* First try, re-enable function which may have been disabled by f/w panic */ - if (i == 0) { - unifi_info(priv, "Try function enable\n"); - CsrSdioClaim(priv->sdio); - r = CsrSdioFunctionEnable(priv->sdio); - CsrSdioRelease(priv->sdio); - if (r != CSR_RESULT_SUCCESS) { - unifi_error(priv, "CsrSdioFunctionEnable failed %d\n", r); - } - continue; - } - - /* Subsequent tries, reset */ - - /* Set clock speed low */ - CsrSdioClaim(priv->sdio); - r = CsrSdioMaxBusClockFrequencySet(priv->sdio, UNIFI_SDIO_CLOCK_SAFE_HZ); - CsrSdioRelease(priv->sdio); - if (r != CSR_RESULT_SUCCESS) { - unifi_error(priv, "CsrSdioMaxBusClockFrequencySet() failed %d\n", r); - } - - /* Card software reset */ - CsrSdioClaim(priv->sdio); - r = unifi_card_hard_reset(priv->card); - CsrSdioRelease(priv->sdio); - if (r != CSR_RESULT_SUCCESS) { - unifi_error(priv, "unifi_card_hard_reset() failed %d\n", r); - } - } else { - unifi_info(priv, "Read chip version of 0x%04x\n", data_u16); - break; - } - } - - if (r != CSR_RESULT_SUCCESS) { - unifi_error(priv, "Failed to prepare chip\n"); - return -EIO; - } - - /* Stop the XAPs for coredump. The PUTEST_STOP must be called, e.g. at - * Raw SDIO deinit, to resume them. - */ - CsrSdioClaim(priv->sdio); - r = unifi_card_stop_processor(priv->card, UNIFI_PROC_BOTH); - CsrSdioRelease(priv->sdio); - if (r != CSR_RESULT_SUCCESS) { - unifi_error(priv, "Failed to stop processors\n"); - } - - return 0; -} - -int unifi_putest_cmd52_block_read(unifi_priv_t *priv, unsigned char *arg) -{ - struct unifi_putest_block_cmd52_r block_cmd52; - u8 *arg_pos; - unsigned int cmd_param_size; - CsrResult r; - u8 *block_local_buffer; - - arg_pos = (u8*)(((unifi_putest_command_t*)arg) + 1); - if (get_user(cmd_param_size, (int*)arg_pos)) { - unifi_error(priv, - "cmd52r_block: Failed to get the argument\n"); - return -EFAULT; - } - - if (cmd_param_size != sizeof(struct unifi_putest_block_cmd52_r)) { - unifi_error(priv, - "cmd52r_block: cmd52 struct mismatch\n"); - return -EINVAL; - } - - arg_pos += sizeof(unsigned int); - if (copy_from_user(&block_cmd52, - (void*)arg_pos, - sizeof(struct unifi_putest_block_cmd52_r))) { - unifi_error(priv, - "cmd52r_block: Failed to get the cmd52 params\n"); - return -EFAULT; - } - - unifi_trace(priv, UDBG2, "cmd52r_block: func=%d addr=0x%x len=0x%x ", - block_cmd52.funcnum, block_cmd52.addr, block_cmd52.length); - - block_local_buffer = vmalloc(block_cmd52.length); - if (block_local_buffer == NULL) { - unifi_error(priv, "cmd52r_block: Failed to allocate buffer\n"); - return -ENOMEM; - } - - CsrSdioClaim(priv->sdio); - r = unifi_card_readn(priv->card, block_cmd52.addr, block_local_buffer, block_cmd52.length); - CsrSdioRelease(priv->sdio); - if (r != CSR_RESULT_SUCCESS) { - unifi_error(priv, "cmd52r_block: unifi_readn failed\n"); - return -EIO; - } - - if (copy_to_user((void*)block_cmd52.data, - block_local_buffer, - block_cmd52.length)) { - unifi_error(priv, - "cmd52r_block: Failed to return the data\n"); - return -EFAULT; - } - - return 0; -} diff --git a/drivers/staging/csr/sdio_events.c b/drivers/staging/csr/sdio_events.c deleted file mode 100644 index 2a80b9eb0200..000000000000 --- a/drivers/staging/csr/sdio_events.c +++ /dev/null @@ -1,134 +0,0 @@ -/* - * --------------------------------------------------------------------------- - * FILE: sdio_events.c - * - * PURPOSE: - * Process the events received by the SDIO glue layer. - * Optional part of the porting exercise. - * - * Copyright (C) 2009 by Cambridge Silicon Radio Ltd. - * - * Refer to LICENSE.txt included with this source code for details on - * the license terms. - * - * --------------------------------------------------------------------------- - */ -#include "unifi_priv.h" - - -/* - * Porting Notes: - * There are two ways to support the suspend/resume system events in a driver. - * In some operating systems these events are delivered to the OS driver - * directly from the system. In this case, the OS driver needs to pass these - * events to the API described in the CSR SDIO Abstration API document. - * In Linux, and other embedded operating systems, the suspend/resume events - * come from the SDIO driver. In this case, simply get these events in the - * SDIO glue layer and notify the OS layer. - * - * In either case, typically, the events are processed by the SME. - * Use the unifi_sys_suspend_ind() and unifi_sys_resume_ind() to pass - * the events to the SME. - */ - -/* - * --------------------------------------------------------------------------- - * unifi_suspend - * - * Handles a suspend request from the SDIO driver. - * - * Arguments: - * ospriv Pointer to OS driver context. - * - * --------------------------------------------------------------------------- - */ -void unifi_suspend(void *ospriv) -{ - unifi_priv_t *priv = ospriv; - int interfaceTag=0; - - /* For powered suspend, tell the resume's wifi_on() not to reinit UniFi */ - priv->wol_suspend = (enable_wol == UNIFI_WOL_OFF) ? FALSE : TRUE; - - unifi_trace(priv, UDBG1, "unifi_suspend: wol_suspend %d, enable_wol %d", - priv->wol_suspend, enable_wol ); - - /* Stop network traffic. */ - /* need to stop all the netdevices*/ - for( interfaceTag=0;interfaceTaginterfacePriv[interfaceTag]; - if (interfacePriv->netdev_registered == 1) - { - if( priv->wol_suspend ) { - unifi_trace(priv, UDBG1, "unifi_suspend: Don't netif_carrier_off"); - } else { - unifi_trace(priv, UDBG1, "unifi_suspend: netif_carrier_off"); - netif_carrier_off(priv->netdev[interfaceTag]); - } - netif_tx_stop_all_queues(priv->netdev[interfaceTag]); - } - } - - unifi_trace(priv, UDBG1, "unifi_suspend: suspend SME"); - - sme_sys_suspend(priv); - -} /* unifi_suspend() */ - - -/* - * --------------------------------------------------------------------------- - * unifi_resume - * - * Handles a resume request from the SDIO driver. - * - * Arguments: - * ospriv Pointer to OS driver context. - * - * --------------------------------------------------------------------------- - */ -void unifi_resume(void *ospriv) -{ - unifi_priv_t *priv = ospriv; - int interfaceTag=0; - int r; - int wol = priv->wol_suspend; - - unifi_trace(priv, UDBG1, "unifi_resume: resume SME, enable_wol=%d", enable_wol); - - /* The resume causes wifi-on which will re-enable the BH and reinstall the ISR */ - r = sme_sys_resume(priv); - if (r) { - unifi_error(priv, "Failed to resume UniFi\n"); - } - - /* Resume the network interfaces. For the cold resume case, this will - * happen upon reconnection. - */ - if (wol) { - unifi_trace(priv, UDBG1, "unifi_resume: try to enable carrier"); - - /* need to start all the netdevices*/ - for( interfaceTag=0;interfaceTaginterfacePriv[interfaceTag]; - - unifi_trace(priv, UDBG1, "unifi_resume: interfaceTag %d netdev_registered %d mode %d\n", - interfaceTag, interfacePriv->netdev_registered, interfacePriv->interfaceMode); - - if (interfacePriv->netdev_registered == 1) - { - netif_carrier_on(priv->netdev[interfaceTag]); - netif_tx_start_all_queues(priv->netdev[interfaceTag]); - } - } - - /* Kick the BH thread (with reason=host) to poll for data that may have - * arrived during a powered suspend. This caters for the case where the SME - * doesn't interact with the chip (e.g install autonomous scans) during resume. - */ - unifi_send_signal(priv->card, NULL, 0, NULL); - } - -} /* unifi_resume() */ - diff --git a/drivers/staging/csr/sdio_mmc.c b/drivers/staging/csr/sdio_mmc.c deleted file mode 100644 index 2b503c23efae..000000000000 --- a/drivers/staging/csr/sdio_mmc.c +++ /dev/null @@ -1,1288 +0,0 @@ -/* - * --------------------------------------------------------------------------- - * - * FILE: sdio_mmc.c - * - * PURPOSE: SDIO driver interface for generic MMC stack. - * - * Copyright (C) 2008-2009 by Cambridge Silicon Radio Ltd. - * - * --------------------------------------------------------------------------- - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "unifi_priv.h" - -#ifdef ANDROID_BUILD -struct wake_lock unifi_sdio_wake_lock; /* wakelock to prevent suspend while resuming */ -#endif - -static CsrSdioFunctionDriver *sdio_func_drv; - -#ifdef CONFIG_PM -static int uf_sdio_mmc_power_event(struct notifier_block *this, unsigned long event, void *ptr); -#endif - -/* - * We need to keep track of the power on/off because we can not call - * mmc_power_restore_host() when the card is already powered. - * Even then, we need to patch the MMC driver to add a power_restore handler - * in the mmc_sdio_ops structure. If the MMC driver before 2.6.37 is not patched, - * mmc_power_save_host() and mmc_power_restore_host() are no-ops in the kernel, - * returning immediately (at least on x86). - */ -static int card_is_powered = 1; - -/* MMC uses ENOMEDIUM to indicate card gone away */ - -static CsrResult -ConvertSdioToCsrSdioResult(int r) -{ - CsrResult csrResult = CSR_RESULT_FAILURE; - - switch (r) { - case 0: - csrResult = CSR_RESULT_SUCCESS; - break; - case -EIO: - case -EILSEQ: - csrResult = CSR_SDIO_RESULT_CRC_ERROR; - break; - /* Timeout errors */ - case -ETIMEDOUT: - case -EBUSY: - csrResult = CSR_SDIO_RESULT_TIMEOUT; - break; - case -ENODEV: - case -ENOMEDIUM: - csrResult = CSR_SDIO_RESULT_NO_DEVICE; - break; - case -EINVAL: - csrResult = CSR_SDIO_RESULT_INVALID_VALUE; - break; - case -ENOMEM: - case -ENOSYS: - case -ERANGE: - case -ENXIO: - csrResult = CSR_RESULT_FAILURE; - break; - default: - unifi_warning(NULL, "Unrecognised SDIO error code: %d\n", r); - break; - } - - return csrResult; -} - - -static int -csr_io_rw_direct(struct mmc_card *card, int write, uint8_t fn, - uint32_t addr, uint8_t in, uint8_t* out) -{ - struct mmc_command cmd; - int err; - - BUG_ON(!card); - BUG_ON(fn > 7); - - memset(&cmd, 0, sizeof(struct mmc_command)); - - cmd.opcode = SD_IO_RW_DIRECT; - cmd.arg = write ? 0x80000000 : 0x00000000; - cmd.arg |= fn << 28; - cmd.arg |= (write && out) ? 0x08000000 : 0x00000000; - cmd.arg |= addr << 9; - cmd.arg |= in; - cmd.flags = MMC_RSP_SPI_R5 | MMC_RSP_R5 | MMC_CMD_AC; - - err = mmc_wait_for_cmd(card->host, &cmd, 0); - if (err) - return err; - - /* this function is not exported, so we will need to sort it out here - * for now, lets hard code it to sdio */ - if (0) { - /* old arg (mmc_host_is_spi(card->host)) { */ - /* host driver already reported errors */ - } else { - if (cmd.resp[0] & R5_ERROR) { - printk(KERN_ERR "%s: r5 error 0x%02x\n", - __FUNCTION__, cmd.resp[0]); - return -EIO; - } - if (cmd.resp[0] & R5_FUNCTION_NUMBER) - return -EINVAL; - if (cmd.resp[0] & R5_OUT_OF_RANGE) - return -ERANGE; - } - - if (out) { - if (0) { /* old argument (mmc_host_is_spi(card->host)) */ - *out = (cmd.resp[0] >> 8) & 0xFF; - } - else { - *out = cmd.resp[0] & 0xFF; - } - } - - return CSR_RESULT_SUCCESS; -} - - -CsrResult -CsrSdioRead8(CsrSdioFunction *function, u32 address, u8 *data) -{ - struct sdio_func *func = (struct sdio_func *)function->priv; - int err = 0; - - _sdio_claim_host(func); - *data = sdio_readb(func, address, &err); - _sdio_release_host(func); - - if (err) { - return ConvertSdioToCsrSdioResult(err); - } - - return CSR_RESULT_SUCCESS; -} /* CsrSdioRead8() */ - -CsrResult -CsrSdioWrite8(CsrSdioFunction *function, u32 address, u8 data) -{ - struct sdio_func *func = (struct sdio_func *)function->priv; - int err = 0; - - _sdio_claim_host(func); - sdio_writeb(func, data, address, &err); - _sdio_release_host(func); - - if (err) { - return ConvertSdioToCsrSdioResult(err); - } - - return CSR_RESULT_SUCCESS; -} /* CsrSdioWrite8() */ - -CsrResult -CsrSdioRead16(CsrSdioFunction *function, u32 address, u16 *data) -{ - struct sdio_func *func = (struct sdio_func *)function->priv; - int err; - uint8_t b0, b1; - - _sdio_claim_host(func); - b0 = sdio_readb(func, address, &err); - if (err) { - _sdio_release_host(func); - return ConvertSdioToCsrSdioResult(err); - } - - b1 = sdio_readb(func, address+1, &err); - if (err) { - _sdio_release_host(func); - return ConvertSdioToCsrSdioResult(err); - } - _sdio_release_host(func); - - *data = ((uint16_t)b1 << 8) | b0; - - return CSR_RESULT_SUCCESS; -} /* CsrSdioRead16() */ - - -CsrResult -CsrSdioWrite16(CsrSdioFunction *function, u32 address, u16 data) -{ - struct sdio_func *func = (struct sdio_func *)function->priv; - int err; - uint8_t b0, b1; - - _sdio_claim_host(func); - b1 = (data >> 8) & 0xFF; - sdio_writeb(func, b1, address+1, &err); - if (err) { - _sdio_release_host(func); - return ConvertSdioToCsrSdioResult(err); - } - - b0 = data & 0xFF; - sdio_writeb(func, b0, address, &err); - if (err) { - _sdio_release_host(func); - return ConvertSdioToCsrSdioResult(err); - } - - _sdio_release_host(func); - return CSR_RESULT_SUCCESS; -} /* CsrSdioWrite16() */ - - -CsrResult -CsrSdioF0Read8(CsrSdioFunction *function, u32 address, u8 *data) -{ - struct sdio_func *func = (struct sdio_func *)function->priv; - int err = 0; - - _sdio_claim_host(func); -#ifdef MMC_QUIRK_LENIENT_FN0 - *data = sdio_f0_readb(func, address, &err); -#else - err = csr_io_rw_direct(func->card, 0, 0, address, 0, data); -#endif - _sdio_release_host(func); - - if (err) { - return ConvertSdioToCsrSdioResult(err); - } - - return CSR_RESULT_SUCCESS; -} /* CsrSdioF0Read8() */ - -CsrResult -CsrSdioF0Write8(CsrSdioFunction *function, u32 address, u8 data) -{ - struct sdio_func *func = (struct sdio_func *)function->priv; - int err = 0; - - _sdio_claim_host(func); -#ifdef MMC_QUIRK_LENIENT_FN0 - sdio_f0_writeb(func, data, address, &err); -#else - err = csr_io_rw_direct(func->card, 1, 0, address, data, NULL); -#endif - _sdio_release_host(func); - - if (err) { - return ConvertSdioToCsrSdioResult(err); - } - - return CSR_RESULT_SUCCESS; -} /* CsrSdioF0Write8() */ - - -CsrResult -CsrSdioRead(CsrSdioFunction *function, u32 address, void *data, u32 length) -{ - struct sdio_func *func = (struct sdio_func *)function->priv; - int err; - - _sdio_claim_host(func); - err = sdio_readsb(func, data, address, length); - _sdio_release_host(func); - - if (err) { - return ConvertSdioToCsrSdioResult(err); - } - - return CSR_RESULT_SUCCESS; -} /* CsrSdioRead() */ - -CsrResult -CsrSdioWrite(CsrSdioFunction *function, u32 address, const void *data, u32 length) -{ - struct sdio_func *func = (struct sdio_func *)function->priv; - int err; - - _sdio_claim_host(func); - err = sdio_writesb(func, address, (void*)data, length); - _sdio_release_host(func); - - if (err) { - return ConvertSdioToCsrSdioResult(err); - } - - return CSR_RESULT_SUCCESS; -} /* CsrSdioWrite() */ - - -static int -csr_sdio_enable_hs(struct mmc_card *card) -{ - int ret; - u8 speed; - - if (!(card->host->caps & MMC_CAP_SD_HIGHSPEED)) { - /* We've asked for HS clock rates, but controller doesn't - * claim to support it. We should limit the clock - * to 25MHz via module parameter. - */ - printk(KERN_INFO "unifi: request HS but not MMC_CAP_SD_HIGHSPEED"); - return 0; - } - - if (!card->cccr.high_speed) - return 0; - -#if 1 - ret = csr_io_rw_direct(card, 0, 0, SDIO_CCCR_SPEED, 0, &speed); - if (ret) - return ret; - - speed |= SDIO_SPEED_EHS; -#else - /* Optimisation: Eliminate read by always assuming SHS and that reserved bits can be zero */ - speed = SDIO_SPEED_EHS | SDIO_SPEED_SHS; -#endif - - ret = csr_io_rw_direct(card, 1, 0, SDIO_CCCR_SPEED, speed, NULL); - if (ret) - return ret; - - mmc_card_set_highspeed(card); - card->host->ios.timing = MMC_TIMING_SD_HS; - card->host->ops->set_ios(card->host, &card->host->ios); - - return 0; -} - -static int -csr_sdio_disable_hs(struct mmc_card *card) -{ - int ret; - u8 speed; - - if (!(card->host->caps & MMC_CAP_SD_HIGHSPEED)) - return 0; - - if (!card->cccr.high_speed) - return 0; -#if 1 - ret = csr_io_rw_direct(card, 0, 0, SDIO_CCCR_SPEED, 0, &speed); - if (ret) - return ret; - - speed &= ~SDIO_SPEED_EHS; -#else - /* Optimisation: Eliminate read by always assuming SHS and that reserved bits can be zero */ - speed = SDIO_SPEED_SHS; /* clear SDIO_SPEED_EHS */ -#endif - - ret = csr_io_rw_direct(card, 1, 0, SDIO_CCCR_SPEED, speed, NULL); - if (ret) - return ret; - - card->state &= ~MMC_STATE_HIGHSPEED; - card->host->ios.timing = MMC_TIMING_LEGACY; - card->host->ops->set_ios(card->host, &card->host->ios); - - return 0; -} - - -/* - * --------------------------------------------------------------------------- - * CsrSdioMaxBusClockFrequencySet - * - * Set the maximum SDIO bus clock speed to use. - * - * Arguments: - * sdio SDIO context pointer - * maxFrequency maximum clock speed in Hz - * - * Returns: - * an error code. - * --------------------------------------------------------------------------- - */ -CsrResult -CsrSdioMaxBusClockFrequencySet(CsrSdioFunction *function, u32 maxFrequency) -{ - struct sdio_func *func = (struct sdio_func *)function->priv; - struct mmc_host *host = func->card->host; - struct mmc_ios *ios = &host->ios; - unsigned int max_hz; - int err; - u32 max_khz = maxFrequency/1000; - - if (!max_khz || max_khz > sdio_clock) { - max_khz = sdio_clock; - } - - _sdio_claim_host(func); - max_hz = 1000 * max_khz; - if (max_hz > host->f_max) { - max_hz = host->f_max; - } - - if (max_hz > 25000000) { - err = csr_sdio_enable_hs(func->card); - } else { - err = csr_sdio_disable_hs(func->card); - } - if (err) { - printk(KERN_ERR "SDIO warning: Failed to configure SDIO clock mode\n"); - _sdio_release_host(func); - return CSR_RESULT_SUCCESS; - } - - ios->clock = max_hz; - host->ops->set_ios(host, ios); - - _sdio_release_host(func); - - return CSR_RESULT_SUCCESS; -} /* CsrSdioMaxBusClockFrequencySet() */ - - -/* - * --------------------------------------------------------------------------- - * CsrSdioInterruptEnable - * CsrSdioInterruptDisable - * - * Enable or disable the SDIO interrupt. - * The driver disables the SDIO interrupt until the i/o thread can - * process it. - * The SDIO interrupt can be disabled by modifying the SDIO_INT_ENABLE - * register in the Card Common Control Register block, but this requires - * two CMD52 operations. A better solution is to mask the interrupt at - * the host controller. - * - * Arguments: - * sdio SDIO context pointer - * - * Returns: - * Zero on success or a UniFi driver error code. - * - * --------------------------------------------------------------------------- - */ -CsrResult -CsrSdioInterruptEnable(CsrSdioFunction *function) -{ - struct sdio_func *func = (struct sdio_func *)function->priv; - int err = 0; - -#ifdef CSR_CONFIG_MMC_INT_BYPASS_KSOFTIRQD - sdio_unblock_card_irq(func); -#else - _sdio_claim_host(func); - /* Write the Int Enable in CCCR block */ -#ifdef MMC_QUIRK_LENIENT_FN0 - sdio_f0_writeb(func, 0x3, SDIO_CCCR_IENx, &err); -#else - err = csr_io_rw_direct(func->card, 1, 0, SDIO_CCCR_IENx, 0x03, NULL); -#endif - _sdio_release_host(func); - - if (err) { - printk(KERN_ERR "unifi: %s: error %d writing IENx\n", __FUNCTION__, err); - return ConvertSdioToCsrSdioResult(err); - } -#endif - return CSR_RESULT_SUCCESS; -} /* CsrSdioInterruptEnable() */ - -CsrResult -CsrSdioInterruptDisable(CsrSdioFunction *function) -{ - struct sdio_func *func = (struct sdio_func *)function->priv; - int err = 0; - -#ifdef CSR_CONFIG_MMC_INT_BYPASS_KSOFTIRQD - sdio_block_card_irq(func); -#else - _sdio_claim_host(func); - /* Write the Int Enable in CCCR block */ -#ifdef MMC_QUIRK_LENIENT_FN0 - sdio_f0_writeb(func, 0, SDIO_CCCR_IENx, &err); -#else - err = csr_io_rw_direct(func->card, 1, 0, SDIO_CCCR_IENx, 0x00, NULL); -#endif - _sdio_release_host(func); - - if (err) { - printk(KERN_ERR "unifi: %s: error %d writing IENx\n", __FUNCTION__, err); - return ConvertSdioToCsrSdioResult(err); - } -#endif - return CSR_RESULT_SUCCESS; -} /* CsrSdioInterruptDisable() */ - - -void CsrSdioInterruptAcknowledge(CsrSdioFunction *function) -{ -} - - -/* - * --------------------------------------------------------------------------- - * CsrSdioFunctionEnable - * - * Enable i/o on function 1. - * - * Arguments: - * sdio SDIO context pointer - * - * Returns: - * UniFi driver error code. - * --------------------------------------------------------------------------- - */ -CsrResult -CsrSdioFunctionEnable(CsrSdioFunction *function) -{ - struct sdio_func *func = (struct sdio_func *)function->priv; - int err; - - /* Enable UniFi function 1 (the 802.11 part). */ - _sdio_claim_host(func); - err = sdio_enable_func(func); - _sdio_release_host(func); - if (err) { - unifi_error(NULL, "Failed to enable SDIO function %d\n", func->num); - } - - return ConvertSdioToCsrSdioResult(err); -} /* CsrSdioFunctionEnable() */ - - -/* - * --------------------------------------------------------------------------- - * CsrSdioFunctionDisable - * - * Enable i/o on function 1. - * - * Arguments: - * sdio SDIO context pointer - * - * Returns: - * UniFi driver error code. - * --------------------------------------------------------------------------- - */ -CsrResult -CsrSdioFunctionDisable(CsrSdioFunction *function) -{ - struct sdio_func *func = (struct sdio_func *)function->priv; - int err; - - /* Disable UniFi function 1 (the 802.11 part). */ - _sdio_claim_host(func); - err = sdio_disable_func(func); - _sdio_release_host(func); - if (err) { - unifi_error(NULL, "Failed to disable SDIO function %d\n", func->num); - } - - return ConvertSdioToCsrSdioResult(err); -} /* CsrSdioFunctionDisable() */ - - -/* - * --------------------------------------------------------------------------- - * CsrSdioFunctionActive - * - * No-op as the bus goes to an active state at the start of every - * command. - * - * Arguments: - * sdio SDIO context pointer - * --------------------------------------------------------------------------- - */ -void -CsrSdioFunctionActive(CsrSdioFunction *function) -{ -} /* CsrSdioFunctionActive() */ - -/* - * --------------------------------------------------------------------------- - * CsrSdioFunctionIdle - * - * Set the function as idle. - * - * Arguments: - * sdio SDIO context pointer - * --------------------------------------------------------------------------- - */ -void -CsrSdioFunctionIdle(CsrSdioFunction *function) -{ -} /* CsrSdioFunctionIdle() */ - - -/* - * --------------------------------------------------------------------------- - * CsrSdioPowerOn - * - * Power on UniFi. - * - * Arguments: - * sdio SDIO context pointer - * --------------------------------------------------------------------------- - */ -CsrResult -CsrSdioPowerOn(CsrSdioFunction *function) -{ - struct sdio_func *func = (struct sdio_func *)function->priv; - struct mmc_host *host = func->card->host; - - _sdio_claim_host(func); - if (!card_is_powered) { - mmc_power_restore_host(host); - card_is_powered = 1; - } else { - printk(KERN_INFO "SDIO: Skip power on; card is already powered.\n"); - } - _sdio_release_host(func); - - return CSR_RESULT_SUCCESS; -} /* CsrSdioPowerOn() */ - -/* - * --------------------------------------------------------------------------- - * CsrSdioPowerOff - * - * Power off UniFi. - * - * Arguments: - * sdio SDIO context pointer - * --------------------------------------------------------------------------- - */ -void -CsrSdioPowerOff(CsrSdioFunction *function) -{ - struct sdio_func *func = (struct sdio_func *)function->priv; - struct mmc_host *host = func->card->host; - - _sdio_claim_host(func); - if (card_is_powered) { - mmc_power_save_host(host); - card_is_powered = 0; - } else { - printk(KERN_INFO "SDIO: Skip power off; card is already powered off.\n"); - } - _sdio_release_host(func); -} /* CsrSdioPowerOff() */ - - -static int -sdio_set_block_size_ignore_first_error(struct sdio_func *func, unsigned blksz) -{ - int ret; - - if (blksz > func->card->host->max_blk_size) - return -EINVAL; - - if (blksz == 0) { - blksz = min(func->max_blksize, func->card->host->max_blk_size); - blksz = min(blksz, 512u); - } - - /* - * Ignore -ERANGE (OUT_OF_RANGE in R5) on the first byte as - * the block size may be invalid until both bytes are written. - */ - ret = csr_io_rw_direct(func->card, 1, 0, - SDIO_FBR_BASE(func->num) + SDIO_FBR_BLKSIZE, - blksz & 0xff, NULL); - if (ret && ret != -ERANGE) - return ret; - ret = csr_io_rw_direct(func->card, 1, 0, - SDIO_FBR_BASE(func->num) + SDIO_FBR_BLKSIZE + 1, - (blksz >> 8) & 0xff, NULL); - if (ret) - return ret; - func->cur_blksize = blksz; - - return 0; -} - -CsrResult -CsrSdioBlockSizeSet(CsrSdioFunction *function, u16 blockSize) -{ - struct sdio_func *func = (struct sdio_func *)function->priv; - int r = 0; - - /* Module parameter overrides */ - if (sdio_block_size > -1) { - blockSize = sdio_block_size; - } - - unifi_trace(NULL, UDBG1, "Set SDIO function block size to %d\n", - blockSize); - - _sdio_claim_host(func); - r = sdio_set_block_size(func, blockSize); - _sdio_release_host(func); - - /* - * The MMC driver for kernels prior to 2.6.32 may fail this request - * with -ERANGE. In this case use our workaround. - */ - if (r == -ERANGE) { - _sdio_claim_host(func); - r = sdio_set_block_size_ignore_first_error(func, blockSize); - _sdio_release_host(func); - } - if (r) { - unifi_error(NULL, "Error %d setting block size\n", r); - } - - /* Determine the achieved block size to pass to the core */ - function->blockSize = func->cur_blksize; - - return ConvertSdioToCsrSdioResult(r); -} /* CsrSdioBlockSizeSet() */ - - -/* - * --------------------------------------------------------------------------- - * CsrSdioHardReset - * - * Hard Resets UniFi is possible. - * - * Arguments: - * sdio SDIO context pointer - * --------------------------------------------------------------------------- - */ -CsrResult -CsrSdioHardReset(CsrSdioFunction *function) -{ - return CSR_RESULT_FAILURE; -} /* CsrSdioHardReset() */ - - - -/* - * --------------------------------------------------------------------------- - * uf_glue_sdio_int_handler - * - * Interrupt callback function for SDIO interrupts. - * This is called in kernel context (i.e. not interrupt context). - * - * Arguments: - * func SDIO context pointer - * - * Returns: - * None. - * - * Note: Called with host already claimed. - * --------------------------------------------------------------------------- - */ -static void -uf_glue_sdio_int_handler(struct sdio_func *func) -{ - CsrSdioFunction *sdio_ctx; - CsrSdioInterruptDsrCallback func_dsr_callback; - int r; - - sdio_ctx = sdio_get_drvdata(func); - if (!sdio_ctx) { - return; - } - -#ifndef CSR_CONFIG_MMC_INT_BYPASS_KSOFTIRQD - /* - * Normally, we are not allowed to do any SDIO commands here. - * However, this is called in a thread context and with the SDIO lock - * so we disable the interrupts here instead of trying to do complicated - * things with the SDIO lock. - */ -#ifdef MMC_QUIRK_LENIENT_FN0 - sdio_f0_writeb(func, 0, SDIO_CCCR_IENx, &r); -#else - r = csr_io_rw_direct(func->card, 1, 0, SDIO_CCCR_IENx, 0x00, NULL); -#endif - if (r) { - printk(KERN_ERR "UniFi MMC Int handler: Failed to disable interrupts %d\n", r); - } -#endif - - /* If the function driver has registered a handler, call it */ - if (sdio_func_drv && sdio_func_drv->intr) { - - func_dsr_callback = sdio_func_drv->intr(sdio_ctx); - - /* If interrupt handle returns a DSR handle, call it */ - if (func_dsr_callback) { - func_dsr_callback(sdio_ctx); - } - } - -} /* uf_glue_sdio_int_handler() */ - - - -/* - * --------------------------------------------------------------------------- - * csr_sdio_linux_remove_irq - * - * Unregister the interrupt handler. - * This means that the linux layer can not process interrupts any more. - * - * Arguments: - * sdio SDIO context pointer - * - * Returns: - * Status of the removal. - * --------------------------------------------------------------------------- - */ -int csr_sdio_linux_remove_irq(CsrSdioFunction *function) -{ - struct sdio_func *func = (struct sdio_func *)function->priv; - int r; - - unifi_trace(NULL, UDBG1, "csr_sdio_linux_remove_irq\n"); - - sdio_claim_host(func); - r = sdio_release_irq(func); - sdio_release_host(func); - - return r; - -} /* csr_sdio_linux_remove_irq() */ - - -/* - * --------------------------------------------------------------------------- - * csr_sdio_linux_install_irq - * - * Register the interrupt handler. - * This means that the linux layer can process interrupts. - * - * Arguments: - * sdio SDIO context pointer - * - * Returns: - * Status of the removal. - * --------------------------------------------------------------------------- - */ -int csr_sdio_linux_install_irq(CsrSdioFunction *function) -{ - struct sdio_func *func = (struct sdio_func *)function->priv; - int r; - - unifi_trace(NULL, UDBG1, "csr_sdio_linux_install_irq\n"); - - /* Register our interrupt handle */ - sdio_claim_host(func); - r = sdio_claim_irq(func, uf_glue_sdio_int_handler); - sdio_release_host(func); - - /* If the interrupt was installed earlier, is fine */ - if (r == -EBUSY) - r = 0; - - return r; -} /* csr_sdio_linux_install_irq() */ - -#ifdef CONFIG_PM - -/* - * Power Management notifier - */ -struct uf_sdio_mmc_pm_notifier -{ - struct list_head list; - - CsrSdioFunction *sdio_ctx; - struct notifier_block pm_notifier; -}; - -/* PM notifier list head */ -static struct uf_sdio_mmc_pm_notifier uf_sdio_mmc_pm_notifiers = { - .sdio_ctx = NULL, -}; - -/* - * --------------------------------------------------------------------------- - * uf_sdio_mmc_register_pm_notifier - * uf_sdio_mmc_unregister_pm_notifier - * - * Register/unregister for power management events. A list is used to - * allow multiple card instances to be supported. - * - * Arguments: - * sdio_ctx - CSR SDIO context to associate PM notifier to - * - * Returns: - * Register function returns NULL on error - * --------------------------------------------------------------------------- - */ -static struct uf_sdio_mmc_pm_notifier * -uf_sdio_mmc_register_pm_notifier(CsrSdioFunction *sdio_ctx) -{ - /* Allocate notifier context for this card instance */ - struct uf_sdio_mmc_pm_notifier *notifier_ctx = kmalloc(sizeof(struct uf_sdio_mmc_pm_notifier), GFP_KERNEL); - - if (notifier_ctx) - { - notifier_ctx->sdio_ctx = sdio_ctx; - notifier_ctx->pm_notifier.notifier_call = uf_sdio_mmc_power_event; - - list_add(¬ifier_ctx->list, &uf_sdio_mmc_pm_notifiers.list); - - if (register_pm_notifier(¬ifier_ctx->pm_notifier)) { - printk(KERN_ERR "unifi: register_pm_notifier failed\n"); - } - } - - return notifier_ctx; -} - -static void -uf_sdio_mmc_unregister_pm_notifier(CsrSdioFunction *sdio_ctx) -{ - struct uf_sdio_mmc_pm_notifier *notifier_ctx; - struct list_head *node, *q; - - list_for_each_safe(node, q, &uf_sdio_mmc_pm_notifiers.list) { - notifier_ctx = list_entry(node, struct uf_sdio_mmc_pm_notifier, list); - - /* If it matches, unregister and free the notifier context */ - if (notifier_ctx && notifier_ctx->sdio_ctx == sdio_ctx) - { - if (unregister_pm_notifier(¬ifier_ctx->pm_notifier)) { - printk(KERN_ERR "unifi: unregister_pm_notifier failed\n"); - } - - /* Remove from list */ - notifier_ctx->sdio_ctx = NULL; - list_del(node); - kfree(notifier_ctx); - } - } -} - -/* - * --------------------------------------------------------------------------- - * uf_sdio_mmc_power_event - * - * Handler for power management events. - * - * We need to handle suspend/resume events while the userspace is unsuspended - * to allow the SME to run its suspend/resume state machines. - * - * Arguments: - * event event ID - * - * Returns: - * Status of the event handling - * --------------------------------------------------------------------------- - */ -static int -uf_sdio_mmc_power_event(struct notifier_block *this, unsigned long event, void *ptr) -{ - struct uf_sdio_mmc_pm_notifier *notifier_ctx = container_of(this, - struct uf_sdio_mmc_pm_notifier, - pm_notifier); - - /* Call the CSR SDIO function driver's suspend/resume method - * while the userspace is unsuspended. - */ - switch (event) { - case PM_POST_HIBERNATION: - case PM_POST_SUSPEND: - printk(KERN_INFO "%s:%d resume\n", __FUNCTION__, __LINE__ ); - if (sdio_func_drv && sdio_func_drv->resume) { - sdio_func_drv->resume(notifier_ctx->sdio_ctx); - } - break; - - case PM_HIBERNATION_PREPARE: - case PM_SUSPEND_PREPARE: - printk(KERN_INFO "%s:%d suspend\n", __FUNCTION__, __LINE__ ); - if (sdio_func_drv && sdio_func_drv->suspend) { - sdio_func_drv->suspend(notifier_ctx->sdio_ctx); - } - break; - } - return NOTIFY_DONE; -} - -#endif /* CONFIG_PM */ - -/* - * --------------------------------------------------------------------------- - * uf_glue_sdio_probe - * - * Card insert callback. - * - * Arguments: - * func Our (glue layer) context pointer. - * - * Returns: - * UniFi driver error code. - * --------------------------------------------------------------------------- - */ -static int -uf_glue_sdio_probe(struct sdio_func *func, - const struct sdio_device_id *id) -{ - int instance; - CsrSdioFunction *sdio_ctx; - - /* First of all claim the SDIO driver */ - sdio_claim_host(func); - - /* Assume that the card is already powered */ - card_is_powered = 1; - - /* Assumes one card per host, which is true for SDIO */ - instance = func->card->host->index; - printk("sdio bus_id: %16s - UniFi card 0x%X inserted\n", - sdio_func_id(func), instance); - - /* Allocate context */ - sdio_ctx = kmalloc(sizeof(CsrSdioFunction), GFP_KERNEL); - if (sdio_ctx == NULL) { - sdio_release_host(func); - return -ENOMEM; - } - - /* Initialise the context */ - sdio_ctx->sdioId.manfId = func->vendor; - sdio_ctx->sdioId.cardId = func->device; - sdio_ctx->sdioId.sdioFunction = func->num; - sdio_ctx->sdioId.sdioInterface = func->class; - sdio_ctx->blockSize = func->cur_blksize; - sdio_ctx->priv = (void *)func; - sdio_ctx->features = 0; - - /* Module parameter enables byte mode */ - if (sdio_byte_mode) { - sdio_ctx->features |= CSR_SDIO_FEATURE_BYTE_MODE; - } - - if (func->card->host->caps & MMC_CAP_SD_HIGHSPEED) { - unifi_trace(NULL, UDBG1, "MMC_CAP_SD_HIGHSPEED is available\n"); - } - -#ifdef MMC_QUIRK_LENIENT_FN0 - func->card->quirks |= MMC_QUIRK_LENIENT_FN0; -#endif - - /* Pass context to the SDIO driver */ - sdio_set_drvdata(func, sdio_ctx); - -#ifdef CONFIG_PM - /* Register to get PM events */ - if (uf_sdio_mmc_register_pm_notifier(sdio_ctx) == NULL) { - unifi_error(NULL, "%s: Failed to register for PM events\n", __FUNCTION__); - } -#endif - - /* Register this device with the SDIO function driver */ - /* Call the main UniFi driver inserted handler */ - if (sdio_func_drv && sdio_func_drv->inserted) { - uf_add_os_device(instance, &func->dev); - sdio_func_drv->inserted(sdio_ctx); - } - - /* We have finished, so release the SDIO driver */ - sdio_release_host(func); - -#ifdef ANDROID_BUILD - /* Take the wakelock */ - unifi_trace(NULL, UDBG1, "probe: take wake lock\n"); - wake_lock(&unifi_sdio_wake_lock); -#endif - - return 0; -} /* uf_glue_sdio_probe() */ - - -/* - * --------------------------------------------------------------------------- - * uf_glue_sdio_remove - * - * Card removal callback. - * - * Arguments: - * func Our (glue layer) context pointer. - * - * Returns: - * UniFi driver error code. - * --------------------------------------------------------------------------- - */ -static void -uf_glue_sdio_remove(struct sdio_func *func) -{ - CsrSdioFunction *sdio_ctx; - - sdio_ctx = sdio_get_drvdata(func); - if (!sdio_ctx) { - return; - } - - unifi_info(NULL, "UniFi card removed\n"); - - /* Clean up the SDIO function driver */ - if (sdio_func_drv && sdio_func_drv->removed) { - uf_remove_os_device(func->card->host->index); - sdio_func_drv->removed(sdio_ctx); - } - -#ifdef CONFIG_PM - /* Unregister for PM events */ - uf_sdio_mmc_unregister_pm_notifier(sdio_ctx); -#endif - - kfree(sdio_ctx); - -} /* uf_glue_sdio_remove */ - - -/* - * SDIO ids *must* be statically declared, so we can't take - * them from the list passed in csr_sdio_register_driver(). - */ -static const struct sdio_device_id unifi_ids[] = { - { SDIO_DEVICE(SDIO_MANF_ID_CSR, SDIO_CARD_ID_UNIFI_3) }, - { SDIO_DEVICE(SDIO_MANF_ID_CSR, SDIO_CARD_ID_UNIFI_4) }, - { /* end: all zeroes */ }, -}; - -MODULE_DEVICE_TABLE(sdio, unifi_ids); - -#ifdef CONFIG_PM - -/* - * --------------------------------------------------------------------------- - * uf_glue_sdio_suspend - * - * Card suspend callback. The userspace will already be suspended. - * - * Arguments: - * dev The struct device owned by the MMC driver - * - * Returns: - * None - * --------------------------------------------------------------------------- - */ -static int -uf_glue_sdio_suspend(struct device *dev) -{ - unifi_trace(NULL, UDBG1, "uf_glue_sdio_suspend"); - - return 0; -} /* uf_glue_sdio_suspend */ - - -/* - * --------------------------------------------------------------------------- - * uf_glue_sdio_resume - * - * Card resume callback. The userspace will still be suspended. - * - * Arguments: - * dev The struct device owned by the MMC driver - * - * Returns: - * None - * --------------------------------------------------------------------------- - */ -static int -uf_glue_sdio_resume(struct device *dev) -{ - unifi_trace(NULL, UDBG1, "uf_glue_sdio_resume"); - -#ifdef ANDROID_BUILD - unifi_trace(NULL, UDBG1, "resume: take wakelock\n"); - wake_lock(&unifi_sdio_wake_lock); -#endif - - return 0; - -} /* uf_glue_sdio_resume */ - -static struct dev_pm_ops unifi_pm_ops = { - .suspend = uf_glue_sdio_suspend, - .resume = uf_glue_sdio_resume, -}; - -#define UNIFI_PM_OPS (&unifi_pm_ops) - -#else - -#define UNIFI_PM_OPS NULL - -#endif /* CONFIG_PM */ - -static struct sdio_driver unifi_driver = { - .probe = uf_glue_sdio_probe, - .remove = uf_glue_sdio_remove, - .name = "unifi", - .id_table = unifi_ids, - .drv.pm = UNIFI_PM_OPS, -}; - - -/* - * --------------------------------------------------------------------------- - * CsrSdioFunctionDriverRegister - * CsrSdioFunctionDriverUnregister - * - * These functions are called from the main module load and unload - * functions. They perform the appropriate operations for the - * linux MMC/SDIO driver. - * - * Arguments: - * sdio_drv Pointer to the function driver's SDIO structure. - * - * Returns: - * None. - * --------------------------------------------------------------------------- - */ -CsrResult -CsrSdioFunctionDriverRegister(CsrSdioFunctionDriver *sdio_drv) -{ - int r; - - printk("UniFi: Using native Linux MMC driver for SDIO.\n"); - - if (sdio_func_drv) { - unifi_error(NULL, "sdio_mmc: UniFi driver already registered\n"); - return CSR_SDIO_RESULT_INVALID_VALUE; - } - -#ifdef ANDROID_BUILD - wake_lock_init(&unifi_sdio_wake_lock, WAKE_LOCK_SUSPEND, "unifi_sdio_work"); -#endif - - /* Save the registered driver description */ - /* - * FIXME: - * Need a table here to handle a call to register for just one function. - * mmc only allows us to register for the whole device - */ - sdio_func_drv = sdio_drv; - -#ifdef CONFIG_PM - /* Initialise PM notifier list */ - INIT_LIST_HEAD(&uf_sdio_mmc_pm_notifiers.list); -#endif - - /* Register ourself with mmc_core */ - r = sdio_register_driver(&unifi_driver); - if (r) { - printk(KERN_ERR "unifi_sdio: Failed to register UniFi SDIO driver: %d\n", r); - return ConvertSdioToCsrSdioResult(r); - } - - return CSR_RESULT_SUCCESS; -} /* CsrSdioFunctionDriverRegister() */ - - - -void -CsrSdioFunctionDriverUnregister(CsrSdioFunctionDriver *sdio_drv) -{ - printk(KERN_INFO "UniFi: unregister from MMC sdio\n"); - -#ifdef ANDROID_BUILD - wake_lock_destroy(&unifi_sdio_wake_lock); -#endif - sdio_unregister_driver(&unifi_driver); - - sdio_func_drv = NULL; - -} /* CsrSdioFunctionDriverUnregister() */ - diff --git a/drivers/staging/csr/sdio_stubs.c b/drivers/staging/csr/sdio_stubs.c deleted file mode 100644 index 839fae01d96c..000000000000 --- a/drivers/staging/csr/sdio_stubs.c +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Stubs for some of the bottom edge functions. - * - * These stubs are optional functions in the bottom edge (SDIO driver - * interface) API that not all platforms or SDIO drivers may support. - * - * They're declared as weak symbols so they can be overridden by - * simply providing a non-weak declaration. - * - * Copyright (C) 2007-2008 by Cambridge Silicon Radio Ltd. - * - * Refer to LICENSE.txt included with this source code for details on - * the license terms. - * - */ -#include "csr_wifi_hip_unifi.h" - -void __attribute__((weak)) CsrSdioFunctionIdle(CsrSdioFunction *function) -{ -} - -void __attribute__((weak)) CsrSdioFunctionActive(CsrSdioFunction *function) -{ -} - -CsrResult __attribute__((weak)) CsrSdioPowerOn(CsrSdioFunction *function) -{ - return CSR_RESULT_SUCCESS; -} - -void __attribute__((weak)) CsrSdioPowerOff(CsrSdioFunction *function) -{ -} - -CsrResult __attribute__((weak)) CsrSdioHardReset(CsrSdioFunction *function) -{ - return CSR_SDIO_RESULT_NOT_RESET; -} - -CsrResult __attribute__((weak)) CsrSdioBlockSizeSet(CsrSdioFunction *function, - u16 blockSize) -{ - return CSR_RESULT_SUCCESS; -} - -CsrResult __attribute__((weak)) CsrSdioSuspend(CsrSdioFunction *function) -{ - return CSR_RESULT_SUCCESS; -} - -CsrResult __attribute__((weak)) CsrSdioResume(CsrSdioFunction *function) -{ - return CSR_RESULT_SUCCESS; -} - -int __attribute__((weak)) csr_sdio_linux_install_irq(CsrSdioFunction *function) -{ - return 0; -} - -int __attribute__((weak)) csr_sdio_linux_remove_irq(CsrSdioFunction *function) -{ - return 0; -} - -void __attribute__((weak)) CsrSdioInsertedAcknowledge(CsrSdioFunction *function, CsrResult result) -{ -} - -void __attribute__((weak)) CsrSdioRemovedAcknowledge(CsrSdioFunction *function) -{ -} - -void __attribute__((weak)) CsrSdioSuspendAcknowledge(CsrSdioFunction *function, CsrResult result) -{ -} - -void __attribute__((weak)) CsrSdioResumeAcknowledge(CsrSdioFunction *function, CsrResult result) -{ -} - - diff --git a/drivers/staging/csr/sme_blocking.c b/drivers/staging/csr/sme_blocking.c deleted file mode 100644 index 0c6e21636e7f..000000000000 --- a/drivers/staging/csr/sme_blocking.c +++ /dev/null @@ -1,1466 +0,0 @@ -/* - * --------------------------------------------------------------------------- - * FILE: sme_mgt_blocking.c - * - * PURPOSE: - * This file contains the driver specific implementation of - * the WEXT <==> SME MGT interface for all SME builds that support WEXT. - * - * Copyright (C) 2009 by Cambridge Silicon Radio Ltd. - * - * Refer to LICENSE.txt included with this source code for details on - * the license terms. - * - * --------------------------------------------------------------------------- - */ - -#include "unifi_priv.h" - - -/* - * This file also contains the implementation of the asynchronous - * requests to the SME. - * - * Before calling an asynchronous SME function, we call sme_init_request() - * which gets hold of the SME semaphore and updates the request status. - * The semaphore makes sure that there is only one pending request to - * the SME at a time. - * - * Now we are ready to call the SME function, but only if - * sme_init_request() has returned 0. - * - * When the SME function returns, we need to wait - * for the reply. This is done in sme_wait_for_reply(). - * If the request times-out, the request status is set to SME_REQUEST_TIMEDOUT - * and the sme_wait_for_reply() returns. - * - * If the SME replies in time, we call sme_complete_request(). - * There we change the request status to SME_REQUEST_RECEIVED. This will - * wake up the process waiting on sme_wait_for_reply(). - * It is important that we copy the reply data in priv->sme_reply - * before calling sme_complete_request(). - * - * Handling the wext requests, we need to block - * until the SME sends the response to our request. - * We use the sme_init_request() and sme_wait_for_reply() - * to implement this behavior in the following functions: - * sme_mgt_wifi_on() - * sme_mgt_wifi_off() - * sme_mgt_scan_full() - * sme_mgt_scan_results_get_async() - * sme_mgt_connect() - * unifi_mgt_media_status_ind() - * sme_mgt_disconnect() - * sme_mgt_pmkid() - * sme_mgt_key() - * sme_mgt_mib_get() - * sme_mgt_mib_set() - * sme_mgt_versions_get() - * sme_mgt_set_value() - * sme_mgt_get_value() - * sme_mgt_set_value_async() - * sme_mgt_get_value_async() - * sme_mgt_packet_filter_set() - * sme_mgt_tspec() - */ - - -/* - * Handling the suspend and resume system events, we need to block - * until the SME sends the response to our indication. - * We use the sme_init_request() and sme_wait_for_reply() - * to implement this behavior in the following functions: - * sme_sys_suspend() - * sme_sys_resume() - */ - -#define UNIFI_SME_MGT_SHORT_TIMEOUT 10000 -#define UNIFI_SME_MGT_LONG_TIMEOUT 19000 -#define UNIFI_SME_SYS_LONG_TIMEOUT 10000 - -#ifdef UNIFI_DEBUG -# define sme_wait_for_reply(priv, t) _sme_wait_for_reply(priv, t, __func__) -#else -# define sme_wait_for_reply(priv, t) _sme_wait_for_reply(priv, t, NULL) -#endif - -static int -sme_init_request(unifi_priv_t *priv) -{ - if (priv == NULL) { - unifi_error(priv, "sme_init_request: Invalid priv\n"); - return -EIO; - } - - unifi_trace(priv, UDBG5, "sme_init_request: wait sem\n"); - - /* Grab the SME semaphore until the reply comes, or timeout */ - if (down_interruptible(&priv->sme_sem)) { - unifi_error(priv, "sme_init_request: Failed to get SME semaphore\n"); - return -EIO; - } - unifi_trace(priv, UDBG5, "sme_init_request: got sem: pending\n"); - - priv->sme_reply.request_status = SME_REQUEST_PENDING; - - return 0; - -} /* sme_init_request() */ - - -void -uf_sme_complete_request(unifi_priv_t *priv, CsrResult reply_status, const char *func) -{ - if (priv == NULL) { - unifi_error(priv, "sme_complete_request: Invalid priv\n"); - return; - } - - if (priv->sme_reply.request_status != SME_REQUEST_PENDING) { - unifi_notice(priv, - "sme_complete_request: request not pending %s (s:%d)\n", - (func ? func : ""), priv->sme_reply.request_status); - return; - } - unifi_trace(priv, UDBG5, - "sme_complete_request: completed %s (s:%d)\n", - (func ? func : ""), priv->sme_reply.request_status); - - priv->sme_reply.request_status = SME_REQUEST_RECEIVED; - priv->sme_reply.reply_status = reply_status; - - wake_up_interruptible(&priv->sme_request_wq); - - return; -} - - -void -uf_sme_cancel_request(unifi_priv_t *priv, CsrResult reply_status) -{ - /* Check for a blocking SME request in progress, and cancel the wait. - * This should be used when the character device is closed. - */ - - if (priv == NULL) { - unifi_error(priv, "sme_cancel_request: Invalid priv\n"); - return; - } - - /* If no request is pending, nothing to wake up */ - if (priv->sme_reply.request_status != SME_REQUEST_PENDING) { - unifi_trace(priv, UDBG5, - "sme_cancel_request: no request was pending (s:%d)\n", - priv->sme_reply.request_status); - /* Nothing to do */ - return; - } - unifi_trace(priv, UDBG5, - "sme_cancel_request: request cancelled (s:%d)\n", - priv->sme_reply.request_status); - - /* Wake up the wait with an error status */ - priv->sme_reply.request_status = SME_REQUEST_CANCELLED; - priv->sme_reply.reply_status = reply_status; /* unimportant since the CANCELLED state will fail the ioctl */ - - wake_up_interruptible(&priv->sme_request_wq); - - return; -} - - -static int -_sme_wait_for_reply(unifi_priv_t *priv, - unsigned long timeout, const char *func) -{ - long r; - - unifi_trace(priv, UDBG5, "sme_wait_for_reply: %s sleep\n", func ? func : ""); - r = wait_event_interruptible_timeout(priv->sme_request_wq, - (priv->sme_reply.request_status != SME_REQUEST_PENDING), - msecs_to_jiffies(timeout)); - unifi_trace(priv, UDBG5, "sme_wait_for_reply: %s awake (%d)\n", func ? func : "", r); - - if (r == -ERESTARTSYS) { - /* The thread was killed */ - unifi_info(priv, "ERESTARTSYS in _sme_wait_for_reply\n"); - up(&priv->sme_sem); - return r; - } - if (priv->sme_reply.request_status == SME_REQUEST_CANCELLED) { - unifi_trace(priv, UDBG5, "Cancelled waiting for SME to reply (%s s:%d, t:%d, r:%d)\n", - (func ? func : ""), priv->sme_reply.request_status, timeout, r); - - /* Release the SME semaphore that was downed in sme_init_request() */ - up(&priv->sme_sem); - return -EIO; /* fail the ioctl */ - } - if ((r == 0) && (priv->sme_reply.request_status != SME_REQUEST_RECEIVED)) { - unifi_notice(priv, "Timeout waiting for SME to reply (%s s:%d, t:%d)\n", - (func ? func : ""), priv->sme_reply.request_status, timeout); - - priv->sme_reply.request_status = SME_REQUEST_TIMEDOUT; - - /* Release the SME semaphore that was downed in sme_init_request() */ - up(&priv->sme_sem); - - return -ETIMEDOUT; - } - - unifi_trace(priv, UDBG5, "sme_wait_for_reply: %s received (%d)\n", - func ? func : "", r); - - /* Release the SME semaphore that was downed in sme_init_request() */ - up(&priv->sme_sem); - - return 0; -} /* sme_wait_for_reply() */ - - - - -#ifdef CSR_SUPPORT_WEXT -int sme_mgt_wifi_on(unifi_priv_t *priv) -{ - u16 numElements; - CsrWifiSmeDataBlock* dataList; -#ifdef CSR_SUPPORT_WEXT_AP - int r; -#endif - - if (priv->smepriv == NULL) { - unifi_error(priv, "sme_mgt_wifi_on: invalid smepriv\n"); - return -EIO; - } - - if (priv->mib_data.length) { - numElements = 1; - dataList = &priv->mib_data; - } else { - numElements = 0; - dataList = NULL; - } - /* Start the SME */ -#ifdef CSR_SUPPORT_WEXT_AP - r = sme_init_request(priv); - if (r) { - return -EIO; - } -#endif - CsrWifiSmeWifiOnReqSend(0, priv->sta_mac_address, numElements, dataList); -#ifdef CSR_SUPPORT_WEXT_AP - r = sme_wait_for_reply(priv, UNIFI_SME_MGT_LONG_TIMEOUT); - unifi_trace(priv, UDBG4, - "sme_mgt_wifi_on: unifi_mgt_wifi_oo_req <-- (r=%d, status=%d)\n", - r, priv->sme_reply.reply_status); - return convert_sme_error(priv->sme_reply.reply_status); -#else - return 0; -#endif -} /* sme_mgt_wifi_on() */ - - -int sme_mgt_wifi_off(unifi_priv_t *priv) -{ - int r; - - if (priv->smepriv == NULL) { - unifi_error(priv, "sme_mgt_wifi_off: invalid smepriv\n"); - return -EIO; - } - - r = sme_init_request(priv); - if (r) - return -EIO; - - /* Stop the SME */ - CsrWifiSmeWifiOffReqSend(0); - - r = sme_wait_for_reply(priv, UNIFI_SME_MGT_LONG_TIMEOUT); - if (r) - return r; - - unifi_trace(priv, UDBG4, - "sme_mgt_wifi_off: unifi_mgt_wifi_off_req <-- (r=%d, status=%d)\n", - r, priv->sme_reply.reply_status); - return convert_sme_error(priv->sme_reply.reply_status); - -} /* sme_mgt_wifi_off */ - -int sme_mgt_key(unifi_priv_t *priv, CsrWifiSmeKey *sme_key, - CsrWifiSmeListAction action) -{ - int r; - - if (priv->smepriv == NULL) { - unifi_error(priv, "sme_mgt_key: invalid smepriv\n"); - return -EIO; - } - - r = sme_init_request(priv); - if (r) - return -EIO; - - CsrWifiSmeKeyReqSend(0, CSR_WIFI_INTERFACE_IN_USE, action, *sme_key); - - r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT); - if (r) - return r; - - return convert_sme_error(priv->sme_reply.reply_status); -} - - -int sme_mgt_scan_full(unifi_priv_t *priv, - CsrWifiSsid *specific_ssid, - int num_channels, - unsigned char *channel_list) -{ - CsrWifiMacAddress bcastAddress = {{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }}; - u8 is_active = (num_channels > 0) ? TRUE : FALSE; - int r; - - if (priv->smepriv == NULL) { - unifi_error(priv, "sme_mgt_scan_full: invalid smepriv\n"); - return -EIO; - } - - unifi_trace(priv, UDBG4, "sme_mgt_scan_full: -->\n"); - - r = sme_init_request(priv); - if (r) - return -EIO; - - /* If a channel list is provided, do an active scan */ - if (is_active) { - unifi_trace(priv, UDBG1, - "channel list - num_channels: %d, active scan\n", - num_channels); - } - - CsrWifiSmeScanFullReqSend(0, - specific_ssid->length?1:0, /* 0 or 1 SSIDS */ - specific_ssid, - bcastAddress, - is_active, - CSR_WIFI_SME_BSS_TYPE_ANY_BSS, - CSR_WIFI_SME_SCAN_TYPE_ALL, - (u16)num_channels, channel_list, - 0, NULL); - - r = sme_wait_for_reply(priv, UNIFI_SME_MGT_LONG_TIMEOUT); - if (r) - return r; - - unifi_trace(priv, UDBG4, "sme_mgt_scan_full: <-- (status=%d)\n", priv->sme_reply.reply_status); - if (priv->sme_reply.reply_status == CSR_WIFI_RESULT_UNAVAILABLE) - return 0; /* initial scan already underway */ - else - return convert_sme_error(priv->sme_reply.reply_status); -} - - -int sme_mgt_scan_results_get_async(unifi_priv_t *priv, - struct iw_request_info *info, - char *scan_results, - long scan_results_len) -{ - u16 scan_result_list_count; - CsrWifiSmeScanResult *scan_result_list; - CsrWifiSmeScanResult *scan_result; - int r; - int i; - char *current_ev = scan_results; - - if (priv->smepriv == NULL) { - unifi_error(priv, "sme_mgt_scan_results_get_async: invalid smepriv\n"); - return -EIO; - } - - r = sme_init_request(priv); - if (r) - return -EIO; - - CsrWifiSmeScanResultsGetReqSend(0); - r = sme_wait_for_reply(priv, UNIFI_SME_MGT_LONG_TIMEOUT); - if (r) - return r; - - scan_result_list_count = priv->sme_reply.reply_scan_results_count; - scan_result_list = priv->sme_reply.reply_scan_results; - unifi_trace(priv, UDBG2, - "scan_results: Scan returned %d, numElements=%d\n", - r, scan_result_list_count); - - /* OK, now we have the scan results */ - for (i = 0; i < scan_result_list_count; ++i) { - scan_result = &scan_result_list[i]; - - unifi_trace(priv, UDBG2, "Scan Result: %.*s\n", - scan_result->ssid.length, - scan_result->ssid.ssid); - - r = unifi_translate_scan(priv->netdev[0], info, - current_ev, - scan_results + scan_results_len, - scan_result, i+1); - - if (r < 0) { - kfree(scan_result_list); - priv->sme_reply.reply_scan_results_count = 0; - priv->sme_reply.reply_scan_results = NULL; - return r; - } - - current_ev += r; - } - - /* - * Free the scan results allocated in unifi_mgt_scan_results_get_cfm() - * and invalidate the reply_scan_results to avoid re-using - * the freed pointers. - */ - kfree(scan_result_list); - priv->sme_reply.reply_scan_results_count = 0; - priv->sme_reply.reply_scan_results = NULL; - - unifi_trace(priv, UDBG2, - "scan_results: Scan translated to %d bytes\n", - current_ev - scan_results); - return (current_ev - scan_results); -} - - -int sme_mgt_connect(unifi_priv_t *priv) -{ - int r; - - if (priv->smepriv == NULL) { - unifi_error(priv, "sme_mgt_connect: invalid smepriv\n"); - return -EIO; - } - - unifi_trace(priv, UDBG2, "sme_mgt_connect: %.*s\n", - priv->connection_config.ssid.length, - priv->connection_config.ssid.ssid); - - r = sme_init_request(priv); - if (r) - return -EIO; - - CsrWifiSmeConnectReqSend(0, CSR_WIFI_INTERFACE_IN_USE, priv->connection_config); - r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT); - if (r) - return r; - - if (priv->sme_reply.reply_status) - unifi_trace(priv, UDBG1, "sme_mgt_connect: failed with SME status %d\n", - priv->sme_reply.reply_status); - - return convert_sme_error(priv->sme_reply.reply_status); -} - - -int sme_mgt_disconnect(unifi_priv_t *priv) -{ - int r; - - if (priv->smepriv == NULL) { - unifi_error(priv, "sme_mgt_disconnect: invalid smepriv\n"); - return -EIO; - } - - r = sme_init_request(priv); - if (r) - return -EIO; - - CsrWifiSmeDisconnectReqSend(0, CSR_WIFI_INTERFACE_IN_USE); - r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT); - if (r) - return r; - - unifi_trace(priv, UDBG4, "sme_mgt_disconnect: <-- (status=%d)\n", priv->sme_reply.reply_status); - return convert_sme_error(priv->sme_reply.reply_status); -} - - -int sme_mgt_pmkid(unifi_priv_t *priv, - CsrWifiSmeListAction action, - CsrWifiSmePmkidList *pmkid_list) -{ - int r; - - if (priv->smepriv == NULL) { - unifi_error(priv, "sme_mgt_pmkid: invalid smepriv\n"); - return -EIO; - } - - r = sme_init_request(priv); - if (r) - return -EIO; - - CsrWifiSmePmkidReqSend(0, CSR_WIFI_INTERFACE_IN_USE, action, - pmkid_list->pmkidsCount, pmkid_list->pmkids); - r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT); - if (r) - return r; - - unifi_trace(priv, UDBG4, "sme_mgt_pmkid: <-- (status=%d)\n", priv->sme_reply.reply_status); - return convert_sme_error(priv->sme_reply.reply_status); -} - - -int sme_mgt_mib_get(unifi_priv_t *priv, - unsigned char *varbind, int *length) -{ - int r; - - if (priv->smepriv == NULL) { - unifi_error(priv, "sme_mgt_mib_get: invalid smepriv\n"); - return -EIO; - } - - r = sme_init_request(priv); - if (r) - return -EIO; - - priv->mib_cfm_buffer = varbind; - priv->mib_cfm_buffer_length = MAX_VARBIND_LENGTH; - - CsrWifiSmeMibGetReqSend(0, *length, varbind); - r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT); - if (r) { - priv->mib_cfm_buffer_length = 0; - priv->mib_cfm_buffer = NULL; - return r; - } - - *length = priv->mib_cfm_buffer_length; - - priv->mib_cfm_buffer_length = 0; - priv->mib_cfm_buffer = NULL; - unifi_trace(priv, UDBG4, "sme_mgt_mib_get: <-- (status=%d)\n", priv->sme_reply.reply_status); - return convert_sme_error(priv->sme_reply.reply_status); -} - -int sme_mgt_mib_set(unifi_priv_t *priv, - unsigned char *varbind, int length) -{ - int r; - - if (priv->smepriv == NULL) { - unifi_error(priv, "sme_mgt_mib_get: invalid smepriv\n"); - return -EIO; - } - - r = sme_init_request(priv); - if (r) - return -EIO; - - CsrWifiSmeMibSetReqSend(0, length, varbind); - r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT); - if (r) - return r; - - unifi_trace(priv, UDBG4, "sme_mgt_mib_set: <-- (status=%d)\n", priv->sme_reply.reply_status); - return convert_sme_error(priv->sme_reply.reply_status); -} - -#endif /* CSR_SUPPORT_WEXT */ - -int sme_mgt_power_config_set(unifi_priv_t *priv, CsrWifiSmePowerConfig *powerConfig) -{ -#ifdef CSR_SME_USERSPACE - int r; - - if (priv->smepriv == NULL) { - unifi_error(priv, "sme_mgt_set_value_async: invalid smepriv\n"); - return -EIO; - } - - r = sme_init_request(priv); - if (r) - return -EIO; - - CsrWifiSmePowerConfigSetReqSend(0, *powerConfig); - - r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT); - if (r) - return r; - - unifi_trace(priv, UDBG4, - "sme_mgt_set_value_async: unifi_mgt_set_value_req <-- (r=%d status=%d)\n", - r, priv->sme_reply.reply_status); - return convert_sme_error(priv->sme_reply.reply_status); -#else - CsrResult status; - if (priv->smepriv == NULL) { - unifi_error(priv, "sme_mgt_set_value: invalid smepriv\n"); - return -EIO; - } - CsrWifiSmeMgtClaimSyncAccess(priv->smepriv); - status = CsrWifiSmeMgtPowerConfigSetReq(priv->smepriv, *powerConfig); - CsrWifiSmeMgtReleaseSyncAccess(priv->smepriv); - return convert_sme_error(status); -#endif -} - -int sme_mgt_sme_config_set(unifi_priv_t *priv, CsrWifiSmeStaConfig *staConfig, CsrWifiSmeDeviceConfig *deviceConfig) -{ -#ifdef CSR_SME_USERSPACE - int r; - - if (priv->smepriv == NULL) { - unifi_error(priv, "sme_mgt_sme_config_set: invalid smepriv\n"); - return -EIO; - } - - r = sme_init_request(priv); - if (r) - return -EIO; - - CsrWifiSmeSmeStaConfigSetReqSend(0, CSR_WIFI_INTERFACE_IN_USE, *staConfig); - r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT); - if (r) - return r; - - unifi_trace(priv, UDBG4, - "sme_mgt_sme_config_set: CsrWifiSmeSmeStaConfigSetReq <-- (r=%d status=%d)\n", - r, priv->sme_reply.reply_status); - - r = sme_init_request(priv); - if (r) - return -EIO; - - CsrWifiSmeSmeCommonConfigSetReqSend(0, *deviceConfig); - r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT); - if (r) - return r; - - unifi_trace(priv, UDBG4, - "sme_mgt_sme_config_set: CsrWifiSmeSmeCommonConfigSetReq <-- (r=%d status=%d)\n", - r, priv->sme_reply.reply_status); - - return convert_sme_error(priv->sme_reply.reply_status); -#else - CsrResult status; - if (priv->smepriv == NULL) { - unifi_error(priv, "sme_mgt_sme_config_set: invalid smepriv\n"); - return -EIO; - } - CsrWifiSmeMgtClaimSyncAccess(priv->smepriv); - status = CsrWifiSmeMgtSmeConfigSetReq(priv->smepriv, *staConfig); - status = CsrWifiSmeMgtDeviceConfigSetReq(priv->smepriv, *deviceConfig); - CsrWifiSmeMgtReleaseSyncAccess(priv->smepriv); - return convert_sme_error(status); -#endif -} - -#ifdef CSR_SUPPORT_WEXT - -int sme_mgt_mib_config_set(unifi_priv_t *priv, CsrWifiSmeMibConfig *mibConfig) -{ -#ifdef CSR_SME_USERSPACE - int r; - - if (priv->smepriv == NULL) { - unifi_error(priv, "sme_mgt_mib_config_set: invalid smepriv\n"); - return -EIO; - } - - r = sme_init_request(priv); - if (r) - return -EIO; - - CsrWifiSmeMibConfigSetReqSend(0, *mibConfig); - - r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT); - if (r) - return r; - - unifi_trace(priv, UDBG4, - "sme_mgt_mib_config_set: unifi_mgt_set_mib_config_req <-- (r=%d status=%d)\n", - r, priv->sme_reply.reply_status); - return convert_sme_error(priv->sme_reply.reply_status); -#else - CsrResult status; - if (priv->smepriv == NULL) { - unifi_error(priv, "sme_mgt_mib_config_set: invalid smepriv\n"); - return -EIO; - } - CsrWifiSmeMgtClaimSyncAccess(priv->smepriv); - status = CsrWifiSmeMgtMibConfigSetReq(priv->smepriv, *mibConfig); - CsrWifiSmeMgtReleaseSyncAccess(priv->smepriv); - return convert_sme_error(status); -#endif -} - -int sme_mgt_coex_config_set(unifi_priv_t *priv, CsrWifiSmeCoexConfig *coexConfig) -{ -#ifdef CSR_SME_USERSPACE - int r; - - if (priv->smepriv == NULL) { - unifi_error(priv, "sme_mgt_coex_config_set: invalid smepriv\n"); - return -EIO; - } - - r = sme_init_request(priv); - if (r) - return -EIO; - - CsrWifiSmeCoexConfigSetReqSend(0, *coexConfig); - - r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT); - if (r) - return r; - - unifi_trace(priv, UDBG4, - "sme_mgt_coex_config_set: unifi_mgt_set_mib_config_req <-- (r=%d status=%d)\n", - r, priv->sme_reply.reply_status); - return convert_sme_error(priv->sme_reply.reply_status); -#else - CsrResult status; - if (priv->smepriv == NULL) { - unifi_error(priv, "sme_mgt_coex_config_set: invalid smepriv\n"); - return -EIO; - } - CsrWifiSmeMgtClaimSyncAccess(priv->smepriv); - status = CsrWifiSmeMgtCoexConfigSetReq(priv->smepriv, *coexConfig); - CsrWifiSmeMgtReleaseSyncAccess(priv->smepriv); - return convert_sme_error(status); -#endif -} - -#endif /* CSR_SUPPORT_WEXT */ - -int sme_mgt_host_config_set(unifi_priv_t *priv, CsrWifiSmeHostConfig *hostConfig) -{ -#ifdef CSR_SME_USERSPACE - int r; - - if (priv->smepriv == NULL) { - unifi_error(priv, "sme_mgt_host_config_set: invalid smepriv\n"); - return -EIO; - } - - r = sme_init_request(priv); - if (r) - return -EIO; - - CsrWifiSmeHostConfigSetReqSend(0, CSR_WIFI_INTERFACE_IN_USE, *hostConfig); - - r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT); - if (r) - return r; - - unifi_trace(priv, UDBG4, - "sme_mgt_host_config_set: unifi_mgt_set_host_config_req <-- (r=%d status=%d)\n", - r, priv->sme_reply.reply_status); - return convert_sme_error(priv->sme_reply.reply_status); -#else - CsrResult status; - if (priv->smepriv == NULL) { - unifi_error(priv, "sme_mgt_host_config_set: invalid smepriv\n"); - return -EIO; - } - CsrWifiSmeMgtClaimSyncAccess(priv->smepriv); - status = CsrWifiSmeMgtHostConfigSetReq(priv->smepriv, *hostConfig); - CsrWifiSmeMgtReleaseSyncAccess(priv->smepriv); - return convert_sme_error(status); -#endif -} - -#ifdef CSR_SUPPORT_WEXT - -int sme_mgt_versions_get(unifi_priv_t *priv, CsrWifiSmeVersions *versions) -{ -#ifdef CSR_SME_USERSPACE - int r; - - if (priv->smepriv == NULL) { - unifi_error(priv, "sme_mgt_versions_get: invalid smepriv\n"); - return -EIO; - } - - unifi_trace(priv, UDBG4, "sme_mgt_versions_get: unifi_mgt_versions_get_req -->\n"); - r = sme_init_request(priv); - if (r) - return -EIO; - - CsrWifiSmeVersionsGetReqSend(0); - - r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT); - if (r) - return r; - - /* store the reply */ - if (versions != NULL) { - memcpy((unsigned char*)versions, - (unsigned char*)&priv->sme_reply.versions, - sizeof(CsrWifiSmeVersions)); - } - - unifi_trace(priv, UDBG4, - "sme_mgt_versions_get: unifi_mgt_versions_get_req <-- (r=%d status=%d)\n", - r, priv->sme_reply.reply_status); - - return convert_sme_error(priv->sme_reply.reply_status); -#else - CsrResult status; - CsrWifiSmeMgtClaimSyncAccess(priv->smepriv); - status = CsrWifiSmeMgtVersionsGetReq(priv->smepriv, versions); - CsrWifiSmeMgtReleaseSyncAccess(priv->smepriv); - return convert_sme_error(status); -#endif -} - -#endif /* CSR_SUPPORT_WEXT */ - -int sme_mgt_power_config_get(unifi_priv_t *priv, CsrWifiSmePowerConfig *powerConfig) -{ -#ifdef CSR_SME_USERSPACE - int r; - - if (priv->smepriv == NULL) { - unifi_error(priv, "sme_mgt_power_config_get: invalid smepriv\n"); - return -EIO; - } - - unifi_trace(priv, UDBG4, "sme_mgt_power_config_get: unifi_mgt_power_config_req -->\n"); - r = sme_init_request(priv); - if (r) - return -EIO; - - CsrWifiSmePowerConfigGetReqSend(0); - - r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT); - if (r) - return r; - - /* store the reply */ - if (powerConfig != NULL) { - memcpy((unsigned char*)powerConfig, - (unsigned char*)&priv->sme_reply.powerConfig, - sizeof(CsrWifiSmePowerConfig)); - } - - unifi_trace(priv, UDBG4, - "sme_mgt_get_versions: unifi_mgt_power_config_req <-- (r=%d status=%d)\n", - r, priv->sme_reply.reply_status); - - return convert_sme_error(priv->sme_reply.reply_status); -#else - CsrResult status; - CsrWifiSmeMgtClaimSyncAccess(priv->smepriv); - status = CsrWifiSmeMgtPowerConfigGetReq(priv->smepriv, powerConfig); - CsrWifiSmeMgtReleaseSyncAccess(priv->smepriv); - return convert_sme_error(status); -#endif -} - -int sme_mgt_host_config_get(unifi_priv_t *priv, CsrWifiSmeHostConfig *hostConfig) -{ -#ifdef CSR_SME_USERSPACE - int r; - - if (priv->smepriv == NULL) { - unifi_error(priv, "sme_mgt_host_config_get: invalid smepriv\n"); - return -EIO; - } - - unifi_trace(priv, UDBG4, "sme_mgt_host_config_get: unifi_mgt_host_config_get_req -->\n"); - r = sme_init_request(priv); - if (r) - return -EIO; - - CsrWifiSmeHostConfigGetReqSend(0, CSR_WIFI_INTERFACE_IN_USE); - - r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT); - if (r) - return r; - - /* store the reply */ - if (hostConfig != NULL) - memcpy((unsigned char*)hostConfig, - (unsigned char*)&priv->sme_reply.hostConfig, - sizeof(CsrWifiSmeHostConfig)); - - unifi_trace(priv, UDBG4, - "sme_mgt_host_config_get: unifi_mgt_host_config_get_req <-- (r=%d status=%d)\n", - r, priv->sme_reply.reply_status); - - return convert_sme_error(priv->sme_reply.reply_status); -#else - CsrResult status; - CsrWifiSmeMgtClaimSyncAccess(priv->smepriv); - status = CsrWifiSmeMgtHostConfigGetReq(priv->smepriv, hostConfig); - CsrWifiSmeMgtReleaseSyncAccess(priv->smepriv); - return convert_sme_error(status); -#endif -} - -int sme_mgt_sme_config_get(unifi_priv_t *priv, CsrWifiSmeStaConfig *staConfig, CsrWifiSmeDeviceConfig *deviceConfig) -{ -#ifdef CSR_SME_USERSPACE - int r; - - if (priv->smepriv == NULL) { - unifi_error(priv, "sme_mgt_sme_config_get: invalid smepriv\n"); - return -EIO; - } - - unifi_trace(priv, UDBG4, "sme_mgt_sme_config_get: unifi_mgt_sme_config_get_req -->\n"); - - /* Common device config */ - r = sme_init_request(priv); - if (r) - return -EIO; - - CsrWifiSmeSmeCommonConfigGetReqSend(0); - r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT); - if (r) - return r; - - /* store the reply */ - if (deviceConfig != NULL) - memcpy((unsigned char*)deviceConfig, - (unsigned char*)&priv->sme_reply.deviceConfig, - sizeof(CsrWifiSmeDeviceConfig)); - - /* STA config */ - r = sme_init_request(priv); - if (r) - return -EIO; - - CsrWifiSmeSmeStaConfigGetReqSend(0, CSR_WIFI_INTERFACE_IN_USE); - r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT); - if (r) - return r; - - /* store the reply */ - if (staConfig != NULL) - memcpy((unsigned char*)staConfig, - (unsigned char*)&priv->sme_reply.staConfig, - sizeof(CsrWifiSmeStaConfig)); - - unifi_trace(priv, UDBG4, - "sme_mgt_sme_config_get: unifi_mgt_sme_config_get_req <-- (r=%d status=%d)\n", - r, priv->sme_reply.reply_status); - - return convert_sme_error(priv->sme_reply.reply_status); -#else - CsrResult status; - CsrWifiSmeMgtClaimSyncAccess(priv->smepriv); - status = CsrWifiSmeMgtSmeConfigGetReq(priv->smepriv, staConfig); - status = CsrWifiSmeMgtDeviceConfigGetReq(priv->smepriv, deviceConfig); - CsrWifiSmeMgtReleaseSyncAccess(priv->smepriv); - return convert_sme_error(status); -#endif -} - -int sme_mgt_coex_info_get(unifi_priv_t *priv, CsrWifiSmeCoexInfo *coexInfo) -{ -#ifdef CSR_SME_USERSPACE - int r; - - if (priv->smepriv == NULL) { - unifi_error(priv, "sme_mgt_coex_info_get: invalid smepriv\n"); - return -EIO; - } - - unifi_trace(priv, UDBG4, "sme_mgt_coex_info_get: unifi_mgt_coex_info_get_req -->\n"); - r = sme_init_request(priv); - if (r) - return -EIO; - - CsrWifiSmeCoexInfoGetReqSend(0); - - r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT); - if (r) - return r; - - /* store the reply */ - if (coexInfo != NULL) - memcpy((unsigned char*)coexInfo, - (unsigned char*)&priv->sme_reply.coexInfo, - sizeof(CsrWifiSmeCoexInfo)); - - unifi_trace(priv, UDBG4, - "sme_mgt_coex_info_get: unifi_mgt_coex_info_get_req <-- (r=%d status=%d)\n", - r, priv->sme_reply.reply_status); - - return convert_sme_error(priv->sme_reply.reply_status); -#else - CsrResult status; - CsrWifiSmeMgtClaimSyncAccess(priv->smepriv); - status = CsrWifiSmeMgtCoexInfoGetReq(priv->smepriv, coexInfo); - CsrWifiSmeMgtReleaseSyncAccess(priv->smepriv); - return convert_sme_error(status); -#endif -} - -#ifdef CSR_SUPPORT_WEXT - -int sme_mgt_coex_config_get(unifi_priv_t *priv, CsrWifiSmeCoexConfig *coexConfig) -{ -#ifdef CSR_SME_USERSPACE - int r; - - if (priv->smepriv == NULL) { - unifi_error(priv, "sme_mgt_coex_config_get: invalid smepriv\n"); - return -EIO; - } - - unifi_trace(priv, UDBG4, "sme_mgt_coex_config_get: unifi_mgt_coex_config_get_req -->\n"); - r = sme_init_request(priv); - if (r) - return -EIO; - - CsrWifiSmeCoexConfigGetReqSend(0); - - r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT); - if (r) - return r; - - /* store the reply */ - if (coexConfig != NULL) - memcpy((unsigned char*)coexConfig, - (unsigned char*)&priv->sme_reply.coexConfig, - sizeof(CsrWifiSmeCoexConfig)); - - unifi_trace(priv, UDBG4, - "sme_mgt_coex_config_get: unifi_mgt_coex_config_get_req <-- (r=%d status=%d)\n", - r, priv->sme_reply.reply_status); - - return convert_sme_error(priv->sme_reply.reply_status); -#else - CsrResult status; - CsrWifiSmeMgtClaimSyncAccess(priv->smepriv); - status = CsrWifiSmeMgtCoexConfigGetReq(priv->smepriv, coexConfig); - CsrWifiSmeMgtReleaseSyncAccess(priv->smepriv); - return convert_sme_error(status); -#endif -} - -int sme_mgt_mib_config_get(unifi_priv_t *priv, CsrWifiSmeMibConfig *mibConfig) -{ -#ifdef CSR_SME_USERSPACE - int r; - - if (priv->smepriv == NULL) { - unifi_error(priv, "sme_mgt_mib_config_get: invalid smepriv\n"); - return -EIO; - } - - unifi_trace(priv, UDBG4, "sme_mgt_mib_config_get: unifi_mgt_mib_config_get_req -->\n"); - r = sme_init_request(priv); - if (r) - return -EIO; - - CsrWifiSmeMibConfigGetReqSend(0); - - r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT); - if (r) - return r; - - /* store the reply */ - if (mibConfig != NULL) - memcpy((unsigned char*)mibConfig, - (unsigned char*)&priv->sme_reply.mibConfig, - sizeof(CsrWifiSmeMibConfig)); - - unifi_trace(priv, UDBG4, - "sme_mgt_mib_config_get: unifi_mgt_mib_config_get_req <-- (r=%d status=%d)\n", - r, priv->sme_reply.reply_status); - - return convert_sme_error(priv->sme_reply.reply_status); -#else - CsrResult status; - CsrWifiSmeMgtClaimSyncAccess(priv->smepriv); - status = CsrWifiSmeMgtMibConfigGetReq(priv->smepriv, mibConfig); - CsrWifiSmeMgtReleaseSyncAccess(priv->smepriv); - return convert_sme_error(status); -#endif -} - -int sme_mgt_connection_info_get(unifi_priv_t *priv, CsrWifiSmeConnectionInfo *connectionInfo) -{ -#ifdef CSR_SME_USERSPACE - int r; - - if (priv->smepriv == NULL) { - unifi_error(priv, "sme_mgt_connection_info_get: invalid smepriv\n"); - return -EIO; - } - - unifi_trace(priv, UDBG4, "sme_mgt_connection_info_get: unifi_mgt_connection_info_get_req -->\n"); - r = sme_init_request(priv); - if (r) - return -EIO; - - CsrWifiSmeConnectionInfoGetReqSend(0, CSR_WIFI_INTERFACE_IN_USE); - - r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT); - if (r) - return r; - - /* store the reply */ - if (connectionInfo != NULL) - memcpy((unsigned char*)connectionInfo, - (unsigned char*)&priv->sme_reply.connectionInfo, - sizeof(CsrWifiSmeConnectionInfo)); - - unifi_trace(priv, UDBG4, - "sme_mgt_connection_info_get: unifi_mgt_connection_info_get_req <-- (r=%d status=%d)\n", - r, priv->sme_reply.reply_status); - - return convert_sme_error(priv->sme_reply.reply_status); -#else - CsrResult status; - CsrWifiSmeMgtClaimSyncAccess(priv->smepriv); - status = CsrWifiSmeMgtConnectionInfoGetReq(priv->smepriv, connectionInfo); - CsrWifiSmeMgtReleaseSyncAccess(priv->smepriv); - return convert_sme_error(status); -#endif -} - -int sme_mgt_connection_config_get(unifi_priv_t *priv, CsrWifiSmeConnectionConfig *connectionConfig) -{ -#ifdef CSR_SME_USERSPACE - int r; - - if (priv->smepriv == NULL) { - unifi_error(priv, "sme_mgt_connection_config_get: invalid smepriv\n"); - return -EIO; - } - - unifi_trace(priv, UDBG4, "sme_mgt_connection_config_get: unifi_mgt_connection_config_get_req -->\n"); - r = sme_init_request(priv); - if (r) - return -EIO; - - CsrWifiSmeConnectionConfigGetReqSend(0, CSR_WIFI_INTERFACE_IN_USE); - - r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT); - if (r) - return r; - - /* store the reply */ - if (connectionConfig != NULL) - memcpy((unsigned char*)connectionConfig, - (unsigned char*)&priv->sme_reply.connectionConfig, - sizeof(CsrWifiSmeConnectionConfig)); - - unifi_trace(priv, UDBG4, - "sme_mgt_connection_config_get: unifi_mgt_connection_config_get_req <-- (r=%d status=%d)\n", - r, priv->sme_reply.reply_status); - - return convert_sme_error(priv->sme_reply.reply_status); -#else - CsrResult status; - CsrWifiSmeMgtClaimSyncAccess(priv->smepriv); - status = CsrWifiSmeMgtConnectionConfigGetReq(priv->smepriv, connectionConfig); - CsrWifiSmeMgtReleaseSyncAccess(priv->smepriv); - return convert_sme_error(status); -#endif -} - -int sme_mgt_connection_stats_get(unifi_priv_t *priv, CsrWifiSmeConnectionStats *connectionStats) -{ -#ifdef CSR_SME_USERSPACE - int r; - - if (priv->smepriv == NULL) { - unifi_error(priv, "sme_mgt_connection_stats_get: invalid smepriv\n"); - return -EIO; - } - - unifi_trace(priv, UDBG4, "sme_mgt_connection_stats_get: unifi_mgt_connection_stats_get_req -->\n"); - r = sme_init_request(priv); - if (r) - return -EIO; - - CsrWifiSmeConnectionStatsGetReqSend(0, CSR_WIFI_INTERFACE_IN_USE); - - r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT); - if (r) - return r; - - /* store the reply */ - if (connectionStats != NULL) - memcpy((unsigned char*)connectionStats, - (unsigned char*)&priv->sme_reply.connectionStats, - sizeof(CsrWifiSmeConnectionStats)); - - unifi_trace(priv, UDBG4, - "sme_mgt_connection_stats_get: unifi_mgt_connection_stats_get_req <-- (r=%d status=%d)\n", - r, priv->sme_reply.reply_status); - - return convert_sme_error(priv->sme_reply.reply_status); -#else - CsrResult status; - CsrWifiSmeMgtClaimSyncAccess(priv->smepriv); - status = CsrWifiSmeMgtConnectionStatsGetReq(priv->smepriv, connectionStats); - CsrWifiSmeMgtReleaseSyncAccess(priv->smepriv); - return convert_sme_error(status); -#endif -} - -#endif /* CSR_SUPPORT_WEXT */ - -int sme_mgt_packet_filter_set(unifi_priv_t *priv) -{ - CsrWifiIp4Address ipAddress = {{0xFF, 0xFF, 0xFF, 0xFF }}; - if (priv->smepriv == NULL) { - unifi_error(priv, "sme_mgt_packet_filter_set: invalid smepriv\n"); - return -EIO; - } - if (priv->packet_filters.arp_filter) { - ipAddress.a[0] = (priv->sta_ip_address ) & 0xFF; - ipAddress.a[1] = (priv->sta_ip_address >> 8) & 0xFF; - ipAddress.a[2] = (priv->sta_ip_address >> 16) & 0xFF; - ipAddress.a[3] = (priv->sta_ip_address >> 24) & 0xFF; - } - - unifi_trace(priv, UDBG5, - "sme_mgt_packet_filter_set: IP address %d.%d.%d.%d\n", - ipAddress.a[0], ipAddress.a[1], - ipAddress.a[2], ipAddress.a[3]); - - /* Doesn't block for a confirm */ - CsrWifiSmePacketFilterSetReqSend(0, CSR_WIFI_INTERFACE_IN_USE, - priv->packet_filters.tclas_ies_length, - priv->filter_tclas_ies, - priv->packet_filters.filter_mode, - ipAddress); - return 0; -} - -int sme_mgt_tspec(unifi_priv_t *priv, CsrWifiSmeListAction action, - u32 tid, CsrWifiSmeDataBlock *tspec, CsrWifiSmeDataBlock *tclas) -{ - int r; - - if (priv->smepriv == NULL) { - unifi_error(priv, "sme_mgt_tspec: invalid smepriv\n"); - return -EIO; - } - - r = sme_init_request(priv); - if (r) - return -EIO; - - CsrWifiSmeTspecReqSend(0, CSR_WIFI_INTERFACE_IN_USE, - action, tid, TRUE, 0, - tspec->length, tspec->data, - tclas->length, tclas->data); - r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT); - if (r) - return r; - - unifi_trace(priv, UDBG4, "sme_mgt_tspec: <-- (status=%d)\n", priv->sme_reply.reply_status); - return convert_sme_error(priv->sme_reply.reply_status); -} - - - -int sme_sys_suspend(unifi_priv_t *priv) -{ - int r; - CsrResult csrResult; - - if (priv->smepriv == NULL) { - unifi_error(priv, "sme_sys_suspend: invalid smepriv\n"); - return -EIO; - } - - r = sme_init_request(priv); - if (r) - return -EIO; - - /* Suspend the SME, which MAY cause it to power down UniFi */ - CsrWifiRouterCtrlSuspendIndSend(priv->CSR_WIFI_SME_IFACEQUEUE, 0, 0, priv->wol_suspend); - r = sme_wait_for_reply(priv, UNIFI_SME_SYS_LONG_TIMEOUT); - if (r) { - /* No reply - forcibly power down in case the request wasn't processed */ - unifi_notice(priv, - "suspend: SME did not reply %s, ", - (priv->ptest_mode | priv->wol_suspend) ? "leave powered" : "power off UniFi anyway\n"); - - /* Leave power on for production test, though */ - if (!priv->ptest_mode) { - /* Put UniFi to deep sleep, in case we can not power it off */ - CsrSdioClaim(priv->sdio); - unifi_trace(priv, UDBG1, "Force deep sleep"); - csrResult = unifi_force_low_power_mode(priv->card); - - /* For WOL, the UniFi must stay powered */ - if (!priv->wol_suspend) { - unifi_trace(priv, UDBG1, "Power off\n"); - CsrSdioPowerOff(priv->sdio); - } - CsrSdioRelease(priv->sdio); - } - } - - if (priv->wol_suspend) { - unifi_trace(priv, UDBG1, "UniFi left powered for WOL\n"); - - /* Remove the IRQ, which also disables the card SDIO interrupt. - * Disabling the card SDIO interrupt enables the PIO WOL source. - * Removal of the of the handler ensures that in both SDIO and PIO cases - * the card interrupt only wakes the host. The card will be polled - * after resume to handle any pending data. - */ - if (csr_sdio_linux_remove_irq(priv->sdio)) { - unifi_notice(priv, "WOL csr_sdio_linux_remove_irq failed\n"); - } - - if (enable_wol == UNIFI_WOL_SDIO) { - /* Because csr_sdio_linux_remove_irq() disabled the card SDIO interrupt, - * it must be left enabled to wake-on-SDIO. - */ - unifi_trace(priv, UDBG1, "Enable card SDIO interrupt for SDIO WOL\n"); - - CsrSdioClaim(priv->sdio); - csrResult = CsrSdioInterruptEnable(priv->sdio); - CsrSdioRelease(priv->sdio); - - if (csrResult != CSR_RESULT_SUCCESS) { - unifi_error(priv, "WOL CsrSdioInterruptEnable failed %d\n", csrResult); - } - } else { - unifi_trace(priv, UDBG1, "Disabled card SDIO interrupt for PIO WOL\n"); - } - - /* Prevent the BH thread from running during the suspend. - * Upon resume, sme_sys_resume() will trigger a wifi-on, this will cause - * the BH thread to be re-enabled and reinstall the ISR. - */ - priv->bh_thread.block_thread = 1; - - unifi_trace(priv, UDBG1, "unifi_suspend: suspended BH"); - } - - /* Consider UniFi to be uninitialised */ - priv->init_progress = UNIFI_INIT_NONE; - - unifi_trace(priv, UDBG1, "sme_sys_suspend: <-- (r=%d status=%d)\n", r, priv->sme_reply.reply_status); - return convert_sme_error(priv->sme_reply.reply_status); -} - - -int sme_sys_resume(unifi_priv_t *priv) -{ - int r; - - unifi_trace(priv, UDBG1, "sme_sys_resume %s\n", priv->wol_suspend ? "warm" : ""); - - if (priv->smepriv == NULL) { - unifi_error(priv, "sme_sys_resume: invalid smepriv\n"); - return -EIO; - } - - r = sme_init_request(priv); - if (r) - return -EIO; - - CsrWifiRouterCtrlResumeIndSend(priv->CSR_WIFI_SME_IFACEQUEUE, 0, priv->wol_suspend); - - r = sme_wait_for_reply(priv, UNIFI_SME_SYS_LONG_TIMEOUT); - if (r) - unifi_notice(priv, - "resume: SME did not reply, return success anyway\n"); - - return 0; -} - -#ifdef CSR_SUPPORT_WEXT_AP -int sme_ap_stop(unifi_priv_t *priv, u16 interface_tag) -{ - int r; - - if (priv->smepriv == NULL) { - unifi_error(priv, "sme_ap_stop: invalid smepriv\n"); - return -EIO; - } - - r = sme_init_request(priv); - if (r) - return -EIO; - - CsrWifiNmeApStopReqSend(0, interface_tag); - - r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT); - if (r) - return r; - - unifi_trace(priv, UDBG4, - "sme_ap_stop <-- (r=%d status=%d)\n", - r, priv->sme_reply.reply_status); - return convert_sme_error(priv->sme_reply.reply_status); - -} - -int sme_ap_start(unifi_priv_t *priv, u16 interface_tag, - CsrWifiSmeApConfig_t * ap_config) -{ - int r; - CsrWifiSmeApP2pGoConfig p2p_go_param; - memset(&p2p_go_param, 0, sizeof(CsrWifiSmeApP2pGoConfig)); - - if (priv->smepriv == NULL) { - unifi_error(priv, "sme_ap_start: invalid smepriv\n"); - return -EIO; - } - - r = sme_init_request(priv); - if (r) - return -EIO; - - CsrWifiNmeApStartReqSend(0, interface_tag, CSR_WIFI_AP_TYPE_LEGACY, FALSE, - ap_config->ssid, 1, ap_config->channel, - ap_config->credentials, ap_config->max_connections, - p2p_go_param, FALSE); - - r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT); - if (r) - return r; - - unifi_trace(priv, UDBG4, - "sme_ap_start <-- (r=%d status=%d)\n", - r, priv->sme_reply.reply_status); - return convert_sme_error(priv->sme_reply.reply_status); -} - -int sme_ap_config(unifi_priv_t *priv, - CsrWifiSmeApMacConfig *ap_mac_config, - CsrWifiNmeApConfig *group_security_config) -{ - int r; - CsrWifiSmeApP2pGoConfig p2p_go_param; - memset(&p2p_go_param, 0, sizeof(CsrWifiSmeApP2pGoConfig)); - - if (priv->smepriv == NULL) { - unifi_error(priv, "sme_ap_config: invalid smepriv\n"); - return -EIO; - } - - r = sme_init_request(priv); - if (r) - return -EIO; - - CsrWifiNmeApConfigSetReqSend(0, *group_security_config, - *ap_mac_config); - - r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT); - if (r) - return r; - - unifi_trace(priv, UDBG4, - "sme_ap_config <-- (r=%d status=%d)\n", - r, priv->sme_reply.reply_status); - return convert_sme_error(priv->sme_reply.reply_status); -} -#endif diff --git a/drivers/staging/csr/sme_mgt.c b/drivers/staging/csr/sme_mgt.c deleted file mode 100644 index 58d1b3b72932..000000000000 --- a/drivers/staging/csr/sme_mgt.c +++ /dev/null @@ -1,1012 +0,0 @@ -/* - * --------------------------------------------------------------------------- - * FILE: sme_mgt.c - * - * PURPOSE: - * This file contains the driver specific implementation of - * the SME MGT SAP. - * It is part of the porting exercise. - * - * Copyright (C) 2008-2009 by Cambridge Silicon Radio Ltd. - * - * Refer to LICENSE.txt included with this source code for details on - * the license terms. - * - * --------------------------------------------------------------------------- - */ - -#include "csr_wifi_hip_unifiversion.h" -#include "unifi_priv.h" -#include "csr_wifi_hip_conversions.h" -/* - * This file implements the SME MGT API. It contains the following functions: - * CsrWifiSmeWifiFlightmodeCfmSend() - * CsrWifiSmeWifiOnCfmSend() - * CsrWifiSmeWifiOffCfmSend() - * CsrWifiSmeWifiOffIndSend() - * CsrWifiSmeScanFullCfmSend() - * CsrWifiSmeScanResultsGetCfmSend() - * CsrWifiSmeScanResultIndSend() - * CsrWifiSmeScanResultsFlushCfmSend() - * CsrWifiSmeConnectCfmSend() - * CsrWifiSmeMediaStatusIndSend() - * CsrWifiSmeDisconnectCfmSend() - * CsrWifiSmeKeyCfmSend() - * CsrWifiSmeMulticastAddressCfmSend() - * CsrWifiSmeSetValueCfmSend() - * CsrWifiSmeGetValueCfmSend() - * CsrWifiSmeMicFailureIndSend() - * CsrWifiSmePmkidCfmSend() - * CsrWifiSmePmkidCandidateListIndSend() - * CsrWifiSmeMibSetCfmSend() - * CsrWifiSmeMibGetCfmSend() - * CsrWifiSmeMibGetNextCfmSend() - * CsrWifiSmeConnectionQualityIndSend() - * CsrWifiSmePacketFilterSetCfmSend() - * CsrWifiSmeTspecCfmSend() - * CsrWifiSmeTspecIndSend() - * CsrWifiSmeBlacklistCfmSend() - * CsrWifiSmeEventMaskSetCfmSend() - * CsrWifiSmeRoamStartIndSend() - * CsrWifiSmeRoamCompleteIndSend() - * CsrWifiSmeAssociationStartIndSend() - * CsrWifiSmeAssociationCompleteIndSend() - * CsrWifiSmeIbssStationIndSend() - */ - - -void CsrWifiSmeMicFailureIndHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ -#ifdef CSR_SUPPORT_WEXT - unifi_priv_t *priv = (unifi_priv_t*)drvpriv; - CsrWifiSmeMicFailureInd* ind = (CsrWifiSmeMicFailureInd*)msg; - - if (priv == NULL) { - unifi_error(NULL, "CsrWifiSmeMicFailureIndSend: invalid priv\n"); - return; - } - - unifi_trace(priv, UDBG1, - "CsrWifiSmeMicFailureIndSend: count=%d, KeyType=%d\n", - ind->count, ind->keyType); - - wext_send_michaelmicfailure_event(priv, ind->count, ind->address, ind->keyType, ind->interfaceTag); -#endif -} - - -void CsrWifiSmePmkidCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ -#ifdef CSR_SUPPORT_WEXT - unifi_priv_t *priv = (unifi_priv_t*)drvpriv; - CsrWifiSmePmkidCfm* cfm = (CsrWifiSmePmkidCfm*)msg; - - if (priv == NULL) { - unifi_error(NULL, "CsrWifiSmePmkidCfmSend: Invalid ospriv.\n"); - return; - } - - /* - * WEXT never does a GET operation the PMKIDs, so we don't need - * handle data returned in pmkids. - */ - - sme_complete_request(priv, cfm->status); -#endif -} - - -void CsrWifiSmePmkidCandidateListIndHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ -#ifdef CSR_SUPPORT_WEXT - unifi_priv_t *priv = (unifi_priv_t*)drvpriv; - CsrWifiSmePmkidCandidateListInd* ind = (CsrWifiSmePmkidCandidateListInd*)msg; - int i; - - if (priv->smepriv == NULL) { - unifi_error(priv, "CsrWifiSmePmkidCandidateListIndSend: invalid smepriv\n"); - return; - } - - for (i = 0; i < ind->pmkidCandidatesCount; i++) - { - wext_send_pmkid_candidate_event(priv, ind->pmkidCandidates[i].bssid, ind->pmkidCandidates[i].preAuthAllowed, ind->interfaceTag); - } -#endif -} - -void CsrWifiSmeScanResultsFlushCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ -} - -void CsrWifiSmeScanResultsGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ -#ifdef CSR_SUPPORT_WEXT - unifi_priv_t *priv = (unifi_priv_t*)drvpriv; - CsrWifiSmeScanResultsGetCfm* cfm = (CsrWifiSmeScanResultsGetCfm*)msg; - int bytesRequired = cfm->scanResultsCount * sizeof(CsrWifiSmeScanResult); - int i; - u8* current_buff; - CsrWifiSmeScanResult* scanCopy; - - if (priv == NULL) { - unifi_error(NULL, "CsrWifiSmeScanResultsGetCfmSend: Invalid ospriv.\n"); - return; - } - - /* Calc the size of the buffer reuired */ - for (i = 0; i < cfm->scanResultsCount; ++i) { - const CsrWifiSmeScanResult *scan_result = &cfm->scanResults[i]; - bytesRequired += scan_result->informationElementsLength; - } - - /* Take a Copy of the scan Results :-) */ - scanCopy = kmalloc(bytesRequired, GFP_KERNEL); - memcpy(scanCopy, cfm->scanResults, sizeof(CsrWifiSmeScanResult) * cfm->scanResultsCount); - - /* Take a Copy of the Info Elements AND update the scan result pointers */ - current_buff = (u8*)&scanCopy[cfm->scanResultsCount]; - for (i = 0; i < cfm->scanResultsCount; ++i) - { - CsrWifiSmeScanResult *scan_result = &scanCopy[i]; - memcpy(current_buff, scan_result->informationElements, scan_result->informationElementsLength); - scan_result->informationElements = current_buff; - current_buff += scan_result->informationElementsLength; - } - - priv->sme_reply.reply_scan_results_count = cfm->scanResultsCount; - priv->sme_reply.reply_scan_results = scanCopy; - - sme_complete_request(priv, cfm->status); -#endif -} - - -void CsrWifiSmeScanFullCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ -#ifdef CSR_SUPPORT_WEXT - unifi_priv_t *priv = (unifi_priv_t*)drvpriv; - CsrWifiSmeScanFullCfm* cfm = (CsrWifiSmeScanFullCfm*)msg; - - if (priv == NULL) { - unifi_error(NULL, "CsrWifiSmeScanFullCfmSend: Invalid ospriv.\n"); - return; - } - - sme_complete_request(priv, cfm->status); -#endif -} - - -void CsrWifiSmeScanResultIndHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ - -} - - -void CsrWifiSmeConnectCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ -#ifdef CSR_SUPPORT_WEXT - unifi_priv_t *priv = (unifi_priv_t*)drvpriv; - CsrWifiSmeConnectCfm* cfm = (CsrWifiSmeConnectCfm*)msg; - - if (priv == NULL) { - unifi_error(NULL, "CsrWifiSmeConnectCfmSend: Invalid ospriv.\n"); - return; - } - - sme_complete_request(priv, cfm->status); -#endif -} - - -void CsrWifiSmeDisconnectCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ -#ifdef CSR_SUPPORT_WEXT - unifi_priv_t *priv = (unifi_priv_t*)drvpriv; - CsrWifiSmeDisconnectCfm* cfm = (CsrWifiSmeDisconnectCfm*)msg; - - if (priv == NULL) { - unifi_error(NULL, "CsrWifiSmeDisconnectCfmSend: Invalid ospriv.\n"); - return; - } - - sme_complete_request(priv, cfm->status); -#endif -} - - -void CsrWifiSmeKeyCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ -#ifdef CSR_SUPPORT_WEXT - unifi_priv_t *priv = (unifi_priv_t*)drvpriv; - CsrWifiSmeKeyCfm* cfm = (CsrWifiSmeKeyCfm*)msg; - - if (priv == NULL) { - unifi_error(NULL, "CsrWifiSmeKeyCfmSend: Invalid ospriv.\n"); - return; - } - - sme_complete_request(priv, cfm->status); -#endif -} - - -void CsrWifiSmeMulticastAddressCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ -#ifdef CSR_SUPPORT_WEXT - unifi_priv_t *priv = (unifi_priv_t*)drvpriv; - CsrWifiSmeMulticastAddressCfm* cfm = (CsrWifiSmeMulticastAddressCfm*)msg; - - if (priv == NULL) { - unifi_error(NULL, "CsrWifiSmeMulticastAddressCfmSend: Invalid ospriv.\n"); - return; - } - - sme_complete_request(priv, cfm->status); -#endif -} - -void CsrWifiSmeWifiFlightmodeCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ -#ifdef CSR_SUPPORT_WEXT - unifi_priv_t *priv = (unifi_priv_t*)drvpriv; - CsrWifiSmeWifiFlightmodeCfm* cfm = (CsrWifiSmeWifiFlightmodeCfm*)msg; - - if (priv == NULL) { - unifi_error(NULL, "CsrWifiSmeWifiFlightmodeCfmSend: Invalid ospriv.\n"); - return; - } - - sme_complete_request(priv, cfm->status); -#endif -} - -void CsrWifiSmeWifiOnCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ -#ifdef CSR_SUPPORT_WEXT - unifi_priv_t *priv = (unifi_priv_t*)drvpriv; - CsrWifiSmeWifiOnCfm* cfm = (CsrWifiSmeWifiOnCfm*)msg; - - if (priv == NULL) { - unifi_error(NULL, "CsrWifiSmeWifiOnCfmSend: Invalid ospriv.\n"); - return; - } - - unifi_trace(priv, UDBG4, - "CsrWifiSmeWifiOnCfmSend: wake up status %d\n", cfm->status); -#ifdef CSR_SUPPORT_WEXT_AP - sme_complete_request(priv, cfm->status); -#endif - -#endif -} - -void CsrWifiSmeWifiOffCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ -#ifdef CSR_SUPPORT_WEXT - unifi_priv_t *priv = (unifi_priv_t*)drvpriv; - CsrWifiSmeWifiOffCfm* cfm = (CsrWifiSmeWifiOffCfm*)msg; - - if (priv == NULL) { - unifi_error(NULL, "CsrWifiSmeWifiOffCfmSend: Invalid ospriv.\n"); - return; - } - - sme_complete_request(priv, cfm->status); -#endif -} - - -void CsrWifiSmeWifiOffIndHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ -#ifdef CSR_SUPPORT_WEXT - unifi_priv_t *priv = (unifi_priv_t*)drvpriv; - CsrWifiSmeWifiOffInd* ind = (CsrWifiSmeWifiOffInd*)msg; - - if (priv == NULL) { - unifi_error(NULL, "CsrWifiRouterCtrlStoppedReqSend: Invalid ospriv.\n"); - return; - } - - if (priv->smepriv == NULL) { - unifi_error(priv, "CsrWifiRouterCtrlStoppedReqSend: invalid smepriv\n"); - return; - } - - /* - * If the status indicates an error, the SME is in a stopped state. - * We need to start it again in order to reinitialise UniFi. - */ - switch (ind->reason) { - case CSR_WIFI_SME_CONTROL_INDICATION_ERROR: - unifi_trace(priv, UDBG1, - "CsrWifiRouterCtrlStoppedReqSend: Restarting SME (ind:%d)\n", - ind->reason); - - /* On error, restart the SME */ - sme_mgt_wifi_on(priv); - break; - case CSR_WIFI_SME_CONTROL_INDICATION_EXIT: -#ifdef CSR_SUPPORT_WEXT_AP - sme_complete_request(priv, 0); -#endif - break; - default: - break; - } - -#endif -} - -void CsrWifiSmeVersionsGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ -#ifdef CSR_SUPPORT_WEXT - unifi_priv_t *priv = (unifi_priv_t*)drvpriv; - CsrWifiSmeVersionsGetCfm* cfm = (CsrWifiSmeVersionsGetCfm*)msg; - - if (priv == NULL) { - unifi_error(NULL, "CsrWifiSmeVersionsGetCfmSend: Invalid ospriv.\n"); - return; - } - - priv->sme_reply.versions = cfm->versions; - sme_complete_request(priv, cfm->status); -#endif -} - -void CsrWifiSmePowerConfigGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ - unifi_priv_t *priv = (unifi_priv_t*)drvpriv; - CsrWifiSmePowerConfigGetCfm* cfm = (CsrWifiSmePowerConfigGetCfm*)msg; - - if (priv == NULL) { - unifi_error(NULL, "CsrWifiSmePowerConfigGetCfmSend: Invalid ospriv.\n"); - return; - } - - priv->sme_reply.powerConfig = cfm->powerConfig; - sme_complete_request(priv, cfm->status); -} - -void CsrWifiSmeHostConfigGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ - unifi_priv_t *priv = (unifi_priv_t*)drvpriv; - CsrWifiSmeHostConfigGetCfm* cfm = (CsrWifiSmeHostConfigGetCfm*)msg; - - if (priv == NULL) { - unifi_error(NULL, "CsrWifiSmeHostConfigGetCfmSend: Invalid ospriv.\n"); - return; - } - - priv->sme_reply.hostConfig = cfm->hostConfig; - sme_complete_request(priv, cfm->status); -} - -void CsrWifiSmeCoexInfoGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ - unifi_priv_t *priv = (unifi_priv_t*)drvpriv; - CsrWifiSmeCoexInfoGetCfm* cfm = (CsrWifiSmeCoexInfoGetCfm*)msg; - - if (priv == NULL) { - unifi_error(NULL, "CsrWifiSmeCoexInfoGetCfmSend: Invalid ospriv.\n"); - return; - } - - priv->sme_reply.coexInfo = cfm->coexInfo; - sme_complete_request(priv, cfm->status); -} - -void CsrWifiSmeCoexConfigGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ -#ifdef CSR_SUPPORT_WEXT - unifi_priv_t *priv = (unifi_priv_t*)drvpriv; - CsrWifiSmeCoexConfigGetCfm* cfm = (CsrWifiSmeCoexConfigGetCfm*)msg; - - if (priv == NULL) { - unifi_error(NULL, "CsrWifiSmeCoexConfigGetCfmSend: Invalid ospriv.\n"); - return; - } - - priv->sme_reply.coexConfig = cfm->coexConfig; - sme_complete_request(priv, cfm->status); -#endif -} - -void CsrWifiSmeMibConfigGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ -#ifdef CSR_SUPPORT_WEXT - unifi_priv_t *priv = (unifi_priv_t*)drvpriv; - CsrWifiSmeMibConfigGetCfm* cfm = (CsrWifiSmeMibConfigGetCfm*)msg; - - if (priv == NULL) { - unifi_error(NULL, "CsrWifiSmeMibConfigGetCfmSend: Invalid ospriv.\n"); - return; - } - - priv->sme_reply.mibConfig = cfm->mibConfig; - sme_complete_request(priv, cfm->status); -#endif -} - -void CsrWifiSmeConnectionInfoGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ -#ifdef CSR_SUPPORT_WEXT - unifi_priv_t *priv = (unifi_priv_t*)drvpriv; - CsrWifiSmeConnectionInfoGetCfm* cfm = (CsrWifiSmeConnectionInfoGetCfm*)msg; - - if (priv == NULL) { - unifi_error(NULL, "CsrWifiSmeConnectionInfoGetCfmSend: Invalid ospriv.\n"); - return; - } - - priv->sme_reply.connectionInfo = cfm->connectionInfo; - sme_complete_request(priv, cfm->status); -#endif -} - -void CsrWifiSmeConnectionConfigGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ -#ifdef CSR_SUPPORT_WEXT - unifi_priv_t *priv = (unifi_priv_t*)drvpriv; - CsrWifiSmeConnectionConfigGetCfm* cfm = (CsrWifiSmeConnectionConfigGetCfm*)msg; - - if (priv == NULL) { - unifi_error(NULL, "CsrWifiSmeConnectionConfigGetCfmSend: Invalid ospriv.\n"); - return; - } - - priv->sme_reply.connectionConfig = cfm->connectionConfig; - sme_complete_request(priv, cfm->status); -#endif -} - -void CsrWifiSmeConnectionStatsGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ -#ifdef CSR_SUPPORT_WEXT - unifi_priv_t *priv = (unifi_priv_t*)drvpriv; - CsrWifiSmeConnectionStatsGetCfm* cfm = (CsrWifiSmeConnectionStatsGetCfm*)msg; - - if (priv == NULL) { - unifi_error(NULL, "CsrWifiSmeConnectionStatsGetCfmSend: Invalid ospriv.\n"); - return; - } - - priv->sme_reply.connectionStats = cfm->connectionStats; - sme_complete_request(priv, cfm->status); -#endif -} - -void CsrWifiSmeMibSetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ -#ifdef CSR_SUPPORT_WEXT - unifi_priv_t *priv = (unifi_priv_t*)drvpriv; - CsrWifiSmeMibSetCfm* cfm = (CsrWifiSmeMibSetCfm*)msg; - - if (priv == NULL) { - unifi_error(NULL, "CsrWifiSmeMibSetCfmSend: Invalid ospriv.\n"); - return; - } - - sme_complete_request(priv, cfm->status); -#endif -} - -void CsrWifiSmeMibGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ -#ifdef CSR_SUPPORT_WEXT - unifi_priv_t *priv = (unifi_priv_t*)drvpriv; - CsrWifiSmeMibGetCfm* cfm = (CsrWifiSmeMibGetCfm*)msg; - - if (priv == NULL) { - unifi_error(NULL, "CsrWifiSmeMibGetCfmSend: Invalid ospriv.\n"); - return; - } - - if (cfm->mibAttribute == NULL) { - unifi_error(priv, "CsrWifiSmeMibGetCfmSend: Empty reply.\n"); - sme_complete_request(priv, cfm->status); - return; - } - - if ((priv->mib_cfm_buffer != NULL) && - (priv->mib_cfm_buffer_length >= cfm->mibAttributeLength)) { - memcpy(priv->mib_cfm_buffer, cfm->mibAttribute, cfm->mibAttributeLength); - priv->mib_cfm_buffer_length = cfm->mibAttributeLength; - } else { - unifi_error(priv, - "CsrWifiSmeMibGetCfmSend: No room to store MIB data (have=%d need=%d).\n", - priv->mib_cfm_buffer_length, cfm->mibAttributeLength); - } - - sme_complete_request(priv, cfm->status); -#endif -} - -void CsrWifiSmeMibGetNextCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ -#ifdef CSR_SUPPORT_WEXT - unifi_priv_t *priv = (unifi_priv_t*)drvpriv; - CsrWifiSmeMibGetNextCfm* cfm = (CsrWifiSmeMibGetNextCfm*)msg; - - if (priv == NULL) { - unifi_error(NULL, "CsrWifiSmeMibGetNextCfmSend: Invalid ospriv.\n"); - return; - } - - /* Need to copy MIB data */ - sme_complete_request(priv, cfm->status); -#endif -} - -void CsrWifiSmeConnectionQualityIndHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ -#ifdef CSR_SUPPORT_WEXT - unifi_priv_t *priv = (unifi_priv_t*)drvpriv; - CsrWifiSmeConnectionQualityInd* ind = (CsrWifiSmeConnectionQualityInd*)msg; - int signal, noise, snr; - - if (priv == NULL) { - unifi_error(NULL, "CsrWifiSmeConnectionQualityIndSend: Invalid ospriv.\n"); - return; - } - - /* - * level and noise below are mapped into an unsigned 8 bit number, - * ranging from [-192; 63]. The way this is achieved is simply to - * add 0x100 onto the number if it is negative, - * once clipped to the correct range. - */ - signal = ind->linkQuality.unifiRssi; - /* Clip range of snr */ - snr = (ind->linkQuality.unifiSnr > 0) ? ind->linkQuality.unifiSnr : 0; /* In dB relative, from 0 - 255 */ - snr = (snr < 255) ? snr : 255; - noise = signal - snr; - - /* Clip range of signal */ - signal = (signal < 63) ? signal : 63; - signal = (signal > -192) ? signal : -192; - - /* Clip range of noise */ - noise = (noise < 63) ? noise : 63; - noise = (noise > -192) ? noise : -192; - - /* Make u8 */ - signal = ( signal < 0 ) ? signal + 0x100 : signal; - noise = ( noise < 0 ) ? noise + 0x100 : noise; - - priv->wext_wireless_stats.qual.level = (u8)signal; /* -192 : 63 */ - priv->wext_wireless_stats.qual.noise = (u8)noise; /* -192 : 63 */ - priv->wext_wireless_stats.qual.qual = snr; /* 0 : 255 */ - priv->wext_wireless_stats.qual.updated = 0; - -#if WIRELESS_EXT > 16 - priv->wext_wireless_stats.qual.updated |= IW_QUAL_LEVEL_UPDATED | - IW_QUAL_NOISE_UPDATED | - IW_QUAL_QUAL_UPDATED; -#if WIRELESS_EXT > 18 - priv->wext_wireless_stats.qual.updated |= IW_QUAL_DBM; -#endif -#endif -#endif -} - -void CsrWifiSmePacketFilterSetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ - unifi_priv_t *priv = (unifi_priv_t*)drvpriv; - - if (priv == NULL) { - unifi_error(NULL, "CsrWifiSmePacketFilterSetCfmSend: Invalid ospriv.\n"); - return; - } - - /* The packet filter set request does not block for a reply */ -} - -void CsrWifiSmeTspecCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ - unifi_priv_t *priv = (unifi_priv_t*)drvpriv; - CsrWifiSmeTspecCfm* cfm = (CsrWifiSmeTspecCfm*)msg; - - if (priv == NULL) { - unifi_error(NULL, "CsrWifiSmeTspecCfmSend: Invalid ospriv.\n"); - return; - } - - sme_complete_request(priv, cfm->status); -} - -void CsrWifiSmeTspecIndHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ -} - -void CsrWifiSmeBlacklistCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ -} - -void CsrWifiSmeEventMaskSetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ -} - - -void CsrWifiSmeRoamStartIndHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ -} - -void CsrWifiSmeRoamCompleteIndHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ - /* This is called when the association completes, before any 802.1x authentication */ -} - -void CsrWifiSmeAssociationStartIndHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ -} - -void CsrWifiSmeAssociationCompleteIndHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ -} - -void CsrWifiSmeIbssStationIndHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ -} - -void CsrWifiSmeWifiOnIndHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ -} - -void CsrWifiSmeRestrictedAccessEnableCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ -} - -void CsrWifiSmeRestrictedAccessDisableCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ -} - - -void CsrWifiSmeAdhocConfigGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ -} - -void CsrWifiSmeAdhocConfigSetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ -#ifdef CSR_SUPPORT_WEXT - unifi_priv_t *priv = (unifi_priv_t*)drvpriv; - CsrWifiSmeAdhocConfigSetCfm* cfm = (CsrWifiSmeAdhocConfigSetCfm*)msg; - - if (priv == NULL) { - unifi_error(NULL, "CsrWifiSmeSmeConfigSetCfmSend: Invalid ospriv.\n"); - return; - } - - sme_complete_request(priv, cfm->status); -#endif -} - -void CsrWifiSmeCalibrationDataGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ -} - -void CsrWifiSmeCalibrationDataSetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ -#ifdef CSR_SUPPORT_WEXT - unifi_priv_t *priv = (unifi_priv_t*)drvpriv; - CsrWifiSmeCalibrationDataSetCfm* cfm = (CsrWifiSmeCalibrationDataSetCfm*)msg; - - if (priv == NULL) { - unifi_error(NULL, "CsrWifiSmeSmeConfigSetCfmSend: Invalid ospriv.\n"); - return; - } - - sme_complete_request(priv, cfm->status); -#endif -} - -void CsrWifiSmeCcxConfigGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ -} - -void CsrWifiSmeCcxConfigSetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ -#ifdef CSR_SUPPORT_WEXT - unifi_priv_t *priv = (unifi_priv_t*)drvpriv; - CsrWifiSmeCcxConfigSetCfm* cfm = (CsrWifiSmeCcxConfigSetCfm*)msg; - - if (priv == NULL) { - unifi_error(NULL, "CsrWifiSmeSmeConfigSetCfmSend: Invalid ospriv.\n"); - return; - } - - sme_complete_request(priv, cfm->status); -#endif -} - -void CsrWifiSmeCloakedSsidsGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ -} - -void CsrWifiSmeCloakedSsidsSetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ -#ifdef CSR_SUPPORT_WEXT - unifi_priv_t *priv = (unifi_priv_t*)drvpriv; - CsrWifiSmeCloakedSsidsSetCfm* cfm = (CsrWifiSmeCloakedSsidsSetCfm*)msg; - - if (priv == NULL) { - unifi_error(NULL, "CsrWifiSmeSmeConfigSetCfmSend: Invalid ospriv.\n"); - return; - } - - sme_complete_request(priv, cfm->status); -#endif -} - - -void CsrWifiSmeCoexConfigSetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ -#ifdef CSR_SUPPORT_WEXT - unifi_priv_t *priv = (unifi_priv_t*)drvpriv; - CsrWifiSmeCoexConfigSetCfm* cfm = (CsrWifiSmeCoexConfigSetCfm*)msg; - - if (priv == NULL) { - unifi_error(NULL, "CsrWifiSmeSmeConfigSetCfmSend: Invalid ospriv.\n"); - return; - } - - sme_complete_request(priv, cfm->status); -#endif -} - -void CsrWifiSmeHostConfigSetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ - unifi_priv_t *priv = (unifi_priv_t*)drvpriv; - CsrWifiSmeHostConfigSetCfm* cfm = (CsrWifiSmeHostConfigSetCfm*)msg; - - if (priv == NULL) { - unifi_error(NULL, "CsrWifiSmeSmeConfigSetCfmSend: Invalid ospriv.\n"); - return; - } - - sme_complete_request(priv, cfm->status); -} - -void CsrWifiSmeLinkQualityGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ -} - - -void CsrWifiSmeMibConfigSetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ -#ifdef CSR_SUPPORT_WEXT - unifi_priv_t *priv = (unifi_priv_t*)drvpriv; - CsrWifiSmeMibConfigSetCfm* cfm = (CsrWifiSmeMibConfigSetCfm*)msg; - - if (priv == NULL) { - unifi_error(NULL, "CsrWifiSmeSmeConfigSetCfmSend: Invalid ospriv.\n"); - return; - } - - sme_complete_request(priv, cfm->status); -#endif -} - -void CsrWifiSmePermanentMacAddressGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ -} - -void CsrWifiSmePowerConfigSetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ - unifi_priv_t *priv = (unifi_priv_t*)drvpriv; - CsrWifiSmePowerConfigSetCfm* cfm = (CsrWifiSmePowerConfigSetCfm*)msg; - - if (priv == NULL) { - unifi_error(NULL, "CsrWifiSmeSmeConfigSetCfmSend: Invalid ospriv.\n"); - return; - } - - sme_complete_request(priv, cfm->status); -} - -void CsrWifiSmeRegulatoryDomainInfoGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ -} - -void CsrWifiSmeRoamingConfigGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ -} - -void CsrWifiSmeMediaStatusIndHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ -#ifdef CSR_SUPPORT_WEXT - unifi_priv_t *priv = (unifi_priv_t*)drvpriv; - CsrWifiSmeMediaStatusInd* ind = (CsrWifiSmeMediaStatusInd*)msg; - - if (priv->smepriv == NULL) { - unifi_error(priv, "CsrWifiSmeMediaStatusIndSend: invalid smepriv\n"); - return; - } - - if (ind->mediaStatus == CSR_WIFI_SME_MEDIA_STATUS_CONNECTED) { - /* - * Send wireless-extension event up to userland to announce - * connection. - */ - wext_send_assoc_event(priv, - (unsigned char *)ind->connectionInfo.bssid.a, - (unsigned char *)ind->connectionInfo.assocReqInfoElements, - ind->connectionInfo.assocReqInfoElementsLength, - (unsigned char *)ind->connectionInfo.assocRspInfoElements, - ind->connectionInfo.assocRspInfoElementsLength, - (unsigned char *)ind->connectionInfo.assocScanInfoElements, - ind->connectionInfo.assocScanInfoElementsLength); - - unifi_trace(priv, UDBG2, "CsrWifiSmeMediaStatusIndSend: IBSS=%pM\n", - ind->connectionInfo.bssid.a); - - sme_mgt_packet_filter_set(priv); - - } else { - /* - * Send wireless-extension event up to userland to announce - * connection lost to a BSS. - */ - wext_send_disassoc_event(priv); - } -#endif -} - -void CsrWifiSmeRoamingConfigSetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ - unifi_priv_t *priv = (unifi_priv_t*)drvpriv; - CsrWifiSmeRoamingConfigSetCfm* cfm = (CsrWifiSmeRoamingConfigSetCfm*)msg; - - if (priv == NULL) { - unifi_error(NULL, "CsrWifiSmeRoamingConfigSetCfmSend: Invalid ospriv.\n"); - return; - } - - sme_complete_request(priv, cfm->status); -} - -void CsrWifiSmeScanConfigGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ -} - -void CsrWifiSmeScanConfigSetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ -#ifdef CSR_SUPPORT_WEXT - unifi_priv_t *priv = (unifi_priv_t*)drvpriv; - CsrWifiSmeScanConfigSetCfm* cfm = (CsrWifiSmeScanConfigSetCfm*)msg; - - if (priv == NULL) { - unifi_error(NULL, "CsrWifiSmeSmeConfigSetCfmSend: Invalid ospriv.\n"); - return; - } - - sme_complete_request(priv, cfm->status); -#endif -} - -void CsrWifiSmeStationMacAddressGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ -} - -void CsrWifiSmeSmeCommonConfigGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ - unifi_priv_t *priv = (unifi_priv_t*)drvpriv; - CsrWifiSmeSmeCommonConfigGetCfm* cfm = (CsrWifiSmeSmeCommonConfigGetCfm*)msg; - - if (priv == NULL) { - unifi_error(NULL, "CsrWifiSmeSmeCommonConfigGetCfmSend: Invalid ospriv.\n"); - return; - } - - priv->sme_reply.deviceConfig = cfm->deviceConfig; - sme_complete_request(priv, cfm->status); -} - -void CsrWifiSmeSmeStaConfigGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ - unifi_priv_t *priv = (unifi_priv_t*)drvpriv; - CsrWifiSmeSmeStaConfigGetCfm* cfm = (CsrWifiSmeSmeStaConfigGetCfm*)msg; - - if (priv == NULL) { - unifi_error(NULL, "CsrWifiSmeSmeStaConfigGetCfmSend: Invalid ospriv.\n"); - return; - } - - priv->sme_reply.staConfig = cfm->smeConfig; - sme_complete_request(priv, cfm->status); -} - -void CsrWifiSmeSmeCommonConfigSetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ - unifi_priv_t *priv = (unifi_priv_t*)drvpriv; - CsrWifiSmeSmeCommonConfigSetCfm* cfm = (CsrWifiSmeSmeCommonConfigSetCfm*)msg; - - if (priv == NULL) { - unifi_error(NULL, "CsrWifiSmeSmeCommonConfigGetCfmSend: Invalid ospriv.\n"); - return; - } - - sme_complete_request(priv, cfm->status); -} - -void CsrWifiSmeSmeStaConfigSetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ - unifi_priv_t *priv = (unifi_priv_t*)drvpriv; - CsrWifiSmeSmeStaConfigSetCfm* cfm = (CsrWifiSmeSmeStaConfigSetCfm*)msg; - - if (priv == NULL) { - unifi_error(NULL, "CsrWifiSmeSmeStaConfigGetCfmSend: Invalid ospriv.\n"); - return; - } - - sme_complete_request(priv, cfm->status); -} - -void CsrWifiSmeGetInterfaceCapabilityCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ -} - -void CsrWifiSmeErrorIndHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ -} - -void CsrWifiSmeInfoIndHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ -} - -void CsrWifiSmeCoreDumpIndHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ -} -void CsrWifiSmeAmpStatusChangeIndHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ -} - -void CsrWifiSmeActivateCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ -} -void CsrWifiSmeDeactivateCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ -} - -#ifdef CSR_SUPPORT_WEXT -#ifdef CSR_SUPPORT_WEXT_AP -void CsrWifiNmeApStartCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ - unifi_priv_t *priv = (unifi_priv_t*)drvpriv; - CsrWifiNmeApStartCfm* cfm = (CsrWifiNmeApStartCfm*)msg; - - if (priv == NULL) { - unifi_error(NULL, "CsrWifiNmeApStartCfmSend: Invalid ospriv.\n"); - return; - } - - sme_complete_request(priv, cfm->status); -} - -void CsrWifiNmeApStopCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ - unifi_priv_t *priv = (unifi_priv_t*)drvpriv; - CsrWifiNmeApStopCfm* cfm = (CsrWifiNmeApStopCfm*)msg; - - if (priv == NULL) { - unifi_error(NULL, "CsrWifiNmeApStopCfmSend: Invalid ospriv.\n"); - return; - } - - sme_complete_request(priv, cfm->status); -} - -void CsrWifiNmeApConfigSetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ - unifi_priv_t *priv = (unifi_priv_t*)drvpriv; - CsrWifiNmeApConfigSetCfm* cfm = (CsrWifiNmeApConfigSetCfm*)msg; - - if (priv == NULL) { - unifi_error(NULL, "CsrWifiNmeApConfigSetCfmSend: Invalid ospriv.\n"); - return; - } - sme_complete_request(priv, cfm->status); -} -#endif -#endif diff --git a/drivers/staging/csr/sme_native.c b/drivers/staging/csr/sme_native.c deleted file mode 100644 index d0b9be31e12c..000000000000 --- a/drivers/staging/csr/sme_native.c +++ /dev/null @@ -1,566 +0,0 @@ -/* - * *************************************************************************** - * - * FILE: sme_native.c - * - * Copyright (C) 2005-2009 by Cambridge Silicon Radio Ltd. - * - * Refer to LICENSE.txt included with this source code for details on - * the license terms. - * - * *************************************************************************** - */ - -#include -#include "unifi_priv.h" -#include "csr_wifi_hip_unifi.h" -#include "csr_wifi_hip_conversions.h" - -static const unsigned char wildcard_address[ETH_ALEN] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; - -int -uf_sme_init(unifi_priv_t *priv) -{ - sema_init(&priv->mlme_blocking_mutex, 1); - -#ifdef CSR_SUPPORT_WEXT - { - int r = uf_init_wext_interface(priv); - if (r != 0) { - return r; - } - } -#endif - - return 0; -} /* uf_sme_init() */ - - -void -uf_sme_deinit(unifi_priv_t *priv) -{ - - /* Free memory allocated for the scan table */ -/* unifi_clear_scan_table(priv); */ - - /* Cancel any pending workqueue tasks */ - flush_workqueue(priv->unifi_workqueue); - -#ifdef CSR_SUPPORT_WEXT - uf_deinit_wext_interface(priv); -#endif - -} /* uf_sme_deinit() */ - - -int sme_mgt_wifi_on(unifi_priv_t *priv) -{ - int r, i; - s32 csrResult; - - if (priv == NULL) { - return -EINVAL; - } - /* Initialize the interface mode to None */ - for (i=0; iinterfacePriv[i]->interfaceMode = 0; - } - - /* Set up interface mode so that get_packet_priority() can - * select the right QOS priority when WMM is enabled. - */ - priv->interfacePriv[0]->interfaceMode = CSR_WIFI_ROUTER_CTRL_MODE_STA; - - r = uf_request_firmware_files(priv, UNIFI_FW_STA); - if (r) { - unifi_error(priv, "sme_mgt_wifi_on: Failed to get f/w\n"); - return r; - } - - /* - * The request to initialise UniFi might come while UniFi is running. - * We need to block all I/O activity until the reset completes, otherwise - * an SDIO error might occur resulting an indication to the SME which - * makes it think that the initialisation has failed. - */ - priv->bh_thread.block_thread = 1; - - /* Power on UniFi */ - CsrSdioClaim(priv->sdio); - csrResult = CsrSdioPowerOn(priv->sdio); - CsrSdioRelease(priv->sdio); - if(csrResult != CSR_RESULT_SUCCESS && csrResult != CSR_SDIO_RESULT_NOT_RESET) { - return -EIO; - } - - if (csrResult == CSR_RESULT_SUCCESS) { - /* Initialise UniFi hardware */ - r = uf_init_hw(priv); - if (r) { - return r; - } - } - - /* Re-enable the I/O thread */ - priv->bh_thread.block_thread = 0; - - /* Disable deep sleep signalling during the firmware initialisation, to - * prevent the wakeup mechanism raising the SDIO clock beyond INIT before - * the first MLME-RESET.ind. It gets re-enabled at the CONNECTED.ind, - * immediately after the MLME-RESET.ind - */ - csrResult = unifi_configure_low_power_mode(priv->card, - UNIFI_LOW_POWER_DISABLED, - UNIFI_PERIODIC_WAKE_HOST_DISABLED); - if (csrResult != CSR_RESULT_SUCCESS) { - unifi_warning(priv, - "sme_mgt_wifi_on: unifi_configure_low_power_mode() returned an error\n"); - } - - - /* Start the I/O thread */ - CsrSdioClaim(priv->sdio); - r = uf_init_bh(priv); - if (r) { - CsrSdioPowerOff(priv->sdio); - CsrSdioRelease(priv->sdio); - return r; - } - CsrSdioRelease(priv->sdio); - - priv->init_progress = UNIFI_INIT_FW_DOWNLOADED; - - return 0; -} - -int -sme_sys_suspend(unifi_priv_t *priv) -{ - const int interfaceNum = 0; /* FIXME */ - CsrResult csrResult; - - /* Abort any pending requests. */ - uf_abort_mlme(priv); - - /* Allow our mlme request to go through. */ - priv->io_aborted = 0; - - /* Send MLME-RESET.req to UniFi. */ - unifi_reset_state(priv, priv->netdev[interfaceNum]->dev_addr, 0); - - /* Stop the network traffic */ - netif_carrier_off(priv->netdev[interfaceNum]); - - /* Put UniFi to deep sleep */ - CsrSdioClaim(priv->sdio); - csrResult = unifi_force_low_power_mode(priv->card); - CsrSdioRelease(priv->sdio); - - return 0; -} /* sme_sys_suspend() */ - - -int -sme_sys_resume(unifi_priv_t *priv) -{ -#ifdef CSR_SUPPORT_WEXT - /* Send disconnect event so clients will re-initialise connection. */ - memset(priv->wext_conf.current_ssid, 0, UNIFI_MAX_SSID_LEN); - memset((void*)priv->wext_conf.current_bssid, 0, ETH_ALEN); - priv->wext_conf.capability = 0; - wext_send_disassoc_event(priv); -#endif - return 0; -} /* sme_sys_resume() */ - - -/* - * --------------------------------------------------------------------------- - * sme_native_log_event - * - * Callback function to be registered as the SME event callback. - * Copies the signal content into a new udi_log_t struct and adds - * it to the read queue for the SME client. - * - * Arguments: - * arg This is the value given to unifi_add_udi_hook, in - * this case a pointer to the client instance. - * signal Pointer to the received signal. - * signal_len Size of the signal structure in bytes. - * bulkdata Pointers to any associated bulk data. - * dir Direction of the signal. Zero means from host, - * non-zero means to host. - * - * Returns: - * None. - * --------------------------------------------------------------------------- - */ -void -sme_native_log_event(ul_client_t *pcli, - const u8 *sig_packed, int sig_len, - const bulk_data_param_t *bulkdata, - int dir) -{ - unifi_priv_t *priv; - udi_log_t *logptr; - u8 *p; - int i, r; - int signal_len; - int total_len; - udi_msg_t *msgptr; - CSR_SIGNAL signal; - ul_client_t *client = pcli; - - if (client == NULL) { - unifi_error(NULL, "sme_native_log_event: client has exited\n"); - return; - } - - priv = uf_find_instance(client->instance); - if (!priv) { - unifi_error(priv, "invalid priv\n"); - return; - } - - /* Just a sanity check */ - if ((sig_packed == NULL) || (sig_len <= 0)) { - return; - } - - /* Get the unpacked signal */ - r = read_unpack_signal(sig_packed, &signal); - if (r == 0) { - signal_len = SigGetSize(&signal); - } else { - u16 receiver_id = CSR_GET_UINT16_FROM_LITTLE_ENDIAN((sig_packed) + sizeof(u16)) & 0xFF00; - - /* The control indications are 1 byte, pass them to client. */ - if (sig_len == 1) { - unifi_trace(priv, UDBG5, - "Control indication (0x%x) for native SME.\n", - *sig_packed); - - *(u8*)&signal = *sig_packed; - signal_len = sig_len; - } else if (receiver_id == 0) { - /* - * Also "unknown" signals with a ReceiverId of 0 are passed to the client - * without unpacking. (This is a code size optimisation to allow signals - * that the driver not interested in to be dropped from the unpack code). - */ - unifi_trace(priv, UDBG5, - "Signal 0x%.4X with ReceiverId 0 for native SME.\n", - CSR_GET_UINT16_FROM_LITTLE_ENDIAN(sig_packed)); - - *(u8*)&signal = *sig_packed; - signal_len = sig_len; - } else { - unifi_error(priv, - "sme_native_log_event - Received unknown signal 0x%.4X.\n", - CSR_GET_UINT16_FROM_LITTLE_ENDIAN(sig_packed)); - return; - } - } - - unifi_trace(priv, UDBG3, "sme_native_log_event: signal 0x%.4X for %d\n", - signal.SignalPrimitiveHeader.SignalId, - client->client_id); - - total_len = signal_len; - /* Calculate the buffer we need to store signal plus bulk data */ - for (i = 0; i < UNIFI_MAX_DATA_REFERENCES; i++) { - total_len += bulkdata->d[i].data_length; - } - - /* Allocate log structure plus actual signal. */ - logptr = kmalloc(sizeof(udi_log_t) + total_len, GFP_KERNEL); - - if (logptr == NULL) { - unifi_error(priv, - "Failed to allocate %d bytes for a UDI log record\n", - sizeof(udi_log_t) + total_len); - return; - } - - /* Fill in udi_log struct */ - INIT_LIST_HEAD(&logptr->q); - msgptr = &logptr->msg; - msgptr->length = sizeof(udi_msg_t) + total_len; - msgptr->timestamp = jiffies_to_msecs(jiffies); - msgptr->direction = dir; - msgptr->signal_length = signal_len; - - /* Copy signal and bulk data to the log */ - p = (u8 *)(msgptr + 1); - memcpy(p, &signal, signal_len); - p += signal_len; - - /* Append any bulk data */ - for (i = 0; i < UNIFI_MAX_DATA_REFERENCES; i++) { - int len = bulkdata->d[i].data_length; - - /* - * Len here might not be the same as the length in the bulk data slot. - * The slot length will always be even, but len could be odd. - */ - if (len > 0) { - if (bulkdata->d[i].os_data_ptr) { - memcpy(p, bulkdata->d[i].os_data_ptr, len); - } else { - memset(p, 0, len); - } - p += len; - } - } - - /* Add to tail of log queue */ - down(&client->udi_sem); - list_add_tail(&logptr->q, &client->udi_log); - up(&client->udi_sem); - - /* Wake any waiting user process */ - wake_up_interruptible(&client->udi_wq); - -} /* sme_native_log_event() */ - - -/* - * --------------------------------------------------------------------------- - * unifi_ta_indicate_protocol - * - * Report that a packet of a particular type has been seen - * - * Arguments: - * drv_priv The device context pointer passed to ta_init. - * protocol The protocol type enum value. - * direction Whether the packet was a tx or rx. - * src_addr The source MAC address from the data packet. - * - * Returns: - * None. - * - * Notes: - * We defer the actual sending to a background workqueue, - * see uf_ta_ind_wq(). - * --------------------------------------------------------------------------- - */ -void -unifi_ta_indicate_protocol(void *ospriv, - CsrWifiRouterCtrlTrafficPacketType packet_type, - CsrWifiRouterCtrlProtocolDirection direction, - const CsrWifiMacAddress *src_addr) -{ - -} /* unifi_ta_indicate_protocol */ - -/* - * --------------------------------------------------------------------------- - * unifi_ta_indicate_sampling - * - * Send the TA sampling information to the SME. - * - * Arguments: - * drv_priv The device context pointer passed to ta_init. - * stats The TA sampling data to send. - * - * Returns: - * None. - * --------------------------------------------------------------------------- - */ -void -unifi_ta_indicate_sampling(void *ospriv, CsrWifiRouterCtrlTrafficStats *stats) -{ - -} /* unifi_ta_indicate_sampling() */ - - -void -unifi_ta_indicate_l4stats(void *ospriv, - u32 rxTcpThroughput, - u32 txTcpThroughput, - u32 rxUdpThroughput, - u32 txUdpThroughput) -{ - -} /* unifi_ta_indicate_l4stats() */ - -/* - * --------------------------------------------------------------------------- - * uf_native_process_udi_signal - * - * Process interesting signals from the UDI interface. - * - * Arguments: - * pcli A pointer to the client instance. - * signal Pointer to the received signal. - * signal_len Size of the signal structure in bytes. - * bulkdata Pointers to any associated bulk data. - * dir Direction of the signal. Zero means from host, - * non-zero means to host. - * - * - * Returns: - * None. - * --------------------------------------------------------------------------- - */ -void -uf_native_process_udi_signal(ul_client_t *pcli, - const u8 *packed_signal, int packed_signal_len, - const bulk_data_param_t *bulkdata, int dir) -{ - -} /* uf_native_process_udi_signal() */ - - -/* - * --------------------------------------------------------------------------- - * sme_native_mlme_event_handler - * - * Callback function to be used as the udi_event_callback when registering - * as a client. - * This function implements a blocking request-reply interface for WEXT. - * To use it, a client specifies this function as the udi_event_callback - * to ul_register_client(). The signal dispatcher in - * unifi_receive_event() will call this function to deliver a signal. - * - * Arguments: - * pcli Pointer to the client instance. - * signal Pointer to the received signal. - * signal_len Size of the signal structure in bytes. - * bulkdata Pointer to structure containing any associated bulk data. - * dir Direction of the signal. Zero means from host, - * non-zero means to host. - * - * Returns: - * None. - * --------------------------------------------------------------------------- - */ -void -sme_native_mlme_event_handler(ul_client_t *pcli, - const u8 *sig_packed, int sig_len, - const bulk_data_param_t *bulkdata, - int dir) -{ - CSR_SIGNAL signal; - int signal_len; - unifi_priv_t *priv = uf_find_instance(pcli->instance); - int id, r; - - /* Just a sanity check */ - if ((sig_packed == NULL) || (sig_len <= 0)) { - return; - } - - /* Get the unpacked signal */ - r = read_unpack_signal(sig_packed, &signal); - if (r == 0) { - signal_len = SigGetSize(&signal); - } else { - unifi_error(priv, - "sme_native_mlme_event_handler - Received unknown signal 0x%.4X.\n", - CSR_GET_UINT16_FROM_LITTLE_ENDIAN(sig_packed)); - return; - } - - id = signal.SignalPrimitiveHeader.SignalId; - unifi_trace(priv, UDBG4, "wext - Process signal 0x%.4X\n", id); - - /* - * Take the appropriate action for the signal. - */ - switch (id) { - /* - * Confirm replies from UniFi. - * These all have zero or one CSR_DATAREF member. (FIXME: check this is still true for softmac) - */ - case CSR_MA_PACKET_CONFIRM_ID: - case CSR_MLME_RESET_CONFIRM_ID: - case CSR_MLME_GET_CONFIRM_ID: - case CSR_MLME_SET_CONFIRM_ID: - case CSR_MLME_GET_NEXT_CONFIRM_ID: - case CSR_MLME_POWERMGT_CONFIRM_ID: - case CSR_MLME_SCAN_CONFIRM_ID: - case CSR_MLME_HL_SYNC_CONFIRM_ID: - case CSR_MLME_MEASURE_CONFIRM_ID: - case CSR_MLME_SETKEYS_CONFIRM_ID: - case CSR_MLME_DELETEKEYS_CONFIRM_ID: - case CSR_MLME_HL_SYNC_CANCEL_CONFIRM_ID: - case CSR_MLME_ADD_PERIODIC_CONFIRM_ID: - case CSR_MLME_DEL_PERIODIC_CONFIRM_ID: - case CSR_MLME_ADD_AUTONOMOUS_SCAN_CONFIRM_ID: - case CSR_MLME_DEL_AUTONOMOUS_SCAN_CONFIRM_ID: - case CSR_MLME_SET_PACKET_FILTER_CONFIRM_ID: - case CSR_MLME_STOP_MEASURE_CONFIRM_ID: - case CSR_MLME_PAUSE_AUTONOMOUS_SCAN_CONFIRM_ID: - case CSR_MLME_ADD_TRIGGERED_GET_CONFIRM_ID: - case CSR_MLME_DEL_TRIGGERED_GET_CONFIRM_ID: - case CSR_MLME_ADD_BLACKOUT_CONFIRM_ID: - case CSR_MLME_DEL_BLACKOUT_CONFIRM_ID: - case CSR_MLME_ADD_RX_TRIGGER_CONFIRM_ID: - case CSR_MLME_DEL_RX_TRIGGER_CONFIRM_ID: - case CSR_MLME_CONNECT_STATUS_CONFIRM_ID: - case CSR_MLME_MODIFY_BSS_PARAMETER_CONFIRM_ID: - case CSR_MLME_ADD_TEMPLATE_CONFIRM_ID: - case CSR_MLME_CONFIG_QUEUE_CONFIRM_ID: - case CSR_MLME_ADD_TSPEC_CONFIRM_ID: - case CSR_MLME_DEL_TSPEC_CONFIRM_ID: - case CSR_MLME_START_AGGREGATION_CONFIRM_ID: - case CSR_MLME_STOP_AGGREGATION_CONFIRM_ID: - case CSR_MLME_SM_START_CONFIRM_ID: - case CSR_MLME_LEAVE_CONFIRM_ID: - case CSR_MLME_SET_TIM_CONFIRM_ID: - case CSR_MLME_GET_KEY_SEQUENCE_CONFIRM_ID: - case CSR_MLME_SET_CHANNEL_CONFIRM_ID: - case CSR_MLME_ADD_MULTICAST_ADDRESS_CONFIRM_ID: - case CSR_DEBUG_GENERIC_CONFIRM_ID: - unifi_mlme_copy_reply_and_wakeup_client(pcli, &signal, signal_len, bulkdata); - break; - - case CSR_MLME_CONNECTED_INDICATION_ID: - /* We currently ignore the connected-ind for softmac f/w development */ - unifi_info(priv, "CSR_MLME_CONNECTED_INDICATION_ID ignored\n"); - break; - - default: - break; - } - -} /* sme_native_mlme_event_handler() */ - - - -/* - * ------------------------------------------------------------------------- - * unifi_reset_state - * - * Ensure that a MAC address has been set. - * Send the MLME-RESET signal. - * This must be called at least once before starting to do any - * network activities (e.g. scan, join etc). - * - * Arguments: - * priv Pointer to device private context struct - * macaddr Pointer to chip MAC address. - * If this is FF:FF:FF:FF:FF:FF it will be replaced - * with the MAC address from the chip. - * set_default_mib 1 if the f/w must reset the MIB to the default values - * 0 otherwise - * - * Returns: - * 0 on success, an error code otherwise. - * ------------------------------------------------------------------------- - */ -int -unifi_reset_state(unifi_priv_t *priv, unsigned char *macaddr, - unsigned char set_default_mib) -{ - int r = 0; - -#ifdef CSR_SUPPORT_WEXT - /* The reset clears any 802.11 association. */ - priv->wext_conf.flag_associated = 0; -#endif - - return r; -} /* unifi_reset_state() */ - diff --git a/drivers/staging/csr/sme_sys.c b/drivers/staging/csr/sme_sys.c deleted file mode 100644 index b5258d71d250..000000000000 --- a/drivers/staging/csr/sme_sys.c +++ /dev/null @@ -1,3260 +0,0 @@ -/* - * --------------------------------------------------------------------------- - * FILE: sme_sys.c - * - * PURPOSE: - * Driver specific implementation of the SME SYS SAP. - * It is part of the porting exercise. - * - * Copyright (C) 2008-2011 by Cambridge Silicon Radio Ltd. - * - * Refer to LICENSE.txt included with this source code for details on - * the license terms. - * - * --------------------------------------------------------------------------- - */ - -#include "csr_wifi_hip_unifiversion.h" -#include "unifi_priv.h" -#include "csr_wifi_hip_conversions.h" -#ifdef CSR_SUPPORT_WEXT_AP -#include "csr_wifi_sme_sef.h" -#endif - -/* - * This file implements the SME SYS API and contains the following functions: - * CsrWifiRouterCtrlMediaStatusReqHandler() - * CsrWifiRouterCtrlHipReqHandler() - * CsrWifiRouterCtrlPortConfigureReqHandler() - * CsrWifiRouterCtrlWifiOnReqHandler() - * CsrWifiRouterCtrlWifiOffReqHandler() - * CsrWifiRouterCtrlSuspendResHandler() - * CsrWifiRouterCtrlResumeResHandler() - * CsrWifiRouterCtrlQosControlReqHandler() - * CsrWifiRouterCtrlConfigurePowerModeReqHandler() - * CsrWifiRouterCtrlWifiOnResHandler() - * CsrWifiRouterCtrlWifiOffRspHandler() - * CsrWifiRouterCtrlMulticastAddressResHandler() - * CsrWifiRouterCtrlTrafficConfigReqHandler() - * CsrWifiRouterCtrlTrafficClassificationReqHandler() - * CsrWifiRouterCtrlTclasAddReqHandler() - * CsrWifiRouterCtrlTclasDelReqHandler() - * CsrWifiRouterCtrlSetModeReqHandler() - * CsrWifiRouterCtrlWapiMulticastFilterReqHandler() - * CsrWifiRouterCtrlWapiUnicastFilterReqHandler() - * CsrWifiRouterCtrlWapiUnicastTxPktReqHandler() - * CsrWifiRouterCtrlWapiRxPktReqHandler() - * CsrWifiRouterCtrlWapiFilterReqHandler() - */ - -#ifdef CSR_SUPPORT_SME -static void check_inactivity_timer_expire_func(unsigned long data); -void uf_send_disconnected_ind_wq(struct work_struct *work); -#endif - -void send_auto_ma_packet_confirm(unifi_priv_t *priv, - netInterface_priv_t *interfacePriv, - struct list_head *buffered_frames_list) -{ - tx_buffered_packets_t *buffered_frame_item = NULL; - struct list_head *listHead; - struct list_head *placeHolder; - int client_id; - - CSR_SIGNAL unpacked_signal; - u8 sigbuf[UNIFI_PACKED_SIGBUF_SIZE]; - u16 packed_siglen; - - - list_for_each_safe(listHead, placeHolder, buffered_frames_list) - { - buffered_frame_item = list_entry(listHead, tx_buffered_packets_t, q); - - if(!buffered_frame_item) { - unifi_error(priv, "Entry should exist, otherwise it is a (BUG)\n"); - continue; - } - - if ((interfacePriv->interfaceMode != CSR_WIFI_ROUTER_CTRL_MODE_NONE) && - (priv->wifi_on_state == wifi_on_done)) - { - - unifi_warning(priv, "Send MA_PACKET_CONFIRM to SenderProcessId = %x for (HostTag = %x TransmissionControl = %x)\n", - (buffered_frame_item->leSenderProcessId), - buffered_frame_item->hostTag, - buffered_frame_item->transmissionControl); - - client_id = buffered_frame_item->leSenderProcessId & 0xFF00; - - if (client_id == priv->sme_cli->sender_id) - { - /* construct a MA-PACKET.confirm message for SME */ - memset(&unpacked_signal, 0, sizeof(unpacked_signal)); - unpacked_signal.SignalPrimitiveHeader.SignalId = CSR_MA_PACKET_CONFIRM_ID; - unpacked_signal.SignalPrimitiveHeader.ReceiverProcessId = buffered_frame_item->leSenderProcessId; - unpacked_signal.SignalPrimitiveHeader.SenderProcessId = CSR_WIFI_ROUTER_IFACEQUEUE; - - unpacked_signal.u.MaPacketConfirm.VirtualInterfaceIdentifier = uf_get_vif_identifier(interfacePriv->interfaceMode, - interfacePriv->InterfaceTag); - unpacked_signal.u.MaPacketConfirm.TransmissionStatus = CSR_RESULT_FAILURE; - unpacked_signal.u.MaPacketConfirm.RetryCount = 0; - unpacked_signal.u.MaPacketConfirm.Rate = buffered_frame_item->rate; - unpacked_signal.u.MaPacketConfirm.HostTag = buffered_frame_item->hostTag; - - write_pack(&unpacked_signal, sigbuf, &packed_siglen); - unifi_warning(priv, "MA_PACKET_CONFIRM for SME (0x%x, 0x%x, 0x%x, 0x%x)\n", - unpacked_signal.SignalPrimitiveHeader.ReceiverProcessId, - unpacked_signal.SignalPrimitiveHeader.SenderProcessId, - unpacked_signal.u.MaPacketConfirm.VirtualInterfaceIdentifier, - unpacked_signal.u.MaPacketConfirm.HostTag); - - CsrWifiRouterCtrlHipIndSend(priv->CSR_WIFI_SME_IFACEQUEUE, - packed_siglen, - (u8 *)sigbuf, - 0, NULL, - 0, NULL); - } - else if((buffered_frame_item->hostTag & 0x80000000)) - { - /* construct a MA-PACKET.confirm message for NME */ - unifi_warning(priv, "MA_PACKET_CONFIRM for NME (0x%x, 0x%x, 0x%x, 0x%x)\n", - buffered_frame_item->leSenderProcessId, - buffered_frame_item->interfaceTag, - buffered_frame_item->transmissionControl, - (buffered_frame_item->hostTag & 0x3FFFFFFF)); - - CsrWifiRouterMaPacketCfmSend((buffered_frame_item->leSenderProcessId & 0xFF), - buffered_frame_item->interfaceTag, - CSR_RESULT_FAILURE, - (buffered_frame_item->hostTag & 0x3FFFFFFF), - buffered_frame_item->rate); - - } - else - { - unifi_warning(priv, "Buffered packet dropped without sending a confirm\n"); - } - - } - - list_del(listHead); - kfree(buffered_frame_item); - buffered_frame_item = NULL; - } -} - -void CsrWifiRouterCtrlMediaStatusReqHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ - unifi_priv_t *priv = (unifi_priv_t*)drvpriv; - CsrWifiRouterCtrlMediaStatusReq* req = (CsrWifiRouterCtrlMediaStatusReq*)msg; - netInterface_priv_t *interfacePriv = priv->interfacePriv[req->interfaceTag]; - unsigned long flags; - - if (priv->smepriv == NULL) { - unifi_error(priv, "CsrWifiRouterCtrlMediaStatusReqHandler: invalid smepriv\n"); - return; - } - if (req->interfaceTag >= CSR_WIFI_NUM_INTERFACES) { - unifi_error(priv, "CsrWifiRouterCtrlMediaStatusReqHandler: invalid interfaceTag\n"); - return; - } - unifi_trace(priv, UDBG3, "CsrWifiRouterCtrlMediaStatusReqHandler: Mode = %d req->mediaStatus = %d\n", interfacePriv->interfaceMode, req->mediaStatus); - if (interfacePriv->interfaceMode != CSR_WIFI_ROUTER_CTRL_MODE_AMP) { - bulk_data_desc_t bulk_data; - - bulk_data.data_length = 0; - - spin_lock_irqsave(&priv->m4_lock, flags); - if (interfacePriv->m4_bulk_data.data_length > 0) { - bulk_data = interfacePriv->m4_bulk_data; - interfacePriv->m4_bulk_data.net_buf_length = 0; - interfacePriv->m4_bulk_data.data_length = 0; - interfacePriv->m4_bulk_data.os_data_ptr = interfacePriv->m4_bulk_data.os_net_buf_ptr = NULL; - } - spin_unlock_irqrestore(&priv->m4_lock, flags); - - if (bulk_data.data_length != 0) { - unifi_trace(priv, UDBG5, "CsrWifiRouterCtrlMediaStatusReqHandler: free M4\n"); - unifi_net_data_free(priv, &bulk_data); - } - - if ((req->mediaStatus == CSR_WIFI_SME_MEDIA_STATUS_CONNECTED) && - (interfacePriv->connected != UnifiConnected)) { - - switch(interfacePriv->interfaceMode){ - case CSR_WIFI_ROUTER_CTRL_MODE_AP: - case CSR_WIFI_ROUTER_CTRL_MODE_P2PGO: - interfacePriv->connected = UnifiConnected; - netif_carrier_on(priv->netdev[req->interfaceTag]); -#ifdef CSR_SUPPORT_WEXT - wext_send_started_event(priv); -#endif - unifi_trace(priv, UDBG1, - "CsrWifiRouterCtrlMediaStatusReqHandler: AP/P2PGO setting netif_carrier_on\n"); - netif_tx_wake_all_queues(priv->netdev[req->interfaceTag]); - break; - - default: -#ifdef CSR_SUPPORT_WEXT - /* In the WEXT builds (sme and native), the userspace is not ready - * to process any EAPOL or WAPI packets, until it has been informed - * of the NETDEV_CHANGE. - */ - if (interfacePriv->netdev_callback_registered && (interfacePriv->interfaceMode != CSR_WIFI_ROUTER_CTRL_MODE_P2PCLI)) { - interfacePriv->wait_netdev_change = TRUE; - unifi_trace(priv, UDBG1, - "CsrWifiRouterCtrlMediaStatusReqHandler: waiting for NETDEV_CHANGE\n"); - /* - * Carrier can go to on, only after wait_netdev_change is set to TRUE. - * Otherwise there can be a race in uf_netdev_event(). - */ - netif_carrier_on(priv->netdev[req->interfaceTag]); - unifi_trace(priv, UDBG1, - "CsrWifiRouterCtrlMediaStatusReqHandler: STA/P2PCLI setting netif_carrier_on\n"); - } - else -#endif - { - /* In the NME build, the userspace does not wait for the NETDEV_CHANGE - * so it is ready to process all the EAPOL or WAPI packets. - * At this point, we enable all the Tx queues, and we indicate any packets - * that are queued (and the respective port is opened). - */ - static const CsrWifiMacAddress broadcast_address = {{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}}; - interfacePriv->connected = UnifiConnected; - unifi_trace(priv, UDBG1, - "CsrWifiRouterMediaStatusReqHandler: UnifiConnected && netif_carrier_on\n"); - netif_carrier_on(priv->netdev[req->interfaceTag]); - netif_tx_wake_all_queues(priv->netdev[req->interfaceTag]); - uf_process_rx_pending_queue(priv, UF_UNCONTROLLED_PORT_Q, broadcast_address, 1, interfacePriv->InterfaceTag); - uf_process_rx_pending_queue(priv, UF_CONTROLLED_PORT_Q, broadcast_address, 1, interfacePriv->InterfaceTag); - } - break; - } - } - - if (req->mediaStatus == CSR_WIFI_SME_MEDIA_STATUS_DISCONNECTED) { -#ifdef CSR_SUPPORT_WEXT - unifi_trace(priv, UDBG1, - "CsrWifiRouterMediaStatusReqHandler: cancel waiting for NETDEV_CHANGE\n"); - interfacePriv->wait_netdev_change = FALSE; -#endif - unifi_trace(priv, UDBG1, - "CsrWifiRouterMediaStatusReqHandler: setting netif_carrier_off\n"); - netif_carrier_off(priv->netdev[req->interfaceTag]); -#ifdef CSR_SUPPORT_WEXT - switch(interfacePriv->interfaceMode){ - case CSR_WIFI_ROUTER_CTRL_MODE_AP: - case CSR_WIFI_ROUTER_CTRL_MODE_P2PGO: - wext_send_started_event(priv); - break; - default: - break; - } -#endif - interfacePriv->connected = UnifiNotConnected; - } - } else { - /* For AMP, just update the L2 connected flag */ - if (req->mediaStatus == CSR_WIFI_SME_MEDIA_STATUS_CONNECTED) { - unifi_trace(priv, UDBG1, "CsrWifiRouterCtrlMediaStatusReqHandler: AMP connected\n"); - interfacePriv->connected = UnifiConnected; - } else { - unifi_trace(priv, UDBG1, "CsrWifiRouterCtrlMediaStatusReqHandler: AMP disconnected\n"); - interfacePriv->connected = UnifiNotConnected; - } - } -} - - -void CsrWifiRouterCtrlHipReqHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ - unifi_priv_t *priv = (unifi_priv_t*)drvpriv; - CsrWifiRouterCtrlHipReq* hipreq = (CsrWifiRouterCtrlHipReq*)msg; - bulk_data_param_t bulkdata; - u8 *signal_ptr; - int signal_length; - int r=0; - void *dest; - CsrResult csrResult; - CSR_SIGNAL *signal; - u16 interfaceTag = 0; - CSR_MA_PACKET_REQUEST *req; - netInterface_priv_t *interfacePriv; - - if (priv == NULL) { - return; - } - if (priv->smepriv == NULL) { - unifi_error(priv, "CsrWifiRouterCtrlHipReqHandler: invalid smepriv\n"); - return; - } - if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) { - unifi_error(priv, "CsrWifiRouterCtrlHipReqHandler: invalid interfaceTag\n"); - return; - } - - interfacePriv = priv->interfacePriv[interfaceTag]; - - /* Initialize bulkdata to avoid os_net_buf is garbage */ - memset(&bulkdata, 0, sizeof(bulk_data_param_t)); - - signal = (CSR_SIGNAL *)hipreq->mlmeCommand; - - unifi_trace(priv, UDBG4, "CsrWifiRouterCtrlHipReqHandler: 0x04%X ---->\n", - *((u16*)hipreq->mlmeCommand)); - - /* Construct the signal. */ - signal_ptr = (u8*)hipreq->mlmeCommand; - signal_length = hipreq->mlmeCommandLength; - - /* - * The MSB of the sender ID needs to be set to the client ID. - * The LSB is controlled by the SME. - */ - signal_ptr[5] = (priv->sme_cli->sender_id >> 8) & 0xff; - - /* Allocate buffers for the bulk data. */ - if (hipreq->dataRef1Length) { - csrResult = unifi_net_data_malloc(priv, &bulkdata.d[0], hipreq->dataRef1Length); - if (csrResult == CSR_RESULT_SUCCESS) { - dest = (void*)bulkdata.d[0].os_data_ptr; - memcpy(dest, hipreq->dataRef1, hipreq->dataRef1Length); - bulkdata.d[0].data_length = hipreq->dataRef1Length; - } else { - unifi_warning(priv, "signal not sent down, allocation failed in CsrWifiRouterCtrlHipReqHandler\n"); - return; - } - } else { - bulkdata.d[0].os_data_ptr = NULL; - bulkdata.d[0].data_length = 0; - } - if (hipreq->dataRef2Length) { - csrResult = unifi_net_data_malloc(priv, &bulkdata.d[1], hipreq->dataRef2Length); - if (csrResult == CSR_RESULT_SUCCESS) { - dest = (void*)bulkdata.d[1].os_data_ptr; - memcpy(dest, hipreq->dataRef2, hipreq->dataRef2Length); - bulkdata.d[1].data_length = hipreq->dataRef2Length; - } else { - if (bulkdata.d[0].data_length) - { - unifi_net_data_free(priv, &bulkdata.d[0]); - } - unifi_warning(priv, "signal not sent down, allocation failed in CsrWifiRouterCtrlHipReqHandler\n"); - return; - } - } else { - bulkdata.d[1].os_data_ptr = NULL; - bulkdata.d[1].data_length = 0; - } - - unifi_trace(priv, UDBG3, "SME SEND: Signal 0x%.4X \n", - *((u16*)signal_ptr)); - if (signal->SignalPrimitiveHeader.SignalId == CSR_MA_PACKET_REQUEST_ID) - { - CSR_SIGNAL unpacked_signal; - read_unpack_signal((u8 *) signal, &unpacked_signal); - req = &unpacked_signal.u.MaPacketRequest; - interfaceTag = req->VirtualInterfaceIdentifier & 0xff; - switch(interfacePriv->interfaceMode) - { - case CSR_WIFI_ROUTER_CTRL_MODE_NONE: - unifi_error(priv, "CsrWifiRouterCtrlHipReqHandler: invalid mode: NONE \n"); - break; - default: - unifi_trace(priv, UDBG5, "mode is %x\n", interfacePriv->interfaceMode); - } - /* While sending ensure that first 2 bits b31 and b30 are 00. These are used for local routing*/ - r = uf_process_ma_packet_req(priv, req->Ra.x, (req->HostTag & 0x3FFFFFFF), interfaceTag, - req->TransmissionControl, req->TransmitRate, - req->Priority, signal->SignalPrimitiveHeader.SenderProcessId, - &bulkdata); - if (r) - { - if (bulkdata.d[0].data_length) - { - unifi_net_data_free(priv, &bulkdata.d[0]); - } - if (bulkdata.d[1].data_length) - { - unifi_net_data_free(priv, &bulkdata.d[1]); - } - } - } else { - /* ul_send_signal_raw frees the bulk data if it fails */ - r = ul_send_signal_raw(priv, signal_ptr, signal_length, &bulkdata); - } - - if (r) { - unifi_error(priv, - "CsrWifiRouterCtrlHipReqHandler: Failed to send signal (0x%.4X - %u)\n", - *((u16*)signal_ptr), r); - CsrWifiRouterCtrlWifiOffIndSend(priv->CSR_WIFI_SME_IFACEQUEUE, 0, CSR_WIFI_SME_CONTROL_INDICATION_ERROR); - } - - unifi_trace(priv, UDBG4, "CsrWifiRouterCtrlHipReqHandler: <----\n"); -} - -#ifdef CSR_WIFI_SEND_GRATUITOUS_ARP -static void -uf_send_gratuitous_arp(unifi_priv_t *priv, u16 interfaceTag) -{ - netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag]; - CSR_PRIORITY priority; - CSR_SIGNAL signal; - bulk_data_param_t bulkdata; - CsrResult csrResult; - struct sk_buff *skb, *newSkb = NULL; - s8 protection; - int r; - static const u8 arp_req[36] = {0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00, - 0x08, 0x06, 0x00, 0x01, 0x08, 0x00, 0x06, 0x04, 0x00, 0x01, - 0x00, 0x02, 0x5f, 0x20, 0x2f, 0x02, - 0xc0, 0xa8, 0x00, 0x02, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xc0, 0xa8, 0x00, 0x02}; - - csrResult = unifi_net_data_malloc(priv, &bulkdata.d[0], sizeof(arp_req)); - if (csrResult != CSR_RESULT_SUCCESS) - { - unifi_error(priv, "Failed to allocate bulk data in CsrWifiSmeRoamCompleteIndHandler()\n"); - return; - } - skb = (struct sk_buff *)(bulkdata.d[0].os_net_buf_ptr); - skb->len = bulkdata.d[0].data_length; - - memcpy(skb->data, arp_req, sizeof(arp_req)); - /* add MAC and IP address */ - memcpy(skb->data + 16, priv->netdev[interfaceTag]->dev_addr, ETH_ALEN); - skb->data[22] = (priv->sta_ip_address ) & 0xFF; - skb->data[23] = (priv->sta_ip_address >> 8) & 0xFF; - skb->data[24] = (priv->sta_ip_address >> 16) & 0xFF; - skb->data[25] = (priv->sta_ip_address >> 24) & 0xFF; - skb->data[32] = (priv->sta_ip_address ) & 0xFF; - skb->data[33] = (priv->sta_ip_address >> 8) & 0xFF; - skb->data[34] = (priv->sta_ip_address >> 16) & 0xFF; - skb->data[35] = (priv->sta_ip_address >> 24) & 0xFF; - - bulkdata.d[1].os_data_ptr = NULL; - bulkdata.d[1].os_net_buf_ptr = NULL; - bulkdata.d[1].net_buf_length = bulkdata.d[1].data_length = 0; - - if ((protection = uf_get_protection_bit_from_interfacemode(priv, interfaceTag, &arp_req[26])) < 0) - { - unifi_error(priv, "CsrWifiSmeRoamCompleteIndHandler: Failed to determine protection mode\n"); - unifi_net_data_free(priv, &bulkdata.d[0]); - return; - } - - if ((priv->sta_wmm_capabilities & QOS_CAPABILITY_WMM_ENABLED) == 1) - { - priority = CSR_QOS_UP0; - } - else - { - priority = CSR_CONTENTION; - } - - if (prepare_and_add_macheader(priv, skb, newSkb, priority, &bulkdata, - interfaceTag, &arp_req[26], - priv->netdev[interfaceTag]->dev_addr, protection)) - { - unifi_error(priv, "CsrWifiSmeRoamCompleteIndHandler: failed to create MAC header\n"); - unifi_net_data_free(priv, &bulkdata.d[0]); - return; - } - bulkdata.d[0].os_data_ptr = skb->data; - bulkdata.d[0].os_net_buf_ptr = skb; - bulkdata.d[0].data_length = skb->len; - - unifi_frame_ma_packet_req(priv, priority, 0, 0xffffffff, interfaceTag, - CSR_NO_CONFIRM_REQUIRED, priv->netdev_client->sender_id, - interfacePriv->bssid.a, &signal); - - r = ul_send_signal_unpacked(priv, &signal, &bulkdata); - if (r) - { - unifi_error(priv, "CsrWifiSmeRoamCompleteIndHandler: failed to send QOS data null packet result: %d\n", r); - unifi_net_data_free(priv, &bulkdata.d[0]); - return; - } - -} -#endif /* CSR_WIFI_SEND_GRATUITOUS_ARP */ - -/* - * --------------------------------------------------------------------------- - * configure_data_port - * - * Store the new controlled port configuration. - * - * Arguments: - * priv Pointer to device private context struct - * port_cfg Pointer to the port configuration - * - * Returns: - * An unifi_ControlledPortAction value. - * --------------------------------------------------------------------------- - */ -static int -configure_data_port(unifi_priv_t *priv, - CsrWifiRouterCtrlPortAction port_action, - const CsrWifiMacAddress *macAddress, - const int queue, - u16 interfaceTag) -{ - const u8 broadcast_mac_address[] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}; - unifi_port_config_t *port; - netInterface_priv_t *interfacePriv; - int i; - const char* controlled_string; /* cosmetic "controlled"/"uncontrolled" for trace */ - - if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) { - unifi_error(priv, "configure_data_port: bad interfaceTag\n"); - return -EFAULT; - } - - interfacePriv = priv->interfacePriv[interfaceTag]; - - if (queue == UF_CONTROLLED_PORT_Q) { - port = &interfacePriv->controlled_data_port; - controlled_string = "controlled"; - } else { - port = &interfacePriv->uncontrolled_data_port; - controlled_string = "uncontrolled"; - } - - unifi_trace(priv, UDBG2, - "port config request %pM %s with port_action %d.\n", - macAddress->a, controlled_string, port_action); - - /* If the new configuration has the broadcast MAC address or if we are in infrastructure mode then clear the list first and set port overide mode */ - if ((CSR_WIFI_ROUTER_CTRL_MODE_STA == interfacePriv->interfaceMode || - interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PCLI) || - !memcmp(macAddress->a, broadcast_mac_address, ETH_ALEN)) { - - port->port_cfg[0].port_action = port_action; - port->port_cfg[0].mac_address = *macAddress; - port->port_cfg[0].in_use = TRUE; - port->entries_in_use = 1; - port->overide_action = UF_DATA_PORT_OVERIDE; - - unifi_trace(priv, UDBG2, "%s port override on\n", - (queue == UF_CONTROLLED_PORT_Q) ? "Controlled" : "Uncontrolled"); - - /* Discard the remaining entries in the port config table */ - for (i = 1; i < UNIFI_MAX_CONNECTIONS; i++) { - port->port_cfg[i].in_use = FALSE; - } - - if (port_action == CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_OPEN) { - unifi_trace(priv, UDBG1, "%s port broadcast set to open.\n", - (queue == UF_CONTROLLED_PORT_Q) ? "Controlled" : "Uncontrolled"); - - /* - * Ask stack to schedule for transmission any packets queued - * while controlled port was not open. - * Use netif_schedule() instead of netif_wake_queue() because - * transmission should be already enabled at this point. If it - * is not, probably the interface is down and should remain as is. - */ - uf_resume_data_plane(priv, queue, *macAddress, interfaceTag); - -#ifdef CSR_WIFI_SEND_GRATUITOUS_ARP - if ((CSR_WIFI_ROUTER_CTRL_MODE_STA == interfacePriv->interfaceMode) && - (queue == UF_CONTROLLED_PORT_Q) && (priv->sta_ip_address != 0xFFFFFFFF)) - { - uf_send_gratuitous_arp(priv, interfaceTag); - } -#endif - } else { - unifi_trace(priv, UDBG1, "%s port broadcast set to %s.\n", - (queue == UF_CONTROLLED_PORT_Q) ? "Controlled" : "Uncontrolled", - (port_action == CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_CLOSED_DISCARD) ? "discard": "closed"); - - /* If port is closed, discard all the pending Rx packets */ - if (port_action == CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_CLOSED_DISCARD) { - uf_free_pending_rx_packets(priv, queue, *macAddress, interfaceTag); - } - } - } else { - /* store the new configuration, either in the entry with matching mac address (if already present), - * otherwise in a new entry - */ - - int found_entry_flag; - int first_free_slot = -1; - - /* If leaving override mode, free the port entry used for override */ - if (port->overide_action == UF_DATA_PORT_OVERIDE) { - port->port_cfg[0].in_use = FALSE; - port->entries_in_use = 0; - port->overide_action = UF_DATA_PORT_NOT_OVERIDE; - - unifi_trace(priv, UDBG2, "%s port override off\n", - (queue == UF_CONTROLLED_PORT_Q) ? "Controlled" : "Uncontrolled"); - } - - found_entry_flag = 0; - for (i = 0; i < UNIFI_MAX_CONNECTIONS; i++) { - if (port->port_cfg[i].in_use) { - if (!memcmp(&port->port_cfg[i].mac_address.a, macAddress->a, ETH_ALEN)) { - /* We've seen this address before, reconfigure it */ - port->port_cfg[i].port_action = port_action; - found_entry_flag = 1; - break; - } - } else if (first_free_slot == -1) { - /* Remember the first free slot on the way past so it can be claimed - * if this turns out to be a new MAC address (to save walking the list again). - */ - first_free_slot = i; - } - } - - /* At this point we found an existing entry and have updated it, or need to - * add a new entry. If all slots are allocated, give up and return an error. - */ - if (!found_entry_flag) { - if (first_free_slot == -1) { - unifi_error(priv, "no free slot found in port config array (%d used)\n", port->entries_in_use); - return -EFAULT; - } else { - port->entries_in_use++; - } - - unifi_trace(priv, UDBG3, "port config index assigned in config_data_port = %d\n", first_free_slot); - port->port_cfg[first_free_slot].in_use = TRUE; - port->port_cfg[first_free_slot].port_action = port_action; - port->port_cfg[first_free_slot].mac_address = *macAddress; - } - - if (port_action == CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_OPEN) { - /* - * Ask stack to schedule for transmission any packets queued - * while controlled port was not open. - * Use netif_schedule() instead of netif_wake_queue() because - * transmission should be already enabled at this point. If it - * is not, probably the interface is down and should remain as is. - */ - uf_resume_data_plane(priv, queue, *macAddress, interfaceTag); - } - - /* - * If port is closed, discard all the pending Rx packets - * coming from the peer station. - */ - if (port_action == CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_CLOSED_DISCARD) { - uf_free_pending_rx_packets(priv, queue, *macAddress, interfaceTag); - } - - unifi_trace(priv, UDBG2, - "port config %pM with port_action %d.\n", - macAddress->a, port_action); - } - return 0; -} /* configure_data_port() */ - - -void CsrWifiRouterCtrlPortConfigureReqHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ - unifi_priv_t *priv = (unifi_priv_t*)drvpriv; - CsrWifiRouterCtrlPortConfigureReq* req = (CsrWifiRouterCtrlPortConfigureReq*)msg; - netInterface_priv_t *interfacePriv = priv->interfacePriv[req->interfaceTag]; - - unifi_trace(priv, UDBG3, "entering CsrWifiRouterCtrlPortConfigureReqHandler\n"); - if (priv->smepriv == NULL) { - unifi_error(priv, "CsrWifiRouterCtrlPortConfigureReqHandler: invalid smepriv\n"); - return; - } - - /* To update the protection status of the peer/station */ - switch(interfacePriv->interfaceMode) - { - case CSR_WIFI_ROUTER_CTRL_MODE_STA: - case CSR_WIFI_ROUTER_CTRL_MODE_AMP: - case CSR_WIFI_ROUTER_CTRL_MODE_IBSS: - case CSR_WIFI_ROUTER_CTRL_MODE_P2PCLI: - /* Since for Unifi as a station, the station record not maintained & interfaceID is - * only needed to update the peer protection status - */ - interfacePriv->protect = req->setProtection; - break; - case CSR_WIFI_ROUTER_CTRL_MODE_AP: - case CSR_WIFI_ROUTER_CTRL_MODE_P2PGO: - { - u8 i; - CsrWifiRouterCtrlStaInfo_t *staRecord; - /* Ifscontrolled port is open means, The peer has been added to station record - * so that the protection corresponding to the peer is valid in this req - */ - if (req->controlledPortAction == CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_OPEN) { - for(i =0; i < UNIFI_MAX_CONNECTIONS; i++) { - staRecord = (CsrWifiRouterCtrlStaInfo_t *) (interfacePriv->staInfo[i]); - if (staRecord) { - /* Find the matching station record & set the protection type */ - if (!memcmp(req->macAddress.a, staRecord->peerMacAddress.a, ETH_ALEN)) { - staRecord->protection = req->setProtection; - break; - } - } - } - } - } - break; - default: - unifi_trace(priv, UDBG1, "CsrWifiRouterCtrlPortConfigureReqHandler(0x%.4X) Uncaught mode %d\n", - msg->source, interfacePriv->interfaceMode); - } - - configure_data_port(priv, req->uncontrolledPortAction, (const CsrWifiMacAddress *)&req->macAddress, - UF_UNCONTROLLED_PORT_Q, req->interfaceTag); - configure_data_port(priv, req->controlledPortAction, (const CsrWifiMacAddress *)&req->macAddress, - UF_CONTROLLED_PORT_Q, req->interfaceTag); - - CsrWifiRouterCtrlPortConfigureCfmSend(msg->source, req->clientData, req->interfaceTag, - CSR_RESULT_SUCCESS, req->macAddress); - unifi_trace(priv, UDBG3, "leaving CsrWifiRouterCtrlPortConfigureReqHandler\n"); -} - - -void CsrWifiRouterCtrlWifiOnReqHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ - unifi_priv_t *priv = (unifi_priv_t*)drvpriv; - CsrWifiRouterCtrlVersions versions; - CsrWifiRouterCtrlWifiOnReq* req = (CsrWifiRouterCtrlWifiOnReq*)msg; - int r, i; - CsrResult csrResult; - - if (priv == NULL) { - return; - } - if( priv->wol_suspend ) { - unifi_trace(priv, UDBG1, "CsrWifiRouterCtrlWifiOnReqHandler: Don't reset mode\n"); - } else { -#ifdef ANDROID_BUILD - /* Take the wakelock while Wi-Fi On is in progress */ - unifi_trace(priv, UDBG1, "CsrWifiRouterCtrlWifiOnReqHandler: take wake lock\n"); - wake_lock(&unifi_sdio_wake_lock); -#endif - for (i=0; iinterfacePriv[i]->interfaceMode = 0; - } - } - unifi_trace(priv, UDBG1, "CsrWifiRouterCtrlWifiOnReqHandler(0x%.4X) req->dataLength=%d req->data=0x%x\n", msg->source, req->dataLength, req->data); - - if(req->dataLength==3 && req->data && req->data[0]==0 && req->data[1]==1 && req->data[2]==1) - { - priv->cmanrTestMode = TRUE; - unifi_trace(priv, UDBG1, "CsrWifiRouterCtrlWifiOnReqHandler: cmanrTestMode=%d\n", priv->cmanrTestMode); - } - else - { - priv->cmanrTestMode = FALSE; - } - - /* - * The request to initialise UniFi might come while UniFi is running. - * We need to block all I/O activity until the reset completes, otherwise - * an SDIO error might occur resulting an indication to the SME which - * makes it think that the initialisation has failed. - */ - priv->bh_thread.block_thread = 1; - - /* Update the wifi_on state */ - priv->wifi_on_state = wifi_on_in_progress; - - /* If UniFi was unpowered, acquire the firmware for download to chip */ - if (!priv->wol_suspend) { - r = uf_request_firmware_files(priv, UNIFI_FW_STA); - if (r) { - unifi_error(priv, "CsrWifiRouterCtrlWifiOnReqHandler: Failed to get f/w\n"); - CsrWifiRouterCtrlWifiOnCfmSend(msg->source, req->clientData, CSR_RESULT_FAILURE); - return; - } - } else { - unifi_trace(priv, UDBG1, "Don't need firmware\n"); - } - - /* Power on UniFi (which may not necessarily have been off) */ - CsrSdioClaim(priv->sdio); - csrResult = CsrSdioPowerOn(priv->sdio); - CsrSdioRelease(priv->sdio); - if (csrResult != CSR_RESULT_SUCCESS && csrResult != CSR_SDIO_RESULT_NOT_RESET) { - unifi_error(priv, "CsrWifiRouterCtrlWifiOnReqHandler: Failed to power on UniFi\n"); - CsrWifiRouterCtrlWifiOnCfmSend(msg->source, req->clientData, CSR_RESULT_FAILURE); - return; - } - - /* If CsrSdioPowerOn() returns CSR_RESULT_SUCCESS, it means that we need to initialise UniFi */ - if (csrResult == CSR_RESULT_SUCCESS && !priv->wol_suspend) { - /* Initialise UniFi hardware */ - r = uf_init_hw(priv); - if (r) { - unifi_error(priv, "CsrWifiRouterCtrlWifiOnReqHandler: Failed to initialise h/w, error %d\n", r); - CsrWifiRouterCtrlWifiOnCfmSend(msg->source, req->clientData, CSR_RESULT_FAILURE); - return; - } - } else { - unifi_trace(priv, UDBG1, "UniFi already initialised\n"); - } - - /* Completed handling of wake up from suspend with UniFi powered */ - priv->wol_suspend = FALSE; - - /* Re-enable the I/O thread */ - priv->bh_thread.block_thread = 0; - - /* - * Start the I/O thread. The thread might be already running. - * This fine, just carry on with the request. - */ - r = uf_init_bh(priv); - if (r) { - CsrSdioClaim(priv->sdio); - CsrSdioPowerOff(priv->sdio); - CsrSdioRelease(priv->sdio); - CsrWifiRouterCtrlWifiOnCfmSend(msg->source, req->clientData, CSR_RESULT_FAILURE); - return; - } - - /* Get the version information from the core */ - unifi_card_info(priv->card, &priv->card_info); - - /* Set the sme queue id */ - priv->CSR_WIFI_SME_IFACEQUEUE = msg->source; - CSR_WIFI_SME_IFACEQUEUE = msg->source; - - - /* Copy to the unifiio_card_info structure. */ - versions.chipId = priv->card_info.chip_id; - versions.chipVersion = priv->card_info.chip_version; - versions.firmwareBuild = priv->card_info.fw_build; - versions.firmwareHip = priv->card_info.fw_hip_version; - versions.routerBuild = (char*)CSR_WIFI_VERSION; - versions.routerHip = (UNIFI_HIP_MAJOR_VERSION << 8) | UNIFI_HIP_MINOR_VERSION; - - CsrWifiRouterCtrlWifiOnIndSend(msg->source, 0, CSR_RESULT_SUCCESS, versions); - - /* Update the wifi_on state */ - priv->wifi_on_state = wifi_on_done; -} - - -/* - * wifi_off: - * Common code for CsrWifiRouterCtrlWifiOffReqHandler() and - * CsrWifiRouterCtrlWifiOffRspHandler(). - */ -static void -wifi_off(unifi_priv_t *priv) -{ - int power_off; - int priv_instance; - int i; - CsrResult csrResult; - - - /* Already off? */ - if (priv->wifi_on_state == wifi_on_unspecified) { - unifi_trace(priv, UDBG1, "wifi_off already\n"); - return; - } - - unifi_trace(priv, UDBG1, "wifi_off\n"); - - /* Destroy the Traffic Analysis Module */ - cancel_work_sync(&priv->ta_ind_work.task); - cancel_work_sync(&priv->ta_sample_ind_work.task); -#ifdef CSR_SUPPORT_WEXT - cancel_work_sync(&priv->sme_config_task); - wext_send_disassoc_event(priv); -#endif - - /* Cancel pending M4 stuff */ - for (i = 0; i < CSR_WIFI_NUM_INTERFACES; i++) { - if (priv->netdev[i]) { - netInterface_priv_t *netpriv = (netInterface_priv_t *) netdev_priv(priv->netdev[i]); - cancel_work_sync(&netpriv->send_m4_ready_task); - } - } - flush_workqueue(priv->unifi_workqueue); - - /* fw_init parameter can prevent power off UniFi, for debugging */ - priv_instance = uf_find_priv(priv); - if (priv_instance == -1) { - unifi_warning(priv, - "CsrWifiRouterCtrlStopReqHandler: Unknown priv instance, will power off card.\n"); - power_off = 1; - } else { - power_off = (fw_init[priv_instance] > 0) ? 0 : 1; - } - - /* Production test mode requires power to the chip, too */ - if (priv->ptest_mode) { - power_off = 0; - } - - /* Stop the bh_thread */ - uf_stop_thread(priv, &priv->bh_thread); - - /* Read the f/w panic codes, if any. Protect against second wifi_off() call, - * which may happen if SME requests a wifi_off and closes the char device */ - if (priv->init_progress != UNIFI_INIT_NONE) { - CsrSdioClaim(priv->sdio); - unifi_capture_panic(priv->card); - CsrSdioRelease(priv->sdio); - } - - /* Unregister the interrupt handler */ - if (csr_sdio_linux_remove_irq(priv->sdio)) { - unifi_notice(priv, - "csr_sdio_linux_remove_irq failed to talk to card.\n"); - } - - if (power_off) { - unifi_trace(priv, UDBG2, - "Force low power and try to power off\n"); - /* Put UniFi to deep sleep, in case we can not power it off */ - CsrSdioClaim(priv->sdio); - csrResult = unifi_force_low_power_mode(priv->card); - CsrSdioRelease(priv->sdio); - - CsrSdioPowerOff(priv->sdio); - } - - /* Consider UniFi to be uninitialised */ - priv->init_progress = UNIFI_INIT_NONE; - priv->wifi_on_state = wifi_on_unspecified; - - -} /* wifi_off() */ - - -void CsrWifiRouterCtrlWifiOffReqHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ - unifi_priv_t *priv = (unifi_priv_t*)drvpriv; - CsrWifiRouterCtrlWifiOffReq* req = (CsrWifiRouterCtrlWifiOffReq*)msg; - int i = 0; - - if (priv == NULL) { - return; - } - - unifi_trace(priv, UDBG1, "CsrWifiRouterCtrlWifiOffReqHandler(0x%.4X)\n", msg->source); - - /* Stop the network traffic on all interfaces before freeing the core. */ - for (i=0; iinterfacePriv[i]; - if (interfacePriv->netdev_registered == 1) { - netif_carrier_off(priv->netdev[i]); - netif_tx_stop_all_queues(priv->netdev[i]); - interfacePriv->connected = UnifiConnectedUnknown; - } - interfacePriv->interfaceMode = 0; - - /* Enable all queues by default */ - interfacePriv->queueEnabled[0] = 1; - interfacePriv->queueEnabled[1] = 1; - interfacePriv->queueEnabled[2] = 1; - interfacePriv->queueEnabled[3] = 1; - } - wifi_off(priv); - - CsrWifiRouterCtrlWifiOffCfmSend(msg->source, req->clientData); - - /* If this is called in response to closing the character device, the - * caller must use uf_sme_cancel_request() to terminate any pending SME - * blocking request or there will be a delay while the operation times out. - */ -} - - -void CsrWifiRouterCtrlQosControlReqHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ - unifi_priv_t *priv = (unifi_priv_t*)drvpriv; - CsrWifiRouterCtrlQosControlReq* req = (CsrWifiRouterCtrlQosControlReq*)msg; - netInterface_priv_t *interfacePriv; - - if (priv->smepriv == NULL) { - unifi_error(priv, "CsrWifiRouterCtrlQosControlReqHandler: invalid smepriv\n"); - return; - } - - unifi_trace(priv, UDBG4, "CsrWifiRouterCtrlQosControlReqHandler:scontrol = %d", req->control); - - if (req->interfaceTag >= CSR_WIFI_NUM_INTERFACES) { - unifi_error(priv, "CsrWifiRouterCtrlQosControlReqHandler: interfaceID >= CSR_WIFI_NUM_INTERFACES.\n"); - return; - } - interfacePriv = priv->interfacePriv[req->interfaceTag]; - - if (req->control == CSR_WIFI_ROUTER_CTRL_QOS_CONTROL_WMM_ON) { - priv->sta_wmm_capabilities |= QOS_CAPABILITY_WMM_ENABLED; - unifi_trace(priv, UDBG1, "WMM enabled\n"); - - unifi_trace(priv, UDBG1, "Queue Config %x\n", req->queueConfig); - - interfacePriv->queueEnabled[UNIFI_TRAFFIC_Q_BK] = (req->queueConfig & CSR_WIFI_ROUTER_CTRL_QUEUE_BK_ENABLE)?1:0; - interfacePriv->queueEnabled[UNIFI_TRAFFIC_Q_BE] = (req->queueConfig & CSR_WIFI_ROUTER_CTRL_QUEUE_BE_ENABLE)?1:0; - interfacePriv->queueEnabled[UNIFI_TRAFFIC_Q_VI] = (req->queueConfig & CSR_WIFI_ROUTER_CTRL_QUEUE_VI_ENABLE)?1:0; - interfacePriv->queueEnabled[UNIFI_TRAFFIC_Q_VO] = (req->queueConfig & CSR_WIFI_ROUTER_CTRL_QUEUE_VO_ENABLE)?1:0; - - } else { - priv->sta_wmm_capabilities = 0; - unifi_trace(priv, UDBG1, "WMM disabled\n"); - } -} - - -void CsrWifiRouterCtrlTclasAddReqHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ - unifi_priv_t *priv = (unifi_priv_t*)drvpriv; - CsrWifiRouterCtrlTclasAddReq* req = (CsrWifiRouterCtrlTclasAddReq*)msg; - - if (priv == NULL) { - unifi_error(priv, "CsrWifiRouterCtrlTclasAddReqHandler: invalid smepriv\n"); - return; - } - - CsrWifiRouterCtrlTclasAddCfmSend(msg->source, req->clientData, req->interfaceTag , CSR_RESULT_SUCCESS); -} - -void CsrWifiRouterCtrlTclasDelReqHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ - unifi_priv_t *priv = (unifi_priv_t*)drvpriv; - CsrWifiRouterCtrlTclasDelReq* req = (CsrWifiRouterCtrlTclasDelReq*)msg; - - if (priv == NULL) { - unifi_error(priv, "CsrWifiRouterCtrlTclasDelReqHandler: invalid smepriv\n"); - return; - } - - CsrWifiRouterCtrlTclasDelCfmSend(msg->source, req->clientData, req->interfaceTag, CSR_RESULT_SUCCESS); -} - - -void CsrWifiRouterCtrlConfigurePowerModeReqHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ - unifi_priv_t *priv = (unifi_priv_t*)drvpriv; - CsrWifiRouterCtrlConfigurePowerModeReq* req = (CsrWifiRouterCtrlConfigurePowerModeReq*)msg; - enum unifi_low_power_mode pm; - CsrResult csrResult; - - if (priv->smepriv == NULL) { - unifi_error(priv, "CsrWifiRouterCtrlConfigurePowerModeReqHandler: invalid smepriv\n"); - return; - } - - if (req->mode == CSR_WIFI_ROUTER_CTRL_LOW_POWER_MODE_DISABLED) { - pm = UNIFI_LOW_POWER_DISABLED; - } else { - pm = UNIFI_LOW_POWER_ENABLED; - } - - unifi_trace(priv, UDBG2, - "CsrWifiRouterCtrlConfigurePowerModeReqHandler (mode=%d, wake=%d)\n", - req->mode, req->wakeHost); - csrResult = unifi_configure_low_power_mode(priv->card, pm, - (req->wakeHost ? UNIFI_PERIODIC_WAKE_HOST_ENABLED : UNIFI_PERIODIC_WAKE_HOST_DISABLED)); -} - - -void CsrWifiRouterCtrlWifiOnResHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ - unifi_priv_t *priv = (unifi_priv_t*)drvpriv; - CsrWifiRouterCtrlWifiOnRes* res = (CsrWifiRouterCtrlWifiOnRes*)msg; - - if (priv == NULL) { - unifi_error(NULL, "CsrWifiRouterCtrlWifiOnResHandler: Invalid ospriv.\n"); - return; - } - - unifi_trace(priv, UDBG1, - "CsrWifiRouterCtrlWifiOnResHandler: status %d (patch %u)\n", res->status, res->smeVersions.firmwarePatch); - - if (res->smeVersions.firmwarePatch != 0) { - unifi_info(priv, "Firmware patch %d\n", res->smeVersions.firmwarePatch); - } - - if (res->numInterfaceAddress > CSR_WIFI_NUM_INTERFACES) { - unifi_error(priv, "WifiOnResHandler bad numInterfaceAddress %d\n", res->numInterfaceAddress); - return; - } - - /* UniFi is now initialised, complete the init. */ - if (res->status == CSR_RESULT_SUCCESS) - { - int i; /* used as a loop counter */ - u32 intmode = CSR_WIFI_INTMODE_DEFAULT; -#ifdef CSR_WIFI_SPLIT_PATCH - u8 switching_ap_fw = FALSE; -#endif - /* Register the UniFi device with the OS network manager */ - unifi_trace(priv, UDBG3, "Card Init Completed Successfully\n"); - - /* Store the MAC address in the netdev */ - for(i=0;inumInterfaceAddress;i++) - { - memcpy(priv->netdev[i]->dev_addr, res->stationMacAddress[i].a, ETH_ALEN); - } - - /* Copy version structure into the private versions field */ - priv->sme_versions = res->smeVersions; - - unifi_trace(priv, UDBG2, "network interfaces count = %d\n", - res->numInterfaceAddress); - - /* Register the netdevs for each interface. */ - for(i=0;inumInterfaceAddress;i++) - { - netInterface_priv_t *interfacePriv = priv->interfacePriv[i]; - if(!interfacePriv->netdev_registered) - { - int r; - unifi_trace(priv, UDBG3, "registering net device %d\n", i); - r = uf_register_netdev(priv, i); - if (r) - { - /* unregister the net_device that are registered in the previous iterations */ - uf_unregister_netdev(priv); - unifi_error(priv, "Failed to register the network device.\n"); - CsrWifiRouterCtrlWifiOnCfmSend(msg->source, res->clientData, CSR_RESULT_FAILURE); - return; - } - } -#ifdef CSR_WIFI_SPLIT_PATCH - else - { - /* If a netdev is already registered, we have received this WifiOnRes - * in response to switching AP/STA firmware in a ModeSetReq. - * Rememeber this in order to send a ModeSetCfm once - */ - switching_ap_fw = TRUE; - } -#endif - } - priv->totalInterfaceCount = res->numInterfaceAddress; - - /* If the MIB has selected f/w scheduled interrupt mode, apply it now - * but let module param override. - */ - if (run_bh_once != -1) { - intmode = (u32)run_bh_once; - } else if (res->scheduledInterrupt) { - intmode = CSR_WIFI_INTMODE_RUN_BH_ONCE; - } - unifi_set_interrupt_mode(priv->card, intmode); - - priv->init_progress = UNIFI_INIT_COMPLETED; - - /* Acknowledge the CsrWifiRouterCtrlWifiOnReq now */ - CsrWifiRouterCtrlWifiOnCfmSend(msg->source, res->clientData, CSR_RESULT_SUCCESS); - -#ifdef CSR_WIFI_SPLIT_PATCH - if (switching_ap_fw && (priv->pending_mode_set.common.destination != 0xaaaa)) { - unifi_info(priv, "Completed firmware reload with %s patch\n", - CSR_WIFI_HIP_IS_AP_FW(priv->interfacePriv[0]->interfaceMode) ? "AP" : "STA"); - - /* Confirm the ModeSetReq that requested the AP/STA patch switch */ - CsrWifiRouterCtrlModeSetCfmSend(priv->pending_mode_set.common.source, - priv->pending_mode_set.clientData, - priv->pending_mode_set.interfaceTag, - priv->pending_mode_set.mode, - CSR_RESULT_SUCCESS); - priv->pending_mode_set.common.destination = 0xaaaa; - } -#endif - unifi_info(priv, "UniFi ready\n"); - -#ifdef ANDROID_BUILD - /* Release the wakelock */ - unifi_trace(priv, UDBG1, "ready: release wake lock\n"); - wake_unlock(&unifi_sdio_wake_lock); -#endif - /* Firmware initialisation is complete, so let the SDIO bus - * clock be raised when convienent to the core. - */ - unifi_request_max_sdio_clock(priv->card); - -#ifdef CSR_SUPPORT_WEXT - /* Notify the Android wpa_supplicant that we are ready */ - wext_send_started_event(priv); - - queue_work(priv->unifi_workqueue, &priv->sme_config_task); -#endif - - } else { - /* Acknowledge the CsrWifiRouterCtrlWifiOnReq now */ - CsrWifiRouterCtrlWifiOnCfmSend(msg->source, res->clientData, CSR_RESULT_FAILURE); - } -} - - -void CsrWifiRouterCtrlWifiOffResHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ -} - - -void CsrWifiRouterCtrlMulticastAddressResHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ -} - - -void CsrWifiRouterMaPacketSubscribeReqHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ - unifi_priv_t *priv = (unifi_priv_t*)drvpriv; - CsrWifiRouterMaPacketSubscribeReq* req = (CsrWifiRouterMaPacketSubscribeReq*)msg; - u8 i; - CsrResult result; - - if (priv == NULL) { - unifi_error(priv, "CsrWifiRouterMaPacketSubscribeReqHandler: invalid priv\n"); - return; - } - - /* Look for an unused filter */ - - result = CSR_WIFI_RESULT_NO_ROOM; - for (i = 0; i < MAX_MA_UNIDATA_IND_FILTERS; i++) { - - if (!priv->sme_unidata_ind_filters[i].in_use) { - - priv->sme_unidata_ind_filters[i].in_use = 1; - priv->sme_unidata_ind_filters[i].appHandle = msg->source; - priv->sme_unidata_ind_filters[i].encapsulation = req->encapsulation; - priv->sme_unidata_ind_filters[i].protocol = req->protocol; - - priv->sme_unidata_ind_filters[i].oui[2] = (u8) (req->oui & 0xFF); - priv->sme_unidata_ind_filters[i].oui[1] = (u8) ((req->oui >> 8) & 0xFF); - priv->sme_unidata_ind_filters[i].oui[0] = (u8) ((req->oui >> 16) & 0xFF); - - result = CSR_RESULT_SUCCESS; - break; - } - } - - unifi_trace(priv, UDBG1, - "subscribe_req: encap=%d, handle=%d, result=%d\n", - req->encapsulation, i, result); - CsrWifiRouterMaPacketSubscribeCfmSend(msg->source, req->interfaceTag, i, result, 0); -} - - -void CsrWifiRouterMaPacketUnsubscribeReqHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ - unifi_priv_t *priv = (unifi_priv_t*)drvpriv; - CsrWifiRouterMaPacketUnsubscribeReq* req = (CsrWifiRouterMaPacketUnsubscribeReq*)msg; - CsrResult result; - - if (priv == NULL) { - unifi_error(priv, "CsrWifiRouterMaPacketUnsubscribeReqHandler: invalid priv\n"); - return; - } - - result = CSR_WIFI_RESULT_NOT_FOUND; - - if (req->subscriptionHandle < MAX_MA_UNIDATA_IND_FILTERS) { - if (priv->sme_unidata_ind_filters[req->subscriptionHandle].in_use) { - priv->sme_unidata_ind_filters[req->subscriptionHandle].in_use = 0; - result = CSR_RESULT_SUCCESS; - } else { - result = CSR_WIFI_RESULT_NOT_FOUND; - } - } - - unifi_trace(priv, UDBG1, - "unsubscribe_req: handle=%d, result=%d\n", - req->subscriptionHandle, result); - CsrWifiRouterMaPacketUnsubscribeCfmSend(msg->source, req->interfaceTag, result); -} - - -void CsrWifiRouterCtrlCapabilitiesReqHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ - unifi_priv_t *priv = (unifi_priv_t*)drvpriv; - CsrWifiRouterCtrlCapabilitiesReq* req = (CsrWifiRouterCtrlCapabilitiesReq*)msg; - - if (priv == NULL) { - unifi_error(priv, "CsrWifiRouterCtrlCapabilitiesReqHandler: invalid priv\n"); - return; - } - - CsrWifiRouterCtrlCapabilitiesCfmSend(msg->source, req->clientData, - UNIFI_SOFT_COMMAND_Q_LENGTH - 1, - UNIFI_SOFT_TRAFFIC_Q_LENGTH - 1); -} - - -void CsrWifiRouterCtrlSuspendResHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ - unifi_priv_t *priv = (unifi_priv_t*)drvpriv; - CsrWifiRouterCtrlSuspendRes* res = (CsrWifiRouterCtrlSuspendRes*)msg; - - if (priv == NULL) { - unifi_error(priv, "CsrWifiRouterCtrlSuspendResHandler: invalid priv\n"); - return; - } - - sme_complete_request(priv, res->status); -} - - -void CsrWifiRouterCtrlResumeResHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ - unifi_priv_t *priv = (unifi_priv_t*)drvpriv; - CsrWifiRouterCtrlResumeRes* res = (CsrWifiRouterCtrlResumeRes*)msg; - - if (priv == NULL) { - unifi_error(priv, "CsrWifiRouterCtrlResumeResHandler: invalid priv\n"); - return; - } - - sme_complete_request(priv, res->status); -} - - -void CsrWifiRouterCtrlTrafficConfigReqHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ - unifi_priv_t *priv = (unifi_priv_t*)drvpriv; - CsrWifiRouterCtrlTrafficConfigReq* req = (CsrWifiRouterCtrlTrafficConfigReq*)msg; - CsrResult csrResult; - - if (priv == NULL) { - unifi_error(priv, "CsrWifiRouterCtrlTrafficConfigReqHandler: invalid smepriv\n"); - return; - } - if (req->trafficConfigType == CSR_WIFI_ROUTER_CTRL_TRAFFIC_CONFIG_TYPE_FILTER) - { - req->config.packetFilter |= CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_CUSTOM; - } - csrResult = unifi_ta_configure(priv->card, req->trafficConfigType, (const CsrWifiRouterCtrlTrafficConfig *)&req->config); -} - -void CsrWifiRouterCtrlTrafficClassificationReqHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ - unifi_priv_t *priv = (unifi_priv_t*)drvpriv; - CsrWifiRouterCtrlTrafficClassificationReq* req = (CsrWifiRouterCtrlTrafficClassificationReq*)msg; - - if (priv == NULL) { - unifi_error(priv, "CsrWifiRouterCtrlTrafficClassificationReqHandler: invalid smepriv\n"); - return; - } - - unifi_ta_classification(priv->card, req->trafficType, req->period); -} - -static int -_sys_packet_req(unifi_priv_t *priv, const CSR_SIGNAL *signal, - u8 subscriptionHandle, - u16 frameLength, u8 *frame, - int proto) -{ - int r; - const sme_ma_unidata_ind_filter_t *subs; - bulk_data_param_t bulkdata; - CSR_MA_PACKET_REQUEST req = signal->u.MaPacketRequest; - struct sk_buff *skb, *newSkb = NULL; - CsrWifiMacAddress peerMacAddress; - CsrResult csrResult; - u16 interfaceTag = req.VirtualInterfaceIdentifier & 0xff; - u8 eapolStore = FALSE; - s8 protection = 0; - netInterface_priv_t *interfacePriv; - unsigned long flags; - - if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) { - unifi_error(priv, "_sys_packet_req: interfaceID >= CSR_WIFI_NUM_INTERFACES.\n"); - return -EINVAL; - } - interfacePriv = priv->interfacePriv[interfaceTag]; - if (!priv->sme_unidata_ind_filters[subscriptionHandle].in_use) { - unifi_error(priv, "_sys_packet_req: unknown subscription.\n"); - return -EINVAL; - } - - subs = &priv->sme_unidata_ind_filters[subscriptionHandle]; - unifi_trace(priv, UDBG1, - "_sys_packet_req: handle=%d, subs=%p, encap=%d\n", - subscriptionHandle, subs, subs->encapsulation); - - csrResult = unifi_net_data_malloc(priv, &bulkdata.d[0], frameLength); - if (csrResult != CSR_RESULT_SUCCESS) { - unifi_error(priv, "_sys_packet_req: failed to allocate bulkdata.\n"); - return (int)CsrHipResultToStatus(csrResult); - } - - /* get the peer Mac address */ - memcpy(&peerMacAddress, frame, ETH_ALEN); - - /* Determine if we need to add encapsulation header */ - if (subs->encapsulation == CSR_WIFI_ROUTER_ENCAPSULATION_ETHERNET) { - memcpy((void*)bulkdata.d[0].os_data_ptr, frame, frameLength); - - /* The translation is performed on the skb */ - skb = (struct sk_buff*)bulkdata.d[0].os_net_buf_ptr; - - unifi_trace(priv, UDBG1, - "_sys_packet_req: skb_add_llc_snap -->\n"); - r = skb_add_llc_snap(priv->netdev[interfaceTag], skb, proto); - unifi_trace(priv, UDBG1, - "_sys_packet_req: skb_add_llc_snap <--\n"); - if (r) { - unifi_error(priv, - "_sys_packet_req: failed to translate eth frame.\n"); - unifi_net_data_free(priv, &bulkdata.d[0]); - return r; - } - - bulkdata.d[0].data_length = skb->len; - } else { - /* Crop the MAC addresses from the packet */ - memcpy((void*)bulkdata.d[0].os_data_ptr, frame + 2*ETH_ALEN, frameLength - 2*ETH_ALEN); - bulkdata.d[0].data_length = frameLength - 2*ETH_ALEN; - skb = (struct sk_buff*)bulkdata.d[0].os_net_buf_ptr; - skb->len = bulkdata.d[0].data_length; - - } - - bulkdata.d[1].os_data_ptr = NULL; - bulkdata.d[1].os_net_buf_ptr = NULL; - bulkdata.d[1].data_length = 0; - - /* check for m4 detection */ - if (0 == uf_verify_m4(priv, bulkdata.d[0].os_data_ptr, bulkdata.d[0].data_length)) { - eapolStore = TRUE; - } - -#ifdef CSR_WIFI_SECURITY_WAPI_ENABLE - if (proto == ETH_P_WAI) - { - protection = 0; /*WAI packets always sent unencrypted*/ - } - else - { -#endif - -#ifdef CSR_SUPPORT_SME - if ((protection = uf_get_protection_bit_from_interfacemode(priv, interfaceTag, peerMacAddress.a)) < 0) { - unifi_error(priv, "unicast address, but destination not in station record database\n"); - unifi_net_data_free(priv, &bulkdata.d[0]); - return -1; - } -#else - protection = 0; -#endif - -#ifdef CSR_WIFI_SECURITY_WAPI_ENABLE - } -#endif - - /* add Mac header */ - if (prepare_and_add_macheader(priv, skb, newSkb, req.Priority, &bulkdata, interfaceTag, frame, frame + ETH_ALEN, protection)) { - unifi_error(priv, "failed to create MAC header\n"); - unifi_net_data_free(priv, &bulkdata.d[0]); - return -1; - } - - if (eapolStore) { - spin_lock_irqsave(&priv->m4_lock, flags); - /* Store the EAPOL M4 packet for later */ - interfacePriv->m4_signal = *signal; - interfacePriv->m4_bulk_data.net_buf_length = bulkdata.d[0].net_buf_length; - interfacePriv->m4_bulk_data.data_length = bulkdata.d[0].data_length; - interfacePriv->m4_bulk_data.os_data_ptr = bulkdata.d[0].os_data_ptr; - interfacePriv->m4_bulk_data.os_net_buf_ptr = bulkdata.d[0].os_net_buf_ptr; - spin_unlock_irqrestore(&priv->m4_lock, flags); - /* Send a signal to SME */ - unifi_trace(priv, UDBG1, "_sys_packet_req: Sending CsrWifiRouterCtrlM4ReadyToSendInd\n"); - CsrWifiRouterCtrlM4ReadyToSendIndSend(priv->CSR_WIFI_SME_IFACEQUEUE, 0, interfaceTag, peerMacAddress); - return 0; - } - - /* Send the signal to UniFi */ - /* Set the B31 to 1 for local routing*/ - r= uf_process_ma_packet_req(priv, peerMacAddress.a, (req.HostTag | 0x80000000), interfaceTag, 0, - (CSR_RATE)0, req.Priority, signal->SignalPrimitiveHeader.SenderProcessId, &bulkdata); - if (r) { - unifi_error(priv, - "_sys_packet_req: failed to send signal.\n"); - unifi_net_data_free(priv, &bulkdata.d[0]); - return r; - } - /* The final CsrWifiRouterMaPacketCfmSend() will called when the actual MA-PACKET.cfm is received from the chip */ - - return 0; -} - -void CsrWifiRouterMaPacketReqHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ - int r; - unifi_priv_t *priv = (unifi_priv_t*)drvpriv; - CsrWifiRouterMaPacketReq* mareq = (CsrWifiRouterMaPacketReq*)msg; - llc_snap_hdr_t *snap; - u16 snap_protocol; - CSR_SIGNAL signal; - CSR_MA_PACKET_REQUEST *req = &signal.u.MaPacketRequest; - CsrWifiRouterCtrlPortAction controlPortaction; - u8 *daddr, *saddr; - u16 interfaceTag = mareq->interfaceTag & 0x00ff; - int queue; - netInterface_priv_t *interfacePriv; - - if (!mareq->frame || !priv || !priv->smepriv) - { - unifi_error(priv, "CsrWifiRouterMaPacketReqHandler: invalid frame/priv/priv->smepriv\n"); - return; - } - - if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) { - unifi_error(priv, "CsrWifiRouterMaPacketReqHandler: interfaceID >= CSR_WIFI_NUM_INTERFACES.\n"); - return; - } - - interfacePriv = priv->interfacePriv[interfaceTag]; - /* get a pointer to dest & source Mac address */ - daddr = mareq->frame; - saddr = (mareq->frame + ETH_ALEN); - /* point to the proper position of frame, since frame has MAC header */ - snap = (llc_snap_hdr_t *) (mareq->frame + 2 * ETH_ALEN); - snap_protocol = ntohs(snap->protocol); - if((snap_protocol == ETH_P_PAE) -#ifdef CSR_WIFI_SECURITY_WAPI_ENABLE - || (snap_protocol == ETH_P_WAI) -#endif - ) - { - queue = UF_UNCONTROLLED_PORT_Q; - } - else - { - queue = UF_CONTROLLED_PORT_Q; - } - - /* Controlled port restrictions apply to the packets */ - controlPortaction = uf_sme_port_state(priv, daddr, queue, interfaceTag); - if (controlPortaction != CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_OPEN) - { - unifi_warning(priv, "CsrWifiRouterMaPacketReqHandler: (%s)controlled port is closed.\n", (queue == UF_CONTROLLED_PORT_Q)?"":"un"); - if(mareq->cfmRequested) - { - CsrWifiRouterMaPacketCfmSend(msg->source, - interfaceTag, - CSR_RESULT_FAILURE, - mareq->hostTag, 0); - } - return; - } - - signal.SignalPrimitiveHeader.SignalId = CSR_MA_PACKET_REQUEST_ID; - /* Store the appHandle in the LSB of the SenderId. */ - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(((priv->sme_cli->sender_id & 0xff00) | (unsigned int)msg->source), - (u8*)&signal.SignalPrimitiveHeader.SenderProcessId); - signal.SignalPrimitiveHeader.ReceiverProcessId = 0; - - /* Fill in the MA-PACKET.req signal */ - memcpy(req->Ra.x, daddr, ETH_ALEN); - req->Priority = mareq->priority; - req->TransmitRate = 0; /* Let firmware select the rate*/ - req->VirtualInterfaceIdentifier = uf_get_vif_identifier(interfacePriv->interfaceMode, interfaceTag); - req->HostTag = mareq->hostTag; - - if(mareq->cfmRequested) - req->TransmissionControl = 0; - else - req->TransmissionControl = CSR_NO_CONFIRM_REQUIRED; - - r = _sys_packet_req(priv, &signal, mareq->subscriptionHandle, - mareq->frameLength, mareq->frame, snap_protocol); - - if (r && mareq->cfmRequested) - { - CsrWifiRouterMaPacketCfmSend(msg->source, interfaceTag, - CSR_RESULT_FAILURE, - mareq->hostTag, 0); - } - return; -} - -void CsrWifiRouterMaPacketCancelReqHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ -} - -void CsrWifiRouterCtrlM4TransmitReqHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ - unifi_priv_t *priv = (unifi_priv_t*)drvpriv; - CsrWifiRouterCtrlM4TransmitReq* req = (CsrWifiRouterCtrlM4TransmitReq*)msg; - int r; - bulk_data_param_t bulkdata; - netInterface_priv_t *interfacePriv; - CSR_SIGNAL m4_signal; - unsigned long flags; - - if (priv == NULL) { - unifi_error(priv, "CsrWifiRouterCtrlM4TransmitReqHandler: invalid smepriv\n"); - return; - } - if (req->interfaceTag >= CSR_WIFI_NUM_INTERFACES) { - unifi_error(priv, "M4TransmitReqHandler: interfaceTag >= CSR_WIFI_NUM_INTERFACES\n"); - return; - } - - interfacePriv = priv->interfacePriv[req->interfaceTag]; - spin_lock_irqsave(&priv->m4_lock, flags); - if (interfacePriv->m4_bulk_data.data_length == 0) { - spin_unlock_irqrestore(&priv->m4_lock, flags); - unifi_error(priv, "CsrWifiRouterCtrlM4TransmitReqHandler: invalid buffer\n"); - return; - } - - memcpy(&bulkdata.d[0], &interfacePriv->m4_bulk_data, sizeof(bulk_data_desc_t)); - - interfacePriv->m4_bulk_data.net_buf_length = 0; - interfacePriv->m4_bulk_data.data_length = 0; - interfacePriv->m4_bulk_data.os_data_ptr = interfacePriv->m4_bulk_data.os_net_buf_ptr = NULL; - m4_signal = interfacePriv->m4_signal; - spin_unlock_irqrestore(&priv->m4_lock, flags); - - bulkdata.d[1].os_data_ptr = NULL; - bulkdata.d[1].data_length = 0; - - interfacePriv->m4_sent = TRUE; - m4_signal.u.MaPacketRequest.HostTag |= 0x80000000; - /* Store the hostTag for later varification */ - interfacePriv->m4_hostTag = m4_signal.u.MaPacketRequest.HostTag; - r = ul_send_signal_unpacked(priv, &m4_signal, &bulkdata); - unifi_trace(priv, UDBG1, - "CsrWifiRouterCtrlM4TransmitReqHandler: sent\n"); - if (r) { - unifi_error(priv, - "CsrWifiRouterCtrlM4TransmitReqHandler: failed to send signal.\n"); - unifi_net_data_free(priv, &bulkdata.d[0]); - } -} - -/* reset the station records when the mode is set as CSR_WIFI_ROUTER_CTRL_MODE_NONE */ -static void CsrWifiRouterCtrlResetStationRecordList(unifi_priv_t *priv, u16 interfaceTag) -{ - u8 i, j; - CsrWifiRouterCtrlStaInfo_t *staInfo=NULL; - netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag]; - unsigned long lock_flags; - - /* create a list for sending confirms of un-delivered packets */ - struct list_head send_cfm_list; - - if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) { - unifi_error(priv, "CsrWifiRouterCtrlResetStationRecordList: bad interfaceTag\n"); - return; - } - - INIT_LIST_HEAD(&send_cfm_list); - - /* Reset the station record to NULL if mode is NONE */ - for(i = 0; i < UNIFI_MAX_CONNECTIONS; i++) { - if ((staInfo=interfacePriv->staInfo[i]) != NULL) { - uf_prepare_send_cfm_list_for_queued_pkts(priv, - &send_cfm_list, - &(staInfo->mgtFrames)); - uf_flush_list(priv, &(staInfo->mgtFrames)); - for(j=0;jdataPdu[j])); - uf_flush_list(priv, &(staInfo->dataPdu[j])); - } - - spin_lock_irqsave(&priv->staRecord_lock, lock_flags); - /* Removing station record information from port config array */ - memset(staInfo->peerControlledPort, 0, sizeof(unifi_port_cfg_t)); - staInfo->peerControlledPort->port_action = CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_CLOSED_DISCARD; - staInfo->peerControlledPort->in_use = FALSE; - interfacePriv->controlled_data_port.entries_in_use--; - - memset(staInfo->peerUnControlledPort, 0, sizeof(unifi_port_cfg_t)); - staInfo->peerUnControlledPort->port_action = CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_CLOSED_DISCARD; - staInfo->peerUnControlledPort->in_use = FALSE; - interfacePriv->uncontrolled_data_port.entries_in_use--; - - kfree(interfacePriv->staInfo[i]); - interfacePriv->staInfo[i] = NULL; - spin_unlock_irqrestore(&priv->staRecord_lock, lock_flags); - } - } - /* after the critical region process the list of frames that requested cfm - * and send cfm to requestor one by one - */ - send_auto_ma_packet_confirm(priv, interfacePriv, &send_cfm_list); - -#ifdef CSR_SUPPORT_SME - /* Interface Independent, no of packet queued, incase of mode is None or AP set to 0 */ - switch(interfacePriv->interfaceMode) - { - case CSR_WIFI_ROUTER_CTRL_MODE_AP: - case CSR_WIFI_ROUTER_CTRL_MODE_P2PGO: - case CSR_WIFI_ROUTER_CTRL_MODE_NONE: - if (priv->noOfPktQueuedInDriver) { - unifi_warning(priv, "After reset the noOfPktQueuedInDriver = %x\n", priv->noOfPktQueuedInDriver); - spin_lock_irqsave(&priv->tx_q_lock, lock_flags); - priv->noOfPktQueuedInDriver = 0; - spin_unlock_irqrestore(&priv->tx_q_lock, lock_flags); - } - break; - case CSR_WIFI_ROUTER_CTRL_MODE_IBSS: - break; - default: - unifi_error(priv, "interfacemode is not correct in CsrWifiRouterCtrlResetStationRecordList: debug\n"); - } -#endif - - if (((interfacePriv->controlled_data_port.entries_in_use != 0) || (interfacePriv->uncontrolled_data_port.entries_in_use != 0)) - && (interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_NONE)) { - /* Print in case if the value of entries goes to -ve/+ve (apart from 0) - * we expect the entries should be zero here if mode is set as NONE - */ - unifi_trace(priv, UDBG3, "In %s controlled port entries = %d, uncontrolled port entries = %d\n", - __FUNCTION__, interfacePriv->controlled_data_port.entries_in_use, - interfacePriv->uncontrolled_data_port.entries_in_use); - } -} - -void CsrWifiRouterCtrlInterfaceReset(unifi_priv_t *priv, u16 interfaceTag) -{ - netInterface_priv_t *interfacePriv; - - /* create a list for sending confirms of un-delivered packets */ - struct list_head send_cfm_list; - - if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) { - unifi_error(priv, "CsrWifiRouterCtrlInterfaceReset: bad interfaceTag\n"); - return; - } - - interfacePriv = priv->interfacePriv[interfaceTag]; - - INIT_LIST_HEAD(&send_cfm_list); - - /* Enable all queues by default */ - interfacePriv->queueEnabled[0] = 1; - interfacePriv->queueEnabled[1] = 1; - interfacePriv->queueEnabled[2] = 1; - interfacePriv->queueEnabled[3] = 1; - - uf_prepare_send_cfm_list_for_queued_pkts(priv, - &send_cfm_list, - &(interfacePriv->genericMgtFrames)); - uf_flush_list(priv, &(interfacePriv->genericMgtFrames)); - - uf_prepare_send_cfm_list_for_queued_pkts(priv, - &send_cfm_list, - &(interfacePriv->genericMulticastOrBroadCastMgtFrames)); - uf_flush_list(priv, &(interfacePriv->genericMulticastOrBroadCastMgtFrames)); - - uf_prepare_send_cfm_list_for_queued_pkts(priv, - &send_cfm_list, - &(interfacePriv->genericMulticastOrBroadCastFrames)); - - uf_flush_list(priv, &(interfacePriv->genericMulticastOrBroadCastFrames)); - - /* process the list of frames that requested cfm - and send cfm to requestor one by one */ - send_auto_ma_packet_confirm(priv, interfacePriv, &send_cfm_list); - - /* Reset the station record to NULL if mode is tried to set as NONE */ - switch(interfacePriv->interfaceMode) - { - case CSR_WIFI_ROUTER_CTRL_MODE_STA: - case CSR_WIFI_ROUTER_CTRL_MODE_P2PCLI: - case CSR_WIFI_ROUTER_CTRL_MODE_MONITOR: - case CSR_WIFI_ROUTER_CTRL_MODE_AMP: - /* station records not available in these modes */ - break; - default: - CsrWifiRouterCtrlResetStationRecordList(priv, interfaceTag); - } - - interfacePriv->num_stations_joined = 0; - interfacePriv->sta_activity_check_enabled = FALSE; -} - - -void CsrWifiRouterCtrlModeSetReqHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ - unifi_priv_t *priv = (unifi_priv_t*)drvpriv; - CsrWifiRouterCtrlModeSetReq* req = (CsrWifiRouterCtrlModeSetReq*)msg; - - if (priv == NULL) - { - unifi_error(priv, "CsrWifiRouterCtrlModeSetReqHandler: invalid smepriv\n"); - return; - } - - if (req->interfaceTag < CSR_WIFI_NUM_INTERFACES) - { - netInterface_priv_t *interfacePriv = priv->interfacePriv[req->interfaceTag]; -#ifdef CSR_WIFI_SPLIT_PATCH - u8 old_mode = interfacePriv->interfaceMode; -#endif - unifi_trace(priv, UDBG1, "CsrWifiRouterCtrlModeSetReqHandler: interfacePriv->interfaceMode = %d\n", - interfacePriv->interfaceMode); - - interfacePriv->interfaceMode = req->mode; - -#ifdef CSR_WIFI_SPLIT_PATCH - /* Detect a change in mode that requires a switch to/from the AP firmware patch. - * This should only happen when transitioning in/out of AP modes. - */ - if (CSR_WIFI_HIP_IS_AP_FW(req->mode) != CSR_WIFI_HIP_IS_AP_FW(old_mode)) - { - CsrWifiRouterCtrlVersions versions; - int r; - -#ifdef ANDROID_BUILD - /* Take the wakelock while switching patch */ - unifi_trace(priv, UDBG1, "patch switch: take wake lock\n"); - wake_lock(&unifi_sdio_wake_lock); -#endif - unifi_info(priv, "Resetting UniFi with %s patch\n", CSR_WIFI_HIP_IS_AP_FW(req->mode) ? "AP" : "STA"); - - r = uf_request_firmware_files(priv, UNIFI_FW_STA); - if (r) { - unifi_error(priv, "CsrWifiRouterCtrlModeSetReqHandler: Failed to get f/w\n"); - CsrWifiRouterCtrlModeSetCfmSend(msg->source, req->clientData, req->interfaceTag, - req->mode, CSR_RESULT_FAILURE); - return; - } - - /* Block the I/O thread */ - priv->bh_thread.block_thread = 1; - - /* Reset and download the new patch */ - r = uf_init_hw(priv); - if (r) { - unifi_error(priv, "CsrWifiRouterCtrlWifiOnReqHandler: Failed to initialise h/w, error %d\n", r); - CsrWifiRouterCtrlModeSetCfmSend(msg->source, req->clientData, req->interfaceTag, - req->mode, CSR_RESULT_FAILURE); - return; - } - - /* Re-enable the I/O thread */ - priv->bh_thread.block_thread = 0; - - /* Get the version information from the core */ - unifi_card_info(priv->card, &priv->card_info); - - /* Copy to the unifiio_card_info structure. */ - versions.chipId = priv->card_info.chip_id; - versions.chipVersion = priv->card_info.chip_version; - versions.firmwareBuild = priv->card_info.fw_build; - versions.firmwareHip = priv->card_info.fw_hip_version; - versions.routerBuild = (char*)CSR_WIFI_VERSION; - versions.routerHip = (UNIFI_HIP_MAJOR_VERSION << 8) | UNIFI_HIP_MINOR_VERSION; - - /* Now that new firmware is running, send a WifiOnInd to the NME. This will - * cause it to retransfer the MIB. - */ - CsrWifiRouterCtrlWifiOnIndSend(msg->source, 0, CSR_RESULT_SUCCESS, versions); - - /* Store the request so we know where to send the ModeSetCfm */ - priv->pending_mode_set = *req; - } - else -#endif - { - /* No patch switch, confirm straightaway */ - CsrWifiRouterCtrlModeSetCfmSend(msg->source, req->clientData, req->interfaceTag, - req->mode, CSR_RESULT_SUCCESS); - } - - interfacePriv->bssid = req->bssid; - /* For modes other than AP/P2PGO, set below member FALSE */ - interfacePriv->intraBssEnabled = FALSE; - /* Initialise the variable bcTimSet with a value - * other then CSR_WIFI_TIM_SET or CSR_WIFI_TIM_RESET value - */ - interfacePriv->bcTimSet = 0xFF; - interfacePriv->bcTimSetReqPendingFlag = FALSE; - /* Initialise the variable bcTimSetReqQueued with a value - * other then CSR_WIFI_TIM_SET or CSR_WIFI_TIM_RESET value - */ - interfacePriv->bcTimSetReqQueued =0xFF; - CsrWifiRouterCtrlInterfaceReset(priv, req->interfaceTag); - - if(req->mode == CSR_WIFI_ROUTER_CTRL_MODE_AP || - req->mode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO) { - interfacePriv->protect = req->protection; - interfacePriv->dtimActive=FALSE; - interfacePriv->multicastPduHostTag = 0xffffffff; - /* For AP/P2PGO mode SME sending intraBssDistEnabled - * i.e. for AP: intraBssDistEnabled = TRUE, for P2PGO - * intraBssDistEnabled = TRUE/FALSE on requirement - */ - interfacePriv->intraBssEnabled = req->intraBssDistEnabled; - unifi_trace(priv, UDBG3, "CsrWifiRouterCtrlModeSetReqHandler: IntraBssDisEnabled = %d\n", - req->intraBssDistEnabled); - } else if (req->mode == CSR_WIFI_ROUTER_CTRL_MODE_NONE) { - netif_carrier_off(priv->netdev[req->interfaceTag]); - interfacePriv->connected = UnifiConnectedUnknown; - } - } - else { - unifi_error(priv, "CsrWifiRouterCtrlModeSetReqHandler: invalid interfaceTag :%d\n", req->interfaceTag); - } -} - -void CsrWifiRouterMaPacketResHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ -} - -/* delete the station record from the station record data base */ -static int peer_delete_record(unifi_priv_t *priv, CsrWifiRouterCtrlPeerDelReq *req) -{ - u8 j; - CsrWifiRouterCtrlStaInfo_t *staInfo = NULL; - unifi_port_config_t *controlledPort; - unifi_port_config_t *unControlledPort; - netInterface_priv_t *interfacePriv; - - u8 ba_session_idx = 0; - ba_session_rx_struct *ba_session_rx = NULL; - ba_session_tx_struct *ba_session_tx = NULL; - - /* create a list for sending confirms of un-delivered packets */ - struct list_head send_cfm_list; - - unsigned long lock_flags; - - if ((req->peerRecordHandle >= UNIFI_MAX_CONNECTIONS) || (req->interfaceTag >= CSR_WIFI_NUM_INTERFACES)) { - unifi_error(priv, "handle/interfaceTag is not proper, handle = %d, interfaceTag = %d\n", req->peerRecordHandle, req->interfaceTag); - return CSR_RESULT_FAILURE; - } - - INIT_LIST_HEAD(&send_cfm_list); - - interfacePriv = priv->interfacePriv[req->interfaceTag]; - /* remove the station record & make it NULL */ - if ((staInfo=interfacePriv->staInfo[req->peerRecordHandle])!=NULL) { - - uf_prepare_send_cfm_list_for_queued_pkts(priv, - &send_cfm_list, - &(staInfo->mgtFrames)); - - uf_flush_list(priv, &(staInfo->mgtFrames)); - for(j=0;jdataPdu[j])); - uf_flush_list(priv, &(staInfo->dataPdu[j])); - } - - spin_lock_irqsave(&priv->staRecord_lock, lock_flags); - /* clear the port configure array info, for the corresponding peer entry */ - controlledPort = &interfacePriv->controlled_data_port; - unControlledPort = &interfacePriv->uncontrolled_data_port; - - unifi_trace(priv, UDBG1, "peer_delete_record: Peer found handle = %d, port in use: cont(%d), unCont(%d)\n", - req->peerRecordHandle, controlledPort->entries_in_use, unControlledPort->entries_in_use); - - memset(staInfo->peerControlledPort, 0, sizeof(unifi_port_cfg_t)); - staInfo->peerControlledPort->port_action = CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_CLOSED_DISCARD; - staInfo->peerControlledPort->in_use = FALSE; - if (controlledPort->entries_in_use) { - controlledPort->entries_in_use--; - } else { - unifi_warning(priv, "number of controlled port entries is zero, trying to decrement: debug\n"); - } - - memset(staInfo->peerUnControlledPort, 0, sizeof(unifi_port_cfg_t)); - staInfo->peerUnControlledPort->port_action = CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_CLOSED_DISCARD; - staInfo->peerUnControlledPort->in_use = FALSE; - if (unControlledPort->entries_in_use) { - unControlledPort->entries_in_use--; - } else { - unifi_warning(priv, "number of uncontrolled port entries is zero, trying to decrement: debug\n"); - } - - spin_unlock_irqrestore(&priv->staRecord_lock, lock_flags); - /* update the TIM with zero */ - if (interfacePriv->interfaceMode != CSR_WIFI_ROUTER_CTRL_MODE_IBSS && - staInfo->timSet == CSR_WIFI_TIM_SET) { - unifi_trace(priv, UDBG3, "peer is deleted so TIM updated to 0, in firmware\n"); - update_tim(priv, staInfo->aid, 0, req->interfaceTag, req->peerRecordHandle); - } - - - /* Stop BA session if it is active, for this peer address all BA sessions - (per tID per role) are closed */ - - down(&priv->ba_mutex); - for(ba_session_idx=0; ba_session_idx < MAX_SUPPORTED_BA_SESSIONS_RX; ba_session_idx++){ - ba_session_rx = priv->interfacePriv[req->interfaceTag]->ba_session_rx[ba_session_idx]; - if(ba_session_rx) { - if(!memcmp(ba_session_rx->macAddress.a, staInfo->peerMacAddress.a, ETH_ALEN)){ - blockack_session_stop(priv, - req->interfaceTag, - CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_RECIPIENT, - ba_session_rx->tID, - ba_session_rx->macAddress); - } - } - } - - for(ba_session_idx=0; ba_session_idx < MAX_SUPPORTED_BA_SESSIONS_TX; ba_session_idx++){ - ba_session_tx = priv->interfacePriv[req->interfaceTag]->ba_session_tx[ba_session_idx]; - if(ba_session_tx) { - if(!memcmp(ba_session_tx->macAddress.a, staInfo->peerMacAddress.a, ETH_ALEN)){ - blockack_session_stop(priv, - req->interfaceTag, - CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_ORIGINATOR, - ba_session_tx->tID, - ba_session_tx->macAddress); - } - } - } - - up(&priv->ba_mutex); - -#ifdef CSR_SUPPORT_SME - unifi_trace(priv, UDBG1, "Canceling work queue for STA with AID: %d\n", staInfo->aid); - cancel_work_sync(&staInfo->send_disconnected_ind_task); -#endif - - spin_lock_irqsave(&priv->staRecord_lock, lock_flags); -#ifdef CSR_SUPPORT_SME - interfacePriv->num_stations_joined--; - - staInfo->nullDataHostTag = INVALID_HOST_TAG; - - if ((interfacePriv->sta_activity_check_enabled) && - (interfacePriv->num_stations_joined < STA_INACTIVE_DETECTION_TRIGGER_THRESHOLD)) - { - unifi_trace(priv, UDBG1, "STOPPING the Inactivity Timer (num of stations = %d)\n", interfacePriv->num_stations_joined); - interfacePriv->sta_activity_check_enabled = FALSE; - del_timer_sync(&interfacePriv->sta_activity_check_timer); - } -#endif - - /* Free the station record for corresponding peer */ - kfree(interfacePriv->staInfo[req->peerRecordHandle]); - interfacePriv->staInfo[req->peerRecordHandle] = NULL; - spin_unlock_irqrestore(&priv->staRecord_lock, lock_flags); - - /* after the critical region process the list of frames that requested cfm - and send cfm to requestor one by one */ - send_auto_ma_packet_confirm(priv, interfacePriv, &send_cfm_list); - - - } - else - { - unifi_trace(priv, UDBG3, " peer not found: Delete request Peer handle[%d]\n", req->peerRecordHandle); - } - - return CSR_RESULT_SUCCESS; -} - -void CsrWifiRouterCtrlPeerDelReqHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ - CsrWifiRouterCtrlPeerDelReq* req = (CsrWifiRouterCtrlPeerDelReq*)msg; - CsrResult status = CSR_RESULT_SUCCESS; - unifi_priv_t *priv = (unifi_priv_t*)drvpriv; - netInterface_priv_t *interfacePriv; - - unifi_trace(priv, UDBG2, "entering CsrWifiRouterCtrlPeerDelReqHandler\n"); - if (priv == NULL) - { - unifi_error(priv, "CsrWifiRouterCtrlPeerDelReqHandler: invalid smepriv\n"); - return; - } - - if (req->interfaceTag >= CSR_WIFI_NUM_INTERFACES) - { - unifi_error(priv, "CsrWifiRouterCtrlPeerDelReqHandler: bad interfaceTag\n"); - return; - } - - interfacePriv = priv->interfacePriv[req->interfaceTag]; - - switch(interfacePriv->interfaceMode) - { - case CSR_WIFI_ROUTER_CTRL_MODE_AP: - case CSR_WIFI_ROUTER_CTRL_MODE_IBSS: - case CSR_WIFI_ROUTER_CTRL_MODE_P2PGO: - /* remove the station from station record data base */ - status = peer_delete_record(priv, req); - break; - case CSR_WIFI_ROUTER_CTRL_MODE_STA: - case CSR_WIFI_ROUTER_CTRL_MODE_P2PCLI: - default: - /* No station record to maintain in these modes */ - break; - } - - CsrWifiRouterCtrlPeerDelCfmSend(msg->source, req->clientData, req->interfaceTag, status); - unifi_trace(priv, UDBG2, "leaving CsrWifiRouterCtrlPeerDelReqHandler \n"); -} - -/* Add the new station to the station record data base */ -static int peer_add_new_record(unifi_priv_t *priv, CsrWifiRouterCtrlPeerAddReq *req, u32 *handle) -{ - u8 i, powerModeTemp = 0; - u8 freeSlotFound = FALSE; - CsrWifiRouterCtrlStaInfo_t *newRecord = NULL; - netInterface_priv_t *interfacePriv = priv->interfacePriv[req->interfaceTag]; - u32 currentTime, currentTimeHi; - unsigned long lock_flags; - - if (req->interfaceTag >= CSR_WIFI_NUM_INTERFACES) { - unifi_error(priv, "peer_add_new_record: bad interfaceTag\n"); - return CSR_RESULT_FAILURE; - } - - currentTime = CsrTimeGet(¤tTimeHi); - - for(i = 0; i < UNIFI_MAX_CONNECTIONS; i++) { - if(interfacePriv->staInfo[i] == NULL) { - /* Slot is empty, so can be used for station record */ - freeSlotFound = TRUE; - *handle = i; - - /* Allocate for the new station record , to avoid race condition would happen between ADD_PEER & - * DEL_PEER the allocation made atomic memory rather than kernel memory - */ - newRecord = kmalloc(sizeof(CsrWifiRouterCtrlStaInfo_t), GFP_ATOMIC); - if (!newRecord) { - unifi_error(priv, "failed to allocate the %d bytes of mem for station record\n", - sizeof(CsrWifiRouterCtrlStaInfo_t)); - return CSR_RESULT_FAILURE; - } - - unifi_trace(priv, UDBG1, "peer_add_new_record: handle = %d AID = %d addr = %x:%x:%x:%x:%x:%x LI=%u\n", - *handle, req->associationId, req->peerMacAddress.a[0], req->peerMacAddress.a[1], req->peerMacAddress.a[2], - req->peerMacAddress.a[3], req->peerMacAddress.a[4], req->peerMacAddress.a[5], - req->staInfo.listenIntervalInTus); - - /* disable the preemption until station record updated */ - spin_lock_irqsave(&priv->staRecord_lock, lock_flags); - - interfacePriv->staInfo[i] = newRecord; - /* Initialize the record*/ - memset(newRecord, 0, sizeof(CsrWifiRouterCtrlStaInfo_t)); - /* update the station record */ - memcpy(newRecord->peerMacAddress.a, req->peerMacAddress.a, ETH_ALEN); - newRecord->wmmOrQosEnabled = req->staInfo.wmmOrQosEnabled; - - /* maxSpLength is bit map in qosInfo field, so converting accordingly */ - newRecord->maxSpLength = req->staInfo.maxSpLength * 2; - - /*Max SP 0 mean any number of packets. since we buffer only 512 - packets we are hard coding this to zero for the moment */ - - if(newRecord->maxSpLength == 0) - newRecord->maxSpLength=512; - - newRecord->assignedHandle = i; - - /* copy power save mode of all access catagory (Trigger/Delivery/both enabled/disabled) */ - powerModeTemp = (u8) ((req->staInfo.powersaveMode >> 4) & 0xff); - - if(!(req->staInfo.powersaveMode & 0x0001)) - newRecord->powersaveMode[UNIFI_TRAFFIC_Q_BK]= CSR_WIFI_AC_LEGACY_POWER_SAVE; - else - newRecord->powersaveMode[UNIFI_TRAFFIC_Q_BK]= powerModeTemp & 0x03; - - if(!(req->staInfo.powersaveMode & 0x0002)) - newRecord->powersaveMode[UNIFI_TRAFFIC_Q_BE]= CSR_WIFI_AC_LEGACY_POWER_SAVE; - else - newRecord->powersaveMode[UNIFI_TRAFFIC_Q_BE]= ((powerModeTemp & 0x0C)>> 2); - - if(!(req->staInfo.powersaveMode & 0x0004)) - newRecord->powersaveMode[UNIFI_TRAFFIC_Q_VI]= CSR_WIFI_AC_LEGACY_POWER_SAVE; - else - newRecord->powersaveMode[UNIFI_TRAFFIC_Q_VI]= ((powerModeTemp & 0x30)>> 4); - - if(!(req->staInfo.powersaveMode & 0x0008)) - newRecord->powersaveMode[UNIFI_TRAFFIC_Q_VO]= CSR_WIFI_AC_LEGACY_POWER_SAVE; - else - newRecord->powersaveMode[UNIFI_TRAFFIC_Q_VO]= ((powerModeTemp & 0xC0)>> 6); - - { - u8 k; - for(k=0; k< MAX_ACCESS_CATOGORY ;k++) - unifi_trace(priv, UDBG2, "peer_add_new_record: WMM : %d ,AC %d, powersaveMode %x \n", - req->staInfo.wmmOrQosEnabled, k, newRecord->powersaveMode[k]); - } - - unifi_trace(priv, UDBG3, "newRecord->wmmOrQosEnabled : %d , MAX SP : %d\n", - newRecord->wmmOrQosEnabled, newRecord->maxSpLength); - - /* Initialize the mgtFrames & data Pdu list */ - { - u8 j; - INIT_LIST_HEAD(&newRecord->mgtFrames); - for(j = 0; j < MAX_ACCESS_CATOGORY; j++) { - INIT_LIST_HEAD(&newRecord->dataPdu[j]); - } - } - - newRecord->lastActivity = currentTime; - newRecord->activity_flag = TRUE; - - /* enable the preemption as station record updated */ - spin_unlock_irqrestore(&priv->staRecord_lock, lock_flags); - - /* First time port actions are set for the peer with below information */ - configure_data_port(priv, CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_OPEN, &newRecord->peerMacAddress, - UF_UNCONTROLLED_PORT_Q, req->interfaceTag); - - if (interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_IBSS) { - configure_data_port(priv, CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_OPEN, &newRecord->peerMacAddress, - UF_CONTROLLED_PORT_Q, req->interfaceTag); - } else { - configure_data_port(priv, CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_CLOSED_DISCARD, &newRecord->peerMacAddress, - UF_CONTROLLED_PORT_Q, req->interfaceTag); - } - - - spin_lock_irqsave(&priv->staRecord_lock, lock_flags); - /* Port status must be already set before calling the Add Peer request */ - newRecord->peerControlledPort = uf_sme_port_config_handle(priv, newRecord->peerMacAddress.a, - UF_CONTROLLED_PORT_Q, req->interfaceTag); - newRecord->peerUnControlledPort = uf_sme_port_config_handle(priv, newRecord->peerMacAddress.a, - UF_UNCONTROLLED_PORT_Q, req->interfaceTag); - - if (!newRecord->peerControlledPort || !newRecord->peerUnControlledPort) { - /* enable the preemption as station record failed to update */ - unifi_warning(priv, "Un/ControlledPort record not found in port configuration array index = %d\n", i); - kfree(interfacePriv->staInfo[i]); - interfacePriv->staInfo[i] = NULL; - spin_unlock_irqrestore(&priv->staRecord_lock, lock_flags); - return CSR_RESULT_FAILURE; - } - - newRecord->currentPeerState = CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_ACTIVE; - - /* changes done during block ack handling */ - newRecord->txSuspend = FALSE; - - /*U-APSD related data structure*/ - newRecord->timRequestPendingFlag = FALSE; - - /* Initialise the variable updateTimReqQueued with a value - * other then CSR_WIFI_TIM_SET or CSR_WIFI_TIM_RESET value - */ - newRecord->updateTimReqQueued = 0xFF; - newRecord->timSet = CSR_WIFI_TIM_RESET; - newRecord->uapsdActive = FALSE; - newRecord->noOfSpFramesSent =0; - newRecord->triggerFramePriority = CSR_QOS_UP0; - - /* The protection bit is updated once the port opens for corresponding peer in - * routerPortConfigure request */ - - /* update the association ID */ - newRecord->aid = req->associationId; - -#ifdef CSR_SUPPORT_SME - interfacePriv->num_stations_joined++; - newRecord->interfacePriv = interfacePriv; - newRecord->listenIntervalInTus = req->staInfo.listenIntervalInTus; - newRecord->nullDataHostTag = INVALID_HOST_TAG; - - INIT_WORK(&newRecord->send_disconnected_ind_task, uf_send_disconnected_ind_wq); - - if(!(interfacePriv->sta_activity_check_enabled) && - (interfacePriv->num_stations_joined >= STA_INACTIVE_DETECTION_TRIGGER_THRESHOLD)){ - unifi_trace(priv, UDBG1, - "peer_add_new_record: STARTING the Inactivity Timer (num of stations = %d)", - interfacePriv->num_stations_joined); - - interfacePriv->sta_activity_check_enabled = TRUE; - interfacePriv->sta_activity_check_timer.function = check_inactivity_timer_expire_func; - interfacePriv->sta_activity_check_timer.data = (unsigned long)interfacePriv; - - init_timer(&interfacePriv->sta_activity_check_timer); - mod_timer(&interfacePriv->sta_activity_check_timer, - (jiffies + usecs_to_jiffies(STA_INACTIVE_DETECTION_TIMER_INTERVAL * 1000 * 1000))); - - } -#endif - spin_unlock_irqrestore(&priv->staRecord_lock, lock_flags); - break; - } - } - - if(!freeSlotFound) { - unifi_error(priv, "Limited connectivity, Free slot not found for station record addition\n"); - return CSR_RESULT_FAILURE; - } - return CSR_RESULT_SUCCESS; -} - -#ifdef CSR_SUPPORT_SME -static void check_inactivity_timer_expire_func(unsigned long data) -{ - struct unifi_priv *priv; - CsrWifiRouterCtrlStaInfo_t *sta_record = NULL; - u8 i = 0; - u32 now; - u32 inactive_time; - netInterface_priv_t *interfacePriv = (netInterface_priv_t *) data; - - if (!interfacePriv) - { - return; - } - - priv = interfacePriv->privPtr; - - if (interfacePriv->InterfaceTag >= CSR_WIFI_NUM_INTERFACES) - { - unifi_error(priv, "check_inactivity_timer_expire_func: Invalid interfaceTag\n"); - return; - } - - /* RUN Algorithm to check inactivity for each connected station */ - now = CsrTimeGet(NULL); - - for(i = 0; i < UNIFI_MAX_CONNECTIONS; i++) { - if(interfacePriv->staInfo[i] != NULL) { - sta_record = interfacePriv->staInfo[i]; - - if (sta_record->activity_flag == TRUE){ - sta_record->activity_flag = FALSE; - sta_record->lastActivity = now; - continue; - } - - if (sta_record->lastActivity > now) - { - /* simple timer wrap (for 1 wrap) */ - inactive_time = CsrTimeAdd((u32)CsrTimeSub(CSR_SCHED_TIME_MAX, sta_record->lastActivity), now); - } - else - { - inactive_time = (u32)CsrTimeSub(now, sta_record->lastActivity); - } - - if (inactive_time >= STA_INACTIVE_TIMEOUT_VAL) - { - unifi_trace(priv, UDBG1, "STA is Inactive - AID = %d inactive_time = %d\n", - sta_record->aid, - inactive_time); - - /* station is in-active, if it is in active mode send a null frame - * and the station should acknowledge the null frame, if acknowledgement - * is not received throw out the station. - * If the station is in Power Save, update TIM for the station so - * that it wakes up and register some activity through PS-Poll or - * trigger frame. - */ - if (sta_record->currentPeerState == CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_ACTIVE) - { - unifi_trace(priv, UDBG1, "STA power save state - Active, send a NULL frame to check if it is ALIVE\n"); - uf_send_nulldata ( priv, - sta_record->interfacePriv->InterfaceTag, - sta_record->peerMacAddress.a, - CSR_CONTENTION, - sta_record); - } - else if (sta_record->currentPeerState == CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_POWER_SAVE) - { - if((sta_record->timSet == CSR_WIFI_TIM_SET) || - (sta_record->timSet == CSR_WIFI_TIM_SETTING)) - { - unifi_trace(priv, UDBG1, "STA power save state - PS, TIM is already SET\n"); - - /* If TIM is set and we do not have any activity for - * more than 3 listen intervals then send a disconnected - * indication to SME, to delete the station from station - * record list. - * The inactivity is already more than STA_INACTIVE_TIMEOUT_VAL - * and this check ensures if the listen interval is a larger - * value than STA_INACTIVE_TIMEOUT_VAL. - */ - if (inactive_time > (3 * (sta_record->listenIntervalInTus * 1024))) - { - unifi_trace(priv, UDBG1, "STA is inactive for more than 3 listen intervals\n"); - queue_work( priv->unifi_workqueue, - &sta_record->send_disconnected_ind_task); - } - - } - else - { - unifi_trace(priv, UDBG1, "STA power save state - PS, update TIM to see if it is ALIVE\n"); - update_tim(priv, - sta_record->aid, - CSR_WIFI_TIM_SET, - interfacePriv->InterfaceTag, - sta_record->assignedHandle); - } - } - } - } - } - - /* re-run the timer interrupt */ - mod_timer(&interfacePriv->sta_activity_check_timer, - (jiffies + usecs_to_jiffies(STA_INACTIVE_DETECTION_TIMER_INTERVAL * 1000 * 1000))); - -} - - -void uf_send_disconnected_ind_wq(struct work_struct *work) -{ - - CsrWifiRouterCtrlStaInfo_t *staInfo = container_of(work, CsrWifiRouterCtrlStaInfo_t, send_disconnected_ind_task); - unifi_priv_t *priv; - u16 interfaceTag; - struct list_head send_cfm_list; - u8 j; - - if(!staInfo) { - return; - } - - if(!staInfo->interfacePriv) { - return; - } - - priv = staInfo->interfacePriv->privPtr; - interfaceTag = staInfo->interfacePriv->InterfaceTag; - - if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) { - unifi_error(priv, "uf_send_disconnected_ind_wq: invalid interfaceTag\n"); - return; - } - - /* The SME/NME may be waiting for confirmation for requested frames to this station. - * So loop through buffered frames for this station and if confirmation is - * requested, send auto confirmation with failure status. Also flush the frames so - * that these are not processed again in PEER_DEL_REQ handler. - */ - INIT_LIST_HEAD(&send_cfm_list); - - uf_prepare_send_cfm_list_for_queued_pkts(priv, - &send_cfm_list, - &(staInfo->mgtFrames)); - - uf_flush_list(priv, &(staInfo->mgtFrames)); - - for(j = 0; j < MAX_ACCESS_CATOGORY; j++){ - uf_prepare_send_cfm_list_for_queued_pkts(priv, - &send_cfm_list, - &(staInfo->dataPdu[j])); - - uf_flush_list(priv, &(staInfo->dataPdu[j])); - } - - send_auto_ma_packet_confirm(priv, staInfo->interfacePriv, &send_cfm_list); - - unifi_warning(priv, "uf_send_disconnected_ind_wq: Router Disconnected IND Peer (%x-%x-%x-%x-%x-%x)\n", - staInfo->peerMacAddress.a[0], - staInfo->peerMacAddress.a[1], - staInfo->peerMacAddress.a[2], - staInfo->peerMacAddress.a[3], - staInfo->peerMacAddress.a[4], - staInfo->peerMacAddress.a[5]); - - CsrWifiRouterCtrlConnectedIndSend(priv->CSR_WIFI_SME_IFACEQUEUE, - 0, - staInfo->interfacePriv->InterfaceTag, - staInfo->peerMacAddress, - CSR_WIFI_ROUTER_CTRL_PEER_DISCONNECTED); - - - return; -} - - -#endif -void CsrWifiRouterCtrlPeerAddReqHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ - CsrWifiRouterCtrlPeerAddReq* req = (CsrWifiRouterCtrlPeerAddReq*)msg; - CsrResult status = CSR_RESULT_SUCCESS; - unifi_priv_t *priv = (unifi_priv_t*)drvpriv; - u32 handle = 0; - netInterface_priv_t *interfacePriv; - - unifi_trace(priv, UDBG2, "entering CsrWifiRouterCtrlPeerAddReqHandler \n"); - if (priv == NULL) - { - unifi_error(priv, "CsrWifiRouterCtrlPeerAddReqHandler: invalid smepriv\n"); - return; - } - - if (req->interfaceTag >= CSR_WIFI_NUM_INTERFACES) - { - unifi_error(priv, "CsrWifiRouterCtrlPeerAddReqHandler: bad interfaceTag\n"); - return; - } - - interfacePriv = priv->interfacePriv[req->interfaceTag]; - - switch(interfacePriv->interfaceMode) - { - case CSR_WIFI_ROUTER_CTRL_MODE_AP: - case CSR_WIFI_ROUTER_CTRL_MODE_IBSS: - case CSR_WIFI_ROUTER_CTRL_MODE_P2PGO: - /* Add station record */ - status = peer_add_new_record(priv, req, &handle); - break; - case CSR_WIFI_ROUTER_CTRL_MODE_STA: - case CSR_WIFI_ROUTER_CTRL_MODE_P2PCLI: - default: - /* No station record to maintain in these modes */ - break; - } - - CsrWifiRouterCtrlPeerAddCfmSend(msg->source, req->clientData, req->interfaceTag, req->peerMacAddress, handle, status); - unifi_trace(priv, UDBG2, "leaving CsrWifiRouterCtrlPeerAddReqHandler \n"); -} - -void CsrWifiRouterCtrlPeerUpdateReqHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ - CsrWifiRouterCtrlPeerUpdateReq* req = (CsrWifiRouterCtrlPeerUpdateReq*)msg; - CsrResult status = CSR_RESULT_SUCCESS; - unifi_priv_t *priv = (unifi_priv_t*)drvpriv; - - unifi_trace(priv, UDBG2, "entering CsrWifiRouterCtrlPeerUpdateReqHandler \n"); - if (priv == NULL) - { - unifi_error(priv, "CsrWifiRouterCtrlPeerUpdateReqHandler: invalid smepriv\n"); - return; - } - - CsrWifiRouterCtrlPeerUpdateCfmSend(msg->source, req->clientData, req->interfaceTag, status); - unifi_trace(priv, UDBG2, "leaving CsrWifiRouterCtrlPeerUpdateReqHandler \n"); -} - - - void CsrWifiRouterCtrlRawSdioDeinitialiseReqHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ - /* This will never be called as it is intercepted in the Userspace */ -} - -void CsrWifiRouterCtrlRawSdioInitialiseReqHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ - /* This will never be called as it is intercepted in the Userspace */ -} - -void -uf_send_ba_err_wq(struct work_struct *work) -{ - ba_session_rx_struct *ba_session = container_of(work, ba_session_rx_struct, send_ba_err_task); - unifi_priv_t *priv; - - if(!ba_session) { - return; - } - - if(!ba_session->interfacePriv) { - return; - } - - priv = ba_session->interfacePriv->privPtr; - - if (ba_session->interfacePriv->InterfaceTag >= CSR_WIFI_NUM_INTERFACES) { - unifi_error(priv, "%s: invalid interfaceTag\n", __FUNCTION__); - return; - } - - unifi_warning(priv, "%s: Calling CsrWifiRouterCtrlBlockAckErrorIndSend(%d, %d, %d, %d, %x:%x:%x:%x:%x:%x, %d)\n", - __FUNCTION__, - priv->CSR_WIFI_SME_IFACEQUEUE, - 0, - ba_session->interfacePriv->InterfaceTag, - ba_session->tID, - ba_session->macAddress.a[0], - ba_session->macAddress.a[1], - ba_session->macAddress.a[2], - ba_session->macAddress.a[3], - ba_session->macAddress.a[4], - ba_session->macAddress.a[5], - CSR_RESULT_SUCCESS - ); - CsrWifiRouterCtrlBlockAckErrorIndSend(priv->CSR_WIFI_SME_IFACEQUEUE, - 0, - ba_session->interfacePriv->InterfaceTag, - ba_session->tID, - ba_session->macAddress, - CSR_RESULT_SUCCESS); -} - - -static void ba_session_terminate_timer_func(unsigned long data) -{ - ba_session_rx_struct *ba_session = (ba_session_rx_struct*)data; - struct unifi_priv *priv; - - if(!ba_session) { - return; - } - - if(!ba_session->interfacePriv) { - return; - } - - priv = ba_session->interfacePriv->privPtr; - - if (ba_session->interfacePriv->InterfaceTag >= CSR_WIFI_NUM_INTERFACES) { - unifi_error(priv, "%s: invalid interfaceTag\n", __FUNCTION__); - return; - } - - queue_work(priv->unifi_workqueue, &ba_session->send_ba_err_task); -} - - -u8 blockack_session_stop(unifi_priv_t *priv, - u16 interfaceTag, - CsrWifiRouterCtrlBlockAckRole role, - u16 tID, - CsrWifiMacAddress macAddress) -{ - netInterface_priv_t *interfacePriv; - ba_session_rx_struct *ba_session_rx = NULL; - ba_session_tx_struct *ba_session_tx = NULL; - u8 ba_session_idx = 0; - int i; - - if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) { - unifi_error(priv, "%s: bad interfaceTag = %d\n", __FUNCTION__, interfaceTag); - return FALSE; - } - - interfacePriv = priv->interfacePriv[interfaceTag]; - - if(!interfacePriv) { - unifi_error(priv, "%s: bad interfacePriv\n", __FUNCTION__); - return FALSE; - } - - if(tID > 15) { - unifi_error(priv, "%s: bad tID = %d\n", __FUNCTION__, tID); - return FALSE; - } - - if((role != CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_ORIGINATOR) && - (role != CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_RECIPIENT)) { - unifi_error(priv, "%s: bad role = %d\n", __FUNCTION__, role); - return FALSE; - } - - unifi_warning(priv, - "%s: stopping ba_session for peer = %pM role = %d tID = %d\n", - __func__, macAddress.a, role, tID); - - /* find out the appropriate ba session (/station /tid /role) for which stop is requested */ - if (role == CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_RECIPIENT){ - for (ba_session_idx =0; ba_session_idx < MAX_SUPPORTED_BA_SESSIONS_RX; ba_session_idx++){ - - ba_session_rx = interfacePriv->ba_session_rx[ba_session_idx]; - - if(ba_session_rx){ - if ((!memcmp(ba_session_rx->macAddress.a, macAddress.a, ETH_ALEN)) && (ba_session_rx->tID == tID)){ - break; - } - } - } - - if (!ba_session_rx || (ba_session_idx == MAX_SUPPORTED_BA_SESSIONS_RX)) { - unifi_error(priv, "%s: bad ba_session for Rx [tID=%d]\n", __FUNCTION__, tID); - return FALSE; - } - - - if(ba_session_rx->timeout) { - del_timer_sync(&ba_session_rx->timer); - } - cancel_work_sync(&ba_session_rx->send_ba_err_task); - for (i = 0; i < ba_session_rx->wind_size; i++) { - if(ba_session_rx->buffer[i].active) { - frame_desc_struct *frame_desc = &ba_session_rx->buffer[i]; - unifi_net_data_free(priv, &frame_desc->bulkdata.d[0]); - } - } - kfree(ba_session_rx->buffer); - - interfacePriv->ba_session_rx[ba_session_idx] = NULL; - kfree(ba_session_rx); - }else if (role == CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_ORIGINATOR){ - for (ba_session_idx =0; ba_session_idx < MAX_SUPPORTED_BA_SESSIONS_TX; ba_session_idx++){ - ba_session_tx = interfacePriv->ba_session_tx[ba_session_idx]; - if(ba_session_tx){ - if ((!memcmp(ba_session_tx->macAddress.a, macAddress.a, ETH_ALEN)) && (ba_session_tx->tID == tID)){ - break; - } - } - } - - if (!ba_session_tx || (ba_session_idx == MAX_SUPPORTED_BA_SESSIONS_TX)) { - unifi_error(priv, "%s: bad ba_session for Tx [tID=%d]\n", __FUNCTION__, tID); - return FALSE; - } - interfacePriv->ba_session_tx[ba_session_idx] = NULL; - kfree(ba_session_tx); - - } - - return TRUE; -} - - -void CsrWifiRouterCtrlBlockAckDisableReqHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ - CsrWifiRouterCtrlBlockAckDisableReq* req = (CsrWifiRouterCtrlBlockAckDisableReq*)msg; - u8 r; - unifi_priv_t *priv = (unifi_priv_t*)drvpriv; - - unifi_trace(priv, UDBG6, "%s: in ok\n", __FUNCTION__); - - down(&priv->ba_mutex); - r = blockack_session_stop(priv, - req->interfaceTag, - req->role, - req->trafficStreamID, - req->macAddress); - up(&priv->ba_mutex); - - CsrWifiRouterCtrlBlockAckDisableCfmSend(msg->source, - req->clientData, - req->interfaceTag, - r?CSR_RESULT_SUCCESS:CSR_RESULT_FAILURE); - - unifi_trace(priv, UDBG6, "%s: out ok\n", __FUNCTION__); -} - - -u8 blockack_session_start(unifi_priv_t *priv, - u16 interfaceTag, - u16 tID, - u16 timeout, - CsrWifiRouterCtrlBlockAckRole role, - u16 wind_size, - u16 start_sn, - CsrWifiMacAddress macAddress - ) -{ - netInterface_priv_t *interfacePriv; - ba_session_rx_struct *ba_session_rx = NULL; - ba_session_tx_struct *ba_session_tx = NULL; - u8 ba_session_idx = 0; - - - if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) { - unifi_error(priv, "%s: bad interfaceTag = %d\n", __FUNCTION__, interfaceTag); - return FALSE; - } - - interfacePriv = priv->interfacePriv[interfaceTag]; - - if(!interfacePriv) { - unifi_error(priv, "%s: bad interfacePriv\n", __FUNCTION__); - return FALSE; - } - - if(tID > 15) - { - unifi_error(priv, "%s: bad tID=%d\n", __FUNCTION__, tID); - return FALSE; - } - - if(wind_size > MAX_BA_WIND_SIZE) { - unifi_error(priv, "%s: bad wind_size = %d\n", __FUNCTION__, wind_size); - return FALSE; - } - - if(role != CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_ORIGINATOR && - role != CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_RECIPIENT) { - unifi_error(priv, "%s: bad role = %d\n", __FUNCTION__, role); - return FALSE; - } - - unifi_warning(priv, - "%s: ba session with peer= (%pM)\n", __func__, - macAddress.a); - - unifi_warning(priv, "%s: ba session for tID=%d timeout=%d role=%d wind_size=%d start_sn=%d\n", __FUNCTION__, - tID, - timeout, - role, - wind_size, - start_sn); - - /* Check if BA session exists for per station, per TID, per role or not. - if BA session exists update parameters and if it does not exist - create a new BA session */ - if (role == CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_ORIGINATOR){ - for (ba_session_idx =0; ba_session_idx < MAX_SUPPORTED_BA_SESSIONS_TX; ba_session_idx++){ - ba_session_tx = interfacePriv->ba_session_tx[ba_session_idx]; - if (ba_session_tx) { - if ((!memcmp(ba_session_tx->macAddress.a, macAddress.a, ETH_ALEN)) && (ba_session_tx->tID == tID)){ - unifi_warning(priv, "%s: ba_session for Tx already exists\n", __FUNCTION__); - return TRUE; - } - } - } - - /* we have to create new ba_session_tx struct */ - ba_session_tx = NULL; - - /* loop through until an empty BA session slot is there and save the session there */ - for (ba_session_idx=0; ba_session_idx < MAX_SUPPORTED_BA_SESSIONS_TX ; ba_session_idx++){ - if (!(interfacePriv->ba_session_tx[ba_session_idx])){ - break; - } - } - if (ba_session_idx == MAX_SUPPORTED_BA_SESSIONS_TX){ - unifi_error(priv, "%s: All ba_session used for Tx, NO free session available\n", __FUNCTION__); - return FALSE; - } - - /* create and populate the new BA session structure */ - ba_session_tx = kzalloc(sizeof(ba_session_tx_struct), GFP_KERNEL); - if (!ba_session_tx) { - unifi_error(priv, "%s: kmalloc failed for ba_session_tx\n", __FUNCTION__); - return FALSE; - } - - ba_session_tx->interfacePriv = interfacePriv; - ba_session_tx->tID = tID; - ba_session_tx->macAddress = macAddress; - - interfacePriv->ba_session_tx[ba_session_idx] = ba_session_tx; - - } else if (role == CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_RECIPIENT){ - - for (ba_session_idx =0; ba_session_idx < MAX_SUPPORTED_BA_SESSIONS_RX; ba_session_idx++){ - ba_session_rx = interfacePriv->ba_session_rx[ba_session_idx]; - if (ba_session_rx) { - if ((!memcmp(ba_session_rx->macAddress.a, macAddress.a, ETH_ALEN)) && (ba_session_rx->tID == tID)){ - unifi_warning(priv, "%s: ba_session for Rx[tID = %d] already exists\n", __FUNCTION__, tID); - - if(ba_session_rx->wind_size == wind_size && - ba_session_rx->timeout == timeout && - ba_session_rx->expected_sn == start_sn) { - return TRUE; - } - - if(ba_session_rx->timeout) { - del_timer_sync(&ba_session_rx->timer); - ba_session_rx->timeout = 0; - } - - if(ba_session_rx->wind_size != wind_size) { - blockack_session_stop(priv, interfaceTag, role, tID, macAddress); - } else { - if (timeout) { - ba_session_rx->timeout = timeout; - ba_session_rx->timer.function = ba_session_terminate_timer_func; - ba_session_rx->timer.data = (unsigned long)ba_session_rx; - init_timer(&ba_session_rx->timer); - mod_timer(&ba_session_rx->timer, (jiffies + usecs_to_jiffies((ba_session_rx->timeout) * 1024))); - } - /* - * The starting sequence number shall remain same if the BA - * enable request is issued to update BA parameters only. If - * it is not same, then we scroll our window to the new starting - * sequence number. This could happen if the DELBA frame from - * originator is lost and then we receive ADDBA frame with new SSN. - */ - if(ba_session_rx->start_sn != start_sn) { - scroll_ba_window(priv, interfacePriv, ba_session_rx, start_sn); - } - return TRUE; - } - } - } - } - - /* we could have a valid BA session pointer here or un-initialized - ba session pointer. but in any case we have to create a new session. - so re-initialize the ba_session pointer */ - ba_session_rx = NULL; - - /* loop through until an empty BA session slot is there and save the session there */ - for (ba_session_idx=0; ba_session_idx < MAX_SUPPORTED_BA_SESSIONS_RX ; ba_session_idx++){ - if (!(interfacePriv->ba_session_rx[ba_session_idx])){ - break; - } - } - if (ba_session_idx == MAX_SUPPORTED_BA_SESSIONS_RX){ - unifi_error(priv, "%s: All ba_session used for Rx, NO free session available\n", __FUNCTION__); - return FALSE; - } - - /* It is observed that with some devices there is a race between - * EAPOL exchanges and BA session establishment. This results in - * some EAPOL authentication packets getting stuck in BA reorder - * buffer and hence the conection cannot be established. To avoid - * this we check here if the EAPOL authentication is complete and - * if so then only allow the BA session to establish. - * - * It is verified that the peers normally re-establish - * the BA session after the initial rejection. - */ - if (CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_OPEN != uf_sme_port_state(priv, macAddress.a, UF_CONTROLLED_PORT_Q, interfacePriv->InterfaceTag)) - { - unifi_warning(priv, "blockack_session_start: Controlled port not opened, Reject BA request\n"); - return FALSE; - } - - ba_session_rx = kzalloc(sizeof(ba_session_rx_struct), GFP_KERNEL); - if (!ba_session_rx) { - unifi_error(priv, "%s: kmalloc failed for ba_session_rx\n", __FUNCTION__); - return FALSE; - } - - ba_session_rx->wind_size = wind_size; - ba_session_rx->start_sn = ba_session_rx->expected_sn = start_sn; - ba_session_rx->trigger_ba_after_ssn = FALSE; - - ba_session_rx->buffer = kzalloc(ba_session_rx->wind_size*sizeof(frame_desc_struct), GFP_KERNEL); - if (!ba_session_rx->buffer) { - kfree(ba_session_rx); - unifi_error(priv, "%s: kmalloc failed for buffer\n", __FUNCTION__); - return FALSE; - } - - INIT_WORK(&ba_session_rx->send_ba_err_task, uf_send_ba_err_wq); - if (timeout) { - ba_session_rx->timeout = timeout; - ba_session_rx->timer.function = ba_session_terminate_timer_func; - ba_session_rx->timer.data = (unsigned long)ba_session_rx; - init_timer(&ba_session_rx->timer); - mod_timer(&ba_session_rx->timer, (jiffies + usecs_to_jiffies((ba_session_rx->timeout) * 1024))); - } - - ba_session_rx->interfacePriv = interfacePriv; - ba_session_rx->tID = tID; - ba_session_rx->macAddress = macAddress; - - interfacePriv->ba_session_rx[ba_session_idx] = ba_session_rx; - } - return TRUE; -} - -void CsrWifiRouterCtrlBlockAckEnableReqHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ - CsrWifiRouterCtrlBlockAckEnableReq* req = (CsrWifiRouterCtrlBlockAckEnableReq*)msg; - u8 r; - unifi_priv_t *priv = (unifi_priv_t*)drvpriv; - - unifi_trace(priv, UDBG6, ">>%s\n", __FUNCTION__); - down(&priv->ba_mutex); - r = blockack_session_start(priv, - req->interfaceTag, - req->trafficStreamID, - req->timeout, - req->role, - req->bufferSize, - req->ssn, - req->macAddress - ); - up(&priv->ba_mutex); - - CsrWifiRouterCtrlBlockAckEnableCfmSend(msg->source, - req->clientData, - req->interfaceTag, - r?CSR_RESULT_SUCCESS:CSR_RESULT_FAILURE); - unifi_trace(priv, UDBG6, "<<%s: r=%d\n", __FUNCTION__, r); - -} - -void CsrWifiRouterCtrlWapiMulticastFilterReqHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ -#ifdef CSR_WIFI_SECURITY_WAPI_ENABLE - - unifi_priv_t *priv = (unifi_priv_t*)drvpriv; - CsrWifiRouterCtrlWapiMulticastFilterReq* req = (CsrWifiRouterCtrlWapiMulticastFilterReq*)msg; - netInterface_priv_t *interfacePriv = priv->interfacePriv[req->interfaceTag]; - - if (CSR_WIFI_ROUTER_CTRL_MODE_STA == interfacePriv->interfaceMode) { - - unifi_trace(priv, UDBG6, ">>%s\n", __FUNCTION__); - - unifi_trace(priv, UDBG1, "CsrWifiRouterCtrlWapiMulticastFilterReq: req->status = %d\n", req->status); - - /* status 1 - Filter on - * status 0 - Filter off */ - priv->wapi_multicast_filter = req->status; - - unifi_trace(priv, UDBG6, "<<%s\n", __FUNCTION__); - } else { - - unifi_warning(priv, "%s is NOT applicable for interface mode - %d\n", __FUNCTION__, interfacePriv->interfaceMode); - - } -#elif defined(UNIFI_DEBUG) - /*WAPI Disabled*/ - unifi_priv_t *priv = (unifi_priv_t*)drvpriv; - unifi_error(priv, "CsrWifiRouterCtrlWapiMulticastFilterReqHandler: called when WAPI isn't enabled\n"); -#endif -} - -void CsrWifiRouterCtrlWapiUnicastFilterReqHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ -#ifdef CSR_WIFI_SECURITY_WAPI_ENABLE - - unifi_priv_t *priv = (unifi_priv_t*)drvpriv; - CsrWifiRouterCtrlWapiUnicastFilterReq* req = (CsrWifiRouterCtrlWapiUnicastFilterReq*)msg; - netInterface_priv_t *interfacePriv = priv->interfacePriv[req->interfaceTag]; - - if (CSR_WIFI_ROUTER_CTRL_MODE_STA == interfacePriv->interfaceMode) { - - unifi_trace(priv, UDBG6, ">>%s\n", __FUNCTION__); - - unifi_trace(priv, UDBG1, "CsrWifiRouterCtrlWapiUnicastFilterReq: req->status= %d\n", req->status); - - if ((priv->wapi_unicast_filter == 1) && (req->status == 0)) { - /* When we have successfully re-associated and obtained a new unicast key with keyid = 0 */ - priv->wapi_unicast_queued_pkt_filter = 1; - } - - /* status 1 - Filter ON - * status 0 - Filter OFF */ - priv->wapi_unicast_filter = req->status; - - unifi_trace(priv, UDBG6, "<<%s\n", __FUNCTION__); - } else { - - unifi_warning(priv, "%s is NOT applicable for interface mode - %d\n", __FUNCTION__, interfacePriv->interfaceMode); - - } -#elif defined(UNIFI_DEBUG) - /*WAPI Disabled*/ - unifi_priv_t *priv = (unifi_priv_t*)drvpriv; - unifi_error(priv, "CsrWifiRouterCtrlWapiUnicastFilterReqHandler: called when WAPI isn't enabled\n"); -#endif -} - -void CsrWifiRouterCtrlWapiRxPktReqHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ -#ifdef CSR_WIFI_SECURITY_WAPI_ENABLE - - unifi_priv_t *priv = (unifi_priv_t*)drvpriv; - CsrWifiRouterCtrlWapiRxPktReq* req = (CsrWifiRouterCtrlWapiRxPktReq*)msg; - int client_id, receiver_id; - bulk_data_param_t bulkdata; - CsrResult res; - ul_client_t *client; - CSR_SIGNAL signal; - CSR_MA_PACKET_INDICATION *pkt_ind; - netInterface_priv_t *interfacePriv; - - if (priv == NULL) { - unifi_error(priv, "CsrWifiRouterCtrlWapiRxPktReq : invalid priv\n", __func__); - return; - } - - if (priv->smepriv == NULL) { - unifi_error(priv, "CsrWifiRouterCtrlWapiRxPktReq : invalid sme priv\n", __func__); - return; - } - - interfacePriv = priv->interfacePriv[req->interfaceTag]; - - if (CSR_WIFI_ROUTER_CTRL_MODE_STA == interfacePriv->interfaceMode) { - - unifi_trace(priv, UDBG6, ">>%s\n", __FUNCTION__); - - - if (req->dataLength == 0 || req->data == NULL) { - unifi_error(priv, "CsrWifiRouterCtrlWapiRxPktReq: invalid request\n", __FUNCTION__); - return; - } - - res = unifi_net_data_malloc(priv, &bulkdata.d[0], req->dataLength); - if (res != CSR_RESULT_SUCCESS) { - unifi_error(priv, "CsrWifiRouterCtrlWapiRxPktReq: Could not allocate net data\n", __FUNCTION__); - return; - } - - /* This function is expected to be called only when the MIC has been verified by SME to be correct - * So reset the reception status to rx_success */ - res = read_unpack_signal(req->signal, &signal); - if (res) { - unifi_error(priv, "CsrWifiRouterCtrlWapiRxPktReqHandler: Received unknown or corrupted signal.\n"); - return; - } - pkt_ind = (CSR_MA_PACKET_INDICATION*) (&((&signal)->u).MaPacketIndication); - if (pkt_ind->ReceptionStatus != CSR_MICHAEL_MIC_ERROR) { - unifi_error(priv, "CsrWifiRouterCtrlWapiRxPktReqHandler: Unknown signal with reception status = %d\n", pkt_ind->ReceptionStatus); - return; - } else { - unifi_trace(priv, UDBG4, "CsrWifiRouterCtrlWapiRxPktReqHandler: MIC verified , RX_SUCCESS \n", __FUNCTION__); - pkt_ind->ReceptionStatus = CSR_RX_SUCCESS; - write_pack(&signal, req->signal, &(req->signalLength)); - } - - memcpy((void*)bulkdata.d[0].os_data_ptr, req->data, req->dataLength); - - receiver_id = CSR_GET_UINT16_FROM_LITTLE_ENDIAN((req->signal) + sizeof(s16)) & 0xFFF0; - client_id = (receiver_id & 0x0F00) >> UDI_SENDER_ID_SHIFT; - - client = &priv->ul_clients[client_id]; - - if (client && client->event_hook) { - unifi_trace(priv, UDBG3, - "CsrWifiRouterCtrlWapiRxPktReq: " - "Sending signal to client %d, (s:0x%X, r:0x%X) - Signal 0x%X \n", - client->client_id, client->sender_id, receiver_id, - CSR_GET_UINT16_FROM_LITTLE_ENDIAN(req->signal)); - - client->event_hook(client, req->signal, req->signalLength, &bulkdata, UDI_TO_HOST); - } else { - unifi_trace(priv, UDBG4, "No client to give the packet to\n"); - unifi_net_data_free(priv, &bulkdata.d[0]); - } - - unifi_trace(priv, UDBG6, "<<%s\n", __FUNCTION__); - } else { - unifi_warning(priv, "%s is NOT applicable for interface mode - %d\n", __FUNCTION__, interfacePriv->interfaceMode); - } -#elif defined(UNIFI_DEBUG) - /*WAPI Disabled*/ - unifi_priv_t *priv = (unifi_priv_t*)drvpriv; - unifi_error(priv, "CsrWifiRouterCtrlWapiRxPktReqHandler: called when WAPI isn't enabled\n"); -#endif -} - -void CsrWifiRouterCtrlWapiUnicastTxPktReqHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ -#if (defined(CSR_WIFI_SECURITY_WAPI_ENABLE) && defined(CSR_WIFI_SECURITY_WAPI_SW_ENCRYPTION)) - - unifi_priv_t *priv = (unifi_priv_t*) drvpriv; - CsrWifiRouterCtrlWapiUnicastTxPktReq *req = (CsrWifiRouterCtrlWapiUnicastTxPktReq*) msg; - netInterface_priv_t *interfacePriv = priv->interfacePriv[req->interfaceTag]; - bulk_data_param_t bulkdata; - u8 macHeaderLengthInBytes = MAC_HEADER_SIZE; - /*KeyID, Reserved, PN, MIC*/ - u8 appendedCryptoFields = 1 + 1 + 16 + 16; - CsrResult result; - /* Retrieve the MA PACKET REQ fields from the Signal retained from send_ma_pkt_request() */ - CSR_MA_PACKET_REQUEST *storedSignalMAPktReq = &interfacePriv->wapi_unicast_ma_pkt_sig.u.MaPacketRequest; - - if (CSR_WIFI_ROUTER_CTRL_MODE_STA == interfacePriv->interfaceMode) { - - unifi_trace(priv, UDBG6, ">>%s\n", __FUNCTION__); - - if (priv == NULL) { - unifi_error(priv, "CsrWifiRouterCtrlWapiUnicastTxPktReqHandler : invalid priv\n", __FUNCTION__); - return; - } - if (priv->smepriv == NULL) { - unifi_error(priv, "CsrWifiRouterCtrlWapiUnicastTxPktReqHandler : invalid sme priv\n", __FUNCTION__); - return; - } - if (req->data == NULL) { - unifi_error(priv, "CsrWifiRouterCtrlWapiUnicastTxPktReqHandler: invalid request\n", __FUNCTION__); - return; - } else { - /* If it is QoS data (type = data subtype = QoS), frame header contains QoS control field */ - if ((req->data[0] & 0x88) == 0x88) { - macHeaderLengthInBytes = macHeaderLengthInBytes + QOS_CONTROL_HEADER_SIZE; - } - } - if ( !(req->dataLength>(macHeaderLengthInBytes+appendedCryptoFields)) ) { - unifi_error(priv, "CsrWifiRouterCtrlWapiUnicastTxPktReqHandler: invalid dataLength\n", __FUNCTION__); - return; - } - - /* Encrypted DATA Packet contained in (req->data) - * ------------------------------------------------------------------- - * |MAC Header| KeyId | Reserved | PN | xxDataxx | xxMICxxx | - * ------------------------------------------------------------------- - * (<-----Encrypted----->) - * ------------------------------------------------------------------- - * |24/26(QoS)| 1 | 1 | 16 | x | 16 | - * ------------------------------------------------------------------- - */ - result = unifi_net_data_malloc(priv, &bulkdata.d[0], req->dataLength); - if (result != CSR_RESULT_SUCCESS) { - unifi_error(priv, "CsrWifiRouterCtrlWapiUnicastTxPktReqHandler: Could not allocate net data\n", __FUNCTION__); - return; - } - memcpy((void*)bulkdata.d[0].os_data_ptr, req->data, req->dataLength); - bulkdata.d[0].data_length = req->dataLength; - bulkdata.d[1].os_data_ptr = NULL; - bulkdata.d[1].data_length = 0; - - /* Send UniFi msg */ - /* Here hostTag is been sent as 0xffffffff, its been appended properly while framing MA-Packet request in pdu_processing.c file */ - result = uf_process_ma_packet_req(priv, - storedSignalMAPktReq->Ra.x, - storedSignalMAPktReq->HostTag,/* Ask for a new HostTag */ - req->interfaceTag, - storedSignalMAPktReq->TransmissionControl, - storedSignalMAPktReq->TransmitRate, - storedSignalMAPktReq->Priority, /* Retained value */ - interfacePriv->wapi_unicast_ma_pkt_sig.SignalPrimitiveHeader.SenderProcessId, /*FIXME AP: VALIDATE ???*/ - &bulkdata); - - if (result == NETDEV_TX_OK) { - (priv->netdev[req->interfaceTag])->trans_start = jiffies; - /* Should really count tx stats in the UNITDATA.status signal but - * that doesn't have the length. - */ - interfacePriv->stats.tx_packets++; - - /* count only the packet payload */ - interfacePriv->stats.tx_bytes += req->dataLength - macHeaderLengthInBytes - appendedCryptoFields; - unifi_trace(priv, UDBG1, "CsrWifiRouterCtrlWapiUnicastTxPktReqHandler: (Packet Sent), sent count = %x\n", interfacePriv->stats.tx_packets); - } else { - /* Failed to send: fh queue was full, and the skb was discarded*/ - unifi_trace(priv, UDBG1, "(HIP validation failure) Result = %d\n", result); - unifi_net_data_free(priv, &bulkdata.d[0]); - - interfacePriv->stats.tx_dropped++; - unifi_trace(priv, UDBG1, "CsrWifiRouterCtrlWapiUnicastTxPktReqHandler: (Packet Drop), dropped count = %x\n", interfacePriv->stats.tx_dropped); - } - - unifi_trace(priv, UDBG6, "<<%s\n", __FUNCTION__); - - } else { - - unifi_warning(priv, "%s is NOT applicable for interface mode - %d\n", __FUNCTION__, interfacePriv->interfaceMode); - - } -#elif defined(UNIFI_DEBUG) - /*WAPI Disabled*/ - unifi_priv_t *priv = (unifi_priv_t*)drvpriv; - unifi_error(priv, "CsrWifiRouterCtrlWapiUnicastTxPktReqHandler: called when WAPI SW ENCRYPTION isn't enabled\n"); -#endif -} - -void CsrWifiRouterCtrlWapiFilterReqHandler(void* drvpriv, CsrWifiFsmEvent* msg) -{ -#ifdef CSR_WIFI_SECURITY_WAPI_ENABLE - -#ifdef CSR_WIFI_SECURITY_WAPI_QOSCTRL_MIC_WORKAROUND - unifi_priv_t *priv = (unifi_priv_t*)drvpriv; - CsrWifiRouterCtrlWapiFilterReq* req = (CsrWifiRouterCtrlWapiFilterReq*)msg; - netInterface_priv_t *interfacePriv = priv->interfacePriv[req->interfaceTag]; - - if (CSR_WIFI_ROUTER_CTRL_MODE_STA == interfacePriv->interfaceMode) { - - unifi_trace(priv, UDBG6, ">>%s\n", __FUNCTION__); - - unifi_trace(priv, UDBG1, "CsrWifiRouterCtrlWapiFilterReq: req->isWapiConnected [0/1] = %d \n", req->isWapiConnected); - - priv->isWapiConnection = req->isWapiConnected; - - unifi_trace(priv, UDBG6, "<<%s\n", __FUNCTION__); - } else { - - unifi_warning(priv, "%s is NOT applicable for interface mode - %d\n", __FUNCTION__, interfacePriv->interfaceMode); - - } -#endif - -#elif defined(UNIFI_DEBUG) - /*WAPI Disabled*/ - unifi_priv_t *priv = (unifi_priv_t*)drvpriv; - unifi_error(priv, "CsrWifiRouterCtrlWapiFilterReq: called when WAPI isn't enabled\n"); -#endif -} diff --git a/drivers/staging/csr/sme_userspace.c b/drivers/staging/csr/sme_userspace.c deleted file mode 100644 index b919b001ef7c..000000000000 --- a/drivers/staging/csr/sme_userspace.c +++ /dev/null @@ -1,315 +0,0 @@ -/* - ***************************************************************************** - * - * FILE : sme_userspace.c - * - * PURPOSE : Support functions for userspace SME helper application. - * - * - * Copyright (C) 2008-2011 by Cambridge Silicon Radio Ltd. - * - * Refer to LICENSE.txt included with this source code for details on - * the license terms. - * - ***************************************************************************** - */ - -#include "unifi_priv.h" - -/* - * Fix Me..... These need to be the correct values... - * Dynamic from the user space. - */ -CsrSchedQid CSR_WIFI_ROUTER_IFACEQUEUE = 0xFFFF; -CsrSchedQid CSR_WIFI_SME_IFACEQUEUE = 0xFFFF; -#ifdef CSR_SUPPORT_WEXT_AP -CsrSchedQid CSR_WIFI_NME_IFACEQUEUE = 0xFFFF; -#endif -int -uf_sme_init(unifi_priv_t *priv) -{ - int i, j; - - CsrWifiRouterTransportInit(priv); - - priv->smepriv = priv; - - init_waitqueue_head(&priv->sme_request_wq); - - priv->filter_tclas_ies = NULL; - memset(&priv->packet_filters, 0, sizeof(uf_cfg_bcast_packet_filter_t)); - -#ifdef CSR_SUPPORT_WEXT - priv->ignore_bssid_join = FALSE; - priv->mib_data.length = 0; - - uf_sme_wext_set_defaults(priv); -#endif /* CSR_SUPPORT_WEXT*/ - - priv->sta_ip_address = 0xFFFFFFFF; - - priv->wifi_on_state = wifi_on_unspecified; - - sema_init(&priv->sme_sem, 1); - memset(&priv->sme_reply, 0, sizeof(sme_reply_t)); - - priv->ta_ind_work.in_use = 0; - priv->ta_sample_ind_work.in_use = 0; - - priv->CSR_WIFI_SME_IFACEQUEUE = 0xFFFF; - - for (i = 0; i < MAX_MA_UNIDATA_IND_FILTERS; i++) { - priv->sme_unidata_ind_filters[i].in_use = 0; - } - - /* Create a work queue item for Traffic Analysis indications to SME */ - INIT_WORK(&priv->ta_ind_work.task, uf_ta_ind_wq); - INIT_WORK(&priv->ta_sample_ind_work.task, uf_ta_sample_ind_wq); -#ifdef CSR_SUPPORT_WEXT - INIT_WORK(&priv->sme_config_task, uf_sme_config_wq); -#endif - - for (i = 0; i < CSR_WIFI_NUM_INTERFACES; i++) { - netInterface_priv_t *interfacePriv = priv->interfacePriv[i]; - interfacePriv->m4_sent = FALSE; - interfacePriv->m4_bulk_data.net_buf_length = 0; - interfacePriv->m4_bulk_data.data_length = 0; - interfacePriv->m4_bulk_data.os_data_ptr = interfacePriv->m4_bulk_data.os_net_buf_ptr = NULL; - - memset(&interfacePriv->controlled_data_port, 0, sizeof(unifi_port_config_t)); - interfacePriv->controlled_data_port.entries_in_use = 1; - interfacePriv->controlled_data_port.port_cfg[0].in_use = TRUE; - interfacePriv->controlled_data_port.port_cfg[0].port_action = CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_CLOSED_DISCARD; - interfacePriv->controlled_data_port.overide_action = UF_DATA_PORT_OVERIDE; - - memset(&interfacePriv->uncontrolled_data_port, 0, sizeof(unifi_port_config_t)); - interfacePriv->uncontrolled_data_port.entries_in_use = 1; - interfacePriv->uncontrolled_data_port.port_cfg[0].in_use = TRUE; - interfacePriv->uncontrolled_data_port.port_cfg[0].port_action = CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_CLOSED_DISCARD; - interfacePriv->uncontrolled_data_port.overide_action = UF_DATA_PORT_OVERIDE; - - /* Mark the remainder of the port config table as unallocated */ - for(j = 1; j < UNIFI_MAX_CONNECTIONS; j++) { - interfacePriv->controlled_data_port.port_cfg[j].in_use = FALSE; - interfacePriv->controlled_data_port.port_cfg[j].port_action = CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_CLOSED_DISCARD; - - interfacePriv->uncontrolled_data_port.port_cfg[j].in_use = FALSE; - interfacePriv->uncontrolled_data_port.port_cfg[j].port_action = CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_CLOSED_DISCARD; - } - - /* intializing the lists */ - INIT_LIST_HEAD(&interfacePriv->genericMgtFrames); - INIT_LIST_HEAD(&interfacePriv->genericMulticastOrBroadCastMgtFrames); - INIT_LIST_HEAD(&interfacePriv->genericMulticastOrBroadCastFrames); - - for(j = 0; j < UNIFI_MAX_CONNECTIONS; j++) { - interfacePriv->staInfo[j] = NULL; - } - - interfacePriv->num_stations_joined = 0; - interfacePriv->sta_activity_check_enabled = FALSE; - } - - - return 0; -} /* uf_sme_init() */ - - -void -uf_sme_deinit(unifi_priv_t *priv) -{ - int i, j; - u8 ba_session_idx; - ba_session_rx_struct *ba_session_rx = NULL; - ba_session_tx_struct *ba_session_tx = NULL; - CsrWifiRouterCtrlStaInfo_t *staInfo = NULL; - netInterface_priv_t *interfacePriv = NULL; - - /* Free any TCLASs previously allocated */ - if (priv->packet_filters.tclas_ies_length) { - priv->packet_filters.tclas_ies_length = 0; - kfree(priv->filter_tclas_ies); - priv->filter_tclas_ies = NULL; - } - - for (i = 0; i < MAX_MA_UNIDATA_IND_FILTERS; i++) { - priv->sme_unidata_ind_filters[i].in_use = 0; - } - - /* Remove all the Peer database, before going down */ - for (i = 0; i < CSR_WIFI_NUM_INTERFACES; i++) { - down(&priv->ba_mutex); - for(ba_session_idx=0; ba_session_idx < MAX_SUPPORTED_BA_SESSIONS_RX; ba_session_idx++){ - ba_session_rx = priv->interfacePriv[i]->ba_session_rx[ba_session_idx]; - if(ba_session_rx) { - blockack_session_stop(priv, - i, - CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_RECIPIENT, - ba_session_rx->tID, - ba_session_rx->macAddress); - } - } - for(ba_session_idx=0; ba_session_idx < MAX_SUPPORTED_BA_SESSIONS_TX; ba_session_idx++){ - ba_session_tx = priv->interfacePriv[i]->ba_session_tx[ba_session_idx]; - if(ba_session_tx) { - blockack_session_stop(priv, - i, - CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_ORIGINATOR, - ba_session_tx->tID, - ba_session_tx->macAddress); - } - } - - up(&priv->ba_mutex); - interfacePriv = priv->interfacePriv[i]; - if(interfacePriv){ - for(j = 0; j < UNIFI_MAX_CONNECTIONS; j++) { - if ((staInfo=interfacePriv->staInfo[j]) != NULL) { - /* Clear the STA activity parameters before freeing station Record */ - unifi_trace(priv, UDBG1, "uf_sme_deinit: Canceling work queue for STA with AID: %d\n", staInfo->aid); - cancel_work_sync(&staInfo->send_disconnected_ind_task); - staInfo->nullDataHostTag = INVALID_HOST_TAG; - } - } - if (interfacePriv->sta_activity_check_enabled){ - interfacePriv->sta_activity_check_enabled = FALSE; - del_timer_sync(&interfacePriv->sta_activity_check_timer); - } - } - CsrWifiRouterCtrlInterfaceReset(priv, i); - priv->interfacePriv[i]->interfaceMode = CSR_WIFI_ROUTER_CTRL_MODE_NONE; - } - - -} /* uf_sme_deinit() */ - - - - - -/* - * --------------------------------------------------------------------------- - * unifi_ta_indicate_protocol - * - * Report that a packet of a particular type has been seen - * - * Arguments: - * drv_priv The device context pointer passed to ta_init. - * protocol The protocol type enum value. - * direction Whether the packet was a tx or rx. - * src_addr The source MAC address from the data packet. - * - * Returns: - * None. - * - * Notes: - * We defer the actual sending to a background workqueue, - * see uf_ta_ind_wq(). - * --------------------------------------------------------------------------- - */ -void -unifi_ta_indicate_protocol(void *ospriv, - CsrWifiRouterCtrlTrafficPacketType packet_type, - CsrWifiRouterCtrlProtocolDirection direction, - const CsrWifiMacAddress *src_addr) -{ - unifi_priv_t *priv = (unifi_priv_t*)ospriv; - - if (priv->ta_ind_work.in_use) { - unifi_warning(priv, - "unifi_ta_indicate_protocol: workqueue item still in use, not sending\n"); - return; - } - - if (CSR_WIFI_ROUTER_CTRL_PROTOCOL_DIRECTION_RX == direction) - { - u16 interfaceTag = 0; - CsrWifiRouterCtrlTrafficProtocolIndSend(priv->CSR_WIFI_SME_IFACEQUEUE, 0, - interfaceTag, - packet_type, - direction, - *src_addr); - } - else - { - priv->ta_ind_work.packet_type = packet_type; - priv->ta_ind_work.direction = direction; - priv->ta_ind_work.src_addr = *src_addr; - - queue_work(priv->unifi_workqueue, &priv->ta_ind_work.task); - } - -} /* unifi_ta_indicate_protocol() */ - - -/* - * --------------------------------------------------------------------------- - * unifi_ta_indicate_sampling - * - * Send the TA sampling information to the SME. - * - * Arguments: - * drv_priv The device context pointer passed to ta_init. - * stats The TA sampling data to send. - * - * Returns: - * None. - * --------------------------------------------------------------------------- - */ -void -unifi_ta_indicate_sampling(void *ospriv, CsrWifiRouterCtrlTrafficStats *stats) -{ - unifi_priv_t *priv = (unifi_priv_t*)ospriv; - - if (!priv) { - return; - } - - if (priv->ta_sample_ind_work.in_use) { - unifi_warning(priv, - "unifi_ta_indicate_sampling: workqueue item still in use, not sending\n"); - return; - } - - priv->ta_sample_ind_work.stats = *stats; - - queue_work(priv->unifi_workqueue, &priv->ta_sample_ind_work.task); - -} /* unifi_ta_indicate_sampling() */ - - -/* - * --------------------------------------------------------------------------- - * unifi_ta_indicate_l4stats - * - * Send the TA TCP/UDP throughput information to the driver. - * - * Arguments: - * drv_priv The device context pointer passed to ta_init. - * rxTcpThroughput TCP RX throughput in KiloBytes - * txTcpThroughput TCP TX throughput in KiloBytes - * rxUdpThroughput UDP RX throughput in KiloBytes - * txUdpThroughput UDP TX throughput in KiloBytes - * - * Returns: - * None. - * --------------------------------------------------------------------------- - */ -void -unifi_ta_indicate_l4stats(void *ospriv, - u32 rxTcpThroughput, - u32 txTcpThroughput, - u32 rxUdpThroughput, - u32 txUdpThroughput) -{ - unifi_priv_t *priv = (unifi_priv_t*)ospriv; - - if (!priv) { - return; - } - /* Save the info. The actual action will be taken in unifi_ta_indicate_sampling() */ - priv->rxTcpThroughput = rxTcpThroughput; - priv->txTcpThroughput = txTcpThroughput; - priv->rxUdpThroughput = rxUdpThroughput; - priv->txUdpThroughput = txUdpThroughput; -} /* unifi_ta_indicate_l4stats() */ diff --git a/drivers/staging/csr/sme_userspace.h b/drivers/staging/csr/sme_userspace.h deleted file mode 100644 index ebe371c732b2..000000000000 --- a/drivers/staging/csr/sme_userspace.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * *************************************************************************** - * FILE: sme_userspace.h - * - * PURPOSE: SME related definitions. - * - * Copyright (C) 2007-2008 by Cambridge Silicon Radio Ltd. - * - * Refer to LICENSE.txt included with this source code for details on - * the license terms. - * - * *************************************************************************** - */ -#ifndef __LINUX_SME_USERSPACE_H__ -#define __LINUX_SME_USERSPACE_H__ 1 - -#include - -int uf_sme_init(unifi_priv_t *priv); -void uf_sme_deinit(unifi_priv_t *priv); -int uf_sme_queue_message(unifi_priv_t *priv, u8 *buffer, int length); - - -#include "csr_wifi_router_lib.h" -#include "csr_wifi_router_sef.h" -#include "csr_wifi_router_ctrl_lib.h" -#include "csr_wifi_router_ctrl_sef.h" -#include "csr_wifi_sme_task.h" -#ifdef CSR_SUPPORT_WEXT_AP -#include "csr_wifi_nme_ap_lib.h" -#endif -#include "csr_wifi_sme_lib.h" - -void CsrWifiRouterTransportInit(unifi_priv_t *priv); -void CsrWifiRouterTransportRecv(unifi_priv_t *priv, u8 *buffer, size_t bufferLength); -void CsrWifiRouterTransportDeInit(unifi_priv_t *priv); - -#endif /* __LINUX_SME_USERSPACE_H__ */ diff --git a/drivers/staging/csr/sme_wext.c b/drivers/staging/csr/sme_wext.c deleted file mode 100644 index 84f11cb53596..000000000000 --- a/drivers/staging/csr/sme_wext.c +++ /dev/null @@ -1,3327 +0,0 @@ -/* - * --------------------------------------------------------------------------- - * FILE: sme_wext.c - * - * PURPOSE: - * Handlers for ioctls from iwconfig. - * These provide the control plane operations. - * - * Copyright (C) 2007-2009 by Cambridge Silicon Radio Ltd. - * - * Refer to LICENSE.txt included with this source code for details on - * the license terms. - * - * --------------------------------------------------------------------------- - */ -#include -#include -#include -#include -#include -#include "unifi_priv.h" -#include - -#define CHECK_INITED(_priv) \ - do { \ - if (_priv->init_progress != UNIFI_INIT_COMPLETED) { \ - unifi_trace(_priv, UDBG2, "%s unifi not ready, failing wext call\n", __FUNCTION__); \ - return -ENODEV; \ - } \ - } while (0) - -/* Workaround for the wpa_supplicant hanging issue - disabled on Android */ -#ifndef ANDROID_BUILD -#define CSR_WIFI_WEXT_HANG_WORKAROUND -#endif - -#ifdef CSR_WIFI_WEXT_HANG_WORKAROUND -# define UF_RTNL_LOCK() rtnl_lock() -# define UF_RTNL_UNLOCK() rtnl_unlock() -#else -# define UF_RTNL_LOCK() -# define UF_RTNL_UNLOCK() -#endif - - -/* - * --------------------------------------------------------------------------- - * Helper functions - * --------------------------------------------------------------------------- - */ - -/* - * --------------------------------------------------------------------------- - * wext_freq_to_channel - * channel_to_mhz - * - * These functions convert between channel number and frequency. - * - * Arguments: - * ch Channel number, as defined in 802.11 specs - * m, e Mantissa and exponent as provided by wireless extension. - * - * Returns: - * channel or frequency (in MHz) value - * --------------------------------------------------------------------------- - */ -static int -wext_freq_to_channel(int m, int e) -{ - int mhz; - - mhz = m; - while (e < 6) { - mhz /= 10; - e++; - } - while (e > 6) { - mhz *= 10; - e--; - } - - if (mhz >= 5000) { - return ((mhz - 5000) / 5); - } - - if (mhz == 2482) { - return 14; - } - - if (mhz >= 2407) { - return ((mhz - 2407) / 5); - } - - return 0; -} /* wext_freq_to_channel() */ - -static int -channel_to_mhz(int ch, int dot11a) -{ - - if (ch == 0) return 0; - if (ch > 200) return 0; - - /* 5G */ - if (dot11a) { - return (5000 + (5 * ch)); - } - - /* 2.4G */ - if (ch == 14) { - return 2484; - } - - if ((ch < 14) && (ch > 0)) { - return (2407 + (5 * ch)); - } - - return 0; -} -#ifdef CSR_SUPPORT_WEXT_AP -void uf_sme_wext_ap_set_defaults(unifi_priv_t *priv) -{ - memcpy(priv->ap_config.ssid.ssid, "defaultssid", sizeof("defaultssid")); - - priv->ap_config.ssid.length = 8; - priv->ap_config.channel = 6; - priv->ap_config.if_index = 1; - priv->ap_config.credentials.authType = 0; - priv->ap_config.max_connections=8; - - priv->group_sec_config.apGroupkeyTimeout = 0; - priv->group_sec_config.apStrictGtkRekey = 0; - priv->group_sec_config.apGmkTimeout = 0; - priv->group_sec_config.apResponseTimeout = 100; /* Default*/ - priv->group_sec_config.apRetransLimit = 3; /* Default*/ - /* Set default params even if they may not be used*/ - /* Until Here*/ - - priv->ap_mac_config.preamble = CSR_WIFI_SME_USE_LONG_PREAMBLE; - priv->ap_mac_config.shortSlotTimeEnabled = FALSE; - priv->ap_mac_config.ctsProtectionType=CSR_WIFI_SME_CTS_PROTECTION_AUTOMATIC; - - priv->ap_mac_config.wmmEnabled = TRUE; - priv->ap_mac_config.wmmApParams[0].cwMin=4; - priv->ap_mac_config.wmmApParams[0].cwMax=10; - priv->ap_mac_config.wmmApParams[0].aifs=3; - priv->ap_mac_config.wmmApParams[0].txopLimit=0; - priv->ap_mac_config.wmmApParams[0].admissionControlMandatory=FALSE; - priv->ap_mac_config.wmmApParams[1].cwMin=4; - priv->ap_mac_config.wmmApParams[1].cwMax=10; - priv->ap_mac_config.wmmApParams[1].aifs=7; - priv->ap_mac_config.wmmApParams[1].txopLimit=0; - priv->ap_mac_config.wmmApParams[1].admissionControlMandatory=FALSE; - priv->ap_mac_config.wmmApParams[2].cwMin=3; - priv->ap_mac_config.wmmApParams[2].cwMax=4; - priv->ap_mac_config.wmmApParams[2].aifs=1; - priv->ap_mac_config.wmmApParams[2].txopLimit=94; - priv->ap_mac_config.wmmApParams[2].admissionControlMandatory=FALSE; - priv->ap_mac_config.wmmApParams[3].cwMin=2; - priv->ap_mac_config.wmmApParams[3].cwMax=3; - priv->ap_mac_config.wmmApParams[3].aifs=1; - priv->ap_mac_config.wmmApParams[3].txopLimit=47; - priv->ap_mac_config.wmmApParams[3].admissionControlMandatory=FALSE; - - priv->ap_mac_config.wmmApBcParams[0].cwMin=4; - priv->ap_mac_config.wmmApBcParams[0].cwMax=10; - priv->ap_mac_config.wmmApBcParams[0].aifs=3; - priv->ap_mac_config.wmmApBcParams[0].txopLimit=0; - priv->ap_mac_config.wmmApBcParams[0].admissionControlMandatory=FALSE; - priv->ap_mac_config.wmmApBcParams[1].cwMin=4; - priv->ap_mac_config.wmmApBcParams[1].cwMax=10; - priv->ap_mac_config.wmmApBcParams[1].aifs=7; - priv->ap_mac_config.wmmApBcParams[1].txopLimit=0; - priv->ap_mac_config.wmmApBcParams[1].admissionControlMandatory=FALSE; - priv->ap_mac_config.wmmApBcParams[2].cwMin=3; - priv->ap_mac_config.wmmApBcParams[2].cwMax=4; - priv->ap_mac_config.wmmApBcParams[2].aifs=2; - priv->ap_mac_config.wmmApBcParams[2].txopLimit=94; - priv->ap_mac_config.wmmApBcParams[2].admissionControlMandatory=FALSE; - priv->ap_mac_config.wmmApBcParams[3].cwMin=2; - priv->ap_mac_config.wmmApBcParams[3].cwMax=3; - priv->ap_mac_config.wmmApBcParams[3].aifs=2; - priv->ap_mac_config.wmmApBcParams[3].txopLimit=47; - priv->ap_mac_config.wmmApBcParams[3].admissionControlMandatory=FALSE; - - priv->ap_mac_config.accessType=CSR_WIFI_AP_ACCESS_TYPE_NONE; - priv->ap_mac_config.macAddressListCount=0; - priv->ap_mac_config.macAddressList=NULL; - - priv->ap_mac_config.apHtParams.rxStbc=1; - priv->ap_mac_config.apHtParams.rifsModeAllowed=TRUE; - priv->ap_mac_config.apHtParams.greenfieldSupported=FALSE; - priv->ap_mac_config.apHtParams.shortGi20MHz=TRUE; - priv->ap_mac_config.apHtParams.htProtection=0; - priv->ap_mac_config.apHtParams.dualCtsProtection=FALSE; - - priv->ap_mac_config.phySupportedBitmap = - (CSR_WIFI_SME_AP_PHY_SUPPORT_B|CSR_WIFI_SME_AP_PHY_SUPPORT_G|CSR_WIFI_SME_AP_PHY_SUPPORT_N); - priv->ap_mac_config.beaconInterval= 100; - priv->ap_mac_config.dtimPeriod=3; - priv->ap_mac_config.maxListenInterval=0x00ff;/* Set it to a large value - to enable different types of - devices to join us */ - priv->ap_mac_config.supportedRatesCount = - uf_configure_supported_rates(priv->ap_mac_config.supportedRates, priv->ap_mac_config.phySupportedBitmap); -} -#endif -/* - * --------------------------------------------------------------------------- - * uf_sme_wext_set_defaults - * - * Set up power-on defaults for driver config. - * - * Note: The SME Management API *cannot* be used in this function. - * - * Arguments: - * priv Pointer to device private context struct - * - * Returns: - * None. - * --------------------------------------------------------------------------- - */ -void -uf_sme_wext_set_defaults(unifi_priv_t *priv) -{ - memset(&priv->connection_config, 0, sizeof(CsrWifiSmeConnectionConfig)); - - priv->connection_config.bssType = CSR_WIFI_SME_BSS_TYPE_INFRASTRUCTURE; - priv->connection_config.authModeMask = CSR_WIFI_SME_AUTH_MODE_80211_OPEN; - priv->connection_config.encryptionModeMask = CSR_WIFI_SME_ENCRYPTION_CIPHER_NONE; - priv->connection_config.privacyMode = CSR_WIFI_SME_80211_PRIVACY_MODE_DISABLED; - priv->connection_config.wmmQosInfo = 0xFF; - priv->connection_config.ifIndex = CSR_WIFI_SME_RADIO_IF_BOTH; - priv->connection_config.adhocJoinOnly = FALSE; - priv->connection_config.adhocChannel = 6; - - priv->wep_tx_key_index = 0; - - priv->wext_wireless_stats.qual.qual = 0; - priv->wext_wireless_stats.qual.level = 0; - priv->wext_wireless_stats.qual.noise = 0; - priv->wext_wireless_stats.qual.updated = 0x70; -#ifdef CSR_SUPPORT_WEXT_AP - /* Initialize the default configuration for AP */ - uf_sme_wext_ap_set_defaults(priv); -#endif - - -} /* uf_sme_wext_set_defaults() */ - - -/* - * --------------------------------------------------------------------------- - * WEXT methods - * --------------------------------------------------------------------------- - */ - -/* - * --------------------------------------------------------------------------- - * unifi_giwname - handler for SIOCGIWNAME - * unifi_siwfreq - handler for SIOCSIWFREQ - * unifi_giwfreq - handler for SIOCGIWFREQ - * unifi_siwmode - handler for SIOCSIWMODE - * unifi_giwmode - handler for SIOCGIWMODE - * unifi_giwrange - handler for SIOCGIWRANGE - * unifi_siwap - handler for SIOCSIWAP - * unifi_giwap - handler for SIOCGIWAP - * unifi_siwscan - handler for SIOCSIWSCAN - * unifi_giwscan - handler for SIOCGIWSCAN - * unifi_siwessid - handler for SIOCSIWESSID - * unifi_giwessid - handler for SIOCGIWESSID - * unifi_siwencode - handler for SIOCSIWENCODE - * unifi_giwencode - handler for SIOCGIWENCODE - * - * Handler functions for IW extensions. - * These are registered via the unifi_iw_handler_def struct below - * and called by the generic IW driver support code. - * See include/net/iw_handler.h. - * - * Arguments: - * None. - * - * Returns: - * None. - * --------------------------------------------------------------------------- - */ -static int -iwprivsdefs(struct net_device *dev, struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - int r; - netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev); - unifi_priv_t *priv = interfacePriv->privPtr; - CsrWifiSmeMibConfig mibConfig; - CsrWifiSmePowerConfig powerConfig; - - unifi_trace(priv, UDBG1, "iwprivs80211defaults: reload defaults\n"); - - uf_sme_wext_set_defaults(priv); - - /* Get, modify and set the MIB data */ - r = sme_mgt_mib_config_get(priv, &mibConfig); - if (r) { - unifi_error(priv, "iwprivs80211defaults: Get CsrWifiSmeMibConfigValue failed.\n"); - return r; - } - mibConfig.dot11RtsThreshold = 2347; - mibConfig.dot11FragmentationThreshold = 2346; - r = sme_mgt_mib_config_set(priv, &mibConfig); - if (r) { - unifi_error(priv, "iwprivs80211defaults: Set CsrWifiSmeMibConfigValue failed.\n"); - return r; - } - - powerConfig.powerSaveLevel = CSR_WIFI_SME_POWER_SAVE_LEVEL_LOW; - powerConfig.listenIntervalTu = 100; - powerConfig.rxDtims = 1; - - r = sme_mgt_power_config_set(priv, &powerConfig); - if (r) { - unifi_error(priv, "iwprivs80211defaults: Set unifi_PowerConfigValue failed.\n"); - return r; - } - - return 0; -} /* iwprivsdefs() */ - -static int -iwprivs80211ps(struct net_device *dev, struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - int r = 0; - netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev); - unifi_priv_t *priv = interfacePriv->privPtr; - - int ps_mode = (int)(*extra); - CsrWifiSmePowerConfig powerConfig; - - unifi_trace(priv, UDBG1, "iwprivs80211ps: power save mode = %d\n", ps_mode); - - r = sme_mgt_power_config_get(priv, &powerConfig); - if (r) { - unifi_error(priv, "iwprivs80211ps: Get unifi_PowerConfigValue failed.\n"); - return r; - } - - switch (ps_mode) { - case CSR_PMM_ACTIVE_MODE: - powerConfig.powerSaveLevel = CSR_WIFI_SME_POWER_SAVE_LEVEL_LOW; - break; - case CSR_PMM_POWER_SAVE: - powerConfig.powerSaveLevel = CSR_WIFI_SME_POWER_SAVE_LEVEL_HIGH; - break; - case CSR_PMM_FAST_POWER_SAVE: - powerConfig.powerSaveLevel = CSR_WIFI_SME_POWER_SAVE_LEVEL_MED; - break; - default: - powerConfig.powerSaveLevel = CSR_WIFI_SME_POWER_SAVE_LEVEL_AUTO; - break; - } - - r = sme_mgt_power_config_set(priv, &powerConfig); - if (r) { - unifi_error(priv, "iwprivs80211ps: Set unifi_PowerConfigValue failed.\n"); - } - - return r; -} - -static int -iwprivg80211ps(struct net_device *dev, struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev); - unifi_priv_t *priv = interfacePriv->privPtr; - - CsrWifiSmePowerConfig powerConfig; - int r; - - r = sme_mgt_power_config_get(priv, &powerConfig); - if (r) { - unifi_error(priv, "iwprivg80211ps: Get 802.11 power mode failed.\n"); - return r; - } - - switch (powerConfig.powerSaveLevel) { - case CSR_WIFI_SME_POWER_SAVE_LEVEL_LOW: - snprintf(extra, IWPRIV_POWER_SAVE_MAX_STRING, - "Power save mode: %d (Active)", - powerConfig.powerSaveLevel); - break; - case CSR_WIFI_SME_POWER_SAVE_LEVEL_MED: - snprintf(extra, IWPRIV_POWER_SAVE_MAX_STRING, - "Power save mode: %d (Fast)", - powerConfig.powerSaveLevel); - break; - case CSR_WIFI_SME_POWER_SAVE_LEVEL_HIGH: - snprintf(extra, IWPRIV_POWER_SAVE_MAX_STRING, - "Power save mode: %d (Full)", - powerConfig.powerSaveLevel); - break; - case CSR_WIFI_SME_POWER_SAVE_LEVEL_AUTO: - snprintf(extra, IWPRIV_POWER_SAVE_MAX_STRING, - "Power save mode: %d (Auto)", - powerConfig.powerSaveLevel); - break; - default: - snprintf(extra, IWPRIV_POWER_SAVE_MAX_STRING, - "Power save mode: %d (Unknown)", - powerConfig.powerSaveLevel); - break; - } - - wrqu->data.length = strlen(extra) + 1; - - return 0; -} - -static int -iwprivssmedebug(struct net_device *dev, struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - /* No longer supported on the API */ -#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) - unifi_debug_buf_dump(); -#endif - - return 0; -} - -#ifdef CSR_SUPPORT_WEXT_AP -#define PARAM_TYPE_INT 0 -#define PARAM_TYPE_STRING 1 -#define CSR_WIFI_MAX_SSID_LEN 32 -#define CSR_WIFI_MAX_SEC_LEN 16 -#define CSR_WIFI_MAX_KEY_LEN 65 - -static int hex_look_up(char x) -{ - if(x>='0' && x<='9') - return (x-48); - if(x>= 'a' && x <= 'f') - return (x-87); - return -1; -} - -static int power (int a, int b) -{ - int i; - int num =1; - for(i=0;i param_max_len) { - unifi_notice(priv, "extracted param len:%d is > MAX:%d\n", param_str_len, param_max_len); - param_str_len = param_max_len; - } - switch (param_type) { - case PARAM_TYPE_INT: - { - u32 *pdst_int = dst, num =0; - int i, j=0; - if (param_str_len > sizeof(int_str)) { - param_str_len = sizeof(int_str); - } - memcpy(int_str, param_str_begin, param_str_len); - for(i = param_str_len; i>0;i--) { - if(int_str[i-1] >= '0' && int_str[i-1] <='9') { - num += ((int_str[i-1]-'0')*power(10, j)); - j++; - } else { - unifi_error(priv, "decode_parameter_from_string:not a number %c\n", (int_str[i-1])); - return -1; - } - } - *pdst_int = num; - unifi_trace(priv, UDBG2, "decode_parameter_from_string:decoded int = %d\n", *pdst_int); - } - break; - default: - memcpy(dst, param_str_begin, param_str_len); - *((char *)dst + param_str_len) = 0; - unifi_trace(priv, UDBG2, "decode_parameter_from_string:decoded string = %s\n", (char *)dst); - break; - } - } else { - unifi_error(priv, "decode_parameter_from_string: Token:%s not found in %s \n", token, orig_str); - return -1; - } - return 0; -} -static int store_ap_advanced_config_from_string(unifi_priv_t *priv, char *param_str) -{ - char * str_ptr=param_str; - int ret = 0, tmp_var; - char phy_mode[6]; - CsrWifiSmeApMacConfig * ap_mac_config = &priv->ap_mac_config; - - /* Check for BI */ - ret = decode_parameter_from_string(priv, &str_ptr, "BI=", - PARAM_TYPE_INT, &tmp_var, 5); - if(ret) { - unifi_error(priv, "store_ap_advanced_config_from_string: BI not found\n"); - return -1; - } - ap_mac_config->beaconInterval = tmp_var; - ret = decode_parameter_from_string(priv, &str_ptr, "DTIM_PER=", - PARAM_TYPE_INT, &tmp_var, 5); - if(ret) { - unifi_error(priv, "store_ap_advanced_config_from_string: DTIM_PER not found\n"); - return -1; - } - ap_mac_config->dtimPeriod = tmp_var; - ret = decode_parameter_from_string(priv, &str_ptr, "WMM=", - PARAM_TYPE_INT, &tmp_var, 5); - if(ret) { - unifi_error(priv, "store_ap_advanced_config_from_string: WMM not found\n"); - return -1; - } - ap_mac_config->wmmEnabled = tmp_var; - ret = decode_parameter_from_string(priv, &str_ptr, "PHY=", - PARAM_TYPE_STRING, phy_mode, 5); - if(ret) { - unifi_error(priv, "store_ap_advanced_config_from_string: PHY not found\n"); - } else { - if(strstr(phy_mode, "b")){ - ap_mac_config->phySupportedBitmap = CSR_WIFI_SME_AP_PHY_SUPPORT_B; - } - if(strstr(phy_mode, "g")) { - ap_mac_config->phySupportedBitmap |= CSR_WIFI_SME_AP_PHY_SUPPORT_G; - } - if(strstr(phy_mode, "n")) { - ap_mac_config->phySupportedBitmap |= CSR_WIFI_SME_AP_PHY_SUPPORT_N; - } - ap_mac_config->supportedRatesCount = - uf_configure_supported_rates(ap_mac_config->supportedRates, ap_mac_config->phySupportedBitmap); - } - return ret; -} - -static int store_ap_config_from_string( unifi_priv_t * priv, char *param_str) - -{ - char *str_ptr = param_str; - char sub_cmd[16]; - char sec[CSR_WIFI_MAX_SEC_LEN]; - char key[CSR_WIFI_MAX_KEY_LEN]; - int ret = 0, tmp_var; - CsrWifiSmeApConfig_t *ap_config = &priv->ap_config; - CsrWifiSmeApMacConfig * ap_mac_config = &priv->ap_mac_config; - memset(sub_cmd, 0, sizeof(sub_cmd)); - if(!strstr(param_str, "END")) { - unifi_error(priv, "store_ap_config_from_string:Invalid config string:%s\n", param_str); - return -1; - } - if (decode_parameter_from_string(priv, &str_ptr, "ASCII_CMD=", - PARAM_TYPE_STRING, sub_cmd, 6) != 0) { - return -1; - } - if (strncmp(sub_cmd, "AP_CFG", 6)) { - - if(!strncmp(sub_cmd , "ADVCFG", 6)) { - return store_ap_advanced_config_from_string(priv, str_ptr); - } - unifi_error(priv, "store_ap_config_from_string: sub_cmd:%s != 'AP_CFG or ADVCFG'!\n", sub_cmd); - return -1; - } - memset(ap_config, 0, sizeof(CsrWifiSmeApConfig_t)); - ret = decode_parameter_from_string(priv, &str_ptr, "SSID=", - PARAM_TYPE_STRING, ap_config->ssid.ssid, - CSR_WIFI_MAX_SSID_LEN); - if(ret) { - unifi_error(priv, "store_ap_config_from_string: SSID not found\n"); - return -1; - } - ap_config->ssid.length = strlen(ap_config->ssid.ssid); - - ret = decode_parameter_from_string(priv, &str_ptr, "SEC=", - PARAM_TYPE_STRING, sec, CSR_WIFI_MAX_SEC_LEN); - if(ret) { - unifi_error(priv, "store_ap_config_from_string: SEC not found\n"); - return -1; - } - ret = decode_parameter_from_string(priv, &str_ptr, "KEY=", - PARAM_TYPE_STRING, key, CSR_WIFI_MAX_KEY_LEN); - if(!strcasecmp(sec, "open")) { - unifi_trace(priv, UDBG2, "store_ap_config_from_string: security open"); - ap_config->credentials.authType = CSR_WIFI_SME_AP_AUTH_TYPE_OPEN_SYSTEM; - if(ret) { - unifi_notice(priv, "store_ap_config_from_string: KEY not found:fine with Open\n"); - } - } - else if(!strcasecmp(sec, "wpa2-psk")) { - int i, j=0; - CsrWifiNmeApAuthPers *pers = - ((CsrWifiNmeApAuthPers *)&(ap_config->credentials.nmeAuthType.authTypePersonal)); - u8 *psk = pers->authPers_credentials.psk.psk; - - unifi_trace(priv, UDBG2, "store_ap_config_from_string: security WPA2"); - if(ret) { - unifi_error(priv, "store_ap_config_from_string: KEY not found for WPA2\n"); - return -1; - } - ap_config->credentials.authType = CSR_WIFI_SME_AP_AUTH_TYPE_PERSONAL; - pers->authSupport = CSR_WIFI_SME_RSN_AUTH_WPA2PSK; - pers->rsnCapabilities =0; - pers->wapiCapabilities =0; - pers->pskOrPassphrase=CSR_WIFI_NME_AP_CREDENTIAL_TYPE_PSK; - pers->authPers_credentials.psk.encryptionMode = - (CSR_WIFI_NME_ENCRYPTION_CIPHER_PAIRWISE_CCMP |CSR_WIFI_NME_ENCRYPTION_CIPHER_GROUP_CCMP) ; - for(i=0;i<32;i++){ - psk[i] = (16*hex_look_up(key[j]))+hex_look_up(key[j+1]); - j+=2; - } - - } else { - unifi_notice(priv, "store_ap_config_from_string: Unknown security: Assuming Open"); - ap_config->credentials.authType = CSR_WIFI_SME_AP_AUTH_TYPE_OPEN_SYSTEM; - return -1; - } - /* Get the decoded value in a temp int variable to ensure that other fields within the struct - which are of type other than int are not over written */ - ret = decode_parameter_from_string(priv, &str_ptr, "CHANNEL=", PARAM_TYPE_INT, &tmp_var, 5); - if(ret) - return -1; - ap_config->channel = tmp_var; - ret = decode_parameter_from_string(priv, &str_ptr, "PREAMBLE=", PARAM_TYPE_INT, &tmp_var, 5); - if(ret) - return -1; - ap_mac_config->preamble = tmp_var; - ret = decode_parameter_from_string(priv, &str_ptr, "MAX_SCB=", PARAM_TYPE_INT, &tmp_var, 5); - ap_config->max_connections = tmp_var; - return ret; -} - -static int -iwprivsapstart(struct net_device *dev, struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev); - unifi_priv_t *priv = interfacePriv->privPtr; - int r; - - unifi_trace(priv, UDBG1, "iwprivsapstart\n" ); - r = sme_ap_start(priv, interfacePriv->InterfaceTag, &priv->ap_config); - if(r) { - unifi_error(priv, "iwprivsapstart AP START failed : %d\n", -r); - } - return r; -} - -static int -iwprivsapconfig(struct net_device *dev, struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev); - unifi_priv_t *priv = interfacePriv->privPtr; - char *cfg_str = NULL; - int r; - - unifi_trace(priv, UDBG1, "iwprivsapconfig\n" ); - if (wrqu->data.length != 0) { - char *str; - if (!(cfg_str = kmalloc(wrqu->data.length+1, GFP_KERNEL))) - { - return -ENOMEM; - } - if (copy_from_user(cfg_str, wrqu->data.pointer, wrqu->data.length)) { - kfree(cfg_str); - return -EFAULT; - } - cfg_str[wrqu->data.length] = 0; - unifi_trace(priv, UDBG2, "length:%d\n", wrqu->data.length); - unifi_trace(priv, UDBG2, "AP configuration string:%s\n", cfg_str); - str = cfg_str; - if ((r = store_ap_config_from_string(priv, str))) { - unifi_error(priv, "iwprivsapconfig:Failed to decode the string %d\n", r); - kfree(cfg_str); - return -EIO; - - } - } else { - unifi_error(priv, "iwprivsapconfig argument length = 0 \n"); - return -EIO; - } - r = sme_ap_config(priv, &priv->ap_mac_config, &priv->group_sec_config); - if(r) { - unifi_error(priv, "iwprivsapstop AP Config failed : %d\n", -r); - } else if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP || - interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO) { - unifi_trace(priv, UDBG1, "iwprivsapconfig: Starting the AP"); - r = sme_ap_start(priv, interfacePriv->InterfaceTag, &priv->ap_config); - if(r) { - unifi_error(priv, "iwprivsapstart AP START failed : %d\n", -r); - } - } - kfree(cfg_str); - return r; -} - -static int -iwprivsapstop(struct net_device *dev, struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev); - unifi_priv_t *priv = interfacePriv->privPtr; - int r; - u16 interface_tag = interfacePriv->InterfaceTag; - - unifi_trace(priv, UDBG1, "iwprivsapstop\n" ); - r = sme_ap_stop(priv, interface_tag); - if(r) { - unifi_error(priv, "iwprivsapstop AP STOP failed : %d\n", -r); - } - return r; -} - -#ifdef ANDROID_BUILD -static int -iwprivsapfwreload(struct net_device *dev, struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev); - unifi_priv_t *priv = interfacePriv->privPtr; - - unifi_trace(priv, UDBG1, "iwprivsapfwreload\n" ); - return 0; -} - -static int -iwprivsstackstart(struct net_device *dev, struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev); - unifi_priv_t *priv = interfacePriv->privPtr; - unifi_trace(priv, UDBG1, "iwprivsstackstart\n" ); - return 0; -} - -static int -iwprivsstackstop(struct net_device *dev, struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev); - unifi_priv_t *priv = interfacePriv->privPtr; - int r = 0; - u16 interface_tag = interfacePriv->InterfaceTag; - - unifi_trace(priv, UDBG1, "iwprivsstackstop\n" ); - - switch(interfacePriv->interfaceMode) { - case CSR_WIFI_ROUTER_CTRL_MODE_STA: - case CSR_WIFI_ROUTER_CTRL_MODE_P2PCLI: - case CSR_WIFI_ROUTER_CTRL_MODE_IBSS: - r = sme_mgt_disconnect(priv); - break; - case CSR_WIFI_ROUTER_CTRL_MODE_AP: - case CSR_WIFI_ROUTER_CTRL_MODE_P2PGO: - r = sme_ap_stop(priv, interface_tag); - break; - default : - break; - } - - if(r) { - unifi_error(priv, "iwprivsstackstop Stack stop failed : %d\n", -r); - } - return 0; -} -#endif /* ANDROID_BUILD */ -#endif /* CSR_SUPPORT_WEXT_AP */ - -#ifdef CSR_WIFI_SECURITY_WAPI_ENABLE -static int -iwprivsconfwapi(struct net_device *dev, struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - u8 enable; - netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev); - unifi_priv_t *priv = interfacePriv->privPtr; - - unifi_trace(priv, UDBG1, "iwprivsconfwapi\n" ); - - if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP || - interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO) { - unifi_error(priv, "iwprivsconfwapi: not permitted in Mode %d\n", - interfacePriv->interfaceMode); - return -EPERM; - } - - enable = *(u8*)(extra); - - if (enable) { - priv->connection_config.authModeMask = CSR_WIFI_SME_AUTH_MODE_80211_OPEN; - priv->connection_config.authModeMask |= (CSR_WIFI_SME_AUTH_MODE_WAPI_WAIPSK | CSR_WIFI_SME_AUTH_MODE_WAPI_WAI); - priv->connection_config.encryptionModeMask |= - CSR_WIFI_SME_ENCRYPTION_CIPHER_PAIRWISE_SMS4 | CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_SMS4; - } else { - priv->connection_config.authModeMask &= ~(CSR_WIFI_SME_AUTH_MODE_WAPI_WAIPSK | CSR_WIFI_SME_AUTH_MODE_WAPI_WAI); - priv->connection_config.encryptionModeMask &= - ~(CSR_WIFI_SME_ENCRYPTION_CIPHER_PAIRWISE_SMS4 | CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_SMS4); - } - - return 0; -} - -static int -iwprivswpikey(struct net_device *dev, struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - int r = 0, i; - CsrWifiSmeKey key; - unifiio_wapi_key_t inKey; - netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev); - unifi_priv_t *priv = interfacePriv->privPtr; - - unifi_trace(priv, UDBG1, "iwprivswpikey\n" ); - - if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP || - interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO) { - unifi_error(priv, "iwprivswpikey: not permitted in Mode %d\n", - interfacePriv->interfaceMode); - return -EPERM; - } - - inKey = *(unifiio_wapi_key_t*)(extra); - - if (inKey.unicastKey) { - key.keyType = CSR_WIFI_SME_KEY_TYPE_PAIRWISE; - } else { - key.keyType = CSR_WIFI_SME_KEY_TYPE_GROUP; - } - - key.keyIndex = inKey.keyIndex; - - /* memcpy(key.keyRsc, inKey.keyRsc, 16); */ - for (i = 0; i < 16; i+= 2) - { - key.keyRsc[i/2] = inKey.keyRsc[i+1] << 8 | inKey.keyRsc[i]; - } - - memcpy(key.address.a, inKey.address, 6); - key.keyLength = 32; - memcpy(key.key, inKey.key, 32); - key.authenticator = 0; - key.wepTxKey = 0; - - unifi_trace(priv, UDBG1, "keyType = %d, keyIndex = %d, wepTxKey = %d, keyRsc = %x:%x, auth = %d, address = %x:%x, " - "keylength = %d, key = %x:%x\n", key.keyType, key.keyIndex, key.wepTxKey, - key.keyRsc[0], key.keyRsc[7], key.authenticator, - key.address.a[0], key.address.a[5], key.keyLength, key.key[0], - key.key[15]); - - r = sme_mgt_key(priv, &key, CSR_WIFI_SME_LIST_ACTION_ADD); - if (r) { - unifi_error(priv, "SETKEYS request was rejected with result %d\n", r); - return convert_sme_error(r); - } - - return r; -} -#endif - - -static int -unifi_giwname(struct net_device *dev, struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev); - unifi_priv_t *priv = interfacePriv->privPtr; - char *name = wrqu->name; - unifi_trace(priv, UDBG2, "unifi_giwname\n"); - - if (priv->if_index == CSR_INDEX_5G) { - strcpy(name, "IEEE 802.11-a"); - } else { - strcpy(name, "IEEE 802.11-bgn"); - } - return 0; -} /* unifi_giwname() */ - - -static int -unifi_siwfreq(struct net_device *dev, struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev); - unifi_priv_t *priv = interfacePriv->privPtr; - struct iw_freq *freq = (struct iw_freq *)wrqu; - - unifi_trace(priv, UDBG2, "unifi_siwfreq\n"); - - if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP || - interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO) { - unifi_error(priv, "unifi_siwfreq: not permitted in Mode %d\n", - interfacePriv->interfaceMode); - return -EPERM; - } - - - /* - * Channel is stored in the connection configuration, - * and set later when ask for a connection. - */ - if ((freq->e == 0) && (freq->m <= 1000)) { - priv->connection_config.adhocChannel = freq->m; - } else { - priv->connection_config.adhocChannel = wext_freq_to_channel(freq->m, freq->e); - } - - return 0; -} /* unifi_siwfreq() */ - - -static int -unifi_giwfreq(struct net_device *dev, struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev); - unifi_priv_t *priv = interfacePriv->privPtr; - struct iw_freq *freq = (struct iw_freq *)wrqu; - int err = 0; - CsrWifiSmeConnectionInfo connectionInfo; - - unifi_trace(priv, UDBG2, "unifi_giwfreq\n"); - CHECK_INITED(priv); - - if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP || - interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO) { - unifi_error(priv, "unifi_giwfreq: not permitted in Mode %d\n", - interfacePriv->interfaceMode); - return -EPERM; - } - - - UF_RTNL_UNLOCK(); - err = sme_mgt_connection_info_get(priv, &connectionInfo); - UF_RTNL_LOCK(); - - freq->m = channel_to_mhz(connectionInfo.channelNumber, - (connectionInfo.networkType80211 == CSR_WIFI_SME_RADIO_IF_GHZ_5_0)); - freq->e = 6; - - return convert_sme_error(err); -} /* unifi_giwfreq() */ - - -static int -unifi_siwmode(struct net_device *dev, struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev); - unifi_priv_t *priv = interfacePriv->privPtr; - - unifi_trace(priv, UDBG2, "unifi_siwmode\n"); - - if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP || - interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO) { - unifi_error(priv, "unifi_siwmode: not permitted in Mode %d\n", - interfacePriv->interfaceMode); - return -EPERM; - } - - - switch(wrqu->mode) { - case IW_MODE_ADHOC: - priv->connection_config.bssType = CSR_WIFI_SME_BSS_TYPE_ADHOC; - break; - case IW_MODE_INFRA: - priv->connection_config.bssType = CSR_WIFI_SME_BSS_TYPE_INFRASTRUCTURE; - break; - case IW_MODE_AUTO: - priv->connection_config.bssType = CSR_WIFI_SME_BSS_TYPE_ANY_BSS; - break; - default: - unifi_notice(priv, "Unknown IW MODE value.\n"); - } - - /* Clear the SSID and BSSID configuration */ - priv->connection_config.ssid.length = 0; - memset(priv->connection_config.bssid.a, 0xFF, ETH_ALEN); - - return 0; -} /* unifi_siwmode() */ - - - -static int -unifi_giwmode(struct net_device *dev, struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - int r = 0; - netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev); - unifi_priv_t *priv = interfacePriv->privPtr; - CsrWifiSmeConnectionConfig connectionConfig; - - unifi_trace(priv, UDBG2, "unifi_giwmode\n"); - CHECK_INITED(priv); - - unifi_trace(priv, UDBG2, "unifi_giwmode: Exisitng mode = 0x%x\n", - interfacePriv->interfaceMode); - switch(interfacePriv->interfaceMode) { - case CSR_WIFI_ROUTER_CTRL_MODE_STA: - case CSR_WIFI_ROUTER_CTRL_MODE_P2PCLI: - wrqu->mode = IW_MODE_INFRA; - break; - case CSR_WIFI_ROUTER_CTRL_MODE_AP: - case CSR_WIFI_ROUTER_CTRL_MODE_P2PGO: - wrqu->mode = IW_MODE_MASTER; - break; - case CSR_WIFI_ROUTER_CTRL_MODE_IBSS: - wrqu->mode = IW_MODE_ADHOC; - break; - case CSR_WIFI_ROUTER_CTRL_MODE_P2P: - case CSR_WIFI_ROUTER_CTRL_MODE_NONE: - UF_RTNL_UNLOCK(); - r = sme_mgt_connection_config_get(priv, &connectionConfig); - UF_RTNL_LOCK(); - if (r == 0) { - switch(connectionConfig.bssType) { - case CSR_WIFI_SME_BSS_TYPE_ADHOC: - wrqu->mode = IW_MODE_ADHOC; - break; - case CSR_WIFI_SME_BSS_TYPE_INFRASTRUCTURE: - wrqu->mode = IW_MODE_INFRA; - break; - default: - wrqu->mode = IW_MODE_AUTO; - unifi_notice(priv, "Unknown IW MODE value.\n"); - } - } - break; - default: - wrqu->mode = IW_MODE_AUTO; - unifi_notice(priv, "Unknown IW MODE value.\n"); - - } - unifi_trace(priv, UDBG4, "unifi_giwmode: mode = 0x%x\n", wrqu->mode); - return r; -} /* unifi_giwmode() */ - - - -static int -unifi_giwrange(struct net_device *dev, struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - struct iw_point *dwrq = &wrqu->data; - struct iw_range *range = (struct iw_range *) extra; - int i; - - unifi_trace(NULL, UDBG2, "unifi_giwrange\n"); - - dwrq->length = sizeof(struct iw_range); - memset(range, 0, sizeof(*range)); - range->min_nwid = 0x0000; - range->max_nwid = 0x0000; - - /* - * Don't report the frequency/channel table, then the channel - * number returned elsewhere will be printed as a channel number. - */ - - /* Ranges of values reported in quality structs */ - range->max_qual.qual = 40; /* Max expected qual value */ - range->max_qual.level = -120; /* Noise floor in dBm */ - range->max_qual.noise = -120; /* Noise floor in dBm */ - - - /* space for IW_MAX_BITRATES (8 up to WE15, 32 later) */ - i = 0; -#if WIRELESS_EXT > 15 - range->bitrate[i++] = 2 * 500000; - range->bitrate[i++] = 4 * 500000; - range->bitrate[i++] = 11 * 500000; - range->bitrate[i++] = 22 * 500000; - range->bitrate[i++] = 12 * 500000; - range->bitrate[i++] = 18 * 500000; - range->bitrate[i++] = 24 * 500000; - range->bitrate[i++] = 36 * 500000; - range->bitrate[i++] = 48 * 500000; - range->bitrate[i++] = 72 * 500000; - range->bitrate[i++] = 96 * 500000; - range->bitrate[i++] = 108 * 500000; -#else - range->bitrate[i++] = 2 * 500000; - range->bitrate[i++] = 4 * 500000; - range->bitrate[i++] = 11 * 500000; - range->bitrate[i++] = 22 * 500000; - range->bitrate[i++] = 24 * 500000; - range->bitrate[i++] = 48 * 500000; - range->bitrate[i++] = 96 * 500000; - range->bitrate[i++] = 108 * 500000; -#endif /* WIRELESS_EXT < 16 */ - range->num_bitrates = i; - - range->max_encoding_tokens = NUM_WEPKEYS; - range->num_encoding_sizes = 2; - range->encoding_size[0] = 5; - range->encoding_size[1] = 13; - - range->we_version_source = 20; - range->we_version_compiled = WIRELESS_EXT; - - /* Number of channels available in h/w */ - range->num_channels = 14; - /* Number of entries in freq[] array */ - range->num_frequency = 14; - for (i = 0; (i < range->num_frequency) && (i < IW_MAX_FREQUENCIES); i++) { - int chan = i + 1; - range->freq[i].i = chan; - range->freq[i].m = channel_to_mhz(chan, 0); - range->freq[i].e = 6; - } - if ((i+3) < IW_MAX_FREQUENCIES) { - range->freq[i].i = 36; - range->freq[i].m = channel_to_mhz(36, 1); - range->freq[i].e = 6; - range->freq[i+1].i = 40; - range->freq[i+1].m = channel_to_mhz(40, 1); - range->freq[i+1].e = 6; - range->freq[i+2].i = 44; - range->freq[i+2].m = channel_to_mhz(44, 1); - range->freq[i+2].e = 6; - range->freq[i+3].i = 48; - range->freq[i+3].m = channel_to_mhz(48, 1); - range->freq[i+3].e = 6; - } - -#if WIRELESS_EXT > 16 - /* Event capability (kernel + driver) */ - range->event_capa[0] = (IW_EVENT_CAPA_K_0 | - IW_EVENT_CAPA_MASK(SIOCGIWTHRSPY) | - IW_EVENT_CAPA_MASK(SIOCGIWAP) | - IW_EVENT_CAPA_MASK(SIOCGIWSCAN)); - range->event_capa[1] = IW_EVENT_CAPA_K_1; - range->event_capa[4] = (IW_EVENT_CAPA_MASK(IWEVTXDROP) | - IW_EVENT_CAPA_MASK(IWEVCUSTOM) | - IW_EVENT_CAPA_MASK(IWEVREGISTERED) | - IW_EVENT_CAPA_MASK(IWEVEXPIRED)); -#endif /* WIRELESS_EXT > 16 */ - -#if WIRELESS_EXT > 17 - range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 | - IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP; -#endif /* WIRELESS_EXT > 17 */ - - - return 0; -} /* unifi_giwrange() */ - - -static int -unifi_siwap(struct net_device *dev, struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev); - unifi_priv_t *priv = interfacePriv->privPtr; - int err = 0; - - CHECK_INITED(priv); - - if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP || - interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO) { - unifi_error(priv, "unifi_siwap: not permitted in Mode %d\n", - interfacePriv->interfaceMode); - return -EPERM; - } - - - if (wrqu->ap_addr.sa_family != ARPHRD_ETHER) { - return -EINVAL; - } - - unifi_trace(priv, UDBG1, "unifi_siwap: asked for %pM\n", - wrqu->ap_addr.sa_data); - - if (is_zero_ether_addr(wrqu->ap_addr.sa_data)) { - priv->ignore_bssid_join = FALSE; - err = sme_mgt_disconnect(priv); - if (err) { - unifi_trace(priv, UDBG4, "unifi_siwap: Disconnect failed, status %d\n", err); - } - return 0; - } - - if (priv->ignore_bssid_join) { - unifi_trace(priv, UDBG4, "unifi_siwap: ignoring second join\n"); - priv->ignore_bssid_join = FALSE; - } else { - memcpy(priv->connection_config.bssid.a, wrqu->ap_addr.sa_data, ETH_ALEN); - unifi_trace(priv, UDBG1, "unifi_siwap: Joining %X:%X:%X:%X:%X:%X\n", - priv->connection_config.bssid.a[0], - priv->connection_config.bssid.a[1], - priv->connection_config.bssid.a[2], - priv->connection_config.bssid.a[3], - priv->connection_config.bssid.a[4], - priv->connection_config.bssid.a[5]); - err = sme_mgt_connect(priv); - if (err) { - unifi_error(priv, "unifi_siwap: Join failed, status %d\n", err); - return convert_sme_error(err); - } - } - - return 0; -} /* unifi_siwap() */ - - -static int -unifi_giwap(struct net_device *dev, struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev); - unifi_priv_t *priv = interfacePriv->privPtr; - CsrWifiSmeConnectionInfo connectionInfo; - int r = 0; - u8 *bssid; - - CHECK_INITED(priv); - unifi_trace(priv, UDBG2, "unifi_giwap\n"); - - if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP || - interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO) { - unifi_error(priv, "iwprivswpikey: not permitted in Mode %d\n", - interfacePriv->interfaceMode); - return -EPERM; - } - - UF_RTNL_UNLOCK(); - r = sme_mgt_connection_info_get(priv, &connectionInfo); - UF_RTNL_LOCK(); - - if (r == 0) { - bssid = connectionInfo.bssid.a; - wrqu->ap_addr.sa_family = ARPHRD_ETHER; - unifi_trace(priv, UDBG4, "unifi_giwap: BSSID = %pM\n", bssid); - - memcpy(wrqu->ap_addr.sa_data, bssid, ETH_ALEN); - } else { - memset(wrqu->ap_addr.sa_data, 0, ETH_ALEN); - } - - return 0; -} /* unifi_giwap() */ - - -static int -unifi_siwscan(struct net_device *dev, struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev); - unifi_priv_t *priv = interfacePriv->privPtr; - int r; - CsrWifiSsid scan_ssid; - unsigned char *channel_list = NULL; - int chans_good = 0; -#if WIRELESS_EXT > 17 - struct iw_point *data = &wrqu->data; - struct iw_scan_req *req = (struct iw_scan_req *) extra; -#endif - - CHECK_INITED(priv); - - if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP || - interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO) { - unifi_error(priv, "unifi_siwscan: not permitted in Mode %d\n", - interfacePriv->interfaceMode); - return -EPERM; - } - - -#if WIRELESS_EXT > 17 - /* Providing a valid channel list will force an active scan */ - if (req) { - if ((req->num_channels > 0) && (req->num_channels < IW_MAX_FREQUENCIES)) { - channel_list = kmalloc(req->num_channels, GFP_KERNEL); - if (channel_list) { - int i; - for (i = 0; i < req->num_channels; i++) { - /* Convert frequency to channel number */ - int ch = wext_freq_to_channel(req->channel_list[i].m, - req->channel_list[i].e); - if (ch) { - channel_list[chans_good++] = ch; - } - } - unifi_trace(priv, UDBG1, - "SIWSCAN: Scanning %d channels\n", chans_good); - } else { - /* Fall back to scanning all */ - unifi_error(priv, "SIWSCAN: Can't alloc channel_list (%d)\n", - req->num_channels); - } - } - } - - if (req && (data->flags & IW_SCAN_THIS_ESSID)) { - memcpy(scan_ssid.ssid, req->essid, req->essid_len); - scan_ssid.length = req->essid_len; - unifi_trace(priv, UDBG1, - "SIWSCAN: Scanning for %.*s\n", - scan_ssid.length, scan_ssid.ssid); - } else -#endif - { - unifi_trace(priv, UDBG1, "SIWSCAN: Scanning for all APs\n"); - scan_ssid.length = 0; - } - - r = sme_mgt_scan_full(priv, &scan_ssid, chans_good, channel_list); - if (r) { - unifi_error(priv, "SIWSCAN: Scan returned error %d\n", r); - } else { - unifi_trace(priv, UDBG1, "SIWSCAN: Scan done\n"); - wext_send_scan_results_event(priv); - } - - if (channel_list) { - kfree(channel_list); - } - - return r; - -} /* unifi_siwscan() */ - - -static const unsigned char * -unifi_find_info_element(int id, const unsigned char *info, int len) -{ - const unsigned char *ie = info; - - while (len > 1) - { - int e_id, e_len; - e_id = ie[0]; - e_len = ie[1]; - - /* Return if we find a match */ - if (e_id == id) - { - return ie; - } - - len -= (e_len + 2); - ie += (e_len + 2); - } - - return NULL; -} /* unifi_find_info_element() */ - - -/* - * Translate scan data returned from the card to a card independent - * format that the Wireless Tools will understand - Jean II - */ -int -unifi_translate_scan(struct net_device *dev, - struct iw_request_info *info, - char *current_ev, char *end_buf, - CsrWifiSmeScanResult *scan_data, - int scan_index) -{ - struct iw_event iwe; /* Temporary buffer */ - unsigned char *info_elems; - int info_elem_len; - const unsigned char *elem; - u16 capabilities; - int signal, noise, snr; - char *start_buf = current_ev; - char *current_val; /* For rates */ - int i, r; - - info_elems = scan_data->informationElements; - info_elem_len = scan_data->informationElementsLength; - - if (!scan_data->informationElementsLength || !scan_data->informationElements) { - unifi_error(NULL, "*** NULL SCAN IEs ***\n"); - return -EIO; - } - - /* get capinfo bits */ - capabilities = scan_data->capabilityInformation; - - unifi_trace(NULL, UDBG5, "Capabilities: 0x%x\n", capabilities); - - /* First entry *MUST* be the AP MAC address */ - memset(&iwe, 0, sizeof(iwe)); - iwe.cmd = SIOCGIWAP; - iwe.u.ap_addr.sa_family = ARPHRD_ETHER; - memcpy(iwe.u.ap_addr.sa_data, scan_data->bssid.a, ETH_ALEN); - iwe.len = IW_EV_ADDR_LEN; - r = uf_iwe_stream_add_event(info, start_buf, end_buf, &iwe, IW_EV_ADDR_LEN); - if (r < 0) { - return r; - } - start_buf += r; - - /* Other entries will be displayed in the order we give them */ - - /* Add the ESSID */ - /* find SSID in Info Elems */ - elem = unifi_find_info_element(IE_SSID_ID, info_elems, info_elem_len); - if (elem) { - int e_len = elem[1]; - const unsigned char *e_ptr = elem + 2; - unsigned char buf[33]; - - memset(&iwe, 0, sizeof(iwe)); - iwe.cmd = SIOCGIWESSID; - iwe.u.essid.length = e_len; - if (iwe.u.essid.length > 32) { - iwe.u.essid.length = 32; - } - iwe.u.essid.flags = scan_index; - memcpy(buf, e_ptr, iwe.u.essid.length); - buf[iwe.u.essid.length] = '\0'; - r = uf_iwe_stream_add_point(info, start_buf, end_buf, &iwe, buf); - if (r < 0) { - return r; - } - start_buf += r; - - } - - /* Add mode */ - memset(&iwe, 0, sizeof(iwe)); - iwe.cmd = SIOCGIWMODE; - if (scan_data->bssType == CSR_WIFI_SME_BSS_TYPE_INFRASTRUCTURE) { - iwe.u.mode = IW_MODE_INFRA; - } else { - iwe.u.mode = IW_MODE_ADHOC; - } - iwe.len = IW_EV_UINT_LEN; - r = uf_iwe_stream_add_event(info, start_buf, end_buf, &iwe, IW_EV_UINT_LEN); - if (r < 0) { - return r; - } - start_buf += r; - - /* Add frequency. iwlist will convert to channel using table given in giwrange */ - memset(&iwe, 0, sizeof(iwe)); - iwe.cmd = SIOCGIWFREQ; - iwe.u.freq.m = scan_data->channelFrequency; - iwe.u.freq.e = 6; - r = uf_iwe_stream_add_event(info, start_buf, end_buf, &iwe, IW_EV_FREQ_LEN); - if (r < 0) { - return r; - } - start_buf += r; - - - /* Add quality statistics */ - iwe.cmd = IWEVQUAL; - /* - * level and noise below are mapped into an unsigned 8 bit number, - * ranging from [-192; 63]. The way this is achieved is simply to - * add 0x100 onto the number if it is negative, - * once clipped to the correct range. - */ - signal = scan_data->rssi; /* This value is in dBm */ - /* Clip range of snr */ - snr = (scan_data->snr > 0) ? scan_data->snr : 0; /* In dB relative, from 0 - 255 */ - snr = (snr < 255) ? snr : 255; - noise = signal - snr; - - /* Clip range of signal */ - signal = (signal < 63) ? signal : 63; - signal = (signal > -192) ? signal : -192; - - /* Clip range of noise */ - noise = (noise < 63) ? noise : 63; - noise = (noise > -192) ? noise : -192; - - /* Make u8 */ - signal = ( signal < 0 ) ? signal + 0x100 : signal; - noise = ( noise < 0 ) ? noise + 0x100 : noise; - - iwe.u.qual.level = (u8)signal; /* -192 : 63 */ - iwe.u.qual.noise = (u8)noise; /* -192 : 63 */ - iwe.u.qual.qual = snr; /* 0 : 255 */ - iwe.u.qual.updated = 0; -#if WIRELESS_EXT > 16 - iwe.u.qual.updated |= IW_QUAL_LEVEL_UPDATED | IW_QUAL_NOISE_UPDATED | - IW_QUAL_QUAL_UPDATED; -#if WIRELESS_EXT > 18 - iwe.u.qual.updated |= IW_QUAL_DBM; -#endif -#endif - r = uf_iwe_stream_add_event(info, start_buf, end_buf, &iwe, IW_EV_QUAL_LEN); - if (r < 0) { - return r; - } - start_buf += r; - - /* Add encryption capability */ - iwe.cmd = SIOCGIWENCODE; - if (capabilities & SIG_CAP_PRIVACY) { - iwe.u.data.flags = IW_ENCODE_ENABLED | IW_ENCODE_NOKEY; - } else { - iwe.u.data.flags = IW_ENCODE_DISABLED; - } - iwe.u.data.length = 0; - iwe.len = IW_EV_POINT_LEN + iwe.u.data.length; - r = uf_iwe_stream_add_point(info, start_buf, end_buf, &iwe, ""); - if (r < 0) { - return r; - } - start_buf += r; - - - /* - * Rate : stuffing multiple values in a single event require a bit - * more of magic - Jean II - */ - current_val = start_buf + IW_EV_LCP_LEN; - - iwe.cmd = SIOCGIWRATE; - /* Those two flags are ignored... */ - iwe.u.bitrate.fixed = iwe.u.bitrate.disabled = 0; - - elem = unifi_find_info_element(IE_SUPPORTED_RATES_ID, - info_elems, info_elem_len); - if (elem) { - int e_len = elem[1]; - const unsigned char *e_ptr = elem + 2; - - /* - * Count how many rates we have. - * Zero marks the end of the list, if the list is not truncated. - */ - /* Max 8 values */ - for (i = 0; i < e_len; i++) { - if (e_ptr[i] == 0) { - break; - } - /* Bit rate given in 500 kb/s units (+ 0x80) */ - iwe.u.bitrate.value = ((e_ptr[i] & 0x7f) * 500000); - /* Add new value to event */ - r = uf_iwe_stream_add_value(info, start_buf, current_val, end_buf, &iwe, IW_EV_PARAM_LEN); - if (r < 0) { - return r; - } - current_val +=r; - - } - } - elem = unifi_find_info_element(IE_EXTENDED_SUPPORTED_RATES_ID, - info_elems, info_elem_len); - if (elem) { - int e_len = elem[1]; - const unsigned char *e_ptr = elem + 2; - - /* - * Count how many rates we have. - * Zero marks the end of the list, if the list is not truncated. - */ - /* Max 8 values */ - for (i = 0; i < e_len; i++) { - if (e_ptr[i] == 0) { - break; - } - /* Bit rate given in 500 kb/s units (+ 0x80) */ - iwe.u.bitrate.value = ((e_ptr[i] & 0x7f) * 500000); - /* Add new value to event */ - r = uf_iwe_stream_add_value(info, start_buf, current_val, end_buf, &iwe, IW_EV_PARAM_LEN); - if (r < 0) { - return r; - } - current_val +=r; - } - } - /* Check if we added any rates event */ - if ((current_val - start_buf) > IW_EV_LCP_LEN) { - start_buf = current_val; - } - - -#if WIRELESS_EXT > 17 - memset(&iwe, 0, sizeof(iwe)); - iwe.cmd = IWEVGENIE; - iwe.u.data.length = info_elem_len; - - r = uf_iwe_stream_add_point(info, start_buf, end_buf, &iwe, info_elems); - if (r < 0) { - return r; - } - - start_buf += r; -#endif /* WE > 17 */ - - return (start_buf - current_ev); -} /* unifi_translate_scan() */ - - - -static int -unifi_giwscan(struct net_device *dev, struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev); - unifi_priv_t *priv = interfacePriv->privPtr; - struct iw_point *dwrq = &wrqu->data; - int r; - - CHECK_INITED(priv); - - if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP || - interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO) { - unifi_error(priv, "unifi_giwscan: not permitted in Mode %d\n", - interfacePriv->interfaceMode); - return -EPERM; - } - - - unifi_trace(priv, UDBG1, - "unifi_giwscan: buffer (%d bytes) \n", - dwrq->length); - UF_RTNL_UNLOCK(); - r = sme_mgt_scan_results_get_async(priv, info, extra, dwrq->length); - UF_RTNL_LOCK(); - if (r < 0) { - unifi_trace(priv, UDBG1, - "unifi_giwscan: buffer (%d bytes) not big enough.\n", - dwrq->length); - return r; - } - - dwrq->length = r; - dwrq->flags = 0; - - return 0; -} /* unifi_giwscan() */ - - -/* - * --------------------------------------------------------------------------- - * unifi_siwessid - * - * Request to join a network or start and AdHoc. - * - * Arguments: - * dev Pointer to network device struct. - * info Pointer to broken-out ioctl request. - * data Pointer to argument data. - * essid Pointer to string giving name of network to join - * or start - * - * Returns: - * 0 on success and everything complete - * -EINPROGRESS to have the higher level call the commit method. - * --------------------------------------------------------------------------- - */ -static int -unifi_siwessid(struct net_device *dev, struct iw_request_info *info, - struct iw_point *data, char *essid) -{ - netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev); - unifi_priv_t *priv = interfacePriv->privPtr; - int len; - int err = 0; - - CHECK_INITED(priv); - - if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP || - interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO) { - unifi_error(priv, "unifi_siwessid: not permitted in Mode %d\n", - interfacePriv->interfaceMode); - return -EPERM; - } - - - len = 0; - if (data->flags & 1) { - /* Limit length */ - len = data->length; - if (len > UNIFI_MAX_SSID_LEN) { - len = UNIFI_MAX_SSID_LEN; - } - } - -#ifdef UNIFI_DEBUG - { - char essid_str[UNIFI_MAX_SSID_LEN+1]; - int i; - - for (i = 0; i < len; i++) { - essid_str[i] = (isprint(essid[i]) ? essid[i] : '?'); - } - essid_str[i] = '\0'; - - unifi_trace(priv, UDBG1, "unifi_siwessid: asked for '%*s' (%d)\n", len, essid_str, len); - unifi_trace(priv, UDBG2, " with authModeMask = %d", priv->connection_config.authModeMask); - } -#endif - - memset(priv->connection_config.bssid.a, 0xFF, ETH_ALEN); - if (len) { - if (essid[len - 1] == 0) { - len --; - } - - memcpy(priv->connection_config.ssid.ssid, essid, len); - priv->connection_config.ssid.length = len; - - } else { - priv->connection_config.ssid.length = 0; - } - - UF_RTNL_UNLOCK(); - err = sme_mgt_connect(priv); - UF_RTNL_LOCK(); - if (err) { - unifi_error(priv, "unifi_siwessid: Join failed, status %d\n", err); - return convert_sme_error(err); - } - - return 0; -} /* unifi_siwessid() */ - - -static int -unifi_giwessid(struct net_device *dev, struct iw_request_info *info, - union iwreq_data *wrqu, char *essid) -{ - netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev); - unifi_priv_t *priv = interfacePriv->privPtr; - struct iw_point *data = &wrqu->essid; - CsrWifiSmeConnectionInfo connectionInfo; - int r = 0; - - unifi_trace(priv, UDBG2, "unifi_giwessid\n"); - CHECK_INITED(priv); - - if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP || - interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO) { - unifi_error(priv, "unifi_giwessid: not permitted in Mode %d\n", - interfacePriv->interfaceMode); - return -EPERM; - } - - UF_RTNL_UNLOCK(); - r = sme_mgt_connection_info_get(priv, &connectionInfo); - UF_RTNL_LOCK(); - - if (r == 0) { - data->length = connectionInfo.ssid.length; - strncpy(essid, - connectionInfo.ssid.ssid, - data->length); - data->flags = 1; /* active */ - - unifi_trace(priv, UDBG2, "unifi_giwessid: %.*s\n", - data->length, essid); - } - - - return 0; -} /* unifi_giwessid() */ - - -static int -unifi_siwrate(struct net_device *dev, struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev); - unifi_priv_t *priv = interfacePriv->privPtr; - struct iw_param *args = &wrqu->bitrate; - CsrWifiSmeMibConfig mibConfig; - int r; - - CHECK_INITED(priv); - unifi_trace(priv, UDBG2, "unifi_siwrate\n"); - - /* - * If args->fixed == 0, value is max rate or -1 for best - * If args->fixed == 1, value is rate to set or -1 for best - * args->disabled and args->flags are not used in SIOCSIWRATE - */ - - /* Get, modify and set the MIB data */ - UF_RTNL_UNLOCK(); - r = sme_mgt_mib_config_get(priv, &mibConfig); - UF_RTNL_LOCK(); - if (r) { - unifi_error(priv, "unifi_siwrate: Get CsrWifiSmeMibConfigValue failed.\n"); - return r; - } - - /* Default to auto rate algorithm */ - /* in 500Kbit/s, 0 means auto */ - mibConfig.unifiFixTxDataRate = 0; - - if (args->value != -1) { - mibConfig.unifiFixTxDataRate = args->value / 500000; - } - - /* 1 means rate is a maximum, 2 means rate is a set value */ - if (args->fixed == 1) { - mibConfig.unifiFixMaxTxDataRate = 0; - } else { - mibConfig.unifiFixMaxTxDataRate = 1; - } - UF_RTNL_UNLOCK(); - r = sme_mgt_mib_config_set(priv, &mibConfig); - UF_RTNL_LOCK(); - if (r) { - unifi_error(priv, "unifi_siwrate: Set CsrWifiSmeMibConfigValue failed.\n"); - return r; - } - - - return 0; -} /* unifi_siwrate() */ - - - -static int -unifi_giwrate(struct net_device *dev, struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev); - unifi_priv_t *priv = interfacePriv->privPtr; - struct iw_param *args = &wrqu->bitrate; - int r; - int bitrate, flag; - CsrWifiSmeMibConfig mibConfig; - CsrWifiSmeConnectionStats connectionStats; - - unifi_trace(priv, UDBG2, "unifi_giwrate\n"); - CHECK_INITED(priv); - - flag = 0; - bitrate = 0; - UF_RTNL_UNLOCK(); - r = sme_mgt_mib_config_get(priv, &mibConfig); - UF_RTNL_LOCK(); - if (r) { - unifi_error(priv, "unifi_giwrate: Get CsrWifiSmeMibConfigValue failed.\n"); - return r; - } - - bitrate = mibConfig.unifiFixTxDataRate; - flag = mibConfig.unifiFixMaxTxDataRate; - - /* Used the value returned by the SME if MIB returns 0 */ - if (bitrate == 0) { - UF_RTNL_UNLOCK(); - r = sme_mgt_connection_stats_get(priv, &connectionStats); - UF_RTNL_LOCK(); - /* Ignore errors, we may be disconnected */ - if (r == 0) { - bitrate = connectionStats.unifiTxDataRate; - } - } - - args->value = bitrate * 500000; - args->fixed = !flag; - - return 0; -} /* unifi_giwrate() */ - - -static int -unifi_siwrts(struct net_device *dev, struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev); - unifi_priv_t *priv = interfacePriv->privPtr; - int val = wrqu->rts.value; - int r = 0; - CsrWifiSmeMibConfig mibConfig; - - unifi_trace(priv, UDBG2, "unifi_siwrts\n"); - CHECK_INITED(priv); - - if (wrqu->rts.disabled) { - val = 2347; - } - - if ( (val < 0) || (val > 2347) ) - { - return -EINVAL; - } - - /* Get, modify and set the MIB data */ - UF_RTNL_UNLOCK(); - r = sme_mgt_mib_config_get(priv, &mibConfig); - UF_RTNL_LOCK(); - if (r) { - unifi_error(priv, "unifi_siwrts: Get CsrWifiSmeMibConfigValue failed.\n"); - return r; - } - mibConfig.dot11RtsThreshold = val; - UF_RTNL_UNLOCK(); - r = sme_mgt_mib_config_set(priv, &mibConfig); - UF_RTNL_LOCK(); - if (r) { - unifi_error(priv, "unifi_siwrts: Set CsrWifiSmeMibConfigValue failed.\n"); - return r; - } - - return 0; -} - - -static int -unifi_giwrts(struct net_device *dev, struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev); - unifi_priv_t *priv = interfacePriv->privPtr; - int r; - int rts_thresh; - CsrWifiSmeMibConfig mibConfig; - - unifi_trace(priv, UDBG2, "unifi_giwrts\n"); - CHECK_INITED(priv); - - UF_RTNL_UNLOCK(); - r = sme_mgt_mib_config_get(priv, &mibConfig); - UF_RTNL_LOCK(); - if (r) { - unifi_error(priv, "unifi_giwrts: Get CsrWifiSmeMibConfigValue failed.\n"); - return r; - } - - rts_thresh = mibConfig.dot11RtsThreshold; - if (rts_thresh > 2347) { - rts_thresh = 2347; - } - - wrqu->rts.value = rts_thresh; - wrqu->rts.disabled = (rts_thresh == 2347); - wrqu->rts.fixed = 1; - - return 0; -} - - -static int -unifi_siwfrag(struct net_device *dev, struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev); - unifi_priv_t *priv = interfacePriv->privPtr; - int val = wrqu->frag.value; - int r = 0; - CsrWifiSmeMibConfig mibConfig; - - unifi_trace(priv, UDBG2, "unifi_siwfrag\n"); - CHECK_INITED(priv); - - if (wrqu->frag.disabled) - val = 2346; - - if ( (val < 256) || (val > 2347) ) - return -EINVAL; - - /* Get, modify and set the MIB data */ - UF_RTNL_UNLOCK(); - r = sme_mgt_mib_config_get(priv, &mibConfig); - UF_RTNL_LOCK(); - if (r) { - unifi_error(priv, "unifi_siwfrag: Get CsrWifiSmeMibConfigValue failed.\n"); - return r; - } - /* Fragmentation Threashold must be even */ - mibConfig.dot11FragmentationThreshold = (val & ~0x1); - UF_RTNL_UNLOCK(); - r = sme_mgt_mib_config_set(priv, &mibConfig); - UF_RTNL_LOCK(); - if (r) { - unifi_error(priv, "unifi_siwfrag: Set CsrWifiSmeMibConfigValue failed.\n"); - return r; - } - - return 0; -} - - -static int -unifi_giwfrag(struct net_device *dev, struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev); - unifi_priv_t *priv = interfacePriv->privPtr; - int r; - int frag_thresh; - CsrWifiSmeMibConfig mibConfig; - - unifi_trace(priv, UDBG2, "unifi_giwfrag\n"); - CHECK_INITED(priv); - - UF_RTNL_UNLOCK(); - r = sme_mgt_mib_config_get(priv, &mibConfig); - UF_RTNL_LOCK(); - if (r) { - unifi_error(priv, "unifi_giwfrag: Get CsrWifiSmeMibConfigValue failed.\n"); - return r; - } - - frag_thresh = mibConfig.dot11FragmentationThreshold; - - /* Build the return structure */ - wrqu->frag.value = frag_thresh; - wrqu->frag.disabled = (frag_thresh >= 2346); - wrqu->frag.fixed = 1; - - return 0; -} - - -static int -unifi_siwencode(struct net_device *dev, struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev); - unifi_priv_t *priv = interfacePriv->privPtr; - struct iw_point *erq = &wrqu->encoding; - int index; - int rc = 0; - int privacy = -1; - CsrWifiSmeKey sme_key; - - unifi_trace(priv, UDBG2, "unifi_siwencode\n"); - - CHECK_INITED(priv); - - if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP || - interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO) { - unifi_error(priv, "unifi_siwencode: not permitted in Mode %d\n", - interfacePriv->interfaceMode); - return -EPERM; - } - - - /* - * Key index is encoded in the flags. - * 0 - use current default, - * 1-4 - if a key value is given set that key - * if not use that key - */ - index = (erq->flags & IW_ENCODE_INDEX); /* key number, 1-4 */ - if ((index < 0) || (index > 4)) { - unifi_error(priv, "unifi_siwencode: Request to set an invalid key (index:%d)", index); - return -EINVAL; - } - - /* - * Basic checking: do we have a key to set ? - * The IW_ENCODE_NOKEY flag is set when no key is present (only change flags), - * but older versions rely on sending a key id 1-4. - */ - if (erq->length > 0) { - - /* Check the size of the key */ - if ((erq->length > LARGE_KEY_SIZE) || (erq->length < SMALL_KEY_SIZE)) { - unifi_error(priv, "unifi_siwencode: Request to set an invalid key (length:%d)", - erq->length); - return -EINVAL; - } - - /* Check the index (none (i.e. 0) means use current) */ - if ((index < 1) || (index > 4)) { - /* If we do not have a previous key, use 1 as default */ - if (!priv->wep_tx_key_index) { - priv->wep_tx_key_index = 1; - } - index = priv->wep_tx_key_index; - } - - /* If we didn't have a key and a valid index is set, we want to remember it*/ - if (!priv->wep_tx_key_index) { - priv->wep_tx_key_index = index; - } - - unifi_trace(priv, UDBG1, "Tx key Index is %d\n", priv->wep_tx_key_index); - - privacy = 1; - - /* Check if the key is not marked as invalid */ - if ((erq->flags & IW_ENCODE_NOKEY) == 0) { - - unifi_trace(priv, UDBG1, "New %s key (len=%d, index=%d)\n", - (priv->wep_tx_key_index == index) ? "tx" : "", - erq->length, index); - - sme_key.wepTxKey = (priv->wep_tx_key_index == index); - if (priv->wep_tx_key_index == index) { - sme_key.keyType = CSR_WIFI_SME_KEY_TYPE_PAIRWISE; - } else { - sme_key.keyType = CSR_WIFI_SME_KEY_TYPE_GROUP; - } - /* Key index is zero based in SME but 1 based in wext */ - sme_key.keyIndex = (index - 1); - sme_key.keyLength = erq->length; - sme_key.authenticator = 0; - memset(sme_key.address.a, 0xFF, ETH_ALEN); - memcpy(sme_key.key, extra, erq->length); - - UF_RTNL_UNLOCK(); - rc = sme_mgt_key(priv, &sme_key, CSR_WIFI_SME_LIST_ACTION_ADD); - UF_RTNL_LOCK(); - if (rc) { - unifi_error(priv, "unifi_siwencode: Set key failed (%d)", rc); - return convert_sme_error(rc); - } - - /* Store the key to be reported by the SIOCGIWENCODE handler */ - priv->wep_keys[index - 1].len = erq->length; - memcpy(priv->wep_keys[index - 1].key, extra, erq->length); - } - } else { - /* - * No additional key data, so it must be a request to change the - * active key. - */ - if (index != 0) { - unifi_trace(priv, UDBG1, "Tx key Index is %d\n", index - 1); - - /* Store the index to be reported by the SIOCGIWENCODE handler */ - priv->wep_tx_key_index = index; - - sme_key.wepTxKey = 1; - sme_key.keyType = CSR_WIFI_SME_KEY_TYPE_PAIRWISE; - - /* Key index is zero based in SME but 1 based in wext */ - sme_key.keyIndex = (index - 1); - sme_key.keyLength = 0; - sme_key.authenticator = 0; - UF_RTNL_UNLOCK(); - rc = sme_mgt_key(priv, &sme_key, CSR_WIFI_SME_LIST_ACTION_ADD); - UF_RTNL_LOCK(); - if (rc) { - unifi_error(priv, "unifi_siwencode: Set key failed (%d)", rc); - return convert_sme_error(rc); - } - - /* Turn on encryption */ - privacy = 1; - } - } - - /* Read the flags */ - if (erq->flags & IW_ENCODE_DISABLED) { - /* disable encryption */ - unifi_trace(priv, UDBG1, "disable WEP encryption\n"); - privacy = 0; - - priv->wep_tx_key_index = 0; - - unifi_trace(priv, UDBG1, "IW_ENCODE_DISABLED: CSR_WIFI_SME_AUTH_MODE_80211_OPEN\n"); - priv->connection_config.authModeMask = CSR_WIFI_SME_AUTH_MODE_80211_OPEN; - } - - if (erq->flags & IW_ENCODE_RESTRICTED) { - /* Use shared key auth */ - unifi_trace(priv, UDBG1, "IW_ENCODE_RESTRICTED: CSR_WIFI_SME_AUTH_MODE_80211_SHARED\n"); - priv->connection_config.authModeMask = CSR_WIFI_SME_AUTH_MODE_80211_SHARED; - - /* Turn on encryption */ - privacy = 1; - } - if (erq->flags & IW_ENCODE_OPEN) { - unifi_trace(priv, UDBG1, "IW_ENCODE_OPEN: CSR_WIFI_SME_AUTH_MODE_80211_OPEN\n"); - priv->connection_config.authModeMask = CSR_WIFI_SME_AUTH_MODE_80211_OPEN; - } - - /* Commit the changes to flags if needed */ - if (privacy != -1) { - priv->connection_config.privacyMode = privacy ? CSR_WIFI_SME_80211_PRIVACY_MODE_ENABLED : CSR_WIFI_SME_80211_PRIVACY_MODE_DISABLED; - priv->connection_config.encryptionModeMask = privacy ? (CSR_WIFI_SME_ENCRYPTION_CIPHER_PAIRWISE_WEP40 | - CSR_WIFI_SME_ENCRYPTION_CIPHER_PAIRWISE_WEP104 | - CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_WEP40 | - CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_WEP104) : - CSR_WIFI_SME_ENCRYPTION_CIPHER_NONE; - } - - return convert_sme_error(rc); - -} /* unifi_siwencode() */ - - - -static int -unifi_giwencode(struct net_device *dev, struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev); - unifi_priv_t *priv = interfacePriv->privPtr; - struct iw_point *erq = &wrqu->encoding; - - unifi_trace(priv, UDBG2, "unifi_giwencode\n"); - - CHECK_INITED(priv); - - if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP || - interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO) { - unifi_error(priv, "unifi_giwencode: not permitted in Mode %d\n", - interfacePriv->interfaceMode); - return -EPERM; - } - - - if (priv->connection_config.authModeMask == CSR_WIFI_SME_AUTH_MODE_80211_SHARED) { - erq->flags = IW_ENCODE_RESTRICTED; - } - else { - if (priv->connection_config.privacyMode == CSR_WIFI_SME_80211_PRIVACY_MODE_DISABLED) { - erq->flags = IW_ENCODE_DISABLED; - } else { - erq->flags = IW_ENCODE_OPEN; - } - } - - erq->length = 0; - - if (erq->flags != IW_ENCODE_DISABLED) { - int index = priv->wep_tx_key_index; - - if ((index > 0) && (index <= NUM_WEPKEYS)) { - erq->flags |= (index & IW_ENCODE_INDEX); - erq->length = priv->wep_keys[index - 1].len; - memcpy(extra, priv->wep_keys[index - 1].key, erq->length); - } else { - unifi_notice(priv, "unifi_giwencode: Surprise, do not have a valid key index (%d)\n", - index); - } - } - - return 0; -} /* unifi_giwencode() */ - - -static int -unifi_siwpower(struct net_device *dev, struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - struct iw_param *args = &wrqu->power; - netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev); - unifi_priv_t *priv = interfacePriv->privPtr; - int listen_interval, wake_for_dtim; - int r = 0; - CsrWifiSmePowerConfig powerConfig; - - unifi_trace(priv, UDBG2, "unifi_siwpower\n"); - - CHECK_INITED(priv); - - if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP || - interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO) { - unifi_error(priv, "unifi_siwpower: not permitted in Mode %d\n", - interfacePriv->interfaceMode); - return -EPERM; - } - - UF_RTNL_UNLOCK(); - r = sme_mgt_power_config_get(priv, &powerConfig); - UF_RTNL_LOCK(); - if (r) { - unifi_error(priv, "unifi_siwpower: Get unifi_PowerConfigValue failed.\n"); - return r; - } - - listen_interval = -1; - wake_for_dtim = -1; - if (args->disabled) { - powerConfig.powerSaveLevel = CSR_WIFI_SME_POWER_SAVE_LEVEL_LOW; - } - else - { - powerConfig.powerSaveLevel = CSR_WIFI_SME_POWER_SAVE_LEVEL_HIGH; - - switch (args->flags & IW_POWER_TYPE) { - case 0: - /* not specified */ - break; - case IW_POWER_PERIOD: - listen_interval = args->value / 1000; - break; - default: - return -EINVAL; - } - - switch (args->flags & IW_POWER_MODE) { - case 0: - /* not specified */ - break; - case IW_POWER_UNICAST_R: - /* not interested in broadcast packets */ - wake_for_dtim = 0; - break; - case IW_POWER_ALL_R: - /* yes, we are interested in broadcast packets */ - wake_for_dtim = 1; - break; - default: - return -EINVAL; - } - } - - if (listen_interval > 0) { - powerConfig.listenIntervalTu = listen_interval; - unifi_trace(priv, UDBG4, "unifi_siwpower: new Listen Interval = %d.\n", - powerConfig.listenIntervalTu); - } - - if (wake_for_dtim >= 0) { - powerConfig.rxDtims = wake_for_dtim; - } - UF_RTNL_UNLOCK(); - r = sme_mgt_power_config_set(priv, &powerConfig); - UF_RTNL_LOCK(); - if (r) { - unifi_error(priv, "unifi_siwpower: Set unifi_PowerConfigValue failed.\n"); - return r; - } - - return 0; -} /* unifi_siwpower() */ - - -static int -unifi_giwpower(struct net_device *dev, struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - struct iw_param *args = &wrqu->power; - netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev); - unifi_priv_t *priv = interfacePriv->privPtr; - CsrWifiSmePowerConfig powerConfig; - int r; - - unifi_trace(priv, UDBG2, "unifi_giwpower\n"); - - CHECK_INITED(priv); - - if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP || - interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO) { - unifi_error(priv, "unifi_giwpower: not permitted in Mode %d\n", - interfacePriv->interfaceMode); - return -EPERM; - } - - - args->flags = 0; - UF_RTNL_UNLOCK(); - r = sme_mgt_power_config_get(priv, &powerConfig); - UF_RTNL_LOCK(); - if (r) { - unifi_error(priv, "unifi_giwpower: Get unifi_PowerConfigValue failed.\n"); - return r; - } - - unifi_trace(priv, UDBG4, "unifi_giwpower: mode=%d\n", - powerConfig.powerSaveLevel); - - args->disabled = (powerConfig.powerSaveLevel == CSR_WIFI_SME_POWER_SAVE_LEVEL_LOW); - if (args->disabled) { - args->flags = 0; - return 0; - } - - args->value = powerConfig.listenIntervalTu * 1000; - args->flags |= IW_POWER_PERIOD; - - if (powerConfig.rxDtims) { - args->flags |= IW_POWER_ALL_R; - } else { - args->flags |= IW_POWER_UNICAST_R; - } - - return 0; -} /* unifi_giwpower() */ - - -/* - * --------------------------------------------------------------------------- - * unifi_siwcommit - handler for SIOCSIWCOMMIT - * - * Apply all the parameters that have been set. - * In practice this means: - * - do a scan - * - join a network or start an AdHoc - * - authenticate and associate. - * - * Arguments: - * None. - * - * Returns: - * None. - * --------------------------------------------------------------------------- - */ -static int -unifi_siwcommit(struct net_device *dev, struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - return 0; -} /* unifi_siwcommit() */ - - - -static int -unifi_siwmlme(struct net_device *dev, struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev); - unifi_priv_t *priv = interfacePriv->privPtr; - struct iw_mlme *mlme = (struct iw_mlme *)extra; - - unifi_trace(priv, UDBG2, "unifi_siwmlme\n"); - CHECK_INITED(priv); - - if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP || - interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO) { - unifi_error(priv, "unifi_siwmlme: not permitted in Mode %d\n", - interfacePriv->interfaceMode); - return -EPERM; - } - - - switch (mlme->cmd) { - case IW_MLME_DEAUTH: - case IW_MLME_DISASSOC: - UF_RTNL_UNLOCK(); - sme_mgt_disconnect(priv); - UF_RTNL_LOCK(); - break; - default: - return -EOPNOTSUPP; - } - - return 0; -} /* unifi_siwmlme() */ - - -/* - * --------------------------------------------------------------------------- - * unifi_siwgenie - * unifi_giwgenie - * - * WPA : Generic IEEE 802.11 information element (e.g., for WPA/RSN/WMM). - * Handlers for SIOCSIWGENIE, SIOCGIWGENIE - set/get generic IE - * - * The host program (e.g. wpa_supplicant) uses this call to set the - * additional IEs to accompany the next (Associate?) request. - * - * Arguments: - * None. - * - * Returns: - * None. - * Notes: - * From wireless.h: - * This ioctl uses struct iw_point and data buffer that includes IE id - * and len fields. More than one IE may be included in the - * request. Setting the generic IE to empty buffer (len=0) removes the - * generic IE from the driver. - * --------------------------------------------------------------------------- - */ -static int -unifi_siwgenie(struct net_device *dev, struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev); - unifi_priv_t *priv = interfacePriv->privPtr; - int len; - - unifi_trace(priv, UDBG2, "unifi_siwgenie\n"); - - if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP || - interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO) { - unifi_error(priv, "unifi_siwgenie: not permitted in Mode %d\n", - interfacePriv->interfaceMode); - return -EPERM; - } - - - if ( priv->connection_config.mlmeAssociateReqInformationElements) { - kfree( priv->connection_config.mlmeAssociateReqInformationElements); - } - priv->connection_config.mlmeAssociateReqInformationElementsLength = 0; - priv->connection_config.mlmeAssociateReqInformationElements = NULL; - - len = wrqu->data.length; - if (len == 0) { - return 0; - } - - priv->connection_config.mlmeAssociateReqInformationElements = kmalloc(len, GFP_KERNEL); - if (priv->connection_config.mlmeAssociateReqInformationElements == NULL) { - return -ENOMEM; - } - - priv->connection_config.mlmeAssociateReqInformationElementsLength = len; - memcpy( priv->connection_config.mlmeAssociateReqInformationElements, extra, len); - - return 0; -} /* unifi_siwgenie() */ - - -static int -unifi_giwgenie(struct net_device *dev, struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev); - unifi_priv_t *priv = interfacePriv->privPtr; - int len; - - unifi_trace(priv, UDBG2, "unifi_giwgenie\n"); - - if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP || - interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO) { - unifi_error(priv, "unifi_giwgenie: not permitted in Mode %d\n", - interfacePriv->interfaceMode); - return -EPERM; - } - - - len = priv->connection_config.mlmeAssociateReqInformationElementsLength; - - if (len == 0) { - wrqu->data.length = 0; - return 0; - } - - if (wrqu->data.length < len) { - return -E2BIG; - } - - wrqu->data.length = len; - memcpy(extra, priv->connection_config.mlmeAssociateReqInformationElements, len); - - return 0; -} /* unifi_giwgenie() */ - - -/* - * --------------------------------------------------------------------------- - * unifi_siwauth - * unifi_giwauth - * - * Handlers for SIOCSIWAUTH, SIOCGIWAUTH - * Set/get various authentication parameters. - * - * Arguments: - * - * - * Returns: - * None. - * --------------------------------------------------------------------------- - */ -static int -_unifi_siwauth(struct net_device *dev, struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev); - unifi_priv_t *priv = interfacePriv->privPtr; - CsrWifiSmeAuthModeMask new_auth; - - unifi_trace(priv, UDBG2, "unifi_siwauth\n"); - - if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP || - interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO) { - unifi_error(priv, "unifi_siwauth: not permitted in Mode %d\n", - interfacePriv->interfaceMode); - return -EPERM; - } - - - /* - * This ioctl is safe to call even when UniFi is powered off. - * wpa_supplicant calls it to test whether we support WPA. - */ - - switch (wrqu->param.flags & IW_AUTH_INDEX) { - - case IW_AUTH_WPA_ENABLED: - unifi_trace(priv, UDBG1, "IW_AUTH_WPA_ENABLED: %d\n", wrqu->param.value); - - if (wrqu->param.value == 0) { - unifi_trace(priv, UDBG5, "IW_AUTH_WPA_ENABLED: CSR_WIFI_SME_AUTH_MODE_80211_OPEN\n"); - priv->connection_config.authModeMask = CSR_WIFI_SME_AUTH_MODE_80211_OPEN; - } - break; - - case IW_AUTH_PRIVACY_INVOKED: - unifi_trace(priv, UDBG1, "IW_AUTH_PRIVACY_INVOKED: %d\n", wrqu->param.value); - - priv->connection_config.privacyMode = wrqu->param.value ? CSR_WIFI_SME_80211_PRIVACY_MODE_ENABLED : CSR_WIFI_SME_80211_PRIVACY_MODE_DISABLED; - if (wrqu->param.value == CSR_WIFI_SME_80211_PRIVACY_MODE_DISABLED) - { - priv->connection_config.encryptionModeMask = CSR_WIFI_SME_ENCRYPTION_CIPHER_NONE; - } - break; - - case IW_AUTH_80211_AUTH_ALG: - /* - IW_AUTH_ALG_OPEN_SYSTEM 0x00000001 - IW_AUTH_ALG_SHARED_KEY 0x00000002 - IW_AUTH_ALG_LEAP 0x00000004 - */ - new_auth = 0; - if (wrqu->param.value & IW_AUTH_ALG_OPEN_SYSTEM) { - unifi_trace(priv, UDBG1, "IW_AUTH_80211_AUTH_ALG: %d (IW_AUTH_ALG_OPEN_SYSTEM)\n", wrqu->param.value); - new_auth |= CSR_WIFI_SME_AUTH_MODE_80211_OPEN; - } - if (wrqu->param.value & IW_AUTH_ALG_SHARED_KEY) { - unifi_trace(priv, UDBG1, "IW_AUTH_80211_AUTH_ALG: %d (IW_AUTH_ALG_SHARED_KEY)\n", wrqu->param.value); - new_auth |= CSR_WIFI_SME_AUTH_MODE_80211_SHARED; - } - if (wrqu->param.value & IW_AUTH_ALG_LEAP) { - /* Initial exchanges using open-system to set EAP */ - unifi_trace(priv, UDBG1, "IW_AUTH_80211_AUTH_ALG: %d (IW_AUTH_ALG_LEAP)\n", wrqu->param.value); - new_auth |= CSR_WIFI_SME_AUTH_MODE_8021X_OTHER1X; - } - if (new_auth == 0) { - unifi_trace(priv, UDBG1, "IW_AUTH_80211_AUTH_ALG: invalid value %d\n", - wrqu->param.value); - return -EINVAL; - } else { - priv->connection_config.authModeMask = new_auth; - } - break; - - case IW_AUTH_WPA_VERSION: - unifi_trace(priv, UDBG1, "IW_AUTH_WPA_VERSION: %d\n", wrqu->param.value); - priv->ignore_bssid_join = TRUE; - /* - IW_AUTH_WPA_VERSION_DISABLED 0x00000001 - IW_AUTH_WPA_VERSION_WPA 0x00000002 - IW_AUTH_WPA_VERSION_WPA2 0x00000004 - */ - - if (!(wrqu->param.value & IW_AUTH_WPA_VERSION_DISABLED)) { - - priv->connection_config.authModeMask = CSR_WIFI_SME_AUTH_MODE_80211_OPEN; - - if (wrqu->param.value & IW_AUTH_WPA_VERSION_WPA) { - unifi_trace(priv, UDBG4, "IW_AUTH_WPA_VERSION: WPA, WPA-PSK\n"); - priv->connection_config.authModeMask |= (CSR_WIFI_SME_AUTH_MODE_8021X_WPA | CSR_WIFI_SME_AUTH_MODE_8021X_WPAPSK); - } - if (wrqu->param.value & IW_AUTH_WPA_VERSION_WPA2) { - unifi_trace(priv, UDBG4, "IW_AUTH_WPA_VERSION: WPA2, WPA2-PSK\n"); - priv->connection_config.authModeMask |= (CSR_WIFI_SME_AUTH_MODE_8021X_WPA2 | CSR_WIFI_SME_AUTH_MODE_8021X_WPA2PSK); - } - } - break; - - case IW_AUTH_CIPHER_PAIRWISE: - unifi_trace(priv, UDBG1, "IW_AUTH_CIPHER_PAIRWISE: %d\n", wrqu->param.value); - /* - * one of: - IW_AUTH_CIPHER_NONE 0x00000001 - IW_AUTH_CIPHER_WEP40 0x00000002 - IW_AUTH_CIPHER_TKIP 0x00000004 - IW_AUTH_CIPHER_CCMP 0x00000008 - IW_AUTH_CIPHER_WEP104 0x00000010 - */ - - priv->connection_config.encryptionModeMask = CSR_WIFI_SME_ENCRYPTION_CIPHER_NONE; - - if (wrqu->param.value & IW_AUTH_CIPHER_WEP40) { - priv->connection_config.encryptionModeMask |= - CSR_WIFI_SME_ENCRYPTION_CIPHER_PAIRWISE_WEP40 | CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_WEP40; - } - if (wrqu->param.value & IW_AUTH_CIPHER_WEP104) { - priv->connection_config.encryptionModeMask |= - CSR_WIFI_SME_ENCRYPTION_CIPHER_PAIRWISE_WEP104 | CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_WEP104; - } - if (wrqu->param.value & IW_AUTH_CIPHER_TKIP) { - priv->connection_config.encryptionModeMask |= - CSR_WIFI_SME_ENCRYPTION_CIPHER_PAIRWISE_TKIP | CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_TKIP; - } - if (wrqu->param.value & IW_AUTH_CIPHER_CCMP) { - priv->connection_config.encryptionModeMask |= - CSR_WIFI_SME_ENCRYPTION_CIPHER_PAIRWISE_CCMP | CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_CCMP; - } - - break; - - case IW_AUTH_CIPHER_GROUP: - unifi_trace(priv, UDBG1, "IW_AUTH_CIPHER_GROUP: %d\n", wrqu->param.value); - /* - * Use the WPA version and the group cipher suite to set the permitted - * group key in the MIB. f/w uses this value to validate WPA and RSN IEs - * in the probe responses from the desired BSS(ID) - */ - - priv->connection_config.encryptionModeMask &= ~(CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_WEP40 | - CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_WEP104 | - CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_TKIP | - CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_CCMP); - if (wrqu->param.value & IW_AUTH_CIPHER_WEP40) { - priv->connection_config.encryptionModeMask |= CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_WEP40; - } - if (wrqu->param.value & IW_AUTH_CIPHER_WEP104) { - priv->connection_config.encryptionModeMask |= CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_WEP104; - } - if (wrqu->param.value & IW_AUTH_CIPHER_TKIP) { - priv->connection_config.encryptionModeMask |= CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_TKIP; - } - if (wrqu->param.value & IW_AUTH_CIPHER_CCMP) { - priv->connection_config.encryptionModeMask |= CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_CCMP; - } - - break; - - case IW_AUTH_KEY_MGMT: - unifi_trace(priv, UDBG1, "IW_AUTH_KEY_MGMT: %d\n", wrqu->param.value); - /* - IW_AUTH_KEY_MGMT_802_1X 1 - IW_AUTH_KEY_MGMT_PSK 2 - */ - if (priv->connection_config.authModeMask & (CSR_WIFI_SME_AUTH_MODE_8021X_WPA | CSR_WIFI_SME_AUTH_MODE_8021X_WPAPSK)) { - /* Check for explicitly set mode. */ - if (wrqu->param.value == IW_AUTH_KEY_MGMT_802_1X) { - priv->connection_config.authModeMask &= ~CSR_WIFI_SME_AUTH_MODE_8021X_WPAPSK; - } - if (wrqu->param.value == IW_AUTH_KEY_MGMT_PSK) { - priv->connection_config.authModeMask &= ~CSR_WIFI_SME_AUTH_MODE_8021X_WPA; - } - unifi_trace(priv, UDBG5, "IW_AUTH_KEY_MGMT: WPA: %d\n", - priv->connection_config.authModeMask); - } - if (priv->connection_config.authModeMask & (CSR_WIFI_SME_AUTH_MODE_8021X_WPA2 | CSR_WIFI_SME_AUTH_MODE_8021X_WPA2PSK)) { - /* Check for explicitly set mode. */ - if (wrqu->param.value == IW_AUTH_KEY_MGMT_802_1X) { - priv->connection_config.authModeMask &= ~CSR_WIFI_SME_AUTH_MODE_8021X_WPA2PSK; - } - if (wrqu->param.value == IW_AUTH_KEY_MGMT_PSK) { - priv->connection_config.authModeMask &= ~CSR_WIFI_SME_AUTH_MODE_8021X_WPA2; - } - unifi_trace(priv, UDBG5, "IW_AUTH_KEY_MGMT: WPA2: %d\n", - priv->connection_config.authModeMask); - } - - break; - case IW_AUTH_TKIP_COUNTERMEASURES: - /* - * Set to true at the start of the 60 second backup-off period - * following 2 MichaelMIC failures within 60s. - */ - unifi_trace(priv, UDBG1, "IW_AUTH_TKIP_COUNTERMEASURES: %d\n", wrqu->param.value); - break; - - case IW_AUTH_DROP_UNENCRYPTED: - /* - * Set to true on init. - * Set to false just before associate if encryption will not be - * required. - * - * Note this is not the same as the 802.1X controlled port - */ - unifi_trace(priv, UDBG1, "IW_AUTH_DROP_UNENCRYPTED: %d\n", wrqu->param.value); - break; - - case IW_AUTH_RX_UNENCRYPTED_EAPOL: - /* - * This is set by wpa_supplicant to allow unencrypted EAPOL messages - * even if pairwise keys are set when not using WPA. IEEE 802.1X - * specifies that these frames are not encrypted, but WPA encrypts - * them when pairwise keys are in use. - * I think the UniFi f/w handles this decision for us. - */ - unifi_trace(priv, UDBG1, "IW_AUTH_RX_UNENCRYPTED_EAPOL: %d\n", wrqu->param.value); - break; - - case IW_AUTH_ROAMING_CONTROL: - unifi_trace(priv, UDBG1, "IW_AUTH_ROAMING_CONTROL: %d\n", wrqu->param.value); - break; - - default: - unifi_trace(priv, UDBG1, "Unsupported auth param %d to 0x%X\n", - wrqu->param.flags & IW_AUTH_INDEX, - wrqu->param.value); - return -EOPNOTSUPP; - } - - unifi_trace(priv, UDBG2, "authModeMask = %d", priv->connection_config.authModeMask); - - return 0; -} /* _unifi_siwauth() */ - - -static int -unifi_siwauth(struct net_device *dev, struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - int err = 0; - - UF_RTNL_UNLOCK(); - err = _unifi_siwauth(dev, info, wrqu, extra); - UF_RTNL_LOCK(); - - return err; -} /* unifi_siwauth() */ - - -static int -unifi_giwauth(struct net_device *dev, struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - unifi_trace(NULL, UDBG2, "unifi_giwauth\n"); - return -EOPNOTSUPP; -} /* unifi_giwauth() */ - -/* - * --------------------------------------------------------------------------- - * unifi_siwencodeext - * unifi_giwencodeext - * - * Handlers for SIOCSIWENCODEEXT, SIOCGIWENCODEEXT - set/get - * encoding token & mode - * - * Arguments: - * None. - * - * Returns: - * None. - * - * Notes: - * For WPA/WPA2 we don't take note of the IW_ENCODE_EXT_SET_TX_KEY flag. - * This flag means "use this key to encode transmissions"; we just - * assume only one key will be set and that is the one to use. - * --------------------------------------------------------------------------- - */ -static int -_unifi_siwencodeext(struct net_device *dev, struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev); - unifi_priv_t *priv = interfacePriv->privPtr; - struct iw_encode_ext *ext = (struct iw_encode_ext *)extra; - int r = 0; - unsigned char *keydata; - unsigned char tkip_key[32]; - int keyid; - unsigned char *a = (unsigned char *)ext->addr.sa_data; - CsrWifiSmeKey sme_key; - CsrWifiSmeKeyType key_type; - - CHECK_INITED(priv); - - if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP || - interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO) { - unifi_error(priv, "unifi_siwencodeext: not permitted in Mode %d\n", - interfacePriv->interfaceMode); - return -EPERM; - } - - - unifi_trace(priv, UDBG1, "siwencodeext: flags=0x%X, alg=%d, ext_flags=0x%X, len=%d, index=%d,\n", - wrqu->encoding.flags, ext->alg, ext->ext_flags, - ext->key_len, (wrqu->encoding.flags & IW_ENCODE_INDEX)); - unifi_trace(priv, UDBG3, " addr=%pM\n", a); - - if ((ext->key_len == 0) && (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)) { - /* This means use a different key (given by key_idx) for Tx. */ - /* NYI */ - unifi_trace(priv, UDBG1, KERN_ERR "unifi_siwencodeext: NYI should change tx key id here!!\n"); - return -ENOTSUPP; - } - - memset(&sme_key, 0, sizeof(sme_key)); - - keydata = (unsigned char *)(ext + 1); - keyid = (wrqu->encoding.flags & IW_ENCODE_INDEX); - - /* - * Check for request to delete keys for an address. - */ - /* Pick out request for no privacy. */ - if (ext->alg == IW_ENCODE_ALG_NONE) { - - unifi_trace(priv, UDBG1, "Deleting %s key %d\n", - (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) ? "GROUP" : "PAIRWISE", - keyid); - - if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) { - sme_key.keyType = CSR_WIFI_SME_KEY_TYPE_GROUP; - } else { - sme_key.keyType = CSR_WIFI_SME_KEY_TYPE_PAIRWISE; - } - sme_key.keyIndex = (keyid - 1); - sme_key.keyLength = 0; - sme_key.authenticator = 0; - memcpy(sme_key.address.a, a, ETH_ALEN); - UF_RTNL_UNLOCK(); - r = sme_mgt_key(priv, &sme_key, CSR_WIFI_SME_LIST_ACTION_REMOVE); - UF_RTNL_LOCK(); - if (r) { - unifi_error(priv, "Delete key request was rejected with result %d\n", r); - return convert_sme_error(r); - } - - return 0; - } - - /* - * Request is to set a key, not delete - */ - - /* Pick out WEP and use set_wep_key(). */ - if (ext->alg == IW_ENCODE_ALG_WEP) { - /* WEP-40, WEP-104 */ - - /* Check for valid key length */ - if (!((ext->key_len == 5) || (ext->key_len == 13))) { - unifi_trace(priv, UDBG1, KERN_ERR "Invalid length for WEP key: %d\n", ext->key_len); - return -EINVAL; - } - - unifi_trace(priv, UDBG1, "Setting WEP key %d tx:%d\n", - keyid, ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY); - - if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY) { - sme_key.wepTxKey = TRUE; - sme_key.keyType = CSR_WIFI_SME_KEY_TYPE_PAIRWISE; - } else { - sme_key.wepTxKey = FALSE; - sme_key.keyType = CSR_WIFI_SME_KEY_TYPE_GROUP; - } - sme_key.keyIndex = (keyid - 1); - sme_key.keyLength = ext->key_len; - sme_key.authenticator = 0; - memset(sme_key.address.a, 0xFF, ETH_ALEN); - memcpy(sme_key.key, keydata, ext->key_len); - UF_RTNL_UNLOCK(); - r = sme_mgt_key(priv, &sme_key, CSR_WIFI_SME_LIST_ACTION_ADD); - UF_RTNL_LOCK(); - if (r) { - unifi_error(priv, "siwencodeext: Set key failed (%d)", r); - return convert_sme_error(r); - } - - return 0; - } - - /* - * - * If we reach here, we are dealing with a WPA/WPA2 key - * - */ - if (ext->key_len > 32) { - return -EINVAL; - } - - /* - * TKIP keys from wpa_supplicant need swapping. - * What about other supplicants (when they come along)? - */ - if ((ext->alg == IW_ENCODE_ALG_TKIP) && (ext->key_len == 32)) { - memcpy(tkip_key, keydata, 16); - memcpy(tkip_key + 16, keydata + 24, 8); - memcpy(tkip_key + 24, keydata + 16, 8); - keydata = tkip_key; - } - - key_type = (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) ? - CSR_WIFI_SME_KEY_TYPE_GROUP : /* Group Key */ - CSR_WIFI_SME_KEY_TYPE_PAIRWISE; /* Pairwise Key */ - - sme_key.keyType = key_type; - sme_key.keyIndex = (keyid - 1); - sme_key.keyLength = ext->key_len; - sme_key.authenticator = 0; - memcpy(sme_key.address.a, ext->addr.sa_data, ETH_ALEN); - if (ext->ext_flags & IW_ENCODE_EXT_RX_SEQ_VALID) { - - unifi_trace(priv, UDBG5, "RSC first 6 bytes = %*phC\n", - 6, ext->rx_seq); - - /* memcpy((u8*)(&sme_key.keyRsc), ext->rx_seq, 8); */ - sme_key.keyRsc[0] = ext->rx_seq[1] << 8 | ext->rx_seq[0]; - sme_key.keyRsc[1] = ext->rx_seq[3] << 8 | ext->rx_seq[2]; - sme_key.keyRsc[2] = ext->rx_seq[5] << 8 | ext->rx_seq[4]; - sme_key.keyRsc[3] = ext->rx_seq[7] << 8 | ext->rx_seq[6]; - - } - - memcpy(sme_key.key, keydata, ext->key_len); - UF_RTNL_UNLOCK(); - r = sme_mgt_key(priv, &sme_key, CSR_WIFI_SME_LIST_ACTION_ADD); - UF_RTNL_LOCK(); - if (r) { - unifi_error(priv, "SETKEYS request was rejected with result %d\n", r); - return convert_sme_error(r); - } - - return r; -} /* _unifi_siwencodeext() */ - - -static int -unifi_siwencodeext(struct net_device *dev, struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - int err = 0; - - err = _unifi_siwencodeext(dev, info, wrqu, extra); - - return err; -} /* unifi_siwencodeext() */ - - -static int -unifi_giwencodeext(struct net_device *dev, struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - return -EOPNOTSUPP; -} /* unifi_giwencodeext() */ - - -/* - * --------------------------------------------------------------------------- - * unifi_siwpmksa - * - * SIOCSIWPMKSA - PMKSA cache operation - * The caller passes a pmksa structure: - * - cmd one of ADD, REMOVE, FLUSH - * - bssid MAC address - * - pmkid ID string (16 bytes) - * - * Arguments: - * None. - * - * Returns: - * None. - * - * Notes: - * This is not needed since we provide a siwgenie method. - * --------------------------------------------------------------------------- - */ -#define UNIFI_PMKID_KEY_SIZE 16 -static int -unifi_siwpmksa(struct net_device *dev, struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev); - unifi_priv_t *priv = interfacePriv->privPtr; - struct iw_pmksa *pmksa = (struct iw_pmksa *)extra; - CsrResult r = 0; - CsrWifiSmePmkidList pmkid_list; - CsrWifiSmePmkid pmkid; - CsrWifiSmeListAction action; - - CHECK_INITED(priv); - - if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP || - interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO) { - unifi_error(priv, "unifi_siwpmksa: not permitted in Mode %d\n", - interfacePriv->interfaceMode); - return -EPERM; - } - - - unifi_trace(priv, UDBG1, "SIWPMKSA: cmd %d, %pM\n", pmksa->cmd, - pmksa->bssid.sa_data); - - pmkid_list.pmkids = NULL; - switch (pmksa->cmd) { - case IW_PMKSA_ADD: - pmkid_list.pmkids = &pmkid; - action = CSR_WIFI_SME_LIST_ACTION_ADD; - pmkid_list.pmkidsCount = 1; - memcpy(pmkid.bssid.a, pmksa->bssid.sa_data, ETH_ALEN); - memcpy(pmkid.pmkid, pmksa->pmkid, UNIFI_PMKID_KEY_SIZE); - break; - case IW_PMKSA_REMOVE: - pmkid_list.pmkids = &pmkid; - action = CSR_WIFI_SME_LIST_ACTION_REMOVE; - pmkid_list.pmkidsCount = 1; - memcpy(pmkid.bssid.a, pmksa->bssid.sa_data, ETH_ALEN); - memcpy(pmkid.pmkid, pmksa->pmkid, UNIFI_PMKID_KEY_SIZE); - break; - case IW_PMKSA_FLUSH: - /* Replace current PMKID's with an empty list */ - pmkid_list.pmkidsCount = 0; - action = CSR_WIFI_SME_LIST_ACTION_FLUSH; - break; - default: - unifi_notice(priv, "SIWPMKSA: Unknown command (0x%x)\n", pmksa->cmd); - return -EINVAL; - } - - /* Set the Value the pmkid's will have 1 added OR 1 removed OR be cleared at this point */ - UF_RTNL_UNLOCK(); - r = sme_mgt_pmkid(priv, action, &pmkid_list); - UF_RTNL_LOCK(); - if (r) { - unifi_error(priv, "SIWPMKSA: Set PMKID's Failed.\n"); - } - - return r; - -} /* unifi_siwpmksa() */ - - -/* - * --------------------------------------------------------------------------- - * unifi_get_wireless_stats - * - * get_wireless_stats method for Linux wireless extensions. - * - * Arguments: - * dev Pointer to associated netdevice. - * - * Returns: - * Pointer to iw_statistics struct. - * --------------------------------------------------------------------------- - */ -struct iw_statistics * -unifi_get_wireless_stats(struct net_device *dev) -{ - netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev); - unifi_priv_t *priv = interfacePriv->privPtr; - - if (priv->init_progress != UNIFI_INIT_COMPLETED) { - return NULL; - } - - return &priv->wext_wireless_stats; -} /* unifi_get_wireless_stats() */ - - -/* - * Structures to export the Wireless Handlers - */ - -static const struct iw_priv_args unifi_private_args[] = { - /*{ cmd, set_args, get_args, name } */ - { SIOCIWS80211POWERSAVEPRIV, IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 1, - IW_PRIV_TYPE_NONE, "iwprivs80211ps" }, - { SIOCIWG80211POWERSAVEPRIV, IW_PRIV_TYPE_NONE, - IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | IWPRIV_POWER_SAVE_MAX_STRING, "iwprivg80211ps" }, - { SIOCIWS80211RELOADDEFAULTSPRIV, IW_PRIV_TYPE_NONE, - IW_PRIV_TYPE_NONE, "iwprivsdefs" }, - { SIOCIWSSMEDEBUGPRIV, IW_PRIV_TYPE_CHAR | IWPRIV_SME_DEBUG_MAX_STRING, IW_PRIV_TYPE_NONE, "iwprivssmedebug" }, -#ifdef CSR_WIFI_SECURITY_WAPI_ENABLE - { SIOCIWSCONFWAPIPRIV, IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 1, - IW_PRIV_TYPE_NONE, "iwprivsconfwapi" }, - { SIOCIWSWAPIKEYPRIV, IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | sizeof(unifiio_wapi_key_t), - IW_PRIV_TYPE_NONE, "iwprivswpikey" }, -#endif -#ifdef CSR_SUPPORT_WEXT_AP - { SIOCIWSAPCFGPRIV, IW_PRIV_TYPE_CHAR | 256, IW_PRIV_TYPE_NONE, "AP_SET_CFG" }, - { SIOCIWSAPSTARTPRIV, 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED|IWPRIV_SME_MAX_STRING, "AP_BSS_START" }, - { SIOCIWSAPSTOPPRIV, IW_PRIV_TYPE_CHAR |IW_PRIV_SIZE_FIXED|0, - IW_PRIV_TYPE_CHAR |IW_PRIV_SIZE_FIXED|0, "AP_BSS_STOP" }, -#ifdef ANDROID_BUILD - { SIOCIWSFWRELOADPRIV, IW_PRIV_TYPE_CHAR |256, - IW_PRIV_TYPE_CHAR |IW_PRIV_SIZE_FIXED|0, "WL_FW_RELOAD" }, - { SIOCIWSSTACKSTART, 0, - IW_PRIV_TYPE_CHAR |IW_PRIV_SIZE_FIXED|IWPRIV_SME_MAX_STRING, "START" }, - { SIOCIWSSTACKSTOP, 0, - IW_PRIV_TYPE_CHAR |IW_PRIV_SIZE_FIXED|IWPRIV_SME_MAX_STRING, "STOP" }, -#endif /* ANDROID_BUILD */ -#endif /* CSR_SUPPORT_WEXT_AP */ -}; - -static const iw_handler unifi_handler[] = -{ - (iw_handler) unifi_siwcommit, /* SIOCSIWCOMMIT */ - (iw_handler) unifi_giwname, /* SIOCGIWNAME */ - (iw_handler) NULL, /* SIOCSIWNWID */ - (iw_handler) NULL, /* SIOCGIWNWID */ - (iw_handler) unifi_siwfreq, /* SIOCSIWFREQ */ - (iw_handler) unifi_giwfreq, /* SIOCGIWFREQ */ - (iw_handler) unifi_siwmode, /* SIOCSIWMODE */ - (iw_handler) unifi_giwmode, /* SIOCGIWMODE */ - (iw_handler) NULL, /* SIOCSIWSENS */ - (iw_handler) NULL, /* SIOCGIWSENS */ - (iw_handler) NULL, /* SIOCSIWRANGE */ - (iw_handler) unifi_giwrange, /* SIOCGIWRANGE */ - (iw_handler) NULL, /* SIOCSIWPRIV */ - (iw_handler) NULL, /* SIOCGIWPRIV */ - (iw_handler) NULL, /* SIOCSIWSTATS */ - (iw_handler) NULL, /* SIOCGIWSTATS */ - (iw_handler) NULL, /* SIOCSIWSPY */ - (iw_handler) NULL, /* SIOCGIWSPY */ - (iw_handler) NULL, /* SIOCSIWTHRSPY */ - (iw_handler) NULL, /* SIOCGIWTHRSPY */ - (iw_handler) unifi_siwap, /* SIOCSIWAP */ - (iw_handler) unifi_giwap, /* SIOCGIWAP */ -#if WIRELESS_EXT > 17 - /* WPA : IEEE 802.11 MLME requests */ - unifi_siwmlme, /* SIOCSIWMLME, request MLME operation */ -#else - (iw_handler) NULL, /* -- hole -- */ -#endif - (iw_handler) NULL, /* SIOCGIWAPLIST */ - (iw_handler) unifi_siwscan, /* SIOCSIWSCAN */ - (iw_handler) unifi_giwscan, /* SIOCGIWSCAN */ - (iw_handler) unifi_siwessid, /* SIOCSIWESSID */ - (iw_handler) unifi_giwessid, /* SIOCGIWESSID */ - (iw_handler) NULL, /* SIOCSIWNICKN */ - (iw_handler) NULL, /* SIOCGIWNICKN */ - (iw_handler) NULL, /* -- hole -- */ - (iw_handler) NULL, /* -- hole -- */ - unifi_siwrate, /* SIOCSIWRATE */ - unifi_giwrate, /* SIOCGIWRATE */ - unifi_siwrts, /* SIOCSIWRTS */ - unifi_giwrts, /* SIOCGIWRTS */ - unifi_siwfrag, /* SIOCSIWFRAG */ - unifi_giwfrag, /* SIOCGIWFRAG */ - (iw_handler) NULL, /* SIOCSIWTXPOW */ - (iw_handler) NULL, /* SIOCGIWTXPOW */ - (iw_handler) NULL, /* SIOCSIWRETRY */ - (iw_handler) NULL, /* SIOCGIWRETRY */ - unifi_siwencode, /* SIOCSIWENCODE */ - unifi_giwencode, /* SIOCGIWENCODE */ - unifi_siwpower, /* SIOCSIWPOWER */ - unifi_giwpower, /* SIOCGIWPOWER */ -#if WIRELESS_EXT > 17 - (iw_handler) NULL, /* -- hole -- */ - (iw_handler) NULL, /* -- hole -- */ - - /* WPA : Generic IEEE 802.11 informatiom element (e.g., for WPA/RSN/WMM). */ - unifi_siwgenie, /* SIOCSIWGENIE */ /* set generic IE */ - unifi_giwgenie, /* SIOCGIWGENIE */ /* get generic IE */ - - /* WPA : Authentication mode parameters */ - unifi_siwauth, /* SIOCSIWAUTH */ /* set authentication mode params */ - unifi_giwauth, /* SIOCGIWAUTH */ /* get authentication mode params */ - - /* WPA : Extended version of encoding configuration */ - unifi_siwencodeext, /* SIOCSIWENCODEEXT */ /* set encoding token & mode */ - unifi_giwencodeext, /* SIOCGIWENCODEEXT */ /* get encoding token & mode */ - - /* WPA2 : PMKSA cache management */ - unifi_siwpmksa, /* SIOCSIWPMKSA */ /* PMKSA cache operation */ - (iw_handler) NULL, /* -- hole -- */ -#endif /* WIRELESS_EXT > 17 */ -}; - - -static const iw_handler unifi_private_handler[] = -{ - iwprivs80211ps, /* SIOCIWFIRSTPRIV */ - iwprivg80211ps, /* SIOCIWFIRSTPRIV + 1 */ - iwprivsdefs, /* SIOCIWFIRSTPRIV + 2 */ - (iw_handler) NULL, -#ifdef CSR_WIFI_SECURITY_WAPI_ENABLE - iwprivsconfwapi, /* SIOCIWFIRSTPRIV + 4 */ - (iw_handler) NULL, /* SIOCIWFIRSTPRIV + 5 */ - iwprivswpikey, /* SIOCIWFIRSTPRIV + 6 */ -#else - (iw_handler) NULL, - (iw_handler) NULL, - (iw_handler) NULL, -#endif - (iw_handler) NULL, - iwprivssmedebug, /* SIOCIWFIRSTPRIV + 8 */ -#ifdef CSR_SUPPORT_WEXT_AP - (iw_handler) NULL, - iwprivsapconfig, - (iw_handler) NULL, - iwprivsapstart, - (iw_handler) NULL, - iwprivsapstop, - (iw_handler) NULL, -#ifdef ANDROID_BUILD - iwprivsapfwreload, - (iw_handler) NULL, - iwprivsstackstart, - (iw_handler) NULL, - iwprivsstackstop, -#else - (iw_handler) NULL, - (iw_handler) NULL, - (iw_handler) NULL, - (iw_handler) NULL, - (iw_handler) NULL, -#endif /* ANDROID_BUILD */ -#else - (iw_handler) NULL, - (iw_handler) NULL, - (iw_handler) NULL, - (iw_handler) NULL, - (iw_handler) NULL, - (iw_handler) NULL, - (iw_handler) NULL, - (iw_handler) NULL, - (iw_handler) NULL, - (iw_handler) NULL, - (iw_handler) NULL, - (iw_handler) NULL, -#endif /* CSR_SUPPORT_WEXT_AP */ -}; - -struct iw_handler_def unifi_iw_handler_def = -{ - .num_standard = sizeof(unifi_handler) / sizeof(iw_handler), - .num_private = sizeof(unifi_private_handler) / sizeof(iw_handler), - .num_private_args = sizeof(unifi_private_args) / sizeof(struct iw_priv_args), - .standard = (iw_handler *) unifi_handler, - .private = (iw_handler *) unifi_private_handler, - .private_args = (struct iw_priv_args *) unifi_private_args, -#if IW_HANDLER_VERSION >= 6 - .get_wireless_stats = unifi_get_wireless_stats, -#endif -}; - - diff --git a/drivers/staging/csr/ul_int.c b/drivers/staging/csr/ul_int.c deleted file mode 100644 index eb286e5f7467..000000000000 --- a/drivers/staging/csr/ul_int.c +++ /dev/null @@ -1,528 +0,0 @@ -/* - * *************************************************************************** - * FILE: ul_int.c - * - * PURPOSE: - * Manage list of client applications using UniFi. - * - * Copyright (C) 2006-2009 by Cambridge Silicon Radio Ltd. - * - * Refer to LICENSE.txt included with this source code for details on - * the license terms. - * - * *************************************************************************** - */ -#include "csr_wifi_hip_unifi.h" -#include "csr_wifi_hip_conversions.h" -#include "unifi_priv.h" -#include "unifiio.h" -#include "unifi_os.h" - -static void free_bulkdata_buffers(unifi_priv_t *priv, bulk_data_param_t *bulkdata); -static void reset_driver_status(unifi_priv_t *priv); - -/* - * --------------------------------------------------------------------------- - * ul_init_clients - * - * Initialise the clients array to empty. - * - * Arguments: - * priv Pointer to device private context struct - * - * Returns: - * None. - * - * Notes: - * This function needs to be called before priv is stored in - * Unifi_instances[]. - * --------------------------------------------------------------------------- - */ -void -ul_init_clients(unifi_priv_t *priv) -{ - int id; - ul_client_t *ul_clients; - - sema_init(&priv->udi_logging_mutex, 1); - priv->logging_client = NULL; - - ul_clients = priv->ul_clients; - - for (id = 0; id < MAX_UDI_CLIENTS; id++) { - memset(&ul_clients[id], 0, sizeof(ul_client_t)); - - ul_clients[id].client_id = id; - ul_clients[id].sender_id = UDI_SENDER_ID_BASE + (id << UDI_SENDER_ID_SHIFT); - ul_clients[id].instance = -1; - ul_clients[id].event_hook = NULL; - - INIT_LIST_HEAD(&ul_clients[id].udi_log); - init_waitqueue_head(&ul_clients[id].udi_wq); - sema_init(&ul_clients[id].udi_sem, 1); - - ul_clients[id].wake_up_wq_id = 0; - ul_clients[id].seq_no = 0; - ul_clients[id].wake_seq_no = 0; - ul_clients[id].snap_filter.count = 0; - } -} /* ul_init_clients() */ - - -/* - * --------------------------------------------------------------------------- - * ul_register_client - * - * This function registers a new ul client. - * - * Arguments: - * priv Pointer to device private context struct - * configuration Special configuration for the client. - * udi_event_clbk Callback for receiving event from unifi. - * - * Returns: - * 0 if a new clients is registered, -1 otherwise. - * --------------------------------------------------------------------------- - */ -ul_client_t * -ul_register_client(unifi_priv_t *priv, unsigned int configuration, - udi_event_t udi_event_clbk) -{ - unsigned char id, ref; - ul_client_t *ul_clients; - - ul_clients = priv->ul_clients; - - /* check for an unused entry */ - for (id = 0; id < MAX_UDI_CLIENTS; id++) { - if (ul_clients[id].udi_enabled == 0) { - ul_clients[id].instance = priv->instance; - ul_clients[id].udi_enabled = 1; - ul_clients[id].configuration = configuration; - - /* Allocate memory for the reply signal.. */ - ul_clients[id].reply_signal = kmalloc(sizeof(CSR_SIGNAL), GFP_KERNEL); - if (ul_clients[id].reply_signal == NULL) { - unifi_error(priv, "Failed to allocate reply signal for client.\n"); - return NULL; - } - /* .. and the bulk data of the reply signal. */ - for (ref = 0; ref < UNIFI_MAX_DATA_REFERENCES; ref ++) { - ul_clients[id].reply_bulkdata[ref] = kmalloc(sizeof(bulk_data_t), GFP_KERNEL); - /* If allocation fails, free allocated memory. */ - if (ul_clients[id].reply_bulkdata[ref] == NULL) { - for (; ref > 0; ref --) { - kfree(ul_clients[id].reply_bulkdata[ref - 1]); - } - kfree(ul_clients[id].reply_signal); - unifi_error(priv, "Failed to allocate bulk data buffers for client.\n"); - return NULL; - } - } - - /* Set the event callback. */ - ul_clients[id].event_hook = udi_event_clbk; - - unifi_trace(priv, UDBG2, "UDI %d (0x%x) registered. configuration = 0x%x\n", - id, &ul_clients[id], configuration); - return &ul_clients[id]; - } - } - return NULL; -} /* ul_register_client() */ - - -/* - * --------------------------------------------------------------------------- - * ul_deregister_client - * - * This function deregisters a blocking UDI client. - * - * Arguments: - * client Pointer to the client we deregister. - * - * Returns: - * 0 if a new clients is deregistered. - * --------------------------------------------------------------------------- - */ -int -ul_deregister_client(ul_client_t *ul_client) -{ - struct list_head *pos, *n; - udi_log_t *logptr; - unifi_priv_t *priv = uf_find_instance(ul_client->instance); - int ref; - - ul_client->instance = -1; - ul_client->event_hook = NULL; - ul_client->udi_enabled = 0; - unifi_trace(priv, UDBG5, "UDI (0x%x) deregistered.\n", ul_client); - - /* Free memory allocated for the reply signal and its bulk data. */ - kfree(ul_client->reply_signal); - for (ref = 0; ref < UNIFI_MAX_DATA_REFERENCES; ref ++) { - kfree(ul_client->reply_bulkdata[ref]); - } - - if (ul_client->snap_filter.count) { - ul_client->snap_filter.count = 0; - kfree(ul_client->snap_filter.protocols); - } - - /* Free anything pending on the udi_log list */ - down(&ul_client->udi_sem); - list_for_each_safe(pos, n, &ul_client->udi_log) - { - logptr = list_entry(pos, udi_log_t, q); - list_del(pos); - kfree(logptr); - } - up(&ul_client->udi_sem); - - return 0; -} /* ul_deregister_client() */ - - - -/* - * --------------------------------------------------------------------------- - * logging_handler - * - * This function is registered with the driver core. - * It is called every time a UniFi HIP Signal is sent. It iterates over - * the list of processes interested in receiving log events and - * delivers the events to them. - * - * Arguments: - * ospriv Pointer to driver's private data. - * sigdata Pointer to the packed signal buffer. - * signal_len Length of the packed signal. - * bulkdata Pointer to the signal's bulk data. - * dir Direction of the signal - * 0 = from-host - * 1 = to-host - * - * Returns: - * None. - * --------------------------------------------------------------------------- - */ -void -logging_handler(void *ospriv, - u8 *sigdata, u32 signal_len, - const bulk_data_param_t *bulkdata, - enum udi_log_direction direction) -{ - unifi_priv_t *priv = (unifi_priv_t*)ospriv; - ul_client_t *client; - int dir; - - dir = (direction == UDI_LOG_FROM_HOST) ? UDI_FROM_HOST : UDI_TO_HOST; - - down(&priv->udi_logging_mutex); - client = priv->logging_client; - if (client != NULL) { - client->event_hook(client, sigdata, signal_len, - bulkdata, dir); - } - up(&priv->udi_logging_mutex); - -} /* logging_handler() */ - - - -/* - * --------------------------------------------------------------------------- - * ul_log_config_ind - * - * This function uses the client's register callback - * to indicate configuration information e.g core errors. - * - * Arguments: - * priv Pointer to driver's private data. - * conf_param Pointer to the configuration data. - * len Length of the configuration data. - * - * Returns: - * None. - * --------------------------------------------------------------------------- - */ -void -ul_log_config_ind(unifi_priv_t *priv, u8 *conf_param, int len) -{ -#ifdef CSR_SUPPORT_SME - if (priv->smepriv == NULL) - { - return; - } - if ((CONFIG_IND_ERROR == (*conf_param)) && (priv->wifi_on_state == wifi_on_in_progress)) { - unifi_notice(priv, "ul_log_config_ind: wifi on in progress, suppress error\n"); - } else { - /* wifi_off_ind (error or exit) */ - CsrWifiRouterCtrlWifiOffIndSend(priv->CSR_WIFI_SME_IFACEQUEUE, 0, (CsrWifiRouterCtrlControlIndication)(*conf_param)); - } -#ifdef CSR_WIFI_HIP_DEBUG_OFFLINE - unifi_debug_buf_dump(); -#endif -#else - bulk_data_param_t bulkdata; - - /* - * If someone killed unifi_managed before the driver was unloaded - * the g_drvpriv pointer is going to be NULL. In this case it is - * safe to assume that there is no client to get the indication. - */ - if (!priv) { - unifi_notice(NULL, "uf_sme_event_ind: NULL priv\n"); - return; - } - - /* Create a null bulkdata structure. */ - bulkdata.d[0].data_length = 0; - bulkdata.d[1].data_length = 0; - - sme_native_log_event(priv->sme_cli, conf_param, sizeof(u8), - &bulkdata, UDI_CONFIG_IND); - -#endif /* CSR_SUPPORT_SME */ - -} /* ul_log_config_ind */ - - -/* - * --------------------------------------------------------------------------- - * free_bulkdata_buffers - * - * Free the bulkdata buffers e.g. after a failed unifi_send_signal(). - * - * Arguments: - * priv Pointer to device private struct - * bulkdata Pointer to bulkdata parameter table - * - * Returns: - * None. - * --------------------------------------------------------------------------- - */ -static void -free_bulkdata_buffers(unifi_priv_t *priv, bulk_data_param_t *bulkdata) -{ - int i; - - if (bulkdata) { - for (i = 0; i < UNIFI_MAX_DATA_REFERENCES; ++i) { - if (bulkdata->d[i].data_length != 0) { - unifi_net_data_free(priv, (bulk_data_desc_t *)(&bulkdata->d[i])); - /* data_length is now 0 */ - } - } - } - -} /* free_bulkdata_buffers */ - -static int -_align_bulk_data_buffers(unifi_priv_t *priv, u8 *signal, - bulk_data_param_t *bulkdata) -{ - unsigned int i; - - if ((bulkdata == NULL) || (CSR_WIFI_ALIGN_BYTES == 0)) { - return 0; - } - - for (i = 0; i < UNIFI_MAX_DATA_REFERENCES; i++) - { - struct sk_buff *skb; - /* - * The following complex casting is in place in order to eliminate 64-bit compilation warning - * "cast to/from pointer from/to integer of different size" - */ - u32 align_offset = (u32)(long)(bulkdata->d[i].os_data_ptr) & (CSR_WIFI_ALIGN_BYTES-1); - if (align_offset) - { - skb = (struct sk_buff*)bulkdata->d[i].os_net_buf_ptr; - if (skb == NULL) { - unifi_warning(priv, - "_align_bulk_data_buffers: Align offset found (%d) but skb is NULL!\n", - align_offset); - return -EINVAL; - } - if (bulkdata->d[i].data_length == 0) { - unifi_warning(priv, - "_align_bulk_data_buffers: Align offset found (%d) but length is zero\n", - align_offset); - return CSR_RESULT_SUCCESS; - } - unifi_trace(priv, UDBG5, - "Align f-h buffer (0x%p) by %d bytes (skb->data: 0x%p)\n", - bulkdata->d[i].os_data_ptr, align_offset, skb->data); - - - /* Check if there is enough headroom... */ - if (unlikely(skb_headroom(skb) < align_offset)) - { - struct sk_buff *tmp = skb; - - unifi_trace(priv, UDBG5, "Headroom not enough - realloc it\n"); - skb = skb_realloc_headroom(skb, align_offset); - if (skb == NULL) { - unifi_error(priv, - "_align_bulk_data_buffers: skb_realloc_headroom failed - signal is dropped\n"); - return -EFAULT; - } - /* Free the old bulk data only if allocation succeeds */ - kfree_skb(tmp); - /* Bulkdata needs to point to the new skb */ - bulkdata->d[i].os_net_buf_ptr = (const unsigned char*)skb; - bulkdata->d[i].os_data_ptr = (const void*)skb->data; - } - /* ... before pushing the data to the right alignment offset */ - skb_push(skb, align_offset); - - } - /* The direction bit is zero for the from-host */ - signal[SIZEOF_SIGNAL_HEADER + (i * SIZEOF_DATAREF) + 1] = align_offset; - - } - return 0; -} /* _align_bulk_data_buffers() */ - - -/* - * --------------------------------------------------------------------------- - * ul_send_signal_unpacked - * - * This function sends a host formatted signal to unifi. - * - * Arguments: - * priv Pointer to driver's private data. - * sigptr Pointer to the signal. - * bulkdata Pointer to the signal's bulk data. - * - * Returns: - * O on success, error code otherwise. - * - * Notes: - * The signals have to be sent in the format described in the host interface - * specification, i.e wire formatted. Certain clients use the host formatted - * structures. The write_pack() transforms the host formatted signal - * into the wired formatted signal. The code is in the core, since the signals - * are defined therefore binded to the host interface specification. - * --------------------------------------------------------------------------- - */ -int -ul_send_signal_unpacked(unifi_priv_t *priv, CSR_SIGNAL *sigptr, - bulk_data_param_t *bulkdata) -{ - u8 sigbuf[UNIFI_PACKED_SIGBUF_SIZE]; - u16 packed_siglen; - CsrResult csrResult; - unsigned long lock_flags; - int r; - - - csrResult = write_pack(sigptr, sigbuf, &packed_siglen); - if (csrResult != CSR_RESULT_SUCCESS) { - unifi_error(priv, "Malformed HIP signal in ul_send_signal_unpacked()\n"); - return CsrHipResultToStatus(csrResult); - } - r = _align_bulk_data_buffers(priv, sigbuf, (bulk_data_param_t*)bulkdata); - if (r) { - return r; - } - - spin_lock_irqsave(&priv->send_signal_lock, lock_flags); - csrResult = unifi_send_signal(priv->card, sigbuf, packed_siglen, bulkdata); - if (csrResult != CSR_RESULT_SUCCESS) { - /* free_bulkdata_buffers(priv, (bulk_data_param_t *)bulkdata); */ - spin_unlock_irqrestore(&priv->send_signal_lock, lock_flags); - return CsrHipResultToStatus(csrResult); - } - spin_unlock_irqrestore(&priv->send_signal_lock, lock_flags); - - return 0; -} /* ul_send_signal_unpacked() */ - - -/* - * --------------------------------------------------------------------------- - * reset_driver_status - * - * This function is called from ul_send_signal_raw() when it detects - * that the SME has sent a MLME-RESET request. - * - * Arguments: - * priv Pointer to device private struct - * - * Returns: - * None. - * --------------------------------------------------------------------------- - */ -static void -reset_driver_status(unifi_priv_t *priv) -{ - priv->sta_wmm_capabilities = 0; -#ifdef CSR_NATIVE_LINUX -#ifdef CSR_SUPPORT_WEXT - priv->wext_conf.flag_associated = 0; - priv->wext_conf.block_controlled_port = CSR_WIFI_ROUTER_PORT_ACTION_8021X_PORT_OPEN; - priv->wext_conf.bss_wmm_capabilities = 0; - priv->wext_conf.disable_join_on_ssid_set = 0; -#endif -#endif -} /* reset_driver_status() */ - - -/* - * --------------------------------------------------------------------------- - * ul_send_signal_raw - * - * This function sends a wire formatted data signal to unifi. - * - * Arguments: - * priv Pointer to driver's private data. - * sigptr Pointer to the signal. - * siglen Length of the signal. - * bulkdata Pointer to the signal's bulk data. - * - * Returns: - * O on success, error code otherwise. - * --------------------------------------------------------------------------- - */ -int -ul_send_signal_raw(unifi_priv_t *priv, unsigned char *sigptr, int siglen, - bulk_data_param_t *bulkdata) -{ - CsrResult csrResult; - unsigned long lock_flags; - int r; - - /* - * Make sure that the signal is updated with the bulk data - * alignment for DMA. - */ - r = _align_bulk_data_buffers(priv, (u8*)sigptr, bulkdata); - if (r) { - return r; - } - - spin_lock_irqsave(&priv->send_signal_lock, lock_flags); - csrResult = unifi_send_signal(priv->card, sigptr, siglen, bulkdata); - if (csrResult != CSR_RESULT_SUCCESS) { - free_bulkdata_buffers(priv, bulkdata); - spin_unlock_irqrestore(&priv->send_signal_lock, lock_flags); - return CsrHipResultToStatus(csrResult); - } - spin_unlock_irqrestore(&priv->send_signal_lock, lock_flags); - - /* - * Since this is use by unicli, if we get an MLME reset request - * we need to initialize a few status parameters - * that the driver uses to make decisions. - */ - if (GET_SIGNAL_ID(sigptr) == CSR_MLME_RESET_REQUEST_ID) { - reset_driver_status(priv); - } - - return 0; -} /* ul_send_signal_raw() */ - - diff --git a/drivers/staging/csr/unifi_clients.h b/drivers/staging/csr/unifi_clients.h deleted file mode 100644 index df853e160ea5..000000000000 --- a/drivers/staging/csr/unifi_clients.h +++ /dev/null @@ -1,129 +0,0 @@ -/* - ***************************************************************************** - * - * FILE : unifi_clients.h - * - * PURPOSE : Private header file for unifi clients. - * - * UDI = UniFi Debug Interface - * - * Copyright (C) 2005-2008 by Cambridge Silicon Radio Ltd. - * - * Refer to LICENSE.txt included with this source code for details on - * the license terms. - * - ***************************************************************************** - */ -#ifndef __LINUX_UNIFI_CLIENTS_H__ -#define __LINUX_UNIFI_CLIENTS_H__ 1 - -#include - -#define MAX_UDI_CLIENTS 8 - -/* The start of the range of process ids allocated for ul clients */ -#define UDI_SENDER_ID_BASE 0xC000 -#define UDI_SENDER_ID_SHIFT 8 - - -/* Structure to hold a UDI logged signal */ -typedef struct { - - /* List link structure */ - struct list_head q; - - /* The message that will be passed to the user app */ - udi_msg_t msg; - - /* Signal body and data follow */ - -} udi_log_t; - - - -typedef struct ul_client ul_client_t; - -typedef void (*udi_event_t)(ul_client_t *client, - const u8 *sigdata, int signal_len, - const bulk_data_param_t *bulkdata, - int dir); - -void logging_handler(void *ospriv, - u8 *sigdata, u32 signal_len, - const bulk_data_param_t *bulkdata, - enum udi_log_direction direction); - - -/* - * Structure describing a bulk data slot. - * The length field is used to indicate empty/occupied state. - */ -typedef struct _bulk_data -{ - unsigned char ptr[2000]; - unsigned int length; -} bulk_data_t; - - -struct ul_client { - /* Index of this client in the ul_clients array. */ - int client_id; - - /* Index of UniFi device to which this client is attached. */ - int instance; - - /* Flag to say whether this client has been enabled. */ - int udi_enabled; - - /* Value to use in signal->SenderProcessId */ - int sender_id; - - /* Configuration flags, e.g blocking, logging, etc. */ - unsigned int configuration; - - udi_event_t event_hook; - - /* A list to hold signals received from UniFi for reading by read() */ - struct list_head udi_log; - - /* Semaphore to protect the udi_log list */ - struct semaphore udi_sem; - - /* - * Linux waitqueue to support blocking read and poll. - * Logging clients should wait on udi_log. while - * blocking clients should wait on wake_up_wq. - */ - wait_queue_head_t udi_wq; - CSR_SIGNAL* reply_signal; - bulk_data_t* reply_bulkdata[UNIFI_MAX_DATA_REFERENCES]; - - u16 signal_filter[SIG_FILTER_SIZE]; - - - /* ------------------------------------------------------------------- */ - /* Code below here is used by the sme_native configuration only */ - - /* Flag to wake up blocking clients waiting on udi_wq. */ - int wake_up_wq_id; - - /* - * A 0x00 - 0x0F mask to apply in signal->SenderProcessId. - * Every time we do a blocking mlme request we increase this value. - * The mlme_wait_for_reply() will wait for this sequence number. - * Only the MLME blocking functions update this field. - */ - unsigned char seq_no; - - /* - * A 0x00 - 0x0F counter, containing the sequence number of - * the signal that this client has last received. - * Only the MLME blocking functions update this field. - */ - unsigned char wake_seq_no; - - unifiio_snap_filter_t snap_filter; -}; /* struct ul_client */ - - -#endif /* __LINUX_UNIFI_CLIENTS_H__ */ diff --git a/drivers/staging/csr/unifi_config.h b/drivers/staging/csr/unifi_config.h deleted file mode 100644 index fe119707844a..000000000000 --- a/drivers/staging/csr/unifi_config.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * --------------------------------------------------------------------------- - * - * FILE: unifi_config.h - * - * PURPOSE: - * This header file provides parameters that configure the operation - * of the driver. - * - * Copyright (C) 2006-2008 by Cambridge Silicon Radio Ltd. - * - * Refer to LICENSE.txt included with this source code for details on - * the license terms. - * - * --------------------------------------------------------------------------- - */ -#ifndef __UNIFI_CONFIG_H__ -#define __UNIFI_CONFIG_H__ 1 - -/* - * Override for the SDIO function block size on this host. When byte mode CMD53s - * are not used/supported by the SD host controller, transfers are padded up to - * the next block boundary. The 512-byte default on UF6xxx wastes too much space - * on the chip, so the block size is reduced to support this configuration. - */ -#define CSR_WIFI_HIP_SDIO_BLOCK_SIZE 64 - -/* Define the number of mini-coredump buffers to allocate at startup. These are - * used to record chip status for the last n unexpected resets. - */ -#define CSR_WIFI_HIP_NUM_COREDUMP_BUFFERS 5 - - -#endif /* __UNIFI_CONFIG_H__ */ diff --git a/drivers/staging/csr/unifi_dbg.c b/drivers/staging/csr/unifi_dbg.c deleted file mode 100644 index 38d57085a26a..000000000000 --- a/drivers/staging/csr/unifi_dbg.c +++ /dev/null @@ -1,110 +0,0 @@ -/* - * *************************************************************************** - * FILE: unifi_dbg.c - * - * PURPOSE: - * Handle debug signals received from UniFi. - * - * Copyright (C) 2007-2008 by Cambridge Silicon Radio Ltd. - * - * Refer to LICENSE.txt included with this source code for details on - * the license terms. - * - * *************************************************************************** - */ -#include "unifi_priv.h" - -/* - * --------------------------------------------------------------------------- - * debug_string_indication - * debug_word16_indication - * - * Handlers for debug indications. - * - * Arguments: - * priv Pointer to private context structure. - * - * Returns: - * None. - * --------------------------------------------------------------------------- - */ -void -debug_string_indication(unifi_priv_t *priv, const unsigned char *extra, unsigned int extralen) -{ - const unsigned int maxlen = sizeof(priv->last_debug_string) - 1; - - if (extralen > maxlen) { - extralen = maxlen; - } - - strncpy(priv->last_debug_string, extra, extralen); - - /* Make sure the string is terminated */ - priv->last_debug_string[extralen] = '\0'; - - unifi_info(priv, "unifi debug: %s\n", priv->last_debug_string); - -} /* debug_string_indication() */ - - - -void -debug_word16_indication(unifi_priv_t *priv, const CSR_SIGNAL *sigptr) -{ - int i; - - if (priv == NULL) { - unifi_info(priv, "Priv is NULL\n"); - return; - } - - for (i = 0; i < 16; i++) { - priv->last_debug_word16[i] = - sigptr->u.DebugWord16Indication.DebugWords[i]; - } - - if (priv->last_debug_word16[0] == 0xFA11) { - unsigned long ts; - ts = (priv->last_debug_word16[6] << 16) | priv->last_debug_word16[5]; - unifi_info(priv, " %10lu: %s fault %04x, arg %04x (x%d)\n", - ts, - priv->last_debug_word16[3] == 0x8000 ? "MAC" : - priv->last_debug_word16[3] == 0x4000 ? "PHY" : - "???", - priv->last_debug_word16[1], - priv->last_debug_word16[2], - priv->last_debug_word16[4]); - } - else if (priv->last_debug_word16[0] != 0xDBAC) - /* suppress SDL Trace output (note: still available to unicli). */ - { - unifi_info(priv, "unifi debug: %04X %04X %04X %04X %04X %04X %04X %04X\n", - priv->last_debug_word16[0], priv->last_debug_word16[1], - priv->last_debug_word16[2], priv->last_debug_word16[3], - priv->last_debug_word16[4], priv->last_debug_word16[5], - priv->last_debug_word16[6], priv->last_debug_word16[7]); - unifi_info(priv, " %04X %04X %04X %04X %04X %04X %04X %04X\n", - priv->last_debug_word16[8], priv->last_debug_word16[9], - priv->last_debug_word16[10], priv->last_debug_word16[11], - priv->last_debug_word16[12], priv->last_debug_word16[13], - priv->last_debug_word16[14], priv->last_debug_word16[15]); - } - -} /* debug_word16_indication() */ - - -void -debug_generic_indication(unifi_priv_t *priv, const CSR_SIGNAL *sigptr) -{ - unifi_info(priv, "debug: %04X %04X %04X %04X %04X %04X %04X %04X\n", - sigptr->u.DebugGenericIndication.DebugWords[0], - sigptr->u.DebugGenericIndication.DebugWords[1], - sigptr->u.DebugGenericIndication.DebugWords[2], - sigptr->u.DebugGenericIndication.DebugWords[3], - sigptr->u.DebugGenericIndication.DebugWords[4], - sigptr->u.DebugGenericIndication.DebugWords[5], - sigptr->u.DebugGenericIndication.DebugWords[6], - sigptr->u.DebugGenericIndication.DebugWords[7]); - -} /* debug_generic_indication() */ - diff --git a/drivers/staging/csr/unifi_event.c b/drivers/staging/csr/unifi_event.c deleted file mode 100644 index 71fdb2180e3d..000000000000 --- a/drivers/staging/csr/unifi_event.c +++ /dev/null @@ -1,692 +0,0 @@ -/* - * *************************************************************************** - * FILE: unifi_event.c - * - * PURPOSE: - * Process the signals received by UniFi. - * It is part of the porting exercise. - * - * Copyright (C) 2009 by Cambridge Silicon Radio Ltd. - * - * Refer to LICENSE.txt included with this source code for details on - * the license terms. - * - * *************************************************************************** - */ - - -/* - * Porting notes: - * The implementation of unifi_receive_event() in Linux is fairly complicated. - * The linux driver support multiple userspace applications and several - * build configurations, so the received signals are processed by different - * processes and multiple times. - * In a simple implementation, this function needs to deliver: - * - The MLME-UNITDATA.ind signals to the Rx data plane and to the Traffic - * Analysis using unifi_ta_sample(). - * - The MLME-UNITDATA-STATUS.ind signals to the Tx data plane. - * - All the other signals to the SME using unifi_sys_hip_ind(). - */ - -#include "csr_wifi_hip_unifi.h" -#include "csr_wifi_hip_conversions.h" -#include "unifi_priv.h" - - -/* - * --------------------------------------------------------------------------- - * send_to_client - * - * Helper for unifi_receive_event. - * - * This function forwards a signal to one client. - * - * Arguments: - * priv Pointer to driver's private data. - * client Pointer to the client structure. - * receiver_id The reciever id of the signal. - * sigdata Pointer to the packed signal buffer. - * siglen Length of the packed signal. - * bulkdata Pointer to the signal's bulk data. - * - * Returns: - * None. - * - * --------------------------------------------------------------------------- - */ -static void send_to_client(unifi_priv_t *priv, ul_client_t *client, - int receiver_id, - unsigned char *sigdata, int siglen, - const bulk_data_param_t *bulkdata) -{ - if (client && client->event_hook) { - /*unifi_trace(priv, UDBG3, - "Receive: client %d, (s:0x%X, r:0x%X) - Signal 0x%.4X \n", - client->client_id, client->sender_id, receiver_id, - CSR_GET_UINT16_FROM_LITTLE_ENDIAN(sigdata));*/ - - client->event_hook(client, sigdata, siglen, bulkdata, UDI_TO_HOST); - } -} - -/* - * --------------------------------------------------------------------------- - * process_pkt_data_ind - * - * Dispatcher for received signals. - * - * This function receives the 'to host' signals and forwards - * them to the unifi linux clients. - * - * Arguments: - * priv Context - * sigdata Pointer to the packed signal buffer(Its in form of MA-PACKET.ind). - * bulkdata Pointer to signal's bulkdata - * freeBulkData Pointer to a flag which gets set if the bulkdata needs to - * be freed after calling the logging handlers. If it is not - * set the bulkdata must be freed by the MLME handler or - * passed to the network stack. - * Returns: - * TRUE if the packet should be routed to the SME etc. - * FALSE if the packet is for the driver or network stack - * --------------------------------------------------------------------------- - */ -static u8 check_routing_pkt_data_ind(unifi_priv_t *priv, - u8 *sigdata, - const bulk_data_param_t* bulkdata, - u8 *freeBulkData, - netInterface_priv_t *interfacePriv) -{ - u16 frmCtrl, receptionStatus, frmCtrlSubType; - u8 *macHdrLocation; - u8 interfaceTag; - u8 isDataFrame; - u8 isProtocolVerInvalid = FALSE; - u8 isDataFrameSubTypeNoData = FALSE; - -#ifdef CSR_WIFI_SECURITY_WAPI_ENABLE - static const u8 wapiProtocolIdSNAPHeader[] = {0x88, 0xb4}; - static const u8 wapiProtocolIdSNAPHeaderOffset = 6; - u8 *destAddr; - u8 *srcAddr; - u8 isWapiUnicastPkt = FALSE; - -#ifdef CSR_WIFI_SECURITY_WAPI_QOSCTRL_MIC_WORKAROUND - u16 qosControl; -#endif - - u8 llcSnapHeaderOffset = 0; - - destAddr = (u8 *) bulkdata->d[0].os_data_ptr + MAC_HEADER_ADDR1_OFFSET; - srcAddr = (u8 *) bulkdata->d[0].os_data_ptr + MAC_HEADER_ADDR2_OFFSET; - - /*Individual/Group bit - Bit 0 of first byte*/ - isWapiUnicastPkt = (!(destAddr[0] & 0x01)) ? TRUE : FALSE; -#endif - -#define CSR_WIFI_MA_PKT_IND_RECEPTION_STATUS_OFFSET sizeof(CSR_SIGNAL_PRIMITIVE_HEADER) + 22 - - *freeBulkData = FALSE; - - /* Fetch the MAC header location from MA_PKT_IND packet */ - macHdrLocation = (u8 *) bulkdata->d[0].os_data_ptr; - /* Fetch the Frame Control value from MAC header */ - frmCtrl = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(macHdrLocation); - - /* Pull out interface tag from virtual interface identifier */ - interfaceTag = (CSR_GET_UINT16_FROM_LITTLE_ENDIAN(sigdata + 14)) & 0xff; - - /* check for MIC failure before processing the signal */ - receptionStatus = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(sigdata + CSR_WIFI_MA_PKT_IND_RECEPTION_STATUS_OFFSET); - - /* To discard any spurious MIC failures that could be reported by the firmware */ - isDataFrame = ((frmCtrl & IEEE80211_FC_TYPE_MASK) == (IEEE802_11_FC_TYPE_DATA & IEEE80211_FC_TYPE_MASK)) ? TRUE : FALSE; - /* 0x00 is the only valid protocol version*/ - isProtocolVerInvalid = (frmCtrl & IEEE80211_FC_PROTO_VERSION_MASK) ? TRUE : FALSE; - frmCtrlSubType = (frmCtrl & IEEE80211_FC_SUBTYPE_MASK) >> FRAME_CONTROL_SUBTYPE_FIELD_OFFSET; - /*Exclude the no data & reserved sub-types from MIC failure processing*/ - isDataFrameSubTypeNoData = (((frmCtrlSubType>0x03)&&(frmCtrlSubType<0x08)) || (frmCtrlSubType>0x0B)) ? TRUE : FALSE; - if ((receptionStatus == CSR_MICHAEL_MIC_ERROR) && - ((!isDataFrame) || isProtocolVerInvalid || (isDataFrame && isDataFrameSubTypeNoData))) { - /* Currently MIC errors are discarded for frames other than data frames. This might need changing when we start - * supporting 802.11w (Protected Management frames) - */ - *freeBulkData = TRUE; - unifi_trace(priv, UDBG4, "Discarding this frame and ignoring the MIC failure as this is a garbage/non-data/no data frame\n"); - return FALSE; - } - -#ifdef CSR_WIFI_SECURITY_WAPI_ENABLE - - if (receptionStatus == CSR_MICHAEL_MIC_ERROR) { - - if (interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_STA) { - -#ifdef CSR_WIFI_SECURITY_WAPI_QOSCTRL_MIC_WORKAROUND - if ((isDataFrame) && - ((IEEE802_11_FC_TYPE_QOS_DATA & IEEE80211_FC_SUBTYPE_MASK) == (frmCtrl & IEEE80211_FC_SUBTYPE_MASK)) && - (priv->isWapiConnection)) - { - qosControl = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(macHdrLocation + (((frmCtrl & IEEE802_11_FC_TO_DS_MASK) && (frmCtrl & IEEE802_11_FC_FROM_DS_MASK)) ? 30 : 24) ); - - unifi_trace(priv, UDBG4, "check_routing_pkt_data_ind() :: Value of the QoS control field - 0x%04x \n", qosControl); - - if (qosControl & IEEE802_11_QC_NON_TID_BITS_MASK) - { - unifi_trace(priv, UDBG4, "Ignore the MIC failure and pass the MPDU to the stack when any of bits [4-15] is set in the QoS control field\n"); - - /*Exclude the MIC [16] and the PN [16] that are appended by the firmware*/ - ((bulk_data_param_t*)bulkdata)->d[0].data_length = bulkdata->d[0].data_length - 32; - - /*Clear the reception status of the signal (CSR_RX_SUCCESS)*/ - *(sigdata + CSR_WIFI_MA_PKT_IND_RECEPTION_STATUS_OFFSET) = 0x00; - *(sigdata + CSR_WIFI_MA_PKT_IND_RECEPTION_STATUS_OFFSET+1) = 0x00; - - *freeBulkData = FALSE; - - return FALSE; - } - } -#endif - /* If this MIC ERROR reported by the firmware is either for - * [1] a WAPI Multicast MPDU and the Multicast filter has NOT been set (It is set only when group key index (MSKID) = 1 in Group Rekeying) OR - * [2] a WAPI Unicast MPDU and either the CONTROL PORT is open or the WAPI Unicast filter or filter(s) is NOT set - * then report a MIC FAILURE indication to the SME. - */ -#ifndef CSR_WIFI_SECURITY_WAPI_SW_ENCRYPTION - if ((priv->wapi_multicast_filter == 0) || isWapiUnicastPkt) { -#else - /*When SW encryption is enabled and USKID=1 (wapi_unicast_filter = 1), we are expected - *to receive MIC failure INDs for unicast MPDUs*/ - if ( ((priv->wapi_multicast_filter == 0) && !isWapiUnicastPkt) || - ((priv->wapi_unicast_filter == 0) && isWapiUnicastPkt) ) { -#endif - /*Discard the frame*/ - *freeBulkData = TRUE; - unifi_trace(priv, UDBG4, "Discarding the contents of the frame with MIC failure \n"); - - if (isWapiUnicastPkt && - ((uf_sme_port_state(priv, srcAddr, UF_CONTROLLED_PORT_Q, interfaceTag) != CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_OPEN)|| -#ifndef CSR_WIFI_SECURITY_WAPI_SW_ENCRYPTION - (priv->wapi_unicast_filter) || -#endif - (priv->wapi_unicast_queued_pkt_filter))) { - - /* Workaround to handle MIC failures reported by the firmware for encrypted packets from the AP - * while we are in the process of re-association induced by unsupported WAPI Unicast key index - * - Discard the packets with MIC failures "until" we have - * a. negotiated a key, - * b. opened the CONTROL PORT and - * c. the AP has started using the new key - */ - unifi_trace(priv, UDBG4, "Ignoring the MIC failure as either a. CONTROL PORT isn't OPEN or b. Unicast filter is set or c. WAPI AP using old key for buffered pkts\n"); - - /*Ignore this MIC failure*/ - return FALSE; - - }/*WAPI re-key specific workaround*/ - - unifi_trace(priv, UDBG6, "check_routing_pkt_data_ind - MIC FAILURE : interfaceTag %x Src Addr %x:%x:%x:%x:%x:%x\n", - interfaceTag, srcAddr[0], srcAddr[1], srcAddr[2], srcAddr[3], srcAddr[4], srcAddr[5]); - unifi_trace(priv, UDBG6, "check_routing_pkt_data_ind - MIC FAILURE : Dest Addr %x:%x:%x:%x:%x:%x\n", - destAddr[0], destAddr[1], destAddr[2], destAddr[3], destAddr[4], destAddr[5]); - unifi_trace(priv, UDBG6, "check_routing_pkt_data_ind - MIC FAILURE : Control Port State - 0x%.4X \n", - uf_sme_port_state(priv, srcAddr, UF_CONTROLLED_PORT_Q, interfaceTag)); - - unifi_error(priv, "MIC failure in %s\n", __FUNCTION__); - - /*Report the MIC failure to the SME*/ - return TRUE; - } - }/* STA mode */ - else { - /* Its AP Mode . Just Return */ - *freeBulkData = TRUE; - unifi_error(priv, "MIC failure in %s\n", __FUNCTION__); - return TRUE; - } /* AP mode */ - }/* MIC error */ -#else - if (receptionStatus == CSR_MICHAEL_MIC_ERROR) { - *freeBulkData = TRUE; - unifi_error(priv, "MIC failure in %s\n", __FUNCTION__); - return TRUE; - } -#endif /*CSR_WIFI_SECURITY_WAPI_ENABLE*/ - - unifi_trace(priv, UDBG4, "frmCtrl = 0x%04x %s\n", - frmCtrl, - (((frmCtrl & 0x000c)>>FRAME_CONTROL_TYPE_FIELD_OFFSET) == IEEE802_11_FRAMETYPE_MANAGEMENT) ? - "Mgt" : "Ctrl/Data"); - -#ifdef CSR_WIFI_SECURITY_WAPI_ENABLE - /* To ignore MIC failures reported due to the WAPI AP using the old key for queued packets before - * starting to use the new key negotiated as part of unicast re-keying - */ - if ((interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_STA)&& - isWapiUnicastPkt && - (receptionStatus == CSR_RX_SUCCESS) && - (priv->wapi_unicast_queued_pkt_filter==1)) { - - unifi_trace(priv, UDBG6, "check_routing_pkt_data_ind(): WAPI unicast pkt received when the (wapi_unicast_queued_pkt_filter) is set\n"); - - if (isDataFrame) { - switch(frmCtrl & IEEE80211_FC_SUBTYPE_MASK) { - case IEEE802_11_FC_TYPE_QOS_DATA & IEEE80211_FC_SUBTYPE_MASK: - llcSnapHeaderOffset = MAC_HEADER_SIZE + 2; - break; - case IEEE802_11_FC_TYPE_QOS_NULL & IEEE80211_FC_SUBTYPE_MASK: - case IEEE802_11_FC_TYPE_NULL & IEEE80211_FC_SUBTYPE_MASK: - break; - default: - llcSnapHeaderOffset = MAC_HEADER_SIZE; - } - } - - if (llcSnapHeaderOffset > 0) { - /* QoS data or Data */ - unifi_trace(priv, UDBG6, "check_routing_pkt_data_ind(): SNAP header found & its offset %d\n", llcSnapHeaderOffset); - if (memcmp((u8 *)(bulkdata->d[0].os_data_ptr+llcSnapHeaderOffset+wapiProtocolIdSNAPHeaderOffset), - wapiProtocolIdSNAPHeader, sizeof(wapiProtocolIdSNAPHeader))) { - - unifi_trace(priv, UDBG6, "check_routing_pkt_data_ind(): This is a data & NOT a WAI protocol packet\n"); - /* On the first unicast data pkt that is decrypted successfully after re-keying, reset the filter */ - priv->wapi_unicast_queued_pkt_filter = 0; - unifi_trace(priv, UDBG4, "check_routing_pkt_data_ind(): WAPI AP has started using the new unicast key, no more MIC failures expected (reset filter)\n"); - } - else { - unifi_trace(priv, UDBG6, "check_routing_pkt_data_ind(): WAPI - This is a WAI protocol packet\n"); - } - } - } -#endif - - - switch ((frmCtrl & 0x000c)>>FRAME_CONTROL_TYPE_FIELD_OFFSET) { - case IEEE802_11_FRAMETYPE_MANAGEMENT: - *freeBulkData = TRUE; /* Free (after SME handler copies it) */ - - /* In P2P device mode, filter the legacy AP beacons here */ - if((interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2P)&&\ - ((CSR_WIFI_80211_GET_FRAME_SUBTYPE(macHdrLocation)) == CSR_WIFI_80211_FRAME_SUBTYPE_BEACON)){ - - u8 *pSsid, *pSsidLen; - static u8 P2PWildCardSsid[CSR_WIFI_P2P_WILDCARD_SSID_LENGTH] = {'D', 'I', 'R', 'E', 'C', 'T', '-'}; - - pSsidLen = macHdrLocation + MAC_HEADER_SIZE + CSR_WIFI_BEACON_FIXED_LENGTH; - pSsid = pSsidLen + 2; - - if(*(pSsidLen + 1) >= CSR_WIFI_P2P_WILDCARD_SSID_LENGTH){ - if(memcmp(pSsid, P2PWildCardSsid, CSR_WIFI_P2P_WILDCARD_SSID_LENGTH) == 0){ - unifi_trace(priv, UDBG6, "Received a P2P Beacon, pass it to SME\n"); - return TRUE; - } - } - unifi_trace(priv, UDBG6, "Received a Legacy AP beacon in P2P mode, drop it\n"); - return FALSE; - } - return TRUE; /* Route to SME */ - case IEEE802_11_FRAMETYPE_DATA: - case IEEE802_11_FRAMETYPE_CONTROL: - *freeBulkData = FALSE; /* Network stack or MLME handler frees */ - return FALSE; - default: - unifi_error(priv, "Unhandled frame type %04x\n", frmCtrl); - *freeBulkData = TRUE; /* Not interested, but must free it */ - return FALSE; - } -} - -/* - * --------------------------------------------------------------------------- - * unifi_process_receive_event - * - * Dispatcher for received signals. - * - * This function receives the 'to host' signals and forwards - * them to the unifi linux clients. - * - * Arguments: - * ospriv Pointer to driver's private data. - * sigdata Pointer to the packed signal buffer. - * siglen Length of the packed signal. - * bulkdata Pointer to the signal's bulk data. - * - * Returns: - * None. - * - * Notes: - * The signals are received in the format described in the host interface - * specification, i.e wire formatted. Certain clients use the same format - * to interpret them and other clients use the host formatted structures. - * Each client has to call read_unpack_signal() to transform the wire - * formatted signal into the host formatted signal, if necessary. - * The code is in the core, since the signals are defined therefore - * binded to the host interface specification. - * --------------------------------------------------------------------------- - */ -static void -unifi_process_receive_event(void *ospriv, - u8 *sigdata, u32 siglen, - const bulk_data_param_t *bulkdata) -{ - unifi_priv_t *priv = (unifi_priv_t*)ospriv; - int i, receiver_id; - int client_id; - s16 signal_id; - u8 pktIndToSme = FALSE, freeBulkData = FALSE; - - unifi_trace(priv, UDBG5, "unifi_process_receive_event: " - "%04x %04x %04x %04x %04x %04x %04x %04x (%d)\n", - CSR_GET_UINT16_FROM_LITTLE_ENDIAN((sigdata) + sizeof(s16)*0) & 0xFFFF, - CSR_GET_UINT16_FROM_LITTLE_ENDIAN((sigdata) + sizeof(s16)*1) & 0xFFFF, - CSR_GET_UINT16_FROM_LITTLE_ENDIAN((sigdata) + sizeof(s16)*2) & 0xFFFF, - CSR_GET_UINT16_FROM_LITTLE_ENDIAN((sigdata) + sizeof(s16)*3) & 0xFFFF, - CSR_GET_UINT16_FROM_LITTLE_ENDIAN((sigdata) + sizeof(s16)*4) & 0xFFFF, - CSR_GET_UINT16_FROM_LITTLE_ENDIAN((sigdata) + sizeof(s16)*5) & 0xFFFF, - CSR_GET_UINT16_FROM_LITTLE_ENDIAN((sigdata) + sizeof(s16)*6) & 0xFFFF, - CSR_GET_UINT16_FROM_LITTLE_ENDIAN((sigdata) + sizeof(s16)*7) & 0xFFFF, - siglen); - - receiver_id = CSR_GET_UINT16_FROM_LITTLE_ENDIAN((sigdata) + sizeof(s16)) & 0xFF00; - client_id = (receiver_id & 0x0F00) >> UDI_SENDER_ID_SHIFT; - signal_id = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(sigdata); - - - - /* check for the type of frame received (checks for 802.11 management frames) */ - if (signal_id == CSR_MA_PACKET_INDICATION_ID) - { -#define CSR_MA_PACKET_INDICATION_INTERFACETAG_OFFSET 14 - u8 interfaceTag; - netInterface_priv_t *interfacePriv; - - /* Pull out interface tag from virtual interface identifier */ - interfaceTag = (CSR_GET_UINT16_FROM_LITTLE_ENDIAN(sigdata + CSR_MA_PACKET_INDICATION_INTERFACETAG_OFFSET)) & 0xff; - interfacePriv = priv->interfacePriv[interfaceTag]; - - /* Update activity for this station in case of IBSS */ -#ifdef CSR_SUPPORT_SME - if (interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_IBSS) - { - u8 *saddr; - /* Fetch the source address from mac header */ - saddr = (u8 *) bulkdata->d[0].os_data_ptr + MAC_HEADER_ADDR2_OFFSET; - unifi_trace(priv, UDBG5, - "Updating sta activity in IBSS interfaceTag %x Src Addr %x:%x:%x:%x:%x:%x\n", - interfaceTag, saddr[0], saddr[1], saddr[2], saddr[3], saddr[4], saddr[5]); - - uf_update_sta_activity(priv, interfaceTag, saddr); - } -#endif - - pktIndToSme = check_routing_pkt_data_ind(priv, sigdata, bulkdata, &freeBulkData, interfacePriv); - - unifi_trace(priv, UDBG6, "RX: packet entry point to driver from HIP,pkt to SME ?(%s) \n", (pktIndToSme)? "YES":"NO"); - - } - - if (pktIndToSme) - { - /* Management MA_PACKET_IND for SME */ - if(sigdata != NULL && bulkdata != NULL){ - send_to_client(priv, priv->sme_cli, receiver_id, sigdata, siglen, bulkdata); - } - else{ - unifi_error(priv, "unifi_receive_event2: sigdata or Bulkdata is NULL \n"); - } -#ifdef CSR_NATIVE_LINUX - send_to_client(priv, priv->wext_client, - receiver_id, - sigdata, siglen, bulkdata); -#endif - } - else - { - /* Signals with ReceiverId==0 are also reported to SME / WEXT, - * unless they are data/control MA_PACKET_INDs or VIF_AVAILABILITY_INDs - */ - if (!receiver_id) { - if(signal_id == CSR_MA_VIF_AVAILABILITY_INDICATION_ID) { - uf_process_ma_vif_availibility_ind(priv, sigdata, siglen); - } - else if (signal_id != CSR_MA_PACKET_INDICATION_ID) { - send_to_client(priv, priv->sme_cli, receiver_id, sigdata, siglen, bulkdata); -#ifdef CSR_NATIVE_LINUX - send_to_client(priv, priv->wext_client, - receiver_id, - sigdata, siglen, bulkdata); -#endif - } - else - { - -#if (defined(CSR_SUPPORT_SME) && defined(CSR_WIFI_SECURITY_WAPI_ENABLE)) - #define CSR_MA_PACKET_INDICATION_RECEPTION_STATUS_OFFSET sizeof(CSR_SIGNAL_PRIMITIVE_HEADER) + 22 - netInterface_priv_t *interfacePriv; - u8 interfaceTag; - u16 receptionStatus = CSR_RX_SUCCESS; - - /* Pull out interface tag from virtual interface identifier */ - interfaceTag = (CSR_GET_UINT16_FROM_LITTLE_ENDIAN(sigdata + CSR_MA_PACKET_INDICATION_INTERFACETAG_OFFSET)) & 0xff; - interfacePriv = priv->interfacePriv[interfaceTag]; - - /* check for MIC failure */ - receptionStatus = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(sigdata + CSR_MA_PACKET_INDICATION_RECEPTION_STATUS_OFFSET); - - /* Send a WAPI MPDU to SME for re-check MIC if the respective filter has been set*/ - if ((!freeBulkData) && - (interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_STA) && - (receptionStatus == CSR_MICHAEL_MIC_ERROR) && - ((priv->wapi_multicast_filter == 1) -#ifdef CSR_WIFI_SECURITY_WAPI_SW_ENCRYPTION - || (priv->wapi_unicast_filter == 1) -#endif - )) - { - CSR_SIGNAL signal; - u8 *destAddr; - CsrResult res; - u16 interfaceTag = 0; - u8 isMcastPkt = TRUE; - - unifi_trace(priv, UDBG6, "Received a WAPI data packet when the Unicast/Multicast filter is set\n"); - res = read_unpack_signal(sigdata, &signal); - if (res) { - unifi_error(priv, "Received unknown or corrupted signal (0x%x).\n", - CSR_GET_UINT16_FROM_LITTLE_ENDIAN(sigdata)); - return; - } - - /* Check if the type of MPDU and the respective filter status*/ - destAddr = (u8 *) bulkdata->d[0].os_data_ptr + MAC_HEADER_ADDR1_OFFSET; - isMcastPkt = (destAddr[0] & 0x01) ? TRUE : FALSE; - unifi_trace(priv, UDBG6, - "1.MPDU type: (%s), 2.Multicast filter: (%s), 3. Unicast filter: (%s)\n", - ((isMcastPkt) ? "Multiast":"Unicast"), - ((priv->wapi_multicast_filter) ? "Enabled":"Disabled"), - ((priv->wapi_unicast_filter) ? "Enabled":"Disabled")); - - if (((isMcastPkt) && (priv->wapi_multicast_filter == 1)) -#ifdef CSR_WIFI_SECURITY_WAPI_SW_ENCRYPTION - || ((!isMcastPkt) && (priv->wapi_unicast_filter == 1)) -#endif - ) - { - unifi_trace(priv, UDBG4, "Sending the WAPI MPDU for MIC check\n"); - CsrWifiRouterCtrlWapiRxMicCheckIndSend(priv->CSR_WIFI_SME_IFACEQUEUE, 0, interfaceTag, siglen, sigdata, bulkdata->d[0].data_length, (u8*)bulkdata->d[0].os_data_ptr); - - for (i = 0; i < UNIFI_MAX_DATA_REFERENCES; i++) { - if (bulkdata->d[i].data_length != 0) { - unifi_net_data_free(priv, (void *)&bulkdata->d[i]); - } - } - return; - } - } /* CSR_MA_PACKET_INDICATION_ID */ -#endif /*CSR_SUPPORT_SME && CSR_WIFI_SECURITY_WAPI_ENABLE*/ - } - } - - /* calls the registered clients handler callback func. - * netdev_mlme_event_handler is one of the registered handler used to route - * data packet to network stack or AMP/EAPOL related data to SME - * - * The freeBulkData check ensures that, it has received a management frame and - * the frame needs to be freed here. So not to be passed to netdev handler - */ - if(!freeBulkData){ - if ((client_id < MAX_UDI_CLIENTS) && - (&priv->ul_clients[client_id] != priv->logging_client)) { - unifi_trace(priv, UDBG6, "Call the registered clients handler callback func\n"); - send_to_client(priv, &priv->ul_clients[client_id], - receiver_id, - sigdata, siglen, bulkdata); - } - } - } - - /* - * Free bulk data buffers here unless it is a CSR_MA_PACKET_INDICATION - */ - switch (signal_id) - { -#ifdef UNIFI_SNIFF_ARPHRD - case CSR_MA_SNIFFDATA_INDICATION_ID: -#endif - break; - - case CSR_MA_PACKET_INDICATION_ID: - if (!freeBulkData) - { - break; - } - /* FALLS THROUGH... */ - default: - for (i = 0; i < UNIFI_MAX_DATA_REFERENCES; i++) { - if (bulkdata->d[i].data_length != 0) { - unifi_net_data_free(priv, (void *)&bulkdata->d[i]); - } - } - } - -} /* unifi_process_receive_event() */ - - -#ifdef CSR_WIFI_RX_PATH_SPLIT -static u8 signal_buffer_is_full(unifi_priv_t* priv) -{ - return (((priv->rxSignalBuffer.writePointer + 1)% priv->rxSignalBuffer.size) == (priv->rxSignalBuffer.readPointer)); -} - -void unifi_rx_queue_flush(void *ospriv) -{ - unifi_priv_t *priv = (unifi_priv_t*)ospriv; - - unifi_trace(priv, UDBG4, "rx_wq_handler: RdPtr = %d WritePtr = %d\n", - priv->rxSignalBuffer.readPointer, priv->rxSignalBuffer.writePointer); - if(priv != NULL) { - u8 readPointer = priv->rxSignalBuffer.readPointer; - while (readPointer != priv->rxSignalBuffer.writePointer) - { - rx_buff_struct_t *buf = &priv->rxSignalBuffer.rx_buff[readPointer]; - unifi_trace(priv, UDBG6, "rx_wq_handler: RdPtr = %d WritePtr = %d\n", - readPointer, priv->rxSignalBuffer.writePointer); - unifi_process_receive_event(priv, buf->bufptr, buf->sig_len, &buf->data_ptrs); - readPointer ++; - if(readPointer >= priv->rxSignalBuffer.size) { - readPointer = 0; - } - } - priv->rxSignalBuffer.readPointer = readPointer; - } -} - -void rx_wq_handler(struct work_struct *work) -{ - unifi_priv_t *priv = container_of(work, unifi_priv_t, rx_work_struct); - unifi_rx_queue_flush(priv); -} -#endif - - - -/* - * --------------------------------------------------------------------------- - * unifi_receive_event - * - * Dispatcher for received signals. - * - * This function receives the 'to host' signals and forwards - * them to the unifi linux clients. - * - * Arguments: - * ospriv Pointer to driver's private data. - * sigdata Pointer to the packed signal buffer. - * siglen Length of the packed signal. - * bulkdata Pointer to the signal's bulk data. - * - * Returns: - * None. - * - * Notes: - * The signals are received in the format described in the host interface - * specification, i.e wire formatted. Certain clients use the same format - * to interpret them and other clients use the host formatted structures. - * Each client has to call read_unpack_signal() to transform the wire - * formatted signal into the host formatted signal, if necessary. - * The code is in the core, since the signals are defined therefore - * binded to the host interface specification. - * --------------------------------------------------------------------------- - */ -void -unifi_receive_event(void *ospriv, - u8 *sigdata, u32 siglen, - const bulk_data_param_t *bulkdata) -{ -#ifdef CSR_WIFI_RX_PATH_SPLIT - unifi_priv_t *priv = (unifi_priv_t*)ospriv; - u8 writePointer; - int i; - rx_buff_struct_t * rx_buff; - - unifi_trace(priv, UDBG5, "unifi_receive_event: " - "%04x %04x %04x %04x %04x %04x %04x %04x (%d)\n", - CSR_GET_UINT16_FROM_LITTLE_ENDIAN((sigdata) + sizeof(s16)*0) & 0xFFFF, - CSR_GET_UINT16_FROM_LITTLE_ENDIAN((sigdata) + sizeof(s16)*1) & 0xFFFF, - CSR_GET_UINT16_FROM_LITTLE_ENDIAN((sigdata) + sizeof(s16)*2) & 0xFFFF, - CSR_GET_UINT16_FROM_LITTLE_ENDIAN((sigdata) + sizeof(s16)*3) & 0xFFFF, - CSR_GET_UINT16_FROM_LITTLE_ENDIAN((sigdata) + sizeof(s16)*4) & 0xFFFF, - CSR_GET_UINT16_FROM_LITTLE_ENDIAN((sigdata) + sizeof(s16)*5) & 0xFFFF, - CSR_GET_UINT16_FROM_LITTLE_ENDIAN((sigdata) + sizeof(s16)*6) & 0xFFFF, - CSR_GET_UINT16_FROM_LITTLE_ENDIAN((sigdata) + sizeof(s16)*7) & 0xFFFF, siglen); - if(signal_buffer_is_full(priv)) { - unifi_error(priv, "TO HOST signal queue FULL dropping the PDU\n"); - for (i = 0; i < UNIFI_MAX_DATA_REFERENCES; i++) { - if (bulkdata->d[i].data_length != 0) { - unifi_net_data_free(priv, (void *)&bulkdata->d[i]); - } - } - return; - } - writePointer = priv->rxSignalBuffer.writePointer; - rx_buff = &priv->rxSignalBuffer.rx_buff[writePointer]; - memcpy(rx_buff->bufptr, sigdata, siglen); - rx_buff->sig_len = siglen; - rx_buff->data_ptrs = *bulkdata; - writePointer++; - if(writePointer >= priv->rxSignalBuffer.size) { - writePointer =0; - } - unifi_trace(priv, UDBG4, "unifi_receive_event:writePtr = %d\n", priv->rxSignalBuffer.writePointer); - priv->rxSignalBuffer.writePointer = writePointer; - -#ifndef CSR_WIFI_RX_PATH_SPLIT_DONT_USE_WQ - queue_work(priv->rx_workqueue, &priv->rx_work_struct); -#endif - -#else - unifi_process_receive_event(ospriv, sigdata, siglen, bulkdata); -#endif -} /* unifi_receive_event() */ - diff --git a/drivers/staging/csr/unifi_native.h b/drivers/staging/csr/unifi_native.h deleted file mode 100644 index a73b38e5e480..000000000000 --- a/drivers/staging/csr/unifi_native.h +++ /dev/null @@ -1,257 +0,0 @@ -/* - ***************************************************************************** - * - * FILE : unifi_native.h - * - * PURPOSE : Private header file for unifi driver support to wireless extensions. - * - * UDI = UniFi Debug Interface - * - * Copyright (C) 2005-2008 by Cambridge Silicon Radio Ltd. - * - * Refer to LICENSE.txt included with this source code for details on - * the license terms. - * - ***************************************************************************** - */ -#ifndef __LINUX_UNIFI_NATIVE_H__ -#define __LINUX_UNIFI_NATIVE_H__ 1 - -#include -#include - - -/* - * scan.c wext.c autojoin.c - */ -/* Structure to hold results of a scan */ -typedef struct scan_info { - -/* CSR_MLME_SCAN_INDICATION msi; */ - - unsigned char *info_elems; - int info_elem_length; - -} scan_info_t; - - -#define IE_VECTOR_MAXLEN 1024 - -#ifdef CSR_SUPPORT_WEXT -/* - * Structre to hold the wireless network configuration info. - */ -struct wext_config { - - /* Requested channel when setting up an adhoc network */ - int channel; - - /* wireless extns mode: IW_MODE_AUTO, ADHOC, INFRA, MASTER ... MONITOR */ - int mode; - - /* The capabilities of the currently joined network */ - int capability; - - /* The interval between beacons if we create an IBSS */ - int beacon_period; - - /* - * Power-save parameters - */ - /* The listen interval to ask for in Associate req. */ - int assoc_listen_interval; - /* Power-mode to put UniFi into */ - - unsigned char desired_ssid[UNIFI_MAX_SSID_LEN]; /* the last ESSID set by SIOCSIWESSID */ - int power_mode; - /* Whether to wake for broadcast packets (using DTIM interval) */ - int wakeup_for_dtims; - - /* Currently selected WEP Key ID (0..3) */ - int wep_key_id; - - wep_key_t wep_keys[NUM_WEPKEYS]; - -/* CSR_AUTHENTICATION_TYPE auth_type; */ - int privacy; - - u32 join_failure_timeout; - u32 auth_failure_timeout; - u32 assoc_failure_timeout; - - unsigned char generic_ie[IE_VECTOR_MAXLEN]; - int generic_ie_len; - - struct iw_statistics wireless_stats; - - - /* the ESSID we are currently associated to */ - unsigned char current_ssid[UNIFI_MAX_SSID_LEN]; - /* the BSSID we are currently associated to */ - unsigned char current_bssid[6]; - - /* - * IW_AUTH_WPA_VERSION_DISABLED 0x00000001 - * IW_AUTH_WPA_VERSION_WPA 0x00000002 - * IW_AUTH_WPA_VERSION_WPA2 0x00000004 - */ - unsigned char wpa_version; - - /* - * cipher selection: - * IW_AUTH_CIPHER_NONE 0x00000001 - * IW_AUTH_CIPHER_WEP40 0x00000002 - * IW_AUTH_CIPHER_TKIP 0x00000004 - * IW_AUTH_CIPHER_CCMP 0x00000008 - * IW_AUTH_CIPHER_WEP104 0x00000010 - */ - unsigned char pairwise_cipher_used; - unsigned char group_cipher_used; - - unsigned int frag_thresh; - unsigned int rts_thresh; - - /* U-APSD value, send with Association Request to WMM Enabled APs */ - unsigned char wmm_bss_uapsd_mask; - /* The WMM capabilities of the selected BSS */ - unsigned int bss_wmm_capabilities; - - /* Flag to prevent a join when the ssid is set */ - int disable_join_on_ssid_set; - - /* Scan info */ -#define UNIFI_MAX_SCANS 32 - scan_info_t scan_list[UNIFI_MAX_SCANS]; - int num_scan_info; - - /* Flag on whether non-802.1x packets are allowed out */ -/* CsrWifiRouterPortAction block_controlled_port;*/ - - /* Flag on whether we have completed an authenticate/associate process */ - unsigned int flag_associated : 1; -}; /* struct wext_config */ - -#endif /* CSR_SUPPORT_WEXT */ - - -/* - * wext.c - */ -/*int mlme_set_protection(unifi_priv_t *priv, unsigned char *addr, - CSR_PROTECT_TYPE prot, CSR_KEY_TYPE key_type); -*/ - -/* - * scan.c - */ -/* -void unifi_scan_indication_handler(unifi_priv_t *priv, - const CSR_MLME_SCAN_INDICATION *msg, - const unsigned char *extra, - unsigned int len); -*/ -void unifi_clear_scan_table(unifi_priv_t *priv); -scan_info_t *unifi_get_scan_report(unifi_priv_t *priv, int index); - - -/* - * Utility functions - */ -const unsigned char *unifi_find_info_element(int id, - const unsigned char *info, - int len); -int unifi_add_info_element(unsigned char *info, - int ie_id, - const unsigned char *ie_data, - int ie_len); - -/* - * autojoin.c - */ -/* Higher level fns */ -int unifi_autojoin(unifi_priv_t *priv, const char *ssid); -/* -int unifi_do_scan(unifi_priv_t *priv, int scantype, CSR_BSS_TYPE bsstype, - const char *ssid, int ssid_len); -*/ -int unifi_set_powermode(unifi_priv_t *priv); -int unifi_join_ap(unifi_priv_t *priv, scan_info_t *si); -int unifi_join_bss(unifi_priv_t *priv, unsigned char *macaddr); -int unifi_leave(unifi_priv_t *priv); -unsigned int unifi_get_wmm_bss_capabilities(unifi_priv_t *priv, - unsigned char *ie_vector, - int ie_len, int *ap_capabilities); - -/* - * Status and management. - */ -int uf_init_wext_interface(unifi_priv_t *priv); -void uf_deinit_wext_interface(unifi_priv_t *priv); - -/* - * Function to reset UniFi's 802.11 state by sending MLME-RESET.req - */ -int unifi_reset_state(unifi_priv_t *priv, unsigned char *macaddr, unsigned char set_default_mib); - - -/* - * mlme.c - */ -/* Abort an MLME operation - useful in error recovery */ -int uf_abort_mlme(unifi_priv_t *priv); - -int unifi_mlme_blocking_request(unifi_priv_t *priv, ul_client_t *pcli, - CSR_SIGNAL *sig, bulk_data_param_t *data_ptrs, - int timeout); -void unifi_mlme_copy_reply_and_wakeup_client(ul_client_t *pcli, - CSR_SIGNAL *signal, int signal_len, - const bulk_data_param_t *bulkdata); - -/* - * Utility functions - */ -const char *lookup_reason_code(int reason); -const char *lookup_result_code(int result); - - -/* - * sme_native.c - */ -int uf_sme_init(unifi_priv_t *priv); -void uf_sme_deinit(unifi_priv_t *priv); -int sme_sys_suspend(unifi_priv_t *priv); -int sme_sys_resume(unifi_priv_t *priv); -int sme_mgt_wifi_on(unifi_priv_t *priv); - -/* Callback for event logging to SME clients (unifi_manager) */ -void sme_native_log_event(ul_client_t *client, - const u8 *sig_packed, int sig_len, - const bulk_data_param_t *bulkdata, - int dir); - -void sme_native_mlme_event_handler(ul_client_t *pcli, - const u8 *sig_packed, int sig_len, - const bulk_data_param_t *bulkdata, - int dir); - -/* Task to query statistics from the MIB */ -#define UF_SME_STATS_WQ_TIMEOUT 2000 /* in msecs */ -void uf_sme_stats_wq(struct work_struct *work); - -void uf_native_process_udi_signal(ul_client_t *pcli, - const u8 *packed_signal, - int packed_signal_len, - const bulk_data_param_t *bulkdata, int dir); -#ifdef UNIFI_SNIFF_ARPHRD -/* - * monitor.c - */ -int uf_start_sniff(unifi_priv_t *priv); -/* -void ma_sniffdata_ind(void *ospriv, - const CSR_MA_SNIFFDATA_INDICATION *ind, - const bulk_data_param_t *bulkdata); -*/ -#endif /* ARPHRD_IEEE80211_PRISM */ - -#endif /* __LINUX_UNIFI_NATIVE_H__ */ diff --git a/drivers/staging/csr/unifi_os.h b/drivers/staging/csr/unifi_os.h deleted file mode 100644 index 56a26982070e..000000000000 --- a/drivers/staging/csr/unifi_os.h +++ /dev/null @@ -1,122 +0,0 @@ -/* - * --------------------------------------------------------------------------- - * - * FILE: os_linux/unifi_os.h - * - * PURPOSE: - * This header file provides the OS-dependent facilities for a linux - * environment. - * - * Copyright (C) 2005-2008 by Cambridge Silicon Radio Ltd. - * - * Refer to LICENSE.txt included with this source code for details on - * the license terms. - * - * --------------------------------------------------------------------------- - */ -#ifndef __UNIFI_OS_LINUX_H__ -#define __UNIFI_OS_LINUX_H__ 1 - -#include -#include -#include -#include -#include - -/* - * Needed for core/signals.c - */ -#include - - -/* Define INLINE directive*/ -#define INLINE inline - -/* Malloc and free */ -CsrResult unifi_net_data_malloc(void *ospriv, bulk_data_desc_t *bulk_data_slot, unsigned int size); -void unifi_net_data_free(void *ospriv, bulk_data_desc_t *bulk_data_slot); -#define CSR_WIFI_ALIGN_BYTES 4 -CsrResult unifi_net_dma_align(void *ospriv, bulk_data_desc_t *bulk_data_slot); - -/* - * Byte Order - * Note that __le*_to_cpu and __cpu_to_le* return an unsigned value! - */ -#ifdef __KERNEL__ -#define unifi2host_16(n) (__le16_to_cpu((n))) -#define unifi2host_32(n) (__le32_to_cpu((n))) -#define host2unifi_16(n) (__cpu_to_le16((n))) -#define host2unifi_32(n) (__cpu_to_le32((n))) -#endif - -/* Module parameters */ -extern int unifi_debug; - -/* debugging */ -#ifdef UNIFI_DEBUG -/* - * unifi_debug is a verbosity level for debug messages - * UDBG0 msgs are always printed if UNIFI_DEBUG is defined - * UDBG1 msgs are printed if UNIFI_DEBUG is defined and unifi_debug > 0 - * etc. - */ - -#define ASSERT(cond) \ - do { \ - if (!(cond)) { \ - printk("Assertion failed in %s at %s:%d: %s\n", \ - __FUNCTION__, __FILE__, __LINE__, #cond); \ - } \ - } while (0) - - -void unifi_dump(void *ospriv, int lvl, const char *msg, void *mem, u16 len); -void dump(void *mem, u16 len); -void dump16(void *mem, u16 len); -#ifdef CSR_WIFI_HIP_DEBUG_OFFLINE -void dump_str(void *mem, u16 len); -#endif /* CSR_WIFI_HIP_DEBUG_OFFLINE */ - -void unifi_error(void* ospriv, const char *fmt, ...); -void unifi_warning(void* ospriv, const char *fmt, ...); -void unifi_notice(void* ospriv, const char *fmt, ...); -void unifi_info(void* ospriv, const char *fmt, ...); - -void unifi_trace(void* ospriv, int level, const char *fmt, ...); - -#else - -/* Stubs */ - -#define ASSERT(cond) - -static inline void unifi_dump(void *ospriv, int lvl, const char *msg, void *mem, u16 len) {} -static inline void dump(void *mem, u16 len) {} -static inline void dump16(void *mem, u16 len) {} -#ifdef CSR_WIFI_HIP_DEBUG_OFFLINE -static inline void dump_str(void *mem, u16 len) {} -#endif /* CSR_WIFI_HIP_DEBUG_OFFLINE */ - -void unifi_error_nop(void* ospriv, const char *fmt, ...); -void unifi_trace_nop(void* ospriv, int level, const char *fmt, ...); -#define unifi_error if(1);else unifi_error_nop -#define unifi_warning if(1);else unifi_error_nop -#define unifi_notice if(1);else unifi_error_nop -#define unifi_info if(1);else unifi_error_nop -#define unifi_trace if(1);else unifi_trace_nop - -#endif /* UNIFI_DEBUG */ - - -/* Different levels of diagnostic detail... */ -#define UDBG0 0 /* always prints in debug build */ -#define UDBG1 1 -#define UDBG2 2 -#define UDBG3 3 -#define UDBG4 4 -#define UDBG5 5 -#define UDBG6 6 -#define UDBG7 7 - - -#endif /* __UNIFI_OS_LINUX_H__ */ diff --git a/drivers/staging/csr/unifi_pdu_processing.c b/drivers/staging/csr/unifi_pdu_processing.c deleted file mode 100644 index 04fe9e2acf0e..000000000000 --- a/drivers/staging/csr/unifi_pdu_processing.c +++ /dev/null @@ -1,3729 +0,0 @@ -/* - * --------------------------------------------------------------------------- - * FILE: unifi_pdu_processing.c - * - * PURPOSE: - * This file provides the PDU handling functionality before it gets sent to unfi and after - * receiving a PDU from unifi - * - * Copyright (C) 2010 by Cambridge Silicon Radio Ltd. - * - * Refer to LICENSE.txt included with this source code for details on - * the license terms. - * - * --------------------------------------------------------------------------- - */ - -#include -#include -#include - -#include "csr_wifi_hip_unifi.h" -#include "csr_wifi_hip_conversions.h" -#include "csr_time.h" -#include "unifi_priv.h" -#include - -#ifdef CSR_SUPPORT_SME -static void _update_buffered_pkt_params_after_alignment(unifi_priv_t *priv, bulk_data_param_t *bulkdata, - tx_buffered_packets_t* buffered_pkt) -{ - struct sk_buff *skb ; - u32 align_offset; - - if (priv == NULL || bulkdata == NULL || buffered_pkt == NULL){ - return; - } - - skb = (struct sk_buff*)bulkdata->d[0].os_net_buf_ptr; - align_offset = (u32)(long)(bulkdata->d[0].os_data_ptr) & (CSR_WIFI_ALIGN_BYTES-1); - if(align_offset){ - skb_pull(skb, align_offset); - } - - buffered_pkt->bulkdata.os_data_ptr = bulkdata->d[0].os_data_ptr; - buffered_pkt->bulkdata.data_length = bulkdata->d[0].data_length; - buffered_pkt->bulkdata.os_net_buf_ptr = bulkdata->d[0].os_net_buf_ptr; - buffered_pkt->bulkdata.net_buf_length = bulkdata->d[0].net_buf_length; -} -#endif - -void -unifi_frame_ma_packet_req(unifi_priv_t *priv, CSR_PRIORITY priority, - CSR_RATE TransmitRate, CSR_CLIENT_TAG hostTag, - u16 interfaceTag, CSR_TRANSMISSION_CONTROL transmissionControl, - CSR_PROCESS_ID leSenderProcessId, u8 *peerMacAddress, - CSR_SIGNAL *signal) -{ - - CSR_MA_PACKET_REQUEST *req = &signal->u.MaPacketRequest; - netInterface_priv_t *interfacePriv; - u8 ba_session_idx = 0; - ba_session_tx_struct *ba_session = NULL; - u8 *ba_addr = NULL; - - interfacePriv = priv->interfacePriv[interfaceTag]; - - unifi_trace(priv, UDBG5, - "In unifi_frame_ma_packet_req, Frame for Peer: %pMF\n", - peerMacAddress); - signal->SignalPrimitiveHeader.SignalId = CSR_MA_PACKET_REQUEST_ID; - signal->SignalPrimitiveHeader.ReceiverProcessId = 0; - signal->SignalPrimitiveHeader.SenderProcessId = leSenderProcessId; - - /* Fill the MA-PACKET.req */ - req->Priority = priority; - unifi_trace(priv, UDBG3, "Tx Frame with Priority: 0x%x\n", req->Priority); - - /* A value of 0 is used for auto selection of rates. But for P2P GO case - * for action frames the rate is governed by SME. Hence instead of 0, - * the rate is filled in with the value passed here - */ - req->TransmitRate = TransmitRate; - - /* packets from netdev then no confirm required but packets from - * Nme/Sme eapol data frames requires the confirmation - */ - req->TransmissionControl = transmissionControl; - req->VirtualInterfaceIdentifier = - uf_get_vif_identifier(interfacePriv->interfaceMode, interfaceTag); - memcpy(req->Ra.x, peerMacAddress, ETH_ALEN); - - if (hostTag == 0xffffffff) { - req->HostTag = interfacePriv->tag++; - req->HostTag |= 0x40000000; - unifi_trace(priv, UDBG3, "new host tag assigned = 0x%x\n", req->HostTag); - interfacePriv->tag &= 0x0fffffff; - } else { - req->HostTag = hostTag; - unifi_trace(priv, UDBG3, "host tag got from SME = 0x%x\n", req->HostTag); - } - /* check if BA session exists for the peer MAC address on same tID */ - if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP || - interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO){ - ba_addr = peerMacAddress; - }else{ - ba_addr = interfacePriv->bssid.a; - } - for (ba_session_idx=0; ba_session_idx < MAX_SUPPORTED_BA_SESSIONS_TX; ba_session_idx++){ - ba_session = interfacePriv->ba_session_tx[ba_session_idx]; - if (ba_session){ - if ((!memcmp(ba_session->macAddress.a, ba_addr, ETH_ALEN)) && (ba_session->tID == priority)){ - req->TransmissionControl |= CSR_ALLOW_BA; - break; - } - } - } - - unifi_trace(priv, UDBG5, "leaving unifi_frame_ma_packet_req\n"); -} - -#ifdef CSR_SUPPORT_SME - -#define TRANSMISSION_CONTROL_TRIGGER_MASK 0x0001 -#define TRANSMISSION_CONTROL_EOSP_MASK 0x0002 - -static -int frame_and_send_queued_pdu(unifi_priv_t* priv, tx_buffered_packets_t* buffered_pkt, - CsrWifiRouterCtrlStaInfo_t *staRecord, u8 moreData , u8 eosp) -{ - - CSR_SIGNAL signal; - bulk_data_param_t bulkdata; - int result; - u8 toDs, fromDs, macHeaderLengthInBytes = MAC_HEADER_SIZE; - u8 *qc; - u16 *fc = (u16*)(buffered_pkt->bulkdata.os_data_ptr); - unsigned long lock_flags; - unifi_trace(priv, UDBG3, "frame_and_send_queued_pdu with moreData: %d , EOSP: %d\n", moreData, eosp); - unifi_frame_ma_packet_req(priv, buffered_pkt->priority, buffered_pkt->rate, buffered_pkt->hostTag, - buffered_pkt->interfaceTag, buffered_pkt->transmissionControl, - buffered_pkt->leSenderProcessId, buffered_pkt->peerMacAddress.a, &signal); - bulkdata.d[0].os_data_ptr = buffered_pkt->bulkdata.os_data_ptr; - bulkdata.d[0].data_length = buffered_pkt->bulkdata.data_length; - bulkdata.d[0].os_net_buf_ptr = buffered_pkt->bulkdata.os_net_buf_ptr; - bulkdata.d[0].net_buf_length = buffered_pkt->bulkdata.net_buf_length; - bulkdata.d[1].os_data_ptr = NULL; - bulkdata.d[1].data_length = 0; - bulkdata.d[1].os_net_buf_ptr =0; - bulkdata.d[1].net_buf_length =0; - - if(moreData) { - *fc |= cpu_to_le16(IEEE802_11_FC_MOREDATA_MASK); - } else { - *fc &= cpu_to_le16(~IEEE802_11_FC_MOREDATA_MASK); - } - - if((staRecord != NULL)&& (staRecord->wmmOrQosEnabled == TRUE)) - { - unifi_trace(priv, UDBG3, "frame_and_send_queued_pdu WMM Enabled: %d \n", staRecord->wmmOrQosEnabled); - - toDs = (*fc & cpu_to_le16(IEEE802_11_FC_TO_DS_MASK))?1 : 0; - fromDs = (*fc & cpu_to_le16(IEEE802_11_FC_FROM_DS_MASK))? 1: 0; - - switch(le16_to_cpu(*fc) & IEEE80211_FC_SUBTYPE_MASK) - { - case IEEE802_11_FC_TYPE_QOS_DATA & IEEE80211_FC_SUBTYPE_MASK: - case IEEE802_11_FC_TYPE_QOS_NULL & IEEE80211_FC_SUBTYPE_MASK: - /* If both are set then the Address4 exists (only for AP) */ - if (fromDs && toDs) { - /* 6 is the size of Address4 field */ - macHeaderLengthInBytes += (QOS_CONTROL_HEADER_SIZE + 6); - } else { - macHeaderLengthInBytes += QOS_CONTROL_HEADER_SIZE; - } - - /* If order bit set then HT control field is the part of MAC header */ - if (*fc & cpu_to_le16(IEEE80211_FC_ORDER_MASK)) { - macHeaderLengthInBytes += HT_CONTROL_HEADER_SIZE; - qc = (u8*)(buffered_pkt->bulkdata.os_data_ptr + (macHeaderLengthInBytes-6)); - } else { - qc = (u8*)(buffered_pkt->bulkdata.os_data_ptr + (macHeaderLengthInBytes-2)); - } - *qc = eosp ? *qc | (1 << 4) : *qc & (~(1 << 4)); - break; - default: - if (fromDs && toDs) - macHeaderLengthInBytes += 6; - } - - } - result = ul_send_signal_unpacked(priv, &signal, &bulkdata); - if(result){ - _update_buffered_pkt_params_after_alignment(priv, &bulkdata, buffered_pkt); - } - - /* Decrement the packet counts queued in driver */ - if (result != -ENOSPC) { - /* protect entire counter updation by disabling preemption */ - if (!priv->noOfPktQueuedInDriver) { - unifi_error(priv, "packets queued in driver 0 still decrementing\n"); - } else { - spin_lock_irqsave(&priv->tx_q_lock, lock_flags); - priv->noOfPktQueuedInDriver--; - spin_unlock_irqrestore(&priv->tx_q_lock, lock_flags); - } - /* Sta Record is available for all unicast (except genericMgt Frames) & in other case its NULL */ - if (staRecord) { - spin_lock_irqsave(&priv->staRecord_lock, lock_flags); - if (!staRecord->noOfPktQueued) { - unifi_error(priv, "packets queued in driver per station is 0 still decrementing\n"); - } else { - staRecord->noOfPktQueued--; - } - /* if the STA alive probe frame has failed then reset the saved host tag */ - if (result){ - if (staRecord->nullDataHostTag == buffered_pkt->hostTag){ - staRecord->nullDataHostTag = INVALID_HOST_TAG; - } - } - spin_unlock_irqrestore(&priv->staRecord_lock, lock_flags); - } - - } - return result; -} -#ifdef CSR_SUPPORT_SME -static -void set_eosp_transmit_ctrl(unifi_priv_t *priv, struct list_head *txList) -{ - /* dequeue the tx data packets from the appropriate queue */ - tx_buffered_packets_t *tx_q_item = NULL; - struct list_head *listHead; - struct list_head *placeHolder; - unsigned long lock_flags; - - - unifi_trace(priv, UDBG5, "entering set_eosp_transmit_ctrl\n"); - /* check for list empty */ - if (list_empty(txList)) { - unifi_warning(priv, "In set_eosp_transmit_ctrl, the list is empty\n"); - return; - } - - /* return the last node , and modify it. */ - - spin_lock_irqsave(&priv->tx_q_lock, lock_flags); - list_for_each_prev_safe(listHead, placeHolder, txList) { - tx_q_item = list_entry(listHead, tx_buffered_packets_t, q); - tx_q_item->transmissionControl |= TRANSMISSION_CONTROL_EOSP_MASK; - tx_q_item->transmissionControl = (tx_q_item->transmissionControl & ~(CSR_NO_CONFIRM_REQUIRED)); - unifi_trace(priv, UDBG1, - "set_eosp_transmit_ctrl Transmission Control = 0x%x hostTag = 0x%x \n", tx_q_item->transmissionControl, tx_q_item->hostTag); - unifi_trace(priv, UDBG3, "in set_eosp_transmit_ctrl no.of buffered frames %d\n", priv->noOfPktQueuedInDriver); - break; - } - spin_unlock_irqrestore(&priv->tx_q_lock, lock_flags); - unifi_trace(priv, UDBG1, "List Empty %d\n", list_empty(txList)); - unifi_trace(priv, UDBG5, "leaving set_eosp_transmit_ctrl\n"); - return; -} - -static -void send_vif_availibility_rsp(unifi_priv_t *priv, CSR_VIF_IDENTIFIER vif, CSR_RESULT_CODE resultCode) -{ - CSR_SIGNAL signal; - CSR_MA_VIF_AVAILABILITY_RESPONSE *rsp; - bulk_data_param_t *bulkdata = NULL; - int r; - - unifi_trace(priv, UDBG3, "send_vif_availibility_rsp : invoked with resultCode = %d \n", resultCode); - - memset(&signal, 0, sizeof(CSR_SIGNAL)); - rsp = &signal.u.MaVifAvailabilityResponse; - rsp->VirtualInterfaceIdentifier = vif; - rsp->ResultCode = resultCode; - signal.SignalPrimitiveHeader.SignalId = CSR_MA_VIF_AVAILABILITY_RESPONSE_ID; - signal.SignalPrimitiveHeader.ReceiverProcessId = 0; - signal.SignalPrimitiveHeader.SenderProcessId = priv->netdev_client->sender_id; - - /* Send the signal to UniFi */ - r = ul_send_signal_unpacked(priv, &signal, bulkdata); - if(r) { - unifi_error(priv, "Availibility response sending failed %x status %d\n", vif, r); - } - else { - unifi_trace(priv, UDBG3, "send_vif_availibility_rsp : status = %d \n", r); - } -} -#endif - -static -void verify_and_accomodate_tx_packet(unifi_priv_t *priv) -{ - tx_buffered_packets_t *tx_q_item; - unsigned long lock_flags; - struct list_head *listHead, *list; - struct list_head *placeHolder; - u8 i, j, eospFramedeleted=0; - u8 thresholdExcedeDueToBroadcast = TRUE; - /* it will be made it interface Specific in the future when multi interfaces are supported , - right now interface 0 is considered */ - netInterface_priv_t *interfacePriv = priv->interfacePriv[0]; - CsrWifiRouterCtrlStaInfo_t *staInfo = NULL; - - unifi_trace(priv, UDBG3, "entering verify_and_accomodate_tx_packet\n"); - - for(i = 0; i < UNIFI_MAX_CONNECTIONS; i++) { - staInfo = interfacePriv->staInfo[i]; - if (staInfo && (staInfo->noOfPktQueued >= CSR_WIFI_DRIVER_MAX_PKT_QUEUING_THRESHOLD_PER_PEER)) { - /* remove the first(oldest) packet from the all the access catogory, since data - * packets for station record crossed the threshold limit (64 for AP supporting - * 8 peers) - */ - unifi_trace(priv, UDBG3, "number of station pkts queued= %d for sta id = %d\n", staInfo->noOfPktQueued, staInfo->aid); - for(j = 0; j < MAX_ACCESS_CATOGORY; j++) { - list = &staInfo->dataPdu[j]; - spin_lock_irqsave(&priv->tx_q_lock, lock_flags); - list_for_each_safe(listHead, placeHolder, list) { - tx_q_item = list_entry(listHead, tx_buffered_packets_t, q); - list_del(listHead); - thresholdExcedeDueToBroadcast = FALSE; - unifi_net_data_free(priv, &tx_q_item->bulkdata); - kfree(tx_q_item); - tx_q_item = NULL; - if (!priv->noOfPktQueuedInDriver) { - unifi_error(priv, "packets queued in driver 0 still decrementing in %s\n", __FUNCTION__); - } else { - /* protection provided by spinlock */ - priv->noOfPktQueuedInDriver--; - - } - /* Sta Record is available for all unicast (except genericMgt Frames) & in other case its NULL */ - if (!staInfo->noOfPktQueued) { - unifi_error(priv, "packets queued in driver per station is 0 still decrementing in %s\n", __FUNCTION__); - } else { - spin_lock(&priv->staRecord_lock); - staInfo->noOfPktQueued--; - spin_unlock(&priv->staRecord_lock); - } - break; - } - spin_unlock_irqrestore(&priv->tx_q_lock, lock_flags); - } - } - } - if (thresholdExcedeDueToBroadcast && interfacePriv->noOfbroadcastPktQueued > CSR_WIFI_DRIVER_MINIMUM_BROADCAST_PKT_THRESHOLD ) { - /* Remove the packets from genericMulticastOrBroadCastFrames queue - * (the max packets in driver is reached due to broadcast/multicast frames) - */ - spin_lock_irqsave(&priv->tx_q_lock, lock_flags); - list_for_each_safe(listHead, placeHolder, &interfacePriv->genericMulticastOrBroadCastFrames) { - tx_q_item = list_entry(listHead, tx_buffered_packets_t, q); - if(eospFramedeleted){ - tx_q_item->transmissionControl |= TRANSMISSION_CONTROL_EOSP_MASK; - tx_q_item->transmissionControl = (tx_q_item->transmissionControl & ~(CSR_NO_CONFIRM_REQUIRED)); - unifi_trace(priv, UDBG1, "updating eosp for next packet hostTag:= 0x%x ", tx_q_item->hostTag); - eospFramedeleted =0; - break; - } - - if(tx_q_item->transmissionControl & TRANSMISSION_CONTROL_EOSP_MASK ){ - eospFramedeleted = 1; - } - unifi_trace(priv, UDBG1, "freeing of multicast packets ToC = 0x%x hostTag = 0x%x \n", tx_q_item->transmissionControl, tx_q_item->hostTag); - list_del(listHead); - unifi_net_data_free(priv, &tx_q_item->bulkdata); - kfree(tx_q_item); - priv->noOfPktQueuedInDriver--; - spin_lock(&priv->staRecord_lock); - interfacePriv->noOfbroadcastPktQueued--; - spin_unlock(&priv->staRecord_lock); - if(!eospFramedeleted){ - break; - } - } - spin_unlock_irqrestore(&priv->tx_q_lock, lock_flags); - } - unifi_trace(priv, UDBG3, "leaving verify_and_accomodate_tx_packet\n"); -} - -static -CsrResult enque_tx_data_pdu(unifi_priv_t *priv, bulk_data_param_t *bulkdata, - struct list_head *list, CSR_SIGNAL *signal, - u8 requeueOnSamePos) -{ - - /* queue the tx data packets on to appropriate queue */ - CSR_MA_PACKET_REQUEST *req = &signal->u.MaPacketRequest; - tx_buffered_packets_t *tx_q_item; - unsigned long lock_flags; - - unifi_trace(priv, UDBG5, "entering enque_tx_data_pdu\n"); - if(!list) { - unifi_error(priv, "List is not specified\n"); - return CSR_RESULT_FAILURE; - } - - /* Removes aged packets & adds the incoming packet */ - if (priv->noOfPktQueuedInDriver >= CSR_WIFI_DRIVER_SUPPORT_FOR_MAX_PKT_QUEUEING) { - unifi_trace(priv, UDBG3, "number of pkts queued= %d \n", priv->noOfPktQueuedInDriver); - verify_and_accomodate_tx_packet(priv); - } - - - - tx_q_item = kmalloc(sizeof(tx_buffered_packets_t), GFP_ATOMIC); - if (tx_q_item == NULL) { - unifi_error(priv, - "Failed to allocate %d bytes for tx packet record\n", - sizeof(tx_buffered_packets_t)); - return CSR_RESULT_FAILURE; - } - - /* disable the preemption */ - spin_lock_irqsave(&priv->tx_q_lock, lock_flags); - INIT_LIST_HEAD(&tx_q_item->q); - /* fill the tx_q structure members */ - tx_q_item->bulkdata.os_data_ptr = bulkdata->d[0].os_data_ptr; - tx_q_item->bulkdata.data_length = bulkdata->d[0].data_length; - tx_q_item->bulkdata.os_net_buf_ptr = bulkdata->d[0].os_net_buf_ptr; - tx_q_item->bulkdata.net_buf_length = bulkdata->d[0].net_buf_length; - tx_q_item->interfaceTag = req->VirtualInterfaceIdentifier & 0xff; - tx_q_item->hostTag = req->HostTag; - tx_q_item->leSenderProcessId = signal->SignalPrimitiveHeader.SenderProcessId; - tx_q_item->transmissionControl = req->TransmissionControl; - tx_q_item->priority = req->Priority; - tx_q_item->rate = req->TransmitRate; - memcpy(tx_q_item->peerMacAddress.a, req->Ra.x, ETH_ALEN); - - - - if (requeueOnSamePos) { - list_add(&tx_q_item->q, list); - } else { - list_add_tail(&tx_q_item->q, list); - } - - /* Count of packet queued in driver */ - priv->noOfPktQueuedInDriver++; - spin_unlock_irqrestore(&priv->tx_q_lock, lock_flags); - unifi_trace(priv, UDBG5, "leaving enque_tx_data_pdu\n"); - return CSR_RESULT_SUCCESS; -} - -#ifdef CSR_WIFI_REQUEUE_PACKET_TO_HAL -CsrResult unifi_reque_ma_packet_request (void *ospriv, u32 host_tag, - u16 txStatus, bulk_data_desc_t *bulkDataDesc) -{ - CsrResult status = CSR_RESULT_SUCCESS; - unifi_priv_t *priv = (unifi_priv_t*)ospriv; - netInterface_priv_t *interfacePriv; - struct list_head *list = NULL; - CsrWifiRouterCtrlStaInfo_t *staRecord = NULL; - bulk_data_param_t bulkData; - CSR_SIGNAL signal; - CSR_PRIORITY priority = 0; - u16 interfaceTag = 0; - unifi_TrafficQueue priority_q; - u16 frameControl = 0, frameType = 0; - unsigned long lock_flags; - - interfacePriv = priv->interfacePriv[interfaceTag]; - - /* If the current mode is not AP or P2PGO then just return failure - * to clear the hip slot - */ - if(!((interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP) || - (interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO))) { - return CSR_RESULT_FAILURE; - } - - unifi_trace(priv, UDBG6, "unifi_reque_ma_packet_request: host_tag = 0x%x\n", host_tag); - - staRecord = CsrWifiRouterCtrlGetStationRecordFromPeerMacAddress(priv, - (((u8 *) bulkDataDesc->os_data_ptr) + 4), - interfaceTag); - if (NULL == staRecord) { - unifi_trace(priv, UDBG5, "unifi_reque_ma_packet_request: Invalid STA record \n"); - return CSR_RESULT_FAILURE; - } - - /* Update TIM if MA-PACKET.cfm fails with status as Tx-retry-limit or No-BSS and then just return failure - * to clear the hip slot associated with the Packet - */ - if (CSR_TX_RETRY_LIMIT == txStatus || CSR_TX_NO_BSS == txStatus) { - if (staRecord->timSet == CSR_WIFI_TIM_RESET || staRecord->timSet == CSR_WIFI_TIM_RESETTING) - { - unifi_trace(priv, UDBG2, "unifi_reque_ma_packet_request: CFM failed with Retry Limit or No BSS-->update TIM\n"); - if (!staRecord->timRequestPendingFlag) { - update_tim(priv, staRecord->aid, 1, interfaceTag, staRecord->assignedHandle); - } - else { - /* Cache the TimSet value so that it will processed immidiatly after - * completing the current setTim Request - */ - staRecord->updateTimReqQueued = 1; - unifi_trace(priv, UDBG6, "unifi_reque_ma_packet_request: One more UpdateTim Request(:%d)Queued for AID %x\n", - staRecord->updateTimReqQueued, staRecord->aid); - } - } - return CSR_RESULT_FAILURE; - } - else if ((CSR_TX_LIFETIME == txStatus) || (CSR_TX_BLOCK_ACK_TIMEOUT == txStatus) || - (CSR_TX_FAIL_TRANSMISSION_VIF_INTERRUPTED == txStatus) || - (CSR_TX_REJECTED_PEER_STATION_SLEEPING == txStatus) || - (CSR_TX_REJECTED_DTIM_STARTED == txStatus)) { - /* Extract the Frame control and the frame type */ - frameControl = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(bulkDataDesc->os_data_ptr); - frameType = ((frameControl & IEEE80211_FC_TYPE_MASK) >> FRAME_CONTROL_TYPE_FIELD_OFFSET); - - /* Mgmt frames will not be re-queued for Tx - * so just return failure to clear the hip slot - */ - if (IEEE802_11_FRAMETYPE_MANAGEMENT == frameType) { - return CSR_RESULT_FAILURE; - } - else if (IEEE802_11_FRAMETYPE_DATA == frameType) { - /* QOS NULL and DATA NULL frames will not be re-queued for Tx - * so just return failure to clear the hip slot - */ - if ((((frameControl & IEEE80211_FC_SUBTYPE_MASK) >> FRAME_CONTROL_SUBTYPE_FIELD_OFFSET) == QOS_DATA_NULL) || - (((frameControl & IEEE80211_FC_SUBTYPE_MASK) >> FRAME_CONTROL_SUBTYPE_FIELD_OFFSET)== DATA_NULL )) { - return CSR_RESULT_FAILURE; - } - } - - /* Extract the Packet priority */ - if (TRUE == staRecord->wmmOrQosEnabled) { - u16 qosControl = 0; - u8 dataFrameType = 0; - - dataFrameType =((frameControl & IEEE80211_FC_SUBTYPE_MASK) >> 4); - - if (dataFrameType == QOS_DATA) { - /* QoS control field is offset from frame control by 2 (frame control) - * + 2 (duration/ID) + 2 (sequence control) + 3*ETH_ALEN or 4*ETH_ALEN - */ - if((frameControl & IEEE802_11_FC_TO_DS_MASK) && (frameControl & IEEE802_11_FC_FROM_DS_MASK)) { - qosControl= CSR_GET_UINT16_FROM_LITTLE_ENDIAN(bulkDataDesc->os_data_ptr + 30); - } - else { - qosControl = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(bulkDataDesc->os_data_ptr + 24); - } - } - - priority = (CSR_PRIORITY)(qosControl & IEEE802_11_QC_TID_MASK); - - if (priority < CSR_QOS_UP0 || priority > CSR_QOS_UP7) { - unifi_trace(priv, UDBG5, "unifi_reque_ma_packet_request: Invalid priority:%x \n", priority); - return CSR_RESULT_FAILURE; - } - } - else { - priority = CSR_CONTENTION; - } - - /* Frame Bulk data to requeue it back to HAL Queues */ - bulkData.d[0].os_data_ptr = bulkDataDesc->os_data_ptr; - bulkData.d[0].data_length = bulkDataDesc->data_length; - bulkData.d[0].os_net_buf_ptr = bulkDataDesc->os_net_buf_ptr; - bulkData.d[0].net_buf_length = bulkDataDesc->net_buf_length; - - bulkData.d[1].os_data_ptr = NULL; - bulkData.d[1].os_net_buf_ptr = NULL; - bulkData.d[1].data_length = bulkData.d[1].net_buf_length = 0; - - /* Initialize signal to zero */ - memset(&signal, 0, sizeof(CSR_SIGNAL)); - - /* Frame MA Packet Req */ - unifi_frame_ma_packet_req(priv, priority, 0, host_tag, - interfaceTag, CSR_NO_CONFIRM_REQUIRED, - priv->netdev_client->sender_id, - staRecord->peerMacAddress.a, &signal); - - /* Find the Q-Priority */ - priority_q = unifi_frame_priority_to_queue(priority); - list = &staRecord->dataPdu[priority_q]; - - /* Place the Packet on to HAL Queue */ - status = enque_tx_data_pdu(priv, &bulkData, list, &signal, TRUE); - - /* Update the Per-station queued packet counter */ - if (!status) { - spin_lock_irqsave(&priv->staRecord_lock, lock_flags); - staRecord->noOfPktQueued++; - spin_unlock_irqrestore(&priv->staRecord_lock, lock_flags); - } - } - else { - /* Packet will not be re-queued for any of the other MA Packet Tx failure - * reasons so just return failure to clear the hip slot - */ - return CSR_RESULT_FAILURE; - } - - return status; -} -#endif - -static void is_all_ac_deliver_enabled_and_moredata(CsrWifiRouterCtrlStaInfo_t *staRecord, u8 *allDeliveryEnabled, u8 *dataAvailable) -{ - u8 i; - *allDeliveryEnabled = TRUE; - for (i = 0 ;i < MAX_ACCESS_CATOGORY; i++) { - if (!IS_DELIVERY_ENABLED(staRecord->powersaveMode[i])) { - /* One is is not Delivery Enabled */ - *allDeliveryEnabled = FALSE; - break; - } - } - if (*allDeliveryEnabled) { - *dataAvailable = (!list_empty(&staRecord->dataPdu[0]) || !list_empty(&staRecord->dataPdu[1]) - ||!list_empty(&staRecord->dataPdu[2]) ||!list_empty(&staRecord->dataPdu[3]) - ||!list_empty(&staRecord->mgtFrames)); - } -} - -/* - * --------------------------------------------------------------------------- - * uf_handle_tim_cfm - * - * - * This function updates tim status in host depending confirm status from firmware - * - * Arguments: - * priv Pointer to device private context struct - * cfm CSR_MLME_SET_TIM_CONFIRM - * receiverProcessId SenderProcessID to fetch handle & timSet status - * - * --------------------------------------------------------------------------- - */ -void uf_handle_tim_cfm(unifi_priv_t *priv, CSR_MLME_SET_TIM_CONFIRM *cfm, u16 receiverProcessId) -{ - u8 handle = CSR_WIFI_GET_STATION_HANDLE_FROM_RECEIVER_ID(receiverProcessId); - u8 timSetStatus = CSR_WIFI_GET_TIMSET_STATE_FROM_RECEIVER_ID(receiverProcessId); - u16 interfaceTag = (cfm->VirtualInterfaceIdentifier & 0xff); - netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag]; - CsrWifiRouterCtrlStaInfo_t *staRecord = NULL; - /* This variable holds what TIM value we wanted to set in firmware */ - u16 timSetValue = 0; - /* Irrespective of interface the count maintained */ - static u8 retryCount = 0; - unsigned long lock_flags; - unifi_trace(priv, UDBG3, "entering %s, handle = %x, timSetStatus = %x\n", __FUNCTION__, handle, timSetStatus); - - if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) { - unifi_warning(priv, "bad interfaceTag = %x\n", interfaceTag); - return; - } - - if ((handle != CSR_WIFI_BROADCAST_OR_MULTICAST_HANDLE) && (handle >= UNIFI_MAX_CONNECTIONS)) { - unifi_warning(priv, "bad station Handle = %x\n", handle); - return; - } - - if (handle != CSR_WIFI_BROADCAST_OR_MULTICAST_HANDLE) { - spin_lock_irqsave(&priv->staRecord_lock, lock_flags); - if ((staRecord = ((CsrWifiRouterCtrlStaInfo_t *) (interfacePriv->staInfo[handle]))) == NULL) { - spin_unlock_irqrestore(&priv->staRecord_lock, lock_flags); - unifi_warning(priv, "uf_handle_tim_cfm: station record is NULL handle = %x\n", handle); - return; - } - spin_unlock_irqrestore(&priv->staRecord_lock, lock_flags); - } - switch(timSetStatus) - { - case CSR_WIFI_TIM_SETTING: - timSetValue = CSR_WIFI_TIM_SET; - break; - case CSR_WIFI_TIM_RESETTING: - timSetValue = CSR_WIFI_TIM_RESET; - break; - default: - unifi_warning(priv, "timSet state is %x: Debug\n", timSetStatus); - return; - } - - /* check TIM confirm for success/failures */ - switch(cfm->ResultCode) - { - case CSR_RC_SUCCESS: - if (handle != CSR_WIFI_BROADCAST_OR_MULTICAST_HANDLE) { - /* Unicast frame & station record available */ - if (timSetStatus == staRecord->timSet) { - staRecord->timSet = timSetValue; - /* fh_cmd_q can also be full at some point of time!, - * resetting count as queue is cleaned by firmware at this point - */ - retryCount = 0; - unifi_trace(priv, UDBG2, "tim (%s) successfully in firmware\n", (timSetValue)?"SET":"RESET"); - } else { - unifi_trace(priv, UDBG3, "receiver processID = %x, success: request & confirm states are not matching in TIM cfm: Debug status = %x, staRecord->timSet = %x, handle = %x\n", - receiverProcessId, timSetStatus, staRecord->timSet, handle); - } - - /* Reset TIM pending flag to send next TIM request */ - staRecord->timRequestPendingFlag = FALSE; - - /* Make sure that one more UpdateTim request is queued, if Queued its value - * should be CSR_WIFI_TIM_SET or CSR_WIFI_TIM_RESET - */ - if (0xFF != staRecord->updateTimReqQueued) - { - /* Process the UpdateTim Request which is queued while previous UpdateTim was in progress */ - if (staRecord->timSet != staRecord->updateTimReqQueued) - { - unifi_trace(priv, UDBG2, "uf_handle_tim_cfm : Processing Queued UpdateTimReq \n"); - - update_tim(priv, staRecord->aid, staRecord->updateTimReqQueued, interfaceTag, handle); - - staRecord->updateTimReqQueued = 0xFF; - } - } - } else { - - interfacePriv->bcTimSet = timSetValue; - /* fh_cmd_q can also be full at some point of time!, - * resetting count as queue is cleaned by firmware at this point - */ - retryCount = 0; - unifi_trace(priv, UDBG3, "tim (%s) successfully for broadcast frame in firmware\n", (timSetValue)?"SET":"RESET"); - - /* Reset DTIM pending flag to send next DTIM request */ - interfacePriv->bcTimSetReqPendingFlag = FALSE; - - /* Make sure that one more UpdateDTim request is queued, if Queued its value - * should be CSR_WIFI_TIM_SET or CSR_WIFI_TIM_RESET - */ - if (0xFF != interfacePriv->bcTimSetReqQueued) - { - /* Process the UpdateTim Request which is queued while previous UpdateTim was in progress */ - if (interfacePriv->bcTimSet != interfacePriv->bcTimSetReqQueued) - { - unifi_trace(priv, UDBG2, "uf_handle_tim_cfm : Processing Queued UpdateDTimReq \n"); - - update_tim(priv, 0, interfacePriv->bcTimSetReqQueued, interfaceTag, 0xFFFFFFFF); - - interfacePriv->bcTimSetReqQueued = 0xFF; - } - } - - } - break; - case CSR_RC_INVALID_PARAMETERS: - case CSR_RC_INSUFFICIENT_RESOURCE: - /* check for max retry limit & send again - * MAX_RETRY_LIMIT is not maintained for each set of transactions..Its generic - * If failure crosses this Limit, we have to take a call to FIX - */ - if (retryCount > UNIFI_MAX_RETRY_LIMIT) { - u8 moreData = FALSE; - retryCount = 0; - /* Because of continuos traffic in fh_cmd_q the tim set request is failing (exceeding retry limit) - * but if we didn't synchronize our timSet varible state with firmware then it can cause below issues - * cond 1. We want to SET tim in firmware if its fails & max retry limit reached - * -> If host set's the timSet to 1, we wont try to send(as max retry reached) update tim but - * firmware is not updated with queue(TIM) status so it wont set TIM in beacon finally host start piling - * up data & wont try to set tim in firmware (This can cause worser performance) - * cond 2. We want to reset tim in firmware it fails & reaches max retry limit - * -> If host sets the timSet to Zero, it wont try to set a TIM request unless we wont have any packets - * to be queued, so beacon unnecessarily advertizes the TIM - */ - - if(staRecord) { - if(!staRecord->wmmOrQosEnabled) { - moreData = (!list_empty(&staRecord->dataPdu[UNIFI_TRAFFIC_Q_CONTENTION]) || - !list_empty(&staRecord->dataPdu[UNIFI_TRAFFIC_Q_VO]) || - !list_empty(&staRecord->mgtFrames)); - } else { - /* Peer is QSTA */ - u8 allDeliveryEnabled = 0, dataAvailable = 0; - /* Check if all AC's are Delivery Enabled */ - is_all_ac_deliver_enabled_and_moredata(staRecord, &allDeliveryEnabled, &dataAvailable); - /*check for more data in non-delivery enabled queues*/ - moreData = (uf_is_more_data_for_non_delivery_ac(staRecord) || (allDeliveryEnabled && dataAvailable)); - - } - /* To avoid cond 1 & 2, check internal Queues status, if we have more Data then set RESET the timSet(0), - * so we are trying to be in sync with firmware & next packets before queuing atleast try to - * set TIM in firmware otherwise it SET timSet(1) - */ - if (moreData) { - staRecord->timSet = CSR_WIFI_TIM_RESET; - } else { - staRecord->timSet = CSR_WIFI_TIM_SET; - } - } else { - /* Its a broadcast frames */ - moreData = (!list_empty(&interfacePriv->genericMulticastOrBroadCastMgtFrames) || - !list_empty(&interfacePriv->genericMulticastOrBroadCastFrames)); - if (moreData) { - update_tim(priv, 0, CSR_WIFI_TIM_SET, interfaceTag, 0xFFFFFFFF); - } else { - update_tim(priv, 0, CSR_WIFI_TIM_RESET, interfaceTag, 0xFFFFFFFF); - } - } - - unifi_error(priv, "no of error's for TIM setting crossed the Limit: verify\n"); - return; - } - retryCount++; - - if (handle != CSR_WIFI_BROADCAST_OR_MULTICAST_HANDLE) { - if (timSetStatus == staRecord->timSet) { - unifi_warning(priv, "tim request failed, retry for AID = %x\n", staRecord->aid); - update_tim(priv, staRecord->aid, timSetValue, interfaceTag, handle); - } else { - unifi_trace(priv, UDBG1, "failure: request & confirm states are not matching in TIM cfm: Debug status = %x, staRecord->timSet = %x\n", - timSetStatus, staRecord->timSet); - } - } else { - unifi_warning(priv, "tim request failed, retry for broadcast frames\n"); - update_tim(priv, 0, timSetValue, interfaceTag, 0xFFFFFFFF); - } - break; - default: - unifi_warning(priv, "tim update request failed resultcode = %x\n", cfm->ResultCode); - } - - unifi_trace(priv, UDBG2, "leaving %s\n", __FUNCTION__); -} - -/* - * --------------------------------------------------------------------------- - * update_tim - * - * - * This function updates tim status in firmware for AID[1 to UNIFI_MAX_CONNECTIONS] or - * AID[0] for broadcast/multicast packets. - * - * NOTE: The LSB (least significant BYTE) of senderId while sending this MLME premitive - * has been modified(utilized) as below - * - * SenderID in signal's SignalPrimitiveHeader is 2 byte the lowe byte bitmap is below - * - * station handle(6 bits) timSet Status (2 bits) - * --------------------- ---------------------- - * 0 0 0 0 0 0 | 0 0 - * - * timSet Status can be one of below: - * - * CSR_WIFI_TIM_RESET - * CSR_WIFI_TIM_RESETTING - * CSR_WIFI_TIM_SET - * CSR_WIFI_TIM_SETTING - * - * Arguments: - * priv Pointer to device private context struct - * aid can be 1 t0 UNIFI_MAX_CONNECTIONS & 0 means multicast/broadcast - * setTim value SET(1) / RESET(0) - * interfaceTag the interfaceID on which activity going on - * handle from (0 <= handle < UNIFI_MAX_CONNECTIONS) - * - * --------------------------------------------------------------------------- - */ -void update_tim(unifi_priv_t * priv, u16 aid, u8 setTim, u16 interfaceTag, u32 handle) -{ - CSR_SIGNAL signal; - s32 r; - CSR_MLME_SET_TIM_REQUEST *req = &signal.u.MlmeSetTimRequest; - bulk_data_param_t *bulkdata = NULL; - netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag]; - u8 senderIdLsb = 0; - CsrWifiRouterCtrlStaInfo_t *staRecord = NULL; - u32 oldTimSetStatus = 0, timSetStatus = 0; - - unifi_trace(priv, UDBG5, "entering the update_tim routine\n"); - - - if (handle == 0xFFFFFFFF) { - handle &= CSR_WIFI_BROADCAST_OR_MULTICAST_HANDLE; - if (setTim == interfacePriv->bcTimSet) - { - unifi_trace(priv, UDBG3, "update_tim, Drop:Hdl=%x, timval=%d, globalTim=%d\n", handle, setTim, interfacePriv->bcTimSet); - return; - } - } else if ((handle != 0xFFFFFFFF) && (handle >= UNIFI_MAX_CONNECTIONS)) { - unifi_warning(priv, "bad station Handle = %x\n", handle); - return; - } - - if (setTim) { - timSetStatus = CSR_WIFI_TIM_SETTING; - } else { - timSetStatus = CSR_WIFI_TIM_RESETTING; - } - - if (handle != CSR_WIFI_BROADCAST_OR_MULTICAST_HANDLE) { - if ((staRecord = ((CsrWifiRouterCtrlStaInfo_t *) (interfacePriv->staInfo[handle]))) == NULL) { - unifi_warning(priv, "station record is NULL in update_tim: handle = %x :debug\n", handle); - return; - } - /* In case of signal sending failed, revert back to old state */ - oldTimSetStatus = staRecord->timSet; - staRecord->timSet = timSetStatus; - } - - /* pack senderID LSB */ - senderIdLsb = CSR_WIFI_PACK_SENDER_ID_LSB_FOR_TIM_REQ(handle, timSetStatus); - - /* initialize signal to zero */ - memset(&signal, 0, sizeof(CSR_SIGNAL)); - - /* Frame the MLME-SET-TIM request */ - signal.SignalPrimitiveHeader.SignalId = CSR_MLME_SET_TIM_REQUEST_ID; - signal.SignalPrimitiveHeader.ReceiverProcessId = 0; - CSR_COPY_UINT16_TO_LITTLE_ENDIAN(((priv->netdev_client->sender_id & 0xff00) | senderIdLsb), - (u8*)&signal.SignalPrimitiveHeader.SenderProcessId); - - /* set The virtual interfaceIdentifier, aid, tim value */ - req->VirtualInterfaceIdentifier = uf_get_vif_identifier(interfacePriv->interfaceMode, interfaceTag); - req->AssociationId = aid; - req->TimValue = setTim; - - - unifi_trace(priv, UDBG2, "update_tim:AID %x,senderIdLsb = 0x%x, handle = 0x%x, timSetStatus = %x, sender proceesID = %x \n", - aid, senderIdLsb, handle, timSetStatus, signal.SignalPrimitiveHeader.SenderProcessId); - - /* Send the signal to UniFi */ - r = ul_send_signal_unpacked(priv, &signal, bulkdata); - if (r) { - /* No need to free bulk data, as TIM request doesn't carries any data */ - unifi_error(priv, "Error queueing CSR_MLME_SET_TIM_REQUEST signal\n"); - if (staRecord) { - staRecord->timSet = oldTimSetStatus ; - } - else - { - /* MLME_SET_TIM.req sending failed here for AID0, so revert back our bcTimSet status */ - interfacePriv->bcTimSet = !setTim; - } - } - else { - /* Update tim request pending flag and ensure no more TIM set requests are send - for the same station until TIM confirm is received */ - if (staRecord) { - staRecord->timRequestPendingFlag = TRUE; - } - else - { - /* Update tim request (for AID 0) pending flag and ensure no more DTIM set requests are send - * for the same station until TIM confirm is received - */ - interfacePriv->bcTimSetReqPendingFlag = TRUE; - } - } - unifi_trace(priv, UDBG5, "leaving the update_tim routine\n"); -} - -static -void process_peer_active_transition(unifi_priv_t * priv, - CsrWifiRouterCtrlStaInfo_t *staRecord, - u16 interfaceTag) -{ - int r, i; - u8 spaceAvail[4] = {TRUE, TRUE, TRUE, TRUE}; - tx_buffered_packets_t * buffered_pkt = NULL; - unsigned long lock_flags; - netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag]; - - unifi_trace(priv, UDBG5, "entering process_peer_active_transition\n"); - - if(IS_DTIM_ACTIVE(interfacePriv->dtimActive, interfacePriv->multicastPduHostTag)) { - /* giving more priority to multicast packets so delaying unicast packets*/ - unifi_trace(priv, UDBG2, "Multicast transmission is going on so resume unicast transmission after DTIM over\n"); - - /* As station is active now, even though AP is not able to send frames to it - * because of DTIM, it needs to reset the TIM here - */ - if (!staRecord->timRequestPendingFlag){ - if((staRecord->timSet == CSR_WIFI_TIM_SET) || (staRecord->timSet == CSR_WIFI_TIM_SETTING)){ - update_tim(priv, staRecord->aid, 0, interfaceTag, staRecord->assignedHandle); - } - } - else - { - /* Cache the TimSet value so that it will processed immidiatly after - * completing the current setTim Request - */ - staRecord->updateTimReqQueued = 0; - unifi_trace(priv, UDBG6, "update_tim : One more UpdateTim Request (Tim value:%d) Queued for AID %x\n", staRecord->updateTimReqQueued, - staRecord->aid); - } - return; - } - while((buffered_pkt=dequeue_tx_data_pdu(priv, &staRecord->mgtFrames))) { - buffered_pkt->transmissionControl &= - ~(TRANSMISSION_CONTROL_TRIGGER_MASK|TRANSMISSION_CONTROL_EOSP_MASK); - if((r=frame_and_send_queued_pdu(priv, buffered_pkt, staRecord, 0, FALSE)) == -ENOSPC) { - unifi_trace(priv, UDBG2, "p_p_a_t:(ENOSPC) Mgt Frame queueing \n"); - /* Enqueue at the head of the queue */ - spin_lock_irqsave(&priv->tx_q_lock, lock_flags); - list_add(&buffered_pkt->q, &staRecord->mgtFrames); - spin_unlock_irqrestore(&priv->tx_q_lock, lock_flags); - priv->pausedStaHandle[3]=(u8)(staRecord->assignedHandle); - spaceAvail[3] = FALSE; - break; - } else { - if(r){ - unifi_trace (priv, UDBG1, " HIP validation failure : PDU sending failed \n"); - /* the PDU failed where we can't do any thing so free the storage */ - unifi_net_data_free(priv, &buffered_pkt->bulkdata); - } - kfree(buffered_pkt); - } - } - if (!staRecord->timRequestPendingFlag) { - if (staRecord->txSuspend) { - if(staRecord->timSet == CSR_WIFI_TIM_SET) { - update_tim(priv, staRecord->aid, 0, interfaceTag, staRecord->assignedHandle); - } - return; - } - } - else - { - /* Cache the TimSet value so that it will processed immidiatly after - * completing the current setTim Request - */ - staRecord->updateTimReqQueued = 0; - unifi_trace(priv, UDBG6, "update_tim : One more UpdateTim Request (Tim value:%d) Queued for AID %x\n", staRecord->updateTimReqQueued, - staRecord->aid); - } - for(i=3;i>=0;i--) { - if(!spaceAvail[i]) - continue; - unifi_trace(priv, UDBG6, "p_p_a_t:data pkt sending for AC %d \n", i); - while((buffered_pkt=dequeue_tx_data_pdu(priv, &staRecord->dataPdu[i]))) { - buffered_pkt->transmissionControl &= - ~(TRANSMISSION_CONTROL_TRIGGER_MASK|TRANSMISSION_CONTROL_EOSP_MASK); - if((r=frame_and_send_queued_pdu(priv, buffered_pkt, staRecord, 0, FALSE)) == -ENOSPC) { - /* Clear the trigger bit transmission control*/ - /* Enqueue at the head of the queue */ - spin_lock_irqsave(&priv->tx_q_lock, lock_flags); - list_add(&buffered_pkt->q, &staRecord->dataPdu[i]); - spin_unlock_irqrestore(&priv->tx_q_lock, lock_flags); - priv->pausedStaHandle[i]=(u8)(staRecord->assignedHandle); - break; - } else { - if(r){ - unifi_trace (priv, UDBG1, " HIP validation failure : PDU sending failed \n"); - /* the PDU failed where we can't do any thing so free the storage */ - unifi_net_data_free(priv, &buffered_pkt->bulkdata); - } - kfree(buffered_pkt); - } - } - } - if (!staRecord->timRequestPendingFlag){ - if((staRecord->timSet == CSR_WIFI_TIM_SET) || (staRecord->timSet == CSR_WIFI_TIM_SETTING)) { - unifi_trace(priv, UDBG3, "p_p_a_t:resetting tim .....\n"); - update_tim(priv, staRecord->aid, 0, interfaceTag, staRecord->assignedHandle); - } - } - else - { - /* Cache the TimSet value so that it will processed immidiatly after - * completing the current setTim Request - */ - staRecord->updateTimReqQueued = 0; - unifi_trace(priv, UDBG6, "update_tim : One more UpdateTim Request (Tim value:%d) Queued for AID %x\n", staRecord->updateTimReqQueued, - staRecord->aid); - } - unifi_trace(priv, UDBG5, "leaving process_peer_active_transition\n"); -} - - - -void uf_process_ma_pkt_cfm_for_ap(unifi_priv_t *priv, u16 interfaceTag, const CSR_MA_PACKET_CONFIRM *pkt_cfm) -{ - netInterface_priv_t *interfacePriv; - u8 i; - CsrWifiRouterCtrlStaInfo_t *staRecord = NULL; - interfacePriv = priv->interfacePriv[interfaceTag]; - - - if(pkt_cfm->HostTag == interfacePriv->multicastPduHostTag) { - unifi_trace(priv, UDBG2, "CFM for marked Multicast Tag = %x\n", interfacePriv->multicastPduHostTag); - interfacePriv->multicastPduHostTag = 0xffffffff; - resume_suspended_uapsd(priv, interfaceTag); - resume_unicast_buffered_frames(priv, interfaceTag); - if(list_empty(&interfacePriv->genericMulticastOrBroadCastMgtFrames) && - list_empty(&interfacePriv->genericMulticastOrBroadCastFrames)) { - unifi_trace(priv, UDBG1, "Resetting multicastTIM"); - if (!interfacePriv->bcTimSetReqPendingFlag) - { - update_tim(priv, 0, CSR_WIFI_TIM_RESET, interfaceTag, 0xFFFFFFFF); - } - else - { - /* Cache the DTimSet value so that it will processed immidiatly after - * completing the current setDTim Request - */ - interfacePriv->bcTimSetReqQueued = CSR_WIFI_TIM_RESET; - unifi_trace(priv, UDBG2, "uf_process_ma_pkt_cfm_for_ap : One more UpdateDTim Request(%d) Queued \n", - interfacePriv->bcTimSetReqQueued); - } - - } - return; - } - - /* Check if it is a Confirm for null data frame used - * for probing station activity - */ - for(i =0; i < UNIFI_MAX_CONNECTIONS; i++) { - staRecord = (CsrWifiRouterCtrlStaInfo_t *) (interfacePriv->staInfo[i]); - if (staRecord && (staRecord->nullDataHostTag == pkt_cfm->HostTag)) { - - unifi_trace(priv, UDBG1, "CFM for Inactive probe Null frame (tag = %x, status = %d)\n", - pkt_cfm->HostTag, - pkt_cfm->TransmissionStatus - ); - staRecord->nullDataHostTag = INVALID_HOST_TAG; - - if(pkt_cfm->TransmissionStatus == CSR_TX_RETRY_LIMIT){ - u32 now; - u32 inactive_time; - - unifi_trace(priv, UDBG1, "Nulldata to probe STA ALIVE Failed with retry limit\n"); - /* Recheck if there is some activity after null data is sent. - * - * If still there is no activity then send a disconnected indication - * to SME to delete the station record. - */ - if (staRecord->activity_flag){ - return; - } - now = CsrTimeGet(NULL); - - if (staRecord->lastActivity > now) - { - /* simple timer wrap (for 1 wrap) */ - inactive_time = CsrTimeAdd((u32)CsrTimeSub(CSR_SCHED_TIME_MAX, staRecord->lastActivity), - now); - } - else - { - inactive_time = (u32)CsrTimeSub(now, staRecord->lastActivity); - } - - if (inactive_time >= STA_INACTIVE_TIMEOUT_VAL) - { - struct list_head send_cfm_list; - u8 j; - - /* The SME/NME may be waiting for confirmation for requested frames to this station. - * Though this is --VERY UNLIKELY-- in case of station in active mode. But still as a - * a defensive check, it loops through buffered frames for this station and if confirmation - * is requested, send auto confirmation with failure status. Also flush the frames so - * that these are not processed again in PEER_DEL_REQ handler. - */ - INIT_LIST_HEAD(&send_cfm_list); - - uf_prepare_send_cfm_list_for_queued_pkts(priv, - &send_cfm_list, - &(staRecord->mgtFrames)); - - uf_flush_list(priv, &(staRecord->mgtFrames)); - - for(j = 0; j < MAX_ACCESS_CATOGORY; j++){ - uf_prepare_send_cfm_list_for_queued_pkts(priv, - &send_cfm_list, - &(staRecord->dataPdu[j])); - - uf_flush_list(priv, &(staRecord->dataPdu[j])); - } - - send_auto_ma_packet_confirm(priv, staRecord->interfacePriv, &send_cfm_list); - - - - unifi_warning(priv, "uf_process_ma_pkt_cfm_for_ap: Router Disconnected IND Peer (%x-%x-%x-%x-%x-%x)\n", - staRecord->peerMacAddress.a[0], - staRecord->peerMacAddress.a[1], - staRecord->peerMacAddress.a[2], - staRecord->peerMacAddress.a[3], - staRecord->peerMacAddress.a[4], - staRecord->peerMacAddress.a[5]); - - CsrWifiRouterCtrlConnectedIndSend(priv->CSR_WIFI_SME_IFACEQUEUE, - 0, - staRecord->interfacePriv->InterfaceTag, - staRecord->peerMacAddress, - CSR_WIFI_ROUTER_CTRL_PEER_DISCONNECTED); - } - - } - else if (pkt_cfm->TransmissionStatus == CSR_TX_SUCCESSFUL) - { - staRecord->activity_flag = TRUE; - } - } - } -} - -#endif -u16 uf_get_vif_identifier (CsrWifiRouterCtrlMode mode, u16 tag) -{ - switch(mode) - { - case CSR_WIFI_ROUTER_CTRL_MODE_STA: - case CSR_WIFI_ROUTER_CTRL_MODE_P2PCLI: - return (0x02<<8|tag); - - case CSR_WIFI_ROUTER_CTRL_MODE_AP: - case CSR_WIFI_ROUTER_CTRL_MODE_P2PGO: - return (0x03<<8|tag); - - case CSR_WIFI_ROUTER_CTRL_MODE_IBSS: - return (0x01<<8|tag); - - case CSR_WIFI_ROUTER_CTRL_MODE_MONITOR: - return (0x04<<8|tag); - case CSR_WIFI_ROUTER_CTRL_MODE_AMP: - return (0x05<<8|tag); - default: - return tag; - } -} - -#ifdef CSR_SUPPORT_SME - -/* - * --------------------------------------------------------------------------- - * update_macheader - * - * - * These functions updates mac header for intra BSS packet - * routing. - * NOTE: This function always has to be called in rx context which - * is in bh thread context since GFP_KERNEL is used. In soft IRQ/ Interrupt - * context shouldn't be used - * - * Arguments: - * priv Pointer to device private context struct - * skb Socket buffer containing data packet to transmit - * newSkb Socket buffer containing data packet + Mac header if no sufficient headroom in skb - * priority to append QOS control header in Mac header - * bulkdata if newSkb allocated then bulkdata updated to send to unifi - * interfaceTag the interfaceID on which activity going on - * macHeaderLengthInBytes no. of bytes of mac header in received frame - * qosDestination used to append Qos control field - * - * Returns: - * Zero on success or -1 on error. - * --------------------------------------------------------------------------- - */ - -static int update_macheader(unifi_priv_t *priv, struct sk_buff *skb, - struct sk_buff *newSkb, CSR_PRIORITY *priority, - bulk_data_param_t *bulkdata, u16 interfaceTag, - u8 macHeaderLengthInBytes, - u8 qosDestination) -{ - - u16 *fc = NULL; - u8 direction = 0, toDs, fromDs; - u8 *bufPtr = NULL; - u8 sa[ETH_ALEN], da[ETH_ALEN]; - netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag]; - int headroom; - u8 macHeaderBuf[IEEE802_11_DATA_FRAME_MAC_HEADER_SIZE] = {0}; - - unifi_trace(priv, UDBG5, "entering the update_macheader function\n"); - - /* temporary buffer for the Mac header storage */ - memcpy(macHeaderBuf, skb->data, macHeaderLengthInBytes); - - /* remove the Macheader from the skb */ - skb_pull(skb, macHeaderLengthInBytes); - - /* get the skb headroom for skb_push check */ - headroom = skb_headroom(skb); - - /* pointer to frame control field */ - fc = (u16*) macHeaderBuf; - - toDs = (*fc & cpu_to_le16(IEEE802_11_FC_TO_DS_MASK))?1 : 0; - fromDs = (*fc & cpu_to_le16(IEEE802_11_FC_FROM_DS_MASK))? 1: 0; - unifi_trace(priv, UDBG5, "In update_macheader function, fromDs = %x, toDs = %x\n", fromDs, toDs); - direction = ((fromDs | (toDs << 1)) & 0x3); - - /* Address1 or 3 from the macheader */ - memcpy(da, macHeaderBuf+4+toDs*12, ETH_ALEN); - /* Address2, 3 or 4 from the mac header */ - memcpy(sa, macHeaderBuf+10+fromDs*(6+toDs*8), ETH_ALEN); - - unifi_trace(priv, UDBG3, "update_macheader:direction = %x\n", direction); - /* update the toDs, fromDs & address fields in Mac header */ - switch(direction) - { - case 2: - /* toDs = 1 & fromDs = 0 , toAp when frames received from peer - * while sending this packet to Destination the Mac header changed - * as fromDs = 1 & toDs = 0, fromAp - */ - *fc &= cpu_to_le16(~IEEE802_11_FC_TO_DS_MASK); - *fc |= cpu_to_le16(IEEE802_11_FC_FROM_DS_MASK); - /* Address1: MAC address of the actual destination (4 = 2+2) */ - memcpy(macHeaderBuf + 4, da, ETH_ALEN); - /* Address2: The MAC address of the AP (10 = 2+2+6) */ - memcpy(macHeaderBuf + 10, &interfacePriv->bssid, ETH_ALEN); - /* Address3: MAC address of the actual source from mac header (16 = 2+2+6+6) */ - memcpy(macHeaderBuf + 16, sa, ETH_ALEN); - break; - case 3: - unifi_trace(priv, UDBG3, "when both the toDs & fromDS set, NOT SUPPORTED\n"); - break; - default: - unifi_trace(priv, UDBG3, "problem in decoding packet in update_macheader \n"); - return -1; - } - - /* frameType is Data always, Validation is done before calling this function */ - - /* check for the souce station type */ - switch(le16_to_cpu(*fc) & IEEE80211_FC_SUBTYPE_MASK) - { - case IEEE802_11_FC_TYPE_QOS_DATA & IEEE80211_FC_SUBTYPE_MASK: - /* No need to modify the qos control field */ - if (!qosDestination) { - - /* If source Sta is QOS enabled & if this bit set, then HTC is supported by - * peer station & htc field present in macHeader - */ - if (*fc & cpu_to_le16(IEEE80211_FC_ORDER_MASK)) { - /* HT control field present in Mac header - * 6 = sizeof(qosControl) + sizeof(htc) - */ - macHeaderLengthInBytes -= 6; - } else { - macHeaderLengthInBytes -= 2; - } - /* Destination STA is non qos so change subtype to DATA */ - *fc &= cpu_to_le16(~IEEE80211_FC_SUBTYPE_MASK); - *fc |= cpu_to_le16(IEEE802_11_FC_TYPE_DATA); - /* remove the qos control field & HTC(if present). new macHeaderLengthInBytes is less than old - * macHeaderLengthInBytes so no need to verify skb headroom - */ - if (headroom < macHeaderLengthInBytes) { - unifi_trace(priv, UDBG1, " sufficient headroom not there to push updated mac header \n"); - return -1; - } - bufPtr = (u8 *) skb_push(skb, macHeaderLengthInBytes); - - /* update bulk data os_data_ptr */ - bulkdata->d[0].os_data_ptr = skb->data; - bulkdata->d[0].os_net_buf_ptr = (unsigned char*)skb; - bulkdata->d[0].data_length = skb->len; - - } else { - /* pointing to QOS control field */ - u8 qc; - if (*fc & cpu_to_le16(IEEE80211_FC_ORDER_MASK)) { - qc = *((u8*)(macHeaderBuf + (macHeaderLengthInBytes - 4 - 2))); - } else { - qc = *((u8*)(macHeaderBuf + (macHeaderLengthInBytes - 2))); - } - - if ((qc & IEEE802_11_QC_TID_MASK) > 7) { - *priority = 7; - } else { - *priority = qc & IEEE802_11_QC_TID_MASK; - } - - unifi_trace(priv, UDBG1, "Incoming packet priority from QSTA is %x\n", *priority); - - if (headroom < macHeaderLengthInBytes) { - unifi_trace(priv, UDBG3, " sufficient headroom not there to push updated mac header \n"); - return -1; - } - bufPtr = (u8 *) skb_push(skb, macHeaderLengthInBytes); - } - break; - default: - { - bulk_data_param_t data_ptrs; - CsrResult csrResult; - unifi_trace(priv, UDBG5, "normal Data packet, NO QOS \n"); - - if (qosDestination) { - u8 qc = 0; - unifi_trace(priv, UDBG3, "destination is QOS station \n"); - - /* Set Ma-Packet.req UP to UP0 */ - *priority = CSR_QOS_UP0; - - /* prepare the qos control field */ - qc |= CSR_QOS_UP0; - /* no Amsdu is in ap buffer so eosp is left 0 */ - if (da[0] & 0x1) { - /* multicast/broadcast frames, no acknowledgement needed */ - qc |= 1 << 5; - } - - /* update new Mac header Length with 2 = sizeof(qos control) */ - macHeaderLengthInBytes += 2; - - /* received DATA frame but destiantion is QOS station so update subtype to QOS*/ - *fc &= cpu_to_le16(~IEEE80211_FC_SUBTYPE_MASK); - *fc |= cpu_to_le16(IEEE802_11_FC_TYPE_QOS_DATA); - - /* appendQosControlOffset = macHeaderLengthInBytes - 2, since source sta is not QOS */ - macHeaderBuf[macHeaderLengthInBytes - 2] = qc; - /* txopLimit is 0 */ - macHeaderBuf[macHeaderLengthInBytes - 1] = 0; - if (headroom < macHeaderLengthInBytes) { - csrResult = unifi_net_data_malloc(priv, &data_ptrs.d[0], skb->len + macHeaderLengthInBytes); - - if (csrResult != CSR_RESULT_SUCCESS) { - unifi_error(priv, " failed to allocate request_data. in update_macheader func\n"); - return -1; - } - newSkb = (struct sk_buff *)(data_ptrs.d[0].os_net_buf_ptr); - newSkb->len = skb->len + macHeaderLengthInBytes; - - memcpy((void*)data_ptrs.d[0].os_data_ptr + macHeaderLengthInBytes, - skb->data, skb->len); - - bulkdata->d[0].os_data_ptr = newSkb->data; - bulkdata->d[0].os_net_buf_ptr = (unsigned char*)newSkb; - bulkdata->d[0].data_length = newSkb->len; - - bufPtr = (u8*)data_ptrs.d[0].os_data_ptr; - - /* The old skb will not be used again */ - kfree_skb(skb); - } else { - /* skb headroom is sufficient to append Macheader */ - bufPtr = (u8*)skb_push(skb, macHeaderLengthInBytes); - bulkdata->d[0].os_data_ptr = skb->data; - bulkdata->d[0].os_net_buf_ptr = (unsigned char*)skb; - bulkdata->d[0].data_length = skb->len; - } - } else { - unifi_trace(priv, UDBG3, "destination is not a QSTA\n"); - if (headroom < macHeaderLengthInBytes) { - csrResult = unifi_net_data_malloc(priv, &data_ptrs.d[0], skb->len + macHeaderLengthInBytes); - - if (csrResult != CSR_RESULT_SUCCESS) { - unifi_error(priv, " failed to allocate request_data. in update_macheader func\n"); - return -1; - } - newSkb = (struct sk_buff *)(data_ptrs.d[0].os_net_buf_ptr); - newSkb->len = skb->len + macHeaderLengthInBytes; - - memcpy((void*)data_ptrs.d[0].os_data_ptr + macHeaderLengthInBytes, - skb->data, skb->len); - - bulkdata->d[0].os_data_ptr = newSkb->data; - bulkdata->d[0].os_net_buf_ptr = (unsigned char*)newSkb; - bulkdata->d[0].data_length = newSkb->len; - - bufPtr = (u8*)data_ptrs.d[0].os_data_ptr; - - /* The old skb will not be used again */ - kfree_skb(skb); - } else { - /* skb headroom is sufficient to append Macheader */ - bufPtr = (u8*)skb_push(skb, macHeaderLengthInBytes); - bulkdata->d[0].os_data_ptr = skb->data; - bulkdata->d[0].os_net_buf_ptr = (unsigned char*)skb; - bulkdata->d[0].data_length = skb->len; - } - } - } - } - - /* prepare the complete skb, by pushing the MAC header to the beginning of the skb->data */ - unifi_trace(priv, UDBG5, "updated Mac Header: %d \n", macHeaderLengthInBytes); - memcpy(bufPtr, macHeaderBuf, macHeaderLengthInBytes); - - unifi_trace(priv, UDBG5, "leaving the update_macheader function\n"); - return 0; -} -/* - * --------------------------------------------------------------------------- - * uf_ap_process_data_pdu - * - * - * Takes care of intra BSS admission control & routing packets within BSS - * - * Arguments: - * priv Pointer to device private context struct - * skb Socket buffer containing data packet to transmit - * ehdr ethernet header to fetch priority of packet - * srcStaInfo source stations record for connection verification - * packed_signal - * signal_len - * signal MA-PACKET.indication signal - * bulkdata if newSkb allocated then bulkdata updated to send to unifi - * macHeaderLengthInBytes no. of bytes of mac header in received frame - * - * Returns: - * Zero on success(ap processing complete) or -1 if packet also have to be sent to NETDEV. - * --------------------------------------------------------------------------- - */ -int -uf_ap_process_data_pdu(unifi_priv_t *priv, struct sk_buff *skb, - struct ethhdr *ehdr, CsrWifiRouterCtrlStaInfo_t * srcStaInfo, - const CSR_SIGNAL *signal, - bulk_data_param_t *bulkdata, - u8 macHeaderLengthInBytes) -{ - const CSR_MA_PACKET_INDICATION *ind = &(signal->u.MaPacketIndication); - u16 interfaceTag = (ind->VirtualInterfaceIdentifier & 0x00ff); - struct sk_buff *newSkb = NULL; - /* pointer to skb or private skb created using skb_copy() */ - struct sk_buff *skbPtr = skb; - u8 sendToNetdev = FALSE; - u8 qosDestination = FALSE; - CSR_PRIORITY priority = CSR_CONTENTION; - CsrWifiRouterCtrlStaInfo_t *dstStaInfo = NULL; - netInterface_priv_t *interfacePriv; - - unifi_trace(priv, UDBG5, "entering uf_ap_process_data_pdu %d\n", macHeaderLengthInBytes); - /* InterfaceTag validation from MA_PACKET.indication */ - if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) { - unifi_trace(priv, UDBG1, "Interface Tag is Invalid in uf_ap_process_data_pdu\n"); - unifi_net_data_free(priv, &bulkdata->d[0]); - return 0; - } - interfacePriv = priv->interfacePriv[interfaceTag]; - - if((interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO) && - (interfacePriv->intraBssEnabled == FALSE)) { - unifi_trace(priv, UDBG2, "uf_ap_process_data_pdu:P2P GO intrabssEnabled?= %d\n", interfacePriv->intraBssEnabled); - - /*In P2P GO case, if intraBSS distribution Disabled then don't do IntraBSS routing */ - /* If destination in our BSS then drop otherwise give packet to netdev */ - dstStaInfo = CsrWifiRouterCtrlGetStationRecordFromPeerMacAddress(priv, ehdr->h_dest, interfaceTag); - if (dstStaInfo) { - unifi_net_data_free(priv, &bulkdata->d[0]); - return 0; - } - /* May be associated P2PCLI trying to send the packets on backbone (Netdev) */ - return -1; - } - - if(!memcmp(ehdr->h_dest, interfacePriv->bssid.a, ETH_ALEN)) { - /* This packet will be given to the TCP/IP stack since this packet is for us(AP) - * No routing needed */ - unifi_trace(priv, UDBG4, "destination address is csr_ap\n"); - return -1; - } - - /* fetch the destination record from station record database */ - dstStaInfo = CsrWifiRouterCtrlGetStationRecordFromPeerMacAddress(priv, ehdr->h_dest, interfaceTag); - - /* AP mode processing, & if packet is unicast */ - if(!dstStaInfo) { - if (!(ehdr->h_dest[0] & 0x1)) { - /* destination not in station record & its a unicast packet, so pass the packet to network stack */ - unifi_trace(priv, UDBG3, "unicast frame & destination record not exist, send to netdev proto = %x\n", htons(skb->protocol)); - return -1; - } else { - /* packet is multicast/broadcast */ - /* copy the skb to skbPtr, send skb to netdev & skbPtr to multicast/broad cast list */ - unifi_trace(priv, UDBG5, "skb_copy, in uf_ap_process_data_pdu, protocol = %x\n", htons(skb->protocol)); - skbPtr = skb_copy(skb, GFP_KERNEL); - if(skbPtr == NULL) { - /* We don't have memory to don't send the frame in BSS*/ - unifi_notice(priv, "broacast/multicast frame can't be sent in BSS No memeory: proto = %x\n", htons(skb->protocol)); - return -1; - } - sendToNetdev = TRUE; - } - } else { - - /* validate the Peer & Destination Station record */ - if (uf_process_station_records_for_sending_data(priv, interfaceTag, srcStaInfo, dstStaInfo)) { - unifi_notice(priv, "uf_ap_process_data_pdu: station record validation failed \n"); - interfacePriv->stats.rx_errors++; - unifi_net_data_free(priv, &bulkdata->d[0]); - return 0; - } - } - - /* BroadCast packet received and it's been sent as non QOS packets. - * Since WMM spec not mandates broadcast/multicast to be sent as QOS data only, - * if all Peers are QSTA - */ - if(sendToNetdev) { - /* BroadCast packet and it's been sent as non QOS packets */ - qosDestination = FALSE; - } else if(dstStaInfo && (dstStaInfo->wmmOrQosEnabled == TRUE)) { - qosDestination = TRUE; - } - - unifi_trace(priv, UDBG3, "uf_ap_process_data_pdu QoS destination = %s\n", (qosDestination)? "TRUE": "FALSE"); - - /* packet is allowed to send to unifi, update the Mac header */ - if (update_macheader(priv, skbPtr, newSkb, &priority, bulkdata, interfaceTag, macHeaderLengthInBytes, qosDestination)) { - interfacePriv->stats.rx_errors++; - unifi_notice(priv, "(Packet Drop) failed to update the Mac header in uf_ap_process_data_pdu\n"); - if (sendToNetdev) { - /* Free's the skb_copy(skbPtr) data since packet processing failed */ - bulkdata->d[0].os_data_ptr = skbPtr->data; - bulkdata->d[0].os_net_buf_ptr = (unsigned char*)skbPtr; - bulkdata->d[0].data_length = skbPtr->len; - unifi_net_data_free(priv, &bulkdata->d[0]); - } - return -1; - } - - unifi_trace(priv, UDBG3, "Mac Header updated...calling uf_process_ma_packet_req \n"); - - /* Packet is ready to send to unifi ,transmissionControl = 0x0004, confirmation is not needed for data packets */ - if (uf_process_ma_packet_req(priv, ehdr->h_dest, 0xffffffff, interfaceTag, CSR_NO_CONFIRM_REQUIRED, (CSR_RATE)0, priority, priv->netdev_client->sender_id, bulkdata)) { - if (sendToNetdev) { - unifi_trace(priv, UDBG1, "In uf_ap_process_data_pdu, (Packet Drop) uf_process_ma_packet_req failed. freeing skb_copy data (original data sent to Netdev)\n"); - /* Free's the skb_copy(skbPtr) data since packet processing failed */ - bulkdata->d[0].os_data_ptr = skbPtr->data; - bulkdata->d[0].os_net_buf_ptr = (unsigned char*)skbPtr; - bulkdata->d[0].data_length = skbPtr->len; - unifi_net_data_free(priv, &bulkdata->d[0]); - } else { - /* This free's the skb data */ - unifi_trace(priv, UDBG1, "In uf_ap_process_data_pdu, (Packet Drop). Unicast data so freeing original skb \n"); - unifi_net_data_free(priv, &bulkdata->d[0]); - } - } - unifi_trace(priv, UDBG5, "leaving uf_ap_process_data_pdu\n"); - - if (sendToNetdev) { - /* The packet is multicast/broadcast, so after AP processing packet has to - * be sent to netdev, if peer port state is open - */ - unifi_trace(priv, UDBG4, "Packet will be routed to NetDev\n"); - return -1; - } - /* Ap handled the packet & its a unicast packet, no need to send to netdev */ - return 0; -} - -#endif - -CsrResult uf_process_ma_packet_req(unifi_priv_t *priv, - u8 *peerMacAddress, - CSR_CLIENT_TAG hostTag, - u16 interfaceTag, - CSR_TRANSMISSION_CONTROL transmissionControl, - CSR_RATE TransmitRate, - CSR_PRIORITY priority, - CSR_PROCESS_ID leSenderProcessId, - bulk_data_param_t *bulkdata) -{ - CsrResult status = CSR_RESULT_SUCCESS; - CSR_SIGNAL signal; - int result; -#ifdef CSR_SUPPORT_SME - CsrWifiRouterCtrlStaInfo_t *staRecord = NULL; - const u8 *macHdrLocation = bulkdata->d[0].os_data_ptr; - CsrWifiPacketType pktType; - int frameType = 0; - u8 queuePacketDozing = FALSE; - u32 priority_q; - u16 frmCtrl; - struct list_head * list = NULL; /* List to which buffered PDUs are to be enqueued*/ - u8 setBcTim=FALSE; - netInterface_priv_t *interfacePriv; - u8 requeueOnSamePos = FALSE; - u32 handle = 0xFFFFFFFF; - unsigned long lock_flags; - - unifi_trace(priv, UDBG5, - "entering uf_process_ma_packet_req, peer: %pMF\n", - peerMacAddress); - - if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) { - unifi_error(priv, "interfaceTag >= CSR_WIFI_NUM_INTERFACES, interfacetag = %d\n", interfaceTag); - return CSR_RESULT_FAILURE; - } - interfacePriv = priv->interfacePriv[interfaceTag]; - - - /* fetch the station record for corresponding peer mac address */ - if ((staRecord = CsrWifiRouterCtrlGetStationRecordFromPeerMacAddress(priv, peerMacAddress, interfaceTag))) { - handle = staRecord->assignedHandle; - } - - /* Frame ma-packet.req, this is saved/transmitted depend on queue state */ - unifi_frame_ma_packet_req(priv, priority, TransmitRate, hostTag, - interfaceTag, transmissionControl, leSenderProcessId, - peerMacAddress, &signal); - - /* Since it's common path between STA & AP mode, in case of STA packet - * need not to be queued but in AP case we have to queue PDU's in - * different scenarios - */ - switch(interfacePriv->interfaceMode) - { - case CSR_WIFI_ROUTER_CTRL_MODE_AP: - case CSR_WIFI_ROUTER_CTRL_MODE_P2PGO: - /* For this mode processing done below */ - break; - default: - /* In case of STA/IBSS/P2PCLI/AMP, no checks needed send the packet down & return */ - unifi_trace(priv, UDBG5, "In %s, interface mode is %x \n", __FUNCTION__, interfacePriv->interfaceMode); - if (interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_NONE) { - unifi_warning(priv, "In %s, interface mode NONE \n", __FUNCTION__); - } - if ((result = ul_send_signal_unpacked(priv, &signal, bulkdata))) { - status = CSR_RESULT_FAILURE; - } - return status; - } - - /* -----Only AP/P2pGO mode handling falls below----- */ - - /* convert priority to queue */ - priority_q = unifi_frame_priority_to_queue((CSR_PRIORITY) priority); - - /* check the powersave status of the peer */ - if (staRecord && (staRecord->currentPeerState == - CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_POWER_SAVE)) { - /* Peer is dozing & packet have to be delivered, so buffer the packet & - * update the TIM - */ - queuePacketDozing = TRUE; - } - - /* find the type of frame unicast or mulicast/broadcast */ - if (*peerMacAddress & 0x1) { - /* Multicast/broadCast data are always triggered by vif_availability.ind - * at the DTIM - */ - pktType = CSR_WIFI_MULTICAST_PDU; - } else { - pktType = CSR_WIFI_UNICAST_PDU; - } - - /* Fetch the frame control field from mac header & check for frame type */ - frmCtrl = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(macHdrLocation); - - /* Processing done according to Frame/Packet type */ - frameType = ((frmCtrl & 0x000c) >> FRAME_CONTROL_TYPE_FIELD_OFFSET); - switch(frameType) - { - case IEEE802_11_FRAMETYPE_MANAGEMENT: - - switch(pktType) - { - case CSR_WIFI_UNICAST_PDU: - unifi_trace(priv, UDBG5, "management unicast PDU in uf_process_ma_packet_req \n"); - /* push the packet in to the queue with appropriate mgt list */ - if (!staRecord) { - /* push the packet to the unifi if list is empty (if packet lost how to re-enque) */ - if (list_empty(&interfacePriv->genericMgtFrames)) { -#ifdef CSR_SUPPORT_SME - if(!(IS_DTIM_ACTIVE(interfacePriv->dtimActive, interfacePriv->multicastPduHostTag))) { -#endif - - unifi_trace(priv, UDBG3, "genericMgtFrames list is empty uf_process_ma_packet_req \n"); - result = ul_send_signal_unpacked(priv, &signal, bulkdata); - /* reque only on ENOSPC */ - if(result == -ENOSPC) { - /* requeue the failed packet to genericMgtFrame with same position */ - unifi_trace(priv, UDBG1, "(ENOSPC) Sending genericMgtFrames Failed so buffering\n"); - list = &interfacePriv->genericMgtFrames; - requeueOnSamePos = TRUE; - } -#ifdef CSR_SUPPORT_SME - }else{ - list = &interfacePriv->genericMgtFrames; - unifi_trace(priv, UDBG3, "genericMgtFrames queue empty and dtim started\n hosttag is 0x%x,\n", signal.u.MaPacketRequest.HostTag); - update_eosp_to_head_of_broadcast_list_head(priv, interfaceTag); - } -#endif - } else { - /* Queue the packet to genericMgtFrame of unifi_priv_t data structure */ - list = &interfacePriv->genericMgtFrames; - unifi_trace(priv, UDBG2, "genericMgtFrames queue not empty\n"); - } - } else { - /* check peer power state */ - if (queuePacketDozing || !list_empty(&staRecord->mgtFrames) || IS_DTIM_ACTIVE(interfacePriv->dtimActive, interfacePriv->multicastPduHostTag)) { - /* peer is in dozing mode, so queue packet in mgt frame list of station record */ - /*if multicast traffic is going on, buffer the unicast packets*/ - list = &staRecord->mgtFrames; - - unifi_trace(priv, UDBG1, "staRecord->MgtFrames list empty? = %s, handle = %d, queuePacketDozing = %d\n", - (list_empty(&staRecord->mgtFrames))? "YES": "NO", staRecord->assignedHandle, queuePacketDozing); - if(IS_DTIM_ACTIVE(interfacePriv->dtimActive, interfacePriv->multicastPduHostTag)){ - update_eosp_to_head_of_broadcast_list_head(priv, interfaceTag); - } - - } else { - unifi_trace(priv, UDBG5, "staRecord->mgtFrames list is empty uf_process_ma_packet_req \n"); - result = ul_send_signal_unpacked(priv, &signal, bulkdata); - if(result == -ENOSPC) { - /* requeue the failed packet to staRecord->mgtFrames with same position */ - list = &staRecord->mgtFrames; - requeueOnSamePos = TRUE; - unifi_trace(priv, UDBG1, "(ENOSPC) Sending MgtFrames Failed handle = %d so buffering\n", staRecord->assignedHandle); - priv->pausedStaHandle[0]=(u8)(staRecord->assignedHandle); - } else if (result) { - status = CSR_RESULT_FAILURE; - } - } - } - break; - case CSR_WIFI_MULTICAST_PDU: - unifi_trace(priv, UDBG5, "management multicast/broadcast PDU in uf_process_ma_packet_req 'QUEUE it' \n"); - /* Queue the packet to genericMulticastOrBroadCastMgtFrames of unifi_priv_t data structure - * will be sent when we receive VIF AVAILABILITY from firmware as part of DTIM - */ - - list = &interfacePriv->genericMulticastOrBroadCastMgtFrames; - if((interfacePriv->interfaceMode != CSR_WIFI_ROUTER_CTRL_MODE_IBSS) && - (list_empty(&interfacePriv->genericMulticastOrBroadCastMgtFrames))) { - setBcTim=TRUE; - } - break; - default: - unifi_error(priv, "condition never meets: packet type unrecognized\n"); - } - break; - case IEEE802_11_FRAMETYPE_DATA: - switch(pktType) - { - case CSR_WIFI_UNICAST_PDU: - unifi_trace(priv, UDBG5, "data unicast PDU in uf_process_ma_packet_req \n"); - /* check peer power state, list status & peer port status */ - if(!staRecord) { - unifi_error(priv, "In %s unicast but staRecord = NULL\n", __FUNCTION__); - return CSR_RESULT_FAILURE; - } else if (queuePacketDozing || isRouterBufferEnabled(priv, priority_q)|| !list_empty(&staRecord->dataPdu[priority_q]) || IS_DTIM_ACTIVE(interfacePriv->dtimActive, interfacePriv->multicastPduHostTag)) { - /* peer is in dozing mode, so queue packet in mgt frame list of station record */ - /* if multicast traffic is going on, buffet the unicast packets */ - unifi_trace(priv, UDBG2, "Enqueued to staRecord->dataPdu[%d] queuePacketDozing=%d,\ - Buffering enabled = %d \n", priority_q, queuePacketDozing, isRouterBufferEnabled(priv, priority_q)); - list = &staRecord->dataPdu[priority_q]; - } else { - unifi_trace(priv, UDBG5, "staRecord->dataPdu[%d] list is empty uf_process_ma_packet_req \n", priority_q); - /* Pdu allowed to send to unifi */ - result = ul_send_signal_unpacked(priv, &signal, bulkdata); - if(result == -ENOSPC) { - /* requeue the failed packet to staRecord->dataPdu[priority_q] with same position */ - unifi_trace(priv, UDBG1, "(ENOSPC) Sending Unicast DataPDU to queue %d Failed so buffering\n", priority_q); - requeueOnSamePos = TRUE; - list = &staRecord->dataPdu[priority_q]; - priv->pausedStaHandle[priority_q]=(u8)(staRecord->assignedHandle); - if(!isRouterBufferEnabled(priv, priority_q)) { - unifi_error(priv, "Buffering Not enabled for queue %d \n", priority_q); - } - } else if (result) { - status = CSR_RESULT_FAILURE; - } - } - break; - case CSR_WIFI_MULTICAST_PDU: - unifi_trace(priv, UDBG5, "data multicast/broadcast PDU in uf_process_ma_packet_req \n"); - /* Queue the packet to genericMulticastOrBroadCastFrames list of unifi_priv_t data structure - * will be sent when we receive VIF AVAILABILITY from firmware as part of DTIM - */ - list = &interfacePriv->genericMulticastOrBroadCastFrames; - if(list_empty(&interfacePriv->genericMulticastOrBroadCastFrames)) { - setBcTim = TRUE; - } - break; - default: - unifi_error(priv, "condition never meets: packet type un recognized\n"); - } - break; - default: - unifi_error(priv, "unrecognized frame type\n"); - } - if(list) { - status = enque_tx_data_pdu(priv, bulkdata, list, &signal, requeueOnSamePos); - /* Record no. of packet queued for each peer */ - if (staRecord && (pktType == CSR_WIFI_UNICAST_PDU) && (!status)) { - spin_lock_irqsave(&priv->staRecord_lock, lock_flags); - staRecord->noOfPktQueued++; - spin_unlock_irqrestore(&priv->staRecord_lock, lock_flags); - } - else if ((pktType == CSR_WIFI_MULTICAST_PDU) && (!status)) - { - /* If broadcast Tim is set && queuing is successful, then only update TIM */ - spin_lock_irqsave(&priv->staRecord_lock, lock_flags); - interfacePriv->noOfbroadcastPktQueued++; - spin_unlock_irqrestore(&priv->staRecord_lock, lock_flags); - } - } - /* If broadcast Tim is set && queuing is successful, then only update TIM */ - if(setBcTim && !status) { - unifi_trace(priv, UDBG3, "tim set due to broadcast pkt\n"); - if (!interfacePriv->bcTimSetReqPendingFlag) - { - update_tim(priv, 0, CSR_WIFI_TIM_SET, interfaceTag, handle); - } - else - { - /* Cache the TimSet value so that it will processed immidiatly after - * completing the current setTim Request - */ - interfacePriv->bcTimSetReqQueued = CSR_WIFI_TIM_SET; - unifi_trace(priv, UDBG2, "uf_process_ma_packet_req : One more UpdateDTim Request(:%d) Queued \n", - interfacePriv->bcTimSetReqQueued); - } - } else if(staRecord && staRecord->currentPeerState == - CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_POWER_SAVE) { - if(staRecord->timSet == CSR_WIFI_TIM_RESET || staRecord->timSet == CSR_WIFI_TIM_RESETTING) { - if(!staRecord->wmmOrQosEnabled) { - if(!list_empty(&staRecord->mgtFrames) || - !list_empty(&staRecord->dataPdu[3]) || - !list_empty(&staRecord->dataPdu[UNIFI_TRAFFIC_Q_CONTENTION])) { - unifi_trace(priv, UDBG3, "tim set due to unicast pkt & peer in powersave\n"); - if (!staRecord->timRequestPendingFlag){ - update_tim(priv, staRecord->aid, 1, interfaceTag, handle); - } - else - { - /* Cache the TimSet value so that it will processed immidiatly after - * completing the current setTim Request - */ - staRecord->updateTimReqQueued = 1; - unifi_trace(priv, UDBG6, "update_tim : One more UpdateTim Request (Tim value:%d) Queued for AID %x\n", staRecord->updateTimReqQueued, - staRecord->aid); - } - } - } else { - /* Check for non delivery enable(i.e trigger enable), all delivery enable & legacy AC for TIM update in firmware */ - u8 allDeliveryEnabled = 0, dataAvailable = 0; - /* Check if all AC's are Delivery Enabled */ - is_all_ac_deliver_enabled_and_moredata(staRecord, &allDeliveryEnabled, &dataAvailable); - if (uf_is_more_data_for_non_delivery_ac(staRecord) || (allDeliveryEnabled && dataAvailable) - || (!list_empty(&staRecord->mgtFrames))) { - if (!staRecord->timRequestPendingFlag) { - update_tim(priv, staRecord->aid, 1, interfaceTag, handle); - } - else - { - /* Cache the TimSet value so that it will processed immidiatly after - * completing the current setTim Request - */ - staRecord->updateTimReqQueued = 1; - unifi_trace(priv, UDBG6, "update_tim : One more UpdateTim Request (Tim value:%d) Queued for AID %x\n", staRecord->updateTimReqQueued, - staRecord->aid); - } - } - } - } - } - - if((list) && (pktType == CSR_WIFI_UNICAST_PDU && !queuePacketDozing) && !(isRouterBufferEnabled(priv, priority_q)) && !(IS_DTIM_ACTIVE(interfacePriv->dtimActive, interfacePriv->multicastPduHostTag))) { - unifi_trace(priv, UDBG2, "buffering cleared for queue = %d So resending buffered frames\n", priority_q); - uf_send_buffered_frames(priv, priority_q); - } - unifi_trace(priv, UDBG5, "leaving uf_process_ma_packet_req \n"); - return status; -#else -#ifdef CSR_NATIVE_LINUX - if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) { - unifi_error(priv, "interfaceTag >= CSR_WIFI_NUM_INTERFACES, interfacetag = %d\n", interfaceTag); - return CSR_RESULT_FAILURE; - } - /* Frame ma-packet.req, this is saved/transmitted depend on queue state */ - unifi_frame_ma_packet_req(priv, priority, TransmitRate, hostTag, interfaceTag, - transmissionControl, leSenderProcessId, - peerMacAddress, &signal); - result = ul_send_signal_unpacked(priv, &signal, bulkdata); - if (result) { - return CSR_RESULT_FAILURE; - } -#endif - return status; -#endif -} - -#ifdef CSR_SUPPORT_SME -s8 uf_get_protection_bit_from_interfacemode(unifi_priv_t *priv, u16 interfaceTag, const u8 *daddr) -{ - s8 protection = 0; - netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag]; - - switch(interfacePriv->interfaceMode) - { - case CSR_WIFI_ROUTER_CTRL_MODE_STA: - case CSR_WIFI_ROUTER_CTRL_MODE_P2PCLI: - case CSR_WIFI_ROUTER_CTRL_MODE_AMP: - case CSR_WIFI_ROUTER_CTRL_MODE_IBSS: - protection = interfacePriv->protect; - break; - case CSR_WIFI_ROUTER_CTRL_MODE_AP: - case CSR_WIFI_ROUTER_CTRL_MODE_P2PGO: - { - CsrWifiRouterCtrlStaInfo_t *dstStaInfo = NULL; - if (daddr[0] & 0x1) { - unifi_trace(priv, UDBG3, "broadcast/multicast packet in send_ma_pkt_request\n"); - /* In this mode, the protect member of priv structure has an information of how - * AP/P2PGO has started, & the member updated in set mode request for AP/P2PGO - */ - protection = interfacePriv->protect; - } else { - /* fetch the destination record from station record database */ - dstStaInfo = CsrWifiRouterCtrlGetStationRecordFromPeerMacAddress(priv, daddr, interfaceTag); - if (!dstStaInfo) { - unifi_trace(priv, UDBG3, "peer not found in station record in send_ma_pkt_request\n"); - return -1; - } - protection = dstStaInfo->protection; - } - } - break; - default: - unifi_trace(priv, UDBG2, "mode unknown in send_ma_pkt_request\n"); - } - return protection; -} -#endif -#ifdef CSR_SUPPORT_SME -u8 send_multicast_frames(unifi_priv_t *priv, u16 interfaceTag) -{ - int r; - tx_buffered_packets_t * buffered_pkt = NULL; - u8 moreData = FALSE; - u8 pduSent =0; - unsigned long lock_flags; - netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag]; - u32 hostTag = 0xffffffff; - - if(!isRouterBufferEnabled(priv, UNIFI_TRAFFIC_Q_VO)) { - while((interfacePriv->dtimActive)&& (buffered_pkt=dequeue_tx_data_pdu(priv, &interfacePriv->genericMulticastOrBroadCastMgtFrames))) { - buffered_pkt->transmissionControl |= (TRANSMISSION_CONTROL_TRIGGER_MASK); - moreData = (buffered_pkt->transmissionControl & TRANSMISSION_CONTROL_EOSP_MASK)?FALSE:TRUE; - - - unifi_trace(priv, UDBG2, "DTIM Occurred for interface:sending Mgt packet %d\n", interfaceTag); - - if((r=frame_and_send_queued_pdu(priv, buffered_pkt, NULL, moreData, FALSE)) == -ENOSPC) { - unifi_trace(priv, UDBG1, "frame_and_send_queued_pdu failed with ENOSPC for host tag = %x\n", buffered_pkt->hostTag); - /* Enqueue at the head of the queue */ - spin_lock_irqsave(&priv->tx_q_lock, lock_flags); - list_add(&buffered_pkt->q, &interfacePriv->genericMulticastOrBroadCastMgtFrames); - spin_unlock_irqrestore(&priv->tx_q_lock, lock_flags); - break; - } else { - unifi_trace(priv, UDBG1, "send_multicast_frames: Send genericMulticastOrBroadCastMgtFrames (%x, %x)\n", - buffered_pkt->hostTag, - r); - if(r) { - unifi_net_data_free(priv, &buffered_pkt->bulkdata); - } - if(!moreData) { - - interfacePriv->dtimActive = FALSE; - if(!r) { - hostTag = buffered_pkt->hostTag; - pduSent++; - } else { - send_vif_availibility_rsp(priv, uf_get_vif_identifier(interfacePriv->interfaceMode, interfaceTag), CSR_RC_UNSPECIFIED_FAILURE); - } - } - /* Buffered frame sent successfully */ - spin_lock_irqsave(&priv->staRecord_lock, lock_flags); - interfacePriv->noOfbroadcastPktQueued--; - spin_unlock_irqrestore(&priv->staRecord_lock, lock_flags); - kfree(buffered_pkt); - } - - } - } - if(!isRouterBufferEnabled(priv, UNIFI_TRAFFIC_Q_CONTENTION)) { - while((interfacePriv->dtimActive)&& (buffered_pkt=dequeue_tx_data_pdu(priv, &interfacePriv->genericMulticastOrBroadCastFrames))) { - buffered_pkt->transmissionControl |= TRANSMISSION_CONTROL_TRIGGER_MASK; - moreData = (buffered_pkt->transmissionControl & TRANSMISSION_CONTROL_EOSP_MASK)?FALSE:TRUE; - - - if((r=frame_and_send_queued_pdu(priv, buffered_pkt, NULL, moreData, FALSE)) == -ENOSPC) { - /* Clear the trigger bit transmission control*/ - buffered_pkt->transmissionControl &= ~(TRANSMISSION_CONTROL_TRIGGER_MASK); - /* Enqueue at the head of the queue */ - spin_lock_irqsave(&priv->tx_q_lock, lock_flags); - list_add(&buffered_pkt->q, &interfacePriv->genericMulticastOrBroadCastFrames); - spin_unlock_irqrestore(&priv->tx_q_lock, lock_flags); - break; - } else { - if(r) { - unifi_trace(priv, UDBG1, "send_multicast_frames: Send genericMulticastOrBroadCastFrame failed (%x, %x)\n", - buffered_pkt->hostTag, - r); - unifi_net_data_free(priv, &buffered_pkt->bulkdata); - } - if(!moreData) { - interfacePriv->dtimActive = FALSE; - if(!r) { - pduSent ++; - hostTag = buffered_pkt->hostTag; - } else { - send_vif_availibility_rsp(priv, uf_get_vif_identifier(interfacePriv->interfaceMode, interfaceTag), CSR_RC_UNSPECIFIED_FAILURE); - } - } - /* Buffered frame sent successfully */ - spin_lock_irqsave(&priv->staRecord_lock, lock_flags); - interfacePriv->noOfbroadcastPktQueued--; - spin_unlock_irqrestore(&priv->staRecord_lock, lock_flags); - kfree(buffered_pkt); - } - } - } - if((interfacePriv->dtimActive == FALSE)) { - /* Record the host Tag*/ - unifi_trace(priv, UDBG2, "send_multicast_frames: Recorded hostTag of EOSP packet: = 0x%x\n", hostTag); - interfacePriv->multicastPduHostTag = hostTag; - } - return pduSent; -} -#endif -void uf_process_ma_vif_availibility_ind(unifi_priv_t *priv, u8 *sigdata, - u32 siglen) -{ -#ifdef CSR_SUPPORT_SME - CSR_SIGNAL signal; - CSR_MA_VIF_AVAILABILITY_INDICATION *ind; - int r; - u16 interfaceTag; - u8 pduSent =0; - CSR_RESULT_CODE resultCode = CSR_RC_SUCCESS; - netInterface_priv_t *interfacePriv; - - unifi_trace(priv, UDBG3, - "uf_process_ma_vif_availibility_ind: Process signal 0x%.4X\n", - *((u16*)sigdata)); - - r = read_unpack_signal(sigdata, &signal); - if (r) { - unifi_error(priv, - "uf_process_ma_vif_availibility_ind: Received unknown signal 0x%.4X.\n", - CSR_GET_UINT16_FROM_LITTLE_ENDIAN(sigdata)); - return; - } - ind = &signal.u.MaVifAvailabilityIndication; - interfaceTag=ind->VirtualInterfaceIdentifier & 0xff; - - if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) { - unifi_error(priv, "in vif_availability_ind interfaceTag is wrong\n"); - return; - } - - interfacePriv = priv->interfacePriv[interfaceTag]; - - if(ind->Multicast) { - if(list_empty(&interfacePriv->genericMulticastOrBroadCastFrames) && - list_empty(&interfacePriv->genericMulticastOrBroadCastMgtFrames)) { - /* This condition can occur because of a potential race where the - TIM is not yet reset as host is waiting for confirm but it is sent - by firmware and DTIM occurs*/ - unifi_notice(priv, "ma_vif_availibility_ind recevied for multicast but queues are empty%d\n", interfaceTag); - send_vif_availibility_rsp(priv, ind->VirtualInterfaceIdentifier, CSR_RC_NO_BUFFERED_BROADCAST_MULTICAST_FRAMES); - interfacePriv->dtimActive = FALSE; - if(interfacePriv->multicastPduHostTag == 0xffffffff) { - unifi_notice(priv, "ma_vif_availibility_ind recevied for multicast but queues are empty%d\n", interfaceTag); - /* This may be an extra request in very rare race conditions but it is fine as it would atleast remove the potential lock up */ - if (!interfacePriv->bcTimSetReqPendingFlag) - { - update_tim(priv, 0, CSR_WIFI_TIM_RESET, interfaceTag, 0xFFFFFFFF); - } - else - { - /* Cache the TimSet value so that it will processed immidiatly after - * completing the current setTim Request - */ - interfacePriv->bcTimSetReqQueued = CSR_WIFI_TIM_RESET; - unifi_trace(priv, UDBG2, "uf_process_ma_vif_availibility_ind : One more UpdateDTim Request(%d) Queued \n", - interfacePriv->bcTimSetReqQueued); - } - } - return; - } - if(interfacePriv->dtimActive) { - unifi_trace(priv, UDBG2, "DTIM Occurred for already active DTIM interface %d\n", interfaceTag); - return; - } else { - unifi_trace(priv, UDBG2, "DTIM Occurred for interface %d\n", interfaceTag); - if(list_empty(&interfacePriv->genericMulticastOrBroadCastFrames)) { - set_eosp_transmit_ctrl(priv, &interfacePriv->genericMulticastOrBroadCastMgtFrames); - } else { - set_eosp_transmit_ctrl(priv, &interfacePriv->genericMulticastOrBroadCastFrames); - } - } - interfacePriv->dtimActive = TRUE; - pduSent = send_multicast_frames(priv, interfaceTag); - } - else { - unifi_error(priv, "Interface switching is not supported %d\n", interfaceTag); - resultCode = CSR_RC_NOT_SUPPORTED; - send_vif_availibility_rsp(priv, ind->VirtualInterfaceIdentifier, CSR_RC_NOT_SUPPORTED); - } -#endif -} -#ifdef CSR_SUPPORT_SME - -#define GET_ACTIVE_INTERFACE_TAG(priv) 0 - -static u8 uf_is_more_data_for_delivery_ac(unifi_priv_t *priv, CsrWifiRouterCtrlStaInfo_t *staRecord) -{ - s8 i; - - for(i=UNIFI_TRAFFIC_Q_VO; i >= UNIFI_TRAFFIC_Q_BK; i--) - { - if(((staRecord->powersaveMode[i]==CSR_WIFI_AC_DELIVERY_ONLY_ENABLE) - ||(staRecord->powersaveMode[i]==CSR_WIFI_AC_TRIGGER_AND_DELIVERY_ENABLED)) - &&(!list_empty(&staRecord->dataPdu[i]))) { - unifi_trace(priv, UDBG2, "uf_is_more_data_for_delivery_ac: Data Available AC = %d\n", i); - return TRUE; - } - } - - unifi_trace(priv, UDBG2, "uf_is_more_data_for_delivery_ac: Data NOT Available \n"); - return FALSE; -} - -static u8 uf_is_more_data_for_usp_delivery(unifi_priv_t *priv, CsrWifiRouterCtrlStaInfo_t *staRecord, unifi_TrafficQueue queue) -{ - s8 i; - - for(i = queue; i >= UNIFI_TRAFFIC_Q_BK; i--) - { - if(((staRecord->powersaveMode[i]==CSR_WIFI_AC_DELIVERY_ONLY_ENABLE) - ||(staRecord->powersaveMode[i]==CSR_WIFI_AC_TRIGGER_AND_DELIVERY_ENABLED)) - &&(!list_empty(&staRecord->dataPdu[i]))) { - unifi_trace(priv, UDBG2, "uf_is_more_data_for_usp_delivery: Data Available AC = %d\n", i); - return TRUE; - } - } - - unifi_trace(priv, UDBG2, "uf_is_more_data_for_usp_delivery: Data NOT Available \n"); - return FALSE; -} - -/* - * --------------------------------------------------------------------------- - * uf_send_buffered_data_from_delivery_ac - * - * This function takes care of - * -> Parsing the delivery enabled queue & sending frame down to HIP - * -> Setting EOSP=1 when USP to be terminated - * -> Depending on MAX SP length services the USP - * - * NOTE:This function always called from uf_handle_uspframes_delivery(), Dont - * call this function from any other location in code - * - * Arguments: - * priv Pointer to device private context struct - * vif interface specific HIP vif instance - * staInfo peer for which UAPSD to be scheduled - * queue AC from which Data to be sent in USP - * txList access category for processing list - * --------------------------------------------------------------------------- - */ -void uf_send_buffered_data_from_delivery_ac(unifi_priv_t *priv, - CsrWifiRouterCtrlStaInfo_t * staInfo, - u8 queue, - struct list_head *txList) -{ - - u16 interfaceTag = GET_ACTIVE_INTERFACE_TAG(priv); - tx_buffered_packets_t * buffered_pkt = NULL; - unsigned long lock_flags; - u8 eosp=FALSE; - s8 r =0; - u8 moreData = FALSE; - netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag]; - - unifi_trace(priv, UDBG2, "++uf_send_buffered_data_from_delivery_ac, active=%x\n", staInfo->uapsdActive); - - if (queue > UNIFI_TRAFFIC_Q_VO) - { - return; - } - while((buffered_pkt=dequeue_tx_data_pdu(priv, txList))) { - if((IS_DTIM_ACTIVE(interfacePriv->dtimActive, interfacePriv->multicastPduHostTag))) { - unifi_trace(priv, UDBG2, "uf_send_buffered_data_from_delivery_ac: DTIM Active, suspend UAPSD, staId: 0x%x\n", - staInfo->aid); - - /* Once resume called, the U-APSD delivery operation will resume */ - spin_lock_irqsave(&priv->staRecord_lock, lock_flags); - staInfo->uspSuspend = TRUE; - spin_unlock_irqrestore(&priv->staRecord_lock, lock_flags); - /* re-queueing the packet as DTIM started */ - spin_lock_irqsave(&priv->tx_q_lock, lock_flags); - list_add(&buffered_pkt->q, txList); - spin_unlock_irqrestore(&priv->tx_q_lock, lock_flags); - break; - } - - buffered_pkt->transmissionControl &= - ~(TRANSMISSION_CONTROL_TRIGGER_MASK | TRANSMISSION_CONTROL_EOSP_MASK); - - - if((staInfo->wmmOrQosEnabled == TRUE)&&(staInfo->uapsdActive == TRUE)) { - - buffered_pkt->transmissionControl = TRANSMISSION_CONTROL_TRIGGER_MASK; - - /* Check All delivery enables Ac for more data, because caller of this - * function not aware about last packet - * (First check in moreData fetching helps in draining out Mgt frames Q) - */ - moreData = (!list_empty(txList) || uf_is_more_data_for_usp_delivery(priv, staInfo, queue)); - - if(staInfo->noOfSpFramesSent == (staInfo->maxSpLength - 1)) { - moreData = FALSE; - } - - if(moreData == FALSE) { - eosp = TRUE; - buffered_pkt->transmissionControl = - (TRANSMISSION_CONTROL_TRIGGER_MASK | TRANSMISSION_CONTROL_EOSP_MASK); - } - } else { - /* Non QoS and non U-APSD */ - unifi_warning(priv, "uf_send_buffered_data_from_delivery_ac: non U-APSD !!! \n"); - } - - unifi_trace(priv, UDBG2, "uf_send_buffered_data_from_delivery_ac : MoreData:%d, EOSP:%d\n", moreData, eosp); - - if((r=frame_and_send_queued_pdu(priv, buffered_pkt, staInfo, moreData, eosp)) == -ENOSPC) { - - unifi_trace(priv, UDBG2, "uf_send_buffered_data_from_delivery_ac: UASPD suspended, ENOSPC in hipQ=%x\n", queue); - - /* Once resume called, the U-APSD delivery operation will resume */ - spin_lock_irqsave(&priv->staRecord_lock, lock_flags); - staInfo->uspSuspend = TRUE; - spin_unlock_irqrestore(&priv->staRecord_lock, lock_flags); - - spin_lock_irqsave(&priv->tx_q_lock, lock_flags); - list_add(&buffered_pkt->q, txList); - spin_unlock_irqrestore(&priv->tx_q_lock, lock_flags); - priv->pausedStaHandle[queue]=(u8)(staInfo->assignedHandle); - break; - } else { - if(r){ - /* the PDU failed where we can't do any thing so free the storage */ - unifi_net_data_free(priv, &buffered_pkt->bulkdata); - } - kfree(buffered_pkt); - spin_lock_irqsave(&priv->staRecord_lock, lock_flags); - staInfo->noOfSpFramesSent++; - if((!moreData) || (staInfo->noOfSpFramesSent == staInfo->maxSpLength)) { - unifi_trace(priv, UDBG2, "uf_send_buffered_data_from_delivery_ac: Terminating USP\n"); - staInfo->uapsdActive = FALSE; - staInfo->uspSuspend = FALSE; - staInfo->noOfSpFramesSent = 0; - spin_unlock_irqrestore(&priv->staRecord_lock, lock_flags); - break; - } - spin_unlock_irqrestore(&priv->staRecord_lock, lock_flags); - } - } - unifi_trace(priv, UDBG2, "--uf_send_buffered_data_from_delivery_ac, active=%x\n", staInfo->uapsdActive); -} - -void uf_send_buffered_data_from_ac(unifi_priv_t *priv, - CsrWifiRouterCtrlStaInfo_t * staInfo, - u8 queue, - struct list_head *txList) -{ - tx_buffered_packets_t * buffered_pkt = NULL; - unsigned long lock_flags; - u8 eosp=FALSE; - u8 moreData = FALSE; - s8 r =0; - - unifi_trace(priv, UDBG2, "uf_send_buffered_data_from_ac :\n"); - - while(!isRouterBufferEnabled(priv, queue) && - ((buffered_pkt=dequeue_tx_data_pdu(priv, txList))!=NULL)){ - - buffered_pkt->transmissionControl &= - ~(TRANSMISSION_CONTROL_TRIGGER_MASK|TRANSMISSION_CONTROL_EOSP_MASK); - - unifi_trace(priv, UDBG3, "uf_send_buffered_data_from_ac : MoreData:%d, EOSP:%d\n", moreData, eosp); - - if((r=frame_and_send_queued_pdu(priv, buffered_pkt, staInfo, moreData, eosp)) == -ENOSPC) { - /* Enqueue at the head of the queue */ - spin_lock_irqsave(&priv->tx_q_lock, lock_flags); - list_add(&buffered_pkt->q, txList); - spin_unlock_irqrestore(&priv->tx_q_lock, lock_flags); - if(staInfo != NULL){ - priv->pausedStaHandle[queue]=(u8)(staInfo->assignedHandle); - } - unifi_trace(priv, UDBG3, " uf_send_buffered_data_from_ac: PDU sending failed .. no space for queue %d \n", queue); - } else { - if(r){ - /* the PDU failed where we can't do any thing so free the storage */ - unifi_net_data_free(priv, &buffered_pkt->bulkdata); - } - kfree(buffered_pkt); - } - } - -} - -void uf_send_buffered_frames(unifi_priv_t *priv, unifi_TrafficQueue q) -{ - u16 interfaceTag = GET_ACTIVE_INTERFACE_TAG(priv); - u32 startIndex=0, endIndex=0; - CsrWifiRouterCtrlStaInfo_t * staInfo = NULL; - u8 queue; - u8 moreData = FALSE; - - netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag]; - - if(!((interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP) || - (interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO))) - return; - - queue = (q<=3)?q:0; - - if(interfacePriv->dtimActive) { - /* this function updates dtimActive*/ - send_multicast_frames(priv, interfaceTag); - if(!interfacePriv->dtimActive) { - moreData = (!list_empty(&interfacePriv->genericMulticastOrBroadCastMgtFrames) || - !list_empty(&interfacePriv->genericMulticastOrBroadCastFrames)); - if(!moreData) { - if (!interfacePriv->bcTimSetReqPendingFlag) - { - update_tim(priv, 0, CSR_WIFI_TIM_RESET, interfaceTag, 0XFFFFFFFF); - } - else - { - /* Cache the TimSet value so that it will processed immidiatly after - * completing the current setTim Request - */ - interfacePriv->bcTimSetReqQueued = CSR_WIFI_TIM_RESET; - unifi_trace(priv, UDBG2, "uf_send_buffered_frames : One more UpdateDTim Request(%d) Queued \n", - interfacePriv->bcTimSetReqQueued); - } - } - } else { - moreData = (!list_empty(&interfacePriv->genericMulticastOrBroadCastMgtFrames) || - !list_empty(&interfacePriv->genericMulticastOrBroadCastFrames)); - if(!moreData) { - /* This should never happen but if it happens, we need a way out */ - unifi_error(priv, "ERROR: No More Data but DTIM is active sending Response\n"); - send_vif_availibility_rsp(priv, uf_get_vif_identifier(interfacePriv->interfaceMode, interfaceTag), CSR_RC_NO_BUFFERED_BROADCAST_MULTICAST_FRAMES); - interfacePriv->dtimActive = FALSE; - } - } - return; - } - if(priv->pausedStaHandle[queue] > 7) { - priv->pausedStaHandle[queue] = 0; - } - - if(queue == UNIFI_TRAFFIC_Q_VO) { - - - unifi_trace(priv, UDBG2, "uf_send_buffered_frames : trying mgt from queue=%d\n", queue); - for(startIndex= 0; startIndex < UNIFI_MAX_CONNECTIONS;startIndex++) { - staInfo = CsrWifiRouterCtrlGetStationRecordFromHandle(priv, startIndex, interfaceTag); - if(!staInfo ) { - continue; - } else if((staInfo->currentPeerState == CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_POWER_SAVE) - &&(staInfo->uapsdActive == FALSE) ) { - continue; - } - - if((staInfo != NULL)&&(staInfo->currentPeerState == CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_ACTIVE) - &&(staInfo->uapsdActive == FALSE)){ - /*Non-UAPSD case push the management frames out*/ - if(!list_empty(&staInfo->mgtFrames)){ - uf_send_buffered_data_from_ac(priv, staInfo, UNIFI_TRAFFIC_Q_VO, &staInfo->mgtFrames); - } - } - - if(isRouterBufferEnabled(priv, queue)) { - unifi_notice(priv, "uf_send_buffered_frames : No space Left for queue = %d\n", queue); - break; - } - } - /*push generic management frames out*/ - if(!list_empty(&interfacePriv->genericMgtFrames)) { - unifi_trace(priv, UDBG2, "uf_send_buffered_frames : trying generic mgt from queue=%d\n", queue); - uf_send_buffered_data_from_ac(priv, staInfo, UNIFI_TRAFFIC_Q_VO, &interfacePriv->genericMgtFrames); - } - } - - - unifi_trace(priv, UDBG2, "uf_send_buffered_frames : Resume called for Queue=%d\n", queue); - unifi_trace(priv, UDBG2, "uf_send_buffered_frames : start=%d end=%d\n", startIndex, endIndex); - - startIndex = priv->pausedStaHandle[queue]; - endIndex = (startIndex + UNIFI_MAX_CONNECTIONS -1) % UNIFI_MAX_CONNECTIONS; - - while(startIndex != endIndex) { - staInfo = CsrWifiRouterCtrlGetStationRecordFromHandle(priv, startIndex, interfaceTag); - if(!staInfo) { - startIndex ++; - if(startIndex >= UNIFI_MAX_CONNECTIONS) { - startIndex = 0; - } - continue; - } else if((staInfo->currentPeerState == CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_POWER_SAVE) - &&(staInfo->uapsdActive == FALSE)) { - startIndex ++; - if(startIndex >= UNIFI_MAX_CONNECTIONS) { - startIndex = 0; - } - continue; - } - /* Peer is active or U-APSD is active so send PDUs to the peer */ - unifi_trace(priv, UDBG2, "uf_send_buffered_frames : trying data from queue=%d\n", queue); - - - if((staInfo != NULL)&&(staInfo->currentPeerState == CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_ACTIVE) - &&(staInfo->uapsdActive == FALSE)) { - if(!list_empty(&staInfo->dataPdu[queue])) { - - /*Non-UAPSD case push the AC frames out*/ - uf_send_buffered_data_from_ac(priv, staInfo, queue, (&staInfo->dataPdu[queue])); - } - } - startIndex ++; - if(startIndex >= UNIFI_MAX_CONNECTIONS) { - startIndex = 0; - } - } - if(isRouterBufferEnabled(priv, queue)) { - priv->pausedStaHandle[queue] = endIndex; - } else { - priv->pausedStaHandle[queue] = 0; - } - - /* U-APSD might have stopped because of ENOSPC in lib_hip (pause activity). - * So restart it if U-APSD was active with any of the station - */ - unifi_trace(priv, UDBG4, "csrWifiHipSendBufferedFrames: UAPSD Resume Q=%x\n", queue); - resume_suspended_uapsd(priv, interfaceTag); -} - - -u8 uf_is_more_data_for_non_delivery_ac(CsrWifiRouterCtrlStaInfo_t *staRecord) -{ - u8 i; - - for(i=0;i<=3;i++) - { - if(((staRecord->powersaveMode[i]==CSR_WIFI_AC_TRIGGER_ONLY_ENABLED) - ||(staRecord->powersaveMode[i]==CSR_WIFI_AC_LEGACY_POWER_SAVE)) - &&(!list_empty(&staRecord->dataPdu[i]))){ - - return TRUE; - } - } - - if(((staRecord->powersaveMode[UNIFI_TRAFFIC_Q_VO]==CSR_WIFI_AC_TRIGGER_ONLY_ENABLED) - ||(staRecord->powersaveMode[UNIFI_TRAFFIC_Q_VO]==CSR_WIFI_AC_LEGACY_POWER_SAVE)) - &&(!list_empty(&staRecord->mgtFrames))){ - - return TRUE; - } - - - - return FALSE; -} - - -int uf_process_station_records_for_sending_data(unifi_priv_t *priv, u16 interfaceTag, - CsrWifiRouterCtrlStaInfo_t *srcStaInfo, - CsrWifiRouterCtrlStaInfo_t *dstStaInfo) -{ - netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag]; - - unifi_trace(priv, UDBG5, "entering uf_process_station_records_for_sending_data\n"); - - if (srcStaInfo->currentPeerState == CSR_WIFI_ROUTER_CTRL_PEER_DISCONNECTED) { - unifi_error(priv, "Peer State not connected AID = %x, handle = %x, control port state = %x\n", - srcStaInfo->aid, srcStaInfo->assignedHandle, srcStaInfo->peerControlledPort->port_action); - return -1; - } - switch (interfacePriv->interfaceMode) - { - case CSR_WIFI_ROUTER_CTRL_MODE_P2PGO: - case CSR_WIFI_ROUTER_CTRL_MODE_AP: - unifi_trace(priv, UDBG5, "mode is AP/P2PGO\n"); - break; - default: - unifi_warning(priv, "mode is nor AP neither P2PGO, packet cant be xmit\n"); - return -1; - } - - switch(dstStaInfo->peerControlledPort->port_action) - { - case CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_CLOSED_DISCARD: - case CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_CLOSED_BLOCK: - unifi_trace(priv, UDBG5, "destination port is closed/blocked, discarding the packet\n"); - return -1; - default: - unifi_trace(priv, UDBG5, "destination port state is open\n"); - } - - /* port state is open, destination station record is valid, Power save state is - * validated in uf_process_ma_packet_req function - */ - unifi_trace(priv, UDBG5, "leaving uf_process_station_records_for_sending_data\n"); - return 0; -} - - -/* - * --------------------------------------------------------------------------- - * uf_handle_uspframes_delivery - * - * This function takes care of handling USP session for peer, when - * -> trigger frame from peer - * -> suspended USP to be processed (resumed) - * - * NOTE: uf_send_buffered_data_from_delivery_ac() always called from this function, Dont - * make a direct call to uf_send_buffered_data_from_delivery_ac() from any other part of - * code - * - * Arguments: - * priv Pointer to device private context struct - * staInfo peer for which UAPSD to be scheduled - * interfaceTag virtual interface tag - * --------------------------------------------------------------------------- - */ -static void uf_handle_uspframes_delivery(unifi_priv_t * priv, CsrWifiRouterCtrlStaInfo_t *staInfo, u16 interfaceTag) -{ - - s8 i; - u8 allDeliveryEnabled = 0, dataAvailable = 0; - netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag]; - unsigned long lock_flags; - - unifi_trace(priv, UDBG2, " ++ uf_handle_uspframes_delivery, uapsd active=%x, suspended?=%x\n", - staInfo->uapsdActive, staInfo->uspSuspend); - - /* Check for Buffered frames according to priority order & deliver it - * 1. AC_VO delivery enable & Mgt frames available - * 2. Process remaining Ac's from order AC_VO to AC_BK - */ - - /* USP initiated by WMMPS enabled peer & SET the status flag to TRUE */ - if (!staInfo->uspSuspend && staInfo->uapsdActive) - { - unifi_notice(priv, "uf_handle_uspframes_delivery: U-APSD already active! STA=%x:%x:%x:%x:%x:%x\n", - staInfo->peerMacAddress.a[0], staInfo->peerMacAddress.a[1], - staInfo->peerMacAddress.a[2], staInfo->peerMacAddress.a[3], - staInfo->peerMacAddress.a[4], staInfo->peerMacAddress.a[5]); - return; - } - - spin_lock_irqsave(&priv->staRecord_lock, lock_flags); - staInfo->uapsdActive = TRUE; - staInfo->uspSuspend = FALSE; - spin_unlock_irqrestore(&priv->staRecord_lock, lock_flags); - - if(((staInfo->powersaveMode[UNIFI_TRAFFIC_Q_VO]==CSR_WIFI_AC_TRIGGER_AND_DELIVERY_ENABLED)|| - (staInfo->powersaveMode[UNIFI_TRAFFIC_Q_VO]==CSR_WIFI_AC_DELIVERY_ONLY_ENABLE)) - && (!list_empty(&staInfo->mgtFrames))) { - - /* Management queue has data && UNIFI_TRAFFIC_Q_VO is delivery enable */ - unifi_trace(priv, UDBG4, "uf_handle_uspframes_delivery: Sending buffered management frames\n"); - uf_send_buffered_data_from_delivery_ac(priv, staInfo, UNIFI_TRAFFIC_Q_VO, &staInfo->mgtFrames); - } - - if (!uf_is_more_data_for_delivery_ac(priv, staInfo)) { - /* All delivery enable AC's are empty, so QNULL to be sent to terminate the USP - * NOTE: If we have sent Mgt frame also, we must send QNULL followed to terminate USP - */ - if (!staInfo->uspSuspend) { - spin_lock_irqsave(&priv->staRecord_lock, lock_flags); - staInfo->uapsdActive = FALSE; - spin_unlock_irqrestore(&priv->staRecord_lock, lock_flags); - - unifi_trace(priv, UDBG2, "uf_handle_uspframes_delivery: sending QNull for trigger\n"); - uf_send_qos_null(priv, interfaceTag, staInfo->peerMacAddress.a, (CSR_PRIORITY) staInfo->triggerFramePriority, staInfo); - staInfo->triggerFramePriority = CSR_QOS_UP0; - } else { - unifi_trace(priv, UDBG2, "uf_handle_uspframes_delivery: MgtQ xfer suspended\n"); - } - } else { - for(i = UNIFI_TRAFFIC_Q_VO; i >= UNIFI_TRAFFIC_Q_BK; i--) { - if(((staInfo->powersaveMode[i]==CSR_WIFI_AC_DELIVERY_ONLY_ENABLE) - ||(staInfo->powersaveMode[i]==CSR_WIFI_AC_TRIGGER_AND_DELIVERY_ENABLED)) - && (!list_empty(&staInfo->dataPdu[i]))) { - /* Deliver Data according to AC priority (from VO to BK) as part of USP */ - unifi_trace(priv, UDBG4, "uf_handle_uspframes_delivery: Buffered data frames from Queue (%d) for USP\n", i); - uf_send_buffered_data_from_delivery_ac(priv, staInfo, i, &staInfo->dataPdu[i]); - } - - if ((!staInfo->uapsdActive) || - (staInfo->uspSuspend && IS_DTIM_ACTIVE(interfacePriv->dtimActive, interfacePriv->multicastPduHostTag))) { - /* If DTIM active found on one AC, No need to parse the remaining AC's - * as USP suspended. Break out of loop - */ - unifi_trace(priv, UDBG2, "uf_handle_uspframes_delivery: suspend=%x, DTIM=%x, USP terminated=%s\n", - staInfo->uspSuspend, IS_DTIM_ACTIVE(interfacePriv->dtimActive, interfacePriv->multicastPduHostTag), - staInfo->uapsdActive?"NO":"YES"); - break; - } - } - } - - /* Depending on the USP status, update the TIM accordingly for delivery enabled AC only - * (since we are not manipulating any Non-delivery list(AC)) - */ - is_all_ac_deliver_enabled_and_moredata(staInfo, &allDeliveryEnabled, &dataAvailable); - if ((allDeliveryEnabled && !dataAvailable)) { - if ((staInfo->timSet != CSR_WIFI_TIM_RESET) && (staInfo->timSet != CSR_WIFI_TIM_RESETTING)) { - staInfo->updateTimReqQueued = (u8) CSR_WIFI_TIM_RESET; - unifi_trace(priv, UDBG4, " --uf_handle_uspframes_delivery, UAPSD timset\n"); - if (!staInfo->timRequestPendingFlag) { - update_tim(priv, staInfo->aid, 0, interfaceTag, staInfo->assignedHandle); - } - } - } - unifi_trace(priv, UDBG2, " --uf_handle_uspframes_delivery, uapsd active=%x, suspend?=%x\n", - staInfo->uapsdActive, staInfo->uspSuspend); -} - -void uf_process_wmm_deliver_ac_uapsd(unifi_priv_t * priv, - CsrWifiRouterCtrlStaInfo_t * srcStaInfo, - u16 qosControl, - u16 interfaceTag) -{ - CSR_PRIORITY priority; - unifi_TrafficQueue priority_q; - unsigned long lock_flags; - - unifi_trace(priv, UDBG2, "++uf_process_wmm_deliver_ac_uapsd: uapsdactive?=%x\n", srcStaInfo->uapsdActive); - /* If recceived Frames trigger Frame and Devlivery enabled AC has data - * then transmit from High priorty delivery enabled AC - */ - priority = (CSR_PRIORITY)(qosControl & IEEE802_11_QC_TID_MASK); - priority_q = unifi_frame_priority_to_queue((CSR_PRIORITY) priority); - - if((srcStaInfo->powersaveMode[priority_q]==CSR_WIFI_AC_TRIGGER_ONLY_ENABLED) - ||(srcStaInfo->powersaveMode[priority_q]==CSR_WIFI_AC_TRIGGER_AND_DELIVERY_ENABLED)) { - spin_lock_irqsave(&priv->staRecord_lock, lock_flags); - srcStaInfo->triggerFramePriority = priority; - spin_unlock_irqrestore(&priv->staRecord_lock, lock_flags); - unifi_trace(priv, UDBG2, "uf_process_wmm_deliver_ac_uapsd: trigger frame, Begin U-APSD, triggerQ=%x\n", priority_q); - uf_handle_uspframes_delivery(priv, srcStaInfo, interfaceTag); - } - unifi_trace(priv, UDBG2, "--uf_process_wmm_deliver_ac_uapsd: uapsdactive?=%x\n", srcStaInfo->uapsdActive); -} - - -void uf_send_qos_null(unifi_priv_t * priv, u16 interfaceTag, const u8 *da, CSR_PRIORITY priority, CsrWifiRouterCtrlStaInfo_t * srcStaInfo) -{ - bulk_data_param_t bulkdata; - CsrResult csrResult; - struct sk_buff *skb, *newSkb = NULL; - CsrWifiMacAddress peerAddress; - netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag]; - CSR_TRANSMISSION_CONTROL transmissionControl = (TRANSMISSION_CONTROL_EOSP_MASK | TRANSMISSION_CONTROL_TRIGGER_MASK); - int r; - CSR_SIGNAL signal; - u32 priority_q; - CSR_RATE transmitRate = 0; - - - /* Send a Null Frame to Peer, - * 32= size of mac header */ - csrResult = unifi_net_data_malloc(priv, &bulkdata.d[0], MAC_HEADER_SIZE + QOS_CONTROL_HEADER_SIZE); - - if (csrResult != CSR_RESULT_SUCCESS) { - unifi_error(priv, " failed to allocate request_data. in uf_send_qos_null func\n"); - return ; - } - skb = (struct sk_buff *)(bulkdata.d[0].os_net_buf_ptr); - skb->len = 0; - bulkdata.d[0].os_data_ptr = skb->data; - bulkdata.d[0].os_net_buf_ptr = (unsigned char*)skb; - bulkdata.d[0].net_buf_length = bulkdata.d[0].data_length = skb->len; - bulkdata.d[1].os_data_ptr = NULL; - bulkdata.d[1].os_net_buf_ptr = NULL; - bulkdata.d[1].net_buf_length = bulkdata.d[1].data_length = 0; - - /* For null frames protection bit should not be set in MAC header, so passing value 0 below for protection field */ - - if (prepare_and_add_macheader(priv, skb, newSkb, priority, &bulkdata, interfaceTag, da, interfacePriv->bssid.a, 0)) { - unifi_error(priv, "failed to create MAC header\n"); - unifi_net_data_free(priv, &bulkdata.d[0]); - return; - } - memcpy(peerAddress.a, ((u8 *) bulkdata.d[0].os_data_ptr) + 4, ETH_ALEN); - /* convert priority to queue */ - priority_q = unifi_frame_priority_to_queue((CSR_PRIORITY) priority); - - /* Frame ma-packet.req, this is saved/transmitted depend on queue state - * send the null frame at data rate of 1 Mb/s for AP or 6 Mb/s for P2PGO - */ - switch (interfacePriv->interfaceMode) - { - case CSR_WIFI_ROUTER_CTRL_MODE_AP: - transmitRate = 2; - break; - case CSR_WIFI_ROUTER_CTRL_MODE_P2PGO: - transmitRate = 12; - break; - default: - transmitRate = 0; - } - unifi_frame_ma_packet_req(priv, priority, transmitRate, 0xffffffff, interfaceTag, - transmissionControl, priv->netdev_client->sender_id, - peerAddress.a, &signal); - - r = ul_send_signal_unpacked(priv, &signal, &bulkdata); - if(r) { - unifi_error(priv, "failed to send QOS data null packet result: %d\n", r); - unifi_net_data_free(priv, &bulkdata.d[0]); - } - - return; - -} -void uf_send_nulldata(unifi_priv_t * priv, u16 interfaceTag, const u8 *da, CSR_PRIORITY priority, CsrWifiRouterCtrlStaInfo_t * srcStaInfo) -{ - bulk_data_param_t bulkdata; - CsrResult csrResult; - struct sk_buff *skb, *newSkb = NULL; - CsrWifiMacAddress peerAddress; - netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag]; - CSR_TRANSMISSION_CONTROL transmissionControl = 0; - int r; - CSR_SIGNAL signal; - u32 priority_q; - CSR_RATE transmitRate = 0; - CSR_MA_PACKET_REQUEST *req = &signal.u.MaPacketRequest; - unsigned long lock_flags; - - /* Send a Null Frame to Peer, size = 24 for MAC header */ - csrResult = unifi_net_data_malloc(priv, &bulkdata.d[0], MAC_HEADER_SIZE); - - if (csrResult != CSR_RESULT_SUCCESS) { - unifi_error(priv, "uf_send_nulldata: Failed to allocate memory for NULL frame\n"); - return ; - } - skb = (struct sk_buff *)(bulkdata.d[0].os_net_buf_ptr); - skb->len = 0; - bulkdata.d[0].os_data_ptr = skb->data; - bulkdata.d[0].os_net_buf_ptr = (unsigned char*)skb; - bulkdata.d[0].net_buf_length = bulkdata.d[0].data_length = skb->len; - bulkdata.d[1].os_data_ptr = NULL; - bulkdata.d[1].os_net_buf_ptr = NULL; - bulkdata.d[1].net_buf_length = bulkdata.d[1].data_length = 0; - - /* For null frames protection bit should not be set in MAC header, so passing value 0 below for protection field */ - if (prepare_and_add_macheader(priv, skb, newSkb, priority, &bulkdata, interfaceTag, da, interfacePriv->bssid.a, 0)) { - unifi_error(priv, "uf_send_nulldata: Failed to create MAC header\n"); - unifi_net_data_free(priv, &bulkdata.d[0]); - return; - } - memcpy(peerAddress.a, ((u8 *) bulkdata.d[0].os_data_ptr) + 4, ETH_ALEN); - /* convert priority to queue */ - priority_q = unifi_frame_priority_to_queue((CSR_PRIORITY) priority); - transmissionControl &= ~(CSR_NO_CONFIRM_REQUIRED); - - /* Frame ma-packet.req, this is saved/transmitted depend on queue state - * send the null frame at data rate of 1 Mb/s for AP or 6 Mb/s for P2PGO - */ - switch (interfacePriv->interfaceMode) - { - case CSR_WIFI_ROUTER_CTRL_MODE_AP: - transmitRate = 2; - break; - case CSR_WIFI_ROUTER_CTRL_MODE_P2PGO: - transmitRate = 12; - break; - default: - transmitRate = 0; - } - unifi_frame_ma_packet_req(priv, priority, transmitRate, INVALID_HOST_TAG, interfaceTag, - transmissionControl, priv->netdev_client->sender_id, - peerAddress.a, &signal); - - /* Save host tag to check the status on reception of MA packet confirm */ - srcStaInfo->nullDataHostTag = req->HostTag; - unifi_trace(priv, UDBG1, "uf_send_nulldata: STA AID = %d hostTag = %x\n", srcStaInfo->aid, req->HostTag); - - r = ul_send_signal_unpacked(priv, &signal, &bulkdata); - - if(r == -ENOSPC) { - unifi_trace(priv, UDBG1, "uf_send_nulldata: ENOSPC Requeue the Null frame\n"); - enque_tx_data_pdu(priv, &bulkdata, &srcStaInfo->dataPdu[priority_q], &signal, 1); - spin_lock_irqsave(&priv->staRecord_lock, lock_flags); - srcStaInfo->noOfPktQueued++; - spin_unlock_irqrestore(&priv->staRecord_lock, lock_flags); - - - } - if(r && r != -ENOSPC){ - unifi_error(priv, "uf_send_nulldata: Failed to send Null frame Error = %d\n", r); - unifi_net_data_free(priv, &bulkdata.d[0]); - srcStaInfo->nullDataHostTag = INVALID_HOST_TAG; - } - - return; -} - -u8 uf_check_broadcast_bssid(unifi_priv_t *priv, const bulk_data_param_t *bulkdata) -{ - u8 *bssid = NULL; - static const CsrWifiMacAddress broadcast_address = {{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}}; - u8 toDs, fromDs; - - toDs = (((bulkdata->d[0].os_data_ptr)[1]) & 0x01) ? 1 : 0; - fromDs =(((bulkdata->d[0].os_data_ptr)[1]) & 0x02) ? 1 : 0; - - if (toDs && fromDs) - { - unifi_trace(priv, UDBG6, "Address 4 present, Don't try to find BSSID\n"); - bssid = NULL; - } - else if((toDs == 0) && (fromDs ==0)) - { - /* BSSID is Address 3 */ - bssid = (u8 *) (bulkdata->d[0].os_data_ptr + 4 + (2 * ETH_ALEN)); - } - else if(toDs) - { - /* BSSID is Address 1 */ - bssid = (u8 *) (bulkdata->d[0].os_data_ptr + 4); - } - else if(fromDs) - { - /* BSSID is Address 2 */ - bssid = (u8 *) (bulkdata->d[0].os_data_ptr + 4 + ETH_ALEN); - } - - if (memcmp(broadcast_address.a, bssid, ETH_ALEN)== 0) - { - return TRUE; - } - else - { - return FALSE; - } -} - - -u8 uf_process_pm_bit_for_peer(unifi_priv_t * priv, CsrWifiRouterCtrlStaInfo_t * srcStaInfo, - u8 pmBit, u16 interfaceTag) -{ - u8 moreData = FALSE; - u8 powerSaveChanged = FALSE; - unsigned long lock_flags; - - unifi_trace(priv, UDBG3, "entering uf_process_pm_bit_for_peer\n"); - if (pmBit) { - priv->allPeerDozing |= (0x01 << (srcStaInfo->assignedHandle)); - } else { - priv->allPeerDozing &= ~(0x01 << (srcStaInfo->assignedHandle)); - } - if(pmBit) { - if(srcStaInfo->currentPeerState == CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_ACTIVE) { - - /* disable the preemption */ - spin_lock_irqsave(&priv->staRecord_lock, lock_flags); - srcStaInfo->currentPeerState =CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_POWER_SAVE; - powerSaveChanged = TRUE; - /* enable the preemption */ - spin_unlock_irqrestore(&priv->staRecord_lock, lock_flags); - } else { - return powerSaveChanged; - } - } else { - if(srcStaInfo->currentPeerState == CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_POWER_SAVE) { - /* disable the preemption */ - spin_lock_irqsave(&priv->staRecord_lock, lock_flags); - srcStaInfo->currentPeerState = CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_ACTIVE; - powerSaveChanged = TRUE; - /* enable the preemption */ - spin_unlock_irqrestore(&priv->staRecord_lock, lock_flags); - }else { - return powerSaveChanged; - } - } - - - if(srcStaInfo->currentPeerState == CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_ACTIVE) { - unifi_trace(priv, UDBG3, "Peer with AID = %d is active now\n", srcStaInfo->aid); - process_peer_active_transition(priv, srcStaInfo, interfaceTag); - } else { - unifi_trace(priv, UDBG3, "Peer with AID = %d is in PS Now\n", srcStaInfo->aid); - /* Set TIM if needed */ - if(!srcStaInfo->wmmOrQosEnabled) { - moreData = (!list_empty(&srcStaInfo->mgtFrames) || - !list_empty(&srcStaInfo->dataPdu[UNIFI_TRAFFIC_Q_VO])|| - !list_empty(&srcStaInfo->dataPdu[UNIFI_TRAFFIC_Q_CONTENTION])); - if(moreData && (srcStaInfo->timSet == CSR_WIFI_TIM_RESET)) { - unifi_trace(priv, UDBG3, "This condition should not occur\n"); - if (!srcStaInfo->timRequestPendingFlag){ - update_tim(priv, srcStaInfo->aid, 1, interfaceTag, srcStaInfo->assignedHandle); - } - else - { - /* Cache the TimSet value so that it will processed immidiatly after - * completing the current setTim Request - */ - srcStaInfo->updateTimReqQueued = 1; - unifi_trace(priv, UDBG6, "update_tim : One more UpdateTim Request (Tim value:%d) Queued for AID %x\n", srcStaInfo->updateTimReqQueued, - srcStaInfo->aid); - } - - } - } else { - u8 allDeliveryEnabled = 0, dataAvailable = 0; - unifi_trace(priv, UDBG5, "Qos in AP Mode\n"); - /* Check if all AC's are Delivery Enabled */ - is_all_ac_deliver_enabled_and_moredata(srcStaInfo, &allDeliveryEnabled, &dataAvailable); - /*check for more data in non-delivery enabled queues*/ - moreData = (uf_is_more_data_for_non_delivery_ac(srcStaInfo) || (allDeliveryEnabled && dataAvailable)); - - if(moreData && (srcStaInfo->timSet == CSR_WIFI_TIM_RESET)) { - if (!srcStaInfo->timRequestPendingFlag){ - update_tim(priv, srcStaInfo->aid, 1, interfaceTag, srcStaInfo->assignedHandle); - } - else - { - /* Cache the TimSet value so that it will processed immidiatly after - * completing the current setTim Request - */ - srcStaInfo->updateTimReqQueued = 1; - unifi_trace(priv, UDBG6, "update_tim : One more UpdateTim Request (Tim value:%d) Queued for AID %x\n", srcStaInfo->updateTimReqQueued, - srcStaInfo->aid); - } - } - } - } - unifi_trace(priv, UDBG3, "leaving uf_process_pm_bit_for_peer\n"); - return powerSaveChanged; -} - - - -void uf_process_ps_poll(unifi_priv_t *priv, u8* sa, u8* da, u8 pmBit, u16 interfaceTag) -{ - CsrWifiRouterCtrlStaInfo_t *staRecord = - CsrWifiRouterCtrlGetStationRecordFromPeerMacAddress(priv, sa, interfaceTag); - tx_buffered_packets_t * buffered_pkt = NULL; - CsrWifiMacAddress peerMacAddress; - unsigned long lock_flags; - s8 r =0; - u8 moreData = FALSE; - netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag]; - - unifi_trace(priv, UDBG3, "entering uf_process_ps_poll\n"); - if(!staRecord) { - memcpy(peerMacAddress.a, sa, ETH_ALEN); - unifi_trace(priv, UDBG3, "In uf_process_ps_poll, sta record not found:unexpected frame addr = %x:%x:%x:%x:%x:%x\n", - sa[0], sa[1], sa[2], sa[3], sa[4], sa[5]); - CsrWifiRouterCtrlUnexpectedFrameIndSend(priv->CSR_WIFI_SME_IFACEQUEUE, 0, interfaceTag, peerMacAddress); - return; - } - - uf_process_pm_bit_for_peer(priv, staRecord, pmBit, interfaceTag); - - /* Update station last activity time */ - staRecord->activity_flag = TRUE; - - /* This should not change the PM bit as PS-POLL has PM bit always set */ - if(!pmBit) { - unifi_notice (priv, " PM bit reset in PS-POLL\n"); - return; - } - - if(IS_DTIM_ACTIVE(interfacePriv->dtimActive, interfacePriv->multicastPduHostTag)) { - /* giving more priority to multicast packets so dropping ps-poll*/ - unifi_notice (priv, " multicast transmission is going on so don't take action on PS-POLL\n"); - return; - } - - if(!staRecord->wmmOrQosEnabled) { - if((buffered_pkt=dequeue_tx_data_pdu(priv, &staRecord->mgtFrames))) { - buffered_pkt->transmissionControl |= TRANSMISSION_CONTROL_TRIGGER_MASK; - moreData = (!list_empty(&staRecord->dataPdu[UNIFI_TRAFFIC_Q_CONTENTION]) || - !list_empty(&staRecord->dataPdu[UNIFI_TRAFFIC_Q_VO]) || - !list_empty(&staRecord->mgtFrames)); - - buffered_pkt->transmissionControl |= (TRANSMISSION_CONTROL_TRIGGER_MASK | TRANSMISSION_CONTROL_EOSP_MASK); - if((r=frame_and_send_queued_pdu(priv, buffered_pkt, staRecord, moreData, FALSE)) == -ENOSPC) { - /* Clear the trigger bit transmission control*/ - buffered_pkt->transmissionControl &= ~(TRANSMISSION_CONTROL_TRIGGER_MASK | TRANSMISSION_CONTROL_EOSP_MASK); - /* Enqueue at the head of the queue */ - spin_lock_irqsave(&priv->tx_q_lock, lock_flags); - list_add(&buffered_pkt->q, &staRecord->mgtFrames); - spin_unlock_irqrestore(&priv->tx_q_lock, lock_flags); - unifi_trace(priv, UDBG1, "(ENOSPC) PS-POLL received : PDU sending failed \n"); - priv->pausedStaHandle[3]=(u8)(staRecord->assignedHandle); - } else { - if(r){ - unifi_trace (priv, UDBG1, " HIP validation failure : PDU sending failed \n"); - /* the PDU failed where we can't do any thing so free the storage */ - unifi_net_data_free(priv, &buffered_pkt->bulkdata); - } - kfree(buffered_pkt); - } - } else if((buffered_pkt=dequeue_tx_data_pdu(priv, &staRecord->dataPdu[UNIFI_TRAFFIC_Q_VO]))) { - buffered_pkt->transmissionControl |= TRANSMISSION_CONTROL_TRIGGER_MASK; - moreData = (!list_empty(&staRecord->dataPdu[UNIFI_TRAFFIC_Q_CONTENTION]) || - !list_empty(&staRecord->dataPdu[UNIFI_TRAFFIC_Q_VO])); - - buffered_pkt->transmissionControl |= (TRANSMISSION_CONTROL_TRIGGER_MASK | TRANSMISSION_CONTROL_EOSP_MASK); - if((r=frame_and_send_queued_pdu(priv, buffered_pkt, staRecord, moreData, FALSE)) == -ENOSPC) { - /* Clear the trigger bit transmission control*/ - buffered_pkt->transmissionControl &= ~(TRANSMISSION_CONTROL_TRIGGER_MASK | TRANSMISSION_CONTROL_EOSP_MASK); - /* Enqueue at the head of the queue */ - spin_lock_irqsave(&priv->tx_q_lock, lock_flags); - list_add(&buffered_pkt->q, &staRecord->dataPdu[UNIFI_TRAFFIC_Q_VO]); - spin_unlock_irqrestore(&priv->tx_q_lock, lock_flags); - priv->pausedStaHandle[3]=(u8)(staRecord->assignedHandle); - unifi_trace(priv, UDBG1, "(ENOSPC) PS-POLL received : PDU sending failed \n"); - } else { - if(r){ - unifi_trace (priv, UDBG1, " HIP validation failure : PDU sending failed \n"); - /* the PDU failed where we can't do any thing so free the storage */ - unifi_net_data_free(priv, &buffered_pkt->bulkdata); - } - kfree(buffered_pkt); - } - } else if((buffered_pkt=dequeue_tx_data_pdu(priv, &staRecord->dataPdu[UNIFI_TRAFFIC_Q_CONTENTION]))) { - buffered_pkt->transmissionControl |= TRANSMISSION_CONTROL_TRIGGER_MASK; - moreData = !list_empty(&staRecord->dataPdu[UNIFI_TRAFFIC_Q_CONTENTION]); - - buffered_pkt->transmissionControl |= (TRANSMISSION_CONTROL_TRIGGER_MASK | TRANSMISSION_CONTROL_EOSP_MASK); - if((r=frame_and_send_queued_pdu(priv, buffered_pkt, staRecord, moreData, FALSE)) == -ENOSPC) { - /* Clear the trigger bit transmission control*/ - buffered_pkt->transmissionControl &= ~(TRANSMISSION_CONTROL_TRIGGER_MASK | TRANSMISSION_CONTROL_EOSP_MASK); - /* Enqueue at the head of the queue */ - spin_lock_irqsave(&priv->tx_q_lock, lock_flags); - list_add(&buffered_pkt->q, &staRecord->dataPdu[UNIFI_TRAFFIC_Q_CONTENTION]); - spin_unlock_irqrestore(&priv->tx_q_lock, lock_flags); - priv->pausedStaHandle[0]=(u8)(staRecord->assignedHandle); - unifi_trace(priv, UDBG1, "(ENOSPC) PS-POLL received : PDU sending failed \n"); - } else { - if(r){ - unifi_trace (priv, UDBG1, " HIP validation failure : PDU sending failed \n"); - /* the PDU failed where we can't do any thing so free the storage */ - unifi_net_data_free(priv, &buffered_pkt->bulkdata); - } - kfree(buffered_pkt); - } - } else { - /* Actually since we have sent an ACK, there - * there is no need to send a NULL frame*/ - } - moreData = (!list_empty(&staRecord->dataPdu[UNIFI_TRAFFIC_Q_VO]) || - !list_empty(&staRecord->dataPdu[UNIFI_TRAFFIC_Q_CONTENTION]) || - !list_empty(&staRecord->mgtFrames)); - if(!moreData && (staRecord->timSet == CSR_WIFI_TIM_SET)) { - unifi_trace(priv, UDBG3, "more data = NULL, set tim to 0 in uf_process_ps_poll\n"); - if (!staRecord->timRequestPendingFlag){ - update_tim(priv, staRecord->aid, 0, interfaceTag, staRecord->assignedHandle); - } - else - { - /* Cache the TimSet value so that it will processed immidiatly after - * completing the current setTim Request - */ - staRecord->updateTimReqQueued = 0; - unifi_trace(priv, UDBG6, "update_tim : One more UpdateTim Request (Tim value:%d) Queued for AID %x\n", staRecord->updateTimReqQueued, - staRecord->aid); - } - } - } else { - - u8 allDeliveryEnabled = 0, dataAvailable = 0; - unifi_trace(priv, UDBG3, "Qos Support station.Processing PS-Poll\n"); - - /*Send Data From Management Frames*/ - /* Priority orders for delivering the buffered packets are - * 1. Deliver the Management frames if there - * 2. Other access category frames which are non deliver enable including UNIFI_TRAFFIC_Q_VO - * priority is from VO->BK - */ - - /* Check if all AC's are Delivery Enabled */ - is_all_ac_deliver_enabled_and_moredata(staRecord, &allDeliveryEnabled, &dataAvailable); - - if (allDeliveryEnabled) { - unifi_trace(priv, UDBG3, "uf_process_ps_poll: All ACs are delivery enable so Sending QOS Null in response of Ps-poll\n"); - uf_send_qos_null(priv, interfaceTag, sa, CSR_QOS_UP0, staRecord); - return; - } - - if (!list_empty(&staRecord->mgtFrames)) { - if ((buffered_pkt=dequeue_tx_data_pdu(priv, &staRecord->mgtFrames))) { - /* We dont have packets in non delivery enabled UNIFI_TRAFFIC_Q_VO, So we are looking in management - * queue of the station record - */ - moreData = uf_is_more_data_for_non_delivery_ac(staRecord); - buffered_pkt->transmissionControl |= (TRANSMISSION_CONTROL_TRIGGER_MASK | TRANSMISSION_CONTROL_EOSP_MASK); - - /* Last parameter is EOSP & its false always for PS-POLL processing */ - if((r=frame_and_send_queued_pdu(priv, buffered_pkt, staRecord, moreData, FALSE)) == -ENOSPC) { - /* Clear the trigger bit transmission control*/ - buffered_pkt->transmissionControl &= ~(TRANSMISSION_CONTROL_TRIGGER_MASK | TRANSMISSION_CONTROL_EOSP_MASK); - /* Enqueue at the head of the queue */ - spin_lock_irqsave(&priv->tx_q_lock, lock_flags); - list_add(&buffered_pkt->q, &staRecord->mgtFrames); - spin_unlock_irqrestore(&priv->tx_q_lock, lock_flags); - priv->pausedStaHandle[0]=(u8)(staRecord->assignedHandle); - unifi_trace(priv, UDBG1, "(ENOSPC) PS-POLL received : PDU sending failed \n"); - } else { - if(r){ - unifi_trace (priv, UDBG1, " HIP validation failure : PDU sending failed \n"); - /* the PDU failed where we can't do any thing so free the storage */ - unifi_net_data_free(priv, &buffered_pkt->bulkdata); - } - kfree(buffered_pkt); - } - } else { - unifi_error(priv, "uf_process_ps_poll: Mgt frame list empty!! \n"); - } - - } else { - s8 i; - /* We dont have buffered packet in mangement frame queue (1 failed), So proceed with condition 2 - * UNIFI_TRAFFIC_Q_VO -> VI -> BE -> BK - */ - for(i= 3; i>=0; i--) { - if (!IS_DELIVERY_ENABLED(staRecord->powersaveMode[i])) { - /* Send One packet, if queue is NULL then continue */ - if((buffered_pkt=dequeue_tx_data_pdu(priv, &staRecord->dataPdu[i]))) { - moreData = uf_is_more_data_for_non_delivery_ac(staRecord); - - buffered_pkt->transmissionControl |= (TRANSMISSION_CONTROL_TRIGGER_MASK | TRANSMISSION_CONTROL_EOSP_MASK); - - /* Last parameter is EOSP & its false always for PS-POLL processing */ - if((r=frame_and_send_queued_pdu(priv, buffered_pkt, staRecord, moreData, FALSE)) == -ENOSPC) { - /* Clear the trigger bit transmission control*/ - buffered_pkt->transmissionControl &= ~(TRANSMISSION_CONTROL_TRIGGER_MASK | TRANSMISSION_CONTROL_EOSP_MASK); - /* Enqueue at the head of the queue */ - spin_lock_irqsave(&priv->tx_q_lock, lock_flags); - list_add(&buffered_pkt->q, &staRecord->dataPdu[i]); - spin_unlock_irqrestore(&priv->tx_q_lock, lock_flags); - priv->pausedStaHandle[0]=(u8)(staRecord->assignedHandle); - unifi_trace(priv, UDBG1, "(ENOSPC) PS-POLL received : PDU sending failed \n"); - } else { - if(r) { - unifi_trace (priv, UDBG1, " HIP validation failure : PDU sending failed \n"); - /* the PDU failed where we can't do any thing so free the storage */ - unifi_net_data_free(priv, &buffered_pkt->bulkdata); - } - kfree(buffered_pkt); - } - break; - } - } - } - } - /* Check if all AC's are Delivery Enabled */ - is_all_ac_deliver_enabled_and_moredata(staRecord, &allDeliveryEnabled, &dataAvailable); - /*check for more data in non-delivery enabled queues*/ - moreData = (uf_is_more_data_for_non_delivery_ac(staRecord) || (allDeliveryEnabled && dataAvailable)); - if(!moreData && (staRecord->timSet == CSR_WIFI_TIM_SET)) { - unifi_trace(priv, UDBG3, "more data = NULL, set tim to 0 in uf_process_ps_poll\n"); - if (!staRecord->timRequestPendingFlag){ - update_tim(priv, staRecord->aid, 0, interfaceTag, staRecord->assignedHandle); - } - else - { - /* Cache the TimSet value so that it will processed immidiatly after - * completing the current setTim Request - */ - staRecord->updateTimReqQueued = 0; - unifi_trace(priv, UDBG6, "update_tim : One more UpdateTim Request (Tim value:%d) Queued for AID %x\n", staRecord->updateTimReqQueued, - staRecord->aid); - } - - } - } - - unifi_trace(priv, UDBG3, "leaving uf_process_ps_poll\n"); -} - - - -void add_to_send_cfm_list(unifi_priv_t * priv, - tx_buffered_packets_t *tx_q_item, - struct list_head *frames_need_cfm_list) -{ - tx_buffered_packets_t *send_cfm_list_item = NULL; - - send_cfm_list_item = kmalloc(sizeof(tx_buffered_packets_t), GFP_ATOMIC); - - if(send_cfm_list_item == NULL){ - unifi_warning(priv, "%s: Failed to allocate memory for new list item \n"); - return; - } - - INIT_LIST_HEAD(&send_cfm_list_item->q); - - send_cfm_list_item->hostTag = tx_q_item->hostTag; - send_cfm_list_item->interfaceTag = tx_q_item->interfaceTag; - send_cfm_list_item->transmissionControl = tx_q_item->transmissionControl; - send_cfm_list_item->leSenderProcessId = tx_q_item->leSenderProcessId; - send_cfm_list_item->rate = tx_q_item->rate; - memcpy(send_cfm_list_item->peerMacAddress.a, tx_q_item->peerMacAddress.a, ETH_ALEN); - send_cfm_list_item->priority = tx_q_item->priority; - - list_add_tail(&send_cfm_list_item->q, frames_need_cfm_list); -} - -void uf_prepare_send_cfm_list_for_queued_pkts(unifi_priv_t * priv, - struct list_head *frames_need_cfm_list, - struct list_head * list) -{ - tx_buffered_packets_t *tx_q_item = NULL; - struct list_head *listHead; - struct list_head *placeHolder; - unsigned long lock_flags; - - spin_lock_irqsave(&priv->tx_q_lock, lock_flags); - - /* Search through the list and if confirmation required for any frames, - add it to the send_cfm list */ - list_for_each_safe(listHead, placeHolder, list) { - tx_q_item = list_entry(listHead, tx_buffered_packets_t, q); - - if(!tx_q_item) { - unifi_error(priv, "Entry should exist, otherwise it is a (BUG)\n"); - continue; - } - - /* check if confirmation is requested and if the sender ID - is not netdevice client then save the entry in the list for need cfms */ - if (!(tx_q_item->transmissionControl & CSR_NO_CONFIRM_REQUIRED) && - (tx_q_item->leSenderProcessId != priv->netdev_client->sender_id)){ - unifi_trace(priv, UDBG1, "%s: SenderProcessID=%x host tag=%x transmission control=%x\n", - __FUNCTION__, - tx_q_item->leSenderProcessId, - tx_q_item->hostTag, - tx_q_item->transmissionControl); - - add_to_send_cfm_list(priv, tx_q_item, frames_need_cfm_list); - } - } - - spin_unlock_irqrestore(&priv->tx_q_lock, lock_flags); - -} - - - -void uf_flush_list(unifi_priv_t * priv, struct list_head * list) -{ - tx_buffered_packets_t *tx_q_item; - struct list_head *listHead; - struct list_head *placeHolder; - unsigned long lock_flags; - - unifi_trace(priv, UDBG5, "entering the uf_flush_list \n"); - - spin_lock_irqsave(&priv->tx_q_lock, lock_flags); - /* go through list, delete & free memory */ - list_for_each_safe(listHead, placeHolder, list) { - tx_q_item = list_entry(listHead, tx_buffered_packets_t, q); - - if(!tx_q_item) { - unifi_error(priv, "entry should exists, otherwise crashes (bug)\n"); - } - unifi_trace(priv, UDBG5, - "proccess_tx: in uf_flush_list peerMacAddress=%02X%02X%02X%02X%02X%02X senderProcessId=%x\n", - tx_q_item->peerMacAddress.a[0], tx_q_item->peerMacAddress.a[1], - tx_q_item->peerMacAddress.a[2], tx_q_item->peerMacAddress.a[3], - tx_q_item->peerMacAddress.a[4], tx_q_item->peerMacAddress.a[5], - tx_q_item->leSenderProcessId); - - list_del(listHead); - /* free the allocated memory */ - unifi_net_data_free(priv, &tx_q_item->bulkdata); - kfree(tx_q_item); - tx_q_item = NULL; - if (!priv->noOfPktQueuedInDriver) { - unifi_error(priv, "packets queued in driver 0 still decrementing in %s\n", __FUNCTION__); - } else { - priv->noOfPktQueuedInDriver--; - } - } - spin_unlock_irqrestore(&priv->tx_q_lock, lock_flags); -} - -tx_buffered_packets_t *dequeue_tx_data_pdu(unifi_priv_t *priv, struct list_head *txList) -{ - /* dequeue the tx data packets from the appropriate queue */ - tx_buffered_packets_t *tx_q_item = NULL; - struct list_head *listHead; - struct list_head *placeHolder; - unsigned long lock_flags; - - unifi_trace(priv, UDBG5, "entering dequeue_tx_data_pdu\n"); - /* check for list empty */ - if (list_empty(txList)) { - unifi_trace(priv, UDBG5, "In dequeue_tx_data_pdu, the list is empty\n"); - return NULL; - } - - /* Verification, if packet count is negetive */ - if (priv->noOfPktQueuedInDriver == 0xFFFF) { - unifi_warning(priv, "no packet available in queue: debug"); - return NULL; - } - - /* return first node after header, & delete from the list && atleast one item exist */ - spin_lock_irqsave(&priv->tx_q_lock, lock_flags); - list_for_each_safe(listHead, placeHolder, txList) { - tx_q_item = list_entry(listHead, tx_buffered_packets_t, q); - list_del(listHead); - break; - } - spin_unlock_irqrestore(&priv->tx_q_lock, lock_flags); - - if (tx_q_item) { - unifi_trace(priv, UDBG5, - "proccess_tx: In dequeue_tx_data_pdu peerMacAddress=%02X%02X%02X%02X%02X%02X senderProcessId=%x\n", - tx_q_item->peerMacAddress.a[0], tx_q_item->peerMacAddress.a[1], - tx_q_item->peerMacAddress.a[2], tx_q_item->peerMacAddress.a[3], - tx_q_item->peerMacAddress.a[4], tx_q_item->peerMacAddress.a[5], - tx_q_item->leSenderProcessId); - } - - unifi_trace(priv, UDBG5, "leaving dequeue_tx_data_pdu\n"); - return tx_q_item; -} -/* generic function to get the station record handler */ -CsrWifiRouterCtrlStaInfo_t *CsrWifiRouterCtrlGetStationRecordFromPeerMacAddress(unifi_priv_t *priv, - const u8 *peerMacAddress, - u16 interfaceTag) -{ - u8 i; - netInterface_priv_t *interfacePriv; - unsigned long lock_flags; - - if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) { - unifi_error(priv, "interfaceTag is not proper, interfaceTag = %d\n", interfaceTag); - return NULL; - } - - interfacePriv = priv->interfacePriv[interfaceTag]; - - /* disable the preemption until station record is fetched */ - spin_lock_irqsave(&priv->staRecord_lock, lock_flags); - - for (i = 0; i < UNIFI_MAX_CONNECTIONS; i++) { - if (interfacePriv->staInfo[i]!= NULL) { - if (!memcmp(((CsrWifiRouterCtrlStaInfo_t *) (interfacePriv->staInfo[i]))->peerMacAddress.a, peerMacAddress, ETH_ALEN)) { - /* enable the preemption as station record is fetched */ - spin_unlock_irqrestore(&priv->staRecord_lock, lock_flags); - unifi_trace(priv, UDBG5, "peer entry found in station record\n"); - return ((CsrWifiRouterCtrlStaInfo_t *) (interfacePriv->staInfo[i])); - } - } - } - /* enable the preemption as station record is fetched */ - spin_unlock_irqrestore(&priv->staRecord_lock, lock_flags); - unifi_trace(priv, UDBG5, "peer entry not found in station record\n"); - return NULL; -} -/* generic function to get the station record handler from the handle */ -CsrWifiRouterCtrlStaInfo_t * CsrWifiRouterCtrlGetStationRecordFromHandle(unifi_priv_t *priv, - u32 handle, - u16 interfaceTag) -{ - netInterface_priv_t *interfacePriv; - - if ((handle >= UNIFI_MAX_CONNECTIONS) || (interfaceTag >= CSR_WIFI_NUM_INTERFACES)) { - unifi_error(priv, "handle/interfaceTag is not proper, handle = %d, interfaceTag = %d\n", handle, interfaceTag); - return NULL; - } - interfacePriv = priv->interfacePriv[interfaceTag]; - return ((CsrWifiRouterCtrlStaInfo_t *) (interfacePriv->staInfo[handle])); -} - -/* Function to do inactivity */ -void uf_check_inactivity(unifi_priv_t *priv, u16 interfaceTag, u32 currentTime) -{ - u32 i; - CsrWifiRouterCtrlStaInfo_t *staInfo; - u32 elapsedTime; /* Time in microseconds */ - netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag]; - CsrWifiMacAddress peerMacAddress; - unsigned long lock_flags; - - if (interfacePriv == NULL) { - unifi_trace(priv, UDBG3, "uf_check_inactivity: Interface priv is NULL \n"); - return; - } - - spin_lock_irqsave(&priv->staRecord_lock, lock_flags); - /* Go through the list of stations to check for inactivity */ - for(i = 0; i < UNIFI_MAX_CONNECTIONS; i++) { - staInfo = CsrWifiRouterCtrlGetStationRecordFromHandle(priv, i, interfaceTag); - if(!staInfo ) { - continue; - } - - unifi_trace(priv, UDBG3, "Running Inactivity handler Time %xus station's last activity %xus\n", - currentTime, staInfo->lastActivity); - - - elapsedTime = (currentTime >= staInfo->lastActivity)? - (currentTime - staInfo->lastActivity): - (~((u32)0) - staInfo->lastActivity + currentTime); - spin_unlock_irqrestore(&priv->staRecord_lock, lock_flags); - - if (elapsedTime > MAX_INACTIVITY_INTERVAL) { - memcpy((u8*)&peerMacAddress, (u8*)&staInfo->peerMacAddress, sizeof(CsrWifiMacAddress)); - - /* Indicate inactivity for the station */ - unifi_trace(priv, UDBG3, "Station %x:%x:%x:%x:%x:%x inactive since %xus\n sending Inactive Ind\n", - peerMacAddress.a[0], peerMacAddress.a[1], - peerMacAddress.a[2], peerMacAddress.a[3], - peerMacAddress.a[4], peerMacAddress.a[5], - elapsedTime); - - CsrWifiRouterCtrlStaInactiveIndSend(priv->CSR_WIFI_SME_IFACEQUEUE, 0, interfaceTag, peerMacAddress); - } - } - - interfacePriv->last_inactivity_check = currentTime; -} - -/* Function to update activity of a station */ -void uf_update_sta_activity(unifi_priv_t *priv, u16 interfaceTag, const u8 *peerMacAddress) -{ - u32 elapsedTime, currentTime; /* Time in microseconds */ - u32 timeHi; /* Not used - Time in microseconds */ - CsrWifiRouterCtrlStaInfo_t *staInfo; - netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag]; - unsigned long lock_flags; - - if (interfacePriv == NULL) { - unifi_trace(priv, UDBG3, "uf_check_inactivity: Interface priv is NULL \n"); - return; - } - - currentTime = CsrTimeGet(&timeHi); - - - staInfo = CsrWifiRouterCtrlGetStationRecordFromPeerMacAddress(priv, peerMacAddress, interfaceTag); - - if (staInfo == NULL) { - unifi_trace(priv, UDBG4, "Sta does not exist yet"); - return; - } - - spin_lock_irqsave(&priv->staRecord_lock, lock_flags); - /* Update activity */ - staInfo->lastActivity = currentTime; - - /* See if inactivity handler needs to be run - * Here it is theoretically possible that the counter may have wrapped around. But - * since we just want to know when to run the inactivity handler it does not really matter. - * Especially since this is data path it makes sense in keeping it simple and avoiding - * 64 bit handling */ - elapsedTime = (currentTime >= interfacePriv->last_inactivity_check)? - (currentTime - interfacePriv->last_inactivity_check): - (~((u32)0) - interfacePriv->last_inactivity_check + currentTime); - - spin_unlock_irqrestore(&priv->staRecord_lock, lock_flags); - - /* Check if it is time to run the inactivity handler */ - if (elapsedTime > INACTIVITY_CHECK_INTERVAL) { - uf_check_inactivity(priv, interfaceTag, currentTime); - } -} -void resume_unicast_buffered_frames(unifi_priv_t *priv, u16 interfaceTag) -{ - - netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag]; - u8 i; - int j; - tx_buffered_packets_t * buffered_pkt = NULL; - u8 hipslotFree[4] = {TRUE, TRUE, TRUE, TRUE}; - int r; - unsigned long lock_flags; - - while(!isRouterBufferEnabled(priv, 3) && - ((buffered_pkt=dequeue_tx_data_pdu(priv, &interfacePriv->genericMgtFrames))!=NULL)) { - buffered_pkt->transmissionControl &= - ~(TRANSMISSION_CONTROL_TRIGGER_MASK|TRANSMISSION_CONTROL_EOSP_MASK); - if((r=frame_and_send_queued_pdu(priv, buffered_pkt, NULL, 0, FALSE)) == -ENOSPC) { - /* Enqueue at the head of the queue */ - spin_lock_irqsave(&priv->tx_q_lock, lock_flags); - list_add(&buffered_pkt->q, &interfacePriv->genericMgtFrames); - spin_unlock_irqrestore(&priv->tx_q_lock, lock_flags); - hipslotFree[3]=FALSE; - break; - }else { - if(r){ - unifi_trace (priv, UDBG1, " HIP validation failure : PDU sending failed \n"); - /* the PDU failed where we can't do any thing so free the storage */ - unifi_net_data_free(priv, &buffered_pkt->bulkdata); - } - kfree(buffered_pkt); - } - } - for(i = 0; i < UNIFI_MAX_CONNECTIONS; i++) { - CsrWifiRouterCtrlStaInfo_t *staInfo = interfacePriv->staInfo[i]; - if(!hipslotFree[0] && !hipslotFree[1] && !hipslotFree[2] && !hipslotFree[3]) { - unifi_trace(priv, UDBG3, "(ENOSPC) in resume_unicast_buffered_frames:: hip slots are full \n"); - break; - } - if (staInfo && (staInfo->currentPeerState == CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_ACTIVE)) { - while((( TRUE == hipslotFree[3] ) && (buffered_pkt=dequeue_tx_data_pdu(priv, &staInfo->mgtFrames)))) { - buffered_pkt->transmissionControl &= - ~(TRANSMISSION_CONTROL_TRIGGER_MASK|TRANSMISSION_CONTROL_EOSP_MASK); - if((r=frame_and_send_queued_pdu(priv, buffered_pkt, staInfo, 0, FALSE)) == -ENOSPC) { - unifi_trace(priv, UDBG3, "(ENOSPC) in resume_unicast_buffered_frames:: hip slots are full for voice queue\n"); - /* Enqueue at the head of the queue */ - spin_lock_irqsave(&priv->tx_q_lock, lock_flags); - list_add(&buffered_pkt->q, &staInfo->mgtFrames); - spin_unlock_irqrestore(&priv->tx_q_lock, lock_flags); - priv->pausedStaHandle[3]=(u8)(staInfo->assignedHandle); - hipslotFree[3] = FALSE; - break; - } else { - if(r){ - unifi_trace (priv, UDBG1, " HIP validation failure : PDU sending failed \n"); - /* the PDU failed where we can't do any thing so free the storage */ - unifi_net_data_free(priv, &buffered_pkt->bulkdata); - } - kfree(buffered_pkt); - } - } - - for(j=3;j>=0;j--) { - if(!hipslotFree[j]) - continue; - - while((buffered_pkt=dequeue_tx_data_pdu(priv, &staInfo->dataPdu[j]))) { - buffered_pkt->transmissionControl &= - ~(TRANSMISSION_CONTROL_TRIGGER_MASK|TRANSMISSION_CONTROL_EOSP_MASK); - if((r=frame_and_send_queued_pdu(priv, buffered_pkt, staInfo, 0, FALSE)) == -ENOSPC) { - /* Enqueue at the head of the queue */ - spin_lock_irqsave(&priv->tx_q_lock, lock_flags); - list_add(&buffered_pkt->q, &staInfo->dataPdu[j]); - spin_unlock_irqrestore(&priv->tx_q_lock, lock_flags); - priv->pausedStaHandle[j]=(u8)(staInfo->assignedHandle); - hipslotFree[j]=FALSE; - break; - } else { - if(r){ - unifi_trace (priv, UDBG1, " HIP validation failure : PDU sending failed \n"); - /* the PDU failed where we can't do any thing so free the storage */ - unifi_net_data_free(priv, &buffered_pkt->bulkdata); - } - kfree(buffered_pkt); - } - } - } - } - } -} -void update_eosp_to_head_of_broadcast_list_head(unifi_priv_t *priv, u16 interfaceTag) -{ - - netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag]; - unsigned long lock_flags; - struct list_head *listHead; - struct list_head *placeHolder; - tx_buffered_packets_t *tx_q_item; - - if (interfacePriv->noOfbroadcastPktQueued) { - - /* Update the EOSP to the HEAD of b/c list - * because we have received any mgmt packet so it should not hold for long time - * peer may time out. - */ - spin_lock_irqsave(&priv->tx_q_lock, lock_flags); - list_for_each_safe(listHead, placeHolder, &interfacePriv->genericMulticastOrBroadCastFrames) { - tx_q_item = list_entry(listHead, tx_buffered_packets_t, q); - tx_q_item->transmissionControl |= TRANSMISSION_CONTROL_EOSP_MASK; - tx_q_item->transmissionControl = (tx_q_item->transmissionControl & ~(CSR_NO_CONFIRM_REQUIRED)); - unifi_trace(priv, UDBG1, "updating eosp for list Head hostTag:= 0x%x ", tx_q_item->hostTag); - break; - } - spin_unlock_irqrestore(&priv->tx_q_lock, lock_flags); - } -} - -/* - * --------------------------------------------------------------------------- - * resume_suspended_uapsd - * - * This function takes care processing packets of Unscheduled Service Period, - * which been suspended earlier due to DTIM/HIP ENOSPC scenarios - * - * Arguments: - * priv Pointer to device private context struct - * interfaceTag For which resume should happen - * --------------------------------------------------------------------------- - */ -void resume_suspended_uapsd(unifi_priv_t* priv, u16 interfaceTag) -{ - - u8 startIndex; - CsrWifiRouterCtrlStaInfo_t * staInfo = NULL; - unsigned long lock_flags; - - unifi_trace(priv, UDBG2, "++resume_suspended_uapsd: \n"); - for(startIndex= 0; startIndex < UNIFI_MAX_CONNECTIONS;startIndex++) { - staInfo = CsrWifiRouterCtrlGetStationRecordFromHandle(priv, startIndex, interfaceTag); - - if(!staInfo || !staInfo->wmmOrQosEnabled) { - continue; - } else if((staInfo->currentPeerState == CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_POWER_SAVE) - &&staInfo->uapsdActive && staInfo->uspSuspend) { - /* U-APSD Still active & previously suspended either ENOSPC of FH queues OR - * due to DTIM activity - */ - uf_handle_uspframes_delivery(priv, staInfo, interfaceTag); - } else { - unifi_trace(priv, UDBG2, "resume_suspended_uapsd: PS state=%x, uapsdActive?=%x, suspend?=%x\n", - staInfo->currentPeerState, staInfo->uapsdActive, staInfo->uspSuspend); - if (staInfo->currentPeerState == CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_ACTIVE) - { - spin_lock_irqsave(&priv->staRecord_lock, lock_flags); - staInfo->uapsdActive = FALSE; - staInfo->uspSuspend = FALSE; - spin_unlock_irqrestore(&priv->staRecord_lock, lock_flags); - } - } - } - unifi_trace(priv, UDBG2, "--resume_suspended_uapsd:\n"); -} - -#endif diff --git a/drivers/staging/csr/unifi_priv.h b/drivers/staging/csr/unifi_priv.h deleted file mode 100644 index 37302f3c2f6c..000000000000 --- a/drivers/staging/csr/unifi_priv.h +++ /dev/null @@ -1,1136 +0,0 @@ -/* - ***************************************************************************** - * - * FILE : unifi_priv.h - * - * PURPOSE : Private header file for unifi driver. - * - * UDI = UniFi Debug Interface - * - * Copyright (C) 2005-2009 by Cambridge Silicon Radio Ltd. - * - * Refer to LICENSE.txt included with this source code for details on - * the license terms. - * - ***************************************************************************** - */ -#ifndef __LINUX_UNIFI_PRIV_H__ -#define __LINUX_UNIFI_PRIV_H__ 1 - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef CSR_WIFI_SUPPORT_MMC_DRIVER -#include -#include -#include -#include -#include -#include -#endif /* CSR_WIFI_SUPPORT_MMC_DRIVER */ - -#include - -#ifdef ANDROID_BUILD -#include -#endif - -#include "csr_wifi_hip_unifi.h" -#include "csr_wifi_hip_unifi_udi.h" -#include "csr_wifi_router_lib.h" -#include "unifiio.h" -#ifndef CSR_WIFI_HIP_TA_DISABLE -#include "csr_wifi_vif_utils.h" -#endif - -/* Define the unifi_priv_t before include the unifi_native.h */ -struct unifi_priv; -typedef struct unifi_priv unifi_priv_t; -#ifdef CSR_SUPPORT_WEXT_AP -struct CsrWifiSmeApConfig; -typedef struct CsrWifiSmeApConfig CsrWifiSmeApConfig_t; -#endif -#ifdef CSR_SUPPORT_WEXT -#include "unifi_wext.h" -#endif - -#ifdef ANDROID_BUILD -extern struct wake_lock unifi_sdio_wake_lock; -#endif - -#include "unifi_clients.h" - -#ifdef CSR_NATIVE_LINUX -#include "sme_native/unifi_native.h" -#else -#include "unifi_sme.h" -#endif - -/* The device major number to use when registering the udi driver */ -#define UNIFI_NAME "unifi" -/* - * MAX_UNIFI_DEVS defines the maximum number of UniFi devices that can be present. - * This number should be set to the number of SDIO slots supported by the SDIO - * host controller on the platform. - * Note: If MAX_UNIFI_DEVS value changes, fw_init[] needs to be corrected in drv.c - */ -#define MAX_UNIFI_DEVS 2 - -/* 802.11 Mac header offsets */ -#define MAC_HEADER_SIZE 24 -#define QOS_CONTROL_HEADER_SIZE 2 -#define HT_CONTROL_HEADER_SIZE 4 -#define QOS_DATA 0x8 -#define QOS_DATA_NULL 0xc -#define DATA_NULL 0x04 -#define FRAME_CONTROL_ORDER_BIT 0x8000 -#define FRAME_CONTROL_TYPE_FIELD_OFFSET 2 -#define FRAME_CONTROL_SUBTYPE_FIELD_OFFSET 4 -#define IEEE802_11_FRAMETYPE_DATA 0x02 -#define IEEE802_11_FRAMETYPE_CONTROL 0x01 -#define IEEE802_11_FRAMETYPE_MANAGEMENT 0x00 -#define IEEE802_11_FRAMETYPE_RESERVED 0x03 - -/* octet offset from start of mac header for certain fields */ -#define IEEE802_11_ADDR3_OFFSET 16 -#define IEEE802_11_SEQUENCE_CONTROL_OFFSET 22 -#define IEEE802_11_MAX_DATA_LEN 2304 - -/* frame control (FC) masks, for frame control as 16 bit integer */ -#define IEEE802_11_FC_TO_DS_MASK 0x100 -#define IEEE802_11_FC_FROM_DS_MASK 0x200 -#define IEEE802_11_FC_MOREDATA_MASK 0x2000 -#define IEEE802_11_FC_PROTECTED_MASK 0x4000 -#define IEEE80211_FC_ORDER_MASK 0x8000 -#define IEEE80211_FC_SUBTYPE_MASK 0x00f0 -#define IEEE80211_FC_TYPE_MASK 0x000c -#define IEEE80211_FC_PROTO_VERSION_MASK 0x0003 - -/* selected type and subtype combinations as in 7.1.3.1 table 1 - For frame control as 16 bit integer, or for ls octet -*/ -#define IEEE802_11_FC_TYPE_DATA 0x08 -#define IEEE802_11_FC_TYPE_NULL 0x48 -#define IEEE802_11_FC_TYPE_QOS_NULL 0xc8 -#define IEEE802_11_FC_TYPE_QOS_DATA 0x88 - -#define IEEE802_11_FC_TYPE_DATA_SUBTYPE_RESERVED 0x0D - -/* qos control (QC) masks for qos control as 16 bit integer, or for ls octet */ -#define IEEE802_11_QC_TID_MASK 0x0f -#define IEEE802_11_QC_A_MSDU_PRESENT 0x80 - -#if (defined(CSR_WIFI_SECURITY_WAPI_ENABLE) && defined(CSR_WIFI_SECURITY_WAPI_QOSCTRL_MIC_WORKAROUND)) -#define IEEE802_11_QC_NON_TID_BITS_MASK 0xFFF0 -#endif - -#define CSR_WIFI_EAPOL_M4_HOST_TAG 0x50000000 -#define IEEE802_11_DATA_FRAME_MAC_HEADER_SIZE 36 -#define MAX_ACCESS_CATOGORY 4 - -/* Time in us to check for inactivity of stations 5 mins */ -#define INACTIVITY_CHECK_INTERVAL 300000000 -/* Time in us before a station is flagged as inactive */ -#define MAX_INACTIVITY_INTERVAL 300000000 - - -/* Define for maximum BA session */ -#define MAX_SUPPORTED_BA_SESSIONS_TX 1 -#define MAX_SUPPORTED_BA_SESSIONS_RX 4 - -#define MAX_BA_WIND_SIZE 64 -#define MAC_HEADER_ADDR1_OFFSET 4 -#define MAC_HEADER_ADDR2_OFFSET 10 - -/* Define for age (in us) value for frames in MPDU reorder buffer */ -#define CSR_WIFI_BA_MPDU_FRAME_AGE_TIMEOUT 30000 /* 30 milli seconds */ - -/* This macro used in prepare_and_add_macheader*/ -#define ADDRESS_ONE_OFFSET 20 - -/* Defines for STA inactivity detection */ -#define STA_INACTIVE_DETECTION_TRIGGER_THRESHOLD 1 /* in number of stations */ -#define STA_INACTIVE_DETECTION_TIMER_INTERVAL 30 /* in seconds */ -#define STA_INACTIVE_TIMEOUT_VAL 120*1000*1000 /* 120 seconds */ - -/* Test for modes requiring AP firmware patch */ -#define CSR_WIFI_HIP_IS_AP_FW(mode) ((((mode) == CSR_WIFI_ROUTER_CTRL_MODE_AP) || \ - ((mode) == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO)) ? TRUE : FALSE) - -/* Defines used in beacon filtering in case of P2P */ -#define CSR_WIFI_P2P_WILDCARD_SSID_LENGTH 0x7 -#define CSR_WIFI_80211_FRAME_SUBTYPE_BEACON 0x8 -#define CSR_WIFI_BEACON_FIXED_LENGTH 12 -#define CSR_WIFI_FRAME_SUBTYPE_BIT_OFFSET 4 -#define CSR_WIFI_80211_FRAME_SUBTYPE_BIT_MASK ((u8)(0xF << CSR_WIFI_FRAME_SUBTYPE_BIT_OFFSET)) - -#define CSR_WIFI_80211_GET_FRAME_SUBTYPE(frameBuffer) \ - ((u8)(((u8 *)frameBuffer)[0] & CSR_WIFI_80211_FRAME_SUBTYPE_BIT_MASK) >> CSR_WIFI_FRAME_SUBTYPE_BIT_OFFSET) - -/* For M4 request received via netdev*/ - -typedef u8 CsrWifiPacketType; -#define CSR_WIFI_UNICAST_PDU ((CsrWifiPacketType) 0x00) -#define CSR_WIFI_MULTICAST_PDU ((CsrWifiPacketType) 0x1) -#define CSR_WIFI_BROADCAST_PDU ((CsrWifiPacketType) 0x2) - -#define PRIO_TO_NICE(prio) ((prio) - MAX_RT_PRIO - 20) - -/* Module parameter variables */ -extern int buswidth; -extern int sdio_clock; -extern int use_5g; -extern int disable_hw_reset; -extern int disable_power_control; -extern int enable_wol; -extern int sme_debug; -extern int fw_init[MAX_UNIFI_DEVS]; -extern int tl_80211d; -extern int sdio_byte_mode; -extern int sdio_block_size; -extern int coredump_max; -extern int run_bh_once; -extern int bh_priority; -#ifdef CSR_WIFI_HIP_DEBUG_OFFLINE -extern int log_hip_signals; -#endif - -struct dlpriv { - const unsigned char *dl_data; - int dl_len; - void *fw_desc; -}; - - -struct uf_thread { - - struct task_struct *thread_task; - - /* wait_queue for waking the unifi_thread kernel thread */ - wait_queue_head_t wakeup_q; - unsigned int wakeup_flag; - - /* - * Use it to block the I/O thread when - * an error occurs or UniFi is reinitialised. - */ - int block_thread; - - char name[16]; - int prio; -}; - -/* - * Link list to hold the received packets for the period the port - * remains closed. - */ -typedef struct rx_buffered_packets { - /* List link structure */ - struct list_head q; - /* Packet to indicate when the port reopens */ - struct sk_buff *skb; - /* Bulkdata to free in case the port closes and need to discard the packet */ - bulk_data_param_t bulkdata; - /* The source address of the packet */ - CsrWifiMacAddress sa; - /* The destination address of the packet */ - CsrWifiMacAddress da; - /* Corresponding signal */ - CSR_SIGNAL signal; -} rx_buffered_packets_t; - - -typedef u8 CsrWifiAcPowersaveMode; -#define CSR_WIFI_AC_TRIGGER_ONLY_ENABLED 0x00 -#define CSR_WIFI_AC_DELIVERY_ONLY_ENABLE 0X01 -#define CSR_WIFI_AC_TRIGGER_AND_DELIVERY_ENABLED 0X03 -#define CSR_WIFI_AC_LEGACY_POWER_SAVE 0X02 - - -#define IS_DELIVERY_ENABLED(mode) (mode & CSR_WIFI_AC_DELIVERY_ONLY_ENABLE)? 1: 0 -#define IS_DELIVERY_AND_TRIGGER_ENABLED(mode) ((mode & CSR_WIFI_AC_DELIVERY_ONLY_ENABLE)||(mode & CSR_WIFI_AC_TRIGGER_AND_DELIVERY_ENABLED))? 1: 0 -#define IS_DTIM_ACTIVE(flag, hostTag) ((flag == TRUE || hostTag != INVALID_HOST_TAG)) -#define INVALID_HOST_TAG 0xFFFFFFFF -#define UNIFI_TRAFFIC_Q_CONTENTION UNIFI_TRAFFIC_Q_BE - - - - -/* Queue to be used for contention priority */ - -/* - * Link list to hold the tx packets for the period the peer - * powersave/free slots in unifi - */ -typedef struct tx_buffered_packets { - /* List link structure */ - struct list_head q; - u16 interfaceTag; - CSR_CLIENT_TAG hostTag; - CSR_PROCESS_ID leSenderProcessId; - CSR_TRANSMISSION_CONTROL transmissionControl; - CSR_RATE rate; - /* Bulkdata to free in case the port closes and need to discard the packet */ - bulk_data_desc_t bulkdata; - /* The source address of the packet */ - CsrWifiMacAddress peerMacAddress; - CSR_PRIORITY priority; -} tx_buffered_packets_t; - -/* station record has this data structure */ -typedef struct CsrWifiRouterCtrlStaInfo_t { - - /* Sme sends these parameters */ - CsrWifiMacAddress peerMacAddress; - u32 assignedHandle; - u8 wmmOrQosEnabled; - CsrWifiAcPowersaveMode powersaveMode[MAX_ACCESS_CATOGORY]; - u16 maxSpLength; - u8 uapsdActive; - u16 noOfSpFramesSent; - - /* Router/Driver database */ -#ifdef CSR_SUPPORT_SME - unifi_port_cfg_t *peerControlledPort; - unifi_port_cfg_t *peerUnControlledPort; - - /* Inactivity feature parameters */ - struct netInterface_priv *interfacePriv; - struct work_struct send_disconnected_ind_task; - u8 activity_flag; - u16 listenIntervalInTus; - CSR_CLIENT_TAG nullDataHostTag; - - /* Activity timestamps for the station */ - u32 lastActivity; - - /* during m/c transmission sp suspended */ - u8 uspSuspend; - CSR_PRIORITY triggerFramePriority; -#endif - CsrWifiRouterCtrlPeerStatus currentPeerState; - struct list_head dataPdu[MAX_ACCESS_CATOGORY]; - struct list_head mgtFrames; - u8 spStatus; - u8 prevFrmType; - u8 prevFrmAccessCatogory; - u8 protection; - u16 aid; - u8 txSuspend; - u8 timSet; - /* Dont change the value of below macro for SET & RESET */ -#define CSR_WIFI_TIM_RESET 0 -#define CSR_WIFI_TIM_SET 1 -#define CSR_WIFI_TIM_RESETTING 2 -#define CSR_WIFI_TIM_SETTING 3 - - u8 timRequestPendingFlag; - u8 updateTimReqQueued; - u16 noOfPktQueued; -}CsrWifiRouterCtrlStaInfo_t; - -#ifdef CSR_SUPPORT_WEXT_AP -struct CsrWifiSmeApConfig { - CsrWifiSsid ssid; - u16 channel; - CsrWifiNmeApCredentials credentials; - u8 max_connections; - u8 if_index; -}; -#endif - -#ifdef CSR_WIFI_RX_PATH_SPLIT -/* This is a test code and may be removed later*/ -#define CSR_WIFI_RX_SIGNAL_BUFFER_SIZE (60+1) - -typedef struct -{ - u8 *bufptr; /* Signal Primitive */ - bulk_data_param_t data_ptrs; /* Bulk Data pointers */ - u16 sig_len; -}rx_buff_struct_t; - -typedef struct -{ - u8 writePointer; /**< write pointer */ - u8 readPointer; /**< read pointer */ - u8 size; /**< size of circular buffer */ - rx_buff_struct_t rx_buff[CSR_WIFI_RX_SIGNAL_BUFFER_SIZE]; /**< Element of ciruclar buffer */ -} rxCircularBuffer_t; - -void rx_wq_handler(struct work_struct *work); -#endif - -struct unifi_priv { - - card_t *card; - CsrSdioFunction *sdio; - - /* Index into Unifi_instances[] for this device. */ - int instance; - /* Reference count for this instance */ - int ref_count; - - /* Firmware images */ - struct dlpriv fw_sta; - struct dlpriv fw_conv; /* used for conversion of production test image */ - - /* Char device related structures */ - struct cdev unifi_cdev; - struct cdev unifiudi_cdev; - struct device *unifi_device; - - /* Which wireless interface to use (1 - 2.4GHz, 2 - 5GHz) */ - CSR_IFINTERFACE if_index; - - /* For multiple interface support */ - struct net_device *netdev[CSR_WIFI_NUM_INTERFACES]; - struct netInterface_priv *interfacePriv[CSR_WIFI_NUM_INTERFACES]; - - u8 totalInterfaceCount; - - int prev_queue; - - /* Name of node under /proc */ - char proc_entry_name[64]; - - /* - * Flags: - * drop_unencrypted - * - Not used? - * netdev_registered - * - whether the netdev has been registered. - */ - unsigned int drop_unencrypted : 1; - - /* Our list of unifi linux clients. */ - ul_client_t ul_clients[MAX_UDI_CLIENTS]; - - /* Mutex to protect using the logging hook after UDI client is gone */ - struct semaphore udi_logging_mutex; - /* Pointer to the ul_clients[] array */ - ul_client_t *logging_client; - - /* A ul_client_t* used to send the netdev related MIB requests. */ - ul_client_t *netdev_client; - - /* The SME ul_client_t pointer. */ - ul_client_t *sme_cli; - - /* The AMP ul_client_t pointer. */ - ul_client_t *amp_client; - - /* - * Semaphore for locking the top-half to one user process. - * This is necessary to prevent multiple processes calling driver - * operations. This can happen because the network driver entry points - * can be called from multiple processes. - */ -#ifdef USE_DRIVER_LOCK - struct semaphore lock; -#endif /* USE_DRIVER_LOCK */ - - /* Flag to say that an operation was aborted */ - int io_aborted; - - struct uf_thread bh_thread; - -#define UNIFI_INIT_NONE 0x00 -#define UNIFI_INIT_IN_PROGRESS 0x01 -#define UNIFI_INIT_FW_DOWNLOADED 0x02 -#define UNIFI_INIT_COMPLETED 0x04 - unsigned char init_progress; - - int sme_is_present; - - /* The WMM features that UniFi uses in the current BSS */ - unsigned int sta_wmm_capabilities; - - /* Debug only */ - char last_debug_string[256]; - unsigned short last_debug_word16[16]; - -#ifdef CSR_SUPPORT_SME - /* lock to protect the tx queues list */ - spinlock_t tx_q_lock; - u8 allPeerDozing; - u8 pausedStaHandle[MAX_ACCESS_CATOGORY]; - /* Max packet the driver can queue, irrespective of interface number */ - u16 noOfPktQueuedInDriver; -#define CSR_WIFI_DRIVER_SUPPORT_FOR_MAX_PKT_QUEUEING 512 -#define CSR_WIFI_DRIVER_MAX_PKT_QUEUING_THRESHOLD_PER_PEER 64 -#define CSR_WIFI_DRIVER_MINIMUM_BROADCAST_PKT_THRESHOLD 3 - - u8 routerBufferEnable[MAX_ACCESS_CATOGORY]; - /* lock to protect stainfo members and priv members*/ - spinlock_t staRecord_lock; -#endif -#ifdef CSR_NATIVE_LINUX -#ifdef CSR_SUPPORT_WEXT - /* wireless config */ - struct wext_config wext_conf; -#endif - - /* Mutex to protect the MLME blocking requests */ - struct semaphore mlme_blocking_mutex; - - /* The ul_client that provides the blocking API for WEXT calls */ - ul_client_t *wext_client; - -#endif /* CSR_NATIVE_LINUX */ - -#ifdef CSR_SUPPORT_SME - wait_queue_head_t sme_request_wq; - /* Semaphore to protect the SME blocking requests */ - struct semaphore sme_sem; - /* Structure to hold the SME blocking requests data*/ - sme_reply_t sme_reply; - - /* Structure to hold a traffic protocol indication */ - struct ta_ind { - struct work_struct task; - CsrWifiRouterCtrlTrafficPacketType packet_type; - CsrWifiRouterCtrlProtocolDirection direction; - CsrWifiMacAddress src_addr; - int in_use; - } ta_ind_work; - - struct ta_sample_ind { - struct work_struct task; - CsrWifiRouterCtrlTrafficStats stats; - int in_use; - } ta_sample_ind_work; - - __be32 sta_ip_address; - CsrWifiRouterCtrlSmeVersions sme_versions; - - /* - * Flag to reflect state of unifi_sys_wifi_on_*() progress. - * This indicates whether we are in an "wifi on" state when we are - * allowed to indication errors with unifi_mgt_wifi_off_ind() - */ - enum { - wifi_on_unspecified = -1, - wifi_on_in_progress = 0, - wifi_on_done = 1, - } wifi_on_state; - - /* Userspace TaskId for the SME Set when a wifi on req is received */ - CsrSchedQid CSR_WIFI_SME_IFACEQUEUE; - - struct work_struct multicast_list_task; - /* - * The SME installs filters to ask for specific MA-UNITDATA.req - * to be passed to different SME components. - */ -#define MAX_MA_UNIDATA_IND_FILTERS 8 - sme_ma_unidata_ind_filter_t sme_unidata_ind_filters[MAX_MA_UNIDATA_IND_FILTERS]; - -/* UNIFI_CFG related parameters */ - uf_cfg_bcast_packet_filter_t packet_filters; - unsigned char *filter_tclas_ies; - /* The structure that holds all the connection configuration. */ - CsrWifiSmeConnectionConfig connection_config; -#ifdef CSR_SUPPORT_WEXT - - int ignore_bssid_join; - struct iw_statistics wext_wireless_stats; - - /* The MIB and MAC address files contents, read from userspace */ - CsrWifiSmeDataBlock mib_data; - CsrWifiMacAddress sta_mac_address; - - int wep_tx_key_index; - wep_key_t wep_keys[NUM_WEPKEYS]; - - -#ifdef CSR_SUPPORT_WEXT_AP - CsrWifiSmeApMacConfig ap_mac_config; - CsrWifiNmeApConfig group_sec_config; - CsrWifiSmeApConfig_t ap_config; -#endif - struct work_struct sme_config_task; - -#endif /* CSR_SUPPORT_WEXT */ - -#endif /* CSR_SUPPORT_SME */ - -#ifdef CSR_SME_USERSPACE - void *smepriv; -#endif /* CSR_SME_USERSPACE */ - - card_info_t card_info; - - /* Mutex to protect unifi_send_signal() */ - spinlock_t send_signal_lock; - - - /* - * The workqueue to offload the TA run - * and the multicast addresses list set - */ - struct workqueue_struct *unifi_workqueue; - - unsigned char *mib_cfm_buffer; - unsigned int mib_cfm_buffer_length; - - int ptest_mode; /* Set when in production test mode */ - int coredump_mode; /* Set when SME has requested a coredump */ - u8 wol_suspend; /* Set when suspending with UniFi powered */ - -#define UF_UNCONTROLLED_PORT_Q 0 -#define UF_CONTROLLED_PORT_Q 1 - - /* Semaphore to protect the rx queues list */ - struct semaphore rx_q_sem; - - /* Spinlock to protect M4 data */ - spinlock_t m4_lock; - /* Mutex to protect BA RX data */ - struct semaphore ba_mutex; - -#if (defined(CSR_WIFI_SECURITY_WAPI_ENABLE) && defined(CSR_WIFI_SECURITY_WAPI_SW_ENCRYPTION)) - /* Spinlock to protect the WAPI data */ - spinlock_t wapi_lock; -#endif - - /* Array to indicate if a particular Tx queue is paused, this may not be - * required in a multiqueue implementation since we can directly stop kernel - * queues */ - u8 tx_q_paused_flag[UNIFI_TRAFFIC_Q_MAX]; - -#ifdef CSR_WIFI_RX_PATH_SPLIT - struct workqueue_struct *rx_workqueue; - struct work_struct rx_work_struct; - rxCircularBuffer_t rxSignalBuffer; - -#endif - - u32 rxTcpThroughput; - u32 txTcpThroughput; - u32 rxUdpThroughput; - u32 txUdpThroughput; - -#ifdef CSR_WIFI_SECURITY_WAPI_ENABLE - /*Set if multicast KeyID = 1*/ - u8 wapi_multicast_filter; - /*Set if unicast KeyID = 1*/ - u8 wapi_unicast_filter; - u8 wapi_unicast_queued_pkt_filter; -#ifdef CSR_WIFI_SECURITY_WAPI_QOSCTRL_MIC_WORKAROUND - u8 isWapiConnection; -#endif -#endif - -#ifdef CSR_WIFI_SPLIT_PATCH - CsrWifiRouterCtrlModeSetReq pending_mode_set; -#endif - - u8 cmanrTestMode; - CSR_RATE cmanrTestModeTransmitRate; - -}; - -typedef struct { - u16 queue_length[4]; - u8 os_queue_paused; -} unifi_OsQosInfo; - - -typedef struct { - u8 active; - bulk_data_param_t bulkdata; - CSR_SIGNAL signal; - u16 sn; - u32 recv_time; -} frame_desc_struct; - -typedef struct { - frame_desc_struct *buffer; - u16 wind_size; - u16 occupied_slots; - struct timer_list timer; - u16 timeout; - u16 expected_sn; - u16 start_sn; - u8 trigger_ba_after_ssn; - struct netInterface_priv *interfacePriv; - u16 tID; - CsrWifiMacAddress macAddress; - struct work_struct send_ba_err_task; -} ba_session_rx_struct; - - -typedef struct { - struct netInterface_priv *interfacePriv; - u16 tID; - CsrWifiMacAddress macAddress; -} ba_session_tx_struct; - -typedef struct netInterface_priv -{ - u16 InterfaceTag; - struct unifi_priv *privPtr; - ba_session_tx_struct *ba_session_tx[MAX_SUPPORTED_BA_SESSIONS_TX]; - ba_session_rx_struct *ba_session_rx[MAX_SUPPORTED_BA_SESSIONS_RX]; - frame_desc_struct ba_complete[MAX_BA_WIND_SIZE]; - u8 ba_complete_index; - u8 queueEnabled[UNIFI_NO_OF_TX_QS]; - struct work_struct send_m4_ready_task; -#ifdef CSR_WIFI_SECURITY_WAPI_ENABLE - struct work_struct send_pkt_to_encrypt; -#endif - struct net_device_stats stats; - u8 interfaceMode; - u8 protect; - CsrWifiMacAddress bssid; - /* - * Flag to reflect state of CONNECTED indication signal. - * This indicates whether we are "joined" an Access Point (i.e. have - * nominated an AP and are receiving beacons) but give no indication - * of whether we are authenticated and/or associated. - */ - enum { - UnifiConnectedUnknown = -1, - UnifiNotConnected = 0, - UnifiConnected = 1, - } connected; -#ifdef CSR_SUPPORT_WEXT - /* Tracks when we are waiting for a netdevice state change callback */ - u8 wait_netdev_change; - /* True if we have successfully registered for netdev callbacks */ - u8 netdev_callback_registered; -#endif /* CSR_SUPPORT_WEXT */ - unsigned int netdev_registered; -#define UNIFI_MAX_MULTICAST_ADDRESSES 10 - /* The multicast addresses list that the thread needs to set. */ - u8 mc_list[UNIFI_MAX_MULTICAST_ADDRESSES*ETH_ALEN]; - /* The multicast addresses count that the thread needs to set. */ - int mc_list_count; - u32 tag; -#ifdef CSR_SUPPORT_SME - /* (un)controlled port configuration */ - unifi_port_config_t controlled_data_port; - unifi_port_config_t uncontrolled_data_port; - - /* station record maintenance related data structures */ - u8 num_stations_joined; - CsrWifiRouterCtrlStaInfo_t *(staInfo)[UNIFI_MAX_CONNECTIONS]; - struct list_head genericMgtFrames; - struct list_head genericMulticastOrBroadCastFrames; - struct list_head genericMulticastOrBroadCastMgtFrames; - - /* Timer for detecting station inactivity */ - struct timer_list sta_activity_check_timer; - u8 sta_activity_check_enabled; - - /* Timestamp when the last inactivity check was done */ - u32 last_inactivity_check; - - /*number of multicast or borad cast packets queued*/ - u16 noOfbroadcastPktQueued; -#endif - /* A list to hold the buffered uncontrolled port packets */ - struct list_head rx_uncontrolled_list; - /* A list to hold the buffered controlled port packets */ - struct list_head rx_controlled_list; - /* Buffered M4 signal to take care of WPA race condition */ - CSR_SIGNAL m4_signal; - bulk_data_desc_t m4_bulk_data; - -#if (defined(CSR_WIFI_SECURITY_WAPI_ENABLE) && defined(CSR_WIFI_SECURITY_WAPI_SW_ENCRYPTION)) - /* Buffered WAPI Unicast MA Packet Request for encryption in Sme */ - CSR_SIGNAL wapi_unicast_ma_pkt_sig; - bulk_data_desc_t wapi_unicast_bulk_data; -#endif - - /* This should be removed and m4_hostTag should be used for checking*/ - u8 m4_sent; - CSR_CLIENT_TAG m4_hostTag; - u8 dtimActive; - u8 intraBssEnabled; - u32 multicastPduHostTag; /* Used to set the tim after getting - a confirm for it */ - u8 bcTimSet; - u8 bcTimSetReqPendingFlag; - u8 bcTimSetReqQueued; -} netInterface_priv_t; - -#ifdef CSR_SUPPORT_SME -#define routerStartBuffering(priv, queue) priv->routerBufferEnable[(queue)] = TRUE; -#define routerStopBuffering(priv, queue) priv->routerBufferEnable[(queue)] = FALSE; -#define isRouterBufferEnabled(priv, queue) priv->routerBufferEnable[(queue)] -#endif - -#ifdef USE_DRIVER_LOCK -#define LOCK_DRIVER(_p) down_interruptible(&(_p)->lock) -#define UNLOCK_DRIVER(_p) up(&(_p)->lock) -#else -#define LOCK_DRIVER(_p) (void)(_p); /* as nothing */ -#define UNLOCK_DRIVER(_p) (void)(_p); /* as nothing */ -#endif /* USE_DRIVER_LOCK */ - -s32 CsrHipResultToStatus(CsrResult csrResult); - - -/* - * SDIO related functions and callbacks - */ -int uf_sdio_load(void); -void uf_sdio_unload(void); -unifi_priv_t *uf_find_instance(int inst); -int uf_find_priv(unifi_priv_t *priv); -int uf_find_netdev_priv(netInterface_priv_t *priv); -unifi_priv_t *uf_get_instance(int inst); -void uf_put_instance(int inst); -int csr_sdio_linux_install_irq(CsrSdioFunction *sdio); -int csr_sdio_linux_remove_irq(CsrSdioFunction *sdio); - -void uf_add_os_device(int bus_id, struct device *os_device); -void uf_remove_os_device(int bus_id); - - - -/* - * Claim/release SDIO - * - * For multifunction cards, we cannot grub the SDIO lock around the unifi_bh() - * as this prevents other functions using SDIO. - * Since some of CSR SDIO API is used regardless of trying to lock unifi_bh() - * we have followed this scheme: - * 1. If a function needs protection only when CSR_WIFI_SINGLE_FUNCTION is defined - * then we call CsrSdioClaim/CsrSdioRelease(). - * 2. If a function needs protection only when CSR_WIFI_SINGLE_FUNCTION is not defined - * then we call _sdio_claim_host/_sdio_claim_host(). Use of this should be restricted - * to the SDIO glue layer only (e.g. sdio_mmc.c). - * 3. If a function needs protection, regardless of the CSR_WIFI_SINGLE_FUNCTION - * then we call directly the sdio_claim_host/sdio_release_host(). - * Use of this must be restricted to the SDIO glue layer only (e.g. sdio_mmc.c). - * - * Note: The _func and function pointers are _not_ the same. - * The former is the (struct sdio_func*) context, which restricts the use to the SDIO glue layer. - * The latter is the (CsrSdioFunction*) context, which allows calls from all layers. - */ - -#ifdef CSR_WIFI_SUPPORT_MMC_DRIVER - -#ifdef CSR_WIFI_SINGLE_FUNCTION -#define CsrSdioClaim(function) sdio_claim_host((function)->priv); -#define CsrSdioRelease(function) sdio_release_host((function)->priv); - -#define _sdio_claim_host(_func) -#define _sdio_release_host(_func) - -#else -#define CsrSdioClaim(function) -#define CsrSdioRelease(function) - -#define _sdio_claim_host(_func) sdio_claim_host(_func) -#define _sdio_release_host(_func) sdio_release_host(_func) - -#endif /* CSR_WIFI_SINGLE_FUNCTION */ - -#else -#define _sdio_claim_host(_func) -#define _sdio_release_host(_func) - -#define CsrSdioClaim(function) -#define CsrSdioRelease(function) - -#endif /* CSR_WIFI_SUPPORT_MMC_DRIVER */ - - -/* - * Functions to allocate and free an ethernet device. - */ -unifi_priv_t *uf_alloc_netdevice(CsrSdioFunction *sdio_dev, int bus_id); -int uf_free_netdevice(unifi_priv_t *priv); - -/* Allocating function for other interfaces */ -u8 uf_alloc_netdevice_for_other_interfaces(unifi_priv_t *priv, u16 interfaceTag); - -/* - * Firmware download related functions. - */ -int uf_run_unifihelper(unifi_priv_t *priv); -int uf_request_firmware_files(unifi_priv_t *priv, int is_fw); -int uf_release_firmware_files(unifi_priv_t *priv); -int uf_release_firmware(unifi_priv_t *priv, struct dlpriv *to_free); - -/* - * Functions to create and delete the device nodes. - */ -int uf_create_device_nodes(unifi_priv_t *priv, int bus_id); -void uf_destroy_device_nodes(unifi_priv_t *priv); - -/* - * Upper Edge Initialisation functions - */ -int uf_init_bh(unifi_priv_t *priv); -int uf_init_hw(unifi_priv_t *priv); - -/* Thread related helper functions */ -int uf_start_thread(unifi_priv_t *priv, struct uf_thread *thread, int (*func)(void *)); -void uf_stop_thread(unifi_priv_t *priv, struct uf_thread *thread); -void uf_wait_for_thread_to_stop(unifi_priv_t *priv, struct uf_thread *thread); - - -/* - * Unifi Linux functions - */ -void ul_init_clients(unifi_priv_t *priv); - -/* Configuration flags */ -#define CLI_USING_WIRE_FORMAT 0x0002 -#define CLI_SME_USERSPACE 0x0020 -ul_client_t *ul_register_client(unifi_priv_t *priv, - unsigned int configuration, - udi_event_t udi_event_clbk); -int ul_deregister_client(ul_client_t *pcli); - -int ul_send_signal_unpacked(unifi_priv_t *priv, - CSR_SIGNAL *sigptr, - bulk_data_param_t *bulkdata); -int ul_send_signal_raw(unifi_priv_t *priv, - unsigned char *sigptr, int siglen, - bulk_data_param_t *bulkdata); - -void ul_log_config_ind(unifi_priv_t *priv, u8 *conf_param, int len); - - -/* - * Data plane operations - */ -/* - * data_tx.c - */ -int uf_verify_m4(unifi_priv_t *priv, const unsigned char *packet, - unsigned int length); - -#ifdef CSR_SUPPORT_SME -u8 uf_check_broadcast_bssid(unifi_priv_t *priv, const bulk_data_param_t *bulkdata); -u8 uf_process_pm_bit_for_peer(unifi_priv_t * priv, CsrWifiRouterCtrlStaInfo_t * srcStaInfo, u8 pmBit, u16 interfaceTag); -void uf_process_ps_poll(unifi_priv_t *priv, u8* sa, u8* da, u8 pmBit, u16 interfaceTag); -int uf_ap_process_data_pdu(unifi_priv_t *priv, struct sk_buff *skb, - struct ethhdr *ehdr, CsrWifiRouterCtrlStaInfo_t * srcStaInfo, - const CSR_SIGNAL *signal, - bulk_data_param_t *bulkdata, - u8 macHeaderLengthInBytes); -u8 uf_is_more_data_for_non_delivery_ac(CsrWifiRouterCtrlStaInfo_t *staRecord); -void uf_process_wmm_deliver_ac_uapsd ( unifi_priv_t * priv, - CsrWifiRouterCtrlStaInfo_t * srcStaInfo, - u16 qosControl, - u16 interfaceTag); - -void uf_send_buffered_data_from_ac(unifi_priv_t *priv, CsrWifiRouterCtrlStaInfo_t * staInfo, u8 queue, struct list_head *txList); -void uf_send_buffered_data_from_delivery_ac(unifi_priv_t *priv, CsrWifiRouterCtrlStaInfo_t * staInfo, u8 queue, struct list_head *txList); - -void uf_continue_uapsd(unifi_priv_t *priv, CsrWifiRouterCtrlStaInfo_t * staInfo); -void uf_send_qos_null(unifi_priv_t * priv, u16 interfaceTag, const u8 *da, CSR_PRIORITY priority, CsrWifiRouterCtrlStaInfo_t * srcStaInfo); -void uf_send_nulldata(unifi_priv_t * priv, u16 interfaceTag, const u8 *da, CSR_PRIORITY priority, CsrWifiRouterCtrlStaInfo_t * srcStaInfo); - - - -#endif -CsrResult uf_process_ma_packet_req(unifi_priv_t *priv, u8 *peerMacAddress, CSR_CLIENT_TAG hostTag, u16 interfaceTag, CSR_TRANSMISSION_CONTROL transmissionControl, CSR_RATE TransmitRate, CSR_PRIORITY priority, CSR_PROCESS_ID senderId, bulk_data_param_t *bulkdata); -void uf_process_ma_vif_availibility_ind(unifi_priv_t *priv, u8 *sigdata, u32 siglen); -#ifdef CSR_SUPPORT_SME -void uf_send_buffered_frames(unifi_priv_t *priv, unifi_TrafficQueue queue); -int uf_process_station_records_for_sending_data(unifi_priv_t *priv, u16 interfaceTag, - CsrWifiRouterCtrlStaInfo_t *srcStaInfo, - CsrWifiRouterCtrlStaInfo_t *dstStaInfo); -void uf_prepare_send_cfm_list_for_queued_pkts(unifi_priv_t * priv, - struct list_head *frames_need_cfm_list, - struct list_head * list); -void send_auto_ma_packet_confirm(unifi_priv_t *priv, - netInterface_priv_t *interfacePriv, - struct list_head *buffered_frames_list); -void uf_flush_list(unifi_priv_t * priv, struct list_head * list); -tx_buffered_packets_t *dequeue_tx_data_pdu(unifi_priv_t *priv, struct list_head *txList); -void resume_unicast_buffered_frames(unifi_priv_t *priv, u16 interfaceTag); -void update_eosp_to_head_of_broadcast_list_head(unifi_priv_t *priv, u16 interfaceTag); -void resume_suspended_uapsd(unifi_priv_t* priv, u16 interfaceTag); -#endif -/* - * netdev.c - */ - -#ifndef P80211_OUI_LEN -#define P80211_OUI_LEN 3 -#endif -typedef struct { - u8 dsap; /* always 0xAA */ - u8 ssap; /* always 0xAA */ - u8 ctrl; /* always 0x03 */ - u8 oui[P80211_OUI_LEN]; /* organizational universal id */ - u16 protocol; -} __attribute__ ((packed)) llc_snap_hdr_t; -int skb_add_llc_snap(struct net_device *dev, struct sk_buff *skb, int proto); -int skb_80211_to_ether(unifi_priv_t *priv, struct sk_buff *skb, - const unsigned char *daddr, const unsigned char *saddr, - const CSR_SIGNAL *signal, - bulk_data_param_t *bulkdata); - -const char *result_code_str(int result); - - -/* prepares & appends the Mac header for the payload */ -int prepare_and_add_macheader(unifi_priv_t *priv, - struct sk_buff *skb, - struct sk_buff *newSkb, - CSR_PRIORITY priority, - bulk_data_param_t *bulkdata, - u16 interfaceTag, - const u8 *daddr, - const u8 *saddr, - u8 protection); -CSR_PRIORITY -get_packet_priority(unifi_priv_t *priv, struct sk_buff *skb, const struct ethhdr *ehdr, netInterface_priv_t *interfacePriv); - -void -unifi_frame_ma_packet_req(unifi_priv_t *priv, CSR_PRIORITY priority, - CSR_RATE TransmitRate, CSR_CLIENT_TAG hostTag, - u16 interfaceTag, CSR_TRANSMISSION_CONTROL transmissionControl, - CSR_PROCESS_ID leSenderProcessId, u8 *peerMacAddress, - CSR_SIGNAL *signal); - - -/* Pack the LSB to include station handle & status of tim set */ -#define CSR_WIFI_PACK_SENDER_ID_LSB_FOR_TIM_REQ(handle, timState) ((handle << 2) | timState) -/* get the station record handle from the sender ID */ -#define CSR_WIFI_GET_STATION_HANDLE_FROM_RECEIVER_ID(receiverProcessId) (u8) ((receiverProcessId & 0xff) >> 2) -/* get the timSet status from the sender ID */ -#define CSR_WIFI_GET_TIMSET_STATE_FROM_RECEIVER_ID(receiverProcessId) (u8) (receiverProcessId & 0x03) - -/* handle is 6 bits to accomodate in senderId LSB (only 64 station can be associated) */ -#define CSR_WIFI_BROADCAST_OR_MULTICAST_HANDLE 0x3F - -void update_tim(unifi_priv_t * priv, u16 aid, u8 setTim, u16 interfaceTag, u32 handle); -void uf_handle_tim_cfm(unifi_priv_t *priv, CSR_MLME_SET_TIM_CONFIRM *cfm, u16 senderProcessId); - -/* Clear the Peer station Record, in case of wifioff/unexpected card removal */ -void CsrWifiRouterCtrlInterfaceReset(unifi_priv_t *priv, u16 interfaceTag); - -void scroll_ba_window(unifi_priv_t *priv, - netInterface_priv_t *interfacePriv, - ba_session_rx_struct *ba_session, - u16 sn); - -u8 blockack_session_stop(unifi_priv_t *priv, - u16 interfaceTag, - CsrWifiRouterCtrlBlockAckRole role, - u16 tID, - CsrWifiMacAddress macAddress); -#ifdef CSR_SUPPORT_SME -/* Fetch the protection information from interface Mode */ -s8 uf_get_protection_bit_from_interfacemode(unifi_priv_t *priv, u16 interfaceTag, const u8 *daddr); -#endif - -/* Fetch the station record handler from data base for matching Mac address */ -#ifdef CSR_SUPPORT_SME -CsrWifiRouterCtrlStaInfo_t *CsrWifiRouterCtrlGetStationRecordFromPeerMacAddress(unifi_priv_t *priv, - const u8 *peerMacAddress, - u16 interfaceTag); - -/* Fetch the station record handler from data base for matching handle */ -CsrWifiRouterCtrlStaInfo_t * CsrWifiRouterCtrlGetStationRecordFromHandle(unifi_priv_t *priv, - u32 handle, - u16 interfaceTag); - -void uf_update_sta_activity(unifi_priv_t *priv, u16 interfaceTag, const u8 *peerMacAddress); -void uf_process_ma_pkt_cfm_for_ap(unifi_priv_t *priv, u16 interfaceTag, const CSR_MA_PACKET_CONFIRM *pkt_cfm); -#endif - -void uf_resume_data_plane(unifi_priv_t *priv, int queue, - CsrWifiMacAddress peer_address, - u16 interfaceTag); -void uf_free_pending_rx_packets(unifi_priv_t *priv, int queue, - CsrWifiMacAddress peer_address, u16 interfaceTag); - -int uf_register_netdev(unifi_priv_t *priv, int numOfInterface); -void uf_unregister_netdev(unifi_priv_t *priv); - -void uf_net_get_name(struct net_device *dev, char *name, int len); - -void uf_send_queue_info(unifi_priv_t *priv); -u16 uf_get_vif_identifier(CsrWifiRouterCtrlMode mode, u16 tag); - -void uf_process_rx_pending_queue(unifi_priv_t *priv, int queue, - CsrWifiMacAddress source_address, - int indicate, u16 interfaceTag); - -#ifdef CSR_WIFI_HIP_DEBUG_OFFLINE -int uf_register_hip_offline_debug(unifi_priv_t *priv); -int uf_unregister_hip_offline_debug(unifi_priv_t *priv); -#endif - -/* - * inet.c - */ -void uf_register_inet_notifier(void); -void uf_unregister_inet_notifier(void); - - -/* - * Suspend / Resume handlers - */ -void unifi_resume(void *ospriv); -void unifi_suspend(void *ospriv); - - -#define QOS_CAPABILITY_WMM_ENABLED 0x0001 -#define QOS_CAPABILITY_WMM_UAPSD 0x0002 -#define QOS_CAPABILITY_ACM_BE_ENABLED 0x0010 -#define QOS_CAPABILITY_ACM_BK_ENABLED 0x0020 -#define QOS_CAPABILITY_ACM_VI_ENABLED 0x0040 -#define QOS_CAPABILITY_ACM_VO_ENABLED 0x0080 -#define QOS_CAPABILITY_TS_BE_ENABLED 0x0100 -#define QOS_CAPABILITY_TS_BK_ENABLED 0x0200 -#define QOS_CAPABILITY_TS_VI_ENABLED 0x0400 -#define QOS_CAPABILITY_TS_VO_ENABLED 0x0800 - - -/* EAPOL PDUS */ -#ifndef ETH_P_PAE -#define ETH_P_PAE 0x888e -#endif -#ifndef ETH_P_WAI -#define ETH_P_WAI 0x88b4 -#endif -/* - * unifi_dbg.c - */ -void debug_string_indication(unifi_priv_t *priv, - const unsigned char *extra, - unsigned int extralen); -void debug_word16_indication(unifi_priv_t *priv, const CSR_SIGNAL *sigptr); -void debug_generic_indication(unifi_priv_t *priv, const CSR_SIGNAL *sigptr); - - -/* - * putest.c - */ -int unifi_putest_start(unifi_priv_t *priv, unsigned char *arg); -int unifi_putest_cmd52_block_read(unifi_priv_t *priv, unsigned char *arg); -int unifi_putest_stop(unifi_priv_t *priv, unsigned char *arg); -int unifi_putest_set_sdio_clock(unifi_priv_t *priv, unsigned char *arg); -int unifi_putest_cmd52_read(unifi_priv_t *priv, unsigned char *arg); -int unifi_putest_coredump_prepare(unifi_priv_t *priv, unsigned char *arg); -int unifi_putest_cmd52_write(unifi_priv_t *priv, unsigned char *arg); -int unifi_putest_gp_read16(unifi_priv_t *priv, unsigned char *arg); -int unifi_putest_gp_write16(unifi_priv_t *priv, unsigned char *arg); - -int unifi_putest_dl_fw(unifi_priv_t *priv, unsigned char *arg); -int unifi_putest_dl_fw_buff(unifi_priv_t *priv, unsigned char *arg); - -#endif /* __LINUX_UNIFI_PRIV_H__ */ diff --git a/drivers/staging/csr/unifi_sme.c b/drivers/staging/csr/unifi_sme.c deleted file mode 100644 index 50908822b3c8..000000000000 --- a/drivers/staging/csr/unifi_sme.c +++ /dev/null @@ -1,1225 +0,0 @@ -/* - * *************************************************************************** - * FILE: unifi_sme.c - * - * PURPOSE: SME related functions. - * - * Copyright (C) 2007-2009 by Cambridge Silicon Radio Ltd. - * - * Refer to LICENSE.txt included with this source code for details on - * the license terms. - * - * *************************************************************************** - */ - -#include "unifi_priv.h" -#include "csr_wifi_hip_unifi.h" -#include "csr_wifi_hip_conversions.h" -#include - - - - int -convert_sme_error(CsrResult error) -{ - switch (error) { - case CSR_RESULT_SUCCESS: - return 0; - case CSR_RESULT_FAILURE: - case CSR_WIFI_RESULT_NOT_FOUND: - case CSR_WIFI_RESULT_TIMED_OUT: - case CSR_WIFI_RESULT_CANCELLED: - case CSR_WIFI_RESULT_UNAVAILABLE: - return -EIO; - case CSR_WIFI_RESULT_NO_ROOM: - return -EBUSY; - case CSR_WIFI_RESULT_INVALID_PARAMETER: - return -EINVAL; - case CSR_WIFI_RESULT_UNSUPPORTED: - return -EOPNOTSUPP; - default: - return -EIO; - } -} - - -/* - * --------------------------------------------------------------------------- - * sme_log_event - * - * Callback function to be registered as the SME event callback. - * Copies the signal content into a new udi_log_t struct and adds - * it to the read queue for the SME client. - * - * Arguments: - * arg This is the value given to unifi_add_udi_hook, in - * this case a pointer to the client instance. - * signal Pointer to the received signal. - * signal_len Size of the signal structure in bytes. - * bulkdata Pointers to any associated bulk data. - * dir Direction of the signal. Zero means from host, - * non-zero means to host. - * - * Returns: - * None. - * --------------------------------------------------------------------------- - */ - void -sme_log_event(ul_client_t *pcli, - const u8 *signal, int signal_len, - const bulk_data_param_t *bulkdata, - int dir) -{ - unifi_priv_t *priv; - CSR_SIGNAL unpacked_signal; - CsrWifiSmeDataBlock mlmeCommand; - CsrWifiSmeDataBlock dataref1; - CsrWifiSmeDataBlock dataref2; - CsrResult result = CSR_RESULT_SUCCESS; - int r; - - /* Just a sanity check */ - if ((signal == NULL) || (signal_len <= 0)) { - return; - } - - priv = uf_find_instance(pcli->instance); - if (!priv) { - unifi_error(priv, "sme_log_event: invalid priv\n"); - return; - } - - if (priv->smepriv == NULL) { - unifi_error(priv, "sme_log_event: invalid smepriv\n"); - return; - } - - unifi_trace(priv, UDBG3, - "sme_log_event: Process signal 0x%.4X\n", - CSR_GET_UINT16_FROM_LITTLE_ENDIAN(signal)); - - - /* If the signal is known, then do any filtering required, otherwise it pass it to the SME. */ - r = read_unpack_signal(signal, &unpacked_signal); - if (r == CSR_RESULT_SUCCESS) { - if ((unpacked_signal.SignalPrimitiveHeader.SignalId == CSR_DEBUG_STRING_INDICATION_ID) || - (unpacked_signal.SignalPrimitiveHeader.SignalId == CSR_DEBUG_WORD16_INDICATION_ID)) - { - return; - } - if (unpacked_signal.SignalPrimitiveHeader.SignalId == CSR_MA_PACKET_INDICATION_ID) - { - u16 frmCtrl; - u8 unicastPdu = TRUE; - u8 *macHdrLocation; - u8 *raddr = NULL, *taddr = NULL; - CsrWifiMacAddress peerMacAddress; - /* Check if we need to send CsrWifiRouterCtrlMicFailureInd*/ - CSR_MA_PACKET_INDICATION *ind = &unpacked_signal.u.MaPacketIndication; - - macHdrLocation = (u8 *) bulkdata->d[0].os_data_ptr; - /* Fetch the frame control value from mac header */ - frmCtrl = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(macHdrLocation); - - /* Point to the addresses */ - raddr = macHdrLocation + MAC_HEADER_ADDR1_OFFSET; - taddr = macHdrLocation + MAC_HEADER_ADDR2_OFFSET; - - memcpy(peerMacAddress.a, taddr, ETH_ALEN); - - if(ind->ReceptionStatus == CSR_MICHAEL_MIC_ERROR) - { - if (*raddr & 0x1) - unicastPdu = FALSE; - - CsrWifiRouterCtrlMicFailureIndSend (priv->CSR_WIFI_SME_IFACEQUEUE, 0, - (ind->VirtualInterfaceIdentifier & 0xff), peerMacAddress, - unicastPdu); - return; - } - else - { - if(ind->ReceptionStatus == CSR_RX_SUCCESS) - { - u8 pmBit = (frmCtrl & 0x1000)?0x01:0x00; - u16 interfaceTag = (ind->VirtualInterfaceIdentifier & 0xff); - CsrWifiRouterCtrlStaInfo_t *srcStaInfo = CsrWifiRouterCtrlGetStationRecordFromPeerMacAddress(priv, taddr, interfaceTag); - if((srcStaInfo != NULL) && (uf_check_broadcast_bssid(priv, bulkdata)== FALSE)) - { - uf_process_pm_bit_for_peer(priv, srcStaInfo, pmBit, interfaceTag); - - /* Update station last activity flag */ - srcStaInfo->activity_flag = TRUE; - } - } - } - } - - if (unpacked_signal.SignalPrimitiveHeader.SignalId == CSR_MA_PACKET_CONFIRM_ID) - { - CSR_MA_PACKET_CONFIRM *cfm = &unpacked_signal.u.MaPacketConfirm; - u16 interfaceTag = (cfm->VirtualInterfaceIdentifier & 0xff); - netInterface_priv_t *interfacePriv; - CSR_MA_PACKET_REQUEST *req; - CsrWifiMacAddress peerMacAddress; - - if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) - { - unifi_error(priv, "Bad MA_PACKET_CONFIRM interfaceTag %d\n", interfaceTag); - return; - } - - unifi_trace(priv, UDBG1, "MA-PACKET Confirm (%x, %x)\n", cfm->HostTag, cfm->TransmissionStatus); - - interfacePriv = priv->interfacePriv[interfaceTag]; -#ifdef CSR_SUPPORT_SME - if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP || - interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO) { - - if(cfm->HostTag == interfacePriv->multicastPduHostTag){ - uf_process_ma_pkt_cfm_for_ap(priv, interfaceTag, cfm); - } - } -#endif - - req = &interfacePriv->m4_signal.u.MaPacketRequest; - - if(cfm->HostTag & 0x80000000) - { - if (cfm->TransmissionStatus != CSR_TX_SUCCESSFUL) - { - result = CSR_RESULT_FAILURE; - } -#ifdef CSR_SUPPORT_SME - memcpy(peerMacAddress.a, req->Ra.x, ETH_ALEN); - /* Check if this is a confirm for EAPOL M4 frame and we need to send transmistted ind*/ - if (interfacePriv->m4_sent && (cfm->HostTag == interfacePriv->m4_hostTag)) - { - unifi_trace(priv, UDBG1, "%s: Sending M4 Transmit CFM\n", __FUNCTION__); - CsrWifiRouterCtrlM4TransmittedIndSend(priv->CSR_WIFI_SME_IFACEQUEUE, 0, - interfaceTag, - peerMacAddress, - result); - interfacePriv->m4_sent = FALSE; - interfacePriv->m4_hostTag = 0xffffffff; - } -#endif - /* If EAPOL was requested via router APIs then send cfm else ignore*/ - if((cfm->HostTag & 0x80000000) != CSR_WIFI_EAPOL_M4_HOST_TAG) { - CsrWifiRouterMaPacketCfmSend((u16)signal[2], - cfm->VirtualInterfaceIdentifier, - result, - (cfm->HostTag & 0x3fffffff), cfm->Rate); - } else { - unifi_trace(priv, UDBG1, "%s: M4 received from netdevice\n", __FUNCTION__); - } - return; - } - } - } - - mlmeCommand.length = signal_len; - mlmeCommand.data = (u8*)signal; - - dataref1.length = bulkdata->d[0].data_length; - if (dataref1.length > 0) { - dataref1.data = (u8 *) bulkdata->d[0].os_data_ptr; - } else - { - dataref1.data = NULL; - } - - dataref2.length = bulkdata->d[1].data_length; - if (dataref2.length > 0) { - dataref2.data = (u8 *) bulkdata->d[1].os_data_ptr; - } else - { - dataref2.data = NULL; - } - - CsrWifiRouterCtrlHipIndSend(priv->CSR_WIFI_SME_IFACEQUEUE, mlmeCommand.length, mlmeCommand.data, - dataref1.length, dataref1.data, - dataref2.length, dataref2.data); - -} /* sme_log_event() */ - - -/* - * --------------------------------------------------------------------------- - * uf_sme_port_state - * - * Return the state of the controlled port. - * - * Arguments: - * priv Pointer to device private context struct - * address Pointer to the destination for tx or sender for rx address - * queue Controlled or uncontrolled queue - * - * Returns: - * An unifi_ControlledPortAction value. - * --------------------------------------------------------------------------- - */ -CsrWifiRouterCtrlPortAction -uf_sme_port_state(unifi_priv_t *priv, unsigned char *address, int queue, u16 interfaceTag) -{ - int i; - unifi_port_config_t *port; - netInterface_priv_t *interfacePriv; - - if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) { - unifi_error(priv, "uf_sme_port_state: bad interfaceTag\n"); - return CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_CLOSED_DISCARD; - } - - interfacePriv = priv->interfacePriv[interfaceTag]; - - if (queue == UF_CONTROLLED_PORT_Q) { - port = &interfacePriv->controlled_data_port; - } else { - port = &interfacePriv->uncontrolled_data_port; - } - - if (!port->entries_in_use) { - unifi_trace(priv, UDBG5, "No port configurations, return Discard.\n"); - return CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_CLOSED_DISCARD; - } - - /* If the port configuration is common for all destinations, return it. */ - if (port->overide_action == UF_DATA_PORT_OVERIDE) { - unifi_trace(priv, UDBG5, "Single port configuration (%d).\n", - port->port_cfg[0].port_action); - return port->port_cfg[0].port_action; - } - - unifi_trace(priv, UDBG5, "Multiple (%d) port configurations.\n", port->entries_in_use); - - /* If multiple configurations exist.. */ - for (i = 0; i < UNIFI_MAX_CONNECTIONS; i++) { - /* .. go through the list and match the destination address. */ - if (port->port_cfg[i].in_use && - memcmp(address, port->port_cfg[i].mac_address.a, ETH_ALEN) == 0) { - /* Return the desired action. */ - return port->port_cfg[i].port_action; - } - } - - /* Could not find any information, return Open. */ - unifi_trace(priv, UDBG5, "port configuration not found, return Open.\n"); - return CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_OPEN; -} /* uf_sme_port_state() */ - -/* - * --------------------------------------------------------------------------- - * uf_sme_port_config_handle - * - * Return the port config handle of the controlled/uncontrolled port. - * - * Arguments: - * priv Pointer to device private context struct - * address Pointer to the destination for tx or sender for rx address - * queue Controlled or uncontrolled queue - * - * Returns: - * An unifi_port_cfg_t* . - * --------------------------------------------------------------------------- - */ -unifi_port_cfg_t* -uf_sme_port_config_handle(unifi_priv_t *priv, unsigned char *address, int queue, u16 interfaceTag) -{ - int i; - unifi_port_config_t *port; - netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag]; - - if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) { - unifi_error(priv, "uf_sme_port_config_handle: bad interfaceTag\n"); - return NULL; - } - - if (queue == UF_CONTROLLED_PORT_Q) { - port = &interfacePriv->controlled_data_port; - } else { - port = &interfacePriv->uncontrolled_data_port; - } - - if (!port->entries_in_use) { - unifi_trace(priv, UDBG5, "No port configurations, return Discard.\n"); - return NULL; - } - - /* If the port configuration is common for all destinations, return it. */ - if (port->overide_action == UF_DATA_PORT_OVERIDE) { - unifi_trace(priv, UDBG5, "Single port configuration (%d).\n", - port->port_cfg[0].port_action); - if (address) { - unifi_trace(priv, UDBG5, "addr[0] = %x, addr[1] = %x, addr[2] = %x, addr[3] = %x\n", address[0], address[1], address[2], address[3]); - } - return &port->port_cfg[0]; - } - - unifi_trace(priv, UDBG5, "Multiple port configurations.\n"); - - /* If multiple configurations exist.. */ - for (i = 0; i < UNIFI_MAX_CONNECTIONS; i++) { - /* .. go through the list and match the destination address. */ - if (port->port_cfg[i].in_use && - memcmp(address, port->port_cfg[i].mac_address.a, ETH_ALEN) == 0) { - /* Return the desired action. */ - return &port->port_cfg[i]; - } - } - - /* Could not find any information, return Open. */ - unifi_trace(priv, UDBG5, "port configuration not found, returning NULL (debug).\n"); - return NULL; -} /* uf_sme_port_config_handle */ - -void -uf_multicast_list_wq(struct work_struct *work) -{ - unifi_priv_t *priv = container_of(work, unifi_priv_t, - multicast_list_task); - int i; - u16 interfaceTag = 0; - CsrWifiMacAddress* multicast_address_list = NULL; - int mc_count; - u8 *mc_list; - netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag]; - - if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) { - unifi_error(priv, "uf_multicast_list_wq: bad interfaceTag\n"); - return; - } - - unifi_trace(priv, UDBG5, - "uf_multicast_list_wq: list count = %d\n", - interfacePriv->mc_list_count); - - /* Flush the current list */ - CsrWifiRouterCtrlMulticastAddressIndSend(priv->CSR_WIFI_SME_IFACEQUEUE, 0, interfaceTag, CSR_WIFI_SME_LIST_ACTION_FLUSH, 0, NULL); - - mc_count = interfacePriv->mc_list_count; - mc_list = interfacePriv->mc_list; - /* - * Allocate a new list, need to free it later - * in unifi_mgt_multicast_address_cfm(). - */ - multicast_address_list = kmalloc(mc_count * sizeof(CsrWifiMacAddress), GFP_KERNEL); - - if (multicast_address_list == NULL) { - return; - } - - for (i = 0; i < mc_count; i++) { - memcpy(multicast_address_list[i].a, mc_list, ETH_ALEN); - mc_list += ETH_ALEN; - } - - if (priv->smepriv == NULL) { - kfree(multicast_address_list); - return; - } - - CsrWifiRouterCtrlMulticastAddressIndSend(priv->CSR_WIFI_SME_IFACEQUEUE, 0, - interfaceTag, - CSR_WIFI_SME_LIST_ACTION_ADD, - mc_count, multicast_address_list); - - /* The SME will take a copy of the addreses*/ - kfree(multicast_address_list); -} - - -int unifi_cfg_power(unifi_priv_t *priv, unsigned char *arg) -{ - unifi_cfg_power_t cfg_power; - int rc; - int wol; - - if (get_user(cfg_power, (unifi_cfg_power_t*)(((unifi_cfg_command_t*)arg) + 1))) { - unifi_error(priv, "UNIFI_CFG: Failed to get the argument\n"); - return -EFAULT; - } - - switch (cfg_power) { - case UNIFI_CFG_POWER_OFF: - priv->wol_suspend = (enable_wol == UNIFI_WOL_OFF) ? FALSE : TRUE; - rc = sme_sys_suspend(priv); - if (rc) { - return rc; - } - break; - case UNIFI_CFG_POWER_ON: - wol = priv->wol_suspend; - rc = sme_sys_resume(priv); - if (rc) { - return rc; - } - if (wol) { - /* Kick the BH to ensure pending transfers are handled when - * a suspend happened with card powered. - */ - unifi_send_signal(priv->card, NULL, 0, NULL); - } - break; - default: - unifi_error(priv, "WIFI POWER: Unknown value.\n"); - return -EINVAL; - } - - return 0; -} - - -int unifi_cfg_power_save(unifi_priv_t *priv, unsigned char *arg) -{ - unifi_cfg_powersave_t cfg_power_save; - CsrWifiSmePowerConfig powerConfig; - int rc; - - if (get_user(cfg_power_save, (unifi_cfg_powersave_t*)(((unifi_cfg_command_t*)arg) + 1))) { - unifi_error(priv, "UNIFI_CFG: Failed to get the argument\n"); - return -EFAULT; - } - - /* Get the coex info from the SME */ - rc = sme_mgt_power_config_get(priv, &powerConfig); - if (rc) { - unifi_error(priv, "UNIFI_CFG: Get unifi_PowerConfigValue failed.\n"); - return rc; - } - - switch (cfg_power_save) { - case UNIFI_CFG_POWERSAVE_NONE: - powerConfig.powerSaveLevel = CSR_WIFI_SME_POWER_SAVE_LEVEL_LOW; - break; - case UNIFI_CFG_POWERSAVE_FAST: - powerConfig.powerSaveLevel = CSR_WIFI_SME_POWER_SAVE_LEVEL_MED; - break; - case UNIFI_CFG_POWERSAVE_FULL: - powerConfig.powerSaveLevel = CSR_WIFI_SME_POWER_SAVE_LEVEL_HIGH; - break; - case UNIFI_CFG_POWERSAVE_AUTO: - powerConfig.powerSaveLevel = CSR_WIFI_SME_POWER_SAVE_LEVEL_AUTO; - break; - default: - unifi_error(priv, "POWERSAVE: Unknown value.\n"); - return -EINVAL; - } - - rc = sme_mgt_power_config_set(priv, &powerConfig); - - if (rc) { - unifi_error(priv, "UNIFI_CFG: Set unifi_PowerConfigValue failed.\n"); - } - - return rc; -} - - -int unifi_cfg_power_supply(unifi_priv_t *priv, unsigned char *arg) -{ - unifi_cfg_powersupply_t cfg_power_supply; - CsrWifiSmeHostConfig hostConfig; - int rc; - - if (get_user(cfg_power_supply, (unifi_cfg_powersupply_t*)(((unifi_cfg_command_t*)arg) + 1))) { - unifi_error(priv, "UNIFI_CFG: Failed to get the argument\n"); - return -EFAULT; - } - - /* Get the coex info from the SME */ - rc = sme_mgt_host_config_get(priv, &hostConfig); - if (rc) { - unifi_error(priv, "UNIFI_CFG: Get unifi_HostConfigValue failed.\n"); - return rc; - } - - switch (cfg_power_supply) { - case UNIFI_CFG_POWERSUPPLY_MAINS: - hostConfig.powerMode = CSR_WIFI_SME_HOST_POWER_MODE_ACTIVE; - break; - case UNIFI_CFG_POWERSUPPLY_BATTERIES: - hostConfig.powerMode = CSR_WIFI_SME_HOST_POWER_MODE_POWER_SAVE; - break; - default: - unifi_error(priv, "POWERSUPPLY: Unknown value.\n"); - return -EINVAL; - } - - rc = sme_mgt_host_config_set(priv, &hostConfig); - if (rc) { - unifi_error(priv, "UNIFI_CFG: Set unifi_HostConfigValue failed.\n"); - } - - return rc; -} - - -int unifi_cfg_packet_filters(unifi_priv_t *priv, unsigned char *arg) -{ - unsigned char *tclas_buffer; - unsigned int tclas_buffer_length; - tclas_t *dhcp_tclas; - int rc; - - /* Free any TCLASs previously allocated */ - if (priv->packet_filters.tclas_ies_length) { - kfree(priv->filter_tclas_ies); - priv->filter_tclas_ies = NULL; - } - - tclas_buffer = ((unsigned char*)arg) + sizeof(unifi_cfg_command_t) + sizeof(unsigned int); - if (copy_from_user(&priv->packet_filters, (void*)tclas_buffer, - sizeof(uf_cfg_bcast_packet_filter_t))) { - unifi_error(priv, "UNIFI_CFG: Failed to get the filter struct\n"); - return -EFAULT; - } - - tclas_buffer_length = priv->packet_filters.tclas_ies_length; - - /* Allocate TCLASs if necessary */ - if (priv->packet_filters.dhcp_filter) { - priv->packet_filters.tclas_ies_length += sizeof(tclas_t); - } - if (priv->packet_filters.tclas_ies_length > 0) { - priv->filter_tclas_ies = kmalloc(priv->packet_filters.tclas_ies_length, GFP_KERNEL); - if (priv->filter_tclas_ies == NULL) { - return -ENOMEM; - } - if (tclas_buffer_length) { - tclas_buffer += sizeof(uf_cfg_bcast_packet_filter_t) - sizeof(unsigned char*); - if (copy_from_user(priv->filter_tclas_ies, - tclas_buffer, - tclas_buffer_length)) { - unifi_error(priv, "UNIFI_CFG: Failed to get the TCLAS buffer\n"); - return -EFAULT; - } - } - } - - if(priv->packet_filters.dhcp_filter) - { - /* Append the DHCP tclas IE */ - dhcp_tclas = (tclas_t*)(priv->filter_tclas_ies + tclas_buffer_length); - memset(dhcp_tclas, 0, sizeof(tclas_t)); - dhcp_tclas->element_id = 14; - dhcp_tclas->length = sizeof(tcpip_clsfr_t) + 1; - dhcp_tclas->user_priority = 0; - dhcp_tclas->tcp_ip_cls_fr.cls_fr_type = 1; - dhcp_tclas->tcp_ip_cls_fr.version = 4; - ((u8*)(&dhcp_tclas->tcp_ip_cls_fr.source_port))[0] = 0x00; - ((u8*)(&dhcp_tclas->tcp_ip_cls_fr.source_port))[1] = 0x44; - ((u8*)(&dhcp_tclas->tcp_ip_cls_fr.dest_port))[0] = 0x00; - ((u8*)(&dhcp_tclas->tcp_ip_cls_fr.dest_port))[1] = 0x43; - dhcp_tclas->tcp_ip_cls_fr.protocol = 0x11; - dhcp_tclas->tcp_ip_cls_fr.cls_fr_mask = 0x58; //bits: 3,4,6 - } - - rc = sme_mgt_packet_filter_set(priv); - - return rc; -} - - -int unifi_cfg_wmm_qos_info(unifi_priv_t *priv, unsigned char *arg) -{ - u8 wmm_qos_info; - int rc = 0; - - if (get_user(wmm_qos_info, (u8*)(((unifi_cfg_command_t*)arg) + 1))) { - unifi_error(priv, "UNIFI_CFG: Failed to get the argument\n"); - return -EFAULT; - } - - /* Store the value in the connection info */ - priv->connection_config.wmmQosInfo = wmm_qos_info; - - return rc; -} - - -int unifi_cfg_wmm_addts(unifi_priv_t *priv, unsigned char *arg) -{ - u32 addts_tid; - u8 addts_ie_length; - u8 *addts_ie; - u8 *addts_params; - CsrWifiSmeDataBlock tspec; - CsrWifiSmeDataBlock tclas; - int rc; - - addts_params = (u8*)(((unifi_cfg_command_t*)arg) + 1); - if (get_user(addts_tid, (u32*)addts_params)) { - unifi_error(priv, "unifi_cfg_wmm_addts: Failed to get the argument\n"); - return -EFAULT; - } - - addts_params += sizeof(u32); - if (get_user(addts_ie_length, (u8*)addts_params)) { - unifi_error(priv, "unifi_cfg_wmm_addts: Failed to get the argument\n"); - return -EFAULT; - } - - unifi_trace(priv, UDBG4, "addts: tid = 0x%x ie_length = %d\n", - addts_tid, addts_ie_length); - - addts_ie = kmalloc(addts_ie_length, GFP_KERNEL); - if (addts_ie == NULL) { - unifi_error(priv, - "unifi_cfg_wmm_addts: Failed to malloc %d bytes for addts_ie buffer\n", - addts_ie_length); - return -ENOMEM; - } - - addts_params += sizeof(u8); - rc = copy_from_user(addts_ie, addts_params, addts_ie_length); - if (rc) { - unifi_error(priv, "unifi_cfg_wmm_addts: Failed to get the addts buffer\n"); - kfree(addts_ie); - return -EFAULT; - } - - tspec.data = addts_ie; - tspec.length = addts_ie_length; - tclas.data = NULL; - tclas.length = 0; - - rc = sme_mgt_tspec(priv, CSR_WIFI_SME_LIST_ACTION_ADD, addts_tid, - &tspec, &tclas); - - kfree(addts_ie); - return rc; -} - - -int unifi_cfg_wmm_delts(unifi_priv_t *priv, unsigned char *arg) -{ - u32 delts_tid; - u8 *delts_params; - CsrWifiSmeDataBlock tspec; - CsrWifiSmeDataBlock tclas; - int rc; - - delts_params = (u8*)(((unifi_cfg_command_t*)arg) + 1); - if (get_user(delts_tid, (u32*)delts_params)) { - unifi_error(priv, "unifi_cfg_wmm_delts: Failed to get the argument\n"); - return -EFAULT; - } - - unifi_trace(priv, UDBG4, "delts: tid = 0x%x\n", delts_tid); - - tspec.data = tclas.data = NULL; - tspec.length = tclas.length = 0; - - rc = sme_mgt_tspec(priv, CSR_WIFI_SME_LIST_ACTION_REMOVE, delts_tid, - &tspec, &tclas); - - return rc; -} - -int unifi_cfg_strict_draft_n(unifi_priv_t *priv, unsigned char *arg) -{ - u8 strict_draft_n; - u8 *strict_draft_n_params; - int rc; - - CsrWifiSmeStaConfig staConfig; - CsrWifiSmeDeviceConfig deviceConfig; - - strict_draft_n_params = (u8*)(((unifi_cfg_command_t*)arg) + 1); - if (get_user(strict_draft_n, (u8*)strict_draft_n_params)) { - unifi_error(priv, "unifi_cfg_strict_draft_n: Failed to get the argument\n"); - return -EFAULT; - } - - unifi_trace(priv, UDBG4, "strict_draft_n: = %s\n", ((strict_draft_n) ? "yes":"no")); - - rc = sme_mgt_sme_config_get(priv, &staConfig, &deviceConfig); - - if (rc) { - unifi_warning(priv, "unifi_cfg_strict_draft_n: Get unifi_SMEConfigValue failed.\n"); - return -EFAULT; - } - - deviceConfig.enableStrictDraftN = strict_draft_n; - - rc = sme_mgt_sme_config_set(priv, &staConfig, &deviceConfig); - if (rc) { - unifi_warning(priv, "unifi_cfg_strict_draft_n: Set unifi_SMEConfigValue failed.\n"); - rc = -EFAULT; - } - - return rc; -} - - -int unifi_cfg_enable_okc(unifi_priv_t *priv, unsigned char *arg) -{ - u8 enable_okc; - u8 *enable_okc_params; - int rc; - - CsrWifiSmeStaConfig staConfig; - CsrWifiSmeDeviceConfig deviceConfig; - - enable_okc_params = (u8*)(((unifi_cfg_command_t*)arg) + 1); - if (get_user(enable_okc, (u8*)enable_okc_params)) { - unifi_error(priv, "unifi_cfg_enable_okc: Failed to get the argument\n"); - return -EFAULT; - } - - unifi_trace(priv, UDBG4, "enable_okc: = %s\n", ((enable_okc) ? "yes":"no")); - - rc = sme_mgt_sme_config_get(priv, &staConfig, &deviceConfig); - if (rc) { - unifi_warning(priv, "unifi_cfg_enable_okc: Get unifi_SMEConfigValue failed.\n"); - return -EFAULT; - } - - staConfig.enableOpportunisticKeyCaching = enable_okc; - - rc = sme_mgt_sme_config_set(priv, &staConfig, &deviceConfig); - if (rc) { - unifi_warning(priv, "unifi_cfg_enable_okc: Set unifi_SMEConfigValue failed.\n"); - rc = -EFAULT; - } - - return rc; -} - - -int unifi_cfg_get_info(unifi_priv_t *priv, unsigned char *arg) -{ - unifi_cfg_get_t get_cmd; - char inst_name[IFNAMSIZ]; - int rc; - - if (get_user(get_cmd, (unifi_cfg_get_t*)(((unifi_cfg_command_t*)arg) + 1))) { - unifi_error(priv, "UNIFI_CFG: Failed to get the argument\n"); - return -EFAULT; - } - - switch (get_cmd) { - case UNIFI_CFG_GET_COEX: - { - CsrWifiSmeCoexInfo coexInfo; - /* Get the coex info from the SME */ - rc = sme_mgt_coex_info_get(priv, &coexInfo); - if (rc) { - unifi_error(priv, "UNIFI_CFG: Get unifi_CoexInfoValue failed.\n"); - return rc; - } - - /* Copy the info to the out buffer */ - if (copy_to_user((void*)arg, - &coexInfo, - sizeof(CsrWifiSmeCoexInfo))) { - unifi_error(priv, "UNIFI_CFG: Failed to copy the coex info\n"); - return -EFAULT; - } - break; - } - case UNIFI_CFG_GET_POWER_MODE: - { - CsrWifiSmePowerConfig powerConfig; - rc = sme_mgt_power_config_get(priv, &powerConfig); - if (rc) { - unifi_error(priv, "UNIFI_CFG: Get unifi_PowerConfigValue failed.\n"); - return rc; - } - - /* Copy the info to the out buffer */ - if (copy_to_user((void*)arg, - &powerConfig.powerSaveLevel, - sizeof(CsrWifiSmePowerSaveLevel))) { - unifi_error(priv, "UNIFI_CFG: Failed to copy the power save info\n"); - return -EFAULT; - } - break; - } - case UNIFI_CFG_GET_POWER_SUPPLY: - { - CsrWifiSmeHostConfig hostConfig; - rc = sme_mgt_host_config_get(priv, &hostConfig); - if (rc) { - unifi_error(priv, "UNIFI_CFG: Get unifi_HostConfigValue failed.\n"); - return rc; - } - - /* Copy the info to the out buffer */ - if (copy_to_user((void*)arg, - &hostConfig.powerMode, - sizeof(CsrWifiSmeHostPowerMode))) { - unifi_error(priv, "UNIFI_CFG: Failed to copy the host power mode\n"); - return -EFAULT; - } - break; - } - case UNIFI_CFG_GET_VERSIONS: - break; - case UNIFI_CFG_GET_INSTANCE: - { - u16 InterfaceId=0; - uf_net_get_name(priv->netdev[InterfaceId], &inst_name[0], sizeof(inst_name)); - - /* Copy the info to the out buffer */ - if (copy_to_user((void*)arg, - &inst_name[0], - sizeof(inst_name))) { - unifi_error(priv, "UNIFI_CFG: Failed to copy the instance name\n"); - return -EFAULT; - } - } - break; - - case UNIFI_CFG_GET_AP_CONFIG: - { -#ifdef CSR_SUPPORT_WEXT_AP - uf_cfg_ap_config_t cfg_ap_config; - - memset(&cfg_ap_config, 0, sizeof(cfg_ap_config)); - cfg_ap_config.channel = priv->ap_config.channel; - cfg_ap_config.beaconInterval = priv->ap_mac_config.beaconInterval; - cfg_ap_config.wmmEnabled = priv->ap_mac_config.wmmEnabled; - cfg_ap_config.dtimPeriod = priv->ap_mac_config.dtimPeriod; - cfg_ap_config.phySupportedBitmap = priv->ap_mac_config.phySupportedBitmap; - if (copy_to_user((void*)arg, - &cfg_ap_config, - sizeof(uf_cfg_ap_config_t))) { - unifi_error(priv, "UNIFI_CFG: Failed to copy the AP configuration\n"); - return -EFAULT; - } -#else - return -EPERM; -#endif - } - break; - - - default: - unifi_error(priv, "unifi_cfg_get_info: Unknown value.\n"); - return -EINVAL; - } - - return 0; -} -#ifdef CSR_SUPPORT_WEXT_AP -int - uf_configure_supported_rates(u8 * supportedRates, u8 phySupportedBitmap) -{ - int i=0; - u8 b=FALSE, g = FALSE, n = FALSE; - b = phySupportedBitmap & CSR_WIFI_SME_AP_PHY_SUPPORT_B; - n = phySupportedBitmap & CSR_WIFI_SME_AP_PHY_SUPPORT_N; - g = phySupportedBitmap & CSR_WIFI_SME_AP_PHY_SUPPORT_G; - if(b || g) { - supportedRates[i++]=0x82; - supportedRates[i++]=0x84; - supportedRates[i++]=0x8b; - supportedRates[i++]=0x96; - } else if(n) { - /* For some strange reasons WiFi stack needs both b and g rates*/ - supportedRates[i++]=0x02; - supportedRates[i++]=0x04; - supportedRates[i++]=0x0b; - supportedRates[i++]=0x16; - supportedRates[i++]=0x0c; - supportedRates[i++]=0x12; - supportedRates[i++]=0x18; - supportedRates[i++]=0x24; - supportedRates[i++]=0x30; - supportedRates[i++]=0x48; - supportedRates[i++]=0x60; - supportedRates[i++]=0x6c; - } - if(g) { - if(!b) { - supportedRates[i++]=0x8c; - supportedRates[i++]=0x98; - supportedRates[i++]=0xb0; - } else { - supportedRates[i++]=0x0c; - supportedRates[i++]=0x18; - supportedRates[i++]=0x30; - } - supportedRates[i++]=0x48; - supportedRates[i++]=0x12; - supportedRates[i++]=0x24; - supportedRates[i++]=0x60; - supportedRates[i++]=0x6c; - } - return i; -} -int unifi_cfg_set_ap_config(unifi_priv_t * priv, unsigned char* arg) -{ - uf_cfg_ap_config_t cfg_ap_config; - char *buffer; - - buffer = ((unsigned char*)arg) + sizeof(unifi_cfg_command_t) + sizeof(unsigned int); - if (copy_from_user(&cfg_ap_config, (void*)buffer, - sizeof(uf_cfg_ap_config_t))) { - unifi_error(priv, "UNIFI_CFG: Failed to get the ap config struct\n"); - return -EFAULT; - } - priv->ap_config.channel = cfg_ap_config.channel; - priv->ap_mac_config.dtimPeriod = cfg_ap_config.dtimPeriod; - priv->ap_mac_config.beaconInterval = cfg_ap_config.beaconInterval; - priv->group_sec_config.apGroupkeyTimeout = cfg_ap_config.groupkeyTimeout; - priv->group_sec_config.apStrictGtkRekey = cfg_ap_config.strictGtkRekeyEnabled; - priv->group_sec_config.apGmkTimeout = cfg_ap_config.gmkTimeout; - priv->group_sec_config.apResponseTimeout = cfg_ap_config.responseTimeout; - priv->group_sec_config.apRetransLimit = cfg_ap_config.retransLimit; - - priv->ap_mac_config.shortSlotTimeEnabled = cfg_ap_config.shortSlotTimeEnabled; - priv->ap_mac_config.ctsProtectionType=cfg_ap_config.ctsProtectionType; - - priv->ap_mac_config.wmmEnabled = cfg_ap_config.wmmEnabled; - - priv->ap_mac_config.apHtParams.rxStbc=cfg_ap_config.rxStbc; - priv->ap_mac_config.apHtParams.rifsModeAllowed=cfg_ap_config.rifsModeAllowed; - - priv->ap_mac_config.phySupportedBitmap = cfg_ap_config.phySupportedBitmap; - priv->ap_mac_config.maxListenInterval=cfg_ap_config.maxListenInterval; - - priv->ap_mac_config.supportedRatesCount= uf_configure_supported_rates(priv->ap_mac_config.supportedRates, priv->ap_mac_config.phySupportedBitmap); - - return 0; -} - -#endif -#ifdef CSR_SUPPORT_WEXT - - void -uf_sme_config_wq(struct work_struct *work) -{ - CsrWifiSmeStaConfig staConfig; - CsrWifiSmeDeviceConfig deviceConfig; - unifi_priv_t *priv = container_of(work, unifi_priv_t, sme_config_task); - - /* Register to receive indications from the SME */ - CsrWifiSmeEventMaskSetReqSend(0, - CSR_WIFI_SME_INDICATIONS_WIFIOFF | CSR_WIFI_SME_INDICATIONS_CONNECTIONQUALITY | - CSR_WIFI_SME_INDICATIONS_MEDIASTATUS | CSR_WIFI_SME_INDICATIONS_MICFAILURE); - - if (sme_mgt_sme_config_get(priv, &staConfig, &deviceConfig)) { - unifi_warning(priv, "uf_sme_config_wq: Get unifi_SMEConfigValue failed.\n"); - return; - } - - if (priv->if_index == CSR_INDEX_5G) { - staConfig.ifIndex = CSR_WIFI_SME_RADIO_IF_GHZ_5_0; - } else { - staConfig.ifIndex = CSR_WIFI_SME_RADIO_IF_GHZ_2_4; - } - - deviceConfig.trustLevel = (CsrWifiSme80211dTrustLevel)tl_80211d; - if (sme_mgt_sme_config_set(priv, &staConfig, &deviceConfig)) { - unifi_warning(priv, - "SME config for 802.11d Trust Level and Radio Band failed.\n"); - return; - } - -} /* uf_sme_config_wq() */ - -#endif /* CSR_SUPPORT_WEXT */ - - -/* - * --------------------------------------------------------------------------- - * uf_ta_ind_wq - * - * Deferred work queue function to send Traffic Analysis protocols - * indications to the SME. - * These are done in a deferred work queue for two reasons: - * - the CsrWifiRouterCtrl...Send() functions are not safe for atomic context - * - we want to load the main driver data path as lightly as possible - * - * The TA classifications already come from a workqueue. - * - * Arguments: - * work Pointer to work queue item. - * - * Returns: - * None. - * --------------------------------------------------------------------------- - */ - void -uf_ta_ind_wq(struct work_struct *work) -{ - struct ta_ind *ind = container_of(work, struct ta_ind, task); - unifi_priv_t *priv = container_of(ind, unifi_priv_t, ta_ind_work); - u16 interfaceTag = 0; - - - CsrWifiRouterCtrlTrafficProtocolIndSend(priv->CSR_WIFI_SME_IFACEQUEUE, 0, - interfaceTag, - ind->packet_type, - ind->direction, - ind->src_addr); - ind->in_use = 0; - -} /* uf_ta_ind_wq() */ - - -/* - * --------------------------------------------------------------------------- - * uf_ta_sample_ind_wq - * - * Deferred work queue function to send Traffic Analysis sample - * indications to the SME. - * These are done in a deferred work queue for two reasons: - * - the CsrWifiRouterCtrl...Send() functions are not safe for atomic context - * - we want to load the main driver data path as lightly as possible - * - * The TA classifications already come from a workqueue. - * - * Arguments: - * work Pointer to work queue item. - * - * Returns: - * None. - * --------------------------------------------------------------------------- - */ - void -uf_ta_sample_ind_wq(struct work_struct *work) -{ - struct ta_sample_ind *ind = container_of(work, struct ta_sample_ind, task); - unifi_priv_t *priv = container_of(ind, unifi_priv_t, ta_sample_ind_work); - u16 interfaceTag = 0; - - unifi_trace(priv, UDBG5, "rxtcp %d txtcp %d rxudp %d txudp %d prio %d\n", - priv->rxTcpThroughput, - priv->txTcpThroughput, - priv->rxUdpThroughput, - priv->txUdpThroughput, - priv->bh_thread.prio); - - if(priv->rxTcpThroughput > 1000) - { - if (bh_priority == -1 && priv->bh_thread.prio != 1) - { - struct sched_param param; - priv->bh_thread.prio = 1; - unifi_trace(priv, UDBG1, "%s new thread (RT) priority = %d\n", - priv->bh_thread.name, priv->bh_thread.prio); - param.sched_priority = priv->bh_thread.prio; - sched_setscheduler(priv->bh_thread.thread_task, SCHED_FIFO, ¶m); - } - } else - { - if (bh_priority == -1 && priv->bh_thread.prio != DEFAULT_PRIO) - { - struct sched_param param; - param.sched_priority = 0; - sched_setscheduler(priv->bh_thread.thread_task, SCHED_NORMAL, ¶m); - priv->bh_thread.prio = DEFAULT_PRIO; - unifi_trace(priv, UDBG1, "%s new thread priority = %d\n", - priv->bh_thread.name, priv->bh_thread.prio); - set_user_nice(priv->bh_thread.thread_task, PRIO_TO_NICE(priv->bh_thread.prio)); - } - } - - CsrWifiRouterCtrlTrafficSampleIndSend(priv->CSR_WIFI_SME_IFACEQUEUE, 0, interfaceTag, ind->stats); - - ind->in_use = 0; - -} /* uf_ta_sample_ind_wq() */ - - -/* - * --------------------------------------------------------------------------- - * uf_send_m4_ready_wq - * - * Deferred work queue function to send M4 ReadyToSend inds to the SME. - * These are done in a deferred work queue for two reasons: - * - the CsrWifiRouterCtrl...Send() functions are not safe for atomic context - * - we want to load the main driver data path as lightly as possible - * - * Arguments: - * work Pointer to work queue item. - * - * Returns: - * None. - * --------------------------------------------------------------------------- - */ -void -uf_send_m4_ready_wq(struct work_struct *work) -{ - netInterface_priv_t *InterfacePriv = container_of(work, netInterface_priv_t, send_m4_ready_task); - u16 iface = InterfacePriv->InterfaceTag; - unifi_priv_t *priv = InterfacePriv->privPtr; - CSR_MA_PACKET_REQUEST *req = &InterfacePriv->m4_signal.u.MaPacketRequest; - CsrWifiMacAddress peer; - unsigned long flags; - - /* The peer address was stored in the signal */ - spin_lock_irqsave(&priv->m4_lock, flags); - memcpy(peer.a, req->Ra.x, sizeof(peer.a)); - spin_unlock_irqrestore(&priv->m4_lock, flags); - - /* Send a signal to SME */ - CsrWifiRouterCtrlM4ReadyToSendIndSend(priv->CSR_WIFI_SME_IFACEQUEUE, 0, iface, peer); - - unifi_trace(priv, UDBG1, "M4ReadyToSendInd sent for peer %pMF\n", - peer.a); - -} /* uf_send_m4_ready_wq() */ - -#if (defined(CSR_WIFI_SECURITY_WAPI_ENABLE) && defined(CSR_WIFI_SECURITY_WAPI_SW_ENCRYPTION)) -/* - * --------------------------------------------------------------------------- - * uf_send_pkt_to_encrypt - * - * Deferred work queue function to send the WAPI data pkts to SME when unicast KeyId = 1 - * These are done in a deferred work queue for two reasons: - * - the CsrWifiRouterCtrl...Send() functions are not safe for atomic context - * - we want to load the main driver data path as lightly as possible - * - * Arguments: - * work Pointer to work queue item. - * - * Returns: - * None. - * --------------------------------------------------------------------------- - */ -void uf_send_pkt_to_encrypt(struct work_struct *work) -{ - netInterface_priv_t *interfacePriv = container_of(work, netInterface_priv_t, send_pkt_to_encrypt); - u16 interfaceTag = interfacePriv->InterfaceTag; - unifi_priv_t *priv = interfacePriv->privPtr; - - u32 pktBulkDataLength; - u8 *pktBulkData; - unsigned long flags; - - if (interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_STA) { - - pktBulkDataLength = interfacePriv->wapi_unicast_bulk_data.data_length; - - if (pktBulkDataLength > 0) { - pktBulkData = kmalloc(pktBulkDataLength, GFP_KERNEL); - } else { - unifi_error(priv, "uf_send_pkt_to_encrypt() : invalid buffer\n"); - return; - } - - spin_lock_irqsave(&priv->wapi_lock, flags); - /* Copy over the MA PKT REQ bulk data */ - memcpy(pktBulkData, (u8*)interfacePriv->wapi_unicast_bulk_data.os_data_ptr, pktBulkDataLength); - /* Free any bulk data buffers allocated for the WAPI Data pkt */ - unifi_net_data_free(priv, &interfacePriv->wapi_unicast_bulk_data); - interfacePriv->wapi_unicast_bulk_data.net_buf_length = 0; - interfacePriv->wapi_unicast_bulk_data.data_length = 0; - interfacePriv->wapi_unicast_bulk_data.os_data_ptr = interfacePriv->wapi_unicast_bulk_data.os_net_buf_ptr = NULL; - spin_unlock_irqrestore(&priv->wapi_lock, flags); - - CsrWifiRouterCtrlWapiUnicastTxEncryptIndSend(priv->CSR_WIFI_SME_IFACEQUEUE, 0, interfaceTag, pktBulkDataLength, pktBulkData); - unifi_trace(priv, UDBG1, "WapiUnicastTxEncryptInd sent to SME\n"); - - kfree(pktBulkData); /* Would have been copied over by the SME Handler */ - - } else { - unifi_warning(priv, "uf_send_pkt_to_encrypt() is NOT applicable for interface mode - %d\n", interfacePriv->interfaceMode); - } -}/* uf_send_pkt_to_encrypt() */ -#endif diff --git a/drivers/staging/csr/unifi_sme.h b/drivers/staging/csr/unifi_sme.h deleted file mode 100644 index aff9aa178124..000000000000 --- a/drivers/staging/csr/unifi_sme.h +++ /dev/null @@ -1,245 +0,0 @@ -/* - * *************************************************************************** - * FILE: unifi_sme.h - * - * PURPOSE: SME related definitions. - * - * Copyright (C) 2007-2011 by Cambridge Silicon Radio Ltd. - * - * Refer to LICENSE.txt included with this source code for details on - * the license terms. - * - * *************************************************************************** - */ -#ifndef __LINUX_UNIFI_SME_H__ -#define __LINUX_UNIFI_SME_H__ 1 - -#include - -#ifdef CSR_SME_USERSPACE -#include "sme_userspace.h" -#endif - -#include "csr_wifi_sme_lib.h" - -typedef int unifi_data_port_action; - -typedef struct unifi_port_cfg -{ - /* TRUE if this port entry is allocated */ - u8 in_use; - CsrWifiRouterCtrlPortAction port_action; - CsrWifiMacAddress mac_address; -} unifi_port_cfg_t; - -#define UNIFI_MAX_CONNECTIONS 8 -#define UNIFI_MAX_RETRY_LIMIT 5 -#define UF_DATA_PORT_NOT_OVERIDE 0 -#define UF_DATA_PORT_OVERIDE 1 - -typedef struct unifi_port_config -{ - int entries_in_use; - int overide_action; - unifi_port_cfg_t port_cfg[UNIFI_MAX_CONNECTIONS]; -} unifi_port_config_t; - - -enum sme_request_status { - SME_REQUEST_EMPTY, - SME_REQUEST_PENDING, - SME_REQUEST_RECEIVED, - SME_REQUEST_TIMEDOUT, - SME_REQUEST_CANCELLED, -}; - -/* Structure to hold a UDI logged signal */ -typedef struct { - - /* The current status of the request */ - enum sme_request_status request_status; - - /* The status the SME has passed to us */ - CsrResult reply_status; - - /* SME's reply to a get request */ - CsrWifiSmeVersions versions; - CsrWifiSmePowerConfig powerConfig; - CsrWifiSmeHostConfig hostConfig; - CsrWifiSmeStaConfig staConfig; - CsrWifiSmeDeviceConfig deviceConfig; - CsrWifiSmeCoexInfo coexInfo; - CsrWifiSmeCoexConfig coexConfig; - CsrWifiSmeMibConfig mibConfig; - CsrWifiSmeConnectionInfo connectionInfo; - CsrWifiSmeConnectionConfig connectionConfig; - CsrWifiSmeConnectionStats connectionStats; - - - /* SME's reply to a scan request */ - u16 reply_scan_results_count; - CsrWifiSmeScanResult* reply_scan_results; - -} sme_reply_t; - - -typedef struct { - u16 appHandle; - CsrWifiRouterEncapsulation encapsulation; - u16 protocol; - u8 oui[3]; - u8 in_use; -} sme_ma_unidata_ind_filter_t; - - -CsrWifiRouterCtrlPortAction uf_sme_port_state(unifi_priv_t *priv, - unsigned char *address, - int queue, - u16 interfaceTag); -unifi_port_cfg_t *uf_sme_port_config_handle(unifi_priv_t *priv, - unsigned char *address, - int queue, - u16 interfaceTag); - - - -/* Callback for event logging to SME clients */ -void sme_log_event(ul_client_t *client, const u8 *signal, int signal_len, - const bulk_data_param_t *bulkdata, int dir); - -/* The workqueue task to the set the multicast addresses list */ -void uf_multicast_list_wq(struct work_struct *work); - -/* The workqueue task to execute the TA module */ -void uf_ta_wq(struct work_struct *work); - - -/* - * SME blocking helper functions - */ -#ifdef UNIFI_DEBUG -# define sme_complete_request(priv, status) uf_sme_complete_request(priv, status, __func__) -#else -# define sme_complete_request(priv, status) uf_sme_complete_request(priv, status, NULL) -#endif - -void uf_sme_complete_request(unifi_priv_t *priv, CsrResult reply_status, const char *func); -void uf_sme_cancel_request(unifi_priv_t *priv, CsrResult reply_status); - - -/* - * Blocking functions using the SME SYS API. - */ -int sme_sys_suspend(unifi_priv_t *priv); -int sme_sys_resume(unifi_priv_t *priv); - - -/* - * Traffic Analysis workqueue jobs - */ -void uf_ta_ind_wq(struct work_struct *work); -void uf_ta_sample_ind_wq(struct work_struct *work); - -/* - * SME config workqueue job - */ -void uf_sme_config_wq(struct work_struct *work); - -/* - * To send M4 read to send IND - */ -void uf_send_m4_ready_wq(struct work_struct *work); - -#if (defined(CSR_WIFI_SECURITY_WAPI_ENABLE) && defined(CSR_WIFI_SECURITY_WAPI_SW_ENCRYPTION)) -/* - * To send data pkt to Sme for encryption - */ -void uf_send_pkt_to_encrypt(struct work_struct *work); -#endif - -int sme_mgt_power_config_set(unifi_priv_t *priv, CsrWifiSmePowerConfig *powerConfig); -int sme_mgt_power_config_get(unifi_priv_t *priv, CsrWifiSmePowerConfig *powerConfig); -int sme_mgt_host_config_set(unifi_priv_t *priv, CsrWifiSmeHostConfig *hostConfig); -int sme_mgt_host_config_get(unifi_priv_t *priv, CsrWifiSmeHostConfig *hostConfig); -int sme_mgt_sme_config_set(unifi_priv_t *priv, CsrWifiSmeStaConfig *staConfig, CsrWifiSmeDeviceConfig *deviceConfig); -int sme_mgt_sme_config_get(unifi_priv_t *priv, CsrWifiSmeStaConfig *staConfig, CsrWifiSmeDeviceConfig *deviceConfig); -int sme_mgt_coex_info_get(unifi_priv_t *priv, CsrWifiSmeCoexInfo *coexInfo); -int sme_mgt_packet_filter_set(unifi_priv_t *priv); -int sme_mgt_tspec(unifi_priv_t *priv, CsrWifiSmeListAction action, - u32 tid, CsrWifiSmeDataBlock *tspec, CsrWifiSmeDataBlock *tclas); - -#ifdef CSR_SUPPORT_WEXT -/* - * Blocking functions using the SME MGT API. - */ -int sme_mgt_wifi_on(unifi_priv_t *priv); -int sme_mgt_wifi_off(unifi_priv_t *priv); -/*int sme_mgt_set_value_async(unifi_priv_t *priv, unifi_AppValue *app_value); -int sme_mgt_get_value_async(unifi_priv_t *priv, unifi_AppValue *app_value); -int sme_mgt_get_value(unifi_priv_t *priv, unifi_AppValue *app_value); -int sme_mgt_set_value(unifi_priv_t *priv, unifi_AppValue *app_value); -*/ -int sme_mgt_coex_config_set(unifi_priv_t *priv, CsrWifiSmeCoexConfig *coexConfig); -int sme_mgt_coex_config_get(unifi_priv_t *priv, CsrWifiSmeCoexConfig *coexConfig); -int sme_mgt_mib_config_set(unifi_priv_t *priv, CsrWifiSmeMibConfig *mibConfig); -int sme_mgt_mib_config_get(unifi_priv_t *priv, CsrWifiSmeMibConfig *mibConfig); - -int sme_mgt_connection_info_set(unifi_priv_t *priv, CsrWifiSmeConnectionInfo *connectionInfo); -int sme_mgt_connection_info_get(unifi_priv_t *priv, CsrWifiSmeConnectionInfo *connectionInfo); -int sme_mgt_connection_config_set(unifi_priv_t *priv, CsrWifiSmeConnectionConfig *connectionConfig); -int sme_mgt_connection_config_get(unifi_priv_t *priv, CsrWifiSmeConnectionConfig *connectionConfig); -int sme_mgt_connection_stats_get(unifi_priv_t *priv, CsrWifiSmeConnectionStats *connectionStats); - -int sme_mgt_versions_get(unifi_priv_t *priv, CsrWifiSmeVersions *versions); - - -int sme_mgt_scan_full(unifi_priv_t *priv, CsrWifiSsid *specific_ssid, - int num_channels, unsigned char *channel_list); -int sme_mgt_scan_results_get_async(unifi_priv_t *priv, - struct iw_request_info *info, - char *scan_results, - long scan_results_len); -int sme_mgt_disconnect(unifi_priv_t *priv); -int sme_mgt_connect(unifi_priv_t *priv); -int sme_mgt_key(unifi_priv_t *priv, CsrWifiSmeKey *sme_key, - CsrWifiSmeListAction action); -int sme_mgt_pmkid(unifi_priv_t *priv, CsrWifiSmeListAction action, - CsrWifiSmePmkidList *pmkid_list); -int sme_mgt_mib_get(unifi_priv_t *priv, - unsigned char *varbind, int *length); -int sme_mgt_mib_set(unifi_priv_t *priv, - unsigned char *varbind, int length); -#ifdef CSR_SUPPORT_WEXT_AP -int sme_ap_start(unifi_priv_t *priv, u16 interface_tag, CsrWifiSmeApConfig_t *ap_config); -int sme_ap_stop(unifi_priv_t *priv, u16 interface_tag); -int sme_ap_config(unifi_priv_t *priv, CsrWifiSmeApMacConfig *ap_mac_config, CsrWifiNmeApConfig *group_security_config); -int uf_configure_supported_rates(u8 * supportedRates, u8 phySupportedBitmap); -#endif -int unifi_translate_scan(struct net_device *dev, - struct iw_request_info *info, - char *current_ev, char *end_buf, - CsrWifiSmeScanResult *scan_data, - int scan_index); - -#endif /* CSR_SUPPORT_WEXT */ - -int unifi_cfg_power(unifi_priv_t *priv, unsigned char *arg); -int unifi_cfg_power_save(unifi_priv_t *priv, unsigned char *arg); -int unifi_cfg_power_supply(unifi_priv_t *priv, unsigned char *arg); -int unifi_cfg_packet_filters(unifi_priv_t *priv, unsigned char *arg); -int unifi_cfg_wmm_qos_info(unifi_priv_t *priv, unsigned char *arg); -int unifi_cfg_wmm_addts(unifi_priv_t *priv, unsigned char *arg); -int unifi_cfg_wmm_delts(unifi_priv_t *priv, unsigned char *arg); -int unifi_cfg_get_info(unifi_priv_t *priv, unsigned char *arg); -int unifi_cfg_strict_draft_n(unifi_priv_t *priv, unsigned char *arg); -int unifi_cfg_enable_okc(unifi_priv_t *priv, unsigned char *arg); -#ifdef CSR_SUPPORT_WEXT_AP -int unifi_cfg_set_ap_config(unifi_priv_t * priv, unsigned char* arg); -#endif - - - -int convert_sme_error(CsrResult error); - - -#endif /* __LINUX_UNIFI_SME_H__ */ diff --git a/drivers/staging/csr/unifi_wext.h b/drivers/staging/csr/unifi_wext.h deleted file mode 100644 index beba089e2e35..000000000000 --- a/drivers/staging/csr/unifi_wext.h +++ /dev/null @@ -1,108 +0,0 @@ -/* - ***************************************************************************** - * - * FILE : unifi_wext.h - * - * PURPOSE : Private header file for unifi driver support to wireless extensions. - * - * Copyright (C) 2005-2008 by Cambridge Silicon Radio Ltd. - * - * Refer to LICENSE.txt included with this source code for details on - * the license terms. - * -***************************************************************************** - */ -#ifndef __LINUX_UNIFI_WEXT_H__ -#define __LINUX_UNIFI_WEXT_H__ 1 - -#include -#include -#include "csr_wifi_sme_prim.h" - -/* - * wext.c - */ -/* A few details needed for WEP (Wireless Equivalent Privacy) */ -#define UNIFI_MAX_KEY_SIZE 16 -#define NUM_WEPKEYS 4 -#define SMALL_KEY_SIZE 5 -#define LARGE_KEY_SIZE 13 -typedef struct wep_key_t { - int len; - unsigned char key[UNIFI_MAX_KEY_SIZE]; /* 40-bit and 104-bit keys */ -} wep_key_t; - -#define UNIFI_SCAN_ACTIVE 0 -#define UNIFI_SCAN_PASSIVE 1 -#define UNIFI_MAX_SSID_LEN 32 - -#define MAX_WPA_IE_LEN 64 -#define MAX_RSN_IE_LEN 255 - -/* - * Function to register in the netdev to report wireless stats. - */ -struct iw_statistics *unifi_get_wireless_stats(struct net_device *dev); - -void uf_sme_wext_set_defaults(unifi_priv_t *priv); - - -/* - * wext_events.c - */ -/* Functions to generate Wireless Extension events */ -void wext_send_scan_results_event(unifi_priv_t *priv); -void wext_send_assoc_event(unifi_priv_t *priv, unsigned char *bssid, - unsigned char *req_ie, int req_ie_len, - unsigned char *resp_ie, int resp_ie_len, - unsigned char *scan_ie, unsigned int scan_ie_len); -void wext_send_disassoc_event(unifi_priv_t *priv); -void wext_send_michaelmicfailure_event(unifi_priv_t *priv, - u16 count, CsrWifiMacAddress address, - CsrWifiSmeKeyType keyType, u16 interfaceTag); -void wext_send_pmkid_candidate_event(unifi_priv_t *priv, CsrWifiMacAddress bssid, u8 preauth_allowed, u16 interfaceTag); -void wext_send_started_event(unifi_priv_t *priv); - - -static inline int -uf_iwe_stream_add_point(struct iw_request_info *info, char *start, char *stop, - struct iw_event *piwe, char *extra) -{ - char *new_start; - - new_start = iwe_stream_add_point(info, start, stop, piwe, extra); - if (unlikely(new_start == start)) - return -E2BIG; - - return (new_start - start); -} - - -static inline int -uf_iwe_stream_add_event(struct iw_request_info *info, char *start, char *stop, - struct iw_event *piwe, int len) -{ - char *new_start; - - new_start = iwe_stream_add_event(info, start, stop, piwe, len); - if (unlikely(new_start == start)) - return -E2BIG; - - return (new_start - start); -} - -static inline int -uf_iwe_stream_add_value(struct iw_request_info *info, char *stream, char *start, - char *stop, struct iw_event *piwe, int len) -{ - char *new_start; - - new_start = iwe_stream_add_value(info, stream, start, stop, piwe, len); - if (unlikely(new_start == start)) - return -E2BIG; - - return (new_start - start); -} - - -#endif /* __LINUX_UNIFI_WEXT_H__ */ diff --git a/drivers/staging/csr/unifiio.h b/drivers/staging/csr/unifiio.h deleted file mode 100644 index b9de0cb94e9a..000000000000 --- a/drivers/staging/csr/unifiio.h +++ /dev/null @@ -1,398 +0,0 @@ -/* - * --------------------------------------------------------------------------- - * - * FILE: unifiio.h - * - * Public definitions for the UniFi linux driver. - * This is mostly ioctl command values and structs. - * - * Include or similar before this file - * - * Copyright (C) 2005-2009 by Cambridge Silicon Radio Ltd. - * - * Refer to LICENSE.txt included with this source code for details on - * the license terms. - * - * --------------------------------------------------------------------------- - */ -#ifndef __UNIFIIO_H__ -#define __UNIFIIO_H__ - -#include - -#define UNIFI_GET_UDI_ENABLE _IOR('u', 1, int) -#define UNIFI_SET_UDI_ENABLE _IOW('u', 2, int) -/* Values for UDI_ENABLE */ -#define UDI_ENABLE_DATA 0x1 -#define UDI_ENABLE_CONTROL 0x2 - -/* MIB set/get. Arg is a pointer to a varbind */ -#define UNIFI_GET_MIB _IOWR('u', 3, unsigned char *) -#define UNIFI_SET_MIB _IOW ('u', 4, unsigned char *) -#define MAX_VARBIND_LENGTH 127 - -/* Private IOCTLs */ -#define SIOCIWS80211POWERSAVEPRIV SIOCIWFIRSTPRIV -#define SIOCIWG80211POWERSAVEPRIV SIOCIWFIRSTPRIV + 1 -#define SIOCIWS80211RELOADDEFAULTSPRIV SIOCIWFIRSTPRIV + 2 -#define SIOCIWSCONFWAPIPRIV SIOCIWFIRSTPRIV + 4 -#define SIOCIWSWAPIKEYPRIV SIOCIWFIRSTPRIV + 6 -#define SIOCIWSSMEDEBUGPRIV SIOCIWFIRSTPRIV + 8 -#define SIOCIWSAPCFGPRIV SIOCIWFIRSTPRIV + 10 -#define SIOCIWSAPSTARTPRIV SIOCIWFIRSTPRIV + 12 -#define SIOCIWSAPSTOPPRIV SIOCIWFIRSTPRIV + 14 -#define SIOCIWSFWRELOADPRIV SIOCIWFIRSTPRIV + 16 -#define SIOCIWSSTACKSTART SIOCIWFIRSTPRIV + 18 -#define SIOCIWSSTACKSTOP SIOCIWFIRSTPRIV + 20 - - - -#define IWPRIV_POWER_SAVE_MAX_STRING 32 -#define IWPRIV_SME_DEBUG_MAX_STRING 32 -#define IWPRIV_SME_MAX_STRING 120 - - -/* Private configuration commands */ -#define UNIFI_CFG _IOWR('u', 5, unsigned char *) -/* - * <------------------ Read/Write Buffer --------------------> - * _____________________________________________________________ - * | Cmd | Arg | ... Buffer (opt) ... | - * ------------------------------------------------------------- - * <-- uint --><-- uint --><----- unsigned char buffer ------> - * - * Cmd: A unifi_cfg_command_t command. - * Arg: Out:Length if Cmd==UNIFI_CFG_GET - * In:PowerOnOff if Cmd==UNIFI_CFG_POWER - * In:PowerMode if Cmd==UNIFI_CFG_POWERSAVE - * In:Length if Cmd==UNIFI_CFG_FILTER - * In:WMM Qos Info if Cmd==UNIFI_CFG_WMM_QOS_INFO - * Buffer: Out:Data if Cmd==UNIFI_CFG_GET - * NULL if Cmd==UNIFI_CFG_POWER - * NULL if Cmd==UNIFI_CFG_POWERSAVE - * In:Filters if Cmd==UNIFI_CFG_FILTER - * - * where Filters is a uf_cfg_bcast_packet_filter_t structure - * followed by 0 - n tclas_t structures. The length of the tclas_t - * structures is obtained by uf_cfg_bcast_packet_filter_t::tclas_ies_length. - */ - - -#define UNIFI_PUTEST _IOWR('u', 6, unsigned char *) -/* - * <------------------ Read/Write Buffer --------------------> - * _____________________________________________________________ - * | Cmd | Arg | ... Buffer (opt) ... | - * ------------------------------------------------------------- - * <-- uint --><-- uint --><----- unsigned char buffer ------> - * - * Cmd: A unifi_putest_command_t command. - * Arg: N/A if Cmd==UNIFI_PUTEST_START - * N/A if Cmd==UNIFI_PUTEST_STOP - * In:int (Clock Speed) if Cmd==UNIFI_PUTEST_SET_SDIO_CLOCK - * In/Out:sizeof(unifi_putest_cmd52) if Cmd==UNIFI_PUTEST_CMD52_READ - * In:sizeof(unifi_putest_cmd52) if Cmd==UNIFI_PUTEST_CMD52_WRITE - * In:uint (f/w file name length) if Cmd==UNIFI_PUTEST_DL_FW - * Buffer: NULL if Cmd==UNIFI_PUTEST_START - * NULL if Cmd==UNIFI_PUTEST_STOP - * NULL if Cmd==UNIFI_PUTEST_SET_SDIO_CLOCK - * In/Out:unifi_putest_cmd52 if Cmd==UNIFI_PUTEST_CMD52_READ - * In:unifi_putest_cmd52 if Cmd==UNIFI_PUTEST_CMD52_WRITE - * In:f/w file name if Cmd==UNIFI_PUTEST_DL_FW - */ - -#define UNIFI_BUILD_TYPE _IOWR('u', 7, unsigned char) -#define UNIFI_BUILD_NME 1 -#define UNIFI_BUILD_WEXT 2 -#define UNIFI_BUILD_AP 3 - -/* debugging */ -#define UNIFI_KICK _IO ('u', 0x10) -#define UNIFI_SET_DEBUG _IO ('u', 0x11) -#define UNIFI_SET_TRACE _IO ('u', 0x12) - -#define UNIFI_GET_INIT_STATUS _IOR ('u', 0x15, int) -#define UNIFI_SET_UDI_LOG_MASK _IOR('u', 0x18, unifiio_filter_t) -#define UNIFI_SET_UDI_SNAP_MASK _IOW('u', 0x1a, unifiio_snap_filter_t) -#define UNIFI_SET_AMP_ENABLE _IOWR('u', 0x1b, int) - -#define UNIFI_INIT_HW _IOR ('u', 0x13, unsigned char) -#define UNIFI_INIT_NETDEV _IOW ('u', 0x14, unsigned char[6]) -#define UNIFI_SME_PRESENT _IOW ('u', 0x19, int) - -#define UNIFI_CFG_PERIOD_TRAFFIC _IOW ('u', 0x21, unsigned char *) -#define UNIFI_CFG_UAPSD_TRAFFIC _IOW ('u', 0x22, unsigned char) - -#define UNIFI_COREDUMP_GET_REG _IOWR('u', 0x23, unifiio_coredump_req_t) - - -/* - * Following reset, f/w may only be downloaded using CMD52. - * This is slow, so there is a facility to download a secondary - * loader first which supports CMD53. - * If loader_len is > 0, then loader_data is assumed to point to - * a suitable secondary loader that can be used to download the - * main image. - * - * The driver will run the host protocol initialisation sequence - * after downloading the image. - * - * If both lengths are zero, then the f/w is assumed to have been - * booted from Flash and the host protocol initialisation sequence - * is run. - */ -typedef struct { - - /* Number of bytes in the image */ - int img_len; - - /* Pointer to image data. */ - unsigned char *img_data; - - - /* Number of bytes in the loader image */ - int loader_len; - - /* Pointer to loader image data. */ - unsigned char *loader_data; - -} unifiio_img_t; - - -/* Structure of data read from the unifi device. */ -typedef struct -{ - /* Length (in bytes) of entire structure including appended bulk data */ - int length; - - /* System time (in milliseconds) that signal was transferred */ - int timestamp; - - /* Direction in which signal was transferred. */ - int direction; -#define UDI_FROM_HOST 0 -#define UDI_TO_HOST 1 -#define UDI_CONFIG_IND 2 - - /* The length of the signal (in bytes) not including bulk data */ - int signal_length; - - /* Signal body follows, then any bulk data */ - -} udi_msg_t; - - -typedef enum -{ - UfSigFil_AllOn = 0, /* Log all signal IDs */ - UfSigFil_AllOff = 1, /* Don't log any signal IDs */ - UfSigFil_SelectOn = 2, /* Log these signal IDs */ - UfSigFil_SelectOff = 3 /* Don't log these signal IDs */ -} uf_sigfilter_action_t; - -typedef struct { - - /* Number of 16-bit ints in the sig_ids array */ - int num_sig_ids; - /* The action to perform */ - uf_sigfilter_action_t action; - /* List of signal IDs to pass or block */ - unsigned short *sig_ids; - -} unifiio_filter_t; - - -typedef struct { - /* Number of 16-bit ints in the protocols array */ - u16 count; - /* List of protocol ids to pass */ - u16 *protocols; -} unifiio_snap_filter_t; - - - -typedef u8 unifi_putest_command_t; - -#define UNIFI_PUTEST_START 0 -#define UNIFI_PUTEST_STOP 1 -#define UNIFI_PUTEST_SET_SDIO_CLOCK 2 -#define UNIFI_PUTEST_CMD52_READ 3 -#define UNIFI_PUTEST_CMD52_WRITE 4 -#define UNIFI_PUTEST_DL_FW 5 -#define UNIFI_PUTEST_DL_FW_BUFF 6 -#define UNIFI_PUTEST_CMD52_BLOCK_READ 7 -#define UNIFI_PUTEST_COREDUMP_PREPARE 8 -#define UNIFI_PUTEST_GP_READ16 9 -#define UNIFI_PUTEST_GP_WRITE16 10 - - -struct unifi_putest_cmd52 { - int funcnum; - unsigned long addr; - unsigned char data; -}; - - -struct unifi_putest_block_cmd52_r { - int funcnum; - unsigned long addr; - unsigned int length; - unsigned char *data; -}; - -struct unifi_putest_gp_rw16 { - unsigned long addr; /* generic address */ - unsigned short data; -}; - -typedef enum unifi_cfg_command { - UNIFI_CFG_GET, - UNIFI_CFG_POWER, - UNIFI_CFG_POWERSAVE, - UNIFI_CFG_FILTER, - UNIFI_CFG_POWERSUPPLY, - UNIFI_CFG_WMM_QOSINFO, - UNIFI_CFG_WMM_ADDTS, - UNIFI_CFG_WMM_DELTS, - UNIFI_CFG_STRICT_DRAFT_N, - UNIFI_CFG_ENABLE_OKC, - UNIFI_CFG_SET_AP_CONFIG, - UNIFI_CFG_CORE_DUMP /* request to take a fw core dump */ -} unifi_cfg_command_t; - -typedef enum unifi_cfg_power { - UNIFI_CFG_POWER_UNSPECIFIED, - UNIFI_CFG_POWER_OFF, - UNIFI_CFG_POWER_ON -} unifi_cfg_power_t; - -typedef enum unifi_cfg_powersupply { - UNIFI_CFG_POWERSUPPLY_UNSPECIFIED, - UNIFI_CFG_POWERSUPPLY_MAINS, - UNIFI_CFG_POWERSUPPLY_BATTERIES -} unifi_cfg_powersupply_t; - -typedef enum unifi_cfg_powersave { - UNIFI_CFG_POWERSAVE_UNSPECIFIED, - UNIFI_CFG_POWERSAVE_NONE, - UNIFI_CFG_POWERSAVE_FAST, - UNIFI_CFG_POWERSAVE_FULL, - UNIFI_CFG_POWERSAVE_AUTO -} unifi_cfg_powersave_t; - -typedef enum unifi_cfg_get { - UNIFI_CFG_GET_COEX, - UNIFI_CFG_GET_POWER_MODE, - UNIFI_CFG_GET_VERSIONS, - UNIFI_CFG_GET_POWER_SUPPLY, - UNIFI_CFG_GET_INSTANCE, - UNIFI_CFG_GET_AP_CONFIG -} unifi_cfg_get_t; - -#define UNIFI_CFG_FILTER_NONE 0x0000 -#define UNIFI_CFG_FILTER_DHCP 0x0001 -#define UNIFI_CFG_FILTER_ARP 0x0002 -#define UNIFI_CFG_FILTER_NBNS 0x0004 -#define UNIFI_CFG_FILTER_NBDS 0x0008 -#define UNIFI_CFG_FILTER_CUPS 0x0010 -#define UNIFI_CFG_FILTER_ALL 0xFFFF - - -typedef struct uf_cfg_bcast_packet_filter -{ - unsigned long filter_mode; //as defined by HIP protocol - unsigned char arp_filter; - unsigned char dhcp_filter; - unsigned long tclas_ies_length; // length of tclas_ies in bytes - unsigned char tclas_ies[1]; // variable length depending on above field -} uf_cfg_bcast_packet_filter_t; - -typedef struct uf_cfg_ap_config -{ - u8 phySupportedBitmap; - u8 channel; - u16 beaconInterval; - u8 dtimPeriod; - u8 wmmEnabled; - u8 shortSlotTimeEnabled; - u16 groupkeyTimeout; - u8 strictGtkRekeyEnabled; - u16 gmkTimeout; - u16 responseTimeout; - u8 retransLimit; - u8 rxStbc; - u8 rifsModeAllowed; - u8 dualCtsProtection; - u8 ctsProtectionType; - u16 maxListenInterval; -}uf_cfg_ap_config_t; - -typedef struct tcpic_clsfr -{ - __u8 cls_fr_type; - __u8 cls_fr_mask; - __u8 version; - __u8 source_ip_addr[4]; - __u8 dest_ip_addr[4]; - __u16 source_port; - __u16 dest_port; - __u8 dscp; - __u8 protocol; - __u8 reserved; -} __attribute__ ((packed)) tcpip_clsfr_t; - -typedef struct tclas { - __u8 element_id; - __u8 length; - __u8 user_priority; - tcpip_clsfr_t tcp_ip_cls_fr; -} __attribute__ ((packed)) tclas_t; - - -#define CONFIG_IND_ERROR 0x01 -#define CONFIG_IND_EXIT 0x02 -#define CONFIG_SME_NOT_PRESENT 0x10 -#define CONFIG_SME_PRESENT 0x20 - -/* WAPI Key */ -typedef struct -{ - u8 unicastKey; - /* If non zero, then unicast key otherwise group key */ - u8 keyIndex; - u8 keyRsc[16]; - u8 authenticator; - /* If non zero, then authenticator otherwise supplicant */ - u8 address[6]; - u8 key[32]; -} unifiio_wapi_key_t; - -/* Values describing XAP memory regions captured by the mini-coredump system */ -typedef enum unifiio_coredump_space { - UNIFIIO_COREDUMP_MAC_REG, - UNIFIIO_COREDUMP_PHY_REG, - UNIFIIO_COREDUMP_SH_DMEM, - UNIFIIO_COREDUMP_MAC_DMEM, - UNIFIIO_COREDUMP_PHY_DMEM, - UNIFIIO_COREDUMP_TRIGGER_MAGIC = 0xFEED -} unifiio_coredump_space_t; - -/* Userspace tool uses this structure to retrieve a register value from a - * mini-coredump buffer previously saved by the HIP - */ -typedef struct unifiio_coredump_req { - /* From user */ - int index; /* 0=newest, -1=oldest */ - unsigned int offset; /* register offset in space */ - unifiio_coredump_space_t space; /* memory space */ - /* Filled by driver */ - unsigned int drv_build; /* driver build id */ - unsigned int chip_ver; /* chip version */ - unsigned int fw_ver; /* firmware version */ - int requestor; /* requestor: 0=auto dump, 1=manual */ - unsigned int timestamp; /* time of capture by driver */ - unsigned int serial; /* capture serial number */ - int value; /* 16 bit register value, -ve for error */ -} unifiio_coredump_req_t; /* Core-dumped register value request */ - -#endif /* __UNIFIIO_H__ */ diff --git a/drivers/staging/csr/wext_events.c b/drivers/staging/csr/wext_events.c deleted file mode 100644 index 9860ea30da25..000000000000 --- a/drivers/staging/csr/wext_events.c +++ /dev/null @@ -1,283 +0,0 @@ -/* - * --------------------------------------------------------------------------- - * FILE: wext_events.c - * - * PURPOSE: - * Code to generate iwevents. - * - * Copyright (C) 2006-2008 by Cambridge Silicon Radio Ltd. - * - * Refer to LICENSE.txt included with this source code for details on - * the license terms. - * - * --------------------------------------------------------------------------- - */ -#include -#include -#include -#include "csr_wifi_hip_unifi.h" -#include "unifi_priv.h" - - - -/* - * --------------------------------------------------------------------------- - * wext_send_assoc_event - * - * Send wireless-extension events up to userland to announce - * successful association with an AP. - * - * Arguments: - * priv Pointer to driver context. - * bssid MAC address of AP we associated with - * req_ie, req_ie_len IEs in the original request - * resp_ie, resp_ie_len IEs in the response - * - * Returns: - * None. - * - * Notes: - * This is sent on first successful association, and again if we - * roam to another AP. - * --------------------------------------------------------------------------- - */ -void -wext_send_assoc_event(unifi_priv_t *priv, unsigned char *bssid, - unsigned char *req_ie, int req_ie_len, - unsigned char *resp_ie, int resp_ie_len, - unsigned char *scan_ie, unsigned int scan_ie_len) -{ -#if WIRELESS_EXT > 17 - union iwreq_data wrqu; - - if (req_ie_len == 0) req_ie = NULL; - wrqu.data.length = req_ie_len; - wrqu.data.flags = 0; - wireless_send_event(priv->netdev[CSR_WIFI_INTERFACE_IN_USE], IWEVASSOCREQIE, &wrqu, req_ie); - - if (resp_ie_len == 0) resp_ie = NULL; - wrqu.data.length = resp_ie_len; - wrqu.data.flags = 0; - wireless_send_event(priv->netdev[CSR_WIFI_INTERFACE_IN_USE], IWEVASSOCRESPIE, &wrqu, resp_ie); - - if (scan_ie_len > 0) { - wrqu.data.length = scan_ie_len; - wrqu.data.flags = 0; - wireless_send_event(priv->netdev[CSR_WIFI_INTERFACE_IN_USE], IWEVGENIE, &wrqu, scan_ie); - } - - memcpy(&wrqu.ap_addr.sa_data, bssid, ETH_ALEN); - wireless_send_event(priv->netdev[CSR_WIFI_INTERFACE_IN_USE], SIOCGIWAP, &wrqu, NULL); -#endif -} /* wext_send_assoc_event() */ - - - -/* - * --------------------------------------------------------------------------- - * wext_send_disassoc_event - * - * Send a wireless-extension event up to userland to announce - * that we disassociated from an AP. - * - * Arguments: - * priv Pointer to driver context. - * - * Returns: - * None. - * - * Notes: - * The semantics of wpa_supplicant (the userland SME application) are - * that a SIOCGIWAP event with MAC address of all zero means - * disassociate. - * --------------------------------------------------------------------------- - */ -void -wext_send_disassoc_event(unifi_priv_t *priv) -{ -#if WIRELESS_EXT > 17 - union iwreq_data wrqu; - - memset(wrqu.ap_addr.sa_data, 0, ETH_ALEN); - wireless_send_event(priv->netdev[CSR_WIFI_INTERFACE_IN_USE], SIOCGIWAP, &wrqu, NULL); -#endif -} /* wext_send_disassoc_event() */ - - - -/* - * --------------------------------------------------------------------------- - * wext_send_scan_results_event - * - * Send wireless-extension events up to userland to announce - * completion of a scan. - * - * Arguments: - * priv Pointer to driver context. - * - * Returns: - * None. - * - * Notes: - * This doesn't actually report the results, they are retrieved - * using the SIOCGIWSCAN ioctl command. - * --------------------------------------------------------------------------- - */ -void -wext_send_scan_results_event(unifi_priv_t *priv) -{ -#if WIRELESS_EXT > 17 - union iwreq_data wrqu; - - wrqu.data.length = 0; - wrqu.data.flags = 0; - wireless_send_event(priv->netdev[CSR_WIFI_INTERFACE_IN_USE], SIOCGIWSCAN, &wrqu, NULL); - -#endif -} /* wext_send_scan_results_event() */ - - - -/* - * --------------------------------------------------------------------------- - * wext_send_michaelmicfailure_event - * - * Send wireless-extension events up to userland to announce - * completion of a scan. - * - * Arguments: - * priv Pointer to driver context. - * count, macaddr, key_type, key_idx, tsc - * Parameters from report from UniFi. - * - * Returns: - * None. - * --------------------------------------------------------------------------- - */ -#if WIRELESS_EXT >= 18 -static inline void -_send_michaelmicfailure_event(struct net_device *dev, - int count, const unsigned char *macaddr, - int key_type, int key_idx, - unsigned char *tsc) -{ - union iwreq_data wrqu; - struct iw_michaelmicfailure mmf; - - memset(&mmf, 0, sizeof(mmf)); - - mmf.flags = key_idx & IW_MICFAILURE_KEY_ID; - if (key_type == CSR_GROUP) { - mmf.flags |= IW_MICFAILURE_GROUP; - } else { - mmf.flags |= IW_MICFAILURE_PAIRWISE; - } - mmf.flags |= ((count << 5) & IW_MICFAILURE_COUNT); - - mmf.src_addr.sa_family = ARPHRD_ETHER; - memcpy(mmf.src_addr.sa_data, macaddr, ETH_ALEN); - - memcpy(mmf.tsc, tsc, IW_ENCODE_SEQ_MAX_SIZE); - - memset(&wrqu, 0, sizeof(wrqu)); - wrqu.data.length = sizeof(mmf); - - wireless_send_event(dev, IWEVMICHAELMICFAILURE, &wrqu, (char *)&mmf); -} -#elif WIRELESS_EXT >= 15 -static inline void -_send_michaelmicfailure_event(struct net_device *dev, - int count, const unsigned char *macaddr, - int key_type, int key_idx, - unsigned char *tsc) -{ - union iwreq_data wrqu; - char buf[128]; - - sprintf(buf, - "MLME-MICHAELMICFAILURE.indication(keyid=%d %scast addr=%pM)", - key_idx, (key_type == CSR_GROUP) ? "broad" : "uni", macaddr); - memset(&wrqu, 0, sizeof(wrqu)); - wrqu.data.length = strlen(buf); - wireless_send_event(dev, IWEVCUSTOM, &wrqu, buf); -} -#else /* WIRELESS_EXT >= 15 */ -static inline void -_send_michaelmicfailure_event(struct net_device *dev, - int count, const unsigned char *macaddr, - int key_type, int key_idx, - unsigned char *tsc) -{ - /* Not supported before WEXT 15 */ -} -#endif /* WIRELESS_EXT >= 15 */ - - -void -wext_send_michaelmicfailure_event(unifi_priv_t *priv, - u16 count, - CsrWifiMacAddress address, - CsrWifiSmeKeyType keyType, - u16 interfaceTag) -{ - unsigned char tsc[8] = {0}; - - if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) { - unifi_error(priv, "wext_send_michaelmicfailure_event bad interfaceTag\n"); - return; - } - - _send_michaelmicfailure_event(priv->netdev[interfaceTag], - count, - address.a, - keyType, - 0, - tsc); -} /* wext_send_michaelmicfailure_event() */ - -void -wext_send_pmkid_candidate_event(unifi_priv_t *priv, CsrWifiMacAddress bssid, u8 preauth_allowed, u16 interfaceTag) -{ -#if WIRELESS_EXT > 17 - union iwreq_data wrqu; - struct iw_pmkid_cand pmkid_cand; - - if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) { - unifi_error(priv, "wext_send_pmkid_candidate_event bad interfaceTag\n"); - return; - } - - memset(&pmkid_cand, 0, sizeof(pmkid_cand)); - - if (preauth_allowed) { - pmkid_cand.flags |= IW_PMKID_CAND_PREAUTH; - } - pmkid_cand.bssid.sa_family = ARPHRD_ETHER; - memcpy(pmkid_cand.bssid.sa_data, bssid.a, ETH_ALEN); - /* Used as priority, smaller the number higher the priority, not really used in our case */ - pmkid_cand.index = 1; - - memset(&wrqu, 0, sizeof(wrqu)); - wrqu.data.length = sizeof(pmkid_cand); - - wireless_send_event(priv->netdev[interfaceTag], IWEVPMKIDCAND, &wrqu, (char *)&pmkid_cand); -#endif -} /* wext_send_pmkid_candidate_event() */ - -/* - * Send a custom WEXT event to say we have completed initialisation - * and are now ready for WEXT ioctls. Used by Android wpa_supplicant. - */ -void -wext_send_started_event(unifi_priv_t *priv) -{ -#if WIRELESS_EXT > 17 - union iwreq_data wrqu; - char data[] = "STARTED"; - - wrqu.data.length = sizeof(data); - wrqu.data.flags = 0; - wireless_send_event(priv->netdev[CSR_WIFI_INTERFACE_IN_USE], IWEVCUSTOM, &wrqu, data); -#endif -} /* wext_send_started_event() */ - From 08801f966571b522f0581de0fd400abdf295b16b Mon Sep 17 00:00:00 2001 From: Randy Dunlap Date: Sun, 14 Jul 2013 17:43:06 -0700 Subject: [PATCH 0984/1048] driver-core: fix new kernel-doc warning in base/platform.c Fix new kernel-doc warning in drivers/base/platform.c: Warning(drivers/base/platform.c:528): No description found for parameter 'owner' Signed-off-by: Randy Dunlap Signed-off-by: Greg Kroah-Hartman --- drivers/base/platform.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/base/platform.c b/drivers/base/platform.c index 15789875128e..3c3197a8de41 100644 --- a/drivers/base/platform.c +++ b/drivers/base/platform.c @@ -522,6 +522,7 @@ static void platform_drv_shutdown(struct device *_dev) /** * __platform_driver_register - register a driver for platform-level devices * @drv: platform driver structure + * @owner: owning module/driver */ int __platform_driver_register(struct platform_driver *drv, struct module *owner) From f45708209dc445bac0844f6ce86e315a2ffe8a29 Mon Sep 17 00:00:00 2001 From: Haiyang Zhang Date: Tue, 16 Jul 2013 23:01:20 -0700 Subject: [PATCH 0985/1048] hyperv: Fix the NETIF_F_SG flag setting in netvsc SG mode is not currently supported by netvsc, so remove this flag for now. Otherwise, it will be unconditionally enabled by commit ec5f0615642 "Kill link between CSUM and SG features" Previously, the SG feature is disabled because CSUM is not set here. Signed-off-by: Haiyang Zhang Reviewed-by: K. Y. Srinivasan Signed-off-by: David S. Miller --- drivers/net/hyperv/netvsc_drv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c index 4dccead586be..23a0fff0df52 100644 --- a/drivers/net/hyperv/netvsc_drv.c +++ b/drivers/net/hyperv/netvsc_drv.c @@ -431,8 +431,8 @@ static int netvsc_probe(struct hv_device *dev, net->netdev_ops = &device_ops; /* TODO: Add GSO and Checksum offload */ - net->hw_features = NETIF_F_SG; - net->features = NETIF_F_SG | NETIF_F_HW_VLAN_CTAG_TX; + net->hw_features = 0; + net->features = NETIF_F_HW_VLAN_CTAG_TX; SET_ETHTOOL_OPS(net, ðtool_ops); SET_NETDEV_DEV(net, &dev->device); From 256ca9c3ad5013ff8a8f165e5a82fab437628c8e Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 16 Jul 2013 12:17:49 +0200 Subject: [PATCH 0986/1048] ALSA: seq-oss: Initialize MIDI clients asynchronously We've got bug reports that the module loading stuck on Debian system with 3.10 kernel. The debugging session revealed that the initial registration of OSS sequencer clients stuck at module loading time, which involves again with request_module() at the init phase. This is triggered only by special --install stuff Debian is using, but it's still not good to have such loops. As a workaround, call the registration part asynchronously. This is a better approach irrespective of the hang fix, in anyway. Reported-and-tested-by: Philipp Matthias Hahn Cc: Signed-off-by: Takashi Iwai --- sound/core/seq/oss/seq_oss_init.c | 16 +++++++++++++--- sound/core/seq/oss/seq_oss_midi.c | 2 +- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/sound/core/seq/oss/seq_oss_init.c b/sound/core/seq/oss/seq_oss_init.c index e3cb46fef2c7..b3f39b5ed742 100644 --- a/sound/core/seq/oss/seq_oss_init.c +++ b/sound/core/seq/oss/seq_oss_init.c @@ -31,6 +31,7 @@ #include #include #include +#include /* * common variables @@ -60,6 +61,14 @@ static void free_devinfo(void *private); #define call_ctl(type,rec) snd_seq_kernel_client_ctl(system_client, type, rec) +/* call snd_seq_oss_midi_lookup_ports() asynchronously */ +static void async_call_lookup_ports(struct work_struct *work) +{ + snd_seq_oss_midi_lookup_ports(system_client); +} + +static DECLARE_WORK(async_lookup_work, async_call_lookup_ports); + /* * create sequencer client for OSS sequencer */ @@ -85,9 +94,6 @@ snd_seq_oss_create_client(void) system_client = rc; debug_printk(("new client = %d\n", rc)); - /* look up midi devices */ - snd_seq_oss_midi_lookup_ports(system_client); - /* create annoucement receiver port */ memset(port, 0, sizeof(*port)); strcpy(port->name, "Receiver"); @@ -115,6 +121,9 @@ snd_seq_oss_create_client(void) } rc = 0; + /* look up midi devices */ + schedule_work(&async_lookup_work); + __error: kfree(port); return rc; @@ -160,6 +169,7 @@ receive_announce(struct snd_seq_event *ev, int direct, void *private, int atomic int snd_seq_oss_delete_client(void) { + cancel_work_sync(&async_lookup_work); if (system_client >= 0) snd_seq_delete_kernel_client(system_client); diff --git a/sound/core/seq/oss/seq_oss_midi.c b/sound/core/seq/oss/seq_oss_midi.c index 677dc84590c7..862d84893ee8 100644 --- a/sound/core/seq/oss/seq_oss_midi.c +++ b/sound/core/seq/oss/seq_oss_midi.c @@ -72,7 +72,7 @@ static int send_midi_event(struct seq_oss_devinfo *dp, struct snd_seq_event *ev, * look up the existing ports * this looks a very exhausting job. */ -int __init +int snd_seq_oss_midi_lookup_ports(int client) { struct snd_seq_client_info *clinfo; From 58cbd3ac09b939ac613dfd4ac9d10bc6f7769f48 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Wed, 10 Jul 2013 15:28:15 +0200 Subject: [PATCH 0987/1048] drm/shmobile: Use the GEM PRIME helpers The GEM CMA PRIME import/export helpers have been removed in favor of generic GEM PRIME helpers with GEM CMA low-level operations. Fix the driver accordingly. Reported-by: Mark Brown Signed-off-by: Laurent Pinchart Tested-by: Mark Brown --- drivers/gpu/drm/shmobile/shmob_drm_drv.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/shmobile/shmob_drm_drv.c b/drivers/gpu/drm/shmobile/shmob_drm_drv.c index edc10181f551..5f83f9a3ef59 100644 --- a/drivers/gpu/drm/shmobile/shmob_drm_drv.c +++ b/drivers/gpu/drm/shmobile/shmob_drm_drv.c @@ -276,8 +276,13 @@ static struct drm_driver shmob_drm_driver = { .gem_vm_ops = &drm_gem_cma_vm_ops, .prime_handle_to_fd = drm_gem_prime_handle_to_fd, .prime_fd_to_handle = drm_gem_prime_fd_to_handle, - .gem_prime_import = drm_gem_cma_dmabuf_import, - .gem_prime_export = drm_gem_cma_dmabuf_export, + .gem_prime_import = drm_gem_prime_import, + .gem_prime_export = drm_gem_prime_export, + .gem_prime_get_sg_table = drm_gem_cma_prime_get_sg_table, + .gem_prime_import_sg_table = drm_gem_cma_prime_import_sg_table, + .gem_prime_vmap = drm_gem_cma_prime_vmap, + .gem_prime_vunmap = drm_gem_cma_prime_vunmap, + .gem_prime_mmap = drm_gem_cma_prime_mmap, .dumb_create = drm_gem_cma_dumb_create, .dumb_map_offset = drm_gem_cma_dumb_map_offset, .dumb_destroy = drm_gem_cma_dumb_destroy, From ffb40400762d86a34318160e8f2169b66f01473d Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Wed, 10 Jul 2013 15:23:35 +0200 Subject: [PATCH 0988/1048] drm/rcar-du: Use the GEM PRIME helpers The GEM CMA PRIME import/export helpers have been removed in favor of generic GEM PRIME helpers with GEM CMA low-level operations. Fix the driver accordingly. Reported-by: Mark Brown Signed-off-by: Laurent Pinchart Tested-by: Mark Brown --- drivers/gpu/drm/rcar-du/rcar_du_drv.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/rcar-du/rcar_du_drv.c b/drivers/gpu/drm/rcar-du/rcar_du_drv.c index ff82877de876..dc0fe09b2ba1 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_drv.c +++ b/drivers/gpu/drm/rcar-du/rcar_du_drv.c @@ -249,8 +249,13 @@ static struct drm_driver rcar_du_driver = { .gem_vm_ops = &drm_gem_cma_vm_ops, .prime_handle_to_fd = drm_gem_prime_handle_to_fd, .prime_fd_to_handle = drm_gem_prime_fd_to_handle, - .gem_prime_import = drm_gem_cma_dmabuf_import, - .gem_prime_export = drm_gem_cma_dmabuf_export, + .gem_prime_import = drm_gem_prime_import, + .gem_prime_export = drm_gem_prime_export, + .gem_prime_get_sg_table = drm_gem_cma_prime_get_sg_table, + .gem_prime_import_sg_table = drm_gem_cma_prime_import_sg_table, + .gem_prime_vmap = drm_gem_cma_prime_vmap, + .gem_prime_vunmap = drm_gem_cma_prime_vunmap, + .gem_prime_mmap = drm_gem_cma_prime_mmap, .dumb_create = rcar_du_dumb_create, .dumb_map_offset = drm_gem_cma_dumb_map_offset, .dumb_destroy = drm_gem_cma_dumb_destroy, From a47bde9b7cbeb87dbb1c5554e90b770d3cc06c5c Mon Sep 17 00:00:00 2001 From: Ralf Baechle Date: Wed, 17 Jul 2013 17:28:48 +0200 Subject: [PATCH 0989/1048] MIPS: Delete dead invocation of exception_exit(). panic() doesn't return so this call was useless. Signed-off-by: Ralf Baechle Reported-by: Alexander Sverdlin --- arch/mips/kernel/traps.c | 1 - 1 file changed, 1 deletion(-) diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c index 0903d70b2cfe..3035a40c4559 100644 --- a/arch/mips/kernel/traps.c +++ b/arch/mips/kernel/traps.c @@ -1242,7 +1242,6 @@ asmlinkage void do_mcheck(struct pt_regs *regs) panic("Caught Machine Check exception - %scaused by multiple " "matching entries in the TLB.", (multi_match) ? "" : "not "); - exception_exit(prev_state); } asmlinkage void do_mt(struct pt_regs *regs) From 1294d4a36d1e0dacfc37c1f269d78ff58f0cd8bc Mon Sep 17 00:00:00 2001 From: Alex Deucher Date: Tue, 16 Jul 2013 15:58:50 -0400 Subject: [PATCH 0990/1048] drm/radeon: add a module parameter to disable aspm Can cause hangs when enabled in certain motherboards. Set radeon.aspm=0 to disable aspm. Signed-off-by: Alex Deucher --- drivers/gpu/drm/radeon/evergreen.c | 3 +++ drivers/gpu/drm/radeon/radeon.h | 1 + drivers/gpu/drm/radeon/radeon_drv.c | 4 ++++ drivers/gpu/drm/radeon/rv6xx_dpm.c | 14 ++++++++------ drivers/gpu/drm/radeon/rv770_dpm.c | 14 ++++++++------ drivers/gpu/drm/radeon/si.c | 3 +++ 6 files changed, 27 insertions(+), 12 deletions(-) diff --git a/drivers/gpu/drm/radeon/evergreen.c b/drivers/gpu/drm/radeon/evergreen.c index 526e428cb4d0..038dcac7670c 100644 --- a/drivers/gpu/drm/radeon/evergreen.c +++ b/drivers/gpu/drm/radeon/evergreen.c @@ -5515,6 +5515,9 @@ void evergreen_program_aspm(struct radeon_device *rdev) */ bool fusion_platform = false; + if (radeon_aspm == 0) + return; + if (!(rdev->flags & RADEON_IS_PCIE)) return; diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h index 001081757895..2f08219c39b6 100644 --- a/drivers/gpu/drm/radeon/radeon.h +++ b/drivers/gpu/drm/radeon/radeon.h @@ -97,6 +97,7 @@ extern int radeon_msi; extern int radeon_lockup_timeout; extern int radeon_fastfb; extern int radeon_dpm; +extern int radeon_aspm; /* * Copy from radeon_drv.h so we don't have to include both and have conflicting diff --git a/drivers/gpu/drm/radeon/radeon_drv.c b/drivers/gpu/drm/radeon/radeon_drv.c index e5419b350170..29876b1be8ec 100644 --- a/drivers/gpu/drm/radeon/radeon_drv.c +++ b/drivers/gpu/drm/radeon/radeon_drv.c @@ -167,6 +167,7 @@ int radeon_msi = -1; int radeon_lockup_timeout = 10000; int radeon_fastfb = 0; int radeon_dpm = -1; +int radeon_aspm = -1; MODULE_PARM_DESC(no_wb, "Disable AGP writeback for scratch registers"); module_param_named(no_wb, radeon_no_wb, int, 0444); @@ -225,6 +226,9 @@ module_param_named(fastfb, radeon_fastfb, int, 0444); MODULE_PARM_DESC(dpm, "DPM support (1 = enable, 0 = disable, -1 = auto)"); module_param_named(dpm, radeon_dpm, int, 0444); +MODULE_PARM_DESC(aspm, "ASPM support (1 = enable, 0 = disable, -1 = auto)"); +module_param_named(aspm, radeon_aspm, int, 0444); + static struct pci_device_id pciidlist[] = { radeon_PCI_IDS }; diff --git a/drivers/gpu/drm/radeon/rv6xx_dpm.c b/drivers/gpu/drm/radeon/rv6xx_dpm.c index 8303de267ee5..65e33f387341 100644 --- a/drivers/gpu/drm/radeon/rv6xx_dpm.c +++ b/drivers/gpu/drm/radeon/rv6xx_dpm.c @@ -1763,12 +1763,14 @@ void rv6xx_setup_asic(struct radeon_device *rdev) { r600_enable_acpi_pm(rdev); - if (rdev->pm.dpm.platform_caps & ATOM_PP_PLATFORM_CAP_ASPM_L0s) - rv6xx_enable_l0s(rdev); - if (rdev->pm.dpm.platform_caps & ATOM_PP_PLATFORM_CAP_ASPM_L1) - rv6xx_enable_l1(rdev); - if (rdev->pm.dpm.platform_caps & ATOM_PP_PLATFORM_CAP_TURNOFFPLL_ASPML1) - rv6xx_enable_pll_sleep_in_l1(rdev); + if (radeon_aspm != 0) { + if (rdev->pm.dpm.platform_caps & ATOM_PP_PLATFORM_CAP_ASPM_L0s) + rv6xx_enable_l0s(rdev); + if (rdev->pm.dpm.platform_caps & ATOM_PP_PLATFORM_CAP_ASPM_L1) + rv6xx_enable_l1(rdev); + if (rdev->pm.dpm.platform_caps & ATOM_PP_PLATFORM_CAP_TURNOFFPLL_ASPML1) + rv6xx_enable_pll_sleep_in_l1(rdev); + } } void rv6xx_dpm_display_configuration_changed(struct radeon_device *rdev) diff --git a/drivers/gpu/drm/radeon/rv770_dpm.c b/drivers/gpu/drm/radeon/rv770_dpm.c index d914e04ea39a..2d347925f77d 100644 --- a/drivers/gpu/drm/radeon/rv770_dpm.c +++ b/drivers/gpu/drm/radeon/rv770_dpm.c @@ -2099,12 +2099,14 @@ void rv770_dpm_setup_asic(struct radeon_device *rdev) rv770_enable_acpi_pm(rdev); - if (rdev->pm.dpm.platform_caps & ATOM_PP_PLATFORM_CAP_ASPM_L0s) - rv770_enable_l0s(rdev); - if (rdev->pm.dpm.platform_caps & ATOM_PP_PLATFORM_CAP_ASPM_L1) - rv770_enable_l1(rdev); - if (rdev->pm.dpm.platform_caps & ATOM_PP_PLATFORM_CAP_TURNOFFPLL_ASPML1) - rv770_enable_pll_sleep_in_l1(rdev); + if (radeon_aspm != 0) { + if (rdev->pm.dpm.platform_caps & ATOM_PP_PLATFORM_CAP_ASPM_L0s) + rv770_enable_l0s(rdev); + if (rdev->pm.dpm.platform_caps & ATOM_PP_PLATFORM_CAP_ASPM_L1) + rv770_enable_l1(rdev); + if (rdev->pm.dpm.platform_caps & ATOM_PP_PLATFORM_CAP_TURNOFFPLL_ASPML1) + rv770_enable_pll_sleep_in_l1(rdev); + } } void rv770_dpm_display_configuration_changed(struct radeon_device *rdev) diff --git a/drivers/gpu/drm/radeon/si.c b/drivers/gpu/drm/radeon/si.c index d3f05076f385..d325280e2f9f 100644 --- a/drivers/gpu/drm/radeon/si.c +++ b/drivers/gpu/drm/radeon/si.c @@ -7053,6 +7053,9 @@ static void si_program_aspm(struct radeon_device *rdev) bool disable_l0s = false, disable_l1 = false, disable_plloff_in_l1 = false; bool disable_clkreq = false; + if (radeon_aspm == 0) + return; + if (!(rdev->flags & RADEON_IS_PCIE)) return; From 1fa4252af760560f77ca3d5d360fd62df3292c7f Mon Sep 17 00:00:00 2001 From: Alex Deucher Date: Wed, 17 Jul 2013 10:18:52 -0400 Subject: [PATCH 0991/1048] drm/radeon: fix an endian bug in atom table parsing Signed-off-by: Alex Deucher --- drivers/gpu/drm/radeon/radeon_atombios.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/radeon/radeon_atombios.c b/drivers/gpu/drm/radeon/radeon_atombios.c index fbdaff55556b..0c3455a73992 100644 --- a/drivers/gpu/drm/radeon/radeon_atombios.c +++ b/drivers/gpu/drm/radeon/radeon_atombios.c @@ -3638,7 +3638,7 @@ int radeon_atom_get_mclk_range_table(struct radeon_device *rdev, p += le16_to_cpu(vram_module->usModuleSize); } mclk_range_table->num_entries = (u8) - ((vram_module->usModuleSize - offsetof(ATOM_VRAM_MODULE_V4, asMemTiming)) / + ((le16_to_cpu(vram_module->usModuleSize) - offsetof(ATOM_VRAM_MODULE_V4, asMemTiming)) / mem_timing_size); p = (u8 *)vram_module->asMemTiming; for (i = 0; i < mclk_range_table->num_entries; i++) { From 77c7d50a4a9f1fa3aa42adad00e7b44aa70ec910 Mon Sep 17 00:00:00 2001 From: Alex Deucher Date: Wed, 17 Jul 2013 10:52:43 -0400 Subject: [PATCH 0992/1048] drm/radeon/dpm: fix atom vram table parsing Parsing the table in incorrectly led to problems with certain asics with mclk switching. Signed-off-by: Alex Deucher --- drivers/gpu/drm/radeon/radeon_atombios.c | 26 +++++++++--------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/drivers/gpu/drm/radeon/radeon_atombios.c b/drivers/gpu/drm/radeon/radeon_atombios.c index 0c3455a73992..a2e324188bc9 100644 --- a/drivers/gpu/drm/radeon/radeon_atombios.c +++ b/drivers/gpu/drm/radeon/radeon_atombios.c @@ -3513,7 +3513,6 @@ int radeon_atom_get_memory_info(struct radeon_device *rdev, u8 frev, crev, i; u16 data_offset, size; union vram_info *vram_info; - u8 *p; memset(mem_info, 0, sizeof(struct atom_memory_info)); @@ -3529,13 +3528,12 @@ int radeon_atom_get_memory_info(struct radeon_device *rdev, if (module_index < vram_info->v1_3.ucNumOfVRAMModule) { ATOM_VRAM_MODULE_V3 *vram_module = (ATOM_VRAM_MODULE_V3 *)vram_info->v1_3.aVramInfo; - p = (u8 *)vram_info->v1_3.aVramInfo; for (i = 0; i < module_index; i++) { - vram_module = (ATOM_VRAM_MODULE_V3 *)p; if (le16_to_cpu(vram_module->usSize) == 0) return -EINVAL; - p += le16_to_cpu(vram_module->usSize); + vram_module = (ATOM_VRAM_MODULE_V3 *) + ((u8 *)vram_module + le16_to_cpu(vram_module->usSize)); } mem_info->mem_vendor = vram_module->asMemory.ucMemoryVenderID & 0xf; mem_info->mem_type = vram_module->asMemory.ucMemoryType & 0xf0; @@ -3547,13 +3545,12 @@ int radeon_atom_get_memory_info(struct radeon_device *rdev, if (module_index < vram_info->v1_4.ucNumOfVRAMModule) { ATOM_VRAM_MODULE_V4 *vram_module = (ATOM_VRAM_MODULE_V4 *)vram_info->v1_4.aVramInfo; - p = (u8 *)vram_info->v1_4.aVramInfo; for (i = 0; i < module_index; i++) { - vram_module = (ATOM_VRAM_MODULE_V4 *)p; if (le16_to_cpu(vram_module->usModuleSize) == 0) return -EINVAL; - p += le16_to_cpu(vram_module->usModuleSize); + vram_module = (ATOM_VRAM_MODULE_V4 *) + ((u8 *)vram_module + le16_to_cpu(vram_module->usModuleSize)); } mem_info->mem_vendor = vram_module->ucMemoryVenderID & 0xf; mem_info->mem_type = vram_module->ucMemoryType & 0xf0; @@ -3572,13 +3569,12 @@ int radeon_atom_get_memory_info(struct radeon_device *rdev, if (module_index < vram_info->v2_1.ucNumOfVRAMModule) { ATOM_VRAM_MODULE_V7 *vram_module = (ATOM_VRAM_MODULE_V7 *)vram_info->v2_1.aVramInfo; - p = (u8 *)vram_info->v2_1.aVramInfo; for (i = 0; i < module_index; i++) { - vram_module = (ATOM_VRAM_MODULE_V7 *)p; if (le16_to_cpu(vram_module->usModuleSize) == 0) return -EINVAL; - p += le16_to_cpu(vram_module->usModuleSize); + vram_module = (ATOM_VRAM_MODULE_V7 *) + ((u8 *)vram_module + le16_to_cpu(vram_module->usModuleSize)); } mem_info->mem_vendor = vram_module->ucMemoryVenderID & 0xf; mem_info->mem_type = vram_module->ucMemoryType & 0xf0; @@ -3628,21 +3624,19 @@ int radeon_atom_get_mclk_range_table(struct radeon_device *rdev, if (module_index < vram_info->v1_4.ucNumOfVRAMModule) { ATOM_VRAM_MODULE_V4 *vram_module = (ATOM_VRAM_MODULE_V4 *)vram_info->v1_4.aVramInfo; - ATOM_MEMORY_TIMING_FORMAT *format; - p = (u8 *)vram_info->v1_4.aVramInfo; for (i = 0; i < module_index; i++) { - vram_module = (ATOM_VRAM_MODULE_V4 *)p; if (le16_to_cpu(vram_module->usModuleSize) == 0) return -EINVAL; - p += le16_to_cpu(vram_module->usModuleSize); + vram_module = (ATOM_VRAM_MODULE_V4 *) + ((u8 *)vram_module + le16_to_cpu(vram_module->usModuleSize)); } mclk_range_table->num_entries = (u8) ((le16_to_cpu(vram_module->usModuleSize) - offsetof(ATOM_VRAM_MODULE_V4, asMemTiming)) / mem_timing_size); - p = (u8 *)vram_module->asMemTiming; + p = (u8 *)&vram_module->asMemTiming[0]; for (i = 0; i < mclk_range_table->num_entries; i++) { - format = (ATOM_MEMORY_TIMING_FORMAT *)p; + ATOM_MEMORY_TIMING_FORMAT *format = (ATOM_MEMORY_TIMING_FORMAT *)p; mclk_range_table->mclk[i] = le32_to_cpu(format->ulClkRange); p += mem_timing_size; } From 48fa04c3fcdb4f6ac041976bedaf19ca5bee20c0 Mon Sep 17 00:00:00 2001 From: Andre Heider Date: Wed, 17 Jul 2013 14:02:23 -0400 Subject: [PATCH 0993/1048] drm/radeon/dpm/atom: restructure logic to work around a compiler bug It seems gcc 4.8.1 generates bogus code for the old logic causing part of the function to get skipped. Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=66932 https://bugs.freedesktop.org/show_bug.cgi?id=66972 https://bugs.freedesktop.org/show_bug.cgi?id=66945 Signed-off-by: Alex Deucher --- drivers/gpu/drm/radeon/radeon_atombios.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/radeon/radeon_atombios.c b/drivers/gpu/drm/radeon/radeon_atombios.c index a2e324188bc9..2606ec680ae3 100644 --- a/drivers/gpu/drm/radeon/radeon_atombios.c +++ b/drivers/gpu/drm/radeon/radeon_atombios.c @@ -3703,8 +3703,9 @@ int radeon_atom_init_mc_reg_table(struct radeon_device *rdev, sizeof(ATOM_INIT_REG_INDEX_FORMAT)) - 1; if (num_entries > VBIOS_MC_REGISTER_ARRAY_SIZE) return -EINVAL; - while (!(reg_block->asRegIndexBuf[i].ucPreRegDataLength & ACCESS_PLACEHOLDER) && - (i < num_entries)) { + while (i < num_entries) { + if (reg_block->asRegIndexBuf[i].ucPreRegDataLength & ACCESS_PLACEHOLDER) + break; reg_table->mc_reg_address[i].s1 = (u16)(le16_to_cpu(reg_block->asRegIndexBuf[i].usRegIndex)); reg_table->mc_reg_address[i].pre_reg_data = From fe5c3561e6f0ac7c9546209f01351113c1b77ec8 Mon Sep 17 00:00:00 2001 From: stephen hemminger Date: Sat, 13 Jul 2013 10:18:18 -0700 Subject: [PATCH 0994/1048] vxlan: add necessary locking on device removal The socket management is now done in workqueue (outside of RTNL) and protected by vn->sock_lock. There were two possible bugs, first the vxlan device was removed from the VNI hash table per socket without holding lock. And there was a race when device is created and the workqueue could run after deletion. Signed-off-by: Stephen Hemminger Signed-off-by: David S. Miller --- drivers/net/vxlan.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c index 0ba1e7edbb1b..a5ba8dd7e6be 100644 --- a/drivers/net/vxlan.c +++ b/drivers/net/vxlan.c @@ -1767,9 +1767,15 @@ static int vxlan_newlink(struct net *net, struct net_device *dev, static void vxlan_dellink(struct net_device *dev, struct list_head *head) { + struct vxlan_net *vn = net_generic(dev_net(dev), vxlan_net_id); struct vxlan_dev *vxlan = netdev_priv(dev); + flush_workqueue(vxlan_wq); + + spin_lock(&vn->sock_lock); hlist_del_rcu(&vxlan->hlist); + spin_unlock(&vn->sock_lock); + list_del(&vxlan->next); unregister_netdevice_queue(dev, head); } From 093b9c71b6e450e375f4646ba86faed0195ec7df Mon Sep 17 00:00:00 2001 From: Jan Beulich Date: Wed, 17 Jul 2013 08:09:37 +0100 Subject: [PATCH 0995/1048] xen-netfront: pull on receive skb may need to happen earlier Due to commit 3683243b ("xen-netfront: use __pskb_pull_tail to ensure linear area is big enough on RX") xennet_fill_frags() may end up filling MAX_SKB_FRAGS + 1 fragments in a receive skb, and only reduce the fragment count subsequently via __pskb_pull_tail(). That's a result of xennet_get_responses() allowing a maximum of one more slot to be consumed (and intermediately transformed into a fragment) if the head slot has a size less than or equal to RX_COPY_THRESHOLD. Hence we need to adjust xennet_fill_frags() to pull earlier if we reached the maximum fragment count - due to the described behavior of xennet_get_responses() this guarantees that at least the first fragment will get completely consumed, and hence the fragment count reduced. In order to not needlessly call __pskb_pull_tail() twice, make the original call conditional upon the pull target not having been reached yet, and defer the newly added one as much as possible (an alternative would have been to always call the function right before the call to xennet_fill_frags(), but that would imply more frequent cases of needing to call it twice). Signed-off-by: Jan Beulich Acked-by: Wei Liu Cc: Ian Campbell Cc: stable@vger.kernel.org (3.6 onwards) Acked-by: Ian Campbell Signed-off-by: David S. Miller --- drivers/net/xen-netfront.c | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c index ff7f111fffee..36808bf25677 100644 --- a/drivers/net/xen-netfront.c +++ b/drivers/net/xen-netfront.c @@ -286,8 +286,7 @@ no_skb: break; } - __skb_fill_page_desc(skb, 0, page, 0, 0); - skb_shinfo(skb)->nr_frags = 1; + skb_add_rx_frag(skb, 0, page, 0, 0, PAGE_SIZE); __skb_queue_tail(&np->rx_batch, skb); } @@ -831,7 +830,6 @@ static RING_IDX xennet_fill_frags(struct netfront_info *np, struct sk_buff_head *list) { struct skb_shared_info *shinfo = skb_shinfo(skb); - int nr_frags = shinfo->nr_frags; RING_IDX cons = np->rx.rsp_cons; struct sk_buff *nskb; @@ -840,19 +838,21 @@ static RING_IDX xennet_fill_frags(struct netfront_info *np, RING_GET_RESPONSE(&np->rx, ++cons); skb_frag_t *nfrag = &skb_shinfo(nskb)->frags[0]; - __skb_fill_page_desc(skb, nr_frags, - skb_frag_page(nfrag), - rx->offset, rx->status); + if (shinfo->nr_frags == MAX_SKB_FRAGS) { + unsigned int pull_to = NETFRONT_SKB_CB(skb)->pull_to; - skb->data_len += rx->status; + BUG_ON(pull_to <= skb_headlen(skb)); + __pskb_pull_tail(skb, pull_to - skb_headlen(skb)); + } + BUG_ON(shinfo->nr_frags >= MAX_SKB_FRAGS); + + skb_add_rx_frag(skb, shinfo->nr_frags, skb_frag_page(nfrag), + rx->offset, rx->status, PAGE_SIZE); skb_shinfo(nskb)->nr_frags = 0; kfree_skb(nskb); - - nr_frags++; } - shinfo->nr_frags = nr_frags; return cons; } @@ -933,7 +933,8 @@ static int handle_incoming_queue(struct net_device *dev, while ((skb = __skb_dequeue(rxq)) != NULL) { int pull_to = NETFRONT_SKB_CB(skb)->pull_to; - __pskb_pull_tail(skb, pull_to - skb_headlen(skb)); + if (pull_to > skb_headlen(skb)) + __pskb_pull_tail(skb, pull_to - skb_headlen(skb)); /* Ethernet work: Delayed to here as it peeks the header. */ skb->protocol = eth_type_trans(skb, dev); @@ -1019,16 +1020,10 @@ err: skb_shinfo(skb)->frags[0].page_offset = rx->offset; skb_frag_size_set(&skb_shinfo(skb)->frags[0], rx->status); skb->data_len = rx->status; + skb->len += rx->status; i = xennet_fill_frags(np, skb, &tmpq); - /* - * Truesize is the actual allocation size, even if the - * allocation is only partially used. - */ - skb->truesize += PAGE_SIZE * skb_shinfo(skb)->nr_frags; - skb->len += skb->data_len; - if (rx->flags & XEN_NETRXF_csum_blank) skb->ip_summed = CHECKSUM_PARTIAL; else if (rx->flags & XEN_NETRXF_data_validated) From f90555cbe629e14c6af1dcec1933a3833ecd321f Mon Sep 17 00:00:00 2001 From: Alex Deucher Date: Wed, 17 Jul 2013 16:34:12 -0400 Subject: [PATCH 0996/1048] drm/radeon/dpm/atom: fix broken gcc harder See bugs: https://bugs.freedesktop.org/show_bug.cgi?id=66932 https://bugs.freedesktop.org/show_bug.cgi?id=66972 https://bugs.freedesktop.org/show_bug.cgi?id=66945 Signed-off-by: Alex Deucher --- drivers/gpu/drm/radeon/radeon_atombios.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/radeon/radeon_atombios.c b/drivers/gpu/drm/radeon/radeon_atombios.c index 2606ec680ae3..e3f3e8841789 100644 --- a/drivers/gpu/drm/radeon/radeon_atombios.c +++ b/drivers/gpu/drm/radeon/radeon_atombios.c @@ -3699,18 +3699,21 @@ int radeon_atom_init_mc_reg_table(struct radeon_device *rdev, (ATOM_MEMORY_SETTING_DATA_BLOCK *) ((u8 *)reg_block + (2 * sizeof(u16)) + le16_to_cpu(reg_block->usRegIndexTblSize)); + ATOM_INIT_REG_INDEX_FORMAT *format = ®_block->asRegIndexBuf[0]; num_entries = (u8)((le16_to_cpu(reg_block->usRegIndexTblSize)) / sizeof(ATOM_INIT_REG_INDEX_FORMAT)) - 1; if (num_entries > VBIOS_MC_REGISTER_ARRAY_SIZE) return -EINVAL; while (i < num_entries) { - if (reg_block->asRegIndexBuf[i].ucPreRegDataLength & ACCESS_PLACEHOLDER) + if (format->ucPreRegDataLength & ACCESS_PLACEHOLDER) break; reg_table->mc_reg_address[i].s1 = - (u16)(le16_to_cpu(reg_block->asRegIndexBuf[i].usRegIndex)); + (u16)(le16_to_cpu(format->usRegIndex)); reg_table->mc_reg_address[i].pre_reg_data = - (u8)(reg_block->asRegIndexBuf[i].ucPreRegDataLength); + (u8)(format->ucPreRegDataLength); i++; + format = (ATOM_INIT_REG_INDEX_FORMAT *) + ((u8 *)format + sizeof(ATOM_INIT_REG_INDEX_FORMAT)); } reg_table->last = i; while ((*(u32 *)reg_data != END_OF_REG_DATA_BLOCK) && From 444bddc4b9b3313a562cd3ba40f780fb82570f7d Mon Sep 17 00:00:00 2001 From: Alex Deucher Date: Tue, 2 Jul 2013 13:05:23 -0400 Subject: [PATCH 0997/1048] drm/radeon/dpm: add debugfs support for RS780/RS880 (v3) This allows you to look at the current DPM state via debugfs. Due to the way the hardware works on these asics, there's no way to look up exactly what power state we are in, so we make the best guess we can based on the current sclk. v2: Anthoine's version v3: fix ref div Signed-off-by: Alex Deucher --- drivers/gpu/drm/radeon/radeon_asic.c | 1 + drivers/gpu/drm/radeon/radeon_asic.h | 2 ++ drivers/gpu/drm/radeon/rs780_dpm.c | 25 +++++++++++++++++++++++++ drivers/gpu/drm/radeon/rs780d.h | 3 +++ 4 files changed, 31 insertions(+) diff --git a/drivers/gpu/drm/radeon/radeon_asic.c b/drivers/gpu/drm/radeon/radeon_asic.c index fea997e247ba..78bec1a58ed1 100644 --- a/drivers/gpu/drm/radeon/radeon_asic.c +++ b/drivers/gpu/drm/radeon/radeon_asic.c @@ -1270,6 +1270,7 @@ static struct radeon_asic rs780_asic = { .get_sclk = &rs780_dpm_get_sclk, .get_mclk = &rs780_dpm_get_mclk, .print_power_state = &rs780_dpm_print_power_state, + .debugfs_print_current_performance_level = &rs780_dpm_debugfs_print_current_performance_level, }, .pflip = { .pre_page_flip = &rs600_pre_page_flip, diff --git a/drivers/gpu/drm/radeon/radeon_asic.h b/drivers/gpu/drm/radeon/radeon_asic.h index b04b5789f4a8..ca1895709908 100644 --- a/drivers/gpu/drm/radeon/radeon_asic.h +++ b/drivers/gpu/drm/radeon/radeon_asic.h @@ -433,6 +433,8 @@ u32 rs780_dpm_get_sclk(struct radeon_device *rdev, bool low); u32 rs780_dpm_get_mclk(struct radeon_device *rdev, bool low); void rs780_dpm_print_power_state(struct radeon_device *rdev, struct radeon_ps *ps); +void rs780_dpm_debugfs_print_current_performance_level(struct radeon_device *rdev, + struct seq_file *m); /* uvd */ int r600_uvd_init(struct radeon_device *rdev); diff --git a/drivers/gpu/drm/radeon/rs780_dpm.c b/drivers/gpu/drm/radeon/rs780_dpm.c index bef832a62fee..d1a1ce73bd45 100644 --- a/drivers/gpu/drm/radeon/rs780_dpm.c +++ b/drivers/gpu/drm/radeon/rs780_dpm.c @@ -28,6 +28,7 @@ #include "r600_dpm.h" #include "rs780_dpm.h" #include "atom.h" +#include static struct igp_ps *rs780_get_ps(struct radeon_ps *rps) { @@ -961,3 +962,27 @@ u32 rs780_dpm_get_mclk(struct radeon_device *rdev, bool low) return pi->bootup_uma_clk; } + +void rs780_dpm_debugfs_print_current_performance_level(struct radeon_device *rdev, + struct seq_file *m) +{ + struct radeon_ps *rps = rdev->pm.dpm.current_ps; + struct igp_ps *ps = rs780_get_ps(rps); + u32 current_fb_div = RREG32(FVTHROT_STATUS_REG0) & CURRENT_FEEDBACK_DIV_MASK; + u32 func_cntl = RREG32(CG_SPLL_FUNC_CNTL); + u32 ref_div = ((func_cntl & SPLL_REF_DIV_MASK) >> SPLL_REF_DIV_SHIFT) + 1; + u32 post_div = ((func_cntl & SPLL_SW_HILEN_MASK) >> SPLL_SW_HILEN_SHIFT) + 1 + + ((func_cntl & SPLL_SW_LOLEN_MASK) >> SPLL_SW_LOLEN_SHIFT) + 1; + u32 sclk = (rdev->clock.spll.reference_freq * current_fb_div) / + (post_div * ref_div); + + seq_printf(m, "uvd vclk: %d dclk: %d\n", rps->vclk, rps->dclk); + + /* guess based on the current sclk */ + if (sclk < (ps->sclk_low + 500)) + seq_printf(m, "power level 0 sclk: %u vddc_index: %d\n", + ps->sclk_low, ps->min_voltage); + else + seq_printf(m, "power level 1 sclk: %u vddc_index: %d\n", + ps->sclk_high, ps->max_voltage); +} diff --git a/drivers/gpu/drm/radeon/rs780d.h b/drivers/gpu/drm/radeon/rs780d.h index b1142ed1c628..cfbe9a43d97b 100644 --- a/drivers/gpu/drm/radeon/rs780d.h +++ b/drivers/gpu/drm/radeon/rs780d.h @@ -28,6 +28,7 @@ # define SPLL_SLEEP (1 << 1) # define SPLL_REF_DIV(x) ((x) << 2) # define SPLL_REF_DIV_MASK (7 << 2) +# define SPLL_REF_DIV_SHIFT 2 # define SPLL_FB_DIV(x) ((x) << 5) # define SPLL_FB_DIV_MASK (0xff << 2) # define SPLL_FB_DIV_SHIFT 2 @@ -36,8 +37,10 @@ # define SPLL_PULSENUM_MASK (3 << 14) # define SPLL_SW_HILEN(x) ((x) << 16) # define SPLL_SW_HILEN_MASK (0xf << 16) +# define SPLL_SW_HILEN_SHIFT 16 # define SPLL_SW_LOLEN(x) ((x) << 20) # define SPLL_SW_LOLEN_MASK (0xf << 20) +# define SPLL_SW_LOLEN_SHIFT 20 # define SPLL_DIVEN (1 << 24) # define SPLL_BYPASS_EN (1 << 25) # define SPLL_CHG_STATUS (1 << 29) From b4a2cf76ab7c08628c62b2062dacefa496b59dfd Mon Sep 17 00:00:00 2001 From: Trond Myklebust Date: Wed, 17 Jul 2013 16:43:16 -0400 Subject: [PATCH 0998/1048] NFSv4: Fix a regression against the FreeBSD server Technically, the Linux client is allowed by the NFSv4 spec to send 3 word bitmaps as part of an OPEN request. However, this causes the current FreeBSD server to return NFS4ERR_ATTRNOTSUPP errors. Fix the regression by making the Linux client use a 2 word bitmap unless doing NFSv4.2 with labeled NFS. Signed-off-by: Trond Myklebust --- fs/nfs/nfs4xdr.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c index 0abfb8466e79..c74d6168db99 100644 --- a/fs/nfs/nfs4xdr.c +++ b/fs/nfs/nfs4xdr.c @@ -999,6 +999,7 @@ static void encode_attrs(struct xdr_stream *xdr, const struct iattr *iap, __be32 *p; __be32 *q; int len; + uint32_t bmval_len = 2; uint32_t bmval0 = 0; uint32_t bmval1 = 0; uint32_t bmval2 = 0; @@ -1010,7 +1011,7 @@ static void encode_attrs(struct xdr_stream *xdr, const struct iattr *iap, * = 40 bytes, plus any contribution from variable-length fields * such as owner/group. */ - len = 20; + len = 8; /* Sigh */ if (iap->ia_valid & ATTR_SIZE) @@ -1040,8 +1041,6 @@ static void encode_attrs(struct xdr_stream *xdr, const struct iattr *iap, } len += 4 + (XDR_QUADLEN(owner_grouplen) << 2); } - if (label) - len += 4 + 4 + 4 + (XDR_QUADLEN(label->len) << 2); if (iap->ia_valid & ATTR_ATIME_SET) len += 16; else if (iap->ia_valid & ATTR_ATIME) @@ -1050,15 +1049,22 @@ static void encode_attrs(struct xdr_stream *xdr, const struct iattr *iap, len += 16; else if (iap->ia_valid & ATTR_MTIME) len += 4; + if (label) { + len += 4 + 4 + 4 + (XDR_QUADLEN(label->len) << 2); + bmval_len = 3; + } + + len += bmval_len << 2; p = reserve_space(xdr, len); /* * We write the bitmap length now, but leave the bitmap and the attribute * buffer length to be backfilled at the end of this routine. */ - *p++ = cpu_to_be32(3); + *p++ = cpu_to_be32(bmval_len); q = p; - p += 4; + /* Skip bitmap entries + attrlen */ + p += bmval_len + 1; if (iap->ia_valid & ATTR_SIZE) { bmval0 |= FATTR4_WORD0_SIZE; @@ -1112,10 +1118,11 @@ static void encode_attrs(struct xdr_stream *xdr, const struct iattr *iap, len, ((char *)p - (char *)q) + 4); BUG(); } - len = (char *)p - (char *)q - 16; + len = (char *)p - (char *)q - (bmval_len << 2); *q++ = htonl(bmval0); *q++ = htonl(bmval1); - *q++ = htonl(bmval2); + if (bmval_len == 3) + *q++ = htonl(bmval2); *q = htonl(len); /* out: */ From 242b2287cd7f27521c8b54a4101d569e53e7a0ca Mon Sep 17 00:00:00 2001 From: Aaron Lu Date: Tue, 2 Jul 2013 21:59:10 +0800 Subject: [PATCH 0999/1048] ACPICA: expose OSI version Expose acpi_gbl_osi_data so that code outside of ACPICA can check the value of the last successfull _OSI call. The definitions for OSI versions are moved to actypes.h so that other components can access them too. Based on a patch from Matthew Garrett which in turn was based on an earlier patch from Seth Forshee. [rjw: Changelog] Signed-off-by: Aaron Lu Signed-off-by: Rafael J. Wysocki --- drivers/acpi/acpica/aclocal.h | 13 ------------- include/acpi/acpixf.h | 1 + include/acpi/actypes.h | 15 +++++++++++++++ 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/drivers/acpi/acpica/aclocal.h b/drivers/acpi/acpica/aclocal.h index dfed26545ba2..d4a4901637cd 100644 --- a/drivers/acpi/acpica/aclocal.h +++ b/drivers/acpi/acpica/aclocal.h @@ -931,19 +931,6 @@ struct acpi_bit_register_info { /* Structs and definitions for _OSI support and I/O port validation */ -#define ACPI_OSI_WIN_2000 0x01 -#define ACPI_OSI_WIN_XP 0x02 -#define ACPI_OSI_WIN_XP_SP1 0x03 -#define ACPI_OSI_WINSRV_2003 0x04 -#define ACPI_OSI_WIN_XP_SP2 0x05 -#define ACPI_OSI_WINSRV_2003_SP1 0x06 -#define ACPI_OSI_WIN_VISTA 0x07 -#define ACPI_OSI_WINSRV_2008 0x08 -#define ACPI_OSI_WIN_VISTA_SP1 0x09 -#define ACPI_OSI_WIN_VISTA_SP2 0x0A -#define ACPI_OSI_WIN_7 0x0B -#define ACPI_OSI_WIN_8 0x0C - #define ACPI_ALWAYS_ILLEGAL 0x00 struct acpi_interface_info { diff --git a/include/acpi/acpixf.h b/include/acpi/acpixf.h index 1b09300810e6..22d497ee6ef9 100644 --- a/include/acpi/acpixf.h +++ b/include/acpi/acpixf.h @@ -62,6 +62,7 @@ extern u32 acpi_current_gpe_count; extern struct acpi_table_fadt acpi_gbl_FADT; extern u8 acpi_gbl_system_awake_and_running; extern u8 acpi_gbl_reduced_hardware; /* ACPI 5.0 */ +extern u8 acpi_gbl_osi_data; /* Runtime configuration of debug print levels */ diff --git a/include/acpi/actypes.h b/include/acpi/actypes.h index a64adcc29ae5..22b03c9286e9 100644 --- a/include/acpi/actypes.h +++ b/include/acpi/actypes.h @@ -1144,4 +1144,19 @@ struct acpi_memory_list { #endif }; +/* Definitions for _OSI support */ + +#define ACPI_OSI_WIN_2000 0x01 +#define ACPI_OSI_WIN_XP 0x02 +#define ACPI_OSI_WIN_XP_SP1 0x03 +#define ACPI_OSI_WINSRV_2003 0x04 +#define ACPI_OSI_WIN_XP_SP2 0x05 +#define ACPI_OSI_WINSRV_2003_SP1 0x06 +#define ACPI_OSI_WIN_VISTA 0x07 +#define ACPI_OSI_WINSRV_2008 0x08 +#define ACPI_OSI_WIN_VISTA_SP1 0x09 +#define ACPI_OSI_WIN_VISTA_SP2 0x0A +#define ACPI_OSI_WIN_7 0x0B +#define ACPI_OSI_WIN_8 0x0C + #endif /* __ACTYPES_H__ */ From c04c697cf1fe8f0962ccd3c2392a9b637a5307aa Mon Sep 17 00:00:00 2001 From: Matthew Garrett Date: Tue, 16 Jul 2013 17:08:16 +0000 Subject: [PATCH 1000/1048] ACPI / video: Always call acpi_video_init_brightness() on init We have to call acpi_video_init_brightness() even if we're not going to initialise the backlight - Thinkpads seem to use this as the trigger for enabling ACPI notifications rather than handling it in firmware. [rjw: Drop the brightness object created by acpi_video_init_brightness() if we are not going to use it.] Signed-off-by: Matthew Garrett Signed-off-by: Rafael J. Wysocki --- drivers/acpi/video.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c index 5d7075d25700..f236e172d948 100644 --- a/drivers/acpi/video.c +++ b/drivers/acpi/video.c @@ -898,6 +898,9 @@ static void acpi_video_device_find_cap(struct acpi_video_device *device) device->cap._DDC = 1; } + if (acpi_video_init_brightness(device)) + return; + if (acpi_video_backlight_support()) { struct backlight_properties props; struct pci_dev *pdev; @@ -907,9 +910,6 @@ static void acpi_video_device_find_cap(struct acpi_video_device *device) static int count = 0; char *name; - result = acpi_video_init_brightness(device); - if (result) - return; name = kasprintf(GFP_KERNEL, "acpi_video%d", count); if (!name) return; @@ -969,6 +969,11 @@ static void acpi_video_device_find_cap(struct acpi_video_device *device) if (result) printk(KERN_ERR PREFIX "Create sysfs link\n"); + } else { + /* Remove the brightness object. */ + kfree(device->brightness->levels); + kfree(device->brightness); + device->brightness = NULL; } } From 3c0fc0710185e618a661528eed2183102e25c2f8 Mon Sep 17 00:00:00 2001 From: Liu ShuoX Date: Tue, 16 Jul 2013 16:23:44 +0800 Subject: [PATCH 1001/1048] PNP / ACPI: avoid garbage in resource name Set temporary variable as 0 to avoid garbage string output from /proc/iomem after register resources and reset to PNP dev name later. Signed-off-by: Liu ShuoX Signed-off-by: Rafael J. Wysocki --- drivers/pnp/pnpacpi/rsparser.c | 2 +- drivers/pnp/resource.c | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/pnp/pnpacpi/rsparser.c b/drivers/pnp/pnpacpi/rsparser.c index 9847ab163829..167f3d00c916 100644 --- a/drivers/pnp/pnpacpi/rsparser.c +++ b/drivers/pnp/pnpacpi/rsparser.c @@ -180,7 +180,7 @@ static acpi_status pnpacpi_allocated_resource(struct acpi_resource *res, struct pnp_dev *dev = data; struct acpi_resource_dma *dma; struct acpi_resource_vendor_typed *vendor_typed; - struct resource r; + struct resource r = {0}; int i, flags; if (acpi_dev_resource_memory(res, &r) diff --git a/drivers/pnp/resource.c b/drivers/pnp/resource.c index 3e6db1c1dc29..d95e101ffb43 100644 --- a/drivers/pnp/resource.c +++ b/drivers/pnp/resource.c @@ -515,6 +515,7 @@ struct pnp_resource *pnp_add_resource(struct pnp_dev *dev, } pnp_res->res = *res; + pnp_res->res.name = dev->name; dev_dbg(&dev->dev, "%pR\n", res); return pnp_res; } From 8c5bd7adb2ce47e6aa39d17b2375f69b0c0aa255 Mon Sep 17 00:00:00 2001 From: "Rafael J. Wysocki" Date: Thu, 18 Jul 2013 02:08:06 +0200 Subject: [PATCH 1002/1048] ACPI / video / i915: No ACPI backlight if firmware expects Windows 8 According to Matthew Garrett, "Windows 8 leaves backlight control up to individual graphics drivers rather than making ACPI calls itself. There's plenty of evidence to suggest that the Intel driver for Windows [8] doesn't use the ACPI interface, including the fact that it's broken on a bunch of machines when the OS claims to support Windows 8. The simplest thing to do appears to be to disable the ACPI backlight interface on these systems". There's a problem with that approach, however, because simply avoiding to register the ACPI backlight interface if the firmware calls _OSI for Windows 8 may not work in the following situations: (1) The ACPI backlight interface actually works on the given system and the i915 driver is not loaded (e.g. another graphics driver is used). (2) The ACPI backlight interface doesn't work on the given system, but there is a vendor platform driver that will register its own, equally broken, backlight interface if not prevented from doing so by the ACPI subsystem. Therefore we need to allow the ACPI backlight interface to be registered until the i915 driver is loaded which then will unregister it if the firmware has called _OSI for Windows 8 (or will register the ACPI video driver without backlight support if not already present). For this reason, introduce an alternative function for registering ACPI video, acpi_video_register_with_quirks(), that will check whether or not the ACPI video driver has already been registered and whether or not the backlight Windows 8 quirk has to be applied. If the quirk has to be applied, it will block the ACPI backlight support and either unregister the backlight interface if the ACPI video driver has already been registered, or register the ACPI video driver without the backlight interface otherwise. Make the i915 driver use acpi_video_register_with_quirks() instead of acpi_video_register() in i915_driver_load(). This change is based on earlier patches from Matthew Garrett, Chun-Yi Lee and Seth Forshee and includes a fix from Aaron Lu's. References: https://bugzilla.kernel.org/show_bug.cgi?id=51231 Tested-by: Aaron Lu Tested-by: Igor Gnatenko Tested-by: Yves-Alexis Perez Signed-off-by: Rafael J. Wysocki Reviewed-by: Aaron Lu Acked-by: Matthew Garrett --- drivers/acpi/internal.h | 11 ++++++ drivers/acpi/video.c | 69 +++++++++++++++++++++++++++++---- drivers/acpi/video_detect.c | 21 ++++++++++ drivers/gpu/drm/i915/i915_dma.c | 2 +- include/acpi/video.h | 11 +++++- include/linux/acpi.h | 1 + 6 files changed, 105 insertions(+), 10 deletions(-) diff --git a/drivers/acpi/internal.h b/drivers/acpi/internal.h index 3a50a34fe176..227aca77ee1e 100644 --- a/drivers/acpi/internal.h +++ b/drivers/acpi/internal.h @@ -164,4 +164,15 @@ struct platform_device; int acpi_create_platform_device(struct acpi_device *adev, const struct acpi_device_id *id); +/*-------------------------------------------------------------------------- + Video + -------------------------------------------------------------------------- */ +#if defined(CONFIG_ACPI_VIDEO) || defined(CONFIG_ACPI_VIDEO_MODULE) +bool acpi_video_backlight_quirks(void); +bool acpi_video_verify_backlight_support(void); +#else +static inline bool acpi_video_backlight_quirks(void) { return false; } +static inline bool acpi_video_verify_backlight_support(void) { return false; } +#endif + #endif /* _ACPI_INTERNAL_H_ */ diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c index f236e172d948..e9d4bb60c35c 100644 --- a/drivers/acpi/video.c +++ b/drivers/acpi/video.c @@ -44,6 +44,8 @@ #include #include +#include "internal.h" + #define PREFIX "ACPI: " #define ACPI_VIDEO_BUS_NAME "Video Bus" @@ -901,7 +903,7 @@ static void acpi_video_device_find_cap(struct acpi_video_device *device) if (acpi_video_init_brightness(device)) return; - if (acpi_video_backlight_support()) { + if (acpi_video_verify_backlight_support()) { struct backlight_properties props; struct pci_dev *pdev; acpi_handle acpi_parent; @@ -1356,8 +1358,8 @@ acpi_video_switch_brightness(struct acpi_video_device *device, int event) unsigned long long level_current, level_next; int result = -EINVAL; - /* no warning message if acpi_backlight=vendor is used */ - if (!acpi_video_backlight_support()) + /* no warning message if acpi_backlight=vendor or a quirk is used */ + if (!acpi_video_verify_backlight_support()) return 0; if (!device->brightness) @@ -1859,6 +1861,46 @@ static int acpi_video_bus_remove(struct acpi_device *device) return 0; } +static acpi_status video_unregister_backlight(acpi_handle handle, u32 lvl, + void *context, void **rv) +{ + struct acpi_device *acpi_dev; + struct acpi_video_bus *video; + struct acpi_video_device *dev, *next; + + if (acpi_bus_get_device(handle, &acpi_dev)) + return AE_OK; + + if (acpi_match_device_ids(acpi_dev, video_device_ids)) + return AE_OK; + + video = acpi_driver_data(acpi_dev); + if (!video) + return AE_OK; + + acpi_video_bus_stop_devices(video); + mutex_lock(&video->device_list_lock); + list_for_each_entry_safe(dev, next, &video->video_device_list, entry) { + if (dev->backlight) { + backlight_device_unregister(dev->backlight); + dev->backlight = NULL; + kfree(dev->brightness->levels); + kfree(dev->brightness); + } + if (dev->cooling_dev) { + sysfs_remove_link(&dev->dev->dev.kobj, + "thermal_cooling"); + sysfs_remove_link(&dev->cooling_dev->device.kobj, + "device"); + thermal_cooling_device_unregister(dev->cooling_dev); + dev->cooling_dev = NULL; + } + } + mutex_unlock(&video->device_list_lock); + acpi_video_bus_start_devices(video); + return AE_OK; +} + static int __init is_i740(struct pci_dev *dev) { if (dev->device == 0x00D1) @@ -1890,14 +1932,25 @@ static int __init intel_opregion_present(void) return opregion; } -int acpi_video_register(void) +int __acpi_video_register(bool backlight_quirks) { - int result = 0; + bool no_backlight; + int result; + + no_backlight = backlight_quirks ? acpi_video_backlight_quirks() : false; + if (register_count) { /* - * if the function of acpi_video_register is already called, - * don't register the acpi_vide_bus again and return no error. + * If acpi_video_register() has been called already, don't try + * to register acpi_video_bus, but unregister backlight devices + * if no backlight support is requested. */ + if (no_backlight) + acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, + ACPI_UINT32_MAX, + video_unregister_backlight, + NULL, NULL, NULL); + return 0; } @@ -1913,7 +1966,7 @@ int acpi_video_register(void) return 0; } -EXPORT_SYMBOL(acpi_video_register); +EXPORT_SYMBOL(__acpi_video_register); void acpi_video_unregister(void) { diff --git a/drivers/acpi/video_detect.c b/drivers/acpi/video_detect.c index e6bd910bc6ed..826e52def080 100644 --- a/drivers/acpi/video_detect.c +++ b/drivers/acpi/video_detect.c @@ -38,6 +38,8 @@ #include #include +#include "internal.h" + #define PREFIX "ACPI: " ACPI_MODULE_NAME("video"); @@ -234,6 +236,17 @@ static void acpi_video_caps_check(void) acpi_video_get_capabilities(NULL); } +bool acpi_video_backlight_quirks(void) +{ + if (acpi_gbl_osi_data >= ACPI_OSI_WIN_8) { + acpi_video_caps_check(); + acpi_video_support |= ACPI_VIDEO_SKIP_BACKLIGHT; + return true; + } + return false; +} +EXPORT_SYMBOL(acpi_video_backlight_quirks); + /* Promote the vendor interface instead of the generic video module. * This function allow DMI blacklists to be implemented by externals * platform drivers instead of putting a big blacklist in video_detect.c @@ -278,6 +291,14 @@ int acpi_video_backlight_support(void) } EXPORT_SYMBOL(acpi_video_backlight_support); +/* For the ACPI video driver use only. */ +bool acpi_video_verify_backlight_support(void) +{ + return (acpi_video_support & ACPI_VIDEO_SKIP_BACKLIGHT) ? + false : acpi_video_backlight_support(); +} +EXPORT_SYMBOL(acpi_video_verify_backlight_support); + /* * Use acpi_backlight=vendor/video to force that backlight switching * is processed by vendor specific acpi drivers or video.ko driver. diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c index adb319b53ecd..cf188ab7051a 100644 --- a/drivers/gpu/drm/i915/i915_dma.c +++ b/drivers/gpu/drm/i915/i915_dma.c @@ -1648,7 +1648,7 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags) if (INTEL_INFO(dev)->num_pipes) { /* Must be done after probing outputs */ intel_opregion_init(dev); - acpi_video_register(); + acpi_video_register_with_quirks(); } if (IS_GEN5(dev)) diff --git a/include/acpi/video.h b/include/acpi/video.h index 61109f2609fc..b26dc4fb7ba8 100644 --- a/include/acpi/video.h +++ b/include/acpi/video.h @@ -17,12 +17,21 @@ struct acpi_device; #define ACPI_VIDEO_DISPLAY_LEGACY_TV 0x0200 #if (defined CONFIG_ACPI_VIDEO || defined CONFIG_ACPI_VIDEO_MODULE) -extern int acpi_video_register(void); +extern int __acpi_video_register(bool backlight_quirks); +static inline int acpi_video_register(void) +{ + return __acpi_video_register(false); +} +static inline int acpi_video_register_with_quirks(void) +{ + return __acpi_video_register(true); +} extern void acpi_video_unregister(void); extern int acpi_video_get_edid(struct acpi_device *device, int type, int device_id, void **edid); #else static inline int acpi_video_register(void) { return 0; } +static inline int acpi_video_register_with_quirks(void) { return 0; } static inline void acpi_video_unregister(void) { return; } static inline int acpi_video_get_edid(struct acpi_device *device, int type, int device_id, void **edid) diff --git a/include/linux/acpi.h b/include/linux/acpi.h index 353ba256f368..6ad72f92469c 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -191,6 +191,7 @@ extern bool wmi_has_guid(const char *guid); #define ACPI_VIDEO_BACKLIGHT_DMI_VIDEO 0x0200 #define ACPI_VIDEO_OUTPUT_SWITCHING_DMI_VENDOR 0x0400 #define ACPI_VIDEO_OUTPUT_SWITCHING_DMI_VIDEO 0x0800 +#define ACPI_VIDEO_SKIP_BACKLIGHT 0x1000 #if defined(CONFIG_ACPI_VIDEO) || defined(CONFIG_ACPI_VIDEO_MODULE) From efaa14c7e981bdf8d3c8d39d3ed12bdc60faabb8 Mon Sep 17 00:00:00 2001 From: Aaron Lu Date: Tue, 16 Jul 2013 13:08:05 +0800 Subject: [PATCH 1003/1048] ACPI / video: no automatic brightness changes by win8-compatible firmware Starting from win8, MS backlight control driver will set bit 2 of the parameter of control method _DOS, to inform firmware it should not perform any automatic brightness changes. This mostly affects hotkey notification deliver - if we do not set this bit, on hotkey press, firmware may choose to adjust brightness level instead of sending out notification and doing nothing. So this patch sets bit 2 when calling _DOS so that GUIs can show the notification window on hotkey press. This behavior change is only necessary for win8 systems. The MS document on win8 backlight control is here: http://msdn.microsoft.com/en-US/library/windows/hardware/jj159305 References: https://bugzilla.kernel.org/show_bug.cgi?id=52951 References: https://bugzilla.kernel.org/show_bug.cgi?id=56711 Reported-by: Micael Dias Reported-by: Dan Garton Reported-by: Bob Ziuchkovski Signed-off-by: Aaron Lu Signed-off-by: Rafael J. Wysocki --- drivers/acpi/video.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c index e9d4bb60c35c..c9fa4621ed25 100644 --- a/drivers/acpi/video.c +++ b/drivers/acpi/video.c @@ -1539,14 +1539,20 @@ static int acpi_video_bus_put_devices(struct acpi_video_bus *video) /* acpi_video interface */ +/* + * Win8 requires setting bit2 of _DOS to let firmware know it shouldn't + * preform any automatic brightness change on receiving a notification. + */ static int acpi_video_bus_start_devices(struct acpi_video_bus *video) { - return acpi_video_bus_DOS(video, 0, 0); + return acpi_video_bus_DOS(video, 0, + acpi_video_backlight_quirks() ? 1 : 0); } static int acpi_video_bus_stop_devices(struct acpi_video_bus *video) { - return acpi_video_bus_DOS(video, 0, 1); + return acpi_video_bus_DOS(video, 0, + acpi_video_backlight_quirks() ? 0 : 1); } static void acpi_video_bus_notify(struct acpi_device *device, u32 event) From 7bb23c4934059c64cbee2e41d5d24ce122285176 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Tue, 16 Jul 2013 16:50:47 +1000 Subject: [PATCH 1004/1048] md/raid10: fix two problems with RAID10 resync. 1/ When an different between blocks is found, data is copied from one bio to the other. However bv_len is used as the length to copy and this could be zero. So use r10_bio->sectors to calculate length instead. Using bv_len was probably always a bit dubious, but the introduction of bio_advance made it much more likely to be a problem. 2/ When preparing some blocks for sync, we don't set BIO_UPTODATE except on bios that we schedule for a read. This ensures that missing/failed devices don't confuse the loop at the top of sync_request write. Commit 8be185f2c9d54d6 "raid10: Use bio_reset()" removed a loop which set BIO_UPTDATE on all appropriate bios. So we need to re-add that flag. These bugs were introduced in 3.10, so this patch is suitable for 3.10-stable, and can remove a potential for data corruption. Cc: stable@vger.kernel.org (3.10) Reported-by: Brassow Jonathan Signed-off-by: NeilBrown --- drivers/md/raid10.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c index cd066b63bdaf..957a719e8c2f 100644 --- a/drivers/md/raid10.c +++ b/drivers/md/raid10.c @@ -2097,11 +2097,17 @@ static void sync_request_write(struct mddev *mddev, struct r10bio *r10_bio) * both 'first' and 'i', so we just compare them. * All vec entries are PAGE_SIZE; */ - for (j = 0; j < vcnt; j++) + int sectors = r10_bio->sectors; + for (j = 0; j < vcnt; j++) { + int len = PAGE_SIZE; + if (sectors < (len / 512)) + len = sectors * 512; if (memcmp(page_address(fbio->bi_io_vec[j].bv_page), page_address(tbio->bi_io_vec[j].bv_page), - fbio->bi_io_vec[j].bv_len)) + len)) break; + sectors -= len/512; + } if (j == vcnt) continue; atomic64_add(r10_bio->sectors, &mddev->resync_mismatches); @@ -3407,6 +3413,7 @@ static sector_t sync_request(struct mddev *mddev, sector_t sector_nr, if (bio->bi_end_io == end_sync_read) { md_sync_acct(bio->bi_bdev, nr_sectors); + set_bit(BIO_UPTODATE, &bio->bi_flags); generic_make_request(bio); } } From 5024c298311f3b97c85cb034f9edaa333fdb9338 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Wed, 17 Jul 2013 14:55:31 +1000 Subject: [PATCH 1005/1048] md: Remove recent change which allows devices to skip recovery. commit 7ceb17e87bde79d285a8b988cfed9eaeebe60b86 md: Allow devices to be re-added to a read-only array. allowed a bit more than just that. It also allows devices to be added to a read-write array and to end up skipping recovery. This patch removes the offending piece of code pending a rewrite for a subsequent release. More specifically: If the array has a bitmap, then the device will still need a bitmap based resync ('saved_raid_disk' is set under different conditions is a bitmap is present). If the array doesn't have a bitmap, then this is correct as long as nothing has been written to the array since the metadata was checked by ->validate_super. However there is no locking to ensure that there was no write. Bug was introduced in 3.10 and causes data corruption so patch is suitable for 3.10-stable. Cc: stable@vger.kernel.org (3.10) Reported-by: Joe Lawrence Signed-off-by: NeilBrown --- drivers/md/md.c | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/drivers/md/md.c b/drivers/md/md.c index dddc87bcf64a..9f13e13506ef 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -7716,20 +7716,6 @@ static int remove_and_add_spares(struct mddev *mddev, continue; rdev->recovery_offset = 0; - if (rdev->saved_raid_disk >= 0 && mddev->in_sync) { - spin_lock_irq(&mddev->write_lock); - if (mddev->in_sync) - /* OK, this device, which is in_sync, - * will definitely be noticed before - * the next write, so recovery isn't - * needed. - */ - rdev->recovery_offset = mddev->recovery_cp; - spin_unlock_irq(&mddev->write_lock); - } - if (mddev->ro && rdev->recovery_offset != MaxSector) - /* not safe to add this disk now */ - continue; if (mddev->pers-> hot_add_disk(mddev, rdev) == 0) { if (sysfs_link_rdev(mddev, rdev)) From 30bc9b53878a9921b02e3b5bc4283ac1c6de102a Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Wed, 17 Jul 2013 15:19:29 +1000 Subject: [PATCH 1006/1048] md/raid1: fix bio handling problems in process_checks() Recent change to use bio_copy_data() in raid1 when repairing an array is faulty. The underlying may have changed the bio in various ways using bio_advance and these need to be undone not just for the 'sbio' which is being copied to, but also the 'pbio' (primary) which is being copied from. So perform the reset on all bios that were read from and do it early. This also ensure that the sbio->bi_io_vec[j].bv_len passed to memcmp is correct. This fixes a crash during a 'check' of a RAID1 array. The crash was introduced in 3.10 so this is suitable for 3.10-stable. Cc: stable@vger.kernel.org (3.10) Reported-by: Joe Lawrence Signed-off-by: NeilBrown --- drivers/md/raid1.c | 53 ++++++++++++++++++++++++++-------------------- 1 file changed, 30 insertions(+), 23 deletions(-) diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index ec734588a1c6..d60412c7f995 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c @@ -1849,6 +1849,36 @@ static int process_checks(struct r1bio *r1_bio) int i; int vcnt; + /* Fix variable parts of all bios */ + vcnt = (r1_bio->sectors + PAGE_SIZE / 512 - 1) >> (PAGE_SHIFT - 9); + for (i = 0; i < conf->raid_disks * 2; i++) { + int j; + int size; + struct bio *b = r1_bio->bios[i]; + if (b->bi_end_io != end_sync_read) + continue; + /* fixup the bio for reuse */ + bio_reset(b); + b->bi_vcnt = vcnt; + b->bi_size = r1_bio->sectors << 9; + b->bi_sector = r1_bio->sector + + conf->mirrors[i].rdev->data_offset; + b->bi_bdev = conf->mirrors[i].rdev->bdev; + b->bi_end_io = end_sync_read; + b->bi_private = r1_bio; + + size = b->bi_size; + for (j = 0; j < vcnt ; j++) { + struct bio_vec *bi; + bi = &b->bi_io_vec[j]; + bi->bv_offset = 0; + if (size > PAGE_SIZE) + bi->bv_len = PAGE_SIZE; + else + bi->bv_len = size; + size -= PAGE_SIZE; + } + } for (primary = 0; primary < conf->raid_disks * 2; primary++) if (r1_bio->bios[primary]->bi_end_io == end_sync_read && test_bit(BIO_UPTODATE, &r1_bio->bios[primary]->bi_flags)) { @@ -1857,12 +1887,10 @@ static int process_checks(struct r1bio *r1_bio) break; } r1_bio->read_disk = primary; - vcnt = (r1_bio->sectors + PAGE_SIZE / 512 - 1) >> (PAGE_SHIFT - 9); for (i = 0; i < conf->raid_disks * 2; i++) { int j; struct bio *pbio = r1_bio->bios[primary]; struct bio *sbio = r1_bio->bios[i]; - int size; if (sbio->bi_end_io != end_sync_read) continue; @@ -1888,27 +1916,6 @@ static int process_checks(struct r1bio *r1_bio) rdev_dec_pending(conf->mirrors[i].rdev, mddev); continue; } - /* fixup the bio for reuse */ - bio_reset(sbio); - sbio->bi_vcnt = vcnt; - sbio->bi_size = r1_bio->sectors << 9; - sbio->bi_sector = r1_bio->sector + - conf->mirrors[i].rdev->data_offset; - sbio->bi_bdev = conf->mirrors[i].rdev->bdev; - sbio->bi_end_io = end_sync_read; - sbio->bi_private = r1_bio; - - size = sbio->bi_size; - for (j = 0; j < vcnt ; j++) { - struct bio_vec *bi; - bi = &sbio->bi_io_vec[j]; - bi->bv_offset = 0; - if (size > PAGE_SIZE) - bi->bv_len = PAGE_SIZE; - else - bi->bv_len = size; - size -= PAGE_SIZE; - } bio_copy_data(sbio, pbio); } From 1c118b8226922d225a7df4127926ed2a2d73baaf Mon Sep 17 00:00:00 2001 From: Xiao Guangrong Date: Thu, 18 Jul 2013 12:52:37 +0800 Subject: [PATCH 1007/1048] KVM: MMU: avoid fast page fault fixing mmio page fault Currently, fast page fault incorrectly tries to fix mmio page fault when the generation number is invalid (spte.gen != kvm.gen). It then returns to guest to retry the fault since it sees the last spte is nonpresent. This causes an infinite loop. Since fast page fault only works for direct mmu, the issue exists when 1) tdp is enabled. It is only triggered only on AMD host since on Intel host the mmio page fault is recognized as ept-misconfig whose handler call fault-page path with error_code = 0 2) guest paging is disabled. Under this case, the issue is hardly discovered since paging disable is short-lived and the sptes will be invalid after memslot changed for 150 times Fix it by filtering out MMIO page faults in page_fault_can_be_fast. Reported-by: Markus Trippelsdorf Tested-by: Markus Trippelsdorf Signed-off-by: Xiao Guangrong Signed-off-by: Paolo Bonzini --- arch/x86/kvm/mmu.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c index 0d094da49541..9e9285ae9b94 100644 --- a/arch/x86/kvm/mmu.c +++ b/arch/x86/kvm/mmu.c @@ -2810,6 +2810,13 @@ exit: static bool page_fault_can_be_fast(struct kvm_vcpu *vcpu, u32 error_code) { + /* + * Do not fix the mmio spte with invalid generation number which + * need to be updated by slow page fault path. + */ + if (unlikely(error_code & PFERR_RSVD_MASK)) + return false; + /* * #PF can be fast only if the shadow page table is present and it * is caused by write-protect, that means we just need change the From 1eeb74782d354175ef9f3bff02fae62c6e0aef24 Mon Sep 17 00:00:00 2001 From: Heiko Carstens Date: Tue, 16 Jul 2013 10:24:48 +0200 Subject: [PATCH 1008/1048] s390/bpf,jit: call module_free() from any context The workqueue workaround is no longer needed. Same as 5199dfe531 "sparc: bpf_jit_comp: can call module_free() from any context". Signed-off-by: Heiko Carstens Signed-off-by: Martin Schwidefsky --- arch/s390/net/bpf_jit_comp.c | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/arch/s390/net/bpf_jit_comp.c b/arch/s390/net/bpf_jit_comp.c index 82f165f8078c..a41f0b15faa1 100644 --- a/arch/s390/net/bpf_jit_comp.c +++ b/arch/s390/net/bpf_jit_comp.c @@ -772,8 +772,7 @@ void bpf_jit_compile(struct sk_filter *fp) } else if (jit.prg == cjit.prg && jit.lit == cjit.lit) { prg_len = jit.prg - jit.start; lit_len = jit.lit - jit.mid; - size = max_t(unsigned long, prg_len + lit_len, - sizeof(struct work_struct)); + size = prg_len + lit_len; if (size >= BPF_SIZE_MAX) goto out; jit.start = module_alloc(size); @@ -804,21 +803,8 @@ out: kfree(addrs); } -static void jit_free_defer(struct work_struct *arg) -{ - module_free(NULL, arg); -} - -/* run from softirq, we must use a work_struct to call - * module_free() from process context - */ void bpf_jit_free(struct sk_filter *fp) { - struct work_struct *work; - - if (fp->bpf_func == sk_run_filter) - return; - work = (struct work_struct *)fp->bpf_func; - INIT_WORK(work, jit_free_defer); - schedule_work(work); + if (fp->bpf_func != sk_run_filter) + module_free(NULL, fp->bpf_func); } From fee1b5488d76396d8f95989624d37f436b3fba44 Mon Sep 17 00:00:00 2001 From: Heiko Carstens Date: Tue, 16 Jul 2013 10:36:06 +0200 Subject: [PATCH 1009/1048] s390/bpf,jit: use generic jit dumper This is the s390 backend of 79617801 "filter: bpf_jit_comp: refactor and unify BPF JIT image dump output". Signed-off-by: Heiko Carstens Signed-off-by: Martin Schwidefsky --- arch/s390/net/bpf_jit_comp.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/arch/s390/net/bpf_jit_comp.c b/arch/s390/net/bpf_jit_comp.c index a41f0b15faa1..80828bfee2ec 100644 --- a/arch/s390/net/bpf_jit_comp.c +++ b/arch/s390/net/bpf_jit_comp.c @@ -787,15 +787,9 @@ void bpf_jit_compile(struct sk_filter *fp) cjit = jit; } if (bpf_jit_enable > 1) { - pr_err("flen=%d proglen=%lu pass=%d image=%p\n", - fp->len, jit.end - jit.start, pass, jit.start); - if (jit.start) { - printk(KERN_ERR "JIT code:\n"); + bpf_jit_dump(fp->len, jit.end - jit.start, pass, jit.start); + if (jit.start) print_fn_code(jit.start, jit.mid - jit.start); - print_hex_dump(KERN_ERR, "JIT literals:\n", - DUMP_PREFIX_ADDRESS, 16, 1, - jit.mid, jit.end - jit.mid, false); - } } if (jit.start) fp->bpf_func = (void *) jit.start; From aa2d2c73c21f22ce4c643128b671aa7e7bbff54f Mon Sep 17 00:00:00 2001 From: Heiko Carstens Date: Tue, 16 Jul 2013 13:25:49 +0200 Subject: [PATCH 1010/1048] s390/bpf,jit: address randomize and write protect jit code This is the s390 variant of 314beb9b "x86: bpf_jit_comp: secure bpf jit against spraying attacks". With this change the whole jit code and literal pool will be write protected after creation. In addition the start address of the jit code won't be always on a page boundary anymore. Signed-off-by: Heiko Carstens Signed-off-by: Martin Schwidefsky --- arch/s390/net/bpf_jit_comp.c | 51 ++++++++++++++++++++++++++++++++---- 1 file changed, 46 insertions(+), 5 deletions(-) diff --git a/arch/s390/net/bpf_jit_comp.c b/arch/s390/net/bpf_jit_comp.c index 80828bfee2ec..788e22395acd 100644 --- a/arch/s390/net/bpf_jit_comp.c +++ b/arch/s390/net/bpf_jit_comp.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -738,8 +739,41 @@ out: return -1; } +/* + * Note: for security reasons, bpf code will follow a randomly + * sized amount of illegal instructions. + */ +struct bpf_binary_header { + unsigned int pages; + u8 image[]; +}; + +static struct bpf_binary_header *bpf_alloc_binary(unsigned int bpfsize, + u8 **image_ptr) +{ + struct bpf_binary_header *header; + unsigned int sz, hole; + + /* Most BPF filters are really small, but if some of them fill a page, + * allow at least 128 extra bytes for illegal instructions. + */ + sz = round_up(bpfsize + sizeof(*header) + 128, PAGE_SIZE); + header = module_alloc(sz); + if (!header) + return NULL; + memset(header, 0, sz); + header->pages = sz / PAGE_SIZE; + hole = sz - bpfsize + sizeof(*header); + /* Insert random number of illegal instructions before BPF code + * and make sure the first instruction starts at an even address. + */ + *image_ptr = &header->image[(prandom_u32() % hole) & -2]; + return header; +} + void bpf_jit_compile(struct sk_filter *fp) { + struct bpf_binary_header *header = NULL; unsigned long size, prg_len, lit_len; struct bpf_jit jit, cjit; unsigned int *addrs; @@ -775,8 +809,8 @@ void bpf_jit_compile(struct sk_filter *fp) size = prg_len + lit_len; if (size >= BPF_SIZE_MAX) goto out; - jit.start = module_alloc(size); - if (!jit.start) + header = bpf_alloc_binary(size, &jit.start); + if (!header) goto out; jit.prg = jit.mid = jit.start + prg_len; jit.lit = jit.end = jit.start + prg_len + lit_len; @@ -791,14 +825,21 @@ void bpf_jit_compile(struct sk_filter *fp) if (jit.start) print_fn_code(jit.start, jit.mid - jit.start); } - if (jit.start) + if (jit.start) { + set_memory_ro((unsigned long)header, header->pages); fp->bpf_func = (void *) jit.start; + } out: kfree(addrs); } void bpf_jit_free(struct sk_filter *fp) { - if (fp->bpf_func != sk_run_filter) - module_free(NULL, fp->bpf_func); + unsigned long addr = (unsigned long)fp->bpf_func & PAGE_MASK; + struct bpf_binary_header *header = (void *)addr; + + if (fp->bpf_func == sk_run_filter) + return; + set_memory_rw(addr, header->pages); + module_free(NULL, header); } From c9a7afa380ecaeb0fbeec2e82f86ec5548ad2963 Mon Sep 17 00:00:00 2001 From: Heiko Carstens Date: Wed, 17 Jul 2013 14:26:50 +0200 Subject: [PATCH 1011/1048] s390/bpf,jit: add pkt_type support s390 version of 3b58908a "x86: bpf_jit_comp: add pkt_type support". Signed-off-by: Heiko Carstens --- arch/s390/net/bpf_jit_comp.c | 42 ++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/arch/s390/net/bpf_jit_comp.c b/arch/s390/net/bpf_jit_comp.c index 788e22395acd..d5f10a43a58f 100644 --- a/arch/s390/net/bpf_jit_comp.c +++ b/arch/s390/net/bpf_jit_comp.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -222,6 +223,37 @@ static void bpf_jit_epilogue(struct bpf_jit *jit) EMIT2(0x07fe); } +/* Helper to find the offset of pkt_type in sk_buff + * Make sure its still a 3bit field starting at the MSBs within a byte. + */ +#define PKT_TYPE_MAX 0xe0 +static int pkt_type_offset; + +static int __init bpf_pkt_type_offset_init(void) +{ + struct sk_buff skb_probe = { + .pkt_type = ~0, + }; + char *ct = (char *)&skb_probe; + int off; + + pkt_type_offset = -1; + for (off = 0; off < sizeof(struct sk_buff); off++) { + if (!ct[off]) + continue; + if (ct[off] == PKT_TYPE_MAX) + pkt_type_offset = off; + else { + /* Found non matching bit pattern, fix needed. */ + WARN_ON_ONCE(1); + pkt_type_offset = -1; + return -1; + } + } + return 0; +} +device_initcall(bpf_pkt_type_offset_init); + /* * make sure we dont leak kernel information to user */ @@ -721,6 +753,16 @@ call_fn: /* lg %r1,(%r13) */ EMIT4_DISP(0x88500000, 12); } break; + case BPF_S_ANC_PKTTYPE: + if (pkt_type_offset < 0) + goto out; + /* lhi %r5,0 */ + EMIT4(0xa7580000); + /* ic %r5,(%r2) */ + EMIT4_DISP(0x43502000, pkt_type_offset); + /* srl %r5,5 */ + EMIT4_DISP(0x88500000, 5); + break; case BPF_S_ANC_CPU: /* A = smp_processor_id() */ #ifdef CONFIG_SMP /* l %r5, */ From 5a74953ff56aa870d6913ef4d81934f5c620c59d Mon Sep 17 00:00:00 2001 From: Michael Holzheu Date: Thu, 18 Jul 2013 12:17:57 +0200 Subject: [PATCH 1012/1048] s390/kdump: Disable mmap for s390 The kdump mmap patch series (git commit 83086978c63afd7c73e1c) directly map the PT_LOADs to memory. On s390 this does not work because the copy_from_oldmem() function swaps [0,crashkernel size] with [crashkernel base, crashkernel base+crashkernel size]. The swap int copy_from_oldmem() was done in order correctly implement /dev/oldmem. See: http://marc.info/?l=kexec&m=136940802511603&w=2 Signed-off-by: Michael Holzheu Signed-off-by: Martin Schwidefsky --- fs/proc/vmcore.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/proc/vmcore.c b/fs/proc/vmcore.c index 28503172f2e4..a1a16eb97c7b 100644 --- a/fs/proc/vmcore.c +++ b/fs/proc/vmcore.c @@ -223,7 +223,7 @@ static inline char *alloc_elfnotes_buf(size_t notes_sz) * regions in the 1st kernel pointed to by PT_LOAD entries) into * virtually contiguous user-space in ELF layout. */ -#ifdef CONFIG_MMU +#if defined(CONFIG_MMU) && !defined(CONFIG_S390) static int mmap_vmcore(struct file *file, struct vm_area_struct *vma) { size_t size = vma->vm_end - vma->vm_start; From 191a2fa0a8d2bbb64c98f9b1976fcb37ee5eae6b Mon Sep 17 00:00:00 2001 From: Michael Holzheu Date: Thu, 18 Jul 2013 12:18:27 +0200 Subject: [PATCH 1013/1048] s390/kdump: Allow copy_oldmem_page() copy to virtual memory The kdump mmap patch series (git commit 83086978c63afd7c73e1c) changed the requirements for copy_oldmem_page(). Now this function is used for copying to virtual memory. So implement vmalloc support for the s390 version of copy_oldmem_page(). Signed-off-by: Michael Holzheu Signed-off-by: Martin Schwidefsky --- arch/s390/kernel/crash_dump.c | 51 ++++++++++++++++++++++++++++++++--- 1 file changed, 47 insertions(+), 4 deletions(-) diff --git a/arch/s390/kernel/crash_dump.c b/arch/s390/kernel/crash_dump.c index f703d91bf720..d8f355657171 100644 --- a/arch/s390/kernel/crash_dump.c +++ b/arch/s390/kernel/crash_dump.c @@ -21,6 +21,48 @@ #define PTR_SUB(x, y) (((char *) (x)) - ((unsigned long) (y))) #define PTR_DIFF(x, y) ((unsigned long)(((char *) (x)) - ((unsigned long) (y)))) + +/* + * Return physical address for virtual address + */ +static inline void *load_real_addr(void *addr) +{ + unsigned long real_addr; + + asm volatile( + " lra %0,0(%1)\n" + " jz 0f\n" + " la %0,0\n" + "0:" + : "=a" (real_addr) : "a" (addr) : "cc"); + return (void *)real_addr; +} + +/* + * Copy up to one page to vmalloc or real memory + */ +static ssize_t copy_page_real(void *buf, void *src, size_t csize) +{ + size_t size; + + if (is_vmalloc_addr(buf)) { + BUG_ON(csize >= PAGE_SIZE); + /* If buf is not page aligned, copy first part */ + size = min(roundup(__pa(buf), PAGE_SIZE) - __pa(buf), csize); + if (size) { + if (memcpy_real(load_real_addr(buf), src, size)) + return -EFAULT; + buf += size; + src += size; + } + /* Copy second part */ + size = csize - size; + return (size) ? memcpy_real(load_real_addr(buf), src, size) : 0; + } else { + return memcpy_real(buf, src, csize); + } +} + /* * Copy one page from "oldmem" * @@ -32,6 +74,7 @@ ssize_t copy_oldmem_page(unsigned long pfn, char *buf, size_t csize, unsigned long offset, int userbuf) { unsigned long src; + int rc; if (!csize) return 0; @@ -43,11 +86,11 @@ ssize_t copy_oldmem_page(unsigned long pfn, char *buf, src < OLDMEM_BASE + OLDMEM_SIZE) src -= OLDMEM_BASE; if (userbuf) - copy_to_user_real((void __force __user *) buf, (void *) src, - csize); + rc = copy_to_user_real((void __force __user *) buf, + (void *) src, csize); else - memcpy_real(buf, (void *) src, csize); - return csize; + rc = copy_page_real(buf, (void *) src, csize); + return (rc == 0) ? csize : rc; } /* From 9657a565a476d517451c10b0bcc106e300785aff Mon Sep 17 00:00:00 2001 From: Lan Tianyu Date: Tue, 16 Jul 2013 10:07:21 +0800 Subject: [PATCH 1014/1048] ACPI / video: ignore BIOS initial backlight value for Fujitsu E753 The BIOS of FUjitsu E753 reports an incorrect initial backlight value for WIN8 compatible OS, causing backlight to be dark during startup. This change causes the incorrect initial value from BIOS to be ignored. References: https://bugzilla.kernel.org/show_bug.cgi?id=60161 Reported-and-tested-by: Jan Hinnerk Stosch Signed-off-by: Lan Tianyu Cc: 3.7+ Signed-off-by: Rafael J. Wysocki --- drivers/acpi/video.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c index 5d7075d25700..e441876f5d5b 100644 --- a/drivers/acpi/video.c +++ b/drivers/acpi/video.c @@ -448,6 +448,14 @@ static struct dmi_system_id video_dmi_table[] __initdata = { DMI_MATCH(DMI_PRODUCT_NAME, "HP Folio 13 - 2000 Notebook PC"), }, }, + { + .callback = video_ignore_initial_backlight, + .ident = "Fujitsu E753", + .matches = { + DMI_MATCH(DMI_BOARD_VENDOR, "FUJITSU"), + DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK E753"), + }, + }, { .callback = video_ignore_initial_backlight, .ident = "HP Pavilion dm4", From 87f40dd6ce7042caca0b3b557e8923127f51f902 Mon Sep 17 00:00:00 2001 From: Paolo Valente Date: Tue, 16 Jul 2013 08:52:30 +0200 Subject: [PATCH 1015/1048] pkt_sched: sch_qfq: remove a source of high packet delay/jitter QFQ+ inherits from QFQ a design choice that may cause a high packet delay/jitter and a severe short-term unfairness. As QFQ, QFQ+ uses a special quantity, the system virtual time, to track the service provided by the ideal system it approximates. When a packet is dequeued, this quantity must be incremented by the size of the packet, divided by the sum of the weights of the aggregates waiting to be served. Tracking this sum correctly is a non-trivial task, because, to preserve tight service guarantees, the decrement of this sum must be delayed in a special way [1]: this sum can be decremented only after that its value would decrease also in the ideal system approximated by QFQ+. For efficiency, QFQ+ keeps track only of the 'instantaneous' weight sum, increased and decreased immediately as the weight of an aggregate changes, and as an aggregate is created or destroyed (which, in its turn, happens as a consequence of some class being created/destroyed/changed). However, to avoid the problems caused to service guarantees by these immediate decreases, QFQ+ increments the system virtual time using the maximum value allowed for the weight sum, 2^10, in place of the dynamic, instantaneous value. The instantaneous value of the weight sum is used only to check whether a request of weight increase or a class creation can be satisfied. Unfortunately, the problems caused by this choice are worse than the temporary degradation of the service guarantees that may occur, when a class is changed or destroyed, if the instantaneous value of the weight sum was used to update the system virtual time. In fact, the fraction of the link bandwidth guaranteed by QFQ+ to each aggregate is equal to the ratio between the weight of the aggregate and the sum of the weights of the competing aggregates. The packet delay guaranteed to the aggregate is instead inversely proportional to the guaranteed bandwidth. By using the maximum possible value, and not the actual value of the weight sum, QFQ+ provides each aggregate with the worst possible service guarantees, and not with service guarantees related to the actual set of competing aggregates. To see the consequences of this fact, consider the following simple example. Suppose that only the following aggregates are backlogged, i.e., that only the classes in the following aggregates have packets to transmit: one aggregate with weight 10, say A, and ten aggregates with weight 1, say B1, B2, ..., B10. In particular, suppose that these aggregates are always backlogged. Given the weight distribution, the smoothest and fairest service order would be: A B1 A B2 A B3 A B4 A B5 A B6 A B7 A B8 A B9 A B10 A B1 A B2 ... QFQ+ would provide exactly this optimal service if it used the actual value for the weight sum instead of the maximum possible value, i.e., 11 instead of 2^10. In contrast, since QFQ+ uses the latter value, it serves aggregates as follows (easy to prove and to reproduce experimentally): A B1 B2 B3 B4 B5 B6 B7 B8 B9 B10 A A A A A A A A A A B1 B2 ... B10 A A ... By replacing 10 with N in the above example, and by increasing N, one can increase at will the maximum packet delay and the jitter experienced by the classes in aggregate A. This patch addresses this issue by just using the above 'instantaneous' value of the weight sum, instead of the maximum possible value, when updating the system virtual time. After the instantaneous weight sum is decreased, QFQ+ may deviate from the ideal service for a time interval in the order of the time to serve one maximum-size packet for each backlogged class. The worst-case extent of the deviation exhibited by QFQ+ during this time interval [1] is basically the same as of the deviation described above (but, without this patch, QFQ+ suffers from such a deviation all the time). Finally, this patch modifies the comment to the function qfq_slot_insert, to make it coherent with the fact that the weight sum used by QFQ+ can now be lower than the maximum possible value. [1] P. Valente, "Extending WF2Q+ to support a dynamic traffic mix", Proceedings of AAA-IDEA'05, June 2005. Signed-off-by: Paolo Valente Signed-off-by: David S. Miller --- net/sched/sch_qfq.c | 85 +++++++++++++++++++++++++++++---------------- 1 file changed, 56 insertions(+), 29 deletions(-) diff --git a/net/sched/sch_qfq.c b/net/sched/sch_qfq.c index a7ab323849b6..8056fb4e618a 100644 --- a/net/sched/sch_qfq.c +++ b/net/sched/sch_qfq.c @@ -113,7 +113,6 @@ #define FRAC_BITS 30 /* fixed point arithmetic */ #define ONE_FP (1UL << FRAC_BITS) -#define IWSUM (ONE_FP/QFQ_MAX_WSUM) #define QFQ_MTU_SHIFT 16 /* to support TSO/GSO */ #define QFQ_MIN_LMAX 512 /* see qfq_slot_insert */ @@ -189,6 +188,7 @@ struct qfq_sched { struct qfq_aggregate *in_serv_agg; /* Aggregate being served. */ u32 num_active_agg; /* Num. of active aggregates */ u32 wsum; /* weight sum */ + u32 iwsum; /* inverse weight sum */ unsigned long bitmaps[QFQ_MAX_STATE]; /* Group bitmaps. */ struct qfq_group groups[QFQ_MAX_INDEX + 1]; /* The groups. */ @@ -314,6 +314,7 @@ static void qfq_update_agg(struct qfq_sched *q, struct qfq_aggregate *agg, q->wsum += (int) agg->class_weight * (new_num_classes - agg->num_classes); + q->iwsum = ONE_FP / q->wsum; agg->num_classes = new_num_classes; } @@ -340,6 +341,10 @@ static void qfq_destroy_agg(struct qfq_sched *q, struct qfq_aggregate *agg) { if (!hlist_unhashed(&agg->nonfull_next)) hlist_del_init(&agg->nonfull_next); + q->wsum -= agg->class_weight; + if (q->wsum != 0) + q->iwsum = ONE_FP / q->wsum; + if (q->in_serv_agg == agg) q->in_serv_agg = qfq_choose_next_agg(q); kfree(agg); @@ -834,38 +839,60 @@ static void qfq_make_eligible(struct qfq_sched *q) } } - /* - * The index of the slot in which the aggregate is to be inserted must - * not be higher than QFQ_MAX_SLOTS-2. There is a '-2' and not a '-1' - * because the start time of the group may be moved backward by one - * slot after the aggregate has been inserted, and this would cause - * non-empty slots to be right-shifted by one position. + * The index of the slot in which the input aggregate agg is to be + * inserted must not be higher than QFQ_MAX_SLOTS-2. There is a '-2' + * and not a '-1' because the start time of the group may be moved + * backward by one slot after the aggregate has been inserted, and + * this would cause non-empty slots to be right-shifted by one + * position. * - * If the weight and lmax (max_pkt_size) of the classes do not change, - * then QFQ+ does meet the above contraint according to the current - * values of its parameters. In fact, if the weight and lmax of the - * classes do not change, then, from the theory, QFQ+ guarantees that - * the slot index is never higher than - * 2 + QFQ_MAX_AGG_CLASSES * ((1<budget -= len; - q->V += (u64)len * IWSUM; + q->V += (u64)len * q->iwsum; pr_debug("qfq dequeue: len %u F %lld now %lld\n", len, (unsigned long long) in_serv_agg->F, (unsigned long long) q->V); From 885291761dba2bfe04df4c0f7bb75e4c920ab82e Mon Sep 17 00:00:00 2001 From: Jason Wang Date: Thu, 18 Jul 2013 10:55:15 +0800 Subject: [PATCH 1016/1048] tuntap: do not zerocopy if iov needs more pages than MAX_SKB_FRAGS We try to linearize part of the skb when the number of iov is greater than MAX_SKB_FRAGS. This is not enough since each single vector may occupy more than one pages, so zerocopy_sg_fromiovec() may still fail and may break the guest network. Solve this problem by calculate the pages needed for iov before trying to do zerocopy and switch to use copy instead of zerocopy if it needs more than MAX_SKB_FRAGS. This is done through introducing a new helper to count the pages for iov, and call uarg->callback() manually when switching from zerocopy to copy to notify vhost. We can do further optimization on top. The bug were introduced from commit 0690899b4d4501b3505be069b9a687e68ccbe15b (tun: experimental zero copy tx support) Cc: Michael S. Tsirkin Signed-off-by: Jason Wang Signed-off-by: David S. Miller --- drivers/net/tun.c | 62 +++++++++++++++++++++++++++++------------------ 1 file changed, 38 insertions(+), 24 deletions(-) diff --git a/drivers/net/tun.c b/drivers/net/tun.c index 5cdcf92eb310..db690a372260 100644 --- a/drivers/net/tun.c +++ b/drivers/net/tun.c @@ -1035,6 +1035,29 @@ static int zerocopy_sg_from_iovec(struct sk_buff *skb, const struct iovec *from, return 0; } +static unsigned long iov_pages(const struct iovec *iv, int offset, + unsigned long nr_segs) +{ + unsigned long seg, base; + int pages = 0, len, size; + + while (nr_segs && (offset >= iv->iov_len)) { + offset -= iv->iov_len; + ++iv; + --nr_segs; + } + + for (seg = 0; seg < nr_segs; seg++) { + base = (unsigned long)iv[seg].iov_base + offset; + len = iv[seg].iov_len - offset; + size = ((base & ~PAGE_MASK) + len + ~PAGE_MASK) >> PAGE_SHIFT; + pages += size; + offset = 0; + } + + return pages; +} + /* Get packet from user space buffer */ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile, void *msg_control, const struct iovec *iv, @@ -1082,32 +1105,18 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile, return -EINVAL; } - if (msg_control) - zerocopy = true; - - if (zerocopy) { - /* Userspace may produce vectors with count greater than - * MAX_SKB_FRAGS, so we need to linearize parts of the skb - * to let the rest of data to be fit in the frags. - */ - if (count > MAX_SKB_FRAGS) { - copylen = iov_length(iv, count - MAX_SKB_FRAGS); - if (copylen < offset) - copylen = 0; - else - copylen -= offset; - } else - copylen = 0; - /* There are 256 bytes to be copied in skb, so there is enough - * room for skb expand head in case it is used. + if (msg_control) { + /* There are 256 bytes to be copied in skb, so there is + * enough room for skb expand head in case it is used. * The rest of the buffer is mapped from userspace. */ - if (copylen < gso.hdr_len) - copylen = gso.hdr_len; - if (!copylen) - copylen = GOODCOPY_LEN; + copylen = gso.hdr_len ? gso.hdr_len : GOODCOPY_LEN; linear = copylen; - } else { + if (iov_pages(iv, offset + copylen, count) <= MAX_SKB_FRAGS) + zerocopy = true; + } + + if (!zerocopy) { copylen = len; linear = gso.hdr_len; } @@ -1121,8 +1130,13 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile, if (zerocopy) err = zerocopy_sg_from_iovec(skb, iv, offset, count); - else + else { err = skb_copy_datagram_from_iovec(skb, 0, iv, offset, len); + if (!err && msg_control) { + struct ubuf_info *uarg = msg_control; + uarg->callback(uarg, false); + } + } if (err) { tun->dev->stats.rx_dropped++; From ece793fcfc417b3925844be88a6a6dc82ae8f7c6 Mon Sep 17 00:00:00 2001 From: Jason Wang Date: Thu, 18 Jul 2013 10:55:16 +0800 Subject: [PATCH 1017/1048] macvtap: do not zerocopy if iov needs more pages than MAX_SKB_FRAGS We try to linearize part of the skb when the number of iov is greater than MAX_SKB_FRAGS. This is not enough since each single vector may occupy more than one pages, so zerocopy_sg_fromiovec() may still fail and may break the guest network. Solve this problem by calculate the pages needed for iov before trying to do zerocopy and switch to use copy instead of zerocopy if it needs more than MAX_SKB_FRAGS. This is done through introducing a new helper to count the pages for iov, and call uarg->callback() manually when switching from zerocopy to copy to notify vhost. We can do further optimization on top. This bug were introduced from b92946e2919134ebe2a4083e4302236295ea2a73 (macvtap: zerocopy: validate vectors before building skb). Cc: Michael S. Tsirkin Signed-off-by: Jason Wang Signed-off-by: David S. Miller --- drivers/net/macvtap.c | 62 ++++++++++++++++++++++++++----------------- 1 file changed, 37 insertions(+), 25 deletions(-) diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c index a7c5654a2e5c..a98fb0ed6aef 100644 --- a/drivers/net/macvtap.c +++ b/drivers/net/macvtap.c @@ -698,6 +698,28 @@ static int macvtap_skb_to_vnet_hdr(const struct sk_buff *skb, return 0; } +static unsigned long iov_pages(const struct iovec *iv, int offset, + unsigned long nr_segs) +{ + unsigned long seg, base; + int pages = 0, len, size; + + while (nr_segs && (offset >= iv->iov_len)) { + offset -= iv->iov_len; + ++iv; + --nr_segs; + } + + for (seg = 0; seg < nr_segs; seg++) { + base = (unsigned long)iv[seg].iov_base + offset; + len = iv[seg].iov_len - offset; + size = ((base & ~PAGE_MASK) + len + ~PAGE_MASK) >> PAGE_SHIFT; + pages += size; + offset = 0; + } + + return pages; +} /* Get packet from user space buffer */ static ssize_t macvtap_get_user(struct macvtap_queue *q, struct msghdr *m, @@ -744,31 +766,15 @@ static ssize_t macvtap_get_user(struct macvtap_queue *q, struct msghdr *m, if (unlikely(count > UIO_MAXIOV)) goto err; - if (m && m->msg_control && sock_flag(&q->sk, SOCK_ZEROCOPY)) - zerocopy = true; - - if (zerocopy) { - /* Userspace may produce vectors with count greater than - * MAX_SKB_FRAGS, so we need to linearize parts of the skb - * to let the rest of data to be fit in the frags. - */ - if (count > MAX_SKB_FRAGS) { - copylen = iov_length(iv, count - MAX_SKB_FRAGS); - if (copylen < vnet_hdr_len) - copylen = 0; - else - copylen -= vnet_hdr_len; - } - /* There are 256 bytes to be copied in skb, so there is enough - * room for skb expand head in case it is used. - * The rest buffer is mapped from userspace. - */ - if (copylen < vnet_hdr.hdr_len) - copylen = vnet_hdr.hdr_len; - if (!copylen) - copylen = GOODCOPY_LEN; + if (m && m->msg_control && sock_flag(&q->sk, SOCK_ZEROCOPY)) { + copylen = vnet_hdr.hdr_len ? vnet_hdr.hdr_len : GOODCOPY_LEN; linear = copylen; - } else { + if (iov_pages(iv, vnet_hdr_len + copylen, count) + <= MAX_SKB_FRAGS) + zerocopy = true; + } + + if (!zerocopy) { copylen = len; linear = vnet_hdr.hdr_len; } @@ -780,9 +786,15 @@ static ssize_t macvtap_get_user(struct macvtap_queue *q, struct msghdr *m, if (zerocopy) err = zerocopy_sg_from_iovec(skb, iv, vnet_hdr_len, count); - else + else { err = skb_copy_datagram_from_iovec(skb, 0, iv, vnet_hdr_len, len); + if (!err && m && m->msg_control) { + struct ubuf_info *uarg = m->msg_control; + uarg->callback(uarg, false); + } + } + if (err) goto err_kfree; From d4b812dea4a236f729526facf97df1a9d18e191c Mon Sep 17 00:00:00 2001 From: Eric Dumazet Date: Thu, 18 Jul 2013 07:19:26 -0700 Subject: [PATCH 1018/1048] vlan: mask vlan prio bits In commit 48cc32d38a52d0b68f91a171a8d00531edc6a46e ("vlan: don't deliver frames for unknown vlans to protocols") Florian made sure we set pkt_type to PACKET_OTHERHOST if the vlan id is set and we could find a vlan device for this particular id. But we also have a problem if prio bits are set. Steinar reported an issue on a router receiving IPv6 frames with a vlan tag of 4000 (id 0, prio 2), and tunneled into a sit device, because skb->vlan_tci is set. Forwarded frame is completely corrupted : We can see (8100:4000) being inserted in the middle of IPv6 source address : 16:48:00.780413 IP6 2001:16d8:8100:4000:ee1c:0:9d9:bc87 > 9f94:4d95:2001:67c:29f4::: ICMP6, unknown icmp6 type (0), length 64 0x0000: 0000 0029 8000 c7c3 7103 0001 a0ae e651 0x0010: 0000 0000 ccce 0b00 0000 0000 1011 1213 0x0020: 1415 1617 1819 1a1b 1c1d 1e1f 2021 2223 0x0030: 2425 2627 2829 2a2b 2c2d 2e2f 3031 3233 It seems we are not really ready to properly cope with this right now. We can probably do better in future kernels : vlan_get_ingress_priority() should be a netdev property instead of a per vlan_dev one. For stable kernels, lets clear vlan_tci to fix the bugs. Reported-by: Steinar H. Gunderson Signed-off-by: Eric Dumazet Signed-off-by: David S. Miller --- include/linux/if_vlan.h | 3 +-- net/8021q/vlan_core.c | 2 +- net/core/dev.c | 11 +++++++++-- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/include/linux/if_vlan.h b/include/linux/if_vlan.h index cdcbafa9b39a..715c343f7c00 100644 --- a/include/linux/if_vlan.h +++ b/include/linux/if_vlan.h @@ -79,9 +79,8 @@ static inline int is_vlan_dev(struct net_device *dev) } #define vlan_tx_tag_present(__skb) ((__skb)->vlan_tci & VLAN_TAG_PRESENT) -#define vlan_tx_nonzero_tag_present(__skb) \ - (vlan_tx_tag_present(__skb) && ((__skb)->vlan_tci & VLAN_VID_MASK)) #define vlan_tx_tag_get(__skb) ((__skb)->vlan_tci & ~VLAN_TAG_PRESENT) +#define vlan_tx_tag_get_id(__skb) ((__skb)->vlan_tci & VLAN_VID_MASK) #if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE) diff --git a/net/8021q/vlan_core.c b/net/8021q/vlan_core.c index 8a15eaadc4bd..4a78c4de9f20 100644 --- a/net/8021q/vlan_core.c +++ b/net/8021q/vlan_core.c @@ -9,7 +9,7 @@ bool vlan_do_receive(struct sk_buff **skbp) { struct sk_buff *skb = *skbp; __be16 vlan_proto = skb->vlan_proto; - u16 vlan_id = skb->vlan_tci & VLAN_VID_MASK; + u16 vlan_id = vlan_tx_tag_get_id(skb); struct net_device *vlan_dev; struct vlan_pcpu_stats *rx_stats; diff --git a/net/core/dev.c b/net/core/dev.c index a3d8d44cb7f4..26755dd40daa 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -3580,8 +3580,15 @@ ncls: } } - if (vlan_tx_nonzero_tag_present(skb)) - skb->pkt_type = PACKET_OTHERHOST; + if (unlikely(vlan_tx_tag_present(skb))) { + if (vlan_tx_tag_get_id(skb)) + skb->pkt_type = PACKET_OTHERHOST; + /* Note: we might in the future use prio bits + * and set skb->priority like in vlan_do_receive() + * For the time being, just ignore Priority Code Point + */ + skb->vlan_tci = 0; + } /* deliver only exact match when indicated */ null_or_dev = deliver_exact ? skb->dev : NULL; From 3e3aac497513c669e1c62c71e1d552ea85c1d974 Mon Sep 17 00:00:00 2001 From: Eric Dumazet Date: Thu, 18 Jul 2013 09:35:10 -0700 Subject: [PATCH 1019/1048] vlan: fix a race in egress prio management egress_priority_map[] hash table updates are protected by rtnl, and we never remove elements until device is dismantled. We have to make sure that before inserting an new element in hash table, all its fields are committed to memory or else another cpu could find corrupt values and crash. Signed-off-by: Eric Dumazet Cc: Patrick McHardy Signed-off-by: David S. Miller --- net/8021q/vlan_dev.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c index 3a8c8fd63c88..1cd3d2a406f5 100644 --- a/net/8021q/vlan_dev.c +++ b/net/8021q/vlan_dev.c @@ -73,6 +73,8 @@ vlan_dev_get_egress_qos_mask(struct net_device *dev, struct sk_buff *skb) { struct vlan_priority_tci_mapping *mp; + smp_rmb(); /* coupled with smp_wmb() in vlan_dev_set_egress_priority() */ + mp = vlan_dev_priv(dev)->egress_priority_map[(skb->priority & 0xF)]; while (mp) { if (mp->priority == skb->priority) { @@ -249,6 +251,11 @@ int vlan_dev_set_egress_priority(const struct net_device *dev, np->next = mp; np->priority = skb_prio; np->vlan_qos = vlan_qos; + /* Before inserting this element in hash table, make sure all its fields + * are committed to memory. + * coupled with smp_rmb() in vlan_dev_get_egress_qos_mask() + */ + smp_wmb(); vlan->egress_priority_map[skb_prio & 0xF] = np; if (vlan_qos) vlan->nr_egress_mappings++; From 9da3545d827cdb9163697a1dc4471fbb5540e85f Mon Sep 17 00:00:00 2001 From: Ingo Tuchscherer Date: Thu, 18 Jul 2013 16:28:26 +0200 Subject: [PATCH 1020/1048] s390/zcrypt: Alias for new zcrypt device driver base module The zcrypt device driver has been split into base/bus module, api-module, card modules and message type modules. The base module has been renamed from z90crypt to ap. A module alias (with the well-known z90crypt identifier) will be introduced that enable users to use their existing way to load the zcrypt device driver. Signed-off-by: Ingo Tuchscherer Signed-off-by: Martin Schwidefsky --- drivers/s390/crypto/ap_bus.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/s390/crypto/ap_bus.c b/drivers/s390/crypto/ap_bus.c index f446a7705c3b..d4174b82a1a9 100644 --- a/drivers/s390/crypto/ap_bus.c +++ b/drivers/s390/crypto/ap_bus.c @@ -71,6 +71,7 @@ MODULE_AUTHOR("IBM Corporation"); MODULE_DESCRIPTION("Adjunct Processor Bus driver, " \ "Copyright IBM Corp. 2006, 2012"); MODULE_LICENSE("GPL"); +MODULE_ALIAS("z90crypt"); /* * Module parameter From 976f39b139cdd06a88a5aadd8202b0c30cac9cda Mon Sep 17 00:00:00 2001 From: Florian Fainelli Date: Wed, 17 Jul 2013 17:56:31 +0000 Subject: [PATCH 1021/1048] MIPS: BMIPS: Fix thinko to release slave TP from reset Commit 4df715aa ["MIPS: BMIPS: support booting from physical CPU other than 0"] introduced a thinko which will prevents slave CPUs from being released from reset on systems where we boot from TP0. The problem is that we are checking whether the slave CPU logical CPU map is 0, which is never true for systems booting from TP0, so we do not release the slave TP from reset and we are just stuck. Fix this by properly checking that the CPU we intend to boot really is the physical slave CPU (logical and physical value being 1). Signed-off-by: Florian Fainelli Cc: linux-mips@linux-mips.org Cc: blogic@openwrt.org Cc: jogo@openwrt.org Cc: cernekee@gmail.com Cc: Florian Fainelli Patchwork: https://patchwork.linux-mips.org/patch/5598/ Signed-off-by: Ralf Baechle --- arch/mips/kernel/smp-bmips.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/mips/kernel/smp-bmips.c b/arch/mips/kernel/smp-bmips.c index aea6c0885838..67445374014f 100644 --- a/arch/mips/kernel/smp-bmips.c +++ b/arch/mips/kernel/smp-bmips.c @@ -173,7 +173,7 @@ static void bmips_boot_secondary(int cpu, struct task_struct *idle) else { #if defined(CONFIG_CPU_BMIPS4350) || defined(CONFIG_CPU_BMIPS4380) /* Reset slave TP1 if booting from TP0 */ - if (cpu_logical_map(cpu) == 0) + if (cpu_logical_map(cpu) == 1) set_c0_brcm_cmt_ctrl(0x01); #elif defined(CONFIG_CPU_BMIPS5000) if (cpu & 0x01) From afc813ae6d01eb4bb03fe67ed74c76608e3db089 Mon Sep 17 00:00:00 2001 From: Tony Wu Date: Thu, 18 Jul 2013 09:45:47 +0000 Subject: [PATCH 1022/1048] MIPS: tlbex: Fix typo in r3000 tlb store handler commit 6ba045f (MIPS: Move generated code to .text for microMIPS) causes a panic at boot. The handler builder should test against handle_tlbs_end, not handle_tlbs. Signed-off-by: Tony Wu Acked-by: Jayachandran C. Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/5600/ Signed-off-by: Ralf Baechle --- arch/mips/mm/tlbex.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/mips/mm/tlbex.c b/arch/mips/mm/tlbex.c index 9ab0f907a52c..605b6fc13697 100644 --- a/arch/mips/mm/tlbex.c +++ b/arch/mips/mm/tlbex.c @@ -1803,7 +1803,7 @@ static void __cpuinit build_r3000_tlb_store_handler(void) uasm_i_j(&p, (unsigned long)tlb_do_page_fault_1 & 0x0fffffff); uasm_i_nop(&p); - if (p >= handle_tlbs) + if (p >= handle_tlbs_end) panic("TLB store handler fastpath space exceeded"); uasm_resolve_relocs(relocs, labels); From 35ac7840bca23a0fcfb53cc433ae1fd6dc6d35c0 Mon Sep 17 00:00:00 2001 From: Ganesan Ramalingam Date: Wed, 17 Jul 2013 10:27:25 +0000 Subject: [PATCH 1023/1048] MIPS: Netlogic: Fix USB block's coherent DMA mask The on-chip USB controller on Netlogic XLP does not suppport DMA beyond 32-bit physical address. Set the coherent_dma_mask of the USB in its PCI fixup to support this. Signed-off-by: Ganesan Ramalingam Signed-off-by: Jayachandran C. Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/5596/ Signed-off-by: Ralf Baechle --- arch/mips/netlogic/xlp/usb-init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/mips/netlogic/xlp/usb-init.c b/arch/mips/netlogic/xlp/usb-init.c index 9c401dd78337..ef3897ef0dc7 100644 --- a/arch/mips/netlogic/xlp/usb-init.c +++ b/arch/mips/netlogic/xlp/usb-init.c @@ -119,7 +119,7 @@ static u64 xlp_usb_dmamask = ~(u32)0; static void nlm_usb_fixup_final(struct pci_dev *dev) { dev->dev.dma_mask = &xlp_usb_dmamask; - dev->dev.coherent_dma_mask = DMA_BIT_MASK(64); + dev->dev.coherent_dma_mask = DMA_BIT_MASK(32); switch (dev->devfn) { case 0x10: dev->irq = PIC_EHCI_0_IRQ; From 628f0650ea65ef2ec0a2bde141c271dea1d18904 Mon Sep 17 00:00:00 2001 From: Jayachandran C Date: Wed, 17 Jul 2013 10:27:26 +0000 Subject: [PATCH 1024/1048] MIPS: Netlogic: Add XLP PIC irqdomain Add a legacy irq domain for the XLP PIC interrupts. This will be used when interrupts are assigned from the device tree. This change is required after commit c5cdc67 "irqdomain: Remove temporary MIPS workaround code". Signed-off-by: Jayachandran C Cc: linux-mips@linux-mips.org Cc: Jayachandran C Patchwork: https://patchwork.linux-mips.org/patch/5597/ Signed-off-by: Ralf Baechle --- arch/mips/netlogic/common/irq.c | 68 +++++++++++++++++++++++++----- arch/mips/netlogic/dts/xlp_evp.dts | 3 +- arch/mips/netlogic/dts/xlp_svp.dts | 3 +- 3 files changed, 61 insertions(+), 13 deletions(-) diff --git a/arch/mips/netlogic/common/irq.c b/arch/mips/netlogic/common/irq.c index 73facb2b33bb..1c7e3a1b81ab 100644 --- a/arch/mips/netlogic/common/irq.c +++ b/arch/mips/netlogic/common/irq.c @@ -40,6 +40,10 @@ #include #include +#include +#include +#include + #include #include #include @@ -223,17 +227,6 @@ static void nlm_init_node_irqs(int node) nodep->irqmask = irqmask; } -void __init arch_init_irq(void) -{ - /* Initialize the irq descriptors */ - nlm_init_percpu_irqs(); - nlm_init_node_irqs(0); - write_c0_eimr(nlm_current_node()->irqmask); -#if defined(CONFIG_CPU_XLR) - nlm_setup_fmn_irq(); -#endif -} - void nlm_smp_irq_init(int hwcpuid) { int node, cpu; @@ -266,3 +259,56 @@ asmlinkage void plat_irq_dispatch(void) /* top level irq handling */ do_IRQ(nlm_irq_to_xirq(node, i)); } + +#ifdef CONFIG_OF +static struct irq_domain *xlp_pic_domain; + +static const struct irq_domain_ops xlp_pic_irq_domain_ops = { + .xlate = irq_domain_xlate_onetwocell, +}; + +static int __init xlp_of_pic_init(struct device_node *node, + struct device_node *parent) +{ + const int n_picirqs = PIC_IRT_LAST_IRQ - PIC_IRQ_BASE + 1; + struct resource res; + int socid, ret; + + /* we need a hack to get the PIC's SoC chip id */ + ret = of_address_to_resource(node, 0, &res); + if (ret < 0) { + pr_err("PIC %s: reg property not found!\n", node->name); + return -EINVAL; + } + socid = (res.start >> 18) & 0x3; + xlp_pic_domain = irq_domain_add_legacy(node, n_picirqs, + nlm_irq_to_xirq(socid, PIC_IRQ_BASE), PIC_IRQ_BASE, + &xlp_pic_irq_domain_ops, NULL); + if (xlp_pic_domain == NULL) { + pr_err("PIC %s: Creating legacy domain failed!\n", node->name); + return -EINVAL; + } + pr_info("Node %d: IRQ domain created for PIC@%pa\n", socid, + &res.start); + return 0; +} + +static struct of_device_id __initdata xlp_pic_irq_ids[] = { + { .compatible = "netlogic,xlp-pic", .data = xlp_of_pic_init }, + {}, +}; +#endif + +void __init arch_init_irq(void) +{ + /* Initialize the irq descriptors */ + nlm_init_percpu_irqs(); + nlm_init_node_irqs(0); + write_c0_eimr(nlm_current_node()->irqmask); +#if defined(CONFIG_CPU_XLR) + nlm_setup_fmn_irq(); +#endif +#if defined(CONFIG_OF) + of_irq_init(xlp_pic_irq_ids); +#endif +} diff --git a/arch/mips/netlogic/dts/xlp_evp.dts b/arch/mips/netlogic/dts/xlp_evp.dts index e14f42308064..06407033678e 100644 --- a/arch/mips/netlogic/dts/xlp_evp.dts +++ b/arch/mips/netlogic/dts/xlp_evp.dts @@ -76,10 +76,11 @@ }; }; pic: pic@4000 { - interrupt-controller; + compatible = "netlogic,xlp-pic"; #address-cells = <0>; #interrupt-cells = <1>; reg = <0 0x4000 0x200>; + interrupt-controller; }; nor_flash@1,0 { diff --git a/arch/mips/netlogic/dts/xlp_svp.dts b/arch/mips/netlogic/dts/xlp_svp.dts index 8af4bdbe5d99..9c5db102df53 100644 --- a/arch/mips/netlogic/dts/xlp_svp.dts +++ b/arch/mips/netlogic/dts/xlp_svp.dts @@ -76,10 +76,11 @@ }; }; pic: pic@4000 { - interrupt-controller; + compatible = "netlogic,xlp-pic"; #address-cells = <0>; #interrupt-cells = <1>; reg = <0 0x4000 0x200>; + interrupt-controller; }; nor_flash@1,0 { From 38a997a70e6cf0ee9fc26de146601ba10fa552a4 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Mon, 15 Jul 2013 07:21:57 +0000 Subject: [PATCH 1025/1048] MIPS: tlbex: fix broken build in v3.11-rc1 Commit 6ba045f9fbdafb48da42aa8576ea7a3980443136 (MIPS: Move generated code to .text for microMIPS) deleted tlbmiss_handler_setup_pgd_array, but some references were not converted. Fix that to enable building a MIPS kernel. Signed-off-by: Aaro Koskinen Acked-by: Jayachandran C. Acked-by: David Daney Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/5589/ Signed-off-by: Ralf Baechle --- arch/mips/mm/tlbex.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/mips/mm/tlbex.c b/arch/mips/mm/tlbex.c index 605b6fc13697..523775d7a20e 100644 --- a/arch/mips/mm/tlbex.c +++ b/arch/mips/mm/tlbex.c @@ -1466,7 +1466,7 @@ static void __cpuinit build_r4000_setup_pgd(void) { const int a0 = 4; const int a1 = 5; - u32 *p = tlbmiss_handler_setup_pgd_array; + u32 *p = tlbmiss_handler_setup_pgd; const int tlbmiss_handler_setup_pgd_size = tlbmiss_handler_setup_pgd_end - tlbmiss_handler_setup_pgd; struct uasm_label *l = labels; From f2a5b1d78c076c525d20176d227faf2e6a20257c Mon Sep 17 00:00:00 2001 From: James Hogan Date: Fri, 12 Jul 2013 10:26:11 +0000 Subject: [PATCH 1026/1048] MIPS: KVM: Mark KVM_GUEST (T&E KVM) as BROKEN_ON_SMP Make KVM_GUEST depend on BROKEN_ON_SMP so that it cannot be enabled with SMP. SMP kernels use ll/sc instructions for an atomic section in the tlb fill handler, with a tlbp instruction contained in the middle. This cannot be emulated with trap & emulate KVM because the tlbp instruction traps and the eret to return to the guest code clears the LLbit which makes the sc instruction always fail. Signed-off-by: James Hogan Cc: Sanjay Lal Cc: Ralf Baechle Cc: David Daney Cc: linux-mips@linux-mips.org Cc: kvm@vger.kernel.org Patchwork: https://patchwork.linux-mips.org/patch/5588/ Signed-off-by: Ralf Baechle --- arch/mips/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig index 4758a8fd3e99..c3abed332301 100644 --- a/arch/mips/Kconfig +++ b/arch/mips/Kconfig @@ -1702,6 +1702,7 @@ endchoice config KVM_GUEST bool "KVM Guest Kernel" + depends on BROKEN_ON_SMP help Select this option if building a guest kernel for KVM (Trap & Emulate) mode From 3179ce7254ffa43f3ba4409f31a954ecc4a8d408 Mon Sep 17 00:00:00 2001 From: Richard Weinberger Date: Sat, 11 May 2013 15:35:32 +0200 Subject: [PATCH 1027/1048] um: Fix return value of strnlen_user() In case of an error it must not return -EFAULT. Return 0 like all other archs do. Reported-by: toralf.foerster@gmx.de Signed-off-by: Richard Weinberger --- arch/um/kernel/skas/uaccess.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/um/kernel/skas/uaccess.c b/arch/um/kernel/skas/uaccess.c index 1d3e0c17340b..4ffb644d6c07 100644 --- a/arch/um/kernel/skas/uaccess.c +++ b/arch/um/kernel/skas/uaccess.c @@ -254,6 +254,6 @@ int strnlen_user(const void __user *str, int len) n = buffer_op((unsigned long) str, len, 0, strnlen_chunk, &count); if (n == 0) return count + 1; - return -EFAULT; + return 0; } EXPORT_SYMBOL(strnlen_user); From dee20035b42d569984d2c16041b51e4d75e233b5 Mon Sep 17 00:00:00 2001 From: Richard Weinberger Date: Sun, 12 May 2013 23:26:03 +0200 Subject: [PATCH 1028/1048] um: Mark stub pages mapping with VM_PFNMAP Ensure that a process cannot destroy his stub pages with using MADV_DONTNEED and friends. Reported-by: toralf.foerster@gmx.de Signed-off-by: Richard Weinberger --- arch/um/kernel/skas/mmu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/um/kernel/skas/mmu.c b/arch/um/kernel/skas/mmu.c index ff03067a3b14..007d5503f49b 100644 --- a/arch/um/kernel/skas/mmu.c +++ b/arch/um/kernel/skas/mmu.c @@ -123,7 +123,7 @@ void uml_setup_stubs(struct mm_struct *mm) /* dup_mmap already holds mmap_sem */ err = install_special_mapping(mm, STUB_START, STUB_END - STUB_START, VM_READ | VM_MAYREAD | VM_EXEC | - VM_MAYEXEC | VM_DONTCOPY, + VM_MAYEXEC | VM_DONTCOPY | VM_PFNMAP, mm->context.stub_pages); if (err) { printk(KERN_ERR "install_special_mapping returned %d\n", err); From 0974a9cadc7886f7baaa458bb0c89f5c5f9d458e Mon Sep 17 00:00:00 2001 From: Richard Weinberger Date: Fri, 17 May 2013 14:21:01 +0200 Subject: [PATCH 1029/1048] um: Fix wait_stub_done() error handling If we die within a stub handler we only way to reliable kill the (obviously) dying uml guest process is killing it's host twin on the host side. Signed-off-by: Richard Weinberger --- arch/um/os-Linux/skas/process.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/arch/um/os-Linux/skas/process.c b/arch/um/os-Linux/skas/process.c index 4625949bf1e4..441e4ba074f4 100644 --- a/arch/um/os-Linux/skas/process.c +++ b/arch/um/os-Linux/skas/process.c @@ -54,7 +54,7 @@ static int ptrace_dump_regs(int pid) void wait_stub_done(int pid) { - int n, status, err; + int n, status, err, bad_stop = 0; while (1) { CATCH_EINTR(n = waitpid(pid, &status, WUNTRACED | __WALL)); @@ -74,6 +74,8 @@ void wait_stub_done(int pid) if (((1 << WSTOPSIG(status)) & STUB_DONE_MASK) != 0) return; + else + bad_stop = 1; bad_wait: err = ptrace_dump_regs(pid); @@ -83,7 +85,10 @@ bad_wait: printk(UM_KERN_ERR "wait_stub_done : failed to wait for SIGTRAP, " "pid = %d, n = %d, errno = %d, status = 0x%x\n", pid, n, errno, status); - fatal_sigsegv(); + if (bad_stop) + kill(pid, SIGKILL); + else + fatal_sigsegv(); } extern unsigned long current_stub_stack(void); From 7473534130c3156d199512c99ff1b796233e8547 Mon Sep 17 00:00:00 2001 From: Tristan Schmelcher Date: Mon, 8 Jul 2013 16:19:49 -0400 Subject: [PATCH 1030/1048] uml: Fix which_tmpdir failure when /dev/shm is a symlink, and in other edge cases which_tmpdir did the wrong thing if /dev/shm was a symlink (e.g., to /run/shm), if there were multiple mounts on top of each other, if the mount(s) were obscured by a later mount, or if /dev/shm was a prefix of another mount point. This fixes these cases. Applies to 3.9.6. Signed-off-by: Tristan Schmelcher Signed-off-by: Richard Weinberger --- arch/um/os-Linux/mem.c | 230 +++++++++++++++++++++++++++++++++-------- 1 file changed, 189 insertions(+), 41 deletions(-) diff --git a/arch/um/os-Linux/mem.c b/arch/um/os-Linux/mem.c index ba4398056fe9..3c4af77e51a2 100644 --- a/arch/um/os-Linux/mem.c +++ b/arch/um/os-Linux/mem.c @@ -52,6 +52,25 @@ static void __init find_tempdir(void) strcat(tempdir, "/"); } +/* + * Remove bytes from the front of the buffer and refill it so that if there's a + * partial string that we care about, it will be completed, and we can recognize + * it. + */ +static int pop(int fd, char *buf, size_t size, size_t npop) +{ + ssize_t n; + size_t len = strlen(&buf[npop]); + + memmove(buf, &buf[npop], len + 1); + n = read(fd, &buf[len], size - len - 1); + if (n < 0) + return -errno; + + buf[len + n] = '\0'; + return 1; +} + /* * This will return 1, with the first character in buf being the * character following the next instance of c in the file. This will @@ -61,7 +80,6 @@ static void __init find_tempdir(void) static int next(int fd, char *buf, size_t size, char c) { ssize_t n; - size_t len; char *ptr; while ((ptr = strchr(buf, c)) == NULL) { @@ -74,20 +92,129 @@ static int next(int fd, char *buf, size_t size, char c) buf[n] = '\0'; } - ptr++; - len = strlen(ptr); - memmove(buf, ptr, len + 1); + return pop(fd, buf, size, ptr - buf + 1); +} + +/* + * Decode an octal-escaped and space-terminated path of the form used by + * /proc/mounts. May be used to decode a path in-place. "out" must be at least + * as large as the input. The output is always null-terminated. "len" gets the + * length of the output, excluding the trailing null. Returns 0 if a full path + * was successfully decoded, otherwise an error. + */ +static int decode_path(const char *in, char *out, size_t *len) +{ + char *first = out; + int c; + int i; + int ret = -EINVAL; + while (1) { + switch (*in) { + case '\0': + goto out; + + case ' ': + ret = 0; + goto out; + + case '\\': + in++; + c = 0; + for (i = 0; i < 3; i++) { + if (*in < '0' || *in > '7') + goto out; + c = (c << 3) | (*in++ - '0'); + } + *(unsigned char *)out++ = (unsigned char) c; + break; + + default: + *out++ = *in++; + break; + } + } + +out: + *out = '\0'; + *len = out - first; + return ret; +} + +/* + * Computes the length of s when encoded with three-digit octal escape sequences + * for the characters in chars. + */ +static size_t octal_encoded_length(const char *s, const char *chars) +{ + size_t len = strlen(s); + while ((s = strpbrk(s, chars)) != NULL) { + len += 3; + s++; + } + + return len; +} + +enum { + OUTCOME_NOTHING_MOUNTED, + OUTCOME_TMPFS_MOUNT, + OUTCOME_NON_TMPFS_MOUNT, +}; + +/* Read a line of /proc/mounts data looking for a tmpfs mount at "path". */ +static int read_mount(int fd, char *buf, size_t bufsize, const char *path, + int *outcome) +{ + int found; + int match; + char *space; + size_t len; + + enum { + MATCH_NONE, + MATCH_EXACT, + MATCH_PARENT, + }; + + found = next(fd, buf, bufsize, ' '); + if (found != 1) + return found; /* - * Refill the buffer so that if there's a partial string that we care - * about, it will be completed, and we can recognize it. + * If there's no following space in the buffer, then this path is + * truncated, so it can't be the one we're looking for. */ - n = read(fd, &buf[len], size - len - 1); - if (n < 0) - return -errno; + space = strchr(buf, ' '); + if (space) { + match = MATCH_NONE; + if (!decode_path(buf, buf, &len)) { + if (!strcmp(buf, path)) + match = MATCH_EXACT; + else if (!strncmp(buf, path, len) + && (path[len] == '/' || !strcmp(buf, "/"))) + match = MATCH_PARENT; + } - buf[len + n] = '\0'; - return 1; + found = pop(fd, buf, bufsize, space - buf + 1); + if (found != 1) + return found; + + switch (match) { + case MATCH_EXACT: + if (!strncmp(buf, "tmpfs", strlen("tmpfs"))) + *outcome = OUTCOME_TMPFS_MOUNT; + else + *outcome = OUTCOME_NON_TMPFS_MOUNT; + break; + + case MATCH_PARENT: + /* This mount obscures any previous ones. */ + *outcome = OUTCOME_NOTHING_MOUNTED; + break; + } + } + + return next(fd, buf, bufsize, '\n'); } /* which_tmpdir is called only during early boot */ @@ -106,8 +233,12 @@ static int checked_tmpdir = 0; */ static void which_tmpdir(void) { - int fd, found; - char buf[128] = { '\0' }; + int fd; + int found; + int outcome; + char *path; + char *buf; + size_t bufsize; if (checked_tmpdir) return; @@ -116,49 +247,66 @@ static void which_tmpdir(void) printf("Checking for tmpfs mount on /dev/shm..."); + path = realpath("/dev/shm", NULL); + if (!path) { + printf("failed to check real path, errno = %d\n", errno); + return; + } + printf("%s...", path); + + /* + * The buffer needs to be able to fit the full octal-escaped path, a + * space, and a trailing null in order to successfully decode it. + */ + bufsize = octal_encoded_length(path, " \t\n\\") + 2; + + if (bufsize < 128) + bufsize = 128; + + buf = malloc(bufsize); + if (!buf) { + printf("malloc failed, errno = %d\n", errno); + goto out; + } + buf[0] = '\0'; + fd = open("/proc/mounts", O_RDONLY); if (fd < 0) { printf("failed to open /proc/mounts, errno = %d\n", errno); - return; + goto out1; } + outcome = OUTCOME_NOTHING_MOUNTED; while (1) { - found = next(fd, buf, ARRAY_SIZE(buf), ' '); - if (found != 1) - break; - - if (!strncmp(buf, "/dev/shm", strlen("/dev/shm"))) - goto found; - - found = next(fd, buf, ARRAY_SIZE(buf), '\n'); + found = read_mount(fd, buf, bufsize, path, &outcome); if (found != 1) break; } -err: - if (found == 0) - printf("nothing mounted on /dev/shm\n"); - else if (found < 0) + if (found < 0) { printf("read returned errno %d\n", -found); + } else { + switch (outcome) { + case OUTCOME_TMPFS_MOUNT: + printf("OK\n"); + default_tmpdir = "/dev/shm"; + break; -out: - close(fd); + case OUTCOME_NON_TMPFS_MOUNT: + printf("not tmpfs\n"); + break; - return; - -found: - found = next(fd, buf, ARRAY_SIZE(buf), ' '); - if (found != 1) - goto err; - - if (strncmp(buf, "tmpfs", strlen("tmpfs"))) { - printf("not tmpfs\n"); - goto out; + default: + printf("nothing mounted on /dev/shm\n"); + break; + } } - printf("OK\n"); - default_tmpdir = "/dev/shm"; - goto out; + close(fd); +out1: + free(buf); +out: + free(path); } static int __init make_tempfile(const char *template, char **out_tempname, From ab2bb148c5932712d2717a7f3a452846f07a660a Mon Sep 17 00:00:00 2001 From: Faidon Liambotis Date: Thu, 11 Jul 2013 21:08:09 +0000 Subject: [PATCH 1031/1048] MIPS: Octeon: Fix DT pruning bug with pip ports During the pruning of the device tree octeon_fdt_pip_iface() is called for each PIP interface and every port up to the port count is removed from the device tree. However, the count was set to the return value of cvmx_helper_interface_enumerate() which doesn't actually return the count but just returns zero on success. This effectively removed *all* ports from the tree. Use cvmx_helper_ports_on_interface() instead to fix this. This successfully restores the 3 ports of my ERLite-3 and fixes the "kernel assigns random MAC addresses" issue. Signed-off-by: Faidon Liambotis Tested-by: Aaro Koskinen Acked-by: David Daney Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/5587/ Signed-off-by: Ralf Baechle --- arch/mips/cavium-octeon/octeon-platform.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/arch/mips/cavium-octeon/octeon-platform.c b/arch/mips/cavium-octeon/octeon-platform.c index 7b746e7bf7a1..1830874ff1e2 100644 --- a/arch/mips/cavium-octeon/octeon-platform.c +++ b/arch/mips/cavium-octeon/octeon-platform.c @@ -334,9 +334,10 @@ static void __init octeon_fdt_pip_iface(int pip, int idx, u64 *pmac) char name_buffer[20]; int iface; int p; - int count; + int count = 0; - count = cvmx_helper_interface_enumerate(idx); + if (cvmx_helper_interface_enumerate(idx) == 0) + count = cvmx_helper_ports_on_interface(idx); snprintf(name_buffer, sizeof(name_buffer), "interface@%d", idx); iface = fdt_subnode_offset(initial_boot_params, pip, name_buffer); From 9a8c1359571c5d5e2fbc43cf457a6486b70a70cb Mon Sep 17 00:00:00 2001 From: Richard Weinberger Date: Fri, 19 Jul 2013 11:31:36 +0200 Subject: [PATCH 1032/1048] um: siginfo cleanup Currently we use both struct siginfo and siginfo_t. Let's use struct siginfo internally to avoid ongoing compiler warning. We are allowed to do so because struct siginfo and siginfo_t are equivalent. Signed-off-by: Richard Weinberger --- arch/um/include/shared/frame_kern.h | 8 ++++---- arch/um/kernel/signal.c | 4 ++-- arch/um/os-Linux/signal.c | 8 ++++---- arch/um/os-Linux/skas/process.c | 10 +++++----- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/arch/um/include/shared/frame_kern.h b/arch/um/include/shared/frame_kern.h index e584e40ee832..f2ca5702a4e2 100644 --- a/arch/um/include/shared/frame_kern.h +++ b/arch/um/include/shared/frame_kern.h @@ -6,13 +6,13 @@ #ifndef __FRAME_KERN_H_ #define __FRAME_KERN_H_ -extern int setup_signal_stack_sc(unsigned long stack_top, int sig, +extern int setup_signal_stack_sc(unsigned long stack_top, int sig, struct k_sigaction *ka, - struct pt_regs *regs, + struct pt_regs *regs, sigset_t *mask); -extern int setup_signal_stack_si(unsigned long stack_top, int sig, +extern int setup_signal_stack_si(unsigned long stack_top, int sig, struct k_sigaction *ka, - struct pt_regs *regs, siginfo_t *info, + struct pt_regs *regs, struct siginfo *info, sigset_t *mask); #endif diff --git a/arch/um/kernel/signal.c b/arch/um/kernel/signal.c index 3e831b3fd07b..f57e02e7910f 100644 --- a/arch/um/kernel/signal.c +++ b/arch/um/kernel/signal.c @@ -19,7 +19,7 @@ EXPORT_SYMBOL(unblock_signals); * OK, we're invoking a handler */ static void handle_signal(struct pt_regs *regs, unsigned long signr, - struct k_sigaction *ka, siginfo_t *info) + struct k_sigaction *ka, struct siginfo *info) { sigset_t *oldset = sigmask_to_save(); int singlestep = 0; @@ -71,7 +71,7 @@ static void handle_signal(struct pt_regs *regs, unsigned long signr, static int kern_do_signal(struct pt_regs *regs) { struct k_sigaction ka_copy; - siginfo_t info; + struct siginfo info; int sig, handled_sig = 0; while ((sig = get_signal_to_deliver(&info, &ka_copy, regs, NULL)) > 0) { diff --git a/arch/um/os-Linux/signal.c b/arch/um/os-Linux/signal.c index 9d9f1b4bf826..905924b773d3 100644 --- a/arch/um/os-Linux/signal.c +++ b/arch/um/os-Linux/signal.c @@ -25,7 +25,7 @@ void (*sig_info[NSIG])(int, struct siginfo *, struct uml_pt_regs *) = { [SIGIO] = sigio_handler, [SIGVTALRM] = timer_handler }; -static void sig_handler_common(int sig, siginfo_t *si, mcontext_t *mc) +static void sig_handler_common(int sig, struct siginfo *si, mcontext_t *mc) { struct uml_pt_regs r; int save_errno = errno; @@ -61,7 +61,7 @@ static void sig_handler_common(int sig, siginfo_t *si, mcontext_t *mc) static int signals_enabled; static unsigned int signals_pending; -void sig_handler(int sig, siginfo_t *si, mcontext_t *mc) +void sig_handler(int sig, struct siginfo *si, mcontext_t *mc) { int enabled; @@ -120,7 +120,7 @@ void set_sigstack(void *sig_stack, int size) panic("enabling signal stack failed, errno = %d\n", errno); } -static void (*handlers[_NSIG])(int sig, siginfo_t *si, mcontext_t *mc) = { +static void (*handlers[_NSIG])(int sig, struct siginfo *si, mcontext_t *mc) = { [SIGSEGV] = sig_handler, [SIGBUS] = sig_handler, [SIGILL] = sig_handler, @@ -162,7 +162,7 @@ static void hard_handler(int sig, siginfo_t *si, void *p) while ((sig = ffs(pending)) != 0){ sig--; pending &= ~(1 << sig); - (*handlers[sig])(sig, si, mc); + (*handlers[sig])(sig, (struct siginfo *)si, mc); } /* diff --git a/arch/um/os-Linux/skas/process.c b/arch/um/os-Linux/skas/process.c index 441e4ba074f4..d531879a4617 100644 --- a/arch/um/os-Linux/skas/process.c +++ b/arch/um/os-Linux/skas/process.c @@ -414,7 +414,7 @@ void userspace(struct uml_pt_regs *regs) if (WIFSTOPPED(status)) { int sig = WSTOPSIG(status); - ptrace(PTRACE_GETSIGINFO, pid, 0, &si); + ptrace(PTRACE_GETSIGINFO, pid, 0, (struct siginfo *)&si); switch (sig) { case SIGSEGV: @@ -422,7 +422,7 @@ void userspace(struct uml_pt_regs *regs) !ptrace_faultinfo) { get_skas_faultinfo(pid, ®s->faultinfo); - (*sig_info[SIGSEGV])(SIGSEGV, &si, + (*sig_info[SIGSEGV])(SIGSEGV, (struct siginfo *)&si, regs); } else handle_segv(pid, regs); @@ -431,14 +431,14 @@ void userspace(struct uml_pt_regs *regs) handle_trap(pid, regs, local_using_sysemu); break; case SIGTRAP: - relay_signal(SIGTRAP, &si, regs); + relay_signal(SIGTRAP, (struct siginfo *)&si, regs); break; case SIGVTALRM: now = os_nsecs(); if (now < nsecs) break; block_signals(); - (*sig_info[sig])(sig, &si, regs); + (*sig_info[sig])(sig, (struct siginfo *)&si, regs); unblock_signals(); nsecs = timer.it_value.tv_sec * UM_NSEC_PER_SEC + @@ -452,7 +452,7 @@ void userspace(struct uml_pt_regs *regs) case SIGFPE: case SIGWINCH: block_signals(); - (*sig_info[sig])(sig, &si, regs); + (*sig_info[sig])(sig, (struct siginfo *)&si, regs); unblock_signals(); break; default: From 9e82d450531c79b18ab18c9b9645cdd9db31ee98 Mon Sep 17 00:00:00 2001 From: Richard Weinberger Date: Fri, 19 Jul 2013 11:35:32 +0200 Subject: [PATCH 1033/1048] um: remove dead code "me" is not used. Signed-off-by: Richard Weinberger --- arch/x86/um/signal.c | 1 - 1 file changed, 1 deletion(-) diff --git a/arch/x86/um/signal.c b/arch/x86/um/signal.c index ae7319db18ee..5e04a1c899fa 100644 --- a/arch/x86/um/signal.c +++ b/arch/x86/um/signal.c @@ -508,7 +508,6 @@ int setup_signal_stack_si(unsigned long stack_top, int sig, { struct rt_sigframe __user *frame; int err = 0; - struct task_struct *me = current; frame = (struct rt_sigframe __user *) round_down(stack_top - sizeof(struct rt_sigframe), 16); From f1b7001903dd5a80bdc9f777d2a741ccfd22ed4e Mon Sep 17 00:00:00 2001 From: Markos Chandras Date: Tue, 11 Jun 2013 09:02:33 +0000 Subject: [PATCH 1034/1048] MIPS: kvm: Kconfig: Drop HAVE_KVM dependency from VIRTUALIZATION Virtualization does not always need KVM capabilities so drop the dependency. The KVM symbol already depends on HAVE_KVM. Fixes the following problem on a randconfig: warning: (REMOTEPROC && RPMSG) selects VIRTUALIZATION which has unmet direct dependencies (HAVE_KVM) warning: (REMOTEPROC && RPMSG) selects VIRTUALIZATION which has unmet direct dependencies (HAVE_KVM) Signed-off-by: Markos Chandras Acked-by: Steven J. Hill Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/5443/ Signed-off-by: Ralf Baechle --- arch/mips/kvm/Kconfig | 1 - 1 file changed, 1 deletion(-) diff --git a/arch/mips/kvm/Kconfig b/arch/mips/kvm/Kconfig index 2c15590e55f7..30e334e823bd 100644 --- a/arch/mips/kvm/Kconfig +++ b/arch/mips/kvm/Kconfig @@ -5,7 +5,6 @@ source "virt/kvm/Kconfig" menuconfig VIRTUALIZATION bool "Virtualization" - depends on HAVE_KVM ---help--- Say Y here to get to see options for using your Linux host to run other operating systems inside virtual machines (guests). From 53ae3acd4390ffeecb3a11dbd5be347b5a3d98f2 Mon Sep 17 00:00:00 2001 From: Catalin Marinas Date: Fri, 19 Jul 2013 15:08:15 +0100 Subject: [PATCH 1035/1048] arm64: Only enable local interrupts after the CPU is marked online There is a slight chance that (timer) interrupts are triggered before a secondary CPU has been marked online with implications on softirq thread affinity. Signed-off-by: Catalin Marinas Reported-by: Kirill Tkhai --- arch/arm64/kernel/smp.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c index 5d54e3717bf8..9c93e126328c 100644 --- a/arch/arm64/kernel/smp.c +++ b/arch/arm64/kernel/smp.c @@ -199,13 +199,6 @@ asmlinkage void __cpuinit secondary_start_kernel(void) raw_spin_lock(&boot_lock); raw_spin_unlock(&boot_lock); - /* - * Enable local interrupts. - */ - notify_cpu_starting(cpu); - local_irq_enable(); - local_fiq_enable(); - /* * OK, now it's safe to let the boot CPU continue. Wait for * the CPU migration code to notice that the CPU is online @@ -214,6 +207,14 @@ asmlinkage void __cpuinit secondary_start_kernel(void) set_cpu_online(cpu, true); complete(&cpu_running); + /* + * Enable GIC and timers. + */ + notify_cpu_starting(cpu); + + local_irq_enable(); + local_fiq_enable(); + /* * OK, it's off to the idle thread for us */ From c783c2815e13bbb0c0b99997cc240bd7e91b6bb8 Mon Sep 17 00:00:00 2001 From: Chen Gang Date: Mon, 24 Jun 2013 10:27:49 +0100 Subject: [PATCH 1036/1048] arm64: add '#ifdef CONFIG_COMPAT' for aarch32_break_handler() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If 'COMPAT' not defined, aarch32_break_handler() cannot pass compiling, and it can work independent with 'COMPAT', so remove dummy definition. The related error: arch/arm64/kernel/debug-monitors.c:249:5: error: redefinition of ‘aarch32_break_handler’ In file included from arch/arm64/kernel/debug-monitors.c:29:0: /root/linux-next/arch/arm64/include/asm/debug-monitors.h:89:12: note: previous definition of ‘aarch32_break_handler’ was here Signed-off-by: Chen Gang Acked-by: Will Deacon Signed-off-by: Catalin Marinas --- arch/arm64/include/asm/debug-monitors.h | 7 ------- 1 file changed, 7 deletions(-) diff --git a/arch/arm64/include/asm/debug-monitors.h b/arch/arm64/include/asm/debug-monitors.h index ef8235c68c09..a2232d07be9d 100644 --- a/arch/arm64/include/asm/debug-monitors.h +++ b/arch/arm64/include/asm/debug-monitors.h @@ -83,14 +83,7 @@ static inline int reinstall_suspended_bps(struct pt_regs *regs) } #endif -#ifdef CONFIG_COMPAT int aarch32_break_handler(struct pt_regs *regs); -#else -static int aarch32_break_handler(struct pt_regs *regs) -{ - return -EFAULT; -} -#endif #endif /* __ASSEMBLY */ #endif /* __KERNEL__ */ From db6f41063cbdb58b14846e600e6bc3f4e4c2e888 Mon Sep 17 00:00:00 2001 From: Will Deacon Date: Fri, 19 Jul 2013 15:37:12 +0100 Subject: [PATCH 1037/1048] arm64: mm: don't treat user cache maintenance faults as writes On arm64, cache maintenance faults appear as data aborts with the CM bit set in the ESR. The WnR bit, usually used to distinguish between faulting loads and stores, always reads as 1 and (slightly confusingly) the instructions are treated as reads by the architecture. This patch fixes our fault handling code to treat cache maintenance faults in the same way as loads. Signed-off-by: Will Deacon Cc: Signed-off-by: Catalin Marinas --- arch/arm64/mm/fault.c | 46 +++++++++++++++++++------------------------ 1 file changed, 20 insertions(+), 26 deletions(-) diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c index 0ecac8980aae..6c8ba25bf6bb 100644 --- a/arch/arm64/mm/fault.c +++ b/arch/arm64/mm/fault.c @@ -152,25 +152,8 @@ void do_bad_area(unsigned long addr, unsigned int esr, struct pt_regs *regs) #define ESR_CM (1 << 8) #define ESR_LNX_EXEC (1 << 24) -/* - * Check that the permissions on the VMA allow for the fault which occurred. - * If we encountered a write fault, we must have write permission, otherwise - * we allow any permission. - */ -static inline bool access_error(unsigned int esr, struct vm_area_struct *vma) -{ - unsigned int mask = VM_READ | VM_WRITE | VM_EXEC; - - if (esr & ESR_WRITE) - mask = VM_WRITE; - if (esr & ESR_LNX_EXEC) - mask = VM_EXEC; - - return vma->vm_flags & mask ? false : true; -} - static int __do_page_fault(struct mm_struct *mm, unsigned long addr, - unsigned int esr, unsigned int flags, + unsigned int mm_flags, unsigned long vm_flags, struct task_struct *tsk) { struct vm_area_struct *vma; @@ -188,12 +171,17 @@ static int __do_page_fault(struct mm_struct *mm, unsigned long addr, * it. */ good_area: - if (access_error(esr, vma)) { + /* + * Check that the permissions on the VMA allow for the fault which + * occurred. If we encountered a write or exec fault, we must have + * appropriate permissions, otherwise we allow any permission. + */ + if (!(vma->vm_flags & vm_flags)) { fault = VM_FAULT_BADACCESS; goto out; } - return handle_mm_fault(mm, vma, addr & PAGE_MASK, flags); + return handle_mm_fault(mm, vma, addr & PAGE_MASK, mm_flags); check_stack: if (vma->vm_flags & VM_GROWSDOWN && !expand_stack(vma, addr)) @@ -208,9 +196,15 @@ static int __kprobes do_page_fault(unsigned long addr, unsigned int esr, struct task_struct *tsk; struct mm_struct *mm; int fault, sig, code; - bool write = (esr & ESR_WRITE) && !(esr & ESR_CM); - unsigned int flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE | - (write ? FAULT_FLAG_WRITE : 0); + unsigned long vm_flags = VM_READ | VM_WRITE | VM_EXEC; + unsigned int mm_flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE; + + if (esr & ESR_LNX_EXEC) { + vm_flags = VM_EXEC; + } else if ((esr & ESR_WRITE) && !(esr & ESR_CM)) { + vm_flags = VM_WRITE; + mm_flags |= FAULT_FLAG_WRITE; + } tsk = current; mm = tsk->mm; @@ -248,7 +242,7 @@ retry: #endif } - fault = __do_page_fault(mm, addr, esr, flags, tsk); + fault = __do_page_fault(mm, addr, mm_flags, vm_flags, tsk); /* * If we need to retry but a fatal signal is pending, handle the @@ -265,7 +259,7 @@ retry: */ perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS, 1, regs, addr); - if (flags & FAULT_FLAG_ALLOW_RETRY) { + if (mm_flags & FAULT_FLAG_ALLOW_RETRY) { if (fault & VM_FAULT_MAJOR) { tsk->maj_flt++; perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MAJ, 1, regs, @@ -280,7 +274,7 @@ retry: * Clear FAULT_FLAG_ALLOW_RETRY to avoid any risk of * starvation. */ - flags &= ~FAULT_FLAG_ALLOW_RETRY; + mm_flags &= ~FAULT_FLAG_ALLOW_RETRY; goto retry; } } From ff701306cd49aaff80fb852323b387812bc76491 Mon Sep 17 00:00:00 2001 From: Marc Zyngier Date: Thu, 11 Jul 2013 12:13:00 +0100 Subject: [PATCH 1038/1048] arm64: use common reboot infrastructure Commit 7b6d864b48d9 (reboot: arm: change reboot_mode to use enum reboot_mode) changed the way reboot is handled on arm, which has a direct impact on arm64 as we share the reset driver on the VE platform. The obvious fix is to move arm64 to use the same infrastructure. Signed-off-by: Marc Zyngier [catalin.marinas@arm.com: removed reboot_mode = REBOOT_HARD default setting] Signed-off-by: Catalin Marinas --- arch/arm64/include/asm/system_misc.h | 3 ++- arch/arm64/kernel/process.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/arch/arm64/include/asm/system_misc.h b/arch/arm64/include/asm/system_misc.h index a6e1750369ef..7a18fabbe0f6 100644 --- a/arch/arm64/include/asm/system_misc.h +++ b/arch/arm64/include/asm/system_misc.h @@ -23,6 +23,7 @@ #include #include #include +#include struct pt_regs; @@ -41,7 +42,7 @@ extern void show_pte(struct mm_struct *mm, unsigned long addr); extern void __show_regs(struct pt_regs *); void soft_restart(unsigned long); -extern void (*arm_pm_restart)(char str, const char *cmd); +extern void (*arm_pm_restart)(enum reboot_mode reboot_mode, const char *cmd); #define UDBG_UNDEFINED (1 << 0) #define UDBG_SYSCALL (1 << 1) diff --git a/arch/arm64/kernel/process.c b/arch/arm64/kernel/process.c index 46f02c3b5015..1788bf6b471f 100644 --- a/arch/arm64/kernel/process.c +++ b/arch/arm64/kernel/process.c @@ -132,7 +132,7 @@ void machine_restart(char *cmd) /* Now call the architecture specific reboot code. */ if (arm_pm_restart) - arm_pm_restart('h', cmd); + arm_pm_restart(reboot_mode, cmd); /* * Whoops - the architecture was unable to reboot. From 3c8f24225752fba30f7265202ce6092318ed9fac Mon Sep 17 00:00:00 2001 From: Josef Bacik Date: Mon, 15 Jul 2013 11:57:06 -0400 Subject: [PATCH 1039/1048] Btrfs: update drop progress before stopping snapshot dropping Alex pointed out a problem and fix that exists in the drop one snapshot at a time patch. If we decide we need to exit for whatever reason (umount for example) we will just exit the snapshot dropping without updating the drop progress. So the next time we go to resume we will BUG_ON() because we can't find the extent we left off at because we never updated it. This patch fixes the problem. Cc: stable@vger.kernel.org Reported-by: Alex Lyakas Signed-off-by: Josef Bacik --- fs/btrfs/extent-tree.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 0236de711989..a429704dd95f 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -7552,11 +7552,6 @@ int btrfs_drop_snapshot(struct btrfs_root *root, wc->reada_count = BTRFS_NODEPTRS_PER_BLOCK(root); while (1) { - if (!for_reloc && btrfs_need_cleaner_sleep(root)) { - pr_debug("btrfs: drop snapshot early exit\n"); - err = -EAGAIN; - goto out_end_trans; - } ret = walk_down_tree(trans, root, path, wc); if (ret < 0) { @@ -7584,7 +7579,8 @@ int btrfs_drop_snapshot(struct btrfs_root *root, } BUG_ON(wc->level == 0); - if (btrfs_should_end_transaction(trans, tree_root)) { + if (btrfs_should_end_transaction(trans, tree_root) || + (!for_reloc && btrfs_need_cleaner_sleep(root))) { ret = btrfs_update_root(trans, tree_root, &root->root_key, root_item); @@ -7595,6 +7591,12 @@ int btrfs_drop_snapshot(struct btrfs_root *root, } btrfs_end_transaction_throttle(trans, tree_root); + if (!for_reloc && btrfs_need_cleaner_sleep(root)) { + pr_debug("btrfs: drop snapshot early exit\n"); + err = -EAGAIN; + goto out_free; + } + trans = btrfs_start_transaction(tree_root, 0); if (IS_ERR(trans)) { err = PTR_ERR(trans); From fec386ac1428f9c0e672df952cbca5cebd4e4e2f Mon Sep 17 00:00:00 2001 From: Josef Bacik Date: Mon, 15 Jul 2013 12:41:42 -0400 Subject: [PATCH 1040/1048] Btrfs: fix lock leak when resuming snapshot deletion We aren't setting path->locks[level] when we resume a snapshot deletion which means we won't unlock the buffer when we free the path. This causes deadlocks if we happen to re-allocate the block before we've evicted the extent buffer from cache. Thanks, Cc: stable@vger.kernel.org Reported-by: Alex Lyakas Signed-off-by: Josef Bacik --- fs/btrfs/extent-tree.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index a429704dd95f..e814b1312511 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -7523,6 +7523,7 @@ int btrfs_drop_snapshot(struct btrfs_root *root, while (1) { btrfs_tree_lock(path->nodes[level]); btrfs_set_lock_blocking(path->nodes[level]); + path->locks[level] = BTRFS_WRITE_LOCK_BLOCKING; ret = btrfs_lookup_extent_info(trans, root, path->nodes[level]->start, @@ -7538,6 +7539,7 @@ int btrfs_drop_snapshot(struct btrfs_root *root, break; btrfs_tree_unlock(path->nodes[level]); + path->locks[level] = 0; WARN_ON(wc->refs[level] != 1); level--; } From d29a9f629e009c9b90e5859bce581070fd6247fc Mon Sep 17 00:00:00 2001 From: Josef Bacik Date: Wed, 17 Jul 2013 19:30:20 -0400 Subject: [PATCH 1041/1048] Btrfs: re-add root to dead root list if we stop dropping it If we stop dropping a root for whatever reason we need to add it back to the dead root list so that we will re-start the dropping next transaction commit. The other case this happens is if we recover a drop because we will add a root without adding it to the fs radix tree, so we can leak it's root and commit root extent buffer, adding this to the dead root list makes this cleanup happen. Thanks, Cc: stable@vger.kernel.org Reported-by: Alex Lyakas Signed-off-by: Josef Bacik --- fs/btrfs/extent-tree.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index e814b1312511..1204c8ef6f32 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -7466,6 +7466,7 @@ int btrfs_drop_snapshot(struct btrfs_root *root, int err = 0; int ret; int level; + bool root_dropped = false; path = btrfs_alloc_path(); if (!path) { @@ -7643,12 +7644,22 @@ int btrfs_drop_snapshot(struct btrfs_root *root, free_extent_buffer(root->commit_root); btrfs_put_fs_root(root); } + root_dropped = true; out_end_trans: btrfs_end_transaction_throttle(trans, tree_root); out_free: kfree(wc); btrfs_free_path(path); out: + /* + * So if we need to stop dropping the snapshot for whatever reason we + * need to make sure to add it back to the dead root list so that we + * keep trying to do the work later. This also cleans up roots if we + * don't have it in the radix (like when we recover after a power fail + * or unmount) so we don't leak memory. + */ + if (root_dropped == false) + btrfs_add_dead_root(root); if (err) btrfs_std_error(root->fs_info, err); return err; From 115930cb2d444a684975cf2325759cb48ebf80cc Mon Sep 17 00:00:00 2001 From: Stefan Behrens Date: Thu, 4 Jul 2013 16:14:23 +0200 Subject: [PATCH 1042/1048] Btrfs: fix wrong write offset when replacing a device Miao Xie reported the following issue: The filesystem was corrupted after we did a device replace. Steps to reproduce: # mkfs.btrfs -f -m single -d raid10 .. # mount # btrfs replace start -rfB 1 # umount # btrfsck The reason for the issue is that we changed the write offset by mistake, introduced by commit 625f1c8dc. We read the data from the source device at first, and then write the data into the corresponding place of the new device. In order to implement the "-r" option, the source location is remapped using btrfs_map_block(). The read takes place on the mapped location, and the write needs to take place on the unmapped location. Currently the write is using the mapped location, and this commit changes it back by undoing the change to the write address that the aforementioned commit added by mistake. Reported-by: Miao Xie Cc: # 3.10+ Signed-off-by: Stefan Behrens Signed-off-by: Josef Bacik --- fs/btrfs/scrub.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c index 4ba2a69a60ad..64a157becbe5 100644 --- a/fs/btrfs/scrub.c +++ b/fs/btrfs/scrub.c @@ -2495,7 +2495,7 @@ again: ret = scrub_extent(sctx, extent_logical, extent_len, extent_physical, extent_dev, flags, generation, extent_mirror_num, - extent_physical); + extent_logical - logical + physical); if (ret) goto out; From ba57ea64cb1820deb37637de0fdb107f0dc90089 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sat, 20 Jul 2013 03:11:32 +0400 Subject: [PATCH 1043/1048] allow O_TMPFILE to work with O_WRONLY Signed-off-by: Al Viro --- fs/open.c | 2 ++ include/uapi/asm-generic/fcntl.h | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/fs/open.c b/fs/open.c index 9156cb050d08..d53e29895082 100644 --- a/fs/open.c +++ b/fs/open.c @@ -844,6 +844,8 @@ static inline int build_open_flags(int flags, umode_t mode, struct open_flags *o if ((flags & O_TMPFILE_MASK) != O_TMPFILE) return -EINVAL; acc_mode = MAY_OPEN | ACC_MODE(flags); + if (!(acc_mode & MAY_WRITE)) + return -EINVAL; } else if (flags & O_PATH) { /* * If we have O_PATH in the open flag. Then we diff --git a/include/uapi/asm-generic/fcntl.h b/include/uapi/asm-generic/fcntl.h index 05ac354e124d..95e46c8e05f9 100644 --- a/include/uapi/asm-generic/fcntl.h +++ b/include/uapi/asm-generic/fcntl.h @@ -89,8 +89,8 @@ #endif /* a horrid kludge trying to make sure that this will fail on old kernels */ -#define O_TMPFILE (__O_TMPFILE | O_DIRECTORY | O_RDWR) -#define O_TMPFILE_MASK (__O_TMPFILE | O_DIRECTORY | O_CREAT | O_ACCMODE) +#define O_TMPFILE (__O_TMPFILE | O_DIRECTORY) +#define O_TMPFILE_MASK (__O_TMPFILE | O_DIRECTORY | O_CREAT) #ifndef O_NDELAY #define O_NDELAY O_NONBLOCK From acfec9a5a892f98461f52ed5770de99a3e571ae2 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sat, 20 Jul 2013 03:13:55 +0400 Subject: [PATCH 1044/1048] livelock avoidance in sget() Eric Sandeen has found a nasty livelock in sget() - take a mount(2) about to fail. The superblock is on ->fs_supers, ->s_umount is held exclusive, ->s_active is 1. Along comes two more processes, trying to mount the same thing; sget() in each is picking that superblock, bumping ->s_count and trying to grab ->s_umount. ->s_active is 3 now. Original mount(2) finally gets to deactivate_locked_super() on failure; ->s_active is 2, superblock is still ->fs_supers because shutdown will *not* happen until ->s_active hits 0. ->s_umount is dropped and now we have two processes chasing each other: s_active = 2, A acquired ->s_umount, B blocked A sees that the damn thing is stillborn, does deactivate_locked_super() s_active = 1, A drops ->s_umount, B gets it A restarts the search and finds the same superblock. And bumps it ->s_active. s_active = 2, B holds ->s_umount, A blocked on trying to get it ... and we are in the earlier situation with A and B switched places. The root cause, of course, is that ->s_active should not grow until we'd got MS_BORN. Then failing ->mount() will have deactivate_locked_super() shut the damn thing down. Fortunately, it's easy to do - the key point is that grab_super() is called only for superblocks currently on ->fs_supers, so it can bump ->s_count and grab ->s_umount first, then check MS_BORN and bump ->s_active; we must never increment ->s_count for superblocks past ->kill_sb(), but grab_super() is never called for those. The bug is pretty old; we would've caught it by now, if not for accidental exclusion between sget() for block filesystems; the things like cgroup or e.g. mtd-based filesystems don't have anything of that sort, so they get bitten. The right way to deal with that is obviously to fix sget()... Signed-off-by: Al Viro --- fs/super.c | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/fs/super.c b/fs/super.c index 7465d4364208..68307c029228 100644 --- a/fs/super.c +++ b/fs/super.c @@ -336,19 +336,19 @@ EXPORT_SYMBOL(deactivate_super); * and want to turn it into a full-blown active reference. grab_super() * is called with sb_lock held and drops it. Returns 1 in case of * success, 0 if we had failed (superblock contents was already dead or - * dying when grab_super() had been called). + * dying when grab_super() had been called). Note that this is only + * called for superblocks not in rundown mode (== ones still on ->fs_supers + * of their type), so increment of ->s_count is OK here. */ static int grab_super(struct super_block *s) __releases(sb_lock) { - if (atomic_inc_not_zero(&s->s_active)) { - spin_unlock(&sb_lock); - return 1; - } - /* it's going away */ s->s_count++; spin_unlock(&sb_lock); - /* wait for it to die */ down_write(&s->s_umount); + if ((s->s_flags & MS_BORN) && atomic_inc_not_zero(&s->s_active)) { + put_super(s); + return 1; + } up_write(&s->s_umount); put_super(s); return 0; @@ -463,11 +463,6 @@ retry: destroy_super(s); s = NULL; } - down_write(&old->s_umount); - if (unlikely(!(old->s_flags & MS_BORN))) { - deactivate_locked_super(old); - goto retry; - } return old; } } @@ -660,10 +655,10 @@ restart: if (hlist_unhashed(&sb->s_instances)) continue; if (sb->s_bdev == bdev) { - if (grab_super(sb)) /* drops sb_lock */ - return sb; - else + if (!grab_super(sb)) goto restart; + up_write(&sb->s_umount); + return sb; } } spin_unlock(&sb_lock); From 24924a20dab603089011f9d3eb7622f0f6ef93c0 Mon Sep 17 00:00:00 2001 From: Peng Tao Date: Thu, 18 Jul 2013 22:09:08 +0800 Subject: [PATCH 1045/1048] vfs: constify dentry parameter in d_count() so that it can be used in places like d_compare/d_hash without causing a compiler warning. Signed-off-by: Peng Tao Signed-off-by: Al Viro --- include/linux/dcache.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/dcache.h b/include/linux/dcache.h index 3092df3614ae..b90337c9d468 100644 --- a/include/linux/dcache.h +++ b/include/linux/dcache.h @@ -324,7 +324,7 @@ static inline int __d_rcu_to_refcount(struct dentry *dentry, unsigned seq) return ret; } -static inline unsigned d_count(struct dentry *dentry) +static inline unsigned d_count(const struct dentry *dentry) { return dentry->d_count; } From e94bd3490f4ef342801cfc76b33d8baf9ccc9437 Mon Sep 17 00:00:00 2001 From: Zheng Liu Date: Sat, 20 Jul 2013 21:58:38 -0400 Subject: [PATCH 1046/1048] ext4: fix a BUG when opening a file with O_TMPFILE flag When we try to open a file with O_TMPFILE flag, we will trigger a bug. The root cause is that in ext4_orphan_add() we check ->i_nlink == 0 and this check always fails because we set ->i_nlink = 1 in inode_init_always(). We can use the following program to trigger it: int main(int argc, char *argv[]) { int fd; fd = open(argv[1], O_TMPFILE, 0666); if (fd < 0) { perror("open "); return -1; } close(fd); return 0; } The oops message looks like this: kernel BUG at fs/ext4/namei.c:2572! invalid opcode: 0000 [#1] PREEMPT SMP DEBUG_PAGEALLOC Modules linked in: dlci bridge stp hidp cmtp kernelcapi l2tp_ppp l2tp_netlink l2tp_core sctp libcrc32c rfcomm tun fuse nfnetli nk can_raw ipt_ULOG can_bcm x25 scsi_transport_iscsi ipx p8023 p8022 appletalk phonet psnap vmw_vsock_vmci_transport af_key vmw_vmci rose vsock atm can netrom ax25 af_rxrpc ir da pppoe pppox ppp_generic slhc bluetooth nfc rfkill rds caif_socket caif crc_ccitt af_802154 llc2 llc snd_hda_codec_realtek snd_hda_intel snd_hda_codec serio_raw snd_pcm pcsp kr edac_core snd_page_alloc snd_timer snd soundcore r8169 mii sr_mod cdrom pata_atiixp radeon backlight drm_kms_helper ttm CPU: 1 PID: 1812571 Comm: trinity-child2 Not tainted 3.11.0-rc1+ #12 Hardware name: Gigabyte Technology Co., Ltd. GA-MA78GM-S2H/GA-MA78GM-S2H, BIOS F12a 04/23/2010 task: ffff88007dfe69a0 ti: ffff88010f7b6000 task.ti: ffff88010f7b6000 RIP: 0010:[] [] ext4_orphan_add+0x299/0x2b0 RSP: 0018:ffff88010f7b7cf8 EFLAGS: 00010202 RAX: 0000000000000000 RBX: ffff8800966d3020 RCX: 0000000000000000 RDX: 0000000000000000 RSI: ffff88007dfe70b8 RDI: 0000000000000001 RBP: ffff88010f7b7d40 R08: ffff880126a3c4e0 R09: ffff88010f7b7ca0 R10: 0000000000000000 R11: 0000000000000000 R12: ffff8801271fd668 R13: ffff8800966d2f78 R14: ffff88011d7089f0 R15: ffff88007dfe69a0 FS: 00007f70441a3740(0000) GS:ffff88012a800000(0000) knlGS:00000000f77c96c0 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000000002834000 CR3: 0000000107964000 CR4: 00000000000007e0 DR0: 0000000000780000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000600 Stack: 0000000000002000 00000020810b6dde 0000000000000000 ffff88011d46db00 ffff8800966d3020 ffff88011d7089f0 ffff88009c7f4c10 ffff88010f7b7f2c ffff88007dfe69a0 ffff88010f7b7da8 ffffffff8125cfac ffff880100000004 Call Trace: [] ext4_tmpfile+0x12c/0x180 [] path_openat+0x238/0x700 [] ? native_sched_clock+0x24/0x80 [] do_filp_open+0x47/0xa0 [] ? __alloc_fd+0xaf/0x200 [] do_sys_open+0x124/0x210 [] ? syscall_trace_enter+0x25/0x290 [] SyS_open+0x1e/0x20 [] tracesys+0xdd/0xe2 [] ? start_thread_common.constprop.6+0x1/0xa0 Code: 04 00 00 00 89 04 24 31 c0 e8 c4 77 04 00 e9 43 fe ff ff 66 25 00 d0 66 3d 00 80 0f 84 0e fe ff ff 83 7b 48 00 0f 84 04 fe ff ff <0f> 0b 49 8b 8c 24 50 07 00 00 e9 88 fe ff ff 0f 1f 84 00 00 00 Here we couldn't call clear_nlink() directly because in d_tmpfile() we will call inode_dec_link_count() to decrease ->i_nlink. So this commit tries to call d_tmpfile() before ext4_orphan_add() to fix this problem. Reported-by: Dave Jones Signed-off-by: Zheng Liu Tested-by: Darrick J. Wong Tested-by: Dave Jones Signed-off-by: "Theodore Ts'o" Acked-by: Al Viro --- fs/ext4/namei.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c index 234b834d5a97..35f55a0dbc4b 100644 --- a/fs/ext4/namei.c +++ b/fs/ext4/namei.c @@ -2316,11 +2316,11 @@ retry: inode->i_op = &ext4_file_inode_operations; inode->i_fop = &ext4_file_operations; ext4_set_aops(inode); + d_tmpfile(dentry, inode); err = ext4_orphan_add(handle, inode); if (err) goto err_drop_inode; mark_inode_dirty(inode); - d_tmpfile(dentry, inode); unlock_new_inode(inode); } if (handle) From dda5690defe4af62ee120f055e98e40d97e4c760 Mon Sep 17 00:00:00 2001 From: Zheng Liu Date: Sat, 20 Jul 2013 22:03:20 -0400 Subject: [PATCH 1047/1048] ext3: fix a BUG when opening a file with O_TMPFILE flag When we try to open a file with O_TMPFILE flag, we will trigger a bug. The root cause is that in ext4_orphan_add() we check ->i_nlink == 0 and this check always fails because we set ->i_nlink = 1 in inode_init_always(). We can use the following program to trigger it: int main(int argc, char *argv[]) { int fd; fd = open(argv[1], O_TMPFILE, 0666); if (fd < 0) { perror("open "); return -1; } close(fd); return 0; } The oops message looks like this: kernel: kernel BUG at fs/ext3/namei.c:1992! kernel: invalid opcode: 0000 [#1] SMP kernel: Modules linked in: ext4 jbd2 crc16 cpufreq_ondemand ipv6 dm_mirror dm_region_hash dm_log dm_mod parport_pc parport serio_raw sg dcdbas pcspkr i2c_i801 ehci_pci ehci_hcd button acpi_cpufreq mperf e1000e ptp pps_core ttm drm_kms_helper drm hwmon i2c_algo_bit i2c_core ext3 jbd sd_mod ahci libahci libata scsi_mod uhci_hcd kernel: CPU: 0 PID: 2882 Comm: tst_tmpfile Not tainted 3.11.0-rc1+ #4 kernel: Hardware name: Dell Inc. OptiPlex 780 /0V4W66, BIOS A05 08/11/2010 kernel: task: ffff880112d30050 ti: ffff8801124d4000 task.ti: ffff8801124d4000 kernel: RIP: 0010:[] [] ext3_orphan_add+0x6a/0x1eb [ext3] kernel: RSP: 0018:ffff8801124d5cc8 EFLAGS: 00010202 kernel: RAX: 0000000000000000 RBX: ffff880111510128 RCX: ffff8801114683a0 kernel: RDX: 0000000000000000 RSI: ffff880111510128 RDI: ffff88010fcf65a8 kernel: RBP: ffff8801124d5d18 R08: 0080000000000000 R09: ffffffffa00d3b7f kernel: R10: ffff8801114683a0 R11: ffff8801032a2558 R12: 0000000000000000 kernel: R13: ffff88010fcf6800 R14: ffff8801032a2558 R15: ffff8801115100d8 kernel: FS: 00007f5d172b5700(0000) GS:ffff880117c00000(0000) knlGS:0000000000000000 kernel: CS: 0010 DS: 0000 ES: 0000 CR0: 000000008005003b kernel: CR2: 00007f5d16df15d0 CR3: 0000000110b1d000 CR4: 00000000000407f0 kernel: Stack: kernel: 000000000000000c ffff8801048a7dc8 ffff8801114685a8 ffffffffa00b80d7 kernel: ffff8801124d5e38 ffff8801032a2558 ffff88010ce24d68 0000000000000000 kernel: ffff88011146b300 ffff8801124d5d44 ffff8801124d5d78 ffffffffa00db7e1 kernel: Call Trace: kernel: [] ? journal_start+0x8c/0xbd [jbd] kernel: [] ext3_tmpfile+0xb2/0x13b [ext3] kernel: [] path_openat+0x11f/0x5e7 kernel: [] ? list_del+0x11/0x30 kernel: [] ? __dequeue_entity+0x33/0x38 kernel: [] do_filp_open+0x3f/0x8d kernel: [] ? __alloc_fd+0x50/0x102 kernel: [] do_sys_open+0x13b/0x1cd kernel: [] SyS_open+0x1e/0x20 kernel: [] system_call_fastpath+0x16/0x1b kernel: Code: 39 c7 0f 85 67 01 00 00 0f b7 03 25 00 f0 00 00 3d 00 40 00 00 74 18 3d 00 80 00 00 74 11 3d 00 a0 00 00 74 0a 83 7b 48 00 74 04 <0f> 0b eb fe 49 8b 85 50 03 00 00 4c 89 f6 48 c7 c7 c0 99 0e a0 kernel: RIP [] ext3_orphan_add+0x6a/0x1eb [ext3] kernel: RSP Here we couldn't call clear_nlink() directly because in d_tmpfile() we will call inode_dec_link_count() to decrease ->i_nlink. So this commit tries to call d_tmpfile() before ext4_orphan_add() to fix this problem. Signed-off-by: Zheng Liu Signed-off-by: "Theodore Ts'o" Cc: Jan Kara Cc: Al Viro --- fs/ext3/namei.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/ext3/namei.c b/fs/ext3/namei.c index 998ea111e537..1194b1f0f839 100644 --- a/fs/ext3/namei.c +++ b/fs/ext3/namei.c @@ -1780,11 +1780,11 @@ retry: inode->i_op = &ext3_file_inode_operations; inode->i_fop = &ext3_file_operations; ext3_set_aops(inode); + d_tmpfile(dentry, inode); err = ext3_orphan_add(handle, inode); if (err) goto err_drop_inode; mark_inode_dirty(inode); - d_tmpfile(dentry, inode); unlock_new_inode(inode); } ext3_journal_stop(handle); From 3b2f64d00c46e1e4e9bd0bb9bb12619adac27a4b Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Sun, 21 Jul 2013 12:05:29 -0700 Subject: [PATCH 1048/1048] Linux 3.11-rc2 --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 9262ba8da4f9..a35f72a420c0 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ VERSION = 3 PATCHLEVEL = 11 SUBLEVEL = 0 -EXTRAVERSION = -rc1 +EXTRAVERSION = -rc2 NAME = Linux for Workgroups # *DOCUMENTATION*